From 94ea825f95db397756129575ea9f7cd4df347f7c Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Fri, 5 Aug 2016 16:20:16 -0700 Subject: [PATCH 001/173] Api Changes and simple superfixes --- src/services/codefixes/codeFixProvider.ts | 53 ++++++++++++++++++ src/services/codefixes/references.ts | 6 +++ src/services/codefixes/superFixes.ts | 65 +++++++++++++++++++++++ src/services/services.ts | 49 ++++++++++++++++- src/services/shims.ts | 19 +++++++ src/services/tsconfig.json | 5 +- 6 files changed, 194 insertions(+), 3 deletions(-) create mode 100644 src/services/codefixes/codeFixProvider.ts create mode 100644 src/services/codefixes/references.ts create mode 100644 src/services/codefixes/superFixes.ts diff --git a/src/services/codefixes/codeFixProvider.ts b/src/services/codefixes/codeFixProvider.ts new file mode 100644 index 00000000000..ca877aef46a --- /dev/null +++ b/src/services/codefixes/codeFixProvider.ts @@ -0,0 +1,53 @@ +/* @internal */ +namespace ts { + export interface CodeFix { + name: string; + errorCodes: string[]; + getCodeActions(context: CodeFixContext): CodeAction[]; + } + + export interface CodeFixContext { + errorCode: string; + sourceFile: SourceFile; + span: TextSpan; + checker: TypeChecker; + newLineCharacter: string; + } + + export namespace codeFix { + const codeFixes: Map = {}; + + export function registerCodeFix(action: CodeFix) { + forEach(action.errorCodes, error => { + let fixes = codeFixes[error]; + if (!fixes) { + fixes = []; + codeFixes[error] = fixes; + } + fixes.push(action); + }); + } + + export class CodeFixProvider { + public static getSupportedErrorCodes() { + return getKeys(codeFixes); + } + + public getFixes(context: CodeFixContext): CodeAction[] { + const fixes = codeFixes[context.errorCode]; + let allActions: CodeAction[] = []; + + Debug.assert(fixes && fixes.length > 0, "No fixes found for error: '${errorCode}'."); + + forEach(fixes, f => { + const actions = f.getCodeActions(context); + if (actions && actions.length > 0) { + allActions = allActions.concat(actions); + } + }); + + return allActions; + } + } + } +} \ No newline at end of file diff --git a/src/services/codefixes/references.ts b/src/services/codefixes/references.ts new file mode 100644 index 00000000000..3675d626678 --- /dev/null +++ b/src/services/codefixes/references.ts @@ -0,0 +1,6 @@ +/// +/// +/// +/// +/// +/// diff --git a/src/services/codefixes/superFixes.ts b/src/services/codefixes/superFixes.ts new file mode 100644 index 00000000000..2c6a67de513 --- /dev/null +++ b/src/services/codefixes/superFixes.ts @@ -0,0 +1,65 @@ +/* @internal */ +namespace ts.codeFix { + function getOpenBraceEnd(constructor: ConstructorDeclaration, sourceFile: SourceFile) { + // First token is the open curly, this is where we want to put the 'super' call. + return constructor.body.getFirstToken(sourceFile).getEnd(); + } + + registerCodeFix({ + name: "AddMissingSuperCallFix", + errorCodes: ["TS2377"], + getCodeActions: (context: CodeFixContext) => { + const sourceFile = context.sourceFile; + const token = getTokenAtPosition(sourceFile, context.span.start); + Debug.assert(token.kind === SyntaxKind.ConstructorKeyword, "Failed to find the constructor."); + + const newPosition = getOpenBraceEnd(token.parent, sourceFile); + return [{ + description: getLocaleSpecificMessage(Diagnostics.Add_missing_super_call), + changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "super();", span: { start: newPosition, length: 0 } }] }] + }]; + } + }); + + registerCodeFix({ + name: "MakeSuperCallTheFirstStatementInTheConstructor", + errorCodes: ["TS17009"], + getCodeActions: (context: CodeFixContext) => { + const sourceFile = context.sourceFile; + + const token = getTokenAtPosition(sourceFile, context.span.start); + const constructor = getContainingFunction(token); + Debug.assert(constructor.kind === SyntaxKind.Constructor, "Failed to find the constructor."); + + const superCall = findSuperCall((constructor).body); + Debug.assert(!!superCall, "Failed to find super call."); + + const newPosition = getOpenBraceEnd(constructor, sourceFile); + const changes = [{ + fileName: sourceFile.fileName, textChanges: [{ + newText: superCall.getText(sourceFile), + span: { start: newPosition, length: 0 } + }, + { + newText: "", + span: { start: superCall.getStart(sourceFile), length: superCall.getWidth(sourceFile) } + }] + }]; + + return [{ + description: getLocaleSpecificMessage(Diagnostics.Make_super_call_the_first_statement_in_the_constructor), + changes + }]; + + function findSuperCall(n: Node): Node { + if (n.kind === SyntaxKind.ExpressionStatement && isSuperCallExpression((n).expression)) { + return n; + } + if (isFunctionLike(n)) { + return undefined; + } + return forEachChild(n, findSuperCall); + } + } + }); +} \ No newline at end of file diff --git a/src/services/services.ts b/src/services/services.ts index aea4d5f872e..b189a6375b7 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -11,6 +11,7 @@ /// /// /// +/// namespace ts { /** The version of the language service API */ @@ -1237,6 +1238,8 @@ namespace ts { isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean; + getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): CodeAction[]; + getEmitOutput(fileName: string): EmitOutput; getProgram(): Program; @@ -1283,6 +1286,18 @@ namespace ts { newText: string; } + export interface FileTextChanges { + fileName: string; + textChanges: TextChange[]; + } + + export interface CodeAction { + /** Description of the code action to display in the UI of the editor */ + description: string; + /** Text changes to apply to each file as part of the code action */ + changes: FileTextChanges[]; + } + export interface TextInsertion { newText: string; /** The position in newText the caret should point to after the insertion. */ @@ -1886,9 +1901,13 @@ namespace ts { }; } - // Cache host information about script should be refreshed + export function getSupportedCodeFixes() { + return codeFix.CodeFixProvider.getSupportedErrorCodes(); + } + + // Cache host information about script Should be refreshed // at each language service public entry point, since we don't know when - // set of scripts handled by the host changes. + // the set of scripts handled by the host changes. class HostCache { private fileNameToEntry: FileMap; private _compilationSettings: CompilerOptions; @@ -3022,6 +3041,7 @@ namespace ts { documentRegistry: DocumentRegistry = createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory())): LanguageService { const syntaxTreeCache: SyntaxTreeCache = new SyntaxTreeCache(host); + const codeFixProvider: codeFix.CodeFixProvider = new codeFix.CodeFixProvider(); let ruleProvider: formatting.RulesProvider; let program: Program; let lastProjectVersion: string; @@ -7832,6 +7852,30 @@ namespace ts { return []; } + function getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): CodeAction[] { + synchronizeHostData(); + const sourceFile = getValidSourceFile(fileName); + const checker = program.getTypeChecker(); + let allFixes: CodeAction[] = []; + + forEach(errorCodes, error => { + const context = { + errorCode: error, + sourceFile: sourceFile, + span: { start, length: end - start }, + checker: checker, + newLineCharacter: getNewLineOrDefaultFromHost(host) + }; + + const fixes = codeFixProvider.getFixes(context); + if (fixes) { + allFixes = allFixes.concat(fixes); + } + }); + + return allFixes; + } + /** * Checks if position points to a valid position to add JSDoc comments, and if so, * returns the appropriate template. Otherwise returns an empty string. @@ -8302,6 +8346,7 @@ namespace ts { getFormattingEditsAfterKeystroke, getDocCommentTemplateAtPosition, isValidBraceCompletionAtPosition, + getCodeFixesAtPosition, getEmitOutput, getNonBoundSourceFile, getProgram diff --git a/src/services/shims.ts b/src/services/shims.ts index 45c4b284ae7..dfa34d29acc 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -240,6 +240,8 @@ namespace ts { */ isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): string; + getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: string): string; + getEmitOutput(fileName: string): string; getEmitOutputObject(fileName: string): EmitOutput; } @@ -255,6 +257,7 @@ namespace ts { getTSConfigFileInfo(fileName: string, sourceText: IScriptSnapshot): string; getDefaultCompilationSettings(): string; discoverTypings(discoverTypingsJson: string): string; + getSupportedCodeFixes(): string; } function logInternalError(logger: Logger, err: Error) { @@ -901,6 +904,16 @@ namespace ts { ); } + public getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: string): string { + return this.forwardJSONCall( + `getCodeFixesAtPosition( '${fileName}', ${start}, ${end}, ${errorCodes}')`, + () => { + const localErrors: string[] = JSON.parse(errorCodes); + return this.languageService.getCodeFixesAtPosition(fileName, start, end, localErrors); + } + ); + } + /// NAVIGATE TO /** Return a list of symbols that are interesting to navigate to */ @@ -1109,6 +1122,12 @@ namespace ts { info.compilerOptions); }); } + + public getSupportedCodeFixes(): string { + return this.forwardJSONCall("getSupportedCodeFixes()", + () => getSupportedCodeFixes() + ); + } } export class TypeScriptServicesFactory implements ShimFactory { diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index cfeb7c2fcd5..2cf75daa861 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -52,6 +52,9 @@ "formatting/rulesMap.ts", "formatting/rulesProvider.ts", "formatting/smartIndenter.ts", - "formatting/tokenRange.ts" + "formatting/tokenRange.ts", + "codeFixes/codeFixProvider.ts", + "codeFixes/references.ts", + "codeFixes/superFixes.ts" ] } From 466d26fc76ff9808383a8973bab4e662ae9b056b Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Fri, 5 Aug 2016 16:21:46 -0700 Subject: [PATCH 002/173] Fourslash support --- src/compiler/core.ts | 9 +++++ src/compiler/diagnosticMessages.json | 28 +++++++++++++++ src/compiler/types.ts | 1 + src/harness/fourslash.ts | 51 +++++++++++++++++++++++++-- src/harness/harnessLanguageService.ts | 3 ++ src/server/client.ts | 4 +++ tests/cases/fourslash/fourslash.ts | 1 + 7 files changed, 94 insertions(+), 3 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 6c87ad82955..b07c21fa4cb 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -115,6 +115,15 @@ namespace ts { return -1; } + export function firstOrUndefined(array: T[], predicate: (x: T) => boolean): T { + for (let i = 0, len = array.length; i < len; i++) { + if (predicate(array[i])) { + return array[i]; + } + } + return undefined; + } + export function indexOfAnyCharCode(text: string, charCodes: number[], start?: number): number { for (let i = start || 0, len = text.length; i < len; i++) { if (contains(charCodes, text.charCodeAt(i))) { diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 8126d5c605e..1dffc35c74c 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3031,5 +3031,33 @@ "Unknown typing option '{0}'.": { "category": "Error", "code": 17010 + }, + "Add missing 'super()' call.": { + "category": "CodeFix", + "code": 90001 + }, + "Make 'super()' call the first statement in the constructor.": { + "category": "CodeFix", + "code": 90002 + }, + "Change 'extends' to 'implements'": { + "category": "CodeFix", + "code": 90003 + }, + "Remove unused identifiers": { + "category": "CodeFix", + "code": 90004 + }, + "Implement interface on reference": { + "category": "CodeFix", + "code": 90005 + }, + "Implement interface on class": { + "category": "CodeFix", + "code": 90006 + }, + "Implement inherited abstract class": { + "category": "CodeFix", + "code": 90007 } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 28ededebb0d..e31a4b0ace1 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2547,6 +2547,7 @@ namespace ts { Warning, Error, Message, + CodeFix, } export enum ModuleResolutionKind { diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index a42abbbc609..91597d7f593 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -384,7 +384,7 @@ namespace FourSlash { if (exists !== negative) { this.printErrorLog(negative, this.getAllDiagnostics()); - throw new Error("Failure between markers: " + startMarkerName + ", " + endMarkerName); + throw new Error(`Failure between markers: '${startMarkerName}', '${endMarkerName}'`); } } @@ -638,7 +638,6 @@ namespace FourSlash { } } - public verifyCompletionListAllowsNewIdentifier(negative: boolean) { const completions = this.getCompletionListAtCaret(); @@ -1479,7 +1478,7 @@ namespace FourSlash { if (isFormattingEdit) { const newContent = this.getFileContent(fileName); - if (newContent.replace(/\s/g, "") !== oldContent.replace(/\s/g, "")) { + if (this.removeWhitespace(newContent) !== this.removeWhitespace(oldContent)) { this.raiseError("Formatting operation destroyed non-whitespace content"); } } @@ -1545,6 +1544,10 @@ namespace FourSlash { } } + private removeWhitespace(text: string): string { + return text.replace(/\s/g, ""); + } + public goToBOF() { this.goToPosition(0); } @@ -1862,6 +1865,44 @@ namespace FourSlash { } } + public verifyCodeFixAtPosition(expectedText: string, errorCode?: number) { + + const ranges = this.getRanges(); + if (ranges.length == 0) { + this.raiseError("At least one range should be specified in the testfile."); + } + + const fileName = this.activeFile.fileName; + const diagnostics = this.getDiagnostics(fileName); + + if (diagnostics.length === 0) { + this.raiseError("Errors expected."); + } + + if (diagnostics.length > 1 && !errorCode) { + this.raiseError("When there's more than one error, you must specify the errror to fix."); + } + + const diagnostic = !errorCode ? diagnostics[0] : ts.firstOrUndefined(diagnostics, d => d.code == errorCode); + + const actual = this.languageService.getCodeFixesAtPosition(fileName, diagnostic.start, diagnostic.length, [`TS${diagnostic.code}`]); + + if (!actual || actual.length == 0) { + this.raiseError("No codefixes returned."); + } + + if (actual.length > 1) { + this.raiseError("More than 1 codefix returned."); + } + + this.applyEdits(actual[0].changes[0].fileName, actual[0].changes[0].textChanges, /*isFormattingEdit*/ false); + const actualText = this.rangeText(ranges[0]); + + if (this.removeWhitespace(actualText) !== this.removeWhitespace(expectedText)) { + this.raiseError(`Actual text doesn't match expected text. Actual: '${actualText}' Expected: '${expectedText}'`); + } + } + public verifyDocCommentTemplate(expected?: ts.TextInsertion) { const name = "verifyDocCommentTemplate"; const actual = this.languageService.getDocCommentTemplateAtPosition(this.activeFile.fileName, this.currentCaretPosition); @@ -3066,6 +3107,10 @@ namespace FourSlashInterface { this.DocCommentTemplate(/*expectedText*/ undefined, /*expectedOffset*/ undefined, /*empty*/ true); } + public codeFixAtPosition(expectedText: string, errorCode?: number): void { + this.state.verifyCodeFixAtPosition(expectedText, errorCode); + } + public navigationBar(json: any) { this.state.verifyNavigationBar(json); } diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index d7ed04b627f..d2219c3969d 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -453,6 +453,9 @@ namespace Harness.LanguageService { isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean { return unwrapJSONCallResult(this.shim.isValidBraceCompletionAtPosition(fileName, position, openingBrace)); } + getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): ts.CodeAction[] { + return unwrapJSONCallResult(this.shim.getCodeFixesAtPosition(fileName, start, end, JSON.stringify(errorCodes))); + } getEmitOutput(fileName: string): ts.EmitOutput { return unwrapJSONCallResult(this.shim.getEmitOutput(fileName)); } diff --git a/src/server/client.ts b/src/server/client.ts index f04dbd8dc02..3c8a07c8cdf 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -592,6 +592,10 @@ namespace ts.server { throw new Error("Not Implemented Yet."); } + getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): ts.CodeAction[] { + throw new Error("Not Implemented Yet."); + } + getBraceMatchingAtPosition(fileName: string, position: number): TextSpan[] { const lineOffset = this.positionToOneBasedLineOffset(fileName, position); const args: protocol.FileLocationRequestArgs = { diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 9ce3197a46f..ee0d4d100d3 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -192,6 +192,7 @@ declare namespace FourSlashInterface { noMatchingBracePositionInCurrentFile(bracePosition: number): void; DocCommentTemplate(expectedText: string, expectedOffset: number, empty?: boolean): void; noDocCommentTemplate(): void; + codeFixAtPosition(expectedText: string, errorCode?: number): void; navigationBar(json: any): void; navigationItemsListCount(count: number, searchValue: string, matchKind?: string): void; From 6f4fb064ca27792b19828d842bd4472a45b4d7ae Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Fri, 5 Aug 2016 16:21:46 -0700 Subject: [PATCH 003/173] SuperFix fourslash tests --- tests/cases/fourslash/superFix1.ts | 10 ++++++++++ tests/cases/fourslash/superFix2.ts | 13 +++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 tests/cases/fourslash/superFix1.ts create mode 100644 tests/cases/fourslash/superFix2.ts diff --git a/tests/cases/fourslash/superFix1.ts b/tests/cases/fourslash/superFix1.ts new file mode 100644 index 00000000000..7fbe2cb4fd7 --- /dev/null +++ b/tests/cases/fourslash/superFix1.ts @@ -0,0 +1,10 @@ +/// + +////class Base{ +////} +////class C extends Base{ +//// constructor() {[| |] +//// } +////} + +verify.codeFixAtPosition('super();'); diff --git a/tests/cases/fourslash/superFix2.ts b/tests/cases/fourslash/superFix2.ts new file mode 100644 index 00000000000..880b5d43167 --- /dev/null +++ b/tests/cases/fourslash/superFix2.ts @@ -0,0 +1,13 @@ +/// + +////class Base{ +////} +////class C extends Base{ +//// private a:number; +//// constructor() {[| +//// this.a = 12; +//// super();|] +//// } +////} + +verify.codeFixAtPosition("super(); this.a = 12;"); \ No newline at end of file From e0b73c4a4a65f3c98a1b99ce5a981a1f89d44283 Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Fri, 5 Aug 2016 16:44:43 -0700 Subject: [PATCH 004/173] Clean up --- src/services/codefixes/references.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/services/codefixes/references.ts b/src/services/codefixes/references.ts index 3675d626678..a9ab7a98b33 100644 --- a/src/services/codefixes/references.ts +++ b/src/services/codefixes/references.ts @@ -1,6 +1,3 @@ /// /// /// -/// -/// -/// From 124e05fd68ffe662fca5bc5fa9ee91dd9b52fdcb Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Fri, 5 Aug 2016 16:44:43 -0700 Subject: [PATCH 005/173] PR Feedback --- src/compiler/core.ts | 24 +++++++++++++---------- src/compiler/diagnosticMessages.json | 14 ++++++------- src/compiler/types.ts | 1 - src/harness/fourslash.ts | 6 +++--- src/services/codefixes/codeFixProvider.ts | 7 ++----- src/services/codefixes/references.ts | 3 --- src/services/codefixes/superFixes.ts | 8 +++----- src/services/services.ts | 4 ++-- 8 files changed, 31 insertions(+), 36 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index b07c21fa4cb..835a8be3167 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1,4 +1,4 @@ -/// +/// /// @@ -115,15 +115,6 @@ namespace ts { return -1; } - export function firstOrUndefined(array: T[], predicate: (x: T) => boolean): T { - for (let i = 0, len = array.length; i < len; i++) { - if (predicate(array[i])) { - return array[i]; - } - } - return undefined; - } - export function indexOfAnyCharCode(text: string, charCodes: number[], start?: number): number { for (let i = start || 0, len = text.length; i < len; i++) { if (contains(charCodes, text.charCodeAt(i))) { @@ -229,6 +220,19 @@ namespace ts { return true; } + /** + * Returns the first element that matches the predicate, or undefined if none + * could be found. + */ + export function find(array: T[], predicate: (item: T) => boolean): T { + for (let i = 0, len = array.length; i < len; i++) { + if (predicate(array[i])) { + return array[i]; + } + } + return undefined; + } + /** * Returns the last element of an array if non-empty, undefined otherwise. */ diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 1dffc35c74c..34f5d481075 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3033,31 +3033,31 @@ "code": 17010 }, "Add missing 'super()' call.": { - "category": "CodeFix", + "category": "Message", "code": 90001 }, "Make 'super()' call the first statement in the constructor.": { - "category": "CodeFix", + "category": "Message", "code": 90002 }, "Change 'extends' to 'implements'": { - "category": "CodeFix", + "category": "Message", "code": 90003 }, "Remove unused identifiers": { - "category": "CodeFix", + "category": "Message", "code": 90004 }, "Implement interface on reference": { - "category": "CodeFix", + "category": "Message", "code": 90005 }, "Implement interface on class": { - "category": "CodeFix", + "category": "Message", "code": 90006 }, "Implement inherited abstract class": { - "category": "CodeFix", + "category": "Message", "code": 90007 } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index e31a4b0ace1..28ededebb0d 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2547,7 +2547,6 @@ namespace ts { Warning, Error, Message, - CodeFix, } export enum ModuleResolutionKind { diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 91597d7f593..19fa9ba5b4a 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1,4 +1,4 @@ -// +// // Copyright (c) Microsoft Corporation. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -1879,11 +1879,11 @@ namespace FourSlash { this.raiseError("Errors expected."); } - if (diagnostics.length > 1 && !errorCode) { + if (diagnostics.length > 1 && errorCode !== undefined) { this.raiseError("When there's more than one error, you must specify the errror to fix."); } - const diagnostic = !errorCode ? diagnostics[0] : ts.firstOrUndefined(diagnostics, d => d.code == errorCode); + const diagnostic = !errorCode ? diagnostics[0] : ts.find(diagnostics, d => d.code == errorCode); const actual = this.languageService.getCodeFixesAtPosition(fileName, diagnostic.start, diagnostic.length, [`TS${diagnostic.code}`]); diff --git a/src/services/codefixes/codeFixProvider.ts b/src/services/codefixes/codeFixProvider.ts index ca877aef46a..71199af88fa 100644 --- a/src/services/codefixes/codeFixProvider.ts +++ b/src/services/codefixes/codeFixProvider.ts @@ -1,7 +1,6 @@ -/* @internal */ +/* @internal */ namespace ts { export interface CodeFix { - name: string; errorCodes: string[]; getCodeActions(context: CodeFixContext): CodeAction[]; } @@ -14,7 +13,7 @@ namespace ts { newLineCharacter: string; } - export namespace codeFix { + export namespace codefix { const codeFixes: Map = {}; export function registerCodeFix(action: CodeFix) { @@ -37,8 +36,6 @@ namespace ts { const fixes = codeFixes[context.errorCode]; let allActions: CodeAction[] = []; - Debug.assert(fixes && fixes.length > 0, "No fixes found for error: '${errorCode}'."); - forEach(fixes, f => { const actions = f.getCodeActions(context); if (actions && actions.length > 0) { diff --git a/src/services/codefixes/references.ts b/src/services/codefixes/references.ts index 3675d626678..a9ab7a98b33 100644 --- a/src/services/codefixes/references.ts +++ b/src/services/codefixes/references.ts @@ -1,6 +1,3 @@ /// /// /// -/// -/// -/// diff --git a/src/services/codefixes/superFixes.ts b/src/services/codefixes/superFixes.ts index 2c6a67de513..d06ba9df955 100644 --- a/src/services/codefixes/superFixes.ts +++ b/src/services/codefixes/superFixes.ts @@ -1,13 +1,12 @@ /* @internal */ -namespace ts.codeFix { +namespace ts.codefix { function getOpenBraceEnd(constructor: ConstructorDeclaration, sourceFile: SourceFile) { // First token is the open curly, this is where we want to put the 'super' call. return constructor.body.getFirstToken(sourceFile).getEnd(); } registerCodeFix({ - name: "AddMissingSuperCallFix", - errorCodes: ["TS2377"], + errorCodes: [`TS${Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call.code}`], getCodeActions: (context: CodeFixContext) => { const sourceFile = context.sourceFile; const token = getTokenAtPosition(sourceFile, context.span.start); @@ -22,8 +21,7 @@ namespace ts.codeFix { }); registerCodeFix({ - name: "MakeSuperCallTheFirstStatementInTheConstructor", - errorCodes: ["TS17009"], + errorCodes: [`TS${Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class.code}`], getCodeActions: (context: CodeFixContext) => { const sourceFile = context.sourceFile; diff --git a/src/services/services.ts b/src/services/services.ts index b189a6375b7..839fc4c298e 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1902,7 +1902,7 @@ namespace ts { } export function getSupportedCodeFixes() { - return codeFix.CodeFixProvider.getSupportedErrorCodes(); + return codefix.CodeFixProvider.getSupportedErrorCodes(); } // Cache host information about script Should be refreshed @@ -3041,7 +3041,7 @@ namespace ts { documentRegistry: DocumentRegistry = createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory())): LanguageService { const syntaxTreeCache: SyntaxTreeCache = new SyntaxTreeCache(host); - const codeFixProvider: codeFix.CodeFixProvider = new codeFix.CodeFixProvider(); + const codeFixProvider: codefix.CodeFixProvider = new codefix.CodeFixProvider(); let ruleProvider: formatting.RulesProvider; let program: Program; let lastProjectVersion: string; From f931e606b18e3635d545b5d1f768b0b05b01a2ca Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Fri, 26 Aug 2016 15:33:23 -0700 Subject: [PATCH 006/173] Fix build break caused by merge from master --- src/compiler/core.ts | 13 ------------- src/services/codefixes/codeFixProvider.ts | 4 ++-- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index fdfa139a21c..c6effb658b7 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -292,19 +292,6 @@ namespace ts { return true; } - /** - * Returns the first element that matches the predicate, or undefined if none - * could be found. - */ - export function find(array: T[], predicate: (item: T) => boolean): T { - for (let i = 0, len = array.length; i < len; i++) { - if (predicate(array[i])) { - return array[i]; - } - } - return undefined; - } - /** * Returns the last element of an array if non-empty, undefined otherwise. */ diff --git a/src/services/codefixes/codeFixProvider.ts b/src/services/codefixes/codeFixProvider.ts index 71199af88fa..9c4e7404c95 100644 --- a/src/services/codefixes/codeFixProvider.ts +++ b/src/services/codefixes/codeFixProvider.ts @@ -14,7 +14,7 @@ namespace ts { } export namespace codefix { - const codeFixes: Map = {}; + const codeFixes = createMap(); export function registerCodeFix(action: CodeFix) { forEach(action.errorCodes, error => { @@ -29,7 +29,7 @@ namespace ts { export class CodeFixProvider { public static getSupportedErrorCodes() { - return getKeys(codeFixes); + return Object.keys(codeFixes); } public getFixes(context: CodeFixContext): CodeAction[] { From 49b65c749fc291dfb22b997820ce0c369ad40c43 Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Fri, 9 Sep 2016 14:30:28 -0700 Subject: [PATCH 007/173] PR feedback --- src/services/codefixes/superFixes.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/services/codefixes/superFixes.ts b/src/services/codefixes/superFixes.ts index d06ba9df955..622ded06d31 100644 --- a/src/services/codefixes/superFixes.ts +++ b/src/services/codefixes/superFixes.ts @@ -10,7 +10,10 @@ namespace ts.codefix { getCodeActions: (context: CodeFixContext) => { const sourceFile = context.sourceFile; const token = getTokenAtPosition(sourceFile, context.span.start); - Debug.assert(token.kind === SyntaxKind.ConstructorKeyword, "Failed to find the constructor."); + + if (token.kind !== SyntaxKind.ConstructorKeyword) { + return undefined; + } const newPosition = getOpenBraceEnd(token.parent, sourceFile); return [{ @@ -26,14 +29,18 @@ namespace ts.codefix { const sourceFile = context.sourceFile; const token = getTokenAtPosition(sourceFile, context.span.start); - const constructor = getContainingFunction(token); - Debug.assert(constructor.kind === SyntaxKind.Constructor, "Failed to find the constructor."); + if (token.kind !== SyntaxKind.ConstructorKeyword) { + return undefined; + } + const constructor = getContainingFunction(token); const superCall = findSuperCall((constructor).body); - Debug.assert(!!superCall, "Failed to find super call."); + if (!superCall) { + return undefined; + } const newPosition = getOpenBraceEnd(constructor, sourceFile); - const changes = [{ + const changes = [{ fileName: sourceFile.fileName, textChanges: [{ newText: superCall.getText(sourceFile), span: { start: newPosition, length: 0 } From 682f81257d345f72e230a53aa864d3dee4af6bdc Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Fri, 16 Sep 2016 14:52:33 -0700 Subject: [PATCH 008/173] PR feedback --- src/services/codefixes/codeFixProvider.ts | 32 +++++++++++------------ src/services/services.ts | 8 +++--- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/services/codefixes/codeFixProvider.ts b/src/services/codefixes/codeFixProvider.ts index 9c4e7404c95..55aa8d38f7a 100644 --- a/src/services/codefixes/codeFixProvider.ts +++ b/src/services/codefixes/codeFixProvider.ts @@ -9,7 +9,7 @@ namespace ts { errorCode: string; sourceFile: SourceFile; span: TextSpan; - checker: TypeChecker; + program: Program; newLineCharacter: string; } @@ -27,24 +27,22 @@ namespace ts { }); } - export class CodeFixProvider { - public static getSupportedErrorCodes() { - return Object.keys(codeFixes); - } + export function getSupportedErrorCodes() { + return Object.keys(codeFixes); + } - public getFixes(context: CodeFixContext): CodeAction[] { - const fixes = codeFixes[context.errorCode]; - let allActions: CodeAction[] = []; + export function getFixes(context: CodeFixContext): CodeAction[] { + const fixes = codeFixes[context.errorCode]; + let allActions: CodeAction[] = []; - forEach(fixes, f => { - const actions = f.getCodeActions(context); - if (actions && actions.length > 0) { - allActions = allActions.concat(actions); - } - }); + forEach(fixes, f => { + const actions = f.getCodeActions(context); + if (actions && actions.length > 0) { + allActions = allActions.concat(actions); + } + }); - return allActions; - } + return allActions; } } -} \ No newline at end of file +} diff --git a/src/services/services.ts b/src/services/services.ts index b481ffa5269..bf6ea627899 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -695,7 +695,7 @@ namespace ts { } export function getSupportedCodeFixes() { - return codefix.CodeFixProvider.getSupportedErrorCodes(); + return codefix.getSupportedErrorCodes(); } // Cache host information about script Should be refreshed @@ -918,7 +918,6 @@ namespace ts { documentRegistry: DocumentRegistry = createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory())): LanguageService { const syntaxTreeCache: SyntaxTreeCache = new SyntaxTreeCache(host); - const codeFixProvider: codefix.CodeFixProvider = new codefix.CodeFixProvider(); let ruleProvider: formatting.RulesProvider; let program: Program; let lastProjectVersion: string; @@ -1588,7 +1587,6 @@ namespace ts { function getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): CodeAction[] { synchronizeHostData(); const sourceFile = getValidSourceFile(fileName); - const checker = program.getTypeChecker(); let allFixes: CodeAction[] = []; forEach(errorCodes, error => { @@ -1596,11 +1594,11 @@ namespace ts { errorCode: error, sourceFile: sourceFile, span: { start, length: end - start }, - checker: checker, + program: program, newLineCharacter: getNewLineOrDefaultFromHost(host) }; - const fixes = codeFixProvider.getFixes(context); + const fixes = codefix.getFixes(context); if (fixes) { allFixes = allFixes.concat(fixes); } From f7647db7f7d0b9b48fefbc5cd56b9246289b680b Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 4 Oct 2016 06:30:05 -0700 Subject: [PATCH 009/173] Fix tests changed by #11309 --- .../reference/variableDeclarationInStrictMode1.errors.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/baselines/reference/variableDeclarationInStrictMode1.errors.txt b/tests/baselines/reference/variableDeclarationInStrictMode1.errors.txt index 9dd9a8d41a1..46782aaa1d6 100644 --- a/tests/baselines/reference/variableDeclarationInStrictMode1.errors.txt +++ b/tests/baselines/reference/variableDeclarationInStrictMode1.errors.txt @@ -1,4 +1,4 @@ -lib.d.ts(28,18): error TS2300: Duplicate identifier 'eval'. +lib.d.ts(32,18): error TS2300: Duplicate identifier 'eval'. tests/cases/compiler/variableDeclarationInStrictMode1.ts(2,5): error TS1100: Invalid use of 'eval' in strict mode. tests/cases/compiler/variableDeclarationInStrictMode1.ts(2,5): error TS2300: Duplicate identifier 'eval'. From a70624d4159e9de3f2c497d2f7ec52082fee7bf6 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Tue, 4 Oct 2016 12:08:58 -0700 Subject: [PATCH 010/173] Add test when require is just a function in external module --- ...quireAsFunctionInExternalModule.errors.txt | 20 ++++++++++ .../requireAsFunctionInExternalModule.js | 37 +++++++++++++++++++ .../requireAsFunctionInExternalModule.ts | 16 ++++++++ 3 files changed, 73 insertions(+) create mode 100644 tests/baselines/reference/requireAsFunctionInExternalModule.errors.txt create mode 100644 tests/baselines/reference/requireAsFunctionInExternalModule.js create mode 100644 tests/cases/compiler/requireAsFunctionInExternalModule.ts diff --git a/tests/baselines/reference/requireAsFunctionInExternalModule.errors.txt b/tests/baselines/reference/requireAsFunctionInExternalModule.errors.txt new file mode 100644 index 00000000000..58e3b145f35 --- /dev/null +++ b/tests/baselines/reference/requireAsFunctionInExternalModule.errors.txt @@ -0,0 +1,20 @@ +tests/cases/compiler/m2.ts(1,10): error TS2305: Module '"tests/cases/compiler/m"' has no exported member 'hello'. + + +==== tests/cases/compiler/c.js (0 errors) ==== + export default function require(a) { } + export function has(a) { return true } + +==== tests/cases/compiler/m.js (0 errors) ==== + import require, { has } from "./c" + export function hello() { } + if (has('ember-debug')) { + require('ember-debug'); + } + +==== tests/cases/compiler/m2.ts (1 errors) ==== + import { hello } from "./m"; + ~~~~~ +!!! error TS2305: Module '"tests/cases/compiler/m"' has no exported member 'hello'. + hello(); + \ No newline at end of file diff --git a/tests/baselines/reference/requireAsFunctionInExternalModule.js b/tests/baselines/reference/requireAsFunctionInExternalModule.js new file mode 100644 index 00000000000..a8b14db3138 --- /dev/null +++ b/tests/baselines/reference/requireAsFunctionInExternalModule.js @@ -0,0 +1,37 @@ +//// [tests/cases/compiler/requireAsFunctionInExternalModule.ts] //// + +//// [c.js] +export default function require(a) { } +export function has(a) { return true } + +//// [m.js] +import require, { has } from "./c" +export function hello() { } +if (has('ember-debug')) { + require('ember-debug'); +} + +//// [m2.ts] +import { hello } from "./m"; +hello(); + + +//// [c.js] +"use strict"; +function require(a) { } +exports.__esModule = true; +exports["default"] = require; +function has(a) { return true; } +exports.has = has; +//// [m.js] +"use strict"; +var c_1 = require("./c"); +function hello() { } +exports.hello = hello; +if (c_1.has('ember-debug')) { + c_1["default"]('ember-debug'); +} +//// [m2.js] +"use strict"; +var m_1 = require("./m"); +m_1.hello(); diff --git a/tests/cases/compiler/requireAsFunctionInExternalModule.ts b/tests/cases/compiler/requireAsFunctionInExternalModule.ts new file mode 100644 index 00000000000..1715090c329 --- /dev/null +++ b/tests/cases/compiler/requireAsFunctionInExternalModule.ts @@ -0,0 +1,16 @@ +// @allowjs: true +// @outDir: dist +// @Filename: c.js +export default function require(a) { } +export function has(a) { return true } + +// @Filename: m.js +import require, { has } from "./c" +export function hello() { } +if (has('ember-debug')) { + require('ember-debug'); +} + +// @Filename: m2.ts +import { hello } from "./m"; +hello(); From a830c844b7846f56a785d0ed8a2e75d4bec7a14f Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Tue, 4 Oct 2016 12:25:07 -0700 Subject: [PATCH 011/173] Bind the source file as external module only if not already done Return type of require call is from external module resolution only if it doesnt resolve to local module Fixes #10931 --- src/compiler/binder.ts | 4 +- src/compiler/checker.ts | 5 ++- ...quireAsFunctionInExternalModule.errors.txt | 20 ---------- .../requireAsFunctionInExternalModule.symbols | 31 ++++++++++++++++ .../requireAsFunctionInExternalModule.types | 37 +++++++++++++++++++ 5 files changed, 75 insertions(+), 22 deletions(-) delete mode 100644 tests/baselines/reference/requireAsFunctionInExternalModule.errors.txt create mode 100644 tests/baselines/reference/requireAsFunctionInExternalModule.symbols create mode 100644 tests/baselines/reference/requireAsFunctionInExternalModule.types diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 2fe7d30ab56..c8785819b9e 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -2000,7 +2000,9 @@ namespace ts { function setCommonJsModuleIndicator(node: Node) { if (!file.commonJsModuleIndicator) { file.commonJsModuleIndicator = node; - bindSourceFileAsExternalModule(); + if (!file.externalModuleIndicator) { + bindSourceFileAsExternalModule(); + } } } diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 422f2a70dcc..1354002a29e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -12535,7 +12535,10 @@ namespace ts { } // In JavaScript files, calls to any identifier 'require' are treated as external module imports - if (isInJavaScriptFile(node) && isRequireCall(node, /*checkArgumentIsStringLiteral*/true)) { + if (isInJavaScriptFile(node) && + isRequireCall(node, /*checkArgumentIsStringLiteral*/true) && + // Make sure require is not a local function + !resolveName(node.expression, (node.expression).text, SymbolFlags.Value | SymbolFlags.ExportValue, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined)) { return resolveExternalModuleTypeByLiteral(node.arguments[0]); } diff --git a/tests/baselines/reference/requireAsFunctionInExternalModule.errors.txt b/tests/baselines/reference/requireAsFunctionInExternalModule.errors.txt deleted file mode 100644 index 58e3b145f35..00000000000 --- a/tests/baselines/reference/requireAsFunctionInExternalModule.errors.txt +++ /dev/null @@ -1,20 +0,0 @@ -tests/cases/compiler/m2.ts(1,10): error TS2305: Module '"tests/cases/compiler/m"' has no exported member 'hello'. - - -==== tests/cases/compiler/c.js (0 errors) ==== - export default function require(a) { } - export function has(a) { return true } - -==== tests/cases/compiler/m.js (0 errors) ==== - import require, { has } from "./c" - export function hello() { } - if (has('ember-debug')) { - require('ember-debug'); - } - -==== tests/cases/compiler/m2.ts (1 errors) ==== - import { hello } from "./m"; - ~~~~~ -!!! error TS2305: Module '"tests/cases/compiler/m"' has no exported member 'hello'. - hello(); - \ No newline at end of file diff --git a/tests/baselines/reference/requireAsFunctionInExternalModule.symbols b/tests/baselines/reference/requireAsFunctionInExternalModule.symbols new file mode 100644 index 00000000000..2f44d6b6611 --- /dev/null +++ b/tests/baselines/reference/requireAsFunctionInExternalModule.symbols @@ -0,0 +1,31 @@ +=== tests/cases/compiler/c.js === +export default function require(a) { } +>require : Symbol(require, Decl(c.js, 0, 0)) +>a : Symbol(a, Decl(c.js, 0, 32)) + +export function has(a) { return true } +>has : Symbol(has, Decl(c.js, 0, 38)) +>a : Symbol(a, Decl(c.js, 1, 20)) + +=== tests/cases/compiler/m.js === +import require, { has } from "./c" +>require : Symbol(require, Decl(m.js, 0, 6)) +>has : Symbol(has, Decl(m.js, 0, 17)) + +export function hello() { } +>hello : Symbol(hello, Decl(m.js, 0, 34)) + +if (has('ember-debug')) { +>has : Symbol(has, Decl(m.js, 0, 17)) + + require('ember-debug'); +>require : Symbol(require, Decl(m.js, 0, 6)) +} + +=== tests/cases/compiler/m2.ts === +import { hello } from "./m"; +>hello : Symbol(hello, Decl(m2.ts, 0, 8)) + +hello(); +>hello : Symbol(hello, Decl(m2.ts, 0, 8)) + diff --git a/tests/baselines/reference/requireAsFunctionInExternalModule.types b/tests/baselines/reference/requireAsFunctionInExternalModule.types new file mode 100644 index 00000000000..2ce5f3aed38 --- /dev/null +++ b/tests/baselines/reference/requireAsFunctionInExternalModule.types @@ -0,0 +1,37 @@ +=== tests/cases/compiler/c.js === +export default function require(a) { } +>require : (a: any) => void +>a : any + +export function has(a) { return true } +>has : (a: any) => boolean +>a : any +>true : true + +=== tests/cases/compiler/m.js === +import require, { has } from "./c" +>require : (a: any) => void +>has : (a: any) => boolean + +export function hello() { } +>hello : () => void + +if (has('ember-debug')) { +>has('ember-debug') : boolean +>has : (a: any) => boolean +>'ember-debug' : "ember-debug" + + require('ember-debug'); +>require('ember-debug') : void +>require : (a: any) => void +>'ember-debug' : "ember-debug" +} + +=== tests/cases/compiler/m2.ts === +import { hello } from "./m"; +>hello : () => void + +hello(); +>hello() : void +>hello : () => void + From 4f404ad92be1e6c318eef04cecf4026ec4c39df2 Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Tue, 4 Oct 2016 16:58:17 -0700 Subject: [PATCH 012/173] Implement codefixes in tsserver --- src/server/protocol.d.ts | 96 +++++++++++++++++++++++++++++++++++++++- src/server/session.ts | 52 +++++++++++++++++++++- src/server/utilities.ts | 3 +- 3 files changed, 148 insertions(+), 3 deletions(-) diff --git a/src/server/protocol.d.ts b/src/server/protocol.d.ts index f0dfe4eb130..e8919f843eb 100644 --- a/src/server/protocol.d.ts +++ b/src/server/protocol.d.ts @@ -203,6 +203,53 @@ declare namespace ts.server.protocol { position?: number; } + /** + * Request for the available codefixed at a specific position. + */ + export interface CodeFixRequest extends Request { + arguments: CodeFixRequestArgs; + } + + /** + * Instances of this interface specify errorcodes on a specific location in a sourcefile. + */ + export interface CodeFixRequestArgs extends FileRequestArgs { + /** + * The line number for the request (1-based). + */ + startLine?: number; + + /** + * The character offset (on the line) for the request (1-based). + */ + startOffset?: number; + + /** + * Position (can be specified instead of line/offset pair) + */ + startPosition?: number; + + /** + * The line number for the request (1-based). + */ + endLine?: number; + + /** + * The character offset (on the line) for the request (1-based). + */ + endOffset?: number; + + /** + * Position (can be specified instead of line/offset pair) + */ + endPosition?: number; + + /** + * Errorcodes we want to get the fixes for. + */ + errorCodes?: string[] + } + /** * A request whose arguments specify a file location (file, line, col). */ @@ -428,7 +475,6 @@ declare namespace ts.server.protocol { findInStrings?: boolean; } - /** * Rename request; value of command field is "rename". Return * response giving the file locations that reference the symbol @@ -873,6 +919,18 @@ declare namespace ts.server.protocol { newText: string; } + export interface FileCodeEdits { + fileName: string; + textChanges: CodeEdit[]; + } + + export interface CodeActionResponse extends Response { + /** Description of the code action to display in the UI of the editor */ + description: string; + /** Text changes to apply to each file as part of the code action */ + changes: FileCodeEdits[]; + } + /** * Format and format on key response message. */ @@ -1518,4 +1576,40 @@ declare namespace ts.server.protocol { export interface NavBarResponse extends Response { body?: NavigationBarItem[]; } + + export interface CodeAction { + /** + * Description of the code action to display in the UI of the editor. + */ + description: string; + + /** + * Changes to apply to each file as part of the code action. + */ + changes: FileTextChanges[] + } + + export interface FileTextChanges { + /** + * File to apply the change to. + */ + fileName: string; + + /** + * Changes to apply to the file. + */ + textChanges: TextChange[]; + } + + export class TextChange { + /** + * The span for the text change. + */ + span: TextSpan; + + /** + * New text for the span, can be an empty string if we want to delete text. + */ + newText: string; + } } diff --git a/src/server/session.ts b/src/server/session.ts index d076d5deb6d..ff4384aafbd 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -134,6 +134,8 @@ namespace ts.server { export const NameOrDottedNameSpan = "nameOrDottedNameSpan"; export const BreakpointStatement = "breakpointStatement"; export const CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects"; + export const GetCodeFixes = "getCodeFixes"; + export const GetCodeFixesFull = "getCodeFixes-full"; } export function formatMessage(msg: T, logger: server.Logger, byteLength: (s: string, encoding: string) => number, newLine: string): string { @@ -751,7 +753,7 @@ namespace ts.server { return this.getFileAndProjectWorker(args.file, args.projectFileName, /*refreshInferredProjects*/ false, errorOnMissingProject); } - private getFileAndProjectWorker(uncheckedFileName: string, projectFileName: string, refreshInferredProjects: boolean, errorOnMissingProject: boolean) { + private getFileAndProjectWorker(uncheckedFileName: string, projectFileName: string, refreshInferredProjects: boolean, errorOnMissingProject: boolean) { const file = toNormalizedPath(uncheckedFileName); const project: Project = this.getProject(projectFileName) || this.projectService.getDefaultProjectForFile(file, refreshInferredProjects); if (!project && errorOnMissingProject) { @@ -1199,6 +1201,48 @@ namespace ts.server { } } + private getCodeFixes(args: protocol.CodeFixRequestArgs, simplifiedResult: boolean): protocol.CodeAction[] | CodeAction[] { + const { file, project } = this.getFileAndProjectWithoutRefreshingInferredProjects(args); + + const scriptInfo = project.getScriptInfoForNormalizedPath(file); + const startPosition = getStartPosition(); + const endPosition = getEndPosition(); + + const codeActions = project.getLanguageService().getCodeFixesAtPosition(file, startPosition, endPosition, args.errorCodes); + if (!codeActions) { + return undefined; + } + if (simplifiedResult) { + return codeActions.map(mapCodeAction); + } else { + return codeActions; + } + + function mapCodeAction(source: CodeAction): protocol.CodeAction { + return { + description: source.description, + changes: source.changes.map(change => ({ + fileName: change.fileName, + textChanges: change.textChanges.map(textChange => ({ + span: { + start: scriptInfo.positionToLineOffset(textChange.span.start), + end: scriptInfo.positionToLineOffset(textChange.span.start + textChange.span.length) + }, + newText: textChange.newText + })) + })) + }; + } + + function getStartPosition() { + return args.startPosition !== undefined ? args.startPosition : scriptInfo.lineOffsetToPosition(args.startLine, args.startOffset); + } + + function getEndPosition() { + return args.endPosition !== undefined ? args.endPosition : scriptInfo.lineOffsetToPosition(args.endLine, args.endOffset); + } + } + private getBraceMatching(args: protocol.FileLocationRequestArgs, simplifiedResult: boolean): protocol.TextSpan[] | TextSpan[] { const { file, project } = this.getFileAndProjectWithoutRefreshingInferredProjects(args); @@ -1521,6 +1565,12 @@ namespace ts.server { [CommandNames.ReloadProjects]: (request: protocol.ReloadProjectsRequest) => { this.projectService.reloadProjects(); return this.notRequired(); + }, + [CommandNames.GetCodeFixes]: (request: protocol.CodeFixRequest) => { + return this.requiredResponse(this.getCodeFixes(request.arguments, /*simplifiedResult*/ true)); + }, + [CommandNames.GetCodeFixesFull]: (request: protocol.CodeFixRequest) => { + return this.requiredResponse(this.getCodeFixes(request.arguments, /*simplifiedResult*/ false)); } }); diff --git a/src/server/utilities.ts b/src/server/utilities.ts index 3f99da9977e..beceab79229 100644 --- a/src/server/utilities.ts +++ b/src/server/utilities.ts @@ -201,7 +201,8 @@ namespace ts.server { dispose: (): any => throwLanguageServiceIsDisabledError(), getCompletionEntrySymbol: (): any => throwLanguageServiceIsDisabledError(), getImplementationAtPosition: (): any => throwLanguageServiceIsDisabledError(), - getSourceFile: (): any => throwLanguageServiceIsDisabledError() + getSourceFile: (): any => throwLanguageServiceIsDisabledError(), + getCodeFixesAtPosition: (): any => throwLanguageServiceIsDisabledError() }; export interface ServerLanguageServiceHost { From 1cc973273f3a504037bfadf086edef170eeff214 Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Tue, 4 Oct 2016 17:37:46 -0700 Subject: [PATCH 013/173] PR feedback --- src/services/codefixes/fixes.ts | 1 + src/services/codefixes/references.ts | 3 --- src/services/services.ts | 10 +++++++--- src/services/tsconfig.json | 3 +-- 4 files changed, 9 insertions(+), 8 deletions(-) create mode 100644 src/services/codefixes/fixes.ts delete mode 100644 src/services/codefixes/references.ts diff --git a/src/services/codefixes/fixes.ts b/src/services/codefixes/fixes.ts new file mode 100644 index 00000000000..d64a99ca1b9 --- /dev/null +++ b/src/services/codefixes/fixes.ts @@ -0,0 +1 @@ +/// diff --git a/src/services/codefixes/references.ts b/src/services/codefixes/references.ts deleted file mode 100644 index a9ab7a98b33..00000000000 --- a/src/services/codefixes/references.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -/// -/// diff --git a/src/services/services.ts b/src/services/services.ts index bed1869b7fb..050096b45d4 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -24,7 +24,8 @@ /// /// /// -/// +/// +/// namespace ts { /** The version of the language service API */ @@ -1641,15 +1642,18 @@ namespace ts { function getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): CodeAction[] { synchronizeHostData(); const sourceFile = getValidSourceFile(fileName); + const span = { start, length: end - start }; + const newLineChar = getNewLineOrDefaultFromHost(host); + let allFixes: CodeAction[] = []; forEach(errorCodes, error => { const context = { errorCode: error, sourceFile: sourceFile, - span: { start, length: end - start }, + span: span, program: program, - newLineCharacter: getNewLineOrDefaultFromHost(host) + newLineCharacter: newLineChar }; const fixes = codefix.getFixes(context); diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index 0f3059a449d..0066ef94343 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -80,7 +80,6 @@ "formatting/smartIndenter.ts", "formatting/tokenRange.ts", "codeFixes/codeFixProvider.ts", - "codeFixes/references.ts", - "codeFixes/superFixes.ts" + "codeFixes/fixes.ts" ] } From ebcfce41277bf80cf57f5a0d2ba9b081109ddb14 Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Wed, 5 Oct 2016 11:29:38 -0700 Subject: [PATCH 014/173] Error span moved from constructor to this keyword. --- src/services/codefixes/superFixes.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/codefixes/superFixes.ts b/src/services/codefixes/superFixes.ts index 622ded06d31..c61e4281e8f 100644 --- a/src/services/codefixes/superFixes.ts +++ b/src/services/codefixes/superFixes.ts @@ -29,7 +29,7 @@ namespace ts.codefix { const sourceFile = context.sourceFile; const token = getTokenAtPosition(sourceFile, context.span.start); - if (token.kind !== SyntaxKind.ConstructorKeyword) { + if (token.kind !== SyntaxKind.ThisKeyword) { return undefined; } From 2c46f9b6870348bd14973c1e5abb2f3ba893c084 Mon Sep 17 00:00:00 2001 From: Andrej Baran Date: Wed, 5 Oct 2016 17:09:58 +0200 Subject: [PATCH 015/173] Add ES8/ES2017 target (#10768) --- src/compiler/commandLineParser.ts | 2 ++ src/compiler/core.ts | 2 +- src/compiler/emitter.ts | 5 +++- src/compiler/transformer.ts | 6 +++-- src/compiler/transformers/ts.ts | 41 +++++++++++++++++++++++++------ src/compiler/types.ts | 4 ++- 6 files changed, 47 insertions(+), 13 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 648447ac26a..16d338cac6a 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -262,7 +262,9 @@ namespace ts { "es3": ScriptTarget.ES3, "es5": ScriptTarget.ES5, "es6": ScriptTarget.ES6, + "es8": ScriptTarget.ES8, "es2015": ScriptTarget.ES2015, + "es2017": ScriptTarget.ES2017, }), description: Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015, paramType: Diagnostics.VERSION, diff --git a/src/compiler/core.ts b/src/compiler/core.ts index e63bcbf8474..3f2cc619cb3 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1191,7 +1191,7 @@ namespace ts { export function getEmitModuleKind(compilerOptions: CompilerOptions) { return typeof compilerOptions.module === "number" ? compilerOptions.module : - getEmitScriptTarget(compilerOptions) === ScriptTarget.ES6 ? ModuleKind.ES6 : ModuleKind.CommonJS; + getEmitScriptTarget(compilerOptions) >= ScriptTarget.ES6 ? ModuleKind.ES6 : ModuleKind.CommonJS; } /* @internal */ diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index b3242e211de..b0e31278ff0 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2192,7 +2192,10 @@ const _super = (function (geti, seti) { helpersEmitted = true; } - if (!awaiterEmitted && node.flags & NodeFlags.HasAsyncFunctions) { + // Only emit __awaiter function when target ES5/ES6. + // Only emit __generator function when target ES5. + // For target ES8 and above, we can emit async/await as is. + if ((languageVersion < ScriptTarget.ES8) && (!awaiterEmitted && node.flags & NodeFlags.HasAsyncFunctions)) { writeLines(awaiterHelper); if (languageVersion < ScriptTarget.ES6) { writeLines(generatorHelper); diff --git a/src/compiler/transformer.ts b/src/compiler/transformer.ts index 92407af2bb9..415a9ecd1d7 100644 --- a/src/compiler/transformer.ts +++ b/src/compiler/transformer.ts @@ -115,7 +115,9 @@ namespace ts { transformers.push(transformJsx); } - transformers.push(transformES7); + if (languageVersion < ScriptTarget.ES8) { + transformers.push(transformES7); + } if (languageVersion < ScriptTarget.ES6) { transformers.push(transformES6); @@ -339,4 +341,4 @@ namespace ts { return statements; } } -} \ No newline at end of file +} diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index f6e8074cb07..40b9e7f64e1 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -240,11 +240,14 @@ namespace ts { // ES6 export and default modifiers are elided when inside a namespace. return currentNamespace ? undefined : node; + case SyntaxKind.AsyncKeyword: + // Async keyword is not elided for target ES8 + return languageVersion < ScriptTarget.ES8 ? undefined : node; + case SyntaxKind.PublicKeyword: case SyntaxKind.PrivateKeyword: case SyntaxKind.ProtectedKeyword: case SyntaxKind.AbstractKeyword: - case SyntaxKind.AsyncKeyword: case SyntaxKind.ConstKeyword: case SyntaxKind.DeclareKeyword: case SyntaxKind.ReadonlyKeyword: @@ -2223,6 +2226,14 @@ namespace ts { /*location*/ node ); + // Add ES8 async function expression modifier + // Not sure this is the right place? Might be better to move this + // into createFunctionExpression itself. + if ((languageVersion >= ScriptTarget.ES8) && isAsyncFunctionLike(node)) { + const funcModifiers = visitNodes(node.modifiers, visitor, isModifier); + func.modifiers = createNodeArray(funcModifiers); + } + setOriginalNode(func, node); return func; @@ -2235,7 +2246,7 @@ namespace ts { */ function visitArrowFunction(node: ArrowFunction) { const func = createArrowFunction( - /*modifiers*/ undefined, + visitNodes(node.modifiers, visitor, isModifier), /*typeParameters*/ undefined, visitNodes(node.parameters, visitor, isParameter), /*type*/ undefined, @@ -2250,7 +2261,7 @@ namespace ts { } function transformFunctionBody(node: MethodDeclaration | AccessorDeclaration | FunctionDeclaration | FunctionExpression): FunctionBody { - if (isAsyncFunctionLike(node)) { + if (isAsyncFunctionLike(node) && languageVersion < ScriptTarget.ES8) { return transformAsyncFunctionBody(node); } @@ -2270,7 +2281,7 @@ namespace ts { } function transformConciseBody(node: ArrowFunction): ConciseBody { - if (isAsyncFunctionLike(node)) { + if (isAsyncFunctionLike(node) && languageVersion < ScriptTarget.ES8) { return transformAsyncFunctionBody(node); } @@ -2453,14 +2464,28 @@ namespace ts { * @param node The await expression node. */ function visitAwaitExpression(node: AwaitExpression): Expression { + const targetAtLeastES8 = languageVersion >= ScriptTarget.ES8; return setOriginalNode( - createYield( + targetAtLeastES8 ? createAwaitExpression() : createYieldExpression(), + node + ); + + function createAwaitExpression() { + const awaitExpression = createAwait( + visitNode(node.expression, visitor, isExpression), + /*location*/ node + ); + return awaitExpression; + } + + function createYieldExpression() { + const yieldExpression = createYield( /*asteriskToken*/ undefined, visitNode(node.expression, visitor, isExpression), /*location*/ node - ), - node - ); + ); + return yieldExpression; + } } /** diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 4a4a25fd627..5b193beb155 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2831,8 +2831,10 @@ namespace ts { ES3 = 0, ES5 = 1, ES6 = 2, + ES8 = 3, ES2015 = ES6, - Latest = ES6, + ES2017 = ES8, + Latest = ES8, } export const enum LanguageVariant { From d16e846ab42e1da1558b8bbc6a28bb76ddae207f Mon Sep 17 00:00:00 2001 From: Andrej Baran Date: Thu, 6 Oct 2016 00:41:22 +0200 Subject: [PATCH 016/173] ES8/ES2017 target tests --- src/harness/unittests/commandLineParsing.ts | 2 +- .../convertCompilerOptionsFromJson.ts | 2 +- tests/baselines/reference/es8-async.js | 87 +++++++++++++ tests/baselines/reference/es8-async.symbols | 79 ++++++++++++ tests/baselines/reference/es8-async.types | 121 ++++++++++++++++++ tests/cases/compiler/es8-async.ts | 49 +++++++ 6 files changed, 338 insertions(+), 2 deletions(-) create mode 100644 tests/baselines/reference/es8-async.js create mode 100644 tests/baselines/reference/es8-async.symbols create mode 100644 tests/baselines/reference/es8-async.types create mode 100644 tests/cases/compiler/es8-async.ts diff --git a/src/harness/unittests/commandLineParsing.ts b/src/harness/unittests/commandLineParsing.ts index 028786eef24..42fc242f08e 100644 --- a/src/harness/unittests/commandLineParsing.ts +++ b/src/harness/unittests/commandLineParsing.ts @@ -165,7 +165,7 @@ namespace ts { start: undefined, length: undefined, }, { - messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015'", + messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es8', 'es2015', 'es2017'", category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code, diff --git a/src/harness/unittests/convertCompilerOptionsFromJson.ts b/src/harness/unittests/convertCompilerOptionsFromJson.ts index ba25409a9b4..db3d6cfc102 100644 --- a/src/harness/unittests/convertCompilerOptionsFromJson.ts +++ b/src/harness/unittests/convertCompilerOptionsFromJson.ts @@ -176,7 +176,7 @@ namespace ts { file: undefined, start: 0, length: 0, - messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015'", + messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es8', 'es2015', 'es2017'", code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category }] diff --git a/tests/baselines/reference/es8-async.js b/tests/baselines/reference/es8-async.js new file mode 100644 index 00000000000..3338b1f88a6 --- /dev/null +++ b/tests/baselines/reference/es8-async.js @@ -0,0 +1,87 @@ +//// [es8-async.ts] + +async (): Promise => { + await 0; +} + +async function asyncFunc() { + await 0; +} + +const asycnArrowFunc = async (): Promise => { + await 0; +} + +async function asyncIIFE() { + await 0; + + await (async function(): Promise { + await 1; + })(); + + await (async function asyncNamedFunc(): Promise { + await 1; + })(); + + await (async (): Promise => { + await 1; + })(); +} + +class AsyncClass { + asyncPropFunc = async function(): Promise { + await 2; + } + + asyncPropNamedFunc = async function namedFunc(): Promise { + await 2; + } + + asyncPropArrowFunc = async (): Promise => { + await 2; + } + + async asyncMethod(): Promise { + await 2; + } +} + + +//// [es8-async.js] +async () => { + await 0; +}; +async function asyncFunc() { + await 0; +} +const asycnArrowFunc = async () => { + await 0; +}; +async function asyncIIFE() { + await 0; + await (async function () { + await 1; + })(); + await (async function asyncNamedFunc() { + await 1; + })(); + await (async () => { + await 1; + })(); +} +class AsyncClass { + constructor() { + this.asyncPropFunc = async function () { + await 2; + }; + this.asyncPropNamedFunc = async function namedFunc() { + await 2; + }; + this.asyncPropArrowFunc = async () => { + await 2; + }; + } + async asyncMethod() { + await 2; + } +} diff --git a/tests/baselines/reference/es8-async.symbols b/tests/baselines/reference/es8-async.symbols new file mode 100644 index 00000000000..25a77351aef --- /dev/null +++ b/tests/baselines/reference/es8-async.symbols @@ -0,0 +1,79 @@ +=== tests/cases/compiler/es8-async.ts === + +async (): Promise => { +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + await 0; +} + +async function asyncFunc() { +>asyncFunc : Symbol(asyncFunc, Decl(es8-async.ts, 3, 1)) + + await 0; +} + +const asycnArrowFunc = async (): Promise => { +>asycnArrowFunc : Symbol(asycnArrowFunc, Decl(es8-async.ts, 9, 5)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + await 0; +} + +async function asyncIIFE() { +>asyncIIFE : Symbol(asyncIIFE, Decl(es8-async.ts, 11, 1)) + + await 0; + + await (async function(): Promise { +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + await 1; + })(); + + await (async function asyncNamedFunc(): Promise { +>asyncNamedFunc : Symbol(asyncNamedFunc, Decl(es8-async.ts, 20, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + await 1; + })(); + + await (async (): Promise => { +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + await 1; + })(); +} + +class AsyncClass { +>AsyncClass : Symbol(AsyncClass, Decl(es8-async.ts, 27, 1)) + + asyncPropFunc = async function(): Promise { +>asyncPropFunc : Symbol(AsyncClass.asyncPropFunc, Decl(es8-async.ts, 29, 18)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + await 2; + } + + asyncPropNamedFunc = async function namedFunc(): Promise { +>asyncPropNamedFunc : Symbol(AsyncClass.asyncPropNamedFunc, Decl(es8-async.ts, 32, 5)) +>namedFunc : Symbol(namedFunc, Decl(es8-async.ts, 34, 24)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + await 2; + } + + asyncPropArrowFunc = async (): Promise => { +>asyncPropArrowFunc : Symbol(AsyncClass.asyncPropArrowFunc, Decl(es8-async.ts, 36, 5)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + await 2; + } + + async asyncMethod(): Promise { +>asyncMethod : Symbol(AsyncClass.asyncMethod, Decl(es8-async.ts, 40, 5)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + await 2; + } +} + diff --git a/tests/baselines/reference/es8-async.types b/tests/baselines/reference/es8-async.types new file mode 100644 index 00000000000..da0ca063777 --- /dev/null +++ b/tests/baselines/reference/es8-async.types @@ -0,0 +1,121 @@ +=== tests/cases/compiler/es8-async.ts === + +async (): Promise => { +>async (): Promise => { await 0;} : () => Promise +>Promise : Promise + + await 0; +>await 0 : 0 +>0 : 0 +} + +async function asyncFunc() { +>asyncFunc : () => Promise + + await 0; +>await 0 : 0 +>0 : 0 +} + +const asycnArrowFunc = async (): Promise => { +>asycnArrowFunc : () => Promise +>async (): Promise => { await 0;} : () => Promise +>Promise : Promise + + await 0; +>await 0 : 0 +>0 : 0 +} + +async function asyncIIFE() { +>asyncIIFE : () => Promise + + await 0; +>await 0 : 0 +>0 : 0 + + await (async function(): Promise { +>await (async function(): Promise { await 1; })() : void +>(async function(): Promise { await 1; })() : Promise +>(async function(): Promise { await 1; }) : () => Promise +>async function(): Promise { await 1; } : () => Promise +>Promise : Promise + + await 1; +>await 1 : 1 +>1 : 1 + + })(); + + await (async function asyncNamedFunc(): Promise { +>await (async function asyncNamedFunc(): Promise { await 1; })() : void +>(async function asyncNamedFunc(): Promise { await 1; })() : Promise +>(async function asyncNamedFunc(): Promise { await 1; }) : () => Promise +>async function asyncNamedFunc(): Promise { await 1; } : () => Promise +>asyncNamedFunc : () => Promise +>Promise : Promise + + await 1; +>await 1 : 1 +>1 : 1 + + })(); + + await (async (): Promise => { +>await (async (): Promise => { await 1; })() : void +>(async (): Promise => { await 1; })() : Promise +>(async (): Promise => { await 1; }) : () => Promise +>async (): Promise => { await 1; } : () => Promise +>Promise : Promise + + await 1; +>await 1 : 1 +>1 : 1 + + })(); +} + +class AsyncClass { +>AsyncClass : AsyncClass + + asyncPropFunc = async function(): Promise { +>asyncPropFunc : () => Promise +>async function(): Promise { await 2; } : () => Promise +>Promise : Promise + + await 2; +>await 2 : 2 +>2 : 2 + } + + asyncPropNamedFunc = async function namedFunc(): Promise { +>asyncPropNamedFunc : () => Promise +>async function namedFunc(): Promise { await 2; } : () => Promise +>namedFunc : () => Promise +>Promise : Promise + + await 2; +>await 2 : 2 +>2 : 2 + } + + asyncPropArrowFunc = async (): Promise => { +>asyncPropArrowFunc : () => Promise +>async (): Promise => { await 2; } : () => Promise +>Promise : Promise + + await 2; +>await 2 : 2 +>2 : 2 + } + + async asyncMethod(): Promise { +>asyncMethod : () => Promise +>Promise : Promise + + await 2; +>await 2 : 2 +>2 : 2 + } +} + diff --git a/tests/cases/compiler/es8-async.ts b/tests/cases/compiler/es8-async.ts new file mode 100644 index 00000000000..0ceb6e397e5 --- /dev/null +++ b/tests/cases/compiler/es8-async.ts @@ -0,0 +1,49 @@ +// @target: es8 +// @lib: es2017 +// @noEmitHelpers: true + +async (): Promise => { + await 0; +} + +async function asyncFunc() { + await 0; +} + +const asycnArrowFunc = async (): Promise => { + await 0; +} + +async function asyncIIFE() { + await 0; + + await (async function(): Promise { + await 1; + })(); + + await (async function asyncNamedFunc(): Promise { + await 1; + })(); + + await (async (): Promise => { + await 1; + })(); +} + +class AsyncClass { + asyncPropFunc = async function(): Promise { + await 2; + } + + asyncPropNamedFunc = async function namedFunc(): Promise { + await 2; + } + + asyncPropArrowFunc = async (): Promise => { + await 2; + } + + async asyncMethod(): Promise { + await 2; + } +} From 9ca2569363809e3bd7aaf8bb817ec5a7020d231b Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 6 Oct 2016 11:04:40 -0700 Subject: [PATCH 017/173] Use control flow analysis for variables initialized with [] --- src/compiler/binder.ts | 21 +++ src/compiler/checker.ts | 218 +++++++++++++++++++++------ src/compiler/diagnosticMessages.json | 2 +- src/compiler/types.ts | 14 +- 4 files changed, 210 insertions(+), 45 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 49434e80aba..624ea269d89 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -760,6 +760,15 @@ namespace ts { }; } + function createFlowArrayMutation(antecedent: FlowNode, node: Expression): FlowNode { + setFlowNodeReferenced(antecedent); + return { + flags: FlowFlags.ArrayMutation, + antecedent, + node + }; + } + function finishFlowLabel(flow: FlowLabel): FlowNode { const antecedents = flow.antecedents; if (!antecedents) { @@ -1136,6 +1145,12 @@ namespace ts { forEachChild(node, bind); if (operator === SyntaxKind.EqualsToken && !isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); + if (node.left.kind === SyntaxKind.ElementAccessExpression) { + const elementAccess = node.left; + if (isNarrowableReference(elementAccess.expression)) { + currentFlow = createFlowArrayMutation(currentFlow, elementAccess.expression); + } + } } } } @@ -1196,6 +1211,12 @@ namespace ts { else { forEachChild(node, bind); } + if (node.expression.kind === SyntaxKind.PropertyAccessExpression) { + const propertyAccess = node.expression; + if (isNarrowableReference(propertyAccess.expression) && propertyAccess.name.text === "push") { + currentFlow = createFlowArrayMutation(currentFlow, propertyAccess.expression); + } + } } function getContainerFlags(node: Node): ContainerFlags { diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 887a406bb8c..eff52967544 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -114,6 +114,7 @@ namespace ts { const intersectionTypes = createMap(); const stringLiteralTypes = createMap(); const numericLiteralTypes = createMap(); + const evolvingArrayTypes: AnonymousType[] = []; const unknownSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "unknown"); const resolvingSymbol = createSymbol(SymbolFlags.Transient, "__resolving__"); @@ -175,6 +176,7 @@ namespace ts { let globalBooleanType: ObjectType; let globalRegExpType: ObjectType; let anyArrayType: Type; + let autoArrayType: Type; let anyReadonlyArrayType: Type; // The library files are only loaded when the feature is used. @@ -3051,9 +3053,14 @@ namespace ts { return undefined; } - function isAutoVariableInitializer(initializer: Expression) { - const expr = initializer && skipParentheses(initializer); - return !expr || expr.kind === SyntaxKind.NullKeyword || expr.kind === SyntaxKind.Identifier && getResolvedSymbol(expr) === undefinedSymbol; + function isNullOrUndefined(node: Expression) { + const expr = skipParentheses(node); + return expr.kind === SyntaxKind.NullKeyword || expr.kind === SyntaxKind.Identifier && getResolvedSymbol(expr) === undefinedSymbol; + } + + function isEmptyArrayLiteral(node: Expression) { + const expr = skipParentheses(node); + return expr.kind === SyntaxKind.ArrayLiteralExpression && (expr).elements.length === 0; } function addOptionality(type: Type, optional: boolean): Type { @@ -3094,12 +3101,18 @@ namespace ts { return addOptionality(getTypeFromTypeNode(declaration.type), /*optional*/ declaration.questionToken && includeOptionality); } - // Use control flow type inference for non-ambient, non-exported var or let variables with no initializer - // or a 'null' or 'undefined' initializer. if (declaration.kind === SyntaxKind.VariableDeclaration && !isBindingPattern(declaration.name) && - !(getCombinedNodeFlags(declaration) & NodeFlags.Const) && !(getCombinedModifierFlags(declaration) & ModifierFlags.Export) && - !isInAmbientContext(declaration) && isAutoVariableInitializer(declaration.initializer)) { - return autoType; + !(getCombinedModifierFlags(declaration) & ModifierFlags.Export) && !isInAmbientContext(declaration)) { + // Use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no + // initializer or a 'null' or 'undefined' initializer. + if (!(getCombinedNodeFlags(declaration) & NodeFlags.Const) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { + return autoType; + } + // Use control flow tracked 'any[]' type for non-ambient, non-exported variables with an empty array + // literal initializer. + if (declaration.initializer && isEmptyArrayLiteral(declaration.initializer)) { + return autoArrayType; + } } if (declaration.kind === SyntaxKind.Parameter) { @@ -8363,6 +8376,11 @@ namespace ts { getAssignedType(node); } + function isEmptyArrayAssignment(node: VariableDeclaration | BindingElement | Expression) { + return node.kind === SyntaxKind.VariableDeclaration && (node).initializer && isEmptyArrayLiteral((node).initializer) || + node.kind !== SyntaxKind.BindingElement && node.parent.kind === SyntaxKind.BinaryExpression && isEmptyArrayLiteral((node.parent).right); + } + function getReferenceCandidate(node: Expression): Expression { switch (node.kind) { case SyntaxKind.ParenthesizedExpression: @@ -8441,21 +8459,94 @@ namespace ts { return incomplete ? { flags: 0, type } : type; } + // An evolving array type tracks the element types that have so far been seen in an + // 'x.push(value)' or 'x[n] = value' operation along the control flow graph. Evolving + // array types are ultimately converted into manifest array types (using getFinalArrayType) + // and never escape the getFlowTypeOfReference function. + function createEvolvingArrayType(elementType: Type): AnonymousType { + const result = createObjectType(TypeFlags.Anonymous); + result.elementType = elementType; + return result; + } + + function getEvolvingArrayType(elementType: Type): AnonymousType { + return evolvingArrayTypes[elementType.id] || (evolvingArrayTypes[elementType.id] = createEvolvingArrayType(elementType)); + } + + // When adding evolving array element types we do not perform subtype reduction. Instead, + // we defer subtype reduction until the evolving array type is finalized into a manifest + // array type. + function addEvolvingArrayElementType(evolvingArrayType: AnonymousType, node: Expression): AnonymousType { + const elementType = getBaseTypeOfLiteralType(checkExpression(node)); + return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType])); + } + + function isEvolvingArrayType(type: Type) { + return type.flags & TypeFlags.Anonymous && !!(type).elementType; + } + + // We perform subtype reduction upon obtaining the final array type from an evolving array type. + function getFinalArrayType(evolvingArrayType: AnonymousType): Type { + return evolvingArrayType.finalArrayType || (evolvingArrayType.finalArrayType = createArrayType(getUnionType([evolvingArrayType.elementType], /*subtypeReduction*/ true))); + } + + function finalizeEvolvingArrayType(type: Type): Type { + return isEvolvingArrayType(type) ? getFinalArrayType(type) : type; + } + + function getElementTypeOfEvolvingArrayType(evolvingArrayType: AnonymousType) { + return evolvingArrayType.elementType; + } + + // At flow control branch or loop junctions, if the type along every antecedent code path + // is an evolving array type, we construct a combined evolving array type. Otherwise we + // finalize all evolving array types. + function getUnionOrEvolvingArrayType(types: Type[], subtypeReduction: boolean) { + return types.length && every(types, isEvolvingArrayType) ? + getEvolvingArrayType(getUnionType(map(types, getElementTypeOfEvolvingArrayType))) : + getUnionType(map(types, finalizeEvolvingArrayType), subtypeReduction); + } + + // Return true if the given node is 'x' in an 'x.push(value)' operation. + function isPushCallTarget(node: Node) { + return node.parent.kind === SyntaxKind.PropertyAccessExpression && + (node.parent).name.text === "push" && + node.parent.parent.kind === SyntaxKind.CallExpression; + } + + // Return true if the given node is 'x' in an 'x[n] = value' operation, where 'n' is an + // expression of type any, undefined, or a number-like type. + function isElementAssignmentTarget(node: Node) { + const parent = node.parent; + return parent.kind === SyntaxKind.ElementAccessExpression && + (parent).expression === node && + parent.parent.kind === SyntaxKind.BinaryExpression && + (parent.parent).operatorToken.kind === SyntaxKind.EqualsToken && + (parent.parent).left === parent && + !isAssignmentTarget(parent.parent) && + isTypeAnyOrAllConstituentTypesHaveKind(checkExpression((parent).argumentExpression), TypeFlags.NumberLike | TypeFlags.Undefined); + } + function getFlowTypeOfReference(reference: Node, declaredType: Type, assumeInitialized: boolean, flowContainer: Node) { let key: string; if (!reference.flowNode || assumeInitialized && !(declaredType.flags & TypeFlags.Narrowable)) { return declaredType; } const initialType = assumeInitialized ? declaredType : - declaredType === autoType ? undefinedType : + declaredType === autoType || declaredType === autoArrayType ? undefinedType : includeFalsyTypes(declaredType, TypeFlags.Undefined); const visitedFlowStart = visitedFlowCount; - const result = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); + const evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); visitedFlowCount = visitedFlowStart; - if (reference.parent.kind === SyntaxKind.NonNullExpression && getTypeWithFacts(result, TypeFacts.NEUndefinedOrNull).flags & TypeFlags.Never) { + // When the reference is 'x' in an 'x.push(value)' or 'x[n] = value' operation, we give type + // 'any[]' to 'x' instead of using the type determed by control flow analysis such that new + // element types are not considered errors. + const isEvolvingArrayInferenceTarget = isEvolvingArrayType(evolvedType) && (isPushCallTarget(reference) || isElementAssignmentTarget(reference)); + const resultType = isEvolvingArrayInferenceTarget ? anyArrayType : finalizeEvolvingArrayType(evolvedType); + if (reference.parent.kind === SyntaxKind.NonNullExpression && getTypeWithFacts(resultType, TypeFacts.NEUndefinedOrNull).flags & TypeFlags.Never) { return declaredType; } - return result; + return resultType; function getTypeAtFlowNode(flow: FlowNode): FlowType { while (true) { @@ -8492,6 +8583,13 @@ namespace ts { getTypeAtFlowBranchLabel(flow) : getTypeAtFlowLoopLabel(flow); } + else if (flow.flags & FlowFlags.ArrayMutation) { + type = getTypeAtFlowArrayMutation(flow); + if (!type) { + flow = (flow).antecedent; + continue; + } + } else if (flow.flags & FlowFlags.Start) { // Check if we should continue with the control flow of the containing function. const container = (flow).container; @@ -8504,8 +8602,8 @@ namespace ts { } else { // Unreachable code errors are reported in the binding phase. Here we - // simply return the declared type to reduce follow-on errors. - type = declaredType; + // simply return the non-auto declared type to reduce follow-on errors. + type = convertAutoToAny(declaredType); } if (flow.flags & FlowFlags.Shared) { // Record visited node and the associated type in the cache. @@ -8526,9 +8624,17 @@ namespace ts { const flowType = getTypeAtFlowNode(flow.antecedent); return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType)); } - return declaredType === autoType ? getBaseTypeOfLiteralType(getInitialOrAssignedType(node)) : - declaredType.flags & TypeFlags.Union ? getAssignmentReducedType(declaredType, getInitialOrAssignedType(node)) : - declaredType; + if (declaredType === autoType || declaredType === autoArrayType) { + if (isEmptyArrayAssignment(node)) { + return getEvolvingArrayType(neverType); + } + const assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(node)); + return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; + } + if (declaredType.flags & TypeFlags.Union) { + return getAssignmentReducedType(declaredType, getInitialOrAssignedType(node)); + } + return declaredType; } // We didn't have a direct match. However, if the reference is a dotted name, this // may be an assignment to a left hand part of the reference. For example, for a @@ -8541,24 +8647,51 @@ namespace ts { return undefined; } + function getTypeAtFlowArrayMutation(flow: FlowArrayMutation): FlowType { + const node = flow.node; + if (isMatchingReference(reference, node)) { + const flowType = getTypeAtFlowNode(flow.antecedent); + const type = getTypeFromFlowType(flowType); + if (isEvolvingArrayType(type)) { + const parent = node.parent; + let evolvedType = type; + if (parent.kind === SyntaxKind.PropertyAccessExpression) { + for (const arg of (parent.parent).arguments) { + evolvedType = addEvolvingArrayElementType(evolvedType, arg); + } + } + else if (isTypeAnyOrAllConstituentTypesHaveKind(checkExpression((parent).argumentExpression), TypeFlags.NumberLike)) { + evolvedType = addEvolvingArrayElementType(evolvedType, (parent.parent).right); + } + return evolvedType === type ? flowType : createFlowType(evolvedType, isIncomplete(flowType)); + } + return flowType; + } + return undefined; + } + function getTypeAtFlowCondition(flow: FlowCondition): FlowType { const flowType = getTypeAtFlowNode(flow.antecedent); - let type = getTypeFromFlowType(flowType); - if (!(type.flags & TypeFlags.Never)) { - // If we have an antecedent type (meaning we're reachable in some way), we first - // attempt to narrow the antecedent type. If that produces the never type, and if - // the antecedent type is incomplete (i.e. a transient type in a loop), then we - // take the type guard as an indication that control *could* reach here once we - // have the complete type. We proceed by switching to the silent never type which - // doesn't report errors when operators are applied to it. Note that this is the - // *only* place a silent never type is ever generated. - const assumeTrue = (flow.flags & FlowFlags.TrueCondition) !== 0; - type = narrowType(type, flow.expression, assumeTrue); - if (type.flags & TypeFlags.Never && isIncomplete(flowType)) { - type = silentNeverType; - } + const type = getTypeFromFlowType(flowType); + if (type.flags & TypeFlags.Never) { + return flowType; } - return createFlowType(type, isIncomplete(flowType)); + // If we have an antecedent type (meaning we're reachable in some way), we first + // attempt to narrow the antecedent type. If that produces the never type, and if + // the antecedent type is incomplete (i.e. a transient type in a loop), then we + // take the type guard as an indication that control *could* reach here once we + // have the complete type. We proceed by switching to the silent never type which + // doesn't report errors when operators are applied to it. Note that this is the + // *only* place a silent never type is ever generated. + const assumeTrue = (flow.flags & FlowFlags.TrueCondition) !== 0; + const nonEvolvingType = finalizeEvolvingArrayType(type); + const narrowedType = narrowType(nonEvolvingType, flow.expression, assumeTrue); + if (narrowedType === nonEvolvingType) { + return flowType; + } + const incomplete = isIncomplete(flowType); + const resultType = incomplete && narrowedType.flags & TypeFlags.Never ? silentNeverType : narrowedType; + return createFlowType(resultType, incomplete); } function getTypeAtSwitchClause(flow: FlowSwitchClause): FlowType { @@ -8601,7 +8734,7 @@ namespace ts { seenIncomplete = true; } } - return createFlowType(getUnionType(antecedentTypes, subtypeReduction), seenIncomplete); + return createFlowType(getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction), seenIncomplete); } function getTypeAtFlowLoopLabel(flow: FlowLabel): FlowType { @@ -8621,7 +8754,7 @@ namespace ts { // junction is always the non-looping control flow path that leads to the top. for (let i = flowLoopStart; i < flowLoopCount; i++) { if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key) { - return createFlowType(getUnionType(flowLoopTypes[i]), /*incomplete*/ true); + return createFlowType(getUnionOrEvolvingArrayType(flowLoopTypes[i], false), /*incomplete*/ true); } } // Add the flow loop junction and reference to the in-process stack and analyze @@ -8664,7 +8797,7 @@ namespace ts { } // The result is incomplete if the first antecedent (the non-looping control flow path) // is incomplete. - const result = getUnionType(antecedentTypes, subtypeReduction); + const result = getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction); if (isIncomplete(firstAntecedentType)) { return createFlowType(result, /*incomplete*/ true); } @@ -9143,19 +9276,19 @@ namespace ts { // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). const assumeInitialized = isParameter || isOuterVariable || - type !== autoType && (!strictNullChecks || (type.flags & TypeFlags.Any) !== 0) || + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & TypeFlags.Any) !== 0) || isInAmbientContext(declaration); const flowType = getFlowTypeOfReference(node, type, assumeInitialized, flowContainer); // A variable is considered uninitialized when it is possible to analyze the entire control flow graph // from declaration to use, and when the variable's declared type doesn't include undefined but the // control flow based type does include undefined. - if (type === autoType) { - if (flowType === autoType) { + if (type === autoType || type === autoArrayType) { + if (flowType === type) { if (compilerOptions.noImplicitAny) { - error(declaration.name, Diagnostics.Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol)); - error(node, Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(anyType)); + error(declaration.name, Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol), typeToString(type)); + error(node, Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(type)); } - return anyType; + return convertAutoToAny(type); } } else if (!assumeInitialized && !(getFalsyFlags(type) & TypeFlags.Undefined) && getFalsyFlags(flowType) & TypeFlags.Undefined) { @@ -15904,7 +16037,7 @@ namespace ts { } function convertAutoToAny(type: Type) { - return type === autoType ? anyType : type; + return type === autoType ? anyType : type === autoArrayType ? anyArrayType : type; } // Check variable, parameter, or property declaration @@ -19307,6 +19440,7 @@ namespace ts { } anyArrayType = createArrayType(anyType); + autoArrayType = createArrayType(autoType); const symbol = getGlobalSymbol("ReadonlyArray", SymbolFlags.Type, /*diagnostic*/ undefined); globalReadonlyArrayType = symbol && getTypeOfGlobalSymbol(symbol, /*arity*/ 1); diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index fe196b29216..7a73b31e1a8 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2953,7 +2953,7 @@ "category": "Error", "code": 7033 }, - "Variable '{0}' implicitly has type 'any' in some locations where its type cannot be determined.": { + "Variable '{0}' implicitly has type '{1}' in some locations where its type cannot be determined.": { "category": "Error", "code": 7034 }, diff --git a/src/compiler/types.ts b/src/compiler/types.ts index ab48ae543c2..5b34c5bfbf6 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1681,8 +1681,9 @@ namespace ts { TrueCondition = 1 << 5, // Condition known to be true FalseCondition = 1 << 6, // Condition known to be false SwitchClause = 1 << 7, // Switch statement clause - Referenced = 1 << 8, // Referenced as antecedent once - Shared = 1 << 9, // Referenced as antecedent more than once + ArrayMutation = 1 << 8, // Potential array mutation + Referenced = 1 << 9, // Referenced as antecedent once + Shared = 1 << 10, // Referenced as antecedent more than once Label = BranchLabel | LoopLabel, Condition = TrueCondition | FalseCondition } @@ -1725,6 +1726,13 @@ namespace ts { antecedent: FlowNode; } + // FlowArrayMutation represents a node potentially mutates an array, i.e. an + // operation of the form 'x.push(value)' or 'x[n] = value'. + export interface FlowArrayMutation extends FlowNode { + node: Expression; + antecedent: FlowNode; + } + export type FlowType = Type | IncompleteType; // Incomplete types occur during control flow analysis of loops. An IncompleteType @@ -2521,6 +2529,8 @@ namespace ts { export interface AnonymousType extends ObjectType { target?: AnonymousType; // Instantiation target mapper?: TypeMapper; // Instantiation mapper + elementType?: Type; // Element expressions of evolving array type + finalArrayType?: Type; // Final array type of evolving array type } /* @internal */ From b5c10553b5ef29da07d66b5ca0a0e3689dc14790 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 6 Oct 2016 11:05:55 -0700 Subject: [PATCH 018/173] Accept new baselines --- .../reference/arrayLiterals2ES5.types | 8 ++--- .../genericTypeParameterEquivalence2.types | 2 +- .../reference/globalThisCapture.types | 4 +-- .../implicitAnyWidenToAny.errors.txt | 5 +-- .../reference/localClassesInLoop.types | 12 +++---- .../reference/localClassesInLoop_ES6.types | 12 +++---- .../strictNullChecksNoWidening.types | 2 +- tests/baselines/reference/typedArrays.types | 36 +++++++++---------- 8 files changed, 39 insertions(+), 42 deletions(-) diff --git a/tests/baselines/reference/arrayLiterals2ES5.types b/tests/baselines/reference/arrayLiterals2ES5.types index c3256db925e..4c5f895114d 100644 --- a/tests/baselines/reference/arrayLiterals2ES5.types +++ b/tests/baselines/reference/arrayLiterals2ES5.types @@ -193,10 +193,10 @@ var d5 = [...temp3]; >temp3 : any[] var d6 = [...temp4]; ->d6 : any[] ->[...temp4] : any[] ->...temp4 : any ->temp4 : any[] +>d6 : never[] +>[...temp4] : never[] +>...temp4 : never +>temp4 : never[] var d7 = [...[...temp1]]; >d7 : number[] diff --git a/tests/baselines/reference/genericTypeParameterEquivalence2.types b/tests/baselines/reference/genericTypeParameterEquivalence2.types index 6ab297fe32c..095ce27c752 100644 --- a/tests/baselines/reference/genericTypeParameterEquivalence2.types +++ b/tests/baselines/reference/genericTypeParameterEquivalence2.types @@ -105,7 +105,7 @@ function filter(f: (a: A) => boolean, ar: A[]): A[] { } ); return ret; ->ret : any[] +>ret : never[] } // length :: [a] -> Num diff --git a/tests/baselines/reference/globalThisCapture.types b/tests/baselines/reference/globalThisCapture.types index 063100ff78e..92a20ff930e 100644 --- a/tests/baselines/reference/globalThisCapture.types +++ b/tests/baselines/reference/globalThisCapture.types @@ -13,7 +13,7 @@ var parts = []; // Ensure that the generated code is correct parts[0]; ->parts[0] : any ->parts : any[] +>parts[0] : never +>parts : never[] >0 : 0 diff --git a/tests/baselines/reference/implicitAnyWidenToAny.errors.txt b/tests/baselines/reference/implicitAnyWidenToAny.errors.txt index 95739a450a8..7a9314d982f 100644 --- a/tests/baselines/reference/implicitAnyWidenToAny.errors.txt +++ b/tests/baselines/reference/implicitAnyWidenToAny.errors.txt @@ -1,8 +1,7 @@ tests/cases/compiler/implicitAnyWidenToAny.ts(4,5): error TS7005: Variable 'widenArray' implicitly has an 'any[]' type. -tests/cases/compiler/implicitAnyWidenToAny.ts(5,5): error TS7005: Variable 'emptyArray' implicitly has an 'any[]' type. -==== tests/cases/compiler/implicitAnyWidenToAny.ts (2 errors) ==== +==== tests/cases/compiler/implicitAnyWidenToAny.ts (1 errors) ==== // these should be errors var x = null; // error at "x" var x1 = undefined; // error at "x1" @@ -10,8 +9,6 @@ tests/cases/compiler/implicitAnyWidenToAny.ts(5,5): error TS7005: Variable 'empt ~~~~~~~~~~ !!! error TS7005: Variable 'widenArray' implicitly has an 'any[]' type. var emptyArray = []; // error at "emptyArray" - ~~~~~~~~~~ -!!! error TS7005: Variable 'emptyArray' implicitly has an 'any[]' type. // these should not be error class AnimalObj { diff --git a/tests/baselines/reference/localClassesInLoop.types b/tests/baselines/reference/localClassesInLoop.types index c88bfc0435d..88050445898 100644 --- a/tests/baselines/reference/localClassesInLoop.types +++ b/tests/baselines/reference/localClassesInLoop.types @@ -35,12 +35,12 @@ use(data[0]() === data[1]()); >use(data[0]() === data[1]()) : any >use : (a: any) => any >data[0]() === data[1]() : boolean ->data[0]() : any ->data[0] : any ->data : any[] +>data[0]() : typeof C +>data[0] : () => typeof C +>data : (() => typeof C)[] >0 : 0 ->data[1]() : any ->data[1] : any ->data : any[] +>data[1]() : typeof C +>data[1] : () => typeof C +>data : (() => typeof C)[] >1 : 1 diff --git a/tests/baselines/reference/localClassesInLoop_ES6.types b/tests/baselines/reference/localClassesInLoop_ES6.types index 9d487f6c600..390f4b8b1dd 100644 --- a/tests/baselines/reference/localClassesInLoop_ES6.types +++ b/tests/baselines/reference/localClassesInLoop_ES6.types @@ -36,12 +36,12 @@ use(data[0]() === data[1]()); >use(data[0]() === data[1]()) : any >use : (a: any) => any >data[0]() === data[1]() : boolean ->data[0]() : any ->data[0] : any ->data : any[] +>data[0]() : typeof C +>data[0] : () => typeof C +>data : (() => typeof C)[] >0 : 0 ->data[1]() : any ->data[1] : any ->data : any[] +>data[1]() : typeof C +>data[1] : () => typeof C +>data : (() => typeof C)[] >1 : 1 diff --git a/tests/baselines/reference/strictNullChecksNoWidening.types b/tests/baselines/reference/strictNullChecksNoWidening.types index 375977ae375..e24797850ee 100644 --- a/tests/baselines/reference/strictNullChecksNoWidening.types +++ b/tests/baselines/reference/strictNullChecksNoWidening.types @@ -14,7 +14,7 @@ var a3 = void 0; >0 : 0 var b1 = []; ->b1 : never[] +>b1 : any[] >[] : never[] var b2 = [,]; diff --git a/tests/baselines/reference/typedArrays.types b/tests/baselines/reference/typedArrays.types index 444d6a74e43..cd2103f6461 100644 --- a/tests/baselines/reference/typedArrays.types +++ b/tests/baselines/reference/typedArrays.types @@ -1,7 +1,7 @@ === tests/cases/compiler/typedArrays.ts === function CreateTypedArrayTypes() { ->CreateTypedArrayTypes : () => any[] +>CreateTypedArrayTypes : () => (Int8ArrayConstructor | Uint8ArrayConstructor | Int16ArrayConstructor | Uint16ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor | Uint8ClampedArrayConstructor)[] var typedArrays = []; >typedArrays : any[] @@ -71,11 +71,11 @@ function CreateTypedArrayTypes() { >Uint8ClampedArray : Uint8ClampedArrayConstructor return typedArrays; ->typedArrays : any[] +>typedArrays : (Int8ArrayConstructor | Uint8ArrayConstructor | Int16ArrayConstructor | Uint16ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor | Uint8ClampedArrayConstructor)[] } function CreateTypedArrayInstancesFromLength(obj: number) { ->CreateTypedArrayInstancesFromLength : (obj: number) => any[] +>CreateTypedArrayInstancesFromLength : (obj: number) => (Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array)[] >obj : number var typedArrays = []; @@ -164,11 +164,11 @@ function CreateTypedArrayInstancesFromLength(obj: number) { >obj : number return typedArrays; ->typedArrays : any[] +>typedArrays : (Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array)[] } function CreateTypedArrayInstancesFromArray(obj: number[]) { ->CreateTypedArrayInstancesFromArray : (obj: number[]) => any[] +>CreateTypedArrayInstancesFromArray : (obj: number[]) => (Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array)[] >obj : number[] var typedArrays = []; @@ -257,11 +257,11 @@ function CreateTypedArrayInstancesFromArray(obj: number[]) { >obj : number[] return typedArrays; ->typedArrays : any[] +>typedArrays : (Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array)[] } function CreateIntegerTypedArraysFromArray2(obj:number[]) { ->CreateIntegerTypedArraysFromArray2 : (obj: number[]) => any[] +>CreateIntegerTypedArraysFromArray2 : (obj: number[]) => (Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array)[] >obj : number[] var typedArrays = []; @@ -368,11 +368,11 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >obj : number[] return typedArrays; ->typedArrays : any[] +>typedArrays : (Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array)[] } function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { ->CreateIntegerTypedArraysFromArrayLike : (obj: ArrayLike) => any[] +>CreateIntegerTypedArraysFromArrayLike : (obj: ArrayLike) => (Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array)[] >obj : ArrayLike >ArrayLike : ArrayLike @@ -480,11 +480,11 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >obj : ArrayLike return typedArrays; ->typedArrays : any[] +>typedArrays : (Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array)[] } function CreateTypedArraysOf(obj) { ->CreateTypedArraysOf : (obj: any) => any[] +>CreateTypedArraysOf : (obj: any) => (Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array)[] >obj : any var typedArrays = []; @@ -600,11 +600,11 @@ function CreateTypedArraysOf(obj) { >obj : any return typedArrays; ->typedArrays : any[] +>typedArrays : (Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array)[] } function CreateTypedArraysOf2() { ->CreateTypedArraysOf2 : () => any[] +>CreateTypedArraysOf2 : () => (Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array)[] var typedArrays = []; >typedArrays : any[] @@ -737,11 +737,11 @@ function CreateTypedArraysOf2() { >4 : 4 return typedArrays; ->typedArrays : any[] +>typedArrays : (Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array)[] } function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:number)=> number) { ->CreateTypedArraysFromMapFn : (obj: ArrayLike, mapFn: (n: number, v: number) => number) => any[] +>CreateTypedArraysFromMapFn : (obj: ArrayLike, mapFn: (n: number, v: number) => number) => (Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array)[] >obj : ArrayLike >ArrayLike : ArrayLike >mapFn : (n: number, v: number) => number @@ -861,11 +861,11 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >mapFn : (n: number, v: number) => number return typedArrays; ->typedArrays : any[] +>typedArrays : (Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array)[] } function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v:number)=> number, thisArg: {}) { ->CreateTypedArraysFromThisObj : (obj: ArrayLike, mapFn: (n: number, v: number) => number, thisArg: {}) => any[] +>CreateTypedArraysFromThisObj : (obj: ArrayLike, mapFn: (n: number, v: number) => number, thisArg: {}) => (Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array)[] >obj : ArrayLike >ArrayLike : ArrayLike >mapFn : (n: number, v: number) => number @@ -995,5 +995,5 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >thisArg : {} return typedArrays; ->typedArrays : any[] +>typedArrays : (Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array)[] } From 163e758e1060616f6fd4a4ebb12ec1a02acd559c Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Thu, 6 Oct 2016 11:44:53 -0700 Subject: [PATCH 019/173] Handle case where this access is inside the supercall --- src/harness/fourslash.ts | 35 +++++++++++++++++++++------- src/services/codefixes/superFixes.ts | 13 ++++++++++- tests/cases/fourslash/fourslash.ts | 1 + tests/cases/fourslash/superFix3.ts | 12 ++++++++++ 4 files changed, 52 insertions(+), 9 deletions(-) create mode 100644 tests/cases/fourslash/superFix3.ts diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 7192cf180e1..5fc2674404f 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -2041,13 +2041,7 @@ namespace FourSlash { } } - public verifyCodeFixAtPosition(expectedText: string, errorCode?: number) { - - const ranges = this.getRanges(); - if (ranges.length == 0) { - this.raiseError("At least one range should be specified in the testfile."); - } - + private getCodeFixes(errorCode?: number) { const fileName = this.activeFile.fileName; const diagnostics = this.getDiagnostics(fileName); @@ -2061,7 +2055,16 @@ namespace FourSlash { const diagnostic = !errorCode ? diagnostics[0] : ts.find(diagnostics, d => d.code == errorCode); - const actual = this.languageService.getCodeFixesAtPosition(fileName, diagnostic.start, diagnostic.length, [`TS${diagnostic.code}`]); + return this.languageService.getCodeFixesAtPosition(fileName, diagnostic.start, diagnostic.length, [`TS${diagnostic.code}`]); + } + + public verifyCodeFixAtPosition(expectedText: string, errorCode?: number) { + const ranges = this.getRanges(); + if (ranges.length == 0) { + this.raiseError("At least one range should be specified in the testfile."); + } + + const actual = this.getCodeFixes(errorCode); if (!actual || actual.length == 0) { this.raiseError("No codefixes returned."); @@ -2350,6 +2353,18 @@ namespace FourSlash { } } + public verifyCodeFixAvailable(negative: boolean, errorCode?:number ) { + const fixes = this.getCodeFixes(errorCode); + + if (negative && fixes && fixes.length > 0) { + this.raiseError(`verifyCodeFixAvailable failed - expected no fixes, actual: ${fixes.length}`); + } + + if (!negative && (fixes === undefined || fixes.length === 0)) { + this.raiseError(`verifyCodeFixAvailable failed - expected code fixes, actual: 0`); + } + } + // Get the text of the entire line the caret is currently at private getCurrentLineContent() { const text = this.getFileContent(this.activeFile.fileName); @@ -3137,6 +3152,10 @@ namespace FourSlashInterface { public isValidBraceCompletionAtPosition(openingBrace: string) { this.state.verifyBraceCompletionAtPosition(this.negative, openingBrace); } + + public codeFixAvailable(errorCode?: number) { + this.state.verifyCodeFixAvailable(this.negative, errorCode); + } } export class Verify extends VerifyNegatable { diff --git a/src/services/codefixes/superFixes.ts b/src/services/codefixes/superFixes.ts index c61e4281e8f..2f0a78580cb 100644 --- a/src/services/codefixes/superFixes.ts +++ b/src/services/codefixes/superFixes.ts @@ -34,11 +34,22 @@ namespace ts.codefix { } const constructor = getContainingFunction(token); - const superCall = findSuperCall((constructor).body); + const superCall = findSuperCall((constructor).body); if (!superCall) { return undefined; } + // figure out if the this access is actuall inside the supercall + // i.e. super(this.a), since in that case we won't suggest a fix + if (superCall.expression && superCall.expression.kind == SyntaxKind.CallExpression) { + const arguments = (superCall.expression).arguments; + for (let i = 0; i < arguments.length; i++){ + if ((arguments[i]).expression === token) { + return undefined; + } + } + } + const newPosition = getOpenBraceEnd(constructor, sourceFile); const changes = [{ fileName: sourceFile.fileName, textChanges: [{ diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 042f6d563a5..5e8666e8670 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -136,6 +136,7 @@ declare namespace FourSlashInterface { typeDefinitionCountIs(expectedCount: number): void; implementationListIsEmpty(): void; isValidBraceCompletionAtPosition(openingBrace?: string): void; + codeFixAvailable(): void; } class verify extends verifyNegatable { assertHasRanges(ranges: Range[]): void; diff --git a/tests/cases/fourslash/superFix3.ts b/tests/cases/fourslash/superFix3.ts new file mode 100644 index 00000000000..9b443b7df62 --- /dev/null +++ b/tests/cases/fourslash/superFix3.ts @@ -0,0 +1,12 @@ +/// + +////class Base{ +//// constructor(id: number) { } +////} +////class C extends Base{ +//// constructor(private a:number) { +//// super(this.a); +//// } +////} + +verify.not.codeFixAvailable(); \ No newline at end of file From 75e1b80ad59d54af5029cdc61ec14a756a0b0063 Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Thu, 6 Oct 2016 13:21:58 -0700 Subject: [PATCH 020/173] Use just the errorcode, without the TS prefix --- src/harness/fourslash.ts | 2 +- src/harness/harnessLanguageService.ts | 2 +- src/server/client.ts | 2 +- src/server/protocol.d.ts | 2 +- src/services/codefixes/codeFixProvider.ts | 6 +++--- src/services/codefixes/superFixes.ts | 8 ++++---- src/services/services.ts | 2 +- src/services/shims.ts | 2 +- src/services/types.ts | 2 +- 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 5fc2674404f..cadda289daa 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -2055,7 +2055,7 @@ namespace FourSlash { const diagnostic = !errorCode ? diagnostics[0] : ts.find(diagnostics, d => d.code == errorCode); - return this.languageService.getCodeFixesAtPosition(fileName, diagnostic.start, diagnostic.length, [`TS${diagnostic.code}`]); + return this.languageService.getCodeFixesAtPosition(fileName, diagnostic.start, diagnostic.length, [diagnostic.code]); } public verifyCodeFixAtPosition(expectedText: string, errorCode?: number) { diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 514049511fc..6af168796f9 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -486,7 +486,7 @@ namespace Harness.LanguageService { isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean { return unwrapJSONCallResult(this.shim.isValidBraceCompletionAtPosition(fileName, position, openingBrace)); } - getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): ts.CodeAction[] { + getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[]): ts.CodeAction[] { return unwrapJSONCallResult(this.shim.getCodeFixesAtPosition(fileName, start, end, JSON.stringify(errorCodes))); } getEmitOutput(fileName: string): ts.EmitOutput { diff --git a/src/server/client.ts b/src/server/client.ts index f9fdf624232..089a0eed12c 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -630,7 +630,7 @@ namespace ts.server { throw new Error("Not Implemented Yet."); } - getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): ts.CodeAction[] { + getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[]): ts.CodeAction[] { throw new Error("Not Implemented Yet."); } diff --git a/src/server/protocol.d.ts b/src/server/protocol.d.ts index e8919f843eb..02e488650cd 100644 --- a/src/server/protocol.d.ts +++ b/src/server/protocol.d.ts @@ -247,7 +247,7 @@ declare namespace ts.server.protocol { /** * Errorcodes we want to get the fixes for. */ - errorCodes?: string[] + errorCodes?: number[] } /** diff --git a/src/services/codefixes/codeFixProvider.ts b/src/services/codefixes/codeFixProvider.ts index 55aa8d38f7a..bc5ee1fb97e 100644 --- a/src/services/codefixes/codeFixProvider.ts +++ b/src/services/codefixes/codeFixProvider.ts @@ -1,12 +1,12 @@ -/* @internal */ +/* @internal */ namespace ts { export interface CodeFix { - errorCodes: string[]; + errorCodes: number[]; getCodeActions(context: CodeFixContext): CodeAction[]; } export interface CodeFixContext { - errorCode: string; + errorCode: number; sourceFile: SourceFile; span: TextSpan; program: Program; diff --git a/src/services/codefixes/superFixes.ts b/src/services/codefixes/superFixes.ts index 2f0a78580cb..35462f0d49e 100644 --- a/src/services/codefixes/superFixes.ts +++ b/src/services/codefixes/superFixes.ts @@ -1,4 +1,4 @@ -/* @internal */ +/* @internal */ namespace ts.codefix { function getOpenBraceEnd(constructor: ConstructorDeclaration, sourceFile: SourceFile) { // First token is the open curly, this is where we want to put the 'super' call. @@ -6,7 +6,7 @@ namespace ts.codefix { } registerCodeFix({ - errorCodes: [`TS${Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call.code}`], + errorCodes: [Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call.code], getCodeActions: (context: CodeFixContext) => { const sourceFile = context.sourceFile; const token = getTokenAtPosition(sourceFile, context.span.start); @@ -24,7 +24,7 @@ namespace ts.codefix { }); registerCodeFix({ - errorCodes: [`TS${Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class.code}`], + errorCodes: [Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class.code], getCodeActions: (context: CodeFixContext) => { const sourceFile = context.sourceFile; @@ -43,7 +43,7 @@ namespace ts.codefix { // i.e. super(this.a), since in that case we won't suggest a fix if (superCall.expression && superCall.expression.kind == SyntaxKind.CallExpression) { const arguments = (superCall.expression).arguments; - for (let i = 0; i < arguments.length; i++){ + for (let i = 0; i < arguments.length; i++) { if ((arguments[i]).expression === token) { return undefined; } diff --git a/src/services/services.ts b/src/services/services.ts index 050096b45d4..7f81649bacb 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1639,7 +1639,7 @@ namespace ts { return []; } - function getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): CodeAction[] { + function getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[]): CodeAction[] { synchronizeHostData(); const sourceFile = getValidSourceFile(fileName); const span = { start, length: end - start }; diff --git a/src/services/shims.ts b/src/services/shims.ts index 63f766eff5a..19dadba89bf 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -961,7 +961,7 @@ namespace ts { return this.forwardJSONCall( `getCodeFixesAtPosition( '${fileName}', ${start}, ${end}, ${errorCodes}')`, () => { - const localErrors: string[] = JSON.parse(errorCodes); + const localErrors: number[] = JSON.parse(errorCodes); return this.languageService.getCodeFixesAtPosition(fileName, start, end, localErrors); } ); diff --git a/src/services/types.ts b/src/services/types.ts index f8b57ab0d32..59abe2f7998 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -239,7 +239,7 @@ namespace ts { isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean; - getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): CodeAction[]; + getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[]): CodeAction[]; getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean): EmitOutput; From 9c4190b1fb31b6317efc15430c2047ca78779ff0 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 6 Oct 2016 13:25:42 -0700 Subject: [PATCH 021/173] Introduce sameMap function --- src/compiler/checker.ts | 26 ++++++++++++++++---------- src/compiler/core.ts | 24 ++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 12 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index eff52967544..414a92ffed4 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7404,7 +7404,7 @@ namespace ts { type.flags & TypeFlags.NumberLiteral ? numberType : type.flags & TypeFlags.BooleanLiteral ? booleanType : type.flags & TypeFlags.EnumLiteral ? (type).baseType : - type.flags & TypeFlags.Union && !(type.flags & TypeFlags.Enum) ? getUnionType(map((type).types, getBaseTypeOfLiteralType)) : + type.flags & TypeFlags.Union && !(type.flags & TypeFlags.Enum) ? getUnionType(sameMap((type).types, getBaseTypeOfLiteralType)) : type; } @@ -7413,7 +7413,7 @@ namespace ts { type.flags & TypeFlags.NumberLiteral && type.flags & TypeFlags.FreshLiteral ? numberType : type.flags & TypeFlags.BooleanLiteral ? booleanType : type.flags & TypeFlags.EnumLiteral ? (type).baseType : - type.flags & TypeFlags.Union && !(type.flags & TypeFlags.Enum) ? getUnionType(map((type).types, getWidenedLiteralType)) : + type.flags & TypeFlags.Union && !(type.flags & TypeFlags.Enum) ? getUnionType(sameMap((type).types, getWidenedLiteralType)) : type; } @@ -7552,10 +7552,10 @@ namespace ts { return getWidenedTypeOfObjectLiteral(type); } if (type.flags & TypeFlags.Union) { - return getUnionType(map((type).types, getWidenedConstituentType)); + return getUnionType(sameMap((type).types, getWidenedConstituentType)); } if (isArrayType(type) || isTupleType(type)) { - return createTypeReference((type).target, map((type).typeArguments, getWidenedType)); + return createTypeReference((type).target, sameMap((type).typeArguments, getWidenedType)); } } return type; @@ -7973,7 +7973,7 @@ namespace ts { const widenLiteralTypes = context.inferences[index].topLevel && !hasPrimitiveConstraint(signature.typeParameters[index]) && (context.inferences[index].isFixed || !isTypeParameterAtTopLevel(getReturnTypeOfSignature(signature), signature.typeParameters[index])); - const baseInferences = widenLiteralTypes ? map(inferences, getWidenedLiteralType) : inferences; + const baseInferences = widenLiteralTypes ? sameMap(inferences, getWidenedLiteralType) : inferences; // Infer widened union or supertype, or the unknown type for no common supertype const unionOrSuperType = context.inferUnionTypes ? getUnionType(baseInferences, /*subtypeReduction*/ true) : getCommonSupertype(baseInferences); inferredType = unionOrSuperType ? getWidenedType(unionOrSuperType) : unknownType; @@ -8485,9 +8485,15 @@ namespace ts { return type.flags & TypeFlags.Anonymous && !!(type).elementType; } + function createFinalArrayType(elementType: Type) { + return createArrayType(elementType !== neverType ? + getUnionType([elementType], /*subtypeReduction*/ true) : + strictNullChecks ? neverType : undefinedWideningType); + } + // We perform subtype reduction upon obtaining the final array type from an evolving array type. function getFinalArrayType(evolvingArrayType: AnonymousType): Type { - return evolvingArrayType.finalArrayType || (evolvingArrayType.finalArrayType = createArrayType(getUnionType([evolvingArrayType.elementType], /*subtypeReduction*/ true))); + return evolvingArrayType.finalArrayType || (evolvingArrayType.finalArrayType = createFinalArrayType(evolvingArrayType.elementType)); } function finalizeEvolvingArrayType(type: Type): Type { @@ -8504,7 +8510,7 @@ namespace ts { function getUnionOrEvolvingArrayType(types: Type[], subtypeReduction: boolean) { return types.length && every(types, isEvolvingArrayType) ? getEvolvingArrayType(getUnionType(map(types, getElementTypeOfEvolvingArrayType))) : - getUnionType(map(types, finalizeEvolvingArrayType), subtypeReduction); + getUnionType(sameMap(types, finalizeEvolvingArrayType), subtypeReduction); } // Return true if the given node is 'x' in an 'x.push(value)' operation. @@ -8754,7 +8760,7 @@ namespace ts { // junction is always the non-looping control flow path that leads to the top. for (let i = flowLoopStart; i < flowLoopCount; i++) { if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key) { - return createFlowType(getUnionOrEvolvingArrayType(flowLoopTypes[i], false), /*incomplete*/ true); + return createFlowType(getUnionOrEvolvingArrayType(flowLoopTypes[i], /*subtypeReduction*/ false), /*incomplete*/ true); } } // Add the flow loop junction and reference to the in-process stack and analyze @@ -10728,7 +10734,7 @@ namespace ts { } } - return getUnionType(signatures.map(getReturnTypeOfSignature), /*subtypeReduction*/ true); + return getUnionType(map(signatures, getReturnTypeOfSignature), /*subtypeReduction*/ true); } /// e.g. "props" for React.d.ts, @@ -10778,7 +10784,7 @@ namespace ts { } if (elemType.flags & TypeFlags.Union) { const types = (elemType).types; - return getUnionType(types.map(type => { + return getUnionType(map(types, type => { return getResolvedJsxType(node, type, elemClassType); }), /*subtypeReduction*/ true); } diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 72d05e1cfd7..bb3aaf23259 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -257,13 +257,33 @@ namespace ts { if (array) { result = []; for (let i = 0; i < array.length; i++) { - const v = array[i]; - result.push(f(v, i)); + result.push(f(array[i], i)); } } return result; } + // Maps from T to T and avoids allocation of all elements map to themselves + export function sameMap(array: T[], f: (x: T, i: number) => T): T[] { + let result: T[]; + if (array) { + for (let i = 0; i < array.length; i++) { + if (result) { + result.push(f(array[i], i)); + } + else { + const item = array[i]; + const mapped = f(item, i); + if (item !== mapped) { + result = array.slice(0, i); + result.push(mapped); + } + } + } + } + return result || array; + } + /** * Flattens an array containing a mix of array or non-array elements. * From 144f4ffc7c836834947ecb6541225a47aa8e1af8 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 6 Oct 2016 13:33:13 -0700 Subject: [PATCH 022/173] Accept new baselines --- tests/baselines/reference/arrayLiterals2ES5.types | 8 ++++---- .../reference/genericTypeParameterEquivalence2.types | 2 +- tests/baselines/reference/globalThisCapture.types | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/baselines/reference/arrayLiterals2ES5.types b/tests/baselines/reference/arrayLiterals2ES5.types index 4c5f895114d..833966a6e48 100644 --- a/tests/baselines/reference/arrayLiterals2ES5.types +++ b/tests/baselines/reference/arrayLiterals2ES5.types @@ -193,10 +193,10 @@ var d5 = [...temp3]; >temp3 : any[] var d6 = [...temp4]; ->d6 : never[] ->[...temp4] : never[] ->...temp4 : never ->temp4 : never[] +>d6 : any[] +>[...temp4] : undefined[] +>...temp4 : undefined +>temp4 : undefined[] var d7 = [...[...temp1]]; >d7 : number[] diff --git a/tests/baselines/reference/genericTypeParameterEquivalence2.types b/tests/baselines/reference/genericTypeParameterEquivalence2.types index 095ce27c752..51253764578 100644 --- a/tests/baselines/reference/genericTypeParameterEquivalence2.types +++ b/tests/baselines/reference/genericTypeParameterEquivalence2.types @@ -105,7 +105,7 @@ function filter(f: (a: A) => boolean, ar: A[]): A[] { } ); return ret; ->ret : never[] +>ret : undefined[] } // length :: [a] -> Num diff --git a/tests/baselines/reference/globalThisCapture.types b/tests/baselines/reference/globalThisCapture.types index 92a20ff930e..d17c899d1ed 100644 --- a/tests/baselines/reference/globalThisCapture.types +++ b/tests/baselines/reference/globalThisCapture.types @@ -13,7 +13,7 @@ var parts = []; // Ensure that the generated code is correct parts[0]; ->parts[0] : never ->parts : never[] +>parts[0] : undefined +>parts : undefined[] >0 : 0 From a9c2b23df52a2abaffae4ba1470ee87e05aae731 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 6 Oct 2016 13:33:28 -0700 Subject: [PATCH 023/173] Add tests --- .../cases/compiler/controlFlowArrayErrors.ts | 59 ++++++++ tests/cases/compiler/controlFlowArrays.ts | 141 ++++++++++++++++++ 2 files changed, 200 insertions(+) create mode 100644 tests/cases/compiler/controlFlowArrayErrors.ts create mode 100644 tests/cases/compiler/controlFlowArrays.ts diff --git a/tests/cases/compiler/controlFlowArrayErrors.ts b/tests/cases/compiler/controlFlowArrayErrors.ts new file mode 100644 index 00000000000..84da65c41dc --- /dev/null +++ b/tests/cases/compiler/controlFlowArrayErrors.ts @@ -0,0 +1,59 @@ +// @noImplicitAny: true + +declare function cond(): boolean; + +function f1() { + let x = []; + let y = x; // Implicit any[] error + x.push(5); + let z = x; +} + +function f2() { + let x; + x = []; + let y = x; // Implicit any[] error + x.push(5); + let z = x; +} + +function f3() { + let x = []; // Implicit any[] error in some locations + x.push(5); + function g() { + x; // Implicit any[] error + } +} + +function f4() { + let x; + x = [5, "hello"]; // Non-evolving array + x.push(true); // Error +} + +function f5() { + let x = [5, "hello"]; // Non-evolving array + x.push(true); // Error +} + +function f6() { + let x; + if (cond()) { + x = []; + x.push(5); + x.push("hello"); + } + else { + x = [true]; // Non-evolving array + } + x; // boolean[] | (string | number)[] + x.push(99); // Error +} + +function f7() { + let x = []; // x has evolving array value + x.push(5); + let y = x; // y has non-evolving array value + x.push("hello"); // Ok + y.push("hello"); // Error +} \ No newline at end of file diff --git a/tests/cases/compiler/controlFlowArrays.ts b/tests/cases/compiler/controlFlowArrays.ts new file mode 100644 index 00000000000..d5eaa9c4320 --- /dev/null +++ b/tests/cases/compiler/controlFlowArrays.ts @@ -0,0 +1,141 @@ +// @strictNullChecks: true +// @noImplicitAny: true + +declare function cond(): boolean; + +function f1() { + let x = []; + x[0] = 5; + x[1] = "hello"; + x[2] = true; + return x; // (string | number | boolean)[] +} + +function f2() { + let x = []; + x.push(5); + x.push("hello"); + x.push(true); + return x; // (string | number | boolean)[] +} + +function f3() { + let x; + x = []; + x.push(5, "hello"); + return x; // (string | number)[] +} + +function f4() { + let x = []; + if (cond()) { + x.push(5); + } + else { + x.push("hello"); + } + return x; // (string | number)[] +} + +function f5() { + let x; + if (cond()) { + x = []; + x.push(5); + } + else { + x = []; + x.push("hello"); + } + return x; // (string | number)[] +} + +function f6() { + let x; + if (cond()) { + x = 5; + } + else { + x = []; + x.push("hello"); + } + return x; // number | string[] +} + +function f7() { + let x = null; + if (cond()) { + x = []; + while (cond()) { + x.push("hello"); + } + } + return x; // string[] | null +} + +function f8() { + let x = []; + x.push(5); + if (cond()) return x; // number[] + x.push("hello"); + if (cond()) return x; // (string | number)[] + x.push(true); + return x; // (string | number | boolean)[] +} + +function f9() { + let x = []; + if (cond()) { + x.push(5); + return x; // number[] + } + else { + x.push("hello"); + return x; // string[] + } +} + +function f10() { + let x = []; + if (cond()) { + x.push(true); + x; // boolean[] + } + else { + x.push(5); + x; // number[] + while (cond()) { + x.push("hello"); + } + x; // (string | number)[] + } + x.push(99); + return x; // (string | number | boolean)[] +} + +function f11() { + let x = []; + return x; // never[] +} + +function f12() { + let x; + x = []; + return x; // never[] +} + +function f13() { + var x = []; + x.push(5); + x.push("hello"); + x.push(true); + return x; // (string | number | boolean)[] +} + +function f14() { + const x = []; + x.push(5); + x.push("hello"); + x.push(true); + return x; // (string | number | boolean)[] +} \ No newline at end of file From c0c2271d31a361528deebe88e91539c2635ccbf9 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 6 Oct 2016 13:35:02 -0700 Subject: [PATCH 024/173] Accept new baselines --- .../controlFlowArrayErrors.errors.txt | 85 ++++ .../reference/controlFlowArrayErrors.js | 110 +++++ .../baselines/reference/controlFlowArrays.js | 267 +++++++++++ .../reference/controlFlowArrays.symbols | 350 ++++++++++++++ .../reference/controlFlowArrays.types | 447 ++++++++++++++++++ 5 files changed, 1259 insertions(+) create mode 100644 tests/baselines/reference/controlFlowArrayErrors.errors.txt create mode 100644 tests/baselines/reference/controlFlowArrayErrors.js create mode 100644 tests/baselines/reference/controlFlowArrays.js create mode 100644 tests/baselines/reference/controlFlowArrays.symbols create mode 100644 tests/baselines/reference/controlFlowArrays.types diff --git a/tests/baselines/reference/controlFlowArrayErrors.errors.txt b/tests/baselines/reference/controlFlowArrayErrors.errors.txt new file mode 100644 index 00000000000..7475c273243 --- /dev/null +++ b/tests/baselines/reference/controlFlowArrayErrors.errors.txt @@ -0,0 +1,85 @@ +tests/cases/compiler/controlFlowArrayErrors.ts(6,9): error TS7005: Variable 'y' implicitly has an 'any[]' type. +tests/cases/compiler/controlFlowArrayErrors.ts(14,9): error TS7005: Variable 'y' implicitly has an 'any[]' type. +tests/cases/compiler/controlFlowArrayErrors.ts(20,9): error TS7034: Variable 'x' implicitly has type 'any[]' in some locations where its type cannot be determined. +tests/cases/compiler/controlFlowArrayErrors.ts(23,9): error TS7005: Variable 'x' implicitly has an 'any[]' type. +tests/cases/compiler/controlFlowArrayErrors.ts(30,12): error TS2345: Argument of type 'true' is not assignable to parameter of type 'string | number'. +tests/cases/compiler/controlFlowArrayErrors.ts(35,12): error TS2345: Argument of type 'true' is not assignable to parameter of type 'string | number'. +tests/cases/compiler/controlFlowArrayErrors.ts(49,5): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((...items: (string | number)[]) => number) | ((...items: boolean[]) => number)' has no compatible call signatures. +tests/cases/compiler/controlFlowArrayErrors.ts(57,12): error TS2345: Argument of type '"hello"' is not assignable to parameter of type 'number'. + + +==== tests/cases/compiler/controlFlowArrayErrors.ts (8 errors) ==== + + declare function cond(): boolean; + + function f1() { + let x = []; + let y = x; // Implicit any[] error + ~ +!!! error TS7005: Variable 'y' implicitly has an 'any[]' type. + x.push(5); + let z = x; + } + + function f2() { + let x; + x = []; + let y = x; // Implicit any[] error + ~ +!!! error TS7005: Variable 'y' implicitly has an 'any[]' type. + x.push(5); + let z = x; + } + + function f3() { + let x = []; // Implicit any[] error in some locations + ~ +!!! error TS7034: Variable 'x' implicitly has type 'any[]' in some locations where its type cannot be determined. + x.push(5); + function g() { + x; // Implicit any[] error + ~ +!!! error TS7005: Variable 'x' implicitly has an 'any[]' type. + } + } + + function f4() { + let x; + x = [5, "hello"]; // Non-evolving array + x.push(true); // Error + ~~~~ +!!! error TS2345: Argument of type 'true' is not assignable to parameter of type 'string | number'. + } + + function f5() { + let x = [5, "hello"]; // Non-evolving array + x.push(true); // Error + ~~~~ +!!! error TS2345: Argument of type 'true' is not assignable to parameter of type 'string | number'. + } + + function f6() { + let x; + if (cond()) { + x = []; + x.push(5); + x.push("hello"); + } + else { + x = [true]; // Non-evolving array + } + x; // boolean[] | (string | number)[] + x.push(99); // Error + ~~~~~~~~~~ +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((...items: (string | number)[]) => number) | ((...items: boolean[]) => number)' has no compatible call signatures. + } + + function f7() { + let x = []; // x has evolving array value + x.push(5); + let y = x; // y has non-evolving array value + x.push("hello"); // Ok + y.push("hello"); // Error + ~~~~~~~ +!!! error TS2345: Argument of type '"hello"' is not assignable to parameter of type 'number'. + } \ No newline at end of file diff --git a/tests/baselines/reference/controlFlowArrayErrors.js b/tests/baselines/reference/controlFlowArrayErrors.js new file mode 100644 index 00000000000..c1589449334 --- /dev/null +++ b/tests/baselines/reference/controlFlowArrayErrors.js @@ -0,0 +1,110 @@ +//// [controlFlowArrayErrors.ts] + +declare function cond(): boolean; + +function f1() { + let x = []; + let y = x; // Implicit any[] error + x.push(5); + let z = x; +} + +function f2() { + let x; + x = []; + let y = x; // Implicit any[] error + x.push(5); + let z = x; +} + +function f3() { + let x = []; // Implicit any[] error in some locations + x.push(5); + function g() { + x; // Implicit any[] error + } +} + +function f4() { + let x; + x = [5, "hello"]; // Non-evolving array + x.push(true); // Error +} + +function f5() { + let x = [5, "hello"]; // Non-evolving array + x.push(true); // Error +} + +function f6() { + let x; + if (cond()) { + x = []; + x.push(5); + x.push("hello"); + } + else { + x = [true]; // Non-evolving array + } + x; // boolean[] | (string | number)[] + x.push(99); // Error +} + +function f7() { + let x = []; // x has evolving array value + x.push(5); + let y = x; // y has non-evolving array value + x.push("hello"); // Ok + y.push("hello"); // Error +} + +//// [controlFlowArrayErrors.js] +function f1() { + var x = []; + var y = x; // Implicit any[] error + x.push(5); + var z = x; +} +function f2() { + var x; + x = []; + var y = x; // Implicit any[] error + x.push(5); + var z = x; +} +function f3() { + var x = []; // Implicit any[] error in some locations + x.push(5); + function g() { + x; // Implicit any[] error + } +} +function f4() { + var x; + x = [5, "hello"]; // Non-evolving array + x.push(true); // Error +} +function f5() { + var x = [5, "hello"]; // Non-evolving array + x.push(true); // Error +} +function f6() { + var x; + if (cond()) { + x = []; + x.push(5); + x.push("hello"); + } + else { + x = [true]; // Non-evolving array + } + x; // boolean[] | (string | number)[] + x.push(99); // Error +} +function f7() { + var x = []; // x has evolving array value + x.push(5); + var y = x; // y has non-evolving array value + x.push("hello"); // Ok + y.push("hello"); // Error +} diff --git a/tests/baselines/reference/controlFlowArrays.js b/tests/baselines/reference/controlFlowArrays.js new file mode 100644 index 00000000000..26885aecd8b --- /dev/null +++ b/tests/baselines/reference/controlFlowArrays.js @@ -0,0 +1,267 @@ +//// [controlFlowArrays.ts] + +declare function cond(): boolean; + +function f1() { + let x = []; + x[0] = 5; + x[1] = "hello"; + x[2] = true; + return x; // (string | number | boolean)[] +} + +function f2() { + let x = []; + x.push(5); + x.push("hello"); + x.push(true); + return x; // (string | number | boolean)[] +} + +function f3() { + let x; + x = []; + x.push(5, "hello"); + return x; // (string | number)[] +} + +function f4() { + let x = []; + if (cond()) { + x.push(5); + } + else { + x.push("hello"); + } + return x; // (string | number)[] +} + +function f5() { + let x; + if (cond()) { + x = []; + x.push(5); + } + else { + x = []; + x.push("hello"); + } + return x; // (string | number)[] +} + +function f6() { + let x; + if (cond()) { + x = 5; + } + else { + x = []; + x.push("hello"); + } + return x; // number | string[] +} + +function f7() { + let x = null; + if (cond()) { + x = []; + while (cond()) { + x.push("hello"); + } + } + return x; // string[] | null +} + +function f8() { + let x = []; + x.push(5); + if (cond()) return x; // number[] + x.push("hello"); + if (cond()) return x; // (string | number)[] + x.push(true); + return x; // (string | number | boolean)[] +} + +function f9() { + let x = []; + if (cond()) { + x.push(5); + return x; // number[] + } + else { + x.push("hello"); + return x; // string[] + } +} + +function f10() { + let x = []; + if (cond()) { + x.push(true); + x; // boolean[] + } + else { + x.push(5); + x; // number[] + while (cond()) { + x.push("hello"); + } + x; // (string | number)[] + } + x.push(99); + return x; // (string | number | boolean)[] +} + +function f11() { + let x = []; + return x; // never[] +} + +function f12() { + let x; + x = []; + return x; // never[] +} + +function f13() { + var x = []; + x.push(5); + x.push("hello"); + x.push(true); + return x; // (string | number | boolean)[] +} + +function f14() { + const x = []; + x.push(5); + x.push("hello"); + x.push(true); + return x; // (string | number | boolean)[] +} + +//// [controlFlowArrays.js] +function f1() { + var x = []; + x[0] = 5; + x[1] = "hello"; + x[2] = true; + return x; // (string | number | boolean)[] +} +function f2() { + var x = []; + x.push(5); + x.push("hello"); + x.push(true); + return x; // (string | number | boolean)[] +} +function f3() { + var x; + x = []; + x.push(5, "hello"); + return x; // (string | number)[] +} +function f4() { + var x = []; + if (cond()) { + x.push(5); + } + else { + x.push("hello"); + } + return x; // (string | number)[] +} +function f5() { + var x; + if (cond()) { + x = []; + x.push(5); + } + else { + x = []; + x.push("hello"); + } + return x; // (string | number)[] +} +function f6() { + var x; + if (cond()) { + x = 5; + } + else { + x = []; + x.push("hello"); + } + return x; // number | string[] +} +function f7() { + var x = null; + if (cond()) { + x = []; + while (cond()) { + x.push("hello"); + } + } + return x; // string[] | null +} +function f8() { + var x = []; + x.push(5); + if (cond()) + return x; // number[] + x.push("hello"); + if (cond()) + return x; // (string | number)[] + x.push(true); + return x; // (string | number | boolean)[] +} +function f9() { + var x = []; + if (cond()) { + x.push(5); + return x; // number[] + } + else { + x.push("hello"); + return x; // string[] + } +} +function f10() { + var x = []; + if (cond()) { + x.push(true); + x; // boolean[] + } + else { + x.push(5); + x; // number[] + while (cond()) { + x.push("hello"); + } + x; // (string | number)[] + } + x.push(99); + return x; // (string | number | boolean)[] +} +function f11() { + var x = []; + return x; // never[] +} +function f12() { + var x; + x = []; + return x; // never[] +} +function f13() { + var x = []; + x.push(5); + x.push("hello"); + x.push(true); + return x; // (string | number | boolean)[] +} +function f14() { + var x = []; + x.push(5); + x.push("hello"); + x.push(true); + return x; // (string | number | boolean)[] +} diff --git a/tests/baselines/reference/controlFlowArrays.symbols b/tests/baselines/reference/controlFlowArrays.symbols new file mode 100644 index 00000000000..5b5ef7f8506 --- /dev/null +++ b/tests/baselines/reference/controlFlowArrays.symbols @@ -0,0 +1,350 @@ +=== tests/cases/compiler/controlFlowArrays.ts === + +declare function cond(): boolean; +>cond : Symbol(cond, Decl(controlFlowArrays.ts, 0, 0)) + +function f1() { +>f1 : Symbol(f1, Decl(controlFlowArrays.ts, 1, 33)) + + let x = []; +>x : Symbol(x, Decl(controlFlowArrays.ts, 4, 7)) + + x[0] = 5; +>x : Symbol(x, Decl(controlFlowArrays.ts, 4, 7)) + + x[1] = "hello"; +>x : Symbol(x, Decl(controlFlowArrays.ts, 4, 7)) + + x[2] = true; +>x : Symbol(x, Decl(controlFlowArrays.ts, 4, 7)) + + return x; // (string | number | boolean)[] +>x : Symbol(x, Decl(controlFlowArrays.ts, 4, 7)) +} + +function f2() { +>f2 : Symbol(f2, Decl(controlFlowArrays.ts, 9, 1)) + + let x = []; +>x : Symbol(x, Decl(controlFlowArrays.ts, 12, 7)) + + x.push(5); +>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 12, 7)) +>push : Symbol(Array.push, Decl(lib.d.ts, --, --)) + + x.push("hello"); +>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 12, 7)) +>push : Symbol(Array.push, Decl(lib.d.ts, --, --)) + + x.push(true); +>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 12, 7)) +>push : Symbol(Array.push, Decl(lib.d.ts, --, --)) + + return x; // (string | number | boolean)[] +>x : Symbol(x, Decl(controlFlowArrays.ts, 12, 7)) +} + +function f3() { +>f3 : Symbol(f3, Decl(controlFlowArrays.ts, 17, 1)) + + let x; +>x : Symbol(x, Decl(controlFlowArrays.ts, 20, 7)) + + x = []; +>x : Symbol(x, Decl(controlFlowArrays.ts, 20, 7)) + + x.push(5, "hello"); +>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 20, 7)) +>push : Symbol(Array.push, Decl(lib.d.ts, --, --)) + + return x; // (string | number)[] +>x : Symbol(x, Decl(controlFlowArrays.ts, 20, 7)) +} + +function f4() { +>f4 : Symbol(f4, Decl(controlFlowArrays.ts, 24, 1)) + + let x = []; +>x : Symbol(x, Decl(controlFlowArrays.ts, 27, 7)) + + if (cond()) { +>cond : Symbol(cond, Decl(controlFlowArrays.ts, 0, 0)) + + x.push(5); +>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 27, 7)) +>push : Symbol(Array.push, Decl(lib.d.ts, --, --)) + } + else { + x.push("hello"); +>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 27, 7)) +>push : Symbol(Array.push, Decl(lib.d.ts, --, --)) + } + return x; // (string | number)[] +>x : Symbol(x, Decl(controlFlowArrays.ts, 27, 7)) +} + +function f5() { +>f5 : Symbol(f5, Decl(controlFlowArrays.ts, 35, 1)) + + let x; +>x : Symbol(x, Decl(controlFlowArrays.ts, 38, 7)) + + if (cond()) { +>cond : Symbol(cond, Decl(controlFlowArrays.ts, 0, 0)) + + x = []; +>x : Symbol(x, Decl(controlFlowArrays.ts, 38, 7)) + + x.push(5); +>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 38, 7)) +>push : Symbol(Array.push, Decl(lib.d.ts, --, --)) + } + else { + x = []; +>x : Symbol(x, Decl(controlFlowArrays.ts, 38, 7)) + + x.push("hello"); +>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 38, 7)) +>push : Symbol(Array.push, Decl(lib.d.ts, --, --)) + } + return x; // (string | number)[] +>x : Symbol(x, Decl(controlFlowArrays.ts, 38, 7)) +} + +function f6() { +>f6 : Symbol(f6, Decl(controlFlowArrays.ts, 48, 1)) + + let x; +>x : Symbol(x, Decl(controlFlowArrays.ts, 51, 7)) + + if (cond()) { +>cond : Symbol(cond, Decl(controlFlowArrays.ts, 0, 0)) + + x = 5; +>x : Symbol(x, Decl(controlFlowArrays.ts, 51, 7)) + } + else { + x = []; +>x : Symbol(x, Decl(controlFlowArrays.ts, 51, 7)) + + x.push("hello"); +>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 51, 7)) +>push : Symbol(Array.push, Decl(lib.d.ts, --, --)) + } + return x; // number | string[] +>x : Symbol(x, Decl(controlFlowArrays.ts, 51, 7)) +} + +function f7() { +>f7 : Symbol(f7, Decl(controlFlowArrays.ts, 60, 1)) + + let x = null; +>x : Symbol(x, Decl(controlFlowArrays.ts, 63, 7)) + + if (cond()) { +>cond : Symbol(cond, Decl(controlFlowArrays.ts, 0, 0)) + + x = []; +>x : Symbol(x, Decl(controlFlowArrays.ts, 63, 7)) + + while (cond()) { +>cond : Symbol(cond, Decl(controlFlowArrays.ts, 0, 0)) + + x.push("hello"); +>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 63, 7)) +>push : Symbol(Array.push, Decl(lib.d.ts, --, --)) + } + } + return x; // string[] | null +>x : Symbol(x, Decl(controlFlowArrays.ts, 63, 7)) +} + +function f8() { +>f8 : Symbol(f8, Decl(controlFlowArrays.ts, 71, 1)) + + let x = []; +>x : Symbol(x, Decl(controlFlowArrays.ts, 74, 7)) + + x.push(5); +>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 74, 7)) +>push : Symbol(Array.push, Decl(lib.d.ts, --, --)) + + if (cond()) return x; // number[] +>cond : Symbol(cond, Decl(controlFlowArrays.ts, 0, 0)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 74, 7)) + + x.push("hello"); +>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 74, 7)) +>push : Symbol(Array.push, Decl(lib.d.ts, --, --)) + + if (cond()) return x; // (string | number)[] +>cond : Symbol(cond, Decl(controlFlowArrays.ts, 0, 0)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 74, 7)) + + x.push(true); +>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 74, 7)) +>push : Symbol(Array.push, Decl(lib.d.ts, --, --)) + + return x; // (string | number | boolean)[] +>x : Symbol(x, Decl(controlFlowArrays.ts, 74, 7)) +} + +function f9() { +>f9 : Symbol(f9, Decl(controlFlowArrays.ts, 81, 1)) + + let x = []; +>x : Symbol(x, Decl(controlFlowArrays.ts, 84, 7)) + + if (cond()) { +>cond : Symbol(cond, Decl(controlFlowArrays.ts, 0, 0)) + + x.push(5); +>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 84, 7)) +>push : Symbol(Array.push, Decl(lib.d.ts, --, --)) + + return x; // number[] +>x : Symbol(x, Decl(controlFlowArrays.ts, 84, 7)) + } + else { + x.push("hello"); +>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 84, 7)) +>push : Symbol(Array.push, Decl(lib.d.ts, --, --)) + + return x; // string[] +>x : Symbol(x, Decl(controlFlowArrays.ts, 84, 7)) + } +} + +function f10() { +>f10 : Symbol(f10, Decl(controlFlowArrays.ts, 93, 1)) + + let x = []; +>x : Symbol(x, Decl(controlFlowArrays.ts, 96, 7)) + + if (cond()) { +>cond : Symbol(cond, Decl(controlFlowArrays.ts, 0, 0)) + + x.push(true); +>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 96, 7)) +>push : Symbol(Array.push, Decl(lib.d.ts, --, --)) + + x; // boolean[] +>x : Symbol(x, Decl(controlFlowArrays.ts, 96, 7)) + } + else { + x.push(5); +>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 96, 7)) +>push : Symbol(Array.push, Decl(lib.d.ts, --, --)) + + x; // number[] +>x : Symbol(x, Decl(controlFlowArrays.ts, 96, 7)) + + while (cond()) { +>cond : Symbol(cond, Decl(controlFlowArrays.ts, 0, 0)) + + x.push("hello"); +>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 96, 7)) +>push : Symbol(Array.push, Decl(lib.d.ts, --, --)) + } + x; // (string | number)[] +>x : Symbol(x, Decl(controlFlowArrays.ts, 96, 7)) + } + x.push(99); +>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 96, 7)) +>push : Symbol(Array.push, Decl(lib.d.ts, --, --)) + + return x; // (string | number | boolean)[] +>x : Symbol(x, Decl(controlFlowArrays.ts, 96, 7)) +} + +function f11() { +>f11 : Symbol(f11, Decl(controlFlowArrays.ts, 111, 1)) + + let x = []; +>x : Symbol(x, Decl(controlFlowArrays.ts, 114, 7)) + + return x; // never[] +>x : Symbol(x, Decl(controlFlowArrays.ts, 114, 7)) +} + +function f12() { +>f12 : Symbol(f12, Decl(controlFlowArrays.ts, 116, 1)) + + let x; +>x : Symbol(x, Decl(controlFlowArrays.ts, 119, 7)) + + x = []; +>x : Symbol(x, Decl(controlFlowArrays.ts, 119, 7)) + + return x; // never[] +>x : Symbol(x, Decl(controlFlowArrays.ts, 119, 7)) +} + +function f13() { +>f13 : Symbol(f13, Decl(controlFlowArrays.ts, 122, 1)) + + var x = []; +>x : Symbol(x, Decl(controlFlowArrays.ts, 125, 7)) + + x.push(5); +>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 125, 7)) +>push : Symbol(Array.push, Decl(lib.d.ts, --, --)) + + x.push("hello"); +>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 125, 7)) +>push : Symbol(Array.push, Decl(lib.d.ts, --, --)) + + x.push(true); +>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 125, 7)) +>push : Symbol(Array.push, Decl(lib.d.ts, --, --)) + + return x; // (string | number | boolean)[] +>x : Symbol(x, Decl(controlFlowArrays.ts, 125, 7)) +} + +function f14() { +>f14 : Symbol(f14, Decl(controlFlowArrays.ts, 130, 1)) + + const x = []; +>x : Symbol(x, Decl(controlFlowArrays.ts, 133, 9)) + + x.push(5); +>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 133, 9)) +>push : Symbol(Array.push, Decl(lib.d.ts, --, --)) + + x.push("hello"); +>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 133, 9)) +>push : Symbol(Array.push, Decl(lib.d.ts, --, --)) + + x.push(true); +>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 133, 9)) +>push : Symbol(Array.push, Decl(lib.d.ts, --, --)) + + return x; // (string | number | boolean)[] +>x : Symbol(x, Decl(controlFlowArrays.ts, 133, 9)) +} diff --git a/tests/baselines/reference/controlFlowArrays.types b/tests/baselines/reference/controlFlowArrays.types new file mode 100644 index 00000000000..7b36e4067fa --- /dev/null +++ b/tests/baselines/reference/controlFlowArrays.types @@ -0,0 +1,447 @@ +=== tests/cases/compiler/controlFlowArrays.ts === + +declare function cond(): boolean; +>cond : () => boolean + +function f1() { +>f1 : () => (string | number | boolean)[] + + let x = []; +>x : any[] +>[] : never[] + + x[0] = 5; +>x[0] = 5 : 5 +>x[0] : any +>x : any[] +>0 : 0 +>5 : 5 + + x[1] = "hello"; +>x[1] = "hello" : "hello" +>x[1] : any +>x : any[] +>1 : 1 +>"hello" : "hello" + + x[2] = true; +>x[2] = true : true +>x[2] : any +>x : any[] +>2 : 2 +>true : true + + return x; // (string | number | boolean)[] +>x : (string | number | boolean)[] +} + +function f2() { +>f2 : () => (string | number | boolean)[] + + let x = []; +>x : any[] +>[] : never[] + + x.push(5); +>x.push(5) : number +>x.push : (...items: any[]) => number +>x : any[] +>push : (...items: any[]) => number +>5 : 5 + + x.push("hello"); +>x.push("hello") : number +>x.push : (...items: any[]) => number +>x : any[] +>push : (...items: any[]) => number +>"hello" : "hello" + + x.push(true); +>x.push(true) : number +>x.push : (...items: any[]) => number +>x : any[] +>push : (...items: any[]) => number +>true : true + + return x; // (string | number | boolean)[] +>x : (string | number | boolean)[] +} + +function f3() { +>f3 : () => (string | number)[] + + let x; +>x : any + + x = []; +>x = [] : never[] +>x : any +>[] : never[] + + x.push(5, "hello"); +>x.push(5, "hello") : number +>x.push : (...items: any[]) => number +>x : any[] +>push : (...items: any[]) => number +>5 : 5 +>"hello" : "hello" + + return x; // (string | number)[] +>x : (string | number)[] +} + +function f4() { +>f4 : () => (string | number)[] + + let x = []; +>x : any[] +>[] : never[] + + if (cond()) { +>cond() : boolean +>cond : () => boolean + + x.push(5); +>x.push(5) : number +>x.push : (...items: any[]) => number +>x : any[] +>push : (...items: any[]) => number +>5 : 5 + } + else { + x.push("hello"); +>x.push("hello") : number +>x.push : (...items: any[]) => number +>x : any[] +>push : (...items: any[]) => number +>"hello" : "hello" + } + return x; // (string | number)[] +>x : (string | number)[] +} + +function f5() { +>f5 : () => (string | number)[] + + let x; +>x : any + + if (cond()) { +>cond() : boolean +>cond : () => boolean + + x = []; +>x = [] : never[] +>x : any +>[] : never[] + + x.push(5); +>x.push(5) : number +>x.push : (...items: any[]) => number +>x : any[] +>push : (...items: any[]) => number +>5 : 5 + } + else { + x = []; +>x = [] : never[] +>x : any +>[] : never[] + + x.push("hello"); +>x.push("hello") : number +>x.push : (...items: any[]) => number +>x : any[] +>push : (...items: any[]) => number +>"hello" : "hello" + } + return x; // (string | number)[] +>x : (string | number)[] +} + +function f6() { +>f6 : () => number | string[] + + let x; +>x : any + + if (cond()) { +>cond() : boolean +>cond : () => boolean + + x = 5; +>x = 5 : 5 +>x : any +>5 : 5 + } + else { + x = []; +>x = [] : never[] +>x : any +>[] : never[] + + x.push("hello"); +>x.push("hello") : number +>x.push : (...items: any[]) => number +>x : any[] +>push : (...items: any[]) => number +>"hello" : "hello" + } + return x; // number | string[] +>x : number | string[] +} + +function f7() { +>f7 : () => string[] | null + + let x = null; +>x : any +>null : null + + if (cond()) { +>cond() : boolean +>cond : () => boolean + + x = []; +>x = [] : never[] +>x : any +>[] : never[] + + while (cond()) { +>cond() : boolean +>cond : () => boolean + + x.push("hello"); +>x.push("hello") : number +>x.push : (...items: any[]) => number +>x : any[] +>push : (...items: any[]) => number +>"hello" : "hello" + } + } + return x; // string[] | null +>x : string[] | null +} + +function f8() { +>f8 : () => (string | number | boolean)[] + + let x = []; +>x : any[] +>[] : never[] + + x.push(5); +>x.push(5) : number +>x.push : (...items: any[]) => number +>x : any[] +>push : (...items: any[]) => number +>5 : 5 + + if (cond()) return x; // number[] +>cond() : boolean +>cond : () => boolean +>x : number[] + + x.push("hello"); +>x.push("hello") : number +>x.push : (...items: any[]) => number +>x : any[] +>push : (...items: any[]) => number +>"hello" : "hello" + + if (cond()) return x; // (string | number)[] +>cond() : boolean +>cond : () => boolean +>x : (string | number)[] + + x.push(true); +>x.push(true) : number +>x.push : (...items: any[]) => number +>x : any[] +>push : (...items: any[]) => number +>true : true + + return x; // (string | number | boolean)[] +>x : (string | number | boolean)[] +} + +function f9() { +>f9 : () => string[] | number[] + + let x = []; +>x : any[] +>[] : never[] + + if (cond()) { +>cond() : boolean +>cond : () => boolean + + x.push(5); +>x.push(5) : number +>x.push : (...items: any[]) => number +>x : any[] +>push : (...items: any[]) => number +>5 : 5 + + return x; // number[] +>x : number[] + } + else { + x.push("hello"); +>x.push("hello") : number +>x.push : (...items: any[]) => number +>x : any[] +>push : (...items: any[]) => number +>"hello" : "hello" + + return x; // string[] +>x : string[] + } +} + +function f10() { +>f10 : () => (string | number | boolean)[] + + let x = []; +>x : any[] +>[] : never[] + + if (cond()) { +>cond() : boolean +>cond : () => boolean + + x.push(true); +>x.push(true) : number +>x.push : (...items: any[]) => number +>x : any[] +>push : (...items: any[]) => number +>true : true + + x; // boolean[] +>x : boolean[] + } + else { + x.push(5); +>x.push(5) : number +>x.push : (...items: any[]) => number +>x : any[] +>push : (...items: any[]) => number +>5 : 5 + + x; // number[] +>x : number[] + + while (cond()) { +>cond() : boolean +>cond : () => boolean + + x.push("hello"); +>x.push("hello") : number +>x.push : (...items: any[]) => number +>x : any[] +>push : (...items: any[]) => number +>"hello" : "hello" + } + x; // (string | number)[] +>x : (string | number)[] + } + x.push(99); +>x.push(99) : number +>x.push : (...items: any[]) => number +>x : any[] +>push : (...items: any[]) => number +>99 : 99 + + return x; // (string | number | boolean)[] +>x : (string | number | boolean)[] +} + +function f11() { +>f11 : () => never[] + + let x = []; +>x : any[] +>[] : never[] + + return x; // never[] +>x : never[] +} + +function f12() { +>f12 : () => never[] + + let x; +>x : any + + x = []; +>x = [] : never[] +>x : any +>[] : never[] + + return x; // never[] +>x : never[] +} + +function f13() { +>f13 : () => (string | number | boolean)[] + + var x = []; +>x : any[] +>[] : never[] + + x.push(5); +>x.push(5) : number +>x.push : (...items: any[]) => number +>x : any[] +>push : (...items: any[]) => number +>5 : 5 + + x.push("hello"); +>x.push("hello") : number +>x.push : (...items: any[]) => number +>x : any[] +>push : (...items: any[]) => number +>"hello" : "hello" + + x.push(true); +>x.push(true) : number +>x.push : (...items: any[]) => number +>x : any[] +>push : (...items: any[]) => number +>true : true + + return x; // (string | number | boolean)[] +>x : (string | number | boolean)[] +} + +function f14() { +>f14 : () => (string | number | boolean)[] + + const x = []; +>x : any[] +>[] : never[] + + x.push(5); +>x.push(5) : number +>x.push : (...items: any[]) => number +>x : any[] +>push : (...items: any[]) => number +>5 : 5 + + x.push("hello"); +>x.push("hello") : number +>x.push : (...items: any[]) => number +>x : any[] +>push : (...items: any[]) => number +>"hello" : "hello" + + x.push(true); +>x.push(true) : number +>x.push : (...items: any[]) => number +>x : any[] +>push : (...items: any[]) => number +>true : true + + return x; // (string | number | boolean)[] +>x : (string | number | boolean)[] +} From 1e9b6536cfce4d451e8c721d35661f18e28809c5 Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Thu, 6 Oct 2016 13:59:54 -0700 Subject: [PATCH 025/173] Fix linting issues --- src/harness/fourslash.ts | 2 +- src/server/protocol.d.ts | 4 ++-- src/server/session.ts | 3 ++- src/services/types.ts | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index cadda289daa..f54804c0eb5 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -2353,7 +2353,7 @@ namespace FourSlash { } } - public verifyCodeFixAvailable(negative: boolean, errorCode?:number ) { + public verifyCodeFixAvailable(negative: boolean, errorCode?: number) { const fixes = this.getCodeFixes(errorCode); if (negative && fixes && fixes.length > 0) { diff --git a/src/server/protocol.d.ts b/src/server/protocol.d.ts index 02e488650cd..c3f5bb97fc5 100644 --- a/src/server/protocol.d.ts +++ b/src/server/protocol.d.ts @@ -247,7 +247,7 @@ declare namespace ts.server.protocol { /** * Errorcodes we want to get the fixes for. */ - errorCodes?: number[] + errorCodes?: number[]; } /** @@ -1586,7 +1586,7 @@ declare namespace ts.server.protocol { /** * Changes to apply to each file as part of the code action. */ - changes: FileTextChanges[] + changes: FileTextChanges[]; } export interface FileTextChanges { diff --git a/src/server/session.ts b/src/server/session.ts index ff4384aafbd..7f62e688907 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -1214,7 +1214,8 @@ namespace ts.server { } if (simplifiedResult) { return codeActions.map(mapCodeAction); - } else { + } + else { return codeActions; } diff --git a/src/services/types.ts b/src/services/types.ts index 59abe2f7998..318166604f5 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -297,7 +297,7 @@ namespace ts { fileName: string; textChanges: TextChange[]; } - + export interface CodeAction { /** Description of the code action to display in the UI of the editor */ description: string; From 12906a74dec4337b55a8be37dc8b29cdd84fea2a Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 6 Oct 2016 16:55:08 -0700 Subject: [PATCH 026/173] Fix some minor issues --- src/compiler/checker.ts | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f95ff1ccfec..0a606afe69f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8510,12 +8510,12 @@ namespace ts { } function isEvolvingArrayType(type: Type) { - return type.flags & TypeFlags.Anonymous && !!(type).elementType; + return !!(type.flags & TypeFlags.Anonymous && (type).elementType); } function createFinalArrayType(elementType: Type) { return createArrayType(elementType !== neverType ? - getUnionType([elementType], /*subtypeReduction*/ true) : + elementType.flags & TypeFlags.Union ? getUnionType((elementType).types, /*subtypeReduction*/ true) : elementType : strictNullChecks ? neverType : undefinedWideningType); } @@ -8528,16 +8528,29 @@ namespace ts { return isEvolvingArrayType(type) ? getFinalArrayType(type) : type; } - function getElementTypeOfEvolvingArrayType(evolvingArrayType: AnonymousType) { - return evolvingArrayType.elementType; + function getElementTypeOfEvolvingArrayType(type: Type) { + return isEvolvingArrayType(type) ? (type).elementType : neverType; + } + + function isEvolvingArrayTypeList(types: Type[]) { + let hasEvolvingArrayType = false; + for (const t of types) { + if (!(t.flags & TypeFlags.Never)) { + if (!isEvolvingArrayType(t)) { + return false; + } + hasEvolvingArrayType = true; + } + } + return hasEvolvingArrayType; } // At flow control branch or loop junctions, if the type along every antecedent code path // is an evolving array type, we construct a combined evolving array type. Otherwise we // finalize all evolving array types. function getUnionOrEvolvingArrayType(types: Type[], subtypeReduction: boolean) { - return types.length && every(types, isEvolvingArrayType) ? - getEvolvingArrayType(getUnionType(map(types, getElementTypeOfEvolvingArrayType))) : + return isEvolvingArrayTypeList(types) ? + getEvolvingArrayType(getUnionType(map(types, getElementTypeOfEvolvingArrayType))) : getUnionType(sameMap(types, finalizeEvolvingArrayType), subtypeReduction); } @@ -9211,6 +9224,10 @@ namespace ts { } } + function isConstVariable(symbol: Symbol) { + return symbol.flags & SymbolFlags.Variable && (getDeclarationNodeFlagsFromSymbol(symbol) & NodeFlags.Const) !== 0 && getTypeOfSymbol(symbol) !== autoArrayType; + } + function checkIdentifier(node: Identifier): Type { const symbol = getResolvedSymbol(node); @@ -9303,7 +9320,7 @@ namespace ts { // analysis to include the immediately enclosing function. while (flowContainer !== declarationContainer && (flowContainer.kind === SyntaxKind.FunctionExpression || flowContainer.kind === SyntaxKind.ArrowFunction) && - (isReadonlySymbol(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { + (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } // We only look for uninitialized variables in strict null checking mode, and only when we can analyze From 2f5af2e04b995873b89fb3cc8744fbdfa36a1a8f Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 6 Oct 2016 17:02:33 -0700 Subject: [PATCH 027/173] Add additional test --- .../reference/controlFlowArrayErrors.errors.txt | 16 +++++++++++++++- .../reference/controlFlowArrayErrors.js | 15 +++++++++++++++ tests/cases/compiler/controlFlowArrayErrors.ts | 8 ++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/tests/baselines/reference/controlFlowArrayErrors.errors.txt b/tests/baselines/reference/controlFlowArrayErrors.errors.txt index 7475c273243..bc13de261e2 100644 --- a/tests/baselines/reference/controlFlowArrayErrors.errors.txt +++ b/tests/baselines/reference/controlFlowArrayErrors.errors.txt @@ -6,9 +6,11 @@ tests/cases/compiler/controlFlowArrayErrors.ts(30,12): error TS2345: Argument of tests/cases/compiler/controlFlowArrayErrors.ts(35,12): error TS2345: Argument of type 'true' is not assignable to parameter of type 'string | number'. tests/cases/compiler/controlFlowArrayErrors.ts(49,5): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((...items: (string | number)[]) => number) | ((...items: boolean[]) => number)' has no compatible call signatures. tests/cases/compiler/controlFlowArrayErrors.ts(57,12): error TS2345: Argument of type '"hello"' is not assignable to parameter of type 'number'. +tests/cases/compiler/controlFlowArrayErrors.ts(61,11): error TS7034: Variable 'x' implicitly has type 'any[]' in some locations where its type cannot be determined. +tests/cases/compiler/controlFlowArrayErrors.ts(64,9): error TS7005: Variable 'x' implicitly has an 'any[]' type. -==== tests/cases/compiler/controlFlowArrayErrors.ts (8 errors) ==== +==== tests/cases/compiler/controlFlowArrayErrors.ts (10 errors) ==== declare function cond(): boolean; @@ -82,4 +84,16 @@ tests/cases/compiler/controlFlowArrayErrors.ts(57,12): error TS2345: Argument of y.push("hello"); // Error ~~~~~~~ !!! error TS2345: Argument of type '"hello"' is not assignable to parameter of type 'number'. + } + + function f8() { + const x = []; // Implicit any[] error in some locations + ~ +!!! error TS7034: Variable 'x' implicitly has type 'any[]' in some locations where its type cannot be determined. + x.push(5); + function g() { + x; // Implicit any[] error + ~ +!!! error TS7005: Variable 'x' implicitly has an 'any[]' type. + } } \ No newline at end of file diff --git a/tests/baselines/reference/controlFlowArrayErrors.js b/tests/baselines/reference/controlFlowArrayErrors.js index c1589449334..538addc31c0 100644 --- a/tests/baselines/reference/controlFlowArrayErrors.js +++ b/tests/baselines/reference/controlFlowArrayErrors.js @@ -56,6 +56,14 @@ function f7() { let y = x; // y has non-evolving array value x.push("hello"); // Ok y.push("hello"); // Error +} + +function f8() { + const x = []; // Implicit any[] error in some locations + x.push(5); + function g() { + x; // Implicit any[] error + } } //// [controlFlowArrayErrors.js] @@ -108,3 +116,10 @@ function f7() { x.push("hello"); // Ok y.push("hello"); // Error } +function f8() { + var x = []; // Implicit any[] error in some locations + x.push(5); + function g() { + x; // Implicit any[] error + } +} diff --git a/tests/cases/compiler/controlFlowArrayErrors.ts b/tests/cases/compiler/controlFlowArrayErrors.ts index 84da65c41dc..aab3a974cd8 100644 --- a/tests/cases/compiler/controlFlowArrayErrors.ts +++ b/tests/cases/compiler/controlFlowArrayErrors.ts @@ -56,4 +56,12 @@ function f7() { let y = x; // y has non-evolving array value x.push("hello"); // Ok y.push("hello"); // Error +} + +function f8() { + const x = []; // Implicit any[] error in some locations + x.push(5); + function g() { + x; // Implicit any[] error + } } \ No newline at end of file From c29e9b7e4b984370a35a949b97280dafb56e1141 Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Fri, 7 Oct 2016 10:31:12 -0700 Subject: [PATCH 028/173] PR feedback --- src/harness/harnessLanguageService.ts | 2 +- src/server/protocol.d.ts | 35 ++++----------- src/server/session.ts | 52 ++++++++++++----------- src/services/codefixes/codeFixProvider.ts | 2 +- src/services/services.ts | 2 + src/services/shims.ts | 19 --------- 6 files changed, 40 insertions(+), 72 deletions(-) diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 6af168796f9..99cee7dbd41 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -487,7 +487,7 @@ namespace Harness.LanguageService { return unwrapJSONCallResult(this.shim.isValidBraceCompletionAtPosition(fileName, position, openingBrace)); } getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[]): ts.CodeAction[] { - return unwrapJSONCallResult(this.shim.getCodeFixesAtPosition(fileName, start, end, JSON.stringify(errorCodes))); + throw new Error("Not supported on the shim."); } getEmitOutput(fileName: string): ts.EmitOutput { return unwrapJSONCallResult(this.shim.getEmitOutput(fileName)); diff --git a/src/server/protocol.d.ts b/src/server/protocol.d.ts index c3f5bb97fc5..bb95144af79 100644 --- a/src/server/protocol.d.ts +++ b/src/server/protocol.d.ts @@ -204,7 +204,7 @@ declare namespace ts.server.protocol { } /** - * Request for the available codefixed at a specific position. + * Request for the available codefixes at a specific position. */ export interface CodeFixRequest extends Request { arguments: CodeFixRequestArgs; @@ -924,7 +924,12 @@ declare namespace ts.server.protocol { textChanges: CodeEdit[]; } - export interface CodeActionResponse extends Response { + export interface CodeFixResponse extends Response { + /** The code actions that are available */ + codeActions: CodeAction[]; + } + + export interface CodeAction { /** Description of the code action to display in the UI of the editor */ description: string; /** Text changes to apply to each file as part of the code action */ @@ -1586,30 +1591,6 @@ declare namespace ts.server.protocol { /** * Changes to apply to each file as part of the code action. */ - changes: FileTextChanges[]; - } - - export interface FileTextChanges { - /** - * File to apply the change to. - */ - fileName: string; - - /** - * Changes to apply to the file. - */ - textChanges: TextChange[]; - } - - export class TextChange { - /** - * The span for the text change. - */ - span: TextSpan; - - /** - * New text for the span, can be an empty string if we want to delete text. - */ - newText: string; + changes: FileCodeEdits[]; } } diff --git a/src/server/session.ts b/src/server/session.ts index 7f62e688907..ccbf6caea1f 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -136,6 +136,7 @@ namespace ts.server { export const CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects"; export const GetCodeFixes = "getCodeFixes"; export const GetCodeFixesFull = "getCodeFixes-full"; + export const GetSupportedCodeFixes = "getSupportedCodeFixes"; } export function formatMessage(msg: T, logger: server.Logger, byteLength: (s: string, encoding: string) => number, newLine: string): string { @@ -844,13 +845,7 @@ namespace ts.server { return undefined; } - return edits.map((edit) => { - return { - start: scriptInfo.positionToLineOffset(edit.span.start), - end: scriptInfo.positionToLineOffset(ts.textSpanEnd(edit.span)), - newText: edit.newText ? edit.newText : "" - }; - }); + return edits.map(edit => this.convertTextChangeToCodeEdit(edit, scriptInfo)); } private getFormattingEditsForRangeFull(args: protocol.FormatRequestArgs) { @@ -1201,6 +1196,10 @@ namespace ts.server { } } + private getSupportedCodeFixes(): string[] { + return ts.getSupportedCodeFixes(); + } + private getCodeFixes(args: protocol.CodeFixRequestArgs, simplifiedResult: boolean): protocol.CodeAction[] | CodeAction[] { const { file, project } = this.getFileAndProjectWithoutRefreshingInferredProjects(args); @@ -1213,28 +1212,12 @@ namespace ts.server { return undefined; } if (simplifiedResult) { - return codeActions.map(mapCodeAction); + return codeActions.map(codeAction => this.mapCodeAction(codeAction, scriptInfo)); } else { return codeActions; } - function mapCodeAction(source: CodeAction): protocol.CodeAction { - return { - description: source.description, - changes: source.changes.map(change => ({ - fileName: change.fileName, - textChanges: change.textChanges.map(textChange => ({ - span: { - start: scriptInfo.positionToLineOffset(textChange.span.start), - end: scriptInfo.positionToLineOffset(textChange.span.start + textChange.span.length) - }, - newText: textChange.newText - })) - })) - }; - } - function getStartPosition() { return args.startPosition !== undefined ? args.startPosition : scriptInfo.lineOffsetToPosition(args.startLine, args.startOffset); } @@ -1244,6 +1227,24 @@ namespace ts.server { } } + private mapCodeAction(codeAction: CodeAction, scriptInfo: ScriptInfo): protocol.CodeAction { + return { + description: codeAction.description, + changes: codeAction.changes.map(change => ({ + fileName: change.fileName, + textChanges: change.textChanges.map(textChange => this.convertTextChangeToCodeEdit(textChange, scriptInfo)) + })) + }; + } + + private convertTextChangeToCodeEdit(change: ts.TextChange, scriptInfo: ScriptInfo): protocol.CodeEdit { + return { + start: scriptInfo.positionToLineOffset(change.span.start), + end: scriptInfo.positionToLineOffset(change.span.start + change.span.length), + newText: change.newText + }; + } + private getBraceMatching(args: protocol.FileLocationRequestArgs, simplifiedResult: boolean): protocol.TextSpan[] | TextSpan[] { const { file, project } = this.getFileAndProjectWithoutRefreshingInferredProjects(args); @@ -1572,6 +1573,9 @@ namespace ts.server { }, [CommandNames.GetCodeFixesFull]: (request: protocol.CodeFixRequest) => { return this.requiredResponse(this.getCodeFixes(request.arguments, /*simplifiedResult*/ false)); + }, + [CommandNames.GetSupportedCodeFixes]: (request: protocol.Request) => { + return this.requiredResponse(this.getSupportedCodeFixes()); } }); diff --git a/src/services/codefixes/codeFixProvider.ts b/src/services/codefixes/codeFixProvider.ts index bc5ee1fb97e..c61cbe1b19e 100644 --- a/src/services/codefixes/codeFixProvider.ts +++ b/src/services/codefixes/codeFixProvider.ts @@ -2,7 +2,7 @@ namespace ts { export interface CodeFix { errorCodes: number[]; - getCodeActions(context: CodeFixContext): CodeAction[]; + getCodeActions(context: CodeFixContext): CodeAction[] | undefined; } export interface CodeFixContext { diff --git a/src/services/services.ts b/src/services/services.ts index 7f81649bacb..4aba7c4f88f 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1648,6 +1648,8 @@ namespace ts { let allFixes: CodeAction[] = []; forEach(errorCodes, error => { + cancellationToken.throwIfCancellationRequested(); + const context = { errorCode: error, sourceFile: sourceFile, diff --git a/src/services/shims.ts b/src/services/shims.ts index 19dadba89bf..56ab852606c 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -251,8 +251,6 @@ namespace ts { */ isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): string; - getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: string): string; - getEmitOutput(fileName: string): string; getEmitOutputObject(fileName: string): EmitOutput; } @@ -268,7 +266,6 @@ namespace ts { getTSConfigFileInfo(fileName: string, sourceText: IScriptSnapshot): string; getDefaultCompilationSettings(): string; discoverTypings(discoverTypingsJson: string): string; - getSupportedCodeFixes(): string; } function logInternalError(logger: Logger, err: Error) { @@ -957,16 +954,6 @@ namespace ts { ); } - public getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: string): string { - return this.forwardJSONCall( - `getCodeFixesAtPosition( '${fileName}', ${start}, ${end}, ${errorCodes}')`, - () => { - const localErrors: number[] = JSON.parse(errorCodes); - return this.languageService.getCodeFixesAtPosition(fileName, start, end, localErrors); - } - ); - } - /// NAVIGATE TO /** Return a list of symbols that are interesting to navigate to */ @@ -1175,12 +1162,6 @@ namespace ts { info.compilerOptions); }); } - - public getSupportedCodeFixes(): string { - return this.forwardJSONCall("getSupportedCodeFixes()", - () => getSupportedCodeFixes() - ); - } } export class TypeScriptServicesFactory implements ShimFactory { From 77610f6e3eedbd423b57dd1a305544877287a7a2 Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Fri, 7 Oct 2016 11:18:01 -0700 Subject: [PATCH 029/173] rename of the response body --- src/server/protocol.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/protocol.d.ts b/src/server/protocol.d.ts index bb95144af79..66cbf56fc3a 100644 --- a/src/server/protocol.d.ts +++ b/src/server/protocol.d.ts @@ -926,7 +926,7 @@ declare namespace ts.server.protocol { export interface CodeFixResponse extends Response { /** The code actions that are available */ - codeActions: CodeAction[]; + body?: CodeAction[]; } export interface CodeAction { From a83a2b0de03e1c8e28f2f2f1b2bbef1a8a6de83c Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Fri, 7 Oct 2016 13:58:53 -0700 Subject: [PATCH 030/173] Codefixes in client for testing the server. --- src/server/client.ts | 70 +++++++++++++++++++++-- src/server/protocol.d.ts | 5 ++ src/server/session.ts | 7 ++- tests/cases/fourslash/server/superFix1.ts | 10 ++++ 4 files changed, 85 insertions(+), 7 deletions(-) create mode 100644 tests/cases/fourslash/server/superFix1.ts diff --git a/src/server/client.ts b/src/server/client.ts index 089a0eed12c..20bddf77895 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -425,11 +425,35 @@ namespace ts.server { } getSyntacticDiagnostics(fileName: string): Diagnostic[] { - throw new Error("Not Implemented Yet."); + const args: protocol.SyntacticDiagnosticsSyncRequestArgs = { file: fileName }; + + const request = this.processRequest(CommandNames.SyntacticDiagnosticsSync, args); + const response = this.processResponse(request); + + return (response.body).map(entry => this.convertDiagnostic(entry, fileName)); } getSemanticDiagnostics(fileName: string): Diagnostic[] { - throw new Error("Not Implemented Yet."); + const args: protocol.SemanticDiagnosticsSyncRequestArgs = { file: fileName }; + + const request = this.processRequest(CommandNames.SemanticDiagnosticsSync, args); + const response = this.processResponse(request); + + return (response.body).map(entry => this.convertDiagnostic(entry, fileName)); + } + + convertDiagnostic(entry: protocol.Diagnostic, fileName: string): Diagnostic { + const start = this.lineOffsetToPosition(fileName, entry.start); + const end = this.lineOffsetToPosition(fileName, entry.end); + + return { + file: undefined, + start: start, + length: end - start, + messageText: entry.text, + category: undefined, + code: entry.code + }; } getCompilerOptionsDiagnostics(): Diagnostic[] { @@ -630,8 +654,46 @@ namespace ts.server { throw new Error("Not Implemented Yet."); } - getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[]): ts.CodeAction[] { - throw new Error("Not Implemented Yet."); + getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[]): CodeAction[] { + const startLineOffset = this.positionToOneBasedLineOffset(fileName, start); + const endLineOffset = this.positionToOneBasedLineOffset(fileName, end); + + const args: protocol.CodeFixRequestArgs = { + file: fileName, + startLine: startLineOffset.line, + startOffset: startLineOffset.offset, + endLine: endLineOffset.line, + endOffset: endLineOffset.offset, + errorCodes: errorCodes, + }; + + const request = this.processRequest(CommandNames.GetCodeFixesFull, args); + const response = this.processResponse(request); + + return response.body.map(entry => this.convertCodeActions(entry, fileName)); + } + + convertCodeActions(entry: protocol.CodeAction, fileName: string): CodeAction { + return { + description: entry.description, + changes: entry.changes.map(change => ({ + fileName: change.fileName, + textChanges: change.textChanges.map(textChange => this.convertTextChangeToCodeEdit(textChange, fileName)) + })) + }; + } + + convertTextChangeToCodeEdit(change: protocol.CodeEdit, fileName: string): ts.TextChange { + const start = this.lineOffsetToPosition(fileName, change.start); + const end = this.lineOffsetToPosition(fileName, change.end); + + return { + span: { + start: start, + length: end - start + }, + newText: change.newText ? change.newText : "" + }; } getBraceMatchingAtPosition(fileName: string, position: number): TextSpan[] { diff --git a/src/server/protocol.d.ts b/src/server/protocol.d.ts index 66cbf56fc3a..60fd61c05cf 100644 --- a/src/server/protocol.d.ts +++ b/src/server/protocol.d.ts @@ -1310,6 +1310,11 @@ declare namespace ts.server.protocol { * Text of diagnostic message. */ text: string; + + /** + * The error code of the diagnostic message. + */ + code?: number; } export interface DiagnosticEventBody { diff --git a/src/server/session.ts b/src/server/session.ts index ccbf6caea1f..c945dca99a4 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -1,4 +1,4 @@ -/// +/// /// /// /// @@ -44,7 +44,8 @@ namespace ts.server { return { start: scriptInfo.positionToLineOffset(diag.start), end: scriptInfo.positionToLineOffset(diag.start + diag.length), - text: ts.flattenDiagnosticMessageText(diag.messageText, "\n") + text: ts.flattenDiagnosticMessageText(diag.messageText, "\n"), + code: diag.code }; } @@ -1241,7 +1242,7 @@ namespace ts.server { return { start: scriptInfo.positionToLineOffset(change.span.start), end: scriptInfo.positionToLineOffset(change.span.start + change.span.length), - newText: change.newText + newText: change.newText ? change.newText : "" }; } diff --git a/tests/cases/fourslash/server/superFix1.ts b/tests/cases/fourslash/server/superFix1.ts new file mode 100644 index 00000000000..7fbe2cb4fd7 --- /dev/null +++ b/tests/cases/fourslash/server/superFix1.ts @@ -0,0 +1,10 @@ +/// + +////class Base{ +////} +////class C extends Base{ +//// constructor() {[| |] +//// } +////} + +verify.codeFixAtPosition('super();'); From f3103100e307ebaa5d34ad4293daab9062fc31d9 Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Fri, 7 Oct 2016 14:13:32 -0700 Subject: [PATCH 031/173] Deal with buildbreak --- src/services/codefixes/superFixes.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/services/codefixes/superFixes.ts b/src/services/codefixes/superFixes.ts index 35462f0d49e..f117799f3e1 100644 --- a/src/services/codefixes/superFixes.ts +++ b/src/services/codefixes/superFixes.ts @@ -34,7 +34,7 @@ namespace ts.codefix { } const constructor = getContainingFunction(token); - const superCall = findSuperCall((constructor).body); + const superCall = findSuperCall((constructor).body); if (!superCall) { return undefined; } @@ -67,9 +67,9 @@ namespace ts.codefix { changes }]; - function findSuperCall(n: Node): Node { - if (n.kind === SyntaxKind.ExpressionStatement && isSuperCallExpression((n).expression)) { - return n; + function findSuperCall(n: Node): ExpressionStatement { + if (n.kind === SyntaxKind.ExpressionStatement && isSuperCall((n).expression)) { + return n; } if (isFunctionLike(n)) { return undefined; From 7c96c288635012a869bb8c620ff2d9e3d813f6a4 Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Fri, 7 Oct 2016 15:55:33 -0700 Subject: [PATCH 032/173] Fix test failure --- src/server/client.ts | 2 +- tests/cases/fourslash/server/{superFix1.ts => codefix.ts} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename tests/cases/fourslash/server/{superFix1.ts => codefix.ts} (100%) diff --git a/src/server/client.ts b/src/server/client.ts index 20bddf77895..2acc0a58cad 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -667,7 +667,7 @@ namespace ts.server { errorCodes: errorCodes, }; - const request = this.processRequest(CommandNames.GetCodeFixesFull, args); + const request = this.processRequest(CommandNames.GetCodeFixes, args); const response = this.processResponse(request); return response.body.map(entry => this.convertCodeActions(entry, fileName)); diff --git a/tests/cases/fourslash/server/superFix1.ts b/tests/cases/fourslash/server/codefix.ts similarity index 100% rename from tests/cases/fourslash/server/superFix1.ts rename to tests/cases/fourslash/server/codefix.ts From d543028226e0e8442fd01153f4393b10f829c3b0 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 6 Oct 2016 13:27:18 -0700 Subject: [PATCH 033/173] Add test case for narrowed const in object literal and class expression method --- .../narrowedConstInMethod.errors.txt | 27 +++++++++++++ .../reference/narrowedConstInMethod.js | 40 +++++++++++++++++++ tests/cases/compiler/narrowedConstInMethod.ts | 19 +++++++++ 3 files changed, 86 insertions(+) create mode 100644 tests/baselines/reference/narrowedConstInMethod.errors.txt create mode 100644 tests/baselines/reference/narrowedConstInMethod.js create mode 100644 tests/cases/compiler/narrowedConstInMethod.ts diff --git a/tests/baselines/reference/narrowedConstInMethod.errors.txt b/tests/baselines/reference/narrowedConstInMethod.errors.txt new file mode 100644 index 00000000000..ebb85218a5b --- /dev/null +++ b/tests/baselines/reference/narrowedConstInMethod.errors.txt @@ -0,0 +1,27 @@ +tests/cases/compiler/narrowedConstInMethod.ts(6,28): error TS2531: Object is possibly 'null'. +tests/cases/compiler/narrowedConstInMethod.ts(15,28): error TS2531: Object is possibly 'null'. + + +==== tests/cases/compiler/narrowedConstInMethod.ts (2 errors) ==== + + function f() { + const x: string | null = {}; + if (x !== null) { + return { + bar() { return x.length; } // Error: possibly null x + ~ +!!! error TS2531: Object is possibly 'null'. + }; + } + } + + function f2() { + const x: string | null = {}; + if (x !== null) { + return class { + bar() { return x.length; } // Error: possibly null x + ~ +!!! error TS2531: Object is possibly 'null'. + }; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/narrowedConstInMethod.js b/tests/baselines/reference/narrowedConstInMethod.js new file mode 100644 index 00000000000..f4cdc3def91 --- /dev/null +++ b/tests/baselines/reference/narrowedConstInMethod.js @@ -0,0 +1,40 @@ +//// [narrowedConstInMethod.ts] + +function f() { + const x: string | null = {}; + if (x !== null) { + return { + bar() { return x.length; } // Error: possibly null x + }; + } +} + +function f2() { + const x: string | null = {}; + if (x !== null) { + return class { + bar() { return x.length; } // Error: possibly null x + }; + } +} + +//// [narrowedConstInMethod.js] +function f() { + var x = {}; + if (x !== null) { + return { + bar: function () { return x.length; } // Error: possibly null x + }; + } +} +function f2() { + var x = {}; + if (x !== null) { + return (function () { + function class_1() { + } + class_1.prototype.bar = function () { return x.length; }; // Error: possibly null x + return class_1; + }()); + } +} diff --git a/tests/cases/compiler/narrowedConstInMethod.ts b/tests/cases/compiler/narrowedConstInMethod.ts new file mode 100644 index 00000000000..3ddf97a8df3 --- /dev/null +++ b/tests/cases/compiler/narrowedConstInMethod.ts @@ -0,0 +1,19 @@ +// @strictNullChecks: true + +function f() { + const x: string | null = {}; + if (x !== null) { + return { + bar() { return x.length; } // Error: possibly null x + }; + } +} + +function f2() { + const x: string | null = {}; + if (x !== null) { + return class { + bar() { return x.length; } // Error: possibly null x + }; + } +} \ No newline at end of file From 402f1f6bf8af963d4cf127b6c123b5b1be1a50bf Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Fri, 7 Oct 2016 17:45:15 -0700 Subject: [PATCH 034/173] Narrowed consts flow through object literal or class expression method Fixes #10501 --- src/compiler/binder.ts | 14 ++++- src/compiler/checker.ts | 4 +- src/compiler/types.ts | 2 +- src/compiler/utilities.ts | 6 ++ .../narrowedConstInMethod.errors.txt | 27 --------- .../reference/narrowedConstInMethod.symbols | 41 ++++++++++++++ .../reference/narrowedConstInMethod.types | 55 +++++++++++++++++++ 7 files changed, 117 insertions(+), 32 deletions(-) delete mode 100644 tests/baselines/reference/narrowedConstInMethod.errors.txt create mode 100644 tests/baselines/reference/narrowedConstInMethod.symbols create mode 100644 tests/baselines/reference/narrowedConstInMethod.types diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 27803b43526..9906bfdc661 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -84,6 +84,7 @@ namespace ts { IsFunctionExpression = 1 << 4, HasLocals = 1 << 5, IsInterface = 1 << 6, + IsObjectLiteralOrClassExpressionMethod = 1 << 7, } const binder = createBinder(); @@ -486,8 +487,8 @@ namespace ts { } else { currentFlow = { flags: FlowFlags.Start }; - if (containerFlags & ContainerFlags.IsFunctionExpression) { - (currentFlow).container = node; + if (containerFlags & (ContainerFlags.IsFunctionExpression | ContainerFlags.IsObjectLiteralOrClassExpressionMethod)) { + (currentFlow).container = node; } currentReturnTarget = undefined; } @@ -1237,9 +1238,12 @@ namespace ts { case SyntaxKind.SourceFile: return ContainerFlags.IsContainer | ContainerFlags.IsControlFlowContainer | ContainerFlags.HasLocals; + case SyntaxKind.MethodDeclaration: + if (isObjectLiteralOrClassExpressionMethod(node)) { + return ContainerFlags.IsContainer | ContainerFlags.IsControlFlowContainer | ContainerFlags.HasLocals | ContainerFlags.IsFunctionLike | ContainerFlags.IsObjectLiteralOrClassExpressionMethod; + } case SyntaxKind.Constructor: case SyntaxKind.FunctionDeclaration: - case SyntaxKind.MethodDeclaration: case SyntaxKind.MethodSignature: case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: @@ -2238,6 +2242,10 @@ namespace ts { } } + if (currentFlow && isObjectLiteralOrClassExpressionMethod(node)) { + node.flowNode = currentFlow; + } + return hasDynamicName(node) ? bindAnonymousDeclaration(node, symbolFlags, "__computed") : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index dfe6317e250..20e20e0eea9 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9163,7 +9163,9 @@ namespace ts { // a const variable or parameter from an outer function, we extend the origin of the control flow // analysis to include the immediately enclosing function. while (flowContainer !== declarationContainer && - (flowContainer.kind === SyntaxKind.FunctionExpression || flowContainer.kind === SyntaxKind.ArrowFunction) && + (flowContainer.kind === SyntaxKind.FunctionExpression || + flowContainer.kind === SyntaxKind.ArrowFunction || + isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isReadonlySymbol(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 638504e613f..5c4ffedb33c 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1922,7 +1922,7 @@ namespace ts { // function, the container property references the function (which in turn has a flowNode // property for the containing control flow). export interface FlowStart extends FlowNode { - container?: FunctionExpression | ArrowFunction; + container?: FunctionExpression | ArrowFunction | MethodDeclaration; } // FlowLabel represents a junction with multiple possible preceding control flows. diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 558015bb0e3..498c195ea3a 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -895,6 +895,12 @@ namespace ts { return node && node.kind === SyntaxKind.MethodDeclaration && node.parent.kind === SyntaxKind.ObjectLiteralExpression; } + export function isObjectLiteralOrClassExpressionMethod(node: Node): node is MethodDeclaration { + return node.kind === SyntaxKind.MethodDeclaration && + (node.parent.kind === SyntaxKind.ObjectLiteralExpression || + node.parent.kind === SyntaxKind.ClassExpression); + } + export function isIdentifierTypePredicate(predicate: TypePredicate): predicate is IdentifierTypePredicate { return predicate && predicate.kind === TypePredicateKind.Identifier; } diff --git a/tests/baselines/reference/narrowedConstInMethod.errors.txt b/tests/baselines/reference/narrowedConstInMethod.errors.txt deleted file mode 100644 index ebb85218a5b..00000000000 --- a/tests/baselines/reference/narrowedConstInMethod.errors.txt +++ /dev/null @@ -1,27 +0,0 @@ -tests/cases/compiler/narrowedConstInMethod.ts(6,28): error TS2531: Object is possibly 'null'. -tests/cases/compiler/narrowedConstInMethod.ts(15,28): error TS2531: Object is possibly 'null'. - - -==== tests/cases/compiler/narrowedConstInMethod.ts (2 errors) ==== - - function f() { - const x: string | null = {}; - if (x !== null) { - return { - bar() { return x.length; } // Error: possibly null x - ~ -!!! error TS2531: Object is possibly 'null'. - }; - } - } - - function f2() { - const x: string | null = {}; - if (x !== null) { - return class { - bar() { return x.length; } // Error: possibly null x - ~ -!!! error TS2531: Object is possibly 'null'. - }; - } - } \ No newline at end of file diff --git a/tests/baselines/reference/narrowedConstInMethod.symbols b/tests/baselines/reference/narrowedConstInMethod.symbols new file mode 100644 index 00000000000..1fd05dcea5e --- /dev/null +++ b/tests/baselines/reference/narrowedConstInMethod.symbols @@ -0,0 +1,41 @@ +=== tests/cases/compiler/narrowedConstInMethod.ts === + +function f() { +>f : Symbol(f, Decl(narrowedConstInMethod.ts, 0, 0)) + + const x: string | null = {}; +>x : Symbol(x, Decl(narrowedConstInMethod.ts, 2, 9)) + + if (x !== null) { +>x : Symbol(x, Decl(narrowedConstInMethod.ts, 2, 9)) + + return { + bar() { return x.length; } // Error: possibly null x +>bar : Symbol(bar, Decl(narrowedConstInMethod.ts, 4, 16)) +>x.length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(narrowedConstInMethod.ts, 2, 9)) +>length : Symbol(String.length, Decl(lib.d.ts, --, --)) + + }; + } +} + +function f2() { +>f2 : Symbol(f2, Decl(narrowedConstInMethod.ts, 8, 1)) + + const x: string | null = {}; +>x : Symbol(x, Decl(narrowedConstInMethod.ts, 11, 9)) + + if (x !== null) { +>x : Symbol(x, Decl(narrowedConstInMethod.ts, 11, 9)) + + return class { + bar() { return x.length; } // Error: possibly null x +>bar : Symbol((Anonymous class).bar, Decl(narrowedConstInMethod.ts, 13, 22)) +>x.length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(narrowedConstInMethod.ts, 11, 9)) +>length : Symbol(String.length, Decl(lib.d.ts, --, --)) + + }; + } +} diff --git a/tests/baselines/reference/narrowedConstInMethod.types b/tests/baselines/reference/narrowedConstInMethod.types new file mode 100644 index 00000000000..a73f2edfccb --- /dev/null +++ b/tests/baselines/reference/narrowedConstInMethod.types @@ -0,0 +1,55 @@ +=== tests/cases/compiler/narrowedConstInMethod.ts === + +function f() { +>f : () => { bar(): number; } | undefined + + const x: string | null = {}; +>x : string | null +>null : null +>{} : any +>{} : {} + + if (x !== null) { +>x !== null : boolean +>x : string | null +>null : null + + return { +>{ bar() { return x.length; } // Error: possibly null x } : { bar(): number; } + + bar() { return x.length; } // Error: possibly null x +>bar : () => number +>x.length : number +>x : string +>length : number + + }; + } +} + +function f2() { +>f2 : () => typeof (Anonymous class) | undefined + + const x: string | null = {}; +>x : string | null +>null : null +>{} : any +>{} : {} + + if (x !== null) { +>x !== null : boolean +>x : string | null +>null : null + + return class { +>class { bar() { return x.length; } // Error: possibly null x } : typeof (Anonymous class) + + bar() { return x.length; } // Error: possibly null x +>bar : () => number +>x.length : number +>x : string +>length : number + + }; + } +} From 71b9b3351755e3e6978cec656c91032c0bfb0ab1 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 8 Oct 2016 15:26:17 -0700 Subject: [PATCH 035/173] Fix issue in control flow analysis of nested loops --- src/compiler/checker.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 0a606afe69f..2ff5700082a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8797,10 +8797,14 @@ namespace ts { } // If this flow loop junction and reference are already being processed, return // the union of the types computed for each branch so far, marked as incomplete. - // We should never see an empty array here because the first antecedent of a loop - // junction is always the non-looping control flow path that leads to the top. + // It is possible to see an empty array in cases where loops are nested and the + // back edge of the outer loop reaches an inner loop that is already being analyzed. + // In such cases we restart the analysis of the inner loop, which will then see + // a non-empty in-process array for the outer loop and eventually terminate because + // the first antecedent of a loop junction is always the non-looping control flow + // path that leads to the top. for (let i = flowLoopStart; i < flowLoopCount; i++) { - if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key) { + if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key && flowLoopTypes[i].length) { return createFlowType(getUnionOrEvolvingArrayType(flowLoopTypes[i], /*subtypeReduction*/ false), /*incomplete*/ true); } } From d202b1c037634939003b88fec921465969dec028 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 8 Oct 2016 15:27:49 -0700 Subject: [PATCH 036/173] Add test --- tests/cases/compiler/controlFlowArrays.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/cases/compiler/controlFlowArrays.ts b/tests/cases/compiler/controlFlowArrays.ts index d5eaa9c4320..781b8c09d12 100644 --- a/tests/cases/compiler/controlFlowArrays.ts +++ b/tests/cases/compiler/controlFlowArrays.ts @@ -138,4 +138,13 @@ function f14() { x.push("hello"); x.push(true); return x; // (string | number | boolean)[] +} + +function f15() { + let x = []; + while (cond()) { + while (cond()) {} + x.push("hello"); + } + return x; // string[] } \ No newline at end of file From 89826a52ad09a5c854670caff7960e83a71fae43 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 8 Oct 2016 15:27:57 -0700 Subject: [PATCH 037/173] Accept new baselines --- .../baselines/reference/controlFlowArrays.js | 17 ++++++++++++ .../reference/controlFlowArrays.symbols | 21 +++++++++++++++ .../reference/controlFlowArrays.types | 26 +++++++++++++++++++ 3 files changed, 64 insertions(+) diff --git a/tests/baselines/reference/controlFlowArrays.js b/tests/baselines/reference/controlFlowArrays.js index 26885aecd8b..c5ec1a7642c 100644 --- a/tests/baselines/reference/controlFlowArrays.js +++ b/tests/baselines/reference/controlFlowArrays.js @@ -137,6 +137,15 @@ function f14() { x.push("hello"); x.push(true); return x; // (string | number | boolean)[] +} + +function f15() { + let x = []; + while (cond()) { + while (cond()) {} + x.push("hello"); + } + return x; // string[] } //// [controlFlowArrays.js] @@ -265,3 +274,11 @@ function f14() { x.push(true); return x; // (string | number | boolean)[] } +function f15() { + var x = []; + while (cond()) { + while (cond()) { } + x.push("hello"); + } + return x; // string[] +} diff --git a/tests/baselines/reference/controlFlowArrays.symbols b/tests/baselines/reference/controlFlowArrays.symbols index 5b5ef7f8506..fd7c6ba89b7 100644 --- a/tests/baselines/reference/controlFlowArrays.symbols +++ b/tests/baselines/reference/controlFlowArrays.symbols @@ -348,3 +348,24 @@ function f14() { return x; // (string | number | boolean)[] >x : Symbol(x, Decl(controlFlowArrays.ts, 133, 9)) } + +function f15() { +>f15 : Symbol(f15, Decl(controlFlowArrays.ts, 138, 1)) + + let x = []; +>x : Symbol(x, Decl(controlFlowArrays.ts, 141, 7)) + + while (cond()) { +>cond : Symbol(cond, Decl(controlFlowArrays.ts, 0, 0)) + + while (cond()) {} +>cond : Symbol(cond, Decl(controlFlowArrays.ts, 0, 0)) + + x.push("hello"); +>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 141, 7)) +>push : Symbol(Array.push, Decl(lib.d.ts, --, --)) + } + return x; // string[] +>x : Symbol(x, Decl(controlFlowArrays.ts, 141, 7)) +} diff --git a/tests/baselines/reference/controlFlowArrays.types b/tests/baselines/reference/controlFlowArrays.types index 7b36e4067fa..3fb84215ed7 100644 --- a/tests/baselines/reference/controlFlowArrays.types +++ b/tests/baselines/reference/controlFlowArrays.types @@ -445,3 +445,29 @@ function f14() { return x; // (string | number | boolean)[] >x : (string | number | boolean)[] } + +function f15() { +>f15 : () => string[] + + let x = []; +>x : any[] +>[] : never[] + + while (cond()) { +>cond() : boolean +>cond : () => boolean + + while (cond()) {} +>cond() : boolean +>cond : () => boolean + + x.push("hello"); +>x.push("hello") : number +>x.push : (...items: any[]) => number +>x : any[] +>push : (...items: any[]) => number +>"hello" : "hello" + } + return x; // string[] +>x : string[] +} From 29a85e02ab4d43cf67d013aaac158c6a32108d20 Mon Sep 17 00:00:00 2001 From: Slawomir Sadziak Date: Sun, 9 Oct 2016 00:49:51 +0200 Subject: [PATCH 038/173] Fix #10758 Add compiler option to parse in strict mode * add compiler option alwaysStrict * compile in strict mode when option is set * emit "use strict" --- src/compiler/binder.ts | 15 +++++++++++++-- src/compiler/commandLineParser.ts | 5 +++++ src/compiler/diagnosticMessages.json | 4 ++++ src/compiler/transformers/ts.ts | 12 ++++++++++++ src/compiler/types.ts | 1 + src/harness/unittests/transpile.ts | 4 ++++ .../baselines/reference/alwaysStrict.errors.txt | 10 ++++++++++ tests/baselines/reference/alwaysStrict.js | 11 +++++++++++ .../reference/alwaysStrictES6.errors.txt | 10 ++++++++++ tests/baselines/reference/alwaysStrictES6.js | 11 +++++++++++ .../reference/alwaysStrictModule.errors.txt | 12 ++++++++++++ tests/baselines/reference/alwaysStrictModule.js | 17 +++++++++++++++++ .../alwaysStrictNoImplicitUseStrict.errors.txt | 12 ++++++++++++ .../alwaysStrictNoImplicitUseStrict.js | 17 +++++++++++++++++ .../transpile/Supports setting alwaysStrict.js | 3 +++ tests/cases/compiler/alwaysStrict.ts | 5 +++++ tests/cases/compiler/alwaysStrictES6.ts | 6 ++++++ tests/cases/compiler/alwaysStrictModule.ts | 8 ++++++++ .../compiler/alwaysStrictNoImplicitUseStrict.ts | 9 +++++++++ 19 files changed, 170 insertions(+), 2 deletions(-) create mode 100644 tests/baselines/reference/alwaysStrict.errors.txt create mode 100644 tests/baselines/reference/alwaysStrict.js create mode 100644 tests/baselines/reference/alwaysStrictES6.errors.txt create mode 100644 tests/baselines/reference/alwaysStrictES6.js create mode 100644 tests/baselines/reference/alwaysStrictModule.errors.txt create mode 100644 tests/baselines/reference/alwaysStrictModule.js create mode 100644 tests/baselines/reference/alwaysStrictNoImplicitUseStrict.errors.txt create mode 100644 tests/baselines/reference/alwaysStrictNoImplicitUseStrict.js create mode 100644 tests/baselines/reference/transpile/Supports setting alwaysStrict.js create mode 100644 tests/cases/compiler/alwaysStrict.ts create mode 100644 tests/cases/compiler/alwaysStrictES6.ts create mode 100644 tests/cases/compiler/alwaysStrictModule.ts create mode 100644 tests/cases/compiler/alwaysStrictNoImplicitUseStrict.ts diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 27803b43526..13da6520408 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -121,7 +121,8 @@ namespace ts { // 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). + // not depending on if we see "use strict" in certain places or if we hit a class/namespace + // or if compiler options contain alwaysStrict. let inStrictMode: boolean; let symbolCount = 0; @@ -139,7 +140,7 @@ namespace ts { file = f; options = opts; languageVersion = getEmitScriptTarget(options); - inStrictMode = !!file.externalModuleIndicator; + inStrictMode = bindInStrictMode(file, opts); classifiableNames = createMap(); symbolCount = 0; skipTransformFlagAggregation = isDeclarationFile(file); @@ -174,6 +175,16 @@ namespace ts { return bindSourceFile; + function bindInStrictMode(file: SourceFile, opts: CompilerOptions): boolean { + if (opts.alwaysStrict && !isDeclarationFile(file)) { + // bind in strict mode source files with alwaysStrict option + return true; + } + else { + return !!file.externalModuleIndicator; + } + } + function createSymbol(flags: SymbolFlags, name: string): Symbol { symbolCount++; return new Symbol(flags, name); diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 648447ac26a..2d657307ec7 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -444,6 +444,11 @@ namespace ts { name: "importHelpers", type: "boolean", description: Diagnostics.Import_emit_helpers_from_tslib + }, + { + name: "alwaysStrict", + type: "boolean", + description: Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file } ]; diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 58c0e6ee3f2..70fc7c43d8d 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2861,6 +2861,10 @@ "category": "Error", "code": 6140 }, + "Parse in strict mode and emit \"use strict\" for each source file": { + "category": "Message", + "code": 6141 + }, "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", "code": 7005 diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 41f03d20f2e..7b6c28a8f41 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -436,6 +436,11 @@ namespace ts { function visitSourceFile(node: SourceFile) { currentSourceFile = node; + // ensure "use strict"" is emitted in all scenarios in alwaysStrict mode + if (compilerOptions.alwaysStrict) { + node = emitUseStrict(node); + } + // If the source file requires any helpers and is an external module, and // the importHelpers compiler option is enabled, emit a synthesized import // statement for the helpers library. @@ -472,6 +477,13 @@ namespace ts { return node; } + function emitUseStrict(node: SourceFile): SourceFile { + const statements: Statement[] = []; + statements.push(startOnNewLine(createStatement(createLiteral("use strict")))); + // add "use strict" as the first statement + return updateSourceFileNode(node, statements.concat(node.statements)); + } + /** * Tests whether we should emit a __decorate call for a class declaration. */ diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 638504e613f..171d7c40e7e 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2929,6 +2929,7 @@ namespace ts { allowSyntheticDefaultImports?: boolean; allowUnreachableCode?: boolean; allowUnusedLabels?: boolean; + alwaysStrict?: boolean; baseUrl?: string; charset?: string; /* @internal */ configFilePath?: string; diff --git a/src/harness/unittests/transpile.ts b/src/harness/unittests/transpile.ts index 808a5df37c1..35b4f808350 100644 --- a/src/harness/unittests/transpile.ts +++ b/src/harness/unittests/transpile.ts @@ -253,6 +253,10 @@ var x = 0;`, { options: { compilerOptions: { allowUnusedLabels: true }, fileName: "input.js", reportDiagnostics: true } }); + transpilesCorrectly("Supports setting 'alwaysStrict'", "x;", { + options: { compilerOptions: { alwaysStrict: true }, fileName: "input.js", reportDiagnostics: true } + }); + transpilesCorrectly("Supports setting 'baseUrl'", "x;", { options: { compilerOptions: { baseUrl: "./folder/baseUrl" }, fileName: "input.js", reportDiagnostics: true } }); diff --git a/tests/baselines/reference/alwaysStrict.errors.txt b/tests/baselines/reference/alwaysStrict.errors.txt new file mode 100644 index 00000000000..d7fcfb45801 --- /dev/null +++ b/tests/baselines/reference/alwaysStrict.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/alwaysStrict.ts(3,9): error TS1100: Invalid use of 'arguments' in strict mode. + + +==== tests/cases/compiler/alwaysStrict.ts (1 errors) ==== + + function f() { + var arguments = []; + ~~~~~~~~~ +!!! error TS1100: Invalid use of 'arguments' in strict mode. + } \ No newline at end of file diff --git a/tests/baselines/reference/alwaysStrict.js b/tests/baselines/reference/alwaysStrict.js new file mode 100644 index 00000000000..bc5f9a29912 --- /dev/null +++ b/tests/baselines/reference/alwaysStrict.js @@ -0,0 +1,11 @@ +//// [alwaysStrict.ts] + +function f() { + var arguments = []; +} + +//// [alwaysStrict.js] +"use strict"; +function f() { + var arguments = []; +} diff --git a/tests/baselines/reference/alwaysStrictES6.errors.txt b/tests/baselines/reference/alwaysStrictES6.errors.txt new file mode 100644 index 00000000000..b775a6e4755 --- /dev/null +++ b/tests/baselines/reference/alwaysStrictES6.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/alwaysStrictES6.ts(3,9): error TS1100: Invalid use of 'arguments' in strict mode. + + +==== tests/cases/compiler/alwaysStrictES6.ts (1 errors) ==== + + function f() { + var arguments = []; + ~~~~~~~~~ +!!! error TS1100: Invalid use of 'arguments' in strict mode. + } \ No newline at end of file diff --git a/tests/baselines/reference/alwaysStrictES6.js b/tests/baselines/reference/alwaysStrictES6.js new file mode 100644 index 00000000000..2c7ad36bce2 --- /dev/null +++ b/tests/baselines/reference/alwaysStrictES6.js @@ -0,0 +1,11 @@ +//// [alwaysStrictES6.ts] + +function f() { + var arguments = []; +} + +//// [alwaysStrictES6.js] +"use strict"; +function f() { + var arguments = []; +} diff --git a/tests/baselines/reference/alwaysStrictModule.errors.txt b/tests/baselines/reference/alwaysStrictModule.errors.txt new file mode 100644 index 00000000000..90c1a0b930a --- /dev/null +++ b/tests/baselines/reference/alwaysStrictModule.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/alwaysStrictModule.ts(4,13): error TS1100: Invalid use of 'arguments' in strict mode. + + +==== tests/cases/compiler/alwaysStrictModule.ts (1 errors) ==== + + module M { + export function f() { + var arguments = []; + ~~~~~~~~~ +!!! error TS1100: Invalid use of 'arguments' in strict mode. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/alwaysStrictModule.js b/tests/baselines/reference/alwaysStrictModule.js new file mode 100644 index 00000000000..f39c87ed96c --- /dev/null +++ b/tests/baselines/reference/alwaysStrictModule.js @@ -0,0 +1,17 @@ +//// [alwaysStrictModule.ts] + +module M { + export function f() { + var arguments = []; + } +} + +//// [alwaysStrictModule.js] +"use strict"; +var M; +(function (M) { + function f() { + var arguments = []; + } + M.f = f; +})(M || (M = {})); diff --git a/tests/baselines/reference/alwaysStrictNoImplicitUseStrict.errors.txt b/tests/baselines/reference/alwaysStrictNoImplicitUseStrict.errors.txt new file mode 100644 index 00000000000..d677ec9b4cb --- /dev/null +++ b/tests/baselines/reference/alwaysStrictNoImplicitUseStrict.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/alwaysStrictNoImplicitUseStrict.ts(4,13): error TS1100: Invalid use of 'arguments' in strict mode. + + +==== tests/cases/compiler/alwaysStrictNoImplicitUseStrict.ts (1 errors) ==== + + module M { + export function f() { + var arguments = []; + ~~~~~~~~~ +!!! error TS1100: Invalid use of 'arguments' in strict mode. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/alwaysStrictNoImplicitUseStrict.js b/tests/baselines/reference/alwaysStrictNoImplicitUseStrict.js new file mode 100644 index 00000000000..cfa7f69629f --- /dev/null +++ b/tests/baselines/reference/alwaysStrictNoImplicitUseStrict.js @@ -0,0 +1,17 @@ +//// [alwaysStrictNoImplicitUseStrict.ts] + +module M { + export function f() { + var arguments = []; + } +} + +//// [alwaysStrictNoImplicitUseStrict.js] +"use strict"; +var M; +(function (M) { + function f() { + var arguments = []; + } + M.f = f; +})(M || (M = {})); diff --git a/tests/baselines/reference/transpile/Supports setting alwaysStrict.js b/tests/baselines/reference/transpile/Supports setting alwaysStrict.js new file mode 100644 index 00000000000..8d91090453b --- /dev/null +++ b/tests/baselines/reference/transpile/Supports setting alwaysStrict.js @@ -0,0 +1,3 @@ +"use strict"; +x; +//# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/cases/compiler/alwaysStrict.ts b/tests/cases/compiler/alwaysStrict.ts new file mode 100644 index 00000000000..22ec09c6e38 --- /dev/null +++ b/tests/cases/compiler/alwaysStrict.ts @@ -0,0 +1,5 @@ +// @alwaysStrict: true + +function f() { + var arguments = []; +} \ No newline at end of file diff --git a/tests/cases/compiler/alwaysStrictES6.ts b/tests/cases/compiler/alwaysStrictES6.ts new file mode 100644 index 00000000000..edb542fa86a --- /dev/null +++ b/tests/cases/compiler/alwaysStrictES6.ts @@ -0,0 +1,6 @@ +// @target: ES6 +// @alwaysStrict: true + +function f() { + var arguments = []; +} \ No newline at end of file diff --git a/tests/cases/compiler/alwaysStrictModule.ts b/tests/cases/compiler/alwaysStrictModule.ts new file mode 100644 index 00000000000..b706f5869a6 --- /dev/null +++ b/tests/cases/compiler/alwaysStrictModule.ts @@ -0,0 +1,8 @@ +// @module: commonjs +// @alwaysStrict: true + +module M { + export function f() { + var arguments = []; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/alwaysStrictNoImplicitUseStrict.ts b/tests/cases/compiler/alwaysStrictNoImplicitUseStrict.ts new file mode 100644 index 00000000000..d3173df8ab5 --- /dev/null +++ b/tests/cases/compiler/alwaysStrictNoImplicitUseStrict.ts @@ -0,0 +1,9 @@ +// @module: commonjs +// @alwaysStrict: true +// @noImplicitUseStrict: true + +module M { + export function f() { + var arguments = []; + } +} \ No newline at end of file From ea808f52fe3dd70dedc6294ebda26a4100767ad1 Mon Sep 17 00:00:00 2001 From: Slawomir Sadziak Date: Mon, 10 Oct 2016 12:15:34 +0200 Subject: [PATCH 039/173] Fix #10758 Add compiler option to parse in strict mode * add unit test to ensure "use strict" is not added twice * fix code --- src/compiler/factory.ts | 30 +++++++++++++++++++ src/compiler/transformers/ts.ts | 9 +----- .../reference/alwaysStrictAlreadyUseStrict.js | 11 +++++++ .../alwaysStrictAlreadyUseStrict.symbols | 8 +++++ .../alwaysStrictAlreadyUseStrict.types | 11 +++++++ .../compiler/alwaysStrictAlreadyUseStrict.ts | 5 ++++ 6 files changed, 66 insertions(+), 8 deletions(-) create mode 100644 tests/baselines/reference/alwaysStrictAlreadyUseStrict.js create mode 100644 tests/baselines/reference/alwaysStrictAlreadyUseStrict.symbols create mode 100644 tests/baselines/reference/alwaysStrictAlreadyUseStrict.types create mode 100644 tests/cases/compiler/alwaysStrictAlreadyUseStrict.ts diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 97a36f46b13..6bf6259c364 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -2235,6 +2235,36 @@ namespace ts { return statementOffset; } + /** + * Ensures "use strict" directive is added + * + * @param node source file + */ + export function ensureUseStrict(node: SourceFile): SourceFile { + let foundUseStrict = false; + let statementOffset = 0; + const numStatements = node.statements.length; + while (statementOffset < numStatements) { + const statement = node.statements[statementOffset]; + if (isPrologueDirective(statement)) { + if (isUseStrictPrologue(statement as ExpressionStatement)) { + foundUseStrict = true; + } + } + else { + break; + } + statementOffset++; + } + if (!foundUseStrict) { + const statements: Statement[] = []; + statements.push(startOnNewLine(createStatement(createLiteral("use strict")))); + // add "use strict" as the first statement + return updateSourceFileNode(node, statements.concat(node.statements)); + } + return node; + } + /** * Wraps the operand to a BinaryExpression in parentheses if they are needed to preserve the intended * order of operations. diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 7b6c28a8f41..112f838a370 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -438,7 +438,7 @@ namespace ts { // ensure "use strict"" is emitted in all scenarios in alwaysStrict mode if (compilerOptions.alwaysStrict) { - node = emitUseStrict(node); + node = ensureUseStrict(node); } // If the source file requires any helpers and is an external module, and @@ -477,13 +477,6 @@ namespace ts { return node; } - function emitUseStrict(node: SourceFile): SourceFile { - const statements: Statement[] = []; - statements.push(startOnNewLine(createStatement(createLiteral("use strict")))); - // add "use strict" as the first statement - return updateSourceFileNode(node, statements.concat(node.statements)); - } - /** * Tests whether we should emit a __decorate call for a class declaration. */ diff --git a/tests/baselines/reference/alwaysStrictAlreadyUseStrict.js b/tests/baselines/reference/alwaysStrictAlreadyUseStrict.js new file mode 100644 index 00000000000..cc3be45dedc --- /dev/null +++ b/tests/baselines/reference/alwaysStrictAlreadyUseStrict.js @@ -0,0 +1,11 @@ +//// [alwaysStrictAlreadyUseStrict.ts] +"use strict" +function f() { + var a = []; +} + +//// [alwaysStrictAlreadyUseStrict.js] +"use strict"; +function f() { + var a = []; +} diff --git a/tests/baselines/reference/alwaysStrictAlreadyUseStrict.symbols b/tests/baselines/reference/alwaysStrictAlreadyUseStrict.symbols new file mode 100644 index 00000000000..143f579b94d --- /dev/null +++ b/tests/baselines/reference/alwaysStrictAlreadyUseStrict.symbols @@ -0,0 +1,8 @@ +=== tests/cases/compiler/alwaysStrictAlreadyUseStrict.ts === +"use strict" +function f() { +>f : Symbol(f, Decl(alwaysStrictAlreadyUseStrict.ts, 0, 12)) + + var a = []; +>a : Symbol(a, Decl(alwaysStrictAlreadyUseStrict.ts, 2, 7)) +} diff --git a/tests/baselines/reference/alwaysStrictAlreadyUseStrict.types b/tests/baselines/reference/alwaysStrictAlreadyUseStrict.types new file mode 100644 index 00000000000..0181b40de27 --- /dev/null +++ b/tests/baselines/reference/alwaysStrictAlreadyUseStrict.types @@ -0,0 +1,11 @@ +=== tests/cases/compiler/alwaysStrictAlreadyUseStrict.ts === +"use strict" +>"use strict" : "use strict" + +function f() { +>f : () => void + + var a = []; +>a : any[] +>[] : undefined[] +} diff --git a/tests/cases/compiler/alwaysStrictAlreadyUseStrict.ts b/tests/cases/compiler/alwaysStrictAlreadyUseStrict.ts new file mode 100644 index 00000000000..1d804a6cf90 --- /dev/null +++ b/tests/cases/compiler/alwaysStrictAlreadyUseStrict.ts @@ -0,0 +1,5 @@ +// @alwaysStrict: true +"use strict" +function f() { + var a = []; +} \ No newline at end of file From 5ce22801a71571f52936fa16360a40f6870a025e Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Mon, 10 Oct 2016 11:11:06 -0700 Subject: [PATCH 040/173] Port fix from PR#11268 --- src/services/navigationBar.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index 5c8c47e9666..0397ae73229 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -324,7 +324,7 @@ namespace ts.NavigationBar { } // More efficient to create a collator once and use its `compare` than to call `a.localeCompare(b)` many times. - const collator: { compare(a: string, b: string): number } = typeof Intl === "undefined" ? undefined : new Intl.Collator(); + const collator: { compare(a: string, b: string): number } = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; // Intl is missing in Safari, and node 0.10 treats "a" as greater than "B". const localeCompareIsCorrect = collator && collator.compare("a", "B") < 0; const localeCompareFix: (a: string, b: string) => number = localeCompareIsCorrect ? collator.compare : function(a, b) { From 8210634e8dbc9a1bc41c108b21c19b4cfac4d91c Mon Sep 17 00:00:00 2001 From: Slawomir Sadziak Date: Mon, 10 Oct 2016 23:03:07 +0200 Subject: [PATCH 041/173] Fix #10758 Add compiler option to parse in strict mode * fix comment * optimize loop --- src/compiler/factory.ts | 7 ++----- src/compiler/transformers/ts.ts | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 6bf6259c364..5a95600d089 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -2242,19 +2242,16 @@ namespace ts { */ export function ensureUseStrict(node: SourceFile): SourceFile { let foundUseStrict = false; - let statementOffset = 0; - const numStatements = node.statements.length; - while (statementOffset < numStatements) { - const statement = node.statements[statementOffset]; + for (const statement of node.statements) { if (isPrologueDirective(statement)) { if (isUseStrictPrologue(statement as ExpressionStatement)) { foundUseStrict = true; + break; } } else { break; } - statementOffset++; } if (!foundUseStrict) { const statements: Statement[] = []; diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 112f838a370..2c146c91bc3 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -436,7 +436,7 @@ namespace ts { function visitSourceFile(node: SourceFile) { currentSourceFile = node; - // ensure "use strict"" is emitted in all scenarios in alwaysStrict mode + // ensure "use strict" is emitted in all scenarios in alwaysStrict mode if (compilerOptions.alwaysStrict) { node = ensureUseStrict(node); } From 997acaec7a08321019729fd5aff3bd6731e98211 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Mon, 10 Oct 2016 16:04:14 -0700 Subject: [PATCH 042/173] update documentation in protocol.d.ts (#11501) update documentation in protocol.d.ts --- src/server/protocol.d.ts | 292 ++++++++++++++++++++++++++++++++++++--- src/server/session.ts | 8 +- 2 files changed, 277 insertions(+), 23 deletions(-) diff --git a/src/server/protocol.d.ts b/src/server/protocol.d.ts index bad403deaf9..cd6f12453d1 100644 --- a/src/server/protocol.d.ts +++ b/src/server/protocol.d.ts @@ -98,19 +98,38 @@ declare namespace ts.server.protocol { projectFileName?: string; } + /** + * A request to get TODO comments from the file + */ export interface TodoCommentRequest extends FileRequest { arguments: TodoCommentRequestArgs; } + /** + * Arguments for TodoCommentRequest request. + */ export interface TodoCommentRequestArgs extends FileRequestArgs { + /** + * Array of target TodoCommentDescriptors that describes TODO comments to be found + */ descriptors: TodoCommentDescriptor[]; } + /** + * A request to get indentation for a location in file + */ export interface IndentationRequest extends FileLocationRequest { arguments: IndentationRequestArgs; } + /** + * Arguments for IndentationRequest request. + */ export interface IndentationRequestArgs extends FileLocationRequestArgs { + /** + * An optional set of settings to be used when computing indentation. + * If argument is omitted - then it will use settings for file that were previously set via 'configure' request or global settings. + */ options?: EditorSettings; } @@ -125,17 +144,26 @@ declare namespace ts.server.protocol { } /** - * A request to get the project information of the current file + * A request to get the project information of the current file. */ export interface ProjectInfoRequest extends Request { arguments: ProjectInfoRequestArgs; } - export interface ProjectRequest extends Request { - arguments: ProjectRequestArgs; + /** + * A request to retrieve compiler options diagnostics for a project + */ + export interface CompilerOptionsDiagnosticsRequest extends Request { + arguments: CompilerOptionsDiagnosticsRequestArgs; } - export interface ProjectRequestArgs { + /** + * Arguments for CompilerOptionsDiagnosticsRequest request. + */ + export interface CompilerOptionsDiagnosticsRequestArgs { + /** + * Name of the project to retrieve compiler options diagnostics. + */ projectFileName: string; } @@ -158,6 +186,11 @@ declare namespace ts.server.protocol { languageServiceDisabled?: boolean; } + /** + * Represents diagnostic info that includes location of diagnostic in two forms + * - start position and length of the error span + * - startLocation and endLocation - a pair of Location objects that store start/end line and offset of the error span. + */ export interface DiagnosticWithLinePosition { message: string; start: number; @@ -210,13 +243,25 @@ declare namespace ts.server.protocol { arguments: FileLocationRequestArgs; } - export interface FileSpanRequestArgs extends FileRequestArgs { - start: number; - length: number; + /** + * A request to get semantic diagnostics for a span in the file + */ + export interface SemanticDiagnosticsRequest extends FileRequest { + arguments: SemanticDiagnosticsRequestArgs; } - export interface FileSpanRequest extends FileRequest { - arguments: FileSpanRequestArgs; + /** + * Arguments for SemanticDiagnosticsRequest request. + */ + export interface SemanticDiagnosticsRequestArgs extends FileRequestArgs { + /** + * Start position of the span. + */ + start: number; + /** + * Length of the span. + */ + length: number; } /** @@ -308,11 +353,20 @@ declare namespace ts.server.protocol { body?: FileSpan[]; } + /** + * Request to get brace completion for a location in the file. + */ export interface BraceCompletionRequest extends FileLocationRequest { arguments: BraceCompletionRequestArgs; } + /** + * Argument for BraceCompletionRequest request. + */ export interface BraceCompletionRequestArgs extends FileLocationRequestArgs { + /** + * Kind of opening brace + */ openingBrace: string; } @@ -344,10 +398,17 @@ declare namespace ts.server.protocol { arguments: DocumentHighlightsRequestArgs; } + /** + * Span augmented with extra information that denotes the kind of the highlighting to be used for span. + * Kind is taken from HighlightSpanKind type. + */ export interface HighlightSpan extends TextSpan { kind: string; } + /** + * Represents a set of highligh spans for a give name + */ export interface DocumentHighlightsItem { /** * File containing highlight spans. @@ -360,6 +421,9 @@ declare namespace ts.server.protocol { highlightSpans: HighlightSpan[]; } + /** + * Response for a DocumentHighlightsRequest request. + */ export interface DocumentHighlightsResponse extends Response { body?: DocumentHighlightsItem[]; } @@ -423,12 +487,20 @@ declare namespace ts.server.protocol { body?: ReferencesResponseBody; } + /** + * Argument for RenameRequest request. + */ export interface RenameRequestArgs extends FileLocationRequestArgs { + /** + * Should text at specified location be found/changed in comments? + */ findInComments?: boolean; + /** + * Should text at specified location be found/changed in strings? + */ findInStrings?: boolean; } - /** * Rename request; value of command field is "rename". Return * response giving the file locations that reference the symbol @@ -503,17 +575,53 @@ declare namespace ts.server.protocol { body?: RenameResponseBody; } + /** + * Represents a file in external project. + * External project is project whose set of files, compilation options and open\close state + * is maintained by the client (i.e. if all this data come from .csproj file in Visual Studio). + * External project will exist even if all files in it are closed and should be closed explicity. + * If external project includes one or more tsconfig.json/jsconfig.json files then tsserver will + * create configured project for every config file but will maintain a link that these projects were created + * as a result of opening external project so they should be removed once external project is closed. + */ export interface ExternalFile { + /** + * Name of file file + */ fileName: string; + /** + * Script kind of the file + */ scriptKind?: ScriptKind; + /** + * Whether file has mixed content (i.e. .cshtml file that combines html markup with C#/JavaScript) + */ hasMixedContent?: boolean; + /** + * Content of the file + */ content?: string; } + /** + * Represent an external project + */ export interface ExternalProject { + /** + * Project name + */ projectFileName: string; + /** + * List of root files in project + */ rootFiles: ExternalFile[]; + /** + * Compiler options for the project + */ options: ExternalProjectCompilerOptions; + /** + * Explicitly specified typing options for the project + */ typingOptions?: TypingOptions; } @@ -522,18 +630,45 @@ declare namespace ts.server.protocol { * compiler settings. */ export interface ExternalProjectCompilerOptions extends CompilerOptions { + /** + * If compile on save is enabled for the project + */ compileOnSave?: boolean; } + /** + * Contains information about current project version + */ export interface ProjectVersionInfo { + /** + * Project name + */ projectName: string; + /** + * true if project is inferred or false if project is external or configured + */ isInferred: boolean; + /** + * Project version + */ version: number; + /** + * Current set of compiler options for project + */ options: CompilerOptions; } + /** + * Represents a set of changes that happen in project + */ export interface ProjectChanges { + /** + * List of added files + */ added: string[]; + /** + * List of removed files + */ removed: string[]; } @@ -545,17 +680,41 @@ declare namespace ts.server.protocol { * otherwise - assume that nothing is changed */ export interface ProjectFiles { + /** + * Information abount project verison + */ info?: ProjectVersionInfo; + /** + * List of files in project (might be omitted if current state of project can be computed using only information from 'changes') + */ files?: string[]; + /** + * Set of changes in project (omitted if the entire set of files in project should be replaced) + */ changes?: ProjectChanges; } + /** + * Combines project information with project level errors. + */ export interface ProjectFilesWithDiagnostics extends ProjectFiles { + /** + * List of errors in project + */ projectErrors: DiagnosticWithLinePosition[]; } + /** + * Represents set of changes in open file + */ export interface ChangedOpenFile { + /** + * Name of file + */ fileName: string; + /** + * List of changes that should be applied to known open file + */ changes: ts.TextChange[]; } @@ -689,54 +848,117 @@ declare namespace ts.server.protocol { arguments: OpenRequestArgs; } - type OpenExternalProjectArgs = ExternalProject; - + /** + * Request to open or update external project + */ export interface OpenExternalProjectRequest extends Request { arguments: OpenExternalProjectArgs; } - export interface CloseExternalProjectRequestArgs { - projectFileName: string; - } + /** + * Arguments to OpenExternalProjectRequest request + */ + type OpenExternalProjectArgs = ExternalProject; + /** + * Request to open multiple external projects + */ export interface OpenExternalProjectsRequest extends Request { arguments: OpenExternalProjectsArgs; } + /** + * Arguments to OpenExternalProjectsRequest + */ export interface OpenExternalProjectsArgs { + /** + * List of external projects to open or update + */ projects: ExternalProject[]; } + /** + * Request to close external project. + */ export interface CloseExternalProjectRequest extends Request { arguments: CloseExternalProjectRequestArgs; } + /** + * Arguments to CloseExternalProjectRequest request + */ + export interface CloseExternalProjectRequestArgs { + /** + * Name of the project to close + */ + projectFileName: string; + } + + /** + * Request to check if given list of projects is up-to-date and synchronize them if necessary + */ export interface SynchronizeProjectListRequest extends Request { arguments: SynchronizeProjectListRequestArgs; } + /** + * Arguments to SynchronizeProjectListRequest + */ export interface SynchronizeProjectListRequestArgs { + /** + * List of last known projects + */ knownProjects: protocol.ProjectVersionInfo[]; } + /** + * Request to synchronize list of open files with the client + */ export interface ApplyChangedToOpenFilesRequest extends Request { arguments: ApplyChangedToOpenFilesRequestArgs; } + /** + * Arguments to ApplyChangedToOpenFilesRequest + */ export interface ApplyChangedToOpenFilesRequestArgs { + /** + * List of newly open files + */ openFiles?: ExternalFile[]; + /** + * List of open files files that were changes + */ changedFiles?: ChangedOpenFile[]; + /** + * List of files that were closed + */ closedFiles?: string[]; } - export interface SetCompilerOptionsForInferredProjectsArgs { - options: ExternalProjectCompilerOptions; - } - + /** + * Request to set compiler options for inferred projects. + * External projects are opened / closed explicitly. + * Configured projects are opened when user opens loose file that has 'tsconfig.json' or 'jsconfig.json' anywhere in one of containing folders. + * This configuration file will be used to obtain a list of files and configuration settings for the project. + * Inferred projects are created when user opens a loose file that is not the part of external project + * or configured project and will contain only open file and transitive closure of referenced files if 'useOneInferredProject' is false, + * or all open loose files and its transitive closure of referenced files if 'useOneInferredProject' is true. + */ export interface SetCompilerOptionsForInferredProjectsRequest extends Request { arguments: SetCompilerOptionsForInferredProjectsArgs; } + /** + * Argument for SetCompilerOptionsForInferredProjectsRequest request. + */ + export interface SetCompilerOptionsForInferredProjectsArgs { + /** + * Compiler options to be used with inferred projects. + */ + options: ExternalProjectCompilerOptions; + } + /** * Exit request; value of command field is "exit". Ask the server process * to exit. @@ -754,23 +976,48 @@ declare namespace ts.server.protocol { export interface CloseRequest extends FileRequest { } + /** + * Request to obtain the list of files that should be regenerated if target file is recompiled. + * NOTE: this us query-only operation and does not generate any output on disk. + */ export interface CompileOnSaveAffectedFileListRequest extends FileRequest { } + /** + * Contains a list of files that should be regenerated in a project + */ export interface CompileOnSaveAffectedFileListSingleProject { + /** + * Project name + */ projectFileName: string; + /** + * List of files names that should be recompiled + */ fileNames: string[]; } + /** + * Response for CompileOnSaveAffectedFileListRequest request; + */ export interface CompileOnSaveAffectedFileListResponse extends Response { body: CompileOnSaveAffectedFileListSingleProject[]; } + /** + * Request to recompile the file. All generated outputs (.js, .d.ts or .js.map files) is written on disk. + */ export interface CompileOnSaveEmitFileRequest extends FileRequest { args: CompileOnSaveEmitFileRequestArgs; } + /** + * Arguments for CompileOnSaveEmitFileRequest + */ export interface CompileOnSaveEmitFileRequestArgs extends FileRequestArgs { + /** + * if true - then file should be recompiled even if it does not have any changes. + */ forced?: boolean; } @@ -839,7 +1086,14 @@ declare namespace ts.server.protocol { */ endOffset: number; + /** + * End position of the range for which to format text in file. + */ endPosition?: number; + + /** + * Format options to be used. + */ options?: ts.FormatCodeOptions; } diff --git a/src/server/session.ts b/src/server/session.ts index edb79e3a0ef..82ca7be0d16 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -342,7 +342,7 @@ namespace ts.server { } } - private getEncodedSemanticClassifications(args: protocol.FileSpanRequestArgs) { + private getEncodedSemanticClassifications(args: protocol.SemanticDiagnosticsRequestArgs) { const { file, project } = this.getFileAndProject(args); return project.getLanguageService().getEncodedSemanticClassifications(file, args); } @@ -351,7 +351,7 @@ namespace ts.server { return projectFileName && this.projectService.findProject(projectFileName); } - private getCompilerOptionsDiagnostics(args: protocol.ProjectRequestArgs) { + private getCompilerOptionsDiagnostics(args: protocol.CompilerOptionsDiagnosticsRequestArgs) { const project = this.getProject(args.projectFileName); return this.convertToDiagnosticsWithLinePosition(project.getLanguageService().getCompilerOptionsDiagnostics(), /*scriptInfo*/ undefined); } @@ -1438,10 +1438,10 @@ namespace ts.server { [CommandNames.SignatureHelpFull]: (request: protocol.SignatureHelpRequest) => { return this.requiredResponse(this.getSignatureHelpItems(request.arguments, /*simplifiedResult*/ false)); }, - [CommandNames.CompilerOptionsDiagnosticsFull]: (request: protocol.ProjectRequest) => { + [CommandNames.CompilerOptionsDiagnosticsFull]: (request: protocol.CompilerOptionsDiagnosticsRequest) => { return this.requiredResponse(this.getCompilerOptionsDiagnostics(request.arguments)); }, - [CommandNames.EncodedSemanticClassificationsFull]: (request: protocol.FileSpanRequest) => { + [CommandNames.EncodedSemanticClassificationsFull]: (request: protocol.SemanticDiagnosticsRequest) => { return this.requiredResponse(this.getEncodedSemanticClassifications(request.arguments)); }, [CommandNames.Cleanup]: (request: protocol.Request) => { From 3b0515fd8b8742d1c25c70642e853a9ed4e324c7 Mon Sep 17 00:00:00 2001 From: Zhengbo Li Date: Mon, 10 Oct 2016 16:38:08 -0700 Subject: [PATCH 043/173] Send config file diagnonstics event even when no errors were found (#11285) * emit config diagnostics event when no errors found * Add tests for project service events --- .../unittests/tsserverProjectSystem.ts | 63 ++++++++++++++++++- src/server/editorServices.ts | 12 ++-- src/server/session.ts | 20 +++--- 3 files changed, 80 insertions(+), 15 deletions(-) diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index 9f0d6ae6a17..f2decc1c339 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -1,4 +1,4 @@ -/// +/// /// namespace ts.projectSystem { @@ -136,6 +136,19 @@ namespace ts.projectSystem { return map(fileNames, toExternalFile); } + export class TestServerEventManager { + private events: server.ProjectServiceEvent[] = []; + + handler: server.ProjectServiceEventHandler = (event: server.ProjectServiceEvent) => { + this.events.push(event); + } + + checkEventCountOfType(eventType: "context" | "configFileDiag", expectedCount: number) { + const eventsOfType = filter(this.events, e => e.eventName === eventType); + assert.equal(eventsOfType.length, expectedCount, `The actual event counts of type ${eventType} is ${eventsOfType.length}, while expected ${expectedCount}`); + } + } + export interface TestServerHostCreationParameters { useCaseSensitiveFileNames?: boolean; executingFilePath?: string; @@ -159,11 +172,11 @@ namespace ts.projectSystem { return host; } - export function createSession(host: server.ServerHost, typingsInstaller?: server.ITypingsInstaller) { + export function createSession(host: server.ServerHost, typingsInstaller?: server.ITypingsInstaller, projectServiceEventHandler?: server.ProjectServiceEventHandler) { if (typingsInstaller === undefined) { typingsInstaller = new TestTypingsInstaller("/a/data/", /*throttleLimit*/5, host); } - return new server.Session(host, nullCancellationToken, /*useSingleInferredProject*/ false, typingsInstaller, Utils.byteLength, process.hrtime, nullLogger, /*canUseEvents*/ false); + return new server.Session(host, nullCancellationToken, /*useSingleInferredProject*/ false, typingsInstaller, Utils.byteLength, process.hrtime, nullLogger, /*canUseEvents*/ projectServiceEventHandler !== undefined, projectServiceEventHandler); } export interface CreateProjectServiceParameters { @@ -2121,4 +2134,48 @@ namespace ts.projectSystem { projectService.inferredProjects[0].getLanguageService().getProgram(); }); }); + + describe("Configure file diagnostics events", () => { + + it("are generated when the config file has errors", () => { + const serverEventManager = new TestServerEventManager(); + const file = { + path: "/a/b/app.ts", + content: "let x = 10" + }; + const configFile = { + path: "/a/b/tsconfig.json", + content: `{ + "compilerOptions": { + "foo": "bar", + "allowJS": true + } + }` + }; + + const host = createServerHost([file, configFile]); + const session = createSession(host, /*typingsInstaller*/ undefined, serverEventManager.handler); + openFilesForSession([file], session); + serverEventManager.checkEventCountOfType("configFileDiag", 1); + }); + + it("are generated when the config file doesn't have errors", () => { + const serverEventManager = new TestServerEventManager(); + const file = { + path: "/a/b/app.ts", + content: "let x = 10" + }; + const configFile = { + path: "/a/b/tsconfig.json", + content: `{ + "compilerOptions": {} + }` + }; + + const host = createServerHost([file, configFile]); + const session = createSession(host, /*typingsInstaller*/ undefined, serverEventManager.handler); + openFilesForSession([file], session); + serverEventManager.checkEventCountOfType("configFileDiag", 1); + }); + }); } \ No newline at end of file diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 51310c90a6b..50dd5612da8 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -755,12 +755,14 @@ namespace ts.server { } private reportConfigFileDiagnostics(configFileName: string, diagnostics: Diagnostic[], triggerFile?: string) { - if (diagnostics && diagnostics.length > 0) { - this.eventHandler({ - eventName: "configFileDiag", - data: { configFileName, diagnostics, triggerFile } - }); + if (!this.eventHandler) { + return; } + + this.eventHandler({ + eventName: "configFileDiag", + data: { configFileName, diagnostics: diagnostics || [], triggerFile } + }); } private createAndAddConfiguredProject(configFileName: NormalizedPath, projectOptions: ProjectOptions, configFileErrors: Diagnostic[], clientFileName?: string) { diff --git a/src/server/session.ts b/src/server/session.ts index 82ca7be0d16..3b95bdd6fb9 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -155,6 +155,8 @@ namespace ts.server { private immediateId: any; private changeSeq = 0; + private eventHander: ProjectServiceEventHandler; + constructor( private host: ServerHost, cancellationToken: HostCancellationToken, @@ -163,17 +165,18 @@ namespace ts.server { private byteLength: (buf: string, encoding?: string) => number, private hrtime: (start?: number[]) => number[], protected logger: Logger, - protected readonly canUseEvents: boolean) { + protected readonly canUseEvents: boolean, + eventHandler?: ProjectServiceEventHandler) { - const eventHandler: ProjectServiceEventHandler = canUseEvents - ? event => this.handleEvent(event) + this.eventHander = canUseEvents + ? eventHandler || (event => this.defaultEventHandler(event)) : undefined; - this.projectService = new ProjectService(host, logger, cancellationToken, useSingleInferredProject, typingsInstaller, eventHandler); + this.projectService = new ProjectService(host, logger, cancellationToken, useSingleInferredProject, typingsInstaller, this.eventHander); this.gcTimer = new GcTimer(host, /*delay*/ 7000, logger); } - private handleEvent(event: ProjectServiceEvent) { + private defaultEventHandler(event: ProjectServiceEvent) { switch (event.eventName) { case "context": const { project, fileName } = event.data; @@ -734,8 +737,11 @@ namespace ts.server { */ private openClientFile(fileName: NormalizedPath, fileContent?: string, scriptKind?: ScriptKind) { const { configFileName, configFileErrors } = this.projectService.openClientFileWithNormalizedPath(fileName, fileContent, scriptKind); - if (configFileErrors) { - this.configFileDiagnosticEvent(fileName, configFileName, configFileErrors); + if (this.eventHander) { + this.eventHander({ + eventName: "configFileDiag", + data: { fileName, configFileName, diagnostics: configFileErrors || [] } + }); } } From 49fd35da33cf3de26199c8183581124974423f50 Mon Sep 17 00:00:00 2001 From: Bill Ticehurst Date: Mon, 10 Oct 2016 22:40:03 -0700 Subject: [PATCH 044/173] Resolve export= module members --- src/compiler/checker.ts | 4 + .../reference/bluebirdStaticThis.errors.txt | 188 +++++++++++++++++- 2 files changed, 191 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index dfe6317e250..b5fe19b0a80 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1465,6 +1465,10 @@ namespace ts { function getExportsForModule(moduleSymbol: Symbol): SymbolTable { const visitedSymbols: Symbol[] = []; + + // A module defined by an 'export=' consists on one export that needs to be resolved + moduleSymbol = resolveExternalModuleSymbol(moduleSymbol); + return visit(moduleSymbol) || moduleSymbol.exports; // The ES6 spec permits export * declarations in a module to circularly reference the module itself. For example, diff --git a/tests/baselines/reference/bluebirdStaticThis.errors.txt b/tests/baselines/reference/bluebirdStaticThis.errors.txt index 1c22a12c341..a20c7ace880 100644 --- a/tests/baselines/reference/bluebirdStaticThis.errors.txt +++ b/tests/baselines/reference/bluebirdStaticThis.errors.txt @@ -1,13 +1,75 @@ tests/cases/compiler/bluebirdStaticThis.ts(5,15): error TS2420: Class 'Promise' incorrectly implements interface 'Thenable'. Property 'then' is missing in type 'Promise'. +tests/cases/compiler/bluebirdStaticThis.ts(7,12): error TS2323: Cannot redeclare exported variable 'try'. +tests/cases/compiler/bluebirdStaticThis.ts(8,12): error TS2323: Cannot redeclare exported variable 'try'. +tests/cases/compiler/bluebirdStaticThis.ts(10,12): error TS2323: Cannot redeclare exported variable 'attempt'. +tests/cases/compiler/bluebirdStaticThis.ts(11,12): error TS2323: Cannot redeclare exported variable 'attempt'. +tests/cases/compiler/bluebirdStaticThis.ts(15,12): error TS2323: Cannot redeclare exported variable 'resolve'. +tests/cases/compiler/bluebirdStaticThis.ts(16,12): error TS2323: Cannot redeclare exported variable 'resolve'. +tests/cases/compiler/bluebirdStaticThis.ts(17,12): error TS2323: Cannot redeclare exported variable 'resolve'. +tests/cases/compiler/bluebirdStaticThis.ts(19,12): error TS2323: Cannot redeclare exported variable 'reject'. +tests/cases/compiler/bluebirdStaticThis.ts(20,12): error TS2323: Cannot redeclare exported variable 'reject'. tests/cases/compiler/bluebirdStaticThis.ts(22,51): error TS2694: Namespace 'Promise' has no exported member 'Resolver'. +tests/cases/compiler/bluebirdStaticThis.ts(24,12): error TS2323: Cannot redeclare exported variable 'cast'. +tests/cases/compiler/bluebirdStaticThis.ts(25,12): error TS2323: Cannot redeclare exported variable 'cast'. +tests/cases/compiler/bluebirdStaticThis.ts(33,12): error TS2323: Cannot redeclare exported variable 'delay'. +tests/cases/compiler/bluebirdStaticThis.ts(34,12): error TS2323: Cannot redeclare exported variable 'delay'. +tests/cases/compiler/bluebirdStaticThis.ts(35,12): error TS2323: Cannot redeclare exported variable 'delay'. +tests/cases/compiler/bluebirdStaticThis.ts(49,12): error TS2323: Cannot redeclare exported variable 'all'. +tests/cases/compiler/bluebirdStaticThis.ts(50,12): error TS2323: Cannot redeclare exported variable 'all'. +tests/cases/compiler/bluebirdStaticThis.ts(51,12): error TS2323: Cannot redeclare exported variable 'all'. +tests/cases/compiler/bluebirdStaticThis.ts(52,12): error TS2323: Cannot redeclare exported variable 'all'. +tests/cases/compiler/bluebirdStaticThis.ts(54,12): error TS2323: Cannot redeclare exported variable 'props'. +tests/cases/compiler/bluebirdStaticThis.ts(55,12): error TS2323: Cannot redeclare exported variable 'props'. +tests/cases/compiler/bluebirdStaticThis.ts(57,12): error TS2323: Cannot redeclare exported variable 'settle'. tests/cases/compiler/bluebirdStaticThis.ts(57,109): error TS2694: Namespace 'Promise' has no exported member 'Inspection'. +tests/cases/compiler/bluebirdStaticThis.ts(58,12): error TS2323: Cannot redeclare exported variable 'settle'. tests/cases/compiler/bluebirdStaticThis.ts(58,91): error TS2694: Namespace 'Promise' has no exported member 'Inspection'. +tests/cases/compiler/bluebirdStaticThis.ts(59,12): error TS2323: Cannot redeclare exported variable 'settle'. tests/cases/compiler/bluebirdStaticThis.ts(59,91): error TS2694: Namespace 'Promise' has no exported member 'Inspection'. +tests/cases/compiler/bluebirdStaticThis.ts(60,12): error TS2323: Cannot redeclare exported variable 'settle'. tests/cases/compiler/bluebirdStaticThis.ts(60,73): error TS2694: Namespace 'Promise' has no exported member 'Inspection'. +tests/cases/compiler/bluebirdStaticThis.ts(62,12): error TS2323: Cannot redeclare exported variable 'any'. +tests/cases/compiler/bluebirdStaticThis.ts(63,12): error TS2323: Cannot redeclare exported variable 'any'. +tests/cases/compiler/bluebirdStaticThis.ts(64,12): error TS2323: Cannot redeclare exported variable 'any'. +tests/cases/compiler/bluebirdStaticThis.ts(65,12): error TS2323: Cannot redeclare exported variable 'any'. +tests/cases/compiler/bluebirdStaticThis.ts(67,12): error TS2323: Cannot redeclare exported variable 'race'. +tests/cases/compiler/bluebirdStaticThis.ts(68,12): error TS2323: Cannot redeclare exported variable 'race'. +tests/cases/compiler/bluebirdStaticThis.ts(69,12): error TS2323: Cannot redeclare exported variable 'race'. +tests/cases/compiler/bluebirdStaticThis.ts(70,12): error TS2323: Cannot redeclare exported variable 'race'. +tests/cases/compiler/bluebirdStaticThis.ts(72,12): error TS2323: Cannot redeclare exported variable 'some'. +tests/cases/compiler/bluebirdStaticThis.ts(73,12): error TS2323: Cannot redeclare exported variable 'some'. +tests/cases/compiler/bluebirdStaticThis.ts(74,12): error TS2323: Cannot redeclare exported variable 'some'. +tests/cases/compiler/bluebirdStaticThis.ts(75,12): error TS2323: Cannot redeclare exported variable 'some'. +tests/cases/compiler/bluebirdStaticThis.ts(77,12): error TS2323: Cannot redeclare exported variable 'join'. +tests/cases/compiler/bluebirdStaticThis.ts(78,12): error TS2323: Cannot redeclare exported variable 'join'. +tests/cases/compiler/bluebirdStaticThis.ts(80,12): error TS2323: Cannot redeclare exported variable 'map'. +tests/cases/compiler/bluebirdStaticThis.ts(81,12): error TS2323: Cannot redeclare exported variable 'map'. +tests/cases/compiler/bluebirdStaticThis.ts(82,12): error TS2323: Cannot redeclare exported variable 'map'. +tests/cases/compiler/bluebirdStaticThis.ts(83,12): error TS2323: Cannot redeclare exported variable 'map'. +tests/cases/compiler/bluebirdStaticThis.ts(84,12): error TS2323: Cannot redeclare exported variable 'map'. +tests/cases/compiler/bluebirdStaticThis.ts(85,12): error TS2323: Cannot redeclare exported variable 'map'. +tests/cases/compiler/bluebirdStaticThis.ts(86,12): error TS2323: Cannot redeclare exported variable 'map'. +tests/cases/compiler/bluebirdStaticThis.ts(87,12): error TS2323: Cannot redeclare exported variable 'map'. +tests/cases/compiler/bluebirdStaticThis.ts(89,12): error TS2323: Cannot redeclare exported variable 'reduce'. +tests/cases/compiler/bluebirdStaticThis.ts(90,12): error TS2323: Cannot redeclare exported variable 'reduce'. +tests/cases/compiler/bluebirdStaticThis.ts(92,12): error TS2323: Cannot redeclare exported variable 'reduce'. +tests/cases/compiler/bluebirdStaticThis.ts(93,12): error TS2323: Cannot redeclare exported variable 'reduce'. +tests/cases/compiler/bluebirdStaticThis.ts(95,12): error TS2323: Cannot redeclare exported variable 'reduce'. +tests/cases/compiler/bluebirdStaticThis.ts(96,12): error TS2323: Cannot redeclare exported variable 'reduce'. +tests/cases/compiler/bluebirdStaticThis.ts(98,12): error TS2323: Cannot redeclare exported variable 'reduce'. +tests/cases/compiler/bluebirdStaticThis.ts(99,12): error TS2323: Cannot redeclare exported variable 'reduce'. +tests/cases/compiler/bluebirdStaticThis.ts(101,12): error TS2323: Cannot redeclare exported variable 'filter'. +tests/cases/compiler/bluebirdStaticThis.ts(102,12): error TS2323: Cannot redeclare exported variable 'filter'. +tests/cases/compiler/bluebirdStaticThis.ts(103,12): error TS2323: Cannot redeclare exported variable 'filter'. +tests/cases/compiler/bluebirdStaticThis.ts(104,12): error TS2323: Cannot redeclare exported variable 'filter'. +tests/cases/compiler/bluebirdStaticThis.ts(105,12): error TS2323: Cannot redeclare exported variable 'filter'. +tests/cases/compiler/bluebirdStaticThis.ts(106,12): error TS2323: Cannot redeclare exported variable 'filter'. +tests/cases/compiler/bluebirdStaticThis.ts(107,12): error TS2323: Cannot redeclare exported variable 'filter'. +tests/cases/compiler/bluebirdStaticThis.ts(108,12): error TS2323: Cannot redeclare exported variable 'filter'. -==== tests/cases/compiler/bluebirdStaticThis.ts (6 errors) ==== +==== tests/cases/compiler/bluebirdStaticThis.ts (68 errors) ==== // This version is reduced from the full d.ts by removing almost all the tests // and all the comments. // Then it adds explicit `this` arguments to the static members. @@ -18,26 +80,48 @@ tests/cases/compiler/bluebirdStaticThis.ts(60,73): error TS2694: Namespace 'Prom !!! error TS2420: Property 'then' is missing in type 'Promise'. constructor(callback: (resolve: (thenableOrResult: R | Promise.Thenable) => void, reject: (error: any) => void) => void); static try(dit: typeof Promise, fn: () => Promise.Thenable, args?: any[], ctx?: any): Promise; + ~~~ +!!! error TS2323: Cannot redeclare exported variable 'try'. static try(dit: typeof Promise, fn: () => R, args?: any[], ctx?: any): Promise; + ~~~ +!!! error TS2323: Cannot redeclare exported variable 'try'. static attempt(dit: typeof Promise, fn: () => Promise.Thenable, args?: any[], ctx?: any): Promise; + ~~~~~~~ +!!! error TS2323: Cannot redeclare exported variable 'attempt'. static attempt(dit: typeof Promise, fn: () => R, args?: any[], ctx?: any): Promise; + ~~~~~~~ +!!! error TS2323: Cannot redeclare exported variable 'attempt'. static method(dit: typeof Promise, fn: Function): Function; static resolve(dit: typeof Promise): Promise; + ~~~~~~~ +!!! error TS2323: Cannot redeclare exported variable 'resolve'. static resolve(dit: typeof Promise, value: Promise.Thenable): Promise; + ~~~~~~~ +!!! error TS2323: Cannot redeclare exported variable 'resolve'. static resolve(dit: typeof Promise, value: R): Promise; + ~~~~~~~ +!!! error TS2323: Cannot redeclare exported variable 'resolve'. static reject(dit: typeof Promise, reason: any): Promise; + ~~~~~~ +!!! error TS2323: Cannot redeclare exported variable 'reject'. static reject(dit: typeof Promise, reason: any): Promise; + ~~~~~~ +!!! error TS2323: Cannot redeclare exported variable 'reject'. static defer(dit: typeof Promise): Promise.Resolver; ~~~~~~~~ !!! error TS2694: Namespace 'Promise' has no exported member 'Resolver'. static cast(dit: typeof Promise, value: Promise.Thenable): Promise; + ~~~~ +!!! error TS2323: Cannot redeclare exported variable 'cast'. static cast(dit: typeof Promise, value: R): Promise; + ~~~~ +!!! error TS2323: Cannot redeclare exported variable 'cast'. static bind(dit: typeof Promise, thisArg: any): Promise; @@ -46,8 +130,14 @@ tests/cases/compiler/bluebirdStaticThis.ts(60,73): error TS2694: Namespace 'Prom static longStackTraces(dit: typeof Promise): void; static delay(dit: typeof Promise, value: Promise.Thenable, ms: number): Promise; + ~~~~~ +!!! error TS2323: Cannot redeclare exported variable 'delay'. static delay(dit: typeof Promise, value: R, ms: number): Promise; + ~~~~~ +!!! error TS2323: Cannot redeclare exported variable 'delay'. static delay(dit: typeof Promise, ms: number): Promise; + ~~~~~ +!!! error TS2323: Cannot redeclare exported variable 'delay'. static promisify(dit: typeof Promise, nodeFunction: Function, receiver?: any): Function; @@ -62,73 +152,169 @@ tests/cases/compiler/bluebirdStaticThis.ts(60,73): error TS2694: Namespace 'Prom static onPossiblyUnhandledRejection(dit: typeof Promise, handler: (reason: any) => any): void; static all(dit: typeof Promise, values: Promise.Thenable[]>): Promise; + ~~~ +!!! error TS2323: Cannot redeclare exported variable 'all'. static all(dit: typeof Promise, values: Promise.Thenable): Promise; + ~~~ +!!! error TS2323: Cannot redeclare exported variable 'all'. static all(dit: typeof Promise, values: Promise.Thenable[]): Promise; + ~~~ +!!! error TS2323: Cannot redeclare exported variable 'all'. static all(dit: typeof Promise, values: R[]): Promise; + ~~~ +!!! error TS2323: Cannot redeclare exported variable 'all'. static props(dit: typeof Promise, object: Promise): Promise; + ~~~~~ +!!! error TS2323: Cannot redeclare exported variable 'props'. static props(dit: typeof Promise, object: Object): Promise; + ~~~~~ +!!! error TS2323: Cannot redeclare exported variable 'props'. static settle(dit: typeof Promise, values: Promise.Thenable[]>): Promise[]>; + ~~~~~~ +!!! error TS2323: Cannot redeclare exported variable 'settle'. ~~~~~~~~~~ !!! error TS2694: Namespace 'Promise' has no exported member 'Inspection'. static settle(dit: typeof Promise, values: Promise.Thenable): Promise[]>; + ~~~~~~ +!!! error TS2323: Cannot redeclare exported variable 'settle'. ~~~~~~~~~~ !!! error TS2694: Namespace 'Promise' has no exported member 'Inspection'. static settle(dit: typeof Promise, values: Promise.Thenable[]): Promise[]>; + ~~~~~~ +!!! error TS2323: Cannot redeclare exported variable 'settle'. ~~~~~~~~~~ !!! error TS2694: Namespace 'Promise' has no exported member 'Inspection'. static settle(dit: typeof Promise, values: R[]): Promise[]>; + ~~~~~~ +!!! error TS2323: Cannot redeclare exported variable 'settle'. ~~~~~~~~~~ !!! error TS2694: Namespace 'Promise' has no exported member 'Inspection'. static any(dit: typeof Promise, values: Promise.Thenable[]>): Promise; + ~~~ +!!! error TS2323: Cannot redeclare exported variable 'any'. static any(dit: typeof Promise, values: Promise.Thenable): Promise; + ~~~ +!!! error TS2323: Cannot redeclare exported variable 'any'. static any(dit: typeof Promise, values: Promise.Thenable[]): Promise; + ~~~ +!!! error TS2323: Cannot redeclare exported variable 'any'. static any(dit: typeof Promise, values: R[]): Promise; + ~~~ +!!! error TS2323: Cannot redeclare exported variable 'any'. static race(dit: typeof Promise, values: Promise.Thenable[]>): Promise; + ~~~~ +!!! error TS2323: Cannot redeclare exported variable 'race'. static race(dit: typeof Promise, values: Promise.Thenable): Promise; + ~~~~ +!!! error TS2323: Cannot redeclare exported variable 'race'. static race(dit: typeof Promise, values: Promise.Thenable[]): Promise; + ~~~~ +!!! error TS2323: Cannot redeclare exported variable 'race'. static race(dit: typeof Promise, values: R[]): Promise; + ~~~~ +!!! error TS2323: Cannot redeclare exported variable 'race'. static some(dit: typeof Promise, values: Promise.Thenable[]>, count: number): Promise; + ~~~~ +!!! error TS2323: Cannot redeclare exported variable 'some'. static some(dit: typeof Promise, values: Promise.Thenable, count: number): Promise; + ~~~~ +!!! error TS2323: Cannot redeclare exported variable 'some'. static some(dit: typeof Promise, values: Promise.Thenable[], count: number): Promise; + ~~~~ +!!! error TS2323: Cannot redeclare exported variable 'some'. static some(dit: typeof Promise, values: R[], count: number): Promise; + ~~~~ +!!! error TS2323: Cannot redeclare exported variable 'some'. static join(dit: typeof Promise, ...values: Promise.Thenable[]): Promise; + ~~~~ +!!! error TS2323: Cannot redeclare exported variable 'join'. static join(dit: typeof Promise, ...values: R[]): Promise; + ~~~~ +!!! error TS2323: Cannot redeclare exported variable 'join'. static map(dit: typeof Promise, values: Promise.Thenable[]>, mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; + ~~~ +!!! error TS2323: Cannot redeclare exported variable 'map'. static map(dit: typeof Promise, values: Promise.Thenable[]>, mapper: (item: R, index: number, arrayLength: number) => U): Promise; + ~~~ +!!! error TS2323: Cannot redeclare exported variable 'map'. static map(dit: typeof Promise, values: Promise.Thenable, mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; + ~~~ +!!! error TS2323: Cannot redeclare exported variable 'map'. static map(dit: typeof Promise, values: Promise.Thenable, mapper: (item: R, index: number, arrayLength: number) => U): Promise; + ~~~ +!!! error TS2323: Cannot redeclare exported variable 'map'. static map(dit: typeof Promise, values: Promise.Thenable[], mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; + ~~~ +!!! error TS2323: Cannot redeclare exported variable 'map'. static map(dit: typeof Promise, values: Promise.Thenable[], mapper: (item: R, index: number, arrayLength: number) => U): Promise; + ~~~ +!!! error TS2323: Cannot redeclare exported variable 'map'. static map(dit: typeof Promise, values: R[], mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; + ~~~ +!!! error TS2323: Cannot redeclare exported variable 'map'. static map(dit: typeof Promise, values: R[], mapper: (item: R, index: number, arrayLength: number) => U): Promise; + ~~~ +!!! error TS2323: Cannot redeclare exported variable 'map'. static reduce(dit: typeof Promise, values: Promise.Thenable[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; + ~~~~~~ +!!! error TS2323: Cannot redeclare exported variable 'reduce'. static reduce(dit: typeof Promise, values: Promise.Thenable[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; + ~~~~~~ +!!! error TS2323: Cannot redeclare exported variable 'reduce'. static reduce(dit: typeof Promise, values: Promise.Thenable, reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; + ~~~~~~ +!!! error TS2323: Cannot redeclare exported variable 'reduce'. static reduce(dit: typeof Promise, values: Promise.Thenable, reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; + ~~~~~~ +!!! error TS2323: Cannot redeclare exported variable 'reduce'. static reduce(dit: typeof Promise, values: Promise.Thenable[], reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; + ~~~~~~ +!!! error TS2323: Cannot redeclare exported variable 'reduce'. static reduce(dit: typeof Promise, values: Promise.Thenable[], reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; + ~~~~~~ +!!! error TS2323: Cannot redeclare exported variable 'reduce'. static reduce(dit: typeof Promise, values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; + ~~~~~~ +!!! error TS2323: Cannot redeclare exported variable 'reduce'. static reduce(dit: typeof Promise, values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; + ~~~~~~ +!!! error TS2323: Cannot redeclare exported variable 'reduce'. static filter(dit: typeof Promise, values: Promise.Thenable[]>, filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; + ~~~~~~ +!!! error TS2323: Cannot redeclare exported variable 'filter'. static filter(dit: typeof Promise, values: Promise.Thenable[]>, filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; + ~~~~~~ +!!! error TS2323: Cannot redeclare exported variable 'filter'. static filter(dit: typeof Promise, values: Promise.Thenable, filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; + ~~~~~~ +!!! error TS2323: Cannot redeclare exported variable 'filter'. static filter(dit: typeof Promise, values: Promise.Thenable, filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; + ~~~~~~ +!!! error TS2323: Cannot redeclare exported variable 'filter'. static filter(dit: typeof Promise, values: Promise.Thenable[], filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; + ~~~~~~ +!!! error TS2323: Cannot redeclare exported variable 'filter'. static filter(dit: typeof Promise, values: Promise.Thenable[], filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; + ~~~~~~ +!!! error TS2323: Cannot redeclare exported variable 'filter'. static filter(dit: typeof Promise, values: R[], filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; + ~~~~~~ +!!! error TS2323: Cannot redeclare exported variable 'filter'. static filter(dit: typeof Promise, values: R[], filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; + ~~~~~~ +!!! error TS2323: Cannot redeclare exported variable 'filter'. } declare module Promise { From 9385b84c624d3c632b20850198f2d4ed94958673 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 11 Oct 2016 07:48:28 -0700 Subject: [PATCH 045/173] Add "navtree" and "navtree-full" server commands --- src/harness/fourslash.ts | 16 +++ src/harness/harnessLanguageService.ts | 4 + src/server/client.ts | 37 ++++-- src/server/protocol.d.ts | 32 +++++- src/server/scriptInfo.ts | 2 +- src/server/session.ts | 93 ++++++++------- src/server/utilities.ts | 85 +++++++------- src/services/navigationBar.ts | 31 +++-- src/services/services.ts | 7 +- src/services/shims.ts | 10 ++ src/services/types.ts | 27 +++++ .../fourslash/deleteClassWithEnumPresent.ts | 26 +++++ tests/cases/fourslash/fourslash.ts | 1 + .../cases/fourslash/getNavigationBarItems.ts | 23 +++- tests/cases/fourslash/navbar_const.ts | 11 ++ .../navbar_contains-no-duplicates.ts | 77 +++++++++++++ tests/cases/fourslash/navbar_exportDefault.ts | 44 +++++++ tests/cases/fourslash/navbar_let.ts | 11 ++ ...BarAnonymousClassAndFunctionExpressions.ts | 79 +++++++++++++ ...arAnonymousClassAndFunctionExpressions2.ts | 33 ++++++ ...FunctionIndirectlyInVariableDeclaration.ts | 87 +++++++++----- .../fourslash/navigationBarGetterAndSetter.ts | 27 +++++ tests/cases/fourslash/navigationBarImports.ts | 23 ++++ .../navigationBarItemsBindingPatterns.ts | 51 +++++++++ ...ionBarItemsBindingPatternsInConstructor.ts | 35 ++++++ .../navigationBarItemsEmptyConstructors.ts | 17 +++ .../fourslash/navigationBarItemsExports.ts | 20 ++++ .../fourslash/navigationBarItemsFunctions.ts | 47 ++++++++ .../navigationBarItemsFunctionsBroken.ts | 17 +++ .../navigationBarItemsFunctionsBroken2.ts | 21 ++++ .../fourslash/navigationBarItemsImports.ts | 38 ++++++ ...ionBarItemsInsideMethodsAndConstructors.ts | 71 ++++++++++++ .../fourslash/navigationBarItemsItems.ts | 108 ++++++++++++++++++ .../fourslash/navigationBarItemsItems2.ts | 16 +++ .../navigationBarItemsItemsExternalModules.ts | 19 +++ ...navigationBarItemsItemsExternalModules2.ts | 24 ++++ ...navigationBarItemsItemsExternalModules3.ts | 24 ++++ .../navigationBarItemsItemsModuleVariables.ts | 34 ++++++ .../navigationBarItemsMissingName1.ts | 22 ++++ .../navigationBarItemsMissingName2.ts | 17 +++ .../fourslash/navigationBarItemsModules.ts | 67 +++++++++++ ...ationBarItemsMultilineStringIdentifiers.ts | 50 ++++++++ ...BarItemsPropertiesDefinedInConstructors.ts | 37 ++++++ .../fourslash/navigationBarItemsSymbols1.ts | 25 ++++ .../fourslash/navigationBarItemsSymbols2.ts | 21 ++++ .../fourslash/navigationBarItemsSymbols3.ts | 11 ++ .../fourslash/navigationBarItemsTypeAlias.ts | 11 ++ tests/cases/fourslash/navigationBarJsDoc.ts | 19 +++ .../navigationBarJsDocCommentWithNoTags.ts | 12 ++ tests/cases/fourslash/navigationBarMerging.ts | 105 +++++++++++++++++ .../navigationBarNamespaceImportWithNoName.ts | 12 ++ .../cases/fourslash/navigationBarVariables.ts | 39 +++++++ .../server/jsdocTypedefTagNavigateTo.ts | 23 ++++ tests/cases/fourslash/server/navbar01.ts | 108 ++++++++++++++++++ .../shims-pp/getNavigationBarItems.ts | 11 ++ .../fourslash/shims/getNavigationBarItems.ts | 11 ++ 56 files changed, 1787 insertions(+), 142 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 49f834963ee..ca40240b2b0 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -2211,6 +2211,18 @@ namespace FourSlash { } } + public verifyNavigationTree(json: any) { + const tree = this.languageService.getNavigationTree(this.activeFile.fileName); + if (JSON.stringify(tree, replacer) !== JSON.stringify(json)) { + this.raiseError(`verifyNavigationTree failed - expected: ${stringify(json)}, got: ${stringify(tree, replacer)}`); + } + + function replacer(key: string, value: any) { + // Don't check "spans", and omit falsy values. + return key === "spans" ? undefined : (value || undefined); + } + } + public printNavigationItems(searchValue: string) { const items = this.languageService.getNavigateToItems(searchValue); const length = items && items.length; @@ -3279,6 +3291,10 @@ namespace FourSlashInterface { this.state.verifyNavigationBar(json); } + public navigationTree(json: any) { + this.state.verifyNavigationTree(json); + } + public navigationItemsListCount(count: number, searchValue: string, matchKind?: string, fileName?: string) { this.state.verifyNavigationItemsCount(count, searchValue, matchKind, fileName); } diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 8d90166ea84..25885c8209a 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -459,6 +459,10 @@ namespace Harness.LanguageService { getNavigationBarItems(fileName: string): ts.NavigationBarItem[] { return unwrapJSONCallResult(this.shim.getNavigationBarItems(fileName)); } + getNavigationTree(fileName: string): ts.NavigationTree { + return unwrapJSONCallResult(this.shim.getNavigationTree(fileName)); + } + getOutliningSpans(fileName: string): ts.OutliningSpan[] { return unwrapJSONCallResult(this.shim.getOutliningSpans(fileName)); } diff --git a/src/server/client.ts b/src/server/client.ts index 688408dfb88..4028a2aab2e 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -488,7 +488,7 @@ namespace ts.server { return this.lastRenameEntry.locations; } - decodeNavigationBarItems(items: protocol.NavigationBarItem[], fileName: string, lineMap: number[]): NavigationBarItem[] { + private decodeNavigationBarItems(items: protocol.NavigationBarItem[], fileName: string, lineMap: number[]): NavigationBarItem[] { if (!items) { return []; } @@ -497,10 +497,7 @@ namespace ts.server { text: item.text, kind: item.kind, kindModifiers: item.kindModifiers || "", - spans: item.spans.map(span => - createTextSpanFromBounds( - this.lineOffsetToPosition(fileName, span.start, lineMap), - this.lineOffsetToPosition(fileName, span.end, lineMap))), + spans: item.spans.map(span => this.decodeSpan(span, fileName, lineMap)), childItems: this.decodeNavigationBarItems(item.childItems, fileName, lineMap), indent: item.indent, bolded: false, @@ -509,17 +506,37 @@ namespace ts.server { } getNavigationBarItems(fileName: string): NavigationBarItem[] { - const args: protocol.FileRequestArgs = { - file: fileName - }; - - const request = this.processRequest(CommandNames.NavBar, args); + const request = this.processRequest(CommandNames.NavBar, { file: fileName }); const response = this.processResponse(request); const lineMap = this.getLineMap(fileName); return this.decodeNavigationBarItems(response.body, fileName, lineMap); } + private decodeNavigationTree(tree: protocol.NavigationTree, fileName: string, lineMap: number[]): NavigationTree { + return { + text: tree.text, + kind: tree.kind, + kindModifiers: tree.kindModifiers, + spans: tree.spans.map(span => this.decodeSpan(span, fileName, lineMap)), + childItems: map(tree.childItems, item => this.decodeNavigationTree(item, fileName, lineMap)) + }; + } + + getNavigationTree(fileName: string): NavigationTree { + const request = this.processRequest(CommandNames.NavTree, { file: fileName }); + const response = this.processResponse(request); + + const lineMap = this.getLineMap(fileName); + return this.decodeNavigationTree(response.body, fileName, lineMap); + } + + private decodeSpan(span: protocol.TextSpan, fileName: string, lineMap: number[]) { + return createTextSpanFromBounds( + this.lineOffsetToPosition(fileName, span.start, lineMap), + this.lineOffsetToPosition(fileName, span.end, lineMap)); + } + getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan { throw new Error("Not Implemented Yet."); } diff --git a/src/server/protocol.d.ts b/src/server/protocol.d.ts index cd6f12453d1..d142ae52998 100644 --- a/src/server/protocol.d.ts +++ b/src/server/protocol.d.ts @@ -110,7 +110,7 @@ declare namespace ts.server.protocol { */ export interface TodoCommentRequestArgs extends FileRequestArgs { /** - * Array of target TodoCommentDescriptors that describes TODO comments to be found + * Array of target TodoCommentDescriptors that describes TODO comments to be found */ descriptors: TodoCommentDescriptor[]; } @@ -231,7 +231,7 @@ declare namespace ts.server.protocol { offset?: number; /** - * Position (can be specified instead of line/offset pair) + * Position (can be specified instead of line/offset pair) */ position?: number; } @@ -577,12 +577,12 @@ declare namespace ts.server.protocol { /** * Represents a file in external project. - * External project is project whose set of files, compilation options and open\close state + * External project is project whose set of files, compilation options and open\close state * is maintained by the client (i.e. if all this data come from .csproj file in Visual Studio). * External project will exist even if all files in it are closed and should be closed explicity. - * If external project includes one or more tsconfig.json/jsconfig.json files then tsserver will + * If external project includes one or more tsconfig.json/jsconfig.json files then tsserver will * create configured project for every config file but will maintain a link that these projects were created - * as a result of opening external project so they should be removed once external project is closed. + * as a result of opening external project so they should be removed once external project is closed. */ export interface ExternalFile { /** @@ -998,7 +998,7 @@ declare namespace ts.server.protocol { } /** - * Response for CompileOnSaveAffectedFileListRequest request; + * Response for CompileOnSaveAffectedFileListRequest request; */ export interface CompileOnSaveAffectedFileListResponse extends Response { body: CompileOnSaveAffectedFileListSingleProject[]; @@ -1743,6 +1743,13 @@ declare namespace ts.server.protocol { export interface NavBarRequest extends FileRequest { } + /** + * NavTree request; value of command field is "navtree". + * Return response giving the navigation tree of the requested file. + */ + export interface NavTreeRequest extends FileRequest { + } + export interface NavigationBarItem { /** * The item's display text. @@ -1775,7 +1782,20 @@ declare namespace ts.server.protocol { indent: number; } + /** protocol.NavigationTree is identical to ts.NavigationTree, except using protocol.TextSpan instead of ts.TextSpan */ + export interface NavigationTree { + text: string; + kind: string; + kindModifiers: string; + spans: TextSpan[]; + childItems?: NavigationTree[]; + } + export interface NavBarResponse extends Response { body?: NavigationBarItem[]; } + + export interface NavTreeResponse extends Response { + body?: NavigationTree; + } } diff --git a/src/server/scriptInfo.ts b/src/server/scriptInfo.ts index 410382a9ca4..ee5122ff4e1 100644 --- a/src/server/scriptInfo.ts +++ b/src/server/scriptInfo.ts @@ -4,7 +4,7 @@ namespace ts.server { export class ScriptInfo { /** - * All projects that include this file + * All projects that include this file */ readonly containingProjects: Project[] = []; private formatCodeSettings: ts.FormatCodeSettings; diff --git a/src/server/session.ts b/src/server/session.ts index 3b95bdd6fb9..070071399e8 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -98,6 +98,8 @@ namespace ts.server { export const SyntacticDiagnosticsSync = "syntacticDiagnosticsSync"; export const NavBar = "navbar"; export const NavBarFull = "navbar-full"; + export const NavTree = "navtree"; + export const NavTreeFull = "navtree-full"; export const Navto = "navto"; export const NavtoFull = "navto-full"; export const Occurrences = "occurrences"; @@ -550,7 +552,7 @@ namespace ts.server { const scriptInfo = this.projectService.getScriptInfo(args.file); projects = scriptInfo.containingProjects; } - // ts.filter handles case when 'projects' is undefined + // ts.filter handles case when 'projects' is undefined projects = filter(projects, p => p.languageServiceEnabled); if (!projects || !projects.length) { return Errors.ThrowNoProject(); @@ -947,15 +949,8 @@ namespace ts.server { return completions.entries.reduce((result: protocol.CompletionEntry[], entry: ts.CompletionEntry) => { if (completions.isMemberCompletion || (entry.name.toLowerCase().indexOf(prefix.toLowerCase()) === 0)) { const { name, kind, kindModifiers, sortText, replacementSpan } = entry; - - let convertedSpan: protocol.TextSpan = undefined; - if (replacementSpan) { - convertedSpan = { - start: scriptInfo.positionToLineOffset(replacementSpan.start), - end: scriptInfo.positionToLineOffset(replacementSpan.start + replacementSpan.length) - }; - } - + const convertedSpan: protocol.TextSpan = + replacementSpan ? this.decorateSpan(replacementSpan, scriptInfo) : undefined; result.push({ name, kind, kindModifiers, sortText, replacementSpan: convertedSpan }); } return result; @@ -1093,22 +1088,13 @@ namespace ts.server { this.projectService.closeClientFile(file); } - private decorateNavigationBarItem(project: Project, fileName: NormalizedPath, items: ts.NavigationBarItem[]): protocol.NavigationBarItem[] { - if (!items) { - return undefined; - } - - const scriptInfo = project.getScriptInfoForNormalizedPath(fileName); - - return items.map(item => ({ + private decorateNavigationBarItems(items: ts.NavigationBarItem[], scriptInfo: ScriptInfo): protocol.NavigationBarItem[] { + return map(items, item => ({ text: item.text, kind: item.kind, kindModifiers: item.kindModifiers, - spans: item.spans.map(span => ({ - start: scriptInfo.positionToLineOffset(span.start), - end: scriptInfo.positionToLineOffset(ts.textSpanEnd(span)) - })), - childItems: this.decorateNavigationBarItem(project, fileName, item.childItems), + spans: item.spans.map(span => this.decorateSpan(span, scriptInfo)), + childItems: this.decorateNavigationBarItems(item.childItems, scriptInfo), indent: item.indent })); } @@ -1116,15 +1102,40 @@ namespace ts.server { private getNavigationBarItems(args: protocol.FileRequestArgs, simplifiedResult: boolean): protocol.NavigationBarItem[] | NavigationBarItem[] { const { file, project } = this.getFileAndProject(args); const items = project.getLanguageService(/*ensureSynchronized*/ false).getNavigationBarItems(file); - if (!items) { - return undefined; - } - - return simplifiedResult - ? this.decorateNavigationBarItem(project, file, items) + return !items + ? undefined + : simplifiedResult + ? this.decorateNavigationBarItems(items, project.getScriptInfoForNormalizedPath(file)) : items; } + private decorateNavigationTree(tree: ts.NavigationTree, scriptInfo: ScriptInfo): protocol.NavigationTree { + return { + text: tree.text, + kind: tree.kind, + kindModifiers: tree.kindModifiers, + spans: tree.spans.map(span => this.decorateSpan(span, scriptInfo)), + childItems: map(tree.childItems, item => this.decorateNavigationTree(item, scriptInfo)) + }; + } + + private decorateSpan(span: TextSpan, scriptInfo: ScriptInfo): protocol.TextSpan { + return { + start: scriptInfo.positionToLineOffset(span.start), + end: scriptInfo.positionToLineOffset(ts.textSpanEnd(span)) + }; + } + + private getNavigationTree(args: protocol.FileRequestArgs, simplifiedResult: boolean): protocol.NavigationTree | NavigationTree { + const { file, project } = this.getFileAndProject(args); + const tree = project.getLanguageService(/*ensureSynchronized*/ false).getNavigationTree(file); + return !tree + ? undefined + : simplifiedResult + ? this.decorateNavigationTree(tree, project.getScriptInfoForNormalizedPath(file)) + : tree; + } + private getNavigateToItems(args: protocol.NavtoRequestArgs, simplifiedResult: boolean): protocol.NavtoItem[] | NavigateToItem[] { const projects = this.getProjects(args); @@ -1212,19 +1223,11 @@ namespace ts.server { const position = this.getPosition(args, scriptInfo); const spans = project.getLanguageService(/*ensureSynchronized*/ false).getBraceMatchingAtPosition(file, position); - if (!spans) { - return undefined; - } - if (simplifiedResult) { - - return spans.map(span => ({ - start: scriptInfo.positionToLineOffset(span.start), - end: scriptInfo.positionToLineOffset(span.start + span.length) - })); - } - else { - return spans; - } + return !spans + ? undefined + : simplifiedResult + ? spans.map(span => this.decorateSpan(span, scriptInfo)) + : spans; } getDiagnosticsForProject(delay: number, fileName: string) { @@ -1509,6 +1512,12 @@ namespace ts.server { [CommandNames.NavBarFull]: (request: protocol.FileRequest) => { return this.requiredResponse(this.getNavigationBarItems(request.arguments, /*simplifiedResult*/ false)); }, + [CommandNames.NavTree]: (request: protocol.FileRequest) => { + return this.requiredResponse(this.getNavigationTree(request.arguments, /*simplifiedResult*/ true)); + }, + [CommandNames.NavTreeFull]: (request: protocol.FileRequest) => { + return this.requiredResponse(this.getNavigationTree(request.arguments, /*simplifiedResult*/ false)); + }, [CommandNames.Occurrences]: (request: protocol.FileLocationRequest) => { return this.requiredResponse(this.getOccurrences(request.arguments)); }, diff --git a/src/server/utilities.ts b/src/server/utilities.ts index 3f99da9977e..9d659d64082 100644 --- a/src/server/utilities.ts +++ b/src/server/utilities.ts @@ -157,51 +157,52 @@ namespace ts.server { } }; } - function throwLanguageServiceIsDisabledError() { + function throwLanguageServiceIsDisabledError(): never { throw new Error("LanguageService is disabled"); } export const nullLanguageService: LanguageService = { - cleanupSemanticCache: (): any => throwLanguageServiceIsDisabledError(), - getSyntacticDiagnostics: (): any => throwLanguageServiceIsDisabledError(), - getSemanticDiagnostics: (): any => throwLanguageServiceIsDisabledError(), - getCompilerOptionsDiagnostics: (): any => throwLanguageServiceIsDisabledError(), - getSyntacticClassifications: (): any => throwLanguageServiceIsDisabledError(), - getEncodedSyntacticClassifications: (): any => throwLanguageServiceIsDisabledError(), - getSemanticClassifications: (): any => throwLanguageServiceIsDisabledError(), - getEncodedSemanticClassifications: (): any => throwLanguageServiceIsDisabledError(), - getCompletionsAtPosition: (): any => throwLanguageServiceIsDisabledError(), - findReferences: (): any => throwLanguageServiceIsDisabledError(), - getCompletionEntryDetails: (): any => throwLanguageServiceIsDisabledError(), - getQuickInfoAtPosition: (): any => throwLanguageServiceIsDisabledError(), - findRenameLocations: (): any => throwLanguageServiceIsDisabledError(), - getNameOrDottedNameSpan: (): any => throwLanguageServiceIsDisabledError(), - getBreakpointStatementAtPosition: (): any => throwLanguageServiceIsDisabledError(), - getBraceMatchingAtPosition: (): any => throwLanguageServiceIsDisabledError(), - getSignatureHelpItems: (): any => throwLanguageServiceIsDisabledError(), - getDefinitionAtPosition: (): any => throwLanguageServiceIsDisabledError(), - getRenameInfo: (): any => throwLanguageServiceIsDisabledError(), - getTypeDefinitionAtPosition: (): any => throwLanguageServiceIsDisabledError(), - getReferencesAtPosition: (): any => throwLanguageServiceIsDisabledError(), - getDocumentHighlights: (): any => throwLanguageServiceIsDisabledError(), - getOccurrencesAtPosition: (): any => throwLanguageServiceIsDisabledError(), - getNavigateToItems: (): any => throwLanguageServiceIsDisabledError(), - getNavigationBarItems: (): any => throwLanguageServiceIsDisabledError(), - getOutliningSpans: (): any => throwLanguageServiceIsDisabledError(), - getTodoComments: (): any => throwLanguageServiceIsDisabledError(), - getIndentationAtPosition: (): any => throwLanguageServiceIsDisabledError(), - getFormattingEditsForRange: (): any => throwLanguageServiceIsDisabledError(), - getFormattingEditsForDocument: (): any => throwLanguageServiceIsDisabledError(), - getFormattingEditsAfterKeystroke: (): any => throwLanguageServiceIsDisabledError(), - getDocCommentTemplateAtPosition: (): any => throwLanguageServiceIsDisabledError(), - isValidBraceCompletionAtPosition: (): any => throwLanguageServiceIsDisabledError(), - getEmitOutput: (): any => throwLanguageServiceIsDisabledError(), - getProgram: (): any => throwLanguageServiceIsDisabledError(), - getNonBoundSourceFile: (): any => throwLanguageServiceIsDisabledError(), - dispose: (): any => throwLanguageServiceIsDisabledError(), - getCompletionEntrySymbol: (): any => throwLanguageServiceIsDisabledError(), - getImplementationAtPosition: (): any => throwLanguageServiceIsDisabledError(), - getSourceFile: (): any => throwLanguageServiceIsDisabledError() + cleanupSemanticCache: throwLanguageServiceIsDisabledError, + getSyntacticDiagnostics: throwLanguageServiceIsDisabledError, + getSemanticDiagnostics: throwLanguageServiceIsDisabledError, + getCompilerOptionsDiagnostics: throwLanguageServiceIsDisabledError, + getSyntacticClassifications: throwLanguageServiceIsDisabledError, + getEncodedSyntacticClassifications: throwLanguageServiceIsDisabledError, + getSemanticClassifications: throwLanguageServiceIsDisabledError, + getEncodedSemanticClassifications: throwLanguageServiceIsDisabledError, + getCompletionsAtPosition: throwLanguageServiceIsDisabledError, + findReferences: throwLanguageServiceIsDisabledError, + getCompletionEntryDetails: throwLanguageServiceIsDisabledError, + getQuickInfoAtPosition: throwLanguageServiceIsDisabledError, + findRenameLocations: throwLanguageServiceIsDisabledError, + getNameOrDottedNameSpan: throwLanguageServiceIsDisabledError, + getBreakpointStatementAtPosition: throwLanguageServiceIsDisabledError, + getBraceMatchingAtPosition: throwLanguageServiceIsDisabledError, + getSignatureHelpItems: throwLanguageServiceIsDisabledError, + getDefinitionAtPosition: throwLanguageServiceIsDisabledError, + getRenameInfo: throwLanguageServiceIsDisabledError, + getTypeDefinitionAtPosition: throwLanguageServiceIsDisabledError, + getReferencesAtPosition: throwLanguageServiceIsDisabledError, + getDocumentHighlights: throwLanguageServiceIsDisabledError, + getOccurrencesAtPosition: throwLanguageServiceIsDisabledError, + getNavigateToItems: throwLanguageServiceIsDisabledError, + getNavigationBarItems: throwLanguageServiceIsDisabledError, + getNavigationTree: throwLanguageServiceIsDisabledError, + getOutliningSpans: throwLanguageServiceIsDisabledError, + getTodoComments: throwLanguageServiceIsDisabledError, + getIndentationAtPosition: throwLanguageServiceIsDisabledError, + getFormattingEditsForRange: throwLanguageServiceIsDisabledError, + getFormattingEditsForDocument: throwLanguageServiceIsDisabledError, + getFormattingEditsAfterKeystroke: throwLanguageServiceIsDisabledError, + getDocCommentTemplateAtPosition: throwLanguageServiceIsDisabledError, + isValidBraceCompletionAtPosition: throwLanguageServiceIsDisabledError, + getEmitOutput: throwLanguageServiceIsDisabledError, + getProgram: throwLanguageServiceIsDisabledError, + getNonBoundSourceFile: throwLanguageServiceIsDisabledError, + dispose: throwLanguageServiceIsDisabledError, + getCompletionEntrySymbol: throwLanguageServiceIsDisabledError, + getImplementationAtPosition: throwLanguageServiceIsDisabledError, + getSourceFile: throwLanguageServiceIsDisabledError }; export interface ServerLanguageServiceHost { @@ -248,7 +249,7 @@ namespace ts.server { // another operation was already scheduled for this id - cancel it this.host.clearTimeout(this.pendingTimeouts[operationId]); } - // schedule new operation, pass arguments + // schedule new operation, pass arguments this.pendingTimeouts[operationId] = this.host.setTimeout(ThrottledOperations.run, delay, this, operationId, cb); } diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index 0397ae73229..18881ae7660 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -21,6 +21,13 @@ namespace ts.NavigationBar { return result; } + export function getNavigationTree(sourceFile: SourceFile): NavigationTree { + curSourceFile = sourceFile; + const result = convertToTree(rootNavigationBarNode(sourceFile)); + curSourceFile = undefined; + return result; + } + // Keep sourceFile handy so we don't have to search for it every time we need to call `getText`. let curSourceFile: SourceFile; function nodeText(node: Node): string { @@ -502,6 +509,16 @@ namespace ts.NavigationBar { // NavigationBarItem requires an array, but will not mutate it, so just give it this for performance. const emptyChildItemArray: NavigationBarItem[] = []; + function convertToTree(n: NavigationBarNode): NavigationTree { + return { + text: getItemName(n.node), + kind: getNodeKind(n.node), + kindModifiers: getNodeModifiers(n.node), + spans: getSpans(n), + childItems: map(n.children, convertToTree) + }; + } + function convertToTopLevelItem(n: NavigationBarNode): NavigationBarItem { return { text: getItemName(n.node), @@ -526,16 +543,16 @@ namespace ts.NavigationBar { grayed: false }; } + } - function getSpans(n: NavigationBarNode): TextSpan[] { - const spans = [getNodeSpan(n.node)]; - if (n.additionalNodes) { - for (const node of n.additionalNodes) { - spans.push(getNodeSpan(node)); - } + function getSpans(n: NavigationBarNode): TextSpan[] { + const spans = [getNodeSpan(n.node)]; + if (n.additionalNodes) { + for (const node of n.additionalNodes) { + spans.push(getNodeSpan(node)); } - return spans; } + return spans; } function getModuleName(moduleDeclaration: ModuleDeclaration): string { diff --git a/src/services/services.ts b/src/services/services.ts index ddac0d51459..5dd97b87dc1 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1516,9 +1516,11 @@ namespace ts { } function getNavigationBarItems(fileName: string): NavigationBarItem[] { - const sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + return NavigationBar.getNavigationBarItems(syntaxTreeCache.getCurrentSourceFile(fileName)); + } - return NavigationBar.getNavigationBarItems(sourceFile); + function getNavigationTree(fileName: string): NavigationTree { + return NavigationBar.getNavigationTree(syntaxTreeCache.getCurrentSourceFile(fileName)); } function isTsOrTsxFile(fileName: string): boolean { @@ -1868,6 +1870,7 @@ namespace ts { getRenameInfo, findRenameLocations, getNavigationBarItems, + getNavigationTree, getOutliningSpans, getTodoComments, getBraceMatchingAtPosition, diff --git a/src/services/shims.ts b/src/services/shims.ts index 56ab852606c..7ed1786640d 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -224,6 +224,9 @@ namespace ts { */ getNavigationBarItems(fileName: string): string; + /** Returns a JSON-encoded value of the type ts.NavigationTree. */ + getNavigationTree(fileName: string): string; + /** * Returns a JSON-encoded value of the type: * { textSpan: { start: number, length: number }; hintSpan: { start: number, length: number }; bannerText: string; autoCollapse: boolean } [] = []; @@ -971,6 +974,13 @@ namespace ts { ); } + public getNavigationTree(fileName: string): string { + return this.forwardJSONCall( + `getNavigationTree('${fileName}')`, + () => this.languageService.getNavigationTree(fileName) + ); + } + public getOutliningSpans(fileName: string): string { return this.forwardJSONCall( `getOutliningSpans('${fileName}')`, diff --git a/src/services/types.ts b/src/services/types.ts index ac81a87daf5..bcb87774901 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -225,6 +225,7 @@ namespace ts { getNavigateToItems(searchValue: string, maxResultCount?: number, fileName?: string, excludeDtsFiles?: boolean): NavigateToItem[]; getNavigationBarItems(fileName: string): NavigationBarItem[]; + getNavigationTree(fileName: string): NavigationTree; getOutliningSpans(fileName: string): OutliningSpan[]; getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[]; @@ -264,6 +265,12 @@ namespace ts { classificationType: string; // ClassificationTypeNames } + /** + * Navigation bar interface designed for visual studio's dual-column layout. + * This does not form a proper tree. + * The navbar is returned as a list of top-level items, each of which has a list of child items. + * Child items always have an empty array for their `childItems`. + */ export interface NavigationBarItem { text: string; kind: string; @@ -275,6 +282,26 @@ namespace ts { grayed: boolean; } + /** + * Node in a tree of nested declarations in a file. + * The top node is always a script or module node. + */ + export interface NavigationTree { + /** Name of the declaration, or a short description, e.g. "". */ + text: string; + /** A ScriptElementKind */ + kind: string; + /** ScriptElementKindModifier separated by commas, e.g. "public,abstract" */ + kindModifiers: string; + /** + * Spans of the nodes that generated this declaration. + * There will be more than one if this is the result of merging. + */ + spans: TextSpan[]; + /** Present if non-empty */ + childItems?: NavigationTree[]; + } + export interface TodoCommentDescriptor { text: string; priority: number; diff --git a/tests/cases/fourslash/deleteClassWithEnumPresent.ts b/tests/cases/fourslash/deleteClassWithEnumPresent.ts index eb40a27bcd7..8914e0020a0 100644 --- a/tests/cases/fourslash/deleteClassWithEnumPresent.ts +++ b/tests/cases/fourslash/deleteClassWithEnumPresent.ts @@ -5,6 +5,32 @@ goTo.marker(); edit.deleteAtCaret('class Bar { }'.length); + +verify.navigationTree({ + "text": "", + "kind": "script", + "childItems": [ + { + "text": "Foo", + "kind": "enum", + "childItems": [ + { + "text": "a", + "kind": "const" + }, + { + "text": "b", + "kind": "const" + }, + { + "text": "c", + "kind": "const" + } + ] + } + ] +}); + verify.navigationBar([ { "text": "", diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 5f86cbbafa4..a64edc70fc8 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -210,6 +210,7 @@ declare namespace FourSlashInterface { noDocCommentTemplate(): void; navigationBar(json: any): void; + navigationTree(json: any): void; navigationItemsListCount(count: number, searchValue: string, matchKind?: string, fileName?: string): void; navigationItemsListContains(name: string, kind: string, searchValue: string, matchKind: string, fileName?: string, parentName?: string): void; occurrencesAtPositionContains(range: Range, isWriteAccess?: boolean): void; diff --git a/tests/cases/fourslash/getNavigationBarItems.ts b/tests/cases/fourslash/getNavigationBarItems.ts index 8041ba3b464..4bcfc3e18aa 100644 --- a/tests/cases/fourslash/getNavigationBarItems.ts +++ b/tests/cases/fourslash/getNavigationBarItems.ts @@ -5,6 +5,27 @@ //// ["bar"]: string; ////} +verify.navigationTree({ + "text": "", + "kind": "script", + "childItems": [ + { + "text": "C", + "kind": "class", + "childItems": [ + { + "text": "[\"bar\"]", + "kind": "property" + }, + { + "text": "foo", + "kind": "property" + } + ] + } + ] +}); + verify.navigationBar([ { "text": "", @@ -31,4 +52,4 @@ verify.navigationBar([ ], "indent": 1 } -]) +]); diff --git a/tests/cases/fourslash/navbar_const.ts b/tests/cases/fourslash/navbar_const.ts index faaedb54482..2d3e3b919d0 100644 --- a/tests/cases/fourslash/navbar_const.ts +++ b/tests/cases/fourslash/navbar_const.ts @@ -2,6 +2,17 @@ //// const c = 0; +verify.navigationTree({ + "text": "", + "kind": "script", + "childItems": [ + { + "text": "c", + "kind": "const" + } + ] +}); + verify.navigationBar([ { "text": "", diff --git a/tests/cases/fourslash/navbar_contains-no-duplicates.ts b/tests/cases/fourslash/navbar_contains-no-duplicates.ts index ba48c4a93dd..f4b52bb09a1 100644 --- a/tests/cases/fourslash/navbar_contains-no-duplicates.ts +++ b/tests/cases/fourslash/navbar_contains-no-duplicates.ts @@ -27,6 +27,83 @@ //// export var x = 3; //// } +verify.navigationTree({ + "text": "", + "kind": "script", + "childItems": [ + { + "text": "ABC", + "kind": "class", + "childItems": [ + { + "text": "foo", + "kind": "method", + "kindModifiers": "public" + } + ] + }, + { + "text": "ABC", + "kind": "module", + "childItems": [ + { + "text": "x", + "kind": "var", + "kindModifiers": "export" + } + ] + }, + { + "text": "Windows", + "kind": "module", + "kindModifiers": "declare", + "childItems": [ + { + "text": "Foundation", + "kind": "module", + "kindModifiers": "export,declare", + "childItems": [ + { + "text": "A", + "kind": "var", + "kindModifiers": "export,declare" + }, + { + "text": "B", + "kind": "var", + "kindModifiers": "export,declare" + }, + { + "text": "Test", + "kind": "class", + "kindModifiers": "export,declare", + "childItems": [ + { + "text": "wow", + "kind": "method", + "kindModifiers": "public,declare" + } + ] + }, + { + "text": "Test", + "kind": "module", + "kindModifiers": "export,declare", + "childItems": [ + { + "text": "Boom", + "kind": "function", + "kindModifiers": "export,declare" + } + ] + } + ] + } + ] + } + ] +}); + verify.navigationBar([ { "text": "", diff --git a/tests/cases/fourslash/navbar_exportDefault.ts b/tests/cases/fourslash/navbar_exportDefault.ts index e547c9129a6..84f50610e6b 100644 --- a/tests/cases/fourslash/navbar_exportDefault.ts +++ b/tests/cases/fourslash/navbar_exportDefault.ts @@ -13,6 +13,17 @@ ////export default function Func { } goTo.file("a.ts"); +verify.navigationTree({ + "text": "\"a\"", + "kind": "module", + "childItems": [ + { + "text": "default", + "kind": "class", + "kindModifiers": "export" + } + ] +}); verify.navigationBar([ { "text": "\"a\"", @@ -34,6 +45,17 @@ verify.navigationBar([ ]); goTo.file("b.ts"); +verify.navigationTree({ + "text": "\"b\"", + "kind": "module", + "childItems": [ + { + "text": "C", + "kind": "class", + "kindModifiers": "export" + } + ] +}); verify.navigationBar([ { "text": "\"b\"", @@ -55,6 +77,17 @@ verify.navigationBar([ ]); goTo.file("c.ts"); +verify.navigationTree({ + "text": "\"c\"", + "kind": "module", + "childItems": [ + { + "text": "default", + "kind": "function", + "kindModifiers": "export" + } + ] +}); verify.navigationBar([ { "text": "\"c\"", @@ -76,6 +109,17 @@ verify.navigationBar([ ]); goTo.file("d.ts"); +verify.navigationTree({ + "text": "\"d\"", + "kind": "module", + "childItems": [ + { + "text": "Func", + "kind": "function", + "kindModifiers": "export" + } + ] +}); verify.navigationBar([ { "text": "\"d\"", diff --git a/tests/cases/fourslash/navbar_let.ts b/tests/cases/fourslash/navbar_let.ts index bd0e702bbf9..77e00ad7300 100644 --- a/tests/cases/fourslash/navbar_let.ts +++ b/tests/cases/fourslash/navbar_let.ts @@ -2,6 +2,17 @@ ////let c = 0; +verify.navigationTree({ + "text": "", + "kind": "script", + "childItems": [ + { + "text": "c", + "kind": "let" + } + ] +}); + verify.navigationBar([ { "text": "", diff --git a/tests/cases/fourslash/navigationBarAnonymousClassAndFunctionExpressions.ts b/tests/cases/fourslash/navigationBarAnonymousClassAndFunctionExpressions.ts index 30e96739ab0..69fa697f7bc 100644 --- a/tests/cases/fourslash/navigationBarAnonymousClassAndFunctionExpressions.ts +++ b/tests/cases/fourslash/navigationBarAnonymousClassAndFunctionExpressions.ts @@ -26,6 +26,85 @@ //// (class { }); ////}) +verify.navigationTree({ + "text": "", + "kind": "script", + "childItems": [ + { + "text": "", + "kind": "function", + "childItems": [ + { + "text": "nest", + "kind": "function", + "childItems": [ + { + "text": "moreNest", + "kind": "function" + } + ] + }, + { + "text": "x", + "kind": "function", + "childItems": [ + { + "text": "xx", + "kind": "function" + } + ] + }, + { + "text": "y", + "kind": "const", + "childItems": [ + { + "text": "foo", + "kind": "function" + } + ] + } + ] + }, + { + "text": "", + "kind": "function", + "childItems": [ + { + "text": "", + "kind": "function" + }, + { + "text": "z", + "kind": "function" + } + ] + }, + { + "text": "classes", + "kind": "function", + "childItems": [ + { + "text": "", + "kind": "class" + }, + { + "text": "cls2", + "kind": "class" + }, + { + "text": "cls3", + "kind": "class" + } + ] + }, + { + "text": "global.cls", + "kind": "class" + } + ] +}); + verify.navigationBar([ { "text": "", diff --git a/tests/cases/fourslash/navigationBarAnonymousClassAndFunctionExpressions2.ts b/tests/cases/fourslash/navigationBarAnonymousClassAndFunctionExpressions2.ts index 36b1e07cd8a..f6ce02e0dd0 100644 --- a/tests/cases/fourslash/navigationBarAnonymousClassAndFunctionExpressions2.ts +++ b/tests/cases/fourslash/navigationBarAnonymousClassAndFunctionExpressions2.ts @@ -3,6 +3,39 @@ ////console.log(console.log(class Y {}, class X {}), console.log(class B {}, class A {})); ////console.log(class Cls { meth() {} }); +verify.navigationTree({ + "text": "", + "kind": "script", + "childItems": [ + { + "text": "A", + "kind": "class" + }, + { + "text": "B", + "kind": "class" + }, + { + "text": "Cls", + "kind": "class", + "childItems": [ + { + "text": "meth", + "kind": "method" + } + ] + }, + { + "text": "X", + "kind": "class" + }, + { + "text": "Y", + "kind": "class" + } + ] +}); + verify.navigationBar([ { "text": "", diff --git a/tests/cases/fourslash/navigationBarFunctionIndirectlyInVariableDeclaration.ts b/tests/cases/fourslash/navigationBarFunctionIndirectlyInVariableDeclaration.ts index f14419a121a..a0ed5174f56 100644 --- a/tests/cases/fourslash/navigationBarFunctionIndirectlyInVariableDeclaration.ts +++ b/tests/cases/fourslash/navigationBarFunctionIndirectlyInVariableDeclaration.ts @@ -8,39 +8,64 @@ //// propB: function() {} ////}; -verify.navigationBar([ - { +verify.navigationTree({ "text": "", "kind": "script", "childItems": [ - { - "text": "a", - "kind": "var" - }, - { - "text": "b", - "kind": "var" - }, - { - "text": "propB", - "kind": "function" - } + { + "text": "a", + "kind": "var", + "childItems": [ + { + "text": "propA", + "kind": "function" + } + ] + }, + { + "text": "b", + "kind": "var" + }, + { + "text": "propB", + "kind": "function" + } ] - }, - { - "text": "a", - "kind": "var", - "childItems": [ - { - "text": "propA", - "kind": "function" - } - ], - "indent": 1 - }, - { - "text": "propB", - "kind": "function", - "indent": 1 - } +}); + +verify.navigationBar([ + { + "text": "", + "kind": "script", + "childItems": [ + { + "text": "a", + "kind": "var" + }, + { + "text": "b", + "kind": "var" + }, + { + "text": "propB", + "kind": "function" + } + ] + }, + { + "text": "a", + "kind": "var", + "childItems": [ + { + "text": "propA", + "kind": "function" + } + ], + "indent": 1 + }, + { + "text": "propB", + "kind": "function", + "indent": 1 + } ]); diff --git a/tests/cases/fourslash/navigationBarGetterAndSetter.ts b/tests/cases/fourslash/navigationBarGetterAndSetter.ts index 3ae2e0f60ac..ccf9e7c472e 100644 --- a/tests/cases/fourslash/navigationBarGetterAndSetter.ts +++ b/tests/cases/fourslash/navigationBarGetterAndSetter.ts @@ -8,6 +8,33 @@ //// } ////} +verify.navigationTree({ + "text": "", + "kind": "script", + "childItems": [ + { + "text": "X", + "kind": "class", + "childItems": [ + { + "text": "x", + "kind": "getter" + }, + { + "text": "x", + "kind": "setter", + "childItems": [ + { + "text": "f", + "kind": "function" + } + ] + } + ] + } + ] +}); + verify.navigationBar([ { "text": "", diff --git a/tests/cases/fourslash/navigationBarImports.ts b/tests/cases/fourslash/navigationBarImports.ts index 43cb99c556a..44f0d46b401 100644 --- a/tests/cases/fourslash/navigationBarImports.ts +++ b/tests/cases/fourslash/navigationBarImports.ts @@ -4,6 +4,29 @@ ////import c = require("m"); ////import * as d from "m"; +verify.navigationTree({ + "text": "\"navigationBarImports\"", + "kind": "module", + "childItems": [ + { + "text": "a", + "kind": "alias" + }, + { + "text": "b", + "kind": "alias" + }, + { + "text": "c", + "kind": "alias" + }, + { + "text": "d", + "kind": "alias" + } + ] +}); + verify.navigationBar([ { "text": "\"navigationBarImports\"", diff --git a/tests/cases/fourslash/navigationBarItemsBindingPatterns.ts b/tests/cases/fourslash/navigationBarItemsBindingPatterns.ts index ff1de04c07e..d2b8b24bcbf 100644 --- a/tests/cases/fourslash/navigationBarItemsBindingPatterns.ts +++ b/tests/cases/fourslash/navigationBarItemsBindingPatterns.ts @@ -6,6 +6,57 @@ ////const bar1, [c, d] ////var {e, x: [f, g]} = {a:1, x:[]}; +verify.navigationTree({ + "text": "", + "kind": "script", + "childItems": [ + { + "text": "a", + "kind": "let" + }, + { + "text": "b", + "kind": "let" + }, + { + "text": "bar", + "kind": "var" + }, + { + "text": "bar1", + "kind": "const" + }, + { + "text": "c", + "kind": "const" + }, + { + "text": "d", + "kind": "const" + }, + { + "text": "e", + "kind": "var" + }, + { + "text": "f", + "kind": "var" + }, + { + "text": "foo", + "kind": "var" + }, + { + "text": "foo1", + "kind": "let" + }, + { + "text": "g", + "kind": "var" + } + ] +}); + verify.navigationBar([ { "text": "", diff --git a/tests/cases/fourslash/navigationBarItemsBindingPatternsInConstructor.ts b/tests/cases/fourslash/navigationBarItemsBindingPatternsInConstructor.ts index 61e34d0f30e..f1250d530d3 100644 --- a/tests/cases/fourslash/navigationBarItemsBindingPatternsInConstructor.ts +++ b/tests/cases/fourslash/navigationBarItemsBindingPatternsInConstructor.ts @@ -11,6 +11,41 @@ //// } ////} +verify.navigationTree({ + "text": "", + "kind": "script", + "childItems": [ + { + "text": "A", + "kind": "class", + "childItems": [ + { + "text": "constructor", + "kind": "constructor" + }, + { + "text": "x", + "kind": "property" + } + ] + }, + { + "text": "B", + "kind": "class", + "childItems": [ + { + "text": "constructor", + "kind": "constructor" + }, + { + "text": "x", + "kind": "property" + } + ] + } + ] +}); + verify.navigationBar([ { "text": "", diff --git a/tests/cases/fourslash/navigationBarItemsEmptyConstructors.ts b/tests/cases/fourslash/navigationBarItemsEmptyConstructors.ts index 2e37f69b456..c300a1207d5 100644 --- a/tests/cases/fourslash/navigationBarItemsEmptyConstructors.ts +++ b/tests/cases/fourslash/navigationBarItemsEmptyConstructors.ts @@ -5,6 +5,23 @@ //// } ////} +verify.navigationTree({ + "text": "", + "kind": "script", + "childItems": [ + { + "text": "Test", + "kind": "class", + "childItems": [ + { + "text": "constructor", + "kind": "constructor" + } + ] + } + ] +}); + verify.navigationBar([ { "text": "", diff --git a/tests/cases/fourslash/navigationBarItemsExports.ts b/tests/cases/fourslash/navigationBarItemsExports.ts index 3ec9b0a7138..1f29ae5af5b 100644 --- a/tests/cases/fourslash/navigationBarItemsExports.ts +++ b/tests/cases/fourslash/navigationBarItemsExports.ts @@ -9,6 +9,26 @@ //// ////export * from "a"; // no bindings here +verify.navigationTree({ + "text": "\"navigationBarItemsExports\"", + "kind": "module", + "childItems": [ + { + "text": "a", + "kind": "alias" + }, + { + "text": "B", + "kind": "alias" + }, + { + "text": "e", + "kind": "alias", + "kindModifiers": "export" + } + ] +}); + verify.navigationBar([ { "text": "\"navigationBarItemsExports\"", diff --git a/tests/cases/fourslash/navigationBarItemsFunctions.ts b/tests/cases/fourslash/navigationBarItemsFunctions.ts index b85e898065c..f43cd3effaf 100644 --- a/tests/cases/fourslash/navigationBarItemsFunctions.ts +++ b/tests/cases/fourslash/navigationBarItemsFunctions.ts @@ -14,6 +14,53 @@ //// var v = 10; ////} +verify.navigationTree({ + "text": "", + "kind": "script", + "childItems": [ + { + "text": "baz", + "kind": "function", + "childItems": [ + { + "text": "v", + "kind": "var" + } + ] + }, + { + "text": "foo", + "kind": "function", + "childItems": [ + { + "text": "bar", + "kind": "function", + "childItems": [ + { + "text": "biz", + "kind": "function", + "childItems": [ + { + "text": "z", + "kind": "var" + } + ] + }, + { + "text": "y", + "kind": "var" + } + ] + }, + { + "text": "x", + "kind": "var" + } + ] + } + ] +}); + verify.navigationBar([ { "text": "", diff --git a/tests/cases/fourslash/navigationBarItemsFunctionsBroken.ts b/tests/cases/fourslash/navigationBarItemsFunctionsBroken.ts index b0238a1ef06..49ca40841d7 100644 --- a/tests/cases/fourslash/navigationBarItemsFunctionsBroken.ts +++ b/tests/cases/fourslash/navigationBarItemsFunctionsBroken.ts @@ -4,6 +4,23 @@ //// function; ////} +verify.navigationTree({ + "text": "", + "kind": "script", + "childItems": [ + { + "text": "f", + "kind": "function", + "childItems": [ + { + "text": "", + "kind": "function" + } + ] + } + ] +}); + verify.navigationBar([ { "text": "", diff --git a/tests/cases/fourslash/navigationBarItemsFunctionsBroken2.ts b/tests/cases/fourslash/navigationBarItemsFunctionsBroken2.ts index 4f279446100..8ebfab8519b 100644 --- a/tests/cases/fourslash/navigationBarItemsFunctionsBroken2.ts +++ b/tests/cases/fourslash/navigationBarItemsFunctionsBroken2.ts @@ -5,6 +5,27 @@ //// function; ////} +verify.navigationTree({ + "text": "", + "kind": "script", + "childItems": [ + { + "text": "", + "kind": "function" + }, + { + "text": "f", + "kind": "function", + "childItems": [ + { + "text": "", + "kind": "function" + } + ] + } + ] +}); + verify.navigationBar([ { "text": "", diff --git a/tests/cases/fourslash/navigationBarItemsImports.ts b/tests/cases/fourslash/navigationBarItemsImports.ts index ed398ec7f1d..b0ce515a56c 100644 --- a/tests/cases/fourslash/navigationBarItemsImports.ts +++ b/tests/cases/fourslash/navigationBarItemsImports.ts @@ -13,6 +13,44 @@ //// ////import * as ns from "a"; +verify.navigationTree({ + "text": "\"navigationBarItemsImports\"", + "kind": "module", + "childItems": [ + { + "text": "a", + "kind": "alias" + }, + { + "text": "B", + "kind": "alias" + }, + { + "text": "c", + "kind": "alias" + }, + { + "text": "D", + "kind": "alias" + }, + { + "text": "d1", + "kind": "alias" + }, + { + "text": "d2", + "kind": "alias" + }, + { + "text": "e", + "kind": "alias" + }, + { + "text": "ns", + "kind": "alias" + } + ] +}); verify.navigationBar([ { diff --git a/tests/cases/fourslash/navigationBarItemsInsideMethodsAndConstructors.ts b/tests/cases/fourslash/navigationBarItemsInsideMethodsAndConstructors.ts index a49f32d960e..35dff3af14c 100644 --- a/tests/cases/fourslash/navigationBarItemsInsideMethodsAndConstructors.ts +++ b/tests/cases/fourslash/navigationBarItemsInsideMethodsAndConstructors.ts @@ -18,6 +18,77 @@ //// emptyMethod() { } // Non child functions method should not be duplicated ////} +verify.navigationTree({ + "text": "", + "kind": "script", + "childItems": [ + { + "text": "Class", + "kind": "class", + "childItems": [ + { + "text": "constructor", + "kind": "constructor", + "childItems": [ + { + "text": "LocalEnumInConstructor", + "kind": "enum", + "childItems": [ + { + "text": "LocalEnumMemberInConstructor", + "kind": "const" + } + ] + }, + { + "text": "LocalFunctionInConstructor", + "kind": "function" + }, + { + "text": "LocalInterfaceInConstrcutor", + "kind": "interface" + } + ] + }, + { + "text": "emptyMethod", + "kind": "method" + }, + { + "text": "method", + "kind": "method", + "childItems": [ + { + "text": "LocalEnumInMethod", + "kind": "enum", + "childItems": [ + { + "text": "LocalEnumMemberInMethod", + "kind": "const" + } + ] + }, + { + "text": "LocalFunctionInMethod", + "kind": "function", + "childItems": [ + { + "text": "LocalFunctionInLocalFunctionInMethod", + "kind": "function" + } + ] + }, + { + "text": "LocalInterfaceInMethod", + "kind": "interface" + } + ] + } + ] + } + ] +}); + verify.navigationBar([ { "text": "", diff --git a/tests/cases/fourslash/navigationBarItemsItems.ts b/tests/cases/fourslash/navigationBarItemsItems.ts index e3d8f0e633c..69422dd0cc2 100644 --- a/tests/cases/fourslash/navigationBarItemsItems.ts +++ b/tests/cases/fourslash/navigationBarItemsItems.ts @@ -39,6 +39,114 @@ ////var p: IPoint = new Shapes.Point(3, 4); ////var dist = p.getDist(); +verify.navigationTree({ + "text": "", + "kind": "script", + "childItems": [ + { + "text": "dist", + "kind": "var" + }, + { + "text": "IPoint", + "kind": "interface", + "childItems": [ + { + "text": "()", + "kind": "call" + }, + { + "text": "new()", + "kind": "construct" + }, + { + "text": "[]", + "kind": "index" + }, + { + "text": "getDist", + "kind": "method" + }, + { + "text": "prop", + "kind": "property" + } + ] + }, + { + "text": "p", + "kind": "var" + }, + { + "text": "Shapes", + "kind": "module", + "childItems": [ + { + "text": "Point", + "kind": "class", + "kindModifiers": "export", + "childItems": [ + { + "text": "constructor", + "kind": "constructor" + }, + { + "text": "getDist", + "kind": "method" + }, + { + "text": "getOrigin", + "kind": "method", + "kindModifiers": "private,static" + }, + { + "text": "origin", + "kind": "property", + "kindModifiers": "static" + }, + { + "text": "value", + "kind": "getter" + }, + { + "text": "value", + "kind": "setter" + }, + { + "text": "x", + "kind": "property", + "kindModifiers": "public" + }, + { + "text": "y", + "kind": "property", + "kindModifiers": "public" + } + ] + }, + { + "text": "Values", + "kind": "enum", + "childItems": [ + { + "text": "value1", + "kind": "const" + }, + { + "text": "value2", + "kind": "const" + }, + { + "text": "value3", + "kind": "const" + } + ] + } + ] + } + ] +}); + verify.navigationBar([ { "text": "", diff --git a/tests/cases/fourslash/navigationBarItemsItems2.ts b/tests/cases/fourslash/navigationBarItemsItems2.ts index 6ab0827e8f9..fa5a5b09fac 100644 --- a/tests/cases/fourslash/navigationBarItemsItems2.ts +++ b/tests/cases/fourslash/navigationBarItemsItems2.ts @@ -6,6 +6,22 @@ goTo.marker(); edit.insertLine("module A"); edit.insert("export class "); +verify.navigationTree({ + "text": "\"navigationBarItemsItems2\"", + "kind": "module", + "childItems": [ + { + "text": "", + "kind": "class", + "kindModifiers": "export" + }, + { + "text": "A", + "kind": "module" + } + ] +}); + // should not crash verify.navigationBar([ { diff --git a/tests/cases/fourslash/navigationBarItemsItemsExternalModules.ts b/tests/cases/fourslash/navigationBarItemsItemsExternalModules.ts index 04091185dd0..705dc2227b3 100644 --- a/tests/cases/fourslash/navigationBarItemsItemsExternalModules.ts +++ b/tests/cases/fourslash/navigationBarItemsItemsExternalModules.ts @@ -4,6 +4,25 @@ //// public s: string; ////} +verify.navigationTree({ + "text": "\"navigationBarItemsItemsExternalModules\"", + "kind": "module", + "childItems": [ + { + "text": "Bar", + "kind": "class", + "kindModifiers": "export", + "childItems": [ + { + "text": "s", + "kind": "property", + "kindModifiers": "public" + } + ] + } + ] +}); + verify.navigationBar([ { "text": "\"navigationBarItemsItemsExternalModules\"", diff --git a/tests/cases/fourslash/navigationBarItemsItemsExternalModules2.ts b/tests/cases/fourslash/navigationBarItemsItemsExternalModules2.ts index 4939091d944..c271050bc52 100644 --- a/tests/cases/fourslash/navigationBarItemsItemsExternalModules2.ts +++ b/tests/cases/fourslash/navigationBarItemsItemsExternalModules2.ts @@ -6,6 +6,30 @@ ////} ////export var x: number; +verify.navigationTree({ + "text": "\"file\"", + "kind": "module", + "childItems": [ + { + "text": "Bar", + "kind": "class", + "kindModifiers": "export", + "childItems": [ + { + "text": "s", + "kind": "property", + "kindModifiers": "public" + } + ] + }, + { + "text": "x", + "kind": "var", + "kindModifiers": "export" + } + ] +}); + verify.navigationBar([ { "text": "\"file\"", diff --git a/tests/cases/fourslash/navigationBarItemsItemsExternalModules3.ts b/tests/cases/fourslash/navigationBarItemsItemsExternalModules3.ts index 5ee760fabc6..91ac533d75c 100644 --- a/tests/cases/fourslash/navigationBarItemsItemsExternalModules3.ts +++ b/tests/cases/fourslash/navigationBarItemsItemsExternalModules3.ts @@ -6,6 +6,30 @@ ////} ////export var x: number; +verify.navigationTree({ + "text": "\"my fil\\\"e\"", + "kind": "module", + "childItems": [ + { + "text": "Bar", + "kind": "class", + "kindModifiers": "export", + "childItems": [ + { + "text": "s", + "kind": "property", + "kindModifiers": "public" + } + ] + }, + { + "text": "x", + "kind": "var", + "kindModifiers": "export" + } + ] +}); + verify.navigationBar([ { "text": "\"my fil\\\"e\"", diff --git a/tests/cases/fourslash/navigationBarItemsItemsModuleVariables.ts b/tests/cases/fourslash/navigationBarItemsItemsModuleVariables.ts index 9b8a65d0430..1beeffddb21 100644 --- a/tests/cases/fourslash/navigationBarItemsItemsModuleVariables.ts +++ b/tests/cases/fourslash/navigationBarItemsItemsModuleVariables.ts @@ -20,6 +20,23 @@ ////} goTo.marker("file1"); // nothing else should show up +verify.navigationTree({ + "text": "", + "kind": "script", + "childItems": [ + { + "text": "Module1", + "kind": "module", + "childItems": [ + { + "text": "x", + "kind": "var", + "kindModifiers": "export" + } + ] + } + ] +}); verify.navigationBar([ { "text": "", @@ -46,6 +63,23 @@ verify.navigationBar([ ]); goTo.marker("file2"); +verify.navigationTree({ + "text": "", + "kind": "script", + "childItems": [ + { + "text": "Module1.SubModule", + "kind": "module", + "childItems": [ + { + "text": "y", + "kind": "var", + "kindModifiers": "export" + } + ] + } + ] +}); verify.navigationBar([ { "text": "", diff --git a/tests/cases/fourslash/navigationBarItemsMissingName1.ts b/tests/cases/fourslash/navigationBarItemsMissingName1.ts index 2a445a5e1ed..60123d92e71 100644 --- a/tests/cases/fourslash/navigationBarItemsMissingName1.ts +++ b/tests/cases/fourslash/navigationBarItemsMissingName1.ts @@ -3,6 +3,28 @@ //// foo() {} ////} +verify.navigationTree({ + "text": "\"navigationBarItemsMissingName1\"", + "kind": "module", + "childItems": [ + { + "text": "", + "kind": "function", + "kindModifiers": "export" + }, + { + "text": "C", + "kind": "class", + "childItems": [ + { + "text": "foo", + "kind": "method" + } + ] + } + ] +}); + verify.navigationBar([ { "text": "\"navigationBarItemsMissingName1\"", diff --git a/tests/cases/fourslash/navigationBarItemsMissingName2.ts b/tests/cases/fourslash/navigationBarItemsMissingName2.ts index 9faeb6de902..ce92128c825 100644 --- a/tests/cases/fourslash/navigationBarItemsMissingName2.ts +++ b/tests/cases/fourslash/navigationBarItemsMissingName2.ts @@ -6,6 +6,23 @@ ////} // Anonymous classes are still included. +verify.navigationTree({ + "text": "", + "kind": "script", + "childItems": [ + { + "text": "", + "kind": "class", + "childItems": [ + { + "text": "foo", + "kind": "method" + } + ] + } + ] +}); + verify.navigationBar([ { "text": "", diff --git a/tests/cases/fourslash/navigationBarItemsModules.ts b/tests/cases/fourslash/navigationBarItemsModules.ts index a41c75de550..fd5907e2bc7 100644 --- a/tests/cases/fourslash/navigationBarItemsModules.ts +++ b/tests/cases/fourslash/navigationBarItemsModules.ts @@ -27,6 +27,73 @@ //We have 8 module keywords, and 4 var keywords. //The declarations of A.B.C.x do not get merged, so the 4 vars are independent. //The two 'A' modules, however, do get merged, so in reality we have 7 modules. +verify.navigationTree({ + "text": "", + "kind": "script", + "childItems": [ + { + "text": "'X2.Y2.Z2'", + "kind": "module", + "kindModifiers": "declare" + }, + { + "text": "\"X.Y.Z\"", + "kind": "module", + "kindModifiers": "declare" + }, + { + "text": "A", + "kind": "module", + "childItems": [ + { + "text": "B", + "kind": "module", + "childItems": [ + { + "text": "C", + "kind": "module", + "childItems": [ + { + "text": "x", + "kind": "var", + "kindModifiers": "declare" + } + ] + } + ] + }, + { + "text": "z", + "kind": "var", + "kindModifiers": "export" + } + ] + }, + { + "text": "A.B", + "kind": "module", + "childItems": [ + { + "text": "y", + "kind": "var", + "kindModifiers": "export" + } + ] + }, + { + "text": "A.B.C", + "kind": "module", + "childItems": [ + { + "text": "x", + "kind": "var", + "kindModifiers": "export" + } + ] + } + ] +}); + verify.navigationBar([ { "text": "", diff --git a/tests/cases/fourslash/navigationBarItemsMultilineStringIdentifiers.ts b/tests/cases/fourslash/navigationBarItemsMultilineStringIdentifiers.ts index dcf8894bb61..793844ac970 100644 --- a/tests/cases/fourslash/navigationBarItemsMultilineStringIdentifiers.ts +++ b/tests/cases/fourslash/navigationBarItemsMultilineStringIdentifiers.ts @@ -24,6 +24,56 @@ //// } ////} +verify.navigationTree({ + "text": "", + "kind": "script", + "childItems": [ + { + "text": "\"Multiline\\\nMadness\"", + "kind": "module", + "kindModifiers": "declare" + }, + { + "text": "\"Multiline\\r\\nMadness\"", + "kind": "module", + "kindModifiers": "declare" + }, + { + "text": "\"MultilineMadness\"", + "kind": "module", + "kindModifiers": "declare" + }, + { + "text": "Bar", + "kind": "class", + "childItems": [ + { + "text": "'a1\\\\\\r\\nb'", + "kind": "property" + }, + { + "text": "'a2\\\n \\\n b'", + "kind": "method" + } + ] + }, + { + "text": "Foo", + "kind": "interface", + "childItems": [ + { + "text": "\"a1\\\\\\r\\nb\"", + "kind": "property" + }, + { + "text": "\"a2\\\n \\\n b\"", + "kind": "method" + } + ] + } + ] +}); + verify.navigationBar([ { "text": "", diff --git a/tests/cases/fourslash/navigationBarItemsPropertiesDefinedInConstructors.ts b/tests/cases/fourslash/navigationBarItemsPropertiesDefinedInConstructors.ts index b741084dab5..6e8e0ea350c 100644 --- a/tests/cases/fourslash/navigationBarItemsPropertiesDefinedInConstructors.ts +++ b/tests/cases/fourslash/navigationBarItemsPropertiesDefinedInConstructors.ts @@ -6,6 +6,43 @@ //// } ////} +verify.navigationTree({ + "text": "", + "kind": "script", + "childItems": [ + { + "text": "List", + "kind": "class", + "childItems": [ + { + "text": "constructor", + "kind": "constructor", + "childItems": [ + { + "text": "local", + "kind": "var" + } + ] + }, + { + "text": "a", + "kind": "property", + "kindModifiers": "public" + }, + { + "text": "b", + "kind": "property", + "kindModifiers": "private" + }, + { + "text": "c", + "kind": "property" + } + ] + } + ] +}); + verify.navigationBar([ { "text": "", diff --git a/tests/cases/fourslash/navigationBarItemsSymbols1.ts b/tests/cases/fourslash/navigationBarItemsSymbols1.ts index ba57916028b..4326d7b4deb 100644 --- a/tests/cases/fourslash/navigationBarItemsSymbols1.ts +++ b/tests/cases/fourslash/navigationBarItemsSymbols1.ts @@ -6,6 +6,31 @@ //// get [Symbol.isConcatSpreadable]() { } ////} +verify.navigationTree({ + "text": "", + "kind": "script", + "childItems": [ + { + "text": "C", + "kind": "class", + "childItems": [ + { + "text": "[Symbol.isConcatSpreadable]", + "kind": "getter" + }, + { + "text": "[Symbol.isRegExp]", + "kind": "property" + }, + { + "text": "[Symbol.iterator]", + "kind": "method" + } + ] + } + ] +}); + verify.navigationBar([ { "text": "", diff --git a/tests/cases/fourslash/navigationBarItemsSymbols2.ts b/tests/cases/fourslash/navigationBarItemsSymbols2.ts index 6812c88c150..64b076aaf0c 100644 --- a/tests/cases/fourslash/navigationBarItemsSymbols2.ts +++ b/tests/cases/fourslash/navigationBarItemsSymbols2.ts @@ -5,6 +5,27 @@ //// [Symbol.iterator](): string; ////} +verify.navigationTree({ + "text": "", + "kind": "script", + "childItems": [ + { + "text": "I", + "kind": "interface", + "childItems": [ + { + "text": "[Symbol.isRegExp]", + "kind": "property" + }, + { + "text": "[Symbol.iterator]", + "kind": "method" + } + ] + } + ] +}); + verify.navigationBar([ { "text": "", diff --git a/tests/cases/fourslash/navigationBarItemsSymbols3.ts b/tests/cases/fourslash/navigationBarItemsSymbols3.ts index 661005b86d9..be001c75e0b 100644 --- a/tests/cases/fourslash/navigationBarItemsSymbols3.ts +++ b/tests/cases/fourslash/navigationBarItemsSymbols3.ts @@ -5,6 +5,17 @@ //// [Symbol.isRegExp] = 0 ////} +verify.navigationTree({ + "text": "", + "kind": "script", + "childItems": [ + { + "text": "E", + "kind": "enum" + } + ] +}); + verify.navigationBar([ { "text": "", diff --git a/tests/cases/fourslash/navigationBarItemsTypeAlias.ts b/tests/cases/fourslash/navigationBarItemsTypeAlias.ts index cba3fb8789c..387a9925d82 100644 --- a/tests/cases/fourslash/navigationBarItemsTypeAlias.ts +++ b/tests/cases/fourslash/navigationBarItemsTypeAlias.ts @@ -2,6 +2,17 @@ ////type T = number | string; +verify.navigationTree({ + "text": "", + "kind": "script", + "childItems": [ + { + "text": "T", + "kind": "type" + } + ] +}); + verify.navigationBar([ { "text": "", diff --git a/tests/cases/fourslash/navigationBarJsDoc.ts b/tests/cases/fourslash/navigationBarJsDoc.ts index 89049e6011a..8efce74d111 100644 --- a/tests/cases/fourslash/navigationBarJsDoc.ts +++ b/tests/cases/fourslash/navigationBarJsDoc.ts @@ -5,6 +5,25 @@ /////** @typedef {(string|number)} */ ////const x = 0; +verify.navigationTree({ + "text": "", + "kind": "script", + "childItems": [ + { + "text": "NumberLike", + "kind": "type" + }, + { + "text": "x", + "kind": "const" + }, + { + "text": "x", + "kind": "type" + } + ] +}); + verify.navigationBar([ { "text": "", diff --git a/tests/cases/fourslash/navigationBarJsDocCommentWithNoTags.ts b/tests/cases/fourslash/navigationBarJsDocCommentWithNoTags.ts index 8746f135e4d..561bdf4a056 100644 --- a/tests/cases/fourslash/navigationBarJsDocCommentWithNoTags.ts +++ b/tests/cases/fourslash/navigationBarJsDocCommentWithNoTags.ts @@ -3,6 +3,18 @@ /////** Test */ ////export const Test = {} +verify.navigationTree({ + "text": "\"navigationBarJsDocCommentWithNoTags\"", + "kind": "module", + "childItems": [ + { + "text": "Test", + "kind": "const", + "kindModifiers": "export" + } + ] +}); + verify.navigationBar([ { "text": "\"navigationBarJsDocCommentWithNoTags\"", diff --git a/tests/cases/fourslash/navigationBarMerging.ts b/tests/cases/fourslash/navigationBarMerging.ts index 2798d186c96..ebf02c94466 100644 --- a/tests/cases/fourslash/navigationBarMerging.ts +++ b/tests/cases/fourslash/navigationBarMerging.ts @@ -11,6 +11,37 @@ //// function bar() {} ////} +verify.navigationTree({ + "text": "", + "kind": "script", + "childItems": [ + { + "text": "a", + "kind": "module", + "childItems": [ + { + "text": "bar", + "kind": "function" + }, + { + "text": "foo", + "kind": "function" + } + ] + }, + { + "text": "b", + "kind": "module", + "childItems": [ + { + "text": "foo", + "kind": "function" + } + ] + } + ] +}); + verify.navigationBar([ { "text": "", @@ -60,6 +91,22 @@ verify.navigationBar([ ////function a() {} goTo.file("file2.ts"); + +verify.navigationTree({ + "text": "", + "kind": "script", + "childItems": [ + { + "text": "a", + "kind": "function" + }, + { + "text": "a", + "kind": "module" + } + ] +}); + verify.navigationBar([ { "text": "", @@ -101,6 +148,34 @@ verify.navigationBar([ ////} goTo.file("file3.ts"); + +verify.navigationTree({ + "text": "", + "kind": "script", + "childItems": [ + { + "text": "a", + "kind": "module", + "childItems": [ + { + "text": "A", + "kind": "interface", + "childItems": [ + { + "text": "bar", + "kind": "property" + }, + { + "text": "foo", + "kind": "property" + } + ] + } + ] + } + ] +}); + verify.navigationBar([ { "text": "", @@ -147,6 +222,36 @@ verify.navigationBar([ ////module A.B { export var y; } goTo.file("file4.ts"); + +verify.navigationTree({ + "text": "", + "kind": "script", + "childItems": [ + { + "text": "A", + "kind": "module", + "childItems": [ + { + "text": "x", + "kind": "var", + "kindModifiers": "export" + } + ] + }, + { + "text": "A.B", + "kind": "module", + "childItems": [ + { + "text": "y", + "kind": "var", + "kindModifiers": "export" + } + ] + } + ] +}); + verify.navigationBar([ { "text": "", diff --git a/tests/cases/fourslash/navigationBarNamespaceImportWithNoName.ts b/tests/cases/fourslash/navigationBarNamespaceImportWithNoName.ts index 732e2deb1dd..4c441728fdf 100644 --- a/tests/cases/fourslash/navigationBarNamespaceImportWithNoName.ts +++ b/tests/cases/fourslash/navigationBarNamespaceImportWithNoName.ts @@ -1,4 +1,16 @@ ////import *{} from 'foo'; + +verify.navigationTree({ + "text": "\"navigationBarNamespaceImportWithNoName\"", + "kind": "module", + "childItems": [ + { + "text": "", + "kind": "alias" + } + ] +}); + verify.navigationBar([ { "text": "\"navigationBarNamespaceImportWithNoName\"", diff --git a/tests/cases/fourslash/navigationBarVariables.ts b/tests/cases/fourslash/navigationBarVariables.ts index 93093df1306..98d5e816e8e 100644 --- a/tests/cases/fourslash/navigationBarVariables.ts +++ b/tests/cases/fourslash/navigationBarVariables.ts @@ -4,6 +4,25 @@ ////let y = 1; ////const z = 2; +verify.navigationTree({ + "text": "", + "kind": "script", + "childItems": [ + { + "text": "x", + "kind": "var" + }, + { + "text": "y", + "kind": "let" + }, + { + "text": "z", + "kind": "const" + } + ] +}); + verify.navigationBar([ { "text": "", @@ -31,6 +50,26 @@ verify.navigationBar([ ////const [c] = 0; goTo.file("file2.ts"); + +verify.navigationTree({ + "text": "", + "kind": "script", + "childItems": [ + { + "text": "a", + "kind": "var" + }, + { + "text": "b", + "kind": "let" + }, + { + "text": "c", + "kind": "const" + } + ] +}); + verify.navigationBar([ { "text": "", diff --git a/tests/cases/fourslash/server/jsdocTypedefTagNavigateTo.ts b/tests/cases/fourslash/server/jsdocTypedefTagNavigateTo.ts index 978db18ab3b..212394159a8 100644 --- a/tests/cases/fourslash/server/jsdocTypedefTagNavigateTo.ts +++ b/tests/cases/fourslash/server/jsdocTypedefTagNavigateTo.ts @@ -10,6 +10,29 @@ //// /** @type {/*1*/NumberLike} */ //// var numberLike; +verify.navigationTree({ + "text": "", + "kind": "script", + "childItems": [ + { + "text": "numberLike", + "kind": "var" + }, + { + "text": "NumberLike", + "kind": "type" + }, + { + "text": "NumberLike2", + "kind": "var" + }, + { + "text": "NumberLike2", + "kind": "type" + } + ] +}); + verify.navigationBar([ { "text": "", diff --git a/tests/cases/fourslash/server/navbar01.ts b/tests/cases/fourslash/server/navbar01.ts index a5b22ee1fa9..4a4f59bcf78 100644 --- a/tests/cases/fourslash/server/navbar01.ts +++ b/tests/cases/fourslash/server/navbar01.ts @@ -38,6 +38,114 @@ ////var p: IPoint = new Shapes.Point(3, 4); ////var dist = p.getDist(); +verify.navigationTree({ + "text": "", + "kind": "script", + "childItems": [ + { + "text": "dist", + "kind": "var" + }, + { + "text": "IPoint", + "kind": "interface", + "childItems": [ + { + "text": "()", + "kind": "call" + }, + { + "text": "new()", + "kind": "construct" + }, + { + "text": "[]", + "kind": "index" + }, + { + "text": "getDist", + "kind": "method" + }, + { + "text": "prop", + "kind": "property" + } + ] + }, + { + "text": "p", + "kind": "var" + }, + { + "text": "Shapes", + "kind": "module", + "childItems": [ + { + "text": "Point", + "kind": "class", + "kindModifiers": "export", + "childItems": [ + { + "text": "constructor", + "kind": "constructor" + }, + { + "text": "getDist", + "kind": "method" + }, + { + "text": "getOrigin", + "kind": "method", + "kindModifiers": "private,static" + }, + { + "text": "origin", + "kind": "property", + "kindModifiers": "static" + }, + { + "text": "value", + "kind": "getter" + }, + { + "text": "value", + "kind": "setter" + }, + { + "text": "x", + "kind": "property", + "kindModifiers": "public" + }, + { + "text": "y", + "kind": "property", + "kindModifiers": "public" + } + ] + }, + { + "text": "Values", + "kind": "enum", + "childItems": [ + { + "text": "value1", + "kind": "const" + }, + { + "text": "value2", + "kind": "const" + }, + { + "text": "value3", + "kind": "const" + } + ] + } + ] + } + ] +}); + verify.navigationBar([ { "text": "", diff --git a/tests/cases/fourslash/shims-pp/getNavigationBarItems.ts b/tests/cases/fourslash/shims-pp/getNavigationBarItems.ts index fba24bdcf77..627d4dac178 100644 --- a/tests/cases/fourslash/shims-pp/getNavigationBarItems.ts +++ b/tests/cases/fourslash/shims-pp/getNavigationBarItems.ts @@ -2,6 +2,17 @@ //// {| "itemName": "c", "kind": "const", "parentName": "" |}const c = 0; +verify.navigationTree({ + "text": "", + "kind": "script", + "childItems": [ + { + "text": "c", + "kind": "const" + } + ] +}) + verify.navigationBar([ { "text": "", diff --git a/tests/cases/fourslash/shims/getNavigationBarItems.ts b/tests/cases/fourslash/shims/getNavigationBarItems.ts index fba24bdcf77..627d4dac178 100644 --- a/tests/cases/fourslash/shims/getNavigationBarItems.ts +++ b/tests/cases/fourslash/shims/getNavigationBarItems.ts @@ -2,6 +2,17 @@ //// {| "itemName": "c", "kind": "const", "parentName": "" |}const c = 0; +verify.navigationTree({ + "text": "", + "kind": "script", + "childItems": [ + { + "text": "c", + "kind": "const" + } + ] +}) + verify.navigationBar([ { "text": "", From e6b588a956d5046469dbfa240d35ab1cc09c0046 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 11 Oct 2016 10:14:06 -0700 Subject: [PATCH 046/173] Support parentheses and comma operator with evolving arrays --- src/compiler/binder.ts | 10 +++++----- src/compiler/checker.ts | 34 ++++++++++++++++++++++++---------- src/compiler/types.ts | 2 +- 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 1b121394a8c..6926403d9bb 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -760,7 +760,7 @@ namespace ts { }; } - function createFlowArrayMutation(antecedent: FlowNode, node: Expression): FlowNode { + function createFlowArrayMutation(antecedent: FlowNode, node: CallExpression | BinaryExpression): FlowNode { setFlowNodeReferenced(antecedent); return { flags: FlowFlags.ArrayMutation, @@ -1151,8 +1151,8 @@ namespace ts { bindAssignmentTargetFlow(node.left); if (node.left.kind === SyntaxKind.ElementAccessExpression) { const elementAccess = node.left; - if (isNarrowableReference(elementAccess.expression)) { - currentFlow = createFlowArrayMutation(currentFlow, elementAccess.expression); + if (isNarrowableOperand(elementAccess.expression)) { + currentFlow = createFlowArrayMutation(currentFlow, node); } } } @@ -1217,8 +1217,8 @@ namespace ts { } if (node.expression.kind === SyntaxKind.PropertyAccessExpression) { const propertyAccess = node.expression; - if (isNarrowableReference(propertyAccess.expression) && propertyAccess.name.text === "push") { - currentFlow = createFlowArrayMutation(currentFlow, propertyAccess.expression); + if (isNarrowableOperand(propertyAccess.expression) && propertyAccess.name.text === "push") { + currentFlow = createFlowArrayMutation(currentFlow, node); } } } diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2ff5700082a..379d61850e4 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8424,6 +8424,14 @@ namespace ts { return node; } + function getReferenceParent(node: Node): Node { + const parent = node.parent; + return parent.kind === SyntaxKind.ParenthesizedExpression || + parent.kind === SyntaxKind.BinaryExpression && (parent).operatorToken.kind === SyntaxKind.EqualsToken && (parent).left === node || + parent.kind === SyntaxKind.BinaryExpression && (parent).operatorToken.kind === SyntaxKind.CommaToken && (parent).right === node ? + getReferenceParent(parent) : parent; + } + function getTypeOfSwitchClause(clause: CaseClause | DefaultClause) { if (clause.kind === SyntaxKind.CaseClause) { const caseType = getRegularTypeOfLiteralType(checkExpression((clause).expression)); @@ -8556,15 +8564,16 @@ namespace ts { // Return true if the given node is 'x' in an 'x.push(value)' operation. function isPushCallTarget(node: Node) { - return node.parent.kind === SyntaxKind.PropertyAccessExpression && - (node.parent).name.text === "push" && - node.parent.parent.kind === SyntaxKind.CallExpression; + const parent = getReferenceParent(node); + return parent.kind === SyntaxKind.PropertyAccessExpression && + (parent).name.text === "push" && + parent.parent.kind === SyntaxKind.CallExpression; } // Return true if the given node is 'x' in an 'x[n] = value' operation, where 'n' is an // expression of type any, undefined, or a number-like type. function isElementAssignmentTarget(node: Node) { - const parent = node.parent; + const parent = getReferenceParent(node); return parent.kind === SyntaxKind.ElementAccessExpression && (parent).expression === node && parent.parent.kind === SyntaxKind.BinaryExpression && @@ -8696,19 +8705,24 @@ namespace ts { function getTypeAtFlowArrayMutation(flow: FlowArrayMutation): FlowType { const node = flow.node; - if (isMatchingReference(reference, node)) { + const expr = node.kind === SyntaxKind.CallExpression ? + ((node).expression).expression : + ((node).left).expression; + if (isMatchingReference(reference, getReferenceCandidate(expr))) { const flowType = getTypeAtFlowNode(flow.antecedent); const type = getTypeFromFlowType(flowType); if (isEvolvingArrayType(type)) { - const parent = node.parent; let evolvedType = type; - if (parent.kind === SyntaxKind.PropertyAccessExpression) { - for (const arg of (parent.parent).arguments) { + if (node.kind === SyntaxKind.CallExpression) { + for (const arg of (node).arguments) { evolvedType = addEvolvingArrayElementType(evolvedType, arg); } } - else if (isTypeAnyOrAllConstituentTypesHaveKind(checkExpression((parent).argumentExpression), TypeFlags.NumberLike)) { - evolvedType = addEvolvingArrayElementType(evolvedType, (parent.parent).right); + else { + const indexType = checkExpression(((node).left).argumentExpression); + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, TypeFlags.NumberLike | TypeFlags.Undefined)) { + evolvedType = addEvolvingArrayElementType(evolvedType, (node).right); + } } return evolvedType === type ? flowType : createFlowType(evolvedType, isIncomplete(flowType)); } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 9759c2ab540..5c32649d97c 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1955,7 +1955,7 @@ namespace ts { // FlowArrayMutation represents a node potentially mutates an array, i.e. an // operation of the form 'x.push(value)' or 'x[n] = value'. export interface FlowArrayMutation extends FlowNode { - node: Expression; + node: CallExpression | BinaryExpression; antecedent: FlowNode; } From 612ed1e24a0932b005a57d27092e39711046be10 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 11 Oct 2016 10:27:40 -0700 Subject: [PATCH 047/173] Fix minor issue --- src/compiler/checker.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 379d61850e4..9e2b7a31748 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8424,12 +8424,12 @@ namespace ts { return node; } - function getReferenceParent(node: Node): Node { + function getReferenceRoot(node: Node): Node { const parent = node.parent; return parent.kind === SyntaxKind.ParenthesizedExpression || parent.kind === SyntaxKind.BinaryExpression && (parent).operatorToken.kind === SyntaxKind.EqualsToken && (parent).left === node || parent.kind === SyntaxKind.BinaryExpression && (parent).operatorToken.kind === SyntaxKind.CommaToken && (parent).right === node ? - getReferenceParent(parent) : parent; + getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause: CaseClause | DefaultClause) { @@ -8564,7 +8564,7 @@ namespace ts { // Return true if the given node is 'x' in an 'x.push(value)' operation. function isPushCallTarget(node: Node) { - const parent = getReferenceParent(node); + const parent = getReferenceRoot(node).parent; return parent.kind === SyntaxKind.PropertyAccessExpression && (parent).name.text === "push" && parent.parent.kind === SyntaxKind.CallExpression; @@ -8573,9 +8573,10 @@ namespace ts { // Return true if the given node is 'x' in an 'x[n] = value' operation, where 'n' is an // expression of type any, undefined, or a number-like type. function isElementAssignmentTarget(node: Node) { - const parent = getReferenceParent(node); + const root = getReferenceRoot(node); + const parent = root.parent; return parent.kind === SyntaxKind.ElementAccessExpression && - (parent).expression === node && + (parent).expression === root && parent.parent.kind === SyntaxKind.BinaryExpression && (parent.parent).operatorToken.kind === SyntaxKind.EqualsToken && (parent.parent).left === parent && From e9858de363e22b0f0318ef8b2848306e944aff50 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 11 Oct 2016 10:28:13 -0700 Subject: [PATCH 048/173] Add test --- tests/cases/compiler/controlFlowArrays.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/cases/compiler/controlFlowArrays.ts b/tests/cases/compiler/controlFlowArrays.ts index 781b8c09d12..e89a2443753 100644 --- a/tests/cases/compiler/controlFlowArrays.ts +++ b/tests/cases/compiler/controlFlowArrays.ts @@ -147,4 +147,13 @@ function f15() { x.push("hello"); } return x; // string[] +} + +function f16() { + let x; + let y; + (x = [], x).push(5); + (x.push("hello"), x).push(true); + ((x))[3] = { a: 1 }; + return x; // (string | number | boolean | { a: number })[] } \ No newline at end of file From c9e2f959184beda9e25ee97d186a5dea0f44bb88 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 11 Oct 2016 10:32:00 -0700 Subject: [PATCH 049/173] Accept new baselines --- .../baselines/reference/controlFlowArrays.js | 17 +++++++ .../reference/controlFlowArrays.symbols | 31 ++++++++++++ .../reference/controlFlowArrays.types | 50 +++++++++++++++++++ 3 files changed, 98 insertions(+) diff --git a/tests/baselines/reference/controlFlowArrays.js b/tests/baselines/reference/controlFlowArrays.js index c5ec1a7642c..d6f387ab981 100644 --- a/tests/baselines/reference/controlFlowArrays.js +++ b/tests/baselines/reference/controlFlowArrays.js @@ -146,6 +146,15 @@ function f15() { x.push("hello"); } return x; // string[] +} + +function f16() { + let x; + let y; + (x = [], x).push(5); + (x.push("hello"), x).push(true); + ((x))[3] = { a: 1 }; + return x; // (string | number | boolean | { a: number })[] } //// [controlFlowArrays.js] @@ -282,3 +291,11 @@ function f15() { } return x; // string[] } +function f16() { + var x; + var y; + (x = [], x).push(5); + (x.push("hello"), x).push(true); + ((x))[3] = { a: 1 }; + return x; // (string | number | boolean | { a: number })[] +} diff --git a/tests/baselines/reference/controlFlowArrays.symbols b/tests/baselines/reference/controlFlowArrays.symbols index fd7c6ba89b7..204a2171992 100644 --- a/tests/baselines/reference/controlFlowArrays.symbols +++ b/tests/baselines/reference/controlFlowArrays.symbols @@ -369,3 +369,34 @@ function f15() { return x; // string[] >x : Symbol(x, Decl(controlFlowArrays.ts, 141, 7)) } + +function f16() { +>f16 : Symbol(f16, Decl(controlFlowArrays.ts, 147, 1)) + + let x; +>x : Symbol(x, Decl(controlFlowArrays.ts, 150, 7)) + + let y; +>y : Symbol(y, Decl(controlFlowArrays.ts, 151, 7)) + + (x = [], x).push(5); +>(x = [], x).push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 150, 7)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 150, 7)) +>push : Symbol(Array.push, Decl(lib.d.ts, --, --)) + + (x.push("hello"), x).push(true); +>(x.push("hello"), x).push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 150, 7)) +>push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 150, 7)) +>push : Symbol(Array.push, Decl(lib.d.ts, --, --)) + + ((x))[3] = { a: 1 }; +>x : Symbol(x, Decl(controlFlowArrays.ts, 150, 7)) +>a : Symbol(a, Decl(controlFlowArrays.ts, 154, 16)) + + return x; // (string | number | boolean | { a: number })[] +>x : Symbol(x, Decl(controlFlowArrays.ts, 150, 7)) +} diff --git a/tests/baselines/reference/controlFlowArrays.types b/tests/baselines/reference/controlFlowArrays.types index 3fb84215ed7..3a91ce7e197 100644 --- a/tests/baselines/reference/controlFlowArrays.types +++ b/tests/baselines/reference/controlFlowArrays.types @@ -471,3 +471,53 @@ function f15() { return x; // string[] >x : string[] } + +function f16() { +>f16 : () => (string | number | boolean | { a: number; })[] + + let x; +>x : any + + let y; +>y : any + + (x = [], x).push(5); +>(x = [], x).push(5) : number +>(x = [], x).push : (...items: any[]) => number +>(x = [], x) : any[] +>x = [], x : any[] +>x = [] : never[] +>x : any +>[] : never[] +>x : any[] +>push : (...items: any[]) => number +>5 : 5 + + (x.push("hello"), x).push(true); +>(x.push("hello"), x).push(true) : number +>(x.push("hello"), x).push : (...items: any[]) => number +>(x.push("hello"), x) : any[] +>x.push("hello"), x : any[] +>x.push("hello") : number +>x.push : (...items: any[]) => number +>x : any[] +>push : (...items: any[]) => number +>"hello" : "hello" +>x : any[] +>push : (...items: any[]) => number +>true : true + + ((x))[3] = { a: 1 }; +>((x))[3] = { a: 1 } : { a: number; } +>((x))[3] : any +>((x)) : any[] +>(x) : any[] +>x : any[] +>3 : 3 +>{ a: 1 } : { a: number; } +>a : number +>1 : 1 + + return x; // (string | number | boolean | { a: number })[] +>x : (string | number | boolean | { a: number; })[] +} From 413a26b94d4cea5d0b1b3aa08ee149794437df77 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 11 Oct 2016 11:14:15 -0700 Subject: [PATCH 050/173] Support JSDoc for type alias --- src/compiler/parser.ts | 2 +- tests/cases/fourslash/jsDocForTypeAlias.ts | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/jsDocForTypeAlias.ts diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index aaf3b4ebecc..62ae61e4cb4 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -5352,7 +5352,7 @@ namespace ts { parseExpected(SyntaxKind.EqualsToken); node.type = parseType(); parseSemicolon(); - return finishNode(node); + return addJSDocComment(finishNode(node)); } // In an ambient declaration, the grammar only allows integer literals as initializers. diff --git a/tests/cases/fourslash/jsDocForTypeAlias.ts b/tests/cases/fourslash/jsDocForTypeAlias.ts new file mode 100644 index 00000000000..dbda7ccbc13 --- /dev/null +++ b/tests/cases/fourslash/jsDocForTypeAlias.ts @@ -0,0 +1,7 @@ +/// + +/////** DOC */ +////type /**/T = number + +goTo.marker(); +verify.quickInfoIs("type T = number", "DOC "); From 2671668d8637d8984b8f861e1234ab06e70730e8 Mon Sep 17 00:00:00 2001 From: Zhengbo Li Date: Tue, 11 Oct 2016 13:41:04 -0700 Subject: [PATCH 051/173] Remove cached resolvedModule result if the target file was deleted (#11460) * Add test first for debugging * Remove cached resolvedModule if the file was deleted * Move the fix to lsHost * Properly clean lastDeletedFile * Remove unused builder API * move the delete file check into module name valid check --- .../unittests/tsserverProjectSystem.ts | 133 +++++++++++++++++- src/server/editorServices.ts | 6 +- src/server/lsHost.ts | 10 +- 3 files changed, 144 insertions(+), 5 deletions(-) diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index f2decc1c339..b758761ee76 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -2097,7 +2097,7 @@ namespace ts.projectSystem { const projectFileName = "externalProject"; const host = createServerHost([f]); const projectService = createProjectService(host); - // create a project + // create a project projectService.openExternalProject({ projectFileName, rootFiles: [toExternalFile(f.path)], options: {} }); projectService.checkNumberOfProjects({ externalProjects: 1 }); @@ -2135,6 +2135,137 @@ namespace ts.projectSystem { }); }); + describe("rename a module file and rename back", () => { + it("should restore the states for inferred projects", () => { + const moduleFile = { + path: "/a/b/moduleFile.ts", + content: "export function bar() { };" + }; + const file1 = { + path: "/a/b/file1.ts", + content: "import * as T from './moduleFile'; T.bar();" + }; + const host = createServerHost([moduleFile, file1]); + const session = createSession(host); + + openFilesForSession([file1], session); + const getErrRequest = makeSessionRequest( + server.CommandNames.SemanticDiagnosticsSync, + { file: file1.path } + ); + let diags = session.executeCommand(getErrRequest).response; + assert.equal(diags.length, 0); + + const moduleFileOldPath = moduleFile.path; + const moduleFileNewPath = "/a/b/moduleFile1.ts"; + moduleFile.path = moduleFileNewPath; + host.reloadFS([moduleFile, file1]); + host.triggerFileWatcherCallback(moduleFileOldPath); + host.triggerDirectoryWatcherCallback("/a/b", moduleFile.path); + host.runQueuedTimeoutCallbacks(); + diags = session.executeCommand(getErrRequest).response; + assert.equal(diags.length, 1); + + moduleFile.path = moduleFileOldPath; + host.reloadFS([moduleFile, file1]); + host.triggerFileWatcherCallback(moduleFileNewPath); + host.triggerDirectoryWatcherCallback("/a/b", moduleFile.path); + host.runQueuedTimeoutCallbacks(); + + // Make a change to trigger the program rebuild + const changeRequest = makeSessionRequest( + server.CommandNames.Change, + { file: file1.path, line: 1, offset: 44, endLine: 1, endOffset: 44, insertString: "\n" } + ); + session.executeCommand(changeRequest); + host.runQueuedTimeoutCallbacks(); + + diags = session.executeCommand(getErrRequest).response; + assert.equal(diags.length, 0); + }); + + it("should restore the states for configured projects", () => { + const moduleFile = { + path: "/a/b/moduleFile.ts", + content: "export function bar() { };" + }; + const file1 = { + path: "/a/b/file1.ts", + content: "import * as T from './moduleFile'; T.bar();" + }; + const configFile = { + path: "/a/b/tsconfig.json", + content: `{}` + }; + const host = createServerHost([moduleFile, file1, configFile]); + const session = createSession(host); + + openFilesForSession([file1], session); + const getErrRequest = makeSessionRequest( + server.CommandNames.SemanticDiagnosticsSync, + { file: file1.path } + ); + let diags = session.executeCommand(getErrRequest).response; + assert.equal(diags.length, 0); + + const moduleFileOldPath = moduleFile.path; + const moduleFileNewPath = "/a/b/moduleFile1.ts"; + moduleFile.path = moduleFileNewPath; + host.reloadFS([moduleFile, file1, configFile]); + host.triggerFileWatcherCallback(moduleFileOldPath); + host.triggerDirectoryWatcherCallback("/a/b", moduleFile.path); + host.runQueuedTimeoutCallbacks(); + diags = session.executeCommand(getErrRequest).response; + assert.equal(diags.length, 1); + + moduleFile.path = moduleFileOldPath; + host.reloadFS([moduleFile, file1, configFile]); + host.triggerFileWatcherCallback(moduleFileNewPath); + host.triggerDirectoryWatcherCallback("/a/b", moduleFile.path); + host.runQueuedTimeoutCallbacks(); + diags = session.executeCommand(getErrRequest).response; + assert.equal(diags.length, 0); + }); + + }); + + describe("add the missing module file for inferred project", () => { + it("should remove the `module not found` error", () => { + const moduleFile = { + path: "/a/b/moduleFile.ts", + content: "export function bar() { };" + }; + const file1 = { + path: "/a/b/file1.ts", + content: "import * as T from './moduleFile'; T.bar();" + }; + const host = createServerHost([file1]); + const session = createSession(host); + openFilesForSession([file1], session); + const getErrRequest = makeSessionRequest( + server.CommandNames.SemanticDiagnosticsSync, + { file: file1.path } + ); + let diags = session.executeCommand(getErrRequest).response; + assert.equal(diags.length, 1); + + host.reloadFS([file1, moduleFile]); + host.triggerDirectoryWatcherCallback(getDirectoryPath(file1.path), moduleFile.path); + host.runQueuedTimeoutCallbacks(); + + // Make a change to trigger the program rebuild + const changeRequest = makeSessionRequest( + server.CommandNames.Change, + { file: file1.path, line: 1, offset: 44, endLine: 1, endOffset: 44, insertString: "\n" } + ); + session.executeCommand(changeRequest); + + // Recheck + diags = session.executeCommand(getErrRequest).response; + assert.equal(diags.length, 0); + }); + }); + describe("Configure file diagnostics events", () => { it("are generated when the config file has errors", () => { diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 50dd5612da8..dc2c45156cd 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -180,6 +180,8 @@ namespace ts.server { private toCanonicalFileName: (f: string) => string; + public lastDeletedFile: ScriptInfo; + constructor(public readonly host: ServerHost, public readonly logger: Logger, public readonly cancellationToken: HostCancellationToken, @@ -272,7 +274,7 @@ namespace ts.server { else { projectsToUpdate = []; for (const f of this.changedFiles) { - projectsToUpdate = projectsToUpdate.concat(f.containingProjects); + projectsToUpdate = projectsToUpdate.concat(f.containingProjects); } } this.updateProjectGraphs(projectsToUpdate); @@ -342,6 +344,7 @@ namespace ts.server { if (!info.isOpen) { this.filenameToScriptInfo.remove(info.path); + this.lastDeletedFile = info; // capture list of projects since detachAllProjects will wipe out original list const containingProjects = info.containingProjects.slice(); @@ -350,6 +353,7 @@ namespace ts.server { // update projects to make sure that set of referenced files is correct this.updateProjectGraphs(containingProjects); + this.lastDeletedFile = undefined; if (!this.eventHandler) { return; diff --git a/src/server/lsHost.ts b/src/server/lsHost.ts index dedbb14c929..b36f73a19c5 100644 --- a/src/server/lsHost.ts +++ b/src/server/lsHost.ts @@ -52,7 +52,7 @@ namespace ts.server { }; } - private resolveNamesWithLocalCache( + private resolveNamesWithLocalCache( names: string[], containingFile: string, cache: ts.FileMap>, @@ -65,6 +65,7 @@ namespace ts.server { const newResolutions: Map = createMap(); const resolvedModules: R[] = []; const compilerOptions = this.getCompilationSettings(); + const lastDeletedFileName = this.project.projectService.lastDeletedFile && this.project.projectService.lastDeletedFile.fileName; for (const name of names) { // check if this is a duplicate entry in the list @@ -94,8 +95,11 @@ namespace ts.server { return false; } - if (getResult(resolution)) { - // TODO: consider checking failedLookupLocations + const result = getResult(resolution); + if (result) { + if (result.resolvedFileName && result.resolvedFileName === lastDeletedFileName) { + return false; + } return true; } From d7e33c90a2fb6748c39630fc2a9f5d8e8272e9a7 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Tue, 11 Oct 2016 13:51:53 -0700 Subject: [PATCH 052/173] Guard localeCompare function --- src/compiler/core.ts | 22 ++++++++++++++++++++-- src/harness/harness.ts | 2 +- src/server/session.ts | 2 +- src/services/navigateTo.ts | 4 ++-- src/services/navigationBar.ts | 6 ++---- 5 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 7c68306211a..5ad9fa2c199 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -20,6 +20,24 @@ namespace ts { const createObject = Object.create; + // More efficient to create a collator once and use its `compare` than to call `a.localeCompare(b)` many times. + export const collator: { compare(a: string, b: string): number } = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; + + /** + * Use this function instead of calling "String.prototype.localeCompre". This function will preform appropriate check to make sure that + * "typeof Intl" is correct as there are reported issues #11110 nad #11339. + * @param a reference string to compare + * @param b string to compare against + * @param locales string of BCP 47 language tag or an array of string of BCP 47 language tag + * @param options an object of Intl.CollatorOptions to specify localeCompare properties + */ + export function localeCompare(a: string, b: string, locales?: string | string[], options?: Intl.CollatorOptions): number | undefined { + if (collator && String.prototype.localeCompare) { + return a.localeCompare(b, locales, options); + } + return undefined; + } + export function createMap(template?: MapLike): Map { const map: Map = createObject(null); // tslint:disable-line:no-null-keyword @@ -1016,8 +1034,8 @@ namespace ts { if (a === undefined) return Comparison.LessThan; if (b === undefined) return Comparison.GreaterThan; if (ignoreCase) { - if (String.prototype.localeCompare) { - const result = a.localeCompare(b, /*locales*/ undefined, { usage: "sort", sensitivity: "accent" }); + const result = localeCompare(a, b, /*locales*/ undefined, /*options*/ { usage: "sort", sensitivity: "accent" }); + if (result) { return result < 0 ? Comparison.LessThan : result > 0 ? Comparison.GreaterThan : Comparison.EqualTo; } diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 7c82aeece78..f26a9dd062b 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1634,7 +1634,7 @@ namespace Harness { export function collateOutputs(outputFiles: Harness.Compiler.GeneratedFile[]): string { // Collect, test, and sort the fileNames - outputFiles.sort((a, b) => cleanName(a.fileName).localeCompare(cleanName(b.fileName))); + outputFiles.sort((a, b) => ts.localeCompare(cleanName(a.fileName), cleanName(b.fileName))); // Emit them let result = ""; diff --git a/src/server/session.ts b/src/server/session.ts index 3b95bdd6fb9..d4633f119e3 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -959,7 +959,7 @@ namespace ts.server { result.push({ name, kind, kindModifiers, sortText, replacementSpan: convertedSpan }); } return result; - }, []).sort((a, b) => a.name.localeCompare(b.name)); + }, []).sort((a, b) => localeCompare(a.name, b.name)); } else { return completions; diff --git a/src/services/navigateTo.ts b/src/services/navigateTo.ts index 44aa25f5005..8c968db7ebb 100644 --- a/src/services/navigateTo.ts +++ b/src/services/navigateTo.ts @@ -188,8 +188,8 @@ namespace ts.NavigateTo { // We first sort case insensitively. So "Aaa" will come before "bar". // Then we sort case sensitively, so "aaa" will come before "Aaa". return i1.matchKind - i2.matchKind || - i1.name.localeCompare(i2.name, undefined, baseSensitivity) || - i1.name.localeCompare(i2.name); + ts.localeCompare(i1.name, i2.name, /*locales*/ undefined, /*options*/ baseSensitivity) || + ts.localeCompare(i1.name, i2.name); } function createNavigateToItem(rawItem: RawNavigateToItem): NavigateToItem { diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index 0397ae73229..f981ad6016d 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -323,10 +323,8 @@ namespace ts.NavigationBar { } } - // More efficient to create a collator once and use its `compare` than to call `a.localeCompare(b)` many times. - const collator: { compare(a: string, b: string): number } = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; // Intl is missing in Safari, and node 0.10 treats "a" as greater than "B". - const localeCompareIsCorrect = collator && collator.compare("a", "B") < 0; + const localeCompareIsCorrect = ts.collator && ts.collator.compare("a", "B") < 0; const localeCompareFix: (a: string, b: string) => number = localeCompareIsCorrect ? collator.compare : function(a, b) { // This isn't perfect, but it passes all of our tests. for (let i = 0; i < Math.min(a.length, b.length); i++) { @@ -337,7 +335,7 @@ namespace ts.NavigationBar { if (chA === "'" && chB === "\"") { return -1; } - const cmp = chA.toLocaleLowerCase().localeCompare(chB.toLocaleLowerCase()); + const cmp = ts.localeCompare(chA.toLocaleLowerCase(), chB.toLocaleLowerCase()); if (cmp !== 0) { return cmp; } From dc516c050ab07f4b8a10355595ead436bbb568e5 Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Tue, 11 Oct 2016 17:30:49 -0700 Subject: [PATCH 053/173] Remove duplicate interface --- src/server/protocol.d.ts | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/server/protocol.d.ts b/src/server/protocol.d.ts index 3ef02d4e493..22799ee4759 100644 --- a/src/server/protocol.d.ts +++ b/src/server/protocol.d.ts @@ -1,4 +1,4 @@ -/** +/** * Declaration module describing the TypeScript Server protocol */ declare namespace ts.server.protocol { @@ -1592,16 +1592,4 @@ declare namespace ts.server.protocol { export interface NavBarResponse extends Response { body?: NavigationBarItem[]; } - - export interface CodeAction { - /** - * Description of the code action to display in the UI of the editor. - */ - description: string; - - /** - * Changes to apply to each file as part of the code action. - */ - changes: FileCodeEdits[]; - } } From a4e7bff759b7d23cca787ff205b4119b950e7fe5 Mon Sep 17 00:00:00 2001 From: Bill Ticehurst Date: Tue, 11 Oct 2016 17:51:53 -0700 Subject: [PATCH 054/173] Fixed errors with overloaded method exports --- src/compiler/checker.ts | 3 ++- .../completionListInImportClause04.ts | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/completionListInImportClause04.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b5fe19b0a80..273b5e06134 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -17893,7 +17893,8 @@ namespace ts { } function isNotOverload(declaration: Declaration): boolean { - return declaration.kind !== SyntaxKind.FunctionDeclaration || !!(declaration as FunctionDeclaration).body; + return (declaration.kind !== SyntaxKind.FunctionDeclaration && declaration.kind !== SyntaxKind.MethodDeclaration) || + !!(declaration as FunctionDeclaration).body; } } diff --git a/tests/cases/fourslash/completionListInImportClause04.ts b/tests/cases/fourslash/completionListInImportClause04.ts new file mode 100644 index 00000000000..672c754e807 --- /dev/null +++ b/tests/cases/fourslash/completionListInImportClause04.ts @@ -0,0 +1,20 @@ +/// + +// @Filename: foo.d.ts +//// declare class Foo { +//// static prop1(x: number): number; +//// static prop1(x: string): string; +//// static prop2(x: boolean): boolean; +//// } +//// export = Foo; /*2*/ + +// @Filename: app.ts +////import {/*1*/} from './foo'; + +goTo.marker('1'); +verify.completionListContains('prop1'); +verify.completionListContains('prop2'); +verify.not.completionListContains('Foo'); +verify.numberOfErrorsInCurrentFile(0); +goTo.marker('2'); +verify.numberOfErrorsInCurrentFile(0); From db5da0b85f7803f8f6bc17b2f8e2a2105a4ccc5b Mon Sep 17 00:00:00 2001 From: Bill Ticehurst Date: Tue, 11 Oct 2016 18:08:54 -0700 Subject: [PATCH 055/173] Reverted test change --- src/compiler/checker.ts | 2 +- .../reference/bluebirdStaticThis.errors.txt | 188 +----------------- 2 files changed, 2 insertions(+), 188 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 273b5e06134..a1a8ae0da5c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -17893,7 +17893,7 @@ namespace ts { } function isNotOverload(declaration: Declaration): boolean { - return (declaration.kind !== SyntaxKind.FunctionDeclaration && declaration.kind !== SyntaxKind.MethodDeclaration) || + return (declaration.kind !== SyntaxKind.FunctionDeclaration && declaration.kind !== SyntaxKind.MethodDeclaration) || !!(declaration as FunctionDeclaration).body; } } diff --git a/tests/baselines/reference/bluebirdStaticThis.errors.txt b/tests/baselines/reference/bluebirdStaticThis.errors.txt index a20c7ace880..1c22a12c341 100644 --- a/tests/baselines/reference/bluebirdStaticThis.errors.txt +++ b/tests/baselines/reference/bluebirdStaticThis.errors.txt @@ -1,75 +1,13 @@ tests/cases/compiler/bluebirdStaticThis.ts(5,15): error TS2420: Class 'Promise' incorrectly implements interface 'Thenable'. Property 'then' is missing in type 'Promise'. -tests/cases/compiler/bluebirdStaticThis.ts(7,12): error TS2323: Cannot redeclare exported variable 'try'. -tests/cases/compiler/bluebirdStaticThis.ts(8,12): error TS2323: Cannot redeclare exported variable 'try'. -tests/cases/compiler/bluebirdStaticThis.ts(10,12): error TS2323: Cannot redeclare exported variable 'attempt'. -tests/cases/compiler/bluebirdStaticThis.ts(11,12): error TS2323: Cannot redeclare exported variable 'attempt'. -tests/cases/compiler/bluebirdStaticThis.ts(15,12): error TS2323: Cannot redeclare exported variable 'resolve'. -tests/cases/compiler/bluebirdStaticThis.ts(16,12): error TS2323: Cannot redeclare exported variable 'resolve'. -tests/cases/compiler/bluebirdStaticThis.ts(17,12): error TS2323: Cannot redeclare exported variable 'resolve'. -tests/cases/compiler/bluebirdStaticThis.ts(19,12): error TS2323: Cannot redeclare exported variable 'reject'. -tests/cases/compiler/bluebirdStaticThis.ts(20,12): error TS2323: Cannot redeclare exported variable 'reject'. tests/cases/compiler/bluebirdStaticThis.ts(22,51): error TS2694: Namespace 'Promise' has no exported member 'Resolver'. -tests/cases/compiler/bluebirdStaticThis.ts(24,12): error TS2323: Cannot redeclare exported variable 'cast'. -tests/cases/compiler/bluebirdStaticThis.ts(25,12): error TS2323: Cannot redeclare exported variable 'cast'. -tests/cases/compiler/bluebirdStaticThis.ts(33,12): error TS2323: Cannot redeclare exported variable 'delay'. -tests/cases/compiler/bluebirdStaticThis.ts(34,12): error TS2323: Cannot redeclare exported variable 'delay'. -tests/cases/compiler/bluebirdStaticThis.ts(35,12): error TS2323: Cannot redeclare exported variable 'delay'. -tests/cases/compiler/bluebirdStaticThis.ts(49,12): error TS2323: Cannot redeclare exported variable 'all'. -tests/cases/compiler/bluebirdStaticThis.ts(50,12): error TS2323: Cannot redeclare exported variable 'all'. -tests/cases/compiler/bluebirdStaticThis.ts(51,12): error TS2323: Cannot redeclare exported variable 'all'. -tests/cases/compiler/bluebirdStaticThis.ts(52,12): error TS2323: Cannot redeclare exported variable 'all'. -tests/cases/compiler/bluebirdStaticThis.ts(54,12): error TS2323: Cannot redeclare exported variable 'props'. -tests/cases/compiler/bluebirdStaticThis.ts(55,12): error TS2323: Cannot redeclare exported variable 'props'. -tests/cases/compiler/bluebirdStaticThis.ts(57,12): error TS2323: Cannot redeclare exported variable 'settle'. tests/cases/compiler/bluebirdStaticThis.ts(57,109): error TS2694: Namespace 'Promise' has no exported member 'Inspection'. -tests/cases/compiler/bluebirdStaticThis.ts(58,12): error TS2323: Cannot redeclare exported variable 'settle'. tests/cases/compiler/bluebirdStaticThis.ts(58,91): error TS2694: Namespace 'Promise' has no exported member 'Inspection'. -tests/cases/compiler/bluebirdStaticThis.ts(59,12): error TS2323: Cannot redeclare exported variable 'settle'. tests/cases/compiler/bluebirdStaticThis.ts(59,91): error TS2694: Namespace 'Promise' has no exported member 'Inspection'. -tests/cases/compiler/bluebirdStaticThis.ts(60,12): error TS2323: Cannot redeclare exported variable 'settle'. tests/cases/compiler/bluebirdStaticThis.ts(60,73): error TS2694: Namespace 'Promise' has no exported member 'Inspection'. -tests/cases/compiler/bluebirdStaticThis.ts(62,12): error TS2323: Cannot redeclare exported variable 'any'. -tests/cases/compiler/bluebirdStaticThis.ts(63,12): error TS2323: Cannot redeclare exported variable 'any'. -tests/cases/compiler/bluebirdStaticThis.ts(64,12): error TS2323: Cannot redeclare exported variable 'any'. -tests/cases/compiler/bluebirdStaticThis.ts(65,12): error TS2323: Cannot redeclare exported variable 'any'. -tests/cases/compiler/bluebirdStaticThis.ts(67,12): error TS2323: Cannot redeclare exported variable 'race'. -tests/cases/compiler/bluebirdStaticThis.ts(68,12): error TS2323: Cannot redeclare exported variable 'race'. -tests/cases/compiler/bluebirdStaticThis.ts(69,12): error TS2323: Cannot redeclare exported variable 'race'. -tests/cases/compiler/bluebirdStaticThis.ts(70,12): error TS2323: Cannot redeclare exported variable 'race'. -tests/cases/compiler/bluebirdStaticThis.ts(72,12): error TS2323: Cannot redeclare exported variable 'some'. -tests/cases/compiler/bluebirdStaticThis.ts(73,12): error TS2323: Cannot redeclare exported variable 'some'. -tests/cases/compiler/bluebirdStaticThis.ts(74,12): error TS2323: Cannot redeclare exported variable 'some'. -tests/cases/compiler/bluebirdStaticThis.ts(75,12): error TS2323: Cannot redeclare exported variable 'some'. -tests/cases/compiler/bluebirdStaticThis.ts(77,12): error TS2323: Cannot redeclare exported variable 'join'. -tests/cases/compiler/bluebirdStaticThis.ts(78,12): error TS2323: Cannot redeclare exported variable 'join'. -tests/cases/compiler/bluebirdStaticThis.ts(80,12): error TS2323: Cannot redeclare exported variable 'map'. -tests/cases/compiler/bluebirdStaticThis.ts(81,12): error TS2323: Cannot redeclare exported variable 'map'. -tests/cases/compiler/bluebirdStaticThis.ts(82,12): error TS2323: Cannot redeclare exported variable 'map'. -tests/cases/compiler/bluebirdStaticThis.ts(83,12): error TS2323: Cannot redeclare exported variable 'map'. -tests/cases/compiler/bluebirdStaticThis.ts(84,12): error TS2323: Cannot redeclare exported variable 'map'. -tests/cases/compiler/bluebirdStaticThis.ts(85,12): error TS2323: Cannot redeclare exported variable 'map'. -tests/cases/compiler/bluebirdStaticThis.ts(86,12): error TS2323: Cannot redeclare exported variable 'map'. -tests/cases/compiler/bluebirdStaticThis.ts(87,12): error TS2323: Cannot redeclare exported variable 'map'. -tests/cases/compiler/bluebirdStaticThis.ts(89,12): error TS2323: Cannot redeclare exported variable 'reduce'. -tests/cases/compiler/bluebirdStaticThis.ts(90,12): error TS2323: Cannot redeclare exported variable 'reduce'. -tests/cases/compiler/bluebirdStaticThis.ts(92,12): error TS2323: Cannot redeclare exported variable 'reduce'. -tests/cases/compiler/bluebirdStaticThis.ts(93,12): error TS2323: Cannot redeclare exported variable 'reduce'. -tests/cases/compiler/bluebirdStaticThis.ts(95,12): error TS2323: Cannot redeclare exported variable 'reduce'. -tests/cases/compiler/bluebirdStaticThis.ts(96,12): error TS2323: Cannot redeclare exported variable 'reduce'. -tests/cases/compiler/bluebirdStaticThis.ts(98,12): error TS2323: Cannot redeclare exported variable 'reduce'. -tests/cases/compiler/bluebirdStaticThis.ts(99,12): error TS2323: Cannot redeclare exported variable 'reduce'. -tests/cases/compiler/bluebirdStaticThis.ts(101,12): error TS2323: Cannot redeclare exported variable 'filter'. -tests/cases/compiler/bluebirdStaticThis.ts(102,12): error TS2323: Cannot redeclare exported variable 'filter'. -tests/cases/compiler/bluebirdStaticThis.ts(103,12): error TS2323: Cannot redeclare exported variable 'filter'. -tests/cases/compiler/bluebirdStaticThis.ts(104,12): error TS2323: Cannot redeclare exported variable 'filter'. -tests/cases/compiler/bluebirdStaticThis.ts(105,12): error TS2323: Cannot redeclare exported variable 'filter'. -tests/cases/compiler/bluebirdStaticThis.ts(106,12): error TS2323: Cannot redeclare exported variable 'filter'. -tests/cases/compiler/bluebirdStaticThis.ts(107,12): error TS2323: Cannot redeclare exported variable 'filter'. -tests/cases/compiler/bluebirdStaticThis.ts(108,12): error TS2323: Cannot redeclare exported variable 'filter'. -==== tests/cases/compiler/bluebirdStaticThis.ts (68 errors) ==== +==== tests/cases/compiler/bluebirdStaticThis.ts (6 errors) ==== // This version is reduced from the full d.ts by removing almost all the tests // and all the comments. // Then it adds explicit `this` arguments to the static members. @@ -80,48 +18,26 @@ tests/cases/compiler/bluebirdStaticThis.ts(108,12): error TS2323: Cannot redecla !!! error TS2420: Property 'then' is missing in type 'Promise'. constructor(callback: (resolve: (thenableOrResult: R | Promise.Thenable) => void, reject: (error: any) => void) => void); static try(dit: typeof Promise, fn: () => Promise.Thenable, args?: any[], ctx?: any): Promise; - ~~~ -!!! error TS2323: Cannot redeclare exported variable 'try'. static try(dit: typeof Promise, fn: () => R, args?: any[], ctx?: any): Promise; - ~~~ -!!! error TS2323: Cannot redeclare exported variable 'try'. static attempt(dit: typeof Promise, fn: () => Promise.Thenable, args?: any[], ctx?: any): Promise; - ~~~~~~~ -!!! error TS2323: Cannot redeclare exported variable 'attempt'. static attempt(dit: typeof Promise, fn: () => R, args?: any[], ctx?: any): Promise; - ~~~~~~~ -!!! error TS2323: Cannot redeclare exported variable 'attempt'. static method(dit: typeof Promise, fn: Function): Function; static resolve(dit: typeof Promise): Promise; - ~~~~~~~ -!!! error TS2323: Cannot redeclare exported variable 'resolve'. static resolve(dit: typeof Promise, value: Promise.Thenable): Promise; - ~~~~~~~ -!!! error TS2323: Cannot redeclare exported variable 'resolve'. static resolve(dit: typeof Promise, value: R): Promise; - ~~~~~~~ -!!! error TS2323: Cannot redeclare exported variable 'resolve'. static reject(dit: typeof Promise, reason: any): Promise; - ~~~~~~ -!!! error TS2323: Cannot redeclare exported variable 'reject'. static reject(dit: typeof Promise, reason: any): Promise; - ~~~~~~ -!!! error TS2323: Cannot redeclare exported variable 'reject'. static defer(dit: typeof Promise): Promise.Resolver; ~~~~~~~~ !!! error TS2694: Namespace 'Promise' has no exported member 'Resolver'. static cast(dit: typeof Promise, value: Promise.Thenable): Promise; - ~~~~ -!!! error TS2323: Cannot redeclare exported variable 'cast'. static cast(dit: typeof Promise, value: R): Promise; - ~~~~ -!!! error TS2323: Cannot redeclare exported variable 'cast'. static bind(dit: typeof Promise, thisArg: any): Promise; @@ -130,14 +46,8 @@ tests/cases/compiler/bluebirdStaticThis.ts(108,12): error TS2323: Cannot redecla static longStackTraces(dit: typeof Promise): void; static delay(dit: typeof Promise, value: Promise.Thenable, ms: number): Promise; - ~~~~~ -!!! error TS2323: Cannot redeclare exported variable 'delay'. static delay(dit: typeof Promise, value: R, ms: number): Promise; - ~~~~~ -!!! error TS2323: Cannot redeclare exported variable 'delay'. static delay(dit: typeof Promise, ms: number): Promise; - ~~~~~ -!!! error TS2323: Cannot redeclare exported variable 'delay'. static promisify(dit: typeof Promise, nodeFunction: Function, receiver?: any): Function; @@ -152,169 +62,73 @@ tests/cases/compiler/bluebirdStaticThis.ts(108,12): error TS2323: Cannot redecla static onPossiblyUnhandledRejection(dit: typeof Promise, handler: (reason: any) => any): void; static all(dit: typeof Promise, values: Promise.Thenable[]>): Promise; - ~~~ -!!! error TS2323: Cannot redeclare exported variable 'all'. static all(dit: typeof Promise, values: Promise.Thenable): Promise; - ~~~ -!!! error TS2323: Cannot redeclare exported variable 'all'. static all(dit: typeof Promise, values: Promise.Thenable[]): Promise; - ~~~ -!!! error TS2323: Cannot redeclare exported variable 'all'. static all(dit: typeof Promise, values: R[]): Promise; - ~~~ -!!! error TS2323: Cannot redeclare exported variable 'all'. static props(dit: typeof Promise, object: Promise): Promise; - ~~~~~ -!!! error TS2323: Cannot redeclare exported variable 'props'. static props(dit: typeof Promise, object: Object): Promise; - ~~~~~ -!!! error TS2323: Cannot redeclare exported variable 'props'. static settle(dit: typeof Promise, values: Promise.Thenable[]>): Promise[]>; - ~~~~~~ -!!! error TS2323: Cannot redeclare exported variable 'settle'. ~~~~~~~~~~ !!! error TS2694: Namespace 'Promise' has no exported member 'Inspection'. static settle(dit: typeof Promise, values: Promise.Thenable): Promise[]>; - ~~~~~~ -!!! error TS2323: Cannot redeclare exported variable 'settle'. ~~~~~~~~~~ !!! error TS2694: Namespace 'Promise' has no exported member 'Inspection'. static settle(dit: typeof Promise, values: Promise.Thenable[]): Promise[]>; - ~~~~~~ -!!! error TS2323: Cannot redeclare exported variable 'settle'. ~~~~~~~~~~ !!! error TS2694: Namespace 'Promise' has no exported member 'Inspection'. static settle(dit: typeof Promise, values: R[]): Promise[]>; - ~~~~~~ -!!! error TS2323: Cannot redeclare exported variable 'settle'. ~~~~~~~~~~ !!! error TS2694: Namespace 'Promise' has no exported member 'Inspection'. static any(dit: typeof Promise, values: Promise.Thenable[]>): Promise; - ~~~ -!!! error TS2323: Cannot redeclare exported variable 'any'. static any(dit: typeof Promise, values: Promise.Thenable): Promise; - ~~~ -!!! error TS2323: Cannot redeclare exported variable 'any'. static any(dit: typeof Promise, values: Promise.Thenable[]): Promise; - ~~~ -!!! error TS2323: Cannot redeclare exported variable 'any'. static any(dit: typeof Promise, values: R[]): Promise; - ~~~ -!!! error TS2323: Cannot redeclare exported variable 'any'. static race(dit: typeof Promise, values: Promise.Thenable[]>): Promise; - ~~~~ -!!! error TS2323: Cannot redeclare exported variable 'race'. static race(dit: typeof Promise, values: Promise.Thenable): Promise; - ~~~~ -!!! error TS2323: Cannot redeclare exported variable 'race'. static race(dit: typeof Promise, values: Promise.Thenable[]): Promise; - ~~~~ -!!! error TS2323: Cannot redeclare exported variable 'race'. static race(dit: typeof Promise, values: R[]): Promise; - ~~~~ -!!! error TS2323: Cannot redeclare exported variable 'race'. static some(dit: typeof Promise, values: Promise.Thenable[]>, count: number): Promise; - ~~~~ -!!! error TS2323: Cannot redeclare exported variable 'some'. static some(dit: typeof Promise, values: Promise.Thenable, count: number): Promise; - ~~~~ -!!! error TS2323: Cannot redeclare exported variable 'some'. static some(dit: typeof Promise, values: Promise.Thenable[], count: number): Promise; - ~~~~ -!!! error TS2323: Cannot redeclare exported variable 'some'. static some(dit: typeof Promise, values: R[], count: number): Promise; - ~~~~ -!!! error TS2323: Cannot redeclare exported variable 'some'. static join(dit: typeof Promise, ...values: Promise.Thenable[]): Promise; - ~~~~ -!!! error TS2323: Cannot redeclare exported variable 'join'. static join(dit: typeof Promise, ...values: R[]): Promise; - ~~~~ -!!! error TS2323: Cannot redeclare exported variable 'join'. static map(dit: typeof Promise, values: Promise.Thenable[]>, mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; - ~~~ -!!! error TS2323: Cannot redeclare exported variable 'map'. static map(dit: typeof Promise, values: Promise.Thenable[]>, mapper: (item: R, index: number, arrayLength: number) => U): Promise; - ~~~ -!!! error TS2323: Cannot redeclare exported variable 'map'. static map(dit: typeof Promise, values: Promise.Thenable, mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; - ~~~ -!!! error TS2323: Cannot redeclare exported variable 'map'. static map(dit: typeof Promise, values: Promise.Thenable, mapper: (item: R, index: number, arrayLength: number) => U): Promise; - ~~~ -!!! error TS2323: Cannot redeclare exported variable 'map'. static map(dit: typeof Promise, values: Promise.Thenable[], mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; - ~~~ -!!! error TS2323: Cannot redeclare exported variable 'map'. static map(dit: typeof Promise, values: Promise.Thenable[], mapper: (item: R, index: number, arrayLength: number) => U): Promise; - ~~~ -!!! error TS2323: Cannot redeclare exported variable 'map'. static map(dit: typeof Promise, values: R[], mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; - ~~~ -!!! error TS2323: Cannot redeclare exported variable 'map'. static map(dit: typeof Promise, values: R[], mapper: (item: R, index: number, arrayLength: number) => U): Promise; - ~~~ -!!! error TS2323: Cannot redeclare exported variable 'map'. static reduce(dit: typeof Promise, values: Promise.Thenable[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; - ~~~~~~ -!!! error TS2323: Cannot redeclare exported variable 'reduce'. static reduce(dit: typeof Promise, values: Promise.Thenable[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; - ~~~~~~ -!!! error TS2323: Cannot redeclare exported variable 'reduce'. static reduce(dit: typeof Promise, values: Promise.Thenable, reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; - ~~~~~~ -!!! error TS2323: Cannot redeclare exported variable 'reduce'. static reduce(dit: typeof Promise, values: Promise.Thenable, reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; - ~~~~~~ -!!! error TS2323: Cannot redeclare exported variable 'reduce'. static reduce(dit: typeof Promise, values: Promise.Thenable[], reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; - ~~~~~~ -!!! error TS2323: Cannot redeclare exported variable 'reduce'. static reduce(dit: typeof Promise, values: Promise.Thenable[], reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; - ~~~~~~ -!!! error TS2323: Cannot redeclare exported variable 'reduce'. static reduce(dit: typeof Promise, values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; - ~~~~~~ -!!! error TS2323: Cannot redeclare exported variable 'reduce'. static reduce(dit: typeof Promise, values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; - ~~~~~~ -!!! error TS2323: Cannot redeclare exported variable 'reduce'. static filter(dit: typeof Promise, values: Promise.Thenable[]>, filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; - ~~~~~~ -!!! error TS2323: Cannot redeclare exported variable 'filter'. static filter(dit: typeof Promise, values: Promise.Thenable[]>, filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; - ~~~~~~ -!!! error TS2323: Cannot redeclare exported variable 'filter'. static filter(dit: typeof Promise, values: Promise.Thenable, filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; - ~~~~~~ -!!! error TS2323: Cannot redeclare exported variable 'filter'. static filter(dit: typeof Promise, values: Promise.Thenable, filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; - ~~~~~~ -!!! error TS2323: Cannot redeclare exported variable 'filter'. static filter(dit: typeof Promise, values: Promise.Thenable[], filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; - ~~~~~~ -!!! error TS2323: Cannot redeclare exported variable 'filter'. static filter(dit: typeof Promise, values: Promise.Thenable[], filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; - ~~~~~~ -!!! error TS2323: Cannot redeclare exported variable 'filter'. static filter(dit: typeof Promise, values: R[], filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; - ~~~~~~ -!!! error TS2323: Cannot redeclare exported variable 'filter'. static filter(dit: typeof Promise, values: R[], filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; - ~~~~~~ -!!! error TS2323: Cannot redeclare exported variable 'filter'. } declare module Promise { From 38278ee0788bb8dc26b5052f103591b8fd0be0ab Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 11 Oct 2016 18:28:19 -0700 Subject: [PATCH 056/173] Fix typo --- src/compiler/core.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 36548334a62..47e533c9a6b 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -271,7 +271,7 @@ namespace ts { return result; } - // Maps from T to T and avoids allocation of all elements map to themselves + // Maps from T to T and avoids allocation if all elements map to themselves export function sameMap(array: T[], f: (x: T, i: number) => T): T[] { let result: T[]; if (array) { From 460de66311b26457481a6d2055231e00fa24e705 Mon Sep 17 00:00:00 2001 From: Zhengbo Li Date: Tue, 11 Oct 2016 19:19:40 -0700 Subject: [PATCH 057/173] Turn on skipLibCheck for js-only inferred project and external project (#11399) * Turn on skipLibCheck for js-only inferred project and external project * avoid changing compiler options * Update tests --- src/compiler/commandLineParser.ts | 2 +- .../convertCompilerOptionsFromJson.ts | 8 +- .../unittests/tsserverProjectSystem.ts | 94 +++++++++++++++++-- src/server/project.ts | 41 +++++++- src/server/session.ts | 29 ++++-- 5 files changed, 151 insertions(+), 23 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 648447ac26a..72dd42b3997 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -975,7 +975,7 @@ namespace ts { basePath: string, errors: Diagnostic[], configFileName?: string): CompilerOptions { const options: CompilerOptions = getBaseFileName(configFileName) === "jsconfig.json" - ? { allowJs: true, maxNodeModuleJsDepth: 2, allowSyntheticDefaultImports: true } + ? { allowJs: true, maxNodeModuleJsDepth: 2, allowSyntheticDefaultImports: true, skipLibCheck: true } : {}; convertOptionsFromJson(optionDeclarations, jsonOptions, basePath, options, Diagnostics.Unknown_compiler_option_0, errors); return options; diff --git a/src/harness/unittests/convertCompilerOptionsFromJson.ts b/src/harness/unittests/convertCompilerOptionsFromJson.ts index ba25409a9b4..33cad7130c7 100644 --- a/src/harness/unittests/convertCompilerOptionsFromJson.ts +++ b/src/harness/unittests/convertCompilerOptionsFromJson.ts @@ -405,6 +405,7 @@ namespace ts { allowJs: true, maxNodeModuleJsDepth: 2, allowSyntheticDefaultImports: true, + skipLibCheck: true, module: ModuleKind.CommonJS, target: ScriptTarget.ES5, noImplicitAny: false, @@ -433,6 +434,7 @@ namespace ts { allowJs: false, maxNodeModuleJsDepth: 2, allowSyntheticDefaultImports: true, + skipLibCheck: true, module: ModuleKind.CommonJS, target: ScriptTarget.ES5, noImplicitAny: false, @@ -456,7 +458,8 @@ namespace ts { { allowJs: true, maxNodeModuleJsDepth: 2, - allowSyntheticDefaultImports: true + allowSyntheticDefaultImports: true, + skipLibCheck: true }, errors: [{ file: undefined, @@ -477,7 +480,8 @@ namespace ts { { allowJs: true, maxNodeModuleJsDepth: 2, - allowSyntheticDefaultImports: true + allowSyntheticDefaultImports: true, + skipLibCheck: true }, errors: [] } diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index b758761ee76..08e4bac7b2c 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -3,6 +3,8 @@ namespace ts.projectSystem { import TI = server.typingsInstaller; + import protocol = server.protocol; + import CommandNames = server.CommandNames; const safeList = { path: "/safeList.json", @@ -128,7 +130,7 @@ namespace ts.projectSystem { return combinePaths(getDirectoryPath(libFile.path), "tsc.js"); } - export function toExternalFile(fileName: string): server.protocol.ExternalFile { + export function toExternalFile(fileName: string): protocol.ExternalFile { return { fileName }; } @@ -527,7 +529,7 @@ namespace ts.projectSystem { } export function makeSessionRequest(command: string, args: T) { - const newRequest: server.protocol.Request = { + const newRequest: protocol.Request = { seq: 0, type: "request", command, @@ -538,7 +540,7 @@ namespace ts.projectSystem { export function openFilesForSession(files: FileOrFolder[], session: server.Session) { for (const file of files) { - const request = makeSessionRequest(server.CommandNames.Open, { file: file.path }); + const request = makeSessionRequest(CommandNames.Open, { file: file.path }); session.executeCommand(request); } } @@ -1751,7 +1753,7 @@ namespace ts.projectSystem { }); describe("navigate-to for javascript project", () => { - function containsNavToItem(items: server.protocol.NavtoItem[], itemName: string, itemKind: string) { + function containsNavToItem(items: protocol.NavtoItem[], itemName: string, itemKind: string) { return find(items, item => item.name === itemName && item.kind === itemKind) !== undefined; } @@ -1769,12 +1771,12 @@ namespace ts.projectSystem { openFilesForSession([file1], session); // Try to find some interface type defined in lib.d.ts - const libTypeNavToRequest = makeSessionRequest(server.CommandNames.Navto, { searchValue: "Document", file: file1.path, projectFileName: configFile.path }); - const items: server.protocol.NavtoItem[] = session.executeCommand(libTypeNavToRequest).response; + const libTypeNavToRequest = makeSessionRequest(CommandNames.Navto, { searchValue: "Document", file: file1.path, projectFileName: configFile.path }); + const items: protocol.NavtoItem[] = session.executeCommand(libTypeNavToRequest).response; assert.isFalse(containsNavToItem(items, "Document", "interface"), `Found lib.d.ts symbol in JavaScript project nav to request result.`); - const localFunctionNavToRequst = makeSessionRequest(server.CommandNames.Navto, { searchValue: "foo", file: file1.path, projectFileName: configFile.path }); - const items2: server.protocol.NavtoItem[] = session.executeCommand(localFunctionNavToRequst).response; + const localFunctionNavToRequst = makeSessionRequest(CommandNames.Navto, { searchValue: "foo", file: file1.path, projectFileName: configFile.path }); + const items2: protocol.NavtoItem[] = session.executeCommand(localFunctionNavToRequst).response; assert.isTrue(containsNavToItem(items2, "foo", "function"), `Cannot find function symbol "foo".`); }); }); @@ -2309,4 +2311,80 @@ namespace ts.projectSystem { serverEventManager.checkEventCountOfType("configFileDiag", 1); }); }); + + describe("skipLibCheck", () => { + it("should be turned on for js-only inferred projects", () => { + const file1 = { + path: "/a/b/file1.js", + content: ` + /// + var x = 1;` + }; + const file2 = { + path: "/a/b/file2.d.ts", + content: ` + interface T { + name: string; + }; + interface T { + name: number; + };` + }; + const host = createServerHost([file1, file2]); + const session = createSession(host); + openFilesForSession([file1, file2], session); + + const file2GetErrRequest = makeSessionRequest( + CommandNames.SemanticDiagnosticsSync, + { file: file2.path } + ); + let errorResult = session.executeCommand(file2GetErrRequest).response; + assert.isTrue(errorResult.length === 0); + + const closeFileRequest = makeSessionRequest(CommandNames.Close, { file: file1.path }); + session.executeCommand(closeFileRequest); + errorResult = session.executeCommand(file2GetErrRequest).response; + assert.isTrue(errorResult.length !== 0); + + openFilesForSession([file1], session); + errorResult = session.executeCommand(file2GetErrRequest).response; + assert.isTrue(errorResult.length === 0); + }); + + it("should be turned on for js-only external projects", () => { + const jsFile = { + path: "/a/b/file1.js", + content: "let x =1;" + }; + const dTsFile = { + path: "/a/b/file2.d.ts", + content: ` + interface T { + name: string; + }; + interface T { + name: number; + };` + }; + const host = createServerHost([jsFile, dTsFile]); + const session = createSession(host); + + const openExternalProjectRequest = makeSessionRequest( + CommandNames.OpenExternalProject, + { + projectFileName: "project1", + rootFiles: toExternalFiles([jsFile.path, dTsFile.path]), + options: {} + } + ); + session.executeCommand(openExternalProjectRequest); + + const dTsFileGetErrRequest = makeSessionRequest( + CommandNames.SemanticDiagnosticsSync, + { file: dTsFile.path } + ); + const errorResult = session.executeCommand(dTsFileGetErrRequest).response; + assert.isTrue(errorResult.length === 0); + }); + }); } \ No newline at end of file diff --git a/src/server/project.ts b/src/server/project.ts index b59efb03cfd..a355d75f942 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -20,16 +20,42 @@ namespace ts.server { } } - function isJsOrDtsFile(info: ScriptInfo) { - return info.scriptKind === ScriptKind.JS || info.scriptKind == ScriptKind.JSX || fileExtensionIs(info.fileName, ".d.ts"); + function countEachFileTypes(infos: ScriptInfo[]): { js: number, jsx: number, ts: number, tsx: number, dts: number } { + const result = { js: 0, jsx: 0, ts: 0, tsx: 0, dts: 0 }; + for (const info of infos) { + switch (info.scriptKind) { + case ScriptKind.JS: + result.js += 1; + break; + case ScriptKind.JSX: + result.jsx += 1; + break; + case ScriptKind.TS: + fileExtensionIs(info.fileName, ".d.ts") + ? result.dts += 1 + : result.ts += 1; + break; + case ScriptKind.TSX: + result.tsx += 1; + break; + } + } + return result; + } + + function hasOneOrMoreJsAndNoTsFiles(project: Project) { + const counts = countEachFileTypes(project.getScriptInfos()); + return counts.js > 0 && counts.ts === 0 && counts.tsx === 0; } export function allRootFilesAreJsOrDts(project: Project): boolean { - return project.getRootScriptInfos().every(isJsOrDtsFile); + const counts = countEachFileTypes(project.getRootScriptInfos()); + return counts.ts === 0 && counts.tsx === 0; } export function allFilesAreJsOrDts(project: Project): boolean { - return project.getScriptInfos().every(isJsOrDtsFile); + const counts = countEachFileTypes(project.getScriptInfos()); + return counts.ts === 0 && counts.tsx === 0; } export interface ProjectFilesWithTSDiagnostics extends protocol.ProjectFiles { @@ -71,11 +97,16 @@ namespace ts.server { public typesVersion = 0; - public isJsOnlyProject() { + public isNonTsProject() { this.updateGraph(); return allFilesAreJsOrDts(this); } + public isJsOnlyProject() { + this.updateGraph(); + return hasOneOrMoreJsAndNoTsFiles(this); + } + constructor( readonly projectKind: ProjectKind, readonly projectService: ProjectService, diff --git a/src/server/session.ts b/src/server/session.ts index 3b95bdd6fb9..263a05aa1f2 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -14,6 +14,17 @@ namespace ts.server { return ((1e9 * seconds) + nanoseconds) / 1000000.0; } + function shouldSkipSematicCheck(project: Project) { + if (project.getCompilerOptions().skipLibCheck !== undefined) { + return false; + } + + if ((project.projectKind === ProjectKind.Inferred || project.projectKind === ProjectKind.External) && project.isJsOnlyProject()) { + return true; + } + return false; + } + interface FileStart { file: string; start: ILineInfo; @@ -255,12 +266,13 @@ namespace ts.server { private semanticCheck(file: NormalizedPath, project: Project) { try { - const diags = project.getLanguageService().getSemanticDiagnostics(file); - - if (diags) { - const bakedDiags = diags.map((diag) => formatDiag(file, project, diag)); - this.event({ file: file, diagnostics: bakedDiags }, "semanticDiag"); + let diags: Diagnostic[] = []; + if (!shouldSkipSematicCheck(project)) { + diags = project.getLanguageService().getSemanticDiagnostics(file); } + + const bakedDiags = diags.map((diag) => formatDiag(file, project, diag)); + this.event({ file: file, diagnostics: bakedDiags }, "semanticDiag"); } catch (err) { this.logError(err, "semantic check"); @@ -373,6 +385,9 @@ namespace ts.server { private getDiagnosticsWorker(args: protocol.FileRequestArgs, selector: (project: Project, file: string) => Diagnostic[], includeLinePosition: boolean) { const { project, file } = this.getFileAndProject(args); + if (shouldSkipSematicCheck(project)) { + return []; + } const scriptInfo = project.getScriptInfoForNormalizedPath(file); const diagnostics = selector(project, file); return includeLinePosition @@ -1133,7 +1148,7 @@ namespace ts.server { return combineProjectOutput( projects, project => { - const navItems = project.getLanguageService().getNavigateToItems(args.searchValue, args.maxResultCount, fileName, /*excludeDts*/ project.isJsOnlyProject()); + const navItems = project.getLanguageService().getNavigateToItems(args.searchValue, args.maxResultCount, fileName, /*excludeDts*/ project.isNonTsProject()); if (!navItems) { return []; } @@ -1171,7 +1186,7 @@ namespace ts.server { else { return combineProjectOutput( projects, - project => project.getLanguageService().getNavigateToItems(args.searchValue, args.maxResultCount, fileName, /*excludeDts*/ project.isJsOnlyProject()), + project => project.getLanguageService().getNavigateToItems(args.searchValue, args.maxResultCount, fileName, /*excludeDts*/ project.isNonTsProject()), /*comparer*/ undefined, navigateToItemIsEqualTo); } From f42c79150253b003f6f7e38011d57cf0af77df10 Mon Sep 17 00:00:00 2001 From: Andrej Baran Date: Wed, 12 Oct 2016 21:28:11 +0200 Subject: [PATCH 058/173] Don't use es8. Add es2016 target. Rename es7 to es2016. Update getDefaultLibFileName for new targets. --- Jakefile.js | 4 +- src/compiler/binder.ts | 4 +- src/compiler/commandLineParser.ts | 2 +- src/compiler/emitter.ts | 4 +- src/compiler/transformer.ts | 7 +-- .../transformers/{es7.ts => es2016.ts} | 10 ++-- src/compiler/transformers/ts.ts | 3 +- src/compiler/tsconfig.json | 2 +- src/compiler/types.ts | 53 ++++++++++--------- src/compiler/utilities.ts | 10 +++- src/harness/harness.ts | 10 +++- src/harness/tsconfig.json | 2 +- src/harness/unittests/commandLineParsing.ts | 2 +- .../convertCompilerOptionsFromJson.ts | 2 +- src/services/tsconfig.json | 2 +- .../{es8-async.ts => es2017basicAsync.ts} | 2 +- 16 files changed, 69 insertions(+), 50 deletions(-) rename src/compiler/transformers/{es7.ts => es2016.ts} (91%) rename tests/cases/compiler/{es8-async.ts => es2017basicAsync.ts} (97%) diff --git a/Jakefile.js b/Jakefile.js index 64a8553ef39..ecbd0ae2be2 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -74,7 +74,7 @@ var compilerSources = [ "transformers/module/system.ts", "transformers/module/module.ts", "transformers/jsx.ts", - "transformers/es7.ts", + "transformers/es2016.ts", "transformers/generators.ts", "transformers/es6.ts", "transformer.ts", @@ -108,7 +108,7 @@ var servicesSources = [ "transformers/module/system.ts", "transformers/module/module.ts", "transformers/jsx.ts", - "transformers/es7.ts", + "transformers/es2016.ts", "transformers/generators.ts", "transformers/es6.ts", "transformer.ts", diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 2fe7d30ab56..ce482dcdfd9 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -2411,8 +2411,8 @@ namespace ts { } else if (operatorTokenKind === SyntaxKind.AsteriskAsteriskToken || operatorTokenKind === SyntaxKind.AsteriskAsteriskEqualsToken) { - // Exponentiation is ES7 syntax. - transformFlags |= TransformFlags.AssertES7; + // Exponentiation is ES2016 syntax. + transformFlags |= TransformFlags.AssertES2016; } node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 16d338cac6a..b77f6898b3c 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -262,8 +262,8 @@ namespace ts { "es3": ScriptTarget.ES3, "es5": ScriptTarget.ES5, "es6": ScriptTarget.ES6, - "es8": ScriptTarget.ES8, "es2015": ScriptTarget.ES2015, + "es2016": ScriptTarget.ES2016, "es2017": ScriptTarget.ES2017, }), description: Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015, diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index b0e31278ff0..a3f69e2fd4b 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2194,8 +2194,8 @@ const _super = (function (geti, seti) { // Only emit __awaiter function when target ES5/ES6. // Only emit __generator function when target ES5. - // For target ES8 and above, we can emit async/await as is. - if ((languageVersion < ScriptTarget.ES8) && (!awaiterEmitted && node.flags & NodeFlags.HasAsyncFunctions)) { + // For target ES2017 and above, we can emit async/await as is. + if ((languageVersion < ScriptTarget.ES2017) && (!awaiterEmitted && node.flags & NodeFlags.HasAsyncFunctions)) { writeLines(awaiterHelper); if (languageVersion < ScriptTarget.ES6) { writeLines(generatorHelper); diff --git a/src/compiler/transformer.ts b/src/compiler/transformer.ts index 415a9ecd1d7..9e548268052 100644 --- a/src/compiler/transformer.ts +++ b/src/compiler/transformer.ts @@ -1,7 +1,7 @@ /// /// /// -/// +/// /// /// /// @@ -115,8 +115,9 @@ namespace ts { transformers.push(transformJsx); } - if (languageVersion < ScriptTarget.ES8) { - transformers.push(transformES7); + + if (languageVersion < ScriptTarget.ES2016) { + transformers.push(transformES2016); } if (languageVersion < ScriptTarget.ES6) { diff --git a/src/compiler/transformers/es7.ts b/src/compiler/transformers/es2016.ts similarity index 91% rename from src/compiler/transformers/es7.ts rename to src/compiler/transformers/es2016.ts index 4d5e96134c4..fba1d300903 100644 --- a/src/compiler/transformers/es7.ts +++ b/src/compiler/transformers/es2016.ts @@ -3,7 +3,7 @@ /*@internal*/ namespace ts { - export function transformES7(context: TransformationContext) { + export function transformES2016(context: TransformationContext) { const { hoistVariableDeclaration } = context; return transformSourceFile; @@ -17,10 +17,10 @@ namespace ts { } function visitor(node: Node): VisitResult { - if (node.transformFlags & TransformFlags.ES7) { + if (node.transformFlags & TransformFlags.ES2016) { return visitorWorker(node); } - else if (node.transformFlags & TransformFlags.ContainsES7) { + else if (node.transformFlags & TransformFlags.ContainsES2016) { return visitEachChild(node, visitor, context); } else { @@ -40,7 +40,7 @@ namespace ts { } function visitBinaryExpression(node: BinaryExpression): Expression { - // We are here because ES7 adds support for the exponentiation operator. + // We are here because ES2016 adds support for the exponentiation operator. const left = visitNode(node.left, visitor, isExpression); const right = visitNode(node.right, visitor, isExpression); if (node.operatorToken.kind === SyntaxKind.AsteriskAsteriskEqualsToken) { @@ -98,4 +98,4 @@ namespace ts { } } } -} \ No newline at end of file +} diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 40b9e7f64e1..c98fbfc26cc 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -241,8 +241,7 @@ namespace ts { return currentNamespace ? undefined : node; case SyntaxKind.AsyncKeyword: - // Async keyword is not elided for target ES8 - return languageVersion < ScriptTarget.ES8 ? undefined : node; + return node; case SyntaxKind.PublicKeyword: case SyntaxKind.PrivateKeyword: diff --git a/src/compiler/tsconfig.json b/src/compiler/tsconfig.json index f128c994af1..fc0f016f664 100644 --- a/src/compiler/tsconfig.json +++ b/src/compiler/tsconfig.json @@ -24,7 +24,7 @@ "visitor.ts", "transformers/ts.ts", "transformers/jsx.ts", - "transformers/es7.ts", + "transformers/es2016.ts", "transformers/es6.ts", "transformers/generators.ts", "transformers/destructuring.ts", diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 5b193beb155..b89887cafa0 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2831,10 +2831,10 @@ namespace ts { ES3 = 0, ES5 = 1, ES6 = 2, - ES8 = 3, ES2015 = ES6, - ES2017 = ES8, - Latest = ES8, + ES2016 = 3, + ES2017 = 4, + Latest = ES2017, } export const enum LanguageVariant { @@ -3119,29 +3119,31 @@ namespace ts { ContainsTypeScript = 1 << 1, Jsx = 1 << 2, ContainsJsx = 1 << 3, - ES7 = 1 << 4, - ContainsES7 = 1 << 5, - ES6 = 1 << 6, - ContainsES6 = 1 << 7, - DestructuringAssignment = 1 << 8, - Generator = 1 << 9, - ContainsGenerator = 1 << 10, + ES2017 = 1 << 4, + ContainsES2017 = 1 << 5, + ES2016 = 1 << 6, + ContainsES2016 = 1 << 7, + ES6 = 1 << 8, + ContainsES6 = 1 << 9, + DestructuringAssignment = 1 << 10, + Generator = 1 << 11, + ContainsGenerator = 1 << 12, // Markers // - Flags used to indicate that a subtree contains a specific transformation. - ContainsDecorators = 1 << 11, - ContainsPropertyInitializer = 1 << 12, - ContainsLexicalThis = 1 << 13, - ContainsCapturedLexicalThis = 1 << 14, - ContainsLexicalThisInComputedPropertyName = 1 << 15, - ContainsDefaultValueAssignments = 1 << 16, - ContainsParameterPropertyAssignments = 1 << 17, - ContainsSpreadElementExpression = 1 << 18, - ContainsComputedPropertyName = 1 << 19, - ContainsBlockScopedBinding = 1 << 20, - ContainsBindingPattern = 1 << 21, - ContainsYield = 1 << 22, - ContainsHoistedDeclarationOrCompletion = 1 << 23, + ContainsDecorators = 1 << 13, + ContainsPropertyInitializer = 1 << 14, + ContainsLexicalThis = 1 << 15, + ContainsCapturedLexicalThis = 1 << 16, + ContainsLexicalThisInComputedPropertyName = 1 << 17, + ContainsDefaultValueAssignments = 1 << 18, + ContainsParameterPropertyAssignments = 1 << 19, + ContainsSpreadElementExpression = 1 << 20, + ContainsComputedPropertyName = 1 << 21, + ContainsBlockScopedBinding = 1 << 22, + ContainsBindingPattern = 1 << 23, + ContainsYield = 1 << 24, + ContainsHoistedDeclarationOrCompletion = 1 << 25, HasComputedFlags = 1 << 29, // Transform flags have been computed. @@ -3149,14 +3151,15 @@ namespace ts { // - Bitmasks that are used to assert facts about the syntax of a node and its subtree. AssertTypeScript = TypeScript | ContainsTypeScript, AssertJsx = Jsx | ContainsJsx, - AssertES7 = ES7 | ContainsES7, + AssertES2017 = ES2017 | ContainsES2017, + AssertES2016 = ES2016 | ContainsES2016, AssertES6 = ES6 | ContainsES6, AssertGenerator = Generator | ContainsGenerator, // Scope Exclusions // - Bitmasks that exclude flags from propagating out of a specific context // into the subtree flags of their container. - NodeExcludes = TypeScript | Jsx | ES7 | ES6 | DestructuringAssignment | Generator | HasComputedFlags, + NodeExcludes = TypeScript | Jsx | ES2017 | ES2016 | ES6 | DestructuringAssignment | Generator | HasComputedFlags, ArrowFunctionExcludes = NodeExcludes | ContainsDecorators | ContainsDefaultValueAssignments | ContainsLexicalThis | ContainsParameterPropertyAssignments | ContainsBlockScopedBinding | ContainsYield | ContainsHoistedDeclarationOrCompletion, FunctionExcludes = NodeExcludes | ContainsDecorators | ContainsDefaultValueAssignments | ContainsCapturedLexicalThis | ContainsLexicalThis | ContainsParameterPropertyAssignments | ContainsBlockScopedBinding | ContainsYield | ContainsHoistedDeclarationOrCompletion, ConstructorExcludes = NodeExcludes | ContainsDefaultValueAssignments | ContainsLexicalThis | ContainsCapturedLexicalThis | ContainsBlockScopedBinding | ContainsYield | ContainsHoistedDeclarationOrCompletion, diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 1a4d95feca5..b661cefb5a6 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -4141,7 +4141,15 @@ namespace ts { namespace ts { export function getDefaultLibFileName(options: CompilerOptions): string { - return options.target === ScriptTarget.ES6 ? "lib.es6.d.ts" : "lib.d.ts"; + switch (options.target) { + case ScriptTarget.ES2016: + return "lib.es2016.d.ts"; + case ScriptTarget.ES6: + return "lib.es2015.d.ts"; + + default: + return "lib.d.ts"; + } } export function textSpanEnd(span: TextSpan) { diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 7c82aeece78..b8703ebc8f2 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -941,7 +941,15 @@ namespace Harness { } export function getDefaultLibFileName(options: ts.CompilerOptions): string { - return options.target === ts.ScriptTarget.ES6 ? es2015DefaultLibFileName : defaultLibFileName; + switch (options.target) { + case ts.ScriptTarget.ES2016: + return "lib.es2016.d.ts"; + case ts.ScriptTarget.ES6: + return es2015DefaultLibFileName; + + default: + return defaultLibFileName; + } } // Cache these between executions so we don't have to re-parse them for every test diff --git a/src/harness/tsconfig.json b/src/harness/tsconfig.json index f9d302ace81..aa46c8ee8d0 100644 --- a/src/harness/tsconfig.json +++ b/src/harness/tsconfig.json @@ -26,7 +26,7 @@ "../compiler/visitor.ts", "../compiler/transformers/ts.ts", "../compiler/transformers/jsx.ts", - "../compiler/transformers/es7.ts", + "../compiler/transformers/es2016.ts", "../compiler/transformers/es6.ts", "../compiler/transformers/generators.ts", "../compiler/transformers/destructuring.ts", diff --git a/src/harness/unittests/commandLineParsing.ts b/src/harness/unittests/commandLineParsing.ts index 42fc242f08e..cd9bf88df60 100644 --- a/src/harness/unittests/commandLineParsing.ts +++ b/src/harness/unittests/commandLineParsing.ts @@ -165,7 +165,7 @@ namespace ts { start: undefined, length: undefined, }, { - messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es8', 'es2015', 'es2017'", + messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015', 'es2016', 'es2017'", category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code, diff --git a/src/harness/unittests/convertCompilerOptionsFromJson.ts b/src/harness/unittests/convertCompilerOptionsFromJson.ts index db3d6cfc102..13f54e369ed 100644 --- a/src/harness/unittests/convertCompilerOptionsFromJson.ts +++ b/src/harness/unittests/convertCompilerOptionsFromJson.ts @@ -176,7 +176,7 @@ namespace ts { file: undefined, start: 0, length: 0, - messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es8', 'es2015', 'es2017'", + messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015', 'es2016', 'es2017'", code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category }] diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index 58312c6f38f..e759ab35b48 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -25,7 +25,7 @@ "../compiler/visitor.ts", "../compiler/transformers/ts.ts", "../compiler/transformers/jsx.ts", - "../compiler/transformers/es7.ts", + "../compiler/transformers/es2016.ts", "../compiler/transformers/es6.ts", "../compiler/transformers/generators.ts", "../compiler/transformers/destructuring.ts", diff --git a/tests/cases/compiler/es8-async.ts b/tests/cases/compiler/es2017basicAsync.ts similarity index 97% rename from tests/cases/compiler/es8-async.ts rename to tests/cases/compiler/es2017basicAsync.ts index 0ceb6e397e5..b13a5d29bc0 100644 --- a/tests/cases/compiler/es8-async.ts +++ b/tests/cases/compiler/es2017basicAsync.ts @@ -1,4 +1,4 @@ -// @target: es8 +// @target: es2017 // @lib: es2017 // @noEmitHelpers: true From 994dae70f065edd683b1c943fbd3c911c83dad57 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Wed, 12 Oct 2016 12:28:15 -0700 Subject: [PATCH 059/173] Move import/export elision to ts transform --- src/compiler/core.ts | 13 +- src/compiler/factory.ts | 26 +-- src/compiler/transformers/module/es6.ts | 115 +----------- src/compiler/transformers/module/module.ts | 43 +++-- src/compiler/transformers/module/system.ts | 31 ++-- src/compiler/transformers/ts.ts | 165 +++++++++++++++++- src/compiler/utilities.ts | 29 ++- .../reference/declareModifierOnImport1.js | 1 + ...ndingFollowedWithNamespaceBinding1InEs5.js | 2 +- ...FollowedWithNamespaceBinding1WithExport.js | 1 - ...tBindingFollowedWithNamespaceBindingDts.js | 2 +- ...BindingFollowedWithNamespaceBindingDts1.js | 1 - ...indingFollowedWithNamespaceBindingInEs5.js | 2 +- ...gFollowedWithNamespaceBindingWithExport.js | 2 +- .../importDeclWithDeclareModifier.js | 1 + ...ler-options module-kind is out-of-range.js | 1 + ...r-options target-script is out-of-range.js | 1 + .../reference/typeAliasDeclarationEmit.js | 1 + .../reference/typeAliasDeclarationEmit2.js | 1 + 19 files changed, 251 insertions(+), 187 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 7c68306211a..4fb0b4d651d 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -399,6 +399,17 @@ namespace ts { return result; } + export function some(array: T[], predicate?: (value: T) => boolean): boolean { + if (array) { + for (const v of array) { + if (!predicate || predicate(v)) { + return true; + } + } + } + return false; + } + export function concatenate(array1: T[], array2: T[]): T[] { if (!array2 || !array2.length) return array1; if (!array1 || !array1.length) return array2; @@ -1177,7 +1188,7 @@ namespace ts { /** * Returns the path except for its basename. Eg: - * + * * /path/to/file.ext -> /path/to */ export function getDirectoryPath(path: Path): Path; diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 97a36f46b13..582f82315d2 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -2206,7 +2206,7 @@ namespace ts { * @param visitor: Optional callback used to visit any custom prologue directives. */ export function addPrologueDirectives(target: Statement[], source: Statement[], ensureUseStrict?: boolean, visitor?: (node: Node) => VisitResult): number { - Debug.assert(target.length === 0, "PrologueDirectives should be at the first statement in the target statements array"); + Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array"); let foundUseStrict = false; let statementOffset = 0; const numStatements = source.length; @@ -2219,16 +2219,20 @@ namespace ts { target.push(statement); } else { - if (ensureUseStrict && !foundUseStrict) { - target.push(startOnNewLine(createStatement(createLiteral("use strict")))); - foundUseStrict = true; - } - if (getEmitFlags(statement) & EmitFlags.CustomPrologue) { - target.push(visitor ? visitNode(statement, visitor, isStatement) : statement); - } - else { - break; - } + break; + } + statementOffset++; + } + if (ensureUseStrict && !foundUseStrict) { + target.push(startOnNewLine(createStatement(createLiteral("use strict")))); + } + while (statementOffset < numStatements) { + const statement = source[statementOffset]; + if (getEmitFlags(statement) & EmitFlags.CustomPrologue) { + target.push(visitor ? visitNode(statement, visitor, isStatement) : statement); + } + else { + break; } statementOffset++; } diff --git a/src/compiler/transformers/module/es6.ts b/src/compiler/transformers/module/es6.ts index 09a2890727c..9eac37bee27 100644 --- a/src/compiler/transformers/module/es6.ts +++ b/src/compiler/transformers/module/es6.ts @@ -5,10 +5,6 @@ namespace ts { export function transformES6Module(context: TransformationContext) { const compilerOptions = context.getCompilerOptions(); - const resolver = context.getEmitResolver(); - - let currentSourceFile: SourceFile; - return transformSourceFile; function transformSourceFile(node: SourceFile) { @@ -17,128 +13,31 @@ namespace ts { } if (isExternalModule(node) || compilerOptions.isolatedModules) { - currentSourceFile = node; return visitEachChild(node, visitor, context); } + return node; } function visitor(node: Node): VisitResult { switch (node.kind) { - case SyntaxKind.ImportDeclaration: - return visitImportDeclaration(node); case SyntaxKind.ImportEqualsDeclaration: return visitImportEqualsDeclaration(node); - case SyntaxKind.ImportClause: - return visitImportClause(node); - case SyntaxKind.NamedImports: - case SyntaxKind.NamespaceImport: - return visitNamedBindings(node); - case SyntaxKind.ImportSpecifier: - return visitImportSpecifier(node); case SyntaxKind.ExportAssignment: return visitExportAssignment(node); - case SyntaxKind.ExportDeclaration: - return visitExportDeclaration(node); - case SyntaxKind.NamedExports: - return visitNamedExports(node); - case SyntaxKind.ExportSpecifier: - return visitExportSpecifier(node); } return node; } - function visitExportAssignment(node: ExportAssignment): ExportAssignment { - if (node.isExportEquals) { - return undefined; // do not emit export equals for ES6 - } - const original = getOriginalNode(node); - return nodeIsSynthesized(original) || resolver.isValueAliasDeclaration(original) ? node : undefined; + function visitImportEqualsDeclaration(node: ImportEqualsDeclaration): VisitResult { + // Elide `import=` as it is not legal with --module ES6 + return undefined; } - function visitExportDeclaration(node: ExportDeclaration): ExportDeclaration { - if (!node.exportClause) { - return resolver.moduleExportsSomeValue(node.moduleSpecifier) ? node : undefined; - } - if (!resolver.isValueAliasDeclaration(node)) { - return undefined; - } - const newExportClause = visitNode(node.exportClause, visitor, isNamedExports, /*optional*/ true); - if (node.exportClause === newExportClause) { - return node; - } - return newExportClause - ? createExportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, - newExportClause, - node.moduleSpecifier) - : undefined; - } - - function visitNamedExports(node: NamedExports): NamedExports { - const newExports = visitNodes(node.elements, visitor, isExportSpecifier); - if (node.elements === newExports) { - return node; - } - return newExports.length ? createNamedExports(newExports) : undefined; - } - - function visitExportSpecifier(node: ExportSpecifier): ExportSpecifier { - return resolver.isValueAliasDeclaration(node) ? node : undefined; - } - - function visitImportEqualsDeclaration(node: ImportEqualsDeclaration): ImportEqualsDeclaration { - return !isExternalModuleImportEqualsDeclaration(node) || resolver.isReferencedAliasDeclaration(node) ? node : undefined; - } - - function visitImportDeclaration(node: ImportDeclaration) { - if (node.importClause) { - const newImportClause = visitNode(node.importClause, visitor, isImportClause); - if (!newImportClause.name && !newImportClause.namedBindings) { - return undefined; - } - else if (newImportClause !== node.importClause) { - return createImportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, - newImportClause, - node.moduleSpecifier); - } - } - return node; - } - - function visitImportClause(node: ImportClause): ImportClause { - let newDefaultImport = node.name; - if (!resolver.isReferencedAliasDeclaration(node)) { - newDefaultImport = undefined; - } - const newNamedBindings = visitNode(node.namedBindings, visitor, isNamedImportBindings, /*optional*/ true); - return newDefaultImport !== node.name || newNamedBindings !== node.namedBindings - ? createImportClause(newDefaultImport, newNamedBindings) - : node; - } - - function visitNamedBindings(node: NamedImportBindings): VisitResult { - if (node.kind === SyntaxKind.NamespaceImport) { - return resolver.isReferencedAliasDeclaration(node) ? node : undefined; - } - else { - const newNamedImportElements = visitNodes((node).elements, visitor, isImportSpecifier); - if (!newNamedImportElements || newNamedImportElements.length == 0) { - return undefined; - } - if (newNamedImportElements === (node).elements) { - return node; - } - return createNamedImports(newNamedImportElements); - } - } - - function visitImportSpecifier(node: ImportSpecifier) { - return resolver.isReferencedAliasDeclaration(node) ? node : undefined; + function visitExportAssignment(node: ExportAssignment): VisitResult { + // Elide `export=` as it is not legal with --module ES6 + return node.isExportEquals ? undefined : node; } } } \ No newline at end of file diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index 516ed5433b8..94852616037 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -59,7 +59,7 @@ namespace ts { currentSourceFile = node; // Collect information about the external module. - ({ externalImports, exportSpecifiers, exportEquals, hasExportStarsToExportValues } = collectExternalModuleInfo(node, resolver)); + ({ externalImports, exportSpecifiers, exportEquals, hasExportStarsToExportValues } = collectExternalModuleInfo(node)); // Perform the transformation. const transformModule = transformModuleDelegates[moduleKind] || transformModuleDelegates[ModuleKind.None]; @@ -228,7 +228,7 @@ namespace ts { } function addExportEqualsIfNeeded(statements: Statement[], emitAsReturn: boolean) { - if (exportEquals && resolver.isValueAliasDeclaration(exportEquals)) { + if (exportEquals) { if (emitAsReturn) { const statement = createReturn( exportEquals.expression, @@ -461,23 +461,21 @@ namespace ts { ); } for (const specifier of node.exportClause.elements) { - if (resolver.isValueAliasDeclaration(specifier)) { - const exportedValue = createPropertyAccess( - generatedName, - specifier.propertyName || specifier.name - ); - statements.push( - createStatement( - createExportAssignment(specifier.name, exportedValue), - /*location*/ specifier - ) - ); - } + const exportedValue = createPropertyAccess( + generatedName, + specifier.propertyName || specifier.name + ); + statements.push( + createStatement( + createExportAssignment(specifier.name, exportedValue), + /*location*/ specifier + ) + ); } return singleOrMany(statements); } - else if (resolver.moduleExportsSomeValue(node.moduleSpecifier)) { + else { // export * from "mod"; return createStatement( createCall( @@ -495,15 +493,14 @@ namespace ts { } function visitExportAssignment(node: ExportAssignment): VisitResult { - if (!node.isExportEquals) { - if (nodeIsSynthesized(node) || resolver.isValueAliasDeclaration(node)) { - const statements: Statement[] = []; - addExportDefault(statements, node.expression, /*location*/ node); - return statements; - } + if (node.isExportEquals) { + // Elide as `export=` is handled in addExportEqualsIfNeeded + return undefined; } - return undefined; + const statements: Statement[] = []; + addExportDefault(statements, node.expression, /*location*/ node); + return statements; } function addExportDefault(statements: Statement[], expression: Expression, location: TextRange): void { @@ -568,7 +565,7 @@ namespace ts { } function collectExportMembers(names: Identifier[], node: Node): Identifier[] { - if (isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node) && isDeclaration(node)) { + if (isAliasSymbolDeclaration(node) && isDeclaration(node)) { const name = node.name; if (isIdentifier(name)) { names.push(name); diff --git a/src/compiler/transformers/module/system.ts b/src/compiler/transformers/module/system.ts index 303c0e1bb96..0bb188eb390 100644 --- a/src/compiler/transformers/module/system.ts +++ b/src/compiler/transformers/module/system.ts @@ -91,7 +91,7 @@ namespace ts { Debug.assert(!exportFunctionForFile); // Collect information about the external module and dependency groups. - ({ externalImports, exportSpecifiers, exportEquals, hasExportStarsToExportValues } = collectExternalModuleInfo(node, resolver)); + ({ externalImports, exportSpecifiers, exportEquals, hasExportStarsToExportValues } = collectExternalModuleInfo(node)); // Make sure that the name of the 'exports' function does not conflict with // existing identifiers. @@ -573,28 +573,23 @@ namespace ts { } function visitExportSpecifier(specifier: ExportSpecifier): Statement { - if (resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) - || resolver.isValueAliasDeclaration(specifier)) { - recordExportName(specifier.name); - return createExportStatement( - specifier.name, - specifier.propertyName || specifier.name - ); - } - return undefined; + recordExportName(specifier.name); + return createExportStatement( + specifier.name, + specifier.propertyName || specifier.name + ); } function visitExportAssignment(node: ExportAssignment): Statement { - if (!node.isExportEquals) { - if (nodeIsSynthesized(node) || resolver.isValueAliasDeclaration(node)) { - return createExportStatement( - createLiteral("default"), - node.expression - ); - } + if (node.isExportEquals) { + // Elide `export=` as it is illegal in a SystemJS module. + return undefined; } - return undefined; + return createExportStatement( + createLiteral("default"), + node.expression + ); } /** diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 41f03d20f2e..3c87036621b 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -147,6 +147,35 @@ namespace ts { return node; } + /** + * Specialized visitor that visits the immediate children of a SourceFile. + * + * @param node The node to visit. + */ + function sourceElementVisitor(node: Node): VisitResult { + return saveStateAndInvoke(node, sourceElementVisitorWorker); + } + + /** + * Specialized visitor that visits the immediate children of a SourceFile. + * + * @param node The node to visit. + */ + function sourceElementVisitorWorker(node: Node): VisitResult { + switch (node.kind) { + case SyntaxKind.ImportDeclaration: + return visitImportDeclaration(node); + case SyntaxKind.ImportEqualsDeclaration: + return visitImportEqualsDeclaration(node); + case SyntaxKind.ExportAssignment: + return visitExportAssignment(node); + case SyntaxKind.ExportDeclaration: + return visitExportDeclaration(node); + default: + return visitorWorker(node); + } + } + /** * Specialized visitor that visits the immediate children of a namespace. * @@ -457,7 +486,7 @@ namespace ts { statements.push(externalHelpersModuleImport); currentSourceFileExternalHelpersModuleName = externalHelpersModuleName; - addRange(statements, visitNodes(node.statements, visitor, isStatement, statementOffset)); + addRange(statements, visitNodes(node.statements, sourceElementVisitor, isStatement, statementOffset)); addRange(statements, endLexicalEnvironment()); currentSourceFileExternalHelpersModuleName = undefined; @@ -465,7 +494,7 @@ namespace ts { node.externalHelpersModuleName = externalHelpersModuleName; } else { - node = visitEachChild(node, visitor, context); + node = visitEachChild(node, sourceElementVisitor, context); } setEmitFlags(node, EmitFlags.EmitEmitHelpers | getEmitFlags(node)); @@ -2993,6 +3022,133 @@ namespace ts { } } + /** + * Visits an import declaration, eliding it if it is not referenced. + * + * @param node The import declaration node. + */ + function visitImportDeclaration(node: ImportDeclaration): VisitResult { + if (!node.importClause) { + // Do not elide a side-effect only import declaration. + // import "foo"; + return node; + } + + // Elide the declaration if the import clause was elided. + const importClause = visitNode(node.importClause, visitImportClause, isImportClause, /*optional*/ true); + return importClause + ? updateImportDeclaration( + node, + /*decorators*/ undefined, + /*modifiers*/ undefined, + importClause, + node.moduleSpecifier) + : undefined; + } + + /** + * Visits an import clause, eliding it if it is not referenced. + * + * @param node The import clause node. + */ + function visitImportClause(node: ImportClause): VisitResult { + // Elide the import clause if we elide both its name and its named bindings. + const name = resolver.isReferencedAliasDeclaration(node) ? node.name : undefined; + const namedBindings = visitNode(node.namedBindings, visitNamedImportBindings, isNamedImportBindings, /*optional*/ true); + return (name || namedBindings) ? updateImportClause(node, name, namedBindings) : undefined; + } + + /** + * Visits named import bindings, eliding it if it is not referenced. + * + * @param node The named import bindings node. + */ + function visitNamedImportBindings(node: NamedImportBindings): VisitResult { + if (node.kind === SyntaxKind.NamespaceImport) { + // Elide a namespace import if it is not referenced. + return resolver.isReferencedAliasDeclaration(node) ? node : undefined; + } + else { + // Elide named imports if all of its import specifiers are elided. + const elements = visitNodes(node.elements, visitImportSpecifier, isImportSpecifier); + return some(elements) ? updateNamedImports(node, elements) : undefined; + } + } + + /** + * Visits an import specifier, eliding it if it is not referenced. + * + * @param node The import specifier node. + */ + function visitImportSpecifier(node: ImportSpecifier): VisitResult { + // Elide an import specifier if it is not referenced. + return resolver.isReferencedAliasDeclaration(node) ? node : undefined; + } + + /** + * Visits an export assignment, eliding it if it does not contain a clause that resolves + * to a value. + * + * @param node The export assignment node. + */ + function visitExportAssignment(node: ExportAssignment): VisitResult { + // Elide the export assignment if it does not reference a value. + return resolver.isValueAliasDeclaration(node) + ? visitEachChild(node, visitor, context) + : undefined; + } + + /** + * Visits an export declaration, eliding it if it does not contain a clause that resolves + * to a value. + * + * @param node The export declaration node. + */ + function visitExportDeclaration(node: ExportDeclaration): VisitResult { + if (!node.exportClause) { + // Elide a star export if the module it references does not export a value. + return resolver.moduleExportsSomeValue(node.moduleSpecifier) ? node : undefined; + } + + if (!resolver.isValueAliasDeclaration(node)) { + // Elide the export declaration if it does not export a value. + return undefined; + } + + // Elide the export declaration if all of its named exports are elided. + const exportClause = visitNode(node.exportClause, visitNamedExports, isNamedExports, /*optional*/ true); + return exportClause + ? updateExportDeclaration( + node, + /*decorators*/ undefined, + /*modifiers*/ undefined, + exportClause, + node.moduleSpecifier) + : undefined; + } + + /** + * Visits named exports, eliding it if it does not contain an export specifier that + * resolves to a value. + * + * @param node The named exports node. + */ + function visitNamedExports(node: NamedExports): VisitResult { + // Elide the named exports if all of its export specifiers were elided. + const elements = visitNodes(node.elements, visitExportSpecifier, isExportSpecifier); + return some(elements) ? updateNamedExports(node, elements) : undefined; + } + + /** + * Visits an export specifier, eliding it if it does not resolve to a value. + * + * @param node The export specifier node. + */ + function visitExportSpecifier(node: ExportSpecifier): VisitResult { + // Elide an export specifier if it does not reference a value. + return resolver.isValueAliasDeclaration(node) ? node : undefined; + } + /** * Determines whether to emit an import equals declaration. * @@ -3014,7 +3170,10 @@ namespace ts { */ function visitImportEqualsDeclaration(node: ImportEqualsDeclaration): VisitResult { if (isExternalModuleImportEqualsDeclaration(node)) { - return visitEachChild(node, visitor, context); + // Elide external module `import=` if it is not referenced. + return resolver.isReferencedAliasDeclaration(node) + ? visitEachChild(node, visitor, context) + : undefined; } if (!shouldEmitImportEqualsDeclaration(node)) { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 558015bb0e3..eee79894a02 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -3496,7 +3496,7 @@ namespace ts { return positionIsSynthesized(range.pos) ? -1 : skipTrivia(sourceFile.text, range.pos); } - export function collectExternalModuleInfo(sourceFile: SourceFile, resolver: EmitResolver) { + export function collectExternalModuleInfo(sourceFile: SourceFile) { const externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[] = []; const exportSpecifiers = createMap(); let exportEquals: ExportAssignment = undefined; @@ -3504,19 +3504,16 @@ namespace ts { for (const node of sourceFile.statements) { switch (node.kind) { case SyntaxKind.ImportDeclaration: - if (!(node).importClause || - resolver.isReferencedAliasDeclaration((node).importClause, /*checkChildren*/ true)) { - // import "mod" - // import x from "mod" where x is referenced - // import * as x from "mod" where x is referenced - // import { x, y } from "mod" where at least one import is referenced - externalImports.push(node); - } + // import "mod" + // import x from "mod" + // import * as x from "mod" + // import { x, y } from "mod" + externalImports.push(node); break; case SyntaxKind.ImportEqualsDeclaration: - if ((node).moduleReference.kind === SyntaxKind.ExternalModuleReference && resolver.isReferencedAliasDeclaration(node)) { - // import x = require("mod") where x is referenced + if ((node).moduleReference.kind === SyntaxKind.ExternalModuleReference) { + // import x = require("mod") externalImports.push(node); } break; @@ -3525,13 +3522,11 @@ namespace ts { if ((node).moduleSpecifier) { if (!(node).exportClause) { // export * from "mod" - if (resolver.moduleExportsSomeValue((node).moduleSpecifier)) { - externalImports.push(node); - hasExportStarsToExportValues = true; - } + externalImports.push(node); + hasExportStarsToExportValues = true; } - else if (resolver.isValueAliasDeclaration(node)) { - // export { x, y } from "mod" where at least one export is a value symbol + else { + // export { x, y } from "mod" externalImports.push(node); } } diff --git a/tests/baselines/reference/declareModifierOnImport1.js b/tests/baselines/reference/declareModifierOnImport1.js index 510407b4deb..3dc3601d470 100644 --- a/tests/baselines/reference/declareModifierOnImport1.js +++ b/tests/baselines/reference/declareModifierOnImport1.js @@ -2,3 +2,4 @@ declare import a = b; //// [declareModifierOnImport1.js] +var a = b; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js index d62cfbc2872..0a0e028b696 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js @@ -16,7 +16,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.default = a; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.js] "use strict"; -var es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1 = require("./es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"), nameSpaceBinding = es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1; +var es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1 = require("./es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"); var x = es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1.default; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.js index c19f68463fa..5f2cb4e97e0 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.js @@ -19,7 +19,6 @@ define(["require", "exports"], function (require, exports) { //// [client.js] define(["require", "exports", "server"], function (require, exports, server_1) { "use strict"; - var nameSpaceBinding = server_1; exports.x = server_1.default; }); diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js index 20abd2e6132..60bdc654842 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js @@ -18,7 +18,7 @@ var a = (function () { exports.a = a; //// [client.js] "use strict"; -var server_1 = require("./server"), nameSpaceBinding = server_1; +var nameSpaceBinding = require("./server"); exports.x = new nameSpaceBinding.a(); diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.js index 5a2f1f35290..8752157eddd 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.js @@ -23,7 +23,6 @@ define(["require", "exports"], function (require, exports) { //// [client.js] define(["require", "exports", "server"], function (require, exports, server_1) { "use strict"; - var nameSpaceBinding = server_1; exports.x = new server_1.default(); }); diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js index 2639291d854..9d11e154755 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js @@ -13,7 +13,7 @@ var x: number = nameSpaceBinding.a; exports.a = 10; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.js] "use strict"; -var es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1 = require("./es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"), nameSpaceBinding = es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1; +var nameSpaceBinding = require("./es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"); var x = nameSpaceBinding.a; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js index f417a086df7..e16ebf99957 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js @@ -13,7 +13,7 @@ export var x: number = nameSpaceBinding.a; exports.a = 10; //// [client.js] "use strict"; -var server_1 = require("./server"), nameSpaceBinding = server_1; +var nameSpaceBinding = require("./server"); exports.x = nameSpaceBinding.a; diff --git a/tests/baselines/reference/importDeclWithDeclareModifier.js b/tests/baselines/reference/importDeclWithDeclareModifier.js index e5267678a49..7c3d3782934 100644 --- a/tests/baselines/reference/importDeclWithDeclareModifier.js +++ b/tests/baselines/reference/importDeclWithDeclareModifier.js @@ -9,4 +9,5 @@ var b: a; //// [importDeclWithDeclareModifier.js] "use strict"; +exports.a = x.c; var b; diff --git a/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.js b/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.js index c7570e81192..1ceb1bcd146 100644 --- a/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.js +++ b/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.js @@ -1 +1,2 @@ +"use strict"; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.js b/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.js index c7570e81192..1ceb1bcd146 100644 --- a/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.js +++ b/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.js @@ -1 +1,2 @@ +"use strict"; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/typeAliasDeclarationEmit.js b/tests/baselines/reference/typeAliasDeclarationEmit.js index 6e82fe4b07d..1f72e1d1b00 100644 --- a/tests/baselines/reference/typeAliasDeclarationEmit.js +++ b/tests/baselines/reference/typeAliasDeclarationEmit.js @@ -6,6 +6,7 @@ export type CallbackArray = () => T; //// [typeAliasDeclarationEmit.js] define(["require", "exports"], function (require, exports) { + "use strict"; }); diff --git a/tests/baselines/reference/typeAliasDeclarationEmit2.js b/tests/baselines/reference/typeAliasDeclarationEmit2.js index 4bb1bd3efd9..b94eb56a2a2 100644 --- a/tests/baselines/reference/typeAliasDeclarationEmit2.js +++ b/tests/baselines/reference/typeAliasDeclarationEmit2.js @@ -4,6 +4,7 @@ export type A = { value: a }; //// [typeAliasDeclarationEmit2.js] define(["require", "exports"], function (require, exports) { + "use strict"; }); From 5d52c9fd3b28b25d2752b5157bc51453187065c9 Mon Sep 17 00:00:00 2001 From: Andrej Baran Date: Wed, 12 Oct 2016 21:34:00 +0200 Subject: [PATCH 060/173] Move async/await into separate es2017 transformer --- Jakefile.js | 2 + src/compiler/binder.ts | 24 +- src/compiler/transformer.ts | 4 + src/compiler/transformers/es2017.ts | 544 ++++++++++++++++++ src/compiler/transformers/module/module.ts | 4 +- src/compiler/transformers/module/system.ts | 6 +- src/compiler/transformers/ts.ts | 238 +------- src/compiler/tsconfig.json | 1 + src/compiler/utilities.ts | 2 + src/harness/harness.ts | 2 + src/harness/tsconfig.json | 1 + src/services/tsconfig.json | 1 + .../{es8-async.js => es2017basicAsync.js} | 4 +- ...async.symbols => es2017basicAsync.symbols} | 22 +- ...es8-async.types => es2017basicAsync.types} | 2 +- 15 files changed, 614 insertions(+), 243 deletions(-) create mode 100644 src/compiler/transformers/es2017.ts rename tests/baselines/reference/{es8-async.js => es2017basicAsync.js} (94%) rename tests/baselines/reference/{es8-async.symbols => es2017basicAsync.symbols} (78%) rename tests/baselines/reference/{es8-async.types => es2017basicAsync.types} (94%) diff --git a/Jakefile.js b/Jakefile.js index ecbd0ae2be2..8d46368653c 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -74,6 +74,7 @@ var compilerSources = [ "transformers/module/system.ts", "transformers/module/module.ts", "transformers/jsx.ts", + "transformers/es2017.ts", "transformers/es2016.ts", "transformers/generators.ts", "transformers/es6.ts", @@ -108,6 +109,7 @@ var servicesSources = [ "transformers/module/system.ts", "transformers/module/module.ts", "transformers/jsx.ts", + "transformers/es2017.ts", "transformers/es2016.ts", "transformers/generators.ts", "transformers/es6.ts", diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index ce482dcdfd9..4edbb5d9e1a 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -2555,6 +2555,11 @@ namespace ts { // extends clause of a class. let transformFlags = subtreeFlags | TransformFlags.AssertES6; + // propagate ES2017 + if (node.expression.transformFlags & TransformFlags.ContainsES2017) { + transformFlags |= TransformFlags.ContainsES2017; + } + // If an ExpressionWithTypeArguments contains type arguments, then it // is TypeScript syntax. if (node.typeArguments) { @@ -2595,6 +2600,11 @@ namespace ts { transformFlags |= TransformFlags.AssertTypeScript; } + // Async MethodDeclaration is ES2017 + if (modifierFlags & ModifierFlags.Async) { + transformFlags |= TransformFlags.AssertES2017; + } + // Currently, we only support generators that were originally async function bodies. if (asteriskToken && getEmitFlags(node) & EmitFlags.AsyncFunctionBody) { transformFlags |= TransformFlags.AssertGenerator; @@ -2656,7 +2666,7 @@ namespace ts { // If a FunctionDeclaration is async, then it is TypeScript syntax. if (modifierFlags & ModifierFlags.Async) { - transformFlags |= TransformFlags.AssertTypeScript; + transformFlags |= TransformFlags.AssertTypeScript | TransformFlags.AssertES2017; } // If a FunctionDeclaration's subtree has marked the container as needing to capture the @@ -2687,7 +2697,7 @@ namespace ts { // An async function expression is TypeScript syntax. if (modifierFlags & ModifierFlags.Async) { - transformFlags |= TransformFlags.AssertTypeScript; + transformFlags |= TransformFlags.AssertTypeScript | TransformFlags.AssertES2017; } // If a FunctionExpression's subtree has marked the container as needing to capture the @@ -2717,7 +2727,7 @@ namespace ts { // An async arrow function is TypeScript syntax. if (modifierFlags & ModifierFlags.Async) { - transformFlags |= TransformFlags.AssertTypeScript; + transformFlags |= TransformFlags.AssertTypeScript | TransformFlags.AssertES2017; } // If an ArrowFunction contains a lexical this, its container must capture the lexical this. @@ -2856,14 +2866,18 @@ namespace ts { let excludeFlags = TransformFlags.NodeExcludes; switch (kind) { + case SyntaxKind.AsyncKeyword: + case SyntaxKind.AwaitExpression: + // Typescript async/await are ES2017 features + transformFlags |= TransformFlags.AssertTypeScript | TransformFlags.AssertES2017; + break; + case SyntaxKind.PublicKeyword: case SyntaxKind.PrivateKeyword: case SyntaxKind.ProtectedKeyword: case SyntaxKind.AbstractKeyword: case SyntaxKind.DeclareKeyword: - case SyntaxKind.AsyncKeyword: case SyntaxKind.ConstKeyword: - case SyntaxKind.AwaitExpression: case SyntaxKind.EnumDeclaration: case SyntaxKind.EnumMember: case SyntaxKind.TypeAssertionExpression: diff --git a/src/compiler/transformer.ts b/src/compiler/transformer.ts index 9e548268052..55b83ea669d 100644 --- a/src/compiler/transformer.ts +++ b/src/compiler/transformer.ts @@ -1,6 +1,7 @@ /// /// /// +/// /// /// /// @@ -115,6 +116,9 @@ namespace ts { transformers.push(transformJsx); } + if (languageVersion < ScriptTarget.ES2017) { + transformers.push(transformES2017); + } if (languageVersion < ScriptTarget.ES2016) { transformers.push(transformES2016); diff --git a/src/compiler/transformers/es2017.ts b/src/compiler/transformers/es2017.ts new file mode 100644 index 00000000000..33376bbceb1 --- /dev/null +++ b/src/compiler/transformers/es2017.ts @@ -0,0 +1,544 @@ +/// +/// + +/*@internal*/ +namespace ts { + type SuperContainer = ClassDeclaration | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | ConstructorDeclaration; + + export function transformES2017(context: TransformationContext) { + + const enum ES2017SubstitutionFlags { + /** Enables substitutions for async methods with `super` calls. */ + AsyncMethodsWithSuper = 1 << 0 + } + + const { + startLexicalEnvironment, + endLexicalEnvironment, + } = context; + + const resolver = context.getEmitResolver(); + const compilerOptions = context.getCompilerOptions(); + const languageVersion = getEmitScriptTarget(compilerOptions); + + // These variables contain state that changes as we descend into the tree. + let currentSourceFileExternalHelpersModuleName: Identifier; + /** + * Keeps track of whether expression substitution has been enabled for specific edge cases. + * They are persisted between each SourceFile transformation and should not be reset. + */ + let enabledSubstitutions: ES2017SubstitutionFlags; + + /** + * Keeps track of whether we are within any containing namespaces when performing + * just-in-time substitution while printing an expression identifier. + */ + let applicableSubstitutions: ES2017SubstitutionFlags; + + /** + * This keeps track of containers where `super` is valid, for use with + * just-in-time substitution for `super` expressions inside of async methods. + */ + let currentSuperContainer: SuperContainer; + + // Save the previous transformation hooks. + const previousOnEmitNode = context.onEmitNode; + const previousOnSubstituteNode = context.onSubstituteNode; + + // Set new transformation hooks. + context.onEmitNode = onEmitNode; + context.onSubstituteNode = onSubstituteNode; + + let currentScope: SourceFile | Block | ModuleBlock | CaseBlock; + + return transformSourceFile; + + function transformSourceFile(node: SourceFile) { + if (isDeclarationFile(node)) { + return node; + } + + currentSourceFileExternalHelpersModuleName = node.externalHelpersModuleName; + + return visitEachChild(node, visitor, context); + } + + function visitor(node: Node): VisitResult { + if (node.transformFlags & TransformFlags.ES2017) { + return visitorWorker(node); + } + else if (node.transformFlags & TransformFlags.ContainsES2017) { + return visitEachChild(node, visitor, context); + } + + // node = visitEachChild(node, visitor, context); + // return visitEachChild(node, visitor, context); + return node; + } + + function visitorWorker(node: Node): VisitResult { + switch (node.kind) { + case SyntaxKind.AsyncKeyword: + return undefined; + + case SyntaxKind.AwaitExpression: + // Typescript 'await' expressions must be transformed for targets < ES2017. + return visitAwaitExpression(node); + + case SyntaxKind.MethodDeclaration: + // TypeScript method declarations may be 'async' + return visitMethodDeclaration(node); + + case SyntaxKind.FunctionDeclaration: + // TypeScript function declarations may be 'async' + return visitFunctionDeclaration(node); + + case SyntaxKind.FunctionExpression: + // TypeScript function expressions may be 'async' + return visitFunctionExpression(node); + + case SyntaxKind.ArrowFunction: + // TypeScript arrow functions may be 'async' + return visitArrowFunction(node); + + default: + Debug.failBadSyntaxKind(node); + return node; + } + } + + /** + * Visits an await expression. + * + * This function will be called any time a ES2017 await expression is encountered. + * + * @param node The await expression node. + */ + function visitAwaitExpression(node: AwaitExpression): Expression { + return setOriginalNode( + createYield( + /*asteriskToken*/ undefined, + visitNode(node.expression, visitor, isExpression), + /*location*/ node + ), + node + ); + } + + /** + * Visits a method declaration of a class. + * + * This function will be called when one of the following conditions are met: + * - The node is marked as async + * + * @param node The method node. + */ + function visitMethodDeclaration(node: MethodDeclaration) { + if (!isAsyncFunctionLike(node)) { + return node; + } + const method = createMethod( + /*decorators*/ undefined, + visitNodes(node.modifiers, visitor, isModifier), + node.asteriskToken, + node.name, + /*typeParameters*/ undefined, + visitNodes(node.parameters, visitor, isParameter), + /*type*/ undefined, + transformFunctionBody(node), + /*location*/ node + ); + + // While we emit the source map for the node after skipping decorators and modifiers, + // we need to emit the comments for the original range. + setCommentRange(method, node); + setSourceMapRange(method, moveRangePastDecorators(node)); + setOriginalNode(method, node); + + return method; + } + + /** + * Visits a function declaration. + * + * This function will be called when one of the following conditions are met: + * - The node is an overload + * - The node is marked async + * - The node is exported from a TypeScript namespace + * + * @param node The function node. + */ + function visitFunctionDeclaration(node: FunctionDeclaration): VisitResult { + if (!isAsyncFunctionLike(node)) { + return node; + } + const func = createFunctionDeclaration( + /*decorators*/ undefined, + visitNodes(node.modifiers, visitor, isModifier), + node.asteriskToken, + node.name, + /*typeParameters*/ undefined, + visitNodes(node.parameters, visitor, isParameter), + /*type*/ undefined, + transformFunctionBody(node), + /*location*/ node + ); + setOriginalNode(func, node); + + return func; + } + + /** + * Visits a function expression node. + * + * This function will be called when one of the following conditions are met: + * - The node is marked async + * + * @param node The function expression node. + */ + function visitFunctionExpression(node: FunctionExpression): Expression { + if (!isAsyncFunctionLike(node)) { + return node; + } + if (nodeIsMissing(node.body)) { + return createOmittedExpression(); + } + + const func = createFunctionExpression( + node.asteriskToken, + node.name, + /*typeParameters*/ undefined, + visitNodes(node.parameters, visitor, isParameter), + /*type*/ undefined, + transformFunctionBody(node), + /*location*/ node + ); + + node.modifiers = visitNodes(node.modifiers, visitor, isModifier); + + setOriginalNode(func, node); + + return func; + } + + /** + * @remarks + * This function will be called when one of the following conditions are met: + * - The node is marked async + */ + function visitArrowFunction(node: ArrowFunction) { + if (!isAsyncFunctionLike(node)) { + return node; + } + const func = createArrowFunction( + visitNodes(node.modifiers, visitor, isModifier), + /*typeParameters*/ undefined, + visitNodes(node.parameters, visitor, isParameter), + /*type*/ undefined, + node.equalsGreaterThanToken, + transformConciseBody(node), + /*location*/ node + ); + + setOriginalNode(func, node); + + return func; + } + + function transformFunctionBody(node: MethodDeclaration | AccessorDeclaration | FunctionDeclaration | FunctionExpression): FunctionBody { + return transformAsyncFunctionBody(node); + } + + function transformConciseBody(node: ArrowFunction): ConciseBody { + return transformAsyncFunctionBody(node); + } + + function transformFunctionBodyWorker(body: Block, start = 0) { + const savedCurrentScope = currentScope; + currentScope = body; + startLexicalEnvironment(); + + const statements = visitNodes(body.statements, visitor, isStatement, start); + const visited = updateBlock(body, statements); + const declarations = endLexicalEnvironment(); + currentScope = savedCurrentScope; + return mergeFunctionBodyLexicalEnvironment(visited, declarations); + } + + function transformAsyncFunctionBody(node: FunctionLikeDeclaration): ConciseBody | FunctionBody { + const nodeType = node.original ? (node.original).type : node.type; + const promiseConstructor = languageVersion < ScriptTarget.ES6 ? getPromiseConstructor(nodeType) : undefined; + const isArrowFunction = node.kind === SyntaxKind.ArrowFunction; + const hasLexicalArguments = (resolver.getNodeCheckFlags(node) & NodeCheckFlags.CaptureArguments) !== 0; + + // An async function is emit as an outer function that calls an inner + // generator function. To preserve lexical bindings, we pass the current + // `this` and `arguments` objects to `__awaiter`. The generator function + // passed to `__awaiter` is executed inside of the callback to the + // promise constructor. + + + if (!isArrowFunction) { + const statements: Statement[] = []; + const statementOffset = addPrologueDirectives(statements, (node.body).statements, /*ensureUseStrict*/ false, visitor); + statements.push( + createReturn( + createAwaiterHelper( + currentSourceFileExternalHelpersModuleName, + hasLexicalArguments, + promiseConstructor, + transformFunctionBodyWorker(node.body, statementOffset) + ) + ) + ); + + const block = createBlock(statements, /*location*/ node.body, /*multiLine*/ true); + + // Minor optimization, emit `_super` helper to capture `super` access in an arrow. + // This step isn't needed if we eventually transform this to ES5. + if (languageVersion >= ScriptTarget.ES6) { + if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.AsyncMethodWithSuperBinding) { + enableSubstitutionForAsyncMethodsWithSuper(); + setEmitFlags(block, EmitFlags.EmitAdvancedSuperHelper); + } + else if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.AsyncMethodWithSuper) { + enableSubstitutionForAsyncMethodsWithSuper(); + setEmitFlags(block, EmitFlags.EmitSuperHelper); + } + } + + return block; + } + else { + return createAwaiterHelper( + currentSourceFileExternalHelpersModuleName, + hasLexicalArguments, + promiseConstructor, + transformConciseBodyWorker(node.body, /*forceBlockFunctionBody*/ true) + ); + } + } + + function transformConciseBodyWorker(body: Block | Expression, forceBlockFunctionBody: boolean) { + if (isBlock(body)) { + return transformFunctionBodyWorker(body); + } + else { + startLexicalEnvironment(); + const visited: Expression | Block = visitNode(body, visitor, isConciseBody); + const declarations = endLexicalEnvironment(); + const merged = mergeFunctionBodyLexicalEnvironment(visited, declarations); + if (forceBlockFunctionBody && !isBlock(merged)) { + return createBlock([ + createReturn(merged) + ]); + } + else { + return merged; + } + } + } + + function getPromiseConstructor(type: TypeNode) { + const typeName = getEntityNameFromTypeNode(type); + if (typeName && isEntityName(typeName)) { + const serializationKind = resolver.getTypeReferenceSerializationKind(typeName); + if (serializationKind === TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue + || serializationKind === TypeReferenceSerializationKind.Unknown) { + return typeName; + } + } + + return undefined; + } + + function enableSubstitutionForAsyncMethodsWithSuper() { + if ((enabledSubstitutions & ES2017SubstitutionFlags.AsyncMethodsWithSuper) === 0) { + enabledSubstitutions |= ES2017SubstitutionFlags.AsyncMethodsWithSuper; + + // We need to enable substitutions for call, property access, and element access + // if we need to rewrite super calls. + context.enableSubstitution(SyntaxKind.CallExpression); + context.enableSubstitution(SyntaxKind.PropertyAccessExpression); + context.enableSubstitution(SyntaxKind.ElementAccessExpression); + + // We need to be notified when entering and exiting declarations that bind super. + context.enableEmitNotification(SyntaxKind.ClassDeclaration); + context.enableEmitNotification(SyntaxKind.MethodDeclaration); + context.enableEmitNotification(SyntaxKind.GetAccessor); + context.enableEmitNotification(SyntaxKind.SetAccessor); + context.enableEmitNotification(SyntaxKind.Constructor); + } + } + + function substituteExpression(node: Expression) { + switch (node.kind) { + case SyntaxKind.PropertyAccessExpression: + return substitutePropertyAccessExpression(node); + case SyntaxKind.ElementAccessExpression: + return substituteElementAccessExpression(node); + case SyntaxKind.CallExpression: + if (enabledSubstitutions & ES2017SubstitutionFlags.AsyncMethodsWithSuper) { + return substituteCallExpression(node); + } + break; + } + + return node; + } + + function substitutePropertyAccessExpression(node: PropertyAccessExpression) { + if (enabledSubstitutions & ES2017SubstitutionFlags.AsyncMethodsWithSuper && node.expression.kind === SyntaxKind.SuperKeyword) { + const flags = getSuperContainerAsyncMethodFlags(); + if (flags) { + return createSuperAccessInAsyncMethod( + createLiteral(node.name.text), + flags, + node + ); + } + } + + return substituteConstantValue(node); + } + + function substituteElementAccessExpression(node: ElementAccessExpression) { + if (enabledSubstitutions & ES2017SubstitutionFlags.AsyncMethodsWithSuper && node.expression.kind === SyntaxKind.SuperKeyword) { + const flags = getSuperContainerAsyncMethodFlags(); + if (flags) { + return createSuperAccessInAsyncMethod( + node.argumentExpression, + flags, + node + ); + } + } + + return substituteConstantValue(node); + } + + function substituteConstantValue(node: PropertyAccessExpression | ElementAccessExpression): LeftHandSideExpression { + const constantValue = tryGetConstEnumValue(node); + if (constantValue !== undefined) { + const substitute = createLiteral(constantValue); + setSourceMapRange(substitute, node); + setCommentRange(substitute, node); + if (!compilerOptions.removeComments) { + const propertyName = isPropertyAccessExpression(node) + ? declarationNameToString(node.name) + : getTextOfNode(node.argumentExpression); + substitute.trailingComment = ` ${propertyName} `; + } + + setConstantValue(node, constantValue); + return substitute; + } + + return node; + } + + function tryGetConstEnumValue(node: Node): number { + if (compilerOptions.isolatedModules) { + return undefined; + } + + return isPropertyAccessExpression(node) || isElementAccessExpression(node) + ? resolver.getConstantValue(node) + : undefined; + } + + function substituteCallExpression(node: CallExpression): Expression { + const expression = node.expression; + if (isSuperProperty(expression)) { + const flags = getSuperContainerAsyncMethodFlags(); + if (flags) { + const argumentExpression = isPropertyAccessExpression(expression) + ? substitutePropertyAccessExpression(expression) + : substituteElementAccessExpression(expression); + return createCall( + createPropertyAccess(argumentExpression, "call"), + /*typeArguments*/ undefined, + [ + createThis(), + ...node.arguments + ] + ); + } + } + return node; + } + + function isSuperContainer(node: Node): node is SuperContainer { + const kind = node.kind; + return kind === SyntaxKind.ClassDeclaration + || kind === SyntaxKind.Constructor + || kind === SyntaxKind.MethodDeclaration + || kind === SyntaxKind.GetAccessor + || kind === SyntaxKind.SetAccessor; + } + + /** + * Hook for node emit. + * + * @param node The node to emit. + * @param emit A callback used to emit the node in the printer. + */ + function onEmitNode(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void { + const savedApplicableSubstitutions = applicableSubstitutions; + const savedCurrentSuperContainer = currentSuperContainer; + // If we need to support substitutions for `super` in an async method, + // we should track it here. + if (enabledSubstitutions & ES2017SubstitutionFlags.AsyncMethodsWithSuper && isSuperContainer(node)) { + currentSuperContainer = node; + } + + previousOnEmitNode(emitContext, node, emitCallback); + + applicableSubstitutions = savedApplicableSubstitutions; + currentSuperContainer = savedCurrentSuperContainer; + } + + /** + * Hooks node substitutions. + * + * @param node The node to substitute. + * @param isExpression A value indicating whether the node is to be used in an expression + * position. + */ + function onSubstituteNode(emitContext: EmitContext, node: Node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === EmitContext.Expression) { + return substituteExpression(node); + } + + return node; + } + + function createSuperAccessInAsyncMethod(argumentExpression: Expression, flags: NodeCheckFlags, location: TextRange): LeftHandSideExpression { + if (flags & NodeCheckFlags.AsyncMethodWithSuperBinding) { + return createPropertyAccess( + createCall( + createIdentifier("_super"), + /*typeArguments*/ undefined, + [argumentExpression] + ), + "value", + location + ); + } + else { + return createCall( + createIdentifier("_super"), + /*typeArguments*/ undefined, + [argumentExpression], + location + ); + } + } + + function getSuperContainerAsyncMethodFlags() { + return currentSuperContainer !== undefined + && resolver.getNodeCheckFlags(currentSuperContainer) & (NodeCheckFlags.AsyncMethodWithSuper | NodeCheckFlags.AsyncMethodWithSuperBinding); + } + } +} diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index c4e9b4c31c8..3877169e6c3 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -701,11 +701,13 @@ namespace ts { const statements: Statement[] = []; const name = node.name || getGeneratedNameForNode(node); if (hasModifier(node, ModifierFlags.Export)) { + // Keep async modifier for ES2017 transformer + const isAsync = hasModifier(node, ModifierFlags.Async); statements.push( setOriginalNode( createFunctionDeclaration( /*decorators*/ undefined, - /*modifiers*/ undefined, + isAsync ? [createNode(SyntaxKind.AsyncKeyword)] : undefined, node.asteriskToken, name, /*typeParameters*/ undefined, diff --git a/src/compiler/transformers/module/system.ts b/src/compiler/transformers/module/system.ts index 4a137c89a93..d4ee4f36b87 100644 --- a/src/compiler/transformers/module/system.ts +++ b/src/compiler/transformers/module/system.ts @@ -662,9 +662,11 @@ namespace ts { if (hasModifier(node, ModifierFlags.Export)) { // If the function is exported, ensure it has a name and rewrite the function without any export flags. const name = node.name || getGeneratedNameForNode(node); + // Keep async modifier for ES2017 transformer + const isAsync = hasModifier(node, ModifierFlags.Async); const newNode = createFunctionDeclaration( /*decorators*/ undefined, - /*modifiers*/ undefined, + isAsync ? [createNode(SyntaxKind.AsyncKeyword)] : undefined, node.asteriskToken, name, /*typeParameters*/ undefined, @@ -1402,4 +1404,4 @@ namespace ts { return updated; } } -} \ No newline at end of file +} diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index c98fbfc26cc..30276deff92 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -4,8 +4,6 @@ /*@internal*/ namespace ts { - type SuperContainer = ClassDeclaration | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | ConstructorDeclaration; - /** * Indicates whether to emit type metadata in the new format. */ @@ -16,8 +14,6 @@ namespace ts { ClassAliases = 1 << 0, /** Enables substitutions for namespace exports. */ NamespaceExports = 1 << 1, - /** Enables substitutions for async methods with `super` calls. */ - AsyncMethodsWithSuper = 1 << 2, /* Enables substitutions for unqualified enum members */ NonQualifiedEnumMembers = 1 << 3 } @@ -72,12 +68,6 @@ namespace ts { */ let applicableSubstitutions: TypeScriptSubstitutionFlags; - /** - * This keeps track of containers where `super` is valid, for use with - * just-in-time substitution for `super` expressions inside of async methods. - */ - let currentSuperContainer: SuperContainer; - return transformSourceFile; /** @@ -240,6 +230,7 @@ namespace ts { // ES6 export and default modifiers are elided when inside a namespace. return currentNamespace ? undefined : node; + // Typescript ES2017 async/await are handled by ES2017 transformer case SyntaxKind.AsyncKeyword: return node; @@ -388,7 +379,7 @@ namespace ts { return visitEnumDeclaration(node); case SyntaxKind.AwaitExpression: - // TypeScript 'await' expressions must be transformed. + // Typescript ES2017 async/await are handled by ES2017 transformer return visitAwaitExpression(node); case SyntaxKind.VariableStatement: @@ -2225,13 +2216,9 @@ namespace ts { /*location*/ node ); - // Add ES8 async function expression modifier - // Not sure this is the right place? Might be better to move this - // into createFunctionExpression itself. - if ((languageVersion >= ScriptTarget.ES8) && isAsyncFunctionLike(node)) { - const funcModifiers = visitNodes(node.modifiers, visitor, isModifier); - func.modifiers = createNodeArray(funcModifiers); - } + // Keep modifiers in case of async functions + const funcModifiers = visitNodes(node.modifiers, visitor, isModifier); + func.modifiers = createNodeArray(funcModifiers); setOriginalNode(func, node); @@ -2260,9 +2247,9 @@ namespace ts { } function transformFunctionBody(node: MethodDeclaration | AccessorDeclaration | FunctionDeclaration | FunctionExpression): FunctionBody { - if (isAsyncFunctionLike(node) && languageVersion < ScriptTarget.ES8) { - return transformAsyncFunctionBody(node); - } + // if (isAsyncFunctionLike(node) && languageVersion < ScriptTarget.ES2017) { + // return transformAsyncFunctionBody(node); + // } return transformFunctionBodyWorker(node.body); } @@ -2280,9 +2267,9 @@ namespace ts { } function transformConciseBody(node: ArrowFunction): ConciseBody { - if (isAsyncFunctionLike(node) && languageVersion < ScriptTarget.ES8) { - return transformAsyncFunctionBody(node); - } + // if (isAsyncFunctionLike(node) && languageVersion < ScriptTarget.ES2017) { + // return transformAsyncFunctionBody(node); + // } return transformConciseBodyWorker(node.body, /*forceBlockFunctionBody*/ false); } @@ -2307,72 +2294,6 @@ namespace ts { } } - function getPromiseConstructor(type: TypeNode) { - const typeName = getEntityNameFromTypeNode(type); - if (typeName && isEntityName(typeName)) { - const serializationKind = resolver.getTypeReferenceSerializationKind(typeName); - if (serializationKind === TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue - || serializationKind === TypeReferenceSerializationKind.Unknown) { - return typeName; - } - } - - return undefined; - } - - function transformAsyncFunctionBody(node: FunctionLikeDeclaration): ConciseBody | FunctionBody { - const promiseConstructor = languageVersion < ScriptTarget.ES6 ? getPromiseConstructor(node.type) : undefined; - const isArrowFunction = node.kind === SyntaxKind.ArrowFunction; - const hasLexicalArguments = (resolver.getNodeCheckFlags(node) & NodeCheckFlags.CaptureArguments) !== 0; - - // An async function is emit as an outer function that calls an inner - // generator function. To preserve lexical bindings, we pass the current - // `this` and `arguments` objects to `__awaiter`. The generator function - // passed to `__awaiter` is executed inside of the callback to the - // promise constructor. - - - if (!isArrowFunction) { - const statements: Statement[] = []; - const statementOffset = addPrologueDirectives(statements, (node.body).statements, /*ensureUseStrict*/ false, visitor); - statements.push( - createReturn( - createAwaiterHelper( - currentSourceFileExternalHelpersModuleName, - hasLexicalArguments, - promiseConstructor, - transformFunctionBodyWorker(node.body, statementOffset) - ) - ) - ); - - const block = createBlock(statements, /*location*/ node.body, /*multiLine*/ true); - - // Minor optimization, emit `_super` helper to capture `super` access in an arrow. - // This step isn't needed if we eventually transform this to ES5. - if (languageVersion >= ScriptTarget.ES6) { - if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.AsyncMethodWithSuperBinding) { - enableSubstitutionForAsyncMethodsWithSuper(); - setEmitFlags(block, EmitFlags.EmitAdvancedSuperHelper); - } - else if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.AsyncMethodWithSuper) { - enableSubstitutionForAsyncMethodsWithSuper(); - setEmitFlags(block, EmitFlags.EmitSuperHelper); - } - } - - return block; - } - else { - return createAwaiterHelper( - currentSourceFileExternalHelpersModuleName, - hasLexicalArguments, - promiseConstructor, - transformConciseBodyWorker(node.body, /*forceBlockFunctionBody*/ true) - ); - } - } - /** * Visits a parameter declaration node. * @@ -2458,33 +2379,18 @@ namespace ts { /** * Visits an await expression. * - * This function will be called any time a TypeScript await expression is encountered. + * This function will be called any time a ES2017 await expression is encountered. * * @param node The await expression node. */ function visitAwaitExpression(node: AwaitExpression): Expression { - const targetAtLeastES8 = languageVersion >= ScriptTarget.ES8; - return setOriginalNode( - targetAtLeastES8 ? createAwaitExpression() : createYieldExpression(), + return updateNode( + createAwait( + visitNode(node.expression, visitor, isExpression), + /*location*/ node + ), node ); - - function createAwaitExpression() { - const awaitExpression = createAwait( - visitNode(node.expression, visitor, isExpression), - /*location*/ node - ); - return awaitExpression; - } - - function createYieldExpression() { - const yieldExpression = createYield( - /*asteriskToken*/ undefined, - visitNode(node.expression, visitor, isExpression), - /*location*/ node - ); - return yieldExpression; - } } /** @@ -3241,25 +3147,6 @@ namespace ts { } } - function enableSubstitutionForAsyncMethodsWithSuper() { - if ((enabledSubstitutions & TypeScriptSubstitutionFlags.AsyncMethodsWithSuper) === 0) { - enabledSubstitutions |= TypeScriptSubstitutionFlags.AsyncMethodsWithSuper; - - // We need to enable substitutions for call, property access, and element access - // if we need to rewrite super calls. - context.enableSubstitution(SyntaxKind.CallExpression); - context.enableSubstitution(SyntaxKind.PropertyAccessExpression); - context.enableSubstitution(SyntaxKind.ElementAccessExpression); - - // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(SyntaxKind.ClassDeclaration); - context.enableEmitNotification(SyntaxKind.MethodDeclaration); - context.enableEmitNotification(SyntaxKind.GetAccessor); - context.enableEmitNotification(SyntaxKind.SetAccessor); - context.enableEmitNotification(SyntaxKind.Constructor); - } - } - function enableSubstitutionForClassAliases() { if ((enabledSubstitutions & TypeScriptSubstitutionFlags.ClassAliases) === 0) { enabledSubstitutions |= TypeScriptSubstitutionFlags.ClassAliases; @@ -3287,15 +3174,6 @@ namespace ts { } } - function isSuperContainer(node: Node): node is SuperContainer { - const kind = node.kind; - return kind === SyntaxKind.ClassDeclaration - || kind === SyntaxKind.Constructor - || kind === SyntaxKind.MethodDeclaration - || kind === SyntaxKind.GetAccessor - || kind === SyntaxKind.SetAccessor; - } - function isTransformedModuleDeclaration(node: Node): boolean { return getOriginalNode(node).kind === SyntaxKind.ModuleDeclaration; } @@ -3312,12 +3190,6 @@ namespace ts { */ function onEmitNode(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void { const savedApplicableSubstitutions = applicableSubstitutions; - const savedCurrentSuperContainer = currentSuperContainer; - // If we need to support substitutions for `super` in an async method, - // we should track it here. - if (enabledSubstitutions & TypeScriptSubstitutionFlags.AsyncMethodsWithSuper && isSuperContainer(node)) { - currentSuperContainer = node; - } if (enabledSubstitutions & TypeScriptSubstitutionFlags.NamespaceExports && isTransformedModuleDeclaration(node)) { applicableSubstitutions |= TypeScriptSubstitutionFlags.NamespaceExports; @@ -3330,7 +3202,6 @@ namespace ts { previousOnEmitNode(emitContext, node, emitCallback); applicableSubstitutions = savedApplicableSubstitutions; - currentSuperContainer = savedCurrentSuperContainer; } /** @@ -3377,11 +3248,6 @@ namespace ts { return substitutePropertyAccessExpression(node); case SyntaxKind.ElementAccessExpression: return substituteElementAccessExpression(node); - case SyntaxKind.CallExpression: - if (enabledSubstitutions & TypeScriptSubstitutionFlags.AsyncMethodsWithSuper) { - return substituteCallExpression(node); - } - break; } return node; @@ -3436,54 +3302,11 @@ namespace ts { return undefined; } - function substituteCallExpression(node: CallExpression): Expression { - const expression = node.expression; - if (isSuperProperty(expression)) { - const flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - const argumentExpression = isPropertyAccessExpression(expression) - ? substitutePropertyAccessExpression(expression) - : substituteElementAccessExpression(expression); - return createCall( - createPropertyAccess(argumentExpression, "call"), - /*typeArguments*/ undefined, - [ - createThis(), - ...node.arguments - ] - ); - } - } - return node; - } - function substitutePropertyAccessExpression(node: PropertyAccessExpression) { - if (enabledSubstitutions & TypeScriptSubstitutionFlags.AsyncMethodsWithSuper && node.expression.kind === SyntaxKind.SuperKeyword) { - const flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - return createSuperAccessInAsyncMethod( - createLiteral(node.name.text), - flags, - node - ); - } - } - return substituteConstantValue(node); } function substituteElementAccessExpression(node: ElementAccessExpression) { - if (enabledSubstitutions & TypeScriptSubstitutionFlags.AsyncMethodsWithSuper && node.expression.kind === SyntaxKind.SuperKeyword) { - const flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - return createSuperAccessInAsyncMethod( - node.argumentExpression, - flags, - node - ); - } - } - return substituteConstantValue(node); } @@ -3516,32 +3339,5 @@ namespace ts { ? resolver.getConstantValue(node) : undefined; } - - function createSuperAccessInAsyncMethod(argumentExpression: Expression, flags: NodeCheckFlags, location: TextRange): LeftHandSideExpression { - if (flags & NodeCheckFlags.AsyncMethodWithSuperBinding) { - return createPropertyAccess( - createCall( - createIdentifier("_super"), - /*typeArguments*/ undefined, - [argumentExpression] - ), - "value", - location - ); - } - else { - return createCall( - createIdentifier("_super"), - /*typeArguments*/ undefined, - [argumentExpression], - location - ); - } - } - - function getSuperContainerAsyncMethodFlags() { - return currentSuperContainer !== undefined - && resolver.getNodeCheckFlags(currentSuperContainer) & (NodeCheckFlags.AsyncMethodWithSuper | NodeCheckFlags.AsyncMethodWithSuperBinding); - } } } diff --git a/src/compiler/tsconfig.json b/src/compiler/tsconfig.json index fc0f016f664..de710e74a46 100644 --- a/src/compiler/tsconfig.json +++ b/src/compiler/tsconfig.json @@ -24,6 +24,7 @@ "visitor.ts", "transformers/ts.ts", "transformers/jsx.ts", + "transformers/es2017.ts", "transformers/es2016.ts", "transformers/es6.ts", "transformers/generators.ts", diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index b661cefb5a6..92ce6ecc6a4 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -4142,6 +4142,8 @@ namespace ts { namespace ts { export function getDefaultLibFileName(options: CompilerOptions): string { switch (options.target) { + case ScriptTarget.ES2017: + return "lib.es2017.d.ts"; case ScriptTarget.ES2016: return "lib.es2016.d.ts"; case ScriptTarget.ES6: diff --git a/src/harness/harness.ts b/src/harness/harness.ts index b8703ebc8f2..c50f33a74c3 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -942,6 +942,8 @@ namespace Harness { export function getDefaultLibFileName(options: ts.CompilerOptions): string { switch (options.target) { + case ts.ScriptTarget.ES2017: + return "lib.es2017.d.ts"; case ts.ScriptTarget.ES2016: return "lib.es2016.d.ts"; case ts.ScriptTarget.ES6: diff --git a/src/harness/tsconfig.json b/src/harness/tsconfig.json index aa46c8ee8d0..c8b90645ce2 100644 --- a/src/harness/tsconfig.json +++ b/src/harness/tsconfig.json @@ -26,6 +26,7 @@ "../compiler/visitor.ts", "../compiler/transformers/ts.ts", "../compiler/transformers/jsx.ts", + "../compiler/transformers/es2017.ts", "../compiler/transformers/es2016.ts", "../compiler/transformers/es6.ts", "../compiler/transformers/generators.ts", diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index e759ab35b48..45e3c9036e0 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -25,6 +25,7 @@ "../compiler/visitor.ts", "../compiler/transformers/ts.ts", "../compiler/transformers/jsx.ts", + "../compiler/transformers/es2017.ts", "../compiler/transformers/es2016.ts", "../compiler/transformers/es6.ts", "../compiler/transformers/generators.ts", diff --git a/tests/baselines/reference/es8-async.js b/tests/baselines/reference/es2017basicAsync.js similarity index 94% rename from tests/baselines/reference/es8-async.js rename to tests/baselines/reference/es2017basicAsync.js index 3338b1f88a6..da219f4614c 100644 --- a/tests/baselines/reference/es8-async.js +++ b/tests/baselines/reference/es2017basicAsync.js @@ -1,4 +1,4 @@ -//// [es8-async.ts] +//// [es2017-async.ts] async (): Promise => { await 0; @@ -47,7 +47,7 @@ class AsyncClass { } -//// [es8-async.js] +//// [es2017-async.js] async () => { await 0; }; diff --git a/tests/baselines/reference/es8-async.symbols b/tests/baselines/reference/es2017basicAsync.symbols similarity index 78% rename from tests/baselines/reference/es8-async.symbols rename to tests/baselines/reference/es2017basicAsync.symbols index 25a77351aef..be3b2e723f4 100644 --- a/tests/baselines/reference/es8-async.symbols +++ b/tests/baselines/reference/es2017basicAsync.symbols @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es8-async.ts === +=== tests/cases/compiler/es2017-async.ts === async (): Promise => { >Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) @@ -7,20 +7,20 @@ async (): Promise => { } async function asyncFunc() { ->asyncFunc : Symbol(asyncFunc, Decl(es8-async.ts, 3, 1)) +>asyncFunc : Symbol(asyncFunc, Decl(es2017-async.ts, 3, 1)) await 0; } const asycnArrowFunc = async (): Promise => { ->asycnArrowFunc : Symbol(asycnArrowFunc, Decl(es8-async.ts, 9, 5)) +>asycnArrowFunc : Symbol(asycnArrowFunc, Decl(es2017-async.ts, 9, 5)) >Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) await 0; } async function asyncIIFE() { ->asyncIIFE : Symbol(asyncIIFE, Decl(es8-async.ts, 11, 1)) +>asyncIIFE : Symbol(asyncIIFE, Decl(es2017-async.ts, 11, 1)) await 0; @@ -31,7 +31,7 @@ async function asyncIIFE() { })(); await (async function asyncNamedFunc(): Promise { ->asyncNamedFunc : Symbol(asyncNamedFunc, Decl(es8-async.ts, 20, 11)) +>asyncNamedFunc : Symbol(asyncNamedFunc, Decl(es2017-async.ts, 20, 11)) >Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) await 1; @@ -45,32 +45,32 @@ async function asyncIIFE() { } class AsyncClass { ->AsyncClass : Symbol(AsyncClass, Decl(es8-async.ts, 27, 1)) +>AsyncClass : Symbol(AsyncClass, Decl(es2017-async.ts, 27, 1)) asyncPropFunc = async function(): Promise { ->asyncPropFunc : Symbol(AsyncClass.asyncPropFunc, Decl(es8-async.ts, 29, 18)) +>asyncPropFunc : Symbol(AsyncClass.asyncPropFunc, Decl(es2017-async.ts, 29, 18)) >Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) await 2; } asyncPropNamedFunc = async function namedFunc(): Promise { ->asyncPropNamedFunc : Symbol(AsyncClass.asyncPropNamedFunc, Decl(es8-async.ts, 32, 5)) ->namedFunc : Symbol(namedFunc, Decl(es8-async.ts, 34, 24)) +>asyncPropNamedFunc : Symbol(AsyncClass.asyncPropNamedFunc, Decl(es2017-async.ts, 32, 5)) +>namedFunc : Symbol(namedFunc, Decl(es2017-async.ts, 34, 24)) >Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) await 2; } asyncPropArrowFunc = async (): Promise => { ->asyncPropArrowFunc : Symbol(AsyncClass.asyncPropArrowFunc, Decl(es8-async.ts, 36, 5)) +>asyncPropArrowFunc : Symbol(AsyncClass.asyncPropArrowFunc, Decl(es2017-async.ts, 36, 5)) >Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) await 2; } async asyncMethod(): Promise { ->asyncMethod : Symbol(AsyncClass.asyncMethod, Decl(es8-async.ts, 40, 5)) +>asyncMethod : Symbol(AsyncClass.asyncMethod, Decl(es2017-async.ts, 40, 5)) >Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) await 2; diff --git a/tests/baselines/reference/es8-async.types b/tests/baselines/reference/es2017basicAsync.types similarity index 94% rename from tests/baselines/reference/es8-async.types rename to tests/baselines/reference/es2017basicAsync.types index da0ca063777..79f3a005e6e 100644 --- a/tests/baselines/reference/es8-async.types +++ b/tests/baselines/reference/es2017basicAsync.types @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es8-async.ts === +=== tests/cases/compiler/es2017-async.ts === async (): Promise => { >async (): Promise => { await 0;} : () => Promise From 1b4c0e331e5aa11133f0a36e1ba24d7ee748a58a Mon Sep 17 00:00:00 2001 From: Andrej Baran Date: Wed, 12 Oct 2016 21:34:55 +0200 Subject: [PATCH 061/173] Add es2017 async conformance --- ...owFunctionWithParameterNameAsync_es2017.js | 6 + ...ctionWithParameterNameAsync_es2017.symbols | 7 + ...unctionWithParameterNameAsync_es2017.types | 8 ++ .../reference/asyncAliasReturnType_es2017.js | 9 ++ .../asyncAliasReturnType_es2017.symbols | 11 ++ .../asyncAliasReturnType_es2017.types | 11 ++ .../asyncArrowFunction10_es2017.errors.txt | 12 ++ .../reference/asyncArrowFunction10_es2017.js | 13 ++ .../reference/asyncArrowFunction1_es2017.js | 8 ++ .../asyncArrowFunction1_es2017.symbols | 7 + .../asyncArrowFunction1_es2017.types | 8 ++ .../reference/asyncArrowFunction2_es2017.js | 7 + .../asyncArrowFunction2_es2017.symbols | 5 + .../asyncArrowFunction2_es2017.types | 6 + .../asyncArrowFunction3_es2017.errors.txt | 8 ++ .../reference/asyncArrowFunction3_es2017.js | 7 + .../reference/asyncArrowFunction4_es2017.js | 7 + .../asyncArrowFunction4_es2017.symbols | 4 + .../asyncArrowFunction4_es2017.types | 5 + .../asyncArrowFunction5_es2017.errors.txt | 24 ++++ .../reference/asyncArrowFunction5_es2017.js | 9 ++ .../asyncArrowFunction6_es2017.errors.txt | 12 ++ .../reference/asyncArrowFunction6_es2017.js | 8 ++ .../asyncArrowFunction7_es2017.errors.txt | 15 ++ .../reference/asyncArrowFunction7_es2017.js | 14 ++ .../asyncArrowFunction8_es2017.errors.txt | 10 ++ .../reference/asyncArrowFunction8_es2017.js | 10 ++ .../asyncArrowFunction9_es2017.errors.txt | 23 ++++ .../reference/asyncArrowFunction9_es2017.js | 8 ++ ...ncArrowFunctionCapturesArguments_es2017.js | 16 +++ ...owFunctionCapturesArguments_es2017.symbols | 20 +++ ...rrowFunctionCapturesArguments_es2017.types | 23 ++++ .../asyncArrowFunctionCapturesThis_es2017.js | 14 ++ ...ncArrowFunctionCapturesThis_es2017.symbols | 13 ++ ...syncArrowFunctionCapturesThis_es2017.types | 15 ++ ...syncAwaitIsolatedModules_es2017.errors.txt | 45 ++++++ .../asyncAwaitIsolatedModules_es2017.js | 73 ++++++++++ .../baselines/reference/asyncAwait_es2017.js | 73 ++++++++++ .../reference/asyncAwait_es2017.symbols | 118 ++++++++++++++++ .../reference/asyncAwait_es2017.types | 129 ++++++++++++++++++ .../reference/asyncClass_es2017.errors.txt | 8 ++ .../baselines/reference/asyncClass_es2017.js | 7 + .../asyncConstructor_es2017.errors.txt | 10 ++ .../reference/asyncConstructor_es2017.js | 11 ++ .../reference/asyncDeclare_es2017.errors.txt | 7 + .../reference/asyncDeclare_es2017.js | 4 + .../reference/asyncEnum_es2017.errors.txt | 9 ++ tests/baselines/reference/asyncEnum_es2017.js | 10 ++ ...yncFunctionDeclaration10_es2017.errors.txt | 26 ++++ .../asyncFunctionDeclaration10_es2017.js | 7 + .../asyncFunctionDeclaration11_es2017.js | 7 + .../asyncFunctionDeclaration11_es2017.symbols | 5 + .../asyncFunctionDeclaration11_es2017.types | 5 + ...yncFunctionDeclaration12_es2017.errors.txt | 16 +++ .../asyncFunctionDeclaration12_es2017.js | 5 + ...yncFunctionDeclaration13_es2017.errors.txt | 11 ++ .../asyncFunctionDeclaration13_es2017.js | 12 ++ .../asyncFunctionDeclaration14_es2017.js | 9 ++ .../asyncFunctionDeclaration14_es2017.symbols | 7 + .../asyncFunctionDeclaration14_es2017.types | 7 + ...yncFunctionDeclaration15_es2017.errors.txt | 48 +++++++ .../asyncFunctionDeclaration15_es2017.js | 64 +++++++++ .../asyncFunctionDeclaration1_es2017.js | 7 + .../asyncFunctionDeclaration1_es2017.symbols | 5 + .../asyncFunctionDeclaration1_es2017.types | 5 + .../asyncFunctionDeclaration2_es2017.js | 7 + .../asyncFunctionDeclaration2_es2017.symbols | 5 + .../asyncFunctionDeclaration2_es2017.types | 5 + ...syncFunctionDeclaration3_es2017.errors.txt | 8 ++ .../asyncFunctionDeclaration3_es2017.js | 7 + .../asyncFunctionDeclaration4_es2017.js | 7 + .../asyncFunctionDeclaration4_es2017.symbols | 4 + .../asyncFunctionDeclaration4_es2017.types | 4 + ...syncFunctionDeclaration5_es2017.errors.txt | 20 +++ .../asyncFunctionDeclaration5_es2017.js | 7 + ...syncFunctionDeclaration6_es2017.errors.txt | 11 ++ .../asyncFunctionDeclaration6_es2017.js | 7 + ...syncFunctionDeclaration7_es2017.errors.txt | 14 ++ .../asyncFunctionDeclaration7_es2017.js | 13 ++ ...syncFunctionDeclaration8_es2017.errors.txt | 10 ++ .../asyncFunctionDeclaration8_es2017.js | 5 + ...syncFunctionDeclaration9_es2017.errors.txt | 9 ++ .../asyncFunctionDeclaration9_es2017.js | 9 ++ .../reference/asyncGetter_es2017.errors.txt | 13 ++ .../baselines/reference/asyncGetter_es2017.js | 11 ++ .../asyncImportedPromise_es2017.errors.txt | 13 ++ .../reference/asyncImportedPromise_es2017.js | 21 +++ .../asyncInterface_es2017.errors.txt | 8 ++ .../reference/asyncInterface_es2017.js | 5 + .../reference/asyncMethodWithSuper_es2017.js | 90 ++++++++++++ .../asyncMethodWithSuper_es2017.symbols | 102 ++++++++++++++ .../asyncMethodWithSuper_es2017.types | 123 +++++++++++++++++ .../reference/asyncModule_es2017.errors.txt | 8 ++ .../baselines/reference/asyncModule_es2017.js | 5 + .../reference/asyncMultiFile_es2017.js | 11 ++ .../reference/asyncMultiFile_es2017.symbols | 8 ++ .../reference/asyncMultiFile_es2017.types | 8 ++ ...asyncQualifiedReturnType_es2017.errors.txt | 13 ++ .../asyncQualifiedReturnType_es2017.js | 18 +++ .../reference/asyncSetter_es2017.errors.txt | 10 ++ .../baselines/reference/asyncSetter_es2017.js | 11 ++ ...syncUnParenthesizedArrowFunction_es2017.js | 9 ++ ...nParenthesizedArrowFunction_es2017.symbols | 19 +++ ...cUnParenthesizedArrowFunction_es2017.types | 25 ++++ .../reference/asyncUseStrict_es2017.js | 13 ++ .../reference/asyncUseStrict_es2017.symbols | 18 +++ .../reference/asyncUseStrict_es2017.types | 22 +++ .../awaitBinaryExpression1_es2017.js | 17 +++ .../awaitBinaryExpression1_es2017.symbols | 29 ++++ .../awaitBinaryExpression1_es2017.types | 33 +++++ .../awaitBinaryExpression2_es2017.js | 17 +++ .../awaitBinaryExpression2_es2017.symbols | 29 ++++ .../awaitBinaryExpression2_es2017.types | 33 +++++ .../awaitBinaryExpression3_es2017.js | 17 +++ .../awaitBinaryExpression3_es2017.symbols | 29 ++++ .../awaitBinaryExpression3_es2017.types | 33 +++++ .../awaitBinaryExpression4_es2017.js | 17 +++ .../awaitBinaryExpression4_es2017.symbols | 29 ++++ .../awaitBinaryExpression4_es2017.types | 34 +++++ .../awaitBinaryExpression5_es2017.js | 19 +++ .../awaitBinaryExpression5_es2017.symbols | 34 +++++ .../awaitBinaryExpression5_es2017.types | 38 ++++++ .../reference/awaitCallExpression1_es2017.js | 21 +++ .../awaitCallExpression1_es2017.symbols | 59 ++++++++ .../awaitCallExpression1_es2017.types | 62 +++++++++ .../reference/awaitCallExpression2_es2017.js | 21 +++ .../awaitCallExpression2_es2017.symbols | 59 ++++++++ .../awaitCallExpression2_es2017.types | 63 +++++++++ .../reference/awaitCallExpression3_es2017.js | 21 +++ .../awaitCallExpression3_es2017.symbols | 59 ++++++++ .../awaitCallExpression3_es2017.types | 63 +++++++++ .../reference/awaitCallExpression4_es2017.js | 21 +++ .../awaitCallExpression4_es2017.symbols | 59 ++++++++ .../awaitCallExpression4_es2017.types | 64 +++++++++ .../reference/awaitCallExpression5_es2017.js | 21 +++ .../awaitCallExpression5_es2017.symbols | 61 +++++++++ .../awaitCallExpression5_es2017.types | 64 +++++++++ .../reference/awaitCallExpression6_es2017.js | 21 +++ .../awaitCallExpression6_es2017.symbols | 61 +++++++++ .../awaitCallExpression6_es2017.types | 65 +++++++++ .../reference/awaitCallExpression7_es2017.js | 21 +++ .../awaitCallExpression7_es2017.symbols | 61 +++++++++ .../awaitCallExpression7_es2017.types | 65 +++++++++ .../reference/awaitCallExpression8_es2017.js | 21 +++ .../awaitCallExpression8_es2017.symbols | 61 +++++++++ .../awaitCallExpression8_es2017.types | 66 +++++++++ .../reference/awaitClassExpression_es2017.js | 14 ++ .../awaitClassExpression_es2017.symbols | 18 +++ .../awaitClassExpression_es2017.types | 20 +++ .../baselines/reference/awaitUnion_es2017.js | 22 +++ .../reference/awaitUnion_es2017.symbols | 44 ++++++ .../reference/awaitUnion_es2017.types | 49 +++++++ .../reference/await_unaryExpression_es2017.js | 31 +++++ .../await_unaryExpression_es2017.symbols | 25 ++++ .../await_unaryExpression_es2017.types | 37 +++++ .../await_unaryExpression_es2017_1.js | 38 ++++++ .../await_unaryExpression_es2017_1.symbols | 31 +++++ .../await_unaryExpression_es2017_1.types | 46 +++++++ .../await_unaryExpression_es2017_2.js | 24 ++++ .../await_unaryExpression_es2017_2.symbols | 19 +++ .../await_unaryExpression_es2017_2.types | 28 ++++ .../await_unaryExpression_es2017_3.errors.txt | 27 ++++ .../await_unaryExpression_es2017_3.js | 37 +++++ tests/baselines/reference/es2017basicAsync.js | 4 +- .../reference/es2017basicAsync.symbols | 22 +-- .../reference/es2017basicAsync.types | 2 +- .../es2017/asyncAliasReturnType_es2017.ts | 6 + ...owFunctionWithParameterNameAsync_es2017.ts | 4 + .../asyncArrowFunction10_es2017.ts | 7 + .../asyncArrowFunction1_es2017.ts | 5 + .../asyncArrowFunction2_es2017.ts | 4 + .../asyncArrowFunction3_es2017.ts | 4 + .../asyncArrowFunction4_es2017.ts | 4 + .../asyncArrowFunction5_es2017.ts | 5 + .../asyncArrowFunction6_es2017.ts | 5 + .../asyncArrowFunction7_es2017.ts | 8 ++ .../asyncArrowFunction8_es2017.ts | 6 + .../asyncArrowFunction9_es2017.ts | 4 + ...ncArrowFunctionCapturesArguments_es2017.ts | 8 ++ .../asyncArrowFunctionCapturesThis_es2017.ts | 7 + ...syncUnParenthesizedArrowFunction_es2017.ts | 6 + .../asyncAwaitIsolatedModules_es2017.ts | 41 ++++++ .../async/es2017/asyncAwait_es2017.ts | 40 ++++++ .../async/es2017/asyncClass_es2017.ts | 4 + .../async/es2017/asyncConstructor_es2017.ts | 6 + .../async/es2017/asyncDeclare_es2017.ts | 3 + .../async/es2017/asyncEnum_es2017.ts | 5 + .../async/es2017/asyncGetter_es2017.ts | 6 + .../es2017/asyncImportedPromise_es2017.ts | 10 ++ .../async/es2017/asyncInterface_es2017.ts | 4 + .../es2017/asyncMethodWithSuper_es2017.ts | 52 +++++++ .../async/es2017/asyncModule_es2017.ts | 4 + .../async/es2017/asyncMultiFile_es2017.ts | 5 + .../es2017/asyncQualifiedReturnType_es2017.ts | 9 ++ .../async/es2017/asyncSetter_es2017.ts | 6 + .../async/es2017/asyncUseStrict_es2017.ts | 8 ++ .../awaitBinaryExpression1_es2017.ts | 11 ++ .../awaitBinaryExpression2_es2017.ts | 11 ++ .../awaitBinaryExpression3_es2017.ts | 11 ++ .../awaitBinaryExpression4_es2017.ts | 11 ++ .../awaitBinaryExpression5_es2017.ts | 12 ++ .../awaitCallExpression1_es2017.ts | 15 ++ .../awaitCallExpression2_es2017.ts | 15 ++ .../awaitCallExpression3_es2017.ts | 15 ++ .../awaitCallExpression4_es2017.ts | 15 ++ .../awaitCallExpression5_es2017.ts | 15 ++ .../awaitCallExpression6_es2017.ts | 15 ++ .../awaitCallExpression7_es2017.ts | 15 ++ .../awaitCallExpression8_es2017.ts | 15 ++ .../es2017/awaitClassExpression_es2017.ts | 9 ++ .../async/es2017/awaitUnion_es2017.ts | 14 ++ .../es2017/await_unaryExpression_es2017.ts | 17 +++ .../es2017/await_unaryExpression_es2017_1.ts | 21 +++ .../es2017/await_unaryExpression_es2017_2.ts | 13 ++ .../es2017/await_unaryExpression_es2017_3.ts | 19 +++ .../asyncFunctionDeclaration10_es2017.ts | 4 + .../asyncFunctionDeclaration11_es2017.ts | 4 + .../asyncFunctionDeclaration12_es2017.ts | 3 + .../asyncFunctionDeclaration13_es2017.ts | 6 + .../asyncFunctionDeclaration14_es2017.ts | 5 + .../asyncFunctionDeclaration15_es2017.ts | 25 ++++ .../asyncFunctionDeclaration1_es2017.ts | 4 + .../asyncFunctionDeclaration2_es2017.ts | 4 + .../asyncFunctionDeclaration3_es2017.ts | 4 + .../asyncFunctionDeclaration4_es2017.ts | 4 + .../asyncFunctionDeclaration5_es2017.ts | 4 + .../asyncFunctionDeclaration6_es2017.ts | 4 + .../asyncFunctionDeclaration7_es2017.ts | 7 + .../asyncFunctionDeclaration8_es2017.ts | 3 + .../asyncFunctionDeclaration9_es2017.ts | 5 + 230 files changed, 4602 insertions(+), 14 deletions(-) create mode 100644 tests/baselines/reference/arrowFunctionWithParameterNameAsync_es2017.js create mode 100644 tests/baselines/reference/arrowFunctionWithParameterNameAsync_es2017.symbols create mode 100644 tests/baselines/reference/arrowFunctionWithParameterNameAsync_es2017.types create mode 100644 tests/baselines/reference/asyncAliasReturnType_es2017.js create mode 100644 tests/baselines/reference/asyncAliasReturnType_es2017.symbols create mode 100644 tests/baselines/reference/asyncAliasReturnType_es2017.types create mode 100644 tests/baselines/reference/asyncArrowFunction10_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncArrowFunction10_es2017.js create mode 100644 tests/baselines/reference/asyncArrowFunction1_es2017.js create mode 100644 tests/baselines/reference/asyncArrowFunction1_es2017.symbols create mode 100644 tests/baselines/reference/asyncArrowFunction1_es2017.types create mode 100644 tests/baselines/reference/asyncArrowFunction2_es2017.js create mode 100644 tests/baselines/reference/asyncArrowFunction2_es2017.symbols create mode 100644 tests/baselines/reference/asyncArrowFunction2_es2017.types create mode 100644 tests/baselines/reference/asyncArrowFunction3_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncArrowFunction3_es2017.js create mode 100644 tests/baselines/reference/asyncArrowFunction4_es2017.js create mode 100644 tests/baselines/reference/asyncArrowFunction4_es2017.symbols create mode 100644 tests/baselines/reference/asyncArrowFunction4_es2017.types create mode 100644 tests/baselines/reference/asyncArrowFunction5_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncArrowFunction5_es2017.js create mode 100644 tests/baselines/reference/asyncArrowFunction6_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncArrowFunction6_es2017.js create mode 100644 tests/baselines/reference/asyncArrowFunction7_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncArrowFunction7_es2017.js create mode 100644 tests/baselines/reference/asyncArrowFunction8_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncArrowFunction8_es2017.js create mode 100644 tests/baselines/reference/asyncArrowFunction9_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncArrowFunction9_es2017.js create mode 100644 tests/baselines/reference/asyncArrowFunctionCapturesArguments_es2017.js create mode 100644 tests/baselines/reference/asyncArrowFunctionCapturesArguments_es2017.symbols create mode 100644 tests/baselines/reference/asyncArrowFunctionCapturesArguments_es2017.types create mode 100644 tests/baselines/reference/asyncArrowFunctionCapturesThis_es2017.js create mode 100644 tests/baselines/reference/asyncArrowFunctionCapturesThis_es2017.symbols create mode 100644 tests/baselines/reference/asyncArrowFunctionCapturesThis_es2017.types create mode 100644 tests/baselines/reference/asyncAwaitIsolatedModules_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncAwaitIsolatedModules_es2017.js create mode 100644 tests/baselines/reference/asyncAwait_es2017.js create mode 100644 tests/baselines/reference/asyncAwait_es2017.symbols create mode 100644 tests/baselines/reference/asyncAwait_es2017.types create mode 100644 tests/baselines/reference/asyncClass_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncClass_es2017.js create mode 100644 tests/baselines/reference/asyncConstructor_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncConstructor_es2017.js create mode 100644 tests/baselines/reference/asyncDeclare_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncDeclare_es2017.js create mode 100644 tests/baselines/reference/asyncEnum_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncEnum_es2017.js create mode 100644 tests/baselines/reference/asyncFunctionDeclaration10_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncFunctionDeclaration10_es2017.js create mode 100644 tests/baselines/reference/asyncFunctionDeclaration11_es2017.js create mode 100644 tests/baselines/reference/asyncFunctionDeclaration11_es2017.symbols create mode 100644 tests/baselines/reference/asyncFunctionDeclaration11_es2017.types create mode 100644 tests/baselines/reference/asyncFunctionDeclaration12_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncFunctionDeclaration12_es2017.js create mode 100644 tests/baselines/reference/asyncFunctionDeclaration13_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncFunctionDeclaration13_es2017.js create mode 100644 tests/baselines/reference/asyncFunctionDeclaration14_es2017.js create mode 100644 tests/baselines/reference/asyncFunctionDeclaration14_es2017.symbols create mode 100644 tests/baselines/reference/asyncFunctionDeclaration14_es2017.types create mode 100644 tests/baselines/reference/asyncFunctionDeclaration15_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncFunctionDeclaration15_es2017.js create mode 100644 tests/baselines/reference/asyncFunctionDeclaration1_es2017.js create mode 100644 tests/baselines/reference/asyncFunctionDeclaration1_es2017.symbols create mode 100644 tests/baselines/reference/asyncFunctionDeclaration1_es2017.types create mode 100644 tests/baselines/reference/asyncFunctionDeclaration2_es2017.js create mode 100644 tests/baselines/reference/asyncFunctionDeclaration2_es2017.symbols create mode 100644 tests/baselines/reference/asyncFunctionDeclaration2_es2017.types create mode 100644 tests/baselines/reference/asyncFunctionDeclaration3_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncFunctionDeclaration3_es2017.js create mode 100644 tests/baselines/reference/asyncFunctionDeclaration4_es2017.js create mode 100644 tests/baselines/reference/asyncFunctionDeclaration4_es2017.symbols create mode 100644 tests/baselines/reference/asyncFunctionDeclaration4_es2017.types create mode 100644 tests/baselines/reference/asyncFunctionDeclaration5_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncFunctionDeclaration5_es2017.js create mode 100644 tests/baselines/reference/asyncFunctionDeclaration6_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncFunctionDeclaration6_es2017.js create mode 100644 tests/baselines/reference/asyncFunctionDeclaration7_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncFunctionDeclaration7_es2017.js create mode 100644 tests/baselines/reference/asyncFunctionDeclaration8_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncFunctionDeclaration8_es2017.js create mode 100644 tests/baselines/reference/asyncFunctionDeclaration9_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncFunctionDeclaration9_es2017.js create mode 100644 tests/baselines/reference/asyncGetter_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncGetter_es2017.js create mode 100644 tests/baselines/reference/asyncImportedPromise_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncImportedPromise_es2017.js create mode 100644 tests/baselines/reference/asyncInterface_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncInterface_es2017.js create mode 100644 tests/baselines/reference/asyncMethodWithSuper_es2017.js create mode 100644 tests/baselines/reference/asyncMethodWithSuper_es2017.symbols create mode 100644 tests/baselines/reference/asyncMethodWithSuper_es2017.types create mode 100644 tests/baselines/reference/asyncModule_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncModule_es2017.js create mode 100644 tests/baselines/reference/asyncMultiFile_es2017.js create mode 100644 tests/baselines/reference/asyncMultiFile_es2017.symbols create mode 100644 tests/baselines/reference/asyncMultiFile_es2017.types create mode 100644 tests/baselines/reference/asyncQualifiedReturnType_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncQualifiedReturnType_es2017.js create mode 100644 tests/baselines/reference/asyncSetter_es2017.errors.txt create mode 100644 tests/baselines/reference/asyncSetter_es2017.js create mode 100644 tests/baselines/reference/asyncUnParenthesizedArrowFunction_es2017.js create mode 100644 tests/baselines/reference/asyncUnParenthesizedArrowFunction_es2017.symbols create mode 100644 tests/baselines/reference/asyncUnParenthesizedArrowFunction_es2017.types create mode 100644 tests/baselines/reference/asyncUseStrict_es2017.js create mode 100644 tests/baselines/reference/asyncUseStrict_es2017.symbols create mode 100644 tests/baselines/reference/asyncUseStrict_es2017.types create mode 100644 tests/baselines/reference/awaitBinaryExpression1_es2017.js create mode 100644 tests/baselines/reference/awaitBinaryExpression1_es2017.symbols create mode 100644 tests/baselines/reference/awaitBinaryExpression1_es2017.types create mode 100644 tests/baselines/reference/awaitBinaryExpression2_es2017.js create mode 100644 tests/baselines/reference/awaitBinaryExpression2_es2017.symbols create mode 100644 tests/baselines/reference/awaitBinaryExpression2_es2017.types create mode 100644 tests/baselines/reference/awaitBinaryExpression3_es2017.js create mode 100644 tests/baselines/reference/awaitBinaryExpression3_es2017.symbols create mode 100644 tests/baselines/reference/awaitBinaryExpression3_es2017.types create mode 100644 tests/baselines/reference/awaitBinaryExpression4_es2017.js create mode 100644 tests/baselines/reference/awaitBinaryExpression4_es2017.symbols create mode 100644 tests/baselines/reference/awaitBinaryExpression4_es2017.types create mode 100644 tests/baselines/reference/awaitBinaryExpression5_es2017.js create mode 100644 tests/baselines/reference/awaitBinaryExpression5_es2017.symbols create mode 100644 tests/baselines/reference/awaitBinaryExpression5_es2017.types create mode 100644 tests/baselines/reference/awaitCallExpression1_es2017.js create mode 100644 tests/baselines/reference/awaitCallExpression1_es2017.symbols create mode 100644 tests/baselines/reference/awaitCallExpression1_es2017.types create mode 100644 tests/baselines/reference/awaitCallExpression2_es2017.js create mode 100644 tests/baselines/reference/awaitCallExpression2_es2017.symbols create mode 100644 tests/baselines/reference/awaitCallExpression2_es2017.types create mode 100644 tests/baselines/reference/awaitCallExpression3_es2017.js create mode 100644 tests/baselines/reference/awaitCallExpression3_es2017.symbols create mode 100644 tests/baselines/reference/awaitCallExpression3_es2017.types create mode 100644 tests/baselines/reference/awaitCallExpression4_es2017.js create mode 100644 tests/baselines/reference/awaitCallExpression4_es2017.symbols create mode 100644 tests/baselines/reference/awaitCallExpression4_es2017.types create mode 100644 tests/baselines/reference/awaitCallExpression5_es2017.js create mode 100644 tests/baselines/reference/awaitCallExpression5_es2017.symbols create mode 100644 tests/baselines/reference/awaitCallExpression5_es2017.types create mode 100644 tests/baselines/reference/awaitCallExpression6_es2017.js create mode 100644 tests/baselines/reference/awaitCallExpression6_es2017.symbols create mode 100644 tests/baselines/reference/awaitCallExpression6_es2017.types create mode 100644 tests/baselines/reference/awaitCallExpression7_es2017.js create mode 100644 tests/baselines/reference/awaitCallExpression7_es2017.symbols create mode 100644 tests/baselines/reference/awaitCallExpression7_es2017.types create mode 100644 tests/baselines/reference/awaitCallExpression8_es2017.js create mode 100644 tests/baselines/reference/awaitCallExpression8_es2017.symbols create mode 100644 tests/baselines/reference/awaitCallExpression8_es2017.types create mode 100644 tests/baselines/reference/awaitClassExpression_es2017.js create mode 100644 tests/baselines/reference/awaitClassExpression_es2017.symbols create mode 100644 tests/baselines/reference/awaitClassExpression_es2017.types create mode 100644 tests/baselines/reference/awaitUnion_es2017.js create mode 100644 tests/baselines/reference/awaitUnion_es2017.symbols create mode 100644 tests/baselines/reference/awaitUnion_es2017.types create mode 100644 tests/baselines/reference/await_unaryExpression_es2017.js create mode 100644 tests/baselines/reference/await_unaryExpression_es2017.symbols create mode 100644 tests/baselines/reference/await_unaryExpression_es2017.types create mode 100644 tests/baselines/reference/await_unaryExpression_es2017_1.js create mode 100644 tests/baselines/reference/await_unaryExpression_es2017_1.symbols create mode 100644 tests/baselines/reference/await_unaryExpression_es2017_1.types create mode 100644 tests/baselines/reference/await_unaryExpression_es2017_2.js create mode 100644 tests/baselines/reference/await_unaryExpression_es2017_2.symbols create mode 100644 tests/baselines/reference/await_unaryExpression_es2017_2.types create mode 100644 tests/baselines/reference/await_unaryExpression_es2017_3.errors.txt create mode 100644 tests/baselines/reference/await_unaryExpression_es2017_3.js create mode 100644 tests/cases/conformance/async/es2017/asyncAliasReturnType_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncArrowFunction/arrowFunctionWithParameterNameAsync_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction10_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction1_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction2_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction3_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction4_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction6_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction7_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction8_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunctionCapturesArguments_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunctionCapturesThis_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncArrowFunction/asyncUnParenthesizedArrowFunction_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncAwaitIsolatedModules_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncAwait_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncClass_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncConstructor_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncDeclare_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncEnum_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncGetter_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncImportedPromise_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncInterface_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncMethodWithSuper_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncModule_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncMultiFile_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncQualifiedReturnType_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncSetter_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/asyncUseStrict_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression1_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression2_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression3_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression4_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression5_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression1_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression2_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression3_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression4_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression5_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression6_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression7_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression8_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/awaitClassExpression_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/awaitUnion_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/await_unaryExpression_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/await_unaryExpression_es2017_1.ts create mode 100644 tests/cases/conformance/async/es2017/await_unaryExpression_es2017_2.ts create mode 100644 tests/cases/conformance/async/es2017/await_unaryExpression_es2017_3.ts create mode 100644 tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration11_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration12_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration13_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration14_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration1_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration2_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration3_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration4_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration6_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration7_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration8_es2017.ts create mode 100644 tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration9_es2017.ts diff --git a/tests/baselines/reference/arrowFunctionWithParameterNameAsync_es2017.js b/tests/baselines/reference/arrowFunctionWithParameterNameAsync_es2017.js new file mode 100644 index 00000000000..daaff29cad9 --- /dev/null +++ b/tests/baselines/reference/arrowFunctionWithParameterNameAsync_es2017.js @@ -0,0 +1,6 @@ +//// [arrowFunctionWithParameterNameAsync_es2017.ts] + +const x = async => async; + +//// [arrowFunctionWithParameterNameAsync_es2017.js] +var x = function (async) { return async; }; diff --git a/tests/baselines/reference/arrowFunctionWithParameterNameAsync_es2017.symbols b/tests/baselines/reference/arrowFunctionWithParameterNameAsync_es2017.symbols new file mode 100644 index 00000000000..481697c0afd --- /dev/null +++ b/tests/baselines/reference/arrowFunctionWithParameterNameAsync_es2017.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/async/es2017/asyncArrowFunction/arrowFunctionWithParameterNameAsync_es2017.ts === + +const x = async => async; +>x : Symbol(x, Decl(arrowFunctionWithParameterNameAsync_es2017.ts, 1, 5)) +>async : Symbol(async, Decl(arrowFunctionWithParameterNameAsync_es2017.ts, 1, 9)) +>async : Symbol(async, Decl(arrowFunctionWithParameterNameAsync_es2017.ts, 1, 9)) + diff --git a/tests/baselines/reference/arrowFunctionWithParameterNameAsync_es2017.types b/tests/baselines/reference/arrowFunctionWithParameterNameAsync_es2017.types new file mode 100644 index 00000000000..ccb8654284c --- /dev/null +++ b/tests/baselines/reference/arrowFunctionWithParameterNameAsync_es2017.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/async/es2017/asyncArrowFunction/arrowFunctionWithParameterNameAsync_es2017.ts === + +const x = async => async; +>x : (async: any) => any +>async => async : (async: any) => any +>async : any +>async : any + diff --git a/tests/baselines/reference/asyncAliasReturnType_es2017.js b/tests/baselines/reference/asyncAliasReturnType_es2017.js new file mode 100644 index 00000000000..f76f2b13b45 --- /dev/null +++ b/tests/baselines/reference/asyncAliasReturnType_es2017.js @@ -0,0 +1,9 @@ +//// [asyncAliasReturnType_es2017.ts] +type PromiseAlias = Promise; + +async function f(): PromiseAlias { +} + +//// [asyncAliasReturnType_es2017.js] +async function f() { +} diff --git a/tests/baselines/reference/asyncAliasReturnType_es2017.symbols b/tests/baselines/reference/asyncAliasReturnType_es2017.symbols new file mode 100644 index 00000000000..cc4fc5b8096 --- /dev/null +++ b/tests/baselines/reference/asyncAliasReturnType_es2017.symbols @@ -0,0 +1,11 @@ +=== tests/cases/conformance/async/es2017/asyncAliasReturnType_es2017.ts === +type PromiseAlias = Promise; +>PromiseAlias : Symbol(PromiseAlias, Decl(asyncAliasReturnType_es2017.ts, 0, 0)) +>T : Symbol(T, Decl(asyncAliasReturnType_es2017.ts, 0, 18)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>T : Symbol(T, Decl(asyncAliasReturnType_es2017.ts, 0, 18)) + +async function f(): PromiseAlias { +>f : Symbol(f, Decl(asyncAliasReturnType_es2017.ts, 0, 34)) +>PromiseAlias : Symbol(PromiseAlias, Decl(asyncAliasReturnType_es2017.ts, 0, 0)) +} diff --git a/tests/baselines/reference/asyncAliasReturnType_es2017.types b/tests/baselines/reference/asyncAliasReturnType_es2017.types new file mode 100644 index 00000000000..67c521b77fa --- /dev/null +++ b/tests/baselines/reference/asyncAliasReturnType_es2017.types @@ -0,0 +1,11 @@ +=== tests/cases/conformance/async/es2017/asyncAliasReturnType_es2017.ts === +type PromiseAlias = Promise; +>PromiseAlias : Promise +>T : T +>Promise : Promise +>T : T + +async function f(): PromiseAlias { +>f : () => Promise +>PromiseAlias : Promise +} diff --git a/tests/baselines/reference/asyncArrowFunction10_es2017.errors.txt b/tests/baselines/reference/asyncArrowFunction10_es2017.errors.txt new file mode 100644 index 00000000000..923dbed6dad --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction10_es2017.errors.txt @@ -0,0 +1,12 @@ +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction10_es2017.ts(4,11): error TS2304: Cannot find name 'await'. + + +==== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction10_es2017.ts (1 errors) ==== + + var foo = async (): Promise => { + // Legal to use 'await' in a type context. + var v: await; + ~~~~~ +!!! error TS2304: Cannot find name 'await'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction10_es2017.js b/tests/baselines/reference/asyncArrowFunction10_es2017.js new file mode 100644 index 00000000000..3c966201bc2 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction10_es2017.js @@ -0,0 +1,13 @@ +//// [asyncArrowFunction10_es2017.ts] + +var foo = async (): Promise => { + // Legal to use 'await' in a type context. + var v: await; +} + + +//// [asyncArrowFunction10_es2017.js] +var foo = async () => { + // Legal to use 'await' in a type context. + var v; +}; diff --git a/tests/baselines/reference/asyncArrowFunction1_es2017.js b/tests/baselines/reference/asyncArrowFunction1_es2017.js new file mode 100644 index 00000000000..ff6a4624242 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction1_es2017.js @@ -0,0 +1,8 @@ +//// [asyncArrowFunction1_es2017.ts] + +var foo = async (): Promise => { +}; + +//// [asyncArrowFunction1_es2017.js] +var foo = async () => { +}; diff --git a/tests/baselines/reference/asyncArrowFunction1_es2017.symbols b/tests/baselines/reference/asyncArrowFunction1_es2017.symbols new file mode 100644 index 00000000000..35fd033d6b4 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction1_es2017.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction1_es2017.ts === + +var foo = async (): Promise => { +>foo : Symbol(foo, Decl(asyncArrowFunction1_es2017.ts, 1, 3)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + +}; diff --git a/tests/baselines/reference/asyncArrowFunction1_es2017.types b/tests/baselines/reference/asyncArrowFunction1_es2017.types new file mode 100644 index 00000000000..bdc6cacc917 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction1_es2017.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction1_es2017.ts === + +var foo = async (): Promise => { +>foo : () => Promise +>async (): Promise => {} : () => Promise +>Promise : Promise + +}; diff --git a/tests/baselines/reference/asyncArrowFunction2_es2017.js b/tests/baselines/reference/asyncArrowFunction2_es2017.js new file mode 100644 index 00000000000..d2a5d0306b1 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction2_es2017.js @@ -0,0 +1,7 @@ +//// [asyncArrowFunction2_es2017.ts] +var f = (await) => { +} + +//// [asyncArrowFunction2_es2017.js] +var f = (await) => { +}; diff --git a/tests/baselines/reference/asyncArrowFunction2_es2017.symbols b/tests/baselines/reference/asyncArrowFunction2_es2017.symbols new file mode 100644 index 00000000000..a56c5bb62c8 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction2_es2017.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction2_es2017.ts === +var f = (await) => { +>f : Symbol(f, Decl(asyncArrowFunction2_es2017.ts, 0, 3)) +>await : Symbol(await, Decl(asyncArrowFunction2_es2017.ts, 0, 9)) +} diff --git a/tests/baselines/reference/asyncArrowFunction2_es2017.types b/tests/baselines/reference/asyncArrowFunction2_es2017.types new file mode 100644 index 00000000000..1feb033e6ee --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction2_es2017.types @@ -0,0 +1,6 @@ +=== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction2_es2017.ts === +var f = (await) => { +>f : (await: any) => void +>(await) => {} : (await: any) => void +>await : any +} diff --git a/tests/baselines/reference/asyncArrowFunction3_es2017.errors.txt b/tests/baselines/reference/asyncArrowFunction3_es2017.errors.txt new file mode 100644 index 00000000000..1c1fd711760 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction3_es2017.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction3_es2017.ts(1,20): error TS2372: Parameter 'await' cannot be referenced in its initializer. + + +==== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction3_es2017.ts (1 errors) ==== + function f(await = await) { + ~~~~~ +!!! error TS2372: Parameter 'await' cannot be referenced in its initializer. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction3_es2017.js b/tests/baselines/reference/asyncArrowFunction3_es2017.js new file mode 100644 index 00000000000..7ae371facc1 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction3_es2017.js @@ -0,0 +1,7 @@ +//// [asyncArrowFunction3_es2017.ts] +function f(await = await) { +} + +//// [asyncArrowFunction3_es2017.js] +function f(await = await) { +} diff --git a/tests/baselines/reference/asyncArrowFunction4_es2017.js b/tests/baselines/reference/asyncArrowFunction4_es2017.js new file mode 100644 index 00000000000..ebec1e6dbd6 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction4_es2017.js @@ -0,0 +1,7 @@ +//// [asyncArrowFunction4_es2017.ts] +var await = () => { +} + +//// [asyncArrowFunction4_es2017.js] +var await = () => { +}; diff --git a/tests/baselines/reference/asyncArrowFunction4_es2017.symbols b/tests/baselines/reference/asyncArrowFunction4_es2017.symbols new file mode 100644 index 00000000000..b44fc0dbdf6 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction4_es2017.symbols @@ -0,0 +1,4 @@ +=== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction4_es2017.ts === +var await = () => { +>await : Symbol(await, Decl(asyncArrowFunction4_es2017.ts, 0, 3)) +} diff --git a/tests/baselines/reference/asyncArrowFunction4_es2017.types b/tests/baselines/reference/asyncArrowFunction4_es2017.types new file mode 100644 index 00000000000..6af5f94c758 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction4_es2017.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction4_es2017.ts === +var await = () => { +>await : () => void +>() => {} : () => void +} diff --git a/tests/baselines/reference/asyncArrowFunction5_es2017.errors.txt b/tests/baselines/reference/asyncArrowFunction5_es2017.errors.txt new file mode 100644 index 00000000000..3df56177107 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction5_es2017.errors.txt @@ -0,0 +1,24 @@ +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts(2,11): error TS2304: Cannot find name 'async'. +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts(2,18): error TS2304: Cannot find name 'await'. +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts(2,24): error TS1005: ',' expected. +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts(2,26): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' must be of type 'PromiseConstructor', but here has type 'void'. +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts(2,33): error TS1005: '=' expected. +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts(2,40): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts (6 errors) ==== + + var foo = async (await): Promise => { + ~~~~~ +!!! error TS2304: Cannot find name 'async'. + ~~~~~ +!!! error TS2304: Cannot find name 'await'. + ~ +!!! error TS1005: ',' expected. + ~~~~~~~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' must be of type 'PromiseConstructor', but here has type 'void'. + ~ +!!! error TS1005: '=' expected. + ~~ +!!! error TS1109: Expression expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction5_es2017.js b/tests/baselines/reference/asyncArrowFunction5_es2017.js new file mode 100644 index 00000000000..0c61a141f17 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction5_es2017.js @@ -0,0 +1,9 @@ +//// [asyncArrowFunction5_es2017.ts] + +var foo = async (await): Promise => { +} + +//// [asyncArrowFunction5_es2017.js] +var foo = async(await), Promise = ; +{ +} diff --git a/tests/baselines/reference/asyncArrowFunction6_es2017.errors.txt b/tests/baselines/reference/asyncArrowFunction6_es2017.errors.txt new file mode 100644 index 00000000000..202ecb1727f --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction6_es2017.errors.txt @@ -0,0 +1,12 @@ +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction6_es2017.ts(2,22): error TS2524: 'await' expressions cannot be used in a parameter initializer. +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction6_es2017.ts(2,27): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction6_es2017.ts (2 errors) ==== + + var foo = async (a = await): Promise => { + ~~~~~ +!!! error TS2524: 'await' expressions cannot be used in a parameter initializer. + ~ +!!! error TS1109: Expression expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction6_es2017.js b/tests/baselines/reference/asyncArrowFunction6_es2017.js new file mode 100644 index 00000000000..c36f75a180a --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction6_es2017.js @@ -0,0 +1,8 @@ +//// [asyncArrowFunction6_es2017.ts] + +var foo = async (a = await): Promise => { +} + +//// [asyncArrowFunction6_es2017.js] +var foo = async (a = await ) => { +}; diff --git a/tests/baselines/reference/asyncArrowFunction7_es2017.errors.txt b/tests/baselines/reference/asyncArrowFunction7_es2017.errors.txt new file mode 100644 index 00000000000..33e03624283 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction7_es2017.errors.txt @@ -0,0 +1,15 @@ +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction7_es2017.ts(4,24): error TS2524: 'await' expressions cannot be used in a parameter initializer. +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction7_es2017.ts(4,29): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction7_es2017.ts (2 errors) ==== + + var bar = async (): Promise => { + // 'await' here is an identifier, and not an await expression. + var foo = async (a = await): Promise => { + ~~~~~ +!!! error TS2524: 'await' expressions cannot be used in a parameter initializer. + ~ +!!! error TS1109: Expression expected. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction7_es2017.js b/tests/baselines/reference/asyncArrowFunction7_es2017.js new file mode 100644 index 00000000000..11d8c879eb8 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction7_es2017.js @@ -0,0 +1,14 @@ +//// [asyncArrowFunction7_es2017.ts] + +var bar = async (): Promise => { + // 'await' here is an identifier, and not an await expression. + var foo = async (a = await): Promise => { + } +} + +//// [asyncArrowFunction7_es2017.js] +var bar = async () => { + // 'await' here is an identifier, and not an await expression. + var foo = async (a = await ) => { + }; +}; diff --git a/tests/baselines/reference/asyncArrowFunction8_es2017.errors.txt b/tests/baselines/reference/asyncArrowFunction8_es2017.errors.txt new file mode 100644 index 00000000000..75e460490bd --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction8_es2017.errors.txt @@ -0,0 +1,10 @@ +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction8_es2017.ts(3,19): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction8_es2017.ts (1 errors) ==== + + var foo = async (): Promise => { + var v = { [await]: foo } + ~ +!!! error TS1109: Expression expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction8_es2017.js b/tests/baselines/reference/asyncArrowFunction8_es2017.js new file mode 100644 index 00000000000..1358f186ce2 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction8_es2017.js @@ -0,0 +1,10 @@ +//// [asyncArrowFunction8_es2017.ts] + +var foo = async (): Promise => { + var v = { [await]: foo } +} + +//// [asyncArrowFunction8_es2017.js] +var foo = async () => { + var v = { [await ]: foo }; +}; diff --git a/tests/baselines/reference/asyncArrowFunction9_es2017.errors.txt b/tests/baselines/reference/asyncArrowFunction9_es2017.errors.txt new file mode 100644 index 00000000000..ee94f3f9caf --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction9_es2017.errors.txt @@ -0,0 +1,23 @@ +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts(1,11): error TS2304: Cannot find name 'async'. +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts(1,18): error TS2304: Cannot find name 'a'. +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts(1,37): error TS1005: ',' expected. +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts(1,39): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' must be of type 'PromiseConstructor', but here has type 'void'. +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts(1,46): error TS1005: '=' expected. +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts(1,53): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts (6 errors) ==== + var foo = async (a = await => await): Promise => { + ~~~~~ +!!! error TS2304: Cannot find name 'async'. + ~ +!!! error TS2304: Cannot find name 'a'. + ~ +!!! error TS1005: ',' expected. + ~~~~~~~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' must be of type 'PromiseConstructor', but here has type 'void'. + ~ +!!! error TS1005: '=' expected. + ~~ +!!! error TS1109: Expression expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction9_es2017.js b/tests/baselines/reference/asyncArrowFunction9_es2017.js new file mode 100644 index 00000000000..c1fec991ec1 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction9_es2017.js @@ -0,0 +1,8 @@ +//// [asyncArrowFunction9_es2017.ts] +var foo = async (a = await => await): Promise => { +} + +//// [asyncArrowFunction9_es2017.js] +var foo = async(a = await => await), Promise = ; +{ +} diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es2017.js b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es2017.js new file mode 100644 index 00000000000..f7f813ad502 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es2017.js @@ -0,0 +1,16 @@ +//// [asyncArrowFunctionCapturesArguments_es2017.ts] +class C { + method() { + function other() {} + var fn = async () => await other.apply(this, arguments); + } +} + + +//// [asyncArrowFunctionCapturesArguments_es2017.js] +class C { + method() { + function other() { } + var fn = async () => await other.apply(this, arguments); + } +} diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es2017.symbols b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es2017.symbols new file mode 100644 index 00000000000..ccd9b48e400 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es2017.symbols @@ -0,0 +1,20 @@ +=== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunctionCapturesArguments_es2017.ts === +class C { +>C : Symbol(C, Decl(asyncArrowFunctionCapturesArguments_es2017.ts, 0, 0)) + + method() { +>method : Symbol(C.method, Decl(asyncArrowFunctionCapturesArguments_es2017.ts, 0, 9)) + + function other() {} +>other : Symbol(other, Decl(asyncArrowFunctionCapturesArguments_es2017.ts, 1, 13)) + + var fn = async () => await other.apply(this, arguments); +>fn : Symbol(fn, Decl(asyncArrowFunctionCapturesArguments_es2017.ts, 3, 9)) +>other.apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --)) +>other : Symbol(other, Decl(asyncArrowFunctionCapturesArguments_es2017.ts, 1, 13)) +>apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --)) +>this : Symbol(C, Decl(asyncArrowFunctionCapturesArguments_es2017.ts, 0, 0)) +>arguments : Symbol(arguments) + } +} + diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es2017.types b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es2017.types new file mode 100644 index 00000000000..a7a80424e19 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es2017.types @@ -0,0 +1,23 @@ +=== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunctionCapturesArguments_es2017.ts === +class C { +>C : C + + method() { +>method : () => void + + function other() {} +>other : () => void + + var fn = async () => await other.apply(this, arguments); +>fn : () => Promise +>async () => await other.apply(this, arguments) : () => Promise +>await other.apply(this, arguments) : any +>other.apply(this, arguments) : any +>other.apply : (this: Function, thisArg: any, argArray?: any) => any +>other : () => void +>apply : (this: Function, thisArg: any, argArray?: any) => any +>this : this +>arguments : IArguments + } +} + diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesThis_es2017.js b/tests/baselines/reference/asyncArrowFunctionCapturesThis_es2017.js new file mode 100644 index 00000000000..13560557ffe --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunctionCapturesThis_es2017.js @@ -0,0 +1,14 @@ +//// [asyncArrowFunctionCapturesThis_es2017.ts] +class C { + method() { + var fn = async () => await this; + } +} + + +//// [asyncArrowFunctionCapturesThis_es2017.js] +class C { + method() { + var fn = async () => await this; + } +} diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesThis_es2017.symbols b/tests/baselines/reference/asyncArrowFunctionCapturesThis_es2017.symbols new file mode 100644 index 00000000000..bc14bafa0c5 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunctionCapturesThis_es2017.symbols @@ -0,0 +1,13 @@ +=== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunctionCapturesThis_es2017.ts === +class C { +>C : Symbol(C, Decl(asyncArrowFunctionCapturesThis_es2017.ts, 0, 0)) + + method() { +>method : Symbol(C.method, Decl(asyncArrowFunctionCapturesThis_es2017.ts, 0, 9)) + + var fn = async () => await this; +>fn : Symbol(fn, Decl(asyncArrowFunctionCapturesThis_es2017.ts, 2, 9)) +>this : Symbol(C, Decl(asyncArrowFunctionCapturesThis_es2017.ts, 0, 0)) + } +} + diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesThis_es2017.types b/tests/baselines/reference/asyncArrowFunctionCapturesThis_es2017.types new file mode 100644 index 00000000000..57f59302bb5 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunctionCapturesThis_es2017.types @@ -0,0 +1,15 @@ +=== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunctionCapturesThis_es2017.ts === +class C { +>C : C + + method() { +>method : () => void + + var fn = async () => await this; +>fn : () => Promise +>async () => await this : () => Promise +>await this : this +>this : this + } +} + diff --git a/tests/baselines/reference/asyncAwaitIsolatedModules_es2017.errors.txt b/tests/baselines/reference/asyncAwaitIsolatedModules_es2017.errors.txt new file mode 100644 index 00000000000..95927c283aa --- /dev/null +++ b/tests/baselines/reference/asyncAwaitIsolatedModules_es2017.errors.txt @@ -0,0 +1,45 @@ +tests/cases/conformance/async/es2017/asyncAwaitIsolatedModules_es2017.ts(1,27): error TS2307: Cannot find module 'missing'. + + +==== tests/cases/conformance/async/es2017/asyncAwaitIsolatedModules_es2017.ts (1 errors) ==== + import { MyPromise } from "missing"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'missing'. + + declare var p: Promise; + declare var mp: MyPromise; + + async function f0() { } + async function f1(): Promise { } + async function f3(): MyPromise { } + + let f4 = async function() { } + let f5 = async function(): Promise { } + let f6 = async function(): MyPromise { } + + let f7 = async () => { }; + let f8 = async (): Promise => { }; + let f9 = async (): MyPromise => { }; + let f10 = async () => p; + let f11 = async () => mp; + let f12 = async (): Promise => mp; + let f13 = async (): MyPromise => p; + + let o = { + async m1() { }, + async m2(): Promise { }, + async m3(): MyPromise { } + }; + + class C { + async m1() { } + async m2(): Promise { } + async m3(): MyPromise { } + static async m4() { } + static async m5(): Promise { } + static async m6(): MyPromise { } + } + + module M { + export async function f1() { } + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncAwaitIsolatedModules_es2017.js b/tests/baselines/reference/asyncAwaitIsolatedModules_es2017.js new file mode 100644 index 00000000000..065aa675b6e --- /dev/null +++ b/tests/baselines/reference/asyncAwaitIsolatedModules_es2017.js @@ -0,0 +1,73 @@ +//// [asyncAwaitIsolatedModules_es2017.ts] +import { MyPromise } from "missing"; + +declare var p: Promise; +declare var mp: MyPromise; + +async function f0() { } +async function f1(): Promise { } +async function f3(): MyPromise { } + +let f4 = async function() { } +let f5 = async function(): Promise { } +let f6 = async function(): MyPromise { } + +let f7 = async () => { }; +let f8 = async (): Promise => { }; +let f9 = async (): MyPromise => { }; +let f10 = async () => p; +let f11 = async () => mp; +let f12 = async (): Promise => mp; +let f13 = async (): MyPromise => p; + +let o = { + async m1() { }, + async m2(): Promise { }, + async m3(): MyPromise { } +}; + +class C { + async m1() { } + async m2(): Promise { } + async m3(): MyPromise { } + static async m4() { } + static async m5(): Promise { } + static async m6(): MyPromise { } +} + +module M { + export async function f1() { } +} + +//// [asyncAwaitIsolatedModules_es2017.js] +async function f0() { } +async function f1() { } +async function f3() { } +let f4 = async function () { }; +let f5 = async function () { }; +let f6 = async function () { }; +let f7 = async () => { }; +let f8 = async () => { }; +let f9 = async () => { }; +let f10 = async () => p; +let f11 = async () => mp; +let f12 = async () => mp; +let f13 = async () => p; +let o = { + async m1() { }, + async m2() { }, + async m3() { } +}; +class C { + async m1() { } + async m2() { } + async m3() { } + static async m4() { } + static async m5() { } + static async m6() { } +} +var M; +(function (M) { + async function f1() { } + M.f1 = f1; +})(M || (M = {})); diff --git a/tests/baselines/reference/asyncAwait_es2017.js b/tests/baselines/reference/asyncAwait_es2017.js new file mode 100644 index 00000000000..314c99fa210 --- /dev/null +++ b/tests/baselines/reference/asyncAwait_es2017.js @@ -0,0 +1,73 @@ +//// [asyncAwait_es2017.ts] +type MyPromise = Promise; +declare var MyPromise: typeof Promise; +declare var p: Promise; +declare var mp: MyPromise; + +async function f0() { } +async function f1(): Promise { } +async function f3(): MyPromise { } + +let f4 = async function() { } +let f5 = async function(): Promise { } +let f6 = async function(): MyPromise { } + +let f7 = async () => { }; +let f8 = async (): Promise => { }; +let f9 = async (): MyPromise => { }; +let f10 = async () => p; +let f11 = async () => mp; +let f12 = async (): Promise => mp; +let f13 = async (): MyPromise => p; + +let o = { + async m1() { }, + async m2(): Promise { }, + async m3(): MyPromise { } +}; + +class C { + async m1() { } + async m2(): Promise { } + async m3(): MyPromise { } + static async m4() { } + static async m5(): Promise { } + static async m6(): MyPromise { } +} + +module M { + export async function f1() { } +} + +//// [asyncAwait_es2017.js] +async function f0() { } +async function f1() { } +async function f3() { } +let f4 = async function () { }; +let f5 = async function () { }; +let f6 = async function () { }; +let f7 = async () => { }; +let f8 = async () => { }; +let f9 = async () => { }; +let f10 = async () => p; +let f11 = async () => mp; +let f12 = async () => mp; +let f13 = async () => p; +let o = { + async m1() { }, + async m2() { }, + async m3() { } +}; +class C { + async m1() { } + async m2() { } + async m3() { } + static async m4() { } + static async m5() { } + static async m6() { } +} +var M; +(function (M) { + async function f1() { } + M.f1 = f1; +})(M || (M = {})); diff --git a/tests/baselines/reference/asyncAwait_es2017.symbols b/tests/baselines/reference/asyncAwait_es2017.symbols new file mode 100644 index 00000000000..34dc9802a25 --- /dev/null +++ b/tests/baselines/reference/asyncAwait_es2017.symbols @@ -0,0 +1,118 @@ +=== tests/cases/conformance/async/es2017/asyncAwait_es2017.ts === +type MyPromise = Promise; +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es2017.ts, 0, 0), Decl(asyncAwait_es2017.ts, 1, 11)) +>T : Symbol(T, Decl(asyncAwait_es2017.ts, 0, 15)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>T : Symbol(T, Decl(asyncAwait_es2017.ts, 0, 15)) + +declare var MyPromise: typeof Promise; +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es2017.ts, 0, 0), Decl(asyncAwait_es2017.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + +declare var p: Promise; +>p : Symbol(p, Decl(asyncAwait_es2017.ts, 2, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + +declare var mp: MyPromise; +>mp : Symbol(mp, Decl(asyncAwait_es2017.ts, 3, 11)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es2017.ts, 0, 0), Decl(asyncAwait_es2017.ts, 1, 11)) + +async function f0() { } +>f0 : Symbol(f0, Decl(asyncAwait_es2017.ts, 3, 34)) + +async function f1(): Promise { } +>f1 : Symbol(f1, Decl(asyncAwait_es2017.ts, 5, 23)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + +async function f3(): MyPromise { } +>f3 : Symbol(f3, Decl(asyncAwait_es2017.ts, 6, 38)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es2017.ts, 0, 0), Decl(asyncAwait_es2017.ts, 1, 11)) + +let f4 = async function() { } +>f4 : Symbol(f4, Decl(asyncAwait_es2017.ts, 9, 3)) + +let f5 = async function(): Promise { } +>f5 : Symbol(f5, Decl(asyncAwait_es2017.ts, 10, 3)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + +let f6 = async function(): MyPromise { } +>f6 : Symbol(f6, Decl(asyncAwait_es2017.ts, 11, 3)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es2017.ts, 0, 0), Decl(asyncAwait_es2017.ts, 1, 11)) + +let f7 = async () => { }; +>f7 : Symbol(f7, Decl(asyncAwait_es2017.ts, 13, 3)) + +let f8 = async (): Promise => { }; +>f8 : Symbol(f8, Decl(asyncAwait_es2017.ts, 14, 3)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + +let f9 = async (): MyPromise => { }; +>f9 : Symbol(f9, Decl(asyncAwait_es2017.ts, 15, 3)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es2017.ts, 0, 0), Decl(asyncAwait_es2017.ts, 1, 11)) + +let f10 = async () => p; +>f10 : Symbol(f10, Decl(asyncAwait_es2017.ts, 16, 3)) +>p : Symbol(p, Decl(asyncAwait_es2017.ts, 2, 11)) + +let f11 = async () => mp; +>f11 : Symbol(f11, Decl(asyncAwait_es2017.ts, 17, 3)) +>mp : Symbol(mp, Decl(asyncAwait_es2017.ts, 3, 11)) + +let f12 = async (): Promise => mp; +>f12 : Symbol(f12, Decl(asyncAwait_es2017.ts, 18, 3)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>mp : Symbol(mp, Decl(asyncAwait_es2017.ts, 3, 11)) + +let f13 = async (): MyPromise => p; +>f13 : Symbol(f13, Decl(asyncAwait_es2017.ts, 19, 3)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es2017.ts, 0, 0), Decl(asyncAwait_es2017.ts, 1, 11)) +>p : Symbol(p, Decl(asyncAwait_es2017.ts, 2, 11)) + +let o = { +>o : Symbol(o, Decl(asyncAwait_es2017.ts, 21, 3)) + + async m1() { }, +>m1 : Symbol(m1, Decl(asyncAwait_es2017.ts, 21, 9)) + + async m2(): Promise { }, +>m2 : Symbol(m2, Decl(asyncAwait_es2017.ts, 22, 16)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + async m3(): MyPromise { } +>m3 : Symbol(m3, Decl(asyncAwait_es2017.ts, 23, 31)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es2017.ts, 0, 0), Decl(asyncAwait_es2017.ts, 1, 11)) + +}; + +class C { +>C : Symbol(C, Decl(asyncAwait_es2017.ts, 25, 2)) + + async m1() { } +>m1 : Symbol(C.m1, Decl(asyncAwait_es2017.ts, 27, 9)) + + async m2(): Promise { } +>m2 : Symbol(C.m2, Decl(asyncAwait_es2017.ts, 28, 15)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + async m3(): MyPromise { } +>m3 : Symbol(C.m3, Decl(asyncAwait_es2017.ts, 29, 30)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es2017.ts, 0, 0), Decl(asyncAwait_es2017.ts, 1, 11)) + + static async m4() { } +>m4 : Symbol(C.m4, Decl(asyncAwait_es2017.ts, 30, 32)) + + static async m5(): Promise { } +>m5 : Symbol(C.m5, Decl(asyncAwait_es2017.ts, 31, 22)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + static async m6(): MyPromise { } +>m6 : Symbol(C.m6, Decl(asyncAwait_es2017.ts, 32, 37)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es2017.ts, 0, 0), Decl(asyncAwait_es2017.ts, 1, 11)) +} + +module M { +>M : Symbol(M, Decl(asyncAwait_es2017.ts, 34, 1)) + + export async function f1() { } +>f1 : Symbol(f1, Decl(asyncAwait_es2017.ts, 36, 10)) +} diff --git a/tests/baselines/reference/asyncAwait_es2017.types b/tests/baselines/reference/asyncAwait_es2017.types new file mode 100644 index 00000000000..a1226d0cbfe --- /dev/null +++ b/tests/baselines/reference/asyncAwait_es2017.types @@ -0,0 +1,129 @@ +=== tests/cases/conformance/async/es2017/asyncAwait_es2017.ts === +type MyPromise = Promise; +>MyPromise : Promise +>T : T +>Promise : Promise +>T : T + +declare var MyPromise: typeof Promise; +>MyPromise : PromiseConstructor +>Promise : PromiseConstructor + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare var mp: MyPromise; +>mp : Promise +>MyPromise : Promise + +async function f0() { } +>f0 : () => Promise + +async function f1(): Promise { } +>f1 : () => Promise +>Promise : Promise + +async function f3(): MyPromise { } +>f3 : () => Promise +>MyPromise : Promise + +let f4 = async function() { } +>f4 : () => Promise +>async function() { } : () => Promise + +let f5 = async function(): Promise { } +>f5 : () => Promise +>async function(): Promise { } : () => Promise +>Promise : Promise + +let f6 = async function(): MyPromise { } +>f6 : () => Promise +>async function(): MyPromise { } : () => Promise +>MyPromise : Promise + +let f7 = async () => { }; +>f7 : () => Promise +>async () => { } : () => Promise + +let f8 = async (): Promise => { }; +>f8 : () => Promise +>async (): Promise => { } : () => Promise +>Promise : Promise + +let f9 = async (): MyPromise => { }; +>f9 : () => Promise +>async (): MyPromise => { } : () => Promise +>MyPromise : Promise + +let f10 = async () => p; +>f10 : () => Promise +>async () => p : () => Promise +>p : Promise + +let f11 = async () => mp; +>f11 : () => Promise +>async () => mp : () => Promise +>mp : Promise + +let f12 = async (): Promise => mp; +>f12 : () => Promise +>async (): Promise => mp : () => Promise +>Promise : Promise +>mp : Promise + +let f13 = async (): MyPromise => p; +>f13 : () => Promise +>async (): MyPromise => p : () => Promise +>MyPromise : Promise +>p : Promise + +let o = { +>o : { m1(): Promise; m2(): Promise; m3(): Promise; } +>{ async m1() { }, async m2(): Promise { }, async m3(): MyPromise { }} : { m1(): Promise; m2(): Promise; m3(): Promise; } + + async m1() { }, +>m1 : () => Promise + + async m2(): Promise { }, +>m2 : () => Promise +>Promise : Promise + + async m3(): MyPromise { } +>m3 : () => Promise +>MyPromise : Promise + +}; + +class C { +>C : C + + async m1() { } +>m1 : () => Promise + + async m2(): Promise { } +>m2 : () => Promise +>Promise : Promise + + async m3(): MyPromise { } +>m3 : () => Promise +>MyPromise : Promise + + static async m4() { } +>m4 : () => Promise + + static async m5(): Promise { } +>m5 : () => Promise +>Promise : Promise + + static async m6(): MyPromise { } +>m6 : () => Promise +>MyPromise : Promise +} + +module M { +>M : typeof M + + export async function f1() { } +>f1 : () => Promise +} diff --git a/tests/baselines/reference/asyncClass_es2017.errors.txt b/tests/baselines/reference/asyncClass_es2017.errors.txt new file mode 100644 index 00000000000..37612b0b0f2 --- /dev/null +++ b/tests/baselines/reference/asyncClass_es2017.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/async/es2017/asyncClass_es2017.ts(1,1): error TS1042: 'async' modifier cannot be used here. + + +==== tests/cases/conformance/async/es2017/asyncClass_es2017.ts (1 errors) ==== + async class C { + ~~~~~ +!!! error TS1042: 'async' modifier cannot be used here. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncClass_es2017.js b/tests/baselines/reference/asyncClass_es2017.js new file mode 100644 index 00000000000..e619bd50b97 --- /dev/null +++ b/tests/baselines/reference/asyncClass_es2017.js @@ -0,0 +1,7 @@ +//// [asyncClass_es2017.ts] +async class C { +} + +//// [asyncClass_es2017.js] +async class C { +} diff --git a/tests/baselines/reference/asyncConstructor_es2017.errors.txt b/tests/baselines/reference/asyncConstructor_es2017.errors.txt new file mode 100644 index 00000000000..3b0c1b42fa9 --- /dev/null +++ b/tests/baselines/reference/asyncConstructor_es2017.errors.txt @@ -0,0 +1,10 @@ +tests/cases/conformance/async/es2017/asyncConstructor_es2017.ts(2,3): error TS1089: 'async' modifier cannot appear on a constructor declaration. + + +==== tests/cases/conformance/async/es2017/asyncConstructor_es2017.ts (1 errors) ==== + class C { + async constructor() { + ~~~~~ +!!! error TS1089: 'async' modifier cannot appear on a constructor declaration. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncConstructor_es2017.js b/tests/baselines/reference/asyncConstructor_es2017.js new file mode 100644 index 00000000000..7dcd6ec6943 --- /dev/null +++ b/tests/baselines/reference/asyncConstructor_es2017.js @@ -0,0 +1,11 @@ +//// [asyncConstructor_es2017.ts] +class C { + async constructor() { + } +} + +//// [asyncConstructor_es2017.js] +class C { + async constructor() { + } +} diff --git a/tests/baselines/reference/asyncDeclare_es2017.errors.txt b/tests/baselines/reference/asyncDeclare_es2017.errors.txt new file mode 100644 index 00000000000..bb74a3865d5 --- /dev/null +++ b/tests/baselines/reference/asyncDeclare_es2017.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/async/es2017/asyncDeclare_es2017.ts(1,9): error TS1040: 'async' modifier cannot be used in an ambient context. + + +==== tests/cases/conformance/async/es2017/asyncDeclare_es2017.ts (1 errors) ==== + declare async function foo(): Promise; + ~~~~~ +!!! error TS1040: 'async' modifier cannot be used in an ambient context. \ No newline at end of file diff --git a/tests/baselines/reference/asyncDeclare_es2017.js b/tests/baselines/reference/asyncDeclare_es2017.js new file mode 100644 index 00000000000..2ff588b2851 --- /dev/null +++ b/tests/baselines/reference/asyncDeclare_es2017.js @@ -0,0 +1,4 @@ +//// [asyncDeclare_es2017.ts] +declare async function foo(): Promise; + +//// [asyncDeclare_es2017.js] diff --git a/tests/baselines/reference/asyncEnum_es2017.errors.txt b/tests/baselines/reference/asyncEnum_es2017.errors.txt new file mode 100644 index 00000000000..8e0015d0b24 --- /dev/null +++ b/tests/baselines/reference/asyncEnum_es2017.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/async/es2017/asyncEnum_es2017.ts(1,1): error TS1042: 'async' modifier cannot be used here. + + +==== tests/cases/conformance/async/es2017/asyncEnum_es2017.ts (1 errors) ==== + async enum E { + ~~~~~ +!!! error TS1042: 'async' modifier cannot be used here. + Value + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncEnum_es2017.js b/tests/baselines/reference/asyncEnum_es2017.js new file mode 100644 index 00000000000..df1f846c2f9 --- /dev/null +++ b/tests/baselines/reference/asyncEnum_es2017.js @@ -0,0 +1,10 @@ +//// [asyncEnum_es2017.ts] +async enum E { + Value +} + +//// [asyncEnum_es2017.js] +var E; +(function (E) { + E[E["Value"] = 0] = "Value"; +})(E || (E = {})); diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es2017.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration10_es2017.errors.txt new file mode 100644 index 00000000000..d5da3432264 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es2017.errors.txt @@ -0,0 +1,26 @@ +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts(1,20): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts(1,30): error TS1109: Expression expected. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts(1,33): error TS1138: Parameter declaration expected. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts(1,33): error TS2304: Cannot find name 'await'. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts(1,38): error TS1005: ';' expected. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts(1,39): error TS1128: Declaration or statement expected. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts(1,53): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts (7 errors) ==== + async function foo(a = await => await): Promise { + ~~~~~~~~~ +!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. + ~~ +!!! error TS1109: Expression expected. + ~~~~~ +!!! error TS1138: Parameter declaration expected. + ~~~~~ +!!! error TS2304: Cannot find name 'await'. + ~ +!!! error TS1005: ';' expected. + ~ +!!! error TS1128: Declaration or statement expected. + ~ +!!! error TS1109: Expression expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration10_es2017.js new file mode 100644 index 00000000000..0e687c1e0d5 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es2017.js @@ -0,0 +1,7 @@ +//// [asyncFunctionDeclaration10_es2017.ts] +async function foo(a = await => await): Promise { +} + +//// [asyncFunctionDeclaration10_es2017.js] +await; +Promise < void > {}; diff --git a/tests/baselines/reference/asyncFunctionDeclaration11_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration11_es2017.js new file mode 100644 index 00000000000..0ae906ebfe1 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration11_es2017.js @@ -0,0 +1,7 @@ +//// [asyncFunctionDeclaration11_es2017.ts] +async function await(): Promise { +} + +//// [asyncFunctionDeclaration11_es2017.js] +async function await() { +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration11_es2017.symbols b/tests/baselines/reference/asyncFunctionDeclaration11_es2017.symbols new file mode 100644 index 00000000000..02c35d81d62 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration11_es2017.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration11_es2017.ts === +async function await(): Promise { +>await : Symbol(await, Decl(asyncFunctionDeclaration11_es2017.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration11_es2017.types b/tests/baselines/reference/asyncFunctionDeclaration11_es2017.types new file mode 100644 index 00000000000..b86601bf33d --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration11_es2017.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration11_es2017.ts === +async function await(): Promise { +>await : () => Promise +>Promise : Promise +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es2017.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration12_es2017.errors.txt new file mode 100644 index 00000000000..f951bee715c --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es2017.errors.txt @@ -0,0 +1,16 @@ +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration12_es2017.ts(1,24): error TS1005: '(' expected. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration12_es2017.ts(1,29): error TS1005: '=' expected. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration12_es2017.ts(1,33): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration12_es2017.ts(1,47): error TS1005: '=>' expected. + + +==== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration12_es2017.ts (4 errors) ==== + var v = async function await(): Promise { } + ~~~~~ +!!! error TS1005: '(' expected. + ~ +!!! error TS1005: '=' expected. + ~~~~~~~~~~~~~ +!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. + ~ +!!! error TS1005: '=>' expected. \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration12_es2017.js new file mode 100644 index 00000000000..69f5993f5c0 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es2017.js @@ -0,0 +1,5 @@ +//// [asyncFunctionDeclaration12_es2017.ts] +var v = async function await(): Promise { } + +//// [asyncFunctionDeclaration12_es2017.js] +var v = , await = () => { }; diff --git a/tests/baselines/reference/asyncFunctionDeclaration13_es2017.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration13_es2017.errors.txt new file mode 100644 index 00000000000..41ea0a7cafb --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration13_es2017.errors.txt @@ -0,0 +1,11 @@ +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration13_es2017.ts(3,11): error TS2304: Cannot find name 'await'. + + +==== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration13_es2017.ts (1 errors) ==== + async function foo(): Promise { + // Legal to use 'await' in a type context. + var v: await; + ~~~~~ +!!! error TS2304: Cannot find name 'await'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration13_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration13_es2017.js new file mode 100644 index 00000000000..a16236aea7f --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration13_es2017.js @@ -0,0 +1,12 @@ +//// [asyncFunctionDeclaration13_es2017.ts] +async function foo(): Promise { + // Legal to use 'await' in a type context. + var v: await; +} + + +//// [asyncFunctionDeclaration13_es2017.js] +async function foo() { + // Legal to use 'await' in a type context. + var v; +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration14_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration14_es2017.js new file mode 100644 index 00000000000..308b8f1763c --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration14_es2017.js @@ -0,0 +1,9 @@ +//// [asyncFunctionDeclaration14_es2017.ts] +async function foo(): Promise { + return; +} + +//// [asyncFunctionDeclaration14_es2017.js] +async function foo() { + return; +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration14_es2017.symbols b/tests/baselines/reference/asyncFunctionDeclaration14_es2017.symbols new file mode 100644 index 00000000000..1b5bca844c0 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration14_es2017.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration14_es2017.ts === +async function foo(): Promise { +>foo : Symbol(foo, Decl(asyncFunctionDeclaration14_es2017.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + return; +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration14_es2017.types b/tests/baselines/reference/asyncFunctionDeclaration14_es2017.types new file mode 100644 index 00000000000..1e505f93a2c --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration14_es2017.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration14_es2017.ts === +async function foo(): Promise { +>foo : () => Promise +>Promise : Promise + + return; +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration15_es2017.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration15_es2017.errors.txt new file mode 100644 index 00000000000..efc1e2440bf --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration15_es2017.errors.txt @@ -0,0 +1,48 @@ +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts(6,23): error TS1064: The return type of an async function or method must be the global Promise type. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts(7,23): error TS1064: The return type of an async function or method must be the global Promise type. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts(8,23): error TS1064: The return type of an async function or method must be the global Promise type. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts(9,23): error TS1064: The return type of an async function or method must be the global Promise type. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts(10,23): error TS1064: The return type of an async function or method must be the global Promise type. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts(17,16): error TS1059: Return expression in async function does not have a valid callable 'then' member. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts(23,25): error TS1058: Operand for 'await' does not have a valid callable 'then' member. + + +==== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts (7 errors) ==== + declare class Thenable { then(): void; } + declare let a: any; + declare let obj: { then: string; }; + declare let thenable: Thenable; + async function fn1() { } // valid: Promise + async function fn2(): { } { } // error + ~~~ +!!! error TS1064: The return type of an async function or method must be the global Promise type. + async function fn3(): any { } // error + ~~~ +!!! error TS1064: The return type of an async function or method must be the global Promise type. + async function fn4(): number { } // error + ~~~~~~ +!!! error TS1064: The return type of an async function or method must be the global Promise type. + async function fn5(): PromiseLike { } // error + ~~~~~~~~~~~~~~~~~ +!!! error TS1064: The return type of an async function or method must be the global Promise type. + async function fn6(): Thenable { } // error + ~~~~~~~~ +!!! error TS1064: The return type of an async function or method must be the global Promise type. + async function fn7() { return; } // valid: Promise + async function fn8() { return 1; } // valid: Promise + async function fn9() { return null; } // valid: Promise + async function fn10() { return undefined; } // valid: Promise + async function fn11() { return a; } // valid: Promise + async function fn12() { return obj; } // valid: Promise<{ then: string; }> + async function fn13() { return thenable; } // error + ~~~~ +!!! error TS1059: Return expression in async function does not have a valid callable 'then' member. + async function fn14() { await 1; } // valid: Promise + async function fn15() { await null; } // valid: Promise + async function fn16() { await undefined; } // valid: Promise + async function fn17() { await a; } // valid: Promise + async function fn18() { await obj; } // valid: Promise + async function fn19() { await thenable; } // error + ~~~~~~~~~~~~~~ +!!! error TS1058: Operand for 'await' does not have a valid callable 'then' member. + \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration15_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration15_es2017.js new file mode 100644 index 00000000000..5704366025e --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration15_es2017.js @@ -0,0 +1,64 @@ +//// [asyncFunctionDeclaration15_es2017.ts] +declare class Thenable { then(): void; } +declare let a: any; +declare let obj: { then: string; }; +declare let thenable: Thenable; +async function fn1() { } // valid: Promise +async function fn2(): { } { } // error +async function fn3(): any { } // error +async function fn4(): number { } // error +async function fn5(): PromiseLike { } // error +async function fn6(): Thenable { } // error +async function fn7() { return; } // valid: Promise +async function fn8() { return 1; } // valid: Promise +async function fn9() { return null; } // valid: Promise +async function fn10() { return undefined; } // valid: Promise +async function fn11() { return a; } // valid: Promise +async function fn12() { return obj; } // valid: Promise<{ then: string; }> +async function fn13() { return thenable; } // error +async function fn14() { await 1; } // valid: Promise +async function fn15() { await null; } // valid: Promise +async function fn16() { await undefined; } // valid: Promise +async function fn17() { await a; } // valid: Promise +async function fn18() { await obj; } // valid: Promise +async function fn19() { await thenable; } // error + + +//// [asyncFunctionDeclaration15_es2017.js] +async function fn1() { } // valid: Promise +// valid: Promise +async function fn2() { } // error +// error +async function fn3() { } // error +// error +async function fn4() { } // error +// error +async function fn5() { } // error +// error +async function fn6() { } // error +// error +async function fn7() { return; } // valid: Promise +// valid: Promise +async function fn8() { return 1; } // valid: Promise +// valid: Promise +async function fn9() { return null; } // valid: Promise +// valid: Promise +async function fn10() { return undefined; } // valid: Promise +// valid: Promise +async function fn11() { return a; } // valid: Promise +// valid: Promise +async function fn12() { return obj; } // valid: Promise<{ then: string; }> +// valid: Promise<{ then: string; }> +async function fn13() { return thenable; } // error +// error +async function fn14() { await 1; } // valid: Promise +// valid: Promise +async function fn15() { await null; } // valid: Promise +// valid: Promise +async function fn16() { await undefined; } // valid: Promise +// valid: Promise +async function fn17() { await a; } // valid: Promise +// valid: Promise +async function fn18() { await obj; } // valid: Promise +// valid: Promise +async function fn19() { await thenable; } // error diff --git a/tests/baselines/reference/asyncFunctionDeclaration1_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration1_es2017.js new file mode 100644 index 00000000000..549fd226b2f --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration1_es2017.js @@ -0,0 +1,7 @@ +//// [asyncFunctionDeclaration1_es2017.ts] +async function foo(): Promise { +} + +//// [asyncFunctionDeclaration1_es2017.js] +async function foo() { +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration1_es2017.symbols b/tests/baselines/reference/asyncFunctionDeclaration1_es2017.symbols new file mode 100644 index 00000000000..a712df45896 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration1_es2017.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration1_es2017.ts === +async function foo(): Promise { +>foo : Symbol(foo, Decl(asyncFunctionDeclaration1_es2017.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration1_es2017.types b/tests/baselines/reference/asyncFunctionDeclaration1_es2017.types new file mode 100644 index 00000000000..ff97e686c43 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration1_es2017.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration1_es2017.ts === +async function foo(): Promise { +>foo : () => Promise +>Promise : Promise +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration2_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration2_es2017.js new file mode 100644 index 00000000000..6de061456e8 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration2_es2017.js @@ -0,0 +1,7 @@ +//// [asyncFunctionDeclaration2_es2017.ts] +function f(await) { +} + +//// [asyncFunctionDeclaration2_es2017.js] +function f(await) { +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration2_es2017.symbols b/tests/baselines/reference/asyncFunctionDeclaration2_es2017.symbols new file mode 100644 index 00000000000..aed41f50310 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration2_es2017.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration2_es2017.ts === +function f(await) { +>f : Symbol(f, Decl(asyncFunctionDeclaration2_es2017.ts, 0, 0)) +>await : Symbol(await, Decl(asyncFunctionDeclaration2_es2017.ts, 0, 11)) +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration2_es2017.types b/tests/baselines/reference/asyncFunctionDeclaration2_es2017.types new file mode 100644 index 00000000000..8413bea692a --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration2_es2017.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration2_es2017.ts === +function f(await) { +>f : (await: any) => void +>await : any +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration3_es2017.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration3_es2017.errors.txt new file mode 100644 index 00000000000..53a85074834 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration3_es2017.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration3_es2017.ts(1,20): error TS2372: Parameter 'await' cannot be referenced in its initializer. + + +==== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration3_es2017.ts (1 errors) ==== + function f(await = await) { + ~~~~~ +!!! error TS2372: Parameter 'await' cannot be referenced in its initializer. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration3_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration3_es2017.js new file mode 100644 index 00000000000..d6110265fdc --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration3_es2017.js @@ -0,0 +1,7 @@ +//// [asyncFunctionDeclaration3_es2017.ts] +function f(await = await) { +} + +//// [asyncFunctionDeclaration3_es2017.js] +function f(await = await) { +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration4_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration4_es2017.js new file mode 100644 index 00000000000..6209531e549 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration4_es2017.js @@ -0,0 +1,7 @@ +//// [asyncFunctionDeclaration4_es2017.ts] +function await() { +} + +//// [asyncFunctionDeclaration4_es2017.js] +function await() { +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration4_es2017.symbols b/tests/baselines/reference/asyncFunctionDeclaration4_es2017.symbols new file mode 100644 index 00000000000..7afbd879c59 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration4_es2017.symbols @@ -0,0 +1,4 @@ +=== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration4_es2017.ts === +function await() { +>await : Symbol(await, Decl(asyncFunctionDeclaration4_es2017.ts, 0, 0)) +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration4_es2017.types b/tests/baselines/reference/asyncFunctionDeclaration4_es2017.types new file mode 100644 index 00000000000..f7c4248f7c3 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration4_es2017.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration4_es2017.ts === +function await() { +>await : () => void +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es2017.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration5_es2017.errors.txt new file mode 100644 index 00000000000..ad8c0280206 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es2017.errors.txt @@ -0,0 +1,20 @@ +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts(1,20): error TS1138: Parameter declaration expected. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts(1,20): error TS2304: Cannot find name 'await'. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts(1,25): error TS1005: ';' expected. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts(1,26): error TS1128: Declaration or statement expected. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts(1,40): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts (5 errors) ==== + async function foo(await): Promise { + ~~~~~ +!!! error TS1138: Parameter declaration expected. + ~~~~~ +!!! error TS2304: Cannot find name 'await'. + ~ +!!! error TS1005: ';' expected. + ~ +!!! error TS1128: Declaration or statement expected. + ~ +!!! error TS1109: Expression expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration5_es2017.js new file mode 100644 index 00000000000..13c04c5d5bc --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es2017.js @@ -0,0 +1,7 @@ +//// [asyncFunctionDeclaration5_es2017.ts] +async function foo(await): Promise { +} + +//// [asyncFunctionDeclaration5_es2017.js] +await; +Promise < void > {}; diff --git a/tests/baselines/reference/asyncFunctionDeclaration6_es2017.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration6_es2017.errors.txt new file mode 100644 index 00000000000..b5a5ddccdce --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration6_es2017.errors.txt @@ -0,0 +1,11 @@ +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration6_es2017.ts(1,24): error TS2524: 'await' expressions cannot be used in a parameter initializer. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration6_es2017.ts(1,29): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration6_es2017.ts (2 errors) ==== + async function foo(a = await): Promise { + ~~~~~ +!!! error TS2524: 'await' expressions cannot be used in a parameter initializer. + ~ +!!! error TS1109: Expression expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration6_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration6_es2017.js new file mode 100644 index 00000000000..6df02000846 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration6_es2017.js @@ -0,0 +1,7 @@ +//// [asyncFunctionDeclaration6_es2017.ts] +async function foo(a = await): Promise { +} + +//// [asyncFunctionDeclaration6_es2017.js] +async function foo(a = await ) { +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration7_es2017.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration7_es2017.errors.txt new file mode 100644 index 00000000000..ad9ec9a043a --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration7_es2017.errors.txt @@ -0,0 +1,14 @@ +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration7_es2017.ts(3,26): error TS2524: 'await' expressions cannot be used in a parameter initializer. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration7_es2017.ts(3,31): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration7_es2017.ts (2 errors) ==== + async function bar(): Promise { + // 'await' here is an identifier, and not a yield expression. + async function foo(a = await): Promise { + ~~~~~ +!!! error TS2524: 'await' expressions cannot be used in a parameter initializer. + ~ +!!! error TS1109: Expression expected. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration7_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration7_es2017.js new file mode 100644 index 00000000000..c9aaa80b9b0 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration7_es2017.js @@ -0,0 +1,13 @@ +//// [asyncFunctionDeclaration7_es2017.ts] +async function bar(): Promise { + // 'await' here is an identifier, and not a yield expression. + async function foo(a = await): Promise { + } +} + +//// [asyncFunctionDeclaration7_es2017.js] +async function bar() { + // 'await' here is an identifier, and not a yield expression. + async function foo(a = await ) { + } +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration8_es2017.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration8_es2017.errors.txt new file mode 100644 index 00000000000..b82f012d694 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration8_es2017.errors.txt @@ -0,0 +1,10 @@ +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration8_es2017.ts(1,12): error TS2304: Cannot find name 'await'. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration8_es2017.ts(1,20): error TS2304: Cannot find name 'foo'. + + +==== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration8_es2017.ts (2 errors) ==== + var v = { [await]: foo } + ~~~~~ +!!! error TS2304: Cannot find name 'await'. + ~~~ +!!! error TS2304: Cannot find name 'foo'. \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration8_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration8_es2017.js new file mode 100644 index 00000000000..db7bfa4f9fb --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration8_es2017.js @@ -0,0 +1,5 @@ +//// [asyncFunctionDeclaration8_es2017.ts] +var v = { [await]: foo } + +//// [asyncFunctionDeclaration8_es2017.js] +var v = { [await]: foo }; diff --git a/tests/baselines/reference/asyncFunctionDeclaration9_es2017.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration9_es2017.errors.txt new file mode 100644 index 00000000000..27c41d8b253 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration9_es2017.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration9_es2017.ts(2,19): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration9_es2017.ts (1 errors) ==== + async function foo(): Promise { + var v = { [await]: foo } + ~ +!!! error TS1109: Expression expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration9_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration9_es2017.js new file mode 100644 index 00000000000..08cb8e44ba0 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration9_es2017.js @@ -0,0 +1,9 @@ +//// [asyncFunctionDeclaration9_es2017.ts] +async function foo(): Promise { + var v = { [await]: foo } +} + +//// [asyncFunctionDeclaration9_es2017.js] +async function foo() { + var v = { [await ]: foo }; +} diff --git a/tests/baselines/reference/asyncGetter_es2017.errors.txt b/tests/baselines/reference/asyncGetter_es2017.errors.txt new file mode 100644 index 00000000000..386e95d5977 --- /dev/null +++ b/tests/baselines/reference/asyncGetter_es2017.errors.txt @@ -0,0 +1,13 @@ +tests/cases/conformance/async/es2017/asyncGetter_es2017.ts(2,3): error TS1042: 'async' modifier cannot be used here. +tests/cases/conformance/async/es2017/asyncGetter_es2017.ts(2,13): error TS2378: A 'get' accessor must return a value. + + +==== tests/cases/conformance/async/es2017/asyncGetter_es2017.ts (2 errors) ==== + class C { + async get foo() { + ~~~~~ +!!! error TS1042: 'async' modifier cannot be used here. + ~~~ +!!! error TS2378: A 'get' accessor must return a value. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncGetter_es2017.js b/tests/baselines/reference/asyncGetter_es2017.js new file mode 100644 index 00000000000..ad8fa347cb5 --- /dev/null +++ b/tests/baselines/reference/asyncGetter_es2017.js @@ -0,0 +1,11 @@ +//// [asyncGetter_es2017.ts] +class C { + async get foo() { + } +} + +//// [asyncGetter_es2017.js] +class C { + async get foo() { + } +} diff --git a/tests/baselines/reference/asyncImportedPromise_es2017.errors.txt b/tests/baselines/reference/asyncImportedPromise_es2017.errors.txt new file mode 100644 index 00000000000..a0348b2e691 --- /dev/null +++ b/tests/baselines/reference/asyncImportedPromise_es2017.errors.txt @@ -0,0 +1,13 @@ +tests/cases/conformance/async/es2017/test.ts(3,25): error TS1064: The return type of an async function or method must be the global Promise type. + + +==== tests/cases/conformance/async/es2017/task.ts (0 errors) ==== + export class Task extends Promise { } + +==== tests/cases/conformance/async/es2017/test.ts (1 errors) ==== + import { Task } from "./task"; + class Test { + async example(): Task { return; } + ~~~~~~~ +!!! error TS1064: The return type of an async function or method must be the global Promise type. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncImportedPromise_es2017.js b/tests/baselines/reference/asyncImportedPromise_es2017.js new file mode 100644 index 00000000000..a48c58c1707 --- /dev/null +++ b/tests/baselines/reference/asyncImportedPromise_es2017.js @@ -0,0 +1,21 @@ +//// [tests/cases/conformance/async/es2017/asyncImportedPromise_es2017.ts] //// + +//// [task.ts] +export class Task extends Promise { } + +//// [test.ts] +import { Task } from "./task"; +class Test { + async example(): Task { return; } +} + +//// [task.js] +"use strict"; +class Task extends Promise { +} +exports.Task = Task; +//// [test.js] +"use strict"; +class Test { + async example() { return; } +} diff --git a/tests/baselines/reference/asyncInterface_es2017.errors.txt b/tests/baselines/reference/asyncInterface_es2017.errors.txt new file mode 100644 index 00000000000..dfbc8789797 --- /dev/null +++ b/tests/baselines/reference/asyncInterface_es2017.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/async/es2017/asyncInterface_es2017.ts(1,1): error TS1042: 'async' modifier cannot be used here. + + +==== tests/cases/conformance/async/es2017/asyncInterface_es2017.ts (1 errors) ==== + async interface I { + ~~~~~ +!!! error TS1042: 'async' modifier cannot be used here. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncInterface_es2017.js b/tests/baselines/reference/asyncInterface_es2017.js new file mode 100644 index 00000000000..4d897389538 --- /dev/null +++ b/tests/baselines/reference/asyncInterface_es2017.js @@ -0,0 +1,5 @@ +//// [asyncInterface_es2017.ts] +async interface I { +} + +//// [asyncInterface_es2017.js] diff --git a/tests/baselines/reference/asyncMethodWithSuper_es2017.js b/tests/baselines/reference/asyncMethodWithSuper_es2017.js new file mode 100644 index 00000000000..b6925793163 --- /dev/null +++ b/tests/baselines/reference/asyncMethodWithSuper_es2017.js @@ -0,0 +1,90 @@ +//// [asyncMethodWithSuper_es2017.ts] +class A { + x() { + } +} + +class B extends A { + // async method with only call/get on 'super' does not require a binding + async simple() { + // call with property access + super.x(); + + // call with element access + super["x"](); + + // property access (read) + const a = super.x; + + // element access (read) + const b = super["x"]; + } + + // async method with assignment/destructuring on 'super' requires a binding + async advanced() { + const f = () => {}; + + // call with property access + super.x(); + + // call with element access + super["x"](); + + // property access (read) + const a = super.x; + + // element access (read) + const b = super["x"]; + + // property access (assign) + super.x = f; + + // element access (assign) + super["x"] = f; + + // destructuring assign with property access + ({ f: super.x } = { f }); + + // destructuring assign with element access + ({ f: super["x"] } = { f }); + } +} + +//// [asyncMethodWithSuper_es2017.js] +class A { + x() { + } +} +class B extends A { + // async method with only call/get on 'super' does not require a binding + async simple() { + // call with property access + super.x(); + // call with element access + super["x"](); + // property access (read) + const a = super.x; + // element access (read) + const b = super["x"]; + } + // async method with assignment/destructuring on 'super' requires a binding + async advanced() { + const f = () => { }; + // call with property access + super.x(); + // call with element access + super["x"](); + // property access (read) + const a = super.x; + // element access (read) + const b = super["x"]; + // property access (assign) + super.x = f; + // element access (assign) + super["x"] = f; + // destructuring assign with property access + ({ f: super.x } = { f }); + // destructuring assign with element access + ({ f: super["x"] } = { f }); + } +} diff --git a/tests/baselines/reference/asyncMethodWithSuper_es2017.symbols b/tests/baselines/reference/asyncMethodWithSuper_es2017.symbols new file mode 100644 index 00000000000..39ed91d7acb --- /dev/null +++ b/tests/baselines/reference/asyncMethodWithSuper_es2017.symbols @@ -0,0 +1,102 @@ +=== tests/cases/conformance/async/es2017/asyncMethodWithSuper_es2017.ts === +class A { +>A : Symbol(A, Decl(asyncMethodWithSuper_es2017.ts, 0, 0)) + + x() { +>x : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9)) + } +} + +class B extends A { +>B : Symbol(B, Decl(asyncMethodWithSuper_es2017.ts, 3, 1)) +>A : Symbol(A, Decl(asyncMethodWithSuper_es2017.ts, 0, 0)) + + // async method with only call/get on 'super' does not require a binding + async simple() { +>simple : Symbol(B.simple, Decl(asyncMethodWithSuper_es2017.ts, 5, 19)) + + // call with property access + super.x(); +>super.x : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9)) +>super : Symbol(A, Decl(asyncMethodWithSuper_es2017.ts, 0, 0)) +>x : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9)) + + // call with element access + super["x"](); +>super : Symbol(A, Decl(asyncMethodWithSuper_es2017.ts, 0, 0)) +>"x" : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9)) + + // property access (read) + const a = super.x; +>a : Symbol(a, Decl(asyncMethodWithSuper_es2017.ts, 15, 13)) +>super.x : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9)) +>super : Symbol(A, Decl(asyncMethodWithSuper_es2017.ts, 0, 0)) +>x : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9)) + + // element access (read) + const b = super["x"]; +>b : Symbol(b, Decl(asyncMethodWithSuper_es2017.ts, 18, 13)) +>super : Symbol(A, Decl(asyncMethodWithSuper_es2017.ts, 0, 0)) +>"x" : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9)) + } + + // async method with assignment/destructuring on 'super' requires a binding + async advanced() { +>advanced : Symbol(B.advanced, Decl(asyncMethodWithSuper_es2017.ts, 19, 5)) + + const f = () => {}; +>f : Symbol(f, Decl(asyncMethodWithSuper_es2017.ts, 23, 13)) + + // call with property access + super.x(); +>super.x : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9)) +>super : Symbol(A, Decl(asyncMethodWithSuper_es2017.ts, 0, 0)) +>x : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9)) + + // call with element access + super["x"](); +>super : Symbol(A, Decl(asyncMethodWithSuper_es2017.ts, 0, 0)) +>"x" : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9)) + + // property access (read) + const a = super.x; +>a : Symbol(a, Decl(asyncMethodWithSuper_es2017.ts, 32, 13)) +>super.x : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9)) +>super : Symbol(A, Decl(asyncMethodWithSuper_es2017.ts, 0, 0)) +>x : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9)) + + // element access (read) + const b = super["x"]; +>b : Symbol(b, Decl(asyncMethodWithSuper_es2017.ts, 35, 13)) +>super : Symbol(A, Decl(asyncMethodWithSuper_es2017.ts, 0, 0)) +>"x" : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9)) + + // property access (assign) + super.x = f; +>super.x : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9)) +>super : Symbol(A, Decl(asyncMethodWithSuper_es2017.ts, 0, 0)) +>x : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9)) +>f : Symbol(f, Decl(asyncMethodWithSuper_es2017.ts, 23, 13)) + + // element access (assign) + super["x"] = f; +>super : Symbol(A, Decl(asyncMethodWithSuper_es2017.ts, 0, 0)) +>"x" : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9)) +>f : Symbol(f, Decl(asyncMethodWithSuper_es2017.ts, 23, 13)) + + // destructuring assign with property access + ({ f: super.x } = { f }); +>f : Symbol(f, Decl(asyncMethodWithSuper_es2017.ts, 44, 10)) +>super.x : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9)) +>super : Symbol(A, Decl(asyncMethodWithSuper_es2017.ts, 0, 0)) +>x : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9)) +>f : Symbol(f, Decl(asyncMethodWithSuper_es2017.ts, 44, 27)) + + // destructuring assign with element access + ({ f: super["x"] } = { f }); +>f : Symbol(f, Decl(asyncMethodWithSuper_es2017.ts, 47, 10)) +>super : Symbol(A, Decl(asyncMethodWithSuper_es2017.ts, 0, 0)) +>"x" : Symbol(A.x, Decl(asyncMethodWithSuper_es2017.ts, 0, 9)) +>f : Symbol(f, Decl(asyncMethodWithSuper_es2017.ts, 47, 30)) + } +} diff --git a/tests/baselines/reference/asyncMethodWithSuper_es2017.types b/tests/baselines/reference/asyncMethodWithSuper_es2017.types new file mode 100644 index 00000000000..b2678e8b837 --- /dev/null +++ b/tests/baselines/reference/asyncMethodWithSuper_es2017.types @@ -0,0 +1,123 @@ +=== tests/cases/conformance/async/es2017/asyncMethodWithSuper_es2017.ts === +class A { +>A : A + + x() { +>x : () => void + } +} + +class B extends A { +>B : B +>A : A + + // async method with only call/get on 'super' does not require a binding + async simple() { +>simple : () => Promise + + // call with property access + super.x(); +>super.x() : void +>super.x : () => void +>super : A +>x : () => void + + // call with element access + super["x"](); +>super["x"]() : void +>super["x"] : () => void +>super : A +>"x" : "x" + + // property access (read) + const a = super.x; +>a : () => void +>super.x : () => void +>super : A +>x : () => void + + // element access (read) + const b = super["x"]; +>b : () => void +>super["x"] : () => void +>super : A +>"x" : "x" + } + + // async method with assignment/destructuring on 'super' requires a binding + async advanced() { +>advanced : () => Promise + + const f = () => {}; +>f : () => void +>() => {} : () => void + + // call with property access + super.x(); +>super.x() : void +>super.x : () => void +>super : A +>x : () => void + + // call with element access + super["x"](); +>super["x"]() : void +>super["x"] : () => void +>super : A +>"x" : "x" + + // property access (read) + const a = super.x; +>a : () => void +>super.x : () => void +>super : A +>x : () => void + + // element access (read) + const b = super["x"]; +>b : () => void +>super["x"] : () => void +>super : A +>"x" : "x" + + // property access (assign) + super.x = f; +>super.x = f : () => void +>super.x : () => void +>super : A +>x : () => void +>f : () => void + + // element access (assign) + super["x"] = f; +>super["x"] = f : () => void +>super["x"] : () => void +>super : A +>"x" : "x" +>f : () => void + + // destructuring assign with property access + ({ f: super.x } = { f }); +>({ f: super.x } = { f }) : { f: () => void; } +>{ f: super.x } = { f } : { f: () => void; } +>{ f: super.x } : { f: () => void; } +>f : () => void +>super.x : () => void +>super : A +>x : () => void +>{ f } : { f: () => void; } +>f : () => void + + // destructuring assign with element access + ({ f: super["x"] } = { f }); +>({ f: super["x"] } = { f }) : { f: () => void; } +>{ f: super["x"] } = { f } : { f: () => void; } +>{ f: super["x"] } : { f: () => void; } +>f : () => void +>super["x"] : () => void +>super : A +>"x" : "x" +>{ f } : { f: () => void; } +>f : () => void + } +} diff --git a/tests/baselines/reference/asyncModule_es2017.errors.txt b/tests/baselines/reference/asyncModule_es2017.errors.txt new file mode 100644 index 00000000000..8b6a4c3dc66 --- /dev/null +++ b/tests/baselines/reference/asyncModule_es2017.errors.txt @@ -0,0 +1,8 @@ +tests/cases/conformance/async/es2017/asyncModule_es2017.ts(1,1): error TS1042: 'async' modifier cannot be used here. + + +==== tests/cases/conformance/async/es2017/asyncModule_es2017.ts (1 errors) ==== + async module M { + ~~~~~ +!!! error TS1042: 'async' modifier cannot be used here. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncModule_es2017.js b/tests/baselines/reference/asyncModule_es2017.js new file mode 100644 index 00000000000..fe3e17d5e74 --- /dev/null +++ b/tests/baselines/reference/asyncModule_es2017.js @@ -0,0 +1,5 @@ +//// [asyncModule_es2017.ts] +async module M { +} + +//// [asyncModule_es2017.js] diff --git a/tests/baselines/reference/asyncMultiFile_es2017.js b/tests/baselines/reference/asyncMultiFile_es2017.js new file mode 100644 index 00000000000..804a58e4b4c --- /dev/null +++ b/tests/baselines/reference/asyncMultiFile_es2017.js @@ -0,0 +1,11 @@ +//// [tests/cases/conformance/async/es2017/asyncMultiFile_es2017.ts] //// + +//// [a.ts] +async function f() {} +//// [b.ts] +function g() { } + +//// [a.js] +async function f() { } +//// [b.js] +function g() { } diff --git a/tests/baselines/reference/asyncMultiFile_es2017.symbols b/tests/baselines/reference/asyncMultiFile_es2017.symbols new file mode 100644 index 00000000000..9d8ff6dbe85 --- /dev/null +++ b/tests/baselines/reference/asyncMultiFile_es2017.symbols @@ -0,0 +1,8 @@ +=== tests/cases/conformance/async/es2017/a.ts === +async function f() {} +>f : Symbol(f, Decl(a.ts, 0, 0)) + +=== tests/cases/conformance/async/es2017/b.ts === +function g() { } +>g : Symbol(g, Decl(b.ts, 0, 0)) + diff --git a/tests/baselines/reference/asyncMultiFile_es2017.types b/tests/baselines/reference/asyncMultiFile_es2017.types new file mode 100644 index 00000000000..e1f8da34c94 --- /dev/null +++ b/tests/baselines/reference/asyncMultiFile_es2017.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/async/es2017/a.ts === +async function f() {} +>f : () => Promise + +=== tests/cases/conformance/async/es2017/b.ts === +function g() { } +>g : () => void + diff --git a/tests/baselines/reference/asyncQualifiedReturnType_es2017.errors.txt b/tests/baselines/reference/asyncQualifiedReturnType_es2017.errors.txt new file mode 100644 index 00000000000..b9027c36539 --- /dev/null +++ b/tests/baselines/reference/asyncQualifiedReturnType_es2017.errors.txt @@ -0,0 +1,13 @@ +tests/cases/conformance/async/es2017/asyncQualifiedReturnType_es2017.ts(6,21): error TS1064: The return type of an async function or method must be the global Promise type. + + +==== tests/cases/conformance/async/es2017/asyncQualifiedReturnType_es2017.ts (1 errors) ==== + namespace X { + export class MyPromise extends Promise { + } + } + + async function f(): X.MyPromise { + ~~~~~~~~~~~~~~~~~ +!!! error TS1064: The return type of an async function or method must be the global Promise type. + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncQualifiedReturnType_es2017.js b/tests/baselines/reference/asyncQualifiedReturnType_es2017.js new file mode 100644 index 00000000000..164a4fef610 --- /dev/null +++ b/tests/baselines/reference/asyncQualifiedReturnType_es2017.js @@ -0,0 +1,18 @@ +//// [asyncQualifiedReturnType_es2017.ts] +namespace X { + export class MyPromise extends Promise { + } +} + +async function f(): X.MyPromise { +} + +//// [asyncQualifiedReturnType_es2017.js] +var X; +(function (X) { + class MyPromise extends Promise { + } + X.MyPromise = MyPromise; +})(X || (X = {})); +async function f() { +} diff --git a/tests/baselines/reference/asyncSetter_es2017.errors.txt b/tests/baselines/reference/asyncSetter_es2017.errors.txt new file mode 100644 index 00000000000..0acd8538f20 --- /dev/null +++ b/tests/baselines/reference/asyncSetter_es2017.errors.txt @@ -0,0 +1,10 @@ +tests/cases/conformance/async/es2017/asyncSetter_es2017.ts(2,3): error TS1042: 'async' modifier cannot be used here. + + +==== tests/cases/conformance/async/es2017/asyncSetter_es2017.ts (1 errors) ==== + class C { + async set foo(value) { + ~~~~~ +!!! error TS1042: 'async' modifier cannot be used here. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/asyncSetter_es2017.js b/tests/baselines/reference/asyncSetter_es2017.js new file mode 100644 index 00000000000..8260c5232a2 --- /dev/null +++ b/tests/baselines/reference/asyncSetter_es2017.js @@ -0,0 +1,11 @@ +//// [asyncSetter_es2017.ts] +class C { + async set foo(value) { + } +} + +//// [asyncSetter_es2017.js] +class C { + async set foo(value) { + } +} diff --git a/tests/baselines/reference/asyncUnParenthesizedArrowFunction_es2017.js b/tests/baselines/reference/asyncUnParenthesizedArrowFunction_es2017.js new file mode 100644 index 00000000000..c97fda43011 --- /dev/null +++ b/tests/baselines/reference/asyncUnParenthesizedArrowFunction_es2017.js @@ -0,0 +1,9 @@ +//// [asyncUnParenthesizedArrowFunction_es2017.ts] + +declare function someOtherFunction(i: any): Promise; +const x = async i => await someOtherFunction(i) +const x1 = async (i) => await someOtherFunction(i); + +//// [asyncUnParenthesizedArrowFunction_es2017.js] +const x = async (i) => await someOtherFunction(i); +const x1 = async (i) => await someOtherFunction(i); diff --git a/tests/baselines/reference/asyncUnParenthesizedArrowFunction_es2017.symbols b/tests/baselines/reference/asyncUnParenthesizedArrowFunction_es2017.symbols new file mode 100644 index 00000000000..b5f83de6021 --- /dev/null +++ b/tests/baselines/reference/asyncUnParenthesizedArrowFunction_es2017.symbols @@ -0,0 +1,19 @@ +=== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncUnParenthesizedArrowFunction_es2017.ts === + +declare function someOtherFunction(i: any): Promise; +>someOtherFunction : Symbol(someOtherFunction, Decl(asyncUnParenthesizedArrowFunction_es2017.ts, 0, 0)) +>i : Symbol(i, Decl(asyncUnParenthesizedArrowFunction_es2017.ts, 1, 35)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + +const x = async i => await someOtherFunction(i) +>x : Symbol(x, Decl(asyncUnParenthesizedArrowFunction_es2017.ts, 2, 5)) +>i : Symbol(i, Decl(asyncUnParenthesizedArrowFunction_es2017.ts, 2, 15)) +>someOtherFunction : Symbol(someOtherFunction, Decl(asyncUnParenthesizedArrowFunction_es2017.ts, 0, 0)) +>i : Symbol(i, Decl(asyncUnParenthesizedArrowFunction_es2017.ts, 2, 15)) + +const x1 = async (i) => await someOtherFunction(i); +>x1 : Symbol(x1, Decl(asyncUnParenthesizedArrowFunction_es2017.ts, 3, 5)) +>i : Symbol(i, Decl(asyncUnParenthesizedArrowFunction_es2017.ts, 3, 18)) +>someOtherFunction : Symbol(someOtherFunction, Decl(asyncUnParenthesizedArrowFunction_es2017.ts, 0, 0)) +>i : Symbol(i, Decl(asyncUnParenthesizedArrowFunction_es2017.ts, 3, 18)) + diff --git a/tests/baselines/reference/asyncUnParenthesizedArrowFunction_es2017.types b/tests/baselines/reference/asyncUnParenthesizedArrowFunction_es2017.types new file mode 100644 index 00000000000..ff573e29ed3 --- /dev/null +++ b/tests/baselines/reference/asyncUnParenthesizedArrowFunction_es2017.types @@ -0,0 +1,25 @@ +=== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncUnParenthesizedArrowFunction_es2017.ts === + +declare function someOtherFunction(i: any): Promise; +>someOtherFunction : (i: any) => Promise +>i : any +>Promise : Promise + +const x = async i => await someOtherFunction(i) +>x : (i: any) => Promise +>async i => await someOtherFunction(i) : (i: any) => Promise +>i : any +>await someOtherFunction(i) : void +>someOtherFunction(i) : Promise +>someOtherFunction : (i: any) => Promise +>i : any + +const x1 = async (i) => await someOtherFunction(i); +>x1 : (i: any) => Promise +>async (i) => await someOtherFunction(i) : (i: any) => Promise +>i : any +>await someOtherFunction(i) : void +>someOtherFunction(i) : Promise +>someOtherFunction : (i: any) => Promise +>i : any + diff --git a/tests/baselines/reference/asyncUseStrict_es2017.js b/tests/baselines/reference/asyncUseStrict_es2017.js new file mode 100644 index 00000000000..1b9d1dc7f20 --- /dev/null +++ b/tests/baselines/reference/asyncUseStrict_es2017.js @@ -0,0 +1,13 @@ +//// [asyncUseStrict_es2017.ts] +declare var a: boolean; +declare var p: Promise; +async function func(): Promise { + "use strict"; + var b = await p || a; +} + +//// [asyncUseStrict_es2017.js] +async function func() { + "use strict"; + var b = await p || a; +} diff --git a/tests/baselines/reference/asyncUseStrict_es2017.symbols b/tests/baselines/reference/asyncUseStrict_es2017.symbols new file mode 100644 index 00000000000..23fd654ca29 --- /dev/null +++ b/tests/baselines/reference/asyncUseStrict_es2017.symbols @@ -0,0 +1,18 @@ +=== tests/cases/conformance/async/es2017/asyncUseStrict_es2017.ts === +declare var a: boolean; +>a : Symbol(a, Decl(asyncUseStrict_es2017.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(asyncUseStrict_es2017.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + +async function func(): Promise { +>func : Symbol(func, Decl(asyncUseStrict_es2017.ts, 1, 32)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + "use strict"; + var b = await p || a; +>b : Symbol(b, Decl(asyncUseStrict_es2017.ts, 4, 7)) +>p : Symbol(p, Decl(asyncUseStrict_es2017.ts, 1, 11)) +>a : Symbol(a, Decl(asyncUseStrict_es2017.ts, 0, 11)) +} diff --git a/tests/baselines/reference/asyncUseStrict_es2017.types b/tests/baselines/reference/asyncUseStrict_es2017.types new file mode 100644 index 00000000000..267eda83525 --- /dev/null +++ b/tests/baselines/reference/asyncUseStrict_es2017.types @@ -0,0 +1,22 @@ +=== tests/cases/conformance/async/es2017/asyncUseStrict_es2017.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + "use strict"; +>"use strict" : "use strict" + + var b = await p || a; +>b : boolean +>await p || a : boolean +>await p : boolean +>p : Promise +>a : boolean +} diff --git a/tests/baselines/reference/awaitBinaryExpression1_es2017.js b/tests/baselines/reference/awaitBinaryExpression1_es2017.js new file mode 100644 index 00000000000..9016a2b5826 --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression1_es2017.js @@ -0,0 +1,17 @@ +//// [awaitBinaryExpression1_es2017.ts] +declare var a: boolean; +declare var p: Promise; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = await p || a; + after(); +} + +//// [awaitBinaryExpression1_es2017.js] +async function func() { + before(); + var b = await p || a; + after(); +} diff --git a/tests/baselines/reference/awaitBinaryExpression1_es2017.symbols b/tests/baselines/reference/awaitBinaryExpression1_es2017.symbols new file mode 100644 index 00000000000..827769b3db5 --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression1_es2017.symbols @@ -0,0 +1,29 @@ +=== tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression1_es2017.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitBinaryExpression1_es2017.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitBinaryExpression1_es2017.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + +declare function before(): void; +>before : Symbol(before, Decl(awaitBinaryExpression1_es2017.ts, 1, 32)) + +declare function after(): void; +>after : Symbol(after, Decl(awaitBinaryExpression1_es2017.ts, 2, 32)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitBinaryExpression1_es2017.ts, 3, 31)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + before(); +>before : Symbol(before, Decl(awaitBinaryExpression1_es2017.ts, 1, 32)) + + var b = await p || a; +>b : Symbol(b, Decl(awaitBinaryExpression1_es2017.ts, 6, 7)) +>p : Symbol(p, Decl(awaitBinaryExpression1_es2017.ts, 1, 11)) +>a : Symbol(a, Decl(awaitBinaryExpression1_es2017.ts, 0, 11)) + + after(); +>after : Symbol(after, Decl(awaitBinaryExpression1_es2017.ts, 2, 32)) +} diff --git a/tests/baselines/reference/awaitBinaryExpression1_es2017.types b/tests/baselines/reference/awaitBinaryExpression1_es2017.types new file mode 100644 index 00000000000..c86631804c5 --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression1_es2017.types @@ -0,0 +1,33 @@ +=== tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression1_es2017.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function before(): void; +>before : () => void + +declare function after(): void; +>after : () => void + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + before(); +>before() : void +>before : () => void + + var b = await p || a; +>b : boolean +>await p || a : boolean +>await p : boolean +>p : Promise +>a : boolean + + after(); +>after() : void +>after : () => void +} diff --git a/tests/baselines/reference/awaitBinaryExpression2_es2017.js b/tests/baselines/reference/awaitBinaryExpression2_es2017.js new file mode 100644 index 00000000000..1d5ad324fda --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression2_es2017.js @@ -0,0 +1,17 @@ +//// [awaitBinaryExpression2_es2017.ts] +declare var a: boolean; +declare var p: Promise; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = await p && a; + after(); +} + +//// [awaitBinaryExpression2_es2017.js] +async function func() { + before(); + var b = await p && a; + after(); +} diff --git a/tests/baselines/reference/awaitBinaryExpression2_es2017.symbols b/tests/baselines/reference/awaitBinaryExpression2_es2017.symbols new file mode 100644 index 00000000000..549eb49cf92 --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression2_es2017.symbols @@ -0,0 +1,29 @@ +=== tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression2_es2017.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitBinaryExpression2_es2017.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitBinaryExpression2_es2017.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + +declare function before(): void; +>before : Symbol(before, Decl(awaitBinaryExpression2_es2017.ts, 1, 32)) + +declare function after(): void; +>after : Symbol(after, Decl(awaitBinaryExpression2_es2017.ts, 2, 32)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitBinaryExpression2_es2017.ts, 3, 31)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + before(); +>before : Symbol(before, Decl(awaitBinaryExpression2_es2017.ts, 1, 32)) + + var b = await p && a; +>b : Symbol(b, Decl(awaitBinaryExpression2_es2017.ts, 6, 7)) +>p : Symbol(p, Decl(awaitBinaryExpression2_es2017.ts, 1, 11)) +>a : Symbol(a, Decl(awaitBinaryExpression2_es2017.ts, 0, 11)) + + after(); +>after : Symbol(after, Decl(awaitBinaryExpression2_es2017.ts, 2, 32)) +} diff --git a/tests/baselines/reference/awaitBinaryExpression2_es2017.types b/tests/baselines/reference/awaitBinaryExpression2_es2017.types new file mode 100644 index 00000000000..f803b1ac840 --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression2_es2017.types @@ -0,0 +1,33 @@ +=== tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression2_es2017.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function before(): void; +>before : () => void + +declare function after(): void; +>after : () => void + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + before(); +>before() : void +>before : () => void + + var b = await p && a; +>b : boolean +>await p && a : boolean +>await p : boolean +>p : Promise +>a : boolean + + after(); +>after() : void +>after : () => void +} diff --git a/tests/baselines/reference/awaitBinaryExpression3_es2017.js b/tests/baselines/reference/awaitBinaryExpression3_es2017.js new file mode 100644 index 00000000000..c752ec3be4a --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression3_es2017.js @@ -0,0 +1,17 @@ +//// [awaitBinaryExpression3_es2017.ts] +declare var a: number; +declare var p: Promise; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = await p + a; + after(); +} + +//// [awaitBinaryExpression3_es2017.js] +async function func() { + before(); + var b = await p + a; + after(); +} diff --git a/tests/baselines/reference/awaitBinaryExpression3_es2017.symbols b/tests/baselines/reference/awaitBinaryExpression3_es2017.symbols new file mode 100644 index 00000000000..29c8fb7f398 --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression3_es2017.symbols @@ -0,0 +1,29 @@ +=== tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression3_es2017.ts === +declare var a: number; +>a : Symbol(a, Decl(awaitBinaryExpression3_es2017.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitBinaryExpression3_es2017.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + +declare function before(): void; +>before : Symbol(before, Decl(awaitBinaryExpression3_es2017.ts, 1, 31)) + +declare function after(): void; +>after : Symbol(after, Decl(awaitBinaryExpression3_es2017.ts, 2, 32)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitBinaryExpression3_es2017.ts, 3, 31)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + before(); +>before : Symbol(before, Decl(awaitBinaryExpression3_es2017.ts, 1, 31)) + + var b = await p + a; +>b : Symbol(b, Decl(awaitBinaryExpression3_es2017.ts, 6, 7)) +>p : Symbol(p, Decl(awaitBinaryExpression3_es2017.ts, 1, 11)) +>a : Symbol(a, Decl(awaitBinaryExpression3_es2017.ts, 0, 11)) + + after(); +>after : Symbol(after, Decl(awaitBinaryExpression3_es2017.ts, 2, 32)) +} diff --git a/tests/baselines/reference/awaitBinaryExpression3_es2017.types b/tests/baselines/reference/awaitBinaryExpression3_es2017.types new file mode 100644 index 00000000000..623d0695237 --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression3_es2017.types @@ -0,0 +1,33 @@ +=== tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression3_es2017.ts === +declare var a: number; +>a : number + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function before(): void; +>before : () => void + +declare function after(): void; +>after : () => void + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + before(); +>before() : void +>before : () => void + + var b = await p + a; +>b : number +>await p + a : number +>await p : number +>p : Promise +>a : number + + after(); +>after() : void +>after : () => void +} diff --git a/tests/baselines/reference/awaitBinaryExpression4_es2017.js b/tests/baselines/reference/awaitBinaryExpression4_es2017.js new file mode 100644 index 00000000000..3fc296ea142 --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression4_es2017.js @@ -0,0 +1,17 @@ +//// [awaitBinaryExpression4_es2017.ts] +declare var a: boolean; +declare var p: Promise; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = (await p, a); + after(); +} + +//// [awaitBinaryExpression4_es2017.js] +async function func() { + before(); + var b = (await p, a); + after(); +} diff --git a/tests/baselines/reference/awaitBinaryExpression4_es2017.symbols b/tests/baselines/reference/awaitBinaryExpression4_es2017.symbols new file mode 100644 index 00000000000..0db5a20e0c1 --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression4_es2017.symbols @@ -0,0 +1,29 @@ +=== tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression4_es2017.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitBinaryExpression4_es2017.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitBinaryExpression4_es2017.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + +declare function before(): void; +>before : Symbol(before, Decl(awaitBinaryExpression4_es2017.ts, 1, 32)) + +declare function after(): void; +>after : Symbol(after, Decl(awaitBinaryExpression4_es2017.ts, 2, 32)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitBinaryExpression4_es2017.ts, 3, 31)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + before(); +>before : Symbol(before, Decl(awaitBinaryExpression4_es2017.ts, 1, 32)) + + var b = (await p, a); +>b : Symbol(b, Decl(awaitBinaryExpression4_es2017.ts, 6, 7)) +>p : Symbol(p, Decl(awaitBinaryExpression4_es2017.ts, 1, 11)) +>a : Symbol(a, Decl(awaitBinaryExpression4_es2017.ts, 0, 11)) + + after(); +>after : Symbol(after, Decl(awaitBinaryExpression4_es2017.ts, 2, 32)) +} diff --git a/tests/baselines/reference/awaitBinaryExpression4_es2017.types b/tests/baselines/reference/awaitBinaryExpression4_es2017.types new file mode 100644 index 00000000000..714b6b1ea3a --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression4_es2017.types @@ -0,0 +1,34 @@ +=== tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression4_es2017.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function before(): void; +>before : () => void + +declare function after(): void; +>after : () => void + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + before(); +>before() : void +>before : () => void + + var b = (await p, a); +>b : boolean +>(await p, a) : boolean +>await p, a : boolean +>await p : boolean +>p : Promise +>a : boolean + + after(); +>after() : void +>after : () => void +} diff --git a/tests/baselines/reference/awaitBinaryExpression5_es2017.js b/tests/baselines/reference/awaitBinaryExpression5_es2017.js new file mode 100644 index 00000000000..b6c5e12ce76 --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression5_es2017.js @@ -0,0 +1,19 @@ +//// [awaitBinaryExpression5_es2017.ts] +declare var a: boolean; +declare var p: Promise; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var o: { a: boolean; }; + o.a = await p; + after(); +} + +//// [awaitBinaryExpression5_es2017.js] +async function func() { + before(); + var o; + o.a = await p; + after(); +} diff --git a/tests/baselines/reference/awaitBinaryExpression5_es2017.symbols b/tests/baselines/reference/awaitBinaryExpression5_es2017.symbols new file mode 100644 index 00000000000..e2d30c658f7 --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression5_es2017.symbols @@ -0,0 +1,34 @@ +=== tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression5_es2017.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitBinaryExpression5_es2017.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitBinaryExpression5_es2017.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + +declare function before(): void; +>before : Symbol(before, Decl(awaitBinaryExpression5_es2017.ts, 1, 32)) + +declare function after(): void; +>after : Symbol(after, Decl(awaitBinaryExpression5_es2017.ts, 2, 32)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitBinaryExpression5_es2017.ts, 3, 31)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + before(); +>before : Symbol(before, Decl(awaitBinaryExpression5_es2017.ts, 1, 32)) + + var o: { a: boolean; }; +>o : Symbol(o, Decl(awaitBinaryExpression5_es2017.ts, 6, 7)) +>a : Symbol(a, Decl(awaitBinaryExpression5_es2017.ts, 6, 12)) + + o.a = await p; +>o.a : Symbol(a, Decl(awaitBinaryExpression5_es2017.ts, 6, 12)) +>o : Symbol(o, Decl(awaitBinaryExpression5_es2017.ts, 6, 7)) +>a : Symbol(a, Decl(awaitBinaryExpression5_es2017.ts, 6, 12)) +>p : Symbol(p, Decl(awaitBinaryExpression5_es2017.ts, 1, 11)) + + after(); +>after : Symbol(after, Decl(awaitBinaryExpression5_es2017.ts, 2, 32)) +} diff --git a/tests/baselines/reference/awaitBinaryExpression5_es2017.types b/tests/baselines/reference/awaitBinaryExpression5_es2017.types new file mode 100644 index 00000000000..763f9e50862 --- /dev/null +++ b/tests/baselines/reference/awaitBinaryExpression5_es2017.types @@ -0,0 +1,38 @@ +=== tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression5_es2017.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function before(): void; +>before : () => void + +declare function after(): void; +>after : () => void + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + before(); +>before() : void +>before : () => void + + var o: { a: boolean; }; +>o : { a: boolean; } +>a : boolean + + o.a = await p; +>o.a = await p : boolean +>o.a : boolean +>o : { a: boolean; } +>a : boolean +>await p : boolean +>p : Promise + + after(); +>after() : void +>after : () => void +} diff --git a/tests/baselines/reference/awaitCallExpression1_es2017.js b/tests/baselines/reference/awaitCallExpression1_es2017.js new file mode 100644 index 00000000000..89fe7dfd912 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression1_es2017.js @@ -0,0 +1,21 @@ +//// [awaitCallExpression1_es2017.ts] +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = fn(a, a, a); + after(); +} + +//// [awaitCallExpression1_es2017.js] +async function func() { + before(); + var b = fn(a, a, a); + after(); +} diff --git a/tests/baselines/reference/awaitCallExpression1_es2017.symbols b/tests/baselines/reference/awaitCallExpression1_es2017.symbols new file mode 100644 index 00000000000..68c28d15350 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression1_es2017.symbols @@ -0,0 +1,59 @@ +=== tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression1_es2017.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitCallExpression1_es2017.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitCallExpression1_es2017.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : Symbol(fn, Decl(awaitCallExpression1_es2017.ts, 1, 32)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression1_es2017.ts, 2, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression1_es2017.ts, 2, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression1_es2017.ts, 2, 49)) + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : Symbol(o, Decl(awaitCallExpression1_es2017.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression1_es2017.ts, 3, 16)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression1_es2017.ts, 3, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression1_es2017.ts, 3, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression1_es2017.ts, 3, 49)) + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Symbol(pfn, Decl(awaitCallExpression1_es2017.ts, 4, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression1_es2017.ts, 4, 28)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression1_es2017.ts, 4, 42)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression1_es2017.ts, 4, 57)) + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Symbol(po, Decl(awaitCallExpression1_es2017.ts, 5, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>fn : Symbol(fn, Decl(awaitCallExpression1_es2017.ts, 5, 25)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression1_es2017.ts, 5, 29)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression1_es2017.ts, 5, 43)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression1_es2017.ts, 5, 58)) + +declare function before(): void; +>before : Symbol(before, Decl(awaitCallExpression1_es2017.ts, 5, 84)) + +declare function after(): void; +>after : Symbol(after, Decl(awaitCallExpression1_es2017.ts, 6, 32)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitCallExpression1_es2017.ts, 7, 31)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + before(); +>before : Symbol(before, Decl(awaitCallExpression1_es2017.ts, 5, 84)) + + var b = fn(a, a, a); +>b : Symbol(b, Decl(awaitCallExpression1_es2017.ts, 10, 7)) +>fn : Symbol(fn, Decl(awaitCallExpression1_es2017.ts, 1, 32)) +>a : Symbol(a, Decl(awaitCallExpression1_es2017.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression1_es2017.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression1_es2017.ts, 0, 11)) + + after(); +>after : Symbol(after, Decl(awaitCallExpression1_es2017.ts, 6, 32)) +} diff --git a/tests/baselines/reference/awaitCallExpression1_es2017.types b/tests/baselines/reference/awaitCallExpression1_es2017.types new file mode 100644 index 00000000000..c5cea091878 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression1_es2017.types @@ -0,0 +1,62 @@ +=== tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression1_es2017.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Promise<(arg0: boolean, arg1: boolean, arg2: boolean) => void> +>Promise : Promise +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }> +>Promise : Promise +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare function before(): void; +>before : () => void + +declare function after(): void; +>after : () => void + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + before(); +>before() : void +>before : () => void + + var b = fn(a, a, a); +>b : void +>fn(a, a, a) : void +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>a : boolean +>a : boolean +>a : boolean + + after(); +>after() : void +>after : () => void +} diff --git a/tests/baselines/reference/awaitCallExpression2_es2017.js b/tests/baselines/reference/awaitCallExpression2_es2017.js new file mode 100644 index 00000000000..24b3012f85d --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression2_es2017.js @@ -0,0 +1,21 @@ +//// [awaitCallExpression2_es2017.ts] +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = fn(await p, a, a); + after(); +} + +//// [awaitCallExpression2_es2017.js] +async function func() { + before(); + var b = fn(await p, a, a); + after(); +} diff --git a/tests/baselines/reference/awaitCallExpression2_es2017.symbols b/tests/baselines/reference/awaitCallExpression2_es2017.symbols new file mode 100644 index 00000000000..4528ae4c074 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression2_es2017.symbols @@ -0,0 +1,59 @@ +=== tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression2_es2017.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitCallExpression2_es2017.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitCallExpression2_es2017.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : Symbol(fn, Decl(awaitCallExpression2_es2017.ts, 1, 32)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression2_es2017.ts, 2, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression2_es2017.ts, 2, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression2_es2017.ts, 2, 49)) + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : Symbol(o, Decl(awaitCallExpression2_es2017.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression2_es2017.ts, 3, 16)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression2_es2017.ts, 3, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression2_es2017.ts, 3, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression2_es2017.ts, 3, 49)) + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Symbol(pfn, Decl(awaitCallExpression2_es2017.ts, 4, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression2_es2017.ts, 4, 28)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression2_es2017.ts, 4, 42)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression2_es2017.ts, 4, 57)) + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Symbol(po, Decl(awaitCallExpression2_es2017.ts, 5, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>fn : Symbol(fn, Decl(awaitCallExpression2_es2017.ts, 5, 25)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression2_es2017.ts, 5, 29)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression2_es2017.ts, 5, 43)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression2_es2017.ts, 5, 58)) + +declare function before(): void; +>before : Symbol(before, Decl(awaitCallExpression2_es2017.ts, 5, 84)) + +declare function after(): void; +>after : Symbol(after, Decl(awaitCallExpression2_es2017.ts, 6, 32)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitCallExpression2_es2017.ts, 7, 31)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + before(); +>before : Symbol(before, Decl(awaitCallExpression2_es2017.ts, 5, 84)) + + var b = fn(await p, a, a); +>b : Symbol(b, Decl(awaitCallExpression2_es2017.ts, 10, 7)) +>fn : Symbol(fn, Decl(awaitCallExpression2_es2017.ts, 1, 32)) +>p : Symbol(p, Decl(awaitCallExpression2_es2017.ts, 1, 11)) +>a : Symbol(a, Decl(awaitCallExpression2_es2017.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression2_es2017.ts, 0, 11)) + + after(); +>after : Symbol(after, Decl(awaitCallExpression2_es2017.ts, 6, 32)) +} diff --git a/tests/baselines/reference/awaitCallExpression2_es2017.types b/tests/baselines/reference/awaitCallExpression2_es2017.types new file mode 100644 index 00000000000..a15609a4078 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression2_es2017.types @@ -0,0 +1,63 @@ +=== tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression2_es2017.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Promise<(arg0: boolean, arg1: boolean, arg2: boolean) => void> +>Promise : Promise +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }> +>Promise : Promise +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare function before(): void; +>before : () => void + +declare function after(): void; +>after : () => void + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + before(); +>before() : void +>before : () => void + + var b = fn(await p, a, a); +>b : void +>fn(await p, a, a) : void +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>await p : boolean +>p : Promise +>a : boolean +>a : boolean + + after(); +>after() : void +>after : () => void +} diff --git a/tests/baselines/reference/awaitCallExpression3_es2017.js b/tests/baselines/reference/awaitCallExpression3_es2017.js new file mode 100644 index 00000000000..6b432851b00 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression3_es2017.js @@ -0,0 +1,21 @@ +//// [awaitCallExpression3_es2017.ts] +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = fn(a, await p, a); + after(); +} + +//// [awaitCallExpression3_es2017.js] +async function func() { + before(); + var b = fn(a, await p, a); + after(); +} diff --git a/tests/baselines/reference/awaitCallExpression3_es2017.symbols b/tests/baselines/reference/awaitCallExpression3_es2017.symbols new file mode 100644 index 00000000000..a1120103fb0 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression3_es2017.symbols @@ -0,0 +1,59 @@ +=== tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression3_es2017.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitCallExpression3_es2017.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitCallExpression3_es2017.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : Symbol(fn, Decl(awaitCallExpression3_es2017.ts, 1, 32)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression3_es2017.ts, 2, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression3_es2017.ts, 2, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression3_es2017.ts, 2, 49)) + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : Symbol(o, Decl(awaitCallExpression3_es2017.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression3_es2017.ts, 3, 16)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression3_es2017.ts, 3, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression3_es2017.ts, 3, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression3_es2017.ts, 3, 49)) + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Symbol(pfn, Decl(awaitCallExpression3_es2017.ts, 4, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression3_es2017.ts, 4, 28)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression3_es2017.ts, 4, 42)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression3_es2017.ts, 4, 57)) + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Symbol(po, Decl(awaitCallExpression3_es2017.ts, 5, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>fn : Symbol(fn, Decl(awaitCallExpression3_es2017.ts, 5, 25)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression3_es2017.ts, 5, 29)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression3_es2017.ts, 5, 43)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression3_es2017.ts, 5, 58)) + +declare function before(): void; +>before : Symbol(before, Decl(awaitCallExpression3_es2017.ts, 5, 84)) + +declare function after(): void; +>after : Symbol(after, Decl(awaitCallExpression3_es2017.ts, 6, 32)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitCallExpression3_es2017.ts, 7, 31)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + before(); +>before : Symbol(before, Decl(awaitCallExpression3_es2017.ts, 5, 84)) + + var b = fn(a, await p, a); +>b : Symbol(b, Decl(awaitCallExpression3_es2017.ts, 10, 7)) +>fn : Symbol(fn, Decl(awaitCallExpression3_es2017.ts, 1, 32)) +>a : Symbol(a, Decl(awaitCallExpression3_es2017.ts, 0, 11)) +>p : Symbol(p, Decl(awaitCallExpression3_es2017.ts, 1, 11)) +>a : Symbol(a, Decl(awaitCallExpression3_es2017.ts, 0, 11)) + + after(); +>after : Symbol(after, Decl(awaitCallExpression3_es2017.ts, 6, 32)) +} diff --git a/tests/baselines/reference/awaitCallExpression3_es2017.types b/tests/baselines/reference/awaitCallExpression3_es2017.types new file mode 100644 index 00000000000..a491836fa06 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression3_es2017.types @@ -0,0 +1,63 @@ +=== tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression3_es2017.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Promise<(arg0: boolean, arg1: boolean, arg2: boolean) => void> +>Promise : Promise +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }> +>Promise : Promise +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare function before(): void; +>before : () => void + +declare function after(): void; +>after : () => void + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + before(); +>before() : void +>before : () => void + + var b = fn(a, await p, a); +>b : void +>fn(a, await p, a) : void +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>a : boolean +>await p : boolean +>p : Promise +>a : boolean + + after(); +>after() : void +>after : () => void +} diff --git a/tests/baselines/reference/awaitCallExpression4_es2017.js b/tests/baselines/reference/awaitCallExpression4_es2017.js new file mode 100644 index 00000000000..9243ac58f82 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression4_es2017.js @@ -0,0 +1,21 @@ +//// [awaitCallExpression4_es2017.ts] +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = (await pfn)(a, a, a); + after(); +} + +//// [awaitCallExpression4_es2017.js] +async function func() { + before(); + var b = (await pfn)(a, a, a); + after(); +} diff --git a/tests/baselines/reference/awaitCallExpression4_es2017.symbols b/tests/baselines/reference/awaitCallExpression4_es2017.symbols new file mode 100644 index 00000000000..fb607d9841f --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression4_es2017.symbols @@ -0,0 +1,59 @@ +=== tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression4_es2017.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitCallExpression4_es2017.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitCallExpression4_es2017.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : Symbol(fn, Decl(awaitCallExpression4_es2017.ts, 1, 32)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression4_es2017.ts, 2, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression4_es2017.ts, 2, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression4_es2017.ts, 2, 49)) + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : Symbol(o, Decl(awaitCallExpression4_es2017.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression4_es2017.ts, 3, 16)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression4_es2017.ts, 3, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression4_es2017.ts, 3, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression4_es2017.ts, 3, 49)) + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Symbol(pfn, Decl(awaitCallExpression4_es2017.ts, 4, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression4_es2017.ts, 4, 28)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression4_es2017.ts, 4, 42)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression4_es2017.ts, 4, 57)) + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Symbol(po, Decl(awaitCallExpression4_es2017.ts, 5, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>fn : Symbol(fn, Decl(awaitCallExpression4_es2017.ts, 5, 25)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression4_es2017.ts, 5, 29)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression4_es2017.ts, 5, 43)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression4_es2017.ts, 5, 58)) + +declare function before(): void; +>before : Symbol(before, Decl(awaitCallExpression4_es2017.ts, 5, 84)) + +declare function after(): void; +>after : Symbol(after, Decl(awaitCallExpression4_es2017.ts, 6, 32)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitCallExpression4_es2017.ts, 7, 31)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + before(); +>before : Symbol(before, Decl(awaitCallExpression4_es2017.ts, 5, 84)) + + var b = (await pfn)(a, a, a); +>b : Symbol(b, Decl(awaitCallExpression4_es2017.ts, 10, 7)) +>pfn : Symbol(pfn, Decl(awaitCallExpression4_es2017.ts, 4, 11)) +>a : Symbol(a, Decl(awaitCallExpression4_es2017.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression4_es2017.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression4_es2017.ts, 0, 11)) + + after(); +>after : Symbol(after, Decl(awaitCallExpression4_es2017.ts, 6, 32)) +} diff --git a/tests/baselines/reference/awaitCallExpression4_es2017.types b/tests/baselines/reference/awaitCallExpression4_es2017.types new file mode 100644 index 00000000000..3f1b478e669 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression4_es2017.types @@ -0,0 +1,64 @@ +=== tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression4_es2017.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Promise<(arg0: boolean, arg1: boolean, arg2: boolean) => void> +>Promise : Promise +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }> +>Promise : Promise +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare function before(): void; +>before : () => void + +declare function after(): void; +>after : () => void + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + before(); +>before() : void +>before : () => void + + var b = (await pfn)(a, a, a); +>b : void +>(await pfn)(a, a, a) : void +>(await pfn) : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>await pfn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>pfn : Promise<(arg0: boolean, arg1: boolean, arg2: boolean) => void> +>a : boolean +>a : boolean +>a : boolean + + after(); +>after() : void +>after : () => void +} diff --git a/tests/baselines/reference/awaitCallExpression5_es2017.js b/tests/baselines/reference/awaitCallExpression5_es2017.js new file mode 100644 index 00000000000..d08823ac5a3 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression5_es2017.js @@ -0,0 +1,21 @@ +//// [awaitCallExpression5_es2017.ts] +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = o.fn(a, a, a); + after(); +} + +//// [awaitCallExpression5_es2017.js] +async function func() { + before(); + var b = o.fn(a, a, a); + after(); +} diff --git a/tests/baselines/reference/awaitCallExpression5_es2017.symbols b/tests/baselines/reference/awaitCallExpression5_es2017.symbols new file mode 100644 index 00000000000..3854353314a --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression5_es2017.symbols @@ -0,0 +1,61 @@ +=== tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression5_es2017.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitCallExpression5_es2017.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitCallExpression5_es2017.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : Symbol(fn, Decl(awaitCallExpression5_es2017.ts, 1, 32)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression5_es2017.ts, 2, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression5_es2017.ts, 2, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression5_es2017.ts, 2, 49)) + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : Symbol(o, Decl(awaitCallExpression5_es2017.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression5_es2017.ts, 3, 16)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression5_es2017.ts, 3, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression5_es2017.ts, 3, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression5_es2017.ts, 3, 49)) + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Symbol(pfn, Decl(awaitCallExpression5_es2017.ts, 4, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression5_es2017.ts, 4, 28)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression5_es2017.ts, 4, 42)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression5_es2017.ts, 4, 57)) + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Symbol(po, Decl(awaitCallExpression5_es2017.ts, 5, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>fn : Symbol(fn, Decl(awaitCallExpression5_es2017.ts, 5, 25)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression5_es2017.ts, 5, 29)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression5_es2017.ts, 5, 43)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression5_es2017.ts, 5, 58)) + +declare function before(): void; +>before : Symbol(before, Decl(awaitCallExpression5_es2017.ts, 5, 84)) + +declare function after(): void; +>after : Symbol(after, Decl(awaitCallExpression5_es2017.ts, 6, 32)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitCallExpression5_es2017.ts, 7, 31)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + before(); +>before : Symbol(before, Decl(awaitCallExpression5_es2017.ts, 5, 84)) + + var b = o.fn(a, a, a); +>b : Symbol(b, Decl(awaitCallExpression5_es2017.ts, 10, 7)) +>o.fn : Symbol(fn, Decl(awaitCallExpression5_es2017.ts, 3, 16)) +>o : Symbol(o, Decl(awaitCallExpression5_es2017.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression5_es2017.ts, 3, 16)) +>a : Symbol(a, Decl(awaitCallExpression5_es2017.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression5_es2017.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression5_es2017.ts, 0, 11)) + + after(); +>after : Symbol(after, Decl(awaitCallExpression5_es2017.ts, 6, 32)) +} diff --git a/tests/baselines/reference/awaitCallExpression5_es2017.types b/tests/baselines/reference/awaitCallExpression5_es2017.types new file mode 100644 index 00000000000..f31320e44f7 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression5_es2017.types @@ -0,0 +1,64 @@ +=== tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression5_es2017.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Promise<(arg0: boolean, arg1: boolean, arg2: boolean) => void> +>Promise : Promise +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }> +>Promise : Promise +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare function before(): void; +>before : () => void + +declare function after(): void; +>after : () => void + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + before(); +>before() : void +>before : () => void + + var b = o.fn(a, a, a); +>b : void +>o.fn(a, a, a) : void +>o.fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>a : boolean +>a : boolean +>a : boolean + + after(); +>after() : void +>after : () => void +} diff --git a/tests/baselines/reference/awaitCallExpression6_es2017.js b/tests/baselines/reference/awaitCallExpression6_es2017.js new file mode 100644 index 00000000000..77a47ba8065 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression6_es2017.js @@ -0,0 +1,21 @@ +//// [awaitCallExpression6_es2017.ts] +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = o.fn(await p, a, a); + after(); +} + +//// [awaitCallExpression6_es2017.js] +async function func() { + before(); + var b = o.fn(await p, a, a); + after(); +} diff --git a/tests/baselines/reference/awaitCallExpression6_es2017.symbols b/tests/baselines/reference/awaitCallExpression6_es2017.symbols new file mode 100644 index 00000000000..6a651510328 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression6_es2017.symbols @@ -0,0 +1,61 @@ +=== tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression6_es2017.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitCallExpression6_es2017.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitCallExpression6_es2017.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : Symbol(fn, Decl(awaitCallExpression6_es2017.ts, 1, 32)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression6_es2017.ts, 2, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression6_es2017.ts, 2, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression6_es2017.ts, 2, 49)) + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : Symbol(o, Decl(awaitCallExpression6_es2017.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression6_es2017.ts, 3, 16)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression6_es2017.ts, 3, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression6_es2017.ts, 3, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression6_es2017.ts, 3, 49)) + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Symbol(pfn, Decl(awaitCallExpression6_es2017.ts, 4, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression6_es2017.ts, 4, 28)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression6_es2017.ts, 4, 42)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression6_es2017.ts, 4, 57)) + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Symbol(po, Decl(awaitCallExpression6_es2017.ts, 5, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>fn : Symbol(fn, Decl(awaitCallExpression6_es2017.ts, 5, 25)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression6_es2017.ts, 5, 29)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression6_es2017.ts, 5, 43)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression6_es2017.ts, 5, 58)) + +declare function before(): void; +>before : Symbol(before, Decl(awaitCallExpression6_es2017.ts, 5, 84)) + +declare function after(): void; +>after : Symbol(after, Decl(awaitCallExpression6_es2017.ts, 6, 32)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitCallExpression6_es2017.ts, 7, 31)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + before(); +>before : Symbol(before, Decl(awaitCallExpression6_es2017.ts, 5, 84)) + + var b = o.fn(await p, a, a); +>b : Symbol(b, Decl(awaitCallExpression6_es2017.ts, 10, 7)) +>o.fn : Symbol(fn, Decl(awaitCallExpression6_es2017.ts, 3, 16)) +>o : Symbol(o, Decl(awaitCallExpression6_es2017.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression6_es2017.ts, 3, 16)) +>p : Symbol(p, Decl(awaitCallExpression6_es2017.ts, 1, 11)) +>a : Symbol(a, Decl(awaitCallExpression6_es2017.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression6_es2017.ts, 0, 11)) + + after(); +>after : Symbol(after, Decl(awaitCallExpression6_es2017.ts, 6, 32)) +} diff --git a/tests/baselines/reference/awaitCallExpression6_es2017.types b/tests/baselines/reference/awaitCallExpression6_es2017.types new file mode 100644 index 00000000000..ccce4cad366 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression6_es2017.types @@ -0,0 +1,65 @@ +=== tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression6_es2017.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Promise<(arg0: boolean, arg1: boolean, arg2: boolean) => void> +>Promise : Promise +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }> +>Promise : Promise +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare function before(): void; +>before : () => void + +declare function after(): void; +>after : () => void + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + before(); +>before() : void +>before : () => void + + var b = o.fn(await p, a, a); +>b : void +>o.fn(await p, a, a) : void +>o.fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>await p : boolean +>p : Promise +>a : boolean +>a : boolean + + after(); +>after() : void +>after : () => void +} diff --git a/tests/baselines/reference/awaitCallExpression7_es2017.js b/tests/baselines/reference/awaitCallExpression7_es2017.js new file mode 100644 index 00000000000..b3391ced6b6 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression7_es2017.js @@ -0,0 +1,21 @@ +//// [awaitCallExpression7_es2017.ts] +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = o.fn(a, await p, a); + after(); +} + +//// [awaitCallExpression7_es2017.js] +async function func() { + before(); + var b = o.fn(a, await p, a); + after(); +} diff --git a/tests/baselines/reference/awaitCallExpression7_es2017.symbols b/tests/baselines/reference/awaitCallExpression7_es2017.symbols new file mode 100644 index 00000000000..e95078c6850 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression7_es2017.symbols @@ -0,0 +1,61 @@ +=== tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression7_es2017.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitCallExpression7_es2017.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitCallExpression7_es2017.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : Symbol(fn, Decl(awaitCallExpression7_es2017.ts, 1, 32)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression7_es2017.ts, 2, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression7_es2017.ts, 2, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression7_es2017.ts, 2, 49)) + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : Symbol(o, Decl(awaitCallExpression7_es2017.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression7_es2017.ts, 3, 16)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression7_es2017.ts, 3, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression7_es2017.ts, 3, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression7_es2017.ts, 3, 49)) + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Symbol(pfn, Decl(awaitCallExpression7_es2017.ts, 4, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression7_es2017.ts, 4, 28)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression7_es2017.ts, 4, 42)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression7_es2017.ts, 4, 57)) + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Symbol(po, Decl(awaitCallExpression7_es2017.ts, 5, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>fn : Symbol(fn, Decl(awaitCallExpression7_es2017.ts, 5, 25)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression7_es2017.ts, 5, 29)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression7_es2017.ts, 5, 43)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression7_es2017.ts, 5, 58)) + +declare function before(): void; +>before : Symbol(before, Decl(awaitCallExpression7_es2017.ts, 5, 84)) + +declare function after(): void; +>after : Symbol(after, Decl(awaitCallExpression7_es2017.ts, 6, 32)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitCallExpression7_es2017.ts, 7, 31)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + before(); +>before : Symbol(before, Decl(awaitCallExpression7_es2017.ts, 5, 84)) + + var b = o.fn(a, await p, a); +>b : Symbol(b, Decl(awaitCallExpression7_es2017.ts, 10, 7)) +>o.fn : Symbol(fn, Decl(awaitCallExpression7_es2017.ts, 3, 16)) +>o : Symbol(o, Decl(awaitCallExpression7_es2017.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression7_es2017.ts, 3, 16)) +>a : Symbol(a, Decl(awaitCallExpression7_es2017.ts, 0, 11)) +>p : Symbol(p, Decl(awaitCallExpression7_es2017.ts, 1, 11)) +>a : Symbol(a, Decl(awaitCallExpression7_es2017.ts, 0, 11)) + + after(); +>after : Symbol(after, Decl(awaitCallExpression7_es2017.ts, 6, 32)) +} diff --git a/tests/baselines/reference/awaitCallExpression7_es2017.types b/tests/baselines/reference/awaitCallExpression7_es2017.types new file mode 100644 index 00000000000..aefe7916852 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression7_es2017.types @@ -0,0 +1,65 @@ +=== tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression7_es2017.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Promise<(arg0: boolean, arg1: boolean, arg2: boolean) => void> +>Promise : Promise +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }> +>Promise : Promise +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare function before(): void; +>before : () => void + +declare function after(): void; +>after : () => void + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + before(); +>before() : void +>before : () => void + + var b = o.fn(a, await p, a); +>b : void +>o.fn(a, await p, a) : void +>o.fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>a : boolean +>await p : boolean +>p : Promise +>a : boolean + + after(); +>after() : void +>after : () => void +} diff --git a/tests/baselines/reference/awaitCallExpression8_es2017.js b/tests/baselines/reference/awaitCallExpression8_es2017.js new file mode 100644 index 00000000000..7e04402e90a --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression8_es2017.js @@ -0,0 +1,21 @@ +//// [awaitCallExpression8_es2017.ts] +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = (await po).fn(a, a, a); + after(); +} + +//// [awaitCallExpression8_es2017.js] +async function func() { + before(); + var b = (await po).fn(a, a, a); + after(); +} diff --git a/tests/baselines/reference/awaitCallExpression8_es2017.symbols b/tests/baselines/reference/awaitCallExpression8_es2017.symbols new file mode 100644 index 00000000000..e3fd465c120 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression8_es2017.symbols @@ -0,0 +1,61 @@ +=== tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression8_es2017.ts === +declare var a: boolean; +>a : Symbol(a, Decl(awaitCallExpression8_es2017.ts, 0, 11)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitCallExpression8_es2017.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : Symbol(fn, Decl(awaitCallExpression8_es2017.ts, 1, 32)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression8_es2017.ts, 2, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression8_es2017.ts, 2, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression8_es2017.ts, 2, 49)) + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : Symbol(o, Decl(awaitCallExpression8_es2017.ts, 3, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression8_es2017.ts, 3, 16)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression8_es2017.ts, 3, 20)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression8_es2017.ts, 3, 34)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression8_es2017.ts, 3, 49)) + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Symbol(pfn, Decl(awaitCallExpression8_es2017.ts, 4, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression8_es2017.ts, 4, 28)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression8_es2017.ts, 4, 42)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression8_es2017.ts, 4, 57)) + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Symbol(po, Decl(awaitCallExpression8_es2017.ts, 5, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>fn : Symbol(fn, Decl(awaitCallExpression8_es2017.ts, 5, 25)) +>arg0 : Symbol(arg0, Decl(awaitCallExpression8_es2017.ts, 5, 29)) +>arg1 : Symbol(arg1, Decl(awaitCallExpression8_es2017.ts, 5, 43)) +>arg2 : Symbol(arg2, Decl(awaitCallExpression8_es2017.ts, 5, 58)) + +declare function before(): void; +>before : Symbol(before, Decl(awaitCallExpression8_es2017.ts, 5, 84)) + +declare function after(): void; +>after : Symbol(after, Decl(awaitCallExpression8_es2017.ts, 6, 32)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitCallExpression8_es2017.ts, 7, 31)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + before(); +>before : Symbol(before, Decl(awaitCallExpression8_es2017.ts, 5, 84)) + + var b = (await po).fn(a, a, a); +>b : Symbol(b, Decl(awaitCallExpression8_es2017.ts, 10, 7)) +>(await po).fn : Symbol(fn, Decl(awaitCallExpression8_es2017.ts, 5, 25)) +>po : Symbol(po, Decl(awaitCallExpression8_es2017.ts, 5, 11)) +>fn : Symbol(fn, Decl(awaitCallExpression8_es2017.ts, 5, 25)) +>a : Symbol(a, Decl(awaitCallExpression8_es2017.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression8_es2017.ts, 0, 11)) +>a : Symbol(a, Decl(awaitCallExpression8_es2017.ts, 0, 11)) + + after(); +>after : Symbol(after, Decl(awaitCallExpression8_es2017.ts, 6, 32)) +} diff --git a/tests/baselines/reference/awaitCallExpression8_es2017.types b/tests/baselines/reference/awaitCallExpression8_es2017.types new file mode 100644 index 00000000000..a9a115d39f2 --- /dev/null +++ b/tests/baselines/reference/awaitCallExpression8_es2017.types @@ -0,0 +1,66 @@ +=== tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression8_es2017.ts === +declare var a: boolean; +>a : boolean + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +>o : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>pfn : Promise<(arg0: boolean, arg1: boolean, arg2: boolean) => void> +>Promise : Promise +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +>po : Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }> +>Promise : Promise +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>arg0 : boolean +>arg1 : boolean +>arg2 : boolean + +declare function before(): void; +>before : () => void + +declare function after(): void; +>after : () => void + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + before(); +>before() : void +>before : () => void + + var b = (await po).fn(a, a, a); +>b : void +>(await po).fn(a, a, a) : void +>(await po).fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>(await po) : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>await po : { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; } +>po : Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }> +>fn : (arg0: boolean, arg1: boolean, arg2: boolean) => void +>a : boolean +>a : boolean +>a : boolean + + after(); +>after() : void +>after : () => void +} diff --git a/tests/baselines/reference/awaitClassExpression_es2017.js b/tests/baselines/reference/awaitClassExpression_es2017.js new file mode 100644 index 00000000000..d84f01f61cf --- /dev/null +++ b/tests/baselines/reference/awaitClassExpression_es2017.js @@ -0,0 +1,14 @@ +//// [awaitClassExpression_es2017.ts] +declare class C { } +declare var p: Promise; + +async function func(): Promise { + class D extends (await p) { + } +} + +//// [awaitClassExpression_es2017.js] +async function func() { + class D extends (await p) { + } +} diff --git a/tests/baselines/reference/awaitClassExpression_es2017.symbols b/tests/baselines/reference/awaitClassExpression_es2017.symbols new file mode 100644 index 00000000000..bebffa2bbad --- /dev/null +++ b/tests/baselines/reference/awaitClassExpression_es2017.symbols @@ -0,0 +1,18 @@ +=== tests/cases/conformance/async/es2017/awaitClassExpression_es2017.ts === +declare class C { } +>C : Symbol(C, Decl(awaitClassExpression_es2017.ts, 0, 0)) + +declare var p: Promise; +>p : Symbol(p, Decl(awaitClassExpression_es2017.ts, 1, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>C : Symbol(C, Decl(awaitClassExpression_es2017.ts, 0, 0)) + +async function func(): Promise { +>func : Symbol(func, Decl(awaitClassExpression_es2017.ts, 1, 33)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + class D extends (await p) { +>D : Symbol(D, Decl(awaitClassExpression_es2017.ts, 3, 38)) +>p : Symbol(p, Decl(awaitClassExpression_es2017.ts, 1, 11)) + } +} diff --git a/tests/baselines/reference/awaitClassExpression_es2017.types b/tests/baselines/reference/awaitClassExpression_es2017.types new file mode 100644 index 00000000000..39d17b1cc50 --- /dev/null +++ b/tests/baselines/reference/awaitClassExpression_es2017.types @@ -0,0 +1,20 @@ +=== tests/cases/conformance/async/es2017/awaitClassExpression_es2017.ts === +declare class C { } +>C : C + +declare var p: Promise; +>p : Promise +>Promise : Promise +>C : typeof C + +async function func(): Promise { +>func : () => Promise +>Promise : Promise + + class D extends (await p) { +>D : D +>(await p) : C +>await p : typeof C +>p : Promise + } +} diff --git a/tests/baselines/reference/awaitUnion_es2017.js b/tests/baselines/reference/awaitUnion_es2017.js new file mode 100644 index 00000000000..12f8b95a652 --- /dev/null +++ b/tests/baselines/reference/awaitUnion_es2017.js @@ -0,0 +1,22 @@ +//// [awaitUnion_es2017.ts] +declare let a: number | string; +declare let b: PromiseLike | PromiseLike; +declare let c: PromiseLike; +declare let d: number | PromiseLike; +declare let e: number | PromiseLike; +async function f() { + let await_a = await a; + let await_b = await b; + let await_c = await c; + let await_d = await d; + let await_e = await e; +} + +//// [awaitUnion_es2017.js] +async function f() { + let await_a = await a; + let await_b = await b; + let await_c = await c; + let await_d = await d; + let await_e = await e; +} diff --git a/tests/baselines/reference/awaitUnion_es2017.symbols b/tests/baselines/reference/awaitUnion_es2017.symbols new file mode 100644 index 00000000000..e70abce4f0b --- /dev/null +++ b/tests/baselines/reference/awaitUnion_es2017.symbols @@ -0,0 +1,44 @@ +=== tests/cases/conformance/async/es2017/awaitUnion_es2017.ts === +declare let a: number | string; +>a : Symbol(a, Decl(awaitUnion_es2017.ts, 0, 11)) + +declare let b: PromiseLike | PromiseLike; +>b : Symbol(b, Decl(awaitUnion_es2017.ts, 1, 11)) +>PromiseLike : Symbol(PromiseLike, Decl(lib.es5.d.ts, --, --)) +>PromiseLike : Symbol(PromiseLike, Decl(lib.es5.d.ts, --, --)) + +declare let c: PromiseLike; +>c : Symbol(c, Decl(awaitUnion_es2017.ts, 2, 11)) +>PromiseLike : Symbol(PromiseLike, Decl(lib.es5.d.ts, --, --)) + +declare let d: number | PromiseLike; +>d : Symbol(d, Decl(awaitUnion_es2017.ts, 3, 11)) +>PromiseLike : Symbol(PromiseLike, Decl(lib.es5.d.ts, --, --)) + +declare let e: number | PromiseLike; +>e : Symbol(e, Decl(awaitUnion_es2017.ts, 4, 11)) +>PromiseLike : Symbol(PromiseLike, Decl(lib.es5.d.ts, --, --)) + +async function f() { +>f : Symbol(f, Decl(awaitUnion_es2017.ts, 4, 53)) + + let await_a = await a; +>await_a : Symbol(await_a, Decl(awaitUnion_es2017.ts, 6, 4)) +>a : Symbol(a, Decl(awaitUnion_es2017.ts, 0, 11)) + + let await_b = await b; +>await_b : Symbol(await_b, Decl(awaitUnion_es2017.ts, 7, 4)) +>b : Symbol(b, Decl(awaitUnion_es2017.ts, 1, 11)) + + let await_c = await c; +>await_c : Symbol(await_c, Decl(awaitUnion_es2017.ts, 8, 4)) +>c : Symbol(c, Decl(awaitUnion_es2017.ts, 2, 11)) + + let await_d = await d; +>await_d : Symbol(await_d, Decl(awaitUnion_es2017.ts, 9, 4)) +>d : Symbol(d, Decl(awaitUnion_es2017.ts, 3, 11)) + + let await_e = await e; +>await_e : Symbol(await_e, Decl(awaitUnion_es2017.ts, 10, 4)) +>e : Symbol(e, Decl(awaitUnion_es2017.ts, 4, 11)) +} diff --git a/tests/baselines/reference/awaitUnion_es2017.types b/tests/baselines/reference/awaitUnion_es2017.types new file mode 100644 index 00000000000..58f8a4ec4b4 --- /dev/null +++ b/tests/baselines/reference/awaitUnion_es2017.types @@ -0,0 +1,49 @@ +=== tests/cases/conformance/async/es2017/awaitUnion_es2017.ts === +declare let a: number | string; +>a : string | number + +declare let b: PromiseLike | PromiseLike; +>b : PromiseLike | PromiseLike +>PromiseLike : PromiseLike +>PromiseLike : PromiseLike + +declare let c: PromiseLike; +>c : PromiseLike +>PromiseLike : PromiseLike + +declare let d: number | PromiseLike; +>d : number | PromiseLike +>PromiseLike : PromiseLike + +declare let e: number | PromiseLike; +>e : number | PromiseLike +>PromiseLike : PromiseLike + +async function f() { +>f : () => Promise + + let await_a = await a; +>await_a : string | number +>await a : string | number +>a : string | number + + let await_b = await b; +>await_b : string | number +>await b : string | number +>b : PromiseLike | PromiseLike + + let await_c = await c; +>await_c : string | number +>await c : string | number +>c : PromiseLike + + let await_d = await d; +>await_d : string | number +>await d : string | number +>d : number | PromiseLike + + let await_e = await e; +>await_e : string | number +>await e : string | number +>e : number | PromiseLike +} diff --git a/tests/baselines/reference/await_unaryExpression_es2017.js b/tests/baselines/reference/await_unaryExpression_es2017.js new file mode 100644 index 00000000000..83fce6588e6 --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es2017.js @@ -0,0 +1,31 @@ +//// [await_unaryExpression_es2017.ts] + +async function bar() { + !await 42; // OK +} + +async function bar1() { + +await 42; // OK +} + +async function bar3() { + -await 42; // OK +} + +async function bar4() { + ~await 42; // OK +} + +//// [await_unaryExpression_es2017.js] +async function bar() { + !await 42; // OK +} +async function bar1() { + +await 42; // OK +} +async function bar3() { + -await 42; // OK +} +async function bar4() { + ~await 42; // OK +} diff --git a/tests/baselines/reference/await_unaryExpression_es2017.symbols b/tests/baselines/reference/await_unaryExpression_es2017.symbols new file mode 100644 index 00000000000..1aa31031177 --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es2017.symbols @@ -0,0 +1,25 @@ +=== tests/cases/conformance/async/es2017/await_unaryExpression_es2017.ts === + +async function bar() { +>bar : Symbol(bar, Decl(await_unaryExpression_es2017.ts, 0, 0)) + + !await 42; // OK +} + +async function bar1() { +>bar1 : Symbol(bar1, Decl(await_unaryExpression_es2017.ts, 3, 1)) + + +await 42; // OK +} + +async function bar3() { +>bar3 : Symbol(bar3, Decl(await_unaryExpression_es2017.ts, 7, 1)) + + -await 42; // OK +} + +async function bar4() { +>bar4 : Symbol(bar4, Decl(await_unaryExpression_es2017.ts, 11, 1)) + + ~await 42; // OK +} diff --git a/tests/baselines/reference/await_unaryExpression_es2017.types b/tests/baselines/reference/await_unaryExpression_es2017.types new file mode 100644 index 00000000000..4f4254df318 --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es2017.types @@ -0,0 +1,37 @@ +=== tests/cases/conformance/async/es2017/await_unaryExpression_es2017.ts === + +async function bar() { +>bar : () => Promise + + !await 42; // OK +>!await 42 : boolean +>await 42 : 42 +>42 : 42 +} + +async function bar1() { +>bar1 : () => Promise + + +await 42; // OK +>+await 42 : number +>await 42 : 42 +>42 : 42 +} + +async function bar3() { +>bar3 : () => Promise + + -await 42; // OK +>-await 42 : number +>await 42 : 42 +>42 : 42 +} + +async function bar4() { +>bar4 : () => Promise + + ~await 42; // OK +>~await 42 : number +>await 42 : 42 +>42 : 42 +} diff --git a/tests/baselines/reference/await_unaryExpression_es2017_1.js b/tests/baselines/reference/await_unaryExpression_es2017_1.js new file mode 100644 index 00000000000..f863fb19a7e --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es2017_1.js @@ -0,0 +1,38 @@ +//// [await_unaryExpression_es2017_1.ts] + +async function bar() { + !await 42; // OK +} + +async function bar1() { + delete await 42; // OK +} + +async function bar2() { + delete await 42; // OK +} + +async function bar3() { + void await 42; +} + +async function bar4() { + +await 42; +} + +//// [await_unaryExpression_es2017_1.js] +async function bar() { + !await 42; // OK +} +async function bar1() { + delete await 42; // OK +} +async function bar2() { + delete await 42; // OK +} +async function bar3() { + void await 42; +} +async function bar4() { + +await 42; +} diff --git a/tests/baselines/reference/await_unaryExpression_es2017_1.symbols b/tests/baselines/reference/await_unaryExpression_es2017_1.symbols new file mode 100644 index 00000000000..81bb31a7efd --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es2017_1.symbols @@ -0,0 +1,31 @@ +=== tests/cases/conformance/async/es2017/await_unaryExpression_es2017_1.ts === + +async function bar() { +>bar : Symbol(bar, Decl(await_unaryExpression_es2017_1.ts, 0, 0)) + + !await 42; // OK +} + +async function bar1() { +>bar1 : Symbol(bar1, Decl(await_unaryExpression_es2017_1.ts, 3, 1)) + + delete await 42; // OK +} + +async function bar2() { +>bar2 : Symbol(bar2, Decl(await_unaryExpression_es2017_1.ts, 7, 1)) + + delete await 42; // OK +} + +async function bar3() { +>bar3 : Symbol(bar3, Decl(await_unaryExpression_es2017_1.ts, 11, 1)) + + void await 42; +} + +async function bar4() { +>bar4 : Symbol(bar4, Decl(await_unaryExpression_es2017_1.ts, 15, 1)) + + +await 42; +} diff --git a/tests/baselines/reference/await_unaryExpression_es2017_1.types b/tests/baselines/reference/await_unaryExpression_es2017_1.types new file mode 100644 index 00000000000..7afa4fe9001 --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es2017_1.types @@ -0,0 +1,46 @@ +=== tests/cases/conformance/async/es2017/await_unaryExpression_es2017_1.ts === + +async function bar() { +>bar : () => Promise + + !await 42; // OK +>!await 42 : boolean +>await 42 : 42 +>42 : 42 +} + +async function bar1() { +>bar1 : () => Promise + + delete await 42; // OK +>delete await 42 : boolean +>await 42 : 42 +>42 : 42 +} + +async function bar2() { +>bar2 : () => Promise + + delete await 42; // OK +>delete await 42 : boolean +>await 42 : 42 +>42 : 42 +} + +async function bar3() { +>bar3 : () => Promise + + void await 42; +>void await 42 : undefined +>await 42 : 42 +>42 : 42 +} + +async function bar4() { +>bar4 : () => Promise + + +await 42; +>+await 42 : number +>await 42 : 42 +>42 : 42 +} diff --git a/tests/baselines/reference/await_unaryExpression_es2017_2.js b/tests/baselines/reference/await_unaryExpression_es2017_2.js new file mode 100644 index 00000000000..b982b20245c --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es2017_2.js @@ -0,0 +1,24 @@ +//// [await_unaryExpression_es2017_2.ts] + +async function bar1() { + delete await 42; +} + +async function bar2() { + delete await 42; +} + +async function bar3() { + void await 42; +} + +//// [await_unaryExpression_es2017_2.js] +async function bar1() { + delete await 42; +} +async function bar2() { + delete await 42; +} +async function bar3() { + void await 42; +} diff --git a/tests/baselines/reference/await_unaryExpression_es2017_2.symbols b/tests/baselines/reference/await_unaryExpression_es2017_2.symbols new file mode 100644 index 00000000000..d4b8a7493d9 --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es2017_2.symbols @@ -0,0 +1,19 @@ +=== tests/cases/conformance/async/es2017/await_unaryExpression_es2017_2.ts === + +async function bar1() { +>bar1 : Symbol(bar1, Decl(await_unaryExpression_es2017_2.ts, 0, 0)) + + delete await 42; +} + +async function bar2() { +>bar2 : Symbol(bar2, Decl(await_unaryExpression_es2017_2.ts, 3, 1)) + + delete await 42; +} + +async function bar3() { +>bar3 : Symbol(bar3, Decl(await_unaryExpression_es2017_2.ts, 7, 1)) + + void await 42; +} diff --git a/tests/baselines/reference/await_unaryExpression_es2017_2.types b/tests/baselines/reference/await_unaryExpression_es2017_2.types new file mode 100644 index 00000000000..acaa76d2d67 --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es2017_2.types @@ -0,0 +1,28 @@ +=== tests/cases/conformance/async/es2017/await_unaryExpression_es2017_2.ts === + +async function bar1() { +>bar1 : () => Promise + + delete await 42; +>delete await 42 : boolean +>await 42 : 42 +>42 : 42 +} + +async function bar2() { +>bar2 : () => Promise + + delete await 42; +>delete await 42 : boolean +>await 42 : 42 +>42 : 42 +} + +async function bar3() { +>bar3 : () => Promise + + void await 42; +>void await 42 : undefined +>await 42 : 42 +>42 : 42 +} diff --git a/tests/baselines/reference/await_unaryExpression_es2017_3.errors.txt b/tests/baselines/reference/await_unaryExpression_es2017_3.errors.txt new file mode 100644 index 00000000000..5d11c4bbb20 --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es2017_3.errors.txt @@ -0,0 +1,27 @@ +tests/cases/conformance/async/es2017/await_unaryExpression_es2017_3.ts(3,7): error TS1109: Expression expected. +tests/cases/conformance/async/es2017/await_unaryExpression_es2017_3.ts(7,7): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es2017/await_unaryExpression_es2017_3.ts (2 errors) ==== + + async function bar1() { + ++await 42; // Error + ~~~~~ +!!! error TS1109: Expression expected. + } + + async function bar2() { + --await 42; // Error + ~~~~~ +!!! error TS1109: Expression expected. + } + + async function bar3() { + var x = 42; + await x++; // OK but shouldn't need parenthesis + } + + async function bar4() { + var x = 42; + await x--; // OK but shouldn't need parenthesis + } \ No newline at end of file diff --git a/tests/baselines/reference/await_unaryExpression_es2017_3.js b/tests/baselines/reference/await_unaryExpression_es2017_3.js new file mode 100644 index 00000000000..5e3c3c3a4bf --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es2017_3.js @@ -0,0 +1,37 @@ +//// [await_unaryExpression_es2017_3.ts] + +async function bar1() { + ++await 42; // Error +} + +async function bar2() { + --await 42; // Error +} + +async function bar3() { + var x = 42; + await x++; // OK but shouldn't need parenthesis +} + +async function bar4() { + var x = 42; + await x--; // OK but shouldn't need parenthesis +} + +//// [await_unaryExpression_es2017_3.js] +async function bar1() { + ++; + await 42; // Error +} +async function bar2() { + --; + await 42; // Error +} +async function bar3() { + var x = 42; + await x++; // OK but shouldn't need parenthesis +} +async function bar4() { + var x = 42; + await x--; // OK but shouldn't need parenthesis +} diff --git a/tests/baselines/reference/es2017basicAsync.js b/tests/baselines/reference/es2017basicAsync.js index da219f4614c..b19eaa4b0ba 100644 --- a/tests/baselines/reference/es2017basicAsync.js +++ b/tests/baselines/reference/es2017basicAsync.js @@ -1,4 +1,4 @@ -//// [es2017-async.ts] +//// [es2017basicAsync.ts] async (): Promise => { await 0; @@ -47,7 +47,7 @@ class AsyncClass { } -//// [es2017-async.js] +//// [es2017basicAsync.js] async () => { await 0; }; diff --git a/tests/baselines/reference/es2017basicAsync.symbols b/tests/baselines/reference/es2017basicAsync.symbols index be3b2e723f4..75f4d2cfa76 100644 --- a/tests/baselines/reference/es2017basicAsync.symbols +++ b/tests/baselines/reference/es2017basicAsync.symbols @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es2017-async.ts === +=== tests/cases/compiler/es2017basicAsync.ts === async (): Promise => { >Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) @@ -7,20 +7,20 @@ async (): Promise => { } async function asyncFunc() { ->asyncFunc : Symbol(asyncFunc, Decl(es2017-async.ts, 3, 1)) +>asyncFunc : Symbol(asyncFunc, Decl(es2017basicAsync.ts, 3, 1)) await 0; } const asycnArrowFunc = async (): Promise => { ->asycnArrowFunc : Symbol(asycnArrowFunc, Decl(es2017-async.ts, 9, 5)) +>asycnArrowFunc : Symbol(asycnArrowFunc, Decl(es2017basicAsync.ts, 9, 5)) >Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) await 0; } async function asyncIIFE() { ->asyncIIFE : Symbol(asyncIIFE, Decl(es2017-async.ts, 11, 1)) +>asyncIIFE : Symbol(asyncIIFE, Decl(es2017basicAsync.ts, 11, 1)) await 0; @@ -31,7 +31,7 @@ async function asyncIIFE() { })(); await (async function asyncNamedFunc(): Promise { ->asyncNamedFunc : Symbol(asyncNamedFunc, Decl(es2017-async.ts, 20, 11)) +>asyncNamedFunc : Symbol(asyncNamedFunc, Decl(es2017basicAsync.ts, 20, 11)) >Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) await 1; @@ -45,32 +45,32 @@ async function asyncIIFE() { } class AsyncClass { ->AsyncClass : Symbol(AsyncClass, Decl(es2017-async.ts, 27, 1)) +>AsyncClass : Symbol(AsyncClass, Decl(es2017basicAsync.ts, 27, 1)) asyncPropFunc = async function(): Promise { ->asyncPropFunc : Symbol(AsyncClass.asyncPropFunc, Decl(es2017-async.ts, 29, 18)) +>asyncPropFunc : Symbol(AsyncClass.asyncPropFunc, Decl(es2017basicAsync.ts, 29, 18)) >Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) await 2; } asyncPropNamedFunc = async function namedFunc(): Promise { ->asyncPropNamedFunc : Symbol(AsyncClass.asyncPropNamedFunc, Decl(es2017-async.ts, 32, 5)) ->namedFunc : Symbol(namedFunc, Decl(es2017-async.ts, 34, 24)) +>asyncPropNamedFunc : Symbol(AsyncClass.asyncPropNamedFunc, Decl(es2017basicAsync.ts, 32, 5)) +>namedFunc : Symbol(namedFunc, Decl(es2017basicAsync.ts, 34, 24)) >Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) await 2; } asyncPropArrowFunc = async (): Promise => { ->asyncPropArrowFunc : Symbol(AsyncClass.asyncPropArrowFunc, Decl(es2017-async.ts, 36, 5)) +>asyncPropArrowFunc : Symbol(AsyncClass.asyncPropArrowFunc, Decl(es2017basicAsync.ts, 36, 5)) >Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) await 2; } async asyncMethod(): Promise { ->asyncMethod : Symbol(AsyncClass.asyncMethod, Decl(es2017-async.ts, 40, 5)) +>asyncMethod : Symbol(AsyncClass.asyncMethod, Decl(es2017basicAsync.ts, 40, 5)) >Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) await 2; diff --git a/tests/baselines/reference/es2017basicAsync.types b/tests/baselines/reference/es2017basicAsync.types index 79f3a005e6e..71c2dbe50f3 100644 --- a/tests/baselines/reference/es2017basicAsync.types +++ b/tests/baselines/reference/es2017basicAsync.types @@ -1,4 +1,4 @@ -=== tests/cases/compiler/es2017-async.ts === +=== tests/cases/compiler/es2017basicAsync.ts === async (): Promise => { >async (): Promise => { await 0;} : () => Promise diff --git a/tests/cases/conformance/async/es2017/asyncAliasReturnType_es2017.ts b/tests/cases/conformance/async/es2017/asyncAliasReturnType_es2017.ts new file mode 100644 index 00000000000..87bbc42e166 --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncAliasReturnType_es2017.ts @@ -0,0 +1,6 @@ +// @target: es2017 +// @noEmitHelpers: true +type PromiseAlias = Promise; + +async function f(): PromiseAlias { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncArrowFunction/arrowFunctionWithParameterNameAsync_es2017.ts b/tests/cases/conformance/async/es2017/asyncArrowFunction/arrowFunctionWithParameterNameAsync_es2017.ts new file mode 100644 index 00000000000..1ade02c09d2 --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncArrowFunction/arrowFunctionWithParameterNameAsync_es2017.ts @@ -0,0 +1,4 @@ +// @target: ES5 +// @noEmitHelpers: true + +const x = async => async; \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction10_es2017.ts b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction10_es2017.ts new file mode 100644 index 00000000000..09d97cc253b --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction10_es2017.ts @@ -0,0 +1,7 @@ +// @target: es2017 +// @noEmitHelpers: true + +var foo = async (): Promise => { + // Legal to use 'await' in a type context. + var v: await; +} diff --git a/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction1_es2017.ts b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction1_es2017.ts new file mode 100644 index 00000000000..0f9ec479a31 --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction1_es2017.ts @@ -0,0 +1,5 @@ +// @target: es2017 +// @noEmitHelpers: true + +var foo = async (): Promise => { +}; \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction2_es2017.ts b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction2_es2017.ts new file mode 100644 index 00000000000..b11441372ff --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction2_es2017.ts @@ -0,0 +1,4 @@ +// @target: es2017 +// @noEmitHelpers: true +var f = (await) => { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction3_es2017.ts b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction3_es2017.ts new file mode 100644 index 00000000000..9b5924fc145 --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction3_es2017.ts @@ -0,0 +1,4 @@ +// @target: es2017 +// @noEmitHelpers: true +function f(await = await) { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction4_es2017.ts b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction4_es2017.ts new file mode 100644 index 00000000000..5a988277836 --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction4_es2017.ts @@ -0,0 +1,4 @@ +// @target: es2017 +// @noEmitHelpers: true +var await = () => { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts new file mode 100644 index 00000000000..aabe5a99372 --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts @@ -0,0 +1,5 @@ +// @target: es2017 +// @noEmitHelpers: true + +var foo = async (await): Promise => { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction6_es2017.ts b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction6_es2017.ts new file mode 100644 index 00000000000..d82ce864421 --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction6_es2017.ts @@ -0,0 +1,5 @@ +// @target: es2017 +// @noEmitHelpers: true + +var foo = async (a = await): Promise => { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction7_es2017.ts b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction7_es2017.ts new file mode 100644 index 00000000000..bc49c5995e6 --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction7_es2017.ts @@ -0,0 +1,8 @@ +// @target: es2017 +// @noEmitHelpers: true + +var bar = async (): Promise => { + // 'await' here is an identifier, and not an await expression. + var foo = async (a = await): Promise => { + } +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction8_es2017.ts b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction8_es2017.ts new file mode 100644 index 00000000000..387b09c791a --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction8_es2017.ts @@ -0,0 +1,6 @@ +// @target: es2017 +// @noEmitHelpers: true + +var foo = async (): Promise => { + var v = { [await]: foo } +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts new file mode 100644 index 00000000000..93254fee5c7 --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts @@ -0,0 +1,4 @@ +// @target: es2017 +// @noEmitHelpers: true +var foo = async (a = await => await): Promise => { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunctionCapturesArguments_es2017.ts b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunctionCapturesArguments_es2017.ts new file mode 100644 index 00000000000..c71c6ddecb0 --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunctionCapturesArguments_es2017.ts @@ -0,0 +1,8 @@ +// @target: es2017 +// @noEmitHelpers: true +class C { + method() { + function other() {} + var fn = async () => await other.apply(this, arguments); + } +} diff --git a/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunctionCapturesThis_es2017.ts b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunctionCapturesThis_es2017.ts new file mode 100644 index 00000000000..3f398d9be82 --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunctionCapturesThis_es2017.ts @@ -0,0 +1,7 @@ +// @target: es2017 +// @noEmitHelpers: true +class C { + method() { + var fn = async () => await this; + } +} diff --git a/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncUnParenthesizedArrowFunction_es2017.ts b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncUnParenthesizedArrowFunction_es2017.ts new file mode 100644 index 00000000000..9b63b7bd468 --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncArrowFunction/asyncUnParenthesizedArrowFunction_es2017.ts @@ -0,0 +1,6 @@ +// @target: es2017 +// @noEmitHelpers: true + +declare function someOtherFunction(i: any): Promise; +const x = async i => await someOtherFunction(i) +const x1 = async (i) => await someOtherFunction(i); \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncAwaitIsolatedModules_es2017.ts b/tests/cases/conformance/async/es2017/asyncAwaitIsolatedModules_es2017.ts new file mode 100644 index 00000000000..c0ab4838f70 --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncAwaitIsolatedModules_es2017.ts @@ -0,0 +1,41 @@ +// @target: es2017 +// @isolatedModules: true +import { MyPromise } from "missing"; + +declare var p: Promise; +declare var mp: MyPromise; + +async function f0() { } +async function f1(): Promise { } +async function f3(): MyPromise { } + +let f4 = async function() { } +let f5 = async function(): Promise { } +let f6 = async function(): MyPromise { } + +let f7 = async () => { }; +let f8 = async (): Promise => { }; +let f9 = async (): MyPromise => { }; +let f10 = async () => p; +let f11 = async () => mp; +let f12 = async (): Promise => mp; +let f13 = async (): MyPromise => p; + +let o = { + async m1() { }, + async m2(): Promise { }, + async m3(): MyPromise { } +}; + +class C { + async m1() { } + async m2(): Promise { } + async m3(): MyPromise { } + static async m4() { } + static async m5(): Promise { } + static async m6(): MyPromise { } +} + +module M { + export async function f1() { } +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncAwait_es2017.ts b/tests/cases/conformance/async/es2017/asyncAwait_es2017.ts new file mode 100644 index 00000000000..a255cb7cb71 --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncAwait_es2017.ts @@ -0,0 +1,40 @@ +// @target: es2017 +type MyPromise = Promise; +declare var MyPromise: typeof Promise; +declare var p: Promise; +declare var mp: MyPromise; + +async function f0() { } +async function f1(): Promise { } +async function f3(): MyPromise { } + +let f4 = async function() { } +let f5 = async function(): Promise { } +let f6 = async function(): MyPromise { } + +let f7 = async () => { }; +let f8 = async (): Promise => { }; +let f9 = async (): MyPromise => { }; +let f10 = async () => p; +let f11 = async () => mp; +let f12 = async (): Promise => mp; +let f13 = async (): MyPromise => p; + +let o = { + async m1() { }, + async m2(): Promise { }, + async m3(): MyPromise { } +}; + +class C { + async m1() { } + async m2(): Promise { } + async m3(): MyPromise { } + static async m4() { } + static async m5(): Promise { } + static async m6(): MyPromise { } +} + +module M { + export async function f1() { } +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncClass_es2017.ts b/tests/cases/conformance/async/es2017/asyncClass_es2017.ts new file mode 100644 index 00000000000..78746c972d0 --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncClass_es2017.ts @@ -0,0 +1,4 @@ +// @target: es2017 +// @noEmitHelpers: true +async class C { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncConstructor_es2017.ts b/tests/cases/conformance/async/es2017/asyncConstructor_es2017.ts new file mode 100644 index 00000000000..874c0b99239 --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncConstructor_es2017.ts @@ -0,0 +1,6 @@ +// @target: es2017 +// @noEmitHelpers: true +class C { + async constructor() { + } +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncDeclare_es2017.ts b/tests/cases/conformance/async/es2017/asyncDeclare_es2017.ts new file mode 100644 index 00000000000..d7fd4888fed --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncDeclare_es2017.ts @@ -0,0 +1,3 @@ +// @target: es2017 +// @noEmitHelpers: true +declare async function foo(): Promise; \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncEnum_es2017.ts b/tests/cases/conformance/async/es2017/asyncEnum_es2017.ts new file mode 100644 index 00000000000..dc995206e84 --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncEnum_es2017.ts @@ -0,0 +1,5 @@ +// @target: es2017 +// @noEmitHelpers: true +async enum E { + Value +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncGetter_es2017.ts b/tests/cases/conformance/async/es2017/asyncGetter_es2017.ts new file mode 100644 index 00000000000..340c33138cf --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncGetter_es2017.ts @@ -0,0 +1,6 @@ +// @target: es2017 +// @noEmitHelpers: true +class C { + async get foo() { + } +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncImportedPromise_es2017.ts b/tests/cases/conformance/async/es2017/asyncImportedPromise_es2017.ts new file mode 100644 index 00000000000..81f5b690edd --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncImportedPromise_es2017.ts @@ -0,0 +1,10 @@ +// @target: es2017 +// @module: commonjs +// @filename: task.ts +export class Task extends Promise { } + +// @filename: test.ts +import { Task } from "./task"; +class Test { + async example(): Task { return; } +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncInterface_es2017.ts b/tests/cases/conformance/async/es2017/asyncInterface_es2017.ts new file mode 100644 index 00000000000..252730f9ff6 --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncInterface_es2017.ts @@ -0,0 +1,4 @@ +// @target: es2017 +// @noEmitHelpers: true +async interface I { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncMethodWithSuper_es2017.ts b/tests/cases/conformance/async/es2017/asyncMethodWithSuper_es2017.ts new file mode 100644 index 00000000000..b9005c48596 --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncMethodWithSuper_es2017.ts @@ -0,0 +1,52 @@ +// @target: es2017 +// @noEmitHelpers: true +class A { + x() { + } +} + +class B extends A { + // async method with only call/get on 'super' does not require a binding + async simple() { + // call with property access + super.x(); + + // call with element access + super["x"](); + + // property access (read) + const a = super.x; + + // element access (read) + const b = super["x"]; + } + + // async method with assignment/destructuring on 'super' requires a binding + async advanced() { + const f = () => {}; + + // call with property access + super.x(); + + // call with element access + super["x"](); + + // property access (read) + const a = super.x; + + // element access (read) + const b = super["x"]; + + // property access (assign) + super.x = f; + + // element access (assign) + super["x"] = f; + + // destructuring assign with property access + ({ f: super.x } = { f }); + + // destructuring assign with element access + ({ f: super["x"] } = { f }); + } +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncModule_es2017.ts b/tests/cases/conformance/async/es2017/asyncModule_es2017.ts new file mode 100644 index 00000000000..7c577e27fb9 --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncModule_es2017.ts @@ -0,0 +1,4 @@ +// @target: es2017 +// @noEmitHelpers: true +async module M { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncMultiFile_es2017.ts b/tests/cases/conformance/async/es2017/asyncMultiFile_es2017.ts new file mode 100644 index 00000000000..920bdfb8bda --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncMultiFile_es2017.ts @@ -0,0 +1,5 @@ +// @target: es2017 +// @filename: a.ts +async function f() {} +// @filename: b.ts +function g() { } \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncQualifiedReturnType_es2017.ts b/tests/cases/conformance/async/es2017/asyncQualifiedReturnType_es2017.ts new file mode 100644 index 00000000000..95695168cea --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncQualifiedReturnType_es2017.ts @@ -0,0 +1,9 @@ +// @target: es2017 +// @noEmitHelpers: true +namespace X { + export class MyPromise extends Promise { + } +} + +async function f(): X.MyPromise { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncSetter_es2017.ts b/tests/cases/conformance/async/es2017/asyncSetter_es2017.ts new file mode 100644 index 00000000000..658c07d42e8 --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncSetter_es2017.ts @@ -0,0 +1,6 @@ +// @target: es2017 +// @noEmitHelpers: true +class C { + async set foo(value) { + } +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncUseStrict_es2017.ts b/tests/cases/conformance/async/es2017/asyncUseStrict_es2017.ts new file mode 100644 index 00000000000..c4d4cafef8a --- /dev/null +++ b/tests/cases/conformance/async/es2017/asyncUseStrict_es2017.ts @@ -0,0 +1,8 @@ +// @target: es2017 +// @noEmitHelpers: true +declare var a: boolean; +declare var p: Promise; +async function func(): Promise { + "use strict"; + var b = await p || a; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression1_es2017.ts b/tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression1_es2017.ts new file mode 100644 index 00000000000..ef9076a8bee --- /dev/null +++ b/tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression1_es2017.ts @@ -0,0 +1,11 @@ +// @target: es2017 +// @noEmitHelpers: true +declare var a: boolean; +declare var p: Promise; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = await p || a; + after(); +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression2_es2017.ts b/tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression2_es2017.ts new file mode 100644 index 00000000000..84d2f622292 --- /dev/null +++ b/tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression2_es2017.ts @@ -0,0 +1,11 @@ +// @target: es2017 +// @noEmitHelpers: true +declare var a: boolean; +declare var p: Promise; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = await p && a; + after(); +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression3_es2017.ts b/tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression3_es2017.ts new file mode 100644 index 00000000000..1f3a8245d42 --- /dev/null +++ b/tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression3_es2017.ts @@ -0,0 +1,11 @@ +// @target: es2017 +// @noEmitHelpers: true +declare var a: number; +declare var p: Promise; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = await p + a; + after(); +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression4_es2017.ts b/tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression4_es2017.ts new file mode 100644 index 00000000000..6c36f1e4ce5 --- /dev/null +++ b/tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression4_es2017.ts @@ -0,0 +1,11 @@ +// @target: es2017 +// @noEmitHelpers: true +declare var a: boolean; +declare var p: Promise; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = (await p, a); + after(); +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression5_es2017.ts b/tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression5_es2017.ts new file mode 100644 index 00000000000..abbcbb95ba9 --- /dev/null +++ b/tests/cases/conformance/async/es2017/awaitBinaryExpression/awaitBinaryExpression5_es2017.ts @@ -0,0 +1,12 @@ +// @target: es2017 +// @noEmitHelpers: true +declare var a: boolean; +declare var p: Promise; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var o: { a: boolean; }; + o.a = await p; + after(); +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression1_es2017.ts b/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression1_es2017.ts new file mode 100644 index 00000000000..da46e04ed1e --- /dev/null +++ b/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression1_es2017.ts @@ -0,0 +1,15 @@ +// @target: es2017 +// @noEmitHelpers: true +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = fn(a, a, a); + after(); +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression2_es2017.ts b/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression2_es2017.ts new file mode 100644 index 00000000000..baf75ab95c3 --- /dev/null +++ b/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression2_es2017.ts @@ -0,0 +1,15 @@ +// @target: es2017 +// @noEmitHelpers: true +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = fn(await p, a, a); + after(); +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression3_es2017.ts b/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression3_es2017.ts new file mode 100644 index 00000000000..17cf6d8c6c9 --- /dev/null +++ b/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression3_es2017.ts @@ -0,0 +1,15 @@ +// @target: es2017 +// @noEmitHelpers: true +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = fn(a, await p, a); + after(); +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression4_es2017.ts b/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression4_es2017.ts new file mode 100644 index 00000000000..ef5e1d203d9 --- /dev/null +++ b/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression4_es2017.ts @@ -0,0 +1,15 @@ +// @target: es2017 +// @noEmitHelpers: true +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = (await pfn)(a, a, a); + after(); +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression5_es2017.ts b/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression5_es2017.ts new file mode 100644 index 00000000000..8494bc11b4c --- /dev/null +++ b/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression5_es2017.ts @@ -0,0 +1,15 @@ +// @target: es2017 +// @noEmitHelpers: true +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = o.fn(a, a, a); + after(); +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression6_es2017.ts b/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression6_es2017.ts new file mode 100644 index 00000000000..7939572baea --- /dev/null +++ b/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression6_es2017.ts @@ -0,0 +1,15 @@ +// @target: es2017 +// @noEmitHelpers: true +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = o.fn(await p, a, a); + after(); +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression7_es2017.ts b/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression7_es2017.ts new file mode 100644 index 00000000000..3f1231a50d6 --- /dev/null +++ b/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression7_es2017.ts @@ -0,0 +1,15 @@ +// @target: es2017 +// @noEmitHelpers: true +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = o.fn(a, await p, a); + after(); +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression8_es2017.ts b/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression8_es2017.ts new file mode 100644 index 00000000000..c669122bada --- /dev/null +++ b/tests/cases/conformance/async/es2017/awaitCallExpression/awaitCallExpression8_es2017.ts @@ -0,0 +1,15 @@ +// @target: es2017 +// @noEmitHelpers: true +declare var a: boolean; +declare var p: Promise; +declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void; +declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }; +declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>; +declare function before(): void; +declare function after(): void; +async function func(): Promise { + before(); + var b = (await po).fn(a, a, a); + after(); +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/awaitClassExpression_es2017.ts b/tests/cases/conformance/async/es2017/awaitClassExpression_es2017.ts new file mode 100644 index 00000000000..fe34d53a03c --- /dev/null +++ b/tests/cases/conformance/async/es2017/awaitClassExpression_es2017.ts @@ -0,0 +1,9 @@ +// @target: es2017 +// @noEmitHelpers: true +declare class C { } +declare var p: Promise; + +async function func(): Promise { + class D extends (await p) { + } +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/awaitUnion_es2017.ts b/tests/cases/conformance/async/es2017/awaitUnion_es2017.ts new file mode 100644 index 00000000000..493aa838ffe --- /dev/null +++ b/tests/cases/conformance/async/es2017/awaitUnion_es2017.ts @@ -0,0 +1,14 @@ +// @target: es2017 +// @noEmitHelpers: true +declare let a: number | string; +declare let b: PromiseLike | PromiseLike; +declare let c: PromiseLike; +declare let d: number | PromiseLike; +declare let e: number | PromiseLike; +async function f() { + let await_a = await a; + let await_b = await b; + let await_c = await c; + let await_d = await d; + let await_e = await e; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/await_unaryExpression_es2017.ts b/tests/cases/conformance/async/es2017/await_unaryExpression_es2017.ts new file mode 100644 index 00000000000..dee2554653d --- /dev/null +++ b/tests/cases/conformance/async/es2017/await_unaryExpression_es2017.ts @@ -0,0 +1,17 @@ +// @target: es2017 + +async function bar() { + !await 42; // OK +} + +async function bar1() { + +await 42; // OK +} + +async function bar3() { + -await 42; // OK +} + +async function bar4() { + ~await 42; // OK +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/await_unaryExpression_es2017_1.ts b/tests/cases/conformance/async/es2017/await_unaryExpression_es2017_1.ts new file mode 100644 index 00000000000..f38260b332d --- /dev/null +++ b/tests/cases/conformance/async/es2017/await_unaryExpression_es2017_1.ts @@ -0,0 +1,21 @@ +// @target: es2017 + +async function bar() { + !await 42; // OK +} + +async function bar1() { + delete await 42; // OK +} + +async function bar2() { + delete await 42; // OK +} + +async function bar3() { + void await 42; +} + +async function bar4() { + +await 42; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/await_unaryExpression_es2017_2.ts b/tests/cases/conformance/async/es2017/await_unaryExpression_es2017_2.ts new file mode 100644 index 00000000000..b48c661f0b9 --- /dev/null +++ b/tests/cases/conformance/async/es2017/await_unaryExpression_es2017_2.ts @@ -0,0 +1,13 @@ +// @target: es2017 + +async function bar1() { + delete await 42; +} + +async function bar2() { + delete await 42; +} + +async function bar3() { + void await 42; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/await_unaryExpression_es2017_3.ts b/tests/cases/conformance/async/es2017/await_unaryExpression_es2017_3.ts new file mode 100644 index 00000000000..d2c608d0e7b --- /dev/null +++ b/tests/cases/conformance/async/es2017/await_unaryExpression_es2017_3.ts @@ -0,0 +1,19 @@ +// @target: es2017 + +async function bar1() { + ++await 42; // Error +} + +async function bar2() { + --await 42; // Error +} + +async function bar3() { + var x = 42; + await x++; // OK but shouldn't need parenthesis +} + +async function bar4() { + var x = 42; + await x--; // OK but shouldn't need parenthesis +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts new file mode 100644 index 00000000000..9b744713945 --- /dev/null +++ b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts @@ -0,0 +1,4 @@ +// @target: es2017 +// @noEmitHelpers: true +async function foo(a = await => await): Promise { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration11_es2017.ts b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration11_es2017.ts new file mode 100644 index 00000000000..9613e866163 --- /dev/null +++ b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration11_es2017.ts @@ -0,0 +1,4 @@ +// @target: es2017 +// @noEmitHelpers: true +async function await(): Promise { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration12_es2017.ts b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration12_es2017.ts new file mode 100644 index 00000000000..02b6e833c2c --- /dev/null +++ b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration12_es2017.ts @@ -0,0 +1,3 @@ +// @target: es2017 +// @noEmitHelpers: true +var v = async function await(): Promise { } \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration13_es2017.ts b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration13_es2017.ts new file mode 100644 index 00000000000..40177c1fbcb --- /dev/null +++ b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration13_es2017.ts @@ -0,0 +1,6 @@ +// @target: es2017 +// @noEmitHelpers: true +async function foo(): Promise { + // Legal to use 'await' in a type context. + var v: await; +} diff --git a/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration14_es2017.ts b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration14_es2017.ts new file mode 100644 index 00000000000..06bd2de3eef --- /dev/null +++ b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration14_es2017.ts @@ -0,0 +1,5 @@ +// @target: es2017 +// @noEmitHelpers: true +async function foo(): Promise { + return; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts new file mode 100644 index 00000000000..2585dc666f4 --- /dev/null +++ b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts @@ -0,0 +1,25 @@ +// @target: es2017 +// @noEmitHelpers: true +declare class Thenable { then(): void; } +declare let a: any; +declare let obj: { then: string; }; +declare let thenable: Thenable; +async function fn1() { } // valid: Promise +async function fn2(): { } { } // error +async function fn3(): any { } // error +async function fn4(): number { } // error +async function fn5(): PromiseLike { } // error +async function fn6(): Thenable { } // error +async function fn7() { return; } // valid: Promise +async function fn8() { return 1; } // valid: Promise +async function fn9() { return null; } // valid: Promise +async function fn10() { return undefined; } // valid: Promise +async function fn11() { return a; } // valid: Promise +async function fn12() { return obj; } // valid: Promise<{ then: string; }> +async function fn13() { return thenable; } // error +async function fn14() { await 1; } // valid: Promise +async function fn15() { await null; } // valid: Promise +async function fn16() { await undefined; } // valid: Promise +async function fn17() { await a; } // valid: Promise +async function fn18() { await obj; } // valid: Promise +async function fn19() { await thenable; } // error diff --git a/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration1_es2017.ts b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration1_es2017.ts new file mode 100644 index 00000000000..178611ad91b --- /dev/null +++ b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration1_es2017.ts @@ -0,0 +1,4 @@ +// @target: es2017 +// @noEmitHelpers: true +async function foo(): Promise { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration2_es2017.ts b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration2_es2017.ts new file mode 100644 index 00000000000..08711a4cfbd --- /dev/null +++ b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration2_es2017.ts @@ -0,0 +1,4 @@ +// @target: es2017 +// @noEmitHelpers: true +function f(await) { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration3_es2017.ts b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration3_es2017.ts new file mode 100644 index 00000000000..9b5924fc145 --- /dev/null +++ b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration3_es2017.ts @@ -0,0 +1,4 @@ +// @target: es2017 +// @noEmitHelpers: true +function f(await = await) { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration4_es2017.ts b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration4_es2017.ts new file mode 100644 index 00000000000..84c6c93b90f --- /dev/null +++ b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration4_es2017.ts @@ -0,0 +1,4 @@ +// @target: es2017 +// @noEmitHelpers: true +function await() { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts new file mode 100644 index 00000000000..c57fb73d6d7 --- /dev/null +++ b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts @@ -0,0 +1,4 @@ +// @target: es2017 +// @noEmitHelpers: true +async function foo(await): Promise { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration6_es2017.ts b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration6_es2017.ts new file mode 100644 index 00000000000..1ceb160c12b --- /dev/null +++ b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration6_es2017.ts @@ -0,0 +1,4 @@ +// @target: es2017 +// @noEmitHelpers: true +async function foo(a = await): Promise { +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration7_es2017.ts b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration7_es2017.ts new file mode 100644 index 00000000000..e5c2649d34e --- /dev/null +++ b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration7_es2017.ts @@ -0,0 +1,7 @@ +// @target: es2017 +// @noEmitHelpers: true +async function bar(): Promise { + // 'await' here is an identifier, and not a yield expression. + async function foo(a = await): Promise { + } +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration8_es2017.ts b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration8_es2017.ts new file mode 100644 index 00000000000..64e62a2719e --- /dev/null +++ b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration8_es2017.ts @@ -0,0 +1,3 @@ +// @target: es2017 +// @noEmitHelpers: true +var v = { [await]: foo } \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration9_es2017.ts b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration9_es2017.ts new file mode 100644 index 00000000000..7d3b7213b99 --- /dev/null +++ b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration9_es2017.ts @@ -0,0 +1,5 @@ +// @target: es2017 +// @noEmitHelpers: true +async function foo(): Promise { + var v = { [await]: foo } +} \ No newline at end of file From 7497d81eecd8a3a17f65154c0c657f9e7966fbb7 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 12 Oct 2016 14:12:32 -0700 Subject: [PATCH 062/173] Narrow string and number types in equality checks and switch cases --- src/compiler/checker.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a1a8ae0da5c..6555710137a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8791,6 +8791,10 @@ namespace ts { assumeTrue ? TypeFacts.EQUndefined : TypeFacts.NEUndefined; return getTypeWithFacts(type, facts); } + if (type.flags & TypeFlags.String && isTypeOfKind(valueType, TypeFlags.StringLiteral) || + type.flags & TypeFlags.Number && isTypeOfKind(valueType, TypeFlags.NumberLiteral)) { + return assumeTrue? valueType : type; + } if (type.flags & TypeFlags.NotUnionOrUnit) { return type; } @@ -8843,7 +8847,11 @@ namespace ts { const clauseTypes = switchTypes.slice(clauseStart, clauseEnd); const hasDefaultClause = clauseStart === clauseEnd || contains(clauseTypes, neverType); const discriminantType = getUnionType(clauseTypes); - const caseType = discriminantType.flags & TypeFlags.Never ? neverType : filterType(type, t => isTypeComparableTo(discriminantType, t)); + const caseType = + discriminantType.flags & TypeFlags.Never ? neverType : + type.flags & TypeFlags.String && isTypeOfKind(discriminantType, TypeFlags.StringLiteral) ? discriminantType : + type.flags & TypeFlags.Number && isTypeOfKind(discriminantType, TypeFlags.NumberLiteral) ? discriminantType : + filterType(type, t => isTypeComparableTo(discriminantType, t)); if (!hasDefaultClause) { return caseType; } From 4c581def93d9d1dbeeb0528901f083cf05f198c3 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 12 Oct 2016 14:12:47 -0700 Subject: [PATCH 063/173] Fix bug in scanner --- src/compiler/scanner.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index e7b3872f2e3..b79106766da 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -1190,7 +1190,7 @@ namespace ts { } function scanBinaryOrOctalDigits(base: number): number { - Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8"); + Debug.assert(base === 2 || base === 8, "Expected either base 2 or base 8"); let value = 0; // For counting number of digits; Valid binaryIntegerLiteral must have at least one binary digit following B or b. From 92b63fa7251e1c6f7d70ca9edc7062f5c284c4e8 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Wed, 12 Oct 2016 11:02:56 -0700 Subject: [PATCH 064/173] Merge pull request #11550 from Microsoft/vladima/generate-protocol Automatically generate protocol.d.ts by pulling in necessary dependencies --- Jakefile.js | 48 ++- scripts/buildProtocol.ts | 143 +++++++++ src/compiler/types.ts | 10 +- src/harness/unittests/compileOnSave.ts | 40 +-- src/server/builder.ts | 1 - src/server/client.ts | 1 - src/server/editorServices.ts | 1 - src/server/{protocol.d.ts => protocol.ts} | 355 +++++++++++++++++----- src/server/scriptInfo.ts | 2 +- src/server/scriptVersionCache.ts | 1 - src/server/session.ts | 144 ++++----- src/server/tsconfig.json | 2 +- src/services/types.ts | 32 +- 13 files changed, 570 insertions(+), 210 deletions(-) create mode 100644 scripts/buildProtocol.ts rename src/server/{protocol.d.ts => protocol.ts} (80%) diff --git a/Jakefile.js b/Jakefile.js index 64a8553ef39..b548a0d3dd8 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -174,7 +174,7 @@ var serverCoreSources = [ "lsHost.ts", "project.ts", "editorServices.ts", - "protocol.d.ts", + "protocol.ts", "session.ts", "server.ts" ].map(function (f) { @@ -198,14 +198,13 @@ var typingsInstallerSources = [ var serverSources = serverCoreSources.concat(servicesSources); var languageServiceLibrarySources = [ - "protocol.d.ts", + "protocol.ts", "utilities.ts", "scriptVersionCache.ts", "scriptInfo.ts", "lsHost.ts", "project.ts", "editorServices.ts", - "protocol.d.ts", "session.ts", ].map(function (f) { @@ -259,7 +258,7 @@ var harnessSources = harnessCoreSources.concat([ ].map(function (f) { return path.join(unittestsDirectory, f); })).concat([ - "protocol.d.ts", + "protocol.ts", "utilities.ts", "scriptVersionCache.ts", "scriptInfo.ts", @@ -267,7 +266,6 @@ var harnessSources = harnessCoreSources.concat([ "project.ts", "typingsCache.ts", "editorServices.ts", - "protocol.d.ts", "session.ts", ].map(function (f) { return path.join(serverDirectory, f); @@ -518,6 +516,40 @@ compileFile(processDiagnosticMessagesJs, [], /*useBuiltCompiler*/ false); +var buildProtocolTs = path.join(scriptsDirectory, "buildProtocol.ts"); +var buildProtocolJs = path.join(scriptsDirectory, "buildProtocol.js"); +var buildProtocolDts = path.join(builtLocalDirectory, "protocol.d.ts"); +var typescriptServicesDts = path.join(builtLocalDirectory, "typescriptServices.d.ts"); + +file(buildProtocolTs); + +compileFile(buildProtocolJs, + [buildProtocolTs], + [buildProtocolTs], + [], + /*useBuiltCompiler*/ false, + {noOutFile: true}); + +file(buildProtocolDts, [buildProtocolTs, buildProtocolJs, typescriptServicesDts], function() { + + var protocolTs = path.join(serverDirectory, "protocol.ts"); + + var cmd = host + " " + buildProtocolJs + " "+ protocolTs + " " + typescriptServicesDts + " " + buildProtocolDts; + console.log(cmd); + var ex = jake.createExec([cmd]); + // Add listeners for output and error + ex.addListener("stdout", function (output) { + process.stdout.write(output); + }); + ex.addListener("stderr", function (error) { + process.stderr.write(error); + }); + ex.addListener("cmdEnd", function () { + complete(); + }); + ex.run(); +}, { async: true }) + // The generated diagnostics map; built for the compiler and for the 'generate-diagnostics' task file(diagnosticInfoMapTs, [processDiagnosticMessagesJs, diagnosticMessagesJson], function () { var cmd = host + " " + processDiagnosticMessagesJs + " " + diagnosticMessagesJson; @@ -655,6 +687,8 @@ compileFile( inlineSourceMap: true }); +file(typescriptServicesDts, [servicesFile]); + var cancellationTokenFile = path.join(builtLocalDirectory, "cancellationToken.js"); compileFile(cancellationTokenFile, cancellationTokenSources, [builtLocalDirectory].concat(cancellationTokenSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { outDir: builtLocalDirectory, noOutFile: true }); @@ -689,7 +723,7 @@ task("build-fold-end", [], function () { // Local target to build the compiler and services desc("Builds the full compiler and services"); -task("local", ["build-fold-start", "generate-diagnostics", "lib", tscFile, servicesFile, nodeDefinitionsFile, serverFile, builtGeneratedDiagnosticMessagesJSON, "lssl", "build-fold-end"]); +task("local", ["build-fold-start", "generate-diagnostics", "lib", tscFile, servicesFile, nodeDefinitionsFile, serverFile, buildProtocolDts, builtGeneratedDiagnosticMessagesJSON, "lssl", "build-fold-end"]); // Local target to build only tsc.js desc("Builds only the compiler"); @@ -745,7 +779,7 @@ task("generate-spec", [specMd]); // Makes a new LKG. This target does not build anything, but errors if not all the outputs are present in the built/local directory desc("Makes a new LKG out of the built js files"); task("LKG", ["clean", "release", "local"].concat(libraryTargets), function () { - var expectedFiles = [tscFile, servicesFile, serverFile, nodePackageFile, nodeDefinitionsFile, standaloneDefinitionsFile, tsserverLibraryFile, tsserverLibraryDefinitionFile, cancellationTokenFile, typingsInstallerFile].concat(libraryTargets); + var expectedFiles = [tscFile, servicesFile, serverFile, nodePackageFile, nodeDefinitionsFile, standaloneDefinitionsFile, tsserverLibraryFile, tsserverLibraryDefinitionFile, cancellationTokenFile, typingsInstallerFile, buildProtocolDts].concat(libraryTargets); var missingFiles = expectedFiles.filter(function (f) { return !fs.existsSync(f); }); diff --git a/scripts/buildProtocol.ts b/scripts/buildProtocol.ts new file mode 100644 index 00000000000..8d49262a470 --- /dev/null +++ b/scripts/buildProtocol.ts @@ -0,0 +1,143 @@ +/// + +import * as ts from "../lib/typescript"; +import * as path from "path"; + +function endsWith(s: string, suffix: string) { + return s.lastIndexOf(suffix, s.length - suffix.length) !== -1; +} + +class DeclarationsWalker { + private visitedTypes: ts.Type[] = []; + private text = ""; + private constructor(private typeChecker: ts.TypeChecker, private protocolFile: ts.SourceFile) { + } + + static getExtraDeclarations(typeChecker: ts.TypeChecker, protocolFile: ts.SourceFile): string { + let text = "declare namespace ts.server.protocol {\n"; + var walker = new DeclarationsWalker(typeChecker, protocolFile); + walker.visitTypeNodes(protocolFile); + return walker.text + ? `declare namespace ts.server.protocol {\n${walker.text}}` + : ""; + } + + private processType(type: ts.Type): void { + if (this.visitedTypes.indexOf(type) >= 0) { + return; + } + this.visitedTypes.push(type); + let s = type.aliasSymbol || type.getSymbol(); + if (!s) { + return; + } + if (s.name === "Array") { + // we should process type argument instead + return this.processType((type).typeArguments[0]); + } + else { + for (const decl of s.getDeclarations()) { + const sourceFile = decl.getSourceFile(); + if (sourceFile === this.protocolFile || path.basename(sourceFile.fileName) === "lib.d.ts") { + return; + } + // splice declaration in final d.ts file + const text = decl.getFullText(); + this.text += `${text}\n`; + + // recursively pull all dependencies into result dts file + this.visitTypeNodes(decl); + } + } + } + + private visitTypeNodes(node: ts.Node) { + if (node.parent) { + switch (node.parent.kind) { + case ts.SyntaxKind.VariableDeclaration: + case ts.SyntaxKind.MethodDeclaration: + case ts.SyntaxKind.MethodSignature: + case ts.SyntaxKind.PropertyDeclaration: + case ts.SyntaxKind.PropertySignature: + case ts.SyntaxKind.Parameter: + case ts.SyntaxKind.IndexSignature: + if (((node.parent).type) === node) { + const type = this.typeChecker.getTypeAtLocation(node); + if (type && !(type.flags & ts.TypeFlags.TypeParameter)) { + this.processType(type); + } + } + break; + } + } + ts.forEachChild(node, n => this.visitTypeNodes(n)); + } +} + +function generateProtocolFile(protocolTs: string, typeScriptServicesDts: string): string { + const options = { target: ts.ScriptTarget.ES5, declaration: true, noResolve: true, types: [], stripInternal: true }; + + /** + * 1st pass - generate a program from protocol.ts and typescriptservices.d.ts and emit core version of protocol.d.ts with all internal members stripped + * @return text of protocol.d.t.s + */ + function getInitialDtsFileForProtocol() { + const program = ts.createProgram([protocolTs, typeScriptServicesDts], options); + + let protocolDts: string; + program.emit(program.getSourceFile(protocolTs), (file, content) => { + if (endsWith(file, ".d.ts")) { + protocolDts = content; + } + }); + if (protocolDts === undefined) { + throw new Error(`Declaration file for protocol.ts is not generated`) + } + return protocolDts; + } + + const protocolFileName = "protocol.d.ts"; + /** + * Second pass - generate a program from protocol.d.ts and typescriptservices.d.ts, then augment core protocol.d.ts with extra types from typescriptservices.d.ts + */ + function getProgramWithProtocolText(protocolDts: string, includeTypeScriptServices: boolean) { + const host = ts.createCompilerHost(options); + const originalGetSourceFile = host.getSourceFile; + host.getSourceFile = (fileName) => { + if (fileName === protocolFileName) { + return ts.createSourceFile(fileName, protocolDts, options.target); + } + return originalGetSourceFile.apply(host, [fileName]); + } + const rootFiles = includeTypeScriptServices ? [protocolFileName, typeScriptServicesDts] : [protocolFileName]; + return ts.createProgram(rootFiles, options, host); + } + + let protocolDts = getInitialDtsFileForProtocol(); + const program = getProgramWithProtocolText(protocolDts, /*includeTypeScriptServices*/ true); + + const protocolFile = program.getSourceFile("protocol.d.ts"); + const extraDeclarations = DeclarationsWalker.getExtraDeclarations(program.getTypeChecker(), protocolFile); + if (extraDeclarations) { + protocolDts += extraDeclarations; + } + // do sanity check and try to compile generated text as standalone program + const sanityCheckProgram = getProgramWithProtocolText(protocolDts, /*includeTypeScriptServices*/ false); + const diagnostics = [...program.getSyntacticDiagnostics(), ...program.getSemanticDiagnostics(), ...program.getGlobalDiagnostics()]; + if (diagnostics.length) { + const flattenedDiagnostics = diagnostics.map(d => ts.flattenDiagnosticMessageText(d.messageText, "\n")).join("\n"); + throw new Error(`Unexpected errors during sanity check: ${flattenedDiagnostics}`); + } + return protocolDts; +} + +if (process.argv.length < 5) { + console.log(`Expected 3 arguments: path to 'protocol.ts', path to 'typescriptservices.d.ts' and path to output file`); + process.exit(1); +} + +const protocolTs = process.argv[2]; +const typeScriptServicesDts = process.argv[3]; +const outputFile = process.argv[4]; +const generatedProtocolDts = generateProtocolFile(protocolTs, typeScriptServicesDts); +ts.sys.writeFile(outputFile, generatedProtocolDts); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 638504e613f..e751f32b3da 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2917,11 +2917,7 @@ namespace ts { NodeJs = 2 } - export type RootPaths = string[]; - export type PathSubstitutions = MapLike; - export type TsConfigOnlyOptions = RootPaths | PathSubstitutions; - - export type CompilerOptionsValue = string | number | boolean | (string | number)[] | TsConfigOnlyOptions; + export type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike; export interface CompilerOptions { allowJs?: boolean; @@ -2973,14 +2969,14 @@ namespace ts { out?: string; outDir?: string; outFile?: string; - paths?: PathSubstitutions; + paths?: MapLike; preserveConstEnums?: boolean; project?: string; /* @internal */ pretty?: DiagnosticStyle; reactNamespace?: string; removeComments?: boolean; rootDir?: string; - rootDirs?: RootPaths; + rootDirs?: string[]; skipLibCheck?: boolean; skipDefaultLibCheck?: boolean; sourceMap?: boolean; diff --git a/src/harness/unittests/compileOnSave.ts b/src/harness/unittests/compileOnSave.ts index 24fd47ee0cb..797268000eb 100644 --- a/src/harness/unittests/compileOnSave.ts +++ b/src/harness/unittests/compileOnSave.ts @@ -3,6 +3,8 @@ /// namespace ts.projectSystem { + import CommandNames = server.CommandNames; + function createTestTypingsInstaller(host: server.ServerHost) { return new TestTypingsInstaller("/a/data/", /*throttleLimit*/5, host); } @@ -75,7 +77,7 @@ namespace ts.projectSystem { }; // Change the content of file1 to `export var T: number;export function Foo() { };` - changeModuleFile1ShapeRequest1 = makeSessionRequest(server.CommandNames.Change, { + changeModuleFile1ShapeRequest1 = makeSessionRequest(CommandNames.Change, { file: moduleFile1.path, line: 1, offset: 1, @@ -85,7 +87,7 @@ namespace ts.projectSystem { }); // Change the content of file1 to `export var T: number;export function Foo() { };` - changeModuleFile1InternalRequest1 = makeSessionRequest(server.CommandNames.Change, { + changeModuleFile1InternalRequest1 = makeSessionRequest(CommandNames.Change, { file: moduleFile1.path, line: 1, offset: 1, @@ -95,7 +97,7 @@ namespace ts.projectSystem { }); // Change the content of file1 to `export var T: number;export function Foo() { };` - changeModuleFile1ShapeRequest2 = makeSessionRequest(server.CommandNames.Change, { + changeModuleFile1ShapeRequest2 = makeSessionRequest(CommandNames.Change, { file: moduleFile1.path, line: 1, offset: 1, @@ -104,7 +106,7 @@ namespace ts.projectSystem { insertString: `export var T2: number;` }); - moduleFile1FileListRequest = makeSessionRequest(server.CommandNames.CompileOnSaveAffectedFileList, { file: moduleFile1.path, projectFileName: configFile.path }); + moduleFile1FileListRequest = makeSessionRequest(CommandNames.CompileOnSaveAffectedFileList, { file: moduleFile1.path, projectFileName: configFile.path }); }); it("should contains only itself if a module file's shape didn't change, and all files referencing it if its shape changed", () => { @@ -120,7 +122,7 @@ namespace ts.projectSystem { sendAffectedFileRequestAndCheckResult(session, moduleFile1FileListRequest, [{ projectFileName: configFile.path, files: [moduleFile1, file1Consumer1, file1Consumer2] }]); // Change the content of file1 to `export var T: number;export function Foo() { console.log('hi'); };` - const changeFile1InternalRequest = makeSessionRequest(server.CommandNames.Change, { + const changeFile1InternalRequest = makeSessionRequest(CommandNames.Change, { file: moduleFile1.path, line: 1, offset: 46, @@ -143,7 +145,7 @@ namespace ts.projectSystem { sendAffectedFileRequestAndCheckResult(session, moduleFile1FileListRequest, [{ projectFileName: configFile.path, files: [moduleFile1, file1Consumer1, file1Consumer2] }]); // Change file2 content to `let y = Foo();` - const removeFile1Consumer1ImportRequest = makeSessionRequest(server.CommandNames.Change, { + const removeFile1Consumer1ImportRequest = makeSessionRequest(CommandNames.Change, { file: file1Consumer1.path, line: 1, offset: 1, @@ -156,7 +158,7 @@ namespace ts.projectSystem { sendAffectedFileRequestAndCheckResult(session, moduleFile1FileListRequest, [{ projectFileName: configFile.path, files: [moduleFile1, file1Consumer2] }]); // Add the import statements back to file2 - const addFile2ImportRequest = makeSessionRequest(server.CommandNames.Change, { + const addFile2ImportRequest = makeSessionRequest(CommandNames.Change, { file: file1Consumer1.path, line: 1, offset: 1, @@ -167,7 +169,7 @@ namespace ts.projectSystem { session.executeCommand(addFile2ImportRequest); // Change the content of file1 to `export var T2: string;export var T: number;export function Foo() { };` - const changeModuleFile1ShapeRequest2 = makeSessionRequest(server.CommandNames.Change, { + const changeModuleFile1ShapeRequest2 = makeSessionRequest(CommandNames.Change, { file: moduleFile1.path, line: 1, offset: 1, @@ -272,7 +274,7 @@ namespace ts.projectSystem { const session = new server.Session(host, nullCancellationToken, /*useSingleInferredProject*/ false, typingsInstaller, Utils.byteLength, process.hrtime, nullLogger, /*canUseEvents*/ false); openFilesForSession([globalFile3], session); - const changeGlobalFile3ShapeRequest = makeSessionRequest(server.CommandNames.Change, { + const changeGlobalFile3ShapeRequest = makeSessionRequest(CommandNames.Change, { file: globalFile3.path, line: 1, offset: 1, @@ -283,7 +285,7 @@ namespace ts.projectSystem { // check after file1 shape changes session.executeCommand(changeGlobalFile3ShapeRequest); - const globalFile3FileListRequest = makeSessionRequest(server.CommandNames.CompileOnSaveAffectedFileList, { file: globalFile3.path }); + const globalFile3FileListRequest = makeSessionRequest(CommandNames.CompileOnSaveAffectedFileList, { file: globalFile3.path }); sendAffectedFileRequestAndCheckResult(session, globalFile3FileListRequest, [{ projectFileName: configFile.path, files: [moduleFile1, file1Consumer1, file1Consumer2, globalFile3, moduleFile2] }]); }); @@ -316,7 +318,7 @@ namespace ts.projectSystem { const session = new server.Session(host, nullCancellationToken, /*useSingleInferredProject*/ false, typingsInstaller, Utils.byteLength, process.hrtime, nullLogger, /*canUseEvents*/ false); openFilesForSession([moduleFile1], session); - const file1ChangeShapeRequest = makeSessionRequest(server.CommandNames.Change, { + const file1ChangeShapeRequest = makeSessionRequest(CommandNames.Change, { file: moduleFile1.path, line: 1, offset: 27, @@ -345,7 +347,7 @@ namespace ts.projectSystem { const session = new server.Session(host, nullCancellationToken, /*useSingleInferredProject*/ false, typingsInstaller, Utils.byteLength, process.hrtime, nullLogger, /*canUseEvents*/ false); openFilesForSession([moduleFile1], session); - const file1ChangeShapeRequest = makeSessionRequest(server.CommandNames.Change, { + const file1ChangeShapeRequest = makeSessionRequest(CommandNames.Change, { file: moduleFile1.path, line: 1, offset: 27, @@ -369,7 +371,7 @@ namespace ts.projectSystem { openFilesForSession([moduleFile1, file1Consumer1], session); sendAffectedFileRequestAndCheckResult(session, moduleFile1FileListRequest, [{ projectFileName: configFile.path, files: [moduleFile1, file1Consumer1, file1Consumer1Consumer1] }]); - const changeFile1Consumer1ShapeRequest = makeSessionRequest(server.CommandNames.Change, { + const changeFile1Consumer1ShapeRequest = makeSessionRequest(CommandNames.Change, { file: file1Consumer1.path, line: 2, offset: 1, @@ -400,7 +402,7 @@ namespace ts.projectSystem { const session = new server.Session(host, nullCancellationToken, /*useSingleInferredProject*/ false, typingsInstaller, Utils.byteLength, process.hrtime, nullLogger, /*canUseEvents*/ false); openFilesForSession([file1, file2], session); - const file1AffectedListRequest = makeSessionRequest(server.CommandNames.CompileOnSaveAffectedFileList, { file: file1.path }); + const file1AffectedListRequest = makeSessionRequest(CommandNames.CompileOnSaveAffectedFileList, { file: file1.path }); sendAffectedFileRequestAndCheckResult(session, file1AffectedListRequest, [{ projectFileName: configFile.path, files: [file1, file2] }]); }); @@ -415,7 +417,7 @@ namespace ts.projectSystem { const session = createSession(host); openFilesForSession([file1, file2, file3], session); - const file1AffectedListRequest = makeSessionRequest(server.CommandNames.CompileOnSaveAffectedFileList, { file: file1.path }); + const file1AffectedListRequest = makeSessionRequest(CommandNames.CompileOnSaveAffectedFileList, { file: file1.path }); sendAffectedFileRequestAndCheckResult(session, file1AffectedListRequest, [ { projectFileName: configFile1.path, files: [file1, file2] }, @@ -437,11 +439,11 @@ namespace ts.projectSystem { host.reloadFS([referenceFile1, configFile]); host.triggerFileWatcherCallback(moduleFile1.path, /*removed*/ true); - const request = makeSessionRequest(server.CommandNames.CompileOnSaveAffectedFileList, { file: referenceFile1.path }); + const request = makeSessionRequest(CommandNames.CompileOnSaveAffectedFileList, { file: referenceFile1.path }); sendAffectedFileRequestAndCheckResult(session, request, [ { projectFileName: configFile.path, files: [referenceFile1] } ]); - const requestForMissingFile = makeSessionRequest(server.CommandNames.CompileOnSaveAffectedFileList, { file: moduleFile1.path }); + const requestForMissingFile = makeSessionRequest(CommandNames.CompileOnSaveAffectedFileList, { file: moduleFile1.path }); sendAffectedFileRequestAndCheckResult(session, requestForMissingFile, []); }); @@ -456,7 +458,7 @@ namespace ts.projectSystem { const session = createSession(host); openFilesForSession([referenceFile1], session); - const request = makeSessionRequest(server.CommandNames.CompileOnSaveAffectedFileList, { file: referenceFile1.path }); + const request = makeSessionRequest(CommandNames.CompileOnSaveAffectedFileList, { file: referenceFile1.path }); sendAffectedFileRequestAndCheckResult(session, request, [ { projectFileName: configFile.path, files: [referenceFile1] } ]); @@ -483,7 +485,7 @@ namespace ts.projectSystem { const session = new server.Session(host, nullCancellationToken, /*useSingleInferredProject*/ false, typingsInstaller, Utils.byteLength, process.hrtime, nullLogger, /*canUseEvents*/ false); openFilesForSession([file1, file2], session); - const compileFileRequest = makeSessionRequest(server.CommandNames.CompileOnSaveEmitFile, { file: file1.path, projectFileName: configFile.path }); + const compileFileRequest = makeSessionRequest(CommandNames.CompileOnSaveEmitFile, { file: file1.path, projectFileName: configFile.path }); session.executeCommand(compileFileRequest); const expectedEmittedFileName = "/a/b/f1.js"; diff --git a/src/server/builder.ts b/src/server/builder.ts index 639c41d2b63..475202a0aab 100644 --- a/src/server/builder.ts +++ b/src/server/builder.ts @@ -1,6 +1,5 @@ /// /// -/// /// /// diff --git a/src/server/client.ts b/src/server/client.ts index 058abdff41d..b0bc2c5dac0 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -1,7 +1,6 @@ /// namespace ts.server { - export interface SessionClientHost extends LanguageServiceHost { writeMessage(message: string): void; } diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index dc2c45156cd..1a331c09320 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -1,6 +1,5 @@ /// /// -/// /// /// /// diff --git a/src/server/protocol.d.ts b/src/server/protocol.ts similarity index 80% rename from src/server/protocol.d.ts rename to src/server/protocol.ts index 2f447934040..80623f05aec 100644 --- a/src/server/protocol.d.ts +++ b/src/server/protocol.ts @@ -1,7 +1,102 @@ /** * Declaration module describing the TypeScript Server protocol */ -declare namespace ts.server.protocol { +namespace ts.server.protocol { + export namespace CommandTypes { + export type Brace = "brace"; + /* @internal */ + export type BraceFull = "brace-full"; + export type BraceCompletion = "braceCompletion"; + export type Change = "change"; + export type Close = "close"; + export type Completions = "completions"; + /* @internal */ + export type CompletionsFull = "completions-full"; + export type CompletionDetails = "completionEntryDetails"; + export type CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList"; + export type CompileOnSaveEmitFile = "compileOnSaveEmitFile"; + export type Configure = "configure"; + export type Definition = "definition"; + /* @internal */ + export type DefinitionFull = "definition-full"; + export type Implementation = "implementation"; + /* @internal */ + export type ImplementationFull = "implementation-full"; + export type Exit = "exit"; + export type Format = "format"; + export type Formatonkey = "formatonkey"; + /* @internal */ + export type FormatFull = "format-full"; + /* @internal */ + export type FormatonkeyFull = "formatonkey-full"; + /* @internal */ + export type FormatRangeFull = "formatRange-full"; + export type Geterr = "geterr"; + export type GeterrForProject = "geterrForProject"; + export type SemanticDiagnosticsSync = "semanticDiagnosticsSync"; + export type SyntacticDiagnosticsSync = "syntacticDiagnosticsSync"; + export type NavBar = "navbar"; + /* @internal */ + export type NavBarFull = "navbar-full"; + export type Navto = "navto"; + /* @internal */ + export type NavtoFull = "navto-full"; + export type NavTree = "navtree"; + export type NavTreeFull = "navtree-full"; + export type Occurrences = "occurrences"; + export type DocumentHighlights = "documentHighlights"; + /* @internal */ + export type DocumentHighlightsFull = "documentHighlights-full"; + export type Open = "open"; + export type Quickinfo = "quickinfo"; + /* @internal */ + export type QuickinfoFull = "quickinfo-full"; + export type References = "references"; + /* @internal */ + export type ReferencesFull = "references-full"; + export type Reload = "reload"; + export type Rename = "rename"; + /* @internal */ + export type RenameInfoFull = "rename-full"; + /* @internal */ + export type RenameLocationsFull = "renameLocations-full"; + export type Saveto = "saveto"; + export type SignatureHelp = "signatureHelp"; + /* @internal */ + export type SignatureHelpFull = "signatureHelp-full"; + export type TypeDefinition = "typeDefinition"; + export type ProjectInfo = "projectInfo"; + export type ReloadProjects = "reloadProjects"; + export type Unknown = "unknown"; + export type OpenExternalProject = "openExternalProject"; + export type OpenExternalProjects = "openExternalProjects"; + export type CloseExternalProject = "closeExternalProject"; + /* @internal */ + export type SynchronizeProjectList = "synchronizeProjectList"; + /* @internal */ + export type ApplyChangedToOpenFiles = "applyChangedToOpenFiles"; + /* @internal */ + export type EncodedSemanticClassificationsFull = "encodedSemanticClassifications-full"; + /* @internal */ + export type Cleanup = "cleanup"; + /* @internal */ + export type OutliningSpans = "outliningSpans"; + export type TodoComments = "todoComments"; + export type Indentation = "indentation"; + export type DocCommentTemplate = "docCommentTemplate"; + /* @internal */ + export type CompilerOptionsDiagnosticsFull = "compilerOptionsDiagnostics-full"; + /* @internal */ + export type NameOrDottedNameSpan = "nameOrDottedNameSpan"; + /* @internal */ + export type BreakpointStatement = "breakpointStatement"; + export type CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects"; + export type GetCodeFixes = "getCodeFixes"; + /* @internal */ + export type GetCodeFixesFull = "getCodeFixes-full"; + export type GetSupportedCodeFixes = "getSupportedCodeFixes"; + } + /** * A TypeScript Server message */ @@ -36,6 +131,7 @@ declare namespace ts.server.protocol { * Request to reload the project structure for all the opened files */ export interface ReloadProjectsRequest extends Message { + command: CommandTypes.ReloadProjects; } /** @@ -98,10 +194,25 @@ declare namespace ts.server.protocol { projectFileName?: string; } + /** + * Requests a JS Doc comment template for a given position + */ + export interface DocCommentTemplateRequest extends FileLocationRequest { + command: CommandTypes.DocCommentTemplate; + } + + /** + * Response to DocCommentTemplateRequest + */ + export interface DocCommandTemplateResponse extends Response { + body?: TextInsertion; + } + /** * A request to get TODO comments from the file */ export interface TodoCommentRequest extends FileRequest { + command: CommandTypes.TodoComments; arguments: TodoCommentRequestArgs; } @@ -115,13 +226,58 @@ declare namespace ts.server.protocol { descriptors: TodoCommentDescriptor[]; } + /** + * Response for TodoCommentRequest request. + */ + export interface TodoCommentsResponse extends Response { + body?: TodoComment[]; + } + + /** + * Request to obtain outlining spans in file. + */ + /* @internal */ + export interface OutliningSpansRequest extends FileRequest { + command: CommandTypes.OutliningSpans; + } + + /** + * Response to OutliningSpansRequest request. + */ + /* @internal */ + export interface OutliningSpansResponse extends Response { + body?: OutliningSpan[]; + } + /** * A request to get indentation for a location in file */ export interface IndentationRequest extends FileLocationRequest { + command: CommandTypes.Indentation; arguments: IndentationRequestArgs; } + /** + * Response for IndentationRequest request. + */ + export interface IndentationResponse extends Response { + body?: IndentationResult; + } + + /** + * Indentation result representing where indentation should be placed + */ + export interface IndentationResult { + /** + * The base position in the document that the indent should be relative to + */ + position: number; + /** + * The number of columns the indent should be at relative to the position's column. + */ + indentation: number; + } + /** * Arguments for IndentationRequest request. */ @@ -147,6 +303,7 @@ declare namespace ts.server.protocol { * A request to get the project information of the current file. */ export interface ProjectInfoRequest extends Request { + command: CommandTypes.ProjectInfo; arguments: ProjectInfoRequestArgs; } @@ -223,16 +380,17 @@ declare namespace ts.server.protocol { /** * The line number for the request (1-based). */ - line?: number; + line: number; /** * The character offset (on the line) for the request (1-based). */ - offset?: number; + offset: number; /** * Position (can be specified instead of line/offset pair) */ + /* @internal */ position?: number; } @@ -240,6 +398,7 @@ declare namespace ts.server.protocol { * Request for the available codefixes at a specific position. */ export interface CodeFixRequest extends Request { + command: CommandTypes.GetCodeFixes; arguments: CodeFixRequestArgs; } @@ -250,31 +409,33 @@ declare namespace ts.server.protocol { /** * The line number for the request (1-based). */ - startLine?: number; + startLine: number; /** * The character offset (on the line) for the request (1-based). */ - startOffset?: number; + startOffset: number; /** * Position (can be specified instead of line/offset pair) */ + /* @internal */ startPosition?: number; /** * The line number for the request (1-based). */ - endLine?: number; + endLine: number; /** * The character offset (on the line) for the request (1-based). */ - endOffset?: number; + endOffset: number; /** * Position (can be specified instead of line/offset pair) */ + /* @internal */ endPosition?: number; /** @@ -283,6 +444,13 @@ declare namespace ts.server.protocol { errorCodes?: number[]; } + /** + * Response for GetCodeFixes request. + */ + export interface GetCodeFixesResponse extends Response { + body?: CodeAction[]; + } + /** * A request whose arguments specify a file location (file, line, col). */ @@ -291,16 +459,34 @@ declare namespace ts.server.protocol { } /** - * A request to get semantic diagnostics for a span in the file + * A request to get codes of supported code fixes. */ - export interface SemanticDiagnosticsRequest extends FileRequest { - arguments: SemanticDiagnosticsRequestArgs; + export interface GetSupportedCodeFixesRequest extends Request { + command: CommandTypes.GetSupportedCodeFixes; } /** - * Arguments for SemanticDiagnosticsRequest request. + * A response for GetSupportedCodeFixesRequest request. */ - export interface SemanticDiagnosticsRequestArgs extends FileRequestArgs { + export interface GetSupportedCodeFixesResponse extends Response { + /** + * List of error codes supported by the server. + */ + body?: string[]; + } + + /** + * A request to get encoded semantic classifications for a span in the file + */ + /** @internal */ + export interface EncodedSemanticClassificationsRequest extends FileRequest { + arguments: EncodedSemanticClassificationsRequestArgs; + } + + /** + * Arguments for EncodedSemanticClassificationsRequest request. + */ + export interface EncodedSemanticClassificationsRequestArgs extends FileRequestArgs { /** * Start position of the span. */ @@ -328,6 +514,7 @@ declare namespace ts.server.protocol { * define the symbol found in file at location line, col. */ export interface DefinitionRequest extends FileLocationRequest { + command: CommandTypes.Definition; } /** @@ -336,6 +523,7 @@ declare namespace ts.server.protocol { * define the type for the symbol found in file at location line, col. */ export interface TypeDefinitionRequest extends FileLocationRequest { + command: CommandTypes.TypeDefinition; } /** @@ -344,6 +532,7 @@ declare namespace ts.server.protocol { * implement the symbol found in file at location line, col. */ export interface ImplementationRequest extends FileLocationRequest { + command: CommandTypes.Implementation; } /** @@ -404,6 +593,7 @@ declare namespace ts.server.protocol { * Request to get brace completion for a location in the file. */ export interface BraceCompletionRequest extends FileLocationRequest { + command: CommandTypes.BraceCompletion; arguments: BraceCompletionRequestArgs; } @@ -423,6 +613,7 @@ declare namespace ts.server.protocol { * in the file at a given line and column. */ export interface OccurrencesRequest extends FileLocationRequest { + command: CommandTypes.Occurrences; } export interface OccurrencesResponseItem extends FileSpan { @@ -442,6 +633,7 @@ declare namespace ts.server.protocol { * in the file at a given line and column. */ export interface DocumentHighlightsRequest extends FileLocationRequest { + command: CommandTypes.DocumentHighlights; arguments: DocumentHighlightsRequestArgs; } @@ -481,6 +673,7 @@ declare namespace ts.server.protocol { * reference the symbol found in file at location line, col. */ export interface ReferencesRequest extends FileLocationRequest { + command: CommandTypes.References; } export interface ReferencesResponseItem extends FileSpan { @@ -555,6 +748,7 @@ declare namespace ts.server.protocol { * name of the symbol so that client can print it unambiguously. */ export interface RenameRequest extends FileLocationRequest { + command: CommandTypes.Rename; arguments: RenameRequestArgs; } @@ -754,6 +948,7 @@ declare namespace ts.server.protocol { /** * Represents set of changes in open file */ + /* @internal */ export interface ChangedOpenFile { /** * Name of file @@ -765,65 +960,6 @@ declare namespace ts.server.protocol { changes: ts.TextChange[]; } - /** - * Editor options - */ - export interface EditorOptions { - - /** Number of spaces for each tab. Default value is 4. */ - tabSize?: number; - - /** Number of spaces to indent during formatting. Default value is 4. */ - indentSize?: number; - - /** Number of additional spaces to indent during formatting to preserve base indentation (ex. script block indentation). Default value is 0. */ - baseIndentSize?: number; - - /** The new line character to be used. Default value is the OS line delimiter. */ - newLineCharacter?: string; - - /** Whether tabs should be converted to spaces. Default value is true. */ - convertTabsToSpaces?: boolean; - } - - /** - * Format options - */ - export interface FormatOptions extends EditorOptions { - - /** Defines space handling after a comma delimiter. Default value is true. */ - insertSpaceAfterCommaDelimiter?: boolean; - - /** Defines space handling after a semicolon in a for statement. Default value is true */ - insertSpaceAfterSemicolonInForStatements?: boolean; - - /** Defines space handling after a binary operator. Default value is true. */ - insertSpaceBeforeAndAfterBinaryOperators?: boolean; - - /** Defines space handling after keywords in control flow statement. Default value is true. */ - insertSpaceAfterKeywordsInControlFlowStatements?: boolean; - - /** Defines space handling after function keyword for anonymous functions. Default value is false. */ - insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; - - /** Defines space handling after opening and before closing non empty parenthesis. Default value is false. */ - insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; - - /** Defines space handling after opening and before closing non empty brackets. Default value is false. */ - insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean; - - /** Defines space handling before and after template string braces. Default value is false. */ - insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; - - /** Defines space handling before and after JSX expression braces. Default value is false. */ - insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; - - /** Defines whether an open brace is put onto a new line for functions or not. Default value is false. */ - placeOpenBraceOnNewLineForFunctions?: boolean; - - /** Defines whether an open brace is put onto a new line for control blocks or not. Default value is false. */ - placeOpenBraceOnNewLineForControlBlocks?: boolean; - } /** * Information found in a configure request. @@ -844,12 +980,7 @@ declare namespace ts.server.protocol { /** * The format options to use during formatting and other code editing features. */ - formatOptions?: FormatOptions; - - /** - * If set to true - then all loose files will land into one inferred project - */ - useOneInferredProject?: boolean; + formatOptions?: FormatCodeSettings; } /** @@ -857,6 +988,7 @@ declare namespace ts.server.protocol { * host information, such as host type, tab size, and indent size. */ export interface ConfigureRequest extends Request { + command: CommandTypes.Configure; arguments: ConfigureRequestArguments; } @@ -892,6 +1024,7 @@ declare namespace ts.server.protocol { * send a response to an open request. */ export interface OpenRequest extends Request { + command: CommandTypes.Open; arguments: OpenRequestArgs; } @@ -899,18 +1032,20 @@ declare namespace ts.server.protocol { * Request to open or update external project */ export interface OpenExternalProjectRequest extends Request { + command: CommandTypes.OpenExternalProject; arguments: OpenExternalProjectArgs; } /** * Arguments to OpenExternalProjectRequest request */ - type OpenExternalProjectArgs = ExternalProject; + export type OpenExternalProjectArgs = ExternalProject; /** * Request to open multiple external projects */ export interface OpenExternalProjectsRequest extends Request { + command: CommandTypes.OpenExternalProjects; arguments: OpenExternalProjectsArgs; } @@ -924,10 +1059,25 @@ declare namespace ts.server.protocol { projects: ExternalProject[]; } + /** + * Response to OpenExternalProjectRequest request. This is just an acknowledgement, so + * no body field is required. + */ + export interface OpenExternalProjectResponse extends Response { + } + + /** + * Response to OpenExternalProjectsRequest request. This is just an acknowledgement, so + * no body field is required. + */ + export interface OpenExternalProjectsResponse extends Response { + } + /** * Request to close external project. */ export interface CloseExternalProjectRequest extends Request { + command: CommandTypes.CloseExternalProject; arguments: CloseExternalProjectRequestArgs; } @@ -941,9 +1091,17 @@ declare namespace ts.server.protocol { projectFileName: string; } + /** + * Response to CloseExternalProjectRequest request. This is just an acknowledgement, so + * no body field is required. + */ + export interface CloseExternalProjectResponse extends Response { + } + /** * Request to check if given list of projects is up-to-date and synchronize them if necessary */ + /* @internal */ export interface SynchronizeProjectListRequest extends Request { arguments: SynchronizeProjectListRequestArgs; } @@ -961,6 +1119,7 @@ declare namespace ts.server.protocol { /** * Request to synchronize list of open files with the client */ + /* @internal */ export interface ApplyChangedToOpenFilesRequest extends Request { arguments: ApplyChangedToOpenFilesRequestArgs; } @@ -968,6 +1127,7 @@ declare namespace ts.server.protocol { /** * Arguments to ApplyChangedToOpenFilesRequest */ + /* @internal */ export interface ApplyChangedToOpenFilesRequestArgs { /** * List of newly open files @@ -993,6 +1153,7 @@ declare namespace ts.server.protocol { * or all open loose files and its transitive closure of referenced files if 'useOneInferredProject' is true. */ export interface SetCompilerOptionsForInferredProjectsRequest extends Request { + command: CommandTypes.CompilerOptionsForInferredProjects; arguments: SetCompilerOptionsForInferredProjectsArgs; } @@ -1006,11 +1167,19 @@ declare namespace ts.server.protocol { options: ExternalProjectCompilerOptions; } + /** + * Response to SetCompilerOptionsForInferredProjectsResponse request. This is just an acknowledgement, so + * no body field is required. + */ + export interface SetCompilerOptionsForInferredProjectsResponse extends Response { + } + /** * Exit request; value of command field is "exit". Ask the server process * to exit. */ export interface ExitRequest extends Request { + command: CommandTypes.Exit; } /** @@ -1021,6 +1190,7 @@ declare namespace ts.server.protocol { * currently send a response to a close request. */ export interface CloseRequest extends FileRequest { + command: CommandTypes.Close; } /** @@ -1028,6 +1198,7 @@ declare namespace ts.server.protocol { * NOTE: this us query-only operation and does not generate any output on disk. */ export interface CompileOnSaveAffectedFileListRequest extends FileRequest { + command: CommandTypes.CompileOnSaveAffectedFileList; } /** @@ -1055,7 +1226,8 @@ declare namespace ts.server.protocol { * Request to recompile the file. All generated outputs (.js, .d.ts or .js.map files) is written on disk. */ export interface CompileOnSaveEmitFileRequest extends FileRequest { - args: CompileOnSaveEmitFileRequestArgs; + command: CommandTypes.CompileOnSaveEmitFile; + arguments: CompileOnSaveEmitFileRequestArgs; } /** @@ -1075,6 +1247,7 @@ declare namespace ts.server.protocol { * line, col. */ export interface QuickInfoRequest extends FileLocationRequest { + command: CommandTypes.Quickinfo; } /** @@ -1136,12 +1309,12 @@ declare namespace ts.server.protocol { /** * End position of the range for which to format text in file. */ + /* @internal */ endPosition?: number; - /** * Format options to be used. */ - options?: ts.FormatCodeOptions; + options?: FormatCodeSettings; } /** @@ -1152,6 +1325,7 @@ declare namespace ts.server.protocol { * reformatted text. */ export interface FormatRequest extends FileLocationRequest { + command: CommandTypes.Format; arguments: FormatRequestArgs; } @@ -1213,7 +1387,7 @@ declare namespace ts.server.protocol { */ key: string; - options?: ts.FormatCodeOptions; + options?: FormatCodeSettings; } /** @@ -1225,6 +1399,7 @@ declare namespace ts.server.protocol { * reformatted text. */ export interface FormatOnKeyRequest extends FileLocationRequest { + command: CommandTypes.Formatonkey; arguments: FormatOnKeyRequestArgs; } @@ -1245,6 +1420,7 @@ declare namespace ts.server.protocol { * begin with prefix. */ export interface CompletionsRequest extends FileLocationRequest { + command: CommandTypes.Completions; arguments: CompletionsRequestArgs; } @@ -1265,6 +1441,7 @@ declare namespace ts.server.protocol { * detailed information for each completion entry. */ export interface CompletionDetailsRequest extends FileLocationRequest { + command: CommandTypes.CompletionDetails; arguments: CompletionDetailsRequestArgs; } @@ -1451,6 +1628,7 @@ declare namespace ts.server.protocol { * help. */ export interface SignatureHelpRequest extends FileLocationRequest { + command: CommandTypes.SignatureHelp; arguments: SignatureHelpRequestArgs; } @@ -1465,6 +1643,7 @@ declare namespace ts.server.protocol { * Synchronous request for semantic diagnostics of one file. */ export interface SemanticDiagnosticsSyncRequest extends FileRequest { + command: CommandTypes.SemanticDiagnosticsSync; arguments: SemanticDiagnosticsSyncRequestArgs; } @@ -1483,6 +1662,7 @@ declare namespace ts.server.protocol { * Synchronous request for syntactic diagnostics of one file. */ export interface SyntacticDiagnosticsSyncRequest extends FileRequest { + command: CommandTypes.SyntacticDiagnosticsSync; arguments: SyntacticDiagnosticsSyncRequestArgs; } @@ -1519,6 +1699,7 @@ declare namespace ts.server.protocol { * it request for every file in this project. */ export interface GeterrForProjectRequest extends Request { + command: CommandTypes.GeterrForProject; arguments: GeterrForProjectRequestArgs; } @@ -1550,6 +1731,7 @@ declare namespace ts.server.protocol { * file that is currently visible, in most-recently-used order. */ export interface GeterrRequest extends Request { + command: CommandTypes.Geterr; arguments: GeterrRequestArgs; } @@ -1642,11 +1824,12 @@ declare namespace ts.server.protocol { * The two names can be identical. */ export interface ReloadRequest extends FileRequest { + command: CommandTypes.Reload; arguments: ReloadRequestArgs; } /** - * Response to "reload" request. This is just an acknowledgement, so + * Response to "reload" request. This is just an acknowledgement, so * no body field is required. */ export interface ReloadResponse extends Response { @@ -1671,6 +1854,7 @@ declare namespace ts.server.protocol { * "saveto" request. */ export interface SavetoRequest extends FileRequest { + command: CommandTypes.Saveto; arguments: SavetoRequestArgs; } @@ -1703,6 +1887,7 @@ declare namespace ts.server.protocol { * context for the search is given by the named file. */ export interface NavtoRequest extends FileRequest { + command: CommandTypes.Navto; arguments: NavtoRequestArgs; } @@ -1786,6 +1971,7 @@ declare namespace ts.server.protocol { * Server does not currently send a response to a change request. */ export interface ChangeRequest extends FileLocationRequest { + command: CommandTypes.Change; arguments: ChangeRequestArgs; } @@ -1802,6 +1988,7 @@ declare namespace ts.server.protocol { * found in file at location line, offset. */ export interface BraceRequest extends FileLocationRequest { + command: CommandTypes.Brace; } /** @@ -1810,6 +1997,7 @@ declare namespace ts.server.protocol { * extracted from the requested file. */ export interface NavBarRequest extends FileRequest { + command: CommandTypes.NavBar; } /** @@ -1817,6 +2005,7 @@ declare namespace ts.server.protocol { * Return response giving the navigation tree of the requested file. */ export interface NavTreeRequest extends FileRequest { + command: CommandTypes.NavTree; } export interface NavigationBarItem { diff --git a/src/server/scriptInfo.ts b/src/server/scriptInfo.ts index ee5122ff4e1..68dd59d2d32 100644 --- a/src/server/scriptInfo.ts +++ b/src/server/scriptInfo.ts @@ -91,7 +91,7 @@ namespace ts.server { return this.containingProjects[0]; } - setFormatOptions(formatSettings: protocol.FormatOptions): void { + setFormatOptions(formatSettings: FormatCodeSettings): void { if (formatSettings) { if (!this.formatCodeSettings) { this.formatCodeSettings = getDefaultFormatCodeSettings(this.host); diff --git a/src/server/scriptVersionCache.ts b/src/server/scriptVersionCache.ts index 1508187c13e..8d0efa081ad 100644 --- a/src/server/scriptVersionCache.ts +++ b/src/server/scriptVersionCache.ts @@ -1,6 +1,5 @@ /// /// -/// /// namespace ts.server { diff --git a/src/server/session.ts b/src/server/session.ts index 172ae70d95a..111ba53a700 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -1,6 +1,6 @@ /// /// -/// +/// /// namespace ts.server { @@ -83,74 +83,74 @@ namespace ts.server { } export namespace CommandNames { - export const Brace = "brace"; - export const BraceFull = "brace-full"; - export const BraceCompletion = "braceCompletion"; - export const Change = "change"; - export const Close = "close"; - export const Completions = "completions"; - export const CompletionsFull = "completions-full"; - export const CompletionDetails = "completionEntryDetails"; - export const CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList"; - export const CompileOnSaveEmitFile = "compileOnSaveEmitFile"; - export const Configure = "configure"; - export const Definition = "definition"; - export const DefinitionFull = "definition-full"; - export const Exit = "exit"; - export const Format = "format"; - export const Formatonkey = "formatonkey"; - export const FormatFull = "format-full"; - export const FormatonkeyFull = "formatonkey-full"; - export const FormatRangeFull = "formatRange-full"; - export const Geterr = "geterr"; - export const GeterrForProject = "geterrForProject"; - export const Implementation = "implementation"; - export const ImplementationFull = "implementation-full"; - export const SemanticDiagnosticsSync = "semanticDiagnosticsSync"; - export const SyntacticDiagnosticsSync = "syntacticDiagnosticsSync"; - export const NavBar = "navbar"; - export const NavBarFull = "navbar-full"; - export const NavTree = "navtree"; - export const NavTreeFull = "navtree-full"; - export const Navto = "navto"; - export const NavtoFull = "navto-full"; - export const Occurrences = "occurrences"; - export const DocumentHighlights = "documentHighlights"; - export const DocumentHighlightsFull = "documentHighlights-full"; - export const Open = "open"; - export const Quickinfo = "quickinfo"; - export const QuickinfoFull = "quickinfo-full"; - export const References = "references"; - export const ReferencesFull = "references-full"; - export const Reload = "reload"; - export const Rename = "rename"; - export const RenameInfoFull = "rename-full"; - export const RenameLocationsFull = "renameLocations-full"; - export const Saveto = "saveto"; - export const SignatureHelp = "signatureHelp"; - export const SignatureHelpFull = "signatureHelp-full"; - export const TypeDefinition = "typeDefinition"; - export const ProjectInfo = "projectInfo"; - export const ReloadProjects = "reloadProjects"; - export const Unknown = "unknown"; - export const OpenExternalProject = "openExternalProject"; - export const OpenExternalProjects = "openExternalProjects"; - export const CloseExternalProject = "closeExternalProject"; - export const SynchronizeProjectList = "synchronizeProjectList"; - export const ApplyChangedToOpenFiles = "applyChangedToOpenFiles"; - export const EncodedSemanticClassificationsFull = "encodedSemanticClassifications-full"; - export const Cleanup = "cleanup"; - export const OutliningSpans = "outliningSpans"; - export const TodoComments = "todoComments"; - export const Indentation = "indentation"; - export const DocCommentTemplate = "docCommentTemplate"; - export const CompilerOptionsDiagnosticsFull = "compilerOptionsDiagnostics-full"; - export const NameOrDottedNameSpan = "nameOrDottedNameSpan"; - export const BreakpointStatement = "breakpointStatement"; - export const CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects"; - export const GetCodeFixes = "getCodeFixes"; - export const GetCodeFixesFull = "getCodeFixes-full"; - export const GetSupportedCodeFixes = "getSupportedCodeFixes"; + export const Brace: protocol.CommandTypes.Brace = "brace"; + export const BraceFull: protocol.CommandTypes.BraceFull = "brace-full"; + export const BraceCompletion: protocol.CommandTypes.BraceCompletion = "braceCompletion"; + export const Change: protocol.CommandTypes.Change = "change"; + export const Close: protocol.CommandTypes.Close = "close"; + export const Completions: protocol.CommandTypes.Completions = "completions"; + export const CompletionsFull: protocol.CommandTypes.CompletionsFull = "completions-full"; + export const CompletionDetails: protocol.CommandTypes.CompletionDetails = "completionEntryDetails"; + export const CompileOnSaveAffectedFileList: protocol.CommandTypes.CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList"; + export const CompileOnSaveEmitFile: protocol.CommandTypes.CompileOnSaveEmitFile = "compileOnSaveEmitFile"; + export const Configure: protocol.CommandTypes.Configure = "configure"; + export const Definition: protocol.CommandTypes.Definition = "definition"; + export const DefinitionFull: protocol.CommandTypes.DefinitionFull = "definition-full"; + export const Exit: protocol.CommandTypes.Exit = "exit"; + export const Format: protocol.CommandTypes.Format = "format"; + export const Formatonkey: protocol.CommandTypes.Formatonkey = "formatonkey"; + export const FormatFull: protocol.CommandTypes.FormatFull = "format-full"; + export const FormatonkeyFull: protocol.CommandTypes.FormatonkeyFull = "formatonkey-full"; + export const FormatRangeFull: protocol.CommandTypes.FormatRangeFull = "formatRange-full"; + export const Geterr: protocol.CommandTypes.Geterr = "geterr"; + export const GeterrForProject: protocol.CommandTypes.GeterrForProject = "geterrForProject"; + export const Implementation: protocol.CommandTypes.Implementation = "implementation"; + export const ImplementationFull: protocol.CommandTypes.ImplementationFull = "implementation-full"; + export const SemanticDiagnosticsSync: protocol.CommandTypes.SemanticDiagnosticsSync = "semanticDiagnosticsSync"; + export const SyntacticDiagnosticsSync: protocol.CommandTypes.SyntacticDiagnosticsSync = "syntacticDiagnosticsSync"; + export const NavBar: protocol.CommandTypes.NavBar = "navbar"; + export const NavBarFull: protocol.CommandTypes.NavBarFull = "navbar-full"; + export const NavTree: protocol.CommandTypes.NavTree = "navtree"; + export const NavTreeFull: protocol.CommandTypes.NavTreeFull = "navtree-full"; + export const Navto: protocol.CommandTypes.Navto = "navto"; + export const NavtoFull: protocol.CommandTypes.NavtoFull = "navto-full"; + export const Occurrences: protocol.CommandTypes.Occurrences = "occurrences"; + export const DocumentHighlights: protocol.CommandTypes.DocumentHighlights = "documentHighlights"; + export const DocumentHighlightsFull: protocol.CommandTypes.DocumentHighlightsFull = "documentHighlights-full"; + export const Open: protocol.CommandTypes.Open = "open"; + export const Quickinfo: protocol.CommandTypes.Quickinfo = "quickinfo"; + export const QuickinfoFull: protocol.CommandTypes.QuickinfoFull = "quickinfo-full"; + export const References: protocol.CommandTypes.References = "references"; + export const ReferencesFull: protocol.CommandTypes.ReferencesFull = "references-full"; + export const Reload: protocol.CommandTypes.Reload = "reload"; + export const Rename: protocol.CommandTypes.Rename = "rename"; + export const RenameInfoFull: protocol.CommandTypes.RenameInfoFull = "rename-full"; + export const RenameLocationsFull: protocol.CommandTypes.RenameLocationsFull = "renameLocations-full"; + export const Saveto: protocol.CommandTypes.Saveto = "saveto"; + export const SignatureHelp: protocol.CommandTypes.SignatureHelp = "signatureHelp"; + export const SignatureHelpFull: protocol.CommandTypes.SignatureHelpFull = "signatureHelp-full"; + export const TypeDefinition: protocol.CommandTypes.TypeDefinition = "typeDefinition"; + export const ProjectInfo: protocol.CommandTypes.ProjectInfo = "projectInfo"; + export const ReloadProjects: protocol.CommandTypes.ReloadProjects = "reloadProjects"; + export const Unknown: protocol.CommandTypes.Unknown = "unknown"; + export const OpenExternalProject: protocol.CommandTypes.OpenExternalProject = "openExternalProject"; + export const OpenExternalProjects: protocol.CommandTypes.OpenExternalProjects = "openExternalProjects"; + export const CloseExternalProject: protocol.CommandTypes.CloseExternalProject = "closeExternalProject"; + export const SynchronizeProjectList: protocol.CommandTypes.SynchronizeProjectList = "synchronizeProjectList"; + export const ApplyChangedToOpenFiles: protocol.CommandTypes.ApplyChangedToOpenFiles = "applyChangedToOpenFiles"; + export const EncodedSemanticClassificationsFull: protocol.CommandTypes.EncodedSemanticClassificationsFull = "encodedSemanticClassifications-full"; + export const Cleanup: protocol.CommandTypes.Cleanup = "cleanup"; + export const OutliningSpans: protocol.CommandTypes.OutliningSpans = "outliningSpans"; + export const TodoComments: protocol.CommandTypes.TodoComments = "todoComments"; + export const Indentation: protocol.CommandTypes.Indentation = "indentation"; + export const DocCommentTemplate: protocol.CommandTypes.DocCommentTemplate = "docCommentTemplate"; + export const CompilerOptionsDiagnosticsFull: protocol.CommandTypes.CompilerOptionsDiagnosticsFull = "compilerOptionsDiagnostics-full"; + export const NameOrDottedNameSpan: protocol.CommandTypes.NameOrDottedNameSpan = "nameOrDottedNameSpan"; + export const BreakpointStatement: protocol.CommandTypes.BreakpointStatement = "breakpointStatement"; + export const CompilerOptionsForInferredProjects: protocol.CommandTypes.CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects"; + export const GetCodeFixes: protocol.CommandTypes.GetCodeFixes = "getCodeFixes"; + export const GetCodeFixesFull: protocol.CommandTypes.GetCodeFixesFull = "getCodeFixes-full"; + export const GetSupportedCodeFixes: protocol.CommandTypes.GetSupportedCodeFixes = "getSupportedCodeFixes"; } export function formatMessage(msg: T, logger: server.Logger, byteLength: (s: string, encoding: string) => number, newLine: string): string { @@ -363,7 +363,7 @@ namespace ts.server { } } - private getEncodedSemanticClassifications(args: protocol.SemanticDiagnosticsRequestArgs) { + private getEncodedSemanticClassifications(args: protocol.EncodedSemanticClassificationsRequestArgs) { const { file, project } = this.getFileAndProject(args); return project.getLanguageService().getEncodedSemanticClassifications(file, args); } @@ -1470,7 +1470,7 @@ namespace ts.server { [CommandNames.BraceCompletion]: (request: protocol.BraceCompletionRequest) => { return this.requiredResponse(this.isValidBraceCompletion(request.arguments)); }, - [CommandNames.DocCommentTemplate]: (request: protocol.FileLocationRequest) => { + [CommandNames.DocCommentTemplate]: (request: protocol.DocCommentTemplateRequest) => { return this.requiredResponse(this.getDocCommentTemplate(request.arguments)); }, [CommandNames.Format]: (request: protocol.FormatRequest) => { @@ -1512,7 +1512,7 @@ namespace ts.server { [CommandNames.CompilerOptionsDiagnosticsFull]: (request: protocol.CompilerOptionsDiagnosticsRequest) => { return this.requiredResponse(this.getCompilerOptionsDiagnostics(request.arguments)); }, - [CommandNames.EncodedSemanticClassificationsFull]: (request: protocol.SemanticDiagnosticsRequest) => { + [CommandNames.EncodedSemanticClassificationsFull]: (request: protocol.EncodedSemanticClassificationsRequest) => { return this.requiredResponse(this.getEncodedSemanticClassifications(request.arguments)); }, [CommandNames.Cleanup]: (request: protocol.Request) => { diff --git a/src/server/tsconfig.json b/src/server/tsconfig.json index 7eb8c28f383..9f907446c03 100644 --- a/src/server/tsconfig.json +++ b/src/server/tsconfig.json @@ -22,7 +22,7 @@ "typingsCache.ts", "project.ts", "editorServices.ts", - "protocol.d.ts", + "protocol.ts", "session.ts", "server.ts" ] diff --git a/src/services/types.ts b/src/services/types.ts index 9797c07b086..3d2bcf4c360 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -403,11 +403,11 @@ namespace ts { export interface EditorSettings { baseIndentSize?: number; - indentSize: number; - tabSize: number; - newLineCharacter: string; - convertTabsToSpaces: boolean; - indentStyle: IndentStyle; + indentSize?: number; + tabSize?: number; + newLineCharacter?: string; + convertTabsToSpaces?: boolean; + indentStyle?: IndentStyle; } /* @deprecated - consider using FormatCodeSettings instead */ @@ -428,19 +428,19 @@ namespace ts { } export interface FormatCodeSettings extends EditorSettings { - insertSpaceAfterCommaDelimiter: boolean; - insertSpaceAfterSemicolonInForStatements: boolean; - insertSpaceBeforeAndAfterBinaryOperators: boolean; - insertSpaceAfterKeywordsInControlFlowStatements: boolean; - insertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean; - insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean; - insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: boolean; + insertSpaceAfterCommaDelimiter?: boolean; + insertSpaceAfterSemicolonInForStatements?: boolean; + insertSpaceBeforeAndAfterBinaryOperators?: boolean; + insertSpaceAfterKeywordsInControlFlowStatements?: boolean; + insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; + insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; + insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean; insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces?: boolean; - insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: boolean; - insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: boolean; + insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; + insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; insertSpaceAfterTypeAssertion?: boolean; - placeOpenBraceOnNewLineForFunctions: boolean; - placeOpenBraceOnNewLineForControlBlocks: boolean; + placeOpenBraceOnNewLineForFunctions?: boolean; + placeOpenBraceOnNewLineForControlBlocks?: boolean; } export interface DefinitionInfo { From c03b04bd4f278dc338ba15017ee8c47b20d96163 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Wed, 12 Oct 2016 14:26:30 -0700 Subject: [PATCH 065/173] Only use localeCompare in CompareStrings --- src/compiler/core.ts | 20 +++++++++++++------- src/harness/harness.ts | 2 +- src/server/session.ts | 2 +- src/services/navigateTo.ts | 4 ++-- src/services/navigationBar.ts | 2 +- 5 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 5ad9fa2c199..47eb66db07c 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -23,6 +23,10 @@ namespace ts { // More efficient to create a collator once and use its `compare` than to call `a.localeCompare(b)` many times. export const collator: { compare(a: string, b: string): number } = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; + // This means "compare in a case insensitive manner but consider accentsor other diacritic marks" + // (e.g. a ≠ b, a ≠ á, a = A) + const accentSensitivity: Intl.CollatorOptions = { usage: "sort", sensitivity: "accent" }; + /** * Use this function instead of calling "String.prototype.localeCompre". This function will preform appropriate check to make sure that * "typeof Intl" is correct as there are reported issues #11110 nad #11339. @@ -1029,13 +1033,13 @@ namespace ts { return a < b ? Comparison.LessThan : Comparison.GreaterThan; } - export function compareStrings(a: string, b: string, ignoreCase?: boolean): Comparison { + export function compareStrings(a: string, b: string, locales?: string | string[], options?: Intl.CollatorOptions): Comparison { if (a === b) return Comparison.EqualTo; if (a === undefined) return Comparison.LessThan; if (b === undefined) return Comparison.GreaterThan; - if (ignoreCase) { - const result = localeCompare(a, b, /*locales*/ undefined, /*options*/ { usage: "sort", sensitivity: "accent" }); - if (result) { + if (options) { + if (collator && String.prototype.localeCompare) { + const result = a.localeCompare(b, locales, options); return result < 0 ? Comparison.LessThan : result > 0 ? Comparison.GreaterThan : Comparison.EqualTo; } @@ -1048,7 +1052,7 @@ namespace ts { } export function compareStringsCaseInsensitive(a: string, b: string) { - return compareStrings(a, b, /*ignoreCase*/ true); + return compareStrings(a, b, /*locales*/ undefined, accentSensitivity); } function getDiagnosticFileName(diagnostic: Diagnostic): string { @@ -1418,7 +1422,8 @@ namespace ts { const bComponents = getNormalizedPathComponents(b, currentDirectory); const sharedLength = Math.min(aComponents.length, bComponents.length); for (let i = 0; i < sharedLength; i++) { - const result = compareStrings(aComponents[i], bComponents[i], ignoreCase); + const result = compareStrings(aComponents[i], bComponents[i], + /*locales*/ undefined, /*options*/ ignoreCase ? accentSensitivity : undefined); if (result !== Comparison.EqualTo) { return result; } @@ -1440,7 +1445,8 @@ namespace ts { } for (let i = 0; i < parentComponents.length; i++) { - const result = compareStrings(parentComponents[i], childComponents[i], ignoreCase); + const result = compareStrings(parentComponents[i], childComponents[i], + /*locales*/ undefined, /*options*/ ignoreCase ? accentSensitivity : undefined); if (result !== Comparison.EqualTo) { return false; } diff --git a/src/harness/harness.ts b/src/harness/harness.ts index f26a9dd062b..9d27257c80f 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1634,7 +1634,7 @@ namespace Harness { export function collateOutputs(outputFiles: Harness.Compiler.GeneratedFile[]): string { // Collect, test, and sort the fileNames - outputFiles.sort((a, b) => ts.localeCompare(cleanName(a.fileName), cleanName(b.fileName))); + outputFiles.sort((a, b) => ts.compareStrings(cleanName(a.fileName), cleanName(b.fileName))); // Emit them let result = ""; diff --git a/src/server/session.ts b/src/server/session.ts index d4633f119e3..cebdef717bc 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -959,7 +959,7 @@ namespace ts.server { result.push({ name, kind, kindModifiers, sortText, replacementSpan: convertedSpan }); } return result; - }, []).sort((a, b) => localeCompare(a.name, b.name)); + }, []).sort((a, b) => ts.compareStrings(a.name, b.name)); } else { return completions; diff --git a/src/services/navigateTo.ts b/src/services/navigateTo.ts index 8c968db7ebb..2433dbe9795 100644 --- a/src/services/navigateTo.ts +++ b/src/services/navigateTo.ts @@ -188,8 +188,8 @@ namespace ts.NavigateTo { // We first sort case insensitively. So "Aaa" will come before "bar". // Then we sort case sensitively, so "aaa" will come before "Aaa". return i1.matchKind - i2.matchKind || - ts.localeCompare(i1.name, i2.name, /*locales*/ undefined, /*options*/ baseSensitivity) || - ts.localeCompare(i1.name, i2.name); + ts.compareStrings(i1.name, i2.name, /*locales*/ undefined, /*options*/ baseSensitivity) || + ts.compareStrings(i1.name, i2.name); } function createNavigateToItem(rawItem: RawNavigateToItem): NavigateToItem { diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index f981ad6016d..4dacf202ef8 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -335,7 +335,7 @@ namespace ts.NavigationBar { if (chA === "'" && chB === "\"") { return -1; } - const cmp = ts.localeCompare(chA.toLocaleLowerCase(), chB.toLocaleLowerCase()); + const cmp = ts.compareStrings(chA.toLocaleLowerCase(), chB.toLocaleLowerCase()); if (cmp !== 0) { return cmp; } From 7bbaef66aec9875c4abf38cb2c5f2aa136d7b7c3 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 12 Oct 2016 15:09:02 -0700 Subject: [PATCH 066/173] Change error message for referencing UMD globals from a module. --- src/compiler/checker.ts | 2 +- src/compiler/diagnosticMessages.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index dfe6317e250..f24d5e3e0cb 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -922,7 +922,7 @@ namespace ts { if (result && isInExternalModule && (meaning & SymbolFlags.Value) === SymbolFlags.Value) { const decls = result.declarations; if (decls && decls.length === 1 && decls[0].kind === SyntaxKind.NamespaceExportDeclaration) { - error(errorLocation, Diagnostics.Identifier_0_must_be_imported_from_a_module, name); + error(errorLocation, Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 58c0e6ee3f2..b99a1a91b8e 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1923,7 +1923,7 @@ "category": "Error", "code": 2685 }, - "Identifier '{0}' must be imported from a module": { + "'{0}' refers to a UMD global, but the current file is a module. Consider adding an import instead.": { "category": "Error", "code": 2686 }, From fbb9d5b148ff1a15d58a023bf5a464e901b0384e Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 12 Oct 2016 15:09:36 -0700 Subject: [PATCH 067/173] Accepted baselines. --- tests/baselines/reference/umd5.errors.txt | 4 ++-- tests/baselines/reference/umd8.errors.txt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/baselines/reference/umd5.errors.txt b/tests/baselines/reference/umd5.errors.txt index 9628ad738db..5595de8de29 100644 --- a/tests/baselines/reference/umd5.errors.txt +++ b/tests/baselines/reference/umd5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/externalModules/a.ts(6,9): error TS2686: Identifier 'Foo' must be imported from a module +tests/cases/conformance/externalModules/a.ts(6,9): error TS2686: 'Foo' refers to a UMD global, but the current file is a module. Consider adding an import instead. ==== tests/cases/conformance/externalModules/a.ts (1 errors) ==== @@ -9,7 +9,7 @@ tests/cases/conformance/externalModules/a.ts(6,9): error TS2686: Identifier 'Foo // should error let z = Foo; ~~~ -!!! error TS2686: Identifier 'Foo' must be imported from a module +!!! error TS2686: 'Foo' refers to a UMD global, but the current file is a module. Consider adding an import instead. ==== tests/cases/conformance/externalModules/foo.d.ts (0 errors) ==== diff --git a/tests/baselines/reference/umd8.errors.txt b/tests/baselines/reference/umd8.errors.txt index 9396c8c5450..26c8adef561 100644 --- a/tests/baselines/reference/umd8.errors.txt +++ b/tests/baselines/reference/umd8.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/externalModules/a.ts(7,14): error TS2686: Identifier 'Foo' must be imported from a module +tests/cases/conformance/externalModules/a.ts(7,14): error TS2686: 'Foo' refers to a UMD global, but the current file is a module. Consider adding an import instead. ==== tests/cases/conformance/externalModules/a.ts (1 errors) ==== @@ -10,7 +10,7 @@ tests/cases/conformance/externalModules/a.ts(7,14): error TS2686: Identifier 'Fo let z: Foo.SubThing; // OK in ns position let x: any = Foo; // Not OK in value position ~~~ -!!! error TS2686: Identifier 'Foo' must be imported from a module +!!! error TS2686: 'Foo' refers to a UMD global, but the current file is a module. Consider adding an import instead. ==== tests/cases/conformance/externalModules/foo.d.ts (0 errors) ==== From e60e97f5c9d7a2c21ba36631c17f9278166feeae Mon Sep 17 00:00:00 2001 From: Andrej Baran Date: Thu, 13 Oct 2016 01:04:38 +0200 Subject: [PATCH 068/173] Cleanup comments --- src/compiler/transformers/es2017.ts | 2 -- src/compiler/transformers/ts.ts | 8 -------- 2 files changed, 10 deletions(-) diff --git a/src/compiler/transformers/es2017.ts b/src/compiler/transformers/es2017.ts index 33376bbceb1..166e1160828 100644 --- a/src/compiler/transformers/es2017.ts +++ b/src/compiler/transformers/es2017.ts @@ -71,8 +71,6 @@ namespace ts { return visitEachChild(node, visitor, context); } - // node = visitEachChild(node, visitor, context); - // return visitEachChild(node, visitor, context); return node; } diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 30276deff92..2aa20410d8c 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -2247,10 +2247,6 @@ namespace ts { } function transformFunctionBody(node: MethodDeclaration | AccessorDeclaration | FunctionDeclaration | FunctionExpression): FunctionBody { - // if (isAsyncFunctionLike(node) && languageVersion < ScriptTarget.ES2017) { - // return transformAsyncFunctionBody(node); - // } - return transformFunctionBodyWorker(node.body); } @@ -2267,10 +2263,6 @@ namespace ts { } function transformConciseBody(node: ArrowFunction): ConciseBody { - // if (isAsyncFunctionLike(node) && languageVersion < ScriptTarget.ES2017) { - // return transformAsyncFunctionBody(node); - // } - return transformConciseBodyWorker(node.body, /*forceBlockFunctionBody*/ false); } From f0fd77ae8edb070e9f01cb0b5f6c69e9454f393a Mon Sep 17 00:00:00 2001 From: Andrej Baran Date: Thu, 13 Oct 2016 11:58:01 +0200 Subject: [PATCH 069/173] Make async/await an ES2017 feature only --- src/compiler/binder.ts | 31 ++++++++---------- src/compiler/transformers/es2017.ts | 13 ++++---- src/compiler/transformers/ts.ts | 49 ++++++----------------------- 3 files changed, 28 insertions(+), 65 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 4edbb5d9e1a..3f5db2ae7c5 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -2555,11 +2555,6 @@ namespace ts { // extends clause of a class. let transformFlags = subtreeFlags | TransformFlags.AssertES6; - // propagate ES2017 - if (node.expression.transformFlags & TransformFlags.ContainsES2017) { - transformFlags |= TransformFlags.ContainsES2017; - } - // If an ExpressionWithTypeArguments contains type arguments, then it // is TypeScript syntax. if (node.typeArguments) { @@ -2591,16 +2586,16 @@ namespace ts { const typeParameters = node.typeParameters; const asteriskToken = node.asteriskToken; - // A MethodDeclaration is TypeScript syntax if it is either async, abstract, overloaded, + // A MethodDeclaration is TypeScript syntax if it is either abstract, overloaded, // generic, or has a decorator. if (!body || typeParameters - || (modifierFlags & (ModifierFlags.Async | ModifierFlags.Abstract)) + || (modifierFlags & ModifierFlags.Abstract) || (subtreeFlags & TransformFlags.ContainsDecorators)) { transformFlags |= TransformFlags.AssertTypeScript; } - // Async MethodDeclaration is ES2017 + // An async method declaration is ES2017 syntax. if (modifierFlags & ModifierFlags.Async) { transformFlags |= TransformFlags.AssertES2017; } @@ -2619,10 +2614,10 @@ namespace ts { const modifierFlags = getModifierFlags(node); const body = node.body; - // A MethodDeclaration is TypeScript syntax if it is either async, abstract, overloaded, + // An accessor is TypeScript syntax if it is either abstract, overloaded, // generic, or has a decorator. if (!body - || (modifierFlags & (ModifierFlags.Async | ModifierFlags.Abstract)) + || (modifierFlags & ModifierFlags.Abstract) || (subtreeFlags & TransformFlags.ContainsDecorators)) { transformFlags |= TransformFlags.AssertTypeScript; } @@ -2664,9 +2659,9 @@ namespace ts { transformFlags |= TransformFlags.AssertTypeScript | TransformFlags.AssertES6; } - // If a FunctionDeclaration is async, then it is TypeScript syntax. + // An async function declaration is ES2017 syntax. if (modifierFlags & ModifierFlags.Async) { - transformFlags |= TransformFlags.AssertTypeScript | TransformFlags.AssertES2017; + transformFlags |= TransformFlags.AssertES2017; } // If a FunctionDeclaration's subtree has marked the container as needing to capture the @@ -2695,9 +2690,9 @@ namespace ts { const modifierFlags = getModifierFlags(node); const asteriskToken = node.asteriskToken; - // An async function expression is TypeScript syntax. + // An async function expression is ES2017 syntax. if (modifierFlags & ModifierFlags.Async) { - transformFlags |= TransformFlags.AssertTypeScript | TransformFlags.AssertES2017; + transformFlags |= TransformFlags.AssertES2017; } // If a FunctionExpression's subtree has marked the container as needing to capture the @@ -2725,9 +2720,9 @@ namespace ts { let transformFlags = subtreeFlags | TransformFlags.AssertES6; const modifierFlags = getModifierFlags(node); - // An async arrow function is TypeScript syntax. + // An async arrow function is ES2017 syntax. if (modifierFlags & ModifierFlags.Async) { - transformFlags |= TransformFlags.AssertTypeScript | TransformFlags.AssertES2017; + transformFlags |= TransformFlags.AssertES2017; } // If an ArrowFunction contains a lexical this, its container must capture the lexical this. @@ -2868,8 +2863,8 @@ namespace ts { switch (kind) { case SyntaxKind.AsyncKeyword: case SyntaxKind.AwaitExpression: - // Typescript async/await are ES2017 features - transformFlags |= TransformFlags.AssertTypeScript | TransformFlags.AssertES2017; + // async/await is ES2017 syntax + transformFlags |= TransformFlags.AssertES2017; break; case SyntaxKind.PublicKeyword: diff --git a/src/compiler/transformers/es2017.ts b/src/compiler/transformers/es2017.ts index 166e1160828..7555c3bdd77 100644 --- a/src/compiler/transformers/es2017.ts +++ b/src/compiler/transformers/es2017.ts @@ -77,26 +77,27 @@ namespace ts { function visitorWorker(node: Node): VisitResult { switch (node.kind) { case SyntaxKind.AsyncKeyword: + // ES2017 async modifier should be elided for targets < ES2017 return undefined; case SyntaxKind.AwaitExpression: - // Typescript 'await' expressions must be transformed for targets < ES2017. + // ES2017 'await' expressions must be transformed for targets < ES2017. return visitAwaitExpression(node); case SyntaxKind.MethodDeclaration: - // TypeScript method declarations may be 'async' + // ES2017 method declarations may be 'async' return visitMethodDeclaration(node); case SyntaxKind.FunctionDeclaration: - // TypeScript function declarations may be 'async' + // ES2017 function declarations may be 'async' return visitFunctionDeclaration(node); case SyntaxKind.FunctionExpression: - // TypeScript function expressions may be 'async' + // ES2017 function expressions may be 'async' return visitFunctionExpression(node); case SyntaxKind.ArrowFunction: - // TypeScript arrow functions may be 'async' + // ES2017 arrow functions may be 'async' return visitArrowFunction(node); default: @@ -160,9 +161,7 @@ namespace ts { * Visits a function declaration. * * This function will be called when one of the following conditions are met: - * - The node is an overload * - The node is marked async - * - The node is exported from a TypeScript namespace * * @param node The function node. */ diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 2aa20410d8c..61f40e1ed80 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -230,10 +230,6 @@ namespace ts { // ES6 export and default modifiers are elided when inside a namespace. return currentNamespace ? undefined : node; - // Typescript ES2017 async/await are handled by ES2017 transformer - case SyntaxKind.AsyncKeyword: - return node; - case SyntaxKind.PublicKeyword: case SyntaxKind.PrivateKeyword: case SyntaxKind.ProtectedKeyword: @@ -297,7 +293,6 @@ namespace ts { // - property declarations // - index signatures // - method overload signatures - // - async methods return visitClassDeclaration(node); case SyntaxKind.ClassExpression: @@ -310,7 +305,6 @@ namespace ts { // - property declarations // - index signatures // - method overload signatures - // - async methods return visitClassExpression(node); case SyntaxKind.HeritageClause: @@ -325,7 +319,7 @@ namespace ts { return visitExpressionWithTypeArguments(node); case SyntaxKind.MethodDeclaration: - // TypeScript method declarations may be 'async', and may have decorators, modifiers + // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); @@ -334,19 +328,19 @@ namespace ts { return visitGetAccessor(node); case SyntaxKind.SetAccessor: - // Set Accessors can have TypeScript modifiers, decorators, and type annotations. + // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); case SyntaxKind.FunctionDeclaration: - // TypeScript function declarations may be 'async' + // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); case SyntaxKind.FunctionExpression: - // TypeScript function expressions may be 'async' + // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); case SyntaxKind.ArrowFunction: - // TypeScript arrow functions may be 'async' + // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); case SyntaxKind.Parameter: @@ -378,10 +372,6 @@ namespace ts { // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case SyntaxKind.AwaitExpression: - // Typescript ES2017 async/await are handled by ES2017 transformer - return visitAwaitExpression(node); - case SyntaxKind.VariableStatement: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); @@ -2050,7 +2040,7 @@ namespace ts { * * This function will be called when one of the following conditions are met: * - The node is an overload - * - The node is marked as abstract, async, public, private, protected, or readonly + * - The node is marked as abstract, public, private, protected, or readonly * - The node has both a decorator and a computed property name * * @param node The method node. @@ -2161,8 +2151,8 @@ namespace ts { * * This function will be called when one of the following conditions are met: * - The node is an overload - * - The node is marked async * - The node is exported from a TypeScript namespace + * - The node has decorators * * @param node The function node. */ @@ -2197,7 +2187,7 @@ namespace ts { * Visits a function expression node. * * This function will be called when one of the following conditions are met: - * - The node is marked async + * - The node has type annotations * * @param node The function expression node. */ @@ -2216,10 +2206,6 @@ namespace ts { /*location*/ node ); - // Keep modifiers in case of async functions - const funcModifiers = visitNodes(node.modifiers, visitor, isModifier); - func.modifiers = createNodeArray(funcModifiers); - setOriginalNode(func, node); return func; @@ -2228,7 +2214,7 @@ namespace ts { /** * @remarks * This function will be called when one of the following conditions are met: - * - The node is marked async + * - The node has type annotations */ function visitArrowFunction(node: ArrowFunction) { const func = createArrowFunction( @@ -2368,23 +2354,6 @@ namespace ts { } } - /** - * Visits an await expression. - * - * This function will be called any time a ES2017 await expression is encountered. - * - * @param node The await expression node. - */ - function visitAwaitExpression(node: AwaitExpression): Expression { - return updateNode( - createAwait( - visitNode(node.expression, visitor, isExpression), - /*location*/ node - ), - node - ); - } - /** * Visits a parenthesized expression that contains either a type assertion or an `as` * expression. From 4284a749b45c441dab54f699e1aa5087527ffeac Mon Sep 17 00:00:00 2001 From: Andrej Baran Date: Thu, 13 Oct 2016 11:32:26 +0200 Subject: [PATCH 070/173] Adjust some async conformance baselines --- .../reference/asyncFunctionDeclaration10_es2017.js | 1 + tests/baselines/reference/asyncFunctionDeclaration10_es5.js | 6 ++++++ tests/baselines/reference/asyncFunctionDeclaration10_es6.js | 3 +++ .../reference/asyncFunctionDeclaration12_es2017.js | 2 +- .../baselines/reference/asyncFunctionDeclaration5_es2017.js | 1 + tests/baselines/reference/asyncFunctionDeclaration5_es5.js | 5 +++++ tests/baselines/reference/asyncFunctionDeclaration5_es6.js | 3 +++ 7 files changed, 20 insertions(+), 1 deletion(-) diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration10_es2017.js index 0e687c1e0d5..f8a22204311 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration10_es2017.js +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es2017.js @@ -3,5 +3,6 @@ async function foo(a = await => await): Promise { } //// [asyncFunctionDeclaration10_es2017.js] +async function foo(a = await ) { } await; Promise < void > {}; diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es5.js b/tests/baselines/reference/asyncFunctionDeclaration10_es5.js index 05ff9daa9da..758bdab5dc9 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration10_es5.js +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es5.js @@ -3,5 +3,11 @@ async function foo(a = await => await): Promise { } //// [asyncFunctionDeclaration10_es5.js] +function foo(a) { + if (a === void 0) { a = yield ; } + return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { + return [2 /*return*/]; + }); }); +} await; Promise < void > {}; diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es6.js b/tests/baselines/reference/asyncFunctionDeclaration10_es6.js index 141c0cbab55..1f175035bf0 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration10_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es6.js @@ -3,5 +3,8 @@ async function foo(a = await => await): Promise { } //// [asyncFunctionDeclaration10_es6.js] +function foo(a = yield ) { + return __awaiter(this, void 0, void 0, function* () { }); +} await; Promise < void > {}; diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration12_es2017.js index 69f5993f5c0..93fbb061023 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration12_es2017.js +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es2017.js @@ -2,4 +2,4 @@ var v = async function await(): Promise { } //// [asyncFunctionDeclaration12_es2017.js] -var v = , await = () => { }; +var v = async function () { }, await = () => { }; diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration5_es2017.js index 13c04c5d5bc..904bbe62f0b 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration5_es2017.js +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es2017.js @@ -3,5 +3,6 @@ async function foo(await): Promise { } //// [asyncFunctionDeclaration5_es2017.js] +async function foo() { } await; Promise < void > {}; diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es5.js b/tests/baselines/reference/asyncFunctionDeclaration5_es5.js index 22c18ff6ad4..5f8f8f42735 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration5_es5.js +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es5.js @@ -3,5 +3,10 @@ async function foo(await): Promise { } //// [asyncFunctionDeclaration5_es5.js] +function foo() { + return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { + return [2 /*return*/]; + }); }); +} await; Promise < void > {}; diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es6.js b/tests/baselines/reference/asyncFunctionDeclaration5_es6.js index 8d28c371465..9521b760415 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration5_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es6.js @@ -3,5 +3,8 @@ async function foo(await): Promise { } //// [asyncFunctionDeclaration5_es6.js] +function foo() { + return __awaiter(this, void 0, void 0, function* () { }); +} await; Promise < void > {}; From 7df3fda2b36e6a1eda5478a9077074e57e35c925 Mon Sep 17 00:00:00 2001 From: Andrej Baran Date: Thu, 13 Oct 2016 12:03:53 +0200 Subject: [PATCH 071/173] Refactor createFunctionExpresson --- src/compiler/factory.ts | 17 +++++++++++------ src/compiler/transformers/es2017.ts | 3 +-- src/compiler/transformers/es6.ts | 5 ++++- src/compiler/transformers/generators.ts | 4 +++- src/compiler/transformers/module/module.ts | 1 + src/compiler/transformers/module/system.ts | 3 +++ src/compiler/transformers/ts.ts | 3 +++ src/compiler/visitor.ts | 3 ++- 8 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index d873c3ef877..519269ccfd0 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -524,9 +524,9 @@ namespace ts { return node; } - export function createFunctionExpression(asteriskToken: Node, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags) { + export function createFunctionExpression(modifiers: Modifier[], asteriskToken: Node, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags) { const node = createNode(SyntaxKind.FunctionExpression, location, flags); - node.modifiers = undefined; + node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; node.name = typeof name === "string" ? createIdentifier(name) : name; node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; @@ -536,9 +536,9 @@ namespace ts { return node; } - export function updateFunctionExpression(node: FunctionExpression, name: Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block) { - if (node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createFunctionExpression(node.asteriskToken, name, typeParameters, parameters, type, body, /*location*/ node, node.flags), node); + export function updateFunctionExpression(node: FunctionExpression, modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block) { + if (node.name !== name || node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { + return updateNode(createFunctionExpression(modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, /*location*/ node, node.flags), node); } return node; } @@ -1735,6 +1735,7 @@ namespace ts { export function createAwaiterHelper(externalHelpersModuleName: Identifier | undefined, hasLexicalArguments: boolean, promiseConstructor: EntityName | Expression, body: Block) { const generatorFunc = createFunctionExpression( + /*modifiers*/ undefined, createNode(SyntaxKind.AsteriskToken), /*name*/ undefined, /*typeParameters*/ undefined, @@ -1908,6 +1909,7 @@ namespace ts { createCall( createParen( createFunctionExpression( + /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, @@ -2089,6 +2091,7 @@ namespace ts { const properties: ObjectLiteralElementLike[] = []; if (getAccessor) { const getterFunction = createFunctionExpression( + getAccessor.modifiers, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, @@ -2104,6 +2107,7 @@ namespace ts { if (setAccessor) { const setterFunction = createFunctionExpression( + setAccessor.modifiers, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, @@ -2170,6 +2174,7 @@ namespace ts { createMemberAccessForPropertyName(receiver, method.name, /*location*/ method.name), setOriginalNode( createFunctionExpression( + method.modifiers, method.asteriskToken, /*name*/ undefined, /*typeParameters*/ undefined, @@ -2909,4 +2914,4 @@ namespace ts { function tryGetModuleNameFromDeclaration(declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration, host: EmitHost, resolver: EmitResolver, compilerOptions: CompilerOptions) { return tryGetModuleNameFromFile(resolver.getExternalModuleFileFromDeclaration(declaration), host, compilerOptions); } -} \ No newline at end of file +} diff --git a/src/compiler/transformers/es2017.ts b/src/compiler/transformers/es2017.ts index 7555c3bdd77..1d3c189110a 100644 --- a/src/compiler/transformers/es2017.ts +++ b/src/compiler/transformers/es2017.ts @@ -202,6 +202,7 @@ namespace ts { } const func = createFunctionExpression( + /*modifiers*/ undefined, node.asteriskToken, node.name, /*typeParameters*/ undefined, @@ -211,8 +212,6 @@ namespace ts { /*location*/ node ); - node.modifiers = visitNodes(node.modifiers, visitor, isModifier); - setOriginalNode(func, node); return func; diff --git a/src/compiler/transformers/es6.ts b/src/compiler/transformers/es6.ts index 7fb0594a6cc..ba5f8a3fb77 100644 --- a/src/compiler/transformers/es6.ts +++ b/src/compiler/transformers/es6.ts @@ -681,6 +681,7 @@ namespace ts { const extendsClauseElement = getClassExtendsHeritageClauseElement(node); const classFunction = createFunctionExpression( + /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, @@ -1509,6 +1510,7 @@ namespace ts { const expression = setOriginalNode( createFunctionExpression( + /*modifiers*/ undefined, node.asteriskToken, name, /*typeParameters*/ undefined, @@ -2240,6 +2242,7 @@ namespace ts { /*type*/ undefined, setEmitFlags( createFunctionExpression( + /*modifiers*/ undefined, isAsyncBlockContainingAwait ? createToken(SyntaxKind.AsteriskToken) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, @@ -3256,4 +3259,4 @@ namespace ts { return isIdentifier(expression) && expression === parameter.name; } } -} \ No newline at end of file +} diff --git a/src/compiler/transformers/generators.ts b/src/compiler/transformers/generators.ts index f3a47f037ca..88788022ef8 100644 --- a/src/compiler/transformers/generators.ts +++ b/src/compiler/transformers/generators.ts @@ -496,6 +496,7 @@ namespace ts { if (node.asteriskToken && getEmitFlags(node) & EmitFlags.AsyncFunctionBody) { node = setOriginalNode( createFunctionExpression( + /*modifiers*/ undefined, /*asteriskToken*/ undefined, node.name, /*typeParameters*/ undefined, @@ -2591,6 +2592,7 @@ namespace ts { createThis(), setEmitFlags( createFunctionExpression( + /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, @@ -3080,4 +3082,4 @@ namespace ts { ); } } -} \ No newline at end of file +} diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index 3877169e6c3..9051f375bf9 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -179,6 +179,7 @@ namespace ts { // // function (require, exports, module1, module2) ... createFunctionExpression( + /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, diff --git a/src/compiler/transformers/module/system.ts b/src/compiler/transformers/module/system.ts index d4ee4f36b87..e7b441f4c9b 100644 --- a/src/compiler/transformers/module/system.ts +++ b/src/compiler/transformers/module/system.ts @@ -110,6 +110,7 @@ namespace ts { const moduleName = tryGetModuleNameFromFile(node, host, compilerOptions); const dependencies = createArrayLiteral(map(dependencyGroups, getNameOfDependencyGroup)); const body = createFunctionExpression( + /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, @@ -244,6 +245,7 @@ namespace ts { ), createPropertyAssignment("execute", createFunctionExpression( + /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, @@ -430,6 +432,7 @@ namespace ts { setters.push( createFunctionExpression( + /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 61f40e1ed80..77ab6a6ca0e 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -2197,6 +2197,7 @@ namespace ts { } const func = createFunctionExpression( + visitNodes(node.modifiers, visitor, isModifier), node.asteriskToken, node.name, /*typeParameters*/ undefined, @@ -2477,6 +2478,7 @@ namespace ts { const enumStatement = createStatement( createCall( createFunctionExpression( + /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, @@ -2748,6 +2750,7 @@ namespace ts { const moduleStatement = createStatement( createCall( createFunctionExpression( + /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index e147eda8535..6910f5aac4d 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -807,6 +807,7 @@ namespace ts { case SyntaxKind.FunctionExpression: return updateFunctionExpression(node, + visitNodes((node).modifiers, visitor, isModifier), visitNode((node).name, visitor, isPropertyName), visitNodes((node).typeParameters, visitor, isTypeParameter), (context.startLexicalEnvironment(), visitNodes((node).parameters, visitor, isParameter)), @@ -1357,4 +1358,4 @@ namespace ts { } } } -} \ No newline at end of file +} From c5ddf27dc68d6dc49a3d6f01e1db35fa6b455b79 Mon Sep 17 00:00:00 2001 From: Andrej Baran Date: Thu, 13 Oct 2016 12:04:36 +0200 Subject: [PATCH 072/173] Remove constant substitution from ES2017 transformer --- src/compiler/transformers/es2017.ts | 32 +---------------------------- 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/src/compiler/transformers/es2017.ts b/src/compiler/transformers/es2017.ts index 1d3c189110a..f9e8b539c6a 100644 --- a/src/compiler/transformers/es2017.ts +++ b/src/compiler/transformers/es2017.ts @@ -395,7 +395,7 @@ namespace ts { } } - return substituteConstantValue(node); + return node; } function substituteElementAccessExpression(node: ElementAccessExpression) { @@ -410,39 +410,9 @@ namespace ts { } } - return substituteConstantValue(node); - } - - function substituteConstantValue(node: PropertyAccessExpression | ElementAccessExpression): LeftHandSideExpression { - const constantValue = tryGetConstEnumValue(node); - if (constantValue !== undefined) { - const substitute = createLiteral(constantValue); - setSourceMapRange(substitute, node); - setCommentRange(substitute, node); - if (!compilerOptions.removeComments) { - const propertyName = isPropertyAccessExpression(node) - ? declarationNameToString(node.name) - : getTextOfNode(node.argumentExpression); - substitute.trailingComment = ` ${propertyName} `; - } - - setConstantValue(node, constantValue); - return substitute; - } - return node; } - function tryGetConstEnumValue(node: Node): number { - if (compilerOptions.isolatedModules) { - return undefined; - } - - return isPropertyAccessExpression(node) || isElementAccessExpression(node) - ? resolver.getConstantValue(node) - : undefined; - } - function substituteCallExpression(node: CallExpression): Expression { const expression = node.expression; if (isSuperProperty(expression)) { From b871b5353c8a9ca6dedd6bc84706fd75ed86bae4 Mon Sep 17 00:00:00 2001 From: Andrej Baran Date: Thu, 13 Oct 2016 13:32:00 +0200 Subject: [PATCH 073/173] Favor use of ES2015 instead of ES6 --- Jakefile.js | 8 +-- src/compiler/binder.ts | 62 +++++++++---------- src/compiler/checker.ts | 42 ++++++------- src/compiler/core.ts | 2 +- src/compiler/emitter.ts | 4 +- src/compiler/factory.ts | 2 +- src/compiler/program.ts | 4 +- src/compiler/transformer.ts | 10 +-- .../transformers/{es6.ts => es2015.ts} | 26 ++++---- src/compiler/transformers/es2017.ts | 4 +- .../transformers/module/{es6.ts => es2015.ts} | 4 +- src/compiler/transformers/module/module.ts | 2 +- src/compiler/transformers/ts.ts | 6 +- src/compiler/tsconfig.json | 4 +- src/compiler/types.ts | 10 +-- src/compiler/utilities.ts | 6 +- src/harness/harness.ts | 2 +- src/harness/tsconfig.json | 4 +- src/harness/unittests/moduleResolution.ts | 2 +- src/services/tsconfig.json | 4 +- src/services/utilities.ts | 2 +- 21 files changed, 105 insertions(+), 105 deletions(-) rename src/compiler/transformers/{es6.ts => es2015.ts} (97%) rename src/compiler/transformers/module/{es6.ts => es2015.ts} (96%) diff --git a/Jakefile.js b/Jakefile.js index 8d46368653c..6f86ef35b09 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -70,14 +70,14 @@ var compilerSources = [ "visitor.ts", "transformers/destructuring.ts", "transformers/ts.ts", - "transformers/module/es6.ts", + "transformers/module/es2015.ts", "transformers/module/system.ts", "transformers/module/module.ts", "transformers/jsx.ts", "transformers/es2017.ts", "transformers/es2016.ts", + "transformers/es2015.ts", "transformers/generators.ts", - "transformers/es6.ts", "transformer.ts", "sourcemap.ts", "comments.ts", @@ -105,14 +105,14 @@ var servicesSources = [ "visitor.ts", "transformers/destructuring.ts", "transformers/ts.ts", - "transformers/module/es6.ts", + "transformers/module/es2015.ts", "transformers/module/system.ts", "transformers/module/module.ts", "transformers/jsx.ts", "transformers/es2017.ts", "transformers/es2016.ts", + "transformers/es2015.ts", "transformers/generators.ts", - "transformers/es6.ts", "transformer.ts", "sourcemap.ts", "comments.ts", diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 3f5db2ae7c5..970e481faaa 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -1636,7 +1636,7 @@ namespace ts { } function checkStrictModeFunctionDeclaration(node: FunctionDeclaration) { - if (languageVersion < ScriptTarget.ES6) { + if (languageVersion < ScriptTarget.ES2015) { // Report error if function is not top level function declaration if (blockScopeContainer.kind !== SyntaxKind.SourceFile && blockScopeContainer.kind !== SyntaxKind.ModuleDeclaration && @@ -2376,7 +2376,7 @@ namespace ts { || isSuperOrSuperProperty(expression, expressionKind)) { // If the this node contains a SpreadElementExpression, or is a super call, then it is an ES6 // node. - transformFlags |= TransformFlags.AssertES6; + transformFlags |= TransformFlags.AssertES2015; } node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; @@ -2407,7 +2407,7 @@ namespace ts { && (leftKind === SyntaxKind.ObjectLiteralExpression || leftKind === SyntaxKind.ArrayLiteralExpression)) { // Destructuring assignments are ES6 syntax. - transformFlags |= TransformFlags.AssertES6 | TransformFlags.DestructuringAssignment; + transformFlags |= TransformFlags.AssertES2015 | TransformFlags.DestructuringAssignment; } else if (operatorTokenKind === SyntaxKind.AsteriskAsteriskToken || operatorTokenKind === SyntaxKind.AsteriskAsteriskEqualsToken) { @@ -2445,7 +2445,7 @@ namespace ts { // If a parameter has an initializer, a binding pattern or a dotDotDot token, then // it is ES6 syntax and its container must emit default value assignments or parameter destructuring downlevel. if (subtreeFlags & TransformFlags.ContainsBindingPattern || initializer || dotDotDotToken) { - transformFlags |= TransformFlags.AssertES6 | TransformFlags.ContainsDefaultValueAssignments; + transformFlags |= TransformFlags.AssertES2015 | TransformFlags.ContainsDefaultValueAssignments; } node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; @@ -2486,7 +2486,7 @@ namespace ts { } else { // A ClassDeclaration is ES6 syntax. - transformFlags = subtreeFlags | TransformFlags.AssertES6; + transformFlags = subtreeFlags | TransformFlags.AssertES2015; // A class with a parameter property assignment, property initializer, or decorator is // TypeScript syntax. @@ -2509,7 +2509,7 @@ namespace ts { function computeClassExpression(node: ClassExpression, subtreeFlags: TransformFlags) { // A ClassExpression is ES6 syntax. - let transformFlags = subtreeFlags | TransformFlags.AssertES6; + let transformFlags = subtreeFlags | TransformFlags.AssertES2015; // A class with a parameter property assignment, property initializer, or decorator is // TypeScript syntax. @@ -2533,7 +2533,7 @@ namespace ts { switch (node.token) { case SyntaxKind.ExtendsKeyword: // An `extends` HeritageClause is ES6 syntax. - transformFlags |= TransformFlags.AssertES6; + transformFlags |= TransformFlags.AssertES2015; break; case SyntaxKind.ImplementsKeyword: @@ -2553,7 +2553,7 @@ namespace ts { function computeExpressionWithTypeArguments(node: ExpressionWithTypeArguments, subtreeFlags: TransformFlags) { // An ExpressionWithTypeArguments is ES6 syntax, as it is used in the // extends clause of a class. - let transformFlags = subtreeFlags | TransformFlags.AssertES6; + let transformFlags = subtreeFlags | TransformFlags.AssertES2015; // If an ExpressionWithTypeArguments contains type arguments, then it // is TypeScript syntax. @@ -2580,7 +2580,7 @@ namespace ts { function computeMethod(node: MethodDeclaration, subtreeFlags: TransformFlags) { // A MethodDeclaration is ES6 syntax. - let transformFlags = subtreeFlags | TransformFlags.AssertES6; + let transformFlags = subtreeFlags | TransformFlags.AssertES2015; const modifierFlags = getModifierFlags(node); const body = node.body; const typeParameters = node.typeParameters; @@ -2656,7 +2656,7 @@ namespace ts { // If a FunctionDeclaration is exported, then it is either ES6 or TypeScript syntax. if (modifierFlags & ModifierFlags.Export) { - transformFlags |= TransformFlags.AssertTypeScript | TransformFlags.AssertES6; + transformFlags |= TransformFlags.AssertTypeScript | TransformFlags.AssertES2015; } // An async function declaration is ES2017 syntax. @@ -2667,8 +2667,8 @@ namespace ts { // If a FunctionDeclaration's subtree has marked the container as needing to capture the // lexical this, or the function contains parameters with initializers, then this node is // ES6 syntax. - if (subtreeFlags & TransformFlags.ES6FunctionSyntaxMask) { - transformFlags |= TransformFlags.AssertES6; + if (subtreeFlags & TransformFlags.ES2015FunctionSyntaxMask) { + transformFlags |= TransformFlags.AssertES2015; } // If a FunctionDeclaration is generator function and is the body of a @@ -2698,8 +2698,8 @@ namespace ts { // If a FunctionExpression's subtree has marked the container as needing to capture the // lexical this, or the function contains parameters with initializers, then this node is // ES6 syntax. - if (subtreeFlags & TransformFlags.ES6FunctionSyntaxMask) { - transformFlags |= TransformFlags.AssertES6; + if (subtreeFlags & TransformFlags.ES2015FunctionSyntaxMask) { + transformFlags |= TransformFlags.AssertES2015; } // If a FunctionExpression is generator function and is the body of a @@ -2717,7 +2717,7 @@ namespace ts { function computeArrowFunction(node: ArrowFunction, subtreeFlags: TransformFlags) { // An ArrowFunction is ES6 syntax, and excludes markers that should not escape the scope of an ArrowFunction. - let transformFlags = subtreeFlags | TransformFlags.AssertES6; + let transformFlags = subtreeFlags | TransformFlags.AssertES2015; const modifierFlags = getModifierFlags(node); // An async arrow function is ES2017 syntax. @@ -2755,7 +2755,7 @@ namespace ts { // A VariableDeclaration with a binding pattern is ES6 syntax. if (nameKind === SyntaxKind.ObjectBindingPattern || nameKind === SyntaxKind.ArrayBindingPattern) { - transformFlags |= TransformFlags.AssertES6 | TransformFlags.ContainsBindingPattern; + transformFlags |= TransformFlags.AssertES2015 | TransformFlags.ContainsBindingPattern; } node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; @@ -2776,11 +2776,11 @@ namespace ts { // If a VariableStatement is exported, then it is either ES6 or TypeScript syntax. if (modifierFlags & ModifierFlags.Export) { - transformFlags |= TransformFlags.AssertES6 | TransformFlags.AssertTypeScript; + transformFlags |= TransformFlags.AssertES2015 | TransformFlags.AssertTypeScript; } if (declarationListTransformFlags & TransformFlags.ContainsBindingPattern) { - transformFlags |= TransformFlags.AssertES6; + transformFlags |= TransformFlags.AssertES2015; } } @@ -2794,7 +2794,7 @@ namespace ts { // A labeled statement containing a block scoped binding *may* need to be transformed from ES6. if (subtreeFlags & TransformFlags.ContainsBlockScopedBinding && isIterationStatement(node, /*lookInLabeledStatements*/ true)) { - transformFlags |= TransformFlags.AssertES6; + transformFlags |= TransformFlags.AssertES2015; } node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; @@ -2820,7 +2820,7 @@ namespace ts { // then we treat the statement as ES6 so that we can indicate that we do not // need to hold on to the right-hand side. if (node.expression.transformFlags & TransformFlags.DestructuringAssignment) { - transformFlags |= TransformFlags.AssertES6; + transformFlags |= TransformFlags.AssertES2015; } node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; @@ -2843,12 +2843,12 @@ namespace ts { let transformFlags = subtreeFlags | TransformFlags.ContainsHoistedDeclarationOrCompletion; if (subtreeFlags & TransformFlags.ContainsBindingPattern) { - transformFlags |= TransformFlags.AssertES6; + transformFlags |= TransformFlags.AssertES2015; } // If a VariableDeclarationList is `let` or `const`, then it is ES6 syntax. if (node.flags & NodeFlags.BlockScoped) { - transformFlags |= TransformFlags.AssertES6 | TransformFlags.ContainsBlockScopedBinding; + transformFlags |= TransformFlags.AssertES2015 | TransformFlags.ContainsBlockScopedBinding; } node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; @@ -2897,7 +2897,7 @@ namespace ts { case SyntaxKind.ExportKeyword: // This node is both ES6 and TypeScript syntax. - transformFlags |= TransformFlags.AssertES6 | TransformFlags.AssertTypeScript; + transformFlags |= TransformFlags.AssertES2015 | TransformFlags.AssertTypeScript; break; case SyntaxKind.DefaultKeyword: @@ -2910,12 +2910,12 @@ namespace ts { case SyntaxKind.ShorthandPropertyAssignment: case SyntaxKind.ForOfStatement: // These nodes are ES6 syntax. - transformFlags |= TransformFlags.AssertES6; + transformFlags |= TransformFlags.AssertES2015; break; case SyntaxKind.YieldExpression: // This node is ES6 syntax. - transformFlags |= TransformFlags.AssertES6 | TransformFlags.ContainsYield; + transformFlags |= TransformFlags.AssertES2015 | TransformFlags.ContainsYield; break; case SyntaxKind.AnyKeyword: @@ -2976,7 +2976,7 @@ namespace ts { case SyntaxKind.SuperKeyword: // This node is ES6 syntax. - transformFlags |= TransformFlags.AssertES6; + transformFlags |= TransformFlags.AssertES2015; break; case SyntaxKind.ThisKeyword: @@ -2987,7 +2987,7 @@ namespace ts { case SyntaxKind.ObjectBindingPattern: case SyntaxKind.ArrayBindingPattern: // These nodes are ES6 syntax. - transformFlags |= TransformFlags.AssertES6 | TransformFlags.ContainsBindingPattern; + transformFlags |= TransformFlags.AssertES2015 | TransformFlags.ContainsBindingPattern; break; case SyntaxKind.Decorator: @@ -3000,7 +3000,7 @@ namespace ts { if (subtreeFlags & TransformFlags.ContainsComputedPropertyName) { // If an ObjectLiteralExpression contains a ComputedPropertyName, then it // is an ES6 node. - transformFlags |= TransformFlags.AssertES6; + transformFlags |= TransformFlags.AssertES2015; } if (subtreeFlags & TransformFlags.ContainsLexicalThisInComputedPropertyName) { @@ -3017,7 +3017,7 @@ namespace ts { if (subtreeFlags & TransformFlags.ContainsSpreadElementExpression) { // If the this node contains a SpreadElementExpression, then it is an ES6 // node. - transformFlags |= TransformFlags.AssertES6; + transformFlags |= TransformFlags.AssertES2015; } break; @@ -3028,14 +3028,14 @@ namespace ts { case SyntaxKind.ForInStatement: // A loop containing a block scoped binding *may* need to be transformed from ES6. if (subtreeFlags & TransformFlags.ContainsBlockScopedBinding) { - transformFlags |= TransformFlags.AssertES6; + transformFlags |= TransformFlags.AssertES2015; } break; case SyntaxKind.SourceFile: if (subtreeFlags & TransformFlags.ContainsCapturedLexicalThis) { - transformFlags |= TransformFlags.AssertES6; + transformFlags |= TransformFlags.AssertES2015; } break; diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 0b5c3963079..cecf2964f3c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3189,7 +3189,7 @@ namespace ts { const elements = pattern.elements; const lastElement = lastOrUndefined(elements); if (elements.length === 0 || (!isOmittedExpression(lastElement) && lastElement.dotDotDotToken)) { - return languageVersion >= ScriptTarget.ES6 ? createIterableType(anyType) : anyArrayType; + return languageVersion >= ScriptTarget.ES2015 ? createIterableType(anyType) : anyArrayType; } // If the pattern has at least one element, and no rest element, then it should imply a tuple type. const elementTypes = map(elements, e => isOmittedExpression(e) ? anyType : getTypeFromBindingElement(e, includePatternInType, reportErrors)); @@ -9059,7 +9059,7 @@ namespace ts { // can explicitly bound arguments objects if (symbol === argumentsSymbol) { const container = getContainingFunction(node); - if (languageVersion < ScriptTarget.ES6) { + if (languageVersion < ScriptTarget.ES2015) { if (container.kind === SyntaxKind.ArrowFunction) { error(node, Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } @@ -9084,7 +9084,7 @@ namespace ts { // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. - if (languageVersion === ScriptTarget.ES6 + if (languageVersion === ScriptTarget.ES2015 && declaration.kind === SyntaxKind.ClassDeclaration && nodeIsDecorated(declaration)) { let container = getContainingClass(node); @@ -9173,7 +9173,7 @@ namespace ts { } function checkNestedBlockScopedBinding(node: Identifier, symbol: Symbol): void { - if (languageVersion >= ScriptTarget.ES6 || + if (languageVersion >= ScriptTarget.ES2015 || (symbol.flags & (SymbolFlags.BlockScopedVariable | SymbolFlags.Class)) === 0 || symbol.valueDeclaration.parent.kind === SyntaxKind.CatchClause) { return; @@ -9339,7 +9339,7 @@ namespace ts { container = 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 < ScriptTarget.ES6); + needToCaptureLexicalThis = (languageVersion < ScriptTarget.ES2015); } switch (container.kind) { @@ -9447,7 +9447,7 @@ namespace ts { if (!isCallExpression) { while (container && container.kind === SyntaxKind.ArrowFunction) { container = getSuperContainer(container, /*stopOnFunctions*/ true); - needToCaptureLexicalThis = languageVersion < ScriptTarget.ES6; + needToCaptureLexicalThis = languageVersion < ScriptTarget.ES2015; } } @@ -9561,7 +9561,7 @@ namespace ts { } if (container.parent.kind === SyntaxKind.ObjectLiteralExpression) { - if (languageVersion < ScriptTarget.ES6) { + if (languageVersion < ScriptTarget.ES2015) { error(node, Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return unknownType; } @@ -9929,7 +9929,7 @@ namespace ts { const index = indexOf(arrayLiteral.elements, node); return getTypeOfPropertyOfContextualType(type, "" + index) || getIndexTypeOfContextualType(type, IndexKind.Number) - || (languageVersion >= ScriptTarget.ES6 ? getElementTypeOfIterable(type, /*errorNode*/ undefined) : undefined); + || (languageVersion >= ScriptTarget.ES2015 ? getElementTypeOfIterable(type, /*errorNode*/ undefined) : undefined); } return undefined; } @@ -10162,7 +10162,7 @@ namespace ts { // if there is no index type / iterated type. const restArrayType = checkExpression((e).expression, contextualMapper); const restElementType = getIndexTypeOfType(restArrayType, IndexKind.Number) || - (languageVersion >= ScriptTarget.ES6 ? getElementTypeOfIterable(restArrayType, /*errorNode*/ undefined) : undefined); + (languageVersion >= ScriptTarget.ES2015 ? getElementTypeOfIterable(restArrayType, /*errorNode*/ undefined) : undefined); if (restElementType) { elementTypes.push(restElementType); } @@ -10909,7 +10909,7 @@ namespace 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 (languageVersion < ScriptTarget.ES6 && getDeclarationKindFromSymbol(prop) !== SyntaxKind.MethodDeclaration) { + if (languageVersion < ScriptTarget.ES2015 && getDeclarationKindFromSymbol(prop) !== SyntaxKind.MethodDeclaration) { // `prop` refers to a *property* declared in the super class // rather than a *method*, so it does not satisfy the above criteria. @@ -14228,7 +14228,7 @@ namespace ts { } if (node.type) { - if (languageVersion >= ScriptTarget.ES6 && isSyntacticallyValidGenerator(node)) { + if (languageVersion >= ScriptTarget.ES2015 && isSyntacticallyValidGenerator(node)) { const returnType = getTypeFromTypeNode(node.type); if (returnType === voidType) { error(node.type, Diagnostics.A_generator_cannot_have_a_void_type_annotation); @@ -15189,7 +15189,7 @@ namespace ts { * callable `then` signature. */ function checkAsyncFunctionReturnType(node: FunctionLikeDeclaration): Type { - if (languageVersion >= ScriptTarget.ES6) { + if (languageVersion >= ScriptTarget.ES2015) { const returnType = getTypeFromTypeNode(node.type); return checkCorrectPromiseType(returnType, node.type, Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type); } @@ -15722,7 +15722,7 @@ namespace ts { function checkCollisionWithRequireExportsInGeneratedCode(node: Node, name: Identifier) { // No need to check for require or exports for ES6 modules and later - if (modulekind >= ModuleKind.ES6) { + if (modulekind >= ModuleKind.ES2015) { return; } @@ -16214,7 +16214,7 @@ namespace ts { if (isTypeAny(inputType)) { return inputType; } - if (languageVersion >= ScriptTarget.ES6) { + if (languageVersion >= ScriptTarget.ES2015) { return checkElementTypeOfIterable(inputType, errorNode); } if (allowStringInput) { @@ -16392,7 +16392,7 @@ namespace ts { * 2. Some constituent is a string and target is less than ES5 (because in ES3 string is not indexable). */ function checkElementTypeOfArrayOrString(arrayOrStringType: Type, errorNode: Node): Type { - Debug.assert(languageVersion < ScriptTarget.ES6); + Debug.assert(languageVersion < ScriptTarget.ES2015); // After we remove all types that are StringLike, we will know if there was a string constituent // based on whether the remaining type is the same as the initial type. @@ -17700,7 +17700,7 @@ namespace ts { } } else { - if (modulekind === ModuleKind.ES6 && !isInAmbientContext(node)) { + if (modulekind === ModuleKind.ES2015 && !isInAmbientContext(node)) { // Import equals declaration is deprecated in es6 or above grammarErrorOnNode(node, Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } @@ -17788,7 +17788,7 @@ namespace ts { checkExternalModuleExports(container); if (node.isExportEquals && !isInAmbientContext(node)) { - if (modulekind === ModuleKind.ES6) { + if (modulekind === ModuleKind.ES2015) { // export assignment is not supported in es6 modules grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_export_default_or_another_module_format_instead); } @@ -19296,7 +19296,7 @@ namespace ts { getGlobalTemplateStringsArrayType = memoize(() => getGlobalType("TemplateStringsArray")); - if (languageVersion >= ScriptTarget.ES6) { + if (languageVersion >= ScriptTarget.ES2015) { getGlobalESSymbolType = memoize(() => getGlobalType("Symbol")); getGlobalIterableType = memoize(() => getGlobalType("Iterable", /*arity*/ 1)); getGlobalIteratorType = memoize(() => getGlobalType("Iterator", /*arity*/ 1)); @@ -19329,7 +19329,7 @@ namespace ts { // If we found the module, report errors if it does not have the necessary exports. if (helpersModule) { const exports = helpersModule.exports; - if (requestedExternalEmitHelpers & NodeFlags.HasClassExtends && languageVersion < ScriptTarget.ES6) { + if (requestedExternalEmitHelpers & NodeFlags.HasClassExtends && languageVersion < ScriptTarget.ES2015) { verifyHelperSymbol(exports, "__extends", SymbolFlags.Value); } if (requestedExternalEmitHelpers & NodeFlags.HasJsxSpreadAttributes && compilerOptions.jsx !== JsxEmit.Preserve) { @@ -19346,7 +19346,7 @@ namespace ts { } if (requestedExternalEmitHelpers & NodeFlags.HasAsyncFunctions) { verifyHelperSymbol(exports, "__awaiter", SymbolFlags.Value); - if (languageVersion < ScriptTarget.ES6) { + if (languageVersion < ScriptTarget.ES2015) { verifyHelperSymbol(exports, "__generator", SymbolFlags.Value); } } @@ -19923,7 +19923,7 @@ namespace ts { if (!node.body) { return grammarErrorOnNode(node.asteriskToken, Diagnostics.An_overload_signature_cannot_be_declared_as_a_generator); } - if (languageVersion < ScriptTarget.ES6) { + if (languageVersion < ScriptTarget.ES2015) { return grammarErrorOnNode(node.asteriskToken, Diagnostics.Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher); } } diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 3f2cc619cb3..3f60ec62c2b 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1191,7 +1191,7 @@ namespace ts { export function getEmitModuleKind(compilerOptions: CompilerOptions) { return typeof compilerOptions.module === "number" ? compilerOptions.module : - getEmitScriptTarget(compilerOptions) >= ScriptTarget.ES6 ? ModuleKind.ES6 : ModuleKind.CommonJS; + getEmitScriptTarget(compilerOptions) >= ScriptTarget.ES2015 ? ModuleKind.ES2015 : ModuleKind.CommonJS; } /* @internal */ diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index a3f69e2fd4b..734fe2778e5 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2165,7 +2165,7 @@ const _super = (function (geti, seti) { // Only Emit __extends function when target ES5. // For target ES6 and above, we can emit classDeclaration as is. - if ((languageVersion < ScriptTarget.ES6) && (!extendsEmitted && node.flags & NodeFlags.HasClassExtends)) { + if ((languageVersion < ScriptTarget.ES2015) && (!extendsEmitted && node.flags & NodeFlags.HasClassExtends)) { writeLines(extendsHelper); extendsEmitted = true; helpersEmitted = true; @@ -2197,7 +2197,7 @@ const _super = (function (geti, seti) { // For target ES2017 and above, we can emit async/await as is. if ((languageVersion < ScriptTarget.ES2017) && (!awaiterEmitted && node.flags & NodeFlags.HasAsyncFunctions)) { writeLines(awaiterHelper); - if (languageVersion < ScriptTarget.ES6) { + if (languageVersion < ScriptTarget.ES2015) { writeLines(generatorHelper); } diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 519269ccfd0..57007619c62 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -1985,7 +1985,7 @@ namespace ts { } else if (callee.kind === SyntaxKind.SuperKeyword) { thisArg = createThis(); - target = languageVersion < ScriptTarget.ES6 ? createIdentifier("_super", /*location*/ callee) : callee; + target = languageVersion < ScriptTarget.ES2015 ? createIdentifier("_super", /*location*/ callee) : callee; } else { switch (callee.kind) { diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 5d46038b2b1..dfe65fc0860 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1478,7 +1478,7 @@ namespace ts { const firstNonAmbientExternalModuleSourceFile = forEach(files, f => isExternalModule(f) && !isDeclarationFile(f) ? f : undefined); if (options.isolatedModules) { - if (options.module === ModuleKind.None && languageVersion < ScriptTarget.ES6) { + if (options.module === ModuleKind.None && languageVersion < ScriptTarget.ES2015) { programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher)); } @@ -1488,7 +1488,7 @@ namespace ts { programDiagnostics.add(createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided)); } } - else if (firstNonAmbientExternalModuleSourceFile && languageVersion < ScriptTarget.ES6 && options.module === ModuleKind.None) { + else if (firstNonAmbientExternalModuleSourceFile && languageVersion < ScriptTarget.ES2015 && options.module === ModuleKind.None) { // We cannot use createDiagnosticFromNode because nodes do not have parents yet const span = getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, firstNonAmbientExternalModuleSourceFile.externalModuleIndicator); programDiagnostics.add(createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none)); diff --git a/src/compiler/transformer.ts b/src/compiler/transformer.ts index 55b83ea669d..fc656e08bf9 100644 --- a/src/compiler/transformer.ts +++ b/src/compiler/transformer.ts @@ -3,16 +3,16 @@ /// /// /// -/// +/// /// /// /// -/// +/// /* @internal */ namespace ts { const moduleTransformerMap = createMap({ - [ModuleKind.ES6]: transformES6Module, + [ModuleKind.ES2015]: transformES2015Module, [ModuleKind.System]: transformSystemModule, [ModuleKind.AMD]: transformModule, [ModuleKind.CommonJS]: transformModule, @@ -124,8 +124,8 @@ namespace ts { transformers.push(transformES2016); } - if (languageVersion < ScriptTarget.ES6) { - transformers.push(transformES6); + if (languageVersion < ScriptTarget.ES2015) { + transformers.push(transformES2015); transformers.push(transformGenerators); } diff --git a/src/compiler/transformers/es6.ts b/src/compiler/transformers/es2015.ts similarity index 97% rename from src/compiler/transformers/es6.ts rename to src/compiler/transformers/es2015.ts index ba5f8a3fb77..101c34a8199 100644 --- a/src/compiler/transformers/es6.ts +++ b/src/compiler/transformers/es2015.ts @@ -4,7 +4,7 @@ /*@internal*/ namespace ts { - const enum ES6SubstitutionFlags { + const enum ES2015SubstitutionFlags { /** Enables substitutions for captured `this` */ CapturedThis = 1 << 0, /** Enables substitutions for block-scoped bindings. */ @@ -163,7 +163,7 @@ namespace ts { ReplaceWithReturn, } - export function transformES6(context: TransformationContext) { + export function transformES2015(context: TransformationContext) { const { startLexicalEnvironment, endLexicalEnvironment, @@ -197,7 +197,7 @@ namespace ts { * They are persisted between each SourceFile transformation and should not * be reset. */ - let enabledSubstitutions: ES6SubstitutionFlags; + let enabledSubstitutions: ES2015SubstitutionFlags; return transformSourceFile; @@ -252,7 +252,7 @@ namespace ts { } function shouldCheckNode(node: Node): boolean { - return (node.transformFlags & TransformFlags.ES6) !== 0 || + return (node.transformFlags & TransformFlags.ES2015) !== 0 || node.kind === SyntaxKind.LabeledStatement || (isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)); } @@ -261,7 +261,7 @@ namespace ts { if (shouldCheckNode(node)) { return visitJavaScript(node); } - else if (node.transformFlags & TransformFlags.ContainsES6) { + else if (node.transformFlags & TransformFlags.ContainsES2015) { return visitEachChild(node, visitor, context); } else { @@ -3037,7 +3037,7 @@ namespace ts { function onEmitNode(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void) { const savedEnclosingFunction = enclosingFunction; - if (enabledSubstitutions & ES6SubstitutionFlags.CapturedThis && isFunctionLike(node)) { + if (enabledSubstitutions & ES2015SubstitutionFlags.CapturedThis && isFunctionLike(node)) { // If we are tracking a captured `this`, keep track of the enclosing function. enclosingFunction = node; } @@ -3052,8 +3052,8 @@ namespace ts { * contains block-scoped bindings (e.g. `let` or `const`). */ function enableSubstitutionsForBlockScopedBindings() { - if ((enabledSubstitutions & ES6SubstitutionFlags.BlockScopedBindings) === 0) { - enabledSubstitutions |= ES6SubstitutionFlags.BlockScopedBindings; + if ((enabledSubstitutions & ES2015SubstitutionFlags.BlockScopedBindings) === 0) { + enabledSubstitutions |= ES2015SubstitutionFlags.BlockScopedBindings; context.enableSubstitution(SyntaxKind.Identifier); } } @@ -3063,8 +3063,8 @@ namespace ts { * contains a captured `this`. */ function enableSubstitutionsForCapturedThis() { - if ((enabledSubstitutions & ES6SubstitutionFlags.CapturedThis) === 0) { - enabledSubstitutions |= ES6SubstitutionFlags.CapturedThis; + if ((enabledSubstitutions & ES2015SubstitutionFlags.CapturedThis) === 0) { + enabledSubstitutions |= ES2015SubstitutionFlags.CapturedThis; context.enableSubstitution(SyntaxKind.ThisKeyword); context.enableEmitNotification(SyntaxKind.Constructor); context.enableEmitNotification(SyntaxKind.MethodDeclaration); @@ -3103,7 +3103,7 @@ namespace ts { function substituteIdentifier(node: Identifier) { // Only substitute the identifier if we have enabled substitutions for block-scoped // bindings. - if (enabledSubstitutions & ES6SubstitutionFlags.BlockScopedBindings) { + if (enabledSubstitutions & ES2015SubstitutionFlags.BlockScopedBindings) { const original = getParseTreeNode(node, isIdentifier); if (original && isNameOfDeclarationWithCollidingName(original)) { return getGeneratedNameForNode(original); @@ -3156,7 +3156,7 @@ namespace ts { * @param node An Identifier node. */ function substituteExpressionIdentifier(node: Identifier): Identifier { - if (enabledSubstitutions & ES6SubstitutionFlags.BlockScopedBindings) { + if (enabledSubstitutions & ES2015SubstitutionFlags.BlockScopedBindings) { const declaration = resolver.getReferencedDeclarationWithCollidingName(node); if (declaration) { return getGeneratedNameForNode(declaration.name); @@ -3172,7 +3172,7 @@ namespace ts { * @param node The ThisKeyword node. */ function substituteThisKeyword(node: PrimaryExpression): PrimaryExpression { - if (enabledSubstitutions & ES6SubstitutionFlags.CapturedThis + if (enabledSubstitutions & ES2015SubstitutionFlags.CapturedThis && enclosingFunction && getEmitFlags(enclosingFunction) & EmitFlags.CapturesThis) { return createIdentifier("_this", /*location*/ node); diff --git a/src/compiler/transformers/es2017.ts b/src/compiler/transformers/es2017.ts index f9e8b539c6a..7800a41e147 100644 --- a/src/compiler/transformers/es2017.ts +++ b/src/compiler/transformers/es2017.ts @@ -263,7 +263,7 @@ namespace ts { function transformAsyncFunctionBody(node: FunctionLikeDeclaration): ConciseBody | FunctionBody { const nodeType = node.original ? (node.original).type : node.type; - const promiseConstructor = languageVersion < ScriptTarget.ES6 ? getPromiseConstructor(nodeType) : undefined; + const promiseConstructor = languageVersion < ScriptTarget.ES2015 ? getPromiseConstructor(nodeType) : undefined; const isArrowFunction = node.kind === SyntaxKind.ArrowFunction; const hasLexicalArguments = (resolver.getNodeCheckFlags(node) & NodeCheckFlags.CaptureArguments) !== 0; @@ -292,7 +292,7 @@ namespace ts { // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. - if (languageVersion >= ScriptTarget.ES6) { + if (languageVersion >= ScriptTarget.ES2015) { if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.AsyncMethodWithSuperBinding) { enableSubstitutionForAsyncMethodsWithSuper(); setEmitFlags(block, EmitFlags.EmitAdvancedSuperHelper); diff --git a/src/compiler/transformers/module/es6.ts b/src/compiler/transformers/module/es2015.ts similarity index 96% rename from src/compiler/transformers/module/es6.ts rename to src/compiler/transformers/module/es2015.ts index 09a2890727c..b06acd2d091 100644 --- a/src/compiler/transformers/module/es6.ts +++ b/src/compiler/transformers/module/es2015.ts @@ -3,7 +3,7 @@ /*@internal*/ namespace ts { - export function transformES6Module(context: TransformationContext) { + export function transformES2015Module(context: TransformationContext) { const compilerOptions = context.getCompilerOptions(); const resolver = context.getEmitResolver(); @@ -141,4 +141,4 @@ namespace ts { return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } } -} \ No newline at end of file +} diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index 9051f375bf9..989efbfd53f 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -416,7 +416,7 @@ namespace ts { ) ], /*location*/ undefined, - /*flags*/ languageVersion >= ScriptTarget.ES6 ? NodeFlags.Const : NodeFlags.None), + /*flags*/ languageVersion >= ScriptTarget.ES2015 ? NodeFlags.Const : NodeFlags.None), /*location*/ node ) ); diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 77ab6a6ca0e..868c371e00f 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -1777,7 +1777,7 @@ namespace ts { return createIdentifier("Number"); case SyntaxKind.SymbolKeyword: - return languageVersion < ScriptTarget.ES6 + return languageVersion < ScriptTarget.ES2015 ? getGlobalSymbolNameWithFallback() : createIdentifier("Symbol"); @@ -1843,7 +1843,7 @@ namespace ts { return createIdentifier("Array"); case TypeReferenceSerializationKind.ESSymbolType: - return languageVersion < ScriptTarget.ES6 + return languageVersion < ScriptTarget.ES2015 ? getGlobalSymbolNameWithFallback() : createIdentifier("Symbol"); @@ -2592,7 +2592,7 @@ namespace ts { function isES6ExportedDeclaration(node: Node) { return isExternalModuleExport(node) - && moduleKind === ModuleKind.ES6; + && moduleKind === ModuleKind.ES2015; } /** diff --git a/src/compiler/tsconfig.json b/src/compiler/tsconfig.json index de710e74a46..da356c0b4d3 100644 --- a/src/compiler/tsconfig.json +++ b/src/compiler/tsconfig.json @@ -26,12 +26,12 @@ "transformers/jsx.ts", "transformers/es2017.ts", "transformers/es2016.ts", - "transformers/es6.ts", + "transformers/es2015.ts", "transformers/generators.ts", "transformers/destructuring.ts", "transformers/module/module.ts", "transformers/module/system.ts", - "transformers/module/es6.ts", + "transformers/module/es2015.ts", "transformer.ts", "comments.ts", "sourcemap.ts", diff --git a/src/compiler/types.ts b/src/compiler/types.ts index b89887cafa0..55200b29676 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3123,8 +3123,8 @@ namespace ts { ContainsES2017 = 1 << 5, ES2016 = 1 << 6, ContainsES2016 = 1 << 7, - ES6 = 1 << 8, - ContainsES6 = 1 << 9, + ES2015 = 1 << 8, + ContainsES2015 = 1 << 9, DestructuringAssignment = 1 << 10, Generator = 1 << 11, ContainsGenerator = 1 << 12, @@ -3153,13 +3153,13 @@ namespace ts { AssertJsx = Jsx | ContainsJsx, AssertES2017 = ES2017 | ContainsES2017, AssertES2016 = ES2016 | ContainsES2016, - AssertES6 = ES6 | ContainsES6, + AssertES2015 = ES2015 | ContainsES2015, AssertGenerator = Generator | ContainsGenerator, // Scope Exclusions // - Bitmasks that exclude flags from propagating out of a specific context // into the subtree flags of their container. - NodeExcludes = TypeScript | Jsx | ES2017 | ES2016 | ES6 | DestructuringAssignment | Generator | HasComputedFlags, + NodeExcludes = TypeScript | Jsx | ES2017 | ES2016 | ES2015 | DestructuringAssignment | Generator | HasComputedFlags, ArrowFunctionExcludes = NodeExcludes | ContainsDecorators | ContainsDefaultValueAssignments | ContainsLexicalThis | ContainsParameterPropertyAssignments | ContainsBlockScopedBinding | ContainsYield | ContainsHoistedDeclarationOrCompletion, FunctionExcludes = NodeExcludes | ContainsDecorators | ContainsDefaultValueAssignments | ContainsCapturedLexicalThis | ContainsLexicalThis | ContainsParameterPropertyAssignments | ContainsBlockScopedBinding | ContainsYield | ContainsHoistedDeclarationOrCompletion, ConstructorExcludes = NodeExcludes | ContainsDefaultValueAssignments | ContainsLexicalThis | ContainsCapturedLexicalThis | ContainsBlockScopedBinding | ContainsYield | ContainsHoistedDeclarationOrCompletion, @@ -3175,7 +3175,7 @@ namespace ts { // Masks // - Additional bitmasks TypeScriptClassSyntaxMask = ContainsParameterPropertyAssignments | ContainsPropertyInitializer | ContainsDecorators, - ES6FunctionSyntaxMask = ContainsCapturedLexicalThis | ContainsDefaultValueAssignments, + ES2015FunctionSyntaxMask = ContainsCapturedLexicalThis | ContainsDefaultValueAssignments, } /* @internal */ diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 92ce6ecc6a4..e10ab6a8add 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -337,7 +337,7 @@ namespace ts { export function getLiteralText(node: LiteralLikeNode, sourceFile: SourceFile, languageVersion: ScriptTarget) { // Any template literal or string literal with an extended escape // (e.g. "\u{0067}") will need to be downleveled as a escaped string literal. - if (languageVersion < ScriptTarget.ES6 && (isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { + if (languageVersion < ScriptTarget.ES2015 && (isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { return getQuotedEscapedLiteralText('"', node.text, '"'); } @@ -345,7 +345,7 @@ namespace ts { // the node's parent reference, then simply get the text as it was originally written. if (!nodeIsSynthesized(node) && node.parent) { const text = getSourceTextOfNodeFromSourceFile(sourceFile, node); - if (languageVersion < ScriptTarget.ES6 && isBinaryOrOctalIntegerLiteral(node, text)) { + if (languageVersion < ScriptTarget.ES2015 && isBinaryOrOctalIntegerLiteral(node, text)) { return node.text; } return text; @@ -4146,7 +4146,7 @@ namespace ts { return "lib.es2017.d.ts"; case ScriptTarget.ES2016: return "lib.es2016.d.ts"; - case ScriptTarget.ES6: + case ScriptTarget.ES2015: return "lib.es2015.d.ts"; default: diff --git a/src/harness/harness.ts b/src/harness/harness.ts index c50f33a74c3..3b45d6d61e5 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -946,7 +946,7 @@ namespace Harness { return "lib.es2017.d.ts"; case ts.ScriptTarget.ES2016: return "lib.es2016.d.ts"; - case ts.ScriptTarget.ES6: + case ts.ScriptTarget.ES2015: return es2015DefaultLibFileName; default: diff --git a/src/harness/tsconfig.json b/src/harness/tsconfig.json index c8b90645ce2..5d7a81d1a74 100644 --- a/src/harness/tsconfig.json +++ b/src/harness/tsconfig.json @@ -28,12 +28,12 @@ "../compiler/transformers/jsx.ts", "../compiler/transformers/es2017.ts", "../compiler/transformers/es2016.ts", - "../compiler/transformers/es6.ts", + "../compiler/transformers/es2015.ts", "../compiler/transformers/generators.ts", "../compiler/transformers/destructuring.ts", "../compiler/transformers/module/module.ts", "../compiler/transformers/module/system.ts", - "../compiler/transformers/module/es6.ts", + "../compiler/transformers/module/es2015.ts", "../compiler/transformer.ts", "../compiler/comments.ts", "../compiler/sourcemap.ts", diff --git a/src/harness/unittests/moduleResolution.ts b/src/harness/unittests/moduleResolution.ts index 3e1ac171216..b2f7d0c224d 100644 --- a/src/harness/unittests/moduleResolution.ts +++ b/src/harness/unittests/moduleResolution.ts @@ -1017,7 +1017,7 @@ import b = require("./moduleB"); const files = [f1, f2, f3, f4]; const names = map(files, f => f.name); - const sourceFiles = arrayToMap(map(files, f => createSourceFile(f.name, f.content, ScriptTarget.ES6)), f => f.fileName); + const sourceFiles = arrayToMap(map(files, f => createSourceFile(f.name, f.content, ScriptTarget.ES2015)), f => f.fileName); const compilerHost: CompilerHost = { fileExists : fileName => fileName in sourceFiles, getSourceFile: fileName => sourceFiles[fileName], diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index 45e3c9036e0..c9428d9a082 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -27,12 +27,12 @@ "../compiler/transformers/jsx.ts", "../compiler/transformers/es2017.ts", "../compiler/transformers/es2016.ts", - "../compiler/transformers/es6.ts", + "../compiler/transformers/es2015.ts", "../compiler/transformers/generators.ts", "../compiler/transformers/destructuring.ts", "../compiler/transformers/module/module.ts", "../compiler/transformers/module/system.ts", - "../compiler/transformers/module/es6.ts", + "../compiler/transformers/module/es2015.ts", "../compiler/transformer.ts", "../compiler/comments.ts", "../compiler/sourcemap.ts", diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 829048fc081..e61906b4f09 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -1339,7 +1339,7 @@ namespace ts { const options: TranspileOptions = { fileName: "config.js", compilerOptions: { - target: ScriptTarget.ES6, + target: ScriptTarget.ES2015, removeComments: true }, reportDiagnostics: true From 7dd64d3ea26c9642ffa8e1f82bd0568b664403ae Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 13 Oct 2016 06:29:34 -0700 Subject: [PATCH 074/173] Properly narrow union types containing string and number --- src/compiler/checker.ts | 32 ++++++++++++++++++++++++-------- src/compiler/types.ts | 2 +- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6555710137a..dffe4244e39 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8461,6 +8461,28 @@ namespace ts { return f(type) ? type : neverType; } + function mapType(type: Type, f: (t: Type) => Type): Type { + return type.flags & TypeFlags.Union ? getUnionType(map((type).types, f)) : f(type); + } + + function extractTypesOfKind(type: Type, kind: TypeFlags) { + return filterType(type, t => (t.flags & kind) !== 0); + } + + // Return a new type in which occurrences of the string and number primitive types in + // typeWithPrimitives have been replaced with occurrences of string literals and numeric + // literals in typeWithLiterals, respectively. + function replacePrimitivesWithLiterals(typeWithPrimitives: Type, typeWithLiterals: Type) { + if (isTypeSubsetOf(stringType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, TypeFlags.StringLiteral) || + isTypeSubsetOf(numberType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, TypeFlags.NumberLiteral)) { + return mapType(typeWithPrimitives, t => + t.flags & TypeFlags.String ? extractTypesOfKind(typeWithLiterals, TypeFlags.String | TypeFlags.StringLiteral) : + t.flags & TypeFlags.Number ? extractTypesOfKind(typeWithLiterals, TypeFlags.Number | TypeFlags.NumberLiteral) : + t); + } + return typeWithPrimitives; + } + function isIncomplete(flowType: FlowType) { return flowType.flags === 0; } @@ -8791,16 +8813,12 @@ namespace ts { assumeTrue ? TypeFacts.EQUndefined : TypeFacts.NEUndefined; return getTypeWithFacts(type, facts); } - if (type.flags & TypeFlags.String && isTypeOfKind(valueType, TypeFlags.StringLiteral) || - type.flags & TypeFlags.Number && isTypeOfKind(valueType, TypeFlags.NumberLiteral)) { - return assumeTrue? valueType : type; - } if (type.flags & TypeFlags.NotUnionOrUnit) { return type; } if (assumeTrue) { const narrowedType = filterType(type, t => areTypesComparable(t, valueType)); - return narrowedType.flags & TypeFlags.Never ? type : narrowedType; + return narrowedType.flags & TypeFlags.Never ? type : replacePrimitivesWithLiterals(narrowedType, valueType); } if (isUnitType(valueType)) { const regularType = getRegularTypeOfLiteralType(valueType); @@ -8849,9 +8867,7 @@ namespace ts { const discriminantType = getUnionType(clauseTypes); const caseType = discriminantType.flags & TypeFlags.Never ? neverType : - type.flags & TypeFlags.String && isTypeOfKind(discriminantType, TypeFlags.StringLiteral) ? discriminantType : - type.flags & TypeFlags.Number && isTypeOfKind(discriminantType, TypeFlags.NumberLiteral) ? discriminantType : - filterType(type, t => isTypeComparableTo(discriminantType, t)); + replacePrimitivesWithLiterals(filterType(type, t => isTypeComparableTo(discriminantType, t)), discriminantType); if (!hasDefaultClause) { return caseType; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 638504e613f..ba11b35459b 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2644,7 +2644,7 @@ namespace ts { // 'Narrowable' types are types where narrowing actually narrows. // This *should* be every type other than null, undefined, void, and never Narrowable = Any | StructuredType | TypeParameter | StringLike | NumberLike | BooleanLike | ESSymbol, - NotUnionOrUnit = Any | String | Number | ESSymbol | ObjectType, + NotUnionOrUnit = Any | ESSymbol | ObjectType, /* @internal */ RequiresWidening = ContainsWideningType | ContainsObjectLiteral, /* @internal */ From 57a9a6344a64f5a5a15fb1b98b2cef4acdcc620b Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 13 Oct 2016 06:31:28 -0700 Subject: [PATCH 075/173] Accept new baselines --- .../reference/declFileTypeAnnotationStringLiteral.types | 2 +- tests/baselines/reference/literalTypes1.types | 8 ++++---- tests/baselines/reference/sourceMapValidationIfElse.types | 6 +++--- tests/baselines/reference/sourceMapValidationSwitch.types | 8 ++++---- tests/baselines/reference/sourceMapValidationWhile.types | 4 ++-- .../reference/stringLiteralTypesInUnionTypes02.types | 6 +++--- .../baselines/reference/throwInEnclosingStatements.types | 2 +- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/tests/baselines/reference/declFileTypeAnnotationStringLiteral.types b/tests/baselines/reference/declFileTypeAnnotationStringLiteral.types index 6d9c17b4ab9..b1a85f3fc30 100644 --- a/tests/baselines/reference/declFileTypeAnnotationStringLiteral.types +++ b/tests/baselines/reference/declFileTypeAnnotationStringLiteral.types @@ -23,7 +23,7 @@ function foo(a: string): string | number { return a.length; >a.length : number ->a : string +>a : "hello" >length : number } diff --git a/tests/baselines/reference/literalTypes1.types b/tests/baselines/reference/literalTypes1.types index faff485d45a..1baaad3ff88 100644 --- a/tests/baselines/reference/literalTypes1.types +++ b/tests/baselines/reference/literalTypes1.types @@ -129,7 +129,7 @@ function f4(x: 0 | 1 | true | string) { >"def" : "def" x; ->x : string +>x : "abc" | "def" break; case null: @@ -163,7 +163,7 @@ function f5(x: string | number | boolean) { >"abc" : "abc" x; ->x : string +>x : "abc" break; case 0: @@ -173,7 +173,7 @@ function f5(x: string | number | boolean) { >1 : 1 x; ->x : number +>x : 0 | 1 break; case true: @@ -190,7 +190,7 @@ function f5(x: string | number | boolean) { >123 : 123 x; ->x : string | number +>x : "hello" | 123 break; default: diff --git a/tests/baselines/reference/sourceMapValidationIfElse.types b/tests/baselines/reference/sourceMapValidationIfElse.types index b4a76d55647..87103b792e7 100644 --- a/tests/baselines/reference/sourceMapValidationIfElse.types +++ b/tests/baselines/reference/sourceMapValidationIfElse.types @@ -10,7 +10,7 @@ if (i == 10) { i++; >i++ : number ->i : number +>i : 10 } else { @@ -22,7 +22,7 @@ if (i == 10) { i++; >i++ : number ->i : number +>i : 10 } else if (i == 20) { >i == 20 : boolean @@ -31,7 +31,7 @@ else if (i == 20) { i--; >i-- : number ->i : number +>i : 20 } else if (i == 30) { >i == 30 : boolean diff --git a/tests/baselines/reference/sourceMapValidationSwitch.types b/tests/baselines/reference/sourceMapValidationSwitch.types index 9df86ee2132..359cabbfabe 100644 --- a/tests/baselines/reference/sourceMapValidationSwitch.types +++ b/tests/baselines/reference/sourceMapValidationSwitch.types @@ -11,7 +11,7 @@ switch (x) { x++; >x++ : number ->x : number +>x : 5 break; case 10: @@ -19,7 +19,7 @@ switch (x) { { x--; >x-- : number ->x : number +>x : 10 break; } @@ -39,7 +39,7 @@ switch (x) x++; >x++ : number ->x : number +>x : 5 break; case 10: @@ -47,7 +47,7 @@ switch (x) { x--; >x-- : number ->x : number +>x : 10 break; } diff --git a/tests/baselines/reference/sourceMapValidationWhile.types b/tests/baselines/reference/sourceMapValidationWhile.types index 71b50d86736..8769d98ef25 100644 --- a/tests/baselines/reference/sourceMapValidationWhile.types +++ b/tests/baselines/reference/sourceMapValidationWhile.types @@ -10,7 +10,7 @@ while (a == 10) { a++; >a++ : number ->a : number +>a : 10 } while (a == 10) >a == 10 : boolean @@ -19,5 +19,5 @@ while (a == 10) { a++; >a++ : number ->a : number +>a : 10 } diff --git a/tests/baselines/reference/stringLiteralTypesInUnionTypes02.types b/tests/baselines/reference/stringLiteralTypesInUnionTypes02.types index 0be891ade44..85378108298 100644 --- a/tests/baselines/reference/stringLiteralTypesInUnionTypes02.types +++ b/tests/baselines/reference/stringLiteralTypesInUnionTypes02.types @@ -19,7 +19,7 @@ if (x === "foo") { let a = x; >a : string ->x : string +>x : "foo" } else if (x !== "bar") { >x !== "bar" : boolean @@ -35,7 +35,7 @@ else if (x !== "bar") { else { let c = x; >c : string ->x : string +>x : "bar" let d = y; >d : string @@ -43,7 +43,7 @@ else { let e: (typeof x) | (typeof y) = c || d; >e : string ->x : string +>x : "bar" >y : string >c || d : string >c : string diff --git a/tests/baselines/reference/throwInEnclosingStatements.types b/tests/baselines/reference/throwInEnclosingStatements.types index 4955b9243ae..2d99ac435ae 100644 --- a/tests/baselines/reference/throwInEnclosingStatements.types +++ b/tests/baselines/reference/throwInEnclosingStatements.types @@ -25,7 +25,7 @@ switch (y) { >'a' : "a" throw y; ->y : string +>y : "a" default: throw y; From 8bcb22c56d389ece0d1997d084ee50c7ac4d8b42 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 13 Oct 2016 06:40:16 -0700 Subject: [PATCH 076/173] Add tests --- tests/baselines/reference/literalTypes3.js | 125 +++++++++++++ .../baselines/reference/literalTypes3.symbols | 137 ++++++++++++++ tests/baselines/reference/literalTypes3.types | 177 ++++++++++++++++++ .../types/literal/literalTypes3.ts | 66 +++++++ 4 files changed, 505 insertions(+) create mode 100644 tests/baselines/reference/literalTypes3.js create mode 100644 tests/baselines/reference/literalTypes3.symbols create mode 100644 tests/baselines/reference/literalTypes3.types create mode 100644 tests/cases/conformance/types/literal/literalTypes3.ts diff --git a/tests/baselines/reference/literalTypes3.js b/tests/baselines/reference/literalTypes3.js new file mode 100644 index 00000000000..1989bb1d5a1 --- /dev/null +++ b/tests/baselines/reference/literalTypes3.js @@ -0,0 +1,125 @@ +//// [literalTypes3.ts] + +function f1(s: string) { + if (s === "foo") { + s; // "foo" + } + if (s === "foo" || s === "bar") { + s; // "foo" | "bar" + } +} + +function f2(s: string) { + switch (s) { + case "foo": + case "bar": + s; // "foo" | "bar" + case "baz": + s; // "foo" | "bar" | "baz" + break; + default: + s; // string + } +} + +function f3(s: string) { + return s === "foo" || s === "bar" ? s : undefined; // "foo" | "bar" | undefined +} + +function f4(x: number) { + if (x === 1 || x === 2) { + return x; // 1 | 2 + } + throw new Error(); +} + +function f5(x: number, y: 1 | 2) { + if (x === 0 || x === y) { + x; // 0 | 1 | 2 + } +} + +function f6(x: number, y: 1 | 2) { + if (y === x || 0 === x) { + x; // 0 | 1 | 2 + } +} + +function f7(x: number | "foo" | "bar", y: 1 | 2 | string) { + if (x === y) { + x; // "foo" | "bar" | 1 | 2 + } +} + +function f8(x: number | "foo" | "bar") { + switch (x) { + case 1: + case 2: + x; // 1 | 2 + break; + case "foo": + x; // "foo" + break; + default: + x; // number | "bar" + } +} + +//// [literalTypes3.js] +function f1(s) { + if (s === "foo") { + s; // "foo" + } + if (s === "foo" || s === "bar") { + s; // "foo" | "bar" + } +} +function f2(s) { + switch (s) { + case "foo": + case "bar": + s; // "foo" | "bar" + case "baz": + s; // "foo" | "bar" | "baz" + break; + default: + s; // string + } +} +function f3(s) { + return s === "foo" || s === "bar" ? s : undefined; // "foo" | "bar" | undefined +} +function f4(x) { + if (x === 1 || x === 2) { + return x; // 1 | 2 + } + throw new Error(); +} +function f5(x, y) { + if (x === 0 || x === y) { + x; // 0 | 1 | 2 + } +} +function f6(x, y) { + if (y === x || 0 === x) { + x; // 0 | 1 | 2 + } +} +function f7(x, y) { + if (x === y) { + x; // "foo" | "bar" | 1 | 2 + } +} +function f8(x) { + switch (x) { + case 1: + case 2: + x; // 1 | 2 + break; + case "foo": + x; // "foo" + break; + default: + x; // number | "bar" + } +} diff --git a/tests/baselines/reference/literalTypes3.symbols b/tests/baselines/reference/literalTypes3.symbols new file mode 100644 index 00000000000..6cc7ab007e6 --- /dev/null +++ b/tests/baselines/reference/literalTypes3.symbols @@ -0,0 +1,137 @@ +=== tests/cases/conformance/types/literal/literalTypes3.ts === + +function f1(s: string) { +>f1 : Symbol(f1, Decl(literalTypes3.ts, 0, 0)) +>s : Symbol(s, Decl(literalTypes3.ts, 1, 12)) + + if (s === "foo") { +>s : Symbol(s, Decl(literalTypes3.ts, 1, 12)) + + s; // "foo" +>s : Symbol(s, Decl(literalTypes3.ts, 1, 12)) + } + if (s === "foo" || s === "bar") { +>s : Symbol(s, Decl(literalTypes3.ts, 1, 12)) +>s : Symbol(s, Decl(literalTypes3.ts, 1, 12)) + + s; // "foo" | "bar" +>s : Symbol(s, Decl(literalTypes3.ts, 1, 12)) + } +} + +function f2(s: string) { +>f2 : Symbol(f2, Decl(literalTypes3.ts, 8, 1)) +>s : Symbol(s, Decl(literalTypes3.ts, 10, 12)) + + switch (s) { +>s : Symbol(s, Decl(literalTypes3.ts, 10, 12)) + + case "foo": + case "bar": + s; // "foo" | "bar" +>s : Symbol(s, Decl(literalTypes3.ts, 10, 12)) + + case "baz": + s; // "foo" | "bar" | "baz" +>s : Symbol(s, Decl(literalTypes3.ts, 10, 12)) + + break; + default: + s; // string +>s : Symbol(s, Decl(literalTypes3.ts, 10, 12)) + } +} + +function f3(s: string) { +>f3 : Symbol(f3, Decl(literalTypes3.ts, 21, 1)) +>s : Symbol(s, Decl(literalTypes3.ts, 23, 12)) + + return s === "foo" || s === "bar" ? s : undefined; // "foo" | "bar" | undefined +>s : Symbol(s, Decl(literalTypes3.ts, 23, 12)) +>s : Symbol(s, Decl(literalTypes3.ts, 23, 12)) +>s : Symbol(s, Decl(literalTypes3.ts, 23, 12)) +>undefined : Symbol(undefined) +} + +function f4(x: number) { +>f4 : Symbol(f4, Decl(literalTypes3.ts, 25, 1)) +>x : Symbol(x, Decl(literalTypes3.ts, 27, 12)) + + if (x === 1 || x === 2) { +>x : Symbol(x, Decl(literalTypes3.ts, 27, 12)) +>x : Symbol(x, Decl(literalTypes3.ts, 27, 12)) + + return x; // 1 | 2 +>x : Symbol(x, Decl(literalTypes3.ts, 27, 12)) + } + throw new Error(); +>Error : Symbol(Error, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +} + +function f5(x: number, y: 1 | 2) { +>f5 : Symbol(f5, Decl(literalTypes3.ts, 32, 1)) +>x : Symbol(x, Decl(literalTypes3.ts, 34, 12)) +>y : Symbol(y, Decl(literalTypes3.ts, 34, 22)) + + if (x === 0 || x === y) { +>x : Symbol(x, Decl(literalTypes3.ts, 34, 12)) +>x : Symbol(x, Decl(literalTypes3.ts, 34, 12)) +>y : Symbol(y, Decl(literalTypes3.ts, 34, 22)) + + x; // 0 | 1 | 2 +>x : Symbol(x, Decl(literalTypes3.ts, 34, 12)) + } +} + +function f6(x: number, y: 1 | 2) { +>f6 : Symbol(f6, Decl(literalTypes3.ts, 38, 1)) +>x : Symbol(x, Decl(literalTypes3.ts, 40, 12)) +>y : Symbol(y, Decl(literalTypes3.ts, 40, 22)) + + if (y === x || 0 === x) { +>y : Symbol(y, Decl(literalTypes3.ts, 40, 22)) +>x : Symbol(x, Decl(literalTypes3.ts, 40, 12)) +>x : Symbol(x, Decl(literalTypes3.ts, 40, 12)) + + x; // 0 | 1 | 2 +>x : Symbol(x, Decl(literalTypes3.ts, 40, 12)) + } +} + +function f7(x: number | "foo" | "bar", y: 1 | 2 | string) { +>f7 : Symbol(f7, Decl(literalTypes3.ts, 44, 1)) +>x : Symbol(x, Decl(literalTypes3.ts, 46, 12)) +>y : Symbol(y, Decl(literalTypes3.ts, 46, 38)) + + if (x === y) { +>x : Symbol(x, Decl(literalTypes3.ts, 46, 12)) +>y : Symbol(y, Decl(literalTypes3.ts, 46, 38)) + + x; // "foo" | "bar" | 1 | 2 +>x : Symbol(x, Decl(literalTypes3.ts, 46, 12)) + } +} + +function f8(x: number | "foo" | "bar") { +>f8 : Symbol(f8, Decl(literalTypes3.ts, 50, 1)) +>x : Symbol(x, Decl(literalTypes3.ts, 52, 12)) + + switch (x) { +>x : Symbol(x, Decl(literalTypes3.ts, 52, 12)) + + case 1: + case 2: + x; // 1 | 2 +>x : Symbol(x, Decl(literalTypes3.ts, 52, 12)) + + break; + case "foo": + x; // "foo" +>x : Symbol(x, Decl(literalTypes3.ts, 52, 12)) + + break; + default: + x; // number | "bar" +>x : Symbol(x, Decl(literalTypes3.ts, 52, 12)) + } +} diff --git a/tests/baselines/reference/literalTypes3.types b/tests/baselines/reference/literalTypes3.types new file mode 100644 index 00000000000..6161bc4b72a --- /dev/null +++ b/tests/baselines/reference/literalTypes3.types @@ -0,0 +1,177 @@ +=== tests/cases/conformance/types/literal/literalTypes3.ts === + +function f1(s: string) { +>f1 : (s: string) => void +>s : string + + if (s === "foo") { +>s === "foo" : boolean +>s : string +>"foo" : "foo" + + s; // "foo" +>s : "foo" + } + if (s === "foo" || s === "bar") { +>s === "foo" || s === "bar" : boolean +>s === "foo" : boolean +>s : string +>"foo" : "foo" +>s === "bar" : boolean +>s : string +>"bar" : "bar" + + s; // "foo" | "bar" +>s : "foo" | "bar" + } +} + +function f2(s: string) { +>f2 : (s: string) => void +>s : string + + switch (s) { +>s : string + + case "foo": +>"foo" : "foo" + + case "bar": +>"bar" : "bar" + + s; // "foo" | "bar" +>s : "foo" | "bar" + + case "baz": +>"baz" : "baz" + + s; // "foo" | "bar" | "baz" +>s : "foo" | "bar" | "baz" + + break; + default: + s; // string +>s : string + } +} + +function f3(s: string) { +>f3 : (s: string) => "foo" | "bar" | undefined +>s : string + + return s === "foo" || s === "bar" ? s : undefined; // "foo" | "bar" | undefined +>s === "foo" || s === "bar" ? s : undefined : "foo" | "bar" | undefined +>s === "foo" || s === "bar" : boolean +>s === "foo" : boolean +>s : string +>"foo" : "foo" +>s === "bar" : boolean +>s : string +>"bar" : "bar" +>s : "foo" | "bar" +>undefined : undefined +} + +function f4(x: number) { +>f4 : (x: number) => 1 | 2 +>x : number + + if (x === 1 || x === 2) { +>x === 1 || x === 2 : boolean +>x === 1 : boolean +>x : number +>1 : 1 +>x === 2 : boolean +>x : number +>2 : 2 + + return x; // 1 | 2 +>x : 1 | 2 + } + throw new Error(); +>new Error() : Error +>Error : ErrorConstructor +} + +function f5(x: number, y: 1 | 2) { +>f5 : (x: number, y: 1 | 2) => void +>x : number +>y : 1 | 2 + + if (x === 0 || x === y) { +>x === 0 || x === y : boolean +>x === 0 : boolean +>x : number +>0 : 0 +>x === y : boolean +>x : number +>y : 1 | 2 + + x; // 0 | 1 | 2 +>x : 1 | 2 | 0 + } +} + +function f6(x: number, y: 1 | 2) { +>f6 : (x: number, y: 1 | 2) => void +>x : number +>y : 1 | 2 + + if (y === x || 0 === x) { +>y === x || 0 === x : boolean +>y === x : boolean +>y : 1 | 2 +>x : number +>0 === x : boolean +>0 : 0 +>x : number + + x; // 0 | 1 | 2 +>x : 1 | 2 | 0 + } +} + +function f7(x: number | "foo" | "bar", y: 1 | 2 | string) { +>f7 : (x: number | "foo" | "bar", y: string | 1 | 2) => void +>x : number | "foo" | "bar" +>y : string | 1 | 2 + + if (x === y) { +>x === y : boolean +>x : number | "foo" | "bar" +>y : string | 1 | 2 + + x; // "foo" | "bar" | 1 | 2 +>x : "foo" | "bar" | 1 | 2 + } +} + +function f8(x: number | "foo" | "bar") { +>f8 : (x: number | "foo" | "bar") => void +>x : number | "foo" | "bar" + + switch (x) { +>x : number | "foo" | "bar" + + case 1: +>1 : 1 + + case 2: +>2 : 2 + + x; // 1 | 2 +>x : 1 | 2 + + break; + case "foo": +>"foo" : "foo" + + x; // "foo" +>x : "foo" + + break; + default: + x; // number | "bar" +>x : number | "bar" + } +} diff --git a/tests/cases/conformance/types/literal/literalTypes3.ts b/tests/cases/conformance/types/literal/literalTypes3.ts new file mode 100644 index 00000000000..2aa3f1020e2 --- /dev/null +++ b/tests/cases/conformance/types/literal/literalTypes3.ts @@ -0,0 +1,66 @@ +// @strictNullChecks: true + +function f1(s: string) { + if (s === "foo") { + s; // "foo" + } + if (s === "foo" || s === "bar") { + s; // "foo" | "bar" + } +} + +function f2(s: string) { + switch (s) { + case "foo": + case "bar": + s; // "foo" | "bar" + case "baz": + s; // "foo" | "bar" | "baz" + break; + default: + s; // string + } +} + +function f3(s: string) { + return s === "foo" || s === "bar" ? s : undefined; // "foo" | "bar" | undefined +} + +function f4(x: number) { + if (x === 1 || x === 2) { + return x; // 1 | 2 + } + throw new Error(); +} + +function f5(x: number, y: 1 | 2) { + if (x === 0 || x === y) { + x; // 0 | 1 | 2 + } +} + +function f6(x: number, y: 1 | 2) { + if (y === x || 0 === x) { + x; // 0 | 1 | 2 + } +} + +function f7(x: number | "foo" | "bar", y: 1 | 2 | string) { + if (x === y) { + x; // "foo" | "bar" | 1 | 2 + } +} + +function f8(x: number | "foo" | "bar") { + switch (x) { + case 1: + case 2: + x; // 1 | 2 + break; + case "foo": + x; // "foo" + break; + default: + x; // number | "bar" + } +} \ No newline at end of file From 1dedca73d120e396fa710c782d2a3bf59252d732 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 13 Oct 2016 09:43:55 -0700 Subject: [PATCH 077/173] Support 'unshift' and fix typo --- src/compiler/binder.ts | 2 +- src/compiler/checker.ts | 18 ++++++++++-------- src/compiler/types.ts | 2 +- src/compiler/utilities.ts | 4 ++++ 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 6926403d9bb..65d620f9233 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -1217,7 +1217,7 @@ namespace ts { } if (node.expression.kind === SyntaxKind.PropertyAccessExpression) { const propertyAccess = node.expression; - if (isNarrowableOperand(propertyAccess.expression) && propertyAccess.name.text === "push") { + if (isNarrowableOperand(propertyAccess.expression) && isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); } } diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9e2b7a31748..7bec343c91e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8405,8 +8405,10 @@ namespace ts { } function isEmptyArrayAssignment(node: VariableDeclaration | BindingElement | Expression) { - return node.kind === SyntaxKind.VariableDeclaration && (node).initializer && isEmptyArrayLiteral((node).initializer) || - node.kind !== SyntaxKind.BindingElement && node.parent.kind === SyntaxKind.BinaryExpression && isEmptyArrayLiteral((node.parent).right); + return node.kind === SyntaxKind.VariableDeclaration && (node).initializer && + isEmptyArrayLiteral((node).initializer) || + node.kind !== SyntaxKind.BindingElement && node.parent.kind === SyntaxKind.BinaryExpression && + isEmptyArrayLiteral((node.parent).right); } function getReferenceCandidate(node: Expression): Expression { @@ -8562,12 +8564,12 @@ namespace ts { getUnionType(sameMap(types, finalizeEvolvingArrayType), subtypeReduction); } - // Return true if the given node is 'x' in an 'x.push(value)' operation. - function isPushCallTarget(node: Node) { + // Return true if the given node is 'x' in an 'x.push(value)' or 'x.unshift(value)' operation. + function isPushOrUnshiftCallTarget(node: Node) { const parent = getReferenceRoot(node).parent; return parent.kind === SyntaxKind.PropertyAccessExpression && - (parent).name.text === "push" && - parent.parent.kind === SyntaxKind.CallExpression; + parent.parent.kind === SyntaxKind.CallExpression && + isPushOrUnshiftIdentifier((parent).name); } // Return true if the given node is 'x' in an 'x[n] = value' operation, where 'n' is an @@ -8596,9 +8598,9 @@ namespace ts { const evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); visitedFlowCount = visitedFlowStart; // When the reference is 'x' in an 'x.push(value)' or 'x[n] = value' operation, we give type - // 'any[]' to 'x' instead of using the type determed by control flow analysis such that new + // 'any[]' to 'x' instead of using the type determined by control flow analysis such that new // element types are not considered errors. - const isEvolvingArrayInferenceTarget = isEvolvingArrayType(evolvedType) && (isPushCallTarget(reference) || isElementAssignmentTarget(reference)); + const isEvolvingArrayInferenceTarget = isEvolvingArrayType(evolvedType) && (isPushOrUnshiftCallTarget(reference) || isElementAssignmentTarget(reference)); const resultType = isEvolvingArrayInferenceTarget ? anyArrayType : finalizeEvolvingArrayType(evolvedType); if (reference.parent.kind === SyntaxKind.NonNullExpression && getTypeWithFacts(resultType, TypeFacts.NEUndefinedOrNull).flags & TypeFlags.Never) { return declaredType; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 5c32649d97c..ff7618c8e37 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1953,7 +1953,7 @@ namespace ts { } // FlowArrayMutation represents a node potentially mutates an array, i.e. an - // operation of the form 'x.push(value)' or 'x[n] = value'. + // operation of the form 'x.push(value)', 'x.unshift(value)' or 'x[n] = value'. export interface FlowArrayMutation extends FlowNode { node: CallExpression | BinaryExpression; antecedent: FlowNode; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 558015bb0e3..6e7dd8702f7 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1895,6 +1895,10 @@ namespace ts { return node.kind === SyntaxKind.Identifier && (node).text === "Symbol"; } + export function isPushOrUnshiftIdentifier(node: Identifier) { + return node.text === "push" || node.text === "unshift"; + } + export function isModifierKind(token: SyntaxKind): boolean { switch (token) { case SyntaxKind.AbstractKeyword: From 620b3f91e11e00a65ad024127d8964988875922a Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 13 Oct 2016 09:44:37 -0700 Subject: [PATCH 078/173] Fix test --- tests/baselines/reference/implicitAnyWidenToAny.errors.txt | 2 +- tests/baselines/reference/implicitAnyWidenToAny.js | 4 ++-- tests/cases/compiler/implicitAnyWidenToAny.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/baselines/reference/implicitAnyWidenToAny.errors.txt b/tests/baselines/reference/implicitAnyWidenToAny.errors.txt index 7a9314d982f..4302211d9a0 100644 --- a/tests/baselines/reference/implicitAnyWidenToAny.errors.txt +++ b/tests/baselines/reference/implicitAnyWidenToAny.errors.txt @@ -8,7 +8,7 @@ tests/cases/compiler/implicitAnyWidenToAny.ts(4,5): error TS7005: Variable 'wide var widenArray = [null, undefined]; // error at "widenArray" ~~~~~~~~~~ !!! error TS7005: Variable 'widenArray' implicitly has an 'any[]' type. - var emptyArray = []; // error at "emptyArray" + var emptyArray = []; // these should not be error class AnimalObj { diff --git a/tests/baselines/reference/implicitAnyWidenToAny.js b/tests/baselines/reference/implicitAnyWidenToAny.js index 0779a166744..0d1c42ad9d0 100644 --- a/tests/baselines/reference/implicitAnyWidenToAny.js +++ b/tests/baselines/reference/implicitAnyWidenToAny.js @@ -3,7 +3,7 @@ var x = null; // error at "x" var x1 = undefined; // error at "x1" var widenArray = [null, undefined]; // error at "widenArray" -var emptyArray = []; // error at "emptyArray" +var emptyArray = []; // these should not be error class AnimalObj { @@ -32,7 +32,7 @@ var obj1 = anyReturnFunc(); var x = null; // error at "x" var x1 = undefined; // error at "x1" var widenArray = [null, undefined]; // error at "widenArray" -var emptyArray = []; // error at "emptyArray" +var emptyArray = []; // these should not be error var AnimalObj = (function () { function AnimalObj() { diff --git a/tests/cases/compiler/implicitAnyWidenToAny.ts b/tests/cases/compiler/implicitAnyWidenToAny.ts index b4f4b5eb312..dcbabd38b47 100644 --- a/tests/cases/compiler/implicitAnyWidenToAny.ts +++ b/tests/cases/compiler/implicitAnyWidenToAny.ts @@ -3,7 +3,7 @@ var x = null; // error at "x" var x1 = undefined; // error at "x1" var widenArray = [null, undefined]; // error at "widenArray" -var emptyArray = []; // error at "emptyArray" +var emptyArray = []; // these should not be error class AnimalObj { From a27a68f8eb67557a9a2eda50501aa0c40c20699f Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 13 Oct 2016 09:44:50 -0700 Subject: [PATCH 079/173] Add additional tests --- .../baselines/reference/controlFlowArrays.js | 30 +++++++++ .../reference/controlFlowArrays.symbols | 48 ++++++++++++++ .../reference/controlFlowArrays.types | 64 +++++++++++++++++++ tests/cases/compiler/controlFlowArrays.ts | 16 +++++ 4 files changed, 158 insertions(+) diff --git a/tests/baselines/reference/controlFlowArrays.js b/tests/baselines/reference/controlFlowArrays.js index d6f387ab981..b2d3fa8a2f2 100644 --- a/tests/baselines/reference/controlFlowArrays.js +++ b/tests/baselines/reference/controlFlowArrays.js @@ -155,6 +155,22 @@ function f16() { (x.push("hello"), x).push(true); ((x))[3] = { a: 1 }; return x; // (string | number | boolean | { a: number })[] +} + +function f17() { + let x = []; + x.unshift(5); + x.unshift("hello"); + x.unshift(true); + return x; // (string | number | boolean)[] +} + +function f18() { + let x = []; + x.push(5); + x.unshift("hello"); + x[2] = true; + return x; // (string | number | boolean)[] } //// [controlFlowArrays.js] @@ -299,3 +315,17 @@ function f16() { ((x))[3] = { a: 1 }; return x; // (string | number | boolean | { a: number })[] } +function f17() { + var x = []; + x.unshift(5); + x.unshift("hello"); + x.unshift(true); + return x; // (string | number | boolean)[] +} +function f18() { + var x = []; + x.push(5); + x.unshift("hello"); + x[2] = true; + return x; // (string | number | boolean)[] +} diff --git a/tests/baselines/reference/controlFlowArrays.symbols b/tests/baselines/reference/controlFlowArrays.symbols index 204a2171992..463fb522585 100644 --- a/tests/baselines/reference/controlFlowArrays.symbols +++ b/tests/baselines/reference/controlFlowArrays.symbols @@ -400,3 +400,51 @@ function f16() { return x; // (string | number | boolean | { a: number })[] >x : Symbol(x, Decl(controlFlowArrays.ts, 150, 7)) } + +function f17() { +>f17 : Symbol(f17, Decl(controlFlowArrays.ts, 156, 1)) + + let x = []; +>x : Symbol(x, Decl(controlFlowArrays.ts, 159, 7)) + + x.unshift(5); +>x.unshift : Symbol(Array.unshift, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 159, 7)) +>unshift : Symbol(Array.unshift, Decl(lib.d.ts, --, --)) + + x.unshift("hello"); +>x.unshift : Symbol(Array.unshift, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 159, 7)) +>unshift : Symbol(Array.unshift, Decl(lib.d.ts, --, --)) + + x.unshift(true); +>x.unshift : Symbol(Array.unshift, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 159, 7)) +>unshift : Symbol(Array.unshift, Decl(lib.d.ts, --, --)) + + return x; // (string | number | boolean)[] +>x : Symbol(x, Decl(controlFlowArrays.ts, 159, 7)) +} + +function f18() { +>f18 : Symbol(f18, Decl(controlFlowArrays.ts, 164, 1)) + + let x = []; +>x : Symbol(x, Decl(controlFlowArrays.ts, 167, 7)) + + x.push(5); +>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 167, 7)) +>push : Symbol(Array.push, Decl(lib.d.ts, --, --)) + + x.unshift("hello"); +>x.unshift : Symbol(Array.unshift, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 167, 7)) +>unshift : Symbol(Array.unshift, Decl(lib.d.ts, --, --)) + + x[2] = true; +>x : Symbol(x, Decl(controlFlowArrays.ts, 167, 7)) + + return x; // (string | number | boolean)[] +>x : Symbol(x, Decl(controlFlowArrays.ts, 167, 7)) +} diff --git a/tests/baselines/reference/controlFlowArrays.types b/tests/baselines/reference/controlFlowArrays.types index 3a91ce7e197..2299afd7d21 100644 --- a/tests/baselines/reference/controlFlowArrays.types +++ b/tests/baselines/reference/controlFlowArrays.types @@ -521,3 +521,67 @@ function f16() { return x; // (string | number | boolean | { a: number })[] >x : (string | number | boolean | { a: number; })[] } + +function f17() { +>f17 : () => (string | number | boolean)[] + + let x = []; +>x : any[] +>[] : never[] + + x.unshift(5); +>x.unshift(5) : number +>x.unshift : (...items: any[]) => number +>x : any[] +>unshift : (...items: any[]) => number +>5 : 5 + + x.unshift("hello"); +>x.unshift("hello") : number +>x.unshift : (...items: any[]) => number +>x : any[] +>unshift : (...items: any[]) => number +>"hello" : "hello" + + x.unshift(true); +>x.unshift(true) : number +>x.unshift : (...items: any[]) => number +>x : any[] +>unshift : (...items: any[]) => number +>true : true + + return x; // (string | number | boolean)[] +>x : (string | number | boolean)[] +} + +function f18() { +>f18 : () => (string | number | boolean)[] + + let x = []; +>x : any[] +>[] : never[] + + x.push(5); +>x.push(5) : number +>x.push : (...items: any[]) => number +>x : any[] +>push : (...items: any[]) => number +>5 : 5 + + x.unshift("hello"); +>x.unshift("hello") : number +>x.unshift : (...items: any[]) => number +>x : any[] +>unshift : (...items: any[]) => number +>"hello" : "hello" + + x[2] = true; +>x[2] = true : true +>x[2] : any +>x : any[] +>2 : 2 +>true : true + + return x; // (string | number | boolean)[] +>x : (string | number | boolean)[] +} diff --git a/tests/cases/compiler/controlFlowArrays.ts b/tests/cases/compiler/controlFlowArrays.ts index e89a2443753..160f0efed17 100644 --- a/tests/cases/compiler/controlFlowArrays.ts +++ b/tests/cases/compiler/controlFlowArrays.ts @@ -156,4 +156,20 @@ function f16() { (x.push("hello"), x).push(true); ((x))[3] = { a: 1 }; return x; // (string | number | boolean | { a: number })[] +} + +function f17() { + let x = []; + x.unshift(5); + x.unshift("hello"); + x.unshift(true); + return x; // (string | number | boolean)[] +} + +function f18() { + let x = []; + x.push(5); + x.unshift("hello"); + x[2] = true; + return x; // (string | number | boolean)[] } \ No newline at end of file From 224582c4f31c2b25164f741ee750360ff9859a38 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Thu, 13 Oct 2016 10:19:18 -0700 Subject: [PATCH 080/173] Merge pull request #11577 from Microsoft/vladima/configure-typing-acquisition Disable automatic type acquisition with command line option, replace npm view with request to npm registry --- .../unittests/tsserverProjectSystem.ts | 16 ++-- src/harness/unittests/typingsInstaller.ts | 28 +++---- src/server/server.ts | 7 +- .../typingsInstaller/nodeTypingsInstaller.ts | 80 +++++++++++++++---- .../typingsInstaller/typingsInstaller.ts | 29 +++---- 5 files changed, 105 insertions(+), 55 deletions(-) diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index 08e4bac7b2c..831dd6a7542 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -19,10 +19,8 @@ namespace ts.projectSystem { export interface PostExecAction { readonly requestKind: TI.RequestKind; - readonly error: Error; - readonly stdout: string; - readonly stderr: string; - readonly callback: (err: Error, stdout: string, stderr: string) => void; + readonly success: boolean; + readonly callback: TI.RequestCompletedAction; } export function notImplemented(): any { @@ -54,7 +52,7 @@ namespace ts.projectSystem { export class TestTypingsInstaller extends TI.TypingsInstaller implements server.ITypingsInstaller { protected projectService: server.ProjectService; constructor(readonly globalTypingsCacheLocation: string, throttleLimit: number, readonly installTypingHost: server.ServerHost, log?: TI.Log) { - super(globalTypingsCacheLocation, "npm", safeList.path, throttleLimit, log); + super(globalTypingsCacheLocation, safeList.path, throttleLimit, log); this.init(); } @@ -65,7 +63,7 @@ namespace ts.projectSystem { const actionsToRun = this.postExecActions; this.postExecActions = []; for (const action of actionsToRun) { - action.callback(action.error, action.stdout, action.stderr); + action.callback(action.success); } } @@ -85,7 +83,7 @@ namespace ts.projectSystem { return this.installTypingHost; } - runCommand(requestKind: TI.RequestKind, requestId: number, command: string, cwd: string, cb: (err: Error, stdout: string, stderr: string) => void): void { + executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: TI.RequestCompletedAction): void { switch (requestKind) { case TI.NpmViewRequest: case TI.NpmInstallRequest: @@ -108,9 +106,7 @@ namespace ts.projectSystem { addPostExecAction(requestKind: TI.RequestKind, stdout: string | string[], cb: TI.RequestCompletedAction) { const out = typeof stdout === "string" ? stdout : createNpmPackageJsonString(stdout); const action: PostExecAction = { - error: undefined, - stdout: out, - stderr: "", + success: !!out, callback: cb, requestKind }; diff --git a/src/harness/unittests/typingsInstaller.ts b/src/harness/unittests/typingsInstaller.ts index d79a1a7723c..ebd0f0ef792 100644 --- a/src/harness/unittests/typingsInstaller.ts +++ b/src/harness/unittests/typingsInstaller.ts @@ -31,11 +31,11 @@ namespace ts.projectSystem { function executeCommand(self: Installer, host: TestServerHost, installedTypings: string[], typingFiles: FileOrFolder[], requestKind: TI.RequestKind, cb: TI.RequestCompletedAction): void { switch (requestKind) { case TI.NpmInstallRequest: - self.addPostExecAction(requestKind, installedTypings, (err, stdout, stderr) => { + self.addPostExecAction(requestKind, installedTypings, success => { for (const file of typingFiles) { host.createFileOrFolder(file, /*createParentDirectory*/ true); } - cb(err, stdout, stderr); + cb(success); }); break; case TI.NpmViewRequest: @@ -81,7 +81,7 @@ namespace ts.projectSystem { constructor() { super(host); } - runCommand(requestKind: TI.RequestKind, requestId: number, command: string, cwd: string, cb: server.typingsInstaller.RequestCompletedAction) { + executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: server.typingsInstaller.RequestCompletedAction) { const installedTypings = ["@types/jquery"]; const typingFiles = [jquery]; executeCommand(this, host, installedTypings, typingFiles, requestKind, cb); @@ -125,7 +125,7 @@ namespace ts.projectSystem { constructor() { super(host); } - runCommand(requestKind: TI.RequestKind, requestId: number, command: string, cwd: string, cb: server.typingsInstaller.RequestCompletedAction) { + executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: server.typingsInstaller.RequestCompletedAction) { const installedTypings = ["@types/jquery"]; const typingFiles = [jquery]; executeCommand(this, host, installedTypings, typingFiles, requestKind, cb); @@ -221,7 +221,7 @@ namespace ts.projectSystem { enqueueIsCalled = true; super.enqueueInstallTypingsRequest(project, typingOptions); } - runCommand(requestKind: TI.RequestKind, requestId: number, command: string, cwd: string, cb: TI.RequestCompletedAction): void { + executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: TI.RequestCompletedAction): void { const installedTypings = ["@types/jquery"]; const typingFiles = [jquery]; executeCommand(this, host, installedTypings, typingFiles, requestKind, cb); @@ -275,7 +275,7 @@ namespace ts.projectSystem { constructor() { super(host); } - runCommand(requestKind: TI.RequestKind, requestId: number, command: string, cwd: string, cb: TI.RequestCompletedAction): void { + executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: TI.RequestCompletedAction): void { const installedTypings = ["@types/lodash", "@types/react"]; const typingFiles = [lodash, react]; executeCommand(this, host, installedTypings, typingFiles, requestKind, cb); @@ -323,7 +323,7 @@ namespace ts.projectSystem { enqueueIsCalled = true; super.enqueueInstallTypingsRequest(project, typingOptions); } - runCommand(requestKind: TI.RequestKind, requestId: number, command: string, cwd: string, cb: TI.RequestCompletedAction): void { + executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: TI.RequestCompletedAction): void { const installedTypings: string[] = []; const typingFiles: FileOrFolder[] = []; executeCommand(this, host, installedTypings, typingFiles, requestKind, cb); @@ -398,7 +398,7 @@ namespace ts.projectSystem { constructor() { super(host); } - runCommand(requestKind: TI.RequestKind, requestId: number, command: string, cwd: string, cb: TI.RequestCompletedAction): void { + executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: TI.RequestCompletedAction): void { const installedTypings = ["@types/commander", "@types/express", "@types/jquery", "@types/moment"]; const typingFiles = [commander, express, jquery, moment]; executeCommand(this, host, installedTypings, typingFiles, requestKind, cb); @@ -477,7 +477,7 @@ namespace ts.projectSystem { constructor() { super(host, { throttleLimit: 3 }); } - runCommand(requestKind: TI.RequestKind, requestId: number, command: string, cwd: string, cb: TI.RequestCompletedAction): void { + executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: TI.RequestCompletedAction): void { const installedTypings = ["@types/commander", "@types/express", "@types/jquery", "@types/moment", "@types/lodash"]; executeCommand(this, host, installedTypings, typingFiles, requestKind, cb); } @@ -567,10 +567,10 @@ namespace ts.projectSystem { constructor() { super(host, { throttleLimit: 3 }); } - runCommand(requestKind: TI.RequestKind, requestId: number, command: string, cwd: string, cb: TI.RequestCompletedAction): void { + executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: TI.RequestCompletedAction): void { if (requestKind === TI.NpmInstallRequest) { let typingFiles: (FileOrFolder & { typings: string}) [] = []; - if (command.indexOf("commander") >= 0) { + if (args.indexOf("@types/commander") >= 0) { typingFiles = [commander, jquery, lodash, cordova]; } else { @@ -655,7 +655,7 @@ namespace ts.projectSystem { constructor() { super(host, { globalTypingsCacheLocation: "/tmp" }); } - runCommand(requestKind: TI.RequestKind, requestId: number, command: string, cwd: string, cb: server.typingsInstaller.RequestCompletedAction) { + executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: server.typingsInstaller.RequestCompletedAction) { const installedTypings = ["@types/jquery"]; const typingFiles = [jqueryDTS]; executeCommand(this, host, installedTypings, typingFiles, requestKind, cb); @@ -701,7 +701,7 @@ namespace ts.projectSystem { constructor() { super(host, { globalTypingsCacheLocation: "/tmp" }); } - runCommand(requestKind: TI.RequestKind, requestId: number, command: string, cwd: string, cb: server.typingsInstaller.RequestCompletedAction) { + executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: server.typingsInstaller.RequestCompletedAction) { const installedTypings = ["@types/jquery"]; const typingFiles = [jqueryDTS]; executeCommand(this, host, installedTypings, typingFiles, requestKind, cb); @@ -766,7 +766,7 @@ namespace ts.projectSystem { constructor() { super(host, { globalTypingsCacheLocation: "/tmp" }, { isEnabled: () => true, writeLine: msg => messages.push(msg) }); } - runCommand(requestKind: TI.RequestKind, requestId: number, command: string, cwd: string, cb: server.typingsInstaller.RequestCompletedAction) { + executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: server.typingsInstaller.RequestCompletedAction) { assert(false, "runCommand should not be invoked"); } })(); diff --git a/src/server/server.ts b/src/server/server.ts index d59100bb57c..e728d7e9d72 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -265,13 +265,16 @@ namespace ts.server { installerEventPort: number, canUseEvents: boolean, useSingleInferredProject: boolean, + disableAutomaticTypingAcquisition: boolean, globalTypingsCacheLocation: string, logger: server.Logger) { super( host, cancellationToken, useSingleInferredProject, - new NodeTypingsInstaller(logger, installerEventPort, globalTypingsCacheLocation, host.newLine), + disableAutomaticTypingAcquisition + ? nullTypingsInstaller + : new NodeTypingsInstaller(logger, installerEventPort, globalTypingsCacheLocation, host.newLine), Buffer.byteLength, process.hrtime, logger, @@ -512,12 +515,14 @@ namespace ts.server { } const useSingleInferredProject = sys.args.indexOf("--useSingleInferredProject") >= 0; + const disableAutomaticTypingAcquisition = sys.args.indexOf("--disableAutomaticTypingAcquisition") >= 0; const ioSession = new IOSession( sys, cancellationToken, eventPort, /*canUseEvents*/ eventPort === undefined, useSingleInferredProject, + disableAutomaticTypingAcquisition, getGlobalTypingsCacheLocation(), logger); process.on("uncaughtException", function (err: Error) { diff --git a/src/server/typingsInstaller/nodeTypingsInstaller.ts b/src/server/typingsInstaller/nodeTypingsInstaller.ts index b73a8e4e79d..044935670f2 100644 --- a/src/server/typingsInstaller/nodeTypingsInstaller.ts +++ b/src/server/typingsInstaller/nodeTypingsInstaller.ts @@ -33,23 +33,38 @@ namespace ts.server.typingsInstaller { } } - export class NodeTypingsInstaller extends TypingsInstaller { - private readonly exec: { (command: string, options: { cwd: string }, callback?: (error: Error, stdout: string, stderr: string) => void): any }; + type HttpGet = { + (url: string, callback: (response: HttpResponse) => void): NodeJS.EventEmitter; + } + interface HttpResponse extends NodeJS.ReadableStream { + statusCode: number; + statusMessage: string; + destroy(): void; + } + + type Exec = { + (command: string, options: { cwd: string }, callback?: (error: Error, stdout: string, stderr: string) => void): any + } + + export class NodeTypingsInstaller extends TypingsInstaller { + private readonly exec: Exec; + private readonly httpGet: HttpGet; + private readonly npmPath: string; readonly installTypingHost: InstallTypingHost = sys; constructor(globalTypingsCacheLocation: string, throttleLimit: number, log: Log) { super( globalTypingsCacheLocation, - /*npmPath*/ getNPMLocation(process.argv[0]), toPath("typingSafeList.json", __dirname, createGetCanonicalFileName(sys.useCaseSensitiveFileNames)), throttleLimit, log); if (this.log.isEnabled()) { this.log.writeLine(`Process id: ${process.pid}`); } - const { exec } = require("child_process"); - this.exec = exec; + this.npmPath = getNPMLocation(process.argv[0]); + this.exec = require("child_process").exec; + this.httpGet = require("http").get; } init() { @@ -75,17 +90,54 @@ namespace ts.server.typingsInstaller { } } - protected runCommand(requestKind: RequestKind, requestId: number, command: string, cwd: string, onRequestCompleted: RequestCompletedAction): void { + protected executeRequest(requestKind: RequestKind, requestId: number, args: string[], cwd: string, onRequestCompleted: RequestCompletedAction): void { if (this.log.isEnabled()) { - this.log.writeLine(`#${requestId} running command '${command}'.`); + this.log.writeLine(`#${requestId} executing ${requestKind}, arguments'${JSON.stringify(args)}'.`); + } + switch (requestKind) { + case NpmViewRequest: { + // const command = `${self.npmPath} view @types/${typing} --silent name`; + // use http request to global npm registry instead of running npm view + Debug.assert(args.length === 1); + const url = `http://registry.npmjs.org/@types%2f${args[0]}`; + const start = Date.now(); + this.httpGet(url, response => { + let ok = false; + if (this.log.isEnabled()) { + this.log.writeLine(`${requestKind} #${requestId} request to ${url}:: status code ${response.statusCode}, status message '${response.statusMessage}', took ${Date.now() - start} ms`); + } + switch (response.statusCode) { + case 200: // OK + case 301: // redirect - Moved - treat package as present + case 302: // redirect - Found - treat package as present + ok = true; + break; + } + response.destroy(); + onRequestCompleted(ok); + }).on("error", (err: Error) => { + if (this.log.isEnabled()) { + this.log.writeLine(`${requestKind} #${requestId} query to npm registry failed with error ${err.message}, stack ${err.stack}`); + } + onRequestCompleted(/*success*/ false); + }); + } + break; + case NpmInstallRequest: { + const command = `${this.npmPath} install ${args.join(" ")} --save-dev`; + const start = Date.now(); + this.exec(command, { cwd }, (err, stdout, stderr) => { + if (this.log.isEnabled()) { + this.log.writeLine(`${requestKind} #${requestId} took: ${Date.now() - start} ms${sys.newLine}stdout: ${stdout}${sys.newLine}stderr: ${stderr}`); + } + // treat any output on stdout as success + onRequestCompleted(!!stdout); + }); + } + break; + default: + Debug.assert(false, `Unknown request kind ${requestKind}`); } - this.exec(command, { cwd }, (err, stdout, stderr) => { - if (this.log.isEnabled()) { - this.log.writeLine(`${requestKind} #${requestId} stdout: ${stdout}`); - this.log.writeLine(`${requestKind} #${requestId} stderr: ${stderr}`); - } - onRequestCompleted(err, stdout, stderr); - }); } } diff --git a/src/server/typingsInstaller/typingsInstaller.ts b/src/server/typingsInstaller/typingsInstaller.ts index 0ed2ccce99d..f62f5fc4abe 100644 --- a/src/server/typingsInstaller/typingsInstaller.ts +++ b/src/server/typingsInstaller/typingsInstaller.ts @@ -65,11 +65,11 @@ namespace ts.server.typingsInstaller { export type RequestKind = typeof NpmViewRequest | typeof NpmInstallRequest; - export type RequestCompletedAction = (err: Error, stdout: string, stderr: string) => void; + export type RequestCompletedAction = (success: boolean) => void; type PendingRequest = { requestKind: RequestKind; requestId: number; - command: string; + args: string[]; cwd: string; onRequestCompleted: RequestCompletedAction }; @@ -88,7 +88,6 @@ namespace ts.server.typingsInstaller { constructor( readonly globalCachePath: string, - readonly npmPath: string, readonly safeListPath: Path, readonly throttleLimit: number, protected readonly log = nullLog) { @@ -331,13 +330,12 @@ namespace ts.server.typingsInstaller { let execInstallCmdCount = 0; const filteredTypings: string[] = []; for (const typing of typingsToInstall) { - execNpmViewTyping(this, typing); + filterExistingTypings(this, typing); } - function execNpmViewTyping(self: TypingsInstaller, typing: string) { - const command = `${self.npmPath} view @types/${typing} --silent name`; - self.execAsync(NpmViewRequest, requestId, command, cachePath, (err, stdout, stderr) => { - if (stdout) { + function filterExistingTypings(self: TypingsInstaller, typing: string) { + self.execAsync(NpmViewRequest, requestId, [typing], cachePath, ok => { + if (ok) { filteredTypings.push(typing); } execInstallCmdCount++; @@ -353,9 +351,8 @@ namespace ts.server.typingsInstaller { return; } const scopedTypings = filteredTypings.map(t => "@types/" + t); - const command = `${self.npmPath} install ${scopedTypings.join(" ")} --save-dev`; - self.execAsync(NpmInstallRequest, requestId, command, cachePath, (err, stdout, stderr) => { - postInstallAction(stdout ? scopedTypings : []); + self.execAsync(NpmInstallRequest, requestId, scopedTypings, cachePath, ok => { + postInstallAction(ok ? scopedTypings : []); }); } } @@ -403,8 +400,8 @@ namespace ts.server.typingsInstaller { }; } - private execAsync(requestKind: RequestKind, requestId: number, command: string, cwd: string, onRequestCompleted: RequestCompletedAction): void { - this.pendingRunRequests.unshift({ requestKind, requestId, command, cwd, onRequestCompleted }); + private execAsync(requestKind: RequestKind, requestId: number, args: string[], cwd: string, onRequestCompleted: RequestCompletedAction): void { + this.pendingRunRequests.unshift({ requestKind, requestId, args, cwd, onRequestCompleted }); this.executeWithThrottling(); } @@ -412,15 +409,15 @@ namespace ts.server.typingsInstaller { while (this.inFlightRequestCount < this.throttleLimit && this.pendingRunRequests.length) { this.inFlightRequestCount++; const request = this.pendingRunRequests.pop(); - this.runCommand(request.requestKind, request.requestId, request.command, request.cwd, (err, stdout, stderr) => { + this.executeRequest(request.requestKind, request.requestId, request.args, request.cwd, ok => { this.inFlightRequestCount--; - request.onRequestCompleted(err, stdout, stderr); + request.onRequestCompleted(ok); this.executeWithThrottling(); }); } } - protected abstract runCommand(requestKind: RequestKind, requestId: number, command: string, cwd: string, onRequestCompleted: RequestCompletedAction): void; + protected abstract executeRequest(requestKind: RequestKind, requestId: number, args: string[], cwd: string, onRequestCompleted: RequestCompletedAction): void; protected abstract sendResponse(response: SetTypings | InvalidateCachedTypings): void; } } \ No newline at end of file From 9c41e42d6265c97ae98d7974b6102086c5098fab Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Thu, 13 Oct 2016 10:29:01 -0700 Subject: [PATCH 081/173] fix linter issues --- src/server/typingsInstaller/nodeTypingsInstaller.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/server/typingsInstaller/nodeTypingsInstaller.ts b/src/server/typingsInstaller/nodeTypingsInstaller.ts index 044935670f2..ff643e885e4 100644 --- a/src/server/typingsInstaller/nodeTypingsInstaller.ts +++ b/src/server/typingsInstaller/nodeTypingsInstaller.ts @@ -35,7 +35,7 @@ namespace ts.server.typingsInstaller { type HttpGet = { (url: string, callback: (response: HttpResponse) => void): NodeJS.EventEmitter; - } + }; interface HttpResponse extends NodeJS.ReadableStream { statusCode: number; @@ -45,7 +45,7 @@ namespace ts.server.typingsInstaller { type Exec = { (command: string, options: { cwd: string }, callback?: (error: Error, stdout: string, stderr: string) => void): any - } + }; export class NodeTypingsInstaller extends TypingsInstaller { private readonly exec: Exec; From 1c6fde67567b9d79d4ba51c68c3a8c12a22e3870 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 13 Oct 2016 13:03:25 -0700 Subject: [PATCH 082/173] Update issue template --- issue_template.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/issue_template.md b/issue_template.md index 7799960ec78..fcd995317f5 100644 --- a/issue_template.md +++ b/issue_template.md @@ -2,7 +2,7 @@ -**TypeScript Version:** 1.8.0 / nightly (2.0.0-dev.201xxxxx) +**TypeScript Version:** 2.0.3 / nightly (2.1.0-dev.201xxxxx) **Code** From 5b4dfcc18f441f6af1bcd5485b86e9a3429019c1 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Thu, 13 Oct 2016 13:22:58 -0700 Subject: [PATCH 083/173] Address PR: remove locales and options; use accent as default --- src/compiler/core.ts | 19 +++++++------------ src/services/navigateTo.ts | 5 +---- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 47eb66db07c..e8fadbff6e9 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -23,10 +23,6 @@ namespace ts { // More efficient to create a collator once and use its `compare` than to call `a.localeCompare(b)` many times. export const collator: { compare(a: string, b: string): number } = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; - // This means "compare in a case insensitive manner but consider accentsor other diacritic marks" - // (e.g. a ≠ b, a ≠ á, a = A) - const accentSensitivity: Intl.CollatorOptions = { usage: "sort", sensitivity: "accent" }; - /** * Use this function instead of calling "String.prototype.localeCompre". This function will preform appropriate check to make sure that * "typeof Intl" is correct as there are reported issues #11110 nad #11339. @@ -1033,13 +1029,14 @@ namespace ts { return a < b ? Comparison.LessThan : Comparison.GreaterThan; } - export function compareStrings(a: string, b: string, locales?: string | string[], options?: Intl.CollatorOptions): Comparison { + export function compareStrings(a: string, b: string, ignoreCase?: boolean): Comparison { if (a === b) return Comparison.EqualTo; if (a === undefined) return Comparison.LessThan; if (b === undefined) return Comparison.GreaterThan; - if (options) { + if (ignoreCase) { if (collator && String.prototype.localeCompare) { - const result = a.localeCompare(b, locales, options); + // accent means a ≠ b, a ≠ á, a = A + const result = a.localeCompare(b, /*locales*/ undefined, { usage: "sort", sensitivity: "accent" }); return result < 0 ? Comparison.LessThan : result > 0 ? Comparison.GreaterThan : Comparison.EqualTo; } @@ -1052,7 +1049,7 @@ namespace ts { } export function compareStringsCaseInsensitive(a: string, b: string) { - return compareStrings(a, b, /*locales*/ undefined, accentSensitivity); + return compareStrings(a, b, /*ignoreCase*/ true); } function getDiagnosticFileName(diagnostic: Diagnostic): string { @@ -1422,8 +1419,7 @@ namespace ts { const bComponents = getNormalizedPathComponents(b, currentDirectory); const sharedLength = Math.min(aComponents.length, bComponents.length); for (let i = 0; i < sharedLength; i++) { - const result = compareStrings(aComponents[i], bComponents[i], - /*locales*/ undefined, /*options*/ ignoreCase ? accentSensitivity : undefined); + const result = compareStrings(aComponents[i], bComponents[i], ignoreCase); if (result !== Comparison.EqualTo) { return result; } @@ -1445,8 +1441,7 @@ namespace ts { } for (let i = 0; i < parentComponents.length; i++) { - const result = compareStrings(parentComponents[i], childComponents[i], - /*locales*/ undefined, /*options*/ ignoreCase ? accentSensitivity : undefined); + const result = compareStrings(parentComponents[i], childComponents[i], ignoreCase); if (result !== Comparison.EqualTo) { return false; } diff --git a/src/services/navigateTo.ts b/src/services/navigateTo.ts index 2433dbe9795..82f4dd49f2b 100644 --- a/src/services/navigateTo.ts +++ b/src/services/navigateTo.ts @@ -6,9 +6,6 @@ namespace ts.NavigateTo { const patternMatcher = createPatternMatcher(searchValue); let rawItems: RawNavigateToItem[] = []; - // This means "compare in a case insensitive manner." - const baseSensitivity: Intl.CollatorOptions = { sensitivity: "base" }; - // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] forEach(sourceFiles, sourceFile => { cancellationToken.throwIfCancellationRequested(); @@ -188,7 +185,7 @@ namespace ts.NavigateTo { // We first sort case insensitively. So "Aaa" will come before "bar". // Then we sort case sensitively, so "aaa" will come before "Aaa". return i1.matchKind - i2.matchKind || - ts.compareStrings(i1.name, i2.name, /*locales*/ undefined, /*options*/ baseSensitivity) || + ts.compareStringsCaseInsensitive(i1.name, i2.name) || ts.compareStrings(i1.name, i2.name); } From bf301e9ccce09f7dcd36944d8941e2c26e5c73f7 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 13 Oct 2016 13:28:58 -0700 Subject: [PATCH 084/173] Treat reference to empty evolving array as an implicit any[] --- src/compiler/checker.ts | 46 ++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7bec343c91e..9b2679adc59 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8524,9 +8524,11 @@ namespace ts { } function createFinalArrayType(elementType: Type) { - return createArrayType(elementType !== neverType ? - elementType.flags & TypeFlags.Union ? getUnionType((elementType).types, /*subtypeReduction*/ true) : elementType : - strictNullChecks ? neverType : undefinedWideningType); + return elementType.flags & TypeFlags.Never ? + autoArrayType : + createArrayType(elementType.flags & TypeFlags.Union ? + getUnionType((elementType).types, /*subtypeReduction*/ true) : + elementType); } // We perform subtype reduction upon obtaining the final array type from an evolving array type. @@ -8564,26 +8566,22 @@ namespace ts { getUnionType(sameMap(types, finalizeEvolvingArrayType), subtypeReduction); } - // Return true if the given node is 'x' in an 'x.push(value)' or 'x.unshift(value)' operation. - function isPushOrUnshiftCallTarget(node: Node) { - const parent = getReferenceRoot(node).parent; - return parent.kind === SyntaxKind.PropertyAccessExpression && - parent.parent.kind === SyntaxKind.CallExpression && - isPushOrUnshiftIdentifier((parent).name); - } - - // Return true if the given node is 'x' in an 'x[n] = value' operation, where 'n' is an - // expression of type any, undefined, or a number-like type. - function isElementAssignmentTarget(node: Node) { + // Return true if the given node is 'x' in an 'x.length', x.push(value)', 'x.unshift(value)' or + // 'x[n] = value' operation, where 'n' is an expression of type any, undefined, or a number-like type. + function isEvolvingArrayOperationTarget(node: Node) { const root = getReferenceRoot(node); const parent = root.parent; - return parent.kind === SyntaxKind.ElementAccessExpression && + const isLengthPushOrUnshift = parent.kind === SyntaxKind.PropertyAccessExpression && ( + (parent).name.text === "length" || + parent.parent.kind === SyntaxKind.CallExpression && isPushOrUnshiftIdentifier((parent).name)); + const isElementAssignment = parent.kind === SyntaxKind.ElementAccessExpression && (parent).expression === root && parent.parent.kind === SyntaxKind.BinaryExpression && (parent.parent).operatorToken.kind === SyntaxKind.EqualsToken && (parent.parent).left === parent && !isAssignmentTarget(parent.parent) && isTypeAnyOrAllConstituentTypesHaveKind(checkExpression((parent).argumentExpression), TypeFlags.NumberLike | TypeFlags.Undefined); + return isLengthPushOrUnshift || isElementAssignment; } function getFlowTypeOfReference(reference: Node, declaredType: Type, assumeInitialized: boolean, flowContainer: Node) { @@ -8597,11 +8595,11 @@ namespace ts { const visitedFlowStart = visitedFlowCount; const evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); visitedFlowCount = visitedFlowStart; - // When the reference is 'x' in an 'x.push(value)' or 'x[n] = value' operation, we give type - // 'any[]' to 'x' instead of using the type determined by control flow analysis such that new - // element types are not considered errors. - const isEvolvingArrayInferenceTarget = isEvolvingArrayType(evolvedType) && (isPushOrUnshiftCallTarget(reference) || isElementAssignmentTarget(reference)); - const resultType = isEvolvingArrayInferenceTarget ? anyArrayType : finalizeEvolvingArrayType(evolvedType); + // When the reference is 'x' in an 'x.length', 'x.push(value)', 'x.unshift(value)' or x[n] = value' operation, + // we give type 'any[]' to 'x' instead of using the type determined by control flow analysis such that operations + // on empty arrays are possible without implicit any errors and new element types can be inferred without + // type mismatch errors. + const resultType = isEvolvingArrayType(evolvedType) && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); if (reference.parent.kind === SyntaxKind.NonNullExpression && getTypeWithFacts(resultType, TypeFacts.NEUndefinedOrNull).flags & TypeFlags.Never) { return declaredType; } @@ -9355,12 +9353,12 @@ namespace ts { // from declaration to use, and when the variable's declared type doesn't include undefined but the // control flow based type does include undefined. if (type === autoType || type === autoArrayType) { - if (flowType === type) { + if (flowType === autoType || flowType === autoArrayType) { if (compilerOptions.noImplicitAny) { - error(declaration.name, Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol), typeToString(type)); - error(node, Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(type)); + error(declaration.name, Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol), typeToString(flowType)); + error(node, Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(flowType)); } - return convertAutoToAny(type); + return convertAutoToAny(flowType); } } else if (!assumeInitialized && !(getFalsyFlags(type) & TypeFlags.Undefined) && getFalsyFlags(flowType) & TypeFlags.Undefined) { From bfa4197ffe610354efb382a5ef772ed3bf70c3c1 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 13 Oct 2016 13:29:08 -0700 Subject: [PATCH 085/173] Update tests --- tests/cases/compiler/controlFlowArrayErrors.ts | 10 +++++----- tests/cases/compiler/controlFlowArrays.ts | 10 ++++++++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/tests/cases/compiler/controlFlowArrayErrors.ts b/tests/cases/compiler/controlFlowArrayErrors.ts index aab3a974cd8..08107ff3659 100644 --- a/tests/cases/compiler/controlFlowArrayErrors.ts +++ b/tests/cases/compiler/controlFlowArrayErrors.ts @@ -3,16 +3,16 @@ declare function cond(): boolean; function f1() { - let x = []; - let y = x; // Implicit any[] error + let x = []; // Implicit any[] error in some locations + let y = x; // Implicit any[] error x.push(5); let z = x; } function f2() { - let x; + let x; // Implicit any[] error in some locations x = []; - let y = x; // Implicit any[] error + let y = x; // Implicit any[] error x.push(5); let z = x; } @@ -21,7 +21,7 @@ function f3() { let x = []; // Implicit any[] error in some locations x.push(5); function g() { - x; // Implicit any[] error + x; // Implicit any[] error } } diff --git a/tests/cases/compiler/controlFlowArrays.ts b/tests/cases/compiler/controlFlowArrays.ts index 160f0efed17..646c85f069f 100644 --- a/tests/cases/compiler/controlFlowArrays.ts +++ b/tests/cases/compiler/controlFlowArrays.ts @@ -115,13 +115,19 @@ function f10() { function f11() { let x = []; - return x; // never[] + if (x.length === 0) { // x.length ok on implicit any[] + x.push("hello"); + } + return x; } function f12() { let x; x = []; - return x; // never[] + if (x.length === 0) { // x.length ok on implicit any[] + x.push("hello"); + } + return x; } function f13() { From 79ed3a7ed83605f0230df160d8472de1b372d4f3 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 13 Oct 2016 13:29:42 -0700 Subject: [PATCH 086/173] Accept new baselines --- .../reference/arrayLiterals2ES5.types | 6 +- .../controlFlowArrayErrors.errors.txt | 28 +++-- .../reference/controlFlowArrayErrors.js | 14 +-- .../baselines/reference/controlFlowArrays.js | 20 +++- .../reference/controlFlowArrays.symbols | 108 +++++++++++------- .../reference/controlFlowArrays.types | 40 ++++++- .../genericTypeParameterEquivalence2.types | 2 +- .../reference/globalThisCapture.types | 4 +- 8 files changed, 144 insertions(+), 78 deletions(-) diff --git a/tests/baselines/reference/arrayLiterals2ES5.types b/tests/baselines/reference/arrayLiterals2ES5.types index 833966a6e48..c3256db925e 100644 --- a/tests/baselines/reference/arrayLiterals2ES5.types +++ b/tests/baselines/reference/arrayLiterals2ES5.types @@ -194,9 +194,9 @@ var d5 = [...temp3]; var d6 = [...temp4]; >d6 : any[] ->[...temp4] : undefined[] ->...temp4 : undefined ->temp4 : undefined[] +>[...temp4] : any[] +>...temp4 : any +>temp4 : any[] var d7 = [...[...temp1]]; >d7 : number[] diff --git a/tests/baselines/reference/controlFlowArrayErrors.errors.txt b/tests/baselines/reference/controlFlowArrayErrors.errors.txt index bc13de261e2..2ef009dc0e1 100644 --- a/tests/baselines/reference/controlFlowArrayErrors.errors.txt +++ b/tests/baselines/reference/controlFlowArrayErrors.errors.txt @@ -1,5 +1,7 @@ -tests/cases/compiler/controlFlowArrayErrors.ts(6,9): error TS7005: Variable 'y' implicitly has an 'any[]' type. -tests/cases/compiler/controlFlowArrayErrors.ts(14,9): error TS7005: Variable 'y' implicitly has an 'any[]' type. +tests/cases/compiler/controlFlowArrayErrors.ts(5,9): error TS7034: Variable 'x' implicitly has type 'any[]' in some locations where its type cannot be determined. +tests/cases/compiler/controlFlowArrayErrors.ts(6,13): error TS7005: Variable 'x' implicitly has an 'any[]' type. +tests/cases/compiler/controlFlowArrayErrors.ts(12,9): error TS7034: Variable 'x' implicitly has type 'any[]' in some locations where its type cannot be determined. +tests/cases/compiler/controlFlowArrayErrors.ts(14,13): error TS7005: Variable 'x' implicitly has an 'any[]' type. tests/cases/compiler/controlFlowArrayErrors.ts(20,9): error TS7034: Variable 'x' implicitly has type 'any[]' in some locations where its type cannot be determined. tests/cases/compiler/controlFlowArrayErrors.ts(23,9): error TS7005: Variable 'x' implicitly has an 'any[]' type. tests/cases/compiler/controlFlowArrayErrors.ts(30,12): error TS2345: Argument of type 'true' is not assignable to parameter of type 'string | number'. @@ -10,25 +12,29 @@ tests/cases/compiler/controlFlowArrayErrors.ts(61,11): error TS7034: Variable 'x tests/cases/compiler/controlFlowArrayErrors.ts(64,9): error TS7005: Variable 'x' implicitly has an 'any[]' type. -==== tests/cases/compiler/controlFlowArrayErrors.ts (10 errors) ==== +==== tests/cases/compiler/controlFlowArrayErrors.ts (12 errors) ==== declare function cond(): boolean; function f1() { - let x = []; - let y = x; // Implicit any[] error + let x = []; // Implicit any[] error in some locations ~ -!!! error TS7005: Variable 'y' implicitly has an 'any[]' type. +!!! error TS7034: Variable 'x' implicitly has type 'any[]' in some locations where its type cannot be determined. + let y = x; // Implicit any[] error + ~ +!!! error TS7005: Variable 'x' implicitly has an 'any[]' type. x.push(5); let z = x; } function f2() { - let x; - x = []; - let y = x; // Implicit any[] error + let x; // Implicit any[] error in some locations ~ -!!! error TS7005: Variable 'y' implicitly has an 'any[]' type. +!!! error TS7034: Variable 'x' implicitly has type 'any[]' in some locations where its type cannot be determined. + x = []; + let y = x; // Implicit any[] error + ~ +!!! error TS7005: Variable 'x' implicitly has an 'any[]' type. x.push(5); let z = x; } @@ -39,7 +45,7 @@ tests/cases/compiler/controlFlowArrayErrors.ts(64,9): error TS7005: Variable 'x' !!! error TS7034: Variable 'x' implicitly has type 'any[]' in some locations where its type cannot be determined. x.push(5); function g() { - x; // Implicit any[] error + x; // Implicit any[] error ~ !!! error TS7005: Variable 'x' implicitly has an 'any[]' type. } diff --git a/tests/baselines/reference/controlFlowArrayErrors.js b/tests/baselines/reference/controlFlowArrayErrors.js index 538addc31c0..59995eb3094 100644 --- a/tests/baselines/reference/controlFlowArrayErrors.js +++ b/tests/baselines/reference/controlFlowArrayErrors.js @@ -3,16 +3,16 @@ declare function cond(): boolean; function f1() { - let x = []; - let y = x; // Implicit any[] error + let x = []; // Implicit any[] error in some locations + let y = x; // Implicit any[] error x.push(5); let z = x; } function f2() { - let x; + let x; // Implicit any[] error in some locations x = []; - let y = x; // Implicit any[] error + let y = x; // Implicit any[] error x.push(5); let z = x; } @@ -21,7 +21,7 @@ function f3() { let x = []; // Implicit any[] error in some locations x.push(5); function g() { - x; // Implicit any[] error + x; // Implicit any[] error } } @@ -68,13 +68,13 @@ function f8() { //// [controlFlowArrayErrors.js] function f1() { - var x = []; + var x = []; // Implicit any[] error in some locations var y = x; // Implicit any[] error x.push(5); var z = x; } function f2() { - var x; + var x; // Implicit any[] error in some locations x = []; var y = x; // Implicit any[] error x.push(5); diff --git a/tests/baselines/reference/controlFlowArrays.js b/tests/baselines/reference/controlFlowArrays.js index b2d3fa8a2f2..3f119599495 100644 --- a/tests/baselines/reference/controlFlowArrays.js +++ b/tests/baselines/reference/controlFlowArrays.js @@ -114,13 +114,19 @@ function f10() { function f11() { let x = []; - return x; // never[] + if (x.length === 0) { // x.length ok on implicit any[] + x.push("hello"); + } + return x; } function f12() { let x; x = []; - return x; // never[] + if (x.length === 0) { // x.length ok on implicit any[] + x.push("hello"); + } + return x; } function f13() { @@ -278,12 +284,18 @@ function f10() { } function f11() { var x = []; - return x; // never[] + if (x.length === 0) { + x.push("hello"); + } + return x; } function f12() { var x; x = []; - return x; // never[] + if (x.length === 0) { + x.push("hello"); + } + return x; } function f13() { var x = []; diff --git a/tests/baselines/reference/controlFlowArrays.symbols b/tests/baselines/reference/controlFlowArrays.symbols index 463fb522585..184a813a05f 100644 --- a/tests/baselines/reference/controlFlowArrays.symbols +++ b/tests/baselines/reference/controlFlowArrays.symbols @@ -282,78 +282,98 @@ function f11() { let x = []; >x : Symbol(x, Decl(controlFlowArrays.ts, 114, 7)) - return x; // never[] + if (x.length === 0) { // x.length ok on implicit any[] +>x.length : Symbol(Array.length, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 114, 7)) +>length : Symbol(Array.length, Decl(lib.d.ts, --, --)) + + x.push("hello"); +>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 114, 7)) +>push : Symbol(Array.push, Decl(lib.d.ts, --, --)) + } + return x; >x : Symbol(x, Decl(controlFlowArrays.ts, 114, 7)) } function f12() { ->f12 : Symbol(f12, Decl(controlFlowArrays.ts, 116, 1)) +>f12 : Symbol(f12, Decl(controlFlowArrays.ts, 119, 1)) let x; ->x : Symbol(x, Decl(controlFlowArrays.ts, 119, 7)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 122, 7)) x = []; ->x : Symbol(x, Decl(controlFlowArrays.ts, 119, 7)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 122, 7)) - return x; // never[] ->x : Symbol(x, Decl(controlFlowArrays.ts, 119, 7)) + if (x.length === 0) { // x.length ok on implicit any[] +>x.length : Symbol(Array.length, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 122, 7)) +>length : Symbol(Array.length, Decl(lib.d.ts, --, --)) + + x.push("hello"); +>x.push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 122, 7)) +>push : Symbol(Array.push, Decl(lib.d.ts, --, --)) + } + return x; +>x : Symbol(x, Decl(controlFlowArrays.ts, 122, 7)) } function f13() { ->f13 : Symbol(f13, Decl(controlFlowArrays.ts, 122, 1)) +>f13 : Symbol(f13, Decl(controlFlowArrays.ts, 128, 1)) var x = []; ->x : Symbol(x, Decl(controlFlowArrays.ts, 125, 7)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 131, 7)) x.push(5); >x.push : Symbol(Array.push, Decl(lib.d.ts, --, --)) ->x : Symbol(x, Decl(controlFlowArrays.ts, 125, 7)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 131, 7)) >push : Symbol(Array.push, Decl(lib.d.ts, --, --)) x.push("hello"); >x.push : Symbol(Array.push, Decl(lib.d.ts, --, --)) ->x : Symbol(x, Decl(controlFlowArrays.ts, 125, 7)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 131, 7)) >push : Symbol(Array.push, Decl(lib.d.ts, --, --)) x.push(true); >x.push : Symbol(Array.push, Decl(lib.d.ts, --, --)) ->x : Symbol(x, Decl(controlFlowArrays.ts, 125, 7)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 131, 7)) >push : Symbol(Array.push, Decl(lib.d.ts, --, --)) return x; // (string | number | boolean)[] ->x : Symbol(x, Decl(controlFlowArrays.ts, 125, 7)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 131, 7)) } function f14() { ->f14 : Symbol(f14, Decl(controlFlowArrays.ts, 130, 1)) +>f14 : Symbol(f14, Decl(controlFlowArrays.ts, 136, 1)) const x = []; ->x : Symbol(x, Decl(controlFlowArrays.ts, 133, 9)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 139, 9)) x.push(5); >x.push : Symbol(Array.push, Decl(lib.d.ts, --, --)) ->x : Symbol(x, Decl(controlFlowArrays.ts, 133, 9)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 139, 9)) >push : Symbol(Array.push, Decl(lib.d.ts, --, --)) x.push("hello"); >x.push : Symbol(Array.push, Decl(lib.d.ts, --, --)) ->x : Symbol(x, Decl(controlFlowArrays.ts, 133, 9)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 139, 9)) >push : Symbol(Array.push, Decl(lib.d.ts, --, --)) x.push(true); >x.push : Symbol(Array.push, Decl(lib.d.ts, --, --)) ->x : Symbol(x, Decl(controlFlowArrays.ts, 133, 9)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 139, 9)) >push : Symbol(Array.push, Decl(lib.d.ts, --, --)) return x; // (string | number | boolean)[] ->x : Symbol(x, Decl(controlFlowArrays.ts, 133, 9)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 139, 9)) } function f15() { ->f15 : Symbol(f15, Decl(controlFlowArrays.ts, 138, 1)) +>f15 : Symbol(f15, Decl(controlFlowArrays.ts, 144, 1)) let x = []; ->x : Symbol(x, Decl(controlFlowArrays.ts, 141, 7)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 147, 7)) while (cond()) { >cond : Symbol(cond, Decl(controlFlowArrays.ts, 0, 0)) @@ -363,88 +383,88 @@ function f15() { x.push("hello"); >x.push : Symbol(Array.push, Decl(lib.d.ts, --, --)) ->x : Symbol(x, Decl(controlFlowArrays.ts, 141, 7)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 147, 7)) >push : Symbol(Array.push, Decl(lib.d.ts, --, --)) } return x; // string[] ->x : Symbol(x, Decl(controlFlowArrays.ts, 141, 7)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 147, 7)) } function f16() { ->f16 : Symbol(f16, Decl(controlFlowArrays.ts, 147, 1)) +>f16 : Symbol(f16, Decl(controlFlowArrays.ts, 153, 1)) let x; ->x : Symbol(x, Decl(controlFlowArrays.ts, 150, 7)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 156, 7)) let y; ->y : Symbol(y, Decl(controlFlowArrays.ts, 151, 7)) +>y : Symbol(y, Decl(controlFlowArrays.ts, 157, 7)) (x = [], x).push(5); >(x = [], x).push : Symbol(Array.push, Decl(lib.d.ts, --, --)) ->x : Symbol(x, Decl(controlFlowArrays.ts, 150, 7)) ->x : Symbol(x, Decl(controlFlowArrays.ts, 150, 7)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 156, 7)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 156, 7)) >push : Symbol(Array.push, Decl(lib.d.ts, --, --)) (x.push("hello"), x).push(true); >(x.push("hello"), x).push : Symbol(Array.push, Decl(lib.d.ts, --, --)) >x.push : Symbol(Array.push, Decl(lib.d.ts, --, --)) ->x : Symbol(x, Decl(controlFlowArrays.ts, 150, 7)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 156, 7)) >push : Symbol(Array.push, Decl(lib.d.ts, --, --)) ->x : Symbol(x, Decl(controlFlowArrays.ts, 150, 7)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 156, 7)) >push : Symbol(Array.push, Decl(lib.d.ts, --, --)) ((x))[3] = { a: 1 }; ->x : Symbol(x, Decl(controlFlowArrays.ts, 150, 7)) ->a : Symbol(a, Decl(controlFlowArrays.ts, 154, 16)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 156, 7)) +>a : Symbol(a, Decl(controlFlowArrays.ts, 160, 16)) return x; // (string | number | boolean | { a: number })[] ->x : Symbol(x, Decl(controlFlowArrays.ts, 150, 7)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 156, 7)) } function f17() { ->f17 : Symbol(f17, Decl(controlFlowArrays.ts, 156, 1)) +>f17 : Symbol(f17, Decl(controlFlowArrays.ts, 162, 1)) let x = []; ->x : Symbol(x, Decl(controlFlowArrays.ts, 159, 7)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 165, 7)) x.unshift(5); >x.unshift : Symbol(Array.unshift, Decl(lib.d.ts, --, --)) ->x : Symbol(x, Decl(controlFlowArrays.ts, 159, 7)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 165, 7)) >unshift : Symbol(Array.unshift, Decl(lib.d.ts, --, --)) x.unshift("hello"); >x.unshift : Symbol(Array.unshift, Decl(lib.d.ts, --, --)) ->x : Symbol(x, Decl(controlFlowArrays.ts, 159, 7)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 165, 7)) >unshift : Symbol(Array.unshift, Decl(lib.d.ts, --, --)) x.unshift(true); >x.unshift : Symbol(Array.unshift, Decl(lib.d.ts, --, --)) ->x : Symbol(x, Decl(controlFlowArrays.ts, 159, 7)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 165, 7)) >unshift : Symbol(Array.unshift, Decl(lib.d.ts, --, --)) return x; // (string | number | boolean)[] ->x : Symbol(x, Decl(controlFlowArrays.ts, 159, 7)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 165, 7)) } function f18() { ->f18 : Symbol(f18, Decl(controlFlowArrays.ts, 164, 1)) +>f18 : Symbol(f18, Decl(controlFlowArrays.ts, 170, 1)) let x = []; ->x : Symbol(x, Decl(controlFlowArrays.ts, 167, 7)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 173, 7)) x.push(5); >x.push : Symbol(Array.push, Decl(lib.d.ts, --, --)) ->x : Symbol(x, Decl(controlFlowArrays.ts, 167, 7)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 173, 7)) >push : Symbol(Array.push, Decl(lib.d.ts, --, --)) x.unshift("hello"); >x.unshift : Symbol(Array.unshift, Decl(lib.d.ts, --, --)) ->x : Symbol(x, Decl(controlFlowArrays.ts, 167, 7)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 173, 7)) >unshift : Symbol(Array.unshift, Decl(lib.d.ts, --, --)) x[2] = true; ->x : Symbol(x, Decl(controlFlowArrays.ts, 167, 7)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 173, 7)) return x; // (string | number | boolean)[] ->x : Symbol(x, Decl(controlFlowArrays.ts, 167, 7)) +>x : Symbol(x, Decl(controlFlowArrays.ts, 173, 7)) } diff --git a/tests/baselines/reference/controlFlowArrays.types b/tests/baselines/reference/controlFlowArrays.types index 2299afd7d21..2a27bbf10de 100644 --- a/tests/baselines/reference/controlFlowArrays.types +++ b/tests/baselines/reference/controlFlowArrays.types @@ -357,18 +357,32 @@ function f10() { } function f11() { ->f11 : () => never[] +>f11 : () => string[] let x = []; >x : any[] >[] : never[] - return x; // never[] ->x : never[] + if (x.length === 0) { // x.length ok on implicit any[] +>x.length === 0 : boolean +>x.length : number +>x : any[] +>length : number +>0 : 0 + + x.push("hello"); +>x.push("hello") : number +>x.push : (...items: any[]) => number +>x : any[] +>push : (...items: any[]) => number +>"hello" : "hello" + } + return x; +>x : string[] } function f12() { ->f12 : () => never[] +>f12 : () => string[] let x; >x : any @@ -378,8 +392,22 @@ function f12() { >x : any >[] : never[] - return x; // never[] ->x : never[] + if (x.length === 0) { // x.length ok on implicit any[] +>x.length === 0 : boolean +>x.length : number +>x : any[] +>length : number +>0 : 0 + + x.push("hello"); +>x.push("hello") : number +>x.push : (...items: any[]) => number +>x : any[] +>push : (...items: any[]) => number +>"hello" : "hello" + } + return x; +>x : string[] } function f13() { diff --git a/tests/baselines/reference/genericTypeParameterEquivalence2.types b/tests/baselines/reference/genericTypeParameterEquivalence2.types index 51253764578..6ab297fe32c 100644 --- a/tests/baselines/reference/genericTypeParameterEquivalence2.types +++ b/tests/baselines/reference/genericTypeParameterEquivalence2.types @@ -105,7 +105,7 @@ function filter(f: (a: A) => boolean, ar: A[]): A[] { } ); return ret; ->ret : undefined[] +>ret : any[] } // length :: [a] -> Num diff --git a/tests/baselines/reference/globalThisCapture.types b/tests/baselines/reference/globalThisCapture.types index d17c899d1ed..063100ff78e 100644 --- a/tests/baselines/reference/globalThisCapture.types +++ b/tests/baselines/reference/globalThisCapture.types @@ -13,7 +13,7 @@ var parts = []; // Ensure that the generated code is correct parts[0]; ->parts[0] : undefined ->parts : undefined[] +>parts[0] : any +>parts : any[] >0 : 0 From 99e2219c4ef8c1f5580d873074aa17cdbedf2cac Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Thu, 13 Oct 2016 15:09:26 -0700 Subject: [PATCH 087/173] Remove unused function --- src/compiler/core.ts | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index e8fadbff6e9..3ca4abc69da 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -23,21 +23,6 @@ namespace ts { // More efficient to create a collator once and use its `compare` than to call `a.localeCompare(b)` many times. export const collator: { compare(a: string, b: string): number } = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; - /** - * Use this function instead of calling "String.prototype.localeCompre". This function will preform appropriate check to make sure that - * "typeof Intl" is correct as there are reported issues #11110 nad #11339. - * @param a reference string to compare - * @param b string to compare against - * @param locales string of BCP 47 language tag or an array of string of BCP 47 language tag - * @param options an object of Intl.CollatorOptions to specify localeCompare properties - */ - export function localeCompare(a: string, b: string, locales?: string | string[], options?: Intl.CollatorOptions): number | undefined { - if (collator && String.prototype.localeCompare) { - return a.localeCompare(b, locales, options); - } - return undefined; - } - export function createMap(template?: MapLike): Map { const map: Map = createObject(null); // tslint:disable-line:no-null-keyword From a6443e3e5a722bf7eb48b8b1f5c87b13efbc70c4 Mon Sep 17 00:00:00 2001 From: Zhengbo Li Date: Thu, 13 Oct 2016 15:39:09 -0700 Subject: [PATCH 088/173] Avoid watching non-existing directories and fix null-exception (#11601) * Avoid watching non-existing directories and fix null-exception * Add test * Move the fix to sys to cover tsc -w also --- src/compiler/sys.ts | 4 +++ .../unittests/tsserverProjectSystem.ts | 29 +++++++++++++++++++ src/server/editorServices.ts | 2 +- 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 7cf7d75bc02..1efa1e2b010 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -476,6 +476,10 @@ namespace ts { // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows // (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643) let options: any; + if (!directoryExists(directoryName)) { + return; + } + if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) { options = { persistent: true, recursive: !!recursive }; } diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index 08e4bac7b2c..dc4cdd08520 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -2387,4 +2387,33 @@ namespace ts.projectSystem { assert.isTrue(errorResult.length === 0); }); }); + + describe("non-existing directories listed in config file input array", () => { + it("should be tolerated without crashing the server", () => { + const configFile = { + path: "/a/b/tsconfig.json", + content: `{ + "compilerOptions": {}, + "include": ["app/*", "test/**/*", "something"] + }` + }; + const file1 = { + path: "/a/b/file1.ts", + content: "let t = 10;" + }; + + const host = createServerHost([file1, configFile]); + const projectService = createProjectService(host); + projectService.openClientFile(file1.path); + host.runQueuedTimeoutCallbacks(); + checkNumberOfConfiguredProjects(projectService, 1); + checkNumberOfInferredProjects(projectService, 1); + + const configuredProject = projectService.configuredProjects[0]; + assert.isTrue(configuredProject.getFileNames().length == 0); + + const inferredProject = projectService.inferredProjects[0]; + assert.isTrue(inferredProject.containsFile(file1.path)); + }); + }); } \ No newline at end of file diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 1a331c09320..91b9f90c88b 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -710,7 +710,7 @@ namespace ts.server { Debug.assert(!!parsedCommandLine.fileNames); if (parsedCommandLine.fileNames.length === 0) { - errors.push(createCompilerDiagnostic(Diagnostics.The_config_file_0_found_doesn_t_contain_any_source_files, configFilename)); + (errors || (errors = [])).push(createCompilerDiagnostic(Diagnostics.The_config_file_0_found_doesn_t_contain_any_source_files, configFilename)); return { success: false, configFileErrors: errors }; } From e9242b16811bba61daca883a940100210824d2fa Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 14 Oct 2016 01:23:14 +0200 Subject: [PATCH 089/173] fix typo in type definition (#11346) --- src/lib/es2015.core.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/es2015.core.d.ts b/src/lib/es2015.core.d.ts index 5d570bb0866..356512ecf58 100644 --- a/src/lib/es2015.core.d.ts +++ b/src/lib/es2015.core.d.ts @@ -201,7 +201,7 @@ interface NumberConstructor { /** * Returns true if passed value is finite. - * Unlike the global isFininte, Number.isFinite doesn't forcibly convert the parameter to a + * Unlike the global isFinite, Number.isFinite doesn't forcibly convert the parameter to a * number. Only finite values of the type number, result in true. * @param number A numeric value. */ From 7060f51fb2d7e439f22634ea352417de4f9d8e5a Mon Sep 17 00:00:00 2001 From: falsandtru Date: Fri, 14 Oct 2016 08:24:05 +0900 Subject: [PATCH 090/173] Fix the Function interface (#11269) (#11293) --- lib/lib.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/lib.d.ts b/lib/lib.d.ts index 586b3675305..d8be920dc0a 100644 --- a/lib/lib.d.ts +++ b/lib/lib.d.ts @@ -260,6 +260,9 @@ interface Function { */ bind(this: Function, thisArg: any, ...argArray: any[]): any; + /** Returns a string representation of an object. */ + toString(): string; + prototype: any; readonly length: number; From dd26822cc0b4c2e6838d2523ab0b99f3a9b031b9 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Thu, 13 Oct 2016 16:46:44 -0700 Subject: [PATCH 091/173] Merge pull request #11594 from Microsoft/vladima/fix-11590 return result from SetCompilerOptionsForInferredProject request --- src/server/session.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/server/session.ts b/src/server/session.ts index 111ba53a700..bd31277716f 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -1590,7 +1590,8 @@ namespace ts.server { return this.requiredResponse(this.getDocumentHighlights(request.arguments, /*simplifiedResult*/ false)); }, [CommandNames.CompilerOptionsForInferredProjects]: (request: protocol.SetCompilerOptionsForInferredProjectsRequest) => { - return this.requiredResponse(this.setCompilerOptionsForInferredProjects(request.arguments)); + this.setCompilerOptionsForInferredProjects(request.arguments); + return this.requiredResponse(true); }, [CommandNames.ProjectInfo]: (request: protocol.ProjectInfoRequest) => { return this.requiredResponse(this.getProjectInfo(request.arguments)); From 2920f8280452f38f2478c30976f6a5fa0c55ab96 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 13 Oct 2016 16:54:09 -0700 Subject: [PATCH 092/173] Add error reporting for using `--noImplicitUseStrict` with `--options.alwaysStrict` --- src/compiler/program.ts | 4 +++ .../reference/alwaysStrictModule2.errors.txt | 22 ++++++++++++ .../reference/alwaysStrictModule2.js | 34 +++++++++++++++++++ ...alwaysStrictNoImplicitUseStrict.errors.txt | 2 ++ tests/cases/compiler/alwaysStrictModule2.ts | 16 +++++++++ 5 files changed, 78 insertions(+) create mode 100644 tests/baselines/reference/alwaysStrictModule2.errors.txt create mode 100644 tests/baselines/reference/alwaysStrictModule2.js create mode 100644 tests/cases/compiler/alwaysStrictModule2.ts diff --git a/src/compiler/program.ts b/src/compiler/program.ts index a52ffc85452..9404be2127e 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1473,6 +1473,10 @@ namespace ts { programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "lib", "noLib")); } + if (options.noImplicitUseStrict && options.alwaysStrict) { + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noImplicitUseStrict", "alwaysStrict")); + } + const languageVersion = options.target || ScriptTarget.ES3; const outFile = options.outFile || options.out; diff --git a/tests/baselines/reference/alwaysStrictModule2.errors.txt b/tests/baselines/reference/alwaysStrictModule2.errors.txt new file mode 100644 index 00000000000..3980d24abfc --- /dev/null +++ b/tests/baselines/reference/alwaysStrictModule2.errors.txt @@ -0,0 +1,22 @@ +tests/cases/compiler/a.ts(4,13): error TS1100: Invalid use of 'arguments' in strict mode. +tests/cases/compiler/b.ts(3,13): error TS1100: Invalid use of 'arguments' in strict mode. + + +==== tests/cases/compiler/a.ts (1 errors) ==== + + module M { + export function f() { + var arguments = []; + ~~~~~~~~~ +!!! error TS1100: Invalid use of 'arguments' in strict mode. + } + } + +==== tests/cases/compiler/b.ts (1 errors) ==== + module M { + export function f2() { + var arguments = []; + ~~~~~~~~~ +!!! error TS1100: Invalid use of 'arguments' in strict mode. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/alwaysStrictModule2.js b/tests/baselines/reference/alwaysStrictModule2.js new file mode 100644 index 00000000000..54f179ff10b --- /dev/null +++ b/tests/baselines/reference/alwaysStrictModule2.js @@ -0,0 +1,34 @@ +//// [tests/cases/compiler/alwaysStrictModule2.ts] //// + +//// [a.ts] + +module M { + export function f() { + var arguments = []; + } +} + +//// [b.ts] +module M { + export function f2() { + var arguments = []; + } +} + +//// [out.js] +"use strict"; +var M; +(function (M) { + function f() { + var arguments = []; + } + M.f = f; +})(M || (M = {})); +"use strict"; +var M; +(function (M) { + function f2() { + var arguments = []; + } + M.f2 = f2; +})(M || (M = {})); diff --git a/tests/baselines/reference/alwaysStrictNoImplicitUseStrict.errors.txt b/tests/baselines/reference/alwaysStrictNoImplicitUseStrict.errors.txt index d677ec9b4cb..8df1d76e546 100644 --- a/tests/baselines/reference/alwaysStrictNoImplicitUseStrict.errors.txt +++ b/tests/baselines/reference/alwaysStrictNoImplicitUseStrict.errors.txt @@ -1,6 +1,8 @@ +error TS5053: Option 'noImplicitUseStrict' cannot be specified with option 'alwaysStrict'. tests/cases/compiler/alwaysStrictNoImplicitUseStrict.ts(4,13): error TS1100: Invalid use of 'arguments' in strict mode. +!!! error TS5053: Option 'noImplicitUseStrict' cannot be specified with option 'alwaysStrict'. ==== tests/cases/compiler/alwaysStrictNoImplicitUseStrict.ts (1 errors) ==== module M { diff --git a/tests/cases/compiler/alwaysStrictModule2.ts b/tests/cases/compiler/alwaysStrictModule2.ts new file mode 100644 index 00000000000..6afecb0e770 --- /dev/null +++ b/tests/cases/compiler/alwaysStrictModule2.ts @@ -0,0 +1,16 @@ +// @alwaysStrict: true +// @outFile: out.js + +// @fileName: a.ts +module M { + export function f() { + var arguments = []; + } +} + +// @fileName: b.ts +module M { + export function f2() { + var arguments = []; + } +} \ No newline at end of file From 80ef3486231000fab6d3a279e2ce9269ca5efedf Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 13 Oct 2016 16:56:59 -0700 Subject: [PATCH 093/173] Add buildProtocol.js --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 4fff675801f..5e4bc0af5ea 100644 --- a/.gitignore +++ b/.gitignore @@ -42,6 +42,7 @@ scripts/debug.bat scripts/run.bat scripts/word2md.js scripts/ior.js +scripts/buildProtocol.js scripts/*.js.map scripts/typings/ coverage/ From 97d40ab4329b4b0ef7083987762dc576c712198b Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 13 Oct 2016 17:08:58 -0700 Subject: [PATCH 094/173] Update LKG --- lib/lib.d.ts | 406 +- lib/lib.dom.d.ts | 381 +- lib/lib.es2015.core.d.ts | 2 +- lib/lib.es5.d.ts | 24 + lib/lib.es6.d.ts | 405 +- lib/lib.webworker.d.ts | 12 +- lib/protocol.d.ts | 1848 +++++++ lib/tsc.js | 3575 ++++++------ lib/tsserver.js | 10126 +++++++++++++++++++++------------- lib/tsserverlibrary.d.ts | 2356 ++++++-- lib/tsserverlibrary.js | 9961 ++++++++++++++++++++------------- lib/typescript.d.ts | 480 +- lib/typescript.js | 4929 ++++++++++------- lib/typescriptServices.d.ts | 480 +- lib/typescriptServices.js | 4929 ++++++++++------- lib/typingsInstaller.js | 377 +- 16 files changed, 25228 insertions(+), 15063 deletions(-) create mode 100644 lib/protocol.d.ts diff --git a/lib/lib.d.ts b/lib/lib.d.ts index d8be920dc0a..87280fedba4 100644 --- a/lib/lib.d.ts +++ b/lib/lib.d.ts @@ -260,9 +260,6 @@ interface Function { */ bind(this: Function, thisArg: any, ...argArray: any[]): any; - /** Returns a string representation of an object. */ - toString(): string; - prototype: any; readonly length: number; @@ -1219,6 +1216,30 @@ interface Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; + /** + * Calls a defined callback function on each element of an array, and returns an array that contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + map(this: [T, T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U, U]; + /** + * Calls a defined callback function on each element of an array, and returns an array that contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + map(this: [T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U]; + /** + * Calls a defined callback function on each element of an array, and returns an array that contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + map(this: [T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U]; + /** + * Calls a defined callback function on each element of an array, and returns an array that contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + map(this: [T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U]; /** * Calls a defined callback function on each element of an array, and returns an array that contains the results. * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. @@ -11663,11 +11684,12 @@ declare var HashChangeEvent: { interface History { readonly length: number; readonly state: any; - back(distance?: any): void; - forward(distance?: any): void; - go(delta?: any): void; - pushState(statedata: any, title?: string, url?: string): void; - replaceState(statedata: any, title?: string, url?: string): void; + scrollRestoration: ScrollRestoration; + back(): void; + forward(): void; + go(delta?: number): void; + pushState(data: any, title: string, url?: string | null): void; + replaceState(data: any, title: string, url?: string | null): void; } declare var History: { @@ -17239,7 +17261,6 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window addEventListener(type: "waiting", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "wheel", listener: (this: this, ev: WheelEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; - [index: number]: Window; } declare var Window: { @@ -17270,7 +17291,7 @@ declare var XMLDocument: { } interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { - onreadystatechange: (this: this, ev: ProgressEvent) => any; + onreadystatechange: (this: this, ev: Event) => any; readonly readyState: number; readonly response: any; readonly responseText: string; @@ -17297,13 +17318,13 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { readonly LOADING: number; readonly OPENED: number; readonly UNSENT: number; - addEventListener(type: "abort", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "load", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "loadstart", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; addEventListener(type: "progress", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "readystatechange", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "timeout", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -17644,183 +17665,183 @@ interface NavigatorUserMedia { } interface NodeSelector { - querySelector(selectors: "a"): HTMLAnchorElement; - querySelector(selectors: "abbr"): HTMLElement; - querySelector(selectors: "acronym"): HTMLElement; - querySelector(selectors: "address"): HTMLElement; - querySelector(selectors: "applet"): HTMLAppletElement; - querySelector(selectors: "area"): HTMLAreaElement; - querySelector(selectors: "article"): HTMLElement; - querySelector(selectors: "aside"): HTMLElement; - querySelector(selectors: "audio"): HTMLAudioElement; - querySelector(selectors: "b"): HTMLElement; - querySelector(selectors: "base"): HTMLBaseElement; - querySelector(selectors: "basefont"): HTMLBaseFontElement; - querySelector(selectors: "bdo"): HTMLElement; - querySelector(selectors: "big"): HTMLElement; - querySelector(selectors: "blockquote"): HTMLQuoteElement; - querySelector(selectors: "body"): HTMLBodyElement; - querySelector(selectors: "br"): HTMLBRElement; - querySelector(selectors: "button"): HTMLButtonElement; - querySelector(selectors: "canvas"): HTMLCanvasElement; - querySelector(selectors: "caption"): HTMLTableCaptionElement; - querySelector(selectors: "center"): HTMLElement; - querySelector(selectors: "circle"): SVGCircleElement; - querySelector(selectors: "cite"): HTMLElement; - querySelector(selectors: "clippath"): SVGClipPathElement; - querySelector(selectors: "code"): HTMLElement; - querySelector(selectors: "col"): HTMLTableColElement; - querySelector(selectors: "colgroup"): HTMLTableColElement; - querySelector(selectors: "datalist"): HTMLDataListElement; - querySelector(selectors: "dd"): HTMLElement; - querySelector(selectors: "defs"): SVGDefsElement; - querySelector(selectors: "del"): HTMLModElement; - querySelector(selectors: "desc"): SVGDescElement; - querySelector(selectors: "dfn"): HTMLElement; - querySelector(selectors: "dir"): HTMLDirectoryElement; - querySelector(selectors: "div"): HTMLDivElement; - querySelector(selectors: "dl"): HTMLDListElement; - querySelector(selectors: "dt"): HTMLElement; - querySelector(selectors: "ellipse"): SVGEllipseElement; - querySelector(selectors: "em"): HTMLElement; - querySelector(selectors: "embed"): HTMLEmbedElement; - querySelector(selectors: "feblend"): SVGFEBlendElement; - querySelector(selectors: "fecolormatrix"): SVGFEColorMatrixElement; - querySelector(selectors: "fecomponenttransfer"): SVGFEComponentTransferElement; - querySelector(selectors: "fecomposite"): SVGFECompositeElement; - querySelector(selectors: "feconvolvematrix"): SVGFEConvolveMatrixElement; - querySelector(selectors: "fediffuselighting"): SVGFEDiffuseLightingElement; - querySelector(selectors: "fedisplacementmap"): SVGFEDisplacementMapElement; - querySelector(selectors: "fedistantlight"): SVGFEDistantLightElement; - querySelector(selectors: "feflood"): SVGFEFloodElement; - querySelector(selectors: "fefunca"): SVGFEFuncAElement; - querySelector(selectors: "fefuncb"): SVGFEFuncBElement; - querySelector(selectors: "fefuncg"): SVGFEFuncGElement; - querySelector(selectors: "fefuncr"): SVGFEFuncRElement; - querySelector(selectors: "fegaussianblur"): SVGFEGaussianBlurElement; - querySelector(selectors: "feimage"): SVGFEImageElement; - querySelector(selectors: "femerge"): SVGFEMergeElement; - querySelector(selectors: "femergenode"): SVGFEMergeNodeElement; - querySelector(selectors: "femorphology"): SVGFEMorphologyElement; - querySelector(selectors: "feoffset"): SVGFEOffsetElement; - querySelector(selectors: "fepointlight"): SVGFEPointLightElement; - querySelector(selectors: "fespecularlighting"): SVGFESpecularLightingElement; - querySelector(selectors: "fespotlight"): SVGFESpotLightElement; - querySelector(selectors: "fetile"): SVGFETileElement; - querySelector(selectors: "feturbulence"): SVGFETurbulenceElement; - querySelector(selectors: "fieldset"): HTMLFieldSetElement; - querySelector(selectors: "figcaption"): HTMLElement; - querySelector(selectors: "figure"): HTMLElement; - querySelector(selectors: "filter"): SVGFilterElement; - querySelector(selectors: "font"): HTMLFontElement; - querySelector(selectors: "footer"): HTMLElement; - querySelector(selectors: "foreignobject"): SVGForeignObjectElement; - querySelector(selectors: "form"): HTMLFormElement; - querySelector(selectors: "frame"): HTMLFrameElement; - querySelector(selectors: "frameset"): HTMLFrameSetElement; - querySelector(selectors: "g"): SVGGElement; - querySelector(selectors: "h1"): HTMLHeadingElement; - querySelector(selectors: "h2"): HTMLHeadingElement; - querySelector(selectors: "h3"): HTMLHeadingElement; - querySelector(selectors: "h4"): HTMLHeadingElement; - querySelector(selectors: "h5"): HTMLHeadingElement; - querySelector(selectors: "h6"): HTMLHeadingElement; - querySelector(selectors: "head"): HTMLHeadElement; - querySelector(selectors: "header"): HTMLElement; - querySelector(selectors: "hgroup"): HTMLElement; - querySelector(selectors: "hr"): HTMLHRElement; - querySelector(selectors: "html"): HTMLHtmlElement; - querySelector(selectors: "i"): HTMLElement; - querySelector(selectors: "iframe"): HTMLIFrameElement; - querySelector(selectors: "image"): SVGImageElement; - querySelector(selectors: "img"): HTMLImageElement; - querySelector(selectors: "input"): HTMLInputElement; - querySelector(selectors: "ins"): HTMLModElement; - querySelector(selectors: "isindex"): HTMLUnknownElement; - querySelector(selectors: "kbd"): HTMLElement; - querySelector(selectors: "keygen"): HTMLElement; - querySelector(selectors: "label"): HTMLLabelElement; - querySelector(selectors: "legend"): HTMLLegendElement; - querySelector(selectors: "li"): HTMLLIElement; - querySelector(selectors: "line"): SVGLineElement; - querySelector(selectors: "lineargradient"): SVGLinearGradientElement; - querySelector(selectors: "link"): HTMLLinkElement; - querySelector(selectors: "listing"): HTMLPreElement; - querySelector(selectors: "map"): HTMLMapElement; - querySelector(selectors: "mark"): HTMLElement; - querySelector(selectors: "marker"): SVGMarkerElement; - querySelector(selectors: "marquee"): HTMLMarqueeElement; - querySelector(selectors: "mask"): SVGMaskElement; - querySelector(selectors: "menu"): HTMLMenuElement; - querySelector(selectors: "meta"): HTMLMetaElement; - querySelector(selectors: "metadata"): SVGMetadataElement; - querySelector(selectors: "meter"): HTMLMeterElement; - querySelector(selectors: "nav"): HTMLElement; - querySelector(selectors: "nextid"): HTMLUnknownElement; - querySelector(selectors: "nobr"): HTMLElement; - querySelector(selectors: "noframes"): HTMLElement; - querySelector(selectors: "noscript"): HTMLElement; - querySelector(selectors: "object"): HTMLObjectElement; - querySelector(selectors: "ol"): HTMLOListElement; - querySelector(selectors: "optgroup"): HTMLOptGroupElement; - querySelector(selectors: "option"): HTMLOptionElement; - querySelector(selectors: "p"): HTMLParagraphElement; - querySelector(selectors: "param"): HTMLParamElement; - querySelector(selectors: "path"): SVGPathElement; - querySelector(selectors: "pattern"): SVGPatternElement; - querySelector(selectors: "picture"): HTMLPictureElement; - querySelector(selectors: "plaintext"): HTMLElement; - querySelector(selectors: "polygon"): SVGPolygonElement; - querySelector(selectors: "polyline"): SVGPolylineElement; - querySelector(selectors: "pre"): HTMLPreElement; - querySelector(selectors: "progress"): HTMLProgressElement; - querySelector(selectors: "q"): HTMLQuoteElement; - querySelector(selectors: "radialgradient"): SVGRadialGradientElement; - querySelector(selectors: "rect"): SVGRectElement; - querySelector(selectors: "rt"): HTMLElement; - querySelector(selectors: "ruby"): HTMLElement; - querySelector(selectors: "s"): HTMLElement; - querySelector(selectors: "samp"): HTMLElement; - querySelector(selectors: "script"): HTMLScriptElement; - querySelector(selectors: "section"): HTMLElement; - querySelector(selectors: "select"): HTMLSelectElement; - querySelector(selectors: "small"): HTMLElement; - querySelector(selectors: "source"): HTMLSourceElement; - querySelector(selectors: "span"): HTMLSpanElement; - querySelector(selectors: "stop"): SVGStopElement; - querySelector(selectors: "strike"): HTMLElement; - querySelector(selectors: "strong"): HTMLElement; - querySelector(selectors: "style"): HTMLStyleElement; - querySelector(selectors: "sub"): HTMLElement; - querySelector(selectors: "sup"): HTMLElement; - querySelector(selectors: "svg"): SVGSVGElement; - querySelector(selectors: "switch"): SVGSwitchElement; - querySelector(selectors: "symbol"): SVGSymbolElement; - querySelector(selectors: "table"): HTMLTableElement; - querySelector(selectors: "tbody"): HTMLTableSectionElement; - querySelector(selectors: "td"): HTMLTableDataCellElement; - querySelector(selectors: "template"): HTMLTemplateElement; - querySelector(selectors: "text"): SVGTextElement; - querySelector(selectors: "textpath"): SVGTextPathElement; - querySelector(selectors: "textarea"): HTMLTextAreaElement; - querySelector(selectors: "tfoot"): HTMLTableSectionElement; - querySelector(selectors: "th"): HTMLTableHeaderCellElement; - querySelector(selectors: "thead"): HTMLTableSectionElement; - querySelector(selectors: "title"): HTMLTitleElement; - querySelector(selectors: "tr"): HTMLTableRowElement; - querySelector(selectors: "track"): HTMLTrackElement; - querySelector(selectors: "tspan"): SVGTSpanElement; - querySelector(selectors: "tt"): HTMLElement; - querySelector(selectors: "u"): HTMLElement; - querySelector(selectors: "ul"): HTMLUListElement; - querySelector(selectors: "use"): SVGUseElement; - querySelector(selectors: "var"): HTMLElement; - querySelector(selectors: "video"): HTMLVideoElement; - querySelector(selectors: "view"): SVGViewElement; - querySelector(selectors: "wbr"): HTMLElement; - querySelector(selectors: "x-ms-webview"): MSHTMLWebViewElement; - querySelector(selectors: "xmp"): HTMLPreElement; - querySelector(selectors: string): Element; + querySelector(selectors: "a"): HTMLAnchorElement | null; + querySelector(selectors: "abbr"): HTMLElement | null; + querySelector(selectors: "acronym"): HTMLElement | null; + querySelector(selectors: "address"): HTMLElement | null; + querySelector(selectors: "applet"): HTMLAppletElement | null; + querySelector(selectors: "area"): HTMLAreaElement | null; + querySelector(selectors: "article"): HTMLElement | null; + querySelector(selectors: "aside"): HTMLElement | null; + querySelector(selectors: "audio"): HTMLAudioElement | null; + querySelector(selectors: "b"): HTMLElement | null; + querySelector(selectors: "base"): HTMLBaseElement | null; + querySelector(selectors: "basefont"): HTMLBaseFontElement | null; + querySelector(selectors: "bdo"): HTMLElement | null; + querySelector(selectors: "big"): HTMLElement | null; + querySelector(selectors: "blockquote"): HTMLQuoteElement | null; + querySelector(selectors: "body"): HTMLBodyElement | null; + querySelector(selectors: "br"): HTMLBRElement | null; + querySelector(selectors: "button"): HTMLButtonElement | null; + querySelector(selectors: "canvas"): HTMLCanvasElement | null; + querySelector(selectors: "caption"): HTMLTableCaptionElement | null; + querySelector(selectors: "center"): HTMLElement | null; + querySelector(selectors: "circle"): SVGCircleElement | null; + querySelector(selectors: "cite"): HTMLElement | null; + querySelector(selectors: "clippath"): SVGClipPathElement | null; + querySelector(selectors: "code"): HTMLElement | null; + querySelector(selectors: "col"): HTMLTableColElement | null; + querySelector(selectors: "colgroup"): HTMLTableColElement | null; + querySelector(selectors: "datalist"): HTMLDataListElement | null; + querySelector(selectors: "dd"): HTMLElement | null; + querySelector(selectors: "defs"): SVGDefsElement | null; + querySelector(selectors: "del"): HTMLModElement | null; + querySelector(selectors: "desc"): SVGDescElement | null; + querySelector(selectors: "dfn"): HTMLElement | null; + querySelector(selectors: "dir"): HTMLDirectoryElement | null; + querySelector(selectors: "div"): HTMLDivElement | null; + querySelector(selectors: "dl"): HTMLDListElement | null; + querySelector(selectors: "dt"): HTMLElement | null; + querySelector(selectors: "ellipse"): SVGEllipseElement | null; + querySelector(selectors: "em"): HTMLElement | null; + querySelector(selectors: "embed"): HTMLEmbedElement | null; + querySelector(selectors: "feblend"): SVGFEBlendElement | null; + querySelector(selectors: "fecolormatrix"): SVGFEColorMatrixElement | null; + querySelector(selectors: "fecomponenttransfer"): SVGFEComponentTransferElement | null; + querySelector(selectors: "fecomposite"): SVGFECompositeElement | null; + querySelector(selectors: "feconvolvematrix"): SVGFEConvolveMatrixElement | null; + querySelector(selectors: "fediffuselighting"): SVGFEDiffuseLightingElement | null; + querySelector(selectors: "fedisplacementmap"): SVGFEDisplacementMapElement | null; + querySelector(selectors: "fedistantlight"): SVGFEDistantLightElement | null; + querySelector(selectors: "feflood"): SVGFEFloodElement | null; + querySelector(selectors: "fefunca"): SVGFEFuncAElement | null; + querySelector(selectors: "fefuncb"): SVGFEFuncBElement | null; + querySelector(selectors: "fefuncg"): SVGFEFuncGElement | null; + querySelector(selectors: "fefuncr"): SVGFEFuncRElement | null; + querySelector(selectors: "fegaussianblur"): SVGFEGaussianBlurElement | null; + querySelector(selectors: "feimage"): SVGFEImageElement | null; + querySelector(selectors: "femerge"): SVGFEMergeElement | null; + querySelector(selectors: "femergenode"): SVGFEMergeNodeElement | null; + querySelector(selectors: "femorphology"): SVGFEMorphologyElement | null; + querySelector(selectors: "feoffset"): SVGFEOffsetElement | null; + querySelector(selectors: "fepointlight"): SVGFEPointLightElement | null; + querySelector(selectors: "fespecularlighting"): SVGFESpecularLightingElement | null; + querySelector(selectors: "fespotlight"): SVGFESpotLightElement | null; + querySelector(selectors: "fetile"): SVGFETileElement | null; + querySelector(selectors: "feturbulence"): SVGFETurbulenceElement | null; + querySelector(selectors: "fieldset"): HTMLFieldSetElement | null; + querySelector(selectors: "figcaption"): HTMLElement | null; + querySelector(selectors: "figure"): HTMLElement | null; + querySelector(selectors: "filter"): SVGFilterElement | null; + querySelector(selectors: "font"): HTMLFontElement | null; + querySelector(selectors: "footer"): HTMLElement | null; + querySelector(selectors: "foreignobject"): SVGForeignObjectElement | null; + querySelector(selectors: "form"): HTMLFormElement | null; + querySelector(selectors: "frame"): HTMLFrameElement | null; + querySelector(selectors: "frameset"): HTMLFrameSetElement | null; + querySelector(selectors: "g"): SVGGElement | null; + querySelector(selectors: "h1"): HTMLHeadingElement | null; + querySelector(selectors: "h2"): HTMLHeadingElement | null; + querySelector(selectors: "h3"): HTMLHeadingElement | null; + querySelector(selectors: "h4"): HTMLHeadingElement | null; + querySelector(selectors: "h5"): HTMLHeadingElement | null; + querySelector(selectors: "h6"): HTMLHeadingElement | null; + querySelector(selectors: "head"): HTMLHeadElement | null; + querySelector(selectors: "header"): HTMLElement | null; + querySelector(selectors: "hgroup"): HTMLElement | null; + querySelector(selectors: "hr"): HTMLHRElement | null; + querySelector(selectors: "html"): HTMLHtmlElement | null; + querySelector(selectors: "i"): HTMLElement | null; + querySelector(selectors: "iframe"): HTMLIFrameElement | null; + querySelector(selectors: "image"): SVGImageElement | null; + querySelector(selectors: "img"): HTMLImageElement | null; + querySelector(selectors: "input"): HTMLInputElement | null; + querySelector(selectors: "ins"): HTMLModElement | null; + querySelector(selectors: "isindex"): HTMLUnknownElement | null; + querySelector(selectors: "kbd"): HTMLElement | null; + querySelector(selectors: "keygen"): HTMLElement | null; + querySelector(selectors: "label"): HTMLLabelElement | null; + querySelector(selectors: "legend"): HTMLLegendElement | null; + querySelector(selectors: "li"): HTMLLIElement | null; + querySelector(selectors: "line"): SVGLineElement | null; + querySelector(selectors: "lineargradient"): SVGLinearGradientElement | null; + querySelector(selectors: "link"): HTMLLinkElement | null; + querySelector(selectors: "listing"): HTMLPreElement | null; + querySelector(selectors: "map"): HTMLMapElement | null; + querySelector(selectors: "mark"): HTMLElement | null; + querySelector(selectors: "marker"): SVGMarkerElement | null; + querySelector(selectors: "marquee"): HTMLMarqueeElement | null; + querySelector(selectors: "mask"): SVGMaskElement | null; + querySelector(selectors: "menu"): HTMLMenuElement | null; + querySelector(selectors: "meta"): HTMLMetaElement | null; + querySelector(selectors: "metadata"): SVGMetadataElement | null; + querySelector(selectors: "meter"): HTMLMeterElement | null; + querySelector(selectors: "nav"): HTMLElement | null; + querySelector(selectors: "nextid"): HTMLUnknownElement | null; + querySelector(selectors: "nobr"): HTMLElement | null; + querySelector(selectors: "noframes"): HTMLElement | null; + querySelector(selectors: "noscript"): HTMLElement | null; + querySelector(selectors: "object"): HTMLObjectElement | null; + querySelector(selectors: "ol"): HTMLOListElement | null; + querySelector(selectors: "optgroup"): HTMLOptGroupElement | null; + querySelector(selectors: "option"): HTMLOptionElement | null; + querySelector(selectors: "p"): HTMLParagraphElement | null; + querySelector(selectors: "param"): HTMLParamElement | null; + querySelector(selectors: "path"): SVGPathElement | null; + querySelector(selectors: "pattern"): SVGPatternElement | null; + querySelector(selectors: "picture"): HTMLPictureElement | null; + querySelector(selectors: "plaintext"): HTMLElement | null; + querySelector(selectors: "polygon"): SVGPolygonElement | null; + querySelector(selectors: "polyline"): SVGPolylineElement | null; + querySelector(selectors: "pre"): HTMLPreElement | null; + querySelector(selectors: "progress"): HTMLProgressElement | null; + querySelector(selectors: "q"): HTMLQuoteElement | null; + querySelector(selectors: "radialgradient"): SVGRadialGradientElement | null; + querySelector(selectors: "rect"): SVGRectElement | null; + querySelector(selectors: "rt"): HTMLElement | null; + querySelector(selectors: "ruby"): HTMLElement | null; + querySelector(selectors: "s"): HTMLElement | null; + querySelector(selectors: "samp"): HTMLElement | null; + querySelector(selectors: "script"): HTMLScriptElement | null; + querySelector(selectors: "section"): HTMLElement | null; + querySelector(selectors: "select"): HTMLSelectElement | null; + querySelector(selectors: "small"): HTMLElement | null; + querySelector(selectors: "source"): HTMLSourceElement | null; + querySelector(selectors: "span"): HTMLSpanElement | null; + querySelector(selectors: "stop"): SVGStopElement | null; + querySelector(selectors: "strike"): HTMLElement | null; + querySelector(selectors: "strong"): HTMLElement | null; + querySelector(selectors: "style"): HTMLStyleElement | null; + querySelector(selectors: "sub"): HTMLElement | null; + querySelector(selectors: "sup"): HTMLElement | null; + querySelector(selectors: "svg"): SVGSVGElement | null; + querySelector(selectors: "switch"): SVGSwitchElement | null; + querySelector(selectors: "symbol"): SVGSymbolElement | null; + querySelector(selectors: "table"): HTMLTableElement | null; + querySelector(selectors: "tbody"): HTMLTableSectionElement | null; + querySelector(selectors: "td"): HTMLTableDataCellElement | null; + querySelector(selectors: "template"): HTMLTemplateElement | null; + querySelector(selectors: "text"): SVGTextElement | null; + querySelector(selectors: "textpath"): SVGTextPathElement | null; + querySelector(selectors: "textarea"): HTMLTextAreaElement | null; + querySelector(selectors: "tfoot"): HTMLTableSectionElement | null; + querySelector(selectors: "th"): HTMLTableHeaderCellElement | null; + querySelector(selectors: "thead"): HTMLTableSectionElement | null; + querySelector(selectors: "title"): HTMLTitleElement | null; + querySelector(selectors: "tr"): HTMLTableRowElement | null; + querySelector(selectors: "track"): HTMLTrackElement | null; + querySelector(selectors: "tspan"): SVGTSpanElement | null; + querySelector(selectors: "tt"): HTMLElement | null; + querySelector(selectors: "u"): HTMLElement | null; + querySelector(selectors: "ul"): HTMLUListElement | null; + querySelector(selectors: "use"): SVGUseElement | null; + querySelector(selectors: "var"): HTMLElement | null; + querySelector(selectors: "video"): HTMLVideoElement | null; + querySelector(selectors: "view"): SVGViewElement | null; + querySelector(selectors: "wbr"): HTMLElement | null; + querySelector(selectors: "x-ms-webview"): MSHTMLWebViewElement | null; + querySelector(selectors: "xmp"): HTMLPreElement | null; + querySelector(selectors: string): Element | null; querySelectorAll(selectors: "a"): NodeListOf; querySelectorAll(selectors: "abbr"): NodeListOf; querySelectorAll(selectors: "acronym"): NodeListOf; @@ -18750,6 +18771,7 @@ type ScrollLogicalPosition = "start" | "center" | "end" | "nearest"; type IDBValidKey = number | string | Date | IDBArrayKey; type BufferSource = ArrayBuffer | ArrayBufferView; type MouseWheelEvent = WheelEvent; +type ScrollRestoration = "auto" | "manual"; ///////////////////////////// /// WorkerGlobalScope APIs ///////////////////////////// diff --git a/lib/lib.dom.d.ts b/lib/lib.dom.d.ts index 4e45a38c17e..4c19c878064 100644 --- a/lib/lib.dom.d.ts +++ b/lib/lib.dom.d.ts @@ -7552,11 +7552,12 @@ declare var HashChangeEvent: { interface History { readonly length: number; readonly state: any; - back(distance?: any): void; - forward(distance?: any): void; - go(delta?: any): void; - pushState(statedata: any, title?: string, url?: string): void; - replaceState(statedata: any, title?: string, url?: string): void; + scrollRestoration: ScrollRestoration; + back(): void; + forward(): void; + go(delta?: number): void; + pushState(data: any, title: string, url?: string | null): void; + replaceState(data: any, title: string, url?: string | null): void; } declare var History: { @@ -13128,7 +13129,6 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window addEventListener(type: "waiting", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "wheel", listener: (this: this, ev: WheelEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; - [index: number]: Window; } declare var Window: { @@ -13159,7 +13159,7 @@ declare var XMLDocument: { } interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { - onreadystatechange: (this: this, ev: ProgressEvent) => any; + onreadystatechange: (this: this, ev: Event) => any; readonly readyState: number; readonly response: any; readonly responseText: string; @@ -13186,13 +13186,13 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { readonly LOADING: number; readonly OPENED: number; readonly UNSENT: number; - addEventListener(type: "abort", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "load", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "loadstart", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; addEventListener(type: "progress", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "readystatechange", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "timeout", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -13533,183 +13533,183 @@ interface NavigatorUserMedia { } interface NodeSelector { - querySelector(selectors: "a"): HTMLAnchorElement; - querySelector(selectors: "abbr"): HTMLElement; - querySelector(selectors: "acronym"): HTMLElement; - querySelector(selectors: "address"): HTMLElement; - querySelector(selectors: "applet"): HTMLAppletElement; - querySelector(selectors: "area"): HTMLAreaElement; - querySelector(selectors: "article"): HTMLElement; - querySelector(selectors: "aside"): HTMLElement; - querySelector(selectors: "audio"): HTMLAudioElement; - querySelector(selectors: "b"): HTMLElement; - querySelector(selectors: "base"): HTMLBaseElement; - querySelector(selectors: "basefont"): HTMLBaseFontElement; - querySelector(selectors: "bdo"): HTMLElement; - querySelector(selectors: "big"): HTMLElement; - querySelector(selectors: "blockquote"): HTMLQuoteElement; - querySelector(selectors: "body"): HTMLBodyElement; - querySelector(selectors: "br"): HTMLBRElement; - querySelector(selectors: "button"): HTMLButtonElement; - querySelector(selectors: "canvas"): HTMLCanvasElement; - querySelector(selectors: "caption"): HTMLTableCaptionElement; - querySelector(selectors: "center"): HTMLElement; - querySelector(selectors: "circle"): SVGCircleElement; - querySelector(selectors: "cite"): HTMLElement; - querySelector(selectors: "clippath"): SVGClipPathElement; - querySelector(selectors: "code"): HTMLElement; - querySelector(selectors: "col"): HTMLTableColElement; - querySelector(selectors: "colgroup"): HTMLTableColElement; - querySelector(selectors: "datalist"): HTMLDataListElement; - querySelector(selectors: "dd"): HTMLElement; - querySelector(selectors: "defs"): SVGDefsElement; - querySelector(selectors: "del"): HTMLModElement; - querySelector(selectors: "desc"): SVGDescElement; - querySelector(selectors: "dfn"): HTMLElement; - querySelector(selectors: "dir"): HTMLDirectoryElement; - querySelector(selectors: "div"): HTMLDivElement; - querySelector(selectors: "dl"): HTMLDListElement; - querySelector(selectors: "dt"): HTMLElement; - querySelector(selectors: "ellipse"): SVGEllipseElement; - querySelector(selectors: "em"): HTMLElement; - querySelector(selectors: "embed"): HTMLEmbedElement; - querySelector(selectors: "feblend"): SVGFEBlendElement; - querySelector(selectors: "fecolormatrix"): SVGFEColorMatrixElement; - querySelector(selectors: "fecomponenttransfer"): SVGFEComponentTransferElement; - querySelector(selectors: "fecomposite"): SVGFECompositeElement; - querySelector(selectors: "feconvolvematrix"): SVGFEConvolveMatrixElement; - querySelector(selectors: "fediffuselighting"): SVGFEDiffuseLightingElement; - querySelector(selectors: "fedisplacementmap"): SVGFEDisplacementMapElement; - querySelector(selectors: "fedistantlight"): SVGFEDistantLightElement; - querySelector(selectors: "feflood"): SVGFEFloodElement; - querySelector(selectors: "fefunca"): SVGFEFuncAElement; - querySelector(selectors: "fefuncb"): SVGFEFuncBElement; - querySelector(selectors: "fefuncg"): SVGFEFuncGElement; - querySelector(selectors: "fefuncr"): SVGFEFuncRElement; - querySelector(selectors: "fegaussianblur"): SVGFEGaussianBlurElement; - querySelector(selectors: "feimage"): SVGFEImageElement; - querySelector(selectors: "femerge"): SVGFEMergeElement; - querySelector(selectors: "femergenode"): SVGFEMergeNodeElement; - querySelector(selectors: "femorphology"): SVGFEMorphologyElement; - querySelector(selectors: "feoffset"): SVGFEOffsetElement; - querySelector(selectors: "fepointlight"): SVGFEPointLightElement; - querySelector(selectors: "fespecularlighting"): SVGFESpecularLightingElement; - querySelector(selectors: "fespotlight"): SVGFESpotLightElement; - querySelector(selectors: "fetile"): SVGFETileElement; - querySelector(selectors: "feturbulence"): SVGFETurbulenceElement; - querySelector(selectors: "fieldset"): HTMLFieldSetElement; - querySelector(selectors: "figcaption"): HTMLElement; - querySelector(selectors: "figure"): HTMLElement; - querySelector(selectors: "filter"): SVGFilterElement; - querySelector(selectors: "font"): HTMLFontElement; - querySelector(selectors: "footer"): HTMLElement; - querySelector(selectors: "foreignobject"): SVGForeignObjectElement; - querySelector(selectors: "form"): HTMLFormElement; - querySelector(selectors: "frame"): HTMLFrameElement; - querySelector(selectors: "frameset"): HTMLFrameSetElement; - querySelector(selectors: "g"): SVGGElement; - querySelector(selectors: "h1"): HTMLHeadingElement; - querySelector(selectors: "h2"): HTMLHeadingElement; - querySelector(selectors: "h3"): HTMLHeadingElement; - querySelector(selectors: "h4"): HTMLHeadingElement; - querySelector(selectors: "h5"): HTMLHeadingElement; - querySelector(selectors: "h6"): HTMLHeadingElement; - querySelector(selectors: "head"): HTMLHeadElement; - querySelector(selectors: "header"): HTMLElement; - querySelector(selectors: "hgroup"): HTMLElement; - querySelector(selectors: "hr"): HTMLHRElement; - querySelector(selectors: "html"): HTMLHtmlElement; - querySelector(selectors: "i"): HTMLElement; - querySelector(selectors: "iframe"): HTMLIFrameElement; - querySelector(selectors: "image"): SVGImageElement; - querySelector(selectors: "img"): HTMLImageElement; - querySelector(selectors: "input"): HTMLInputElement; - querySelector(selectors: "ins"): HTMLModElement; - querySelector(selectors: "isindex"): HTMLUnknownElement; - querySelector(selectors: "kbd"): HTMLElement; - querySelector(selectors: "keygen"): HTMLElement; - querySelector(selectors: "label"): HTMLLabelElement; - querySelector(selectors: "legend"): HTMLLegendElement; - querySelector(selectors: "li"): HTMLLIElement; - querySelector(selectors: "line"): SVGLineElement; - querySelector(selectors: "lineargradient"): SVGLinearGradientElement; - querySelector(selectors: "link"): HTMLLinkElement; - querySelector(selectors: "listing"): HTMLPreElement; - querySelector(selectors: "map"): HTMLMapElement; - querySelector(selectors: "mark"): HTMLElement; - querySelector(selectors: "marker"): SVGMarkerElement; - querySelector(selectors: "marquee"): HTMLMarqueeElement; - querySelector(selectors: "mask"): SVGMaskElement; - querySelector(selectors: "menu"): HTMLMenuElement; - querySelector(selectors: "meta"): HTMLMetaElement; - querySelector(selectors: "metadata"): SVGMetadataElement; - querySelector(selectors: "meter"): HTMLMeterElement; - querySelector(selectors: "nav"): HTMLElement; - querySelector(selectors: "nextid"): HTMLUnknownElement; - querySelector(selectors: "nobr"): HTMLElement; - querySelector(selectors: "noframes"): HTMLElement; - querySelector(selectors: "noscript"): HTMLElement; - querySelector(selectors: "object"): HTMLObjectElement; - querySelector(selectors: "ol"): HTMLOListElement; - querySelector(selectors: "optgroup"): HTMLOptGroupElement; - querySelector(selectors: "option"): HTMLOptionElement; - querySelector(selectors: "p"): HTMLParagraphElement; - querySelector(selectors: "param"): HTMLParamElement; - querySelector(selectors: "path"): SVGPathElement; - querySelector(selectors: "pattern"): SVGPatternElement; - querySelector(selectors: "picture"): HTMLPictureElement; - querySelector(selectors: "plaintext"): HTMLElement; - querySelector(selectors: "polygon"): SVGPolygonElement; - querySelector(selectors: "polyline"): SVGPolylineElement; - querySelector(selectors: "pre"): HTMLPreElement; - querySelector(selectors: "progress"): HTMLProgressElement; - querySelector(selectors: "q"): HTMLQuoteElement; - querySelector(selectors: "radialgradient"): SVGRadialGradientElement; - querySelector(selectors: "rect"): SVGRectElement; - querySelector(selectors: "rt"): HTMLElement; - querySelector(selectors: "ruby"): HTMLElement; - querySelector(selectors: "s"): HTMLElement; - querySelector(selectors: "samp"): HTMLElement; - querySelector(selectors: "script"): HTMLScriptElement; - querySelector(selectors: "section"): HTMLElement; - querySelector(selectors: "select"): HTMLSelectElement; - querySelector(selectors: "small"): HTMLElement; - querySelector(selectors: "source"): HTMLSourceElement; - querySelector(selectors: "span"): HTMLSpanElement; - querySelector(selectors: "stop"): SVGStopElement; - querySelector(selectors: "strike"): HTMLElement; - querySelector(selectors: "strong"): HTMLElement; - querySelector(selectors: "style"): HTMLStyleElement; - querySelector(selectors: "sub"): HTMLElement; - querySelector(selectors: "sup"): HTMLElement; - querySelector(selectors: "svg"): SVGSVGElement; - querySelector(selectors: "switch"): SVGSwitchElement; - querySelector(selectors: "symbol"): SVGSymbolElement; - querySelector(selectors: "table"): HTMLTableElement; - querySelector(selectors: "tbody"): HTMLTableSectionElement; - querySelector(selectors: "td"): HTMLTableDataCellElement; - querySelector(selectors: "template"): HTMLTemplateElement; - querySelector(selectors: "text"): SVGTextElement; - querySelector(selectors: "textpath"): SVGTextPathElement; - querySelector(selectors: "textarea"): HTMLTextAreaElement; - querySelector(selectors: "tfoot"): HTMLTableSectionElement; - querySelector(selectors: "th"): HTMLTableHeaderCellElement; - querySelector(selectors: "thead"): HTMLTableSectionElement; - querySelector(selectors: "title"): HTMLTitleElement; - querySelector(selectors: "tr"): HTMLTableRowElement; - querySelector(selectors: "track"): HTMLTrackElement; - querySelector(selectors: "tspan"): SVGTSpanElement; - querySelector(selectors: "tt"): HTMLElement; - querySelector(selectors: "u"): HTMLElement; - querySelector(selectors: "ul"): HTMLUListElement; - querySelector(selectors: "use"): SVGUseElement; - querySelector(selectors: "var"): HTMLElement; - querySelector(selectors: "video"): HTMLVideoElement; - querySelector(selectors: "view"): SVGViewElement; - querySelector(selectors: "wbr"): HTMLElement; - querySelector(selectors: "x-ms-webview"): MSHTMLWebViewElement; - querySelector(selectors: "xmp"): HTMLPreElement; - querySelector(selectors: string): Element; + querySelector(selectors: "a"): HTMLAnchorElement | null; + querySelector(selectors: "abbr"): HTMLElement | null; + querySelector(selectors: "acronym"): HTMLElement | null; + querySelector(selectors: "address"): HTMLElement | null; + querySelector(selectors: "applet"): HTMLAppletElement | null; + querySelector(selectors: "area"): HTMLAreaElement | null; + querySelector(selectors: "article"): HTMLElement | null; + querySelector(selectors: "aside"): HTMLElement | null; + querySelector(selectors: "audio"): HTMLAudioElement | null; + querySelector(selectors: "b"): HTMLElement | null; + querySelector(selectors: "base"): HTMLBaseElement | null; + querySelector(selectors: "basefont"): HTMLBaseFontElement | null; + querySelector(selectors: "bdo"): HTMLElement | null; + querySelector(selectors: "big"): HTMLElement | null; + querySelector(selectors: "blockquote"): HTMLQuoteElement | null; + querySelector(selectors: "body"): HTMLBodyElement | null; + querySelector(selectors: "br"): HTMLBRElement | null; + querySelector(selectors: "button"): HTMLButtonElement | null; + querySelector(selectors: "canvas"): HTMLCanvasElement | null; + querySelector(selectors: "caption"): HTMLTableCaptionElement | null; + querySelector(selectors: "center"): HTMLElement | null; + querySelector(selectors: "circle"): SVGCircleElement | null; + querySelector(selectors: "cite"): HTMLElement | null; + querySelector(selectors: "clippath"): SVGClipPathElement | null; + querySelector(selectors: "code"): HTMLElement | null; + querySelector(selectors: "col"): HTMLTableColElement | null; + querySelector(selectors: "colgroup"): HTMLTableColElement | null; + querySelector(selectors: "datalist"): HTMLDataListElement | null; + querySelector(selectors: "dd"): HTMLElement | null; + querySelector(selectors: "defs"): SVGDefsElement | null; + querySelector(selectors: "del"): HTMLModElement | null; + querySelector(selectors: "desc"): SVGDescElement | null; + querySelector(selectors: "dfn"): HTMLElement | null; + querySelector(selectors: "dir"): HTMLDirectoryElement | null; + querySelector(selectors: "div"): HTMLDivElement | null; + querySelector(selectors: "dl"): HTMLDListElement | null; + querySelector(selectors: "dt"): HTMLElement | null; + querySelector(selectors: "ellipse"): SVGEllipseElement | null; + querySelector(selectors: "em"): HTMLElement | null; + querySelector(selectors: "embed"): HTMLEmbedElement | null; + querySelector(selectors: "feblend"): SVGFEBlendElement | null; + querySelector(selectors: "fecolormatrix"): SVGFEColorMatrixElement | null; + querySelector(selectors: "fecomponenttransfer"): SVGFEComponentTransferElement | null; + querySelector(selectors: "fecomposite"): SVGFECompositeElement | null; + querySelector(selectors: "feconvolvematrix"): SVGFEConvolveMatrixElement | null; + querySelector(selectors: "fediffuselighting"): SVGFEDiffuseLightingElement | null; + querySelector(selectors: "fedisplacementmap"): SVGFEDisplacementMapElement | null; + querySelector(selectors: "fedistantlight"): SVGFEDistantLightElement | null; + querySelector(selectors: "feflood"): SVGFEFloodElement | null; + querySelector(selectors: "fefunca"): SVGFEFuncAElement | null; + querySelector(selectors: "fefuncb"): SVGFEFuncBElement | null; + querySelector(selectors: "fefuncg"): SVGFEFuncGElement | null; + querySelector(selectors: "fefuncr"): SVGFEFuncRElement | null; + querySelector(selectors: "fegaussianblur"): SVGFEGaussianBlurElement | null; + querySelector(selectors: "feimage"): SVGFEImageElement | null; + querySelector(selectors: "femerge"): SVGFEMergeElement | null; + querySelector(selectors: "femergenode"): SVGFEMergeNodeElement | null; + querySelector(selectors: "femorphology"): SVGFEMorphologyElement | null; + querySelector(selectors: "feoffset"): SVGFEOffsetElement | null; + querySelector(selectors: "fepointlight"): SVGFEPointLightElement | null; + querySelector(selectors: "fespecularlighting"): SVGFESpecularLightingElement | null; + querySelector(selectors: "fespotlight"): SVGFESpotLightElement | null; + querySelector(selectors: "fetile"): SVGFETileElement | null; + querySelector(selectors: "feturbulence"): SVGFETurbulenceElement | null; + querySelector(selectors: "fieldset"): HTMLFieldSetElement | null; + querySelector(selectors: "figcaption"): HTMLElement | null; + querySelector(selectors: "figure"): HTMLElement | null; + querySelector(selectors: "filter"): SVGFilterElement | null; + querySelector(selectors: "font"): HTMLFontElement | null; + querySelector(selectors: "footer"): HTMLElement | null; + querySelector(selectors: "foreignobject"): SVGForeignObjectElement | null; + querySelector(selectors: "form"): HTMLFormElement | null; + querySelector(selectors: "frame"): HTMLFrameElement | null; + querySelector(selectors: "frameset"): HTMLFrameSetElement | null; + querySelector(selectors: "g"): SVGGElement | null; + querySelector(selectors: "h1"): HTMLHeadingElement | null; + querySelector(selectors: "h2"): HTMLHeadingElement | null; + querySelector(selectors: "h3"): HTMLHeadingElement | null; + querySelector(selectors: "h4"): HTMLHeadingElement | null; + querySelector(selectors: "h5"): HTMLHeadingElement | null; + querySelector(selectors: "h6"): HTMLHeadingElement | null; + querySelector(selectors: "head"): HTMLHeadElement | null; + querySelector(selectors: "header"): HTMLElement | null; + querySelector(selectors: "hgroup"): HTMLElement | null; + querySelector(selectors: "hr"): HTMLHRElement | null; + querySelector(selectors: "html"): HTMLHtmlElement | null; + querySelector(selectors: "i"): HTMLElement | null; + querySelector(selectors: "iframe"): HTMLIFrameElement | null; + querySelector(selectors: "image"): SVGImageElement | null; + querySelector(selectors: "img"): HTMLImageElement | null; + querySelector(selectors: "input"): HTMLInputElement | null; + querySelector(selectors: "ins"): HTMLModElement | null; + querySelector(selectors: "isindex"): HTMLUnknownElement | null; + querySelector(selectors: "kbd"): HTMLElement | null; + querySelector(selectors: "keygen"): HTMLElement | null; + querySelector(selectors: "label"): HTMLLabelElement | null; + querySelector(selectors: "legend"): HTMLLegendElement | null; + querySelector(selectors: "li"): HTMLLIElement | null; + querySelector(selectors: "line"): SVGLineElement | null; + querySelector(selectors: "lineargradient"): SVGLinearGradientElement | null; + querySelector(selectors: "link"): HTMLLinkElement | null; + querySelector(selectors: "listing"): HTMLPreElement | null; + querySelector(selectors: "map"): HTMLMapElement | null; + querySelector(selectors: "mark"): HTMLElement | null; + querySelector(selectors: "marker"): SVGMarkerElement | null; + querySelector(selectors: "marquee"): HTMLMarqueeElement | null; + querySelector(selectors: "mask"): SVGMaskElement | null; + querySelector(selectors: "menu"): HTMLMenuElement | null; + querySelector(selectors: "meta"): HTMLMetaElement | null; + querySelector(selectors: "metadata"): SVGMetadataElement | null; + querySelector(selectors: "meter"): HTMLMeterElement | null; + querySelector(selectors: "nav"): HTMLElement | null; + querySelector(selectors: "nextid"): HTMLUnknownElement | null; + querySelector(selectors: "nobr"): HTMLElement | null; + querySelector(selectors: "noframes"): HTMLElement | null; + querySelector(selectors: "noscript"): HTMLElement | null; + querySelector(selectors: "object"): HTMLObjectElement | null; + querySelector(selectors: "ol"): HTMLOListElement | null; + querySelector(selectors: "optgroup"): HTMLOptGroupElement | null; + querySelector(selectors: "option"): HTMLOptionElement | null; + querySelector(selectors: "p"): HTMLParagraphElement | null; + querySelector(selectors: "param"): HTMLParamElement | null; + querySelector(selectors: "path"): SVGPathElement | null; + querySelector(selectors: "pattern"): SVGPatternElement | null; + querySelector(selectors: "picture"): HTMLPictureElement | null; + querySelector(selectors: "plaintext"): HTMLElement | null; + querySelector(selectors: "polygon"): SVGPolygonElement | null; + querySelector(selectors: "polyline"): SVGPolylineElement | null; + querySelector(selectors: "pre"): HTMLPreElement | null; + querySelector(selectors: "progress"): HTMLProgressElement | null; + querySelector(selectors: "q"): HTMLQuoteElement | null; + querySelector(selectors: "radialgradient"): SVGRadialGradientElement | null; + querySelector(selectors: "rect"): SVGRectElement | null; + querySelector(selectors: "rt"): HTMLElement | null; + querySelector(selectors: "ruby"): HTMLElement | null; + querySelector(selectors: "s"): HTMLElement | null; + querySelector(selectors: "samp"): HTMLElement | null; + querySelector(selectors: "script"): HTMLScriptElement | null; + querySelector(selectors: "section"): HTMLElement | null; + querySelector(selectors: "select"): HTMLSelectElement | null; + querySelector(selectors: "small"): HTMLElement | null; + querySelector(selectors: "source"): HTMLSourceElement | null; + querySelector(selectors: "span"): HTMLSpanElement | null; + querySelector(selectors: "stop"): SVGStopElement | null; + querySelector(selectors: "strike"): HTMLElement | null; + querySelector(selectors: "strong"): HTMLElement | null; + querySelector(selectors: "style"): HTMLStyleElement | null; + querySelector(selectors: "sub"): HTMLElement | null; + querySelector(selectors: "sup"): HTMLElement | null; + querySelector(selectors: "svg"): SVGSVGElement | null; + querySelector(selectors: "switch"): SVGSwitchElement | null; + querySelector(selectors: "symbol"): SVGSymbolElement | null; + querySelector(selectors: "table"): HTMLTableElement | null; + querySelector(selectors: "tbody"): HTMLTableSectionElement | null; + querySelector(selectors: "td"): HTMLTableDataCellElement | null; + querySelector(selectors: "template"): HTMLTemplateElement | null; + querySelector(selectors: "text"): SVGTextElement | null; + querySelector(selectors: "textpath"): SVGTextPathElement | null; + querySelector(selectors: "textarea"): HTMLTextAreaElement | null; + querySelector(selectors: "tfoot"): HTMLTableSectionElement | null; + querySelector(selectors: "th"): HTMLTableHeaderCellElement | null; + querySelector(selectors: "thead"): HTMLTableSectionElement | null; + querySelector(selectors: "title"): HTMLTitleElement | null; + querySelector(selectors: "tr"): HTMLTableRowElement | null; + querySelector(selectors: "track"): HTMLTrackElement | null; + querySelector(selectors: "tspan"): SVGTSpanElement | null; + querySelector(selectors: "tt"): HTMLElement | null; + querySelector(selectors: "u"): HTMLElement | null; + querySelector(selectors: "ul"): HTMLUListElement | null; + querySelector(selectors: "use"): SVGUseElement | null; + querySelector(selectors: "var"): HTMLElement | null; + querySelector(selectors: "video"): HTMLVideoElement | null; + querySelector(selectors: "view"): SVGViewElement | null; + querySelector(selectors: "wbr"): HTMLElement | null; + querySelector(selectors: "x-ms-webview"): MSHTMLWebViewElement | null; + querySelector(selectors: "xmp"): HTMLPreElement | null; + querySelector(selectors: string): Element | null; querySelectorAll(selectors: "a"): NodeListOf; querySelectorAll(selectors: "abbr"): NodeListOf; querySelectorAll(selectors: "acronym"): NodeListOf; @@ -14638,4 +14638,5 @@ type ScrollBehavior = "auto" | "instant" | "smooth"; type ScrollLogicalPosition = "start" | "center" | "end" | "nearest"; type IDBValidKey = number | string | Date | IDBArrayKey; type BufferSource = ArrayBuffer | ArrayBufferView; -type MouseWheelEvent = WheelEvent; \ No newline at end of file +type MouseWheelEvent = WheelEvent; +type ScrollRestoration = "auto" | "manual"; \ No newline at end of file diff --git a/lib/lib.es2015.core.d.ts b/lib/lib.es2015.core.d.ts index 49a81a220ce..669c80944ec 100644 --- a/lib/lib.es2015.core.d.ts +++ b/lib/lib.es2015.core.d.ts @@ -217,7 +217,7 @@ interface NumberConstructor { /** * Returns true if passed value is finite. - * Unlike the global isFininte, Number.isFinite doesn't forcibly convert the parameter to a + * Unlike the global isFinite, Number.isFinite doesn't forcibly convert the parameter to a * number. Only finite values of the type number, result in true. * @param number A numeric value. */ diff --git a/lib/lib.es5.d.ts b/lib/lib.es5.d.ts index 5df0d7d4068..d20c7d1e3a7 100644 --- a/lib/lib.es5.d.ts +++ b/lib/lib.es5.d.ts @@ -1216,6 +1216,30 @@ interface Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; + /** + * Calls a defined callback function on each element of an array, and returns an array that contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + map(this: [T, T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U, U]; + /** + * Calls a defined callback function on each element of an array, and returns an array that contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + map(this: [T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U]; + /** + * Calls a defined callback function on each element of an array, and returns an array that contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + map(this: [T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U]; + /** + * Calls a defined callback function on each element of an array, and returns an array that contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + map(this: [T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U]; /** * Calls a defined callback function on each element of an array, and returns an array that contains the results. * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. diff --git a/lib/lib.es6.d.ts b/lib/lib.es6.d.ts index f6c7766ea9f..6067d810b44 100644 --- a/lib/lib.es6.d.ts +++ b/lib/lib.es6.d.ts @@ -1216,6 +1216,30 @@ interface Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; + /** + * Calls a defined callback function on each element of an array, and returns an array that contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + map(this: [T, T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U, U]; + /** + * Calls a defined callback function on each element of an array, and returns an array that contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + map(this: [T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U]; + /** + * Calls a defined callback function on each element of an array, and returns an array that contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + map(this: [T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U]; + /** + * Calls a defined callback function on each element of an array, and returns an array that contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + map(this: [T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U]; /** * Calls a defined callback function on each element of an array, and returns an array that contains the results. * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. @@ -4325,7 +4349,7 @@ interface NumberConstructor { /** * Returns true if passed value is finite. - * Unlike the global isFininte, Number.isFinite doesn't forcibly convert the parameter to a + * Unlike the global isFinite, Number.isFinite doesn't forcibly convert the parameter to a * number. Only finite values of the type number, result in true. * @param number A numeric value. */ @@ -13361,11 +13385,12 @@ declare var HashChangeEvent: { interface History { readonly length: number; readonly state: any; - back(distance?: any): void; - forward(distance?: any): void; - go(delta?: any): void; - pushState(statedata: any, title?: string, url?: string): void; - replaceState(statedata: any, title?: string, url?: string): void; + scrollRestoration: ScrollRestoration; + back(): void; + forward(): void; + go(delta?: number): void; + pushState(data: any, title: string, url?: string | null): void; + replaceState(data: any, title: string, url?: string | null): void; } declare var History: { @@ -18937,7 +18962,6 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window addEventListener(type: "waiting", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "wheel", listener: (this: this, ev: WheelEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; - [index: number]: Window; } declare var Window: { @@ -18968,7 +18992,7 @@ declare var XMLDocument: { } interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { - onreadystatechange: (this: this, ev: ProgressEvent) => any; + onreadystatechange: (this: this, ev: Event) => any; readonly readyState: number; readonly response: any; readonly responseText: string; @@ -18995,13 +19019,13 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { readonly LOADING: number; readonly OPENED: number; readonly UNSENT: number; - addEventListener(type: "abort", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "load", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "loadstart", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; addEventListener(type: "progress", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "readystatechange", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "timeout", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -19342,183 +19366,183 @@ interface NavigatorUserMedia { } interface NodeSelector { - querySelector(selectors: "a"): HTMLAnchorElement; - querySelector(selectors: "abbr"): HTMLElement; - querySelector(selectors: "acronym"): HTMLElement; - querySelector(selectors: "address"): HTMLElement; - querySelector(selectors: "applet"): HTMLAppletElement; - querySelector(selectors: "area"): HTMLAreaElement; - querySelector(selectors: "article"): HTMLElement; - querySelector(selectors: "aside"): HTMLElement; - querySelector(selectors: "audio"): HTMLAudioElement; - querySelector(selectors: "b"): HTMLElement; - querySelector(selectors: "base"): HTMLBaseElement; - querySelector(selectors: "basefont"): HTMLBaseFontElement; - querySelector(selectors: "bdo"): HTMLElement; - querySelector(selectors: "big"): HTMLElement; - querySelector(selectors: "blockquote"): HTMLQuoteElement; - querySelector(selectors: "body"): HTMLBodyElement; - querySelector(selectors: "br"): HTMLBRElement; - querySelector(selectors: "button"): HTMLButtonElement; - querySelector(selectors: "canvas"): HTMLCanvasElement; - querySelector(selectors: "caption"): HTMLTableCaptionElement; - querySelector(selectors: "center"): HTMLElement; - querySelector(selectors: "circle"): SVGCircleElement; - querySelector(selectors: "cite"): HTMLElement; - querySelector(selectors: "clippath"): SVGClipPathElement; - querySelector(selectors: "code"): HTMLElement; - querySelector(selectors: "col"): HTMLTableColElement; - querySelector(selectors: "colgroup"): HTMLTableColElement; - querySelector(selectors: "datalist"): HTMLDataListElement; - querySelector(selectors: "dd"): HTMLElement; - querySelector(selectors: "defs"): SVGDefsElement; - querySelector(selectors: "del"): HTMLModElement; - querySelector(selectors: "desc"): SVGDescElement; - querySelector(selectors: "dfn"): HTMLElement; - querySelector(selectors: "dir"): HTMLDirectoryElement; - querySelector(selectors: "div"): HTMLDivElement; - querySelector(selectors: "dl"): HTMLDListElement; - querySelector(selectors: "dt"): HTMLElement; - querySelector(selectors: "ellipse"): SVGEllipseElement; - querySelector(selectors: "em"): HTMLElement; - querySelector(selectors: "embed"): HTMLEmbedElement; - querySelector(selectors: "feblend"): SVGFEBlendElement; - querySelector(selectors: "fecolormatrix"): SVGFEColorMatrixElement; - querySelector(selectors: "fecomponenttransfer"): SVGFEComponentTransferElement; - querySelector(selectors: "fecomposite"): SVGFECompositeElement; - querySelector(selectors: "feconvolvematrix"): SVGFEConvolveMatrixElement; - querySelector(selectors: "fediffuselighting"): SVGFEDiffuseLightingElement; - querySelector(selectors: "fedisplacementmap"): SVGFEDisplacementMapElement; - querySelector(selectors: "fedistantlight"): SVGFEDistantLightElement; - querySelector(selectors: "feflood"): SVGFEFloodElement; - querySelector(selectors: "fefunca"): SVGFEFuncAElement; - querySelector(selectors: "fefuncb"): SVGFEFuncBElement; - querySelector(selectors: "fefuncg"): SVGFEFuncGElement; - querySelector(selectors: "fefuncr"): SVGFEFuncRElement; - querySelector(selectors: "fegaussianblur"): SVGFEGaussianBlurElement; - querySelector(selectors: "feimage"): SVGFEImageElement; - querySelector(selectors: "femerge"): SVGFEMergeElement; - querySelector(selectors: "femergenode"): SVGFEMergeNodeElement; - querySelector(selectors: "femorphology"): SVGFEMorphologyElement; - querySelector(selectors: "feoffset"): SVGFEOffsetElement; - querySelector(selectors: "fepointlight"): SVGFEPointLightElement; - querySelector(selectors: "fespecularlighting"): SVGFESpecularLightingElement; - querySelector(selectors: "fespotlight"): SVGFESpotLightElement; - querySelector(selectors: "fetile"): SVGFETileElement; - querySelector(selectors: "feturbulence"): SVGFETurbulenceElement; - querySelector(selectors: "fieldset"): HTMLFieldSetElement; - querySelector(selectors: "figcaption"): HTMLElement; - querySelector(selectors: "figure"): HTMLElement; - querySelector(selectors: "filter"): SVGFilterElement; - querySelector(selectors: "font"): HTMLFontElement; - querySelector(selectors: "footer"): HTMLElement; - querySelector(selectors: "foreignobject"): SVGForeignObjectElement; - querySelector(selectors: "form"): HTMLFormElement; - querySelector(selectors: "frame"): HTMLFrameElement; - querySelector(selectors: "frameset"): HTMLFrameSetElement; - querySelector(selectors: "g"): SVGGElement; - querySelector(selectors: "h1"): HTMLHeadingElement; - querySelector(selectors: "h2"): HTMLHeadingElement; - querySelector(selectors: "h3"): HTMLHeadingElement; - querySelector(selectors: "h4"): HTMLHeadingElement; - querySelector(selectors: "h5"): HTMLHeadingElement; - querySelector(selectors: "h6"): HTMLHeadingElement; - querySelector(selectors: "head"): HTMLHeadElement; - querySelector(selectors: "header"): HTMLElement; - querySelector(selectors: "hgroup"): HTMLElement; - querySelector(selectors: "hr"): HTMLHRElement; - querySelector(selectors: "html"): HTMLHtmlElement; - querySelector(selectors: "i"): HTMLElement; - querySelector(selectors: "iframe"): HTMLIFrameElement; - querySelector(selectors: "image"): SVGImageElement; - querySelector(selectors: "img"): HTMLImageElement; - querySelector(selectors: "input"): HTMLInputElement; - querySelector(selectors: "ins"): HTMLModElement; - querySelector(selectors: "isindex"): HTMLUnknownElement; - querySelector(selectors: "kbd"): HTMLElement; - querySelector(selectors: "keygen"): HTMLElement; - querySelector(selectors: "label"): HTMLLabelElement; - querySelector(selectors: "legend"): HTMLLegendElement; - querySelector(selectors: "li"): HTMLLIElement; - querySelector(selectors: "line"): SVGLineElement; - querySelector(selectors: "lineargradient"): SVGLinearGradientElement; - querySelector(selectors: "link"): HTMLLinkElement; - querySelector(selectors: "listing"): HTMLPreElement; - querySelector(selectors: "map"): HTMLMapElement; - querySelector(selectors: "mark"): HTMLElement; - querySelector(selectors: "marker"): SVGMarkerElement; - querySelector(selectors: "marquee"): HTMLMarqueeElement; - querySelector(selectors: "mask"): SVGMaskElement; - querySelector(selectors: "menu"): HTMLMenuElement; - querySelector(selectors: "meta"): HTMLMetaElement; - querySelector(selectors: "metadata"): SVGMetadataElement; - querySelector(selectors: "meter"): HTMLMeterElement; - querySelector(selectors: "nav"): HTMLElement; - querySelector(selectors: "nextid"): HTMLUnknownElement; - querySelector(selectors: "nobr"): HTMLElement; - querySelector(selectors: "noframes"): HTMLElement; - querySelector(selectors: "noscript"): HTMLElement; - querySelector(selectors: "object"): HTMLObjectElement; - querySelector(selectors: "ol"): HTMLOListElement; - querySelector(selectors: "optgroup"): HTMLOptGroupElement; - querySelector(selectors: "option"): HTMLOptionElement; - querySelector(selectors: "p"): HTMLParagraphElement; - querySelector(selectors: "param"): HTMLParamElement; - querySelector(selectors: "path"): SVGPathElement; - querySelector(selectors: "pattern"): SVGPatternElement; - querySelector(selectors: "picture"): HTMLPictureElement; - querySelector(selectors: "plaintext"): HTMLElement; - querySelector(selectors: "polygon"): SVGPolygonElement; - querySelector(selectors: "polyline"): SVGPolylineElement; - querySelector(selectors: "pre"): HTMLPreElement; - querySelector(selectors: "progress"): HTMLProgressElement; - querySelector(selectors: "q"): HTMLQuoteElement; - querySelector(selectors: "radialgradient"): SVGRadialGradientElement; - querySelector(selectors: "rect"): SVGRectElement; - querySelector(selectors: "rt"): HTMLElement; - querySelector(selectors: "ruby"): HTMLElement; - querySelector(selectors: "s"): HTMLElement; - querySelector(selectors: "samp"): HTMLElement; - querySelector(selectors: "script"): HTMLScriptElement; - querySelector(selectors: "section"): HTMLElement; - querySelector(selectors: "select"): HTMLSelectElement; - querySelector(selectors: "small"): HTMLElement; - querySelector(selectors: "source"): HTMLSourceElement; - querySelector(selectors: "span"): HTMLSpanElement; - querySelector(selectors: "stop"): SVGStopElement; - querySelector(selectors: "strike"): HTMLElement; - querySelector(selectors: "strong"): HTMLElement; - querySelector(selectors: "style"): HTMLStyleElement; - querySelector(selectors: "sub"): HTMLElement; - querySelector(selectors: "sup"): HTMLElement; - querySelector(selectors: "svg"): SVGSVGElement; - querySelector(selectors: "switch"): SVGSwitchElement; - querySelector(selectors: "symbol"): SVGSymbolElement; - querySelector(selectors: "table"): HTMLTableElement; - querySelector(selectors: "tbody"): HTMLTableSectionElement; - querySelector(selectors: "td"): HTMLTableDataCellElement; - querySelector(selectors: "template"): HTMLTemplateElement; - querySelector(selectors: "text"): SVGTextElement; - querySelector(selectors: "textpath"): SVGTextPathElement; - querySelector(selectors: "textarea"): HTMLTextAreaElement; - querySelector(selectors: "tfoot"): HTMLTableSectionElement; - querySelector(selectors: "th"): HTMLTableHeaderCellElement; - querySelector(selectors: "thead"): HTMLTableSectionElement; - querySelector(selectors: "title"): HTMLTitleElement; - querySelector(selectors: "tr"): HTMLTableRowElement; - querySelector(selectors: "track"): HTMLTrackElement; - querySelector(selectors: "tspan"): SVGTSpanElement; - querySelector(selectors: "tt"): HTMLElement; - querySelector(selectors: "u"): HTMLElement; - querySelector(selectors: "ul"): HTMLUListElement; - querySelector(selectors: "use"): SVGUseElement; - querySelector(selectors: "var"): HTMLElement; - querySelector(selectors: "video"): HTMLVideoElement; - querySelector(selectors: "view"): SVGViewElement; - querySelector(selectors: "wbr"): HTMLElement; - querySelector(selectors: "x-ms-webview"): MSHTMLWebViewElement; - querySelector(selectors: "xmp"): HTMLPreElement; - querySelector(selectors: string): Element; + querySelector(selectors: "a"): HTMLAnchorElement | null; + querySelector(selectors: "abbr"): HTMLElement | null; + querySelector(selectors: "acronym"): HTMLElement | null; + querySelector(selectors: "address"): HTMLElement | null; + querySelector(selectors: "applet"): HTMLAppletElement | null; + querySelector(selectors: "area"): HTMLAreaElement | null; + querySelector(selectors: "article"): HTMLElement | null; + querySelector(selectors: "aside"): HTMLElement | null; + querySelector(selectors: "audio"): HTMLAudioElement | null; + querySelector(selectors: "b"): HTMLElement | null; + querySelector(selectors: "base"): HTMLBaseElement | null; + querySelector(selectors: "basefont"): HTMLBaseFontElement | null; + querySelector(selectors: "bdo"): HTMLElement | null; + querySelector(selectors: "big"): HTMLElement | null; + querySelector(selectors: "blockquote"): HTMLQuoteElement | null; + querySelector(selectors: "body"): HTMLBodyElement | null; + querySelector(selectors: "br"): HTMLBRElement | null; + querySelector(selectors: "button"): HTMLButtonElement | null; + querySelector(selectors: "canvas"): HTMLCanvasElement | null; + querySelector(selectors: "caption"): HTMLTableCaptionElement | null; + querySelector(selectors: "center"): HTMLElement | null; + querySelector(selectors: "circle"): SVGCircleElement | null; + querySelector(selectors: "cite"): HTMLElement | null; + querySelector(selectors: "clippath"): SVGClipPathElement | null; + querySelector(selectors: "code"): HTMLElement | null; + querySelector(selectors: "col"): HTMLTableColElement | null; + querySelector(selectors: "colgroup"): HTMLTableColElement | null; + querySelector(selectors: "datalist"): HTMLDataListElement | null; + querySelector(selectors: "dd"): HTMLElement | null; + querySelector(selectors: "defs"): SVGDefsElement | null; + querySelector(selectors: "del"): HTMLModElement | null; + querySelector(selectors: "desc"): SVGDescElement | null; + querySelector(selectors: "dfn"): HTMLElement | null; + querySelector(selectors: "dir"): HTMLDirectoryElement | null; + querySelector(selectors: "div"): HTMLDivElement | null; + querySelector(selectors: "dl"): HTMLDListElement | null; + querySelector(selectors: "dt"): HTMLElement | null; + querySelector(selectors: "ellipse"): SVGEllipseElement | null; + querySelector(selectors: "em"): HTMLElement | null; + querySelector(selectors: "embed"): HTMLEmbedElement | null; + querySelector(selectors: "feblend"): SVGFEBlendElement | null; + querySelector(selectors: "fecolormatrix"): SVGFEColorMatrixElement | null; + querySelector(selectors: "fecomponenttransfer"): SVGFEComponentTransferElement | null; + querySelector(selectors: "fecomposite"): SVGFECompositeElement | null; + querySelector(selectors: "feconvolvematrix"): SVGFEConvolveMatrixElement | null; + querySelector(selectors: "fediffuselighting"): SVGFEDiffuseLightingElement | null; + querySelector(selectors: "fedisplacementmap"): SVGFEDisplacementMapElement | null; + querySelector(selectors: "fedistantlight"): SVGFEDistantLightElement | null; + querySelector(selectors: "feflood"): SVGFEFloodElement | null; + querySelector(selectors: "fefunca"): SVGFEFuncAElement | null; + querySelector(selectors: "fefuncb"): SVGFEFuncBElement | null; + querySelector(selectors: "fefuncg"): SVGFEFuncGElement | null; + querySelector(selectors: "fefuncr"): SVGFEFuncRElement | null; + querySelector(selectors: "fegaussianblur"): SVGFEGaussianBlurElement | null; + querySelector(selectors: "feimage"): SVGFEImageElement | null; + querySelector(selectors: "femerge"): SVGFEMergeElement | null; + querySelector(selectors: "femergenode"): SVGFEMergeNodeElement | null; + querySelector(selectors: "femorphology"): SVGFEMorphologyElement | null; + querySelector(selectors: "feoffset"): SVGFEOffsetElement | null; + querySelector(selectors: "fepointlight"): SVGFEPointLightElement | null; + querySelector(selectors: "fespecularlighting"): SVGFESpecularLightingElement | null; + querySelector(selectors: "fespotlight"): SVGFESpotLightElement | null; + querySelector(selectors: "fetile"): SVGFETileElement | null; + querySelector(selectors: "feturbulence"): SVGFETurbulenceElement | null; + querySelector(selectors: "fieldset"): HTMLFieldSetElement | null; + querySelector(selectors: "figcaption"): HTMLElement | null; + querySelector(selectors: "figure"): HTMLElement | null; + querySelector(selectors: "filter"): SVGFilterElement | null; + querySelector(selectors: "font"): HTMLFontElement | null; + querySelector(selectors: "footer"): HTMLElement | null; + querySelector(selectors: "foreignobject"): SVGForeignObjectElement | null; + querySelector(selectors: "form"): HTMLFormElement | null; + querySelector(selectors: "frame"): HTMLFrameElement | null; + querySelector(selectors: "frameset"): HTMLFrameSetElement | null; + querySelector(selectors: "g"): SVGGElement | null; + querySelector(selectors: "h1"): HTMLHeadingElement | null; + querySelector(selectors: "h2"): HTMLHeadingElement | null; + querySelector(selectors: "h3"): HTMLHeadingElement | null; + querySelector(selectors: "h4"): HTMLHeadingElement | null; + querySelector(selectors: "h5"): HTMLHeadingElement | null; + querySelector(selectors: "h6"): HTMLHeadingElement | null; + querySelector(selectors: "head"): HTMLHeadElement | null; + querySelector(selectors: "header"): HTMLElement | null; + querySelector(selectors: "hgroup"): HTMLElement | null; + querySelector(selectors: "hr"): HTMLHRElement | null; + querySelector(selectors: "html"): HTMLHtmlElement | null; + querySelector(selectors: "i"): HTMLElement | null; + querySelector(selectors: "iframe"): HTMLIFrameElement | null; + querySelector(selectors: "image"): SVGImageElement | null; + querySelector(selectors: "img"): HTMLImageElement | null; + querySelector(selectors: "input"): HTMLInputElement | null; + querySelector(selectors: "ins"): HTMLModElement | null; + querySelector(selectors: "isindex"): HTMLUnknownElement | null; + querySelector(selectors: "kbd"): HTMLElement | null; + querySelector(selectors: "keygen"): HTMLElement | null; + querySelector(selectors: "label"): HTMLLabelElement | null; + querySelector(selectors: "legend"): HTMLLegendElement | null; + querySelector(selectors: "li"): HTMLLIElement | null; + querySelector(selectors: "line"): SVGLineElement | null; + querySelector(selectors: "lineargradient"): SVGLinearGradientElement | null; + querySelector(selectors: "link"): HTMLLinkElement | null; + querySelector(selectors: "listing"): HTMLPreElement | null; + querySelector(selectors: "map"): HTMLMapElement | null; + querySelector(selectors: "mark"): HTMLElement | null; + querySelector(selectors: "marker"): SVGMarkerElement | null; + querySelector(selectors: "marquee"): HTMLMarqueeElement | null; + querySelector(selectors: "mask"): SVGMaskElement | null; + querySelector(selectors: "menu"): HTMLMenuElement | null; + querySelector(selectors: "meta"): HTMLMetaElement | null; + querySelector(selectors: "metadata"): SVGMetadataElement | null; + querySelector(selectors: "meter"): HTMLMeterElement | null; + querySelector(selectors: "nav"): HTMLElement | null; + querySelector(selectors: "nextid"): HTMLUnknownElement | null; + querySelector(selectors: "nobr"): HTMLElement | null; + querySelector(selectors: "noframes"): HTMLElement | null; + querySelector(selectors: "noscript"): HTMLElement | null; + querySelector(selectors: "object"): HTMLObjectElement | null; + querySelector(selectors: "ol"): HTMLOListElement | null; + querySelector(selectors: "optgroup"): HTMLOptGroupElement | null; + querySelector(selectors: "option"): HTMLOptionElement | null; + querySelector(selectors: "p"): HTMLParagraphElement | null; + querySelector(selectors: "param"): HTMLParamElement | null; + querySelector(selectors: "path"): SVGPathElement | null; + querySelector(selectors: "pattern"): SVGPatternElement | null; + querySelector(selectors: "picture"): HTMLPictureElement | null; + querySelector(selectors: "plaintext"): HTMLElement | null; + querySelector(selectors: "polygon"): SVGPolygonElement | null; + querySelector(selectors: "polyline"): SVGPolylineElement | null; + querySelector(selectors: "pre"): HTMLPreElement | null; + querySelector(selectors: "progress"): HTMLProgressElement | null; + querySelector(selectors: "q"): HTMLQuoteElement | null; + querySelector(selectors: "radialgradient"): SVGRadialGradientElement | null; + querySelector(selectors: "rect"): SVGRectElement | null; + querySelector(selectors: "rt"): HTMLElement | null; + querySelector(selectors: "ruby"): HTMLElement | null; + querySelector(selectors: "s"): HTMLElement | null; + querySelector(selectors: "samp"): HTMLElement | null; + querySelector(selectors: "script"): HTMLScriptElement | null; + querySelector(selectors: "section"): HTMLElement | null; + querySelector(selectors: "select"): HTMLSelectElement | null; + querySelector(selectors: "small"): HTMLElement | null; + querySelector(selectors: "source"): HTMLSourceElement | null; + querySelector(selectors: "span"): HTMLSpanElement | null; + querySelector(selectors: "stop"): SVGStopElement | null; + querySelector(selectors: "strike"): HTMLElement | null; + querySelector(selectors: "strong"): HTMLElement | null; + querySelector(selectors: "style"): HTMLStyleElement | null; + querySelector(selectors: "sub"): HTMLElement | null; + querySelector(selectors: "sup"): HTMLElement | null; + querySelector(selectors: "svg"): SVGSVGElement | null; + querySelector(selectors: "switch"): SVGSwitchElement | null; + querySelector(selectors: "symbol"): SVGSymbolElement | null; + querySelector(selectors: "table"): HTMLTableElement | null; + querySelector(selectors: "tbody"): HTMLTableSectionElement | null; + querySelector(selectors: "td"): HTMLTableDataCellElement | null; + querySelector(selectors: "template"): HTMLTemplateElement | null; + querySelector(selectors: "text"): SVGTextElement | null; + querySelector(selectors: "textpath"): SVGTextPathElement | null; + querySelector(selectors: "textarea"): HTMLTextAreaElement | null; + querySelector(selectors: "tfoot"): HTMLTableSectionElement | null; + querySelector(selectors: "th"): HTMLTableHeaderCellElement | null; + querySelector(selectors: "thead"): HTMLTableSectionElement | null; + querySelector(selectors: "title"): HTMLTitleElement | null; + querySelector(selectors: "tr"): HTMLTableRowElement | null; + querySelector(selectors: "track"): HTMLTrackElement | null; + querySelector(selectors: "tspan"): SVGTSpanElement | null; + querySelector(selectors: "tt"): HTMLElement | null; + querySelector(selectors: "u"): HTMLElement | null; + querySelector(selectors: "ul"): HTMLUListElement | null; + querySelector(selectors: "use"): SVGUseElement | null; + querySelector(selectors: "var"): HTMLElement | null; + querySelector(selectors: "video"): HTMLVideoElement | null; + querySelector(selectors: "view"): SVGViewElement | null; + querySelector(selectors: "wbr"): HTMLElement | null; + querySelector(selectors: "x-ms-webview"): MSHTMLWebViewElement | null; + querySelector(selectors: "xmp"): HTMLPreElement | null; + querySelector(selectors: string): Element | null; querySelectorAll(selectors: "a"): NodeListOf; querySelectorAll(selectors: "abbr"): NodeListOf; querySelectorAll(selectors: "acronym"): NodeListOf; @@ -20448,6 +20472,7 @@ type ScrollLogicalPosition = "start" | "center" | "end" | "nearest"; type IDBValidKey = number | string | Date | IDBArrayKey; type BufferSource = ArrayBuffer | ArrayBufferView; type MouseWheelEvent = WheelEvent; +type ScrollRestoration = "auto" | "manual"; ///////////////////////////// /// WorkerGlobalScope APIs ///////////////////////////// diff --git a/lib/lib.webworker.d.ts b/lib/lib.webworker.d.ts index 5b35d820dfe..6cb14c5b184 100644 --- a/lib/lib.webworker.d.ts +++ b/lib/lib.webworker.d.ts @@ -744,7 +744,7 @@ declare var Worker: { } interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { - onreadystatechange: (this: this, ev: ProgressEvent) => any; + onreadystatechange: (this: this, ev: Event) => any; readonly readyState: number; readonly response: any; readonly responseText: string; @@ -770,13 +770,13 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { readonly LOADING: number; readonly OPENED: number; readonly UNSENT: number; - addEventListener(type: "abort", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "load", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "abort", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "error", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "load", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; addEventListener(type: "loadend", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "loadstart", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "loadstart", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; addEventListener(type: "progress", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "readystatechange", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; + addEventListener(type: "readystatechange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "timeout", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } diff --git a/lib/protocol.d.ts b/lib/protocol.d.ts new file mode 100644 index 00000000000..2b57b5de644 --- /dev/null +++ b/lib/protocol.d.ts @@ -0,0 +1,1848 @@ +/** + * Declaration module describing the TypeScript Server protocol + */ +declare namespace ts.server.protocol { + namespace CommandTypes { + type Brace = "brace"; + type BraceCompletion = "braceCompletion"; + type Change = "change"; + type Close = "close"; + type Completions = "completions"; + type CompletionDetails = "completionEntryDetails"; + type CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList"; + type CompileOnSaveEmitFile = "compileOnSaveEmitFile"; + type Configure = "configure"; + type Definition = "definition"; + type Implementation = "implementation"; + type Exit = "exit"; + type Format = "format"; + type Formatonkey = "formatonkey"; + type Geterr = "geterr"; + type GeterrForProject = "geterrForProject"; + type SemanticDiagnosticsSync = "semanticDiagnosticsSync"; + type SyntacticDiagnosticsSync = "syntacticDiagnosticsSync"; + type NavBar = "navbar"; + type Navto = "navto"; + type NavTree = "navtree"; + type NavTreeFull = "navtree-full"; + type Occurrences = "occurrences"; + type DocumentHighlights = "documentHighlights"; + type Open = "open"; + type Quickinfo = "quickinfo"; + type References = "references"; + type Reload = "reload"; + type Rename = "rename"; + type Saveto = "saveto"; + type SignatureHelp = "signatureHelp"; + type TypeDefinition = "typeDefinition"; + type ProjectInfo = "projectInfo"; + type ReloadProjects = "reloadProjects"; + type Unknown = "unknown"; + type OpenExternalProject = "openExternalProject"; + type OpenExternalProjects = "openExternalProjects"; + type CloseExternalProject = "closeExternalProject"; + type TodoComments = "todoComments"; + type Indentation = "indentation"; + type DocCommentTemplate = "docCommentTemplate"; + type CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects"; + type GetCodeFixes = "getCodeFixes"; + type GetSupportedCodeFixes = "getSupportedCodeFixes"; + } + /** + * A TypeScript Server message + */ + interface Message { + /** + * Sequence number of the message + */ + seq: number; + /** + * One of "request", "response", or "event" + */ + type: string; + } + /** + * Client-initiated request message + */ + interface Request extends Message { + /** + * The command to execute + */ + command: string; + /** + * Object containing arguments for the command + */ + arguments?: any; + } + /** + * Request to reload the project structure for all the opened files + */ + interface ReloadProjectsRequest extends Message { + command: CommandTypes.ReloadProjects; + } + /** + * Server-initiated event message + */ + interface Event extends Message { + /** + * Name of event + */ + event: string; + /** + * Event-specific information + */ + body?: any; + } + /** + * Response by server to client request message. + */ + interface Response extends Message { + /** + * Sequence number of the request message. + */ + request_seq: number; + /** + * Outcome of the request. + */ + success: boolean; + /** + * The command requested. + */ + command: string; + /** + * Contains error message if success === false. + */ + message?: string; + /** + * Contains message body if success === true. + */ + body?: any; + } + /** + * Arguments for FileRequest messages. + */ + interface FileRequestArgs { + /** + * The file for the request (absolute pathname required). + */ + file: string; + projectFileName?: string; + } + /** + * Requests a JS Doc comment template for a given position + */ + interface DocCommentTemplateRequest extends FileLocationRequest { + command: CommandTypes.DocCommentTemplate; + } + /** + * Response to DocCommentTemplateRequest + */ + interface DocCommandTemplateResponse extends Response { + body?: TextInsertion; + } + /** + * A request to get TODO comments from the file + */ + interface TodoCommentRequest extends FileRequest { + command: CommandTypes.TodoComments; + arguments: TodoCommentRequestArgs; + } + /** + * Arguments for TodoCommentRequest request. + */ + interface TodoCommentRequestArgs extends FileRequestArgs { + /** + * Array of target TodoCommentDescriptors that describes TODO comments to be found + */ + descriptors: TodoCommentDescriptor[]; + } + /** + * Response for TodoCommentRequest request. + */ + interface TodoCommentsResponse extends Response { + body?: TodoComment[]; + } + /** + * A request to get indentation for a location in file + */ + interface IndentationRequest extends FileLocationRequest { + command: CommandTypes.Indentation; + arguments: IndentationRequestArgs; + } + /** + * Response for IndentationRequest request. + */ + interface IndentationResponse extends Response { + body?: IndentationResult; + } + /** + * Indentation result representing where indentation should be placed + */ + interface IndentationResult { + /** + * The base position in the document that the indent should be relative to + */ + position: number; + /** + * The number of columns the indent should be at relative to the position's column. + */ + indentation: number; + } + /** + * Arguments for IndentationRequest request. + */ + interface IndentationRequestArgs extends FileLocationRequestArgs { + /** + * An optional set of settings to be used when computing indentation. + * If argument is omitted - then it will use settings for file that were previously set via 'configure' request or global settings. + */ + options?: EditorSettings; + } + /** + * Arguments for ProjectInfoRequest request. + */ + interface ProjectInfoRequestArgs extends FileRequestArgs { + /** + * Indicate if the file name list of the project is needed + */ + needFileNameList: boolean; + } + /** + * A request to get the project information of the current file. + */ + interface ProjectInfoRequest extends Request { + command: CommandTypes.ProjectInfo; + arguments: ProjectInfoRequestArgs; + } + /** + * A request to retrieve compiler options diagnostics for a project + */ + interface CompilerOptionsDiagnosticsRequest extends Request { + arguments: CompilerOptionsDiagnosticsRequestArgs; + } + /** + * Arguments for CompilerOptionsDiagnosticsRequest request. + */ + interface CompilerOptionsDiagnosticsRequestArgs { + /** + * Name of the project to retrieve compiler options diagnostics. + */ + projectFileName: string; + } + /** + * Response message body for "projectInfo" request + */ + interface ProjectInfo { + /** + * For configured project, this is the normalized path of the 'tsconfig.json' file + * For inferred project, this is undefined + */ + configFileName: string; + /** + * The list of normalized file name in the project, including 'lib.d.ts' + */ + fileNames?: string[]; + /** + * Indicates if the project has a active language service instance + */ + languageServiceDisabled?: boolean; + } + /** + * Represents diagnostic info that includes location of diagnostic in two forms + * - start position and length of the error span + * - startLocation and endLocation - a pair of Location objects that store start/end line and offset of the error span. + */ + interface DiagnosticWithLinePosition { + message: string; + start: number; + length: number; + startLocation: Location; + endLocation: Location; + category: string; + code: number; + } + /** + * Response message for "projectInfo" request + */ + interface ProjectInfoResponse extends Response { + body?: ProjectInfo; + } + /** + * Request whose sole parameter is a file name. + */ + interface FileRequest extends Request { + arguments: FileRequestArgs; + } + /** + * Instances of this interface specify a location in a source file: + * (file, line, character offset), where line and character offset are 1-based. + */ + interface FileLocationRequestArgs extends FileRequestArgs { + /** + * The line number for the request (1-based). + */ + line: number; + /** + * The character offset (on the line) for the request (1-based). + */ + offset: number; + } + /** + * Request for the available codefixes at a specific position. + */ + interface CodeFixRequest extends Request { + command: CommandTypes.GetCodeFixes; + arguments: CodeFixRequestArgs; + } + /** + * Instances of this interface specify errorcodes on a specific location in a sourcefile. + */ + interface CodeFixRequestArgs extends FileRequestArgs { + /** + * The line number for the request (1-based). + */ + startLine: number; + /** + * The character offset (on the line) for the request (1-based). + */ + startOffset: number; + /** + * The line number for the request (1-based). + */ + endLine: number; + /** + * The character offset (on the line) for the request (1-based). + */ + endOffset: number; + /** + * Errorcodes we want to get the fixes for. + */ + errorCodes?: number[]; + } + /** + * Response for GetCodeFixes request. + */ + interface GetCodeFixesResponse extends Response { + body?: CodeAction[]; + } + /** + * A request whose arguments specify a file location (file, line, col). + */ + interface FileLocationRequest extends FileRequest { + arguments: FileLocationRequestArgs; + } + /** + * A request to get codes of supported code fixes. + */ + interface GetSupportedCodeFixesRequest extends Request { + command: CommandTypes.GetSupportedCodeFixes; + } + /** + * A response for GetSupportedCodeFixesRequest request. + */ + interface GetSupportedCodeFixesResponse extends Response { + /** + * List of error codes supported by the server. + */ + body?: string[]; + } + /** + * Arguments for EncodedSemanticClassificationsRequest request. + */ + interface EncodedSemanticClassificationsRequestArgs extends FileRequestArgs { + /** + * Start position of the span. + */ + start: number; + /** + * Length of the span. + */ + length: number; + } + /** + * Arguments in document highlight request; include: filesToSearch, file, + * line, offset. + */ + interface DocumentHighlightsRequestArgs extends FileLocationRequestArgs { + /** + * List of files to search for document highlights. + */ + filesToSearch: string[]; + } + /** + * Go to definition request; value of command field is + * "definition". Return response giving the file locations that + * define the symbol found in file at location line, col. + */ + interface DefinitionRequest extends FileLocationRequest { + command: CommandTypes.Definition; + } + /** + * Go to type request; value of command field is + * "typeDefinition". Return response giving the file locations that + * define the type for the symbol found in file at location line, col. + */ + interface TypeDefinitionRequest extends FileLocationRequest { + command: CommandTypes.TypeDefinition; + } + /** + * Go to implementation request; value of command field is + * "implementation". Return response giving the file locations that + * implement the symbol found in file at location line, col. + */ + interface ImplementationRequest extends FileLocationRequest { + command: CommandTypes.Implementation; + } + /** + * Location in source code expressed as (one-based) line and character offset. + */ + interface Location { + line: number; + offset: number; + } + /** + * Object found in response messages defining a span of text in source code. + */ + interface TextSpan { + /** + * First character of the definition. + */ + start: Location; + /** + * One character past last character of the definition. + */ + end: Location; + } + /** + * Object found in response messages defining a span of text in a specific source file. + */ + interface FileSpan extends TextSpan { + /** + * File containing text span. + */ + file: string; + } + /** + * Definition response message. Gives text range for definition. + */ + interface DefinitionResponse extends Response { + body?: FileSpan[]; + } + /** + * Definition response message. Gives text range for definition. + */ + interface TypeDefinitionResponse extends Response { + body?: FileSpan[]; + } + /** + * Implementation response message. Gives text range for implementations. + */ + interface ImplementationResponse extends Response { + body?: FileSpan[]; + } + /** + * Request to get brace completion for a location in the file. + */ + interface BraceCompletionRequest extends FileLocationRequest { + command: CommandTypes.BraceCompletion; + arguments: BraceCompletionRequestArgs; + } + /** + * Argument for BraceCompletionRequest request. + */ + interface BraceCompletionRequestArgs extends FileLocationRequestArgs { + /** + * Kind of opening brace + */ + openingBrace: string; + } + /** + * Get occurrences request; value of command field is + * "occurrences". Return response giving spans that are relevant + * in the file at a given line and column. + */ + interface OccurrencesRequest extends FileLocationRequest { + command: CommandTypes.Occurrences; + } + interface OccurrencesResponseItem extends FileSpan { + /** + * True if the occurrence is a write location, false otherwise. + */ + isWriteAccess: boolean; + } + interface OccurrencesResponse extends Response { + body?: OccurrencesResponseItem[]; + } + /** + * Get document highlights request; value of command field is + * "documentHighlights". Return response giving spans that are relevant + * in the file at a given line and column. + */ + interface DocumentHighlightsRequest extends FileLocationRequest { + command: CommandTypes.DocumentHighlights; + arguments: DocumentHighlightsRequestArgs; + } + /** + * Span augmented with extra information that denotes the kind of the highlighting to be used for span. + * Kind is taken from HighlightSpanKind type. + */ + interface HighlightSpan extends TextSpan { + kind: string; + } + /** + * Represents a set of highligh spans for a give name + */ + interface DocumentHighlightsItem { + /** + * File containing highlight spans. + */ + file: string; + /** + * Spans to highlight in file. + */ + highlightSpans: HighlightSpan[]; + } + /** + * Response for a DocumentHighlightsRequest request. + */ + interface DocumentHighlightsResponse extends Response { + body?: DocumentHighlightsItem[]; + } + /** + * Find references request; value of command field is + * "references". Return response giving the file locations that + * reference the symbol found in file at location line, col. + */ + interface ReferencesRequest extends FileLocationRequest { + command: CommandTypes.References; + } + interface ReferencesResponseItem extends FileSpan { + /** Text of line containing the reference. Including this + * with the response avoids latency of editor loading files + * to show text of reference line (the server already has + * loaded the referencing files). + */ + lineText: string; + /** + * True if reference is a write location, false otherwise. + */ + isWriteAccess: boolean; + /** + * True if reference is a definition, false otherwise. + */ + isDefinition: boolean; + } + /** + * The body of a "references" response message. + */ + interface ReferencesResponseBody { + /** + * The file locations referencing the symbol. + */ + refs: ReferencesResponseItem[]; + /** + * The name of the symbol. + */ + symbolName: string; + /** + * The start character offset of the symbol (on the line provided by the references request). + */ + symbolStartOffset: number; + /** + * The full display name of the symbol. + */ + symbolDisplayString: string; + } + /** + * Response to "references" request. + */ + interface ReferencesResponse extends Response { + body?: ReferencesResponseBody; + } + /** + * Argument for RenameRequest request. + */ + interface RenameRequestArgs extends FileLocationRequestArgs { + /** + * Should text at specified location be found/changed in comments? + */ + findInComments?: boolean; + /** + * Should text at specified location be found/changed in strings? + */ + findInStrings?: boolean; + } + /** + * Rename request; value of command field is "rename". Return + * response giving the file locations that reference the symbol + * found in file at location line, col. Also return full display + * name of the symbol so that client can print it unambiguously. + */ + interface RenameRequest extends FileLocationRequest { + command: CommandTypes.Rename; + arguments: RenameRequestArgs; + } + /** + * Information about the item to be renamed. + */ + interface RenameInfo { + /** + * True if item can be renamed. + */ + canRename: boolean; + /** + * Error message if item can not be renamed. + */ + localizedErrorMessage?: string; + /** + * Display name of the item to be renamed. + */ + displayName: string; + /** + * Full display name of item to be renamed. + */ + fullDisplayName: string; + /** + * The items's kind (such as 'className' or 'parameterName' or plain 'text'). + */ + kind: string; + /** + * Optional modifiers for the kind (such as 'public'). + */ + kindModifiers: string; + } + /** + * A group of text spans, all in 'file'. + */ + interface SpanGroup { + /** The file to which the spans apply */ + file: string; + /** The text spans in this group */ + locs: TextSpan[]; + } + interface RenameResponseBody { + /** + * Information about the item to be renamed. + */ + info: RenameInfo; + /** + * An array of span groups (one per file) that refer to the item to be renamed. + */ + locs: SpanGroup[]; + } + /** + * Rename response message. + */ + interface RenameResponse extends Response { + body?: RenameResponseBody; + } + /** + * Represents a file in external project. + * External project is project whose set of files, compilation options and open\close state + * is maintained by the client (i.e. if all this data come from .csproj file in Visual Studio). + * External project will exist even if all files in it are closed and should be closed explicity. + * If external project includes one or more tsconfig.json/jsconfig.json files then tsserver will + * create configured project for every config file but will maintain a link that these projects were created + * as a result of opening external project so they should be removed once external project is closed. + */ + interface ExternalFile { + /** + * Name of file file + */ + fileName: string; + /** + * Script kind of the file + */ + scriptKind?: ScriptKind; + /** + * Whether file has mixed content (i.e. .cshtml file that combines html markup with C#/JavaScript) + */ + hasMixedContent?: boolean; + /** + * Content of the file + */ + content?: string; + } + /** + * Represent an external project + */ + interface ExternalProject { + /** + * Project name + */ + projectFileName: string; + /** + * List of root files in project + */ + rootFiles: ExternalFile[]; + /** + * Compiler options for the project + */ + options: ExternalProjectCompilerOptions; + /** + * Explicitly specified typing options for the project + */ + typingOptions?: TypingOptions; + } + /** + * For external projects, some of the project settings are sent together with + * compiler settings. + */ + interface ExternalProjectCompilerOptions extends CompilerOptions { + /** + * If compile on save is enabled for the project + */ + compileOnSave?: boolean; + } + /** + * Contains information about current project version + */ + interface ProjectVersionInfo { + /** + * Project name + */ + projectName: string; + /** + * true if project is inferred or false if project is external or configured + */ + isInferred: boolean; + /** + * Project version + */ + version: number; + /** + * Current set of compiler options for project + */ + options: CompilerOptions; + } + /** + * Represents a set of changes that happen in project + */ + interface ProjectChanges { + /** + * List of added files + */ + added: string[]; + /** + * List of removed files + */ + removed: string[]; + } + /** + * Describes set of files in the project. + * info might be omitted in case of inferred projects + * if files is set - then this is the entire set of files in the project + * if changes is set - then this is the set of changes that should be applied to existing project + * otherwise - assume that nothing is changed + */ + interface ProjectFiles { + /** + * Information abount project verison + */ + info?: ProjectVersionInfo; + /** + * List of files in project (might be omitted if current state of project can be computed using only information from 'changes') + */ + files?: string[]; + /** + * Set of changes in project (omitted if the entire set of files in project should be replaced) + */ + changes?: ProjectChanges; + } + /** + * Combines project information with project level errors. + */ + interface ProjectFilesWithDiagnostics extends ProjectFiles { + /** + * List of errors in project + */ + projectErrors: DiagnosticWithLinePosition[]; + } + /** + * Information found in a configure request. + */ + interface ConfigureRequestArguments { + /** + * Information about the host, for example 'Emacs 24.4' or + * 'Sublime Text version 3075' + */ + hostInfo?: string; + /** + * If present, tab settings apply only to this file. + */ + file?: string; + /** + * The format options to use during formatting and other code editing features. + */ + formatOptions?: FormatCodeSettings; + } + /** + * Configure request; value of command field is "configure". Specifies + * host information, such as host type, tab size, and indent size. + */ + interface ConfigureRequest extends Request { + command: CommandTypes.Configure; + arguments: ConfigureRequestArguments; + } + /** + * Response to "configure" request. This is just an acknowledgement, so + * no body field is required. + */ + interface ConfigureResponse extends Response { + } + /** + * Information found in an "open" request. + */ + interface OpenRequestArgs extends FileRequestArgs { + /** + * Used when a version of the file content is known to be more up to date than the one on disk. + * Then the known content will be used upon opening instead of the disk copy + */ + fileContent?: string; + /** + * Used to specify the script kind of the file explicitly. It could be one of the following: + * "TS", "JS", "TSX", "JSX" + */ + scriptKindName?: "TS" | "JS" | "TSX" | "JSX"; + } + /** + * Open request; value of command field is "open". Notify the + * server that the client has file open. The server will not + * monitor the filesystem for changes in this file and will assume + * that the client is updating the server (using the change and/or + * reload messages) when the file changes. Server does not currently + * send a response to an open request. + */ + interface OpenRequest extends Request { + command: CommandTypes.Open; + arguments: OpenRequestArgs; + } + /** + * Request to open or update external project + */ + interface OpenExternalProjectRequest extends Request { + command: CommandTypes.OpenExternalProject; + arguments: OpenExternalProjectArgs; + } + /** + * Arguments to OpenExternalProjectRequest request + */ + type OpenExternalProjectArgs = ExternalProject; + /** + * Request to open multiple external projects + */ + interface OpenExternalProjectsRequest extends Request { + command: CommandTypes.OpenExternalProjects; + arguments: OpenExternalProjectsArgs; + } + /** + * Arguments to OpenExternalProjectsRequest + */ + interface OpenExternalProjectsArgs { + /** + * List of external projects to open or update + */ + projects: ExternalProject[]; + } + /** + * Response to OpenExternalProjectRequest request. This is just an acknowledgement, so + * no body field is required. + */ + interface OpenExternalProjectResponse extends Response { + } + /** + * Response to OpenExternalProjectsRequest request. This is just an acknowledgement, so + * no body field is required. + */ + interface OpenExternalProjectsResponse extends Response { + } + /** + * Request to close external project. + */ + interface CloseExternalProjectRequest extends Request { + command: CommandTypes.CloseExternalProject; + arguments: CloseExternalProjectRequestArgs; + } + /** + * Arguments to CloseExternalProjectRequest request + */ + interface CloseExternalProjectRequestArgs { + /** + * Name of the project to close + */ + projectFileName: string; + } + /** + * Response to CloseExternalProjectRequest request. This is just an acknowledgement, so + * no body field is required. + */ + interface CloseExternalProjectResponse extends Response { + } + /** + * Arguments to SynchronizeProjectListRequest + */ + interface SynchronizeProjectListRequestArgs { + /** + * List of last known projects + */ + knownProjects: protocol.ProjectVersionInfo[]; + } + /** + * Request to set compiler options for inferred projects. + * External projects are opened / closed explicitly. + * Configured projects are opened when user opens loose file that has 'tsconfig.json' or 'jsconfig.json' anywhere in one of containing folders. + * This configuration file will be used to obtain a list of files and configuration settings for the project. + * Inferred projects are created when user opens a loose file that is not the part of external project + * or configured project and will contain only open file and transitive closure of referenced files if 'useOneInferredProject' is false, + * or all open loose files and its transitive closure of referenced files if 'useOneInferredProject' is true. + */ + interface SetCompilerOptionsForInferredProjectsRequest extends Request { + command: CommandTypes.CompilerOptionsForInferredProjects; + arguments: SetCompilerOptionsForInferredProjectsArgs; + } + /** + * Argument for SetCompilerOptionsForInferredProjectsRequest request. + */ + interface SetCompilerOptionsForInferredProjectsArgs { + /** + * Compiler options to be used with inferred projects. + */ + options: ExternalProjectCompilerOptions; + } + /** + * Response to SetCompilerOptionsForInferredProjectsResponse request. This is just an acknowledgement, so + * no body field is required. + */ + interface SetCompilerOptionsForInferredProjectsResponse extends Response { + } + /** + * Exit request; value of command field is "exit". Ask the server process + * to exit. + */ + interface ExitRequest extends Request { + command: CommandTypes.Exit; + } + /** + * Close request; value of command field is "close". Notify the + * server that the client has closed a previously open file. If + * file is still referenced by open files, the server will resume + * monitoring the filesystem for changes to file. Server does not + * currently send a response to a close request. + */ + interface CloseRequest extends FileRequest { + command: CommandTypes.Close; + } + /** + * Request to obtain the list of files that should be regenerated if target file is recompiled. + * NOTE: this us query-only operation and does not generate any output on disk. + */ + interface CompileOnSaveAffectedFileListRequest extends FileRequest { + command: CommandTypes.CompileOnSaveAffectedFileList; + } + /** + * Contains a list of files that should be regenerated in a project + */ + interface CompileOnSaveAffectedFileListSingleProject { + /** + * Project name + */ + projectFileName: string; + /** + * List of files names that should be recompiled + */ + fileNames: string[]; + } + /** + * Response for CompileOnSaveAffectedFileListRequest request; + */ + interface CompileOnSaveAffectedFileListResponse extends Response { + body: CompileOnSaveAffectedFileListSingleProject[]; + } + /** + * Request to recompile the file. All generated outputs (.js, .d.ts or .js.map files) is written on disk. + */ + interface CompileOnSaveEmitFileRequest extends FileRequest { + command: CommandTypes.CompileOnSaveEmitFile; + arguments: CompileOnSaveEmitFileRequestArgs; + } + /** + * Arguments for CompileOnSaveEmitFileRequest + */ + interface CompileOnSaveEmitFileRequestArgs extends FileRequestArgs { + /** + * if true - then file should be recompiled even if it does not have any changes. + */ + forced?: boolean; + } + /** + * Quickinfo request; value of command field is + * "quickinfo". Return response giving a quick type and + * documentation string for the symbol found in file at location + * line, col. + */ + interface QuickInfoRequest extends FileLocationRequest { + command: CommandTypes.Quickinfo; + } + /** + * Body of QuickInfoResponse. + */ + interface QuickInfoResponseBody { + /** + * The symbol's kind (such as 'className' or 'parameterName' or plain 'text'). + */ + kind: string; + /** + * Optional modifiers for the kind (such as 'public'). + */ + kindModifiers: string; + /** + * Starting file location of symbol. + */ + start: Location; + /** + * One past last character of symbol. + */ + end: Location; + /** + * Type and kind of symbol. + */ + displayString: string; + /** + * Documentation associated with symbol. + */ + documentation: string; + } + /** + * Quickinfo response message. + */ + interface QuickInfoResponse extends Response { + body?: QuickInfoResponseBody; + } + /** + * Arguments for format messages. + */ + interface FormatRequestArgs extends FileLocationRequestArgs { + /** + * Last line of range for which to format text in file. + */ + endLine: number; + /** + * Character offset on last line of range for which to format text in file. + */ + endOffset: number; + /** + * Format options to be used. + */ + options?: FormatCodeSettings; + } + /** + * Format request; value of command field is "format". Return + * response giving zero or more edit instructions. The edit + * instructions will be sorted in file order. Applying the edit + * instructions in reverse to file will result in correctly + * reformatted text. + */ + interface FormatRequest extends FileLocationRequest { + command: CommandTypes.Format; + arguments: FormatRequestArgs; + } + /** + * Object found in response messages defining an editing + * instruction for a span of text in source code. The effect of + * this instruction is to replace the text starting at start and + * ending one character before end with newText. For an insertion, + * the text span is empty. For a deletion, newText is empty. + */ + interface CodeEdit { + /** + * First character of the text span to edit. + */ + start: Location; + /** + * One character past last character of the text span to edit. + */ + end: Location; + /** + * Replace the span defined above with this string (may be + * the empty string). + */ + newText: string; + } + interface FileCodeEdits { + fileName: string; + textChanges: CodeEdit[]; + } + interface CodeFixResponse extends Response { + /** The code actions that are available */ + body?: CodeAction[]; + } + interface CodeAction { + /** Description of the code action to display in the UI of the editor */ + description: string; + /** Text changes to apply to each file as part of the code action */ + changes: FileCodeEdits[]; + } + /** + * Format and format on key response message. + */ + interface FormatResponse extends Response { + body?: CodeEdit[]; + } + /** + * Arguments for format on key messages. + */ + interface FormatOnKeyRequestArgs extends FileLocationRequestArgs { + /** + * Key pressed (';', '\n', or '}'). + */ + key: string; + options?: FormatCodeSettings; + } + /** + * Format on key request; value of command field is + * "formatonkey". Given file location and key typed (as string), + * return response giving zero or more edit instructions. The + * edit instructions will be sorted in file order. Applying the + * edit instructions in reverse to file will result in correctly + * reformatted text. + */ + interface FormatOnKeyRequest extends FileLocationRequest { + command: CommandTypes.Formatonkey; + arguments: FormatOnKeyRequestArgs; + } + /** + * Arguments for completions messages. + */ + interface CompletionsRequestArgs extends FileLocationRequestArgs { + /** + * Optional prefix to apply to possible completions. + */ + prefix?: string; + } + /** + * Completions request; value of command field is "completions". + * Given a file location (file, line, col) and a prefix (which may + * be the empty string), return the possible completions that + * begin with prefix. + */ + interface CompletionsRequest extends FileLocationRequest { + command: CommandTypes.Completions; + arguments: CompletionsRequestArgs; + } + /** + * Arguments for completion details request. + */ + interface CompletionDetailsRequestArgs extends FileLocationRequestArgs { + /** + * Names of one or more entries for which to obtain details. + */ + entryNames: string[]; + } + /** + * Completion entry details request; value of command field is + * "completionEntryDetails". Given a file location (file, line, + * col) and an array of completion entry names return more + * detailed information for each completion entry. + */ + interface CompletionDetailsRequest extends FileLocationRequest { + command: CommandTypes.CompletionDetails; + arguments: CompletionDetailsRequestArgs; + } + /** + * Part of a symbol description. + */ + interface SymbolDisplayPart { + /** + * Text of an item describing the symbol. + */ + text: string; + /** + * The symbol's kind (such as 'className' or 'parameterName' or plain 'text'). + */ + kind: string; + } + /** + * An item found in a completion response. + */ + interface CompletionEntry { + /** + * The symbol's name. + */ + name: string; + /** + * The symbol's kind (such as 'className' or 'parameterName'). + */ + kind: string; + /** + * Optional modifiers for the kind (such as 'public'). + */ + kindModifiers: string; + /** + * A string that is used for comparing completion items so that they can be ordered. This + * is often the same as the name but may be different in certain circumstances. + */ + sortText: string; + /** + * An optional span that indicates the text to be replaced by this completion item. If present, + * this span should be used instead of the default one. + */ + replacementSpan?: TextSpan; + } + /** + * Additional completion entry details, available on demand + */ + interface CompletionEntryDetails { + /** + * The symbol's name. + */ + name: string; + /** + * The symbol's kind (such as 'className' or 'parameterName'). + */ + kind: string; + /** + * Optional modifiers for the kind (such as 'public'). + */ + kindModifiers: string; + /** + * Display parts of the symbol (similar to quick info). + */ + displayParts: SymbolDisplayPart[]; + /** + * Documentation strings for the symbol. + */ + documentation: SymbolDisplayPart[]; + } + interface CompletionsResponse extends Response { + body?: CompletionEntry[]; + } + interface CompletionDetailsResponse extends Response { + body?: CompletionEntryDetails[]; + } + /** + * Signature help information for a single parameter + */ + interface SignatureHelpParameter { + /** + * The parameter's name + */ + name: string; + /** + * Documentation of the parameter. + */ + documentation: SymbolDisplayPart[]; + /** + * Display parts of the parameter. + */ + displayParts: SymbolDisplayPart[]; + /** + * Whether the parameter is optional or not. + */ + isOptional: boolean; + } + /** + * Represents a single signature to show in signature help. + */ + interface SignatureHelpItem { + /** + * Whether the signature accepts a variable number of arguments. + */ + isVariadic: boolean; + /** + * The prefix display parts. + */ + prefixDisplayParts: SymbolDisplayPart[]; + /** + * The suffix display parts. + */ + suffixDisplayParts: SymbolDisplayPart[]; + /** + * The separator display parts. + */ + separatorDisplayParts: SymbolDisplayPart[]; + /** + * The signature helps items for the parameters. + */ + parameters: SignatureHelpParameter[]; + /** + * The signature's documentation + */ + documentation: SymbolDisplayPart[]; + } + /** + * Signature help items found in the response of a signature help request. + */ + interface SignatureHelpItems { + /** + * The signature help items. + */ + items: SignatureHelpItem[]; + /** + * The span for which signature help should appear on a signature + */ + applicableSpan: TextSpan; + /** + * The item selected in the set of available help items. + */ + selectedItemIndex: number; + /** + * The argument selected in the set of parameters. + */ + argumentIndex: number; + /** + * The argument count + */ + argumentCount: number; + } + /** + * Arguments of a signature help request. + */ + interface SignatureHelpRequestArgs extends FileLocationRequestArgs { + } + /** + * Signature help request; value of command field is "signatureHelp". + * Given a file location (file, line, col), return the signature + * help. + */ + interface SignatureHelpRequest extends FileLocationRequest { + command: CommandTypes.SignatureHelp; + arguments: SignatureHelpRequestArgs; + } + /** + * Response object for a SignatureHelpRequest. + */ + interface SignatureHelpResponse extends Response { + body?: SignatureHelpItems; + } + /** + * Synchronous request for semantic diagnostics of one file. + */ + interface SemanticDiagnosticsSyncRequest extends FileRequest { + command: CommandTypes.SemanticDiagnosticsSync; + arguments: SemanticDiagnosticsSyncRequestArgs; + } + interface SemanticDiagnosticsSyncRequestArgs extends FileRequestArgs { + includeLinePosition?: boolean; + } + /** + * Response object for synchronous sematic diagnostics request. + */ + interface SemanticDiagnosticsSyncResponse extends Response { + body?: Diagnostic[] | DiagnosticWithLinePosition[]; + } + /** + * Synchronous request for syntactic diagnostics of one file. + */ + interface SyntacticDiagnosticsSyncRequest extends FileRequest { + command: CommandTypes.SyntacticDiagnosticsSync; + arguments: SyntacticDiagnosticsSyncRequestArgs; + } + interface SyntacticDiagnosticsSyncRequestArgs extends FileRequestArgs { + includeLinePosition?: boolean; + } + /** + * Response object for synchronous syntactic diagnostics request. + */ + interface SyntacticDiagnosticsSyncResponse extends Response { + body?: Diagnostic[] | DiagnosticWithLinePosition[]; + } + /** + * Arguments for GeterrForProject request. + */ + interface GeterrForProjectRequestArgs { + /** + * the file requesting project error list + */ + file: string; + /** + * Delay in milliseconds to wait before starting to compute + * errors for the files in the file list + */ + delay: number; + } + /** + * GeterrForProjectRequest request; value of command field is + * "geterrForProject". It works similarly with 'Geterr', only + * it request for every file in this project. + */ + interface GeterrForProjectRequest extends Request { + command: CommandTypes.GeterrForProject; + arguments: GeterrForProjectRequestArgs; + } + /** + * Arguments for geterr messages. + */ + interface GeterrRequestArgs { + /** + * List of file names for which to compute compiler errors. + * The files will be checked in list order. + */ + files: string[]; + /** + * Delay in milliseconds to wait before starting to compute + * errors for the files in the file list + */ + delay: number; + } + /** + * Geterr request; value of command field is "geterr". Wait for + * delay milliseconds and then, if during the wait no change or + * reload messages have arrived for the first file in the files + * list, get the syntactic errors for the file, field requests, + * and then get the semantic errors for the file. Repeat with a + * smaller delay for each subsequent file on the files list. Best + * practice for an editor is to send a file list containing each + * file that is currently visible, in most-recently-used order. + */ + interface GeterrRequest extends Request { + command: CommandTypes.Geterr; + arguments: GeterrRequestArgs; + } + /** + * Item of diagnostic information found in a DiagnosticEvent message. + */ + interface Diagnostic { + /** + * Starting file location at which text applies. + */ + start: Location; + /** + * The last file location at which the text applies. + */ + end: Location; + /** + * Text of diagnostic message. + */ + text: string; + /** + * The error code of the diagnostic message. + */ + code?: number; + } + interface DiagnosticEventBody { + /** + * The file for which diagnostic information is reported. + */ + file: string; + /** + * An array of diagnostic information items. + */ + diagnostics: Diagnostic[]; + } + /** + * Event message for "syntaxDiag" and "semanticDiag" event types. + * These events provide syntactic and semantic errors for a file. + */ + interface DiagnosticEvent extends Event { + body?: DiagnosticEventBody; + } + interface ConfigFileDiagnosticEventBody { + /** + * The file which trigged the searching and error-checking of the config file + */ + triggerFile: string; + /** + * The name of the found config file. + */ + configFile: string; + /** + * An arry of diagnostic information items for the found config file. + */ + diagnostics: Diagnostic[]; + } + /** + * Event message for "configFileDiag" event type. + * This event provides errors for a found config file. + */ + interface ConfigFileDiagnosticEvent extends Event { + body?: ConfigFileDiagnosticEventBody; + event: "configFileDiag"; + } + /** + * Arguments for reload request. + */ + interface ReloadRequestArgs extends FileRequestArgs { + /** + * Name of temporary file from which to reload file + * contents. May be same as file. + */ + tmpfile: string; + } + /** + * Reload request message; value of command field is "reload". + * Reload contents of file with name given by the 'file' argument + * from temporary file with name given by the 'tmpfile' argument. + * The two names can be identical. + */ + interface ReloadRequest extends FileRequest { + command: CommandTypes.Reload; + arguments: ReloadRequestArgs; + } + /** + * Response to "reload" request. This is just an acknowledgement, so + * no body field is required. + */ + interface ReloadResponse extends Response { + } + /** + * Arguments for saveto request. + */ + interface SavetoRequestArgs extends FileRequestArgs { + /** + * Name of temporary file into which to save server's view of + * file contents. + */ + tmpfile: string; + } + /** + * Saveto request message; value of command field is "saveto". + * For debugging purposes, save to a temporaryfile (named by + * argument 'tmpfile') the contents of file named by argument + * 'file'. The server does not currently send a response to a + * "saveto" request. + */ + interface SavetoRequest extends FileRequest { + command: CommandTypes.Saveto; + arguments: SavetoRequestArgs; + } + /** + * Arguments for navto request message. + */ + interface NavtoRequestArgs extends FileRequestArgs { + /** + * Search term to navigate to from current location; term can + * be '.*' or an identifier prefix. + */ + searchValue: string; + /** + * Optional limit on the number of items to return. + */ + maxResultCount?: number; + /** + * Optional flag to indicate we want results for just the current file + * or the entire project. + */ + currentFileOnly?: boolean; + projectFileName?: string; + } + /** + * Navto request message; value of command field is "navto". + * Return list of objects giving file locations and symbols that + * match the search term given in argument 'searchTerm'. The + * context for the search is given by the named file. + */ + interface NavtoRequest extends FileRequest { + command: CommandTypes.Navto; + arguments: NavtoRequestArgs; + } + /** + * An item found in a navto response. + */ + interface NavtoItem { + /** + * The symbol's name. + */ + name: string; + /** + * The symbol's kind (such as 'className' or 'parameterName'). + */ + kind: string; + /** + * exact, substring, or prefix. + */ + matchKind?: string; + /** + * If this was a case sensitive or insensitive match. + */ + isCaseSensitive?: boolean; + /** + * Optional modifiers for the kind (such as 'public'). + */ + kindModifiers?: string; + /** + * The file in which the symbol is found. + */ + file: string; + /** + * The location within file at which the symbol is found. + */ + start: Location; + /** + * One past the last character of the symbol. + */ + end: Location; + /** + * Name of symbol's container symbol (if any); for example, + * the class name if symbol is a class member. + */ + containerName?: string; + /** + * Kind of symbol's container symbol (if any). + */ + containerKind?: string; + } + /** + * Navto response message. Body is an array of navto items. Each + * item gives a symbol that matched the search term. + */ + interface NavtoResponse extends Response { + body?: NavtoItem[]; + } + /** + * Arguments for change request message. + */ + interface ChangeRequestArgs extends FormatRequestArgs { + /** + * Optional string to insert at location (file, line, offset). + */ + insertString?: string; + } + /** + * Change request message; value of command field is "change". + * Update the server's view of the file named by argument 'file'. + * Server does not currently send a response to a change request. + */ + interface ChangeRequest extends FileLocationRequest { + command: CommandTypes.Change; + arguments: ChangeRequestArgs; + } + /** + * Response to "brace" request. + */ + interface BraceResponse extends Response { + body?: TextSpan[]; + } + /** + * Brace matching request; value of command field is "brace". + * Return response giving the file locations of matching braces + * found in file at location line, offset. + */ + interface BraceRequest extends FileLocationRequest { + command: CommandTypes.Brace; + } + /** + * NavBar items request; value of command field is "navbar". + * Return response giving the list of navigation bar entries + * extracted from the requested file. + */ + interface NavBarRequest extends FileRequest { + command: CommandTypes.NavBar; + } + /** + * NavTree request; value of command field is "navtree". + * Return response giving the navigation tree of the requested file. + */ + interface NavTreeRequest extends FileRequest { + command: CommandTypes.NavTree; + } + interface NavigationBarItem { + /** + * The item's display text. + */ + text: string; + /** + * The symbol's kind (such as 'className' or 'parameterName'). + */ + kind: string; + /** + * Optional modifiers for the kind (such as 'public'). + */ + kindModifiers?: string; + /** + * The definition locations of the item. + */ + spans: TextSpan[]; + /** + * Optional children. + */ + childItems?: NavigationBarItem[]; + /** + * Number of levels deep this item should appear. + */ + indent: number; + } + /** protocol.NavigationTree is identical to ts.NavigationTree, except using protocol.TextSpan instead of ts.TextSpan */ + interface NavigationTree { + text: string; + kind: string; + kindModifiers: string; + spans: TextSpan[]; + childItems?: NavigationTree[]; + } + interface NavBarResponse extends Response { + body?: NavigationBarItem[]; + } + interface NavTreeResponse extends Response { + body?: NavigationTree; + } +} +declare namespace ts.server.protocol { + + interface TextInsertion { + newText: string; + /** The position in newText the caret should point to after the insertion. */ + caretOffset: number; + } + + interface TodoCommentDescriptor { + text: string; + priority: number; + } + + interface TodoComment { + descriptor: TodoCommentDescriptor; + message: string; + position: number; + } + + interface EditorSettings { + baseIndentSize?: number; + indentSize?: number; + tabSize?: number; + newLineCharacter?: string; + convertTabsToSpaces?: boolean; + indentStyle?: IndentStyle; + } + + enum IndentStyle { + None = 0, + Block = 1, + Smart = 2, + } + + enum ScriptKind { + Unknown = 0, + JS = 1, + JSX = 2, + TS = 3, + TSX = 4, + } + + interface TypingOptions { + enableAutoDiscovery?: boolean; + include?: string[]; + exclude?: string[]; + [option: string]: string[] | boolean | undefined; + } + + interface CompilerOptions { + allowJs?: boolean; + allowSyntheticDefaultImports?: boolean; + allowUnreachableCode?: boolean; + allowUnusedLabels?: boolean; + alwaysStrict?: boolean; + baseUrl?: string; + charset?: string; + declaration?: boolean; + declarationDir?: string; + disableSizeLimit?: boolean; + emitBOM?: boolean; + emitDecoratorMetadata?: boolean; + experimentalDecorators?: boolean; + forceConsistentCasingInFileNames?: boolean; + importHelpers?: boolean; + inlineSourceMap?: boolean; + inlineSources?: boolean; + isolatedModules?: boolean; + jsx?: JsxEmit; + lib?: string[]; + locale?: string; + mapRoot?: string; + maxNodeModuleJsDepth?: number; + module?: ModuleKind; + moduleResolution?: ModuleResolutionKind; + newLine?: NewLineKind; + noEmit?: boolean; + noEmitHelpers?: boolean; + noEmitOnError?: boolean; + noErrorTruncation?: boolean; + noFallthroughCasesInSwitch?: boolean; + noImplicitAny?: boolean; + noImplicitReturns?: boolean; + noImplicitThis?: boolean; + noUnusedLocals?: boolean; + noUnusedParameters?: boolean; + noImplicitUseStrict?: boolean; + noLib?: boolean; + noResolve?: boolean; + out?: string; + outDir?: string; + outFile?: string; + paths?: MapLike; + preserveConstEnums?: boolean; + project?: string; + reactNamespace?: string; + removeComments?: boolean; + rootDir?: string; + rootDirs?: string[]; + skipLibCheck?: boolean; + skipDefaultLibCheck?: boolean; + sourceMap?: boolean; + sourceRoot?: string; + strictNullChecks?: boolean; + suppressExcessPropertyErrors?: boolean; + suppressImplicitAnyIndexErrors?: boolean; + target?: ScriptTarget; + traceResolution?: boolean; + types?: string[]; + /** Paths used to used to compute primary types search locations */ + typeRoots?: string[]; + [option: string]: CompilerOptionsValue | undefined; + } + + enum JsxEmit { + None = 0, + Preserve = 1, + React = 2, + } + + enum ModuleKind { + None = 0, + CommonJS = 1, + AMD = 2, + UMD = 3, + System = 4, + ES6 = 5, + ES2015 = 5, + } + + enum ModuleResolutionKind { + Classic = 1, + NodeJs = 2, + } + + enum NewLineKind { + CarriageReturnLineFeed = 0, + LineFeed = 1, + } + + interface MapLike { + [index: string]: T; + } + + enum ScriptTarget { + ES3 = 0, + ES5 = 1, + ES6 = 2, + ES2015 = 2, + Latest = 2, + } + + type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike; + + interface FormatCodeSettings extends EditorSettings { + insertSpaceAfterCommaDelimiter?: boolean; + insertSpaceAfterSemicolonInForStatements?: boolean; + insertSpaceBeforeAndAfterBinaryOperators?: boolean; + insertSpaceAfterKeywordsInControlFlowStatements?: boolean; + insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; + insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; + insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean; + insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces?: boolean; + insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; + insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; + insertSpaceAfterTypeAssertion?: boolean; + placeOpenBraceOnNewLineForFunctions?: boolean; + placeOpenBraceOnNewLineForControlBlocks?: boolean; + } +} \ No newline at end of file diff --git a/lib/tsc.js b/lib/tsc.js index aef54c957e6..7f46b1dddb4 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -145,6 +145,7 @@ var ts; contains: contains, remove: remove, forEachValue: forEachValueInMap, + getKeys: getKeys, clear: clear }; function forEachValueInMap(f) { @@ -152,6 +153,13 @@ var ts; f(key, files[key]); } } + function getKeys() { + var keys = []; + for (var key in files) { + keys.push(key); + } + return keys; + } function get(path) { return files[toKey(path)]; } @@ -528,16 +536,22 @@ var ts; : undefined; } ts.lastOrUndefined = lastOrUndefined; - function binarySearch(array, value) { + function binarySearch(array, value, comparer) { + if (!array || array.length === 0) { + return -1; + } var low = 0; var high = array.length - 1; + comparer = comparer !== undefined + ? comparer + : function (v1, v2) { return (v1 < v2 ? -1 : (v1 > v2 ? 1 : 0)); }; while (low <= high) { var middle = low + ((high - low) >> 1); var midValue = array[middle]; - if (midValue === value) { + if (comparer(midValue, value) === 0) { return middle; } - else if (midValue > value) { + else if (comparer(midValue, value) > 0) { high = middle - 1; } else { @@ -771,6 +785,56 @@ var ts; }; } ts.memoize = memoize; + function chain(a, b, c, d, e) { + if (e) { + var args_2 = []; + for (var i = 0; i < arguments.length; i++) { + args_2[i] = arguments[i]; + } + return function (t) { return compose.apply(void 0, map(args_2, function (f) { return f(t); })); }; + } + else if (d) { + return function (t) { return compose(a(t), b(t), c(t), d(t)); }; + } + else if (c) { + return function (t) { return compose(a(t), b(t), c(t)); }; + } + else if (b) { + return function (t) { return compose(a(t), b(t)); }; + } + else if (a) { + return function (t) { return compose(a(t)); }; + } + else { + return function (t) { return function (u) { return u; }; }; + } + } + ts.chain = chain; + function compose(a, b, c, d, e) { + if (e) { + var args_3 = []; + for (var i = 0; i < arguments.length; i++) { + args_3[i] = arguments[i]; + } + return function (t) { return reduceLeft(args_3, function (u, f) { return f(u); }, t); }; + } + else if (d) { + return function (t) { return d(c(b(a(t)))); }; + } + else if (c) { + return function (t) { return c(b(a(t))); }; + } + else if (b) { + return function (t) { return b(a(t)); }; + } + else if (a) { + return function (t) { return a(t); }; + } + else { + return function (t) { return t; }; + } + } + ts.compose = compose; function formatStringFromArgs(text, args, baseIndex) { baseIndex = baseIndex || 0; return text.replace(/{(\d+)}/g, function (match, index) { return args[+index + baseIndex]; }); @@ -1007,10 +1071,45 @@ var ts; return path && !isRootedDiskPath(path) && path.indexOf("://") !== -1; } ts.isUrl = isUrl; + function isExternalModuleNameRelative(moduleName) { + return /^\.\.?($|[\\/])/.test(moduleName); + } + ts.isExternalModuleNameRelative = isExternalModuleNameRelative; + function getEmitScriptTarget(compilerOptions) { + return compilerOptions.target || 0; + } + ts.getEmitScriptTarget = getEmitScriptTarget; + function getEmitModuleKind(compilerOptions) { + return typeof compilerOptions.module === "number" ? + compilerOptions.module : + getEmitScriptTarget(compilerOptions) === 2 ? ts.ModuleKind.ES6 : ts.ModuleKind.CommonJS; + } + ts.getEmitModuleKind = getEmitModuleKind; + function hasZeroOrOneAsteriskCharacter(str) { + var seenAsterisk = false; + for (var i = 0; i < str.length; i++) { + if (str.charCodeAt(i) === 42) { + if (!seenAsterisk) { + seenAsterisk = true; + } + else { + return false; + } + } + } + return true; + } + ts.hasZeroOrOneAsteriskCharacter = hasZeroOrOneAsteriskCharacter; function isRootedDiskPath(path) { return getRootLength(path) !== 0; } ts.isRootedDiskPath = isRootedDiskPath; + function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) { + return !isRootedDiskPath(absoluteOrRelativePath) + ? absoluteOrRelativePath + : getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, false); + } + ts.convertToRelativePath = convertToRelativePath; function normalizedPathComponents(path, rootLength) { var normalizedParts = getNormalizedParts(path, rootLength); return [path.substr(0, rootLength)].concat(normalizedParts); @@ -1384,6 +1483,14 @@ var ts; return options && options.allowJs ? allSupportedExtensions : ts.supportedTypeScriptExtensions; } ts.getSupportedExtensions = getSupportedExtensions; + function hasJavaScriptFileExtension(fileName) { + return forEach(ts.supportedJavascriptExtensions, function (extension) { return fileExtensionIs(fileName, extension); }); + } + ts.hasJavaScriptFileExtension = hasJavaScriptFileExtension; + function hasTypeScriptFileExtension(fileName) { + return forEach(ts.supportedTypeScriptExtensions, function (extension) { return fileExtensionIs(fileName, extension); }); + } + ts.hasTypeScriptFileExtension = hasTypeScriptFileExtension; function isSupportedSourceFileName(fileName, compilerOptions) { if (!fileName) { return false; @@ -1475,7 +1582,6 @@ var ts; this.transformFlags = 0; this.parent = undefined; this.original = undefined; - this.transformId = 0; } ts.objectAllocator = { getNodeConstructor: function () { return Node; }, @@ -1488,9 +1594,9 @@ var ts; }; var Debug; (function (Debug) { - var currentAssertionLevel; + Debug.currentAssertionLevel = 0; function shouldAssert(level) { - return getCurrentAssertionLevel() >= level; + return Debug.currentAssertionLevel >= level; } Debug.shouldAssert = shouldAssert; function assert(expression, message, verboseDebugInfo) { @@ -1508,30 +1614,7 @@ var ts; Debug.assert(false, message); } Debug.fail = fail; - function getCurrentAssertionLevel() { - if (currentAssertionLevel !== undefined) { - return currentAssertionLevel; - } - if (ts.sys === undefined) { - return 0; - } - var developmentMode = /^development$/i.test(getEnvironmentVariable("NODE_ENV")); - currentAssertionLevel = developmentMode - ? 1 - : 0; - return currentAssertionLevel; - } })(Debug = ts.Debug || (ts.Debug = {})); - function getEnvironmentVariable(name, host) { - if (host && host.getEnvironmentVariable) { - return host.getEnvironmentVariable(name); - } - if (ts.sys && ts.sys.getEnvironmentVariable) { - return ts.sys.getEnvironmentVariable(name); - } - return ""; - } - ts.getEnvironmentVariable = getEnvironmentVariable; function orderedRemoveItemAt(array, index) { for (var i = index; i < array.length - 1; i++) { array[i] = array[i + 1]; @@ -1562,6 +1645,64 @@ var ts; : (function (fileName) { return fileName.toLowerCase(); }); } ts.createGetCanonicalFileName = createGetCanonicalFileName; + function matchPatternOrExact(patternStrings, candidate) { + var patterns = []; + for (var _i = 0, patternStrings_1 = patternStrings; _i < patternStrings_1.length; _i++) { + var patternString = patternStrings_1[_i]; + var pattern = tryParsePattern(patternString); + if (pattern) { + patterns.push(pattern); + } + else if (patternString === candidate) { + return patternString; + } + } + return findBestPatternMatch(patterns, function (_) { return _; }, candidate); + } + ts.matchPatternOrExact = matchPatternOrExact; + function patternText(_a) { + var prefix = _a.prefix, suffix = _a.suffix; + return prefix + "*" + suffix; + } + ts.patternText = patternText; + function matchedText(pattern, candidate) { + Debug.assert(isPatternMatch(pattern, candidate)); + return candidate.substr(pattern.prefix.length, candidate.length - pattern.suffix.length); + } + ts.matchedText = matchedText; + function findBestPatternMatch(values, getPattern, candidate) { + var matchedValue = undefined; + var longestMatchPrefixLength = -1; + for (var _i = 0, values_1 = values; _i < values_1.length; _i++) { + var v = values_1[_i]; + var pattern = getPattern(v); + if (isPatternMatch(pattern, candidate) && pattern.prefix.length > longestMatchPrefixLength) { + longestMatchPrefixLength = pattern.prefix.length; + matchedValue = v; + } + } + return matchedValue; + } + ts.findBestPatternMatch = findBestPatternMatch; + function isPatternMatch(_a, candidate) { + var prefix = _a.prefix, suffix = _a.suffix; + return candidate.length >= prefix.length + suffix.length && + startsWith(candidate, prefix) && + endsWith(candidate, suffix); + } + function tryParsePattern(pattern) { + Debug.assert(hasZeroOrOneAsteriskCharacter(pattern)); + var indexOfStar = pattern.indexOf("*"); + return indexOfStar === -1 ? undefined : { + prefix: pattern.substr(0, indexOfStar), + suffix: pattern.substr(indexOfStar + 1) + }; + } + ts.tryParsePattern = tryParsePattern; + function positionIsSynthesized(pos) { + return !(pos >= 0); + } + ts.positionIsSynthesized = positionIsSynthesized; })(ts || (ts = {})); var ts; (function (ts) { @@ -1755,8 +1896,14 @@ var ts; function isNode4OrLater() { return parseInt(process.version.charAt(1)) >= 4; } + function isFileSystemCaseSensitive() { + if (platform === "win32" || platform === "win64") { + return false; + } + return !fileExists(__filename.toUpperCase()) || !fileExists(__filename.toLowerCase()); + } var platform = _os.platform(); - var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin"; + var useCaseSensitiveFileNames = isFileSystemCaseSensitive(); function readFile(fileName, encoding) { if (!fileExists(fileName)) { return undefined; @@ -1881,6 +2028,9 @@ var ts; }, watchDirectory: function (directoryName, callback, recursive) { var options; + if (!directoryExists(directoryName)) { + return; + } if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) { options = { persistent: true, recursive: !!recursive }; } @@ -1992,19 +2142,43 @@ var ts; realpath: realpath }; } + function recursiveCreateDirectory(directoryPath, sys) { + var basePath = ts.getDirectoryPath(directoryPath); + var shouldCreateParent = directoryPath !== basePath && !sys.directoryExists(basePath); + if (shouldCreateParent) { + recursiveCreateDirectory(basePath, sys); + } + if (shouldCreateParent || !sys.directoryExists(directoryPath)) { + sys.createDirectory(directoryPath); + } + } + var sys; if (typeof ChakraHost !== "undefined") { - return getChakraSystem(); + sys = getChakraSystem(); } else if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { - return getWScriptSystem(); + sys = getWScriptSystem(); } else if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof require !== "undefined") { - return getNodeSystem(); + sys = getNodeSystem(); } - else { - return undefined; + if (sys) { + var originalWriteFile_1 = sys.writeFile; + sys.writeFile = function (path, data, writeBom) { + var directoryPath = ts.getDirectoryPath(ts.normalizeSlashes(path)); + if (directoryPath && !sys.directoryExists(directoryPath)) { + recursiveCreateDirectory(directoryPath, sys); + } + originalWriteFile_1.call(sys, path, data, writeBom); + }; } + return sys; })(); + if (ts.sys && ts.sys.getEnvironmentVariable) { + ts.Debug.currentAssertionLevel = /^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV")) + ? 1 + : 0; + } })(ts || (ts = {})); var ts; (function (ts) { @@ -2329,7 +2503,7 @@ var ts; The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2407, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_2407", message: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter." }, Setters_cannot_return_a_value: { code: 2408, category: ts.DiagnosticCategory.Error, key: "Setters_cannot_return_a_value_2408", message: "Setters cannot return a value." }, Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { code: 2409, category: ts.DiagnosticCategory.Error, key: "Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class_2409", message: "Return type of constructor signature must be assignable to the instance type of the class" }, - All_symbols_within_a_with_block_will_be_resolved_to_any: { code: 2410, category: ts.DiagnosticCategory.Error, key: "All_symbols_within_a_with_block_will_be_resolved_to_any_2410", message: "All symbols within a 'with' block will be resolved to 'any'." }, + The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any: { code: 2410, category: ts.DiagnosticCategory.Error, key: "The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any_2410", message: "The 'with' statement is not supported. All symbols in a 'with' block will have type 'any'." }, Property_0_of_type_1_is_not_assignable_to_string_index_type_2: { code: 2411, category: ts.DiagnosticCategory.Error, key: "Property_0_of_type_1_is_not_assignable_to_string_index_type_2_2411", message: "Property '{0}' of type '{1}' is not assignable to string index type '{2}'." }, Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2: { code: 2412, category: ts.DiagnosticCategory.Error, key: "Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2_2412", message: "Property '{0}' of type '{1}' is not assignable to numeric index type '{2}'." }, Numeric_index_type_0_is_not_assignable_to_string_index_type_1: { code: 2413, category: ts.DiagnosticCategory.Error, key: "Numeric_index_type_0_is_not_assignable_to_string_index_type_1_2413", message: "Numeric index type '{0}' is not assignable to string index type '{1}'." }, @@ -2490,7 +2664,7 @@ var ts; this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation: { code: 2683, category: ts.DiagnosticCategory.Error, key: "this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_2683", message: "'this' implicitly has type 'any' because it does not have a type annotation." }, The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1: { code: 2684, category: ts.DiagnosticCategory.Error, key: "The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1_2684", message: "The 'this' context of type '{0}' is not assignable to method's 'this' of type '{1}'." }, The_this_types_of_each_signature_are_incompatible: { code: 2685, category: ts.DiagnosticCategory.Error, key: "The_this_types_of_each_signature_are_incompatible_2685", message: "The 'this' types of each signature are incompatible." }, - Identifier_0_must_be_imported_from_a_module: { code: 2686, category: ts.DiagnosticCategory.Error, key: "Identifier_0_must_be_imported_from_a_module_2686", message: "Identifier '{0}' must be imported from a module" }, + _0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead: { code: 2686, category: ts.DiagnosticCategory.Error, key: "_0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead_2686", message: "'{0}' refers to a UMD global, but the current file is a module. Consider adding an import instead." }, All_declarations_of_0_must_have_identical_modifiers: { code: 2687, category: ts.DiagnosticCategory.Error, key: "All_declarations_of_0_must_have_identical_modifiers_2687", message: "All declarations of '{0}' must have identical modifiers." }, Cannot_find_type_definition_file_for_0: { code: 2688, category: ts.DiagnosticCategory.Error, key: "Cannot_find_type_definition_file_for_0_2688", message: "Cannot find type definition file for '{0}'." }, Cannot_extend_an_interface_0_Did_you_mean_implements: { code: 2689, category: ts.DiagnosticCategory.Error, key: "Cannot_extend_an_interface_0_Did_you_mean_implements_2689", message: "Cannot extend an interface '{0}'. Did you mean 'implements'?" }, @@ -2723,6 +2897,8 @@ var ts; No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0: { code: 6137, category: ts.DiagnosticCategory.Message, key: "No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0_6137", message: "No types specified in 'package.json' but 'allowJs' is set, so returning 'main' value of '{0}'" }, Property_0_is_declared_but_never_used: { code: 6138, category: ts.DiagnosticCategory.Error, key: "Property_0_is_declared_but_never_used_6138", message: "Property '{0}' is declared but never used." }, Import_emit_helpers_from_tslib: { code: 6139, category: ts.DiagnosticCategory.Message, key: "Import_emit_helpers_from_tslib_6139", message: "Import emit helpers from 'tslib'." }, + Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: { code: 6140, category: ts.DiagnosticCategory.Error, key: "Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using__6140", message: "Auto discovery for typings is enabled in project '{0}'. Running extra resolution pass for module '{1}' using cache location '{2}'." }, + Parse_in_strict_mode_and_emit_use_strict_for_each_source_file: { code: 6141, category: ts.DiagnosticCategory.Message, key: "Parse_in_strict_mode_and_emit_use_strict_for_each_source_file_6141", message: "Parse in strict mode and emit \"use strict\" for each source file" }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter_0_implicitly_has_an_1_type_7006", message: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member_0_implicitly_has_an_1_type_7008", message: "Member '{0}' implicitly has an '{1}' type." }, @@ -2747,6 +2923,7 @@ var ts; Binding_element_0_implicitly_has_an_1_type: { code: 7031, category: ts.DiagnosticCategory.Error, key: "Binding_element_0_implicitly_has_an_1_type_7031", message: "Binding element '{0}' implicitly has an '{1}' type." }, Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation: { code: 7032, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation_7032", message: "Property '{0}' implicitly has type 'any', because its set accessor lacks a parameter type annotation." }, Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation: { code: 7033, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation_7033", message: "Property '{0}' implicitly has type 'any', because its get accessor lacks a return type annotation." }, + Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined: { code: 7034, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined_7034", message: "Variable '{0}' implicitly has type 'any' in some locations where its type cannot be determined." }, You_cannot_rename_this_element: { code: 8000, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_this_element_8000", message: "You cannot rename this element." }, You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", message: "You cannot rename elements that are defined in the standard TypeScript library." }, import_can_only_be_used_in_a_ts_file: { code: 8002, category: ts.DiagnosticCategory.Error, key: "import_can_only_be_used_in_a_ts_file_8002", message: "'import ... =' can only be used in a .ts file." }, @@ -2776,7 +2953,14 @@ var ts; super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class: { code: 17009, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class_17009", message: "'super' must be called before accessing 'this' in the constructor of a derived class." }, Unknown_typing_option_0: { code: 17010, category: ts.DiagnosticCategory.Error, key: "Unknown_typing_option_0_17010", message: "Unknown typing option '{0}'." }, Circularity_detected_while_resolving_configuration_Colon_0: { code: 18000, category: ts.DiagnosticCategory.Error, key: "Circularity_detected_while_resolving_configuration_Colon_0_18000", message: "Circularity detected while resolving configuration: {0}" }, - The_path_in_an_extends_options_must_be_relative_or_rooted: { code: 18001, category: ts.DiagnosticCategory.Error, key: "The_path_in_an_extends_options_must_be_relative_or_rooted_18001", message: "The path in an 'extends' options must be relative or rooted." } + The_path_in_an_extends_options_must_be_relative_or_rooted: { code: 18001, category: ts.DiagnosticCategory.Error, key: "The_path_in_an_extends_options_must_be_relative_or_rooted_18001", message: "The path in an 'extends' options must be relative or rooted." }, + Add_missing_super_call: { code: 90001, category: ts.DiagnosticCategory.Message, key: "Add_missing_super_call_90001", message: "Add missing 'super()' call." }, + Make_super_call_the_first_statement_in_the_constructor: { code: 90002, category: ts.DiagnosticCategory.Message, key: "Make_super_call_the_first_statement_in_the_constructor_90002", message: "Make 'super()' call the first statement in the constructor." }, + Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'" }, + Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers" }, + Implement_interface_on_reference: { code: 90005, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_reference_90005", message: "Implement interface on reference" }, + Implement_interface_on_class: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_class_90006", message: "Implement interface on class" }, + Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" } }; })(ts || (ts = {})); var ts; @@ -3686,7 +3870,7 @@ var ts; return token = 69; } function scanBinaryOrOctalDigits(base) { - ts.Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8"); + ts.Debug.assert(base === 2 || base === 8, "Expected either base 2 or base 8"); var value = 0; var numberOfDigits = 0; while (true) { @@ -4810,10 +4994,10 @@ var ts; return !!(ts.getCombinedNodeFlags(node) & 1); } ts.isLet = isLet; - function isSuperCallExpression(n) { + function isSuperCall(n) { return n.kind === 174 && n.expression.kind === 95; } - ts.isSuperCallExpression = isSuperCallExpression; + ts.isSuperCall = isSuperCall; function isPrologueDirective(node) { return node.kind === 202 && node.expression.kind === 9; } @@ -5061,6 +5245,12 @@ var ts; return node && node.kind === 147 && node.parent.kind === 171; } ts.isObjectLiteralMethod = isObjectLiteralMethod; + function isObjectLiteralOrClassExpressionMethod(node) { + return node.kind === 147 && + (node.parent.kind === 171 || + node.parent.kind === 192); + } + ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { return predicate && predicate.kind === 1; } @@ -5376,10 +5566,6 @@ var ts; return false; } ts.isPartOfExpression = isPartOfExpression; - function isExternalModuleNameRelative(moduleName) { - return /^\.\.?($|[\\/])/.test(moduleName); - } - ts.isExternalModuleNameRelative = isExternalModuleNameRelative; function isInstantiatedModule(node, preserveConstEnums) { var moduleState = ts.getModuleInstanceState(node); return moduleState === 1 || @@ -5977,14 +6163,10 @@ var ts; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { - return positionIsSynthesized(node.pos) - || positionIsSynthesized(node.end); + return ts.positionIsSynthesized(node.pos) + || ts.positionIsSynthesized(node.end); } ts.nodeIsSynthesized = nodeIsSynthesized; - function positionIsSynthesized(pos) { - return !(pos >= 0); - } - ts.positionIsSynthesized = positionIsSynthesized; function getOriginalNode(node) { if (node) { while (node.original !== undefined) { @@ -6420,28 +6602,16 @@ var ts; function getDeclarationEmitOutputFilePath(sourceFile, host) { var options = host.getCompilerOptions(); var outputDir = options.declarationDir || options.outDir; - if (options.declaration) { - var path = outputDir - ? getSourceFilePathInNewDir(sourceFile, host, outputDir) - : sourceFile.fileName; - return ts.removeFileExtension(path) + ".d.ts"; - } + var path = outputDir + ? getSourceFilePathInNewDir(sourceFile, host, outputDir) + : sourceFile.fileName; + return ts.removeFileExtension(path) + ".d.ts"; } ts.getDeclarationEmitOutputFilePath = getDeclarationEmitOutputFilePath; - function getEmitScriptTarget(compilerOptions) { - return compilerOptions.target || 0; - } - ts.getEmitScriptTarget = getEmitScriptTarget; - function getEmitModuleKind(compilerOptions) { - return typeof compilerOptions.module === "number" ? - compilerOptions.module : - getEmitScriptTarget(compilerOptions) === 2 ? ts.ModuleKind.ES6 : ts.ModuleKind.CommonJS; - } - ts.getEmitModuleKind = getEmitModuleKind; function getSourceFilesToEmit(host, targetSourceFile) { var options = host.getCompilerOptions(); if (options.outFile || options.out) { - var moduleKind = getEmitModuleKind(options); + var moduleKind = ts.getEmitModuleKind(options); var moduleEmitEnabled = moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System; var sourceFiles = host.getSourceFiles(); return ts.filter(sourceFiles, moduleEmitEnabled ? isNonDeclarationFile : isBundleEmitNonExternalModule); @@ -6458,7 +6628,7 @@ var ts; function isBundleEmitNonExternalModule(sourceFile) { return !isDeclarationFile(sourceFile) && !ts.isExternalModule(sourceFile); } - function forEachTransformedEmitFile(host, sourceFiles, action) { + function forEachTransformedEmitFile(host, sourceFiles, action, emitOnlyDtsFiles) { var options = host.getCompilerOptions(); if (options.outFile || options.out) { onBundledEmit(host, sourceFiles); @@ -6485,7 +6655,7 @@ var ts; } var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = !isSourceFileJavaScript(sourceFile) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; + var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (options.declaration || emitOnlyDtsFiles) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; action(jsFilePath, sourceMapFilePath, declarationFilePath, [sourceFile], false); } function onBundledEmit(host, sourceFiles) { @@ -6501,7 +6671,7 @@ var ts; function getSourceMapFilePath(jsFilePath, options) { return options.sourceMap ? jsFilePath + ".map" : undefined; } - function forEachExpectedEmitFile(host, action, targetSourceFile) { + function forEachExpectedEmitFile(host, action, targetSourceFile, emitOnlyDtsFiles) { var options = host.getCompilerOptions(); if (options.outFile || options.out) { onBundledEmit(host); @@ -6528,18 +6698,19 @@ var ts; } } var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); + var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (emitOnlyDtsFiles || options.declaration) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; var emitFileNames = { jsFilePath: jsFilePath, sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), - declarationFilePath: !isSourceFileJavaScript(sourceFile) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined + declarationFilePath: declarationFilePath }; - action(emitFileNames, [sourceFile], false); + action(emitFileNames, [sourceFile], false, emitOnlyDtsFiles); } function onBundledEmit(host) { var bundledSources = ts.filter(host.getSourceFiles(), function (sourceFile) { return !isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile) && (!ts.isExternalModule(sourceFile) || - !!getEmitModuleKind(options)); }); + !!ts.getEmitModuleKind(options)); }); if (bundledSources.length) { var jsFilePath = options.outFile || options.out; var emitFileNames = { @@ -6547,7 +6718,7 @@ var ts; sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), declarationFilePath: options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined }; - action(emitFileNames, bundledSources, true); + action(emitFileNames, bundledSources, true, emitOnlyDtsFiles); } } } @@ -6584,13 +6755,32 @@ var ts; ts.getFirstConstructorWithBody = getFirstConstructorWithBody; function getSetAccessorTypeAnnotationNode(accessor) { if (accessor && accessor.parameters.length > 0) { - var hasThis = accessor.parameters.length === 2 && - accessor.parameters[0].name.kind === 69 && - accessor.parameters[0].name.originalKeywordKind === 97; + var hasThis = accessor.parameters.length === 2 && parameterIsThisKeyword(accessor.parameters[0]); return accessor.parameters[hasThis ? 1 : 0].type; } } ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode; + function getThisParameter(signature) { + if (signature.parameters.length) { + var thisParameter = signature.parameters[0]; + if (parameterIsThisKeyword(thisParameter)) { + return thisParameter; + } + } + } + ts.getThisParameter = getThisParameter; + function parameterIsThisKeyword(parameter) { + return isThisIdentifier(parameter.name); + } + ts.parameterIsThisKeyword = parameterIsThisKeyword; + function isThisIdentifier(node) { + return node && node.kind === 69 && identifierIsThisKeyword(node); + } + ts.isThisIdentifier = isThisIdentifier; + function identifierIsThisKeyword(id) { + return id.originalKeywordKind === 97; + } + ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { var firstAccessor; var secondAccessor; @@ -6904,14 +7094,6 @@ var ts; return symbol && symbol.valueDeclaration && hasModifier(symbol.valueDeclaration, 512) ? symbol.valueDeclaration.localSymbol : undefined; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; - function hasJavaScriptFileExtension(fileName) { - return ts.forEach(ts.supportedJavascriptExtensions, function (extension) { return ts.fileExtensionIs(fileName, extension); }); - } - ts.hasJavaScriptFileExtension = hasJavaScriptFileExtension; - function hasTypeScriptFileExtension(fileName) { - return ts.forEach(ts.supportedTypeScriptExtensions, function (extension) { return ts.fileExtensionIs(fileName, extension); }); - } - ts.hasTypeScriptFileExtension = hasTypeScriptFileExtension; function tryExtractTypeScriptExtension(fileName) { return ts.find(ts.supportedTypescriptExtensionsForExtractExtension, function (extension) { return ts.fileExtensionIs(fileName, extension); }); } @@ -7002,12 +7184,6 @@ var ts; return result; } ts.convertToBase64 = convertToBase64; - function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) { - return !ts.isRootedDiskPath(absoluteOrRelativePath) - ? absoluteOrRelativePath - : ts.getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, false); - } - ts.convertToRelativePath = convertToRelativePath; var carriageReturnLineFeed = "\r\n"; var lineFeed = "\n"; function getNewLineCharacter(options) { @@ -7108,7 +7284,7 @@ var ts; } ts.formatSyntaxKind = formatSyntaxKind; function movePos(pos, value) { - return positionIsSynthesized(pos) ? -1 : pos + value; + return ts.positionIsSynthesized(pos) ? -1 : pos + value; } ts.movePos = movePos; function createRange(pos, end) { @@ -7177,7 +7353,7 @@ var ts; } ts.positionsAreOnSameLine = positionsAreOnSameLine; function getStartPositionOfRange(range, sourceFile) { - return positionIsSynthesized(range.pos) ? -1 : ts.skipTrivia(sourceFile.text, range.pos); + return ts.positionIsSynthesized(range.pos) ? -1 : ts.skipTrivia(sourceFile.text, range.pos); } ts.getStartPositionOfRange = getStartPositionOfRange; function collectExternalModuleInfo(sourceFile, resolver) { @@ -7277,15 +7453,16 @@ var ts; return 11 <= kind && kind <= 14; } ts.isTemplateLiteralKind = isTemplateLiteralKind; - function isTemplateLiteralFragmentKind(kind) { - return kind === 12 - || kind === 13 + function isTemplateHead(node) { + return node.kind === 12; + } + ts.isTemplateHead = isTemplateHead; + function isTemplateMiddleOrTemplateTail(node) { + var kind = node.kind; + return kind === 13 || kind === 14; } - function isTemplateLiteralFragment(node) { - return isTemplateLiteralFragmentKind(node.kind); - } - ts.isTemplateLiteralFragment = isTemplateLiteralFragment; + ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; function isIdentifier(node) { return node.kind === 69; } @@ -7424,12 +7601,12 @@ var ts; return node.kind === 174; } ts.isCallExpression = isCallExpression; - function isTemplate(node) { + function isTemplateLiteral(node) { var kind = node.kind; return kind === 189 || kind === 11; } - ts.isTemplate = isTemplate; + ts.isTemplateLiteral = isTemplateLiteral; function isSpreadElementExpression(node) { return node.kind === 191; } @@ -7995,7 +8172,7 @@ var ts; ts.createSynthesizedNodeArray = createSynthesizedNodeArray; function getSynthesizedClone(node) { var clone = createNode(node.kind, undefined, node.flags); - clone.original = node; + setOriginalNode(clone, node); for (var key in node) { if (clone.hasOwnProperty(key) || !node.hasOwnProperty(key)) { continue; @@ -8027,7 +8204,7 @@ var ts; node.text = value; return node; } - else { + else if (value) { var node = createNode(9, location, undefined); node.textSourceNode = value; node.text = value.text; @@ -8314,7 +8491,7 @@ var ts; function createPropertyAccess(expression, name, location, flags) { var node = createNode(172, location, flags); node.expression = parenthesizeForAccess(expression); - node.emitFlags = 1048576; + (node.emitNode || (node.emitNode = {})).flags |= 1048576; node.name = typeof name === "string" ? createIdentifier(name) : name; return node; } @@ -8322,7 +8499,7 @@ var ts; function updatePropertyAccess(node, expression, name) { if (node.expression !== expression || node.name !== name) { var propertyAccess = createPropertyAccess(expression, name, node, node.flags); - propertyAccess.emitFlags = node.emitFlags; + (propertyAccess.emitNode || (propertyAccess.emitNode = {})).flags = getEmitFlags(node); return updateNode(propertyAccess, node); } return node; @@ -8426,7 +8603,7 @@ var ts; node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; node.parameters = createNodeArray(parameters); node.type = type; - node.equalsGreaterThanToken = equalsGreaterThanToken || createNode(34); + node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(34); node.body = parenthesizeConciseBody(body); return node; } @@ -8519,7 +8696,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right, location) { - var operatorToken = typeof operator === "number" ? createSynthesizedNode(operator) : operator; + var operatorToken = typeof operator === "number" ? createToken(operator) : operator; var operatorKind = operatorToken.kind; var node = createNode(187, location); node.left = parenthesizeBinaryOperand(operatorKind, left, true, undefined); @@ -9419,13 +9596,13 @@ var ts; } else { var expression = ts.isIdentifier(memberName) ? createPropertyAccess(target, memberName, location) : createElementAccess(target, memberName, location); - expression.emitFlags |= 2048; + (expression.emitNode || (expression.emitNode = {})).flags |= 2048; return expression; } } ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName; function createRestParameter(name) { - return createParameterDeclaration(undefined, undefined, createSynthesizedNode(22), name, undefined, undefined, undefined); + return createParameterDeclaration(undefined, undefined, createToken(22), name, undefined, undefined, undefined); } ts.createRestParameter = createRestParameter; function createFunctionCall(func, thisArg, argumentsList, location) { @@ -9539,8 +9716,8 @@ var ts; } ts.createDecorateHelper = createDecorateHelper; function createAwaiterHelper(externalHelpersModuleName, hasLexicalArguments, promiseConstructor, body) { - var generatorFunc = createFunctionExpression(createNode(37), undefined, undefined, [], undefined, body); - generatorFunc.emitFlags |= 2097152; + var generatorFunc = createFunctionExpression(createToken(37), undefined, undefined, [], undefined, body); + (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 2097152; return createCall(createHelperName(externalHelpersModuleName, "__awaiter"), undefined, [ createThis(), hasLexicalArguments ? createIdentifier("arguments") : createVoidZero(), @@ -9767,7 +9944,7 @@ var ts; target.push(startOnNewLine(createStatement(createLiteral("use strict")))); foundUseStrict = true; } - if (statement.emitFlags & 8388608) { + if (getEmitFlags(statement) & 8388608) { target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); } else { @@ -9779,6 +9956,28 @@ var ts; return statementOffset; } ts.addPrologueDirectives = addPrologueDirectives; + function ensureUseStrict(node) { + var foundUseStrict = false; + for (var _i = 0, _a = node.statements; _i < _a.length; _i++) { + var statement = _a[_i]; + if (ts.isPrologueDirective(statement)) { + if (isUseStrictPrologue(statement)) { + foundUseStrict = true; + break; + } + } + else { + break; + } + } + if (!foundUseStrict) { + var statements = []; + statements.push(startOnNewLine(createStatement(createLiteral("use strict")))); + return updateSourceFileNode(node, statements.concat(node.statements)); + } + return node; + } + ts.ensureUseStrict = ensureUseStrict; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = skipPartiallyEmittedExpressions(operand); if (skipped.kind === 178) { @@ -10018,17 +10217,112 @@ var ts; function setOriginalNode(node, original) { node.original = original; if (original) { - var emitFlags = original.emitFlags, commentRange = original.commentRange, sourceMapRange = original.sourceMapRange; - if (emitFlags) - node.emitFlags = emitFlags; - if (commentRange) - node.commentRange = commentRange; - if (sourceMapRange) - node.sourceMapRange = sourceMapRange; + var emitNode = original.emitNode; + if (emitNode) + node.emitNode = mergeEmitNode(emitNode, node.emitNode); } return node; } ts.setOriginalNode = setOriginalNode; + function mergeEmitNode(sourceEmitNode, destEmitNode) { + var flags = sourceEmitNode.flags, commentRange = sourceEmitNode.commentRange, sourceMapRange = sourceEmitNode.sourceMapRange, tokenSourceMapRanges = sourceEmitNode.tokenSourceMapRanges; + if (!destEmitNode && (flags || commentRange || sourceMapRange || tokenSourceMapRanges)) + destEmitNode = {}; + if (flags) + destEmitNode.flags = flags; + if (commentRange) + destEmitNode.commentRange = commentRange; + if (sourceMapRange) + destEmitNode.sourceMapRange = sourceMapRange; + if (tokenSourceMapRanges) + destEmitNode.tokenSourceMapRanges = mergeTokenSourceMapRanges(tokenSourceMapRanges, destEmitNode.tokenSourceMapRanges); + return destEmitNode; + } + function mergeTokenSourceMapRanges(sourceRanges, destRanges) { + if (!destRanges) + destRanges = ts.createMap(); + ts.copyProperties(sourceRanges, destRanges); + return destRanges; + } + function disposeEmitNodes(sourceFile) { + sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(sourceFile)); + var emitNode = sourceFile && sourceFile.emitNode; + var annotatedNodes = emitNode && emitNode.annotatedNodes; + if (annotatedNodes) { + for (var _i = 0, annotatedNodes_1 = annotatedNodes; _i < annotatedNodes_1.length; _i++) { + var node = annotatedNodes_1[_i]; + node.emitNode = undefined; + } + } + } + ts.disposeEmitNodes = disposeEmitNodes; + function getOrCreateEmitNode(node) { + if (!node.emitNode) { + if (ts.isParseTreeNode(node)) { + if (node.kind === 256) { + return node.emitNode = { annotatedNodes: [node] }; + } + var sourceFile = ts.getSourceFileOfNode(node); + getOrCreateEmitNode(sourceFile).annotatedNodes.push(node); + } + node.emitNode = {}; + } + return node.emitNode; + } + function getEmitFlags(node) { + var emitNode = node.emitNode; + return emitNode && emitNode.flags; + } + ts.getEmitFlags = getEmitFlags; + function setEmitFlags(node, emitFlags) { + getOrCreateEmitNode(node).flags = emitFlags; + return node; + } + ts.setEmitFlags = setEmitFlags; + function setSourceMapRange(node, range) { + getOrCreateEmitNode(node).sourceMapRange = range; + return node; + } + ts.setSourceMapRange = setSourceMapRange; + function setTokenSourceMapRange(node, token, range) { + var emitNode = getOrCreateEmitNode(node); + var tokenSourceMapRanges = emitNode.tokenSourceMapRanges || (emitNode.tokenSourceMapRanges = ts.createMap()); + tokenSourceMapRanges[token] = range; + return node; + } + ts.setTokenSourceMapRange = setTokenSourceMapRange; + function setCommentRange(node, range) { + getOrCreateEmitNode(node).commentRange = range; + return node; + } + ts.setCommentRange = setCommentRange; + function getCommentRange(node) { + var emitNode = node.emitNode; + return (emitNode && emitNode.commentRange) || node; + } + ts.getCommentRange = getCommentRange; + function getSourceMapRange(node) { + var emitNode = node.emitNode; + return (emitNode && emitNode.sourceMapRange) || node; + } + ts.getSourceMapRange = getSourceMapRange; + function getTokenSourceMapRange(node, token) { + var emitNode = node.emitNode; + var tokenSourceMapRanges = emitNode && emitNode.tokenSourceMapRanges; + return tokenSourceMapRanges && tokenSourceMapRanges[token]; + } + ts.getTokenSourceMapRange = getTokenSourceMapRange; + function getConstantValue(node) { + var emitNode = node.emitNode; + return emitNode && emitNode.constantValue; + } + ts.getConstantValue = getConstantValue; + function setConstantValue(node, value) { + var emitNode = getOrCreateEmitNode(node); + emitNode.constantValue = value; + return node; + } + ts.setConstantValue = setConstantValue; function setTextRange(node, location) { if (location) { node.pos = location.pos; @@ -11138,7 +11432,7 @@ var ts; case 16: return token() === 18 || token() === 20; case 18: - return token() === 27 || token() === 17; + return token() !== 24; case 20: return token() === 15 || token() === 16; case 13: @@ -11466,7 +11760,7 @@ var ts; } function parseTemplateExpression() { var template = createNode(189); - template.head = parseTemplateLiteralFragment(); + template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 12, "Template head has wrong token kind"); var templateSpans = createNodeArray(); do { @@ -11482,7 +11776,7 @@ var ts; var literal; if (token() === 16) { reScanTemplateToken(); - literal = parseTemplateLiteralFragment(); + literal = parseTemplateMiddleOrTemplateTail(); } else { literal = parseExpectedToken(14, false, ts.Diagnostics._0_expected, ts.tokenToString(16)); @@ -11493,8 +11787,15 @@ var ts; function parseLiteralNode(internName) { return parseLiteralLikeNode(token(), internName); } - function parseTemplateLiteralFragment() { - return parseLiteralLikeNode(token(), false); + function parseTemplateHead() { + var fragment = parseLiteralLikeNode(token(), false); + ts.Debug.assert(fragment.kind === 12, "Template head has wrong token kind"); + return fragment; + } + function parseTemplateMiddleOrTemplateTail() { + var fragment = parseLiteralLikeNode(token(), false); + ts.Debug.assert(fragment.kind === 13 || fragment.kind === 14, "Template fragment has wrong token kind"); + return fragment; } function parseLiteralLikeNode(kind, internName) { var node = createNode(kind); @@ -13842,7 +14143,7 @@ var ts; parseExpected(56); node.type = parseType(); parseSemicolon(); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseEnumMember() { var node = createNode(255, scanner.getStartPos()); @@ -15277,7 +15578,7 @@ var ts; file = f; options = opts; languageVersion = ts.getEmitScriptTarget(options); - inStrictMode = !!file.externalModuleIndicator; + inStrictMode = bindInStrictMode(file, opts); classifiableNames = ts.createMap(); symbolCount = 0; skipTransformFlagAggregation = ts.isDeclarationFile(file); @@ -15307,6 +15608,14 @@ var ts; subtreeTransformFlags = 0; } return bindSourceFile; + function bindInStrictMode(file, opts) { + if (opts.alwaysStrict && !ts.isDeclarationFile(file)) { + return true; + } + else { + return !!file.externalModuleIndicator; + } + } function createSymbol(flags, name) { symbolCount++; return new Symbol(flags, name); @@ -15425,11 +15734,17 @@ var ts; var message_1 = symbol.flags & 2 ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; - ts.forEach(symbol.declarations, function (declaration) { - if (ts.hasModifier(declaration, 512)) { + if (symbol.declarations && symbol.declarations.length) { + if (isDefaultExport) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } - }); + else { + if (symbol.declarations && symbol.declarations.length && + (isDefaultExport || (node.kind === 235 && !node.isExportEquals))) { + message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; + } + } + } ts.forEach(symbol.declarations, function (declaration) { file.bindDiagnostics.push(ts.createDiagnosticForNode(declaration.name || declaration, message_1, getDisplayName(declaration))); }); @@ -15494,7 +15809,7 @@ var ts; } else { currentFlow = { flags: 2 }; - if (containerFlags & 16) { + if (containerFlags & (16 | 128)) { currentFlow.container = node; } currentReturnTarget = undefined; @@ -15949,7 +16264,9 @@ var ts; currentFlow = preTryFlow; bind(node.finallyBlock); } - currentFlow = finishFlowLabel(postFinallyLabel); + if (!node.finallyBlock || !(currentFlow.flags & 1)) { + currentFlow = finishFlowLabel(postFinallyLabel); + } } function bindSwitchStatement(node) { var postSwitchLabel = createBranchLabel(); @@ -16082,7 +16399,7 @@ var ts; } else { ts.forEachChild(node, bind); - if (node.operator === 57 || node.operator === 42) { + if (node.operator === 41 || node.operator === 42) { bindAssignmentTargetFlow(node.operand); } } @@ -16181,9 +16498,12 @@ var ts; return 1 | 32; case 256: return 1 | 4 | 32; + case 147: + if (ts.isObjectLiteralOrClassExpressionMethod(node)) { + return 1 | 4 | 32 | 8 | 128; + } case 148: case 220: - case 147: case 146: case 149: case 150: @@ -16715,7 +17035,7 @@ var ts; var flags = node.kind === 235 && ts.exportAssignmentIsAlias(node) ? 8388608 : 4; - declareSymbol(container.symbol.exports, container.symbol, node, flags, 0 | 8388608); + declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 | 8388608 | 32 | 16); } } function bindNamespaceExportDeclaration(node) { @@ -16912,6 +17232,9 @@ var ts; emitFlags |= 2048; } } + if (currentFlow && ts.isObjectLiteralOrClassExpressionMethod(node)) { + node.flowNode = currentFlow; + } return ts.hasDynamicName(node) ? bindAnonymousDeclaration(node, symbolFlags, "__computed") : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); @@ -17050,8 +17373,7 @@ var ts; if (node.questionToken) { transformFlags |= 3; } - if (subtreeFlags & 2048 - || (name && ts.isIdentifier(name) && name.originalKeywordKind === 97)) { + if (subtreeFlags & 2048 || ts.isThisIdentifier(name)) { transformFlags |= 3; } if (modifierFlags & 92) { @@ -17153,7 +17475,7 @@ var ts; || (subtreeFlags & 2048)) { transformFlags |= 3; } - if (asteriskToken && node.emitFlags & 2097152) { + if (asteriskToken && ts.getEmitFlags(node) & 2097152) { transformFlags |= 1536; } node.transformFlags = transformFlags | 536870912; @@ -17198,7 +17520,7 @@ var ts; if (subtreeFlags & 81920) { transformFlags |= 192; } - if (asteriskToken && node.emitFlags & 2097152) { + if (asteriskToken && ts.getEmitFlags(node) & 2097152) { transformFlags |= 1536; } } @@ -17215,7 +17537,7 @@ var ts; if (subtreeFlags & 81920) { transformFlags |= 192; } - if (asteriskToken && node.emitFlags & 2097152) { + if (asteriskToken && ts.getEmitFlags(node) & 2097152) { transformFlags |= 1536; } node.transformFlags = transformFlags | 536870912; @@ -17456,6 +17778,560 @@ var ts; } })(ts || (ts = {})); var ts; +(function (ts) { + function trace(host, message) { + host.trace(ts.formatMessage.apply(undefined, arguments)); + } + ts.trace = trace; + function isTraceEnabled(compilerOptions, host) { + return compilerOptions.traceResolution && host.trace !== undefined; + } + ts.isTraceEnabled = isTraceEnabled; + function createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations) { + return { resolvedModule: resolvedFileName ? { resolvedFileName: resolvedFileName, isExternalLibraryImport: isExternalLibraryImport } : undefined, failedLookupLocations: failedLookupLocations }; + } + ts.createResolvedModule = createResolvedModule; + function moduleHasNonRelativeName(moduleName) { + return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); + } + function tryReadTypesSection(packageJsonPath, baseDirectory, state) { + var jsonContent = readJson(packageJsonPath, state.host); + function tryReadFromField(fieldName) { + if (ts.hasProperty(jsonContent, fieldName)) { + var typesFile = jsonContent[fieldName]; + if (typeof typesFile === "string") { + var typesFilePath_1 = ts.normalizePath(ts.combinePaths(baseDirectory, typesFile)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath_1); + } + return typesFilePath_1; + } + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof typesFile); + } + } + } + } + var typesFilePath = tryReadFromField("typings") || tryReadFromField("types"); + if (typesFilePath) { + return typesFilePath; + } + if (state.compilerOptions.allowJs && jsonContent.main && typeof jsonContent.main === "string") { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0, jsonContent.main); + } + var mainFilePath = ts.normalizePath(ts.combinePaths(baseDirectory, jsonContent.main)); + return mainFilePath; + } + return undefined; + } + function readJson(path, host) { + try { + var jsonText = host.readFile(path); + return jsonText ? JSON.parse(jsonText) : {}; + } + catch (e) { + return {}; + } + } + var typeReferenceExtensions = [".d.ts"]; + function getEffectiveTypeRoots(options, host) { + if (options.typeRoots) { + return options.typeRoots; + } + var currentDirectory; + if (options.configFilePath) { + currentDirectory = ts.getDirectoryPath(options.configFilePath); + } + else if (host.getCurrentDirectory) { + currentDirectory = host.getCurrentDirectory(); + } + return currentDirectory !== undefined && getDefaultTypeRoots(currentDirectory, host); + } + ts.getEffectiveTypeRoots = getEffectiveTypeRoots; + function getDefaultTypeRoots(currentDirectory, host) { + if (!host.directoryExists) { + return [ts.combinePaths(currentDirectory, nodeModulesAtTypes)]; + } + var typeRoots; + while (true) { + var atTypes = ts.combinePaths(currentDirectory, nodeModulesAtTypes); + if (host.directoryExists(atTypes)) { + (typeRoots || (typeRoots = [])).push(atTypes); + } + var parent_7 = ts.getDirectoryPath(currentDirectory); + if (parent_7 === currentDirectory) { + break; + } + currentDirectory = parent_7; + } + return typeRoots; + } + var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types"); + function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host) { + var traceEnabled = isTraceEnabled(options, host); + var moduleResolutionState = { + compilerOptions: options, + host: host, + skipTsx: true, + traceEnabled: traceEnabled + }; + var typeRoots = getEffectiveTypeRoots(options, host); + if (traceEnabled) { + if (containingFile === undefined) { + if (typeRoots === undefined) { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set, typeReferenceDirectiveName); + } + else { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1, typeReferenceDirectiveName, typeRoots); + } + } + else { + if (typeRoots === undefined) { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set, typeReferenceDirectiveName, containingFile); + } + else { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, typeRoots); + } + } + } + var failedLookupLocations = []; + if (typeRoots && typeRoots.length) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", ")); + } + var primarySearchPaths = typeRoots; + for (var _i = 0, primarySearchPaths_1 = primarySearchPaths; _i < primarySearchPaths_1.length; _i++) { + var typeRoot = primarySearchPaths_1[_i]; + var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); + var candidateDirectory = ts.getDirectoryPath(candidate); + var resolvedFile_1 = loadNodeModuleFromDirectory(typeReferenceExtensions, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState); + if (resolvedFile_1) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile_1, true); + } + return { + resolvedTypeReferenceDirective: { primary: true, resolvedFileName: resolvedFile_1 }, + failedLookupLocations: failedLookupLocations + }; + } + } + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths); + } + } + var resolvedFile; + var initialLocationForSecondaryLookup; + if (containingFile) { + initialLocationForSecondaryLookup = ts.getDirectoryPath(containingFile); + } + if (initialLocationForSecondaryLookup !== undefined) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); + } + resolvedFile = loadModuleFromNodeModules(typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, false); + if (traceEnabled) { + if (resolvedFile) { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile, false); + } + else { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); + } + } + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder); + } + } + return { + resolvedTypeReferenceDirective: resolvedFile + ? { primary: false, resolvedFileName: resolvedFile } + : undefined, + failedLookupLocations: failedLookupLocations + }; + } + ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective; + function getAutomaticTypeDirectiveNames(options, host) { + if (options.types) { + return options.types; + } + var result = []; + if (host.directoryExists && host.getDirectories) { + var typeRoots = getEffectiveTypeRoots(options, host); + if (typeRoots) { + for (var _i = 0, typeRoots_1 = typeRoots; _i < typeRoots_1.length; _i++) { + var root = typeRoots_1[_i]; + if (host.directoryExists(root)) { + for (var _a = 0, _b = host.getDirectories(root); _a < _b.length; _a++) { + var typeDirectivePath = _b[_a]; + var normalized = ts.normalizePath(typeDirectivePath); + var packageJsonPath = pathToPackageJson(ts.combinePaths(root, normalized)); + var isNotNeededPackage = host.fileExists(packageJsonPath) && readJson(packageJsonPath, host).typings === null; + if (!isNotNeededPackage) { + result.push(ts.getBaseFileName(normalized)); + } + } + } + } + } + } + return result; + } + ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; + function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + var traceEnabled = isTraceEnabled(compilerOptions, host); + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); + } + var moduleResolution = compilerOptions.moduleResolution; + if (moduleResolution === undefined) { + moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + if (traceEnabled) { + trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + var result; + switch (moduleResolution) { + case ts.ModuleResolutionKind.NodeJs: + result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host); + break; + case ts.ModuleResolutionKind.Classic: + result = classicNameResolver(moduleName, containingFile, compilerOptions, host); + break; + } + if (traceEnabled) { + if (result.resolvedModule) { + trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.resolvedModule.resolvedFileName); + } + else { + trace(host, ts.Diagnostics.Module_name_0_was_not_resolved, moduleName); + } + } + return result; + } + ts.resolveModuleName = resolveModuleName; + function tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { + if (moduleHasNonRelativeName(moduleName)) { + return tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state); + } + else { + return tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state); + } + } + function tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { + if (!state.compilerOptions.rootDirs) { + return undefined; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0, moduleName); + } + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var matchedRootDir; + var matchedNormalizedPrefix; + for (var _i = 0, _a = state.compilerOptions.rootDirs; _i < _a.length; _i++) { + var rootDir = _a[_i]; + var normalizedRoot = ts.normalizePath(rootDir); + if (!ts.endsWith(normalizedRoot, ts.directorySeparator)) { + normalizedRoot += ts.directorySeparator; + } + var isLongestMatchingPrefix = ts.startsWith(candidate, normalizedRoot) && + (matchedNormalizedPrefix === undefined || matchedNormalizedPrefix.length < normalizedRoot.length); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Checking_if_0_is_the_longest_matching_prefix_for_1_2, normalizedRoot, candidate, isLongestMatchingPrefix); + } + if (isLongestMatchingPrefix) { + matchedNormalizedPrefix = normalizedRoot; + matchedRootDir = rootDir; + } + } + if (matchedNormalizedPrefix) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Longest_matching_prefix_for_0_is_1, candidate, matchedNormalizedPrefix); + } + var suffix = candidate.substr(matchedNormalizedPrefix.length); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, matchedNormalizedPrefix, candidate); + } + var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(containingDirectory, state.host), state); + if (resolvedFileName) { + return resolvedFileName; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Trying_other_entries_in_rootDirs); + } + for (var _b = 0, _c = state.compilerOptions.rootDirs; _b < _c.length; _b++) { + var rootDir = _c[_b]; + if (rootDir === matchedRootDir) { + continue; + } + var candidate_1 = ts.combinePaths(ts.normalizePath(rootDir), suffix); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, rootDir, candidate_1); + } + var baseDirectory = ts.getDirectoryPath(candidate_1); + var resolvedFileName_1 = loader(candidate_1, supportedExtensions, failedLookupLocations, !directoryProbablyExists(baseDirectory, state.host), state); + if (resolvedFileName_1) { + return resolvedFileName_1; + } + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Module_resolution_using_rootDirs_has_failed); + } + } + return undefined; + } + function tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state) { + if (!state.compilerOptions.baseUrl) { + return undefined; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, state.compilerOptions.baseUrl, moduleName); + } + var matchedPattern = undefined; + if (state.compilerOptions.paths) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); + } + matchedPattern = ts.matchPatternOrExact(ts.getOwnKeys(state.compilerOptions.paths), moduleName); + } + if (matchedPattern) { + var matchedStar = typeof matchedPattern === "string" ? undefined : ts.matchedText(matchedPattern, moduleName); + var matchedPatternText = typeof matchedPattern === "string" ? matchedPattern : ts.patternText(matchedPattern); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPatternText); + } + for (var _i = 0, _a = state.compilerOptions.paths[matchedPatternText]; _i < _a.length; _i++) { + var subst = _a[_i]; + var path = matchedStar ? subst.replace("*", matchedStar) : subst; + var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, path)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path); + } + var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + if (resolvedFileName) { + return resolvedFileName; + } + } + return undefined; + } + else { + var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, moduleName)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Resolving_module_name_0_relative_to_base_url_1_2, moduleName, state.compilerOptions.baseUrl, candidate); + } + return loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + } + } + function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host) { + var containingDirectory = ts.getDirectoryPath(containingFile); + var supportedExtensions = ts.getSupportedExtensions(compilerOptions); + var traceEnabled = isTraceEnabled(compilerOptions, host); + var failedLookupLocations = []; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: false }; + var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, supportedExtensions, state); + var isExternalLibraryImport = false; + if (!resolvedFileName) { + if (moduleHasNonRelativeName(moduleName)) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder, moduleName); + } + resolvedFileName = loadModuleFromNodeModules(moduleName, containingDirectory, failedLookupLocations, state, false); + isExternalLibraryImport = resolvedFileName !== undefined; + } + else { + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + resolvedFileName = nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, false, state); + } + } + if (resolvedFileName && host.realpath) { + var originalFileName = resolvedFileName; + resolvedFileName = ts.normalizePath(host.realpath(resolvedFileName)); + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, originalFileName, resolvedFileName); + } + } + return createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations); + } + ts.nodeModuleNameResolver = nodeModuleNameResolver; + function nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate); + } + var resolvedFileName = !ts.pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state); + return resolvedFileName || loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, onlyRecordFailures, state); + } + function directoryProbablyExists(directoryName, host) { + return !host.directoryExists || host.directoryExists(directoryName); + } + ts.directoryProbablyExists = directoryProbablyExists; + function loadModuleFromFile(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) { + var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state); + if (resolvedByAddingExtension) { + return resolvedByAddingExtension; + } + if (ts.hasJavaScriptFileExtension(candidate)) { + var extensionless = ts.removeFileExtension(candidate); + if (state.traceEnabled) { + var extension = candidate.substring(extensionless.length); + trace(state.host, ts.Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension); + } + return tryAddingExtensions(extensionless, extensions, failedLookupLocation, onlyRecordFailures, state); + } + } + function tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) { + if (!onlyRecordFailures) { + var directory = ts.getDirectoryPath(candidate); + if (directory) { + onlyRecordFailures = !directoryProbablyExists(directory, state.host); + } + } + return ts.forEach(extensions, function (ext) { + return !(state.skipTsx && ts.isJsxOrTsxExtension(ext)) && tryFile(candidate + ext, failedLookupLocation, onlyRecordFailures, state); + }); + } + function tryFile(fileName, failedLookupLocation, onlyRecordFailures, state) { + if (!onlyRecordFailures && state.host.fileExists(fileName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); + } + return fileName; + } + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); + } + failedLookupLocation.push(fileName); + return undefined; + } + } + function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocation, onlyRecordFailures, state) { + var packageJsonPath = pathToPackageJson(candidate); + var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); + if (directoryExists && state.host.fileExists(packageJsonPath)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); + } + var typesFile = tryReadTypesSection(packageJsonPath, candidate, state); + if (typesFile) { + var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(typesFile), state.host); + var result = tryFile(typesFile, failedLookupLocation, onlyRecordFailures_1, state) || + tryAddingExtensions(typesFile, extensions, failedLookupLocation, onlyRecordFailures_1, state); + if (result) { + return result; + } + } + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_does_not_have_types_field); + } + } + } + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); + } + failedLookupLocation.push(packageJsonPath); + } + return loadModuleFromFile(ts.combinePaths(candidate, "index"), extensions, failedLookupLocation, !directoryExists, state); + } + function pathToPackageJson(directory) { + return ts.combinePaths(directory, "package.json"); + } + function loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state) { + var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); + var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); + var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); + var supportedExtensions = ts.getSupportedExtensions(state.compilerOptions); + var result = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, !nodeModulesFolderExists, state); + if (result) { + return result; + } + result = loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); + if (result) { + return result; + } + } + function loadModuleFromNodeModules(moduleName, directory, failedLookupLocations, state, checkOneLevel) { + return loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, checkOneLevel, false); + } + ts.loadModuleFromNodeModules = loadModuleFromNodeModules; + function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) { + return loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, false, true); + } + function loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, checkOneLevel, typesOnly) { + directory = ts.normalizeSlashes(directory); + while (true) { + var baseName = ts.getBaseFileName(directory); + if (baseName !== "node_modules") { + var packageResult = void 0; + if (!typesOnly) { + packageResult = loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state); + if (packageResult && ts.hasTypeScriptFileExtension(packageResult)) { + return packageResult; + } + } + var typesResult = loadModuleFromNodeModulesFolder(ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); + if (typesResult || packageResult) { + return typesResult || packageResult; + } + } + var parentPath = ts.getDirectoryPath(directory); + if (parentPath === directory || checkOneLevel) { + break; + } + directory = parentPath; + } + return undefined; + } + function classicNameResolver(moduleName, containingFile, compilerOptions, host) { + var traceEnabled = isTraceEnabled(compilerOptions, host); + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: !compilerOptions.jsx }; + var failedLookupLocations = []; + var supportedExtensions = ts.getSupportedExtensions(compilerOptions); + var containingDirectory = ts.getDirectoryPath(containingFile); + var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, supportedExtensions, state); + if (resolvedFileName) { + return createResolvedModule(resolvedFileName, false, failedLookupLocations); + } + var referencedSourceFile; + if (moduleHasNonRelativeName(moduleName)) { + referencedSourceFile = referencedSourceFile = loadModuleFromAncestorDirectories(moduleName, containingDirectory, supportedExtensions, failedLookupLocations, state) || + loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); + } + else { + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + referencedSourceFile = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, false, state); + } + return referencedSourceFile + ? { resolvedModule: { resolvedFileName: referencedSourceFile }, failedLookupLocations: failedLookupLocations } + : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; + } + ts.classicNameResolver = classicNameResolver; + function loadModuleFromAncestorDirectories(moduleName, containingDirectory, supportedExtensions, failedLookupLocations, state) { + while (true) { + var searchName = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var referencedSourceFile = loadModuleFromFile(searchName, supportedExtensions, failedLookupLocations, false, state); + if (referencedSourceFile) { + return referencedSourceFile; + } + var parentPath = ts.getDirectoryPath(containingDirectory); + if (parentPath === containingDirectory) { + return undefined; + } + containingDirectory = parentPath; + } + } +})(ts || (ts = {})); +var ts; (function (ts) { var ambientModuleSymbolRegex = /^".+"$/; var nextSymbolId = 1; @@ -17551,6 +18427,7 @@ var ts; var unknownSymbol = createSymbol(4 | 67108864, "unknown"); var resolvingSymbol = createSymbol(67108864, "__resolving__"); var anyType = createIntrinsicType(1, "any"); + var autoType = createIntrinsicType(1, "any"); var unknownType = createIntrinsicType(1, "unknown"); var undefinedType = createIntrinsicType(2048, "undefined"); var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(2048 | 33554432, "undefined"); @@ -18108,7 +18985,7 @@ var ts; if (result && isInExternalModule && (meaning & 107455) === 107455) { var decls = result.declarations; if (decls && decls.length === 1 && decls[0].kind === 228) { - error(errorLocation, ts.Diagnostics.Identifier_0_must_be_imported_from_a_module, name); + error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } } @@ -18526,6 +19403,7 @@ var ts; } function getExportsForModule(moduleSymbol) { var visitedSymbols = []; + moduleSymbol = resolveExternalModuleSymbol(moduleSymbol); return visit(moduleSymbol) || moduleSymbol.exports; function visit(symbol) { if (!(symbol && symbol.flags & 1952 && !ts.contains(visitedSymbols, symbol))) { @@ -19010,9 +19888,9 @@ var ts; var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & 2)); if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { - var parent_7 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); - if (parent_7) { - walkSymbol(parent_7, getQualifiedLeftMeaning(meaning), false); + var parent_8 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent_8) { + walkSymbol(parent_8, getQualifiedLeftMeaning(meaning), false); } } if (accessibleSymbolChain) { @@ -19047,7 +19925,7 @@ var ts; ? "any" : type.intrinsicName); } - else if (type.flags & 268435456) { + else if (type.flags & 16384 && type.isThisType) { if (inObjectTypeLiteral) { writer.reportInaccessibleThisError(); } @@ -19064,7 +19942,7 @@ var ts; else if (type.flags & (32768 | 65536 | 16 | 16384)) { buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 793064, 0, nextFlags); } - else if (!(flags & 512) && type.flags & (2097152 | 1572864) && type.aliasSymbol && + else if (!(flags & 512) && ((type.flags & 2097152 && !type.target) || type.flags & 1572864) && type.aliasSymbol && isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, 793064, false).accessibility === 0) { var typeArguments = type.aliasTypeArguments; writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments.length : 0, nextFlags); @@ -19134,12 +20012,12 @@ var ts; var length_1 = outerTypeParameters.length; while (i < length_1) { var start = i; - var parent_8 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + var parent_9 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_8); + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_9); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_8, typeArguments, start, i, flags); + writeSymbolTypeReference(parent_9, typeArguments, start, i, flags); writePunctuation(writer, 21); } } @@ -19528,12 +20406,12 @@ var ts; if (ts.isExternalModuleAugmentation(node)) { return true; } - var parent_9 = getDeclarationContainer(node); + var parent_10 = getDeclarationContainer(node); if (!(ts.getCombinedModifierFlags(node) & 1) && - !(node.kind !== 229 && parent_9.kind !== 256 && ts.isInAmbientContext(parent_9))) { - return isGlobalSourceFile(parent_9); + !(node.kind !== 229 && parent_10.kind !== 256 && ts.isInAmbientContext(parent_10))) { + return isGlobalSourceFile(parent_10); } - return isDeclarationVisible(parent_9); + return isDeclarationVisible(parent_10); case 145: case 144: case 149: @@ -19791,6 +20669,10 @@ var ts; } return undefined; } + function isAutoVariableInitializer(initializer) { + var expr = initializer && ts.skipParentheses(initializer); + return !expr || expr.kind === 93 || expr.kind === 69 && getResolvedSymbol(expr) === undefinedSymbol; + } function addOptionality(type, optional) { return strictNullChecks && optional ? includeFalsyTypes(type, 2048) : type; } @@ -19813,6 +20695,11 @@ var ts; if (declaration.type) { return addOptionality(getTypeFromTypeNode(declaration.type), declaration.questionToken && includeOptionality); } + if (declaration.kind === 218 && !ts.isBindingPattern(declaration.name) && + !(ts.getCombinedNodeFlags(declaration) & 2) && !(ts.getCombinedModifierFlags(declaration) & 1) && + !ts.isInAmbientContext(declaration) && isAutoVariableInitializer(declaration.initializer)) { + return autoType; + } if (declaration.kind === 142) { var func = declaration.parent; if (func.kind === 150 && !ts.hasDynamicName(func)) { @@ -19884,7 +20771,7 @@ var ts; result.pattern = pattern; } if (hasComputedProperties) { - result.flags |= 536870912; + result.isObjectLiteralPatternWithComputedProperties = true; } return result; } @@ -20353,7 +21240,8 @@ var ts; type.instantiations[getTypeListId(type.typeParameters)] = type; type.target = type; type.typeArguments = type.typeParameters; - type.thisType = createType(16384 | 268435456); + type.thisType = createType(16384); + type.thisType.isThisType = true; type.thisType.symbol = symbol; type.thisType.constraint = type; } @@ -20886,13 +21774,24 @@ var ts; var current = _a[_i]; for (var _b = 0, _c = getPropertiesOfType(current); _b < _c.length; _b++) { var prop = _c[_b]; - getPropertyOfUnionOrIntersectionType(type, prop.name); + getUnionOrIntersectionProperty(type, prop.name); } if (type.flags & 524288) { break; } } - return type.resolvedProperties ? symbolsToArray(type.resolvedProperties) : emptyArray; + var props = type.resolvedProperties; + if (props) { + var result = []; + for (var key in props) { + var prop = props[key]; + if (!(prop.flags & 268435456 && prop.isPartial)) { + result.push(prop); + } + } + return result; + } + return emptyArray; } function getPropertiesOfType(type) { type = getApparentType(type); @@ -20931,6 +21830,7 @@ var ts; var props; var commonFlags = (containingType.flags & 1048576) ? 536870912 : 0; var isReadonly = false; + var isPartial = false; for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { var current = types_2[_i]; var type = getApparentType(current); @@ -20949,20 +21849,20 @@ var ts; } } else if (containingType.flags & 524288) { - return undefined; + isPartial = true; } } } if (!props) { return undefined; } - if (props.length === 1) { + if (props.length === 1 && !isPartial) { return props[0]; } var propTypes = []; var declarations = []; var commonType = undefined; - var hasCommonType = true; + var hasNonUniformType = false; for (var _a = 0, props_1 = props; _a < props_1.length; _a++) { var prop = props_1[_a]; if (prop.declarations) { @@ -20973,22 +21873,20 @@ var ts; commonType = type; } else if (type !== commonType) { - hasCommonType = false; + hasNonUniformType = true; } - propTypes.push(getTypeOfSymbol(prop)); + propTypes.push(type); } - var result = createSymbol(4 | - 67108864 | - 268435456 | - commonFlags, name); + var result = createSymbol(4 | 67108864 | 268435456 | commonFlags, name); result.containingType = containingType; - result.hasCommonType = hasCommonType; + result.hasNonUniformType = hasNonUniformType; + result.isPartial = isPartial; result.declarations = declarations; result.isReadonly = isReadonly; result.type = containingType.flags & 524288 ? getUnionType(propTypes) : getIntersectionType(propTypes); return result; } - function getPropertyOfUnionOrIntersectionType(type, name) { + function getUnionOrIntersectionProperty(type, name) { var properties = type.resolvedProperties || (type.resolvedProperties = ts.createMap()); var property = properties[name]; if (!property) { @@ -20999,6 +21897,10 @@ var ts; } return property; } + function getPropertyOfUnionOrIntersectionType(type, name) { + var property = getUnionOrIntersectionProperty(type, name); + return property && !(property.flags & 268435456 && property.isPartial) ? property : undefined; + } function getPropertyOfType(type, name) { type = getApparentType(type); if (type.flags & 2588672) { @@ -21371,7 +22273,7 @@ var ts; } function hasConstraintReferenceTo(type, target) { var checked; - while (type && !(type.flags & 268435456) && type.flags & 16384 && !ts.contains(checked, type)) { + while (type && type.flags & 16384 && !(type.isThisType) && !ts.contains(checked, type)) { if (type === target) { return true; } @@ -21655,7 +22557,8 @@ var ts; type.instantiations[getTypeListId(type.typeParameters)] = type; type.target = type; type.typeArguments = type.typeParameters; - type.thisType = createType(16384 | 268435456); + type.thisType = createType(16384); + type.thisType.isThisType = true; type.thisType.constraint = type; type.declaredProperties = properties; type.declaredCallSignatures = emptyArray; @@ -21754,7 +22657,24 @@ var ts; } return false; } + function isSetOfLiteralsFromSameEnum(types) { + var first = types[0]; + if (first.flags & 256) { + var firstEnum = getParentOfSymbol(first.symbol); + for (var i = 1; i < types.length; i++) { + var other = types[i]; + if (!(other.flags & 256) || (firstEnum !== getParentOfSymbol(other.symbol))) { + return false; + } + } + return true; + } + return false; + } function removeSubtypes(types) { + if (types.length === 0 || isSetOfLiteralsFromSameEnum(types)) { + return; + } var i = types.length; while (i > 0) { i--; @@ -22729,7 +23649,8 @@ var ts; !t.numberIndexInfo; } function hasExcessProperties(source, target, reportErrors) { - if (!(target.flags & 536870912) && maybeTypeOfKind(target, 2588672)) { + if (maybeTypeOfKind(target, 2588672) && + (!(target.flags & 2588672) || !target.isObjectLiteralPatternWithComputedProperties)) { for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { var prop = _a[_i]; if (!isKnownProperty(target, prop.name)) { @@ -23934,17 +24855,10 @@ var ts; } function isDiscriminantProperty(type, name) { if (type && type.flags & 524288) { - var prop = getPropertyOfType(type, name); - if (!prop) { - var filteredType = getTypeWithFacts(type, 4194304); - if (filteredType !== type && filteredType.flags & 524288) { - prop = getPropertyOfType(filteredType, name); - } - } + var prop = getUnionOrIntersectionProperty(type, name); if (prop && prop.flags & 268435456) { if (prop.isDiscriminantProperty === undefined) { - prop.isDiscriminantProperty = !prop.hasCommonType && - isLiteralType(getTypeOfSymbol(prop)); + prop.isDiscriminantProperty = prop.hasNonUniformType && isLiteralType(getTypeOfSymbol(prop)); } return prop.isDiscriminantProperty; } @@ -24221,6 +25135,23 @@ var ts; } return f(type) ? type : neverType; } + function mapType(type, f) { + return type.flags & 524288 ? getUnionType(ts.map(type.types, f)) : f(type); + } + function extractTypesOfKind(type, kind) { + return filterType(type, function (t) { return (t.flags & kind) !== 0; }); + } + function replacePrimitivesWithLiterals(typeWithPrimitives, typeWithLiterals) { + if (isTypeSubsetOf(stringType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 32) || + isTypeSubsetOf(numberType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 64)) { + return mapType(typeWithPrimitives, function (t) { + return t.flags & 2 ? extractTypesOfKind(typeWithLiterals, 2 | 32) : + t.flags & 4 ? extractTypesOfKind(typeWithLiterals, 4 | 64) : + t; + }); + } + return typeWithPrimitives; + } function isIncomplete(flowType) { return flowType.flags === 0; } @@ -24235,7 +25166,9 @@ var ts; if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 4178943)) { return declaredType; } - var initialType = assumeInitialized ? declaredType : includeFalsyTypes(declaredType, 2048); + var initialType = assumeInitialized ? declaredType : + declaredType === autoType ? undefinedType : + includeFalsyTypes(declaredType, 2048); var visitedFlowStart = visitedFlowCount; var result = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); visitedFlowCount = visitedFlowStart; @@ -24297,10 +25230,13 @@ var ts; function getTypeAtFlowAssignment(flow) { var node = flow.node; if (isMatchingReference(reference, node)) { - var isIncrementOrDecrement = node.parent.kind === 185 || node.parent.kind === 186; - return declaredType.flags & 524288 && !isIncrementOrDecrement ? - getAssignmentReducedType(declaredType, getInitialOrAssignedType(node)) : - declaredType; + if (node.parent.kind === 185 || node.parent.kind === 186) { + var flowType = getTypeAtFlowNode(flow.antecedent); + return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType)); + } + return declaredType === autoType ? getBaseTypeOfLiteralType(getInitialOrAssignedType(node)) : + declaredType.flags & 524288 ? getAssignmentReducedType(declaredType, getInitialOrAssignedType(node)) : + declaredType; } if (containsMatchingReference(reference, node)) { return declaredType; @@ -24486,12 +25422,12 @@ var ts; assumeTrue ? 16384 : 131072; return getTypeWithFacts(type, facts); } - if (type.flags & 2589191) { + if (type.flags & 2589185) { return type; } if (assumeTrue) { var narrowedType = filterType(type, function (t) { return areTypesComparable(t, valueType); }); - return narrowedType.flags & 8192 ? type : narrowedType; + return narrowedType.flags & 8192 ? type : replacePrimitivesWithLiterals(narrowedType, valueType); } if (isUnitType(valueType)) { var regularType_1 = getRegularTypeOfLiteralType(valueType); @@ -24529,7 +25465,8 @@ var ts; var clauseTypes = switchTypes.slice(clauseStart, clauseEnd); var hasDefaultClause = clauseStart === clauseEnd || ts.contains(clauseTypes, neverType); var discriminantType = getUnionType(clauseTypes); - var caseType = discriminantType.flags & 8192 ? neverType : filterType(type, function (t) { return isTypeComparableTo(discriminantType, t); }); + var caseType = discriminantType.flags & 8192 ? neverType : + replacePrimitivesWithLiterals(filterType(type, function (t) { return isTypeComparableTo(discriminantType, t); }), discriminantType); if (!hasDefaultClause) { return caseType; } @@ -24656,7 +25593,7 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } - if (ts.isExpression(location) && !ts.isAssignmentTarget(location)) { + if (ts.isPartOfExpression(location) && !ts.isAssignmentTarget(location)) { var type = checkExpression(location); if (getExportSymbolOfValueSymbolIfExported(getNodeLinks(location).resolvedSymbol) === symbol) { return type; @@ -24779,14 +25716,26 @@ var ts; var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; while (flowContainer !== declarationContainer && - (flowContainer.kind === 179 || flowContainer.kind === 180) && + (flowContainer.kind === 179 || + flowContainer.kind === 180 || + ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isReadonlySymbol(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } - var assumeInitialized = !strictNullChecks || (type.flags & 1) !== 0 || isParameter || - isOuterVariable || ts.isInAmbientContext(declaration); + var assumeInitialized = isParameter || isOuterVariable || + type !== autoType && (!strictNullChecks || (type.flags & 1) !== 0) || + ts.isInAmbientContext(declaration); var flowType = getFlowTypeOfReference(node, type, assumeInitialized, flowContainer); - if (!assumeInitialized && !(getFalsyFlags(type) & 2048) && getFalsyFlags(flowType) & 2048) { + if (type === autoType) { + if (flowType === autoType) { + if (compilerOptions.noImplicitAny) { + error(declaration.name, ts.Diagnostics.Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol)); + error(node, ts.Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(anyType)); + } + return anyType; + } + } + else if (!assumeInitialized && !(getFalsyFlags(type) & 2048) && getFalsyFlags(flowType) & 2048) { error(node, ts.Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol)); return type; } @@ -24871,7 +25820,7 @@ var ts; } } function findFirstSuperCall(n) { - if (ts.isSuperCallExpression(n)) { + if (ts.isSuperCall(n)) { return n; } else if (ts.isFunctionLike(n)) { @@ -24936,7 +25885,7 @@ var ts; captureLexicalThis(node, container); } if (ts.isFunctionLike(container) && - (!isInParameterInitializerBeforeContainingFunction(node) || getFunctionLikeThisParameter(container))) { + (!isInParameterInitializerBeforeContainingFunction(node) || ts.getThisParameter(container))) { if (container.kind === 179 && ts.isInJavaScriptFile(container.parent) && ts.getSpecialPropertyAssignmentKind(container.parent) === 3) { @@ -25596,7 +26545,8 @@ var ts; patternWithComputedProperties = true; } } - else if (contextualTypeHasPattern && !(contextualType.flags & 536870912)) { + else if (contextualTypeHasPattern && + !(contextualType.flags & 2588672 && contextualType.isObjectLiteralPatternWithComputedProperties)) { var impliedProp = getPropertyOfType(contextualType, member.name); if (impliedProp) { prop.flags |= impliedProp.flags & 536870912; @@ -25647,7 +26597,10 @@ var ts; var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, propertiesArray, 1) : undefined; var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 16777216; - result.flags |= 8388608 | 67108864 | freshObjectLiteralFlag | (typeFlags & 234881024) | (patternWithComputedProperties ? 536870912 : 0); + result.flags |= 8388608 | 67108864 | freshObjectLiteralFlag | (typeFlags & 234881024); + if (patternWithComputedProperties) { + result.isObjectLiteralPatternWithComputedProperties = true; + } if (inDestructuringPattern) { result.pattern = node; } @@ -26042,7 +26995,7 @@ var ts; if (flags & 32) { return true; } - if (type.flags & 268435456) { + if (type.flags & 16384 && type.isThisType) { type = getConstraintOfTypeParameter(type); } if (!(getTargetType(type).flags & (32768 | 65536) && hasBaseType(type, enclosingClass))) { @@ -26083,7 +27036,7 @@ var ts; var prop = getPropertyOfType(apparentType, right.text); if (!prop) { if (right.text && !checkAndReportErrorForExtendingInterface(node)) { - reportNonexistentProperty(right, type.flags & 268435456 ? apparentType : type); + reportNonexistentProperty(right, type.flags & 16384 && type.isThisType ? apparentType : type); } return unknownType; } @@ -26308,19 +27261,19 @@ var ts; for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var signature = signatures_2[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_10 = signature.declaration && signature.declaration.parent; + var parent_11 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_10 === lastParent) { + if (lastParent && parent_11 === lastParent) { index++; } else { - lastParent = parent_10; + lastParent = parent_11; index = cutoffIndex; } } else { index = cutoffIndex = result.length; - lastParent = parent_10; + lastParent = parent_11; } lastSymbol = symbol; if (signature.hasLiteralTypes) { @@ -27223,7 +28176,9 @@ var ts; if (!contextualSignature) { reportErrorsFromWidening(func, type); } - if (isUnitType(type) && !(contextualSignature && isLiteralContextualType(getReturnTypeOfSignature(contextualSignature)))) { + if (isUnitType(type) && + !(contextualSignature && + isLiteralContextualType(contextualSignature === getSignatureFromDeclaration(func) ? type : getReturnTypeOfSignature(contextualSignature)))) { type = getWidenedLiteralType(type); } var widenedType = getWidenedType(type); @@ -27373,7 +28328,7 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 147 && node.kind !== 146) { + if (produceDiagnostics && node.kind !== 147) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } @@ -28316,9 +29271,9 @@ var ts; case 156: case 147: case 146: - var parent_11 = node.parent; - if (node === parent_11.type) { - return parent_11; + var parent_12 = node.parent; + if (node === parent_12.type) { + return parent_12; } } } @@ -28529,7 +29484,7 @@ var ts; return n.name && containsSuperCall(n.name); } function containsSuperCall(n) { - if (ts.isSuperCallExpression(n)) { + if (ts.isSuperCall(n)) { return true; } else if (ts.isFunctionLike(n)) { @@ -28555,6 +29510,7 @@ var ts; } var containingClassDecl = node.parent; if (ts.getClassExtendsHeritageClauseElement(containingClassDecl)) { + captureLexicalThis(node.parent, containingClassDecl); var classExtendsNull = classDeclarationExtendsNull(containingClassDecl); var superCall = getSuperCallInConstructor(node); if (superCall) { @@ -28568,7 +29524,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 202 && ts.isSuperCallExpression(statement.expression)) { + if (statement.kind === 202 && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -29271,14 +30227,14 @@ var ts; } function checkUnusedLocalsAndParameters(node) { if (node.parent.kind !== 222 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { - var _loop_1 = function(key) { + var _loop_1 = function (key) { var local = node.locals[key]; if (!local.isReferenced) { if (local.valueDeclaration && local.valueDeclaration.kind === 142) { var parameter = local.valueDeclaration; if (compilerOptions.noUnusedParameters && !ts.isParameterPropertyDeclaration(parameter) && - !parameterIsThisKeyword(parameter) && + !ts.parameterIsThisKeyword(parameter) && !parameterNameStartsWithUnderscore(parameter)) { error(local.valueDeclaration.name, ts.Diagnostics._0_is_declared_but_never_used, local.name); } @@ -29293,9 +30249,6 @@ var ts; } } } - function parameterIsThisKeyword(parameter) { - return parameter.name && parameter.name.originalKeywordKind === 97; - } function parameterNameStartsWithUnderscore(parameter) { return parameter.name && parameter.name.kind === 69 && parameter.name.text.charCodeAt(0) === 95; } @@ -29433,6 +30386,9 @@ var ts; } } function checkCollisionWithRequireExportsInGeneratedCode(node, name) { + if (modulekind >= ts.ModuleKind.ES6) { + return; + } if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } @@ -29536,6 +30492,9 @@ var ts; } } } + function convertAutoToAny(type) { + return type === autoType ? anyType : type; + } function checkVariableLikeDeclaration(node) { checkDecorators(node); checkSourceElement(node.type); @@ -29549,12 +30508,12 @@ var ts; if (node.propertyName && node.propertyName.kind === 140) { checkComputedPropertyName(node.propertyName); } - var parent_12 = node.parent.parent; - var parentType = getTypeForBindingElementParent(parent_12); + var parent_13 = node.parent.parent; + var parentType = getTypeForBindingElementParent(parent_13); var name_21 = node.propertyName || node.name; var property = getPropertyOfType(parentType, getTextOfPropertyName(name_21)); - if (parent_12.initializer && property && getParentOfSymbol(property)) { - checkClassPropertyAccess(parent_12, parent_12.initializer, parentType, property); + if (parent_13.initializer && property && getParentOfSymbol(property)) { + checkClassPropertyAccess(parent_13, parent_13.initializer, parentType, property); } } if (ts.isBindingPattern(node.name)) { @@ -29572,7 +30531,7 @@ var ts; return; } var symbol = getSymbolOfNode(node); - var type = getTypeOfVariableOrParameterOrProperty(symbol); + var type = convertAutoToAny(getTypeOfVariableOrParameterOrProperty(symbol)); if (node === symbol.valueDeclaration) { if (node.initializer && node.parent.parent.kind !== 207) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); @@ -29580,7 +30539,7 @@ var ts; } } else { - var declarationType = getWidenedTypeForVariableLikeDeclaration(node); + var declarationType = convertAutoToAny(getWidenedTypeForVariableLikeDeclaration(node)); if (type !== unknownType && declarationType !== unknownType && !isTypeIdenticalTo(type, declarationType)) { error(node.name, ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2, ts.declarationNameToString(node.name), typeToString(type), typeToString(declarationType)); } @@ -29955,7 +30914,12 @@ var ts; } } checkExpression(node.expression); - error(node.expression, ts.Diagnostics.All_symbols_within_a_with_block_will_be_resolved_to_any); + var sourceFile = ts.getSourceFileOfNode(node); + if (!hasParseDiagnostics(sourceFile)) { + var start = ts.getSpanOfTokenAtPosition(sourceFile, node.pos).start; + var end = node.statement.pos; + grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any); + } } function checkSwitchStatement(node) { checkGrammarStatementInAmbientContext(node); @@ -30674,9 +31638,11 @@ var ts; grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } } - checkCollisionWithCapturedThisVariable(node, node.name); - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); + if (ts.isIdentifier(node.name)) { + checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); + } checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); if (symbol.flags & 512 @@ -30915,9 +31881,11 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - if (node.parent.kind !== 256 && node.parent.kind !== 226 && node.parent.kind !== 225) { - return grammarErrorOnFirstToken(node, errorMessage); + var isInAppropriateContext = node.parent.kind === 256 || node.parent.kind === 226 || node.parent.kind === 225; + if (!isInAppropriateContext) { + grammarErrorOnFirstToken(node, errorMessage); } + return !isInAppropriateContext; } function checkExportSpecifier(node) { checkAliasSymbol(node); @@ -31004,7 +31972,8 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return declaration.kind !== 220 || !!declaration.body; + return (declaration.kind !== 220 && declaration.kind !== 147) || + !!declaration.body; } } function checkSourceElement(node) { @@ -31489,6 +32458,9 @@ var ts; node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } + if (ts.isInJavaScriptFile(node) && ts.isRequireCall(node.parent, false)) { + return resolveExternalModuleName(node, node); + } case 8: if (node.parent.kind === 173 && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); @@ -31912,9 +32884,9 @@ var ts; } var location = reference; if (startInDeclarationContainer) { - var parent_13 = reference.parent; - if (ts.isDeclaration(parent_13) && reference === parent_13.name) { - location = getDeclarationContainer(parent_13); + var parent_14 = reference.parent; + if (ts.isDeclaration(parent_14) && reference === parent_14.name) { + location = getDeclarationContainer(parent_14); } } return resolveName(location, reference.text, 107455 | 1048576 | 8388608, undefined, undefined); @@ -32023,9 +32995,9 @@ var ts; } var current = symbol; while (true) { - var parent_14 = getParentOfSymbol(current); - if (parent_14) { - current = parent_14; + var parent_15 = getParentOfSymbol(current); + if (parent_15) { + current = parent_15; } else { break; @@ -32585,8 +33557,8 @@ var ts; function checkGrammarForOmittedArgument(node, args) { if (args) { var sourceFile = ts.getSourceFileOfNode(node); - for (var _i = 0, args_2 = args; _i < args_2.length; _i++) { - var arg = args_2[_i]; + for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { + var arg = args_4[_i]; if (arg.kind === 193) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } @@ -32695,8 +33667,7 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; var name_24 = prop.name; - if (prop.kind === 193 || - name_24.kind === 140) { + if (name_24.kind === 140) { checkGrammarComputedPropertyName(name_24); } if (prop.kind === 254 && !inDestructuring && prop.objectAssignmentInitializer) { @@ -32852,17 +33823,8 @@ var ts; return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 149 ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 149 ? 1 : 2) && - accessor.parameters[0].name.kind === 69 && - accessor.parameters[0].name.originalKeywordKind === 97) { - return accessor.parameters[0]; - } - } - function getFunctionLikeThisParameter(func) { - if (func.parameters.length && - func.parameters[0].name.kind === 69 && - func.parameters[0].name.originalKeywordKind === 97) { - return func.parameters[0]; + if (accessor.parameters.length === (accessor.kind === 149 ? 1 : 2)) { + return ts.getThisParameter(accessor); } } function checkGrammarForNonSymbolComputedProperty(node, message) { @@ -33222,8 +34184,7 @@ var ts; { name: "name", test: ts.isPropertyName }, { name: "initializer", test: ts.isExpression, optional: true, parenthesize: ts.parenthesizeExpressionForList } ], - _a - )); + _a)); function reduceNode(node, f, initial) { return node ? f(initial, node) : initial; } @@ -33697,7 +34658,7 @@ var ts; case 175: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); case 176: - return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplate)); + return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); case 178: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); case 179: @@ -33721,7 +34682,7 @@ var ts; case 188: return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); case 189: - return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateLiteralFragment), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); + return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); case 190: return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); case 191: @@ -33731,7 +34692,7 @@ var ts; case 194: return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); case 197: - return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateLiteralFragment)); + return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); case 199: return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); case 200: @@ -33955,10 +34916,10 @@ var ts; ? function (message) { return Debug.assert(false, message || "Node not optional."); } : function (message) { }; Debug.failBadSyntaxKind = Debug.shouldAssert(1) - ? function (node, message) { return Debug.assert(false, message || "Unexpected node.", function () { return ("Node " + ts.formatSyntaxKind(node.kind) + " was unexpected."); }); } + ? function (node, message) { return Debug.assert(false, message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " was unexpected."; }); } : function (node, message) { }; Debug.assertNode = Debug.shouldAssert(1) - ? function (node, test, message) { return Debug.assert(test === undefined || test(node), message || "Unexpected node.", function () { return ("Node " + ts.formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."); }); } + ? function (node, test, message) { return Debug.assert(test === undefined || test(node), message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }); } : function (node, test, message) { }; function getFunctionName(func) { if (typeof func !== "function") { @@ -34006,7 +34967,7 @@ var ts; return expression; function emitAssignment(name, value, location) { var expression = ts.createAssignment(name, value, location); - context.setNodeEmitFlags(expression, 2048); + ts.setEmitFlags(expression, 2048); ts.aggregateTransformFlags(expression); expressions.push(expression); } @@ -34023,7 +34984,7 @@ var ts; return declarations; function emitAssignment(name, value, location) { var declaration = ts.createVariableDeclaration(name, undefined, value, location); - context.setNodeEmitFlags(declaration, 2048); + ts.setEmitFlags(declaration, 2048); ts.aggregateTransformFlags(declaration); declarations.push(declaration); } @@ -34047,7 +35008,7 @@ var ts; } var declaration = ts.createVariableDeclaration(name, undefined, value, location); declaration.original = original; - context.setNodeEmitFlags(declaration, 2048); + ts.setEmitFlags(declaration, 2048); declarations.push(declaration); ts.aggregateTransformFlags(declaration); } @@ -34087,7 +35048,7 @@ var ts; function emitPendingAssignment(name, value, location, original) { var expression = ts.createAssignment(name, value, location); expression.original = original; - context.setNodeEmitFlags(expression, 2048); + ts.setEmitFlags(expression, 2048); pendingAssignments.push(expression); return expression; } @@ -34132,8 +35093,8 @@ var ts; } else { var name_26 = ts.getMutableClone(target); - context.setSourceMapRange(name_26, target); - context.setCommentRange(name_26, target); + ts.setSourceMapRange(name_26, target); + ts.setCommentRange(name_26, target); emitAssignment(name_26, value, location, undefined); } } @@ -34248,7 +35209,7 @@ var ts; (function (ts) { var USE_NEW_TYPE_METADATA_FORMAT = false; function transformTypeScript(context) { - var getNodeEmitFlags = context.getNodeEmitFlags, setNodeEmitFlags = context.setNodeEmitFlags, setCommentRange = context.setCommentRange, setSourceMapRange = context.setSourceMapRange, startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); var compilerOptions = context.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); @@ -34257,10 +35218,13 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; + context.enableSubstitution(172); + context.enableSubstitution(173); var currentSourceFile; var currentNamespace; var currentNamespaceContainerName; var currentScope; + var currentScopeFirstDeclarationsOfName; var currentSourceFileExternalHelpersModuleName; var enabledSubstitutions; var classAliases; @@ -34268,12 +35232,19 @@ var ts; var currentSuperContainer; return transformSourceFile; function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } return ts.visitNode(node, visitor, ts.isSourceFile); } function saveStateAndInvoke(node, f) { var savedCurrentScope = currentScope; + var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName; onBeforeVisitNode(node); var visited = f(node); + if (currentScope !== savedCurrentScope) { + currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; + } currentScope = savedCurrentScope; return visited; } @@ -34427,11 +35398,22 @@ var ts; case 226: case 199: currentScope = node; + currentScopeFirstDeclarationsOfName = undefined; + break; + case 221: + case 220: + if (ts.hasModifier(node, 2)) { + break; + } + recordEmittedDeclarationInScope(node); break; } } function visitSourceFile(node) { currentSourceFile = node; + if (compilerOptions.alwaysStrict) { + node = ts.ensureUseStrict(node); + } if (node.flags & 31744 && compilerOptions.importHelpers && (ts.isExternalModule(node) || compilerOptions.isolatedModules)) { @@ -34453,7 +35435,7 @@ var ts; else { node = ts.visitEachChild(node, visitor, context); } - setNodeEmitFlags(node, 1 | node.emitFlags); + ts.setEmitFlags(node, 1 | ts.getEmitFlags(node)); return node; } function shouldEmitDecorateCallForClass(node) { @@ -34483,7 +35465,7 @@ var ts; var classDeclaration = ts.createClassDeclaration(undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, hasExtendsClause), node); ts.setOriginalNode(classDeclaration, node); if (staticProperties.length > 0) { - setNodeEmitFlags(classDeclaration, 1024 | getNodeEmitFlags(classDeclaration)); + ts.setEmitFlags(classDeclaration, 1024 | ts.getEmitFlags(classDeclaration)); } statements.push(classDeclaration); } @@ -34525,7 +35507,7 @@ var ts; var transformedClassExpression = ts.createVariableStatement(undefined, ts.createLetDeclarationList([ ts.createVariableDeclaration(classAlias || declaredName, undefined, classExpression) ]), location); - setCommentRange(transformedClassExpression, node); + ts.setCommentRange(transformedClassExpression, node); statements.push(ts.setOriginalNode(transformedClassExpression, node)); if (classAlias) { statements.push(ts.setOriginalNode(ts.createVariableStatement(undefined, ts.createLetDeclarationList([ @@ -34546,7 +35528,7 @@ var ts; enableSubstitutionForClassAliases(); classAliases[ts.getOriginalNodeId(node)] = ts.getSynthesizedClone(temp); } - setNodeEmitFlags(classExpression, 524288 | getNodeEmitFlags(classExpression)); + ts.setEmitFlags(classExpression, 524288 | ts.getEmitFlags(classExpression)); expressions.push(ts.startOnNewLine(ts.createAssignment(temp, classExpression))); ts.addRange(expressions, generateInitializedPropertyExpressions(node, staticProperties, temp)); expressions.push(ts.startOnNewLine(temp)); @@ -34607,7 +35589,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 202 && ts.isSuperCallExpression(statement.expression)) { + if (statement.kind === 202 && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -34626,9 +35608,9 @@ var ts; ts.Debug.assert(ts.isIdentifier(node.name)); var name = node.name; var propertyName = ts.getMutableClone(name); - setNodeEmitFlags(propertyName, 49152 | 1536); + ts.setEmitFlags(propertyName, 49152 | 1536); var localName = ts.getMutableClone(name); - setNodeEmitFlags(localName, 49152); + ts.setEmitFlags(localName, 49152); return ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createThis(), propertyName, node.name), localName), ts.moveRangePos(node, -1))); } function getInitializedProperties(node, isStatic) { @@ -34649,8 +35631,8 @@ var ts; for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) { var property = properties_7[_i]; var statement = ts.createStatement(transformInitializedProperty(node, property, receiver)); - setSourceMapRange(statement, ts.moveRangePastModifiers(property)); - setCommentRange(statement, property); + ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property)); + ts.setCommentRange(statement, property); statements.push(statement); } } @@ -34660,8 +35642,8 @@ var ts; var property = properties_8[_i]; var expression = transformInitializedProperty(node, property, receiver); expression.startsOnNewLine = true; - setSourceMapRange(expression, ts.moveRangePastModifiers(property)); - setCommentRange(expression, property); + ts.setSourceMapRange(expression, ts.moveRangePastModifiers(property)); + ts.setCommentRange(expression, property); expressions.push(expression); } return expressions; @@ -34802,7 +35784,7 @@ var ts; : ts.createNull() : undefined; var helper = ts.createDecorateHelper(currentSourceFileExternalHelpersModuleName, decoratorExpressions, prefix, memberName, descriptor, ts.moveRangePastDecorators(member)); - setNodeEmitFlags(helper, 49152); + ts.setEmitFlags(helper, 49152); return helper; } function addConstructorDecorationStatement(statements, node, decoratedClassAlias) { @@ -34820,12 +35802,12 @@ var ts; if (decoratedClassAlias) { var expression = ts.createAssignment(decoratedClassAlias, ts.createDecorateHelper(currentSourceFileExternalHelpersModuleName, decoratorExpressions, getDeclarationName(node))); var result = ts.createAssignment(getDeclarationName(node), expression, ts.moveRangePastDecorators(node)); - setNodeEmitFlags(result, 49152); + ts.setEmitFlags(result, 49152); return result; } else { var result = ts.createAssignment(getDeclarationName(node), ts.createDecorateHelper(currentSourceFileExternalHelpersModuleName, decoratorExpressions, getDeclarationName(node)), ts.moveRangePastDecorators(node)); - setNodeEmitFlags(result, 49152); + ts.setEmitFlags(result, 49152); return result; } } @@ -34839,7 +35821,7 @@ var ts; for (var _i = 0, decorators_1 = decorators; _i < decorators_1.length; _i++) { var decorator = decorators_1[_i]; var helper = ts.createParamHelper(currentSourceFileExternalHelpersModuleName, transformDecorator(decorator), parameterOffset, decorator.expression); - setNodeEmitFlags(helper, 49152); + ts.setEmitFlags(helper, 49152); expressions.push(helper); } } @@ -35004,10 +35986,33 @@ var ts; : ts.createIdentifier("Symbol"); case 155: return serializeTypeReferenceNode(node); + case 163: + case 162: + { + var unionOrIntersection = node; + var serializedUnion = void 0; + for (var _i = 0, _a = unionOrIntersection.types; _i < _a.length; _i++) { + var typeNode = _a[_i]; + var serializedIndividual = serializeTypeNode(typeNode); + if (serializedIndividual.kind !== 69) { + serializedUnion = undefined; + break; + } + if (serializedIndividual.text === "Object") { + return serializedIndividual; + } + if (serializedUnion && serializedUnion.text !== serializedIndividual.text) { + serializedUnion = undefined; + break; + } + serializedUnion = serializedIndividual; + } + if (serializedUnion) { + return serializedUnion; + } + } case 158: case 159: - case 162: - case 163: case 117: case 165: break; @@ -35128,8 +36133,8 @@ var ts; return undefined; } var method = ts.createMethod(undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, visitPropertyNameOfClassElement(node), undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); - setCommentRange(method, node); - setSourceMapRange(method, ts.moveRangePastDecorators(node)); + ts.setCommentRange(method, node); + ts.setSourceMapRange(method, ts.moveRangePastDecorators(node)); ts.setOriginalNode(method, node); return method; } @@ -35141,8 +36146,8 @@ var ts; return undefined; } var accessor = ts.createGetAccessor(undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, node.body ? ts.visitEachChild(node.body, visitor, context) : ts.createBlock([]), node); - setCommentRange(accessor, node); - setSourceMapRange(accessor, ts.moveRangePastDecorators(node)); + ts.setCommentRange(accessor, node); + ts.setSourceMapRange(accessor, ts.moveRangePastDecorators(node)); ts.setOriginalNode(accessor, node); return accessor; } @@ -35151,8 +36156,8 @@ var ts; return undefined; } var accessor = ts.createSetAccessor(undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitNodes(node.parameters, visitor, ts.isParameter), node.body ? ts.visitEachChild(node.body, visitor, context) : ts.createBlock([]), node); - setCommentRange(accessor, node); - setSourceMapRange(accessor, ts.moveRangePastDecorators(node)); + ts.setCommentRange(accessor, node); + ts.setSourceMapRange(accessor, ts.moveRangePastDecorators(node)); ts.setOriginalNode(accessor, node); return accessor; } @@ -35247,11 +36252,11 @@ var ts; if (languageVersion >= 2) { if (resolver.getNodeCheckFlags(node) & 4096) { enableSubstitutionForAsyncMethodsWithSuper(); - setNodeEmitFlags(block, 8); + ts.setEmitFlags(block, 8); } else if (resolver.getNodeCheckFlags(node) & 2048) { enableSubstitutionForAsyncMethodsWithSuper(); - setNodeEmitFlags(block, 4); + ts.setEmitFlags(block, 4); } } return block; @@ -35261,14 +36266,14 @@ var ts; } } function visitParameter(node) { - if (node.name && ts.isIdentifier(node.name) && node.name.originalKeywordKind === 97) { + if (ts.parameterIsThisKeyword(node)) { return undefined; } var parameter = ts.createParameterDeclaration(undefined, undefined, node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression), ts.moveRangePastModifiers(node)); ts.setOriginalNode(parameter, node); - setCommentRange(parameter, node); - setSourceMapRange(parameter, ts.moveRangePastModifiers(node)); - setNodeEmitFlags(parameter.name, 1024); + ts.setCommentRange(parameter, node); + ts.setSourceMapRange(parameter, ts.moveRangePastModifiers(node)); + ts.setEmitFlags(parameter.name, 1024); return parameter; } function visitVariableStatement(node) { @@ -35317,12 +36322,13 @@ var ts; || compilerOptions.isolatedModules; } function shouldEmitVarForEnumDeclaration(node) { - return !ts.hasModifier(node, 1) - || (isES6ExportedDeclaration(node) && ts.isFirstDeclarationOfKind(node, node.kind)); + return isFirstEmittedDeclarationInScope(node) + && (!ts.hasModifier(node, 1) + || isES6ExportedDeclaration(node)); } function addVarForEnumExportedFromNamespace(statements, node) { var statement = ts.createVariableStatement(undefined, [ts.createVariableDeclaration(getDeclarationName(node), undefined, getExportName(node))]); - setSourceMapRange(statement, node); + ts.setSourceMapRange(statement, node); statements.push(statement); } function visitEnumDeclaration(node) { @@ -35331,6 +36337,7 @@ var ts; } var statements = []; var emitFlags = 64; + recordEmittedDeclarationInScope(node); if (shouldEmitVarForEnumDeclaration(node)) { addVarForEnumOrModuleDeclaration(statements, node); if (moduleKind !== ts.ModuleKind.System || currentScope !== currentSourceFile) { @@ -35342,7 +36349,7 @@ var ts; var exportName = getExportName(node); var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, transformEnumBody(node, containerName)), undefined, [ts.createLogicalOr(exportName, ts.createAssignment(exportName, ts.createObjectLiteral()))]), node); ts.setOriginalNode(enumStatement, node); - setNodeEmitFlags(enumStatement, emitFlags); + ts.setEmitFlags(enumStatement, emitFlags); statements.push(enumStatement); if (isNamespaceExport(node)) { addVarForEnumExportedFromNamespace(statements, node); @@ -35381,18 +36388,32 @@ var ts; function shouldEmitModuleDeclaration(node) { return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); } - function isModuleMergedWithES6Class(node) { - return languageVersion === 2 - && ts.isMergedWithClass(node); - } function isES6ExportedDeclaration(node) { return isExternalModuleExport(node) && moduleKind === ts.ModuleKind.ES6; } + function recordEmittedDeclarationInScope(node) { + var name = node.symbol && node.symbol.name; + if (name) { + if (!currentScopeFirstDeclarationsOfName) { + currentScopeFirstDeclarationsOfName = ts.createMap(); + } + if (!(name in currentScopeFirstDeclarationsOfName)) { + currentScopeFirstDeclarationsOfName[name] = node; + } + } + } + function isFirstEmittedDeclarationInScope(node) { + if (currentScopeFirstDeclarationsOfName) { + var name_28 = node.symbol && node.symbol.name; + if (name_28) { + return currentScopeFirstDeclarationsOfName[name_28] === node; + } + } + return false; + } function shouldEmitVarForModuleDeclaration(node) { - return !isModuleMergedWithES6Class(node) - && (!isES6ExportedDeclaration(node) - || ts.isFirstDeclarationOfKind(node, node.kind)); + return isFirstEmittedDeclarationInScope(node); } function addVarForEnumOrModuleDeclaration(statements, node) { var statement = ts.createVariableStatement(isES6ExportedDeclaration(node) @@ -35402,13 +36423,13 @@ var ts; ]); ts.setOriginalNode(statement, node); if (node.kind === 224) { - setSourceMapRange(statement.declarationList, node); + ts.setSourceMapRange(statement.declarationList, node); } else { - setSourceMapRange(statement, node); + ts.setSourceMapRange(statement, node); } - setCommentRange(statement, node); - setNodeEmitFlags(statement, 32768); + ts.setCommentRange(statement, node); + ts.setEmitFlags(statement, 32768); statements.push(statement); } function visitModuleDeclaration(node) { @@ -35419,6 +36440,7 @@ var ts; enableSubstitutionForNamespaceExports(); var statements = []; var emitFlags = 64; + recordEmittedDeclarationInScope(node); if (shouldEmitVarForModuleDeclaration(node)) { addVarForEnumOrModuleDeclaration(statements, node); if (moduleKind !== ts.ModuleKind.System || currentScope !== currentSourceFile) { @@ -35435,15 +36457,17 @@ var ts; } var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, transformModuleBody(node, containerName)), undefined, [moduleArg]), node); ts.setOriginalNode(moduleStatement, node); - setNodeEmitFlags(moduleStatement, emitFlags); + ts.setEmitFlags(moduleStatement, emitFlags); statements.push(moduleStatement); return statements; } function transformModuleBody(node, namespaceLocalName) { var savedCurrentNamespaceContainerName = currentNamespaceContainerName; var savedCurrentNamespace = currentNamespace; + var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName; currentNamespaceContainerName = namespaceLocalName; currentNamespace = node; + currentScopeFirstDeclarationsOfName = undefined; var statements = []; startLexicalEnvironment(); var statementsLocation; @@ -35470,9 +36494,10 @@ var ts; ts.addRange(statements, endLexicalEnvironment()); currentNamespaceContainerName = savedCurrentNamespaceContainerName; currentNamespace = savedCurrentNamespace; + currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), blockLocation, true); if (body.kind !== 226) { - setNodeEmitFlags(block, block.emitFlags | 49152); + ts.setEmitFlags(block, ts.getEmitFlags(block) | 49152); } return block; } @@ -35495,7 +36520,7 @@ var ts; return undefined; } var moduleReference = ts.createExpressionFromEntityName(node.moduleReference); - setNodeEmitFlags(moduleReference, 49152 | 65536); + ts.setEmitFlags(moduleReference, 49152 | 65536); if (isNamedExternalModuleExport(node) || !isNamespaceExport(node)) { return ts.setOriginalNode(ts.createVariableStatement(ts.visitNodes(node.modifiers, visitor, ts.isModifier), ts.createVariableDeclarationList([ ts.createVariableDeclaration(node.name, undefined, moduleReference) @@ -35524,9 +36549,9 @@ var ts; } function addExportMemberAssignment(statements, node) { var expression = ts.createAssignment(getExportName(node), getLocalName(node, true)); - setSourceMapRange(expression, ts.createRange(node.name.pos, node.end)); + ts.setSourceMapRange(expression, ts.createRange(node.name.pos, node.end)); var statement = ts.createStatement(expression); - setSourceMapRange(statement, ts.createRange(-1, node.end)); + ts.setSourceMapRange(statement, ts.createRange(-1, node.end)); statements.push(statement); } function createNamespaceExport(exportName, exportValue, location) { @@ -35547,7 +36572,7 @@ var ts; emitFlags |= 1536; } if (emitFlags) { - setNodeEmitFlags(qualifiedName, emitFlags); + ts.setEmitFlags(qualifiedName, emitFlags); } return qualifiedName; } @@ -35556,7 +36581,7 @@ var ts; } function getNamespaceParameterName(node) { var name = ts.getGeneratedNameForNode(node); - setSourceMapRange(name, node.name); + ts.setSourceMapRange(name, node.name); return name; } function getNamespaceContainerName(node) { @@ -35573,8 +36598,8 @@ var ts; } function getDeclarationName(node, allowComments, allowSourceMaps, emitFlags) { if (node.name) { - var name_28 = ts.getMutableClone(node.name); - emitFlags |= getNodeEmitFlags(node.name); + var name_29 = ts.getMutableClone(node.name); + emitFlags |= ts.getEmitFlags(node.name); if (!allowSourceMaps) { emitFlags |= 1536; } @@ -35582,9 +36607,9 @@ var ts; emitFlags |= 49152; } if (emitFlags) { - setNodeEmitFlags(name_28, emitFlags); + ts.setEmitFlags(name_29, emitFlags); } - return name_28; + return name_29; } else { return ts.getGeneratedNameForNode(node); @@ -35646,7 +36671,7 @@ var ts; function isTransformedEnumDeclaration(node) { return ts.getOriginalNode(node).kind === 224; } - function onEmitNode(node, emit) { + function onEmitNode(emitContext, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; var savedCurrentSuperContainer = currentSuperContainer; if (enabledSubstitutions & 4 && isSuperContainer(node)) { @@ -35658,13 +36683,13 @@ var ts; if (enabledSubstitutions & 8 && isTransformedEnumDeclaration(node)) { applicableSubstitutions |= 8; } - previousOnEmitNode(node, emit); + previousOnEmitNode(emitContext, node, emitCallback); applicableSubstitutions = savedApplicableSubstitutions; currentSuperContainer = savedCurrentSuperContainer; } - function onSubstituteNode(node, isExpression) { - node = previousOnSubstituteNode(node, isExpression); - if (isExpression) { + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1) { return substituteExpression(node); } else if (ts.isShorthandPropertyAssignment(node)) { @@ -35674,14 +36699,14 @@ var ts; } function substituteShorthandPropertyAssignment(node) { if (enabledSubstitutions & 2) { - var name_29 = node.name; - var exportedName = trySubstituteNamespaceExportedName(name_29); + var name_30 = node.name; + var exportedName = trySubstituteNamespaceExportedName(name_30); if (exportedName) { if (node.objectAssignmentInitializer) { var initializer = ts.createAssignment(exportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name_29, initializer, node); + return ts.createPropertyAssignment(name_30, initializer, node); } - return ts.createPropertyAssignment(name_29, exportedName, node); + return ts.createPropertyAssignment(name_30, exportedName, node); } } return node; @@ -35690,16 +36715,15 @@ var ts; switch (node.kind) { case 69: return substituteExpressionIdentifier(node); - } - if (enabledSubstitutions & 4) { - switch (node.kind) { - case 174: + case 172: + return substitutePropertyAccessExpression(node); + case 173: + return substituteElementAccessExpression(node); + case 174: + if (enabledSubstitutions & 4) { return substituteCallExpression(node); - case 172: - return substitutePropertyAccessExpression(node); - case 173: - return substituteElementAccessExpression(node); - } + } + break; } return node; } @@ -35716,8 +36740,8 @@ var ts; var classAlias = classAliases[declaration.id]; if (classAlias) { var clone_4 = ts.getSynthesizedClone(classAlias); - setSourceMapRange(clone_4, node); - setCommentRange(clone_4, node); + ts.setSourceMapRange(clone_4, node); + ts.setCommentRange(clone_4, node); return clone_4; } } @@ -35726,7 +36750,7 @@ var ts; return undefined; } function trySubstituteNamespaceExportedName(node) { - if (enabledSubstitutions & applicableSubstitutions && (getNodeEmitFlags(node) & 262144) === 0) { + if (enabledSubstitutions & applicableSubstitutions && (ts.getEmitFlags(node) & 262144) === 0) { var container = resolver.getReferencedExportContainer(node, false); if (container) { var substitute = (applicableSubstitutions & 2 && container.kind === 225) || @@ -35754,23 +36778,48 @@ var ts; return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 95) { + if (enabledSubstitutions & 4 && node.expression.kind === 95) { var flags = getSuperContainerAsyncMethodFlags(); if (flags) { return createSuperAccessInAsyncMethod(ts.createLiteral(node.name.text), flags, node); } } - return node; + return substituteConstantValue(node); } function substituteElementAccessExpression(node) { - if (node.expression.kind === 95) { + if (enabledSubstitutions & 4 && node.expression.kind === 95) { var flags = getSuperContainerAsyncMethodFlags(); if (flags) { return createSuperAccessInAsyncMethod(node.argumentExpression, flags, node); } } + return substituteConstantValue(node); + } + function substituteConstantValue(node) { + var constantValue = tryGetConstEnumValue(node); + if (constantValue !== undefined) { + var substitute = ts.createLiteral(constantValue); + ts.setSourceMapRange(substitute, node); + ts.setCommentRange(substitute, node); + if (!compilerOptions.removeComments) { + var propertyName = ts.isPropertyAccessExpression(node) + ? ts.declarationNameToString(node.name) + : ts.getTextOfNode(node.argumentExpression); + substitute.trailingComment = " " + propertyName + " "; + } + ts.setConstantValue(node, constantValue); + return substitute; + } return node; } + function tryGetConstEnumValue(node) { + if (compilerOptions.isolatedModules) { + return undefined; + } + return ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node) + ? resolver.getConstantValue(node) + : undefined; + } function createSuperAccessInAsyncMethod(argumentExpression, flags, location) { if (flags & 4096) { return ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), "value", location); @@ -35794,6 +36843,9 @@ var ts; var currentSourceFile; return transformSourceFile; function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { currentSourceFile = node; return ts.visitEachChild(node, visitor, context); @@ -35905,7 +36957,7 @@ var ts; var ts; (function (ts) { function transformSystemModule(context) { - var getNodeEmitFlags = context.getNodeEmitFlags, setNodeEmitFlags = context.setNodeEmitFlags, startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration, hoistFunctionDeclaration = context.hoistFunctionDeclaration; + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration, hoistFunctionDeclaration = context.hoistFunctionDeclaration; var compilerOptions = context.getCompilerOptions(); var resolver = context.getEmitResolver(); var host = context.getEmitHost(); @@ -35934,6 +36986,9 @@ var ts; var currentNode; return transformSourceFile; function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { currentSourceFile = node; currentNode = node; @@ -35966,12 +37021,12 @@ var ts; var body = ts.createFunctionExpression(undefined, undefined, undefined, [ ts.createParameter(exportFunctionForFile), ts.createParameter(contextObjectForFile) - ], undefined, setNodeEmitFlags(ts.createBlock(statements, undefined, true), 1)); + ], undefined, ts.setEmitFlags(ts.createBlock(statements, undefined, true), 1)); return updateSourceFile(node, [ ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), undefined, moduleName ? [moduleName, dependencies, body] : [dependencies, body])) - ], ~1 & getNodeEmitFlags(node)); + ], ~1 & ts.getEmitFlags(node)); var _a; } function addSystemModuleBody(statements, node, dependencyGroups) { @@ -36215,11 +37270,11 @@ var ts; } function visitFunctionDeclaration(node) { if (ts.hasModifier(node, 1)) { - var name_30 = node.name || ts.getGeneratedNameForNode(node); - var newNode = ts.createFunctionDeclaration(undefined, undefined, node.asteriskToken, name_30, undefined, node.parameters, undefined, node.body, node); + var name_31 = node.name || ts.getGeneratedNameForNode(node); + var newNode = ts.createFunctionDeclaration(undefined, undefined, node.asteriskToken, name_31, undefined, node.parameters, undefined, node.body, node); recordExportedFunctionDeclaration(node); if (!ts.hasModifier(node, 512)) { - recordExportName(name_30); + recordExportName(name_31); } ts.setOriginalNode(newNode, node); node = newNode; @@ -36230,13 +37285,13 @@ var ts; function visitExpressionStatement(node) { var originalNode = ts.getOriginalNode(node); if ((originalNode.kind === 225 || originalNode.kind === 224) && ts.hasModifier(originalNode, 1)) { - var name_31 = getDeclarationName(originalNode); + var name_32 = getDeclarationName(originalNode); if (originalNode.kind === 224) { - hoistVariableDeclaration(name_31); + hoistVariableDeclaration(name_32); } return [ node, - createExportStatement(name_31, name_31) + createExportStatement(name_32, name_32) ]; } return node; @@ -36390,19 +37445,19 @@ var ts; function visitBlock(node) { return ts.visitEachChild(node, visitNestedNode, context); } - function onEmitNode(node, emit) { + function onEmitNode(emitContext, node, emitCallback) { if (node.kind === 256) { exportFunctionForFile = exportFunctionForFileMap[ts.getOriginalNodeId(node)]; - previousOnEmitNode(node, emit); + previousOnEmitNode(emitContext, node, emitCallback); exportFunctionForFile = undefined; } else { - previousOnEmitNode(node, emit); + previousOnEmitNode(emitContext, node, emitCallback); } } - function onSubstituteNode(node, isExpression) { - node = previousOnSubstituteNode(node, isExpression); - if (isExpression) { + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1) { return substituteExpression(node); } return node; @@ -36436,7 +37491,7 @@ var ts; return node; } function substituteAssignmentExpression(node) { - setNodeEmitFlags(node, 128); + ts.setEmitFlags(node, 128); var left = node.left; switch (left.kind) { case 69: @@ -36541,7 +37596,7 @@ var ts; var exportDeclaration = resolver.getReferencedExportContainer(operand); if (exportDeclaration) { var expr = ts.createPrefix(node.operator, operand, node); - setNodeEmitFlags(expr, 128); + ts.setEmitFlags(expr, 128); var call = createExportExpression(operand, expr); if (node.kind === 185) { return call; @@ -36574,7 +37629,7 @@ var ts; ts.createForIn(ts.createVariableDeclarationList([ ts.createVariableDeclaration(n, undefined) ]), m, ts.createBlock([ - setNodeEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 32) + ts.setEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 32) ])), ts.createStatement(ts.createCall(exportFunctionForFile, undefined, [exports])) ], undefined, true))); @@ -36674,7 +37729,7 @@ var ts; function updateSourceFile(node, statements, nodeEmitFlags) { var updated = ts.getMutableClone(node); updated.statements = ts.createNodeArray(statements, node.statements); - setNodeEmitFlags(updated, nodeEmitFlags); + ts.setEmitFlags(updated, nodeEmitFlags); return updated; } } @@ -36688,9 +37743,8 @@ var ts; _a[ts.ModuleKind.CommonJS] = transformCommonJSModule, _a[ts.ModuleKind.AMD] = transformAMDModule, _a[ts.ModuleKind.UMD] = transformUMDModule, - _a - )); - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration, setNodeEmitFlags = context.setNodeEmitFlags, getNodeEmitFlags = context.getNodeEmitFlags, setSourceMapRange = context.setSourceMapRange; + _a)); + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var compilerOptions = context.getCompilerOptions(); var resolver = context.getEmitResolver(); var host = context.getEmitHost(); @@ -36715,6 +37769,9 @@ var ts; var hasExportStarsToExportValues; return transformSourceFile; function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { currentSourceFile = node; (_a = ts.collectExternalModuleInfo(node, resolver), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); @@ -36740,7 +37797,7 @@ var ts; addExportEqualsIfNeeded(statements, false); var updated = updateSourceFile(node, statements); if (hasExportStarsToExportValues) { - setNodeEmitFlags(updated, 2 | getNodeEmitFlags(node)); + ts.setEmitFlags(updated, 2 | ts.getEmitFlags(node)); } return updated; } @@ -36751,7 +37808,7 @@ var ts; } function transformUMDModule(node) { var define = ts.createIdentifier("define"); - setNodeEmitFlags(define, 16); + ts.setEmitFlags(define, 16); return transformAsynchronousModule(node, define, undefined, false); } function transformAsynchronousModule(node, define, moduleName, includeNonAmdDependencies) { @@ -36778,7 +37835,7 @@ var ts; addExportEqualsIfNeeded(statements, true); var body = ts.createBlock(statements, undefined, true); if (hasExportStarsToExportValues) { - setNodeEmitFlags(body, 2); + ts.setEmitFlags(body, 2); } return body; } @@ -36786,12 +37843,12 @@ var ts; if (exportEquals && resolver.isValueAliasDeclaration(exportEquals)) { if (emitAsReturn) { var statement = ts.createReturn(exportEquals.expression, exportEquals); - setNodeEmitFlags(statement, 12288 | 49152); + ts.setEmitFlags(statement, 12288 | 49152); statements.push(statement); } else { var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), exportEquals.expression), exportEquals); - setNodeEmitFlags(statement, 49152); + ts.setEmitFlags(statement, 49152); statements.push(statement); } } @@ -36854,7 +37911,7 @@ var ts; if (!ts.contains(externalImports, node)) { return undefined; } - setNodeEmitFlags(node.name, 128); + ts.setEmitFlags(node.name, 128); var statements = []; if (moduleKind !== ts.ModuleKind.AMD) { if (ts.hasModifier(node, 1)) { @@ -36942,16 +37999,16 @@ var ts; else { var names = ts.reduceEachChild(node, collectExportMembers, []); for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_32 = names_1[_i]; - addExportMemberAssignments(statements, name_32); + var name_33 = names_1[_i]; + addExportMemberAssignments(statements, name_33); } } } function collectExportMembers(names, node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node) && ts.isDeclaration(node)) { - var name_33 = node.name; - if (ts.isIdentifier(name_33)) { - names.push(name_33); + var name_34 = node.name; + if (ts.isIdentifier(name_34)) { + names.push(name_34); } } return ts.reduceEachChild(node, collectExportMembers, names); @@ -36969,7 +38026,7 @@ var ts; addExportDefault(statements, getDeclarationName(node), node); } else { - statements.push(createExportStatement(node.name, setNodeEmitFlags(ts.getSynthesizedClone(node.name), 262144), node)); + statements.push(createExportStatement(node.name, ts.setEmitFlags(ts.getSynthesizedClone(node.name), 262144), node)); } } function visitVariableStatement(node) { @@ -37086,25 +38143,25 @@ var ts; } function addVarForExportedEnumOrNamespaceDeclaration(statements, node) { var transformedStatement = ts.createVariableStatement(undefined, [ts.createVariableDeclaration(getDeclarationName(node), undefined, ts.createPropertyAccess(ts.createIdentifier("exports"), getDeclarationName(node)))], node); - setNodeEmitFlags(transformedStatement, 49152); + ts.setEmitFlags(transformedStatement, 49152); statements.push(transformedStatement); } function getDeclarationName(node) { return node.name ? ts.getSynthesizedClone(node.name) : ts.getGeneratedNameForNode(node); } - function onEmitNode(node, emit) { + function onEmitNode(emitContext, node, emitCallback) { if (node.kind === 256) { bindingNameExportSpecifiersMap = bindingNameExportSpecifiersForFileMap[ts.getOriginalNodeId(node)]; - previousOnEmitNode(node, emit); + previousOnEmitNode(emitContext, node, emitCallback); bindingNameExportSpecifiersMap = undefined; } else { - previousOnEmitNode(node, emit); + previousOnEmitNode(emitContext, node, emitCallback); } } - function onSubstituteNode(node, isExpression) { - node = previousOnSubstituteNode(node, isExpression); - if (isExpression) { + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1) { return substituteExpression(node); } else if (ts.isShorthandPropertyAssignment(node)) { @@ -37145,7 +38202,7 @@ var ts; var left = node.left; if (ts.isIdentifier(left) && ts.isAssignmentOperator(node.operatorToken.kind)) { if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, left.text)) { - setNodeEmitFlags(node, 128); + ts.setEmitFlags(node, 128); var nestedExportAssignment = void 0; for (var _i = 0, _a = bindingNameExportSpecifiersMap[left.text]; _i < _a.length; _i++) { var specifier = _a[_i]; @@ -37163,11 +38220,11 @@ var ts; var operand = node.operand; if (ts.isIdentifier(operand) && bindingNameExportSpecifiersForFileMap) { if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, operand.text)) { - setNodeEmitFlags(node, 128); + ts.setEmitFlags(node, 128); var transformedUnaryExpression = void 0; if (node.kind === 186) { - transformedUnaryExpression = ts.createBinary(operand, ts.createNode(operator === 41 ? 57 : 58), ts.createLiteral(1), node); - setNodeEmitFlags(transformedUnaryExpression, 128); + transformedUnaryExpression = ts.createBinary(operand, ts.createToken(operator === 41 ? 57 : 58), ts.createLiteral(1), node); + ts.setEmitFlags(transformedUnaryExpression, 128); } var nestedExportAssignment = void 0; for (var _i = 0, _a = bindingNameExportSpecifiersMap[operand.text]; _i < _a.length; _i++) { @@ -37182,7 +38239,7 @@ var ts; return node; } function trySubstituteExportedName(node) { - var emitFlags = getNodeEmitFlags(node); + var emitFlags = ts.getEmitFlags(node); if ((emitFlags & 262144) === 0) { var container = resolver.getReferencedExportContainer(node, (emitFlags & 131072) !== 0); if (container) { @@ -37194,7 +38251,7 @@ var ts; return undefined; } function trySubstituteImportedName(node) { - if ((getNodeEmitFlags(node) & 262144) === 0) { + if ((ts.getEmitFlags(node) & 262144) === 0) { var declaration = resolver.getReferencedImportDeclaration(node); if (declaration) { if (ts.isImportClause(declaration)) { @@ -37206,12 +38263,12 @@ var ts; } } else if (ts.isImportSpecifier(declaration)) { - var name_34 = declaration.propertyName || declaration.name; - if (name_34.originalKeywordKind === 77 && languageVersion <= 0) { - return ts.createElementAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.createLiteral(name_34.text), node); + var name_35 = declaration.propertyName || declaration.name; + if (name_35.originalKeywordKind === 77 && languageVersion <= 0) { + return ts.createElementAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.createLiteral(name_35.text), node); } else { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.getSynthesizedClone(name_34), node); + return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.getSynthesizedClone(name_35), node); } } } @@ -37233,7 +38290,7 @@ var ts; var statement = ts.createStatement(createExportAssignment(name, value)); statement.startsOnNewLine = true; if (location) { - setSourceMapRange(statement, location); + ts.setSourceMapRange(statement, location); } return statement; } @@ -37261,7 +38318,7 @@ var ts; var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile); if (includeNonAmdDependencies && importAliasName) { - setNodeEmitFlags(importAliasName, 128); + ts.setEmitFlags(importAliasName, 128); aliasedModuleNames.push(externalModuleName); importAliasNames.push(ts.createParameter(importAliasName)); } @@ -37288,6 +38345,9 @@ var ts; var currentSourceFile; return transformSourceFile; function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } currentSourceFile = node; node = ts.visitEachChild(node, visitor, context); currentSourceFile = undefined; @@ -37446,12 +38506,12 @@ var ts; return getTagName(node.openingElement); } else { - var name_35 = node.tagName; - if (ts.isIdentifier(name_35) && ts.isIntrinsicJsxName(name_35.text)) { - return ts.createLiteral(name_35.text); + var name_36 = node.tagName; + if (ts.isIdentifier(name_36) && ts.isIntrinsicJsxName(name_36.text)) { + return ts.createLiteral(name_36.text); } else { - return ts.createExpressionFromEntityName(name_35); + return ts.createExpressionFromEntityName(name_36); } } } @@ -37733,6 +38793,9 @@ var ts; var hoistVariableDeclaration = context.hoistVariableDeclaration; return transformSourceFile; function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } return ts.visitEachChild(node, visitor, context); } function visitor(node) { @@ -37797,10 +38860,9 @@ var ts; _a[4] = "yield", _a[5] = "yield*", _a[7] = "endfinally", - _a - )); + _a)); function transformGenerators(context) { - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistFunctionDeclaration = context.hoistFunctionDeclaration, hoistVariableDeclaration = context.hoistVariableDeclaration, setSourceMapRange = context.setSourceMapRange, setCommentRange = context.setCommentRange, setNodeEmitFlags = context.setNodeEmitFlags; + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistFunctionDeclaration = context.hoistFunctionDeclaration, hoistVariableDeclaration = context.hoistVariableDeclaration; var compilerOptions = context.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var resolver = context.getEmitResolver(); @@ -37834,6 +38896,9 @@ var ts; var withBlockStack; return transformSourceFile; function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } if (node.transformFlags & 1024) { currentSourceFile = node; node = ts.visitEachChild(node, visitor, context); @@ -37940,7 +39005,7 @@ var ts; } } function visitFunctionDeclaration(node) { - if (node.asteriskToken && node.emitFlags & 2097152) { + if (node.asteriskToken && ts.getEmitFlags(node) & 2097152) { node = ts.setOriginalNode(ts.createFunctionDeclaration(undefined, undefined, undefined, node.name, undefined, node.parameters, undefined, transformGeneratorFunctionBody(node.body), node), node); } else { @@ -37961,7 +39026,7 @@ var ts; } } function visitFunctionExpression(node) { - if (node.asteriskToken && node.emitFlags & 2097152) { + if (node.asteriskToken && ts.getEmitFlags(node) & 2097152) { node = ts.setOriginalNode(ts.createFunctionExpression(undefined, node.name, undefined, node.parameters, undefined, transformGeneratorFunctionBody(node.body), node), node); } else { @@ -37992,6 +39057,7 @@ var ts; var savedBlocks = blocks; var savedBlockOffsets = blockOffsets; var savedBlockActions = blockActions; + var savedBlockStack = blockStack; var savedLabelOffsets = labelOffsets; var savedLabelExpressions = labelExpressions; var savedNextLabelId = nextLabelId; @@ -38004,6 +39070,7 @@ var ts; blocks = undefined; blockOffsets = undefined; blockActions = undefined; + blockStack = undefined; labelOffsets = undefined; labelExpressions = undefined; nextLabelId = 1; @@ -38022,6 +39089,7 @@ var ts; blocks = savedBlocks; blockOffsets = savedBlockOffsets; blockActions = savedBlockActions; + blockStack = savedBlockStack; labelOffsets = savedLabelOffsets; labelExpressions = savedLabelExpressions; nextLabelId = savedNextLabelId; @@ -38037,7 +39105,7 @@ var ts; return undefined; } else { - if (node.emitFlags & 8388608) { + if (ts.getEmitFlags(node) & 8388608) { return node; } for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { @@ -38705,9 +39773,9 @@ var ts; } return -1; } - function onSubstituteNode(node, isExpression) { - node = previousOnSubstituteNode(node, isExpression); - if (isExpression) { + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1) { return substituteExpression(node); } return node; @@ -38724,11 +39792,11 @@ var ts; if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - var name_36 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); - if (name_36) { - var clone_7 = ts.getMutableClone(name_36); - setSourceMapRange(clone_7, node); - setCommentRange(clone_7, node); + var name_37 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); + if (name_37) { + var clone_7 = ts.getMutableClone(name_37); + ts.setSourceMapRange(clone_7, node); + ts.setCommentRange(clone_7, node); return clone_7; } } @@ -39122,7 +40190,7 @@ var ts; var buildResult = buildStatements(); return ts.createCall(ts.createHelperName(currentSourceFile.externalHelpersModuleName, "__generator"), undefined, [ ts.createThis(), - setNodeEmitFlags(ts.createFunctionExpression(undefined, undefined, undefined, [ts.createParameter(state)], undefined, ts.createBlock(buildResult, undefined, buildResult.length > 0)), 4194304) + ts.setEmitFlags(ts.createFunctionExpression(undefined, undefined, undefined, [ts.createParameter(state)], undefined, ts.createBlock(buildResult, undefined, buildResult.length > 0)), 4194304) ]); } function buildStatements() { @@ -39391,7 +40459,7 @@ var ts; var ts; (function (ts) { function transformES6(context) { - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration, getNodeEmitFlags = context.getNodeEmitFlags, setNodeEmitFlags = context.setNodeEmitFlags, getCommentRange = context.getCommentRange, setCommentRange = context.setCommentRange, getSourceMapRange = context.getSourceMapRange, setSourceMapRange = context.setSourceMapRange, setTokenSourceMapRange = context.setTokenSourceMapRange; + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); var previousOnSubstituteNode = context.onSubstituteNode; var previousOnEmitNode = context.onEmitNode; @@ -39411,6 +40479,9 @@ var ts; var enabledSubstitutions; return transformSourceFile; function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } currentSourceFile = node; currentText = node.text; return ts.visitNode(node, visitor, ts.isSourceFile); @@ -39580,7 +40651,7 @@ var ts; enclosingFunction = currentNode; if (currentNode.kind !== 180) { enclosingNonArrowFunction = currentNode; - if (!(currentNode.emitFlags & 2097152)) { + if (!(ts.getEmitFlags(currentNode) & 2097152)) { enclosingNonAsyncFunctionBody = currentNode; } } @@ -39717,15 +40788,15 @@ var ts; } var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); var classFunction = ts.createFunctionExpression(undefined, undefined, undefined, extendsClauseElement ? [ts.createParameter("_super")] : [], undefined, transformClassBody(node, extendsClauseElement)); - if (getNodeEmitFlags(node) & 524288) { - setNodeEmitFlags(classFunction, 524288); + if (ts.getEmitFlags(node) & 524288) { + ts.setEmitFlags(classFunction, 524288); } var inner = ts.createPartiallyEmittedExpression(classFunction); inner.end = node.end; - setNodeEmitFlags(inner, 49152); + ts.setEmitFlags(inner, 49152); var outer = ts.createPartiallyEmittedExpression(inner); outer.end = ts.skipTrivia(currentText, node.pos); - setNodeEmitFlags(outer, 49152); + ts.setEmitFlags(outer, 49152); return ts.createParen(ts.createCall(outer, undefined, extendsClauseElement ? [ts.visitNode(extendsClauseElement.expression, visitor, ts.isExpression)] : [])); @@ -39740,14 +40811,14 @@ var ts; var localName = getLocalName(node); var outer = ts.createPartiallyEmittedExpression(localName); outer.end = closingBraceLocation.end; - setNodeEmitFlags(outer, 49152); + ts.setEmitFlags(outer, 49152); var statement = ts.createReturn(outer); statement.pos = closingBraceLocation.pos; - setNodeEmitFlags(statement, 49152 | 12288); + ts.setEmitFlags(statement, 49152 | 12288); statements.push(statement); ts.addRange(statements, endLexicalEnvironment()); var block = ts.createBlock(ts.createNodeArray(statements, node.members), undefined, true); - setNodeEmitFlags(block, 49152); + ts.setEmitFlags(block, 49152); return block; } function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) { @@ -39758,7 +40829,11 @@ var ts; function addConstructor(statements, node, extendsClauseElement) { var constructor = ts.getFirstConstructorWithBody(node); var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); - statements.push(ts.createFunctionDeclaration(undefined, undefined, undefined, getDeclarationName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), constructor || node)); + var constructorFunction = ts.createFunctionDeclaration(undefined, undefined, undefined, getDeclarationName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), constructor || node); + if (extendsClauseElement) { + ts.setEmitFlags(constructorFunction, 256); + } + statements.push(constructorFunction); } function transformConstructorParameters(constructor, hasSynthesizedSuper) { if (constructor && !hasSynthesizedSuper) { @@ -39769,33 +40844,98 @@ var ts; function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { var statements = []; startLexicalEnvironment(); + var statementOffset = -1; + if (hasSynthesizedSuper) { + statementOffset = 1; + } + else if (constructor) { + statementOffset = ts.addPrologueDirectives(statements, constructor.body.statements, false, visitor); + } if (constructor) { - addCaptureThisForNodeIfNeeded(statements, constructor); addDefaultValueAssignmentsIfNeeded(statements, constructor); addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); + ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); + } + var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, !!extendsClauseElement, hasSynthesizedSuper, statementOffset); + if (superCaptureStatus === 1 || superCaptureStatus === 2) { + statementOffset++; } - addDefaultSuperCallIfNeeded(statements, constructor, extendsClauseElement, hasSynthesizedSuper); if (constructor) { - var body = saveStateAndInvoke(constructor, hasSynthesizedSuper ? transformConstructorBodyWithSynthesizedSuper : transformConstructorBodyWithoutSynthesizedSuper); + var body = saveStateAndInvoke(constructor, function (constructor) { return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset); }); ts.addRange(statements, body); } + if (extendsClauseElement + && superCaptureStatus !== 2 + && !(constructor && isSufficientlyCoveredByReturnStatements(constructor.body))) { + statements.push(ts.createReturn(ts.createIdentifier("_this"))); + } ts.addRange(statements, endLexicalEnvironment()); var block = ts.createBlock(ts.createNodeArray(statements, constructor ? constructor.body.statements : node.members), constructor ? constructor.body : node, true); if (!constructor) { - setNodeEmitFlags(block, 49152); + ts.setEmitFlags(block, 49152); } return block; } - function transformConstructorBodyWithSynthesizedSuper(node) { - return ts.visitNodes(node.body.statements, visitor, ts.isStatement, 1); - } - function transformConstructorBodyWithoutSynthesizedSuper(node) { - return ts.visitNodes(node.body.statements, visitor, ts.isStatement, 0); - } - function addDefaultSuperCallIfNeeded(statements, constructor, extendsClauseElement, hasSynthesizedSuper) { - if (constructor ? hasSynthesizedSuper : extendsClauseElement) { - statements.push(ts.createStatement(ts.createFunctionApply(ts.createIdentifier("_super"), ts.createThis(), ts.createIdentifier("arguments")), extendsClauseElement)); + function isSufficientlyCoveredByReturnStatements(statement) { + if (statement.kind === 211) { + return true; } + else if (statement.kind === 203) { + var ifStatement = statement; + if (ifStatement.elseStatement) { + return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && + isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); + } + } + else if (statement.kind === 199) { + var lastStatement = ts.lastOrUndefined(statement.statements); + if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { + return true; + } + } + return false; + } + function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, hasExtendsClause, hasSynthesizedSuper, statementOffset) { + if (!hasExtendsClause) { + if (ctor) { + addCaptureThisForNodeIfNeeded(statements, ctor); + } + return 0; + } + if (!ctor) { + statements.push(ts.createReturn(createDefaultSuperCallOrThis())); + return 2; + } + if (hasSynthesizedSuper) { + captureThisForNode(statements, ctor, createDefaultSuperCallOrThis()); + enableSubstitutionsForCapturedThis(); + return 1; + } + var firstStatement; + var superCallExpression; + var ctorStatements = ctor.body.statements; + if (statementOffset < ctorStatements.length) { + firstStatement = ctorStatements[statementOffset]; + if (firstStatement.kind === 202 && ts.isSuperCall(firstStatement.expression)) { + var superCall = firstStatement.expression; + superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); + } + } + if (superCallExpression && statementOffset === ctorStatements.length - 1) { + statements.push(ts.createReturn(superCallExpression)); + return 2; + } + captureThisForNode(statements, ctor, superCallExpression, firstStatement); + if (superCallExpression) { + return 1; + } + return 0; + } + function createDefaultSuperCallOrThis() { + var actualThis = ts.createThis(); + ts.setEmitFlags(actualThis, 128); + var superCall = ts.createFunctionApply(ts.createIdentifier("_super"), actualThis, ts.createIdentifier("arguments")); + return ts.createLogicalOr(superCall, actualThis); } function visitParameter(node) { if (node.dotDotDotToken) { @@ -39820,34 +40960,34 @@ var ts; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { var parameter = _a[_i]; - var name_37 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; + var name_38 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; if (dotDotDotToken) { continue; } - if (ts.isBindingPattern(name_37)) { - addDefaultValueAssignmentForBindingPattern(statements, parameter, name_37, initializer); + if (ts.isBindingPattern(name_38)) { + addDefaultValueAssignmentForBindingPattern(statements, parameter, name_38, initializer); } else if (initializer) { - addDefaultValueAssignmentForInitializer(statements, parameter, name_37, initializer); + addDefaultValueAssignmentForInitializer(statements, parameter, name_38, initializer); } } } function addDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer) { var temp = ts.getGeneratedNameForNode(parameter); if (name.elements.length > 0) { - statements.push(setNodeEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(ts.flattenParameterDestructuring(context, parameter, temp, visitor))), 8388608)); + statements.push(ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(ts.flattenParameterDestructuring(context, parameter, temp, visitor))), 8388608)); } else if (initializer) { - statements.push(setNodeEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 8388608)); + statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 8388608)); } } function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) { initializer = ts.visitNode(initializer, visitor, ts.isExpression); - var statement = ts.createIf(ts.createStrictEquality(ts.getSynthesizedClone(name), ts.createVoidZero()), setNodeEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(setNodeEmitFlags(ts.getMutableClone(name), 1536), setNodeEmitFlags(initializer, 1536 | getNodeEmitFlags(initializer)), parameter)) + var statement = ts.createIf(ts.createStrictEquality(ts.getSynthesizedClone(name), ts.createVoidZero()), ts.setEmitFlags(ts.createBlock([ + ts.createStatement(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 1536), ts.setEmitFlags(initializer, 1536 | ts.getEmitFlags(initializer)), parameter)) ], parameter), 32 | 1024 | 12288), undefined, parameter); statement.startsOnNewLine = true; - setNodeEmitFlags(statement, 12288 | 1024 | 8388608); + ts.setEmitFlags(statement, 12288 | 1024 | 8388608); statements.push(statement); } function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) { @@ -39859,11 +40999,11 @@ var ts; return; } var declarationName = ts.getMutableClone(parameter.name); - setNodeEmitFlags(declarationName, 1536); + ts.setEmitFlags(declarationName, 1536); var expressionName = ts.getSynthesizedClone(parameter.name); var restIndex = node.parameters.length - 1; var temp = ts.createLoopVariable(); - statements.push(setNodeEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + statements.push(ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration(declarationName, undefined, ts.createArrayLiteral([])) ]), parameter), 8388608)); var forStatement = ts.createFor(ts.createVariableDeclarationList([ @@ -39871,21 +41011,24 @@ var ts; ], parameter), ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length"), parameter), ts.createPostfixIncrement(temp, parameter), ts.createBlock([ ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp)), parameter)) ])); - setNodeEmitFlags(forStatement, 8388608); + ts.setEmitFlags(forStatement, 8388608); ts.startOnNewLine(forStatement); statements.push(forStatement); } function addCaptureThisForNodeIfNeeded(statements, node) { if (node.transformFlags & 16384 && node.kind !== 180) { - enableSubstitutionsForCapturedThis(); - var captureThisStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration("_this", undefined, ts.createThis()) - ])); - setNodeEmitFlags(captureThisStatement, 49152 | 8388608); - setSourceMapRange(captureThisStatement, node); - statements.push(captureThisStatement); + captureThisForNode(statements, node, ts.createThis()); } } + function captureThisForNode(statements, node, initializer, originalStatement) { + enableSubstitutionsForCapturedThis(); + var captureThisStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration("_this", undefined, initializer) + ]), originalStatement); + ts.setEmitFlags(captureThisStatement, 49152 | 8388608); + ts.setSourceMapRange(captureThisStatement, node); + statements.push(captureThisStatement); + } function addClassMembers(statements, node) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; @@ -39915,43 +41058,43 @@ var ts; return ts.createEmptyStatement(member); } function transformClassMethodDeclarationToStatement(receiver, member) { - var commentRange = getCommentRange(member); - var sourceMapRange = getSourceMapRange(member); + var commentRange = ts.getCommentRange(member); + var sourceMapRange = ts.getSourceMapRange(member); var func = transformFunctionLikeToExpression(member, member, undefined); - setNodeEmitFlags(func, 49152); - setSourceMapRange(func, sourceMapRange); + ts.setEmitFlags(func, 49152); + ts.setSourceMapRange(func, sourceMapRange); var statement = ts.createStatement(ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), member.name), func), member); ts.setOriginalNode(statement, member); - setCommentRange(statement, commentRange); - setNodeEmitFlags(statement, 1536); + ts.setCommentRange(statement, commentRange); + ts.setEmitFlags(statement, 1536); return statement; } function transformAccessorsToStatement(receiver, accessors) { - var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, false), getSourceMapRange(accessors.firstAccessor)); - setNodeEmitFlags(statement, 49152); + var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, false), ts.getSourceMapRange(accessors.firstAccessor)); + ts.setEmitFlags(statement, 49152); return statement; } function transformAccessorsToExpression(receiver, _a, startsOnNewLine) { var firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; var target = ts.getMutableClone(receiver); - setNodeEmitFlags(target, 49152 | 1024); - setSourceMapRange(target, firstAccessor.name); + ts.setEmitFlags(target, 49152 | 1024); + ts.setSourceMapRange(target, firstAccessor.name); var propertyName = ts.createExpressionForPropertyName(ts.visitNode(firstAccessor.name, visitor, ts.isPropertyName)); - setNodeEmitFlags(propertyName, 49152 | 512); - setSourceMapRange(propertyName, firstAccessor.name); + ts.setEmitFlags(propertyName, 49152 | 512); + ts.setSourceMapRange(propertyName, firstAccessor.name); var properties = []; if (getAccessor) { var getterFunction = transformFunctionLikeToExpression(getAccessor, undefined, undefined); - setSourceMapRange(getterFunction, getSourceMapRange(getAccessor)); + ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); var getter = ts.createPropertyAssignment("get", getterFunction); - setCommentRange(getter, getCommentRange(getAccessor)); + ts.setCommentRange(getter, ts.getCommentRange(getAccessor)); properties.push(getter); } if (setAccessor) { var setterFunction = transformFunctionLikeToExpression(setAccessor, undefined, undefined); - setSourceMapRange(setterFunction, getSourceMapRange(setAccessor)); + ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); var setter = ts.createPropertyAssignment("set", setterFunction); - setCommentRange(setter, getCommentRange(setAccessor)); + ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); properties.push(setter); } properties.push(ts.createPropertyAssignment("enumerable", ts.createLiteral(true)), ts.createPropertyAssignment("configurable", ts.createLiteral(true))); @@ -39970,7 +41113,7 @@ var ts; enableSubstitutionsForCapturedThis(); } var func = transformFunctionLikeToExpression(node, node, undefined); - setNodeEmitFlags(func, 256); + ts.setEmitFlags(func, 256); return func; } function visitFunctionExpression(node) { @@ -40027,7 +41170,7 @@ var ts; } var expression = ts.visitNode(body, visitor, ts.isExpression); var returnStatement = ts.createReturn(expression, body); - setNodeEmitFlags(returnStatement, 12288 | 1024 | 32768); + ts.setEmitFlags(returnStatement, 12288 | 1024 | 32768); statements.push(returnStatement); closeBraceLocation = body; } @@ -40038,10 +41181,10 @@ var ts; } var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), node.body, multiLine); if (!multiLine && singleLine) { - setNodeEmitFlags(block, 32); + ts.setEmitFlags(block, 32); } if (closeBraceLocation) { - setTokenSourceMapRange(block, 16, closeBraceLocation); + ts.setTokenSourceMapRange(block, 16, closeBraceLocation); } ts.setOriginalNode(block, node.body); return block; @@ -40082,7 +41225,7 @@ var ts; assignment = ts.flattenVariableDestructuringToExpression(context, decl, hoistVariableDeclaration, undefined, visitor); } else { - assignment = ts.createBinary(decl.name, 56, decl.initializer); + assignment = ts.createBinary(decl.name, 56, ts.visitNode(decl.initializer, visitor, ts.isExpression)); } (assignments || (assignments = [])).push(assignment); } @@ -40105,13 +41248,13 @@ var ts; : visitVariableDeclaration)); var declarationList = ts.createVariableDeclarationList(declarations, node); ts.setOriginalNode(declarationList, node); - setCommentRange(declarationList, node); + ts.setCommentRange(declarationList, node); if (node.transformFlags & 2097152 && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { var firstDeclaration = ts.firstOrUndefined(declarations); var lastDeclaration = ts.lastOrUndefined(declarations); - setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); } return declarationList; } @@ -40206,7 +41349,7 @@ var ts; ts.setOriginalNode(declarationList, initializer); var firstDeclaration = declarations[0]; var lastDeclaration = ts.lastOrUndefined(declarations); - setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); statements.push(ts.createVariableStatement(undefined, declarationList)); } else { @@ -40241,14 +41384,14 @@ var ts; statements.push(statement); } } - setNodeEmitFlags(expression, 1536 | getNodeEmitFlags(expression)); + ts.setEmitFlags(expression, 1536 | ts.getEmitFlags(expression)); var body = ts.createBlock(ts.createNodeArray(statements, statementsLocation), bodyLocation); - setNodeEmitFlags(body, 1536 | 12288); + ts.setEmitFlags(body, 1536 | 12288); var forStatement = ts.createFor(ts.createVariableDeclarationList([ ts.createVariableDeclaration(counter, undefined, ts.createLiteral(0), ts.moveRangePos(node.expression, -1)), ts.createVariableDeclaration(rhsReference, undefined, expression, node.expression) ], node.expression), ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length"), node.expression), ts.createPostfixIncrement(counter, node.expression), body, node); - setNodeEmitFlags(forStatement, 8192); + ts.setEmitFlags(forStatement, 8192); return forStatement; } function visitObjectLiteralExpression(node) { @@ -40266,7 +41409,7 @@ var ts; ts.Debug.assert(numInitialProperties !== numProperties); var temp = ts.createTempVariable(hoistVariableDeclaration); var expressions = []; - var assignment = ts.createAssignment(temp, setNodeEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), undefined, node.multiLine), 524288)); + var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), undefined, node.multiLine), 524288)); if (node.multiLine) { assignment.startsOnNewLine = true; } @@ -40355,7 +41498,7 @@ var ts; loopBody = ts.createBlock([loopBody], undefined, true); } var isAsyncBlockContainingAwait = enclosingNonArrowFunction - && (enclosingNonArrowFunction.emitFlags & 2097152) !== 0 + && (ts.getEmitFlags(enclosingNonArrowFunction) & 2097152) !== 0 && (node.statement.transformFlags & 4194304) !== 0; var loopBodyFlags = 0; if (currentState.containsLexicalThis) { @@ -40365,7 +41508,7 @@ var ts; loopBodyFlags |= 2097152; } var convertedLoopVariable = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(functionName, undefined, setNodeEmitFlags(ts.createFunctionExpression(isAsyncBlockContainingAwait ? ts.createToken(37) : undefined, undefined, undefined, loopParameters, undefined, loopBody), loopBodyFlags)) + ts.createVariableDeclaration(functionName, undefined, ts.setEmitFlags(ts.createFunctionExpression(isAsyncBlockContainingAwait ? ts.createToken(37) : undefined, undefined, undefined, loopParameters, undefined, loopBody), loopBodyFlags)) ])); var statements = [convertedLoopVariable]; var extraVariableDeclarations; @@ -40393,8 +41536,8 @@ var ts; if (!extraVariableDeclarations) { extraVariableDeclarations = []; } - for (var name_38 in currentState.hoistedLocalVariables) { - var identifier = currentState.hoistedLocalVariables[name_38]; + for (var _b = 0, _c = currentState.hoistedLocalVariables; _b < _c.length; _b++) { + var identifier = _c[_b]; extraVariableDeclarations.push(ts.createVariableDeclaration(identifier)); } } @@ -40403,8 +41546,8 @@ var ts; if (!extraVariableDeclarations) { extraVariableDeclarations = []; } - for (var _b = 0, loopOutParameters_1 = loopOutParameters; _b < loopOutParameters_1.length; _b++) { - var outParam = loopOutParameters_1[_b]; + for (var _d = 0, loopOutParameters_1 = loopOutParameters; _d < loopOutParameters_1.length; _d++) { + var outParam = loopOutParameters_1[_d]; extraVariableDeclarations.push(ts.createVariableDeclaration(outParam.outParamName)); } } @@ -40582,7 +41725,7 @@ var ts; function visitMethodDeclaration(node) { ts.Debug.assert(!ts.isComputedPropertyName(node.name)); var functionExpression = transformFunctionLikeToExpression(node, ts.moveRangePos(node, -1), undefined); - setNodeEmitFlags(functionExpression, 16384 | getNodeEmitFlags(functionExpression)); + ts.setEmitFlags(functionExpression, 16384 | ts.getEmitFlags(functionExpression)); return ts.createPropertyAssignment(node.name, functionExpression, node); } function visitShorthandPropertyAssignment(node) { @@ -40595,13 +41738,32 @@ var ts; return transformAndSpreadElements(node.elements, true, node.multiLine, node.elements.hasTrailingComma); } function visitCallExpression(node) { + return visitCallExpressionWithPotentialCapturedThisAssignment(node, true); + } + function visitImmediateSuperCallInBody(node) { + return visitCallExpressionWithPotentialCapturedThisAssignment(node, false); + } + function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) { var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; + if (node.expression.kind === 95) { + ts.setEmitFlags(thisArg, 128); + } + var resultingCall; if (node.transformFlags & 262144) { - return ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, false, false, false)); + resultingCall = ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, false, false, false)); } else { - return ts.createFunctionCall(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), node); + resultingCall = ts.createFunctionCall(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), node); } + if (node.expression.kind === 95) { + var actualThis = ts.createThis(); + ts.setEmitFlags(actualThis, 128); + var initializer = ts.createLogicalOr(resultingCall, actualThis); + return assignToCapturedThis + ? ts.createAssignment(ts.createIdentifier("_this"), initializer) + : initializer; + } + return resultingCall; } function visitNewExpression(node) { ts.Debug.assert((node.transformFlags & 262144) !== 0); @@ -40721,12 +41883,12 @@ var ts; clone.statements = ts.createNodeArray(statements, node.statements); return clone; } - function onEmitNode(node, emit) { + function onEmitNode(emitContext, node, emitCallback) { var savedEnclosingFunction = enclosingFunction; if (enabledSubstitutions & 1 && ts.isFunctionLike(node)) { enclosingFunction = node; } - previousOnEmitNode(node, emit); + previousOnEmitNode(emitContext, node, emitCallback); enclosingFunction = savedEnclosingFunction; } function enableSubstitutionsForBlockScopedBindings() { @@ -40748,9 +41910,9 @@ var ts; context.enableEmitNotification(220); } } - function onSubstituteNode(node, isExpression) { - node = previousOnSubstituteNode(node, isExpression); - if (isExpression) { + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1) { return substituteExpression(node); } if (ts.isIdentifier(node)) { @@ -40800,7 +41962,7 @@ var ts; function substituteThisKeyword(node) { if (enabledSubstitutions & 1 && enclosingFunction - && enclosingFunction.emitFlags & 256) { + && ts.getEmitFlags(enclosingFunction) & 256) { return ts.createIdentifier("_this", node); } return node; @@ -40811,7 +41973,7 @@ var ts; function getDeclarationName(node, allowComments, allowSourceMaps, emitFlags) { if (node.name && !ts.isGeneratedIdentifier(node.name)) { var name_39 = ts.getMutableClone(node.name); - emitFlags |= getNodeEmitFlags(node.name); + emitFlags |= ts.getEmitFlags(node.name); if (!allowSourceMaps) { emitFlags |= 1536; } @@ -40819,7 +41981,7 @@ var ts; emitFlags |= 49152; } if (emitFlags) { - setNodeEmitFlags(name_39, emitFlags); + ts.setEmitFlags(name_39, emitFlags); } return name_39; } @@ -40868,8 +42030,7 @@ var ts; _a[ts.ModuleKind.CommonJS] = ts.transformModule, _a[ts.ModuleKind.UMD] = ts.transformModule, _a[ts.ModuleKind.None] = ts.transformModule, - _a - )); + _a)); function getTransformers(compilerOptions) { var jsx = compilerOptions.jsx; var languageVersion = ts.getEmitScriptTarget(compilerOptions); @@ -40888,18 +42049,10 @@ var ts; return transformers; } ts.getTransformers = getTransformers; - var nextTransformId = 1; function transformFiles(resolver, host, sourceFiles, transformers) { - var transformId = nextTransformId; - nextTransformId++; - var tokenSourceMapRanges = ts.createMap(); var lexicalEnvironmentVariableDeclarationsStack = []; var lexicalEnvironmentFunctionDeclarationsStack = []; var enabledSyntaxKindFeatures = new Array(289); - var parseTreeNodesWithAnnotations = []; - var lastTokenSourceMapRangeNode; - var lastTokenSourceMapRangeToken; - var lastTokenSourceMapRange; var lexicalEnvironmentStackOffset = 0; var hoistedVariableDeclarations; var hoistedFunctionDeclarations; @@ -40908,47 +42061,24 @@ var ts; getCompilerOptions: function () { return host.getCompilerOptions(); }, getEmitResolver: function () { return resolver; }, getEmitHost: function () { return host; }, - getNodeEmitFlags: getNodeEmitFlags, - setNodeEmitFlags: setNodeEmitFlags, - getSourceMapRange: getSourceMapRange, - setSourceMapRange: setSourceMapRange, - getTokenSourceMapRange: getTokenSourceMapRange, - setTokenSourceMapRange: setTokenSourceMapRange, - getCommentRange: getCommentRange, - setCommentRange: setCommentRange, hoistVariableDeclaration: hoistVariableDeclaration, hoistFunctionDeclaration: hoistFunctionDeclaration, startLexicalEnvironment: startLexicalEnvironment, endLexicalEnvironment: endLexicalEnvironment, - onSubstituteNode: onSubstituteNode, + onSubstituteNode: function (emitContext, node) { return node; }, enableSubstitution: enableSubstitution, isSubstitutionEnabled: isSubstitutionEnabled, - onEmitNode: onEmitNode, + onEmitNode: function (node, emitContext, emitCallback) { return emitCallback(node, emitContext); }, enableEmitNotification: enableEmitNotification, isEmitNotificationEnabled: isEmitNotificationEnabled }; - var transformation = chain.apply(void 0, transformers)(context); + var transformation = ts.chain.apply(void 0, transformers)(context); var transformed = ts.map(sourceFiles, transformSourceFile); lexicalEnvironmentDisabled = true; return { - getSourceFiles: function () { return transformed; }, - getTokenSourceMapRange: getTokenSourceMapRange, - isSubstitutionEnabled: isSubstitutionEnabled, - isEmitNotificationEnabled: isEmitNotificationEnabled, - onSubstituteNode: context.onSubstituteNode, - onEmitNode: context.onEmitNode, - dispose: function () { - for (var _i = 0, parseTreeNodesWithAnnotations_1 = parseTreeNodesWithAnnotations; _i < parseTreeNodesWithAnnotations_1.length; _i++) { - var node = parseTreeNodesWithAnnotations_1[_i]; - if (node.transformId === transformId) { - node.transformId = 0; - node.emitFlags = 0; - node.commentRange = undefined; - node.sourceMapRange = undefined; - } - } - parseTreeNodesWithAnnotations.length = 0; - } + transformed: transformed, + emitNodeWithSubstitution: emitNodeWithSubstitution, + emitNodeWithNotification: emitNodeWithNotification }; function transformSourceFile(sourceFile) { if (ts.isDeclarationFile(sourceFile)) { @@ -40960,75 +42090,37 @@ var ts; enabledSyntaxKindFeatures[kind] |= 1; } function isSubstitutionEnabled(node) { - return (enabledSyntaxKindFeatures[node.kind] & 1) !== 0; + return (enabledSyntaxKindFeatures[node.kind] & 1) !== 0 + && (ts.getEmitFlags(node) & 128) === 0; } - function onSubstituteNode(node, isExpression) { - return node; + function emitNodeWithSubstitution(emitContext, node, emitCallback) { + if (node) { + if (isSubstitutionEnabled(node)) { + var substitute = context.onSubstituteNode(emitContext, node); + if (substitute && substitute !== node) { + emitCallback(emitContext, substitute); + return; + } + } + emitCallback(emitContext, node); + } } function enableEmitNotification(kind) { enabledSyntaxKindFeatures[kind] |= 2; } function isEmitNotificationEnabled(node) { return (enabledSyntaxKindFeatures[node.kind] & 2) !== 0 - || (getNodeEmitFlags(node) & 64) !== 0; + || (ts.getEmitFlags(node) & 64) !== 0; } - function onEmitNode(node, emit) { - emit(node); - } - function beforeSetAnnotation(node) { - if ((node.flags & 8) === 0 && node.transformId !== transformId) { - parseTreeNodesWithAnnotations.push(node); - node.transformId = transformId; - } - } - function getNodeEmitFlags(node) { - return node.emitFlags; - } - function setNodeEmitFlags(node, emitFlags) { - beforeSetAnnotation(node); - node.emitFlags = emitFlags; - return node; - } - function getSourceMapRange(node) { - return node.sourceMapRange || node; - } - function setSourceMapRange(node, range) { - beforeSetAnnotation(node); - node.sourceMapRange = range; - return node; - } - function getTokenSourceMapRange(node, token) { - if (lastTokenSourceMapRangeNode === node && lastTokenSourceMapRangeToken === token) { - return lastTokenSourceMapRange; - } - var range; - var current = node; - while (current) { - range = current.id ? tokenSourceMapRanges[current.id + "-" + token] : undefined; - if (range !== undefined) { - break; + function emitNodeWithNotification(emitContext, node, emitCallback) { + if (node) { + if (isEmitNotificationEnabled(node)) { + context.onEmitNode(emitContext, node, emitCallback); + } + else { + emitCallback(emitContext, node); } - current = current.original; } - lastTokenSourceMapRangeNode = node; - lastTokenSourceMapRangeToken = token; - lastTokenSourceMapRange = range; - return range; - } - function setTokenSourceMapRange(node, token, range) { - lastTokenSourceMapRangeNode = node; - lastTokenSourceMapRangeToken = token; - lastTokenSourceMapRange = range; - tokenSourceMapRanges[ts.getNodeId(node) + "-" + token] = range; - return node; - } - function getCommentRange(node) { - return node.commentRange || node; - } - function setCommentRange(node, range) { - beforeSetAnnotation(node); - node.commentRange = range; - return node; } function hoistVariableDeclaration(name) { ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot modify the lexical environment during the print phase."); @@ -41081,93 +42173,10 @@ var ts; } } ts.transformFiles = transformFiles; - function chain(a, b, c, d, e) { - if (e) { - var args_3 = []; - for (var i = 0; i < arguments.length; i++) { - args_3[i] = arguments[i]; - } - return function (t) { return compose.apply(void 0, ts.map(args_3, function (f) { return f(t); })); }; - } - else if (d) { - return function (t) { return compose(a(t), b(t), c(t), d(t)); }; - } - else if (c) { - return function (t) { return compose(a(t), b(t), c(t)); }; - } - else if (b) { - return function (t) { return compose(a(t), b(t)); }; - } - else if (a) { - return function (t) { return compose(a(t)); }; - } - else { - return function (t) { return function (u) { return u; }; }; - } - } - function compose(a, b, c, d, e) { - if (e) { - var args_4 = []; - for (var i = 0; i < arguments.length; i++) { - args_4[i] = arguments[i]; - } - return function (t) { return ts.reduceLeft(args_4, function (u, f) { return f(u); }, t); }; - } - else if (d) { - return function (t) { return d(c(b(a(t)))); }; - } - else if (c) { - return function (t) { return c(b(a(t))); }; - } - else if (b) { - return function (t) { return b(a(t)); }; - } - else if (a) { - return function (t) { return a(t); }; - } - else { - return function (t) { return t; }; - } - } var _a; })(ts || (ts = {})); var ts; (function (ts) { - function createSourceMapWriter(host, writer) { - var compilerOptions = host.getCompilerOptions(); - if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) { - if (compilerOptions.extendedDiagnostics) { - return createSourceMapWriterWithExtendedDiagnostics(host, writer); - } - return createSourceMapWriterWorker(host, writer); - } - else { - return getNullSourceMapWriter(); - } - } - ts.createSourceMapWriter = createSourceMapWriter; - var nullSourceMapWriter; - function getNullSourceMapWriter() { - if (nullSourceMapWriter === undefined) { - nullSourceMapWriter = { - initialize: function (filePath, sourceMapFilePath, sourceFiles, isBundledEmit) { }, - reset: function () { }, - getSourceMapData: function () { return undefined; }, - setSourceFile: function (sourceFile) { }, - emitPos: function (pos) { }, - emitStart: function (range, contextNode, ignoreNodeCallback, ignoreChildrenCallback, getTextRangeCallback) { }, - emitEnd: function (range, contextNode, ignoreNodeCallback, ignoreChildrenCallback, getTextRangeCallback) { }, - emitTokenStart: function (token, pos, contextNode, ignoreTokenCallback, getTokenTextRangeCallback) { return -1; }, - emitTokenEnd: function (token, end, contextNode, ignoreTokenCallback, getTokenTextRangeCallback) { return -1; }, - changeEmitSourcePos: function () { }, - stopOverridingSpan: function () { }, - getText: function () { return undefined; }, - getSourceMappingURL: function () { return undefined; } - }; - } - return nullSourceMapWriter; - } - ts.getNullSourceMapWriter = getNullSourceMapWriter; var defaultLastEncodedSourceMapSpan = { emittedLine: 1, emittedColumn: 1, @@ -41175,42 +42184,38 @@ var ts; sourceColumn: 1, sourceIndex: 0 }; - function createSourceMapWriterWorker(host, writer) { + function createSourceMapWriter(host, writer) { var compilerOptions = host.getCompilerOptions(); var extendedDiagnostics = compilerOptions.extendedDiagnostics; var currentSourceFile; var currentSourceText; var sourceMapDir; - var stopOverridingSpan = false; - var modifyLastSourcePos = false; var sourceMapSourceIndex; var lastRecordedSourceMapSpan; var lastEncodedSourceMapSpan; var lastEncodedNameIndex; var sourceMapData; - var disableDepth; + var disabled = !(compilerOptions.sourceMap || compilerOptions.inlineSourceMap); return { initialize: initialize, reset: reset, getSourceMapData: function () { return sourceMapData; }, setSourceFile: setSourceFile, emitPos: emitPos, - emitStart: emitStart, - emitEnd: emitEnd, - emitTokenStart: emitTokenStart, - emitTokenEnd: emitTokenEnd, - changeEmitSourcePos: changeEmitSourcePos, - stopOverridingSpan: function () { return stopOverridingSpan = true; }, + emitNodeWithSourceMap: emitNodeWithSourceMap, + emitTokenWithSourceMap: emitTokenWithSourceMap, getText: getText, getSourceMappingURL: getSourceMappingURL }; function initialize(filePath, sourceMapFilePath, sourceFiles, isBundledEmit) { + if (disabled) { + return; + } if (sourceMapData) { reset(); } currentSourceFile = undefined; currentSourceText = undefined; - disableDepth = 0; sourceMapSourceIndex = -1; lastRecordedSourceMapSpan = undefined; lastEncodedSourceMapSpan = defaultLastEncodedSourceMapSpan; @@ -41250,6 +42255,9 @@ var ts; } } function reset() { + if (disabled) { + return; + } currentSourceFile = undefined; sourceMapDir = undefined; sourceMapSourceIndex = undefined; @@ -41257,38 +42265,6 @@ var ts; lastEncodedSourceMapSpan = undefined; lastEncodedNameIndex = undefined; sourceMapData = undefined; - disableDepth = 0; - } - function enable() { - if (disableDepth > 0) { - disableDepth--; - } - } - function disable() { - disableDepth++; - } - function updateLastEncodedAndRecordedSpans() { - if (modifyLastSourcePos) { - modifyLastSourcePos = false; - lastRecordedSourceMapSpan.emittedLine = lastEncodedSourceMapSpan.emittedLine; - lastRecordedSourceMapSpan.emittedColumn = lastEncodedSourceMapSpan.emittedColumn; - sourceMapData.sourceMapDecodedMappings.pop(); - lastEncodedSourceMapSpan = sourceMapData.sourceMapDecodedMappings.length ? - sourceMapData.sourceMapDecodedMappings[sourceMapData.sourceMapDecodedMappings.length - 1] : - defaultLastEncodedSourceMapSpan; - var sourceMapMappings = sourceMapData.sourceMapMappings; - var lenthToSet = sourceMapMappings.length - 1; - for (; lenthToSet >= 0; lenthToSet--) { - var currentChar = sourceMapMappings.charAt(lenthToSet); - if (currentChar === ",") { - break; - } - if (currentChar === ";" && lenthToSet !== 0 && sourceMapMappings.charAt(lenthToSet - 1) !== ";") { - break; - } - } - sourceMapData.sourceMapMappings = sourceMapMappings.substr(0, Math.max(0, lenthToSet)); - } } function encodeLastRecordedSourceMapSpan() { if (!lastRecordedSourceMapSpan || lastRecordedSourceMapSpan === lastEncodedSourceMapSpan) { @@ -41319,7 +42295,7 @@ var ts; sourceMapData.sourceMapDecodedMappings.push(lastEncodedSourceMapSpan); } function emitPos(pos) { - if (ts.positionIsSynthesized(pos) || disableDepth > 0) { + if (disabled || ts.positionIsSynthesized(pos)) { return; } if (extendedDiagnostics) { @@ -41344,84 +42320,68 @@ var ts; sourceColumn: sourceLinePos.character, sourceIndex: sourceMapSourceIndex }; - stopOverridingSpan = false; } - else if (!stopOverridingSpan) { + else { lastRecordedSourceMapSpan.sourceLine = sourceLinePos.line; lastRecordedSourceMapSpan.sourceColumn = sourceLinePos.character; lastRecordedSourceMapSpan.sourceIndex = sourceMapSourceIndex; } - updateLastEncodedAndRecordedSpans(); if (extendedDiagnostics) { ts.performance.mark("afterSourcemap"); ts.performance.measure("Source Map", "beforeSourcemap", "afterSourcemap"); } } - function getStartPosPastDecorators(range) { - var rangeHasDecorators = !!range.decorators; - return ts.skipTrivia(currentSourceText, rangeHasDecorators ? range.decorators.end : range.pos); - } - function emitStart(range, contextNode, ignoreNodeCallback, ignoreChildrenCallback, getTextRangeCallback) { - if (contextNode) { - if (!ignoreNodeCallback(contextNode)) { - range = getTextRangeCallback(contextNode) || range; - emitPos(getStartPosPastDecorators(range)); - } - if (ignoreChildrenCallback(contextNode)) { - disable(); - } + function emitNodeWithSourceMap(emitContext, node, emitCallback) { + if (disabled) { + return emitCallback(emitContext, node); } - else { - emitPos(getStartPosPastDecorators(range)); + if (node) { + var emitNode = node.emitNode; + var emitFlags = emitNode && emitNode.flags; + var _a = emitNode && emitNode.sourceMapRange || node, pos = _a.pos, end = _a.end; + if (node.kind !== 287 + && (emitFlags & 512) === 0 + && pos >= 0) { + emitPos(ts.skipTrivia(currentSourceText, pos)); + } + if (emitFlags & 2048) { + disabled = true; + emitCallback(emitContext, node); + disabled = false; + } + else { + emitCallback(emitContext, node); + } + if (node.kind !== 287 + && (emitFlags & 1024) === 0 + && end >= 0) { + emitPos(end); + } } } - function emitEnd(range, contextNode, ignoreNodeCallback, ignoreChildrenCallback, getTextRangeCallback) { - if (contextNode) { - if (ignoreChildrenCallback(contextNode)) { - enable(); - } - if (!ignoreNodeCallback(contextNode)) { - range = getTextRangeCallback(contextNode) || range; - emitPos(range.end); - } + function emitTokenWithSourceMap(node, token, tokenPos, emitCallback) { + if (disabled) { + return emitCallback(token, tokenPos); } - else { - emitPos(range.end); + var emitNode = node && node.emitNode; + var emitFlags = emitNode && emitNode.flags; + var range = emitNode && emitNode.tokenSourceMapRanges && emitNode.tokenSourceMapRanges[token]; + tokenPos = ts.skipTrivia(currentSourceText, range ? range.pos : tokenPos); + if ((emitFlags & 4096) === 0 && tokenPos >= 0) { + emitPos(tokenPos); } - stopOverridingSpan = false; - } - function emitTokenStart(token, tokenStartPos, contextNode, ignoreTokenCallback, getTokenTextRangeCallback) { - if (contextNode) { - if (ignoreTokenCallback(contextNode, token)) { - return ts.skipTrivia(currentSourceText, tokenStartPos); - } - var range = getTokenTextRangeCallback(contextNode, token); - if (range) { - tokenStartPos = range.pos; - } + tokenPos = emitCallback(token, tokenPos); + if (range) + tokenPos = range.end; + if ((emitFlags & 8192) === 0 && tokenPos >= 0) { + emitPos(tokenPos); } - tokenStartPos = ts.skipTrivia(currentSourceText, tokenStartPos); - emitPos(tokenStartPos); - return tokenStartPos; - } - function emitTokenEnd(token, tokenEndPos, contextNode, ignoreTokenCallback, getTokenTextRangeCallback) { - if (contextNode) { - if (ignoreTokenCallback(contextNode, token)) { - return tokenEndPos; - } - var range = getTokenTextRangeCallback(contextNode, token); - if (range) { - tokenEndPos = range.end; - } - } - emitPos(tokenEndPos); - return tokenEndPos; - } - function changeEmitSourcePos() { - ts.Debug.assert(!modifyLastSourcePos); - modifyLastSourcePos = true; + return tokenPos; } function setSourceFile(sourceFile) { + if (disabled) { + return; + } currentSourceFile = sourceFile; currentSourceText = currentSourceFile.text; var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; @@ -41437,6 +42397,9 @@ var ts; } } function getText() { + if (disabled) { + return; + } encodeLastRecordedSourceMapSpan(); return ts.stringify({ version: 3, @@ -41449,6 +42412,9 @@ var ts; }); } function getSourceMappingURL() { + if (disabled) { + return; + } if (compilerOptions.inlineSourceMap) { var base64SourceMapText = ts.convertToBase64(getText()); return sourceMapData.jsSourceMappingURL = "data:application/json;base64," + base64SourceMapText; @@ -41458,46 +42424,7 @@ var ts; } } } - function createSourceMapWriterWithExtendedDiagnostics(host, writer) { - var _a = createSourceMapWriterWorker(host, writer), initialize = _a.initialize, reset = _a.reset, getSourceMapData = _a.getSourceMapData, setSourceFile = _a.setSourceFile, emitPos = _a.emitPos, emitStart = _a.emitStart, emitEnd = _a.emitEnd, emitTokenStart = _a.emitTokenStart, emitTokenEnd = _a.emitTokenEnd, changeEmitSourcePos = _a.changeEmitSourcePos, stopOverridingSpan = _a.stopOverridingSpan, getText = _a.getText, getSourceMappingURL = _a.getSourceMappingURL; - return { - initialize: initialize, - reset: reset, - getSourceMapData: getSourceMapData, - setSourceFile: setSourceFile, - emitPos: function (pos) { - ts.performance.mark("sourcemapStart"); - emitPos(pos); - ts.performance.measure("sourceMapTime", "sourcemapStart"); - }, - emitStart: function (range, contextNode, ignoreNodeCallback, ignoreChildrenCallback, getTextRangeCallback) { - ts.performance.mark("emitSourcemap:emitStart"); - emitStart(range, contextNode, ignoreNodeCallback, ignoreChildrenCallback, getTextRangeCallback); - ts.performance.measure("sourceMapTime", "emitSourcemap:emitStart"); - }, - emitEnd: function (range, contextNode, ignoreNodeCallback, ignoreChildrenCallback, getTextRangeCallback) { - ts.performance.mark("emitSourcemap:emitEnd"); - emitEnd(range, contextNode, ignoreNodeCallback, ignoreChildrenCallback, getTextRangeCallback); - ts.performance.measure("sourceMapTime", "emitSourcemap:emitEnd"); - }, - emitTokenStart: function (token, tokenStartPos, contextNode, ignoreTokenCallback, getTokenTextRangeCallback) { - ts.performance.mark("emitSourcemap:emitTokenStart"); - tokenStartPos = emitTokenStart(token, tokenStartPos, contextNode, ignoreTokenCallback, getTokenTextRangeCallback); - ts.performance.measure("sourceMapTime", "emitSourcemap:emitTokenStart"); - return tokenStartPos; - }, - emitTokenEnd: function (token, tokenEndPos, contextNode, ignoreTokenCallback, getTokenTextRangeCallback) { - ts.performance.mark("emitSourcemap:emitTokenEnd"); - tokenEndPos = emitTokenEnd(token, tokenEndPos, contextNode, ignoreTokenCallback, getTokenTextRangeCallback); - ts.performance.measure("sourceMapTime", "emitSourcemap:emitTokenEnd"); - return tokenEndPos; - }, - changeEmitSourcePos: changeEmitSourcePos, - stopOverridingSpan: stopOverridingSpan, - getText: getText, - getSourceMappingURL: getSourceMappingURL - }; - } + ts.createSourceMapWriter = createSourceMapWriter; var base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; function base64FormatEncode(inValue) { if (inValue < 64) { @@ -41547,20 +42474,22 @@ var ts; emitBodyWithDetachedComments: emitBodyWithDetachedComments, emitTrailingCommentsOfPosition: emitTrailingCommentsOfPosition }; - function emitNodeWithComments(node, emitCallback) { + function emitNodeWithComments(emitContext, node, emitCallback) { if (disabled) { - emitCallback(node); + emitCallback(emitContext, node); return; } if (node) { - var _a = node.commentRange || node, pos = _a.pos, end = _a.end; - var emitFlags = node.emitFlags; + var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; + var emitFlags = ts.getEmitFlags(node); if ((pos < 0 && end < 0) || (pos === end)) { if (emitFlags & 65536) { - disableCommentsAndEmit(node, emitCallback); + disabled = true; + emitCallback(emitContext, node); + disabled = false; } else { - emitCallback(node); + emitCallback(emitContext, node); } } else { @@ -41589,10 +42518,12 @@ var ts; ts.performance.measure("commentTime", "preEmitNodeWithComment"); } if (emitFlags & 65536) { - disableCommentsAndEmit(node, emitCallback); + disabled = true; + emitCallback(emitContext, node); + disabled = false; } else { - emitCallback(node); + emitCallback(emitContext, node); } if (extendedDiagnostics) { ts.performance.mark("beginEmitNodeWithComment"); @@ -41614,7 +42545,7 @@ var ts; ts.performance.mark("preEmitBodyWithDetachedComments"); } var pos = detachedRange.pos, end = detachedRange.end; - var emitFlags = node.emitFlags; + var emitFlags = ts.getEmitFlags(node); var skipLeadingComments = pos < 0 || (emitFlags & 16384) !== 0; var skipTrailingComments = disabled || end < 0 || (emitFlags & 32768) !== 0; if (!skipLeadingComments) { @@ -41623,8 +42554,10 @@ var ts; if (extendedDiagnostics) { ts.performance.measure("commentTime", "preEmitBodyWithDetachedComments"); } - if (emitFlags & 65536) { - disableCommentsAndEmit(node, emitCallback); + if (emitFlags & 65536 && !disabled) { + disabled = true; + emitCallback(node); + disabled = false; } else { emitCallback(node); @@ -41732,16 +42665,6 @@ var ts; currentLineMap = ts.getLineStarts(currentSourceFile); detachedCommentsInfo = undefined; } - function disableCommentsAndEmit(node, emitCallback) { - if (disabled) { - emitCallback(node); - } - else { - disabled = true; - emitCallback(node); - disabled = false; - } - } function hasDetachedComments(pos) { return detachedCommentsInfo !== undefined && ts.lastOrUndefined(detachedCommentsInfo).nodePos === pos; } @@ -41793,11 +42716,11 @@ var ts; return declarationDiagnostics.getDiagnostics(targetSourceFile ? targetSourceFile.fileName : undefined); function getDeclarationDiagnosticsFromFile(_a, sources, isBundledEmit) { var declarationFilePath = _a.declarationFilePath; - emitDeclarations(host, resolver, declarationDiagnostics, declarationFilePath, sources, isBundledEmit); + emitDeclarations(host, resolver, declarationDiagnostics, declarationFilePath, sources, isBundledEmit, false); } } ts.getDeclarationDiagnostics = getDeclarationDiagnostics; - function emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFiles, isBundledEmit) { + function emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFiles, isBundledEmit, emitOnlyDtsFiles) { var newLine = host.getNewLine(); var compilerOptions = host.getCompilerOptions(); var write; @@ -41833,7 +42756,7 @@ var ts; ts.forEach(sourceFile.referencedFiles, function (fileReference) { var referencedFile = ts.tryResolveScriptReference(host, sourceFile, fileReference); if (referencedFile && !ts.contains(emittedReferencedFiles, referencedFile)) { - if (writeReferencePath(referencedFile, !isBundledEmit && !addedGlobalFileReference)) { + if (writeReferencePath(referencedFile, !isBundledEmit && !addedGlobalFileReference, emitOnlyDtsFiles)) { addedGlobalFileReference = true; } emittedReferencedFiles.push(referencedFile); @@ -42018,7 +42941,7 @@ var ts; } else { errorNameNode = declaration.name; - resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2, writer); + resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2 | 1024, writer); errorNameNode = undefined; } } @@ -42030,7 +42953,7 @@ var ts; } else { errorNameNode = signature.name; - resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, 2, writer); + resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, 2 | 1024, writer); errorNameNode = undefined; } } @@ -42223,7 +43146,7 @@ var ts; write(tempVarName); write(": "); writer.getSymbolAccessibilityDiagnostic = getDefaultExportAccessibilityDiagnostic; - resolver.writeTypeOfExpression(node.expression, enclosingDeclaration, 2, writer); + resolver.writeTypeOfExpression(node.expression, enclosingDeclaration, 2 | 1024, writer); write(";"); writeLine(); write(node.isExportEquals ? "export = " : "export default "); @@ -42629,7 +43552,7 @@ var ts; } else { writer.getSymbolAccessibilityDiagnostic = getHeritageClauseVisibilityError; - resolver.writeBaseConstructorTypeOfClass(enclosingDeclaration, enclosingDeclaration, 2, writer); + resolver.writeBaseConstructorTypeOfClass(enclosingDeclaration, enclosingDeclaration, 2 | 1024, writer); } function getHeritageClauseVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; @@ -43197,14 +44120,14 @@ var ts; return emitSourceFile(node); } } - function writeReferencePath(referencedFile, addBundledFileReference) { + function writeReferencePath(referencedFile, addBundledFileReference, emitOnlyDtsFiles) { var declFileName; var addedBundledEmitReference = false; if (ts.isDeclarationFile(referencedFile)) { declFileName = referencedFile.fileName; } else { - ts.forEachExpectedEmitFile(host, getDeclFileName, referencedFile); + ts.forEachExpectedEmitFile(host, getDeclFileName, referencedFile, emitOnlyDtsFiles); } if (declFileName) { declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(declarationFilePath)), declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, false); @@ -43221,8 +44144,8 @@ var ts; } } } - function writeDeclarationFile(declarationFilePath, sourceFiles, isBundledEmit, host, resolver, emitterDiagnostics) { - var emitDeclarationResult = emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFiles, isBundledEmit); + function writeDeclarationFile(declarationFilePath, sourceFiles, isBundledEmit, host, resolver, emitterDiagnostics, emitOnlyDtsFiles) { + var emitDeclarationResult = emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFiles, isBundledEmit, emitOnlyDtsFiles); var emitSkipped = emitDeclarationResult.reportedDeclarationError || host.isEmitBlocked(declarationFilePath) || host.getCompilerOptions().noEmit; if (!emitSkipped) { var declarationOutput = emitDeclarationResult.referencesOutput @@ -43248,7 +44171,9 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function emitFiles(resolver, host, targetSourceFile) { + var id = function (s) { return s; }; + var nullTransformers = [function (ctx) { return id; }]; + function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles) { var delimiters = createDelimiterMap(); var brackets = createBracketsMap(); 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};"; @@ -43256,7 +44181,7 @@ var ts; 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, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments)).next());\n });\n};"; + var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments)).next());\n });\n};"; var generatorHelper = "\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t;\n return { next: verb(0), \"throw\": verb(1), \"return\": verb(2) };\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};"; var exportStarHelper = "\nfunction __export(m) {\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\n}"; var umdHelper = "\n(function (dependencies, 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(dependencies, factory);\n }\n})"; @@ -43269,11 +44194,11 @@ var ts; var emittedFilesList = compilerOptions.listEmittedFiles ? [] : undefined; var emitterDiagnostics = ts.createDiagnosticCollection(); var newLine = host.getNewLine(); - var transformers = ts.getTransformers(compilerOptions); + var transformers = emitOnlyDtsFiles ? nullTransformers : ts.getTransformers(compilerOptions); var writer = ts.createTextWriter(newLine); var write = writer.write, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; var sourceMap = ts.createSourceMapWriter(host, writer); - var emitStart = sourceMap.emitStart, emitEnd = sourceMap.emitEnd, emitTokenStart = sourceMap.emitTokenStart, emitTokenEnd = sourceMap.emitTokenEnd; + var emitNodeWithSourceMap = sourceMap.emitNodeWithSourceMap, emitTokenWithSourceMap = sourceMap.emitTokenWithSourceMap; var comments = ts.createCommentWriter(host, writer, sourceMap); var emitNodeWithComments = comments.emitNodeWithComments, emitBodyWithDetachedComments = comments.emitBodyWithDetachedComments, emitTrailingCommentsOfPosition = comments.emitTrailingCommentsOfPosition; var nodeIdToGeneratedName; @@ -43290,14 +44215,17 @@ var ts; var awaiterEmitted; var isOwnFileEmit; var emitSkipped = false; + var sourceFiles = ts.getSourceFilesToEmit(host, targetSourceFile); ts.performance.mark("beforeTransform"); - var transformed = ts.transformFiles(resolver, host, ts.getSourceFilesToEmit(host, targetSourceFile), transformers); + var _a = ts.transformFiles(resolver, host, sourceFiles, transformers), transformed = _a.transformed, emitNodeWithSubstitution = _a.emitNodeWithSubstitution, emitNodeWithNotification = _a.emitNodeWithNotification; ts.performance.measure("transformTime", "beforeTransform"); - var getTokenSourceMapRange = transformed.getTokenSourceMapRange, isSubstitutionEnabled = transformed.isSubstitutionEnabled, isEmitNotificationEnabled = transformed.isEmitNotificationEnabled, onSubstituteNode = transformed.onSubstituteNode, onEmitNode = transformed.onEmitNode; ts.performance.mark("beforePrint"); - ts.forEachTransformedEmitFile(host, transformed.getSourceFiles(), emitFile); - transformed.dispose(); + ts.forEachTransformedEmitFile(host, transformed, emitFile, emitOnlyDtsFiles); ts.performance.measure("printTime", "beforePrint"); + for (var _b = 0, sourceFiles_4 = sourceFiles; _b < sourceFiles_4.length; _b++) { + var sourceFile = sourceFiles_4[_b]; + ts.disposeEmitNodes(sourceFile); + } return { emitSkipped: emitSkipped, diagnostics: emitterDiagnostics.getDiagnostics(), @@ -43306,16 +44234,20 @@ var ts; }; function emitFile(jsFilePath, sourceMapFilePath, declarationFilePath, sourceFiles, isBundledEmit) { if (!host.isEmitBlocked(jsFilePath) && !compilerOptions.noEmit) { - printFile(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit); + if (!emitOnlyDtsFiles) { + printFile(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit); + } } else { emitSkipped = true; } if (declarationFilePath) { - emitSkipped = ts.writeDeclarationFile(declarationFilePath, ts.getOriginalSourceFiles(sourceFiles), isBundledEmit, host, resolver, emitterDiagnostics) || emitSkipped; + emitSkipped = ts.writeDeclarationFile(declarationFilePath, ts.getOriginalSourceFiles(sourceFiles), isBundledEmit, host, resolver, emitterDiagnostics, emitOnlyDtsFiles) || emitSkipped; } if (!emitSkipped && emittedFilesList) { - emittedFilesList.push(jsFilePath); + if (!emitOnlyDtsFiles) { + emittedFilesList.push(jsFilePath); + } if (sourceMapFilePath) { emittedFilesList.push(sourceMapFilePath); } @@ -43331,8 +44263,8 @@ var ts; generatedNameSet = ts.createMap(); isOwnFileEmit = !isBundledEmit; if (isBundledEmit && moduleKind) { - for (var _a = 0, sourceFiles_4 = sourceFiles; _a < sourceFiles_4.length; _a++) { - var sourceFile = sourceFiles_4[_a]; + for (var _a = 0, sourceFiles_5 = sourceFiles; _a < sourceFiles_5.length; _a++) { + var sourceFile = sourceFiles_5[_a]; emitEmitHelpers(sourceFile); } } @@ -43368,73 +44300,61 @@ var ts; currentFileIdentifiers = node.identifiers; sourceMap.setSourceFile(node); comments.setSourceFile(node); - emitNodeWithNotification(node, emitWorker); + pipelineEmitWithNotification(0, node); } function emit(node) { - emitNodeWithNotification(node, emitWithComments); - } - function emitWithComments(node) { - emitNodeWithComments(node, emitWithSourceMap); - } - function emitWithSourceMap(node) { - emitNodeWithSourceMap(node, emitWorker); + pipelineEmitWithNotification(3, node); } function emitIdentifierName(node) { - if (node) { - emitNodeWithNotification(node, emitIdentifierNameWithComments); - } - } - function emitIdentifierNameWithComments(node) { - emitNodeWithComments(node, emitWorker); + pipelineEmitWithNotification(2, node); } function emitExpression(node) { - emitNodeWithNotification(node, emitExpressionWithComments); + pipelineEmitWithNotification(1, node); } - function emitExpressionWithComments(node) { - emitNodeWithComments(node, emitExpressionWithSourceMap); + function pipelineEmitWithNotification(emitContext, node) { + emitNodeWithNotification(emitContext, node, pipelineEmitWithComments); } - function emitExpressionWithSourceMap(node) { - emitNodeWithSourceMap(node, emitExpressionWorker); - } - function emitNodeWithNotification(node, emitCallback) { - if (node) { - if (isEmitNotificationEnabled(node)) { - onEmitNode(node, emitCallback); - } - else { - emitCallback(node); - } - } - } - function emitNodeWithSourceMap(node, emitCallback) { - if (node) { - emitStart(node, node, shouldSkipLeadingSourceMapForNode, shouldSkipSourceMapForChildren, getSourceMapRange); - emitCallback(node); - emitEnd(node, node, shouldSkipTrailingSourceMapForNode, shouldSkipSourceMapForChildren, getSourceMapRange); - } - } - function getSourceMapRange(node) { - return node.sourceMapRange || node; - } - function shouldSkipLeadingCommentsForNode(node) { - return ts.isNotEmittedStatement(node) - || (node.emitFlags & 16384) !== 0; - } - function shouldSkipLeadingSourceMapForNode(node) { - return ts.isNotEmittedStatement(node) - || (node.emitFlags & 512) !== 0; - } - function shouldSkipTrailingSourceMapForNode(node) { - return ts.isNotEmittedStatement(node) - || (node.emitFlags & 1024) !== 0; - } - function shouldSkipSourceMapForChildren(node) { - return (node.emitFlags & 2048) !== 0; - } - function emitWorker(node) { - if (tryEmitSubstitute(node, emitWorker, false)) { + function pipelineEmitWithComments(emitContext, node) { + if (emitContext === 0) { + pipelineEmitWithSourceMap(emitContext, node); return; } + emitNodeWithComments(emitContext, node, pipelineEmitWithSourceMap); + } + function pipelineEmitWithSourceMap(emitContext, node) { + if (emitContext === 0 + || emitContext === 2) { + pipelineEmitWithSubstitution(emitContext, node); + return; + } + emitNodeWithSourceMap(emitContext, node, pipelineEmitWithSubstitution); + } + function pipelineEmitWithSubstitution(emitContext, node) { + emitNodeWithSubstitution(emitContext, node, pipelineEmitForContext); + } + function pipelineEmitForContext(emitContext, node) { + switch (emitContext) { + case 0: return pipelineEmitInSourceFileContext(node); + case 2: return pipelineEmitInIdentifierNameContext(node); + case 3: return pipelineEmitInUnspecifiedContext(node); + case 1: return pipelineEmitInExpressionContext(node); + } + } + function pipelineEmitInSourceFileContext(node) { + var kind = node.kind; + switch (kind) { + case 256: + return emitSourceFile(node); + } + } + function pipelineEmitInIdentifierNameContext(node) { + var kind = node.kind; + switch (kind) { + case 69: + return emitIdentifier(node); + } + } + function pipelineEmitInUnspecifiedContext(node) { var kind = node.kind; switch (kind) { case 12: @@ -43461,7 +44381,8 @@ var ts; case 132: case 133: case 137: - return writeTokenNode(node); + writeTokenText(kind); + return; case 139: return emitQualifiedName(node); case 140: @@ -43637,17 +44558,12 @@ var ts; return emitShorthandPropertyAssignment(node); case 255: return emitEnumMember(node); - case 256: - return emitSourceFile(node); } if (ts.isExpression(node)) { - return emitExpressionWorker(node); + return pipelineEmitWithSubstitution(1, node); } } - function emitExpressionWorker(node) { - if (tryEmitSubstitute(node, emitExpressionWorker, true)) { - return; - } + function pipelineEmitInExpressionContext(node) { var kind = node.kind; switch (kind) { case 8: @@ -43663,7 +44579,8 @@ var ts; case 95: case 99: case 97: - return writeTokenNode(node); + writeTokenText(kind); + return; case 170: return emitArrayLiteralExpression(node); case 171: @@ -43741,7 +44658,7 @@ var ts; } } function emitIdentifier(node) { - if (node.emitFlags & 16) { + if (ts.getEmitFlags(node) & 16) { writeLines(umdHelper); } else { @@ -43956,7 +44873,7 @@ var ts; write("{}"); } else { - var indentedFlag = node.emitFlags & 524288; + var indentedFlag = ts.getEmitFlags(node) & 524288; if (indentedFlag) { increaseIndent(); } @@ -43969,21 +44886,18 @@ var ts; } } function emitPropertyAccessExpression(node) { - if (tryEmitConstantValue(node)) { - return; - } var indentBeforeDot = false; var indentAfterDot = false; - if (!(node.emitFlags & 1048576)) { + if (!(ts.getEmitFlags(node) & 1048576)) { var dotRangeStart = node.expression.end; var dotRangeEnd = ts.skipTrivia(currentText, node.expression.end) + 1; var dotToken = { kind: 21, pos: dotRangeStart, end: dotRangeEnd }; indentBeforeDot = needsIndentation(node, node.expression, dotToken); indentAfterDot = needsIndentation(node, dotToken, node.name); } - var shouldEmitDotDot = !indentBeforeDot && needsDotDotForPropertyAccess(node.expression); emitExpression(node.expression); increaseIndentIf(indentBeforeDot); + var shouldEmitDotDot = !indentBeforeDot && needsDotDotForPropertyAccess(node.expression); write(shouldEmitDotDot ? ".." : "."); increaseIndentIf(indentAfterDot); emit(node.name); @@ -43994,15 +44908,14 @@ var ts; var text = getLiteralTextOfNode(expression); return text.indexOf(ts.tokenToString(21)) < 0; } - else { - var constantValue = tryGetConstEnumValue(expression); - return isFinite(constantValue) && Math.floor(constantValue) === constantValue; + else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { + var constantValue = ts.getConstantValue(expression); + return isFinite(constantValue) + && Math.floor(constantValue) === constantValue + && compilerOptions.removeComments; } } function emitElementAccessExpression(node) { - if (tryEmitConstantValue(node)) { - return; - } emitExpression(node.expression); write("["); emitExpression(node.argumentExpression); @@ -44157,7 +45070,7 @@ var ts; } } function emitBlockStatements(node) { - if (node.emitFlags & 32) { + if (ts.getEmitFlags(node) & 32) { emitList(node, node.statements, 384); } else { @@ -44332,11 +45245,11 @@ var ts; var body = node.body; if (body) { if (ts.isBlock(body)) { - var indentedFlag = node.emitFlags & 524288; + var indentedFlag = ts.getEmitFlags(node) & 524288; if (indentedFlag) { increaseIndent(); } - if (node.emitFlags & 4194304) { + if (ts.getEmitFlags(node) & 4194304) { emitSignatureHead(node); emitBlockFunctionBody(node, body); } @@ -44368,7 +45281,7 @@ var ts; emitWithPrefix(": ", node.type); } function shouldEmitBlockFunctionBodyOnSingleLine(parentNode, body) { - if (body.emitFlags & 32) { + if (ts.getEmitFlags(body) & 32) { return true; } if (body.multiLine) { @@ -44423,7 +45336,7 @@ var ts; emitModifiers(node, node.modifiers); write("class"); emitNodeWithPrefix(" ", node.name, emitIdentifierName); - var indentedFlag = node.emitFlags & 524288; + var indentedFlag = ts.getEmitFlags(node) & 524288; if (indentedFlag) { increaseIndent(); } @@ -44485,7 +45398,7 @@ var ts; emit(body); } function emitModuleBlock(node) { - if (isSingleLineEmptyBlock(node)) { + if (isEmptyBlock(node)) { write("{ }"); } else { @@ -44682,8 +45595,8 @@ var ts; emit(node.name); write(": "); var initializer = node.initializer; - if (!shouldSkipLeadingCommentsForNode(initializer)) { - var commentRange = initializer.commentRange || initializer; + if ((ts.getEmitFlags(initializer) & 16384) === 0) { + var commentRange = ts.getCommentRange(initializer); emitTrailingCommentsOfPosition(commentRange.pos); } emitExpression(initializer); @@ -44731,7 +45644,7 @@ var ts; return statements.length; } function emitHelpers(node) { - var emitFlags = node.emitFlags; + var emitFlags = ts.getEmitFlags(node); var helpersEmitted = false; if (emitFlags & 1) { helpersEmitted = emitEmitHelpers(currentSourceFile); @@ -44837,31 +45750,6 @@ var ts; write(suffix); } } - function tryEmitSubstitute(node, emitNode, isExpression) { - if (isSubstitutionEnabled(node) && (node.emitFlags & 128) === 0) { - var substitute = onSubstituteNode(node, isExpression); - if (substitute !== node) { - substitute.emitFlags |= 128; - emitNode(substitute); - return true; - } - } - return false; - } - function tryEmitConstantValue(node) { - var constantValue = tryGetConstEnumValue(node); - if (constantValue !== undefined) { - write(String(constantValue)); - if (!compilerOptions.removeComments) { - var propertyName = ts.isPropertyAccessExpression(node) - ? ts.declarationNameToString(node.name) - : getTextOfNode(node.argumentExpression); - write(" /* " + propertyName + " */"); - } - return true; - } - return false; - } function emitEmbeddedStatement(node) { if (ts.isBlock(node)) { write(" "); @@ -44961,7 +45849,7 @@ var ts; } } if (shouldEmitInterveningComments) { - var commentRange = child.commentRange || child; + var commentRange = ts.getCommentRange(child); emitTrailingCommentsOfPosition(commentRange.pos); } else { @@ -45003,27 +45891,12 @@ var ts; } } function writeToken(token, pos, contextNode) { - var tokenStartPos = emitTokenStart(token, pos, contextNode, shouldSkipLeadingSourceMapForToken, getTokenSourceMapRange); - var tokenEndPos = writeTokenText(token, tokenStartPos); - return emitTokenEnd(token, tokenEndPos, contextNode, shouldSkipTrailingSourceMapForToken, getTokenSourceMapRange); - } - function shouldSkipLeadingSourceMapForToken(contextNode) { - return (contextNode.emitFlags & 4096) !== 0; - } - function shouldSkipTrailingSourceMapForToken(contextNode) { - return (contextNode.emitFlags & 8192) !== 0; + return emitTokenWithSourceMap(contextNode, token, pos, writeTokenText); } function writeTokenText(token, pos) { var tokenString = ts.tokenToString(token); write(tokenString); - return ts.positionIsSynthesized(pos) ? -1 : pos + tokenString.length; - } - function writeTokenNode(node) { - if (node) { - emitStart(node, node, shouldSkipLeadingSourceMapForNode, shouldSkipSourceMapForChildren, getSourceMapRange); - writeTokenText(node.kind); - emitEnd(node, node, shouldSkipTrailingSourceMapForNode, shouldSkipSourceMapForChildren, getSourceMapRange); - } + return pos < 0 ? pos : pos + tokenString.length; } function increaseIndentIf(value, valueToWriteWhenNotIndenting) { if (value) { @@ -45162,17 +46035,12 @@ var ts; } return ts.getLiteralText(node, currentSourceFile, languageVersion); } - function tryGetConstEnumValue(node) { - if (compilerOptions.isolatedModules) { - return undefined; - } - return ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node) - ? resolver.getConstantValue(node) - : undefined; - } function isSingleLineEmptyBlock(block) { return !block.multiLine - && block.statements.length === 0 + && isEmptyBlock(block); + } + function isEmptyBlock(block) { + return block.statements.length === 0 && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function isUniqueName(name) { @@ -45382,581 +46250,6 @@ var ts; return ts.getNormalizedPathFromPathComponents(commonPathComponents); } ts.computeCommonSourceDirectoryOfFilenames = computeCommonSourceDirectoryOfFilenames; - function trace(host, message) { - host.trace(ts.formatMessage.apply(undefined, arguments)); - } - function isTraceEnabled(compilerOptions, host) { - return compilerOptions.traceResolution && host.trace !== undefined; - } - function hasZeroOrOneAsteriskCharacter(str) { - var seenAsterisk = false; - for (var i = 0; i < str.length; i++) { - if (str.charCodeAt(i) === 42) { - if (!seenAsterisk) { - seenAsterisk = true; - } - else { - return false; - } - } - } - return true; - } - ts.hasZeroOrOneAsteriskCharacter = hasZeroOrOneAsteriskCharacter; - function createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations) { - return { resolvedModule: resolvedFileName ? { resolvedFileName: resolvedFileName, isExternalLibraryImport: isExternalLibraryImport } : undefined, failedLookupLocations: failedLookupLocations }; - } - function moduleHasNonRelativeName(moduleName) { - return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); - } - function tryReadTypesSection(packageJsonPath, baseDirectory, state) { - var jsonContent = readJson(packageJsonPath, state.host); - function tryReadFromField(fieldName) { - if (ts.hasProperty(jsonContent, fieldName)) { - var typesFile = jsonContent[fieldName]; - if (typeof typesFile === "string") { - var typesFilePath_1 = ts.normalizePath(ts.combinePaths(baseDirectory, typesFile)); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath_1); - } - return typesFilePath_1; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof typesFile); - } - } - } - } - var typesFilePath = tryReadFromField("typings") || tryReadFromField("types"); - if (typesFilePath) { - return typesFilePath; - } - if (state.compilerOptions.allowJs && jsonContent.main && typeof jsonContent.main === "string") { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0, jsonContent.main); - } - var mainFilePath = ts.normalizePath(ts.combinePaths(baseDirectory, jsonContent.main)); - return mainFilePath; - } - return undefined; - } - function readJson(path, host) { - try { - var jsonText = host.readFile(path); - return jsonText ? JSON.parse(jsonText) : {}; - } - catch (e) { - return {}; - } - } - var typeReferenceExtensions = [".d.ts"]; - function getEffectiveTypeRoots(options, host) { - if (options.typeRoots) { - return options.typeRoots; - } - var currentDirectory; - if (options.configFilePath) { - currentDirectory = ts.getDirectoryPath(options.configFilePath); - } - else if (host.getCurrentDirectory) { - currentDirectory = host.getCurrentDirectory(); - } - return currentDirectory && getDefaultTypeRoots(currentDirectory, host); - } - ts.getEffectiveTypeRoots = getEffectiveTypeRoots; - function getDefaultTypeRoots(currentDirectory, host) { - if (!host.directoryExists) { - return [ts.combinePaths(currentDirectory, nodeModulesAtTypes)]; - } - var typeRoots; - while (true) { - var atTypes = ts.combinePaths(currentDirectory, nodeModulesAtTypes); - if (host.directoryExists(atTypes)) { - (typeRoots || (typeRoots = [])).push(atTypes); - } - var parent_15 = ts.getDirectoryPath(currentDirectory); - if (parent_15 === currentDirectory) { - break; - } - currentDirectory = parent_15; - } - return typeRoots; - } - var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types"); - function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host) { - var traceEnabled = isTraceEnabled(options, host); - var moduleResolutionState = { - compilerOptions: options, - host: host, - skipTsx: true, - traceEnabled: traceEnabled - }; - var typeRoots = getEffectiveTypeRoots(options, host); - if (traceEnabled) { - if (containingFile === undefined) { - if (typeRoots === undefined) { - trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set, typeReferenceDirectiveName); - } - else { - trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1, typeReferenceDirectiveName, typeRoots); - } - } - else { - if (typeRoots === undefined) { - trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set, typeReferenceDirectiveName, containingFile); - } - else { - trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, typeRoots); - } - } - } - var failedLookupLocations = []; - if (typeRoots && typeRoots.length) { - if (traceEnabled) { - trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", ")); - } - var primarySearchPaths = typeRoots; - for (var _i = 0, primarySearchPaths_1 = primarySearchPaths; _i < primarySearchPaths_1.length; _i++) { - var typeRoot = primarySearchPaths_1[_i]; - var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); - var candidateDirectory = ts.getDirectoryPath(candidate); - var resolvedFile_1 = loadNodeModuleFromDirectory(typeReferenceExtensions, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState); - if (resolvedFile_1) { - if (traceEnabled) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile_1, true); - } - return { - resolvedTypeReferenceDirective: { primary: true, resolvedFileName: resolvedFile_1 }, - failedLookupLocations: failedLookupLocations - }; - } - } - } - else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths); - } - } - var resolvedFile; - var initialLocationForSecondaryLookup; - if (containingFile) { - initialLocationForSecondaryLookup = ts.getDirectoryPath(containingFile); - } - if (initialLocationForSecondaryLookup !== undefined) { - if (traceEnabled) { - trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); - } - resolvedFile = loadModuleFromNodeModules(typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState); - if (traceEnabled) { - if (resolvedFile) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile, false); - } - else { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); - } - } - } - else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder); - } - } - return { - resolvedTypeReferenceDirective: resolvedFile - ? { primary: false, resolvedFileName: resolvedFile } - : undefined, - failedLookupLocations: failedLookupLocations - }; - } - ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective; - function resolveModuleName(moduleName, containingFile, compilerOptions, host) { - var traceEnabled = isTraceEnabled(compilerOptions, host); - if (traceEnabled) { - trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); - } - var moduleResolution = compilerOptions.moduleResolution; - if (moduleResolution === undefined) { - moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; - if (traceEnabled) { - trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); - } - } - else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); - } - } - var result; - switch (moduleResolution) { - case ts.ModuleResolutionKind.NodeJs: - result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host); - break; - case ts.ModuleResolutionKind.Classic: - result = classicNameResolver(moduleName, containingFile, compilerOptions, host); - break; - } - if (traceEnabled) { - if (result.resolvedModule) { - trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.resolvedModule.resolvedFileName); - } - else { - trace(host, ts.Diagnostics.Module_name_0_was_not_resolved, moduleName); - } - } - return result; - } - ts.resolveModuleName = resolveModuleName; - function tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { - if (moduleHasNonRelativeName(moduleName)) { - return tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state); - } - else { - return tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state); - } - } - function tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { - if (!state.compilerOptions.rootDirs) { - return undefined; - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0, moduleName); - } - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var matchedRootDir; - var matchedNormalizedPrefix; - for (var _i = 0, _a = state.compilerOptions.rootDirs; _i < _a.length; _i++) { - var rootDir = _a[_i]; - var normalizedRoot = ts.normalizePath(rootDir); - if (!ts.endsWith(normalizedRoot, ts.directorySeparator)) { - normalizedRoot += ts.directorySeparator; - } - var isLongestMatchingPrefix = ts.startsWith(candidate, normalizedRoot) && - (matchedNormalizedPrefix === undefined || matchedNormalizedPrefix.length < normalizedRoot.length); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Checking_if_0_is_the_longest_matching_prefix_for_1_2, normalizedRoot, candidate, isLongestMatchingPrefix); - } - if (isLongestMatchingPrefix) { - matchedNormalizedPrefix = normalizedRoot; - matchedRootDir = rootDir; - } - } - if (matchedNormalizedPrefix) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Longest_matching_prefix_for_0_is_1, candidate, matchedNormalizedPrefix); - } - var suffix = candidate.substr(matchedNormalizedPrefix.length); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, matchedNormalizedPrefix, candidate); - } - var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(containingDirectory, state.host), state); - if (resolvedFileName) { - return resolvedFileName; - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Trying_other_entries_in_rootDirs); - } - for (var _b = 0, _c = state.compilerOptions.rootDirs; _b < _c.length; _b++) { - var rootDir = _c[_b]; - if (rootDir === matchedRootDir) { - continue; - } - var candidate_1 = ts.combinePaths(ts.normalizePath(rootDir), suffix); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, rootDir, candidate_1); - } - var baseDirectory = ts.getDirectoryPath(candidate_1); - var resolvedFileName_1 = loader(candidate_1, supportedExtensions, failedLookupLocations, !directoryProbablyExists(baseDirectory, state.host), state); - if (resolvedFileName_1) { - return resolvedFileName_1; - } - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Module_resolution_using_rootDirs_has_failed); - } - } - return undefined; - } - function tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state) { - if (!state.compilerOptions.baseUrl) { - return undefined; - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, state.compilerOptions.baseUrl, moduleName); - } - var matchedPattern = undefined; - if (state.compilerOptions.paths) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); - } - matchedPattern = matchPatternOrExact(ts.getOwnKeys(state.compilerOptions.paths), moduleName); - } - if (matchedPattern) { - var matchedStar = typeof matchedPattern === "string" ? undefined : matchedText(matchedPattern, moduleName); - var matchedPatternText = typeof matchedPattern === "string" ? matchedPattern : patternText(matchedPattern); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPatternText); - } - for (var _i = 0, _a = state.compilerOptions.paths[matchedPatternText]; _i < _a.length; _i++) { - var subst = _a[_i]; - var path = matchedStar ? subst.replace("*", matchedStar) : subst; - var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, path)); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path); - } - var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); - if (resolvedFileName) { - return resolvedFileName; - } - } - return undefined; - } - else { - var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, moduleName)); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Resolving_module_name_0_relative_to_base_url_1_2, moduleName, state.compilerOptions.baseUrl, candidate); - } - return loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); - } - } - function matchPatternOrExact(patternStrings, candidate) { - var patterns = []; - for (var _i = 0, patternStrings_1 = patternStrings; _i < patternStrings_1.length; _i++) { - var patternString = patternStrings_1[_i]; - var pattern = tryParsePattern(patternString); - if (pattern) { - patterns.push(pattern); - } - else if (patternString === candidate) { - return patternString; - } - } - return findBestPatternMatch(patterns, function (_) { return _; }, candidate); - } - function patternText(_a) { - var prefix = _a.prefix, suffix = _a.suffix; - return prefix + "*" + suffix; - } - function matchedText(pattern, candidate) { - ts.Debug.assert(isPatternMatch(pattern, candidate)); - return candidate.substr(pattern.prefix.length, candidate.length - pattern.suffix.length); - } - function findBestPatternMatch(values, getPattern, candidate) { - var matchedValue = undefined; - var longestMatchPrefixLength = -1; - for (var _i = 0, values_1 = values; _i < values_1.length; _i++) { - var v = values_1[_i]; - var pattern = getPattern(v); - if (isPatternMatch(pattern, candidate) && pattern.prefix.length > longestMatchPrefixLength) { - longestMatchPrefixLength = pattern.prefix.length; - matchedValue = v; - } - } - return matchedValue; - } - ts.findBestPatternMatch = findBestPatternMatch; - function isPatternMatch(_a, candidate) { - var prefix = _a.prefix, suffix = _a.suffix; - return candidate.length >= prefix.length + suffix.length && - ts.startsWith(candidate, prefix) && - ts.endsWith(candidate, suffix); - } - function tryParsePattern(pattern) { - ts.Debug.assert(hasZeroOrOneAsteriskCharacter(pattern)); - var indexOfStar = pattern.indexOf("*"); - return indexOfStar === -1 ? undefined : { - prefix: pattern.substr(0, indexOfStar), - suffix: pattern.substr(indexOfStar + 1) - }; - } - ts.tryParsePattern = tryParsePattern; - function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host) { - var containingDirectory = ts.getDirectoryPath(containingFile); - var supportedExtensions = ts.getSupportedExtensions(compilerOptions); - var traceEnabled = isTraceEnabled(compilerOptions, host); - var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: false }; - var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, supportedExtensions, state); - var isExternalLibraryImport = false; - if (!resolvedFileName) { - if (moduleHasNonRelativeName(moduleName)) { - if (traceEnabled) { - trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder, moduleName); - } - resolvedFileName = loadModuleFromNodeModules(moduleName, containingDirectory, failedLookupLocations, state); - isExternalLibraryImport = resolvedFileName !== undefined; - } - else { - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - resolvedFileName = nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, false, state); - } - } - if (resolvedFileName && host.realpath) { - var originalFileName = resolvedFileName; - resolvedFileName = ts.normalizePath(host.realpath(resolvedFileName)); - if (traceEnabled) { - trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, originalFileName, resolvedFileName); - } - } - return createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations); - } - ts.nodeModuleNameResolver = nodeModuleNameResolver; - function nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate); - } - var resolvedFileName = !ts.pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state); - return resolvedFileName || loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, onlyRecordFailures, state); - } - function directoryProbablyExists(directoryName, host) { - return !host.directoryExists || host.directoryExists(directoryName); - } - ts.directoryProbablyExists = directoryProbablyExists; - function loadModuleFromFile(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) { - var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state); - if (resolvedByAddingExtension) { - return resolvedByAddingExtension; - } - if (ts.hasJavaScriptFileExtension(candidate)) { - var extensionless = ts.removeFileExtension(candidate); - if (state.traceEnabled) { - var extension = candidate.substring(extensionless.length); - trace(state.host, ts.Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension); - } - return tryAddingExtensions(extensionless, extensions, failedLookupLocation, onlyRecordFailures, state); - } - } - function tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) { - if (!onlyRecordFailures) { - var directory = ts.getDirectoryPath(candidate); - if (directory) { - onlyRecordFailures = !directoryProbablyExists(directory, state.host); - } - } - return ts.forEach(extensions, function (ext) { - return !(state.skipTsx && ts.isJsxOrTsxExtension(ext)) && tryFile(candidate + ext, failedLookupLocation, onlyRecordFailures, state); - }); - } - function tryFile(fileName, failedLookupLocation, onlyRecordFailures, state) { - if (!onlyRecordFailures && state.host.fileExists(fileName)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); - } - return fileName; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); - } - failedLookupLocation.push(fileName); - return undefined; - } - } - function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocation, onlyRecordFailures, state) { - var packageJsonPath = pathToPackageJson(candidate); - var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); - if (directoryExists && state.host.fileExists(packageJsonPath)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); - } - var typesFile = tryReadTypesSection(packageJsonPath, candidate, state); - if (typesFile) { - var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(typesFile), state.host); - var result = tryFile(typesFile, failedLookupLocation, onlyRecordFailures_1, state) || - tryAddingExtensions(typesFile, extensions, failedLookupLocation, onlyRecordFailures_1, state); - if (result) { - return result; - } - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_does_not_have_types_field); - } - } - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); - } - failedLookupLocation.push(packageJsonPath); - } - return loadModuleFromFile(ts.combinePaths(candidate, "index"), extensions, failedLookupLocation, !directoryExists, state); - } - function pathToPackageJson(directory) { - return ts.combinePaths(directory, "package.json"); - } - function loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state) { - var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); - var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); - var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); - var supportedExtensions = ts.getSupportedExtensions(state.compilerOptions); - var result = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, !nodeModulesFolderExists, state); - if (result) { - return result; - } - result = loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); - if (result) { - return result; - } - } - function loadModuleFromNodeModules(moduleName, directory, failedLookupLocations, state) { - directory = ts.normalizeSlashes(directory); - while (true) { - var baseName = ts.getBaseFileName(directory); - if (baseName !== "node_modules") { - var packageResult = loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state); - if (packageResult && ts.hasTypeScriptFileExtension(packageResult)) { - return packageResult; - } - else { - var typesResult = loadModuleFromNodeModulesFolder(ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); - if (typesResult || packageResult) { - return typesResult || packageResult; - } - } - } - var parentPath = ts.getDirectoryPath(directory); - if (parentPath === directory) { - break; - } - directory = parentPath; - } - return undefined; - } - function classicNameResolver(moduleName, containingFile, compilerOptions, host) { - var traceEnabled = isTraceEnabled(compilerOptions, host); - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: !compilerOptions.jsx }; - var failedLookupLocations = []; - var supportedExtensions = ts.getSupportedExtensions(compilerOptions); - var containingDirectory = ts.getDirectoryPath(containingFile); - var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, supportedExtensions, state); - if (resolvedFileName) { - return createResolvedModule(resolvedFileName, false, failedLookupLocations); - } - var referencedSourceFile; - if (moduleHasNonRelativeName(moduleName)) { - while (true) { - var searchName = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - referencedSourceFile = loadModuleFromFile(searchName, supportedExtensions, failedLookupLocations, false, state); - if (referencedSourceFile) { - break; - } - var parentPath = ts.getDirectoryPath(containingDirectory); - if (parentPath === containingDirectory) { - break; - } - containingDirectory = parentPath; - } - } - else { - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - referencedSourceFile = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, false, state); - } - return referencedSourceFile - ? { resolvedModule: { resolvedFileName: referencedSourceFile }, failedLookupLocations: failedLookupLocations } - : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; - } - ts.classicNameResolver = classicNameResolver; function createCompilerHost(options, setParentNodes) { var existingDirectories = ts.createMap(); function getCanonicalFileName(fileName) { @@ -46058,7 +46351,7 @@ var ts; readFile: function (fileName) { return ts.sys.readFile(fileName); }, trace: function (s) { return ts.sys.write(s + newLine); }, directoryExists: function (directoryName) { return ts.sys.directoryExists(directoryName); }, - getEnvironmentVariable: function (name) { return ts.getEnvironmentVariable(name, undefined); }, + getEnvironmentVariable: function (name) { return ts.sys.getEnvironmentVariable ? ts.sys.getEnvironmentVariable(name) : ""; }, getDirectories: function (path) { return ts.sys.getDirectories(path); }, realpath: realpath }; @@ -46126,33 +46419,6 @@ var ts; } return resolutions; } - function getAutomaticTypeDirectiveNames(options, host) { - if (options.types) { - return options.types; - } - var result = []; - if (host.directoryExists && host.getDirectories) { - var typeRoots = getEffectiveTypeRoots(options, host); - if (typeRoots) { - for (var _i = 0, typeRoots_1 = typeRoots; _i < typeRoots_1.length; _i++) { - var root = typeRoots_1[_i]; - if (host.directoryExists(root)) { - for (var _a = 0, _b = host.getDirectories(root); _a < _b.length; _a++) { - var typeDirectivePath = _b[_a]; - var normalized = ts.normalizePath(typeDirectivePath); - var packageJsonPath = pathToPackageJson(ts.combinePaths(root, normalized)); - var isNotNeededPackage = host.fileExists(packageJsonPath) && readJson(packageJsonPath, host).typings === null; - if (!isNotNeededPackage) { - result.push(ts.getBaseFileName(normalized)); - } - } - } - } - } - } - return result; - } - ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; function createProgram(rootNames, options, host, oldProgram) { var program; var files = []; @@ -46178,7 +46444,7 @@ var ts; resolveModuleNamesWorker = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }; } else { - var loader_1 = function (moduleName, containingFile) { return resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }; + var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }; resolveModuleNamesWorker = function (moduleNames, containingFile) { return loadWithLocalCache(moduleNames, containingFile, loader_1); }; } var resolveTypeReferenceDirectiveNamesWorker; @@ -46186,15 +46452,15 @@ var ts; resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile) { return host.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile); }; } else { - var loader_2 = function (typesRef, containingFile) { return resolveTypeReferenceDirective(typesRef, containingFile, options, host).resolvedTypeReferenceDirective; }; + var loader_2 = function (typesRef, containingFile) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host).resolvedTypeReferenceDirective; }; resolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile) { return loadWithLocalCache(typeReferenceDirectiveNames, containingFile, loader_2); }; } var filesByName = ts.createFileMap(); var filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? ts.createFileMap(function (fileName) { return fileName.toLowerCase(); }) : undefined; if (!tryReuseStructureFromOldProgram()) { ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); - var typeReferences = getAutomaticTypeDirectiveNames(options, host); - if (typeReferences) { + var typeReferences = ts.getAutomaticTypeDirectiveNames(options, host); + if (typeReferences.length) { var containingFilename = ts.combinePaths(host.getCurrentDirectory(), "__inferred type names__.ts"); var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename); for (var i = 0; i < typeReferences.length; i++) { @@ -46236,7 +46502,8 @@ var ts; getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); }, getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); }, getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; }, - getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; } + getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; }, + dropDiagnosticsProducingTypeChecker: dropDiagnosticsProducingTypeChecker }; verifyCompilerOptions(); ts.performance.mark("afterProgram"); @@ -46283,6 +46550,7 @@ var ts; (oldOptions.configFilePath !== options.configFilePath) || (oldOptions.baseUrl !== options.baseUrl) || (oldOptions.maxNodeModuleJsDepth !== options.maxNodeModuleJsDepth) || + !ts.arrayIsEqualTo(oldOptions.lib, options.lib) || !ts.arrayIsEqualTo(oldOptions.typeRoots, oldOptions.typeRoots) || !ts.arrayIsEqualTo(oldOptions.rootDirs, options.rootDirs) || !ts.equalOwnProperties(oldOptions.paths, options.paths)) { @@ -46383,16 +46651,19 @@ var ts; function getDiagnosticsProducingTypeChecker() { return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, true)); } + function dropDiagnosticsProducingTypeChecker() { + diagnosticsProducingTypeChecker = undefined; + } function getTypeChecker() { return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, false)); } - function emit(sourceFile, writeFileCallback, cancellationToken) { - return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken); }); + function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles) { + return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles); }); } function isEmitBlocked(emitFileName) { return hasEmitBlockingDiagnostics.contains(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName)); } - function emitWorker(program, sourceFile, writeFileCallback, cancellationToken) { + function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles) { var declarationDiagnostics = []; if (options.noEmit) { return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true }; @@ -46413,7 +46684,7 @@ var ts; } var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile); ts.performance.mark("beforeEmit"); - var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile); + var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, emitOnlyDtsFiles); ts.performance.mark("afterEmit"); ts.performance.measure("Emit", "beforeEmit", "afterEmit"); return emitResult; @@ -46928,7 +47199,6 @@ var ts; for (var i = 0; i < moduleNames.length; i++) { var resolution = resolutions[i]; ts.setResolvedModule(file, moduleNames[i], resolution); - var resolvedPath = resolution ? ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName) : undefined; var isFromNodeModulesSearch = resolution && resolution.isExternalLibraryImport; var isJsFileFromNodeModules = isFromNodeModulesSearch && ts.hasJavaScriptFileExtension(resolution.resolvedFileName); if (isFromNodeModulesSearch) { @@ -46940,7 +47210,7 @@ var ts; modulesWithElidedImports[file.path] = true; } else if (shouldAddFile) { - findSourceFile(resolution.resolvedFileName, resolvedPath, false, false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); + findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), false, false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); } if (isFromNodeModulesSearch) { currentNodeModulesDepth--; @@ -46954,8 +47224,8 @@ var ts; } function computeCommonSourceDirectory(sourceFiles) { var fileNames = []; - for (var _i = 0, sourceFiles_5 = sourceFiles; _i < sourceFiles_5.length; _i++) { - var file = sourceFiles_5[_i]; + for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { + var file = sourceFiles_6[_i]; if (!file.isDeclarationFile) { fileNames.push(file.fileName); } @@ -46966,8 +47236,8 @@ var ts; var allFilesBelongToPath = true; if (sourceFiles) { var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); - for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { - var sourceFile = sourceFiles_6[_i]; + for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { + var sourceFile = sourceFiles_7[_i]; if (!ts.isDeclarationFile(sourceFile)) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { @@ -47010,7 +47280,7 @@ var ts; if (!ts.hasProperty(options.paths, key)) { continue; } - if (!hasZeroOrOneAsteriskCharacter(key)) { + if (!ts.hasZeroOrOneAsteriskCharacter(key)) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Pattern_0_can_have_at_most_one_Asterisk_character, key)); } if (ts.isArray(options.paths[key])) { @@ -47021,7 +47291,7 @@ var ts; var subst = _a[_i]; var typeOfSubst = typeof subst; if (typeOfSubst === "string") { - if (!hasZeroOrOneAsteriskCharacter(subst)) { + if (!ts.hasZeroOrOneAsteriskCharacter(subst)) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character, subst, key)); } } @@ -47060,6 +47330,9 @@ var ts; if (options.lib && options.noLib) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "lib", "noLib")); } + if (options.noImplicitUseStrict && options.alwaysStrict) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noImplicitUseStrict", "alwaysStrict")); + } var languageVersion = options.target || 0; var outFile = options.outFile || options.out; var firstNonAmbientExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) && !ts.isDeclarationFile(f) ? f : undefined; }); @@ -47136,11 +47409,13 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + ts.compileOnSaveCommandLineOption = { name: "compileOnSave", type: "boolean" }; ts.optionDeclarations = [ { name: "charset", type: "string" }, + ts.compileOnSaveCommandLineOption, { name: "declaration", shortName: "d", @@ -47563,6 +47838,11 @@ var ts; name: "importHelpers", type: "boolean", description: ts.Diagnostics.Import_emit_helpers_from_tslib + }, + { + name: "alwaysStrict", + type: "boolean", + description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file } ]; ts.typingOptionDeclarations = [ @@ -47764,10 +48044,11 @@ var ts; return parseConfigFileTextToJson(fileName, text); } ts.readConfigFile = readConfigFile; - function parseConfigFileTextToJson(fileName, jsonText) { + function parseConfigFileTextToJson(fileName, jsonText, stripComments) { + if (stripComments === void 0) { stripComments = true; } try { - var jsonTextWithoutComments = removeComments(jsonText); - return { config: /\S/.test(jsonTextWithoutComments) ? JSON.parse(jsonTextWithoutComments) : {} }; + var jsonTextToParse = stripComments ? removeComments(jsonText) : jsonText; + return { config: /\S/.test(jsonTextToParse) ? JSON.parse(jsonTextToParse) : {} }; } catch (e) { return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) }; @@ -47901,13 +48182,15 @@ var ts; options = ts.extend(existingOptions, options); options.configFilePath = configFileName; var _c = getFileNames(errors), fileNames = _c.fileNames, wildcardDirectories = _c.wildcardDirectories; + var compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors); return { options: options, fileNames: fileNames, typingOptions: typingOptions, raw: json, errors: errors, - wildcardDirectories: wildcardDirectories + wildcardDirectories: wildcardDirectories, + compileOnSave: compileOnSave }; function tryExtendsName(extendedConfig) { if (!(ts.isRootedDiskPath(extendedConfig) || ts.startsWith(ts.normalizeSlashes(extendedConfig), "./") || ts.startsWith(ts.normalizeSlashes(extendedConfig), "../"))) { @@ -47916,7 +48199,7 @@ var ts; } var extendedConfigPath = ts.toPath(extendedConfig, basePath, getCanonicalFileName); if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json")) { - extendedConfigPath = (extendedConfigPath + ".json"); + extendedConfigPath = extendedConfigPath + ".json"; if (!host.fileExists(extendedConfigPath)) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig)); return; @@ -47985,6 +48268,17 @@ var ts; var _b; } ts.parseJsonConfigFileContent = parseJsonConfigFileContent; + function convertCompileOnSaveOptionFromJson(jsonOption, basePath, errors) { + if (!ts.hasProperty(jsonOption, ts.compileOnSaveCommandLineOption.name)) { + return false; + } + var result = convertJsonOption(ts.compileOnSaveCommandLineOption, jsonOption["compileOnSave"], basePath, errors); + if (typeof result === "boolean" && result) { + return result; + } + return false; + } + ts.convertCompileOnSaveOptionFromJson = convertCompileOnSaveOptionFromJson; function convertCompilerOptionsFromJson(jsonOptions, basePath, configFileName) { var errors = []; var options = convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName); @@ -47998,7 +48292,9 @@ var ts; } ts.convertTypingOptionsFromJson = convertTypingOptionsFromJson; function convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { - var options = ts.getBaseFileName(configFileName) === "jsconfig.json" ? { allowJs: true, maxNodeModuleJsDepth: 2 } : {}; + var options = ts.getBaseFileName(configFileName) === "jsconfig.json" + ? { allowJs: true, maxNodeModuleJsDepth: 2, allowSyntheticDefaultImports: true, skipLibCheck: true } + : {}; convertOptionsFromJson(ts.optionDeclarations, jsonOptions, basePath, options, ts.Diagnostics.Unknown_compiler_option_0, errors); return options; } @@ -48294,8 +48590,7 @@ var ts; _a[ts.DiagnosticCategory.Warning] = yellowForegroundEscapeSequence, _a[ts.DiagnosticCategory.Error] = redForegroundEscapeSequence, _a[ts.DiagnosticCategory.Message] = blueForegroundEscapeSequence, - _a - )); + _a)); function formatAndReset(text, formatStyle) { return formatStyle + text + resetEscapeSequence; } diff --git a/lib/tsserver.js b/lib/tsserver.js index 8bb071cf4a1..f5437988c1a 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -72,7 +72,6 @@ var ts; (function (ts) { ts.timestamp = typeof performance !== "undefined" && performance.now ? function () { return performance.now(); } : Date.now ? Date.now : function () { return +(new Date()); }; })(ts || (ts = {})); -var ts; (function (ts) { var performance; (function (performance) { @@ -150,6 +149,7 @@ var ts; contains: contains, remove: remove, forEachValue: forEachValueInMap, + getKeys: getKeys, clear: clear }; function forEachValueInMap(f) { @@ -157,6 +157,13 @@ var ts; f(key, files[key]); } } + function getKeys() { + var keys = []; + for (var key in files) { + keys.push(key); + } + return keys; + } function get(path) { return files[toKey(path)]; } @@ -533,16 +540,22 @@ var ts; : undefined; } ts.lastOrUndefined = lastOrUndefined; - function binarySearch(array, value) { + function binarySearch(array, value, comparer) { + if (!array || array.length === 0) { + return -1; + } var low = 0; var high = array.length - 1; + comparer = comparer !== undefined + ? comparer + : function (v1, v2) { return (v1 < v2 ? -1 : (v1 > v2 ? 1 : 0)); }; while (low <= high) { var middle = low + ((high - low) >> 1); var midValue = array[middle]; - if (midValue === value) { + if (comparer(midValue, value) === 0) { return middle; } - else if (midValue > value) { + else if (comparer(midValue, value) > 0) { high = middle - 1; } else { @@ -776,6 +789,56 @@ var ts; }; } ts.memoize = memoize; + function chain(a, b, c, d, e) { + if (e) { + var args_2 = []; + for (var i = 0; i < arguments.length; i++) { + args_2[i] = arguments[i]; + } + return function (t) { return compose.apply(void 0, map(args_2, function (f) { return f(t); })); }; + } + else if (d) { + return function (t) { return compose(a(t), b(t), c(t), d(t)); }; + } + else if (c) { + return function (t) { return compose(a(t), b(t), c(t)); }; + } + else if (b) { + return function (t) { return compose(a(t), b(t)); }; + } + else if (a) { + return function (t) { return compose(a(t)); }; + } + else { + return function (t) { return function (u) { return u; }; }; + } + } + ts.chain = chain; + function compose(a, b, c, d, e) { + if (e) { + var args_3 = []; + for (var i = 0; i < arguments.length; i++) { + args_3[i] = arguments[i]; + } + return function (t) { return reduceLeft(args_3, function (u, f) { return f(u); }, t); }; + } + else if (d) { + return function (t) { return d(c(b(a(t)))); }; + } + else if (c) { + return function (t) { return c(b(a(t))); }; + } + else if (b) { + return function (t) { return b(a(t)); }; + } + else if (a) { + return function (t) { return a(t); }; + } + else { + return function (t) { return t; }; + } + } + ts.compose = compose; function formatStringFromArgs(text, args, baseIndex) { baseIndex = baseIndex || 0; return text.replace(/{(\d+)}/g, function (match, index) { return args[+index + baseIndex]; }); @@ -1012,10 +1075,45 @@ var ts; return path && !isRootedDiskPath(path) && path.indexOf("://") !== -1; } ts.isUrl = isUrl; + function isExternalModuleNameRelative(moduleName) { + return /^\.\.?($|[\\/])/.test(moduleName); + } + ts.isExternalModuleNameRelative = isExternalModuleNameRelative; + function getEmitScriptTarget(compilerOptions) { + return compilerOptions.target || 0; + } + ts.getEmitScriptTarget = getEmitScriptTarget; + function getEmitModuleKind(compilerOptions) { + return typeof compilerOptions.module === "number" ? + compilerOptions.module : + getEmitScriptTarget(compilerOptions) === 2 ? ts.ModuleKind.ES6 : ts.ModuleKind.CommonJS; + } + ts.getEmitModuleKind = getEmitModuleKind; + function hasZeroOrOneAsteriskCharacter(str) { + var seenAsterisk = false; + for (var i = 0; i < str.length; i++) { + if (str.charCodeAt(i) === 42) { + if (!seenAsterisk) { + seenAsterisk = true; + } + else { + return false; + } + } + } + return true; + } + ts.hasZeroOrOneAsteriskCharacter = hasZeroOrOneAsteriskCharacter; function isRootedDiskPath(path) { return getRootLength(path) !== 0; } ts.isRootedDiskPath = isRootedDiskPath; + function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) { + return !isRootedDiskPath(absoluteOrRelativePath) + ? absoluteOrRelativePath + : getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, false); + } + ts.convertToRelativePath = convertToRelativePath; function normalizedPathComponents(path, rootLength) { var normalizedParts = getNormalizedParts(path, rootLength); return [path.substr(0, rootLength)].concat(normalizedParts); @@ -1389,6 +1487,14 @@ var ts; return options && options.allowJs ? allSupportedExtensions : ts.supportedTypeScriptExtensions; } ts.getSupportedExtensions = getSupportedExtensions; + function hasJavaScriptFileExtension(fileName) { + return forEach(ts.supportedJavascriptExtensions, function (extension) { return fileExtensionIs(fileName, extension); }); + } + ts.hasJavaScriptFileExtension = hasJavaScriptFileExtension; + function hasTypeScriptFileExtension(fileName) { + return forEach(ts.supportedTypeScriptExtensions, function (extension) { return fileExtensionIs(fileName, extension); }); + } + ts.hasTypeScriptFileExtension = hasTypeScriptFileExtension; function isSupportedSourceFileName(fileName, compilerOptions) { if (!fileName) { return false; @@ -1480,7 +1586,6 @@ var ts; this.transformFlags = 0; this.parent = undefined; this.original = undefined; - this.transformId = 0; } ts.objectAllocator = { getNodeConstructor: function () { return Node; }, @@ -1493,9 +1598,9 @@ var ts; }; var Debug; (function (Debug) { - var currentAssertionLevel; + Debug.currentAssertionLevel = 0; function shouldAssert(level) { - return getCurrentAssertionLevel() >= level; + return Debug.currentAssertionLevel >= level; } Debug.shouldAssert = shouldAssert; function assert(expression, message, verboseDebugInfo) { @@ -1513,30 +1618,7 @@ var ts; Debug.assert(false, message); } Debug.fail = fail; - function getCurrentAssertionLevel() { - if (currentAssertionLevel !== undefined) { - return currentAssertionLevel; - } - if (ts.sys === undefined) { - return 0; - } - var developmentMode = /^development$/i.test(getEnvironmentVariable("NODE_ENV")); - currentAssertionLevel = developmentMode - ? 1 - : 0; - return currentAssertionLevel; - } })(Debug = ts.Debug || (ts.Debug = {})); - function getEnvironmentVariable(name, host) { - if (host && host.getEnvironmentVariable) { - return host.getEnvironmentVariable(name); - } - if (ts.sys && ts.sys.getEnvironmentVariable) { - return ts.sys.getEnvironmentVariable(name); - } - return ""; - } - ts.getEnvironmentVariable = getEnvironmentVariable; function orderedRemoveItemAt(array, index) { for (var i = index; i < array.length - 1; i++) { array[i] = array[i + 1]; @@ -1567,6 +1649,64 @@ var ts; : (function (fileName) { return fileName.toLowerCase(); }); } ts.createGetCanonicalFileName = createGetCanonicalFileName; + function matchPatternOrExact(patternStrings, candidate) { + var patterns = []; + for (var _i = 0, patternStrings_1 = patternStrings; _i < patternStrings_1.length; _i++) { + var patternString = patternStrings_1[_i]; + var pattern = tryParsePattern(patternString); + if (pattern) { + patterns.push(pattern); + } + else if (patternString === candidate) { + return patternString; + } + } + return findBestPatternMatch(patterns, function (_) { return _; }, candidate); + } + ts.matchPatternOrExact = matchPatternOrExact; + function patternText(_a) { + var prefix = _a.prefix, suffix = _a.suffix; + return prefix + "*" + suffix; + } + ts.patternText = patternText; + function matchedText(pattern, candidate) { + Debug.assert(isPatternMatch(pattern, candidate)); + return candidate.substr(pattern.prefix.length, candidate.length - pattern.suffix.length); + } + ts.matchedText = matchedText; + function findBestPatternMatch(values, getPattern, candidate) { + var matchedValue = undefined; + var longestMatchPrefixLength = -1; + for (var _i = 0, values_1 = values; _i < values_1.length; _i++) { + var v = values_1[_i]; + var pattern = getPattern(v); + if (isPatternMatch(pattern, candidate) && pattern.prefix.length > longestMatchPrefixLength) { + longestMatchPrefixLength = pattern.prefix.length; + matchedValue = v; + } + } + return matchedValue; + } + ts.findBestPatternMatch = findBestPatternMatch; + function isPatternMatch(_a, candidate) { + var prefix = _a.prefix, suffix = _a.suffix; + return candidate.length >= prefix.length + suffix.length && + startsWith(candidate, prefix) && + endsWith(candidate, suffix); + } + function tryParsePattern(pattern) { + Debug.assert(hasZeroOrOneAsteriskCharacter(pattern)); + var indexOfStar = pattern.indexOf("*"); + return indexOfStar === -1 ? undefined : { + prefix: pattern.substr(0, indexOfStar), + suffix: pattern.substr(indexOfStar + 1) + }; + } + ts.tryParsePattern = tryParsePattern; + function positionIsSynthesized(pos) { + return !(pos >= 0); + } + ts.positionIsSynthesized = positionIsSynthesized; })(ts || (ts = {})); var ts; (function (ts) { @@ -1760,8 +1900,14 @@ var ts; function isNode4OrLater() { return parseInt(process.version.charAt(1)) >= 4; } + function isFileSystemCaseSensitive() { + if (platform === "win32" || platform === "win64") { + return false; + } + return !fileExists(__filename.toUpperCase()) || !fileExists(__filename.toLowerCase()); + } var platform = _os.platform(); - var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin"; + var useCaseSensitiveFileNames = isFileSystemCaseSensitive(); function readFile(fileName, encoding) { if (!fileExists(fileName)) { return undefined; @@ -1886,6 +2032,9 @@ var ts; }, watchDirectory: function (directoryName, callback, recursive) { var options; + if (!directoryExists(directoryName)) { + return; + } if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) { options = { persistent: true, recursive: !!recursive }; } @@ -1997,19 +2146,43 @@ var ts; realpath: realpath }; } + function recursiveCreateDirectory(directoryPath, sys) { + var basePath = ts.getDirectoryPath(directoryPath); + var shouldCreateParent = directoryPath !== basePath && !sys.directoryExists(basePath); + if (shouldCreateParent) { + recursiveCreateDirectory(basePath, sys); + } + if (shouldCreateParent || !sys.directoryExists(directoryPath)) { + sys.createDirectory(directoryPath); + } + } + var sys; if (typeof ChakraHost !== "undefined") { - return getChakraSystem(); + sys = getChakraSystem(); } else if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { - return getWScriptSystem(); + sys = getWScriptSystem(); } else if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof require !== "undefined") { - return getNodeSystem(); + sys = getNodeSystem(); } - else { - return undefined; + if (sys) { + var originalWriteFile_1 = sys.writeFile; + sys.writeFile = function (path, data, writeBom) { + var directoryPath = ts.getDirectoryPath(ts.normalizeSlashes(path)); + if (directoryPath && !sys.directoryExists(directoryPath)) { + recursiveCreateDirectory(directoryPath, sys); + } + originalWriteFile_1.call(sys, path, data, writeBom); + }; } + return sys; })(); + if (ts.sys && ts.sys.getEnvironmentVariable) { + ts.Debug.currentAssertionLevel = /^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV")) + ? 1 + : 0; + } })(ts || (ts = {})); var ts; (function (ts) { @@ -2334,7 +2507,7 @@ var ts; The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2407, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_2407", message: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter." }, Setters_cannot_return_a_value: { code: 2408, category: ts.DiagnosticCategory.Error, key: "Setters_cannot_return_a_value_2408", message: "Setters cannot return a value." }, Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { code: 2409, category: ts.DiagnosticCategory.Error, key: "Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class_2409", message: "Return type of constructor signature must be assignable to the instance type of the class" }, - All_symbols_within_a_with_block_will_be_resolved_to_any: { code: 2410, category: ts.DiagnosticCategory.Error, key: "All_symbols_within_a_with_block_will_be_resolved_to_any_2410", message: "All symbols within a 'with' block will be resolved to 'any'." }, + The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any: { code: 2410, category: ts.DiagnosticCategory.Error, key: "The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any_2410", message: "The 'with' statement is not supported. All symbols in a 'with' block will have type 'any'." }, Property_0_of_type_1_is_not_assignable_to_string_index_type_2: { code: 2411, category: ts.DiagnosticCategory.Error, key: "Property_0_of_type_1_is_not_assignable_to_string_index_type_2_2411", message: "Property '{0}' of type '{1}' is not assignable to string index type '{2}'." }, Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2: { code: 2412, category: ts.DiagnosticCategory.Error, key: "Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2_2412", message: "Property '{0}' of type '{1}' is not assignable to numeric index type '{2}'." }, Numeric_index_type_0_is_not_assignable_to_string_index_type_1: { code: 2413, category: ts.DiagnosticCategory.Error, key: "Numeric_index_type_0_is_not_assignable_to_string_index_type_1_2413", message: "Numeric index type '{0}' is not assignable to string index type '{1}'." }, @@ -2495,7 +2668,7 @@ var ts; this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation: { code: 2683, category: ts.DiagnosticCategory.Error, key: "this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_2683", message: "'this' implicitly has type 'any' because it does not have a type annotation." }, The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1: { code: 2684, category: ts.DiagnosticCategory.Error, key: "The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1_2684", message: "The 'this' context of type '{0}' is not assignable to method's 'this' of type '{1}'." }, The_this_types_of_each_signature_are_incompatible: { code: 2685, category: ts.DiagnosticCategory.Error, key: "The_this_types_of_each_signature_are_incompatible_2685", message: "The 'this' types of each signature are incompatible." }, - Identifier_0_must_be_imported_from_a_module: { code: 2686, category: ts.DiagnosticCategory.Error, key: "Identifier_0_must_be_imported_from_a_module_2686", message: "Identifier '{0}' must be imported from a module" }, + _0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead: { code: 2686, category: ts.DiagnosticCategory.Error, key: "_0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead_2686", message: "'{0}' refers to a UMD global, but the current file is a module. Consider adding an import instead." }, All_declarations_of_0_must_have_identical_modifiers: { code: 2687, category: ts.DiagnosticCategory.Error, key: "All_declarations_of_0_must_have_identical_modifiers_2687", message: "All declarations of '{0}' must have identical modifiers." }, Cannot_find_type_definition_file_for_0: { code: 2688, category: ts.DiagnosticCategory.Error, key: "Cannot_find_type_definition_file_for_0_2688", message: "Cannot find type definition file for '{0}'." }, Cannot_extend_an_interface_0_Did_you_mean_implements: { code: 2689, category: ts.DiagnosticCategory.Error, key: "Cannot_extend_an_interface_0_Did_you_mean_implements_2689", message: "Cannot extend an interface '{0}'. Did you mean 'implements'?" }, @@ -2728,6 +2901,8 @@ var ts; No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0: { code: 6137, category: ts.DiagnosticCategory.Message, key: "No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0_6137", message: "No types specified in 'package.json' but 'allowJs' is set, so returning 'main' value of '{0}'" }, Property_0_is_declared_but_never_used: { code: 6138, category: ts.DiagnosticCategory.Error, key: "Property_0_is_declared_but_never_used_6138", message: "Property '{0}' is declared but never used." }, Import_emit_helpers_from_tslib: { code: 6139, category: ts.DiagnosticCategory.Message, key: "Import_emit_helpers_from_tslib_6139", message: "Import emit helpers from 'tslib'." }, + Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: { code: 6140, category: ts.DiagnosticCategory.Error, key: "Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using__6140", message: "Auto discovery for typings is enabled in project '{0}'. Running extra resolution pass for module '{1}' using cache location '{2}'." }, + Parse_in_strict_mode_and_emit_use_strict_for_each_source_file: { code: 6141, category: ts.DiagnosticCategory.Message, key: "Parse_in_strict_mode_and_emit_use_strict_for_each_source_file_6141", message: "Parse in strict mode and emit \"use strict\" for each source file" }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter_0_implicitly_has_an_1_type_7006", message: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member_0_implicitly_has_an_1_type_7008", message: "Member '{0}' implicitly has an '{1}' type." }, @@ -2752,6 +2927,7 @@ var ts; Binding_element_0_implicitly_has_an_1_type: { code: 7031, category: ts.DiagnosticCategory.Error, key: "Binding_element_0_implicitly_has_an_1_type_7031", message: "Binding element '{0}' implicitly has an '{1}' type." }, Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation: { code: 7032, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation_7032", message: "Property '{0}' implicitly has type 'any', because its set accessor lacks a parameter type annotation." }, Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation: { code: 7033, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation_7033", message: "Property '{0}' implicitly has type 'any', because its get accessor lacks a return type annotation." }, + Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined: { code: 7034, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined_7034", message: "Variable '{0}' implicitly has type 'any' in some locations where its type cannot be determined." }, You_cannot_rename_this_element: { code: 8000, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_this_element_8000", message: "You cannot rename this element." }, You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", message: "You cannot rename elements that are defined in the standard TypeScript library." }, import_can_only_be_used_in_a_ts_file: { code: 8002, category: ts.DiagnosticCategory.Error, key: "import_can_only_be_used_in_a_ts_file_8002", message: "'import ... =' can only be used in a .ts file." }, @@ -2781,7 +2957,14 @@ var ts; super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class: { code: 17009, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class_17009", message: "'super' must be called before accessing 'this' in the constructor of a derived class." }, Unknown_typing_option_0: { code: 17010, category: ts.DiagnosticCategory.Error, key: "Unknown_typing_option_0_17010", message: "Unknown typing option '{0}'." }, Circularity_detected_while_resolving_configuration_Colon_0: { code: 18000, category: ts.DiagnosticCategory.Error, key: "Circularity_detected_while_resolving_configuration_Colon_0_18000", message: "Circularity detected while resolving configuration: {0}" }, - The_path_in_an_extends_options_must_be_relative_or_rooted: { code: 18001, category: ts.DiagnosticCategory.Error, key: "The_path_in_an_extends_options_must_be_relative_or_rooted_18001", message: "The path in an 'extends' options must be relative or rooted." } + The_path_in_an_extends_options_must_be_relative_or_rooted: { code: 18001, category: ts.DiagnosticCategory.Error, key: "The_path_in_an_extends_options_must_be_relative_or_rooted_18001", message: "The path in an 'extends' options must be relative or rooted." }, + Add_missing_super_call: { code: 90001, category: ts.DiagnosticCategory.Message, key: "Add_missing_super_call_90001", message: "Add missing 'super()' call." }, + Make_super_call_the_first_statement_in_the_constructor: { code: 90002, category: ts.DiagnosticCategory.Message, key: "Make_super_call_the_first_statement_in_the_constructor_90002", message: "Make 'super()' call the first statement in the constructor." }, + Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'" }, + Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers" }, + Implement_interface_on_reference: { code: 90005, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_reference_90005", message: "Implement interface on reference" }, + Implement_interface_on_class: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_class_90006", message: "Implement interface on class" }, + Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" } }; })(ts || (ts = {})); var ts; @@ -3691,7 +3874,7 @@ var ts; return token = 69; } function scanBinaryOrOctalDigits(base) { - ts.Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8"); + ts.Debug.assert(base === 2 || base === 8, "Expected either base 2 or base 8"); var value = 0; var numberOfDigits = 0; while (true) { @@ -4334,11 +4517,13 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + ts.compileOnSaveCommandLineOption = { name: "compileOnSave", type: "boolean" }; ts.optionDeclarations = [ { name: "charset", type: "string" }, + ts.compileOnSaveCommandLineOption, { name: "declaration", shortName: "d", @@ -4761,6 +4946,11 @@ var ts; name: "importHelpers", type: "boolean", description: ts.Diagnostics.Import_emit_helpers_from_tslib + }, + { + name: "alwaysStrict", + type: "boolean", + description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file } ]; ts.typingOptionDeclarations = [ @@ -4962,10 +5152,11 @@ var ts; return parseConfigFileTextToJson(fileName, text); } ts.readConfigFile = readConfigFile; - function parseConfigFileTextToJson(fileName, jsonText) { + function parseConfigFileTextToJson(fileName, jsonText, stripComments) { + if (stripComments === void 0) { stripComments = true; } try { - var jsonTextWithoutComments = removeComments(jsonText); - return { config: /\S/.test(jsonTextWithoutComments) ? JSON.parse(jsonTextWithoutComments) : {} }; + var jsonTextToParse = stripComments ? removeComments(jsonText) : jsonText; + return { config: /\S/.test(jsonTextToParse) ? JSON.parse(jsonTextToParse) : {} }; } catch (e) { return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) }; @@ -5099,13 +5290,15 @@ var ts; options = ts.extend(existingOptions, options); options.configFilePath = configFileName; var _c = getFileNames(errors), fileNames = _c.fileNames, wildcardDirectories = _c.wildcardDirectories; + var compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors); return { options: options, fileNames: fileNames, typingOptions: typingOptions, raw: json, errors: errors, - wildcardDirectories: wildcardDirectories + wildcardDirectories: wildcardDirectories, + compileOnSave: compileOnSave }; function tryExtendsName(extendedConfig) { if (!(ts.isRootedDiskPath(extendedConfig) || ts.startsWith(ts.normalizeSlashes(extendedConfig), "./") || ts.startsWith(ts.normalizeSlashes(extendedConfig), "../"))) { @@ -5183,6 +5376,17 @@ var ts; var _b; } ts.parseJsonConfigFileContent = parseJsonConfigFileContent; + function convertCompileOnSaveOptionFromJson(jsonOption, basePath, errors) { + if (!ts.hasProperty(jsonOption, ts.compileOnSaveCommandLineOption.name)) { + return false; + } + var result = convertJsonOption(ts.compileOnSaveCommandLineOption, jsonOption["compileOnSave"], basePath, errors); + if (typeof result === "boolean" && result) { + return result; + } + return false; + } + ts.convertCompileOnSaveOptionFromJson = convertCompileOnSaveOptionFromJson; function convertCompilerOptionsFromJson(jsonOptions, basePath, configFileName) { var errors = []; var options = convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName); @@ -5196,7 +5400,9 @@ var ts; } ts.convertTypingOptionsFromJson = convertTypingOptionsFromJson; function convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { - var options = ts.getBaseFileName(configFileName) === "jsconfig.json" ? { allowJs: true, maxNodeModuleJsDepth: 2 } : {}; + var options = ts.getBaseFileName(configFileName) === "jsconfig.json" + ? { allowJs: true, maxNodeModuleJsDepth: 2, allowSyntheticDefaultImports: true, skipLibCheck: true } + : {}; convertOptionsFromJson(ts.optionDeclarations, jsonOptions, basePath, options, ts.Diagnostics.Unknown_compiler_option_0, errors); return options; } @@ -5395,6 +5601,937 @@ var ts; } })(ts || (ts = {})); var ts; +(function (ts) { + var JsTyping; + (function (JsTyping) { + ; + ; + var safeList; + var EmptySafeList = ts.createMap(); + function discoverTypings(host, fileNames, projectRootPath, safeListPath, packageNameToTypingLocation, typingOptions, compilerOptions) { + var inferredTypings = ts.createMap(); + if (!typingOptions || !typingOptions.enableAutoDiscovery) { + return { cachedTypingPaths: [], newTypingNames: [], filesToWatch: [] }; + } + fileNames = ts.filter(ts.map(fileNames, ts.normalizePath), function (f) { + var kind = ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)); + return kind === 1 || kind === 2; + }); + if (!safeList) { + var result = ts.readConfigFile(safeListPath, function (path) { return host.readFile(path); }); + safeList = result.config ? ts.createMap(result.config) : EmptySafeList; + } + var filesToWatch = []; + var searchDirs = []; + var exclude = []; + mergeTypings(typingOptions.include); + exclude = typingOptions.exclude || []; + var possibleSearchDirs = ts.map(fileNames, ts.getDirectoryPath); + if (projectRootPath !== undefined) { + possibleSearchDirs.push(projectRootPath); + } + searchDirs = ts.deduplicate(possibleSearchDirs); + for (var _i = 0, searchDirs_1 = searchDirs; _i < searchDirs_1.length; _i++) { + var searchDir = searchDirs_1[_i]; + var packageJsonPath = ts.combinePaths(searchDir, "package.json"); + getTypingNamesFromJson(packageJsonPath, filesToWatch); + var bowerJsonPath = ts.combinePaths(searchDir, "bower.json"); + getTypingNamesFromJson(bowerJsonPath, filesToWatch); + var nodeModulesPath = ts.combinePaths(searchDir, "node_modules"); + getTypingNamesFromNodeModuleFolder(nodeModulesPath); + } + getTypingNamesFromSourceFileNames(fileNames); + for (var name_7 in packageNameToTypingLocation) { + if (name_7 in inferredTypings && !inferredTypings[name_7]) { + inferredTypings[name_7] = packageNameToTypingLocation[name_7]; + } + } + for (var _a = 0, exclude_1 = exclude; _a < exclude_1.length; _a++) { + var excludeTypingName = exclude_1[_a]; + delete inferredTypings[excludeTypingName]; + } + var newTypingNames = []; + var cachedTypingPaths = []; + for (var typing in inferredTypings) { + if (inferredTypings[typing] !== undefined) { + cachedTypingPaths.push(inferredTypings[typing]); + } + else { + newTypingNames.push(typing); + } + } + return { cachedTypingPaths: cachedTypingPaths, newTypingNames: newTypingNames, filesToWatch: filesToWatch }; + function mergeTypings(typingNames) { + if (!typingNames) { + return; + } + for (var _i = 0, typingNames_1 = typingNames; _i < typingNames_1.length; _i++) { + var typing = typingNames_1[_i]; + if (!(typing in inferredTypings)) { + inferredTypings[typing] = undefined; + } + } + } + function getTypingNamesFromJson(jsonPath, filesToWatch) { + var result = ts.readConfigFile(jsonPath, function (path) { return host.readFile(path); }); + if (result.config) { + var jsonConfig = result.config; + filesToWatch.push(jsonPath); + if (jsonConfig.dependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.dependencies)); + } + if (jsonConfig.devDependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.devDependencies)); + } + if (jsonConfig.optionalDependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.optionalDependencies)); + } + if (jsonConfig.peerDependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.peerDependencies)); + } + } + } + function getTypingNamesFromSourceFileNames(fileNames) { + var jsFileNames = ts.filter(fileNames, ts.hasJavaScriptFileExtension); + var inferredTypingNames = ts.map(jsFileNames, function (f) { return ts.removeFileExtension(ts.getBaseFileName(f.toLowerCase())); }); + var cleanedTypingNames = ts.map(inferredTypingNames, function (f) { return f.replace(/((?:\.|-)min(?=\.|$))|((?:-|\.)\d+)/g, ""); }); + if (safeList !== EmptySafeList) { + mergeTypings(ts.filter(cleanedTypingNames, function (f) { return f in safeList; })); + } + var hasJsxFile = ts.forEach(fileNames, function (f) { return ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)) === 2; }); + if (hasJsxFile) { + mergeTypings(["react"]); + } + } + function getTypingNamesFromNodeModuleFolder(nodeModulesPath) { + if (!host.directoryExists(nodeModulesPath)) { + return; + } + var typingNames = []; + var fileNames = host.readDirectory(nodeModulesPath, [".json"], undefined, undefined, 2); + for (var _i = 0, fileNames_2 = fileNames; _i < fileNames_2.length; _i++) { + var fileName = fileNames_2[_i]; + var normalizedFileName = ts.normalizePath(fileName); + if (ts.getBaseFileName(normalizedFileName) !== "package.json") { + continue; + } + var result = ts.readConfigFile(normalizedFileName, function (path) { return host.readFile(path); }); + if (!result.config) { + continue; + } + var packageJson = result.config; + if (packageJson._requiredBy && + ts.filter(packageJson._requiredBy, function (r) { return r[0] === "#" || r === "/"; }).length === 0) { + continue; + } + if (!packageJson.name) { + continue; + } + if (packageJson.typings) { + var absolutePath = ts.getNormalizedAbsolutePath(packageJson.typings, ts.getDirectoryPath(normalizedFileName)); + inferredTypings[packageJson.name] = absolutePath; + } + else { + typingNames.push(packageJson.name); + } + } + mergeTypings(typingNames); + } + } + JsTyping.discoverTypings = discoverTypings; + })(JsTyping = ts.JsTyping || (ts.JsTyping = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + (function (LogLevel) { + LogLevel[LogLevel["terse"] = 0] = "terse"; + LogLevel[LogLevel["normal"] = 1] = "normal"; + LogLevel[LogLevel["requestTime"] = 2] = "requestTime"; + LogLevel[LogLevel["verbose"] = 3] = "verbose"; + })(server.LogLevel || (server.LogLevel = {})); + var LogLevel = server.LogLevel; + server.emptyArray = []; + var Msg; + (function (Msg) { + Msg.Err = "Err"; + Msg.Info = "Info"; + Msg.Perf = "Perf"; + })(Msg = server.Msg || (server.Msg = {})); + function getProjectRootPath(project) { + switch (project.projectKind) { + case server.ProjectKind.Configured: + return ts.getDirectoryPath(project.getProjectName()); + case server.ProjectKind.Inferred: + return ""; + case server.ProjectKind.External: + var projectName = ts.normalizeSlashes(project.getProjectName()); + return project.projectService.host.fileExists(projectName) ? ts.getDirectoryPath(projectName) : projectName; + } + } + function createInstallTypingsRequest(project, typingOptions, cachePath) { + return { + projectName: project.getProjectName(), + fileNames: project.getFileNames(), + compilerOptions: project.getCompilerOptions(), + typingOptions: typingOptions, + projectRootPath: getProjectRootPath(project), + cachePath: cachePath, + kind: "discover" + }; + } + server.createInstallTypingsRequest = createInstallTypingsRequest; + var Errors; + (function (Errors) { + function ThrowNoProject() { + throw new Error("No Project."); + } + Errors.ThrowNoProject = ThrowNoProject; + function ThrowProjectLanguageServiceDisabled() { + throw new Error("The project's language service is disabled."); + } + Errors.ThrowProjectLanguageServiceDisabled = ThrowProjectLanguageServiceDisabled; + function ThrowProjectDoesNotContainDocument(fileName, project) { + throw new Error("Project '" + project.getProjectName() + "' does not contain document '" + fileName + "'"); + } + Errors.ThrowProjectDoesNotContainDocument = ThrowProjectDoesNotContainDocument; + })(Errors = server.Errors || (server.Errors = {})); + function getDefaultFormatCodeSettings(host) { + return { + indentSize: 4, + tabSize: 4, + newLineCharacter: host.newLine || "\n", + convertTabsToSpaces: true, + indentStyle: ts.IndentStyle.Smart, + insertSpaceAfterCommaDelimiter: true, + insertSpaceAfterSemicolonInForStatements: true, + insertSpaceBeforeAndAfterBinaryOperators: true, + insertSpaceAfterKeywordsInControlFlowStatements: true, + insertSpaceAfterFunctionKeywordForAnonymousFunctions: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, + insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, + insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, + placeOpenBraceOnNewLineForFunctions: false, + placeOpenBraceOnNewLineForControlBlocks: false + }; + } + server.getDefaultFormatCodeSettings = getDefaultFormatCodeSettings; + function mergeMaps(target, source) { + for (var key in source) { + if (ts.hasProperty(source, key)) { + target[key] = source[key]; + } + } + } + server.mergeMaps = mergeMaps; + function removeItemFromSet(items, itemToRemove) { + if (items.length === 0) { + return; + } + var index = items.indexOf(itemToRemove); + if (index < 0) { + return; + } + if (index === items.length - 1) { + items.pop(); + } + else { + items[index] = items.pop(); + } + } + server.removeItemFromSet = removeItemFromSet; + function toNormalizedPath(fileName) { + return ts.normalizePath(fileName); + } + server.toNormalizedPath = toNormalizedPath; + function normalizedPathToPath(normalizedPath, currentDirectory, getCanonicalFileName) { + var f = ts.isRootedDiskPath(normalizedPath) ? normalizedPath : ts.getNormalizedAbsolutePath(normalizedPath, currentDirectory); + return getCanonicalFileName(f); + } + server.normalizedPathToPath = normalizedPathToPath; + function asNormalizedPath(fileName) { + return fileName; + } + server.asNormalizedPath = asNormalizedPath; + function createNormalizedPathMap() { + var map = Object.create(null); + return { + get: function (path) { + return map[path]; + }, + set: function (path, value) { + map[path] = value; + }, + contains: function (path) { + return ts.hasProperty(map, path); + }, + remove: function (path) { + delete map[path]; + } + }; + } + server.createNormalizedPathMap = createNormalizedPathMap; + function throwLanguageServiceIsDisabledError() { + throw new Error("LanguageService is disabled"); + } + server.nullLanguageService = { + cleanupSemanticCache: throwLanguageServiceIsDisabledError, + getSyntacticDiagnostics: throwLanguageServiceIsDisabledError, + getSemanticDiagnostics: throwLanguageServiceIsDisabledError, + getCompilerOptionsDiagnostics: throwLanguageServiceIsDisabledError, + getSyntacticClassifications: throwLanguageServiceIsDisabledError, + getEncodedSyntacticClassifications: throwLanguageServiceIsDisabledError, + getSemanticClassifications: throwLanguageServiceIsDisabledError, + getEncodedSemanticClassifications: throwLanguageServiceIsDisabledError, + getCompletionsAtPosition: throwLanguageServiceIsDisabledError, + findReferences: throwLanguageServiceIsDisabledError, + getCompletionEntryDetails: throwLanguageServiceIsDisabledError, + getQuickInfoAtPosition: throwLanguageServiceIsDisabledError, + findRenameLocations: throwLanguageServiceIsDisabledError, + getNameOrDottedNameSpan: throwLanguageServiceIsDisabledError, + getBreakpointStatementAtPosition: throwLanguageServiceIsDisabledError, + getBraceMatchingAtPosition: throwLanguageServiceIsDisabledError, + getSignatureHelpItems: throwLanguageServiceIsDisabledError, + getDefinitionAtPosition: throwLanguageServiceIsDisabledError, + getRenameInfo: throwLanguageServiceIsDisabledError, + getTypeDefinitionAtPosition: throwLanguageServiceIsDisabledError, + getReferencesAtPosition: throwLanguageServiceIsDisabledError, + getDocumentHighlights: throwLanguageServiceIsDisabledError, + getOccurrencesAtPosition: throwLanguageServiceIsDisabledError, + getNavigateToItems: throwLanguageServiceIsDisabledError, + getNavigationBarItems: throwLanguageServiceIsDisabledError, + getNavigationTree: throwLanguageServiceIsDisabledError, + getOutliningSpans: throwLanguageServiceIsDisabledError, + getTodoComments: throwLanguageServiceIsDisabledError, + getIndentationAtPosition: throwLanguageServiceIsDisabledError, + getFormattingEditsForRange: throwLanguageServiceIsDisabledError, + getFormattingEditsForDocument: throwLanguageServiceIsDisabledError, + getFormattingEditsAfterKeystroke: throwLanguageServiceIsDisabledError, + getDocCommentTemplateAtPosition: throwLanguageServiceIsDisabledError, + isValidBraceCompletionAtPosition: throwLanguageServiceIsDisabledError, + getEmitOutput: throwLanguageServiceIsDisabledError, + getProgram: throwLanguageServiceIsDisabledError, + getNonBoundSourceFile: throwLanguageServiceIsDisabledError, + dispose: throwLanguageServiceIsDisabledError, + getCompletionEntrySymbol: throwLanguageServiceIsDisabledError, + getImplementationAtPosition: throwLanguageServiceIsDisabledError, + getSourceFile: throwLanguageServiceIsDisabledError, + getCodeFixesAtPosition: throwLanguageServiceIsDisabledError + }; + server.nullLanguageServiceHost = { + setCompilationSettings: function () { return undefined; }, + notifyFileRemoved: function () { return undefined; } + }; + function isInferredProjectName(name) { + return /dev\/null\/inferredProject\d+\*/.test(name); + } + server.isInferredProjectName = isInferredProjectName; + function makeInferredProjectName(counter) { + return "/dev/null/inferredProject" + counter + "*"; + } + server.makeInferredProjectName = makeInferredProjectName; + var ThrottledOperations = (function () { + function ThrottledOperations(host) { + this.host = host; + this.pendingTimeouts = ts.createMap(); + } + ThrottledOperations.prototype.schedule = function (operationId, delay, cb) { + if (ts.hasProperty(this.pendingTimeouts, operationId)) { + this.host.clearTimeout(this.pendingTimeouts[operationId]); + } + this.pendingTimeouts[operationId] = this.host.setTimeout(ThrottledOperations.run, delay, this, operationId, cb); + }; + ThrottledOperations.run = function (self, operationId, cb) { + delete self.pendingTimeouts[operationId]; + cb(); + }; + return ThrottledOperations; + }()); + server.ThrottledOperations = ThrottledOperations; + var GcTimer = (function () { + function GcTimer(host, delay, logger) { + this.host = host; + this.delay = delay; + this.logger = logger; + } + GcTimer.prototype.scheduleCollect = function () { + if (!this.host.gc || this.timerId != undefined) { + return; + } + this.timerId = this.host.setTimeout(GcTimer.run, this.delay, this); + }; + GcTimer.run = function (self) { + self.timerId = undefined; + var log = self.logger.hasLevel(LogLevel.requestTime); + var before = log && self.host.getMemoryUsage(); + self.host.gc(); + if (log) { + var after = self.host.getMemoryUsage(); + self.logger.perftrc("GC::before " + before + ", after " + after); + } + }; + return GcTimer; + }()); + server.GcTimer = GcTimer; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + function trace(host, message) { + host.trace(ts.formatMessage.apply(undefined, arguments)); + } + ts.trace = trace; + function isTraceEnabled(compilerOptions, host) { + return compilerOptions.traceResolution && host.trace !== undefined; + } + ts.isTraceEnabled = isTraceEnabled; + function createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations) { + return { resolvedModule: resolvedFileName ? { resolvedFileName: resolvedFileName, isExternalLibraryImport: isExternalLibraryImport } : undefined, failedLookupLocations: failedLookupLocations }; + } + ts.createResolvedModule = createResolvedModule; + function moduleHasNonRelativeName(moduleName) { + return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); + } + function tryReadTypesSection(packageJsonPath, baseDirectory, state) { + var jsonContent = readJson(packageJsonPath, state.host); + function tryReadFromField(fieldName) { + if (ts.hasProperty(jsonContent, fieldName)) { + var typesFile = jsonContent[fieldName]; + if (typeof typesFile === "string") { + var typesFilePath_1 = ts.normalizePath(ts.combinePaths(baseDirectory, typesFile)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath_1); + } + return typesFilePath_1; + } + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof typesFile); + } + } + } + } + var typesFilePath = tryReadFromField("typings") || tryReadFromField("types"); + if (typesFilePath) { + return typesFilePath; + } + if (state.compilerOptions.allowJs && jsonContent.main && typeof jsonContent.main === "string") { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0, jsonContent.main); + } + var mainFilePath = ts.normalizePath(ts.combinePaths(baseDirectory, jsonContent.main)); + return mainFilePath; + } + return undefined; + } + function readJson(path, host) { + try { + var jsonText = host.readFile(path); + return jsonText ? JSON.parse(jsonText) : {}; + } + catch (e) { + return {}; + } + } + var typeReferenceExtensions = [".d.ts"]; + function getEffectiveTypeRoots(options, host) { + if (options.typeRoots) { + return options.typeRoots; + } + var currentDirectory; + if (options.configFilePath) { + currentDirectory = ts.getDirectoryPath(options.configFilePath); + } + else if (host.getCurrentDirectory) { + currentDirectory = host.getCurrentDirectory(); + } + return currentDirectory !== undefined && getDefaultTypeRoots(currentDirectory, host); + } + ts.getEffectiveTypeRoots = getEffectiveTypeRoots; + function getDefaultTypeRoots(currentDirectory, host) { + if (!host.directoryExists) { + return [ts.combinePaths(currentDirectory, nodeModulesAtTypes)]; + } + var typeRoots; + while (true) { + var atTypes = ts.combinePaths(currentDirectory, nodeModulesAtTypes); + if (host.directoryExists(atTypes)) { + (typeRoots || (typeRoots = [])).push(atTypes); + } + var parent_1 = ts.getDirectoryPath(currentDirectory); + if (parent_1 === currentDirectory) { + break; + } + currentDirectory = parent_1; + } + return typeRoots; + } + var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types"); + function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host) { + var traceEnabled = isTraceEnabled(options, host); + var moduleResolutionState = { + compilerOptions: options, + host: host, + skipTsx: true, + traceEnabled: traceEnabled + }; + var typeRoots = getEffectiveTypeRoots(options, host); + if (traceEnabled) { + if (containingFile === undefined) { + if (typeRoots === undefined) { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set, typeReferenceDirectiveName); + } + else { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1, typeReferenceDirectiveName, typeRoots); + } + } + else { + if (typeRoots === undefined) { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set, typeReferenceDirectiveName, containingFile); + } + else { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, typeRoots); + } + } + } + var failedLookupLocations = []; + if (typeRoots && typeRoots.length) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", ")); + } + var primarySearchPaths = typeRoots; + for (var _i = 0, primarySearchPaths_1 = primarySearchPaths; _i < primarySearchPaths_1.length; _i++) { + var typeRoot = primarySearchPaths_1[_i]; + var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); + var candidateDirectory = ts.getDirectoryPath(candidate); + var resolvedFile_1 = loadNodeModuleFromDirectory(typeReferenceExtensions, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState); + if (resolvedFile_1) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile_1, true); + } + return { + resolvedTypeReferenceDirective: { primary: true, resolvedFileName: resolvedFile_1 }, + failedLookupLocations: failedLookupLocations + }; + } + } + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths); + } + } + var resolvedFile; + var initialLocationForSecondaryLookup; + if (containingFile) { + initialLocationForSecondaryLookup = ts.getDirectoryPath(containingFile); + } + if (initialLocationForSecondaryLookup !== undefined) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); + } + resolvedFile = loadModuleFromNodeModules(typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, false); + if (traceEnabled) { + if (resolvedFile) { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile, false); + } + else { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); + } + } + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder); + } + } + return { + resolvedTypeReferenceDirective: resolvedFile + ? { primary: false, resolvedFileName: resolvedFile } + : undefined, + failedLookupLocations: failedLookupLocations + }; + } + ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective; + function getAutomaticTypeDirectiveNames(options, host) { + if (options.types) { + return options.types; + } + var result = []; + if (host.directoryExists && host.getDirectories) { + var typeRoots = getEffectiveTypeRoots(options, host); + if (typeRoots) { + for (var _i = 0, typeRoots_1 = typeRoots; _i < typeRoots_1.length; _i++) { + var root = typeRoots_1[_i]; + if (host.directoryExists(root)) { + for (var _a = 0, _b = host.getDirectories(root); _a < _b.length; _a++) { + var typeDirectivePath = _b[_a]; + var normalized = ts.normalizePath(typeDirectivePath); + var packageJsonPath = pathToPackageJson(ts.combinePaths(root, normalized)); + var isNotNeededPackage = host.fileExists(packageJsonPath) && readJson(packageJsonPath, host).typings === null; + if (!isNotNeededPackage) { + result.push(ts.getBaseFileName(normalized)); + } + } + } + } + } + } + return result; + } + ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; + function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + var traceEnabled = isTraceEnabled(compilerOptions, host); + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); + } + var moduleResolution = compilerOptions.moduleResolution; + if (moduleResolution === undefined) { + moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + if (traceEnabled) { + trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + var result; + switch (moduleResolution) { + case ts.ModuleResolutionKind.NodeJs: + result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host); + break; + case ts.ModuleResolutionKind.Classic: + result = classicNameResolver(moduleName, containingFile, compilerOptions, host); + break; + } + if (traceEnabled) { + if (result.resolvedModule) { + trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.resolvedModule.resolvedFileName); + } + else { + trace(host, ts.Diagnostics.Module_name_0_was_not_resolved, moduleName); + } + } + return result; + } + ts.resolveModuleName = resolveModuleName; + function tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { + if (moduleHasNonRelativeName(moduleName)) { + return tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state); + } + else { + return tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state); + } + } + function tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { + if (!state.compilerOptions.rootDirs) { + return undefined; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0, moduleName); + } + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var matchedRootDir; + var matchedNormalizedPrefix; + for (var _i = 0, _a = state.compilerOptions.rootDirs; _i < _a.length; _i++) { + var rootDir = _a[_i]; + var normalizedRoot = ts.normalizePath(rootDir); + if (!ts.endsWith(normalizedRoot, ts.directorySeparator)) { + normalizedRoot += ts.directorySeparator; + } + var isLongestMatchingPrefix = ts.startsWith(candidate, normalizedRoot) && + (matchedNormalizedPrefix === undefined || matchedNormalizedPrefix.length < normalizedRoot.length); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Checking_if_0_is_the_longest_matching_prefix_for_1_2, normalizedRoot, candidate, isLongestMatchingPrefix); + } + if (isLongestMatchingPrefix) { + matchedNormalizedPrefix = normalizedRoot; + matchedRootDir = rootDir; + } + } + if (matchedNormalizedPrefix) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Longest_matching_prefix_for_0_is_1, candidate, matchedNormalizedPrefix); + } + var suffix = candidate.substr(matchedNormalizedPrefix.length); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, matchedNormalizedPrefix, candidate); + } + var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(containingDirectory, state.host), state); + if (resolvedFileName) { + return resolvedFileName; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Trying_other_entries_in_rootDirs); + } + for (var _b = 0, _c = state.compilerOptions.rootDirs; _b < _c.length; _b++) { + var rootDir = _c[_b]; + if (rootDir === matchedRootDir) { + continue; + } + var candidate_1 = ts.combinePaths(ts.normalizePath(rootDir), suffix); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, rootDir, candidate_1); + } + var baseDirectory = ts.getDirectoryPath(candidate_1); + var resolvedFileName_1 = loader(candidate_1, supportedExtensions, failedLookupLocations, !directoryProbablyExists(baseDirectory, state.host), state); + if (resolvedFileName_1) { + return resolvedFileName_1; + } + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Module_resolution_using_rootDirs_has_failed); + } + } + return undefined; + } + function tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state) { + if (!state.compilerOptions.baseUrl) { + return undefined; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, state.compilerOptions.baseUrl, moduleName); + } + var matchedPattern = undefined; + if (state.compilerOptions.paths) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); + } + matchedPattern = ts.matchPatternOrExact(ts.getOwnKeys(state.compilerOptions.paths), moduleName); + } + if (matchedPattern) { + var matchedStar = typeof matchedPattern === "string" ? undefined : ts.matchedText(matchedPattern, moduleName); + var matchedPatternText = typeof matchedPattern === "string" ? matchedPattern : ts.patternText(matchedPattern); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPatternText); + } + for (var _i = 0, _a = state.compilerOptions.paths[matchedPatternText]; _i < _a.length; _i++) { + var subst = _a[_i]; + var path = matchedStar ? subst.replace("*", matchedStar) : subst; + var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, path)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path); + } + var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + if (resolvedFileName) { + return resolvedFileName; + } + } + return undefined; + } + else { + var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, moduleName)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Resolving_module_name_0_relative_to_base_url_1_2, moduleName, state.compilerOptions.baseUrl, candidate); + } + return loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + } + } + function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host) { + var containingDirectory = ts.getDirectoryPath(containingFile); + var supportedExtensions = ts.getSupportedExtensions(compilerOptions); + var traceEnabled = isTraceEnabled(compilerOptions, host); + var failedLookupLocations = []; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: false }; + var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, supportedExtensions, state); + var isExternalLibraryImport = false; + if (!resolvedFileName) { + if (moduleHasNonRelativeName(moduleName)) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder, moduleName); + } + resolvedFileName = loadModuleFromNodeModules(moduleName, containingDirectory, failedLookupLocations, state, false); + isExternalLibraryImport = resolvedFileName !== undefined; + } + else { + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + resolvedFileName = nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, false, state); + } + } + if (resolvedFileName && host.realpath) { + var originalFileName = resolvedFileName; + resolvedFileName = ts.normalizePath(host.realpath(resolvedFileName)); + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, originalFileName, resolvedFileName); + } + } + return createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations); + } + ts.nodeModuleNameResolver = nodeModuleNameResolver; + function nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate); + } + var resolvedFileName = !ts.pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state); + return resolvedFileName || loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, onlyRecordFailures, state); + } + function directoryProbablyExists(directoryName, host) { + return !host.directoryExists || host.directoryExists(directoryName); + } + ts.directoryProbablyExists = directoryProbablyExists; + function loadModuleFromFile(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) { + var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state); + if (resolvedByAddingExtension) { + return resolvedByAddingExtension; + } + if (ts.hasJavaScriptFileExtension(candidate)) { + var extensionless = ts.removeFileExtension(candidate); + if (state.traceEnabled) { + var extension = candidate.substring(extensionless.length); + trace(state.host, ts.Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension); + } + return tryAddingExtensions(extensionless, extensions, failedLookupLocation, onlyRecordFailures, state); + } + } + function tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) { + if (!onlyRecordFailures) { + var directory = ts.getDirectoryPath(candidate); + if (directory) { + onlyRecordFailures = !directoryProbablyExists(directory, state.host); + } + } + return ts.forEach(extensions, function (ext) { + return !(state.skipTsx && ts.isJsxOrTsxExtension(ext)) && tryFile(candidate + ext, failedLookupLocation, onlyRecordFailures, state); + }); + } + function tryFile(fileName, failedLookupLocation, onlyRecordFailures, state) { + if (!onlyRecordFailures && state.host.fileExists(fileName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); + } + return fileName; + } + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); + } + failedLookupLocation.push(fileName); + return undefined; + } + } + function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocation, onlyRecordFailures, state) { + var packageJsonPath = pathToPackageJson(candidate); + var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); + if (directoryExists && state.host.fileExists(packageJsonPath)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); + } + var typesFile = tryReadTypesSection(packageJsonPath, candidate, state); + if (typesFile) { + var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(typesFile), state.host); + var result = tryFile(typesFile, failedLookupLocation, onlyRecordFailures_1, state) || + tryAddingExtensions(typesFile, extensions, failedLookupLocation, onlyRecordFailures_1, state); + if (result) { + return result; + } + } + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_does_not_have_types_field); + } + } + } + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); + } + failedLookupLocation.push(packageJsonPath); + } + return loadModuleFromFile(ts.combinePaths(candidate, "index"), extensions, failedLookupLocation, !directoryExists, state); + } + function pathToPackageJson(directory) { + return ts.combinePaths(directory, "package.json"); + } + function loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state) { + var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); + var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); + var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); + var supportedExtensions = ts.getSupportedExtensions(state.compilerOptions); + var result = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, !nodeModulesFolderExists, state); + if (result) { + return result; + } + result = loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); + if (result) { + return result; + } + } + function loadModuleFromNodeModules(moduleName, directory, failedLookupLocations, state, checkOneLevel) { + return loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, checkOneLevel, false); + } + ts.loadModuleFromNodeModules = loadModuleFromNodeModules; + function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) { + return loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, false, true); + } + function loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, checkOneLevel, typesOnly) { + directory = ts.normalizeSlashes(directory); + while (true) { + var baseName = ts.getBaseFileName(directory); + if (baseName !== "node_modules") { + var packageResult = void 0; + if (!typesOnly) { + packageResult = loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state); + if (packageResult && ts.hasTypeScriptFileExtension(packageResult)) { + return packageResult; + } + } + var typesResult = loadModuleFromNodeModulesFolder(ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); + if (typesResult || packageResult) { + return typesResult || packageResult; + } + } + var parentPath = ts.getDirectoryPath(directory); + if (parentPath === directory || checkOneLevel) { + break; + } + directory = parentPath; + } + return undefined; + } + function classicNameResolver(moduleName, containingFile, compilerOptions, host) { + var traceEnabled = isTraceEnabled(compilerOptions, host); + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: !compilerOptions.jsx }; + var failedLookupLocations = []; + var supportedExtensions = ts.getSupportedExtensions(compilerOptions); + var containingDirectory = ts.getDirectoryPath(containingFile); + var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, supportedExtensions, state); + if (resolvedFileName) { + return createResolvedModule(resolvedFileName, false, failedLookupLocations); + } + var referencedSourceFile; + if (moduleHasNonRelativeName(moduleName)) { + referencedSourceFile = referencedSourceFile = loadModuleFromAncestorDirectories(moduleName, containingDirectory, supportedExtensions, failedLookupLocations, state) || + loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); + } + else { + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + referencedSourceFile = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, false, state); + } + return referencedSourceFile + ? { resolvedModule: { resolvedFileName: referencedSourceFile }, failedLookupLocations: failedLookupLocations } + : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; + } + ts.classicNameResolver = classicNameResolver; + function loadModuleFromAncestorDirectories(moduleName, containingDirectory, supportedExtensions, failedLookupLocations, state) { + while (true) { + var searchName = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var referencedSourceFile = loadModuleFromFile(searchName, supportedExtensions, failedLookupLocations, false, state); + if (referencedSourceFile) { + return referencedSourceFile; + } + var parentPath = ts.getDirectoryPath(containingDirectory); + if (parentPath === containingDirectory) { + return undefined; + } + containingDirectory = parentPath; + } + } +})(ts || (ts = {})); +var ts; (function (ts) { ts.externalHelpersModuleNameText = "tslib"; function getDeclarationOfKind(symbol, kind) { @@ -5877,10 +7014,10 @@ var ts; return !!(ts.getCombinedNodeFlags(node) & 1); } ts.isLet = isLet; - function isSuperCallExpression(n) { + function isSuperCall(n) { return n.kind === 174 && n.expression.kind === 95; } - ts.isSuperCallExpression = isSuperCallExpression; + ts.isSuperCall = isSuperCall; function isPrologueDirective(node) { return node.kind === 202 && node.expression.kind === 9; } @@ -5943,23 +7080,23 @@ var ts; case 139: case 172: case 97: - var parent_1 = node.parent; - if (parent_1.kind === 158) { + var parent_2 = node.parent; + if (parent_2.kind === 158) { return false; } - if (154 <= parent_1.kind && parent_1.kind <= 166) { + if (154 <= parent_2.kind && parent_2.kind <= 166) { return true; } - switch (parent_1.kind) { + switch (parent_2.kind) { case 194: - return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); + return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); case 141: - return node === parent_1.constraint; + return node === parent_2.constraint; case 145: case 144: case 142: case 218: - return node === parent_1.type; + return node === parent_2.type; case 220: case 179: case 180: @@ -5968,16 +7105,16 @@ var ts; case 146: case 149: case 150: - return node === parent_1.type; + return node === parent_2.type; case 151: case 152: case 153: - return node === parent_1.type; + return node === parent_2.type; case 177: - return node === parent_1.type; + return node === parent_2.type; case 174: case 175: - return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; + return parent_2.typeArguments && ts.indexOf(parent_2.typeArguments, node) >= 0; case 176: return false; } @@ -6030,9 +7167,9 @@ var ts; return; default: if (isFunctionLike(node)) { - var name_7 = node.name; - if (name_7 && name_7.kind === 140) { - traverse(name_7.expression); + var name_8 = node.name; + if (name_8 && name_8.kind === 140) { + traverse(name_8.expression); return; } } @@ -6128,6 +7265,12 @@ var ts; return node && node.kind === 147 && node.parent.kind === 171; } ts.isObjectLiteralMethod = isObjectLiteralMethod; + function isObjectLiteralOrClassExpressionMethod(node) { + return node.kind === 147 && + (node.parent.kind === 171 || + node.parent.kind === 192); + } + ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { return predicate && predicate.kind === 1; } @@ -6238,13 +7381,13 @@ var ts; function getImmediatelyInvokedFunctionExpression(func) { if (func.kind === 179 || func.kind === 180) { var prev = func; - var parent_2 = func.parent; - while (parent_2.kind === 178) { - prev = parent_2; - parent_2 = parent_2.parent; + var parent_3 = func.parent; + while (parent_3.kind === 178) { + prev = parent_3; + parent_3 = parent_3.parent; } - if (parent_2.kind === 174 && parent_2.expression === prev) { - return parent_2; + if (parent_3.kind === 174 && parent_3.expression === prev) { + return parent_3; } } } @@ -6390,8 +7533,8 @@ var ts; case 8: case 9: case 97: - var parent_3 = node.parent; - switch (parent_3.kind) { + var parent_4 = node.parent; + switch (parent_4.kind) { case 218: case 142: case 145: @@ -6399,7 +7542,7 @@ var ts; case 255: case 253: case 169: - return parent_3.initializer === node; + return parent_4.initializer === node; case 202: case 203: case 204: @@ -6410,32 +7553,32 @@ var ts; case 249: case 215: case 213: - return parent_3.expression === node; + return parent_4.expression === node; case 206: - var forStatement = parent_3; + var forStatement = parent_4; return (forStatement.initializer === node && forStatement.initializer.kind !== 219) || forStatement.condition === node || forStatement.incrementor === node; case 207: case 208: - var forInStatement = parent_3; + var forInStatement = parent_4; return (forInStatement.initializer === node && forInStatement.initializer.kind !== 219) || forInStatement.expression === node; case 177: case 195: - return node === parent_3.expression; + return node === parent_4.expression; case 197: - return node === parent_3.expression; + return node === parent_4.expression; case 140: - return node === parent_3.expression; + return node === parent_4.expression; case 143: case 248: case 247: return true; case 194: - return parent_3.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_3); + return parent_4.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_4); default: - if (isPartOfExpression(parent_3)) { + if (isPartOfExpression(parent_4)) { return true; } } @@ -6443,10 +7586,6 @@ var ts; return false; } ts.isPartOfExpression = isPartOfExpression; - function isExternalModuleNameRelative(moduleName) { - return /^\.\.?($|[\\/])/.test(moduleName); - } - ts.isExternalModuleNameRelative = isExternalModuleNameRelative; function isInstantiatedModule(node, preserveConstEnums) { var moduleState = ts.getModuleInstanceState(node); return moduleState === 1 || @@ -6650,17 +7789,17 @@ var ts; node.parent && node.parent.kind === 225) { result = append(result, getJSDocs(node.parent, checkParentVariableStatement, getDocs, getTags)); } - var parent_4 = node.parent; - var isSourceOfAssignmentExpressionStatement = parent_4 && parent_4.parent && - parent_4.kind === 187 && - parent_4.operatorToken.kind === 56 && - parent_4.parent.kind === 202; + var parent_5 = node.parent; + var isSourceOfAssignmentExpressionStatement = parent_5 && parent_5.parent && + parent_5.kind === 187 && + parent_5.operatorToken.kind === 56 && + parent_5.parent.kind === 202; if (isSourceOfAssignmentExpressionStatement) { - result = append(result, getJSDocs(parent_4.parent, checkParentVariableStatement, getDocs, getTags)); + result = append(result, getJSDocs(parent_5.parent, checkParentVariableStatement, getDocs, getTags)); } - var isPropertyAssignmentExpression = parent_4 && parent_4.kind === 253; + var isPropertyAssignmentExpression = parent_5 && parent_5.kind === 253; if (isPropertyAssignmentExpression) { - result = append(result, getJSDocs(parent_4, checkParentVariableStatement, getDocs, getTags)); + result = append(result, getJSDocs(parent_5, checkParentVariableStatement, getDocs, getTags)); } if (node.kind === 142) { var paramTags = getJSDocParameterTag(node, checkParentVariableStatement); @@ -6693,8 +7832,8 @@ var ts; } } else if (param.name.kind === 69) { - var name_8 = param.name.text; - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 275 && tag.parameterName.text === name_8; }); + var name_9 = param.name.text; + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 275 && tag.parameterName.text === name_9; }); if (paramTags) { return paramTags; } @@ -6765,20 +7904,20 @@ var ts; node = node.parent; } while (true) { - var parent_5 = node.parent; - if (parent_5.kind === 170 || parent_5.kind === 191) { - node = parent_5; + var parent_6 = node.parent; + if (parent_6.kind === 170 || parent_6.kind === 191) { + node = parent_6; continue; } - if (parent_5.kind === 253 || parent_5.kind === 254) { - node = parent_5.parent; + if (parent_6.kind === 253 || parent_6.kind === 254) { + node = parent_6.parent; continue; } - return parent_5.kind === 187 && - isAssignmentOperator(parent_5.operatorToken.kind) && - parent_5.left === node || - (parent_5.kind === 207 || parent_5.kind === 208) && - parent_5.initializer === node; + return parent_6.kind === 187 && + isAssignmentOperator(parent_6.operatorToken.kind) && + parent_6.left === node || + (parent_6.kind === 207 || parent_6.kind === 208) && + parent_6.initializer === node; } } ts.isAssignmentTarget = isAssignmentTarget; @@ -7044,14 +8183,10 @@ var ts; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { - return positionIsSynthesized(node.pos) - || positionIsSynthesized(node.end); + return ts.positionIsSynthesized(node.pos) + || ts.positionIsSynthesized(node.end); } ts.nodeIsSynthesized = nodeIsSynthesized; - function positionIsSynthesized(pos) { - return !(pos >= 0); - } - ts.positionIsSynthesized = positionIsSynthesized; function getOriginalNode(node) { if (node) { while (node.original !== undefined) { @@ -7487,28 +8622,16 @@ var ts; function getDeclarationEmitOutputFilePath(sourceFile, host) { var options = host.getCompilerOptions(); var outputDir = options.declarationDir || options.outDir; - if (options.declaration) { - var path = outputDir - ? getSourceFilePathInNewDir(sourceFile, host, outputDir) - : sourceFile.fileName; - return ts.removeFileExtension(path) + ".d.ts"; - } + var path = outputDir + ? getSourceFilePathInNewDir(sourceFile, host, outputDir) + : sourceFile.fileName; + return ts.removeFileExtension(path) + ".d.ts"; } ts.getDeclarationEmitOutputFilePath = getDeclarationEmitOutputFilePath; - function getEmitScriptTarget(compilerOptions) { - return compilerOptions.target || 0; - } - ts.getEmitScriptTarget = getEmitScriptTarget; - function getEmitModuleKind(compilerOptions) { - return typeof compilerOptions.module === "number" ? - compilerOptions.module : - getEmitScriptTarget(compilerOptions) === 2 ? ts.ModuleKind.ES6 : ts.ModuleKind.CommonJS; - } - ts.getEmitModuleKind = getEmitModuleKind; function getSourceFilesToEmit(host, targetSourceFile) { var options = host.getCompilerOptions(); if (options.outFile || options.out) { - var moduleKind = getEmitModuleKind(options); + var moduleKind = ts.getEmitModuleKind(options); var moduleEmitEnabled = moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System; var sourceFiles = host.getSourceFiles(); return ts.filter(sourceFiles, moduleEmitEnabled ? isNonDeclarationFile : isBundleEmitNonExternalModule); @@ -7525,7 +8648,7 @@ var ts; function isBundleEmitNonExternalModule(sourceFile) { return !isDeclarationFile(sourceFile) && !ts.isExternalModule(sourceFile); } - function forEachTransformedEmitFile(host, sourceFiles, action) { + function forEachTransformedEmitFile(host, sourceFiles, action, emitOnlyDtsFiles) { var options = host.getCompilerOptions(); if (options.outFile || options.out) { onBundledEmit(host, sourceFiles); @@ -7552,7 +8675,7 @@ var ts; } var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = !isSourceFileJavaScript(sourceFile) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; + var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (options.declaration || emitOnlyDtsFiles) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; action(jsFilePath, sourceMapFilePath, declarationFilePath, [sourceFile], false); } function onBundledEmit(host, sourceFiles) { @@ -7568,7 +8691,7 @@ var ts; function getSourceMapFilePath(jsFilePath, options) { return options.sourceMap ? jsFilePath + ".map" : undefined; } - function forEachExpectedEmitFile(host, action, targetSourceFile) { + function forEachExpectedEmitFile(host, action, targetSourceFile, emitOnlyDtsFiles) { var options = host.getCompilerOptions(); if (options.outFile || options.out) { onBundledEmit(host); @@ -7595,18 +8718,19 @@ var ts; } } var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); + var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (emitOnlyDtsFiles || options.declaration) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; var emitFileNames = { jsFilePath: jsFilePath, sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), - declarationFilePath: !isSourceFileJavaScript(sourceFile) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined + declarationFilePath: declarationFilePath }; - action(emitFileNames, [sourceFile], false); + action(emitFileNames, [sourceFile], false, emitOnlyDtsFiles); } function onBundledEmit(host) { var bundledSources = ts.filter(host.getSourceFiles(), function (sourceFile) { return !isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile) && (!ts.isExternalModule(sourceFile) || - !!getEmitModuleKind(options)); }); + !!ts.getEmitModuleKind(options)); }); if (bundledSources.length) { var jsFilePath = options.outFile || options.out; var emitFileNames = { @@ -7614,7 +8738,7 @@ var ts; sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), declarationFilePath: options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined }; - action(emitFileNames, bundledSources, true); + action(emitFileNames, bundledSources, true, emitOnlyDtsFiles); } } } @@ -7651,13 +8775,32 @@ var ts; ts.getFirstConstructorWithBody = getFirstConstructorWithBody; function getSetAccessorTypeAnnotationNode(accessor) { if (accessor && accessor.parameters.length > 0) { - var hasThis = accessor.parameters.length === 2 && - accessor.parameters[0].name.kind === 69 && - accessor.parameters[0].name.originalKeywordKind === 97; + var hasThis = accessor.parameters.length === 2 && parameterIsThisKeyword(accessor.parameters[0]); return accessor.parameters[hasThis ? 1 : 0].type; } } ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode; + function getThisParameter(signature) { + if (signature.parameters.length) { + var thisParameter = signature.parameters[0]; + if (parameterIsThisKeyword(thisParameter)) { + return thisParameter; + } + } + } + ts.getThisParameter = getThisParameter; + function parameterIsThisKeyword(parameter) { + return isThisIdentifier(parameter.name); + } + ts.parameterIsThisKeyword = parameterIsThisKeyword; + function isThisIdentifier(node) { + return node && node.kind === 69 && identifierIsThisKeyword(node); + } + ts.isThisIdentifier = isThisIdentifier; + function identifierIsThisKeyword(id) { + return id.originalKeywordKind === 97; + } + ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { var firstAccessor; var secondAccessor; @@ -7971,14 +9114,6 @@ var ts; return symbol && symbol.valueDeclaration && hasModifier(symbol.valueDeclaration, 512) ? symbol.valueDeclaration.localSymbol : undefined; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; - function hasJavaScriptFileExtension(fileName) { - return ts.forEach(ts.supportedJavascriptExtensions, function (extension) { return ts.fileExtensionIs(fileName, extension); }); - } - ts.hasJavaScriptFileExtension = hasJavaScriptFileExtension; - function hasTypeScriptFileExtension(fileName) { - return ts.forEach(ts.supportedTypeScriptExtensions, function (extension) { return ts.fileExtensionIs(fileName, extension); }); - } - ts.hasTypeScriptFileExtension = hasTypeScriptFileExtension; function tryExtractTypeScriptExtension(fileName) { return ts.find(ts.supportedTypescriptExtensionsForExtractExtension, function (extension) { return ts.fileExtensionIs(fileName, extension); }); } @@ -8069,12 +9204,6 @@ var ts; return result; } ts.convertToBase64 = convertToBase64; - function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) { - return !ts.isRootedDiskPath(absoluteOrRelativePath) - ? absoluteOrRelativePath - : ts.getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, false); - } - ts.convertToRelativePath = convertToRelativePath; var carriageReturnLineFeed = "\r\n"; var lineFeed = "\n"; function getNewLineCharacter(options) { @@ -8163,9 +9292,9 @@ var ts; if (syntaxKindCache[kind]) { return syntaxKindCache[kind]; } - for (var name_9 in syntaxKindEnum) { - if (syntaxKindEnum[name_9] === kind) { - return syntaxKindCache[kind] = kind.toString() + " (" + name_9 + ")"; + for (var name_10 in syntaxKindEnum) { + if (syntaxKindEnum[name_10] === kind) { + return syntaxKindCache[kind] = kind.toString() + " (" + name_10 + ")"; } } } @@ -8175,7 +9304,7 @@ var ts; } ts.formatSyntaxKind = formatSyntaxKind; function movePos(pos, value) { - return positionIsSynthesized(pos) ? -1 : pos + value; + return ts.positionIsSynthesized(pos) ? -1 : pos + value; } ts.movePos = movePos; function createRange(pos, end) { @@ -8244,7 +9373,7 @@ var ts; } ts.positionsAreOnSameLine = positionsAreOnSameLine; function getStartPositionOfRange(range, sourceFile) { - return positionIsSynthesized(range.pos) ? -1 : ts.skipTrivia(sourceFile.text, range.pos); + return ts.positionIsSynthesized(range.pos) ? -1 : ts.skipTrivia(sourceFile.text, range.pos); } ts.getStartPositionOfRange = getStartPositionOfRange; function collectExternalModuleInfo(sourceFile, resolver) { @@ -8281,8 +9410,8 @@ var ts; else { for (var _b = 0, _c = node.exportClause.elements; _b < _c.length; _b++) { var specifier = _c[_b]; - var name_10 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_10] || (exportSpecifiers[name_10] = [])).push(specifier); + var name_11 = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[name_11] || (exportSpecifiers[name_11] = [])).push(specifier); } } break; @@ -8344,15 +9473,16 @@ var ts; return 11 <= kind && kind <= 14; } ts.isTemplateLiteralKind = isTemplateLiteralKind; - function isTemplateLiteralFragmentKind(kind) { - return kind === 12 - || kind === 13 + function isTemplateHead(node) { + return node.kind === 12; + } + ts.isTemplateHead = isTemplateHead; + function isTemplateMiddleOrTemplateTail(node) { + var kind = node.kind; + return kind === 13 || kind === 14; } - function isTemplateLiteralFragment(node) { - return isTemplateLiteralFragmentKind(node.kind); - } - ts.isTemplateLiteralFragment = isTemplateLiteralFragment; + ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; function isIdentifier(node) { return node.kind === 69; } @@ -8491,12 +9621,12 @@ var ts; return node.kind === 174; } ts.isCallExpression = isCallExpression; - function isTemplate(node) { + function isTemplateLiteral(node) { var kind = node.kind; return kind === 189 || kind === 11; } - ts.isTemplate = isTemplate; + ts.isTemplateLiteral = isTemplateLiteral; function isSpreadElementExpression(node) { return node.kind === 191; } @@ -8827,7 +9957,6 @@ var ts; } ts.isWatchSet = isWatchSet; })(ts || (ts = {})); -var ts; (function (ts) { function getDefaultLibFileName(options) { return options.target === 2 ? "lib.es6.d.ts" : "lib.d.ts"; @@ -9062,7 +10191,7 @@ var ts; ts.createSynthesizedNodeArray = createSynthesizedNodeArray; function getSynthesizedClone(node) { var clone = createNode(node.kind, undefined, node.flags); - clone.original = node; + setOriginalNode(clone, node); for (var key in node) { if (clone.hasOwnProperty(key) || !node.hasOwnProperty(key)) { continue; @@ -9094,7 +10223,7 @@ var ts; node.text = value; return node; } - else { + else if (value) { var node = createNode(9, location, undefined); node.textSourceNode = value; node.text = value.text; @@ -9381,7 +10510,7 @@ var ts; function createPropertyAccess(expression, name, location, flags) { var node = createNode(172, location, flags); node.expression = parenthesizeForAccess(expression); - node.emitFlags = 1048576; + (node.emitNode || (node.emitNode = {})).flags |= 1048576; node.name = typeof name === "string" ? createIdentifier(name) : name; return node; } @@ -9389,7 +10518,7 @@ var ts; function updatePropertyAccess(node, expression, name) { if (node.expression !== expression || node.name !== name) { var propertyAccess = createPropertyAccess(expression, name, node, node.flags); - propertyAccess.emitFlags = node.emitFlags; + (propertyAccess.emitNode || (propertyAccess.emitNode = {})).flags = getEmitFlags(node); return updateNode(propertyAccess, node); } return node; @@ -9493,7 +10622,7 @@ var ts; node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; node.parameters = createNodeArray(parameters); node.type = type; - node.equalsGreaterThanToken = equalsGreaterThanToken || createNode(34); + node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(34); node.body = parenthesizeConciseBody(body); return node; } @@ -9586,7 +10715,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right, location) { - var operatorToken = typeof operator === "number" ? createSynthesizedNode(operator) : operator; + var operatorToken = typeof operator === "number" ? createToken(operator) : operator; var operatorKind = operatorToken.kind; var node = createNode(187, location); node.left = parenthesizeBinaryOperand(operatorKind, left, true, undefined); @@ -10486,13 +11615,13 @@ var ts; } else { var expression = ts.isIdentifier(memberName) ? createPropertyAccess(target, memberName, location) : createElementAccess(target, memberName, location); - expression.emitFlags |= 2048; + (expression.emitNode || (expression.emitNode = {})).flags |= 2048; return expression; } } ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName; function createRestParameter(name) { - return createParameterDeclaration(undefined, undefined, createSynthesizedNode(22), name, undefined, undefined, undefined); + return createParameterDeclaration(undefined, undefined, createToken(22), name, undefined, undefined, undefined); } ts.createRestParameter = createRestParameter; function createFunctionCall(func, thisArg, argumentsList, location) { @@ -10606,8 +11735,8 @@ var ts; } ts.createDecorateHelper = createDecorateHelper; function createAwaiterHelper(externalHelpersModuleName, hasLexicalArguments, promiseConstructor, body) { - var generatorFunc = createFunctionExpression(createNode(37), undefined, undefined, [], undefined, body); - generatorFunc.emitFlags |= 2097152; + var generatorFunc = createFunctionExpression(createToken(37), undefined, undefined, [], undefined, body); + (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 2097152; return createCall(createHelperName(externalHelpersModuleName, "__awaiter"), undefined, [ createThis(), hasLexicalArguments ? createIdentifier("arguments") : createVoidZero(), @@ -10834,7 +11963,7 @@ var ts; target.push(startOnNewLine(createStatement(createLiteral("use strict")))); foundUseStrict = true; } - if (statement.emitFlags & 8388608) { + if (getEmitFlags(statement) & 8388608) { target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); } else { @@ -10846,6 +11975,28 @@ var ts; return statementOffset; } ts.addPrologueDirectives = addPrologueDirectives; + function ensureUseStrict(node) { + var foundUseStrict = false; + for (var _i = 0, _a = node.statements; _i < _a.length; _i++) { + var statement = _a[_i]; + if (ts.isPrologueDirective(statement)) { + if (isUseStrictPrologue(statement)) { + foundUseStrict = true; + break; + } + } + else { + break; + } + } + if (!foundUseStrict) { + var statements = []; + statements.push(startOnNewLine(createStatement(createLiteral("use strict")))); + return updateSourceFileNode(node, statements.concat(node.statements)); + } + return node; + } + ts.ensureUseStrict = ensureUseStrict; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = skipPartiallyEmittedExpressions(operand); if (skipped.kind === 178) { @@ -11085,17 +12236,112 @@ var ts; function setOriginalNode(node, original) { node.original = original; if (original) { - var emitFlags = original.emitFlags, commentRange = original.commentRange, sourceMapRange = original.sourceMapRange; - if (emitFlags) - node.emitFlags = emitFlags; - if (commentRange) - node.commentRange = commentRange; - if (sourceMapRange) - node.sourceMapRange = sourceMapRange; + var emitNode = original.emitNode; + if (emitNode) + node.emitNode = mergeEmitNode(emitNode, node.emitNode); } return node; } ts.setOriginalNode = setOriginalNode; + function mergeEmitNode(sourceEmitNode, destEmitNode) { + var flags = sourceEmitNode.flags, commentRange = sourceEmitNode.commentRange, sourceMapRange = sourceEmitNode.sourceMapRange, tokenSourceMapRanges = sourceEmitNode.tokenSourceMapRanges; + if (!destEmitNode && (flags || commentRange || sourceMapRange || tokenSourceMapRanges)) + destEmitNode = {}; + if (flags) + destEmitNode.flags = flags; + if (commentRange) + destEmitNode.commentRange = commentRange; + if (sourceMapRange) + destEmitNode.sourceMapRange = sourceMapRange; + if (tokenSourceMapRanges) + destEmitNode.tokenSourceMapRanges = mergeTokenSourceMapRanges(tokenSourceMapRanges, destEmitNode.tokenSourceMapRanges); + return destEmitNode; + } + function mergeTokenSourceMapRanges(sourceRanges, destRanges) { + if (!destRanges) + destRanges = ts.createMap(); + ts.copyProperties(sourceRanges, destRanges); + return destRanges; + } + function disposeEmitNodes(sourceFile) { + sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(sourceFile)); + var emitNode = sourceFile && sourceFile.emitNode; + var annotatedNodes = emitNode && emitNode.annotatedNodes; + if (annotatedNodes) { + for (var _i = 0, annotatedNodes_1 = annotatedNodes; _i < annotatedNodes_1.length; _i++) { + var node = annotatedNodes_1[_i]; + node.emitNode = undefined; + } + } + } + ts.disposeEmitNodes = disposeEmitNodes; + function getOrCreateEmitNode(node) { + if (!node.emitNode) { + if (ts.isParseTreeNode(node)) { + if (node.kind === 256) { + return node.emitNode = { annotatedNodes: [node] }; + } + var sourceFile = ts.getSourceFileOfNode(node); + getOrCreateEmitNode(sourceFile).annotatedNodes.push(node); + } + node.emitNode = {}; + } + return node.emitNode; + } + function getEmitFlags(node) { + var emitNode = node.emitNode; + return emitNode && emitNode.flags; + } + ts.getEmitFlags = getEmitFlags; + function setEmitFlags(node, emitFlags) { + getOrCreateEmitNode(node).flags = emitFlags; + return node; + } + ts.setEmitFlags = setEmitFlags; + function setSourceMapRange(node, range) { + getOrCreateEmitNode(node).sourceMapRange = range; + return node; + } + ts.setSourceMapRange = setSourceMapRange; + function setTokenSourceMapRange(node, token, range) { + var emitNode = getOrCreateEmitNode(node); + var tokenSourceMapRanges = emitNode.tokenSourceMapRanges || (emitNode.tokenSourceMapRanges = ts.createMap()); + tokenSourceMapRanges[token] = range; + return node; + } + ts.setTokenSourceMapRange = setTokenSourceMapRange; + function setCommentRange(node, range) { + getOrCreateEmitNode(node).commentRange = range; + return node; + } + ts.setCommentRange = setCommentRange; + function getCommentRange(node) { + var emitNode = node.emitNode; + return (emitNode && emitNode.commentRange) || node; + } + ts.getCommentRange = getCommentRange; + function getSourceMapRange(node) { + var emitNode = node.emitNode; + return (emitNode && emitNode.sourceMapRange) || node; + } + ts.getSourceMapRange = getSourceMapRange; + function getTokenSourceMapRange(node, token) { + var emitNode = node.emitNode; + var tokenSourceMapRanges = emitNode && emitNode.tokenSourceMapRanges; + return tokenSourceMapRanges && tokenSourceMapRanges[token]; + } + ts.getTokenSourceMapRange = getTokenSourceMapRange; + function getConstantValue(node) { + var emitNode = node.emitNode; + return emitNode && emitNode.constantValue; + } + ts.getConstantValue = getConstantValue; + function setConstantValue(node, value) { + var emitNode = getOrCreateEmitNode(node); + emitNode.constantValue = value; + return node; + } + ts.setConstantValue = setConstantValue; function setTextRange(node, location) { if (location) { node.pos = location.pos; @@ -11122,8 +12368,8 @@ var ts; function getLocalNameForExternalImport(node, sourceFile) { var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); if (namespaceDeclaration && !ts.isDefaultImport(node)) { - var name_11 = namespaceDeclaration.name; - return ts.isGeneratedIdentifier(name_11) ? name_11 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); + var name_12 = namespaceDeclaration.name; + return ts.isGeneratedIdentifier(name_12) ? name_12 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); } if (node.kind === 230 && node.importClause) { return getGeneratedNameForNode(node); @@ -12205,7 +13451,7 @@ var ts; case 16: return token() === 18 || token() === 20; case 18: - return token() === 27 || token() === 17; + return token() !== 24; case 20: return token() === 15 || token() === 16; case 13: @@ -12533,7 +13779,7 @@ var ts; } function parseTemplateExpression() { var template = createNode(189); - template.head = parseTemplateLiteralFragment(); + template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 12, "Template head has wrong token kind"); var templateSpans = createNodeArray(); do { @@ -12549,7 +13795,7 @@ var ts; var literal; if (token() === 16) { reScanTemplateToken(); - literal = parseTemplateLiteralFragment(); + literal = parseTemplateMiddleOrTemplateTail(); } else { literal = parseExpectedToken(14, false, ts.Diagnostics._0_expected, ts.tokenToString(16)); @@ -12560,8 +13806,15 @@ var ts; function parseLiteralNode(internName) { return parseLiteralLikeNode(token(), internName); } - function parseTemplateLiteralFragment() { - return parseLiteralLikeNode(token(), false); + function parseTemplateHead() { + var fragment = parseLiteralLikeNode(token(), false); + ts.Debug.assert(fragment.kind === 12, "Template head has wrong token kind"); + return fragment; + } + function parseTemplateMiddleOrTemplateTail() { + var fragment = parseLiteralLikeNode(token(), false); + ts.Debug.assert(fragment.kind === 13 || fragment.kind === 14, "Template fragment has wrong token kind"); + return fragment; } function parseLiteralLikeNode(kind, internName) { var node = createNode(kind); @@ -14822,8 +16075,8 @@ var ts; return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { - var name_12 = createMissingNode(69, true, ts.Diagnostics.Declaration_expected); - return parsePropertyDeclaration(fullStart, decorators, modifiers, name_12, undefined); + var name_13 = createMissingNode(69, true, ts.Diagnostics.Declaration_expected); + return parsePropertyDeclaration(fullStart, decorators, modifiers, name_13, undefined); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } @@ -14909,7 +16162,7 @@ var ts; parseExpected(56); node.type = parseType(); parseSemicolon(); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseEnumMember() { var node = createNode(255, scanner.getStartPos()); @@ -15847,8 +17100,8 @@ var ts; if (typeExpression.type.kind === 267) { var jsDocTypeReference = typeExpression.type; if (jsDocTypeReference.name.kind === 69) { - var name_13 = jsDocTypeReference.name; - if (name_13.text === "Object") { + var name_14 = jsDocTypeReference.name; + if (name_14.text === "Object") { typedefTag.jsDocTypeLiteral = scanChildTags(); } } @@ -15934,14 +17187,14 @@ var ts; } var typeParameters = createNodeArray(); while (true) { - var name_14 = parseJSDocIdentifierName(); + var name_15 = parseJSDocIdentifierName(); skipWhitespace(); - if (!name_14) { + if (!name_15) { parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(141, name_14.pos); - typeParameter.name = name_14; + var typeParameter = createNode(141, name_15.pos); + typeParameter.name = name_15; finishNode(typeParameter); typeParameters.push(typeParameter); if (token() === 24) { @@ -16344,7 +17597,7 @@ var ts; file = f; options = opts; languageVersion = ts.getEmitScriptTarget(options); - inStrictMode = !!file.externalModuleIndicator; + inStrictMode = bindInStrictMode(file, opts); classifiableNames = ts.createMap(); symbolCount = 0; skipTransformFlagAggregation = ts.isDeclarationFile(file); @@ -16374,6 +17627,14 @@ var ts; subtreeTransformFlags = 0; } return bindSourceFile; + function bindInStrictMode(file, opts) { + if (opts.alwaysStrict && !ts.isDeclarationFile(file)) { + return true; + } + else { + return !!file.externalModuleIndicator; + } + } function createSymbol(flags, name) { symbolCount++; return new Symbol(flags, name); @@ -16492,11 +17753,17 @@ var ts; var message_1 = symbol.flags & 2 ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; - ts.forEach(symbol.declarations, function (declaration) { - if (ts.hasModifier(declaration, 512)) { + if (symbol.declarations && symbol.declarations.length) { + if (isDefaultExport) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } - }); + else { + if (symbol.declarations && symbol.declarations.length && + (isDefaultExport || (node.kind === 235 && !node.isExportEquals))) { + message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; + } + } + } ts.forEach(symbol.declarations, function (declaration) { file.bindDiagnostics.push(ts.createDiagnosticForNode(declaration.name || declaration, message_1, getDisplayName(declaration))); }); @@ -16561,7 +17828,7 @@ var ts; } else { currentFlow = { flags: 2 }; - if (containerFlags & 16) { + if (containerFlags & (16 | 128)) { currentFlow.container = node; } currentReturnTarget = undefined; @@ -17016,7 +18283,9 @@ var ts; currentFlow = preTryFlow; bind(node.finallyBlock); } - currentFlow = finishFlowLabel(postFinallyLabel); + if (!node.finallyBlock || !(currentFlow.flags & 1)) { + currentFlow = finishFlowLabel(postFinallyLabel); + } } function bindSwitchStatement(node) { var postSwitchLabel = createBranchLabel(); @@ -17149,7 +18418,7 @@ var ts; } else { ts.forEachChild(node, bind); - if (node.operator === 57 || node.operator === 42) { + if (node.operator === 41 || node.operator === 42) { bindAssignmentTargetFlow(node.operand); } } @@ -17248,9 +18517,12 @@ var ts; return 1 | 32; case 256: return 1 | 4 | 32; + case 147: + if (ts.isObjectLiteralOrClassExpressionMethod(node)) { + return 1 | 4 | 32 | 8 | 128; + } case 148: case 220: - case 147: case 146: case 149: case 150: @@ -17782,7 +19054,7 @@ var ts; var flags = node.kind === 235 && ts.exportAssignmentIsAlias(node) ? 8388608 : 4; - declareSymbol(container.symbol.exports, container.symbol, node, flags, 0 | 8388608); + declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 | 8388608 | 32 | 16); } } function bindNamespaceExportDeclaration(node) { @@ -17794,12 +19066,12 @@ var ts; return; } else { - var parent_6 = node.parent; - if (!ts.isExternalModule(parent_6)) { + var parent_7 = node.parent; + if (!ts.isExternalModule(parent_7)) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_module_files)); return; } - if (!parent_6.isDeclarationFile) { + if (!parent_7.isDeclarationFile) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_declaration_files)); return; } @@ -17979,6 +19251,9 @@ var ts; emitFlags |= 2048; } } + if (currentFlow && ts.isObjectLiteralOrClassExpressionMethod(node)) { + node.flowNode = currentFlow; + } return ts.hasDynamicName(node) ? bindAnonymousDeclaration(node, symbolFlags, "__computed") : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); @@ -18117,8 +19392,7 @@ var ts; if (node.questionToken) { transformFlags |= 3; } - if (subtreeFlags & 2048 - || (name && ts.isIdentifier(name) && name.originalKeywordKind === 97)) { + if (subtreeFlags & 2048 || ts.isThisIdentifier(name)) { transformFlags |= 3; } if (modifierFlags & 92) { @@ -18220,7 +19494,7 @@ var ts; || (subtreeFlags & 2048)) { transformFlags |= 3; } - if (asteriskToken && node.emitFlags & 2097152) { + if (asteriskToken && ts.getEmitFlags(node) & 2097152) { transformFlags |= 1536; } node.transformFlags = transformFlags | 536870912; @@ -18265,7 +19539,7 @@ var ts; if (subtreeFlags & 81920) { transformFlags |= 192; } - if (asteriskToken && node.emitFlags & 2097152) { + if (asteriskToken && ts.getEmitFlags(node) & 2097152) { transformFlags |= 1536; } } @@ -18282,7 +19556,7 @@ var ts; if (subtreeFlags & 81920) { transformFlags |= 192; } - if (asteriskToken && node.emitFlags & 2097152) { + if (asteriskToken && ts.getEmitFlags(node) & 2097152) { transformFlags |= 1536; } node.transformFlags = transformFlags | 536870912; @@ -18618,6 +19892,7 @@ var ts; var unknownSymbol = createSymbol(4 | 67108864, "unknown"); var resolvingSymbol = createSymbol(67108864, "__resolving__"); var anyType = createIntrinsicType(1, "any"); + var autoType = createIntrinsicType(1, "any"); var unknownType = createIntrinsicType(1, "unknown"); var undefinedType = createIntrinsicType(2048, "undefined"); var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(2048 | 33554432, "undefined"); @@ -19175,7 +20450,7 @@ var ts; if (result && isInExternalModule && (meaning & 107455) === 107455) { var decls = result.declarations; if (decls && decls.length === 1 && decls[0].kind === 228) { - error(errorLocation, ts.Diagnostics.Identifier_0_must_be_imported_from_a_module, name); + error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } } @@ -19335,28 +20610,28 @@ var ts; var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); if (targetSymbol) { - var name_15 = specifier.propertyName || specifier.name; - if (name_15.text) { + var name_16 = specifier.propertyName || specifier.name; + if (name_16.text) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { return moduleSymbol; } var symbolFromVariable = void 0; if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports["export="]) { - symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name_15.text); + symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name_16.text); } else { - symbolFromVariable = getPropertyOfVariable(targetSymbol, name_15.text); + symbolFromVariable = getPropertyOfVariable(targetSymbol, name_16.text); } symbolFromVariable = resolveSymbol(symbolFromVariable); - var symbolFromModule = getExportOfModule(targetSymbol, name_15.text); - if (!symbolFromModule && allowSyntheticDefaultImports && name_15.text === "default") { + var symbolFromModule = getExportOfModule(targetSymbol, name_16.text); + if (!symbolFromModule && allowSyntheticDefaultImports && name_16.text === "default") { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol); } var symbol = symbolFromModule && symbolFromVariable ? combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : symbolFromModule || symbolFromVariable; if (!symbol) { - error(name_15, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_15)); + error(name_16, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_16)); } return symbol; } @@ -19593,6 +20868,7 @@ var ts; } function getExportsForModule(moduleSymbol) { var visitedSymbols = []; + moduleSymbol = resolveExternalModuleSymbol(moduleSymbol); return visit(moduleSymbol) || moduleSymbol.exports; function visit(symbol) { if (!(symbol && symbol.flags & 1952 && !ts.contains(visitedSymbols, symbol))) { @@ -20077,9 +21353,9 @@ var ts; var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & 2)); if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { - var parent_7 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); - if (parent_7) { - walkSymbol(parent_7, getQualifiedLeftMeaning(meaning), false); + var parent_8 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent_8) { + walkSymbol(parent_8, getQualifiedLeftMeaning(meaning), false); } } if (accessibleSymbolChain) { @@ -20114,7 +21390,7 @@ var ts; ? "any" : type.intrinsicName); } - else if (type.flags & 268435456) { + else if (type.flags & 16384 && type.isThisType) { if (inObjectTypeLiteral) { writer.reportInaccessibleThisError(); } @@ -20131,7 +21407,7 @@ var ts; else if (type.flags & (32768 | 65536 | 16 | 16384)) { buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 793064, 0, nextFlags); } - else if (!(flags & 512) && type.flags & (2097152 | 1572864) && type.aliasSymbol && + else if (!(flags & 512) && ((type.flags & 2097152 && !type.target) || type.flags & 1572864) && type.aliasSymbol && isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, 793064, false).accessibility === 0) { var typeArguments = type.aliasTypeArguments; writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments.length : 0, nextFlags); @@ -20201,12 +21477,12 @@ var ts; var length_1 = outerTypeParameters.length; while (i < length_1) { var start = i; - var parent_8 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + var parent_9 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_8); + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_9); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_8, typeArguments, start, i, flags); + writeSymbolTypeReference(parent_9, typeArguments, start, i, flags); writePunctuation(writer, 21); } } @@ -20595,12 +21871,12 @@ var ts; if (ts.isExternalModuleAugmentation(node)) { return true; } - var parent_9 = getDeclarationContainer(node); + var parent_10 = getDeclarationContainer(node); if (!(ts.getCombinedModifierFlags(node) & 1) && - !(node.kind !== 229 && parent_9.kind !== 256 && ts.isInAmbientContext(parent_9))) { - return isGlobalSourceFile(parent_9); + !(node.kind !== 229 && parent_10.kind !== 256 && ts.isInAmbientContext(parent_10))) { + return isGlobalSourceFile(parent_10); } - return isDeclarationVisible(parent_9); + return isDeclarationVisible(parent_10); case 145: case 144: case 149: @@ -20787,19 +22063,19 @@ var ts; } var type; if (pattern.kind === 167) { - var name_16 = declaration.propertyName || declaration.name; - if (isComputedNonLiteralName(name_16)) { + var name_17 = declaration.propertyName || declaration.name; + if (isComputedNonLiteralName(name_17)) { return anyType; } if (declaration.initializer) { getContextualType(declaration.initializer); } - var text = getTextOfPropertyName(name_16); + var text = getTextOfPropertyName(name_17); type = getTypeOfPropertyOfType(parentType, text) || isNumericLiteralName(text) && getIndexTypeOfType(parentType, 1) || getIndexTypeOfType(parentType, 0); if (!type) { - error(name_16, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_16)); + error(name_17, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_17)); return unknownType; } } @@ -20858,6 +22134,10 @@ var ts; } return undefined; } + function isAutoVariableInitializer(initializer) { + var expr = initializer && ts.skipParentheses(initializer); + return !expr || expr.kind === 93 || expr.kind === 69 && getResolvedSymbol(expr) === undefinedSymbol; + } function addOptionality(type, optional) { return strictNullChecks && optional ? includeFalsyTypes(type, 2048) : type; } @@ -20880,6 +22160,11 @@ var ts; if (declaration.type) { return addOptionality(getTypeFromTypeNode(declaration.type), declaration.questionToken && includeOptionality); } + if (declaration.kind === 218 && !ts.isBindingPattern(declaration.name) && + !(ts.getCombinedNodeFlags(declaration) & 2) && !(ts.getCombinedModifierFlags(declaration) & 1) && + !ts.isInAmbientContext(declaration) && isAutoVariableInitializer(declaration.initializer)) { + return autoType; + } if (declaration.kind === 142) { var func = declaration.parent; if (func.kind === 150 && !ts.hasDynamicName(func)) { @@ -20951,7 +22236,7 @@ var ts; result.pattern = pattern; } if (hasComputedProperties) { - result.flags |= 536870912; + result.isObjectLiteralPatternWithComputedProperties = true; } return result; } @@ -21420,7 +22705,8 @@ var ts; type.instantiations[getTypeListId(type.typeParameters)] = type; type.target = type; type.typeArguments = type.typeParameters; - type.thisType = createType(16384 | 268435456); + type.thisType = createType(16384); + type.thisType.isThisType = true; type.thisType.symbol = symbol; type.thisType.constraint = type; } @@ -21953,13 +23239,24 @@ var ts; var current = _a[_i]; for (var _b = 0, _c = getPropertiesOfType(current); _b < _c.length; _b++) { var prop = _c[_b]; - getPropertyOfUnionOrIntersectionType(type, prop.name); + getUnionOrIntersectionProperty(type, prop.name); } if (type.flags & 524288) { break; } } - return type.resolvedProperties ? symbolsToArray(type.resolvedProperties) : emptyArray; + var props = type.resolvedProperties; + if (props) { + var result = []; + for (var key in props) { + var prop = props[key]; + if (!(prop.flags & 268435456 && prop.isPartial)) { + result.push(prop); + } + } + return result; + } + return emptyArray; } function getPropertiesOfType(type) { type = getApparentType(type); @@ -21998,6 +23295,7 @@ var ts; var props; var commonFlags = (containingType.flags & 1048576) ? 536870912 : 0; var isReadonly = false; + var isPartial = false; for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { var current = types_2[_i]; var type = getApparentType(current); @@ -22016,20 +23314,20 @@ var ts; } } else if (containingType.flags & 524288) { - return undefined; + isPartial = true; } } } if (!props) { return undefined; } - if (props.length === 1) { + if (props.length === 1 && !isPartial) { return props[0]; } var propTypes = []; var declarations = []; var commonType = undefined; - var hasCommonType = true; + var hasNonUniformType = false; for (var _a = 0, props_1 = props; _a < props_1.length; _a++) { var prop = props_1[_a]; if (prop.declarations) { @@ -22040,22 +23338,20 @@ var ts; commonType = type; } else if (type !== commonType) { - hasCommonType = false; + hasNonUniformType = true; } - propTypes.push(getTypeOfSymbol(prop)); + propTypes.push(type); } - var result = createSymbol(4 | - 67108864 | - 268435456 | - commonFlags, name); + var result = createSymbol(4 | 67108864 | 268435456 | commonFlags, name); result.containingType = containingType; - result.hasCommonType = hasCommonType; + result.hasNonUniformType = hasNonUniformType; + result.isPartial = isPartial; result.declarations = declarations; result.isReadonly = isReadonly; result.type = containingType.flags & 524288 ? getUnionType(propTypes) : getIntersectionType(propTypes); return result; } - function getPropertyOfUnionOrIntersectionType(type, name) { + function getUnionOrIntersectionProperty(type, name) { var properties = type.resolvedProperties || (type.resolvedProperties = ts.createMap()); var property = properties[name]; if (!property) { @@ -22066,6 +23362,10 @@ var ts; } return property; } + function getPropertyOfUnionOrIntersectionType(type, name) { + var property = getUnionOrIntersectionProperty(type, name); + return property && !(property.flags & 268435456 && property.isPartial) ? property : undefined; + } function getPropertyOfType(type, name) { type = getApparentType(type); if (type.flags & 2588672) { @@ -22438,7 +23738,7 @@ var ts; } function hasConstraintReferenceTo(type, target) { var checked; - while (type && !(type.flags & 268435456) && type.flags & 16384 && !ts.contains(checked, type)) { + while (type && type.flags & 16384 && !(type.isThisType) && !ts.contains(checked, type)) { if (type === target) { return true; } @@ -22722,7 +24022,8 @@ var ts; type.instantiations[getTypeListId(type.typeParameters)] = type; type.target = type; type.typeArguments = type.typeParameters; - type.thisType = createType(16384 | 268435456); + type.thisType = createType(16384); + type.thisType.isThisType = true; type.thisType.constraint = type; type.declaredProperties = properties; type.declaredCallSignatures = emptyArray; @@ -22821,7 +24122,24 @@ var ts; } return false; } + function isSetOfLiteralsFromSameEnum(types) { + var first = types[0]; + if (first.flags & 256) { + var firstEnum = getParentOfSymbol(first.symbol); + for (var i = 1; i < types.length; i++) { + var other = types[i]; + if (!(other.flags & 256) || (firstEnum !== getParentOfSymbol(other.symbol))) { + return false; + } + } + return true; + } + return false; + } function removeSubtypes(types) { + if (types.length === 0 || isSetOfLiteralsFromSameEnum(types)) { + return; + } var i = types.length; while (i > 0) { i--; @@ -23796,7 +25114,8 @@ var ts; !t.numberIndexInfo; } function hasExcessProperties(source, target, reportErrors) { - if (!(target.flags & 536870912) && maybeTypeOfKind(target, 2588672)) { + if (maybeTypeOfKind(target, 2588672) && + (!(target.flags & 2588672) || !target.isObjectLiteralPatternWithComputedProperties)) { for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { var prop = _a[_i]; if (!isKnownProperty(target, prop.name)) { @@ -25001,17 +26320,10 @@ var ts; } function isDiscriminantProperty(type, name) { if (type && type.flags & 524288) { - var prop = getPropertyOfType(type, name); - if (!prop) { - var filteredType = getTypeWithFacts(type, 4194304); - if (filteredType !== type && filteredType.flags & 524288) { - prop = getPropertyOfType(filteredType, name); - } - } + var prop = getUnionOrIntersectionProperty(type, name); if (prop && prop.flags & 268435456) { if (prop.isDiscriminantProperty === undefined) { - prop.isDiscriminantProperty = !prop.hasCommonType && - isLiteralType(getTypeOfSymbol(prop)); + prop.isDiscriminantProperty = prop.hasNonUniformType && isLiteralType(getTypeOfSymbol(prop)); } return prop.isDiscriminantProperty; } @@ -25288,6 +26600,23 @@ var ts; } return f(type) ? type : neverType; } + function mapType(type, f) { + return type.flags & 524288 ? getUnionType(ts.map(type.types, f)) : f(type); + } + function extractTypesOfKind(type, kind) { + return filterType(type, function (t) { return (t.flags & kind) !== 0; }); + } + function replacePrimitivesWithLiterals(typeWithPrimitives, typeWithLiterals) { + if (isTypeSubsetOf(stringType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 32) || + isTypeSubsetOf(numberType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 64)) { + return mapType(typeWithPrimitives, function (t) { + return t.flags & 2 ? extractTypesOfKind(typeWithLiterals, 2 | 32) : + t.flags & 4 ? extractTypesOfKind(typeWithLiterals, 4 | 64) : + t; + }); + } + return typeWithPrimitives; + } function isIncomplete(flowType) { return flowType.flags === 0; } @@ -25302,7 +26631,9 @@ var ts; if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 4178943)) { return declaredType; } - var initialType = assumeInitialized ? declaredType : includeFalsyTypes(declaredType, 2048); + var initialType = assumeInitialized ? declaredType : + declaredType === autoType ? undefinedType : + includeFalsyTypes(declaredType, 2048); var visitedFlowStart = visitedFlowCount; var result = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); visitedFlowCount = visitedFlowStart; @@ -25364,10 +26695,13 @@ var ts; function getTypeAtFlowAssignment(flow) { var node = flow.node; if (isMatchingReference(reference, node)) { - var isIncrementOrDecrement = node.parent.kind === 185 || node.parent.kind === 186; - return declaredType.flags & 524288 && !isIncrementOrDecrement ? - getAssignmentReducedType(declaredType, getInitialOrAssignedType(node)) : - declaredType; + if (node.parent.kind === 185 || node.parent.kind === 186) { + var flowType = getTypeAtFlowNode(flow.antecedent); + return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType)); + } + return declaredType === autoType ? getBaseTypeOfLiteralType(getInitialOrAssignedType(node)) : + declaredType.flags & 524288 ? getAssignmentReducedType(declaredType, getInitialOrAssignedType(node)) : + declaredType; } if (containsMatchingReference(reference, node)) { return declaredType; @@ -25553,12 +26887,12 @@ var ts; assumeTrue ? 16384 : 131072; return getTypeWithFacts(type, facts); } - if (type.flags & 2589191) { + if (type.flags & 2589185) { return type; } if (assumeTrue) { var narrowedType = filterType(type, function (t) { return areTypesComparable(t, valueType); }); - return narrowedType.flags & 8192 ? type : narrowedType; + return narrowedType.flags & 8192 ? type : replacePrimitivesWithLiterals(narrowedType, valueType); } if (isUnitType(valueType)) { var regularType_1 = getRegularTypeOfLiteralType(valueType); @@ -25596,7 +26930,8 @@ var ts; var clauseTypes = switchTypes.slice(clauseStart, clauseEnd); var hasDefaultClause = clauseStart === clauseEnd || ts.contains(clauseTypes, neverType); var discriminantType = getUnionType(clauseTypes); - var caseType = discriminantType.flags & 8192 ? neverType : filterType(type, function (t) { return isTypeComparableTo(discriminantType, t); }); + var caseType = discriminantType.flags & 8192 ? neverType : + replacePrimitivesWithLiterals(filterType(type, function (t) { return isTypeComparableTo(discriminantType, t); }), discriminantType); if (!hasDefaultClause) { return caseType; } @@ -25723,7 +27058,7 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } - if (ts.isExpression(location) && !ts.isAssignmentTarget(location)) { + if (ts.isPartOfExpression(location) && !ts.isAssignmentTarget(location)) { var type = checkExpression(location); if (getExportSymbolOfValueSymbolIfExported(getNodeLinks(location).resolvedSymbol) === symbol) { return type; @@ -25846,14 +27181,26 @@ var ts; var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; while (flowContainer !== declarationContainer && - (flowContainer.kind === 179 || flowContainer.kind === 180) && + (flowContainer.kind === 179 || + flowContainer.kind === 180 || + ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isReadonlySymbol(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } - var assumeInitialized = !strictNullChecks || (type.flags & 1) !== 0 || isParameter || - isOuterVariable || ts.isInAmbientContext(declaration); + var assumeInitialized = isParameter || isOuterVariable || + type !== autoType && (!strictNullChecks || (type.flags & 1) !== 0) || + ts.isInAmbientContext(declaration); var flowType = getFlowTypeOfReference(node, type, assumeInitialized, flowContainer); - if (!assumeInitialized && !(getFalsyFlags(type) & 2048) && getFalsyFlags(flowType) & 2048) { + if (type === autoType) { + if (flowType === autoType) { + if (compilerOptions.noImplicitAny) { + error(declaration.name, ts.Diagnostics.Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol)); + error(node, ts.Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(anyType)); + } + return anyType; + } + } + else if (!assumeInitialized && !(getFalsyFlags(type) & 2048) && getFalsyFlags(flowType) & 2048) { error(node, ts.Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol)); return type; } @@ -25938,7 +27285,7 @@ var ts; } } function findFirstSuperCall(n) { - if (ts.isSuperCallExpression(n)) { + if (ts.isSuperCall(n)) { return n; } else if (ts.isFunctionLike(n)) { @@ -26003,7 +27350,7 @@ var ts; captureLexicalThis(node, container); } if (ts.isFunctionLike(container) && - (!isInParameterInitializerBeforeContainingFunction(node) || getFunctionLikeThisParameter(container))) { + (!isInParameterInitializerBeforeContainingFunction(node) || ts.getThisParameter(container))) { if (container.kind === 179 && ts.isInJavaScriptFile(container.parent) && ts.getSpecialPropertyAssignmentKind(container.parent) === 3) { @@ -26222,11 +27569,11 @@ var ts; } if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; - var name_17 = declaration.propertyName || declaration.name; + var name_18 = declaration.propertyName || declaration.name; if (ts.isVariableLike(parentDeclaration) && parentDeclaration.type && - !ts.isBindingPattern(name_17)) { - var text = getTextOfPropertyName(name_17); + !ts.isBindingPattern(name_18)) { + var text = getTextOfPropertyName(name_18); if (text) { return getTypeOfPropertyOfType(getTypeFromTypeNode(parentDeclaration.type), text); } @@ -26663,7 +28010,8 @@ var ts; patternWithComputedProperties = true; } } - else if (contextualTypeHasPattern && !(contextualType.flags & 536870912)) { + else if (contextualTypeHasPattern && + !(contextualType.flags & 2588672 && contextualType.isObjectLiteralPatternWithComputedProperties)) { var impliedProp = getPropertyOfType(contextualType, member.name); if (impliedProp) { prop.flags |= impliedProp.flags & 536870912; @@ -26714,7 +28062,10 @@ var ts; var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, propertiesArray, 1) : undefined; var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 16777216; - result.flags |= 8388608 | 67108864 | freshObjectLiteralFlag | (typeFlags & 234881024) | (patternWithComputedProperties ? 536870912 : 0); + result.flags |= 8388608 | 67108864 | freshObjectLiteralFlag | (typeFlags & 234881024); + if (patternWithComputedProperties) { + result.isObjectLiteralPatternWithComputedProperties = true; + } if (inDestructuringPattern) { result.pattern = node; } @@ -27109,7 +28460,7 @@ var ts; if (flags & 32) { return true; } - if (type.flags & 268435456) { + if (type.flags & 16384 && type.isThisType) { type = getConstraintOfTypeParameter(type); } if (!(getTargetType(type).flags & (32768 | 65536) && hasBaseType(type, enclosingClass))) { @@ -27150,7 +28501,7 @@ var ts; var prop = getPropertyOfType(apparentType, right.text); if (!prop) { if (right.text && !checkAndReportErrorForExtendingInterface(node)) { - reportNonexistentProperty(right, type.flags & 268435456 ? apparentType : type); + reportNonexistentProperty(right, type.flags & 16384 && type.isThisType ? apparentType : type); } return unknownType; } @@ -27266,15 +28617,15 @@ var ts; return unknownType; } if (node.argumentExpression) { - var name_18 = getPropertyNameForIndexedAccess(node.argumentExpression, indexType); - if (name_18 !== undefined) { - var prop = getPropertyOfType(objectType, name_18); + var name_19 = getPropertyNameForIndexedAccess(node.argumentExpression, indexType); + if (name_19 !== undefined) { + var prop = getPropertyOfType(objectType, name_19); if (prop) { getNodeLinks(node).resolvedSymbol = prop; return getTypeOfSymbol(prop); } else if (isConstEnum) { - error(node.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_const_enum_1, name_18, symbolToString(objectType.symbol)); + error(node.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_const_enum_1, name_19, symbolToString(objectType.symbol)); return unknownType; } } @@ -27375,19 +28726,19 @@ var ts; for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var signature = signatures_2[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_10 = signature.declaration && signature.declaration.parent; + var parent_11 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_10 === lastParent) { + if (lastParent && parent_11 === lastParent) { index++; } else { - lastParent = parent_10; + lastParent = parent_11; index = cutoffIndex; } } else { index = cutoffIndex = result.length; - lastParent = parent_10; + lastParent = parent_11; } lastSymbol = symbol; if (signature.hasLiteralTypes) { @@ -28290,7 +29641,9 @@ var ts; if (!contextualSignature) { reportErrorsFromWidening(func, type); } - if (isUnitType(type) && !(contextualSignature && isLiteralContextualType(getReturnTypeOfSignature(contextualSignature)))) { + if (isUnitType(type) && + !(contextualSignature && + isLiteralContextualType(contextualSignature === getSignatureFromDeclaration(func) ? type : getReturnTypeOfSignature(contextualSignature)))) { type = getWidenedLiteralType(type); } var widenedType = getWidenedType(type); @@ -28440,7 +29793,7 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 147 && node.kind !== 146) { + if (produceDiagnostics && node.kind !== 147) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } @@ -28690,14 +30043,14 @@ var ts; } function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, contextualMapper) { if (property.kind === 253 || property.kind === 254) { - var name_19 = property.name; - if (name_19.kind === 140) { - checkComputedPropertyName(name_19); + var name_20 = property.name; + if (name_20.kind === 140) { + checkComputedPropertyName(name_20); } - if (isComputedNonLiteralName(name_19)) { + if (isComputedNonLiteralName(name_20)) { return undefined; } - var text = getTextOfPropertyName(name_19); + var text = getTextOfPropertyName(name_20); var type = isTypeAny(objectLiteralType) ? objectLiteralType : getTypeOfPropertyOfType(objectLiteralType, text) || @@ -28712,7 +30065,7 @@ var ts; } } else { - error(name_19, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_19)); + error(name_20, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_20)); } } else { @@ -29361,9 +30714,9 @@ var ts; else if (parameterName) { var hasReportedError = false; for (var _i = 0, _a = parent.parameters; _i < _a.length; _i++) { - var name_20 = _a[_i].name; - if (ts.isBindingPattern(name_20) && - checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_20, parameterName, typePredicate.parameterName)) { + var name_21 = _a[_i].name; + if (ts.isBindingPattern(name_21) && + checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_21, parameterName, typePredicate.parameterName)) { hasReportedError = true; break; } @@ -29383,9 +30736,9 @@ var ts; case 156: case 147: case 146: - var parent_11 = node.parent; - if (node === parent_11.type) { - return parent_11; + var parent_12 = node.parent; + if (node === parent_12.type) { + return parent_12; } } } @@ -29395,15 +30748,15 @@ var ts; if (ts.isOmittedExpression(element)) { continue; } - var name_21 = element.name; - if (name_21.kind === 69 && - name_21.text === predicateVariableName) { + var name_22 = element.name; + if (name_22.kind === 69 && + name_22.text === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name_21.kind === 168 || - name_21.kind === 167) { - if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_21, predicateVariableNode, predicateVariableName)) { + else if (name_22.kind === 168 || + name_22.kind === 167) { + if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_22, predicateVariableNode, predicateVariableName)) { return true; } } @@ -29596,7 +30949,7 @@ var ts; return n.name && containsSuperCall(n.name); } function containsSuperCall(n) { - if (ts.isSuperCallExpression(n)) { + if (ts.isSuperCall(n)) { return true; } else if (ts.isFunctionLike(n)) { @@ -29622,6 +30975,7 @@ var ts; } var containingClassDecl = node.parent; if (ts.getClassExtendsHeritageClauseElement(containingClassDecl)) { + captureLexicalThis(node.parent, containingClassDecl); var classExtendsNull = classDeclarationExtendsNull(containingClassDecl); var superCall = getSuperCallInConstructor(node); if (superCall) { @@ -29635,7 +30989,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 202 && ts.isSuperCallExpression(statement.expression)) { + if (statement.kind === 202 && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -30345,7 +31699,7 @@ var ts; var parameter = local.valueDeclaration; if (compilerOptions.noUnusedParameters && !ts.isParameterPropertyDeclaration(parameter) && - !parameterIsThisKeyword(parameter) && + !ts.parameterIsThisKeyword(parameter) && !parameterNameStartsWithUnderscore(parameter)) { error(local.valueDeclaration.name, ts.Diagnostics._0_is_declared_but_never_used, local.name); } @@ -30360,9 +31714,6 @@ var ts; } } } - function parameterIsThisKeyword(parameter) { - return parameter.name && parameter.name.originalKeywordKind === 97; - } function parameterNameStartsWithUnderscore(parameter) { return parameter.name && parameter.name.kind === 69 && parameter.name.text.charCodeAt(0) === 95; } @@ -30500,6 +31851,9 @@ var ts; } } function checkCollisionWithRequireExportsInGeneratedCode(node, name) { + if (modulekind >= ts.ModuleKind.ES6) { + return; + } if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } @@ -30547,8 +31901,8 @@ var ts; container.kind === 225 || container.kind === 256); if (!namesShareScope) { - var name_22 = symbolToString(localDeclarationSymbol); - error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_22, name_22); + var name_23 = symbolToString(localDeclarationSymbol); + error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_23, name_23); } } } @@ -30603,6 +31957,9 @@ var ts; } } } + function convertAutoToAny(type) { + return type === autoType ? anyType : type; + } function checkVariableLikeDeclaration(node) { checkDecorators(node); checkSourceElement(node.type); @@ -30616,12 +31973,12 @@ var ts; if (node.propertyName && node.propertyName.kind === 140) { checkComputedPropertyName(node.propertyName); } - var parent_12 = node.parent.parent; - var parentType = getTypeForBindingElementParent(parent_12); - var name_23 = node.propertyName || node.name; - var property = getPropertyOfType(parentType, getTextOfPropertyName(name_23)); - if (parent_12.initializer && property && getParentOfSymbol(property)) { - checkClassPropertyAccess(parent_12, parent_12.initializer, parentType, property); + var parent_13 = node.parent.parent; + var parentType = getTypeForBindingElementParent(parent_13); + var name_24 = node.propertyName || node.name; + var property = getPropertyOfType(parentType, getTextOfPropertyName(name_24)); + if (parent_13.initializer && property && getParentOfSymbol(property)) { + checkClassPropertyAccess(parent_13, parent_13.initializer, parentType, property); } } if (ts.isBindingPattern(node.name)) { @@ -30639,7 +31996,7 @@ var ts; return; } var symbol = getSymbolOfNode(node); - var type = getTypeOfVariableOrParameterOrProperty(symbol); + var type = convertAutoToAny(getTypeOfVariableOrParameterOrProperty(symbol)); if (node === symbol.valueDeclaration) { if (node.initializer && node.parent.parent.kind !== 207) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); @@ -30647,7 +32004,7 @@ var ts; } } else { - var declarationType = getWidenedTypeForVariableLikeDeclaration(node); + var declarationType = convertAutoToAny(getWidenedTypeForVariableLikeDeclaration(node)); if (type !== unknownType && declarationType !== unknownType && !isTypeIdenticalTo(type, declarationType)) { error(node.name, ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2, ts.declarationNameToString(node.name), typeToString(type), typeToString(declarationType)); } @@ -31022,7 +32379,12 @@ var ts; } } checkExpression(node.expression); - error(node.expression, ts.Diagnostics.All_symbols_within_a_with_block_will_be_resolved_to_any); + var sourceFile = ts.getSourceFileOfNode(node); + if (!hasParseDiagnostics(sourceFile)) { + var start = ts.getSpanOfTokenAtPosition(sourceFile, node.pos).start; + var end = node.statement.pos; + grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any); + } } function checkSwitchStatement(node) { checkGrammarStatementInAmbientContext(node); @@ -31741,9 +33103,11 @@ var ts; grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } } - checkCollisionWithCapturedThisVariable(node, node.name); - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); + if (ts.isIdentifier(node.name)) { + checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); + } checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); if (symbol.flags & 512 @@ -31818,9 +33182,9 @@ var ts; break; case 169: case 218: - var name_24 = node.name; - if (ts.isBindingPattern(name_24)) { - for (var _b = 0, _c = name_24.elements; _b < _c.length; _b++) { + var name_25 = node.name; + if (ts.isBindingPattern(name_25)) { + for (var _b = 0, _c = name_25.elements; _b < _c.length; _b++) { var el = _c[_b]; checkModuleAugmentationElement(el, isGlobalAugmentation); } @@ -31982,9 +33346,11 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - if (node.parent.kind !== 256 && node.parent.kind !== 226 && node.parent.kind !== 225) { - return grammarErrorOnFirstToken(node, errorMessage); + var isInAppropriateContext = node.parent.kind === 256 || node.parent.kind === 226 || node.parent.kind === 225; + if (!isInAppropriateContext) { + grammarErrorOnFirstToken(node, errorMessage); } + return !isInAppropriateContext; } function checkExportSpecifier(node) { checkAliasSymbol(node); @@ -32071,7 +33437,8 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return declaration.kind !== 220 || !!declaration.body; + return (declaration.kind !== 220 && declaration.kind !== 147) || + !!declaration.body; } } function checkSourceElement(node) { @@ -32556,6 +33923,9 @@ var ts; node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } + if (ts.isInJavaScriptFile(node) && ts.isRequireCall(node.parent, false)) { + return resolveExternalModuleName(node, node); + } case 8: if (node.parent.kind === 173 && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); @@ -32670,9 +34040,9 @@ var ts; function getRootSymbols(symbol) { if (symbol.flags & 268435456) { var symbols_3 = []; - var name_25 = symbol.name; + var name_26 = symbol.name; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - var symbol = getPropertyOfType(t, name_25); + var symbol = getPropertyOfType(t, name_26); if (symbol) { symbols_3.push(symbol); } @@ -32979,9 +34349,9 @@ var ts; } var location = reference; if (startInDeclarationContainer) { - var parent_13 = reference.parent; - if (ts.isDeclaration(parent_13) && reference === parent_13.name) { - location = getDeclarationContainer(parent_13); + var parent_14 = reference.parent; + if (ts.isDeclaration(parent_14) && reference === parent_14.name) { + location = getDeclarationContainer(parent_14); } } return resolveName(location, reference.text, 107455 | 1048576 | 8388608, undefined, undefined); @@ -33090,9 +34460,9 @@ var ts; } var current = symbol; while (true) { - var parent_14 = getParentOfSymbol(current); - if (parent_14) { - current = parent_14; + var parent_15 = getParentOfSymbol(current); + if (parent_15) { + current = parent_15; } else { break; @@ -33652,8 +35022,8 @@ var ts; function checkGrammarForOmittedArgument(node, args) { if (args) { var sourceFile = ts.getSourceFileOfNode(node); - for (var _i = 0, args_2 = args; _i < args_2.length; _i++) { - var arg = args_2[_i]; + for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { + var arg = args_4[_i]; if (arg.kind === 193) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } @@ -33761,10 +35131,9 @@ var ts; var GetOrSetAccessor = GetAccessor | SetAccessor; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - var name_26 = prop.name; - if (prop.kind === 193 || - name_26.kind === 140) { - checkGrammarComputedPropertyName(name_26); + var name_27 = prop.name; + if (name_27.kind === 140) { + checkGrammarComputedPropertyName(name_27); } if (prop.kind === 254 && !inDestructuring && prop.objectAssignmentInitializer) { return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); @@ -33780,8 +35149,8 @@ var ts; var currentKind = void 0; if (prop.kind === 253 || prop.kind === 254) { checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_26.kind === 8) { - checkGrammarNumericLiteral(name_26); + if (name_27.kind === 8) { + checkGrammarNumericLiteral(name_27); } currentKind = Property; } @@ -33797,7 +35166,7 @@ var ts; else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - var effectiveName = ts.getPropertyNameForPropertyNameNode(name_26); + var effectiveName = ts.getPropertyNameForPropertyNameNode(name_27); if (effectiveName === undefined) { continue; } @@ -33807,18 +35176,18 @@ var ts; else { var existingKind = seen[effectiveName]; if (currentKind === Property && existingKind === Property) { - grammarErrorOnNode(name_26, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_26)); + grammarErrorOnNode(name_27, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_27)); } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { seen[effectiveName] = currentKind | existingKind; } else { - return grammarErrorOnNode(name_26, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name_27, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name_26, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name_27, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } @@ -33831,12 +35200,12 @@ var ts; continue; } var jsxAttr = attr; - var name_27 = jsxAttr.name; - if (!seen[name_27.text]) { - seen[name_27.text] = true; + var name_28 = jsxAttr.name; + if (!seen[name_28.text]) { + seen[name_28.text] = true; } else { - return grammarErrorOnNode(name_27, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + return grammarErrorOnNode(name_28, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; if (initializer && initializer.kind === 248 && !initializer.expression) { @@ -33919,17 +35288,8 @@ var ts; return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 149 ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 149 ? 1 : 2) && - accessor.parameters[0].name.kind === 69 && - accessor.parameters[0].name.originalKeywordKind === 97) { - return accessor.parameters[0]; - } - } - function getFunctionLikeThisParameter(func) { - if (func.parameters.length && - func.parameters[0].name.kind === 69 && - func.parameters[0].name.originalKeywordKind === 97) { - return func.parameters[0]; + if (accessor.parameters.length === (accessor.kind === 149 ? 1 : 2)) { + return ts.getThisParameter(accessor); } } function checkGrammarForNonSymbolComputedProperty(node, message) { @@ -34763,7 +36123,7 @@ var ts; case 175: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); case 176: - return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplate)); + return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); case 178: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); case 179: @@ -34787,7 +36147,7 @@ var ts; case 188: return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); case 189: - return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateLiteralFragment), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); + return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); case 190: return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); case 191: @@ -34797,7 +36157,7 @@ var ts; case 194: return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); case 197: - return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateLiteralFragment)); + return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); case 199: return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); case 200: @@ -35072,7 +36432,7 @@ var ts; return expression; function emitAssignment(name, value, location) { var expression = ts.createAssignment(name, value, location); - context.setNodeEmitFlags(expression, 2048); + ts.setEmitFlags(expression, 2048); ts.aggregateTransformFlags(expression); expressions.push(expression); } @@ -35089,7 +36449,7 @@ var ts; return declarations; function emitAssignment(name, value, location) { var declaration = ts.createVariableDeclaration(name, undefined, value, location); - context.setNodeEmitFlags(declaration, 2048); + ts.setEmitFlags(declaration, 2048); ts.aggregateTransformFlags(declaration); declarations.push(declaration); } @@ -35113,7 +36473,7 @@ var ts; } var declaration = ts.createVariableDeclaration(name, undefined, value, location); declaration.original = original; - context.setNodeEmitFlags(declaration, 2048); + ts.setEmitFlags(declaration, 2048); declarations.push(declaration); ts.aggregateTransformFlags(declaration); } @@ -35153,7 +36513,7 @@ var ts; function emitPendingAssignment(name, value, location, original) { var expression = ts.createAssignment(name, value, location); expression.original = original; - context.setNodeEmitFlags(expression, 2048); + ts.setEmitFlags(expression, 2048); pendingAssignments.push(expression); return expression; } @@ -35197,10 +36557,10 @@ var ts; emitArrayLiteralAssignment(target, value, location); } else { - var name_28 = ts.getMutableClone(target); - context.setSourceMapRange(name_28, target); - context.setCommentRange(name_28, target); - emitAssignment(name_28, value, location, undefined); + var name_29 = ts.getMutableClone(target); + ts.setSourceMapRange(name_29, target); + ts.setCommentRange(name_29, target); + emitAssignment(name_29, value, location, undefined); } } function emitObjectLiteralAssignment(target, value, location) { @@ -35314,7 +36674,7 @@ var ts; (function (ts) { var USE_NEW_TYPE_METADATA_FORMAT = false; function transformTypeScript(context) { - var getNodeEmitFlags = context.getNodeEmitFlags, setNodeEmitFlags = context.setNodeEmitFlags, setCommentRange = context.setCommentRange, setSourceMapRange = context.setSourceMapRange, startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); var compilerOptions = context.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); @@ -35323,10 +36683,13 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; + context.enableSubstitution(172); + context.enableSubstitution(173); var currentSourceFile; var currentNamespace; var currentNamespaceContainerName; var currentScope; + var currentScopeFirstDeclarationsOfName; var currentSourceFileExternalHelpersModuleName; var enabledSubstitutions; var classAliases; @@ -35334,12 +36697,19 @@ var ts; var currentSuperContainer; return transformSourceFile; function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } return ts.visitNode(node, visitor, ts.isSourceFile); } function saveStateAndInvoke(node, f) { var savedCurrentScope = currentScope; + var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName; onBeforeVisitNode(node); var visited = f(node); + if (currentScope !== savedCurrentScope) { + currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; + } currentScope = savedCurrentScope; return visited; } @@ -35493,11 +36863,22 @@ var ts; case 226: case 199: currentScope = node; + currentScopeFirstDeclarationsOfName = undefined; + break; + case 221: + case 220: + if (ts.hasModifier(node, 2)) { + break; + } + recordEmittedDeclarationInScope(node); break; } } function visitSourceFile(node) { currentSourceFile = node; + if (compilerOptions.alwaysStrict) { + node = ts.ensureUseStrict(node); + } if (node.flags & 31744 && compilerOptions.importHelpers && (ts.isExternalModule(node) || compilerOptions.isolatedModules)) { @@ -35519,7 +36900,7 @@ var ts; else { node = ts.visitEachChild(node, visitor, context); } - setNodeEmitFlags(node, 1 | node.emitFlags); + ts.setEmitFlags(node, 1 | ts.getEmitFlags(node)); return node; } function shouldEmitDecorateCallForClass(node) { @@ -35549,7 +36930,7 @@ var ts; var classDeclaration = ts.createClassDeclaration(undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, hasExtendsClause), node); ts.setOriginalNode(classDeclaration, node); if (staticProperties.length > 0) { - setNodeEmitFlags(classDeclaration, 1024 | getNodeEmitFlags(classDeclaration)); + ts.setEmitFlags(classDeclaration, 1024 | ts.getEmitFlags(classDeclaration)); } statements.push(classDeclaration); } @@ -35591,7 +36972,7 @@ var ts; var transformedClassExpression = ts.createVariableStatement(undefined, ts.createLetDeclarationList([ ts.createVariableDeclaration(classAlias || declaredName, undefined, classExpression) ]), location); - setCommentRange(transformedClassExpression, node); + ts.setCommentRange(transformedClassExpression, node); statements.push(ts.setOriginalNode(transformedClassExpression, node)); if (classAlias) { statements.push(ts.setOriginalNode(ts.createVariableStatement(undefined, ts.createLetDeclarationList([ @@ -35612,7 +36993,7 @@ var ts; enableSubstitutionForClassAliases(); classAliases[ts.getOriginalNodeId(node)] = ts.getSynthesizedClone(temp); } - setNodeEmitFlags(classExpression, 524288 | getNodeEmitFlags(classExpression)); + ts.setEmitFlags(classExpression, 524288 | ts.getEmitFlags(classExpression)); expressions.push(ts.startOnNewLine(ts.createAssignment(temp, classExpression))); ts.addRange(expressions, generateInitializedPropertyExpressions(node, staticProperties, temp)); expressions.push(ts.startOnNewLine(temp)); @@ -35673,7 +37054,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 202 && ts.isSuperCallExpression(statement.expression)) { + if (statement.kind === 202 && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -35692,9 +37073,9 @@ var ts; ts.Debug.assert(ts.isIdentifier(node.name)); var name = node.name; var propertyName = ts.getMutableClone(name); - setNodeEmitFlags(propertyName, 49152 | 1536); + ts.setEmitFlags(propertyName, 49152 | 1536); var localName = ts.getMutableClone(name); - setNodeEmitFlags(localName, 49152); + ts.setEmitFlags(localName, 49152); return ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createThis(), propertyName, node.name), localName), ts.moveRangePos(node, -1))); } function getInitializedProperties(node, isStatic) { @@ -35715,8 +37096,8 @@ var ts; for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) { var property = properties_7[_i]; var statement = ts.createStatement(transformInitializedProperty(node, property, receiver)); - setSourceMapRange(statement, ts.moveRangePastModifiers(property)); - setCommentRange(statement, property); + ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property)); + ts.setCommentRange(statement, property); statements.push(statement); } } @@ -35726,8 +37107,8 @@ var ts; var property = properties_8[_i]; var expression = transformInitializedProperty(node, property, receiver); expression.startsOnNewLine = true; - setSourceMapRange(expression, ts.moveRangePastModifiers(property)); - setCommentRange(expression, property); + ts.setSourceMapRange(expression, ts.moveRangePastModifiers(property)); + ts.setCommentRange(expression, property); expressions.push(expression); } return expressions; @@ -35868,7 +37249,7 @@ var ts; : ts.createNull() : undefined; var helper = ts.createDecorateHelper(currentSourceFileExternalHelpersModuleName, decoratorExpressions, prefix, memberName, descriptor, ts.moveRangePastDecorators(member)); - setNodeEmitFlags(helper, 49152); + ts.setEmitFlags(helper, 49152); return helper; } function addConstructorDecorationStatement(statements, node, decoratedClassAlias) { @@ -35886,12 +37267,12 @@ var ts; if (decoratedClassAlias) { var expression = ts.createAssignment(decoratedClassAlias, ts.createDecorateHelper(currentSourceFileExternalHelpersModuleName, decoratorExpressions, getDeclarationName(node))); var result = ts.createAssignment(getDeclarationName(node), expression, ts.moveRangePastDecorators(node)); - setNodeEmitFlags(result, 49152); + ts.setEmitFlags(result, 49152); return result; } else { var result = ts.createAssignment(getDeclarationName(node), ts.createDecorateHelper(currentSourceFileExternalHelpersModuleName, decoratorExpressions, getDeclarationName(node)), ts.moveRangePastDecorators(node)); - setNodeEmitFlags(result, 49152); + ts.setEmitFlags(result, 49152); return result; } } @@ -35905,7 +37286,7 @@ var ts; for (var _i = 0, decorators_1 = decorators; _i < decorators_1.length; _i++) { var decorator = decorators_1[_i]; var helper = ts.createParamHelper(currentSourceFileExternalHelpersModuleName, transformDecorator(decorator), parameterOffset, decorator.expression); - setNodeEmitFlags(helper, 49152); + ts.setEmitFlags(helper, 49152); expressions.push(helper); } } @@ -36070,10 +37451,33 @@ var ts; : ts.createIdentifier("Symbol"); case 155: return serializeTypeReferenceNode(node); + case 163: + case 162: + { + var unionOrIntersection = node; + var serializedUnion = void 0; + for (var _i = 0, _a = unionOrIntersection.types; _i < _a.length; _i++) { + var typeNode = _a[_i]; + var serializedIndividual = serializeTypeNode(typeNode); + if (serializedIndividual.kind !== 69) { + serializedUnion = undefined; + break; + } + if (serializedIndividual.text === "Object") { + return serializedIndividual; + } + if (serializedUnion && serializedUnion.text !== serializedIndividual.text) { + serializedUnion = undefined; + break; + } + serializedUnion = serializedIndividual; + } + if (serializedUnion) { + return serializedUnion; + } + } case 158: case 159: - case 162: - case 163: case 117: case 165: break; @@ -36117,14 +37521,14 @@ var ts; function serializeEntityNameAsExpression(node, useFallback) { switch (node.kind) { case 69: - var name_29 = ts.getMutableClone(node); - name_29.flags &= ~8; - name_29.original = undefined; - name_29.parent = currentScope; + var name_30 = ts.getMutableClone(node); + name_30.flags &= ~8; + name_30.original = undefined; + name_30.parent = currentScope; if (useFallback) { - return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_29), ts.createLiteral("undefined")), name_29); + return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_30), ts.createLiteral("undefined")), name_30); } - return name_29; + return name_30; case 139: return serializeQualifiedNameAsExpression(node, useFallback); } @@ -36194,8 +37598,8 @@ var ts; return undefined; } var method = ts.createMethod(undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, visitPropertyNameOfClassElement(node), undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); - setCommentRange(method, node); - setSourceMapRange(method, ts.moveRangePastDecorators(node)); + ts.setCommentRange(method, node); + ts.setSourceMapRange(method, ts.moveRangePastDecorators(node)); ts.setOriginalNode(method, node); return method; } @@ -36207,8 +37611,8 @@ var ts; return undefined; } var accessor = ts.createGetAccessor(undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, node.body ? ts.visitEachChild(node.body, visitor, context) : ts.createBlock([]), node); - setCommentRange(accessor, node); - setSourceMapRange(accessor, ts.moveRangePastDecorators(node)); + ts.setCommentRange(accessor, node); + ts.setSourceMapRange(accessor, ts.moveRangePastDecorators(node)); ts.setOriginalNode(accessor, node); return accessor; } @@ -36217,8 +37621,8 @@ var ts; return undefined; } var accessor = ts.createSetAccessor(undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitNodes(node.parameters, visitor, ts.isParameter), node.body ? ts.visitEachChild(node.body, visitor, context) : ts.createBlock([]), node); - setCommentRange(accessor, node); - setSourceMapRange(accessor, ts.moveRangePastDecorators(node)); + ts.setCommentRange(accessor, node); + ts.setSourceMapRange(accessor, ts.moveRangePastDecorators(node)); ts.setOriginalNode(accessor, node); return accessor; } @@ -36313,11 +37717,11 @@ var ts; if (languageVersion >= 2) { if (resolver.getNodeCheckFlags(node) & 4096) { enableSubstitutionForAsyncMethodsWithSuper(); - setNodeEmitFlags(block, 8); + ts.setEmitFlags(block, 8); } else if (resolver.getNodeCheckFlags(node) & 2048) { enableSubstitutionForAsyncMethodsWithSuper(); - setNodeEmitFlags(block, 4); + ts.setEmitFlags(block, 4); } } return block; @@ -36327,14 +37731,14 @@ var ts; } } function visitParameter(node) { - if (node.name && ts.isIdentifier(node.name) && node.name.originalKeywordKind === 97) { + if (ts.parameterIsThisKeyword(node)) { return undefined; } var parameter = ts.createParameterDeclaration(undefined, undefined, node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression), ts.moveRangePastModifiers(node)); ts.setOriginalNode(parameter, node); - setCommentRange(parameter, node); - setSourceMapRange(parameter, ts.moveRangePastModifiers(node)); - setNodeEmitFlags(parameter.name, 1024); + ts.setCommentRange(parameter, node); + ts.setSourceMapRange(parameter, ts.moveRangePastModifiers(node)); + ts.setEmitFlags(parameter.name, 1024); return parameter; } function visitVariableStatement(node) { @@ -36383,12 +37787,13 @@ var ts; || compilerOptions.isolatedModules; } function shouldEmitVarForEnumDeclaration(node) { - return !ts.hasModifier(node, 1) - || (isES6ExportedDeclaration(node) && ts.isFirstDeclarationOfKind(node, node.kind)); + return isFirstEmittedDeclarationInScope(node) + && (!ts.hasModifier(node, 1) + || isES6ExportedDeclaration(node)); } function addVarForEnumExportedFromNamespace(statements, node) { var statement = ts.createVariableStatement(undefined, [ts.createVariableDeclaration(getDeclarationName(node), undefined, getExportName(node))]); - setSourceMapRange(statement, node); + ts.setSourceMapRange(statement, node); statements.push(statement); } function visitEnumDeclaration(node) { @@ -36397,6 +37802,7 @@ var ts; } var statements = []; var emitFlags = 64; + recordEmittedDeclarationInScope(node); if (shouldEmitVarForEnumDeclaration(node)) { addVarForEnumOrModuleDeclaration(statements, node); if (moduleKind !== ts.ModuleKind.System || currentScope !== currentSourceFile) { @@ -36408,7 +37814,7 @@ var ts; var exportName = getExportName(node); var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, transformEnumBody(node, containerName)), undefined, [ts.createLogicalOr(exportName, ts.createAssignment(exportName, ts.createObjectLiteral()))]), node); ts.setOriginalNode(enumStatement, node); - setNodeEmitFlags(enumStatement, emitFlags); + ts.setEmitFlags(enumStatement, emitFlags); statements.push(enumStatement); if (isNamespaceExport(node)) { addVarForEnumExportedFromNamespace(statements, node); @@ -36447,18 +37853,32 @@ var ts; function shouldEmitModuleDeclaration(node) { return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); } - function isModuleMergedWithES6Class(node) { - return languageVersion === 2 - && ts.isMergedWithClass(node); - } function isES6ExportedDeclaration(node) { return isExternalModuleExport(node) && moduleKind === ts.ModuleKind.ES6; } + function recordEmittedDeclarationInScope(node) { + var name = node.symbol && node.symbol.name; + if (name) { + if (!currentScopeFirstDeclarationsOfName) { + currentScopeFirstDeclarationsOfName = ts.createMap(); + } + if (!(name in currentScopeFirstDeclarationsOfName)) { + currentScopeFirstDeclarationsOfName[name] = node; + } + } + } + function isFirstEmittedDeclarationInScope(node) { + if (currentScopeFirstDeclarationsOfName) { + var name_31 = node.symbol && node.symbol.name; + if (name_31) { + return currentScopeFirstDeclarationsOfName[name_31] === node; + } + } + return false; + } function shouldEmitVarForModuleDeclaration(node) { - return !isModuleMergedWithES6Class(node) - && (!isES6ExportedDeclaration(node) - || ts.isFirstDeclarationOfKind(node, node.kind)); + return isFirstEmittedDeclarationInScope(node); } function addVarForEnumOrModuleDeclaration(statements, node) { var statement = ts.createVariableStatement(isES6ExportedDeclaration(node) @@ -36468,13 +37888,13 @@ var ts; ]); ts.setOriginalNode(statement, node); if (node.kind === 224) { - setSourceMapRange(statement.declarationList, node); + ts.setSourceMapRange(statement.declarationList, node); } else { - setSourceMapRange(statement, node); + ts.setSourceMapRange(statement, node); } - setCommentRange(statement, node); - setNodeEmitFlags(statement, 32768); + ts.setCommentRange(statement, node); + ts.setEmitFlags(statement, 32768); statements.push(statement); } function visitModuleDeclaration(node) { @@ -36485,6 +37905,7 @@ var ts; enableSubstitutionForNamespaceExports(); var statements = []; var emitFlags = 64; + recordEmittedDeclarationInScope(node); if (shouldEmitVarForModuleDeclaration(node)) { addVarForEnumOrModuleDeclaration(statements, node); if (moduleKind !== ts.ModuleKind.System || currentScope !== currentSourceFile) { @@ -36501,15 +37922,17 @@ var ts; } var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, transformModuleBody(node, containerName)), undefined, [moduleArg]), node); ts.setOriginalNode(moduleStatement, node); - setNodeEmitFlags(moduleStatement, emitFlags); + ts.setEmitFlags(moduleStatement, emitFlags); statements.push(moduleStatement); return statements; } function transformModuleBody(node, namespaceLocalName) { var savedCurrentNamespaceContainerName = currentNamespaceContainerName; var savedCurrentNamespace = currentNamespace; + var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName; currentNamespaceContainerName = namespaceLocalName; currentNamespace = node; + currentScopeFirstDeclarationsOfName = undefined; var statements = []; startLexicalEnvironment(); var statementsLocation; @@ -36536,9 +37959,10 @@ var ts; ts.addRange(statements, endLexicalEnvironment()); currentNamespaceContainerName = savedCurrentNamespaceContainerName; currentNamespace = savedCurrentNamespace; + currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), blockLocation, true); if (body.kind !== 226) { - setNodeEmitFlags(block, block.emitFlags | 49152); + ts.setEmitFlags(block, ts.getEmitFlags(block) | 49152); } return block; } @@ -36561,7 +37985,7 @@ var ts; return undefined; } var moduleReference = ts.createExpressionFromEntityName(node.moduleReference); - setNodeEmitFlags(moduleReference, 49152 | 65536); + ts.setEmitFlags(moduleReference, 49152 | 65536); if (isNamedExternalModuleExport(node) || !isNamespaceExport(node)) { return ts.setOriginalNode(ts.createVariableStatement(ts.visitNodes(node.modifiers, visitor, ts.isModifier), ts.createVariableDeclarationList([ ts.createVariableDeclaration(node.name, undefined, moduleReference) @@ -36590,9 +38014,9 @@ var ts; } function addExportMemberAssignment(statements, node) { var expression = ts.createAssignment(getExportName(node), getLocalName(node, true)); - setSourceMapRange(expression, ts.createRange(node.name.pos, node.end)); + ts.setSourceMapRange(expression, ts.createRange(node.name.pos, node.end)); var statement = ts.createStatement(expression); - setSourceMapRange(statement, ts.createRange(-1, node.end)); + ts.setSourceMapRange(statement, ts.createRange(-1, node.end)); statements.push(statement); } function createNamespaceExport(exportName, exportValue, location) { @@ -36613,7 +38037,7 @@ var ts; emitFlags |= 1536; } if (emitFlags) { - setNodeEmitFlags(qualifiedName, emitFlags); + ts.setEmitFlags(qualifiedName, emitFlags); } return qualifiedName; } @@ -36622,7 +38046,7 @@ var ts; } function getNamespaceParameterName(node) { var name = ts.getGeneratedNameForNode(node); - setSourceMapRange(name, node.name); + ts.setSourceMapRange(name, node.name); return name; } function getNamespaceContainerName(node) { @@ -36639,8 +38063,8 @@ var ts; } function getDeclarationName(node, allowComments, allowSourceMaps, emitFlags) { if (node.name) { - var name_30 = ts.getMutableClone(node.name); - emitFlags |= getNodeEmitFlags(node.name); + var name_32 = ts.getMutableClone(node.name); + emitFlags |= ts.getEmitFlags(node.name); if (!allowSourceMaps) { emitFlags |= 1536; } @@ -36648,9 +38072,9 @@ var ts; emitFlags |= 49152; } if (emitFlags) { - setNodeEmitFlags(name_30, emitFlags); + ts.setEmitFlags(name_32, emitFlags); } - return name_30; + return name_32; } else { return ts.getGeneratedNameForNode(node); @@ -36712,7 +38136,7 @@ var ts; function isTransformedEnumDeclaration(node) { return ts.getOriginalNode(node).kind === 224; } - function onEmitNode(node, emit) { + function onEmitNode(emitContext, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; var savedCurrentSuperContainer = currentSuperContainer; if (enabledSubstitutions & 4 && isSuperContainer(node)) { @@ -36724,13 +38148,13 @@ var ts; if (enabledSubstitutions & 8 && isTransformedEnumDeclaration(node)) { applicableSubstitutions |= 8; } - previousOnEmitNode(node, emit); + previousOnEmitNode(emitContext, node, emitCallback); applicableSubstitutions = savedApplicableSubstitutions; currentSuperContainer = savedCurrentSuperContainer; } - function onSubstituteNode(node, isExpression) { - node = previousOnSubstituteNode(node, isExpression); - if (isExpression) { + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1) { return substituteExpression(node); } else if (ts.isShorthandPropertyAssignment(node)) { @@ -36740,14 +38164,14 @@ var ts; } function substituteShorthandPropertyAssignment(node) { if (enabledSubstitutions & 2) { - var name_31 = node.name; - var exportedName = trySubstituteNamespaceExportedName(name_31); + var name_33 = node.name; + var exportedName = trySubstituteNamespaceExportedName(name_33); if (exportedName) { if (node.objectAssignmentInitializer) { var initializer = ts.createAssignment(exportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name_31, initializer, node); + return ts.createPropertyAssignment(name_33, initializer, node); } - return ts.createPropertyAssignment(name_31, exportedName, node); + return ts.createPropertyAssignment(name_33, exportedName, node); } } return node; @@ -36756,16 +38180,15 @@ var ts; switch (node.kind) { case 69: return substituteExpressionIdentifier(node); - } - if (enabledSubstitutions & 4) { - switch (node.kind) { - case 174: + case 172: + return substitutePropertyAccessExpression(node); + case 173: + return substituteElementAccessExpression(node); + case 174: + if (enabledSubstitutions & 4) { return substituteCallExpression(node); - case 172: - return substitutePropertyAccessExpression(node); - case 173: - return substituteElementAccessExpression(node); - } + } + break; } return node; } @@ -36782,8 +38205,8 @@ var ts; var classAlias = classAliases[declaration.id]; if (classAlias) { var clone_4 = ts.getSynthesizedClone(classAlias); - setSourceMapRange(clone_4, node); - setCommentRange(clone_4, node); + ts.setSourceMapRange(clone_4, node); + ts.setCommentRange(clone_4, node); return clone_4; } } @@ -36792,7 +38215,7 @@ var ts; return undefined; } function trySubstituteNamespaceExportedName(node) { - if (enabledSubstitutions & applicableSubstitutions && (getNodeEmitFlags(node) & 262144) === 0) { + if (enabledSubstitutions & applicableSubstitutions && (ts.getEmitFlags(node) & 262144) === 0) { var container = resolver.getReferencedExportContainer(node, false); if (container) { var substitute = (applicableSubstitutions & 2 && container.kind === 225) || @@ -36820,23 +38243,48 @@ var ts; return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 95) { + if (enabledSubstitutions & 4 && node.expression.kind === 95) { var flags = getSuperContainerAsyncMethodFlags(); if (flags) { return createSuperAccessInAsyncMethod(ts.createLiteral(node.name.text), flags, node); } } - return node; + return substituteConstantValue(node); } function substituteElementAccessExpression(node) { - if (node.expression.kind === 95) { + if (enabledSubstitutions & 4 && node.expression.kind === 95) { var flags = getSuperContainerAsyncMethodFlags(); if (flags) { return createSuperAccessInAsyncMethod(node.argumentExpression, flags, node); } } + return substituteConstantValue(node); + } + function substituteConstantValue(node) { + var constantValue = tryGetConstEnumValue(node); + if (constantValue !== undefined) { + var substitute = ts.createLiteral(constantValue); + ts.setSourceMapRange(substitute, node); + ts.setCommentRange(substitute, node); + if (!compilerOptions.removeComments) { + var propertyName = ts.isPropertyAccessExpression(node) + ? ts.declarationNameToString(node.name) + : ts.getTextOfNode(node.argumentExpression); + substitute.trailingComment = " " + propertyName + " "; + } + ts.setConstantValue(node, constantValue); + return substitute; + } return node; } + function tryGetConstEnumValue(node) { + if (compilerOptions.isolatedModules) { + return undefined; + } + return ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node) + ? resolver.getConstantValue(node) + : undefined; + } function createSuperAccessInAsyncMethod(argumentExpression, flags, location) { if (flags & 4096) { return ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), "value", location); @@ -36860,6 +38308,9 @@ var ts; var currentSourceFile; return transformSourceFile; function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } currentSourceFile = node; node = ts.visitEachChild(node, visitor, context); currentSourceFile = undefined; @@ -37018,12 +38469,12 @@ var ts; return getTagName(node.openingElement); } else { - var name_32 = node.tagName; - if (ts.isIdentifier(name_32) && ts.isIntrinsicJsxName(name_32.text)) { - return ts.createLiteral(name_32.text); + var name_34 = node.tagName; + if (ts.isIdentifier(name_34) && ts.isIntrinsicJsxName(name_34.text)) { + return ts.createLiteral(name_34.text); } else { - return ts.createExpressionFromEntityName(name_32); + return ts.createExpressionFromEntityName(name_34); } } } @@ -37305,6 +38756,9 @@ var ts; var hoistVariableDeclaration = context.hoistVariableDeclaration; return transformSourceFile; function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } return ts.visitEachChild(node, visitor, context); } function visitor(node) { @@ -37364,7 +38818,7 @@ var ts; var ts; (function (ts) { function transformES6(context) { - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration, getNodeEmitFlags = context.getNodeEmitFlags, setNodeEmitFlags = context.setNodeEmitFlags, getCommentRange = context.getCommentRange, setCommentRange = context.setCommentRange, getSourceMapRange = context.getSourceMapRange, setSourceMapRange = context.setSourceMapRange, setTokenSourceMapRange = context.setTokenSourceMapRange; + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); var previousOnSubstituteNode = context.onSubstituteNode; var previousOnEmitNode = context.onEmitNode; @@ -37384,6 +38838,9 @@ var ts; var enabledSubstitutions; return transformSourceFile; function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } currentSourceFile = node; currentText = node.text; return ts.visitNode(node, visitor, ts.isSourceFile); @@ -37553,7 +39010,7 @@ var ts; enclosingFunction = currentNode; if (currentNode.kind !== 180) { enclosingNonArrowFunction = currentNode; - if (!(currentNode.emitFlags & 2097152)) { + if (!(ts.getEmitFlags(currentNode) & 2097152)) { enclosingNonAsyncFunctionBody = currentNode; } } @@ -37690,15 +39147,15 @@ var ts; } var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); var classFunction = ts.createFunctionExpression(undefined, undefined, undefined, extendsClauseElement ? [ts.createParameter("_super")] : [], undefined, transformClassBody(node, extendsClauseElement)); - if (getNodeEmitFlags(node) & 524288) { - setNodeEmitFlags(classFunction, 524288); + if (ts.getEmitFlags(node) & 524288) { + ts.setEmitFlags(classFunction, 524288); } var inner = ts.createPartiallyEmittedExpression(classFunction); inner.end = node.end; - setNodeEmitFlags(inner, 49152); + ts.setEmitFlags(inner, 49152); var outer = ts.createPartiallyEmittedExpression(inner); outer.end = ts.skipTrivia(currentText, node.pos); - setNodeEmitFlags(outer, 49152); + ts.setEmitFlags(outer, 49152); return ts.createParen(ts.createCall(outer, undefined, extendsClauseElement ? [ts.visitNode(extendsClauseElement.expression, visitor, ts.isExpression)] : [])); @@ -37713,14 +39170,14 @@ var ts; var localName = getLocalName(node); var outer = ts.createPartiallyEmittedExpression(localName); outer.end = closingBraceLocation.end; - setNodeEmitFlags(outer, 49152); + ts.setEmitFlags(outer, 49152); var statement = ts.createReturn(outer); statement.pos = closingBraceLocation.pos; - setNodeEmitFlags(statement, 49152 | 12288); + ts.setEmitFlags(statement, 49152 | 12288); statements.push(statement); ts.addRange(statements, endLexicalEnvironment()); var block = ts.createBlock(ts.createNodeArray(statements, node.members), undefined, true); - setNodeEmitFlags(block, 49152); + ts.setEmitFlags(block, 49152); return block; } function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) { @@ -37731,7 +39188,11 @@ var ts; function addConstructor(statements, node, extendsClauseElement) { var constructor = ts.getFirstConstructorWithBody(node); var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); - statements.push(ts.createFunctionDeclaration(undefined, undefined, undefined, getDeclarationName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), constructor || node)); + var constructorFunction = ts.createFunctionDeclaration(undefined, undefined, undefined, getDeclarationName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), constructor || node); + if (extendsClauseElement) { + ts.setEmitFlags(constructorFunction, 256); + } + statements.push(constructorFunction); } function transformConstructorParameters(constructor, hasSynthesizedSuper) { if (constructor && !hasSynthesizedSuper) { @@ -37742,33 +39203,98 @@ var ts; function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { var statements = []; startLexicalEnvironment(); + var statementOffset = -1; + if (hasSynthesizedSuper) { + statementOffset = 1; + } + else if (constructor) { + statementOffset = ts.addPrologueDirectives(statements, constructor.body.statements, false, visitor); + } if (constructor) { - addCaptureThisForNodeIfNeeded(statements, constructor); addDefaultValueAssignmentsIfNeeded(statements, constructor); addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); + ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); + } + var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, !!extendsClauseElement, hasSynthesizedSuper, statementOffset); + if (superCaptureStatus === 1 || superCaptureStatus === 2) { + statementOffset++; } - addDefaultSuperCallIfNeeded(statements, constructor, extendsClauseElement, hasSynthesizedSuper); if (constructor) { - var body = saveStateAndInvoke(constructor, hasSynthesizedSuper ? transformConstructorBodyWithSynthesizedSuper : transformConstructorBodyWithoutSynthesizedSuper); + var body = saveStateAndInvoke(constructor, function (constructor) { return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset); }); ts.addRange(statements, body); } + if (extendsClauseElement + && superCaptureStatus !== 2 + && !(constructor && isSufficientlyCoveredByReturnStatements(constructor.body))) { + statements.push(ts.createReturn(ts.createIdentifier("_this"))); + } ts.addRange(statements, endLexicalEnvironment()); var block = ts.createBlock(ts.createNodeArray(statements, constructor ? constructor.body.statements : node.members), constructor ? constructor.body : node, true); if (!constructor) { - setNodeEmitFlags(block, 49152); + ts.setEmitFlags(block, 49152); } return block; } - function transformConstructorBodyWithSynthesizedSuper(node) { - return ts.visitNodes(node.body.statements, visitor, ts.isStatement, 1); - } - function transformConstructorBodyWithoutSynthesizedSuper(node) { - return ts.visitNodes(node.body.statements, visitor, ts.isStatement, 0); - } - function addDefaultSuperCallIfNeeded(statements, constructor, extendsClauseElement, hasSynthesizedSuper) { - if (constructor ? hasSynthesizedSuper : extendsClauseElement) { - statements.push(ts.createStatement(ts.createFunctionApply(ts.createIdentifier("_super"), ts.createThis(), ts.createIdentifier("arguments")), extendsClauseElement)); + function isSufficientlyCoveredByReturnStatements(statement) { + if (statement.kind === 211) { + return true; } + else if (statement.kind === 203) { + var ifStatement = statement; + if (ifStatement.elseStatement) { + return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && + isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); + } + } + else if (statement.kind === 199) { + var lastStatement = ts.lastOrUndefined(statement.statements); + if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { + return true; + } + } + return false; + } + function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, hasExtendsClause, hasSynthesizedSuper, statementOffset) { + if (!hasExtendsClause) { + if (ctor) { + addCaptureThisForNodeIfNeeded(statements, ctor); + } + return 0; + } + if (!ctor) { + statements.push(ts.createReturn(createDefaultSuperCallOrThis())); + return 2; + } + if (hasSynthesizedSuper) { + captureThisForNode(statements, ctor, createDefaultSuperCallOrThis()); + enableSubstitutionsForCapturedThis(); + return 1; + } + var firstStatement; + var superCallExpression; + var ctorStatements = ctor.body.statements; + if (statementOffset < ctorStatements.length) { + firstStatement = ctorStatements[statementOffset]; + if (firstStatement.kind === 202 && ts.isSuperCall(firstStatement.expression)) { + var superCall = firstStatement.expression; + superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); + } + } + if (superCallExpression && statementOffset === ctorStatements.length - 1) { + statements.push(ts.createReturn(superCallExpression)); + return 2; + } + captureThisForNode(statements, ctor, superCallExpression, firstStatement); + if (superCallExpression) { + return 1; + } + return 0; + } + function createDefaultSuperCallOrThis() { + var actualThis = ts.createThis(); + ts.setEmitFlags(actualThis, 128); + var superCall = ts.createFunctionApply(ts.createIdentifier("_super"), actualThis, ts.createIdentifier("arguments")); + return ts.createLogicalOr(superCall, actualThis); } function visitParameter(node) { if (node.dotDotDotToken) { @@ -37793,34 +39319,34 @@ var ts; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { var parameter = _a[_i]; - var name_33 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; + var name_35 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; if (dotDotDotToken) { continue; } - if (ts.isBindingPattern(name_33)) { - addDefaultValueAssignmentForBindingPattern(statements, parameter, name_33, initializer); + if (ts.isBindingPattern(name_35)) { + addDefaultValueAssignmentForBindingPattern(statements, parameter, name_35, initializer); } else if (initializer) { - addDefaultValueAssignmentForInitializer(statements, parameter, name_33, initializer); + addDefaultValueAssignmentForInitializer(statements, parameter, name_35, initializer); } } } function addDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer) { var temp = ts.getGeneratedNameForNode(parameter); if (name.elements.length > 0) { - statements.push(setNodeEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(ts.flattenParameterDestructuring(context, parameter, temp, visitor))), 8388608)); + statements.push(ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(ts.flattenParameterDestructuring(context, parameter, temp, visitor))), 8388608)); } else if (initializer) { - statements.push(setNodeEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 8388608)); + statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 8388608)); } } function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) { initializer = ts.visitNode(initializer, visitor, ts.isExpression); - var statement = ts.createIf(ts.createStrictEquality(ts.getSynthesizedClone(name), ts.createVoidZero()), setNodeEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(setNodeEmitFlags(ts.getMutableClone(name), 1536), setNodeEmitFlags(initializer, 1536 | getNodeEmitFlags(initializer)), parameter)) + var statement = ts.createIf(ts.createStrictEquality(ts.getSynthesizedClone(name), ts.createVoidZero()), ts.setEmitFlags(ts.createBlock([ + ts.createStatement(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 1536), ts.setEmitFlags(initializer, 1536 | ts.getEmitFlags(initializer)), parameter)) ], parameter), 32 | 1024 | 12288), undefined, parameter); statement.startsOnNewLine = true; - setNodeEmitFlags(statement, 12288 | 1024 | 8388608); + ts.setEmitFlags(statement, 12288 | 1024 | 8388608); statements.push(statement); } function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) { @@ -37832,11 +39358,11 @@ var ts; return; } var declarationName = ts.getMutableClone(parameter.name); - setNodeEmitFlags(declarationName, 1536); + ts.setEmitFlags(declarationName, 1536); var expressionName = ts.getSynthesizedClone(parameter.name); var restIndex = node.parameters.length - 1; var temp = ts.createLoopVariable(); - statements.push(setNodeEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + statements.push(ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration(declarationName, undefined, ts.createArrayLiteral([])) ]), parameter), 8388608)); var forStatement = ts.createFor(ts.createVariableDeclarationList([ @@ -37844,21 +39370,24 @@ var ts; ], parameter), ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length"), parameter), ts.createPostfixIncrement(temp, parameter), ts.createBlock([ ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp)), parameter)) ])); - setNodeEmitFlags(forStatement, 8388608); + ts.setEmitFlags(forStatement, 8388608); ts.startOnNewLine(forStatement); statements.push(forStatement); } function addCaptureThisForNodeIfNeeded(statements, node) { if (node.transformFlags & 16384 && node.kind !== 180) { - enableSubstitutionsForCapturedThis(); - var captureThisStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration("_this", undefined, ts.createThis()) - ])); - setNodeEmitFlags(captureThisStatement, 49152 | 8388608); - setSourceMapRange(captureThisStatement, node); - statements.push(captureThisStatement); + captureThisForNode(statements, node, ts.createThis()); } } + function captureThisForNode(statements, node, initializer, originalStatement) { + enableSubstitutionsForCapturedThis(); + var captureThisStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration("_this", undefined, initializer) + ]), originalStatement); + ts.setEmitFlags(captureThisStatement, 49152 | 8388608); + ts.setSourceMapRange(captureThisStatement, node); + statements.push(captureThisStatement); + } function addClassMembers(statements, node) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; @@ -37888,43 +39417,43 @@ var ts; return ts.createEmptyStatement(member); } function transformClassMethodDeclarationToStatement(receiver, member) { - var commentRange = getCommentRange(member); - var sourceMapRange = getSourceMapRange(member); + var commentRange = ts.getCommentRange(member); + var sourceMapRange = ts.getSourceMapRange(member); var func = transformFunctionLikeToExpression(member, member, undefined); - setNodeEmitFlags(func, 49152); - setSourceMapRange(func, sourceMapRange); + ts.setEmitFlags(func, 49152); + ts.setSourceMapRange(func, sourceMapRange); var statement = ts.createStatement(ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), member.name), func), member); ts.setOriginalNode(statement, member); - setCommentRange(statement, commentRange); - setNodeEmitFlags(statement, 1536); + ts.setCommentRange(statement, commentRange); + ts.setEmitFlags(statement, 1536); return statement; } function transformAccessorsToStatement(receiver, accessors) { - var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, false), getSourceMapRange(accessors.firstAccessor)); - setNodeEmitFlags(statement, 49152); + var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, false), ts.getSourceMapRange(accessors.firstAccessor)); + ts.setEmitFlags(statement, 49152); return statement; } function transformAccessorsToExpression(receiver, _a, startsOnNewLine) { var firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; var target = ts.getMutableClone(receiver); - setNodeEmitFlags(target, 49152 | 1024); - setSourceMapRange(target, firstAccessor.name); + ts.setEmitFlags(target, 49152 | 1024); + ts.setSourceMapRange(target, firstAccessor.name); var propertyName = ts.createExpressionForPropertyName(ts.visitNode(firstAccessor.name, visitor, ts.isPropertyName)); - setNodeEmitFlags(propertyName, 49152 | 512); - setSourceMapRange(propertyName, firstAccessor.name); + ts.setEmitFlags(propertyName, 49152 | 512); + ts.setSourceMapRange(propertyName, firstAccessor.name); var properties = []; if (getAccessor) { var getterFunction = transformFunctionLikeToExpression(getAccessor, undefined, undefined); - setSourceMapRange(getterFunction, getSourceMapRange(getAccessor)); + ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); var getter = ts.createPropertyAssignment("get", getterFunction); - setCommentRange(getter, getCommentRange(getAccessor)); + ts.setCommentRange(getter, ts.getCommentRange(getAccessor)); properties.push(getter); } if (setAccessor) { var setterFunction = transformFunctionLikeToExpression(setAccessor, undefined, undefined); - setSourceMapRange(setterFunction, getSourceMapRange(setAccessor)); + ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); var setter = ts.createPropertyAssignment("set", setterFunction); - setCommentRange(setter, getCommentRange(setAccessor)); + ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); properties.push(setter); } properties.push(ts.createPropertyAssignment("enumerable", ts.createLiteral(true)), ts.createPropertyAssignment("configurable", ts.createLiteral(true))); @@ -37943,7 +39472,7 @@ var ts; enableSubstitutionsForCapturedThis(); } var func = transformFunctionLikeToExpression(node, node, undefined); - setNodeEmitFlags(func, 256); + ts.setEmitFlags(func, 256); return func; } function visitFunctionExpression(node) { @@ -38000,7 +39529,7 @@ var ts; } var expression = ts.visitNode(body, visitor, ts.isExpression); var returnStatement = ts.createReturn(expression, body); - setNodeEmitFlags(returnStatement, 12288 | 1024 | 32768); + ts.setEmitFlags(returnStatement, 12288 | 1024 | 32768); statements.push(returnStatement); closeBraceLocation = body; } @@ -38011,10 +39540,10 @@ var ts; } var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), node.body, multiLine); if (!multiLine && singleLine) { - setNodeEmitFlags(block, 32); + ts.setEmitFlags(block, 32); } if (closeBraceLocation) { - setTokenSourceMapRange(block, 16, closeBraceLocation); + ts.setTokenSourceMapRange(block, 16, closeBraceLocation); } ts.setOriginalNode(block, node.body); return block; @@ -38055,7 +39584,7 @@ var ts; assignment = ts.flattenVariableDestructuringToExpression(context, decl, hoistVariableDeclaration, undefined, visitor); } else { - assignment = ts.createBinary(decl.name, 56, decl.initializer); + assignment = ts.createBinary(decl.name, 56, ts.visitNode(decl.initializer, visitor, ts.isExpression)); } (assignments || (assignments = [])).push(assignment); } @@ -38078,13 +39607,13 @@ var ts; : visitVariableDeclaration)); var declarationList = ts.createVariableDeclarationList(declarations, node); ts.setOriginalNode(declarationList, node); - setCommentRange(declarationList, node); + ts.setCommentRange(declarationList, node); if (node.transformFlags & 2097152 && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { var firstDeclaration = ts.firstOrUndefined(declarations); var lastDeclaration = ts.lastOrUndefined(declarations); - setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); } return declarationList; } @@ -38179,7 +39708,7 @@ var ts; ts.setOriginalNode(declarationList, initializer); var firstDeclaration = declarations[0]; var lastDeclaration = ts.lastOrUndefined(declarations); - setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); statements.push(ts.createVariableStatement(undefined, declarationList)); } else { @@ -38214,14 +39743,14 @@ var ts; statements.push(statement); } } - setNodeEmitFlags(expression, 1536 | getNodeEmitFlags(expression)); + ts.setEmitFlags(expression, 1536 | ts.getEmitFlags(expression)); var body = ts.createBlock(ts.createNodeArray(statements, statementsLocation), bodyLocation); - setNodeEmitFlags(body, 1536 | 12288); + ts.setEmitFlags(body, 1536 | 12288); var forStatement = ts.createFor(ts.createVariableDeclarationList([ ts.createVariableDeclaration(counter, undefined, ts.createLiteral(0), ts.moveRangePos(node.expression, -1)), ts.createVariableDeclaration(rhsReference, undefined, expression, node.expression) ], node.expression), ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length"), node.expression), ts.createPostfixIncrement(counter, node.expression), body, node); - setNodeEmitFlags(forStatement, 8192); + ts.setEmitFlags(forStatement, 8192); return forStatement; } function visitObjectLiteralExpression(node) { @@ -38239,7 +39768,7 @@ var ts; ts.Debug.assert(numInitialProperties !== numProperties); var temp = ts.createTempVariable(hoistVariableDeclaration); var expressions = []; - var assignment = ts.createAssignment(temp, setNodeEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), undefined, node.multiLine), 524288)); + var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), undefined, node.multiLine), 524288)); if (node.multiLine) { assignment.startsOnNewLine = true; } @@ -38328,7 +39857,7 @@ var ts; loopBody = ts.createBlock([loopBody], undefined, true); } var isAsyncBlockContainingAwait = enclosingNonArrowFunction - && (enclosingNonArrowFunction.emitFlags & 2097152) !== 0 + && (ts.getEmitFlags(enclosingNonArrowFunction) & 2097152) !== 0 && (node.statement.transformFlags & 4194304) !== 0; var loopBodyFlags = 0; if (currentState.containsLexicalThis) { @@ -38338,7 +39867,7 @@ var ts; loopBodyFlags |= 2097152; } var convertedLoopVariable = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(functionName, undefined, setNodeEmitFlags(ts.createFunctionExpression(isAsyncBlockContainingAwait ? ts.createToken(37) : undefined, undefined, undefined, loopParameters, undefined, loopBody), loopBodyFlags)) + ts.createVariableDeclaration(functionName, undefined, ts.setEmitFlags(ts.createFunctionExpression(isAsyncBlockContainingAwait ? ts.createToken(37) : undefined, undefined, undefined, loopParameters, undefined, loopBody), loopBodyFlags)) ])); var statements = [convertedLoopVariable]; var extraVariableDeclarations; @@ -38366,8 +39895,8 @@ var ts; if (!extraVariableDeclarations) { extraVariableDeclarations = []; } - for (var name_34 in currentState.hoistedLocalVariables) { - var identifier = currentState.hoistedLocalVariables[name_34]; + for (var _b = 0, _c = currentState.hoistedLocalVariables; _b < _c.length; _b++) { + var identifier = _c[_b]; extraVariableDeclarations.push(ts.createVariableDeclaration(identifier)); } } @@ -38376,8 +39905,8 @@ var ts; if (!extraVariableDeclarations) { extraVariableDeclarations = []; } - for (var _b = 0, loopOutParameters_1 = loopOutParameters; _b < loopOutParameters_1.length; _b++) { - var outParam = loopOutParameters_1[_b]; + for (var _d = 0, loopOutParameters_1 = loopOutParameters; _d < loopOutParameters_1.length; _d++) { + var outParam = loopOutParameters_1[_d]; extraVariableDeclarations.push(ts.createVariableDeclaration(outParam.outParamName)); } } @@ -38555,7 +40084,7 @@ var ts; function visitMethodDeclaration(node) { ts.Debug.assert(!ts.isComputedPropertyName(node.name)); var functionExpression = transformFunctionLikeToExpression(node, ts.moveRangePos(node, -1), undefined); - setNodeEmitFlags(functionExpression, 16384 | getNodeEmitFlags(functionExpression)); + ts.setEmitFlags(functionExpression, 16384 | ts.getEmitFlags(functionExpression)); return ts.createPropertyAssignment(node.name, functionExpression, node); } function visitShorthandPropertyAssignment(node) { @@ -38568,13 +40097,32 @@ var ts; return transformAndSpreadElements(node.elements, true, node.multiLine, node.elements.hasTrailingComma); } function visitCallExpression(node) { + return visitCallExpressionWithPotentialCapturedThisAssignment(node, true); + } + function visitImmediateSuperCallInBody(node) { + return visitCallExpressionWithPotentialCapturedThisAssignment(node, false); + } + function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) { var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; + if (node.expression.kind === 95) { + ts.setEmitFlags(thisArg, 128); + } + var resultingCall; if (node.transformFlags & 262144) { - return ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, false, false, false)); + resultingCall = ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, false, false, false)); } else { - return ts.createFunctionCall(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), node); + resultingCall = ts.createFunctionCall(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), node); } + if (node.expression.kind === 95) { + var actualThis = ts.createThis(); + ts.setEmitFlags(actualThis, 128); + var initializer = ts.createLogicalOr(resultingCall, actualThis); + return assignToCapturedThis + ? ts.createAssignment(ts.createIdentifier("_this"), initializer) + : initializer; + } + return resultingCall; } function visitNewExpression(node) { ts.Debug.assert((node.transformFlags & 262144) !== 0); @@ -38694,12 +40242,12 @@ var ts; clone.statements = ts.createNodeArray(statements, node.statements); return clone; } - function onEmitNode(node, emit) { + function onEmitNode(emitContext, node, emitCallback) { var savedEnclosingFunction = enclosingFunction; if (enabledSubstitutions & 1 && ts.isFunctionLike(node)) { enclosingFunction = node; } - previousOnEmitNode(node, emit); + previousOnEmitNode(emitContext, node, emitCallback); enclosingFunction = savedEnclosingFunction; } function enableSubstitutionsForBlockScopedBindings() { @@ -38721,9 +40269,9 @@ var ts; context.enableEmitNotification(220); } } - function onSubstituteNode(node, isExpression) { - node = previousOnSubstituteNode(node, isExpression); - if (isExpression) { + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1) { return substituteExpression(node); } if (ts.isIdentifier(node)) { @@ -38773,7 +40321,7 @@ var ts; function substituteThisKeyword(node) { if (enabledSubstitutions & 1 && enclosingFunction - && enclosingFunction.emitFlags & 256) { + && ts.getEmitFlags(enclosingFunction) & 256) { return ts.createIdentifier("_this", node); } return node; @@ -38783,8 +40331,8 @@ var ts; } function getDeclarationName(node, allowComments, allowSourceMaps, emitFlags) { if (node.name && !ts.isGeneratedIdentifier(node.name)) { - var name_35 = ts.getMutableClone(node.name); - emitFlags |= getNodeEmitFlags(node.name); + var name_36 = ts.getMutableClone(node.name); + emitFlags |= ts.getEmitFlags(node.name); if (!allowSourceMaps) { emitFlags |= 1536; } @@ -38792,9 +40340,9 @@ var ts; emitFlags |= 49152; } if (emitFlags) { - setNodeEmitFlags(name_35, emitFlags); + ts.setEmitFlags(name_36, emitFlags); } - return name_35; + return name_36; } return ts.getGeneratedNameForNode(node); } @@ -38842,7 +40390,7 @@ var ts; _a[7] = "endfinally", _a)); function transformGenerators(context) { - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistFunctionDeclaration = context.hoistFunctionDeclaration, hoistVariableDeclaration = context.hoistVariableDeclaration, setSourceMapRange = context.setSourceMapRange, setCommentRange = context.setCommentRange, setNodeEmitFlags = context.setNodeEmitFlags; + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistFunctionDeclaration = context.hoistFunctionDeclaration, hoistVariableDeclaration = context.hoistVariableDeclaration; var compilerOptions = context.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var resolver = context.getEmitResolver(); @@ -38876,6 +40424,9 @@ var ts; var withBlockStack; return transformSourceFile; function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } if (node.transformFlags & 1024) { currentSourceFile = node; node = ts.visitEachChild(node, visitor, context); @@ -38982,7 +40533,7 @@ var ts; } } function visitFunctionDeclaration(node) { - if (node.asteriskToken && node.emitFlags & 2097152) { + if (node.asteriskToken && ts.getEmitFlags(node) & 2097152) { node = ts.setOriginalNode(ts.createFunctionDeclaration(undefined, undefined, undefined, node.name, undefined, node.parameters, undefined, transformGeneratorFunctionBody(node.body), node), node); } else { @@ -39003,7 +40554,7 @@ var ts; } } function visitFunctionExpression(node) { - if (node.asteriskToken && node.emitFlags & 2097152) { + if (node.asteriskToken && ts.getEmitFlags(node) & 2097152) { node = ts.setOriginalNode(ts.createFunctionExpression(undefined, node.name, undefined, node.parameters, undefined, transformGeneratorFunctionBody(node.body), node), node); } else { @@ -39034,6 +40585,7 @@ var ts; var savedBlocks = blocks; var savedBlockOffsets = blockOffsets; var savedBlockActions = blockActions; + var savedBlockStack = blockStack; var savedLabelOffsets = labelOffsets; var savedLabelExpressions = labelExpressions; var savedNextLabelId = nextLabelId; @@ -39046,6 +40598,7 @@ var ts; blocks = undefined; blockOffsets = undefined; blockActions = undefined; + blockStack = undefined; labelOffsets = undefined; labelExpressions = undefined; nextLabelId = 1; @@ -39064,6 +40617,7 @@ var ts; blocks = savedBlocks; blockOffsets = savedBlockOffsets; blockActions = savedBlockActions; + blockStack = savedBlockStack; labelOffsets = savedLabelOffsets; labelExpressions = savedLabelExpressions; nextLabelId = savedNextLabelId; @@ -39079,7 +40633,7 @@ var ts; return undefined; } else { - if (node.emitFlags & 8388608) { + if (ts.getEmitFlags(node) & 8388608) { return node; } for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { @@ -39747,9 +41301,9 @@ var ts; } return -1; } - function onSubstituteNode(node, isExpression) { - node = previousOnSubstituteNode(node, isExpression); - if (isExpression) { + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1) { return substituteExpression(node); } return node; @@ -39766,11 +41320,11 @@ var ts; if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - var name_36 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); - if (name_36) { - var clone_8 = ts.getMutableClone(name_36); - setSourceMapRange(clone_8, node); - setCommentRange(clone_8, node); + var name_37 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); + if (name_37) { + var clone_8 = ts.getMutableClone(name_37); + ts.setSourceMapRange(clone_8, node); + ts.setCommentRange(clone_8, node); return clone_8; } } @@ -40164,7 +41718,7 @@ var ts; var buildResult = buildStatements(); return ts.createCall(ts.createHelperName(currentSourceFile.externalHelpersModuleName, "__generator"), undefined, [ ts.createThis(), - setNodeEmitFlags(ts.createFunctionExpression(undefined, undefined, undefined, [ts.createParameter(state)], undefined, ts.createBlock(buildResult, undefined, buildResult.length > 0)), 4194304) + ts.setEmitFlags(ts.createFunctionExpression(undefined, undefined, undefined, [ts.createParameter(state)], undefined, ts.createBlock(buildResult, undefined, buildResult.length > 0)), 4194304) ]); } function buildStatements() { @@ -40439,7 +41993,7 @@ var ts; _a[ts.ModuleKind.AMD] = transformAMDModule, _a[ts.ModuleKind.UMD] = transformUMDModule, _a)); - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration, setNodeEmitFlags = context.setNodeEmitFlags, getNodeEmitFlags = context.getNodeEmitFlags, setSourceMapRange = context.setSourceMapRange; + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var compilerOptions = context.getCompilerOptions(); var resolver = context.getEmitResolver(); var host = context.getEmitHost(); @@ -40464,6 +42018,9 @@ var ts; var hasExportStarsToExportValues; return transformSourceFile; function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { currentSourceFile = node; (_a = ts.collectExternalModuleInfo(node, resolver), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); @@ -40489,7 +42046,7 @@ var ts; addExportEqualsIfNeeded(statements, false); var updated = updateSourceFile(node, statements); if (hasExportStarsToExportValues) { - setNodeEmitFlags(updated, 2 | getNodeEmitFlags(node)); + ts.setEmitFlags(updated, 2 | ts.getEmitFlags(node)); } return updated; } @@ -40500,7 +42057,7 @@ var ts; } function transformUMDModule(node) { var define = ts.createIdentifier("define"); - setNodeEmitFlags(define, 16); + ts.setEmitFlags(define, 16); return transformAsynchronousModule(node, define, undefined, false); } function transformAsynchronousModule(node, define, moduleName, includeNonAmdDependencies) { @@ -40527,7 +42084,7 @@ var ts; addExportEqualsIfNeeded(statements, true); var body = ts.createBlock(statements, undefined, true); if (hasExportStarsToExportValues) { - setNodeEmitFlags(body, 2); + ts.setEmitFlags(body, 2); } return body; } @@ -40535,12 +42092,12 @@ var ts; if (exportEquals && resolver.isValueAliasDeclaration(exportEquals)) { if (emitAsReturn) { var statement = ts.createReturn(exportEquals.expression, exportEquals); - setNodeEmitFlags(statement, 12288 | 49152); + ts.setEmitFlags(statement, 12288 | 49152); statements.push(statement); } else { var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), exportEquals.expression), exportEquals); - setNodeEmitFlags(statement, 49152); + ts.setEmitFlags(statement, 49152); statements.push(statement); } } @@ -40603,7 +42160,7 @@ var ts; if (!ts.contains(externalImports, node)) { return undefined; } - setNodeEmitFlags(node.name, 128); + ts.setEmitFlags(node.name, 128); var statements = []; if (moduleKind !== ts.ModuleKind.AMD) { if (ts.hasModifier(node, 1)) { @@ -40691,16 +42248,16 @@ var ts; else { var names = ts.reduceEachChild(node, collectExportMembers, []); for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_37 = names_1[_i]; - addExportMemberAssignments(statements, name_37); + var name_38 = names_1[_i]; + addExportMemberAssignments(statements, name_38); } } } function collectExportMembers(names, node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node) && ts.isDeclaration(node)) { - var name_38 = node.name; - if (ts.isIdentifier(name_38)) { - names.push(name_38); + var name_39 = node.name; + if (ts.isIdentifier(name_39)) { + names.push(name_39); } } return ts.reduceEachChild(node, collectExportMembers, names); @@ -40718,7 +42275,7 @@ var ts; addExportDefault(statements, getDeclarationName(node), node); } else { - statements.push(createExportStatement(node.name, setNodeEmitFlags(ts.getSynthesizedClone(node.name), 262144), node)); + statements.push(createExportStatement(node.name, ts.setEmitFlags(ts.getSynthesizedClone(node.name), 262144), node)); } } function visitVariableStatement(node) { @@ -40835,25 +42392,25 @@ var ts; } function addVarForExportedEnumOrNamespaceDeclaration(statements, node) { var transformedStatement = ts.createVariableStatement(undefined, [ts.createVariableDeclaration(getDeclarationName(node), undefined, ts.createPropertyAccess(ts.createIdentifier("exports"), getDeclarationName(node)))], node); - setNodeEmitFlags(transformedStatement, 49152); + ts.setEmitFlags(transformedStatement, 49152); statements.push(transformedStatement); } function getDeclarationName(node) { return node.name ? ts.getSynthesizedClone(node.name) : ts.getGeneratedNameForNode(node); } - function onEmitNode(node, emit) { + function onEmitNode(emitContext, node, emitCallback) { if (node.kind === 256) { bindingNameExportSpecifiersMap = bindingNameExportSpecifiersForFileMap[ts.getOriginalNodeId(node)]; - previousOnEmitNode(node, emit); + previousOnEmitNode(emitContext, node, emitCallback); bindingNameExportSpecifiersMap = undefined; } else { - previousOnEmitNode(node, emit); + previousOnEmitNode(emitContext, node, emitCallback); } } - function onSubstituteNode(node, isExpression) { - node = previousOnSubstituteNode(node, isExpression); - if (isExpression) { + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1) { return substituteExpression(node); } else if (ts.isShorthandPropertyAssignment(node)) { @@ -40894,7 +42451,7 @@ var ts; var left = node.left; if (ts.isIdentifier(left) && ts.isAssignmentOperator(node.operatorToken.kind)) { if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, left.text)) { - setNodeEmitFlags(node, 128); + ts.setEmitFlags(node, 128); var nestedExportAssignment = void 0; for (var _i = 0, _a = bindingNameExportSpecifiersMap[left.text]; _i < _a.length; _i++) { var specifier = _a[_i]; @@ -40912,11 +42469,11 @@ var ts; var operand = node.operand; if (ts.isIdentifier(operand) && bindingNameExportSpecifiersForFileMap) { if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, operand.text)) { - setNodeEmitFlags(node, 128); + ts.setEmitFlags(node, 128); var transformedUnaryExpression = void 0; if (node.kind === 186) { - transformedUnaryExpression = ts.createBinary(operand, ts.createNode(operator === 41 ? 57 : 58), ts.createLiteral(1), node); - setNodeEmitFlags(transformedUnaryExpression, 128); + transformedUnaryExpression = ts.createBinary(operand, ts.createToken(operator === 41 ? 57 : 58), ts.createLiteral(1), node); + ts.setEmitFlags(transformedUnaryExpression, 128); } var nestedExportAssignment = void 0; for (var _i = 0, _a = bindingNameExportSpecifiersMap[operand.text]; _i < _a.length; _i++) { @@ -40931,7 +42488,7 @@ var ts; return node; } function trySubstituteExportedName(node) { - var emitFlags = getNodeEmitFlags(node); + var emitFlags = ts.getEmitFlags(node); if ((emitFlags & 262144) === 0) { var container = resolver.getReferencedExportContainer(node, (emitFlags & 131072) !== 0); if (container) { @@ -40943,7 +42500,7 @@ var ts; return undefined; } function trySubstituteImportedName(node) { - if ((getNodeEmitFlags(node) & 262144) === 0) { + if ((ts.getEmitFlags(node) & 262144) === 0) { var declaration = resolver.getReferencedImportDeclaration(node); if (declaration) { if (ts.isImportClause(declaration)) { @@ -40955,12 +42512,12 @@ var ts; } } else if (ts.isImportSpecifier(declaration)) { - var name_39 = declaration.propertyName || declaration.name; - if (name_39.originalKeywordKind === 77 && languageVersion <= 0) { - return ts.createElementAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.createLiteral(name_39.text), node); + var name_40 = declaration.propertyName || declaration.name; + if (name_40.originalKeywordKind === 77 && languageVersion <= 0) { + return ts.createElementAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.createLiteral(name_40.text), node); } else { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.getSynthesizedClone(name_39), node); + return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.getSynthesizedClone(name_40), node); } } } @@ -40982,7 +42539,7 @@ var ts; var statement = ts.createStatement(createExportAssignment(name, value)); statement.startsOnNewLine = true; if (location) { - setSourceMapRange(statement, location); + ts.setSourceMapRange(statement, location); } return statement; } @@ -41010,7 +42567,7 @@ var ts; var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile); if (includeNonAmdDependencies && importAliasName) { - setNodeEmitFlags(importAliasName, 128); + ts.setEmitFlags(importAliasName, 128); aliasedModuleNames.push(externalModuleName); importAliasNames.push(ts.createParameter(importAliasName)); } @@ -41032,7 +42589,7 @@ var ts; var ts; (function (ts) { function transformSystemModule(context) { - var getNodeEmitFlags = context.getNodeEmitFlags, setNodeEmitFlags = context.setNodeEmitFlags, startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration, hoistFunctionDeclaration = context.hoistFunctionDeclaration; + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration, hoistFunctionDeclaration = context.hoistFunctionDeclaration; var compilerOptions = context.getCompilerOptions(); var resolver = context.getEmitResolver(); var host = context.getEmitHost(); @@ -41061,6 +42618,9 @@ var ts; var currentNode; return transformSourceFile; function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { currentSourceFile = node; currentNode = node; @@ -41093,12 +42653,12 @@ var ts; var body = ts.createFunctionExpression(undefined, undefined, undefined, [ ts.createParameter(exportFunctionForFile), ts.createParameter(contextObjectForFile) - ], undefined, setNodeEmitFlags(ts.createBlock(statements, undefined, true), 1)); + ], undefined, ts.setEmitFlags(ts.createBlock(statements, undefined, true), 1)); return updateSourceFile(node, [ ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), undefined, moduleName ? [moduleName, dependencies, body] : [dependencies, body])) - ], ~1 & getNodeEmitFlags(node)); + ], ~1 & ts.getEmitFlags(node)); var _a; } function addSystemModuleBody(statements, node, dependencyGroups) { @@ -41342,11 +42902,11 @@ var ts; } function visitFunctionDeclaration(node) { if (ts.hasModifier(node, 1)) { - var name_40 = node.name || ts.getGeneratedNameForNode(node); - var newNode = ts.createFunctionDeclaration(undefined, undefined, node.asteriskToken, name_40, undefined, node.parameters, undefined, node.body, node); + var name_41 = node.name || ts.getGeneratedNameForNode(node); + var newNode = ts.createFunctionDeclaration(undefined, undefined, node.asteriskToken, name_41, undefined, node.parameters, undefined, node.body, node); recordExportedFunctionDeclaration(node); if (!ts.hasModifier(node, 512)) { - recordExportName(name_40); + recordExportName(name_41); } ts.setOriginalNode(newNode, node); node = newNode; @@ -41357,13 +42917,13 @@ var ts; function visitExpressionStatement(node) { var originalNode = ts.getOriginalNode(node); if ((originalNode.kind === 225 || originalNode.kind === 224) && ts.hasModifier(originalNode, 1)) { - var name_41 = getDeclarationName(originalNode); + var name_42 = getDeclarationName(originalNode); if (originalNode.kind === 224) { - hoistVariableDeclaration(name_41); + hoistVariableDeclaration(name_42); } return [ node, - createExportStatement(name_41, name_41) + createExportStatement(name_42, name_42) ]; } return node; @@ -41517,19 +43077,19 @@ var ts; function visitBlock(node) { return ts.visitEachChild(node, visitNestedNode, context); } - function onEmitNode(node, emit) { + function onEmitNode(emitContext, node, emitCallback) { if (node.kind === 256) { exportFunctionForFile = exportFunctionForFileMap[ts.getOriginalNodeId(node)]; - previousOnEmitNode(node, emit); + previousOnEmitNode(emitContext, node, emitCallback); exportFunctionForFile = undefined; } else { - previousOnEmitNode(node, emit); + previousOnEmitNode(emitContext, node, emitCallback); } } - function onSubstituteNode(node, isExpression) { - node = previousOnSubstituteNode(node, isExpression); - if (isExpression) { + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1) { return substituteExpression(node); } return node; @@ -41563,7 +43123,7 @@ var ts; return node; } function substituteAssignmentExpression(node) { - setNodeEmitFlags(node, 128); + ts.setEmitFlags(node, 128); var left = node.left; switch (left.kind) { case 69: @@ -41668,7 +43228,7 @@ var ts; var exportDeclaration = resolver.getReferencedExportContainer(operand); if (exportDeclaration) { var expr = ts.createPrefix(node.operator, operand, node); - setNodeEmitFlags(expr, 128); + ts.setEmitFlags(expr, 128); var call = createExportExpression(operand, expr); if (node.kind === 185) { return call; @@ -41701,7 +43261,7 @@ var ts; ts.createForIn(ts.createVariableDeclarationList([ ts.createVariableDeclaration(n, undefined) ]), m, ts.createBlock([ - setNodeEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 32) + ts.setEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 32) ])), ts.createStatement(ts.createCall(exportFunctionForFile, undefined, [exports])) ], undefined, true))); @@ -41801,7 +43361,7 @@ var ts; function updateSourceFile(node, statements, nodeEmitFlags) { var updated = ts.getMutableClone(node); updated.statements = ts.createNodeArray(statements, node.statements); - setNodeEmitFlags(updated, nodeEmitFlags); + ts.setEmitFlags(updated, nodeEmitFlags); return updated; } } @@ -41815,6 +43375,9 @@ var ts; var currentSourceFile; return transformSourceFile; function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { currentSourceFile = node; return ts.visitEachChild(node, visitor, context); @@ -41951,18 +43514,10 @@ var ts; return transformers; } ts.getTransformers = getTransformers; - var nextTransformId = 1; function transformFiles(resolver, host, sourceFiles, transformers) { - var transformId = nextTransformId; - nextTransformId++; - var tokenSourceMapRanges = ts.createMap(); var lexicalEnvironmentVariableDeclarationsStack = []; var lexicalEnvironmentFunctionDeclarationsStack = []; var enabledSyntaxKindFeatures = new Array(289); - var parseTreeNodesWithAnnotations = []; - var lastTokenSourceMapRangeNode; - var lastTokenSourceMapRangeToken; - var lastTokenSourceMapRange; var lexicalEnvironmentStackOffset = 0; var hoistedVariableDeclarations; var hoistedFunctionDeclarations; @@ -41971,47 +43526,24 @@ var ts; getCompilerOptions: function () { return host.getCompilerOptions(); }, getEmitResolver: function () { return resolver; }, getEmitHost: function () { return host; }, - getNodeEmitFlags: getNodeEmitFlags, - setNodeEmitFlags: setNodeEmitFlags, - getSourceMapRange: getSourceMapRange, - setSourceMapRange: setSourceMapRange, - getTokenSourceMapRange: getTokenSourceMapRange, - setTokenSourceMapRange: setTokenSourceMapRange, - getCommentRange: getCommentRange, - setCommentRange: setCommentRange, hoistVariableDeclaration: hoistVariableDeclaration, hoistFunctionDeclaration: hoistFunctionDeclaration, startLexicalEnvironment: startLexicalEnvironment, endLexicalEnvironment: endLexicalEnvironment, - onSubstituteNode: onSubstituteNode, + onSubstituteNode: function (emitContext, node) { return node; }, enableSubstitution: enableSubstitution, isSubstitutionEnabled: isSubstitutionEnabled, - onEmitNode: onEmitNode, + onEmitNode: function (node, emitContext, emitCallback) { return emitCallback(node, emitContext); }, enableEmitNotification: enableEmitNotification, isEmitNotificationEnabled: isEmitNotificationEnabled }; - var transformation = chain.apply(void 0, transformers)(context); + var transformation = ts.chain.apply(void 0, transformers)(context); var transformed = ts.map(sourceFiles, transformSourceFile); lexicalEnvironmentDisabled = true; return { - getSourceFiles: function () { return transformed; }, - getTokenSourceMapRange: getTokenSourceMapRange, - isSubstitutionEnabled: isSubstitutionEnabled, - isEmitNotificationEnabled: isEmitNotificationEnabled, - onSubstituteNode: context.onSubstituteNode, - onEmitNode: context.onEmitNode, - dispose: function () { - for (var _i = 0, parseTreeNodesWithAnnotations_1 = parseTreeNodesWithAnnotations; _i < parseTreeNodesWithAnnotations_1.length; _i++) { - var node = parseTreeNodesWithAnnotations_1[_i]; - if (node.transformId === transformId) { - node.transformId = 0; - node.emitFlags = 0; - node.commentRange = undefined; - node.sourceMapRange = undefined; - } - } - parseTreeNodesWithAnnotations.length = 0; - } + transformed: transformed, + emitNodeWithSubstitution: emitNodeWithSubstitution, + emitNodeWithNotification: emitNodeWithNotification }; function transformSourceFile(sourceFile) { if (ts.isDeclarationFile(sourceFile)) { @@ -42023,75 +43555,37 @@ var ts; enabledSyntaxKindFeatures[kind] |= 1; } function isSubstitutionEnabled(node) { - return (enabledSyntaxKindFeatures[node.kind] & 1) !== 0; + return (enabledSyntaxKindFeatures[node.kind] & 1) !== 0 + && (ts.getEmitFlags(node) & 128) === 0; } - function onSubstituteNode(node, isExpression) { - return node; + function emitNodeWithSubstitution(emitContext, node, emitCallback) { + if (node) { + if (isSubstitutionEnabled(node)) { + var substitute = context.onSubstituteNode(emitContext, node); + if (substitute && substitute !== node) { + emitCallback(emitContext, substitute); + return; + } + } + emitCallback(emitContext, node); + } } function enableEmitNotification(kind) { enabledSyntaxKindFeatures[kind] |= 2; } function isEmitNotificationEnabled(node) { return (enabledSyntaxKindFeatures[node.kind] & 2) !== 0 - || (getNodeEmitFlags(node) & 64) !== 0; + || (ts.getEmitFlags(node) & 64) !== 0; } - function onEmitNode(node, emit) { - emit(node); - } - function beforeSetAnnotation(node) { - if ((node.flags & 8) === 0 && node.transformId !== transformId) { - parseTreeNodesWithAnnotations.push(node); - node.transformId = transformId; - } - } - function getNodeEmitFlags(node) { - return node.emitFlags; - } - function setNodeEmitFlags(node, emitFlags) { - beforeSetAnnotation(node); - node.emitFlags = emitFlags; - return node; - } - function getSourceMapRange(node) { - return node.sourceMapRange || node; - } - function setSourceMapRange(node, range) { - beforeSetAnnotation(node); - node.sourceMapRange = range; - return node; - } - function getTokenSourceMapRange(node, token) { - if (lastTokenSourceMapRangeNode === node && lastTokenSourceMapRangeToken === token) { - return lastTokenSourceMapRange; - } - var range; - var current = node; - while (current) { - range = current.id ? tokenSourceMapRanges[current.id + "-" + token] : undefined; - if (range !== undefined) { - break; + function emitNodeWithNotification(emitContext, node, emitCallback) { + if (node) { + if (isEmitNotificationEnabled(node)) { + context.onEmitNode(emitContext, node, emitCallback); + } + else { + emitCallback(emitContext, node); } - current = current.original; } - lastTokenSourceMapRangeNode = node; - lastTokenSourceMapRangeToken = token; - lastTokenSourceMapRange = range; - return range; - } - function setTokenSourceMapRange(node, token, range) { - lastTokenSourceMapRangeNode = node; - lastTokenSourceMapRangeToken = token; - lastTokenSourceMapRange = range; - tokenSourceMapRanges[ts.getNodeId(node) + "-" + token] = range; - return node; - } - function getCommentRange(node) { - return node.commentRange || node; - } - function setCommentRange(node, range) { - beforeSetAnnotation(node); - node.commentRange = range; - return node; } function hoistVariableDeclaration(name) { ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot modify the lexical environment during the print phase."); @@ -42144,54 +43638,6 @@ var ts; } } ts.transformFiles = transformFiles; - function chain(a, b, c, d, e) { - if (e) { - var args_3 = []; - for (var i = 0; i < arguments.length; i++) { - args_3[i] = arguments[i]; - } - return function (t) { return compose.apply(void 0, ts.map(args_3, function (f) { return f(t); })); }; - } - else if (d) { - return function (t) { return compose(a(t), b(t), c(t), d(t)); }; - } - else if (c) { - return function (t) { return compose(a(t), b(t), c(t)); }; - } - else if (b) { - return function (t) { return compose(a(t), b(t)); }; - } - else if (a) { - return function (t) { return compose(a(t)); }; - } - else { - return function (t) { return function (u) { return u; }; }; - } - } - function compose(a, b, c, d, e) { - if (e) { - var args_4 = []; - for (var i = 0; i < arguments.length; i++) { - args_4[i] = arguments[i]; - } - return function (t) { return ts.reduceLeft(args_4, function (u, f) { return f(u); }, t); }; - } - else if (d) { - return function (t) { return d(c(b(a(t)))); }; - } - else if (c) { - return function (t) { return c(b(a(t))); }; - } - else if (b) { - return function (t) { return b(a(t)); }; - } - else if (a) { - return function (t) { return a(t); }; - } - else { - return function (t) { return t; }; - } - } var _a; })(ts || (ts = {})); var ts; @@ -42202,11 +43648,11 @@ var ts; return declarationDiagnostics.getDiagnostics(targetSourceFile ? targetSourceFile.fileName : undefined); function getDeclarationDiagnosticsFromFile(_a, sources, isBundledEmit) { var declarationFilePath = _a.declarationFilePath; - emitDeclarations(host, resolver, declarationDiagnostics, declarationFilePath, sources, isBundledEmit); + emitDeclarations(host, resolver, declarationDiagnostics, declarationFilePath, sources, isBundledEmit, false); } } ts.getDeclarationDiagnostics = getDeclarationDiagnostics; - function emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFiles, isBundledEmit) { + function emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFiles, isBundledEmit, emitOnlyDtsFiles) { var newLine = host.getNewLine(); var compilerOptions = host.getCompilerOptions(); var write; @@ -42242,7 +43688,7 @@ var ts; ts.forEach(sourceFile.referencedFiles, function (fileReference) { var referencedFile = ts.tryResolveScriptReference(host, sourceFile, fileReference); if (referencedFile && !ts.contains(emittedReferencedFiles, referencedFile)) { - if (writeReferencePath(referencedFile, !isBundledEmit && !addedGlobalFileReference)) { + if (writeReferencePath(referencedFile, !isBundledEmit && !addedGlobalFileReference, emitOnlyDtsFiles)) { addedGlobalFileReference = true; } emittedReferencedFiles.push(referencedFile); @@ -42427,7 +43873,7 @@ var ts; } else { errorNameNode = declaration.name; - resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2, writer); + resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2 | 1024, writer); errorNameNode = undefined; } } @@ -42439,7 +43885,7 @@ var ts; } else { errorNameNode = signature.name; - resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, 2, writer); + resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, 2 | 1024, writer); errorNameNode = undefined; } } @@ -42612,9 +44058,9 @@ var ts; var count = 0; while (true) { count++; - var name_42 = baseName + "_" + count; - if (!(name_42 in currentIdentifiers)) { - return name_42; + var name_43 = baseName + "_" + count; + if (!(name_43 in currentIdentifiers)) { + return name_43; } } } @@ -42632,7 +44078,7 @@ var ts; write(tempVarName); write(": "); writer.getSymbolAccessibilityDiagnostic = getDefaultExportAccessibilityDiagnostic; - resolver.writeTypeOfExpression(node.expression, enclosingDeclaration, 2, writer); + resolver.writeTypeOfExpression(node.expression, enclosingDeclaration, 2 | 1024, writer); write(";"); writeLine(); write(node.isExportEquals ? "export = " : "export default "); @@ -43038,7 +44484,7 @@ var ts; } else { writer.getSymbolAccessibilityDiagnostic = getHeritageClauseVisibilityError; - resolver.writeBaseConstructorTypeOfClass(enclosingDeclaration, enclosingDeclaration, 2, writer); + resolver.writeBaseConstructorTypeOfClass(enclosingDeclaration, enclosingDeclaration, 2 | 1024, writer); } function getHeritageClauseVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; @@ -43606,14 +45052,14 @@ var ts; return emitSourceFile(node); } } - function writeReferencePath(referencedFile, addBundledFileReference) { + function writeReferencePath(referencedFile, addBundledFileReference, emitOnlyDtsFiles) { var declFileName; var addedBundledEmitReference = false; if (ts.isDeclarationFile(referencedFile)) { declFileName = referencedFile.fileName; } else { - ts.forEachExpectedEmitFile(host, getDeclFileName, referencedFile); + ts.forEachExpectedEmitFile(host, getDeclFileName, referencedFile, emitOnlyDtsFiles); } if (declFileName) { declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(declarationFilePath)), declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, false); @@ -43630,8 +45076,8 @@ var ts; } } } - function writeDeclarationFile(declarationFilePath, sourceFiles, isBundledEmit, host, resolver, emitterDiagnostics) { - var emitDeclarationResult = emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFiles, isBundledEmit); + function writeDeclarationFile(declarationFilePath, sourceFiles, isBundledEmit, host, resolver, emitterDiagnostics, emitOnlyDtsFiles) { + var emitDeclarationResult = emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFiles, isBundledEmit, emitOnlyDtsFiles); var emitSkipped = emitDeclarationResult.reportedDeclarationError || host.isEmitBlocked(declarationFilePath) || host.getCompilerOptions().noEmit; if (!emitSkipped) { var declarationOutput = emitDeclarationResult.referencesOutput @@ -43657,41 +45103,6 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function createSourceMapWriter(host, writer) { - var compilerOptions = host.getCompilerOptions(); - if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) { - if (compilerOptions.extendedDiagnostics) { - return createSourceMapWriterWithExtendedDiagnostics(host, writer); - } - return createSourceMapWriterWorker(host, writer); - } - else { - return getNullSourceMapWriter(); - } - } - ts.createSourceMapWriter = createSourceMapWriter; - var nullSourceMapWriter; - function getNullSourceMapWriter() { - if (nullSourceMapWriter === undefined) { - nullSourceMapWriter = { - initialize: function (filePath, sourceMapFilePath, sourceFiles, isBundledEmit) { }, - reset: function () { }, - getSourceMapData: function () { return undefined; }, - setSourceFile: function (sourceFile) { }, - emitPos: function (pos) { }, - emitStart: function (range, contextNode, ignoreNodeCallback, ignoreChildrenCallback, getTextRangeCallback) { }, - emitEnd: function (range, contextNode, ignoreNodeCallback, ignoreChildrenCallback, getTextRangeCallback) { }, - emitTokenStart: function (token, pos, contextNode, ignoreTokenCallback, getTokenTextRangeCallback) { return -1; }, - emitTokenEnd: function (token, end, contextNode, ignoreTokenCallback, getTokenTextRangeCallback) { return -1; }, - changeEmitSourcePos: function () { }, - stopOverridingSpan: function () { }, - getText: function () { return undefined; }, - getSourceMappingURL: function () { return undefined; } - }; - } - return nullSourceMapWriter; - } - ts.getNullSourceMapWriter = getNullSourceMapWriter; var defaultLastEncodedSourceMapSpan = { emittedLine: 1, emittedColumn: 1, @@ -43699,42 +45110,38 @@ var ts; sourceColumn: 1, sourceIndex: 0 }; - function createSourceMapWriterWorker(host, writer) { + function createSourceMapWriter(host, writer) { var compilerOptions = host.getCompilerOptions(); var extendedDiagnostics = compilerOptions.extendedDiagnostics; var currentSourceFile; var currentSourceText; var sourceMapDir; - var stopOverridingSpan = false; - var modifyLastSourcePos = false; var sourceMapSourceIndex; var lastRecordedSourceMapSpan; var lastEncodedSourceMapSpan; var lastEncodedNameIndex; var sourceMapData; - var disableDepth; + var disabled = !(compilerOptions.sourceMap || compilerOptions.inlineSourceMap); return { initialize: initialize, reset: reset, getSourceMapData: function () { return sourceMapData; }, setSourceFile: setSourceFile, emitPos: emitPos, - emitStart: emitStart, - emitEnd: emitEnd, - emitTokenStart: emitTokenStart, - emitTokenEnd: emitTokenEnd, - changeEmitSourcePos: changeEmitSourcePos, - stopOverridingSpan: function () { return stopOverridingSpan = true; }, + emitNodeWithSourceMap: emitNodeWithSourceMap, + emitTokenWithSourceMap: emitTokenWithSourceMap, getText: getText, getSourceMappingURL: getSourceMappingURL }; function initialize(filePath, sourceMapFilePath, sourceFiles, isBundledEmit) { + if (disabled) { + return; + } if (sourceMapData) { reset(); } currentSourceFile = undefined; currentSourceText = undefined; - disableDepth = 0; sourceMapSourceIndex = -1; lastRecordedSourceMapSpan = undefined; lastEncodedSourceMapSpan = defaultLastEncodedSourceMapSpan; @@ -43774,6 +45181,9 @@ var ts; } } function reset() { + if (disabled) { + return; + } currentSourceFile = undefined; sourceMapDir = undefined; sourceMapSourceIndex = undefined; @@ -43781,38 +45191,6 @@ var ts; lastEncodedSourceMapSpan = undefined; lastEncodedNameIndex = undefined; sourceMapData = undefined; - disableDepth = 0; - } - function enable() { - if (disableDepth > 0) { - disableDepth--; - } - } - function disable() { - disableDepth++; - } - function updateLastEncodedAndRecordedSpans() { - if (modifyLastSourcePos) { - modifyLastSourcePos = false; - lastRecordedSourceMapSpan.emittedLine = lastEncodedSourceMapSpan.emittedLine; - lastRecordedSourceMapSpan.emittedColumn = lastEncodedSourceMapSpan.emittedColumn; - sourceMapData.sourceMapDecodedMappings.pop(); - lastEncodedSourceMapSpan = sourceMapData.sourceMapDecodedMappings.length ? - sourceMapData.sourceMapDecodedMappings[sourceMapData.sourceMapDecodedMappings.length - 1] : - defaultLastEncodedSourceMapSpan; - var sourceMapMappings = sourceMapData.sourceMapMappings; - var lenthToSet = sourceMapMappings.length - 1; - for (; lenthToSet >= 0; lenthToSet--) { - var currentChar = sourceMapMappings.charAt(lenthToSet); - if (currentChar === ",") { - break; - } - if (currentChar === ";" && lenthToSet !== 0 && sourceMapMappings.charAt(lenthToSet - 1) !== ";") { - break; - } - } - sourceMapData.sourceMapMappings = sourceMapMappings.substr(0, Math.max(0, lenthToSet)); - } } function encodeLastRecordedSourceMapSpan() { if (!lastRecordedSourceMapSpan || lastRecordedSourceMapSpan === lastEncodedSourceMapSpan) { @@ -43843,7 +45221,7 @@ var ts; sourceMapData.sourceMapDecodedMappings.push(lastEncodedSourceMapSpan); } function emitPos(pos) { - if (ts.positionIsSynthesized(pos) || disableDepth > 0) { + if (disabled || ts.positionIsSynthesized(pos)) { return; } if (extendedDiagnostics) { @@ -43868,84 +45246,68 @@ var ts; sourceColumn: sourceLinePos.character, sourceIndex: sourceMapSourceIndex }; - stopOverridingSpan = false; } - else if (!stopOverridingSpan) { + else { lastRecordedSourceMapSpan.sourceLine = sourceLinePos.line; lastRecordedSourceMapSpan.sourceColumn = sourceLinePos.character; lastRecordedSourceMapSpan.sourceIndex = sourceMapSourceIndex; } - updateLastEncodedAndRecordedSpans(); if (extendedDiagnostics) { ts.performance.mark("afterSourcemap"); ts.performance.measure("Source Map", "beforeSourcemap", "afterSourcemap"); } } - function getStartPosPastDecorators(range) { - var rangeHasDecorators = !!range.decorators; - return ts.skipTrivia(currentSourceText, rangeHasDecorators ? range.decorators.end : range.pos); - } - function emitStart(range, contextNode, ignoreNodeCallback, ignoreChildrenCallback, getTextRangeCallback) { - if (contextNode) { - if (!ignoreNodeCallback(contextNode)) { - range = getTextRangeCallback(contextNode) || range; - emitPos(getStartPosPastDecorators(range)); - } - if (ignoreChildrenCallback(contextNode)) { - disable(); - } + function emitNodeWithSourceMap(emitContext, node, emitCallback) { + if (disabled) { + return emitCallback(emitContext, node); } - else { - emitPos(getStartPosPastDecorators(range)); + if (node) { + var emitNode = node.emitNode; + var emitFlags = emitNode && emitNode.flags; + var _a = emitNode && emitNode.sourceMapRange || node, pos = _a.pos, end = _a.end; + if (node.kind !== 287 + && (emitFlags & 512) === 0 + && pos >= 0) { + emitPos(ts.skipTrivia(currentSourceText, pos)); + } + if (emitFlags & 2048) { + disabled = true; + emitCallback(emitContext, node); + disabled = false; + } + else { + emitCallback(emitContext, node); + } + if (node.kind !== 287 + && (emitFlags & 1024) === 0 + && end >= 0) { + emitPos(end); + } } } - function emitEnd(range, contextNode, ignoreNodeCallback, ignoreChildrenCallback, getTextRangeCallback) { - if (contextNode) { - if (ignoreChildrenCallback(contextNode)) { - enable(); - } - if (!ignoreNodeCallback(contextNode)) { - range = getTextRangeCallback(contextNode) || range; - emitPos(range.end); - } + function emitTokenWithSourceMap(node, token, tokenPos, emitCallback) { + if (disabled) { + return emitCallback(token, tokenPos); } - else { - emitPos(range.end); + var emitNode = node && node.emitNode; + var emitFlags = emitNode && emitNode.flags; + var range = emitNode && emitNode.tokenSourceMapRanges && emitNode.tokenSourceMapRanges[token]; + tokenPos = ts.skipTrivia(currentSourceText, range ? range.pos : tokenPos); + if ((emitFlags & 4096) === 0 && tokenPos >= 0) { + emitPos(tokenPos); } - stopOverridingSpan = false; - } - function emitTokenStart(token, tokenStartPos, contextNode, ignoreTokenCallback, getTokenTextRangeCallback) { - if (contextNode) { - if (ignoreTokenCallback(contextNode, token)) { - return ts.skipTrivia(currentSourceText, tokenStartPos); - } - var range = getTokenTextRangeCallback(contextNode, token); - if (range) { - tokenStartPos = range.pos; - } + tokenPos = emitCallback(token, tokenPos); + if (range) + tokenPos = range.end; + if ((emitFlags & 8192) === 0 && tokenPos >= 0) { + emitPos(tokenPos); } - tokenStartPos = ts.skipTrivia(currentSourceText, tokenStartPos); - emitPos(tokenStartPos); - return tokenStartPos; - } - function emitTokenEnd(token, tokenEndPos, contextNode, ignoreTokenCallback, getTokenTextRangeCallback) { - if (contextNode) { - if (ignoreTokenCallback(contextNode, token)) { - return tokenEndPos; - } - var range = getTokenTextRangeCallback(contextNode, token); - if (range) { - tokenEndPos = range.end; - } - } - emitPos(tokenEndPos); - return tokenEndPos; - } - function changeEmitSourcePos() { - ts.Debug.assert(!modifyLastSourcePos); - modifyLastSourcePos = true; + return tokenPos; } function setSourceFile(sourceFile) { + if (disabled) { + return; + } currentSourceFile = sourceFile; currentSourceText = currentSourceFile.text; var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; @@ -43961,6 +45323,9 @@ var ts; } } function getText() { + if (disabled) { + return; + } encodeLastRecordedSourceMapSpan(); return ts.stringify({ version: 3, @@ -43973,6 +45338,9 @@ var ts; }); } function getSourceMappingURL() { + if (disabled) { + return; + } if (compilerOptions.inlineSourceMap) { var base64SourceMapText = ts.convertToBase64(getText()); return sourceMapData.jsSourceMappingURL = "data:application/json;base64," + base64SourceMapText; @@ -43982,46 +45350,7 @@ var ts; } } } - function createSourceMapWriterWithExtendedDiagnostics(host, writer) { - var _a = createSourceMapWriterWorker(host, writer), initialize = _a.initialize, reset = _a.reset, getSourceMapData = _a.getSourceMapData, setSourceFile = _a.setSourceFile, emitPos = _a.emitPos, emitStart = _a.emitStart, emitEnd = _a.emitEnd, emitTokenStart = _a.emitTokenStart, emitTokenEnd = _a.emitTokenEnd, changeEmitSourcePos = _a.changeEmitSourcePos, stopOverridingSpan = _a.stopOverridingSpan, getText = _a.getText, getSourceMappingURL = _a.getSourceMappingURL; - return { - initialize: initialize, - reset: reset, - getSourceMapData: getSourceMapData, - setSourceFile: setSourceFile, - emitPos: function (pos) { - ts.performance.mark("sourcemapStart"); - emitPos(pos); - ts.performance.measure("sourceMapTime", "sourcemapStart"); - }, - emitStart: function (range, contextNode, ignoreNodeCallback, ignoreChildrenCallback, getTextRangeCallback) { - ts.performance.mark("emitSourcemap:emitStart"); - emitStart(range, contextNode, ignoreNodeCallback, ignoreChildrenCallback, getTextRangeCallback); - ts.performance.measure("sourceMapTime", "emitSourcemap:emitStart"); - }, - emitEnd: function (range, contextNode, ignoreNodeCallback, ignoreChildrenCallback, getTextRangeCallback) { - ts.performance.mark("emitSourcemap:emitEnd"); - emitEnd(range, contextNode, ignoreNodeCallback, ignoreChildrenCallback, getTextRangeCallback); - ts.performance.measure("sourceMapTime", "emitSourcemap:emitEnd"); - }, - emitTokenStart: function (token, tokenStartPos, contextNode, ignoreTokenCallback, getTokenTextRangeCallback) { - ts.performance.mark("emitSourcemap:emitTokenStart"); - tokenStartPos = emitTokenStart(token, tokenStartPos, contextNode, ignoreTokenCallback, getTokenTextRangeCallback); - ts.performance.measure("sourceMapTime", "emitSourcemap:emitTokenStart"); - return tokenStartPos; - }, - emitTokenEnd: function (token, tokenEndPos, contextNode, ignoreTokenCallback, getTokenTextRangeCallback) { - ts.performance.mark("emitSourcemap:emitTokenEnd"); - tokenEndPos = emitTokenEnd(token, tokenEndPos, contextNode, ignoreTokenCallback, getTokenTextRangeCallback); - ts.performance.measure("sourceMapTime", "emitSourcemap:emitTokenEnd"); - return tokenEndPos; - }, - changeEmitSourcePos: changeEmitSourcePos, - stopOverridingSpan: stopOverridingSpan, - getText: getText, - getSourceMappingURL: getSourceMappingURL - }; - } + ts.createSourceMapWriter = createSourceMapWriter; var base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; function base64FormatEncode(inValue) { if (inValue < 64) { @@ -44071,20 +45400,22 @@ var ts; emitBodyWithDetachedComments: emitBodyWithDetachedComments, emitTrailingCommentsOfPosition: emitTrailingCommentsOfPosition }; - function emitNodeWithComments(node, emitCallback) { + function emitNodeWithComments(emitContext, node, emitCallback) { if (disabled) { - emitCallback(node); + emitCallback(emitContext, node); return; } if (node) { - var _a = node.commentRange || node, pos = _a.pos, end = _a.end; - var emitFlags = node.emitFlags; + var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; + var emitFlags = ts.getEmitFlags(node); if ((pos < 0 && end < 0) || (pos === end)) { if (emitFlags & 65536) { - disableCommentsAndEmit(node, emitCallback); + disabled = true; + emitCallback(emitContext, node); + disabled = false; } else { - emitCallback(node); + emitCallback(emitContext, node); } } else { @@ -44113,10 +45444,12 @@ var ts; ts.performance.measure("commentTime", "preEmitNodeWithComment"); } if (emitFlags & 65536) { - disableCommentsAndEmit(node, emitCallback); + disabled = true; + emitCallback(emitContext, node); + disabled = false; } else { - emitCallback(node); + emitCallback(emitContext, node); } if (extendedDiagnostics) { ts.performance.mark("beginEmitNodeWithComment"); @@ -44138,7 +45471,7 @@ var ts; ts.performance.mark("preEmitBodyWithDetachedComments"); } var pos = detachedRange.pos, end = detachedRange.end; - var emitFlags = node.emitFlags; + var emitFlags = ts.getEmitFlags(node); var skipLeadingComments = pos < 0 || (emitFlags & 16384) !== 0; var skipTrailingComments = disabled || end < 0 || (emitFlags & 32768) !== 0; if (!skipLeadingComments) { @@ -44147,8 +45480,10 @@ var ts; if (extendedDiagnostics) { ts.performance.measure("commentTime", "preEmitBodyWithDetachedComments"); } - if (emitFlags & 65536) { - disableCommentsAndEmit(node, emitCallback); + if (emitFlags & 65536 && !disabled) { + disabled = true; + emitCallback(node); + disabled = false; } else { emitCallback(node); @@ -44256,16 +45591,6 @@ var ts; currentLineMap = ts.getLineStarts(currentSourceFile); detachedCommentsInfo = undefined; } - function disableCommentsAndEmit(node, emitCallback) { - if (disabled) { - emitCallback(node); - } - else { - disabled = true; - emitCallback(node); - disabled = false; - } - } function hasDetachedComments(pos) { return detachedCommentsInfo !== undefined && ts.lastOrUndefined(detachedCommentsInfo).nodePos === pos; } @@ -44311,7 +45636,9 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function emitFiles(resolver, host, targetSourceFile) { + var id = function (s) { return s; }; + var nullTransformers = [function (ctx) { return id; }]; + function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles) { var delimiters = createDelimiterMap(); var brackets = createBracketsMap(); 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};"; @@ -44319,7 +45646,7 @@ var ts; 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, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments)).next());\n });\n};"; + var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments)).next());\n });\n};"; var generatorHelper = "\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t;\n return { next: verb(0), \"throw\": verb(1), \"return\": verb(2) };\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};"; var exportStarHelper = "\nfunction __export(m) {\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\n}"; var umdHelper = "\n(function (dependencies, 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(dependencies, factory);\n }\n})"; @@ -44332,11 +45659,11 @@ var ts; var emittedFilesList = compilerOptions.listEmittedFiles ? [] : undefined; var emitterDiagnostics = ts.createDiagnosticCollection(); var newLine = host.getNewLine(); - var transformers = ts.getTransformers(compilerOptions); + var transformers = emitOnlyDtsFiles ? nullTransformers : ts.getTransformers(compilerOptions); var writer = ts.createTextWriter(newLine); var write = writer.write, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; var sourceMap = ts.createSourceMapWriter(host, writer); - var emitStart = sourceMap.emitStart, emitEnd = sourceMap.emitEnd, emitTokenStart = sourceMap.emitTokenStart, emitTokenEnd = sourceMap.emitTokenEnd; + var emitNodeWithSourceMap = sourceMap.emitNodeWithSourceMap, emitTokenWithSourceMap = sourceMap.emitTokenWithSourceMap; var comments = ts.createCommentWriter(host, writer, sourceMap); var emitNodeWithComments = comments.emitNodeWithComments, emitBodyWithDetachedComments = comments.emitBodyWithDetachedComments, emitTrailingCommentsOfPosition = comments.emitTrailingCommentsOfPosition; var nodeIdToGeneratedName; @@ -44353,14 +45680,17 @@ var ts; var awaiterEmitted; var isOwnFileEmit; var emitSkipped = false; + var sourceFiles = ts.getSourceFilesToEmit(host, targetSourceFile); ts.performance.mark("beforeTransform"); - var transformed = ts.transformFiles(resolver, host, ts.getSourceFilesToEmit(host, targetSourceFile), transformers); + var _a = ts.transformFiles(resolver, host, sourceFiles, transformers), transformed = _a.transformed, emitNodeWithSubstitution = _a.emitNodeWithSubstitution, emitNodeWithNotification = _a.emitNodeWithNotification; ts.performance.measure("transformTime", "beforeTransform"); - var getTokenSourceMapRange = transformed.getTokenSourceMapRange, isSubstitutionEnabled = transformed.isSubstitutionEnabled, isEmitNotificationEnabled = transformed.isEmitNotificationEnabled, onSubstituteNode = transformed.onSubstituteNode, onEmitNode = transformed.onEmitNode; ts.performance.mark("beforePrint"); - ts.forEachTransformedEmitFile(host, transformed.getSourceFiles(), emitFile); - transformed.dispose(); + ts.forEachTransformedEmitFile(host, transformed, emitFile, emitOnlyDtsFiles); ts.performance.measure("printTime", "beforePrint"); + for (var _b = 0, sourceFiles_4 = sourceFiles; _b < sourceFiles_4.length; _b++) { + var sourceFile = sourceFiles_4[_b]; + ts.disposeEmitNodes(sourceFile); + } return { emitSkipped: emitSkipped, diagnostics: emitterDiagnostics.getDiagnostics(), @@ -44369,16 +45699,20 @@ var ts; }; function emitFile(jsFilePath, sourceMapFilePath, declarationFilePath, sourceFiles, isBundledEmit) { if (!host.isEmitBlocked(jsFilePath) && !compilerOptions.noEmit) { - printFile(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit); + if (!emitOnlyDtsFiles) { + printFile(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit); + } } else { emitSkipped = true; } if (declarationFilePath) { - emitSkipped = ts.writeDeclarationFile(declarationFilePath, ts.getOriginalSourceFiles(sourceFiles), isBundledEmit, host, resolver, emitterDiagnostics) || emitSkipped; + emitSkipped = ts.writeDeclarationFile(declarationFilePath, ts.getOriginalSourceFiles(sourceFiles), isBundledEmit, host, resolver, emitterDiagnostics, emitOnlyDtsFiles) || emitSkipped; } if (!emitSkipped && emittedFilesList) { - emittedFilesList.push(jsFilePath); + if (!emitOnlyDtsFiles) { + emittedFilesList.push(jsFilePath); + } if (sourceMapFilePath) { emittedFilesList.push(sourceMapFilePath); } @@ -44394,8 +45728,8 @@ var ts; generatedNameSet = ts.createMap(); isOwnFileEmit = !isBundledEmit; if (isBundledEmit && moduleKind) { - for (var _a = 0, sourceFiles_4 = sourceFiles; _a < sourceFiles_4.length; _a++) { - var sourceFile = sourceFiles_4[_a]; + for (var _a = 0, sourceFiles_5 = sourceFiles; _a < sourceFiles_5.length; _a++) { + var sourceFile = sourceFiles_5[_a]; emitEmitHelpers(sourceFile); } } @@ -44431,73 +45765,61 @@ var ts; currentFileIdentifiers = node.identifiers; sourceMap.setSourceFile(node); comments.setSourceFile(node); - emitNodeWithNotification(node, emitWorker); + pipelineEmitWithNotification(0, node); } function emit(node) { - emitNodeWithNotification(node, emitWithComments); - } - function emitWithComments(node) { - emitNodeWithComments(node, emitWithSourceMap); - } - function emitWithSourceMap(node) { - emitNodeWithSourceMap(node, emitWorker); + pipelineEmitWithNotification(3, node); } function emitIdentifierName(node) { - if (node) { - emitNodeWithNotification(node, emitIdentifierNameWithComments); - } - } - function emitIdentifierNameWithComments(node) { - emitNodeWithComments(node, emitWorker); + pipelineEmitWithNotification(2, node); } function emitExpression(node) { - emitNodeWithNotification(node, emitExpressionWithComments); + pipelineEmitWithNotification(1, node); } - function emitExpressionWithComments(node) { - emitNodeWithComments(node, emitExpressionWithSourceMap); + function pipelineEmitWithNotification(emitContext, node) { + emitNodeWithNotification(emitContext, node, pipelineEmitWithComments); } - function emitExpressionWithSourceMap(node) { - emitNodeWithSourceMap(node, emitExpressionWorker); - } - function emitNodeWithNotification(node, emitCallback) { - if (node) { - if (isEmitNotificationEnabled(node)) { - onEmitNode(node, emitCallback); - } - else { - emitCallback(node); - } - } - } - function emitNodeWithSourceMap(node, emitCallback) { - if (node) { - emitStart(node, node, shouldSkipLeadingSourceMapForNode, shouldSkipSourceMapForChildren, getSourceMapRange); - emitCallback(node); - emitEnd(node, node, shouldSkipTrailingSourceMapForNode, shouldSkipSourceMapForChildren, getSourceMapRange); - } - } - function getSourceMapRange(node) { - return node.sourceMapRange || node; - } - function shouldSkipLeadingCommentsForNode(node) { - return ts.isNotEmittedStatement(node) - || (node.emitFlags & 16384) !== 0; - } - function shouldSkipLeadingSourceMapForNode(node) { - return ts.isNotEmittedStatement(node) - || (node.emitFlags & 512) !== 0; - } - function shouldSkipTrailingSourceMapForNode(node) { - return ts.isNotEmittedStatement(node) - || (node.emitFlags & 1024) !== 0; - } - function shouldSkipSourceMapForChildren(node) { - return (node.emitFlags & 2048) !== 0; - } - function emitWorker(node) { - if (tryEmitSubstitute(node, emitWorker, false)) { + function pipelineEmitWithComments(emitContext, node) { + if (emitContext === 0) { + pipelineEmitWithSourceMap(emitContext, node); return; } + emitNodeWithComments(emitContext, node, pipelineEmitWithSourceMap); + } + function pipelineEmitWithSourceMap(emitContext, node) { + if (emitContext === 0 + || emitContext === 2) { + pipelineEmitWithSubstitution(emitContext, node); + return; + } + emitNodeWithSourceMap(emitContext, node, pipelineEmitWithSubstitution); + } + function pipelineEmitWithSubstitution(emitContext, node) { + emitNodeWithSubstitution(emitContext, node, pipelineEmitForContext); + } + function pipelineEmitForContext(emitContext, node) { + switch (emitContext) { + case 0: return pipelineEmitInSourceFileContext(node); + case 2: return pipelineEmitInIdentifierNameContext(node); + case 3: return pipelineEmitInUnspecifiedContext(node); + case 1: return pipelineEmitInExpressionContext(node); + } + } + function pipelineEmitInSourceFileContext(node) { + var kind = node.kind; + switch (kind) { + case 256: + return emitSourceFile(node); + } + } + function pipelineEmitInIdentifierNameContext(node) { + var kind = node.kind; + switch (kind) { + case 69: + return emitIdentifier(node); + } + } + function pipelineEmitInUnspecifiedContext(node) { var kind = node.kind; switch (kind) { case 12: @@ -44524,7 +45846,8 @@ var ts; case 132: case 133: case 137: - return writeTokenNode(node); + writeTokenText(kind); + return; case 139: return emitQualifiedName(node); case 140: @@ -44700,17 +46023,12 @@ var ts; return emitShorthandPropertyAssignment(node); case 255: return emitEnumMember(node); - case 256: - return emitSourceFile(node); } if (ts.isExpression(node)) { - return emitExpressionWorker(node); + return pipelineEmitWithSubstitution(1, node); } } - function emitExpressionWorker(node) { - if (tryEmitSubstitute(node, emitExpressionWorker, true)) { - return; - } + function pipelineEmitInExpressionContext(node) { var kind = node.kind; switch (kind) { case 8: @@ -44726,7 +46044,8 @@ var ts; case 95: case 99: case 97: - return writeTokenNode(node); + writeTokenText(kind); + return; case 170: return emitArrayLiteralExpression(node); case 171: @@ -44804,7 +46123,7 @@ var ts; } } function emitIdentifier(node) { - if (node.emitFlags & 16) { + if (ts.getEmitFlags(node) & 16) { writeLines(umdHelper); } else { @@ -45019,7 +46338,7 @@ var ts; write("{}"); } else { - var indentedFlag = node.emitFlags & 524288; + var indentedFlag = ts.getEmitFlags(node) & 524288; if (indentedFlag) { increaseIndent(); } @@ -45032,21 +46351,18 @@ var ts; } } function emitPropertyAccessExpression(node) { - if (tryEmitConstantValue(node)) { - return; - } var indentBeforeDot = false; var indentAfterDot = false; - if (!(node.emitFlags & 1048576)) { + if (!(ts.getEmitFlags(node) & 1048576)) { var dotRangeStart = node.expression.end; var dotRangeEnd = ts.skipTrivia(currentText, node.expression.end) + 1; var dotToken = { kind: 21, pos: dotRangeStart, end: dotRangeEnd }; indentBeforeDot = needsIndentation(node, node.expression, dotToken); indentAfterDot = needsIndentation(node, dotToken, node.name); } - var shouldEmitDotDot = !indentBeforeDot && needsDotDotForPropertyAccess(node.expression); emitExpression(node.expression); increaseIndentIf(indentBeforeDot); + var shouldEmitDotDot = !indentBeforeDot && needsDotDotForPropertyAccess(node.expression); write(shouldEmitDotDot ? ".." : "."); increaseIndentIf(indentAfterDot); emit(node.name); @@ -45057,15 +46373,14 @@ var ts; var text = getLiteralTextOfNode(expression); return text.indexOf(ts.tokenToString(21)) < 0; } - else { - var constantValue = tryGetConstEnumValue(expression); - return isFinite(constantValue) && Math.floor(constantValue) === constantValue; + else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { + var constantValue = ts.getConstantValue(expression); + return isFinite(constantValue) + && Math.floor(constantValue) === constantValue + && compilerOptions.removeComments; } } function emitElementAccessExpression(node) { - if (tryEmitConstantValue(node)) { - return; - } emitExpression(node.expression); write("["); emitExpression(node.argumentExpression); @@ -45220,7 +46535,7 @@ var ts; } } function emitBlockStatements(node) { - if (node.emitFlags & 32) { + if (ts.getEmitFlags(node) & 32) { emitList(node, node.statements, 384); } else { @@ -45395,11 +46710,11 @@ var ts; var body = node.body; if (body) { if (ts.isBlock(body)) { - var indentedFlag = node.emitFlags & 524288; + var indentedFlag = ts.getEmitFlags(node) & 524288; if (indentedFlag) { increaseIndent(); } - if (node.emitFlags & 4194304) { + if (ts.getEmitFlags(node) & 4194304) { emitSignatureHead(node); emitBlockFunctionBody(node, body); } @@ -45431,7 +46746,7 @@ var ts; emitWithPrefix(": ", node.type); } function shouldEmitBlockFunctionBodyOnSingleLine(parentNode, body) { - if (body.emitFlags & 32) { + if (ts.getEmitFlags(body) & 32) { return true; } if (body.multiLine) { @@ -45486,7 +46801,7 @@ var ts; emitModifiers(node, node.modifiers); write("class"); emitNodeWithPrefix(" ", node.name, emitIdentifierName); - var indentedFlag = node.emitFlags & 524288; + var indentedFlag = ts.getEmitFlags(node) & 524288; if (indentedFlag) { increaseIndent(); } @@ -45548,7 +46863,7 @@ var ts; emit(body); } function emitModuleBlock(node) { - if (isSingleLineEmptyBlock(node)) { + if (isEmptyBlock(node)) { write("{ }"); } else { @@ -45745,8 +47060,8 @@ var ts; emit(node.name); write(": "); var initializer = node.initializer; - if (!shouldSkipLeadingCommentsForNode(initializer)) { - var commentRange = initializer.commentRange || initializer; + if ((ts.getEmitFlags(initializer) & 16384) === 0) { + var commentRange = ts.getCommentRange(initializer); emitTrailingCommentsOfPosition(commentRange.pos); } emitExpression(initializer); @@ -45794,7 +47109,7 @@ var ts; return statements.length; } function emitHelpers(node) { - var emitFlags = node.emitFlags; + var emitFlags = ts.getEmitFlags(node); var helpersEmitted = false; if (emitFlags & 1) { helpersEmitted = emitEmitHelpers(currentSourceFile); @@ -45900,31 +47215,6 @@ var ts; write(suffix); } } - function tryEmitSubstitute(node, emitNode, isExpression) { - if (isSubstitutionEnabled(node) && (node.emitFlags & 128) === 0) { - var substitute = onSubstituteNode(node, isExpression); - if (substitute !== node) { - substitute.emitFlags |= 128; - emitNode(substitute); - return true; - } - } - return false; - } - function tryEmitConstantValue(node) { - var constantValue = tryGetConstEnumValue(node); - if (constantValue !== undefined) { - write(String(constantValue)); - if (!compilerOptions.removeComments) { - var propertyName = ts.isPropertyAccessExpression(node) - ? ts.declarationNameToString(node.name) - : getTextOfNode(node.argumentExpression); - write(" /* " + propertyName + " */"); - } - return true; - } - return false; - } function emitEmbeddedStatement(node) { if (ts.isBlock(node)) { write(" "); @@ -46024,7 +47314,7 @@ var ts; } } if (shouldEmitInterveningComments) { - var commentRange = child.commentRange || child; + var commentRange = ts.getCommentRange(child); emitTrailingCommentsOfPosition(commentRange.pos); } else { @@ -46066,27 +47356,12 @@ var ts; } } function writeToken(token, pos, contextNode) { - var tokenStartPos = emitTokenStart(token, pos, contextNode, shouldSkipLeadingSourceMapForToken, getTokenSourceMapRange); - var tokenEndPos = writeTokenText(token, tokenStartPos); - return emitTokenEnd(token, tokenEndPos, contextNode, shouldSkipTrailingSourceMapForToken, getTokenSourceMapRange); - } - function shouldSkipLeadingSourceMapForToken(contextNode) { - return (contextNode.emitFlags & 4096) !== 0; - } - function shouldSkipTrailingSourceMapForToken(contextNode) { - return (contextNode.emitFlags & 8192) !== 0; + return emitTokenWithSourceMap(contextNode, token, pos, writeTokenText); } function writeTokenText(token, pos) { var tokenString = ts.tokenToString(token); write(tokenString); - return ts.positionIsSynthesized(pos) ? -1 : pos + tokenString.length; - } - function writeTokenNode(node) { - if (node) { - emitStart(node, node, shouldSkipLeadingSourceMapForNode, shouldSkipSourceMapForChildren, getSourceMapRange); - writeTokenText(node.kind); - emitEnd(node, node, shouldSkipTrailingSourceMapForNode, shouldSkipSourceMapForChildren, getSourceMapRange); - } + return pos < 0 ? pos : pos + tokenString.length; } function increaseIndentIf(value, valueToWriteWhenNotIndenting) { if (value) { @@ -46225,17 +47500,12 @@ var ts; } return ts.getLiteralText(node, currentSourceFile, languageVersion); } - function tryGetConstEnumValue(node) { - if (compilerOptions.isolatedModules) { - return undefined; - } - return ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node) - ? resolver.getConstantValue(node) - : undefined; - } function isSingleLineEmptyBlock(block) { return !block.multiLine - && block.statements.length === 0 + && isEmptyBlock(block); + } + function isEmptyBlock(block) { + return block.statements.length === 0 && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function isUniqueName(name) { @@ -46255,21 +47525,21 @@ var ts; } function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name_43 = flags === 268435456 ? "_i" : "_n"; - if (isUniqueName(name_43)) { + var name_44 = flags === 268435456 ? "_i" : "_n"; + if (isUniqueName(name_44)) { tempFlags |= flags; - return name_43; + return name_44; } } while (true) { var count = tempFlags & 268435455; tempFlags++; if (count !== 8 && count !== 13) { - var name_44 = count < 26 + var name_45 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); - if (isUniqueName(name_44)) { - return name_44; + if (isUniqueName(name_45)) { + return name_45; } } } @@ -46445,581 +47715,6 @@ var ts; return ts.getNormalizedPathFromPathComponents(commonPathComponents); } ts.computeCommonSourceDirectoryOfFilenames = computeCommonSourceDirectoryOfFilenames; - function trace(host, message) { - host.trace(ts.formatMessage.apply(undefined, arguments)); - } - function isTraceEnabled(compilerOptions, host) { - return compilerOptions.traceResolution && host.trace !== undefined; - } - function hasZeroOrOneAsteriskCharacter(str) { - var seenAsterisk = false; - for (var i = 0; i < str.length; i++) { - if (str.charCodeAt(i) === 42) { - if (!seenAsterisk) { - seenAsterisk = true; - } - else { - return false; - } - } - } - return true; - } - ts.hasZeroOrOneAsteriskCharacter = hasZeroOrOneAsteriskCharacter; - function createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations) { - return { resolvedModule: resolvedFileName ? { resolvedFileName: resolvedFileName, isExternalLibraryImport: isExternalLibraryImport } : undefined, failedLookupLocations: failedLookupLocations }; - } - function moduleHasNonRelativeName(moduleName) { - return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); - } - function tryReadTypesSection(packageJsonPath, baseDirectory, state) { - var jsonContent = readJson(packageJsonPath, state.host); - function tryReadFromField(fieldName) { - if (ts.hasProperty(jsonContent, fieldName)) { - var typesFile = jsonContent[fieldName]; - if (typeof typesFile === "string") { - var typesFilePath_1 = ts.normalizePath(ts.combinePaths(baseDirectory, typesFile)); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath_1); - } - return typesFilePath_1; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof typesFile); - } - } - } - } - var typesFilePath = tryReadFromField("typings") || tryReadFromField("types"); - if (typesFilePath) { - return typesFilePath; - } - if (state.compilerOptions.allowJs && jsonContent.main && typeof jsonContent.main === "string") { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0, jsonContent.main); - } - var mainFilePath = ts.normalizePath(ts.combinePaths(baseDirectory, jsonContent.main)); - return mainFilePath; - } - return undefined; - } - function readJson(path, host) { - try { - var jsonText = host.readFile(path); - return jsonText ? JSON.parse(jsonText) : {}; - } - catch (e) { - return {}; - } - } - var typeReferenceExtensions = [".d.ts"]; - function getEffectiveTypeRoots(options, host) { - if (options.typeRoots) { - return options.typeRoots; - } - var currentDirectory; - if (options.configFilePath) { - currentDirectory = ts.getDirectoryPath(options.configFilePath); - } - else if (host.getCurrentDirectory) { - currentDirectory = host.getCurrentDirectory(); - } - return currentDirectory && getDefaultTypeRoots(currentDirectory, host); - } - ts.getEffectiveTypeRoots = getEffectiveTypeRoots; - function getDefaultTypeRoots(currentDirectory, host) { - if (!host.directoryExists) { - return [ts.combinePaths(currentDirectory, nodeModulesAtTypes)]; - } - var typeRoots; - while (true) { - var atTypes = ts.combinePaths(currentDirectory, nodeModulesAtTypes); - if (host.directoryExists(atTypes)) { - (typeRoots || (typeRoots = [])).push(atTypes); - } - var parent_15 = ts.getDirectoryPath(currentDirectory); - if (parent_15 === currentDirectory) { - break; - } - currentDirectory = parent_15; - } - return typeRoots; - } - var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types"); - function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host) { - var traceEnabled = isTraceEnabled(options, host); - var moduleResolutionState = { - compilerOptions: options, - host: host, - skipTsx: true, - traceEnabled: traceEnabled - }; - var typeRoots = getEffectiveTypeRoots(options, host); - if (traceEnabled) { - if (containingFile === undefined) { - if (typeRoots === undefined) { - trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set, typeReferenceDirectiveName); - } - else { - trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1, typeReferenceDirectiveName, typeRoots); - } - } - else { - if (typeRoots === undefined) { - trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set, typeReferenceDirectiveName, containingFile); - } - else { - trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, typeRoots); - } - } - } - var failedLookupLocations = []; - if (typeRoots && typeRoots.length) { - if (traceEnabled) { - trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", ")); - } - var primarySearchPaths = typeRoots; - for (var _i = 0, primarySearchPaths_1 = primarySearchPaths; _i < primarySearchPaths_1.length; _i++) { - var typeRoot = primarySearchPaths_1[_i]; - var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); - var candidateDirectory = ts.getDirectoryPath(candidate); - var resolvedFile_1 = loadNodeModuleFromDirectory(typeReferenceExtensions, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState); - if (resolvedFile_1) { - if (traceEnabled) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile_1, true); - } - return { - resolvedTypeReferenceDirective: { primary: true, resolvedFileName: resolvedFile_1 }, - failedLookupLocations: failedLookupLocations - }; - } - } - } - else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths); - } - } - var resolvedFile; - var initialLocationForSecondaryLookup; - if (containingFile) { - initialLocationForSecondaryLookup = ts.getDirectoryPath(containingFile); - } - if (initialLocationForSecondaryLookup !== undefined) { - if (traceEnabled) { - trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); - } - resolvedFile = loadModuleFromNodeModules(typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState); - if (traceEnabled) { - if (resolvedFile) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile, false); - } - else { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); - } - } - } - else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder); - } - } - return { - resolvedTypeReferenceDirective: resolvedFile - ? { primary: false, resolvedFileName: resolvedFile } - : undefined, - failedLookupLocations: failedLookupLocations - }; - } - ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective; - function resolveModuleName(moduleName, containingFile, compilerOptions, host) { - var traceEnabled = isTraceEnabled(compilerOptions, host); - if (traceEnabled) { - trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); - } - var moduleResolution = compilerOptions.moduleResolution; - if (moduleResolution === undefined) { - moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; - if (traceEnabled) { - trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); - } - } - else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); - } - } - var result; - switch (moduleResolution) { - case ts.ModuleResolutionKind.NodeJs: - result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host); - break; - case ts.ModuleResolutionKind.Classic: - result = classicNameResolver(moduleName, containingFile, compilerOptions, host); - break; - } - if (traceEnabled) { - if (result.resolvedModule) { - trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.resolvedModule.resolvedFileName); - } - else { - trace(host, ts.Diagnostics.Module_name_0_was_not_resolved, moduleName); - } - } - return result; - } - ts.resolveModuleName = resolveModuleName; - function tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { - if (moduleHasNonRelativeName(moduleName)) { - return tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state); - } - else { - return tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state); - } - } - function tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { - if (!state.compilerOptions.rootDirs) { - return undefined; - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0, moduleName); - } - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var matchedRootDir; - var matchedNormalizedPrefix; - for (var _i = 0, _a = state.compilerOptions.rootDirs; _i < _a.length; _i++) { - var rootDir = _a[_i]; - var normalizedRoot = ts.normalizePath(rootDir); - if (!ts.endsWith(normalizedRoot, ts.directorySeparator)) { - normalizedRoot += ts.directorySeparator; - } - var isLongestMatchingPrefix = ts.startsWith(candidate, normalizedRoot) && - (matchedNormalizedPrefix === undefined || matchedNormalizedPrefix.length < normalizedRoot.length); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Checking_if_0_is_the_longest_matching_prefix_for_1_2, normalizedRoot, candidate, isLongestMatchingPrefix); - } - if (isLongestMatchingPrefix) { - matchedNormalizedPrefix = normalizedRoot; - matchedRootDir = rootDir; - } - } - if (matchedNormalizedPrefix) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Longest_matching_prefix_for_0_is_1, candidate, matchedNormalizedPrefix); - } - var suffix = candidate.substr(matchedNormalizedPrefix.length); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, matchedNormalizedPrefix, candidate); - } - var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(containingDirectory, state.host), state); - if (resolvedFileName) { - return resolvedFileName; - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Trying_other_entries_in_rootDirs); - } - for (var _b = 0, _c = state.compilerOptions.rootDirs; _b < _c.length; _b++) { - var rootDir = _c[_b]; - if (rootDir === matchedRootDir) { - continue; - } - var candidate_1 = ts.combinePaths(ts.normalizePath(rootDir), suffix); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, rootDir, candidate_1); - } - var baseDirectory = ts.getDirectoryPath(candidate_1); - var resolvedFileName_1 = loader(candidate_1, supportedExtensions, failedLookupLocations, !directoryProbablyExists(baseDirectory, state.host), state); - if (resolvedFileName_1) { - return resolvedFileName_1; - } - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Module_resolution_using_rootDirs_has_failed); - } - } - return undefined; - } - function tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state) { - if (!state.compilerOptions.baseUrl) { - return undefined; - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, state.compilerOptions.baseUrl, moduleName); - } - var matchedPattern = undefined; - if (state.compilerOptions.paths) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); - } - matchedPattern = matchPatternOrExact(ts.getOwnKeys(state.compilerOptions.paths), moduleName); - } - if (matchedPattern) { - var matchedStar = typeof matchedPattern === "string" ? undefined : matchedText(matchedPattern, moduleName); - var matchedPatternText = typeof matchedPattern === "string" ? matchedPattern : patternText(matchedPattern); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPatternText); - } - for (var _i = 0, _a = state.compilerOptions.paths[matchedPatternText]; _i < _a.length; _i++) { - var subst = _a[_i]; - var path = matchedStar ? subst.replace("*", matchedStar) : subst; - var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, path)); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path); - } - var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); - if (resolvedFileName) { - return resolvedFileName; - } - } - return undefined; - } - else { - var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, moduleName)); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Resolving_module_name_0_relative_to_base_url_1_2, moduleName, state.compilerOptions.baseUrl, candidate); - } - return loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); - } - } - function matchPatternOrExact(patternStrings, candidate) { - var patterns = []; - for (var _i = 0, patternStrings_1 = patternStrings; _i < patternStrings_1.length; _i++) { - var patternString = patternStrings_1[_i]; - var pattern = tryParsePattern(patternString); - if (pattern) { - patterns.push(pattern); - } - else if (patternString === candidate) { - return patternString; - } - } - return findBestPatternMatch(patterns, function (_) { return _; }, candidate); - } - function patternText(_a) { - var prefix = _a.prefix, suffix = _a.suffix; - return prefix + "*" + suffix; - } - function matchedText(pattern, candidate) { - ts.Debug.assert(isPatternMatch(pattern, candidate)); - return candidate.substr(pattern.prefix.length, candidate.length - pattern.suffix.length); - } - function findBestPatternMatch(values, getPattern, candidate) { - var matchedValue = undefined; - var longestMatchPrefixLength = -1; - for (var _i = 0, values_1 = values; _i < values_1.length; _i++) { - var v = values_1[_i]; - var pattern = getPattern(v); - if (isPatternMatch(pattern, candidate) && pattern.prefix.length > longestMatchPrefixLength) { - longestMatchPrefixLength = pattern.prefix.length; - matchedValue = v; - } - } - return matchedValue; - } - ts.findBestPatternMatch = findBestPatternMatch; - function isPatternMatch(_a, candidate) { - var prefix = _a.prefix, suffix = _a.suffix; - return candidate.length >= prefix.length + suffix.length && - ts.startsWith(candidate, prefix) && - ts.endsWith(candidate, suffix); - } - function tryParsePattern(pattern) { - ts.Debug.assert(hasZeroOrOneAsteriskCharacter(pattern)); - var indexOfStar = pattern.indexOf("*"); - return indexOfStar === -1 ? undefined : { - prefix: pattern.substr(0, indexOfStar), - suffix: pattern.substr(indexOfStar + 1) - }; - } - ts.tryParsePattern = tryParsePattern; - function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host) { - var containingDirectory = ts.getDirectoryPath(containingFile); - var supportedExtensions = ts.getSupportedExtensions(compilerOptions); - var traceEnabled = isTraceEnabled(compilerOptions, host); - var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: false }; - var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, supportedExtensions, state); - var isExternalLibraryImport = false; - if (!resolvedFileName) { - if (moduleHasNonRelativeName(moduleName)) { - if (traceEnabled) { - trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder, moduleName); - } - resolvedFileName = loadModuleFromNodeModules(moduleName, containingDirectory, failedLookupLocations, state); - isExternalLibraryImport = resolvedFileName !== undefined; - } - else { - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - resolvedFileName = nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, false, state); - } - } - if (resolvedFileName && host.realpath) { - var originalFileName = resolvedFileName; - resolvedFileName = ts.normalizePath(host.realpath(resolvedFileName)); - if (traceEnabled) { - trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, originalFileName, resolvedFileName); - } - } - return createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations); - } - ts.nodeModuleNameResolver = nodeModuleNameResolver; - function nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate); - } - var resolvedFileName = !ts.pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state); - return resolvedFileName || loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, onlyRecordFailures, state); - } - function directoryProbablyExists(directoryName, host) { - return !host.directoryExists || host.directoryExists(directoryName); - } - ts.directoryProbablyExists = directoryProbablyExists; - function loadModuleFromFile(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) { - var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state); - if (resolvedByAddingExtension) { - return resolvedByAddingExtension; - } - if (ts.hasJavaScriptFileExtension(candidate)) { - var extensionless = ts.removeFileExtension(candidate); - if (state.traceEnabled) { - var extension = candidate.substring(extensionless.length); - trace(state.host, ts.Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension); - } - return tryAddingExtensions(extensionless, extensions, failedLookupLocation, onlyRecordFailures, state); - } - } - function tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) { - if (!onlyRecordFailures) { - var directory = ts.getDirectoryPath(candidate); - if (directory) { - onlyRecordFailures = !directoryProbablyExists(directory, state.host); - } - } - return ts.forEach(extensions, function (ext) { - return !(state.skipTsx && ts.isJsxOrTsxExtension(ext)) && tryFile(candidate + ext, failedLookupLocation, onlyRecordFailures, state); - }); - } - function tryFile(fileName, failedLookupLocation, onlyRecordFailures, state) { - if (!onlyRecordFailures && state.host.fileExists(fileName)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); - } - return fileName; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); - } - failedLookupLocation.push(fileName); - return undefined; - } - } - function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocation, onlyRecordFailures, state) { - var packageJsonPath = pathToPackageJson(candidate); - var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); - if (directoryExists && state.host.fileExists(packageJsonPath)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); - } - var typesFile = tryReadTypesSection(packageJsonPath, candidate, state); - if (typesFile) { - var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(typesFile), state.host); - var result = tryFile(typesFile, failedLookupLocation, onlyRecordFailures_1, state) || - tryAddingExtensions(typesFile, extensions, failedLookupLocation, onlyRecordFailures_1, state); - if (result) { - return result; - } - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_does_not_have_types_field); - } - } - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); - } - failedLookupLocation.push(packageJsonPath); - } - return loadModuleFromFile(ts.combinePaths(candidate, "index"), extensions, failedLookupLocation, !directoryExists, state); - } - function pathToPackageJson(directory) { - return ts.combinePaths(directory, "package.json"); - } - function loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state) { - var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); - var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); - var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); - var supportedExtensions = ts.getSupportedExtensions(state.compilerOptions); - var result = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, !nodeModulesFolderExists, state); - if (result) { - return result; - } - result = loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); - if (result) { - return result; - } - } - function loadModuleFromNodeModules(moduleName, directory, failedLookupLocations, state) { - directory = ts.normalizeSlashes(directory); - while (true) { - var baseName = ts.getBaseFileName(directory); - if (baseName !== "node_modules") { - var packageResult = loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state); - if (packageResult && ts.hasTypeScriptFileExtension(packageResult)) { - return packageResult; - } - else { - var typesResult = loadModuleFromNodeModulesFolder(ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); - if (typesResult || packageResult) { - return typesResult || packageResult; - } - } - } - var parentPath = ts.getDirectoryPath(directory); - if (parentPath === directory) { - break; - } - directory = parentPath; - } - return undefined; - } - function classicNameResolver(moduleName, containingFile, compilerOptions, host) { - var traceEnabled = isTraceEnabled(compilerOptions, host); - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: !compilerOptions.jsx }; - var failedLookupLocations = []; - var supportedExtensions = ts.getSupportedExtensions(compilerOptions); - var containingDirectory = ts.getDirectoryPath(containingFile); - var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, supportedExtensions, state); - if (resolvedFileName) { - return createResolvedModule(resolvedFileName, false, failedLookupLocations); - } - var referencedSourceFile; - if (moduleHasNonRelativeName(moduleName)) { - while (true) { - var searchName = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - referencedSourceFile = loadModuleFromFile(searchName, supportedExtensions, failedLookupLocations, false, state); - if (referencedSourceFile) { - break; - } - var parentPath = ts.getDirectoryPath(containingDirectory); - if (parentPath === containingDirectory) { - break; - } - containingDirectory = parentPath; - } - } - else { - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - referencedSourceFile = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, false, state); - } - return referencedSourceFile - ? { resolvedModule: { resolvedFileName: referencedSourceFile }, failedLookupLocations: failedLookupLocations } - : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; - } - ts.classicNameResolver = classicNameResolver; function createCompilerHost(options, setParentNodes) { var existingDirectories = ts.createMap(); function getCanonicalFileName(fileName) { @@ -47121,7 +47816,7 @@ var ts; readFile: function (fileName) { return ts.sys.readFile(fileName); }, trace: function (s) { return ts.sys.write(s + newLine); }, directoryExists: function (directoryName) { return ts.sys.directoryExists(directoryName); }, - getEnvironmentVariable: function (name) { return ts.getEnvironmentVariable(name, undefined); }, + getEnvironmentVariable: function (name) { return ts.sys.getEnvironmentVariable ? ts.sys.getEnvironmentVariable(name) : ""; }, getDirectories: function (path) { return ts.sys.getDirectories(path); }, realpath: realpath }; @@ -47181,41 +47876,14 @@ var ts; var resolutions = []; var cache = ts.createMap(); for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { - var name_45 = names_2[_i]; - var result = name_45 in cache - ? cache[name_45] - : cache[name_45] = loader(name_45, containingFile); + var name_46 = names_2[_i]; + var result = name_46 in cache + ? cache[name_46] + : cache[name_46] = loader(name_46, containingFile); resolutions.push(result); } return resolutions; } - function getAutomaticTypeDirectiveNames(options, host) { - if (options.types) { - return options.types; - } - var result = []; - if (host.directoryExists && host.getDirectories) { - var typeRoots = getEffectiveTypeRoots(options, host); - if (typeRoots) { - for (var _i = 0, typeRoots_1 = typeRoots; _i < typeRoots_1.length; _i++) { - var root = typeRoots_1[_i]; - if (host.directoryExists(root)) { - for (var _a = 0, _b = host.getDirectories(root); _a < _b.length; _a++) { - var typeDirectivePath = _b[_a]; - var normalized = ts.normalizePath(typeDirectivePath); - var packageJsonPath = pathToPackageJson(ts.combinePaths(root, normalized)); - var isNotNeededPackage = host.fileExists(packageJsonPath) && readJson(packageJsonPath, host).typings === null; - if (!isNotNeededPackage) { - result.push(ts.getBaseFileName(normalized)); - } - } - } - } - } - } - return result; - } - ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; function createProgram(rootNames, options, host, oldProgram) { var program; var files = []; @@ -47241,7 +47909,7 @@ var ts; resolveModuleNamesWorker = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }; } else { - var loader_1 = function (moduleName, containingFile) { return resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }; + var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }; resolveModuleNamesWorker = function (moduleNames, containingFile) { return loadWithLocalCache(moduleNames, containingFile, loader_1); }; } var resolveTypeReferenceDirectiveNamesWorker; @@ -47249,15 +47917,15 @@ var ts; resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile) { return host.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile); }; } else { - var loader_2 = function (typesRef, containingFile) { return resolveTypeReferenceDirective(typesRef, containingFile, options, host).resolvedTypeReferenceDirective; }; + var loader_2 = function (typesRef, containingFile) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host).resolvedTypeReferenceDirective; }; resolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile) { return loadWithLocalCache(typeReferenceDirectiveNames, containingFile, loader_2); }; } var filesByName = ts.createFileMap(); var filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? ts.createFileMap(function (fileName) { return fileName.toLowerCase(); }) : undefined; if (!tryReuseStructureFromOldProgram()) { ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); - var typeReferences = getAutomaticTypeDirectiveNames(options, host); - if (typeReferences) { + var typeReferences = ts.getAutomaticTypeDirectiveNames(options, host); + if (typeReferences.length) { var containingFilename = ts.combinePaths(host.getCurrentDirectory(), "__inferred type names__.ts"); var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename); for (var i = 0; i < typeReferences.length; i++) { @@ -47299,7 +47967,8 @@ var ts; getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); }, getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); }, getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; }, - getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; } + getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; }, + dropDiagnosticsProducingTypeChecker: dropDiagnosticsProducingTypeChecker }; verifyCompilerOptions(); ts.performance.mark("afterProgram"); @@ -47346,6 +48015,7 @@ var ts; (oldOptions.configFilePath !== options.configFilePath) || (oldOptions.baseUrl !== options.baseUrl) || (oldOptions.maxNodeModuleJsDepth !== options.maxNodeModuleJsDepth) || + !ts.arrayIsEqualTo(oldOptions.lib, options.lib) || !ts.arrayIsEqualTo(oldOptions.typeRoots, oldOptions.typeRoots) || !ts.arrayIsEqualTo(oldOptions.rootDirs, options.rootDirs) || !ts.equalOwnProperties(oldOptions.paths, options.paths)) { @@ -47446,16 +48116,19 @@ var ts; function getDiagnosticsProducingTypeChecker() { return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, true)); } + function dropDiagnosticsProducingTypeChecker() { + diagnosticsProducingTypeChecker = undefined; + } function getTypeChecker() { return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, false)); } - function emit(sourceFile, writeFileCallback, cancellationToken) { - return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken); }); + function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles) { + return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles); }); } function isEmitBlocked(emitFileName) { return hasEmitBlockingDiagnostics.contains(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName)); } - function emitWorker(program, sourceFile, writeFileCallback, cancellationToken) { + function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles) { var declarationDiagnostics = []; if (options.noEmit) { return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true }; @@ -47476,7 +48149,7 @@ var ts; } var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile); ts.performance.mark("beforeEmit"); - var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile); + var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, emitOnlyDtsFiles); ts.performance.mark("afterEmit"); ts.performance.measure("Emit", "beforeEmit", "afterEmit"); return emitResult; @@ -47991,7 +48664,6 @@ var ts; for (var i = 0; i < moduleNames.length; i++) { var resolution = resolutions[i]; ts.setResolvedModule(file, moduleNames[i], resolution); - var resolvedPath = resolution ? ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName) : undefined; var isFromNodeModulesSearch = resolution && resolution.isExternalLibraryImport; var isJsFileFromNodeModules = isFromNodeModulesSearch && ts.hasJavaScriptFileExtension(resolution.resolvedFileName); if (isFromNodeModulesSearch) { @@ -48003,7 +48675,7 @@ var ts; modulesWithElidedImports[file.path] = true; } else if (shouldAddFile) { - findSourceFile(resolution.resolvedFileName, resolvedPath, false, false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); + findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), false, false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); } if (isFromNodeModulesSearch) { currentNodeModulesDepth--; @@ -48017,8 +48689,8 @@ var ts; } function computeCommonSourceDirectory(sourceFiles) { var fileNames = []; - for (var _i = 0, sourceFiles_5 = sourceFiles; _i < sourceFiles_5.length; _i++) { - var file = sourceFiles_5[_i]; + for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { + var file = sourceFiles_6[_i]; if (!file.isDeclarationFile) { fileNames.push(file.fileName); } @@ -48029,8 +48701,8 @@ var ts; var allFilesBelongToPath = true; if (sourceFiles) { var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); - for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { - var sourceFile = sourceFiles_6[_i]; + for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { + var sourceFile = sourceFiles_7[_i]; if (!ts.isDeclarationFile(sourceFile)) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { @@ -48073,7 +48745,7 @@ var ts; if (!ts.hasProperty(options.paths, key)) { continue; } - if (!hasZeroOrOneAsteriskCharacter(key)) { + if (!ts.hasZeroOrOneAsteriskCharacter(key)) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Pattern_0_can_have_at_most_one_Asterisk_character, key)); } if (ts.isArray(options.paths[key])) { @@ -48084,7 +48756,7 @@ var ts; var subst = _a[_i]; var typeOfSubst = typeof subst; if (typeOfSubst === "string") { - if (!hasZeroOrOneAsteriskCharacter(subst)) { + if (!ts.hasZeroOrOneAsteriskCharacter(subst)) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character, subst, key)); } } @@ -48123,6 +48795,9 @@ var ts; if (options.lib && options.noLib) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "lib", "noLib")); } + if (options.noImplicitUseStrict && options.alwaysStrict) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noImplicitUseStrict", "alwaysStrict")); + } var languageVersion = options.target || 0; var outFile = options.outFile || options.out; var firstNonAmbientExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) && !ts.isDeclarationFile(f) ? f : undefined; }); @@ -48685,7 +49360,7 @@ var ts; case 97: return true; case 69: - return node.originalKeywordKind === 97 && node.parent.kind === 142; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 142; default: return false; } @@ -49258,7 +49933,6 @@ var ts; } ts.isInNonReferenceComment = isInNonReferenceComment; })(ts || (ts = {})); -var ts; (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 142; @@ -49481,7 +50155,7 @@ var ts; return ts.ensureScriptKind(fileName, scriptKind); } ts.getScriptKind = getScriptKind; - function parseAndReEmitConfigJSONFile(content) { + function sanitizeConfigFile(configFileName, content) { var options = { fileName: "config.js", compilerOptions: { @@ -49492,14 +50166,17 @@ var ts; }; var _a = ts.transpileModule("(" + content + ")", options), outputText = _a.outputText, diagnostics = _a.diagnostics; var trimmedOutput = outputText.trim(); - var configJsonObject = JSON.parse(trimmedOutput.substring(1, trimmedOutput.length - 2)); for (var _i = 0, diagnostics_2 = diagnostics; _i < diagnostics_2.length; _i++) { var diagnostic = diagnostics_2[_i]; diagnostic.start = diagnostic.start - 1; } - return { configJsonObject: configJsonObject, diagnostics: diagnostics }; + var _b = ts.parseConfigFileTextToJson(configFileName, trimmedOutput.substring(1, trimmedOutput.length - 2), false), config = _b.config, error = _b.error; + return { + configJsonObject: config || {}, + diagnostics: error ? ts.concatenate(diagnostics, [error]) : diagnostics + }; } - ts.parseAndReEmitConfigJSONFile = parseAndReEmitConfigJSONFile; + ts.sanitizeConfigFile = sanitizeConfigFile; })(ts || (ts = {})); var ts; (function (ts) { @@ -50701,8 +51378,7 @@ var ts; return; case 142: if (token.parent.name === token) { - var isThis_1 = token.kind === 69 && token.originalKeywordKind === 97; - return isThis_1 ? 3 : 17; + return ts.isThisIdentifier(token) ? 3 : 17; } return; } @@ -50743,13 +51419,13 @@ var ts; if (!completionData) { return undefined; } - var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isJsDocTagName = completionData.isJsDocTagName; + var symbols = completionData.symbols, isGlobalCompletion = completionData.isGlobalCompletion, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isJsDocTagName = completionData.isJsDocTagName; if (isJsDocTagName) { - return { isMemberCompletion: false, isNewIdentifierLocation: false, entries: ts.JsDoc.getAllJsDocCompletionEntries() }; + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: ts.JsDoc.getAllJsDocCompletionEntries() }; } var entries = []; if (ts.isSourceFileJavaScript(sourceFile)) { - var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, false); + var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, true); ts.addRange(entries, getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames)); } else { @@ -50773,17 +51449,17 @@ var ts; if (!isMemberCompletion && !isJsDocTagName) { ts.addRange(entries, keywordCompletions); } - return { isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation || ts.isSourceFileJavaScript(sourceFile), entries: entries }; + return { isGlobalCompletion: isGlobalCompletion, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames) { var entries = []; var nameTable = ts.getNameTable(sourceFile); - for (var name_46 in nameTable) { - if (nameTable[name_46] === position) { + for (var name_47 in nameTable) { + if (nameTable[name_47] === position) { continue; } - if (!uniqueNames[name_46]) { - uniqueNames[name_46] = name_46; - var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_46), compilerOptions.target, true); + if (!uniqueNames[name_47]) { + uniqueNames[name_47] = name_47; + var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_47), compilerOptions.target, true); if (displayName) { var entry = { name: displayName, @@ -50833,7 +51509,9 @@ var ts; if (!node || node.kind !== 9) { return undefined; } - if (node.parent.kind === 253 && node.parent.parent.kind === 171) { + if (node.parent.kind === 253 && + node.parent.parent.kind === 171 && + node.parent.name === node) { return getStringLiteralCompletionEntriesFromPropertyAssignment(node.parent); } else if (ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node) { @@ -50856,7 +51534,7 @@ var ts; if (type) { getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, element, false); if (entries.length) { - return { isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; + return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; } } } @@ -50872,7 +51550,7 @@ var ts; } } if (entries.length) { - return { isMemberCompletion: false, isNewIdentifierLocation: true, entries: entries }; + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: true, entries: entries }; } return undefined; } @@ -50882,7 +51560,7 @@ var ts; if (type) { getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, node, false); if (entries.length) { - return { isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; + return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; } } return undefined; @@ -50893,7 +51571,7 @@ var ts; var entries_2 = []; addStringLiteralCompletionsFromType(type, entries_2); if (entries_2.length) { - return { isMemberCompletion: false, isNewIdentifierLocation: false, entries: entries_2 }; + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: entries_2 }; } } return undefined; @@ -50934,6 +51612,7 @@ var ts; entries = getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, span); } return { + isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: true, entries: entries @@ -50964,13 +51643,15 @@ var ts; } function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, extensions, includeExtensions, span, exclude, result) { if (result === void 0) { result = []; } + if (fragment === undefined) { + fragment = ""; + } + fragment = ts.normalizeSlashes(fragment); fragment = ts.getDirectoryPath(fragment); - if (!fragment) { - fragment = "./"; - } - else { - fragment = ts.ensureTrailingDirectorySeparator(fragment); + if (fragment === "") { + fragment = "." + ts.directorySeparator; } + fragment = ts.ensureTrailingDirectorySeparator(fragment); var absolutePath = normalizeAndPreserveTrailingSlash(ts.isRootedDiskPath(fragment) ? fragment : ts.combinePaths(scriptPath, fragment)); var baseDirectory = ts.getDirectoryPath(absolutePath); var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); @@ -51126,6 +51807,12 @@ var ts; if (!range) { return undefined; } + var completionInfo = { + isGlobalCompletion: false, + isMemberCompletion: false, + isNewIdentifierLocation: true, + entries: [] + }; var text = sourceFile.text.substr(range.pos, position - range.pos); var match = tripleSlashDirectiveFragmentRegex.exec(text); if (match) { @@ -51133,22 +51820,16 @@ var ts; var kind = match[2]; var toComplete = match[3]; var scriptPath = ts.getDirectoryPath(sourceFile.path); - var entries_3; if (kind === "path") { var span_10 = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length); - entries_3 = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, ts.getSupportedExtensions(compilerOptions), true, span_10, sourceFile.path); + completionInfo.entries = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, ts.getSupportedExtensions(compilerOptions), true, span_10, sourceFile.path); } else { var span_11 = { start: range.pos + prefix.length, length: match[0].length - prefix.length }; - entries_3 = getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span_11); + completionInfo.entries = getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span_11); } - return { - isMemberCompletion: false, - isNewIdentifierLocation: true, - entries: entries_3 - }; } - return undefined; + return completionInfo; } function getCompletionEntriesFromTypings(host, options, scriptPath, span, result) { if (result === void 0) { result = []; } @@ -51347,7 +52028,7 @@ var ts; } } if (isJsDocTagName) { - return { symbols: undefined, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, isJsDocTagName: isJsDocTagName }; + return { symbols: undefined, isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, isJsDocTagName: isJsDocTagName }; } if (!insideJsDocTagExpression) { log("Returning an empty list because completion was inside a regular comment or plain text part of a JsDoc comment."); @@ -51399,6 +52080,7 @@ var ts; } } var semanticStart = ts.timestamp(); + var isGlobalCompletion = false; var isMemberCompletion; var isNewIdentifierLocation; var symbols = []; @@ -51429,10 +52111,12 @@ var ts; if (!tryGetGlobalSymbols()) { return undefined; } + isGlobalCompletion = true; } log("getCompletionData: Semantic work: " + (ts.timestamp() - semanticStart)); - return { symbols: symbols, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName: isJsDocTagName }; + return { symbols: symbols, isGlobalCompletion: isGlobalCompletion, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName: isJsDocTagName }; function getTypeScriptMemberSymbols() { + isGlobalCompletion = false; isMemberCompletion = true; isNewIdentifierLocation = false; if (node.kind === 69 || node.kind === 139 || node.kind === 172) { @@ -51483,6 +52167,7 @@ var ts; var attrsType = void 0; if ((jsxContainer.kind === 242) || (jsxContainer.kind === 243)) { attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); + isGlobalCompletion = false; if (attrsType) { symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); isMemberCompletion = true; @@ -51842,8 +52527,8 @@ var ts; if (element.getStart() <= position && position <= element.getEnd()) { continue; } - var name_47 = element.propertyName || element.name; - existingImportsOrExports[name_47.text] = true; + var name_48 = element.propertyName || element.name; + existingImportsOrExports[name_48.text] = true; } if (!ts.someProperties(existingImportsOrExports)) { return ts.filter(exportsOfModule, function (e) { return e.name !== "default"; }); @@ -51927,7 +52612,7 @@ var ts; sortText: "0" }); } - var tripleSlashDirectiveFragmentRegex = /^(\/\/\/\s* sourceFile.text.length) { return getBaseIndentation(options); } - if (options.IndentStyle === ts.IndentStyle.None) { + if (options.indentStyle === ts.IndentStyle.None) { return 0; } var precedingToken = ts.findPrecedingToken(position, sourceFile); @@ -58576,7 +59140,7 @@ var ts; return 0; } var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; - if (options.IndentStyle === ts.IndentStyle.Block) { + if (options.indentStyle === ts.IndentStyle.Block) { var current_1 = position; while (current_1 > 0) { var char = sourceFile.text.charCodeAt(current_1); @@ -58605,7 +59169,7 @@ var ts; indentationDelta = 0; } else { - indentationDelta = lineAtPosition !== currentStart.line ? options.IndentSize : 0; + indentationDelta = lineAtPosition !== currentStart.line ? options.indentSize : 0; } break; } @@ -58615,7 +59179,7 @@ var ts; } actualIndentation = getLineIndentationWhenExpressionIsInMultiLine(current, sourceFile, options); if (actualIndentation !== -1) { - return actualIndentation + options.IndentSize; + return actualIndentation + options.indentSize; } previous = current; current = current.parent; @@ -58626,15 +59190,15 @@ var ts; return getIndentationForNodeWorker(current, currentStart, undefined, indentationDelta, sourceFile, options); } SmartIndenter.getIndentation = getIndentation; - function getBaseIndentation(options) { - return options.BaseIndentSize || 0; - } - SmartIndenter.getBaseIndentation = getBaseIndentation; function getIndentationForNode(n, ignoreActualIndentationRange, sourceFile, options) { var start = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); return getIndentationForNodeWorker(n, start, ignoreActualIndentationRange, 0, sourceFile, options); } SmartIndenter.getIndentationForNode = getIndentationForNode; + function getBaseIndentation(options) { + return options.baseIndentSize || 0; + } + SmartIndenter.getBaseIndentation = getBaseIndentation; function getIndentationForNodeWorker(current, currentStart, ignoreActualIndentationRange, indentationDelta, sourceFile, options) { var parent = current.parent; var parentStart; @@ -58664,7 +59228,7 @@ var ts; } } if (shouldIndentChildNode(parent, current) && !parentAndChildShareLine) { - indentationDelta += options.IndentSize; + indentationDelta += options.indentSize; } current = parent; currentStart = parentStart; @@ -58842,7 +59406,7 @@ var ts; break; } if (ch === 9) { - column += options.TabSize + (column % options.TabSize); + column += options.tabSize + (column % options.tabSize); } else { column++; @@ -58940,11 +59504,116 @@ var ts; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var codefix; + (function (codefix) { + var codeFixes = ts.createMap(); + function registerCodeFix(action) { + ts.forEach(action.errorCodes, function (error) { + var fixes = codeFixes[error]; + if (!fixes) { + fixes = []; + codeFixes[error] = fixes; + } + fixes.push(action); + }); + } + codefix.registerCodeFix = registerCodeFix; + function getSupportedErrorCodes() { + return Object.keys(codeFixes); + } + codefix.getSupportedErrorCodes = getSupportedErrorCodes; + function getFixes(context) { + var fixes = codeFixes[context.errorCode]; + var allActions = []; + ts.forEach(fixes, function (f) { + var actions = f.getCodeActions(context); + if (actions && actions.length > 0) { + allActions = allActions.concat(actions); + } + }); + return allActions; + } + codefix.getFixes = getFixes; + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var codefix; + (function (codefix) { + function getOpenBraceEnd(constructor, sourceFile) { + return constructor.body.getFirstToken(sourceFile).getEnd(); + } + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call.code], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var token = ts.getTokenAtPosition(sourceFile, context.span.start); + if (token.kind !== 121) { + return undefined; + } + var newPosition = getOpenBraceEnd(token.parent, sourceFile); + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_missing_super_call), + changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "super();", span: { start: newPosition, length: 0 } }] }] + }]; + } + }); + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class.code], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var token = ts.getTokenAtPosition(sourceFile, context.span.start); + if (token.kind !== 97) { + return undefined; + } + var constructor = ts.getContainingFunction(token); + var superCall = findSuperCall(constructor.body); + if (!superCall) { + return undefined; + } + if (superCall.expression && superCall.expression.kind == 174) { + var arguments_1 = superCall.expression.arguments; + for (var i = 0; i < arguments_1.length; i++) { + if (arguments_1[i].expression === token) { + return undefined; + } + } + } + var newPosition = getOpenBraceEnd(constructor, sourceFile); + var changes = [{ + fileName: sourceFile.fileName, textChanges: [{ + newText: superCall.getText(sourceFile), + span: { start: newPosition, length: 0 } + }, + { + newText: "", + span: { start: superCall.getStart(sourceFile), length: superCall.getWidth(sourceFile) } + }] + }]; + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Make_super_call_the_first_statement_in_the_constructor), + changes: changes + }]; + function findSuperCall(n) { + if (n.kind === 202 && ts.isSuperCall(n.expression)) { + return n; + } + if (ts.isFunctionLike(n)) { + return undefined; + } + return ts.forEachChild(n, findSuperCall); + } + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; (function (ts) { ts.servicesVersion = "0.5"; function createNode(kind, pos, end, parent) { var node = kind >= 139 ? new NodeObject(kind, pos, end) : - kind === 69 ? new IdentifierObject(kind, pos, end) : + kind === 69 ? new IdentifierObject(69, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; return node; @@ -59167,15 +59836,16 @@ var ts; var TokenObject = (function (_super) { __extends(TokenObject, _super); function TokenObject(kind, pos, end) { - _super.call(this, pos, end); - this.kind = kind; + var _this = _super.call(this, pos, end) || this; + _this.kind = kind; + return _this; } return TokenObject; }(TokenOrIdentifierObject)); var IdentifierObject = (function (_super) { __extends(IdentifierObject, _super); function IdentifierObject(kind, pos, end) { - _super.call(this, pos, end); + return _super.call(this, pos, end) || this; } return IdentifierObject; }(TokenOrIdentifierObject)); @@ -59249,7 +59919,7 @@ var ts; var SourceFileObject = (function (_super) { __extends(SourceFileObject, _super); function SourceFileObject(kind, pos, end) { - _super.call(this, kind, pos, end); + return _super.call(this, kind, pos, end) || this; } SourceFileObject.prototype.update = function (newText, textChangeRange) { return ts.updateSourceFile(this, newText, textChangeRange); @@ -59406,6 +60076,30 @@ var ts; getSignatureConstructor: function () { return SignatureObject; } }; } + function toEditorSettings(optionsAsMap) { + var allPropertiesAreCamelCased = true; + for (var key in optionsAsMap) { + if (ts.hasProperty(optionsAsMap, key) && !isCamelCase(key)) { + allPropertiesAreCamelCased = false; + break; + } + } + if (allPropertiesAreCamelCased) { + return optionsAsMap; + } + var settings = {}; + for (var key in optionsAsMap) { + if (ts.hasProperty(optionsAsMap, key)) { + var newKey = isCamelCase(key) ? key : key.charAt(0).toLowerCase() + key.substr(1); + settings[newKey] = optionsAsMap[key]; + } + } + return settings; + } + ts.toEditorSettings = toEditorSettings; + function isCamelCase(s) { + return !s.length || s.charAt(0) === s.charAt(0).toLowerCase(); + } function displayPartsToString(displayParts) { if (displayParts) { return ts.map(displayParts, function (displayPart) { return displayPart.text; }).join(""); @@ -59420,6 +60114,10 @@ var ts; }; } ts.getDefaultCompilerOptions = getDefaultCompilerOptions; + function getSupportedCodeFixes() { + return ts.codefix.getSupportedErrorCodes(); + } + ts.getSupportedCodeFixes = getSupportedCodeFixes; var HostCache = (function () { function HostCache(host, getCanonicalFileName) { this.host = host; @@ -59583,7 +60281,8 @@ var ts; var ruleProvider; var program; var lastProjectVersion; - var useCaseSensitivefileNames = false; + var lastTypesRootVersion = 0; + var useCaseSensitivefileNames = host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(); var cancellationToken = new CancellationTokenObject(host.getCancellationToken && host.getCancellationToken()); var currentDirectory = host.getCurrentDirectory(); if (!ts.localizedDiagnosticMessages && host.getLocalizedDiagnosticMessages) { @@ -59619,6 +60318,12 @@ var ts; lastProjectVersion = hostProjectVersion; } } + var typeRootsVersion = host.getTypeRootsVersion ? host.getTypeRootsVersion() : 0; + if (lastTypesRootVersion !== typeRootsVersion) { + log("TypeRoots version has changed; provide new program"); + program = undefined; + lastTypesRootVersion = typeRootsVersion; + } var hostCache = new HostCache(host, getCanonicalFileName); if (programUpToDate()) { return; @@ -59878,12 +60583,12 @@ var ts; synchronizeHostData(); return ts.FindAllReferences.findReferencedSymbols(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position, findInStrings, findInComments); } - function getNavigateToItems(searchValue, maxResultCount, fileName) { + function getNavigateToItems(searchValue, maxResultCount, fileName, excludeDtsFiles) { synchronizeHostData(); var sourceFiles = fileName ? [getValidSourceFile(fileName)] : program.getSourceFiles(); - return ts.NavigateTo.getNavigateToItems(sourceFiles, program.getTypeChecker(), cancellationToken, searchValue, maxResultCount); + return ts.NavigateTo.getNavigateToItems(sourceFiles, program.getTypeChecker(), cancellationToken, searchValue, maxResultCount, excludeDtsFiles); } - function getEmitOutput(fileName) { + function getEmitOutput(fileName, emitOnlyDtsFiles) { synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); var outputFiles = []; @@ -59894,7 +60599,7 @@ var ts; text: data }); } - var emitOutput = program.emit(sourceFile, writeFile, cancellationToken); + var emitOutput = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles); return { outputFiles: outputFiles, emitSkipped: emitOutput.emitSkipped @@ -59957,14 +60662,26 @@ var ts; return ts.BreakpointResolver.spanInSourceFileAtLocation(sourceFile, position); } function getNavigationBarItems(fileName) { - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - return ts.NavigationBar.getNavigationBarItems(sourceFile); + return ts.NavigationBar.getNavigationBarItems(syntaxTreeCache.getCurrentSourceFile(fileName)); + } + function getNavigationTree(fileName) { + return ts.NavigationBar.getNavigationTree(syntaxTreeCache.getCurrentSourceFile(fileName)); + } + function isTsOrTsxFile(fileName) { + var kind = ts.getScriptKind(fileName, host); + return kind === 3 || kind === 4; } function getSemanticClassifications(fileName, span) { + if (!isTsOrTsxFile(fileName)) { + return []; + } synchronizeHostData(); return ts.getSemanticClassifications(program.getTypeChecker(), cancellationToken, getValidSourceFile(fileName), program.getClassifiableNames(), span); } function getEncodedSemanticClassifications(fileName, span) { + if (!isTsOrTsxFile(fileName)) { + return { spans: [], endOfLineState: 0 }; + } synchronizeHostData(); return ts.getEncodedSemanticClassifications(program.getTypeChecker(), cancellationToken, getValidSourceFile(fileName), program.getClassifiableNames(), span); } @@ -60020,34 +60737,60 @@ var ts; } function getIndentationAtPosition(fileName, position, editorOptions) { var start = ts.timestamp(); + var settings = toEditorSettings(editorOptions); var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); log("getIndentationAtPosition: getCurrentSourceFile: " + (ts.timestamp() - start)); start = ts.timestamp(); - var result = ts.formatting.SmartIndenter.getIndentation(position, sourceFile, editorOptions); + var result = ts.formatting.SmartIndenter.getIndentation(position, sourceFile, settings); log("getIndentationAtPosition: computeIndentation : " + (ts.timestamp() - start)); return result; } function getFormattingEditsForRange(fileName, start, end, options) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - return ts.formatting.formatSelection(start, end, sourceFile, getRuleProvider(options), options); + var settings = toEditorSettings(options); + return ts.formatting.formatSelection(start, end, sourceFile, getRuleProvider(settings), settings); } function getFormattingEditsForDocument(fileName, options) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - return ts.formatting.formatDocument(sourceFile, getRuleProvider(options), options); + var settings = toEditorSettings(options); + return ts.formatting.formatDocument(sourceFile, getRuleProvider(settings), settings); } function getFormattingEditsAfterKeystroke(fileName, position, key, options) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + var settings = toEditorSettings(options); if (key === "}") { - return ts.formatting.formatOnClosingCurly(position, sourceFile, getRuleProvider(options), options); + return ts.formatting.formatOnClosingCurly(position, sourceFile, getRuleProvider(settings), settings); } else if (key === ";") { - return ts.formatting.formatOnSemicolon(position, sourceFile, getRuleProvider(options), options); + return ts.formatting.formatOnSemicolon(position, sourceFile, getRuleProvider(settings), settings); } else if (key === "\n") { - return ts.formatting.formatOnEnter(position, sourceFile, getRuleProvider(options), options); + return ts.formatting.formatOnEnter(position, sourceFile, getRuleProvider(settings), settings); } return []; } + function getCodeFixesAtPosition(fileName, start, end, errorCodes) { + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + var span = { start: start, length: end - start }; + var newLineChar = ts.getNewLineOrDefaultFromHost(host); + var allFixes = []; + ts.forEach(errorCodes, function (error) { + cancellationToken.throwIfCancellationRequested(); + var context = { + errorCode: error, + sourceFile: sourceFile, + span: span, + program: program, + newLineCharacter: newLineChar + }; + var fixes = ts.codefix.getFixes(context); + if (fixes) { + allFixes = allFixes.concat(fixes); + } + }); + return allFixes; + } function getDocCommentTemplateAtPosition(fileName, position) { return ts.JsDoc.getDocCommentTemplateAtPosition(ts.getNewLineOrDefaultFromHost(host), syntaxTreeCache.getCurrentSourceFile(fileName), position); } @@ -60159,6 +60902,7 @@ var ts; getRenameInfo: getRenameInfo, findRenameLocations: findRenameLocations, getNavigationBarItems: getNavigationBarItems, + getNavigationTree: getNavigationTree, getOutliningSpans: getOutliningSpans, getTodoComments: getTodoComments, getBraceMatchingAtPosition: getBraceMatchingAtPosition, @@ -60168,6 +60912,7 @@ var ts; getFormattingEditsAfterKeystroke: getFormattingEditsAfterKeystroke, getDocCommentTemplateAtPosition: getDocCommentTemplateAtPosition, isValidBraceCompletionAtPosition: isValidBraceCompletionAtPosition, + getCodeFixesAtPosition: getCodeFixesAtPosition, getEmitOutput: getEmitOutput, getNonBoundSourceFile: getNonBoundSourceFile, getSourceFile: getSourceFile, @@ -60233,43 +60978,2344 @@ var ts; (function (ts) { var server; (function (server) { - var spaceCache = []; - function generateSpaces(n) { - if (!spaceCache[n]) { - var strBuilder = ""; - for (var i = 0; i < n; i++) { - strBuilder += " "; - } - spaceCache[n] = strBuilder; + var ScriptInfo = (function () { + function ScriptInfo(host, fileName, content, scriptKind, isOpen, hasMixedContent) { + if (isOpen === void 0) { isOpen = false; } + if (hasMixedContent === void 0) { hasMixedContent = false; } + this.host = host; + this.fileName = fileName; + this.scriptKind = scriptKind; + this.isOpen = isOpen; + this.hasMixedContent = hasMixedContent; + this.containingProjects = []; + this.path = ts.toPath(fileName, host.getCurrentDirectory(), ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames)); + this.svc = server.ScriptVersionCache.fromString(host, content); + this.scriptKind = scriptKind + ? scriptKind + : ts.getScriptKindFromFileName(fileName); } - return spaceCache[n]; + ScriptInfo.prototype.getFormatCodeSettings = function () { + return this.formatCodeSettings; + }; + ScriptInfo.prototype.attachToProject = function (project) { + var isNew = !this.isAttached(project); + if (isNew) { + this.containingProjects.push(project); + } + return isNew; + }; + ScriptInfo.prototype.isAttached = function (project) { + switch (this.containingProjects.length) { + case 0: return false; + case 1: return this.containingProjects[0] === project; + case 2: return this.containingProjects[0] === project || this.containingProjects[1] === project; + default: return ts.contains(this.containingProjects, project); + } + }; + ScriptInfo.prototype.detachFromProject = function (project) { + switch (this.containingProjects.length) { + case 0: + return; + case 1: + if (this.containingProjects[0] === project) { + this.containingProjects.pop(); + } + break; + case 2: + if (this.containingProjects[0] === project) { + this.containingProjects[0] = this.containingProjects.pop(); + } + else if (this.containingProjects[1] === project) { + this.containingProjects.pop(); + } + break; + default: + server.removeItemFromSet(this.containingProjects, project); + break; + } + }; + ScriptInfo.prototype.detachAllProjects = function () { + for (var _i = 0, _a = this.containingProjects; _i < _a.length; _i++) { + var p = _a[_i]; + p.removeFile(this, false); + } + this.containingProjects.length = 0; + }; + ScriptInfo.prototype.getDefaultProject = function () { + if (this.containingProjects.length === 0) { + return server.Errors.ThrowNoProject(); + } + ts.Debug.assert(this.containingProjects.length !== 0); + return this.containingProjects[0]; + }; + ScriptInfo.prototype.setFormatOptions = function (formatSettings) { + if (formatSettings) { + if (!this.formatCodeSettings) { + this.formatCodeSettings = server.getDefaultFormatCodeSettings(this.host); + } + server.mergeMaps(this.formatCodeSettings, formatSettings); + } + }; + ScriptInfo.prototype.setWatcher = function (watcher) { + this.stopWatcher(); + this.fileWatcher = watcher; + }; + ScriptInfo.prototype.stopWatcher = function () { + if (this.fileWatcher) { + this.fileWatcher.close(); + this.fileWatcher = undefined; + } + }; + ScriptInfo.prototype.getLatestVersion = function () { + return this.svc.latestVersion().toString(); + }; + ScriptInfo.prototype.reload = function (script) { + this.svc.reload(script); + this.markContainingProjectsAsDirty(); + }; + ScriptInfo.prototype.saveTo = function (fileName) { + var snap = this.snap(); + this.host.writeFile(fileName, snap.getText(0, snap.getLength())); + }; + ScriptInfo.prototype.reloadFromFile = function () { + if (this.hasMixedContent) { + this.reload(""); + } + else { + this.svc.reloadFromFile(this.fileName); + this.markContainingProjectsAsDirty(); + } + }; + ScriptInfo.prototype.snap = function () { + return this.svc.getSnapshot(); + }; + ScriptInfo.prototype.getLineInfo = function (line) { + var snap = this.snap(); + return snap.index.lineNumberToInfo(line); + }; + ScriptInfo.prototype.editContent = function (start, end, newText) { + this.svc.edit(start, end - start, newText); + this.markContainingProjectsAsDirty(); + }; + ScriptInfo.prototype.markContainingProjectsAsDirty = function () { + for (var _i = 0, _a = this.containingProjects; _i < _a.length; _i++) { + var p = _a[_i]; + p.markAsDirty(); + } + }; + ScriptInfo.prototype.lineToTextSpan = function (line) { + var index = this.snap().index; + var lineInfo = index.lineNumberToInfo(line + 1); + var len; + if (lineInfo.leaf) { + len = lineInfo.leaf.text.length; + } + else { + var nextLineInfo = index.lineNumberToInfo(line + 2); + len = nextLineInfo.offset - lineInfo.offset; + } + return ts.createTextSpan(lineInfo.offset, len); + }; + ScriptInfo.prototype.lineOffsetToPosition = function (line, offset) { + var index = this.snap().index; + var lineInfo = index.lineNumberToInfo(line); + return (lineInfo.offset + offset - 1); + }; + ScriptInfo.prototype.positionToLineOffset = function (position) { + var index = this.snap().index; + var lineOffset = index.charOffsetToLineNumberAndPos(position); + return { line: lineOffset.line, offset: lineOffset.offset + 1 }; + }; + return ScriptInfo; + }()); + server.ScriptInfo = ScriptInfo; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + var LSHost = (function () { + function LSHost(host, project, cancellationToken) { + var _this = this; + this.host = host; + this.project = project; + this.cancellationToken = cancellationToken; + this.getCanonicalFileName = ts.createGetCanonicalFileName(this.host.useCaseSensitiveFileNames); + this.resolvedModuleNames = ts.createFileMap(); + this.resolvedTypeReferenceDirectives = ts.createFileMap(); + if (host.trace) { + this.trace = function (s) { return host.trace(s); }; + } + this.resolveModuleName = function (moduleName, containingFile, compilerOptions, host) { + var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host); + if (primaryResult.resolvedModule) { + if (ts.fileExtensionIsAny(primaryResult.resolvedModule.resolvedFileName, ts.supportedTypeScriptExtensions)) { + return primaryResult; + } + } + var secondaryLookupFailedLookupLocations = []; + var globalCache = _this.project.projectService.typingsInstaller.globalTypingsCacheLocation; + if (_this.project.getTypingOptions().enableAutoDiscovery && globalCache) { + var traceEnabled = ts.isTraceEnabled(compilerOptions, host); + if (traceEnabled) { + ts.trace(host, ts.Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2, _this.project.getProjectName(), moduleName, globalCache); + } + var state = { compilerOptions: compilerOptions, host: host, skipTsx: false, traceEnabled: traceEnabled }; + var resolvedName = ts.loadModuleFromNodeModules(moduleName, globalCache, secondaryLookupFailedLookupLocations, state, true); + if (resolvedName) { + return ts.createResolvedModule(resolvedName, true, primaryResult.failedLookupLocations.concat(secondaryLookupFailedLookupLocations)); + } + } + if (!primaryResult.resolvedModule && secondaryLookupFailedLookupLocations.length) { + primaryResult.failedLookupLocations = primaryResult.failedLookupLocations.concat(secondaryLookupFailedLookupLocations); + } + return primaryResult; + }; + } + LSHost.prototype.resolveNamesWithLocalCache = function (names, containingFile, cache, loader, getResult) { + var path = ts.toPath(containingFile, this.host.getCurrentDirectory(), this.getCanonicalFileName); + var currentResolutionsInFile = cache.get(path); + var newResolutions = ts.createMap(); + var resolvedModules = []; + var compilerOptions = this.getCompilationSettings(); + var lastDeletedFileName = this.project.projectService.lastDeletedFile && this.project.projectService.lastDeletedFile.fileName; + for (var _i = 0, names_3 = names; _i < names_3.length; _i++) { + var name_52 = names_3[_i]; + var resolution = newResolutions[name_52]; + if (!resolution) { + var existingResolution = currentResolutionsInFile && currentResolutionsInFile[name_52]; + if (moduleResolutionIsValid(existingResolution)) { + resolution = existingResolution; + } + else { + newResolutions[name_52] = resolution = loader(name_52, containingFile, compilerOptions, this); + } + } + ts.Debug.assert(resolution !== undefined); + resolvedModules.push(getResult(resolution)); + } + cache.set(path, newResolutions); + return resolvedModules; + function moduleResolutionIsValid(resolution) { + if (!resolution) { + return false; + } + var result = getResult(resolution); + if (result) { + if (result.resolvedFileName && result.resolvedFileName === lastDeletedFileName) { + return false; + } + return true; + } + return resolution.failedLookupLocations.length === 0; + } + }; + LSHost.prototype.getProjectVersion = function () { + return this.project.getProjectVersion(); + }; + LSHost.prototype.getCompilationSettings = function () { + return this.compilationSettings; + }; + LSHost.prototype.useCaseSensitiveFileNames = function () { + return this.host.useCaseSensitiveFileNames; + }; + LSHost.prototype.getCancellationToken = function () { + return this.cancellationToken; + }; + LSHost.prototype.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile) { + return this.resolveNamesWithLocalCache(typeDirectiveNames, containingFile, this.resolvedTypeReferenceDirectives, ts.resolveTypeReferenceDirective, function (m) { return m.resolvedTypeReferenceDirective; }); + }; + LSHost.prototype.resolveModuleNames = function (moduleNames, containingFile) { + return this.resolveNamesWithLocalCache(moduleNames, containingFile, this.resolvedModuleNames, this.resolveModuleName, function (m) { return m.resolvedModule; }); + }; + LSHost.prototype.getDefaultLibFileName = function () { + var nodeModuleBinDir = ts.getDirectoryPath(ts.normalizePath(this.host.getExecutingFilePath())); + return ts.combinePaths(nodeModuleBinDir, ts.getDefaultLibFileName(this.compilationSettings)); + }; + LSHost.prototype.getScriptSnapshot = function (filename) { + var scriptInfo = this.project.getScriptInfoLSHost(filename); + if (scriptInfo) { + return scriptInfo.snap(); + } + }; + LSHost.prototype.getScriptFileNames = function () { + return this.project.getRootFilesLSHost(); + }; + LSHost.prototype.getTypeRootsVersion = function () { + return this.project.typesVersion; + }; + LSHost.prototype.getScriptKind = function (fileName) { + var info = this.project.getScriptInfoLSHost(fileName); + return info && info.scriptKind; + }; + LSHost.prototype.getScriptVersion = function (filename) { + var info = this.project.getScriptInfoLSHost(filename); + return info && info.getLatestVersion(); + }; + LSHost.prototype.getCurrentDirectory = function () { + return this.host.getCurrentDirectory(); + }; + LSHost.prototype.resolvePath = function (path) { + return this.host.resolvePath(path); + }; + LSHost.prototype.fileExists = function (path) { + return this.host.fileExists(path); + }; + LSHost.prototype.readFile = function (fileName) { + return this.host.readFile(fileName); + }; + LSHost.prototype.directoryExists = function (path) { + return this.host.directoryExists(path); + }; + LSHost.prototype.readDirectory = function (path, extensions, exclude, include) { + return this.host.readDirectory(path, extensions, exclude, include); + }; + LSHost.prototype.getDirectories = function (path) { + return this.host.getDirectories(path); + }; + LSHost.prototype.notifyFileRemoved = function (info) { + this.resolvedModuleNames.remove(info.path); + this.resolvedTypeReferenceDirectives.remove(info.path); + }; + LSHost.prototype.setCompilationSettings = function (opt) { + this.compilationSettings = opt; + this.resolvedModuleNames.clear(); + this.resolvedTypeReferenceDirectives.clear(); + }; + return LSHost; + }()); + server.LSHost = LSHost; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + server.nullTypingsInstaller = { + enqueueInstallTypingsRequest: function () { }, + attach: function (projectService) { }, + onProjectClosed: function (p) { }, + globalTypingsCacheLocation: undefined + }; + var TypingsCacheEntry = (function () { + function TypingsCacheEntry() { + } + return TypingsCacheEntry; + }()); + function setIsEqualTo(arr1, arr2) { + if (arr1 === arr2) { + return true; + } + if ((arr1 || server.emptyArray).length === 0 && (arr2 || server.emptyArray).length === 0) { + return true; + } + var set = ts.createMap(); + var unique = 0; + for (var _i = 0, arr1_1 = arr1; _i < arr1_1.length; _i++) { + var v = arr1_1[_i]; + if (set[v] !== true) { + set[v] = true; + unique++; + } + } + for (var _a = 0, arr2_1 = arr2; _a < arr2_1.length; _a++) { + var v = arr2_1[_a]; + if (!ts.hasProperty(set, v)) { + return false; + } + if (set[v] === true) { + set[v] = false; + unique--; + } + } + return unique === 0; } - server.generateSpaces = generateSpaces; - function generateIndentString(n, editorOptions) { - if (editorOptions.ConvertTabsToSpaces) { - return generateSpaces(n); + function typingOptionsChanged(opt1, opt2) { + return opt1.enableAutoDiscovery !== opt2.enableAutoDiscovery || + !setIsEqualTo(opt1.include, opt2.include) || + !setIsEqualTo(opt1.exclude, opt2.exclude); + } + function compilerOptionsChanged(opt1, opt2) { + return opt1.allowJs != opt2.allowJs; + } + function toTypingsArray(arr) { + arr.sort(); + return arr; + } + var TypingsCache = (function () { + function TypingsCache(installer) { + this.installer = installer; + this.perProjectCache = ts.createMap(); } - else { - var result = ""; - for (var i = 0; i < Math.floor(n / editorOptions.TabSize); i++) { - result += "\t"; + TypingsCache.prototype.getTypingsForProject = function (project, forceRefresh) { + var typingOptions = project.getTypingOptions(); + if (!typingOptions || !typingOptions.enableAutoDiscovery) { + return server.emptyArray; } - for (var i = 0; i < n % editorOptions.TabSize; i++) { - result += " "; + var entry = this.perProjectCache[project.getProjectName()]; + var result = entry ? entry.typings : server.emptyArray; + if (forceRefresh || !entry || typingOptionsChanged(typingOptions, entry.typingOptions) || compilerOptionsChanged(project.getCompilerOptions(), entry.compilerOptions)) { + this.perProjectCache[project.getProjectName()] = { + compilerOptions: project.getCompilerOptions(), + typingOptions: typingOptions, + typings: result, + poisoned: true + }; + this.installer.enqueueInstallTypingsRequest(project, typingOptions); } return result; + }; + TypingsCache.prototype.invalidateCachedTypingsForProject = function (project) { + var typingOptions = project.getTypingOptions(); + if (!typingOptions.enableAutoDiscovery) { + return; + } + this.installer.enqueueInstallTypingsRequest(project, typingOptions); + }; + TypingsCache.prototype.updateTypingsForProject = function (projectName, compilerOptions, typingOptions, newTypings) { + this.perProjectCache[projectName] = { + compilerOptions: compilerOptions, + typingOptions: typingOptions, + typings: toTypingsArray(newTypings), + poisoned: false + }; + }; + TypingsCache.prototype.onProjectClosed = function (project) { + delete this.perProjectCache[project.getProjectName()]; + this.installer.onProjectClosed(project); + }; + return TypingsCache; + }()); + server.TypingsCache = TypingsCache; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + var crypto = require("crypto"); + function shouldEmitFile(scriptInfo) { + return !scriptInfo.hasMixedContent; + } + server.shouldEmitFile = shouldEmitFile; + var BuilderFileInfo = (function () { + function BuilderFileInfo(scriptInfo, project) { + this.scriptInfo = scriptInfo; + this.project = project; + } + BuilderFileInfo.prototype.isExternalModuleOrHasOnlyAmbientExternalModules = function () { + var sourceFile = this.getSourceFile(); + return ts.isExternalModule(sourceFile) || this.containsOnlyAmbientModules(sourceFile); + }; + BuilderFileInfo.prototype.containsOnlyAmbientModules = function (sourceFile) { + for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { + var statement = _a[_i]; + if (statement.kind !== 225 || statement.name.kind !== 9) { + return false; + } + } + return true; + }; + BuilderFileInfo.prototype.computeHash = function (text) { + return crypto.createHash("md5") + .update(text) + .digest("base64"); + }; + BuilderFileInfo.prototype.getSourceFile = function () { + return this.project.getSourceFile(this.scriptInfo.path); + }; + BuilderFileInfo.prototype.updateShapeSignature = function () { + var sourceFile = this.getSourceFile(); + if (!sourceFile) { + return true; + } + var lastSignature = this.lastCheckedShapeSignature; + if (sourceFile.isDeclarationFile) { + this.lastCheckedShapeSignature = this.computeHash(sourceFile.text); + } + else { + var emitOutput = this.project.getFileEmitOutput(this.scriptInfo, true); + if (emitOutput.outputFiles && emitOutput.outputFiles.length > 0) { + this.lastCheckedShapeSignature = this.computeHash(emitOutput.outputFiles[0].text); + } + } + return !lastSignature || this.lastCheckedShapeSignature !== lastSignature; + }; + return BuilderFileInfo; + }()); + server.BuilderFileInfo = BuilderFileInfo; + var AbstractBuilder = (function () { + function AbstractBuilder(project, ctor) { + this.project = project; + this.ctor = ctor; + this.fileInfos = ts.createFileMap(); + } + AbstractBuilder.prototype.getFileInfo = function (path) { + return this.fileInfos.get(path); + }; + AbstractBuilder.prototype.getOrCreateFileInfo = function (path) { + var fileInfo = this.getFileInfo(path); + if (!fileInfo) { + var scriptInfo = this.project.getScriptInfo(path); + fileInfo = new this.ctor(scriptInfo, this.project); + this.setFileInfo(path, fileInfo); + } + return fileInfo; + }; + AbstractBuilder.prototype.getFileInfoPaths = function () { + return this.fileInfos.getKeys(); + }; + AbstractBuilder.prototype.setFileInfo = function (path, info) { + this.fileInfos.set(path, info); + }; + AbstractBuilder.prototype.removeFileInfo = function (path) { + this.fileInfos.remove(path); + }; + AbstractBuilder.prototype.forEachFileInfo = function (action) { + this.fileInfos.forEachValue(function (path, value) { return action(value); }); + }; + AbstractBuilder.prototype.emitFile = function (scriptInfo, writeFile) { + var fileInfo = this.getFileInfo(scriptInfo.path); + if (!fileInfo) { + return false; + } + var _a = this.project.getFileEmitOutput(fileInfo.scriptInfo, false), emitSkipped = _a.emitSkipped, outputFiles = _a.outputFiles; + if (!emitSkipped) { + var projectRootPath = this.project.getProjectRootPath(); + for (var _i = 0, outputFiles_1 = outputFiles; _i < outputFiles_1.length; _i++) { + var outputFile = outputFiles_1[_i]; + var outputFileAbsoluteFileName = ts.getNormalizedAbsolutePath(outputFile.name, projectRootPath ? projectRootPath : ts.getDirectoryPath(scriptInfo.fileName)); + writeFile(outputFileAbsoluteFileName, outputFile.text, outputFile.writeByteOrderMark); + } + } + return !emitSkipped; + }; + return AbstractBuilder; + }()); + var NonModuleBuilder = (function (_super) { + __extends(NonModuleBuilder, _super); + function NonModuleBuilder(project) { + var _this = _super.call(this, project, BuilderFileInfo) || this; + _this.project = project; + return _this; + } + NonModuleBuilder.prototype.onProjectUpdateGraph = function () { + }; + NonModuleBuilder.prototype.getFilesAffectedBy = function (scriptInfo) { + var info = this.getOrCreateFileInfo(scriptInfo.path); + var singleFileResult = scriptInfo.hasMixedContent ? [] : [scriptInfo.fileName]; + if (info.updateShapeSignature()) { + var options = this.project.getCompilerOptions(); + if (options && (options.out || options.outFile)) { + return singleFileResult; + } + return this.project.getAllEmittableFiles(); + } + return singleFileResult; + }; + return NonModuleBuilder; + }(AbstractBuilder)); + var ModuleBuilderFileInfo = (function (_super) { + __extends(ModuleBuilderFileInfo, _super); + function ModuleBuilderFileInfo() { + var _this = _super.apply(this, arguments) || this; + _this.references = []; + _this.referencedBy = []; + return _this; + } + ModuleBuilderFileInfo.compareFileInfos = function (lf, rf) { + var l = lf.scriptInfo.fileName; + var r = rf.scriptInfo.fileName; + return (l < r ? -1 : (l > r ? 1 : 0)); + }; + ; + ModuleBuilderFileInfo.addToReferenceList = function (array, fileInfo) { + if (array.length === 0) { + array.push(fileInfo); + return; + } + var insertIndex = ts.binarySearch(array, fileInfo, ModuleBuilderFileInfo.compareFileInfos); + if (insertIndex < 0) { + array.splice(~insertIndex, 0, fileInfo); + } + }; + ModuleBuilderFileInfo.removeFromReferenceList = function (array, fileInfo) { + if (!array || array.length === 0) { + return; + } + if (array[0] === fileInfo) { + array.splice(0, 1); + return; + } + var removeIndex = ts.binarySearch(array, fileInfo, ModuleBuilderFileInfo.compareFileInfos); + if (removeIndex >= 0) { + array.splice(removeIndex, 1); + } + }; + ModuleBuilderFileInfo.prototype.addReferencedBy = function (fileInfo) { + ModuleBuilderFileInfo.addToReferenceList(this.referencedBy, fileInfo); + }; + ModuleBuilderFileInfo.prototype.removeReferencedBy = function (fileInfo) { + ModuleBuilderFileInfo.removeFromReferenceList(this.referencedBy, fileInfo); + }; + ModuleBuilderFileInfo.prototype.removeFileReferences = function () { + for (var _i = 0, _a = this.references; _i < _a.length; _i++) { + var reference = _a[_i]; + reference.removeReferencedBy(this); + } + this.references = []; + }; + return ModuleBuilderFileInfo; + }(BuilderFileInfo)); + var ModuleBuilder = (function (_super) { + __extends(ModuleBuilder, _super); + function ModuleBuilder(project) { + var _this = _super.call(this, project, ModuleBuilderFileInfo) || this; + _this.project = project; + return _this; + } + ModuleBuilder.prototype.getReferencedFileInfos = function (fileInfo) { + var _this = this; + if (!fileInfo.isExternalModuleOrHasOnlyAmbientExternalModules()) { + return []; + } + var referencedFilePaths = this.project.getReferencedFiles(fileInfo.scriptInfo.path); + if (referencedFilePaths.length > 0) { + return ts.map(referencedFilePaths, function (f) { return _this.getOrCreateFileInfo(f); }).sort(ModuleBuilderFileInfo.compareFileInfos); + } + return []; + }; + ModuleBuilder.prototype.onProjectUpdateGraph = function () { + this.ensureProjectDependencyGraphUpToDate(); + }; + ModuleBuilder.prototype.ensureProjectDependencyGraphUpToDate = function () { + var _this = this; + if (!this.projectVersionForDependencyGraph || this.project.getProjectVersion() !== this.projectVersionForDependencyGraph) { + var currentScriptInfos = this.project.getScriptInfos(); + for (var _i = 0, currentScriptInfos_1 = currentScriptInfos; _i < currentScriptInfos_1.length; _i++) { + var scriptInfo = currentScriptInfos_1[_i]; + var fileInfo = this.getOrCreateFileInfo(scriptInfo.path); + this.updateFileReferences(fileInfo); + } + this.forEachFileInfo(function (fileInfo) { + if (!_this.project.containsScriptInfo(fileInfo.scriptInfo)) { + fileInfo.removeFileReferences(); + _this.removeFileInfo(fileInfo.scriptInfo.path); + } + }); + this.projectVersionForDependencyGraph = this.project.getProjectVersion(); + } + }; + ModuleBuilder.prototype.updateFileReferences = function (fileInfo) { + if (fileInfo.scriptVersionForReferences === fileInfo.scriptInfo.getLatestVersion()) { + return; + } + var newReferences = this.getReferencedFileInfos(fileInfo); + var oldReferences = fileInfo.references; + var oldIndex = 0; + var newIndex = 0; + while (oldIndex < oldReferences.length && newIndex < newReferences.length) { + var oldReference = oldReferences[oldIndex]; + var newReference = newReferences[newIndex]; + var compare = ModuleBuilderFileInfo.compareFileInfos(oldReference, newReference); + if (compare < 0) { + oldReference.removeReferencedBy(fileInfo); + oldIndex++; + } + else if (compare > 0) { + newReference.addReferencedBy(fileInfo); + newIndex++; + } + else { + oldIndex++; + newIndex++; + } + } + for (var i = oldIndex; i < oldReferences.length; i++) { + oldReferences[i].removeReferencedBy(fileInfo); + } + for (var i = newIndex; i < newReferences.length; i++) { + newReferences[i].addReferencedBy(fileInfo); + } + fileInfo.references = newReferences; + fileInfo.scriptVersionForReferences = fileInfo.scriptInfo.getLatestVersion(); + }; + ModuleBuilder.prototype.getFilesAffectedBy = function (scriptInfo) { + this.ensureProjectDependencyGraphUpToDate(); + var singleFileResult = scriptInfo.hasMixedContent ? [] : [scriptInfo.fileName]; + var fileInfo = this.getFileInfo(scriptInfo.path); + if (!fileInfo || !fileInfo.updateShapeSignature()) { + return singleFileResult; + } + if (!fileInfo.isExternalModuleOrHasOnlyAmbientExternalModules()) { + return this.project.getAllEmittableFiles(); + } + var options = this.project.getCompilerOptions(); + if (options && (options.isolatedModules || options.out || options.outFile)) { + return singleFileResult; + } + var queue = fileInfo.referencedBy.slice(0); + var fileNameSet = ts.createMap(); + fileNameSet[scriptInfo.fileName] = scriptInfo; + while (queue.length > 0) { + var processingFileInfo = queue.pop(); + if (processingFileInfo.updateShapeSignature() && processingFileInfo.referencedBy.length > 0) { + for (var _i = 0, _a = processingFileInfo.referencedBy; _i < _a.length; _i++) { + var potentialFileInfo = _a[_i]; + if (!fileNameSet[potentialFileInfo.scriptInfo.fileName]) { + queue.push(potentialFileInfo); + } + } + } + fileNameSet[processingFileInfo.scriptInfo.fileName] = processingFileInfo.scriptInfo; + } + var result = []; + for (var fileName in fileNameSet) { + if (shouldEmitFile(fileNameSet[fileName])) { + result.push(fileName); + } + } + return result; + }; + return ModuleBuilder; + }(AbstractBuilder)); + function createBuilder(project) { + var moduleKind = project.getCompilerOptions().module; + switch (moduleKind) { + case ts.ModuleKind.None: + return new NonModuleBuilder(project); + default: + return new ModuleBuilder(project); } } - server.generateIndentString = generateIndentString; + server.createBuilder = createBuilder; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + (function (ProjectKind) { + ProjectKind[ProjectKind["Inferred"] = 0] = "Inferred"; + ProjectKind[ProjectKind["Configured"] = 1] = "Configured"; + ProjectKind[ProjectKind["External"] = 2] = "External"; + })(server.ProjectKind || (server.ProjectKind = {})); + var ProjectKind = server.ProjectKind; + function remove(items, item) { + var index = items.indexOf(item); + if (index >= 0) { + items.splice(index, 1); + } + } + function countEachFileTypes(infos) { + var result = { js: 0, jsx: 0, ts: 0, tsx: 0, dts: 0 }; + for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { + var info = infos_1[_i]; + switch (info.scriptKind) { + case 1: + result.js += 1; + break; + case 2: + result.jsx += 1; + break; + case 3: + ts.fileExtensionIs(info.fileName, ".d.ts") + ? result.dts += 1 + : result.ts += 1; + break; + case 4: + result.tsx += 1; + break; + } + } + return result; + } + function hasOneOrMoreJsAndNoTsFiles(project) { + var counts = countEachFileTypes(project.getScriptInfos()); + return counts.js > 0 && counts.ts === 0 && counts.tsx === 0; + } + function allRootFilesAreJsOrDts(project) { + var counts = countEachFileTypes(project.getRootScriptInfos()); + return counts.ts === 0 && counts.tsx === 0; + } + server.allRootFilesAreJsOrDts = allRootFilesAreJsOrDts; + function allFilesAreJsOrDts(project) { + var counts = countEachFileTypes(project.getScriptInfos()); + return counts.ts === 0 && counts.tsx === 0; + } + server.allFilesAreJsOrDts = allFilesAreJsOrDts; + var Project = (function () { + function Project(projectKind, projectService, documentRegistry, hasExplicitListOfFiles, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) { + this.projectKind = projectKind; + this.projectService = projectService; + this.documentRegistry = documentRegistry; + this.languageServiceEnabled = languageServiceEnabled; + this.compilerOptions = compilerOptions; + this.compileOnSaveEnabled = compileOnSaveEnabled; + this.rootFiles = []; + this.rootFilesMap = ts.createFileMap(); + this.lastReportedVersion = 0; + this.projectStructureVersion = 0; + this.projectStateVersion = 0; + this.typesVersion = 0; + if (!this.compilerOptions) { + this.compilerOptions = ts.getDefaultCompilerOptions(); + this.compilerOptions.allowNonTsExtensions = true; + this.compilerOptions.allowJs = true; + } + else if (hasExplicitListOfFiles) { + this.compilerOptions.allowNonTsExtensions = true; + } + if (languageServiceEnabled) { + this.enableLanguageService(); + } + else { + this.disableLanguageService(); + } + this.builder = server.createBuilder(this); + this.markAsDirty(); + } + Project.prototype.isNonTsProject = function () { + this.updateGraph(); + return allFilesAreJsOrDts(this); + }; + Project.prototype.isJsOnlyProject = function () { + this.updateGraph(); + return hasOneOrMoreJsAndNoTsFiles(this); + }; + Project.prototype.getProjectErrors = function () { + return this.projectErrors; + }; + Project.prototype.getLanguageService = function (ensureSynchronized) { + if (ensureSynchronized === void 0) { ensureSynchronized = true; } + if (ensureSynchronized) { + this.updateGraph(); + } + return this.languageService; + }; + Project.prototype.getCompileOnSaveAffectedFileList = function (scriptInfo) { + if (!this.languageServiceEnabled) { + return []; + } + this.updateGraph(); + return this.builder.getFilesAffectedBy(scriptInfo); + }; + Project.prototype.getProjectVersion = function () { + return this.projectStateVersion.toString(); + }; + Project.prototype.enableLanguageService = function () { + var lsHost = new server.LSHost(this.projectService.host, this, this.projectService.cancellationToken); + lsHost.setCompilationSettings(this.compilerOptions); + this.languageService = ts.createLanguageService(lsHost, this.documentRegistry); + this.lsHost = lsHost; + this.languageServiceEnabled = true; + }; + Project.prototype.disableLanguageService = function () { + this.languageService = server.nullLanguageService; + this.lsHost = server.nullLanguageServiceHost; + this.languageServiceEnabled = false; + }; + Project.prototype.getSourceFile = function (path) { + if (!this.program) { + return undefined; + } + return this.program.getSourceFileByPath(path); + }; + Project.prototype.updateTypes = function () { + this.typesVersion++; + this.markAsDirty(); + this.updateGraph(); + }; + Project.prototype.close = function () { + if (this.program) { + for (var _i = 0, _a = this.program.getSourceFiles(); _i < _a.length; _i++) { + var f = _a[_i]; + var info = this.projectService.getScriptInfo(f.fileName); + info.detachFromProject(this); + } + } + else { + for (var _b = 0, _c = this.rootFiles; _b < _c.length; _b++) { + var root = _c[_b]; + root.detachFromProject(this); + } + } + this.rootFiles = undefined; + this.rootFilesMap = undefined; + this.program = undefined; + this.languageService.dispose(); + }; + Project.prototype.getCompilerOptions = function () { + return this.compilerOptions; + }; + Project.prototype.hasRoots = function () { + return this.rootFiles && this.rootFiles.length > 0; + }; + Project.prototype.getRootFiles = function () { + return this.rootFiles && this.rootFiles.map(function (info) { return info.fileName; }); + }; + Project.prototype.getRootFilesLSHost = function () { + var result = []; + if (this.rootFiles) { + for (var _i = 0, _a = this.rootFiles; _i < _a.length; _i++) { + var f = _a[_i]; + result.push(f.fileName); + } + if (this.typingFiles) { + for (var _b = 0, _c = this.typingFiles; _b < _c.length; _b++) { + var f = _c[_b]; + result.push(f); + } + } + } + return result; + }; + Project.prototype.getRootScriptInfos = function () { + return this.rootFiles; + }; + Project.prototype.getScriptInfos = function () { + var _this = this; + return ts.map(this.program.getSourceFiles(), function (sourceFile) { + var scriptInfo = _this.projectService.getScriptInfoForPath(sourceFile.path); + if (!scriptInfo) { + ts.Debug.assert(false, "scriptInfo for a file '" + sourceFile.fileName + "' is missing."); + } + return scriptInfo; + }); + }; + Project.prototype.getFileEmitOutput = function (info, emitOnlyDtsFiles) { + if (!this.languageServiceEnabled) { + return undefined; + } + return this.getLanguageService().getEmitOutput(info.fileName, emitOnlyDtsFiles); + }; + Project.prototype.getFileNames = function () { + if (!this.program) { + return []; + } + if (!this.languageServiceEnabled) { + var rootFiles = this.getRootFiles(); + if (this.compilerOptions) { + var defaultLibrary = ts.getDefaultLibFilePath(this.compilerOptions); + if (defaultLibrary) { + (rootFiles || (rootFiles = [])).push(server.asNormalizedPath(defaultLibrary)); + } + } + return rootFiles; + } + var sourceFiles = this.program.getSourceFiles(); + return sourceFiles.map(function (sourceFile) { return server.asNormalizedPath(sourceFile.fileName); }); + }; + Project.prototype.getAllEmittableFiles = function () { + if (!this.languageServiceEnabled) { + return []; + } + var defaultLibraryFileName = ts.getDefaultLibFileName(this.compilerOptions); + var infos = this.getScriptInfos(); + var result = []; + for (var _i = 0, infos_2 = infos; _i < infos_2.length; _i++) { + var info = infos_2[_i]; + if (ts.getBaseFileName(info.fileName) !== defaultLibraryFileName && server.shouldEmitFile(info)) { + result.push(info.fileName); + } + } + return result; + }; + Project.prototype.containsScriptInfo = function (info) { + return this.isRoot(info) || (this.program && this.program.getSourceFileByPath(info.path) !== undefined); + }; + Project.prototype.containsFile = function (filename, requireOpen) { + var info = this.projectService.getScriptInfoForNormalizedPath(filename); + if (info && (info.isOpen || !requireOpen)) { + return this.containsScriptInfo(info); + } + }; + Project.prototype.isRoot = function (info) { + return this.rootFilesMap && this.rootFilesMap.contains(info.path); + }; + Project.prototype.addRoot = function (info) { + if (!this.isRoot(info)) { + this.rootFiles.push(info); + this.rootFilesMap.set(info.path, info); + info.attachToProject(this); + this.markAsDirty(); + } + }; + Project.prototype.removeFile = function (info, detachFromProject) { + if (detachFromProject === void 0) { detachFromProject = true; } + this.removeRootFileIfNecessary(info); + this.lsHost.notifyFileRemoved(info); + if (detachFromProject) { + info.detachFromProject(this); + } + this.markAsDirty(); + }; + Project.prototype.markAsDirty = function () { + this.projectStateVersion++; + }; + Project.prototype.updateGraph = function () { + if (!this.languageServiceEnabled) { + return true; + } + var hasChanges = this.updateGraphWorker(); + var cachedTypings = this.projectService.typingsCache.getTypingsForProject(this, hasChanges); + if (this.setTypings(cachedTypings)) { + hasChanges = this.updateGraphWorker() || hasChanges; + } + if (hasChanges) { + this.projectStructureVersion++; + } + return !hasChanges; + }; + Project.prototype.setTypings = function (typings) { + if (ts.arrayIsEqualTo(this.typingFiles, typings)) { + return false; + } + this.typingFiles = typings; + this.markAsDirty(); + return true; + }; + Project.prototype.updateGraphWorker = function () { + var oldProgram = this.program; + this.program = this.languageService.getProgram(); + var hasChanges = false; + if (!oldProgram || (this.program !== oldProgram && !oldProgram.structureIsReused)) { + hasChanges = true; + if (oldProgram) { + for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { + var f = _a[_i]; + if (this.program.getSourceFileByPath(f.path)) { + continue; + } + var scriptInfoToDetach = this.projectService.getScriptInfo(f.fileName); + if (scriptInfoToDetach) { + scriptInfoToDetach.detachFromProject(this); + } + } + } + } + this.builder.onProjectUpdateGraph(); + return hasChanges; + }; + Project.prototype.getScriptInfoLSHost = function (fileName) { + var scriptInfo = this.projectService.getOrCreateScriptInfo(fileName, false); + if (scriptInfo) { + scriptInfo.attachToProject(this); + } + return scriptInfo; + }; + Project.prototype.getScriptInfoForNormalizedPath = function (fileName) { + var scriptInfo = this.projectService.getOrCreateScriptInfoForNormalizedPath(fileName, false); + if (scriptInfo && !scriptInfo.isAttached(this)) { + return server.Errors.ThrowProjectDoesNotContainDocument(fileName, this); + } + return scriptInfo; + }; + Project.prototype.getScriptInfo = function (uncheckedFileName) { + return this.getScriptInfoForNormalizedPath(server.toNormalizedPath(uncheckedFileName)); + }; + Project.prototype.filesToString = function () { + if (!this.program) { + return ""; + } + var strBuilder = ""; + for (var _i = 0, _a = this.program.getSourceFiles(); _i < _a.length; _i++) { + var file = _a[_i]; + strBuilder += file.fileName + "\n"; + } + return strBuilder; + }; + Project.prototype.setCompilerOptions = function (compilerOptions) { + if (compilerOptions) { + if (this.projectKind === ProjectKind.Inferred) { + compilerOptions.allowJs = true; + } + compilerOptions.allowNonTsExtensions = true; + this.compilerOptions = compilerOptions; + this.lsHost.setCompilationSettings(compilerOptions); + this.markAsDirty(); + } + }; + Project.prototype.reloadScript = function (filename) { + var script = this.projectService.getScriptInfoForNormalizedPath(filename); + if (script) { + ts.Debug.assert(script.isAttached(this)); + script.reloadFromFile(); + return true; + } + return false; + }; + Project.prototype.getChangesSinceVersion = function (lastKnownVersion) { + this.updateGraph(); + var info = { + projectName: this.getProjectName(), + version: this.projectStructureVersion, + isInferred: this.projectKind === ProjectKind.Inferred, + options: this.getCompilerOptions() + }; + if (this.lastReportedFileNames && lastKnownVersion === this.lastReportedVersion) { + if (this.projectStructureVersion == this.lastReportedVersion) { + return { info: info, projectErrors: this.projectErrors }; + } + var lastReportedFileNames = this.lastReportedFileNames; + var currentFiles = ts.arrayToMap(this.getFileNames(), function (x) { return x; }); + var added = []; + var removed = []; + for (var id in currentFiles) { + if (!ts.hasProperty(lastReportedFileNames, id)) { + added.push(id); + } + } + for (var id in lastReportedFileNames) { + if (!ts.hasProperty(currentFiles, id)) { + removed.push(id); + } + } + this.lastReportedFileNames = currentFiles; + this.lastReportedVersion = this.projectStructureVersion; + return { info: info, changes: { added: added, removed: removed }, projectErrors: this.projectErrors }; + } + else { + var projectFileNames = this.getFileNames(); + this.lastReportedFileNames = ts.arrayToMap(projectFileNames, function (x) { return x; }); + this.lastReportedVersion = this.projectStructureVersion; + return { info: info, files: projectFileNames, projectErrors: this.projectErrors }; + } + }; + Project.prototype.getReferencedFiles = function (path) { + var _this = this; + if (!this.languageServiceEnabled) { + return []; + } + var sourceFile = this.getSourceFile(path); + if (!sourceFile) { + return []; + } + var referencedFiles = ts.createMap(); + if (sourceFile.imports && sourceFile.imports.length > 0) { + var checker = this.program.getTypeChecker(); + for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { + var importName = _a[_i]; + var symbol = checker.getSymbolAtLocation(importName); + if (symbol && symbol.declarations && symbol.declarations[0]) { + var declarationSourceFile = symbol.declarations[0].getSourceFile(); + if (declarationSourceFile) { + referencedFiles[declarationSourceFile.path] = true; + } + } + } + } + var currentDirectory = ts.getDirectoryPath(path); + var getCanonicalFileName = ts.createGetCanonicalFileName(this.projectService.host.useCaseSensitiveFileNames); + if (sourceFile.referencedFiles && sourceFile.referencedFiles.length > 0) { + for (var _b = 0, _c = sourceFile.referencedFiles; _b < _c.length; _b++) { + var referencedFile = _c[_b]; + var referencedPath = ts.toPath(referencedFile.fileName, currentDirectory, getCanonicalFileName); + referencedFiles[referencedPath] = true; + } + } + if (sourceFile.resolvedTypeReferenceDirectiveNames) { + for (var typeName in sourceFile.resolvedTypeReferenceDirectiveNames) { + var resolvedTypeReferenceDirective = sourceFile.resolvedTypeReferenceDirectiveNames[typeName]; + if (!resolvedTypeReferenceDirective) { + continue; + } + var fileName = resolvedTypeReferenceDirective.resolvedFileName; + var typeFilePath = ts.toPath(fileName, currentDirectory, getCanonicalFileName); + referencedFiles[typeFilePath] = true; + } + } + var allFileNames = ts.map(Object.keys(referencedFiles), function (key) { return key; }); + return ts.filter(allFileNames, function (file) { return _this.projectService.host.fileExists(file); }); + }; + Project.prototype.removeRootFileIfNecessary = function (info) { + if (this.isRoot(info)) { + remove(this.rootFiles, info); + this.rootFilesMap.remove(info.path); + } + }; + return Project; + }()); + server.Project = Project; + var InferredProject = (function (_super) { + __extends(InferredProject, _super); + function InferredProject(projectService, documentRegistry, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) { + var _this = _super.call(this, ProjectKind.Inferred, projectService, documentRegistry, undefined, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) || this; + _this.compileOnSaveEnabled = compileOnSaveEnabled; + _this.directoriesWatchedForTsconfig = []; + _this.inferredProjectName = server.makeInferredProjectName(InferredProject.NextId); + InferredProject.NextId++; + return _this; + } + InferredProject.prototype.getProjectName = function () { + return this.inferredProjectName; + }; + InferredProject.prototype.getProjectRootPath = function () { + if (this.projectService.useSingleInferredProject) { + return undefined; + } + var rootFiles = this.getRootFiles(); + return ts.getDirectoryPath(rootFiles[0]); + }; + InferredProject.prototype.close = function () { + _super.prototype.close.call(this); + for (var _i = 0, _a = this.directoriesWatchedForTsconfig; _i < _a.length; _i++) { + var directory = _a[_i]; + this.projectService.stopWatchingDirectory(directory); + } + }; + InferredProject.prototype.getTypingOptions = function () { + return { + enableAutoDiscovery: allRootFilesAreJsOrDts(this), + include: [], + exclude: [] + }; + }; + return InferredProject; + }(Project)); + InferredProject.NextId = 1; + server.InferredProject = InferredProject; + var ConfiguredProject = (function (_super) { + __extends(ConfiguredProject, _super); + function ConfiguredProject(configFileName, projectService, documentRegistry, hasExplicitListOfFiles, compilerOptions, wildcardDirectories, languageServiceEnabled, compileOnSaveEnabled) { + var _this = _super.call(this, ProjectKind.Configured, projectService, documentRegistry, hasExplicitListOfFiles, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) || this; + _this.configFileName = configFileName; + _this.wildcardDirectories = wildcardDirectories; + _this.compileOnSaveEnabled = compileOnSaveEnabled; + _this.openRefCount = 0; + return _this; + } + ConfiguredProject.prototype.getProjectRootPath = function () { + return ts.getDirectoryPath(this.configFileName); + }; + ConfiguredProject.prototype.setProjectErrors = function (projectErrors) { + this.projectErrors = projectErrors; + }; + ConfiguredProject.prototype.setTypingOptions = function (newTypingOptions) { + this.typingOptions = newTypingOptions; + }; + ConfiguredProject.prototype.getTypingOptions = function () { + return this.typingOptions; + }; + ConfiguredProject.prototype.getProjectName = function () { + return this.configFileName; + }; + ConfiguredProject.prototype.watchConfigFile = function (callback) { + var _this = this; + this.projectFileWatcher = this.projectService.host.watchFile(this.configFileName, function (_) { return callback(_this); }); + }; + ConfiguredProject.prototype.watchTypeRoots = function (callback) { + var _this = this; + var roots = this.getEffectiveTypeRoots(); + var watchers = []; + for (var _i = 0, roots_1 = roots; _i < roots_1.length; _i++) { + var root = roots_1[_i]; + this.projectService.logger.info("Add type root watcher for: " + root); + watchers.push(this.projectService.host.watchDirectory(root, function (path) { return callback(_this, path); }, false)); + } + this.typeRootsWatchers = watchers; + }; + ConfiguredProject.prototype.watchConfigDirectory = function (callback) { + var _this = this; + if (this.directoryWatcher) { + return; + } + var directoryToWatch = ts.getDirectoryPath(this.configFileName); + this.projectService.logger.info("Add recursive watcher for: " + directoryToWatch); + this.directoryWatcher = this.projectService.host.watchDirectory(directoryToWatch, function (path) { return callback(_this, path); }, true); + }; + ConfiguredProject.prototype.watchWildcards = function (callback) { + var _this = this; + if (!this.wildcardDirectories) { + return; + } + var configDirectoryPath = ts.getDirectoryPath(this.configFileName); + this.directoriesWatchedForWildcards = ts.reduceProperties(this.wildcardDirectories, function (watchers, flag, directory) { + if (ts.comparePaths(configDirectoryPath, directory, ".", !_this.projectService.host.useCaseSensitiveFileNames) !== 0) { + var recursive = (flag & 1) !== 0; + _this.projectService.logger.info("Add " + (recursive ? "recursive " : "") + "watcher for: " + directory); + watchers[directory] = _this.projectService.host.watchDirectory(directory, function (path) { return callback(_this, path); }, recursive); + } + return watchers; + }, {}); + }; + ConfiguredProject.prototype.stopWatchingDirectory = function () { + if (this.directoryWatcher) { + this.directoryWatcher.close(); + this.directoryWatcher = undefined; + } + }; + ConfiguredProject.prototype.close = function () { + _super.prototype.close.call(this); + if (this.projectFileWatcher) { + this.projectFileWatcher.close(); + } + if (this.typeRootsWatchers) { + for (var _i = 0, _a = this.typeRootsWatchers; _i < _a.length; _i++) { + var watcher = _a[_i]; + watcher.close(); + } + this.typeRootsWatchers = undefined; + } + for (var id in this.directoriesWatchedForWildcards) { + this.directoriesWatchedForWildcards[id].close(); + } + this.directoriesWatchedForWildcards = undefined; + this.stopWatchingDirectory(); + }; + ConfiguredProject.prototype.addOpenRef = function () { + this.openRefCount++; + }; + ConfiguredProject.prototype.deleteOpenRef = function () { + this.openRefCount--; + return this.openRefCount; + }; + ConfiguredProject.prototype.getEffectiveTypeRoots = function () { + return ts.getEffectiveTypeRoots(this.getCompilerOptions(), this.projectService.host) || []; + }; + return ConfiguredProject; + }(Project)); + server.ConfiguredProject = ConfiguredProject; + var ExternalProject = (function (_super) { + __extends(ExternalProject, _super); + function ExternalProject(externalProjectName, projectService, documentRegistry, compilerOptions, languageServiceEnabled, compileOnSaveEnabled, projectFilePath) { + var _this = _super.call(this, ProjectKind.External, projectService, documentRegistry, true, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) || this; + _this.externalProjectName = externalProjectName; + _this.compileOnSaveEnabled = compileOnSaveEnabled; + _this.projectFilePath = projectFilePath; + return _this; + } + ExternalProject.prototype.getProjectRootPath = function () { + if (this.projectFilePath) { + return ts.getDirectoryPath(this.projectFilePath); + } + return ts.getDirectoryPath(ts.normalizeSlashes(this.externalProjectName)); + }; + ExternalProject.prototype.getTypingOptions = function () { + return this.typingOptions; + }; + ExternalProject.prototype.setProjectErrors = function (projectErrors) { + this.projectErrors = projectErrors; + }; + ExternalProject.prototype.setTypingOptions = function (newTypingOptions) { + if (!newTypingOptions) { + newTypingOptions = { + enableAutoDiscovery: allRootFilesAreJsOrDts(this), + include: [], + exclude: [] + }; + } + else { + if (newTypingOptions.enableAutoDiscovery === undefined) { + newTypingOptions.enableAutoDiscovery = allRootFilesAreJsOrDts(this); + } + if (!newTypingOptions.include) { + newTypingOptions.include = []; + } + if (!newTypingOptions.exclude) { + newTypingOptions.exclude = []; + } + } + this.typingOptions = newTypingOptions; + }; + ExternalProject.prototype.getProjectName = function () { + return this.externalProjectName; + }; + return ExternalProject; + }(Project)); + server.ExternalProject = ExternalProject; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + server.maxProgramSizeForNonTsFiles = 20 * 1024 * 1024; + function combineProjectOutput(projects, action, comparer, areEqual) { + var result = projects.reduce(function (previous, current) { return ts.concatenate(previous, action(current)); }, []).sort(comparer); + return projects.length > 1 ? ts.deduplicate(result, areEqual) : result; + } + server.combineProjectOutput = combineProjectOutput; + var fileNamePropertyReader = { + getFileName: function (x) { return x; }, + getScriptKind: function (_) { return undefined; }, + hasMixedContent: function (_) { return false; } + }; + var externalFilePropertyReader = { + getFileName: function (x) { return x.fileName; }, + getScriptKind: function (x) { return x.scriptKind; }, + hasMixedContent: function (x) { return x.hasMixedContent; } + }; + function findProjectByName(projectName, projects) { + for (var _i = 0, projects_1 = projects; _i < projects_1.length; _i++) { + var proj = projects_1[_i]; + if (proj.getProjectName() === projectName) { + return proj; + } + } + } + function createFileNotFoundDiagnostic(fileName) { + return ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, fileName); + } + function isRootFileInInferredProject(info) { + if (info.containingProjects.length === 0) { + return false; + } + return info.containingProjects[0].projectKind === server.ProjectKind.Inferred && info.containingProjects[0].isRoot(info); + } + var DirectoryWatchers = (function () { + function DirectoryWatchers(projectService) { + this.projectService = projectService; + this.directoryWatchersForTsconfig = ts.createMap(); + this.directoryWatchersRefCount = ts.createMap(); + } + DirectoryWatchers.prototype.stopWatchingDirectory = function (directory) { + this.directoryWatchersRefCount[directory]--; + if (this.directoryWatchersRefCount[directory] === 0) { + this.projectService.logger.info("Close directory watcher for: " + directory); + this.directoryWatchersForTsconfig[directory].close(); + delete this.directoryWatchersForTsconfig[directory]; + } + }; + DirectoryWatchers.prototype.startWatchingContainingDirectoriesForFile = function (fileName, project, callback) { + var currentPath = ts.getDirectoryPath(fileName); + var parentPath = ts.getDirectoryPath(currentPath); + while (currentPath != parentPath) { + if (!this.directoryWatchersForTsconfig[currentPath]) { + this.projectService.logger.info("Add watcher for: " + currentPath); + this.directoryWatchersForTsconfig[currentPath] = this.projectService.host.watchDirectory(currentPath, callback); + this.directoryWatchersRefCount[currentPath] = 1; + } + else { + this.directoryWatchersRefCount[currentPath] += 1; + } + project.directoriesWatchedForTsconfig.push(currentPath); + currentPath = parentPath; + parentPath = ts.getDirectoryPath(parentPath); + } + }; + return DirectoryWatchers; + }()); + var ProjectService = (function () { + function ProjectService(host, logger, cancellationToken, useSingleInferredProject, typingsInstaller, eventHandler) { + if (typingsInstaller === void 0) { typingsInstaller = server.nullTypingsInstaller; } + this.host = host; + this.logger = logger; + this.cancellationToken = cancellationToken; + this.useSingleInferredProject = useSingleInferredProject; + this.typingsInstaller = typingsInstaller; + this.eventHandler = eventHandler; + this.filenameToScriptInfo = ts.createFileMap(); + this.externalProjectToConfiguredProjectMap = ts.createMap(); + this.externalProjects = []; + this.inferredProjects = []; + this.configuredProjects = []; + this.openFiles = []; + this.toCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); + this.directoryWatchers = new DirectoryWatchers(this); + this.throttledOperations = new server.ThrottledOperations(host); + this.typingsInstaller.attach(this); + this.typingsCache = new server.TypingsCache(this.typingsInstaller); + this.hostConfiguration = { + formatCodeOptions: server.getDefaultFormatCodeSettings(this.host), + hostInfo: "Unknown host" + }; + this.documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames, host.getCurrentDirectory()); + } + ProjectService.prototype.getChangedFiles_TestOnly = function () { + return this.changedFiles; + }; + ProjectService.prototype.ensureInferredProjectsUpToDate_TestOnly = function () { + this.ensureInferredProjectsUpToDate(); + }; + ProjectService.prototype.updateTypingsForProject = function (response) { + var project = this.findProject(response.projectName); + if (!project) { + return; + } + switch (response.kind) { + case "set": + this.typingsCache.updateTypingsForProject(response.projectName, response.compilerOptions, response.typingOptions, response.typings); + project.updateGraph(); + break; + case "invalidate": + this.typingsCache.invalidateCachedTypingsForProject(project); + break; + } + }; + ProjectService.prototype.setCompilerOptionsForInferredProjects = function (projectCompilerOptions) { + this.compilerOptionsForInferredProjects = projectCompilerOptions; + this.compileOnSaveForInferredProjects = projectCompilerOptions.compileOnSave; + for (var _i = 0, _a = this.inferredProjects; _i < _a.length; _i++) { + var proj = _a[_i]; + proj.setCompilerOptions(projectCompilerOptions); + proj.compileOnSaveEnabled = projectCompilerOptions.compileOnSave; + } + this.updateProjectGraphs(this.inferredProjects); + }; + ProjectService.prototype.stopWatchingDirectory = function (directory) { + this.directoryWatchers.stopWatchingDirectory(directory); + }; + ProjectService.prototype.findProject = function (projectName) { + if (projectName === undefined) { + return undefined; + } + if (server.isInferredProjectName(projectName)) { + this.ensureInferredProjectsUpToDate(); + return findProjectByName(projectName, this.inferredProjects); + } + return this.findExternalProjectByProjectName(projectName) || this.findConfiguredProjectByProjectName(server.toNormalizedPath(projectName)); + }; + ProjectService.prototype.getDefaultProjectForFile = function (fileName, refreshInferredProjects) { + if (refreshInferredProjects) { + this.ensureInferredProjectsUpToDate(); + } + var scriptInfo = this.getScriptInfoForNormalizedPath(fileName); + return scriptInfo && scriptInfo.getDefaultProject(); + }; + ProjectService.prototype.ensureInferredProjectsUpToDate = function () { + if (this.changedFiles) { + var projectsToUpdate = void 0; + if (this.changedFiles.length === 1) { + projectsToUpdate = this.changedFiles[0].containingProjects; + } + else { + projectsToUpdate = []; + for (var _i = 0, _a = this.changedFiles; _i < _a.length; _i++) { + var f = _a[_i]; + projectsToUpdate = projectsToUpdate.concat(f.containingProjects); + } + } + this.updateProjectGraphs(projectsToUpdate); + this.changedFiles = undefined; + } + }; + ProjectService.prototype.findContainingExternalProject = function (fileName) { + for (var _i = 0, _a = this.externalProjects; _i < _a.length; _i++) { + var proj = _a[_i]; + if (proj.containsFile(fileName)) { + return proj; + } + } + return undefined; + }; + ProjectService.prototype.getFormatCodeOptions = function (file) { + var formatCodeSettings; + if (file) { + var info = this.getScriptInfoForNormalizedPath(file); + if (info) { + formatCodeSettings = info.getFormatCodeSettings(); + } + } + return formatCodeSettings || this.hostConfiguration.formatCodeOptions; + }; + ProjectService.prototype.updateProjectGraphs = function (projects) { + var shouldRefreshInferredProjects = false; + for (var _i = 0, projects_2 = projects; _i < projects_2.length; _i++) { + var p = projects_2[_i]; + if (!p.updateGraph()) { + shouldRefreshInferredProjects = true; + } + } + if (shouldRefreshInferredProjects) { + this.refreshInferredProjects(); + } + }; + ProjectService.prototype.onSourceFileChanged = function (fileName) { + var info = this.getScriptInfoForNormalizedPath(fileName); + if (!info) { + this.logger.info("Error: got watch notification for unknown file: " + fileName); + return; + } + if (!this.host.fileExists(fileName)) { + this.handleDeletedFile(info); + } + else { + if (info && (!info.isOpen)) { + info.reloadFromFile(); + this.updateProjectGraphs(info.containingProjects); + } + } + }; + ProjectService.prototype.handleDeletedFile = function (info) { + this.logger.info(info.fileName + " deleted"); + info.stopWatcher(); + if (!info.isOpen) { + this.filenameToScriptInfo.remove(info.path); + this.lastDeletedFile = info; + var containingProjects = info.containingProjects.slice(); + info.detachAllProjects(); + this.updateProjectGraphs(containingProjects); + this.lastDeletedFile = undefined; + if (!this.eventHandler) { + return; + } + for (var _i = 0, _a = this.openFiles; _i < _a.length; _i++) { + var openFile = _a[_i]; + this.eventHandler({ eventName: "context", data: { project: openFile.getDefaultProject(), fileName: openFile.fileName } }); + } + } + this.printProjects(); + }; + ProjectService.prototype.onTypeRootFileChanged = function (project, fileName) { + var _this = this; + this.logger.info("Type root file " + fileName + " changed"); + this.throttledOperations.schedule(project.configFileName + " * type root", 250, function () { + project.updateTypes(); + _this.updateConfiguredProject(project); + _this.refreshInferredProjects(); + }); + }; + ProjectService.prototype.onSourceFileInDirectoryChangedForConfiguredProject = function (project, fileName) { + var _this = this; + if (fileName && !ts.isSupportedSourceFileName(fileName, project.getCompilerOptions())) { + return; + } + this.logger.info("Detected source file changes: " + fileName); + this.throttledOperations.schedule(project.configFileName, 250, function () { return _this.handleChangeInSourceFileForConfiguredProject(project); }); + }; + ProjectService.prototype.handleChangeInSourceFileForConfiguredProject = function (project) { + var _this = this; + var _a = this.convertConfigFileContentToProjectOptions(project.configFileName), projectOptions = _a.projectOptions, configFileErrors = _a.configFileErrors; + this.reportConfigFileDiagnostics(project.getProjectName(), configFileErrors); + var newRootFiles = projectOptions.files.map((function (f) { return _this.getCanonicalFileName(f); })); + var currentRootFiles = project.getRootFiles().map((function (f) { return _this.getCanonicalFileName(f); })); + if (!ts.arrayIsEqualTo(currentRootFiles.sort(), newRootFiles.sort())) { + this.logger.info("Updating configured project"); + this.updateConfiguredProject(project); + this.refreshInferredProjects(); + } + }; + ProjectService.prototype.onConfigChangedForConfiguredProject = function (project) { + this.logger.info("Config file changed: " + project.configFileName); + this.updateConfiguredProject(project); + this.refreshInferredProjects(); + }; + ProjectService.prototype.onConfigFileAddedForInferredProject = function (fileName) { + if (ts.getBaseFileName(fileName) != "tsconfig.json") { + this.logger.info(fileName + " is not tsconfig.json"); + return; + } + var configFileErrors = this.convertConfigFileContentToProjectOptions(fileName).configFileErrors; + this.reportConfigFileDiagnostics(fileName, configFileErrors); + this.logger.info("Detected newly added tsconfig file: " + fileName); + this.reloadProjects(); + }; + ProjectService.prototype.getCanonicalFileName = function (fileName) { + var name = this.host.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); + return ts.normalizePath(name); + }; + ProjectService.prototype.removeProject = function (project) { + this.logger.info("remove project: " + project.getRootFiles().toString()); + project.close(); + switch (project.projectKind) { + case server.ProjectKind.External: + server.removeItemFromSet(this.externalProjects, project); + break; + case server.ProjectKind.Configured: + server.removeItemFromSet(this.configuredProjects, project); + break; + case server.ProjectKind.Inferred: + server.removeItemFromSet(this.inferredProjects, project); + break; + } + }; + ProjectService.prototype.assignScriptInfoToInferredProjectIfNecessary = function (info, addToListOfOpenFiles) { + var externalProject = this.findContainingExternalProject(info.fileName); + if (externalProject) { + if (addToListOfOpenFiles) { + this.openFiles.push(info); + } + return; + } + var foundConfiguredProject = false; + for (var _i = 0, _a = info.containingProjects; _i < _a.length; _i++) { + var p = _a[_i]; + if (p.projectKind === server.ProjectKind.Configured) { + foundConfiguredProject = true; + if (addToListOfOpenFiles) { + (p).addOpenRef(); + } + } + } + if (foundConfiguredProject) { + if (addToListOfOpenFiles) { + this.openFiles.push(info); + } + return; + } + if (info.containingProjects.length === 0) { + var inferredProject = this.createInferredProjectWithRootFileIfNecessary(info); + if (!this.useSingleInferredProject) { + for (var _b = 0, _c = this.openFiles; _b < _c.length; _b++) { + var f = _c[_b]; + if (f.containingProjects.length === 0) { + continue; + } + var defaultProject = f.getDefaultProject(); + if (isRootFileInInferredProject(info) && defaultProject !== inferredProject && inferredProject.containsScriptInfo(f)) { + this.removeProject(defaultProject); + f.attachToProject(inferredProject); + } + } + } + } + if (addToListOfOpenFiles) { + this.openFiles.push(info); + } + }; + ProjectService.prototype.closeOpenFile = function (info) { + info.reloadFromFile(); + server.removeItemFromSet(this.openFiles, info); + info.isOpen = false; + var projectsToRemove; + for (var _i = 0, _a = info.containingProjects; _i < _a.length; _i++) { + var p = _a[_i]; + if (p.projectKind === server.ProjectKind.Configured) { + if (p.deleteOpenRef() === 0) { + (projectsToRemove || (projectsToRemove = [])).push(p); + } + } + else if (p.projectKind === server.ProjectKind.Inferred && p.isRoot(info)) { + (projectsToRemove || (projectsToRemove = [])).push(p); + } + } + if (projectsToRemove) { + for (var _b = 0, projectsToRemove_1 = projectsToRemove; _b < projectsToRemove_1.length; _b++) { + var project = projectsToRemove_1[_b]; + this.removeProject(project); + } + var orphanFiles = void 0; + for (var _c = 0, _d = this.openFiles; _c < _d.length; _c++) { + var f = _d[_c]; + if (f.containingProjects.length === 0) { + (orphanFiles || (orphanFiles = [])).push(f); + } + } + if (orphanFiles) { + for (var _e = 0, orphanFiles_1 = orphanFiles; _e < orphanFiles_1.length; _e++) { + var f = orphanFiles_1[_e]; + this.assignScriptInfoToInferredProjectIfNecessary(f, false); + } + } + } + if (info.containingProjects.length === 0) { + this.filenameToScriptInfo.remove(info.path); + } + }; + ProjectService.prototype.openOrUpdateConfiguredProjectForFile = function (fileName) { + var searchPath = ts.getDirectoryPath(fileName); + this.logger.info("Search path: " + searchPath); + var configFileName = this.findConfigFile(server.asNormalizedPath(searchPath)); + if (!configFileName) { + this.logger.info("No config files found."); + return {}; + } + this.logger.info("Config file name: " + configFileName); + var project = this.findConfiguredProjectByProjectName(configFileName); + if (!project) { + var _a = this.openConfigFile(configFileName, fileName), success = _a.success, errors = _a.errors; + if (!success) { + return { configFileName: configFileName, configFileErrors: errors }; + } + this.logger.info("Opened configuration file " + configFileName); + if (errors && errors.length > 0) { + return { configFileName: configFileName, configFileErrors: errors }; + } + } + else { + this.updateConfiguredProject(project); + } + return { configFileName: configFileName }; + }; + ProjectService.prototype.findConfigFile = function (searchPath) { + while (true) { + var tsconfigFileName = server.asNormalizedPath(ts.combinePaths(searchPath, "tsconfig.json")); + if (this.host.fileExists(tsconfigFileName)) { + return tsconfigFileName; + } + var jsconfigFileName = server.asNormalizedPath(ts.combinePaths(searchPath, "jsconfig.json")); + if (this.host.fileExists(jsconfigFileName)) { + return jsconfigFileName; + } + var parentPath = server.asNormalizedPath(ts.getDirectoryPath(searchPath)); + if (parentPath === searchPath) { + break; + } + searchPath = parentPath; + } + return undefined; + }; + ProjectService.prototype.printProjects = function () { + if (!this.logger.hasLevel(server.LogLevel.verbose)) { + return; + } + this.logger.startGroup(); + var counter = 0; + counter = printProjects(this.logger, this.externalProjects, counter); + counter = printProjects(this.logger, this.configuredProjects, counter); + counter = printProjects(this.logger, this.inferredProjects, counter); + this.logger.info("Open files: "); + for (var _i = 0, _a = this.openFiles; _i < _a.length; _i++) { + var rootFile = _a[_i]; + this.logger.info(rootFile.fileName); + } + this.logger.endGroup(); + function printProjects(logger, projects, counter) { + for (var _i = 0, projects_3 = projects; _i < projects_3.length; _i++) { + var project = projects_3[_i]; + project.updateGraph(); + logger.info("Project '" + project.getProjectName() + "' (" + server.ProjectKind[project.projectKind] + ") " + counter); + logger.info(project.filesToString()); + logger.info("-----------------------------------------------"); + counter++; + } + return counter; + } + }; + ProjectService.prototype.findConfiguredProjectByProjectName = function (configFileName) { + return findProjectByName(configFileName, this.configuredProjects); + }; + ProjectService.prototype.findExternalProjectByProjectName = function (projectFileName) { + return findProjectByName(projectFileName, this.externalProjects); + }; + ProjectService.prototype.convertConfigFileContentToProjectOptions = function (configFilename) { + configFilename = ts.normalizePath(configFilename); + var configFileContent = this.host.readFile(configFilename); + var errors; + var result = ts.parseConfigFileTextToJson(configFilename, configFileContent); + var config = result.config; + if (result.error) { + var _a = ts.sanitizeConfigFile(configFilename, configFileContent), sanitizedConfig = _a.configJsonObject, diagnostics = _a.diagnostics; + config = sanitizedConfig; + errors = diagnostics.length ? diagnostics : [result.error]; + } + var parsedCommandLine = ts.parseJsonConfigFileContent(config, this.host, ts.getDirectoryPath(configFilename), {}, configFilename); + if (parsedCommandLine.errors.length) { + errors = ts.concatenate(errors, parsedCommandLine.errors); + } + ts.Debug.assert(!!parsedCommandLine.fileNames); + if (parsedCommandLine.fileNames.length === 0) { + (errors || (errors = [])).push(ts.createCompilerDiagnostic(ts.Diagnostics.The_config_file_0_found_doesn_t_contain_any_source_files, configFilename)); + return { success: false, configFileErrors: errors }; + } + var projectOptions = { + files: parsedCommandLine.fileNames, + compilerOptions: parsedCommandLine.options, + configHasFilesProperty: config["files"] !== undefined, + wildcardDirectories: ts.createMap(parsedCommandLine.wildcardDirectories), + typingOptions: parsedCommandLine.typingOptions, + compileOnSave: parsedCommandLine.compileOnSave + }; + return { success: true, projectOptions: projectOptions, configFileErrors: errors }; + }; + ProjectService.prototype.exceededTotalSizeLimitForNonTsFiles = function (options, fileNames, propertyReader) { + if (options && options.disableSizeLimit || !this.host.getFileSize) { + return false; + } + var totalNonTsFileSize = 0; + for (var _i = 0, fileNames_3 = fileNames; _i < fileNames_3.length; _i++) { + var f = fileNames_3[_i]; + var fileName = propertyReader.getFileName(f); + if (ts.hasTypeScriptFileExtension(fileName)) { + continue; + } + totalNonTsFileSize += this.host.getFileSize(fileName); + if (totalNonTsFileSize > server.maxProgramSizeForNonTsFiles) { + return true; + } + } + return false; + }; + ProjectService.prototype.createAndAddExternalProject = function (projectFileName, files, options, typingOptions) { + var project = new server.ExternalProject(projectFileName, this, this.documentRegistry, options, !this.exceededTotalSizeLimitForNonTsFiles(options, files, externalFilePropertyReader), options.compileOnSave === undefined ? true : options.compileOnSave); + this.addFilesToProjectAndUpdateGraph(project, files, externalFilePropertyReader, undefined, typingOptions, undefined); + this.externalProjects.push(project); + return project; + }; + ProjectService.prototype.reportConfigFileDiagnostics = function (configFileName, diagnostics, triggerFile) { + if (!this.eventHandler) { + return; + } + this.eventHandler({ + eventName: "configFileDiag", + data: { configFileName: configFileName, diagnostics: diagnostics || [], triggerFile: triggerFile } + }); + }; + ProjectService.prototype.createAndAddConfiguredProject = function (configFileName, projectOptions, configFileErrors, clientFileName) { + var _this = this; + var sizeLimitExceeded = this.exceededTotalSizeLimitForNonTsFiles(projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader); + var project = new server.ConfiguredProject(configFileName, this, this.documentRegistry, projectOptions.configHasFilesProperty, projectOptions.compilerOptions, projectOptions.wildcardDirectories, !sizeLimitExceeded, projectOptions.compileOnSave === undefined ? false : projectOptions.compileOnSave); + this.addFilesToProjectAndUpdateGraph(project, projectOptions.files, fileNamePropertyReader, clientFileName, projectOptions.typingOptions, configFileErrors); + project.watchConfigFile(function (project) { return _this.onConfigChangedForConfiguredProject(project); }); + if (!sizeLimitExceeded) { + this.watchConfigDirectoryForProject(project, projectOptions); + } + project.watchWildcards(function (project, path) { return _this.onSourceFileInDirectoryChangedForConfiguredProject(project, path); }); + project.watchTypeRoots(function (project, path) { return _this.onTypeRootFileChanged(project, path); }); + this.configuredProjects.push(project); + return project; + }; + ProjectService.prototype.watchConfigDirectoryForProject = function (project, options) { + var _this = this; + if (!options.configHasFilesProperty) { + project.watchConfigDirectory(function (project, path) { return _this.onSourceFileInDirectoryChangedForConfiguredProject(project, path); }); + } + }; + ProjectService.prototype.addFilesToProjectAndUpdateGraph = function (project, files, propertyReader, clientFileName, typingOptions, configFileErrors) { + var errors; + for (var _i = 0, files_4 = files; _i < files_4.length; _i++) { + var f = files_4[_i]; + var rootFilename = propertyReader.getFileName(f); + var scriptKind = propertyReader.getScriptKind(f); + var hasMixedContent = propertyReader.hasMixedContent(f); + if (this.host.fileExists(rootFilename)) { + var info = this.getOrCreateScriptInfoForNormalizedPath(server.toNormalizedPath(rootFilename), clientFileName == rootFilename, undefined, scriptKind, hasMixedContent); + project.addRoot(info); + } + else { + (errors || (errors = [])).push(createFileNotFoundDiagnostic(rootFilename)); + } + } + project.setProjectErrors(ts.concatenate(configFileErrors, errors)); + project.setTypingOptions(typingOptions); + project.updateGraph(); + }; + ProjectService.prototype.openConfigFile = function (configFileName, clientFileName) { + var conversionResult = this.convertConfigFileContentToProjectOptions(configFileName); + var projectOptions = conversionResult.success + ? conversionResult.projectOptions + : { files: [], compilerOptions: {} }; + var project = this.createAndAddConfiguredProject(configFileName, projectOptions, conversionResult.configFileErrors, clientFileName); + return { + success: conversionResult.success, + project: project, + errors: project.getProjectErrors() + }; + }; + ProjectService.prototype.updateNonInferredProject = function (project, newUncheckedFiles, propertyReader, newOptions, newTypingOptions, compileOnSave, configFileErrors) { + var oldRootScriptInfos = project.getRootScriptInfos(); + var newRootScriptInfos = []; + var newRootScriptInfoMap = server.createNormalizedPathMap(); + var projectErrors; + var rootFilesChanged = false; + for (var _i = 0, newUncheckedFiles_1 = newUncheckedFiles; _i < newUncheckedFiles_1.length; _i++) { + var f = newUncheckedFiles_1[_i]; + var newRootFile = propertyReader.getFileName(f); + if (!this.host.fileExists(newRootFile)) { + (projectErrors || (projectErrors = [])).push(createFileNotFoundDiagnostic(newRootFile)); + continue; + } + var normalizedPath = server.toNormalizedPath(newRootFile); + var scriptInfo = this.getScriptInfoForNormalizedPath(normalizedPath); + if (!scriptInfo || !project.isRoot(scriptInfo)) { + rootFilesChanged = true; + if (!scriptInfo) { + var scriptKind = propertyReader.getScriptKind(f); + var hasMixedContent = propertyReader.hasMixedContent(f); + scriptInfo = this.getOrCreateScriptInfoForNormalizedPath(normalizedPath, false, undefined, scriptKind, hasMixedContent); + } + } + newRootScriptInfos.push(scriptInfo); + newRootScriptInfoMap.set(scriptInfo.fileName, scriptInfo); + } + if (rootFilesChanged || newRootScriptInfos.length !== oldRootScriptInfos.length) { + var toAdd = void 0; + var toRemove = void 0; + for (var _a = 0, oldRootScriptInfos_1 = oldRootScriptInfos; _a < oldRootScriptInfos_1.length; _a++) { + var oldFile = oldRootScriptInfos_1[_a]; + if (!newRootScriptInfoMap.contains(oldFile.fileName)) { + (toRemove || (toRemove = [])).push(oldFile); + } + } + for (var _b = 0, newRootScriptInfos_1 = newRootScriptInfos; _b < newRootScriptInfos_1.length; _b++) { + var newFile = newRootScriptInfos_1[_b]; + if (!project.isRoot(newFile)) { + (toAdd || (toAdd = [])).push(newFile); + } + } + if (toRemove) { + for (var _c = 0, toRemove_1 = toRemove; _c < toRemove_1.length; _c++) { + var f = toRemove_1[_c]; + project.removeFile(f); + } + } + if (toAdd) { + for (var _d = 0, toAdd_1 = toAdd; _d < toAdd_1.length; _d++) { + var f = toAdd_1[_d]; + if (f.isOpen && isRootFileInInferredProject(f)) { + var inferredProject = f.containingProjects[0]; + inferredProject.removeFile(f); + if (!inferredProject.hasRoots()) { + this.removeProject(inferredProject); + } + } + project.addRoot(f); + } + } + } + project.setCompilerOptions(newOptions); + project.setTypingOptions(newTypingOptions); + if (compileOnSave !== undefined) { + project.compileOnSaveEnabled = compileOnSave; + } + project.setProjectErrors(ts.concatenate(configFileErrors, projectErrors)); + project.updateGraph(); + }; + ProjectService.prototype.updateConfiguredProject = function (project) { + if (!this.host.fileExists(project.configFileName)) { + this.logger.info("Config file deleted"); + this.removeProject(project); + return; + } + var _a = this.convertConfigFileContentToProjectOptions(project.configFileName), success = _a.success, projectOptions = _a.projectOptions, configFileErrors = _a.configFileErrors; + if (!success) { + this.updateNonInferredProject(project, [], fileNamePropertyReader, {}, {}, false, configFileErrors); + return configFileErrors; + } + if (this.exceededTotalSizeLimitForNonTsFiles(projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader)) { + project.setCompilerOptions(projectOptions.compilerOptions); + if (!project.languageServiceEnabled) { + return; + } + project.disableLanguageService(); + project.stopWatchingDirectory(); + } + else { + if (!project.languageServiceEnabled) { + project.enableLanguageService(); + } + this.watchConfigDirectoryForProject(project, projectOptions); + this.updateNonInferredProject(project, projectOptions.files, fileNamePropertyReader, projectOptions.compilerOptions, projectOptions.typingOptions, projectOptions.compileOnSave, configFileErrors); + } + }; + ProjectService.prototype.createInferredProjectWithRootFileIfNecessary = function (root) { + var _this = this; + var useExistingProject = this.useSingleInferredProject && this.inferredProjects.length; + var project = useExistingProject + ? this.inferredProjects[0] + : new server.InferredProject(this, this.documentRegistry, true, this.compilerOptionsForInferredProjects, this.compileOnSaveForInferredProjects); + project.addRoot(root); + this.directoryWatchers.startWatchingContainingDirectoriesForFile(root.fileName, project, function (fileName) { return _this.onConfigFileAddedForInferredProject(fileName); }); + project.updateGraph(); + if (!useExistingProject) { + this.inferredProjects.push(project); + } + return project; + }; + ProjectService.prototype.getOrCreateScriptInfo = function (uncheckedFileName, openedByClient, fileContent, scriptKind) { + return this.getOrCreateScriptInfoForNormalizedPath(server.toNormalizedPath(uncheckedFileName), openedByClient, fileContent, scriptKind); + }; + ProjectService.prototype.getScriptInfo = function (uncheckedFileName) { + return this.getScriptInfoForNormalizedPath(server.toNormalizedPath(uncheckedFileName)); + }; + ProjectService.prototype.getOrCreateScriptInfoForNormalizedPath = function (fileName, openedByClient, fileContent, scriptKind, hasMixedContent) { + var _this = this; + var info = this.getScriptInfoForNormalizedPath(fileName); + if (!info) { + var content = void 0; + if (this.host.fileExists(fileName)) { + content = fileContent || (hasMixedContent ? "" : this.host.readFile(fileName)); + } + if (!content) { + if (openedByClient) { + content = ""; + } + } + if (content !== undefined) { + info = new server.ScriptInfo(this.host, fileName, content, scriptKind, openedByClient, hasMixedContent); + this.filenameToScriptInfo.set(info.path, info); + if (!info.isOpen && !hasMixedContent) { + info.setWatcher(this.host.watchFile(fileName, function (_) { return _this.onSourceFileChanged(fileName); })); + } + } + } + if (info) { + if (fileContent !== undefined) { + info.reload(fileContent); + } + if (openedByClient) { + info.isOpen = true; + } + } + return info; + }; + ProjectService.prototype.getScriptInfoForNormalizedPath = function (fileName) { + return this.getScriptInfoForPath(server.normalizedPathToPath(fileName, this.host.getCurrentDirectory(), this.toCanonicalFileName)); + }; + ProjectService.prototype.getScriptInfoForPath = function (fileName) { + return this.filenameToScriptInfo.get(fileName); + }; + ProjectService.prototype.setHostConfiguration = function (args) { + if (args.file) { + var info = this.getScriptInfoForNormalizedPath(server.toNormalizedPath(args.file)); + if (info) { + info.setFormatOptions(args.formatOptions); + this.logger.info("Host configuration update for file " + args.file); + } + } + else { + if (args.hostInfo !== undefined) { + this.hostConfiguration.hostInfo = args.hostInfo; + this.logger.info("Host information " + args.hostInfo); + } + if (args.formatOptions) { + server.mergeMaps(this.hostConfiguration.formatCodeOptions, args.formatOptions); + this.logger.info("Format host information updated"); + } + } + }; + ProjectService.prototype.closeLog = function () { + this.logger.close(); + }; + ProjectService.prototype.reloadProjects = function () { + this.logger.info("reload projects."); + for (var _i = 0, _a = this.openFiles; _i < _a.length; _i++) { + var info = _a[_i]; + this.openOrUpdateConfiguredProjectForFile(info.fileName); + } + this.refreshInferredProjects(); + }; + ProjectService.prototype.refreshInferredProjects = function () { + this.logger.info("updating project structure from ..."); + this.printProjects(); + var orphantedFiles = []; + for (var _i = 0, _a = this.openFiles; _i < _a.length; _i++) { + var info = _a[_i]; + if (info.containingProjects.length === 0) { + orphantedFiles.push(info); + } + else { + if (isRootFileInInferredProject(info) && info.containingProjects.length > 1) { + var inferredProject = info.containingProjects[0]; + ts.Debug.assert(inferredProject.projectKind === server.ProjectKind.Inferred); + inferredProject.removeFile(info); + if (!inferredProject.hasRoots()) { + this.removeProject(inferredProject); + } + } + } + } + for (var _b = 0, orphantedFiles_1 = orphantedFiles; _b < orphantedFiles_1.length; _b++) { + var f = orphantedFiles_1[_b]; + this.assignScriptInfoToInferredProjectIfNecessary(f, false); + } + for (var _c = 0, _d = this.inferredProjects; _c < _d.length; _c++) { + var p = _d[_c]; + p.updateGraph(); + } + this.printProjects(); + }; + ProjectService.prototype.openClientFile = function (fileName, fileContent, scriptKind) { + return this.openClientFileWithNormalizedPath(server.toNormalizedPath(fileName), fileContent, scriptKind); + }; + ProjectService.prototype.openClientFileWithNormalizedPath = function (fileName, fileContent, scriptKind, hasMixedContent) { + var _a = this.findContainingExternalProject(fileName) + ? {} + : this.openOrUpdateConfiguredProjectForFile(fileName), _b = _a.configFileName, configFileName = _b === void 0 ? undefined : _b, _c = _a.configFileErrors, configFileErrors = _c === void 0 ? undefined : _c; + var info = this.getOrCreateScriptInfoForNormalizedPath(fileName, true, fileContent, scriptKind, hasMixedContent); + this.assignScriptInfoToInferredProjectIfNecessary(info, true); + this.printProjects(); + return { configFileName: configFileName, configFileErrors: configFileErrors }; + }; + ProjectService.prototype.closeClientFile = function (uncheckedFileName) { + var info = this.getScriptInfoForNormalizedPath(server.toNormalizedPath(uncheckedFileName)); + if (info) { + this.closeOpenFile(info); + info.isOpen = false; + } + this.printProjects(); + }; + ProjectService.prototype.collectChanges = function (lastKnownProjectVersions, currentProjects, result) { + var _loop_3 = function (proj) { + var knownProject = ts.forEach(lastKnownProjectVersions, function (p) { return p.projectName === proj.getProjectName() && p; }); + result.push(proj.getChangesSinceVersion(knownProject && knownProject.version)); + }; + for (var _i = 0, currentProjects_1 = currentProjects; _i < currentProjects_1.length; _i++) { + var proj = currentProjects_1[_i]; + _loop_3(proj); + } + }; + ProjectService.prototype.synchronizeProjectList = function (knownProjects) { + var files = []; + this.collectChanges(knownProjects, this.externalProjects, files); + this.collectChanges(knownProjects, this.configuredProjects, files); + this.collectChanges(knownProjects, this.inferredProjects, files); + return files; + }; + ProjectService.prototype.applyChangesInOpenFiles = function (openFiles, changedFiles, closedFiles) { + var recordChangedFiles = changedFiles && !openFiles && !closedFiles; + if (openFiles) { + for (var _i = 0, openFiles_1 = openFiles; _i < openFiles_1.length; _i++) { + var file = openFiles_1[_i]; + var scriptInfo = this.getScriptInfo(file.fileName); + ts.Debug.assert(!scriptInfo || !scriptInfo.isOpen); + var normalizedPath = scriptInfo ? scriptInfo.fileName : server.toNormalizedPath(file.fileName); + this.openClientFileWithNormalizedPath(normalizedPath, file.content, file.scriptKind, file.hasMixedContent); + } + } + if (changedFiles) { + for (var _a = 0, changedFiles_1 = changedFiles; _a < changedFiles_1.length; _a++) { + var file = changedFiles_1[_a]; + var scriptInfo = this.getScriptInfo(file.fileName); + ts.Debug.assert(!!scriptInfo); + for (var i = file.changes.length - 1; i >= 0; i--) { + var change = file.changes[i]; + scriptInfo.editContent(change.span.start, change.span.start + change.span.length, change.newText); + } + if (recordChangedFiles) { + if (!this.changedFiles) { + this.changedFiles = [scriptInfo]; + } + else if (this.changedFiles.indexOf(scriptInfo) < 0) { + this.changedFiles.push(scriptInfo); + } + } + } + } + if (closedFiles) { + for (var _b = 0, closedFiles_1 = closedFiles; _b < closedFiles_1.length; _b++) { + var file = closedFiles_1[_b]; + this.closeClientFile(file); + } + } + if (openFiles || closedFiles) { + this.refreshInferredProjects(); + } + }; + ProjectService.prototype.closeConfiguredProject = function (configFile) { + var configuredProject = this.findConfiguredProjectByProjectName(configFile); + if (configuredProject && configuredProject.deleteOpenRef() === 0) { + this.removeProject(configuredProject); + } + }; + ProjectService.prototype.closeExternalProject = function (uncheckedFileName, suppressRefresh) { + if (suppressRefresh === void 0) { suppressRefresh = false; } + var fileName = server.toNormalizedPath(uncheckedFileName); + var configFiles = this.externalProjectToConfiguredProjectMap[fileName]; + if (configFiles) { + var shouldRefreshInferredProjects = false; + for (var _i = 0, configFiles_1 = configFiles; _i < configFiles_1.length; _i++) { + var configFile = configFiles_1[_i]; + if (this.closeConfiguredProject(configFile)) { + shouldRefreshInferredProjects = true; + } + } + delete this.externalProjectToConfiguredProjectMap[fileName]; + if (shouldRefreshInferredProjects && !suppressRefresh) { + this.refreshInferredProjects(); + } + } + else { + var externalProject = this.findExternalProjectByProjectName(uncheckedFileName); + if (externalProject) { + this.removeProject(externalProject); + if (!suppressRefresh) { + this.refreshInferredProjects(); + } + } + } + }; + ProjectService.prototype.openExternalProject = function (proj) { + var tsConfigFiles; + var rootFiles = []; + for (var _i = 0, _a = proj.rootFiles; _i < _a.length; _i++) { + var file = _a[_i]; + var normalized = server.toNormalizedPath(file.fileName); + if (ts.getBaseFileName(normalized) === "tsconfig.json") { + (tsConfigFiles || (tsConfigFiles = [])).push(normalized); + } + else { + rootFiles.push(file); + } + } + if (tsConfigFiles) { + tsConfigFiles.sort(); + } + var externalProject = this.findExternalProjectByProjectName(proj.projectFileName); + var exisingConfigFiles; + if (externalProject) { + if (!tsConfigFiles) { + this.updateNonInferredProject(externalProject, proj.rootFiles, externalFilePropertyReader, proj.options, proj.typingOptions, proj.options.compileOnSave, undefined); + return; + } + this.closeExternalProject(proj.projectFileName, true); + } + else if (this.externalProjectToConfiguredProjectMap[proj.projectFileName]) { + if (!tsConfigFiles) { + this.closeExternalProject(proj.projectFileName, true); + } + else { + var oldConfigFiles = this.externalProjectToConfiguredProjectMap[proj.projectFileName]; + var iNew = 0; + var iOld = 0; + while (iNew < tsConfigFiles.length && iOld < oldConfigFiles.length) { + var newConfig = tsConfigFiles[iNew]; + var oldConfig = oldConfigFiles[iOld]; + if (oldConfig < newConfig) { + this.closeConfiguredProject(oldConfig); + iOld++; + } + else if (oldConfig > newConfig) { + iNew++; + } + else { + (exisingConfigFiles || (exisingConfigFiles = [])).push(oldConfig); + iOld++; + iNew++; + } + } + for (var i = iOld; i < oldConfigFiles.length; i++) { + this.closeConfiguredProject(oldConfigFiles[i]); + } + } + } + if (tsConfigFiles) { + this.externalProjectToConfiguredProjectMap[proj.projectFileName] = tsConfigFiles; + for (var _b = 0, tsConfigFiles_1 = tsConfigFiles; _b < tsConfigFiles_1.length; _b++) { + var tsconfigFile = tsConfigFiles_1[_b]; + var project = this.findConfiguredProjectByProjectName(tsconfigFile); + if (!project) { + var result = this.openConfigFile(tsconfigFile); + project = result.success && result.project; + } + if (project && !ts.contains(exisingConfigFiles, tsconfigFile)) { + project.addOpenRef(); + } + } + } + else { + delete this.externalProjectToConfiguredProjectMap[proj.projectFileName]; + this.createAndAddExternalProject(proj.projectFileName, rootFiles, proj.options, proj.typingOptions); + } + this.refreshInferredProjects(); + }; + return ProjectService; + }()); + server.ProjectService = ProjectService; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + function hrTimeToMilliseconds(time) { + var seconds = time[0]; + var nanoseconds = time[1]; + return ((1e9 * seconds) + nanoseconds) / 1000000.0; + } + function shouldSkipSematicCheck(project) { + if (project.getCompilerOptions().skipLibCheck !== undefined) { + return false; + } + if ((project.projectKind === server.ProjectKind.Inferred || project.projectKind === server.ProjectKind.External) && project.isJsOnlyProject()) { + return true; + } + return false; + } function compareNumber(a, b) { - if (a < b) { - return -1; - } - else if (a === b) { - return 0; - } - else - return 1; + return a - b; } function compareFileStart(a, b) { if (a.file < b.file) { @@ -60288,10 +63334,12 @@ var ts; } } function formatDiag(fileName, project, diag) { + var scriptInfo = project.getScriptInfoForNormalizedPath(fileName); return { - start: project.compilerService.host.positionToLineOffset(fileName, diag.start), - end: project.compilerService.host.positionToLineOffset(fileName, diag.start + diag.length), - text: ts.flattenDiagnosticMessageText(diag.messageText, "\n") + start: scriptInfo.positionToLineOffset(diag.start), + end: scriptInfo.positionToLineOffset(diag.start + diag.length), + text: ts.flattenDiagnosticMessageText(diag.messageText, "\n"), + code: diag.code }; } function formatConfigFileDiag(diag) { @@ -60302,8 +63350,9 @@ var ts; }; } function allEditsBeforePos(edits, pos) { - for (var i = 0, len = edits.length; i < len; i++) { - if (ts.textSpanEnd(edits[i].span) >= pos) { + for (var _i = 0, edits_1 = edits; _i < edits_1.length; _i++) { + var edit = edits_1[_i]; + if (ts.textSpanEnd(edit.span) >= pos) { return false; } } @@ -60312,73 +63361,166 @@ var ts; var CommandNames; (function (CommandNames) { CommandNames.Brace = "brace"; + CommandNames.BraceFull = "brace-full"; + CommandNames.BraceCompletion = "braceCompletion"; CommandNames.Change = "change"; CommandNames.Close = "close"; CommandNames.Completions = "completions"; + CommandNames.CompletionsFull = "completions-full"; CommandNames.CompletionDetails = "completionEntryDetails"; + CommandNames.CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList"; + CommandNames.CompileOnSaveEmitFile = "compileOnSaveEmitFile"; CommandNames.Configure = "configure"; CommandNames.Definition = "definition"; + CommandNames.DefinitionFull = "definition-full"; CommandNames.Exit = "exit"; CommandNames.Format = "format"; CommandNames.Formatonkey = "formatonkey"; + CommandNames.FormatFull = "format-full"; + CommandNames.FormatonkeyFull = "formatonkey-full"; + CommandNames.FormatRangeFull = "formatRange-full"; CommandNames.Geterr = "geterr"; CommandNames.GeterrForProject = "geterrForProject"; CommandNames.Implementation = "implementation"; + CommandNames.ImplementationFull = "implementation-full"; CommandNames.SemanticDiagnosticsSync = "semanticDiagnosticsSync"; CommandNames.SyntacticDiagnosticsSync = "syntacticDiagnosticsSync"; CommandNames.NavBar = "navbar"; + CommandNames.NavBarFull = "navbar-full"; + CommandNames.NavTree = "navtree"; + CommandNames.NavTreeFull = "navtree-full"; CommandNames.Navto = "navto"; + CommandNames.NavtoFull = "navto-full"; CommandNames.Occurrences = "occurrences"; CommandNames.DocumentHighlights = "documentHighlights"; + CommandNames.DocumentHighlightsFull = "documentHighlights-full"; CommandNames.Open = "open"; CommandNames.Quickinfo = "quickinfo"; + CommandNames.QuickinfoFull = "quickinfo-full"; CommandNames.References = "references"; + CommandNames.ReferencesFull = "references-full"; CommandNames.Reload = "reload"; CommandNames.Rename = "rename"; + CommandNames.RenameInfoFull = "rename-full"; + CommandNames.RenameLocationsFull = "renameLocations-full"; CommandNames.Saveto = "saveto"; CommandNames.SignatureHelp = "signatureHelp"; + CommandNames.SignatureHelpFull = "signatureHelp-full"; CommandNames.TypeDefinition = "typeDefinition"; CommandNames.ProjectInfo = "projectInfo"; CommandNames.ReloadProjects = "reloadProjects"; CommandNames.Unknown = "unknown"; + CommandNames.OpenExternalProject = "openExternalProject"; + CommandNames.OpenExternalProjects = "openExternalProjects"; + CommandNames.CloseExternalProject = "closeExternalProject"; + CommandNames.SynchronizeProjectList = "synchronizeProjectList"; + CommandNames.ApplyChangedToOpenFiles = "applyChangedToOpenFiles"; + CommandNames.EncodedSemanticClassificationsFull = "encodedSemanticClassifications-full"; + CommandNames.Cleanup = "cleanup"; + CommandNames.OutliningSpans = "outliningSpans"; + CommandNames.TodoComments = "todoComments"; + CommandNames.Indentation = "indentation"; + CommandNames.DocCommentTemplate = "docCommentTemplate"; + CommandNames.CompilerOptionsDiagnosticsFull = "compilerOptionsDiagnostics-full"; + CommandNames.NameOrDottedNameSpan = "nameOrDottedNameSpan"; + CommandNames.BreakpointStatement = "breakpointStatement"; + CommandNames.CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects"; + CommandNames.GetCodeFixes = "getCodeFixes"; + CommandNames.GetCodeFixesFull = "getCodeFixes-full"; + CommandNames.GetSupportedCodeFixes = "getSupportedCodeFixes"; })(CommandNames = server.CommandNames || (server.CommandNames = {})); - var Errors; - (function (Errors) { - Errors.NoProject = new Error("No Project."); - Errors.ProjectLanguageServiceDisabled = new Error("The project's language service is disabled."); - })(Errors || (Errors = {})); + function formatMessage(msg, logger, byteLength, newLine) { + var verboseLogging = logger.hasLevel(server.LogLevel.verbose); + var json = JSON.stringify(msg); + if (verboseLogging) { + logger.info(msg.type + ": " + json); + } + var len = byteLength(json, "utf8"); + return "Content-Length: " + (1 + len) + "\r\n\r\n" + json + newLine; + } + server.formatMessage = formatMessage; var Session = (function () { - function Session(host, byteLength, hrtime, logger) { + function Session(host, cancellationToken, useSingleInferredProject, typingsInstaller, byteLength, hrtime, logger, canUseEvents, eventHandler) { var _this = this; this.host = host; + this.typingsInstaller = typingsInstaller; this.byteLength = byteLength; this.hrtime = hrtime; this.logger = logger; + this.canUseEvents = canUseEvents; this.changeSeq = 0; this.handlers = ts.createMap((_a = {}, + _a[CommandNames.OpenExternalProject] = function (request) { + _this.projectService.openExternalProject(request.arguments); + return _this.requiredResponse(true); + }, + _a[CommandNames.OpenExternalProjects] = function (request) { + for (var _i = 0, _a = request.arguments.projects; _i < _a.length; _i++) { + var proj = _a[_i]; + _this.projectService.openExternalProject(proj); + } + return _this.requiredResponse(true); + }, + _a[CommandNames.CloseExternalProject] = function (request) { + _this.projectService.closeExternalProject(request.arguments.projectFileName); + return _this.requiredResponse(true); + }, + _a[CommandNames.SynchronizeProjectList] = function (request) { + var result = _this.projectService.synchronizeProjectList(request.arguments.knownProjects); + if (!result.some(function (p) { return p.projectErrors && p.projectErrors.length !== 0; })) { + return _this.requiredResponse(result); + } + var converted = ts.map(result, function (p) { + if (!p.projectErrors || p.projectErrors.length === 0) { + return p; + } + return { + info: p.info, + changes: p.changes, + files: p.files, + projectErrors: _this.convertToDiagnosticsWithLinePosition(p.projectErrors, undefined) + }; + }); + return _this.requiredResponse(converted); + }, + _a[CommandNames.ApplyChangedToOpenFiles] = function (request) { + _this.projectService.applyChangesInOpenFiles(request.arguments.openFiles, request.arguments.changedFiles, request.arguments.closedFiles); + _this.changeSeq++; + return _this.requiredResponse(true); + }, _a[CommandNames.Exit] = function () { _this.exit(); - return { responseRequired: false }; + return _this.notRequired(); }, _a[CommandNames.Definition] = function (request) { - var defArgs = request.arguments; - return { response: _this.getDefinition(defArgs.line, defArgs.offset, defArgs.file), responseRequired: true }; + return _this.requiredResponse(_this.getDefinition(request.arguments, true)); + }, + _a[CommandNames.DefinitionFull] = function (request) { + return _this.requiredResponse(_this.getDefinition(request.arguments, false)); }, _a[CommandNames.TypeDefinition] = function (request) { - var defArgs = request.arguments; - return { response: _this.getTypeDefinition(defArgs.line, defArgs.offset, defArgs.file), responseRequired: true }; + return _this.requiredResponse(_this.getTypeDefinition(request.arguments)); }, _a[CommandNames.Implementation] = function (request) { - var implArgs = request.arguments; - return { response: _this.getImplementation(implArgs.line, implArgs.offset, implArgs.file), responseRequired: true }; + return _this.requiredResponse(_this.getImplementation(request.arguments, true)); + }, + _a[CommandNames.ImplementationFull] = function (request) { + return _this.requiredResponse(_this.getImplementation(request.arguments, false)); }, _a[CommandNames.References] = function (request) { - var defArgs = request.arguments; - return { response: _this.getReferences(defArgs.line, defArgs.offset, defArgs.file), responseRequired: true }; + return _this.requiredResponse(_this.getReferences(request.arguments, true)); + }, + _a[CommandNames.ReferencesFull] = function (request) { + return _this.requiredResponse(_this.getReferences(request.arguments, false)); }, _a[CommandNames.Rename] = function (request) { - var renameArgs = request.arguments; - return { response: _this.getRenameLocations(renameArgs.line, renameArgs.offset, renameArgs.file, renameArgs.findInComments, renameArgs.findInStrings), responseRequired: true }; + return _this.requiredResponse(_this.getRenameLocations(request.arguments, true)); + }, + _a[CommandNames.RenameLocationsFull] = function (request) { + return _this.requiredResponse(_this.getRenameLocations(request.arguments, false)); + }, + _a[CommandNames.RenameInfoFull] = function (request) { + return _this.requiredResponse(_this.getRenameInfo(request.arguments)); }, _a[CommandNames.Open] = function (request) { var openArgs = request.arguments; @@ -60397,34 +63539,81 @@ var ts; scriptKind = 2; break; } - _this.openClientFile(openArgs.file, openArgs.fileContent, scriptKind); - return { responseRequired: false }; + _this.openClientFile(server.toNormalizedPath(openArgs.file), openArgs.fileContent, scriptKind); + return _this.notRequired(); }, _a[CommandNames.Quickinfo] = function (request) { - var quickinfoArgs = request.arguments; - return { response: _this.getQuickInfo(quickinfoArgs.line, quickinfoArgs.offset, quickinfoArgs.file), responseRequired: true }; + return _this.requiredResponse(_this.getQuickInfoWorker(request.arguments, true)); + }, + _a[CommandNames.QuickinfoFull] = function (request) { + return _this.requiredResponse(_this.getQuickInfoWorker(request.arguments, false)); + }, + _a[CommandNames.OutliningSpans] = function (request) { + return _this.requiredResponse(_this.getOutliningSpans(request.arguments)); + }, + _a[CommandNames.TodoComments] = function (request) { + return _this.requiredResponse(_this.getTodoComments(request.arguments)); + }, + _a[CommandNames.Indentation] = function (request) { + return _this.requiredResponse(_this.getIndentation(request.arguments)); + }, + _a[CommandNames.NameOrDottedNameSpan] = function (request) { + return _this.requiredResponse(_this.getNameOrDottedNameSpan(request.arguments)); + }, + _a[CommandNames.BreakpointStatement] = function (request) { + return _this.requiredResponse(_this.getBreakpointStatement(request.arguments)); + }, + _a[CommandNames.BraceCompletion] = function (request) { + return _this.requiredResponse(_this.isValidBraceCompletion(request.arguments)); + }, + _a[CommandNames.DocCommentTemplate] = function (request) { + return _this.requiredResponse(_this.getDocCommentTemplate(request.arguments)); }, _a[CommandNames.Format] = function (request) { - var formatArgs = request.arguments; - return { response: _this.getFormattingEditsForRange(formatArgs.line, formatArgs.offset, formatArgs.endLine, formatArgs.endOffset, formatArgs.file), responseRequired: true }; + return _this.requiredResponse(_this.getFormattingEditsForRange(request.arguments)); }, _a[CommandNames.Formatonkey] = function (request) { - var formatOnKeyArgs = request.arguments; - return { response: _this.getFormattingEditsAfterKeystroke(formatOnKeyArgs.line, formatOnKeyArgs.offset, formatOnKeyArgs.key, formatOnKeyArgs.file), responseRequired: true }; + return _this.requiredResponse(_this.getFormattingEditsAfterKeystroke(request.arguments)); + }, + _a[CommandNames.FormatFull] = function (request) { + return _this.requiredResponse(_this.getFormattingEditsForDocumentFull(request.arguments)); + }, + _a[CommandNames.FormatonkeyFull] = function (request) { + return _this.requiredResponse(_this.getFormattingEditsAfterKeystrokeFull(request.arguments)); + }, + _a[CommandNames.FormatRangeFull] = function (request) { + return _this.requiredResponse(_this.getFormattingEditsForRangeFull(request.arguments)); }, _a[CommandNames.Completions] = function (request) { - var completionsArgs = request.arguments; - return { response: _this.getCompletions(completionsArgs.line, completionsArgs.offset, completionsArgs.prefix, completionsArgs.file), responseRequired: true }; + return _this.requiredResponse(_this.getCompletions(request.arguments, true)); + }, + _a[CommandNames.CompletionsFull] = function (request) { + return _this.requiredResponse(_this.getCompletions(request.arguments, false)); }, _a[CommandNames.CompletionDetails] = function (request) { - var completionDetailsArgs = request.arguments; - return { - response: _this.getCompletionEntryDetails(completionDetailsArgs.line, completionDetailsArgs.offset, completionDetailsArgs.entryNames, completionDetailsArgs.file), responseRequired: true - }; + return _this.requiredResponse(_this.getCompletionEntryDetails(request.arguments)); + }, + _a[CommandNames.CompileOnSaveAffectedFileList] = function (request) { + return _this.requiredResponse(_this.getCompileOnSaveAffectedFileList(request.arguments)); + }, + _a[CommandNames.CompileOnSaveEmitFile] = function (request) { + return _this.requiredResponse(_this.emitFile(request.arguments)); }, _a[CommandNames.SignatureHelp] = function (request) { - var signatureHelpArgs = request.arguments; - return { response: _this.getSignatureHelpItems(signatureHelpArgs.line, signatureHelpArgs.offset, signatureHelpArgs.file), responseRequired: true }; + return _this.requiredResponse(_this.getSignatureHelpItems(request.arguments, true)); + }, + _a[CommandNames.SignatureHelpFull] = function (request) { + return _this.requiredResponse(_this.getSignatureHelpItems(request.arguments, false)); + }, + _a[CommandNames.CompilerOptionsDiagnosticsFull] = function (request) { + return _this.requiredResponse(_this.getCompilerOptionsDiagnostics(request.arguments)); + }, + _a[CommandNames.EncodedSemanticClassificationsFull] = function (request) { + return _this.requiredResponse(_this.getEncodedSemanticClassifications(request.arguments)); + }, + _a[CommandNames.Cleanup] = function (request) { + _this.cleanup(); + return _this.requiredResponse(true); }, _a[CommandNames.SemanticDiagnosticsSync] = function (request) { return _this.requiredResponse(_this.getSemanticDiagnosticsSync(request.arguments)); @@ -60441,72 +63630,94 @@ var ts; return { response: _this.getDiagnosticsForProject(delay, file), responseRequired: false }; }, _a[CommandNames.Change] = function (request) { - var changeArgs = request.arguments; - _this.change(changeArgs.line, changeArgs.offset, changeArgs.endLine, changeArgs.endOffset, changeArgs.insertString, changeArgs.file); - return { responseRequired: false }; + _this.change(request.arguments); + return _this.notRequired(); }, _a[CommandNames.Configure] = function (request) { - var configureArgs = request.arguments; - _this.projectService.setHostConfiguration(configureArgs); + _this.projectService.setHostConfiguration(request.arguments); _this.output(undefined, CommandNames.Configure, request.seq); - return { responseRequired: false }; + return _this.notRequired(); }, _a[CommandNames.Reload] = function (request) { - var reloadArgs = request.arguments; - _this.reload(reloadArgs.file, reloadArgs.tmpfile, request.seq); - return { response: { reloadFinished: true }, responseRequired: true }; + _this.reload(request.arguments, request.seq); + return _this.requiredResponse({ reloadFinished: true }); }, _a[CommandNames.Saveto] = function (request) { var savetoArgs = request.arguments; _this.saveToTmp(savetoArgs.file, savetoArgs.tmpfile); - return { responseRequired: false }; + return _this.notRequired(); }, _a[CommandNames.Close] = function (request) { var closeArgs = request.arguments; _this.closeClientFile(closeArgs.file); - return { responseRequired: false }; + return _this.notRequired(); }, _a[CommandNames.Navto] = function (request) { - var navtoArgs = request.arguments; - return { response: _this.getNavigateToItems(navtoArgs.searchValue, navtoArgs.file, navtoArgs.maxResultCount, navtoArgs.currentFileOnly), responseRequired: true }; + return _this.requiredResponse(_this.getNavigateToItems(request.arguments, true)); + }, + _a[CommandNames.NavtoFull] = function (request) { + return _this.requiredResponse(_this.getNavigateToItems(request.arguments, false)); }, _a[CommandNames.Brace] = function (request) { - var braceArguments = request.arguments; - return { response: _this.getBraceMatching(braceArguments.line, braceArguments.offset, braceArguments.file), responseRequired: true }; + return _this.requiredResponse(_this.getBraceMatching(request.arguments, true)); + }, + _a[CommandNames.BraceFull] = function (request) { + return _this.requiredResponse(_this.getBraceMatching(request.arguments, false)); }, _a[CommandNames.NavBar] = function (request) { - var navBarArgs = request.arguments; - return { response: _this.getNavigationBarItems(navBarArgs.file), responseRequired: true }; + return _this.requiredResponse(_this.getNavigationBarItems(request.arguments, true)); + }, + _a[CommandNames.NavBarFull] = function (request) { + return _this.requiredResponse(_this.getNavigationBarItems(request.arguments, false)); + }, + _a[CommandNames.NavTree] = function (request) { + return _this.requiredResponse(_this.getNavigationTree(request.arguments, true)); + }, + _a[CommandNames.NavTreeFull] = function (request) { + return _this.requiredResponse(_this.getNavigationTree(request.arguments, false)); }, _a[CommandNames.Occurrences] = function (request) { - var _a = request.arguments, line = _a.line, offset = _a.offset, fileName = _a.file; - return { response: _this.getOccurrences(line, offset, fileName), responseRequired: true }; + return _this.requiredResponse(_this.getOccurrences(request.arguments)); }, _a[CommandNames.DocumentHighlights] = function (request) { - var _a = request.arguments, line = _a.line, offset = _a.offset, fileName = _a.file, filesToSearch = _a.filesToSearch; - return { response: _this.getDocumentHighlights(line, offset, fileName, filesToSearch), responseRequired: true }; + return _this.requiredResponse(_this.getDocumentHighlights(request.arguments, true)); + }, + _a[CommandNames.DocumentHighlightsFull] = function (request) { + return _this.requiredResponse(_this.getDocumentHighlights(request.arguments, false)); + }, + _a[CommandNames.CompilerOptionsForInferredProjects] = function (request) { + return _this.requiredResponse(_this.setCompilerOptionsForInferredProjects(request.arguments)); }, _a[CommandNames.ProjectInfo] = function (request) { - var _a = request.arguments, file = _a.file, needFileNameList = _a.needFileNameList; - return { response: _this.getProjectInfo(file, needFileNameList), responseRequired: true }; + return _this.requiredResponse(_this.getProjectInfo(request.arguments)); }, _a[CommandNames.ReloadProjects] = function (request) { - _this.reloadProjects(); - return { responseRequired: false }; + _this.projectService.reloadProjects(); + return _this.notRequired(); + }, + _a[CommandNames.GetCodeFixes] = function (request) { + return _this.requiredResponse(_this.getCodeFixes(request.arguments, true)); + }, + _a[CommandNames.GetCodeFixesFull] = function (request) { + return _this.requiredResponse(_this.getCodeFixes(request.arguments, false)); + }, + _a[CommandNames.GetSupportedCodeFixes] = function (request) { + return _this.requiredResponse(_this.getSupportedCodeFixes()); }, _a)); - this.projectService = - new server.ProjectService(host, logger, function (event) { - _this.handleEvent(event); - }); + this.eventHander = canUseEvents + ? eventHandler || (function (event) { return _this.defaultEventHandler(event); }) + : undefined; + this.projectService = new server.ProjectService(host, logger, cancellationToken, useSingleInferredProject, typingsInstaller, this.eventHander); + this.gcTimer = new server.GcTimer(host, 7000, logger); var _a; } - Session.prototype.handleEvent = function (event) { + Session.prototype.defaultEventHandler = function (event) { var _this = this; switch (event.eventName) { case "context": var _a = event.data, project = _a.project, fileName = _a.fileName; - this.projectService.log("got context event, updating diagnostics for" + fileName, "Info"); + this.projectService.logger.info("got context event, updating diagnostics for " + fileName); this.updateErrorCheck([{ fileName: fileName, project: project }], this.changeSeq, function (n) { return n === _this.changeSeq; }, 100); break; case "configFileDiag": @@ -60515,26 +63726,23 @@ var ts; } }; Session.prototype.logError = function (err, cmd) { - var typedErr = err; var msg = "Exception on executing command " + cmd; - if (typedErr.message) { - msg += ":\n" + typedErr.message; - if (typedErr.stack) { - msg += "\n" + typedErr.stack; + if (err.message) { + msg += ":\n" + err.message; + if (err.stack) { + msg += "\n" + err.stack; } } - this.projectService.log(msg); - }; - Session.prototype.sendLineToClient = function (line) { - this.host.write(line + this.host.newLine); + this.logger.msg(msg, server.Msg.Err); }; Session.prototype.send = function (msg) { - var json = JSON.stringify(msg); - if (this.logger.isVerbose()) { - this.logger.info(msg.type + ": " + json); + if (msg.type === "event" && !this.canUseEvents) { + if (this.logger.hasLevel(server.LogLevel.verbose)) { + this.logger.info("Session does not support events: ignored event: " + JSON.stringify(msg)); + } + return; } - this.sendLineToClient("Content-Length: " + (1 + this.byteLength(json, "utf8")) + - "\r\n\r\n" + json); + this.host.write(formatMessage(msg, this.logger, this.byteLength, this.host.newLine)); }; Session.prototype.configFileDiagnosticEvent = function (triggerFile, configFile, diagnostics) { var bakedDiags = ts.map(diagnostics, formatConfigFileDiag); @@ -60559,7 +63767,7 @@ var ts; }; this.send(ev); }; - Session.prototype.response = function (info, cmdName, reqSeq, errorMsg) { + Session.prototype.output = function (info, cmdName, reqSeq, errorMsg) { if (reqSeq === void 0) { reqSeq = 0; } var res = { seq: 0, @@ -60576,17 +63784,14 @@ var ts; } this.send(res); }; - Session.prototype.output = function (body, commandName, requestSequence, errorMessage) { - if (requestSequence === void 0) { requestSequence = 0; } - this.response(body, commandName, requestSequence, errorMessage); - }; Session.prototype.semanticCheck = function (file, project) { try { - var diags = project.compilerService.languageService.getSemanticDiagnostics(file); - if (diags) { - var bakedDiags = diags.map(function (diag) { return formatDiag(file, project, diag); }); - this.event({ file: file, diagnostics: bakedDiags }, "semanticDiag"); + var diags = []; + if (!shouldSkipSematicCheck(project)) { + diags = project.getLanguageService().getSemanticDiagnostics(file); } + var bakedDiags = diags.map(function (diag) { return formatDiag(file, project, diag); }); + this.event({ file: file, diagnostics: bakedDiags }, "semanticDiag"); } catch (err) { this.logError(err, "semantic check"); @@ -60594,7 +63799,7 @@ var ts; }; Session.prototype.syntacticCheck = function (file, project) { try { - var diags = project.compilerService.languageService.getSyntacticDiagnostics(file); + var diags = project.getLanguageService().getSyntacticDiagnostics(file); if (diags) { var bakedDiags = diags.map(function (diag) { return formatDiag(file, project, diag); }); this.event({ file: file, diagnostics: bakedDiags }, "syntaxDiag"); @@ -60604,15 +63809,12 @@ var ts; this.logError(err, "syntactic check"); } }; - Session.prototype.reloadProjects = function () { - this.projectService.reloadProjects(); - }; Session.prototype.updateProjectStructure = function (seq, matchSeq, ms) { var _this = this; if (ms === void 0) { ms = 1500; } - setTimeout(function () { + this.host.setTimeout(function () { if (matchSeq(seq)) { - _this.projectService.updateProjectStructure(); + _this.projectService.refreshInferredProjects(); } }, ms); }; @@ -60625,10 +63827,10 @@ var ts; followMs = ms; } if (this.errorTimer) { - clearTimeout(this.errorTimer); + this.host.clearTimeout(this.errorTimer); } if (this.immediateId) { - clearImmediate(this.immediateId); + this.host.clearImmediate(this.immediateId); this.immediateId = undefined; } var index = 0; @@ -60636,13 +63838,13 @@ var ts; if (matchSeq(seq)) { var checkSpec_1 = checkList[index]; index++; - if (checkSpec_1.project.getSourceFileFromName(checkSpec_1.fileName, requireOpen)) { + if (checkSpec_1.project.containsFile(checkSpec_1.fileName, requireOpen)) { _this.syntacticCheck(checkSpec_1.fileName, checkSpec_1.project); - _this.immediateId = setImmediate(function () { + _this.immediateId = _this.host.setImmediate(function () { _this.semanticCheck(checkSpec_1.fileName, checkSpec_1.project); _this.immediateId = undefined; if (checkList.length > index) { - _this.errorTimer = setTimeout(checkOne, followMs); + _this.errorTimer = _this.host.setTimeout(checkOne, followMs); } else { _this.errorTimer = undefined; @@ -60652,78 +63854,133 @@ var ts; } }; if ((checkList.length > index) && (matchSeq(seq))) { - this.errorTimer = setTimeout(checkOne, ms); + this.errorTimer = this.host.setTimeout(checkOne, ms); } }; - Session.prototype.getDefinition = function (line, offset, fileName) { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project || project.languageServiceDiabled) { - throw Errors.NoProject; + Session.prototype.cleanProjects = function (caption, projects) { + if (!projects) { + return; } - var compilerService = project.compilerService; - var position = compilerService.host.lineOffsetToPosition(file, line, offset); - var definitions = compilerService.languageService.getDefinitionAtPosition(file, position); + this.logger.info("cleaning " + caption); + for (var _i = 0, projects_4 = projects; _i < projects_4.length; _i++) { + var p = projects_4[_i]; + p.getLanguageService(false).cleanupSemanticCache(); + } + }; + Session.prototype.cleanup = function () { + this.cleanProjects("inferred projects", this.projectService.inferredProjects); + this.cleanProjects("configured projects", this.projectService.configuredProjects); + this.cleanProjects("external projects", this.projectService.externalProjects); + if (this.host.gc) { + this.logger.info("host.gc()"); + this.host.gc(); + } + }; + Session.prototype.getEncodedSemanticClassifications = function (args) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + return project.getLanguageService().getEncodedSemanticClassifications(file, args); + }; + Session.prototype.getProject = function (projectFileName) { + return projectFileName && this.projectService.findProject(projectFileName); + }; + Session.prototype.getCompilerOptionsDiagnostics = function (args) { + var project = this.getProject(args.projectFileName); + return this.convertToDiagnosticsWithLinePosition(project.getLanguageService().getCompilerOptionsDiagnostics(), undefined); + }; + Session.prototype.convertToDiagnosticsWithLinePosition = function (diagnostics, scriptInfo) { + var _this = this; + return diagnostics.map(function (d) { return ({ + message: ts.flattenDiagnosticMessageText(d.messageText, _this.host.newLine), + start: d.start, + length: d.length, + category: ts.DiagnosticCategory[d.category].toLowerCase(), + code: d.code, + startLocation: scriptInfo && scriptInfo.positionToLineOffset(d.start), + endLocation: scriptInfo && scriptInfo.positionToLineOffset(d.start + d.length) + }); }); + }; + Session.prototype.getDiagnosticsWorker = function (args, selector, includeLinePosition) { + var _a = this.getFileAndProject(args), project = _a.project, file = _a.file; + if (shouldSkipSematicCheck(project)) { + return []; + } + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var diagnostics = selector(project, file); + return includeLinePosition + ? this.convertToDiagnosticsWithLinePosition(diagnostics, scriptInfo) + : diagnostics.map(function (d) { return formatDiag(file, project, d); }); + }; + Session.prototype.getDefinition = function (args, simplifiedResult) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + var definitions = project.getLanguageService().getDefinitionAtPosition(file, position); if (!definitions) { return undefined; } - return definitions.map(function (def) { return ({ - file: def.fileName, - start: compilerService.host.positionToLineOffset(def.fileName, def.textSpan.start), - end: compilerService.host.positionToLineOffset(def.fileName, ts.textSpanEnd(def.textSpan)) - }); }); - }; - Session.prototype.getTypeDefinition = function (line, offset, fileName) { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project || project.languageServiceDiabled) { - throw Errors.NoProject; + if (simplifiedResult) { + return definitions.map(function (def) { + var defScriptInfo = project.getScriptInfo(def.fileName); + return { + file: def.fileName, + start: defScriptInfo.positionToLineOffset(def.textSpan.start), + end: defScriptInfo.positionToLineOffset(ts.textSpanEnd(def.textSpan)) + }; + }); } - var compilerService = project.compilerService; - var position = compilerService.host.lineOffsetToPosition(file, line, offset); - var definitions = compilerService.languageService.getTypeDefinitionAtPosition(file, position); + else { + return definitions; + } + }; + Session.prototype.getTypeDefinition = function (args) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + var definitions = project.getLanguageService().getTypeDefinitionAtPosition(file, position); if (!definitions) { return undefined; } - return definitions.map(function (def) { return ({ - file: def.fileName, - start: compilerService.host.positionToLineOffset(def.fileName, def.textSpan.start), - end: compilerService.host.positionToLineOffset(def.fileName, ts.textSpanEnd(def.textSpan)) - }); }); + return definitions.map(function (def) { + var defScriptInfo = project.getScriptInfo(def.fileName); + return { + file: def.fileName, + start: defScriptInfo.positionToLineOffset(def.textSpan.start), + end: defScriptInfo.positionToLineOffset(ts.textSpanEnd(def.textSpan)) + }; + }); }; - Session.prototype.getImplementation = function (line, offset, fileName) { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project || project.languageServiceDiabled) { - throw Errors.NoProject; - } - var compilerService = project.compilerService; - var implementations = compilerService.languageService.getImplementationAtPosition(file, compilerService.host.lineOffsetToPosition(file, line, offset)); + Session.prototype.getImplementation = function (args, simplifiedResult) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + var implementations = project.getLanguageService().getImplementationAtPosition(file, position); if (!implementations) { - return undefined; + return []; + } + if (simplifiedResult) { + return implementations.map(function (impl) { return ({ + file: impl.fileName, + start: scriptInfo.positionToLineOffset(impl.textSpan.start), + end: scriptInfo.positionToLineOffset(ts.textSpanEnd(impl.textSpan)) + }); }); + } + else { + return implementations; } - return implementations.map(function (impl) { return ({ - file: impl.fileName, - start: compilerService.host.positionToLineOffset(impl.fileName, impl.textSpan.start), - end: compilerService.host.positionToLineOffset(impl.fileName, ts.textSpanEnd(impl.textSpan)) - }); }); }; - Session.prototype.getOccurrences = function (line, offset, fileName) { - fileName = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(fileName); - if (!project || project.languageServiceDiabled) { - throw Errors.NoProject; - } - var compilerService = project.compilerService; - var position = compilerService.host.lineOffsetToPosition(fileName, line, offset); - var occurrences = compilerService.languageService.getOccurrencesAtPosition(fileName, position); + Session.prototype.getOccurrences = function (args) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + var occurrences = project.getLanguageService().getOccurrencesAtPosition(file, position); if (!occurrences) { return undefined; } return occurrences.map(function (occurrence) { var fileName = occurrence.fileName, isWriteAccess = occurrence.isWriteAccess, textSpan = occurrence.textSpan; - var start = compilerService.host.positionToLineOffset(fileName, textSpan.start); - var end = compilerService.host.positionToLineOffset(fileName, ts.textSpanEnd(textSpan)); + var scriptInfo = project.getScriptInfo(fileName); + var start = scriptInfo.positionToLineOffset(textSpan.start); + var end = scriptInfo.positionToLineOffset(ts.textSpanEnd(textSpan)); return { start: start, end: end, @@ -60732,115 +63989,142 @@ var ts; }; }); }; - Session.prototype.getDiagnosticsWorker = function (args, selector) { - var file = ts.normalizePath(args.file); - var project = this.projectService.getProjectForFile(file); - if (!project) { - throw Errors.NoProject; - } - if (project.languageServiceDiabled) { - throw Errors.ProjectLanguageServiceDisabled; - } - var diagnostics = selector(project, file); - return ts.map(diagnostics, function (originalDiagnostic) { return formatDiag(file, project, originalDiagnostic); }); - }; Session.prototype.getSyntacticDiagnosticsSync = function (args) { - return this.getDiagnosticsWorker(args, function (project, file) { return project.compilerService.languageService.getSyntacticDiagnostics(file); }); + return this.getDiagnosticsWorker(args, function (project, file) { return project.getLanguageService().getSyntacticDiagnostics(file); }, args.includeLinePosition); }; Session.prototype.getSemanticDiagnosticsSync = function (args) { - return this.getDiagnosticsWorker(args, function (project, file) { return project.compilerService.languageService.getSemanticDiagnostics(file); }); + return this.getDiagnosticsWorker(args, function (project, file) { return project.getLanguageService().getSemanticDiagnostics(file); }, args.includeLinePosition); }; - Session.prototype.getDocumentHighlights = function (line, offset, fileName, filesToSearch) { - fileName = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(fileName); - if (!project || project.languageServiceDiabled) { - throw Errors.NoProject; - } - var compilerService = project.compilerService; - var position = compilerService.host.lineOffsetToPosition(fileName, line, offset); - var documentHighlights = compilerService.languageService.getDocumentHighlights(fileName, position, filesToSearch); + Session.prototype.getDocumentHighlights = function (args, simplifiedResult) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + var documentHighlights = project.getLanguageService().getDocumentHighlights(file, position, args.filesToSearch); if (!documentHighlights) { return undefined; } - return documentHighlights.map(convertToDocumentHighlightsItem); + if (simplifiedResult) { + return documentHighlights.map(convertToDocumentHighlightsItem); + } + else { + return documentHighlights; + } function convertToDocumentHighlightsItem(documentHighlights) { var fileName = documentHighlights.fileName, highlightSpans = documentHighlights.highlightSpans; + var scriptInfo = project.getScriptInfo(fileName); return { file: fileName, highlightSpans: highlightSpans.map(convertHighlightSpan) }; function convertHighlightSpan(highlightSpan) { var textSpan = highlightSpan.textSpan, kind = highlightSpan.kind; - var start = compilerService.host.positionToLineOffset(fileName, textSpan.start); - var end = compilerService.host.positionToLineOffset(fileName, ts.textSpanEnd(textSpan)); + var start = scriptInfo.positionToLineOffset(textSpan.start); + var end = scriptInfo.positionToLineOffset(ts.textSpanEnd(textSpan)); return { start: start, end: end, kind: kind }; } } }; - Session.prototype.getProjectInfo = function (fileName, needFileNameList) { - fileName = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(fileName); - if (!project) { - throw Errors.NoProject; - } + Session.prototype.setCompilerOptionsForInferredProjects = function (args) { + this.projectService.setCompilerOptionsForInferredProjects(args.options); + }; + Session.prototype.getProjectInfo = function (args) { + return this.getProjectInfoWorker(args.file, args.projectFileName, args.needFileNameList); + }; + Session.prototype.getProjectInfoWorker = function (uncheckedFileName, projectFileName, needFileNameList) { + var project = this.getFileAndProjectWorker(uncheckedFileName, projectFileName, true, true).project; var projectInfo = { - configFileName: project.projectFilename, - languageServiceDisabled: project.languageServiceDiabled + configFileName: project.getProjectName(), + languageServiceDisabled: !project.languageServiceEnabled, + fileNames: needFileNameList ? project.getFileNames() : undefined }; - if (needFileNameList) { - projectInfo.fileNames = project.getFileNames(); - } return projectInfo; }; - Session.prototype.getRenameLocations = function (line, offset, fileName, findInComments, findInStrings) { - var file = ts.normalizePath(fileName); - var info = this.projectService.getScriptInfo(file); - var projects = this.projectService.findReferencingProjects(info); - var projectsWithLanguageServiceEnabeld = ts.filter(projects, function (p) { return !p.languageServiceDiabled; }); - if (projectsWithLanguageServiceEnabeld.length === 0) { - throw Errors.NoProject; - } - var defaultProject = projectsWithLanguageServiceEnabeld[0]; - var defaultProjectCompilerService = defaultProject.compilerService; - var position = defaultProjectCompilerService.host.lineOffsetToPosition(file, line, offset); - var renameInfo = defaultProjectCompilerService.languageService.getRenameInfo(file, position); - if (!renameInfo) { - return undefined; - } - if (!renameInfo.canRename) { - return { - info: renameInfo, - locs: [] - }; - } - var fileSpans = server.combineProjectOutput(projectsWithLanguageServiceEnabeld, function (project) { - var compilerService = project.compilerService; - var renameLocations = compilerService.languageService.findRenameLocations(file, position, findInStrings, findInComments); - if (!renameLocations) { - return []; + Session.prototype.getRenameInfo = function (args) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + return project.getLanguageService().getRenameInfo(file, position); + }; + Session.prototype.getProjects = function (args) { + var projects; + if (args.projectFileName) { + var project = this.getProject(args.projectFileName); + if (project) { + projects = [project]; } - return renameLocations.map(function (location) { return ({ - file: location.fileName, - start: compilerService.host.positionToLineOffset(location.fileName, location.textSpan.start), - end: compilerService.host.positionToLineOffset(location.fileName, ts.textSpanEnd(location.textSpan)) - }); }); - }, compareRenameLocation, function (a, b) { return a.file === b.file && a.start.line === b.start.line && a.start.offset === b.start.offset; }); - var locs = fileSpans.reduce(function (accum, cur) { - var curFileAccum; - if (accum.length > 0) { - curFileAccum = accum[accum.length - 1]; - if (curFileAccum.file !== cur.file) { - curFileAccum = undefined; + } + else { + var scriptInfo = this.projectService.getScriptInfo(args.file); + projects = scriptInfo.containingProjects; + } + projects = ts.filter(projects, function (p) { return p.languageServiceEnabled; }); + if (!projects || !projects.length) { + return server.Errors.ThrowNoProject(); + } + return projects; + }; + Session.prototype.getRenameLocations = function (args, simplifiedResult) { + var file = server.toNormalizedPath(args.file); + var info = this.projectService.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, info); + var projects = this.getProjects(args); + if (simplifiedResult) { + var defaultProject = projects[0]; + var renameInfo = defaultProject.getLanguageService().getRenameInfo(file, position); + if (!renameInfo) { + return undefined; + } + if (!renameInfo.canRename) { + return { + info: renameInfo, + locs: [] + }; + } + var fileSpans = server.combineProjectOutput(projects, function (project) { + var renameLocations = project.getLanguageService().findRenameLocations(file, position, args.findInStrings, args.findInComments); + if (!renameLocations) { + return []; } + return renameLocations.map(function (location) { + var locationScriptInfo = project.getScriptInfo(location.fileName); + return { + file: location.fileName, + start: locationScriptInfo.positionToLineOffset(location.textSpan.start), + end: locationScriptInfo.positionToLineOffset(ts.textSpanEnd(location.textSpan)) + }; + }); + }, compareRenameLocation, function (a, b) { return a.file === b.file && a.start.line === b.start.line && a.start.offset === b.start.offset; }); + var locs = fileSpans.reduce(function (accum, cur) { + var curFileAccum; + if (accum.length > 0) { + curFileAccum = accum[accum.length - 1]; + if (curFileAccum.file !== cur.file) { + curFileAccum = undefined; + } + } + if (!curFileAccum) { + curFileAccum = { file: cur.file, locs: [] }; + accum.push(curFileAccum); + } + curFileAccum.locs.push({ start: cur.start, end: cur.end }); + return accum; + }, []); + return { info: renameInfo, locs: locs }; + } + else { + return server.combineProjectOutput(projects, function (p) { return p.getLanguageService().findRenameLocations(file, position, args.findInStrings, args.findInComments); }, undefined, renameLocationIsEqualTo); + } + function renameLocationIsEqualTo(a, b) { + if (a === b) { + return true; } - if (!curFileAccum) { - curFileAccum = { file: cur.file, locs: [] }; - accum.push(curFileAccum); + if (!a || !b) { + return false; } - curFileAccum.locs.push({ start: cur.start, end: cur.end }); - return accum; - }, []); - return { info: renameInfo, locs: locs }; + return a.fileName === b.fileName && + a.textSpan.start === b.textSpan.start && + a.textSpan.length === b.textSpan.length; + } function compareRenameLocation(a, b) { if (a.file < b.file) { return -1; @@ -60861,51 +64145,51 @@ var ts; } } }; - Session.prototype.getReferences = function (line, offset, fileName) { - var file = ts.normalizePath(fileName); - var info = this.projectService.getScriptInfo(file); - var projects = this.projectService.findReferencingProjects(info); - var projectsWithLanguageServiceEnabeld = ts.filter(projects, function (p) { return !p.languageServiceDiabled; }); - if (projectsWithLanguageServiceEnabeld.length === 0) { - throw Errors.NoProject; - } - var defaultProject = projectsWithLanguageServiceEnabeld[0]; - var position = defaultProject.compilerService.host.lineOffsetToPosition(file, line, offset); - var nameInfo = defaultProject.compilerService.languageService.getQuickInfoAtPosition(file, position); - if (!nameInfo) { - return undefined; - } - var displayString = ts.displayPartsToString(nameInfo.displayParts); - var nameSpan = nameInfo.textSpan; - var nameColStart = defaultProject.compilerService.host.positionToLineOffset(file, nameSpan.start).offset; - var nameText = defaultProject.compilerService.host.getScriptSnapshot(file).getText(nameSpan.start, ts.textSpanEnd(nameSpan)); - var refs = server.combineProjectOutput(projectsWithLanguageServiceEnabeld, function (project) { - var compilerService = project.compilerService; - var references = compilerService.languageService.getReferencesAtPosition(file, position); - if (!references) { - return []; + Session.prototype.getReferences = function (args, simplifiedResult) { + var file = server.toNormalizedPath(args.file); + var projects = this.getProjects(args); + var defaultProject = projects[0]; + var scriptInfo = defaultProject.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + if (simplifiedResult) { + var nameInfo = defaultProject.getLanguageService().getQuickInfoAtPosition(file, position); + if (!nameInfo) { + return undefined; } - return references.map(function (ref) { - var start = compilerService.host.positionToLineOffset(ref.fileName, ref.textSpan.start); - var refLineSpan = compilerService.host.lineToTextSpan(ref.fileName, start.line - 1); - var snap = compilerService.host.getScriptSnapshot(ref.fileName); - var lineText = snap.getText(refLineSpan.start, ts.textSpanEnd(refLineSpan)).replace(/\r|\n/g, ""); - return { - file: ref.fileName, - start: start, - lineText: lineText, - end: compilerService.host.positionToLineOffset(ref.fileName, ts.textSpanEnd(ref.textSpan)), - isWriteAccess: ref.isWriteAccess, - isDefinition: ref.isDefinition - }; - }); - }, compareFileStart, areReferencesResponseItemsForTheSameLocation); - return { - refs: refs, - symbolName: nameText, - symbolStartOffset: nameColStart, - symbolDisplayString: displayString - }; + var displayString = ts.displayPartsToString(nameInfo.displayParts); + var nameSpan = nameInfo.textSpan; + var nameColStart = scriptInfo.positionToLineOffset(nameSpan.start).offset; + var nameText = scriptInfo.snap().getText(nameSpan.start, ts.textSpanEnd(nameSpan)); + var refs = server.combineProjectOutput(projects, function (project) { + var references = project.getLanguageService().getReferencesAtPosition(file, position); + if (!references) { + return []; + } + return references.map(function (ref) { + var refScriptInfo = project.getScriptInfo(ref.fileName); + var start = refScriptInfo.positionToLineOffset(ref.textSpan.start); + var refLineSpan = refScriptInfo.lineToTextSpan(start.line - 1); + var lineText = refScriptInfo.snap().getText(refLineSpan.start, ts.textSpanEnd(refLineSpan)).replace(/\r|\n/g, ""); + return { + file: ref.fileName, + start: start, + lineText: lineText, + end: refScriptInfo.positionToLineOffset(ts.textSpanEnd(ref.textSpan)), + isWriteAccess: ref.isWriteAccess, + isDefinition: ref.isDefinition + }; + }); + }, compareFileStart, areReferencesResponseItemsForTheSameLocation); + return { + refs: refs, + symbolName: nameText, + symbolStartOffset: nameColStart, + symbolDisplayString: displayString + }; + } + else { + return server.combineProjectOutput(projects, function (project) { return project.getLanguageService().findReferences(file, position); }, undefined, undefined); + } function areReferencesResponseItemsForTheSameLocation(a, b) { if (a && b) { return a.file === b.file && @@ -60916,102 +64200,150 @@ var ts; } }; Session.prototype.openClientFile = function (fileName, fileContent, scriptKind) { - var file = ts.normalizePath(fileName); - var _a = this.projectService.openClientFile(file, fileContent, scriptKind), configFileName = _a.configFileName, configFileErrors = _a.configFileErrors; - if (configFileErrors) { - this.configFileDiagnosticEvent(fileName, configFileName, configFileErrors); + var _a = this.projectService.openClientFileWithNormalizedPath(fileName, fileContent, scriptKind), configFileName = _a.configFileName, configFileErrors = _a.configFileErrors; + if (this.eventHander) { + this.eventHander({ + eventName: "configFileDiag", + data: { fileName: fileName, configFileName: configFileName, diagnostics: configFileErrors || [] } + }); } }; - Session.prototype.getQuickInfo = function (line, offset, fileName) { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project || project.languageServiceDiabled) { - throw Errors.NoProject; + Session.prototype.getPosition = function (args, scriptInfo) { + return args.position !== undefined ? args.position : scriptInfo.lineOffsetToPosition(args.line, args.offset); + }; + Session.prototype.getFileAndProject = function (args, errorOnMissingProject) { + if (errorOnMissingProject === void 0) { errorOnMissingProject = true; } + return this.getFileAndProjectWorker(args.file, args.projectFileName, true, errorOnMissingProject); + }; + Session.prototype.getFileAndProjectWithoutRefreshingInferredProjects = function (args, errorOnMissingProject) { + if (errorOnMissingProject === void 0) { errorOnMissingProject = true; } + return this.getFileAndProjectWorker(args.file, args.projectFileName, false, errorOnMissingProject); + }; + Session.prototype.getFileAndProjectWorker = function (uncheckedFileName, projectFileName, refreshInferredProjects, errorOnMissingProject) { + var file = server.toNormalizedPath(uncheckedFileName); + var project = this.getProject(projectFileName) || this.projectService.getDefaultProjectForFile(file, refreshInferredProjects); + if (!project && errorOnMissingProject) { + return server.Errors.ThrowNoProject(); } - var compilerService = project.compilerService; - var position = compilerService.host.lineOffsetToPosition(file, line, offset); - var quickInfo = compilerService.languageService.getQuickInfoAtPosition(file, position); + return { file: file, project: project }; + }; + Session.prototype.getOutliningSpans = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + return project.getLanguageService(false).getOutliningSpans(file); + }; + Session.prototype.getTodoComments = function (args) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + return project.getLanguageService().getTodoComments(file, args.descriptors); + }; + Session.prototype.getDocCommentTemplate = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + return project.getLanguageService(false).getDocCommentTemplateAtPosition(file, position); + }; + Session.prototype.getIndentation = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); + var options = args.options || this.projectService.getFormatCodeOptions(file); + var indentation = project.getLanguageService(false).getIndentationAtPosition(file, position, options); + return { position: position, indentation: indentation }; + }; + Session.prototype.getBreakpointStatement = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); + return project.getLanguageService(false).getBreakpointStatementAtPosition(file, position); + }; + Session.prototype.getNameOrDottedNameSpan = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); + return project.getLanguageService(false).getNameOrDottedNameSpan(file, position, position); + }; + Session.prototype.isValidBraceCompletion = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); + return project.getLanguageService(false).isValidBraceCompletionAtPosition(file, position, args.openingBrace.charCodeAt(0)); + }; + Session.prototype.getQuickInfoWorker = function (args, simplifiedResult) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var quickInfo = project.getLanguageService().getQuickInfoAtPosition(file, this.getPosition(args, scriptInfo)); if (!quickInfo) { return undefined; } - var displayString = ts.displayPartsToString(quickInfo.displayParts); - var docString = ts.displayPartsToString(quickInfo.documentation); - return { - kind: quickInfo.kind, - kindModifiers: quickInfo.kindModifiers, - start: compilerService.host.positionToLineOffset(file, quickInfo.textSpan.start), - end: compilerService.host.positionToLineOffset(file, ts.textSpanEnd(quickInfo.textSpan)), - displayString: displayString, - documentation: docString - }; - }; - Session.prototype.getFormattingEditsForRange = function (line, offset, endLine, endOffset, fileName) { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project || project.languageServiceDiabled) { - throw Errors.NoProject; + if (simplifiedResult) { + var displayString = ts.displayPartsToString(quickInfo.displayParts); + var docString = ts.displayPartsToString(quickInfo.documentation); + return { + kind: quickInfo.kind, + kindModifiers: quickInfo.kindModifiers, + start: scriptInfo.positionToLineOffset(quickInfo.textSpan.start), + end: scriptInfo.positionToLineOffset(ts.textSpanEnd(quickInfo.textSpan)), + displayString: displayString, + documentation: docString + }; } - var compilerService = project.compilerService; - var startPosition = compilerService.host.lineOffsetToPosition(file, line, offset); - var endPosition = compilerService.host.lineOffsetToPosition(file, endLine, endOffset); - var edits = compilerService.languageService.getFormattingEditsForRange(file, startPosition, endPosition, this.projectService.getFormatCodeOptions(file)); + else { + return quickInfo; + } + }; + Session.prototype.getFormattingEditsForRange = function (args) { + var _this = this; + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var startPosition = scriptInfo.lineOffsetToPosition(args.line, args.offset); + var endPosition = scriptInfo.lineOffsetToPosition(args.endLine, args.endOffset); + var edits = project.getLanguageService(false).getFormattingEditsForRange(file, startPosition, endPosition, this.projectService.getFormatCodeOptions(file)); if (!edits) { return undefined; } - return edits.map(function (edit) { - return { - start: compilerService.host.positionToLineOffset(file, edit.span.start), - end: compilerService.host.positionToLineOffset(file, ts.textSpanEnd(edit.span)), - newText: edit.newText ? edit.newText : "" - }; - }); + return edits.map(function (edit) { return _this.convertTextChangeToCodeEdit(edit, scriptInfo); }); }; - Session.prototype.getFormattingEditsAfterKeystroke = function (line, offset, key, fileName) { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project || project.languageServiceDiabled) { - throw Errors.NoProject; - } - var compilerService = project.compilerService; - var position = compilerService.host.lineOffsetToPosition(file, line, offset); + Session.prototype.getFormattingEditsForRangeFull = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var options = args.options || this.projectService.getFormatCodeOptions(file); + return project.getLanguageService(false).getFormattingEditsForRange(file, args.position, args.endPosition, options); + }; + Session.prototype.getFormattingEditsForDocumentFull = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var options = args.options || this.projectService.getFormatCodeOptions(file); + return project.getLanguageService(false).getFormattingEditsForDocument(file, options); + }; + Session.prototype.getFormattingEditsAfterKeystrokeFull = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var options = args.options || this.projectService.getFormatCodeOptions(file); + return project.getLanguageService(false).getFormattingEditsAfterKeystroke(file, args.position, args.key, options); + }; + Session.prototype.getFormattingEditsAfterKeystroke = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = scriptInfo.lineOffsetToPosition(args.line, args.offset); var formatOptions = this.projectService.getFormatCodeOptions(file); - var edits = compilerService.languageService.getFormattingEditsAfterKeystroke(file, position, key, formatOptions); - if ((key == "\n") && ((!edits) || (edits.length === 0) || allEditsBeforePos(edits, position))) { - var scriptInfo = compilerService.host.getScriptInfo(file); - if (scriptInfo) { - var lineInfo = scriptInfo.getLineInfo(line); - if (lineInfo && (lineInfo.leaf) && (lineInfo.leaf.text)) { - var lineText = lineInfo.leaf.text; - if (lineText.search("\\S") < 0) { - var editorOptions = { - BaseIndentSize: formatOptions.BaseIndentSize, - IndentSize: formatOptions.IndentSize, - TabSize: formatOptions.TabSize, - NewLineCharacter: formatOptions.NewLineCharacter, - ConvertTabsToSpaces: formatOptions.ConvertTabsToSpaces, - IndentStyle: ts.IndentStyle.Smart - }; - var preferredIndent = compilerService.languageService.getIndentationAtPosition(file, position, editorOptions); - var hasIndent = 0; - var i = void 0, len = void 0; - for (i = 0, len = lineText.length; i < len; i++) { - if (lineText.charAt(i) == " ") { - hasIndent++; - } - else if (lineText.charAt(i) == "\t") { - hasIndent += editorOptions.TabSize; - } - else { - break; - } + var edits = project.getLanguageService(false).getFormattingEditsAfterKeystroke(file, position, args.key, formatOptions); + if ((args.key == "\n") && ((!edits) || (edits.length === 0) || allEditsBeforePos(edits, position))) { + var lineInfo = scriptInfo.getLineInfo(args.line); + if (lineInfo && (lineInfo.leaf) && (lineInfo.leaf.text)) { + var lineText = lineInfo.leaf.text; + if (lineText.search("\\S") < 0) { + var preferredIndent = project.getLanguageService(false).getIndentationAtPosition(file, position, formatOptions); + var hasIndent = 0; + var i = void 0, len = void 0; + for (i = 0, len = lineText.length; i < len; i++) { + if (lineText.charAt(i) == " ") { + hasIndent++; } - if (preferredIndent !== hasIndent) { - var firstNoWhiteSpacePosition = lineInfo.offset + i; - edits.push({ - span: ts.createTextSpanFromBounds(lineInfo.offset, firstNoWhiteSpacePosition), - newText: generateIndentString(preferredIndent, editorOptions) - }); + else if (lineText.charAt(i) == "\t") { + hasIndent += formatOptions.tabSize; } + else { + break; + } + } + if (preferredIndent !== hasIndent) { + var firstNoWhiteSpacePosition = lineInfo.offset + i; + edits.push({ + span: ts.createTextSpanFromBounds(lineInfo.offset, firstNoWhiteSpacePosition), + newText: ts.formatting.getIndentationString(preferredIndent, formatOptions) + }); } } } @@ -61021,89 +64353,106 @@ var ts; } return edits.map(function (edit) { return { - start: compilerService.host.positionToLineOffset(file, edit.span.start), - end: compilerService.host.positionToLineOffset(file, ts.textSpanEnd(edit.span)), + start: scriptInfo.positionToLineOffset(edit.span.start), + end: scriptInfo.positionToLineOffset(ts.textSpanEnd(edit.span)), newText: edit.newText ? edit.newText : "" }; }); }; - Session.prototype.getCompletions = function (line, offset, prefix, fileName) { - if (!prefix) { - prefix = ""; - } - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project || project.languageServiceDiabled) { - throw Errors.NoProject; - } - var compilerService = project.compilerService; - var position = compilerService.host.lineOffsetToPosition(file, line, offset); - var completions = compilerService.languageService.getCompletionsAtPosition(file, position); + Session.prototype.getCompletions = function (args, simplifiedResult) { + var _this = this; + var prefix = args.prefix || ""; + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + var completions = project.getLanguageService().getCompletionsAtPosition(file, position); if (!completions) { return undefined; } - return completions.entries.reduce(function (result, entry) { - if (completions.isMemberCompletion || (entry.name.toLowerCase().indexOf(prefix.toLowerCase()) === 0)) { - var name_52 = entry.name, kind = entry.kind, kindModifiers = entry.kindModifiers, sortText = entry.sortText, replacementSpan = entry.replacementSpan; - var convertedSpan = undefined; - if (replacementSpan) { - convertedSpan = { - start: compilerService.host.positionToLineOffset(fileName, replacementSpan.start), - end: compilerService.host.positionToLineOffset(fileName, replacementSpan.start + replacementSpan.length) - }; + if (simplifiedResult) { + return completions.entries.reduce(function (result, entry) { + if (completions.isMemberCompletion || (entry.name.toLowerCase().indexOf(prefix.toLowerCase()) === 0)) { + var name_53 = entry.name, kind = entry.kind, kindModifiers = entry.kindModifiers, sortText = entry.sortText, replacementSpan = entry.replacementSpan; + var convertedSpan = replacementSpan ? _this.decorateSpan(replacementSpan, scriptInfo) : undefined; + result.push({ name: name_53, kind: kind, kindModifiers: kindModifiers, sortText: sortText, replacementSpan: convertedSpan }); } - result.push({ name: name_52, kind: kind, kindModifiers: kindModifiers, sortText: sortText, replacementSpan: convertedSpan }); - } - return result; - }, []).sort(function (a, b) { return a.name.localeCompare(b.name); }); - }; - Session.prototype.getCompletionEntryDetails = function (line, offset, entryNames, fileName) { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project || project.languageServiceDiabled) { - throw Errors.NoProject; + return result; + }, []).sort(function (a, b) { return a.name.localeCompare(b.name); }); } - var compilerService = project.compilerService; - var position = compilerService.host.lineOffsetToPosition(file, line, offset); - return entryNames.reduce(function (accum, entryName) { - var details = compilerService.languageService.getCompletionEntryDetails(file, position, entryName); + else { + return completions; + } + }; + Session.prototype.getCompletionEntryDetails = function (args) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + return args.entryNames.reduce(function (accum, entryName) { + var details = project.getLanguageService().getCompletionEntryDetails(file, position, entryName); if (details) { accum.push(details); } return accum; }, []); }; - Session.prototype.getSignatureHelpItems = function (line, offset, fileName) { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project || project.languageServiceDiabled) { - throw Errors.NoProject; + Session.prototype.getCompileOnSaveAffectedFileList = function (args) { + var info = this.projectService.getScriptInfo(args.file); + var result = []; + if (!info) { + return []; } - var compilerService = project.compilerService; - var position = compilerService.host.lineOffsetToPosition(file, line, offset); - var helpItems = compilerService.languageService.getSignatureHelpItems(file, position); + var projectsToSearch = args.projectFileName ? [this.projectService.findProject(args.projectFileName)] : info.containingProjects; + for (var _i = 0, projectsToSearch_1 = projectsToSearch; _i < projectsToSearch_1.length; _i++) { + var project = projectsToSearch_1[_i]; + if (project.compileOnSaveEnabled && project.languageServiceEnabled) { + result.push({ + projectFileName: project.getProjectName(), + fileNames: project.getCompileOnSaveAffectedFileList(info) + }); + } + } + return result; + }; + Session.prototype.emitFile = function (args) { + var _this = this; + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + if (!project) { + server.Errors.ThrowNoProject(); + } + var scriptInfo = project.getScriptInfo(file); + return project.builder.emitFile(scriptInfo, function (path, data, writeByteOrderMark) { return _this.host.writeFile(path, data, writeByteOrderMark); }); + }; + Session.prototype.getSignatureHelpItems = function (args, simplifiedResult) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + var helpItems = project.getLanguageService().getSignatureHelpItems(file, position); if (!helpItems) { return undefined; } - var span = helpItems.applicableSpan; - var result = { - items: helpItems.items, - applicableSpan: { - start: compilerService.host.positionToLineOffset(file, span.start), - end: compilerService.host.positionToLineOffset(file, span.start + span.length) - }, - selectedItemIndex: helpItems.selectedItemIndex, - argumentIndex: helpItems.argumentIndex, - argumentCount: helpItems.argumentCount - }; - return result; + if (simplifiedResult) { + var span_16 = helpItems.applicableSpan; + return { + items: helpItems.items, + applicableSpan: { + start: scriptInfo.positionToLineOffset(span_16.start), + end: scriptInfo.positionToLineOffset(span_16.start + span_16.length) + }, + selectedItemIndex: helpItems.selectedItemIndex, + argumentIndex: helpItems.argumentIndex, + argumentCount: helpItems.argumentCount + }; + } + else { + return helpItems; + } }; Session.prototype.getDiagnostics = function (delay, fileNames) { var _this = this; - var checkList = fileNames.reduce(function (accum, fileName) { - fileName = ts.normalizePath(fileName); - var project = _this.projectService.getProjectForFile(fileName); - if (project && !project.languageServiceDiabled) { + var checkList = fileNames.reduce(function (accum, uncheckedFileName) { + var fileName = server.toNormalizedPath(uncheckedFileName); + var project = _this.projectService.getDefaultProjectForFile(fileName, true); + if (project) { accum.push({ fileName: fileName, project: project }); } return accum; @@ -61112,40 +64461,34 @@ var ts; this.updateErrorCheck(checkList, this.changeSeq, function (n) { return n === _this.changeSeq; }, delay); } }; - Session.prototype.change = function (line, offset, endLine, endOffset, insertString, fileName) { + Session.prototype.change = function (args) { var _this = this; - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (project && !project.languageServiceDiabled) { - var compilerService = project.compilerService; - var start = compilerService.host.lineOffsetToPosition(file, line, offset); - var end = compilerService.host.lineOffsetToPosition(file, endLine, endOffset); + var _a = this.getFileAndProject(args, false), file = _a.file, project = _a.project; + if (project) { + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var start = scriptInfo.lineOffsetToPosition(args.line, args.offset); + var end = scriptInfo.lineOffsetToPosition(args.endLine, args.endOffset); if (start >= 0) { - compilerService.host.editScript(file, start, end, insertString); + scriptInfo.editContent(start, end, args.insertString); this.changeSeq++; } this.updateProjectStructure(this.changeSeq, function (n) { return n === _this.changeSeq; }); } }; - Session.prototype.reload = function (fileName, tempFileName, reqSeq) { - var _this = this; - if (reqSeq === void 0) { reqSeq = 0; } - var file = ts.normalizePath(fileName); - var tmpfile = ts.normalizePath(tempFileName); - var project = this.projectService.getProjectForFile(file); - if (project && !project.languageServiceDiabled) { + Session.prototype.reload = function (args, reqSeq) { + var file = server.toNormalizedPath(args.file); + var project = this.projectService.getDefaultProjectForFile(file, true); + if (project) { this.changeSeq++; - project.compilerService.host.reloadScript(file, tmpfile, function () { - _this.output(undefined, CommandNames.Reload, reqSeq); - }); + if (project.reloadScript(file)) { + this.output(undefined, CommandNames.Reload, reqSeq); + } } }; Session.prototype.saveToTmp = function (fileName, tempFileName) { - var file = ts.normalizePath(fileName); - var tmpfile = ts.normalizePath(tempFileName); - var project = this.projectService.getProjectForFile(file); - if (project && !project.languageServiceDiabled) { - project.compilerService.host.saveTo(file, tmpfile); + var scriptInfo = this.projectService.getScriptInfo(fileName); + if (scriptInfo) { + scriptInfo.saveTo(tempFileName); } }; Session.prototype.closeClientFile = function (fileName) { @@ -61155,77 +64498,108 @@ var ts; var file = ts.normalizePath(fileName); this.projectService.closeClientFile(file); }; - Session.prototype.decorateNavigationBarItem = function (project, fileName, items, lineIndex) { + Session.prototype.decorateNavigationBarItems = function (items, scriptInfo) { var _this = this; - if (!items) { - return undefined; - } - var compilerService = project.compilerService; - return items.map(function (item) { return ({ + return ts.map(items, function (item) { return ({ text: item.text, kind: item.kind, kindModifiers: item.kindModifiers, - spans: item.spans.map(function (span) { return ({ - start: compilerService.host.positionToLineOffset(fileName, span.start, lineIndex), - end: compilerService.host.positionToLineOffset(fileName, ts.textSpanEnd(span), lineIndex) - }); }), - childItems: _this.decorateNavigationBarItem(project, fileName, item.childItems, lineIndex), + spans: item.spans.map(function (span) { return _this.decorateSpan(span, scriptInfo); }), + childItems: _this.decorateNavigationBarItems(item.childItems, scriptInfo), indent: item.indent }); }); }; - Session.prototype.getNavigationBarItems = function (fileName) { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project || project.languageServiceDiabled) { - throw Errors.NoProject; - } - var compilerService = project.compilerService; - var items = compilerService.languageService.getNavigationBarItems(file); - if (!items) { - return undefined; - } - return this.decorateNavigationBarItem(project, fileName, items, compilerService.host.getLineIndex(fileName)); + Session.prototype.getNavigationBarItems = function (args, simplifiedResult) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var items = project.getLanguageService(false).getNavigationBarItems(file); + return !items + ? undefined + : simplifiedResult + ? this.decorateNavigationBarItems(items, project.getScriptInfoForNormalizedPath(file)) + : items; }; - Session.prototype.getNavigateToItems = function (searchValue, fileName, maxResultCount, currentFileOnly) { - var file = ts.normalizePath(fileName); - var info = this.projectService.getScriptInfo(file); - var projects = this.projectService.findReferencingProjects(info); - var projectsWithLanguageServiceEnabeld = ts.filter(projects, function (p) { return !p.languageServiceDiabled; }); - if (projectsWithLanguageServiceEnabeld.length === 0) { - throw Errors.NoProject; + Session.prototype.decorateNavigationTree = function (tree, scriptInfo) { + var _this = this; + return { + text: tree.text, + kind: tree.kind, + kindModifiers: tree.kindModifiers, + spans: tree.spans.map(function (span) { return _this.decorateSpan(span, scriptInfo); }), + childItems: ts.map(tree.childItems, function (item) { return _this.decorateNavigationTree(item, scriptInfo); }) + }; + }; + Session.prototype.decorateSpan = function (span, scriptInfo) { + return { + start: scriptInfo.positionToLineOffset(span.start), + end: scriptInfo.positionToLineOffset(ts.textSpanEnd(span)) + }; + }; + Session.prototype.getNavigationTree = function (args, simplifiedResult) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var tree = project.getLanguageService(false).getNavigationTree(file); + return !tree + ? undefined + : simplifiedResult + ? this.decorateNavigationTree(tree, project.getScriptInfoForNormalizedPath(file)) + : tree; + }; + Session.prototype.getNavigateToItems = function (args, simplifiedResult) { + var projects = this.getProjects(args); + var fileName = args.currentFileOnly ? args.file && ts.normalizeSlashes(args.file) : undefined; + if (simplifiedResult) { + return server.combineProjectOutput(projects, function (project) { + var navItems = project.getLanguageService().getNavigateToItems(args.searchValue, args.maxResultCount, fileName, project.isNonTsProject()); + if (!navItems) { + return []; + } + return navItems.map(function (navItem) { + var scriptInfo = project.getScriptInfo(navItem.fileName); + var start = scriptInfo.positionToLineOffset(navItem.textSpan.start); + var end = scriptInfo.positionToLineOffset(ts.textSpanEnd(navItem.textSpan)); + var bakedItem = { + name: navItem.name, + kind: navItem.kind, + file: navItem.fileName, + start: start, + end: end + }; + if (navItem.kindModifiers && (navItem.kindModifiers !== "")) { + bakedItem.kindModifiers = navItem.kindModifiers; + } + if (navItem.matchKind !== "none") { + bakedItem.matchKind = navItem.matchKind; + } + if (navItem.containerName && (navItem.containerName.length > 0)) { + bakedItem.containerName = navItem.containerName; + } + if (navItem.containerKind && (navItem.containerKind.length > 0)) { + bakedItem.containerKind = navItem.containerKind; + } + return bakedItem; + }); + }, undefined, areNavToItemsForTheSameLocation); } - var allNavToItems = server.combineProjectOutput(projectsWithLanguageServiceEnabeld, function (project) { - var compilerService = project.compilerService; - var navItems = compilerService.languageService.getNavigateToItems(searchValue, maxResultCount, currentFileOnly ? fileName : undefined); - if (!navItems) { - return []; + else { + return server.combineProjectOutput(projects, function (project) { return project.getLanguageService().getNavigateToItems(args.searchValue, args.maxResultCount, fileName, project.isNonTsProject()); }, undefined, navigateToItemIsEqualTo); + } + function navigateToItemIsEqualTo(a, b) { + if (a === b) { + return true; } - return navItems.map(function (navItem) { - var start = compilerService.host.positionToLineOffset(navItem.fileName, navItem.textSpan.start); - var end = compilerService.host.positionToLineOffset(navItem.fileName, ts.textSpanEnd(navItem.textSpan)); - var bakedItem = { - name: navItem.name, - kind: navItem.kind, - file: navItem.fileName, - start: start, - end: end - }; - if (navItem.kindModifiers && (navItem.kindModifiers !== "")) { - bakedItem.kindModifiers = navItem.kindModifiers; - } - if (navItem.matchKind !== "none") { - bakedItem.matchKind = navItem.matchKind; - } - if (navItem.containerName && (navItem.containerName.length > 0)) { - bakedItem.containerName = navItem.containerName; - } - if (navItem.containerKind && (navItem.containerKind.length > 0)) { - bakedItem.containerKind = navItem.containerKind; - } - return bakedItem; - }); - }, undefined, areNavToItemsForTheSameLocation); - return allNavToItems; + if (!a || !b) { + return false; + } + return a.containerKind === b.containerKind && + a.containerName === b.containerName && + a.fileName === b.fileName && + a.isCaseSensitive === b.isCaseSensitive && + a.kind === b.kind && + a.kindModifiers === b.containerName && + a.matchKind === b.matchKind && + a.name === b.name && + a.textSpan.start === b.textSpan.start && + a.textSpan.length === b.textSpan.length; + } function areNavToItemsForTheSameLocation(a, b) { if (a && b) { return a.file === b.file && @@ -61235,26 +64609,64 @@ var ts; return false; } }; - Session.prototype.getBraceMatching = function (line, offset, fileName) { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project || project.languageServiceDiabled) { - throw Errors.NoProject; - } - var compilerService = project.compilerService; - var position = compilerService.host.lineOffsetToPosition(file, line, offset); - var spans = compilerService.languageService.getBraceMatchingAtPosition(file, position); - if (!spans) { + Session.prototype.getSupportedCodeFixes = function () { + return ts.getSupportedCodeFixes(); + }; + Session.prototype.getCodeFixes = function (args, simplifiedResult) { + var _this = this; + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var startPosition = getStartPosition(); + var endPosition = getEndPosition(); + var codeActions = project.getLanguageService().getCodeFixesAtPosition(file, startPosition, endPosition, args.errorCodes); + if (!codeActions) { return undefined; } - return spans.map(function (span) { return ({ - start: compilerService.host.positionToLineOffset(file, span.start), - end: compilerService.host.positionToLineOffset(file, span.start + span.length) - }); }); + if (simplifiedResult) { + return codeActions.map(function (codeAction) { return _this.mapCodeAction(codeAction, scriptInfo); }); + } + else { + return codeActions; + } + function getStartPosition() { + return args.startPosition !== undefined ? args.startPosition : scriptInfo.lineOffsetToPosition(args.startLine, args.startOffset); + } + function getEndPosition() { + return args.endPosition !== undefined ? args.endPosition : scriptInfo.lineOffsetToPosition(args.endLine, args.endOffset); + } + }; + Session.prototype.mapCodeAction = function (codeAction, scriptInfo) { + var _this = this; + return { + description: codeAction.description, + changes: codeAction.changes.map(function (change) { return ({ + fileName: change.fileName, + textChanges: change.textChanges.map(function (textChange) { return _this.convertTextChangeToCodeEdit(textChange, scriptInfo); }) + }); }) + }; + }; + Session.prototype.convertTextChangeToCodeEdit = function (change, scriptInfo) { + return { + start: scriptInfo.positionToLineOffset(change.span.start), + end: scriptInfo.positionToLineOffset(change.span.start + change.span.length), + newText: change.newText ? change.newText : "" + }; + }; + Session.prototype.getBraceMatching = function (args, simplifiedResult) { + var _this = this; + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + var spans = project.getLanguageService(false).getBraceMatchingAtPosition(file, position); + return !spans + ? undefined + : simplifiedResult + ? spans.map(function (span) { return _this.decorateSpan(span, scriptInfo); }) + : spans; }; Session.prototype.getDiagnosticsForProject = function (delay, fileName) { var _this = this; - var _a = this.getProjectInfo(fileName, true), fileNames = _a.fileNames, languageServiceDisabled = _a.languageServiceDisabled; + var _a = this.getProjectInfoWorker(fileName, undefined, true), fileNames = _a.fileNames, languageServiceDisabled = _a.languageServiceDisabled; if (languageServiceDisabled) { return; } @@ -61263,8 +64675,8 @@ var ts; var mediumPriorityFiles = []; var lowPriorityFiles = []; var veryLowPriorityFiles = []; - var normalizedFileName = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(normalizedFileName); + var normalizedFileName = server.toNormalizedPath(fileName); + var project = this.projectService.getDefaultProjectForFile(normalizedFileName, true); for (var _i = 0, fileNamesInProject_1 = fileNamesInProject; _i < fileNamesInProject_1.length; _i++) { var fileNameInProject = fileNamesInProject_1[_i]; if (this.getCanonicalFileName(fileNameInProject) == this.getCanonicalFileName(fileName)) @@ -61283,10 +64695,7 @@ var ts; } fileNamesInProject = highPriorityFiles.concat(mediumPriorityFiles).concat(lowPriorityFiles).concat(veryLowPriorityFiles); if (fileNamesInProject.length > 0) { - var checkList = fileNamesInProject.map(function (fileName) { - var normalizedFileName = ts.normalizePath(fileName); - return { fileName: normalizedFileName, project: project }; - }); + var checkList = fileNamesInProject.map(function (fileName) { return ({ fileName: fileName, project: project }); }); this.updateErrorCheck(checkList, this.changeSeq, function (n) { return n == _this.changeSeq; }, delay, 200, false); } }; @@ -61296,6 +64705,9 @@ var ts; }; Session.prototype.exit = function () { }; + Session.prototype.notRequired = function () { + return { responseRequired: false }; + }; Session.prototype.requiredResponse = function (response) { return { response: response, responseRequired: true }; }; @@ -61311,31 +64723,32 @@ var ts; return handler(request); } else { - this.projectService.log("Unrecognized JSON command: " + JSON.stringify(request)); + this.logger.msg("Unrecognized JSON command: " + JSON.stringify(request), server.Msg.Err); this.output(undefined, CommandNames.Unknown, request.seq, "Unrecognized JSON command: " + request.command); return { responseRequired: false }; } }; Session.prototype.onMessage = function (message) { + this.gcTimer.scheduleCollect(); var start; - if (this.logger.isVerbose()) { - this.logger.info("request: " + message); + if (this.logger.hasLevel(server.LogLevel.requestTime)) { start = this.hrtime(); + if (this.logger.hasLevel(server.LogLevel.verbose)) { + this.logger.info("request: " + message); + } } var request; try { request = JSON.parse(message); var _a = this.executeCommand(request), response = _a.response, responseRequired = _a.responseRequired; - if (this.logger.isVerbose()) { - var elapsed = this.hrtime(start); - var seconds = elapsed[0]; - var nanoseconds = elapsed[1]; - var elapsedMs = ((1e9 * seconds) + nanoseconds) / 1000000.0; - var leader = "Elapsed time (in milliseconds)"; - if (!responseRequired) { - leader = "Async elapsed time (in milliseconds)"; + if (this.logger.hasLevel(server.LogLevel.requestTime)) { + var elapsedTime = hrTimeToMilliseconds(this.hrtime(start)).toFixed(4); + if (responseRequired) { + this.logger.perftrc(request.seq + "::" + request.command + ": elapsed time (in milliseconds) " + elapsedTime); + } + else { + this.logger.perftrc(request.seq + "::" + request.command + ": async elapsed time (in milliseconds) " + elapsedTime); } - this.logger.msg(leader + ": " + elapsedMs.toFixed(4).toString(), "Perf"); } if (response) { this.output(response, request.command, request.seq); @@ -61346,6 +64759,8 @@ var ts; } catch (err) { if (err instanceof ts.OperationCanceledException) { + this.output({ canceled: true }, request.command, request.seq); + return; } this.logError(err, message); this.output(undefined, request ? request.command : CommandNames.Unknown, request ? request.seq : 0, "Error processing request. " + err.message + "\n" + err.stack); @@ -61361,1229 +64776,6 @@ var ts; var server; (function (server) { var lineCollectionCapacity = 4; - function mergeFormatOptions(formatCodeOptions, formatOptions) { - var hasOwnProperty = Object.prototype.hasOwnProperty; - Object.keys(formatOptions).forEach(function (key) { - var codeKey = key.charAt(0).toUpperCase() + key.substring(1); - if (hasOwnProperty.call(formatCodeOptions, codeKey)) { - formatCodeOptions[codeKey] = formatOptions[key]; - } - }); - } - server.maxProgramSizeForNonTsFiles = 20 * 1024 * 1024; - var ScriptInfo = (function () { - function ScriptInfo(host, fileName, content, isOpen) { - if (isOpen === void 0) { isOpen = false; } - this.host = host; - this.fileName = fileName; - this.isOpen = isOpen; - this.children = []; - this.formatCodeOptions = ts.clone(CompilerService.getDefaultFormatCodeOptions(this.host)); - this.path = ts.toPath(fileName, host.getCurrentDirectory(), ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames)); - this.svc = ScriptVersionCache.fromString(host, content); - } - ScriptInfo.prototype.setFormatOptions = function (formatOptions) { - if (formatOptions) { - mergeFormatOptions(this.formatCodeOptions, formatOptions); - } - }; - ScriptInfo.prototype.close = function () { - this.isOpen = false; - }; - ScriptInfo.prototype.addChild = function (childInfo) { - this.children.push(childInfo); - }; - ScriptInfo.prototype.snap = function () { - return this.svc.getSnapshot(); - }; - ScriptInfo.prototype.getText = function () { - var snap = this.snap(); - return snap.getText(0, snap.getLength()); - }; - ScriptInfo.prototype.getLineInfo = function (line) { - var snap = this.snap(); - return snap.index.lineNumberToInfo(line); - }; - ScriptInfo.prototype.editContent = function (start, end, newText) { - this.svc.edit(start, end - start, newText); - }; - ScriptInfo.prototype.getTextChangeRangeBetweenVersions = function (startVersion, endVersion) { - return this.svc.getTextChangesBetweenVersions(startVersion, endVersion); - }; - ScriptInfo.prototype.getChangeRange = function (oldSnapshot) { - return this.snap().getChangeRange(oldSnapshot); - }; - return ScriptInfo; - }()); - server.ScriptInfo = ScriptInfo; - var LSHost = (function () { - function LSHost(host, project) { - var _this = this; - this.host = host; - this.project = project; - this.roots = []; - this.getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); - this.resolvedModuleNames = ts.createFileMap(); - this.resolvedTypeReferenceDirectives = ts.createFileMap(); - this.filenameToScript = ts.createFileMap(); - this.moduleResolutionHost = { - fileExists: function (fileName) { return _this.fileExists(fileName); }, - readFile: function (fileName) { return _this.host.readFile(fileName); }, - directoryExists: function (directoryName) { return _this.host.directoryExists(directoryName); } - }; - if (this.host.realpath) { - this.moduleResolutionHost.realpath = function (path) { return _this.host.realpath(path); }; - } - } - LSHost.prototype.resolveNamesWithLocalCache = function (names, containingFile, cache, loader, getResult) { - var path = ts.toPath(containingFile, this.host.getCurrentDirectory(), this.getCanonicalFileName); - var currentResolutionsInFile = cache.get(path); - var newResolutions = ts.createMap(); - var resolvedModules = []; - var compilerOptions = this.getCompilationSettings(); - for (var _i = 0, names_3 = names; _i < names_3.length; _i++) { - var name_53 = names_3[_i]; - var resolution = newResolutions[name_53]; - if (!resolution) { - var existingResolution = currentResolutionsInFile && currentResolutionsInFile[name_53]; - if (moduleResolutionIsValid(existingResolution)) { - resolution = existingResolution; - } - else { - resolution = loader(name_53, containingFile, compilerOptions, this.moduleResolutionHost); - resolution.lastCheckTime = Date.now(); - newResolutions[name_53] = resolution; - } - } - ts.Debug.assert(resolution !== undefined); - resolvedModules.push(getResult(resolution)); - } - cache.set(path, newResolutions); - return resolvedModules; - function moduleResolutionIsValid(resolution) { - if (!resolution) { - return false; - } - if (getResult(resolution)) { - return true; - } - return resolution.failedLookupLocations.length === 0; - } - }; - LSHost.prototype.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile) { - return this.resolveNamesWithLocalCache(typeDirectiveNames, containingFile, this.resolvedTypeReferenceDirectives, ts.resolveTypeReferenceDirective, function (m) { return m.resolvedTypeReferenceDirective; }); - }; - LSHost.prototype.resolveModuleNames = function (moduleNames, containingFile) { - return this.resolveNamesWithLocalCache(moduleNames, containingFile, this.resolvedModuleNames, ts.resolveModuleName, function (m) { return m.resolvedModule; }); - }; - LSHost.prototype.getDefaultLibFileName = function () { - var nodeModuleBinDir = ts.getDirectoryPath(ts.normalizePath(this.host.getExecutingFilePath())); - return ts.combinePaths(nodeModuleBinDir, ts.getDefaultLibFileName(this.compilationSettings)); - }; - LSHost.prototype.getScriptSnapshot = function (filename) { - var scriptInfo = this.getScriptInfo(filename); - if (scriptInfo) { - return scriptInfo.snap(); - } - }; - LSHost.prototype.setCompilationSettings = function (opt) { - this.compilationSettings = opt; - this.resolvedModuleNames.clear(); - this.resolvedTypeReferenceDirectives.clear(); - }; - LSHost.prototype.lineAffectsRefs = function (filename, line) { - var info = this.getScriptInfo(filename); - var lineInfo = info.getLineInfo(line); - if (lineInfo && lineInfo.text) { - var regex = /reference|import|\/\*|\*\//; - return regex.test(lineInfo.text); - } - }; - LSHost.prototype.getCompilationSettings = function () { - return this.compilationSettings; - }; - LSHost.prototype.getScriptFileNames = function () { - return this.roots.map(function (root) { return root.fileName; }); - }; - LSHost.prototype.getScriptKind = function (fileName) { - var info = this.getScriptInfo(fileName); - if (!info) { - return undefined; - } - if (!info.scriptKind) { - info.scriptKind = ts.getScriptKindFromFileName(fileName); - } - return info.scriptKind; - }; - LSHost.prototype.getScriptVersion = function (filename) { - return this.getScriptInfo(filename).svc.latestVersion().toString(); - }; - LSHost.prototype.getCurrentDirectory = function () { - return ""; - }; - LSHost.prototype.getScriptIsOpen = function (filename) { - return this.getScriptInfo(filename).isOpen; - }; - LSHost.prototype.removeReferencedFile = function (info) { - if (!info.isOpen) { - this.filenameToScript.remove(info.path); - this.resolvedModuleNames.remove(info.path); - this.resolvedTypeReferenceDirectives.remove(info.path); - } - }; - LSHost.prototype.getScriptInfo = function (filename) { - var path = ts.toPath(filename, this.host.getCurrentDirectory(), this.getCanonicalFileName); - var scriptInfo = this.filenameToScript.get(path); - if (!scriptInfo) { - scriptInfo = this.project.openReferencedFile(filename); - if (scriptInfo) { - this.filenameToScript.set(path, scriptInfo); - } - } - return scriptInfo; - }; - LSHost.prototype.addRoot = function (info) { - if (!this.filenameToScript.contains(info.path)) { - this.filenameToScript.set(info.path, info); - this.roots.push(info); - } - }; - LSHost.prototype.removeRoot = function (info) { - if (this.filenameToScript.contains(info.path)) { - this.filenameToScript.remove(info.path); - ts.unorderedRemoveItem(this.roots, info); - this.resolvedModuleNames.remove(info.path); - this.resolvedTypeReferenceDirectives.remove(info.path); - } - }; - LSHost.prototype.saveTo = function (filename, tmpfilename) { - var script = this.getScriptInfo(filename); - if (script) { - var snap = script.snap(); - this.host.writeFile(tmpfilename, snap.getText(0, snap.getLength())); - } - }; - LSHost.prototype.reloadScript = function (filename, tmpfilename, cb) { - var script = this.getScriptInfo(filename); - if (script) { - script.svc.reloadFromFile(tmpfilename, cb); - } - }; - LSHost.prototype.editScript = function (filename, start, end, newText) { - var script = this.getScriptInfo(filename); - if (script) { - script.editContent(start, end, newText); - return; - } - throw new Error("No script with name '" + filename + "'"); - }; - LSHost.prototype.fileExists = function (path) { - var result = this.host.fileExists(path); - return result; - }; - LSHost.prototype.directoryExists = function (path) { - return this.host.directoryExists(path); - }; - LSHost.prototype.getDirectories = function (path) { - return this.host.getDirectories(path); - }; - LSHost.prototype.readDirectory = function (path, extensions, exclude, include) { - return this.host.readDirectory(path, extensions, exclude, include); - }; - LSHost.prototype.readFile = function (path, encoding) { - return this.host.readFile(path, encoding); - }; - LSHost.prototype.lineToTextSpan = function (filename, line) { - var path = ts.toPath(filename, this.host.getCurrentDirectory(), this.getCanonicalFileName); - var script = this.filenameToScript.get(path); - var index = script.snap().index; - var lineInfo = index.lineNumberToInfo(line + 1); - var len; - if (lineInfo.leaf) { - len = lineInfo.leaf.text.length; - } - else { - var nextLineInfo = index.lineNumberToInfo(line + 2); - len = nextLineInfo.offset - lineInfo.offset; - } - return ts.createTextSpan(lineInfo.offset, len); - }; - LSHost.prototype.lineOffsetToPosition = function (filename, line, offset) { - var path = ts.toPath(filename, this.host.getCurrentDirectory(), this.getCanonicalFileName); - var script = this.filenameToScript.get(path); - var index = script.snap().index; - var lineInfo = index.lineNumberToInfo(line); - return (lineInfo.offset + offset - 1); - }; - LSHost.prototype.positionToLineOffset = function (filename, position, lineIndex) { - lineIndex = lineIndex || this.getLineIndex(filename); - var lineOffset = lineIndex.charOffsetToLineNumberAndPos(position); - return { line: lineOffset.line, offset: lineOffset.offset + 1 }; - }; - LSHost.prototype.getLineIndex = function (filename) { - var path = ts.toPath(filename, this.host.getCurrentDirectory(), this.getCanonicalFileName); - var script = this.filenameToScript.get(path); - return script.snap().index; - }; - return LSHost; - }()); - server.LSHost = LSHost; - var Project = (function () { - function Project(projectService, projectOptions, languageServiceDiabled) { - if (languageServiceDiabled === void 0) { languageServiceDiabled = false; } - this.projectService = projectService; - this.projectOptions = projectOptions; - this.languageServiceDiabled = languageServiceDiabled; - this.directoriesWatchedForTsconfig = []; - this.filenameToSourceFile = ts.createMap(); - this.updateGraphSeq = 0; - this.openRefCount = 0; - if (projectOptions && projectOptions.files) { - projectOptions.compilerOptions.allowNonTsExtensions = true; - } - if (!languageServiceDiabled) { - this.compilerService = new CompilerService(this, projectOptions && projectOptions.compilerOptions); - } - } - Project.prototype.enableLanguageService = function () { - if (this.languageServiceDiabled) { - this.compilerService = new CompilerService(this, this.projectOptions && this.projectOptions.compilerOptions); - } - this.languageServiceDiabled = false; - }; - Project.prototype.disableLanguageService = function () { - this.languageServiceDiabled = true; - }; - Project.prototype.addOpenRef = function () { - this.openRefCount++; - }; - Project.prototype.deleteOpenRef = function () { - this.openRefCount--; - return this.openRefCount; - }; - Project.prototype.openReferencedFile = function (filename) { - return this.projectService.openFile(filename, false); - }; - Project.prototype.getRootFiles = function () { - if (this.languageServiceDiabled) { - return this.projectOptions ? this.projectOptions.files : undefined; - } - return this.compilerService.host.roots.map(function (info) { return info.fileName; }); - }; - Project.prototype.getFileNames = function () { - if (this.languageServiceDiabled) { - if (!this.projectOptions) { - return undefined; - } - var fileNames = []; - if (this.projectOptions && this.projectOptions.compilerOptions) { - fileNames.push(ts.getDefaultLibFilePath(this.projectOptions.compilerOptions)); - } - ts.addRange(fileNames, this.projectOptions.files); - return fileNames; - } - var sourceFiles = this.program.getSourceFiles(); - return sourceFiles.map(function (sourceFile) { return sourceFile.fileName; }); - }; - Project.prototype.getSourceFile = function (info) { - if (this.languageServiceDiabled) { - return undefined; - } - return this.filenameToSourceFile[info.fileName]; - }; - Project.prototype.getSourceFileFromName = function (filename, requireOpen) { - if (this.languageServiceDiabled) { - return undefined; - } - var info = this.projectService.getScriptInfo(filename); - if (info) { - if ((!requireOpen) || info.isOpen) { - return this.getSourceFile(info); - } - } - }; - Project.prototype.isRoot = function (info) { - if (this.languageServiceDiabled) { - return undefined; - } - return this.compilerService.host.roots.some(function (root) { return root === info; }); - }; - Project.prototype.removeReferencedFile = function (info) { - if (this.languageServiceDiabled) { - return; - } - this.compilerService.host.removeReferencedFile(info); - this.updateGraph(); - }; - Project.prototype.updateFileMap = function () { - if (this.languageServiceDiabled) { - return; - } - this.filenameToSourceFile = ts.createMap(); - var sourceFiles = this.program.getSourceFiles(); - for (var i = 0, len = sourceFiles.length; i < len; i++) { - var normFilename = ts.normalizePath(sourceFiles[i].fileName); - this.filenameToSourceFile[normFilename] = sourceFiles[i]; - } - }; - Project.prototype.finishGraph = function () { - if (this.languageServiceDiabled) { - return; - } - this.updateGraph(); - this.compilerService.languageService.getNavigateToItems(".*"); - }; - Project.prototype.updateGraph = function () { - if (this.languageServiceDiabled) { - return; - } - this.program = this.compilerService.languageService.getProgram(); - this.updateFileMap(); - }; - Project.prototype.isConfiguredProject = function () { - return this.projectFilename; - }; - Project.prototype.addRoot = function (info) { - if (this.languageServiceDiabled) { - return; - } - this.compilerService.host.addRoot(info); - }; - Project.prototype.removeRoot = function (info) { - if (this.languageServiceDiabled) { - return; - } - this.compilerService.host.removeRoot(info); - }; - Project.prototype.filesToString = function () { - if (this.languageServiceDiabled) { - if (this.projectOptions) { - var strBuilder_1 = ""; - ts.forEach(this.projectOptions.files, function (file) { strBuilder_1 += file + "\n"; }); - return strBuilder_1; - } - } - var strBuilder = ""; - ts.forEachProperty(this.filenameToSourceFile, function (sourceFile) { strBuilder += sourceFile.fileName + "\n"; }); - return strBuilder; - }; - Project.prototype.setProjectOptions = function (projectOptions) { - this.projectOptions = projectOptions; - if (projectOptions.compilerOptions) { - projectOptions.compilerOptions.allowNonTsExtensions = true; - if (!this.languageServiceDiabled) { - this.compilerService.setCompilerOptions(projectOptions.compilerOptions); - } - } - }; - return Project; - }()); - server.Project = Project; - function combineProjectOutput(projects, action, comparer, areEqual) { - var result = projects.reduce(function (previous, current) { return ts.concatenate(previous, action(current)); }, []).sort(comparer); - return projects.length > 1 ? ts.deduplicate(result, areEqual) : result; - } - server.combineProjectOutput = combineProjectOutput; - var ProjectService = (function () { - function ProjectService(host, psLogger, eventHandler) { - this.host = host; - this.psLogger = psLogger; - this.eventHandler = eventHandler; - this.filenameToScriptInfo = ts.createMap(); - this.openFileRoots = []; - this.inferredProjects = []; - this.configuredProjects = []; - this.openFilesReferenced = []; - this.openFileRootsConfigured = []; - this.directoryWatchersForTsconfig = ts.createMap(); - this.directoryWatchersRefCount = ts.createMap(); - this.timerForDetectingProjectFileListChanges = ts.createMap(); - this.addDefaultHostConfiguration(); - } - ProjectService.prototype.addDefaultHostConfiguration = function () { - this.hostConfiguration = { - formatCodeOptions: ts.clone(CompilerService.getDefaultFormatCodeOptions(this.host)), - hostInfo: "Unknown host" - }; - }; - ProjectService.prototype.getFormatCodeOptions = function (file) { - if (file) { - var info = this.filenameToScriptInfo[file]; - if (info) { - return info.formatCodeOptions; - } - } - return this.hostConfiguration.formatCodeOptions; - }; - ProjectService.prototype.watchedFileChanged = function (fileName) { - var info = this.filenameToScriptInfo[fileName]; - if (!info) { - this.psLogger.info("Error: got watch notification for unknown file: " + fileName); - } - if (!this.host.fileExists(fileName)) { - this.fileDeletedInFilesystem(info); - } - else { - if (info && (!info.isOpen)) { - info.svc.reloadFromFile(info.fileName); - } - } - }; - ProjectService.prototype.directoryWatchedForSourceFilesChanged = function (project, fileName) { - if (fileName && !ts.isSupportedSourceFileName(fileName, project.projectOptions ? project.projectOptions.compilerOptions : undefined)) { - return; - } - this.log("Detected source file changes: " + fileName); - this.startTimerForDetectingProjectFileListChanges(project); - }; - ProjectService.prototype.startTimerForDetectingProjectFileListChanges = function (project) { - var _this = this; - if (this.timerForDetectingProjectFileListChanges[project.projectFilename]) { - this.host.clearTimeout(this.timerForDetectingProjectFileListChanges[project.projectFilename]); - } - this.timerForDetectingProjectFileListChanges[project.projectFilename] = this.host.setTimeout(function () { return _this.handleProjectFileListChanges(project); }, 250); - }; - ProjectService.prototype.handleProjectFileListChanges = function (project) { - var _this = this; - var _a = this.configFileToProjectOptions(project.projectFilename), projectOptions = _a.projectOptions, errors = _a.errors; - this.reportConfigFileDiagnostics(project.projectFilename, errors); - var newRootFiles = projectOptions.files.map((function (f) { return _this.getCanonicalFileName(f); })); - var currentRootFiles = project.getRootFiles().map((function (f) { return _this.getCanonicalFileName(f); })); - if (!ts.arrayIsEqualTo(currentRootFiles && currentRootFiles.sort(), newRootFiles && newRootFiles.sort())) { - this.updateConfiguredProject(project); - this.updateProjectStructure(); - } - }; - ProjectService.prototype.reportConfigFileDiagnostics = function (configFileName, diagnostics, triggerFile) { - if (diagnostics && diagnostics.length > 0) { - this.eventHandler({ - eventName: "configFileDiag", - data: { configFileName: configFileName, diagnostics: diagnostics, triggerFile: triggerFile } - }); - } - }; - ProjectService.prototype.directoryWatchedForTsconfigChanged = function (fileName) { - var _this = this; - if (ts.getBaseFileName(fileName) !== "tsconfig.json") { - this.log(fileName + " is not tsconfig.json"); - return; - } - this.log("Detected newly added tsconfig file: " + fileName); - var _a = this.configFileToProjectOptions(fileName), projectOptions = _a.projectOptions, errors = _a.errors; - this.reportConfigFileDiagnostics(fileName, errors); - if (!projectOptions) { - return; - } - var rootFilesInTsconfig = projectOptions.files.map(function (f) { return _this.getCanonicalFileName(f); }); - var openFileRoots = this.openFileRoots.map(function (s) { return _this.getCanonicalFileName(s.fileName); }); - for (var _i = 0, openFileRoots_1 = openFileRoots; _i < openFileRoots_1.length; _i++) { - var openFileRoot = openFileRoots_1[_i]; - if (rootFilesInTsconfig.indexOf(openFileRoot) >= 0) { - this.reloadProjects(); - return; - } - } - }; - ProjectService.prototype.getCanonicalFileName = function (fileName) { - var name = this.host.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); - return ts.normalizePath(name); - }; - ProjectService.prototype.watchedProjectConfigFileChanged = function (project) { - this.log("Config file changed: " + project.projectFilename); - var configFileErrors = this.updateConfiguredProject(project); - this.updateProjectStructure(); - if (configFileErrors && configFileErrors.length > 0) { - this.eventHandler({ eventName: "configFileDiag", data: { triggerFile: project.projectFilename, configFileName: project.projectFilename, diagnostics: configFileErrors } }); - } - }; - ProjectService.prototype.log = function (msg, type) { - if (type === void 0) { type = "Err"; } - this.psLogger.msg(msg, type); - }; - ProjectService.prototype.setHostConfiguration = function (args) { - if (args.file) { - var info = this.filenameToScriptInfo[args.file]; - if (info) { - info.setFormatOptions(args.formatOptions); - this.log("Host configuration update for file " + args.file, "Info"); - } - } - else { - if (args.hostInfo !== undefined) { - this.hostConfiguration.hostInfo = args.hostInfo; - this.log("Host information " + args.hostInfo, "Info"); - } - if (args.formatOptions) { - mergeFormatOptions(this.hostConfiguration.formatCodeOptions, args.formatOptions); - this.log("Format host information updated", "Info"); - } - } - }; - ProjectService.prototype.closeLog = function () { - this.psLogger.close(); - }; - ProjectService.prototype.createInferredProject = function (root) { - var _this = this; - var project = new Project(this); - project.addRoot(root); - var currentPath = ts.getDirectoryPath(root.fileName); - var parentPath = ts.getDirectoryPath(currentPath); - while (currentPath != parentPath) { - if (!project.projectService.directoryWatchersForTsconfig[currentPath]) { - this.log("Add watcher for: " + currentPath); - project.projectService.directoryWatchersForTsconfig[currentPath] = - this.host.watchDirectory(currentPath, function (fileName) { return _this.directoryWatchedForTsconfigChanged(fileName); }); - project.projectService.directoryWatchersRefCount[currentPath] = 1; - } - else { - project.projectService.directoryWatchersRefCount[currentPath] += 1; - } - project.directoriesWatchedForTsconfig.push(currentPath); - currentPath = parentPath; - parentPath = ts.getDirectoryPath(parentPath); - } - project.finishGraph(); - this.inferredProjects.push(project); - return project; - }; - ProjectService.prototype.fileDeletedInFilesystem = function (info) { - this.psLogger.info(info.fileName + " deleted"); - if (info.fileWatcher) { - info.fileWatcher.close(); - info.fileWatcher = undefined; - } - if (!info.isOpen) { - this.filenameToScriptInfo[info.fileName] = undefined; - var referencingProjects = this.findReferencingProjects(info); - if (info.defaultProject) { - info.defaultProject.removeRoot(info); - } - for (var i = 0, len = referencingProjects.length; i < len; i++) { - referencingProjects[i].removeReferencedFile(info); - } - for (var j = 0, flen = this.openFileRoots.length; j < flen; j++) { - var openFile = this.openFileRoots[j]; - if (this.eventHandler) { - this.eventHandler({ eventName: "context", data: { project: openFile.defaultProject, fileName: openFile.fileName } }); - } - } - for (var j = 0, flen = this.openFilesReferenced.length; j < flen; j++) { - var openFile = this.openFilesReferenced[j]; - if (this.eventHandler) { - this.eventHandler({ eventName: "context", data: { project: openFile.defaultProject, fileName: openFile.fileName } }); - } - } - } - this.printProjects(); - }; - ProjectService.prototype.updateConfiguredProjectList = function () { - var configuredProjects = []; - for (var i = 0, len = this.configuredProjects.length; i < len; i++) { - if (this.configuredProjects[i].openRefCount > 0) { - configuredProjects.push(this.configuredProjects[i]); - } - } - this.configuredProjects = configuredProjects; - }; - ProjectService.prototype.removeProject = function (project) { - this.log("remove project: " + project.getRootFiles().toString()); - if (project.isConfiguredProject()) { - project.projectFileWatcher.close(); - project.directoryWatcher.close(); - ts.forEachProperty(project.directoriesWatchedForWildcards, function (watcher) { watcher.close(); }); - delete project.directoriesWatchedForWildcards; - ts.unorderedRemoveItem(this.configuredProjects, project); - } - else { - for (var _i = 0, _a = project.directoriesWatchedForTsconfig; _i < _a.length; _i++) { - var directory = _a[_i]; - project.projectService.directoryWatchersRefCount[directory]--; - if (!project.projectService.directoryWatchersRefCount[directory]) { - this.log("Close directory watcher for: " + directory); - project.projectService.directoryWatchersForTsconfig[directory].close(); - delete project.projectService.directoryWatchersForTsconfig[directory]; - } - } - ts.unorderedRemoveItem(this.inferredProjects, project); - } - var fileNames = project.getFileNames(); - for (var _b = 0, fileNames_3 = fileNames; _b < fileNames_3.length; _b++) { - var fileName = fileNames_3[_b]; - var info = this.getScriptInfo(fileName); - if (info.defaultProject == project) { - info.defaultProject = undefined; - } - } - }; - ProjectService.prototype.setConfiguredProjectRoot = function (info) { - for (var i = 0, len = this.configuredProjects.length; i < len; i++) { - var configuredProject = this.configuredProjects[i]; - if (configuredProject.isRoot(info)) { - info.defaultProject = configuredProject; - configuredProject.addOpenRef(); - return true; - } - } - return false; - }; - ProjectService.prototype.addOpenFile = function (info) { - if (this.setConfiguredProjectRoot(info)) { - this.openFileRootsConfigured.push(info); - } - else { - this.findReferencingProjects(info); - if (info.defaultProject) { - info.defaultProject.addOpenRef(); - this.openFilesReferenced.push(info); - } - else { - info.defaultProject = this.createInferredProject(info); - var openFileRoots = []; - for (var i = 0, len = this.openFileRoots.length; i < len; i++) { - var r = this.openFileRoots[i]; - if (info.defaultProject.getSourceFile(r)) { - this.removeProject(r.defaultProject); - this.openFilesReferenced.push(r); - r.defaultProject = info.defaultProject; - } - else { - openFileRoots.push(r); - } - } - this.openFileRoots = openFileRoots; - this.openFileRoots.push(info); - } - } - this.updateConfiguredProjectList(); - }; - ProjectService.prototype.closeOpenFile = function (info) { - info.svc.reloadFromFile(info.fileName); - var openFileRoots = []; - var removedProject; - for (var i = 0, len = this.openFileRoots.length; i < len; i++) { - if (info === this.openFileRoots[i]) { - removedProject = info.defaultProject; - } - else { - openFileRoots.push(this.openFileRoots[i]); - } - } - this.openFileRoots = openFileRoots; - if (!removedProject) { - var openFileRootsConfigured = []; - for (var i = 0, len = this.openFileRootsConfigured.length; i < len; i++) { - if (info === this.openFileRootsConfigured[i]) { - if (info.defaultProject.deleteOpenRef() === 0) { - removedProject = info.defaultProject; - } - } - else { - openFileRootsConfigured.push(this.openFileRootsConfigured[i]); - } - } - this.openFileRootsConfigured = openFileRootsConfigured; - } - if (removedProject) { - this.removeProject(removedProject); - var openFilesReferenced = []; - var orphanFiles = []; - for (var i = 0, len = this.openFilesReferenced.length; i < len; i++) { - var f = this.openFilesReferenced[i]; - if (f.defaultProject === removedProject || !f.defaultProject) { - f.defaultProject = undefined; - orphanFiles.push(f); - } - else { - openFilesReferenced.push(f); - } - } - this.openFilesReferenced = openFilesReferenced; - for (var i = 0, len = orphanFiles.length; i < len; i++) { - this.addOpenFile(orphanFiles[i]); - } - } - else { - ts.unorderedRemoveItem(this.openFilesReferenced, info); - } - info.close(); - }; - ProjectService.prototype.findReferencingProjects = function (info, excludedProject) { - var referencingProjects = []; - info.defaultProject = undefined; - for (var i = 0, len = this.inferredProjects.length; i < len; i++) { - var inferredProject = this.inferredProjects[i]; - inferredProject.updateGraph(); - if (inferredProject !== excludedProject) { - if (inferredProject.getSourceFile(info)) { - info.defaultProject = inferredProject; - referencingProjects.push(inferredProject); - } - } - } - for (var i = 0, len = this.configuredProjects.length; i < len; i++) { - var configuredProject = this.configuredProjects[i]; - configuredProject.updateGraph(); - if (configuredProject.getSourceFile(info)) { - info.defaultProject = configuredProject; - referencingProjects.push(configuredProject); - } - } - return referencingProjects; - }; - ProjectService.prototype.reloadProjects = function () { - this.log("reload projects."); - for (var _i = 0, _a = this.openFileRoots; _i < _a.length; _i++) { - var info = _a[_i]; - this.openOrUpdateConfiguredProjectForFile(info.fileName); - } - this.updateProjectStructure(); - }; - ProjectService.prototype.updateProjectStructure = function () { - this.log("updating project structure from ...", "Info"); - this.printProjects(); - var unattachedOpenFiles = []; - var openFileRootsConfigured = []; - for (var _i = 0, _a = this.openFileRootsConfigured; _i < _a.length; _i++) { - var info = _a[_i]; - var project = info.defaultProject; - if (!project || !(project.getSourceFile(info))) { - info.defaultProject = undefined; - unattachedOpenFiles.push(info); - } - else { - openFileRootsConfigured.push(info); - } - } - this.openFileRootsConfigured = openFileRootsConfigured; - var openFilesReferenced = []; - for (var i = 0, len = this.openFilesReferenced.length; i < len; i++) { - var referencedFile = this.openFilesReferenced[i]; - referencedFile.defaultProject.updateGraph(); - var sourceFile = referencedFile.defaultProject.getSourceFile(referencedFile); - if (sourceFile) { - openFilesReferenced.push(referencedFile); - } - else { - unattachedOpenFiles.push(referencedFile); - } - } - this.openFilesReferenced = openFilesReferenced; - var openFileRoots = []; - for (var i = 0, len = this.openFileRoots.length; i < len; i++) { - var rootFile = this.openFileRoots[i]; - var rootedProject = rootFile.defaultProject; - var referencingProjects = this.findReferencingProjects(rootFile, rootedProject); - if (rootFile.defaultProject && rootFile.defaultProject.isConfiguredProject()) { - if (!rootedProject.isConfiguredProject()) { - this.removeProject(rootedProject); - } - this.openFileRootsConfigured.push(rootFile); - } - else { - if (referencingProjects.length === 0) { - rootFile.defaultProject = rootedProject; - openFileRoots.push(rootFile); - } - else { - this.removeProject(rootedProject); - this.openFilesReferenced.push(rootFile); - } - } - } - this.openFileRoots = openFileRoots; - for (var i = 0, len = unattachedOpenFiles.length; i < len; i++) { - this.addOpenFile(unattachedOpenFiles[i]); - } - this.printProjects(); - }; - ProjectService.prototype.getScriptInfo = function (filename) { - filename = ts.normalizePath(filename); - return this.filenameToScriptInfo[filename]; - }; - ProjectService.prototype.openFile = function (fileName, openedByClient, fileContent, scriptKind) { - var _this = this; - fileName = ts.normalizePath(fileName); - var info = this.filenameToScriptInfo[fileName]; - if (!info) { - var content = void 0; - if (this.host.fileExists(fileName)) { - content = fileContent || this.host.readFile(fileName); - } - if (!content) { - if (openedByClient) { - content = ""; - } - } - if (content !== undefined) { - info = new ScriptInfo(this.host, fileName, content, openedByClient); - info.scriptKind = scriptKind; - info.setFormatOptions(this.getFormatCodeOptions()); - this.filenameToScriptInfo[fileName] = info; - if (!info.isOpen) { - info.fileWatcher = this.host.watchFile(fileName, function (_) { _this.watchedFileChanged(fileName); }); - } - } - } - if (info) { - if (fileContent) { - info.svc.reload(fileContent); - } - if (openedByClient) { - info.isOpen = true; - } - } - return info; - }; - ProjectService.prototype.findConfigFile = function (searchPath) { - while (true) { - var tsconfigFileName = ts.combinePaths(searchPath, "tsconfig.json"); - if (this.host.fileExists(tsconfigFileName)) { - return tsconfigFileName; - } - var jsconfigFileName = ts.combinePaths(searchPath, "jsconfig.json"); - if (this.host.fileExists(jsconfigFileName)) { - return jsconfigFileName; - } - var parentPath = ts.getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; - } - return undefined; - }; - ProjectService.prototype.openClientFile = function (fileName, fileContent, scriptKind) { - var _a = this.openOrUpdateConfiguredProjectForFile(fileName), configFileName = _a.configFileName, configFileErrors = _a.configFileErrors; - var info = this.openFile(fileName, true, fileContent, scriptKind); - this.addOpenFile(info); - this.printProjects(); - return { configFileName: configFileName, configFileErrors: configFileErrors }; - }; - ProjectService.prototype.openOrUpdateConfiguredProjectForFile = function (fileName) { - var searchPath = ts.normalizePath(ts.getDirectoryPath(fileName)); - this.log("Search path: " + searchPath, "Info"); - var configFileName = this.findConfigFile(searchPath); - if (configFileName) { - this.log("Config file name: " + configFileName, "Info"); - var project = this.findConfiguredProjectByConfigFile(configFileName); - if (!project) { - var configResult = this.openConfigFile(configFileName, fileName); - if (!configResult.project) { - return { configFileName: configFileName, configFileErrors: configResult.errors }; - } - else { - this.log("Opened configuration file " + configFileName, "Info"); - this.configuredProjects.push(configResult.project); - if (configResult.errors && configResult.errors.length > 0) { - return { configFileName: configFileName, configFileErrors: configResult.errors }; - } - } - } - else { - this.updateConfiguredProject(project); - } - return { configFileName: configFileName }; - } - else { - this.log("No config files found."); - } - return {}; - }; - ProjectService.prototype.closeClientFile = function (filename) { - var info = this.filenameToScriptInfo[filename]; - if (info) { - this.closeOpenFile(info); - info.isOpen = false; - } - this.printProjects(); - }; - ProjectService.prototype.getProjectForFile = function (filename) { - var scriptInfo = this.filenameToScriptInfo[filename]; - if (scriptInfo) { - return scriptInfo.defaultProject; - } - }; - ProjectService.prototype.printProjectsForFile = function (filename) { - var scriptInfo = this.filenameToScriptInfo[filename]; - if (scriptInfo) { - this.psLogger.startGroup(); - this.psLogger.info("Projects for " + filename); - var projects = this.findReferencingProjects(scriptInfo); - for (var i = 0, len = projects.length; i < len; i++) { - this.psLogger.info("Project " + i.toString()); - } - this.psLogger.endGroup(); - } - else { - this.psLogger.info(filename + " not in any project"); - } - }; - ProjectService.prototype.printProjects = function () { - if (!this.psLogger.isVerbose()) { - return; - } - this.psLogger.startGroup(); - for (var i = 0, len = this.inferredProjects.length; i < len; i++) { - var project = this.inferredProjects[i]; - project.updateGraph(); - this.psLogger.info("Project " + i.toString()); - this.psLogger.info(project.filesToString()); - this.psLogger.info("-----------------------------------------------"); - } - for (var i = 0, len = this.configuredProjects.length; i < len; i++) { - var project = this.configuredProjects[i]; - project.updateGraph(); - this.psLogger.info("Project (configured) " + (i + this.inferredProjects.length).toString()); - this.psLogger.info(project.filesToString()); - this.psLogger.info("-----------------------------------------------"); - } - this.psLogger.info("Open file roots of inferred projects: "); - for (var i = 0, len = this.openFileRoots.length; i < len; i++) { - this.psLogger.info(this.openFileRoots[i].fileName); - } - this.psLogger.info("Open files referenced by inferred or configured projects: "); - for (var i = 0, len = this.openFilesReferenced.length; i < len; i++) { - var fileInfo = this.openFilesReferenced[i].fileName; - if (this.openFilesReferenced[i].defaultProject.isConfiguredProject()) { - fileInfo += " (configured)"; - } - this.psLogger.info(fileInfo); - } - this.psLogger.info("Open file roots of configured projects: "); - for (var i = 0, len = this.openFileRootsConfigured.length; i < len; i++) { - this.psLogger.info(this.openFileRootsConfigured[i].fileName); - } - this.psLogger.endGroup(); - }; - ProjectService.prototype.configProjectIsActive = function (fileName) { - return this.findConfiguredProjectByConfigFile(fileName) === undefined; - }; - ProjectService.prototype.findConfiguredProjectByConfigFile = function (configFileName) { - for (var i = 0, len = this.configuredProjects.length; i < len; i++) { - if (this.configuredProjects[i].projectFilename == configFileName) { - return this.configuredProjects[i]; - } - } - return undefined; - }; - ProjectService.prototype.configFileToProjectOptions = function (configFilename) { - configFilename = ts.normalizePath(configFilename); - var errors = []; - var dirPath = ts.getDirectoryPath(configFilename); - var contents = this.host.readFile(configFilename); - var _a = ts.parseAndReEmitConfigJSONFile(contents), configJsonObject = _a.configJsonObject, diagnostics = _a.diagnostics; - errors = ts.concatenate(errors, diagnostics); - var parsedCommandLine = ts.parseJsonConfigFileContent(configJsonObject, this.host, dirPath, {}, configFilename); - errors = ts.concatenate(errors, parsedCommandLine.errors); - ts.Debug.assert(!!parsedCommandLine.fileNames); - if (parsedCommandLine.fileNames.length === 0) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.The_config_file_0_found_doesn_t_contain_any_source_files, configFilename)); - return { errors: errors }; - } - else { - var projectOptions = { - files: parsedCommandLine.fileNames, - wildcardDirectories: parsedCommandLine.wildcardDirectories, - compilerOptions: parsedCommandLine.options - }; - return { projectOptions: projectOptions, errors: errors }; - } - }; - ProjectService.prototype.exceedTotalNonTsFileSizeLimit = function (fileNames) { - var totalNonTsFileSize = 0; - if (!this.host.getFileSize) { - return false; - } - for (var _i = 0, fileNames_4 = fileNames; _i < fileNames_4.length; _i++) { - var fileName = fileNames_4[_i]; - if (ts.hasTypeScriptFileExtension(fileName)) { - continue; - } - totalNonTsFileSize += this.host.getFileSize(fileName); - if (totalNonTsFileSize > server.maxProgramSizeForNonTsFiles) { - return true; - } - } - return false; - }; - ProjectService.prototype.openConfigFile = function (configFilename, clientFileName) { - var _this = this; - var parseConfigFileResult = this.configFileToProjectOptions(configFilename); - var errors = parseConfigFileResult.errors; - if (!parseConfigFileResult.projectOptions) { - return { errors: errors }; - } - var projectOptions = parseConfigFileResult.projectOptions; - if (!projectOptions.compilerOptions.disableSizeLimit && projectOptions.compilerOptions.allowJs) { - if (this.exceedTotalNonTsFileSizeLimit(projectOptions.files)) { - var project_1 = this.createProject(configFilename, projectOptions, true); - project_1.projectFileWatcher = this.host.watchFile(ts.toPath(configFilename, configFilename, ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)), function (_) { return _this.watchedProjectConfigFileChanged(project_1); }); - return { project: project_1, errors: errors }; - } - } - var project = this.createProject(configFilename, projectOptions); - for (var _i = 0, _a = projectOptions.files; _i < _a.length; _i++) { - var rootFilename = _a[_i]; - if (this.host.fileExists(rootFilename)) { - var info = this.openFile(rootFilename, clientFileName == rootFilename); - project.addRoot(info); - } - else { - (errors || (errors = [])).push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, rootFilename)); - } - } - project.finishGraph(); - project.projectFileWatcher = this.host.watchFile(configFilename, function (_) { return _this.watchedProjectConfigFileChanged(project); }); - var configDirectoryPath = ts.getDirectoryPath(configFilename); - this.log("Add recursive watcher for: " + configDirectoryPath); - project.directoryWatcher = this.host.watchDirectory(configDirectoryPath, function (path) { return _this.directoryWatchedForSourceFilesChanged(project, path); }, true); - project.directoriesWatchedForWildcards = ts.reduceProperties(ts.createMap(projectOptions.wildcardDirectories), function (watchers, flag, directory) { - if (ts.comparePaths(configDirectoryPath, directory, ".", !_this.host.useCaseSensitiveFileNames) !== 0) { - var recursive = (flag & 1) !== 0; - _this.log("Add " + (recursive ? "recursive " : "") + "watcher for: " + directory); - watchers[directory] = _this.host.watchDirectory(directory, function (path) { return _this.directoryWatchedForSourceFilesChanged(project, path); }, recursive); - } - return watchers; - }, {}); - return { project: project, errors: errors }; - }; - ProjectService.prototype.updateConfiguredProject = function (project) { - var _this = this; - if (!this.host.fileExists(project.projectFilename)) { - this.log("Config file deleted"); - this.removeProject(project); - } - else { - var _a = this.configFileToProjectOptions(project.projectFilename), projectOptions = _a.projectOptions, errors = _a.errors; - if (!projectOptions) { - return errors; - } - else { - if (projectOptions.compilerOptions && !projectOptions.compilerOptions.disableSizeLimit && this.exceedTotalNonTsFileSizeLimit(projectOptions.files)) { - project.setProjectOptions(projectOptions); - if (project.languageServiceDiabled) { - return errors; - } - project.disableLanguageService(); - if (project.directoryWatcher) { - project.directoryWatcher.close(); - project.directoryWatcher = undefined; - } - return errors; - } - if (project.languageServiceDiabled) { - project.setProjectOptions(projectOptions); - project.enableLanguageService(); - project.directoryWatcher = this.host.watchDirectory(ts.getDirectoryPath(project.projectFilename), function (path) { return _this.directoryWatchedForSourceFilesChanged(project, path); }, true); - for (var _i = 0, _b = projectOptions.files; _i < _b.length; _i++) { - var rootFilename = _b[_i]; - if (this.host.fileExists(rootFilename)) { - var info = this.openFile(rootFilename, false); - project.addRoot(info); - } - } - project.finishGraph(); - return errors; - } - var oldFileNames_1 = project.projectOptions ? project.projectOptions.files : project.compilerService.host.roots.map(function (info) { return info.fileName; }); - var newFileNames_1 = ts.filter(projectOptions.files, function (f) { return _this.host.fileExists(f); }); - var fileNamesToRemove = oldFileNames_1.filter(function (f) { return newFileNames_1.indexOf(f) < 0; }); - var fileNamesToAdd = newFileNames_1.filter(function (f) { return oldFileNames_1.indexOf(f) < 0; }); - for (var _c = 0, fileNamesToRemove_1 = fileNamesToRemove; _c < fileNamesToRemove_1.length; _c++) { - var fileName = fileNamesToRemove_1[_c]; - var info = this.getScriptInfo(fileName); - if (info) { - project.removeRoot(info); - } - } - for (var _d = 0, fileNamesToAdd_1 = fileNamesToAdd; _d < fileNamesToAdd_1.length; _d++) { - var fileName = fileNamesToAdd_1[_d]; - var info = this.getScriptInfo(fileName); - if (!info) { - info = this.openFile(fileName, false); - } - else { - if (info.isOpen) { - if (this.openFileRoots.indexOf(info) >= 0) { - ts.unorderedRemoveItem(this.openFileRoots, info); - if (info.defaultProject && !info.defaultProject.isConfiguredProject()) { - this.removeProject(info.defaultProject); - } - } - if (this.openFilesReferenced.indexOf(info) >= 0) { - ts.unorderedRemoveItem(this.openFilesReferenced, info); - } - this.openFileRootsConfigured.push(info); - info.defaultProject = project; - } - } - project.addRoot(info); - } - project.setProjectOptions(projectOptions); - project.finishGraph(); - } - return errors; - } - }; - ProjectService.prototype.createProject = function (projectFilename, projectOptions, languageServiceDisabled) { - var project = new Project(this, projectOptions, languageServiceDisabled); - project.projectFilename = projectFilename; - return project; - }; - return ProjectService; - }()); - server.ProjectService = ProjectService; - var CompilerService = (function () { - function CompilerService(project, opt) { - this.project = project; - this.documentRegistry = ts.createDocumentRegistry(); - this.host = new LSHost(project.projectService.host, project); - if (opt) { - this.setCompilerOptions(opt); - } - else { - var defaultOpts = ts.getDefaultCompilerOptions(); - defaultOpts.allowNonTsExtensions = true; - defaultOpts.allowJs = true; - this.setCompilerOptions(defaultOpts); - } - this.languageService = ts.createLanguageService(this.host, this.documentRegistry); - this.classifier = ts.createClassifier(); - } - CompilerService.prototype.setCompilerOptions = function (opt) { - this.settings = opt; - this.host.setCompilationSettings(opt); - }; - CompilerService.prototype.isExternalModule = function (filename) { - var sourceFile = this.languageService.getNonBoundSourceFile(filename); - return ts.isExternalModule(sourceFile); - }; - CompilerService.getDefaultFormatCodeOptions = function (host) { - return ts.clone({ - BaseIndentSize: 0, - IndentSize: 4, - TabSize: 4, - NewLineCharacter: host.newLine || "\n", - ConvertTabsToSpaces: true, - IndentStyle: ts.IndentStyle.Smart, - InsertSpaceAfterCommaDelimiter: true, - InsertSpaceAfterSemicolonInForStatements: true, - InsertSpaceBeforeAndAfterBinaryOperators: true, - InsertSpaceAfterKeywordsInControlFlowStatements: true, - InsertSpaceAfterFunctionKeywordForAnonymousFunctions: false, - InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, - InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, - InsertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: true, - InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, - InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, - InsertSpaceAfterTypeAssertion: false, - PlaceOpenBraceOnNewLineForFunctions: false, - PlaceOpenBraceOnNewLineForControlBlocks: false - }); - }; - return CompilerService; - }()); - server.CompilerService = CompilerService; (function (CharRangeSection) { CharRangeSection[CharRangeSection["PreStart"] = 0] = "PreStart"; CharRangeSection[CharRangeSection["Start"] = 1] = "Start"; @@ -62605,16 +64797,17 @@ var ts; var EditWalker = (function (_super) { __extends(EditWalker, _super); function EditWalker() { - _super.call(this); - this.lineIndex = new LineIndex(); - this.endBranch = []; - this.state = CharRangeSection.Entire; - this.initialText = ""; - this.trailingText = ""; - this.suppressTrailingText = false; - this.lineIndex.root = new LineNode(); - this.startPath = [this.lineIndex.root]; - this.stack = [this.lineIndex.root]; + var _this = _super.call(this) || this; + _this.lineIndex = new LineIndex(); + _this.endBranch = []; + _this.state = CharRangeSection.Entire; + _this.initialText = ""; + _this.trailingText = ""; + _this.suppressTrailingText = false; + _this.lineIndex.root = new LineNode(); + _this.startPath = [_this.lineIndex.root]; + _this.stack = [_this.lineIndex.root]; + return _this; } EditWalker.prototype.insertLines = function (insertedText) { if (this.suppressTrailingText) { @@ -62801,10 +64994,19 @@ var ts; var ScriptVersionCache = (function () { function ScriptVersionCache() { this.changes = []; - this.versions = []; + this.versions = new Array(ScriptVersionCache.maxVersions); this.minVersion = 0; this.currentVersion = 0; } + ScriptVersionCache.prototype.versionToIndex = function (version) { + if (version < this.minVersion || version > this.currentVersion) { + return undefined; + } + return version % ScriptVersionCache.maxVersions; + }; + ScriptVersionCache.prototype.currentVersionToIndex = function () { + return this.currentVersion % ScriptVersionCache.maxVersions; + }; ScriptVersionCache.prototype.edit = function (pos, deleteLen, insertedText) { this.changes[this.changes.length] = new TextChange(pos, deleteLen, insertedText); if ((this.changes.length > ScriptVersionCache.changeNumberThreshold) || @@ -62814,7 +65016,7 @@ var ts; } }; ScriptVersionCache.prototype.latest = function () { - return this.versions[this.currentVersion]; + return this.versions[this.currentVersionToIndex()]; }; ScriptVersionCache.prototype.latestVersion = function () { if (this.changes.length > 0) { @@ -62822,32 +65024,30 @@ var ts; } return this.currentVersion; }; - ScriptVersionCache.prototype.reloadFromFile = function (filename, cb) { + ScriptVersionCache.prototype.reloadFromFile = function (filename) { var content = this.host.readFile(filename); if (!content) { content = ""; } this.reload(content); - if (cb) - cb(); }; ScriptVersionCache.prototype.reload = function (script) { this.currentVersion++; this.changes = []; var snap = new LineIndexSnapshot(this.currentVersion, this); - this.versions[this.currentVersion] = snap; + for (var i = 0; i < this.versions.length; i++) { + this.versions[i] = undefined; + } + this.versions[this.currentVersionToIndex()] = snap; snap.index = new LineIndex(); var lm = LineIndex.linesFromText(script); snap.index.load(lm.lines); - for (var i = this.minVersion; i < this.currentVersion; i++) { - this.versions[i] = undefined; - } this.minVersion = this.currentVersion; }; ScriptVersionCache.prototype.getSnapshot = function () { - var snap = this.versions[this.currentVersion]; + var snap = this.versions[this.currentVersionToIndex()]; if (this.changes.length > 0) { - var snapIndex = this.latest().index; + var snapIndex = snap.index; for (var i = 0, len = this.changes.length; i < len; i++) { var change = this.changes[i]; snapIndex = snapIndex.edit(change.pos, change.deleteLen, change.insertedText); @@ -62856,14 +65056,10 @@ var ts; snap.index = snapIndex; snap.changesSincePreviousVersion = this.changes; this.currentVersion = snap.version; - this.versions[snap.version] = snap; + this.versions[this.currentVersionToIndex()] = snap; this.changes = []; if ((this.currentVersion - this.minVersion) >= ScriptVersionCache.maxVersions) { - var oldMin = this.minVersion; this.minVersion = (this.currentVersion - ScriptVersionCache.maxVersions) + 1; - for (var j = oldMin; j < this.minVersion; j++) { - this.versions[j] = undefined; - } } } return snap; @@ -62873,7 +65069,7 @@ var ts; if (oldVersion >= this.minVersion) { var textChangeRanges = []; for (var i = oldVersion + 1; i <= newVersion; i++) { - var snap = this.versions[i]; + var snap = this.versions[this.versionToIndex(i)]; for (var j = 0, len = snap.changesSincePreviousVersion.length; j < len; j++) { var textChange = snap.changesSincePreviousVersion[j]; textChangeRanges[textChangeRanges.length] = textChange.getTextChangeRange(); @@ -63011,7 +65207,7 @@ var ts; done: false, leaf: function (relativeStart, relativeLength, ll) { if (!f(ll, relativeStart, relativeLength)) { - walkFns.done = true; + this.done = true; } } }; @@ -63024,7 +65220,7 @@ var ts; return source.substring(0, s) + nt + source.substring(s + dl, source.length); } if (this.root.charCount() === 0) { - if (newText) { + if (newText !== undefined) { this.load(LineIndex.linesFromText(newText).lines); return this; } @@ -63404,12 +65600,6 @@ var ts; function LineLeaf(text) { this.text = text; } - LineLeaf.prototype.setUdata = function (data) { - this.udata = data; - }; - LineLeaf.prototype.getUdata = function () { - return this.udata; - }; LineLeaf.prototype.isLeaf = function () { return true; }; @@ -63431,6 +65621,25 @@ var ts; (function (ts) { var server; (function (server) { + var net = require("net"); + var childProcess = require("child_process"); + var os = require("os"); + function getGlobalTypingsCacheLocation() { + var basePath; + switch (process.platform) { + case "win32": + basePath = process.env.LOCALAPPDATA || process.env.APPDATA || os.homedir(); + break; + case "linux": + basePath = os.homedir(); + break; + case "darwin": + basePath = ts.combinePaths(os.homedir(), "Library/Application Support/"); + break; + } + ts.Debug.assert(basePath !== undefined); + return ts.combinePaths(ts.normalizeSlashes(basePath), "Microsoft/TypeScript"); + } var readline = require("readline"); var fs = require("fs"); var rl = readline.createInterface({ @@ -63439,8 +65648,9 @@ var ts; terminal: false }); var Logger = (function () { - function Logger(logFilename, level) { + function Logger(logFilename, traceToConsole, level) { this.logFilename = logFilename; + this.traceToConsole = traceToConsole; this.level = level; this.fd = -1; this.seq = 0; @@ -63455,11 +65665,14 @@ var ts; fs.close(this.fd); } }; + Logger.prototype.getLogFileName = function () { + return this.logFilename; + }; Logger.prototype.perftrc = function (s) { - this.msg(s, "Perf"); + this.msg(s, server.Msg.Perf); }; Logger.prototype.info = function (s) { - this.msg(s, "Info"); + this.msg(s, server.Msg.Info); }; Logger.prototype.startGroup = function () { this.inGroup = true; @@ -63471,19 +65684,19 @@ var ts; this.firstInGroup = true; }; Logger.prototype.loggingEnabled = function () { - return !!this.logFilename; + return !!this.logFilename || this.traceToConsole; }; - Logger.prototype.isVerbose = function () { - return this.loggingEnabled() && (this.level == "verbose"); + Logger.prototype.hasLevel = function (level) { + return this.loggingEnabled() && this.level >= level; }; Logger.prototype.msg = function (s, type) { - if (type === void 0) { type = "Err"; } + if (type === void 0) { type = server.Msg.Err; } if (this.fd < 0) { if (this.logFilename) { this.fd = fs.openSync(this.logFilename, "w"); } } - if (this.fd >= 0) { + if (this.fd >= 0 || this.traceToConsole) { s = s + "\n"; var prefix = Logger.padStringRight(type + " " + this.seq.toString(), " "); if (this.firstInGroup) { @@ -63494,19 +65707,88 @@ var ts; this.seq++; this.firstInGroup = true; } - var buf = new Buffer(s); - fs.writeSync(this.fd, buf, 0, buf.length, null); + if (this.fd >= 0) { + var buf = new Buffer(s); + fs.writeSync(this.fd, buf, 0, buf.length, null); + } + if (this.traceToConsole) { + console.warn(s); + } } }; return Logger; }()); + var NodeTypingsInstaller = (function () { + function NodeTypingsInstaller(logger, eventPort, globalTypingsCacheLocation, newLine) { + var _this = this; + this.logger = logger; + this.eventPort = eventPort; + this.globalTypingsCacheLocation = globalTypingsCacheLocation; + this.newLine = newLine; + if (eventPort) { + var s_1 = net.connect({ port: eventPort }, function () { + _this.socket = s_1; + }); + } + } + NodeTypingsInstaller.prototype.attach = function (projectService) { + var _this = this; + this.projectService = projectService; + if (this.logger.hasLevel(server.LogLevel.requestTime)) { + this.logger.info("Binding..."); + } + var args = ["--globalTypingsCacheLocation", this.globalTypingsCacheLocation]; + if (this.logger.loggingEnabled() && this.logger.getLogFileName()) { + args.push("--logFile", ts.combinePaths(ts.getDirectoryPath(ts.normalizeSlashes(this.logger.getLogFileName())), "ti-" + process.pid + ".log")); + } + var execArgv = []; + { + for (var _i = 0, _a = process.execArgv; _i < _a.length; _i++) { + var arg = _a[_i]; + var match = /^--(debug|inspect)(=(\d+))?$/.exec(arg); + if (match) { + var currentPort = match[3] !== undefined + ? +match[3] + : match[1] === "debug" ? 5858 : 9229; + execArgv.push("--" + match[1] + "=" + (currentPort + 1)); + break; + } + } + } + this.installer = childProcess.fork(ts.combinePaths(__dirname, "typingsInstaller.js"), args, { execArgv: execArgv }); + this.installer.on("message", function (m) { return _this.handleMessage(m); }); + process.on("exit", function () { + _this.installer.kill(); + }); + }; + NodeTypingsInstaller.prototype.onProjectClosed = function (p) { + this.installer.send({ projectName: p.getProjectName(), kind: "closeProject" }); + }; + NodeTypingsInstaller.prototype.enqueueInstallTypingsRequest = function (project, typingOptions) { + var request = server.createInstallTypingsRequest(project, typingOptions); + if (this.logger.hasLevel(server.LogLevel.verbose)) { + this.logger.info("Sending request: " + JSON.stringify(request)); + } + this.installer.send(request); + }; + NodeTypingsInstaller.prototype.handleMessage = function (response) { + if (this.logger.hasLevel(server.LogLevel.verbose)) { + this.logger.info("Received response: " + JSON.stringify(response)); + } + this.projectService.updateTypingsForProject(response); + if (response.kind == "set" && this.socket) { + this.socket.write(server.formatMessage({ seq: 0, type: "event", message: response }, this.logger, Buffer.byteLength, this.newLine), "utf8"); + } + }; + return NodeTypingsInstaller; + }()); var IOSession = (function (_super) { __extends(IOSession, _super); - function IOSession(host, logger) { - _super.call(this, host, Buffer.byteLength, process.hrtime, logger); + function IOSession(host, cancellationToken, installerEventPort, canUseEvents, useSingleInferredProject, globalTypingsCacheLocation, logger) { + return _super.call(this, host, cancellationToken, useSingleInferredProject, new NodeTypingsInstaller(logger, installerEventPort, globalTypingsCacheLocation, host.newLine), Buffer.byteLength, process.hrtime, logger, canUseEvents) || this; } IOSession.prototype.exit = function () { - this.projectService.log("Exiting...", "Info"); + this.logger.info("Exiting..."); this.projectService.closeLog(); process.exit(0); }; @@ -63523,7 +65805,7 @@ var ts; return IOSession; }(server.Session)); function parseLoggingEnvironmentString(logEnvStr) { - var logEnv = {}; + var logEnv = { logToFile: true }; var args = logEnvStr.split(" "); for (var i = 0, len = args.length; i < (len - 1); i += 2) { var option = args[i]; @@ -63531,10 +65813,17 @@ var ts; if (option && value) { switch (option) { case "-file": - logEnv.file = value; + logEnv.file = ts.stripQuotes(value); break; case "-level": - logEnv.detailLevel = value; + var level = server.LogLevel[value]; + logEnv.detailLevel = typeof level === "number" ? level : server.LogLevel.normal; + break; + case "-traceToConsole": + logEnv.traceToConsole = value.toLowerCase() === "true"; + break; + case "-logToFile": + logEnv.logToFile = value.toLowerCase() === "true"; break; } } @@ -63543,21 +65832,25 @@ var ts; } function createLoggerFromEnv() { var fileName = undefined; - var detailLevel = "normal"; + var detailLevel = server.LogLevel.normal; + var traceToConsole = false; var logEnvStr = process.env["TSS_LOG"]; if (logEnvStr) { var logEnv = parseLoggingEnvironmentString(logEnvStr); - if (logEnv.file) { - fileName = logEnv.file; - } - else { - fileName = __dirname + "/.log" + process.pid.toString(); + if (logEnv.logToFile) { + if (logEnv.file) { + fileName = logEnv.file; + } + else { + fileName = __dirname + "/.log" + process.pid.toString(); + } } if (logEnv.detailLevel) { detailLevel = logEnv.detailLevel; } + traceToConsole = logEnv.traceToConsole; } - return new Logger(fileName, detailLevel); + return new Logger(fileName, traceToConsole, detailLevel); } function createPollingWatchedFileSet(interval, chunkSize) { if (interval === void 0) { interval = 2500; } @@ -63629,13 +65922,13 @@ var ts; var logger = createLoggerFromEnv(); var pending = []; var canWrite = true; - function writeMessage(s) { + function writeMessage(buf) { if (!canWrite) { - pending.push(s); + pending.push(buf); } else { canWrite = false; - process.stdout.write(new Buffer(s, "utf8"), setCanWriteFlagAndWriteMessageIfNecessary); + process.stdout.write(buf, setCanWriteFlagAndWriteMessageIfNecessary); } } function setCanWriteFlagAndWriteMessageIfNecessary() { @@ -63645,7 +65938,7 @@ var ts; } } var sys = ts.sys; - sys.write = function (s) { return writeMessage(s); }; + sys.write = function (s) { return writeMessage(new Buffer(s, "utf8")); }; sys.watchFile = function (fileName, callback) { var watchedFile = pollingWatchedFileSet.addFile(fileName, callback); return { @@ -63654,14 +65947,42 @@ var ts; }; sys.setTimeout = setTimeout; sys.clearTimeout = clearTimeout; - var ioSession = new IOSession(sys, logger); + sys.setImmediate = setImmediate; + sys.clearImmediate = clearImmediate; + if (typeof global !== "undefined" && global.gc) { + sys.gc = function () { return global.gc(); }; + } + var cancellationToken; + try { + var factory = require("./cancellationToken"); + cancellationToken = factory(sys.args); + } + catch (e) { + cancellationToken = { + isCancellationRequested: function () { return false; } + }; + } + ; + var eventPort; + { + var index = sys.args.indexOf("--eventPort"); + if (index >= 0 && index < sys.args.length - 1) { + var v = parseInt(sys.args[index + 1]); + if (!isNaN(v)) { + eventPort = v; + } + } + } + var useSingleInferredProject = sys.args.indexOf("--useSingleInferredProject") >= 0; + var ioSession = new IOSession(sys, cancellationToken, eventPort, eventPort === undefined, useSingleInferredProject, getGlobalTypingsCacheLocation(), logger); process.on("uncaughtException", function (err) { ioSession.logError(err, "unknown"); }); + process.noAsar = true; ioSession.listen(); })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); -var debugObjectHost = new Function("return this")(); +var debugObjectHost = (function () { return this; })(); var ts; (function (ts) { function logInternalError(logger, err) { @@ -63739,6 +66060,12 @@ var ts; } return this.shimHost.getProjectVersion(); }; + LanguageServiceShimHostAdapter.prototype.getTypeRootsVersion = function () { + if (!this.shimHost.getTypeRootsVersion) { + return 0; + } + return this.shimHost.getTypeRootsVersion(); + }; LanguageServiceShimHostAdapter.prototype.useCaseSensitiveFileNames = function () { return this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false; }; @@ -63932,11 +66259,12 @@ var ts; var LanguageServiceShimObject = (function (_super) { __extends(LanguageServiceShimObject, _super); function LanguageServiceShimObject(factory, host, languageService) { - _super.call(this, factory); - this.host = host; - this.languageService = languageService; - this.logPerformance = false; - this.logger = this.host; + var _this = _super.call(this, factory) || this; + _this.host = host; + _this.languageService = languageService; + _this.logPerformance = false; + _this.logger = _this.host; + return _this; } LanguageServiceShimObject.prototype.forwardJSONCall = function (actionDescription, action) { return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); @@ -64115,6 +66443,10 @@ var ts; var _this = this; return this.forwardJSONCall("getNavigationBarItems('" + fileName + "')", function () { return _this.languageService.getNavigationBarItems(fileName); }); }; + LanguageServiceShimObject.prototype.getNavigationTree = function (fileName) { + var _this = this; + return this.forwardJSONCall("getNavigationTree('" + fileName + "')", function () { return _this.languageService.getNavigationTree(fileName); }); + }; LanguageServiceShimObject.prototype.getOutliningSpans = function (fileName) { var _this = this; return this.forwardJSONCall("getOutliningSpans('" + fileName + "')", function () { return _this.languageService.getOutliningSpans(fileName); }); @@ -64139,10 +66471,11 @@ var ts; var ClassifierShimObject = (function (_super) { __extends(ClassifierShimObject, _super); function ClassifierShimObject(factory, logger) { - _super.call(this, factory); - this.logger = logger; - this.logPerformance = false; - this.classifier = ts.createClassifier(); + var _this = _super.call(this, factory) || this; + _this.logger = logger; + _this.logPerformance = false; + _this.classifier = ts.createClassifier(); + return _this; } ClassifierShimObject.prototype.getEncodedLexicalClassifications = function (text, lexState, syntacticClassifierAbsent) { var _this = this; @@ -64164,10 +66497,11 @@ var ts; var CoreServicesShimObject = (function (_super) { __extends(CoreServicesShimObject, _super); function CoreServicesShimObject(factory, logger, host) { - _super.call(this, factory); - this.logger = logger; - this.host = host; - this.logPerformance = false; + var _this = _super.call(this, factory) || this; + _this.logger = logger; + _this.host = host; + _this.logPerformance = false; + return _this; } CoreServicesShimObject.prototype.forwardJSONCall = function (actionDescription, action) { return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); diff --git a/lib/tsserverlibrary.d.ts b/lib/tsserverlibrary.d.ts index 7ed6595bc80..c23bccf0a68 100644 --- a/lib/tsserverlibrary.d.ts +++ b/lib/tsserverlibrary.d.ts @@ -1,4 +1,700 @@ -/// +/// +/// +declare namespace ts.server.protocol { + namespace CommandTypes { + type Brace = "brace"; + type BraceFull = "brace-full"; + type BraceCompletion = "braceCompletion"; + type Change = "change"; + type Close = "close"; + type Completions = "completions"; + type CompletionsFull = "completions-full"; + type CompletionDetails = "completionEntryDetails"; + type CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList"; + type CompileOnSaveEmitFile = "compileOnSaveEmitFile"; + type Configure = "configure"; + type Definition = "definition"; + type DefinitionFull = "definition-full"; + type Implementation = "implementation"; + type ImplementationFull = "implementation-full"; + type Exit = "exit"; + type Format = "format"; + type Formatonkey = "formatonkey"; + type FormatFull = "format-full"; + type FormatonkeyFull = "formatonkey-full"; + type FormatRangeFull = "formatRange-full"; + type Geterr = "geterr"; + type GeterrForProject = "geterrForProject"; + type SemanticDiagnosticsSync = "semanticDiagnosticsSync"; + type SyntacticDiagnosticsSync = "syntacticDiagnosticsSync"; + type NavBar = "navbar"; + type NavBarFull = "navbar-full"; + type Navto = "navto"; + type NavtoFull = "navto-full"; + type NavTree = "navtree"; + type NavTreeFull = "navtree-full"; + type Occurrences = "occurrences"; + type DocumentHighlights = "documentHighlights"; + type DocumentHighlightsFull = "documentHighlights-full"; + type Open = "open"; + type Quickinfo = "quickinfo"; + type QuickinfoFull = "quickinfo-full"; + type References = "references"; + type ReferencesFull = "references-full"; + type Reload = "reload"; + type Rename = "rename"; + type RenameInfoFull = "rename-full"; + type RenameLocationsFull = "renameLocations-full"; + type Saveto = "saveto"; + type SignatureHelp = "signatureHelp"; + type SignatureHelpFull = "signatureHelp-full"; + type TypeDefinition = "typeDefinition"; + type ProjectInfo = "projectInfo"; + type ReloadProjects = "reloadProjects"; + type Unknown = "unknown"; + type OpenExternalProject = "openExternalProject"; + type OpenExternalProjects = "openExternalProjects"; + type CloseExternalProject = "closeExternalProject"; + type SynchronizeProjectList = "synchronizeProjectList"; + type ApplyChangedToOpenFiles = "applyChangedToOpenFiles"; + type EncodedSemanticClassificationsFull = "encodedSemanticClassifications-full"; + type Cleanup = "cleanup"; + type OutliningSpans = "outliningSpans"; + type TodoComments = "todoComments"; + type Indentation = "indentation"; + type DocCommentTemplate = "docCommentTemplate"; + type CompilerOptionsDiagnosticsFull = "compilerOptionsDiagnostics-full"; + type NameOrDottedNameSpan = "nameOrDottedNameSpan"; + type BreakpointStatement = "breakpointStatement"; + type CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects"; + type GetCodeFixes = "getCodeFixes"; + type GetCodeFixesFull = "getCodeFixes-full"; + type GetSupportedCodeFixes = "getSupportedCodeFixes"; + } + interface Message { + seq: number; + type: string; + } + interface Request extends Message { + command: string; + arguments?: any; + } + interface ReloadProjectsRequest extends Message { + command: CommandTypes.ReloadProjects; + } + interface Event extends Message { + event: string; + body?: any; + } + interface Response extends Message { + request_seq: number; + success: boolean; + command: string; + message?: string; + body?: any; + } + interface FileRequestArgs { + file: string; + projectFileName?: string; + } + interface DocCommentTemplateRequest extends FileLocationRequest { + command: CommandTypes.DocCommentTemplate; + } + interface DocCommandTemplateResponse extends Response { + body?: TextInsertion; + } + interface TodoCommentRequest extends FileRequest { + command: CommandTypes.TodoComments; + arguments: TodoCommentRequestArgs; + } + interface TodoCommentRequestArgs extends FileRequestArgs { + descriptors: TodoCommentDescriptor[]; + } + interface TodoCommentsResponse extends Response { + body?: TodoComment[]; + } + interface OutliningSpansRequest extends FileRequest { + command: CommandTypes.OutliningSpans; + } + interface OutliningSpansResponse extends Response { + body?: OutliningSpan[]; + } + interface IndentationRequest extends FileLocationRequest { + command: CommandTypes.Indentation; + arguments: IndentationRequestArgs; + } + interface IndentationResponse extends Response { + body?: IndentationResult; + } + interface IndentationResult { + position: number; + indentation: number; + } + interface IndentationRequestArgs extends FileLocationRequestArgs { + options?: EditorSettings; + } + interface ProjectInfoRequestArgs extends FileRequestArgs { + needFileNameList: boolean; + } + interface ProjectInfoRequest extends Request { + command: CommandTypes.ProjectInfo; + arguments: ProjectInfoRequestArgs; + } + interface CompilerOptionsDiagnosticsRequest extends Request { + arguments: CompilerOptionsDiagnosticsRequestArgs; + } + interface CompilerOptionsDiagnosticsRequestArgs { + projectFileName: string; + } + interface ProjectInfo { + configFileName: string; + fileNames?: string[]; + languageServiceDisabled?: boolean; + } + interface DiagnosticWithLinePosition { + message: string; + start: number; + length: number; + startLocation: Location; + endLocation: Location; + category: string; + code: number; + } + interface ProjectInfoResponse extends Response { + body?: ProjectInfo; + } + interface FileRequest extends Request { + arguments: FileRequestArgs; + } + interface FileLocationRequestArgs extends FileRequestArgs { + line: number; + offset: number; + position?: number; + } + interface CodeFixRequest extends Request { + command: CommandTypes.GetCodeFixes; + arguments: CodeFixRequestArgs; + } + interface CodeFixRequestArgs extends FileRequestArgs { + startLine: number; + startOffset: number; + startPosition?: number; + endLine: number; + endOffset: number; + endPosition?: number; + errorCodes?: number[]; + } + interface GetCodeFixesResponse extends Response { + body?: CodeAction[]; + } + interface FileLocationRequest extends FileRequest { + arguments: FileLocationRequestArgs; + } + interface GetSupportedCodeFixesRequest extends Request { + command: CommandTypes.GetSupportedCodeFixes; + } + interface GetSupportedCodeFixesResponse extends Response { + body?: string[]; + } + interface EncodedSemanticClassificationsRequest extends FileRequest { + arguments: EncodedSemanticClassificationsRequestArgs; + } + interface EncodedSemanticClassificationsRequestArgs extends FileRequestArgs { + start: number; + length: number; + } + interface DocumentHighlightsRequestArgs extends FileLocationRequestArgs { + filesToSearch: string[]; + } + interface DefinitionRequest extends FileLocationRequest { + command: CommandTypes.Definition; + } + interface TypeDefinitionRequest extends FileLocationRequest { + command: CommandTypes.TypeDefinition; + } + interface ImplementationRequest extends FileLocationRequest { + command: CommandTypes.Implementation; + } + interface Location { + line: number; + offset: number; + } + interface TextSpan { + start: Location; + end: Location; + } + interface FileSpan extends TextSpan { + file: string; + } + interface DefinitionResponse extends Response { + body?: FileSpan[]; + } + interface TypeDefinitionResponse extends Response { + body?: FileSpan[]; + } + interface ImplementationResponse extends Response { + body?: FileSpan[]; + } + interface BraceCompletionRequest extends FileLocationRequest { + command: CommandTypes.BraceCompletion; + arguments: BraceCompletionRequestArgs; + } + interface BraceCompletionRequestArgs extends FileLocationRequestArgs { + openingBrace: string; + } + interface OccurrencesRequest extends FileLocationRequest { + command: CommandTypes.Occurrences; + } + interface OccurrencesResponseItem extends FileSpan { + isWriteAccess: boolean; + } + interface OccurrencesResponse extends Response { + body?: OccurrencesResponseItem[]; + } + interface DocumentHighlightsRequest extends FileLocationRequest { + command: CommandTypes.DocumentHighlights; + arguments: DocumentHighlightsRequestArgs; + } + interface HighlightSpan extends TextSpan { + kind: string; + } + interface DocumentHighlightsItem { + file: string; + highlightSpans: HighlightSpan[]; + } + interface DocumentHighlightsResponse extends Response { + body?: DocumentHighlightsItem[]; + } + interface ReferencesRequest extends FileLocationRequest { + command: CommandTypes.References; + } + interface ReferencesResponseItem extends FileSpan { + lineText: string; + isWriteAccess: boolean; + isDefinition: boolean; + } + interface ReferencesResponseBody { + refs: ReferencesResponseItem[]; + symbolName: string; + symbolStartOffset: number; + symbolDisplayString: string; + } + interface ReferencesResponse extends Response { + body?: ReferencesResponseBody; + } + interface RenameRequestArgs extends FileLocationRequestArgs { + findInComments?: boolean; + findInStrings?: boolean; + } + interface RenameRequest extends FileLocationRequest { + command: CommandTypes.Rename; + arguments: RenameRequestArgs; + } + interface RenameInfo { + canRename: boolean; + localizedErrorMessage?: string; + displayName: string; + fullDisplayName: string; + kind: string; + kindModifiers: string; + } + interface SpanGroup { + file: string; + locs: TextSpan[]; + } + interface RenameResponseBody { + info: RenameInfo; + locs: SpanGroup[]; + } + interface RenameResponse extends Response { + body?: RenameResponseBody; + } + interface ExternalFile { + fileName: string; + scriptKind?: ScriptKind; + hasMixedContent?: boolean; + content?: string; + } + interface ExternalProject { + projectFileName: string; + rootFiles: ExternalFile[]; + options: ExternalProjectCompilerOptions; + typingOptions?: TypingOptions; + } + interface ExternalProjectCompilerOptions extends CompilerOptions { + compileOnSave?: boolean; + } + interface ProjectVersionInfo { + projectName: string; + isInferred: boolean; + version: number; + options: CompilerOptions; + } + interface ProjectChanges { + added: string[]; + removed: string[]; + } + interface ProjectFiles { + info?: ProjectVersionInfo; + files?: string[]; + changes?: ProjectChanges; + } + interface ProjectFilesWithDiagnostics extends ProjectFiles { + projectErrors: DiagnosticWithLinePosition[]; + } + interface ChangedOpenFile { + fileName: string; + changes: ts.TextChange[]; + } + interface ConfigureRequestArguments { + hostInfo?: string; + file?: string; + formatOptions?: FormatCodeSettings; + } + interface ConfigureRequest extends Request { + command: CommandTypes.Configure; + arguments: ConfigureRequestArguments; + } + interface ConfigureResponse extends Response { + } + interface OpenRequestArgs extends FileRequestArgs { + fileContent?: string; + scriptKindName?: "TS" | "JS" | "TSX" | "JSX"; + } + interface OpenRequest extends Request { + command: CommandTypes.Open; + arguments: OpenRequestArgs; + } + interface OpenExternalProjectRequest extends Request { + command: CommandTypes.OpenExternalProject; + arguments: OpenExternalProjectArgs; + } + type OpenExternalProjectArgs = ExternalProject; + interface OpenExternalProjectsRequest extends Request { + command: CommandTypes.OpenExternalProjects; + arguments: OpenExternalProjectsArgs; + } + interface OpenExternalProjectsArgs { + projects: ExternalProject[]; + } + interface OpenExternalProjectResponse extends Response { + } + interface OpenExternalProjectsResponse extends Response { + } + interface CloseExternalProjectRequest extends Request { + command: CommandTypes.CloseExternalProject; + arguments: CloseExternalProjectRequestArgs; + } + interface CloseExternalProjectRequestArgs { + projectFileName: string; + } + interface CloseExternalProjectResponse extends Response { + } + interface SynchronizeProjectListRequest extends Request { + arguments: SynchronizeProjectListRequestArgs; + } + interface SynchronizeProjectListRequestArgs { + knownProjects: protocol.ProjectVersionInfo[]; + } + interface ApplyChangedToOpenFilesRequest extends Request { + arguments: ApplyChangedToOpenFilesRequestArgs; + } + interface ApplyChangedToOpenFilesRequestArgs { + openFiles?: ExternalFile[]; + changedFiles?: ChangedOpenFile[]; + closedFiles?: string[]; + } + interface SetCompilerOptionsForInferredProjectsRequest extends Request { + command: CommandTypes.CompilerOptionsForInferredProjects; + arguments: SetCompilerOptionsForInferredProjectsArgs; + } + interface SetCompilerOptionsForInferredProjectsArgs { + options: ExternalProjectCompilerOptions; + } + interface SetCompilerOptionsForInferredProjectsResponse extends Response { + } + interface ExitRequest extends Request { + command: CommandTypes.Exit; + } + interface CloseRequest extends FileRequest { + command: CommandTypes.Close; + } + interface CompileOnSaveAffectedFileListRequest extends FileRequest { + command: CommandTypes.CompileOnSaveAffectedFileList; + } + interface CompileOnSaveAffectedFileListSingleProject { + projectFileName: string; + fileNames: string[]; + } + interface CompileOnSaveAffectedFileListResponse extends Response { + body: CompileOnSaveAffectedFileListSingleProject[]; + } + interface CompileOnSaveEmitFileRequest extends FileRequest { + command: CommandTypes.CompileOnSaveEmitFile; + arguments: CompileOnSaveEmitFileRequestArgs; + } + interface CompileOnSaveEmitFileRequestArgs extends FileRequestArgs { + forced?: boolean; + } + interface QuickInfoRequest extends FileLocationRequest { + command: CommandTypes.Quickinfo; + } + interface QuickInfoResponseBody { + kind: string; + kindModifiers: string; + start: Location; + end: Location; + displayString: string; + documentation: string; + } + interface QuickInfoResponse extends Response { + body?: QuickInfoResponseBody; + } + interface FormatRequestArgs extends FileLocationRequestArgs { + endLine: number; + endOffset: number; + endPosition?: number; + options?: FormatCodeSettings; + } + interface FormatRequest extends FileLocationRequest { + command: CommandTypes.Format; + arguments: FormatRequestArgs; + } + interface CodeEdit { + start: Location; + end: Location; + newText: string; + } + interface FileCodeEdits { + fileName: string; + textChanges: CodeEdit[]; + } + interface CodeFixResponse extends Response { + body?: CodeAction[]; + } + interface CodeAction { + description: string; + changes: FileCodeEdits[]; + } + interface FormatResponse extends Response { + body?: CodeEdit[]; + } + interface FormatOnKeyRequestArgs extends FileLocationRequestArgs { + key: string; + options?: FormatCodeSettings; + } + interface FormatOnKeyRequest extends FileLocationRequest { + command: CommandTypes.Formatonkey; + arguments: FormatOnKeyRequestArgs; + } + interface CompletionsRequestArgs extends FileLocationRequestArgs { + prefix?: string; + } + interface CompletionsRequest extends FileLocationRequest { + command: CommandTypes.Completions; + arguments: CompletionsRequestArgs; + } + interface CompletionDetailsRequestArgs extends FileLocationRequestArgs { + entryNames: string[]; + } + interface CompletionDetailsRequest extends FileLocationRequest { + command: CommandTypes.CompletionDetails; + arguments: CompletionDetailsRequestArgs; + } + interface SymbolDisplayPart { + text: string; + kind: string; + } + interface CompletionEntry { + name: string; + kind: string; + kindModifiers: string; + sortText: string; + replacementSpan?: TextSpan; + } + interface CompletionEntryDetails { + name: string; + kind: string; + kindModifiers: string; + displayParts: SymbolDisplayPart[]; + documentation: SymbolDisplayPart[]; + } + interface CompletionsResponse extends Response { + body?: CompletionEntry[]; + } + interface CompletionDetailsResponse extends Response { + body?: CompletionEntryDetails[]; + } + interface SignatureHelpParameter { + name: string; + documentation: SymbolDisplayPart[]; + displayParts: SymbolDisplayPart[]; + isOptional: boolean; + } + interface SignatureHelpItem { + isVariadic: boolean; + prefixDisplayParts: SymbolDisplayPart[]; + suffixDisplayParts: SymbolDisplayPart[]; + separatorDisplayParts: SymbolDisplayPart[]; + parameters: SignatureHelpParameter[]; + documentation: SymbolDisplayPart[]; + } + interface SignatureHelpItems { + items: SignatureHelpItem[]; + applicableSpan: TextSpan; + selectedItemIndex: number; + argumentIndex: number; + argumentCount: number; + } + interface SignatureHelpRequestArgs extends FileLocationRequestArgs { + } + interface SignatureHelpRequest extends FileLocationRequest { + command: CommandTypes.SignatureHelp; + arguments: SignatureHelpRequestArgs; + } + interface SignatureHelpResponse extends Response { + body?: SignatureHelpItems; + } + interface SemanticDiagnosticsSyncRequest extends FileRequest { + command: CommandTypes.SemanticDiagnosticsSync; + arguments: SemanticDiagnosticsSyncRequestArgs; + } + interface SemanticDiagnosticsSyncRequestArgs extends FileRequestArgs { + includeLinePosition?: boolean; + } + interface SemanticDiagnosticsSyncResponse extends Response { + body?: Diagnostic[] | DiagnosticWithLinePosition[]; + } + interface SyntacticDiagnosticsSyncRequest extends FileRequest { + command: CommandTypes.SyntacticDiagnosticsSync; + arguments: SyntacticDiagnosticsSyncRequestArgs; + } + interface SyntacticDiagnosticsSyncRequestArgs extends FileRequestArgs { + includeLinePosition?: boolean; + } + interface SyntacticDiagnosticsSyncResponse extends Response { + body?: Diagnostic[] | DiagnosticWithLinePosition[]; + } + interface GeterrForProjectRequestArgs { + file: string; + delay: number; + } + interface GeterrForProjectRequest extends Request { + command: CommandTypes.GeterrForProject; + arguments: GeterrForProjectRequestArgs; + } + interface GeterrRequestArgs { + files: string[]; + delay: number; + } + interface GeterrRequest extends Request { + command: CommandTypes.Geterr; + arguments: GeterrRequestArgs; + } + interface Diagnostic { + start: Location; + end: Location; + text: string; + code?: number; + } + interface DiagnosticEventBody { + file: string; + diagnostics: Diagnostic[]; + } + interface DiagnosticEvent extends Event { + body?: DiagnosticEventBody; + } + interface ConfigFileDiagnosticEventBody { + triggerFile: string; + configFile: string; + diagnostics: Diagnostic[]; + } + interface ConfigFileDiagnosticEvent extends Event { + body?: ConfigFileDiagnosticEventBody; + event: "configFileDiag"; + } + interface ReloadRequestArgs extends FileRequestArgs { + tmpfile: string; + } + interface ReloadRequest extends FileRequest { + command: CommandTypes.Reload; + arguments: ReloadRequestArgs; + } + interface ReloadResponse extends Response { + } + interface SavetoRequestArgs extends FileRequestArgs { + tmpfile: string; + } + interface SavetoRequest extends FileRequest { + command: CommandTypes.Saveto; + arguments: SavetoRequestArgs; + } + interface NavtoRequestArgs extends FileRequestArgs { + searchValue: string; + maxResultCount?: number; + currentFileOnly?: boolean; + projectFileName?: string; + } + interface NavtoRequest extends FileRequest { + command: CommandTypes.Navto; + arguments: NavtoRequestArgs; + } + interface NavtoItem { + name: string; + kind: string; + matchKind?: string; + isCaseSensitive?: boolean; + kindModifiers?: string; + file: string; + start: Location; + end: Location; + containerName?: string; + containerKind?: string; + } + interface NavtoResponse extends Response { + body?: NavtoItem[]; + } + interface ChangeRequestArgs extends FormatRequestArgs { + insertString?: string; + } + interface ChangeRequest extends FileLocationRequest { + command: CommandTypes.Change; + arguments: ChangeRequestArgs; + } + interface BraceResponse extends Response { + body?: TextSpan[]; + } + interface BraceRequest extends FileLocationRequest { + command: CommandTypes.Brace; + } + interface NavBarRequest extends FileRequest { + command: CommandTypes.NavBar; + } + interface NavTreeRequest extends FileRequest { + command: CommandTypes.NavTree; + } + interface NavigationBarItem { + text: string; + kind: string; + kindModifiers?: string; + spans: TextSpan[]; + childItems?: NavigationBarItem[]; + indent: number; + } + interface NavigationTree { + text: string; + kind: string; + kindModifiers: string; + spans: TextSpan[]; + childItems?: NavigationTree[]; + } + interface NavBarResponse extends Response { + body?: NavigationBarItem[]; + } + interface NavTreeResponse extends Response { + body?: NavigationTree; + } +} declare namespace ts { interface MapLike { [index: string]: T; @@ -15,6 +711,7 @@ declare namespace ts { contains(fileName: Path): boolean; remove(fileName: Path): void; forEachValue(f: (key: Path, v: T) => void): void; + getKeys(): Path[]; clear(): void; } interface TextRange { @@ -374,7 +1071,6 @@ declare namespace ts { ContextFlags = 1540096, TypeExcludesFlags = 327680, } - type ModifiersArray = NodeArray; const enum ModifierFlags { None = 0, Export = 1, @@ -421,19 +1117,24 @@ declare namespace ts { nextContainer?: Node; localSymbol?: Symbol; flowNode?: FlowNode; - transformId?: number; - emitFlags?: NodeEmitFlags; - sourceMapRange?: TextRange; - commentRange?: TextRange; + emitNode?: EmitNode; } interface NodeArray extends Array, TextRange { hasTrailingComma?: boolean; } - interface Token extends Node { - __tokenTag: any; - } - interface Modifier extends Token { + interface Token extends Node { + kind: TKind; } + type DotDotDotToken = Token; + type QuestionToken = Token; + type ColonToken = Token; + type EqualsToken = Token; + type AsteriskToken = Token; + type EqualsGreaterThanToken = Token; + type EndOfFileToken = Token; + type AtToken = Token; + type Modifier = Token | Token | Token | Token | Token | Token | Token | Token | Token | Token | Token; + type ModifiersArray = NodeArray; const enum GeneratedIdentifierKind { None = 0, Auto = 1, @@ -442,6 +1143,7 @@ declare namespace ts { Node = 4, } interface Identifier extends PrimaryExpression { + kind: SyntaxKind.Identifier; text: string; originalKeywordKind?: SyntaxKind; autoGenerateKind?: GeneratedIdentifierKind; @@ -451,6 +1153,7 @@ declare namespace ts { resolvedSymbol: Symbol; } interface QualifiedName extends Node { + kind: SyntaxKind.QualifiedName; left: EntityName; right: Identifier; } @@ -462,15 +1165,18 @@ declare namespace ts { name?: DeclarationName; } interface DeclarationStatement extends Declaration, Statement { - name?: Identifier; + name?: Identifier | LiteralExpression; } interface ComputedPropertyName extends Node { + kind: SyntaxKind.ComputedPropertyName; expression: Expression; } interface Decorator extends Node { + kind: SyntaxKind.Decorator; expression: LeftHandSideExpression; } interface TypeParameterDeclaration extends Declaration { + kind: SyntaxKind.TypeParameter; name: Identifier; constraint?: TypeNode; expression?: Expression; @@ -482,40 +1188,48 @@ declare namespace ts { type?: TypeNode; } interface CallSignatureDeclaration extends SignatureDeclaration, TypeElement { + kind: SyntaxKind.CallSignature; } interface ConstructSignatureDeclaration extends SignatureDeclaration, TypeElement { + kind: SyntaxKind.ConstructSignature; } type BindingName = Identifier | BindingPattern; interface VariableDeclaration extends Declaration { + kind: SyntaxKind.VariableDeclaration; parent?: VariableDeclarationList; name: BindingName; type?: TypeNode; initializer?: Expression; } interface VariableDeclarationList extends Node { + kind: SyntaxKind.VariableDeclarationList; declarations: NodeArray; } interface ParameterDeclaration extends Declaration { - dotDotDotToken?: Node; + kind: SyntaxKind.Parameter; + dotDotDotToken?: DotDotDotToken; name: BindingName; - questionToken?: Node; + questionToken?: QuestionToken; type?: TypeNode; initializer?: Expression; } interface BindingElement extends Declaration { + kind: SyntaxKind.BindingElement; propertyName?: PropertyName; - dotDotDotToken?: Node; + dotDotDotToken?: DotDotDotToken; name: BindingName; initializer?: Expression; } interface PropertySignature extends TypeElement { + kind: SyntaxKind.PropertySignature | SyntaxKind.JSDocRecordMember; name: PropertyName; - questionToken?: Node; + questionToken?: QuestionToken; type?: TypeNode; initializer?: Expression; } interface PropertyDeclaration extends ClassElement { - questionToken?: Node; + kind: SyntaxKind.PropertyDeclaration; + questionToken?: QuestionToken; name: PropertyName; type?: TypeNode; initializer?: Expression; @@ -526,22 +1240,23 @@ declare namespace ts { } type ObjectLiteralElementLike = PropertyAssignment | ShorthandPropertyAssignment | MethodDeclaration | AccessorDeclaration; interface PropertyAssignment extends ObjectLiteralElement { - _propertyAssignmentBrand: any; + kind: SyntaxKind.PropertyAssignment; name: PropertyName; - questionToken?: Node; + questionToken?: QuestionToken; initializer: Expression; } interface ShorthandPropertyAssignment extends ObjectLiteralElement { + kind: SyntaxKind.ShorthandPropertyAssignment; name: Identifier; - questionToken?: Node; - equalsToken?: Node; + questionToken?: QuestionToken; + equalsToken?: Token; objectAssignmentInitializer?: Expression; } interface VariableLikeDeclaration extends Declaration { propertyName?: PropertyName; - dotDotDotToken?: Node; + dotDotDotToken?: DotDotDotToken; name: DeclarationName; - questionToken?: Node; + questionToken?: QuestionToken; type?: TypeNode; initializer?: Expression; } @@ -552,96 +1267,119 @@ declare namespace ts { elements: NodeArray; } interface ObjectBindingPattern extends BindingPattern { + kind: SyntaxKind.ObjectBindingPattern; elements: NodeArray; } type ArrayBindingElement = BindingElement | OmittedExpression; interface ArrayBindingPattern extends BindingPattern { + kind: SyntaxKind.ArrayBindingPattern; elements: NodeArray; } interface FunctionLikeDeclaration extends SignatureDeclaration { _functionLikeDeclarationBrand: any; - asteriskToken?: Node; - questionToken?: Node; + asteriskToken?: AsteriskToken; + questionToken?: QuestionToken; body?: Block | Expression; } interface FunctionDeclaration extends FunctionLikeDeclaration, DeclarationStatement { + kind: SyntaxKind.FunctionDeclaration; name?: Identifier; body?: FunctionBody; } interface MethodSignature extends SignatureDeclaration, TypeElement { + kind: SyntaxKind.MethodSignature; name: PropertyName; } interface MethodDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { + kind: SyntaxKind.MethodDeclaration; name: PropertyName; body?: FunctionBody; } interface ConstructorDeclaration extends FunctionLikeDeclaration, ClassElement { + kind: SyntaxKind.Constructor; body?: FunctionBody; } interface SemicolonClassElement extends ClassElement { - _semicolonClassElementBrand: any; + kind: SyntaxKind.SemicolonClassElement; } - interface AccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { - _accessorDeclarationBrand: any; + interface GetAccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { + kind: SyntaxKind.GetAccessor; name: PropertyName; body: FunctionBody; } - interface GetAccessorDeclaration extends AccessorDeclaration { - } - interface SetAccessorDeclaration extends AccessorDeclaration { + interface SetAccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { + kind: SyntaxKind.SetAccessor; + name: PropertyName; + body: FunctionBody; } + type AccessorDeclaration = GetAccessorDeclaration | SetAccessorDeclaration; interface IndexSignatureDeclaration extends SignatureDeclaration, ClassElement, TypeElement { - _indexSignatureDeclarationBrand: any; + kind: SyntaxKind.IndexSignature; } interface TypeNode extends Node { _typeNodeBrand: any; } + interface KeywordTypeNode extends TypeNode { + kind: SyntaxKind.AnyKeyword | SyntaxKind.NumberKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.VoidKeyword; + } interface ThisTypeNode extends TypeNode { - _thisTypeNodeBrand: any; + kind: SyntaxKind.ThisType; } interface FunctionOrConstructorTypeNode extends TypeNode, SignatureDeclaration { - _functionOrConstructorTypeNodeBrand: any; + kind: SyntaxKind.FunctionType | SyntaxKind.ConstructorType; } interface FunctionTypeNode extends FunctionOrConstructorTypeNode { + kind: SyntaxKind.FunctionType; } interface ConstructorTypeNode extends FunctionOrConstructorTypeNode { + kind: SyntaxKind.ConstructorType; } interface TypeReferenceNode extends TypeNode { + kind: SyntaxKind.TypeReference; typeName: EntityName; typeArguments?: NodeArray; } interface TypePredicateNode extends TypeNode { + kind: SyntaxKind.TypePredicate; parameterName: Identifier | ThisTypeNode; type: TypeNode; } interface TypeQueryNode extends TypeNode { + kind: SyntaxKind.TypeQuery; exprName: EntityName; } interface TypeLiteralNode extends TypeNode, Declaration { + kind: SyntaxKind.TypeLiteral; members: NodeArray; } interface ArrayTypeNode extends TypeNode { + kind: SyntaxKind.ArrayType; elementType: TypeNode; } interface TupleTypeNode extends TypeNode { + kind: SyntaxKind.TupleType; elementTypes: NodeArray; } interface UnionOrIntersectionTypeNode extends TypeNode { + kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType; types: NodeArray; } interface UnionTypeNode extends UnionOrIntersectionTypeNode { + kind: SyntaxKind.UnionType; } interface IntersectionTypeNode extends UnionOrIntersectionTypeNode { + kind: SyntaxKind.IntersectionType; } interface ParenthesizedTypeNode extends TypeNode { + kind: SyntaxKind.ParenthesizedType; type: TypeNode; } interface LiteralTypeNode extends TypeNode { - _stringLiteralTypeBrand: any; + kind: SyntaxKind.LiteralType; literal: Expression; } interface StringLiteral extends LiteralExpression { - _stringLiteralBrand: any; + kind: SyntaxKind.StringLiteral; textSourceNode?: Identifier | StringLiteral; } interface Expression extends Node { @@ -649,9 +1387,10 @@ declare namespace ts { contextualType?: Type; } interface OmittedExpression extends Expression { - _omittedExpressionBrand: any; + kind: SyntaxKind.OmittedExpression; } interface PartiallyEmittedExpression extends LeftHandSideExpression { + kind: SyntaxKind.PartiallyEmittedExpression; expression: Expression; } interface UnaryExpression extends Expression { @@ -660,13 +1399,17 @@ declare namespace ts { interface IncrementExpression extends UnaryExpression { _incrementExpressionBrand: any; } + type PrefixUnaryOperator = SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.TildeToken | SyntaxKind.ExclamationToken; interface PrefixUnaryExpression extends IncrementExpression { - operator: SyntaxKind; + kind: SyntaxKind.PrefixUnaryExpression; + operator: PrefixUnaryOperator; operand: UnaryExpression; } + type PostfixUnaryOperator = SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken; interface PostfixUnaryExpression extends IncrementExpression { + kind: SyntaxKind.PostfixUnaryExpression; operand: LeftHandSideExpression; - operator: SyntaxKind; + operator: PostfixUnaryOperator; } interface PostfixExpression extends UnaryExpression { _postfixExpressionBrand: any; @@ -680,42 +1423,83 @@ declare namespace ts { interface PrimaryExpression extends MemberExpression { _primaryExpressionBrand: any; } + interface NullLiteral extends PrimaryExpression { + kind: SyntaxKind.NullKeyword; + } + interface BooleanLiteral extends PrimaryExpression { + kind: SyntaxKind.TrueKeyword | SyntaxKind.FalseKeyword; + } + interface ThisExpression extends PrimaryExpression { + kind: SyntaxKind.ThisKeyword; + } + interface SuperExpression extends PrimaryExpression { + kind: SyntaxKind.SuperKeyword; + } interface DeleteExpression extends UnaryExpression { + kind: SyntaxKind.DeleteExpression; expression: UnaryExpression; } interface TypeOfExpression extends UnaryExpression { + kind: SyntaxKind.TypeOfExpression; expression: UnaryExpression; } interface VoidExpression extends UnaryExpression { + kind: SyntaxKind.VoidExpression; expression: UnaryExpression; } interface AwaitExpression extends UnaryExpression { + kind: SyntaxKind.AwaitExpression; expression: UnaryExpression; } interface YieldExpression extends Expression { - asteriskToken?: Node; + kind: SyntaxKind.YieldExpression; + asteriskToken?: AsteriskToken; expression?: Expression; } + type ExponentiationOperator = SyntaxKind.AsteriskAsteriskToken; + type MultiplicativeOperator = SyntaxKind.AsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken; + type MultiplicativeOperatorOrHigher = ExponentiationOperator | MultiplicativeOperator; + type AdditiveOperator = SyntaxKind.PlusToken | SyntaxKind.MinusToken; + type AdditiveOperatorOrHigher = MultiplicativeOperatorOrHigher | AdditiveOperator; + type ShiftOperator = SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken; + type ShiftOperatorOrHigher = AdditiveOperatorOrHigher | ShiftOperator; + type RelationalOperator = SyntaxKind.LessThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.InstanceOfKeyword | SyntaxKind.InKeyword; + type RelationalOperatorOrHigher = ShiftOperatorOrHigher | RelationalOperator; + type EqualityOperator = SyntaxKind.EqualsEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.ExclamationEqualsToken; + type EqualityOperatorOrHigher = RelationalOperatorOrHigher | EqualityOperator; + type BitwiseOperator = SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken; + type BitwiseOperatorOrHigher = EqualityOperatorOrHigher | BitwiseOperator; + type LogicalOperator = SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken; + type LogicalOperatorOrHigher = BitwiseOperatorOrHigher | LogicalOperator; + type CompoundAssignmentOperator = SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken; + type AssignmentOperator = SyntaxKind.EqualsToken | CompoundAssignmentOperator; + type AssignmentOperatorOrHigher = LogicalOperatorOrHigher | AssignmentOperator; + type BinaryOperator = AssignmentOperatorOrHigher | SyntaxKind.CommaToken; + type BinaryOperatorToken = Token; interface BinaryExpression extends Expression, Declaration { + kind: SyntaxKind.BinaryExpression; left: Expression; - operatorToken: Node; + operatorToken: BinaryOperatorToken; right: Expression; } interface ConditionalExpression extends Expression { + kind: SyntaxKind.ConditionalExpression; condition: Expression; - questionToken: Node; + questionToken: QuestionToken; whenTrue: Expression; - colonToken: Node; + colonToken: ColonToken; whenFalse: Expression; } type FunctionBody = Block; type ConciseBody = FunctionBody | Expression; interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclaration { + kind: SyntaxKind.FunctionExpression; name?: Identifier; body: FunctionBody; } interface ArrowFunction extends Expression, FunctionLikeDeclaration { - equalsGreaterThanToken: Node; + kind: SyntaxKind.ArrowFunction; + equalsGreaterThanToken: EqualsGreaterThanToken; body: ConciseBody; } interface LiteralLikeNode extends Node { @@ -727,137 +1511,192 @@ declare namespace ts { interface LiteralExpression extends LiteralLikeNode, PrimaryExpression { _literalExpressionBrand: any; } + interface RegularExpressionLiteral extends LiteralExpression { + kind: SyntaxKind.RegularExpressionLiteral; + } + interface NoSubstitutionTemplateLiteral extends LiteralExpression { + kind: SyntaxKind.NoSubstitutionTemplateLiteral; + } interface NumericLiteral extends LiteralExpression { - _numericLiteralBrand: any; + kind: SyntaxKind.NumericLiteral; trailingComment?: string; } - interface TemplateLiteralFragment extends LiteralLikeNode { - _templateLiteralFragmentBrand: any; + interface TemplateHead extends LiteralLikeNode { + kind: SyntaxKind.TemplateHead; } - type Template = TemplateExpression | LiteralExpression; + interface TemplateMiddle extends LiteralLikeNode { + kind: SyntaxKind.TemplateMiddle; + } + interface TemplateTail extends LiteralLikeNode { + kind: SyntaxKind.TemplateTail; + } + type TemplateLiteral = TemplateExpression | NoSubstitutionTemplateLiteral; interface TemplateExpression extends PrimaryExpression { - head: TemplateLiteralFragment; + kind: SyntaxKind.TemplateExpression; + head: TemplateHead; templateSpans: NodeArray; } interface TemplateSpan extends Node { + kind: SyntaxKind.TemplateSpan; expression: Expression; - literal: TemplateLiteralFragment; + literal: TemplateMiddle | TemplateTail; } interface ParenthesizedExpression extends PrimaryExpression { + kind: SyntaxKind.ParenthesizedExpression; expression: Expression; } interface ArrayLiteralExpression extends PrimaryExpression { + kind: SyntaxKind.ArrayLiteralExpression; elements: NodeArray; multiLine?: boolean; } interface SpreadElementExpression extends Expression { + kind: SyntaxKind.SpreadElementExpression; expression: Expression; } interface ObjectLiteralExpressionBase extends PrimaryExpression, Declaration { properties: NodeArray; } interface ObjectLiteralExpression extends ObjectLiteralExpressionBase { + kind: SyntaxKind.ObjectLiteralExpression; multiLine?: boolean; } type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression; type EntityNameOrEntityNameExpression = EntityName | EntityNameExpression; interface PropertyAccessExpression extends MemberExpression, Declaration { + kind: SyntaxKind.PropertyAccessExpression; expression: LeftHandSideExpression; name: Identifier; } + interface SuperPropertyAccessExpression extends PropertyAccessExpression { + expression: SuperExpression; + } interface PropertyAccessEntityNameExpression extends PropertyAccessExpression { _propertyAccessExpressionLikeQualifiedNameBrand?: any; expression: EntityNameExpression; } interface ElementAccessExpression extends MemberExpression { + kind: SyntaxKind.ElementAccessExpression; expression: LeftHandSideExpression; argumentExpression?: Expression; } + interface SuperElementAccessExpression extends ElementAccessExpression { + expression: SuperExpression; + } + type SuperProperty = SuperPropertyAccessExpression | SuperElementAccessExpression; interface CallExpression extends LeftHandSideExpression, Declaration { + kind: SyntaxKind.CallExpression; expression: LeftHandSideExpression; typeArguments?: NodeArray; arguments: NodeArray; } + interface SuperCall extends CallExpression { + expression: SuperExpression; + } interface ExpressionWithTypeArguments extends TypeNode { + kind: SyntaxKind.ExpressionWithTypeArguments; expression: LeftHandSideExpression; typeArguments?: NodeArray; } - interface NewExpression extends CallExpression, PrimaryExpression { + interface NewExpression extends PrimaryExpression, Declaration { + kind: SyntaxKind.NewExpression; + expression: LeftHandSideExpression; + typeArguments?: NodeArray; + arguments: NodeArray; } interface TaggedTemplateExpression extends MemberExpression { + kind: SyntaxKind.TaggedTemplateExpression; tag: LeftHandSideExpression; - template: Template; + template: TemplateLiteral; } type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator; interface AsExpression extends Expression { + kind: SyntaxKind.AsExpression; expression: Expression; type: TypeNode; } interface TypeAssertion extends UnaryExpression { + kind: SyntaxKind.TypeAssertionExpression; type: TypeNode; expression: UnaryExpression; } type AssertionExpression = TypeAssertion | AsExpression; interface NonNullExpression extends LeftHandSideExpression { + kind: SyntaxKind.NonNullExpression; expression: Expression; } interface JsxElement extends PrimaryExpression { + kind: SyntaxKind.JsxElement; openingElement: JsxOpeningElement; children: NodeArray; closingElement: JsxClosingElement; } type JsxTagNameExpression = PrimaryExpression | PropertyAccessExpression; interface JsxOpeningElement extends Expression { - _openingElementBrand?: any; + kind: SyntaxKind.JsxOpeningElement; tagName: JsxTagNameExpression; attributes: NodeArray; } - interface JsxSelfClosingElement extends PrimaryExpression, JsxOpeningElement { - _selfClosingElementBrand?: any; + interface JsxSelfClosingElement extends PrimaryExpression { + kind: SyntaxKind.JsxSelfClosingElement; + tagName: JsxTagNameExpression; + attributes: NodeArray; } type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; interface JsxAttribute extends Node { + kind: SyntaxKind.JsxAttribute; name: Identifier; initializer?: StringLiteral | JsxExpression; } interface JsxSpreadAttribute extends Node { + kind: SyntaxKind.JsxSpreadAttribute; expression: Expression; } interface JsxClosingElement extends Node { + kind: SyntaxKind.JsxClosingElement; tagName: JsxTagNameExpression; } interface JsxExpression extends Expression { + kind: SyntaxKind.JsxExpression; expression?: Expression; } interface JsxText extends Node { - _jsxTextExpressionBrand: any; + kind: SyntaxKind.JsxText; } type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement; interface Statement extends Node { _statementBrand: any; } interface NotEmittedStatement extends Statement { + kind: SyntaxKind.NotEmittedStatement; } interface EmptyStatement extends Statement { + kind: SyntaxKind.EmptyStatement; } interface DebuggerStatement extends Statement { + kind: SyntaxKind.DebuggerStatement; } interface MissingDeclaration extends DeclarationStatement, ClassElement, ObjectLiteralElement, TypeElement { + kind: SyntaxKind.MissingDeclaration; name?: Identifier; } type BlockLike = SourceFile | Block | ModuleBlock | CaseClause; interface Block extends Statement { + kind: SyntaxKind.Block; statements: NodeArray; multiLine?: boolean; } interface VariableStatement extends Statement { + kind: SyntaxKind.VariableStatement; declarationList: VariableDeclarationList; } interface ExpressionStatement extends Statement { + kind: SyntaxKind.ExpressionStatement; expression: Expression; } interface IfStatement extends Statement { + kind: SyntaxKind.IfStatement; expression: Expression; thenStatement: Statement; elseStatement?: Statement; @@ -866,68 +1705,85 @@ declare namespace ts { statement: Statement; } interface DoStatement extends IterationStatement { + kind: SyntaxKind.DoStatement; expression: Expression; } interface WhileStatement extends IterationStatement { + kind: SyntaxKind.WhileStatement; expression: Expression; } type ForInitializer = VariableDeclarationList | Expression; interface ForStatement extends IterationStatement { + kind: SyntaxKind.ForStatement; initializer?: ForInitializer; condition?: Expression; incrementor?: Expression; } interface ForInStatement extends IterationStatement { + kind: SyntaxKind.ForInStatement; initializer: ForInitializer; expression: Expression; } interface ForOfStatement extends IterationStatement { + kind: SyntaxKind.ForOfStatement; initializer: ForInitializer; expression: Expression; } interface BreakStatement extends Statement { + kind: SyntaxKind.BreakStatement; label?: Identifier; } interface ContinueStatement extends Statement { + kind: SyntaxKind.ContinueStatement; label?: Identifier; } type BreakOrContinueStatement = BreakStatement | ContinueStatement; interface ReturnStatement extends Statement { + kind: SyntaxKind.ReturnStatement; expression?: Expression; } interface WithStatement extends Statement { + kind: SyntaxKind.WithStatement; expression: Expression; statement: Statement; } interface SwitchStatement extends Statement { + kind: SyntaxKind.SwitchStatement; expression: Expression; caseBlock: CaseBlock; possiblyExhaustive?: boolean; } interface CaseBlock extends Node { + kind: SyntaxKind.CaseBlock; clauses: NodeArray; } interface CaseClause extends Node { + kind: SyntaxKind.CaseClause; expression: Expression; statements: NodeArray; } interface DefaultClause extends Node { + kind: SyntaxKind.DefaultClause; statements: NodeArray; } type CaseOrDefaultClause = CaseClause | DefaultClause; interface LabeledStatement extends Statement { + kind: SyntaxKind.LabeledStatement; label: Identifier; statement: Statement; } interface ThrowStatement extends Statement { + kind: SyntaxKind.ThrowStatement; expression: Expression; } interface TryStatement extends Statement { + kind: SyntaxKind.TryStatement; tryBlock: Block; catchClause?: CatchClause; finallyBlock?: Block; } interface CatchClause extends Node { + kind: SyntaxKind.CatchClause; variableDeclaration: VariableDeclaration; block: Block; } @@ -939,9 +1795,11 @@ declare namespace ts { members: NodeArray; } interface ClassDeclaration extends ClassLikeDeclaration, DeclarationStatement { + kind: SyntaxKind.ClassDeclaration; name?: Identifier; } interface ClassExpression extends ClassLikeDeclaration, PrimaryExpression { + kind: SyntaxKind.ClassExpression; } interface ClassElement extends Declaration { _classElementBrand: any; @@ -950,85 +1808,108 @@ declare namespace ts { interface TypeElement extends Declaration { _typeElementBrand: any; name?: PropertyName; - questionToken?: Node; + questionToken?: QuestionToken; } interface InterfaceDeclaration extends DeclarationStatement { + kind: SyntaxKind.InterfaceDeclaration; name: Identifier; typeParameters?: NodeArray; heritageClauses?: NodeArray; members: NodeArray; } interface HeritageClause extends Node { + kind: SyntaxKind.HeritageClause; token: SyntaxKind; types?: NodeArray; } interface TypeAliasDeclaration extends DeclarationStatement { + kind: SyntaxKind.TypeAliasDeclaration; name: Identifier; typeParameters?: NodeArray; type: TypeNode; } interface EnumMember extends Declaration { + kind: SyntaxKind.EnumMember; name: PropertyName; initializer?: Expression; } interface EnumDeclaration extends DeclarationStatement { + kind: SyntaxKind.EnumDeclaration; name: Identifier; members: NodeArray; } type ModuleBody = ModuleBlock | ModuleDeclaration; type ModuleName = Identifier | StringLiteral; interface ModuleDeclaration extends DeclarationStatement { + kind: SyntaxKind.ModuleDeclaration; name: Identifier | LiteralExpression; - body?: ModuleBlock | ModuleDeclaration; + body?: ModuleBlock | NamespaceDeclaration; + } + interface NamespaceDeclaration extends ModuleDeclaration { + name: Identifier; + body: ModuleBlock | NamespaceDeclaration; } interface ModuleBlock extends Node, Statement { + kind: SyntaxKind.ModuleBlock; statements: NodeArray; } type ModuleReference = EntityName | ExternalModuleReference; interface ImportEqualsDeclaration extends DeclarationStatement { + kind: SyntaxKind.ImportEqualsDeclaration; name: Identifier; moduleReference: ModuleReference; } interface ExternalModuleReference extends Node { + kind: SyntaxKind.ExternalModuleReference; expression?: Expression; } interface ImportDeclaration extends Statement { + kind: SyntaxKind.ImportDeclaration; importClause?: ImportClause; moduleSpecifier: Expression; } type NamedImportBindings = NamespaceImport | NamedImports; interface ImportClause extends Declaration { + kind: SyntaxKind.ImportClause; name?: Identifier; namedBindings?: NamedImportBindings; } interface NamespaceImport extends Declaration { + kind: SyntaxKind.NamespaceImport; name: Identifier; } interface NamespaceExportDeclaration extends DeclarationStatement { + kind: SyntaxKind.NamespaceExportDeclaration; name: Identifier; moduleReference: LiteralLikeNode; } interface ExportDeclaration extends DeclarationStatement { + kind: SyntaxKind.ExportDeclaration; exportClause?: NamedExports; moduleSpecifier?: Expression; } interface NamedImports extends Node { + kind: SyntaxKind.NamedImports; elements: NodeArray; } interface NamedExports extends Node { + kind: SyntaxKind.NamedExports; elements: NodeArray; } type NamedImportsOrExports = NamedImports | NamedExports; interface ImportSpecifier extends Declaration { + kind: SyntaxKind.ImportSpecifier; propertyName?: Identifier; name: Identifier; } interface ExportSpecifier extends Declaration { + kind: SyntaxKind.ExportSpecifier; propertyName?: Identifier; name: Identifier; } type ImportOrExportSpecifier = ImportSpecifier | ExportSpecifier; interface ExportAssignment extends DeclarationStatement { + kind: SyntaxKind.ExportAssignment; isExportEquals?: boolean; expression: Expression; } @@ -1040,95 +1921,121 @@ declare namespace ts { kind: SyntaxKind; } interface JSDocTypeExpression extends Node { + kind: SyntaxKind.JSDocTypeExpression; type: JSDocType; } interface JSDocType extends TypeNode { _jsDocTypeBrand: any; } interface JSDocAllType extends JSDocType { - _JSDocAllTypeBrand: any; + kind: SyntaxKind.JSDocAllType; } interface JSDocUnknownType extends JSDocType { - _JSDocUnknownTypeBrand: any; + kind: SyntaxKind.JSDocUnknownType; } interface JSDocArrayType extends JSDocType { + kind: SyntaxKind.JSDocArrayType; elementType: JSDocType; } interface JSDocUnionType extends JSDocType { + kind: SyntaxKind.JSDocUnionType; types: NodeArray; } interface JSDocTupleType extends JSDocType { + kind: SyntaxKind.JSDocTupleType; types: NodeArray; } interface JSDocNonNullableType extends JSDocType { + kind: SyntaxKind.JSDocNonNullableType; type: JSDocType; } interface JSDocNullableType extends JSDocType { + kind: SyntaxKind.JSDocNullableType; type: JSDocType; } - interface JSDocRecordType extends JSDocType, TypeLiteralNode { + interface JSDocRecordType extends JSDocType { + kind: SyntaxKind.JSDocRecordType; literal: TypeLiteralNode; } interface JSDocTypeReference extends JSDocType { + kind: SyntaxKind.JSDocTypeReference; name: EntityName; typeArguments: NodeArray; } interface JSDocOptionalType extends JSDocType { + kind: SyntaxKind.JSDocOptionalType; type: JSDocType; } interface JSDocFunctionType extends JSDocType, SignatureDeclaration { + kind: SyntaxKind.JSDocFunctionType; parameters: NodeArray; type: JSDocType; } interface JSDocVariadicType extends JSDocType { + kind: SyntaxKind.JSDocVariadicType; type: JSDocType; } interface JSDocConstructorType extends JSDocType { + kind: SyntaxKind.JSDocConstructorType; type: JSDocType; } interface JSDocThisType extends JSDocType { + kind: SyntaxKind.JSDocThisType; type: JSDocType; } interface JSDocLiteralType extends JSDocType { + kind: SyntaxKind.JSDocLiteralType; literal: LiteralTypeNode; } type JSDocTypeReferencingNode = JSDocThisType | JSDocConstructorType | JSDocVariadicType | JSDocOptionalType | JSDocNullableType | JSDocNonNullableType; interface JSDocRecordMember extends PropertySignature { + kind: SyntaxKind.JSDocRecordMember; name: Identifier | LiteralExpression; type?: JSDocType; } interface JSDoc extends Node { + kind: SyntaxKind.JSDocComment; tags: NodeArray | undefined; comment: string | undefined; } interface JSDocTag extends Node { - atToken: Node; + atToken: AtToken; tagName: Identifier; comment: string | undefined; } + interface JSDocUnknownTag extends JSDocTag { + kind: SyntaxKind.JSDocTag; + } interface JSDocTemplateTag extends JSDocTag { + kind: SyntaxKind.JSDocTemplateTag; typeParameters: NodeArray; } interface JSDocReturnTag extends JSDocTag { + kind: SyntaxKind.JSDocReturnTag; typeExpression: JSDocTypeExpression; } interface JSDocTypeTag extends JSDocTag { + kind: SyntaxKind.JSDocTypeTag; typeExpression: JSDocTypeExpression; } interface JSDocTypedefTag extends JSDocTag, Declaration { + kind: SyntaxKind.JSDocTypedefTag; name?: Identifier; typeExpression?: JSDocTypeExpression; jsDocTypeLiteral?: JSDocTypeLiteral; } interface JSDocPropertyTag extends JSDocTag, TypeElement { + kind: SyntaxKind.JSDocPropertyTag; name: Identifier; typeExpression: JSDocTypeExpression; } interface JSDocTypeLiteral extends JSDocType { + kind: SyntaxKind.JSDocTypeLiteral; jsDocPropertyTags?: NodeArray; jsDocTypeTag?: JSDocTypeTag; } interface JSDocParameterTag extends JSDocTag { + kind: SyntaxKind.JSDocParameterTag; preParameterName?: Identifier; typeExpression?: JSDocTypeExpression; postParameterName?: Identifier; @@ -1154,7 +2061,7 @@ declare namespace ts { id?: number; } interface FlowStart extends FlowNode { - container?: FunctionExpression | ArrowFunction; + container?: FunctionExpression | ArrowFunction | MethodDeclaration; } interface FlowLabel extends FlowNode { antecedents: FlowNode[]; @@ -1183,8 +2090,9 @@ declare namespace ts { name: string; } interface SourceFile extends Declaration { + kind: SyntaxKind.SourceFile; statements: NodeArray; - endOfFileToken: Node; + endOfFileToken: Token; fileName: string; path: Path; text: string; @@ -1239,7 +2147,7 @@ declare namespace ts { interface Program extends ScriptReferenceHost { getRootFileNames(): string[]; getSourceFiles(): SourceFile[]; - emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken): EmitResult; + emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean): EmitResult; getOptionsDiagnostics(cancellationToken?: CancellationToken): Diagnostic[]; getGlobalDiagnostics(cancellationToken?: CancellationToken): Diagnostic[]; getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; @@ -1248,6 +2156,7 @@ declare namespace ts { getTypeChecker(): TypeChecker; getCommonSourceDirectory(): string; getDiagnosticsProducingTypeChecker(): TypeChecker; + dropDiagnosticsProducingTypeChecker(): void; getClassifiableNames(): Map; getNodeCount(): number; getIdentifierCount(): number; @@ -1379,6 +2288,7 @@ declare namespace ts { UseFullyQualifiedType = 128, InFirstTypeArgument = 256, InTypeAlias = 512, + UseTypeAliasValue = 1024, } const enum SymbolFormatFlags { None = 0, @@ -1399,9 +2309,10 @@ declare namespace ts { type: Type; } interface ThisTypePredicate extends TypePredicateBase { - _thisTypePredicateBrand: any; + kind: TypePredicateKind.This; } interface IdentifierTypePredicate extends TypePredicateBase { + kind: TypePredicateKind.Identifier; parameterName: string; parameterIndex: number; } @@ -1457,8 +2368,8 @@ declare namespace ts { getExternalModuleFileFromDeclaration(declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration): SourceFile; getTypeReferenceDirectivesForEntityName(name: EntityNameOrEntityNameExpression): string[]; getTypeReferenceDirectivesForSymbol(symbol: Symbol, meaning?: SymbolFlags): string[]; - isLiteralConstDeclaration(node: VariableDeclaration): boolean; - writeLiteralConstValue(node: VariableDeclaration, writer: SymbolWriter): void; + isLiteralConstDeclaration(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration): boolean; + writeLiteralConstValue(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration, writer: SymbolWriter): void; } const enum SymbolFlags { None = 0, @@ -1556,7 +2467,8 @@ declare namespace ts { mapper?: TypeMapper; referenced?: boolean; containingType?: UnionOrIntersectionType; - hasCommonType?: boolean; + hasNonUniformType?: boolean; + isPartial?: boolean; isDiscriminantProperty?: boolean; resolvedExports?: SymbolTable; exportsChecked?: boolean; @@ -1641,8 +2553,6 @@ declare namespace ts { ContainsWideningType = 33554432, ContainsObjectLiteral = 67108864, ContainsAnyFunctionType = 134217728, - ThisType = 268435456, - ObjectLiteralPatternWithComputedProperties = 536870912, Nullable = 6144, Literal = 480, StringOrNumberLiteral = 96, @@ -1659,7 +2569,7 @@ declare namespace ts { StructuredType = 4161536, StructuredOrTypeParameter = 4177920, Narrowable = 4178943, - NotUnionOrUnit = 2589191, + NotUnionOrUnit = 2589185, RequiresWidening = 100663296, PropagatingFlags = 234881024, } @@ -1687,6 +2597,7 @@ declare namespace ts { baseType: EnumType & UnionType; } interface ObjectType extends Type { + isObjectLiteralPatternWithComputedProperties?: boolean; } interface InterfaceType extends ObjectType { typeParameters: TypeParameter[]; @@ -1743,6 +2654,7 @@ declare namespace ts { target?: TypeParameter; mapper?: TypeMapper; resolvedApparentType: Type; + isThisType?: boolean; } const enum SignatureKind { Call = 0, @@ -1830,16 +2742,14 @@ declare namespace ts { Classic = 1, NodeJs = 2, } - type RootPaths = string[]; - type PathSubstitutions = MapLike; - type TsConfigOnlyOptions = RootPaths | PathSubstitutions; - type CompilerOptionsValue = string | number | boolean | (string | number)[] | TsConfigOnlyOptions; + type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike; interface CompilerOptions { allowJs?: boolean; allowNonTsExtensions?: boolean; allowSyntheticDefaultImports?: boolean; allowUnreachableCode?: boolean; allowUnusedLabels?: boolean; + alwaysStrict?: boolean; baseUrl?: string; charset?: string; configFilePath?: string; @@ -1884,14 +2794,14 @@ declare namespace ts { out?: string; outDir?: string; outFile?: string; - paths?: PathSubstitutions; + paths?: MapLike; preserveConstEnums?: boolean; project?: string; pretty?: DiagnosticStyle; reactNamespace?: string; removeComments?: boolean; rootDir?: string; - rootDirs?: RootPaths; + rootDirs?: string[]; skipLibCheck?: boolean; skipDefaultLibCheck?: boolean; sourceMap?: boolean; @@ -1974,6 +2884,7 @@ declare namespace ts { raw?: any; errors: Diagnostic[]; wildcardDirectories?: MapLike; + compileOnSave?: boolean; } const enum WatchDirectoryFlags { None = 0, @@ -2221,7 +3132,15 @@ declare namespace ts { TypeScriptClassSyntaxMask = 137216, ES6FunctionSyntaxMask = 81920, } - const enum NodeEmitFlags { + interface EmitNode { + flags?: EmitFlags; + commentRange?: TextRange; + sourceMapRange?: TextRange; + tokenSourceMapRanges?: Map; + annotatedNodes?: Node[]; + constantValue?: number; + } + const enum EmitFlags { EmitEmitHelpers = 1, EmitExportStar = 2, EmitSuperHelper = 4, @@ -2250,6 +3169,12 @@ declare namespace ts { ReuseTempVariableScope = 4194304, CustomPrologue = 8388608, } + const enum EmitContext { + SourceFile = 0, + Expression = 1, + IdentifierName = 2, + Unspecified = 3, + } interface LexicalEnvironment { startLexicalEnvironment(): void; endLexicalEnvironment(): Statement[]; @@ -2327,7 +3252,7 @@ declare namespace ts { function singleOrUndefined(array: T[]): T; function singleOrMany(array: T[]): T | T[]; function lastOrUndefined(array: T[]): T; - function binarySearch(array: number[], value: number): number; + function binarySearch(array: T[], value: T, comparer?: (v1: T, v2: T) => number): number; function reduceLeft(array: T[], f: (memo: U, value: T, i: number) => U, initial: U, start?: number, count?: number): U; function reduceLeft(array: T[], f: (memo: T, value: T, i: number) => T): T; function reduceRight(array: T[], f: (memo: U, value: T, i: number) => U, initial: U, start?: number, count?: number): U; @@ -2354,6 +3279,8 @@ declare namespace ts { function multiMapRemove(map: Map, key: string, value: V): void; function isArray(value: any): value is any[]; function memoize(callback: () => T): () => T; + function chain(...args: ((t: T) => (u: U) => U)[]): (t: T) => (u: U) => U; + function compose(...args: ((t: T) => T)[]): (t: T) => T; let localizedDiagnosticMessages: Map; function getLocaleSpecificMessage(message: DiagnosticMessage): string; function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ...args: any[]): Diagnostic; @@ -2375,7 +3302,12 @@ declare namespace ts { function getDirectoryPath(path: Path): Path; function getDirectoryPath(path: string): string; function isUrl(path: string): boolean; + function isExternalModuleNameRelative(moduleName: string): boolean; + function getEmitScriptTarget(compilerOptions: CompilerOptions): ScriptTarget; + function getEmitModuleKind(compilerOptions: CompilerOptions): ModuleKind; + function hasZeroOrOneAsteriskCharacter(str: string): boolean; function isRootedDiskPath(path: string): boolean; + function convertToRelativePath(absoluteOrRelativePath: string, basePath: string, getCanonicalFileName: (path: string) => string): string; function getNormalizedPathComponents(path: string, currentDirectory: string): string[]; function getNormalizedAbsolutePath(fileName: string, currentDirectory: string): string; function getNormalizedPathFromPathComponents(pathComponents: string[]): string; @@ -2409,6 +3341,8 @@ declare namespace ts { const supportedTypescriptExtensionsForExtractExtension: string[]; const supportedJavascriptExtensions: string[]; function getSupportedExtensions(options?: CompilerOptions): string[]; + function hasJavaScriptFileExtension(fileName: string): boolean; + function hasTypeScriptFileExtension(fileName: string): boolean; function isSupportedSourceFileName(fileName: string, compilerOptions?: CompilerOptions): boolean; const enum ExtensionPriority { TypeScriptFiles = 0, @@ -2427,9 +3361,9 @@ declare namespace ts { function changeExtension(path: T, newExtension: string): T; interface ObjectAllocator { getNodeConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => Node; - getTokenConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => Token; - getIdentifierConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => Token; - getSourceFileConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => SourceFile; + getTokenConstructor(): new (kind: TKind, pos?: number, end?: number) => Token; + getIdentifierConstructor(): new (kind: SyntaxKind.Identifier, pos?: number, end?: number) => Identifier; + getSourceFileConstructor(): new (kind: SyntaxKind.SourceFile, pos?: number, end?: number) => SourceFile; getSymbolConstructor(): new (flags: SymbolFlags, name: string) => Symbol; getTypeConstructor(): new (checker: TypeChecker, flags: TypeFlags) => Type; getSignatureConstructor(): new (checker: TypeChecker) => Signature; @@ -2442,15 +3376,21 @@ declare namespace ts { VeryAggressive = 3, } namespace Debug { + let currentAssertionLevel: AssertionLevel; function shouldAssert(level: AssertionLevel): boolean; function assert(expression: boolean, message?: string, verboseDebugInfo?: () => string): void; function fail(message?: string): void; } - function getEnvironmentVariable(name: string, host?: CompilerHost): string; function orderedRemoveItemAt(array: T[], index: number): void; function unorderedRemoveItemAt(array: T[], index: number): void; function unorderedRemoveItem(array: T[], item: T): void; function createGetCanonicalFileName(useCaseSensitiveFileNames: boolean): (fileName: string) => string; + function matchPatternOrExact(patternStrings: string[], candidate: string): string | Pattern | undefined; + function patternText({prefix, suffix}: Pattern): string; + function matchedText(pattern: Pattern, candidate: string): string; + function findBestPatternMatch(values: T[], getPattern: (value: T) => Pattern, candidate: string): T | undefined; + function tryParsePattern(pattern: string): Pattern | undefined; + function positionIsSynthesized(pos: number): boolean; } declare namespace ts { type FileWatcherCallback = (fileName: string, removed?: boolean) => void; @@ -2493,10 +3433,10 @@ declare namespace ts { directoryName: string; referenceCount: number; } - var sys: System; + let sys: System; } declare namespace ts { - var Diagnostics: { + const Diagnostics: { Unterminated_string_literal: { code: number; category: DiagnosticCategory; @@ -4417,7 +5357,7 @@ declare namespace ts { key: string; message: string; }; - All_symbols_within_a_with_block_will_be_resolved_to_any: { + The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any: { code: number; category: DiagnosticCategory; key: string; @@ -5383,7 +6323,7 @@ declare namespace ts { key: string; message: string; }; - Identifier_0_must_be_imported_from_a_module: { + _0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead: { code: number; category: DiagnosticCategory; key: string; @@ -6781,6 +7721,18 @@ declare namespace ts { key: string; message: string; }; + Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Parse_in_strict_mode_and_emit_use_strict_for_each_source_file: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; Variable_0_implicitly_has_an_1_type: { code: number; category: DiagnosticCategory; @@ -6925,6 +7877,12 @@ declare namespace ts { key: string; message: string; }; + Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; You_cannot_rename_this_element: { code: number; category: DiagnosticCategory; @@ -7105,6 +8063,48 @@ declare namespace ts { key: string; message: string; }; + Add_missing_super_call: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Make_super_call_the_first_statement_in_the_constructor: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Change_extends_to_implements: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Remove_unused_identifiers: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Implement_interface_on_reference: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Implement_interface_on_class: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Implement_inherited_abstract_class: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; }; } declare namespace ts { @@ -7174,6 +8174,7 @@ declare namespace ts { function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, languageVariant?: LanguageVariant, text?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner; } declare namespace ts { + const compileOnSaveCommandLineOption: CommandLineOption; const optionDeclarations: CommandLineOption[]; let typingOptionDeclarations: CommandLineOption[]; interface OptionNameMap { @@ -7190,7 +8191,7 @@ declare namespace ts { config?: any; error?: Diagnostic; }; - function parseConfigFileTextToJson(fileName: string, jsonText: string): { + function parseConfigFileTextToJson(fileName: string, jsonText: string, stripComments?: boolean): { config?: any; error?: Diagnostic; }; @@ -7198,15 +8199,136 @@ declare namespace ts { compilerOptions: Map; }; function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[]): ParsedCommandLine; + function convertCompileOnSaveOptionFromJson(jsonOption: any, basePath: string, errors: Diagnostic[]): boolean; function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: CompilerOptions; errors: Diagnostic[]; }; function convertTypingOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { - options: CompilerOptions; + options: TypingOptions; errors: Diagnostic[]; }; } +declare namespace ts.JsTyping { + interface TypingResolutionHost { + directoryExists: (path: string) => boolean; + fileExists: (fileName: string) => boolean; + readFile: (path: string, encoding?: string) => string; + readDirectory: (rootDir: string, extensions: string[], excludes: string[], includes: string[], depth?: number) => string[]; + } + function discoverTypings(host: TypingResolutionHost, fileNames: string[], projectRootPath: Path, safeListPath: Path, packageNameToTypingLocation: Map, typingOptions: TypingOptions, compilerOptions: CompilerOptions): { + cachedTypingPaths: string[]; + newTypingNames: string[]; + filesToWatch: string[]; + }; +} +declare namespace ts.server { + enum LogLevel { + terse = 0, + normal = 1, + requestTime = 2, + verbose = 3, + } + const emptyArray: ReadonlyArray; + interface Logger { + close(): void; + hasLevel(level: LogLevel): boolean; + loggingEnabled(): boolean; + perftrc(s: string): void; + info(s: string): void; + startGroup(): void; + endGroup(): void; + msg(s: string, type?: Msg.Types): void; + getLogFileName(): string; + } + namespace Msg { + type Err = "Err"; + const Err: Err; + type Info = "Info"; + const Info: Info; + type Perf = "Perf"; + const Perf: Perf; + type Types = Err | Info | Perf; + } + function createInstallTypingsRequest(project: Project, typingOptions: TypingOptions, cachePath?: string): DiscoverTypings; + namespace Errors { + function ThrowNoProject(): never; + function ThrowProjectLanguageServiceDisabled(): never; + function ThrowProjectDoesNotContainDocument(fileName: string, project: Project): never; + } + function getDefaultFormatCodeSettings(host: ServerHost): FormatCodeSettings; + function mergeMaps(target: MapLike, source: MapLike): void; + function removeItemFromSet(items: T[], itemToRemove: T): void; + type NormalizedPath = string & { + __normalizedPathTag: any; + }; + function toNormalizedPath(fileName: string): NormalizedPath; + function normalizedPathToPath(normalizedPath: NormalizedPath, currentDirectory: string, getCanonicalFileName: (f: string) => string): Path; + function asNormalizedPath(fileName: string): NormalizedPath; + interface NormalizedPathMap { + get(path: NormalizedPath): T; + set(path: NormalizedPath, value: T): void; + contains(path: NormalizedPath): boolean; + remove(path: NormalizedPath): void; + } + function createNormalizedPathMap(): NormalizedPathMap; + const nullLanguageService: LanguageService; + interface ServerLanguageServiceHost { + setCompilationSettings(options: CompilerOptions): void; + notifyFileRemoved(info: ScriptInfo): void; + } + const nullLanguageServiceHost: ServerLanguageServiceHost; + interface ProjectOptions { + configHasFilesProperty?: boolean; + files?: string[]; + wildcardDirectories?: Map; + compilerOptions?: CompilerOptions; + typingOptions?: TypingOptions; + compileOnSave?: boolean; + } + function isInferredProjectName(name: string): boolean; + function makeInferredProjectName(counter: number): string; + class ThrottledOperations { + private readonly host; + private pendingTimeouts; + constructor(host: ServerHost); + schedule(operationId: string, delay: number, cb: () => void): void; + private static run(self, operationId, cb); + } + class GcTimer { + private readonly host; + private readonly delay; + private readonly logger; + private timerId; + constructor(host: ServerHost, delay: number, logger: Logger); + scheduleCollect(): void; + private static run(self); + } +} +declare namespace ts { + function trace(host: ModuleResolutionHost, message: DiagnosticMessage, ...args: any[]): void; + function isTraceEnabled(compilerOptions: CompilerOptions, host: ModuleResolutionHost): boolean; + function createResolvedModule(resolvedFileName: string, isExternalLibraryImport: boolean, failedLookupLocations: string[]): ResolvedModuleWithFailedLookupLocations; + interface ModuleResolutionState { + host: ModuleResolutionHost; + compilerOptions: CompilerOptions; + traceEnabled: boolean; + skipTsx: boolean; + } + function getEffectiveTypeRoots(options: CompilerOptions, host: { + directoryExists?: (directoryName: string) => boolean; + getCurrentDirectory?: () => string; + }): string[] | undefined; + function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string, options: CompilerOptions, host: ModuleResolutionHost): ResolvedTypeReferenceDirectiveWithFailedLookupLocations; + function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[]; + function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; + function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; + function directoryProbablyExists(directoryName: string, host: { + directoryExists?: (directoryName: string) => boolean; + }): boolean; + function loadModuleFromNodeModules(moduleName: string, directory: string, failedLookupLocations: string[], state: ModuleResolutionState, checkOneLevel: boolean): string; + function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; +} declare namespace ts { const externalHelpersModuleNameText = "tslib"; interface ReferencePathMatchResult { @@ -7231,7 +8353,7 @@ declare namespace ts { function getSingleLineStringWriter(): StringSymbolWriter; function releaseStringWriter(writer: StringSymbolWriter): void; function getFullWidth(node: Node): number; - function arrayIsEqualTo(array1: T[], array2: T[], equaler?: (a: T, b: T) => boolean): boolean; + function arrayIsEqualTo(array1: ReadonlyArray, array2: ReadonlyArray, equaler?: (a: T, b: T) => boolean): boolean; function hasResolvedModule(sourceFile: SourceFile, moduleNameText: string): boolean; function getResolvedModule(sourceFile: SourceFile, moduleNameText: string): ResolvedModule; function setResolvedModule(sourceFile: SourceFile, moduleNameText: string, resolvedModule: ResolvedModule): void; @@ -7280,7 +8402,7 @@ declare namespace ts { function isConstEnumDeclaration(node: Node): boolean; function isConst(node: Node): boolean; function isLet(node: Node): boolean; - function isSuperCallExpression(n: Node): boolean; + function isSuperCall(n: Node): n is SuperCall; function isPrologueDirective(node: Node): boolean; function getLeadingCommentRangesOfNode(node: Node, sourceFileOfNode: SourceFile): CommentRange[]; function getLeadingCommentRangesOfNodeFromText(node: Node, text: string): CommentRange[]; @@ -7301,6 +8423,7 @@ declare namespace ts { function isIterationStatement(node: Node, lookInLabeledStatements: boolean): node is IterationStatement; function isFunctionBlock(node: Node): boolean; function isObjectLiteralMethod(node: Node): node is MethodDeclaration; + function isObjectLiteralOrClassExpressionMethod(node: Node): node is MethodDeclaration; function isIdentifierTypePredicate(predicate: TypePredicate): predicate is IdentifierTypePredicate; function isThisTypePredicate(predicate: TypePredicate): predicate is ThisTypePredicate; function getContainingFunction(node: Node): FunctionLikeDeclaration; @@ -7308,7 +8431,7 @@ declare namespace ts { function getThisContainer(node: Node, includeArrowFunctions: boolean): Node; function getSuperContainer(node: Node, stopOnFunctions: boolean): Node; function getImmediatelyInvokedFunctionExpression(func: Node): CallExpression; - function isSuperProperty(node: Node): node is (PropertyAccessExpression | ElementAccessExpression); + function isSuperProperty(node: Node): node is SuperProperty; function getEntityNameFromTypeNode(node: TypeNode): EntityNameOrEntityNameExpression; function isCallLikeExpression(node: Node): node is CallLikeExpression; function getInvokedExpression(node: CallLikeExpression): Expression; @@ -7318,7 +8441,6 @@ declare namespace ts { function childIsDecorated(node: Node): boolean; function isJSXTagName(node: Node): boolean; function isPartOfExpression(node: Node): boolean; - function isExternalModuleNameRelative(moduleName: string): boolean; function isInstantiatedModule(node: ModuleDeclaration, preserveConstEnums: boolean): boolean; function isExternalModuleImportEqualsDeclaration(node: Node): boolean; function getExternalModuleImportEqualsDeclarationExpression(node: Node): Expression; @@ -7330,7 +8452,7 @@ declare namespace ts { function isDeclarationOfFunctionExpression(s: Symbol): boolean; function getSpecialPropertyAssignmentKind(expression: Node): SpecialPropertyAssignmentKind; function getExternalModuleName(node: Node): Expression; - function getNamespaceDeclarationNode(node: ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration): NamespaceImport; + function getNamespaceDeclarationNode(node: ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration): ImportEqualsDeclaration | NamespaceImport; function isDefaultImport(node: ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration): boolean; function hasQuestionToken(node: Node): boolean; function isJSDocConstructSignature(node: Node): boolean; @@ -7373,7 +8495,6 @@ declare namespace ts { function getRootDeclaration(node: Node): Node; function nodeStartsNewLexicalEnvironment(node: Node): boolean; function nodeIsSynthesized(node: TextRange): boolean; - function positionIsSynthesized(pos: number): boolean; function getOriginalNode(node: Node): Node; function isParseTreeNode(node: Node): boolean; function getParseTreeNode(node: Node): Node; @@ -7387,7 +8508,7 @@ declare namespace ts { function getExpressionAssociativity(expression: Expression): Associativity; function getOperatorAssociativity(kind: SyntaxKind, operator: SyntaxKind, hasArguments?: boolean): Associativity; function getExpressionPrecedence(expression: Expression): 0 | 1 | -1 | 2 | 4 | 3 | 16 | 10 | 5 | 6 | 11 | 8 | 19 | 18 | 17 | 15 | 14 | 13 | 12 | 9 | 7; - function getOperator(expression: Expression): SyntaxKind; + function getOperator(expression: Expression): SyntaxKind.Unknown | SyntaxKind.EndOfFileToken | SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.NumericLiteral | SyntaxKind.StringLiteral | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral | SyntaxKind.TemplateHead | SyntaxKind.TemplateMiddle | SyntaxKind.TemplateTail | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.OpenParenToken | SyntaxKind.CloseParenToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.DotToken | SyntaxKind.DotDotDotToken | SyntaxKind.SemicolonToken | SyntaxKind.CommaToken | SyntaxKind.LessThanToken | SyntaxKind.LessThanSlashToken | SyntaxKind.GreaterThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.EqualsEqualsToken | SyntaxKind.ExclamationEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.EqualsGreaterThanToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.AsteriskToken | SyntaxKind.AsteriskAsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken | SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken | SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken | SyntaxKind.ExclamationToken | SyntaxKind.TildeToken | SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken | SyntaxKind.QuestionToken | SyntaxKind.ColonToken | SyntaxKind.AtToken | SyntaxKind.EqualsToken | SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken | SyntaxKind.Identifier | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.LetKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.StaticKeyword | SyntaxKind.YieldKeyword | SyntaxKind.AbstractKeyword | SyntaxKind.AsKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.GetKeyword | SyntaxKind.IsKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.NumberKeyword | SyntaxKind.SetKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.TypeKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.FromKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.OfKeyword | SyntaxKind.QualifiedName | SyntaxKind.ComputedPropertyName | SyntaxKind.TypeParameter | SyntaxKind.Parameter | SyntaxKind.Decorator | SyntaxKind.PropertySignature | SyntaxKind.PropertyDeclaration | SyntaxKind.MethodSignature | SyntaxKind.MethodDeclaration | SyntaxKind.Constructor | SyntaxKind.GetAccessor | SyntaxKind.SetAccessor | SyntaxKind.CallSignature | SyntaxKind.ConstructSignature | SyntaxKind.IndexSignature | SyntaxKind.TypePredicate | SyntaxKind.TypeReference | SyntaxKind.FunctionType | SyntaxKind.ConstructorType | SyntaxKind.TypeQuery | SyntaxKind.TypeLiteral | SyntaxKind.ArrayType | SyntaxKind.TupleType | SyntaxKind.UnionType | SyntaxKind.IntersectionType | SyntaxKind.ParenthesizedType | SyntaxKind.ThisType | SyntaxKind.LiteralType | SyntaxKind.ObjectBindingPattern | SyntaxKind.ArrayBindingPattern | SyntaxKind.BindingElement | SyntaxKind.ArrayLiteralExpression | SyntaxKind.ObjectLiteralExpression | SyntaxKind.PropertyAccessExpression | SyntaxKind.ElementAccessExpression | SyntaxKind.CallExpression | SyntaxKind.NewExpression | SyntaxKind.TaggedTemplateExpression | SyntaxKind.TypeAssertionExpression | SyntaxKind.ParenthesizedExpression | SyntaxKind.FunctionExpression | SyntaxKind.ArrowFunction | SyntaxKind.DeleteExpression | SyntaxKind.TypeOfExpression | SyntaxKind.VoidExpression | SyntaxKind.AwaitExpression | SyntaxKind.ConditionalExpression | SyntaxKind.TemplateExpression | SyntaxKind.YieldExpression | SyntaxKind.SpreadElementExpression | SyntaxKind.ClassExpression | SyntaxKind.OmittedExpression | SyntaxKind.ExpressionWithTypeArguments | SyntaxKind.AsExpression | SyntaxKind.NonNullExpression | SyntaxKind.TemplateSpan | SyntaxKind.SemicolonClassElement | SyntaxKind.Block | SyntaxKind.VariableStatement | SyntaxKind.EmptyStatement | SyntaxKind.ExpressionStatement | SyntaxKind.IfStatement | SyntaxKind.DoStatement | SyntaxKind.WhileStatement | SyntaxKind.ForStatement | SyntaxKind.ForInStatement | SyntaxKind.ForOfStatement | SyntaxKind.ContinueStatement | SyntaxKind.BreakStatement | SyntaxKind.ReturnStatement | SyntaxKind.WithStatement | SyntaxKind.SwitchStatement | SyntaxKind.LabeledStatement | SyntaxKind.ThrowStatement | SyntaxKind.TryStatement | SyntaxKind.DebuggerStatement | SyntaxKind.VariableDeclaration | SyntaxKind.VariableDeclarationList | SyntaxKind.FunctionDeclaration | SyntaxKind.ClassDeclaration | SyntaxKind.InterfaceDeclaration | SyntaxKind.TypeAliasDeclaration | SyntaxKind.EnumDeclaration | SyntaxKind.ModuleDeclaration | SyntaxKind.ModuleBlock | SyntaxKind.CaseBlock | SyntaxKind.NamespaceExportDeclaration | SyntaxKind.ImportEqualsDeclaration | SyntaxKind.ImportDeclaration | SyntaxKind.ImportClause | SyntaxKind.NamespaceImport | SyntaxKind.NamedImports | SyntaxKind.ImportSpecifier | SyntaxKind.ExportAssignment | SyntaxKind.ExportDeclaration | SyntaxKind.NamedExports | SyntaxKind.ExportSpecifier | SyntaxKind.MissingDeclaration | SyntaxKind.ExternalModuleReference | SyntaxKind.JsxElement | SyntaxKind.JsxSelfClosingElement | SyntaxKind.JsxOpeningElement | SyntaxKind.JsxText | SyntaxKind.JsxClosingElement | SyntaxKind.JsxAttribute | SyntaxKind.JsxSpreadAttribute | SyntaxKind.JsxExpression | SyntaxKind.CaseClause | SyntaxKind.DefaultClause | SyntaxKind.HeritageClause | SyntaxKind.CatchClause | SyntaxKind.PropertyAssignment | SyntaxKind.ShorthandPropertyAssignment | SyntaxKind.EnumMember | SyntaxKind.SourceFile | SyntaxKind.JSDocTypeExpression | SyntaxKind.JSDocAllType | SyntaxKind.JSDocUnknownType | SyntaxKind.JSDocArrayType | SyntaxKind.JSDocUnionType | SyntaxKind.JSDocTupleType | SyntaxKind.JSDocNullableType | SyntaxKind.JSDocNonNullableType | SyntaxKind.JSDocRecordType | SyntaxKind.JSDocRecordMember | SyntaxKind.JSDocTypeReference | SyntaxKind.JSDocOptionalType | SyntaxKind.JSDocFunctionType | SyntaxKind.JSDocVariadicType | SyntaxKind.JSDocConstructorType | SyntaxKind.JSDocThisType | SyntaxKind.JSDocComment | SyntaxKind.JSDocTag | SyntaxKind.JSDocParameterTag | SyntaxKind.JSDocReturnTag | SyntaxKind.JSDocTypeTag | SyntaxKind.JSDocTemplateTag | SyntaxKind.JSDocTypedefTag | SyntaxKind.JSDocPropertyTag | SyntaxKind.JSDocTypeLiteral | SyntaxKind.JSDocLiteralType | SyntaxKind.JSDocNullKeyword | SyntaxKind.JSDocUndefinedKeyword | SyntaxKind.JSDocNeverKeyword | SyntaxKind.SyntaxList | SyntaxKind.NotEmittedStatement | SyntaxKind.PartiallyEmittedExpression | SyntaxKind.Count; function getOperatorPrecedence(nodeKind: SyntaxKind, operatorKind: SyntaxKind, hasArguments?: boolean): 0 | 1 | -1 | 2 | 4 | 3 | 16 | 10 | 5 | 6 | 11 | 8 | 19 | 18 | 17 | 15 | 14 | 13 | 12 | 9 | 7; function createDiagnosticCollection(): DiagnosticCollection; function escapeString(s: string): string; @@ -7413,26 +8534,28 @@ declare namespace ts { function getIndentSize(): number; function createTextWriter(newLine: String): EmitTextWriter; function getResolvedExternalModuleName(host: EmitHost, file: SourceFile): string; - function getExternalModuleNameFromDeclaration(host: EmitHost, resolver: EmitResolver, declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration): string; + function getExternalModuleNameFromDeclaration(host: EmitHost, resolver: EmitResolver, declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration): string; function getExternalModuleNameFromPath(host: EmitHost, fileName: string): string; function getOwnEmitOutputFilePath(sourceFile: SourceFile, host: EmitHost, extension: string): string; function getDeclarationEmitOutputFilePath(sourceFile: SourceFile, host: EmitHost): string; - function getEmitScriptTarget(compilerOptions: CompilerOptions): ScriptTarget; - function getEmitModuleKind(compilerOptions: CompilerOptions): ModuleKind; interface EmitFileNames { jsFilePath: string; sourceMapFilePath: string; declarationFilePath: string; } function getSourceFilesToEmit(host: EmitHost, targetSourceFile?: SourceFile): SourceFile[]; - function forEachTransformedEmitFile(host: EmitHost, sourceFiles: SourceFile[], action: (jsFilePath: string, sourceMapFilePath: string, declarationFilePath: string, sourceFiles: SourceFile[], isBundledEmit: boolean) => void): void; - function forEachExpectedEmitFile(host: EmitHost, action: (emitFileNames: EmitFileNames, sourceFiles: SourceFile[], isBundledEmit: boolean) => void, targetSourceFile?: SourceFile): void; + function forEachTransformedEmitFile(host: EmitHost, sourceFiles: SourceFile[], action: (jsFilePath: string, sourceMapFilePath: string, declarationFilePath: string, sourceFiles: SourceFile[], isBundledEmit: boolean) => void, emitOnlyDtsFiles?: boolean): void; + function forEachExpectedEmitFile(host: EmitHost, action: (emitFileNames: EmitFileNames, sourceFiles: SourceFile[], isBundledEmit: boolean, emitOnlyDtsFiles: boolean) => void, targetSourceFile?: SourceFile, emitOnlyDtsFiles?: boolean): void; function getSourceFilePathInNewDir(sourceFile: SourceFile, host: EmitHost, newDirPath: string): string; function writeFile(host: EmitHost, diagnostics: DiagnosticCollection, fileName: string, data: string, writeByteOrderMark: boolean, sourceFiles?: SourceFile[]): void; function getLineOfLocalPosition(currentSourceFile: SourceFile, pos: number): number; function getLineOfLocalPositionFromLineMap(lineMap: number[], pos: number): number; function getFirstConstructorWithBody(node: ClassLikeDeclaration): ConstructorDeclaration; - function getSetAccessorTypeAnnotationNode(accessor: AccessorDeclaration): TypeNode; + function getSetAccessorTypeAnnotationNode(accessor: SetAccessorDeclaration): TypeNode; + function getThisParameter(signature: SignatureDeclaration): ParameterDeclaration | undefined; + function parameterIsThisKeyword(parameter: ParameterDeclaration): boolean; + function isThisIdentifier(node: Node | undefined): boolean; + function identifierIsThisKeyword(id: Identifier): boolean; interface AllAccessorDeclarations { firstAccessor: AccessorDeclaration; secondAccessor: AccessorDeclaration; @@ -7463,12 +8586,9 @@ declare namespace ts { function isRightSideOfQualifiedNameOrPropertyAccess(node: Node): boolean; function isEmptyObjectLiteralOrArrayLiteral(expression: Node): boolean; function getLocalSymbolForExportDefault(symbol: Symbol): Symbol; - function hasJavaScriptFileExtension(fileName: string): boolean; - function hasTypeScriptFileExtension(fileName: string): boolean; function tryExtractTypeScriptExtension(fileName: string): string | undefined; const stringify: (value: any) => string; function convertToBase64(input: string): string; - function convertToRelativePath(absoluteOrRelativePath: string, basePath: string, getCanonicalFileName: (path: string) => string): string; function getNewLineCharacter(options: CompilerOptions): string; function isSimpleExpression(node: Expression): boolean; function formatSyntaxKind(kind: SyntaxKind): string; @@ -7504,7 +8624,8 @@ declare namespace ts { function isTextualLiteralKind(kind: SyntaxKind): boolean; function isLiteralExpression(node: Node): node is LiteralExpression; function isTemplateLiteralKind(kind: SyntaxKind): boolean; - function isTemplateLiteralFragment(node: Node): node is TemplateLiteralFragment; + function isTemplateHead(node: Node): node is TemplateHead; + function isTemplateMiddleOrTemplateTail(node: Node): node is TemplateMiddle | TemplateTail; function isIdentifier(node: Node): node is Identifier; function isGeneratedIdentifier(node: Node): boolean; function isModifier(node: Node): node is Modifier; @@ -7529,7 +8650,7 @@ declare namespace ts { function isBinaryExpression(node: Node): node is BinaryExpression; function isConditionalExpression(node: Node): node is ConditionalExpression; function isCallExpression(node: Node): node is CallExpression; - function isTemplate(node: Node): node is Template; + function isTemplateLiteral(node: Node): node is TemplateLiteral; function isSpreadElementExpression(node: Node): node is SpreadElementExpression; function isExpressionWithTypeArguments(node: Node): node is ExpressionWithTypeArguments; function isLeftHandSideExpression(node: Node): node is LeftHandSideExpression; @@ -7613,24 +8734,25 @@ declare namespace ts { function createLiteral(textSource: StringLiteral | Identifier, location?: TextRange): StringLiteral; function createLiteral(value: string, location?: TextRange): StringLiteral; function createLiteral(value: number, location?: TextRange): NumericLiteral; + function createLiteral(value: boolean, location?: TextRange): BooleanLiteral; function createLiteral(value: string | number | boolean, location?: TextRange): PrimaryExpression; function createIdentifier(text: string, location?: TextRange): Identifier; function createTempVariable(recordTempVariable: ((node: Identifier) => void) | undefined, location?: TextRange): Identifier; function createLoopVariable(location?: TextRange): Identifier; function createUniqueName(text: string, location?: TextRange): Identifier; function getGeneratedNameForNode(node: Node, location?: TextRange): Identifier; - function createToken(token: SyntaxKind): Node; + function createToken(token: TKind): Token; function createSuper(): PrimaryExpression; function createThis(location?: TextRange): PrimaryExpression; function createNull(): PrimaryExpression; function createComputedPropertyName(expression: Expression, location?: TextRange): ComputedPropertyName; function updateComputedPropertyName(node: ComputedPropertyName, expression: Expression): ComputedPropertyName; function createParameter(name: string | Identifier | BindingPattern, initializer?: Expression, location?: TextRange): ParameterDeclaration; - function createParameterDeclaration(decorators: Decorator[], modifiers: Modifier[], dotDotDotToken: Node, name: string | Identifier | BindingPattern, questionToken: Node, type: TypeNode, initializer: Expression, location?: TextRange, flags?: NodeFlags): ParameterDeclaration; + function createParameterDeclaration(decorators: Decorator[], modifiers: Modifier[], dotDotDotToken: DotDotDotToken, name: string | Identifier | BindingPattern, questionToken: QuestionToken, type: TypeNode, initializer: Expression, location?: TextRange, flags?: NodeFlags): ParameterDeclaration; function updateParameterDeclaration(node: ParameterDeclaration, decorators: Decorator[], modifiers: Modifier[], name: BindingName, type: TypeNode, initializer: Expression): ParameterDeclaration; - function createProperty(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, questionToken: Node, type: TypeNode, initializer: Expression, location?: TextRange): PropertyDeclaration; + function createProperty(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, questionToken: QuestionToken, type: TypeNode, initializer: Expression, location?: TextRange): PropertyDeclaration; function updateProperty(node: PropertyDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, type: TypeNode, initializer: Expression): PropertyDeclaration; - function createMethod(decorators: Decorator[], modifiers: Modifier[], asteriskToken: Node, name: string | PropertyName, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags): MethodDeclaration; + function createMethod(decorators: Decorator[], modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | PropertyName, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags): MethodDeclaration; function updateMethod(node: MethodDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): MethodDeclaration; function createConstructor(decorators: Decorator[], modifiers: Modifier[], parameters: ParameterDeclaration[], body: Block, location?: TextRange, flags?: NodeFlags): ConstructorDeclaration; function updateConstructor(node: ConstructorDeclaration, decorators: Decorator[], modifiers: Modifier[], parameters: ParameterDeclaration[], body: Block): ConstructorDeclaration; @@ -7642,7 +8764,7 @@ declare namespace ts { function updateObjectBindingPattern(node: ObjectBindingPattern, elements: BindingElement[]): ObjectBindingPattern; function createArrayBindingPattern(elements: ArrayBindingElement[], location?: TextRange): ArrayBindingPattern; function updateArrayBindingPattern(node: ArrayBindingPattern, elements: ArrayBindingElement[]): ArrayBindingPattern; - function createBindingElement(propertyName: string | PropertyName, dotDotDotToken: Node, name: string | BindingName, initializer?: Expression, location?: TextRange): BindingElement; + function createBindingElement(propertyName: string | PropertyName, dotDotDotToken: DotDotDotToken, name: string | BindingName, initializer?: Expression, location?: TextRange): BindingElement; function updateBindingElement(node: BindingElement, propertyName: PropertyName, name: BindingName, initializer: Expression): BindingElement; function createArrayLiteral(elements?: Expression[], location?: TextRange, multiLine?: boolean): ArrayLiteralExpression; function updateArrayLiteral(node: ArrayLiteralExpression, elements: Expression[]): ArrayLiteralExpression; @@ -7656,13 +8778,13 @@ declare namespace ts { function updateCall(node: CallExpression, expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): CallExpression; function createNew(expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[], location?: TextRange, flags?: NodeFlags): NewExpression; function updateNew(node: NewExpression, expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): NewExpression; - function createTaggedTemplate(tag: Expression, template: Template, location?: TextRange): TaggedTemplateExpression; - function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, template: Template): TaggedTemplateExpression; + function createTaggedTemplate(tag: Expression, template: TemplateLiteral, location?: TextRange): TaggedTemplateExpression; + function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; function createParen(expression: Expression, location?: TextRange): ParenthesizedExpression; function updateParen(node: ParenthesizedExpression, expression: Expression): ParenthesizedExpression; - function createFunctionExpression(asteriskToken: Node, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags): FunctionExpression; + function createFunctionExpression(asteriskToken: AsteriskToken, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags): FunctionExpression; function updateFunctionExpression(node: FunctionExpression, name: Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionExpression; - function createArrowFunction(modifiers: Modifier[], typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, equalsGreaterThanToken: Node, body: ConciseBody, location?: TextRange, flags?: NodeFlags): ArrowFunction; + function createArrowFunction(modifiers: Modifier[], typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, equalsGreaterThanToken: EqualsGreaterThanToken, body: ConciseBody, location?: TextRange, flags?: NodeFlags): ArrowFunction; function updateArrowFunction(node: ArrowFunction, modifiers: Modifier[], typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: ConciseBody): ArrowFunction; function createDelete(expression: Expression, location?: TextRange): DeleteExpression; function updateDelete(node: DeleteExpression, expression: Expression): Expression; @@ -7672,17 +8794,17 @@ declare namespace ts { function updateVoid(node: VoidExpression, expression: Expression): VoidExpression; function createAwait(expression: Expression, location?: TextRange): AwaitExpression; function updateAwait(node: AwaitExpression, expression: Expression): AwaitExpression; - function createPrefix(operator: SyntaxKind, operand: Expression, location?: TextRange): PrefixUnaryExpression; + function createPrefix(operator: PrefixUnaryOperator, operand: Expression, location?: TextRange): PrefixUnaryExpression; function updatePrefix(node: PrefixUnaryExpression, operand: Expression): PrefixUnaryExpression; - function createPostfix(operand: Expression, operator: SyntaxKind, location?: TextRange): PostfixUnaryExpression; + function createPostfix(operand: Expression, operator: PostfixUnaryOperator, location?: TextRange): PostfixUnaryExpression; function updatePostfix(node: PostfixUnaryExpression, operand: Expression): PostfixUnaryExpression; - function createBinary(left: Expression, operator: SyntaxKind | Node, right: Expression, location?: TextRange): BinaryExpression; + function createBinary(left: Expression, operator: BinaryOperator | BinaryOperatorToken, right: Expression, location?: TextRange): BinaryExpression; function updateBinary(node: BinaryExpression, left: Expression, right: Expression): BinaryExpression; - function createConditional(condition: Expression, questionToken: Node, whenTrue: Expression, colonToken: Node, whenFalse: Expression, location?: TextRange): ConditionalExpression; + function createConditional(condition: Expression, questionToken: QuestionToken, whenTrue: Expression, colonToken: ColonToken, whenFalse: Expression, location?: TextRange): ConditionalExpression; function updateConditional(node: ConditionalExpression, condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; - function createTemplateExpression(head: TemplateLiteralFragment, templateSpans: TemplateSpan[], location?: TextRange): TemplateExpression; - function updateTemplateExpression(node: TemplateExpression, head: TemplateLiteralFragment, templateSpans: TemplateSpan[]): TemplateExpression; - function createYield(asteriskToken: Node, expression: Expression, location?: TextRange): YieldExpression; + function createTemplateExpression(head: TemplateHead, templateSpans: TemplateSpan[], location?: TextRange): TemplateExpression; + function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: TemplateSpan[]): TemplateExpression; + function createYield(asteriskToken: AsteriskToken, expression: Expression, location?: TextRange): YieldExpression; function updateYield(node: YieldExpression, expression: Expression): YieldExpression; function createSpread(expression: Expression, location?: TextRange): SpreadElementExpression; function updateSpread(node: SpreadElementExpression, expression: Expression): SpreadElementExpression; @@ -7691,8 +8813,8 @@ declare namespace ts { function createOmittedExpression(location?: TextRange): OmittedExpression; function createExpressionWithTypeArguments(typeArguments: TypeNode[], expression: Expression, location?: TextRange): ExpressionWithTypeArguments; function updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, typeArguments: TypeNode[], expression: Expression): ExpressionWithTypeArguments; - function createTemplateSpan(expression: Expression, literal: TemplateLiteralFragment, location?: TextRange): TemplateSpan; - function updateTemplateSpan(node: TemplateSpan, expression: Expression, literal: TemplateLiteralFragment): TemplateSpan; + function createTemplateSpan(expression: Expression, literal: TemplateMiddle | TemplateTail, location?: TextRange): TemplateSpan; + function updateTemplateSpan(node: TemplateSpan, expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; function createBlock(statements: Statement[], location?: TextRange, multiLine?: boolean, flags?: NodeFlags): Block; function updateBlock(node: Block, statements: Statement[]): Block; function createVariableStatement(modifiers: Modifier[], declarationList: VariableDeclarationList | VariableDeclaration[], location?: TextRange, flags?: NodeFlags): VariableStatement; @@ -7715,9 +8837,9 @@ declare namespace ts { function createForIn(initializer: ForInitializer, expression: Expression, statement: Statement, location?: TextRange): ForInStatement; function updateForIn(node: ForInStatement, initializer: ForInitializer, expression: Expression, statement: Statement): ForInStatement; function createForOf(initializer: ForInitializer, expression: Expression, statement: Statement, location?: TextRange): ForOfStatement; - function updateForOf(node: ForInStatement, initializer: ForInitializer, expression: Expression, statement: Statement): ForInStatement; - function createContinue(label?: Identifier, location?: TextRange): BreakStatement; - function updateContinue(node: ContinueStatement, label: Identifier): BreakStatement; + function updateForOf(node: ForOfStatement, initializer: ForInitializer, expression: Expression, statement: Statement): ForOfStatement; + function createContinue(label?: Identifier, location?: TextRange): ContinueStatement; + function updateContinue(node: ContinueStatement, label: Identifier): ContinueStatement; function createBreak(label?: Identifier, location?: TextRange): BreakStatement; function updateBreak(node: BreakStatement, label: Identifier): BreakStatement; function createReturn(expression?: Expression, location?: TextRange): ReturnStatement; @@ -7734,7 +8856,7 @@ declare namespace ts { function updateTry(node: TryStatement, tryBlock: Block, catchClause: CatchClause, finallyBlock: Block): TryStatement; function createCaseBlock(clauses: CaseOrDefaultClause[], location?: TextRange): CaseBlock; function updateCaseBlock(node: CaseBlock, clauses: CaseOrDefaultClause[]): CaseBlock; - function createFunctionDeclaration(decorators: Decorator[], modifiers: Modifier[], asteriskToken: Node, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags): FunctionDeclaration; + function createFunctionDeclaration(decorators: Decorator[], modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags): FunctionDeclaration; function updateFunctionDeclaration(node: FunctionDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionDeclaration; function createClassDeclaration(decorators: Decorator[], modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[], location?: TextRange): ClassDeclaration; function updateClassDeclaration(node: ClassDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]): ClassDeclaration; @@ -7828,6 +8950,7 @@ declare namespace ts { function createExpressionForPropertyName(memberName: PropertyName): Expression; function createExpressionForObjectLiteralElementLike(node: ObjectLiteralExpression, property: ObjectLiteralElementLike, receiver: Expression): Expression; function addPrologueDirectives(target: Statement[], source: Statement[], ensureUseStrict?: boolean, visitor?: (node: Node) => VisitResult): number; + function ensureUseStrict(node: SourceFile): SourceFile; function parenthesizeBinaryOperand(binaryOperator: SyntaxKind, operand: Expression, isLeftSideOfBinary: boolean, leftOperand?: Expression): Expression; function parenthesizeForNew(expression: Expression): LeftHandSideExpression; function parenthesizeForAccess(expression: Expression): LeftHandSideExpression; @@ -7852,6 +8975,17 @@ declare namespace ts { function skipPartiallyEmittedExpressions(node: Node): Node; function startOnNewLine(node: T): T; function setOriginalNode(node: T, original: Node): T; + function disposeEmitNodes(sourceFile: SourceFile): void; + function getEmitFlags(node: Node): EmitFlags; + function setEmitFlags(node: T, emitFlags: EmitFlags): T; + function setSourceMapRange(node: T, range: TextRange): T; + function setTokenSourceMapRange(node: T, token: SyntaxKind, range: TextRange): T; + function setCommentRange(node: T, range: TextRange): T; + function getCommentRange(node: Node): TextRange; + function getSourceMapRange(node: Node): TextRange; + function getTokenSourceMapRange(node: Node, token: SyntaxKind): TextRange; + function getConstantValue(node: PropertyAccessExpression | ElementAccessExpression): number; + function setConstantValue(node: PropertyAccessExpression | ElementAccessExpression, value: number): PropertyAccessExpression | ElementAccessExpression; function setTextRange(node: T, location: TextRange): T; function setNodeFlags(node: T, flags: NodeFlags): T; function setMultiLine(node: T, multiLine: boolean): T; @@ -7940,34 +9074,22 @@ declare namespace ts { } declare namespace ts { interface TransformationResult { - getSourceFiles(): SourceFile[]; - getTokenSourceMapRange(node: Node, token: SyntaxKind): TextRange; - isSubstitutionEnabled(node: Node): boolean; - isEmitNotificationEnabled(node: Node): boolean; - onSubstituteNode(node: Node, isExpression: boolean): Node; - onEmitNode(node: Node, emitCallback: (node: Node) => void): void; - dispose(): void; + transformed: SourceFile[]; + emitNodeWithSubstitution(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void; + emitNodeWithNotification(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void; } interface TransformationContext extends LexicalEnvironment { getCompilerOptions(): CompilerOptions; getEmitResolver(): EmitResolver; getEmitHost(): EmitHost; - getNodeEmitFlags(node: Node): NodeEmitFlags; - setNodeEmitFlags(node: T, flags: NodeEmitFlags): T; - getSourceMapRange(node: Node): TextRange; - setSourceMapRange(node: T, range: TextRange): T; - getTokenSourceMapRange(node: Node, token: SyntaxKind): TextRange; - setTokenSourceMapRange(node: T, token: SyntaxKind, range: TextRange): T; - getCommentRange(node: Node): TextRange; - setCommentRange(node: T, range: TextRange): T; hoistFunctionDeclaration(node: FunctionDeclaration): void; hoistVariableDeclaration(node: Identifier): void; enableSubstitution(kind: SyntaxKind): void; isSubstitutionEnabled(node: Node): boolean; - onSubstituteNode?: (node: Node, isExpression: boolean) => Node; + onSubstituteNode?: (emitContext: EmitContext, node: Node) => Node; enableEmitNotification(kind: SyntaxKind): void; isEmitNotificationEnabled(node: Node): boolean; - onEmitNode?: (node: Node, emit: (node: Node) => void) => void; + onEmitNode?: (emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void) => void; } type Transformer = (context: TransformationContext) => (node: SourceFile) => SourceFile; function getTransformers(compilerOptions: CompilerOptions): Transformer[]; @@ -7975,63 +9097,40 @@ declare namespace ts { } declare namespace ts { function getDeclarationDiagnostics(host: EmitHost, resolver: EmitResolver, targetSourceFile: SourceFile): Diagnostic[]; - function writeDeclarationFile(declarationFilePath: string, sourceFiles: SourceFile[], isBundledEmit: boolean, host: EmitHost, resolver: EmitResolver, emitterDiagnostics: DiagnosticCollection): boolean; + function writeDeclarationFile(declarationFilePath: string, sourceFiles: SourceFile[], isBundledEmit: boolean, host: EmitHost, resolver: EmitResolver, emitterDiagnostics: DiagnosticCollection, emitOnlyDtsFiles: boolean): boolean; } declare namespace ts { interface SourceMapWriter { initialize(filePath: string, sourceMapFilePath: string, sourceFiles: SourceFile[], isBundledEmit: boolean): void; reset(): void; - getSourceMapData(): SourceMapData; setSourceFile(sourceFile: SourceFile): void; emitPos(pos: number): void; - emitStart(range: TextRange): void; - emitStart(range: TextRange, contextNode: Node, ignoreNodeCallback: (node: Node) => boolean, ignoreChildrenCallback: (node: Node) => boolean, getTextRangeCallbackCallback: (node: Node) => TextRange): void; - emitEnd(range: TextRange): void; - emitEnd(range: TextRange, contextNode: Node, ignoreNodeCallback: (node: Node) => boolean, ignoreChildrenCallback: (node: Node) => boolean, getTextRangeCallbackCallback: (node: Node) => TextRange): void; - emitTokenStart(token: SyntaxKind, tokenStartPos: number): number; - emitTokenStart(token: SyntaxKind, tokenStartPos: number, contextNode: Node, ignoreTokenCallback: (node: Node, token: SyntaxKind) => boolean, getTokenTextRangeCallback: (node: Node, token: SyntaxKind) => TextRange): number; - emitTokenEnd(token: SyntaxKind, tokenEndPos: number): number; - emitTokenEnd(token: SyntaxKind, tokenEndPos: number, contextNode: Node, ignoreTokenCallback: (node: Node, token: SyntaxKind) => boolean, getTokenTextRangeCallback: (node: Node, token: SyntaxKind) => TextRange): number; - changeEmitSourcePos(): void; - stopOverridingSpan(): void; + emitNodeWithSourceMap(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void; + emitTokenWithSourceMap(node: Node, token: SyntaxKind, tokenStartPos: number, emitCallback: (token: SyntaxKind, tokenStartPos: number) => number): number; getText(): string; getSourceMappingURL(): string; + getSourceMapData(): SourceMapData; } function createSourceMapWriter(host: EmitHost, writer: EmitTextWriter): SourceMapWriter; - function getNullSourceMapWriter(): SourceMapWriter; } declare namespace ts { interface CommentWriter { reset(): void; setSourceFile(sourceFile: SourceFile): void; - emitNodeWithComments(node: Node, emitCallback: (node: Node) => void): void; + emitNodeWithComments(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void; emitBodyWithDetachedComments(node: Node, detachedRange: TextRange, emitCallback: (node: Node) => void): void; emitTrailingCommentsOfPosition(pos: number): void; } function createCommentWriter(host: EmitHost, writer: EmitTextWriter, sourceMap: SourceMapWriter): CommentWriter; } declare namespace ts { - function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFile: SourceFile): EmitResult; + function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFile: SourceFile, emitOnlyDtsFiles?: boolean): EmitResult; } declare namespace ts { const version = "2.1.0"; function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName?: string): string; function resolveTripleslashReference(moduleName: string, containingFile: string): string; function computeCommonSourceDirectoryOfFilenames(fileNames: string[], currentDirectory: string, getCanonicalFileName: (fileName: string) => string): string; - function hasZeroOrOneAsteriskCharacter(str: string): boolean; - function getEffectiveTypeRoots(options: CompilerOptions, host: { - directoryExists?: (directoryName: string) => boolean; - getCurrentDirectory?: () => string; - }): string[] | undefined; - function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string, options: CompilerOptions, host: ModuleResolutionHost): ResolvedTypeReferenceDirectiveWithFailedLookupLocations; - function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; - function findBestPatternMatch(values: T[], getPattern: (value: T) => Pattern, candidate: string): T | undefined; - function tryParsePattern(pattern: string): Pattern | undefined; - function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; - function directoryProbablyExists(directoryName: string, host: { - directoryExists?: (directoryName: string) => boolean; - }): boolean; - function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; interface FormatDiagnosticsHost { @@ -8041,7 +9140,6 @@ declare namespace ts { } function formatDiagnostics(diagnostics: Diagnostic[], host: FormatDiagnosticsHost): string; function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string; - function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[]; function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program; } declare namespace ts { @@ -8135,6 +9233,7 @@ declare namespace ts { readDirectory?(path: string, extensions?: string[], exclude?: string[], include?: string[]): string[]; readFile?(path: string, encoding?: string): string; fileExists?(path: string): boolean; + getTypeRootsVersion?(): number; resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[]; resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; directoryExists?(directoryName: string): boolean; @@ -8165,18 +9264,20 @@ declare namespace ts { findReferences(fileName: string, position: number): ReferencedSymbol[]; getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[]; getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[]; - getNavigateToItems(searchValue: string, maxResultCount?: number, fileName?: string): NavigateToItem[]; + getNavigateToItems(searchValue: string, maxResultCount?: number, fileName?: string, excludeDtsFiles?: boolean): NavigateToItem[]; getNavigationBarItems(fileName: string): NavigationBarItem[]; + getNavigationTree(fileName: string): NavigationTree; getOutliningSpans(fileName: string): OutliningSpan[]; getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[]; getBraceMatchingAtPosition(fileName: string, position: number): TextSpan[]; - getIndentationAtPosition(fileName: string, position: number, options: EditorOptions): number; - getFormattingEditsForRange(fileName: string, start: number, end: number, options: FormatCodeOptions): TextChange[]; - getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions): TextChange[]; - getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): TextChange[]; + getIndentationAtPosition(fileName: string, position: number, options: EditorOptions | EditorSettings): number; + getFormattingEditsForRange(fileName: string, start: number, end: number, options: FormatCodeOptions | FormatCodeSettings): TextChange[]; + getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions | FormatCodeSettings): TextChange[]; + getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions | FormatCodeSettings): TextChange[]; getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion; isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean; - getEmitOutput(fileName: string): EmitOutput; + getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[]): CodeAction[]; + getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean): EmitOutput; getProgram(): Program; getNonBoundSourceFile(fileName: string): SourceFile; getSourceFile(fileName: string): SourceFile; @@ -8200,6 +9301,13 @@ declare namespace ts { bolded: boolean; grayed: boolean; } + interface NavigationTree { + text: string; + kind: string; + kindModifiers: string; + spans: TextSpan[]; + childItems?: NavigationTree[]; + } interface TodoCommentDescriptor { text: string; priority: number; @@ -8213,6 +9321,14 @@ declare namespace ts { span: TextSpan; newText: string; } + interface FileTextChanges { + fileName: string; + textChanges: TextChange[]; + } + interface CodeAction { + description: string; + changes: FileTextChanges[]; + } interface TextInsertion { newText: string; caretOffset: number; @@ -8257,6 +9373,11 @@ declare namespace ts { containerName: string; containerKind: string; } + enum IndentStyle { + None = 0, + Block = 1, + Smart = 2, + } interface EditorOptions { BaseIndentSize?: number; IndentSize: number; @@ -8265,10 +9386,13 @@ declare namespace ts { ConvertTabsToSpaces: boolean; IndentStyle: IndentStyle; } - enum IndentStyle { - None = 0, - Block = 1, - Smart = 2, + interface EditorSettings { + baseIndentSize?: number; + indentSize?: number; + tabSize?: number; + newLineCharacter?: string; + convertTabsToSpaces?: boolean; + indentStyle?: IndentStyle; } interface FormatCodeOptions extends EditorOptions { InsertSpaceAfterCommaDelimiter: boolean; @@ -8284,7 +9408,21 @@ declare namespace ts { InsertSpaceAfterTypeAssertion?: boolean; PlaceOpenBraceOnNewLineForFunctions: boolean; PlaceOpenBraceOnNewLineForControlBlocks: boolean; - [s: string]: boolean | number | string | undefined; + } + interface FormatCodeSettings extends EditorSettings { + insertSpaceAfterCommaDelimiter?: boolean; + insertSpaceAfterSemicolonInForStatements?: boolean; + insertSpaceBeforeAndAfterBinaryOperators?: boolean; + insertSpaceAfterKeywordsInControlFlowStatements?: boolean; + insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; + insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; + insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean; + insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces?: boolean; + insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; + insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; + insertSpaceAfterTypeAssertion?: boolean; + placeOpenBraceOnNewLineForFunctions?: boolean; + placeOpenBraceOnNewLineForControlBlocks?: boolean; } interface DefinitionInfo { fileName: string; @@ -8367,6 +9505,7 @@ declare namespace ts { argumentCount: number; } interface CompletionInfo { + isGlobalCompletion: boolean; isMemberCompletion: boolean; isNewIdentifierLocation: boolean; entries: CompletionEntry[]; @@ -8628,7 +9767,7 @@ declare namespace ts { function stripQuotes(name: string): string; function scriptKindIs(fileName: string, host: LanguageServiceHost, ...scriptKinds: ScriptKind[]): boolean; function getScriptKind(fileName: string, host?: LanguageServiceHost): ScriptKind; - function parseAndReEmitConfigJSONFile(content: string): { + function sanitizeConfigFile(configFileName: string, content: string): { configJsonObject: any; diagnostics: Diagnostic[]; }; @@ -8686,24 +9825,12 @@ declare namespace ts.JsDoc { function getAllJsDocCompletionEntries(): CompletionEntry[]; function getDocCommentTemplateAtPosition(newLine: string, sourceFile: SourceFile, position: number): TextInsertion; } -declare namespace ts.JsTyping { - interface TypingResolutionHost { - directoryExists: (path: string) => boolean; - fileExists: (fileName: string) => boolean; - readFile: (path: string, encoding?: string) => string; - readDirectory: (rootDir: string, extensions: string[], excludes: string[], includes: string[], depth?: number) => string[]; - } - function discoverTypings(host: TypingResolutionHost, fileNames: string[], projectRootPath: Path, safeListPath: Path, packageNameToTypingLocation: Map, typingOptions: TypingOptions, compilerOptions: CompilerOptions): { - cachedTypingPaths: string[]; - newTypingNames: string[]; - filesToWatch: string[]; - }; -} declare namespace ts.NavigateTo { - function getNavigateToItems(sourceFiles: SourceFile[], checker: TypeChecker, cancellationToken: CancellationToken, searchValue: string, maxResultCount: number): NavigateToItem[]; + function getNavigateToItems(sourceFiles: SourceFile[], checker: TypeChecker, cancellationToken: CancellationToken, searchValue: string, maxResultCount: number, excludeDtsFiles: boolean): NavigateToItem[]; } declare namespace ts.NavigationBar { function getNavigationBarItems(sourceFile: SourceFile): NavigationBarItem[]; + function getNavigationTree(sourceFile: SourceFile): NavigationTree; } declare namespace ts.OutliningElementsCollector { function collectElements(sourceFile: SourceFile): OutliningSpan[]; @@ -9148,7 +10275,7 @@ declare namespace ts.formatting { getRuleName(rule: Rule): string; getRuleByName(name: string): Rule; getRulesMap(): RulesMap; - ensureUpToDate(options: ts.FormatCodeOptions): void; + ensureUpToDate(options: ts.FormatCodeSettings): void; private createActiveRules(options); } } @@ -9161,35 +10288,58 @@ declare namespace ts.formatting { token: TextRangeWithKind; trailingTrivia: TextRangeWithKind[]; } - function formatOnEnter(position: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeOptions): TextChange[]; - function formatOnSemicolon(position: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeOptions): TextChange[]; - function formatOnClosingCurly(position: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeOptions): TextChange[]; - function formatDocument(sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeOptions): TextChange[]; - function formatSelection(start: number, end: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeOptions): TextChange[]; - function getIndentationString(indentation: number, options: FormatCodeOptions): string; + function formatOnEnter(position: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeSettings): TextChange[]; + function formatOnSemicolon(position: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeSettings): TextChange[]; + function formatOnClosingCurly(position: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeSettings): TextChange[]; + function formatDocument(sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeSettings): TextChange[]; + function formatSelection(start: number, end: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeSettings): TextChange[]; + function getIndentationString(indentation: number, options: EditorSettings): string; } declare namespace ts.formatting { namespace SmartIndenter { - function getIndentation(position: number, sourceFile: SourceFile, options: EditorOptions): number; - function getBaseIndentation(options: EditorOptions): number; - function getIndentationForNode(n: Node, ignoreActualIndentationRange: TextRange, sourceFile: SourceFile, options: FormatCodeOptions): number; + function getIndentation(position: number, sourceFile: SourceFile, options: EditorSettings): number; + function getIndentationForNode(n: Node, ignoreActualIndentationRange: TextRange, sourceFile: SourceFile, options: EditorSettings): number; + function getBaseIndentation(options: EditorSettings): number; function childStartsOnTheSameLineWithElseInIfStatement(parent: Node, child: TextRangeWithKind, childStartLine: number, sourceFile: SourceFile): boolean; - function findFirstNonWhitespaceCharacterAndColumn(startPos: number, endPos: number, sourceFile: SourceFile, options: EditorOptions): { + function findFirstNonWhitespaceCharacterAndColumn(startPos: number, endPos: number, sourceFile: SourceFile, options: EditorSettings): { column: number; character: number; }; - function findFirstNonWhitespaceColumn(startPos: number, endPos: number, sourceFile: SourceFile, options: EditorOptions): number; + function findFirstNonWhitespaceColumn(startPos: number, endPos: number, sourceFile: SourceFile, options: EditorSettings): number; function nodeWillIndentChild(parent: TextRangeWithKind, child: TextRangeWithKind, indentByDefault: boolean): boolean; function shouldIndentChildNode(parent: TextRangeWithKind, child?: TextRangeWithKind): boolean; } } +declare namespace ts { + interface CodeFix { + errorCodes: number[]; + getCodeActions(context: CodeFixContext): CodeAction[] | undefined; + } + interface CodeFixContext { + errorCode: number; + sourceFile: SourceFile; + span: TextSpan; + program: Program; + newLineCharacter: string; + } + namespace codefix { + function registerCodeFix(action: CodeFix): void; + function getSupportedErrorCodes(): string[]; + function getFixes(context: CodeFixContext): CodeAction[]; + } +} +declare namespace ts.codefix { +} declare namespace ts { const servicesVersion = "0.5"; interface DisplayPartsSymbolWriter extends SymbolWriter { displayParts(): SymbolDisplayPart[]; } + function toEditorSettings(options: FormatCodeOptions | FormatCodeSettings): FormatCodeSettings; + function toEditorSettings(options: EditorOptions | EditorSettings): EditorSettings; function displayPartsToString(displayParts: SymbolDisplayPart[]): string; function getDefaultCompilerOptions(): CompilerOptions; + function getSupportedCodeFixes(): string[]; function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean, scriptKind?: ScriptKind): SourceFile; let disableIncrementalParsing: boolean; function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; @@ -9198,101 +10348,516 @@ declare namespace ts { function getDefaultLibFilePath(options: CompilerOptions): string; } declare namespace ts.server { - function generateSpaces(n: number): string; - function generateIndentString(n: number, editorOptions: EditorOptions): string; + class ScriptInfo { + private readonly host; + readonly fileName: NormalizedPath; + readonly scriptKind: ScriptKind; + isOpen: boolean; + hasMixedContent: boolean; + readonly containingProjects: Project[]; + private formatCodeSettings; + readonly path: Path; + private fileWatcher; + private svc; + constructor(host: ServerHost, fileName: NormalizedPath, content: string, scriptKind: ScriptKind, isOpen?: boolean, hasMixedContent?: boolean); + getFormatCodeSettings(): FormatCodeSettings; + attachToProject(project: Project): boolean; + isAttached(project: Project): boolean; + detachFromProject(project: Project): void; + detachAllProjects(): void; + getDefaultProject(): Project; + setFormatOptions(formatSettings: FormatCodeSettings): void; + setWatcher(watcher: FileWatcher): void; + stopWatcher(): void; + getLatestVersion(): string; + reload(script: string): void; + saveTo(fileName: string): void; + reloadFromFile(): void; + snap(): LineIndexSnapshot; + getLineInfo(line: number): ILineInfo; + editContent(start: number, end: number, newText: string): void; + markContainingProjectsAsDirty(): void; + lineToTextSpan(line: number): TextSpan; + lineOffsetToPosition(line: number, offset: number): number; + positionToLineOffset(position: number): ILineInfo; + } +} +declare namespace ts.server { + class LSHost implements ts.LanguageServiceHost, ModuleResolutionHost, ServerLanguageServiceHost { + private readonly host; + private readonly project; + private readonly cancellationToken; + private compilationSettings; + private readonly resolvedModuleNames; + private readonly resolvedTypeReferenceDirectives; + private readonly getCanonicalFileName; + private readonly resolveModuleName; + readonly trace: (s: string) => void; + constructor(host: ServerHost, project: Project, cancellationToken: HostCancellationToken); + private resolveNamesWithLocalCache(names, containingFile, cache, loader, getResult); + getProjectVersion(): string; + getCompilationSettings(): CompilerOptions; + useCaseSensitiveFileNames(): boolean; + getCancellationToken(): HostCancellationToken; + resolveTypeReferenceDirectives(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; + resolveModuleNames(moduleNames: string[], containingFile: string): ResolvedModule[]; + getDefaultLibFileName(): string; + getScriptSnapshot(filename: string): ts.IScriptSnapshot; + getScriptFileNames(): string[]; + getTypeRootsVersion(): number; + getScriptKind(fileName: string): ScriptKind; + getScriptVersion(filename: string): string; + getCurrentDirectory(): string; + resolvePath(path: string): string; + fileExists(path: string): boolean; + readFile(fileName: string): string; + directoryExists(path: string): boolean; + readDirectory(path: string, extensions?: string[], exclude?: string[], include?: string[]): string[]; + getDirectories(path: string): string[]; + notifyFileRemoved(info: ScriptInfo): void; + setCompilationSettings(opt: ts.CompilerOptions): void; + } +} +declare namespace ts.server { + interface ITypingsInstaller { + enqueueInstallTypingsRequest(p: Project, typingOptions: TypingOptions): void; + attach(projectService: ProjectService): void; + onProjectClosed(p: Project): void; + readonly globalTypingsCacheLocation: string; + } + const nullTypingsInstaller: ITypingsInstaller; + interface TypingsArray extends ReadonlyArray { + " __typingsArrayBrand": any; + } + class TypingsCache { + private readonly installer; + private readonly perProjectCache; + constructor(installer: ITypingsInstaller); + getTypingsForProject(project: Project, forceRefresh: boolean): TypingsArray; + invalidateCachedTypingsForProject(project: Project): void; + updateTypingsForProject(projectName: string, compilerOptions: CompilerOptions, typingOptions: TypingOptions, newTypings: string[]): void; + onProjectClosed(project: Project): void; + } +} +declare namespace ts.server { + function shouldEmitFile(scriptInfo: ScriptInfo): boolean; + class BuilderFileInfo { + readonly scriptInfo: ScriptInfo; + readonly project: Project; + private lastCheckedShapeSignature; + constructor(scriptInfo: ScriptInfo, project: Project); + isExternalModuleOrHasOnlyAmbientExternalModules(): boolean; + private containsOnlyAmbientModules(sourceFile); + private computeHash(text); + private getSourceFile(); + updateShapeSignature(): boolean; + } + interface Builder { + readonly project: Project; + getFilesAffectedBy(scriptInfo: ScriptInfo): string[]; + onProjectUpdateGraph(): void; + emitFile(scriptInfo: ScriptInfo, writeFile: (path: string, data: string, writeByteOrderMark?: boolean) => void): boolean; + } + function createBuilder(project: Project): Builder; +} +declare namespace ts.server { + enum ProjectKind { + Inferred = 0, + Configured = 1, + External = 2, + } + function allRootFilesAreJsOrDts(project: Project): boolean; + function allFilesAreJsOrDts(project: Project): boolean; + interface ProjectFilesWithTSDiagnostics extends protocol.ProjectFiles { + projectErrors: Diagnostic[]; + } + abstract class Project { + readonly projectKind: ProjectKind; + readonly projectService: ProjectService; + private documentRegistry; + languageServiceEnabled: boolean; + private compilerOptions; + compileOnSaveEnabled: boolean; + private rootFiles; + private rootFilesMap; + private lsHost; + private program; + private languageService; + builder: Builder; + private lastReportedFileNames; + private lastReportedVersion; + private projectStructureVersion; + private projectStateVersion; + private typingFiles; + protected projectErrors: Diagnostic[]; + typesVersion: number; + isNonTsProject(): boolean; + isJsOnlyProject(): boolean; + constructor(projectKind: ProjectKind, projectService: ProjectService, documentRegistry: ts.DocumentRegistry, hasExplicitListOfFiles: boolean, languageServiceEnabled: boolean, compilerOptions: CompilerOptions, compileOnSaveEnabled: boolean); + getProjectErrors(): Diagnostic[]; + getLanguageService(ensureSynchronized?: boolean): LanguageService; + getCompileOnSaveAffectedFileList(scriptInfo: ScriptInfo): string[]; + getProjectVersion(): string; + enableLanguageService(): void; + disableLanguageService(): void; + abstract getProjectName(): string; + abstract getProjectRootPath(): string | undefined; + abstract getTypingOptions(): TypingOptions; + getSourceFile(path: Path): SourceFile; + updateTypes(): void; + close(): void; + getCompilerOptions(): CompilerOptions; + hasRoots(): boolean; + getRootFiles(): NormalizedPath[]; + getRootFilesLSHost(): string[]; + getRootScriptInfos(): ScriptInfo[]; + getScriptInfos(): ScriptInfo[]; + getFileEmitOutput(info: ScriptInfo, emitOnlyDtsFiles: boolean): EmitOutput; + getFileNames(): NormalizedPath[]; + getAllEmittableFiles(): string[]; + containsScriptInfo(info: ScriptInfo): boolean; + containsFile(filename: NormalizedPath, requireOpen?: boolean): boolean; + isRoot(info: ScriptInfo): boolean; + addRoot(info: ScriptInfo): void; + removeFile(info: ScriptInfo, detachFromProject?: boolean): void; + markAsDirty(): void; + updateGraph(): boolean; + private setTypings(typings); + private updateGraphWorker(); + getScriptInfoLSHost(fileName: string): ScriptInfo; + getScriptInfoForNormalizedPath(fileName: NormalizedPath): ScriptInfo; + getScriptInfo(uncheckedFileName: string): ScriptInfo; + filesToString(): string; + setCompilerOptions(compilerOptions: CompilerOptions): void; + reloadScript(filename: NormalizedPath): boolean; + getChangesSinceVersion(lastKnownVersion?: number): ProjectFilesWithTSDiagnostics; + getReferencedFiles(path: Path): Path[]; + private removeRootFileIfNecessary(info); + } + class InferredProject extends Project { + compileOnSaveEnabled: boolean; + private static NextId; + private readonly inferredProjectName; + directoriesWatchedForTsconfig: string[]; + constructor(projectService: ProjectService, documentRegistry: ts.DocumentRegistry, languageServiceEnabled: boolean, compilerOptions: CompilerOptions, compileOnSaveEnabled: boolean); + getProjectName(): string; + getProjectRootPath(): string; + close(): void; + getTypingOptions(): TypingOptions; + } + class ConfiguredProject extends Project { + readonly configFileName: NormalizedPath; + private wildcardDirectories; + compileOnSaveEnabled: boolean; + private typingOptions; + private projectFileWatcher; + private directoryWatcher; + private directoriesWatchedForWildcards; + private typeRootsWatchers; + openRefCount: number; + constructor(configFileName: NormalizedPath, projectService: ProjectService, documentRegistry: ts.DocumentRegistry, hasExplicitListOfFiles: boolean, compilerOptions: CompilerOptions, wildcardDirectories: Map, languageServiceEnabled: boolean, compileOnSaveEnabled: boolean); + getProjectRootPath(): string; + setProjectErrors(projectErrors: Diagnostic[]): void; + setTypingOptions(newTypingOptions: TypingOptions): void; + getTypingOptions(): TypingOptions; + getProjectName(): NormalizedPath; + watchConfigFile(callback: (project: ConfiguredProject) => void): void; + watchTypeRoots(callback: (project: ConfiguredProject, path: string) => void): void; + watchConfigDirectory(callback: (project: ConfiguredProject, path: string) => void): void; + watchWildcards(callback: (project: ConfiguredProject, path: string) => void): void; + stopWatchingDirectory(): void; + close(): void; + addOpenRef(): void; + deleteOpenRef(): number; + getEffectiveTypeRoots(): string[]; + } + class ExternalProject extends Project { + readonly externalProjectName: string; + compileOnSaveEnabled: boolean; + private readonly projectFilePath; + private typingOptions; + constructor(externalProjectName: string, projectService: ProjectService, documentRegistry: ts.DocumentRegistry, compilerOptions: CompilerOptions, languageServiceEnabled: boolean, compileOnSaveEnabled: boolean, projectFilePath?: string); + getProjectRootPath(): string; + getTypingOptions(): TypingOptions; + setProjectErrors(projectErrors: Diagnostic[]): void; + setTypingOptions(newTypingOptions: TypingOptions): void; + getProjectName(): string; + } +} +declare namespace ts.server { + const maxProgramSizeForNonTsFiles: number; + type ProjectServiceEvent = { + eventName: "context"; + data: { + project: Project; + fileName: NormalizedPath; + }; + } | { + eventName: "configFileDiag"; + data: { + triggerFile?: string; + configFileName: string; + diagnostics: Diagnostic[]; + }; + }; + interface ProjectServiceEventHandler { + (event: ProjectServiceEvent): void; + } + function combineProjectOutput(projects: Project[], action: (project: Project) => T[], comparer?: (a: T, b: T) => number, areEqual?: (a: T, b: T) => boolean): T[]; + interface HostConfiguration { + formatCodeOptions: FormatCodeSettings; + hostInfo: string; + } + interface OpenConfiguredProjectResult { + configFileName?: string; + configFileErrors?: Diagnostic[]; + } + class ProjectService { + readonly host: ServerHost; + readonly logger: Logger; + readonly cancellationToken: HostCancellationToken; + readonly useSingleInferredProject: boolean; + readonly typingsInstaller: ITypingsInstaller; + private readonly eventHandler; + readonly typingsCache: TypingsCache; + private readonly documentRegistry; + private readonly filenameToScriptInfo; + private readonly externalProjectToConfiguredProjectMap; + readonly externalProjects: ExternalProject[]; + readonly inferredProjects: InferredProject[]; + readonly configuredProjects: ConfiguredProject[]; + readonly openFiles: ScriptInfo[]; + private compilerOptionsForInferredProjects; + private compileOnSaveForInferredProjects; + private readonly directoryWatchers; + private readonly throttledOperations; + private readonly hostConfiguration; + private changedFiles; + private toCanonicalFileName; + lastDeletedFile: ScriptInfo; + constructor(host: ServerHost, logger: Logger, cancellationToken: HostCancellationToken, useSingleInferredProject: boolean, typingsInstaller?: ITypingsInstaller, eventHandler?: ProjectServiceEventHandler); + getChangedFiles_TestOnly(): ScriptInfo[]; + ensureInferredProjectsUpToDate_TestOnly(): void; + updateTypingsForProject(response: SetTypings | InvalidateCachedTypings): void; + setCompilerOptionsForInferredProjects(projectCompilerOptions: protocol.ExternalProjectCompilerOptions): void; + stopWatchingDirectory(directory: string): void; + findProject(projectName: string): Project; + getDefaultProjectForFile(fileName: NormalizedPath, refreshInferredProjects: boolean): Project; + private ensureInferredProjectsUpToDate(); + private findContainingExternalProject(fileName); + getFormatCodeOptions(file?: NormalizedPath): FormatCodeSettings; + private updateProjectGraphs(projects); + private onSourceFileChanged(fileName); + private handleDeletedFile(info); + private onTypeRootFileChanged(project, fileName); + private onSourceFileInDirectoryChangedForConfiguredProject(project, fileName); + private handleChangeInSourceFileForConfiguredProject(project); + private onConfigChangedForConfiguredProject(project); + private onConfigFileAddedForInferredProject(fileName); + private getCanonicalFileName(fileName); + private removeProject(project); + private assignScriptInfoToInferredProjectIfNecessary(info, addToListOfOpenFiles); + private closeOpenFile(info); + private openOrUpdateConfiguredProjectForFile(fileName); + private findConfigFile(searchPath); + private printProjects(); + private findConfiguredProjectByProjectName(configFileName); + private findExternalProjectByProjectName(projectFileName); + private convertConfigFileContentToProjectOptions(configFilename); + private exceededTotalSizeLimitForNonTsFiles(options, fileNames, propertyReader); + private createAndAddExternalProject(projectFileName, files, options, typingOptions); + private reportConfigFileDiagnostics(configFileName, diagnostics, triggerFile?); + private createAndAddConfiguredProject(configFileName, projectOptions, configFileErrors, clientFileName?); + private watchConfigDirectoryForProject(project, options); + private addFilesToProjectAndUpdateGraph(project, files, propertyReader, clientFileName, typingOptions, configFileErrors); + private openConfigFile(configFileName, clientFileName?); + private updateNonInferredProject(project, newUncheckedFiles, propertyReader, newOptions, newTypingOptions, compileOnSave, configFileErrors); + private updateConfiguredProject(project); + createInferredProjectWithRootFileIfNecessary(root: ScriptInfo): InferredProject; + getOrCreateScriptInfo(uncheckedFileName: string, openedByClient: boolean, fileContent?: string, scriptKind?: ScriptKind): ScriptInfo; + getScriptInfo(uncheckedFileName: string): ScriptInfo; + getOrCreateScriptInfoForNormalizedPath(fileName: NormalizedPath, openedByClient: boolean, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean): ScriptInfo; + getScriptInfoForNormalizedPath(fileName: NormalizedPath): ScriptInfo; + getScriptInfoForPath(fileName: Path): ScriptInfo; + setHostConfiguration(args: protocol.ConfigureRequestArguments): void; + closeLog(): void; + reloadProjects(): void; + refreshInferredProjects(): void; + openClientFile(fileName: string, fileContent?: string, scriptKind?: ScriptKind): OpenConfiguredProjectResult; + openClientFileWithNormalizedPath(fileName: NormalizedPath, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean): OpenConfiguredProjectResult; + closeClientFile(uncheckedFileName: string): void; + private collectChanges(lastKnownProjectVersions, currentProjects, result); + synchronizeProjectList(knownProjects: protocol.ProjectVersionInfo[]): ProjectFilesWithTSDiagnostics[]; + applyChangesInOpenFiles(openFiles: protocol.ExternalFile[], changedFiles: protocol.ChangedOpenFile[], closedFiles: string[]): void; + private closeConfiguredProject(configFile); + closeExternalProject(uncheckedFileName: string, suppressRefresh?: boolean): void; + openExternalProject(proj: protocol.ExternalProject): void; + } +} +declare namespace ts.server { interface PendingErrorCheck { - fileName: string; + fileName: NormalizedPath; project: Project; } namespace CommandNames { - const Brace = "brace"; - const Change = "change"; - const Close = "close"; - const Completions = "completions"; - const CompletionDetails = "completionEntryDetails"; - const Configure = "configure"; - const Definition = "definition"; - const Exit = "exit"; - const Format = "format"; - const Formatonkey = "formatonkey"; - const Geterr = "geterr"; - const GeterrForProject = "geterrForProject"; - const Implementation = "implementation"; - const SemanticDiagnosticsSync = "semanticDiagnosticsSync"; - const SyntacticDiagnosticsSync = "syntacticDiagnosticsSync"; - const NavBar = "navbar"; - const Navto = "navto"; - const Occurrences = "occurrences"; - const DocumentHighlights = "documentHighlights"; - const Open = "open"; - const Quickinfo = "quickinfo"; - const References = "references"; - const Reload = "reload"; - const Rename = "rename"; - const Saveto = "saveto"; - const SignatureHelp = "signatureHelp"; - const TypeDefinition = "typeDefinition"; - const ProjectInfo = "projectInfo"; - const ReloadProjects = "reloadProjects"; - const Unknown = "unknown"; - } - interface ServerHost extends ts.System { - setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): any; - clearTimeout(timeoutId: any): void; + const Brace: protocol.CommandTypes.Brace; + const BraceFull: protocol.CommandTypes.BraceFull; + const BraceCompletion: protocol.CommandTypes.BraceCompletion; + const Change: protocol.CommandTypes.Change; + const Close: protocol.CommandTypes.Close; + const Completions: protocol.CommandTypes.Completions; + const CompletionsFull: protocol.CommandTypes.CompletionsFull; + const CompletionDetails: protocol.CommandTypes.CompletionDetails; + const CompileOnSaveAffectedFileList: protocol.CommandTypes.CompileOnSaveAffectedFileList; + const CompileOnSaveEmitFile: protocol.CommandTypes.CompileOnSaveEmitFile; + const Configure: protocol.CommandTypes.Configure; + const Definition: protocol.CommandTypes.Definition; + const DefinitionFull: protocol.CommandTypes.DefinitionFull; + const Exit: protocol.CommandTypes.Exit; + const Format: protocol.CommandTypes.Format; + const Formatonkey: protocol.CommandTypes.Formatonkey; + const FormatFull: protocol.CommandTypes.FormatFull; + const FormatonkeyFull: protocol.CommandTypes.FormatonkeyFull; + const FormatRangeFull: protocol.CommandTypes.FormatRangeFull; + const Geterr: protocol.CommandTypes.Geterr; + const GeterrForProject: protocol.CommandTypes.GeterrForProject; + const Implementation: protocol.CommandTypes.Implementation; + const ImplementationFull: protocol.CommandTypes.ImplementationFull; + const SemanticDiagnosticsSync: protocol.CommandTypes.SemanticDiagnosticsSync; + const SyntacticDiagnosticsSync: protocol.CommandTypes.SyntacticDiagnosticsSync; + const NavBar: protocol.CommandTypes.NavBar; + const NavBarFull: protocol.CommandTypes.NavBarFull; + const NavTree: protocol.CommandTypes.NavTree; + const NavTreeFull: protocol.CommandTypes.NavTreeFull; + const Navto: protocol.CommandTypes.Navto; + const NavtoFull: protocol.CommandTypes.NavtoFull; + const Occurrences: protocol.CommandTypes.Occurrences; + const DocumentHighlights: protocol.CommandTypes.DocumentHighlights; + const DocumentHighlightsFull: protocol.CommandTypes.DocumentHighlightsFull; + const Open: protocol.CommandTypes.Open; + const Quickinfo: protocol.CommandTypes.Quickinfo; + const QuickinfoFull: protocol.CommandTypes.QuickinfoFull; + const References: protocol.CommandTypes.References; + const ReferencesFull: protocol.CommandTypes.ReferencesFull; + const Reload: protocol.CommandTypes.Reload; + const Rename: protocol.CommandTypes.Rename; + const RenameInfoFull: protocol.CommandTypes.RenameInfoFull; + const RenameLocationsFull: protocol.CommandTypes.RenameLocationsFull; + const Saveto: protocol.CommandTypes.Saveto; + const SignatureHelp: protocol.CommandTypes.SignatureHelp; + const SignatureHelpFull: protocol.CommandTypes.SignatureHelpFull; + const TypeDefinition: protocol.CommandTypes.TypeDefinition; + const ProjectInfo: protocol.CommandTypes.ProjectInfo; + const ReloadProjects: protocol.CommandTypes.ReloadProjects; + const Unknown: protocol.CommandTypes.Unknown; + const OpenExternalProject: protocol.CommandTypes.OpenExternalProject; + const OpenExternalProjects: protocol.CommandTypes.OpenExternalProjects; + const CloseExternalProject: protocol.CommandTypes.CloseExternalProject; + const SynchronizeProjectList: protocol.CommandTypes.SynchronizeProjectList; + const ApplyChangedToOpenFiles: protocol.CommandTypes.ApplyChangedToOpenFiles; + const EncodedSemanticClassificationsFull: protocol.CommandTypes.EncodedSemanticClassificationsFull; + const Cleanup: protocol.CommandTypes.Cleanup; + const OutliningSpans: protocol.CommandTypes.OutliningSpans; + const TodoComments: protocol.CommandTypes.TodoComments; + const Indentation: protocol.CommandTypes.Indentation; + const DocCommentTemplate: protocol.CommandTypes.DocCommentTemplate; + const CompilerOptionsDiagnosticsFull: protocol.CommandTypes.CompilerOptionsDiagnosticsFull; + const NameOrDottedNameSpan: protocol.CommandTypes.NameOrDottedNameSpan; + const BreakpointStatement: protocol.CommandTypes.BreakpointStatement; + const CompilerOptionsForInferredProjects: protocol.CommandTypes.CompilerOptionsForInferredProjects; + const GetCodeFixes: protocol.CommandTypes.GetCodeFixes; + const GetCodeFixesFull: protocol.CommandTypes.GetCodeFixesFull; + const GetSupportedCodeFixes: protocol.CommandTypes.GetSupportedCodeFixes; } + function formatMessage(msg: T, logger: server.Logger, byteLength: (s: string, encoding: string) => number, newLine: string): string; class Session { private host; + protected readonly typingsInstaller: ITypingsInstaller; private byteLength; private hrtime; - private logger; + protected logger: Logger; + protected readonly canUseEvents: boolean; + private readonly gcTimer; protected projectService: ProjectService; private errorTimer; private immediateId; private changeSeq; - constructor(host: ServerHost, byteLength: (buf: string, encoding?: string) => number, hrtime: (start?: number[]) => number[], logger: Logger); - private handleEvent(event); + private eventHander; + constructor(host: ServerHost, cancellationToken: HostCancellationToken, useSingleInferredProject: boolean, typingsInstaller: ITypingsInstaller, byteLength: (buf: string, encoding?: string) => number, hrtime: (start?: number[]) => number[], logger: Logger, canUseEvents: boolean, eventHandler?: ProjectServiceEventHandler); + private defaultEventHandler(event); logError(err: Error, cmd: string): void; - private sendLineToClient(line); send(msg: protocol.Message): void; configFileDiagnosticEvent(triggerFile: string, configFile: string, diagnostics: ts.Diagnostic[]): void; event(info: any, eventName: string): void; - private response(info, cmdName, reqSeq?, errorMsg?); - output(body: any, commandName: string, requestSequence?: number, errorMessage?: string): void; + output(info: any, cmdName: string, reqSeq?: number, errorMsg?: string): void; private semanticCheck(file, project); private syntacticCheck(file, project); - private reloadProjects(); private updateProjectStructure(seq, matchSeq, ms?); private updateErrorCheck(checkList, seq, matchSeq, ms?, followMs?, requireOpen?); - private getDefinition(line, offset, fileName); - private getTypeDefinition(line, offset, fileName); - private getImplementation(line, offset, fileName); - private getOccurrences(line, offset, fileName); - private getDiagnosticsWorker(args, selector); + private cleanProjects(caption, projects); + private cleanup(); + private getEncodedSemanticClassifications(args); + private getProject(projectFileName); + private getCompilerOptionsDiagnostics(args); + private convertToDiagnosticsWithLinePosition(diagnostics, scriptInfo); + private getDiagnosticsWorker(args, selector, includeLinePosition); + private getDefinition(args, simplifiedResult); + private getTypeDefinition(args); + private getImplementation(args, simplifiedResult); + private getOccurrences(args); private getSyntacticDiagnosticsSync(args); private getSemanticDiagnosticsSync(args); - private getDocumentHighlights(line, offset, fileName, filesToSearch); - private getProjectInfo(fileName, needFileNameList); - private getRenameLocations(line, offset, fileName, findInComments, findInStrings); - private getReferences(line, offset, fileName); + private getDocumentHighlights(args, simplifiedResult); + private setCompilerOptionsForInferredProjects(args); + private getProjectInfo(args); + private getProjectInfoWorker(uncheckedFileName, projectFileName, needFileNameList); + private getRenameInfo(args); + private getProjects(args); + private getRenameLocations(args, simplifiedResult); + private getReferences(args, simplifiedResult); private openClientFile(fileName, fileContent?, scriptKind?); - private getQuickInfo(line, offset, fileName); - private getFormattingEditsForRange(line, offset, endLine, endOffset, fileName); - private getFormattingEditsAfterKeystroke(line, offset, key, fileName); - private getCompletions(line, offset, prefix, fileName); - private getCompletionEntryDetails(line, offset, entryNames, fileName); - private getSignatureHelpItems(line, offset, fileName); + private getPosition(args, scriptInfo); + private getFileAndProject(args, errorOnMissingProject?); + private getFileAndProjectWithoutRefreshingInferredProjects(args, errorOnMissingProject?); + private getFileAndProjectWorker(uncheckedFileName, projectFileName, refreshInferredProjects, errorOnMissingProject); + private getOutliningSpans(args); + private getTodoComments(args); + private getDocCommentTemplate(args); + private getIndentation(args); + private getBreakpointStatement(args); + private getNameOrDottedNameSpan(args); + private isValidBraceCompletion(args); + private getQuickInfoWorker(args, simplifiedResult); + private getFormattingEditsForRange(args); + private getFormattingEditsForRangeFull(args); + private getFormattingEditsForDocumentFull(args); + private getFormattingEditsAfterKeystrokeFull(args); + private getFormattingEditsAfterKeystroke(args); + private getCompletions(args, simplifiedResult); + private getCompletionEntryDetails(args); + private getCompileOnSaveAffectedFileList(args); + private emitFile(args); + private getSignatureHelpItems(args, simplifiedResult); private getDiagnostics(delay, fileNames); - private change(line, offset, endLine, endOffset, insertString, fileName); - private reload(fileName, tempFileName, reqSeq?); + private change(args); + private reload(args, reqSeq); private saveToTmp(fileName, tempFileName); private closeClientFile(fileName); - private decorateNavigationBarItem(project, fileName, items, lineIndex); - private getNavigationBarItems(fileName); - private getNavigateToItems(searchValue, fileName, maxResultCount?, currentFileOnly?); - private getBraceMatching(line, offset, fileName); + private decorateNavigationBarItems(items, scriptInfo); + private getNavigationBarItems(args, simplifiedResult); + private decorateNavigationTree(tree, scriptInfo); + private decorateSpan(span, scriptInfo); + private getNavigationTree(args, simplifiedResult); + private getNavigateToItems(args, simplifiedResult); + private getSupportedCodeFixes(); + private getCodeFixes(args, simplifiedResult); + private mapCodeAction(codeAction, scriptInfo); + private convertTextChangeToCodeEdit(change, scriptInfo); + private getBraceMatching(args, simplifiedResult); getDiagnosticsForProject(delay: number, fileName: string): void; getCanonicalFileName(fileName: string): string; exit(): void; + private notRequired(); private requiredResponse(response); private handlers; addProtocolHandler(command: string, handler: (request: protocol.Request) => { @@ -9307,227 +10872,6 @@ declare namespace ts.server { } } declare namespace ts.server { - interface Logger { - close(): void; - isVerbose(): boolean; - loggingEnabled(): boolean; - perftrc(s: string): void; - info(s: string): void; - startGroup(): void; - endGroup(): void; - msg(s: string, type?: string): void; - } - const maxProgramSizeForNonTsFiles: number; - class ScriptInfo { - private host; - fileName: string; - isOpen: boolean; - svc: ScriptVersionCache; - children: ScriptInfo[]; - defaultProject: Project; - fileWatcher: FileWatcher; - formatCodeOptions: FormatCodeOptions; - path: Path; - scriptKind: ScriptKind; - constructor(host: ServerHost, fileName: string, content: string, isOpen?: boolean); - setFormatOptions(formatOptions: protocol.FormatOptions): void; - close(): void; - addChild(childInfo: ScriptInfo): void; - snap(): LineIndexSnapshot; - getText(): string; - getLineInfo(line: number): ILineInfo; - editContent(start: number, end: number, newText: string): void; - getTextChangeRangeBetweenVersions(startVersion: number, endVersion: number): ts.TextChangeRange; - getChangeRange(oldSnapshot: ts.IScriptSnapshot): ts.TextChangeRange; - } - class LSHost implements ts.LanguageServiceHost { - host: ServerHost; - project: Project; - ls: ts.LanguageService; - compilationSettings: ts.CompilerOptions; - filenameToScript: ts.FileMap; - roots: ScriptInfo[]; - private resolvedModuleNames; - private resolvedTypeReferenceDirectives; - private moduleResolutionHost; - private getCanonicalFileName; - constructor(host: ServerHost, project: Project); - private resolveNamesWithLocalCache(names, containingFile, cache, loader, getResult); - resolveTypeReferenceDirectives(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; - resolveModuleNames(moduleNames: string[], containingFile: string): ResolvedModule[]; - getDefaultLibFileName(): string; - getScriptSnapshot(filename: string): ts.IScriptSnapshot; - setCompilationSettings(opt: ts.CompilerOptions): void; - lineAffectsRefs(filename: string, line: number): boolean; - getCompilationSettings(): CompilerOptions; - getScriptFileNames(): string[]; - getScriptKind(fileName: string): ScriptKind; - getScriptVersion(filename: string): string; - getCurrentDirectory(): string; - getScriptIsOpen(filename: string): boolean; - removeReferencedFile(info: ScriptInfo): void; - getScriptInfo(filename: string): ScriptInfo; - addRoot(info: ScriptInfo): void; - removeRoot(info: ScriptInfo): void; - saveTo(filename: string, tmpfilename: string): void; - reloadScript(filename: string, tmpfilename: string, cb: () => any): void; - editScript(filename: string, start: number, end: number, newText: string): void; - fileExists(path: string): boolean; - directoryExists(path: string): boolean; - getDirectories(path: string): string[]; - readDirectory(path: string, extensions?: string[], exclude?: string[], include?: string[]): string[]; - readFile(path: string, encoding?: string): string; - lineToTextSpan(filename: string, line: number): ts.TextSpan; - lineOffsetToPosition(filename: string, line: number, offset: number): number; - positionToLineOffset(filename: string, position: number, lineIndex?: LineIndex): ILineInfo; - getLineIndex(filename: string): LineIndex; - } - interface ProjectOptions { - files?: string[]; - wildcardDirectories?: ts.MapLike; - compilerOptions?: ts.CompilerOptions; - } - class Project { - projectService: ProjectService; - projectOptions: ProjectOptions; - languageServiceDiabled: boolean; - compilerService: CompilerService; - projectFilename: string; - projectFileWatcher: FileWatcher; - directoryWatcher: FileWatcher; - directoriesWatchedForWildcards: Map; - directoriesWatchedForTsconfig: string[]; - program: ts.Program; - filenameToSourceFile: Map; - updateGraphSeq: number; - openRefCount: number; - constructor(projectService: ProjectService, projectOptions?: ProjectOptions, languageServiceDiabled?: boolean); - enableLanguageService(): void; - disableLanguageService(): void; - addOpenRef(): void; - deleteOpenRef(): number; - openReferencedFile(filename: string): ScriptInfo; - getRootFiles(): string[]; - getFileNames(): string[]; - getSourceFile(info: ScriptInfo): SourceFile; - getSourceFileFromName(filename: string, requireOpen?: boolean): SourceFile; - isRoot(info: ScriptInfo): boolean; - removeReferencedFile(info: ScriptInfo): void; - updateFileMap(): void; - finishGraph(): void; - updateGraph(): void; - isConfiguredProject(): string; - addRoot(info: ScriptInfo): void; - removeRoot(info: ScriptInfo): void; - filesToString(): string; - setProjectOptions(projectOptions: ProjectOptions): void; - } - interface ProjectOpenResult { - success?: boolean; - errorMsg?: string; - project?: Project; - } - function combineProjectOutput(projects: Project[], action: (project: Project) => T[], comparer?: (a: T, b: T) => number, areEqual?: (a: T, b: T) => boolean): T[]; - type ProjectServiceEvent = { - eventName: "context"; - data: { - project: Project; - fileName: string; - }; - } | { - eventName: "configFileDiag"; - data: { - triggerFile?: string; - configFileName: string; - diagnostics: Diagnostic[]; - }; - }; - interface ProjectServiceEventHandler { - (event: ProjectServiceEvent): void; - } - interface HostConfiguration { - formatCodeOptions: ts.FormatCodeOptions; - hostInfo: string; - } - class ProjectService { - host: ServerHost; - psLogger: Logger; - eventHandler: ProjectServiceEventHandler; - filenameToScriptInfo: Map; - openFileRoots: ScriptInfo[]; - inferredProjects: Project[]; - configuredProjects: Project[]; - openFilesReferenced: ScriptInfo[]; - openFileRootsConfigured: ScriptInfo[]; - directoryWatchersForTsconfig: Map; - directoryWatchersRefCount: Map; - hostConfiguration: HostConfiguration; - timerForDetectingProjectFileListChanges: Map; - constructor(host: ServerHost, psLogger: Logger, eventHandler?: ProjectServiceEventHandler); - addDefaultHostConfiguration(): void; - getFormatCodeOptions(file?: string): FormatCodeOptions; - watchedFileChanged(fileName: string): void; - directoryWatchedForSourceFilesChanged(project: Project, fileName: string): void; - startTimerForDetectingProjectFileListChanges(project: Project): void; - handleProjectFileListChanges(project: Project): void; - reportConfigFileDiagnostics(configFileName: string, diagnostics: Diagnostic[], triggerFile?: string): void; - directoryWatchedForTsconfigChanged(fileName: string): void; - getCanonicalFileName(fileName: string): string; - watchedProjectConfigFileChanged(project: Project): void; - log(msg: string, type?: string): void; - setHostConfiguration(args: ts.server.protocol.ConfigureRequestArguments): void; - closeLog(): void; - createInferredProject(root: ScriptInfo): Project; - fileDeletedInFilesystem(info: ScriptInfo): void; - updateConfiguredProjectList(): void; - removeProject(project: Project): void; - setConfiguredProjectRoot(info: ScriptInfo): boolean; - addOpenFile(info: ScriptInfo): void; - closeOpenFile(info: ScriptInfo): void; - findReferencingProjects(info: ScriptInfo, excludedProject?: Project): Project[]; - reloadProjects(): void; - updateProjectStructure(): void; - getScriptInfo(filename: string): ScriptInfo; - openFile(fileName: string, openedByClient: boolean, fileContent?: string, scriptKind?: ScriptKind): ScriptInfo; - findConfigFile(searchPath: string): string; - openClientFile(fileName: string, fileContent?: string, scriptKind?: ScriptKind): { - configFileName?: string; - configFileErrors?: Diagnostic[]; - }; - openOrUpdateConfiguredProjectForFile(fileName: string): { - configFileName?: string; - configFileErrors?: Diagnostic[]; - }; - closeClientFile(filename: string): void; - getProjectForFile(filename: string): Project; - printProjectsForFile(filename: string): void; - printProjects(): void; - configProjectIsActive(fileName: string): boolean; - findConfiguredProjectByConfigFile(configFileName: string): Project; - configFileToProjectOptions(configFilename: string): { - projectOptions?: ProjectOptions; - errors: Diagnostic[]; - }; - private exceedTotalNonTsFileSizeLimit(fileNames); - openConfigFile(configFilename: string, clientFileName?: string): { - project?: Project; - errors: Diagnostic[]; - }; - updateConfiguredProject(project: Project): Diagnostic[]; - createProject(projectFilename: string, projectOptions?: ProjectOptions, languageServiceDisabled?: boolean): Project; - } - class CompilerService { - project: Project; - host: LSHost; - languageService: ts.LanguageService; - classifier: ts.Classifier; - settings: ts.CompilerOptions; - documentRegistry: DocumentRegistry; - constructor(project: Project, opt?: ts.CompilerOptions); - setCompilerOptions(opt: ts.CompilerOptions): void; - isExternalModule(filename: string): boolean; - static getDefaultFormatCodeOptions(host: ServerHost): ts.FormatCodeOptions; - } interface LineCollection { charCount(): number; lineCount(): number; @@ -9566,15 +10910,17 @@ declare namespace ts.server { changes: TextChange[]; versions: LineIndexSnapshot[]; minVersion: number; - private currentVersion; private host; + private currentVersion; static changeNumberThreshold: number; static changeLengthThreshold: number; static maxVersions: number; + private versionToIndex(version); + private currentVersionToIndex(); edit(pos: number, deleteLen: number, insertedText?: string): void; latest(): LineIndexSnapshot; latestVersion(): number; - reloadFromFile(filename: string, cb?: () => any): void; + reloadFromFile(filename: string): void; reload(script: string): void; getSnapshot(): LineIndexSnapshot; getTextChangesBetweenVersions(oldVersion: number, newVersion: number): TextChangeRange; @@ -9643,10 +10989,7 @@ declare namespace ts.server { } class LineLeaf implements LineCollection { text: string; - udata: any; constructor(text: string); - setUdata(data: any): void; - getUdata(): any; isLeaf(): boolean; walk(rangeStart: number, rangeLength: number, walkFns: ILineIndexWalker): void; charCount(): number; @@ -9680,6 +11023,7 @@ declare namespace ts { getNewLine?(): string; getProjectVersion?(): string; useCaseSensitiveFileNames?(): boolean; + getTypeRootsVersion?(): number; readDirectory(rootDir: string, extension: string, basePaths?: string, excludeEx?: string, includeFileEx?: string, includeDirEx?: string, depth?: number): string; readFile(path: string, encoding?: string): string; fileExists(path: string): boolean; @@ -9739,6 +11083,7 @@ declare namespace ts { getDocumentHighlights(fileName: string, position: number, filesToSearch: string): string; getNavigateToItems(searchValue: string, maxResultCount?: number, fileName?: string): string; getNavigationBarItems(fileName: string): string; + getNavigationTree(fileName: string): string; getOutliningSpans(fileName: string): string; getTodoComments(fileName: string, todoCommentDescriptors: string): string; getBraceMatchingAtPosition(fileName: string, position: number): string; @@ -9775,6 +11120,7 @@ declare namespace ts { trace(s: string): void; error(s: string): void; getProjectVersion(): string; + getTypeRootsVersion(): number; useCaseSensitiveFileNames(): boolean; getCompilationSettings(): CompilerOptions; getScriptFileNames(): string[]; diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index a8fa909efcc..a360ac081ec 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -72,7 +72,6 @@ var ts; (function (ts) { ts.timestamp = typeof performance !== "undefined" && performance.now ? function () { return performance.now(); } : Date.now ? Date.now : function () { return +(new Date()); }; })(ts || (ts = {})); -var ts; (function (ts) { var performance; (function (performance) { @@ -150,6 +149,7 @@ var ts; contains: contains, remove: remove, forEachValue: forEachValueInMap, + getKeys: getKeys, clear: clear }; function forEachValueInMap(f) { @@ -157,6 +157,13 @@ var ts; f(key, files[key]); } } + function getKeys() { + var keys = []; + for (var key in files) { + keys.push(key); + } + return keys; + } function get(path) { return files[toKey(path)]; } @@ -533,16 +540,22 @@ var ts; : undefined; } ts.lastOrUndefined = lastOrUndefined; - function binarySearch(array, value) { + function binarySearch(array, value, comparer) { + if (!array || array.length === 0) { + return -1; + } var low = 0; var high = array.length - 1; + comparer = comparer !== undefined + ? comparer + : function (v1, v2) { return (v1 < v2 ? -1 : (v1 > v2 ? 1 : 0)); }; while (low <= high) { var middle = low + ((high - low) >> 1); var midValue = array[middle]; - if (midValue === value) { + if (comparer(midValue, value) === 0) { return middle; } - else if (midValue > value) { + else if (comparer(midValue, value) > 0) { high = middle - 1; } else { @@ -776,6 +789,56 @@ var ts; }; } ts.memoize = memoize; + function chain(a, b, c, d, e) { + if (e) { + var args_2 = []; + for (var i = 0; i < arguments.length; i++) { + args_2[i] = arguments[i]; + } + return function (t) { return compose.apply(void 0, map(args_2, function (f) { return f(t); })); }; + } + else if (d) { + return function (t) { return compose(a(t), b(t), c(t), d(t)); }; + } + else if (c) { + return function (t) { return compose(a(t), b(t), c(t)); }; + } + else if (b) { + return function (t) { return compose(a(t), b(t)); }; + } + else if (a) { + return function (t) { return compose(a(t)); }; + } + else { + return function (t) { return function (u) { return u; }; }; + } + } + ts.chain = chain; + function compose(a, b, c, d, e) { + if (e) { + var args_3 = []; + for (var i = 0; i < arguments.length; i++) { + args_3[i] = arguments[i]; + } + return function (t) { return reduceLeft(args_3, function (u, f) { return f(u); }, t); }; + } + else if (d) { + return function (t) { return d(c(b(a(t)))); }; + } + else if (c) { + return function (t) { return c(b(a(t))); }; + } + else if (b) { + return function (t) { return b(a(t)); }; + } + else if (a) { + return function (t) { return a(t); }; + } + else { + return function (t) { return t; }; + } + } + ts.compose = compose; function formatStringFromArgs(text, args, baseIndex) { baseIndex = baseIndex || 0; return text.replace(/{(\d+)}/g, function (match, index) { return args[+index + baseIndex]; }); @@ -1012,10 +1075,45 @@ var ts; return path && !isRootedDiskPath(path) && path.indexOf("://") !== -1; } ts.isUrl = isUrl; + function isExternalModuleNameRelative(moduleName) { + return /^\.\.?($|[\\/])/.test(moduleName); + } + ts.isExternalModuleNameRelative = isExternalModuleNameRelative; + function getEmitScriptTarget(compilerOptions) { + return compilerOptions.target || 0; + } + ts.getEmitScriptTarget = getEmitScriptTarget; + function getEmitModuleKind(compilerOptions) { + return typeof compilerOptions.module === "number" ? + compilerOptions.module : + getEmitScriptTarget(compilerOptions) === 2 ? ts.ModuleKind.ES6 : ts.ModuleKind.CommonJS; + } + ts.getEmitModuleKind = getEmitModuleKind; + function hasZeroOrOneAsteriskCharacter(str) { + var seenAsterisk = false; + for (var i = 0; i < str.length; i++) { + if (str.charCodeAt(i) === 42) { + if (!seenAsterisk) { + seenAsterisk = true; + } + else { + return false; + } + } + } + return true; + } + ts.hasZeroOrOneAsteriskCharacter = hasZeroOrOneAsteriskCharacter; function isRootedDiskPath(path) { return getRootLength(path) !== 0; } ts.isRootedDiskPath = isRootedDiskPath; + function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) { + return !isRootedDiskPath(absoluteOrRelativePath) + ? absoluteOrRelativePath + : getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, false); + } + ts.convertToRelativePath = convertToRelativePath; function normalizedPathComponents(path, rootLength) { var normalizedParts = getNormalizedParts(path, rootLength); return [path.substr(0, rootLength)].concat(normalizedParts); @@ -1389,6 +1487,14 @@ var ts; return options && options.allowJs ? allSupportedExtensions : ts.supportedTypeScriptExtensions; } ts.getSupportedExtensions = getSupportedExtensions; + function hasJavaScriptFileExtension(fileName) { + return forEach(ts.supportedJavascriptExtensions, function (extension) { return fileExtensionIs(fileName, extension); }); + } + ts.hasJavaScriptFileExtension = hasJavaScriptFileExtension; + function hasTypeScriptFileExtension(fileName) { + return forEach(ts.supportedTypeScriptExtensions, function (extension) { return fileExtensionIs(fileName, extension); }); + } + ts.hasTypeScriptFileExtension = hasTypeScriptFileExtension; function isSupportedSourceFileName(fileName, compilerOptions) { if (!fileName) { return false; @@ -1480,7 +1586,6 @@ var ts; this.transformFlags = 0; this.parent = undefined; this.original = undefined; - this.transformId = 0; } ts.objectAllocator = { getNodeConstructor: function () { return Node; }, @@ -1493,9 +1598,9 @@ var ts; }; var Debug; (function (Debug) { - var currentAssertionLevel; + Debug.currentAssertionLevel = 0; function shouldAssert(level) { - return getCurrentAssertionLevel() >= level; + return Debug.currentAssertionLevel >= level; } Debug.shouldAssert = shouldAssert; function assert(expression, message, verboseDebugInfo) { @@ -1513,30 +1618,7 @@ var ts; Debug.assert(false, message); } Debug.fail = fail; - function getCurrentAssertionLevel() { - if (currentAssertionLevel !== undefined) { - return currentAssertionLevel; - } - if (ts.sys === undefined) { - return 0; - } - var developmentMode = /^development$/i.test(getEnvironmentVariable("NODE_ENV")); - currentAssertionLevel = developmentMode - ? 1 - : 0; - return currentAssertionLevel; - } })(Debug = ts.Debug || (ts.Debug = {})); - function getEnvironmentVariable(name, host) { - if (host && host.getEnvironmentVariable) { - return host.getEnvironmentVariable(name); - } - if (ts.sys && ts.sys.getEnvironmentVariable) { - return ts.sys.getEnvironmentVariable(name); - } - return ""; - } - ts.getEnvironmentVariable = getEnvironmentVariable; function orderedRemoveItemAt(array, index) { for (var i = index; i < array.length - 1; i++) { array[i] = array[i + 1]; @@ -1567,6 +1649,64 @@ var ts; : (function (fileName) { return fileName.toLowerCase(); }); } ts.createGetCanonicalFileName = createGetCanonicalFileName; + function matchPatternOrExact(patternStrings, candidate) { + var patterns = []; + for (var _i = 0, patternStrings_1 = patternStrings; _i < patternStrings_1.length; _i++) { + var patternString = patternStrings_1[_i]; + var pattern = tryParsePattern(patternString); + if (pattern) { + patterns.push(pattern); + } + else if (patternString === candidate) { + return patternString; + } + } + return findBestPatternMatch(patterns, function (_) { return _; }, candidate); + } + ts.matchPatternOrExact = matchPatternOrExact; + function patternText(_a) { + var prefix = _a.prefix, suffix = _a.suffix; + return prefix + "*" + suffix; + } + ts.patternText = patternText; + function matchedText(pattern, candidate) { + Debug.assert(isPatternMatch(pattern, candidate)); + return candidate.substr(pattern.prefix.length, candidate.length - pattern.suffix.length); + } + ts.matchedText = matchedText; + function findBestPatternMatch(values, getPattern, candidate) { + var matchedValue = undefined; + var longestMatchPrefixLength = -1; + for (var _i = 0, values_1 = values; _i < values_1.length; _i++) { + var v = values_1[_i]; + var pattern = getPattern(v); + if (isPatternMatch(pattern, candidate) && pattern.prefix.length > longestMatchPrefixLength) { + longestMatchPrefixLength = pattern.prefix.length; + matchedValue = v; + } + } + return matchedValue; + } + ts.findBestPatternMatch = findBestPatternMatch; + function isPatternMatch(_a, candidate) { + var prefix = _a.prefix, suffix = _a.suffix; + return candidate.length >= prefix.length + suffix.length && + startsWith(candidate, prefix) && + endsWith(candidate, suffix); + } + function tryParsePattern(pattern) { + Debug.assert(hasZeroOrOneAsteriskCharacter(pattern)); + var indexOfStar = pattern.indexOf("*"); + return indexOfStar === -1 ? undefined : { + prefix: pattern.substr(0, indexOfStar), + suffix: pattern.substr(indexOfStar + 1) + }; + } + ts.tryParsePattern = tryParsePattern; + function positionIsSynthesized(pos) { + return !(pos >= 0); + } + ts.positionIsSynthesized = positionIsSynthesized; })(ts || (ts = {})); var ts; (function (ts) { @@ -1760,8 +1900,14 @@ var ts; function isNode4OrLater() { return parseInt(process.version.charAt(1)) >= 4; } + function isFileSystemCaseSensitive() { + if (platform === "win32" || platform === "win64") { + return false; + } + return !fileExists(__filename.toUpperCase()) || !fileExists(__filename.toLowerCase()); + } var platform = _os.platform(); - var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin"; + var useCaseSensitiveFileNames = isFileSystemCaseSensitive(); function readFile(fileName, encoding) { if (!fileExists(fileName)) { return undefined; @@ -1886,6 +2032,9 @@ var ts; }, watchDirectory: function (directoryName, callback, recursive) { var options; + if (!directoryExists(directoryName)) { + return; + } if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) { options = { persistent: true, recursive: !!recursive }; } @@ -1997,19 +2146,43 @@ var ts; realpath: realpath }; } + function recursiveCreateDirectory(directoryPath, sys) { + var basePath = ts.getDirectoryPath(directoryPath); + var shouldCreateParent = directoryPath !== basePath && !sys.directoryExists(basePath); + if (shouldCreateParent) { + recursiveCreateDirectory(basePath, sys); + } + if (shouldCreateParent || !sys.directoryExists(directoryPath)) { + sys.createDirectory(directoryPath); + } + } + var sys; if (typeof ChakraHost !== "undefined") { - return getChakraSystem(); + sys = getChakraSystem(); } else if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { - return getWScriptSystem(); + sys = getWScriptSystem(); } else if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof require !== "undefined") { - return getNodeSystem(); + sys = getNodeSystem(); } - else { - return undefined; + if (sys) { + var originalWriteFile_1 = sys.writeFile; + sys.writeFile = function (path, data, writeBom) { + var directoryPath = ts.getDirectoryPath(ts.normalizeSlashes(path)); + if (directoryPath && !sys.directoryExists(directoryPath)) { + recursiveCreateDirectory(directoryPath, sys); + } + originalWriteFile_1.call(sys, path, data, writeBom); + }; } + return sys; })(); + if (ts.sys && ts.sys.getEnvironmentVariable) { + ts.Debug.currentAssertionLevel = /^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV")) + ? 1 + : 0; + } })(ts || (ts = {})); var ts; (function (ts) { @@ -2334,7 +2507,7 @@ var ts; The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2407, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_2407", message: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter." }, Setters_cannot_return_a_value: { code: 2408, category: ts.DiagnosticCategory.Error, key: "Setters_cannot_return_a_value_2408", message: "Setters cannot return a value." }, Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { code: 2409, category: ts.DiagnosticCategory.Error, key: "Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class_2409", message: "Return type of constructor signature must be assignable to the instance type of the class" }, - All_symbols_within_a_with_block_will_be_resolved_to_any: { code: 2410, category: ts.DiagnosticCategory.Error, key: "All_symbols_within_a_with_block_will_be_resolved_to_any_2410", message: "All symbols within a 'with' block will be resolved to 'any'." }, + The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any: { code: 2410, category: ts.DiagnosticCategory.Error, key: "The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any_2410", message: "The 'with' statement is not supported. All symbols in a 'with' block will have type 'any'." }, Property_0_of_type_1_is_not_assignable_to_string_index_type_2: { code: 2411, category: ts.DiagnosticCategory.Error, key: "Property_0_of_type_1_is_not_assignable_to_string_index_type_2_2411", message: "Property '{0}' of type '{1}' is not assignable to string index type '{2}'." }, Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2: { code: 2412, category: ts.DiagnosticCategory.Error, key: "Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2_2412", message: "Property '{0}' of type '{1}' is not assignable to numeric index type '{2}'." }, Numeric_index_type_0_is_not_assignable_to_string_index_type_1: { code: 2413, category: ts.DiagnosticCategory.Error, key: "Numeric_index_type_0_is_not_assignable_to_string_index_type_1_2413", message: "Numeric index type '{0}' is not assignable to string index type '{1}'." }, @@ -2495,7 +2668,7 @@ var ts; this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation: { code: 2683, category: ts.DiagnosticCategory.Error, key: "this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_2683", message: "'this' implicitly has type 'any' because it does not have a type annotation." }, The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1: { code: 2684, category: ts.DiagnosticCategory.Error, key: "The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1_2684", message: "The 'this' context of type '{0}' is not assignable to method's 'this' of type '{1}'." }, The_this_types_of_each_signature_are_incompatible: { code: 2685, category: ts.DiagnosticCategory.Error, key: "The_this_types_of_each_signature_are_incompatible_2685", message: "The 'this' types of each signature are incompatible." }, - Identifier_0_must_be_imported_from_a_module: { code: 2686, category: ts.DiagnosticCategory.Error, key: "Identifier_0_must_be_imported_from_a_module_2686", message: "Identifier '{0}' must be imported from a module" }, + _0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead: { code: 2686, category: ts.DiagnosticCategory.Error, key: "_0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead_2686", message: "'{0}' refers to a UMD global, but the current file is a module. Consider adding an import instead." }, All_declarations_of_0_must_have_identical_modifiers: { code: 2687, category: ts.DiagnosticCategory.Error, key: "All_declarations_of_0_must_have_identical_modifiers_2687", message: "All declarations of '{0}' must have identical modifiers." }, Cannot_find_type_definition_file_for_0: { code: 2688, category: ts.DiagnosticCategory.Error, key: "Cannot_find_type_definition_file_for_0_2688", message: "Cannot find type definition file for '{0}'." }, Cannot_extend_an_interface_0_Did_you_mean_implements: { code: 2689, category: ts.DiagnosticCategory.Error, key: "Cannot_extend_an_interface_0_Did_you_mean_implements_2689", message: "Cannot extend an interface '{0}'. Did you mean 'implements'?" }, @@ -2728,6 +2901,8 @@ var ts; No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0: { code: 6137, category: ts.DiagnosticCategory.Message, key: "No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0_6137", message: "No types specified in 'package.json' but 'allowJs' is set, so returning 'main' value of '{0}'" }, Property_0_is_declared_but_never_used: { code: 6138, category: ts.DiagnosticCategory.Error, key: "Property_0_is_declared_but_never_used_6138", message: "Property '{0}' is declared but never used." }, Import_emit_helpers_from_tslib: { code: 6139, category: ts.DiagnosticCategory.Message, key: "Import_emit_helpers_from_tslib_6139", message: "Import emit helpers from 'tslib'." }, + Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: { code: 6140, category: ts.DiagnosticCategory.Error, key: "Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using__6140", message: "Auto discovery for typings is enabled in project '{0}'. Running extra resolution pass for module '{1}' using cache location '{2}'." }, + Parse_in_strict_mode_and_emit_use_strict_for_each_source_file: { code: 6141, category: ts.DiagnosticCategory.Message, key: "Parse_in_strict_mode_and_emit_use_strict_for_each_source_file_6141", message: "Parse in strict mode and emit \"use strict\" for each source file" }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter_0_implicitly_has_an_1_type_7006", message: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member_0_implicitly_has_an_1_type_7008", message: "Member '{0}' implicitly has an '{1}' type." }, @@ -2752,6 +2927,7 @@ var ts; Binding_element_0_implicitly_has_an_1_type: { code: 7031, category: ts.DiagnosticCategory.Error, key: "Binding_element_0_implicitly_has_an_1_type_7031", message: "Binding element '{0}' implicitly has an '{1}' type." }, Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation: { code: 7032, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation_7032", message: "Property '{0}' implicitly has type 'any', because its set accessor lacks a parameter type annotation." }, Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation: { code: 7033, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation_7033", message: "Property '{0}' implicitly has type 'any', because its get accessor lacks a return type annotation." }, + Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined: { code: 7034, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined_7034", message: "Variable '{0}' implicitly has type 'any' in some locations where its type cannot be determined." }, You_cannot_rename_this_element: { code: 8000, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_this_element_8000", message: "You cannot rename this element." }, You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", message: "You cannot rename elements that are defined in the standard TypeScript library." }, import_can_only_be_used_in_a_ts_file: { code: 8002, category: ts.DiagnosticCategory.Error, key: "import_can_only_be_used_in_a_ts_file_8002", message: "'import ... =' can only be used in a .ts file." }, @@ -2781,7 +2957,14 @@ var ts; super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class: { code: 17009, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class_17009", message: "'super' must be called before accessing 'this' in the constructor of a derived class." }, Unknown_typing_option_0: { code: 17010, category: ts.DiagnosticCategory.Error, key: "Unknown_typing_option_0_17010", message: "Unknown typing option '{0}'." }, Circularity_detected_while_resolving_configuration_Colon_0: { code: 18000, category: ts.DiagnosticCategory.Error, key: "Circularity_detected_while_resolving_configuration_Colon_0_18000", message: "Circularity detected while resolving configuration: {0}" }, - The_path_in_an_extends_options_must_be_relative_or_rooted: { code: 18001, category: ts.DiagnosticCategory.Error, key: "The_path_in_an_extends_options_must_be_relative_or_rooted_18001", message: "The path in an 'extends' options must be relative or rooted." } + The_path_in_an_extends_options_must_be_relative_or_rooted: { code: 18001, category: ts.DiagnosticCategory.Error, key: "The_path_in_an_extends_options_must_be_relative_or_rooted_18001", message: "The path in an 'extends' options must be relative or rooted." }, + Add_missing_super_call: { code: 90001, category: ts.DiagnosticCategory.Message, key: "Add_missing_super_call_90001", message: "Add missing 'super()' call." }, + Make_super_call_the_first_statement_in_the_constructor: { code: 90002, category: ts.DiagnosticCategory.Message, key: "Make_super_call_the_first_statement_in_the_constructor_90002", message: "Make 'super()' call the first statement in the constructor." }, + Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'" }, + Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers" }, + Implement_interface_on_reference: { code: 90005, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_reference_90005", message: "Implement interface on reference" }, + Implement_interface_on_class: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_class_90006", message: "Implement interface on class" }, + Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" } }; })(ts || (ts = {})); var ts; @@ -3691,7 +3874,7 @@ var ts; return token = 69; } function scanBinaryOrOctalDigits(base) { - ts.Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8"); + ts.Debug.assert(base === 2 || base === 8, "Expected either base 2 or base 8"); var value = 0; var numberOfDigits = 0; while (true) { @@ -4334,11 +4517,13 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + ts.compileOnSaveCommandLineOption = { name: "compileOnSave", type: "boolean" }; ts.optionDeclarations = [ { name: "charset", type: "string" }, + ts.compileOnSaveCommandLineOption, { name: "declaration", shortName: "d", @@ -4761,6 +4946,11 @@ var ts; name: "importHelpers", type: "boolean", description: ts.Diagnostics.Import_emit_helpers_from_tslib + }, + { + name: "alwaysStrict", + type: "boolean", + description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file } ]; ts.typingOptionDeclarations = [ @@ -4962,10 +5152,11 @@ var ts; return parseConfigFileTextToJson(fileName, text); } ts.readConfigFile = readConfigFile; - function parseConfigFileTextToJson(fileName, jsonText) { + function parseConfigFileTextToJson(fileName, jsonText, stripComments) { + if (stripComments === void 0) { stripComments = true; } try { - var jsonTextWithoutComments = removeComments(jsonText); - return { config: /\S/.test(jsonTextWithoutComments) ? JSON.parse(jsonTextWithoutComments) : {} }; + var jsonTextToParse = stripComments ? removeComments(jsonText) : jsonText; + return { config: /\S/.test(jsonTextToParse) ? JSON.parse(jsonTextToParse) : {} }; } catch (e) { return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) }; @@ -5099,13 +5290,15 @@ var ts; options = ts.extend(existingOptions, options); options.configFilePath = configFileName; var _c = getFileNames(errors), fileNames = _c.fileNames, wildcardDirectories = _c.wildcardDirectories; + var compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors); return { options: options, fileNames: fileNames, typingOptions: typingOptions, raw: json, errors: errors, - wildcardDirectories: wildcardDirectories + wildcardDirectories: wildcardDirectories, + compileOnSave: compileOnSave }; function tryExtendsName(extendedConfig) { if (!(ts.isRootedDiskPath(extendedConfig) || ts.startsWith(ts.normalizeSlashes(extendedConfig), "./") || ts.startsWith(ts.normalizeSlashes(extendedConfig), "../"))) { @@ -5183,6 +5376,17 @@ var ts; var _b; } ts.parseJsonConfigFileContent = parseJsonConfigFileContent; + function convertCompileOnSaveOptionFromJson(jsonOption, basePath, errors) { + if (!ts.hasProperty(jsonOption, ts.compileOnSaveCommandLineOption.name)) { + return false; + } + var result = convertJsonOption(ts.compileOnSaveCommandLineOption, jsonOption["compileOnSave"], basePath, errors); + if (typeof result === "boolean" && result) { + return result; + } + return false; + } + ts.convertCompileOnSaveOptionFromJson = convertCompileOnSaveOptionFromJson; function convertCompilerOptionsFromJson(jsonOptions, basePath, configFileName) { var errors = []; var options = convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName); @@ -5196,7 +5400,9 @@ var ts; } ts.convertTypingOptionsFromJson = convertTypingOptionsFromJson; function convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { - var options = ts.getBaseFileName(configFileName) === "jsconfig.json" ? { allowJs: true, maxNodeModuleJsDepth: 2 } : {}; + var options = ts.getBaseFileName(configFileName) === "jsconfig.json" + ? { allowJs: true, maxNodeModuleJsDepth: 2, allowSyntheticDefaultImports: true, skipLibCheck: true } + : {}; convertOptionsFromJson(ts.optionDeclarations, jsonOptions, basePath, options, ts.Diagnostics.Unknown_compiler_option_0, errors); return options; } @@ -5395,6 +5601,937 @@ var ts; } })(ts || (ts = {})); var ts; +(function (ts) { + var JsTyping; + (function (JsTyping) { + ; + ; + var safeList; + var EmptySafeList = ts.createMap(); + function discoverTypings(host, fileNames, projectRootPath, safeListPath, packageNameToTypingLocation, typingOptions, compilerOptions) { + var inferredTypings = ts.createMap(); + if (!typingOptions || !typingOptions.enableAutoDiscovery) { + return { cachedTypingPaths: [], newTypingNames: [], filesToWatch: [] }; + } + fileNames = ts.filter(ts.map(fileNames, ts.normalizePath), function (f) { + var kind = ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)); + return kind === 1 || kind === 2; + }); + if (!safeList) { + var result = ts.readConfigFile(safeListPath, function (path) { return host.readFile(path); }); + safeList = result.config ? ts.createMap(result.config) : EmptySafeList; + } + var filesToWatch = []; + var searchDirs = []; + var exclude = []; + mergeTypings(typingOptions.include); + exclude = typingOptions.exclude || []; + var possibleSearchDirs = ts.map(fileNames, ts.getDirectoryPath); + if (projectRootPath !== undefined) { + possibleSearchDirs.push(projectRootPath); + } + searchDirs = ts.deduplicate(possibleSearchDirs); + for (var _i = 0, searchDirs_1 = searchDirs; _i < searchDirs_1.length; _i++) { + var searchDir = searchDirs_1[_i]; + var packageJsonPath = ts.combinePaths(searchDir, "package.json"); + getTypingNamesFromJson(packageJsonPath, filesToWatch); + var bowerJsonPath = ts.combinePaths(searchDir, "bower.json"); + getTypingNamesFromJson(bowerJsonPath, filesToWatch); + var nodeModulesPath = ts.combinePaths(searchDir, "node_modules"); + getTypingNamesFromNodeModuleFolder(nodeModulesPath); + } + getTypingNamesFromSourceFileNames(fileNames); + for (var name_7 in packageNameToTypingLocation) { + if (name_7 in inferredTypings && !inferredTypings[name_7]) { + inferredTypings[name_7] = packageNameToTypingLocation[name_7]; + } + } + for (var _a = 0, exclude_1 = exclude; _a < exclude_1.length; _a++) { + var excludeTypingName = exclude_1[_a]; + delete inferredTypings[excludeTypingName]; + } + var newTypingNames = []; + var cachedTypingPaths = []; + for (var typing in inferredTypings) { + if (inferredTypings[typing] !== undefined) { + cachedTypingPaths.push(inferredTypings[typing]); + } + else { + newTypingNames.push(typing); + } + } + return { cachedTypingPaths: cachedTypingPaths, newTypingNames: newTypingNames, filesToWatch: filesToWatch }; + function mergeTypings(typingNames) { + if (!typingNames) { + return; + } + for (var _i = 0, typingNames_1 = typingNames; _i < typingNames_1.length; _i++) { + var typing = typingNames_1[_i]; + if (!(typing in inferredTypings)) { + inferredTypings[typing] = undefined; + } + } + } + function getTypingNamesFromJson(jsonPath, filesToWatch) { + var result = ts.readConfigFile(jsonPath, function (path) { return host.readFile(path); }); + if (result.config) { + var jsonConfig = result.config; + filesToWatch.push(jsonPath); + if (jsonConfig.dependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.dependencies)); + } + if (jsonConfig.devDependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.devDependencies)); + } + if (jsonConfig.optionalDependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.optionalDependencies)); + } + if (jsonConfig.peerDependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.peerDependencies)); + } + } + } + function getTypingNamesFromSourceFileNames(fileNames) { + var jsFileNames = ts.filter(fileNames, ts.hasJavaScriptFileExtension); + var inferredTypingNames = ts.map(jsFileNames, function (f) { return ts.removeFileExtension(ts.getBaseFileName(f.toLowerCase())); }); + var cleanedTypingNames = ts.map(inferredTypingNames, function (f) { return f.replace(/((?:\.|-)min(?=\.|$))|((?:-|\.)\d+)/g, ""); }); + if (safeList !== EmptySafeList) { + mergeTypings(ts.filter(cleanedTypingNames, function (f) { return f in safeList; })); + } + var hasJsxFile = ts.forEach(fileNames, function (f) { return ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)) === 2; }); + if (hasJsxFile) { + mergeTypings(["react"]); + } + } + function getTypingNamesFromNodeModuleFolder(nodeModulesPath) { + if (!host.directoryExists(nodeModulesPath)) { + return; + } + var typingNames = []; + var fileNames = host.readDirectory(nodeModulesPath, [".json"], undefined, undefined, 2); + for (var _i = 0, fileNames_2 = fileNames; _i < fileNames_2.length; _i++) { + var fileName = fileNames_2[_i]; + var normalizedFileName = ts.normalizePath(fileName); + if (ts.getBaseFileName(normalizedFileName) !== "package.json") { + continue; + } + var result = ts.readConfigFile(normalizedFileName, function (path) { return host.readFile(path); }); + if (!result.config) { + continue; + } + var packageJson = result.config; + if (packageJson._requiredBy && + ts.filter(packageJson._requiredBy, function (r) { return r[0] === "#" || r === "/"; }).length === 0) { + continue; + } + if (!packageJson.name) { + continue; + } + if (packageJson.typings) { + var absolutePath = ts.getNormalizedAbsolutePath(packageJson.typings, ts.getDirectoryPath(normalizedFileName)); + inferredTypings[packageJson.name] = absolutePath; + } + else { + typingNames.push(packageJson.name); + } + } + mergeTypings(typingNames); + } + } + JsTyping.discoverTypings = discoverTypings; + })(JsTyping = ts.JsTyping || (ts.JsTyping = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + (function (LogLevel) { + LogLevel[LogLevel["terse"] = 0] = "terse"; + LogLevel[LogLevel["normal"] = 1] = "normal"; + LogLevel[LogLevel["requestTime"] = 2] = "requestTime"; + LogLevel[LogLevel["verbose"] = 3] = "verbose"; + })(server.LogLevel || (server.LogLevel = {})); + var LogLevel = server.LogLevel; + server.emptyArray = []; + var Msg; + (function (Msg) { + Msg.Err = "Err"; + Msg.Info = "Info"; + Msg.Perf = "Perf"; + })(Msg = server.Msg || (server.Msg = {})); + function getProjectRootPath(project) { + switch (project.projectKind) { + case server.ProjectKind.Configured: + return ts.getDirectoryPath(project.getProjectName()); + case server.ProjectKind.Inferred: + return ""; + case server.ProjectKind.External: + var projectName = ts.normalizeSlashes(project.getProjectName()); + return project.projectService.host.fileExists(projectName) ? ts.getDirectoryPath(projectName) : projectName; + } + } + function createInstallTypingsRequest(project, typingOptions, cachePath) { + return { + projectName: project.getProjectName(), + fileNames: project.getFileNames(), + compilerOptions: project.getCompilerOptions(), + typingOptions: typingOptions, + projectRootPath: getProjectRootPath(project), + cachePath: cachePath, + kind: "discover" + }; + } + server.createInstallTypingsRequest = createInstallTypingsRequest; + var Errors; + (function (Errors) { + function ThrowNoProject() { + throw new Error("No Project."); + } + Errors.ThrowNoProject = ThrowNoProject; + function ThrowProjectLanguageServiceDisabled() { + throw new Error("The project's language service is disabled."); + } + Errors.ThrowProjectLanguageServiceDisabled = ThrowProjectLanguageServiceDisabled; + function ThrowProjectDoesNotContainDocument(fileName, project) { + throw new Error("Project '" + project.getProjectName() + "' does not contain document '" + fileName + "'"); + } + Errors.ThrowProjectDoesNotContainDocument = ThrowProjectDoesNotContainDocument; + })(Errors = server.Errors || (server.Errors = {})); + function getDefaultFormatCodeSettings(host) { + return { + indentSize: 4, + tabSize: 4, + newLineCharacter: host.newLine || "\n", + convertTabsToSpaces: true, + indentStyle: ts.IndentStyle.Smart, + insertSpaceAfterCommaDelimiter: true, + insertSpaceAfterSemicolonInForStatements: true, + insertSpaceBeforeAndAfterBinaryOperators: true, + insertSpaceAfterKeywordsInControlFlowStatements: true, + insertSpaceAfterFunctionKeywordForAnonymousFunctions: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, + insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, + insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, + placeOpenBraceOnNewLineForFunctions: false, + placeOpenBraceOnNewLineForControlBlocks: false + }; + } + server.getDefaultFormatCodeSettings = getDefaultFormatCodeSettings; + function mergeMaps(target, source) { + for (var key in source) { + if (ts.hasProperty(source, key)) { + target[key] = source[key]; + } + } + } + server.mergeMaps = mergeMaps; + function removeItemFromSet(items, itemToRemove) { + if (items.length === 0) { + return; + } + var index = items.indexOf(itemToRemove); + if (index < 0) { + return; + } + if (index === items.length - 1) { + items.pop(); + } + else { + items[index] = items.pop(); + } + } + server.removeItemFromSet = removeItemFromSet; + function toNormalizedPath(fileName) { + return ts.normalizePath(fileName); + } + server.toNormalizedPath = toNormalizedPath; + function normalizedPathToPath(normalizedPath, currentDirectory, getCanonicalFileName) { + var f = ts.isRootedDiskPath(normalizedPath) ? normalizedPath : ts.getNormalizedAbsolutePath(normalizedPath, currentDirectory); + return getCanonicalFileName(f); + } + server.normalizedPathToPath = normalizedPathToPath; + function asNormalizedPath(fileName) { + return fileName; + } + server.asNormalizedPath = asNormalizedPath; + function createNormalizedPathMap() { + var map = Object.create(null); + return { + get: function (path) { + return map[path]; + }, + set: function (path, value) { + map[path] = value; + }, + contains: function (path) { + return ts.hasProperty(map, path); + }, + remove: function (path) { + delete map[path]; + } + }; + } + server.createNormalizedPathMap = createNormalizedPathMap; + function throwLanguageServiceIsDisabledError() { + throw new Error("LanguageService is disabled"); + } + server.nullLanguageService = { + cleanupSemanticCache: throwLanguageServiceIsDisabledError, + getSyntacticDiagnostics: throwLanguageServiceIsDisabledError, + getSemanticDiagnostics: throwLanguageServiceIsDisabledError, + getCompilerOptionsDiagnostics: throwLanguageServiceIsDisabledError, + getSyntacticClassifications: throwLanguageServiceIsDisabledError, + getEncodedSyntacticClassifications: throwLanguageServiceIsDisabledError, + getSemanticClassifications: throwLanguageServiceIsDisabledError, + getEncodedSemanticClassifications: throwLanguageServiceIsDisabledError, + getCompletionsAtPosition: throwLanguageServiceIsDisabledError, + findReferences: throwLanguageServiceIsDisabledError, + getCompletionEntryDetails: throwLanguageServiceIsDisabledError, + getQuickInfoAtPosition: throwLanguageServiceIsDisabledError, + findRenameLocations: throwLanguageServiceIsDisabledError, + getNameOrDottedNameSpan: throwLanguageServiceIsDisabledError, + getBreakpointStatementAtPosition: throwLanguageServiceIsDisabledError, + getBraceMatchingAtPosition: throwLanguageServiceIsDisabledError, + getSignatureHelpItems: throwLanguageServiceIsDisabledError, + getDefinitionAtPosition: throwLanguageServiceIsDisabledError, + getRenameInfo: throwLanguageServiceIsDisabledError, + getTypeDefinitionAtPosition: throwLanguageServiceIsDisabledError, + getReferencesAtPosition: throwLanguageServiceIsDisabledError, + getDocumentHighlights: throwLanguageServiceIsDisabledError, + getOccurrencesAtPosition: throwLanguageServiceIsDisabledError, + getNavigateToItems: throwLanguageServiceIsDisabledError, + getNavigationBarItems: throwLanguageServiceIsDisabledError, + getNavigationTree: throwLanguageServiceIsDisabledError, + getOutliningSpans: throwLanguageServiceIsDisabledError, + getTodoComments: throwLanguageServiceIsDisabledError, + getIndentationAtPosition: throwLanguageServiceIsDisabledError, + getFormattingEditsForRange: throwLanguageServiceIsDisabledError, + getFormattingEditsForDocument: throwLanguageServiceIsDisabledError, + getFormattingEditsAfterKeystroke: throwLanguageServiceIsDisabledError, + getDocCommentTemplateAtPosition: throwLanguageServiceIsDisabledError, + isValidBraceCompletionAtPosition: throwLanguageServiceIsDisabledError, + getEmitOutput: throwLanguageServiceIsDisabledError, + getProgram: throwLanguageServiceIsDisabledError, + getNonBoundSourceFile: throwLanguageServiceIsDisabledError, + dispose: throwLanguageServiceIsDisabledError, + getCompletionEntrySymbol: throwLanguageServiceIsDisabledError, + getImplementationAtPosition: throwLanguageServiceIsDisabledError, + getSourceFile: throwLanguageServiceIsDisabledError, + getCodeFixesAtPosition: throwLanguageServiceIsDisabledError + }; + server.nullLanguageServiceHost = { + setCompilationSettings: function () { return undefined; }, + notifyFileRemoved: function () { return undefined; } + }; + function isInferredProjectName(name) { + return /dev\/null\/inferredProject\d+\*/.test(name); + } + server.isInferredProjectName = isInferredProjectName; + function makeInferredProjectName(counter) { + return "/dev/null/inferredProject" + counter + "*"; + } + server.makeInferredProjectName = makeInferredProjectName; + var ThrottledOperations = (function () { + function ThrottledOperations(host) { + this.host = host; + this.pendingTimeouts = ts.createMap(); + } + ThrottledOperations.prototype.schedule = function (operationId, delay, cb) { + if (ts.hasProperty(this.pendingTimeouts, operationId)) { + this.host.clearTimeout(this.pendingTimeouts[operationId]); + } + this.pendingTimeouts[operationId] = this.host.setTimeout(ThrottledOperations.run, delay, this, operationId, cb); + }; + ThrottledOperations.run = function (self, operationId, cb) { + delete self.pendingTimeouts[operationId]; + cb(); + }; + return ThrottledOperations; + }()); + server.ThrottledOperations = ThrottledOperations; + var GcTimer = (function () { + function GcTimer(host, delay, logger) { + this.host = host; + this.delay = delay; + this.logger = logger; + } + GcTimer.prototype.scheduleCollect = function () { + if (!this.host.gc || this.timerId != undefined) { + return; + } + this.timerId = this.host.setTimeout(GcTimer.run, this.delay, this); + }; + GcTimer.run = function (self) { + self.timerId = undefined; + var log = self.logger.hasLevel(LogLevel.requestTime); + var before = log && self.host.getMemoryUsage(); + self.host.gc(); + if (log) { + var after = self.host.getMemoryUsage(); + self.logger.perftrc("GC::before " + before + ", after " + after); + } + }; + return GcTimer; + }()); + server.GcTimer = GcTimer; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + function trace(host, message) { + host.trace(ts.formatMessage.apply(undefined, arguments)); + } + ts.trace = trace; + function isTraceEnabled(compilerOptions, host) { + return compilerOptions.traceResolution && host.trace !== undefined; + } + ts.isTraceEnabled = isTraceEnabled; + function createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations) { + return { resolvedModule: resolvedFileName ? { resolvedFileName: resolvedFileName, isExternalLibraryImport: isExternalLibraryImport } : undefined, failedLookupLocations: failedLookupLocations }; + } + ts.createResolvedModule = createResolvedModule; + function moduleHasNonRelativeName(moduleName) { + return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); + } + function tryReadTypesSection(packageJsonPath, baseDirectory, state) { + var jsonContent = readJson(packageJsonPath, state.host); + function tryReadFromField(fieldName) { + if (ts.hasProperty(jsonContent, fieldName)) { + var typesFile = jsonContent[fieldName]; + if (typeof typesFile === "string") { + var typesFilePath_1 = ts.normalizePath(ts.combinePaths(baseDirectory, typesFile)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath_1); + } + return typesFilePath_1; + } + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof typesFile); + } + } + } + } + var typesFilePath = tryReadFromField("typings") || tryReadFromField("types"); + if (typesFilePath) { + return typesFilePath; + } + if (state.compilerOptions.allowJs && jsonContent.main && typeof jsonContent.main === "string") { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0, jsonContent.main); + } + var mainFilePath = ts.normalizePath(ts.combinePaths(baseDirectory, jsonContent.main)); + return mainFilePath; + } + return undefined; + } + function readJson(path, host) { + try { + var jsonText = host.readFile(path); + return jsonText ? JSON.parse(jsonText) : {}; + } + catch (e) { + return {}; + } + } + var typeReferenceExtensions = [".d.ts"]; + function getEffectiveTypeRoots(options, host) { + if (options.typeRoots) { + return options.typeRoots; + } + var currentDirectory; + if (options.configFilePath) { + currentDirectory = ts.getDirectoryPath(options.configFilePath); + } + else if (host.getCurrentDirectory) { + currentDirectory = host.getCurrentDirectory(); + } + return currentDirectory !== undefined && getDefaultTypeRoots(currentDirectory, host); + } + ts.getEffectiveTypeRoots = getEffectiveTypeRoots; + function getDefaultTypeRoots(currentDirectory, host) { + if (!host.directoryExists) { + return [ts.combinePaths(currentDirectory, nodeModulesAtTypes)]; + } + var typeRoots; + while (true) { + var atTypes = ts.combinePaths(currentDirectory, nodeModulesAtTypes); + if (host.directoryExists(atTypes)) { + (typeRoots || (typeRoots = [])).push(atTypes); + } + var parent_1 = ts.getDirectoryPath(currentDirectory); + if (parent_1 === currentDirectory) { + break; + } + currentDirectory = parent_1; + } + return typeRoots; + } + var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types"); + function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host) { + var traceEnabled = isTraceEnabled(options, host); + var moduleResolutionState = { + compilerOptions: options, + host: host, + skipTsx: true, + traceEnabled: traceEnabled + }; + var typeRoots = getEffectiveTypeRoots(options, host); + if (traceEnabled) { + if (containingFile === undefined) { + if (typeRoots === undefined) { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set, typeReferenceDirectiveName); + } + else { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1, typeReferenceDirectiveName, typeRoots); + } + } + else { + if (typeRoots === undefined) { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set, typeReferenceDirectiveName, containingFile); + } + else { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, typeRoots); + } + } + } + var failedLookupLocations = []; + if (typeRoots && typeRoots.length) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", ")); + } + var primarySearchPaths = typeRoots; + for (var _i = 0, primarySearchPaths_1 = primarySearchPaths; _i < primarySearchPaths_1.length; _i++) { + var typeRoot = primarySearchPaths_1[_i]; + var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); + var candidateDirectory = ts.getDirectoryPath(candidate); + var resolvedFile_1 = loadNodeModuleFromDirectory(typeReferenceExtensions, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState); + if (resolvedFile_1) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile_1, true); + } + return { + resolvedTypeReferenceDirective: { primary: true, resolvedFileName: resolvedFile_1 }, + failedLookupLocations: failedLookupLocations + }; + } + } + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths); + } + } + var resolvedFile; + var initialLocationForSecondaryLookup; + if (containingFile) { + initialLocationForSecondaryLookup = ts.getDirectoryPath(containingFile); + } + if (initialLocationForSecondaryLookup !== undefined) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); + } + resolvedFile = loadModuleFromNodeModules(typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, false); + if (traceEnabled) { + if (resolvedFile) { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile, false); + } + else { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); + } + } + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder); + } + } + return { + resolvedTypeReferenceDirective: resolvedFile + ? { primary: false, resolvedFileName: resolvedFile } + : undefined, + failedLookupLocations: failedLookupLocations + }; + } + ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective; + function getAutomaticTypeDirectiveNames(options, host) { + if (options.types) { + return options.types; + } + var result = []; + if (host.directoryExists && host.getDirectories) { + var typeRoots = getEffectiveTypeRoots(options, host); + if (typeRoots) { + for (var _i = 0, typeRoots_1 = typeRoots; _i < typeRoots_1.length; _i++) { + var root = typeRoots_1[_i]; + if (host.directoryExists(root)) { + for (var _a = 0, _b = host.getDirectories(root); _a < _b.length; _a++) { + var typeDirectivePath = _b[_a]; + var normalized = ts.normalizePath(typeDirectivePath); + var packageJsonPath = pathToPackageJson(ts.combinePaths(root, normalized)); + var isNotNeededPackage = host.fileExists(packageJsonPath) && readJson(packageJsonPath, host).typings === null; + if (!isNotNeededPackage) { + result.push(ts.getBaseFileName(normalized)); + } + } + } + } + } + } + return result; + } + ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; + function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + var traceEnabled = isTraceEnabled(compilerOptions, host); + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); + } + var moduleResolution = compilerOptions.moduleResolution; + if (moduleResolution === undefined) { + moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + if (traceEnabled) { + trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + var result; + switch (moduleResolution) { + case ts.ModuleResolutionKind.NodeJs: + result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host); + break; + case ts.ModuleResolutionKind.Classic: + result = classicNameResolver(moduleName, containingFile, compilerOptions, host); + break; + } + if (traceEnabled) { + if (result.resolvedModule) { + trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.resolvedModule.resolvedFileName); + } + else { + trace(host, ts.Diagnostics.Module_name_0_was_not_resolved, moduleName); + } + } + return result; + } + ts.resolveModuleName = resolveModuleName; + function tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { + if (moduleHasNonRelativeName(moduleName)) { + return tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state); + } + else { + return tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state); + } + } + function tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { + if (!state.compilerOptions.rootDirs) { + return undefined; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0, moduleName); + } + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var matchedRootDir; + var matchedNormalizedPrefix; + for (var _i = 0, _a = state.compilerOptions.rootDirs; _i < _a.length; _i++) { + var rootDir = _a[_i]; + var normalizedRoot = ts.normalizePath(rootDir); + if (!ts.endsWith(normalizedRoot, ts.directorySeparator)) { + normalizedRoot += ts.directorySeparator; + } + var isLongestMatchingPrefix = ts.startsWith(candidate, normalizedRoot) && + (matchedNormalizedPrefix === undefined || matchedNormalizedPrefix.length < normalizedRoot.length); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Checking_if_0_is_the_longest_matching_prefix_for_1_2, normalizedRoot, candidate, isLongestMatchingPrefix); + } + if (isLongestMatchingPrefix) { + matchedNormalizedPrefix = normalizedRoot; + matchedRootDir = rootDir; + } + } + if (matchedNormalizedPrefix) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Longest_matching_prefix_for_0_is_1, candidate, matchedNormalizedPrefix); + } + var suffix = candidate.substr(matchedNormalizedPrefix.length); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, matchedNormalizedPrefix, candidate); + } + var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(containingDirectory, state.host), state); + if (resolvedFileName) { + return resolvedFileName; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Trying_other_entries_in_rootDirs); + } + for (var _b = 0, _c = state.compilerOptions.rootDirs; _b < _c.length; _b++) { + var rootDir = _c[_b]; + if (rootDir === matchedRootDir) { + continue; + } + var candidate_1 = ts.combinePaths(ts.normalizePath(rootDir), suffix); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, rootDir, candidate_1); + } + var baseDirectory = ts.getDirectoryPath(candidate_1); + var resolvedFileName_1 = loader(candidate_1, supportedExtensions, failedLookupLocations, !directoryProbablyExists(baseDirectory, state.host), state); + if (resolvedFileName_1) { + return resolvedFileName_1; + } + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Module_resolution_using_rootDirs_has_failed); + } + } + return undefined; + } + function tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state) { + if (!state.compilerOptions.baseUrl) { + return undefined; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, state.compilerOptions.baseUrl, moduleName); + } + var matchedPattern = undefined; + if (state.compilerOptions.paths) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); + } + matchedPattern = ts.matchPatternOrExact(ts.getOwnKeys(state.compilerOptions.paths), moduleName); + } + if (matchedPattern) { + var matchedStar = typeof matchedPattern === "string" ? undefined : ts.matchedText(matchedPattern, moduleName); + var matchedPatternText = typeof matchedPattern === "string" ? matchedPattern : ts.patternText(matchedPattern); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPatternText); + } + for (var _i = 0, _a = state.compilerOptions.paths[matchedPatternText]; _i < _a.length; _i++) { + var subst = _a[_i]; + var path = matchedStar ? subst.replace("*", matchedStar) : subst; + var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, path)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path); + } + var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + if (resolvedFileName) { + return resolvedFileName; + } + } + return undefined; + } + else { + var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, moduleName)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Resolving_module_name_0_relative_to_base_url_1_2, moduleName, state.compilerOptions.baseUrl, candidate); + } + return loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + } + } + function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host) { + var containingDirectory = ts.getDirectoryPath(containingFile); + var supportedExtensions = ts.getSupportedExtensions(compilerOptions); + var traceEnabled = isTraceEnabled(compilerOptions, host); + var failedLookupLocations = []; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: false }; + var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, supportedExtensions, state); + var isExternalLibraryImport = false; + if (!resolvedFileName) { + if (moduleHasNonRelativeName(moduleName)) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder, moduleName); + } + resolvedFileName = loadModuleFromNodeModules(moduleName, containingDirectory, failedLookupLocations, state, false); + isExternalLibraryImport = resolvedFileName !== undefined; + } + else { + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + resolvedFileName = nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, false, state); + } + } + if (resolvedFileName && host.realpath) { + var originalFileName = resolvedFileName; + resolvedFileName = ts.normalizePath(host.realpath(resolvedFileName)); + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, originalFileName, resolvedFileName); + } + } + return createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations); + } + ts.nodeModuleNameResolver = nodeModuleNameResolver; + function nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate); + } + var resolvedFileName = !ts.pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state); + return resolvedFileName || loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, onlyRecordFailures, state); + } + function directoryProbablyExists(directoryName, host) { + return !host.directoryExists || host.directoryExists(directoryName); + } + ts.directoryProbablyExists = directoryProbablyExists; + function loadModuleFromFile(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) { + var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state); + if (resolvedByAddingExtension) { + return resolvedByAddingExtension; + } + if (ts.hasJavaScriptFileExtension(candidate)) { + var extensionless = ts.removeFileExtension(candidate); + if (state.traceEnabled) { + var extension = candidate.substring(extensionless.length); + trace(state.host, ts.Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension); + } + return tryAddingExtensions(extensionless, extensions, failedLookupLocation, onlyRecordFailures, state); + } + } + function tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) { + if (!onlyRecordFailures) { + var directory = ts.getDirectoryPath(candidate); + if (directory) { + onlyRecordFailures = !directoryProbablyExists(directory, state.host); + } + } + return ts.forEach(extensions, function (ext) { + return !(state.skipTsx && ts.isJsxOrTsxExtension(ext)) && tryFile(candidate + ext, failedLookupLocation, onlyRecordFailures, state); + }); + } + function tryFile(fileName, failedLookupLocation, onlyRecordFailures, state) { + if (!onlyRecordFailures && state.host.fileExists(fileName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); + } + return fileName; + } + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); + } + failedLookupLocation.push(fileName); + return undefined; + } + } + function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocation, onlyRecordFailures, state) { + var packageJsonPath = pathToPackageJson(candidate); + var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); + if (directoryExists && state.host.fileExists(packageJsonPath)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); + } + var typesFile = tryReadTypesSection(packageJsonPath, candidate, state); + if (typesFile) { + var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(typesFile), state.host); + var result = tryFile(typesFile, failedLookupLocation, onlyRecordFailures_1, state) || + tryAddingExtensions(typesFile, extensions, failedLookupLocation, onlyRecordFailures_1, state); + if (result) { + return result; + } + } + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_does_not_have_types_field); + } + } + } + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); + } + failedLookupLocation.push(packageJsonPath); + } + return loadModuleFromFile(ts.combinePaths(candidate, "index"), extensions, failedLookupLocation, !directoryExists, state); + } + function pathToPackageJson(directory) { + return ts.combinePaths(directory, "package.json"); + } + function loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state) { + var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); + var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); + var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); + var supportedExtensions = ts.getSupportedExtensions(state.compilerOptions); + var result = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, !nodeModulesFolderExists, state); + if (result) { + return result; + } + result = loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); + if (result) { + return result; + } + } + function loadModuleFromNodeModules(moduleName, directory, failedLookupLocations, state, checkOneLevel) { + return loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, checkOneLevel, false); + } + ts.loadModuleFromNodeModules = loadModuleFromNodeModules; + function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) { + return loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, false, true); + } + function loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, checkOneLevel, typesOnly) { + directory = ts.normalizeSlashes(directory); + while (true) { + var baseName = ts.getBaseFileName(directory); + if (baseName !== "node_modules") { + var packageResult = void 0; + if (!typesOnly) { + packageResult = loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state); + if (packageResult && ts.hasTypeScriptFileExtension(packageResult)) { + return packageResult; + } + } + var typesResult = loadModuleFromNodeModulesFolder(ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); + if (typesResult || packageResult) { + return typesResult || packageResult; + } + } + var parentPath = ts.getDirectoryPath(directory); + if (parentPath === directory || checkOneLevel) { + break; + } + directory = parentPath; + } + return undefined; + } + function classicNameResolver(moduleName, containingFile, compilerOptions, host) { + var traceEnabled = isTraceEnabled(compilerOptions, host); + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: !compilerOptions.jsx }; + var failedLookupLocations = []; + var supportedExtensions = ts.getSupportedExtensions(compilerOptions); + var containingDirectory = ts.getDirectoryPath(containingFile); + var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, supportedExtensions, state); + if (resolvedFileName) { + return createResolvedModule(resolvedFileName, false, failedLookupLocations); + } + var referencedSourceFile; + if (moduleHasNonRelativeName(moduleName)) { + referencedSourceFile = referencedSourceFile = loadModuleFromAncestorDirectories(moduleName, containingDirectory, supportedExtensions, failedLookupLocations, state) || + loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); + } + else { + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + referencedSourceFile = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, false, state); + } + return referencedSourceFile + ? { resolvedModule: { resolvedFileName: referencedSourceFile }, failedLookupLocations: failedLookupLocations } + : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; + } + ts.classicNameResolver = classicNameResolver; + function loadModuleFromAncestorDirectories(moduleName, containingDirectory, supportedExtensions, failedLookupLocations, state) { + while (true) { + var searchName = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var referencedSourceFile = loadModuleFromFile(searchName, supportedExtensions, failedLookupLocations, false, state); + if (referencedSourceFile) { + return referencedSourceFile; + } + var parentPath = ts.getDirectoryPath(containingDirectory); + if (parentPath === containingDirectory) { + return undefined; + } + containingDirectory = parentPath; + } + } +})(ts || (ts = {})); +var ts; (function (ts) { ts.externalHelpersModuleNameText = "tslib"; function getDeclarationOfKind(symbol, kind) { @@ -5877,10 +7014,10 @@ var ts; return !!(ts.getCombinedNodeFlags(node) & 1); } ts.isLet = isLet; - function isSuperCallExpression(n) { + function isSuperCall(n) { return n.kind === 174 && n.expression.kind === 95; } - ts.isSuperCallExpression = isSuperCallExpression; + ts.isSuperCall = isSuperCall; function isPrologueDirective(node) { return node.kind === 202 && node.expression.kind === 9; } @@ -5943,23 +7080,23 @@ var ts; case 139: case 172: case 97: - var parent_1 = node.parent; - if (parent_1.kind === 158) { + var parent_2 = node.parent; + if (parent_2.kind === 158) { return false; } - if (154 <= parent_1.kind && parent_1.kind <= 166) { + if (154 <= parent_2.kind && parent_2.kind <= 166) { return true; } - switch (parent_1.kind) { + switch (parent_2.kind) { case 194: - return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); + return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); case 141: - return node === parent_1.constraint; + return node === parent_2.constraint; case 145: case 144: case 142: case 218: - return node === parent_1.type; + return node === parent_2.type; case 220: case 179: case 180: @@ -5968,16 +7105,16 @@ var ts; case 146: case 149: case 150: - return node === parent_1.type; + return node === parent_2.type; case 151: case 152: case 153: - return node === parent_1.type; + return node === parent_2.type; case 177: - return node === parent_1.type; + return node === parent_2.type; case 174: case 175: - return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; + return parent_2.typeArguments && ts.indexOf(parent_2.typeArguments, node) >= 0; case 176: return false; } @@ -6030,9 +7167,9 @@ var ts; return; default: if (isFunctionLike(node)) { - var name_7 = node.name; - if (name_7 && name_7.kind === 140) { - traverse(name_7.expression); + var name_8 = node.name; + if (name_8 && name_8.kind === 140) { + traverse(name_8.expression); return; } } @@ -6128,6 +7265,12 @@ var ts; return node && node.kind === 147 && node.parent.kind === 171; } ts.isObjectLiteralMethod = isObjectLiteralMethod; + function isObjectLiteralOrClassExpressionMethod(node) { + return node.kind === 147 && + (node.parent.kind === 171 || + node.parent.kind === 192); + } + ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { return predicate && predicate.kind === 1; } @@ -6238,13 +7381,13 @@ var ts; function getImmediatelyInvokedFunctionExpression(func) { if (func.kind === 179 || func.kind === 180) { var prev = func; - var parent_2 = func.parent; - while (parent_2.kind === 178) { - prev = parent_2; - parent_2 = parent_2.parent; + var parent_3 = func.parent; + while (parent_3.kind === 178) { + prev = parent_3; + parent_3 = parent_3.parent; } - if (parent_2.kind === 174 && parent_2.expression === prev) { - return parent_2; + if (parent_3.kind === 174 && parent_3.expression === prev) { + return parent_3; } } } @@ -6390,8 +7533,8 @@ var ts; case 8: case 9: case 97: - var parent_3 = node.parent; - switch (parent_3.kind) { + var parent_4 = node.parent; + switch (parent_4.kind) { case 218: case 142: case 145: @@ -6399,7 +7542,7 @@ var ts; case 255: case 253: case 169: - return parent_3.initializer === node; + return parent_4.initializer === node; case 202: case 203: case 204: @@ -6410,32 +7553,32 @@ var ts; case 249: case 215: case 213: - return parent_3.expression === node; + return parent_4.expression === node; case 206: - var forStatement = parent_3; + var forStatement = parent_4; return (forStatement.initializer === node && forStatement.initializer.kind !== 219) || forStatement.condition === node || forStatement.incrementor === node; case 207: case 208: - var forInStatement = parent_3; + var forInStatement = parent_4; return (forInStatement.initializer === node && forInStatement.initializer.kind !== 219) || forInStatement.expression === node; case 177: case 195: - return node === parent_3.expression; + return node === parent_4.expression; case 197: - return node === parent_3.expression; + return node === parent_4.expression; case 140: - return node === parent_3.expression; + return node === parent_4.expression; case 143: case 248: case 247: return true; case 194: - return parent_3.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_3); + return parent_4.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_4); default: - if (isPartOfExpression(parent_3)) { + if (isPartOfExpression(parent_4)) { return true; } } @@ -6443,10 +7586,6 @@ var ts; return false; } ts.isPartOfExpression = isPartOfExpression; - function isExternalModuleNameRelative(moduleName) { - return /^\.\.?($|[\\/])/.test(moduleName); - } - ts.isExternalModuleNameRelative = isExternalModuleNameRelative; function isInstantiatedModule(node, preserveConstEnums) { var moduleState = ts.getModuleInstanceState(node); return moduleState === 1 || @@ -6650,17 +7789,17 @@ var ts; node.parent && node.parent.kind === 225) { result = append(result, getJSDocs(node.parent, checkParentVariableStatement, getDocs, getTags)); } - var parent_4 = node.parent; - var isSourceOfAssignmentExpressionStatement = parent_4 && parent_4.parent && - parent_4.kind === 187 && - parent_4.operatorToken.kind === 56 && - parent_4.parent.kind === 202; + var parent_5 = node.parent; + var isSourceOfAssignmentExpressionStatement = parent_5 && parent_5.parent && + parent_5.kind === 187 && + parent_5.operatorToken.kind === 56 && + parent_5.parent.kind === 202; if (isSourceOfAssignmentExpressionStatement) { - result = append(result, getJSDocs(parent_4.parent, checkParentVariableStatement, getDocs, getTags)); + result = append(result, getJSDocs(parent_5.parent, checkParentVariableStatement, getDocs, getTags)); } - var isPropertyAssignmentExpression = parent_4 && parent_4.kind === 253; + var isPropertyAssignmentExpression = parent_5 && parent_5.kind === 253; if (isPropertyAssignmentExpression) { - result = append(result, getJSDocs(parent_4, checkParentVariableStatement, getDocs, getTags)); + result = append(result, getJSDocs(parent_5, checkParentVariableStatement, getDocs, getTags)); } if (node.kind === 142) { var paramTags = getJSDocParameterTag(node, checkParentVariableStatement); @@ -6693,8 +7832,8 @@ var ts; } } else if (param.name.kind === 69) { - var name_8 = param.name.text; - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 275 && tag.parameterName.text === name_8; }); + var name_9 = param.name.text; + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 275 && tag.parameterName.text === name_9; }); if (paramTags) { return paramTags; } @@ -6765,20 +7904,20 @@ var ts; node = node.parent; } while (true) { - var parent_5 = node.parent; - if (parent_5.kind === 170 || parent_5.kind === 191) { - node = parent_5; + var parent_6 = node.parent; + if (parent_6.kind === 170 || parent_6.kind === 191) { + node = parent_6; continue; } - if (parent_5.kind === 253 || parent_5.kind === 254) { - node = parent_5.parent; + if (parent_6.kind === 253 || parent_6.kind === 254) { + node = parent_6.parent; continue; } - return parent_5.kind === 187 && - isAssignmentOperator(parent_5.operatorToken.kind) && - parent_5.left === node || - (parent_5.kind === 207 || parent_5.kind === 208) && - parent_5.initializer === node; + return parent_6.kind === 187 && + isAssignmentOperator(parent_6.operatorToken.kind) && + parent_6.left === node || + (parent_6.kind === 207 || parent_6.kind === 208) && + parent_6.initializer === node; } } ts.isAssignmentTarget = isAssignmentTarget; @@ -7044,14 +8183,10 @@ var ts; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { - return positionIsSynthesized(node.pos) - || positionIsSynthesized(node.end); + return ts.positionIsSynthesized(node.pos) + || ts.positionIsSynthesized(node.end); } ts.nodeIsSynthesized = nodeIsSynthesized; - function positionIsSynthesized(pos) { - return !(pos >= 0); - } - ts.positionIsSynthesized = positionIsSynthesized; function getOriginalNode(node) { if (node) { while (node.original !== undefined) { @@ -7487,28 +8622,16 @@ var ts; function getDeclarationEmitOutputFilePath(sourceFile, host) { var options = host.getCompilerOptions(); var outputDir = options.declarationDir || options.outDir; - if (options.declaration) { - var path = outputDir - ? getSourceFilePathInNewDir(sourceFile, host, outputDir) - : sourceFile.fileName; - return ts.removeFileExtension(path) + ".d.ts"; - } + var path = outputDir + ? getSourceFilePathInNewDir(sourceFile, host, outputDir) + : sourceFile.fileName; + return ts.removeFileExtension(path) + ".d.ts"; } ts.getDeclarationEmitOutputFilePath = getDeclarationEmitOutputFilePath; - function getEmitScriptTarget(compilerOptions) { - return compilerOptions.target || 0; - } - ts.getEmitScriptTarget = getEmitScriptTarget; - function getEmitModuleKind(compilerOptions) { - return typeof compilerOptions.module === "number" ? - compilerOptions.module : - getEmitScriptTarget(compilerOptions) === 2 ? ts.ModuleKind.ES6 : ts.ModuleKind.CommonJS; - } - ts.getEmitModuleKind = getEmitModuleKind; function getSourceFilesToEmit(host, targetSourceFile) { var options = host.getCompilerOptions(); if (options.outFile || options.out) { - var moduleKind = getEmitModuleKind(options); + var moduleKind = ts.getEmitModuleKind(options); var moduleEmitEnabled = moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System; var sourceFiles = host.getSourceFiles(); return ts.filter(sourceFiles, moduleEmitEnabled ? isNonDeclarationFile : isBundleEmitNonExternalModule); @@ -7525,7 +8648,7 @@ var ts; function isBundleEmitNonExternalModule(sourceFile) { return !isDeclarationFile(sourceFile) && !ts.isExternalModule(sourceFile); } - function forEachTransformedEmitFile(host, sourceFiles, action) { + function forEachTransformedEmitFile(host, sourceFiles, action, emitOnlyDtsFiles) { var options = host.getCompilerOptions(); if (options.outFile || options.out) { onBundledEmit(host, sourceFiles); @@ -7552,7 +8675,7 @@ var ts; } var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = !isSourceFileJavaScript(sourceFile) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; + var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (options.declaration || emitOnlyDtsFiles) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; action(jsFilePath, sourceMapFilePath, declarationFilePath, [sourceFile], false); } function onBundledEmit(host, sourceFiles) { @@ -7568,7 +8691,7 @@ var ts; function getSourceMapFilePath(jsFilePath, options) { return options.sourceMap ? jsFilePath + ".map" : undefined; } - function forEachExpectedEmitFile(host, action, targetSourceFile) { + function forEachExpectedEmitFile(host, action, targetSourceFile, emitOnlyDtsFiles) { var options = host.getCompilerOptions(); if (options.outFile || options.out) { onBundledEmit(host); @@ -7595,18 +8718,19 @@ var ts; } } var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); + var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (emitOnlyDtsFiles || options.declaration) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; var emitFileNames = { jsFilePath: jsFilePath, sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), - declarationFilePath: !isSourceFileJavaScript(sourceFile) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined + declarationFilePath: declarationFilePath }; - action(emitFileNames, [sourceFile], false); + action(emitFileNames, [sourceFile], false, emitOnlyDtsFiles); } function onBundledEmit(host) { var bundledSources = ts.filter(host.getSourceFiles(), function (sourceFile) { return !isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile) && (!ts.isExternalModule(sourceFile) || - !!getEmitModuleKind(options)); }); + !!ts.getEmitModuleKind(options)); }); if (bundledSources.length) { var jsFilePath = options.outFile || options.out; var emitFileNames = { @@ -7614,7 +8738,7 @@ var ts; sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), declarationFilePath: options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined }; - action(emitFileNames, bundledSources, true); + action(emitFileNames, bundledSources, true, emitOnlyDtsFiles); } } } @@ -7651,13 +8775,32 @@ var ts; ts.getFirstConstructorWithBody = getFirstConstructorWithBody; function getSetAccessorTypeAnnotationNode(accessor) { if (accessor && accessor.parameters.length > 0) { - var hasThis = accessor.parameters.length === 2 && - accessor.parameters[0].name.kind === 69 && - accessor.parameters[0].name.originalKeywordKind === 97; + var hasThis = accessor.parameters.length === 2 && parameterIsThisKeyword(accessor.parameters[0]); return accessor.parameters[hasThis ? 1 : 0].type; } } ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode; + function getThisParameter(signature) { + if (signature.parameters.length) { + var thisParameter = signature.parameters[0]; + if (parameterIsThisKeyword(thisParameter)) { + return thisParameter; + } + } + } + ts.getThisParameter = getThisParameter; + function parameterIsThisKeyword(parameter) { + return isThisIdentifier(parameter.name); + } + ts.parameterIsThisKeyword = parameterIsThisKeyword; + function isThisIdentifier(node) { + return node && node.kind === 69 && identifierIsThisKeyword(node); + } + ts.isThisIdentifier = isThisIdentifier; + function identifierIsThisKeyword(id) { + return id.originalKeywordKind === 97; + } + ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { var firstAccessor; var secondAccessor; @@ -7971,14 +9114,6 @@ var ts; return symbol && symbol.valueDeclaration && hasModifier(symbol.valueDeclaration, 512) ? symbol.valueDeclaration.localSymbol : undefined; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; - function hasJavaScriptFileExtension(fileName) { - return ts.forEach(ts.supportedJavascriptExtensions, function (extension) { return ts.fileExtensionIs(fileName, extension); }); - } - ts.hasJavaScriptFileExtension = hasJavaScriptFileExtension; - function hasTypeScriptFileExtension(fileName) { - return ts.forEach(ts.supportedTypeScriptExtensions, function (extension) { return ts.fileExtensionIs(fileName, extension); }); - } - ts.hasTypeScriptFileExtension = hasTypeScriptFileExtension; function tryExtractTypeScriptExtension(fileName) { return ts.find(ts.supportedTypescriptExtensionsForExtractExtension, function (extension) { return ts.fileExtensionIs(fileName, extension); }); } @@ -8069,12 +9204,6 @@ var ts; return result; } ts.convertToBase64 = convertToBase64; - function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) { - return !ts.isRootedDiskPath(absoluteOrRelativePath) - ? absoluteOrRelativePath - : ts.getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, false); - } - ts.convertToRelativePath = convertToRelativePath; var carriageReturnLineFeed = "\r\n"; var lineFeed = "\n"; function getNewLineCharacter(options) { @@ -8163,9 +9292,9 @@ var ts; if (syntaxKindCache[kind]) { return syntaxKindCache[kind]; } - for (var name_9 in syntaxKindEnum) { - if (syntaxKindEnum[name_9] === kind) { - return syntaxKindCache[kind] = kind.toString() + " (" + name_9 + ")"; + for (var name_10 in syntaxKindEnum) { + if (syntaxKindEnum[name_10] === kind) { + return syntaxKindCache[kind] = kind.toString() + " (" + name_10 + ")"; } } } @@ -8175,7 +9304,7 @@ var ts; } ts.formatSyntaxKind = formatSyntaxKind; function movePos(pos, value) { - return positionIsSynthesized(pos) ? -1 : pos + value; + return ts.positionIsSynthesized(pos) ? -1 : pos + value; } ts.movePos = movePos; function createRange(pos, end) { @@ -8244,7 +9373,7 @@ var ts; } ts.positionsAreOnSameLine = positionsAreOnSameLine; function getStartPositionOfRange(range, sourceFile) { - return positionIsSynthesized(range.pos) ? -1 : ts.skipTrivia(sourceFile.text, range.pos); + return ts.positionIsSynthesized(range.pos) ? -1 : ts.skipTrivia(sourceFile.text, range.pos); } ts.getStartPositionOfRange = getStartPositionOfRange; function collectExternalModuleInfo(sourceFile, resolver) { @@ -8281,8 +9410,8 @@ var ts; else { for (var _b = 0, _c = node.exportClause.elements; _b < _c.length; _b++) { var specifier = _c[_b]; - var name_10 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_10] || (exportSpecifiers[name_10] = [])).push(specifier); + var name_11 = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[name_11] || (exportSpecifiers[name_11] = [])).push(specifier); } } break; @@ -8344,15 +9473,16 @@ var ts; return 11 <= kind && kind <= 14; } ts.isTemplateLiteralKind = isTemplateLiteralKind; - function isTemplateLiteralFragmentKind(kind) { - return kind === 12 - || kind === 13 + function isTemplateHead(node) { + return node.kind === 12; + } + ts.isTemplateHead = isTemplateHead; + function isTemplateMiddleOrTemplateTail(node) { + var kind = node.kind; + return kind === 13 || kind === 14; } - function isTemplateLiteralFragment(node) { - return isTemplateLiteralFragmentKind(node.kind); - } - ts.isTemplateLiteralFragment = isTemplateLiteralFragment; + ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; function isIdentifier(node) { return node.kind === 69; } @@ -8491,12 +9621,12 @@ var ts; return node.kind === 174; } ts.isCallExpression = isCallExpression; - function isTemplate(node) { + function isTemplateLiteral(node) { var kind = node.kind; return kind === 189 || kind === 11; } - ts.isTemplate = isTemplate; + ts.isTemplateLiteral = isTemplateLiteral; function isSpreadElementExpression(node) { return node.kind === 191; } @@ -8827,7 +9957,6 @@ var ts; } ts.isWatchSet = isWatchSet; })(ts || (ts = {})); -var ts; (function (ts) { function getDefaultLibFileName(options) { return options.target === 2 ? "lib.es6.d.ts" : "lib.d.ts"; @@ -9062,7 +10191,7 @@ var ts; ts.createSynthesizedNodeArray = createSynthesizedNodeArray; function getSynthesizedClone(node) { var clone = createNode(node.kind, undefined, node.flags); - clone.original = node; + setOriginalNode(clone, node); for (var key in node) { if (clone.hasOwnProperty(key) || !node.hasOwnProperty(key)) { continue; @@ -9094,7 +10223,7 @@ var ts; node.text = value; return node; } - else { + else if (value) { var node = createNode(9, location, undefined); node.textSourceNode = value; node.text = value.text; @@ -9381,7 +10510,7 @@ var ts; function createPropertyAccess(expression, name, location, flags) { var node = createNode(172, location, flags); node.expression = parenthesizeForAccess(expression); - node.emitFlags = 1048576; + (node.emitNode || (node.emitNode = {})).flags |= 1048576; node.name = typeof name === "string" ? createIdentifier(name) : name; return node; } @@ -9389,7 +10518,7 @@ var ts; function updatePropertyAccess(node, expression, name) { if (node.expression !== expression || node.name !== name) { var propertyAccess = createPropertyAccess(expression, name, node, node.flags); - propertyAccess.emitFlags = node.emitFlags; + (propertyAccess.emitNode || (propertyAccess.emitNode = {})).flags = getEmitFlags(node); return updateNode(propertyAccess, node); } return node; @@ -9493,7 +10622,7 @@ var ts; node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; node.parameters = createNodeArray(parameters); node.type = type; - node.equalsGreaterThanToken = equalsGreaterThanToken || createNode(34); + node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(34); node.body = parenthesizeConciseBody(body); return node; } @@ -9586,7 +10715,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right, location) { - var operatorToken = typeof operator === "number" ? createSynthesizedNode(operator) : operator; + var operatorToken = typeof operator === "number" ? createToken(operator) : operator; var operatorKind = operatorToken.kind; var node = createNode(187, location); node.left = parenthesizeBinaryOperand(operatorKind, left, true, undefined); @@ -10486,13 +11615,13 @@ var ts; } else { var expression = ts.isIdentifier(memberName) ? createPropertyAccess(target, memberName, location) : createElementAccess(target, memberName, location); - expression.emitFlags |= 2048; + (expression.emitNode || (expression.emitNode = {})).flags |= 2048; return expression; } } ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName; function createRestParameter(name) { - return createParameterDeclaration(undefined, undefined, createSynthesizedNode(22), name, undefined, undefined, undefined); + return createParameterDeclaration(undefined, undefined, createToken(22), name, undefined, undefined, undefined); } ts.createRestParameter = createRestParameter; function createFunctionCall(func, thisArg, argumentsList, location) { @@ -10606,8 +11735,8 @@ var ts; } ts.createDecorateHelper = createDecorateHelper; function createAwaiterHelper(externalHelpersModuleName, hasLexicalArguments, promiseConstructor, body) { - var generatorFunc = createFunctionExpression(createNode(37), undefined, undefined, [], undefined, body); - generatorFunc.emitFlags |= 2097152; + var generatorFunc = createFunctionExpression(createToken(37), undefined, undefined, [], undefined, body); + (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 2097152; return createCall(createHelperName(externalHelpersModuleName, "__awaiter"), undefined, [ createThis(), hasLexicalArguments ? createIdentifier("arguments") : createVoidZero(), @@ -10834,7 +11963,7 @@ var ts; target.push(startOnNewLine(createStatement(createLiteral("use strict")))); foundUseStrict = true; } - if (statement.emitFlags & 8388608) { + if (getEmitFlags(statement) & 8388608) { target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); } else { @@ -10846,6 +11975,28 @@ var ts; return statementOffset; } ts.addPrologueDirectives = addPrologueDirectives; + function ensureUseStrict(node) { + var foundUseStrict = false; + for (var _i = 0, _a = node.statements; _i < _a.length; _i++) { + var statement = _a[_i]; + if (ts.isPrologueDirective(statement)) { + if (isUseStrictPrologue(statement)) { + foundUseStrict = true; + break; + } + } + else { + break; + } + } + if (!foundUseStrict) { + var statements = []; + statements.push(startOnNewLine(createStatement(createLiteral("use strict")))); + return updateSourceFileNode(node, statements.concat(node.statements)); + } + return node; + } + ts.ensureUseStrict = ensureUseStrict; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = skipPartiallyEmittedExpressions(operand); if (skipped.kind === 178) { @@ -11085,17 +12236,112 @@ var ts; function setOriginalNode(node, original) { node.original = original; if (original) { - var emitFlags = original.emitFlags, commentRange = original.commentRange, sourceMapRange = original.sourceMapRange; - if (emitFlags) - node.emitFlags = emitFlags; - if (commentRange) - node.commentRange = commentRange; - if (sourceMapRange) - node.sourceMapRange = sourceMapRange; + var emitNode = original.emitNode; + if (emitNode) + node.emitNode = mergeEmitNode(emitNode, node.emitNode); } return node; } ts.setOriginalNode = setOriginalNode; + function mergeEmitNode(sourceEmitNode, destEmitNode) { + var flags = sourceEmitNode.flags, commentRange = sourceEmitNode.commentRange, sourceMapRange = sourceEmitNode.sourceMapRange, tokenSourceMapRanges = sourceEmitNode.tokenSourceMapRanges; + if (!destEmitNode && (flags || commentRange || sourceMapRange || tokenSourceMapRanges)) + destEmitNode = {}; + if (flags) + destEmitNode.flags = flags; + if (commentRange) + destEmitNode.commentRange = commentRange; + if (sourceMapRange) + destEmitNode.sourceMapRange = sourceMapRange; + if (tokenSourceMapRanges) + destEmitNode.tokenSourceMapRanges = mergeTokenSourceMapRanges(tokenSourceMapRanges, destEmitNode.tokenSourceMapRanges); + return destEmitNode; + } + function mergeTokenSourceMapRanges(sourceRanges, destRanges) { + if (!destRanges) + destRanges = ts.createMap(); + ts.copyProperties(sourceRanges, destRanges); + return destRanges; + } + function disposeEmitNodes(sourceFile) { + sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(sourceFile)); + var emitNode = sourceFile && sourceFile.emitNode; + var annotatedNodes = emitNode && emitNode.annotatedNodes; + if (annotatedNodes) { + for (var _i = 0, annotatedNodes_1 = annotatedNodes; _i < annotatedNodes_1.length; _i++) { + var node = annotatedNodes_1[_i]; + node.emitNode = undefined; + } + } + } + ts.disposeEmitNodes = disposeEmitNodes; + function getOrCreateEmitNode(node) { + if (!node.emitNode) { + if (ts.isParseTreeNode(node)) { + if (node.kind === 256) { + return node.emitNode = { annotatedNodes: [node] }; + } + var sourceFile = ts.getSourceFileOfNode(node); + getOrCreateEmitNode(sourceFile).annotatedNodes.push(node); + } + node.emitNode = {}; + } + return node.emitNode; + } + function getEmitFlags(node) { + var emitNode = node.emitNode; + return emitNode && emitNode.flags; + } + ts.getEmitFlags = getEmitFlags; + function setEmitFlags(node, emitFlags) { + getOrCreateEmitNode(node).flags = emitFlags; + return node; + } + ts.setEmitFlags = setEmitFlags; + function setSourceMapRange(node, range) { + getOrCreateEmitNode(node).sourceMapRange = range; + return node; + } + ts.setSourceMapRange = setSourceMapRange; + function setTokenSourceMapRange(node, token, range) { + var emitNode = getOrCreateEmitNode(node); + var tokenSourceMapRanges = emitNode.tokenSourceMapRanges || (emitNode.tokenSourceMapRanges = ts.createMap()); + tokenSourceMapRanges[token] = range; + return node; + } + ts.setTokenSourceMapRange = setTokenSourceMapRange; + function setCommentRange(node, range) { + getOrCreateEmitNode(node).commentRange = range; + return node; + } + ts.setCommentRange = setCommentRange; + function getCommentRange(node) { + var emitNode = node.emitNode; + return (emitNode && emitNode.commentRange) || node; + } + ts.getCommentRange = getCommentRange; + function getSourceMapRange(node) { + var emitNode = node.emitNode; + return (emitNode && emitNode.sourceMapRange) || node; + } + ts.getSourceMapRange = getSourceMapRange; + function getTokenSourceMapRange(node, token) { + var emitNode = node.emitNode; + var tokenSourceMapRanges = emitNode && emitNode.tokenSourceMapRanges; + return tokenSourceMapRanges && tokenSourceMapRanges[token]; + } + ts.getTokenSourceMapRange = getTokenSourceMapRange; + function getConstantValue(node) { + var emitNode = node.emitNode; + return emitNode && emitNode.constantValue; + } + ts.getConstantValue = getConstantValue; + function setConstantValue(node, value) { + var emitNode = getOrCreateEmitNode(node); + emitNode.constantValue = value; + return node; + } + ts.setConstantValue = setConstantValue; function setTextRange(node, location) { if (location) { node.pos = location.pos; @@ -11122,8 +12368,8 @@ var ts; function getLocalNameForExternalImport(node, sourceFile) { var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); if (namespaceDeclaration && !ts.isDefaultImport(node)) { - var name_11 = namespaceDeclaration.name; - return ts.isGeneratedIdentifier(name_11) ? name_11 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); + var name_12 = namespaceDeclaration.name; + return ts.isGeneratedIdentifier(name_12) ? name_12 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); } if (node.kind === 230 && node.importClause) { return getGeneratedNameForNode(node); @@ -12205,7 +13451,7 @@ var ts; case 16: return token() === 18 || token() === 20; case 18: - return token() === 27 || token() === 17; + return token() !== 24; case 20: return token() === 15 || token() === 16; case 13: @@ -12533,7 +13779,7 @@ var ts; } function parseTemplateExpression() { var template = createNode(189); - template.head = parseTemplateLiteralFragment(); + template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 12, "Template head has wrong token kind"); var templateSpans = createNodeArray(); do { @@ -12549,7 +13795,7 @@ var ts; var literal; if (token() === 16) { reScanTemplateToken(); - literal = parseTemplateLiteralFragment(); + literal = parseTemplateMiddleOrTemplateTail(); } else { literal = parseExpectedToken(14, false, ts.Diagnostics._0_expected, ts.tokenToString(16)); @@ -12560,8 +13806,15 @@ var ts; function parseLiteralNode(internName) { return parseLiteralLikeNode(token(), internName); } - function parseTemplateLiteralFragment() { - return parseLiteralLikeNode(token(), false); + function parseTemplateHead() { + var fragment = parseLiteralLikeNode(token(), false); + ts.Debug.assert(fragment.kind === 12, "Template head has wrong token kind"); + return fragment; + } + function parseTemplateMiddleOrTemplateTail() { + var fragment = parseLiteralLikeNode(token(), false); + ts.Debug.assert(fragment.kind === 13 || fragment.kind === 14, "Template fragment has wrong token kind"); + return fragment; } function parseLiteralLikeNode(kind, internName) { var node = createNode(kind); @@ -14822,8 +16075,8 @@ var ts; return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { - var name_12 = createMissingNode(69, true, ts.Diagnostics.Declaration_expected); - return parsePropertyDeclaration(fullStart, decorators, modifiers, name_12, undefined); + var name_13 = createMissingNode(69, true, ts.Diagnostics.Declaration_expected); + return parsePropertyDeclaration(fullStart, decorators, modifiers, name_13, undefined); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } @@ -14909,7 +16162,7 @@ var ts; parseExpected(56); node.type = parseType(); parseSemicolon(); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseEnumMember() { var node = createNode(255, scanner.getStartPos()); @@ -15847,8 +17100,8 @@ var ts; if (typeExpression.type.kind === 267) { var jsDocTypeReference = typeExpression.type; if (jsDocTypeReference.name.kind === 69) { - var name_13 = jsDocTypeReference.name; - if (name_13.text === "Object") { + var name_14 = jsDocTypeReference.name; + if (name_14.text === "Object") { typedefTag.jsDocTypeLiteral = scanChildTags(); } } @@ -15934,14 +17187,14 @@ var ts; } var typeParameters = createNodeArray(); while (true) { - var name_14 = parseJSDocIdentifierName(); + var name_15 = parseJSDocIdentifierName(); skipWhitespace(); - if (!name_14) { + if (!name_15) { parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(141, name_14.pos); - typeParameter.name = name_14; + var typeParameter = createNode(141, name_15.pos); + typeParameter.name = name_15; finishNode(typeParameter); typeParameters.push(typeParameter); if (token() === 24) { @@ -16344,7 +17597,7 @@ var ts; file = f; options = opts; languageVersion = ts.getEmitScriptTarget(options); - inStrictMode = !!file.externalModuleIndicator; + inStrictMode = bindInStrictMode(file, opts); classifiableNames = ts.createMap(); symbolCount = 0; skipTransformFlagAggregation = ts.isDeclarationFile(file); @@ -16374,6 +17627,14 @@ var ts; subtreeTransformFlags = 0; } return bindSourceFile; + function bindInStrictMode(file, opts) { + if (opts.alwaysStrict && !ts.isDeclarationFile(file)) { + return true; + } + else { + return !!file.externalModuleIndicator; + } + } function createSymbol(flags, name) { symbolCount++; return new Symbol(flags, name); @@ -16492,11 +17753,17 @@ var ts; var message_1 = symbol.flags & 2 ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; - ts.forEach(symbol.declarations, function (declaration) { - if (ts.hasModifier(declaration, 512)) { + if (symbol.declarations && symbol.declarations.length) { + if (isDefaultExport) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } - }); + else { + if (symbol.declarations && symbol.declarations.length && + (isDefaultExport || (node.kind === 235 && !node.isExportEquals))) { + message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; + } + } + } ts.forEach(symbol.declarations, function (declaration) { file.bindDiagnostics.push(ts.createDiagnosticForNode(declaration.name || declaration, message_1, getDisplayName(declaration))); }); @@ -16561,7 +17828,7 @@ var ts; } else { currentFlow = { flags: 2 }; - if (containerFlags & 16) { + if (containerFlags & (16 | 128)) { currentFlow.container = node; } currentReturnTarget = undefined; @@ -17016,7 +18283,9 @@ var ts; currentFlow = preTryFlow; bind(node.finallyBlock); } - currentFlow = finishFlowLabel(postFinallyLabel); + if (!node.finallyBlock || !(currentFlow.flags & 1)) { + currentFlow = finishFlowLabel(postFinallyLabel); + } } function bindSwitchStatement(node) { var postSwitchLabel = createBranchLabel(); @@ -17149,7 +18418,7 @@ var ts; } else { ts.forEachChild(node, bind); - if (node.operator === 57 || node.operator === 42) { + if (node.operator === 41 || node.operator === 42) { bindAssignmentTargetFlow(node.operand); } } @@ -17248,9 +18517,12 @@ var ts; return 1 | 32; case 256: return 1 | 4 | 32; + case 147: + if (ts.isObjectLiteralOrClassExpressionMethod(node)) { + return 1 | 4 | 32 | 8 | 128; + } case 148: case 220: - case 147: case 146: case 149: case 150: @@ -17782,7 +19054,7 @@ var ts; var flags = node.kind === 235 && ts.exportAssignmentIsAlias(node) ? 8388608 : 4; - declareSymbol(container.symbol.exports, container.symbol, node, flags, 0 | 8388608); + declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 | 8388608 | 32 | 16); } } function bindNamespaceExportDeclaration(node) { @@ -17794,12 +19066,12 @@ var ts; return; } else { - var parent_6 = node.parent; - if (!ts.isExternalModule(parent_6)) { + var parent_7 = node.parent; + if (!ts.isExternalModule(parent_7)) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_module_files)); return; } - if (!parent_6.isDeclarationFile) { + if (!parent_7.isDeclarationFile) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_declaration_files)); return; } @@ -17979,6 +19251,9 @@ var ts; emitFlags |= 2048; } } + if (currentFlow && ts.isObjectLiteralOrClassExpressionMethod(node)) { + node.flowNode = currentFlow; + } return ts.hasDynamicName(node) ? bindAnonymousDeclaration(node, symbolFlags, "__computed") : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); @@ -18117,8 +19392,7 @@ var ts; if (node.questionToken) { transformFlags |= 3; } - if (subtreeFlags & 2048 - || (name && ts.isIdentifier(name) && name.originalKeywordKind === 97)) { + if (subtreeFlags & 2048 || ts.isThisIdentifier(name)) { transformFlags |= 3; } if (modifierFlags & 92) { @@ -18220,7 +19494,7 @@ var ts; || (subtreeFlags & 2048)) { transformFlags |= 3; } - if (asteriskToken && node.emitFlags & 2097152) { + if (asteriskToken && ts.getEmitFlags(node) & 2097152) { transformFlags |= 1536; } node.transformFlags = transformFlags | 536870912; @@ -18265,7 +19539,7 @@ var ts; if (subtreeFlags & 81920) { transformFlags |= 192; } - if (asteriskToken && node.emitFlags & 2097152) { + if (asteriskToken && ts.getEmitFlags(node) & 2097152) { transformFlags |= 1536; } } @@ -18282,7 +19556,7 @@ var ts; if (subtreeFlags & 81920) { transformFlags |= 192; } - if (asteriskToken && node.emitFlags & 2097152) { + if (asteriskToken && ts.getEmitFlags(node) & 2097152) { transformFlags |= 1536; } node.transformFlags = transformFlags | 536870912; @@ -18618,6 +19892,7 @@ var ts; var unknownSymbol = createSymbol(4 | 67108864, "unknown"); var resolvingSymbol = createSymbol(67108864, "__resolving__"); var anyType = createIntrinsicType(1, "any"); + var autoType = createIntrinsicType(1, "any"); var unknownType = createIntrinsicType(1, "unknown"); var undefinedType = createIntrinsicType(2048, "undefined"); var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(2048 | 33554432, "undefined"); @@ -19175,7 +20450,7 @@ var ts; if (result && isInExternalModule && (meaning & 107455) === 107455) { var decls = result.declarations; if (decls && decls.length === 1 && decls[0].kind === 228) { - error(errorLocation, ts.Diagnostics.Identifier_0_must_be_imported_from_a_module, name); + error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } } @@ -19335,28 +20610,28 @@ var ts; var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); if (targetSymbol) { - var name_15 = specifier.propertyName || specifier.name; - if (name_15.text) { + var name_16 = specifier.propertyName || specifier.name; + if (name_16.text) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { return moduleSymbol; } var symbolFromVariable = void 0; if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports["export="]) { - symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name_15.text); + symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name_16.text); } else { - symbolFromVariable = getPropertyOfVariable(targetSymbol, name_15.text); + symbolFromVariable = getPropertyOfVariable(targetSymbol, name_16.text); } symbolFromVariable = resolveSymbol(symbolFromVariable); - var symbolFromModule = getExportOfModule(targetSymbol, name_15.text); - if (!symbolFromModule && allowSyntheticDefaultImports && name_15.text === "default") { + var symbolFromModule = getExportOfModule(targetSymbol, name_16.text); + if (!symbolFromModule && allowSyntheticDefaultImports && name_16.text === "default") { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol); } var symbol = symbolFromModule && symbolFromVariable ? combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : symbolFromModule || symbolFromVariable; if (!symbol) { - error(name_15, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_15)); + error(name_16, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_16)); } return symbol; } @@ -19593,6 +20868,7 @@ var ts; } function getExportsForModule(moduleSymbol) { var visitedSymbols = []; + moduleSymbol = resolveExternalModuleSymbol(moduleSymbol); return visit(moduleSymbol) || moduleSymbol.exports; function visit(symbol) { if (!(symbol && symbol.flags & 1952 && !ts.contains(visitedSymbols, symbol))) { @@ -20077,9 +21353,9 @@ var ts; var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & 2)); if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { - var parent_7 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); - if (parent_7) { - walkSymbol(parent_7, getQualifiedLeftMeaning(meaning), false); + var parent_8 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent_8) { + walkSymbol(parent_8, getQualifiedLeftMeaning(meaning), false); } } if (accessibleSymbolChain) { @@ -20114,7 +21390,7 @@ var ts; ? "any" : type.intrinsicName); } - else if (type.flags & 268435456) { + else if (type.flags & 16384 && type.isThisType) { if (inObjectTypeLiteral) { writer.reportInaccessibleThisError(); } @@ -20131,7 +21407,7 @@ var ts; else if (type.flags & (32768 | 65536 | 16 | 16384)) { buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 793064, 0, nextFlags); } - else if (!(flags & 512) && type.flags & (2097152 | 1572864) && type.aliasSymbol && + else if (!(flags & 512) && ((type.flags & 2097152 && !type.target) || type.flags & 1572864) && type.aliasSymbol && isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, 793064, false).accessibility === 0) { var typeArguments = type.aliasTypeArguments; writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments.length : 0, nextFlags); @@ -20201,12 +21477,12 @@ var ts; var length_1 = outerTypeParameters.length; while (i < length_1) { var start = i; - var parent_8 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + var parent_9 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_8); + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_9); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_8, typeArguments, start, i, flags); + writeSymbolTypeReference(parent_9, typeArguments, start, i, flags); writePunctuation(writer, 21); } } @@ -20595,12 +21871,12 @@ var ts; if (ts.isExternalModuleAugmentation(node)) { return true; } - var parent_9 = getDeclarationContainer(node); + var parent_10 = getDeclarationContainer(node); if (!(ts.getCombinedModifierFlags(node) & 1) && - !(node.kind !== 229 && parent_9.kind !== 256 && ts.isInAmbientContext(parent_9))) { - return isGlobalSourceFile(parent_9); + !(node.kind !== 229 && parent_10.kind !== 256 && ts.isInAmbientContext(parent_10))) { + return isGlobalSourceFile(parent_10); } - return isDeclarationVisible(parent_9); + return isDeclarationVisible(parent_10); case 145: case 144: case 149: @@ -20787,19 +22063,19 @@ var ts; } var type; if (pattern.kind === 167) { - var name_16 = declaration.propertyName || declaration.name; - if (isComputedNonLiteralName(name_16)) { + var name_17 = declaration.propertyName || declaration.name; + if (isComputedNonLiteralName(name_17)) { return anyType; } if (declaration.initializer) { getContextualType(declaration.initializer); } - var text = getTextOfPropertyName(name_16); + var text = getTextOfPropertyName(name_17); type = getTypeOfPropertyOfType(parentType, text) || isNumericLiteralName(text) && getIndexTypeOfType(parentType, 1) || getIndexTypeOfType(parentType, 0); if (!type) { - error(name_16, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_16)); + error(name_17, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_17)); return unknownType; } } @@ -20858,6 +22134,10 @@ var ts; } return undefined; } + function isAutoVariableInitializer(initializer) { + var expr = initializer && ts.skipParentheses(initializer); + return !expr || expr.kind === 93 || expr.kind === 69 && getResolvedSymbol(expr) === undefinedSymbol; + } function addOptionality(type, optional) { return strictNullChecks && optional ? includeFalsyTypes(type, 2048) : type; } @@ -20880,6 +22160,11 @@ var ts; if (declaration.type) { return addOptionality(getTypeFromTypeNode(declaration.type), declaration.questionToken && includeOptionality); } + if (declaration.kind === 218 && !ts.isBindingPattern(declaration.name) && + !(ts.getCombinedNodeFlags(declaration) & 2) && !(ts.getCombinedModifierFlags(declaration) & 1) && + !ts.isInAmbientContext(declaration) && isAutoVariableInitializer(declaration.initializer)) { + return autoType; + } if (declaration.kind === 142) { var func = declaration.parent; if (func.kind === 150 && !ts.hasDynamicName(func)) { @@ -20951,7 +22236,7 @@ var ts; result.pattern = pattern; } if (hasComputedProperties) { - result.flags |= 536870912; + result.isObjectLiteralPatternWithComputedProperties = true; } return result; } @@ -21420,7 +22705,8 @@ var ts; type.instantiations[getTypeListId(type.typeParameters)] = type; type.target = type; type.typeArguments = type.typeParameters; - type.thisType = createType(16384 | 268435456); + type.thisType = createType(16384); + type.thisType.isThisType = true; type.thisType.symbol = symbol; type.thisType.constraint = type; } @@ -21953,13 +23239,24 @@ var ts; var current = _a[_i]; for (var _b = 0, _c = getPropertiesOfType(current); _b < _c.length; _b++) { var prop = _c[_b]; - getPropertyOfUnionOrIntersectionType(type, prop.name); + getUnionOrIntersectionProperty(type, prop.name); } if (type.flags & 524288) { break; } } - return type.resolvedProperties ? symbolsToArray(type.resolvedProperties) : emptyArray; + var props = type.resolvedProperties; + if (props) { + var result = []; + for (var key in props) { + var prop = props[key]; + if (!(prop.flags & 268435456 && prop.isPartial)) { + result.push(prop); + } + } + return result; + } + return emptyArray; } function getPropertiesOfType(type) { type = getApparentType(type); @@ -21998,6 +23295,7 @@ var ts; var props; var commonFlags = (containingType.flags & 1048576) ? 536870912 : 0; var isReadonly = false; + var isPartial = false; for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { var current = types_2[_i]; var type = getApparentType(current); @@ -22016,20 +23314,20 @@ var ts; } } else if (containingType.flags & 524288) { - return undefined; + isPartial = true; } } } if (!props) { return undefined; } - if (props.length === 1) { + if (props.length === 1 && !isPartial) { return props[0]; } var propTypes = []; var declarations = []; var commonType = undefined; - var hasCommonType = true; + var hasNonUniformType = false; for (var _a = 0, props_1 = props; _a < props_1.length; _a++) { var prop = props_1[_a]; if (prop.declarations) { @@ -22040,22 +23338,20 @@ var ts; commonType = type; } else if (type !== commonType) { - hasCommonType = false; + hasNonUniformType = true; } - propTypes.push(getTypeOfSymbol(prop)); + propTypes.push(type); } - var result = createSymbol(4 | - 67108864 | - 268435456 | - commonFlags, name); + var result = createSymbol(4 | 67108864 | 268435456 | commonFlags, name); result.containingType = containingType; - result.hasCommonType = hasCommonType; + result.hasNonUniformType = hasNonUniformType; + result.isPartial = isPartial; result.declarations = declarations; result.isReadonly = isReadonly; result.type = containingType.flags & 524288 ? getUnionType(propTypes) : getIntersectionType(propTypes); return result; } - function getPropertyOfUnionOrIntersectionType(type, name) { + function getUnionOrIntersectionProperty(type, name) { var properties = type.resolvedProperties || (type.resolvedProperties = ts.createMap()); var property = properties[name]; if (!property) { @@ -22066,6 +23362,10 @@ var ts; } return property; } + function getPropertyOfUnionOrIntersectionType(type, name) { + var property = getUnionOrIntersectionProperty(type, name); + return property && !(property.flags & 268435456 && property.isPartial) ? property : undefined; + } function getPropertyOfType(type, name) { type = getApparentType(type); if (type.flags & 2588672) { @@ -22438,7 +23738,7 @@ var ts; } function hasConstraintReferenceTo(type, target) { var checked; - while (type && !(type.flags & 268435456) && type.flags & 16384 && !ts.contains(checked, type)) { + while (type && type.flags & 16384 && !(type.isThisType) && !ts.contains(checked, type)) { if (type === target) { return true; } @@ -22722,7 +24022,8 @@ var ts; type.instantiations[getTypeListId(type.typeParameters)] = type; type.target = type; type.typeArguments = type.typeParameters; - type.thisType = createType(16384 | 268435456); + type.thisType = createType(16384); + type.thisType.isThisType = true; type.thisType.constraint = type; type.declaredProperties = properties; type.declaredCallSignatures = emptyArray; @@ -22821,7 +24122,24 @@ var ts; } return false; } + function isSetOfLiteralsFromSameEnum(types) { + var first = types[0]; + if (first.flags & 256) { + var firstEnum = getParentOfSymbol(first.symbol); + for (var i = 1; i < types.length; i++) { + var other = types[i]; + if (!(other.flags & 256) || (firstEnum !== getParentOfSymbol(other.symbol))) { + return false; + } + } + return true; + } + return false; + } function removeSubtypes(types) { + if (types.length === 0 || isSetOfLiteralsFromSameEnum(types)) { + return; + } var i = types.length; while (i > 0) { i--; @@ -23796,7 +25114,8 @@ var ts; !t.numberIndexInfo; } function hasExcessProperties(source, target, reportErrors) { - if (!(target.flags & 536870912) && maybeTypeOfKind(target, 2588672)) { + if (maybeTypeOfKind(target, 2588672) && + (!(target.flags & 2588672) || !target.isObjectLiteralPatternWithComputedProperties)) { for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { var prop = _a[_i]; if (!isKnownProperty(target, prop.name)) { @@ -25001,17 +26320,10 @@ var ts; } function isDiscriminantProperty(type, name) { if (type && type.flags & 524288) { - var prop = getPropertyOfType(type, name); - if (!prop) { - var filteredType = getTypeWithFacts(type, 4194304); - if (filteredType !== type && filteredType.flags & 524288) { - prop = getPropertyOfType(filteredType, name); - } - } + var prop = getUnionOrIntersectionProperty(type, name); if (prop && prop.flags & 268435456) { if (prop.isDiscriminantProperty === undefined) { - prop.isDiscriminantProperty = !prop.hasCommonType && - isLiteralType(getTypeOfSymbol(prop)); + prop.isDiscriminantProperty = prop.hasNonUniformType && isLiteralType(getTypeOfSymbol(prop)); } return prop.isDiscriminantProperty; } @@ -25288,6 +26600,23 @@ var ts; } return f(type) ? type : neverType; } + function mapType(type, f) { + return type.flags & 524288 ? getUnionType(ts.map(type.types, f)) : f(type); + } + function extractTypesOfKind(type, kind) { + return filterType(type, function (t) { return (t.flags & kind) !== 0; }); + } + function replacePrimitivesWithLiterals(typeWithPrimitives, typeWithLiterals) { + if (isTypeSubsetOf(stringType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 32) || + isTypeSubsetOf(numberType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 64)) { + return mapType(typeWithPrimitives, function (t) { + return t.flags & 2 ? extractTypesOfKind(typeWithLiterals, 2 | 32) : + t.flags & 4 ? extractTypesOfKind(typeWithLiterals, 4 | 64) : + t; + }); + } + return typeWithPrimitives; + } function isIncomplete(flowType) { return flowType.flags === 0; } @@ -25302,7 +26631,9 @@ var ts; if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 4178943)) { return declaredType; } - var initialType = assumeInitialized ? declaredType : includeFalsyTypes(declaredType, 2048); + var initialType = assumeInitialized ? declaredType : + declaredType === autoType ? undefinedType : + includeFalsyTypes(declaredType, 2048); var visitedFlowStart = visitedFlowCount; var result = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); visitedFlowCount = visitedFlowStart; @@ -25364,10 +26695,13 @@ var ts; function getTypeAtFlowAssignment(flow) { var node = flow.node; if (isMatchingReference(reference, node)) { - var isIncrementOrDecrement = node.parent.kind === 185 || node.parent.kind === 186; - return declaredType.flags & 524288 && !isIncrementOrDecrement ? - getAssignmentReducedType(declaredType, getInitialOrAssignedType(node)) : - declaredType; + if (node.parent.kind === 185 || node.parent.kind === 186) { + var flowType = getTypeAtFlowNode(flow.antecedent); + return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType)); + } + return declaredType === autoType ? getBaseTypeOfLiteralType(getInitialOrAssignedType(node)) : + declaredType.flags & 524288 ? getAssignmentReducedType(declaredType, getInitialOrAssignedType(node)) : + declaredType; } if (containsMatchingReference(reference, node)) { return declaredType; @@ -25553,12 +26887,12 @@ var ts; assumeTrue ? 16384 : 131072; return getTypeWithFacts(type, facts); } - if (type.flags & 2589191) { + if (type.flags & 2589185) { return type; } if (assumeTrue) { var narrowedType = filterType(type, function (t) { return areTypesComparable(t, valueType); }); - return narrowedType.flags & 8192 ? type : narrowedType; + return narrowedType.flags & 8192 ? type : replacePrimitivesWithLiterals(narrowedType, valueType); } if (isUnitType(valueType)) { var regularType_1 = getRegularTypeOfLiteralType(valueType); @@ -25596,7 +26930,8 @@ var ts; var clauseTypes = switchTypes.slice(clauseStart, clauseEnd); var hasDefaultClause = clauseStart === clauseEnd || ts.contains(clauseTypes, neverType); var discriminantType = getUnionType(clauseTypes); - var caseType = discriminantType.flags & 8192 ? neverType : filterType(type, function (t) { return isTypeComparableTo(discriminantType, t); }); + var caseType = discriminantType.flags & 8192 ? neverType : + replacePrimitivesWithLiterals(filterType(type, function (t) { return isTypeComparableTo(discriminantType, t); }), discriminantType); if (!hasDefaultClause) { return caseType; } @@ -25723,7 +27058,7 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } - if (ts.isExpression(location) && !ts.isAssignmentTarget(location)) { + if (ts.isPartOfExpression(location) && !ts.isAssignmentTarget(location)) { var type = checkExpression(location); if (getExportSymbolOfValueSymbolIfExported(getNodeLinks(location).resolvedSymbol) === symbol) { return type; @@ -25846,14 +27181,26 @@ var ts; var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; while (flowContainer !== declarationContainer && - (flowContainer.kind === 179 || flowContainer.kind === 180) && + (flowContainer.kind === 179 || + flowContainer.kind === 180 || + ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isReadonlySymbol(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } - var assumeInitialized = !strictNullChecks || (type.flags & 1) !== 0 || isParameter || - isOuterVariable || ts.isInAmbientContext(declaration); + var assumeInitialized = isParameter || isOuterVariable || + type !== autoType && (!strictNullChecks || (type.flags & 1) !== 0) || + ts.isInAmbientContext(declaration); var flowType = getFlowTypeOfReference(node, type, assumeInitialized, flowContainer); - if (!assumeInitialized && !(getFalsyFlags(type) & 2048) && getFalsyFlags(flowType) & 2048) { + if (type === autoType) { + if (flowType === autoType) { + if (compilerOptions.noImplicitAny) { + error(declaration.name, ts.Diagnostics.Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol)); + error(node, ts.Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(anyType)); + } + return anyType; + } + } + else if (!assumeInitialized && !(getFalsyFlags(type) & 2048) && getFalsyFlags(flowType) & 2048) { error(node, ts.Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol)); return type; } @@ -25938,7 +27285,7 @@ var ts; } } function findFirstSuperCall(n) { - if (ts.isSuperCallExpression(n)) { + if (ts.isSuperCall(n)) { return n; } else if (ts.isFunctionLike(n)) { @@ -26003,7 +27350,7 @@ var ts; captureLexicalThis(node, container); } if (ts.isFunctionLike(container) && - (!isInParameterInitializerBeforeContainingFunction(node) || getFunctionLikeThisParameter(container))) { + (!isInParameterInitializerBeforeContainingFunction(node) || ts.getThisParameter(container))) { if (container.kind === 179 && ts.isInJavaScriptFile(container.parent) && ts.getSpecialPropertyAssignmentKind(container.parent) === 3) { @@ -26222,11 +27569,11 @@ var ts; } if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; - var name_17 = declaration.propertyName || declaration.name; + var name_18 = declaration.propertyName || declaration.name; if (ts.isVariableLike(parentDeclaration) && parentDeclaration.type && - !ts.isBindingPattern(name_17)) { - var text = getTextOfPropertyName(name_17); + !ts.isBindingPattern(name_18)) { + var text = getTextOfPropertyName(name_18); if (text) { return getTypeOfPropertyOfType(getTypeFromTypeNode(parentDeclaration.type), text); } @@ -26663,7 +28010,8 @@ var ts; patternWithComputedProperties = true; } } - else if (contextualTypeHasPattern && !(contextualType.flags & 536870912)) { + else if (contextualTypeHasPattern && + !(contextualType.flags & 2588672 && contextualType.isObjectLiteralPatternWithComputedProperties)) { var impliedProp = getPropertyOfType(contextualType, member.name); if (impliedProp) { prop.flags |= impliedProp.flags & 536870912; @@ -26714,7 +28062,10 @@ var ts; var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, propertiesArray, 1) : undefined; var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 16777216; - result.flags |= 8388608 | 67108864 | freshObjectLiteralFlag | (typeFlags & 234881024) | (patternWithComputedProperties ? 536870912 : 0); + result.flags |= 8388608 | 67108864 | freshObjectLiteralFlag | (typeFlags & 234881024); + if (patternWithComputedProperties) { + result.isObjectLiteralPatternWithComputedProperties = true; + } if (inDestructuringPattern) { result.pattern = node; } @@ -27109,7 +28460,7 @@ var ts; if (flags & 32) { return true; } - if (type.flags & 268435456) { + if (type.flags & 16384 && type.isThisType) { type = getConstraintOfTypeParameter(type); } if (!(getTargetType(type).flags & (32768 | 65536) && hasBaseType(type, enclosingClass))) { @@ -27150,7 +28501,7 @@ var ts; var prop = getPropertyOfType(apparentType, right.text); if (!prop) { if (right.text && !checkAndReportErrorForExtendingInterface(node)) { - reportNonexistentProperty(right, type.flags & 268435456 ? apparentType : type); + reportNonexistentProperty(right, type.flags & 16384 && type.isThisType ? apparentType : type); } return unknownType; } @@ -27266,15 +28617,15 @@ var ts; return unknownType; } if (node.argumentExpression) { - var name_18 = getPropertyNameForIndexedAccess(node.argumentExpression, indexType); - if (name_18 !== undefined) { - var prop = getPropertyOfType(objectType, name_18); + var name_19 = getPropertyNameForIndexedAccess(node.argumentExpression, indexType); + if (name_19 !== undefined) { + var prop = getPropertyOfType(objectType, name_19); if (prop) { getNodeLinks(node).resolvedSymbol = prop; return getTypeOfSymbol(prop); } else if (isConstEnum) { - error(node.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_const_enum_1, name_18, symbolToString(objectType.symbol)); + error(node.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_const_enum_1, name_19, symbolToString(objectType.symbol)); return unknownType; } } @@ -27375,19 +28726,19 @@ var ts; for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var signature = signatures_2[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_10 = signature.declaration && signature.declaration.parent; + var parent_11 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_10 === lastParent) { + if (lastParent && parent_11 === lastParent) { index++; } else { - lastParent = parent_10; + lastParent = parent_11; index = cutoffIndex; } } else { index = cutoffIndex = result.length; - lastParent = parent_10; + lastParent = parent_11; } lastSymbol = symbol; if (signature.hasLiteralTypes) { @@ -28290,7 +29641,9 @@ var ts; if (!contextualSignature) { reportErrorsFromWidening(func, type); } - if (isUnitType(type) && !(contextualSignature && isLiteralContextualType(getReturnTypeOfSignature(contextualSignature)))) { + if (isUnitType(type) && + !(contextualSignature && + isLiteralContextualType(contextualSignature === getSignatureFromDeclaration(func) ? type : getReturnTypeOfSignature(contextualSignature)))) { type = getWidenedLiteralType(type); } var widenedType = getWidenedType(type); @@ -28440,7 +29793,7 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 147 && node.kind !== 146) { + if (produceDiagnostics && node.kind !== 147) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } @@ -28690,14 +30043,14 @@ var ts; } function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, contextualMapper) { if (property.kind === 253 || property.kind === 254) { - var name_19 = property.name; - if (name_19.kind === 140) { - checkComputedPropertyName(name_19); + var name_20 = property.name; + if (name_20.kind === 140) { + checkComputedPropertyName(name_20); } - if (isComputedNonLiteralName(name_19)) { + if (isComputedNonLiteralName(name_20)) { return undefined; } - var text = getTextOfPropertyName(name_19); + var text = getTextOfPropertyName(name_20); var type = isTypeAny(objectLiteralType) ? objectLiteralType : getTypeOfPropertyOfType(objectLiteralType, text) || @@ -28712,7 +30065,7 @@ var ts; } } else { - error(name_19, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_19)); + error(name_20, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_20)); } } else { @@ -29361,9 +30714,9 @@ var ts; else if (parameterName) { var hasReportedError = false; for (var _i = 0, _a = parent.parameters; _i < _a.length; _i++) { - var name_20 = _a[_i].name; - if (ts.isBindingPattern(name_20) && - checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_20, parameterName, typePredicate.parameterName)) { + var name_21 = _a[_i].name; + if (ts.isBindingPattern(name_21) && + checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_21, parameterName, typePredicate.parameterName)) { hasReportedError = true; break; } @@ -29383,9 +30736,9 @@ var ts; case 156: case 147: case 146: - var parent_11 = node.parent; - if (node === parent_11.type) { - return parent_11; + var parent_12 = node.parent; + if (node === parent_12.type) { + return parent_12; } } } @@ -29395,15 +30748,15 @@ var ts; if (ts.isOmittedExpression(element)) { continue; } - var name_21 = element.name; - if (name_21.kind === 69 && - name_21.text === predicateVariableName) { + var name_22 = element.name; + if (name_22.kind === 69 && + name_22.text === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name_21.kind === 168 || - name_21.kind === 167) { - if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_21, predicateVariableNode, predicateVariableName)) { + else if (name_22.kind === 168 || + name_22.kind === 167) { + if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_22, predicateVariableNode, predicateVariableName)) { return true; } } @@ -29596,7 +30949,7 @@ var ts; return n.name && containsSuperCall(n.name); } function containsSuperCall(n) { - if (ts.isSuperCallExpression(n)) { + if (ts.isSuperCall(n)) { return true; } else if (ts.isFunctionLike(n)) { @@ -29622,6 +30975,7 @@ var ts; } var containingClassDecl = node.parent; if (ts.getClassExtendsHeritageClauseElement(containingClassDecl)) { + captureLexicalThis(node.parent, containingClassDecl); var classExtendsNull = classDeclarationExtendsNull(containingClassDecl); var superCall = getSuperCallInConstructor(node); if (superCall) { @@ -29635,7 +30989,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 202 && ts.isSuperCallExpression(statement.expression)) { + if (statement.kind === 202 && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -30345,7 +31699,7 @@ var ts; var parameter = local.valueDeclaration; if (compilerOptions.noUnusedParameters && !ts.isParameterPropertyDeclaration(parameter) && - !parameterIsThisKeyword(parameter) && + !ts.parameterIsThisKeyword(parameter) && !parameterNameStartsWithUnderscore(parameter)) { error(local.valueDeclaration.name, ts.Diagnostics._0_is_declared_but_never_used, local.name); } @@ -30360,9 +31714,6 @@ var ts; } } } - function parameterIsThisKeyword(parameter) { - return parameter.name && parameter.name.originalKeywordKind === 97; - } function parameterNameStartsWithUnderscore(parameter) { return parameter.name && parameter.name.kind === 69 && parameter.name.text.charCodeAt(0) === 95; } @@ -30500,6 +31851,9 @@ var ts; } } function checkCollisionWithRequireExportsInGeneratedCode(node, name) { + if (modulekind >= ts.ModuleKind.ES6) { + return; + } if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } @@ -30547,8 +31901,8 @@ var ts; container.kind === 225 || container.kind === 256); if (!namesShareScope) { - var name_22 = symbolToString(localDeclarationSymbol); - error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_22, name_22); + var name_23 = symbolToString(localDeclarationSymbol); + error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_23, name_23); } } } @@ -30603,6 +31957,9 @@ var ts; } } } + function convertAutoToAny(type) { + return type === autoType ? anyType : type; + } function checkVariableLikeDeclaration(node) { checkDecorators(node); checkSourceElement(node.type); @@ -30616,12 +31973,12 @@ var ts; if (node.propertyName && node.propertyName.kind === 140) { checkComputedPropertyName(node.propertyName); } - var parent_12 = node.parent.parent; - var parentType = getTypeForBindingElementParent(parent_12); - var name_23 = node.propertyName || node.name; - var property = getPropertyOfType(parentType, getTextOfPropertyName(name_23)); - if (parent_12.initializer && property && getParentOfSymbol(property)) { - checkClassPropertyAccess(parent_12, parent_12.initializer, parentType, property); + var parent_13 = node.parent.parent; + var parentType = getTypeForBindingElementParent(parent_13); + var name_24 = node.propertyName || node.name; + var property = getPropertyOfType(parentType, getTextOfPropertyName(name_24)); + if (parent_13.initializer && property && getParentOfSymbol(property)) { + checkClassPropertyAccess(parent_13, parent_13.initializer, parentType, property); } } if (ts.isBindingPattern(node.name)) { @@ -30639,7 +31996,7 @@ var ts; return; } var symbol = getSymbolOfNode(node); - var type = getTypeOfVariableOrParameterOrProperty(symbol); + var type = convertAutoToAny(getTypeOfVariableOrParameterOrProperty(symbol)); if (node === symbol.valueDeclaration) { if (node.initializer && node.parent.parent.kind !== 207) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); @@ -30647,7 +32004,7 @@ var ts; } } else { - var declarationType = getWidenedTypeForVariableLikeDeclaration(node); + var declarationType = convertAutoToAny(getWidenedTypeForVariableLikeDeclaration(node)); if (type !== unknownType && declarationType !== unknownType && !isTypeIdenticalTo(type, declarationType)) { error(node.name, ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2, ts.declarationNameToString(node.name), typeToString(type), typeToString(declarationType)); } @@ -31022,7 +32379,12 @@ var ts; } } checkExpression(node.expression); - error(node.expression, ts.Diagnostics.All_symbols_within_a_with_block_will_be_resolved_to_any); + var sourceFile = ts.getSourceFileOfNode(node); + if (!hasParseDiagnostics(sourceFile)) { + var start = ts.getSpanOfTokenAtPosition(sourceFile, node.pos).start; + var end = node.statement.pos; + grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any); + } } function checkSwitchStatement(node) { checkGrammarStatementInAmbientContext(node); @@ -31741,9 +33103,11 @@ var ts; grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } } - checkCollisionWithCapturedThisVariable(node, node.name); - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); + if (ts.isIdentifier(node.name)) { + checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); + } checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); if (symbol.flags & 512 @@ -31818,9 +33182,9 @@ var ts; break; case 169: case 218: - var name_24 = node.name; - if (ts.isBindingPattern(name_24)) { - for (var _b = 0, _c = name_24.elements; _b < _c.length; _b++) { + var name_25 = node.name; + if (ts.isBindingPattern(name_25)) { + for (var _b = 0, _c = name_25.elements; _b < _c.length; _b++) { var el = _c[_b]; checkModuleAugmentationElement(el, isGlobalAugmentation); } @@ -31982,9 +33346,11 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - if (node.parent.kind !== 256 && node.parent.kind !== 226 && node.parent.kind !== 225) { - return grammarErrorOnFirstToken(node, errorMessage); + var isInAppropriateContext = node.parent.kind === 256 || node.parent.kind === 226 || node.parent.kind === 225; + if (!isInAppropriateContext) { + grammarErrorOnFirstToken(node, errorMessage); } + return !isInAppropriateContext; } function checkExportSpecifier(node) { checkAliasSymbol(node); @@ -32046,12 +33412,12 @@ var ts; error(declaration, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); } } - var exports = getExportsOfModule(moduleSymbol); - for (var id in exports) { + var exports_1 = getExportsOfModule(moduleSymbol); + for (var id in exports_1) { if (id === "__export") { continue; } - var _a = exports[id], declarations = _a.declarations, flags = _a.flags; + var _a = exports_1[id], declarations = _a.declarations, flags = _a.flags; if (flags & (1920 | 64 | 384)) { continue; } @@ -32071,7 +33437,8 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return declaration.kind !== 220 || !!declaration.body; + return (declaration.kind !== 220 && declaration.kind !== 147) || + !!declaration.body; } } function checkSourceElement(node) { @@ -32556,6 +33923,9 @@ var ts; node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } + if (ts.isInJavaScriptFile(node) && ts.isRequireCall(node.parent, false)) { + return resolveExternalModuleName(node, node); + } case 8: if (node.parent.kind === 173 && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); @@ -32670,9 +34040,9 @@ var ts; function getRootSymbols(symbol) { if (symbol.flags & 268435456) { var symbols_3 = []; - var name_25 = symbol.name; + var name_26 = symbol.name; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - var symbol = getPropertyOfType(t, name_25); + var symbol = getPropertyOfType(t, name_26); if (symbol) { symbols_3.push(symbol); } @@ -32979,9 +34349,9 @@ var ts; } var location = reference; if (startInDeclarationContainer) { - var parent_13 = reference.parent; - if (ts.isDeclaration(parent_13) && reference === parent_13.name) { - location = getDeclarationContainer(parent_13); + var parent_14 = reference.parent; + if (ts.isDeclaration(parent_14) && reference === parent_14.name) { + location = getDeclarationContainer(parent_14); } } return resolveName(location, reference.text, 107455 | 1048576 | 8388608, undefined, undefined); @@ -33090,9 +34460,9 @@ var ts; } var current = symbol; while (true) { - var parent_14 = getParentOfSymbol(current); - if (parent_14) { - current = parent_14; + var parent_15 = getParentOfSymbol(current); + if (parent_15) { + current = parent_15; } else { break; @@ -33211,26 +34581,26 @@ var ts; if (compilerOptions.importHelpers && firstFileRequestingExternalHelpers) { var helpersModule = resolveExternalModule(firstFileRequestingExternalHelpers, ts.externalHelpersModuleNameText, ts.Diagnostics.Cannot_find_module_0, undefined); if (helpersModule) { - var exports = helpersModule.exports; + var exports_2 = helpersModule.exports; if (requestedExternalEmitHelpers & 1024 && languageVersion < 2) { - verifyHelperSymbol(exports, "__extends", 107455); + verifyHelperSymbol(exports_2, "__extends", 107455); } if (requestedExternalEmitHelpers & 16384 && compilerOptions.jsx !== 1) { - verifyHelperSymbol(exports, "__assign", 107455); + verifyHelperSymbol(exports_2, "__assign", 107455); } if (requestedExternalEmitHelpers & 2048) { - verifyHelperSymbol(exports, "__decorate", 107455); + verifyHelperSymbol(exports_2, "__decorate", 107455); if (compilerOptions.emitDecoratorMetadata) { - verifyHelperSymbol(exports, "__metadata", 107455); + verifyHelperSymbol(exports_2, "__metadata", 107455); } } if (requestedExternalEmitHelpers & 4096) { - verifyHelperSymbol(exports, "__param", 107455); + verifyHelperSymbol(exports_2, "__param", 107455); } if (requestedExternalEmitHelpers & 8192) { - verifyHelperSymbol(exports, "__awaiter", 107455); + verifyHelperSymbol(exports_2, "__awaiter", 107455); if (languageVersion < 2) { - verifyHelperSymbol(exports, "__generator", 107455); + verifyHelperSymbol(exports_2, "__generator", 107455); } } } @@ -33652,8 +35022,8 @@ var ts; function checkGrammarForOmittedArgument(node, args) { if (args) { var sourceFile = ts.getSourceFileOfNode(node); - for (var _i = 0, args_2 = args; _i < args_2.length; _i++) { - var arg = args_2[_i]; + for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { + var arg = args_4[_i]; if (arg.kind === 193) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } @@ -33761,10 +35131,9 @@ var ts; var GetOrSetAccessor = GetAccessor | SetAccessor; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - var name_26 = prop.name; - if (prop.kind === 193 || - name_26.kind === 140) { - checkGrammarComputedPropertyName(name_26); + var name_27 = prop.name; + if (name_27.kind === 140) { + checkGrammarComputedPropertyName(name_27); } if (prop.kind === 254 && !inDestructuring && prop.objectAssignmentInitializer) { return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); @@ -33780,8 +35149,8 @@ var ts; var currentKind = void 0; if (prop.kind === 253 || prop.kind === 254) { checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_26.kind === 8) { - checkGrammarNumericLiteral(name_26); + if (name_27.kind === 8) { + checkGrammarNumericLiteral(name_27); } currentKind = Property; } @@ -33797,7 +35166,7 @@ var ts; else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - var effectiveName = ts.getPropertyNameForPropertyNameNode(name_26); + var effectiveName = ts.getPropertyNameForPropertyNameNode(name_27); if (effectiveName === undefined) { continue; } @@ -33807,18 +35176,18 @@ var ts; else { var existingKind = seen[effectiveName]; if (currentKind === Property && existingKind === Property) { - grammarErrorOnNode(name_26, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_26)); + grammarErrorOnNode(name_27, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_27)); } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { seen[effectiveName] = currentKind | existingKind; } else { - return grammarErrorOnNode(name_26, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name_27, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name_26, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name_27, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } @@ -33831,12 +35200,12 @@ var ts; continue; } var jsxAttr = attr; - var name_27 = jsxAttr.name; - if (!seen[name_27.text]) { - seen[name_27.text] = true; + var name_28 = jsxAttr.name; + if (!seen[name_28.text]) { + seen[name_28.text] = true; } else { - return grammarErrorOnNode(name_27, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + return grammarErrorOnNode(name_28, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; if (initializer && initializer.kind === 248 && !initializer.expression) { @@ -33919,17 +35288,8 @@ var ts; return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 149 ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 149 ? 1 : 2) && - accessor.parameters[0].name.kind === 69 && - accessor.parameters[0].name.originalKeywordKind === 97) { - return accessor.parameters[0]; - } - } - function getFunctionLikeThisParameter(func) { - if (func.parameters.length && - func.parameters[0].name.kind === 69 && - func.parameters[0].name.originalKeywordKind === 97) { - return func.parameters[0]; + if (accessor.parameters.length === (accessor.kind === 149 ? 1 : 2)) { + return ts.getThisParameter(accessor); } } function checkGrammarForNonSymbolComputedProperty(node, message) { @@ -34763,7 +36123,7 @@ var ts; case 175: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); case 176: - return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplate)); + return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); case 178: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); case 179: @@ -34787,7 +36147,7 @@ var ts; case 188: return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); case 189: - return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateLiteralFragment), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); + return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); case 190: return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); case 191: @@ -34797,7 +36157,7 @@ var ts; case 194: return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); case 197: - return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateLiteralFragment)); + return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); case 199: return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); case 200: @@ -35072,7 +36432,7 @@ var ts; return expression; function emitAssignment(name, value, location) { var expression = ts.createAssignment(name, value, location); - context.setNodeEmitFlags(expression, 2048); + ts.setEmitFlags(expression, 2048); ts.aggregateTransformFlags(expression); expressions.push(expression); } @@ -35089,7 +36449,7 @@ var ts; return declarations; function emitAssignment(name, value, location) { var declaration = ts.createVariableDeclaration(name, undefined, value, location); - context.setNodeEmitFlags(declaration, 2048); + ts.setEmitFlags(declaration, 2048); ts.aggregateTransformFlags(declaration); declarations.push(declaration); } @@ -35113,7 +36473,7 @@ var ts; } var declaration = ts.createVariableDeclaration(name, undefined, value, location); declaration.original = original; - context.setNodeEmitFlags(declaration, 2048); + ts.setEmitFlags(declaration, 2048); declarations.push(declaration); ts.aggregateTransformFlags(declaration); } @@ -35153,7 +36513,7 @@ var ts; function emitPendingAssignment(name, value, location, original) { var expression = ts.createAssignment(name, value, location); expression.original = original; - context.setNodeEmitFlags(expression, 2048); + ts.setEmitFlags(expression, 2048); pendingAssignments.push(expression); return expression; } @@ -35197,10 +36557,10 @@ var ts; emitArrayLiteralAssignment(target, value, location); } else { - var name_28 = ts.getMutableClone(target); - context.setSourceMapRange(name_28, target); - context.setCommentRange(name_28, target); - emitAssignment(name_28, value, location, undefined); + var name_29 = ts.getMutableClone(target); + ts.setSourceMapRange(name_29, target); + ts.setCommentRange(name_29, target); + emitAssignment(name_29, value, location, undefined); } } function emitObjectLiteralAssignment(target, value, location) { @@ -35314,7 +36674,7 @@ var ts; (function (ts) { var USE_NEW_TYPE_METADATA_FORMAT = false; function transformTypeScript(context) { - var getNodeEmitFlags = context.getNodeEmitFlags, setNodeEmitFlags = context.setNodeEmitFlags, setCommentRange = context.setCommentRange, setSourceMapRange = context.setSourceMapRange, startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); var compilerOptions = context.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); @@ -35323,10 +36683,13 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; + context.enableSubstitution(172); + context.enableSubstitution(173); var currentSourceFile; var currentNamespace; var currentNamespaceContainerName; var currentScope; + var currentScopeFirstDeclarationsOfName; var currentSourceFileExternalHelpersModuleName; var enabledSubstitutions; var classAliases; @@ -35334,12 +36697,19 @@ var ts; var currentSuperContainer; return transformSourceFile; function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } return ts.visitNode(node, visitor, ts.isSourceFile); } function saveStateAndInvoke(node, f) { var savedCurrentScope = currentScope; + var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName; onBeforeVisitNode(node); var visited = f(node); + if (currentScope !== savedCurrentScope) { + currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; + } currentScope = savedCurrentScope; return visited; } @@ -35493,11 +36863,22 @@ var ts; case 226: case 199: currentScope = node; + currentScopeFirstDeclarationsOfName = undefined; + break; + case 221: + case 220: + if (ts.hasModifier(node, 2)) { + break; + } + recordEmittedDeclarationInScope(node); break; } } function visitSourceFile(node) { currentSourceFile = node; + if (compilerOptions.alwaysStrict) { + node = ts.ensureUseStrict(node); + } if (node.flags & 31744 && compilerOptions.importHelpers && (ts.isExternalModule(node) || compilerOptions.isolatedModules)) { @@ -35519,7 +36900,7 @@ var ts; else { node = ts.visitEachChild(node, visitor, context); } - setNodeEmitFlags(node, 1 | node.emitFlags); + ts.setEmitFlags(node, 1 | ts.getEmitFlags(node)); return node; } function shouldEmitDecorateCallForClass(node) { @@ -35549,7 +36930,7 @@ var ts; var classDeclaration = ts.createClassDeclaration(undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, hasExtendsClause), node); ts.setOriginalNode(classDeclaration, node); if (staticProperties.length > 0) { - setNodeEmitFlags(classDeclaration, 1024 | getNodeEmitFlags(classDeclaration)); + ts.setEmitFlags(classDeclaration, 1024 | ts.getEmitFlags(classDeclaration)); } statements.push(classDeclaration); } @@ -35591,7 +36972,7 @@ var ts; var transformedClassExpression = ts.createVariableStatement(undefined, ts.createLetDeclarationList([ ts.createVariableDeclaration(classAlias || declaredName, undefined, classExpression) ]), location); - setCommentRange(transformedClassExpression, node); + ts.setCommentRange(transformedClassExpression, node); statements.push(ts.setOriginalNode(transformedClassExpression, node)); if (classAlias) { statements.push(ts.setOriginalNode(ts.createVariableStatement(undefined, ts.createLetDeclarationList([ @@ -35612,7 +36993,7 @@ var ts; enableSubstitutionForClassAliases(); classAliases[ts.getOriginalNodeId(node)] = ts.getSynthesizedClone(temp); } - setNodeEmitFlags(classExpression, 524288 | getNodeEmitFlags(classExpression)); + ts.setEmitFlags(classExpression, 524288 | ts.getEmitFlags(classExpression)); expressions.push(ts.startOnNewLine(ts.createAssignment(temp, classExpression))); ts.addRange(expressions, generateInitializedPropertyExpressions(node, staticProperties, temp)); expressions.push(ts.startOnNewLine(temp)); @@ -35673,7 +37054,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 202 && ts.isSuperCallExpression(statement.expression)) { + if (statement.kind === 202 && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -35692,9 +37073,9 @@ var ts; ts.Debug.assert(ts.isIdentifier(node.name)); var name = node.name; var propertyName = ts.getMutableClone(name); - setNodeEmitFlags(propertyName, 49152 | 1536); + ts.setEmitFlags(propertyName, 49152 | 1536); var localName = ts.getMutableClone(name); - setNodeEmitFlags(localName, 49152); + ts.setEmitFlags(localName, 49152); return ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createThis(), propertyName, node.name), localName), ts.moveRangePos(node, -1))); } function getInitializedProperties(node, isStatic) { @@ -35715,8 +37096,8 @@ var ts; for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) { var property = properties_7[_i]; var statement = ts.createStatement(transformInitializedProperty(node, property, receiver)); - setSourceMapRange(statement, ts.moveRangePastModifiers(property)); - setCommentRange(statement, property); + ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property)); + ts.setCommentRange(statement, property); statements.push(statement); } } @@ -35726,8 +37107,8 @@ var ts; var property = properties_8[_i]; var expression = transformInitializedProperty(node, property, receiver); expression.startsOnNewLine = true; - setSourceMapRange(expression, ts.moveRangePastModifiers(property)); - setCommentRange(expression, property); + ts.setSourceMapRange(expression, ts.moveRangePastModifiers(property)); + ts.setCommentRange(expression, property); expressions.push(expression); } return expressions; @@ -35868,7 +37249,7 @@ var ts; : ts.createNull() : undefined; var helper = ts.createDecorateHelper(currentSourceFileExternalHelpersModuleName, decoratorExpressions, prefix, memberName, descriptor, ts.moveRangePastDecorators(member)); - setNodeEmitFlags(helper, 49152); + ts.setEmitFlags(helper, 49152); return helper; } function addConstructorDecorationStatement(statements, node, decoratedClassAlias) { @@ -35886,12 +37267,12 @@ var ts; if (decoratedClassAlias) { var expression = ts.createAssignment(decoratedClassAlias, ts.createDecorateHelper(currentSourceFileExternalHelpersModuleName, decoratorExpressions, getDeclarationName(node))); var result = ts.createAssignment(getDeclarationName(node), expression, ts.moveRangePastDecorators(node)); - setNodeEmitFlags(result, 49152); + ts.setEmitFlags(result, 49152); return result; } else { var result = ts.createAssignment(getDeclarationName(node), ts.createDecorateHelper(currentSourceFileExternalHelpersModuleName, decoratorExpressions, getDeclarationName(node)), ts.moveRangePastDecorators(node)); - setNodeEmitFlags(result, 49152); + ts.setEmitFlags(result, 49152); return result; } } @@ -35905,7 +37286,7 @@ var ts; for (var _i = 0, decorators_1 = decorators; _i < decorators_1.length; _i++) { var decorator = decorators_1[_i]; var helper = ts.createParamHelper(currentSourceFileExternalHelpersModuleName, transformDecorator(decorator), parameterOffset, decorator.expression); - setNodeEmitFlags(helper, 49152); + ts.setEmitFlags(helper, 49152); expressions.push(helper); } } @@ -36070,10 +37451,33 @@ var ts; : ts.createIdentifier("Symbol"); case 155: return serializeTypeReferenceNode(node); + case 163: + case 162: + { + var unionOrIntersection = node; + var serializedUnion = void 0; + for (var _i = 0, _a = unionOrIntersection.types; _i < _a.length; _i++) { + var typeNode = _a[_i]; + var serializedIndividual = serializeTypeNode(typeNode); + if (serializedIndividual.kind !== 69) { + serializedUnion = undefined; + break; + } + if (serializedIndividual.text === "Object") { + return serializedIndividual; + } + if (serializedUnion && serializedUnion.text !== serializedIndividual.text) { + serializedUnion = undefined; + break; + } + serializedUnion = serializedIndividual; + } + if (serializedUnion) { + return serializedUnion; + } + } case 158: case 159: - case 162: - case 163: case 117: case 165: break; @@ -36117,14 +37521,14 @@ var ts; function serializeEntityNameAsExpression(node, useFallback) { switch (node.kind) { case 69: - var name_29 = ts.getMutableClone(node); - name_29.flags &= ~8; - name_29.original = undefined; - name_29.parent = currentScope; + var name_30 = ts.getMutableClone(node); + name_30.flags &= ~8; + name_30.original = undefined; + name_30.parent = currentScope; if (useFallback) { - return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_29), ts.createLiteral("undefined")), name_29); + return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_30), ts.createLiteral("undefined")), name_30); } - return name_29; + return name_30; case 139: return serializeQualifiedNameAsExpression(node, useFallback); } @@ -36194,8 +37598,8 @@ var ts; return undefined; } var method = ts.createMethod(undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, visitPropertyNameOfClassElement(node), undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); - setCommentRange(method, node); - setSourceMapRange(method, ts.moveRangePastDecorators(node)); + ts.setCommentRange(method, node); + ts.setSourceMapRange(method, ts.moveRangePastDecorators(node)); ts.setOriginalNode(method, node); return method; } @@ -36207,8 +37611,8 @@ var ts; return undefined; } var accessor = ts.createGetAccessor(undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, node.body ? ts.visitEachChild(node.body, visitor, context) : ts.createBlock([]), node); - setCommentRange(accessor, node); - setSourceMapRange(accessor, ts.moveRangePastDecorators(node)); + ts.setCommentRange(accessor, node); + ts.setSourceMapRange(accessor, ts.moveRangePastDecorators(node)); ts.setOriginalNode(accessor, node); return accessor; } @@ -36217,8 +37621,8 @@ var ts; return undefined; } var accessor = ts.createSetAccessor(undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitNodes(node.parameters, visitor, ts.isParameter), node.body ? ts.visitEachChild(node.body, visitor, context) : ts.createBlock([]), node); - setCommentRange(accessor, node); - setSourceMapRange(accessor, ts.moveRangePastDecorators(node)); + ts.setCommentRange(accessor, node); + ts.setSourceMapRange(accessor, ts.moveRangePastDecorators(node)); ts.setOriginalNode(accessor, node); return accessor; } @@ -36313,11 +37717,11 @@ var ts; if (languageVersion >= 2) { if (resolver.getNodeCheckFlags(node) & 4096) { enableSubstitutionForAsyncMethodsWithSuper(); - setNodeEmitFlags(block, 8); + ts.setEmitFlags(block, 8); } else if (resolver.getNodeCheckFlags(node) & 2048) { enableSubstitutionForAsyncMethodsWithSuper(); - setNodeEmitFlags(block, 4); + ts.setEmitFlags(block, 4); } } return block; @@ -36327,14 +37731,14 @@ var ts; } } function visitParameter(node) { - if (node.name && ts.isIdentifier(node.name) && node.name.originalKeywordKind === 97) { + if (ts.parameterIsThisKeyword(node)) { return undefined; } var parameter = ts.createParameterDeclaration(undefined, undefined, node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression), ts.moveRangePastModifiers(node)); ts.setOriginalNode(parameter, node); - setCommentRange(parameter, node); - setSourceMapRange(parameter, ts.moveRangePastModifiers(node)); - setNodeEmitFlags(parameter.name, 1024); + ts.setCommentRange(parameter, node); + ts.setSourceMapRange(parameter, ts.moveRangePastModifiers(node)); + ts.setEmitFlags(parameter.name, 1024); return parameter; } function visitVariableStatement(node) { @@ -36383,12 +37787,13 @@ var ts; || compilerOptions.isolatedModules; } function shouldEmitVarForEnumDeclaration(node) { - return !ts.hasModifier(node, 1) - || (isES6ExportedDeclaration(node) && ts.isFirstDeclarationOfKind(node, node.kind)); + return isFirstEmittedDeclarationInScope(node) + && (!ts.hasModifier(node, 1) + || isES6ExportedDeclaration(node)); } function addVarForEnumExportedFromNamespace(statements, node) { var statement = ts.createVariableStatement(undefined, [ts.createVariableDeclaration(getDeclarationName(node), undefined, getExportName(node))]); - setSourceMapRange(statement, node); + ts.setSourceMapRange(statement, node); statements.push(statement); } function visitEnumDeclaration(node) { @@ -36397,6 +37802,7 @@ var ts; } var statements = []; var emitFlags = 64; + recordEmittedDeclarationInScope(node); if (shouldEmitVarForEnumDeclaration(node)) { addVarForEnumOrModuleDeclaration(statements, node); if (moduleKind !== ts.ModuleKind.System || currentScope !== currentSourceFile) { @@ -36408,7 +37814,7 @@ var ts; var exportName = getExportName(node); var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, transformEnumBody(node, containerName)), undefined, [ts.createLogicalOr(exportName, ts.createAssignment(exportName, ts.createObjectLiteral()))]), node); ts.setOriginalNode(enumStatement, node); - setNodeEmitFlags(enumStatement, emitFlags); + ts.setEmitFlags(enumStatement, emitFlags); statements.push(enumStatement); if (isNamespaceExport(node)) { addVarForEnumExportedFromNamespace(statements, node); @@ -36447,18 +37853,32 @@ var ts; function shouldEmitModuleDeclaration(node) { return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); } - function isModuleMergedWithES6Class(node) { - return languageVersion === 2 - && ts.isMergedWithClass(node); - } function isES6ExportedDeclaration(node) { return isExternalModuleExport(node) && moduleKind === ts.ModuleKind.ES6; } + function recordEmittedDeclarationInScope(node) { + var name = node.symbol && node.symbol.name; + if (name) { + if (!currentScopeFirstDeclarationsOfName) { + currentScopeFirstDeclarationsOfName = ts.createMap(); + } + if (!(name in currentScopeFirstDeclarationsOfName)) { + currentScopeFirstDeclarationsOfName[name] = node; + } + } + } + function isFirstEmittedDeclarationInScope(node) { + if (currentScopeFirstDeclarationsOfName) { + var name_31 = node.symbol && node.symbol.name; + if (name_31) { + return currentScopeFirstDeclarationsOfName[name_31] === node; + } + } + return false; + } function shouldEmitVarForModuleDeclaration(node) { - return !isModuleMergedWithES6Class(node) - && (!isES6ExportedDeclaration(node) - || ts.isFirstDeclarationOfKind(node, node.kind)); + return isFirstEmittedDeclarationInScope(node); } function addVarForEnumOrModuleDeclaration(statements, node) { var statement = ts.createVariableStatement(isES6ExportedDeclaration(node) @@ -36468,13 +37888,13 @@ var ts; ]); ts.setOriginalNode(statement, node); if (node.kind === 224) { - setSourceMapRange(statement.declarationList, node); + ts.setSourceMapRange(statement.declarationList, node); } else { - setSourceMapRange(statement, node); + ts.setSourceMapRange(statement, node); } - setCommentRange(statement, node); - setNodeEmitFlags(statement, 32768); + ts.setCommentRange(statement, node); + ts.setEmitFlags(statement, 32768); statements.push(statement); } function visitModuleDeclaration(node) { @@ -36485,6 +37905,7 @@ var ts; enableSubstitutionForNamespaceExports(); var statements = []; var emitFlags = 64; + recordEmittedDeclarationInScope(node); if (shouldEmitVarForModuleDeclaration(node)) { addVarForEnumOrModuleDeclaration(statements, node); if (moduleKind !== ts.ModuleKind.System || currentScope !== currentSourceFile) { @@ -36501,15 +37922,17 @@ var ts; } var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, transformModuleBody(node, containerName)), undefined, [moduleArg]), node); ts.setOriginalNode(moduleStatement, node); - setNodeEmitFlags(moduleStatement, emitFlags); + ts.setEmitFlags(moduleStatement, emitFlags); statements.push(moduleStatement); return statements; } function transformModuleBody(node, namespaceLocalName) { var savedCurrentNamespaceContainerName = currentNamespaceContainerName; var savedCurrentNamespace = currentNamespace; + var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName; currentNamespaceContainerName = namespaceLocalName; currentNamespace = node; + currentScopeFirstDeclarationsOfName = undefined; var statements = []; startLexicalEnvironment(); var statementsLocation; @@ -36536,9 +37959,10 @@ var ts; ts.addRange(statements, endLexicalEnvironment()); currentNamespaceContainerName = savedCurrentNamespaceContainerName; currentNamespace = savedCurrentNamespace; + currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), blockLocation, true); if (body.kind !== 226) { - setNodeEmitFlags(block, block.emitFlags | 49152); + ts.setEmitFlags(block, ts.getEmitFlags(block) | 49152); } return block; } @@ -36561,7 +37985,7 @@ var ts; return undefined; } var moduleReference = ts.createExpressionFromEntityName(node.moduleReference); - setNodeEmitFlags(moduleReference, 49152 | 65536); + ts.setEmitFlags(moduleReference, 49152 | 65536); if (isNamedExternalModuleExport(node) || !isNamespaceExport(node)) { return ts.setOriginalNode(ts.createVariableStatement(ts.visitNodes(node.modifiers, visitor, ts.isModifier), ts.createVariableDeclarationList([ ts.createVariableDeclaration(node.name, undefined, moduleReference) @@ -36590,9 +38014,9 @@ var ts; } function addExportMemberAssignment(statements, node) { var expression = ts.createAssignment(getExportName(node), getLocalName(node, true)); - setSourceMapRange(expression, ts.createRange(node.name.pos, node.end)); + ts.setSourceMapRange(expression, ts.createRange(node.name.pos, node.end)); var statement = ts.createStatement(expression); - setSourceMapRange(statement, ts.createRange(-1, node.end)); + ts.setSourceMapRange(statement, ts.createRange(-1, node.end)); statements.push(statement); } function createNamespaceExport(exportName, exportValue, location) { @@ -36613,7 +38037,7 @@ var ts; emitFlags |= 1536; } if (emitFlags) { - setNodeEmitFlags(qualifiedName, emitFlags); + ts.setEmitFlags(qualifiedName, emitFlags); } return qualifiedName; } @@ -36622,7 +38046,7 @@ var ts; } function getNamespaceParameterName(node) { var name = ts.getGeneratedNameForNode(node); - setSourceMapRange(name, node.name); + ts.setSourceMapRange(name, node.name); return name; } function getNamespaceContainerName(node) { @@ -36639,8 +38063,8 @@ var ts; } function getDeclarationName(node, allowComments, allowSourceMaps, emitFlags) { if (node.name) { - var name_30 = ts.getMutableClone(node.name); - emitFlags |= getNodeEmitFlags(node.name); + var name_32 = ts.getMutableClone(node.name); + emitFlags |= ts.getEmitFlags(node.name); if (!allowSourceMaps) { emitFlags |= 1536; } @@ -36648,9 +38072,9 @@ var ts; emitFlags |= 49152; } if (emitFlags) { - setNodeEmitFlags(name_30, emitFlags); + ts.setEmitFlags(name_32, emitFlags); } - return name_30; + return name_32; } else { return ts.getGeneratedNameForNode(node); @@ -36712,7 +38136,7 @@ var ts; function isTransformedEnumDeclaration(node) { return ts.getOriginalNode(node).kind === 224; } - function onEmitNode(node, emit) { + function onEmitNode(emitContext, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; var savedCurrentSuperContainer = currentSuperContainer; if (enabledSubstitutions & 4 && isSuperContainer(node)) { @@ -36724,13 +38148,13 @@ var ts; if (enabledSubstitutions & 8 && isTransformedEnumDeclaration(node)) { applicableSubstitutions |= 8; } - previousOnEmitNode(node, emit); + previousOnEmitNode(emitContext, node, emitCallback); applicableSubstitutions = savedApplicableSubstitutions; currentSuperContainer = savedCurrentSuperContainer; } - function onSubstituteNode(node, isExpression) { - node = previousOnSubstituteNode(node, isExpression); - if (isExpression) { + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1) { return substituteExpression(node); } else if (ts.isShorthandPropertyAssignment(node)) { @@ -36740,14 +38164,14 @@ var ts; } function substituteShorthandPropertyAssignment(node) { if (enabledSubstitutions & 2) { - var name_31 = node.name; - var exportedName = trySubstituteNamespaceExportedName(name_31); + var name_33 = node.name; + var exportedName = trySubstituteNamespaceExportedName(name_33); if (exportedName) { if (node.objectAssignmentInitializer) { var initializer = ts.createAssignment(exportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name_31, initializer, node); + return ts.createPropertyAssignment(name_33, initializer, node); } - return ts.createPropertyAssignment(name_31, exportedName, node); + return ts.createPropertyAssignment(name_33, exportedName, node); } } return node; @@ -36756,16 +38180,15 @@ var ts; switch (node.kind) { case 69: return substituteExpressionIdentifier(node); - } - if (enabledSubstitutions & 4) { - switch (node.kind) { - case 174: + case 172: + return substitutePropertyAccessExpression(node); + case 173: + return substituteElementAccessExpression(node); + case 174: + if (enabledSubstitutions & 4) { return substituteCallExpression(node); - case 172: - return substitutePropertyAccessExpression(node); - case 173: - return substituteElementAccessExpression(node); - } + } + break; } return node; } @@ -36782,8 +38205,8 @@ var ts; var classAlias = classAliases[declaration.id]; if (classAlias) { var clone_4 = ts.getSynthesizedClone(classAlias); - setSourceMapRange(clone_4, node); - setCommentRange(clone_4, node); + ts.setSourceMapRange(clone_4, node); + ts.setCommentRange(clone_4, node); return clone_4; } } @@ -36792,7 +38215,7 @@ var ts; return undefined; } function trySubstituteNamespaceExportedName(node) { - if (enabledSubstitutions & applicableSubstitutions && (getNodeEmitFlags(node) & 262144) === 0) { + if (enabledSubstitutions & applicableSubstitutions && (ts.getEmitFlags(node) & 262144) === 0) { var container = resolver.getReferencedExportContainer(node, false); if (container) { var substitute = (applicableSubstitutions & 2 && container.kind === 225) || @@ -36820,23 +38243,48 @@ var ts; return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 95) { + if (enabledSubstitutions & 4 && node.expression.kind === 95) { var flags = getSuperContainerAsyncMethodFlags(); if (flags) { return createSuperAccessInAsyncMethod(ts.createLiteral(node.name.text), flags, node); } } - return node; + return substituteConstantValue(node); } function substituteElementAccessExpression(node) { - if (node.expression.kind === 95) { + if (enabledSubstitutions & 4 && node.expression.kind === 95) { var flags = getSuperContainerAsyncMethodFlags(); if (flags) { return createSuperAccessInAsyncMethod(node.argumentExpression, flags, node); } } + return substituteConstantValue(node); + } + function substituteConstantValue(node) { + var constantValue = tryGetConstEnumValue(node); + if (constantValue !== undefined) { + var substitute = ts.createLiteral(constantValue); + ts.setSourceMapRange(substitute, node); + ts.setCommentRange(substitute, node); + if (!compilerOptions.removeComments) { + var propertyName = ts.isPropertyAccessExpression(node) + ? ts.declarationNameToString(node.name) + : ts.getTextOfNode(node.argumentExpression); + substitute.trailingComment = " " + propertyName + " "; + } + ts.setConstantValue(node, constantValue); + return substitute; + } return node; } + function tryGetConstEnumValue(node) { + if (compilerOptions.isolatedModules) { + return undefined; + } + return ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node) + ? resolver.getConstantValue(node) + : undefined; + } function createSuperAccessInAsyncMethod(argumentExpression, flags, location) { if (flags & 4096) { return ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), "value", location); @@ -36860,6 +38308,9 @@ var ts; var currentSourceFile; return transformSourceFile; function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } currentSourceFile = node; node = ts.visitEachChild(node, visitor, context); currentSourceFile = undefined; @@ -37018,12 +38469,12 @@ var ts; return getTagName(node.openingElement); } else { - var name_32 = node.tagName; - if (ts.isIdentifier(name_32) && ts.isIntrinsicJsxName(name_32.text)) { - return ts.createLiteral(name_32.text); + var name_34 = node.tagName; + if (ts.isIdentifier(name_34) && ts.isIntrinsicJsxName(name_34.text)) { + return ts.createLiteral(name_34.text); } else { - return ts.createExpressionFromEntityName(name_32); + return ts.createExpressionFromEntityName(name_34); } } } @@ -37305,6 +38756,9 @@ var ts; var hoistVariableDeclaration = context.hoistVariableDeclaration; return transformSourceFile; function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } return ts.visitEachChild(node, visitor, context); } function visitor(node) { @@ -37364,7 +38818,7 @@ var ts; var ts; (function (ts) { function transformES6(context) { - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration, getNodeEmitFlags = context.getNodeEmitFlags, setNodeEmitFlags = context.setNodeEmitFlags, getCommentRange = context.getCommentRange, setCommentRange = context.setCommentRange, getSourceMapRange = context.getSourceMapRange, setSourceMapRange = context.setSourceMapRange, setTokenSourceMapRange = context.setTokenSourceMapRange; + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); var previousOnSubstituteNode = context.onSubstituteNode; var previousOnEmitNode = context.onEmitNode; @@ -37384,6 +38838,9 @@ var ts; var enabledSubstitutions; return transformSourceFile; function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } currentSourceFile = node; currentText = node.text; return ts.visitNode(node, visitor, ts.isSourceFile); @@ -37553,7 +39010,7 @@ var ts; enclosingFunction = currentNode; if (currentNode.kind !== 180) { enclosingNonArrowFunction = currentNode; - if (!(currentNode.emitFlags & 2097152)) { + if (!(ts.getEmitFlags(currentNode) & 2097152)) { enclosingNonAsyncFunctionBody = currentNode; } } @@ -37690,15 +39147,15 @@ var ts; } var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); var classFunction = ts.createFunctionExpression(undefined, undefined, undefined, extendsClauseElement ? [ts.createParameter("_super")] : [], undefined, transformClassBody(node, extendsClauseElement)); - if (getNodeEmitFlags(node) & 524288) { - setNodeEmitFlags(classFunction, 524288); + if (ts.getEmitFlags(node) & 524288) { + ts.setEmitFlags(classFunction, 524288); } var inner = ts.createPartiallyEmittedExpression(classFunction); inner.end = node.end; - setNodeEmitFlags(inner, 49152); + ts.setEmitFlags(inner, 49152); var outer = ts.createPartiallyEmittedExpression(inner); outer.end = ts.skipTrivia(currentText, node.pos); - setNodeEmitFlags(outer, 49152); + ts.setEmitFlags(outer, 49152); return ts.createParen(ts.createCall(outer, undefined, extendsClauseElement ? [ts.visitNode(extendsClauseElement.expression, visitor, ts.isExpression)] : [])); @@ -37713,14 +39170,14 @@ var ts; var localName = getLocalName(node); var outer = ts.createPartiallyEmittedExpression(localName); outer.end = closingBraceLocation.end; - setNodeEmitFlags(outer, 49152); + ts.setEmitFlags(outer, 49152); var statement = ts.createReturn(outer); statement.pos = closingBraceLocation.pos; - setNodeEmitFlags(statement, 49152 | 12288); + ts.setEmitFlags(statement, 49152 | 12288); statements.push(statement); ts.addRange(statements, endLexicalEnvironment()); var block = ts.createBlock(ts.createNodeArray(statements, node.members), undefined, true); - setNodeEmitFlags(block, 49152); + ts.setEmitFlags(block, 49152); return block; } function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) { @@ -37731,7 +39188,11 @@ var ts; function addConstructor(statements, node, extendsClauseElement) { var constructor = ts.getFirstConstructorWithBody(node); var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); - statements.push(ts.createFunctionDeclaration(undefined, undefined, undefined, getDeclarationName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), constructor || node)); + var constructorFunction = ts.createFunctionDeclaration(undefined, undefined, undefined, getDeclarationName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), constructor || node); + if (extendsClauseElement) { + ts.setEmitFlags(constructorFunction, 256); + } + statements.push(constructorFunction); } function transformConstructorParameters(constructor, hasSynthesizedSuper) { if (constructor && !hasSynthesizedSuper) { @@ -37742,33 +39203,98 @@ var ts; function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { var statements = []; startLexicalEnvironment(); + var statementOffset = -1; + if (hasSynthesizedSuper) { + statementOffset = 1; + } + else if (constructor) { + statementOffset = ts.addPrologueDirectives(statements, constructor.body.statements, false, visitor); + } if (constructor) { - addCaptureThisForNodeIfNeeded(statements, constructor); addDefaultValueAssignmentsIfNeeded(statements, constructor); addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); + ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); + } + var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, !!extendsClauseElement, hasSynthesizedSuper, statementOffset); + if (superCaptureStatus === 1 || superCaptureStatus === 2) { + statementOffset++; } - addDefaultSuperCallIfNeeded(statements, constructor, extendsClauseElement, hasSynthesizedSuper); if (constructor) { - var body = saveStateAndInvoke(constructor, hasSynthesizedSuper ? transformConstructorBodyWithSynthesizedSuper : transformConstructorBodyWithoutSynthesizedSuper); + var body = saveStateAndInvoke(constructor, function (constructor) { return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset); }); ts.addRange(statements, body); } + if (extendsClauseElement + && superCaptureStatus !== 2 + && !(constructor && isSufficientlyCoveredByReturnStatements(constructor.body))) { + statements.push(ts.createReturn(ts.createIdentifier("_this"))); + } ts.addRange(statements, endLexicalEnvironment()); var block = ts.createBlock(ts.createNodeArray(statements, constructor ? constructor.body.statements : node.members), constructor ? constructor.body : node, true); if (!constructor) { - setNodeEmitFlags(block, 49152); + ts.setEmitFlags(block, 49152); } return block; } - function transformConstructorBodyWithSynthesizedSuper(node) { - return ts.visitNodes(node.body.statements, visitor, ts.isStatement, 1); - } - function transformConstructorBodyWithoutSynthesizedSuper(node) { - return ts.visitNodes(node.body.statements, visitor, ts.isStatement, 0); - } - function addDefaultSuperCallIfNeeded(statements, constructor, extendsClauseElement, hasSynthesizedSuper) { - if (constructor ? hasSynthesizedSuper : extendsClauseElement) { - statements.push(ts.createStatement(ts.createFunctionApply(ts.createIdentifier("_super"), ts.createThis(), ts.createIdentifier("arguments")), extendsClauseElement)); + function isSufficientlyCoveredByReturnStatements(statement) { + if (statement.kind === 211) { + return true; } + else if (statement.kind === 203) { + var ifStatement = statement; + if (ifStatement.elseStatement) { + return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && + isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); + } + } + else if (statement.kind === 199) { + var lastStatement = ts.lastOrUndefined(statement.statements); + if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { + return true; + } + } + return false; + } + function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, hasExtendsClause, hasSynthesizedSuper, statementOffset) { + if (!hasExtendsClause) { + if (ctor) { + addCaptureThisForNodeIfNeeded(statements, ctor); + } + return 0; + } + if (!ctor) { + statements.push(ts.createReturn(createDefaultSuperCallOrThis())); + return 2; + } + if (hasSynthesizedSuper) { + captureThisForNode(statements, ctor, createDefaultSuperCallOrThis()); + enableSubstitutionsForCapturedThis(); + return 1; + } + var firstStatement; + var superCallExpression; + var ctorStatements = ctor.body.statements; + if (statementOffset < ctorStatements.length) { + firstStatement = ctorStatements[statementOffset]; + if (firstStatement.kind === 202 && ts.isSuperCall(firstStatement.expression)) { + var superCall = firstStatement.expression; + superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); + } + } + if (superCallExpression && statementOffset === ctorStatements.length - 1) { + statements.push(ts.createReturn(superCallExpression)); + return 2; + } + captureThisForNode(statements, ctor, superCallExpression, firstStatement); + if (superCallExpression) { + return 1; + } + return 0; + } + function createDefaultSuperCallOrThis() { + var actualThis = ts.createThis(); + ts.setEmitFlags(actualThis, 128); + var superCall = ts.createFunctionApply(ts.createIdentifier("_super"), actualThis, ts.createIdentifier("arguments")); + return ts.createLogicalOr(superCall, actualThis); } function visitParameter(node) { if (node.dotDotDotToken) { @@ -37793,34 +39319,34 @@ var ts; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { var parameter = _a[_i]; - var name_33 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; + var name_35 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; if (dotDotDotToken) { continue; } - if (ts.isBindingPattern(name_33)) { - addDefaultValueAssignmentForBindingPattern(statements, parameter, name_33, initializer); + if (ts.isBindingPattern(name_35)) { + addDefaultValueAssignmentForBindingPattern(statements, parameter, name_35, initializer); } else if (initializer) { - addDefaultValueAssignmentForInitializer(statements, parameter, name_33, initializer); + addDefaultValueAssignmentForInitializer(statements, parameter, name_35, initializer); } } } function addDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer) { var temp = ts.getGeneratedNameForNode(parameter); if (name.elements.length > 0) { - statements.push(setNodeEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(ts.flattenParameterDestructuring(context, parameter, temp, visitor))), 8388608)); + statements.push(ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(ts.flattenParameterDestructuring(context, parameter, temp, visitor))), 8388608)); } else if (initializer) { - statements.push(setNodeEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 8388608)); + statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 8388608)); } } function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) { initializer = ts.visitNode(initializer, visitor, ts.isExpression); - var statement = ts.createIf(ts.createStrictEquality(ts.getSynthesizedClone(name), ts.createVoidZero()), setNodeEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(setNodeEmitFlags(ts.getMutableClone(name), 1536), setNodeEmitFlags(initializer, 1536 | getNodeEmitFlags(initializer)), parameter)) + var statement = ts.createIf(ts.createStrictEquality(ts.getSynthesizedClone(name), ts.createVoidZero()), ts.setEmitFlags(ts.createBlock([ + ts.createStatement(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 1536), ts.setEmitFlags(initializer, 1536 | ts.getEmitFlags(initializer)), parameter)) ], parameter), 32 | 1024 | 12288), undefined, parameter); statement.startsOnNewLine = true; - setNodeEmitFlags(statement, 12288 | 1024 | 8388608); + ts.setEmitFlags(statement, 12288 | 1024 | 8388608); statements.push(statement); } function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) { @@ -37832,11 +39358,11 @@ var ts; return; } var declarationName = ts.getMutableClone(parameter.name); - setNodeEmitFlags(declarationName, 1536); + ts.setEmitFlags(declarationName, 1536); var expressionName = ts.getSynthesizedClone(parameter.name); var restIndex = node.parameters.length - 1; var temp = ts.createLoopVariable(); - statements.push(setNodeEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + statements.push(ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration(declarationName, undefined, ts.createArrayLiteral([])) ]), parameter), 8388608)); var forStatement = ts.createFor(ts.createVariableDeclarationList([ @@ -37844,21 +39370,24 @@ var ts; ], parameter), ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length"), parameter), ts.createPostfixIncrement(temp, parameter), ts.createBlock([ ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp)), parameter)) ])); - setNodeEmitFlags(forStatement, 8388608); + ts.setEmitFlags(forStatement, 8388608); ts.startOnNewLine(forStatement); statements.push(forStatement); } function addCaptureThisForNodeIfNeeded(statements, node) { if (node.transformFlags & 16384 && node.kind !== 180) { - enableSubstitutionsForCapturedThis(); - var captureThisStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration("_this", undefined, ts.createThis()) - ])); - setNodeEmitFlags(captureThisStatement, 49152 | 8388608); - setSourceMapRange(captureThisStatement, node); - statements.push(captureThisStatement); + captureThisForNode(statements, node, ts.createThis()); } } + function captureThisForNode(statements, node, initializer, originalStatement) { + enableSubstitutionsForCapturedThis(); + var captureThisStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration("_this", undefined, initializer) + ]), originalStatement); + ts.setEmitFlags(captureThisStatement, 49152 | 8388608); + ts.setSourceMapRange(captureThisStatement, node); + statements.push(captureThisStatement); + } function addClassMembers(statements, node) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; @@ -37888,43 +39417,43 @@ var ts; return ts.createEmptyStatement(member); } function transformClassMethodDeclarationToStatement(receiver, member) { - var commentRange = getCommentRange(member); - var sourceMapRange = getSourceMapRange(member); + var commentRange = ts.getCommentRange(member); + var sourceMapRange = ts.getSourceMapRange(member); var func = transformFunctionLikeToExpression(member, member, undefined); - setNodeEmitFlags(func, 49152); - setSourceMapRange(func, sourceMapRange); + ts.setEmitFlags(func, 49152); + ts.setSourceMapRange(func, sourceMapRange); var statement = ts.createStatement(ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), member.name), func), member); ts.setOriginalNode(statement, member); - setCommentRange(statement, commentRange); - setNodeEmitFlags(statement, 1536); + ts.setCommentRange(statement, commentRange); + ts.setEmitFlags(statement, 1536); return statement; } function transformAccessorsToStatement(receiver, accessors) { - var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, false), getSourceMapRange(accessors.firstAccessor)); - setNodeEmitFlags(statement, 49152); + var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, false), ts.getSourceMapRange(accessors.firstAccessor)); + ts.setEmitFlags(statement, 49152); return statement; } function transformAccessorsToExpression(receiver, _a, startsOnNewLine) { var firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; var target = ts.getMutableClone(receiver); - setNodeEmitFlags(target, 49152 | 1024); - setSourceMapRange(target, firstAccessor.name); + ts.setEmitFlags(target, 49152 | 1024); + ts.setSourceMapRange(target, firstAccessor.name); var propertyName = ts.createExpressionForPropertyName(ts.visitNode(firstAccessor.name, visitor, ts.isPropertyName)); - setNodeEmitFlags(propertyName, 49152 | 512); - setSourceMapRange(propertyName, firstAccessor.name); + ts.setEmitFlags(propertyName, 49152 | 512); + ts.setSourceMapRange(propertyName, firstAccessor.name); var properties = []; if (getAccessor) { var getterFunction = transformFunctionLikeToExpression(getAccessor, undefined, undefined); - setSourceMapRange(getterFunction, getSourceMapRange(getAccessor)); + ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); var getter = ts.createPropertyAssignment("get", getterFunction); - setCommentRange(getter, getCommentRange(getAccessor)); + ts.setCommentRange(getter, ts.getCommentRange(getAccessor)); properties.push(getter); } if (setAccessor) { var setterFunction = transformFunctionLikeToExpression(setAccessor, undefined, undefined); - setSourceMapRange(setterFunction, getSourceMapRange(setAccessor)); + ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); var setter = ts.createPropertyAssignment("set", setterFunction); - setCommentRange(setter, getCommentRange(setAccessor)); + ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); properties.push(setter); } properties.push(ts.createPropertyAssignment("enumerable", ts.createLiteral(true)), ts.createPropertyAssignment("configurable", ts.createLiteral(true))); @@ -37943,7 +39472,7 @@ var ts; enableSubstitutionsForCapturedThis(); } var func = transformFunctionLikeToExpression(node, node, undefined); - setNodeEmitFlags(func, 256); + ts.setEmitFlags(func, 256); return func; } function visitFunctionExpression(node) { @@ -38000,7 +39529,7 @@ var ts; } var expression = ts.visitNode(body, visitor, ts.isExpression); var returnStatement = ts.createReturn(expression, body); - setNodeEmitFlags(returnStatement, 12288 | 1024 | 32768); + ts.setEmitFlags(returnStatement, 12288 | 1024 | 32768); statements.push(returnStatement); closeBraceLocation = body; } @@ -38011,10 +39540,10 @@ var ts; } var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), node.body, multiLine); if (!multiLine && singleLine) { - setNodeEmitFlags(block, 32); + ts.setEmitFlags(block, 32); } if (closeBraceLocation) { - setTokenSourceMapRange(block, 16, closeBraceLocation); + ts.setTokenSourceMapRange(block, 16, closeBraceLocation); } ts.setOriginalNode(block, node.body); return block; @@ -38055,7 +39584,7 @@ var ts; assignment = ts.flattenVariableDestructuringToExpression(context, decl, hoistVariableDeclaration, undefined, visitor); } else { - assignment = ts.createBinary(decl.name, 56, decl.initializer); + assignment = ts.createBinary(decl.name, 56, ts.visitNode(decl.initializer, visitor, ts.isExpression)); } (assignments || (assignments = [])).push(assignment); } @@ -38078,13 +39607,13 @@ var ts; : visitVariableDeclaration)); var declarationList = ts.createVariableDeclarationList(declarations, node); ts.setOriginalNode(declarationList, node); - setCommentRange(declarationList, node); + ts.setCommentRange(declarationList, node); if (node.transformFlags & 2097152 && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { var firstDeclaration = ts.firstOrUndefined(declarations); var lastDeclaration = ts.lastOrUndefined(declarations); - setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); } return declarationList; } @@ -38179,7 +39708,7 @@ var ts; ts.setOriginalNode(declarationList, initializer); var firstDeclaration = declarations[0]; var lastDeclaration = ts.lastOrUndefined(declarations); - setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); statements.push(ts.createVariableStatement(undefined, declarationList)); } else { @@ -38214,14 +39743,14 @@ var ts; statements.push(statement); } } - setNodeEmitFlags(expression, 1536 | getNodeEmitFlags(expression)); + ts.setEmitFlags(expression, 1536 | ts.getEmitFlags(expression)); var body = ts.createBlock(ts.createNodeArray(statements, statementsLocation), bodyLocation); - setNodeEmitFlags(body, 1536 | 12288); + ts.setEmitFlags(body, 1536 | 12288); var forStatement = ts.createFor(ts.createVariableDeclarationList([ ts.createVariableDeclaration(counter, undefined, ts.createLiteral(0), ts.moveRangePos(node.expression, -1)), ts.createVariableDeclaration(rhsReference, undefined, expression, node.expression) ], node.expression), ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length"), node.expression), ts.createPostfixIncrement(counter, node.expression), body, node); - setNodeEmitFlags(forStatement, 8192); + ts.setEmitFlags(forStatement, 8192); return forStatement; } function visitObjectLiteralExpression(node) { @@ -38239,7 +39768,7 @@ var ts; ts.Debug.assert(numInitialProperties !== numProperties); var temp = ts.createTempVariable(hoistVariableDeclaration); var expressions = []; - var assignment = ts.createAssignment(temp, setNodeEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), undefined, node.multiLine), 524288)); + var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), undefined, node.multiLine), 524288)); if (node.multiLine) { assignment.startsOnNewLine = true; } @@ -38328,7 +39857,7 @@ var ts; loopBody = ts.createBlock([loopBody], undefined, true); } var isAsyncBlockContainingAwait = enclosingNonArrowFunction - && (enclosingNonArrowFunction.emitFlags & 2097152) !== 0 + && (ts.getEmitFlags(enclosingNonArrowFunction) & 2097152) !== 0 && (node.statement.transformFlags & 4194304) !== 0; var loopBodyFlags = 0; if (currentState.containsLexicalThis) { @@ -38338,7 +39867,7 @@ var ts; loopBodyFlags |= 2097152; } var convertedLoopVariable = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(functionName, undefined, setNodeEmitFlags(ts.createFunctionExpression(isAsyncBlockContainingAwait ? ts.createToken(37) : undefined, undefined, undefined, loopParameters, undefined, loopBody), loopBodyFlags)) + ts.createVariableDeclaration(functionName, undefined, ts.setEmitFlags(ts.createFunctionExpression(isAsyncBlockContainingAwait ? ts.createToken(37) : undefined, undefined, undefined, loopParameters, undefined, loopBody), loopBodyFlags)) ])); var statements = [convertedLoopVariable]; var extraVariableDeclarations; @@ -38366,8 +39895,8 @@ var ts; if (!extraVariableDeclarations) { extraVariableDeclarations = []; } - for (var name_34 in currentState.hoistedLocalVariables) { - var identifier = currentState.hoistedLocalVariables[name_34]; + for (var _b = 0, _c = currentState.hoistedLocalVariables; _b < _c.length; _b++) { + var identifier = _c[_b]; extraVariableDeclarations.push(ts.createVariableDeclaration(identifier)); } } @@ -38376,8 +39905,8 @@ var ts; if (!extraVariableDeclarations) { extraVariableDeclarations = []; } - for (var _b = 0, loopOutParameters_1 = loopOutParameters; _b < loopOutParameters_1.length; _b++) { - var outParam = loopOutParameters_1[_b]; + for (var _d = 0, loopOutParameters_1 = loopOutParameters; _d < loopOutParameters_1.length; _d++) { + var outParam = loopOutParameters_1[_d]; extraVariableDeclarations.push(ts.createVariableDeclaration(outParam.outParamName)); } } @@ -38555,7 +40084,7 @@ var ts; function visitMethodDeclaration(node) { ts.Debug.assert(!ts.isComputedPropertyName(node.name)); var functionExpression = transformFunctionLikeToExpression(node, ts.moveRangePos(node, -1), undefined); - setNodeEmitFlags(functionExpression, 16384 | getNodeEmitFlags(functionExpression)); + ts.setEmitFlags(functionExpression, 16384 | ts.getEmitFlags(functionExpression)); return ts.createPropertyAssignment(node.name, functionExpression, node); } function visitShorthandPropertyAssignment(node) { @@ -38568,13 +40097,32 @@ var ts; return transformAndSpreadElements(node.elements, true, node.multiLine, node.elements.hasTrailingComma); } function visitCallExpression(node) { + return visitCallExpressionWithPotentialCapturedThisAssignment(node, true); + } + function visitImmediateSuperCallInBody(node) { + return visitCallExpressionWithPotentialCapturedThisAssignment(node, false); + } + function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) { var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; + if (node.expression.kind === 95) { + ts.setEmitFlags(thisArg, 128); + } + var resultingCall; if (node.transformFlags & 262144) { - return ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, false, false, false)); + resultingCall = ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, false, false, false)); } else { - return ts.createFunctionCall(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), node); + resultingCall = ts.createFunctionCall(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), node); } + if (node.expression.kind === 95) { + var actualThis = ts.createThis(); + ts.setEmitFlags(actualThis, 128); + var initializer = ts.createLogicalOr(resultingCall, actualThis); + return assignToCapturedThis + ? ts.createAssignment(ts.createIdentifier("_this"), initializer) + : initializer; + } + return resultingCall; } function visitNewExpression(node) { ts.Debug.assert((node.transformFlags & 262144) !== 0); @@ -38694,12 +40242,12 @@ var ts; clone.statements = ts.createNodeArray(statements, node.statements); return clone; } - function onEmitNode(node, emit) { + function onEmitNode(emitContext, node, emitCallback) { var savedEnclosingFunction = enclosingFunction; if (enabledSubstitutions & 1 && ts.isFunctionLike(node)) { enclosingFunction = node; } - previousOnEmitNode(node, emit); + previousOnEmitNode(emitContext, node, emitCallback); enclosingFunction = savedEnclosingFunction; } function enableSubstitutionsForBlockScopedBindings() { @@ -38721,9 +40269,9 @@ var ts; context.enableEmitNotification(220); } } - function onSubstituteNode(node, isExpression) { - node = previousOnSubstituteNode(node, isExpression); - if (isExpression) { + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1) { return substituteExpression(node); } if (ts.isIdentifier(node)) { @@ -38773,7 +40321,7 @@ var ts; function substituteThisKeyword(node) { if (enabledSubstitutions & 1 && enclosingFunction - && enclosingFunction.emitFlags & 256) { + && ts.getEmitFlags(enclosingFunction) & 256) { return ts.createIdentifier("_this", node); } return node; @@ -38783,8 +40331,8 @@ var ts; } function getDeclarationName(node, allowComments, allowSourceMaps, emitFlags) { if (node.name && !ts.isGeneratedIdentifier(node.name)) { - var name_35 = ts.getMutableClone(node.name); - emitFlags |= getNodeEmitFlags(node.name); + var name_36 = ts.getMutableClone(node.name); + emitFlags |= ts.getEmitFlags(node.name); if (!allowSourceMaps) { emitFlags |= 1536; } @@ -38792,9 +40340,9 @@ var ts; emitFlags |= 49152; } if (emitFlags) { - setNodeEmitFlags(name_35, emitFlags); + ts.setEmitFlags(name_36, emitFlags); } - return name_35; + return name_36; } return ts.getGeneratedNameForNode(node); } @@ -38842,7 +40390,7 @@ var ts; _a[7] = "endfinally", _a)); function transformGenerators(context) { - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistFunctionDeclaration = context.hoistFunctionDeclaration, hoistVariableDeclaration = context.hoistVariableDeclaration, setSourceMapRange = context.setSourceMapRange, setCommentRange = context.setCommentRange, setNodeEmitFlags = context.setNodeEmitFlags; + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistFunctionDeclaration = context.hoistFunctionDeclaration, hoistVariableDeclaration = context.hoistVariableDeclaration; var compilerOptions = context.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var resolver = context.getEmitResolver(); @@ -38876,6 +40424,9 @@ var ts; var withBlockStack; return transformSourceFile; function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } if (node.transformFlags & 1024) { currentSourceFile = node; node = ts.visitEachChild(node, visitor, context); @@ -38982,7 +40533,7 @@ var ts; } } function visitFunctionDeclaration(node) { - if (node.asteriskToken && node.emitFlags & 2097152) { + if (node.asteriskToken && ts.getEmitFlags(node) & 2097152) { node = ts.setOriginalNode(ts.createFunctionDeclaration(undefined, undefined, undefined, node.name, undefined, node.parameters, undefined, transformGeneratorFunctionBody(node.body), node), node); } else { @@ -39003,7 +40554,7 @@ var ts; } } function visitFunctionExpression(node) { - if (node.asteriskToken && node.emitFlags & 2097152) { + if (node.asteriskToken && ts.getEmitFlags(node) & 2097152) { node = ts.setOriginalNode(ts.createFunctionExpression(undefined, node.name, undefined, node.parameters, undefined, transformGeneratorFunctionBody(node.body), node), node); } else { @@ -39034,6 +40585,7 @@ var ts; var savedBlocks = blocks; var savedBlockOffsets = blockOffsets; var savedBlockActions = blockActions; + var savedBlockStack = blockStack; var savedLabelOffsets = labelOffsets; var savedLabelExpressions = labelExpressions; var savedNextLabelId = nextLabelId; @@ -39046,6 +40598,7 @@ var ts; blocks = undefined; blockOffsets = undefined; blockActions = undefined; + blockStack = undefined; labelOffsets = undefined; labelExpressions = undefined; nextLabelId = 1; @@ -39064,6 +40617,7 @@ var ts; blocks = savedBlocks; blockOffsets = savedBlockOffsets; blockActions = savedBlockActions; + blockStack = savedBlockStack; labelOffsets = savedLabelOffsets; labelExpressions = savedLabelExpressions; nextLabelId = savedNextLabelId; @@ -39079,7 +40633,7 @@ var ts; return undefined; } else { - if (node.emitFlags & 8388608) { + if (ts.getEmitFlags(node) & 8388608) { return node; } for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { @@ -39747,9 +41301,9 @@ var ts; } return -1; } - function onSubstituteNode(node, isExpression) { - node = previousOnSubstituteNode(node, isExpression); - if (isExpression) { + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1) { return substituteExpression(node); } return node; @@ -39766,11 +41320,11 @@ var ts; if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - var name_36 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); - if (name_36) { - var clone_8 = ts.getMutableClone(name_36); - setSourceMapRange(clone_8, node); - setCommentRange(clone_8, node); + var name_37 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); + if (name_37) { + var clone_8 = ts.getMutableClone(name_37); + ts.setSourceMapRange(clone_8, node); + ts.setCommentRange(clone_8, node); return clone_8; } } @@ -40164,7 +41718,7 @@ var ts; var buildResult = buildStatements(); return ts.createCall(ts.createHelperName(currentSourceFile.externalHelpersModuleName, "__generator"), undefined, [ ts.createThis(), - setNodeEmitFlags(ts.createFunctionExpression(undefined, undefined, undefined, [ts.createParameter(state)], undefined, ts.createBlock(buildResult, undefined, buildResult.length > 0)), 4194304) + ts.setEmitFlags(ts.createFunctionExpression(undefined, undefined, undefined, [ts.createParameter(state)], undefined, ts.createBlock(buildResult, undefined, buildResult.length > 0)), 4194304) ]); } function buildStatements() { @@ -40439,7 +41993,7 @@ var ts; _a[ts.ModuleKind.AMD] = transformAMDModule, _a[ts.ModuleKind.UMD] = transformUMDModule, _a)); - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration, setNodeEmitFlags = context.setNodeEmitFlags, getNodeEmitFlags = context.getNodeEmitFlags, setSourceMapRange = context.setSourceMapRange; + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var compilerOptions = context.getCompilerOptions(); var resolver = context.getEmitResolver(); var host = context.getEmitHost(); @@ -40464,6 +42018,9 @@ var ts; var hasExportStarsToExportValues; return transformSourceFile; function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { currentSourceFile = node; (_a = ts.collectExternalModuleInfo(node, resolver), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); @@ -40489,7 +42046,7 @@ var ts; addExportEqualsIfNeeded(statements, false); var updated = updateSourceFile(node, statements); if (hasExportStarsToExportValues) { - setNodeEmitFlags(updated, 2 | getNodeEmitFlags(node)); + ts.setEmitFlags(updated, 2 | ts.getEmitFlags(node)); } return updated; } @@ -40500,7 +42057,7 @@ var ts; } function transformUMDModule(node) { var define = ts.createIdentifier("define"); - setNodeEmitFlags(define, 16); + ts.setEmitFlags(define, 16); return transformAsynchronousModule(node, define, undefined, false); } function transformAsynchronousModule(node, define, moduleName, includeNonAmdDependencies) { @@ -40527,7 +42084,7 @@ var ts; addExportEqualsIfNeeded(statements, true); var body = ts.createBlock(statements, undefined, true); if (hasExportStarsToExportValues) { - setNodeEmitFlags(body, 2); + ts.setEmitFlags(body, 2); } return body; } @@ -40535,12 +42092,12 @@ var ts; if (exportEquals && resolver.isValueAliasDeclaration(exportEquals)) { if (emitAsReturn) { var statement = ts.createReturn(exportEquals.expression, exportEquals); - setNodeEmitFlags(statement, 12288 | 49152); + ts.setEmitFlags(statement, 12288 | 49152); statements.push(statement); } else { var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), exportEquals.expression), exportEquals); - setNodeEmitFlags(statement, 49152); + ts.setEmitFlags(statement, 49152); statements.push(statement); } } @@ -40603,7 +42160,7 @@ var ts; if (!ts.contains(externalImports, node)) { return undefined; } - setNodeEmitFlags(node.name, 128); + ts.setEmitFlags(node.name, 128); var statements = []; if (moduleKind !== ts.ModuleKind.AMD) { if (ts.hasModifier(node, 1)) { @@ -40691,16 +42248,16 @@ var ts; else { var names = ts.reduceEachChild(node, collectExportMembers, []); for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_37 = names_1[_i]; - addExportMemberAssignments(statements, name_37); + var name_38 = names_1[_i]; + addExportMemberAssignments(statements, name_38); } } } function collectExportMembers(names, node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node) && ts.isDeclaration(node)) { - var name_38 = node.name; - if (ts.isIdentifier(name_38)) { - names.push(name_38); + var name_39 = node.name; + if (ts.isIdentifier(name_39)) { + names.push(name_39); } } return ts.reduceEachChild(node, collectExportMembers, names); @@ -40718,7 +42275,7 @@ var ts; addExportDefault(statements, getDeclarationName(node), node); } else { - statements.push(createExportStatement(node.name, setNodeEmitFlags(ts.getSynthesizedClone(node.name), 262144), node)); + statements.push(createExportStatement(node.name, ts.setEmitFlags(ts.getSynthesizedClone(node.name), 262144), node)); } } function visitVariableStatement(node) { @@ -40835,25 +42392,25 @@ var ts; } function addVarForExportedEnumOrNamespaceDeclaration(statements, node) { var transformedStatement = ts.createVariableStatement(undefined, [ts.createVariableDeclaration(getDeclarationName(node), undefined, ts.createPropertyAccess(ts.createIdentifier("exports"), getDeclarationName(node)))], node); - setNodeEmitFlags(transformedStatement, 49152); + ts.setEmitFlags(transformedStatement, 49152); statements.push(transformedStatement); } function getDeclarationName(node) { return node.name ? ts.getSynthesizedClone(node.name) : ts.getGeneratedNameForNode(node); } - function onEmitNode(node, emit) { + function onEmitNode(emitContext, node, emitCallback) { if (node.kind === 256) { bindingNameExportSpecifiersMap = bindingNameExportSpecifiersForFileMap[ts.getOriginalNodeId(node)]; - previousOnEmitNode(node, emit); + previousOnEmitNode(emitContext, node, emitCallback); bindingNameExportSpecifiersMap = undefined; } else { - previousOnEmitNode(node, emit); + previousOnEmitNode(emitContext, node, emitCallback); } } - function onSubstituteNode(node, isExpression) { - node = previousOnSubstituteNode(node, isExpression); - if (isExpression) { + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1) { return substituteExpression(node); } else if (ts.isShorthandPropertyAssignment(node)) { @@ -40894,7 +42451,7 @@ var ts; var left = node.left; if (ts.isIdentifier(left) && ts.isAssignmentOperator(node.operatorToken.kind)) { if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, left.text)) { - setNodeEmitFlags(node, 128); + ts.setEmitFlags(node, 128); var nestedExportAssignment = void 0; for (var _i = 0, _a = bindingNameExportSpecifiersMap[left.text]; _i < _a.length; _i++) { var specifier = _a[_i]; @@ -40912,11 +42469,11 @@ var ts; var operand = node.operand; if (ts.isIdentifier(operand) && bindingNameExportSpecifiersForFileMap) { if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, operand.text)) { - setNodeEmitFlags(node, 128); + ts.setEmitFlags(node, 128); var transformedUnaryExpression = void 0; if (node.kind === 186) { - transformedUnaryExpression = ts.createBinary(operand, ts.createNode(operator === 41 ? 57 : 58), ts.createLiteral(1), node); - setNodeEmitFlags(transformedUnaryExpression, 128); + transformedUnaryExpression = ts.createBinary(operand, ts.createToken(operator === 41 ? 57 : 58), ts.createLiteral(1), node); + ts.setEmitFlags(transformedUnaryExpression, 128); } var nestedExportAssignment = void 0; for (var _i = 0, _a = bindingNameExportSpecifiersMap[operand.text]; _i < _a.length; _i++) { @@ -40931,7 +42488,7 @@ var ts; return node; } function trySubstituteExportedName(node) { - var emitFlags = getNodeEmitFlags(node); + var emitFlags = ts.getEmitFlags(node); if ((emitFlags & 262144) === 0) { var container = resolver.getReferencedExportContainer(node, (emitFlags & 131072) !== 0); if (container) { @@ -40943,7 +42500,7 @@ var ts; return undefined; } function trySubstituteImportedName(node) { - if ((getNodeEmitFlags(node) & 262144) === 0) { + if ((ts.getEmitFlags(node) & 262144) === 0) { var declaration = resolver.getReferencedImportDeclaration(node); if (declaration) { if (ts.isImportClause(declaration)) { @@ -40955,12 +42512,12 @@ var ts; } } else if (ts.isImportSpecifier(declaration)) { - var name_39 = declaration.propertyName || declaration.name; - if (name_39.originalKeywordKind === 77 && languageVersion <= 0) { - return ts.createElementAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.createLiteral(name_39.text), node); + var name_40 = declaration.propertyName || declaration.name; + if (name_40.originalKeywordKind === 77 && languageVersion <= 0) { + return ts.createElementAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.createLiteral(name_40.text), node); } else { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.getSynthesizedClone(name_39), node); + return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.getSynthesizedClone(name_40), node); } } } @@ -40982,7 +42539,7 @@ var ts; var statement = ts.createStatement(createExportAssignment(name, value)); statement.startsOnNewLine = true; if (location) { - setSourceMapRange(statement, location); + ts.setSourceMapRange(statement, location); } return statement; } @@ -41010,7 +42567,7 @@ var ts; var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile); if (includeNonAmdDependencies && importAliasName) { - setNodeEmitFlags(importAliasName, 128); + ts.setEmitFlags(importAliasName, 128); aliasedModuleNames.push(externalModuleName); importAliasNames.push(ts.createParameter(importAliasName)); } @@ -41032,7 +42589,7 @@ var ts; var ts; (function (ts) { function transformSystemModule(context) { - var getNodeEmitFlags = context.getNodeEmitFlags, setNodeEmitFlags = context.setNodeEmitFlags, startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration, hoistFunctionDeclaration = context.hoistFunctionDeclaration; + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration, hoistFunctionDeclaration = context.hoistFunctionDeclaration; var compilerOptions = context.getCompilerOptions(); var resolver = context.getEmitResolver(); var host = context.getEmitHost(); @@ -41061,6 +42618,9 @@ var ts; var currentNode; return transformSourceFile; function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { currentSourceFile = node; currentNode = node; @@ -41093,12 +42653,12 @@ var ts; var body = ts.createFunctionExpression(undefined, undefined, undefined, [ ts.createParameter(exportFunctionForFile), ts.createParameter(contextObjectForFile) - ], undefined, setNodeEmitFlags(ts.createBlock(statements, undefined, true), 1)); + ], undefined, ts.setEmitFlags(ts.createBlock(statements, undefined, true), 1)); return updateSourceFile(node, [ ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), undefined, moduleName ? [moduleName, dependencies, body] : [dependencies, body])) - ], ~1 & getNodeEmitFlags(node)); + ], ~1 & ts.getEmitFlags(node)); var _a; } function addSystemModuleBody(statements, node, dependencyGroups) { @@ -41342,11 +42902,11 @@ var ts; } function visitFunctionDeclaration(node) { if (ts.hasModifier(node, 1)) { - var name_40 = node.name || ts.getGeneratedNameForNode(node); - var newNode = ts.createFunctionDeclaration(undefined, undefined, node.asteriskToken, name_40, undefined, node.parameters, undefined, node.body, node); + var name_41 = node.name || ts.getGeneratedNameForNode(node); + var newNode = ts.createFunctionDeclaration(undefined, undefined, node.asteriskToken, name_41, undefined, node.parameters, undefined, node.body, node); recordExportedFunctionDeclaration(node); if (!ts.hasModifier(node, 512)) { - recordExportName(name_40); + recordExportName(name_41); } ts.setOriginalNode(newNode, node); node = newNode; @@ -41357,13 +42917,13 @@ var ts; function visitExpressionStatement(node) { var originalNode = ts.getOriginalNode(node); if ((originalNode.kind === 225 || originalNode.kind === 224) && ts.hasModifier(originalNode, 1)) { - var name_41 = getDeclarationName(originalNode); + var name_42 = getDeclarationName(originalNode); if (originalNode.kind === 224) { - hoistVariableDeclaration(name_41); + hoistVariableDeclaration(name_42); } return [ node, - createExportStatement(name_41, name_41) + createExportStatement(name_42, name_42) ]; } return node; @@ -41517,19 +43077,19 @@ var ts; function visitBlock(node) { return ts.visitEachChild(node, visitNestedNode, context); } - function onEmitNode(node, emit) { + function onEmitNode(emitContext, node, emitCallback) { if (node.kind === 256) { exportFunctionForFile = exportFunctionForFileMap[ts.getOriginalNodeId(node)]; - previousOnEmitNode(node, emit); + previousOnEmitNode(emitContext, node, emitCallback); exportFunctionForFile = undefined; } else { - previousOnEmitNode(node, emit); + previousOnEmitNode(emitContext, node, emitCallback); } } - function onSubstituteNode(node, isExpression) { - node = previousOnSubstituteNode(node, isExpression); - if (isExpression) { + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1) { return substituteExpression(node); } return node; @@ -41563,7 +43123,7 @@ var ts; return node; } function substituteAssignmentExpression(node) { - setNodeEmitFlags(node, 128); + ts.setEmitFlags(node, 128); var left = node.left; switch (left.kind) { case 69: @@ -41668,7 +43228,7 @@ var ts; var exportDeclaration = resolver.getReferencedExportContainer(operand); if (exportDeclaration) { var expr = ts.createPrefix(node.operator, operand, node); - setNodeEmitFlags(expr, 128); + ts.setEmitFlags(expr, 128); var call = createExportExpression(operand, expr); if (node.kind === 185) { return call; @@ -41701,7 +43261,7 @@ var ts; ts.createForIn(ts.createVariableDeclarationList([ ts.createVariableDeclaration(n, undefined) ]), m, ts.createBlock([ - setNodeEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 32) + ts.setEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 32) ])), ts.createStatement(ts.createCall(exportFunctionForFile, undefined, [exports])) ], undefined, true))); @@ -41801,7 +43361,7 @@ var ts; function updateSourceFile(node, statements, nodeEmitFlags) { var updated = ts.getMutableClone(node); updated.statements = ts.createNodeArray(statements, node.statements); - setNodeEmitFlags(updated, nodeEmitFlags); + ts.setEmitFlags(updated, nodeEmitFlags); return updated; } } @@ -41815,6 +43375,9 @@ var ts; var currentSourceFile; return transformSourceFile; function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { currentSourceFile = node; return ts.visitEachChild(node, visitor, context); @@ -41951,18 +43514,10 @@ var ts; return transformers; } ts.getTransformers = getTransformers; - var nextTransformId = 1; function transformFiles(resolver, host, sourceFiles, transformers) { - var transformId = nextTransformId; - nextTransformId++; - var tokenSourceMapRanges = ts.createMap(); var lexicalEnvironmentVariableDeclarationsStack = []; var lexicalEnvironmentFunctionDeclarationsStack = []; var enabledSyntaxKindFeatures = new Array(289); - var parseTreeNodesWithAnnotations = []; - var lastTokenSourceMapRangeNode; - var lastTokenSourceMapRangeToken; - var lastTokenSourceMapRange; var lexicalEnvironmentStackOffset = 0; var hoistedVariableDeclarations; var hoistedFunctionDeclarations; @@ -41971,47 +43526,24 @@ var ts; getCompilerOptions: function () { return host.getCompilerOptions(); }, getEmitResolver: function () { return resolver; }, getEmitHost: function () { return host; }, - getNodeEmitFlags: getNodeEmitFlags, - setNodeEmitFlags: setNodeEmitFlags, - getSourceMapRange: getSourceMapRange, - setSourceMapRange: setSourceMapRange, - getTokenSourceMapRange: getTokenSourceMapRange, - setTokenSourceMapRange: setTokenSourceMapRange, - getCommentRange: getCommentRange, - setCommentRange: setCommentRange, hoistVariableDeclaration: hoistVariableDeclaration, hoistFunctionDeclaration: hoistFunctionDeclaration, startLexicalEnvironment: startLexicalEnvironment, endLexicalEnvironment: endLexicalEnvironment, - onSubstituteNode: onSubstituteNode, + onSubstituteNode: function (emitContext, node) { return node; }, enableSubstitution: enableSubstitution, isSubstitutionEnabled: isSubstitutionEnabled, - onEmitNode: onEmitNode, + onEmitNode: function (node, emitContext, emitCallback) { return emitCallback(node, emitContext); }, enableEmitNotification: enableEmitNotification, isEmitNotificationEnabled: isEmitNotificationEnabled }; - var transformation = chain.apply(void 0, transformers)(context); + var transformation = ts.chain.apply(void 0, transformers)(context); var transformed = ts.map(sourceFiles, transformSourceFile); lexicalEnvironmentDisabled = true; return { - getSourceFiles: function () { return transformed; }, - getTokenSourceMapRange: getTokenSourceMapRange, - isSubstitutionEnabled: isSubstitutionEnabled, - isEmitNotificationEnabled: isEmitNotificationEnabled, - onSubstituteNode: context.onSubstituteNode, - onEmitNode: context.onEmitNode, - dispose: function () { - for (var _i = 0, parseTreeNodesWithAnnotations_1 = parseTreeNodesWithAnnotations; _i < parseTreeNodesWithAnnotations_1.length; _i++) { - var node = parseTreeNodesWithAnnotations_1[_i]; - if (node.transformId === transformId) { - node.transformId = 0; - node.emitFlags = 0; - node.commentRange = undefined; - node.sourceMapRange = undefined; - } - } - parseTreeNodesWithAnnotations.length = 0; - } + transformed: transformed, + emitNodeWithSubstitution: emitNodeWithSubstitution, + emitNodeWithNotification: emitNodeWithNotification }; function transformSourceFile(sourceFile) { if (ts.isDeclarationFile(sourceFile)) { @@ -42023,75 +43555,37 @@ var ts; enabledSyntaxKindFeatures[kind] |= 1; } function isSubstitutionEnabled(node) { - return (enabledSyntaxKindFeatures[node.kind] & 1) !== 0; + return (enabledSyntaxKindFeatures[node.kind] & 1) !== 0 + && (ts.getEmitFlags(node) & 128) === 0; } - function onSubstituteNode(node, isExpression) { - return node; + function emitNodeWithSubstitution(emitContext, node, emitCallback) { + if (node) { + if (isSubstitutionEnabled(node)) { + var substitute = context.onSubstituteNode(emitContext, node); + if (substitute && substitute !== node) { + emitCallback(emitContext, substitute); + return; + } + } + emitCallback(emitContext, node); + } } function enableEmitNotification(kind) { enabledSyntaxKindFeatures[kind] |= 2; } function isEmitNotificationEnabled(node) { return (enabledSyntaxKindFeatures[node.kind] & 2) !== 0 - || (getNodeEmitFlags(node) & 64) !== 0; + || (ts.getEmitFlags(node) & 64) !== 0; } - function onEmitNode(node, emit) { - emit(node); - } - function beforeSetAnnotation(node) { - if ((node.flags & 8) === 0 && node.transformId !== transformId) { - parseTreeNodesWithAnnotations.push(node); - node.transformId = transformId; - } - } - function getNodeEmitFlags(node) { - return node.emitFlags; - } - function setNodeEmitFlags(node, emitFlags) { - beforeSetAnnotation(node); - node.emitFlags = emitFlags; - return node; - } - function getSourceMapRange(node) { - return node.sourceMapRange || node; - } - function setSourceMapRange(node, range) { - beforeSetAnnotation(node); - node.sourceMapRange = range; - return node; - } - function getTokenSourceMapRange(node, token) { - if (lastTokenSourceMapRangeNode === node && lastTokenSourceMapRangeToken === token) { - return lastTokenSourceMapRange; - } - var range; - var current = node; - while (current) { - range = current.id ? tokenSourceMapRanges[current.id + "-" + token] : undefined; - if (range !== undefined) { - break; + function emitNodeWithNotification(emitContext, node, emitCallback) { + if (node) { + if (isEmitNotificationEnabled(node)) { + context.onEmitNode(emitContext, node, emitCallback); + } + else { + emitCallback(emitContext, node); } - current = current.original; } - lastTokenSourceMapRangeNode = node; - lastTokenSourceMapRangeToken = token; - lastTokenSourceMapRange = range; - return range; - } - function setTokenSourceMapRange(node, token, range) { - lastTokenSourceMapRangeNode = node; - lastTokenSourceMapRangeToken = token; - lastTokenSourceMapRange = range; - tokenSourceMapRanges[ts.getNodeId(node) + "-" + token] = range; - return node; - } - function getCommentRange(node) { - return node.commentRange || node; - } - function setCommentRange(node, range) { - beforeSetAnnotation(node); - node.commentRange = range; - return node; } function hoistVariableDeclaration(name) { ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot modify the lexical environment during the print phase."); @@ -42144,54 +43638,6 @@ var ts; } } ts.transformFiles = transformFiles; - function chain(a, b, c, d, e) { - if (e) { - var args_3 = []; - for (var i = 0; i < arguments.length; i++) { - args_3[i] = arguments[i]; - } - return function (t) { return compose.apply(void 0, ts.map(args_3, function (f) { return f(t); })); }; - } - else if (d) { - return function (t) { return compose(a(t), b(t), c(t), d(t)); }; - } - else if (c) { - return function (t) { return compose(a(t), b(t), c(t)); }; - } - else if (b) { - return function (t) { return compose(a(t), b(t)); }; - } - else if (a) { - return function (t) { return compose(a(t)); }; - } - else { - return function (t) { return function (u) { return u; }; }; - } - } - function compose(a, b, c, d, e) { - if (e) { - var args_4 = []; - for (var i = 0; i < arguments.length; i++) { - args_4[i] = arguments[i]; - } - return function (t) { return ts.reduceLeft(args_4, function (u, f) { return f(u); }, t); }; - } - else if (d) { - return function (t) { return d(c(b(a(t)))); }; - } - else if (c) { - return function (t) { return c(b(a(t))); }; - } - else if (b) { - return function (t) { return b(a(t)); }; - } - else if (a) { - return function (t) { return a(t); }; - } - else { - return function (t) { return t; }; - } - } var _a; })(ts || (ts = {})); var ts; @@ -42202,11 +43648,11 @@ var ts; return declarationDiagnostics.getDiagnostics(targetSourceFile ? targetSourceFile.fileName : undefined); function getDeclarationDiagnosticsFromFile(_a, sources, isBundledEmit) { var declarationFilePath = _a.declarationFilePath; - emitDeclarations(host, resolver, declarationDiagnostics, declarationFilePath, sources, isBundledEmit); + emitDeclarations(host, resolver, declarationDiagnostics, declarationFilePath, sources, isBundledEmit, false); } } ts.getDeclarationDiagnostics = getDeclarationDiagnostics; - function emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFiles, isBundledEmit) { + function emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFiles, isBundledEmit, emitOnlyDtsFiles) { var newLine = host.getNewLine(); var compilerOptions = host.getCompilerOptions(); var write; @@ -42242,7 +43688,7 @@ var ts; ts.forEach(sourceFile.referencedFiles, function (fileReference) { var referencedFile = ts.tryResolveScriptReference(host, sourceFile, fileReference); if (referencedFile && !ts.contains(emittedReferencedFiles, referencedFile)) { - if (writeReferencePath(referencedFile, !isBundledEmit && !addedGlobalFileReference)) { + if (writeReferencePath(referencedFile, !isBundledEmit && !addedGlobalFileReference, emitOnlyDtsFiles)) { addedGlobalFileReference = true; } emittedReferencedFiles.push(referencedFile); @@ -42427,7 +43873,7 @@ var ts; } else { errorNameNode = declaration.name; - resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2, writer); + resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2 | 1024, writer); errorNameNode = undefined; } } @@ -42439,7 +43885,7 @@ var ts; } else { errorNameNode = signature.name; - resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, 2, writer); + resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, 2 | 1024, writer); errorNameNode = undefined; } } @@ -42612,9 +44058,9 @@ var ts; var count = 0; while (true) { count++; - var name_42 = baseName + "_" + count; - if (!(name_42 in currentIdentifiers)) { - return name_42; + var name_43 = baseName + "_" + count; + if (!(name_43 in currentIdentifiers)) { + return name_43; } } } @@ -42632,7 +44078,7 @@ var ts; write(tempVarName); write(": "); writer.getSymbolAccessibilityDiagnostic = getDefaultExportAccessibilityDiagnostic; - resolver.writeTypeOfExpression(node.expression, enclosingDeclaration, 2, writer); + resolver.writeTypeOfExpression(node.expression, enclosingDeclaration, 2 | 1024, writer); write(";"); writeLine(); write(node.isExportEquals ? "export = " : "export default "); @@ -43038,7 +44484,7 @@ var ts; } else { writer.getSymbolAccessibilityDiagnostic = getHeritageClauseVisibilityError; - resolver.writeBaseConstructorTypeOfClass(enclosingDeclaration, enclosingDeclaration, 2, writer); + resolver.writeBaseConstructorTypeOfClass(enclosingDeclaration, enclosingDeclaration, 2 | 1024, writer); } function getHeritageClauseVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; @@ -43606,14 +45052,14 @@ var ts; return emitSourceFile(node); } } - function writeReferencePath(referencedFile, addBundledFileReference) { + function writeReferencePath(referencedFile, addBundledFileReference, emitOnlyDtsFiles) { var declFileName; var addedBundledEmitReference = false; if (ts.isDeclarationFile(referencedFile)) { declFileName = referencedFile.fileName; } else { - ts.forEachExpectedEmitFile(host, getDeclFileName, referencedFile); + ts.forEachExpectedEmitFile(host, getDeclFileName, referencedFile, emitOnlyDtsFiles); } if (declFileName) { declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(declarationFilePath)), declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, false); @@ -43630,8 +45076,8 @@ var ts; } } } - function writeDeclarationFile(declarationFilePath, sourceFiles, isBundledEmit, host, resolver, emitterDiagnostics) { - var emitDeclarationResult = emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFiles, isBundledEmit); + function writeDeclarationFile(declarationFilePath, sourceFiles, isBundledEmit, host, resolver, emitterDiagnostics, emitOnlyDtsFiles) { + var emitDeclarationResult = emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFiles, isBundledEmit, emitOnlyDtsFiles); var emitSkipped = emitDeclarationResult.reportedDeclarationError || host.isEmitBlocked(declarationFilePath) || host.getCompilerOptions().noEmit; if (!emitSkipped) { var declarationOutput = emitDeclarationResult.referencesOutput @@ -43657,41 +45103,6 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function createSourceMapWriter(host, writer) { - var compilerOptions = host.getCompilerOptions(); - if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) { - if (compilerOptions.extendedDiagnostics) { - return createSourceMapWriterWithExtendedDiagnostics(host, writer); - } - return createSourceMapWriterWorker(host, writer); - } - else { - return getNullSourceMapWriter(); - } - } - ts.createSourceMapWriter = createSourceMapWriter; - var nullSourceMapWriter; - function getNullSourceMapWriter() { - if (nullSourceMapWriter === undefined) { - nullSourceMapWriter = { - initialize: function (filePath, sourceMapFilePath, sourceFiles, isBundledEmit) { }, - reset: function () { }, - getSourceMapData: function () { return undefined; }, - setSourceFile: function (sourceFile) { }, - emitPos: function (pos) { }, - emitStart: function (range, contextNode, ignoreNodeCallback, ignoreChildrenCallback, getTextRangeCallback) { }, - emitEnd: function (range, contextNode, ignoreNodeCallback, ignoreChildrenCallback, getTextRangeCallback) { }, - emitTokenStart: function (token, pos, contextNode, ignoreTokenCallback, getTokenTextRangeCallback) { return -1; }, - emitTokenEnd: function (token, end, contextNode, ignoreTokenCallback, getTokenTextRangeCallback) { return -1; }, - changeEmitSourcePos: function () { }, - stopOverridingSpan: function () { }, - getText: function () { return undefined; }, - getSourceMappingURL: function () { return undefined; } - }; - } - return nullSourceMapWriter; - } - ts.getNullSourceMapWriter = getNullSourceMapWriter; var defaultLastEncodedSourceMapSpan = { emittedLine: 1, emittedColumn: 1, @@ -43699,42 +45110,38 @@ var ts; sourceColumn: 1, sourceIndex: 0 }; - function createSourceMapWriterWorker(host, writer) { + function createSourceMapWriter(host, writer) { var compilerOptions = host.getCompilerOptions(); var extendedDiagnostics = compilerOptions.extendedDiagnostics; var currentSourceFile; var currentSourceText; var sourceMapDir; - var stopOverridingSpan = false; - var modifyLastSourcePos = false; var sourceMapSourceIndex; var lastRecordedSourceMapSpan; var lastEncodedSourceMapSpan; var lastEncodedNameIndex; var sourceMapData; - var disableDepth; + var disabled = !(compilerOptions.sourceMap || compilerOptions.inlineSourceMap); return { initialize: initialize, reset: reset, getSourceMapData: function () { return sourceMapData; }, setSourceFile: setSourceFile, emitPos: emitPos, - emitStart: emitStart, - emitEnd: emitEnd, - emitTokenStart: emitTokenStart, - emitTokenEnd: emitTokenEnd, - changeEmitSourcePos: changeEmitSourcePos, - stopOverridingSpan: function () { return stopOverridingSpan = true; }, + emitNodeWithSourceMap: emitNodeWithSourceMap, + emitTokenWithSourceMap: emitTokenWithSourceMap, getText: getText, getSourceMappingURL: getSourceMappingURL }; function initialize(filePath, sourceMapFilePath, sourceFiles, isBundledEmit) { + if (disabled) { + return; + } if (sourceMapData) { reset(); } currentSourceFile = undefined; currentSourceText = undefined; - disableDepth = 0; sourceMapSourceIndex = -1; lastRecordedSourceMapSpan = undefined; lastEncodedSourceMapSpan = defaultLastEncodedSourceMapSpan; @@ -43774,6 +45181,9 @@ var ts; } } function reset() { + if (disabled) { + return; + } currentSourceFile = undefined; sourceMapDir = undefined; sourceMapSourceIndex = undefined; @@ -43781,38 +45191,6 @@ var ts; lastEncodedSourceMapSpan = undefined; lastEncodedNameIndex = undefined; sourceMapData = undefined; - disableDepth = 0; - } - function enable() { - if (disableDepth > 0) { - disableDepth--; - } - } - function disable() { - disableDepth++; - } - function updateLastEncodedAndRecordedSpans() { - if (modifyLastSourcePos) { - modifyLastSourcePos = false; - lastRecordedSourceMapSpan.emittedLine = lastEncodedSourceMapSpan.emittedLine; - lastRecordedSourceMapSpan.emittedColumn = lastEncodedSourceMapSpan.emittedColumn; - sourceMapData.sourceMapDecodedMappings.pop(); - lastEncodedSourceMapSpan = sourceMapData.sourceMapDecodedMappings.length ? - sourceMapData.sourceMapDecodedMappings[sourceMapData.sourceMapDecodedMappings.length - 1] : - defaultLastEncodedSourceMapSpan; - var sourceMapMappings = sourceMapData.sourceMapMappings; - var lenthToSet = sourceMapMappings.length - 1; - for (; lenthToSet >= 0; lenthToSet--) { - var currentChar = sourceMapMappings.charAt(lenthToSet); - if (currentChar === ",") { - break; - } - if (currentChar === ";" && lenthToSet !== 0 && sourceMapMappings.charAt(lenthToSet - 1) !== ";") { - break; - } - } - sourceMapData.sourceMapMappings = sourceMapMappings.substr(0, Math.max(0, lenthToSet)); - } } function encodeLastRecordedSourceMapSpan() { if (!lastRecordedSourceMapSpan || lastRecordedSourceMapSpan === lastEncodedSourceMapSpan) { @@ -43843,7 +45221,7 @@ var ts; sourceMapData.sourceMapDecodedMappings.push(lastEncodedSourceMapSpan); } function emitPos(pos) { - if (ts.positionIsSynthesized(pos) || disableDepth > 0) { + if (disabled || ts.positionIsSynthesized(pos)) { return; } if (extendedDiagnostics) { @@ -43868,84 +45246,68 @@ var ts; sourceColumn: sourceLinePos.character, sourceIndex: sourceMapSourceIndex }; - stopOverridingSpan = false; } - else if (!stopOverridingSpan) { + else { lastRecordedSourceMapSpan.sourceLine = sourceLinePos.line; lastRecordedSourceMapSpan.sourceColumn = sourceLinePos.character; lastRecordedSourceMapSpan.sourceIndex = sourceMapSourceIndex; } - updateLastEncodedAndRecordedSpans(); if (extendedDiagnostics) { ts.performance.mark("afterSourcemap"); ts.performance.measure("Source Map", "beforeSourcemap", "afterSourcemap"); } } - function getStartPosPastDecorators(range) { - var rangeHasDecorators = !!range.decorators; - return ts.skipTrivia(currentSourceText, rangeHasDecorators ? range.decorators.end : range.pos); - } - function emitStart(range, contextNode, ignoreNodeCallback, ignoreChildrenCallback, getTextRangeCallback) { - if (contextNode) { - if (!ignoreNodeCallback(contextNode)) { - range = getTextRangeCallback(contextNode) || range; - emitPos(getStartPosPastDecorators(range)); - } - if (ignoreChildrenCallback(contextNode)) { - disable(); - } + function emitNodeWithSourceMap(emitContext, node, emitCallback) { + if (disabled) { + return emitCallback(emitContext, node); } - else { - emitPos(getStartPosPastDecorators(range)); + if (node) { + var emitNode = node.emitNode; + var emitFlags = emitNode && emitNode.flags; + var _a = emitNode && emitNode.sourceMapRange || node, pos = _a.pos, end = _a.end; + if (node.kind !== 287 + && (emitFlags & 512) === 0 + && pos >= 0) { + emitPos(ts.skipTrivia(currentSourceText, pos)); + } + if (emitFlags & 2048) { + disabled = true; + emitCallback(emitContext, node); + disabled = false; + } + else { + emitCallback(emitContext, node); + } + if (node.kind !== 287 + && (emitFlags & 1024) === 0 + && end >= 0) { + emitPos(end); + } } } - function emitEnd(range, contextNode, ignoreNodeCallback, ignoreChildrenCallback, getTextRangeCallback) { - if (contextNode) { - if (ignoreChildrenCallback(contextNode)) { - enable(); - } - if (!ignoreNodeCallback(contextNode)) { - range = getTextRangeCallback(contextNode) || range; - emitPos(range.end); - } + function emitTokenWithSourceMap(node, token, tokenPos, emitCallback) { + if (disabled) { + return emitCallback(token, tokenPos); } - else { - emitPos(range.end); + var emitNode = node && node.emitNode; + var emitFlags = emitNode && emitNode.flags; + var range = emitNode && emitNode.tokenSourceMapRanges && emitNode.tokenSourceMapRanges[token]; + tokenPos = ts.skipTrivia(currentSourceText, range ? range.pos : tokenPos); + if ((emitFlags & 4096) === 0 && tokenPos >= 0) { + emitPos(tokenPos); } - stopOverridingSpan = false; - } - function emitTokenStart(token, tokenStartPos, contextNode, ignoreTokenCallback, getTokenTextRangeCallback) { - if (contextNode) { - if (ignoreTokenCallback(contextNode, token)) { - return ts.skipTrivia(currentSourceText, tokenStartPos); - } - var range = getTokenTextRangeCallback(contextNode, token); - if (range) { - tokenStartPos = range.pos; - } + tokenPos = emitCallback(token, tokenPos); + if (range) + tokenPos = range.end; + if ((emitFlags & 8192) === 0 && tokenPos >= 0) { + emitPos(tokenPos); } - tokenStartPos = ts.skipTrivia(currentSourceText, tokenStartPos); - emitPos(tokenStartPos); - return tokenStartPos; - } - function emitTokenEnd(token, tokenEndPos, contextNode, ignoreTokenCallback, getTokenTextRangeCallback) { - if (contextNode) { - if (ignoreTokenCallback(contextNode, token)) { - return tokenEndPos; - } - var range = getTokenTextRangeCallback(contextNode, token); - if (range) { - tokenEndPos = range.end; - } - } - emitPos(tokenEndPos); - return tokenEndPos; - } - function changeEmitSourcePos() { - ts.Debug.assert(!modifyLastSourcePos); - modifyLastSourcePos = true; + return tokenPos; } function setSourceFile(sourceFile) { + if (disabled) { + return; + } currentSourceFile = sourceFile; currentSourceText = currentSourceFile.text; var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; @@ -43961,6 +45323,9 @@ var ts; } } function getText() { + if (disabled) { + return; + } encodeLastRecordedSourceMapSpan(); return ts.stringify({ version: 3, @@ -43973,6 +45338,9 @@ var ts; }); } function getSourceMappingURL() { + if (disabled) { + return; + } if (compilerOptions.inlineSourceMap) { var base64SourceMapText = ts.convertToBase64(getText()); return sourceMapData.jsSourceMappingURL = "data:application/json;base64," + base64SourceMapText; @@ -43982,46 +45350,7 @@ var ts; } } } - function createSourceMapWriterWithExtendedDiagnostics(host, writer) { - var _a = createSourceMapWriterWorker(host, writer), initialize = _a.initialize, reset = _a.reset, getSourceMapData = _a.getSourceMapData, setSourceFile = _a.setSourceFile, emitPos = _a.emitPos, emitStart = _a.emitStart, emitEnd = _a.emitEnd, emitTokenStart = _a.emitTokenStart, emitTokenEnd = _a.emitTokenEnd, changeEmitSourcePos = _a.changeEmitSourcePos, stopOverridingSpan = _a.stopOverridingSpan, getText = _a.getText, getSourceMappingURL = _a.getSourceMappingURL; - return { - initialize: initialize, - reset: reset, - getSourceMapData: getSourceMapData, - setSourceFile: setSourceFile, - emitPos: function (pos) { - ts.performance.mark("sourcemapStart"); - emitPos(pos); - ts.performance.measure("sourceMapTime", "sourcemapStart"); - }, - emitStart: function (range, contextNode, ignoreNodeCallback, ignoreChildrenCallback, getTextRangeCallback) { - ts.performance.mark("emitSourcemap:emitStart"); - emitStart(range, contextNode, ignoreNodeCallback, ignoreChildrenCallback, getTextRangeCallback); - ts.performance.measure("sourceMapTime", "emitSourcemap:emitStart"); - }, - emitEnd: function (range, contextNode, ignoreNodeCallback, ignoreChildrenCallback, getTextRangeCallback) { - ts.performance.mark("emitSourcemap:emitEnd"); - emitEnd(range, contextNode, ignoreNodeCallback, ignoreChildrenCallback, getTextRangeCallback); - ts.performance.measure("sourceMapTime", "emitSourcemap:emitEnd"); - }, - emitTokenStart: function (token, tokenStartPos, contextNode, ignoreTokenCallback, getTokenTextRangeCallback) { - ts.performance.mark("emitSourcemap:emitTokenStart"); - tokenStartPos = emitTokenStart(token, tokenStartPos, contextNode, ignoreTokenCallback, getTokenTextRangeCallback); - ts.performance.measure("sourceMapTime", "emitSourcemap:emitTokenStart"); - return tokenStartPos; - }, - emitTokenEnd: function (token, tokenEndPos, contextNode, ignoreTokenCallback, getTokenTextRangeCallback) { - ts.performance.mark("emitSourcemap:emitTokenEnd"); - tokenEndPos = emitTokenEnd(token, tokenEndPos, contextNode, ignoreTokenCallback, getTokenTextRangeCallback); - ts.performance.measure("sourceMapTime", "emitSourcemap:emitTokenEnd"); - return tokenEndPos; - }, - changeEmitSourcePos: changeEmitSourcePos, - stopOverridingSpan: stopOverridingSpan, - getText: getText, - getSourceMappingURL: getSourceMappingURL - }; - } + ts.createSourceMapWriter = createSourceMapWriter; var base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; function base64FormatEncode(inValue) { if (inValue < 64) { @@ -44071,20 +45400,22 @@ var ts; emitBodyWithDetachedComments: emitBodyWithDetachedComments, emitTrailingCommentsOfPosition: emitTrailingCommentsOfPosition }; - function emitNodeWithComments(node, emitCallback) { + function emitNodeWithComments(emitContext, node, emitCallback) { if (disabled) { - emitCallback(node); + emitCallback(emitContext, node); return; } if (node) { - var _a = node.commentRange || node, pos = _a.pos, end = _a.end; - var emitFlags = node.emitFlags; + var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; + var emitFlags = ts.getEmitFlags(node); if ((pos < 0 && end < 0) || (pos === end)) { if (emitFlags & 65536) { - disableCommentsAndEmit(node, emitCallback); + disabled = true; + emitCallback(emitContext, node); + disabled = false; } else { - emitCallback(node); + emitCallback(emitContext, node); } } else { @@ -44113,10 +45444,12 @@ var ts; ts.performance.measure("commentTime", "preEmitNodeWithComment"); } if (emitFlags & 65536) { - disableCommentsAndEmit(node, emitCallback); + disabled = true; + emitCallback(emitContext, node); + disabled = false; } else { - emitCallback(node); + emitCallback(emitContext, node); } if (extendedDiagnostics) { ts.performance.mark("beginEmitNodeWithComment"); @@ -44138,7 +45471,7 @@ var ts; ts.performance.mark("preEmitBodyWithDetachedComments"); } var pos = detachedRange.pos, end = detachedRange.end; - var emitFlags = node.emitFlags; + var emitFlags = ts.getEmitFlags(node); var skipLeadingComments = pos < 0 || (emitFlags & 16384) !== 0; var skipTrailingComments = disabled || end < 0 || (emitFlags & 32768) !== 0; if (!skipLeadingComments) { @@ -44147,8 +45480,10 @@ var ts; if (extendedDiagnostics) { ts.performance.measure("commentTime", "preEmitBodyWithDetachedComments"); } - if (emitFlags & 65536) { - disableCommentsAndEmit(node, emitCallback); + if (emitFlags & 65536 && !disabled) { + disabled = true; + emitCallback(node); + disabled = false; } else { emitCallback(node); @@ -44256,16 +45591,6 @@ var ts; currentLineMap = ts.getLineStarts(currentSourceFile); detachedCommentsInfo = undefined; } - function disableCommentsAndEmit(node, emitCallback) { - if (disabled) { - emitCallback(node); - } - else { - disabled = true; - emitCallback(node); - disabled = false; - } - } function hasDetachedComments(pos) { return detachedCommentsInfo !== undefined && ts.lastOrUndefined(detachedCommentsInfo).nodePos === pos; } @@ -44311,7 +45636,9 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function emitFiles(resolver, host, targetSourceFile) { + var id = function (s) { return s; }; + var nullTransformers = [function (ctx) { return id; }]; + function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles) { var delimiters = createDelimiterMap(); var brackets = createBracketsMap(); 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};"; @@ -44319,7 +45646,7 @@ var ts; 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, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments)).next());\n });\n};"; + var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments)).next());\n });\n};"; var generatorHelper = "\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t;\n return { next: verb(0), \"throw\": verb(1), \"return\": verb(2) };\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};"; var exportStarHelper = "\nfunction __export(m) {\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\n}"; var umdHelper = "\n(function (dependencies, 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(dependencies, factory);\n }\n})"; @@ -44332,11 +45659,11 @@ var ts; var emittedFilesList = compilerOptions.listEmittedFiles ? [] : undefined; var emitterDiagnostics = ts.createDiagnosticCollection(); var newLine = host.getNewLine(); - var transformers = ts.getTransformers(compilerOptions); + var transformers = emitOnlyDtsFiles ? nullTransformers : ts.getTransformers(compilerOptions); var writer = ts.createTextWriter(newLine); var write = writer.write, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; var sourceMap = ts.createSourceMapWriter(host, writer); - var emitStart = sourceMap.emitStart, emitEnd = sourceMap.emitEnd, emitTokenStart = sourceMap.emitTokenStart, emitTokenEnd = sourceMap.emitTokenEnd; + var emitNodeWithSourceMap = sourceMap.emitNodeWithSourceMap, emitTokenWithSourceMap = sourceMap.emitTokenWithSourceMap; var comments = ts.createCommentWriter(host, writer, sourceMap); var emitNodeWithComments = comments.emitNodeWithComments, emitBodyWithDetachedComments = comments.emitBodyWithDetachedComments, emitTrailingCommentsOfPosition = comments.emitTrailingCommentsOfPosition; var nodeIdToGeneratedName; @@ -44353,14 +45680,17 @@ var ts; var awaiterEmitted; var isOwnFileEmit; var emitSkipped = false; + var sourceFiles = ts.getSourceFilesToEmit(host, targetSourceFile); ts.performance.mark("beforeTransform"); - var transformed = ts.transformFiles(resolver, host, ts.getSourceFilesToEmit(host, targetSourceFile), transformers); + var _a = ts.transformFiles(resolver, host, sourceFiles, transformers), transformed = _a.transformed, emitNodeWithSubstitution = _a.emitNodeWithSubstitution, emitNodeWithNotification = _a.emitNodeWithNotification; ts.performance.measure("transformTime", "beforeTransform"); - var getTokenSourceMapRange = transformed.getTokenSourceMapRange, isSubstitutionEnabled = transformed.isSubstitutionEnabled, isEmitNotificationEnabled = transformed.isEmitNotificationEnabled, onSubstituteNode = transformed.onSubstituteNode, onEmitNode = transformed.onEmitNode; ts.performance.mark("beforePrint"); - ts.forEachTransformedEmitFile(host, transformed.getSourceFiles(), emitFile); - transformed.dispose(); + ts.forEachTransformedEmitFile(host, transformed, emitFile, emitOnlyDtsFiles); ts.performance.measure("printTime", "beforePrint"); + for (var _b = 0, sourceFiles_4 = sourceFiles; _b < sourceFiles_4.length; _b++) { + var sourceFile = sourceFiles_4[_b]; + ts.disposeEmitNodes(sourceFile); + } return { emitSkipped: emitSkipped, diagnostics: emitterDiagnostics.getDiagnostics(), @@ -44369,16 +45699,20 @@ var ts; }; function emitFile(jsFilePath, sourceMapFilePath, declarationFilePath, sourceFiles, isBundledEmit) { if (!host.isEmitBlocked(jsFilePath) && !compilerOptions.noEmit) { - printFile(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit); + if (!emitOnlyDtsFiles) { + printFile(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit); + } } else { emitSkipped = true; } if (declarationFilePath) { - emitSkipped = ts.writeDeclarationFile(declarationFilePath, ts.getOriginalSourceFiles(sourceFiles), isBundledEmit, host, resolver, emitterDiagnostics) || emitSkipped; + emitSkipped = ts.writeDeclarationFile(declarationFilePath, ts.getOriginalSourceFiles(sourceFiles), isBundledEmit, host, resolver, emitterDiagnostics, emitOnlyDtsFiles) || emitSkipped; } if (!emitSkipped && emittedFilesList) { - emittedFilesList.push(jsFilePath); + if (!emitOnlyDtsFiles) { + emittedFilesList.push(jsFilePath); + } if (sourceMapFilePath) { emittedFilesList.push(sourceMapFilePath); } @@ -44394,8 +45728,8 @@ var ts; generatedNameSet = ts.createMap(); isOwnFileEmit = !isBundledEmit; if (isBundledEmit && moduleKind) { - for (var _a = 0, sourceFiles_4 = sourceFiles; _a < sourceFiles_4.length; _a++) { - var sourceFile = sourceFiles_4[_a]; + for (var _a = 0, sourceFiles_5 = sourceFiles; _a < sourceFiles_5.length; _a++) { + var sourceFile = sourceFiles_5[_a]; emitEmitHelpers(sourceFile); } } @@ -44431,73 +45765,61 @@ var ts; currentFileIdentifiers = node.identifiers; sourceMap.setSourceFile(node); comments.setSourceFile(node); - emitNodeWithNotification(node, emitWorker); + pipelineEmitWithNotification(0, node); } function emit(node) { - emitNodeWithNotification(node, emitWithComments); - } - function emitWithComments(node) { - emitNodeWithComments(node, emitWithSourceMap); - } - function emitWithSourceMap(node) { - emitNodeWithSourceMap(node, emitWorker); + pipelineEmitWithNotification(3, node); } function emitIdentifierName(node) { - if (node) { - emitNodeWithNotification(node, emitIdentifierNameWithComments); - } - } - function emitIdentifierNameWithComments(node) { - emitNodeWithComments(node, emitWorker); + pipelineEmitWithNotification(2, node); } function emitExpression(node) { - emitNodeWithNotification(node, emitExpressionWithComments); + pipelineEmitWithNotification(1, node); } - function emitExpressionWithComments(node) { - emitNodeWithComments(node, emitExpressionWithSourceMap); + function pipelineEmitWithNotification(emitContext, node) { + emitNodeWithNotification(emitContext, node, pipelineEmitWithComments); } - function emitExpressionWithSourceMap(node) { - emitNodeWithSourceMap(node, emitExpressionWorker); - } - function emitNodeWithNotification(node, emitCallback) { - if (node) { - if (isEmitNotificationEnabled(node)) { - onEmitNode(node, emitCallback); - } - else { - emitCallback(node); - } - } - } - function emitNodeWithSourceMap(node, emitCallback) { - if (node) { - emitStart(node, node, shouldSkipLeadingSourceMapForNode, shouldSkipSourceMapForChildren, getSourceMapRange); - emitCallback(node); - emitEnd(node, node, shouldSkipTrailingSourceMapForNode, shouldSkipSourceMapForChildren, getSourceMapRange); - } - } - function getSourceMapRange(node) { - return node.sourceMapRange || node; - } - function shouldSkipLeadingCommentsForNode(node) { - return ts.isNotEmittedStatement(node) - || (node.emitFlags & 16384) !== 0; - } - function shouldSkipLeadingSourceMapForNode(node) { - return ts.isNotEmittedStatement(node) - || (node.emitFlags & 512) !== 0; - } - function shouldSkipTrailingSourceMapForNode(node) { - return ts.isNotEmittedStatement(node) - || (node.emitFlags & 1024) !== 0; - } - function shouldSkipSourceMapForChildren(node) { - return (node.emitFlags & 2048) !== 0; - } - function emitWorker(node) { - if (tryEmitSubstitute(node, emitWorker, false)) { + function pipelineEmitWithComments(emitContext, node) { + if (emitContext === 0) { + pipelineEmitWithSourceMap(emitContext, node); return; } + emitNodeWithComments(emitContext, node, pipelineEmitWithSourceMap); + } + function pipelineEmitWithSourceMap(emitContext, node) { + if (emitContext === 0 + || emitContext === 2) { + pipelineEmitWithSubstitution(emitContext, node); + return; + } + emitNodeWithSourceMap(emitContext, node, pipelineEmitWithSubstitution); + } + function pipelineEmitWithSubstitution(emitContext, node) { + emitNodeWithSubstitution(emitContext, node, pipelineEmitForContext); + } + function pipelineEmitForContext(emitContext, node) { + switch (emitContext) { + case 0: return pipelineEmitInSourceFileContext(node); + case 2: return pipelineEmitInIdentifierNameContext(node); + case 3: return pipelineEmitInUnspecifiedContext(node); + case 1: return pipelineEmitInExpressionContext(node); + } + } + function pipelineEmitInSourceFileContext(node) { + var kind = node.kind; + switch (kind) { + case 256: + return emitSourceFile(node); + } + } + function pipelineEmitInIdentifierNameContext(node) { + var kind = node.kind; + switch (kind) { + case 69: + return emitIdentifier(node); + } + } + function pipelineEmitInUnspecifiedContext(node) { var kind = node.kind; switch (kind) { case 12: @@ -44524,7 +45846,8 @@ var ts; case 132: case 133: case 137: - return writeTokenNode(node); + writeTokenText(kind); + return; case 139: return emitQualifiedName(node); case 140: @@ -44700,17 +46023,12 @@ var ts; return emitShorthandPropertyAssignment(node); case 255: return emitEnumMember(node); - case 256: - return emitSourceFile(node); } if (ts.isExpression(node)) { - return emitExpressionWorker(node); + return pipelineEmitWithSubstitution(1, node); } } - function emitExpressionWorker(node) { - if (tryEmitSubstitute(node, emitExpressionWorker, true)) { - return; - } + function pipelineEmitInExpressionContext(node) { var kind = node.kind; switch (kind) { case 8: @@ -44726,7 +46044,8 @@ var ts; case 95: case 99: case 97: - return writeTokenNode(node); + writeTokenText(kind); + return; case 170: return emitArrayLiteralExpression(node); case 171: @@ -44804,7 +46123,7 @@ var ts; } } function emitIdentifier(node) { - if (node.emitFlags & 16) { + if (ts.getEmitFlags(node) & 16) { writeLines(umdHelper); } else { @@ -45019,7 +46338,7 @@ var ts; write("{}"); } else { - var indentedFlag = node.emitFlags & 524288; + var indentedFlag = ts.getEmitFlags(node) & 524288; if (indentedFlag) { increaseIndent(); } @@ -45032,21 +46351,18 @@ var ts; } } function emitPropertyAccessExpression(node) { - if (tryEmitConstantValue(node)) { - return; - } var indentBeforeDot = false; var indentAfterDot = false; - if (!(node.emitFlags & 1048576)) { + if (!(ts.getEmitFlags(node) & 1048576)) { var dotRangeStart = node.expression.end; var dotRangeEnd = ts.skipTrivia(currentText, node.expression.end) + 1; var dotToken = { kind: 21, pos: dotRangeStart, end: dotRangeEnd }; indentBeforeDot = needsIndentation(node, node.expression, dotToken); indentAfterDot = needsIndentation(node, dotToken, node.name); } - var shouldEmitDotDot = !indentBeforeDot && needsDotDotForPropertyAccess(node.expression); emitExpression(node.expression); increaseIndentIf(indentBeforeDot); + var shouldEmitDotDot = !indentBeforeDot && needsDotDotForPropertyAccess(node.expression); write(shouldEmitDotDot ? ".." : "."); increaseIndentIf(indentAfterDot); emit(node.name); @@ -45057,15 +46373,14 @@ var ts; var text = getLiteralTextOfNode(expression); return text.indexOf(ts.tokenToString(21)) < 0; } - else { - var constantValue = tryGetConstEnumValue(expression); - return isFinite(constantValue) && Math.floor(constantValue) === constantValue; + else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { + var constantValue = ts.getConstantValue(expression); + return isFinite(constantValue) + && Math.floor(constantValue) === constantValue + && compilerOptions.removeComments; } } function emitElementAccessExpression(node) { - if (tryEmitConstantValue(node)) { - return; - } emitExpression(node.expression); write("["); emitExpression(node.argumentExpression); @@ -45220,7 +46535,7 @@ var ts; } } function emitBlockStatements(node) { - if (node.emitFlags & 32) { + if (ts.getEmitFlags(node) & 32) { emitList(node, node.statements, 384); } else { @@ -45395,11 +46710,11 @@ var ts; var body = node.body; if (body) { if (ts.isBlock(body)) { - var indentedFlag = node.emitFlags & 524288; + var indentedFlag = ts.getEmitFlags(node) & 524288; if (indentedFlag) { increaseIndent(); } - if (node.emitFlags & 4194304) { + if (ts.getEmitFlags(node) & 4194304) { emitSignatureHead(node); emitBlockFunctionBody(node, body); } @@ -45431,7 +46746,7 @@ var ts; emitWithPrefix(": ", node.type); } function shouldEmitBlockFunctionBodyOnSingleLine(parentNode, body) { - if (body.emitFlags & 32) { + if (ts.getEmitFlags(body) & 32) { return true; } if (body.multiLine) { @@ -45486,7 +46801,7 @@ var ts; emitModifiers(node, node.modifiers); write("class"); emitNodeWithPrefix(" ", node.name, emitIdentifierName); - var indentedFlag = node.emitFlags & 524288; + var indentedFlag = ts.getEmitFlags(node) & 524288; if (indentedFlag) { increaseIndent(); } @@ -45548,7 +46863,7 @@ var ts; emit(body); } function emitModuleBlock(node) { - if (isSingleLineEmptyBlock(node)) { + if (isEmptyBlock(node)) { write("{ }"); } else { @@ -45745,8 +47060,8 @@ var ts; emit(node.name); write(": "); var initializer = node.initializer; - if (!shouldSkipLeadingCommentsForNode(initializer)) { - var commentRange = initializer.commentRange || initializer; + if ((ts.getEmitFlags(initializer) & 16384) === 0) { + var commentRange = ts.getCommentRange(initializer); emitTrailingCommentsOfPosition(commentRange.pos); } emitExpression(initializer); @@ -45794,7 +47109,7 @@ var ts; return statements.length; } function emitHelpers(node) { - var emitFlags = node.emitFlags; + var emitFlags = ts.getEmitFlags(node); var helpersEmitted = false; if (emitFlags & 1) { helpersEmitted = emitEmitHelpers(currentSourceFile); @@ -45900,31 +47215,6 @@ var ts; write(suffix); } } - function tryEmitSubstitute(node, emitNode, isExpression) { - if (isSubstitutionEnabled(node) && (node.emitFlags & 128) === 0) { - var substitute = onSubstituteNode(node, isExpression); - if (substitute !== node) { - substitute.emitFlags |= 128; - emitNode(substitute); - return true; - } - } - return false; - } - function tryEmitConstantValue(node) { - var constantValue = tryGetConstEnumValue(node); - if (constantValue !== undefined) { - write(String(constantValue)); - if (!compilerOptions.removeComments) { - var propertyName = ts.isPropertyAccessExpression(node) - ? ts.declarationNameToString(node.name) - : getTextOfNode(node.argumentExpression); - write(" /* " + propertyName + " */"); - } - return true; - } - return false; - } function emitEmbeddedStatement(node) { if (ts.isBlock(node)) { write(" "); @@ -46024,7 +47314,7 @@ var ts; } } if (shouldEmitInterveningComments) { - var commentRange = child.commentRange || child; + var commentRange = ts.getCommentRange(child); emitTrailingCommentsOfPosition(commentRange.pos); } else { @@ -46066,27 +47356,12 @@ var ts; } } function writeToken(token, pos, contextNode) { - var tokenStartPos = emitTokenStart(token, pos, contextNode, shouldSkipLeadingSourceMapForToken, getTokenSourceMapRange); - var tokenEndPos = writeTokenText(token, tokenStartPos); - return emitTokenEnd(token, tokenEndPos, contextNode, shouldSkipTrailingSourceMapForToken, getTokenSourceMapRange); - } - function shouldSkipLeadingSourceMapForToken(contextNode) { - return (contextNode.emitFlags & 4096) !== 0; - } - function shouldSkipTrailingSourceMapForToken(contextNode) { - return (contextNode.emitFlags & 8192) !== 0; + return emitTokenWithSourceMap(contextNode, token, pos, writeTokenText); } function writeTokenText(token, pos) { var tokenString = ts.tokenToString(token); write(tokenString); - return ts.positionIsSynthesized(pos) ? -1 : pos + tokenString.length; - } - function writeTokenNode(node) { - if (node) { - emitStart(node, node, shouldSkipLeadingSourceMapForNode, shouldSkipSourceMapForChildren, getSourceMapRange); - writeTokenText(node.kind); - emitEnd(node, node, shouldSkipTrailingSourceMapForNode, shouldSkipSourceMapForChildren, getSourceMapRange); - } + return pos < 0 ? pos : pos + tokenString.length; } function increaseIndentIf(value, valueToWriteWhenNotIndenting) { if (value) { @@ -46225,17 +47500,12 @@ var ts; } return ts.getLiteralText(node, currentSourceFile, languageVersion); } - function tryGetConstEnumValue(node) { - if (compilerOptions.isolatedModules) { - return undefined; - } - return ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node) - ? resolver.getConstantValue(node) - : undefined; - } function isSingleLineEmptyBlock(block) { return !block.multiLine - && block.statements.length === 0 + && isEmptyBlock(block); + } + function isEmptyBlock(block) { + return block.statements.length === 0 && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function isUniqueName(name) { @@ -46255,21 +47525,21 @@ var ts; } function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name_43 = flags === 268435456 ? "_i" : "_n"; - if (isUniqueName(name_43)) { + var name_44 = flags === 268435456 ? "_i" : "_n"; + if (isUniqueName(name_44)) { tempFlags |= flags; - return name_43; + return name_44; } } while (true) { var count = tempFlags & 268435455; tempFlags++; if (count !== 8 && count !== 13) { - var name_44 = count < 26 + var name_45 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); - if (isUniqueName(name_44)) { - return name_44; + if (isUniqueName(name_45)) { + return name_45; } } } @@ -46445,581 +47715,6 @@ var ts; return ts.getNormalizedPathFromPathComponents(commonPathComponents); } ts.computeCommonSourceDirectoryOfFilenames = computeCommonSourceDirectoryOfFilenames; - function trace(host, message) { - host.trace(ts.formatMessage.apply(undefined, arguments)); - } - function isTraceEnabled(compilerOptions, host) { - return compilerOptions.traceResolution && host.trace !== undefined; - } - function hasZeroOrOneAsteriskCharacter(str) { - var seenAsterisk = false; - for (var i = 0; i < str.length; i++) { - if (str.charCodeAt(i) === 42) { - if (!seenAsterisk) { - seenAsterisk = true; - } - else { - return false; - } - } - } - return true; - } - ts.hasZeroOrOneAsteriskCharacter = hasZeroOrOneAsteriskCharacter; - function createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations) { - return { resolvedModule: resolvedFileName ? { resolvedFileName: resolvedFileName, isExternalLibraryImport: isExternalLibraryImport } : undefined, failedLookupLocations: failedLookupLocations }; - } - function moduleHasNonRelativeName(moduleName) { - return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); - } - function tryReadTypesSection(packageJsonPath, baseDirectory, state) { - var jsonContent = readJson(packageJsonPath, state.host); - function tryReadFromField(fieldName) { - if (ts.hasProperty(jsonContent, fieldName)) { - var typesFile = jsonContent[fieldName]; - if (typeof typesFile === "string") { - var typesFilePath_1 = ts.normalizePath(ts.combinePaths(baseDirectory, typesFile)); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath_1); - } - return typesFilePath_1; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof typesFile); - } - } - } - } - var typesFilePath = tryReadFromField("typings") || tryReadFromField("types"); - if (typesFilePath) { - return typesFilePath; - } - if (state.compilerOptions.allowJs && jsonContent.main && typeof jsonContent.main === "string") { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0, jsonContent.main); - } - var mainFilePath = ts.normalizePath(ts.combinePaths(baseDirectory, jsonContent.main)); - return mainFilePath; - } - return undefined; - } - function readJson(path, host) { - try { - var jsonText = host.readFile(path); - return jsonText ? JSON.parse(jsonText) : {}; - } - catch (e) { - return {}; - } - } - var typeReferenceExtensions = [".d.ts"]; - function getEffectiveTypeRoots(options, host) { - if (options.typeRoots) { - return options.typeRoots; - } - var currentDirectory; - if (options.configFilePath) { - currentDirectory = ts.getDirectoryPath(options.configFilePath); - } - else if (host.getCurrentDirectory) { - currentDirectory = host.getCurrentDirectory(); - } - return currentDirectory && getDefaultTypeRoots(currentDirectory, host); - } - ts.getEffectiveTypeRoots = getEffectiveTypeRoots; - function getDefaultTypeRoots(currentDirectory, host) { - if (!host.directoryExists) { - return [ts.combinePaths(currentDirectory, nodeModulesAtTypes)]; - } - var typeRoots; - while (true) { - var atTypes = ts.combinePaths(currentDirectory, nodeModulesAtTypes); - if (host.directoryExists(atTypes)) { - (typeRoots || (typeRoots = [])).push(atTypes); - } - var parent_15 = ts.getDirectoryPath(currentDirectory); - if (parent_15 === currentDirectory) { - break; - } - currentDirectory = parent_15; - } - return typeRoots; - } - var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types"); - function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host) { - var traceEnabled = isTraceEnabled(options, host); - var moduleResolutionState = { - compilerOptions: options, - host: host, - skipTsx: true, - traceEnabled: traceEnabled - }; - var typeRoots = getEffectiveTypeRoots(options, host); - if (traceEnabled) { - if (containingFile === undefined) { - if (typeRoots === undefined) { - trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set, typeReferenceDirectiveName); - } - else { - trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1, typeReferenceDirectiveName, typeRoots); - } - } - else { - if (typeRoots === undefined) { - trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set, typeReferenceDirectiveName, containingFile); - } - else { - trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, typeRoots); - } - } - } - var failedLookupLocations = []; - if (typeRoots && typeRoots.length) { - if (traceEnabled) { - trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", ")); - } - var primarySearchPaths = typeRoots; - for (var _i = 0, primarySearchPaths_1 = primarySearchPaths; _i < primarySearchPaths_1.length; _i++) { - var typeRoot = primarySearchPaths_1[_i]; - var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); - var candidateDirectory = ts.getDirectoryPath(candidate); - var resolvedFile_1 = loadNodeModuleFromDirectory(typeReferenceExtensions, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState); - if (resolvedFile_1) { - if (traceEnabled) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile_1, true); - } - return { - resolvedTypeReferenceDirective: { primary: true, resolvedFileName: resolvedFile_1 }, - failedLookupLocations: failedLookupLocations - }; - } - } - } - else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths); - } - } - var resolvedFile; - var initialLocationForSecondaryLookup; - if (containingFile) { - initialLocationForSecondaryLookup = ts.getDirectoryPath(containingFile); - } - if (initialLocationForSecondaryLookup !== undefined) { - if (traceEnabled) { - trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); - } - resolvedFile = loadModuleFromNodeModules(typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState); - if (traceEnabled) { - if (resolvedFile) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile, false); - } - else { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); - } - } - } - else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder); - } - } - return { - resolvedTypeReferenceDirective: resolvedFile - ? { primary: false, resolvedFileName: resolvedFile } - : undefined, - failedLookupLocations: failedLookupLocations - }; - } - ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective; - function resolveModuleName(moduleName, containingFile, compilerOptions, host) { - var traceEnabled = isTraceEnabled(compilerOptions, host); - if (traceEnabled) { - trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); - } - var moduleResolution = compilerOptions.moduleResolution; - if (moduleResolution === undefined) { - moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; - if (traceEnabled) { - trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); - } - } - else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); - } - } - var result; - switch (moduleResolution) { - case ts.ModuleResolutionKind.NodeJs: - result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host); - break; - case ts.ModuleResolutionKind.Classic: - result = classicNameResolver(moduleName, containingFile, compilerOptions, host); - break; - } - if (traceEnabled) { - if (result.resolvedModule) { - trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.resolvedModule.resolvedFileName); - } - else { - trace(host, ts.Diagnostics.Module_name_0_was_not_resolved, moduleName); - } - } - return result; - } - ts.resolveModuleName = resolveModuleName; - function tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { - if (moduleHasNonRelativeName(moduleName)) { - return tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state); - } - else { - return tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state); - } - } - function tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { - if (!state.compilerOptions.rootDirs) { - return undefined; - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0, moduleName); - } - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var matchedRootDir; - var matchedNormalizedPrefix; - for (var _i = 0, _a = state.compilerOptions.rootDirs; _i < _a.length; _i++) { - var rootDir = _a[_i]; - var normalizedRoot = ts.normalizePath(rootDir); - if (!ts.endsWith(normalizedRoot, ts.directorySeparator)) { - normalizedRoot += ts.directorySeparator; - } - var isLongestMatchingPrefix = ts.startsWith(candidate, normalizedRoot) && - (matchedNormalizedPrefix === undefined || matchedNormalizedPrefix.length < normalizedRoot.length); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Checking_if_0_is_the_longest_matching_prefix_for_1_2, normalizedRoot, candidate, isLongestMatchingPrefix); - } - if (isLongestMatchingPrefix) { - matchedNormalizedPrefix = normalizedRoot; - matchedRootDir = rootDir; - } - } - if (matchedNormalizedPrefix) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Longest_matching_prefix_for_0_is_1, candidate, matchedNormalizedPrefix); - } - var suffix = candidate.substr(matchedNormalizedPrefix.length); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, matchedNormalizedPrefix, candidate); - } - var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(containingDirectory, state.host), state); - if (resolvedFileName) { - return resolvedFileName; - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Trying_other_entries_in_rootDirs); - } - for (var _b = 0, _c = state.compilerOptions.rootDirs; _b < _c.length; _b++) { - var rootDir = _c[_b]; - if (rootDir === matchedRootDir) { - continue; - } - var candidate_1 = ts.combinePaths(ts.normalizePath(rootDir), suffix); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, rootDir, candidate_1); - } - var baseDirectory = ts.getDirectoryPath(candidate_1); - var resolvedFileName_1 = loader(candidate_1, supportedExtensions, failedLookupLocations, !directoryProbablyExists(baseDirectory, state.host), state); - if (resolvedFileName_1) { - return resolvedFileName_1; - } - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Module_resolution_using_rootDirs_has_failed); - } - } - return undefined; - } - function tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state) { - if (!state.compilerOptions.baseUrl) { - return undefined; - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, state.compilerOptions.baseUrl, moduleName); - } - var matchedPattern = undefined; - if (state.compilerOptions.paths) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); - } - matchedPattern = matchPatternOrExact(ts.getOwnKeys(state.compilerOptions.paths), moduleName); - } - if (matchedPattern) { - var matchedStar = typeof matchedPattern === "string" ? undefined : matchedText(matchedPattern, moduleName); - var matchedPatternText = typeof matchedPattern === "string" ? matchedPattern : patternText(matchedPattern); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPatternText); - } - for (var _i = 0, _a = state.compilerOptions.paths[matchedPatternText]; _i < _a.length; _i++) { - var subst = _a[_i]; - var path = matchedStar ? subst.replace("*", matchedStar) : subst; - var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, path)); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path); - } - var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); - if (resolvedFileName) { - return resolvedFileName; - } - } - return undefined; - } - else { - var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, moduleName)); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Resolving_module_name_0_relative_to_base_url_1_2, moduleName, state.compilerOptions.baseUrl, candidate); - } - return loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); - } - } - function matchPatternOrExact(patternStrings, candidate) { - var patterns = []; - for (var _i = 0, patternStrings_1 = patternStrings; _i < patternStrings_1.length; _i++) { - var patternString = patternStrings_1[_i]; - var pattern = tryParsePattern(patternString); - if (pattern) { - patterns.push(pattern); - } - else if (patternString === candidate) { - return patternString; - } - } - return findBestPatternMatch(patterns, function (_) { return _; }, candidate); - } - function patternText(_a) { - var prefix = _a.prefix, suffix = _a.suffix; - return prefix + "*" + suffix; - } - function matchedText(pattern, candidate) { - ts.Debug.assert(isPatternMatch(pattern, candidate)); - return candidate.substr(pattern.prefix.length, candidate.length - pattern.suffix.length); - } - function findBestPatternMatch(values, getPattern, candidate) { - var matchedValue = undefined; - var longestMatchPrefixLength = -1; - for (var _i = 0, values_1 = values; _i < values_1.length; _i++) { - var v = values_1[_i]; - var pattern = getPattern(v); - if (isPatternMatch(pattern, candidate) && pattern.prefix.length > longestMatchPrefixLength) { - longestMatchPrefixLength = pattern.prefix.length; - matchedValue = v; - } - } - return matchedValue; - } - ts.findBestPatternMatch = findBestPatternMatch; - function isPatternMatch(_a, candidate) { - var prefix = _a.prefix, suffix = _a.suffix; - return candidate.length >= prefix.length + suffix.length && - ts.startsWith(candidate, prefix) && - ts.endsWith(candidate, suffix); - } - function tryParsePattern(pattern) { - ts.Debug.assert(hasZeroOrOneAsteriskCharacter(pattern)); - var indexOfStar = pattern.indexOf("*"); - return indexOfStar === -1 ? undefined : { - prefix: pattern.substr(0, indexOfStar), - suffix: pattern.substr(indexOfStar + 1) - }; - } - ts.tryParsePattern = tryParsePattern; - function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host) { - var containingDirectory = ts.getDirectoryPath(containingFile); - var supportedExtensions = ts.getSupportedExtensions(compilerOptions); - var traceEnabled = isTraceEnabled(compilerOptions, host); - var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: false }; - var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, supportedExtensions, state); - var isExternalLibraryImport = false; - if (!resolvedFileName) { - if (moduleHasNonRelativeName(moduleName)) { - if (traceEnabled) { - trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder, moduleName); - } - resolvedFileName = loadModuleFromNodeModules(moduleName, containingDirectory, failedLookupLocations, state); - isExternalLibraryImport = resolvedFileName !== undefined; - } - else { - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - resolvedFileName = nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, false, state); - } - } - if (resolvedFileName && host.realpath) { - var originalFileName = resolvedFileName; - resolvedFileName = ts.normalizePath(host.realpath(resolvedFileName)); - if (traceEnabled) { - trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, originalFileName, resolvedFileName); - } - } - return createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations); - } - ts.nodeModuleNameResolver = nodeModuleNameResolver; - function nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate); - } - var resolvedFileName = !ts.pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state); - return resolvedFileName || loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, onlyRecordFailures, state); - } - function directoryProbablyExists(directoryName, host) { - return !host.directoryExists || host.directoryExists(directoryName); - } - ts.directoryProbablyExists = directoryProbablyExists; - function loadModuleFromFile(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) { - var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state); - if (resolvedByAddingExtension) { - return resolvedByAddingExtension; - } - if (ts.hasJavaScriptFileExtension(candidate)) { - var extensionless = ts.removeFileExtension(candidate); - if (state.traceEnabled) { - var extension = candidate.substring(extensionless.length); - trace(state.host, ts.Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension); - } - return tryAddingExtensions(extensionless, extensions, failedLookupLocation, onlyRecordFailures, state); - } - } - function tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) { - if (!onlyRecordFailures) { - var directory = ts.getDirectoryPath(candidate); - if (directory) { - onlyRecordFailures = !directoryProbablyExists(directory, state.host); - } - } - return ts.forEach(extensions, function (ext) { - return !(state.skipTsx && ts.isJsxOrTsxExtension(ext)) && tryFile(candidate + ext, failedLookupLocation, onlyRecordFailures, state); - }); - } - function tryFile(fileName, failedLookupLocation, onlyRecordFailures, state) { - if (!onlyRecordFailures && state.host.fileExists(fileName)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); - } - return fileName; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); - } - failedLookupLocation.push(fileName); - return undefined; - } - } - function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocation, onlyRecordFailures, state) { - var packageJsonPath = pathToPackageJson(candidate); - var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); - if (directoryExists && state.host.fileExists(packageJsonPath)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); - } - var typesFile = tryReadTypesSection(packageJsonPath, candidate, state); - if (typesFile) { - var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(typesFile), state.host); - var result = tryFile(typesFile, failedLookupLocation, onlyRecordFailures_1, state) || - tryAddingExtensions(typesFile, extensions, failedLookupLocation, onlyRecordFailures_1, state); - if (result) { - return result; - } - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_does_not_have_types_field); - } - } - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); - } - failedLookupLocation.push(packageJsonPath); - } - return loadModuleFromFile(ts.combinePaths(candidate, "index"), extensions, failedLookupLocation, !directoryExists, state); - } - function pathToPackageJson(directory) { - return ts.combinePaths(directory, "package.json"); - } - function loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state) { - var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); - var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); - var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); - var supportedExtensions = ts.getSupportedExtensions(state.compilerOptions); - var result = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, !nodeModulesFolderExists, state); - if (result) { - return result; - } - result = loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); - if (result) { - return result; - } - } - function loadModuleFromNodeModules(moduleName, directory, failedLookupLocations, state) { - directory = ts.normalizeSlashes(directory); - while (true) { - var baseName = ts.getBaseFileName(directory); - if (baseName !== "node_modules") { - var packageResult = loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state); - if (packageResult && ts.hasTypeScriptFileExtension(packageResult)) { - return packageResult; - } - else { - var typesResult = loadModuleFromNodeModulesFolder(ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); - if (typesResult || packageResult) { - return typesResult || packageResult; - } - } - } - var parentPath = ts.getDirectoryPath(directory); - if (parentPath === directory) { - break; - } - directory = parentPath; - } - return undefined; - } - function classicNameResolver(moduleName, containingFile, compilerOptions, host) { - var traceEnabled = isTraceEnabled(compilerOptions, host); - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: !compilerOptions.jsx }; - var failedLookupLocations = []; - var supportedExtensions = ts.getSupportedExtensions(compilerOptions); - var containingDirectory = ts.getDirectoryPath(containingFile); - var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, supportedExtensions, state); - if (resolvedFileName) { - return createResolvedModule(resolvedFileName, false, failedLookupLocations); - } - var referencedSourceFile; - if (moduleHasNonRelativeName(moduleName)) { - while (true) { - var searchName = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - referencedSourceFile = loadModuleFromFile(searchName, supportedExtensions, failedLookupLocations, false, state); - if (referencedSourceFile) { - break; - } - var parentPath = ts.getDirectoryPath(containingDirectory); - if (parentPath === containingDirectory) { - break; - } - containingDirectory = parentPath; - } - } - else { - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - referencedSourceFile = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, false, state); - } - return referencedSourceFile - ? { resolvedModule: { resolvedFileName: referencedSourceFile }, failedLookupLocations: failedLookupLocations } - : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; - } - ts.classicNameResolver = classicNameResolver; function createCompilerHost(options, setParentNodes) { var existingDirectories = ts.createMap(); function getCanonicalFileName(fileName) { @@ -47121,7 +47816,7 @@ var ts; readFile: function (fileName) { return ts.sys.readFile(fileName); }, trace: function (s) { return ts.sys.write(s + newLine); }, directoryExists: function (directoryName) { return ts.sys.directoryExists(directoryName); }, - getEnvironmentVariable: function (name) { return ts.getEnvironmentVariable(name, undefined); }, + getEnvironmentVariable: function (name) { return ts.sys.getEnvironmentVariable ? ts.sys.getEnvironmentVariable(name) : ""; }, getDirectories: function (path) { return ts.sys.getDirectories(path); }, realpath: realpath }; @@ -47181,41 +47876,14 @@ var ts; var resolutions = []; var cache = ts.createMap(); for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { - var name_45 = names_2[_i]; - var result = name_45 in cache - ? cache[name_45] - : cache[name_45] = loader(name_45, containingFile); + var name_46 = names_2[_i]; + var result = name_46 in cache + ? cache[name_46] + : cache[name_46] = loader(name_46, containingFile); resolutions.push(result); } return resolutions; } - function getAutomaticTypeDirectiveNames(options, host) { - if (options.types) { - return options.types; - } - var result = []; - if (host.directoryExists && host.getDirectories) { - var typeRoots = getEffectiveTypeRoots(options, host); - if (typeRoots) { - for (var _i = 0, typeRoots_1 = typeRoots; _i < typeRoots_1.length; _i++) { - var root = typeRoots_1[_i]; - if (host.directoryExists(root)) { - for (var _a = 0, _b = host.getDirectories(root); _a < _b.length; _a++) { - var typeDirectivePath = _b[_a]; - var normalized = ts.normalizePath(typeDirectivePath); - var packageJsonPath = pathToPackageJson(ts.combinePaths(root, normalized)); - var isNotNeededPackage = host.fileExists(packageJsonPath) && readJson(packageJsonPath, host).typings === null; - if (!isNotNeededPackage) { - result.push(ts.getBaseFileName(normalized)); - } - } - } - } - } - } - return result; - } - ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; function createProgram(rootNames, options, host, oldProgram) { var program; var files = []; @@ -47241,7 +47909,7 @@ var ts; resolveModuleNamesWorker = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }; } else { - var loader_1 = function (moduleName, containingFile) { return resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }; + var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }; resolveModuleNamesWorker = function (moduleNames, containingFile) { return loadWithLocalCache(moduleNames, containingFile, loader_1); }; } var resolveTypeReferenceDirectiveNamesWorker; @@ -47249,15 +47917,15 @@ var ts; resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile) { return host.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile); }; } else { - var loader_2 = function (typesRef, containingFile) { return resolveTypeReferenceDirective(typesRef, containingFile, options, host).resolvedTypeReferenceDirective; }; + var loader_2 = function (typesRef, containingFile) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host).resolvedTypeReferenceDirective; }; resolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile) { return loadWithLocalCache(typeReferenceDirectiveNames, containingFile, loader_2); }; } var filesByName = ts.createFileMap(); var filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? ts.createFileMap(function (fileName) { return fileName.toLowerCase(); }) : undefined; if (!tryReuseStructureFromOldProgram()) { ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); - var typeReferences = getAutomaticTypeDirectiveNames(options, host); - if (typeReferences) { + var typeReferences = ts.getAutomaticTypeDirectiveNames(options, host); + if (typeReferences.length) { var containingFilename = ts.combinePaths(host.getCurrentDirectory(), "__inferred type names__.ts"); var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename); for (var i = 0; i < typeReferences.length; i++) { @@ -47299,7 +47967,8 @@ var ts; getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); }, getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); }, getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; }, - getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; } + getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; }, + dropDiagnosticsProducingTypeChecker: dropDiagnosticsProducingTypeChecker }; verifyCompilerOptions(); ts.performance.mark("afterProgram"); @@ -47346,6 +48015,7 @@ var ts; (oldOptions.configFilePath !== options.configFilePath) || (oldOptions.baseUrl !== options.baseUrl) || (oldOptions.maxNodeModuleJsDepth !== options.maxNodeModuleJsDepth) || + !ts.arrayIsEqualTo(oldOptions.lib, options.lib) || !ts.arrayIsEqualTo(oldOptions.typeRoots, oldOptions.typeRoots) || !ts.arrayIsEqualTo(oldOptions.rootDirs, options.rootDirs) || !ts.equalOwnProperties(oldOptions.paths, options.paths)) { @@ -47446,16 +48116,19 @@ var ts; function getDiagnosticsProducingTypeChecker() { return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, true)); } + function dropDiagnosticsProducingTypeChecker() { + diagnosticsProducingTypeChecker = undefined; + } function getTypeChecker() { return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, false)); } - function emit(sourceFile, writeFileCallback, cancellationToken) { - return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken); }); + function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles) { + return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles); }); } function isEmitBlocked(emitFileName) { return hasEmitBlockingDiagnostics.contains(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName)); } - function emitWorker(program, sourceFile, writeFileCallback, cancellationToken) { + function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles) { var declarationDiagnostics = []; if (options.noEmit) { return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true }; @@ -47476,7 +48149,7 @@ var ts; } var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile); ts.performance.mark("beforeEmit"); - var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile); + var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, emitOnlyDtsFiles); ts.performance.mark("afterEmit"); ts.performance.measure("Emit", "beforeEmit", "afterEmit"); return emitResult; @@ -47991,7 +48664,6 @@ var ts; for (var i = 0; i < moduleNames.length; i++) { var resolution = resolutions[i]; ts.setResolvedModule(file, moduleNames[i], resolution); - var resolvedPath = resolution ? ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName) : undefined; var isFromNodeModulesSearch = resolution && resolution.isExternalLibraryImport; var isJsFileFromNodeModules = isFromNodeModulesSearch && ts.hasJavaScriptFileExtension(resolution.resolvedFileName); if (isFromNodeModulesSearch) { @@ -48003,7 +48675,7 @@ var ts; modulesWithElidedImports[file.path] = true; } else if (shouldAddFile) { - findSourceFile(resolution.resolvedFileName, resolvedPath, false, false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); + findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), false, false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); } if (isFromNodeModulesSearch) { currentNodeModulesDepth--; @@ -48017,8 +48689,8 @@ var ts; } function computeCommonSourceDirectory(sourceFiles) { var fileNames = []; - for (var _i = 0, sourceFiles_5 = sourceFiles; _i < sourceFiles_5.length; _i++) { - var file = sourceFiles_5[_i]; + for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { + var file = sourceFiles_6[_i]; if (!file.isDeclarationFile) { fileNames.push(file.fileName); } @@ -48029,8 +48701,8 @@ var ts; var allFilesBelongToPath = true; if (sourceFiles) { var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); - for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { - var sourceFile = sourceFiles_6[_i]; + for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { + var sourceFile = sourceFiles_7[_i]; if (!ts.isDeclarationFile(sourceFile)) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { @@ -48073,7 +48745,7 @@ var ts; if (!ts.hasProperty(options.paths, key)) { continue; } - if (!hasZeroOrOneAsteriskCharacter(key)) { + if (!ts.hasZeroOrOneAsteriskCharacter(key)) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Pattern_0_can_have_at_most_one_Asterisk_character, key)); } if (ts.isArray(options.paths[key])) { @@ -48084,7 +48756,7 @@ var ts; var subst = _a[_i]; var typeOfSubst = typeof subst; if (typeOfSubst === "string") { - if (!hasZeroOrOneAsteriskCharacter(subst)) { + if (!ts.hasZeroOrOneAsteriskCharacter(subst)) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character, subst, key)); } } @@ -48123,6 +48795,9 @@ var ts; if (options.lib && options.noLib) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "lib", "noLib")); } + if (options.noImplicitUseStrict && options.alwaysStrict) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noImplicitUseStrict", "alwaysStrict")); + } var languageVersion = options.target || 0; var outFile = options.outFile || options.out; var firstNonAmbientExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) && !ts.isDeclarationFile(f) ? f : undefined; }); @@ -48685,7 +49360,7 @@ var ts; case 97: return true; case 69: - return node.originalKeywordKind === 97 && node.parent.kind === 142; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 142; default: return false; } @@ -49258,7 +49933,6 @@ var ts; } ts.isInNonReferenceComment = isInNonReferenceComment; })(ts || (ts = {})); -var ts; (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 142; @@ -49481,7 +50155,7 @@ var ts; return ts.ensureScriptKind(fileName, scriptKind); } ts.getScriptKind = getScriptKind; - function parseAndReEmitConfigJSONFile(content) { + function sanitizeConfigFile(configFileName, content) { var options = { fileName: "config.js", compilerOptions: { @@ -49492,14 +50166,17 @@ var ts; }; var _a = ts.transpileModule("(" + content + ")", options), outputText = _a.outputText, diagnostics = _a.diagnostics; var trimmedOutput = outputText.trim(); - var configJsonObject = JSON.parse(trimmedOutput.substring(1, trimmedOutput.length - 2)); for (var _i = 0, diagnostics_2 = diagnostics; _i < diagnostics_2.length; _i++) { var diagnostic = diagnostics_2[_i]; diagnostic.start = diagnostic.start - 1; } - return { configJsonObject: configJsonObject, diagnostics: diagnostics }; + var _b = ts.parseConfigFileTextToJson(configFileName, trimmedOutput.substring(1, trimmedOutput.length - 2), false), config = _b.config, error = _b.error; + return { + configJsonObject: config || {}, + diagnostics: error ? ts.concatenate(diagnostics, [error]) : diagnostics + }; } - ts.parseAndReEmitConfigJSONFile = parseAndReEmitConfigJSONFile; + ts.sanitizeConfigFile = sanitizeConfigFile; })(ts || (ts = {})); var ts; (function (ts) { @@ -50701,8 +51378,7 @@ var ts; return; case 142: if (token.parent.name === token) { - var isThis_1 = token.kind === 69 && token.originalKeywordKind === 97; - return isThis_1 ? 3 : 17; + return ts.isThisIdentifier(token) ? 3 : 17; } return; } @@ -50743,13 +51419,13 @@ var ts; if (!completionData) { return undefined; } - var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isJsDocTagName = completionData.isJsDocTagName; + var symbols = completionData.symbols, isGlobalCompletion = completionData.isGlobalCompletion, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isJsDocTagName = completionData.isJsDocTagName; if (isJsDocTagName) { - return { isMemberCompletion: false, isNewIdentifierLocation: false, entries: ts.JsDoc.getAllJsDocCompletionEntries() }; + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: ts.JsDoc.getAllJsDocCompletionEntries() }; } var entries = []; if (ts.isSourceFileJavaScript(sourceFile)) { - var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, false); + var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, true); ts.addRange(entries, getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames)); } else { @@ -50773,17 +51449,17 @@ var ts; if (!isMemberCompletion && !isJsDocTagName) { ts.addRange(entries, keywordCompletions); } - return { isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation || ts.isSourceFileJavaScript(sourceFile), entries: entries }; + return { isGlobalCompletion: isGlobalCompletion, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames) { var entries = []; var nameTable = ts.getNameTable(sourceFile); - for (var name_46 in nameTable) { - if (nameTable[name_46] === position) { + for (var name_47 in nameTable) { + if (nameTable[name_47] === position) { continue; } - if (!uniqueNames[name_46]) { - uniqueNames[name_46] = name_46; - var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_46), compilerOptions.target, true); + if (!uniqueNames[name_47]) { + uniqueNames[name_47] = name_47; + var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_47), compilerOptions.target, true); if (displayName) { var entry = { name: displayName, @@ -50833,7 +51509,9 @@ var ts; if (!node || node.kind !== 9) { return undefined; } - if (node.parent.kind === 253 && node.parent.parent.kind === 171) { + if (node.parent.kind === 253 && + node.parent.parent.kind === 171 && + node.parent.name === node) { return getStringLiteralCompletionEntriesFromPropertyAssignment(node.parent); } else if (ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node) { @@ -50856,7 +51534,7 @@ var ts; if (type) { getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, element, false); if (entries.length) { - return { isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; + return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; } } } @@ -50872,7 +51550,7 @@ var ts; } } if (entries.length) { - return { isMemberCompletion: false, isNewIdentifierLocation: true, entries: entries }; + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: true, entries: entries }; } return undefined; } @@ -50882,7 +51560,7 @@ var ts; if (type) { getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, node, false); if (entries.length) { - return { isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; + return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; } } return undefined; @@ -50893,7 +51571,7 @@ var ts; var entries_2 = []; addStringLiteralCompletionsFromType(type, entries_2); if (entries_2.length) { - return { isMemberCompletion: false, isNewIdentifierLocation: false, entries: entries_2 }; + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: entries_2 }; } } return undefined; @@ -50934,6 +51612,7 @@ var ts; entries = getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, span); } return { + isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: true, entries: entries @@ -50964,13 +51643,15 @@ var ts; } function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, extensions, includeExtensions, span, exclude, result) { if (result === void 0) { result = []; } + if (fragment === undefined) { + fragment = ""; + } + fragment = ts.normalizeSlashes(fragment); fragment = ts.getDirectoryPath(fragment); - if (!fragment) { - fragment = "./"; - } - else { - fragment = ts.ensureTrailingDirectorySeparator(fragment); + if (fragment === "") { + fragment = "." + ts.directorySeparator; } + fragment = ts.ensureTrailingDirectorySeparator(fragment); var absolutePath = normalizeAndPreserveTrailingSlash(ts.isRootedDiskPath(fragment) ? fragment : ts.combinePaths(scriptPath, fragment)); var baseDirectory = ts.getDirectoryPath(absolutePath); var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); @@ -51126,6 +51807,12 @@ var ts; if (!range) { return undefined; } + var completionInfo = { + isGlobalCompletion: false, + isMemberCompletion: false, + isNewIdentifierLocation: true, + entries: [] + }; var text = sourceFile.text.substr(range.pos, position - range.pos); var match = tripleSlashDirectiveFragmentRegex.exec(text); if (match) { @@ -51133,22 +51820,16 @@ var ts; var kind = match[2]; var toComplete = match[3]; var scriptPath = ts.getDirectoryPath(sourceFile.path); - var entries_3; if (kind === "path") { var span_10 = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length); - entries_3 = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, ts.getSupportedExtensions(compilerOptions), true, span_10, sourceFile.path); + completionInfo.entries = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, ts.getSupportedExtensions(compilerOptions), true, span_10, sourceFile.path); } else { var span_11 = { start: range.pos + prefix.length, length: match[0].length - prefix.length }; - entries_3 = getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span_11); + completionInfo.entries = getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span_11); } - return { - isMemberCompletion: false, - isNewIdentifierLocation: true, - entries: entries_3 - }; } - return undefined; + return completionInfo; } function getCompletionEntriesFromTypings(host, options, scriptPath, span, result) { if (result === void 0) { result = []; } @@ -51347,7 +52028,7 @@ var ts; } } if (isJsDocTagName) { - return { symbols: undefined, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, isJsDocTagName: isJsDocTagName }; + return { symbols: undefined, isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, isJsDocTagName: isJsDocTagName }; } if (!insideJsDocTagExpression) { log("Returning an empty list because completion was inside a regular comment or plain text part of a JsDoc comment."); @@ -51399,6 +52080,7 @@ var ts; } } var semanticStart = ts.timestamp(); + var isGlobalCompletion = false; var isMemberCompletion; var isNewIdentifierLocation; var symbols = []; @@ -51429,10 +52111,12 @@ var ts; if (!tryGetGlobalSymbols()) { return undefined; } + isGlobalCompletion = true; } log("getCompletionData: Semantic work: " + (ts.timestamp() - semanticStart)); - return { symbols: symbols, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName: isJsDocTagName }; + return { symbols: symbols, isGlobalCompletion: isGlobalCompletion, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName: isJsDocTagName }; function getTypeScriptMemberSymbols() { + isGlobalCompletion = false; isMemberCompletion = true; isNewIdentifierLocation = false; if (node.kind === 69 || node.kind === 139 || node.kind === 172) { @@ -51483,6 +52167,7 @@ var ts; var attrsType = void 0; if ((jsxContainer.kind === 242) || (jsxContainer.kind === 243)) { attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); + isGlobalCompletion = false; if (attrsType) { symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); isMemberCompletion = true; @@ -51842,8 +52527,8 @@ var ts; if (element.getStart() <= position && position <= element.getEnd()) { continue; } - var name_47 = element.propertyName || element.name; - existingImportsOrExports[name_47.text] = true; + var name_48 = element.propertyName || element.name; + existingImportsOrExports[name_48.text] = true; } if (!ts.someProperties(existingImportsOrExports)) { return ts.filter(exportsOfModule, function (e) { return e.name !== "default"; }); @@ -51927,7 +52612,7 @@ var ts; sortText: "0" }); } - var tripleSlashDirectiveFragmentRegex = /^(\/\/\/\s* sourceFile.text.length) { return getBaseIndentation(options); } - if (options.IndentStyle === ts.IndentStyle.None) { + if (options.indentStyle === ts.IndentStyle.None) { return 0; } var precedingToken = ts.findPrecedingToken(position, sourceFile); @@ -58576,7 +59140,7 @@ var ts; return 0; } var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; - if (options.IndentStyle === ts.IndentStyle.Block) { + if (options.indentStyle === ts.IndentStyle.Block) { var current_1 = position; while (current_1 > 0) { var char = sourceFile.text.charCodeAt(current_1); @@ -58605,7 +59169,7 @@ var ts; indentationDelta = 0; } else { - indentationDelta = lineAtPosition !== currentStart.line ? options.IndentSize : 0; + indentationDelta = lineAtPosition !== currentStart.line ? options.indentSize : 0; } break; } @@ -58615,7 +59179,7 @@ var ts; } actualIndentation = getLineIndentationWhenExpressionIsInMultiLine(current, sourceFile, options); if (actualIndentation !== -1) { - return actualIndentation + options.IndentSize; + return actualIndentation + options.indentSize; } previous = current; current = current.parent; @@ -58626,15 +59190,15 @@ var ts; return getIndentationForNodeWorker(current, currentStart, undefined, indentationDelta, sourceFile, options); } SmartIndenter.getIndentation = getIndentation; - function getBaseIndentation(options) { - return options.BaseIndentSize || 0; - } - SmartIndenter.getBaseIndentation = getBaseIndentation; function getIndentationForNode(n, ignoreActualIndentationRange, sourceFile, options) { var start = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); return getIndentationForNodeWorker(n, start, ignoreActualIndentationRange, 0, sourceFile, options); } SmartIndenter.getIndentationForNode = getIndentationForNode; + function getBaseIndentation(options) { + return options.baseIndentSize || 0; + } + SmartIndenter.getBaseIndentation = getBaseIndentation; function getIndentationForNodeWorker(current, currentStart, ignoreActualIndentationRange, indentationDelta, sourceFile, options) { var parent = current.parent; var parentStart; @@ -58664,7 +59228,7 @@ var ts; } } if (shouldIndentChildNode(parent, current) && !parentAndChildShareLine) { - indentationDelta += options.IndentSize; + indentationDelta += options.indentSize; } current = parent; currentStart = parentStart; @@ -58842,7 +59406,7 @@ var ts; break; } if (ch === 9) { - column += options.TabSize + (column % options.TabSize); + column += options.tabSize + (column % options.tabSize); } else { column++; @@ -58940,11 +59504,116 @@ var ts; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var codefix; + (function (codefix) { + var codeFixes = ts.createMap(); + function registerCodeFix(action) { + ts.forEach(action.errorCodes, function (error) { + var fixes = codeFixes[error]; + if (!fixes) { + fixes = []; + codeFixes[error] = fixes; + } + fixes.push(action); + }); + } + codefix.registerCodeFix = registerCodeFix; + function getSupportedErrorCodes() { + return Object.keys(codeFixes); + } + codefix.getSupportedErrorCodes = getSupportedErrorCodes; + function getFixes(context) { + var fixes = codeFixes[context.errorCode]; + var allActions = []; + ts.forEach(fixes, function (f) { + var actions = f.getCodeActions(context); + if (actions && actions.length > 0) { + allActions = allActions.concat(actions); + } + }); + return allActions; + } + codefix.getFixes = getFixes; + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var codefix; + (function (codefix) { + function getOpenBraceEnd(constructor, sourceFile) { + return constructor.body.getFirstToken(sourceFile).getEnd(); + } + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call.code], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var token = ts.getTokenAtPosition(sourceFile, context.span.start); + if (token.kind !== 121) { + return undefined; + } + var newPosition = getOpenBraceEnd(token.parent, sourceFile); + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_missing_super_call), + changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "super();", span: { start: newPosition, length: 0 } }] }] + }]; + } + }); + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class.code], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var token = ts.getTokenAtPosition(sourceFile, context.span.start); + if (token.kind !== 97) { + return undefined; + } + var constructor = ts.getContainingFunction(token); + var superCall = findSuperCall(constructor.body); + if (!superCall) { + return undefined; + } + if (superCall.expression && superCall.expression.kind == 174) { + var arguments_1 = superCall.expression.arguments; + for (var i = 0; i < arguments_1.length; i++) { + if (arguments_1[i].expression === token) { + return undefined; + } + } + } + var newPosition = getOpenBraceEnd(constructor, sourceFile); + var changes = [{ + fileName: sourceFile.fileName, textChanges: [{ + newText: superCall.getText(sourceFile), + span: { start: newPosition, length: 0 } + }, + { + newText: "", + span: { start: superCall.getStart(sourceFile), length: superCall.getWidth(sourceFile) } + }] + }]; + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Make_super_call_the_first_statement_in_the_constructor), + changes: changes + }]; + function findSuperCall(n) { + if (n.kind === 202 && ts.isSuperCall(n.expression)) { + return n; + } + if (ts.isFunctionLike(n)) { + return undefined; + } + return ts.forEachChild(n, findSuperCall); + } + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; (function (ts) { ts.servicesVersion = "0.5"; function createNode(kind, pos, end, parent) { var node = kind >= 139 ? new NodeObject(kind, pos, end) : - kind === 69 ? new IdentifierObject(kind, pos, end) : + kind === 69 ? new IdentifierObject(69, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; return node; @@ -59167,15 +59836,16 @@ var ts; var TokenObject = (function (_super) { __extends(TokenObject, _super); function TokenObject(kind, pos, end) { - _super.call(this, pos, end); - this.kind = kind; + var _this = _super.call(this, pos, end) || this; + _this.kind = kind; + return _this; } return TokenObject; }(TokenOrIdentifierObject)); var IdentifierObject = (function (_super) { __extends(IdentifierObject, _super); function IdentifierObject(kind, pos, end) { - _super.call(this, pos, end); + return _super.call(this, pos, end) || this; } return IdentifierObject; }(TokenOrIdentifierObject)); @@ -59249,7 +59919,7 @@ var ts; var SourceFileObject = (function (_super) { __extends(SourceFileObject, _super); function SourceFileObject(kind, pos, end) { - _super.call(this, kind, pos, end); + return _super.call(this, kind, pos, end) || this; } SourceFileObject.prototype.update = function (newText, textChangeRange) { return ts.updateSourceFile(this, newText, textChangeRange); @@ -59406,6 +60076,30 @@ var ts; getSignatureConstructor: function () { return SignatureObject; } }; } + function toEditorSettings(optionsAsMap) { + var allPropertiesAreCamelCased = true; + for (var key in optionsAsMap) { + if (ts.hasProperty(optionsAsMap, key) && !isCamelCase(key)) { + allPropertiesAreCamelCased = false; + break; + } + } + if (allPropertiesAreCamelCased) { + return optionsAsMap; + } + var settings = {}; + for (var key in optionsAsMap) { + if (ts.hasProperty(optionsAsMap, key)) { + var newKey = isCamelCase(key) ? key : key.charAt(0).toLowerCase() + key.substr(1); + settings[newKey] = optionsAsMap[key]; + } + } + return settings; + } + ts.toEditorSettings = toEditorSettings; + function isCamelCase(s) { + return !s.length || s.charAt(0) === s.charAt(0).toLowerCase(); + } function displayPartsToString(displayParts) { if (displayParts) { return ts.map(displayParts, function (displayPart) { return displayPart.text; }).join(""); @@ -59420,6 +60114,10 @@ var ts; }; } ts.getDefaultCompilerOptions = getDefaultCompilerOptions; + function getSupportedCodeFixes() { + return ts.codefix.getSupportedErrorCodes(); + } + ts.getSupportedCodeFixes = getSupportedCodeFixes; var HostCache = (function () { function HostCache(host, getCanonicalFileName) { this.host = host; @@ -59583,7 +60281,8 @@ var ts; var ruleProvider; var program; var lastProjectVersion; - var useCaseSensitivefileNames = false; + var lastTypesRootVersion = 0; + var useCaseSensitivefileNames = host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(); var cancellationToken = new CancellationTokenObject(host.getCancellationToken && host.getCancellationToken()); var currentDirectory = host.getCurrentDirectory(); if (!ts.localizedDiagnosticMessages && host.getLocalizedDiagnosticMessages) { @@ -59619,6 +60318,12 @@ var ts; lastProjectVersion = hostProjectVersion; } } + var typeRootsVersion = host.getTypeRootsVersion ? host.getTypeRootsVersion() : 0; + if (lastTypesRootVersion !== typeRootsVersion) { + log("TypeRoots version has changed; provide new program"); + program = undefined; + lastTypesRootVersion = typeRootsVersion; + } var hostCache = new HostCache(host, getCanonicalFileName); if (programUpToDate()) { return; @@ -59878,12 +60583,12 @@ var ts; synchronizeHostData(); return ts.FindAllReferences.findReferencedSymbols(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position, findInStrings, findInComments); } - function getNavigateToItems(searchValue, maxResultCount, fileName) { + function getNavigateToItems(searchValue, maxResultCount, fileName, excludeDtsFiles) { synchronizeHostData(); var sourceFiles = fileName ? [getValidSourceFile(fileName)] : program.getSourceFiles(); - return ts.NavigateTo.getNavigateToItems(sourceFiles, program.getTypeChecker(), cancellationToken, searchValue, maxResultCount); + return ts.NavigateTo.getNavigateToItems(sourceFiles, program.getTypeChecker(), cancellationToken, searchValue, maxResultCount, excludeDtsFiles); } - function getEmitOutput(fileName) { + function getEmitOutput(fileName, emitOnlyDtsFiles) { synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); var outputFiles = []; @@ -59894,7 +60599,7 @@ var ts; text: data }); } - var emitOutput = program.emit(sourceFile, writeFile, cancellationToken); + var emitOutput = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles); return { outputFiles: outputFiles, emitSkipped: emitOutput.emitSkipped @@ -59957,14 +60662,26 @@ var ts; return ts.BreakpointResolver.spanInSourceFileAtLocation(sourceFile, position); } function getNavigationBarItems(fileName) { - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - return ts.NavigationBar.getNavigationBarItems(sourceFile); + return ts.NavigationBar.getNavigationBarItems(syntaxTreeCache.getCurrentSourceFile(fileName)); + } + function getNavigationTree(fileName) { + return ts.NavigationBar.getNavigationTree(syntaxTreeCache.getCurrentSourceFile(fileName)); + } + function isTsOrTsxFile(fileName) { + var kind = ts.getScriptKind(fileName, host); + return kind === 3 || kind === 4; } function getSemanticClassifications(fileName, span) { + if (!isTsOrTsxFile(fileName)) { + return []; + } synchronizeHostData(); return ts.getSemanticClassifications(program.getTypeChecker(), cancellationToken, getValidSourceFile(fileName), program.getClassifiableNames(), span); } function getEncodedSemanticClassifications(fileName, span) { + if (!isTsOrTsxFile(fileName)) { + return { spans: [], endOfLineState: 0 }; + } synchronizeHostData(); return ts.getEncodedSemanticClassifications(program.getTypeChecker(), cancellationToken, getValidSourceFile(fileName), program.getClassifiableNames(), span); } @@ -60020,34 +60737,60 @@ var ts; } function getIndentationAtPosition(fileName, position, editorOptions) { var start = ts.timestamp(); + var settings = toEditorSettings(editorOptions); var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); log("getIndentationAtPosition: getCurrentSourceFile: " + (ts.timestamp() - start)); start = ts.timestamp(); - var result = ts.formatting.SmartIndenter.getIndentation(position, sourceFile, editorOptions); + var result = ts.formatting.SmartIndenter.getIndentation(position, sourceFile, settings); log("getIndentationAtPosition: computeIndentation : " + (ts.timestamp() - start)); return result; } function getFormattingEditsForRange(fileName, start, end, options) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - return ts.formatting.formatSelection(start, end, sourceFile, getRuleProvider(options), options); + var settings = toEditorSettings(options); + return ts.formatting.formatSelection(start, end, sourceFile, getRuleProvider(settings), settings); } function getFormattingEditsForDocument(fileName, options) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - return ts.formatting.formatDocument(sourceFile, getRuleProvider(options), options); + var settings = toEditorSettings(options); + return ts.formatting.formatDocument(sourceFile, getRuleProvider(settings), settings); } function getFormattingEditsAfterKeystroke(fileName, position, key, options) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + var settings = toEditorSettings(options); if (key === "}") { - return ts.formatting.formatOnClosingCurly(position, sourceFile, getRuleProvider(options), options); + return ts.formatting.formatOnClosingCurly(position, sourceFile, getRuleProvider(settings), settings); } else if (key === ";") { - return ts.formatting.formatOnSemicolon(position, sourceFile, getRuleProvider(options), options); + return ts.formatting.formatOnSemicolon(position, sourceFile, getRuleProvider(settings), settings); } else if (key === "\n") { - return ts.formatting.formatOnEnter(position, sourceFile, getRuleProvider(options), options); + return ts.formatting.formatOnEnter(position, sourceFile, getRuleProvider(settings), settings); } return []; } + function getCodeFixesAtPosition(fileName, start, end, errorCodes) { + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + var span = { start: start, length: end - start }; + var newLineChar = ts.getNewLineOrDefaultFromHost(host); + var allFixes = []; + ts.forEach(errorCodes, function (error) { + cancellationToken.throwIfCancellationRequested(); + var context = { + errorCode: error, + sourceFile: sourceFile, + span: span, + program: program, + newLineCharacter: newLineChar + }; + var fixes = ts.codefix.getFixes(context); + if (fixes) { + allFixes = allFixes.concat(fixes); + } + }); + return allFixes; + } function getDocCommentTemplateAtPosition(fileName, position) { return ts.JsDoc.getDocCommentTemplateAtPosition(ts.getNewLineOrDefaultFromHost(host), syntaxTreeCache.getCurrentSourceFile(fileName), position); } @@ -60159,6 +60902,7 @@ var ts; getRenameInfo: getRenameInfo, findRenameLocations: findRenameLocations, getNavigationBarItems: getNavigationBarItems, + getNavigationTree: getNavigationTree, getOutliningSpans: getOutliningSpans, getTodoComments: getTodoComments, getBraceMatchingAtPosition: getBraceMatchingAtPosition, @@ -60168,6 +60912,7 @@ var ts; getFormattingEditsAfterKeystroke: getFormattingEditsAfterKeystroke, getDocCommentTemplateAtPosition: getDocCommentTemplateAtPosition, isValidBraceCompletionAtPosition: isValidBraceCompletionAtPosition, + getCodeFixesAtPosition: getCodeFixesAtPosition, getEmitOutput: getEmitOutput, getNonBoundSourceFile: getNonBoundSourceFile, getSourceFile: getSourceFile, @@ -60233,43 +60978,2344 @@ var ts; (function (ts) { var server; (function (server) { - var spaceCache = []; - function generateSpaces(n) { - if (!spaceCache[n]) { - var strBuilder = ""; - for (var i = 0; i < n; i++) { - strBuilder += " "; - } - spaceCache[n] = strBuilder; + var ScriptInfo = (function () { + function ScriptInfo(host, fileName, content, scriptKind, isOpen, hasMixedContent) { + if (isOpen === void 0) { isOpen = false; } + if (hasMixedContent === void 0) { hasMixedContent = false; } + this.host = host; + this.fileName = fileName; + this.scriptKind = scriptKind; + this.isOpen = isOpen; + this.hasMixedContent = hasMixedContent; + this.containingProjects = []; + this.path = ts.toPath(fileName, host.getCurrentDirectory(), ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames)); + this.svc = server.ScriptVersionCache.fromString(host, content); + this.scriptKind = scriptKind + ? scriptKind + : ts.getScriptKindFromFileName(fileName); } - return spaceCache[n]; + ScriptInfo.prototype.getFormatCodeSettings = function () { + return this.formatCodeSettings; + }; + ScriptInfo.prototype.attachToProject = function (project) { + var isNew = !this.isAttached(project); + if (isNew) { + this.containingProjects.push(project); + } + return isNew; + }; + ScriptInfo.prototype.isAttached = function (project) { + switch (this.containingProjects.length) { + case 0: return false; + case 1: return this.containingProjects[0] === project; + case 2: return this.containingProjects[0] === project || this.containingProjects[1] === project; + default: return ts.contains(this.containingProjects, project); + } + }; + ScriptInfo.prototype.detachFromProject = function (project) { + switch (this.containingProjects.length) { + case 0: + return; + case 1: + if (this.containingProjects[0] === project) { + this.containingProjects.pop(); + } + break; + case 2: + if (this.containingProjects[0] === project) { + this.containingProjects[0] = this.containingProjects.pop(); + } + else if (this.containingProjects[1] === project) { + this.containingProjects.pop(); + } + break; + default: + server.removeItemFromSet(this.containingProjects, project); + break; + } + }; + ScriptInfo.prototype.detachAllProjects = function () { + for (var _i = 0, _a = this.containingProjects; _i < _a.length; _i++) { + var p = _a[_i]; + p.removeFile(this, false); + } + this.containingProjects.length = 0; + }; + ScriptInfo.prototype.getDefaultProject = function () { + if (this.containingProjects.length === 0) { + return server.Errors.ThrowNoProject(); + } + ts.Debug.assert(this.containingProjects.length !== 0); + return this.containingProjects[0]; + }; + ScriptInfo.prototype.setFormatOptions = function (formatSettings) { + if (formatSettings) { + if (!this.formatCodeSettings) { + this.formatCodeSettings = server.getDefaultFormatCodeSettings(this.host); + } + server.mergeMaps(this.formatCodeSettings, formatSettings); + } + }; + ScriptInfo.prototype.setWatcher = function (watcher) { + this.stopWatcher(); + this.fileWatcher = watcher; + }; + ScriptInfo.prototype.stopWatcher = function () { + if (this.fileWatcher) { + this.fileWatcher.close(); + this.fileWatcher = undefined; + } + }; + ScriptInfo.prototype.getLatestVersion = function () { + return this.svc.latestVersion().toString(); + }; + ScriptInfo.prototype.reload = function (script) { + this.svc.reload(script); + this.markContainingProjectsAsDirty(); + }; + ScriptInfo.prototype.saveTo = function (fileName) { + var snap = this.snap(); + this.host.writeFile(fileName, snap.getText(0, snap.getLength())); + }; + ScriptInfo.prototype.reloadFromFile = function () { + if (this.hasMixedContent) { + this.reload(""); + } + else { + this.svc.reloadFromFile(this.fileName); + this.markContainingProjectsAsDirty(); + } + }; + ScriptInfo.prototype.snap = function () { + return this.svc.getSnapshot(); + }; + ScriptInfo.prototype.getLineInfo = function (line) { + var snap = this.snap(); + return snap.index.lineNumberToInfo(line); + }; + ScriptInfo.prototype.editContent = function (start, end, newText) { + this.svc.edit(start, end - start, newText); + this.markContainingProjectsAsDirty(); + }; + ScriptInfo.prototype.markContainingProjectsAsDirty = function () { + for (var _i = 0, _a = this.containingProjects; _i < _a.length; _i++) { + var p = _a[_i]; + p.markAsDirty(); + } + }; + ScriptInfo.prototype.lineToTextSpan = function (line) { + var index = this.snap().index; + var lineInfo = index.lineNumberToInfo(line + 1); + var len; + if (lineInfo.leaf) { + len = lineInfo.leaf.text.length; + } + else { + var nextLineInfo = index.lineNumberToInfo(line + 2); + len = nextLineInfo.offset - lineInfo.offset; + } + return ts.createTextSpan(lineInfo.offset, len); + }; + ScriptInfo.prototype.lineOffsetToPosition = function (line, offset) { + var index = this.snap().index; + var lineInfo = index.lineNumberToInfo(line); + return (lineInfo.offset + offset - 1); + }; + ScriptInfo.prototype.positionToLineOffset = function (position) { + var index = this.snap().index; + var lineOffset = index.charOffsetToLineNumberAndPos(position); + return { line: lineOffset.line, offset: lineOffset.offset + 1 }; + }; + return ScriptInfo; + }()); + server.ScriptInfo = ScriptInfo; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + var LSHost = (function () { + function LSHost(host, project, cancellationToken) { + var _this = this; + this.host = host; + this.project = project; + this.cancellationToken = cancellationToken; + this.getCanonicalFileName = ts.createGetCanonicalFileName(this.host.useCaseSensitiveFileNames); + this.resolvedModuleNames = ts.createFileMap(); + this.resolvedTypeReferenceDirectives = ts.createFileMap(); + if (host.trace) { + this.trace = function (s) { return host.trace(s); }; + } + this.resolveModuleName = function (moduleName, containingFile, compilerOptions, host) { + var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host); + if (primaryResult.resolvedModule) { + if (ts.fileExtensionIsAny(primaryResult.resolvedModule.resolvedFileName, ts.supportedTypeScriptExtensions)) { + return primaryResult; + } + } + var secondaryLookupFailedLookupLocations = []; + var globalCache = _this.project.projectService.typingsInstaller.globalTypingsCacheLocation; + if (_this.project.getTypingOptions().enableAutoDiscovery && globalCache) { + var traceEnabled = ts.isTraceEnabled(compilerOptions, host); + if (traceEnabled) { + ts.trace(host, ts.Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2, _this.project.getProjectName(), moduleName, globalCache); + } + var state = { compilerOptions: compilerOptions, host: host, skipTsx: false, traceEnabled: traceEnabled }; + var resolvedName = ts.loadModuleFromNodeModules(moduleName, globalCache, secondaryLookupFailedLookupLocations, state, true); + if (resolvedName) { + return ts.createResolvedModule(resolvedName, true, primaryResult.failedLookupLocations.concat(secondaryLookupFailedLookupLocations)); + } + } + if (!primaryResult.resolvedModule && secondaryLookupFailedLookupLocations.length) { + primaryResult.failedLookupLocations = primaryResult.failedLookupLocations.concat(secondaryLookupFailedLookupLocations); + } + return primaryResult; + }; + } + LSHost.prototype.resolveNamesWithLocalCache = function (names, containingFile, cache, loader, getResult) { + var path = ts.toPath(containingFile, this.host.getCurrentDirectory(), this.getCanonicalFileName); + var currentResolutionsInFile = cache.get(path); + var newResolutions = ts.createMap(); + var resolvedModules = []; + var compilerOptions = this.getCompilationSettings(); + var lastDeletedFileName = this.project.projectService.lastDeletedFile && this.project.projectService.lastDeletedFile.fileName; + for (var _i = 0, names_3 = names; _i < names_3.length; _i++) { + var name_52 = names_3[_i]; + var resolution = newResolutions[name_52]; + if (!resolution) { + var existingResolution = currentResolutionsInFile && currentResolutionsInFile[name_52]; + if (moduleResolutionIsValid(existingResolution)) { + resolution = existingResolution; + } + else { + newResolutions[name_52] = resolution = loader(name_52, containingFile, compilerOptions, this); + } + } + ts.Debug.assert(resolution !== undefined); + resolvedModules.push(getResult(resolution)); + } + cache.set(path, newResolutions); + return resolvedModules; + function moduleResolutionIsValid(resolution) { + if (!resolution) { + return false; + } + var result = getResult(resolution); + if (result) { + if (result.resolvedFileName && result.resolvedFileName === lastDeletedFileName) { + return false; + } + return true; + } + return resolution.failedLookupLocations.length === 0; + } + }; + LSHost.prototype.getProjectVersion = function () { + return this.project.getProjectVersion(); + }; + LSHost.prototype.getCompilationSettings = function () { + return this.compilationSettings; + }; + LSHost.prototype.useCaseSensitiveFileNames = function () { + return this.host.useCaseSensitiveFileNames; + }; + LSHost.prototype.getCancellationToken = function () { + return this.cancellationToken; + }; + LSHost.prototype.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile) { + return this.resolveNamesWithLocalCache(typeDirectiveNames, containingFile, this.resolvedTypeReferenceDirectives, ts.resolveTypeReferenceDirective, function (m) { return m.resolvedTypeReferenceDirective; }); + }; + LSHost.prototype.resolveModuleNames = function (moduleNames, containingFile) { + return this.resolveNamesWithLocalCache(moduleNames, containingFile, this.resolvedModuleNames, this.resolveModuleName, function (m) { return m.resolvedModule; }); + }; + LSHost.prototype.getDefaultLibFileName = function () { + var nodeModuleBinDir = ts.getDirectoryPath(ts.normalizePath(this.host.getExecutingFilePath())); + return ts.combinePaths(nodeModuleBinDir, ts.getDefaultLibFileName(this.compilationSettings)); + }; + LSHost.prototype.getScriptSnapshot = function (filename) { + var scriptInfo = this.project.getScriptInfoLSHost(filename); + if (scriptInfo) { + return scriptInfo.snap(); + } + }; + LSHost.prototype.getScriptFileNames = function () { + return this.project.getRootFilesLSHost(); + }; + LSHost.prototype.getTypeRootsVersion = function () { + return this.project.typesVersion; + }; + LSHost.prototype.getScriptKind = function (fileName) { + var info = this.project.getScriptInfoLSHost(fileName); + return info && info.scriptKind; + }; + LSHost.prototype.getScriptVersion = function (filename) { + var info = this.project.getScriptInfoLSHost(filename); + return info && info.getLatestVersion(); + }; + LSHost.prototype.getCurrentDirectory = function () { + return this.host.getCurrentDirectory(); + }; + LSHost.prototype.resolvePath = function (path) { + return this.host.resolvePath(path); + }; + LSHost.prototype.fileExists = function (path) { + return this.host.fileExists(path); + }; + LSHost.prototype.readFile = function (fileName) { + return this.host.readFile(fileName); + }; + LSHost.prototype.directoryExists = function (path) { + return this.host.directoryExists(path); + }; + LSHost.prototype.readDirectory = function (path, extensions, exclude, include) { + return this.host.readDirectory(path, extensions, exclude, include); + }; + LSHost.prototype.getDirectories = function (path) { + return this.host.getDirectories(path); + }; + LSHost.prototype.notifyFileRemoved = function (info) { + this.resolvedModuleNames.remove(info.path); + this.resolvedTypeReferenceDirectives.remove(info.path); + }; + LSHost.prototype.setCompilationSettings = function (opt) { + this.compilationSettings = opt; + this.resolvedModuleNames.clear(); + this.resolvedTypeReferenceDirectives.clear(); + }; + return LSHost; + }()); + server.LSHost = LSHost; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + server.nullTypingsInstaller = { + enqueueInstallTypingsRequest: function () { }, + attach: function (projectService) { }, + onProjectClosed: function (p) { }, + globalTypingsCacheLocation: undefined + }; + var TypingsCacheEntry = (function () { + function TypingsCacheEntry() { + } + return TypingsCacheEntry; + }()); + function setIsEqualTo(arr1, arr2) { + if (arr1 === arr2) { + return true; + } + if ((arr1 || server.emptyArray).length === 0 && (arr2 || server.emptyArray).length === 0) { + return true; + } + var set = ts.createMap(); + var unique = 0; + for (var _i = 0, arr1_1 = arr1; _i < arr1_1.length; _i++) { + var v = arr1_1[_i]; + if (set[v] !== true) { + set[v] = true; + unique++; + } + } + for (var _a = 0, arr2_1 = arr2; _a < arr2_1.length; _a++) { + var v = arr2_1[_a]; + if (!ts.hasProperty(set, v)) { + return false; + } + if (set[v] === true) { + set[v] = false; + unique--; + } + } + return unique === 0; } - server.generateSpaces = generateSpaces; - function generateIndentString(n, editorOptions) { - if (editorOptions.ConvertTabsToSpaces) { - return generateSpaces(n); + function typingOptionsChanged(opt1, opt2) { + return opt1.enableAutoDiscovery !== opt2.enableAutoDiscovery || + !setIsEqualTo(opt1.include, opt2.include) || + !setIsEqualTo(opt1.exclude, opt2.exclude); + } + function compilerOptionsChanged(opt1, opt2) { + return opt1.allowJs != opt2.allowJs; + } + function toTypingsArray(arr) { + arr.sort(); + return arr; + } + var TypingsCache = (function () { + function TypingsCache(installer) { + this.installer = installer; + this.perProjectCache = ts.createMap(); } - else { - var result = ""; - for (var i = 0; i < Math.floor(n / editorOptions.TabSize); i++) { - result += "\t"; + TypingsCache.prototype.getTypingsForProject = function (project, forceRefresh) { + var typingOptions = project.getTypingOptions(); + if (!typingOptions || !typingOptions.enableAutoDiscovery) { + return server.emptyArray; } - for (var i = 0; i < n % editorOptions.TabSize; i++) { - result += " "; + var entry = this.perProjectCache[project.getProjectName()]; + var result = entry ? entry.typings : server.emptyArray; + if (forceRefresh || !entry || typingOptionsChanged(typingOptions, entry.typingOptions) || compilerOptionsChanged(project.getCompilerOptions(), entry.compilerOptions)) { + this.perProjectCache[project.getProjectName()] = { + compilerOptions: project.getCompilerOptions(), + typingOptions: typingOptions, + typings: result, + poisoned: true + }; + this.installer.enqueueInstallTypingsRequest(project, typingOptions); } return result; + }; + TypingsCache.prototype.invalidateCachedTypingsForProject = function (project) { + var typingOptions = project.getTypingOptions(); + if (!typingOptions.enableAutoDiscovery) { + return; + } + this.installer.enqueueInstallTypingsRequest(project, typingOptions); + }; + TypingsCache.prototype.updateTypingsForProject = function (projectName, compilerOptions, typingOptions, newTypings) { + this.perProjectCache[projectName] = { + compilerOptions: compilerOptions, + typingOptions: typingOptions, + typings: toTypingsArray(newTypings), + poisoned: false + }; + }; + TypingsCache.prototype.onProjectClosed = function (project) { + delete this.perProjectCache[project.getProjectName()]; + this.installer.onProjectClosed(project); + }; + return TypingsCache; + }()); + server.TypingsCache = TypingsCache; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + var crypto = require("crypto"); + function shouldEmitFile(scriptInfo) { + return !scriptInfo.hasMixedContent; + } + server.shouldEmitFile = shouldEmitFile; + var BuilderFileInfo = (function () { + function BuilderFileInfo(scriptInfo, project) { + this.scriptInfo = scriptInfo; + this.project = project; + } + BuilderFileInfo.prototype.isExternalModuleOrHasOnlyAmbientExternalModules = function () { + var sourceFile = this.getSourceFile(); + return ts.isExternalModule(sourceFile) || this.containsOnlyAmbientModules(sourceFile); + }; + BuilderFileInfo.prototype.containsOnlyAmbientModules = function (sourceFile) { + for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { + var statement = _a[_i]; + if (statement.kind !== 225 || statement.name.kind !== 9) { + return false; + } + } + return true; + }; + BuilderFileInfo.prototype.computeHash = function (text) { + return crypto.createHash("md5") + .update(text) + .digest("base64"); + }; + BuilderFileInfo.prototype.getSourceFile = function () { + return this.project.getSourceFile(this.scriptInfo.path); + }; + BuilderFileInfo.prototype.updateShapeSignature = function () { + var sourceFile = this.getSourceFile(); + if (!sourceFile) { + return true; + } + var lastSignature = this.lastCheckedShapeSignature; + if (sourceFile.isDeclarationFile) { + this.lastCheckedShapeSignature = this.computeHash(sourceFile.text); + } + else { + var emitOutput = this.project.getFileEmitOutput(this.scriptInfo, true); + if (emitOutput.outputFiles && emitOutput.outputFiles.length > 0) { + this.lastCheckedShapeSignature = this.computeHash(emitOutput.outputFiles[0].text); + } + } + return !lastSignature || this.lastCheckedShapeSignature !== lastSignature; + }; + return BuilderFileInfo; + }()); + server.BuilderFileInfo = BuilderFileInfo; + var AbstractBuilder = (function () { + function AbstractBuilder(project, ctor) { + this.project = project; + this.ctor = ctor; + this.fileInfos = ts.createFileMap(); + } + AbstractBuilder.prototype.getFileInfo = function (path) { + return this.fileInfos.get(path); + }; + AbstractBuilder.prototype.getOrCreateFileInfo = function (path) { + var fileInfo = this.getFileInfo(path); + if (!fileInfo) { + var scriptInfo = this.project.getScriptInfo(path); + fileInfo = new this.ctor(scriptInfo, this.project); + this.setFileInfo(path, fileInfo); + } + return fileInfo; + }; + AbstractBuilder.prototype.getFileInfoPaths = function () { + return this.fileInfos.getKeys(); + }; + AbstractBuilder.prototype.setFileInfo = function (path, info) { + this.fileInfos.set(path, info); + }; + AbstractBuilder.prototype.removeFileInfo = function (path) { + this.fileInfos.remove(path); + }; + AbstractBuilder.prototype.forEachFileInfo = function (action) { + this.fileInfos.forEachValue(function (path, value) { return action(value); }); + }; + AbstractBuilder.prototype.emitFile = function (scriptInfo, writeFile) { + var fileInfo = this.getFileInfo(scriptInfo.path); + if (!fileInfo) { + return false; + } + var _a = this.project.getFileEmitOutput(fileInfo.scriptInfo, false), emitSkipped = _a.emitSkipped, outputFiles = _a.outputFiles; + if (!emitSkipped) { + var projectRootPath = this.project.getProjectRootPath(); + for (var _i = 0, outputFiles_1 = outputFiles; _i < outputFiles_1.length; _i++) { + var outputFile = outputFiles_1[_i]; + var outputFileAbsoluteFileName = ts.getNormalizedAbsolutePath(outputFile.name, projectRootPath ? projectRootPath : ts.getDirectoryPath(scriptInfo.fileName)); + writeFile(outputFileAbsoluteFileName, outputFile.text, outputFile.writeByteOrderMark); + } + } + return !emitSkipped; + }; + return AbstractBuilder; + }()); + var NonModuleBuilder = (function (_super) { + __extends(NonModuleBuilder, _super); + function NonModuleBuilder(project) { + var _this = _super.call(this, project, BuilderFileInfo) || this; + _this.project = project; + return _this; + } + NonModuleBuilder.prototype.onProjectUpdateGraph = function () { + }; + NonModuleBuilder.prototype.getFilesAffectedBy = function (scriptInfo) { + var info = this.getOrCreateFileInfo(scriptInfo.path); + var singleFileResult = scriptInfo.hasMixedContent ? [] : [scriptInfo.fileName]; + if (info.updateShapeSignature()) { + var options = this.project.getCompilerOptions(); + if (options && (options.out || options.outFile)) { + return singleFileResult; + } + return this.project.getAllEmittableFiles(); + } + return singleFileResult; + }; + return NonModuleBuilder; + }(AbstractBuilder)); + var ModuleBuilderFileInfo = (function (_super) { + __extends(ModuleBuilderFileInfo, _super); + function ModuleBuilderFileInfo() { + var _this = _super.apply(this, arguments) || this; + _this.references = []; + _this.referencedBy = []; + return _this; + } + ModuleBuilderFileInfo.compareFileInfos = function (lf, rf) { + var l = lf.scriptInfo.fileName; + var r = rf.scriptInfo.fileName; + return (l < r ? -1 : (l > r ? 1 : 0)); + }; + ; + ModuleBuilderFileInfo.addToReferenceList = function (array, fileInfo) { + if (array.length === 0) { + array.push(fileInfo); + return; + } + var insertIndex = ts.binarySearch(array, fileInfo, ModuleBuilderFileInfo.compareFileInfos); + if (insertIndex < 0) { + array.splice(~insertIndex, 0, fileInfo); + } + }; + ModuleBuilderFileInfo.removeFromReferenceList = function (array, fileInfo) { + if (!array || array.length === 0) { + return; + } + if (array[0] === fileInfo) { + array.splice(0, 1); + return; + } + var removeIndex = ts.binarySearch(array, fileInfo, ModuleBuilderFileInfo.compareFileInfos); + if (removeIndex >= 0) { + array.splice(removeIndex, 1); + } + }; + ModuleBuilderFileInfo.prototype.addReferencedBy = function (fileInfo) { + ModuleBuilderFileInfo.addToReferenceList(this.referencedBy, fileInfo); + }; + ModuleBuilderFileInfo.prototype.removeReferencedBy = function (fileInfo) { + ModuleBuilderFileInfo.removeFromReferenceList(this.referencedBy, fileInfo); + }; + ModuleBuilderFileInfo.prototype.removeFileReferences = function () { + for (var _i = 0, _a = this.references; _i < _a.length; _i++) { + var reference = _a[_i]; + reference.removeReferencedBy(this); + } + this.references = []; + }; + return ModuleBuilderFileInfo; + }(BuilderFileInfo)); + var ModuleBuilder = (function (_super) { + __extends(ModuleBuilder, _super); + function ModuleBuilder(project) { + var _this = _super.call(this, project, ModuleBuilderFileInfo) || this; + _this.project = project; + return _this; + } + ModuleBuilder.prototype.getReferencedFileInfos = function (fileInfo) { + var _this = this; + if (!fileInfo.isExternalModuleOrHasOnlyAmbientExternalModules()) { + return []; + } + var referencedFilePaths = this.project.getReferencedFiles(fileInfo.scriptInfo.path); + if (referencedFilePaths.length > 0) { + return ts.map(referencedFilePaths, function (f) { return _this.getOrCreateFileInfo(f); }).sort(ModuleBuilderFileInfo.compareFileInfos); + } + return []; + }; + ModuleBuilder.prototype.onProjectUpdateGraph = function () { + this.ensureProjectDependencyGraphUpToDate(); + }; + ModuleBuilder.prototype.ensureProjectDependencyGraphUpToDate = function () { + var _this = this; + if (!this.projectVersionForDependencyGraph || this.project.getProjectVersion() !== this.projectVersionForDependencyGraph) { + var currentScriptInfos = this.project.getScriptInfos(); + for (var _i = 0, currentScriptInfos_1 = currentScriptInfos; _i < currentScriptInfos_1.length; _i++) { + var scriptInfo = currentScriptInfos_1[_i]; + var fileInfo = this.getOrCreateFileInfo(scriptInfo.path); + this.updateFileReferences(fileInfo); + } + this.forEachFileInfo(function (fileInfo) { + if (!_this.project.containsScriptInfo(fileInfo.scriptInfo)) { + fileInfo.removeFileReferences(); + _this.removeFileInfo(fileInfo.scriptInfo.path); + } + }); + this.projectVersionForDependencyGraph = this.project.getProjectVersion(); + } + }; + ModuleBuilder.prototype.updateFileReferences = function (fileInfo) { + if (fileInfo.scriptVersionForReferences === fileInfo.scriptInfo.getLatestVersion()) { + return; + } + var newReferences = this.getReferencedFileInfos(fileInfo); + var oldReferences = fileInfo.references; + var oldIndex = 0; + var newIndex = 0; + while (oldIndex < oldReferences.length && newIndex < newReferences.length) { + var oldReference = oldReferences[oldIndex]; + var newReference = newReferences[newIndex]; + var compare = ModuleBuilderFileInfo.compareFileInfos(oldReference, newReference); + if (compare < 0) { + oldReference.removeReferencedBy(fileInfo); + oldIndex++; + } + else if (compare > 0) { + newReference.addReferencedBy(fileInfo); + newIndex++; + } + else { + oldIndex++; + newIndex++; + } + } + for (var i = oldIndex; i < oldReferences.length; i++) { + oldReferences[i].removeReferencedBy(fileInfo); + } + for (var i = newIndex; i < newReferences.length; i++) { + newReferences[i].addReferencedBy(fileInfo); + } + fileInfo.references = newReferences; + fileInfo.scriptVersionForReferences = fileInfo.scriptInfo.getLatestVersion(); + }; + ModuleBuilder.prototype.getFilesAffectedBy = function (scriptInfo) { + this.ensureProjectDependencyGraphUpToDate(); + var singleFileResult = scriptInfo.hasMixedContent ? [] : [scriptInfo.fileName]; + var fileInfo = this.getFileInfo(scriptInfo.path); + if (!fileInfo || !fileInfo.updateShapeSignature()) { + return singleFileResult; + } + if (!fileInfo.isExternalModuleOrHasOnlyAmbientExternalModules()) { + return this.project.getAllEmittableFiles(); + } + var options = this.project.getCompilerOptions(); + if (options && (options.isolatedModules || options.out || options.outFile)) { + return singleFileResult; + } + var queue = fileInfo.referencedBy.slice(0); + var fileNameSet = ts.createMap(); + fileNameSet[scriptInfo.fileName] = scriptInfo; + while (queue.length > 0) { + var processingFileInfo = queue.pop(); + if (processingFileInfo.updateShapeSignature() && processingFileInfo.referencedBy.length > 0) { + for (var _i = 0, _a = processingFileInfo.referencedBy; _i < _a.length; _i++) { + var potentialFileInfo = _a[_i]; + if (!fileNameSet[potentialFileInfo.scriptInfo.fileName]) { + queue.push(potentialFileInfo); + } + } + } + fileNameSet[processingFileInfo.scriptInfo.fileName] = processingFileInfo.scriptInfo; + } + var result = []; + for (var fileName in fileNameSet) { + if (shouldEmitFile(fileNameSet[fileName])) { + result.push(fileName); + } + } + return result; + }; + return ModuleBuilder; + }(AbstractBuilder)); + function createBuilder(project) { + var moduleKind = project.getCompilerOptions().module; + switch (moduleKind) { + case ts.ModuleKind.None: + return new NonModuleBuilder(project); + default: + return new ModuleBuilder(project); } } - server.generateIndentString = generateIndentString; + server.createBuilder = createBuilder; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + (function (ProjectKind) { + ProjectKind[ProjectKind["Inferred"] = 0] = "Inferred"; + ProjectKind[ProjectKind["Configured"] = 1] = "Configured"; + ProjectKind[ProjectKind["External"] = 2] = "External"; + })(server.ProjectKind || (server.ProjectKind = {})); + var ProjectKind = server.ProjectKind; + function remove(items, item) { + var index = items.indexOf(item); + if (index >= 0) { + items.splice(index, 1); + } + } + function countEachFileTypes(infos) { + var result = { js: 0, jsx: 0, ts: 0, tsx: 0, dts: 0 }; + for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { + var info = infos_1[_i]; + switch (info.scriptKind) { + case 1: + result.js += 1; + break; + case 2: + result.jsx += 1; + break; + case 3: + ts.fileExtensionIs(info.fileName, ".d.ts") + ? result.dts += 1 + : result.ts += 1; + break; + case 4: + result.tsx += 1; + break; + } + } + return result; + } + function hasOneOrMoreJsAndNoTsFiles(project) { + var counts = countEachFileTypes(project.getScriptInfos()); + return counts.js > 0 && counts.ts === 0 && counts.tsx === 0; + } + function allRootFilesAreJsOrDts(project) { + var counts = countEachFileTypes(project.getRootScriptInfos()); + return counts.ts === 0 && counts.tsx === 0; + } + server.allRootFilesAreJsOrDts = allRootFilesAreJsOrDts; + function allFilesAreJsOrDts(project) { + var counts = countEachFileTypes(project.getScriptInfos()); + return counts.ts === 0 && counts.tsx === 0; + } + server.allFilesAreJsOrDts = allFilesAreJsOrDts; + var Project = (function () { + function Project(projectKind, projectService, documentRegistry, hasExplicitListOfFiles, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) { + this.projectKind = projectKind; + this.projectService = projectService; + this.documentRegistry = documentRegistry; + this.languageServiceEnabled = languageServiceEnabled; + this.compilerOptions = compilerOptions; + this.compileOnSaveEnabled = compileOnSaveEnabled; + this.rootFiles = []; + this.rootFilesMap = ts.createFileMap(); + this.lastReportedVersion = 0; + this.projectStructureVersion = 0; + this.projectStateVersion = 0; + this.typesVersion = 0; + if (!this.compilerOptions) { + this.compilerOptions = ts.getDefaultCompilerOptions(); + this.compilerOptions.allowNonTsExtensions = true; + this.compilerOptions.allowJs = true; + } + else if (hasExplicitListOfFiles) { + this.compilerOptions.allowNonTsExtensions = true; + } + if (languageServiceEnabled) { + this.enableLanguageService(); + } + else { + this.disableLanguageService(); + } + this.builder = server.createBuilder(this); + this.markAsDirty(); + } + Project.prototype.isNonTsProject = function () { + this.updateGraph(); + return allFilesAreJsOrDts(this); + }; + Project.prototype.isJsOnlyProject = function () { + this.updateGraph(); + return hasOneOrMoreJsAndNoTsFiles(this); + }; + Project.prototype.getProjectErrors = function () { + return this.projectErrors; + }; + Project.prototype.getLanguageService = function (ensureSynchronized) { + if (ensureSynchronized === void 0) { ensureSynchronized = true; } + if (ensureSynchronized) { + this.updateGraph(); + } + return this.languageService; + }; + Project.prototype.getCompileOnSaveAffectedFileList = function (scriptInfo) { + if (!this.languageServiceEnabled) { + return []; + } + this.updateGraph(); + return this.builder.getFilesAffectedBy(scriptInfo); + }; + Project.prototype.getProjectVersion = function () { + return this.projectStateVersion.toString(); + }; + Project.prototype.enableLanguageService = function () { + var lsHost = new server.LSHost(this.projectService.host, this, this.projectService.cancellationToken); + lsHost.setCompilationSettings(this.compilerOptions); + this.languageService = ts.createLanguageService(lsHost, this.documentRegistry); + this.lsHost = lsHost; + this.languageServiceEnabled = true; + }; + Project.prototype.disableLanguageService = function () { + this.languageService = server.nullLanguageService; + this.lsHost = server.nullLanguageServiceHost; + this.languageServiceEnabled = false; + }; + Project.prototype.getSourceFile = function (path) { + if (!this.program) { + return undefined; + } + return this.program.getSourceFileByPath(path); + }; + Project.prototype.updateTypes = function () { + this.typesVersion++; + this.markAsDirty(); + this.updateGraph(); + }; + Project.prototype.close = function () { + if (this.program) { + for (var _i = 0, _a = this.program.getSourceFiles(); _i < _a.length; _i++) { + var f = _a[_i]; + var info = this.projectService.getScriptInfo(f.fileName); + info.detachFromProject(this); + } + } + else { + for (var _b = 0, _c = this.rootFiles; _b < _c.length; _b++) { + var root = _c[_b]; + root.detachFromProject(this); + } + } + this.rootFiles = undefined; + this.rootFilesMap = undefined; + this.program = undefined; + this.languageService.dispose(); + }; + Project.prototype.getCompilerOptions = function () { + return this.compilerOptions; + }; + Project.prototype.hasRoots = function () { + return this.rootFiles && this.rootFiles.length > 0; + }; + Project.prototype.getRootFiles = function () { + return this.rootFiles && this.rootFiles.map(function (info) { return info.fileName; }); + }; + Project.prototype.getRootFilesLSHost = function () { + var result = []; + if (this.rootFiles) { + for (var _i = 0, _a = this.rootFiles; _i < _a.length; _i++) { + var f = _a[_i]; + result.push(f.fileName); + } + if (this.typingFiles) { + for (var _b = 0, _c = this.typingFiles; _b < _c.length; _b++) { + var f = _c[_b]; + result.push(f); + } + } + } + return result; + }; + Project.prototype.getRootScriptInfos = function () { + return this.rootFiles; + }; + Project.prototype.getScriptInfos = function () { + var _this = this; + return ts.map(this.program.getSourceFiles(), function (sourceFile) { + var scriptInfo = _this.projectService.getScriptInfoForPath(sourceFile.path); + if (!scriptInfo) { + ts.Debug.assert(false, "scriptInfo for a file '" + sourceFile.fileName + "' is missing."); + } + return scriptInfo; + }); + }; + Project.prototype.getFileEmitOutput = function (info, emitOnlyDtsFiles) { + if (!this.languageServiceEnabled) { + return undefined; + } + return this.getLanguageService().getEmitOutput(info.fileName, emitOnlyDtsFiles); + }; + Project.prototype.getFileNames = function () { + if (!this.program) { + return []; + } + if (!this.languageServiceEnabled) { + var rootFiles = this.getRootFiles(); + if (this.compilerOptions) { + var defaultLibrary = ts.getDefaultLibFilePath(this.compilerOptions); + if (defaultLibrary) { + (rootFiles || (rootFiles = [])).push(server.asNormalizedPath(defaultLibrary)); + } + } + return rootFiles; + } + var sourceFiles = this.program.getSourceFiles(); + return sourceFiles.map(function (sourceFile) { return server.asNormalizedPath(sourceFile.fileName); }); + }; + Project.prototype.getAllEmittableFiles = function () { + if (!this.languageServiceEnabled) { + return []; + } + var defaultLibraryFileName = ts.getDefaultLibFileName(this.compilerOptions); + var infos = this.getScriptInfos(); + var result = []; + for (var _i = 0, infos_2 = infos; _i < infos_2.length; _i++) { + var info = infos_2[_i]; + if (ts.getBaseFileName(info.fileName) !== defaultLibraryFileName && server.shouldEmitFile(info)) { + result.push(info.fileName); + } + } + return result; + }; + Project.prototype.containsScriptInfo = function (info) { + return this.isRoot(info) || (this.program && this.program.getSourceFileByPath(info.path) !== undefined); + }; + Project.prototype.containsFile = function (filename, requireOpen) { + var info = this.projectService.getScriptInfoForNormalizedPath(filename); + if (info && (info.isOpen || !requireOpen)) { + return this.containsScriptInfo(info); + } + }; + Project.prototype.isRoot = function (info) { + return this.rootFilesMap && this.rootFilesMap.contains(info.path); + }; + Project.prototype.addRoot = function (info) { + if (!this.isRoot(info)) { + this.rootFiles.push(info); + this.rootFilesMap.set(info.path, info); + info.attachToProject(this); + this.markAsDirty(); + } + }; + Project.prototype.removeFile = function (info, detachFromProject) { + if (detachFromProject === void 0) { detachFromProject = true; } + this.removeRootFileIfNecessary(info); + this.lsHost.notifyFileRemoved(info); + if (detachFromProject) { + info.detachFromProject(this); + } + this.markAsDirty(); + }; + Project.prototype.markAsDirty = function () { + this.projectStateVersion++; + }; + Project.prototype.updateGraph = function () { + if (!this.languageServiceEnabled) { + return true; + } + var hasChanges = this.updateGraphWorker(); + var cachedTypings = this.projectService.typingsCache.getTypingsForProject(this, hasChanges); + if (this.setTypings(cachedTypings)) { + hasChanges = this.updateGraphWorker() || hasChanges; + } + if (hasChanges) { + this.projectStructureVersion++; + } + return !hasChanges; + }; + Project.prototype.setTypings = function (typings) { + if (ts.arrayIsEqualTo(this.typingFiles, typings)) { + return false; + } + this.typingFiles = typings; + this.markAsDirty(); + return true; + }; + Project.prototype.updateGraphWorker = function () { + var oldProgram = this.program; + this.program = this.languageService.getProgram(); + var hasChanges = false; + if (!oldProgram || (this.program !== oldProgram && !oldProgram.structureIsReused)) { + hasChanges = true; + if (oldProgram) { + for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { + var f = _a[_i]; + if (this.program.getSourceFileByPath(f.path)) { + continue; + } + var scriptInfoToDetach = this.projectService.getScriptInfo(f.fileName); + if (scriptInfoToDetach) { + scriptInfoToDetach.detachFromProject(this); + } + } + } + } + this.builder.onProjectUpdateGraph(); + return hasChanges; + }; + Project.prototype.getScriptInfoLSHost = function (fileName) { + var scriptInfo = this.projectService.getOrCreateScriptInfo(fileName, false); + if (scriptInfo) { + scriptInfo.attachToProject(this); + } + return scriptInfo; + }; + Project.prototype.getScriptInfoForNormalizedPath = function (fileName) { + var scriptInfo = this.projectService.getOrCreateScriptInfoForNormalizedPath(fileName, false); + if (scriptInfo && !scriptInfo.isAttached(this)) { + return server.Errors.ThrowProjectDoesNotContainDocument(fileName, this); + } + return scriptInfo; + }; + Project.prototype.getScriptInfo = function (uncheckedFileName) { + return this.getScriptInfoForNormalizedPath(server.toNormalizedPath(uncheckedFileName)); + }; + Project.prototype.filesToString = function () { + if (!this.program) { + return ""; + } + var strBuilder = ""; + for (var _i = 0, _a = this.program.getSourceFiles(); _i < _a.length; _i++) { + var file = _a[_i]; + strBuilder += file.fileName + "\n"; + } + return strBuilder; + }; + Project.prototype.setCompilerOptions = function (compilerOptions) { + if (compilerOptions) { + if (this.projectKind === ProjectKind.Inferred) { + compilerOptions.allowJs = true; + } + compilerOptions.allowNonTsExtensions = true; + this.compilerOptions = compilerOptions; + this.lsHost.setCompilationSettings(compilerOptions); + this.markAsDirty(); + } + }; + Project.prototype.reloadScript = function (filename) { + var script = this.projectService.getScriptInfoForNormalizedPath(filename); + if (script) { + ts.Debug.assert(script.isAttached(this)); + script.reloadFromFile(); + return true; + } + return false; + }; + Project.prototype.getChangesSinceVersion = function (lastKnownVersion) { + this.updateGraph(); + var info = { + projectName: this.getProjectName(), + version: this.projectStructureVersion, + isInferred: this.projectKind === ProjectKind.Inferred, + options: this.getCompilerOptions() + }; + if (this.lastReportedFileNames && lastKnownVersion === this.lastReportedVersion) { + if (this.projectStructureVersion == this.lastReportedVersion) { + return { info: info, projectErrors: this.projectErrors }; + } + var lastReportedFileNames = this.lastReportedFileNames; + var currentFiles = ts.arrayToMap(this.getFileNames(), function (x) { return x; }); + var added = []; + var removed = []; + for (var id in currentFiles) { + if (!ts.hasProperty(lastReportedFileNames, id)) { + added.push(id); + } + } + for (var id in lastReportedFileNames) { + if (!ts.hasProperty(currentFiles, id)) { + removed.push(id); + } + } + this.lastReportedFileNames = currentFiles; + this.lastReportedVersion = this.projectStructureVersion; + return { info: info, changes: { added: added, removed: removed }, projectErrors: this.projectErrors }; + } + else { + var projectFileNames = this.getFileNames(); + this.lastReportedFileNames = ts.arrayToMap(projectFileNames, function (x) { return x; }); + this.lastReportedVersion = this.projectStructureVersion; + return { info: info, files: projectFileNames, projectErrors: this.projectErrors }; + } + }; + Project.prototype.getReferencedFiles = function (path) { + var _this = this; + if (!this.languageServiceEnabled) { + return []; + } + var sourceFile = this.getSourceFile(path); + if (!sourceFile) { + return []; + } + var referencedFiles = ts.createMap(); + if (sourceFile.imports && sourceFile.imports.length > 0) { + var checker = this.program.getTypeChecker(); + for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { + var importName = _a[_i]; + var symbol = checker.getSymbolAtLocation(importName); + if (symbol && symbol.declarations && symbol.declarations[0]) { + var declarationSourceFile = symbol.declarations[0].getSourceFile(); + if (declarationSourceFile) { + referencedFiles[declarationSourceFile.path] = true; + } + } + } + } + var currentDirectory = ts.getDirectoryPath(path); + var getCanonicalFileName = ts.createGetCanonicalFileName(this.projectService.host.useCaseSensitiveFileNames); + if (sourceFile.referencedFiles && sourceFile.referencedFiles.length > 0) { + for (var _b = 0, _c = sourceFile.referencedFiles; _b < _c.length; _b++) { + var referencedFile = _c[_b]; + var referencedPath = ts.toPath(referencedFile.fileName, currentDirectory, getCanonicalFileName); + referencedFiles[referencedPath] = true; + } + } + if (sourceFile.resolvedTypeReferenceDirectiveNames) { + for (var typeName in sourceFile.resolvedTypeReferenceDirectiveNames) { + var resolvedTypeReferenceDirective = sourceFile.resolvedTypeReferenceDirectiveNames[typeName]; + if (!resolvedTypeReferenceDirective) { + continue; + } + var fileName = resolvedTypeReferenceDirective.resolvedFileName; + var typeFilePath = ts.toPath(fileName, currentDirectory, getCanonicalFileName); + referencedFiles[typeFilePath] = true; + } + } + var allFileNames = ts.map(Object.keys(referencedFiles), function (key) { return key; }); + return ts.filter(allFileNames, function (file) { return _this.projectService.host.fileExists(file); }); + }; + Project.prototype.removeRootFileIfNecessary = function (info) { + if (this.isRoot(info)) { + remove(this.rootFiles, info); + this.rootFilesMap.remove(info.path); + } + }; + return Project; + }()); + server.Project = Project; + var InferredProject = (function (_super) { + __extends(InferredProject, _super); + function InferredProject(projectService, documentRegistry, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) { + var _this = _super.call(this, ProjectKind.Inferred, projectService, documentRegistry, undefined, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) || this; + _this.compileOnSaveEnabled = compileOnSaveEnabled; + _this.directoriesWatchedForTsconfig = []; + _this.inferredProjectName = server.makeInferredProjectName(InferredProject.NextId); + InferredProject.NextId++; + return _this; + } + InferredProject.prototype.getProjectName = function () { + return this.inferredProjectName; + }; + InferredProject.prototype.getProjectRootPath = function () { + if (this.projectService.useSingleInferredProject) { + return undefined; + } + var rootFiles = this.getRootFiles(); + return ts.getDirectoryPath(rootFiles[0]); + }; + InferredProject.prototype.close = function () { + _super.prototype.close.call(this); + for (var _i = 0, _a = this.directoriesWatchedForTsconfig; _i < _a.length; _i++) { + var directory = _a[_i]; + this.projectService.stopWatchingDirectory(directory); + } + }; + InferredProject.prototype.getTypingOptions = function () { + return { + enableAutoDiscovery: allRootFilesAreJsOrDts(this), + include: [], + exclude: [] + }; + }; + return InferredProject; + }(Project)); + InferredProject.NextId = 1; + server.InferredProject = InferredProject; + var ConfiguredProject = (function (_super) { + __extends(ConfiguredProject, _super); + function ConfiguredProject(configFileName, projectService, documentRegistry, hasExplicitListOfFiles, compilerOptions, wildcardDirectories, languageServiceEnabled, compileOnSaveEnabled) { + var _this = _super.call(this, ProjectKind.Configured, projectService, documentRegistry, hasExplicitListOfFiles, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) || this; + _this.configFileName = configFileName; + _this.wildcardDirectories = wildcardDirectories; + _this.compileOnSaveEnabled = compileOnSaveEnabled; + _this.openRefCount = 0; + return _this; + } + ConfiguredProject.prototype.getProjectRootPath = function () { + return ts.getDirectoryPath(this.configFileName); + }; + ConfiguredProject.prototype.setProjectErrors = function (projectErrors) { + this.projectErrors = projectErrors; + }; + ConfiguredProject.prototype.setTypingOptions = function (newTypingOptions) { + this.typingOptions = newTypingOptions; + }; + ConfiguredProject.prototype.getTypingOptions = function () { + return this.typingOptions; + }; + ConfiguredProject.prototype.getProjectName = function () { + return this.configFileName; + }; + ConfiguredProject.prototype.watchConfigFile = function (callback) { + var _this = this; + this.projectFileWatcher = this.projectService.host.watchFile(this.configFileName, function (_) { return callback(_this); }); + }; + ConfiguredProject.prototype.watchTypeRoots = function (callback) { + var _this = this; + var roots = this.getEffectiveTypeRoots(); + var watchers = []; + for (var _i = 0, roots_1 = roots; _i < roots_1.length; _i++) { + var root = roots_1[_i]; + this.projectService.logger.info("Add type root watcher for: " + root); + watchers.push(this.projectService.host.watchDirectory(root, function (path) { return callback(_this, path); }, false)); + } + this.typeRootsWatchers = watchers; + }; + ConfiguredProject.prototype.watchConfigDirectory = function (callback) { + var _this = this; + if (this.directoryWatcher) { + return; + } + var directoryToWatch = ts.getDirectoryPath(this.configFileName); + this.projectService.logger.info("Add recursive watcher for: " + directoryToWatch); + this.directoryWatcher = this.projectService.host.watchDirectory(directoryToWatch, function (path) { return callback(_this, path); }, true); + }; + ConfiguredProject.prototype.watchWildcards = function (callback) { + var _this = this; + if (!this.wildcardDirectories) { + return; + } + var configDirectoryPath = ts.getDirectoryPath(this.configFileName); + this.directoriesWatchedForWildcards = ts.reduceProperties(this.wildcardDirectories, function (watchers, flag, directory) { + if (ts.comparePaths(configDirectoryPath, directory, ".", !_this.projectService.host.useCaseSensitiveFileNames) !== 0) { + var recursive = (flag & 1) !== 0; + _this.projectService.logger.info("Add " + (recursive ? "recursive " : "") + "watcher for: " + directory); + watchers[directory] = _this.projectService.host.watchDirectory(directory, function (path) { return callback(_this, path); }, recursive); + } + return watchers; + }, {}); + }; + ConfiguredProject.prototype.stopWatchingDirectory = function () { + if (this.directoryWatcher) { + this.directoryWatcher.close(); + this.directoryWatcher = undefined; + } + }; + ConfiguredProject.prototype.close = function () { + _super.prototype.close.call(this); + if (this.projectFileWatcher) { + this.projectFileWatcher.close(); + } + if (this.typeRootsWatchers) { + for (var _i = 0, _a = this.typeRootsWatchers; _i < _a.length; _i++) { + var watcher = _a[_i]; + watcher.close(); + } + this.typeRootsWatchers = undefined; + } + for (var id in this.directoriesWatchedForWildcards) { + this.directoriesWatchedForWildcards[id].close(); + } + this.directoriesWatchedForWildcards = undefined; + this.stopWatchingDirectory(); + }; + ConfiguredProject.prototype.addOpenRef = function () { + this.openRefCount++; + }; + ConfiguredProject.prototype.deleteOpenRef = function () { + this.openRefCount--; + return this.openRefCount; + }; + ConfiguredProject.prototype.getEffectiveTypeRoots = function () { + return ts.getEffectiveTypeRoots(this.getCompilerOptions(), this.projectService.host) || []; + }; + return ConfiguredProject; + }(Project)); + server.ConfiguredProject = ConfiguredProject; + var ExternalProject = (function (_super) { + __extends(ExternalProject, _super); + function ExternalProject(externalProjectName, projectService, documentRegistry, compilerOptions, languageServiceEnabled, compileOnSaveEnabled, projectFilePath) { + var _this = _super.call(this, ProjectKind.External, projectService, documentRegistry, true, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) || this; + _this.externalProjectName = externalProjectName; + _this.compileOnSaveEnabled = compileOnSaveEnabled; + _this.projectFilePath = projectFilePath; + return _this; + } + ExternalProject.prototype.getProjectRootPath = function () { + if (this.projectFilePath) { + return ts.getDirectoryPath(this.projectFilePath); + } + return ts.getDirectoryPath(ts.normalizeSlashes(this.externalProjectName)); + }; + ExternalProject.prototype.getTypingOptions = function () { + return this.typingOptions; + }; + ExternalProject.prototype.setProjectErrors = function (projectErrors) { + this.projectErrors = projectErrors; + }; + ExternalProject.prototype.setTypingOptions = function (newTypingOptions) { + if (!newTypingOptions) { + newTypingOptions = { + enableAutoDiscovery: allRootFilesAreJsOrDts(this), + include: [], + exclude: [] + }; + } + else { + if (newTypingOptions.enableAutoDiscovery === undefined) { + newTypingOptions.enableAutoDiscovery = allRootFilesAreJsOrDts(this); + } + if (!newTypingOptions.include) { + newTypingOptions.include = []; + } + if (!newTypingOptions.exclude) { + newTypingOptions.exclude = []; + } + } + this.typingOptions = newTypingOptions; + }; + ExternalProject.prototype.getProjectName = function () { + return this.externalProjectName; + }; + return ExternalProject; + }(Project)); + server.ExternalProject = ExternalProject; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + server.maxProgramSizeForNonTsFiles = 20 * 1024 * 1024; + function combineProjectOutput(projects, action, comparer, areEqual) { + var result = projects.reduce(function (previous, current) { return ts.concatenate(previous, action(current)); }, []).sort(comparer); + return projects.length > 1 ? ts.deduplicate(result, areEqual) : result; + } + server.combineProjectOutput = combineProjectOutput; + var fileNamePropertyReader = { + getFileName: function (x) { return x; }, + getScriptKind: function (_) { return undefined; }, + hasMixedContent: function (_) { return false; } + }; + var externalFilePropertyReader = { + getFileName: function (x) { return x.fileName; }, + getScriptKind: function (x) { return x.scriptKind; }, + hasMixedContent: function (x) { return x.hasMixedContent; } + }; + function findProjectByName(projectName, projects) { + for (var _i = 0, projects_1 = projects; _i < projects_1.length; _i++) { + var proj = projects_1[_i]; + if (proj.getProjectName() === projectName) { + return proj; + } + } + } + function createFileNotFoundDiagnostic(fileName) { + return ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, fileName); + } + function isRootFileInInferredProject(info) { + if (info.containingProjects.length === 0) { + return false; + } + return info.containingProjects[0].projectKind === server.ProjectKind.Inferred && info.containingProjects[0].isRoot(info); + } + var DirectoryWatchers = (function () { + function DirectoryWatchers(projectService) { + this.projectService = projectService; + this.directoryWatchersForTsconfig = ts.createMap(); + this.directoryWatchersRefCount = ts.createMap(); + } + DirectoryWatchers.prototype.stopWatchingDirectory = function (directory) { + this.directoryWatchersRefCount[directory]--; + if (this.directoryWatchersRefCount[directory] === 0) { + this.projectService.logger.info("Close directory watcher for: " + directory); + this.directoryWatchersForTsconfig[directory].close(); + delete this.directoryWatchersForTsconfig[directory]; + } + }; + DirectoryWatchers.prototype.startWatchingContainingDirectoriesForFile = function (fileName, project, callback) { + var currentPath = ts.getDirectoryPath(fileName); + var parentPath = ts.getDirectoryPath(currentPath); + while (currentPath != parentPath) { + if (!this.directoryWatchersForTsconfig[currentPath]) { + this.projectService.logger.info("Add watcher for: " + currentPath); + this.directoryWatchersForTsconfig[currentPath] = this.projectService.host.watchDirectory(currentPath, callback); + this.directoryWatchersRefCount[currentPath] = 1; + } + else { + this.directoryWatchersRefCount[currentPath] += 1; + } + project.directoriesWatchedForTsconfig.push(currentPath); + currentPath = parentPath; + parentPath = ts.getDirectoryPath(parentPath); + } + }; + return DirectoryWatchers; + }()); + var ProjectService = (function () { + function ProjectService(host, logger, cancellationToken, useSingleInferredProject, typingsInstaller, eventHandler) { + if (typingsInstaller === void 0) { typingsInstaller = server.nullTypingsInstaller; } + this.host = host; + this.logger = logger; + this.cancellationToken = cancellationToken; + this.useSingleInferredProject = useSingleInferredProject; + this.typingsInstaller = typingsInstaller; + this.eventHandler = eventHandler; + this.filenameToScriptInfo = ts.createFileMap(); + this.externalProjectToConfiguredProjectMap = ts.createMap(); + this.externalProjects = []; + this.inferredProjects = []; + this.configuredProjects = []; + this.openFiles = []; + this.toCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); + this.directoryWatchers = new DirectoryWatchers(this); + this.throttledOperations = new server.ThrottledOperations(host); + this.typingsInstaller.attach(this); + this.typingsCache = new server.TypingsCache(this.typingsInstaller); + this.hostConfiguration = { + formatCodeOptions: server.getDefaultFormatCodeSettings(this.host), + hostInfo: "Unknown host" + }; + this.documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames, host.getCurrentDirectory()); + } + ProjectService.prototype.getChangedFiles_TestOnly = function () { + return this.changedFiles; + }; + ProjectService.prototype.ensureInferredProjectsUpToDate_TestOnly = function () { + this.ensureInferredProjectsUpToDate(); + }; + ProjectService.prototype.updateTypingsForProject = function (response) { + var project = this.findProject(response.projectName); + if (!project) { + return; + } + switch (response.kind) { + case "set": + this.typingsCache.updateTypingsForProject(response.projectName, response.compilerOptions, response.typingOptions, response.typings); + project.updateGraph(); + break; + case "invalidate": + this.typingsCache.invalidateCachedTypingsForProject(project); + break; + } + }; + ProjectService.prototype.setCompilerOptionsForInferredProjects = function (projectCompilerOptions) { + this.compilerOptionsForInferredProjects = projectCompilerOptions; + this.compileOnSaveForInferredProjects = projectCompilerOptions.compileOnSave; + for (var _i = 0, _a = this.inferredProjects; _i < _a.length; _i++) { + var proj = _a[_i]; + proj.setCompilerOptions(projectCompilerOptions); + proj.compileOnSaveEnabled = projectCompilerOptions.compileOnSave; + } + this.updateProjectGraphs(this.inferredProjects); + }; + ProjectService.prototype.stopWatchingDirectory = function (directory) { + this.directoryWatchers.stopWatchingDirectory(directory); + }; + ProjectService.prototype.findProject = function (projectName) { + if (projectName === undefined) { + return undefined; + } + if (server.isInferredProjectName(projectName)) { + this.ensureInferredProjectsUpToDate(); + return findProjectByName(projectName, this.inferredProjects); + } + return this.findExternalProjectByProjectName(projectName) || this.findConfiguredProjectByProjectName(server.toNormalizedPath(projectName)); + }; + ProjectService.prototype.getDefaultProjectForFile = function (fileName, refreshInferredProjects) { + if (refreshInferredProjects) { + this.ensureInferredProjectsUpToDate(); + } + var scriptInfo = this.getScriptInfoForNormalizedPath(fileName); + return scriptInfo && scriptInfo.getDefaultProject(); + }; + ProjectService.prototype.ensureInferredProjectsUpToDate = function () { + if (this.changedFiles) { + var projectsToUpdate = void 0; + if (this.changedFiles.length === 1) { + projectsToUpdate = this.changedFiles[0].containingProjects; + } + else { + projectsToUpdate = []; + for (var _i = 0, _a = this.changedFiles; _i < _a.length; _i++) { + var f = _a[_i]; + projectsToUpdate = projectsToUpdate.concat(f.containingProjects); + } + } + this.updateProjectGraphs(projectsToUpdate); + this.changedFiles = undefined; + } + }; + ProjectService.prototype.findContainingExternalProject = function (fileName) { + for (var _i = 0, _a = this.externalProjects; _i < _a.length; _i++) { + var proj = _a[_i]; + if (proj.containsFile(fileName)) { + return proj; + } + } + return undefined; + }; + ProjectService.prototype.getFormatCodeOptions = function (file) { + var formatCodeSettings; + if (file) { + var info = this.getScriptInfoForNormalizedPath(file); + if (info) { + formatCodeSettings = info.getFormatCodeSettings(); + } + } + return formatCodeSettings || this.hostConfiguration.formatCodeOptions; + }; + ProjectService.prototype.updateProjectGraphs = function (projects) { + var shouldRefreshInferredProjects = false; + for (var _i = 0, projects_2 = projects; _i < projects_2.length; _i++) { + var p = projects_2[_i]; + if (!p.updateGraph()) { + shouldRefreshInferredProjects = true; + } + } + if (shouldRefreshInferredProjects) { + this.refreshInferredProjects(); + } + }; + ProjectService.prototype.onSourceFileChanged = function (fileName) { + var info = this.getScriptInfoForNormalizedPath(fileName); + if (!info) { + this.logger.info("Error: got watch notification for unknown file: " + fileName); + return; + } + if (!this.host.fileExists(fileName)) { + this.handleDeletedFile(info); + } + else { + if (info && (!info.isOpen)) { + info.reloadFromFile(); + this.updateProjectGraphs(info.containingProjects); + } + } + }; + ProjectService.prototype.handleDeletedFile = function (info) { + this.logger.info(info.fileName + " deleted"); + info.stopWatcher(); + if (!info.isOpen) { + this.filenameToScriptInfo.remove(info.path); + this.lastDeletedFile = info; + var containingProjects = info.containingProjects.slice(); + info.detachAllProjects(); + this.updateProjectGraphs(containingProjects); + this.lastDeletedFile = undefined; + if (!this.eventHandler) { + return; + } + for (var _i = 0, _a = this.openFiles; _i < _a.length; _i++) { + var openFile = _a[_i]; + this.eventHandler({ eventName: "context", data: { project: openFile.getDefaultProject(), fileName: openFile.fileName } }); + } + } + this.printProjects(); + }; + ProjectService.prototype.onTypeRootFileChanged = function (project, fileName) { + var _this = this; + this.logger.info("Type root file " + fileName + " changed"); + this.throttledOperations.schedule(project.configFileName + " * type root", 250, function () { + project.updateTypes(); + _this.updateConfiguredProject(project); + _this.refreshInferredProjects(); + }); + }; + ProjectService.prototype.onSourceFileInDirectoryChangedForConfiguredProject = function (project, fileName) { + var _this = this; + if (fileName && !ts.isSupportedSourceFileName(fileName, project.getCompilerOptions())) { + return; + } + this.logger.info("Detected source file changes: " + fileName); + this.throttledOperations.schedule(project.configFileName, 250, function () { return _this.handleChangeInSourceFileForConfiguredProject(project); }); + }; + ProjectService.prototype.handleChangeInSourceFileForConfiguredProject = function (project) { + var _this = this; + var _a = this.convertConfigFileContentToProjectOptions(project.configFileName), projectOptions = _a.projectOptions, configFileErrors = _a.configFileErrors; + this.reportConfigFileDiagnostics(project.getProjectName(), configFileErrors); + var newRootFiles = projectOptions.files.map((function (f) { return _this.getCanonicalFileName(f); })); + var currentRootFiles = project.getRootFiles().map((function (f) { return _this.getCanonicalFileName(f); })); + if (!ts.arrayIsEqualTo(currentRootFiles.sort(), newRootFiles.sort())) { + this.logger.info("Updating configured project"); + this.updateConfiguredProject(project); + this.refreshInferredProjects(); + } + }; + ProjectService.prototype.onConfigChangedForConfiguredProject = function (project) { + this.logger.info("Config file changed: " + project.configFileName); + this.updateConfiguredProject(project); + this.refreshInferredProjects(); + }; + ProjectService.prototype.onConfigFileAddedForInferredProject = function (fileName) { + if (ts.getBaseFileName(fileName) != "tsconfig.json") { + this.logger.info(fileName + " is not tsconfig.json"); + return; + } + var configFileErrors = this.convertConfigFileContentToProjectOptions(fileName).configFileErrors; + this.reportConfigFileDiagnostics(fileName, configFileErrors); + this.logger.info("Detected newly added tsconfig file: " + fileName); + this.reloadProjects(); + }; + ProjectService.prototype.getCanonicalFileName = function (fileName) { + var name = this.host.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); + return ts.normalizePath(name); + }; + ProjectService.prototype.removeProject = function (project) { + this.logger.info("remove project: " + project.getRootFiles().toString()); + project.close(); + switch (project.projectKind) { + case server.ProjectKind.External: + server.removeItemFromSet(this.externalProjects, project); + break; + case server.ProjectKind.Configured: + server.removeItemFromSet(this.configuredProjects, project); + break; + case server.ProjectKind.Inferred: + server.removeItemFromSet(this.inferredProjects, project); + break; + } + }; + ProjectService.prototype.assignScriptInfoToInferredProjectIfNecessary = function (info, addToListOfOpenFiles) { + var externalProject = this.findContainingExternalProject(info.fileName); + if (externalProject) { + if (addToListOfOpenFiles) { + this.openFiles.push(info); + } + return; + } + var foundConfiguredProject = false; + for (var _i = 0, _a = info.containingProjects; _i < _a.length; _i++) { + var p = _a[_i]; + if (p.projectKind === server.ProjectKind.Configured) { + foundConfiguredProject = true; + if (addToListOfOpenFiles) { + (p).addOpenRef(); + } + } + } + if (foundConfiguredProject) { + if (addToListOfOpenFiles) { + this.openFiles.push(info); + } + return; + } + if (info.containingProjects.length === 0) { + var inferredProject = this.createInferredProjectWithRootFileIfNecessary(info); + if (!this.useSingleInferredProject) { + for (var _b = 0, _c = this.openFiles; _b < _c.length; _b++) { + var f = _c[_b]; + if (f.containingProjects.length === 0) { + continue; + } + var defaultProject = f.getDefaultProject(); + if (isRootFileInInferredProject(info) && defaultProject !== inferredProject && inferredProject.containsScriptInfo(f)) { + this.removeProject(defaultProject); + f.attachToProject(inferredProject); + } + } + } + } + if (addToListOfOpenFiles) { + this.openFiles.push(info); + } + }; + ProjectService.prototype.closeOpenFile = function (info) { + info.reloadFromFile(); + server.removeItemFromSet(this.openFiles, info); + info.isOpen = false; + var projectsToRemove; + for (var _i = 0, _a = info.containingProjects; _i < _a.length; _i++) { + var p = _a[_i]; + if (p.projectKind === server.ProjectKind.Configured) { + if (p.deleteOpenRef() === 0) { + (projectsToRemove || (projectsToRemove = [])).push(p); + } + } + else if (p.projectKind === server.ProjectKind.Inferred && p.isRoot(info)) { + (projectsToRemove || (projectsToRemove = [])).push(p); + } + } + if (projectsToRemove) { + for (var _b = 0, projectsToRemove_1 = projectsToRemove; _b < projectsToRemove_1.length; _b++) { + var project = projectsToRemove_1[_b]; + this.removeProject(project); + } + var orphanFiles = void 0; + for (var _c = 0, _d = this.openFiles; _c < _d.length; _c++) { + var f = _d[_c]; + if (f.containingProjects.length === 0) { + (orphanFiles || (orphanFiles = [])).push(f); + } + } + if (orphanFiles) { + for (var _e = 0, orphanFiles_1 = orphanFiles; _e < orphanFiles_1.length; _e++) { + var f = orphanFiles_1[_e]; + this.assignScriptInfoToInferredProjectIfNecessary(f, false); + } + } + } + if (info.containingProjects.length === 0) { + this.filenameToScriptInfo.remove(info.path); + } + }; + ProjectService.prototype.openOrUpdateConfiguredProjectForFile = function (fileName) { + var searchPath = ts.getDirectoryPath(fileName); + this.logger.info("Search path: " + searchPath); + var configFileName = this.findConfigFile(server.asNormalizedPath(searchPath)); + if (!configFileName) { + this.logger.info("No config files found."); + return {}; + } + this.logger.info("Config file name: " + configFileName); + var project = this.findConfiguredProjectByProjectName(configFileName); + if (!project) { + var _a = this.openConfigFile(configFileName, fileName), success = _a.success, errors = _a.errors; + if (!success) { + return { configFileName: configFileName, configFileErrors: errors }; + } + this.logger.info("Opened configuration file " + configFileName); + if (errors && errors.length > 0) { + return { configFileName: configFileName, configFileErrors: errors }; + } + } + else { + this.updateConfiguredProject(project); + } + return { configFileName: configFileName }; + }; + ProjectService.prototype.findConfigFile = function (searchPath) { + while (true) { + var tsconfigFileName = server.asNormalizedPath(ts.combinePaths(searchPath, "tsconfig.json")); + if (this.host.fileExists(tsconfigFileName)) { + return tsconfigFileName; + } + var jsconfigFileName = server.asNormalizedPath(ts.combinePaths(searchPath, "jsconfig.json")); + if (this.host.fileExists(jsconfigFileName)) { + return jsconfigFileName; + } + var parentPath = server.asNormalizedPath(ts.getDirectoryPath(searchPath)); + if (parentPath === searchPath) { + break; + } + searchPath = parentPath; + } + return undefined; + }; + ProjectService.prototype.printProjects = function () { + if (!this.logger.hasLevel(server.LogLevel.verbose)) { + return; + } + this.logger.startGroup(); + var counter = 0; + counter = printProjects(this.logger, this.externalProjects, counter); + counter = printProjects(this.logger, this.configuredProjects, counter); + counter = printProjects(this.logger, this.inferredProjects, counter); + this.logger.info("Open files: "); + for (var _i = 0, _a = this.openFiles; _i < _a.length; _i++) { + var rootFile = _a[_i]; + this.logger.info(rootFile.fileName); + } + this.logger.endGroup(); + function printProjects(logger, projects, counter) { + for (var _i = 0, projects_3 = projects; _i < projects_3.length; _i++) { + var project = projects_3[_i]; + project.updateGraph(); + logger.info("Project '" + project.getProjectName() + "' (" + server.ProjectKind[project.projectKind] + ") " + counter); + logger.info(project.filesToString()); + logger.info("-----------------------------------------------"); + counter++; + } + return counter; + } + }; + ProjectService.prototype.findConfiguredProjectByProjectName = function (configFileName) { + return findProjectByName(configFileName, this.configuredProjects); + }; + ProjectService.prototype.findExternalProjectByProjectName = function (projectFileName) { + return findProjectByName(projectFileName, this.externalProjects); + }; + ProjectService.prototype.convertConfigFileContentToProjectOptions = function (configFilename) { + configFilename = ts.normalizePath(configFilename); + var configFileContent = this.host.readFile(configFilename); + var errors; + var result = ts.parseConfigFileTextToJson(configFilename, configFileContent); + var config = result.config; + if (result.error) { + var _a = ts.sanitizeConfigFile(configFilename, configFileContent), sanitizedConfig = _a.configJsonObject, diagnostics = _a.diagnostics; + config = sanitizedConfig; + errors = diagnostics.length ? diagnostics : [result.error]; + } + var parsedCommandLine = ts.parseJsonConfigFileContent(config, this.host, ts.getDirectoryPath(configFilename), {}, configFilename); + if (parsedCommandLine.errors.length) { + errors = ts.concatenate(errors, parsedCommandLine.errors); + } + ts.Debug.assert(!!parsedCommandLine.fileNames); + if (parsedCommandLine.fileNames.length === 0) { + (errors || (errors = [])).push(ts.createCompilerDiagnostic(ts.Diagnostics.The_config_file_0_found_doesn_t_contain_any_source_files, configFilename)); + return { success: false, configFileErrors: errors }; + } + var projectOptions = { + files: parsedCommandLine.fileNames, + compilerOptions: parsedCommandLine.options, + configHasFilesProperty: config["files"] !== undefined, + wildcardDirectories: ts.createMap(parsedCommandLine.wildcardDirectories), + typingOptions: parsedCommandLine.typingOptions, + compileOnSave: parsedCommandLine.compileOnSave + }; + return { success: true, projectOptions: projectOptions, configFileErrors: errors }; + }; + ProjectService.prototype.exceededTotalSizeLimitForNonTsFiles = function (options, fileNames, propertyReader) { + if (options && options.disableSizeLimit || !this.host.getFileSize) { + return false; + } + var totalNonTsFileSize = 0; + for (var _i = 0, fileNames_3 = fileNames; _i < fileNames_3.length; _i++) { + var f = fileNames_3[_i]; + var fileName = propertyReader.getFileName(f); + if (ts.hasTypeScriptFileExtension(fileName)) { + continue; + } + totalNonTsFileSize += this.host.getFileSize(fileName); + if (totalNonTsFileSize > server.maxProgramSizeForNonTsFiles) { + return true; + } + } + return false; + }; + ProjectService.prototype.createAndAddExternalProject = function (projectFileName, files, options, typingOptions) { + var project = new server.ExternalProject(projectFileName, this, this.documentRegistry, options, !this.exceededTotalSizeLimitForNonTsFiles(options, files, externalFilePropertyReader), options.compileOnSave === undefined ? true : options.compileOnSave); + this.addFilesToProjectAndUpdateGraph(project, files, externalFilePropertyReader, undefined, typingOptions, undefined); + this.externalProjects.push(project); + return project; + }; + ProjectService.prototype.reportConfigFileDiagnostics = function (configFileName, diagnostics, triggerFile) { + if (!this.eventHandler) { + return; + } + this.eventHandler({ + eventName: "configFileDiag", + data: { configFileName: configFileName, diagnostics: diagnostics || [], triggerFile: triggerFile } + }); + }; + ProjectService.prototype.createAndAddConfiguredProject = function (configFileName, projectOptions, configFileErrors, clientFileName) { + var _this = this; + var sizeLimitExceeded = this.exceededTotalSizeLimitForNonTsFiles(projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader); + var project = new server.ConfiguredProject(configFileName, this, this.documentRegistry, projectOptions.configHasFilesProperty, projectOptions.compilerOptions, projectOptions.wildcardDirectories, !sizeLimitExceeded, projectOptions.compileOnSave === undefined ? false : projectOptions.compileOnSave); + this.addFilesToProjectAndUpdateGraph(project, projectOptions.files, fileNamePropertyReader, clientFileName, projectOptions.typingOptions, configFileErrors); + project.watchConfigFile(function (project) { return _this.onConfigChangedForConfiguredProject(project); }); + if (!sizeLimitExceeded) { + this.watchConfigDirectoryForProject(project, projectOptions); + } + project.watchWildcards(function (project, path) { return _this.onSourceFileInDirectoryChangedForConfiguredProject(project, path); }); + project.watchTypeRoots(function (project, path) { return _this.onTypeRootFileChanged(project, path); }); + this.configuredProjects.push(project); + return project; + }; + ProjectService.prototype.watchConfigDirectoryForProject = function (project, options) { + var _this = this; + if (!options.configHasFilesProperty) { + project.watchConfigDirectory(function (project, path) { return _this.onSourceFileInDirectoryChangedForConfiguredProject(project, path); }); + } + }; + ProjectService.prototype.addFilesToProjectAndUpdateGraph = function (project, files, propertyReader, clientFileName, typingOptions, configFileErrors) { + var errors; + for (var _i = 0, files_4 = files; _i < files_4.length; _i++) { + var f = files_4[_i]; + var rootFilename = propertyReader.getFileName(f); + var scriptKind = propertyReader.getScriptKind(f); + var hasMixedContent = propertyReader.hasMixedContent(f); + if (this.host.fileExists(rootFilename)) { + var info = this.getOrCreateScriptInfoForNormalizedPath(server.toNormalizedPath(rootFilename), clientFileName == rootFilename, undefined, scriptKind, hasMixedContent); + project.addRoot(info); + } + else { + (errors || (errors = [])).push(createFileNotFoundDiagnostic(rootFilename)); + } + } + project.setProjectErrors(ts.concatenate(configFileErrors, errors)); + project.setTypingOptions(typingOptions); + project.updateGraph(); + }; + ProjectService.prototype.openConfigFile = function (configFileName, clientFileName) { + var conversionResult = this.convertConfigFileContentToProjectOptions(configFileName); + var projectOptions = conversionResult.success + ? conversionResult.projectOptions + : { files: [], compilerOptions: {} }; + var project = this.createAndAddConfiguredProject(configFileName, projectOptions, conversionResult.configFileErrors, clientFileName); + return { + success: conversionResult.success, + project: project, + errors: project.getProjectErrors() + }; + }; + ProjectService.prototype.updateNonInferredProject = function (project, newUncheckedFiles, propertyReader, newOptions, newTypingOptions, compileOnSave, configFileErrors) { + var oldRootScriptInfos = project.getRootScriptInfos(); + var newRootScriptInfos = []; + var newRootScriptInfoMap = server.createNormalizedPathMap(); + var projectErrors; + var rootFilesChanged = false; + for (var _i = 0, newUncheckedFiles_1 = newUncheckedFiles; _i < newUncheckedFiles_1.length; _i++) { + var f = newUncheckedFiles_1[_i]; + var newRootFile = propertyReader.getFileName(f); + if (!this.host.fileExists(newRootFile)) { + (projectErrors || (projectErrors = [])).push(createFileNotFoundDiagnostic(newRootFile)); + continue; + } + var normalizedPath = server.toNormalizedPath(newRootFile); + var scriptInfo = this.getScriptInfoForNormalizedPath(normalizedPath); + if (!scriptInfo || !project.isRoot(scriptInfo)) { + rootFilesChanged = true; + if (!scriptInfo) { + var scriptKind = propertyReader.getScriptKind(f); + var hasMixedContent = propertyReader.hasMixedContent(f); + scriptInfo = this.getOrCreateScriptInfoForNormalizedPath(normalizedPath, false, undefined, scriptKind, hasMixedContent); + } + } + newRootScriptInfos.push(scriptInfo); + newRootScriptInfoMap.set(scriptInfo.fileName, scriptInfo); + } + if (rootFilesChanged || newRootScriptInfos.length !== oldRootScriptInfos.length) { + var toAdd = void 0; + var toRemove = void 0; + for (var _a = 0, oldRootScriptInfos_1 = oldRootScriptInfos; _a < oldRootScriptInfos_1.length; _a++) { + var oldFile = oldRootScriptInfos_1[_a]; + if (!newRootScriptInfoMap.contains(oldFile.fileName)) { + (toRemove || (toRemove = [])).push(oldFile); + } + } + for (var _b = 0, newRootScriptInfos_1 = newRootScriptInfos; _b < newRootScriptInfos_1.length; _b++) { + var newFile = newRootScriptInfos_1[_b]; + if (!project.isRoot(newFile)) { + (toAdd || (toAdd = [])).push(newFile); + } + } + if (toRemove) { + for (var _c = 0, toRemove_1 = toRemove; _c < toRemove_1.length; _c++) { + var f = toRemove_1[_c]; + project.removeFile(f); + } + } + if (toAdd) { + for (var _d = 0, toAdd_1 = toAdd; _d < toAdd_1.length; _d++) { + var f = toAdd_1[_d]; + if (f.isOpen && isRootFileInInferredProject(f)) { + var inferredProject = f.containingProjects[0]; + inferredProject.removeFile(f); + if (!inferredProject.hasRoots()) { + this.removeProject(inferredProject); + } + } + project.addRoot(f); + } + } + } + project.setCompilerOptions(newOptions); + project.setTypingOptions(newTypingOptions); + if (compileOnSave !== undefined) { + project.compileOnSaveEnabled = compileOnSave; + } + project.setProjectErrors(ts.concatenate(configFileErrors, projectErrors)); + project.updateGraph(); + }; + ProjectService.prototype.updateConfiguredProject = function (project) { + if (!this.host.fileExists(project.configFileName)) { + this.logger.info("Config file deleted"); + this.removeProject(project); + return; + } + var _a = this.convertConfigFileContentToProjectOptions(project.configFileName), success = _a.success, projectOptions = _a.projectOptions, configFileErrors = _a.configFileErrors; + if (!success) { + this.updateNonInferredProject(project, [], fileNamePropertyReader, {}, {}, false, configFileErrors); + return configFileErrors; + } + if (this.exceededTotalSizeLimitForNonTsFiles(projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader)) { + project.setCompilerOptions(projectOptions.compilerOptions); + if (!project.languageServiceEnabled) { + return; + } + project.disableLanguageService(); + project.stopWatchingDirectory(); + } + else { + if (!project.languageServiceEnabled) { + project.enableLanguageService(); + } + this.watchConfigDirectoryForProject(project, projectOptions); + this.updateNonInferredProject(project, projectOptions.files, fileNamePropertyReader, projectOptions.compilerOptions, projectOptions.typingOptions, projectOptions.compileOnSave, configFileErrors); + } + }; + ProjectService.prototype.createInferredProjectWithRootFileIfNecessary = function (root) { + var _this = this; + var useExistingProject = this.useSingleInferredProject && this.inferredProjects.length; + var project = useExistingProject + ? this.inferredProjects[0] + : new server.InferredProject(this, this.documentRegistry, true, this.compilerOptionsForInferredProjects, this.compileOnSaveForInferredProjects); + project.addRoot(root); + this.directoryWatchers.startWatchingContainingDirectoriesForFile(root.fileName, project, function (fileName) { return _this.onConfigFileAddedForInferredProject(fileName); }); + project.updateGraph(); + if (!useExistingProject) { + this.inferredProjects.push(project); + } + return project; + }; + ProjectService.prototype.getOrCreateScriptInfo = function (uncheckedFileName, openedByClient, fileContent, scriptKind) { + return this.getOrCreateScriptInfoForNormalizedPath(server.toNormalizedPath(uncheckedFileName), openedByClient, fileContent, scriptKind); + }; + ProjectService.prototype.getScriptInfo = function (uncheckedFileName) { + return this.getScriptInfoForNormalizedPath(server.toNormalizedPath(uncheckedFileName)); + }; + ProjectService.prototype.getOrCreateScriptInfoForNormalizedPath = function (fileName, openedByClient, fileContent, scriptKind, hasMixedContent) { + var _this = this; + var info = this.getScriptInfoForNormalizedPath(fileName); + if (!info) { + var content = void 0; + if (this.host.fileExists(fileName)) { + content = fileContent || (hasMixedContent ? "" : this.host.readFile(fileName)); + } + if (!content) { + if (openedByClient) { + content = ""; + } + } + if (content !== undefined) { + info = new server.ScriptInfo(this.host, fileName, content, scriptKind, openedByClient, hasMixedContent); + this.filenameToScriptInfo.set(info.path, info); + if (!info.isOpen && !hasMixedContent) { + info.setWatcher(this.host.watchFile(fileName, function (_) { return _this.onSourceFileChanged(fileName); })); + } + } + } + if (info) { + if (fileContent !== undefined) { + info.reload(fileContent); + } + if (openedByClient) { + info.isOpen = true; + } + } + return info; + }; + ProjectService.prototype.getScriptInfoForNormalizedPath = function (fileName) { + return this.getScriptInfoForPath(server.normalizedPathToPath(fileName, this.host.getCurrentDirectory(), this.toCanonicalFileName)); + }; + ProjectService.prototype.getScriptInfoForPath = function (fileName) { + return this.filenameToScriptInfo.get(fileName); + }; + ProjectService.prototype.setHostConfiguration = function (args) { + if (args.file) { + var info = this.getScriptInfoForNormalizedPath(server.toNormalizedPath(args.file)); + if (info) { + info.setFormatOptions(args.formatOptions); + this.logger.info("Host configuration update for file " + args.file); + } + } + else { + if (args.hostInfo !== undefined) { + this.hostConfiguration.hostInfo = args.hostInfo; + this.logger.info("Host information " + args.hostInfo); + } + if (args.formatOptions) { + server.mergeMaps(this.hostConfiguration.formatCodeOptions, args.formatOptions); + this.logger.info("Format host information updated"); + } + } + }; + ProjectService.prototype.closeLog = function () { + this.logger.close(); + }; + ProjectService.prototype.reloadProjects = function () { + this.logger.info("reload projects."); + for (var _i = 0, _a = this.openFiles; _i < _a.length; _i++) { + var info = _a[_i]; + this.openOrUpdateConfiguredProjectForFile(info.fileName); + } + this.refreshInferredProjects(); + }; + ProjectService.prototype.refreshInferredProjects = function () { + this.logger.info("updating project structure from ..."); + this.printProjects(); + var orphantedFiles = []; + for (var _i = 0, _a = this.openFiles; _i < _a.length; _i++) { + var info = _a[_i]; + if (info.containingProjects.length === 0) { + orphantedFiles.push(info); + } + else { + if (isRootFileInInferredProject(info) && info.containingProjects.length > 1) { + var inferredProject = info.containingProjects[0]; + ts.Debug.assert(inferredProject.projectKind === server.ProjectKind.Inferred); + inferredProject.removeFile(info); + if (!inferredProject.hasRoots()) { + this.removeProject(inferredProject); + } + } + } + } + for (var _b = 0, orphantedFiles_1 = orphantedFiles; _b < orphantedFiles_1.length; _b++) { + var f = orphantedFiles_1[_b]; + this.assignScriptInfoToInferredProjectIfNecessary(f, false); + } + for (var _c = 0, _d = this.inferredProjects; _c < _d.length; _c++) { + var p = _d[_c]; + p.updateGraph(); + } + this.printProjects(); + }; + ProjectService.prototype.openClientFile = function (fileName, fileContent, scriptKind) { + return this.openClientFileWithNormalizedPath(server.toNormalizedPath(fileName), fileContent, scriptKind); + }; + ProjectService.prototype.openClientFileWithNormalizedPath = function (fileName, fileContent, scriptKind, hasMixedContent) { + var _a = this.findContainingExternalProject(fileName) + ? {} + : this.openOrUpdateConfiguredProjectForFile(fileName), _b = _a.configFileName, configFileName = _b === void 0 ? undefined : _b, _c = _a.configFileErrors, configFileErrors = _c === void 0 ? undefined : _c; + var info = this.getOrCreateScriptInfoForNormalizedPath(fileName, true, fileContent, scriptKind, hasMixedContent); + this.assignScriptInfoToInferredProjectIfNecessary(info, true); + this.printProjects(); + return { configFileName: configFileName, configFileErrors: configFileErrors }; + }; + ProjectService.prototype.closeClientFile = function (uncheckedFileName) { + var info = this.getScriptInfoForNormalizedPath(server.toNormalizedPath(uncheckedFileName)); + if (info) { + this.closeOpenFile(info); + info.isOpen = false; + } + this.printProjects(); + }; + ProjectService.prototype.collectChanges = function (lastKnownProjectVersions, currentProjects, result) { + var _loop_3 = function (proj) { + var knownProject = ts.forEach(lastKnownProjectVersions, function (p) { return p.projectName === proj.getProjectName() && p; }); + result.push(proj.getChangesSinceVersion(knownProject && knownProject.version)); + }; + for (var _i = 0, currentProjects_1 = currentProjects; _i < currentProjects_1.length; _i++) { + var proj = currentProjects_1[_i]; + _loop_3(proj); + } + }; + ProjectService.prototype.synchronizeProjectList = function (knownProjects) { + var files = []; + this.collectChanges(knownProjects, this.externalProjects, files); + this.collectChanges(knownProjects, this.configuredProjects, files); + this.collectChanges(knownProjects, this.inferredProjects, files); + return files; + }; + ProjectService.prototype.applyChangesInOpenFiles = function (openFiles, changedFiles, closedFiles) { + var recordChangedFiles = changedFiles && !openFiles && !closedFiles; + if (openFiles) { + for (var _i = 0, openFiles_1 = openFiles; _i < openFiles_1.length; _i++) { + var file = openFiles_1[_i]; + var scriptInfo = this.getScriptInfo(file.fileName); + ts.Debug.assert(!scriptInfo || !scriptInfo.isOpen); + var normalizedPath = scriptInfo ? scriptInfo.fileName : server.toNormalizedPath(file.fileName); + this.openClientFileWithNormalizedPath(normalizedPath, file.content, file.scriptKind, file.hasMixedContent); + } + } + if (changedFiles) { + for (var _a = 0, changedFiles_1 = changedFiles; _a < changedFiles_1.length; _a++) { + var file = changedFiles_1[_a]; + var scriptInfo = this.getScriptInfo(file.fileName); + ts.Debug.assert(!!scriptInfo); + for (var i = file.changes.length - 1; i >= 0; i--) { + var change = file.changes[i]; + scriptInfo.editContent(change.span.start, change.span.start + change.span.length, change.newText); + } + if (recordChangedFiles) { + if (!this.changedFiles) { + this.changedFiles = [scriptInfo]; + } + else if (this.changedFiles.indexOf(scriptInfo) < 0) { + this.changedFiles.push(scriptInfo); + } + } + } + } + if (closedFiles) { + for (var _b = 0, closedFiles_1 = closedFiles; _b < closedFiles_1.length; _b++) { + var file = closedFiles_1[_b]; + this.closeClientFile(file); + } + } + if (openFiles || closedFiles) { + this.refreshInferredProjects(); + } + }; + ProjectService.prototype.closeConfiguredProject = function (configFile) { + var configuredProject = this.findConfiguredProjectByProjectName(configFile); + if (configuredProject && configuredProject.deleteOpenRef() === 0) { + this.removeProject(configuredProject); + } + }; + ProjectService.prototype.closeExternalProject = function (uncheckedFileName, suppressRefresh) { + if (suppressRefresh === void 0) { suppressRefresh = false; } + var fileName = server.toNormalizedPath(uncheckedFileName); + var configFiles = this.externalProjectToConfiguredProjectMap[fileName]; + if (configFiles) { + var shouldRefreshInferredProjects = false; + for (var _i = 0, configFiles_1 = configFiles; _i < configFiles_1.length; _i++) { + var configFile = configFiles_1[_i]; + if (this.closeConfiguredProject(configFile)) { + shouldRefreshInferredProjects = true; + } + } + delete this.externalProjectToConfiguredProjectMap[fileName]; + if (shouldRefreshInferredProjects && !suppressRefresh) { + this.refreshInferredProjects(); + } + } + else { + var externalProject = this.findExternalProjectByProjectName(uncheckedFileName); + if (externalProject) { + this.removeProject(externalProject); + if (!suppressRefresh) { + this.refreshInferredProjects(); + } + } + } + }; + ProjectService.prototype.openExternalProject = function (proj) { + var tsConfigFiles; + var rootFiles = []; + for (var _i = 0, _a = proj.rootFiles; _i < _a.length; _i++) { + var file = _a[_i]; + var normalized = server.toNormalizedPath(file.fileName); + if (ts.getBaseFileName(normalized) === "tsconfig.json") { + (tsConfigFiles || (tsConfigFiles = [])).push(normalized); + } + else { + rootFiles.push(file); + } + } + if (tsConfigFiles) { + tsConfigFiles.sort(); + } + var externalProject = this.findExternalProjectByProjectName(proj.projectFileName); + var exisingConfigFiles; + if (externalProject) { + if (!tsConfigFiles) { + this.updateNonInferredProject(externalProject, proj.rootFiles, externalFilePropertyReader, proj.options, proj.typingOptions, proj.options.compileOnSave, undefined); + return; + } + this.closeExternalProject(proj.projectFileName, true); + } + else if (this.externalProjectToConfiguredProjectMap[proj.projectFileName]) { + if (!tsConfigFiles) { + this.closeExternalProject(proj.projectFileName, true); + } + else { + var oldConfigFiles = this.externalProjectToConfiguredProjectMap[proj.projectFileName]; + var iNew = 0; + var iOld = 0; + while (iNew < tsConfigFiles.length && iOld < oldConfigFiles.length) { + var newConfig = tsConfigFiles[iNew]; + var oldConfig = oldConfigFiles[iOld]; + if (oldConfig < newConfig) { + this.closeConfiguredProject(oldConfig); + iOld++; + } + else if (oldConfig > newConfig) { + iNew++; + } + else { + (exisingConfigFiles || (exisingConfigFiles = [])).push(oldConfig); + iOld++; + iNew++; + } + } + for (var i = iOld; i < oldConfigFiles.length; i++) { + this.closeConfiguredProject(oldConfigFiles[i]); + } + } + } + if (tsConfigFiles) { + this.externalProjectToConfiguredProjectMap[proj.projectFileName] = tsConfigFiles; + for (var _b = 0, tsConfigFiles_1 = tsConfigFiles; _b < tsConfigFiles_1.length; _b++) { + var tsconfigFile = tsConfigFiles_1[_b]; + var project = this.findConfiguredProjectByProjectName(tsconfigFile); + if (!project) { + var result = this.openConfigFile(tsconfigFile); + project = result.success && result.project; + } + if (project && !ts.contains(exisingConfigFiles, tsconfigFile)) { + project.addOpenRef(); + } + } + } + else { + delete this.externalProjectToConfiguredProjectMap[proj.projectFileName]; + this.createAndAddExternalProject(proj.projectFileName, rootFiles, proj.options, proj.typingOptions); + } + this.refreshInferredProjects(); + }; + return ProjectService; + }()); + server.ProjectService = ProjectService; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var server; + (function (server) { + function hrTimeToMilliseconds(time) { + var seconds = time[0]; + var nanoseconds = time[1]; + return ((1e9 * seconds) + nanoseconds) / 1000000.0; + } + function shouldSkipSematicCheck(project) { + if (project.getCompilerOptions().skipLibCheck !== undefined) { + return false; + } + if ((project.projectKind === server.ProjectKind.Inferred || project.projectKind === server.ProjectKind.External) && project.isJsOnlyProject()) { + return true; + } + return false; + } function compareNumber(a, b) { - if (a < b) { - return -1; - } - else if (a === b) { - return 0; - } - else - return 1; + return a - b; } function compareFileStart(a, b) { if (a.file < b.file) { @@ -60288,10 +63334,12 @@ var ts; } } function formatDiag(fileName, project, diag) { + var scriptInfo = project.getScriptInfoForNormalizedPath(fileName); return { - start: project.compilerService.host.positionToLineOffset(fileName, diag.start), - end: project.compilerService.host.positionToLineOffset(fileName, diag.start + diag.length), - text: ts.flattenDiagnosticMessageText(diag.messageText, "\n") + start: scriptInfo.positionToLineOffset(diag.start), + end: scriptInfo.positionToLineOffset(diag.start + diag.length), + text: ts.flattenDiagnosticMessageText(diag.messageText, "\n"), + code: diag.code }; } function formatConfigFileDiag(diag) { @@ -60302,8 +63350,9 @@ var ts; }; } function allEditsBeforePos(edits, pos) { - for (var i = 0, len = edits.length; i < len; i++) { - if (ts.textSpanEnd(edits[i].span) >= pos) { + for (var _i = 0, edits_1 = edits; _i < edits_1.length; _i++) { + var edit = edits_1[_i]; + if (ts.textSpanEnd(edit.span) >= pos) { return false; } } @@ -60312,73 +63361,166 @@ var ts; var CommandNames; (function (CommandNames) { CommandNames.Brace = "brace"; + CommandNames.BraceFull = "brace-full"; + CommandNames.BraceCompletion = "braceCompletion"; CommandNames.Change = "change"; CommandNames.Close = "close"; CommandNames.Completions = "completions"; + CommandNames.CompletionsFull = "completions-full"; CommandNames.CompletionDetails = "completionEntryDetails"; + CommandNames.CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList"; + CommandNames.CompileOnSaveEmitFile = "compileOnSaveEmitFile"; CommandNames.Configure = "configure"; CommandNames.Definition = "definition"; + CommandNames.DefinitionFull = "definition-full"; CommandNames.Exit = "exit"; CommandNames.Format = "format"; CommandNames.Formatonkey = "formatonkey"; + CommandNames.FormatFull = "format-full"; + CommandNames.FormatonkeyFull = "formatonkey-full"; + CommandNames.FormatRangeFull = "formatRange-full"; CommandNames.Geterr = "geterr"; CommandNames.GeterrForProject = "geterrForProject"; CommandNames.Implementation = "implementation"; + CommandNames.ImplementationFull = "implementation-full"; CommandNames.SemanticDiagnosticsSync = "semanticDiagnosticsSync"; CommandNames.SyntacticDiagnosticsSync = "syntacticDiagnosticsSync"; CommandNames.NavBar = "navbar"; + CommandNames.NavBarFull = "navbar-full"; + CommandNames.NavTree = "navtree"; + CommandNames.NavTreeFull = "navtree-full"; CommandNames.Navto = "navto"; + CommandNames.NavtoFull = "navto-full"; CommandNames.Occurrences = "occurrences"; CommandNames.DocumentHighlights = "documentHighlights"; + CommandNames.DocumentHighlightsFull = "documentHighlights-full"; CommandNames.Open = "open"; CommandNames.Quickinfo = "quickinfo"; + CommandNames.QuickinfoFull = "quickinfo-full"; CommandNames.References = "references"; + CommandNames.ReferencesFull = "references-full"; CommandNames.Reload = "reload"; CommandNames.Rename = "rename"; + CommandNames.RenameInfoFull = "rename-full"; + CommandNames.RenameLocationsFull = "renameLocations-full"; CommandNames.Saveto = "saveto"; CommandNames.SignatureHelp = "signatureHelp"; + CommandNames.SignatureHelpFull = "signatureHelp-full"; CommandNames.TypeDefinition = "typeDefinition"; CommandNames.ProjectInfo = "projectInfo"; CommandNames.ReloadProjects = "reloadProjects"; CommandNames.Unknown = "unknown"; + CommandNames.OpenExternalProject = "openExternalProject"; + CommandNames.OpenExternalProjects = "openExternalProjects"; + CommandNames.CloseExternalProject = "closeExternalProject"; + CommandNames.SynchronizeProjectList = "synchronizeProjectList"; + CommandNames.ApplyChangedToOpenFiles = "applyChangedToOpenFiles"; + CommandNames.EncodedSemanticClassificationsFull = "encodedSemanticClassifications-full"; + CommandNames.Cleanup = "cleanup"; + CommandNames.OutliningSpans = "outliningSpans"; + CommandNames.TodoComments = "todoComments"; + CommandNames.Indentation = "indentation"; + CommandNames.DocCommentTemplate = "docCommentTemplate"; + CommandNames.CompilerOptionsDiagnosticsFull = "compilerOptionsDiagnostics-full"; + CommandNames.NameOrDottedNameSpan = "nameOrDottedNameSpan"; + CommandNames.BreakpointStatement = "breakpointStatement"; + CommandNames.CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects"; + CommandNames.GetCodeFixes = "getCodeFixes"; + CommandNames.GetCodeFixesFull = "getCodeFixes-full"; + CommandNames.GetSupportedCodeFixes = "getSupportedCodeFixes"; })(CommandNames = server.CommandNames || (server.CommandNames = {})); - var Errors; - (function (Errors) { - Errors.NoProject = new Error("No Project."); - Errors.ProjectLanguageServiceDisabled = new Error("The project's language service is disabled."); - })(Errors || (Errors = {})); + function formatMessage(msg, logger, byteLength, newLine) { + var verboseLogging = logger.hasLevel(server.LogLevel.verbose); + var json = JSON.stringify(msg); + if (verboseLogging) { + logger.info(msg.type + ": " + json); + } + var len = byteLength(json, "utf8"); + return "Content-Length: " + (1 + len) + "\r\n\r\n" + json + newLine; + } + server.formatMessage = formatMessage; var Session = (function () { - function Session(host, byteLength, hrtime, logger) { + function Session(host, cancellationToken, useSingleInferredProject, typingsInstaller, byteLength, hrtime, logger, canUseEvents, eventHandler) { var _this = this; this.host = host; + this.typingsInstaller = typingsInstaller; this.byteLength = byteLength; this.hrtime = hrtime; this.logger = logger; + this.canUseEvents = canUseEvents; this.changeSeq = 0; this.handlers = ts.createMap((_a = {}, + _a[CommandNames.OpenExternalProject] = function (request) { + _this.projectService.openExternalProject(request.arguments); + return _this.requiredResponse(true); + }, + _a[CommandNames.OpenExternalProjects] = function (request) { + for (var _i = 0, _a = request.arguments.projects; _i < _a.length; _i++) { + var proj = _a[_i]; + _this.projectService.openExternalProject(proj); + } + return _this.requiredResponse(true); + }, + _a[CommandNames.CloseExternalProject] = function (request) { + _this.projectService.closeExternalProject(request.arguments.projectFileName); + return _this.requiredResponse(true); + }, + _a[CommandNames.SynchronizeProjectList] = function (request) { + var result = _this.projectService.synchronizeProjectList(request.arguments.knownProjects); + if (!result.some(function (p) { return p.projectErrors && p.projectErrors.length !== 0; })) { + return _this.requiredResponse(result); + } + var converted = ts.map(result, function (p) { + if (!p.projectErrors || p.projectErrors.length === 0) { + return p; + } + return { + info: p.info, + changes: p.changes, + files: p.files, + projectErrors: _this.convertToDiagnosticsWithLinePosition(p.projectErrors, undefined) + }; + }); + return _this.requiredResponse(converted); + }, + _a[CommandNames.ApplyChangedToOpenFiles] = function (request) { + _this.projectService.applyChangesInOpenFiles(request.arguments.openFiles, request.arguments.changedFiles, request.arguments.closedFiles); + _this.changeSeq++; + return _this.requiredResponse(true); + }, _a[CommandNames.Exit] = function () { _this.exit(); - return { responseRequired: false }; + return _this.notRequired(); }, _a[CommandNames.Definition] = function (request) { - var defArgs = request.arguments; - return { response: _this.getDefinition(defArgs.line, defArgs.offset, defArgs.file), responseRequired: true }; + return _this.requiredResponse(_this.getDefinition(request.arguments, true)); + }, + _a[CommandNames.DefinitionFull] = function (request) { + return _this.requiredResponse(_this.getDefinition(request.arguments, false)); }, _a[CommandNames.TypeDefinition] = function (request) { - var defArgs = request.arguments; - return { response: _this.getTypeDefinition(defArgs.line, defArgs.offset, defArgs.file), responseRequired: true }; + return _this.requiredResponse(_this.getTypeDefinition(request.arguments)); }, _a[CommandNames.Implementation] = function (request) { - var implArgs = request.arguments; - return { response: _this.getImplementation(implArgs.line, implArgs.offset, implArgs.file), responseRequired: true }; + return _this.requiredResponse(_this.getImplementation(request.arguments, true)); + }, + _a[CommandNames.ImplementationFull] = function (request) { + return _this.requiredResponse(_this.getImplementation(request.arguments, false)); }, _a[CommandNames.References] = function (request) { - var defArgs = request.arguments; - return { response: _this.getReferences(defArgs.line, defArgs.offset, defArgs.file), responseRequired: true }; + return _this.requiredResponse(_this.getReferences(request.arguments, true)); + }, + _a[CommandNames.ReferencesFull] = function (request) { + return _this.requiredResponse(_this.getReferences(request.arguments, false)); }, _a[CommandNames.Rename] = function (request) { - var renameArgs = request.arguments; - return { response: _this.getRenameLocations(renameArgs.line, renameArgs.offset, renameArgs.file, renameArgs.findInComments, renameArgs.findInStrings), responseRequired: true }; + return _this.requiredResponse(_this.getRenameLocations(request.arguments, true)); + }, + _a[CommandNames.RenameLocationsFull] = function (request) { + return _this.requiredResponse(_this.getRenameLocations(request.arguments, false)); + }, + _a[CommandNames.RenameInfoFull] = function (request) { + return _this.requiredResponse(_this.getRenameInfo(request.arguments)); }, _a[CommandNames.Open] = function (request) { var openArgs = request.arguments; @@ -60397,34 +63539,81 @@ var ts; scriptKind = 2; break; } - _this.openClientFile(openArgs.file, openArgs.fileContent, scriptKind); - return { responseRequired: false }; + _this.openClientFile(server.toNormalizedPath(openArgs.file), openArgs.fileContent, scriptKind); + return _this.notRequired(); }, _a[CommandNames.Quickinfo] = function (request) { - var quickinfoArgs = request.arguments; - return { response: _this.getQuickInfo(quickinfoArgs.line, quickinfoArgs.offset, quickinfoArgs.file), responseRequired: true }; + return _this.requiredResponse(_this.getQuickInfoWorker(request.arguments, true)); + }, + _a[CommandNames.QuickinfoFull] = function (request) { + return _this.requiredResponse(_this.getQuickInfoWorker(request.arguments, false)); + }, + _a[CommandNames.OutliningSpans] = function (request) { + return _this.requiredResponse(_this.getOutliningSpans(request.arguments)); + }, + _a[CommandNames.TodoComments] = function (request) { + return _this.requiredResponse(_this.getTodoComments(request.arguments)); + }, + _a[CommandNames.Indentation] = function (request) { + return _this.requiredResponse(_this.getIndentation(request.arguments)); + }, + _a[CommandNames.NameOrDottedNameSpan] = function (request) { + return _this.requiredResponse(_this.getNameOrDottedNameSpan(request.arguments)); + }, + _a[CommandNames.BreakpointStatement] = function (request) { + return _this.requiredResponse(_this.getBreakpointStatement(request.arguments)); + }, + _a[CommandNames.BraceCompletion] = function (request) { + return _this.requiredResponse(_this.isValidBraceCompletion(request.arguments)); + }, + _a[CommandNames.DocCommentTemplate] = function (request) { + return _this.requiredResponse(_this.getDocCommentTemplate(request.arguments)); }, _a[CommandNames.Format] = function (request) { - var formatArgs = request.arguments; - return { response: _this.getFormattingEditsForRange(formatArgs.line, formatArgs.offset, formatArgs.endLine, formatArgs.endOffset, formatArgs.file), responseRequired: true }; + return _this.requiredResponse(_this.getFormattingEditsForRange(request.arguments)); }, _a[CommandNames.Formatonkey] = function (request) { - var formatOnKeyArgs = request.arguments; - return { response: _this.getFormattingEditsAfterKeystroke(formatOnKeyArgs.line, formatOnKeyArgs.offset, formatOnKeyArgs.key, formatOnKeyArgs.file), responseRequired: true }; + return _this.requiredResponse(_this.getFormattingEditsAfterKeystroke(request.arguments)); + }, + _a[CommandNames.FormatFull] = function (request) { + return _this.requiredResponse(_this.getFormattingEditsForDocumentFull(request.arguments)); + }, + _a[CommandNames.FormatonkeyFull] = function (request) { + return _this.requiredResponse(_this.getFormattingEditsAfterKeystrokeFull(request.arguments)); + }, + _a[CommandNames.FormatRangeFull] = function (request) { + return _this.requiredResponse(_this.getFormattingEditsForRangeFull(request.arguments)); }, _a[CommandNames.Completions] = function (request) { - var completionsArgs = request.arguments; - return { response: _this.getCompletions(completionsArgs.line, completionsArgs.offset, completionsArgs.prefix, completionsArgs.file), responseRequired: true }; + return _this.requiredResponse(_this.getCompletions(request.arguments, true)); + }, + _a[CommandNames.CompletionsFull] = function (request) { + return _this.requiredResponse(_this.getCompletions(request.arguments, false)); }, _a[CommandNames.CompletionDetails] = function (request) { - var completionDetailsArgs = request.arguments; - return { - response: _this.getCompletionEntryDetails(completionDetailsArgs.line, completionDetailsArgs.offset, completionDetailsArgs.entryNames, completionDetailsArgs.file), responseRequired: true - }; + return _this.requiredResponse(_this.getCompletionEntryDetails(request.arguments)); + }, + _a[CommandNames.CompileOnSaveAffectedFileList] = function (request) { + return _this.requiredResponse(_this.getCompileOnSaveAffectedFileList(request.arguments)); + }, + _a[CommandNames.CompileOnSaveEmitFile] = function (request) { + return _this.requiredResponse(_this.emitFile(request.arguments)); }, _a[CommandNames.SignatureHelp] = function (request) { - var signatureHelpArgs = request.arguments; - return { response: _this.getSignatureHelpItems(signatureHelpArgs.line, signatureHelpArgs.offset, signatureHelpArgs.file), responseRequired: true }; + return _this.requiredResponse(_this.getSignatureHelpItems(request.arguments, true)); + }, + _a[CommandNames.SignatureHelpFull] = function (request) { + return _this.requiredResponse(_this.getSignatureHelpItems(request.arguments, false)); + }, + _a[CommandNames.CompilerOptionsDiagnosticsFull] = function (request) { + return _this.requiredResponse(_this.getCompilerOptionsDiagnostics(request.arguments)); + }, + _a[CommandNames.EncodedSemanticClassificationsFull] = function (request) { + return _this.requiredResponse(_this.getEncodedSemanticClassifications(request.arguments)); + }, + _a[CommandNames.Cleanup] = function (request) { + _this.cleanup(); + return _this.requiredResponse(true); }, _a[CommandNames.SemanticDiagnosticsSync] = function (request) { return _this.requiredResponse(_this.getSemanticDiagnosticsSync(request.arguments)); @@ -60441,72 +63630,94 @@ var ts; return { response: _this.getDiagnosticsForProject(delay, file), responseRequired: false }; }, _a[CommandNames.Change] = function (request) { - var changeArgs = request.arguments; - _this.change(changeArgs.line, changeArgs.offset, changeArgs.endLine, changeArgs.endOffset, changeArgs.insertString, changeArgs.file); - return { responseRequired: false }; + _this.change(request.arguments); + return _this.notRequired(); }, _a[CommandNames.Configure] = function (request) { - var configureArgs = request.arguments; - _this.projectService.setHostConfiguration(configureArgs); + _this.projectService.setHostConfiguration(request.arguments); _this.output(undefined, CommandNames.Configure, request.seq); - return { responseRequired: false }; + return _this.notRequired(); }, _a[CommandNames.Reload] = function (request) { - var reloadArgs = request.arguments; - _this.reload(reloadArgs.file, reloadArgs.tmpfile, request.seq); - return { response: { reloadFinished: true }, responseRequired: true }; + _this.reload(request.arguments, request.seq); + return _this.requiredResponse({ reloadFinished: true }); }, _a[CommandNames.Saveto] = function (request) { var savetoArgs = request.arguments; _this.saveToTmp(savetoArgs.file, savetoArgs.tmpfile); - return { responseRequired: false }; + return _this.notRequired(); }, _a[CommandNames.Close] = function (request) { var closeArgs = request.arguments; _this.closeClientFile(closeArgs.file); - return { responseRequired: false }; + return _this.notRequired(); }, _a[CommandNames.Navto] = function (request) { - var navtoArgs = request.arguments; - return { response: _this.getNavigateToItems(navtoArgs.searchValue, navtoArgs.file, navtoArgs.maxResultCount, navtoArgs.currentFileOnly), responseRequired: true }; + return _this.requiredResponse(_this.getNavigateToItems(request.arguments, true)); + }, + _a[CommandNames.NavtoFull] = function (request) { + return _this.requiredResponse(_this.getNavigateToItems(request.arguments, false)); }, _a[CommandNames.Brace] = function (request) { - var braceArguments = request.arguments; - return { response: _this.getBraceMatching(braceArguments.line, braceArguments.offset, braceArguments.file), responseRequired: true }; + return _this.requiredResponse(_this.getBraceMatching(request.arguments, true)); + }, + _a[CommandNames.BraceFull] = function (request) { + return _this.requiredResponse(_this.getBraceMatching(request.arguments, false)); }, _a[CommandNames.NavBar] = function (request) { - var navBarArgs = request.arguments; - return { response: _this.getNavigationBarItems(navBarArgs.file), responseRequired: true }; + return _this.requiredResponse(_this.getNavigationBarItems(request.arguments, true)); + }, + _a[CommandNames.NavBarFull] = function (request) { + return _this.requiredResponse(_this.getNavigationBarItems(request.arguments, false)); + }, + _a[CommandNames.NavTree] = function (request) { + return _this.requiredResponse(_this.getNavigationTree(request.arguments, true)); + }, + _a[CommandNames.NavTreeFull] = function (request) { + return _this.requiredResponse(_this.getNavigationTree(request.arguments, false)); }, _a[CommandNames.Occurrences] = function (request) { - var _a = request.arguments, line = _a.line, offset = _a.offset, fileName = _a.file; - return { response: _this.getOccurrences(line, offset, fileName), responseRequired: true }; + return _this.requiredResponse(_this.getOccurrences(request.arguments)); }, _a[CommandNames.DocumentHighlights] = function (request) { - var _a = request.arguments, line = _a.line, offset = _a.offset, fileName = _a.file, filesToSearch = _a.filesToSearch; - return { response: _this.getDocumentHighlights(line, offset, fileName, filesToSearch), responseRequired: true }; + return _this.requiredResponse(_this.getDocumentHighlights(request.arguments, true)); + }, + _a[CommandNames.DocumentHighlightsFull] = function (request) { + return _this.requiredResponse(_this.getDocumentHighlights(request.arguments, false)); + }, + _a[CommandNames.CompilerOptionsForInferredProjects] = function (request) { + return _this.requiredResponse(_this.setCompilerOptionsForInferredProjects(request.arguments)); }, _a[CommandNames.ProjectInfo] = function (request) { - var _a = request.arguments, file = _a.file, needFileNameList = _a.needFileNameList; - return { response: _this.getProjectInfo(file, needFileNameList), responseRequired: true }; + return _this.requiredResponse(_this.getProjectInfo(request.arguments)); }, _a[CommandNames.ReloadProjects] = function (request) { - _this.reloadProjects(); - return { responseRequired: false }; + _this.projectService.reloadProjects(); + return _this.notRequired(); + }, + _a[CommandNames.GetCodeFixes] = function (request) { + return _this.requiredResponse(_this.getCodeFixes(request.arguments, true)); + }, + _a[CommandNames.GetCodeFixesFull] = function (request) { + return _this.requiredResponse(_this.getCodeFixes(request.arguments, false)); + }, + _a[CommandNames.GetSupportedCodeFixes] = function (request) { + return _this.requiredResponse(_this.getSupportedCodeFixes()); }, _a)); - this.projectService = - new server.ProjectService(host, logger, function (event) { - _this.handleEvent(event); - }); + this.eventHander = canUseEvents + ? eventHandler || (function (event) { return _this.defaultEventHandler(event); }) + : undefined; + this.projectService = new server.ProjectService(host, logger, cancellationToken, useSingleInferredProject, typingsInstaller, this.eventHander); + this.gcTimer = new server.GcTimer(host, 7000, logger); var _a; } - Session.prototype.handleEvent = function (event) { + Session.prototype.defaultEventHandler = function (event) { var _this = this; switch (event.eventName) { case "context": var _a = event.data, project = _a.project, fileName = _a.fileName; - this.projectService.log("got context event, updating diagnostics for" + fileName, "Info"); + this.projectService.logger.info("got context event, updating diagnostics for " + fileName); this.updateErrorCheck([{ fileName: fileName, project: project }], this.changeSeq, function (n) { return n === _this.changeSeq; }, 100); break; case "configFileDiag": @@ -60515,26 +63726,23 @@ var ts; } }; Session.prototype.logError = function (err, cmd) { - var typedErr = err; var msg = "Exception on executing command " + cmd; - if (typedErr.message) { - msg += ":\n" + typedErr.message; - if (typedErr.stack) { - msg += "\n" + typedErr.stack; + if (err.message) { + msg += ":\n" + err.message; + if (err.stack) { + msg += "\n" + err.stack; } } - this.projectService.log(msg); - }; - Session.prototype.sendLineToClient = function (line) { - this.host.write(line + this.host.newLine); + this.logger.msg(msg, server.Msg.Err); }; Session.prototype.send = function (msg) { - var json = JSON.stringify(msg); - if (this.logger.isVerbose()) { - this.logger.info(msg.type + ": " + json); + if (msg.type === "event" && !this.canUseEvents) { + if (this.logger.hasLevel(server.LogLevel.verbose)) { + this.logger.info("Session does not support events: ignored event: " + JSON.stringify(msg)); + } + return; } - this.sendLineToClient("Content-Length: " + (1 + this.byteLength(json, "utf8")) + - "\r\n\r\n" + json); + this.host.write(formatMessage(msg, this.logger, this.byteLength, this.host.newLine)); }; Session.prototype.configFileDiagnosticEvent = function (triggerFile, configFile, diagnostics) { var bakedDiags = ts.map(diagnostics, formatConfigFileDiag); @@ -60559,7 +63767,7 @@ var ts; }; this.send(ev); }; - Session.prototype.response = function (info, cmdName, reqSeq, errorMsg) { + Session.prototype.output = function (info, cmdName, reqSeq, errorMsg) { if (reqSeq === void 0) { reqSeq = 0; } var res = { seq: 0, @@ -60576,17 +63784,14 @@ var ts; } this.send(res); }; - Session.prototype.output = function (body, commandName, requestSequence, errorMessage) { - if (requestSequence === void 0) { requestSequence = 0; } - this.response(body, commandName, requestSequence, errorMessage); - }; Session.prototype.semanticCheck = function (file, project) { try { - var diags = project.compilerService.languageService.getSemanticDiagnostics(file); - if (diags) { - var bakedDiags = diags.map(function (diag) { return formatDiag(file, project, diag); }); - this.event({ file: file, diagnostics: bakedDiags }, "semanticDiag"); + var diags = []; + if (!shouldSkipSematicCheck(project)) { + diags = project.getLanguageService().getSemanticDiagnostics(file); } + var bakedDiags = diags.map(function (diag) { return formatDiag(file, project, diag); }); + this.event({ file: file, diagnostics: bakedDiags }, "semanticDiag"); } catch (err) { this.logError(err, "semantic check"); @@ -60594,7 +63799,7 @@ var ts; }; Session.prototype.syntacticCheck = function (file, project) { try { - var diags = project.compilerService.languageService.getSyntacticDiagnostics(file); + var diags = project.getLanguageService().getSyntacticDiagnostics(file); if (diags) { var bakedDiags = diags.map(function (diag) { return formatDiag(file, project, diag); }); this.event({ file: file, diagnostics: bakedDiags }, "syntaxDiag"); @@ -60604,15 +63809,12 @@ var ts; this.logError(err, "syntactic check"); } }; - Session.prototype.reloadProjects = function () { - this.projectService.reloadProjects(); - }; Session.prototype.updateProjectStructure = function (seq, matchSeq, ms) { var _this = this; if (ms === void 0) { ms = 1500; } - setTimeout(function () { + this.host.setTimeout(function () { if (matchSeq(seq)) { - _this.projectService.updateProjectStructure(); + _this.projectService.refreshInferredProjects(); } }, ms); }; @@ -60625,10 +63827,10 @@ var ts; followMs = ms; } if (this.errorTimer) { - clearTimeout(this.errorTimer); + this.host.clearTimeout(this.errorTimer); } if (this.immediateId) { - clearImmediate(this.immediateId); + this.host.clearImmediate(this.immediateId); this.immediateId = undefined; } var index = 0; @@ -60636,13 +63838,13 @@ var ts; if (matchSeq(seq)) { var checkSpec_1 = checkList[index]; index++; - if (checkSpec_1.project.getSourceFileFromName(checkSpec_1.fileName, requireOpen)) { + if (checkSpec_1.project.containsFile(checkSpec_1.fileName, requireOpen)) { _this.syntacticCheck(checkSpec_1.fileName, checkSpec_1.project); - _this.immediateId = setImmediate(function () { + _this.immediateId = _this.host.setImmediate(function () { _this.semanticCheck(checkSpec_1.fileName, checkSpec_1.project); _this.immediateId = undefined; if (checkList.length > index) { - _this.errorTimer = setTimeout(checkOne, followMs); + _this.errorTimer = _this.host.setTimeout(checkOne, followMs); } else { _this.errorTimer = undefined; @@ -60652,78 +63854,133 @@ var ts; } }; if ((checkList.length > index) && (matchSeq(seq))) { - this.errorTimer = setTimeout(checkOne, ms); + this.errorTimer = this.host.setTimeout(checkOne, ms); } }; - Session.prototype.getDefinition = function (line, offset, fileName) { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project || project.languageServiceDiabled) { - throw Errors.NoProject; + Session.prototype.cleanProjects = function (caption, projects) { + if (!projects) { + return; } - var compilerService = project.compilerService; - var position = compilerService.host.lineOffsetToPosition(file, line, offset); - var definitions = compilerService.languageService.getDefinitionAtPosition(file, position); + this.logger.info("cleaning " + caption); + for (var _i = 0, projects_4 = projects; _i < projects_4.length; _i++) { + var p = projects_4[_i]; + p.getLanguageService(false).cleanupSemanticCache(); + } + }; + Session.prototype.cleanup = function () { + this.cleanProjects("inferred projects", this.projectService.inferredProjects); + this.cleanProjects("configured projects", this.projectService.configuredProjects); + this.cleanProjects("external projects", this.projectService.externalProjects); + if (this.host.gc) { + this.logger.info("host.gc()"); + this.host.gc(); + } + }; + Session.prototype.getEncodedSemanticClassifications = function (args) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + return project.getLanguageService().getEncodedSemanticClassifications(file, args); + }; + Session.prototype.getProject = function (projectFileName) { + return projectFileName && this.projectService.findProject(projectFileName); + }; + Session.prototype.getCompilerOptionsDiagnostics = function (args) { + var project = this.getProject(args.projectFileName); + return this.convertToDiagnosticsWithLinePosition(project.getLanguageService().getCompilerOptionsDiagnostics(), undefined); + }; + Session.prototype.convertToDiagnosticsWithLinePosition = function (diagnostics, scriptInfo) { + var _this = this; + return diagnostics.map(function (d) { return ({ + message: ts.flattenDiagnosticMessageText(d.messageText, _this.host.newLine), + start: d.start, + length: d.length, + category: ts.DiagnosticCategory[d.category].toLowerCase(), + code: d.code, + startLocation: scriptInfo && scriptInfo.positionToLineOffset(d.start), + endLocation: scriptInfo && scriptInfo.positionToLineOffset(d.start + d.length) + }); }); + }; + Session.prototype.getDiagnosticsWorker = function (args, selector, includeLinePosition) { + var _a = this.getFileAndProject(args), project = _a.project, file = _a.file; + if (shouldSkipSematicCheck(project)) { + return []; + } + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var diagnostics = selector(project, file); + return includeLinePosition + ? this.convertToDiagnosticsWithLinePosition(diagnostics, scriptInfo) + : diagnostics.map(function (d) { return formatDiag(file, project, d); }); + }; + Session.prototype.getDefinition = function (args, simplifiedResult) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + var definitions = project.getLanguageService().getDefinitionAtPosition(file, position); if (!definitions) { return undefined; } - return definitions.map(function (def) { return ({ - file: def.fileName, - start: compilerService.host.positionToLineOffset(def.fileName, def.textSpan.start), - end: compilerService.host.positionToLineOffset(def.fileName, ts.textSpanEnd(def.textSpan)) - }); }); - }; - Session.prototype.getTypeDefinition = function (line, offset, fileName) { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project || project.languageServiceDiabled) { - throw Errors.NoProject; + if (simplifiedResult) { + return definitions.map(function (def) { + var defScriptInfo = project.getScriptInfo(def.fileName); + return { + file: def.fileName, + start: defScriptInfo.positionToLineOffset(def.textSpan.start), + end: defScriptInfo.positionToLineOffset(ts.textSpanEnd(def.textSpan)) + }; + }); } - var compilerService = project.compilerService; - var position = compilerService.host.lineOffsetToPosition(file, line, offset); - var definitions = compilerService.languageService.getTypeDefinitionAtPosition(file, position); + else { + return definitions; + } + }; + Session.prototype.getTypeDefinition = function (args) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + var definitions = project.getLanguageService().getTypeDefinitionAtPosition(file, position); if (!definitions) { return undefined; } - return definitions.map(function (def) { return ({ - file: def.fileName, - start: compilerService.host.positionToLineOffset(def.fileName, def.textSpan.start), - end: compilerService.host.positionToLineOffset(def.fileName, ts.textSpanEnd(def.textSpan)) - }); }); + return definitions.map(function (def) { + var defScriptInfo = project.getScriptInfo(def.fileName); + return { + file: def.fileName, + start: defScriptInfo.positionToLineOffset(def.textSpan.start), + end: defScriptInfo.positionToLineOffset(ts.textSpanEnd(def.textSpan)) + }; + }); }; - Session.prototype.getImplementation = function (line, offset, fileName) { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project || project.languageServiceDiabled) { - throw Errors.NoProject; - } - var compilerService = project.compilerService; - var implementations = compilerService.languageService.getImplementationAtPosition(file, compilerService.host.lineOffsetToPosition(file, line, offset)); + Session.prototype.getImplementation = function (args, simplifiedResult) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + var implementations = project.getLanguageService().getImplementationAtPosition(file, position); if (!implementations) { - return undefined; + return []; + } + if (simplifiedResult) { + return implementations.map(function (impl) { return ({ + file: impl.fileName, + start: scriptInfo.positionToLineOffset(impl.textSpan.start), + end: scriptInfo.positionToLineOffset(ts.textSpanEnd(impl.textSpan)) + }); }); + } + else { + return implementations; } - return implementations.map(function (impl) { return ({ - file: impl.fileName, - start: compilerService.host.positionToLineOffset(impl.fileName, impl.textSpan.start), - end: compilerService.host.positionToLineOffset(impl.fileName, ts.textSpanEnd(impl.textSpan)) - }); }); }; - Session.prototype.getOccurrences = function (line, offset, fileName) { - fileName = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(fileName); - if (!project || project.languageServiceDiabled) { - throw Errors.NoProject; - } - var compilerService = project.compilerService; - var position = compilerService.host.lineOffsetToPosition(fileName, line, offset); - var occurrences = compilerService.languageService.getOccurrencesAtPosition(fileName, position); + Session.prototype.getOccurrences = function (args) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + var occurrences = project.getLanguageService().getOccurrencesAtPosition(file, position); if (!occurrences) { return undefined; } return occurrences.map(function (occurrence) { var fileName = occurrence.fileName, isWriteAccess = occurrence.isWriteAccess, textSpan = occurrence.textSpan; - var start = compilerService.host.positionToLineOffset(fileName, textSpan.start); - var end = compilerService.host.positionToLineOffset(fileName, ts.textSpanEnd(textSpan)); + var scriptInfo = project.getScriptInfo(fileName); + var start = scriptInfo.positionToLineOffset(textSpan.start); + var end = scriptInfo.positionToLineOffset(ts.textSpanEnd(textSpan)); return { start: start, end: end, @@ -60732,115 +63989,142 @@ var ts; }; }); }; - Session.prototype.getDiagnosticsWorker = function (args, selector) { - var file = ts.normalizePath(args.file); - var project = this.projectService.getProjectForFile(file); - if (!project) { - throw Errors.NoProject; - } - if (project.languageServiceDiabled) { - throw Errors.ProjectLanguageServiceDisabled; - } - var diagnostics = selector(project, file); - return ts.map(diagnostics, function (originalDiagnostic) { return formatDiag(file, project, originalDiagnostic); }); - }; Session.prototype.getSyntacticDiagnosticsSync = function (args) { - return this.getDiagnosticsWorker(args, function (project, file) { return project.compilerService.languageService.getSyntacticDiagnostics(file); }); + return this.getDiagnosticsWorker(args, function (project, file) { return project.getLanguageService().getSyntacticDiagnostics(file); }, args.includeLinePosition); }; Session.prototype.getSemanticDiagnosticsSync = function (args) { - return this.getDiagnosticsWorker(args, function (project, file) { return project.compilerService.languageService.getSemanticDiagnostics(file); }); + return this.getDiagnosticsWorker(args, function (project, file) { return project.getLanguageService().getSemanticDiagnostics(file); }, args.includeLinePosition); }; - Session.prototype.getDocumentHighlights = function (line, offset, fileName, filesToSearch) { - fileName = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(fileName); - if (!project || project.languageServiceDiabled) { - throw Errors.NoProject; - } - var compilerService = project.compilerService; - var position = compilerService.host.lineOffsetToPosition(fileName, line, offset); - var documentHighlights = compilerService.languageService.getDocumentHighlights(fileName, position, filesToSearch); + Session.prototype.getDocumentHighlights = function (args, simplifiedResult) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + var documentHighlights = project.getLanguageService().getDocumentHighlights(file, position, args.filesToSearch); if (!documentHighlights) { return undefined; } - return documentHighlights.map(convertToDocumentHighlightsItem); + if (simplifiedResult) { + return documentHighlights.map(convertToDocumentHighlightsItem); + } + else { + return documentHighlights; + } function convertToDocumentHighlightsItem(documentHighlights) { var fileName = documentHighlights.fileName, highlightSpans = documentHighlights.highlightSpans; + var scriptInfo = project.getScriptInfo(fileName); return { file: fileName, highlightSpans: highlightSpans.map(convertHighlightSpan) }; function convertHighlightSpan(highlightSpan) { var textSpan = highlightSpan.textSpan, kind = highlightSpan.kind; - var start = compilerService.host.positionToLineOffset(fileName, textSpan.start); - var end = compilerService.host.positionToLineOffset(fileName, ts.textSpanEnd(textSpan)); + var start = scriptInfo.positionToLineOffset(textSpan.start); + var end = scriptInfo.positionToLineOffset(ts.textSpanEnd(textSpan)); return { start: start, end: end, kind: kind }; } } }; - Session.prototype.getProjectInfo = function (fileName, needFileNameList) { - fileName = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(fileName); - if (!project) { - throw Errors.NoProject; - } + Session.prototype.setCompilerOptionsForInferredProjects = function (args) { + this.projectService.setCompilerOptionsForInferredProjects(args.options); + }; + Session.prototype.getProjectInfo = function (args) { + return this.getProjectInfoWorker(args.file, args.projectFileName, args.needFileNameList); + }; + Session.prototype.getProjectInfoWorker = function (uncheckedFileName, projectFileName, needFileNameList) { + var project = this.getFileAndProjectWorker(uncheckedFileName, projectFileName, true, true).project; var projectInfo = { - configFileName: project.projectFilename, - languageServiceDisabled: project.languageServiceDiabled + configFileName: project.getProjectName(), + languageServiceDisabled: !project.languageServiceEnabled, + fileNames: needFileNameList ? project.getFileNames() : undefined }; - if (needFileNameList) { - projectInfo.fileNames = project.getFileNames(); - } return projectInfo; }; - Session.prototype.getRenameLocations = function (line, offset, fileName, findInComments, findInStrings) { - var file = ts.normalizePath(fileName); - var info = this.projectService.getScriptInfo(file); - var projects = this.projectService.findReferencingProjects(info); - var projectsWithLanguageServiceEnabeld = ts.filter(projects, function (p) { return !p.languageServiceDiabled; }); - if (projectsWithLanguageServiceEnabeld.length === 0) { - throw Errors.NoProject; - } - var defaultProject = projectsWithLanguageServiceEnabeld[0]; - var defaultProjectCompilerService = defaultProject.compilerService; - var position = defaultProjectCompilerService.host.lineOffsetToPosition(file, line, offset); - var renameInfo = defaultProjectCompilerService.languageService.getRenameInfo(file, position); - if (!renameInfo) { - return undefined; - } - if (!renameInfo.canRename) { - return { - info: renameInfo, - locs: [] - }; - } - var fileSpans = server.combineProjectOutput(projectsWithLanguageServiceEnabeld, function (project) { - var compilerService = project.compilerService; - var renameLocations = compilerService.languageService.findRenameLocations(file, position, findInStrings, findInComments); - if (!renameLocations) { - return []; + Session.prototype.getRenameInfo = function (args) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + return project.getLanguageService().getRenameInfo(file, position); + }; + Session.prototype.getProjects = function (args) { + var projects; + if (args.projectFileName) { + var project = this.getProject(args.projectFileName); + if (project) { + projects = [project]; } - return renameLocations.map(function (location) { return ({ - file: location.fileName, - start: compilerService.host.positionToLineOffset(location.fileName, location.textSpan.start), - end: compilerService.host.positionToLineOffset(location.fileName, ts.textSpanEnd(location.textSpan)) - }); }); - }, compareRenameLocation, function (a, b) { return a.file === b.file && a.start.line === b.start.line && a.start.offset === b.start.offset; }); - var locs = fileSpans.reduce(function (accum, cur) { - var curFileAccum; - if (accum.length > 0) { - curFileAccum = accum[accum.length - 1]; - if (curFileAccum.file !== cur.file) { - curFileAccum = undefined; + } + else { + var scriptInfo = this.projectService.getScriptInfo(args.file); + projects = scriptInfo.containingProjects; + } + projects = ts.filter(projects, function (p) { return p.languageServiceEnabled; }); + if (!projects || !projects.length) { + return server.Errors.ThrowNoProject(); + } + return projects; + }; + Session.prototype.getRenameLocations = function (args, simplifiedResult) { + var file = server.toNormalizedPath(args.file); + var info = this.projectService.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, info); + var projects = this.getProjects(args); + if (simplifiedResult) { + var defaultProject = projects[0]; + var renameInfo = defaultProject.getLanguageService().getRenameInfo(file, position); + if (!renameInfo) { + return undefined; + } + if (!renameInfo.canRename) { + return { + info: renameInfo, + locs: [] + }; + } + var fileSpans = server.combineProjectOutput(projects, function (project) { + var renameLocations = project.getLanguageService().findRenameLocations(file, position, args.findInStrings, args.findInComments); + if (!renameLocations) { + return []; } + return renameLocations.map(function (location) { + var locationScriptInfo = project.getScriptInfo(location.fileName); + return { + file: location.fileName, + start: locationScriptInfo.positionToLineOffset(location.textSpan.start), + end: locationScriptInfo.positionToLineOffset(ts.textSpanEnd(location.textSpan)) + }; + }); + }, compareRenameLocation, function (a, b) { return a.file === b.file && a.start.line === b.start.line && a.start.offset === b.start.offset; }); + var locs = fileSpans.reduce(function (accum, cur) { + var curFileAccum; + if (accum.length > 0) { + curFileAccum = accum[accum.length - 1]; + if (curFileAccum.file !== cur.file) { + curFileAccum = undefined; + } + } + if (!curFileAccum) { + curFileAccum = { file: cur.file, locs: [] }; + accum.push(curFileAccum); + } + curFileAccum.locs.push({ start: cur.start, end: cur.end }); + return accum; + }, []); + return { info: renameInfo, locs: locs }; + } + else { + return server.combineProjectOutput(projects, function (p) { return p.getLanguageService().findRenameLocations(file, position, args.findInStrings, args.findInComments); }, undefined, renameLocationIsEqualTo); + } + function renameLocationIsEqualTo(a, b) { + if (a === b) { + return true; } - if (!curFileAccum) { - curFileAccum = { file: cur.file, locs: [] }; - accum.push(curFileAccum); + if (!a || !b) { + return false; } - curFileAccum.locs.push({ start: cur.start, end: cur.end }); - return accum; - }, []); - return { info: renameInfo, locs: locs }; + return a.fileName === b.fileName && + a.textSpan.start === b.textSpan.start && + a.textSpan.length === b.textSpan.length; + } function compareRenameLocation(a, b) { if (a.file < b.file) { return -1; @@ -60861,51 +64145,51 @@ var ts; } } }; - Session.prototype.getReferences = function (line, offset, fileName) { - var file = ts.normalizePath(fileName); - var info = this.projectService.getScriptInfo(file); - var projects = this.projectService.findReferencingProjects(info); - var projectsWithLanguageServiceEnabeld = ts.filter(projects, function (p) { return !p.languageServiceDiabled; }); - if (projectsWithLanguageServiceEnabeld.length === 0) { - throw Errors.NoProject; - } - var defaultProject = projectsWithLanguageServiceEnabeld[0]; - var position = defaultProject.compilerService.host.lineOffsetToPosition(file, line, offset); - var nameInfo = defaultProject.compilerService.languageService.getQuickInfoAtPosition(file, position); - if (!nameInfo) { - return undefined; - } - var displayString = ts.displayPartsToString(nameInfo.displayParts); - var nameSpan = nameInfo.textSpan; - var nameColStart = defaultProject.compilerService.host.positionToLineOffset(file, nameSpan.start).offset; - var nameText = defaultProject.compilerService.host.getScriptSnapshot(file).getText(nameSpan.start, ts.textSpanEnd(nameSpan)); - var refs = server.combineProjectOutput(projectsWithLanguageServiceEnabeld, function (project) { - var compilerService = project.compilerService; - var references = compilerService.languageService.getReferencesAtPosition(file, position); - if (!references) { - return []; + Session.prototype.getReferences = function (args, simplifiedResult) { + var file = server.toNormalizedPath(args.file); + var projects = this.getProjects(args); + var defaultProject = projects[0]; + var scriptInfo = defaultProject.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + if (simplifiedResult) { + var nameInfo = defaultProject.getLanguageService().getQuickInfoAtPosition(file, position); + if (!nameInfo) { + return undefined; } - return references.map(function (ref) { - var start = compilerService.host.positionToLineOffset(ref.fileName, ref.textSpan.start); - var refLineSpan = compilerService.host.lineToTextSpan(ref.fileName, start.line - 1); - var snap = compilerService.host.getScriptSnapshot(ref.fileName); - var lineText = snap.getText(refLineSpan.start, ts.textSpanEnd(refLineSpan)).replace(/\r|\n/g, ""); - return { - file: ref.fileName, - start: start, - lineText: lineText, - end: compilerService.host.positionToLineOffset(ref.fileName, ts.textSpanEnd(ref.textSpan)), - isWriteAccess: ref.isWriteAccess, - isDefinition: ref.isDefinition - }; - }); - }, compareFileStart, areReferencesResponseItemsForTheSameLocation); - return { - refs: refs, - symbolName: nameText, - symbolStartOffset: nameColStart, - symbolDisplayString: displayString - }; + var displayString = ts.displayPartsToString(nameInfo.displayParts); + var nameSpan = nameInfo.textSpan; + var nameColStart = scriptInfo.positionToLineOffset(nameSpan.start).offset; + var nameText = scriptInfo.snap().getText(nameSpan.start, ts.textSpanEnd(nameSpan)); + var refs = server.combineProjectOutput(projects, function (project) { + var references = project.getLanguageService().getReferencesAtPosition(file, position); + if (!references) { + return []; + } + return references.map(function (ref) { + var refScriptInfo = project.getScriptInfo(ref.fileName); + var start = refScriptInfo.positionToLineOffset(ref.textSpan.start); + var refLineSpan = refScriptInfo.lineToTextSpan(start.line - 1); + var lineText = refScriptInfo.snap().getText(refLineSpan.start, ts.textSpanEnd(refLineSpan)).replace(/\r|\n/g, ""); + return { + file: ref.fileName, + start: start, + lineText: lineText, + end: refScriptInfo.positionToLineOffset(ts.textSpanEnd(ref.textSpan)), + isWriteAccess: ref.isWriteAccess, + isDefinition: ref.isDefinition + }; + }); + }, compareFileStart, areReferencesResponseItemsForTheSameLocation); + return { + refs: refs, + symbolName: nameText, + symbolStartOffset: nameColStart, + symbolDisplayString: displayString + }; + } + else { + return server.combineProjectOutput(projects, function (project) { return project.getLanguageService().findReferences(file, position); }, undefined, undefined); + } function areReferencesResponseItemsForTheSameLocation(a, b) { if (a && b) { return a.file === b.file && @@ -60916,102 +64200,150 @@ var ts; } }; Session.prototype.openClientFile = function (fileName, fileContent, scriptKind) { - var file = ts.normalizePath(fileName); - var _a = this.projectService.openClientFile(file, fileContent, scriptKind), configFileName = _a.configFileName, configFileErrors = _a.configFileErrors; - if (configFileErrors) { - this.configFileDiagnosticEvent(fileName, configFileName, configFileErrors); + var _a = this.projectService.openClientFileWithNormalizedPath(fileName, fileContent, scriptKind), configFileName = _a.configFileName, configFileErrors = _a.configFileErrors; + if (this.eventHander) { + this.eventHander({ + eventName: "configFileDiag", + data: { fileName: fileName, configFileName: configFileName, diagnostics: configFileErrors || [] } + }); } }; - Session.prototype.getQuickInfo = function (line, offset, fileName) { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project || project.languageServiceDiabled) { - throw Errors.NoProject; + Session.prototype.getPosition = function (args, scriptInfo) { + return args.position !== undefined ? args.position : scriptInfo.lineOffsetToPosition(args.line, args.offset); + }; + Session.prototype.getFileAndProject = function (args, errorOnMissingProject) { + if (errorOnMissingProject === void 0) { errorOnMissingProject = true; } + return this.getFileAndProjectWorker(args.file, args.projectFileName, true, errorOnMissingProject); + }; + Session.prototype.getFileAndProjectWithoutRefreshingInferredProjects = function (args, errorOnMissingProject) { + if (errorOnMissingProject === void 0) { errorOnMissingProject = true; } + return this.getFileAndProjectWorker(args.file, args.projectFileName, false, errorOnMissingProject); + }; + Session.prototype.getFileAndProjectWorker = function (uncheckedFileName, projectFileName, refreshInferredProjects, errorOnMissingProject) { + var file = server.toNormalizedPath(uncheckedFileName); + var project = this.getProject(projectFileName) || this.projectService.getDefaultProjectForFile(file, refreshInferredProjects); + if (!project && errorOnMissingProject) { + return server.Errors.ThrowNoProject(); } - var compilerService = project.compilerService; - var position = compilerService.host.lineOffsetToPosition(file, line, offset); - var quickInfo = compilerService.languageService.getQuickInfoAtPosition(file, position); + return { file: file, project: project }; + }; + Session.prototype.getOutliningSpans = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + return project.getLanguageService(false).getOutliningSpans(file); + }; + Session.prototype.getTodoComments = function (args) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + return project.getLanguageService().getTodoComments(file, args.descriptors); + }; + Session.prototype.getDocCommentTemplate = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + return project.getLanguageService(false).getDocCommentTemplateAtPosition(file, position); + }; + Session.prototype.getIndentation = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); + var options = args.options || this.projectService.getFormatCodeOptions(file); + var indentation = project.getLanguageService(false).getIndentationAtPosition(file, position, options); + return { position: position, indentation: indentation }; + }; + Session.prototype.getBreakpointStatement = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); + return project.getLanguageService(false).getBreakpointStatementAtPosition(file, position); + }; + Session.prototype.getNameOrDottedNameSpan = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); + return project.getLanguageService(false).getNameOrDottedNameSpan(file, position, position); + }; + Session.prototype.isValidBraceCompletion = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); + return project.getLanguageService(false).isValidBraceCompletionAtPosition(file, position, args.openingBrace.charCodeAt(0)); + }; + Session.prototype.getQuickInfoWorker = function (args, simplifiedResult) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var quickInfo = project.getLanguageService().getQuickInfoAtPosition(file, this.getPosition(args, scriptInfo)); if (!quickInfo) { return undefined; } - var displayString = ts.displayPartsToString(quickInfo.displayParts); - var docString = ts.displayPartsToString(quickInfo.documentation); - return { - kind: quickInfo.kind, - kindModifiers: quickInfo.kindModifiers, - start: compilerService.host.positionToLineOffset(file, quickInfo.textSpan.start), - end: compilerService.host.positionToLineOffset(file, ts.textSpanEnd(quickInfo.textSpan)), - displayString: displayString, - documentation: docString - }; - }; - Session.prototype.getFormattingEditsForRange = function (line, offset, endLine, endOffset, fileName) { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project || project.languageServiceDiabled) { - throw Errors.NoProject; + if (simplifiedResult) { + var displayString = ts.displayPartsToString(quickInfo.displayParts); + var docString = ts.displayPartsToString(quickInfo.documentation); + return { + kind: quickInfo.kind, + kindModifiers: quickInfo.kindModifiers, + start: scriptInfo.positionToLineOffset(quickInfo.textSpan.start), + end: scriptInfo.positionToLineOffset(ts.textSpanEnd(quickInfo.textSpan)), + displayString: displayString, + documentation: docString + }; } - var compilerService = project.compilerService; - var startPosition = compilerService.host.lineOffsetToPosition(file, line, offset); - var endPosition = compilerService.host.lineOffsetToPosition(file, endLine, endOffset); - var edits = compilerService.languageService.getFormattingEditsForRange(file, startPosition, endPosition, this.projectService.getFormatCodeOptions(file)); + else { + return quickInfo; + } + }; + Session.prototype.getFormattingEditsForRange = function (args) { + var _this = this; + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var startPosition = scriptInfo.lineOffsetToPosition(args.line, args.offset); + var endPosition = scriptInfo.lineOffsetToPosition(args.endLine, args.endOffset); + var edits = project.getLanguageService(false).getFormattingEditsForRange(file, startPosition, endPosition, this.projectService.getFormatCodeOptions(file)); if (!edits) { return undefined; } - return edits.map(function (edit) { - return { - start: compilerService.host.positionToLineOffset(file, edit.span.start), - end: compilerService.host.positionToLineOffset(file, ts.textSpanEnd(edit.span)), - newText: edit.newText ? edit.newText : "" - }; - }); + return edits.map(function (edit) { return _this.convertTextChangeToCodeEdit(edit, scriptInfo); }); }; - Session.prototype.getFormattingEditsAfterKeystroke = function (line, offset, key, fileName) { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project || project.languageServiceDiabled) { - throw Errors.NoProject; - } - var compilerService = project.compilerService; - var position = compilerService.host.lineOffsetToPosition(file, line, offset); + Session.prototype.getFormattingEditsForRangeFull = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var options = args.options || this.projectService.getFormatCodeOptions(file); + return project.getLanguageService(false).getFormattingEditsForRange(file, args.position, args.endPosition, options); + }; + Session.prototype.getFormattingEditsForDocumentFull = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var options = args.options || this.projectService.getFormatCodeOptions(file); + return project.getLanguageService(false).getFormattingEditsForDocument(file, options); + }; + Session.prototype.getFormattingEditsAfterKeystrokeFull = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var options = args.options || this.projectService.getFormatCodeOptions(file); + return project.getLanguageService(false).getFormattingEditsAfterKeystroke(file, args.position, args.key, options); + }; + Session.prototype.getFormattingEditsAfterKeystroke = function (args) { + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = scriptInfo.lineOffsetToPosition(args.line, args.offset); var formatOptions = this.projectService.getFormatCodeOptions(file); - var edits = compilerService.languageService.getFormattingEditsAfterKeystroke(file, position, key, formatOptions); - if ((key == "\n") && ((!edits) || (edits.length === 0) || allEditsBeforePos(edits, position))) { - var scriptInfo = compilerService.host.getScriptInfo(file); - if (scriptInfo) { - var lineInfo = scriptInfo.getLineInfo(line); - if (lineInfo && (lineInfo.leaf) && (lineInfo.leaf.text)) { - var lineText = lineInfo.leaf.text; - if (lineText.search("\\S") < 0) { - var editorOptions = { - BaseIndentSize: formatOptions.BaseIndentSize, - IndentSize: formatOptions.IndentSize, - TabSize: formatOptions.TabSize, - NewLineCharacter: formatOptions.NewLineCharacter, - ConvertTabsToSpaces: formatOptions.ConvertTabsToSpaces, - IndentStyle: ts.IndentStyle.Smart - }; - var preferredIndent = compilerService.languageService.getIndentationAtPosition(file, position, editorOptions); - var hasIndent = 0; - var i = void 0, len = void 0; - for (i = 0, len = lineText.length; i < len; i++) { - if (lineText.charAt(i) == " ") { - hasIndent++; - } - else if (lineText.charAt(i) == "\t") { - hasIndent += editorOptions.TabSize; - } - else { - break; - } + var edits = project.getLanguageService(false).getFormattingEditsAfterKeystroke(file, position, args.key, formatOptions); + if ((args.key == "\n") && ((!edits) || (edits.length === 0) || allEditsBeforePos(edits, position))) { + var lineInfo = scriptInfo.getLineInfo(args.line); + if (lineInfo && (lineInfo.leaf) && (lineInfo.leaf.text)) { + var lineText = lineInfo.leaf.text; + if (lineText.search("\\S") < 0) { + var preferredIndent = project.getLanguageService(false).getIndentationAtPosition(file, position, formatOptions); + var hasIndent = 0; + var i = void 0, len = void 0; + for (i = 0, len = lineText.length; i < len; i++) { + if (lineText.charAt(i) == " ") { + hasIndent++; } - if (preferredIndent !== hasIndent) { - var firstNoWhiteSpacePosition = lineInfo.offset + i; - edits.push({ - span: ts.createTextSpanFromBounds(lineInfo.offset, firstNoWhiteSpacePosition), - newText: generateIndentString(preferredIndent, editorOptions) - }); + else if (lineText.charAt(i) == "\t") { + hasIndent += formatOptions.tabSize; } + else { + break; + } + } + if (preferredIndent !== hasIndent) { + var firstNoWhiteSpacePosition = lineInfo.offset + i; + edits.push({ + span: ts.createTextSpanFromBounds(lineInfo.offset, firstNoWhiteSpacePosition), + newText: ts.formatting.getIndentationString(preferredIndent, formatOptions) + }); } } } @@ -61021,89 +64353,106 @@ var ts; } return edits.map(function (edit) { return { - start: compilerService.host.positionToLineOffset(file, edit.span.start), - end: compilerService.host.positionToLineOffset(file, ts.textSpanEnd(edit.span)), + start: scriptInfo.positionToLineOffset(edit.span.start), + end: scriptInfo.positionToLineOffset(ts.textSpanEnd(edit.span)), newText: edit.newText ? edit.newText : "" }; }); }; - Session.prototype.getCompletions = function (line, offset, prefix, fileName) { - if (!prefix) { - prefix = ""; - } - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project || project.languageServiceDiabled) { - throw Errors.NoProject; - } - var compilerService = project.compilerService; - var position = compilerService.host.lineOffsetToPosition(file, line, offset); - var completions = compilerService.languageService.getCompletionsAtPosition(file, position); + Session.prototype.getCompletions = function (args, simplifiedResult) { + var _this = this; + var prefix = args.prefix || ""; + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + var completions = project.getLanguageService().getCompletionsAtPosition(file, position); if (!completions) { return undefined; } - return completions.entries.reduce(function (result, entry) { - if (completions.isMemberCompletion || (entry.name.toLowerCase().indexOf(prefix.toLowerCase()) === 0)) { - var name_52 = entry.name, kind = entry.kind, kindModifiers = entry.kindModifiers, sortText = entry.sortText, replacementSpan = entry.replacementSpan; - var convertedSpan = undefined; - if (replacementSpan) { - convertedSpan = { - start: compilerService.host.positionToLineOffset(fileName, replacementSpan.start), - end: compilerService.host.positionToLineOffset(fileName, replacementSpan.start + replacementSpan.length) - }; + if (simplifiedResult) { + return completions.entries.reduce(function (result, entry) { + if (completions.isMemberCompletion || (entry.name.toLowerCase().indexOf(prefix.toLowerCase()) === 0)) { + var name_53 = entry.name, kind = entry.kind, kindModifiers = entry.kindModifiers, sortText = entry.sortText, replacementSpan = entry.replacementSpan; + var convertedSpan = replacementSpan ? _this.decorateSpan(replacementSpan, scriptInfo) : undefined; + result.push({ name: name_53, kind: kind, kindModifiers: kindModifiers, sortText: sortText, replacementSpan: convertedSpan }); } - result.push({ name: name_52, kind: kind, kindModifiers: kindModifiers, sortText: sortText, replacementSpan: convertedSpan }); - } - return result; - }, []).sort(function (a, b) { return a.name.localeCompare(b.name); }); - }; - Session.prototype.getCompletionEntryDetails = function (line, offset, entryNames, fileName) { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project || project.languageServiceDiabled) { - throw Errors.NoProject; + return result; + }, []).sort(function (a, b) { return a.name.localeCompare(b.name); }); } - var compilerService = project.compilerService; - var position = compilerService.host.lineOffsetToPosition(file, line, offset); - return entryNames.reduce(function (accum, entryName) { - var details = compilerService.languageService.getCompletionEntryDetails(file, position, entryName); + else { + return completions; + } + }; + Session.prototype.getCompletionEntryDetails = function (args) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + return args.entryNames.reduce(function (accum, entryName) { + var details = project.getLanguageService().getCompletionEntryDetails(file, position, entryName); if (details) { accum.push(details); } return accum; }, []); }; - Session.prototype.getSignatureHelpItems = function (line, offset, fileName) { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project || project.languageServiceDiabled) { - throw Errors.NoProject; + Session.prototype.getCompileOnSaveAffectedFileList = function (args) { + var info = this.projectService.getScriptInfo(args.file); + var result = []; + if (!info) { + return []; } - var compilerService = project.compilerService; - var position = compilerService.host.lineOffsetToPosition(file, line, offset); - var helpItems = compilerService.languageService.getSignatureHelpItems(file, position); + var projectsToSearch = args.projectFileName ? [this.projectService.findProject(args.projectFileName)] : info.containingProjects; + for (var _i = 0, projectsToSearch_1 = projectsToSearch; _i < projectsToSearch_1.length; _i++) { + var project = projectsToSearch_1[_i]; + if (project.compileOnSaveEnabled && project.languageServiceEnabled) { + result.push({ + projectFileName: project.getProjectName(), + fileNames: project.getCompileOnSaveAffectedFileList(info) + }); + } + } + return result; + }; + Session.prototype.emitFile = function (args) { + var _this = this; + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + if (!project) { + server.Errors.ThrowNoProject(); + } + var scriptInfo = project.getScriptInfo(file); + return project.builder.emitFile(scriptInfo, function (path, data, writeByteOrderMark) { return _this.host.writeFile(path, data, writeByteOrderMark); }); + }; + Session.prototype.getSignatureHelpItems = function (args, simplifiedResult) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + var helpItems = project.getLanguageService().getSignatureHelpItems(file, position); if (!helpItems) { return undefined; } - var span = helpItems.applicableSpan; - var result = { - items: helpItems.items, - applicableSpan: { - start: compilerService.host.positionToLineOffset(file, span.start), - end: compilerService.host.positionToLineOffset(file, span.start + span.length) - }, - selectedItemIndex: helpItems.selectedItemIndex, - argumentIndex: helpItems.argumentIndex, - argumentCount: helpItems.argumentCount - }; - return result; + if (simplifiedResult) { + var span_16 = helpItems.applicableSpan; + return { + items: helpItems.items, + applicableSpan: { + start: scriptInfo.positionToLineOffset(span_16.start), + end: scriptInfo.positionToLineOffset(span_16.start + span_16.length) + }, + selectedItemIndex: helpItems.selectedItemIndex, + argumentIndex: helpItems.argumentIndex, + argumentCount: helpItems.argumentCount + }; + } + else { + return helpItems; + } }; Session.prototype.getDiagnostics = function (delay, fileNames) { var _this = this; - var checkList = fileNames.reduce(function (accum, fileName) { - fileName = ts.normalizePath(fileName); - var project = _this.projectService.getProjectForFile(fileName); - if (project && !project.languageServiceDiabled) { + var checkList = fileNames.reduce(function (accum, uncheckedFileName) { + var fileName = server.toNormalizedPath(uncheckedFileName); + var project = _this.projectService.getDefaultProjectForFile(fileName, true); + if (project) { accum.push({ fileName: fileName, project: project }); } return accum; @@ -61112,40 +64461,34 @@ var ts; this.updateErrorCheck(checkList, this.changeSeq, function (n) { return n === _this.changeSeq; }, delay); } }; - Session.prototype.change = function (line, offset, endLine, endOffset, insertString, fileName) { + Session.prototype.change = function (args) { var _this = this; - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (project && !project.languageServiceDiabled) { - var compilerService = project.compilerService; - var start = compilerService.host.lineOffsetToPosition(file, line, offset); - var end = compilerService.host.lineOffsetToPosition(file, endLine, endOffset); + var _a = this.getFileAndProject(args, false), file = _a.file, project = _a.project; + if (project) { + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var start = scriptInfo.lineOffsetToPosition(args.line, args.offset); + var end = scriptInfo.lineOffsetToPosition(args.endLine, args.endOffset); if (start >= 0) { - compilerService.host.editScript(file, start, end, insertString); + scriptInfo.editContent(start, end, args.insertString); this.changeSeq++; } this.updateProjectStructure(this.changeSeq, function (n) { return n === _this.changeSeq; }); } }; - Session.prototype.reload = function (fileName, tempFileName, reqSeq) { - var _this = this; - if (reqSeq === void 0) { reqSeq = 0; } - var file = ts.normalizePath(fileName); - var tmpfile = ts.normalizePath(tempFileName); - var project = this.projectService.getProjectForFile(file); - if (project && !project.languageServiceDiabled) { + Session.prototype.reload = function (args, reqSeq) { + var file = server.toNormalizedPath(args.file); + var project = this.projectService.getDefaultProjectForFile(file, true); + if (project) { this.changeSeq++; - project.compilerService.host.reloadScript(file, tmpfile, function () { - _this.output(undefined, CommandNames.Reload, reqSeq); - }); + if (project.reloadScript(file)) { + this.output(undefined, CommandNames.Reload, reqSeq); + } } }; Session.prototype.saveToTmp = function (fileName, tempFileName) { - var file = ts.normalizePath(fileName); - var tmpfile = ts.normalizePath(tempFileName); - var project = this.projectService.getProjectForFile(file); - if (project && !project.languageServiceDiabled) { - project.compilerService.host.saveTo(file, tmpfile); + var scriptInfo = this.projectService.getScriptInfo(fileName); + if (scriptInfo) { + scriptInfo.saveTo(tempFileName); } }; Session.prototype.closeClientFile = function (fileName) { @@ -61155,77 +64498,108 @@ var ts; var file = ts.normalizePath(fileName); this.projectService.closeClientFile(file); }; - Session.prototype.decorateNavigationBarItem = function (project, fileName, items, lineIndex) { + Session.prototype.decorateNavigationBarItems = function (items, scriptInfo) { var _this = this; - if (!items) { - return undefined; - } - var compilerService = project.compilerService; - return items.map(function (item) { return ({ + return ts.map(items, function (item) { return ({ text: item.text, kind: item.kind, kindModifiers: item.kindModifiers, - spans: item.spans.map(function (span) { return ({ - start: compilerService.host.positionToLineOffset(fileName, span.start, lineIndex), - end: compilerService.host.positionToLineOffset(fileName, ts.textSpanEnd(span), lineIndex) - }); }), - childItems: _this.decorateNavigationBarItem(project, fileName, item.childItems, lineIndex), + spans: item.spans.map(function (span) { return _this.decorateSpan(span, scriptInfo); }), + childItems: _this.decorateNavigationBarItems(item.childItems, scriptInfo), indent: item.indent }); }); }; - Session.prototype.getNavigationBarItems = function (fileName) { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project || project.languageServiceDiabled) { - throw Errors.NoProject; - } - var compilerService = project.compilerService; - var items = compilerService.languageService.getNavigationBarItems(file); - if (!items) { - return undefined; - } - return this.decorateNavigationBarItem(project, fileName, items, compilerService.host.getLineIndex(fileName)); + Session.prototype.getNavigationBarItems = function (args, simplifiedResult) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var items = project.getLanguageService(false).getNavigationBarItems(file); + return !items + ? undefined + : simplifiedResult + ? this.decorateNavigationBarItems(items, project.getScriptInfoForNormalizedPath(file)) + : items; }; - Session.prototype.getNavigateToItems = function (searchValue, fileName, maxResultCount, currentFileOnly) { - var file = ts.normalizePath(fileName); - var info = this.projectService.getScriptInfo(file); - var projects = this.projectService.findReferencingProjects(info); - var projectsWithLanguageServiceEnabeld = ts.filter(projects, function (p) { return !p.languageServiceDiabled; }); - if (projectsWithLanguageServiceEnabeld.length === 0) { - throw Errors.NoProject; + Session.prototype.decorateNavigationTree = function (tree, scriptInfo) { + var _this = this; + return { + text: tree.text, + kind: tree.kind, + kindModifiers: tree.kindModifiers, + spans: tree.spans.map(function (span) { return _this.decorateSpan(span, scriptInfo); }), + childItems: ts.map(tree.childItems, function (item) { return _this.decorateNavigationTree(item, scriptInfo); }) + }; + }; + Session.prototype.decorateSpan = function (span, scriptInfo) { + return { + start: scriptInfo.positionToLineOffset(span.start), + end: scriptInfo.positionToLineOffset(ts.textSpanEnd(span)) + }; + }; + Session.prototype.getNavigationTree = function (args, simplifiedResult) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var tree = project.getLanguageService(false).getNavigationTree(file); + return !tree + ? undefined + : simplifiedResult + ? this.decorateNavigationTree(tree, project.getScriptInfoForNormalizedPath(file)) + : tree; + }; + Session.prototype.getNavigateToItems = function (args, simplifiedResult) { + var projects = this.getProjects(args); + var fileName = args.currentFileOnly ? args.file && ts.normalizeSlashes(args.file) : undefined; + if (simplifiedResult) { + return server.combineProjectOutput(projects, function (project) { + var navItems = project.getLanguageService().getNavigateToItems(args.searchValue, args.maxResultCount, fileName, project.isNonTsProject()); + if (!navItems) { + return []; + } + return navItems.map(function (navItem) { + var scriptInfo = project.getScriptInfo(navItem.fileName); + var start = scriptInfo.positionToLineOffset(navItem.textSpan.start); + var end = scriptInfo.positionToLineOffset(ts.textSpanEnd(navItem.textSpan)); + var bakedItem = { + name: navItem.name, + kind: navItem.kind, + file: navItem.fileName, + start: start, + end: end + }; + if (navItem.kindModifiers && (navItem.kindModifiers !== "")) { + bakedItem.kindModifiers = navItem.kindModifiers; + } + if (navItem.matchKind !== "none") { + bakedItem.matchKind = navItem.matchKind; + } + if (navItem.containerName && (navItem.containerName.length > 0)) { + bakedItem.containerName = navItem.containerName; + } + if (navItem.containerKind && (navItem.containerKind.length > 0)) { + bakedItem.containerKind = navItem.containerKind; + } + return bakedItem; + }); + }, undefined, areNavToItemsForTheSameLocation); } - var allNavToItems = server.combineProjectOutput(projectsWithLanguageServiceEnabeld, function (project) { - var compilerService = project.compilerService; - var navItems = compilerService.languageService.getNavigateToItems(searchValue, maxResultCount, currentFileOnly ? fileName : undefined); - if (!navItems) { - return []; + else { + return server.combineProjectOutput(projects, function (project) { return project.getLanguageService().getNavigateToItems(args.searchValue, args.maxResultCount, fileName, project.isNonTsProject()); }, undefined, navigateToItemIsEqualTo); + } + function navigateToItemIsEqualTo(a, b) { + if (a === b) { + return true; } - return navItems.map(function (navItem) { - var start = compilerService.host.positionToLineOffset(navItem.fileName, navItem.textSpan.start); - var end = compilerService.host.positionToLineOffset(navItem.fileName, ts.textSpanEnd(navItem.textSpan)); - var bakedItem = { - name: navItem.name, - kind: navItem.kind, - file: navItem.fileName, - start: start, - end: end - }; - if (navItem.kindModifiers && (navItem.kindModifiers !== "")) { - bakedItem.kindModifiers = navItem.kindModifiers; - } - if (navItem.matchKind !== "none") { - bakedItem.matchKind = navItem.matchKind; - } - if (navItem.containerName && (navItem.containerName.length > 0)) { - bakedItem.containerName = navItem.containerName; - } - if (navItem.containerKind && (navItem.containerKind.length > 0)) { - bakedItem.containerKind = navItem.containerKind; - } - return bakedItem; - }); - }, undefined, areNavToItemsForTheSameLocation); - return allNavToItems; + if (!a || !b) { + return false; + } + return a.containerKind === b.containerKind && + a.containerName === b.containerName && + a.fileName === b.fileName && + a.isCaseSensitive === b.isCaseSensitive && + a.kind === b.kind && + a.kindModifiers === b.containerName && + a.matchKind === b.matchKind && + a.name === b.name && + a.textSpan.start === b.textSpan.start && + a.textSpan.length === b.textSpan.length; + } function areNavToItemsForTheSameLocation(a, b) { if (a && b) { return a.file === b.file && @@ -61235,26 +64609,64 @@ var ts; return false; } }; - Session.prototype.getBraceMatching = function (line, offset, fileName) { - var file = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(file); - if (!project || project.languageServiceDiabled) { - throw Errors.NoProject; - } - var compilerService = project.compilerService; - var position = compilerService.host.lineOffsetToPosition(file, line, offset); - var spans = compilerService.languageService.getBraceMatchingAtPosition(file, position); - if (!spans) { + Session.prototype.getSupportedCodeFixes = function () { + return ts.getSupportedCodeFixes(); + }; + Session.prototype.getCodeFixes = function (args, simplifiedResult) { + var _this = this; + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var startPosition = getStartPosition(); + var endPosition = getEndPosition(); + var codeActions = project.getLanguageService().getCodeFixesAtPosition(file, startPosition, endPosition, args.errorCodes); + if (!codeActions) { return undefined; } - return spans.map(function (span) { return ({ - start: compilerService.host.positionToLineOffset(file, span.start), - end: compilerService.host.positionToLineOffset(file, span.start + span.length) - }); }); + if (simplifiedResult) { + return codeActions.map(function (codeAction) { return _this.mapCodeAction(codeAction, scriptInfo); }); + } + else { + return codeActions; + } + function getStartPosition() { + return args.startPosition !== undefined ? args.startPosition : scriptInfo.lineOffsetToPosition(args.startLine, args.startOffset); + } + function getEndPosition() { + return args.endPosition !== undefined ? args.endPosition : scriptInfo.lineOffsetToPosition(args.endLine, args.endOffset); + } + }; + Session.prototype.mapCodeAction = function (codeAction, scriptInfo) { + var _this = this; + return { + description: codeAction.description, + changes: codeAction.changes.map(function (change) { return ({ + fileName: change.fileName, + textChanges: change.textChanges.map(function (textChange) { return _this.convertTextChangeToCodeEdit(textChange, scriptInfo); }) + }); }) + }; + }; + Session.prototype.convertTextChangeToCodeEdit = function (change, scriptInfo) { + return { + start: scriptInfo.positionToLineOffset(change.span.start), + end: scriptInfo.positionToLineOffset(change.span.start + change.span.length), + newText: change.newText ? change.newText : "" + }; + }; + Session.prototype.getBraceMatching = function (args, simplifiedResult) { + var _this = this; + var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + var position = this.getPosition(args, scriptInfo); + var spans = project.getLanguageService(false).getBraceMatchingAtPosition(file, position); + return !spans + ? undefined + : simplifiedResult + ? spans.map(function (span) { return _this.decorateSpan(span, scriptInfo); }) + : spans; }; Session.prototype.getDiagnosticsForProject = function (delay, fileName) { var _this = this; - var _a = this.getProjectInfo(fileName, true), fileNames = _a.fileNames, languageServiceDisabled = _a.languageServiceDisabled; + var _a = this.getProjectInfoWorker(fileName, undefined, true), fileNames = _a.fileNames, languageServiceDisabled = _a.languageServiceDisabled; if (languageServiceDisabled) { return; } @@ -61263,8 +64675,8 @@ var ts; var mediumPriorityFiles = []; var lowPriorityFiles = []; var veryLowPriorityFiles = []; - var normalizedFileName = ts.normalizePath(fileName); - var project = this.projectService.getProjectForFile(normalizedFileName); + var normalizedFileName = server.toNormalizedPath(fileName); + var project = this.projectService.getDefaultProjectForFile(normalizedFileName, true); for (var _i = 0, fileNamesInProject_1 = fileNamesInProject; _i < fileNamesInProject_1.length; _i++) { var fileNameInProject = fileNamesInProject_1[_i]; if (this.getCanonicalFileName(fileNameInProject) == this.getCanonicalFileName(fileName)) @@ -61283,10 +64695,7 @@ var ts; } fileNamesInProject = highPriorityFiles.concat(mediumPriorityFiles).concat(lowPriorityFiles).concat(veryLowPriorityFiles); if (fileNamesInProject.length > 0) { - var checkList = fileNamesInProject.map(function (fileName) { - var normalizedFileName = ts.normalizePath(fileName); - return { fileName: normalizedFileName, project: project }; - }); + var checkList = fileNamesInProject.map(function (fileName) { return ({ fileName: fileName, project: project }); }); this.updateErrorCheck(checkList, this.changeSeq, function (n) { return n == _this.changeSeq; }, delay, 200, false); } }; @@ -61296,6 +64705,9 @@ var ts; }; Session.prototype.exit = function () { }; + Session.prototype.notRequired = function () { + return { responseRequired: false }; + }; Session.prototype.requiredResponse = function (response) { return { response: response, responseRequired: true }; }; @@ -61311,31 +64723,32 @@ var ts; return handler(request); } else { - this.projectService.log("Unrecognized JSON command: " + JSON.stringify(request)); + this.logger.msg("Unrecognized JSON command: " + JSON.stringify(request), server.Msg.Err); this.output(undefined, CommandNames.Unknown, request.seq, "Unrecognized JSON command: " + request.command); return { responseRequired: false }; } }; Session.prototype.onMessage = function (message) { + this.gcTimer.scheduleCollect(); var start; - if (this.logger.isVerbose()) { - this.logger.info("request: " + message); + if (this.logger.hasLevel(server.LogLevel.requestTime)) { start = this.hrtime(); + if (this.logger.hasLevel(server.LogLevel.verbose)) { + this.logger.info("request: " + message); + } } var request; try { request = JSON.parse(message); var _a = this.executeCommand(request), response = _a.response, responseRequired = _a.responseRequired; - if (this.logger.isVerbose()) { - var elapsed = this.hrtime(start); - var seconds = elapsed[0]; - var nanoseconds = elapsed[1]; - var elapsedMs = ((1e9 * seconds) + nanoseconds) / 1000000.0; - var leader = "Elapsed time (in milliseconds)"; - if (!responseRequired) { - leader = "Async elapsed time (in milliseconds)"; + if (this.logger.hasLevel(server.LogLevel.requestTime)) { + var elapsedTime = hrTimeToMilliseconds(this.hrtime(start)).toFixed(4); + if (responseRequired) { + this.logger.perftrc(request.seq + "::" + request.command + ": elapsed time (in milliseconds) " + elapsedTime); + } + else { + this.logger.perftrc(request.seq + "::" + request.command + ": async elapsed time (in milliseconds) " + elapsedTime); } - this.logger.msg(leader + ": " + elapsedMs.toFixed(4).toString(), "Perf"); } if (response) { this.output(response, request.command, request.seq); @@ -61346,6 +64759,8 @@ var ts; } catch (err) { if (err instanceof ts.OperationCanceledException) { + this.output({ canceled: true }, request.command, request.seq); + return; } this.logError(err, message); this.output(undefined, request ? request.command : CommandNames.Unknown, request ? request.seq : 0, "Error processing request. " + err.message + "\n" + err.stack); @@ -61361,1229 +64776,6 @@ var ts; var server; (function (server) { var lineCollectionCapacity = 4; - function mergeFormatOptions(formatCodeOptions, formatOptions) { - var hasOwnProperty = Object.prototype.hasOwnProperty; - Object.keys(formatOptions).forEach(function (key) { - var codeKey = key.charAt(0).toUpperCase() + key.substring(1); - if (hasOwnProperty.call(formatCodeOptions, codeKey)) { - formatCodeOptions[codeKey] = formatOptions[key]; - } - }); - } - server.maxProgramSizeForNonTsFiles = 20 * 1024 * 1024; - var ScriptInfo = (function () { - function ScriptInfo(host, fileName, content, isOpen) { - if (isOpen === void 0) { isOpen = false; } - this.host = host; - this.fileName = fileName; - this.isOpen = isOpen; - this.children = []; - this.formatCodeOptions = ts.clone(CompilerService.getDefaultFormatCodeOptions(this.host)); - this.path = ts.toPath(fileName, host.getCurrentDirectory(), ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames)); - this.svc = ScriptVersionCache.fromString(host, content); - } - ScriptInfo.prototype.setFormatOptions = function (formatOptions) { - if (formatOptions) { - mergeFormatOptions(this.formatCodeOptions, formatOptions); - } - }; - ScriptInfo.prototype.close = function () { - this.isOpen = false; - }; - ScriptInfo.prototype.addChild = function (childInfo) { - this.children.push(childInfo); - }; - ScriptInfo.prototype.snap = function () { - return this.svc.getSnapshot(); - }; - ScriptInfo.prototype.getText = function () { - var snap = this.snap(); - return snap.getText(0, snap.getLength()); - }; - ScriptInfo.prototype.getLineInfo = function (line) { - var snap = this.snap(); - return snap.index.lineNumberToInfo(line); - }; - ScriptInfo.prototype.editContent = function (start, end, newText) { - this.svc.edit(start, end - start, newText); - }; - ScriptInfo.prototype.getTextChangeRangeBetweenVersions = function (startVersion, endVersion) { - return this.svc.getTextChangesBetweenVersions(startVersion, endVersion); - }; - ScriptInfo.prototype.getChangeRange = function (oldSnapshot) { - return this.snap().getChangeRange(oldSnapshot); - }; - return ScriptInfo; - }()); - server.ScriptInfo = ScriptInfo; - var LSHost = (function () { - function LSHost(host, project) { - var _this = this; - this.host = host; - this.project = project; - this.roots = []; - this.getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); - this.resolvedModuleNames = ts.createFileMap(); - this.resolvedTypeReferenceDirectives = ts.createFileMap(); - this.filenameToScript = ts.createFileMap(); - this.moduleResolutionHost = { - fileExists: function (fileName) { return _this.fileExists(fileName); }, - readFile: function (fileName) { return _this.host.readFile(fileName); }, - directoryExists: function (directoryName) { return _this.host.directoryExists(directoryName); } - }; - if (this.host.realpath) { - this.moduleResolutionHost.realpath = function (path) { return _this.host.realpath(path); }; - } - } - LSHost.prototype.resolveNamesWithLocalCache = function (names, containingFile, cache, loader, getResult) { - var path = ts.toPath(containingFile, this.host.getCurrentDirectory(), this.getCanonicalFileName); - var currentResolutionsInFile = cache.get(path); - var newResolutions = ts.createMap(); - var resolvedModules = []; - var compilerOptions = this.getCompilationSettings(); - for (var _i = 0, names_3 = names; _i < names_3.length; _i++) { - var name_53 = names_3[_i]; - var resolution = newResolutions[name_53]; - if (!resolution) { - var existingResolution = currentResolutionsInFile && currentResolutionsInFile[name_53]; - if (moduleResolutionIsValid(existingResolution)) { - resolution = existingResolution; - } - else { - resolution = loader(name_53, containingFile, compilerOptions, this.moduleResolutionHost); - resolution.lastCheckTime = Date.now(); - newResolutions[name_53] = resolution; - } - } - ts.Debug.assert(resolution !== undefined); - resolvedModules.push(getResult(resolution)); - } - cache.set(path, newResolutions); - return resolvedModules; - function moduleResolutionIsValid(resolution) { - if (!resolution) { - return false; - } - if (getResult(resolution)) { - return true; - } - return resolution.failedLookupLocations.length === 0; - } - }; - LSHost.prototype.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile) { - return this.resolveNamesWithLocalCache(typeDirectiveNames, containingFile, this.resolvedTypeReferenceDirectives, ts.resolveTypeReferenceDirective, function (m) { return m.resolvedTypeReferenceDirective; }); - }; - LSHost.prototype.resolveModuleNames = function (moduleNames, containingFile) { - return this.resolveNamesWithLocalCache(moduleNames, containingFile, this.resolvedModuleNames, ts.resolveModuleName, function (m) { return m.resolvedModule; }); - }; - LSHost.prototype.getDefaultLibFileName = function () { - var nodeModuleBinDir = ts.getDirectoryPath(ts.normalizePath(this.host.getExecutingFilePath())); - return ts.combinePaths(nodeModuleBinDir, ts.getDefaultLibFileName(this.compilationSettings)); - }; - LSHost.prototype.getScriptSnapshot = function (filename) { - var scriptInfo = this.getScriptInfo(filename); - if (scriptInfo) { - return scriptInfo.snap(); - } - }; - LSHost.prototype.setCompilationSettings = function (opt) { - this.compilationSettings = opt; - this.resolvedModuleNames.clear(); - this.resolvedTypeReferenceDirectives.clear(); - }; - LSHost.prototype.lineAffectsRefs = function (filename, line) { - var info = this.getScriptInfo(filename); - var lineInfo = info.getLineInfo(line); - if (lineInfo && lineInfo.text) { - var regex = /reference|import|\/\*|\*\//; - return regex.test(lineInfo.text); - } - }; - LSHost.prototype.getCompilationSettings = function () { - return this.compilationSettings; - }; - LSHost.prototype.getScriptFileNames = function () { - return this.roots.map(function (root) { return root.fileName; }); - }; - LSHost.prototype.getScriptKind = function (fileName) { - var info = this.getScriptInfo(fileName); - if (!info) { - return undefined; - } - if (!info.scriptKind) { - info.scriptKind = ts.getScriptKindFromFileName(fileName); - } - return info.scriptKind; - }; - LSHost.prototype.getScriptVersion = function (filename) { - return this.getScriptInfo(filename).svc.latestVersion().toString(); - }; - LSHost.prototype.getCurrentDirectory = function () { - return ""; - }; - LSHost.prototype.getScriptIsOpen = function (filename) { - return this.getScriptInfo(filename).isOpen; - }; - LSHost.prototype.removeReferencedFile = function (info) { - if (!info.isOpen) { - this.filenameToScript.remove(info.path); - this.resolvedModuleNames.remove(info.path); - this.resolvedTypeReferenceDirectives.remove(info.path); - } - }; - LSHost.prototype.getScriptInfo = function (filename) { - var path = ts.toPath(filename, this.host.getCurrentDirectory(), this.getCanonicalFileName); - var scriptInfo = this.filenameToScript.get(path); - if (!scriptInfo) { - scriptInfo = this.project.openReferencedFile(filename); - if (scriptInfo) { - this.filenameToScript.set(path, scriptInfo); - } - } - return scriptInfo; - }; - LSHost.prototype.addRoot = function (info) { - if (!this.filenameToScript.contains(info.path)) { - this.filenameToScript.set(info.path, info); - this.roots.push(info); - } - }; - LSHost.prototype.removeRoot = function (info) { - if (this.filenameToScript.contains(info.path)) { - this.filenameToScript.remove(info.path); - ts.unorderedRemoveItem(this.roots, info); - this.resolvedModuleNames.remove(info.path); - this.resolvedTypeReferenceDirectives.remove(info.path); - } - }; - LSHost.prototype.saveTo = function (filename, tmpfilename) { - var script = this.getScriptInfo(filename); - if (script) { - var snap = script.snap(); - this.host.writeFile(tmpfilename, snap.getText(0, snap.getLength())); - } - }; - LSHost.prototype.reloadScript = function (filename, tmpfilename, cb) { - var script = this.getScriptInfo(filename); - if (script) { - script.svc.reloadFromFile(tmpfilename, cb); - } - }; - LSHost.prototype.editScript = function (filename, start, end, newText) { - var script = this.getScriptInfo(filename); - if (script) { - script.editContent(start, end, newText); - return; - } - throw new Error("No script with name '" + filename + "'"); - }; - LSHost.prototype.fileExists = function (path) { - var result = this.host.fileExists(path); - return result; - }; - LSHost.prototype.directoryExists = function (path) { - return this.host.directoryExists(path); - }; - LSHost.prototype.getDirectories = function (path) { - return this.host.getDirectories(path); - }; - LSHost.prototype.readDirectory = function (path, extensions, exclude, include) { - return this.host.readDirectory(path, extensions, exclude, include); - }; - LSHost.prototype.readFile = function (path, encoding) { - return this.host.readFile(path, encoding); - }; - LSHost.prototype.lineToTextSpan = function (filename, line) { - var path = ts.toPath(filename, this.host.getCurrentDirectory(), this.getCanonicalFileName); - var script = this.filenameToScript.get(path); - var index = script.snap().index; - var lineInfo = index.lineNumberToInfo(line + 1); - var len; - if (lineInfo.leaf) { - len = lineInfo.leaf.text.length; - } - else { - var nextLineInfo = index.lineNumberToInfo(line + 2); - len = nextLineInfo.offset - lineInfo.offset; - } - return ts.createTextSpan(lineInfo.offset, len); - }; - LSHost.prototype.lineOffsetToPosition = function (filename, line, offset) { - var path = ts.toPath(filename, this.host.getCurrentDirectory(), this.getCanonicalFileName); - var script = this.filenameToScript.get(path); - var index = script.snap().index; - var lineInfo = index.lineNumberToInfo(line); - return (lineInfo.offset + offset - 1); - }; - LSHost.prototype.positionToLineOffset = function (filename, position, lineIndex) { - lineIndex = lineIndex || this.getLineIndex(filename); - var lineOffset = lineIndex.charOffsetToLineNumberAndPos(position); - return { line: lineOffset.line, offset: lineOffset.offset + 1 }; - }; - LSHost.prototype.getLineIndex = function (filename) { - var path = ts.toPath(filename, this.host.getCurrentDirectory(), this.getCanonicalFileName); - var script = this.filenameToScript.get(path); - return script.snap().index; - }; - return LSHost; - }()); - server.LSHost = LSHost; - var Project = (function () { - function Project(projectService, projectOptions, languageServiceDiabled) { - if (languageServiceDiabled === void 0) { languageServiceDiabled = false; } - this.projectService = projectService; - this.projectOptions = projectOptions; - this.languageServiceDiabled = languageServiceDiabled; - this.directoriesWatchedForTsconfig = []; - this.filenameToSourceFile = ts.createMap(); - this.updateGraphSeq = 0; - this.openRefCount = 0; - if (projectOptions && projectOptions.files) { - projectOptions.compilerOptions.allowNonTsExtensions = true; - } - if (!languageServiceDiabled) { - this.compilerService = new CompilerService(this, projectOptions && projectOptions.compilerOptions); - } - } - Project.prototype.enableLanguageService = function () { - if (this.languageServiceDiabled) { - this.compilerService = new CompilerService(this, this.projectOptions && this.projectOptions.compilerOptions); - } - this.languageServiceDiabled = false; - }; - Project.prototype.disableLanguageService = function () { - this.languageServiceDiabled = true; - }; - Project.prototype.addOpenRef = function () { - this.openRefCount++; - }; - Project.prototype.deleteOpenRef = function () { - this.openRefCount--; - return this.openRefCount; - }; - Project.prototype.openReferencedFile = function (filename) { - return this.projectService.openFile(filename, false); - }; - Project.prototype.getRootFiles = function () { - if (this.languageServiceDiabled) { - return this.projectOptions ? this.projectOptions.files : undefined; - } - return this.compilerService.host.roots.map(function (info) { return info.fileName; }); - }; - Project.prototype.getFileNames = function () { - if (this.languageServiceDiabled) { - if (!this.projectOptions) { - return undefined; - } - var fileNames = []; - if (this.projectOptions && this.projectOptions.compilerOptions) { - fileNames.push(ts.getDefaultLibFilePath(this.projectOptions.compilerOptions)); - } - ts.addRange(fileNames, this.projectOptions.files); - return fileNames; - } - var sourceFiles = this.program.getSourceFiles(); - return sourceFiles.map(function (sourceFile) { return sourceFile.fileName; }); - }; - Project.prototype.getSourceFile = function (info) { - if (this.languageServiceDiabled) { - return undefined; - } - return this.filenameToSourceFile[info.fileName]; - }; - Project.prototype.getSourceFileFromName = function (filename, requireOpen) { - if (this.languageServiceDiabled) { - return undefined; - } - var info = this.projectService.getScriptInfo(filename); - if (info) { - if ((!requireOpen) || info.isOpen) { - return this.getSourceFile(info); - } - } - }; - Project.prototype.isRoot = function (info) { - if (this.languageServiceDiabled) { - return undefined; - } - return this.compilerService.host.roots.some(function (root) { return root === info; }); - }; - Project.prototype.removeReferencedFile = function (info) { - if (this.languageServiceDiabled) { - return; - } - this.compilerService.host.removeReferencedFile(info); - this.updateGraph(); - }; - Project.prototype.updateFileMap = function () { - if (this.languageServiceDiabled) { - return; - } - this.filenameToSourceFile = ts.createMap(); - var sourceFiles = this.program.getSourceFiles(); - for (var i = 0, len = sourceFiles.length; i < len; i++) { - var normFilename = ts.normalizePath(sourceFiles[i].fileName); - this.filenameToSourceFile[normFilename] = sourceFiles[i]; - } - }; - Project.prototype.finishGraph = function () { - if (this.languageServiceDiabled) { - return; - } - this.updateGraph(); - this.compilerService.languageService.getNavigateToItems(".*"); - }; - Project.prototype.updateGraph = function () { - if (this.languageServiceDiabled) { - return; - } - this.program = this.compilerService.languageService.getProgram(); - this.updateFileMap(); - }; - Project.prototype.isConfiguredProject = function () { - return this.projectFilename; - }; - Project.prototype.addRoot = function (info) { - if (this.languageServiceDiabled) { - return; - } - this.compilerService.host.addRoot(info); - }; - Project.prototype.removeRoot = function (info) { - if (this.languageServiceDiabled) { - return; - } - this.compilerService.host.removeRoot(info); - }; - Project.prototype.filesToString = function () { - if (this.languageServiceDiabled) { - if (this.projectOptions) { - var strBuilder_1 = ""; - ts.forEach(this.projectOptions.files, function (file) { strBuilder_1 += file + "\n"; }); - return strBuilder_1; - } - } - var strBuilder = ""; - ts.forEachProperty(this.filenameToSourceFile, function (sourceFile) { strBuilder += sourceFile.fileName + "\n"; }); - return strBuilder; - }; - Project.prototype.setProjectOptions = function (projectOptions) { - this.projectOptions = projectOptions; - if (projectOptions.compilerOptions) { - projectOptions.compilerOptions.allowNonTsExtensions = true; - if (!this.languageServiceDiabled) { - this.compilerService.setCompilerOptions(projectOptions.compilerOptions); - } - } - }; - return Project; - }()); - server.Project = Project; - function combineProjectOutput(projects, action, comparer, areEqual) { - var result = projects.reduce(function (previous, current) { return ts.concatenate(previous, action(current)); }, []).sort(comparer); - return projects.length > 1 ? ts.deduplicate(result, areEqual) : result; - } - server.combineProjectOutput = combineProjectOutput; - var ProjectService = (function () { - function ProjectService(host, psLogger, eventHandler) { - this.host = host; - this.psLogger = psLogger; - this.eventHandler = eventHandler; - this.filenameToScriptInfo = ts.createMap(); - this.openFileRoots = []; - this.inferredProjects = []; - this.configuredProjects = []; - this.openFilesReferenced = []; - this.openFileRootsConfigured = []; - this.directoryWatchersForTsconfig = ts.createMap(); - this.directoryWatchersRefCount = ts.createMap(); - this.timerForDetectingProjectFileListChanges = ts.createMap(); - this.addDefaultHostConfiguration(); - } - ProjectService.prototype.addDefaultHostConfiguration = function () { - this.hostConfiguration = { - formatCodeOptions: ts.clone(CompilerService.getDefaultFormatCodeOptions(this.host)), - hostInfo: "Unknown host" - }; - }; - ProjectService.prototype.getFormatCodeOptions = function (file) { - if (file) { - var info = this.filenameToScriptInfo[file]; - if (info) { - return info.formatCodeOptions; - } - } - return this.hostConfiguration.formatCodeOptions; - }; - ProjectService.prototype.watchedFileChanged = function (fileName) { - var info = this.filenameToScriptInfo[fileName]; - if (!info) { - this.psLogger.info("Error: got watch notification for unknown file: " + fileName); - } - if (!this.host.fileExists(fileName)) { - this.fileDeletedInFilesystem(info); - } - else { - if (info && (!info.isOpen)) { - info.svc.reloadFromFile(info.fileName); - } - } - }; - ProjectService.prototype.directoryWatchedForSourceFilesChanged = function (project, fileName) { - if (fileName && !ts.isSupportedSourceFileName(fileName, project.projectOptions ? project.projectOptions.compilerOptions : undefined)) { - return; - } - this.log("Detected source file changes: " + fileName); - this.startTimerForDetectingProjectFileListChanges(project); - }; - ProjectService.prototype.startTimerForDetectingProjectFileListChanges = function (project) { - var _this = this; - if (this.timerForDetectingProjectFileListChanges[project.projectFilename]) { - this.host.clearTimeout(this.timerForDetectingProjectFileListChanges[project.projectFilename]); - } - this.timerForDetectingProjectFileListChanges[project.projectFilename] = this.host.setTimeout(function () { return _this.handleProjectFileListChanges(project); }, 250); - }; - ProjectService.prototype.handleProjectFileListChanges = function (project) { - var _this = this; - var _a = this.configFileToProjectOptions(project.projectFilename), projectOptions = _a.projectOptions, errors = _a.errors; - this.reportConfigFileDiagnostics(project.projectFilename, errors); - var newRootFiles = projectOptions.files.map((function (f) { return _this.getCanonicalFileName(f); })); - var currentRootFiles = project.getRootFiles().map((function (f) { return _this.getCanonicalFileName(f); })); - if (!ts.arrayIsEqualTo(currentRootFiles && currentRootFiles.sort(), newRootFiles && newRootFiles.sort())) { - this.updateConfiguredProject(project); - this.updateProjectStructure(); - } - }; - ProjectService.prototype.reportConfigFileDiagnostics = function (configFileName, diagnostics, triggerFile) { - if (diagnostics && diagnostics.length > 0) { - this.eventHandler({ - eventName: "configFileDiag", - data: { configFileName: configFileName, diagnostics: diagnostics, triggerFile: triggerFile } - }); - } - }; - ProjectService.prototype.directoryWatchedForTsconfigChanged = function (fileName) { - var _this = this; - if (ts.getBaseFileName(fileName) !== "tsconfig.json") { - this.log(fileName + " is not tsconfig.json"); - return; - } - this.log("Detected newly added tsconfig file: " + fileName); - var _a = this.configFileToProjectOptions(fileName), projectOptions = _a.projectOptions, errors = _a.errors; - this.reportConfigFileDiagnostics(fileName, errors); - if (!projectOptions) { - return; - } - var rootFilesInTsconfig = projectOptions.files.map(function (f) { return _this.getCanonicalFileName(f); }); - var openFileRoots = this.openFileRoots.map(function (s) { return _this.getCanonicalFileName(s.fileName); }); - for (var _i = 0, openFileRoots_1 = openFileRoots; _i < openFileRoots_1.length; _i++) { - var openFileRoot = openFileRoots_1[_i]; - if (rootFilesInTsconfig.indexOf(openFileRoot) >= 0) { - this.reloadProjects(); - return; - } - } - }; - ProjectService.prototype.getCanonicalFileName = function (fileName) { - var name = this.host.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); - return ts.normalizePath(name); - }; - ProjectService.prototype.watchedProjectConfigFileChanged = function (project) { - this.log("Config file changed: " + project.projectFilename); - var configFileErrors = this.updateConfiguredProject(project); - this.updateProjectStructure(); - if (configFileErrors && configFileErrors.length > 0) { - this.eventHandler({ eventName: "configFileDiag", data: { triggerFile: project.projectFilename, configFileName: project.projectFilename, diagnostics: configFileErrors } }); - } - }; - ProjectService.prototype.log = function (msg, type) { - if (type === void 0) { type = "Err"; } - this.psLogger.msg(msg, type); - }; - ProjectService.prototype.setHostConfiguration = function (args) { - if (args.file) { - var info = this.filenameToScriptInfo[args.file]; - if (info) { - info.setFormatOptions(args.formatOptions); - this.log("Host configuration update for file " + args.file, "Info"); - } - } - else { - if (args.hostInfo !== undefined) { - this.hostConfiguration.hostInfo = args.hostInfo; - this.log("Host information " + args.hostInfo, "Info"); - } - if (args.formatOptions) { - mergeFormatOptions(this.hostConfiguration.formatCodeOptions, args.formatOptions); - this.log("Format host information updated", "Info"); - } - } - }; - ProjectService.prototype.closeLog = function () { - this.psLogger.close(); - }; - ProjectService.prototype.createInferredProject = function (root) { - var _this = this; - var project = new Project(this); - project.addRoot(root); - var currentPath = ts.getDirectoryPath(root.fileName); - var parentPath = ts.getDirectoryPath(currentPath); - while (currentPath != parentPath) { - if (!project.projectService.directoryWatchersForTsconfig[currentPath]) { - this.log("Add watcher for: " + currentPath); - project.projectService.directoryWatchersForTsconfig[currentPath] = - this.host.watchDirectory(currentPath, function (fileName) { return _this.directoryWatchedForTsconfigChanged(fileName); }); - project.projectService.directoryWatchersRefCount[currentPath] = 1; - } - else { - project.projectService.directoryWatchersRefCount[currentPath] += 1; - } - project.directoriesWatchedForTsconfig.push(currentPath); - currentPath = parentPath; - parentPath = ts.getDirectoryPath(parentPath); - } - project.finishGraph(); - this.inferredProjects.push(project); - return project; - }; - ProjectService.prototype.fileDeletedInFilesystem = function (info) { - this.psLogger.info(info.fileName + " deleted"); - if (info.fileWatcher) { - info.fileWatcher.close(); - info.fileWatcher = undefined; - } - if (!info.isOpen) { - this.filenameToScriptInfo[info.fileName] = undefined; - var referencingProjects = this.findReferencingProjects(info); - if (info.defaultProject) { - info.defaultProject.removeRoot(info); - } - for (var i = 0, len = referencingProjects.length; i < len; i++) { - referencingProjects[i].removeReferencedFile(info); - } - for (var j = 0, flen = this.openFileRoots.length; j < flen; j++) { - var openFile = this.openFileRoots[j]; - if (this.eventHandler) { - this.eventHandler({ eventName: "context", data: { project: openFile.defaultProject, fileName: openFile.fileName } }); - } - } - for (var j = 0, flen = this.openFilesReferenced.length; j < flen; j++) { - var openFile = this.openFilesReferenced[j]; - if (this.eventHandler) { - this.eventHandler({ eventName: "context", data: { project: openFile.defaultProject, fileName: openFile.fileName } }); - } - } - } - this.printProjects(); - }; - ProjectService.prototype.updateConfiguredProjectList = function () { - var configuredProjects = []; - for (var i = 0, len = this.configuredProjects.length; i < len; i++) { - if (this.configuredProjects[i].openRefCount > 0) { - configuredProjects.push(this.configuredProjects[i]); - } - } - this.configuredProjects = configuredProjects; - }; - ProjectService.prototype.removeProject = function (project) { - this.log("remove project: " + project.getRootFiles().toString()); - if (project.isConfiguredProject()) { - project.projectFileWatcher.close(); - project.directoryWatcher.close(); - ts.forEachProperty(project.directoriesWatchedForWildcards, function (watcher) { watcher.close(); }); - delete project.directoriesWatchedForWildcards; - ts.unorderedRemoveItem(this.configuredProjects, project); - } - else { - for (var _i = 0, _a = project.directoriesWatchedForTsconfig; _i < _a.length; _i++) { - var directory = _a[_i]; - project.projectService.directoryWatchersRefCount[directory]--; - if (!project.projectService.directoryWatchersRefCount[directory]) { - this.log("Close directory watcher for: " + directory); - project.projectService.directoryWatchersForTsconfig[directory].close(); - delete project.projectService.directoryWatchersForTsconfig[directory]; - } - } - ts.unorderedRemoveItem(this.inferredProjects, project); - } - var fileNames = project.getFileNames(); - for (var _b = 0, fileNames_3 = fileNames; _b < fileNames_3.length; _b++) { - var fileName = fileNames_3[_b]; - var info = this.getScriptInfo(fileName); - if (info.defaultProject == project) { - info.defaultProject = undefined; - } - } - }; - ProjectService.prototype.setConfiguredProjectRoot = function (info) { - for (var i = 0, len = this.configuredProjects.length; i < len; i++) { - var configuredProject = this.configuredProjects[i]; - if (configuredProject.isRoot(info)) { - info.defaultProject = configuredProject; - configuredProject.addOpenRef(); - return true; - } - } - return false; - }; - ProjectService.prototype.addOpenFile = function (info) { - if (this.setConfiguredProjectRoot(info)) { - this.openFileRootsConfigured.push(info); - } - else { - this.findReferencingProjects(info); - if (info.defaultProject) { - info.defaultProject.addOpenRef(); - this.openFilesReferenced.push(info); - } - else { - info.defaultProject = this.createInferredProject(info); - var openFileRoots = []; - for (var i = 0, len = this.openFileRoots.length; i < len; i++) { - var r = this.openFileRoots[i]; - if (info.defaultProject.getSourceFile(r)) { - this.removeProject(r.defaultProject); - this.openFilesReferenced.push(r); - r.defaultProject = info.defaultProject; - } - else { - openFileRoots.push(r); - } - } - this.openFileRoots = openFileRoots; - this.openFileRoots.push(info); - } - } - this.updateConfiguredProjectList(); - }; - ProjectService.prototype.closeOpenFile = function (info) { - info.svc.reloadFromFile(info.fileName); - var openFileRoots = []; - var removedProject; - for (var i = 0, len = this.openFileRoots.length; i < len; i++) { - if (info === this.openFileRoots[i]) { - removedProject = info.defaultProject; - } - else { - openFileRoots.push(this.openFileRoots[i]); - } - } - this.openFileRoots = openFileRoots; - if (!removedProject) { - var openFileRootsConfigured = []; - for (var i = 0, len = this.openFileRootsConfigured.length; i < len; i++) { - if (info === this.openFileRootsConfigured[i]) { - if (info.defaultProject.deleteOpenRef() === 0) { - removedProject = info.defaultProject; - } - } - else { - openFileRootsConfigured.push(this.openFileRootsConfigured[i]); - } - } - this.openFileRootsConfigured = openFileRootsConfigured; - } - if (removedProject) { - this.removeProject(removedProject); - var openFilesReferenced = []; - var orphanFiles = []; - for (var i = 0, len = this.openFilesReferenced.length; i < len; i++) { - var f = this.openFilesReferenced[i]; - if (f.defaultProject === removedProject || !f.defaultProject) { - f.defaultProject = undefined; - orphanFiles.push(f); - } - else { - openFilesReferenced.push(f); - } - } - this.openFilesReferenced = openFilesReferenced; - for (var i = 0, len = orphanFiles.length; i < len; i++) { - this.addOpenFile(orphanFiles[i]); - } - } - else { - ts.unorderedRemoveItem(this.openFilesReferenced, info); - } - info.close(); - }; - ProjectService.prototype.findReferencingProjects = function (info, excludedProject) { - var referencingProjects = []; - info.defaultProject = undefined; - for (var i = 0, len = this.inferredProjects.length; i < len; i++) { - var inferredProject = this.inferredProjects[i]; - inferredProject.updateGraph(); - if (inferredProject !== excludedProject) { - if (inferredProject.getSourceFile(info)) { - info.defaultProject = inferredProject; - referencingProjects.push(inferredProject); - } - } - } - for (var i = 0, len = this.configuredProjects.length; i < len; i++) { - var configuredProject = this.configuredProjects[i]; - configuredProject.updateGraph(); - if (configuredProject.getSourceFile(info)) { - info.defaultProject = configuredProject; - referencingProjects.push(configuredProject); - } - } - return referencingProjects; - }; - ProjectService.prototype.reloadProjects = function () { - this.log("reload projects."); - for (var _i = 0, _a = this.openFileRoots; _i < _a.length; _i++) { - var info = _a[_i]; - this.openOrUpdateConfiguredProjectForFile(info.fileName); - } - this.updateProjectStructure(); - }; - ProjectService.prototype.updateProjectStructure = function () { - this.log("updating project structure from ...", "Info"); - this.printProjects(); - var unattachedOpenFiles = []; - var openFileRootsConfigured = []; - for (var _i = 0, _a = this.openFileRootsConfigured; _i < _a.length; _i++) { - var info = _a[_i]; - var project = info.defaultProject; - if (!project || !(project.getSourceFile(info))) { - info.defaultProject = undefined; - unattachedOpenFiles.push(info); - } - else { - openFileRootsConfigured.push(info); - } - } - this.openFileRootsConfigured = openFileRootsConfigured; - var openFilesReferenced = []; - for (var i = 0, len = this.openFilesReferenced.length; i < len; i++) { - var referencedFile = this.openFilesReferenced[i]; - referencedFile.defaultProject.updateGraph(); - var sourceFile = referencedFile.defaultProject.getSourceFile(referencedFile); - if (sourceFile) { - openFilesReferenced.push(referencedFile); - } - else { - unattachedOpenFiles.push(referencedFile); - } - } - this.openFilesReferenced = openFilesReferenced; - var openFileRoots = []; - for (var i = 0, len = this.openFileRoots.length; i < len; i++) { - var rootFile = this.openFileRoots[i]; - var rootedProject = rootFile.defaultProject; - var referencingProjects = this.findReferencingProjects(rootFile, rootedProject); - if (rootFile.defaultProject && rootFile.defaultProject.isConfiguredProject()) { - if (!rootedProject.isConfiguredProject()) { - this.removeProject(rootedProject); - } - this.openFileRootsConfigured.push(rootFile); - } - else { - if (referencingProjects.length === 0) { - rootFile.defaultProject = rootedProject; - openFileRoots.push(rootFile); - } - else { - this.removeProject(rootedProject); - this.openFilesReferenced.push(rootFile); - } - } - } - this.openFileRoots = openFileRoots; - for (var i = 0, len = unattachedOpenFiles.length; i < len; i++) { - this.addOpenFile(unattachedOpenFiles[i]); - } - this.printProjects(); - }; - ProjectService.prototype.getScriptInfo = function (filename) { - filename = ts.normalizePath(filename); - return this.filenameToScriptInfo[filename]; - }; - ProjectService.prototype.openFile = function (fileName, openedByClient, fileContent, scriptKind) { - var _this = this; - fileName = ts.normalizePath(fileName); - var info = this.filenameToScriptInfo[fileName]; - if (!info) { - var content = void 0; - if (this.host.fileExists(fileName)) { - content = fileContent || this.host.readFile(fileName); - } - if (!content) { - if (openedByClient) { - content = ""; - } - } - if (content !== undefined) { - info = new ScriptInfo(this.host, fileName, content, openedByClient); - info.scriptKind = scriptKind; - info.setFormatOptions(this.getFormatCodeOptions()); - this.filenameToScriptInfo[fileName] = info; - if (!info.isOpen) { - info.fileWatcher = this.host.watchFile(fileName, function (_) { _this.watchedFileChanged(fileName); }); - } - } - } - if (info) { - if (fileContent) { - info.svc.reload(fileContent); - } - if (openedByClient) { - info.isOpen = true; - } - } - return info; - }; - ProjectService.prototype.findConfigFile = function (searchPath) { - while (true) { - var tsconfigFileName = ts.combinePaths(searchPath, "tsconfig.json"); - if (this.host.fileExists(tsconfigFileName)) { - return tsconfigFileName; - } - var jsconfigFileName = ts.combinePaths(searchPath, "jsconfig.json"); - if (this.host.fileExists(jsconfigFileName)) { - return jsconfigFileName; - } - var parentPath = ts.getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; - } - return undefined; - }; - ProjectService.prototype.openClientFile = function (fileName, fileContent, scriptKind) { - var _a = this.openOrUpdateConfiguredProjectForFile(fileName), configFileName = _a.configFileName, configFileErrors = _a.configFileErrors; - var info = this.openFile(fileName, true, fileContent, scriptKind); - this.addOpenFile(info); - this.printProjects(); - return { configFileName: configFileName, configFileErrors: configFileErrors }; - }; - ProjectService.prototype.openOrUpdateConfiguredProjectForFile = function (fileName) { - var searchPath = ts.normalizePath(ts.getDirectoryPath(fileName)); - this.log("Search path: " + searchPath, "Info"); - var configFileName = this.findConfigFile(searchPath); - if (configFileName) { - this.log("Config file name: " + configFileName, "Info"); - var project = this.findConfiguredProjectByConfigFile(configFileName); - if (!project) { - var configResult = this.openConfigFile(configFileName, fileName); - if (!configResult.project) { - return { configFileName: configFileName, configFileErrors: configResult.errors }; - } - else { - this.log("Opened configuration file " + configFileName, "Info"); - this.configuredProjects.push(configResult.project); - if (configResult.errors && configResult.errors.length > 0) { - return { configFileName: configFileName, configFileErrors: configResult.errors }; - } - } - } - else { - this.updateConfiguredProject(project); - } - return { configFileName: configFileName }; - } - else { - this.log("No config files found."); - } - return {}; - }; - ProjectService.prototype.closeClientFile = function (filename) { - var info = this.filenameToScriptInfo[filename]; - if (info) { - this.closeOpenFile(info); - info.isOpen = false; - } - this.printProjects(); - }; - ProjectService.prototype.getProjectForFile = function (filename) { - var scriptInfo = this.filenameToScriptInfo[filename]; - if (scriptInfo) { - return scriptInfo.defaultProject; - } - }; - ProjectService.prototype.printProjectsForFile = function (filename) { - var scriptInfo = this.filenameToScriptInfo[filename]; - if (scriptInfo) { - this.psLogger.startGroup(); - this.psLogger.info("Projects for " + filename); - var projects = this.findReferencingProjects(scriptInfo); - for (var i = 0, len = projects.length; i < len; i++) { - this.psLogger.info("Project " + i.toString()); - } - this.psLogger.endGroup(); - } - else { - this.psLogger.info(filename + " not in any project"); - } - }; - ProjectService.prototype.printProjects = function () { - if (!this.psLogger.isVerbose()) { - return; - } - this.psLogger.startGroup(); - for (var i = 0, len = this.inferredProjects.length; i < len; i++) { - var project = this.inferredProjects[i]; - project.updateGraph(); - this.psLogger.info("Project " + i.toString()); - this.psLogger.info(project.filesToString()); - this.psLogger.info("-----------------------------------------------"); - } - for (var i = 0, len = this.configuredProjects.length; i < len; i++) { - var project = this.configuredProjects[i]; - project.updateGraph(); - this.psLogger.info("Project (configured) " + (i + this.inferredProjects.length).toString()); - this.psLogger.info(project.filesToString()); - this.psLogger.info("-----------------------------------------------"); - } - this.psLogger.info("Open file roots of inferred projects: "); - for (var i = 0, len = this.openFileRoots.length; i < len; i++) { - this.psLogger.info(this.openFileRoots[i].fileName); - } - this.psLogger.info("Open files referenced by inferred or configured projects: "); - for (var i = 0, len = this.openFilesReferenced.length; i < len; i++) { - var fileInfo = this.openFilesReferenced[i].fileName; - if (this.openFilesReferenced[i].defaultProject.isConfiguredProject()) { - fileInfo += " (configured)"; - } - this.psLogger.info(fileInfo); - } - this.psLogger.info("Open file roots of configured projects: "); - for (var i = 0, len = this.openFileRootsConfigured.length; i < len; i++) { - this.psLogger.info(this.openFileRootsConfigured[i].fileName); - } - this.psLogger.endGroup(); - }; - ProjectService.prototype.configProjectIsActive = function (fileName) { - return this.findConfiguredProjectByConfigFile(fileName) === undefined; - }; - ProjectService.prototype.findConfiguredProjectByConfigFile = function (configFileName) { - for (var i = 0, len = this.configuredProjects.length; i < len; i++) { - if (this.configuredProjects[i].projectFilename == configFileName) { - return this.configuredProjects[i]; - } - } - return undefined; - }; - ProjectService.prototype.configFileToProjectOptions = function (configFilename) { - configFilename = ts.normalizePath(configFilename); - var errors = []; - var dirPath = ts.getDirectoryPath(configFilename); - var contents = this.host.readFile(configFilename); - var _a = ts.parseAndReEmitConfigJSONFile(contents), configJsonObject = _a.configJsonObject, diagnostics = _a.diagnostics; - errors = ts.concatenate(errors, diagnostics); - var parsedCommandLine = ts.parseJsonConfigFileContent(configJsonObject, this.host, dirPath, {}, configFilename); - errors = ts.concatenate(errors, parsedCommandLine.errors); - ts.Debug.assert(!!parsedCommandLine.fileNames); - if (parsedCommandLine.fileNames.length === 0) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.The_config_file_0_found_doesn_t_contain_any_source_files, configFilename)); - return { errors: errors }; - } - else { - var projectOptions = { - files: parsedCommandLine.fileNames, - wildcardDirectories: parsedCommandLine.wildcardDirectories, - compilerOptions: parsedCommandLine.options - }; - return { projectOptions: projectOptions, errors: errors }; - } - }; - ProjectService.prototype.exceedTotalNonTsFileSizeLimit = function (fileNames) { - var totalNonTsFileSize = 0; - if (!this.host.getFileSize) { - return false; - } - for (var _i = 0, fileNames_4 = fileNames; _i < fileNames_4.length; _i++) { - var fileName = fileNames_4[_i]; - if (ts.hasTypeScriptFileExtension(fileName)) { - continue; - } - totalNonTsFileSize += this.host.getFileSize(fileName); - if (totalNonTsFileSize > server.maxProgramSizeForNonTsFiles) { - return true; - } - } - return false; - }; - ProjectService.prototype.openConfigFile = function (configFilename, clientFileName) { - var _this = this; - var parseConfigFileResult = this.configFileToProjectOptions(configFilename); - var errors = parseConfigFileResult.errors; - if (!parseConfigFileResult.projectOptions) { - return { errors: errors }; - } - var projectOptions = parseConfigFileResult.projectOptions; - if (!projectOptions.compilerOptions.disableSizeLimit && projectOptions.compilerOptions.allowJs) { - if (this.exceedTotalNonTsFileSizeLimit(projectOptions.files)) { - var project_1 = this.createProject(configFilename, projectOptions, true); - project_1.projectFileWatcher = this.host.watchFile(ts.toPath(configFilename, configFilename, ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)), function (_) { return _this.watchedProjectConfigFileChanged(project_1); }); - return { project: project_1, errors: errors }; - } - } - var project = this.createProject(configFilename, projectOptions); - for (var _i = 0, _a = projectOptions.files; _i < _a.length; _i++) { - var rootFilename = _a[_i]; - if (this.host.fileExists(rootFilename)) { - var info = this.openFile(rootFilename, clientFileName == rootFilename); - project.addRoot(info); - } - else { - (errors || (errors = [])).push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, rootFilename)); - } - } - project.finishGraph(); - project.projectFileWatcher = this.host.watchFile(configFilename, function (_) { return _this.watchedProjectConfigFileChanged(project); }); - var configDirectoryPath = ts.getDirectoryPath(configFilename); - this.log("Add recursive watcher for: " + configDirectoryPath); - project.directoryWatcher = this.host.watchDirectory(configDirectoryPath, function (path) { return _this.directoryWatchedForSourceFilesChanged(project, path); }, true); - project.directoriesWatchedForWildcards = ts.reduceProperties(ts.createMap(projectOptions.wildcardDirectories), function (watchers, flag, directory) { - if (ts.comparePaths(configDirectoryPath, directory, ".", !_this.host.useCaseSensitiveFileNames) !== 0) { - var recursive = (flag & 1) !== 0; - _this.log("Add " + (recursive ? "recursive " : "") + "watcher for: " + directory); - watchers[directory] = _this.host.watchDirectory(directory, function (path) { return _this.directoryWatchedForSourceFilesChanged(project, path); }, recursive); - } - return watchers; - }, {}); - return { project: project, errors: errors }; - }; - ProjectService.prototype.updateConfiguredProject = function (project) { - var _this = this; - if (!this.host.fileExists(project.projectFilename)) { - this.log("Config file deleted"); - this.removeProject(project); - } - else { - var _a = this.configFileToProjectOptions(project.projectFilename), projectOptions = _a.projectOptions, errors = _a.errors; - if (!projectOptions) { - return errors; - } - else { - if (projectOptions.compilerOptions && !projectOptions.compilerOptions.disableSizeLimit && this.exceedTotalNonTsFileSizeLimit(projectOptions.files)) { - project.setProjectOptions(projectOptions); - if (project.languageServiceDiabled) { - return errors; - } - project.disableLanguageService(); - if (project.directoryWatcher) { - project.directoryWatcher.close(); - project.directoryWatcher = undefined; - } - return errors; - } - if (project.languageServiceDiabled) { - project.setProjectOptions(projectOptions); - project.enableLanguageService(); - project.directoryWatcher = this.host.watchDirectory(ts.getDirectoryPath(project.projectFilename), function (path) { return _this.directoryWatchedForSourceFilesChanged(project, path); }, true); - for (var _i = 0, _b = projectOptions.files; _i < _b.length; _i++) { - var rootFilename = _b[_i]; - if (this.host.fileExists(rootFilename)) { - var info = this.openFile(rootFilename, false); - project.addRoot(info); - } - } - project.finishGraph(); - return errors; - } - var oldFileNames_1 = project.projectOptions ? project.projectOptions.files : project.compilerService.host.roots.map(function (info) { return info.fileName; }); - var newFileNames_1 = ts.filter(projectOptions.files, function (f) { return _this.host.fileExists(f); }); - var fileNamesToRemove = oldFileNames_1.filter(function (f) { return newFileNames_1.indexOf(f) < 0; }); - var fileNamesToAdd = newFileNames_1.filter(function (f) { return oldFileNames_1.indexOf(f) < 0; }); - for (var _c = 0, fileNamesToRemove_1 = fileNamesToRemove; _c < fileNamesToRemove_1.length; _c++) { - var fileName = fileNamesToRemove_1[_c]; - var info = this.getScriptInfo(fileName); - if (info) { - project.removeRoot(info); - } - } - for (var _d = 0, fileNamesToAdd_1 = fileNamesToAdd; _d < fileNamesToAdd_1.length; _d++) { - var fileName = fileNamesToAdd_1[_d]; - var info = this.getScriptInfo(fileName); - if (!info) { - info = this.openFile(fileName, false); - } - else { - if (info.isOpen) { - if (this.openFileRoots.indexOf(info) >= 0) { - ts.unorderedRemoveItem(this.openFileRoots, info); - if (info.defaultProject && !info.defaultProject.isConfiguredProject()) { - this.removeProject(info.defaultProject); - } - } - if (this.openFilesReferenced.indexOf(info) >= 0) { - ts.unorderedRemoveItem(this.openFilesReferenced, info); - } - this.openFileRootsConfigured.push(info); - info.defaultProject = project; - } - } - project.addRoot(info); - } - project.setProjectOptions(projectOptions); - project.finishGraph(); - } - return errors; - } - }; - ProjectService.prototype.createProject = function (projectFilename, projectOptions, languageServiceDisabled) { - var project = new Project(this, projectOptions, languageServiceDisabled); - project.projectFilename = projectFilename; - return project; - }; - return ProjectService; - }()); - server.ProjectService = ProjectService; - var CompilerService = (function () { - function CompilerService(project, opt) { - this.project = project; - this.documentRegistry = ts.createDocumentRegistry(); - this.host = new LSHost(project.projectService.host, project); - if (opt) { - this.setCompilerOptions(opt); - } - else { - var defaultOpts = ts.getDefaultCompilerOptions(); - defaultOpts.allowNonTsExtensions = true; - defaultOpts.allowJs = true; - this.setCompilerOptions(defaultOpts); - } - this.languageService = ts.createLanguageService(this.host, this.documentRegistry); - this.classifier = ts.createClassifier(); - } - CompilerService.prototype.setCompilerOptions = function (opt) { - this.settings = opt; - this.host.setCompilationSettings(opt); - }; - CompilerService.prototype.isExternalModule = function (filename) { - var sourceFile = this.languageService.getNonBoundSourceFile(filename); - return ts.isExternalModule(sourceFile); - }; - CompilerService.getDefaultFormatCodeOptions = function (host) { - return ts.clone({ - BaseIndentSize: 0, - IndentSize: 4, - TabSize: 4, - NewLineCharacter: host.newLine || "\n", - ConvertTabsToSpaces: true, - IndentStyle: ts.IndentStyle.Smart, - InsertSpaceAfterCommaDelimiter: true, - InsertSpaceAfterSemicolonInForStatements: true, - InsertSpaceBeforeAndAfterBinaryOperators: true, - InsertSpaceAfterKeywordsInControlFlowStatements: true, - InsertSpaceAfterFunctionKeywordForAnonymousFunctions: false, - InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, - InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, - InsertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: true, - InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, - InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, - InsertSpaceAfterTypeAssertion: false, - PlaceOpenBraceOnNewLineForFunctions: false, - PlaceOpenBraceOnNewLineForControlBlocks: false - }); - }; - return CompilerService; - }()); - server.CompilerService = CompilerService; (function (CharRangeSection) { CharRangeSection[CharRangeSection["PreStart"] = 0] = "PreStart"; CharRangeSection[CharRangeSection["Start"] = 1] = "Start"; @@ -62605,16 +64797,17 @@ var ts; var EditWalker = (function (_super) { __extends(EditWalker, _super); function EditWalker() { - _super.call(this); - this.lineIndex = new LineIndex(); - this.endBranch = []; - this.state = CharRangeSection.Entire; - this.initialText = ""; - this.trailingText = ""; - this.suppressTrailingText = false; - this.lineIndex.root = new LineNode(); - this.startPath = [this.lineIndex.root]; - this.stack = [this.lineIndex.root]; + var _this = _super.call(this) || this; + _this.lineIndex = new LineIndex(); + _this.endBranch = []; + _this.state = CharRangeSection.Entire; + _this.initialText = ""; + _this.trailingText = ""; + _this.suppressTrailingText = false; + _this.lineIndex.root = new LineNode(); + _this.startPath = [_this.lineIndex.root]; + _this.stack = [_this.lineIndex.root]; + return _this; } EditWalker.prototype.insertLines = function (insertedText) { if (this.suppressTrailingText) { @@ -62801,10 +64994,19 @@ var ts; var ScriptVersionCache = (function () { function ScriptVersionCache() { this.changes = []; - this.versions = []; + this.versions = new Array(ScriptVersionCache.maxVersions); this.minVersion = 0; this.currentVersion = 0; } + ScriptVersionCache.prototype.versionToIndex = function (version) { + if (version < this.minVersion || version > this.currentVersion) { + return undefined; + } + return version % ScriptVersionCache.maxVersions; + }; + ScriptVersionCache.prototype.currentVersionToIndex = function () { + return this.currentVersion % ScriptVersionCache.maxVersions; + }; ScriptVersionCache.prototype.edit = function (pos, deleteLen, insertedText) { this.changes[this.changes.length] = new TextChange(pos, deleteLen, insertedText); if ((this.changes.length > ScriptVersionCache.changeNumberThreshold) || @@ -62814,7 +65016,7 @@ var ts; } }; ScriptVersionCache.prototype.latest = function () { - return this.versions[this.currentVersion]; + return this.versions[this.currentVersionToIndex()]; }; ScriptVersionCache.prototype.latestVersion = function () { if (this.changes.length > 0) { @@ -62822,32 +65024,30 @@ var ts; } return this.currentVersion; }; - ScriptVersionCache.prototype.reloadFromFile = function (filename, cb) { + ScriptVersionCache.prototype.reloadFromFile = function (filename) { var content = this.host.readFile(filename); if (!content) { content = ""; } this.reload(content); - if (cb) - cb(); }; ScriptVersionCache.prototype.reload = function (script) { this.currentVersion++; this.changes = []; var snap = new LineIndexSnapshot(this.currentVersion, this); - this.versions[this.currentVersion] = snap; + for (var i = 0; i < this.versions.length; i++) { + this.versions[i] = undefined; + } + this.versions[this.currentVersionToIndex()] = snap; snap.index = new LineIndex(); var lm = LineIndex.linesFromText(script); snap.index.load(lm.lines); - for (var i = this.minVersion; i < this.currentVersion; i++) { - this.versions[i] = undefined; - } this.minVersion = this.currentVersion; }; ScriptVersionCache.prototype.getSnapshot = function () { - var snap = this.versions[this.currentVersion]; + var snap = this.versions[this.currentVersionToIndex()]; if (this.changes.length > 0) { - var snapIndex = this.latest().index; + var snapIndex = snap.index; for (var i = 0, len = this.changes.length; i < len; i++) { var change = this.changes[i]; snapIndex = snapIndex.edit(change.pos, change.deleteLen, change.insertedText); @@ -62856,14 +65056,10 @@ var ts; snap.index = snapIndex; snap.changesSincePreviousVersion = this.changes; this.currentVersion = snap.version; - this.versions[snap.version] = snap; + this.versions[this.currentVersionToIndex()] = snap; this.changes = []; if ((this.currentVersion - this.minVersion) >= ScriptVersionCache.maxVersions) { - var oldMin = this.minVersion; this.minVersion = (this.currentVersion - ScriptVersionCache.maxVersions) + 1; - for (var j = oldMin; j < this.minVersion; j++) { - this.versions[j] = undefined; - } } } return snap; @@ -62873,7 +65069,7 @@ var ts; if (oldVersion >= this.minVersion) { var textChangeRanges = []; for (var i = oldVersion + 1; i <= newVersion; i++) { - var snap = this.versions[i]; + var snap = this.versions[this.versionToIndex(i)]; for (var j = 0, len = snap.changesSincePreviousVersion.length; j < len; j++) { var textChange = snap.changesSincePreviousVersion[j]; textChangeRanges[textChangeRanges.length] = textChange.getTextChangeRange(); @@ -63011,7 +65207,7 @@ var ts; done: false, leaf: function (relativeStart, relativeLength, ll) { if (!f(ll, relativeStart, relativeLength)) { - walkFns.done = true; + this.done = true; } } }; @@ -63024,7 +65220,7 @@ var ts; return source.substring(0, s) + nt + source.substring(s + dl, source.length); } if (this.root.charCount() === 0) { - if (newText) { + if (newText !== undefined) { this.load(LineIndex.linesFromText(newText).lines); return this; } @@ -63404,12 +65600,6 @@ var ts; function LineLeaf(text) { this.text = text; } - LineLeaf.prototype.setUdata = function (data) { - this.udata = data; - }; - LineLeaf.prototype.getUdata = function () { - return this.udata; - }; LineLeaf.prototype.isLeaf = function () { return true; }; @@ -63427,7 +65617,7 @@ var ts; server.LineLeaf = LineLeaf; })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); -var debugObjectHost = new Function("return this")(); +var debugObjectHost = (function () { return this; })(); var ts; (function (ts) { function logInternalError(logger, err) { @@ -63505,6 +65695,12 @@ var ts; } return this.shimHost.getProjectVersion(); }; + LanguageServiceShimHostAdapter.prototype.getTypeRootsVersion = function () { + if (!this.shimHost.getTypeRootsVersion) { + return 0; + } + return this.shimHost.getTypeRootsVersion(); + }; LanguageServiceShimHostAdapter.prototype.useCaseSensitiveFileNames = function () { return this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false; }; @@ -63698,11 +65894,12 @@ var ts; var LanguageServiceShimObject = (function (_super) { __extends(LanguageServiceShimObject, _super); function LanguageServiceShimObject(factory, host, languageService) { - _super.call(this, factory); - this.host = host; - this.languageService = languageService; - this.logPerformance = false; - this.logger = this.host; + var _this = _super.call(this, factory) || this; + _this.host = host; + _this.languageService = languageService; + _this.logPerformance = false; + _this.logger = _this.host; + return _this; } LanguageServiceShimObject.prototype.forwardJSONCall = function (actionDescription, action) { return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); @@ -63881,6 +66078,10 @@ var ts; var _this = this; return this.forwardJSONCall("getNavigationBarItems('" + fileName + "')", function () { return _this.languageService.getNavigationBarItems(fileName); }); }; + LanguageServiceShimObject.prototype.getNavigationTree = function (fileName) { + var _this = this; + return this.forwardJSONCall("getNavigationTree('" + fileName + "')", function () { return _this.languageService.getNavigationTree(fileName); }); + }; LanguageServiceShimObject.prototype.getOutliningSpans = function (fileName) { var _this = this; return this.forwardJSONCall("getOutliningSpans('" + fileName + "')", function () { return _this.languageService.getOutliningSpans(fileName); }); @@ -63905,10 +66106,11 @@ var ts; var ClassifierShimObject = (function (_super) { __extends(ClassifierShimObject, _super); function ClassifierShimObject(factory, logger) { - _super.call(this, factory); - this.logger = logger; - this.logPerformance = false; - this.classifier = ts.createClassifier(); + var _this = _super.call(this, factory) || this; + _this.logger = logger; + _this.logPerformance = false; + _this.classifier = ts.createClassifier(); + return _this; } ClassifierShimObject.prototype.getEncodedLexicalClassifications = function (text, lexState, syntacticClassifierAbsent) { var _this = this; @@ -63930,10 +66132,11 @@ var ts; var CoreServicesShimObject = (function (_super) { __extends(CoreServicesShimObject, _super); function CoreServicesShimObject(factory, logger, host) { - _super.call(this, factory); - this.logger = logger; - this.host = host; - this.logPerformance = false; + var _this = _super.call(this, factory) || this; + _this.logger = logger; + _this.host = host; + _this.logPerformance = false; + return _this; } CoreServicesShimObject.prototype.forwardJSONCall = function (actionDescription, action) { return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index 9116a629d6d..c915bd9efc8 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -29,6 +29,7 @@ declare namespace ts { contains(fileName: Path): boolean; remove(fileName: Path): void; forEachValue(f: (key: Path, v: T) => void): void; + getKeys(): Path[]; clear(): void; } interface TextRange { @@ -388,7 +389,6 @@ declare namespace ts { ContextFlags = 1540096, TypeExcludesFlags = 327680, } - type ModifiersArray = NodeArray; enum ModifierFlags { None = 0, Export = 1, @@ -425,12 +425,21 @@ declare namespace ts { interface NodeArray extends Array, TextRange { hasTrailingComma?: boolean; } - interface Token extends Node { - __tokenTag: any; - } - interface Modifier extends Token { + interface Token extends Node { + kind: TKind; } + type DotDotDotToken = Token; + type QuestionToken = Token; + type ColonToken = Token; + type EqualsToken = Token; + type AsteriskToken = Token; + type EqualsGreaterThanToken = Token; + type EndOfFileToken = Token; + type AtToken = Token; + type Modifier = Token | Token | Token | Token | Token | Token | Token | Token | Token | Token | Token; + type ModifiersArray = NodeArray; interface Identifier extends PrimaryExpression { + kind: SyntaxKind.Identifier; text: string; originalKeywordKind?: SyntaxKind; } @@ -438,6 +447,7 @@ declare namespace ts { resolvedSymbol: Symbol; } interface QualifiedName extends Node { + kind: SyntaxKind.QualifiedName; left: EntityName; right: Identifier; } @@ -449,15 +459,18 @@ declare namespace ts { name?: DeclarationName; } interface DeclarationStatement extends Declaration, Statement { - name?: Identifier; + name?: Identifier | LiteralExpression; } interface ComputedPropertyName extends Node { + kind: SyntaxKind.ComputedPropertyName; expression: Expression; } interface Decorator extends Node { + kind: SyntaxKind.Decorator; expression: LeftHandSideExpression; } interface TypeParameterDeclaration extends Declaration { + kind: SyntaxKind.TypeParameter; name: Identifier; constraint?: TypeNode; expression?: Expression; @@ -469,40 +482,48 @@ declare namespace ts { type?: TypeNode; } interface CallSignatureDeclaration extends SignatureDeclaration, TypeElement { + kind: SyntaxKind.CallSignature; } interface ConstructSignatureDeclaration extends SignatureDeclaration, TypeElement { + kind: SyntaxKind.ConstructSignature; } type BindingName = Identifier | BindingPattern; interface VariableDeclaration extends Declaration { + kind: SyntaxKind.VariableDeclaration; parent?: VariableDeclarationList; name: BindingName; type?: TypeNode; initializer?: Expression; } interface VariableDeclarationList extends Node { + kind: SyntaxKind.VariableDeclarationList; declarations: NodeArray; } interface ParameterDeclaration extends Declaration { - dotDotDotToken?: Node; + kind: SyntaxKind.Parameter; + dotDotDotToken?: DotDotDotToken; name: BindingName; - questionToken?: Node; + questionToken?: QuestionToken; type?: TypeNode; initializer?: Expression; } interface BindingElement extends Declaration { + kind: SyntaxKind.BindingElement; propertyName?: PropertyName; - dotDotDotToken?: Node; + dotDotDotToken?: DotDotDotToken; name: BindingName; initializer?: Expression; } interface PropertySignature extends TypeElement { + kind: SyntaxKind.PropertySignature | SyntaxKind.JSDocRecordMember; name: PropertyName; - questionToken?: Node; + questionToken?: QuestionToken; type?: TypeNode; initializer?: Expression; } interface PropertyDeclaration extends ClassElement { - questionToken?: Node; + kind: SyntaxKind.PropertyDeclaration; + questionToken?: QuestionToken; name: PropertyName; type?: TypeNode; initializer?: Expression; @@ -513,22 +534,23 @@ declare namespace ts { } type ObjectLiteralElementLike = PropertyAssignment | ShorthandPropertyAssignment | MethodDeclaration | AccessorDeclaration; interface PropertyAssignment extends ObjectLiteralElement { - _propertyAssignmentBrand: any; + kind: SyntaxKind.PropertyAssignment; name: PropertyName; - questionToken?: Node; + questionToken?: QuestionToken; initializer: Expression; } interface ShorthandPropertyAssignment extends ObjectLiteralElement { + kind: SyntaxKind.ShorthandPropertyAssignment; name: Identifier; - questionToken?: Node; - equalsToken?: Node; + questionToken?: QuestionToken; + equalsToken?: Token; objectAssignmentInitializer?: Expression; } interface VariableLikeDeclaration extends Declaration { propertyName?: PropertyName; - dotDotDotToken?: Node; + dotDotDotToken?: DotDotDotToken; name: DeclarationName; - questionToken?: Node; + questionToken?: QuestionToken; type?: TypeNode; initializer?: Expression; } @@ -539,10 +561,12 @@ declare namespace ts { elements: NodeArray; } interface ObjectBindingPattern extends BindingPattern { + kind: SyntaxKind.ObjectBindingPattern; elements: NodeArray; } type ArrayBindingElement = BindingElement | OmittedExpression; interface ArrayBindingPattern extends BindingPattern { + kind: SyntaxKind.ArrayBindingPattern; elements: NodeArray; } /** @@ -555,95 +579,116 @@ declare namespace ts { */ interface FunctionLikeDeclaration extends SignatureDeclaration { _functionLikeDeclarationBrand: any; - asteriskToken?: Node; - questionToken?: Node; + asteriskToken?: AsteriskToken; + questionToken?: QuestionToken; body?: Block | Expression; } interface FunctionDeclaration extends FunctionLikeDeclaration, DeclarationStatement { + kind: SyntaxKind.FunctionDeclaration; name?: Identifier; body?: FunctionBody; } interface MethodSignature extends SignatureDeclaration, TypeElement { + kind: SyntaxKind.MethodSignature; name: PropertyName; } interface MethodDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { + kind: SyntaxKind.MethodDeclaration; name: PropertyName; body?: FunctionBody; } interface ConstructorDeclaration extends FunctionLikeDeclaration, ClassElement { + kind: SyntaxKind.Constructor; body?: FunctionBody; } interface SemicolonClassElement extends ClassElement { - _semicolonClassElementBrand: any; + kind: SyntaxKind.SemicolonClassElement; } - interface AccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { - _accessorDeclarationBrand: any; + interface GetAccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { + kind: SyntaxKind.GetAccessor; name: PropertyName; body: FunctionBody; } - interface GetAccessorDeclaration extends AccessorDeclaration { - } - interface SetAccessorDeclaration extends AccessorDeclaration { + interface SetAccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { + kind: SyntaxKind.SetAccessor; + name: PropertyName; + body: FunctionBody; } + type AccessorDeclaration = GetAccessorDeclaration | SetAccessorDeclaration; interface IndexSignatureDeclaration extends SignatureDeclaration, ClassElement, TypeElement { - _indexSignatureDeclarationBrand: any; + kind: SyntaxKind.IndexSignature; } interface TypeNode extends Node { _typeNodeBrand: any; } + interface KeywordTypeNode extends TypeNode { + kind: SyntaxKind.AnyKeyword | SyntaxKind.NumberKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.VoidKeyword; + } interface ThisTypeNode extends TypeNode { - _thisTypeNodeBrand: any; + kind: SyntaxKind.ThisType; } interface FunctionOrConstructorTypeNode extends TypeNode, SignatureDeclaration { - _functionOrConstructorTypeNodeBrand: any; + kind: SyntaxKind.FunctionType | SyntaxKind.ConstructorType; } interface FunctionTypeNode extends FunctionOrConstructorTypeNode { + kind: SyntaxKind.FunctionType; } interface ConstructorTypeNode extends FunctionOrConstructorTypeNode { + kind: SyntaxKind.ConstructorType; } interface TypeReferenceNode extends TypeNode { + kind: SyntaxKind.TypeReference; typeName: EntityName; typeArguments?: NodeArray; } interface TypePredicateNode extends TypeNode { + kind: SyntaxKind.TypePredicate; parameterName: Identifier | ThisTypeNode; type: TypeNode; } interface TypeQueryNode extends TypeNode { + kind: SyntaxKind.TypeQuery; exprName: EntityName; } interface TypeLiteralNode extends TypeNode, Declaration { + kind: SyntaxKind.TypeLiteral; members: NodeArray; } interface ArrayTypeNode extends TypeNode { + kind: SyntaxKind.ArrayType; elementType: TypeNode; } interface TupleTypeNode extends TypeNode { + kind: SyntaxKind.TupleType; elementTypes: NodeArray; } interface UnionOrIntersectionTypeNode extends TypeNode { + kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType; types: NodeArray; } interface UnionTypeNode extends UnionOrIntersectionTypeNode { + kind: SyntaxKind.UnionType; } interface IntersectionTypeNode extends UnionOrIntersectionTypeNode { + kind: SyntaxKind.IntersectionType; } interface ParenthesizedTypeNode extends TypeNode { + kind: SyntaxKind.ParenthesizedType; type: TypeNode; } interface LiteralTypeNode extends TypeNode { - _stringLiteralTypeBrand: any; + kind: SyntaxKind.LiteralType; literal: Expression; } interface StringLiteral extends LiteralExpression { - _stringLiteralBrand: any; + kind: SyntaxKind.StringLiteral; } interface Expression extends Node { _expressionBrand: any; contextualType?: Type; } interface OmittedExpression extends Expression { - _omittedExpressionBrand: any; + kind: SyntaxKind.OmittedExpression; } interface UnaryExpression extends Expression { _unaryExpressionBrand: any; @@ -651,13 +696,17 @@ declare namespace ts { interface IncrementExpression extends UnaryExpression { _incrementExpressionBrand: any; } + type PrefixUnaryOperator = SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.TildeToken | SyntaxKind.ExclamationToken; interface PrefixUnaryExpression extends IncrementExpression { - operator: SyntaxKind; + kind: SyntaxKind.PrefixUnaryExpression; + operator: PrefixUnaryOperator; operand: UnaryExpression; } + type PostfixUnaryOperator = SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken; interface PostfixUnaryExpression extends IncrementExpression { + kind: SyntaxKind.PostfixUnaryExpression; operand: LeftHandSideExpression; - operator: SyntaxKind; + operator: PostfixUnaryOperator; } interface PostfixExpression extends UnaryExpression { _postfixExpressionBrand: any; @@ -671,42 +720,83 @@ declare namespace ts { interface PrimaryExpression extends MemberExpression { _primaryExpressionBrand: any; } + interface NullLiteral extends PrimaryExpression { + kind: SyntaxKind.NullKeyword; + } + interface BooleanLiteral extends PrimaryExpression { + kind: SyntaxKind.TrueKeyword | SyntaxKind.FalseKeyword; + } + interface ThisExpression extends PrimaryExpression { + kind: SyntaxKind.ThisKeyword; + } + interface SuperExpression extends PrimaryExpression { + kind: SyntaxKind.SuperKeyword; + } interface DeleteExpression extends UnaryExpression { + kind: SyntaxKind.DeleteExpression; expression: UnaryExpression; } interface TypeOfExpression extends UnaryExpression { + kind: SyntaxKind.TypeOfExpression; expression: UnaryExpression; } interface VoidExpression extends UnaryExpression { + kind: SyntaxKind.VoidExpression; expression: UnaryExpression; } interface AwaitExpression extends UnaryExpression { + kind: SyntaxKind.AwaitExpression; expression: UnaryExpression; } interface YieldExpression extends Expression { - asteriskToken?: Node; + kind: SyntaxKind.YieldExpression; + asteriskToken?: AsteriskToken; expression?: Expression; } + type ExponentiationOperator = SyntaxKind.AsteriskAsteriskToken; + type MultiplicativeOperator = SyntaxKind.AsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken; + type MultiplicativeOperatorOrHigher = ExponentiationOperator | MultiplicativeOperator; + type AdditiveOperator = SyntaxKind.PlusToken | SyntaxKind.MinusToken; + type AdditiveOperatorOrHigher = MultiplicativeOperatorOrHigher | AdditiveOperator; + type ShiftOperator = SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken; + type ShiftOperatorOrHigher = AdditiveOperatorOrHigher | ShiftOperator; + type RelationalOperator = SyntaxKind.LessThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.InstanceOfKeyword | SyntaxKind.InKeyword; + type RelationalOperatorOrHigher = ShiftOperatorOrHigher | RelationalOperator; + type EqualityOperator = SyntaxKind.EqualsEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.ExclamationEqualsToken; + type EqualityOperatorOrHigher = RelationalOperatorOrHigher | EqualityOperator; + type BitwiseOperator = SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken; + type BitwiseOperatorOrHigher = EqualityOperatorOrHigher | BitwiseOperator; + type LogicalOperator = SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken; + type LogicalOperatorOrHigher = BitwiseOperatorOrHigher | LogicalOperator; + type CompoundAssignmentOperator = SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken; + type AssignmentOperator = SyntaxKind.EqualsToken | CompoundAssignmentOperator; + type AssignmentOperatorOrHigher = LogicalOperatorOrHigher | AssignmentOperator; + type BinaryOperator = AssignmentOperatorOrHigher | SyntaxKind.CommaToken; + type BinaryOperatorToken = Token; interface BinaryExpression extends Expression, Declaration { + kind: SyntaxKind.BinaryExpression; left: Expression; - operatorToken: Node; + operatorToken: BinaryOperatorToken; right: Expression; } interface ConditionalExpression extends Expression { + kind: SyntaxKind.ConditionalExpression; condition: Expression; - questionToken: Node; + questionToken: QuestionToken; whenTrue: Expression; - colonToken: Node; + colonToken: ColonToken; whenFalse: Expression; } type FunctionBody = Block; type ConciseBody = FunctionBody | Expression; interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclaration { + kind: SyntaxKind.FunctionExpression; name?: Identifier; body: FunctionBody; } interface ArrowFunction extends Expression, FunctionLikeDeclaration { - equalsGreaterThanToken: Node; + kind: SyntaxKind.ArrowFunction; + equalsGreaterThanToken: EqualsGreaterThanToken; body: ConciseBody; } interface LiteralLikeNode extends Node { @@ -717,29 +807,46 @@ declare namespace ts { interface LiteralExpression extends LiteralLikeNode, PrimaryExpression { _literalExpressionBrand: any; } + interface RegularExpressionLiteral extends LiteralExpression { + kind: SyntaxKind.RegularExpressionLiteral; + } + interface NoSubstitutionTemplateLiteral extends LiteralExpression { + kind: SyntaxKind.NoSubstitutionTemplateLiteral; + } interface NumericLiteral extends LiteralExpression { - _numericLiteralBrand: any; + kind: SyntaxKind.NumericLiteral; trailingComment?: string; } - interface TemplateLiteralFragment extends LiteralLikeNode { - _templateLiteralFragmentBrand: any; + interface TemplateHead extends LiteralLikeNode { + kind: SyntaxKind.TemplateHead; } - type Template = TemplateExpression | LiteralExpression; + interface TemplateMiddle extends LiteralLikeNode { + kind: SyntaxKind.TemplateMiddle; + } + interface TemplateTail extends LiteralLikeNode { + kind: SyntaxKind.TemplateTail; + } + type TemplateLiteral = TemplateExpression | NoSubstitutionTemplateLiteral; interface TemplateExpression extends PrimaryExpression { - head: TemplateLiteralFragment; + kind: SyntaxKind.TemplateExpression; + head: TemplateHead; templateSpans: NodeArray; } interface TemplateSpan extends Node { + kind: SyntaxKind.TemplateSpan; expression: Expression; - literal: TemplateLiteralFragment; + literal: TemplateMiddle | TemplateTail; } interface ParenthesizedExpression extends PrimaryExpression { + kind: SyntaxKind.ParenthesizedExpression; expression: Expression; } interface ArrayLiteralExpression extends PrimaryExpression { + kind: SyntaxKind.ArrayLiteralExpression; elements: NodeArray; } interface SpreadElementExpression extends Expression { + kind: SyntaxKind.SpreadElementExpression; expression: Expression; } /** @@ -752,104 +859,141 @@ declare namespace ts { properties: NodeArray; } interface ObjectLiteralExpression extends ObjectLiteralExpressionBase { + kind: SyntaxKind.ObjectLiteralExpression; } type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression; type EntityNameOrEntityNameExpression = EntityName | EntityNameExpression; interface PropertyAccessExpression extends MemberExpression, Declaration { + kind: SyntaxKind.PropertyAccessExpression; expression: LeftHandSideExpression; name: Identifier; } + interface SuperPropertyAccessExpression extends PropertyAccessExpression { + expression: SuperExpression; + } /** Brand for a PropertyAccessExpression which, like a QualifiedName, consists of a sequence of identifiers separated by dots. */ interface PropertyAccessEntityNameExpression extends PropertyAccessExpression { _propertyAccessExpressionLikeQualifiedNameBrand?: any; expression: EntityNameExpression; } interface ElementAccessExpression extends MemberExpression { + kind: SyntaxKind.ElementAccessExpression; expression: LeftHandSideExpression; argumentExpression?: Expression; } + interface SuperElementAccessExpression extends ElementAccessExpression { + expression: SuperExpression; + } + type SuperProperty = SuperPropertyAccessExpression | SuperElementAccessExpression; interface CallExpression extends LeftHandSideExpression, Declaration { + kind: SyntaxKind.CallExpression; expression: LeftHandSideExpression; typeArguments?: NodeArray; arguments: NodeArray; } + interface SuperCall extends CallExpression { + expression: SuperExpression; + } interface ExpressionWithTypeArguments extends TypeNode { + kind: SyntaxKind.ExpressionWithTypeArguments; expression: LeftHandSideExpression; typeArguments?: NodeArray; } - interface NewExpression extends CallExpression, PrimaryExpression { + interface NewExpression extends PrimaryExpression, Declaration { + kind: SyntaxKind.NewExpression; + expression: LeftHandSideExpression; + typeArguments?: NodeArray; + arguments: NodeArray; } interface TaggedTemplateExpression extends MemberExpression { + kind: SyntaxKind.TaggedTemplateExpression; tag: LeftHandSideExpression; - template: Template; + template: TemplateLiteral; } type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator; interface AsExpression extends Expression { + kind: SyntaxKind.AsExpression; expression: Expression; type: TypeNode; } interface TypeAssertion extends UnaryExpression { + kind: SyntaxKind.TypeAssertionExpression; type: TypeNode; expression: UnaryExpression; } type AssertionExpression = TypeAssertion | AsExpression; interface NonNullExpression extends LeftHandSideExpression { + kind: SyntaxKind.NonNullExpression; expression: Expression; } interface JsxElement extends PrimaryExpression { + kind: SyntaxKind.JsxElement; openingElement: JsxOpeningElement; children: NodeArray; closingElement: JsxClosingElement; } type JsxTagNameExpression = PrimaryExpression | PropertyAccessExpression; interface JsxOpeningElement extends Expression { - _openingElementBrand?: any; + kind: SyntaxKind.JsxOpeningElement; tagName: JsxTagNameExpression; attributes: NodeArray; } - interface JsxSelfClosingElement extends PrimaryExpression, JsxOpeningElement { - _selfClosingElementBrand?: any; + interface JsxSelfClosingElement extends PrimaryExpression { + kind: SyntaxKind.JsxSelfClosingElement; + tagName: JsxTagNameExpression; + attributes: NodeArray; } type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; interface JsxAttribute extends Node { + kind: SyntaxKind.JsxAttribute; name: Identifier; initializer?: StringLiteral | JsxExpression; } interface JsxSpreadAttribute extends Node { + kind: SyntaxKind.JsxSpreadAttribute; expression: Expression; } interface JsxClosingElement extends Node { + kind: SyntaxKind.JsxClosingElement; tagName: JsxTagNameExpression; } interface JsxExpression extends Expression { + kind: SyntaxKind.JsxExpression; expression?: Expression; } interface JsxText extends Node { - _jsxTextExpressionBrand: any; + kind: SyntaxKind.JsxText; } type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement; interface Statement extends Node { _statementBrand: any; } interface EmptyStatement extends Statement { + kind: SyntaxKind.EmptyStatement; } interface DebuggerStatement extends Statement { + kind: SyntaxKind.DebuggerStatement; } interface MissingDeclaration extends DeclarationStatement, ClassElement, ObjectLiteralElement, TypeElement { + kind: SyntaxKind.MissingDeclaration; name?: Identifier; } type BlockLike = SourceFile | Block | ModuleBlock | CaseClause; interface Block extends Statement { + kind: SyntaxKind.Block; statements: NodeArray; } interface VariableStatement extends Statement { + kind: SyntaxKind.VariableStatement; declarationList: VariableDeclarationList; } interface ExpressionStatement extends Statement { + kind: SyntaxKind.ExpressionStatement; expression: Expression; } interface IfStatement extends Statement { + kind: SyntaxKind.IfStatement; expression: Expression; thenStatement: Statement; elseStatement?: Statement; @@ -858,68 +1002,85 @@ declare namespace ts { statement: Statement; } interface DoStatement extends IterationStatement { + kind: SyntaxKind.DoStatement; expression: Expression; } interface WhileStatement extends IterationStatement { + kind: SyntaxKind.WhileStatement; expression: Expression; } type ForInitializer = VariableDeclarationList | Expression; interface ForStatement extends IterationStatement { + kind: SyntaxKind.ForStatement; initializer?: ForInitializer; condition?: Expression; incrementor?: Expression; } interface ForInStatement extends IterationStatement { + kind: SyntaxKind.ForInStatement; initializer: ForInitializer; expression: Expression; } interface ForOfStatement extends IterationStatement { + kind: SyntaxKind.ForOfStatement; initializer: ForInitializer; expression: Expression; } interface BreakStatement extends Statement { + kind: SyntaxKind.BreakStatement; label?: Identifier; } interface ContinueStatement extends Statement { + kind: SyntaxKind.ContinueStatement; label?: Identifier; } type BreakOrContinueStatement = BreakStatement | ContinueStatement; interface ReturnStatement extends Statement { + kind: SyntaxKind.ReturnStatement; expression?: Expression; } interface WithStatement extends Statement { + kind: SyntaxKind.WithStatement; expression: Expression; statement: Statement; } interface SwitchStatement extends Statement { + kind: SyntaxKind.SwitchStatement; expression: Expression; caseBlock: CaseBlock; possiblyExhaustive?: boolean; } interface CaseBlock extends Node { + kind: SyntaxKind.CaseBlock; clauses: NodeArray; } interface CaseClause extends Node { + kind: SyntaxKind.CaseClause; expression: Expression; statements: NodeArray; } interface DefaultClause extends Node { + kind: SyntaxKind.DefaultClause; statements: NodeArray; } type CaseOrDefaultClause = CaseClause | DefaultClause; interface LabeledStatement extends Statement { + kind: SyntaxKind.LabeledStatement; label: Identifier; statement: Statement; } interface ThrowStatement extends Statement { + kind: SyntaxKind.ThrowStatement; expression: Expression; } interface TryStatement extends Statement { + kind: SyntaxKind.TryStatement; tryBlock: Block; catchClause?: CatchClause; finallyBlock?: Block; } interface CatchClause extends Node { + kind: SyntaxKind.CatchClause; variableDeclaration: VariableDeclaration; block: Block; } @@ -931,9 +1092,11 @@ declare namespace ts { members: NodeArray; } interface ClassDeclaration extends ClassLikeDeclaration, DeclarationStatement { + kind: SyntaxKind.ClassDeclaration; name?: Identifier; } interface ClassExpression extends ClassLikeDeclaration, PrimaryExpression { + kind: SyntaxKind.ClassExpression; } interface ClassElement extends Declaration { _classElementBrand: any; @@ -942,85 +1105,108 @@ declare namespace ts { interface TypeElement extends Declaration { _typeElementBrand: any; name?: PropertyName; - questionToken?: Node; + questionToken?: QuestionToken; } interface InterfaceDeclaration extends DeclarationStatement { + kind: SyntaxKind.InterfaceDeclaration; name: Identifier; typeParameters?: NodeArray; heritageClauses?: NodeArray; members: NodeArray; } interface HeritageClause extends Node { + kind: SyntaxKind.HeritageClause; token: SyntaxKind; types?: NodeArray; } interface TypeAliasDeclaration extends DeclarationStatement { + kind: SyntaxKind.TypeAliasDeclaration; name: Identifier; typeParameters?: NodeArray; type: TypeNode; } interface EnumMember extends Declaration { + kind: SyntaxKind.EnumMember; name: PropertyName; initializer?: Expression; } interface EnumDeclaration extends DeclarationStatement { + kind: SyntaxKind.EnumDeclaration; name: Identifier; members: NodeArray; } type ModuleBody = ModuleBlock | ModuleDeclaration; type ModuleName = Identifier | StringLiteral; interface ModuleDeclaration extends DeclarationStatement { + kind: SyntaxKind.ModuleDeclaration; name: Identifier | LiteralExpression; - body?: ModuleBlock | ModuleDeclaration; + body?: ModuleBlock | NamespaceDeclaration; + } + interface NamespaceDeclaration extends ModuleDeclaration { + name: Identifier; + body: ModuleBlock | NamespaceDeclaration; } interface ModuleBlock extends Node, Statement { + kind: SyntaxKind.ModuleBlock; statements: NodeArray; } type ModuleReference = EntityName | ExternalModuleReference; interface ImportEqualsDeclaration extends DeclarationStatement { + kind: SyntaxKind.ImportEqualsDeclaration; name: Identifier; moduleReference: ModuleReference; } interface ExternalModuleReference extends Node { + kind: SyntaxKind.ExternalModuleReference; expression?: Expression; } interface ImportDeclaration extends Statement { + kind: SyntaxKind.ImportDeclaration; importClause?: ImportClause; moduleSpecifier: Expression; } type NamedImportBindings = NamespaceImport | NamedImports; interface ImportClause extends Declaration { + kind: SyntaxKind.ImportClause; name?: Identifier; namedBindings?: NamedImportBindings; } interface NamespaceImport extends Declaration { + kind: SyntaxKind.NamespaceImport; name: Identifier; } interface NamespaceExportDeclaration extends DeclarationStatement { + kind: SyntaxKind.NamespaceExportDeclaration; name: Identifier; moduleReference: LiteralLikeNode; } interface ExportDeclaration extends DeclarationStatement { + kind: SyntaxKind.ExportDeclaration; exportClause?: NamedExports; moduleSpecifier?: Expression; } interface NamedImports extends Node { + kind: SyntaxKind.NamedImports; elements: NodeArray; } interface NamedExports extends Node { + kind: SyntaxKind.NamedExports; elements: NodeArray; } type NamedImportsOrExports = NamedImports | NamedExports; interface ImportSpecifier extends Declaration { + kind: SyntaxKind.ImportSpecifier; propertyName?: Identifier; name: Identifier; } interface ExportSpecifier extends Declaration { + kind: SyntaxKind.ExportSpecifier; propertyName?: Identifier; name: Identifier; } type ImportOrExportSpecifier = ImportSpecifier | ExportSpecifier; interface ExportAssignment extends DeclarationStatement { + kind: SyntaxKind.ExportAssignment; isExportEquals?: boolean; expression: Expression; } @@ -1032,95 +1218,121 @@ declare namespace ts { kind: SyntaxKind; } interface JSDocTypeExpression extends Node { + kind: SyntaxKind.JSDocTypeExpression; type: JSDocType; } interface JSDocType extends TypeNode { _jsDocTypeBrand: any; } interface JSDocAllType extends JSDocType { - _JSDocAllTypeBrand: any; + kind: SyntaxKind.JSDocAllType; } interface JSDocUnknownType extends JSDocType { - _JSDocUnknownTypeBrand: any; + kind: SyntaxKind.JSDocUnknownType; } interface JSDocArrayType extends JSDocType { + kind: SyntaxKind.JSDocArrayType; elementType: JSDocType; } interface JSDocUnionType extends JSDocType { + kind: SyntaxKind.JSDocUnionType; types: NodeArray; } interface JSDocTupleType extends JSDocType { + kind: SyntaxKind.JSDocTupleType; types: NodeArray; } interface JSDocNonNullableType extends JSDocType { + kind: SyntaxKind.JSDocNonNullableType; type: JSDocType; } interface JSDocNullableType extends JSDocType { + kind: SyntaxKind.JSDocNullableType; type: JSDocType; } - interface JSDocRecordType extends JSDocType, TypeLiteralNode { + interface JSDocRecordType extends JSDocType { + kind: SyntaxKind.JSDocRecordType; literal: TypeLiteralNode; } interface JSDocTypeReference extends JSDocType { + kind: SyntaxKind.JSDocTypeReference; name: EntityName; typeArguments: NodeArray; } interface JSDocOptionalType extends JSDocType { + kind: SyntaxKind.JSDocOptionalType; type: JSDocType; } interface JSDocFunctionType extends JSDocType, SignatureDeclaration { + kind: SyntaxKind.JSDocFunctionType; parameters: NodeArray; type: JSDocType; } interface JSDocVariadicType extends JSDocType { + kind: SyntaxKind.JSDocVariadicType; type: JSDocType; } interface JSDocConstructorType extends JSDocType { + kind: SyntaxKind.JSDocConstructorType; type: JSDocType; } interface JSDocThisType extends JSDocType { + kind: SyntaxKind.JSDocThisType; type: JSDocType; } interface JSDocLiteralType extends JSDocType { + kind: SyntaxKind.JSDocLiteralType; literal: LiteralTypeNode; } type JSDocTypeReferencingNode = JSDocThisType | JSDocConstructorType | JSDocVariadicType | JSDocOptionalType | JSDocNullableType | JSDocNonNullableType; interface JSDocRecordMember extends PropertySignature { + kind: SyntaxKind.JSDocRecordMember; name: Identifier | LiteralExpression; type?: JSDocType; } interface JSDoc extends Node { + kind: SyntaxKind.JSDocComment; tags: NodeArray | undefined; comment: string | undefined; } interface JSDocTag extends Node { - atToken: Node; + atToken: AtToken; tagName: Identifier; comment: string | undefined; } + interface JSDocUnknownTag extends JSDocTag { + kind: SyntaxKind.JSDocTag; + } interface JSDocTemplateTag extends JSDocTag { + kind: SyntaxKind.JSDocTemplateTag; typeParameters: NodeArray; } interface JSDocReturnTag extends JSDocTag { + kind: SyntaxKind.JSDocReturnTag; typeExpression: JSDocTypeExpression; } interface JSDocTypeTag extends JSDocTag { + kind: SyntaxKind.JSDocTypeTag; typeExpression: JSDocTypeExpression; } interface JSDocTypedefTag extends JSDocTag, Declaration { + kind: SyntaxKind.JSDocTypedefTag; name?: Identifier; typeExpression?: JSDocTypeExpression; jsDocTypeLiteral?: JSDocTypeLiteral; } interface JSDocPropertyTag extends JSDocTag, TypeElement { + kind: SyntaxKind.JSDocPropertyTag; name: Identifier; typeExpression: JSDocTypeExpression; } interface JSDocTypeLiteral extends JSDocType { + kind: SyntaxKind.JSDocTypeLiteral; jsDocPropertyTags?: NodeArray; jsDocTypeTag?: JSDocTypeTag; } interface JSDocParameterTag extends JSDocTag { + kind: SyntaxKind.JSDocParameterTag; /** the parameter name, if provided *before* the type (TypeScript-style) */ preParameterName?: Identifier; typeExpression?: JSDocTypeExpression; @@ -1149,7 +1361,7 @@ declare namespace ts { id?: number; } interface FlowStart extends FlowNode { - container?: FunctionExpression | ArrowFunction; + container?: FunctionExpression | ArrowFunction | MethodDeclaration; } interface FlowLabel extends FlowNode { antecedents: FlowNode[]; @@ -1178,8 +1390,9 @@ declare namespace ts { name: string; } interface SourceFile extends Declaration { + kind: SyntaxKind.SourceFile; statements: NodeArray; - endOfFileToken: Node; + endOfFileToken: Token; fileName: string; path: Path; text: string; @@ -1245,7 +1458,7 @@ declare namespace ts { * used for writing the JavaScript and declaration files. Otherwise, the writeFile parameter * will be invoked when writing the JavaScript and declaration files. */ - emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken): EmitResult; + emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean): EmitResult; getOptionsDiagnostics(cancellationToken?: CancellationToken): Diagnostic[]; getGlobalDiagnostics(cancellationToken?: CancellationToken): Diagnostic[]; getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; @@ -1372,6 +1585,7 @@ declare namespace ts { UseFullyQualifiedType = 128, InFirstTypeArgument = 256, InTypeAlias = 512, + UseTypeAliasValue = 1024, } enum SymbolFormatFlags { None = 0, @@ -1387,9 +1601,10 @@ declare namespace ts { type: Type; } interface ThisTypePredicate extends TypePredicateBase { - _thisTypePredicateBrand: any; + kind: TypePredicateKind.This; } interface IdentifierTypePredicate extends TypePredicateBase { + kind: TypePredicateKind.Identifier; parameterName: string; parameterIndex: number; } @@ -1495,8 +1710,6 @@ declare namespace ts { Intersection = 1048576, Anonymous = 2097152, Instantiated = 4194304, - ThisType = 268435456, - ObjectLiteralPatternWithComputedProperties = 536870912, Literal = 480, StringOrNumberLiteral = 96, PossiblyFalsy = 7406, @@ -1509,7 +1722,7 @@ declare namespace ts { StructuredType = 4161536, StructuredOrTypeParameter = 4177920, Narrowable = 4178943, - NotUnionOrUnit = 2589191, + NotUnionOrUnit = 2589185, } type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; interface Type { @@ -1531,6 +1744,7 @@ declare namespace ts { baseType: EnumType & UnionType; } interface ObjectType extends Type { + isObjectLiteralPatternWithComputedProperties?: boolean; } interface InterfaceType extends ObjectType { typeParameters: TypeParameter[]; @@ -1614,15 +1828,13 @@ declare namespace ts { Classic = 1, NodeJs = 2, } - type RootPaths = string[]; - type PathSubstitutions = MapLike; - type TsConfigOnlyOptions = RootPaths | PathSubstitutions; - type CompilerOptionsValue = string | number | boolean | (string | number)[] | TsConfigOnlyOptions; + type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike; interface CompilerOptions { allowJs?: boolean; allowSyntheticDefaultImports?: boolean; allowUnreachableCode?: boolean; allowUnusedLabels?: boolean; + alwaysStrict?: boolean; baseUrl?: string; charset?: string; declaration?: boolean; @@ -1660,13 +1872,13 @@ declare namespace ts { out?: string; outDir?: string; outFile?: string; - paths?: PathSubstitutions; + paths?: MapLike; preserveConstEnums?: boolean; project?: string; reactNamespace?: string; removeComments?: boolean; rootDir?: string; - rootDirs?: RootPaths; + rootDirs?: string[]; skipLibCheck?: boolean; skipDefaultLibCheck?: boolean; sourceMap?: boolean; @@ -1742,6 +1954,7 @@ declare namespace ts { raw?: any; errors: Diagnostic[]; wildcardDirectories?: MapLike; + compileOnSave?: boolean; } enum WatchDirectoryFlags { None = 0, @@ -1846,7 +2059,7 @@ declare namespace ts { directoryName: string; referenceCount: number; } - var sys: System; + let sys: System; } declare namespace ts { interface ErrorCallback { @@ -1944,10 +2157,6 @@ declare namespace ts { function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; } declare namespace ts { - /** The version of the TypeScript compiler release */ - const version = "2.1.0"; - function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName?: string): string; - function resolveTripleslashReference(moduleName: string, containingFile: string): string; function getEffectiveTypeRoots(options: CompilerOptions, host: { directoryExists?: (directoryName: string) => boolean; getCurrentDirectory?: () => string; @@ -1958,18 +2167,6 @@ declare namespace ts { * is assumed to be the same as root directory of the project. */ function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string, options: CompilerOptions, host: ModuleResolutionHost): ResolvedTypeReferenceDirectiveWithFailedLookupLocations; - function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; - function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; - function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; - function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; - function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; - interface FormatDiagnosticsHost { - getCurrentDirectory(): string; - getCanonicalFileName(fileName: string): string; - getNewLine(): string; - } - function formatDiagnostics(diagnostics: Diagnostic[], host: FormatDiagnosticsHost): string; - function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string; /** * Given a set of options, returns the set of type directive names * that should be included for this program automatically. @@ -1979,6 +2176,24 @@ declare namespace ts { * this list is only the set of defaults that are implicitly included. */ function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[]; + function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; + function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; + function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; +} +declare namespace ts { + /** The version of the TypeScript compiler release */ + const version = "2.1.0"; + function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName?: string): string; + function resolveTripleslashReference(moduleName: string, containingFile: string): string; + function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; + function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; + interface FormatDiagnosticsHost { + getCurrentDirectory(): string; + getCanonicalFileName(fileName: string): string; + getNewLine(): string; + } + function formatDiagnostics(diagnostics: Diagnostic[], host: FormatDiagnosticsHost): string; + function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string; function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program; } declare namespace ts { @@ -1995,7 +2210,7 @@ declare namespace ts { * @param fileName The path to the config file * @param jsonText The text of the config file */ - function parseConfigFileTextToJson(fileName: string, jsonText: string): { + function parseConfigFileTextToJson(fileName: string, jsonText: string, stripComments?: boolean): { config?: any; error?: Diagnostic; }; @@ -2007,12 +2222,13 @@ declare namespace ts { * file to. e.g. outDir */ function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[]): ParsedCommandLine; + function convertCompileOnSaveOptionFromJson(jsonOption: any, basePath: string, errors: Diagnostic[]): boolean; function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: CompilerOptions; errors: Diagnostic[]; }; function convertTypingOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { - options: CompilerOptions; + options: TypingOptions; errors: Diagnostic[]; }; } @@ -2118,6 +2334,7 @@ declare namespace ts { readDirectory?(path: string, extensions?: string[], exclude?: string[], include?: string[]): string[]; readFile?(path: string, encoding?: string): string; fileExists?(path: string): boolean; + getTypeRootsVersion?(): number; resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[]; resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; directoryExists?(directoryName: string): boolean; @@ -2155,18 +2372,20 @@ declare namespace ts { getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[]; /** @deprecated */ getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[]; - getNavigateToItems(searchValue: string, maxResultCount?: number, fileName?: string): NavigateToItem[]; + getNavigateToItems(searchValue: string, maxResultCount?: number, fileName?: string, excludeDtsFiles?: boolean): NavigateToItem[]; getNavigationBarItems(fileName: string): NavigationBarItem[]; + getNavigationTree(fileName: string): NavigationTree; getOutliningSpans(fileName: string): OutliningSpan[]; getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[]; getBraceMatchingAtPosition(fileName: string, position: number): TextSpan[]; - getIndentationAtPosition(fileName: string, position: number, options: EditorOptions): number; - getFormattingEditsForRange(fileName: string, start: number, end: number, options: FormatCodeOptions): TextChange[]; - getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions): TextChange[]; - getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): TextChange[]; + getIndentationAtPosition(fileName: string, position: number, options: EditorOptions | EditorSettings): number; + getFormattingEditsForRange(fileName: string, start: number, end: number, options: FormatCodeOptions | FormatCodeSettings): TextChange[]; + getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions | FormatCodeSettings): TextChange[]; + getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions | FormatCodeSettings): TextChange[]; getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion; isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean; - getEmitOutput(fileName: string): EmitOutput; + getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[]): CodeAction[]; + getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean): EmitOutput; getProgram(): Program; dispose(): void; } @@ -2178,6 +2397,12 @@ declare namespace ts { textSpan: TextSpan; classificationType: string; } + /** + * Navigation bar interface designed for visual studio's dual-column layout. + * This does not form a proper tree. + * The navbar is returned as a list of top-level items, each of which has a list of child items. + * Child items always have an empty array for their `childItems`. + */ interface NavigationBarItem { text: string; kind: string; @@ -2188,6 +2413,25 @@ declare namespace ts { bolded: boolean; grayed: boolean; } + /** + * Node in a tree of nested declarations in a file. + * The top node is always a script or module node. + */ + interface NavigationTree { + /** Name of the declaration, or a short description, e.g. "". */ + text: string; + /** A ScriptElementKind */ + kind: string; + /** ScriptElementKindModifier separated by commas, e.g. "public,abstract" */ + kindModifiers: string; + /** + * Spans of the nodes that generated this declaration. + * There will be more than one if this is the result of merging. + */ + spans: TextSpan[]; + /** Present if non-empty */ + childItems?: NavigationTree[]; + } interface TodoCommentDescriptor { text: string; priority: number; @@ -2201,6 +2445,16 @@ declare namespace ts { span: TextSpan; newText: string; } + interface FileTextChanges { + fileName: string; + textChanges: TextChange[]; + } + interface CodeAction { + /** Description of the code action to display in the UI of the editor */ + description: string; + /** Text changes to apply to each file as part of the code action */ + changes: FileTextChanges[]; + } interface TextInsertion { newText: string; /** The position in newText the caret should point to after the insertion. */ @@ -2246,6 +2500,11 @@ declare namespace ts { containerName: string; containerKind: string; } + enum IndentStyle { + None = 0, + Block = 1, + Smart = 2, + } interface EditorOptions { BaseIndentSize?: number; IndentSize: number; @@ -2254,10 +2513,13 @@ declare namespace ts { ConvertTabsToSpaces: boolean; IndentStyle: IndentStyle; } - enum IndentStyle { - None = 0, - Block = 1, - Smart = 2, + interface EditorSettings { + baseIndentSize?: number; + indentSize?: number; + tabSize?: number; + newLineCharacter?: string; + convertTabsToSpaces?: boolean; + indentStyle?: IndentStyle; } interface FormatCodeOptions extends EditorOptions { InsertSpaceAfterCommaDelimiter: boolean; @@ -2273,7 +2535,21 @@ declare namespace ts { InsertSpaceAfterTypeAssertion?: boolean; PlaceOpenBraceOnNewLineForFunctions: boolean; PlaceOpenBraceOnNewLineForControlBlocks: boolean; - [s: string]: boolean | number | string | undefined; + } + interface FormatCodeSettings extends EditorSettings { + insertSpaceAfterCommaDelimiter?: boolean; + insertSpaceAfterSemicolonInForStatements?: boolean; + insertSpaceBeforeAndAfterBinaryOperators?: boolean; + insertSpaceAfterKeywordsInControlFlowStatements?: boolean; + insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; + insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; + insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean; + insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces?: boolean; + insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; + insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; + insertSpaceAfterTypeAssertion?: boolean; + placeOpenBraceOnNewLineForFunctions?: boolean; + placeOpenBraceOnNewLineForControlBlocks?: boolean; } interface DefinitionInfo { fileName: string; @@ -2366,7 +2642,11 @@ declare namespace ts { argumentCount: number; } interface CompletionInfo { + isGlobalCompletion: boolean; isMemberCompletion: boolean; + /** + * true when the current location also allows for a new identifier + */ isNewIdentifierLocation: boolean; entries: CompletionEntry[]; } @@ -2687,8 +2967,10 @@ declare namespace ts { interface DisplayPartsSymbolWriter extends SymbolWriter { displayParts(): SymbolDisplayPart[]; } + function toEditorSettings(options: EditorOptions | EditorSettings): EditorSettings; function displayPartsToString(displayParts: SymbolDisplayPart[]): string; function getDefaultCompilerOptions(): CompilerOptions; + function getSupportedCodeFixes(): string[]; function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean, scriptKind?: ScriptKind): SourceFile; let disableIncrementalParsing: boolean; function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; diff --git a/lib/typescript.js b/lib/typescript.js index 14fbdce59a8..c534a725901 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -502,6 +502,7 @@ var ts; TypeFormatFlags[TypeFormatFlags["UseFullyQualifiedType"] = 128] = "UseFullyQualifiedType"; TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 256] = "InFirstTypeArgument"; TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 512] = "InTypeAlias"; + TypeFormatFlags[TypeFormatFlags["UseTypeAliasValue"] = 1024] = "UseTypeAliasValue"; })(ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); var TypeFormatFlags = ts.TypeFormatFlags; (function (SymbolFormatFlags) { @@ -685,8 +686,6 @@ var ts; TypeFlags[TypeFlags["ContainsObjectLiteral"] = 67108864] = "ContainsObjectLiteral"; /* @internal */ TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 134217728] = "ContainsAnyFunctionType"; - TypeFlags[TypeFlags["ThisType"] = 268435456] = "ThisType"; - TypeFlags[TypeFlags["ObjectLiteralPatternWithComputedProperties"] = 536870912] = "ObjectLiteralPatternWithComputedProperties"; /* @internal */ TypeFlags[TypeFlags["Nullable"] = 6144] = "Nullable"; TypeFlags[TypeFlags["Literal"] = 480] = "Literal"; @@ -709,7 +708,7 @@ var ts; // 'Narrowable' types are types where narrowing actually narrows. // This *should* be every type other than null, undefined, void, and never TypeFlags[TypeFlags["Narrowable"] = 4178943] = "Narrowable"; - TypeFlags[TypeFlags["NotUnionOrUnit"] = 2589191] = "NotUnionOrUnit"; + TypeFlags[TypeFlags["NotUnionOrUnit"] = 2589185] = "NotUnionOrUnit"; /* @internal */ TypeFlags[TypeFlags["RequiresWidening"] = 100663296] = "RequiresWidening"; /* @internal */ @@ -993,36 +992,44 @@ var ts; })(ts.TransformFlags || (ts.TransformFlags = {})); var TransformFlags = ts.TransformFlags; /* @internal */ - (function (NodeEmitFlags) { - NodeEmitFlags[NodeEmitFlags["EmitEmitHelpers"] = 1] = "EmitEmitHelpers"; - NodeEmitFlags[NodeEmitFlags["EmitExportStar"] = 2] = "EmitExportStar"; - NodeEmitFlags[NodeEmitFlags["EmitSuperHelper"] = 4] = "EmitSuperHelper"; - NodeEmitFlags[NodeEmitFlags["EmitAdvancedSuperHelper"] = 8] = "EmitAdvancedSuperHelper"; - NodeEmitFlags[NodeEmitFlags["UMDDefine"] = 16] = "UMDDefine"; - NodeEmitFlags[NodeEmitFlags["SingleLine"] = 32] = "SingleLine"; - NodeEmitFlags[NodeEmitFlags["AdviseOnEmitNode"] = 64] = "AdviseOnEmitNode"; - NodeEmitFlags[NodeEmitFlags["NoSubstitution"] = 128] = "NoSubstitution"; - NodeEmitFlags[NodeEmitFlags["CapturesThis"] = 256] = "CapturesThis"; - NodeEmitFlags[NodeEmitFlags["NoLeadingSourceMap"] = 512] = "NoLeadingSourceMap"; - NodeEmitFlags[NodeEmitFlags["NoTrailingSourceMap"] = 1024] = "NoTrailingSourceMap"; - NodeEmitFlags[NodeEmitFlags["NoSourceMap"] = 1536] = "NoSourceMap"; - NodeEmitFlags[NodeEmitFlags["NoNestedSourceMaps"] = 2048] = "NoNestedSourceMaps"; - NodeEmitFlags[NodeEmitFlags["NoTokenLeadingSourceMaps"] = 4096] = "NoTokenLeadingSourceMaps"; - NodeEmitFlags[NodeEmitFlags["NoTokenTrailingSourceMaps"] = 8192] = "NoTokenTrailingSourceMaps"; - NodeEmitFlags[NodeEmitFlags["NoTokenSourceMaps"] = 12288] = "NoTokenSourceMaps"; - NodeEmitFlags[NodeEmitFlags["NoLeadingComments"] = 16384] = "NoLeadingComments"; - NodeEmitFlags[NodeEmitFlags["NoTrailingComments"] = 32768] = "NoTrailingComments"; - NodeEmitFlags[NodeEmitFlags["NoComments"] = 49152] = "NoComments"; - NodeEmitFlags[NodeEmitFlags["NoNestedComments"] = 65536] = "NoNestedComments"; - NodeEmitFlags[NodeEmitFlags["ExportName"] = 131072] = "ExportName"; - NodeEmitFlags[NodeEmitFlags["LocalName"] = 262144] = "LocalName"; - NodeEmitFlags[NodeEmitFlags["Indented"] = 524288] = "Indented"; - NodeEmitFlags[NodeEmitFlags["NoIndentation"] = 1048576] = "NoIndentation"; - NodeEmitFlags[NodeEmitFlags["AsyncFunctionBody"] = 2097152] = "AsyncFunctionBody"; - NodeEmitFlags[NodeEmitFlags["ReuseTempVariableScope"] = 4194304] = "ReuseTempVariableScope"; - NodeEmitFlags[NodeEmitFlags["CustomPrologue"] = 8388608] = "CustomPrologue"; - })(ts.NodeEmitFlags || (ts.NodeEmitFlags = {})); - var NodeEmitFlags = ts.NodeEmitFlags; + (function (EmitFlags) { + EmitFlags[EmitFlags["EmitEmitHelpers"] = 1] = "EmitEmitHelpers"; + EmitFlags[EmitFlags["EmitExportStar"] = 2] = "EmitExportStar"; + EmitFlags[EmitFlags["EmitSuperHelper"] = 4] = "EmitSuperHelper"; + EmitFlags[EmitFlags["EmitAdvancedSuperHelper"] = 8] = "EmitAdvancedSuperHelper"; + EmitFlags[EmitFlags["UMDDefine"] = 16] = "UMDDefine"; + EmitFlags[EmitFlags["SingleLine"] = 32] = "SingleLine"; + EmitFlags[EmitFlags["AdviseOnEmitNode"] = 64] = "AdviseOnEmitNode"; + EmitFlags[EmitFlags["NoSubstitution"] = 128] = "NoSubstitution"; + EmitFlags[EmitFlags["CapturesThis"] = 256] = "CapturesThis"; + EmitFlags[EmitFlags["NoLeadingSourceMap"] = 512] = "NoLeadingSourceMap"; + EmitFlags[EmitFlags["NoTrailingSourceMap"] = 1024] = "NoTrailingSourceMap"; + EmitFlags[EmitFlags["NoSourceMap"] = 1536] = "NoSourceMap"; + EmitFlags[EmitFlags["NoNestedSourceMaps"] = 2048] = "NoNestedSourceMaps"; + EmitFlags[EmitFlags["NoTokenLeadingSourceMaps"] = 4096] = "NoTokenLeadingSourceMaps"; + EmitFlags[EmitFlags["NoTokenTrailingSourceMaps"] = 8192] = "NoTokenTrailingSourceMaps"; + EmitFlags[EmitFlags["NoTokenSourceMaps"] = 12288] = "NoTokenSourceMaps"; + EmitFlags[EmitFlags["NoLeadingComments"] = 16384] = "NoLeadingComments"; + EmitFlags[EmitFlags["NoTrailingComments"] = 32768] = "NoTrailingComments"; + EmitFlags[EmitFlags["NoComments"] = 49152] = "NoComments"; + EmitFlags[EmitFlags["NoNestedComments"] = 65536] = "NoNestedComments"; + EmitFlags[EmitFlags["ExportName"] = 131072] = "ExportName"; + EmitFlags[EmitFlags["LocalName"] = 262144] = "LocalName"; + EmitFlags[EmitFlags["Indented"] = 524288] = "Indented"; + EmitFlags[EmitFlags["NoIndentation"] = 1048576] = "NoIndentation"; + EmitFlags[EmitFlags["AsyncFunctionBody"] = 2097152] = "AsyncFunctionBody"; + EmitFlags[EmitFlags["ReuseTempVariableScope"] = 4194304] = "ReuseTempVariableScope"; + EmitFlags[EmitFlags["CustomPrologue"] = 8388608] = "CustomPrologue"; + })(ts.EmitFlags || (ts.EmitFlags = {})); + var EmitFlags = ts.EmitFlags; + /* @internal */ + (function (EmitContext) { + EmitContext[EmitContext["SourceFile"] = 0] = "SourceFile"; + EmitContext[EmitContext["Expression"] = 1] = "Expression"; + EmitContext[EmitContext["IdentifierName"] = 2] = "IdentifierName"; + EmitContext[EmitContext["Unspecified"] = 3] = "Unspecified"; + })(ts.EmitContext || (ts.EmitContext = {})); + var EmitContext = ts.EmitContext; })(ts || (ts = {})); /*@internal*/ var ts; @@ -1032,7 +1039,6 @@ var ts; })(ts || (ts = {})); /*@internal*/ /** Performance measurements for the compiler. */ -var ts; (function (ts) { var performance; (function (performance) { @@ -1164,6 +1170,7 @@ var ts; contains: contains, remove: remove, forEachValue: forEachValueInMap, + getKeys: getKeys, clear: clear }; function forEachValueInMap(f) { @@ -1171,6 +1178,13 @@ var ts; f(key, files[key]); } } + function getKeys() { + var keys = []; + for (var key in files) { + keys.push(key); + } + return keys; + } // path should already be well-formed so it does not need to be normalized function get(path) { return files[toKey(path)]; @@ -1501,6 +1515,7 @@ var ts; return array1.concat(array2); } ts.concatenate = concatenate; + // TODO: fixme (N^2) - add optional comparer so collection can be sorted before deduplication. function deduplicate(array, areEqual) { var result; if (array) { @@ -1604,16 +1619,22 @@ var ts; * @param array A sorted array whose first element must be no larger than number * @param number The value to be searched for in the array. */ - function binarySearch(array, value) { + function binarySearch(array, value, comparer) { + if (!array || array.length === 0) { + return -1; + } var low = 0; var high = array.length - 1; + comparer = comparer !== undefined + ? comparer + : function (v1, v2) { return (v1 < v2 ? -1 : (v1 > v2 ? 1 : 0)); }; while (low <= high) { var middle = low + ((high - low) >> 1); var midValue = array[middle]; - if (midValue === value) { + if (comparer(midValue, value) === 0) { return middle; } - else if (midValue > value) { + else if (comparer(midValue, value) > 0) { high = middle - 1; } else { @@ -1929,6 +1950,56 @@ var ts; }; } ts.memoize = memoize; + function chain(a, b, c, d, e) { + if (e) { + var args_2 = []; + for (var i = 0; i < arguments.length; i++) { + args_2[i] = arguments[i]; + } + return function (t) { return compose.apply(void 0, map(args_2, function (f) { return f(t); })); }; + } + else if (d) { + return function (t) { return compose(a(t), b(t), c(t), d(t)); }; + } + else if (c) { + return function (t) { return compose(a(t), b(t), c(t)); }; + } + else if (b) { + return function (t) { return compose(a(t), b(t)); }; + } + else if (a) { + return function (t) { return compose(a(t)); }; + } + else { + return function (t) { return function (u) { return u; }; }; + } + } + ts.chain = chain; + function compose(a, b, c, d, e) { + if (e) { + var args_3 = []; + for (var i = 0; i < arguments.length; i++) { + args_3[i] = arguments[i]; + } + return function (t) { return reduceLeft(args_3, function (u, f) { return f(u); }, t); }; + } + else if (d) { + return function (t) { return d(c(b(a(t)))); }; + } + else if (c) { + return function (t) { return c(b(a(t))); }; + } + else if (b) { + return function (t) { return b(a(t)); }; + } + else if (a) { + return function (t) { return a(t); }; + } + else { + return function (t) { return t; }; + } + } + ts.compose = compose; function formatStringFromArgs(text, args, baseIndex) { baseIndex = baseIndex || 0; return text.replace(/{(\d+)}/g, function (match, index) { return args[+index + baseIndex]; }); @@ -2096,7 +2167,9 @@ var ts; return path.replace(/\\/g, "/"); } ts.normalizeSlashes = normalizeSlashes; - // Returns length of path root (i.e. length of "/", "x:/", "//server/share/, file:///user/files") + /** + * Returns length of path root (i.e. length of "/", "x:/", "//server/share/, file:///user/files") + */ function getRootLength(path) { if (path.charCodeAt(0) === 47 /* slash */) { if (path.charCodeAt(1) !== 47 /* slash */) @@ -2129,6 +2202,11 @@ var ts; return 0; } ts.getRootLength = getRootLength; + /** + * Internally, we represent paths as strings with '/' as the directory separator. + * When we make system calls (eg: LanguageServiceHost.getDirectory()), + * we expect the host to correctly handle paths in our specified format. + */ ts.directorySeparator = "/"; var directorySeparatorCharCode = 47 /* slash */; function getNormalizedParts(normalizedSlashedPath, rootLength) { @@ -2178,10 +2256,49 @@ var ts; return path && !isRootedDiskPath(path) && path.indexOf("://") !== -1; } ts.isUrl = isUrl; + 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 /^\.\.?($|[\\/])/.test(moduleName); + } + ts.isExternalModuleNameRelative = isExternalModuleNameRelative; + function getEmitScriptTarget(compilerOptions) { + return compilerOptions.target || 0 /* ES3 */; + } + ts.getEmitScriptTarget = getEmitScriptTarget; + function getEmitModuleKind(compilerOptions) { + return typeof compilerOptions.module === "number" ? + compilerOptions.module : + getEmitScriptTarget(compilerOptions) === 2 /* ES6 */ ? ts.ModuleKind.ES6 : ts.ModuleKind.CommonJS; + } + ts.getEmitModuleKind = getEmitModuleKind; + /* @internal */ + function hasZeroOrOneAsteriskCharacter(str) { + var seenAsterisk = false; + for (var i = 0; i < str.length; i++) { + if (str.charCodeAt(i) === 42 /* asterisk */) { + if (!seenAsterisk) { + seenAsterisk = true; + } + else { + // have already seen asterisk + return false; + } + } + } + return true; + } + ts.hasZeroOrOneAsteriskCharacter = hasZeroOrOneAsteriskCharacter; function isRootedDiskPath(path) { return getRootLength(path) !== 0; } ts.isRootedDiskPath = isRootedDiskPath; + function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) { + return !isRootedDiskPath(absoluteOrRelativePath) + ? absoluteOrRelativePath + : getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); + } + ts.convertToRelativePath = convertToRelativePath; function normalizedPathComponents(path, rootLength) { var normalizedParts = getNormalizedParts(path, rootLength); return [path.substr(0, rootLength)].concat(normalizedParts); @@ -2625,6 +2742,14 @@ var ts; return options && options.allowJs ? allSupportedExtensions : ts.supportedTypeScriptExtensions; } ts.getSupportedExtensions = getSupportedExtensions; + function hasJavaScriptFileExtension(fileName) { + return forEach(ts.supportedJavascriptExtensions, function (extension) { return fileExtensionIs(fileName, extension); }); + } + ts.hasJavaScriptFileExtension = hasJavaScriptFileExtension; + function hasTypeScriptFileExtension(fileName) { + return forEach(ts.supportedTypeScriptExtensions, function (extension) { return fileExtensionIs(fileName, extension); }); + } + ts.hasTypeScriptFileExtension = hasTypeScriptFileExtension; function isSupportedSourceFileName(fileName, compilerOptions) { if (!fileName) { return false; @@ -2737,7 +2862,6 @@ var ts; this.transformFlags = 0 /* None */; this.parent = undefined; this.original = undefined; - this.transformId = 0; } ts.objectAllocator = { getNodeConstructor: function () { return Node; }, @@ -2757,9 +2881,9 @@ var ts; var AssertionLevel = ts.AssertionLevel; var Debug; (function (Debug) { - var currentAssertionLevel; + Debug.currentAssertionLevel = 0 /* None */; function shouldAssert(level) { - return getCurrentAssertionLevel() >= level; + return Debug.currentAssertionLevel >= level; } Debug.shouldAssert = shouldAssert; function assert(expression, message, verboseDebugInfo) { @@ -2777,30 +2901,7 @@ var ts; Debug.assert(/*expression*/ false, message); } Debug.fail = fail; - function getCurrentAssertionLevel() { - if (currentAssertionLevel !== undefined) { - return currentAssertionLevel; - } - if (ts.sys === undefined) { - return 0 /* None */; - } - var developmentMode = /^development$/i.test(getEnvironmentVariable("NODE_ENV")); - currentAssertionLevel = developmentMode - ? 1 /* Normal */ - : 0 /* None */; - return currentAssertionLevel; - } })(Debug = ts.Debug || (ts.Debug = {})); - function getEnvironmentVariable(name, host) { - if (host && host.getEnvironmentVariable) { - return host.getEnvironmentVariable(name); - } - if (ts.sys && ts.sys.getEnvironmentVariable) { - return ts.sys.getEnvironmentVariable(name); - } - return ""; - } - ts.getEnvironmentVariable = getEnvironmentVariable; /** Remove an item from an array, moving everything to its right one space left. */ function orderedRemoveItemAt(array, index) { // This seems to be faster than either `array.splice(i, 1)` or `array.copyWithin(i, i+ 1)`. @@ -2836,6 +2937,84 @@ var ts; : (function (fileName) { return fileName.toLowerCase(); }); } ts.createGetCanonicalFileName = createGetCanonicalFileName; + /** + * patternStrings contains both pattern strings (containing "*") and regular strings. + * Return an exact match if possible, or a pattern match, or undefined. + * (These are verified by verifyCompilerOptions to have 0 or 1 "*" characters.) + */ + /* @internal */ + function matchPatternOrExact(patternStrings, candidate) { + var patterns = []; + for (var _i = 0, patternStrings_1 = patternStrings; _i < patternStrings_1.length; _i++) { + var patternString = patternStrings_1[_i]; + var pattern = tryParsePattern(patternString); + if (pattern) { + patterns.push(pattern); + } + else if (patternString === candidate) { + // pattern was matched as is - no need to search further + return patternString; + } + } + return findBestPatternMatch(patterns, function (_) { return _; }, candidate); + } + ts.matchPatternOrExact = matchPatternOrExact; + /* @internal */ + function patternText(_a) { + var prefix = _a.prefix, suffix = _a.suffix; + return prefix + "*" + suffix; + } + ts.patternText = patternText; + /** + * Given that candidate matches pattern, returns the text matching the '*'. + * E.g.: matchedText(tryParsePattern("foo*baz"), "foobarbaz") === "bar" + */ + /* @internal */ + function matchedText(pattern, candidate) { + Debug.assert(isPatternMatch(pattern, candidate)); + return candidate.substr(pattern.prefix.length, candidate.length - pattern.suffix.length); + } + ts.matchedText = matchedText; + /** Return the object corresponding to the best pattern to match `candidate`. */ + /* @internal */ + function findBestPatternMatch(values, getPattern, candidate) { + var matchedValue = undefined; + // use length of prefix as betterness criteria + var longestMatchPrefixLength = -1; + for (var _i = 0, values_1 = values; _i < values_1.length; _i++) { + var v = values_1[_i]; + var pattern = getPattern(v); + if (isPatternMatch(pattern, candidate) && pattern.prefix.length > longestMatchPrefixLength) { + longestMatchPrefixLength = pattern.prefix.length; + matchedValue = v; + } + } + return matchedValue; + } + ts.findBestPatternMatch = findBestPatternMatch; + function isPatternMatch(_a, candidate) { + var prefix = _a.prefix, suffix = _a.suffix; + return candidate.length >= prefix.length + suffix.length && + startsWith(candidate, prefix) && + endsWith(candidate, suffix); + } + /* @internal */ + function tryParsePattern(pattern) { + // This should be verified outside of here and a proper error thrown. + Debug.assert(hasZeroOrOneAsteriskCharacter(pattern)); + var indexOfStar = pattern.indexOf("*"); + return indexOfStar === -1 ? undefined : { + prefix: pattern.substr(0, indexOfStar), + suffix: pattern.substr(indexOfStar + 1) + }; + } + ts.tryParsePattern = tryParsePattern; + function positionIsSynthesized(pos) { + // This is a fast way of testing the following conditions: + // pos === undefined || pos === null || isNaN(pos) || pos < 0; + return !(pos >= 0); + } + ts.positionIsSynthesized = positionIsSynthesized; })(ts || (ts = {})); /// var ts; @@ -3040,9 +3219,17 @@ var ts; function isNode4OrLater() { return parseInt(process.version.charAt(1)) >= 4; } + function isFileSystemCaseSensitive() { + // win32\win64 are case insensitive platforms + if (platform === "win32" || platform === "win64") { + return false; + } + // convert current file name to upper case / lower case and check if file exists + // (guards against cases when name is already all uppercase or lowercase) + return !fileExists(__filename.toUpperCase()) || !fileExists(__filename.toLowerCase()); + } var platform = _os.platform(); - // win32\win64 are case insensitive platforms, MacOS (darwin) by default is also case insensitive - var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin"; + var useCaseSensitiveFileNames = isFileSystemCaseSensitive(); function readFile(fileName, encoding) { if (!fileExists(fileName)) { return undefined; @@ -3182,6 +3369,9 @@ var ts; // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows // (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643) var options; + if (!directoryExists(directoryName)) { + return; + } if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) { options = { persistent: true, recursive: !!recursive }; } @@ -3299,21 +3489,46 @@ var ts; realpath: realpath }; } + function recursiveCreateDirectory(directoryPath, sys) { + var basePath = ts.getDirectoryPath(directoryPath); + var shouldCreateParent = directoryPath !== basePath && !sys.directoryExists(basePath); + if (shouldCreateParent) { + recursiveCreateDirectory(basePath, sys); + } + if (shouldCreateParent || !sys.directoryExists(directoryPath)) { + sys.createDirectory(directoryPath); + } + } + var sys; if (typeof ChakraHost !== "undefined") { - return getChakraSystem(); + sys = getChakraSystem(); } else if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { - return getWScriptSystem(); + sys = getWScriptSystem(); } else if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof require !== "undefined") { // process and process.nextTick checks if current environment is node-like // process.browser check excludes webpack and browserify - return getNodeSystem(); + sys = getNodeSystem(); } - else { - return undefined; // Unsupported host + if (sys) { + // patch writefile to create folder before writing the file + var originalWriteFile_1 = sys.writeFile; + sys.writeFile = function (path, data, writeBom) { + var directoryPath = ts.getDirectoryPath(ts.normalizeSlashes(path)); + if (directoryPath && !sys.directoryExists(directoryPath)) { + recursiveCreateDirectory(directoryPath, sys); + } + originalWriteFile_1.call(sys, path, data, writeBom); + }; } + return sys; })(); + if (ts.sys && ts.sys.getEnvironmentVariable) { + ts.Debug.currentAssertionLevel = /^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV")) + ? 1 /* Normal */ + : 0 /* None */; + } })(ts || (ts = {})); // /// @@ -3641,7 +3856,7 @@ var ts; The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2407, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_2407", message: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter." }, Setters_cannot_return_a_value: { code: 2408, category: ts.DiagnosticCategory.Error, key: "Setters_cannot_return_a_value_2408", message: "Setters cannot return a value." }, Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { code: 2409, category: ts.DiagnosticCategory.Error, key: "Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class_2409", message: "Return type of constructor signature must be assignable to the instance type of the class" }, - All_symbols_within_a_with_block_will_be_resolved_to_any: { code: 2410, category: ts.DiagnosticCategory.Error, key: "All_symbols_within_a_with_block_will_be_resolved_to_any_2410", message: "All symbols within a 'with' block will be resolved to 'any'." }, + The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any: { code: 2410, category: ts.DiagnosticCategory.Error, key: "The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any_2410", message: "The 'with' statement is not supported. All symbols in a 'with' block will have type 'any'." }, Property_0_of_type_1_is_not_assignable_to_string_index_type_2: { code: 2411, category: ts.DiagnosticCategory.Error, key: "Property_0_of_type_1_is_not_assignable_to_string_index_type_2_2411", message: "Property '{0}' of type '{1}' is not assignable to string index type '{2}'." }, Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2: { code: 2412, category: ts.DiagnosticCategory.Error, key: "Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2_2412", message: "Property '{0}' of type '{1}' is not assignable to numeric index type '{2}'." }, Numeric_index_type_0_is_not_assignable_to_string_index_type_1: { code: 2413, category: ts.DiagnosticCategory.Error, key: "Numeric_index_type_0_is_not_assignable_to_string_index_type_1_2413", message: "Numeric index type '{0}' is not assignable to string index type '{1}'." }, @@ -3802,7 +4017,7 @@ var ts; this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation: { code: 2683, category: ts.DiagnosticCategory.Error, key: "this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_2683", message: "'this' implicitly has type 'any' because it does not have a type annotation." }, The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1: { code: 2684, category: ts.DiagnosticCategory.Error, key: "The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1_2684", message: "The 'this' context of type '{0}' is not assignable to method's 'this' of type '{1}'." }, The_this_types_of_each_signature_are_incompatible: { code: 2685, category: ts.DiagnosticCategory.Error, key: "The_this_types_of_each_signature_are_incompatible_2685", message: "The 'this' types of each signature are incompatible." }, - Identifier_0_must_be_imported_from_a_module: { code: 2686, category: ts.DiagnosticCategory.Error, key: "Identifier_0_must_be_imported_from_a_module_2686", message: "Identifier '{0}' must be imported from a module" }, + _0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead: { code: 2686, category: ts.DiagnosticCategory.Error, key: "_0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead_2686", message: "'{0}' refers to a UMD global, but the current file is a module. Consider adding an import instead." }, All_declarations_of_0_must_have_identical_modifiers: { code: 2687, category: ts.DiagnosticCategory.Error, key: "All_declarations_of_0_must_have_identical_modifiers_2687", message: "All declarations of '{0}' must have identical modifiers." }, Cannot_find_type_definition_file_for_0: { code: 2688, category: ts.DiagnosticCategory.Error, key: "Cannot_find_type_definition_file_for_0_2688", message: "Cannot find type definition file for '{0}'." }, Cannot_extend_an_interface_0_Did_you_mean_implements: { code: 2689, category: ts.DiagnosticCategory.Error, key: "Cannot_extend_an_interface_0_Did_you_mean_implements_2689", message: "Cannot extend an interface '{0}'. Did you mean 'implements'?" }, @@ -4035,6 +4250,8 @@ var ts; No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0: { code: 6137, category: ts.DiagnosticCategory.Message, key: "No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0_6137", message: "No types specified in 'package.json' but 'allowJs' is set, so returning 'main' value of '{0}'" }, Property_0_is_declared_but_never_used: { code: 6138, category: ts.DiagnosticCategory.Error, key: "Property_0_is_declared_but_never_used_6138", message: "Property '{0}' is declared but never used." }, Import_emit_helpers_from_tslib: { code: 6139, category: ts.DiagnosticCategory.Message, key: "Import_emit_helpers_from_tslib_6139", message: "Import emit helpers from 'tslib'." }, + Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: { code: 6140, category: ts.DiagnosticCategory.Error, key: "Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using__6140", message: "Auto discovery for typings is enabled in project '{0}'. Running extra resolution pass for module '{1}' using cache location '{2}'." }, + Parse_in_strict_mode_and_emit_use_strict_for_each_source_file: { code: 6141, category: ts.DiagnosticCategory.Message, key: "Parse_in_strict_mode_and_emit_use_strict_for_each_source_file_6141", message: "Parse in strict mode and emit \"use strict\" for each source file" }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter_0_implicitly_has_an_1_type_7006", message: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member_0_implicitly_has_an_1_type_7008", message: "Member '{0}' implicitly has an '{1}' type." }, @@ -4059,6 +4276,7 @@ var ts; Binding_element_0_implicitly_has_an_1_type: { code: 7031, category: ts.DiagnosticCategory.Error, key: "Binding_element_0_implicitly_has_an_1_type_7031", message: "Binding element '{0}' implicitly has an '{1}' type." }, Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation: { code: 7032, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation_7032", message: "Property '{0}' implicitly has type 'any', because its set accessor lacks a parameter type annotation." }, Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation: { code: 7033, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation_7033", message: "Property '{0}' implicitly has type 'any', because its get accessor lacks a return type annotation." }, + Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined: { code: 7034, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined_7034", message: "Variable '{0}' implicitly has type 'any' in some locations where its type cannot be determined." }, You_cannot_rename_this_element: { code: 8000, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_this_element_8000", message: "You cannot rename this element." }, You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", message: "You cannot rename elements that are defined in the standard TypeScript library." }, import_can_only_be_used_in_a_ts_file: { code: 8002, category: ts.DiagnosticCategory.Error, key: "import_can_only_be_used_in_a_ts_file_8002", message: "'import ... =' can only be used in a .ts file." }, @@ -4088,7 +4306,14 @@ var ts; super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class: { code: 17009, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class_17009", message: "'super' must be called before accessing 'this' in the constructor of a derived class." }, Unknown_typing_option_0: { code: 17010, category: ts.DiagnosticCategory.Error, key: "Unknown_typing_option_0_17010", message: "Unknown typing option '{0}'." }, Circularity_detected_while_resolving_configuration_Colon_0: { code: 18000, category: ts.DiagnosticCategory.Error, key: "Circularity_detected_while_resolving_configuration_Colon_0_18000", message: "Circularity detected while resolving configuration: {0}" }, - The_path_in_an_extends_options_must_be_relative_or_rooted: { code: 18001, category: ts.DiagnosticCategory.Error, key: "The_path_in_an_extends_options_must_be_relative_or_rooted_18001", message: "The path in an 'extends' options must be relative or rooted." } + The_path_in_an_extends_options_must_be_relative_or_rooted: { code: 18001, category: ts.DiagnosticCategory.Error, key: "The_path_in_an_extends_options_must_be_relative_or_rooted_18001", message: "The path in an 'extends' options must be relative or rooted." }, + Add_missing_super_call: { code: 90001, category: ts.DiagnosticCategory.Message, key: "Add_missing_super_call_90001", message: "Add missing 'super()' call." }, + Make_super_call_the_first_statement_in_the_constructor: { code: 90002, category: ts.DiagnosticCategory.Message, key: "Make_super_call_the_first_statement_in_the_constructor_90002", message: "Make 'super()' call the first statement in the constructor." }, + Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'" }, + Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers" }, + Implement_interface_on_reference: { code: 90005, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_reference_90005", message: "Implement interface on reference" }, + Implement_interface_on_class: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_class_90006", message: "Implement interface on class" }, + Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" } }; })(ts || (ts = {})); /// @@ -5145,7 +5370,7 @@ var ts; return token = 69 /* Identifier */; } function scanBinaryOrOctalDigits(base) { - ts.Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8"); + ts.Debug.assert(base === 2 || base === 8, "Expected either base 2 or base 8"); var value = 0; // For counting number of digits; Valid binaryIntegerLiteral must have at least one binary digit following B or b. // Similarly valid octalIntegerLiteral must have at least one octal digit following o or O. @@ -6364,10 +6589,10 @@ var ts; return !!(ts.getCombinedNodeFlags(node) & 1 /* Let */); } ts.isLet = isLet; - function isSuperCallExpression(n) { + function isSuperCall(n) { return n.kind === 174 /* CallExpression */ && n.expression.kind === 95 /* SuperKeyword */; } - ts.isSuperCallExpression = isSuperCallExpression; + ts.isSuperCall = isSuperCall; function isPrologueDirective(node) { return node.kind === 202 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; } @@ -6636,6 +6861,12 @@ var ts; return node && node.kind === 147 /* MethodDeclaration */ && node.parent.kind === 171 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; + function isObjectLiteralOrClassExpressionMethod(node) { + return node.kind === 147 /* MethodDeclaration */ && + (node.parent.kind === 171 /* ObjectLiteralExpression */ || + node.parent.kind === 192 /* ClassExpression */); + } + ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { return predicate && predicate.kind === 1 /* Identifier */; } @@ -6723,11 +6954,11 @@ var ts; } ts.getThisContainer = getThisContainer; /** - * Given an super call\property node returns a closest node where either - * - super call\property is legal in the node and not legal in the parent node the node. + * Given an super call/property node, returns the closest node where + * - a super call/property access is legal in the node and not legal in the parent node the node. * i.e. super call is legal in constructor but not legal in the class body. - * - node is arrow function (so caller might need to call getSuperContainer in case it needs to climb higher) - * - super call\property is definitely illegal in the node (but might be legal in some subnode) + * - the container is an arrow function (so caller might need to call getSuperContainer again in case it needs to climb higher) + * - a super call/property is definitely illegal in the container (but might be legal in some subnode) * i.e. super property access is illegal in function declaration but can be legal in the statement list */ function getSuperContainer(node, stopOnFunctions) { @@ -6988,12 +7219,6 @@ var ts; return false; } ts.isPartOfExpression = isPartOfExpression; - 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 /^\.\.?($|[\\/])/.test(moduleName); - } - ts.isExternalModuleNameRelative = isExternalModuleNameRelative; function isInstantiatedModule(node, preserveConstEnums) { var moduleState = ts.getModuleInstanceState(node); return moduleState === 1 /* Instantiated */ || @@ -7655,16 +7880,10 @@ var ts; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { - return positionIsSynthesized(node.pos) - || positionIsSynthesized(node.end); + return ts.positionIsSynthesized(node.pos) + || ts.positionIsSynthesized(node.end); } ts.nodeIsSynthesized = nodeIsSynthesized; - function positionIsSynthesized(pos) { - // This is a fast way of testing the following conditions: - // pos === undefined || pos === null || isNaN(pos) || pos < 0; - return !(pos >= 0); - } - ts.positionIsSynthesized = positionIsSynthesized; function getOriginalNode(node) { if (node) { while (node.original !== undefined) { @@ -8125,24 +8344,12 @@ var ts; function getDeclarationEmitOutputFilePath(sourceFile, host) { var options = host.getCompilerOptions(); var outputDir = options.declarationDir || options.outDir; // Prefer declaration folder if specified - if (options.declaration) { - var path = outputDir - ? getSourceFilePathInNewDir(sourceFile, host, outputDir) - : sourceFile.fileName; - return ts.removeFileExtension(path) + ".d.ts"; - } + var path = outputDir + ? getSourceFilePathInNewDir(sourceFile, host, outputDir) + : sourceFile.fileName; + return ts.removeFileExtension(path) + ".d.ts"; } ts.getDeclarationEmitOutputFilePath = getDeclarationEmitOutputFilePath; - function getEmitScriptTarget(compilerOptions) { - return compilerOptions.target || 0 /* ES3 */; - } - ts.getEmitScriptTarget = getEmitScriptTarget; - function getEmitModuleKind(compilerOptions) { - return typeof compilerOptions.module === "number" ? - compilerOptions.module : - getEmitScriptTarget(compilerOptions) === 2 /* ES6 */ ? ts.ModuleKind.ES6 : ts.ModuleKind.CommonJS; - } - ts.getEmitModuleKind = getEmitModuleKind; /** * Gets the source files that are expected to have an emit output. * @@ -8155,7 +8362,7 @@ var ts; function getSourceFilesToEmit(host, targetSourceFile) { var options = host.getCompilerOptions(); if (options.outFile || options.out) { - var moduleKind = getEmitModuleKind(options); + var moduleKind = ts.getEmitModuleKind(options); var moduleEmitEnabled = moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System; var sourceFiles = host.getSourceFiles(); // Can emit only sources that are not declaration file and are either non module code or module with --module or --target es6 specified @@ -8184,7 +8391,7 @@ var ts; * @param sourceFiles The transformed source files to emit. * @param action The action to execute. */ - function forEachTransformedEmitFile(host, sourceFiles, action) { + function forEachTransformedEmitFile(host, sourceFiles, action, emitOnlyDtsFiles) { var options = host.getCompilerOptions(); // Emit on each source file if (options.outFile || options.out) { @@ -8217,7 +8424,7 @@ var ts; } var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = !isSourceFileJavaScript(sourceFile) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; + var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (options.declaration || emitOnlyDtsFiles) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; action(jsFilePath, sourceMapFilePath, declarationFilePath, [sourceFile], /*isBundledEmit*/ false); } function onBundledEmit(host, sourceFiles) { @@ -8242,7 +8449,7 @@ var ts; * @param action The action to execute. * @param targetSourceFile An optional target source file to emit. */ - function forEachExpectedEmitFile(host, action, targetSourceFile) { + function forEachExpectedEmitFile(host, action, targetSourceFile, emitOnlyDtsFiles) { var options = host.getCompilerOptions(); // Emit on each source file if (options.outFile || options.out) { @@ -8275,12 +8482,13 @@ var ts; } } var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); + var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (emitOnlyDtsFiles || options.declaration) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; var emitFileNames = { jsFilePath: jsFilePath, sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), - declarationFilePath: !isSourceFileJavaScript(sourceFile) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined + declarationFilePath: declarationFilePath }; - action(emitFileNames, [sourceFile], /*isBundledEmit*/ false); + action(emitFileNames, [sourceFile], /*isBundledEmit*/ false, emitOnlyDtsFiles); } function onBundledEmit(host) { // Can emit only sources that are not declaration file and are either non module code or module with @@ -8288,7 +8496,7 @@ var ts; var bundledSources = ts.filter(host.getSourceFiles(), function (sourceFile) { return !isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile) && (!ts.isExternalModule(sourceFile) || - !!getEmitModuleKind(options)); }); + !!ts.getEmitModuleKind(options)); }); if (bundledSources.length) { var jsFilePath = options.outFile || options.out; var emitFileNames = { @@ -8296,7 +8504,7 @@ var ts; sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), declarationFilePath: options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined }; - action(emitFileNames, bundledSources, /*isBundledEmit*/ true); + action(emitFileNames, bundledSources, /*isBundledEmit*/ true, emitOnlyDtsFiles); } } } @@ -8331,15 +8539,35 @@ var ts; }); } ts.getFirstConstructorWithBody = getFirstConstructorWithBody; + /** Get the type annotaion for the value parameter. */ function getSetAccessorTypeAnnotationNode(accessor) { if (accessor && accessor.parameters.length > 0) { - var hasThis = accessor.parameters.length === 2 && - accessor.parameters[0].name.kind === 69 /* Identifier */ && - accessor.parameters[0].name.originalKeywordKind === 97 /* ThisKeyword */; + var hasThis = accessor.parameters.length === 2 && parameterIsThisKeyword(accessor.parameters[0]); return accessor.parameters[hasThis ? 1 : 0].type; } } ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode; + function getThisParameter(signature) { + if (signature.parameters.length) { + var thisParameter = signature.parameters[0]; + if (parameterIsThisKeyword(thisParameter)) { + return thisParameter; + } + } + } + ts.getThisParameter = getThisParameter; + function parameterIsThisKeyword(parameter) { + return isThisIdentifier(parameter.name); + } + ts.parameterIsThisKeyword = parameterIsThisKeyword; + function isThisIdentifier(node) { + return node && node.kind === 69 /* Identifier */ && identifierIsThisKeyword(node); + } + ts.isThisIdentifier = isThisIdentifier; + function identifierIsThisKeyword(id) { + return id.originalKeywordKind === 97 /* ThisKeyword */; + } + ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { var firstAccessor; var secondAccessor; @@ -8700,14 +8928,6 @@ var ts; return symbol && symbol.valueDeclaration && hasModifier(symbol.valueDeclaration, 512 /* Default */) ? symbol.valueDeclaration.localSymbol : undefined; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; - function hasJavaScriptFileExtension(fileName) { - return ts.forEach(ts.supportedJavascriptExtensions, function (extension) { return ts.fileExtensionIs(fileName, extension); }); - } - ts.hasJavaScriptFileExtension = hasJavaScriptFileExtension; - function hasTypeScriptFileExtension(fileName) { - return ts.forEach(ts.supportedTypeScriptExtensions, function (extension) { return ts.fileExtensionIs(fileName, extension); }); - } - ts.hasTypeScriptFileExtension = hasTypeScriptFileExtension; /** Return ".ts", ".d.ts", or ".tsx", if that is the extension. */ function tryExtractTypeScriptExtension(fileName) { return ts.find(ts.supportedTypescriptExtensionsForExtractExtension, function (extension) { return ts.fileExtensionIs(fileName, extension); }); @@ -8820,12 +9040,6 @@ var ts; return result; } ts.convertToBase64 = convertToBase64; - function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) { - return !ts.isRootedDiskPath(absoluteOrRelativePath) - ? absoluteOrRelativePath - : ts.getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, /* isAbsolutePathAnUrl */ false); - } - ts.convertToRelativePath = convertToRelativePath; var carriageReturnLineFeed = "\r\n"; var lineFeed = "\n"; function getNewLineCharacter(options) { @@ -8938,7 +9152,7 @@ var ts; * @param value The delta. */ function movePos(pos, value) { - return positionIsSynthesized(pos) ? -1 : pos + value; + return ts.positionIsSynthesized(pos) ? -1 : pos + value; } ts.movePos = movePos; /** @@ -9054,7 +9268,7 @@ var ts; } ts.positionsAreOnSameLine = positionsAreOnSameLine; function getStartPositionOfRange(range, sourceFile) { - return positionIsSynthesized(range.pos) ? -1 : ts.skipTrivia(sourceFile.text, range.pos); + return ts.positionIsSynthesized(range.pos) ? -1 : ts.skipTrivia(sourceFile.text, range.pos); } ts.getStartPositionOfRange = getStartPositionOfRange; function collectExternalModuleInfo(sourceFile, resolver) { @@ -9179,15 +9393,16 @@ var ts; return 11 /* FirstTemplateToken */ <= kind && kind <= 14 /* LastTemplateToken */; } ts.isTemplateLiteralKind = isTemplateLiteralKind; - function isTemplateLiteralFragmentKind(kind) { - return kind === 12 /* TemplateHead */ - || kind === 13 /* TemplateMiddle */ + function isTemplateHead(node) { + return node.kind === 12 /* TemplateHead */; + } + ts.isTemplateHead = isTemplateHead; + function isTemplateMiddleOrTemplateTail(node) { + var kind = node.kind; + return kind === 13 /* TemplateMiddle */ || kind === 14 /* TemplateTail */; } - function isTemplateLiteralFragment(node) { - return isTemplateLiteralFragmentKind(node.kind); - } - ts.isTemplateLiteralFragment = isTemplateLiteralFragment; + ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; // Identifiers function isIdentifier(node) { return node.kind === 69 /* Identifier */; @@ -9340,12 +9555,12 @@ var ts; return node.kind === 174 /* CallExpression */; } ts.isCallExpression = isCallExpression; - function isTemplate(node) { + function isTemplateLiteral(node) { var kind = node.kind; return kind === 189 /* TemplateExpression */ || kind === 11 /* NoSubstitutionTemplateLiteral */; } - ts.isTemplate = isTemplate; + ts.isTemplateLiteral = isTemplateLiteral; function isSpreadElementExpression(node) { return node.kind === 191 /* SpreadElementExpression */; } @@ -9688,7 +9903,6 @@ var ts; } ts.isWatchSet = isWatchSet; })(ts || (ts = {})); -var ts; (function (ts) { function getDefaultLibFileName(options) { return options.target === 2 /* ES6 */ ? "lib.es6.d.ts" : "lib.d.ts"; @@ -10029,7 +10243,7 @@ var ts; // the original node. We also need to exclude specific properties and only include own- // properties (to skip members already defined on the shared prototype). var clone = createNode(node.kind, /*location*/ undefined, node.flags); - clone.original = node; + setOriginalNode(clone, node); for (var key in node) { if (clone.hasOwnProperty(key) || !node.hasOwnProperty(key)) { continue; @@ -10064,7 +10278,7 @@ var ts; node.text = value; return node; } - else { + else if (value) { var node = createNode(9 /* StringLiteral */, location, /*flags*/ undefined); node.textSourceNode = value; node.text = value.text; @@ -10364,7 +10578,7 @@ var ts; function createPropertyAccess(expression, name, location, flags) { var node = createNode(172 /* PropertyAccessExpression */, location, flags); node.expression = parenthesizeForAccess(expression); - node.emitFlags = 1048576 /* NoIndentation */; + (node.emitNode || (node.emitNode = {})).flags |= 1048576 /* NoIndentation */; node.name = typeof name === "string" ? createIdentifier(name) : name; return node; } @@ -10373,7 +10587,7 @@ var ts; if (node.expression !== expression || node.name !== name) { var propertyAccess = createPropertyAccess(expression, name, /*location*/ node, node.flags); // Because we are updating existed propertyAccess we want to inherit its emitFlags instead of using default from createPropertyAccess - propertyAccess.emitFlags = node.emitFlags; + (propertyAccess.emitNode || (propertyAccess.emitNode = {})).flags = getEmitFlags(node); return updateNode(propertyAccess, node); } return node; @@ -10477,7 +10691,7 @@ var ts; node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; node.parameters = createNodeArray(parameters); node.type = type; - node.equalsGreaterThanToken = equalsGreaterThanToken || createNode(34 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(34 /* EqualsGreaterThanToken */); node.body = parenthesizeConciseBody(body); return node; } @@ -10570,7 +10784,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right, location) { - var operatorToken = typeof operator === "number" ? createSynthesizedNode(operator) : operator; + var operatorToken = typeof operator === "number" ? createToken(operator) : operator; var operatorKind = operatorToken.kind; var node = createNode(187 /* BinaryExpression */, location); node.left = parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); @@ -11492,7 +11706,7 @@ var ts; } else { var expression = ts.isIdentifier(memberName) ? createPropertyAccess(target, memberName, location) : createElementAccess(target, memberName, location); - expression.emitFlags |= 2048 /* NoNestedSourceMaps */; + (expression.emitNode || (expression.emitNode = {})).flags |= 2048 /* NoNestedSourceMaps */; return expression; } } @@ -11500,7 +11714,7 @@ var ts; function createRestParameter(name) { return createParameterDeclaration( /*decorators*/ undefined, - /*modifiers*/ undefined, createSynthesizedNode(22 /* DotDotDotToken */), name, + /*modifiers*/ undefined, createToken(22 /* DotDotDotToken */), name, /*questionToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined); @@ -11630,13 +11844,13 @@ var ts; } ts.createDecorateHelper = createDecorateHelper; function createAwaiterHelper(externalHelpersModuleName, hasLexicalArguments, promiseConstructor, body) { - var generatorFunc = createFunctionExpression(createNode(37 /* AsteriskToken */), + var generatorFunc = createFunctionExpression(createToken(37 /* AsteriskToken */), /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ [], /*type*/ undefined, body); // Mark this node as originally an async function - generatorFunc.emitFlags |= 2097152 /* AsyncFunctionBody */; + (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 2097152 /* AsyncFunctionBody */; return createCall(createHelperName(externalHelpersModuleName, "__awaiter"), /*typeArguments*/ undefined, [ createThis(), @@ -11953,7 +12167,7 @@ var ts; target.push(startOnNewLine(createStatement(createLiteral("use strict")))); foundUseStrict = true; } - if (statement.emitFlags & 8388608 /* CustomPrologue */) { + if (getEmitFlags(statement) & 8388608 /* CustomPrologue */) { target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); } else { @@ -11965,6 +12179,34 @@ var ts; return statementOffset; } ts.addPrologueDirectives = addPrologueDirectives; + /** + * Ensures "use strict" directive is added + * + * @param node source file + */ + function ensureUseStrict(node) { + var foundUseStrict = false; + for (var _i = 0, _a = node.statements; _i < _a.length; _i++) { + var statement = _a[_i]; + if (ts.isPrologueDirective(statement)) { + if (isUseStrictPrologue(statement)) { + foundUseStrict = true; + break; + } + } + else { + break; + } + } + if (!foundUseStrict) { + var statements = []; + statements.push(startOnNewLine(createStatement(createLiteral("use strict")))); + // add "use strict" as the first statement + return updateSourceFileNode(node, statements.concat(node.statements)); + } + return node; + } + ts.ensureUseStrict = ensureUseStrict; /** * Wraps the operand to a BinaryExpression in parentheses if they are needed to preserve the intended * order of operations. @@ -12323,17 +12565,180 @@ var ts; function setOriginalNode(node, original) { node.original = original; if (original) { - var emitFlags = original.emitFlags, commentRange = original.commentRange, sourceMapRange = original.sourceMapRange; - if (emitFlags) - node.emitFlags = emitFlags; - if (commentRange) - node.commentRange = commentRange; - if (sourceMapRange) - node.sourceMapRange = sourceMapRange; + var emitNode = original.emitNode; + if (emitNode) + node.emitNode = mergeEmitNode(emitNode, node.emitNode); } return node; } ts.setOriginalNode = setOriginalNode; + function mergeEmitNode(sourceEmitNode, destEmitNode) { + var flags = sourceEmitNode.flags, commentRange = sourceEmitNode.commentRange, sourceMapRange = sourceEmitNode.sourceMapRange, tokenSourceMapRanges = sourceEmitNode.tokenSourceMapRanges; + if (!destEmitNode && (flags || commentRange || sourceMapRange || tokenSourceMapRanges)) + destEmitNode = {}; + if (flags) + destEmitNode.flags = flags; + if (commentRange) + destEmitNode.commentRange = commentRange; + if (sourceMapRange) + destEmitNode.sourceMapRange = sourceMapRange; + if (tokenSourceMapRanges) + destEmitNode.tokenSourceMapRanges = mergeTokenSourceMapRanges(tokenSourceMapRanges, destEmitNode.tokenSourceMapRanges); + return destEmitNode; + } + function mergeTokenSourceMapRanges(sourceRanges, destRanges) { + if (!destRanges) + destRanges = ts.createMap(); + ts.copyProperties(sourceRanges, destRanges); + return destRanges; + } + /** + * Clears any EmitNode entries from parse-tree nodes. + * @param sourceFile A source file. + */ + function disposeEmitNodes(sourceFile) { + // During transformation we may need to annotate a parse tree node with transient + // transformation properties. As parse tree nodes live longer than transformation + // nodes, we need to make sure we reclaim any memory allocated for custom ranges + // from these nodes to ensure we do not hold onto entire subtrees just for position + // information. We also need to reset these nodes to a pre-transformation state + // for incremental parsing scenarios so that we do not impact later emit. + sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(sourceFile)); + var emitNode = sourceFile && sourceFile.emitNode; + var annotatedNodes = emitNode && emitNode.annotatedNodes; + if (annotatedNodes) { + for (var _i = 0, annotatedNodes_1 = annotatedNodes; _i < annotatedNodes_1.length; _i++) { + var node = annotatedNodes_1[_i]; + node.emitNode = undefined; + } + } + } + ts.disposeEmitNodes = disposeEmitNodes; + /** + * Associates a node with the current transformation, initializing + * various transient transformation properties. + * + * @param node The node. + */ + function getOrCreateEmitNode(node) { + if (!node.emitNode) { + if (ts.isParseTreeNode(node)) { + // To avoid holding onto transformation artifacts, we keep track of any + // parse tree node we are annotating. This allows us to clean them up after + // all transformations have completed. + if (node.kind === 256 /* SourceFile */) { + return node.emitNode = { annotatedNodes: [node] }; + } + var sourceFile = ts.getSourceFileOfNode(node); + getOrCreateEmitNode(sourceFile).annotatedNodes.push(node); + } + node.emitNode = {}; + } + return node.emitNode; + } + /** + * Gets flags that control emit behavior of a node. + * + * @param node The node. + */ + function getEmitFlags(node) { + var emitNode = node.emitNode; + return emitNode && emitNode.flags; + } + ts.getEmitFlags = getEmitFlags; + /** + * Sets flags that control emit behavior of a node. + * + * @param node The node. + * @param emitFlags The NodeEmitFlags for the node. + */ + function setEmitFlags(node, emitFlags) { + getOrCreateEmitNode(node).flags = emitFlags; + return node; + } + ts.setEmitFlags = setEmitFlags; + /** + * Sets a custom text range to use when emitting source maps. + * + * @param node The node. + * @param range The text range. + */ + function setSourceMapRange(node, range) { + getOrCreateEmitNode(node).sourceMapRange = range; + return node; + } + ts.setSourceMapRange = setSourceMapRange; + /** + * Sets the TextRange to use for source maps for a token of a node. + * + * @param node The node. + * @param token The token. + * @param range The text range. + */ + function setTokenSourceMapRange(node, token, range) { + var emitNode = getOrCreateEmitNode(node); + var tokenSourceMapRanges = emitNode.tokenSourceMapRanges || (emitNode.tokenSourceMapRanges = ts.createMap()); + tokenSourceMapRanges[token] = range; + return node; + } + ts.setTokenSourceMapRange = setTokenSourceMapRange; + /** + * Sets a custom text range to use when emitting comments. + */ + function setCommentRange(node, range) { + getOrCreateEmitNode(node).commentRange = range; + return node; + } + ts.setCommentRange = setCommentRange; + /** + * Gets a custom text range to use when emitting comments. + * + * @param node The node. + */ + function getCommentRange(node) { + var emitNode = node.emitNode; + return (emitNode && emitNode.commentRange) || node; + } + ts.getCommentRange = getCommentRange; + /** + * Gets a custom text range to use when emitting source maps. + * + * @param node The node. + */ + function getSourceMapRange(node) { + var emitNode = node.emitNode; + return (emitNode && emitNode.sourceMapRange) || node; + } + ts.getSourceMapRange = getSourceMapRange; + /** + * Gets the TextRange to use for source maps for a token of a node. + * + * @param node The node. + * @param token The token. + */ + function getTokenSourceMapRange(node, token) { + var emitNode = node.emitNode; + var tokenSourceMapRanges = emitNode && emitNode.tokenSourceMapRanges; + return tokenSourceMapRanges && tokenSourceMapRanges[token]; + } + ts.getTokenSourceMapRange = getTokenSourceMapRange; + /** + * Gets the constant value to emit for an expression. + */ + function getConstantValue(node) { + var emitNode = node.emitNode; + return emitNode && emitNode.constantValue; + } + ts.getConstantValue = getConstantValue; + /** + * Sets the constant value to emit for an expression. + */ + function setConstantValue(node, value) { + var emitNode = getOrCreateEmitNode(node); + emitNode.constantValue = value; + return node; + } + ts.setConstantValue = setConstantValue; function setTextRange(node, location) { if (location) { node.pos = location.pos; @@ -12376,13 +12781,13 @@ var ts; } ts.getLocalNameForExternalImport = getLocalNameForExternalImport; /** - * Get the name of a target module from an import/export declaration as should be written in the emitted output. - * The emitted output name can be different from the input if: - * 1. The module has a /// - * 2. --out or --outFile is used, making the name relative to the rootDir - * 3- The containing SourceFile has an entry in renamedDependencies for the import as requested by some module loaders (e.g. System). - * Otherwise, a new StringLiteral node representing the module name will be returned. - */ + * Get the name of a target module from an import/export declaration as should be written in the emitted output. + * The emitted output name can be different from the input if: + * 1. The module has a /// + * 2. --out or --outFile is used, making the name relative to the rootDir + * 3- The containing SourceFile has an entry in renamedDependencies for the import as requested by some module loaders (e.g. System). + * Otherwise, a new StringLiteral node representing the module name will be returned. + */ function getExternalModuleNameLiteral(importNode, sourceFile, host, resolver, compilerOptions) { var moduleName = ts.getExternalModuleName(importNode); if (moduleName.kind === 9 /* StringLiteral */) { @@ -13683,8 +14088,8 @@ var ts; // Tokens other than ')' and ']' (the latter for index signatures) are here for better error recovery return token() === 18 /* CloseParenToken */ || token() === 20 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; case 18 /* TypeArguments */: - // Tokens other than '>' are here for better error recovery - return token() === 27 /* GreaterThanToken */ || token() === 17 /* OpenParenToken */; + // All other tokens should cause the type-argument to terminate except comma token + return token() !== 24 /* CommaToken */; case 20 /* HeritageClauses */: return token() === 15 /* OpenBraceToken */ || token() === 16 /* CloseBraceToken */; case 13 /* JsxAttributes */: @@ -14135,7 +14540,7 @@ var ts; } function parseTemplateExpression() { var template = createNode(189 /* TemplateExpression */); - template.head = parseTemplateLiteralFragment(); + template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 12 /* TemplateHead */, "Template head has wrong token kind"); var templateSpans = createNodeArray(); do { @@ -14151,7 +14556,7 @@ var ts; var literal; if (token() === 16 /* CloseBraceToken */) { reScanTemplateToken(); - literal = parseTemplateLiteralFragment(); + literal = parseTemplateMiddleOrTemplateTail(); } else { literal = parseExpectedToken(14 /* TemplateTail */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(16 /* CloseBraceToken */)); @@ -14162,8 +14567,15 @@ var ts; function parseLiteralNode(internName) { return parseLiteralLikeNode(token(), internName); } - function parseTemplateLiteralFragment() { - return parseLiteralLikeNode(token(), /*internName*/ false); + function parseTemplateHead() { + var fragment = parseLiteralLikeNode(token(), /*internName*/ false); + ts.Debug.assert(fragment.kind === 12 /* TemplateHead */, "Template head has wrong token kind"); + return fragment; + } + function parseTemplateMiddleOrTemplateTail() { + var fragment = parseLiteralLikeNode(token(), /*internName*/ false); + ts.Debug.assert(fragment.kind === 13 /* TemplateMiddle */ || fragment.kind === 14 /* TemplateTail */, "Template fragment has wrong token kind"); + return fragment; } function parseLiteralLikeNode(kind, internName) { var node = createNode(kind); @@ -17144,7 +17556,7 @@ var ts; parseExpected(56 /* EqualsToken */); node.type = parseType(); parseSemicolon(); - return finishNode(node); + return addJSDocComment(finishNode(node)); } // In an ambient declaration, the grammar only allows integer literals as initializers. // In a non-ambient declaration, the grammar allows uninitialized members only in a @@ -17702,6 +18114,7 @@ var ts; var parameter = createNode(142 /* Parameter */); parameter.type = parseJSDocType(); if (parseOptional(56 /* EqualsToken */)) { + // TODO(rbuckton): Can this be changed to SyntaxKind.QuestionToken? parameter.questionToken = createNode(56 /* EqualsToken */); } return finishNode(parameter); @@ -18895,6 +19308,7 @@ var ts; ContainerFlags[ContainerFlags["IsFunctionExpression"] = 16] = "IsFunctionExpression"; ContainerFlags[ContainerFlags["HasLocals"] = 32] = "HasLocals"; ContainerFlags[ContainerFlags["IsInterface"] = 64] = "IsInterface"; + ContainerFlags[ContainerFlags["IsObjectLiteralOrClassExpressionMethod"] = 128] = "IsObjectLiteralOrClassExpressionMethod"; })(ContainerFlags || (ContainerFlags = {})); var binder = createBinder(); function bindSourceFile(file, options) { @@ -18927,7 +19341,8 @@ var ts; var emitFlags; // 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). + // not depending on if we see "use strict" in certain places or if we hit a class/namespace + // or if compiler options contain alwaysStrict. var inStrictMode; var symbolCount = 0; var Symbol; @@ -18941,7 +19356,7 @@ var ts; file = f; options = opts; languageVersion = ts.getEmitScriptTarget(options); - inStrictMode = !!file.externalModuleIndicator; + inStrictMode = bindInStrictMode(file, opts); classifiableNames = ts.createMap(); symbolCount = 0; skipTransformFlagAggregation = ts.isDeclarationFile(file); @@ -18971,6 +19386,15 @@ var ts; subtreeTransformFlags = 0 /* None */; } return bindSourceFile; + function bindInStrictMode(file, opts) { + if (opts.alwaysStrict && !ts.isDeclarationFile(file)) { + // bind in strict mode source files with alwaysStrict option + return true; + } + else { + return !!file.externalModuleIndicator; + } + } function createSymbol(flags, name) { symbolCount++; return new Symbol(flags, name); @@ -19134,11 +19558,24 @@ var ts; var message_1 = symbol.flags & 2 /* BlockScopedVariable */ ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; - ts.forEach(symbol.declarations, function (declaration) { - if (ts.hasModifier(declaration, 512 /* Default */)) { + if (symbol.declarations && symbol.declarations.length) { + // If the current node is a default export of some sort, then check if + // there are any other default exports that we need to error on. + // We'll know whether we have other default exports depending on if `symbol` already has a declaration list set. + if (isDefaultExport) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } - }); + else { + // This is to properly report an error in the case "export default { }" is after export default of class declaration or function declaration. + // Error on multiple export default in the following case: + // 1. multiple export default of class declaration or function declaration by checking NodeFlags.Default + // 2. multiple export default of export assignment. This one doesn't have NodeFlags.Default on (as export default doesn't considered as modifiers) + if (symbol.declarations && symbol.declarations.length && + (isDefaultExport || (node.kind === 235 /* ExportAssignment */ && !node.isExportEquals))) { + message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; + } + } + } ts.forEach(symbol.declarations, function (declaration) { file.bindDiagnostics.push(ts.createDiagnosticForNode(declaration.name || declaration, message_1, getDisplayName(declaration))); }); @@ -19243,7 +19680,7 @@ var ts; } else { currentFlow = { flags: 2 /* Start */ }; - if (containerFlags & 16 /* IsFunctionExpression */) { + if (containerFlags & (16 /* IsFunctionExpression */ | 128 /* IsObjectLiteralOrClassExpressionMethod */)) { currentFlow.container = node; } currentReturnTarget = undefined; @@ -19705,7 +20142,11 @@ var ts; currentFlow = preTryFlow; bind(node.finallyBlock); } - currentFlow = finishFlowLabel(postFinallyLabel); + // if try statement has finally block and flow after finally block is unreachable - keep it + // otherwise use whatever flow was accumulated at postFinallyLabel + if (!node.finallyBlock || !(currentFlow.flags & 1 /* Unreachable */)) { + currentFlow = finishFlowLabel(postFinallyLabel); + } } function bindSwitchStatement(node) { var postSwitchLabel = createBranchLabel(); @@ -19840,7 +20281,7 @@ var ts; } else { ts.forEachChild(node, bind); - if (node.operator === 57 /* PlusEqualsToken */ || node.operator === 42 /* MinusMinusToken */) { + if (node.operator === 41 /* PlusPlusToken */ || node.operator === 42 /* MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } @@ -19942,9 +20383,12 @@ var ts; return 1 /* IsContainer */ | 32 /* HasLocals */; case 256 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; + case 147 /* MethodDeclaration */: + if (ts.isObjectLiteralOrClassExpressionMethod(node)) { + return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; + } case 148 /* Constructor */: case 220 /* FunctionDeclaration */: - case 147 /* MethodDeclaration */: case 146 /* MethodSignature */: case 149 /* GetAccessor */: case 150 /* SetAccessor */: @@ -20588,10 +21032,13 @@ var ts; bindAnonymousDeclaration(node, 8388608 /* Alias */, getDeclarationName(node)); } else { + // An export default clause with an expression exports a value + // We want to exclude both class and function here, this is necessary to issue an error when there are both + // default export-assignment and default export function and class declaration. var flags = node.kind === 235 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) ? 8388608 /* Alias */ : 4 /* Property */; - declareSymbol(container.symbol.exports, container.symbol, node, flags, 0 /* PropertyExcludes */ | 8388608 /* AliasExcludes */); + declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 /* Property */ | 8388608 /* AliasExcludes */ | 32 /* Class */ | 16 /* Function */); } } function bindNamespaceExportDeclaration(node) { @@ -20829,6 +21276,9 @@ var ts; emitFlags |= 2048 /* HasDecorators */; } } + if (currentFlow && ts.isObjectLiteralOrClassExpressionMethod(node)) { + node.flowNode = currentFlow; + } return ts.hasDynamicName(node) ? bindAnonymousDeclaration(node, symbolFlags, "__computed") : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); @@ -20994,8 +21444,7 @@ var ts; transformFlags |= 3 /* AssertTypeScript */; } // If the parameter's name is 'this', then it is TypeScript syntax. - if (subtreeFlags & 2048 /* ContainsDecorators */ - || (name && ts.isIdentifier(name) && name.originalKeywordKind === 97 /* ThisKeyword */)) { + if (subtreeFlags & 2048 /* ContainsDecorators */ || ts.isThisIdentifier(name)) { transformFlags |= 3 /* AssertTypeScript */; } // If a parameter has an accessibility modifier, then it is TypeScript syntax. @@ -21128,7 +21577,7 @@ var ts; transformFlags |= 3 /* AssertTypeScript */; } // Currently, we only support generators that were originally async function bodies. - if (asteriskToken && node.emitFlags & 2097152 /* AsyncFunctionBody */) { + if (asteriskToken && ts.getEmitFlags(node) & 2097152 /* AsyncFunctionBody */) { transformFlags |= 1536 /* AssertGenerator */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; @@ -21190,7 +21639,7 @@ var ts; // down-level generator. // Currently we do not support transforming any other generator fucntions // down level. - if (asteriskToken && node.emitFlags & 2097152 /* AsyncFunctionBody */) { + if (asteriskToken && ts.getEmitFlags(node) & 2097152 /* AsyncFunctionBody */) { transformFlags |= 1536 /* AssertGenerator */; } } @@ -21216,7 +21665,7 @@ var ts; // down-level generator. // Currently we do not support transforming any other generator fucntions // down level. - if (asteriskToken && node.emitFlags & 2097152 /* AsyncFunctionBody */) { + if (asteriskToken && ts.getEmitFlags(node) & 2097152 /* AsyncFunctionBody */) { transformFlags |= 1536 /* AssertGenerator */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; @@ -21500,6 +21949,677 @@ var ts; return transformFlags & ~excludeFlags; } })(ts || (ts = {})); +/// +/// +var ts; +(function (ts) { + function trace(host, message) { + host.trace(ts.formatMessage.apply(undefined, arguments)); + } + ts.trace = trace; + /* @internal */ + function isTraceEnabled(compilerOptions, host) { + return compilerOptions.traceResolution && host.trace !== undefined; + } + ts.isTraceEnabled = isTraceEnabled; + /* @internal */ + function createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations) { + return { resolvedModule: resolvedFileName ? { resolvedFileName: resolvedFileName, isExternalLibraryImport: isExternalLibraryImport } : undefined, failedLookupLocations: failedLookupLocations }; + } + ts.createResolvedModule = createResolvedModule; + function moduleHasNonRelativeName(moduleName) { + return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); + } + function tryReadTypesSection(packageJsonPath, baseDirectory, state) { + var jsonContent = readJson(packageJsonPath, state.host); + function tryReadFromField(fieldName) { + if (ts.hasProperty(jsonContent, fieldName)) { + var typesFile = jsonContent[fieldName]; + if (typeof typesFile === "string") { + var typesFilePath_1 = ts.normalizePath(ts.combinePaths(baseDirectory, typesFile)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath_1); + } + return typesFilePath_1; + } + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof typesFile); + } + } + } + } + var typesFilePath = tryReadFromField("typings") || tryReadFromField("types"); + if (typesFilePath) { + return typesFilePath; + } + // Use the main module for inferring types if no types package specified and the allowJs is set + if (state.compilerOptions.allowJs && jsonContent.main && typeof jsonContent.main === "string") { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0, jsonContent.main); + } + var mainFilePath = ts.normalizePath(ts.combinePaths(baseDirectory, jsonContent.main)); + return mainFilePath; + } + return undefined; + } + function readJson(path, host) { + try { + var jsonText = host.readFile(path); + return jsonText ? JSON.parse(jsonText) : {}; + } + catch (e) { + // gracefully handle if readFile fails or returns not JSON + return {}; + } + } + var typeReferenceExtensions = [".d.ts"]; + function getEffectiveTypeRoots(options, host) { + if (options.typeRoots) { + return options.typeRoots; + } + var currentDirectory; + if (options.configFilePath) { + currentDirectory = ts.getDirectoryPath(options.configFilePath); + } + else if (host.getCurrentDirectory) { + currentDirectory = host.getCurrentDirectory(); + } + return currentDirectory !== undefined && getDefaultTypeRoots(currentDirectory, host); + } + ts.getEffectiveTypeRoots = getEffectiveTypeRoots; + /** + * Returns the path to every node_modules/@types directory from some ancestor directory. + * Returns undefined if there are none. + */ + function getDefaultTypeRoots(currentDirectory, host) { + if (!host.directoryExists) { + return [ts.combinePaths(currentDirectory, nodeModulesAtTypes)]; + } + var typeRoots; + while (true) { + var atTypes = ts.combinePaths(currentDirectory, nodeModulesAtTypes); + if (host.directoryExists(atTypes)) { + (typeRoots || (typeRoots = [])).push(atTypes); + } + var parent_7 = ts.getDirectoryPath(currentDirectory); + if (parent_7 === currentDirectory) { + break; + } + currentDirectory = parent_7; + } + return typeRoots; + } + var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types"); + /** + * @param {string | undefined} containingFile - file that contains type reference directive, can be undefined if containing file is unknown. + * This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups + * is assumed to be the same as root directory of the project. + */ + function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host) { + var traceEnabled = isTraceEnabled(options, host); + var moduleResolutionState = { + compilerOptions: options, + host: host, + skipTsx: true, + traceEnabled: traceEnabled + }; + var typeRoots = getEffectiveTypeRoots(options, host); + if (traceEnabled) { + if (containingFile === undefined) { + if (typeRoots === undefined) { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set, typeReferenceDirectiveName); + } + else { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1, typeReferenceDirectiveName, typeRoots); + } + } + else { + if (typeRoots === undefined) { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set, typeReferenceDirectiveName, containingFile); + } + else { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, typeRoots); + } + } + } + var failedLookupLocations = []; + // Check primary library paths + if (typeRoots && typeRoots.length) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", ")); + } + var primarySearchPaths = typeRoots; + for (var _i = 0, primarySearchPaths_1 = primarySearchPaths; _i < primarySearchPaths_1.length; _i++) { + var typeRoot = primarySearchPaths_1[_i]; + var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); + var candidateDirectory = ts.getDirectoryPath(candidate); + var resolvedFile_1 = loadNodeModuleFromDirectory(typeReferenceExtensions, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState); + if (resolvedFile_1) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile_1, true); + } + return { + resolvedTypeReferenceDirective: { primary: true, resolvedFileName: resolvedFile_1 }, + failedLookupLocations: failedLookupLocations + }; + } + } + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths); + } + } + var resolvedFile; + var initialLocationForSecondaryLookup; + if (containingFile) { + initialLocationForSecondaryLookup = ts.getDirectoryPath(containingFile); + } + if (initialLocationForSecondaryLookup !== undefined) { + // check secondary locations + if (traceEnabled) { + trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); + } + resolvedFile = loadModuleFromNodeModules(typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, /*checkOneLevel*/ false); + if (traceEnabled) { + if (resolvedFile) { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile, false); + } + else { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); + } + } + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder); + } + } + return { + resolvedTypeReferenceDirective: resolvedFile + ? { primary: false, resolvedFileName: resolvedFile } + : undefined, + failedLookupLocations: failedLookupLocations + }; + } + ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective; + /** + * Given a set of options, returns the set of type directive names + * that should be included for this program automatically. + * This list could either come from the config file, + * or from enumerating the types root + initial secondary types lookup location. + * More type directives might appear in the program later as a result of loading actual source files; + * this list is only the set of defaults that are implicitly included. + */ + function getAutomaticTypeDirectiveNames(options, host) { + // Use explicit type list from tsconfig.json + if (options.types) { + return options.types; + } + // Walk the primary type lookup locations + var result = []; + if (host.directoryExists && host.getDirectories) { + var typeRoots = getEffectiveTypeRoots(options, host); + if (typeRoots) { + for (var _i = 0, typeRoots_1 = typeRoots; _i < typeRoots_1.length; _i++) { + var root = typeRoots_1[_i]; + if (host.directoryExists(root)) { + for (var _a = 0, _b = host.getDirectories(root); _a < _b.length; _a++) { + var typeDirectivePath = _b[_a]; + var normalized = ts.normalizePath(typeDirectivePath); + var packageJsonPath = pathToPackageJson(ts.combinePaths(root, normalized)); + // tslint:disable-next-line:no-null-keyword + var isNotNeededPackage = host.fileExists(packageJsonPath) && readJson(packageJsonPath, host).typings === null; + if (!isNotNeededPackage) { + // Return just the type directive names + result.push(ts.getBaseFileName(normalized)); + } + } + } + } + } + } + return result; + } + ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; + function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + var traceEnabled = isTraceEnabled(compilerOptions, host); + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); + } + var moduleResolution = compilerOptions.moduleResolution; + if (moduleResolution === undefined) { + moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + if (traceEnabled) { + trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + var result; + switch (moduleResolution) { + case ts.ModuleResolutionKind.NodeJs: + result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host); + break; + case ts.ModuleResolutionKind.Classic: + result = classicNameResolver(moduleName, containingFile, compilerOptions, host); + break; + } + if (traceEnabled) { + if (result.resolvedModule) { + trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.resolvedModule.resolvedFileName); + } + else { + trace(host, ts.Diagnostics.Module_name_0_was_not_resolved, moduleName); + } + } + return result; + } + ts.resolveModuleName = resolveModuleName; + /** + * Any module resolution kind can be augmented with optional settings: 'baseUrl', 'paths' and 'rootDirs' - they are used to + * mitigate differences between design time structure of the project and its runtime counterpart so the same import name + * can be resolved successfully by TypeScript compiler and runtime module loader. + * If these settings are set then loading procedure will try to use them to resolve module name and it can of failure it will + * fallback to standard resolution routine. + * + * - baseUrl - this setting controls how non-relative module names are resolved. If this setting is specified then non-relative + * names will be resolved relative to baseUrl: i.e. if baseUrl is '/a/b' then candidate location to resolve module name 'c/d' will + * be '/a/b/c/d' + * - paths - this setting can only be used when baseUrl is specified. allows to tune how non-relative module names + * will be resolved based on the content of the module name. + * Structure of 'paths' compiler options + * 'paths': { + * pattern-1: [...substitutions], + * pattern-2: [...substitutions], + * ... + * pattern-n: [...substitutions] + * } + * Pattern here is a string that can contain zero or one '*' character. During module resolution module name will be matched against + * all patterns in the list. Matching for patterns that don't contain '*' means that module name must be equal to pattern respecting the case. + * If pattern contains '*' then to match pattern "*" module name must start with the and end with . + * denotes part of the module name between and . + * If module name can be matches with multiple patterns then pattern with the longest prefix will be picked. + * After selecting pattern we'll use list of substitutions to get candidate locations of the module and the try to load module + * from the candidate location. + * Substitution is a string that can contain zero or one '*'. To get candidate location from substitution we'll pick every + * substitution in the list and replace '*' with string. If candidate location is not rooted it + * will be converted to absolute using baseUrl. + * For example: + * baseUrl: /a/b/c + * "paths": { + * // match all module names + * "*": [ + * "*", // use matched name as is, + * // will be looked as /a/b/c/ + * + * "folder1/*" // substitution will convert matched name to 'folder1/', + * // since it is not rooted then final candidate location will be /a/b/c/folder1/ + * ], + * // match module names that start with 'components/' + * "components/*": [ "/root/components/*" ] // substitution will convert /components/folder1/ to '/root/components/folder1/', + * // it is rooted so it will be final candidate location + * } + * + * 'rootDirs' allows the project to be spreaded across multiple locations and resolve modules with relative names as if + * they were in the same location. For example lets say there are two files + * '/local/src/content/file1.ts' + * '/shared/components/contracts/src/content/protocols/file2.ts' + * After bundling content of '/shared/components/contracts/src' will be merged with '/local/src' so + * if file1 has the following import 'import {x} from "./protocols/file2"' it will be resolved successfully in runtime. + * 'rootDirs' provides the way to tell compiler that in order to get the whole project it should behave as if content of all + * root dirs were merged together. + * I.e. for the example above 'rootDirs' will have two entries: [ '/local/src', '/shared/components/contracts/src' ]. + * Compiler will first convert './protocols/file2' into absolute path relative to the location of containing file: + * '/local/src/content/protocols/file2' and try to load it - failure. + * Then it will search 'rootDirs' looking for a longest matching prefix of this absolute path and if such prefix is found - absolute path will + * be converted to a path relative to found rootDir entry './content/protocols/file2' (*). As a last step compiler will check all remaining + * entries in 'rootDirs', use them to build absolute path out of (*) and try to resolve module from this location. + */ + function tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { + if (moduleHasNonRelativeName(moduleName)) { + return tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state); + } + else { + return tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state); + } + } + function tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { + if (!state.compilerOptions.rootDirs) { + return undefined; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0, moduleName); + } + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var matchedRootDir; + var matchedNormalizedPrefix; + for (var _i = 0, _a = state.compilerOptions.rootDirs; _i < _a.length; _i++) { + var rootDir = _a[_i]; + // rootDirs are expected to be absolute + // in case of tsconfig.json this will happen automatically - compiler will expand relative names + // using location of tsconfig.json as base location + var normalizedRoot = ts.normalizePath(rootDir); + if (!ts.endsWith(normalizedRoot, ts.directorySeparator)) { + normalizedRoot += ts.directorySeparator; + } + var isLongestMatchingPrefix = ts.startsWith(candidate, normalizedRoot) && + (matchedNormalizedPrefix === undefined || matchedNormalizedPrefix.length < normalizedRoot.length); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Checking_if_0_is_the_longest_matching_prefix_for_1_2, normalizedRoot, candidate, isLongestMatchingPrefix); + } + if (isLongestMatchingPrefix) { + matchedNormalizedPrefix = normalizedRoot; + matchedRootDir = rootDir; + } + } + if (matchedNormalizedPrefix) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Longest_matching_prefix_for_0_is_1, candidate, matchedNormalizedPrefix); + } + var suffix = candidate.substr(matchedNormalizedPrefix.length); + // first - try to load from a initial location + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, matchedNormalizedPrefix, candidate); + } + var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(containingDirectory, state.host), state); + if (resolvedFileName) { + return resolvedFileName; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Trying_other_entries_in_rootDirs); + } + // then try to resolve using remaining entries in rootDirs + for (var _b = 0, _c = state.compilerOptions.rootDirs; _b < _c.length; _b++) { + var rootDir = _c[_b]; + if (rootDir === matchedRootDir) { + // skip the initially matched entry + continue; + } + var candidate_1 = ts.combinePaths(ts.normalizePath(rootDir), suffix); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, rootDir, candidate_1); + } + var baseDirectory = ts.getDirectoryPath(candidate_1); + var resolvedFileName_1 = loader(candidate_1, supportedExtensions, failedLookupLocations, !directoryProbablyExists(baseDirectory, state.host), state); + if (resolvedFileName_1) { + return resolvedFileName_1; + } + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Module_resolution_using_rootDirs_has_failed); + } + } + return undefined; + } + function tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state) { + if (!state.compilerOptions.baseUrl) { + return undefined; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, state.compilerOptions.baseUrl, moduleName); + } + // string is for exact match + var matchedPattern = undefined; + if (state.compilerOptions.paths) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); + } + matchedPattern = ts.matchPatternOrExact(ts.getOwnKeys(state.compilerOptions.paths), moduleName); + } + if (matchedPattern) { + var matchedStar = typeof matchedPattern === "string" ? undefined : ts.matchedText(matchedPattern, moduleName); + var matchedPatternText = typeof matchedPattern === "string" ? matchedPattern : ts.patternText(matchedPattern); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPatternText); + } + for (var _i = 0, _a = state.compilerOptions.paths[matchedPatternText]; _i < _a.length; _i++) { + var subst = _a[_i]; + var path = matchedStar ? subst.replace("*", matchedStar) : subst; + var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, path)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path); + } + var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + if (resolvedFileName) { + return resolvedFileName; + } + } + return undefined; + } + else { + var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, moduleName)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Resolving_module_name_0_relative_to_base_url_1_2, moduleName, state.compilerOptions.baseUrl, candidate); + } + return loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + } + } + function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host) { + var containingDirectory = ts.getDirectoryPath(containingFile); + var supportedExtensions = ts.getSupportedExtensions(compilerOptions); + var traceEnabled = isTraceEnabled(compilerOptions, host); + var failedLookupLocations = []; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: false }; + var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, supportedExtensions, state); + var isExternalLibraryImport = false; + if (!resolvedFileName) { + if (moduleHasNonRelativeName(moduleName)) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder, moduleName); + } + resolvedFileName = loadModuleFromNodeModules(moduleName, containingDirectory, failedLookupLocations, state, /*checkOneLevel*/ false); + isExternalLibraryImport = resolvedFileName !== undefined; + } + else { + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + resolvedFileName = nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, /*onlyRecordFailures*/ false, state); + } + } + if (resolvedFileName && host.realpath) { + var originalFileName = resolvedFileName; + resolvedFileName = ts.normalizePath(host.realpath(resolvedFileName)); + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, originalFileName, resolvedFileName); + } + } + return createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations); + } + ts.nodeModuleNameResolver = nodeModuleNameResolver; + function nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate); + } + var resolvedFileName = !ts.pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state); + return resolvedFileName || loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, onlyRecordFailures, state); + } + /* @internal */ + function directoryProbablyExists(directoryName, host) { + // if host does not support 'directoryExists' assume that directory will exist + return !host.directoryExists || host.directoryExists(directoryName); + } + ts.directoryProbablyExists = directoryProbablyExists; + /** + * @param {boolean} onlyRecordFailures - if true then function won't try to actually load files but instead record all attempts as failures. This flag is necessary + * in cases when we know upfront that all load attempts will fail (because containing folder does not exists) however we still need to record all failed lookup locations. + */ + function loadModuleFromFile(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) { + // First, try adding an extension. An import of "foo" could be matched by a file "foo.ts", or "foo.js" by "foo.js.ts" + var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state); + if (resolvedByAddingExtension) { + return resolvedByAddingExtension; + } + // If that didn't work, try stripping a ".js" or ".jsx" extension and replacing it with a TypeScript one; + // e.g. "./foo.js" can be matched by "./foo.ts" or "./foo.d.ts" + if (ts.hasJavaScriptFileExtension(candidate)) { + var extensionless = ts.removeFileExtension(candidate); + if (state.traceEnabled) { + var extension = candidate.substring(extensionless.length); + trace(state.host, ts.Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension); + } + return tryAddingExtensions(extensionless, extensions, failedLookupLocation, onlyRecordFailures, state); + } + } + /** Try to return an existing file that adds one of the `extensions` to `candidate`. */ + function tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) { + if (!onlyRecordFailures) { + // check if containing folder exists - if it doesn't then just record failures for all supported extensions without disk probing + var directory = ts.getDirectoryPath(candidate); + if (directory) { + onlyRecordFailures = !directoryProbablyExists(directory, state.host); + } + } + return ts.forEach(extensions, function (ext) { + return !(state.skipTsx && ts.isJsxOrTsxExtension(ext)) && tryFile(candidate + ext, failedLookupLocation, onlyRecordFailures, state); + }); + } + /** Return the file if it exists. */ + function tryFile(fileName, failedLookupLocation, onlyRecordFailures, state) { + if (!onlyRecordFailures && state.host.fileExists(fileName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); + } + return fileName; + } + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); + } + failedLookupLocation.push(fileName); + return undefined; + } + } + function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocation, onlyRecordFailures, state) { + var packageJsonPath = pathToPackageJson(candidate); + var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); + if (directoryExists && state.host.fileExists(packageJsonPath)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); + } + var typesFile = tryReadTypesSection(packageJsonPath, candidate, state); + if (typesFile) { + var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(typesFile), state.host); + // A package.json "typings" may specify an exact filename, or may choose to omit an extension. + var result = tryFile(typesFile, failedLookupLocation, onlyRecordFailures_1, state) || + tryAddingExtensions(typesFile, extensions, failedLookupLocation, onlyRecordFailures_1, state); + if (result) { + return result; + } + } + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_does_not_have_types_field); + } + } + } + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); + } + // 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 loadModuleFromFile(ts.combinePaths(candidate, "index"), extensions, failedLookupLocation, !directoryExists, state); + } + function pathToPackageJson(directory) { + return ts.combinePaths(directory, "package.json"); + } + function loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state) { + var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); + var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); + var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); + var supportedExtensions = ts.getSupportedExtensions(state.compilerOptions); + var result = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, !nodeModulesFolderExists, state); + if (result) { + return result; + } + result = loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); + if (result) { + return result; + } + } + /* @internal */ + function loadModuleFromNodeModules(moduleName, directory, failedLookupLocations, state, checkOneLevel) { + return loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, checkOneLevel, /*typesOnly*/ false); + } + ts.loadModuleFromNodeModules = loadModuleFromNodeModules; + function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) { + return loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, /*checkOneLevel*/ false, /*typesOnly*/ true); + } + function loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, checkOneLevel, typesOnly) { + directory = ts.normalizeSlashes(directory); + while (true) { + var baseName = ts.getBaseFileName(directory); + if (baseName !== "node_modules") { + var packageResult = void 0; + if (!typesOnly) { + // Try to load source from the package + packageResult = loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state); + if (packageResult && ts.hasTypeScriptFileExtension(packageResult)) { + // Always prefer a TypeScript (.ts, .tsx, .d.ts) file shipped with the package + return packageResult; + } + } + // Else prefer a types package over non-TypeScript results (e.g. JavaScript files) + var typesResult = loadModuleFromNodeModulesFolder(ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); + if (typesResult || packageResult) { + return typesResult || packageResult; + } + } + var parentPath = ts.getDirectoryPath(directory); + if (parentPath === directory || checkOneLevel) { + break; + } + directory = parentPath; + } + return undefined; + } + function classicNameResolver(moduleName, containingFile, compilerOptions, host) { + var traceEnabled = isTraceEnabled(compilerOptions, host); + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: !compilerOptions.jsx }; + var failedLookupLocations = []; + var supportedExtensions = ts.getSupportedExtensions(compilerOptions); + var containingDirectory = ts.getDirectoryPath(containingFile); + var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, supportedExtensions, state); + if (resolvedFileName) { + return createResolvedModule(resolvedFileName, /*isExternalLibraryImport*/ false, failedLookupLocations); + } + var referencedSourceFile; + if (moduleHasNonRelativeName(moduleName)) { + referencedSourceFile = referencedSourceFile = loadModuleFromAncestorDirectories(moduleName, containingDirectory, supportedExtensions, failedLookupLocations, state) || + // If we didn't find the file normally, look it up in @types. + loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); + } + else { + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + referencedSourceFile = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, /*onlyRecordFailures*/ false, state); + } + return referencedSourceFile + ? { resolvedModule: { resolvedFileName: referencedSourceFile }, failedLookupLocations: failedLookupLocations } + : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; + } + ts.classicNameResolver = classicNameResolver; + /** Climb up parent directories looking for a module. */ + function loadModuleFromAncestorDirectories(moduleName, containingDirectory, supportedExtensions, failedLookupLocations, state) { + while (true) { + var searchName = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var referencedSourceFile = loadModuleFromFile(searchName, supportedExtensions, failedLookupLocations, /*onlyRecordFailures*/ false, state); + if (referencedSourceFile) { + return referencedSourceFile; + } + var parentPath = ts.getDirectoryPath(containingDirectory); + if (parentPath === containingDirectory) { + return undefined; + } + containingDirectory = parentPath; + } + } +})(ts || (ts = {})); +/// /// /* @internal */ var ts; @@ -21607,6 +22727,7 @@ var ts; var unknownSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "unknown"); var resolvingSymbol = createSymbol(67108864 /* Transient */, "__resolving__"); var anyType = createIntrinsicType(1 /* Any */, "any"); + var autoType = createIntrinsicType(1 /* Any */, "any"); var unknownType = createIntrinsicType(1 /* Any */, "unknown"); var undefinedType = createIntrinsicType(2048 /* Undefined */, "undefined"); var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(2048 /* Undefined */ | 33554432 /* ContainsWideningType */, "undefined"); @@ -22350,7 +23471,7 @@ var ts; if (result && isInExternalModule && (meaning & 107455 /* Value */) === 107455 /* Value */) { var decls = result.declarations; if (decls && decls.length === 1 && decls[0].kind === 228 /* NamespaceExportDeclaration */) { - error(errorLocation, ts.Diagnostics.Identifier_0_must_be_imported_from_a_module, name); + error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } } @@ -22833,6 +23954,8 @@ var ts; } function getExportsForModule(moduleSymbol) { var visitedSymbols = []; + // A module defined by an 'export=' consists on one export that needs to be resolved + moduleSymbol = resolveExternalModuleSymbol(moduleSymbol); return visit(moduleSymbol) || moduleSymbol.exports; // The ES6 spec permits export * declarations in a module to circularly reference the module itself. For example, // module 'a' can 'export * from "b"' and 'b' can 'export * from "a"' without error. @@ -23407,9 +24530,9 @@ var ts; if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { // Go up and add our parent. - var parent_7 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); - if (parent_7) { - walkSymbol(parent_7, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); + var parent_8 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent_8) { + walkSymbol(parent_8, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); } } if (accessibleSymbolChain) { @@ -23453,7 +24576,7 @@ var ts; ? "any" : type.intrinsicName); } - else if (type.flags & 268435456 /* ThisType */) { + else if (type.flags & 16384 /* TypeParameter */ && type.isThisType) { if (inObjectTypeLiteral) { writer.reportInaccessibleThisError(); } @@ -23471,9 +24594,14 @@ var ts; // The specified symbol flags need to be reinterpreted as type flags buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 793064 /* Type */, 0 /* None */, nextFlags); } - else if (!(flags & 512 /* InTypeAlias */) && type.flags & (2097152 /* Anonymous */ | 1572864 /* UnionOrIntersection */) && type.aliasSymbol && + else if (!(flags & 512 /* InTypeAlias */) && ((type.flags & 2097152 /* Anonymous */ && !type.target) || type.flags & 1572864 /* UnionOrIntersection */) && type.aliasSymbol && isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, 793064 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false).accessibility === 0 /* Accessible */) { - // Only write out inferred type with its corresponding type-alias if type-alias is visible + // We emit inferred type as type-alias at the current localtion if all the following is true + // the input type is has alias symbol that is accessible + // the input type is a union, intersection or anonymous type that is fully instantiated (if not we want to keep dive into) + // e.g.: export type Bar = () => [X, Y]; + // export type Foo = Bar; + // export const y = (x: Foo) => 1 // we want to emit as ...x: () => [any, string]) var typeArguments = type.aliasTypeArguments; writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments.length : 0, nextFlags); } @@ -23549,14 +24677,14 @@ var ts; while (i < length_1) { // Find group of type arguments for type parameters with the same declaring container. var start = i; - var parent_8 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + var parent_9 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_8); + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_9); // 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_8, typeArguments, start, i, flags); + writeSymbolTypeReference(parent_9, typeArguments, start, i, flags); writePunctuation(writer, 21 /* DotToken */); } } @@ -23960,14 +25088,14 @@ var ts; if (ts.isExternalModuleAugmentation(node)) { return true; } - var parent_9 = getDeclarationContainer(node); + var parent_10 = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedModifierFlags(node) & 1 /* Export */) && - !(node.kind !== 229 /* ImportEqualsDeclaration */ && parent_9.kind !== 256 /* SourceFile */ && ts.isInAmbientContext(parent_9))) { - return isGlobalSourceFile(parent_9); + !(node.kind !== 229 /* ImportEqualsDeclaration */ && parent_10.kind !== 256 /* SourceFile */ && ts.isInAmbientContext(parent_10))) { + return isGlobalSourceFile(parent_10); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible - return isDeclarationVisible(parent_9); + return isDeclarationVisible(parent_10); case 145 /* PropertyDeclaration */: case 144 /* PropertySignature */: case 149 /* GetAccessor */: @@ -24274,6 +25402,10 @@ var ts; } return undefined; } + function isAutoVariableInitializer(initializer) { + var expr = initializer && ts.skipParentheses(initializer); + return !expr || expr.kind === 93 /* NullKeyword */ || expr.kind === 69 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; + } function addOptionality(type, optional) { return strictNullChecks && optional ? includeFalsyTypes(type, 2048 /* Undefined */) : type; } @@ -24306,6 +25438,13 @@ var ts; if (declaration.type) { return addOptionality(getTypeFromTypeNode(declaration.type), /*optional*/ declaration.questionToken && includeOptionality); } + // Use control flow type inference for non-ambient, non-exported var or let variables with no initializer + // or a 'null' or 'undefined' initializer. + if (declaration.kind === 218 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + !(ts.getCombinedNodeFlags(declaration) & 2 /* Const */) && !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && + !ts.isInAmbientContext(declaration) && isAutoVariableInitializer(declaration.initializer)) { + return autoType; + } if (declaration.kind === 142 /* Parameter */) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present @@ -24389,7 +25528,7 @@ var ts; result.pattern = pattern; } if (hasComputedProperties) { - result.flags |= 536870912 /* ObjectLiteralPatternWithComputedProperties */; + result.isObjectLiteralPatternWithComputedProperties = true; } return result; } @@ -24935,7 +26074,8 @@ var ts; type.instantiations[getTypeListId(type.typeParameters)] = type; type.target = type; type.typeArguments = type.typeParameters; - type.thisType = createType(16384 /* TypeParameter */ | 268435456 /* ThisType */); + type.thisType = createType(16384 /* TypeParameter */); + type.thisType.isThisType = true; type.thisType.symbol = symbol; type.thisType.constraint = type; } @@ -25509,7 +26649,7 @@ var ts; var current = _a[_i]; for (var _b = 0, _c = getPropertiesOfType(current); _b < _c.length; _b++) { var prop = _c[_b]; - getPropertyOfUnionOrIntersectionType(type, prop.name); + getUnionOrIntersectionProperty(type, prop.name); } // The properties of a union type are those that are present in all constituent types, so // we only need to check the properties of the first type @@ -25517,7 +26657,19 @@ var ts; break; } } - return type.resolvedProperties ? symbolsToArray(type.resolvedProperties) : emptyArray; + var props = type.resolvedProperties; + if (props) { + var result = []; + for (var key in props) { + var prop = props[key]; + // We need to filter out partial properties in union types + if (!(prop.flags & 268435456 /* SyntheticProperty */ && prop.isPartial)) { + result.push(prop); + } + } + return result; + } + return emptyArray; } function getPropertiesOfType(type) { type = getApparentType(type); @@ -25566,6 +26718,7 @@ var ts; // Flags we want to propagate to the result if they exist in all source symbols var commonFlags = (containingType.flags & 1048576 /* Intersection */) ? 536870912 /* Optional */ : 0 /* None */; var isReadonly = false; + var isPartial = false; for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { var current = types_2[_i]; var type = getApparentType(current); @@ -25584,21 +26737,20 @@ var ts; } } else if (containingType.flags & 524288 /* Union */) { - // A union type requires the property to be present in all constituent types - return undefined; + isPartial = true; } } } if (!props) { return undefined; } - if (props.length === 1) { + if (props.length === 1 && !isPartial) { return props[0]; } var propTypes = []; var declarations = []; var commonType = undefined; - var hasCommonType = true; + var hasNonUniformType = false; for (var _a = 0, props_1 = props; _a < props_1.length; _a++) { var prop = props_1[_a]; if (prop.declarations) { @@ -25609,22 +26761,25 @@ var ts; commonType = type; } else if (type !== commonType) { - hasCommonType = false; + hasNonUniformType = true; } - propTypes.push(getTypeOfSymbol(prop)); + propTypes.push(type); } - var result = createSymbol(4 /* Property */ | - 67108864 /* Transient */ | - 268435456 /* SyntheticProperty */ | - commonFlags, name); + var result = createSymbol(4 /* Property */ | 67108864 /* Transient */ | 268435456 /* SyntheticProperty */ | commonFlags, name); result.containingType = containingType; - result.hasCommonType = hasCommonType; + result.hasNonUniformType = hasNonUniformType; + result.isPartial = isPartial; result.declarations = declarations; result.isReadonly = isReadonly; result.type = containingType.flags & 524288 /* Union */ ? getUnionType(propTypes) : getIntersectionType(propTypes); return result; } - function getPropertyOfUnionOrIntersectionType(type, name) { + // Return the symbol for a given property in a union or intersection type, or undefined if the property + // does not exist in any constituent type. Note that the returned property may only be present in some + // constituents, in which case the isPartial flag is set when the containing type is union type. We need + // these partial properties when identifying discriminant properties, but otherwise they are filtered out + // and do not appear to be present in the union type. + function getUnionOrIntersectionProperty(type, name) { var properties = type.resolvedProperties || (type.resolvedProperties = ts.createMap()); var property = properties[name]; if (!property) { @@ -25635,6 +26790,11 @@ var ts; } return property; } + function getPropertyOfUnionOrIntersectionType(type, name) { + var property = getUnionOrIntersectionProperty(type, name); + // We need to filter out partial properties in union types + return property && !(property.flags & 268435456 /* SyntheticProperty */ && property.isPartial) ? property : undefined; + } /** * Return the symbol for the property with the given name in the given type. Creates synthetic union properties when * necessary, maps primitive types and type parameters are to their apparent types, and augments with properties from @@ -26040,7 +27200,7 @@ var ts; } function hasConstraintReferenceTo(type, target) { var checked; - while (type && !(type.flags & 268435456 /* ThisType */) && type.flags & 16384 /* TypeParameter */ && !ts.contains(checked, type)) { + while (type && type.flags & 16384 /* TypeParameter */ && !(type.isThisType) && !ts.contains(checked, type)) { if (type === target) { return true; } @@ -26365,7 +27525,8 @@ var ts; type.instantiations[getTypeListId(type.typeParameters)] = type; type.target = type; type.typeArguments = type.typeParameters; - type.thisType = createType(16384 /* TypeParameter */ | 268435456 /* ThisType */); + type.thisType = createType(16384 /* TypeParameter */); + type.thisType.isThisType = true; type.thisType.constraint = type; type.declaredProperties = properties; type.declaredCallSignatures = emptyArray; @@ -26466,7 +27627,24 @@ var ts; } return false; } + function isSetOfLiteralsFromSameEnum(types) { + var first = types[0]; + if (first.flags & 256 /* EnumLiteral */) { + var firstEnum = getParentOfSymbol(first.symbol); + for (var i = 1; i < types.length; i++) { + var other = types[i]; + if (!(other.flags & 256 /* EnumLiteral */) || (firstEnum !== getParentOfSymbol(other.symbol))) { + return false; + } + } + return true; + } + return false; + } function removeSubtypes(types) { + if (types.length === 0 || isSetOfLiteralsFromSameEnum(types)) { + return; + } var i = types.length; while (i > 0) { i--; @@ -27553,7 +28731,8 @@ var ts; !t.numberIndexInfo; } function hasExcessProperties(source, target, reportErrors) { - if (!(target.flags & 536870912 /* ObjectLiteralPatternWithComputedProperties */) && maybeTypeOfKind(target, 2588672 /* ObjectType */)) { + if (maybeTypeOfKind(target, 2588672 /* ObjectType */) && + (!(target.flags & 2588672 /* ObjectType */) || !target.isObjectLiteralPatternWithComputedProperties)) { for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { var prop = _a[_i]; if (!isKnownProperty(target, prop.name)) { @@ -28917,21 +30096,10 @@ var ts; } function isDiscriminantProperty(type, name) { if (type && type.flags & 524288 /* Union */) { - var prop = getPropertyOfType(type, name); - if (!prop) { - // The type may be a union that includes nullable or primitive types. If filtering - // those out produces a different type, get the property from that type instead. - // Effectively, we're checking if this *could* be a discriminant property once nullable - // and primitive types are removed by other type guards. - var filteredType = getTypeWithFacts(type, 4194304 /* Discriminatable */); - if (filteredType !== type && filteredType.flags & 524288 /* Union */) { - prop = getPropertyOfType(filteredType, name); - } - } + var prop = getUnionOrIntersectionProperty(type, name); if (prop && prop.flags & 268435456 /* SyntheticProperty */) { if (prop.isDiscriminantProperty === undefined) { - prop.isDiscriminantProperty = !prop.hasCommonType && - isLiteralType(getTypeOfSymbol(prop)); + prop.isDiscriminantProperty = prop.hasNonUniformType && isLiteralType(getTypeOfSymbol(prop)); } return prop.isDiscriminantProperty; } @@ -29218,6 +30386,26 @@ var ts; } return f(type) ? type : neverType; } + function mapType(type, f) { + return type.flags & 524288 /* Union */ ? getUnionType(ts.map(type.types, f)) : f(type); + } + function extractTypesOfKind(type, kind) { + return filterType(type, function (t) { return (t.flags & kind) !== 0; }); + } + // Return a new type in which occurrences of the string and number primitive types in + // typeWithPrimitives have been replaced with occurrences of string literals and numeric + // literals in typeWithLiterals, respectively. + function replacePrimitivesWithLiterals(typeWithPrimitives, typeWithLiterals) { + if (isTypeSubsetOf(stringType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 32 /* StringLiteral */) || + isTypeSubsetOf(numberType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 64 /* NumberLiteral */)) { + return mapType(typeWithPrimitives, function (t) { + return t.flags & 2 /* String */ ? extractTypesOfKind(typeWithLiterals, 2 /* String */ | 32 /* StringLiteral */) : + t.flags & 4 /* Number */ ? extractTypesOfKind(typeWithLiterals, 4 /* Number */ | 64 /* NumberLiteral */) : + t; + }); + } + return typeWithPrimitives; + } function isIncomplete(flowType) { return flowType.flags === 0; } @@ -29232,7 +30420,9 @@ var ts; if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 4178943 /* Narrowable */)) { return declaredType; } - var initialType = assumeInitialized ? declaredType : includeFalsyTypes(declaredType, 2048 /* Undefined */); + var initialType = assumeInitialized ? declaredType : + declaredType === autoType ? undefinedType : + includeFalsyTypes(declaredType, 2048 /* Undefined */); var visitedFlowStart = visitedFlowCount; var result = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); visitedFlowCount = visitedFlowStart; @@ -29304,10 +30494,13 @@ var ts; // Assignments only narrow the computed type if the declared type is a union type. Thus, we // only need to evaluate the assigned type if the declared type is a union type. if (isMatchingReference(reference, node)) { - var isIncrementOrDecrement = node.parent.kind === 185 /* PrefixUnaryExpression */ || node.parent.kind === 186 /* PostfixUnaryExpression */; - return declaredType.flags & 524288 /* Union */ && !isIncrementOrDecrement ? - getAssignmentReducedType(declaredType, getInitialOrAssignedType(node)) : - declaredType; + if (node.parent.kind === 185 /* PrefixUnaryExpression */ || node.parent.kind === 186 /* PostfixUnaryExpression */) { + var flowType = getTypeAtFlowNode(flow.antecedent); + return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType)); + } + return declaredType === autoType ? getBaseTypeOfLiteralType(getInitialOrAssignedType(node)) : + declaredType.flags & 524288 /* Union */ ? getAssignmentReducedType(declaredType, getInitialOrAssignedType(node)) : + declaredType; } // We didn't have a direct match. However, if the reference is a dotted name, this // may be an assignment to a left hand part of the reference. For example, for a @@ -29531,12 +30724,12 @@ var ts; assumeTrue ? 16384 /* EQUndefined */ : 131072 /* NEUndefined */; return getTypeWithFacts(type, facts); } - if (type.flags & 2589191 /* NotUnionOrUnit */) { + if (type.flags & 2589185 /* NotUnionOrUnit */) { return type; } if (assumeTrue) { var narrowedType = filterType(type, function (t) { return areTypesComparable(t, valueType); }); - return narrowedType.flags & 8192 /* Never */ ? type : narrowedType; + return narrowedType.flags & 8192 /* Never */ ? type : replacePrimitivesWithLiterals(narrowedType, valueType); } if (isUnitType(valueType)) { var regularType_1 = getRegularTypeOfLiteralType(valueType); @@ -29581,7 +30774,8 @@ var ts; var clauseTypes = switchTypes.slice(clauseStart, clauseEnd); var hasDefaultClause = clauseStart === clauseEnd || ts.contains(clauseTypes, neverType); var discriminantType = getUnionType(clauseTypes); - var caseType = discriminantType.flags & 8192 /* Never */ ? neverType : filterType(type, function (t) { return isTypeComparableTo(discriminantType, t); }); + var caseType = discriminantType.flags & 8192 /* Never */ ? neverType : + replacePrimitivesWithLiterals(filterType(type, function (t) { return isTypeComparableTo(discriminantType, t); }), discriminantType); if (!hasDefaultClause) { return caseType; } @@ -29728,7 +30922,7 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } - if (ts.isExpression(location) && !ts.isAssignmentTarget(location)) { + if (ts.isPartOfExpression(location) && !ts.isAssignmentTarget(location)) { var type = checkExpression(location); if (getExportSymbolOfValueSymbolIfExported(getNodeLinks(location).resolvedSymbol) === symbol) { return type; @@ -29877,20 +31071,32 @@ var ts; // a const variable or parameter from an outer function, we extend the origin of the control flow // analysis to include the immediately enclosing function. while (flowContainer !== declarationContainer && - (flowContainer.kind === 179 /* FunctionExpression */ || flowContainer.kind === 180 /* ArrowFunction */) && + (flowContainer.kind === 179 /* FunctionExpression */ || + flowContainer.kind === 180 /* ArrowFunction */ || + ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isReadonlySymbol(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } // We only look for uninitialized variables in strict null checking mode, and only when we can analyze // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). - var assumeInitialized = !strictNullChecks || (type.flags & 1 /* Any */) !== 0 || isParameter || - isOuterVariable || ts.isInAmbientContext(declaration); + var assumeInitialized = isParameter || isOuterVariable || + type !== autoType && (!strictNullChecks || (type.flags & 1 /* Any */) !== 0) || + ts.isInAmbientContext(declaration); var flowType = getFlowTypeOfReference(node, type, assumeInitialized, flowContainer); // A variable is considered uninitialized when it is possible to analyze the entire control flow graph // from declaration to use, and when the variable's declared type doesn't include undefined but the // control flow based type does include undefined. - if (!assumeInitialized && !(getFalsyFlags(type) & 2048 /* Undefined */) && getFalsyFlags(flowType) & 2048 /* Undefined */) { + if (type === autoType) { + if (flowType === autoType) { + if (compilerOptions.noImplicitAny) { + error(declaration.name, ts.Diagnostics.Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol)); + error(node, ts.Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(anyType)); + } + return anyType; + } + } + else if (!assumeInitialized && !(getFalsyFlags(type) & 2048 /* Undefined */) && getFalsyFlags(flowType) & 2048 /* Undefined */) { error(node, ts.Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol)); // Return the declared type to reduce follow-on errors return type; @@ -29988,7 +31194,7 @@ var ts; } } function findFirstSuperCall(n) { - if (ts.isSuperCallExpression(n)) { + if (ts.isSuperCall(n)) { return n; } else if (ts.isFunctionLike(n)) { @@ -30081,7 +31287,7 @@ var ts; captureLexicalThis(node, container); } if (ts.isFunctionLike(container) && - (!isInParameterInitializerBeforeContainingFunction(node) || getFunctionLikeThisParameter(container))) { + (!isInParameterInitializerBeforeContainingFunction(node) || ts.getThisParameter(container))) { // Note: a parameter initializer should refer to class-this unless function-this is explicitly annotated. // If this is a function in a JS file, it might be a class method. Check if it's the RHS // of a x.prototype.y = function [name]() { .... } @@ -30141,8 +31347,8 @@ var ts; var isCallExpression = node.parent.kind === 174 /* CallExpression */ && node.parent.expression === node; var container = ts.getSuperContainer(node, /*stopOnFunctions*/ true); var needToCaptureLexicalThis = false; + // adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting if (!isCallExpression) { - // adjust the container reference in case if super is used inside arrow functions with arbitrary deep nesting while (container && container.kind === 180 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES6 */; @@ -30954,7 +32160,8 @@ var ts; patternWithComputedProperties = true; } } - else if (contextualTypeHasPattern && !(contextualType.flags & 536870912 /* ObjectLiteralPatternWithComputedProperties */)) { + else if (contextualTypeHasPattern && + !(contextualType.flags & 2588672 /* ObjectType */ && contextualType.isObjectLiteralPatternWithComputedProperties)) { // If object literal is contextually typed by the implied type of a binding pattern, and if the // binding pattern specifies a default value for the property, make the property optional. var impliedProp = getPropertyOfType(contextualType, member.name); @@ -31014,7 +32221,10 @@ var ts; var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, propertiesArray, 1 /* Number */) : undefined; var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 16777216 /* FreshLiteral */; - result.flags |= 8388608 /* ObjectLiteral */ | 67108864 /* ContainsObjectLiteral */ | freshObjectLiteralFlag | (typeFlags & 234881024 /* PropagatingFlags */) | (patternWithComputedProperties ? 536870912 /* ObjectLiteralPatternWithComputedProperties */ : 0); + result.flags |= 8388608 /* ObjectLiteral */ | 67108864 /* ContainsObjectLiteral */ | freshObjectLiteralFlag | (typeFlags & 234881024 /* PropagatingFlags */); + if (patternWithComputedProperties) { + result.isObjectLiteralPatternWithComputedProperties = true; + } if (inDestructuringPattern) { result.pattern = node; } @@ -31523,7 +32733,7 @@ var ts; return true; } // An instance property must be accessed through an instance of the enclosing class - if (type.flags & 268435456 /* ThisType */) { + if (type.flags & 16384 /* TypeParameter */ && type.isThisType) { // get the original type -- represented as the type constraint of the 'this' type type = getConstraintOfTypeParameter(type); } @@ -31567,7 +32777,7 @@ var ts; var prop = getPropertyOfType(apparentType, right.text); if (!prop) { if (right.text && !checkAndReportErrorForExtendingInterface(node)) { - reportNonexistentProperty(right, type.flags & 268435456 /* ThisType */ ? apparentType : type); + reportNonexistentProperty(right, type.flags & 16384 /* TypeParameter */ && type.isThisType ? apparentType : type); } return unknownType; } @@ -31848,13 +33058,13 @@ var ts; for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var signature = signatures_2[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_10 = signature.declaration && signature.declaration.parent; + var parent_11 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_10 === lastParent) { + if (lastParent && parent_11 === lastParent) { index++; } else { - lastParent = parent_10; + lastParent = parent_11; index = cutoffIndex; } } @@ -31862,7 +33072,7 @@ var ts; // current declaration belongs to a different symbol // set cutoffIndex so re-orderings in the future won't change result set from 0 to cutoffIndex index = cutoffIndex = result.length; - lastParent = parent_10; + lastParent = parent_11; } lastSymbol = symbol; // specialized signatures always need to be placed before non-specialized signatures regardless @@ -33121,7 +34331,9 @@ var ts; if (!contextualSignature) { reportErrorsFromWidening(func, type); } - if (isUnitType(type) && !(contextualSignature && isLiteralContextualType(getReturnTypeOfSignature(contextualSignature)))) { + if (isUnitType(type) && + !(contextualSignature && + isLiteralContextualType(contextualSignature === getSignatureFromDeclaration(func) ? type : getReturnTypeOfSignature(contextualSignature)))) { type = getWidenedLiteralType(type); } var widenedType = getWidenedType(type); @@ -33305,7 +34517,7 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 147 /* MethodDeclaration */ && node.kind !== 146 /* MethodSignature */) { + if (produceDiagnostics && node.kind !== 147 /* MethodDeclaration */) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } @@ -34388,9 +35600,9 @@ var ts; case 156 /* FunctionType */: case 147 /* MethodDeclaration */: case 146 /* MethodSignature */: - var parent_11 = node.parent; - if (node === parent_11.type) { - return parent_11; + var parent_12 = node.parent; + if (node === parent_12.type) { + return parent_12; } } } @@ -34628,7 +35840,7 @@ var ts; return n.name && containsSuperCall(n.name); } function containsSuperCall(n) { - if (ts.isSuperCallExpression(n)) { + if (ts.isSuperCall(n)) { return true; } else if (ts.isFunctionLike(n)) { @@ -34657,6 +35869,7 @@ var ts; // constructors of derived classes must contain at least one super call somewhere in their function body. var containingClassDecl = node.parent; if (ts.getClassExtendsHeritageClauseElement(containingClassDecl)) { + captureLexicalThis(node.parent, containingClassDecl); var classExtendsNull = classDeclarationExtendsNull(containingClassDecl); var superCall = getSuperCallInConstructor(node); if (superCall) { @@ -34677,7 +35890,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 202 /* ExpressionStatement */ && ts.isSuperCallExpression(statement.expression)) { + if (statement.kind === 202 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -35607,7 +36820,7 @@ var ts; var parameter = local.valueDeclaration; if (compilerOptions.noUnusedParameters && !ts.isParameterPropertyDeclaration(parameter) && - !parameterIsThisKeyword(parameter) && + !ts.parameterIsThisKeyword(parameter) && !parameterNameStartsWithUnderscore(parameter)) { error(local.valueDeclaration.name, ts.Diagnostics._0_is_declared_but_never_used, local.name); } @@ -35622,9 +36835,6 @@ var ts; } } } - function parameterIsThisKeyword(parameter) { - return parameter.name && parameter.name.originalKeywordKind === 97 /* ThisKeyword */; - } function parameterNameStartsWithUnderscore(parameter) { return parameter.name && parameter.name.kind === 69 /* Identifier */ && parameter.name.text.charCodeAt(0) === 95 /* _ */; } @@ -35772,6 +36982,10 @@ var ts; } } function checkCollisionWithRequireExportsInGeneratedCode(node, name) { + // No need to check for require or exports for ES6 modules and later + if (modulekind >= ts.ModuleKind.ES6) { + return; + } if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } @@ -35926,6 +37140,9 @@ var ts; } } } + function convertAutoToAny(type) { + return type === autoType ? anyType : type; + } // Check variable, parameter, or property declaration function checkVariableLikeDeclaration(node) { checkDecorators(node); @@ -35946,12 +37163,12 @@ var ts; checkComputedPropertyName(node.propertyName); } // check private/protected variable access - var parent_12 = node.parent.parent; - var parentType = getTypeForBindingElementParent(parent_12); + var parent_13 = node.parent.parent; + var parentType = getTypeForBindingElementParent(parent_13); var name_21 = node.propertyName || node.name; var property = getPropertyOfType(parentType, getTextOfPropertyName(name_21)); - if (parent_12.initializer && property && getParentOfSymbol(property)) { - checkClassPropertyAccess(parent_12, parent_12.initializer, parentType, property); + if (parent_13.initializer && property && getParentOfSymbol(property)) { + checkClassPropertyAccess(parent_13, parent_13.initializer, parentType, property); } } // For a binding pattern, check contained binding elements @@ -35973,7 +37190,7 @@ var ts; return; } var symbol = getSymbolOfNode(node); - var type = getTypeOfVariableOrParameterOrProperty(symbol); + var type = convertAutoToAny(getTypeOfVariableOrParameterOrProperty(symbol)); if (node === symbol.valueDeclaration) { // Node is the primary declaration of the symbol, just validate the initializer // Don't validate for-in initializer as it is already an error @@ -35985,7 +37202,7 @@ var ts; else { // Node is a secondary declaration, check that type is identical to primary declaration and check that // initializer is consistent with type associated with the node - var declarationType = getWidenedTypeForVariableLikeDeclaration(node); + var declarationType = convertAutoToAny(getWidenedTypeForVariableLikeDeclaration(node)); if (type !== unknownType && declarationType !== unknownType && !isTypeIdenticalTo(type, declarationType)) { error(node.name, ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2, ts.declarationNameToString(node.name), typeToString(type), typeToString(declarationType)); } @@ -36480,7 +37697,12 @@ var ts; } } checkExpression(node.expression); - error(node.expression, ts.Diagnostics.All_symbols_within_a_with_block_will_be_resolved_to_any); + var sourceFile = ts.getSourceFileOfNode(node); + if (!hasParseDiagnostics(sourceFile)) { + var start = ts.getSpanOfTokenAtPosition(sourceFile, node.pos).start; + var end = node.statement.pos; + grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any); + } } function checkSwitchStatement(node) { // Grammar checking @@ -37288,9 +38510,11 @@ var ts; grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } } - checkCollisionWithCapturedThisVariable(node, node.name); - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); + if (ts.isIdentifier(node.name)) { + checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); + } checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); // The following checks only apply on a non-ambient instantiated module declaration. @@ -37568,9 +38792,11 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - if (node.parent.kind !== 256 /* SourceFile */ && node.parent.kind !== 226 /* ModuleBlock */ && node.parent.kind !== 225 /* ModuleDeclaration */) { - return grammarErrorOnFirstToken(node, errorMessage); + var isInAppropriateContext = node.parent.kind === 256 /* SourceFile */ || node.parent.kind === 226 /* ModuleBlock */ || node.parent.kind === 225 /* ModuleDeclaration */; + if (!isInAppropriateContext) { + grammarErrorOnFirstToken(node, errorMessage); } + return !isInAppropriateContext; } function checkExportSpecifier(node) { checkAliasSymbol(node); @@ -37668,7 +38894,8 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return declaration.kind !== 220 /* FunctionDeclaration */ || !!declaration.body; + return (declaration.kind !== 220 /* FunctionDeclaration */ && declaration.kind !== 147 /* MethodDeclaration */) || + !!declaration.body; } } function checkSourceElement(node) { @@ -38202,6 +39429,9 @@ var ts; node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } + if (ts.isInJavaScriptFile(node) && ts.isRequireCall(node.parent, /*checkArgumentIsStringLiteral*/ false)) { + return resolveExternalModuleName(node, node); + } // Fall through case 8 /* NumericLiteral */: // index access @@ -38726,9 +39956,9 @@ var ts; if (startInDeclarationContainer) { // When resolving the name of a declaration as a value, we need to start resolution // at a point outside of the declaration. - var parent_13 = reference.parent; - if (ts.isDeclaration(parent_13) && reference === parent_13.name) { - location = getDeclarationContainer(parent_13); + var parent_14 = reference.parent; + if (ts.isDeclaration(parent_14) && reference === parent_14.name) { + location = getDeclarationContainer(parent_14); } } return resolveName(location, reference.text, 107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); @@ -38852,9 +40082,9 @@ var ts; // external modules cannot define or contribute to type declaration files var current = symbol; while (true) { - var parent_14 = getParentOfSymbol(current); - if (parent_14) { - current = parent_14; + var parent_15 = getParentOfSymbol(current); + if (parent_15) { + current = parent_15; } else { break; @@ -39437,8 +40667,8 @@ var ts; function checkGrammarForOmittedArgument(node, args) { if (args) { var sourceFile = ts.getSourceFileOfNode(node); - for (var _i = 0, args_2 = args; _i < args_2.length; _i++) { - var arg = args_2[_i]; + for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { + var arg = args_4[_i]; if (arg.kind === 193 /* OmittedExpression */) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } @@ -39550,8 +40780,7 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; var name_24 = prop.name; - if (prop.kind === 193 /* OmittedExpression */ || - name_24.kind === 140 /* ComputedPropertyName */) { + if (name_24.kind === 140 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name_24); } @@ -39731,17 +40960,8 @@ var ts; return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 149 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 149 /* GetAccessor */ ? 1 : 2) && - accessor.parameters[0].name.kind === 69 /* Identifier */ && - accessor.parameters[0].name.originalKeywordKind === 97 /* ThisKeyword */) { - return accessor.parameters[0]; - } - } - function getFunctionLikeThisParameter(func) { - if (func.parameters.length && - func.parameters[0].name.kind === 69 /* Identifier */ && - func.parameters[0].name.originalKeywordKind === 97 /* ThisKeyword */) { - return func.parameters[0]; + if (accessor.parameters.length === (accessor.kind === 149 /* GetAccessor */ ? 1 : 2)) { + return ts.getThisParameter(accessor); } } function checkGrammarForNonSymbolComputedProperty(node, message) { @@ -40673,7 +41893,7 @@ var ts; case 175 /* NewExpression */: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); case 176 /* TaggedTemplateExpression */: - return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplate)); + return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); case 178 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); case 179 /* FunctionExpression */: @@ -40697,7 +41917,7 @@ var ts; case 188 /* ConditionalExpression */: return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); case 189 /* TemplateExpression */: - return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateLiteralFragment), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); + return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); case 190 /* YieldExpression */: return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); case 191 /* SpreadElementExpression */: @@ -40708,7 +41928,7 @@ var ts; return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); // Misc case 197 /* TemplateSpan */: - return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateLiteralFragment)); + return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element case 199 /* Block */: return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); @@ -41055,7 +42275,7 @@ var ts; var expression = ts.createAssignment(name, value, location); // NOTE: this completely disables source maps, but aligns with the behavior of // `emitAssignment` in the old emitter. - context.setNodeEmitFlags(expression, 2048 /* NoNestedSourceMaps */); + ts.setEmitFlags(expression, 2048 /* NoNestedSourceMaps */); ts.aggregateTransformFlags(expression); expressions.push(expression); } @@ -41081,7 +42301,7 @@ var ts; var declaration = ts.createVariableDeclaration(name, /*type*/ undefined, value, location); // NOTE: this completely disables source maps, but aligns with the behavior of // `emitAssignment` in the old emitter. - context.setNodeEmitFlags(declaration, 2048 /* NoNestedSourceMaps */); + ts.setEmitFlags(declaration, 2048 /* NoNestedSourceMaps */); ts.aggregateTransformFlags(declaration); declarations.push(declaration); } @@ -41114,7 +42334,7 @@ var ts; declaration.original = original; // NOTE: this completely disables source maps, but aligns with the behavior of // `emitAssignment` in the old emitter. - context.setNodeEmitFlags(declaration, 2048 /* NoNestedSourceMaps */); + ts.setEmitFlags(declaration, 2048 /* NoNestedSourceMaps */); declarations.push(declaration); ts.aggregateTransformFlags(declaration); } @@ -41164,7 +42384,7 @@ var ts; expression.original = original; // NOTE: this completely disables source maps, but aligns with the behavior of // `emitAssignment` in the old emitter. - context.setNodeEmitFlags(expression, 2048 /* NoNestedSourceMaps */); + ts.setEmitFlags(expression, 2048 /* NoNestedSourceMaps */); pendingAssignments.push(expression); return expression; } @@ -41210,8 +42430,8 @@ var ts; } else { var name_26 = ts.getMutableClone(target); - context.setSourceMapRange(name_26, target); - context.setCommentRange(name_26, target); + ts.setSourceMapRange(name_26, target); + ts.setCommentRange(name_26, target); emitAssignment(name_26, value, location, /*original*/ undefined); } } @@ -41380,7 +42600,7 @@ var ts; TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["NonQualifiedEnumMembers"] = 8] = "NonQualifiedEnumMembers"; })(TypeScriptSubstitutionFlags || (TypeScriptSubstitutionFlags = {})); function transformTypeScript(context) { - var getNodeEmitFlags = context.getNodeEmitFlags, setNodeEmitFlags = context.setNodeEmitFlags, setCommentRange = context.setCommentRange, setSourceMapRange = context.setSourceMapRange, startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); var compilerOptions = context.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); @@ -41391,11 +42611,15 @@ var ts; // Set new transformation hooks. context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; + // Enable substitution for property/element access to emit const enum values. + context.enableSubstitution(172 /* PropertyAccessExpression */); + context.enableSubstitution(173 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; var currentNamespaceContainerName; var currentScope; + var currentScopeFirstDeclarationsOfName; var currentSourceFileExternalHelpersModuleName; /** * Keeps track of whether expression substitution has been enabled for specific edge cases. @@ -41424,6 +42648,9 @@ var ts; * @param node A SourceFile node. */ function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } return ts.visitNode(node, visitor, ts.isSourceFile); } /** @@ -41434,10 +42661,14 @@ var ts; function saveStateAndInvoke(node, f) { // Save state var savedCurrentScope = currentScope; + var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName; // Handle state changes before visiting a node. onBeforeVisitNode(node); var visited = f(node); // Restore state + if (currentScope !== savedCurrentScope) { + currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; + } currentScope = savedCurrentScope; return visited; } @@ -41702,11 +42933,23 @@ var ts; case 226 /* ModuleBlock */: case 199 /* Block */: currentScope = node; + currentScopeFirstDeclarationsOfName = undefined; + break; + case 221 /* ClassDeclaration */: + case 220 /* FunctionDeclaration */: + if (ts.hasModifier(node, 2 /* Ambient */)) { + break; + } + recordEmittedDeclarationInScope(node); break; } } function visitSourceFile(node) { currentSourceFile = node; + // ensure "use strict" is emitted in all scenarios in alwaysStrict mode + if (compilerOptions.alwaysStrict) { + node = ts.ensureUseStrict(node); + } // If the source file requires any helpers and is an external module, and // the importHelpers compiler option is enabled, emit a synthesized import // statement for the helpers library. @@ -41733,7 +42976,7 @@ var ts; else { node = ts.visitEachChild(node, visitor, context); } - setNodeEmitFlags(node, 1 /* EmitEmitHelpers */ | node.emitFlags); + ts.setEmitFlags(node, 1 /* EmitEmitHelpers */ | ts.getEmitFlags(node)); return node; } /** @@ -41792,7 +43035,7 @@ var ts; // To better align with the old emitter, we should not emit a trailing source map // entry if the class has static properties. if (staticProperties.length > 0) { - setNodeEmitFlags(classDeclaration, 1024 /* NoTrailingSourceMap */ | getNodeEmitFlags(classDeclaration)); + ts.setEmitFlags(classDeclaration, 1024 /* NoTrailingSourceMap */ | ts.getEmitFlags(classDeclaration)); } statements.push(classDeclaration); } @@ -41951,7 +43194,7 @@ var ts; /*type*/ undefined, classExpression) ]), /*location*/ location); - setCommentRange(transformedClassExpression, node); + ts.setCommentRange(transformedClassExpression, node); statements.push(ts.setOriginalNode( /*node*/ transformedClassExpression, /*original*/ node)); @@ -41996,7 +43239,7 @@ var ts; } // To preserve the behavior of the old emitter, we explicitly indent // the body of a class with static initializers. - setNodeEmitFlags(classExpression, 524288 /* Indented */ | getNodeEmitFlags(classExpression)); + ts.setEmitFlags(classExpression, 524288 /* Indented */ | ts.getEmitFlags(classExpression)); expressions.push(ts.startOnNewLine(ts.createAssignment(temp, classExpression))); ts.addRange(expressions, generateInitializedPropertyExpressions(node, staticProperties, temp)); expressions.push(ts.startOnNewLine(temp)); @@ -42151,7 +43394,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 202 /* ExpressionStatement */ && ts.isSuperCallExpression(statement.expression)) { + if (statement.kind === 202 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -42185,9 +43428,9 @@ var ts; ts.Debug.assert(ts.isIdentifier(node.name)); var name = node.name; var propertyName = ts.getMutableClone(name); - setNodeEmitFlags(propertyName, 49152 /* NoComments */ | 1536 /* NoSourceMap */); + ts.setEmitFlags(propertyName, 49152 /* NoComments */ | 1536 /* NoSourceMap */); var localName = ts.getMutableClone(name); - setNodeEmitFlags(localName, 49152 /* NoComments */); + ts.setEmitFlags(localName, 49152 /* NoComments */); return ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createThis(), propertyName, /*location*/ node.name), localName), /*location*/ ts.moveRangePos(node, -1))); @@ -42239,8 +43482,8 @@ var ts; for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) { var property = properties_7[_i]; var statement = ts.createStatement(transformInitializedProperty(node, property, receiver)); - setSourceMapRange(statement, ts.moveRangePastModifiers(property)); - setCommentRange(statement, property); + ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property)); + ts.setCommentRange(statement, property); statements.push(statement); } } @@ -42257,8 +43500,8 @@ var ts; var property = properties_8[_i]; var expression = transformInitializedProperty(node, property, receiver); expression.startsOnNewLine = true; - setSourceMapRange(expression, ts.moveRangePastModifiers(property)); - setCommentRange(expression, property); + ts.setSourceMapRange(expression, ts.moveRangePastModifiers(property)); + ts.setCommentRange(expression, property); expressions.push(expression); } return expressions; @@ -42524,7 +43767,7 @@ var ts; : ts.createNull() : undefined; var helper = ts.createDecorateHelper(currentSourceFileExternalHelpersModuleName, decoratorExpressions, prefix, memberName, descriptor, ts.moveRangePastDecorators(member)); - setNodeEmitFlags(helper, 49152 /* NoComments */); + ts.setEmitFlags(helper, 49152 /* NoComments */); return helper; } /** @@ -42562,12 +43805,12 @@ var ts; if (decoratedClassAlias) { var expression = ts.createAssignment(decoratedClassAlias, ts.createDecorateHelper(currentSourceFileExternalHelpersModuleName, decoratorExpressions, getDeclarationName(node))); var result = ts.createAssignment(getDeclarationName(node), expression, ts.moveRangePastDecorators(node)); - setNodeEmitFlags(result, 49152 /* NoComments */); + ts.setEmitFlags(result, 49152 /* NoComments */); return result; } else { var result = ts.createAssignment(getDeclarationName(node), ts.createDecorateHelper(currentSourceFileExternalHelpersModuleName, decoratorExpressions, getDeclarationName(node)), ts.moveRangePastDecorators(node)); - setNodeEmitFlags(result, 49152 /* NoComments */); + ts.setEmitFlags(result, 49152 /* NoComments */); return result; } } @@ -42593,7 +43836,7 @@ var ts; var decorator = decorators_1[_i]; var helper = ts.createParamHelper(currentSourceFileExternalHelpersModuleName, transformDecorator(decorator), parameterOffset, /*location*/ decorator.expression); - setNodeEmitFlags(helper, 49152 /* NoComments */); + ts.setEmitFlags(helper, 49152 /* NoComments */); expressions.push(helper); } } @@ -42824,10 +44067,38 @@ var ts; : ts.createIdentifier("Symbol"); case 155 /* TypeReference */: return serializeTypeReferenceNode(node); + case 163 /* IntersectionType */: + case 162 /* UnionType */: + { + var unionOrIntersection = node; + var serializedUnion = void 0; + for (var _i = 0, _a = unionOrIntersection.types; _i < _a.length; _i++) { + var typeNode = _a[_i]; + var serializedIndividual = serializeTypeNode(typeNode); + // Non identifier + if (serializedIndividual.kind !== 69 /* Identifier */) { + serializedUnion = undefined; + break; + } + // One of the individual is global object, return immediately + if (serializedIndividual.text === "Object") { + return serializedIndividual; + } + // Different types + if (serializedUnion && serializedUnion.text !== serializedIndividual.text) { + serializedUnion = undefined; + break; + } + serializedUnion = serializedIndividual; + } + // If we were able to find common type + if (serializedUnion) { + return serializedUnion; + } + } + // Fallthrough case 158 /* TypeQuery */: case 159 /* TypeLiteral */: - case 162 /* UnionType */: - case 163 /* IntersectionType */: case 117 /* AnyKeyword */: case 165 /* ThisType */: break; @@ -43027,8 +44298,8 @@ var ts; /*location*/ node); // While we emit the source map for the node after skipping decorators and modifiers, // we need to emit the comments for the original range. - setCommentRange(method, node); - setSourceMapRange(method, ts.moveRangePastDecorators(node)); + ts.setCommentRange(method, node); + ts.setSourceMapRange(method, ts.moveRangePastDecorators(node)); ts.setOriginalNode(method, node); return method; } @@ -43060,8 +44331,8 @@ var ts; /*location*/ node); // While we emit the source map for the node after skipping decorators and modifiers, // we need to emit the comments for the original range. - setCommentRange(accessor, node); - setSourceMapRange(accessor, ts.moveRangePastDecorators(node)); + ts.setCommentRange(accessor, node); + ts.setSourceMapRange(accessor, ts.moveRangePastDecorators(node)); ts.setOriginalNode(accessor, node); return accessor; } @@ -43083,8 +44354,8 @@ var ts; /*location*/ node); // While we emit the source map for the node after skipping decorators and modifiers, // we need to emit the comments for the original range. - setCommentRange(accessor, node); - setSourceMapRange(accessor, ts.moveRangePastDecorators(node)); + ts.setCommentRange(accessor, node); + ts.setSourceMapRange(accessor, ts.moveRangePastDecorators(node)); ts.setOriginalNode(accessor, node); return accessor; } @@ -43220,11 +44491,11 @@ var ts; if (languageVersion >= 2 /* ES6 */) { if (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) { enableSubstitutionForAsyncMethodsWithSuper(); - setNodeEmitFlags(block, 8 /* EmitAdvancedSuperHelper */); + ts.setEmitFlags(block, 8 /* EmitAdvancedSuperHelper */); } else if (resolver.getNodeCheckFlags(node) & 2048 /* AsyncMethodWithSuper */) { enableSubstitutionForAsyncMethodsWithSuper(); - setNodeEmitFlags(block, 4 /* EmitSuperHelper */); + ts.setEmitFlags(block, 4 /* EmitSuperHelper */); } } return block; @@ -43244,7 +44515,7 @@ var ts; * @param node The parameter declaration node. */ function visitParameter(node) { - if (node.name && ts.isIdentifier(node.name) && node.name.originalKeywordKind === 97 /* ThisKeyword */) { + if (ts.parameterIsThisKeyword(node)) { return undefined; } var parameter = ts.createParameterDeclaration( @@ -43256,9 +44527,9 @@ var ts; // While we emit the source map for the node after skipping decorators and modifiers, // we need to emit the comments for the original range. ts.setOriginalNode(parameter, node); - setCommentRange(parameter, node); - setSourceMapRange(parameter, ts.moveRangePastModifiers(node)); - setNodeEmitFlags(parameter.name, 1024 /* NoTrailingSourceMap */); + ts.setCommentRange(parameter, node); + ts.setSourceMapRange(parameter, ts.moveRangePastModifiers(node)); + ts.setEmitFlags(parameter.name, 1024 /* NoTrailingSourceMap */); return parameter; } /** @@ -43351,8 +44622,9 @@ var ts; || compilerOptions.isolatedModules; } function shouldEmitVarForEnumDeclaration(node) { - return !ts.hasModifier(node, 1 /* Export */) - || (isES6ExportedDeclaration(node) && ts.isFirstDeclarationOfKind(node, node.kind)); + return isFirstEmittedDeclarationInScope(node) + && (!ts.hasModifier(node, 1 /* Export */) + || isES6ExportedDeclaration(node)); } /* * Adds a trailing VariableStatement for an enum or module declaration. @@ -43361,7 +44633,7 @@ var ts; var statement = ts.createVariableStatement( /*modifiers*/ undefined, [ts.createVariableDeclaration(getDeclarationName(node), /*type*/ undefined, getExportName(node))]); - setSourceMapRange(statement, node); + ts.setSourceMapRange(statement, node); statements.push(statement); } /** @@ -43382,6 +44654,7 @@ var ts; // If needed, we should emit a variable declaration for the enum. If we emit // a leading variable declaration, we should not emit leading comments for the // enum body. + recordEmittedDeclarationInScope(node); if (shouldEmitVarForEnumDeclaration(node)) { addVarForEnumOrModuleDeclaration(statements, node); // We should still emit the comments if we are emitting a system module. @@ -43407,7 +44680,7 @@ var ts; /*typeArguments*/ undefined, [ts.createLogicalOr(exportName, ts.createAssignment(exportName, ts.createObjectLiteral()))]), /*location*/ node); ts.setOriginalNode(enumStatement, node); - setNodeEmitFlags(enumStatement, emitFlags); + ts.setEmitFlags(enumStatement, emitFlags); statements.push(enumStatement); if (isNamespaceExport(node)) { addVarForEnumExportedFromNamespace(statements, node); @@ -43473,18 +44746,43 @@ var ts; function shouldEmitModuleDeclaration(node) { return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); } - function isModuleMergedWithES6Class(node) { - return languageVersion === 2 /* ES6 */ - && ts.isMergedWithClass(node); - } function isES6ExportedDeclaration(node) { return isExternalModuleExport(node) && moduleKind === ts.ModuleKind.ES6; } + /** + * Records that a declaration was emitted in the current scope, if it was the first + * declaration for the provided symbol. + * + * NOTE: if there is ever a transformation above this one, we may not be able to rely + * on symbol names. + */ + function recordEmittedDeclarationInScope(node) { + var name = node.symbol && node.symbol.name; + if (name) { + if (!currentScopeFirstDeclarationsOfName) { + currentScopeFirstDeclarationsOfName = ts.createMap(); + } + if (!(name in currentScopeFirstDeclarationsOfName)) { + currentScopeFirstDeclarationsOfName[name] = node; + } + } + } + /** + * Determines whether a declaration is the first declaration with the same name emitted + * in the current scope. + */ + function isFirstEmittedDeclarationInScope(node) { + if (currentScopeFirstDeclarationsOfName) { + var name_28 = node.symbol && node.symbol.name; + if (name_28) { + return currentScopeFirstDeclarationsOfName[name_28] === node; + } + } + return false; + } function shouldEmitVarForModuleDeclaration(node) { - return !isModuleMergedWithES6Class(node) - && (!isES6ExportedDeclaration(node) - || ts.isFirstDeclarationOfKind(node, node.kind)); + return isFirstEmittedDeclarationInScope(node); } /** * Adds a leading VariableStatement for a enum or module declaration. @@ -43499,10 +44797,10 @@ var ts; ts.setOriginalNode(statement, /*original*/ node); // Adjust the source map emit to match the old emitter. if (node.kind === 224 /* EnumDeclaration */) { - setSourceMapRange(statement.declarationList, node); + ts.setSourceMapRange(statement.declarationList, node); } else { - setSourceMapRange(statement, node); + ts.setSourceMapRange(statement, node); } // Trailing comments for module declaration should be emitted after the function closure // instead of the variable statement: @@ -43522,8 +44820,8 @@ var ts; // } // })(m1 || (m1 = {})); // trailing comment module // - setCommentRange(statement, node); - setNodeEmitFlags(statement, 32768 /* NoTrailingComments */); + ts.setCommentRange(statement, node); + ts.setEmitFlags(statement, 32768 /* NoTrailingComments */); statements.push(statement); } /** @@ -43546,6 +44844,7 @@ var ts; // If needed, we should emit a variable declaration for the module. If we emit // a leading variable declaration, we should not emit leading comments for the // module body. + recordEmittedDeclarationInScope(node); if (shouldEmitVarForModuleDeclaration(node)) { addVarForEnumOrModuleDeclaration(statements, node); // We should still emit the comments if we are emitting a system module. @@ -43579,7 +44878,7 @@ var ts; /*typeArguments*/ undefined, [moduleArg]), /*location*/ node); ts.setOriginalNode(moduleStatement, node); - setNodeEmitFlags(moduleStatement, emitFlags); + ts.setEmitFlags(moduleStatement, emitFlags); statements.push(moduleStatement); return statements; } @@ -43591,8 +44890,10 @@ var ts; function transformModuleBody(node, namespaceLocalName) { var savedCurrentNamespaceContainerName = currentNamespaceContainerName; var savedCurrentNamespace = currentNamespace; + var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName; currentNamespaceContainerName = namespaceLocalName; currentNamespace = node; + currentScopeFirstDeclarationsOfName = undefined; var statements = []; startLexicalEnvironment(); var statementsLocation; @@ -43619,6 +44920,7 @@ var ts; ts.addRange(statements, endLexicalEnvironment()); currentNamespaceContainerName = savedCurrentNamespaceContainerName; currentNamespace = savedCurrentNamespace; + currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; var block = ts.createBlock(ts.createNodeArray(statements, /*location*/ statementsLocation), /*location*/ blockLocation, @@ -43644,7 +44946,7 @@ var ts; // })(hello || (hello = {})); // We only want to emit comment on the namespace which contains block body itself, not the containing namespaces. if (body.kind !== 226 /* ModuleBlock */) { - setNodeEmitFlags(block, block.emitFlags | 49152 /* NoComments */); + ts.setEmitFlags(block, ts.getEmitFlags(block) | 49152 /* NoComments */); } return block; } @@ -43680,7 +44982,7 @@ var ts; return undefined; } var moduleReference = ts.createExpressionFromEntityName(node.moduleReference); - setNodeEmitFlags(moduleReference, 49152 /* NoComments */ | 65536 /* NoNestedComments */); + ts.setEmitFlags(moduleReference, 49152 /* NoComments */ | 65536 /* NoNestedComments */); if (isNamedExternalModuleExport(node) || !isNamespaceExport(node)) { // export var ${name} = ${moduleReference}; // var ${name} = ${moduleReference}; @@ -43736,9 +45038,9 @@ var ts; } function addExportMemberAssignment(statements, node) { var expression = ts.createAssignment(getExportName(node), getLocalName(node, /*noSourceMaps*/ true)); - setSourceMapRange(expression, ts.createRange(node.name.pos, node.end)); + ts.setSourceMapRange(expression, ts.createRange(node.name.pos, node.end)); var statement = ts.createStatement(expression); - setSourceMapRange(statement, ts.createRange(-1, node.end)); + ts.setSourceMapRange(statement, ts.createRange(-1, node.end)); statements.push(statement); } function createNamespaceExport(exportName, exportValue, location) { @@ -43761,7 +45063,7 @@ var ts; emitFlags |= 1536 /* NoSourceMap */; } if (emitFlags) { - setNodeEmitFlags(qualifiedName, emitFlags); + ts.setEmitFlags(qualifiedName, emitFlags); } return qualifiedName; } @@ -43773,7 +45075,7 @@ var ts; */ function getNamespaceParameterName(node) { var name = ts.getGeneratedNameForNode(node); - setSourceMapRange(name, node.name); + ts.setSourceMapRange(name, node.name); return name; } /** @@ -43822,8 +45124,8 @@ var ts; */ function getDeclarationName(node, allowComments, allowSourceMaps, emitFlags) { if (node.name) { - var name_28 = ts.getMutableClone(node.name); - emitFlags |= getNodeEmitFlags(node.name); + var name_29 = ts.getMutableClone(node.name); + emitFlags |= ts.getEmitFlags(node.name); if (!allowSourceMaps) { emitFlags |= 1536 /* NoSourceMap */; } @@ -43831,9 +45133,9 @@ var ts; emitFlags |= 49152 /* NoComments */; } if (emitFlags) { - setNodeEmitFlags(name_28, emitFlags); + ts.setEmitFlags(name_29, emitFlags); } - return name_28; + return name_29; } else { return ts.getGeneratedNameForNode(node); @@ -43910,7 +45212,7 @@ var ts; * @param node The node to emit. * @param emit A callback used to emit the node in the printer. */ - function onEmitNode(node, emit) { + function onEmitNode(emitContext, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; var savedCurrentSuperContainer = currentSuperContainer; // If we need to support substitutions for `super` in an async method, @@ -43924,7 +45226,7 @@ var ts; if (enabledSubstitutions & 8 /* NonQualifiedEnumMembers */ && isTransformedEnumDeclaration(node)) { applicableSubstitutions |= 8 /* NonQualifiedEnumMembers */; } - previousOnEmitNode(node, emit); + previousOnEmitNode(emitContext, node, emitCallback); applicableSubstitutions = savedApplicableSubstitutions; currentSuperContainer = savedCurrentSuperContainer; } @@ -43935,9 +45237,9 @@ var ts; * @param isExpression A value indicating whether the node is to be used in an expression * position. */ - function onSubstituteNode(node, isExpression) { - node = previousOnSubstituteNode(node, isExpression); - if (isExpression) { + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1 /* Expression */) { return substituteExpression(node); } else if (ts.isShorthandPropertyAssignment(node)) { @@ -43947,16 +45249,16 @@ var ts; } function substituteShorthandPropertyAssignment(node) { if (enabledSubstitutions & 2 /* NamespaceExports */) { - var name_29 = node.name; - var exportedName = trySubstituteNamespaceExportedName(name_29); + var name_30 = node.name; + var exportedName = trySubstituteNamespaceExportedName(name_30); if (exportedName) { // A shorthand property with an assignment initializer is probably part of a // destructuring assignment if (node.objectAssignmentInitializer) { var initializer = ts.createAssignment(exportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name_29, initializer, /*location*/ node); + return ts.createPropertyAssignment(name_30, initializer, /*location*/ node); } - return ts.createPropertyAssignment(name_29, exportedName, /*location*/ node); + return ts.createPropertyAssignment(name_30, exportedName, /*location*/ node); } } return node; @@ -43965,16 +45267,15 @@ var ts; switch (node.kind) { case 69 /* Identifier */: return substituteExpressionIdentifier(node); - } - if (enabledSubstitutions & 4 /* AsyncMethodsWithSuper */) { - switch (node.kind) { - case 174 /* CallExpression */: + case 172 /* PropertyAccessExpression */: + return substitutePropertyAccessExpression(node); + case 173 /* ElementAccessExpression */: + return substituteElementAccessExpression(node); + case 174 /* CallExpression */: + if (enabledSubstitutions & 4 /* AsyncMethodsWithSuper */) { return substituteCallExpression(node); - case 172 /* PropertyAccessExpression */: - return substitutePropertyAccessExpression(node); - case 173 /* ElementAccessExpression */: - return substituteElementAccessExpression(node); - } + } + break; } return node; } @@ -43996,8 +45297,8 @@ var ts; var classAlias = classAliases[declaration.id]; if (classAlias) { var clone_4 = ts.getSynthesizedClone(classAlias); - setSourceMapRange(clone_4, node); - setCommentRange(clone_4, node); + ts.setSourceMapRange(clone_4, node); + ts.setCommentRange(clone_4, node); return clone_4; } } @@ -44007,7 +45308,7 @@ var ts; } function trySubstituteNamespaceExportedName(node) { // If this is explicitly a local name, do not substitute. - if (enabledSubstitutions & applicableSubstitutions && (getNodeEmitFlags(node) & 262144 /* LocalName */) === 0) { + if (enabledSubstitutions & applicableSubstitutions && (ts.getEmitFlags(node) & 262144 /* LocalName */) === 0) { // If we are nested within a namespace declaration, we may need to qualifiy // an identifier that is exported from a merged namespace. var container = resolver.getReferencedExportContainer(node, /*prefixLocals*/ false); @@ -44038,23 +45339,48 @@ var ts; return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 95 /* SuperKeyword */) { + if (enabledSubstitutions & 4 /* AsyncMethodsWithSuper */ && node.expression.kind === 95 /* SuperKeyword */) { var flags = getSuperContainerAsyncMethodFlags(); if (flags) { return createSuperAccessInAsyncMethod(ts.createLiteral(node.name.text), flags, node); } } - return node; + return substituteConstantValue(node); } function substituteElementAccessExpression(node) { - if (node.expression.kind === 95 /* SuperKeyword */) { + if (enabledSubstitutions & 4 /* AsyncMethodsWithSuper */ && node.expression.kind === 95 /* SuperKeyword */) { var flags = getSuperContainerAsyncMethodFlags(); if (flags) { return createSuperAccessInAsyncMethod(node.argumentExpression, flags, node); } } + return substituteConstantValue(node); + } + function substituteConstantValue(node) { + var constantValue = tryGetConstEnumValue(node); + if (constantValue !== undefined) { + var substitute = ts.createLiteral(constantValue); + ts.setSourceMapRange(substitute, node); + ts.setCommentRange(substitute, node); + if (!compilerOptions.removeComments) { + var propertyName = ts.isPropertyAccessExpression(node) + ? ts.declarationNameToString(node.name) + : ts.getTextOfNode(node.argumentExpression); + substitute.trailingComment = " " + propertyName + " "; + } + ts.setConstantValue(node, constantValue); + return substitute; + } return node; } + function tryGetConstEnumValue(node) { + if (compilerOptions.isolatedModules) { + return undefined; + } + return ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node) + ? resolver.getConstantValue(node) + : undefined; + } function createSuperAccessInAsyncMethod(argumentExpression, flags, location) { if (flags & 4096 /* AsyncMethodWithSuperBinding */) { return ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), @@ -44083,6 +45409,9 @@ var ts; var currentSourceFile; return transformSourceFile; function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { currentSourceFile = node; return ts.visitEachChild(node, visitor, context); @@ -44201,7 +45530,7 @@ var ts; var ts; (function (ts) { function transformSystemModule(context) { - var getNodeEmitFlags = context.getNodeEmitFlags, setNodeEmitFlags = context.setNodeEmitFlags, startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration, hoistFunctionDeclaration = context.hoistFunctionDeclaration; + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration, hoistFunctionDeclaration = context.hoistFunctionDeclaration; var compilerOptions = context.getCompilerOptions(); var resolver = context.getEmitResolver(); var host = context.getEmitHost(); @@ -44230,6 +45559,9 @@ var ts; var currentNode; return transformSourceFile; function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { currentSourceFile = node; currentNode = node; @@ -44283,7 +45615,7 @@ var ts; ts.createParameter(exportFunctionForFile), ts.createParameter(contextObjectForFile) ], - /*type*/ undefined, setNodeEmitFlags(ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true), 1 /* EmitEmitHelpers */)); + /*type*/ undefined, ts.setEmitFlags(ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true), 1 /* EmitEmitHelpers */)); // Write the call to `System.register` // Clear the emit-helpers flag for later passes since we'll have already used it in the module body // So the helper will be emit at the correct position instead of at the top of the source-file @@ -44292,7 +45624,7 @@ var ts; /*typeArguments*/ undefined, moduleName ? [moduleName, dependencies, body] : [dependencies, body])) - ], /*nodeEmitFlags*/ ~1 /* EmitEmitHelpers */ & getNodeEmitFlags(node)); + ], /*nodeEmitFlags*/ ~1 /* EmitEmitHelpers */ & ts.getEmitFlags(node)); var _a; } /** @@ -44676,17 +46008,17 @@ var ts; function visitFunctionDeclaration(node) { if (ts.hasModifier(node, 1 /* Export */)) { // If the function is exported, ensure it has a name and rewrite the function without any export flags. - var name_30 = node.name || ts.getGeneratedNameForNode(node); + var name_31 = node.name || ts.getGeneratedNameForNode(node); var newNode = ts.createFunctionDeclaration( /*decorators*/ undefined, - /*modifiers*/ undefined, node.asteriskToken, name_30, + /*modifiers*/ undefined, node.asteriskToken, name_31, /*typeParameters*/ undefined, node.parameters, /*type*/ undefined, node.body, /*location*/ node); // Record a declaration export in the outer module body function. recordExportedFunctionDeclaration(node); if (!ts.hasModifier(node, 512 /* Default */)) { - recordExportName(name_30); + recordExportName(name_31); } ts.setOriginalNode(newNode, node); node = newNode; @@ -44698,16 +46030,16 @@ var ts; function visitExpressionStatement(node) { var originalNode = ts.getOriginalNode(node); if ((originalNode.kind === 225 /* ModuleDeclaration */ || originalNode.kind === 224 /* EnumDeclaration */) && ts.hasModifier(originalNode, 1 /* Export */)) { - var name_31 = getDeclarationName(originalNode); + var name_32 = getDeclarationName(originalNode); // We only need to hoistVariableDeclaration for EnumDeclaration // as ModuleDeclaration is already hoisted when the transformer call visitVariableStatement // which then call transformsVariable for each declaration in declarationList if (originalNode.kind === 224 /* EnumDeclaration */) { - hoistVariableDeclaration(name_31); + hoistVariableDeclaration(name_32); } return [ node, - createExportStatement(name_31, name_31) + createExportStatement(name_32, name_32) ]; } return node; @@ -44952,14 +46284,14 @@ var ts; // // Substitutions // - function onEmitNode(node, emit) { + function onEmitNode(emitContext, node, emitCallback) { if (node.kind === 256 /* SourceFile */) { exportFunctionForFile = exportFunctionForFileMap[ts.getOriginalNodeId(node)]; - previousOnEmitNode(node, emit); + previousOnEmitNode(emitContext, node, emitCallback); exportFunctionForFile = undefined; } else { - previousOnEmitNode(node, emit); + previousOnEmitNode(emitContext, node, emitCallback); } } /** @@ -44969,9 +46301,9 @@ var ts; * @param isExpression A value indicating whether the node is to be used in an expression * position. */ - function onSubstituteNode(node, isExpression) { - node = previousOnSubstituteNode(node, isExpression); - if (isExpression) { + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1 /* Expression */) { return substituteExpression(node); } return node; @@ -45013,7 +46345,7 @@ var ts; return node; } function substituteAssignmentExpression(node) { - setNodeEmitFlags(node, 128 /* NoSubstitution */); + ts.setEmitFlags(node, 128 /* NoSubstitution */); var left = node.left; switch (left.kind) { case 69 /* Identifier */: @@ -45118,7 +46450,7 @@ var ts; var exportDeclaration = resolver.getReferencedExportContainer(operand); if (exportDeclaration) { var expr = ts.createPrefix(node.operator, operand, node); - setNodeEmitFlags(expr, 128 /* NoSubstitution */); + ts.setEmitFlags(expr, 128 /* NoSubstitution */); var call = createExportExpression(operand, expr); if (node.kind === 185 /* PrefixUnaryExpression */) { return call; @@ -45165,7 +46497,7 @@ var ts; ts.createForIn(ts.createVariableDeclarationList([ ts.createVariableDeclaration(n, /*type*/ undefined) ]), m, ts.createBlock([ - setNodeEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 32 /* SingleLine */) + ts.setEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 32 /* SingleLine */) ])), ts.createStatement(ts.createCall(exportFunctionForFile, /*typeArguments*/ undefined, [exports])) @@ -45283,7 +46615,7 @@ var ts; function updateSourceFile(node, statements, nodeEmitFlags) { var updated = ts.getMutableClone(node); updated.statements = ts.createNodeArray(statements, node.statements); - setNodeEmitFlags(updated, nodeEmitFlags); + ts.setEmitFlags(updated, nodeEmitFlags); return updated; } } @@ -45301,7 +46633,7 @@ var ts; _a[ts.ModuleKind.AMD] = transformAMDModule, _a[ts.ModuleKind.UMD] = transformUMDModule, _a)); - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration, setNodeEmitFlags = context.setNodeEmitFlags, getNodeEmitFlags = context.getNodeEmitFlags, setSourceMapRange = context.setSourceMapRange; + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var compilerOptions = context.getCompilerOptions(); var resolver = context.getEmitResolver(); var host = context.getEmitHost(); @@ -45333,6 +46665,9 @@ var ts; * @param node The SourceFile node. */ function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { currentSourceFile = node; // Collect information about the external module. @@ -45365,7 +46700,7 @@ var ts; addExportEqualsIfNeeded(statements, /*emitAsReturn*/ false); var updated = updateSourceFile(node, statements); if (hasExportStarsToExportValues) { - setNodeEmitFlags(updated, 2 /* EmitExportStar */ | getNodeEmitFlags(node)); + ts.setEmitFlags(updated, 2 /* EmitExportStar */ | ts.getEmitFlags(node)); } return updated; } @@ -45386,7 +46721,7 @@ var ts; */ function transformUMDModule(node) { var define = ts.createIdentifier("define"); - setNodeEmitFlags(define, 16 /* UMDDefine */); + ts.setEmitFlags(define, 16 /* UMDDefine */); return transformAsynchronousModule(node, define, /*moduleName*/ undefined, /*includeNonAmdDependencies*/ false); } /** @@ -45466,7 +46801,7 @@ var ts; if (hasExportStarsToExportValues) { // If we have any `export * from ...` declarations // we need to inform the emitter to add the __export helper. - setNodeEmitFlags(body, 2 /* EmitExportStar */); + ts.setEmitFlags(body, 2 /* EmitExportStar */); } return body; } @@ -45475,13 +46810,13 @@ var ts; if (emitAsReturn) { var statement = ts.createReturn(exportEquals.expression, /*location*/ exportEquals); - setNodeEmitFlags(statement, 12288 /* NoTokenSourceMaps */ | 49152 /* NoComments */); + ts.setEmitFlags(statement, 12288 /* NoTokenSourceMaps */ | 49152 /* NoComments */); statements.push(statement); } else { var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), exportEquals.expression), /*location*/ exportEquals); - setNodeEmitFlags(statement, 49152 /* NoComments */); + ts.setEmitFlags(statement, 49152 /* NoComments */); statements.push(statement); } } @@ -45574,7 +46909,7 @@ var ts; } // Set emitFlags on the name of the importEqualsDeclaration // This is so the printer will not substitute the identifier - setNodeEmitFlags(node.name, 128 /* NoSubstitution */); + ts.setEmitFlags(node.name, 128 /* NoSubstitution */); var statements = []; if (moduleKind !== ts.ModuleKind.AMD) { if (ts.hasModifier(node, 1 /* Export */)) { @@ -45678,16 +47013,16 @@ var ts; else { var names = ts.reduceEachChild(node, collectExportMembers, []); for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_32 = names_1[_i]; - addExportMemberAssignments(statements, name_32); + var name_33 = names_1[_i]; + addExportMemberAssignments(statements, name_33); } } } function collectExportMembers(names, node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node) && ts.isDeclaration(node)) { - var name_33 = node.name; - if (ts.isIdentifier(name_33)) { - names.push(name_33); + var name_34 = node.name; + if (ts.isIdentifier(name_34)) { + names.push(name_34); } } return ts.reduceEachChild(node, collectExportMembers, names); @@ -45706,7 +47041,7 @@ var ts; addExportDefault(statements, getDeclarationName(node), /*location*/ node); } else { - statements.push(createExportStatement(node.name, setNodeEmitFlags(ts.getSynthesizedClone(node.name), 262144 /* LocalName */), /*location*/ node)); + statements.push(createExportStatement(node.name, ts.setEmitFlags(ts.getSynthesizedClone(node.name), 262144 /* LocalName */), /*location*/ node)); } } function visitVariableStatement(node) { @@ -45856,20 +47191,20 @@ var ts; /*modifiers*/ undefined, [ts.createVariableDeclaration(getDeclarationName(node), /*type*/ undefined, ts.createPropertyAccess(ts.createIdentifier("exports"), getDeclarationName(node)))], /*location*/ node); - setNodeEmitFlags(transformedStatement, 49152 /* NoComments */); + ts.setEmitFlags(transformedStatement, 49152 /* NoComments */); statements.push(transformedStatement); } function getDeclarationName(node) { return node.name ? ts.getSynthesizedClone(node.name) : ts.getGeneratedNameForNode(node); } - function onEmitNode(node, emit) { + function onEmitNode(emitContext, node, emitCallback) { if (node.kind === 256 /* SourceFile */) { bindingNameExportSpecifiersMap = bindingNameExportSpecifiersForFileMap[ts.getOriginalNodeId(node)]; - previousOnEmitNode(node, emit); + previousOnEmitNode(emitContext, node, emitCallback); bindingNameExportSpecifiersMap = undefined; } else { - previousOnEmitNode(node, emit); + previousOnEmitNode(emitContext, node, emitCallback); } } /** @@ -45879,9 +47214,9 @@ var ts; * @param isExpression A value indicating whether the node is to be used in an expression * position. */ - function onSubstituteNode(node, isExpression) { - node = previousOnSubstituteNode(node, isExpression); - if (isExpression) { + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1 /* Expression */) { return substituteExpression(node); } else if (ts.isShorthandPropertyAssignment(node)) { @@ -45925,7 +47260,7 @@ var ts; // If the left-hand-side of the binaryExpression is an identifier and its is export through export Specifier if (ts.isIdentifier(left) && ts.isAssignmentOperator(node.operatorToken.kind)) { if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, left.text)) { - setNodeEmitFlags(node, 128 /* NoSubstitution */); + ts.setEmitFlags(node, 128 /* NoSubstitution */); var nestedExportAssignment = void 0; for (var _i = 0, _a = bindingNameExportSpecifiersMap[left.text]; _i < _a.length; _i++) { var specifier = _a[_i]; @@ -45945,13 +47280,13 @@ var ts; var operand = node.operand; if (ts.isIdentifier(operand) && bindingNameExportSpecifiersForFileMap) { if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, operand.text)) { - setNodeEmitFlags(node, 128 /* NoSubstitution */); + ts.setEmitFlags(node, 128 /* NoSubstitution */); var transformedUnaryExpression = void 0; if (node.kind === 186 /* PostfixUnaryExpression */) { - transformedUnaryExpression = ts.createBinary(operand, ts.createNode(operator === 41 /* PlusPlusToken */ ? 57 /* PlusEqualsToken */ : 58 /* MinusEqualsToken */), ts.createLiteral(1), + transformedUnaryExpression = ts.createBinary(operand, ts.createToken(operator === 41 /* PlusPlusToken */ ? 57 /* PlusEqualsToken */ : 58 /* MinusEqualsToken */), ts.createLiteral(1), /*location*/ node); // We have to set no substitution flag here to prevent visit the binary expression and substitute it again as we will preform all necessary substitution in here - setNodeEmitFlags(transformedUnaryExpression, 128 /* NoSubstitution */); + ts.setEmitFlags(transformedUnaryExpression, 128 /* NoSubstitution */); } var nestedExportAssignment = void 0; for (var _i = 0, _a = bindingNameExportSpecifiersMap[operand.text]; _i < _a.length; _i++) { @@ -45966,7 +47301,7 @@ var ts; return node; } function trySubstituteExportedName(node) { - var emitFlags = getNodeEmitFlags(node); + var emitFlags = ts.getEmitFlags(node); if ((emitFlags & 262144 /* LocalName */) === 0) { var container = resolver.getReferencedExportContainer(node, (emitFlags & 131072 /* ExportName */) !== 0); if (container) { @@ -45979,7 +47314,7 @@ var ts; return undefined; } function trySubstituteImportedName(node) { - if ((getNodeEmitFlags(node) & 262144 /* LocalName */) === 0) { + if ((ts.getEmitFlags(node) & 262144 /* LocalName */) === 0) { var declaration = resolver.getReferencedImportDeclaration(node); if (declaration) { if (ts.isImportClause(declaration)) { @@ -45994,14 +47329,14 @@ var ts; } } else if (ts.isImportSpecifier(declaration)) { - var name_34 = declaration.propertyName || declaration.name; - if (name_34.originalKeywordKind === 77 /* DefaultKeyword */ && languageVersion <= 0 /* ES3 */) { + var name_35 = declaration.propertyName || declaration.name; + if (name_35.originalKeywordKind === 77 /* DefaultKeyword */ && languageVersion <= 0 /* ES3 */) { // TODO: ES3 transform to handle x.default -> x["default"] - return ts.createElementAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.createLiteral(name_34.text), + return ts.createElementAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.createLiteral(name_35.text), /*location*/ node); } else { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.getSynthesizedClone(name_34), + return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.getSynthesizedClone(name_35), /*location*/ node); } } @@ -46025,7 +47360,7 @@ var ts; var statement = ts.createStatement(createExportAssignment(name, value)); statement.startsOnNewLine = true; if (location) { - setSourceMapRange(statement, location); + ts.setSourceMapRange(statement, location); } return statement; } @@ -46063,7 +47398,7 @@ var ts; if (includeNonAmdDependencies && importAliasName) { // Set emitFlags on the name of the classDeclaration // This is so that when printer will not substitute the identifier - setNodeEmitFlags(importAliasName, 128 /* NoSubstitution */); + ts.setEmitFlags(importAliasName, 128 /* NoSubstitution */); aliasedModuleNames.push(externalModuleName); importAliasNames.push(ts.createParameter(importAliasName)); } @@ -46098,6 +47433,9 @@ var ts; * @param node A SourceFile node. */ function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } currentSourceFile = node; node = ts.visitEachChild(node, visitor, context); currentSourceFile = undefined; @@ -46280,12 +47618,12 @@ var ts; return getTagName(node.openingElement); } else { - var name_35 = node.tagName; - if (ts.isIdentifier(name_35) && ts.isIntrinsicJsxName(name_35.text)) { - return ts.createLiteral(name_35.text); + var name_36 = node.tagName; + if (ts.isIdentifier(name_36) && ts.isIntrinsicJsxName(name_36.text)) { + return ts.createLiteral(name_36.text); } else { - return ts.createExpressionFromEntityName(name_35); + return ts.createExpressionFromEntityName(name_36); } } } @@ -46575,6 +47913,9 @@ var ts; var hoistVariableDeclaration = context.hoistVariableDeclaration; return transformSourceFile; function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } return ts.visitEachChild(node, visitor, context); } function visitor(node) { @@ -46820,7 +48161,7 @@ var ts; _a[7 /* Endfinally */] = "endfinally", _a)); function transformGenerators(context) { - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistFunctionDeclaration = context.hoistFunctionDeclaration, hoistVariableDeclaration = context.hoistVariableDeclaration, setSourceMapRange = context.setSourceMapRange, setCommentRange = context.setCommentRange, setNodeEmitFlags = context.setNodeEmitFlags; + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistFunctionDeclaration = context.hoistFunctionDeclaration, hoistVariableDeclaration = context.hoistVariableDeclaration; var compilerOptions = context.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var resolver = context.getEmitResolver(); @@ -46870,6 +48211,9 @@ var ts; var withBlockStack; // A stack containing `with` blocks. return transformSourceFile; function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } if (node.transformFlags & 1024 /* ContainsGenerator */) { currentSourceFile = node; node = ts.visitEachChild(node, visitor, context); @@ -47011,7 +48355,7 @@ var ts; */ function visitFunctionDeclaration(node) { // Currently, we only support generators that were originally async functions. - if (node.asteriskToken && node.emitFlags & 2097152 /* AsyncFunctionBody */) { + if (node.asteriskToken && ts.getEmitFlags(node) & 2097152 /* AsyncFunctionBody */) { node = ts.setOriginalNode(ts.createFunctionDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -47050,7 +48394,7 @@ var ts; */ function visitFunctionExpression(node) { // Currently, we only support generators that were originally async functions. - if (node.asteriskToken && node.emitFlags & 2097152 /* AsyncFunctionBody */) { + if (node.asteriskToken && ts.getEmitFlags(node) & 2097152 /* AsyncFunctionBody */) { node = ts.setOriginalNode(ts.createFunctionExpression( /*asteriskToken*/ undefined, node.name, /*typeParameters*/ undefined, node.parameters, @@ -47099,6 +48443,7 @@ var ts; var savedBlocks = blocks; var savedBlockOffsets = blockOffsets; var savedBlockActions = blockActions; + var savedBlockStack = blockStack; var savedLabelOffsets = labelOffsets; var savedLabelExpressions = labelExpressions; var savedNextLabelId = nextLabelId; @@ -47112,6 +48457,7 @@ var ts; blocks = undefined; blockOffsets = undefined; blockActions = undefined; + blockStack = undefined; labelOffsets = undefined; labelExpressions = undefined; nextLabelId = 1; @@ -47132,6 +48478,7 @@ var ts; blocks = savedBlocks; blockOffsets = savedBlockOffsets; blockActions = savedBlockActions; + blockStack = savedBlockStack; labelOffsets = savedLabelOffsets; labelExpressions = savedLabelExpressions; nextLabelId = savedNextLabelId; @@ -47156,7 +48503,7 @@ var ts; } else { // Do not hoist custom prologues. - if (node.emitFlags & 8388608 /* CustomPrologue */) { + if (ts.getEmitFlags(node) & 8388608 /* CustomPrologue */) { return node; } for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { @@ -48202,9 +49549,9 @@ var ts; } return -1; } - function onSubstituteNode(node, isExpression) { - node = previousOnSubstituteNode(node, isExpression); - if (isExpression) { + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1 /* Expression */) { return substituteExpression(node); } return node; @@ -48221,11 +49568,11 @@ var ts; if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - var name_36 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); - if (name_36) { - var clone_7 = ts.getMutableClone(name_36); - setSourceMapRange(clone_7, node); - setCommentRange(clone_7, node); + var name_37 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); + if (name_37) { + var clone_7 = ts.getMutableClone(name_37); + ts.setSourceMapRange(clone_7, node); + ts.setCommentRange(clone_7, node); return clone_7; } } @@ -48815,7 +50162,7 @@ var ts; return ts.createCall(ts.createHelperName(currentSourceFile.externalHelpersModuleName, "__generator"), /*typeArguments*/ undefined, [ ts.createThis(), - setNodeEmitFlags(ts.createFunctionExpression( + ts.setEmitFlags(ts.createFunctionExpression( /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, [ts.createParameter(state)], @@ -49218,8 +50565,32 @@ var ts; Jump[Jump["Continue"] = 4] = "Continue"; Jump[Jump["Return"] = 8] = "Return"; })(Jump || (Jump = {})); + var SuperCaptureResult; + (function (SuperCaptureResult) { + /** + * A capture may have been added for calls to 'super', but + * the caller should emit subsequent statements normally. + */ + SuperCaptureResult[SuperCaptureResult["NoReplacement"] = 0] = "NoReplacement"; + /** + * A call to 'super()' got replaced with a capturing statement like: + * + * var _this = _super.call(...) || this; + * + * Callers should skip the current statement. + */ + SuperCaptureResult[SuperCaptureResult["ReplaceSuperCapture"] = 1] = "ReplaceSuperCapture"; + /** + * A call to 'super()' got replaced with a capturing statement like: + * + * return _super.call(...) || this; + * + * Callers should skip the current statement and avoid any returns of '_this'. + */ + SuperCaptureResult[SuperCaptureResult["ReplaceWithReturn"] = 2] = "ReplaceWithReturn"; + })(SuperCaptureResult || (SuperCaptureResult = {})); function transformES6(context) { - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration, getNodeEmitFlags = context.getNodeEmitFlags, setNodeEmitFlags = context.setNodeEmitFlags, getCommentRange = context.getCommentRange, setCommentRange = context.setCommentRange, getSourceMapRange = context.getSourceMapRange, setSourceMapRange = context.setSourceMapRange, setTokenSourceMapRange = context.setTokenSourceMapRange; + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); var previousOnSubstituteNode = context.onSubstituteNode; var previousOnEmitNode = context.onEmitNode; @@ -49247,6 +50618,9 @@ var ts; var enabledSubstitutions; return transformSourceFile; function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } currentSourceFile = node; currentText = node.text; return ts.visitNode(node, visitor, ts.isSourceFile); @@ -49418,7 +50792,7 @@ var ts; enclosingFunction = currentNode; if (currentNode.kind !== 180 /* ArrowFunction */) { enclosingNonArrowFunction = currentNode; - if (!(currentNode.emitFlags & 2097152 /* AsyncFunctionBody */)) { + if (!(ts.getEmitFlags(currentNode) & 2097152 /* AsyncFunctionBody */)) { enclosingNonAsyncFunctionBody = currentNode; } } @@ -49634,17 +51008,17 @@ var ts; // To preserve the behavior of the old emitter, we explicitly indent // the body of the function here if it was requested in an earlier // transformation. - if (getNodeEmitFlags(node) & 524288 /* Indented */) { - setNodeEmitFlags(classFunction, 524288 /* Indented */); + if (ts.getEmitFlags(node) & 524288 /* Indented */) { + ts.setEmitFlags(classFunction, 524288 /* Indented */); } // "inner" and "outer" below are added purely to preserve source map locations from // the old emitter var inner = ts.createPartiallyEmittedExpression(classFunction); inner.end = node.end; - setNodeEmitFlags(inner, 49152 /* NoComments */); + ts.setEmitFlags(inner, 49152 /* NoComments */); var outer = ts.createPartiallyEmittedExpression(inner); outer.end = ts.skipTrivia(currentText, node.pos); - setNodeEmitFlags(outer, 49152 /* NoComments */); + ts.setEmitFlags(outer, 49152 /* NoComments */); return ts.createParen(ts.createCall(outer, /*typeArguments*/ undefined, extendsClauseElement ? [ts.visitNode(extendsClauseElement.expression, visitor, ts.isExpression)] @@ -49669,14 +51043,14 @@ var ts; // emit with the original emitter. var outer = ts.createPartiallyEmittedExpression(localName); outer.end = closingBraceLocation.end; - setNodeEmitFlags(outer, 49152 /* NoComments */); + ts.setEmitFlags(outer, 49152 /* NoComments */); var statement = ts.createReturn(outer); statement.pos = closingBraceLocation.pos; - setNodeEmitFlags(statement, 49152 /* NoComments */ | 12288 /* NoTokenSourceMaps */); + ts.setEmitFlags(statement, 49152 /* NoComments */ | 12288 /* NoTokenSourceMaps */); statements.push(statement); ts.addRange(statements, endLexicalEnvironment()); var block = ts.createBlock(ts.createNodeArray(statements, /*location*/ node.members), /*location*/ undefined, /*multiLine*/ true); - setNodeEmitFlags(block, 49152 /* NoComments */); + ts.setEmitFlags(block, 49152 /* NoComments */); return block; } /** @@ -49702,13 +51076,17 @@ var ts; function addConstructor(statements, node, extendsClauseElement) { var constructor = ts.getFirstConstructorWithBody(node); var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); - statements.push(ts.createFunctionDeclaration( + var constructorFunction = ts.createFunctionDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, /*asteriskToken*/ undefined, getDeclarationName(node), /*typeParameters*/ undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), /*type*/ undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), - /*location*/ constructor || node)); + /*location*/ constructor || node); + if (extendsClauseElement) { + ts.setEmitFlags(constructorFunction, 256 /* CapturesThis */); + } + statements.push(constructorFunction); } /** * Transforms the parameters of the constructor declaration of a class. @@ -49740,51 +51118,146 @@ var ts; function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { var statements = []; startLexicalEnvironment(); + var statementOffset = -1; + if (hasSynthesizedSuper) { + // If a super call has already been synthesized, + // we're going to assume that we should just transform everything after that. + // The assumption is that no prior step in the pipeline has added any prologue directives. + statementOffset = 1; + } + else if (constructor) { + // Otherwise, try to emit all potential prologue directives first. + statementOffset = ts.addPrologueDirectives(statements, constructor.body.statements, /*ensureUseStrict*/ false, visitor); + } if (constructor) { - addCaptureThisForNodeIfNeeded(statements, constructor); addDefaultValueAssignmentsIfNeeded(statements, constructor); addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); + ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); + } + var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, !!extendsClauseElement, hasSynthesizedSuper, statementOffset); + // The last statement expression was replaced. Skip it. + if (superCaptureStatus === 1 /* ReplaceSuperCapture */ || superCaptureStatus === 2 /* ReplaceWithReturn */) { + statementOffset++; } - addDefaultSuperCallIfNeeded(statements, constructor, extendsClauseElement, hasSynthesizedSuper); if (constructor) { - var body = saveStateAndInvoke(constructor, hasSynthesizedSuper ? transformConstructorBodyWithSynthesizedSuper : transformConstructorBodyWithoutSynthesizedSuper); + var body = saveStateAndInvoke(constructor, function (constructor) { return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, /*start*/ statementOffset); }); ts.addRange(statements, body); } + // Return `_this` unless we're sure enough that it would be pointless to add a return statement. + // If there's a constructor that we can tell returns in enough places, then we *do not* want to add a return. + if (extendsClauseElement + && superCaptureStatus !== 2 /* ReplaceWithReturn */ + && !(constructor && isSufficientlyCoveredByReturnStatements(constructor.body))) { + statements.push(ts.createReturn(ts.createIdentifier("_this"))); + } ts.addRange(statements, endLexicalEnvironment()); var block = ts.createBlock(ts.createNodeArray(statements, /*location*/ constructor ? constructor.body.statements : node.members), /*location*/ constructor ? constructor.body : node, /*multiLine*/ true); if (!constructor) { - setNodeEmitFlags(block, 49152 /* NoComments */); + ts.setEmitFlags(block, 49152 /* NoComments */); } return block; } - function transformConstructorBodyWithSynthesizedSuper(node) { - return ts.visitNodes(node.body.statements, visitor, ts.isStatement, 1); - } - function transformConstructorBodyWithoutSynthesizedSuper(node) { - return ts.visitNodes(node.body.statements, visitor, ts.isStatement, 0); + /** + * We want to try to avoid emitting a return statement in certain cases if a user already returned something. + * It would generate obviously dead code, so we'll try to make things a little bit prettier + * by doing a minimal check on whether some common patterns always explicitly return. + */ + function isSufficientlyCoveredByReturnStatements(statement) { + // A return statement is considered covered. + if (statement.kind === 211 /* ReturnStatement */) { + return true; + } + else if (statement.kind === 203 /* IfStatement */) { + var ifStatement = statement; + if (ifStatement.elseStatement) { + return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && + isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); + } + } + else if (statement.kind === 199 /* Block */) { + var lastStatement = ts.lastOrUndefined(statement.statements); + if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { + return true; + } + } + return false; } /** - * Adds a synthesized call to `_super` if it is needed. + * Declares a `_this` variable for derived classes and for when arrow functions capture `this`. * - * @param statements The statements for the new constructor body. - * @param constructor The constructor for the class. - * @param extendsClauseElement The expression for the class `extends` clause. - * @param hasSynthesizedSuper A value indicating whether the constructor starts with a - * synthesized `super` call. + * @returns The new statement offset into the `statements` array. */ - function addDefaultSuperCallIfNeeded(statements, constructor, extendsClauseElement, hasSynthesizedSuper) { - // If the TypeScript transformer needed to synthesize a constructor for property - // initializers, it would have also added a synthetic `...args` parameter and - // `super` call. - // If this is the case, or if the class has an `extends` clause but no - // constructor, we emit a synthesized call to `_super`. - if (constructor ? hasSynthesizedSuper : extendsClauseElement) { - statements.push(ts.createStatement(ts.createFunctionApply(ts.createIdentifier("_super"), ts.createThis(), ts.createIdentifier("arguments")), - /*location*/ extendsClauseElement)); + function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, hasExtendsClause, hasSynthesizedSuper, statementOffset) { + // If this isn't a derived class, just capture 'this' for arrow functions if necessary. + if (!hasExtendsClause) { + if (ctor) { + addCaptureThisForNodeIfNeeded(statements, ctor); + } + return 0 /* NoReplacement */; } + // We must be here because the user didn't write a constructor + // but we needed to call 'super(...args)' anyway as per 14.5.14 of the ES2016 spec. + // If that's the case we can just immediately return the result of a 'super()' call. + if (!ctor) { + statements.push(ts.createReturn(createDefaultSuperCallOrThis())); + return 2 /* ReplaceWithReturn */; + } + // The constructor exists, but it and the 'super()' call it contains were generated + // for something like property initializers. + // Create a captured '_this' variable and assume it will subsequently be used. + if (hasSynthesizedSuper) { + captureThisForNode(statements, ctor, createDefaultSuperCallOrThis()); + enableSubstitutionsForCapturedThis(); + return 1 /* ReplaceSuperCapture */; + } + // Most of the time, a 'super' call will be the first real statement in a constructor body. + // In these cases, we'd like to transform these into a *single* statement instead of a declaration + // followed by an assignment statement for '_this'. For instance, if we emitted without an initializer, + // we'd get: + // + // var _this; + // _this = _super.call(...) || this; + // + // instead of + // + // var _this = _super.call(...) || this; + // + // Additionally, if the 'super()' call is the last statement, we should just avoid capturing + // entirely and immediately return the result like so: + // + // return _super.call(...) || this; + // + var firstStatement; + var superCallExpression; + var ctorStatements = ctor.body.statements; + if (statementOffset < ctorStatements.length) { + firstStatement = ctorStatements[statementOffset]; + if (firstStatement.kind === 202 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { + var superCall = firstStatement.expression; + superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); + } + } + // Return the result if we have an immediate super() call on the last statement. + if (superCallExpression && statementOffset === ctorStatements.length - 1) { + statements.push(ts.createReturn(superCallExpression)); + return 2 /* ReplaceWithReturn */; + } + // Perform the capture. + captureThisForNode(statements, ctor, superCallExpression, firstStatement); + // If we're actually replacing the original statement, we need to signal this to the caller. + if (superCallExpression) { + return 1 /* ReplaceSuperCapture */; + } + return 0 /* NoReplacement */; + } + function createDefaultSuperCallOrThis() { + var actualThis = ts.createThis(); + ts.setEmitFlags(actualThis, 128 /* NoSubstitution */); + var superCall = ts.createFunctionApply(ts.createIdentifier("_super"), actualThis, ts.createIdentifier("arguments")); + return ts.createLogicalOr(superCall, actualThis); } /** * Visits a parameter declaration. @@ -49837,17 +51310,17 @@ var ts; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { var parameter = _a[_i]; - var name_37 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; + var name_38 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; // A rest parameter cannot have a binding pattern or an initializer, // so let's just ignore it. if (dotDotDotToken) { continue; } - if (ts.isBindingPattern(name_37)) { - addDefaultValueAssignmentForBindingPattern(statements, parameter, name_37, initializer); + if (ts.isBindingPattern(name_38)) { + addDefaultValueAssignmentForBindingPattern(statements, parameter, name_38, initializer); } else if (initializer) { - addDefaultValueAssignmentForInitializer(statements, parameter, name_37, initializer); + addDefaultValueAssignmentForInitializer(statements, parameter, name_38, initializer); } } } @@ -49865,11 +51338,11 @@ var ts; // we usually don't want to emit a var declaration; however, in the presence // of an initializer, we must emit that expression to preserve side effects. if (name.elements.length > 0) { - statements.push(setNodeEmitFlags(ts.createVariableStatement( + statements.push(ts.setEmitFlags(ts.createVariableStatement( /*modifiers*/ undefined, ts.createVariableDeclarationList(ts.flattenParameterDestructuring(context, parameter, temp, visitor))), 8388608 /* CustomPrologue */)); } else if (initializer) { - statements.push(setNodeEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 8388608 /* CustomPrologue */)); + statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 8388608 /* CustomPrologue */)); } } /** @@ -49882,14 +51355,14 @@ var ts; */ function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) { initializer = ts.visitNode(initializer, visitor, ts.isExpression); - var statement = ts.createIf(ts.createStrictEquality(ts.getSynthesizedClone(name), ts.createVoidZero()), setNodeEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(setNodeEmitFlags(ts.getMutableClone(name), 1536 /* NoSourceMap */), setNodeEmitFlags(initializer, 1536 /* NoSourceMap */ | getNodeEmitFlags(initializer)), + var statement = ts.createIf(ts.createStrictEquality(ts.getSynthesizedClone(name), ts.createVoidZero()), ts.setEmitFlags(ts.createBlock([ + ts.createStatement(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 1536 /* NoSourceMap */), ts.setEmitFlags(initializer, 1536 /* NoSourceMap */ | ts.getEmitFlags(initializer)), /*location*/ parameter)) ], /*location*/ parameter), 32 /* SingleLine */ | 1024 /* NoTrailingSourceMap */ | 12288 /* NoTokenSourceMaps */), /*elseStatement*/ undefined, /*location*/ parameter); statement.startsOnNewLine = true; - setNodeEmitFlags(statement, 12288 /* NoTokenSourceMaps */ | 1024 /* NoTrailingSourceMap */ | 8388608 /* CustomPrologue */); + ts.setEmitFlags(statement, 12288 /* NoTokenSourceMaps */ | 1024 /* NoTrailingSourceMap */ | 8388608 /* CustomPrologue */); statements.push(statement); } /** @@ -49919,13 +51392,13 @@ var ts; } // `declarationName` is the name of the local declaration for the parameter. var declarationName = ts.getMutableClone(parameter.name); - setNodeEmitFlags(declarationName, 1536 /* NoSourceMap */); + ts.setEmitFlags(declarationName, 1536 /* NoSourceMap */); // `expressionName` is the name of the parameter used in expressions. var expressionName = ts.getSynthesizedClone(parameter.name); var restIndex = node.parameters.length - 1; var temp = ts.createLoopVariable(); // var param = []; - statements.push(setNodeEmitFlags(ts.createVariableStatement( + statements.push(ts.setEmitFlags(ts.createVariableStatement( /*modifiers*/ undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration(declarationName, /*type*/ undefined, ts.createArrayLiteral([])) @@ -49941,7 +51414,7 @@ var ts; ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp)), /*location*/ parameter)) ])); - setNodeEmitFlags(forStatement, 8388608 /* CustomPrologue */); + ts.setEmitFlags(forStatement, 8388608 /* CustomPrologue */); ts.startOnNewLine(forStatement); statements.push(forStatement); } @@ -49953,17 +51426,20 @@ var ts; */ function addCaptureThisForNodeIfNeeded(statements, node) { if (node.transformFlags & 16384 /* ContainsCapturedLexicalThis */ && node.kind !== 180 /* ArrowFunction */) { - enableSubstitutionsForCapturedThis(); - var captureThisStatement = ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration("_this", - /*type*/ undefined, ts.createThis()) - ])); - setNodeEmitFlags(captureThisStatement, 49152 /* NoComments */ | 8388608 /* CustomPrologue */); - setSourceMapRange(captureThisStatement, node); - statements.push(captureThisStatement); + captureThisForNode(statements, node, ts.createThis()); } } + function captureThisForNode(statements, node, initializer, originalStatement) { + enableSubstitutionsForCapturedThis(); + var captureThisStatement = ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration("_this", + /*type*/ undefined, initializer) + ]), originalStatement); + ts.setEmitFlags(captureThisStatement, 49152 /* NoComments */ | 8388608 /* CustomPrologue */); + ts.setSourceMapRange(captureThisStatement, node); + statements.push(captureThisStatement); + } /** * Adds statements to the class body function for a class to define the members of the * class. @@ -50012,20 +51488,20 @@ var ts; * @param member The MethodDeclaration node. */ function transformClassMethodDeclarationToStatement(receiver, member) { - var commentRange = getCommentRange(member); - var sourceMapRange = getSourceMapRange(member); + var commentRange = ts.getCommentRange(member); + var sourceMapRange = ts.getSourceMapRange(member); var func = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined); - setNodeEmitFlags(func, 49152 /* NoComments */); - setSourceMapRange(func, sourceMapRange); + ts.setEmitFlags(func, 49152 /* NoComments */); + ts.setSourceMapRange(func, sourceMapRange); var statement = ts.createStatement(ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), /*location*/ member.name), func), /*location*/ member); ts.setOriginalNode(statement, member); - setCommentRange(statement, commentRange); + ts.setCommentRange(statement, commentRange); // The location for the statement is used to emit comments only. // No source map should be emitted for this statement to align with the // old emitter. - setNodeEmitFlags(statement, 1536 /* NoSourceMap */); + ts.setEmitFlags(statement, 1536 /* NoSourceMap */); return statement; } /** @@ -50036,11 +51512,11 @@ var ts; */ function transformAccessorsToStatement(receiver, accessors) { var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, /*startsOnNewLine*/ false), - /*location*/ getSourceMapRange(accessors.firstAccessor)); + /*location*/ ts.getSourceMapRange(accessors.firstAccessor)); // The location for the statement is used to emit source maps only. // No comments should be emitted for this statement to align with the // old emitter. - setNodeEmitFlags(statement, 49152 /* NoComments */); + ts.setEmitFlags(statement, 49152 /* NoComments */); return statement; } /** @@ -50054,24 +51530,24 @@ var ts; // To align with source maps in the old emitter, the receiver and property name // arguments are both mapped contiguously to the accessor name. var target = ts.getMutableClone(receiver); - setNodeEmitFlags(target, 49152 /* NoComments */ | 1024 /* NoTrailingSourceMap */); - setSourceMapRange(target, firstAccessor.name); + ts.setEmitFlags(target, 49152 /* NoComments */ | 1024 /* NoTrailingSourceMap */); + ts.setSourceMapRange(target, firstAccessor.name); var propertyName = ts.createExpressionForPropertyName(ts.visitNode(firstAccessor.name, visitor, ts.isPropertyName)); - setNodeEmitFlags(propertyName, 49152 /* NoComments */ | 512 /* NoLeadingSourceMap */); - setSourceMapRange(propertyName, firstAccessor.name); + ts.setEmitFlags(propertyName, 49152 /* NoComments */ | 512 /* NoLeadingSourceMap */); + ts.setSourceMapRange(propertyName, firstAccessor.name); var properties = []; if (getAccessor) { var getterFunction = transformFunctionLikeToExpression(getAccessor, /*location*/ undefined, /*name*/ undefined); - setSourceMapRange(getterFunction, getSourceMapRange(getAccessor)); + ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); var getter = ts.createPropertyAssignment("get", getterFunction); - setCommentRange(getter, getCommentRange(getAccessor)); + ts.setCommentRange(getter, ts.getCommentRange(getAccessor)); properties.push(getter); } if (setAccessor) { var setterFunction = transformFunctionLikeToExpression(setAccessor, /*location*/ undefined, /*name*/ undefined); - setSourceMapRange(setterFunction, getSourceMapRange(setAccessor)); + ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); var setter = ts.createPropertyAssignment("set", setterFunction); - setCommentRange(setter, getCommentRange(setAccessor)); + ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); properties.push(setter); } properties.push(ts.createPropertyAssignment("enumerable", ts.createLiteral(true)), ts.createPropertyAssignment("configurable", ts.createLiteral(true))); @@ -50096,7 +51572,7 @@ var ts; enableSubstitutionsForCapturedThis(); } var func = transformFunctionLikeToExpression(node, /*location*/ node, /*name*/ undefined); - setNodeEmitFlags(func, 256 /* CapturesThis */); + ts.setEmitFlags(func, 256 /* CapturesThis */); return func; } /** @@ -50191,7 +51667,7 @@ var ts; } var expression = ts.visitNode(body, visitor, ts.isExpression); var returnStatement = ts.createReturn(expression, /*location*/ body); - setNodeEmitFlags(returnStatement, 12288 /* NoTokenSourceMaps */ | 1024 /* NoTrailingSourceMap */ | 32768 /* NoTrailingComments */); + ts.setEmitFlags(returnStatement, 12288 /* NoTokenSourceMaps */ | 1024 /* NoTrailingSourceMap */ | 32768 /* NoTrailingComments */); statements.push(returnStatement); // To align with the source map emit for the old emitter, we set a custom // source map location for the close brace. @@ -50205,10 +51681,10 @@ var ts; } var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), node.body, multiLine); if (!multiLine && singleLine) { - setNodeEmitFlags(block, 32 /* SingleLine */); + ts.setEmitFlags(block, 32 /* SingleLine */); } if (closeBraceLocation) { - setTokenSourceMapRange(block, 16 /* CloseBraceToken */, closeBraceLocation); + ts.setTokenSourceMapRange(block, 16 /* CloseBraceToken */, closeBraceLocation); } ts.setOriginalNode(block, node.body); return block; @@ -50274,7 +51750,7 @@ var ts; assignment = ts.flattenVariableDestructuringToExpression(context, decl, hoistVariableDeclaration, /*nameSubstitution*/ undefined, visitor); } else { - assignment = ts.createBinary(decl.name, 56 /* EqualsToken */, decl.initializer); + assignment = ts.createBinary(decl.name, 56 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); } (assignments || (assignments = [])).push(assignment); } @@ -50303,7 +51779,7 @@ var ts; : visitVariableDeclaration)); var declarationList = ts.createVariableDeclarationList(declarations, /*location*/ node); ts.setOriginalNode(declarationList, node); - setCommentRange(declarationList, node); + ts.setCommentRange(declarationList, node); if (node.transformFlags & 2097152 /* ContainsBindingPattern */ && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { @@ -50311,7 +51787,7 @@ var ts; // the source map range for the declaration list. var firstDeclaration = ts.firstOrUndefined(declarations); var lastDeclaration = ts.lastOrUndefined(declarations); - setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); } return declarationList; } @@ -50501,7 +51977,7 @@ var ts; // emitter. var firstDeclaration = declarations[0]; var lastDeclaration = ts.lastOrUndefined(declarations); - setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); statements.push(ts.createVariableStatement( /*modifiers*/ undefined, declarationList)); } @@ -50549,12 +52025,12 @@ var ts; } } // The old emitter does not emit source maps for the expression - setNodeEmitFlags(expression, 1536 /* NoSourceMap */ | getNodeEmitFlags(expression)); + ts.setEmitFlags(expression, 1536 /* NoSourceMap */ | ts.getEmitFlags(expression)); // The old emitter does not emit source maps for the block. // We add the location to preserve comments. var body = ts.createBlock(ts.createNodeArray(statements, /*location*/ statementsLocation), /*location*/ bodyLocation); - setNodeEmitFlags(body, 1536 /* NoSourceMap */ | 12288 /* NoTokenSourceMaps */); + ts.setEmitFlags(body, 1536 /* NoSourceMap */ | 12288 /* NoTokenSourceMaps */); var forStatement = ts.createFor(ts.createVariableDeclarationList([ ts.createVariableDeclaration(counter, /*type*/ undefined, ts.createLiteral(0), /*location*/ ts.moveRangePos(node.expression, -1)), ts.createVariableDeclaration(rhsReference, /*type*/ undefined, expression, /*location*/ node.expression) @@ -50562,7 +52038,7 @@ var ts; /*location*/ node.expression), ts.createPostfixIncrement(counter, /*location*/ node.expression), body, /*location*/ node); // Disable trailing source maps for the OpenParenToken to align source map emit with the old emitter. - setNodeEmitFlags(forStatement, 8192 /* NoTokenTrailingSourceMaps */); + ts.setEmitFlags(forStatement, 8192 /* NoTokenTrailingSourceMaps */); return forStatement; } /** @@ -50591,7 +52067,7 @@ var ts; var temp = ts.createTempVariable(hoistVariableDeclaration); // Write out the first non-computed properties, then emit the rest through indexing on the temp variable. var expressions = []; - var assignment = ts.createAssignment(temp, setNodeEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), + var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), /*location*/ undefined, node.multiLine), 524288 /* Indented */)); if (node.multiLine) { assignment.startsOnNewLine = true; @@ -50698,7 +52174,7 @@ var ts; loopBody = ts.createBlock([loopBody], /*location*/ undefined, /*multiline*/ true); } var isAsyncBlockContainingAwait = enclosingNonArrowFunction - && (enclosingNonArrowFunction.emitFlags & 2097152 /* AsyncFunctionBody */) !== 0 + && (ts.getEmitFlags(enclosingNonArrowFunction) & 2097152 /* AsyncFunctionBody */) !== 0 && (node.statement.transformFlags & 4194304 /* ContainsYield */) !== 0; var loopBodyFlags = 0; if (currentState.containsLexicalThis) { @@ -50710,7 +52186,7 @@ var ts; var convertedLoopVariable = ts.createVariableStatement( /*modifiers*/ undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration(functionName, - /*type*/ undefined, setNodeEmitFlags(ts.createFunctionExpression(isAsyncBlockContainingAwait ? ts.createToken(37 /* AsteriskToken */) : undefined, + /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression(isAsyncBlockContainingAwait ? ts.createToken(37 /* AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, loopParameters, /*type*/ undefined, loopBody), loopBodyFlags)) @@ -50756,8 +52232,8 @@ var ts; extraVariableDeclarations = []; } // hoist collected variable declarations - for (var name_38 in currentState.hoistedLocalVariables) { - var identifier = currentState.hoistedLocalVariables[name_38]; + for (var _b = 0, _c = currentState.hoistedLocalVariables; _b < _c.length; _b++) { + var identifier = _c[_b]; extraVariableDeclarations.push(ts.createVariableDeclaration(identifier)); } } @@ -50767,8 +52243,8 @@ var ts; if (!extraVariableDeclarations) { extraVariableDeclarations = []; } - for (var _b = 0, loopOutParameters_1 = loopOutParameters; _b < loopOutParameters_1.length; _b++) { - var outParam = loopOutParameters_1[_b]; + for (var _d = 0, loopOutParameters_1 = loopOutParameters; _d < loopOutParameters_1.length; _d++) { + var outParam = loopOutParameters_1[_d]; extraVariableDeclarations.push(ts.createVariableDeclaration(outParam.outParamName)); } } @@ -51003,7 +52479,7 @@ var ts; // Methods with computed property names are handled in visitObjectLiteralExpression. ts.Debug.assert(!ts.isComputedPropertyName(node.name)); var functionExpression = transformFunctionLikeToExpression(node, /*location*/ ts.moveRangePos(node, -1), /*name*/ undefined); - setNodeEmitFlags(functionExpression, 16384 /* NoLeadingComments */ | getNodeEmitFlags(functionExpression)); + ts.setEmitFlags(functionExpression, 16384 /* NoLeadingComments */ | ts.getEmitFlags(functionExpression)); return ts.createPropertyAssignment(node.name, functionExpression, /*location*/ node); } @@ -51040,9 +52516,19 @@ var ts; * @param node a CallExpression. */ function visitCallExpression(node) { + return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); + } + function visitImmediateSuperCallInBody(node) { + return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ false); + } + function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) { // We are here either because SuperKeyword was used somewhere in the expression, or // because we contain a SpreadElementExpression. var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; + if (node.expression.kind === 95 /* SuperKeyword */) { + ts.setEmitFlags(thisArg, 128 /* NoSubstitution */); + } + var resultingCall; if (node.transformFlags & 262144 /* ContainsSpreadElementExpression */) { // [source] // f(...a, b) @@ -51057,7 +52543,7 @@ var ts; // _super.apply(this, a.concat([b])) // _super.m.apply(this, a.concat([b])) // _super.prototype.m.apply(this, a.concat([b])) - return ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); + resultingCall = ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); } else { // [source] @@ -51069,9 +52555,18 @@ var ts; // _super.call(this, a) // _super.m.call(this, a) // _super.prototype.m.call(this, a) - return ts.createFunctionCall(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), + resultingCall = ts.createFunctionCall(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), /*location*/ node); } + if (node.expression.kind === 95 /* SuperKeyword */) { + var actualThis = ts.createThis(); + ts.setEmitFlags(actualThis, 128 /* NoSubstitution */); + var initializer = ts.createLogicalOr(resultingCall, actualThis); + return assignToCapturedThis + ? ts.createAssignment(ts.createIdentifier("_this"), initializer) + : initializer; + } + return resultingCall; } /** * Visits a NewExpression that contains a spread element. @@ -51313,13 +52808,13 @@ var ts; * * @param node The node to be printed. */ - function onEmitNode(node, emit) { + function onEmitNode(emitContext, node, emitCallback) { var savedEnclosingFunction = enclosingFunction; if (enabledSubstitutions & 1 /* CapturedThis */ && ts.isFunctionLike(node)) { // If we are tracking a captured `this`, keep track of the enclosing function. enclosingFunction = node; } - previousOnEmitNode(node, emit); + previousOnEmitNode(emitContext, node, emitCallback); enclosingFunction = savedEnclosingFunction; } /** @@ -51356,9 +52851,9 @@ var ts; * @param isExpression A value indicating whether the node is to be used in an expression * position. */ - function onSubstituteNode(node, isExpression) { - node = previousOnSubstituteNode(node, isExpression); - if (isExpression) { + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1 /* Expression */) { return substituteExpression(node); } if (ts.isIdentifier(node)) { @@ -51434,7 +52929,7 @@ var ts; function substituteThisKeyword(node) { if (enabledSubstitutions & 1 /* CapturedThis */ && enclosingFunction - && enclosingFunction.emitFlags & 256 /* CapturesThis */) { + && ts.getEmitFlags(enclosingFunction) & 256 /* CapturesThis */) { return ts.createIdentifier("_this", /*location*/ node); } return node; @@ -51461,7 +52956,7 @@ var ts; function getDeclarationName(node, allowComments, allowSourceMaps, emitFlags) { if (node.name && !ts.isGeneratedIdentifier(node.name)) { var name_39 = ts.getMutableClone(node.name); - emitFlags |= getNodeEmitFlags(node.name); + emitFlags |= ts.getEmitFlags(node.name); if (!allowSourceMaps) { emitFlags |= 1536 /* NoSourceMap */; } @@ -51469,7 +52964,7 @@ var ts; emitFlags |= 49152 /* NoComments */; } if (emitFlags) { - setNodeEmitFlags(name_39, emitFlags); + ts.setEmitFlags(name_39, emitFlags); } return name_39; } @@ -51552,13 +53047,6 @@ var ts; return transformers; } ts.getTransformers = getTransformers; - /** - * Tracks a monotonically increasing transformation id used to associate a node with a specific - * transformation. This ensures transient properties related to transformations can be safely - * stored on source tree nodes that may be reused across multiple transformations (such as - * with compile-on-save). - */ - var nextTransformId = 1; /** * Transforms an array of SourceFiles by passing them through each transformer. * @@ -51568,16 +53056,9 @@ var ts; * @param transforms An array of Transformers. */ function transformFiles(resolver, host, sourceFiles, transformers) { - var transformId = nextTransformId; - nextTransformId++; - var tokenSourceMapRanges = ts.createMap(); var lexicalEnvironmentVariableDeclarationsStack = []; var lexicalEnvironmentFunctionDeclarationsStack = []; var enabledSyntaxKindFeatures = new Array(289 /* Count */); - var parseTreeNodesWithAnnotations = []; - var lastTokenSourceMapRangeNode; - var lastTokenSourceMapRangeToken; - var lastTokenSourceMapRange; var lexicalEnvironmentStackOffset = 0; var hoistedVariableDeclarations; var hoistedFunctionDeclarations; @@ -51588,56 +53069,27 @@ var ts; getCompilerOptions: function () { return host.getCompilerOptions(); }, getEmitResolver: function () { return resolver; }, getEmitHost: function () { return host; }, - getNodeEmitFlags: getNodeEmitFlags, - setNodeEmitFlags: setNodeEmitFlags, - getSourceMapRange: getSourceMapRange, - setSourceMapRange: setSourceMapRange, - getTokenSourceMapRange: getTokenSourceMapRange, - setTokenSourceMapRange: setTokenSourceMapRange, - getCommentRange: getCommentRange, - setCommentRange: setCommentRange, hoistVariableDeclaration: hoistVariableDeclaration, hoistFunctionDeclaration: hoistFunctionDeclaration, startLexicalEnvironment: startLexicalEnvironment, endLexicalEnvironment: endLexicalEnvironment, - onSubstituteNode: onSubstituteNode, + onSubstituteNode: function (emitContext, node) { return node; }, enableSubstitution: enableSubstitution, isSubstitutionEnabled: isSubstitutionEnabled, - onEmitNode: onEmitNode, + onEmitNode: function (node, emitContext, emitCallback) { return emitCallback(node, emitContext); }, enableEmitNotification: enableEmitNotification, isEmitNotificationEnabled: isEmitNotificationEnabled }; // Chain together and initialize each transformer. - var transformation = chain.apply(void 0, transformers)(context); + var transformation = ts.chain.apply(void 0, transformers)(context); // Transform each source file. var transformed = ts.map(sourceFiles, transformSourceFile); // Disable modification of the lexical environment. lexicalEnvironmentDisabled = true; return { - getSourceFiles: function () { return transformed; }, - getTokenSourceMapRange: getTokenSourceMapRange, - isSubstitutionEnabled: isSubstitutionEnabled, - isEmitNotificationEnabled: isEmitNotificationEnabled, - onSubstituteNode: context.onSubstituteNode, - onEmitNode: context.onEmitNode, - dispose: function () { - // During transformation we may need to annotate a parse tree node with transient - // transformation properties. As parse tree nodes live longer than transformation - // nodes, we need to make sure we reclaim any memory allocated for custom ranges - // from these nodes to ensure we do not hold onto entire subtrees just for position - // information. We also need to reset these nodes to a pre-transformation state - // for incremental parsing scenarios so that we do not impact later emit. - for (var _i = 0, parseTreeNodesWithAnnotations_1 = parseTreeNodesWithAnnotations; _i < parseTreeNodesWithAnnotations_1.length; _i++) { - var node = parseTreeNodesWithAnnotations_1[_i]; - if (node.transformId === transformId) { - node.transformId = 0; - node.emitFlags = 0; - node.commentRange = undefined; - node.sourceMapRange = undefined; - } - } - parseTreeNodesWithAnnotations.length = 0; - } + transformed: transformed, + emitNodeWithSubstitution: emitNodeWithSubstitution, + emitNodeWithNotification: emitNodeWithNotification }; /** * Transforms a source file. @@ -51660,17 +53112,27 @@ var ts; * Determines whether expression substitutions are enabled for the provided node. */ function isSubstitutionEnabled(node) { - return (enabledSyntaxKindFeatures[node.kind] & 1 /* Substitution */) !== 0; + return (enabledSyntaxKindFeatures[node.kind] & 1 /* Substitution */) !== 0 + && (ts.getEmitFlags(node) & 128 /* NoSubstitution */) === 0; } /** - * Default hook for node substitutions. + * Emits a node with possible substitution. * - * @param node The node to substitute. - * @param isExpression A value indicating whether the node is to be used in an expression - * position. + * @param emitContext The current emit context. + * @param node The node to emit. + * @param emitCallback The callback used to emit the node or its substitute. */ - function onSubstituteNode(node, isExpression) { - return node; + function emitNodeWithSubstitution(emitContext, node, emitCallback) { + if (node) { + if (isSubstitutionEnabled(node)) { + var substitute = context.onSubstituteNode(emitContext, node); + if (substitute && substitute !== node) { + emitCallback(emitContext, substitute); + return; + } + } + emitCallback(emitContext, node); + } } /** * Enables before/after emit notifications in the pretty printer for the provided SyntaxKind. @@ -51684,141 +53146,24 @@ var ts; */ function isEmitNotificationEnabled(node) { return (enabledSyntaxKindFeatures[node.kind] & 2 /* EmitNotifications */) !== 0 - || (getNodeEmitFlags(node) & 64 /* AdviseOnEmitNode */) !== 0; + || (ts.getEmitFlags(node) & 64 /* AdviseOnEmitNode */) !== 0; } /** - * Default hook for node emit. + * Emits a node with possible emit notification. * + * @param emitContext The current emit context. * @param node The node to emit. - * @param emit A callback used to emit the node in the printer. + * @param emitCallback The callback used to emit the node. */ - function onEmitNode(node, emit) { - emit(node); - } - /** - * Associates a node with the current transformation, initializing - * various transient transformation properties. - * - * @param node The node. - */ - function beforeSetAnnotation(node) { - if ((node.flags & 8 /* Synthesized */) === 0 && node.transformId !== transformId) { - // To avoid holding onto transformation artifacts, we keep track of any - // parse tree node we are annotating. This allows us to clean them up after - // all transformations have completed. - parseTreeNodesWithAnnotations.push(node); - node.transformId = transformId; - } - } - /** - * Gets flags that control emit behavior of a node. - * - * If the node does not have its own NodeEmitFlags set, the node emit flags of its - * original pointer are used. - * - * @param node The node. - */ - function getNodeEmitFlags(node) { - return node.emitFlags; - } - /** - * Sets flags that control emit behavior of a node. - * - * @param node The node. - * @param emitFlags The NodeEmitFlags for the node. - */ - function setNodeEmitFlags(node, emitFlags) { - beforeSetAnnotation(node); - node.emitFlags = emitFlags; - return node; - } - /** - * Gets a custom text range to use when emitting source maps. - * - * If a node does not have its own custom source map text range, the custom source map - * text range of its original pointer is used. - * - * @param node The node. - */ - function getSourceMapRange(node) { - return node.sourceMapRange || node; - } - /** - * Sets a custom text range to use when emitting source maps. - * - * @param node The node. - * @param range The text range. - */ - function setSourceMapRange(node, range) { - beforeSetAnnotation(node); - node.sourceMapRange = range; - return node; - } - /** - * Gets the TextRange to use for source maps for a token of a node. - * - * If a node does not have its own custom source map text range for a token, the custom - * source map text range for the token of its original pointer is used. - * - * @param node The node. - * @param token The token. - */ - function getTokenSourceMapRange(node, token) { - // As a performance optimization, use the cached value of the most recent node. - // This helps for cases where this function is called repeatedly for the same node. - if (lastTokenSourceMapRangeNode === node && lastTokenSourceMapRangeToken === token) { - return lastTokenSourceMapRange; - } - // Get the custom token source map range for a node or from one of its original nodes. - // Custom token ranges are not stored on the node to avoid the GC burden. - var range; - var current = node; - while (current) { - range = current.id ? tokenSourceMapRanges[current.id + "-" + token] : undefined; - if (range !== undefined) { - break; + function emitNodeWithNotification(emitContext, node, emitCallback) { + if (node) { + if (isEmitNotificationEnabled(node)) { + context.onEmitNode(emitContext, node, emitCallback); + } + else { + emitCallback(emitContext, node); } - current = current.original; } - // Cache the most recently requested value. - lastTokenSourceMapRangeNode = node; - lastTokenSourceMapRangeToken = token; - lastTokenSourceMapRange = range; - return range; - } - /** - * Sets the TextRange to use for source maps for a token of a node. - * - * @param node The node. - * @param token The token. - * @param range The text range. - */ - function setTokenSourceMapRange(node, token, range) { - // Cache the most recently requested value. - lastTokenSourceMapRangeNode = node; - lastTokenSourceMapRangeToken = token; - lastTokenSourceMapRange = range; - tokenSourceMapRanges[ts.getNodeId(node) + "-" + token] = range; - return node; - } - /** - * Gets a custom text range to use when emitting comments. - * - * If a node does not have its own custom source map text range, the custom source map - * text range of its original pointer is used. - * - * @param node The node. - */ - function getCommentRange(node) { - return node.commentRange || node; - } - /** - * Sets a custom text range to use when emitting comments. - */ - function setCommentRange(node, range) { - beforeSetAnnotation(node); - node.commentRange = range; - return node; } /** * Records a hoisted variable declaration for the provided name within a lexical environment. @@ -51891,95 +53236,12 @@ var ts; } } ts.transformFiles = transformFiles; - function chain(a, b, c, d, e) { - if (e) { - var args_3 = []; - for (var i = 0; i < arguments.length; i++) { - args_3[i] = arguments[i]; - } - return function (t) { return compose.apply(void 0, ts.map(args_3, function (f) { return f(t); })); }; - } - else if (d) { - return function (t) { return compose(a(t), b(t), c(t), d(t)); }; - } - else if (c) { - return function (t) { return compose(a(t), b(t), c(t)); }; - } - else if (b) { - return function (t) { return compose(a(t), b(t)); }; - } - else if (a) { - return function (t) { return compose(a(t)); }; - } - else { - return function (t) { return function (u) { return u; }; }; - } - } - function compose(a, b, c, d, e) { - if (e) { - var args_4 = []; - for (var i = 0; i < arguments.length; i++) { - args_4[i] = arguments[i]; - } - return function (t) { return ts.reduceLeft(args_4, function (u, f) { return f(u); }, t); }; - } - else if (d) { - return function (t) { return d(c(b(a(t)))); }; - } - else if (c) { - return function (t) { return c(b(a(t))); }; - } - else if (b) { - return function (t) { return b(a(t)); }; - } - else if (a) { - return function (t) { return a(t); }; - } - else { - return function (t) { return t; }; - } - } var _a; })(ts || (ts = {})); /// /* @internal */ var ts; (function (ts) { - function createSourceMapWriter(host, writer) { - var compilerOptions = host.getCompilerOptions(); - if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) { - if (compilerOptions.extendedDiagnostics) { - return createSourceMapWriterWithExtendedDiagnostics(host, writer); - } - return createSourceMapWriterWorker(host, writer); - } - else { - return getNullSourceMapWriter(); - } - } - ts.createSourceMapWriter = createSourceMapWriter; - var nullSourceMapWriter; - function getNullSourceMapWriter() { - if (nullSourceMapWriter === undefined) { - nullSourceMapWriter = { - initialize: function (filePath, sourceMapFilePath, sourceFiles, isBundledEmit) { }, - reset: function () { }, - getSourceMapData: function () { return undefined; }, - setSourceFile: function (sourceFile) { }, - emitPos: function (pos) { }, - emitStart: function (range, contextNode, ignoreNodeCallback, ignoreChildrenCallback, getTextRangeCallback) { }, - emitEnd: function (range, contextNode, ignoreNodeCallback, ignoreChildrenCallback, getTextRangeCallback) { }, - emitTokenStart: function (token, pos, contextNode, ignoreTokenCallback, getTokenTextRangeCallback) { return -1; }, - emitTokenEnd: function (token, end, contextNode, ignoreTokenCallback, getTokenTextRangeCallback) { return -1; }, - changeEmitSourcePos: function () { }, - stopOverridingSpan: function () { }, - getText: function () { return undefined; }, - getSourceMappingURL: function () { return undefined; } - }; - } - return nullSourceMapWriter; - } - ts.getNullSourceMapWriter = getNullSourceMapWriter; // Used for initialize lastEncodedSourceMapSpan and reset lastEncodedSourceMapSpan when updateLastEncodedAndRecordedSpans var defaultLastEncodedSourceMapSpan = { emittedLine: 1, @@ -51988,14 +53250,12 @@ var ts; sourceColumn: 1, sourceIndex: 0 }; - function createSourceMapWriterWorker(host, writer) { + function createSourceMapWriter(host, writer) { var compilerOptions = host.getCompilerOptions(); var extendedDiagnostics = compilerOptions.extendedDiagnostics; var currentSourceFile; var currentSourceText; var sourceMapDir; // The directory in which sourcemap will be - var stopOverridingSpan = false; - var modifyLastSourcePos = false; // Current source map file and its index in the sources list var sourceMapSourceIndex; // Last recorded and encoded spans @@ -52004,24 +53264,15 @@ var ts; var lastEncodedNameIndex; // Source map data var sourceMapData; - // This keeps track of the number of times `disable` has been called without a - // corresponding call to `enable`. As long as this value is non-zero, mappings will not - // be recorded. - // This is primarily used to provide a better experience when debugging binding - // patterns and destructuring assignments for simple expressions. - var disableDepth; + var disabled = !(compilerOptions.sourceMap || compilerOptions.inlineSourceMap); return { initialize: initialize, reset: reset, getSourceMapData: function () { return sourceMapData; }, setSourceFile: setSourceFile, emitPos: emitPos, - emitStart: emitStart, - emitEnd: emitEnd, - emitTokenStart: emitTokenStart, - emitTokenEnd: emitTokenEnd, - changeEmitSourcePos: changeEmitSourcePos, - stopOverridingSpan: function () { return stopOverridingSpan = true; }, + emitNodeWithSourceMap: emitNodeWithSourceMap, + emitTokenWithSourceMap: emitTokenWithSourceMap, getText: getText, getSourceMappingURL: getSourceMappingURL }; @@ -52034,12 +53285,14 @@ var ts; * @param isBundledEmit A value indicating whether the generated output file is a bundle. */ function initialize(filePath, sourceMapFilePath, sourceFiles, isBundledEmit) { + if (disabled) { + return; + } if (sourceMapData) { reset(); } currentSourceFile = undefined; currentSourceText = undefined; - disableDepth = 0; // Current source map file and its index in the sources list sourceMapSourceIndex = -1; // Last recorded and encoded spans @@ -52093,6 +53346,9 @@ var ts; * Reset the SourceMapWriter to an empty state. */ function reset() { + if (disabled) { + return; + } currentSourceFile = undefined; sourceMapDir = undefined; sourceMapSourceIndex = undefined; @@ -52100,56 +53356,6 @@ var ts; lastEncodedSourceMapSpan = undefined; lastEncodedNameIndex = undefined; sourceMapData = undefined; - disableDepth = 0; - } - /** - * Re-enables the recording of mappings. - */ - function enable() { - if (disableDepth > 0) { - disableDepth--; - } - } - /** - * Disables the recording of mappings. - */ - function disable() { - disableDepth++; - } - function updateLastEncodedAndRecordedSpans() { - if (modifyLastSourcePos) { - // Reset the source pos - modifyLastSourcePos = false; - // Change Last recorded Map with last encoded emit line and character - lastRecordedSourceMapSpan.emittedLine = lastEncodedSourceMapSpan.emittedLine; - lastRecordedSourceMapSpan.emittedColumn = lastEncodedSourceMapSpan.emittedColumn; - // Pop sourceMapDecodedMappings to remove last entry - sourceMapData.sourceMapDecodedMappings.pop(); - // Point the lastEncodedSourceMapSpace to the previous encoded sourceMapSpan - // If the list is empty which indicates that we are at the beginning of the file, - // we have to reset it to default value (same value when we first initialize sourceMapWriter) - lastEncodedSourceMapSpan = sourceMapData.sourceMapDecodedMappings.length ? - sourceMapData.sourceMapDecodedMappings[sourceMapData.sourceMapDecodedMappings.length - 1] : - defaultLastEncodedSourceMapSpan; - // TODO: Update lastEncodedNameIndex - // Since we dont support this any more, lets not worry about it right now. - // When we start supporting nameIndex, we will get back to this - // Change the encoded source map - var sourceMapMappings = sourceMapData.sourceMapMappings; - var lenthToSet = sourceMapMappings.length - 1; - for (; lenthToSet >= 0; lenthToSet--) { - var currentChar = sourceMapMappings.charAt(lenthToSet); - if (currentChar === ",") { - // Separator for the entry found - break; - } - if (currentChar === ";" && lenthToSet !== 0 && sourceMapMappings.charAt(lenthToSet - 1) !== ";") { - // Last line separator found - break; - } - } - sourceMapData.sourceMapMappings = sourceMapMappings.substr(0, Math.max(0, lenthToSet)); - } } // Encoding for sourcemap span function encodeLastRecordedSourceMapSpan() { @@ -52197,7 +53403,7 @@ var ts; * @param pos The position. */ function emitPos(pos) { - if (ts.positionIsSynthesized(pos) || disableDepth > 0) { + if (disabled || ts.positionIsSynthesized(pos)) { return; } if (extendedDiagnostics) { @@ -52226,84 +53432,78 @@ var ts; sourceColumn: sourceLinePos.character, sourceIndex: sourceMapSourceIndex }; - stopOverridingSpan = false; } - else if (!stopOverridingSpan) { + else { // Take the new pos instead since there is no change in emittedLine and column since last location lastRecordedSourceMapSpan.sourceLine = sourceLinePos.line; lastRecordedSourceMapSpan.sourceColumn = sourceLinePos.character; lastRecordedSourceMapSpan.sourceIndex = sourceMapSourceIndex; } - updateLastEncodedAndRecordedSpans(); if (extendedDiagnostics) { ts.performance.mark("afterSourcemap"); ts.performance.measure("Source Map", "beforeSourcemap", "afterSourcemap"); } } - function getStartPosPastDecorators(range) { - var rangeHasDecorators = !!range.decorators; - return ts.skipTrivia(currentSourceText, rangeHasDecorators ? range.decorators.end : range.pos); - } - function emitStart(range, contextNode, ignoreNodeCallback, ignoreChildrenCallback, getTextRangeCallback) { - if (contextNode) { - if (!ignoreNodeCallback(contextNode)) { - range = getTextRangeCallback(contextNode) || range; - emitPos(getStartPosPastDecorators(range)); - } - if (ignoreChildrenCallback(contextNode)) { - disable(); - } + /** + * Emits a node with possible leading and trailing source maps. + * + * @param node The node to emit. + * @param emitCallback The callback used to emit the node. + */ + function emitNodeWithSourceMap(emitContext, node, emitCallback) { + if (disabled) { + return emitCallback(emitContext, node); } - else { - emitPos(getStartPosPastDecorators(range)); + if (node) { + var emitNode = node.emitNode; + var emitFlags = emitNode && emitNode.flags; + var _a = emitNode && emitNode.sourceMapRange || node, pos = _a.pos, end = _a.end; + if (node.kind !== 287 /* NotEmittedStatement */ + && (emitFlags & 512 /* NoLeadingSourceMap */) === 0 + && pos >= 0) { + emitPos(ts.skipTrivia(currentSourceText, pos)); + } + if (emitFlags & 2048 /* NoNestedSourceMaps */) { + disabled = true; + emitCallback(emitContext, node); + disabled = false; + } + else { + emitCallback(emitContext, node); + } + if (node.kind !== 287 /* NotEmittedStatement */ + && (emitFlags & 1024 /* NoTrailingSourceMap */) === 0 + && end >= 0) { + emitPos(end); + } } } - function emitEnd(range, contextNode, ignoreNodeCallback, ignoreChildrenCallback, getTextRangeCallback) { - if (contextNode) { - if (ignoreChildrenCallback(contextNode)) { - enable(); - } - if (!ignoreNodeCallback(contextNode)) { - range = getTextRangeCallback(contextNode) || range; - emitPos(range.end); - } + /** + * Emits a token of a node with possible leading and trailing source maps. + * + * @param node The node containing the token. + * @param token The token to emit. + * @param tokenStartPos The start pos of the token. + * @param emitCallback The callback used to emit the token. + */ + function emitTokenWithSourceMap(node, token, tokenPos, emitCallback) { + if (disabled) { + return emitCallback(token, tokenPos); } - else { - emitPos(range.end); + var emitNode = node && node.emitNode; + var emitFlags = emitNode && emitNode.flags; + var range = emitNode && emitNode.tokenSourceMapRanges && emitNode.tokenSourceMapRanges[token]; + tokenPos = ts.skipTrivia(currentSourceText, range ? range.pos : tokenPos); + if ((emitFlags & 4096 /* NoTokenLeadingSourceMaps */) === 0 && tokenPos >= 0) { + emitPos(tokenPos); } - stopOverridingSpan = false; - } - function emitTokenStart(token, tokenStartPos, contextNode, ignoreTokenCallback, getTokenTextRangeCallback) { - if (contextNode) { - if (ignoreTokenCallback(contextNode, token)) { - return ts.skipTrivia(currentSourceText, tokenStartPos); - } - var range = getTokenTextRangeCallback(contextNode, token); - if (range) { - tokenStartPos = range.pos; - } + tokenPos = emitCallback(token, tokenPos); + if (range) + tokenPos = range.end; + if ((emitFlags & 8192 /* NoTokenTrailingSourceMaps */) === 0 && tokenPos >= 0) { + emitPos(tokenPos); } - tokenStartPos = ts.skipTrivia(currentSourceText, tokenStartPos); - emitPos(tokenStartPos); - return tokenStartPos; - } - function emitTokenEnd(token, tokenEndPos, contextNode, ignoreTokenCallback, getTokenTextRangeCallback) { - if (contextNode) { - if (ignoreTokenCallback(contextNode, token)) { - return tokenEndPos; - } - var range = getTokenTextRangeCallback(contextNode, token); - if (range) { - tokenEndPos = range.end; - } - } - emitPos(tokenEndPos); - return tokenEndPos; - } - // @deprecated - function changeEmitSourcePos() { - ts.Debug.assert(!modifyLastSourcePos); - modifyLastSourcePos = true; + return tokenPos; } /** * Set the current source file. @@ -52311,6 +53511,9 @@ var ts; * @param sourceFile The source file. */ function setSourceFile(sourceFile) { + if (disabled) { + return; + } currentSourceFile = sourceFile; currentSourceText = currentSourceFile.text; // Add the file to tsFilePaths @@ -52334,6 +53537,9 @@ var ts; * Gets the text for the source map. */ function getText() { + if (disabled) { + return; + } encodeLastRecordedSourceMapSpan(); return ts.stringify({ version: 3, @@ -52349,6 +53555,9 @@ var ts; * Gets the SourceMappingURL for the source map. */ function getSourceMappingURL() { + if (disabled) { + return; + } if (compilerOptions.inlineSourceMap) { // Encode the sourceMap into the sourceMap url var base64SourceMapText = ts.convertToBase64(getText()); @@ -52359,46 +53568,7 @@ var ts; } } } - function createSourceMapWriterWithExtendedDiagnostics(host, writer) { - var _a = createSourceMapWriterWorker(host, writer), initialize = _a.initialize, reset = _a.reset, getSourceMapData = _a.getSourceMapData, setSourceFile = _a.setSourceFile, emitPos = _a.emitPos, emitStart = _a.emitStart, emitEnd = _a.emitEnd, emitTokenStart = _a.emitTokenStart, emitTokenEnd = _a.emitTokenEnd, changeEmitSourcePos = _a.changeEmitSourcePos, stopOverridingSpan = _a.stopOverridingSpan, getText = _a.getText, getSourceMappingURL = _a.getSourceMappingURL; - return { - initialize: initialize, - reset: reset, - getSourceMapData: getSourceMapData, - setSourceFile: setSourceFile, - emitPos: function (pos) { - ts.performance.mark("sourcemapStart"); - emitPos(pos); - ts.performance.measure("sourceMapTime", "sourcemapStart"); - }, - emitStart: function (range, contextNode, ignoreNodeCallback, ignoreChildrenCallback, getTextRangeCallback) { - ts.performance.mark("emitSourcemap:emitStart"); - emitStart(range, contextNode, ignoreNodeCallback, ignoreChildrenCallback, getTextRangeCallback); - ts.performance.measure("sourceMapTime", "emitSourcemap:emitStart"); - }, - emitEnd: function (range, contextNode, ignoreNodeCallback, ignoreChildrenCallback, getTextRangeCallback) { - ts.performance.mark("emitSourcemap:emitEnd"); - emitEnd(range, contextNode, ignoreNodeCallback, ignoreChildrenCallback, getTextRangeCallback); - ts.performance.measure("sourceMapTime", "emitSourcemap:emitEnd"); - }, - emitTokenStart: function (token, tokenStartPos, contextNode, ignoreTokenCallback, getTokenTextRangeCallback) { - ts.performance.mark("emitSourcemap:emitTokenStart"); - tokenStartPos = emitTokenStart(token, tokenStartPos, contextNode, ignoreTokenCallback, getTokenTextRangeCallback); - ts.performance.measure("sourceMapTime", "emitSourcemap:emitTokenStart"); - return tokenStartPos; - }, - emitTokenEnd: function (token, tokenEndPos, contextNode, ignoreTokenCallback, getTokenTextRangeCallback) { - ts.performance.mark("emitSourcemap:emitTokenEnd"); - tokenEndPos = emitTokenEnd(token, tokenEndPos, contextNode, ignoreTokenCallback, getTokenTextRangeCallback); - ts.performance.measure("sourceMapTime", "emitSourcemap:emitTokenEnd"); - return tokenEndPos; - }, - changeEmitSourcePos: changeEmitSourcePos, - stopOverridingSpan: stopOverridingSpan, - getText: getText, - getSourceMappingURL: getSourceMappingURL - }; - } + ts.createSourceMapWriter = createSourceMapWriter; var base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; function base64FormatEncode(inValue) { if (inValue < 64) { @@ -52457,21 +53627,23 @@ var ts; emitBodyWithDetachedComments: emitBodyWithDetachedComments, emitTrailingCommentsOfPosition: emitTrailingCommentsOfPosition }; - function emitNodeWithComments(node, emitCallback) { + function emitNodeWithComments(emitContext, node, emitCallback) { if (disabled) { - emitCallback(node); + emitCallback(emitContext, node); return; } if (node) { - var _a = node.commentRange || node, pos = _a.pos, end = _a.end; - var emitFlags = node.emitFlags; + var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; + var emitFlags = ts.getEmitFlags(node); if ((pos < 0 && end < 0) || (pos === end)) { // Both pos and end are synthesized, so just emit the node without comments. if (emitFlags & 65536 /* NoNestedComments */) { - disableCommentsAndEmit(node, emitCallback); + disabled = true; + emitCallback(emitContext, node); + disabled = false; } else { - emitCallback(node); + emitCallback(emitContext, node); } } else { @@ -52505,10 +53677,12 @@ var ts; ts.performance.measure("commentTime", "preEmitNodeWithComment"); } if (emitFlags & 65536 /* NoNestedComments */) { - disableCommentsAndEmit(node, emitCallback); + disabled = true; + emitCallback(emitContext, node); + disabled = false; } else { - emitCallback(node); + emitCallback(emitContext, node); } if (extendedDiagnostics) { ts.performance.mark("beginEmitNodeWithComment"); @@ -52533,7 +53707,7 @@ var ts; ts.performance.mark("preEmitBodyWithDetachedComments"); } var pos = detachedRange.pos, end = detachedRange.end; - var emitFlags = node.emitFlags; + var emitFlags = ts.getEmitFlags(node); var skipLeadingComments = pos < 0 || (emitFlags & 16384 /* NoLeadingComments */) !== 0; var skipTrailingComments = disabled || end < 0 || (emitFlags & 32768 /* NoTrailingComments */) !== 0; if (!skipLeadingComments) { @@ -52542,8 +53716,10 @@ var ts; if (extendedDiagnostics) { ts.performance.measure("commentTime", "preEmitBodyWithDetachedComments"); } - if (emitFlags & 65536 /* NoNestedComments */) { - disableCommentsAndEmit(node, emitCallback); + if (emitFlags & 65536 /* NoNestedComments */ && !disabled) { + disabled = true; + emitCallback(node); + disabled = false; } else { emitCallback(node); @@ -52664,16 +53840,6 @@ var ts; currentLineMap = ts.getLineStarts(currentSourceFile); detachedCommentsInfo = undefined; } - function disableCommentsAndEmit(node, emitCallback) { - if (disabled) { - emitCallback(node); - } - else { - disabled = true; - emitCallback(node); - disabled = false; - } - } function hasDetachedComments(pos) { return detachedCommentsInfo !== undefined && ts.lastOrUndefined(detachedCommentsInfo).nodePos === pos; } @@ -52735,11 +53901,11 @@ var ts; return declarationDiagnostics.getDiagnostics(targetSourceFile ? targetSourceFile.fileName : undefined); function getDeclarationDiagnosticsFromFile(_a, sources, isBundledEmit) { var declarationFilePath = _a.declarationFilePath; - emitDeclarations(host, resolver, declarationDiagnostics, declarationFilePath, sources, isBundledEmit); + emitDeclarations(host, resolver, declarationDiagnostics, declarationFilePath, sources, isBundledEmit, /*emitOnlyDtsFiles*/ false); } } ts.getDeclarationDiagnostics = getDeclarationDiagnostics; - function emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFiles, isBundledEmit) { + function emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFiles, isBundledEmit, emitOnlyDtsFiles) { var newLine = host.getNewLine(); var compilerOptions = host.getCompilerOptions(); var write; @@ -52786,7 +53952,7 @@ var ts; // global file reference is added only // - if it is not bundled emit (because otherwise it would be self reference) // - and it is not already added - if (writeReferencePath(referencedFile, !isBundledEmit && !addedGlobalFileReference)) { + if (writeReferencePath(referencedFile, !isBundledEmit && !addedGlobalFileReference, emitOnlyDtsFiles)) { addedGlobalFileReference = true; } emittedReferencedFiles.push(referencedFile); @@ -52987,7 +54153,7 @@ var ts; } else { errorNameNode = declaration.name; - resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); + resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2 /* UseTypeOfFunction */ | 1024 /* UseTypeAliasValue */, writer); errorNameNode = undefined; } } @@ -53000,7 +54166,7 @@ var ts; } else { errorNameNode = signature.name; - resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); + resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, 2 /* UseTypeOfFunction */ | 1024 /* UseTypeAliasValue */, writer); errorNameNode = undefined; } } @@ -53202,7 +54368,7 @@ var ts; write(tempVarName); write(": "); writer.getSymbolAccessibilityDiagnostic = getDefaultExportAccessibilityDiagnostic; - resolver.writeTypeOfExpression(node.expression, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); + resolver.writeTypeOfExpression(node.expression, enclosingDeclaration, 2 /* UseTypeOfFunction */ | 1024 /* UseTypeAliasValue */, writer); write(";"); writeLine(); write(node.isExportEquals ? "export = " : "export default "); @@ -53624,7 +54790,7 @@ var ts; } else { writer.getSymbolAccessibilityDiagnostic = getHeritageClauseVisibilityError; - resolver.writeBaseConstructorTypeOfClass(enclosingDeclaration, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); + resolver.writeBaseConstructorTypeOfClass(enclosingDeclaration, enclosingDeclaration, 2 /* UseTypeOfFunction */ | 1024 /* UseTypeAliasValue */, writer); } function getHeritageClauseVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; @@ -54265,7 +55431,7 @@ var ts; * @param referencedFile * @param addBundledFileReference Determines if global file reference corresponding to bundled file should be emitted or not */ - function writeReferencePath(referencedFile, addBundledFileReference) { + function writeReferencePath(referencedFile, addBundledFileReference, emitOnlyDtsFiles) { var declFileName; var addedBundledEmitReference = false; if (ts.isDeclarationFile(referencedFile)) { @@ -54274,7 +55440,7 @@ var ts; } else { // Get the declaration file path - ts.forEachExpectedEmitFile(host, getDeclFileName, referencedFile); + ts.forEachExpectedEmitFile(host, getDeclFileName, referencedFile, emitOnlyDtsFiles); } if (declFileName) { declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(declarationFilePath)), declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, @@ -54294,8 +55460,8 @@ var ts; } } /* @internal */ - function writeDeclarationFile(declarationFilePath, sourceFiles, isBundledEmit, host, resolver, emitterDiagnostics) { - var emitDeclarationResult = emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFiles, isBundledEmit); + function writeDeclarationFile(declarationFilePath, sourceFiles, isBundledEmit, host, resolver, emitterDiagnostics, emitOnlyDtsFiles) { + var emitDeclarationResult = emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFiles, isBundledEmit, emitOnlyDtsFiles); var emitSkipped = emitDeclarationResult.reportedDeclarationError || host.isEmitBlocked(declarationFilePath) || host.getCompilerOptions().noEmit; if (!emitSkipped) { var declarationOutput = emitDeclarationResult.referencesOutput @@ -54335,8 +55501,10 @@ var ts; TempFlags[TempFlags["CountMask"] = 268435455] = "CountMask"; TempFlags[TempFlags["_i"] = 268435456] = "_i"; })(TempFlags || (TempFlags = {})); + var id = function (s) { return s; }; + var nullTransformers = [function (ctx) { return id; }]; // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature - function emitFiles(resolver, host, targetSourceFile) { + function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles) { var delimiters = createDelimiterMap(); var brackets = createBracketsMap(); // emit output for the __extends helper function @@ -54352,7 +55520,7 @@ var ts; // emit output for the __param helper function var paramHelper = "\nvar __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; // emit output for the __awaiter helper function - var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments)).next());\n });\n};"; + var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments)).next());\n });\n};"; // The __generator helper is used by down-level transformations to emulate the runtime // semantics of an ES2015 generator function. When called, this helper returns an // object that implements the Iterator protocol, in that it has `next`, `return`, and @@ -54426,11 +55594,11 @@ var ts; var emittedFilesList = compilerOptions.listEmittedFiles ? [] : undefined; var emitterDiagnostics = ts.createDiagnosticCollection(); var newLine = host.getNewLine(); - var transformers = ts.getTransformers(compilerOptions); + var transformers = emitOnlyDtsFiles ? nullTransformers : ts.getTransformers(compilerOptions); var writer = ts.createTextWriter(newLine); var write = writer.write, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; var sourceMap = ts.createSourceMapWriter(host, writer); - var emitStart = sourceMap.emitStart, emitEnd = sourceMap.emitEnd, emitTokenStart = sourceMap.emitTokenStart, emitTokenEnd = sourceMap.emitTokenEnd; + var emitNodeWithSourceMap = sourceMap.emitNodeWithSourceMap, emitTokenWithSourceMap = sourceMap.emitTokenWithSourceMap; var comments = ts.createCommentWriter(host, writer, sourceMap); var emitNodeWithComments = comments.emitNodeWithComments, emitBodyWithDetachedComments = comments.emitBodyWithDetachedComments, emitTrailingCommentsOfPosition = comments.emitTrailingCommentsOfPosition; var nodeIdToGeneratedName; @@ -54447,18 +55615,20 @@ var ts; var awaiterEmitted; var isOwnFileEmit; var emitSkipped = false; - ts.performance.mark("beforeTransform"); + var sourceFiles = ts.getSourceFilesToEmit(host, targetSourceFile); // Transform the source files - var transformed = ts.transformFiles(resolver, host, ts.getSourceFilesToEmit(host, targetSourceFile), transformers); + ts.performance.mark("beforeTransform"); + var _a = ts.transformFiles(resolver, host, sourceFiles, transformers), transformed = _a.transformed, emitNodeWithSubstitution = _a.emitNodeWithSubstitution, emitNodeWithNotification = _a.emitNodeWithNotification; ts.performance.measure("transformTime", "beforeTransform"); - // Extract helpers from the result - var getTokenSourceMapRange = transformed.getTokenSourceMapRange, isSubstitutionEnabled = transformed.isSubstitutionEnabled, isEmitNotificationEnabled = transformed.isEmitNotificationEnabled, onSubstituteNode = transformed.onSubstituteNode, onEmitNode = transformed.onEmitNode; - ts.performance.mark("beforePrint"); // Emit each output file - ts.forEachTransformedEmitFile(host, transformed.getSourceFiles(), emitFile); - // Clean up after transformation - transformed.dispose(); + ts.performance.mark("beforePrint"); + ts.forEachTransformedEmitFile(host, transformed, emitFile, emitOnlyDtsFiles); ts.performance.measure("printTime", "beforePrint"); + // Clean up emit nodes on parse tree + for (var _b = 0, sourceFiles_4 = sourceFiles; _b < sourceFiles_4.length; _b++) { + var sourceFile = sourceFiles_4[_b]; + ts.disposeEmitNodes(sourceFile); + } return { emitSkipped: emitSkipped, diagnostics: emitterDiagnostics.getDiagnostics(), @@ -54468,16 +55638,20 @@ var ts; function emitFile(jsFilePath, sourceMapFilePath, declarationFilePath, sourceFiles, isBundledEmit) { // Make sure not to write js file and source map file if any of them cannot be written if (!host.isEmitBlocked(jsFilePath) && !compilerOptions.noEmit) { - printFile(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit); + if (!emitOnlyDtsFiles) { + printFile(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit); + } } else { emitSkipped = true; } if (declarationFilePath) { - emitSkipped = ts.writeDeclarationFile(declarationFilePath, ts.getOriginalSourceFiles(sourceFiles), isBundledEmit, host, resolver, emitterDiagnostics) || emitSkipped; + emitSkipped = ts.writeDeclarationFile(declarationFilePath, ts.getOriginalSourceFiles(sourceFiles), isBundledEmit, host, resolver, emitterDiagnostics, emitOnlyDtsFiles) || emitSkipped; } if (!emitSkipped && emittedFilesList) { - emittedFilesList.push(jsFilePath); + if (!emitOnlyDtsFiles) { + emittedFilesList.push(jsFilePath); + } if (sourceMapFilePath) { emittedFilesList.push(sourceMapFilePath); } @@ -54494,8 +55668,8 @@ var ts; isOwnFileEmit = !isBundledEmit; // Emit helpers from all the files if (isBundledEmit && moduleKind) { - for (var _a = 0, sourceFiles_4 = sourceFiles; _a < sourceFiles_4.length; _a++) { - var sourceFile = sourceFiles_4[_a]; + for (var _a = 0, sourceFiles_5 = sourceFiles; _a < sourceFiles_5.length; _a++) { + var sourceFile = sourceFiles_5[_a]; emitEmitHelpers(sourceFile); } } @@ -54536,135 +55710,124 @@ var ts; currentFileIdentifiers = node.identifiers; sourceMap.setSourceFile(node); comments.setSourceFile(node); - emitNodeWithNotification(node, emitWorker); + pipelineEmitWithNotification(0 /* SourceFile */, node); } /** * Emits a node. */ function emit(node) { - emitNodeWithNotification(node, emitWithComments); + pipelineEmitWithNotification(3 /* Unspecified */, node); } /** - * Emits a node with comments. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called indirectly from emit. + * Emits an IdentifierName. */ - function emitWithComments(node) { - emitNodeWithComments(node, emitWithSourceMap); - } - /** - * Emits a node with source maps. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called indirectly from emitWithComments. - */ - function emitWithSourceMap(node) { - emitNodeWithSourceMap(node, emitWorker); - } function emitIdentifierName(node) { - if (node) { - emitNodeWithNotification(node, emitIdentifierNameWithComments); - } - } - function emitIdentifierNameWithComments(node) { - emitNodeWithComments(node, emitWorker); + pipelineEmitWithNotification(2 /* IdentifierName */, node); } /** * Emits an expression node. */ function emitExpression(node) { - emitNodeWithNotification(node, emitExpressionWithComments); + pipelineEmitWithNotification(1 /* Expression */, node); } /** - * Emits an expression with comments. + * Emits a node with possible notification. * - * NOTE: Do not call this method directly. It is part of the emitExpression pipeline - * and should only be called indirectly from emitExpression. + * NOTE: Do not call this method directly. It is part of the emit pipeline + * and should only be called from printSourceFile, emit, emitExpression, or + * emitIdentifierName. */ - function emitExpressionWithComments(node) { - emitNodeWithComments(node, emitExpressionWithSourceMap); + function pipelineEmitWithNotification(emitContext, node) { + emitNodeWithNotification(emitContext, node, pipelineEmitWithComments); } /** - * Emits an expression with source maps. + * Emits a node with comments. * - * NOTE: Do not call this method directly. It is part of the emitExpression pipeline - * and should only be called indirectly from emitExpressionWithComments. + * NOTE: Do not call this method directly. It is part of the emit pipeline + * and should only be called indirectly from pipelineEmitWithNotification. */ - function emitExpressionWithSourceMap(node) { - emitNodeWithSourceMap(node, emitExpressionWorker); - } - /** - * Emits a node with emit notification if available. - */ - function emitNodeWithNotification(node, emitCallback) { - if (node) { - if (isEmitNotificationEnabled(node)) { - onEmitNode(node, emitCallback); - } - else { - emitCallback(node); - } - } - } - function emitNodeWithSourceMap(node, emitCallback) { - if (node) { - emitStart(/*range*/ node, /*contextNode*/ node, shouldSkipLeadingSourceMapForNode, shouldSkipSourceMapForChildren, getSourceMapRange); - emitCallback(node); - emitEnd(/*range*/ node, /*contextNode*/ node, shouldSkipTrailingSourceMapForNode, shouldSkipSourceMapForChildren, getSourceMapRange); - } - } - function getSourceMapRange(node) { - return node.sourceMapRange || node; - } - /** - * Determines whether to skip leading comment emit for a node. - * - * We do not emit comments for NotEmittedStatement nodes or any node that has - * NodeEmitFlags.NoLeadingComments. - * - * @param node A Node. - */ - function shouldSkipLeadingCommentsForNode(node) { - return ts.isNotEmittedStatement(node) - || (node.emitFlags & 16384 /* NoLeadingComments */) !== 0; - } - /** - * Determines whether to skip source map emit for the start position of a node. - * - * We do not emit source maps for NotEmittedStatement nodes or any node that - * has NodeEmitFlags.NoLeadingSourceMap. - * - * @param node A Node. - */ - function shouldSkipLeadingSourceMapForNode(node) { - return ts.isNotEmittedStatement(node) - || (node.emitFlags & 512 /* NoLeadingSourceMap */) !== 0; - } - /** - * Determines whether to skip source map emit for the end position of a node. - * - * We do not emit source maps for NotEmittedStatement nodes or any node that - * has NodeEmitFlags.NoTrailingSourceMap. - * - * @param node A Node. - */ - function shouldSkipTrailingSourceMapForNode(node) { - return ts.isNotEmittedStatement(node) - || (node.emitFlags & 1024 /* NoTrailingSourceMap */) !== 0; - } - /** - * Determines whether to skip source map emit for a node and its children. - * - * We do not emit source maps for a node that has NodeEmitFlags.NoNestedSourceMaps. - */ - function shouldSkipSourceMapForChildren(node) { - return (node.emitFlags & 2048 /* NoNestedSourceMaps */) !== 0; - } - function emitWorker(node) { - if (tryEmitSubstitute(node, emitWorker, /*isExpression*/ false)) { + function pipelineEmitWithComments(emitContext, node) { + // Do not emit comments for SourceFile + if (emitContext === 0 /* SourceFile */) { + pipelineEmitWithSourceMap(emitContext, node); return; } + emitNodeWithComments(emitContext, node, pipelineEmitWithSourceMap); + } + /** + * Emits a node with source maps. + * + * NOTE: Do not call this method directly. It is part of the emit pipeline + * and should only be called indirectly from pipelineEmitWithComments. + */ + function pipelineEmitWithSourceMap(emitContext, node) { + // Do not emit source mappings for SourceFile or IdentifierName + if (emitContext === 0 /* SourceFile */ + || emitContext === 2 /* IdentifierName */) { + pipelineEmitWithSubstitution(emitContext, node); + return; + } + emitNodeWithSourceMap(emitContext, node, pipelineEmitWithSubstitution); + } + /** + * Emits a node with possible substitution. + * + * NOTE: Do not call this method directly. It is part of the emit pipeline + * and should only be called indirectly from pipelineEmitWithSourceMap or + * pipelineEmitInUnspecifiedContext (when picking a more specific context). + */ + function pipelineEmitWithSubstitution(emitContext, node) { + emitNodeWithSubstitution(emitContext, node, pipelineEmitForContext); + } + /** + * Emits a node. + * + * NOTE: Do not call this method directly. It is part of the emit pipeline + * and should only be called indirectly from pipelineEmitWithSubstitution. + */ + function pipelineEmitForContext(emitContext, node) { + switch (emitContext) { + case 0 /* SourceFile */: return pipelineEmitInSourceFileContext(node); + case 2 /* IdentifierName */: return pipelineEmitInIdentifierNameContext(node); + case 3 /* Unspecified */: return pipelineEmitInUnspecifiedContext(node); + case 1 /* Expression */: return pipelineEmitInExpressionContext(node); + } + } + /** + * Emits a node in the SourceFile EmitContext. + * + * NOTE: Do not call this method directly. It is part of the emit pipeline + * and should only be called indirectly from pipelineEmitForContext. + */ + function pipelineEmitInSourceFileContext(node) { + var kind = node.kind; + switch (kind) { + // Top-level nodes + case 256 /* SourceFile */: + return emitSourceFile(node); + } + } + /** + * Emits a node in the IdentifierName EmitContext. + * + * NOTE: Do not call this method directly. It is part of the emit pipeline + * and should only be called indirectly from pipelineEmitForContext. + */ + function pipelineEmitInIdentifierNameContext(node) { + var kind = node.kind; + switch (kind) { + // Identifiers + case 69 /* Identifier */: + return emitIdentifier(node); + } + } + /** + * Emits a node in the Unspecified EmitContext. + * + * NOTE: Do not call this method directly. It is part of the emit pipeline + * and should only be called indirectly from pipelineEmitForContext. + */ + function pipelineEmitInUnspecifiedContext(node) { var kind = node.kind; switch (kind) { // Pseudo-literals @@ -54696,7 +55859,8 @@ var ts; case 132 /* StringKeyword */: case 133 /* SymbolKeyword */: case 137 /* GlobalKeyword */: - return writeTokenNode(node); + writeTokenText(kind); + return; // Parse tree nodes // Names case 139 /* QualifiedName */: @@ -54886,18 +56050,20 @@ var ts; // Enum case 255 /* EnumMember */: return emitEnumMember(node); - // Top-level nodes - case 256 /* SourceFile */: - return emitSourceFile(node); } + // If the node is an expression, try to emit it as an expression with + // substitution. if (ts.isExpression(node)) { - return emitExpressionWorker(node); + return pipelineEmitWithSubstitution(1 /* Expression */, node); } } - function emitExpressionWorker(node) { - if (tryEmitSubstitute(node, emitExpressionWorker, /*isExpression*/ true)) { - return; - } + /** + * Emits a node in the Expression EmitContext. + * + * NOTE: Do not call this method directly. It is part of the emit pipeline + * and should only be called indirectly from pipelineEmitForContext. + */ + function pipelineEmitInExpressionContext(node) { var kind = node.kind; switch (kind) { // Literals @@ -54916,7 +56082,8 @@ var ts; case 95 /* SuperKeyword */: case 99 /* TrueKeyword */: case 97 /* ThisKeyword */: - return writeTokenNode(node); + writeTokenText(kind); + return; // Expressions case 170 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); @@ -55010,7 +56177,7 @@ var ts; // Identifiers // function emitIdentifier(node) { - if (node.emitFlags & 16 /* UMDDefine */) { + if (ts.getEmitFlags(node) & 16 /* UMDDefine */) { writeLines(umdHelper); } else { @@ -55243,7 +56410,7 @@ var ts; write("{}"); } else { - var indentedFlag = node.emitFlags & 524288 /* Indented */; + var indentedFlag = ts.getEmitFlags(node) & 524288 /* Indented */; if (indentedFlag) { increaseIndent(); } @@ -55256,21 +56423,18 @@ var ts; } } function emitPropertyAccessExpression(node) { - if (tryEmitConstantValue(node)) { - return; - } var indentBeforeDot = false; var indentAfterDot = false; - if (!(node.emitFlags & 1048576 /* NoIndentation */)) { + if (!(ts.getEmitFlags(node) & 1048576 /* NoIndentation */)) { var dotRangeStart = node.expression.end; var dotRangeEnd = ts.skipTrivia(currentText, node.expression.end) + 1; var dotToken = { kind: 21 /* DotToken */, pos: dotRangeStart, end: dotRangeEnd }; indentBeforeDot = needsIndentation(node, node.expression, dotToken); indentAfterDot = needsIndentation(node, dotToken, node.name); } - var shouldEmitDotDot = !indentBeforeDot && needsDotDotForPropertyAccess(node.expression); emitExpression(node.expression); increaseIndentIf(indentBeforeDot); + var shouldEmitDotDot = !indentBeforeDot && needsDotDotForPropertyAccess(node.expression); write(shouldEmitDotDot ? ".." : "."); increaseIndentIf(indentAfterDot); emit(node.name); @@ -55284,17 +56448,16 @@ var ts; var text = getLiteralTextOfNode(expression); return text.indexOf(ts.tokenToString(21 /* DotToken */)) < 0; } - else { + else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { // check if constant enum value is integer - var constantValue = tryGetConstEnumValue(expression); + var constantValue = ts.getConstantValue(expression); // isFinite handles cases when constantValue is undefined - return isFinite(constantValue) && Math.floor(constantValue) === constantValue; + return isFinite(constantValue) + && Math.floor(constantValue) === constantValue + && compilerOptions.removeComments; } } function emitElementAccessExpression(node) { - if (tryEmitConstantValue(node)) { - return; - } emitExpression(node.expression); write("["); emitExpression(node.argumentExpression); @@ -55467,7 +56630,7 @@ var ts; } } function emitBlockStatements(node) { - if (node.emitFlags & 32 /* SingleLine */) { + if (ts.getEmitFlags(node) & 32 /* SingleLine */) { emitList(node, node.statements, 384 /* SingleLineBlockStatements */); } else { @@ -55645,11 +56808,11 @@ var ts; var body = node.body; if (body) { if (ts.isBlock(body)) { - var indentedFlag = node.emitFlags & 524288 /* Indented */; + var indentedFlag = ts.getEmitFlags(node) & 524288 /* Indented */; if (indentedFlag) { increaseIndent(); } - if (node.emitFlags & 4194304 /* ReuseTempVariableScope */) { + if (ts.getEmitFlags(node) & 4194304 /* ReuseTempVariableScope */) { emitSignatureHead(node); emitBlockFunctionBody(node, body); } @@ -55687,7 +56850,7 @@ var ts; // * The body is explicitly marked as multi-line. // * A non-synthesized body's start and end position are on different lines. // * Any statement in the body starts on a new line. - if (body.emitFlags & 32 /* SingleLine */) { + if (ts.getEmitFlags(body) & 32 /* SingleLine */) { return true; } if (body.multiLine) { @@ -55743,7 +56906,7 @@ var ts; emitModifiers(node, node.modifiers); write("class"); emitNodeWithPrefix(" ", node.name, emitIdentifierName); - var indentedFlag = node.emitFlags & 524288 /* Indented */; + var indentedFlag = ts.getEmitFlags(node) & 524288 /* Indented */; if (indentedFlag) { increaseIndent(); } @@ -55805,7 +56968,7 @@ var ts; emit(body); } function emitModuleBlock(node) { - if (isSingleLineEmptyBlock(node)) { + if (isEmptyBlock(node)) { write("{ }"); } else { @@ -56023,8 +57186,8 @@ var ts; // "comment1" is not considered to be leading comment for node.initializer // but rather a trailing comment on the previous node. var initializer = node.initializer; - if (!shouldSkipLeadingCommentsForNode(initializer)) { - var commentRange = initializer.commentRange || initializer; + if ((ts.getEmitFlags(initializer) & 16384 /* NoLeadingComments */) === 0) { + var commentRange = ts.getCommentRange(initializer); emitTrailingCommentsOfPosition(commentRange.pos); } emitExpression(initializer); @@ -56084,7 +57247,7 @@ var ts; return statements.length; } function emitHelpers(node) { - var emitFlags = node.emitFlags; + var emitFlags = ts.getEmitFlags(node); var helpersEmitted = false; if (emitFlags & 1 /* EmitEmitHelpers */) { helpersEmitted = emitEmitHelpers(currentSourceFile); @@ -56197,31 +57360,6 @@ var ts; write(suffix); } } - function tryEmitSubstitute(node, emitNode, isExpression) { - if (isSubstitutionEnabled(node) && (node.emitFlags & 128 /* NoSubstitution */) === 0) { - var substitute = onSubstituteNode(node, isExpression); - if (substitute !== node) { - substitute.emitFlags |= 128 /* NoSubstitution */; - emitNode(substitute); - return true; - } - } - return false; - } - function tryEmitConstantValue(node) { - var constantValue = tryGetConstEnumValue(node); - if (constantValue !== undefined) { - write(String(constantValue)); - if (!compilerOptions.removeComments) { - var propertyName = ts.isPropertyAccessExpression(node) - ? ts.declarationNameToString(node.name) - : getTextOfNode(node.argumentExpression); - write(" /* " + propertyName + " */"); - } - return true; - } - return false; - } function emitEmbeddedStatement(node) { if (ts.isBlock(node)) { write(" "); @@ -56329,7 +57467,7 @@ var ts; } } if (shouldEmitInterveningComments) { - var commentRange = child.commentRange || child; + var commentRange = ts.getCommentRange(child); emitTrailingCommentsOfPosition(commentRange.pos); } else { @@ -56375,27 +57513,12 @@ var ts; } } function writeToken(token, pos, contextNode) { - var tokenStartPos = emitTokenStart(token, pos, contextNode, shouldSkipLeadingSourceMapForToken, getTokenSourceMapRange); - var tokenEndPos = writeTokenText(token, tokenStartPos); - return emitTokenEnd(token, tokenEndPos, contextNode, shouldSkipTrailingSourceMapForToken, getTokenSourceMapRange); - } - function shouldSkipLeadingSourceMapForToken(contextNode) { - return (contextNode.emitFlags & 4096 /* NoTokenLeadingSourceMaps */) !== 0; - } - function shouldSkipTrailingSourceMapForToken(contextNode) { - return (contextNode.emitFlags & 8192 /* NoTokenTrailingSourceMaps */) !== 0; + return emitTokenWithSourceMap(contextNode, token, pos, writeTokenText); } function writeTokenText(token, pos) { var tokenString = ts.tokenToString(token); write(tokenString); - return ts.positionIsSynthesized(pos) ? -1 : pos + tokenString.length; - } - function writeTokenNode(node) { - if (node) { - emitStart(/*range*/ node, /*contextNode*/ node, shouldSkipLeadingSourceMapForNode, shouldSkipSourceMapForChildren, getSourceMapRange); - writeTokenText(node.kind); - emitEnd(/*range*/ node, /*contextNode*/ node, shouldSkipTrailingSourceMapForNode, shouldSkipSourceMapForChildren, getSourceMapRange); - } + return pos < 0 ? pos : pos + tokenString.length; } function increaseIndentIf(value, valueToWriteWhenNotIndenting) { if (value) { @@ -56539,17 +57662,12 @@ var ts; } return ts.getLiteralText(node, currentSourceFile, languageVersion); } - function tryGetConstEnumValue(node) { - if (compilerOptions.isolatedModules) { - return undefined; - } - return ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node) - ? resolver.getConstantValue(node) - : undefined; - } function isSingleLineEmptyBlock(block) { return !block.multiLine - && block.statements.length === 0 + && isEmptyBlock(block); + } + function isEmptyBlock(block) { + return block.statements.length === 0 && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function isUniqueName(name) { @@ -56878,695 +57996,6 @@ var ts; return ts.getNormalizedPathFromPathComponents(commonPathComponents); } ts.computeCommonSourceDirectoryOfFilenames = computeCommonSourceDirectoryOfFilenames; - function trace(host, message) { - host.trace(ts.formatMessage.apply(undefined, arguments)); - } - function isTraceEnabled(compilerOptions, host) { - return compilerOptions.traceResolution && host.trace !== undefined; - } - /* @internal */ - function hasZeroOrOneAsteriskCharacter(str) { - var seenAsterisk = false; - for (var i = 0; i < str.length; i++) { - if (str.charCodeAt(i) === 42 /* asterisk */) { - if (!seenAsterisk) { - seenAsterisk = true; - } - else { - // have already seen asterisk - return false; - } - } - } - return true; - } - ts.hasZeroOrOneAsteriskCharacter = hasZeroOrOneAsteriskCharacter; - function createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations) { - return { resolvedModule: resolvedFileName ? { resolvedFileName: resolvedFileName, isExternalLibraryImport: isExternalLibraryImport } : undefined, failedLookupLocations: failedLookupLocations }; - } - function moduleHasNonRelativeName(moduleName) { - return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); - } - function tryReadTypesSection(packageJsonPath, baseDirectory, state) { - var jsonContent = readJson(packageJsonPath, state.host); - function tryReadFromField(fieldName) { - if (ts.hasProperty(jsonContent, fieldName)) { - var typesFile = jsonContent[fieldName]; - if (typeof typesFile === "string") { - var typesFilePath_1 = ts.normalizePath(ts.combinePaths(baseDirectory, typesFile)); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath_1); - } - return typesFilePath_1; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof typesFile); - } - } - } - } - var typesFilePath = tryReadFromField("typings") || tryReadFromField("types"); - if (typesFilePath) { - return typesFilePath; - } - // Use the main module for inferring types if no types package specified and the allowJs is set - if (state.compilerOptions.allowJs && jsonContent.main && typeof jsonContent.main === "string") { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0, jsonContent.main); - } - var mainFilePath = ts.normalizePath(ts.combinePaths(baseDirectory, jsonContent.main)); - return mainFilePath; - } - return undefined; - } - function readJson(path, host) { - try { - var jsonText = host.readFile(path); - return jsonText ? JSON.parse(jsonText) : {}; - } - catch (e) { - // gracefully handle if readFile fails or returns not JSON - return {}; - } - } - var typeReferenceExtensions = [".d.ts"]; - function getEffectiveTypeRoots(options, host) { - if (options.typeRoots) { - return options.typeRoots; - } - var currentDirectory; - if (options.configFilePath) { - currentDirectory = ts.getDirectoryPath(options.configFilePath); - } - else if (host.getCurrentDirectory) { - currentDirectory = host.getCurrentDirectory(); - } - return currentDirectory && getDefaultTypeRoots(currentDirectory, host); - } - ts.getEffectiveTypeRoots = getEffectiveTypeRoots; - /** - * Returns the path to every node_modules/@types directory from some ancestor directory. - * Returns undefined if there are none. - */ - function getDefaultTypeRoots(currentDirectory, host) { - if (!host.directoryExists) { - return [ts.combinePaths(currentDirectory, nodeModulesAtTypes)]; - } - var typeRoots; - while (true) { - var atTypes = ts.combinePaths(currentDirectory, nodeModulesAtTypes); - if (host.directoryExists(atTypes)) { - (typeRoots || (typeRoots = [])).push(atTypes); - } - var parent_15 = ts.getDirectoryPath(currentDirectory); - if (parent_15 === currentDirectory) { - break; - } - currentDirectory = parent_15; - } - return typeRoots; - } - var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types"); - /** - * @param {string | undefined} containingFile - file that contains type reference directive, can be undefined if containing file is unknown. - * This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups - * is assumed to be the same as root directory of the project. - */ - function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host) { - var traceEnabled = isTraceEnabled(options, host); - var moduleResolutionState = { - compilerOptions: options, - host: host, - skipTsx: true, - traceEnabled: traceEnabled - }; - var typeRoots = getEffectiveTypeRoots(options, host); - if (traceEnabled) { - if (containingFile === undefined) { - if (typeRoots === undefined) { - trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set, typeReferenceDirectiveName); - } - else { - trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1, typeReferenceDirectiveName, typeRoots); - } - } - else { - if (typeRoots === undefined) { - trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set, typeReferenceDirectiveName, containingFile); - } - else { - trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, typeRoots); - } - } - } - var failedLookupLocations = []; - // Check primary library paths - if (typeRoots && typeRoots.length) { - if (traceEnabled) { - trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", ")); - } - var primarySearchPaths = typeRoots; - for (var _i = 0, primarySearchPaths_1 = primarySearchPaths; _i < primarySearchPaths_1.length; _i++) { - var typeRoot = primarySearchPaths_1[_i]; - var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); - var candidateDirectory = ts.getDirectoryPath(candidate); - var resolvedFile_1 = loadNodeModuleFromDirectory(typeReferenceExtensions, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState); - if (resolvedFile_1) { - if (traceEnabled) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile_1, true); - } - return { - resolvedTypeReferenceDirective: { primary: true, resolvedFileName: resolvedFile_1 }, - failedLookupLocations: failedLookupLocations - }; - } - } - } - else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths); - } - } - var resolvedFile; - var initialLocationForSecondaryLookup; - if (containingFile) { - initialLocationForSecondaryLookup = ts.getDirectoryPath(containingFile); - } - if (initialLocationForSecondaryLookup !== undefined) { - // check secondary locations - if (traceEnabled) { - trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); - } - resolvedFile = loadModuleFromNodeModules(typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState); - if (traceEnabled) { - if (resolvedFile) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile, false); - } - else { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); - } - } - } - else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder); - } - } - return { - resolvedTypeReferenceDirective: resolvedFile - ? { primary: false, resolvedFileName: resolvedFile } - : undefined, - failedLookupLocations: failedLookupLocations - }; - } - ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective; - function resolveModuleName(moduleName, containingFile, compilerOptions, host) { - var traceEnabled = isTraceEnabled(compilerOptions, host); - if (traceEnabled) { - trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); - } - var moduleResolution = compilerOptions.moduleResolution; - if (moduleResolution === undefined) { - moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; - if (traceEnabled) { - trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); - } - } - else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); - } - } - var result; - switch (moduleResolution) { - case ts.ModuleResolutionKind.NodeJs: - result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host); - break; - case ts.ModuleResolutionKind.Classic: - result = classicNameResolver(moduleName, containingFile, compilerOptions, host); - break; - } - if (traceEnabled) { - if (result.resolvedModule) { - trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.resolvedModule.resolvedFileName); - } - else { - trace(host, ts.Diagnostics.Module_name_0_was_not_resolved, moduleName); - } - } - return result; - } - ts.resolveModuleName = resolveModuleName; - /** - * Any module resolution kind can be augmented with optional settings: 'baseUrl', 'paths' and 'rootDirs' - they are used to - * mitigate differences between design time structure of the project and its runtime counterpart so the same import name - * can be resolved successfully by TypeScript compiler and runtime module loader. - * If these settings are set then loading procedure will try to use them to resolve module name and it can of failure it will - * fallback to standard resolution routine. - * - * - baseUrl - this setting controls how non-relative module names are resolved. If this setting is specified then non-relative - * names will be resolved relative to baseUrl: i.e. if baseUrl is '/a/b' then candidate location to resolve module name 'c/d' will - * be '/a/b/c/d' - * - paths - this setting can only be used when baseUrl is specified. allows to tune how non-relative module names - * will be resolved based on the content of the module name. - * Structure of 'paths' compiler options - * 'paths': { - * pattern-1: [...substitutions], - * pattern-2: [...substitutions], - * ... - * pattern-n: [...substitutions] - * } - * Pattern here is a string that can contain zero or one '*' character. During module resolution module name will be matched against - * all patterns in the list. Matching for patterns that don't contain '*' means that module name must be equal to pattern respecting the case. - * If pattern contains '*' then to match pattern "*" module name must start with the and end with . - * denotes part of the module name between and . - * If module name can be matches with multiple patterns then pattern with the longest prefix will be picked. - * After selecting pattern we'll use list of substitutions to get candidate locations of the module and the try to load module - * from the candidate location. - * Substitution is a string that can contain zero or one '*'. To get candidate location from substitution we'll pick every - * substitution in the list and replace '*' with string. If candidate location is not rooted it - * will be converted to absolute using baseUrl. - * For example: - * baseUrl: /a/b/c - * "paths": { - * // match all module names - * "*": [ - * "*", // use matched name as is, - * // will be looked as /a/b/c/ - * - * "folder1/*" // substitution will convert matched name to 'folder1/', - * // since it is not rooted then final candidate location will be /a/b/c/folder1/ - * ], - * // match module names that start with 'components/' - * "components/*": [ "/root/components/*" ] // substitution will convert /components/folder1/ to '/root/components/folder1/', - * // it is rooted so it will be final candidate location - * } - * - * 'rootDirs' allows the project to be spreaded across multiple locations and resolve modules with relative names as if - * they were in the same location. For example lets say there are two files - * '/local/src/content/file1.ts' - * '/shared/components/contracts/src/content/protocols/file2.ts' - * After bundling content of '/shared/components/contracts/src' will be merged with '/local/src' so - * if file1 has the following import 'import {x} from "./protocols/file2"' it will be resolved successfully in runtime. - * 'rootDirs' provides the way to tell compiler that in order to get the whole project it should behave as if content of all - * root dirs were merged together. - * I.e. for the example above 'rootDirs' will have two entries: [ '/local/src', '/shared/components/contracts/src' ]. - * Compiler will first convert './protocols/file2' into absolute path relative to the location of containing file: - * '/local/src/content/protocols/file2' and try to load it - failure. - * Then it will search 'rootDirs' looking for a longest matching prefix of this absolute path and if such prefix is found - absolute path will - * be converted to a path relative to found rootDir entry './content/protocols/file2' (*). As a last step compiler will check all remaining - * entries in 'rootDirs', use them to build absolute path out of (*) and try to resolve module from this location. - */ - function tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { - if (moduleHasNonRelativeName(moduleName)) { - return tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state); - } - else { - return tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state); - } - } - function tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { - if (!state.compilerOptions.rootDirs) { - return undefined; - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0, moduleName); - } - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var matchedRootDir; - var matchedNormalizedPrefix; - for (var _i = 0, _a = state.compilerOptions.rootDirs; _i < _a.length; _i++) { - var rootDir = _a[_i]; - // rootDirs are expected to be absolute - // in case of tsconfig.json this will happen automatically - compiler will expand relative names - // using location of tsconfig.json as base location - var normalizedRoot = ts.normalizePath(rootDir); - if (!ts.endsWith(normalizedRoot, ts.directorySeparator)) { - normalizedRoot += ts.directorySeparator; - } - var isLongestMatchingPrefix = ts.startsWith(candidate, normalizedRoot) && - (matchedNormalizedPrefix === undefined || matchedNormalizedPrefix.length < normalizedRoot.length); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Checking_if_0_is_the_longest_matching_prefix_for_1_2, normalizedRoot, candidate, isLongestMatchingPrefix); - } - if (isLongestMatchingPrefix) { - matchedNormalizedPrefix = normalizedRoot; - matchedRootDir = rootDir; - } - } - if (matchedNormalizedPrefix) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Longest_matching_prefix_for_0_is_1, candidate, matchedNormalizedPrefix); - } - var suffix = candidate.substr(matchedNormalizedPrefix.length); - // first - try to load from a initial location - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, matchedNormalizedPrefix, candidate); - } - var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(containingDirectory, state.host), state); - if (resolvedFileName) { - return resolvedFileName; - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Trying_other_entries_in_rootDirs); - } - // then try to resolve using remaining entries in rootDirs - for (var _b = 0, _c = state.compilerOptions.rootDirs; _b < _c.length; _b++) { - var rootDir = _c[_b]; - if (rootDir === matchedRootDir) { - // skip the initially matched entry - continue; - } - var candidate_1 = ts.combinePaths(ts.normalizePath(rootDir), suffix); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, rootDir, candidate_1); - } - var baseDirectory = ts.getDirectoryPath(candidate_1); - var resolvedFileName_1 = loader(candidate_1, supportedExtensions, failedLookupLocations, !directoryProbablyExists(baseDirectory, state.host), state); - if (resolvedFileName_1) { - return resolvedFileName_1; - } - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Module_resolution_using_rootDirs_has_failed); - } - } - return undefined; - } - function tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state) { - if (!state.compilerOptions.baseUrl) { - return undefined; - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, state.compilerOptions.baseUrl, moduleName); - } - // string is for exact match - var matchedPattern = undefined; - if (state.compilerOptions.paths) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); - } - matchedPattern = matchPatternOrExact(ts.getOwnKeys(state.compilerOptions.paths), moduleName); - } - if (matchedPattern) { - var matchedStar = typeof matchedPattern === "string" ? undefined : matchedText(matchedPattern, moduleName); - var matchedPatternText = typeof matchedPattern === "string" ? matchedPattern : patternText(matchedPattern); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPatternText); - } - for (var _i = 0, _a = state.compilerOptions.paths[matchedPatternText]; _i < _a.length; _i++) { - var subst = _a[_i]; - var path = matchedStar ? subst.replace("*", matchedStar) : subst; - var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, path)); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path); - } - var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); - if (resolvedFileName) { - return resolvedFileName; - } - } - return undefined; - } - else { - var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, moduleName)); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Resolving_module_name_0_relative_to_base_url_1_2, moduleName, state.compilerOptions.baseUrl, candidate); - } - return loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); - } - } - /** - * patternStrings contains both pattern strings (containing "*") and regular strings. - * Return an exact match if possible, or a pattern match, or undefined. - * (These are verified by verifyCompilerOptions to have 0 or 1 "*" characters.) - */ - function matchPatternOrExact(patternStrings, candidate) { - var patterns = []; - for (var _i = 0, patternStrings_1 = patternStrings; _i < patternStrings_1.length; _i++) { - var patternString = patternStrings_1[_i]; - var pattern = tryParsePattern(patternString); - if (pattern) { - patterns.push(pattern); - } - else if (patternString === candidate) { - // pattern was matched as is - no need to search further - return patternString; - } - } - return findBestPatternMatch(patterns, function (_) { return _; }, candidate); - } - function patternText(_a) { - var prefix = _a.prefix, suffix = _a.suffix; - return prefix + "*" + suffix; - } - /** - * Given that candidate matches pattern, returns the text matching the '*'. - * E.g.: matchedText(tryParsePattern("foo*baz"), "foobarbaz") === "bar" - */ - function matchedText(pattern, candidate) { - ts.Debug.assert(isPatternMatch(pattern, candidate)); - return candidate.substr(pattern.prefix.length, candidate.length - pattern.suffix.length); - } - /** Return the object corresponding to the best pattern to match `candidate`. */ - /* @internal */ - function findBestPatternMatch(values, getPattern, candidate) { - var matchedValue = undefined; - // use length of prefix as betterness criteria - var longestMatchPrefixLength = -1; - for (var _i = 0, values_1 = values; _i < values_1.length; _i++) { - var v = values_1[_i]; - var pattern = getPattern(v); - if (isPatternMatch(pattern, candidate) && pattern.prefix.length > longestMatchPrefixLength) { - longestMatchPrefixLength = pattern.prefix.length; - matchedValue = v; - } - } - return matchedValue; - } - ts.findBestPatternMatch = findBestPatternMatch; - function isPatternMatch(_a, candidate) { - var prefix = _a.prefix, suffix = _a.suffix; - return candidate.length >= prefix.length + suffix.length && - ts.startsWith(candidate, prefix) && - ts.endsWith(candidate, suffix); - } - /* @internal */ - function tryParsePattern(pattern) { - // This should be verified outside of here and a proper error thrown. - ts.Debug.assert(hasZeroOrOneAsteriskCharacter(pattern)); - var indexOfStar = pattern.indexOf("*"); - return indexOfStar === -1 ? undefined : { - prefix: pattern.substr(0, indexOfStar), - suffix: pattern.substr(indexOfStar + 1) - }; - } - ts.tryParsePattern = tryParsePattern; - function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host) { - var containingDirectory = ts.getDirectoryPath(containingFile); - var supportedExtensions = ts.getSupportedExtensions(compilerOptions); - var traceEnabled = isTraceEnabled(compilerOptions, host); - var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: false }; - var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, supportedExtensions, state); - var isExternalLibraryImport = false; - if (!resolvedFileName) { - if (moduleHasNonRelativeName(moduleName)) { - if (traceEnabled) { - trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder, moduleName); - } - resolvedFileName = loadModuleFromNodeModules(moduleName, containingDirectory, failedLookupLocations, state); - isExternalLibraryImport = resolvedFileName !== undefined; - } - else { - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - resolvedFileName = nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, /*onlyRecordFailures*/ false, state); - } - } - if (resolvedFileName && host.realpath) { - var originalFileName = resolvedFileName; - resolvedFileName = ts.normalizePath(host.realpath(resolvedFileName)); - if (traceEnabled) { - trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, originalFileName, resolvedFileName); - } - } - return createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations); - } - ts.nodeModuleNameResolver = nodeModuleNameResolver; - function nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate); - } - var resolvedFileName = !ts.pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state); - return resolvedFileName || loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, onlyRecordFailures, state); - } - /* @internal */ - function directoryProbablyExists(directoryName, host) { - // if host does not support 'directoryExists' assume that directory will exist - return !host.directoryExists || host.directoryExists(directoryName); - } - ts.directoryProbablyExists = directoryProbablyExists; - /** - * @param {boolean} onlyRecordFailures - if true then function won't try to actually load files but instead record all attempts as failures. This flag is necessary - * in cases when we know upfront that all load attempts will fail (because containing folder does not exists) however we still need to record all failed lookup locations. - */ - function loadModuleFromFile(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) { - // First, try adding an extension. An import of "foo" could be matched by a file "foo.ts", or "foo.js" by "foo.js.ts" - var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state); - if (resolvedByAddingExtension) { - return resolvedByAddingExtension; - } - // If that didn't work, try stripping a ".js" or ".jsx" extension and replacing it with a TypeScript one; - // e.g. "./foo.js" can be matched by "./foo.ts" or "./foo.d.ts" - if (ts.hasJavaScriptFileExtension(candidate)) { - var extensionless = ts.removeFileExtension(candidate); - if (state.traceEnabled) { - var extension = candidate.substring(extensionless.length); - trace(state.host, ts.Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension); - } - return tryAddingExtensions(extensionless, extensions, failedLookupLocation, onlyRecordFailures, state); - } - } - /** Try to return an existing file that adds one of the `extensions` to `candidate`. */ - function tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) { - if (!onlyRecordFailures) { - // check if containing folder exists - if it doesn't then just record failures for all supported extensions without disk probing - var directory = ts.getDirectoryPath(candidate); - if (directory) { - onlyRecordFailures = !directoryProbablyExists(directory, state.host); - } - } - return ts.forEach(extensions, function (ext) { - return !(state.skipTsx && ts.isJsxOrTsxExtension(ext)) && tryFile(candidate + ext, failedLookupLocation, onlyRecordFailures, state); - }); - } - /** Return the file if it exists. */ - function tryFile(fileName, failedLookupLocation, onlyRecordFailures, state) { - if (!onlyRecordFailures && state.host.fileExists(fileName)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); - } - return fileName; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); - } - failedLookupLocation.push(fileName); - return undefined; - } - } - function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocation, onlyRecordFailures, state) { - var packageJsonPath = pathToPackageJson(candidate); - var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); - if (directoryExists && state.host.fileExists(packageJsonPath)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); - } - var typesFile = tryReadTypesSection(packageJsonPath, candidate, state); - if (typesFile) { - var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(typesFile), state.host); - // A package.json "typings" may specify an exact filename, or may choose to omit an extension. - var result = tryFile(typesFile, failedLookupLocation, onlyRecordFailures_1, state) || - tryAddingExtensions(typesFile, extensions, failedLookupLocation, onlyRecordFailures_1, state); - if (result) { - return result; - } - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_does_not_have_types_field); - } - } - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); - } - // 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 loadModuleFromFile(ts.combinePaths(candidate, "index"), extensions, failedLookupLocation, !directoryExists, state); - } - function pathToPackageJson(directory) { - return ts.combinePaths(directory, "package.json"); - } - function loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state) { - var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); - var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); - var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); - var supportedExtensions = ts.getSupportedExtensions(state.compilerOptions); - var result = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, !nodeModulesFolderExists, state); - if (result) { - return result; - } - result = loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); - if (result) { - return result; - } - } - function loadModuleFromNodeModules(moduleName, directory, failedLookupLocations, state) { - directory = ts.normalizeSlashes(directory); - while (true) { - var baseName = ts.getBaseFileName(directory); - if (baseName !== "node_modules") { - // Try to load source from the package - var packageResult = loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state); - if (packageResult && ts.hasTypeScriptFileExtension(packageResult)) { - // Always prefer a TypeScript (.ts, .tsx, .d.ts) file shipped with the package - return packageResult; - } - else { - // Else prefer a types package over non-TypeScript results (e.g. JavaScript files) - var typesResult = loadModuleFromNodeModulesFolder(ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); - if (typesResult || packageResult) { - return typesResult || packageResult; - } - } - } - var parentPath = ts.getDirectoryPath(directory); - if (parentPath === directory) { - break; - } - directory = parentPath; - } - return undefined; - } - function classicNameResolver(moduleName, containingFile, compilerOptions, host) { - var traceEnabled = isTraceEnabled(compilerOptions, host); - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: !compilerOptions.jsx }; - var failedLookupLocations = []; - var supportedExtensions = ts.getSupportedExtensions(compilerOptions); - var containingDirectory = ts.getDirectoryPath(containingFile); - var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, supportedExtensions, state); - if (resolvedFileName) { - return createResolvedModule(resolvedFileName, /*isExternalLibraryImport*/ false, failedLookupLocations); - } - var referencedSourceFile; - if (moduleHasNonRelativeName(moduleName)) { - while (true) { - var searchName = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - referencedSourceFile = loadModuleFromFile(searchName, supportedExtensions, failedLookupLocations, /*onlyRecordFailures*/ false, state); - if (referencedSourceFile) { - break; - } - var parentPath = ts.getDirectoryPath(containingDirectory); - if (parentPath === containingDirectory) { - break; - } - containingDirectory = parentPath; - } - } - else { - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - referencedSourceFile = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, /*onlyRecordFailures*/ false, state); - } - return referencedSourceFile - ? { resolvedModule: { resolvedFileName: referencedSourceFile }, failedLookupLocations: failedLookupLocations } - : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; - } - ts.classicNameResolver = classicNameResolver; function createCompilerHost(options, setParentNodes) { var existingDirectories = ts.createMap(); function getCanonicalFileName(fileName) { @@ -57672,7 +58101,7 @@ var ts; readFile: function (fileName) { return ts.sys.readFile(fileName); }, trace: function (s) { return ts.sys.write(s + newLine); }, directoryExists: function (directoryName) { return ts.sys.directoryExists(directoryName); }, - getEnvironmentVariable: function (name) { return ts.getEnvironmentVariable(name, /*host*/ undefined); }, + getEnvironmentVariable: function (name) { return ts.sys.getEnvironmentVariable ? ts.sys.getEnvironmentVariable(name) : ""; }, getDirectories: function (path) { return ts.sys.getDirectories(path); }, realpath: realpath }; @@ -57740,45 +58169,6 @@ var ts; } return resolutions; } - /** - * Given a set of options, returns the set of type directive names - * that should be included for this program automatically. - * This list could either come from the config file, - * or from enumerating the types root + initial secondary types lookup location. - * More type directives might appear in the program later as a result of loading actual source files; - * this list is only the set of defaults that are implicitly included. - */ - function getAutomaticTypeDirectiveNames(options, host) { - // Use explicit type list from tsconfig.json - if (options.types) { - return options.types; - } - // Walk the primary type lookup locations - var result = []; - if (host.directoryExists && host.getDirectories) { - var typeRoots = getEffectiveTypeRoots(options, host); - if (typeRoots) { - for (var _i = 0, typeRoots_1 = typeRoots; _i < typeRoots_1.length; _i++) { - var root = typeRoots_1[_i]; - if (host.directoryExists(root)) { - for (var _a = 0, _b = host.getDirectories(root); _a < _b.length; _a++) { - var typeDirectivePath = _b[_a]; - var normalized = ts.normalizePath(typeDirectivePath); - var packageJsonPath = pathToPackageJson(ts.combinePaths(root, normalized)); - // tslint:disable-next-line:no-null-keyword - var isNotNeededPackage = host.fileExists(packageJsonPath) && readJson(packageJsonPath, host).typings === null; - if (!isNotNeededPackage) { - // Return just the type directive names - result.push(ts.getBaseFileName(normalized)); - } - } - } - } - } - } - return result; - } - ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; function createProgram(rootNames, options, host, oldProgram) { var program; var files = []; @@ -57815,7 +58205,7 @@ var ts; resolveModuleNamesWorker = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }; } else { - var loader_1 = function (moduleName, containingFile) { return resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }; + var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }; resolveModuleNamesWorker = function (moduleNames, containingFile) { return loadWithLocalCache(moduleNames, containingFile, loader_1); }; } var resolveTypeReferenceDirectiveNamesWorker; @@ -57823,7 +58213,7 @@ var ts; resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile) { return host.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile); }; } else { - var loader_2 = function (typesRef, containingFile) { return resolveTypeReferenceDirective(typesRef, containingFile, options, host).resolvedTypeReferenceDirective; }; + var loader_2 = function (typesRef, containingFile) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host).resolvedTypeReferenceDirective; }; resolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile) { return loadWithLocalCache(typeReferenceDirectiveNames, containingFile, loader_2); }; } var filesByName = ts.createFileMap(); @@ -57833,8 +58223,8 @@ var ts; if (!tryReuseStructureFromOldProgram()) { ts.forEach(rootNames, function (name) { return processRootFile(name, /*isDefaultLib*/ false); }); // load type declarations specified via 'types' argument or implicitly from types/ and node_modules/@types folders - var typeReferences = getAutomaticTypeDirectiveNames(options, host); - if (typeReferences) { + var typeReferences = ts.getAutomaticTypeDirectiveNames(options, host); + if (typeReferences.length) { // This containingFilename needs to match with the one used in managed-side var containingFilename = ts.combinePaths(host.getCurrentDirectory(), "__inferred type names__.ts"); var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename); @@ -57884,7 +58274,8 @@ var ts; getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); }, getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); }, getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; }, - getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; } + getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; }, + dropDiagnosticsProducingTypeChecker: dropDiagnosticsProducingTypeChecker }; verifyCompilerOptions(); ts.performance.mark("afterProgram"); @@ -57938,6 +58329,7 @@ var ts; (oldOptions.configFilePath !== options.configFilePath) || (oldOptions.baseUrl !== options.baseUrl) || (oldOptions.maxNodeModuleJsDepth !== options.maxNodeModuleJsDepth) || + !ts.arrayIsEqualTo(oldOptions.lib, options.lib) || !ts.arrayIsEqualTo(oldOptions.typeRoots, oldOptions.typeRoots) || !ts.arrayIsEqualTo(oldOptions.rootDirs, options.rootDirs) || !ts.equalOwnProperties(oldOptions.paths, options.paths)) { @@ -58054,16 +58446,19 @@ var ts; function getDiagnosticsProducingTypeChecker() { return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ true)); } + function dropDiagnosticsProducingTypeChecker() { + diagnosticsProducingTypeChecker = undefined; + } function getTypeChecker() { return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ false)); } - function emit(sourceFile, writeFileCallback, cancellationToken) { - return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken); }); + function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles) { + return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles); }); } function isEmitBlocked(emitFileName) { return hasEmitBlockingDiagnostics.contains(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName)); } - function emitWorker(program, sourceFile, writeFileCallback, cancellationToken) { + function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles) { var declarationDiagnostics = []; if (options.noEmit) { return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true }; @@ -58095,7 +58490,7 @@ var ts; // checked is to not pass the file to getEmitResolver. var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile); ts.performance.mark("beforeEmit"); - var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile); + var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, emitOnlyDtsFiles); ts.performance.mark("afterEmit"); ts.performance.measure("Emit", "beforeEmit", "afterEmit"); return emitResult; @@ -58659,7 +59054,6 @@ var ts; for (var i = 0; i < moduleNames.length; i++) { var resolution = resolutions[i]; ts.setResolvedModule(file, moduleNames[i], resolution); - var resolvedPath = resolution ? ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName) : undefined; // add file to program only if: // - resolution was successful // - noResolve is falsy @@ -58676,7 +59070,7 @@ var ts; modulesWithElidedImports[file.path] = true; } else if (shouldAddFile) { - findSourceFile(resolution.resolvedFileName, resolvedPath, + findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), /*isDefaultLib*/ false, /*isReference*/ false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); } if (isFromNodeModulesSearch) { @@ -58692,8 +59086,8 @@ var ts; } function computeCommonSourceDirectory(sourceFiles) { var fileNames = []; - for (var _i = 0, sourceFiles_5 = sourceFiles; _i < sourceFiles_5.length; _i++) { - var file = sourceFiles_5[_i]; + for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { + var file = sourceFiles_6[_i]; if (!file.isDeclarationFile) { fileNames.push(file.fileName); } @@ -58704,8 +59098,8 @@ var ts; var allFilesBelongToPath = true; if (sourceFiles) { var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); - for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { - var sourceFile = sourceFiles_6[_i]; + for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { + var sourceFile = sourceFiles_7[_i]; if (!ts.isDeclarationFile(sourceFile)) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { @@ -58748,7 +59142,7 @@ var ts; if (!ts.hasProperty(options.paths, key)) { continue; } - if (!hasZeroOrOneAsteriskCharacter(key)) { + if (!ts.hasZeroOrOneAsteriskCharacter(key)) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Pattern_0_can_have_at_most_one_Asterisk_character, key)); } if (ts.isArray(options.paths[key])) { @@ -58759,7 +59153,7 @@ var ts; var subst = _a[_i]; var typeOfSubst = typeof subst; if (typeOfSubst === "string") { - if (!hasZeroOrOneAsteriskCharacter(subst)) { + if (!ts.hasZeroOrOneAsteriskCharacter(subst)) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character, subst, key)); } } @@ -58799,6 +59193,9 @@ var ts; if (options.lib && options.noLib) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "lib", "noLib")); } + if (options.noImplicitUseStrict && options.alwaysStrict) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noImplicitUseStrict", "alwaysStrict")); + } var languageVersion = options.target || 0 /* ES3 */; var outFile = options.outFile || options.out; var firstNonAmbientExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) && !ts.isDeclarationFile(f) ? f : undefined; }); @@ -58891,12 +59288,15 @@ var ts; /// var ts; (function (ts) { + /* @internal */ + ts.compileOnSaveCommandLineOption = { name: "compileOnSave", type: "boolean" }; /* @internal */ ts.optionDeclarations = [ { name: "charset", type: "string" }, + ts.compileOnSaveCommandLineOption, { name: "declaration", shortName: "d", @@ -59327,6 +59727,11 @@ var ts; name: "importHelpers", type: "boolean", description: ts.Diagnostics.Import_emit_helpers_from_tslib + }, + { + name: "alwaysStrict", + type: "boolean", + description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file } ]; /* @internal */ @@ -59547,10 +59952,11 @@ var ts; * @param fileName The path to the config file * @param jsonText The text of the config file */ - function parseConfigFileTextToJson(fileName, jsonText) { + function parseConfigFileTextToJson(fileName, jsonText, stripComments) { + if (stripComments === void 0) { stripComments = true; } try { - var jsonTextWithoutComments = removeComments(jsonText); - return { config: /\S/.test(jsonTextWithoutComments) ? JSON.parse(jsonTextWithoutComments) : {} }; + var jsonTextToParse = stripComments ? removeComments(jsonText) : jsonText; + return { config: /\S/.test(jsonTextToParse) ? JSON.parse(jsonTextToParse) : {} }; } catch (e) { return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) }; @@ -59712,13 +60118,15 @@ var ts; options = ts.extend(existingOptions, options); options.configFilePath = configFileName; var _c = getFileNames(errors), fileNames = _c.fileNames, wildcardDirectories = _c.wildcardDirectories; + var compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors); return { options: options, fileNames: fileNames, typingOptions: typingOptions, raw: json, errors: errors, - wildcardDirectories: wildcardDirectories + wildcardDirectories: wildcardDirectories, + compileOnSave: compileOnSave }; function tryExtendsName(extendedConfig) { // If the path isn't a rooted or relative path, don't try to resolve it (we reserve the right to special case module-id like paths in the future) @@ -59799,6 +60207,17 @@ var ts; var _b; } ts.parseJsonConfigFileContent = parseJsonConfigFileContent; + function convertCompileOnSaveOptionFromJson(jsonOption, basePath, errors) { + if (!ts.hasProperty(jsonOption, ts.compileOnSaveCommandLineOption.name)) { + return false; + } + var result = convertJsonOption(ts.compileOnSaveCommandLineOption, jsonOption["compileOnSave"], basePath, errors); + if (typeof result === "boolean" && result) { + return result; + } + return false; + } + ts.convertCompileOnSaveOptionFromJson = convertCompileOnSaveOptionFromJson; function convertCompilerOptionsFromJson(jsonOptions, basePath, configFileName) { var errors = []; var options = convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName); @@ -59812,7 +60231,9 @@ var ts; } ts.convertTypingOptionsFromJson = convertTypingOptionsFromJson; function convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { - var options = ts.getBaseFileName(configFileName) === "jsconfig.json" ? { allowJs: true, maxNodeModuleJsDepth: 2 } : {}; + var options = ts.getBaseFileName(configFileName) === "jsconfig.json" + ? { allowJs: true, maxNodeModuleJsDepth: 2, allowSyntheticDefaultImports: true, skipLibCheck: true } + : {}; convertOptionsFromJson(ts.optionDeclarations, jsonOptions, basePath, options, ts.Diagnostics.Unknown_compiler_option_0, errors); return options; } @@ -60742,7 +61163,7 @@ var ts; return true; case 69 /* Identifier */: // 'this' as a parameter - return node.originalKeywordKind === 97 /* ThisKeyword */ && node.parent.kind === 142 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 142 /* Parameter */; default: return false; } @@ -61420,7 +61841,6 @@ var ts; })(ts || (ts = {})); // Display-part writer helpers /* @internal */ -var ts; (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 142 /* Parameter */; @@ -61657,7 +62077,7 @@ var ts; return ts.ensureScriptKind(fileName, scriptKind); } ts.getScriptKind = getScriptKind; - function parseAndReEmitConfigJSONFile(content) { + function sanitizeConfigFile(configFileName, content) { var options = { fileName: "config.js", compilerOptions: { @@ -61671,14 +62091,17 @@ var ts; // also, the emitted result will have "(" in the beginning and ");" in the end. We need to strip these // as well var trimmedOutput = outputText.trim(); - var configJsonObject = JSON.parse(trimmedOutput.substring(1, trimmedOutput.length - 2)); for (var _i = 0, diagnostics_2 = diagnostics; _i < diagnostics_2.length; _i++) { var diagnostic = diagnostics_2[_i]; diagnostic.start = diagnostic.start - 1; } - return { configJsonObject: configJsonObject, diagnostics: diagnostics }; + var _b = ts.parseConfigFileTextToJson(configFileName, trimmedOutput.substring(1, trimmedOutput.length - 2), /*stripComments*/ false), config = _b.config, error = _b.error; + return { + configJsonObject: config || {}, + diagnostics: error ? ts.concatenate(diagnostics, [error]) : diagnostics + }; } - ts.parseAndReEmitConfigJSONFile = parseAndReEmitConfigJSONFile; + ts.sanitizeConfigFile = sanitizeConfigFile; })(ts || (ts = {})); var ts; (function (ts) { @@ -62538,8 +62961,7 @@ var ts; return; case 142 /* Parameter */: if (token.parent.name === token) { - var isThis_1 = token.kind === 69 /* Identifier */ && token.originalKeywordKind === 97 /* ThisKeyword */; - return isThis_1 ? 3 /* keyword */ : 17 /* parameterName */; + return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; } return; } @@ -62583,14 +63005,14 @@ var ts; if (!completionData) { return undefined; } - var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isJsDocTagName = completionData.isJsDocTagName; + var symbols = completionData.symbols, isGlobalCompletion = completionData.isGlobalCompletion, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isJsDocTagName = completionData.isJsDocTagName; 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: ts.JsDoc.getAllJsDocCompletionEntries() }; + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: ts.JsDoc.getAllJsDocCompletionEntries() }; } var entries = []; if (ts.isSourceFileJavaScript(sourceFile)) { - var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ false); + var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true); ts.addRange(entries, getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames)); } else { @@ -62619,7 +63041,7 @@ var ts; if (!isMemberCompletion && !isJsDocTagName) { ts.addRange(entries, keywordCompletions); } - return { isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation || ts.isSourceFileJavaScript(sourceFile), entries: entries }; + return { isGlobalCompletion: isGlobalCompletion, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames) { var entries = []; var nameTable = ts.getNameTable(sourceFile); @@ -62690,7 +63112,9 @@ var ts; if (!node || node.kind !== 9 /* StringLiteral */) { return undefined; } - if (node.parent.kind === 253 /* PropertyAssignment */ && node.parent.parent.kind === 171 /* ObjectLiteralExpression */) { + if (node.parent.kind === 253 /* PropertyAssignment */ && + node.parent.parent.kind === 171 /* ObjectLiteralExpression */ && + node.parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { // 'jspm:dev': string @@ -62740,7 +63164,7 @@ var ts; if (type) { getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, element, /*performCharacterChecks*/ false); if (entries.length) { - return { isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; + return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; } } } @@ -62756,7 +63180,7 @@ var ts; } } if (entries.length) { - return { isMemberCompletion: false, isNewIdentifierLocation: true, entries: entries }; + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: true, entries: entries }; } return undefined; } @@ -62766,7 +63190,7 @@ var ts; if (type) { getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, node, /*performCharacterChecks*/ false); if (entries.length) { - return { isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; + return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; } } return undefined; @@ -62777,7 +63201,7 @@ var ts; var entries_2 = []; addStringLiteralCompletionsFromType(type, entries_2); if (entries_2.length) { - return { isMemberCompletion: false, isNewIdentifierLocation: false, entries: entries_2 }; + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: entries_2 }; } } return undefined; @@ -62819,6 +63243,7 @@ var ts; entries = getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, span); } return { + isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: true, entries: entries @@ -62854,15 +63279,24 @@ var ts; } return result; } + /** + * Given a path ending at a directory, gets the completions for the path, and filters for those entries containing the basename. + */ function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, extensions, includeExtensions, span, exclude, result) { if (result === void 0) { result = []; } + if (fragment === undefined) { + fragment = ""; + } + fragment = ts.normalizeSlashes(fragment); + /** + * Remove the basename from the path. Note that we don't use the basename to filter completions; + * the client is responsible for refining completions. + */ fragment = ts.getDirectoryPath(fragment); - if (!fragment) { - fragment = "./"; - } - else { - fragment = ts.ensureTrailingDirectorySeparator(fragment); + if (fragment === "") { + fragment = "." + ts.directorySeparator; } + fragment = ts.ensureTrailingDirectorySeparator(fragment); var absolutePath = normalizeAndPreserveTrailingSlash(ts.isRootedDiskPath(fragment) ? fragment : ts.combinePaths(scriptPath, fragment)); var baseDirectory = ts.getDirectoryPath(absolutePath); var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); @@ -62870,6 +63304,12 @@ var ts; // Enumerate the available files if possible var files = tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]); if (files) { + /** + * Multiple file entries might map to the same truncated name once we remove extensions + * (happens iff includeExtensions === false)so we use a set-like data structure. Eg: + * + * both foo.ts and foo.tsx become foo + */ var foundFiles = ts.createMap(); for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { var filePath = files_3[_i]; @@ -63039,6 +63479,19 @@ var ts; if (!range) { return undefined; } + var completionInfo = { + /** + * We don't want the editor to offer any other completions, such as snippets, inside a comment. + */ + isGlobalCompletion: false, + isMemberCompletion: false, + /** + * The user may type in a path that doesn't yet exist, creating a "new identifier" + * with respect to the collection of identifiers the server is aware of. + */ + isNewIdentifierLocation: true, + entries: [] + }; var text = sourceFile.text.substr(range.pos, position - range.pos); var match = tripleSlashDirectiveFragmentRegex.exec(text); if (match) { @@ -63046,24 +63499,18 @@ var ts; var kind = match[2]; var toComplete = match[3]; var scriptPath = ts.getDirectoryPath(sourceFile.path); - var entries_3; if (kind === "path") { // Give completions for a relative path var span_10 = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length); - entries_3 = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, ts.getSupportedExtensions(compilerOptions), /*includeExtensions*/ true, span_10, sourceFile.path); + completionInfo.entries = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, ts.getSupportedExtensions(compilerOptions), /*includeExtensions*/ true, span_10, sourceFile.path); } else { // Give completions based on the typings available var span_11 = { start: range.pos + prefix.length, length: match[0].length - prefix.length }; - entries_3 = getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span_11); + completionInfo.entries = getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span_11); } - return { - isMemberCompletion: false, - isNewIdentifierLocation: true, - entries: entries_3 - }; } - return undefined; + return completionInfo; } function getCompletionEntriesFromTypings(host, options, scriptPath, span, result) { if (result === void 0) { result = []; } @@ -63285,7 +63732,7 @@ var ts; } } if (isJsDocTagName) { - return { symbols: undefined, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, isJsDocTagName: isJsDocTagName }; + return { symbols: undefined, isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, isJsDocTagName: isJsDocTagName }; } if (!insideJsDocTagExpression) { // Proceed if the current position is in jsDoc tag expression; otherwise it is a normal @@ -63349,6 +63796,7 @@ var ts; } } var semanticStart = ts.timestamp(); + var isGlobalCompletion = false; var isMemberCompletion; var isNewIdentifierLocation; var symbols = []; @@ -63382,11 +63830,13 @@ var ts; if (!tryGetGlobalSymbols()) { return undefined; } + isGlobalCompletion = true; } log("getCompletionData: Semantic work: " + (ts.timestamp() - semanticStart)); - return { symbols: symbols, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName: isJsDocTagName }; + return { symbols: symbols, isGlobalCompletion: isGlobalCompletion, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName: isJsDocTagName }; function getTypeScriptMemberSymbols() { // Right of dot member completion list + isGlobalCompletion = false; isMemberCompletion = true; isNewIdentifierLocation = false; if (node.kind === 69 /* Identifier */ || node.kind === 139 /* QualifiedName */ || node.kind === 172 /* PropertyAccessExpression */) { @@ -63448,6 +63898,7 @@ var ts; if ((jsxContainer.kind === 242 /* JsxSelfClosingElement */) || (jsxContainer.kind === 243 /* JsxOpeningElement */)) { // Cursor is inside a JSX self-closing element or opening element attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); + isGlobalCompletion = false; if (attrsType) { symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); isMemberCompletion = true; @@ -64026,9 +64477,15 @@ var ts; * Matches a triple slash reference directive with an incomplete string literal for its path. Used * to determine if the caret is currently within the string literal and capture the literal fragment * for completions. - * For example, this matches /// +/// +/// +/// /* @internal */ var ts; (function (ts) { @@ -66442,6 +66901,7 @@ var ts; // A map of loose file names to library names // that we are confident require typings var safeList; + var EmptySafeList = ts.createMap(); /** * @param host is the object providing I/O related operations. * @param fileNames are the file names that belong to the same project @@ -66458,10 +66918,13 @@ var ts; return { cachedTypingPaths: [], newTypingNames: [], filesToWatch: [] }; } // Only infer typings for .js and .jsx files - fileNames = ts.filter(ts.map(fileNames, ts.normalizePath), function (f) { return ts.scriptKindIs(f, /*LanguageServiceHost*/ undefined, 1 /* JS */, 2 /* JSX */); }); + fileNames = ts.filter(ts.map(fileNames, ts.normalizePath), function (f) { + var kind = ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)); + return kind === 1 /* JS */ || kind === 2 /* JSX */; + }); if (!safeList) { var result = ts.readConfigFile(safeListPath, function (path) { return host.readFile(path); }); - safeList = ts.createMap(result.config); + safeList = result.config ? ts.createMap(result.config) : EmptySafeList; } var filesToWatch = []; // Directories to search for package.json, bower.json and other typing information @@ -66552,13 +67015,10 @@ var ts; var jsFileNames = ts.filter(fileNames, ts.hasJavaScriptFileExtension); var inferredTypingNames = ts.map(jsFileNames, function (f) { return ts.removeFileExtension(ts.getBaseFileName(f.toLowerCase())); }); var cleanedTypingNames = ts.map(inferredTypingNames, function (f) { return f.replace(/((?:\.|-)min(?=\.|$))|((?:-|\.)\d+)/g, ""); }); - if (safeList === undefined) { - mergeTypings(cleanedTypingNames); - } - else { + if (safeList !== EmptySafeList) { mergeTypings(ts.filter(cleanedTypingNames, function (f) { return f in safeList; })); } - var hasJsxFile = ts.forEach(fileNames, function (f) { return ts.scriptKindIs(f, /*LanguageServiceHost*/ undefined, 2 /* JSX */); }); + var hasJsxFile = ts.forEach(fileNames, function (f) { return ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)) === 2 /* JSX */; }); if (hasJsxFile) { mergeTypings(["react"]); } @@ -66573,7 +67033,7 @@ var ts; return; } var typingNames = []; - var fileNames = host.readDirectory(nodeModulesPath, ["*.json"], /*excludes*/ undefined, /*includes*/ undefined, /*depth*/ 2); + var fileNames = host.readDirectory(nodeModulesPath, [".json"], /*excludes*/ undefined, /*includes*/ undefined, /*depth*/ 2); for (var _i = 0, fileNames_2 = fileNames; _i < fileNames_2.length; _i++) { var fileName = fileNames_2[_i]; var normalizedFileName = ts.normalizePath(fileName); @@ -66616,7 +67076,7 @@ var ts; (function (ts) { var NavigateTo; (function (NavigateTo) { - function getNavigateToItems(sourceFiles, checker, cancellationToken, searchValue, maxResultCount) { + function getNavigateToItems(sourceFiles, checker, cancellationToken, searchValue, maxResultCount, excludeDtsFiles) { var patternMatcher = ts.createPatternMatcher(searchValue); var rawItems = []; // This means "compare in a case insensitive manner." @@ -66624,6 +67084,9 @@ var ts; // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] ts.forEach(sourceFiles, function (sourceFile) { cancellationToken.throwIfCancellationRequested(); + if (excludeDtsFiles && ts.fileExtensionIs(sourceFile.fileName, ".d.ts")) { + return; + } var nameToDeclarations = sourceFile.getNamedDeclarations(); for (var name_49 in nameToDeclarations) { var declarations = nameToDeclarations[name_49]; @@ -66803,6 +67266,13 @@ var ts; return result; } NavigationBar.getNavigationBarItems = getNavigationBarItems; + function getNavigationTree(sourceFile) { + curSourceFile = sourceFile; + var result = convertToTree(rootNavigationBarNode(sourceFile)); + curSourceFile = undefined; + return result; + } + NavigationBar.getNavigationTree = getNavigationTree; // Keep sourceFile handy so we don't have to search for it every time we need to call `getText`. var curSourceFile; function nodeText(node) { @@ -67077,7 +67547,7 @@ var ts; } } // More efficient to create a collator once and use its `compare` than to call `a.localeCompare(b)` many times. - var collator = typeof Intl === "undefined" ? undefined : new Intl.Collator(); + var collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; // Intl is missing in Safari, and node 0.10 treats "a" as greater than "B". var localeCompareIsCorrect = collator && collator.compare("a", "B") < 0; var localeCompareFix = localeCompareIsCorrect ? collator.compare : function (a, b) { @@ -67242,6 +67712,15 @@ var ts; } // NavigationBarItem requires an array, but will not mutate it, so just give it this for performance. var emptyChildItemArray = []; + function convertToTree(n) { + return { + text: getItemName(n.node), + kind: ts.getNodeKind(n.node), + kindModifiers: ts.getNodeModifiers(n.node), + spans: getSpans(n), + childItems: ts.map(n.children, convertToTree) + }; + } function convertToTopLevelItem(n) { return { text: getItemName(n.node), @@ -67265,16 +67744,16 @@ var ts; grayed: false }; } - function getSpans(n) { - var spans = [getNodeSpan(n.node)]; - if (n.additionalNodes) { - for (var _i = 0, _a = n.additionalNodes; _i < _a.length; _i++) { - var node = _a[_i]; - spans.push(getNodeSpan(node)); - } + } + function getSpans(n) { + var spans = [getNodeSpan(n.node)]; + if (n.additionalNodes) { + for (var _i = 0, _a = n.additionalNodes; _i < _a.length; _i++) { + var node = _a[_i]; + spans.push(getNodeSpan(node)); } - return spans; } + return spans; } function getModuleName(moduleDeclaration) { // We want to maintain quotation marks. @@ -71005,25 +71484,25 @@ var ts; }; RulesProvider.prototype.createActiveRules = function (options) { var rules = this.globalRules.HighPriorityCommonRules.slice(0); - if (options.InsertSpaceAfterCommaDelimiter) { + if (options.insertSpaceAfterCommaDelimiter) { rules.push(this.globalRules.SpaceAfterComma); } else { rules.push(this.globalRules.NoSpaceAfterComma); } - if (options.InsertSpaceAfterFunctionKeywordForAnonymousFunctions) { + if (options.insertSpaceAfterFunctionKeywordForAnonymousFunctions) { rules.push(this.globalRules.SpaceAfterAnonymousFunctionKeyword); } else { rules.push(this.globalRules.NoSpaceAfterAnonymousFunctionKeyword); } - if (options.InsertSpaceAfterKeywordsInControlFlowStatements) { + if (options.insertSpaceAfterKeywordsInControlFlowStatements) { rules.push(this.globalRules.SpaceAfterKeywordInControl); } else { rules.push(this.globalRules.NoSpaceAfterKeywordInControl); } - if (options.InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis) { + if (options.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis) { rules.push(this.globalRules.SpaceAfterOpenParen); rules.push(this.globalRules.SpaceBeforeCloseParen); rules.push(this.globalRules.NoSpaceBetweenParens); @@ -71033,7 +71512,7 @@ var ts; rules.push(this.globalRules.NoSpaceBeforeCloseParen); rules.push(this.globalRules.NoSpaceBetweenParens); } - if (options.InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets) { + if (options.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets) { rules.push(this.globalRules.SpaceAfterOpenBracket); rules.push(this.globalRules.SpaceBeforeCloseBracket); rules.push(this.globalRules.NoSpaceBetweenBrackets); @@ -71045,7 +71524,7 @@ var ts; } // The default value of InsertSpaceAfterOpeningAndBeforeClosingNonemptyBraces is true // so if the option is undefined, we should treat it as true as well - if (options.InsertSpaceAfterOpeningAndBeforeClosingNonemptyBraces !== false) { + if (options.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces !== false) { rules.push(this.globalRules.SpaceAfterOpenBrace); rules.push(this.globalRules.SpaceBeforeCloseBrace); rules.push(this.globalRules.NoSpaceBetweenEmptyBraceBrackets); @@ -71055,7 +71534,7 @@ var ts; rules.push(this.globalRules.NoSpaceBeforeCloseBrace); rules.push(this.globalRules.NoSpaceBetweenEmptyBraceBrackets); } - if (options.InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces) { + if (options.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces) { rules.push(this.globalRules.SpaceAfterTemplateHeadAndMiddle); rules.push(this.globalRules.SpaceBeforeTemplateMiddleAndTail); } @@ -71063,7 +71542,7 @@ var ts; rules.push(this.globalRules.NoSpaceAfterTemplateHeadAndMiddle); rules.push(this.globalRules.NoSpaceBeforeTemplateMiddleAndTail); } - if (options.InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces) { + if (options.insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces) { rules.push(this.globalRules.SpaceAfterOpenBraceInJsxExpression); rules.push(this.globalRules.SpaceBeforeCloseBraceInJsxExpression); } @@ -71071,13 +71550,13 @@ var ts; rules.push(this.globalRules.NoSpaceAfterOpenBraceInJsxExpression); rules.push(this.globalRules.NoSpaceBeforeCloseBraceInJsxExpression); } - if (options.InsertSpaceAfterSemicolonInForStatements) { + if (options.insertSpaceAfterSemicolonInForStatements) { rules.push(this.globalRules.SpaceAfterSemicolonInFor); } else { rules.push(this.globalRules.NoSpaceAfterSemicolonInFor); } - if (options.InsertSpaceBeforeAndAfterBinaryOperators) { + if (options.insertSpaceBeforeAndAfterBinaryOperators) { rules.push(this.globalRules.SpaceBeforeBinaryOperator); rules.push(this.globalRules.SpaceAfterBinaryOperator); } @@ -71085,14 +71564,14 @@ var ts; rules.push(this.globalRules.NoSpaceBeforeBinaryOperator); rules.push(this.globalRules.NoSpaceAfterBinaryOperator); } - if (options.PlaceOpenBraceOnNewLineForControlBlocks) { + if (options.placeOpenBraceOnNewLineForControlBlocks) { rules.push(this.globalRules.NewLineBeforeOpenBraceInControl); } - if (options.PlaceOpenBraceOnNewLineForFunctions) { + if (options.placeOpenBraceOnNewLineForFunctions) { rules.push(this.globalRules.NewLineBeforeOpenBraceInFunction); rules.push(this.globalRules.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock); } - if (options.InsertSpaceAfterTypeAssertion) { + if (options.insertSpaceAfterTypeAssertion) { rules.push(this.globalRules.SpaceAfterTypeAssertion); } else { @@ -71222,7 +71701,7 @@ var ts; return ts.rangeContainsRange(parent.members, node); case 225 /* ModuleDeclaration */: var body = parent.body; - return body && body.kind === 199 /* Block */ && ts.rangeContainsRange(body.statements, node); + return body && body.kind === 226 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); case 256 /* SourceFile */: case 199 /* Block */: case 226 /* ModuleBlock */: @@ -71332,7 +71811,7 @@ var ts; break; } if (formatting.SmartIndenter.shouldIndentChildNode(n, child)) { - return options.IndentSize; + return options.indentSize; } previousLine = line; child = n; @@ -71404,7 +71883,7 @@ var ts; } function computeIndentation(node, startLine, inheritedIndentation, parent, parentDynamicIndentation, effectiveParentStartLine) { var indentation = inheritedIndentation; - var delta = formatting.SmartIndenter.shouldIndentChildNode(node) ? options.IndentSize : 0; + var delta = formatting.SmartIndenter.shouldIndentChildNode(node) ? options.indentSize : 0; if (effectiveParentStartLine === startLine) { // if node is located on the same line with the parent // - inherit indentation from the parent @@ -71412,7 +71891,7 @@ var ts; indentation = startLine === lastIndentedLine ? indentationOnLastIndentedLine : parentDynamicIndentation.getIndentation(); - delta = Math.min(options.IndentSize, parentDynamicIndentation.getDelta(node) + delta); + delta = Math.min(options.indentSize, parentDynamicIndentation.getDelta(node) + delta); } else if (indentation === -1 /* Unknown */) { if (formatting.SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement(parent, node, startLine, sourceFile)) { @@ -71493,13 +71972,13 @@ var ts; recomputeIndentation: function (lineAdded) { if (node.parent && formatting.SmartIndenter.shouldIndentChildNode(node.parent, node)) { if (lineAdded) { - indentation += options.IndentSize; + indentation += options.indentSize; } else { - indentation -= options.IndentSize; + indentation -= options.indentSize; } if (formatting.SmartIndenter.shouldIndentChildNode(node)) { - delta = options.IndentSize; + delta = options.indentSize; } else { delta = 0; @@ -71919,7 +72398,7 @@ var ts; // edit should not be applied only if we have one line feed between elements var lineDelta = currentStartLine - previousStartLine; if (lineDelta !== 1) { - recordReplace(previousRange.end, currentRange.pos - previousRange.end, options.NewLineCharacter); + recordReplace(previousRange.end, currentRange.pos - previousRange.end, options.newLineCharacter); } break; case 2 /* Space */: @@ -71980,14 +72459,14 @@ var ts; var internedSpacesIndentation; function getIndentationString(indentation, options) { // reset interned strings if FormatCodeOptions were changed - var resetInternedStrings = !internedSizes || (internedSizes.tabSize !== options.TabSize || internedSizes.indentSize !== options.IndentSize); + var resetInternedStrings = !internedSizes || (internedSizes.tabSize !== options.tabSize || internedSizes.indentSize !== options.indentSize); if (resetInternedStrings) { - internedSizes = { tabSize: options.TabSize, indentSize: options.IndentSize }; + internedSizes = { tabSize: options.tabSize, indentSize: options.indentSize }; internedTabsIndentation = internedSpacesIndentation = undefined; } - if (!options.ConvertTabsToSpaces) { - var tabs = Math.floor(indentation / options.TabSize); - var spaces = indentation - tabs * options.TabSize; + if (!options.convertTabsToSpaces) { + var tabs = Math.floor(indentation / options.tabSize); + var spaces = indentation - tabs * options.tabSize; var tabString = void 0; if (!internedTabsIndentation) { internedTabsIndentation = []; @@ -72002,13 +72481,13 @@ var ts; } else { var spacesString = void 0; - var quotient = Math.floor(indentation / options.IndentSize); - var remainder = indentation % options.IndentSize; + var quotient = Math.floor(indentation / options.indentSize); + var remainder = indentation % options.indentSize; if (!internedSpacesIndentation) { internedSpacesIndentation = []; } if (internedSpacesIndentation[quotient] === undefined) { - spacesString = repeat(" ", options.IndentSize * quotient); + spacesString = repeat(" ", options.indentSize * quotient); internedSpacesIndentation[quotient] = spacesString; } else { @@ -72045,7 +72524,7 @@ var ts; } // no indentation when the indent style is set to none, // so we can return fast - if (options.IndentStyle === ts.IndentStyle.None) { + if (options.indentStyle === ts.IndentStyle.None) { return 0; } var precedingToken = ts.findPrecedingToken(position, sourceFile); @@ -72061,7 +72540,7 @@ var ts; // 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) { + 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; @@ -72095,7 +72574,7 @@ var ts; indentationDelta = 0; } else { - indentationDelta = lineAtPosition !== currentStart.line ? options.IndentSize : 0; + indentationDelta = lineAtPosition !== currentStart.line ? options.indentSize : 0; } break; } @@ -72106,7 +72585,7 @@ var ts; } actualIndentation = getLineIndentationWhenExpressionIsInMultiLine(current, sourceFile, options); if (actualIndentation !== -1 /* Unknown */) { - return actualIndentation + options.IndentSize; + return actualIndentation + options.indentSize; } previous = current; current = current.parent; @@ -72118,15 +72597,15 @@ var ts; return getIndentationForNodeWorker(current, currentStart, /*ignoreActualIndentationRange*/ undefined, indentationDelta, sourceFile, options); } SmartIndenter.getIndentation = getIndentation; - function getBaseIndentation(options) { - return options.BaseIndentSize || 0; - } - SmartIndenter.getBaseIndentation = getBaseIndentation; function getIndentationForNode(n, ignoreActualIndentationRange, sourceFile, options) { var start = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); return getIndentationForNodeWorker(n, start, ignoreActualIndentationRange, /*indentationDelta*/ 0, sourceFile, options); } SmartIndenter.getIndentationForNode = getIndentationForNode; + function getBaseIndentation(options) { + return options.baseIndentSize || 0; + } + SmartIndenter.getBaseIndentation = getBaseIndentation; function getIndentationForNodeWorker(current, currentStart, ignoreActualIndentationRange, indentationDelta, sourceFile, options) { var parent = current.parent; var parentStart; @@ -72161,7 +72640,7 @@ var ts; } // increase indentation if parent node wants its content to be indented and parent and child nodes don't start on the same line if (shouldIndentChildNode(parent, current) && !parentAndChildShareLine) { - indentationDelta += options.IndentSize; + indentationDelta += options.indentSize; } current = parent; currentStart = parentStart; @@ -72371,7 +72850,7 @@ var ts; break; } if (ch === 9 /* tab */) { - column += options.TabSize + (column % options.TabSize); + column += options.tabSize + (column % options.tabSize); } else { column++; @@ -72473,6 +72952,117 @@ var ts; })(SmartIndenter = formatting.SmartIndenter || (formatting.SmartIndenter = {})); })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var codefix; + (function (codefix) { + var codeFixes = ts.createMap(); + function registerCodeFix(action) { + ts.forEach(action.errorCodes, function (error) { + var fixes = codeFixes[error]; + if (!fixes) { + fixes = []; + codeFixes[error] = fixes; + } + fixes.push(action); + }); + } + codefix.registerCodeFix = registerCodeFix; + function getSupportedErrorCodes() { + return Object.keys(codeFixes); + } + codefix.getSupportedErrorCodes = getSupportedErrorCodes; + function getFixes(context) { + var fixes = codeFixes[context.errorCode]; + var allActions = []; + ts.forEach(fixes, function (f) { + var actions = f.getCodeActions(context); + if (actions && actions.length > 0) { + allActions = allActions.concat(actions); + } + }); + return allActions; + } + codefix.getFixes = getFixes; + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var codefix; + (function (codefix) { + function getOpenBraceEnd(constructor, sourceFile) { + // First token is the open curly, this is where we want to put the 'super' call. + return constructor.body.getFirstToken(sourceFile).getEnd(); + } + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call.code], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var token = ts.getTokenAtPosition(sourceFile, context.span.start); + if (token.kind !== 121 /* ConstructorKeyword */) { + return undefined; + } + var newPosition = getOpenBraceEnd(token.parent, sourceFile); + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_missing_super_call), + changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "super();", span: { start: newPosition, length: 0 } }] }] + }]; + } + }); + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class.code], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var token = ts.getTokenAtPosition(sourceFile, context.span.start); + if (token.kind !== 97 /* ThisKeyword */) { + return undefined; + } + var constructor = ts.getContainingFunction(token); + var superCall = findSuperCall(constructor.body); + if (!superCall) { + return undefined; + } + // figure out if the this access is actuall inside the supercall + // i.e. super(this.a), since in that case we won't suggest a fix + if (superCall.expression && superCall.expression.kind == 174 /* CallExpression */) { + var arguments_1 = superCall.expression.arguments; + for (var i = 0; i < arguments_1.length; i++) { + if (arguments_1[i].expression === token) { + return undefined; + } + } + } + var newPosition = getOpenBraceEnd(constructor, sourceFile); + var changes = [{ + fileName: sourceFile.fileName, textChanges: [{ + newText: superCall.getText(sourceFile), + span: { start: newPosition, length: 0 } + }, + { + newText: "", + span: { start: superCall.getStart(sourceFile), length: superCall.getWidth(sourceFile) } + }] + }]; + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Make_super_call_the_first_statement_in_the_constructor), + changes: changes + }]; + function findSuperCall(n) { + if (n.kind === 202 /* ExpressionStatement */ && ts.isSuperCall(n.expression)) { + return n; + } + if (ts.isFunctionLike(n)) { + return undefined; + } + return ts.forEachChild(n, findSuperCall); + } + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/// /// /// /// @@ -72498,13 +73088,15 @@ var ts; /// /// /// +/// +/// var ts; (function (ts) { /** The version of the language service API */ ts.servicesVersion = "0.5"; function createNode(kind, pos, end, parent) { var node = kind >= 139 /* FirstNode */ ? new NodeObject(kind, pos, end) : - kind === 69 /* Identifier */ ? new IdentifierObject(kind, pos, end) : + kind === 69 /* Identifier */ ? new IdentifierObject(69 /* Identifier */, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; return node; @@ -72732,15 +73324,16 @@ var ts; var TokenObject = (function (_super) { __extends(TokenObject, _super); function TokenObject(kind, pos, end) { - _super.call(this, pos, end); - this.kind = kind; + var _this = _super.call(this, pos, end) || this; + _this.kind = kind; + return _this; } return TokenObject; }(TokenOrIdentifierObject)); var IdentifierObject = (function (_super) { __extends(IdentifierObject, _super); function IdentifierObject(kind, pos, end) { - _super.call(this, pos, end); + return _super.call(this, pos, end) || this; } return IdentifierObject; }(TokenOrIdentifierObject)); @@ -72816,7 +73409,7 @@ var ts; var SourceFileObject = (function (_super) { __extends(SourceFileObject, _super); function SourceFileObject(kind, pos, end) { - _super.call(this, kind, pos, end); + return _super.call(this, kind, pos, end) || this; } SourceFileObject.prototype.update = function (newText, textChangeRange) { return ts.updateSourceFile(this, newText, textChangeRange); @@ -72985,6 +73578,30 @@ var ts; getSignatureConstructor: function () { return SignatureObject; } }; } + function toEditorSettings(optionsAsMap) { + var allPropertiesAreCamelCased = true; + for (var key in optionsAsMap) { + if (ts.hasProperty(optionsAsMap, key) && !isCamelCase(key)) { + allPropertiesAreCamelCased = false; + break; + } + } + if (allPropertiesAreCamelCased) { + return optionsAsMap; + } + var settings = {}; + for (var key in optionsAsMap) { + if (ts.hasProperty(optionsAsMap, key)) { + var newKey = isCamelCase(key) ? key : key.charAt(0).toLowerCase() + key.substr(1); + settings[newKey] = optionsAsMap[key]; + } + } + return settings; + } + ts.toEditorSettings = toEditorSettings; + function isCamelCase(s) { + return !s.length || s.charAt(0) === s.charAt(0).toLowerCase(); + } function displayPartsToString(displayParts) { if (displayParts) { return ts.map(displayParts, function (displayPart) { return displayPart.text; }).join(""); @@ -73000,9 +73617,13 @@ var ts; }; } ts.getDefaultCompilerOptions = getDefaultCompilerOptions; - // Cache host information about script should be refreshed + function getSupportedCodeFixes() { + return ts.codefix.getSupportedErrorCodes(); + } + ts.getSupportedCodeFixes = getSupportedCodeFixes; + // Cache host information about script Should be refreshed // at each language service public entry point, since we don't know when - // set of scripts handled by the host changes. + // the set of scripts handled by the host changes. var HostCache = (function () { function HostCache(host, getCanonicalFileName) { this.host = host; @@ -73185,7 +73806,8 @@ var ts; var ruleProvider; var program; var lastProjectVersion; - var useCaseSensitivefileNames = false; + var lastTypesRootVersion = 0; + var useCaseSensitivefileNames = host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(); var cancellationToken = new CancellationTokenObject(host.getCancellationToken && host.getCancellationToken()); var currentDirectory = host.getCurrentDirectory(); // Check if the localized messages json is set, otherwise query the host for it @@ -73224,6 +73846,12 @@ var ts; lastProjectVersion = hostProjectVersion; } } + var typeRootsVersion = host.getTypeRootsVersion ? host.getTypeRootsVersion() : 0; + if (lastTypesRootVersion !== typeRootsVersion) { + log("TypeRoots version has changed; provide new program"); + program = undefined; + lastTypesRootVersion = typeRootsVersion; + } // Get a fresh cache of the host information var hostCache = new HostCache(host, getCanonicalFileName); // If the program is already up-to-date, we can reuse it @@ -73553,12 +74181,12 @@ var ts; return ts.FindAllReferences.findReferencedSymbols(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position, findInStrings, findInComments); } /// NavigateTo - function getNavigateToItems(searchValue, maxResultCount, fileName) { + function getNavigateToItems(searchValue, maxResultCount, fileName, excludeDtsFiles) { synchronizeHostData(); var sourceFiles = fileName ? [getValidSourceFile(fileName)] : program.getSourceFiles(); - return ts.NavigateTo.getNavigateToItems(sourceFiles, program.getTypeChecker(), cancellationToken, searchValue, maxResultCount); + return ts.NavigateTo.getNavigateToItems(sourceFiles, program.getTypeChecker(), cancellationToken, searchValue, maxResultCount, excludeDtsFiles); } - function getEmitOutput(fileName) { + function getEmitOutput(fileName, emitOnlyDtsFiles) { synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); var outputFiles = []; @@ -73569,7 +74197,7 @@ var ts; text: data }); } - var emitOutput = program.emit(sourceFile, writeFile, cancellationToken); + var emitOutput = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles); return { outputFiles: outputFiles, emitSkipped: emitOutput.emitSkipped @@ -73647,14 +74275,28 @@ var ts; return ts.BreakpointResolver.spanInSourceFileAtLocation(sourceFile, position); } function getNavigationBarItems(fileName) { - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - return ts.NavigationBar.getNavigationBarItems(sourceFile); + return ts.NavigationBar.getNavigationBarItems(syntaxTreeCache.getCurrentSourceFile(fileName)); + } + function getNavigationTree(fileName) { + return ts.NavigationBar.getNavigationTree(syntaxTreeCache.getCurrentSourceFile(fileName)); + } + function isTsOrTsxFile(fileName) { + var kind = ts.getScriptKind(fileName, host); + return kind === 3 /* TS */ || kind === 4 /* TSX */; } function getSemanticClassifications(fileName, span) { + if (!isTsOrTsxFile(fileName)) { + // do not run semantic classification on non-ts-or-tsx files + return []; + } synchronizeHostData(); return ts.getSemanticClassifications(program.getTypeChecker(), cancellationToken, getValidSourceFile(fileName), program.getClassifiableNames(), span); } function getEncodedSemanticClassifications(fileName, span) { + if (!isTsOrTsxFile(fileName)) { + // do not run semantic classification on non-ts-or-tsx files + return { spans: [], endOfLineState: 0 /* None */ }; + } synchronizeHostData(); return ts.getEncodedSemanticClassifications(program.getTypeChecker(), cancellationToken, getValidSourceFile(fileName), program.getClassifiableNames(), span); } @@ -73715,34 +74357,60 @@ var ts; } function getIndentationAtPosition(fileName, position, editorOptions) { var start = ts.timestamp(); + var settings = toEditorSettings(editorOptions); var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); log("getIndentationAtPosition: getCurrentSourceFile: " + (ts.timestamp() - start)); start = ts.timestamp(); - var result = ts.formatting.SmartIndenter.getIndentation(position, sourceFile, editorOptions); + var result = ts.formatting.SmartIndenter.getIndentation(position, sourceFile, settings); log("getIndentationAtPosition: computeIndentation : " + (ts.timestamp() - start)); return result; } function getFormattingEditsForRange(fileName, start, end, options) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - return ts.formatting.formatSelection(start, end, sourceFile, getRuleProvider(options), options); + var settings = toEditorSettings(options); + return ts.formatting.formatSelection(start, end, sourceFile, getRuleProvider(settings), settings); } function getFormattingEditsForDocument(fileName, options) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - return ts.formatting.formatDocument(sourceFile, getRuleProvider(options), options); + var settings = toEditorSettings(options); + return ts.formatting.formatDocument(sourceFile, getRuleProvider(settings), settings); } function getFormattingEditsAfterKeystroke(fileName, position, key, options) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + var settings = toEditorSettings(options); if (key === "}") { - return ts.formatting.formatOnClosingCurly(position, sourceFile, getRuleProvider(options), options); + return ts.formatting.formatOnClosingCurly(position, sourceFile, getRuleProvider(settings), settings); } else if (key === ";") { - return ts.formatting.formatOnSemicolon(position, sourceFile, getRuleProvider(options), options); + return ts.formatting.formatOnSemicolon(position, sourceFile, getRuleProvider(settings), settings); } else if (key === "\n") { - return ts.formatting.formatOnEnter(position, sourceFile, getRuleProvider(options), options); + return ts.formatting.formatOnEnter(position, sourceFile, getRuleProvider(settings), settings); } return []; } + function getCodeFixesAtPosition(fileName, start, end, errorCodes) { + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + var span = { start: start, length: end - start }; + var newLineChar = ts.getNewLineOrDefaultFromHost(host); + var allFixes = []; + ts.forEach(errorCodes, function (error) { + cancellationToken.throwIfCancellationRequested(); + var context = { + errorCode: error, + sourceFile: sourceFile, + span: span, + program: program, + newLineCharacter: newLineChar + }; + var fixes = ts.codefix.getFixes(context); + if (fixes) { + allFixes = allFixes.concat(fixes); + } + }); + return allFixes; + } function getDocCommentTemplateAtPosition(fileName, position) { return ts.JsDoc.getDocCommentTemplateAtPosition(ts.getNewLineOrDefaultFromHost(host), syntaxTreeCache.getCurrentSourceFile(fileName), position); } @@ -73926,6 +74594,7 @@ var ts; getRenameInfo: getRenameInfo, findRenameLocations: findRenameLocations, getNavigationBarItems: getNavigationBarItems, + getNavigationTree: getNavigationTree, getOutliningSpans: getOutliningSpans, getTodoComments: getTodoComments, getBraceMatchingAtPosition: getBraceMatchingAtPosition, @@ -73935,6 +74604,7 @@ var ts; getFormattingEditsAfterKeystroke: getFormattingEditsAfterKeystroke, getDocCommentTemplateAtPosition: getDocCommentTemplateAtPosition, isValidBraceCompletionAtPosition: isValidBraceCompletionAtPosition, + getCodeFixesAtPosition: getCodeFixesAtPosition, getEmitOutput: getEmitOutput, getNonBoundSourceFile: getNonBoundSourceFile, getSourceFile: getSourceFile, @@ -74624,7 +75294,7 @@ var ts; // /// /* @internal */ -var debugObjectHost = new Function("return this")(); +var debugObjectHost = (function () { return this; })(); // We need to use 'null' to interface with the managed side. /* tslint:disable:no-null-keyword */ /* tslint:disable:no-in-operator */ @@ -74712,6 +75382,12 @@ var ts; } return this.shimHost.getProjectVersion(); }; + LanguageServiceShimHostAdapter.prototype.getTypeRootsVersion = function () { + if (!this.shimHost.getTypeRootsVersion) { + return 0; + } + return this.shimHost.getTypeRootsVersion(); + }; LanguageServiceShimHostAdapter.prototype.useCaseSensitiveFileNames = function () { return this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false; }; @@ -74914,11 +75590,12 @@ var ts; var LanguageServiceShimObject = (function (_super) { __extends(LanguageServiceShimObject, _super); function LanguageServiceShimObject(factory, host, languageService) { - _super.call(this, factory); - this.host = host; - this.languageService = languageService; - this.logPerformance = false; - this.logger = this.host; + var _this = _super.call(this, factory) || this; + _this.host = host; + _this.languageService = languageService; + _this.logPerformance = false; + _this.logger = _this.host; + return _this; } LanguageServiceShimObject.prototype.forwardJSONCall = function (actionDescription, action) { return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); @@ -75156,6 +75833,10 @@ var ts; var _this = this; return this.forwardJSONCall("getNavigationBarItems('" + fileName + "')", function () { return _this.languageService.getNavigationBarItems(fileName); }); }; + LanguageServiceShimObject.prototype.getNavigationTree = function (fileName) { + var _this = this; + return this.forwardJSONCall("getNavigationTree('" + fileName + "')", function () { return _this.languageService.getNavigationTree(fileName); }); + }; LanguageServiceShimObject.prototype.getOutliningSpans = function (fileName) { var _this = this; return this.forwardJSONCall("getOutliningSpans('" + fileName + "')", function () { return _this.languageService.getOutliningSpans(fileName); }); @@ -75182,10 +75863,11 @@ var ts; var ClassifierShimObject = (function (_super) { __extends(ClassifierShimObject, _super); function ClassifierShimObject(factory, logger) { - _super.call(this, factory); - this.logger = logger; - this.logPerformance = false; - this.classifier = ts.createClassifier(); + var _this = _super.call(this, factory) || this; + _this.logger = logger; + _this.logPerformance = false; + _this.classifier = ts.createClassifier(); + return _this; } ClassifierShimObject.prototype.getEncodedLexicalClassifications = function (text, lexState, syntacticClassifierAbsent) { var _this = this; @@ -75208,10 +75890,11 @@ var ts; var CoreServicesShimObject = (function (_super) { __extends(CoreServicesShimObject, _super); function CoreServicesShimObject(factory, logger, host) { - _super.call(this, factory); - this.logger = logger; - this.host = host; - this.logPerformance = false; + var _this = _super.call(this, factory) || this; + _this.logger = logger; + _this.host = host; + _this.logPerformance = false; + return _this; } CoreServicesShimObject.prototype.forwardJSONCall = function (actionDescription, action) { return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index e9c209674b5..5f319ffb74c 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -29,6 +29,7 @@ declare namespace ts { contains(fileName: Path): boolean; remove(fileName: Path): void; forEachValue(f: (key: Path, v: T) => void): void; + getKeys(): Path[]; clear(): void; } interface TextRange { @@ -388,7 +389,6 @@ declare namespace ts { ContextFlags = 1540096, TypeExcludesFlags = 327680, } - type ModifiersArray = NodeArray; enum ModifierFlags { None = 0, Export = 1, @@ -425,12 +425,21 @@ declare namespace ts { interface NodeArray extends Array, TextRange { hasTrailingComma?: boolean; } - interface Token extends Node { - __tokenTag: any; - } - interface Modifier extends Token { + interface Token extends Node { + kind: TKind; } + type DotDotDotToken = Token; + type QuestionToken = Token; + type ColonToken = Token; + type EqualsToken = Token; + type AsteriskToken = Token; + type EqualsGreaterThanToken = Token; + type EndOfFileToken = Token; + type AtToken = Token; + type Modifier = Token | Token | Token | Token | Token | Token | Token | Token | Token | Token | Token; + type ModifiersArray = NodeArray; interface Identifier extends PrimaryExpression { + kind: SyntaxKind.Identifier; text: string; originalKeywordKind?: SyntaxKind; } @@ -438,6 +447,7 @@ declare namespace ts { resolvedSymbol: Symbol; } interface QualifiedName extends Node { + kind: SyntaxKind.QualifiedName; left: EntityName; right: Identifier; } @@ -449,15 +459,18 @@ declare namespace ts { name?: DeclarationName; } interface DeclarationStatement extends Declaration, Statement { - name?: Identifier; + name?: Identifier | LiteralExpression; } interface ComputedPropertyName extends Node { + kind: SyntaxKind.ComputedPropertyName; expression: Expression; } interface Decorator extends Node { + kind: SyntaxKind.Decorator; expression: LeftHandSideExpression; } interface TypeParameterDeclaration extends Declaration { + kind: SyntaxKind.TypeParameter; name: Identifier; constraint?: TypeNode; expression?: Expression; @@ -469,40 +482,48 @@ declare namespace ts { type?: TypeNode; } interface CallSignatureDeclaration extends SignatureDeclaration, TypeElement { + kind: SyntaxKind.CallSignature; } interface ConstructSignatureDeclaration extends SignatureDeclaration, TypeElement { + kind: SyntaxKind.ConstructSignature; } type BindingName = Identifier | BindingPattern; interface VariableDeclaration extends Declaration { + kind: SyntaxKind.VariableDeclaration; parent?: VariableDeclarationList; name: BindingName; type?: TypeNode; initializer?: Expression; } interface VariableDeclarationList extends Node { + kind: SyntaxKind.VariableDeclarationList; declarations: NodeArray; } interface ParameterDeclaration extends Declaration { - dotDotDotToken?: Node; + kind: SyntaxKind.Parameter; + dotDotDotToken?: DotDotDotToken; name: BindingName; - questionToken?: Node; + questionToken?: QuestionToken; type?: TypeNode; initializer?: Expression; } interface BindingElement extends Declaration { + kind: SyntaxKind.BindingElement; propertyName?: PropertyName; - dotDotDotToken?: Node; + dotDotDotToken?: DotDotDotToken; name: BindingName; initializer?: Expression; } interface PropertySignature extends TypeElement { + kind: SyntaxKind.PropertySignature | SyntaxKind.JSDocRecordMember; name: PropertyName; - questionToken?: Node; + questionToken?: QuestionToken; type?: TypeNode; initializer?: Expression; } interface PropertyDeclaration extends ClassElement { - questionToken?: Node; + kind: SyntaxKind.PropertyDeclaration; + questionToken?: QuestionToken; name: PropertyName; type?: TypeNode; initializer?: Expression; @@ -513,22 +534,23 @@ declare namespace ts { } type ObjectLiteralElementLike = PropertyAssignment | ShorthandPropertyAssignment | MethodDeclaration | AccessorDeclaration; interface PropertyAssignment extends ObjectLiteralElement { - _propertyAssignmentBrand: any; + kind: SyntaxKind.PropertyAssignment; name: PropertyName; - questionToken?: Node; + questionToken?: QuestionToken; initializer: Expression; } interface ShorthandPropertyAssignment extends ObjectLiteralElement { + kind: SyntaxKind.ShorthandPropertyAssignment; name: Identifier; - questionToken?: Node; - equalsToken?: Node; + questionToken?: QuestionToken; + equalsToken?: Token; objectAssignmentInitializer?: Expression; } interface VariableLikeDeclaration extends Declaration { propertyName?: PropertyName; - dotDotDotToken?: Node; + dotDotDotToken?: DotDotDotToken; name: DeclarationName; - questionToken?: Node; + questionToken?: QuestionToken; type?: TypeNode; initializer?: Expression; } @@ -539,10 +561,12 @@ declare namespace ts { elements: NodeArray; } interface ObjectBindingPattern extends BindingPattern { + kind: SyntaxKind.ObjectBindingPattern; elements: NodeArray; } type ArrayBindingElement = BindingElement | OmittedExpression; interface ArrayBindingPattern extends BindingPattern { + kind: SyntaxKind.ArrayBindingPattern; elements: NodeArray; } /** @@ -555,95 +579,116 @@ declare namespace ts { */ interface FunctionLikeDeclaration extends SignatureDeclaration { _functionLikeDeclarationBrand: any; - asteriskToken?: Node; - questionToken?: Node; + asteriskToken?: AsteriskToken; + questionToken?: QuestionToken; body?: Block | Expression; } interface FunctionDeclaration extends FunctionLikeDeclaration, DeclarationStatement { + kind: SyntaxKind.FunctionDeclaration; name?: Identifier; body?: FunctionBody; } interface MethodSignature extends SignatureDeclaration, TypeElement { + kind: SyntaxKind.MethodSignature; name: PropertyName; } interface MethodDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { + kind: SyntaxKind.MethodDeclaration; name: PropertyName; body?: FunctionBody; } interface ConstructorDeclaration extends FunctionLikeDeclaration, ClassElement { + kind: SyntaxKind.Constructor; body?: FunctionBody; } interface SemicolonClassElement extends ClassElement { - _semicolonClassElementBrand: any; + kind: SyntaxKind.SemicolonClassElement; } - interface AccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { - _accessorDeclarationBrand: any; + interface GetAccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { + kind: SyntaxKind.GetAccessor; name: PropertyName; body: FunctionBody; } - interface GetAccessorDeclaration extends AccessorDeclaration { - } - interface SetAccessorDeclaration extends AccessorDeclaration { + interface SetAccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { + kind: SyntaxKind.SetAccessor; + name: PropertyName; + body: FunctionBody; } + type AccessorDeclaration = GetAccessorDeclaration | SetAccessorDeclaration; interface IndexSignatureDeclaration extends SignatureDeclaration, ClassElement, TypeElement { - _indexSignatureDeclarationBrand: any; + kind: SyntaxKind.IndexSignature; } interface TypeNode extends Node { _typeNodeBrand: any; } + interface KeywordTypeNode extends TypeNode { + kind: SyntaxKind.AnyKeyword | SyntaxKind.NumberKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.VoidKeyword; + } interface ThisTypeNode extends TypeNode { - _thisTypeNodeBrand: any; + kind: SyntaxKind.ThisType; } interface FunctionOrConstructorTypeNode extends TypeNode, SignatureDeclaration { - _functionOrConstructorTypeNodeBrand: any; + kind: SyntaxKind.FunctionType | SyntaxKind.ConstructorType; } interface FunctionTypeNode extends FunctionOrConstructorTypeNode { + kind: SyntaxKind.FunctionType; } interface ConstructorTypeNode extends FunctionOrConstructorTypeNode { + kind: SyntaxKind.ConstructorType; } interface TypeReferenceNode extends TypeNode { + kind: SyntaxKind.TypeReference; typeName: EntityName; typeArguments?: NodeArray; } interface TypePredicateNode extends TypeNode { + kind: SyntaxKind.TypePredicate; parameterName: Identifier | ThisTypeNode; type: TypeNode; } interface TypeQueryNode extends TypeNode { + kind: SyntaxKind.TypeQuery; exprName: EntityName; } interface TypeLiteralNode extends TypeNode, Declaration { + kind: SyntaxKind.TypeLiteral; members: NodeArray; } interface ArrayTypeNode extends TypeNode { + kind: SyntaxKind.ArrayType; elementType: TypeNode; } interface TupleTypeNode extends TypeNode { + kind: SyntaxKind.TupleType; elementTypes: NodeArray; } interface UnionOrIntersectionTypeNode extends TypeNode { + kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType; types: NodeArray; } interface UnionTypeNode extends UnionOrIntersectionTypeNode { + kind: SyntaxKind.UnionType; } interface IntersectionTypeNode extends UnionOrIntersectionTypeNode { + kind: SyntaxKind.IntersectionType; } interface ParenthesizedTypeNode extends TypeNode { + kind: SyntaxKind.ParenthesizedType; type: TypeNode; } interface LiteralTypeNode extends TypeNode { - _stringLiteralTypeBrand: any; + kind: SyntaxKind.LiteralType; literal: Expression; } interface StringLiteral extends LiteralExpression { - _stringLiteralBrand: any; + kind: SyntaxKind.StringLiteral; } interface Expression extends Node { _expressionBrand: any; contextualType?: Type; } interface OmittedExpression extends Expression { - _omittedExpressionBrand: any; + kind: SyntaxKind.OmittedExpression; } interface UnaryExpression extends Expression { _unaryExpressionBrand: any; @@ -651,13 +696,17 @@ declare namespace ts { interface IncrementExpression extends UnaryExpression { _incrementExpressionBrand: any; } + type PrefixUnaryOperator = SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.TildeToken | SyntaxKind.ExclamationToken; interface PrefixUnaryExpression extends IncrementExpression { - operator: SyntaxKind; + kind: SyntaxKind.PrefixUnaryExpression; + operator: PrefixUnaryOperator; operand: UnaryExpression; } + type PostfixUnaryOperator = SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken; interface PostfixUnaryExpression extends IncrementExpression { + kind: SyntaxKind.PostfixUnaryExpression; operand: LeftHandSideExpression; - operator: SyntaxKind; + operator: PostfixUnaryOperator; } interface PostfixExpression extends UnaryExpression { _postfixExpressionBrand: any; @@ -671,42 +720,83 @@ declare namespace ts { interface PrimaryExpression extends MemberExpression { _primaryExpressionBrand: any; } + interface NullLiteral extends PrimaryExpression { + kind: SyntaxKind.NullKeyword; + } + interface BooleanLiteral extends PrimaryExpression { + kind: SyntaxKind.TrueKeyword | SyntaxKind.FalseKeyword; + } + interface ThisExpression extends PrimaryExpression { + kind: SyntaxKind.ThisKeyword; + } + interface SuperExpression extends PrimaryExpression { + kind: SyntaxKind.SuperKeyword; + } interface DeleteExpression extends UnaryExpression { + kind: SyntaxKind.DeleteExpression; expression: UnaryExpression; } interface TypeOfExpression extends UnaryExpression { + kind: SyntaxKind.TypeOfExpression; expression: UnaryExpression; } interface VoidExpression extends UnaryExpression { + kind: SyntaxKind.VoidExpression; expression: UnaryExpression; } interface AwaitExpression extends UnaryExpression { + kind: SyntaxKind.AwaitExpression; expression: UnaryExpression; } interface YieldExpression extends Expression { - asteriskToken?: Node; + kind: SyntaxKind.YieldExpression; + asteriskToken?: AsteriskToken; expression?: Expression; } + type ExponentiationOperator = SyntaxKind.AsteriskAsteriskToken; + type MultiplicativeOperator = SyntaxKind.AsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken; + type MultiplicativeOperatorOrHigher = ExponentiationOperator | MultiplicativeOperator; + type AdditiveOperator = SyntaxKind.PlusToken | SyntaxKind.MinusToken; + type AdditiveOperatorOrHigher = MultiplicativeOperatorOrHigher | AdditiveOperator; + type ShiftOperator = SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken; + type ShiftOperatorOrHigher = AdditiveOperatorOrHigher | ShiftOperator; + type RelationalOperator = SyntaxKind.LessThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.InstanceOfKeyword | SyntaxKind.InKeyword; + type RelationalOperatorOrHigher = ShiftOperatorOrHigher | RelationalOperator; + type EqualityOperator = SyntaxKind.EqualsEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.ExclamationEqualsToken; + type EqualityOperatorOrHigher = RelationalOperatorOrHigher | EqualityOperator; + type BitwiseOperator = SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken; + type BitwiseOperatorOrHigher = EqualityOperatorOrHigher | BitwiseOperator; + type LogicalOperator = SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken; + type LogicalOperatorOrHigher = BitwiseOperatorOrHigher | LogicalOperator; + type CompoundAssignmentOperator = SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken; + type AssignmentOperator = SyntaxKind.EqualsToken | CompoundAssignmentOperator; + type AssignmentOperatorOrHigher = LogicalOperatorOrHigher | AssignmentOperator; + type BinaryOperator = AssignmentOperatorOrHigher | SyntaxKind.CommaToken; + type BinaryOperatorToken = Token; interface BinaryExpression extends Expression, Declaration { + kind: SyntaxKind.BinaryExpression; left: Expression; - operatorToken: Node; + operatorToken: BinaryOperatorToken; right: Expression; } interface ConditionalExpression extends Expression { + kind: SyntaxKind.ConditionalExpression; condition: Expression; - questionToken: Node; + questionToken: QuestionToken; whenTrue: Expression; - colonToken: Node; + colonToken: ColonToken; whenFalse: Expression; } type FunctionBody = Block; type ConciseBody = FunctionBody | Expression; interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclaration { + kind: SyntaxKind.FunctionExpression; name?: Identifier; body: FunctionBody; } interface ArrowFunction extends Expression, FunctionLikeDeclaration { - equalsGreaterThanToken: Node; + kind: SyntaxKind.ArrowFunction; + equalsGreaterThanToken: EqualsGreaterThanToken; body: ConciseBody; } interface LiteralLikeNode extends Node { @@ -717,29 +807,46 @@ declare namespace ts { interface LiteralExpression extends LiteralLikeNode, PrimaryExpression { _literalExpressionBrand: any; } + interface RegularExpressionLiteral extends LiteralExpression { + kind: SyntaxKind.RegularExpressionLiteral; + } + interface NoSubstitutionTemplateLiteral extends LiteralExpression { + kind: SyntaxKind.NoSubstitutionTemplateLiteral; + } interface NumericLiteral extends LiteralExpression { - _numericLiteralBrand: any; + kind: SyntaxKind.NumericLiteral; trailingComment?: string; } - interface TemplateLiteralFragment extends LiteralLikeNode { - _templateLiteralFragmentBrand: any; + interface TemplateHead extends LiteralLikeNode { + kind: SyntaxKind.TemplateHead; } - type Template = TemplateExpression | LiteralExpression; + interface TemplateMiddle extends LiteralLikeNode { + kind: SyntaxKind.TemplateMiddle; + } + interface TemplateTail extends LiteralLikeNode { + kind: SyntaxKind.TemplateTail; + } + type TemplateLiteral = TemplateExpression | NoSubstitutionTemplateLiteral; interface TemplateExpression extends PrimaryExpression { - head: TemplateLiteralFragment; + kind: SyntaxKind.TemplateExpression; + head: TemplateHead; templateSpans: NodeArray; } interface TemplateSpan extends Node { + kind: SyntaxKind.TemplateSpan; expression: Expression; - literal: TemplateLiteralFragment; + literal: TemplateMiddle | TemplateTail; } interface ParenthesizedExpression extends PrimaryExpression { + kind: SyntaxKind.ParenthesizedExpression; expression: Expression; } interface ArrayLiteralExpression extends PrimaryExpression { + kind: SyntaxKind.ArrayLiteralExpression; elements: NodeArray; } interface SpreadElementExpression extends Expression { + kind: SyntaxKind.SpreadElementExpression; expression: Expression; } /** @@ -752,104 +859,141 @@ declare namespace ts { properties: NodeArray; } interface ObjectLiteralExpression extends ObjectLiteralExpressionBase { + kind: SyntaxKind.ObjectLiteralExpression; } type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression; type EntityNameOrEntityNameExpression = EntityName | EntityNameExpression; interface PropertyAccessExpression extends MemberExpression, Declaration { + kind: SyntaxKind.PropertyAccessExpression; expression: LeftHandSideExpression; name: Identifier; } + interface SuperPropertyAccessExpression extends PropertyAccessExpression { + expression: SuperExpression; + } /** Brand for a PropertyAccessExpression which, like a QualifiedName, consists of a sequence of identifiers separated by dots. */ interface PropertyAccessEntityNameExpression extends PropertyAccessExpression { _propertyAccessExpressionLikeQualifiedNameBrand?: any; expression: EntityNameExpression; } interface ElementAccessExpression extends MemberExpression { + kind: SyntaxKind.ElementAccessExpression; expression: LeftHandSideExpression; argumentExpression?: Expression; } + interface SuperElementAccessExpression extends ElementAccessExpression { + expression: SuperExpression; + } + type SuperProperty = SuperPropertyAccessExpression | SuperElementAccessExpression; interface CallExpression extends LeftHandSideExpression, Declaration { + kind: SyntaxKind.CallExpression; expression: LeftHandSideExpression; typeArguments?: NodeArray; arguments: NodeArray; } + interface SuperCall extends CallExpression { + expression: SuperExpression; + } interface ExpressionWithTypeArguments extends TypeNode { + kind: SyntaxKind.ExpressionWithTypeArguments; expression: LeftHandSideExpression; typeArguments?: NodeArray; } - interface NewExpression extends CallExpression, PrimaryExpression { + interface NewExpression extends PrimaryExpression, Declaration { + kind: SyntaxKind.NewExpression; + expression: LeftHandSideExpression; + typeArguments?: NodeArray; + arguments: NodeArray; } interface TaggedTemplateExpression extends MemberExpression { + kind: SyntaxKind.TaggedTemplateExpression; tag: LeftHandSideExpression; - template: Template; + template: TemplateLiteral; } type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator; interface AsExpression extends Expression { + kind: SyntaxKind.AsExpression; expression: Expression; type: TypeNode; } interface TypeAssertion extends UnaryExpression { + kind: SyntaxKind.TypeAssertionExpression; type: TypeNode; expression: UnaryExpression; } type AssertionExpression = TypeAssertion | AsExpression; interface NonNullExpression extends LeftHandSideExpression { + kind: SyntaxKind.NonNullExpression; expression: Expression; } interface JsxElement extends PrimaryExpression { + kind: SyntaxKind.JsxElement; openingElement: JsxOpeningElement; children: NodeArray; closingElement: JsxClosingElement; } type JsxTagNameExpression = PrimaryExpression | PropertyAccessExpression; interface JsxOpeningElement extends Expression { - _openingElementBrand?: any; + kind: SyntaxKind.JsxOpeningElement; tagName: JsxTagNameExpression; attributes: NodeArray; } - interface JsxSelfClosingElement extends PrimaryExpression, JsxOpeningElement { - _selfClosingElementBrand?: any; + interface JsxSelfClosingElement extends PrimaryExpression { + kind: SyntaxKind.JsxSelfClosingElement; + tagName: JsxTagNameExpression; + attributes: NodeArray; } type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; interface JsxAttribute extends Node { + kind: SyntaxKind.JsxAttribute; name: Identifier; initializer?: StringLiteral | JsxExpression; } interface JsxSpreadAttribute extends Node { + kind: SyntaxKind.JsxSpreadAttribute; expression: Expression; } interface JsxClosingElement extends Node { + kind: SyntaxKind.JsxClosingElement; tagName: JsxTagNameExpression; } interface JsxExpression extends Expression { + kind: SyntaxKind.JsxExpression; expression?: Expression; } interface JsxText extends Node { - _jsxTextExpressionBrand: any; + kind: SyntaxKind.JsxText; } type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement; interface Statement extends Node { _statementBrand: any; } interface EmptyStatement extends Statement { + kind: SyntaxKind.EmptyStatement; } interface DebuggerStatement extends Statement { + kind: SyntaxKind.DebuggerStatement; } interface MissingDeclaration extends DeclarationStatement, ClassElement, ObjectLiteralElement, TypeElement { + kind: SyntaxKind.MissingDeclaration; name?: Identifier; } type BlockLike = SourceFile | Block | ModuleBlock | CaseClause; interface Block extends Statement { + kind: SyntaxKind.Block; statements: NodeArray; } interface VariableStatement extends Statement { + kind: SyntaxKind.VariableStatement; declarationList: VariableDeclarationList; } interface ExpressionStatement extends Statement { + kind: SyntaxKind.ExpressionStatement; expression: Expression; } interface IfStatement extends Statement { + kind: SyntaxKind.IfStatement; expression: Expression; thenStatement: Statement; elseStatement?: Statement; @@ -858,68 +1002,85 @@ declare namespace ts { statement: Statement; } interface DoStatement extends IterationStatement { + kind: SyntaxKind.DoStatement; expression: Expression; } interface WhileStatement extends IterationStatement { + kind: SyntaxKind.WhileStatement; expression: Expression; } type ForInitializer = VariableDeclarationList | Expression; interface ForStatement extends IterationStatement { + kind: SyntaxKind.ForStatement; initializer?: ForInitializer; condition?: Expression; incrementor?: Expression; } interface ForInStatement extends IterationStatement { + kind: SyntaxKind.ForInStatement; initializer: ForInitializer; expression: Expression; } interface ForOfStatement extends IterationStatement { + kind: SyntaxKind.ForOfStatement; initializer: ForInitializer; expression: Expression; } interface BreakStatement extends Statement { + kind: SyntaxKind.BreakStatement; label?: Identifier; } interface ContinueStatement extends Statement { + kind: SyntaxKind.ContinueStatement; label?: Identifier; } type BreakOrContinueStatement = BreakStatement | ContinueStatement; interface ReturnStatement extends Statement { + kind: SyntaxKind.ReturnStatement; expression?: Expression; } interface WithStatement extends Statement { + kind: SyntaxKind.WithStatement; expression: Expression; statement: Statement; } interface SwitchStatement extends Statement { + kind: SyntaxKind.SwitchStatement; expression: Expression; caseBlock: CaseBlock; possiblyExhaustive?: boolean; } interface CaseBlock extends Node { + kind: SyntaxKind.CaseBlock; clauses: NodeArray; } interface CaseClause extends Node { + kind: SyntaxKind.CaseClause; expression: Expression; statements: NodeArray; } interface DefaultClause extends Node { + kind: SyntaxKind.DefaultClause; statements: NodeArray; } type CaseOrDefaultClause = CaseClause | DefaultClause; interface LabeledStatement extends Statement { + kind: SyntaxKind.LabeledStatement; label: Identifier; statement: Statement; } interface ThrowStatement extends Statement { + kind: SyntaxKind.ThrowStatement; expression: Expression; } interface TryStatement extends Statement { + kind: SyntaxKind.TryStatement; tryBlock: Block; catchClause?: CatchClause; finallyBlock?: Block; } interface CatchClause extends Node { + kind: SyntaxKind.CatchClause; variableDeclaration: VariableDeclaration; block: Block; } @@ -931,9 +1092,11 @@ declare namespace ts { members: NodeArray; } interface ClassDeclaration extends ClassLikeDeclaration, DeclarationStatement { + kind: SyntaxKind.ClassDeclaration; name?: Identifier; } interface ClassExpression extends ClassLikeDeclaration, PrimaryExpression { + kind: SyntaxKind.ClassExpression; } interface ClassElement extends Declaration { _classElementBrand: any; @@ -942,85 +1105,108 @@ declare namespace ts { interface TypeElement extends Declaration { _typeElementBrand: any; name?: PropertyName; - questionToken?: Node; + questionToken?: QuestionToken; } interface InterfaceDeclaration extends DeclarationStatement { + kind: SyntaxKind.InterfaceDeclaration; name: Identifier; typeParameters?: NodeArray; heritageClauses?: NodeArray; members: NodeArray; } interface HeritageClause extends Node { + kind: SyntaxKind.HeritageClause; token: SyntaxKind; types?: NodeArray; } interface TypeAliasDeclaration extends DeclarationStatement { + kind: SyntaxKind.TypeAliasDeclaration; name: Identifier; typeParameters?: NodeArray; type: TypeNode; } interface EnumMember extends Declaration { + kind: SyntaxKind.EnumMember; name: PropertyName; initializer?: Expression; } interface EnumDeclaration extends DeclarationStatement { + kind: SyntaxKind.EnumDeclaration; name: Identifier; members: NodeArray; } type ModuleBody = ModuleBlock | ModuleDeclaration; type ModuleName = Identifier | StringLiteral; interface ModuleDeclaration extends DeclarationStatement { + kind: SyntaxKind.ModuleDeclaration; name: Identifier | LiteralExpression; - body?: ModuleBlock | ModuleDeclaration; + body?: ModuleBlock | NamespaceDeclaration; + } + interface NamespaceDeclaration extends ModuleDeclaration { + name: Identifier; + body: ModuleBlock | NamespaceDeclaration; } interface ModuleBlock extends Node, Statement { + kind: SyntaxKind.ModuleBlock; statements: NodeArray; } type ModuleReference = EntityName | ExternalModuleReference; interface ImportEqualsDeclaration extends DeclarationStatement { + kind: SyntaxKind.ImportEqualsDeclaration; name: Identifier; moduleReference: ModuleReference; } interface ExternalModuleReference extends Node { + kind: SyntaxKind.ExternalModuleReference; expression?: Expression; } interface ImportDeclaration extends Statement { + kind: SyntaxKind.ImportDeclaration; importClause?: ImportClause; moduleSpecifier: Expression; } type NamedImportBindings = NamespaceImport | NamedImports; interface ImportClause extends Declaration { + kind: SyntaxKind.ImportClause; name?: Identifier; namedBindings?: NamedImportBindings; } interface NamespaceImport extends Declaration { + kind: SyntaxKind.NamespaceImport; name: Identifier; } interface NamespaceExportDeclaration extends DeclarationStatement { + kind: SyntaxKind.NamespaceExportDeclaration; name: Identifier; moduleReference: LiteralLikeNode; } interface ExportDeclaration extends DeclarationStatement { + kind: SyntaxKind.ExportDeclaration; exportClause?: NamedExports; moduleSpecifier?: Expression; } interface NamedImports extends Node { + kind: SyntaxKind.NamedImports; elements: NodeArray; } interface NamedExports extends Node { + kind: SyntaxKind.NamedExports; elements: NodeArray; } type NamedImportsOrExports = NamedImports | NamedExports; interface ImportSpecifier extends Declaration { + kind: SyntaxKind.ImportSpecifier; propertyName?: Identifier; name: Identifier; } interface ExportSpecifier extends Declaration { + kind: SyntaxKind.ExportSpecifier; propertyName?: Identifier; name: Identifier; } type ImportOrExportSpecifier = ImportSpecifier | ExportSpecifier; interface ExportAssignment extends DeclarationStatement { + kind: SyntaxKind.ExportAssignment; isExportEquals?: boolean; expression: Expression; } @@ -1032,95 +1218,121 @@ declare namespace ts { kind: SyntaxKind; } interface JSDocTypeExpression extends Node { + kind: SyntaxKind.JSDocTypeExpression; type: JSDocType; } interface JSDocType extends TypeNode { _jsDocTypeBrand: any; } interface JSDocAllType extends JSDocType { - _JSDocAllTypeBrand: any; + kind: SyntaxKind.JSDocAllType; } interface JSDocUnknownType extends JSDocType { - _JSDocUnknownTypeBrand: any; + kind: SyntaxKind.JSDocUnknownType; } interface JSDocArrayType extends JSDocType { + kind: SyntaxKind.JSDocArrayType; elementType: JSDocType; } interface JSDocUnionType extends JSDocType { + kind: SyntaxKind.JSDocUnionType; types: NodeArray; } interface JSDocTupleType extends JSDocType { + kind: SyntaxKind.JSDocTupleType; types: NodeArray; } interface JSDocNonNullableType extends JSDocType { + kind: SyntaxKind.JSDocNonNullableType; type: JSDocType; } interface JSDocNullableType extends JSDocType { + kind: SyntaxKind.JSDocNullableType; type: JSDocType; } - interface JSDocRecordType extends JSDocType, TypeLiteralNode { + interface JSDocRecordType extends JSDocType { + kind: SyntaxKind.JSDocRecordType; literal: TypeLiteralNode; } interface JSDocTypeReference extends JSDocType { + kind: SyntaxKind.JSDocTypeReference; name: EntityName; typeArguments: NodeArray; } interface JSDocOptionalType extends JSDocType { + kind: SyntaxKind.JSDocOptionalType; type: JSDocType; } interface JSDocFunctionType extends JSDocType, SignatureDeclaration { + kind: SyntaxKind.JSDocFunctionType; parameters: NodeArray; type: JSDocType; } interface JSDocVariadicType extends JSDocType { + kind: SyntaxKind.JSDocVariadicType; type: JSDocType; } interface JSDocConstructorType extends JSDocType { + kind: SyntaxKind.JSDocConstructorType; type: JSDocType; } interface JSDocThisType extends JSDocType { + kind: SyntaxKind.JSDocThisType; type: JSDocType; } interface JSDocLiteralType extends JSDocType { + kind: SyntaxKind.JSDocLiteralType; literal: LiteralTypeNode; } type JSDocTypeReferencingNode = JSDocThisType | JSDocConstructorType | JSDocVariadicType | JSDocOptionalType | JSDocNullableType | JSDocNonNullableType; interface JSDocRecordMember extends PropertySignature { + kind: SyntaxKind.JSDocRecordMember; name: Identifier | LiteralExpression; type?: JSDocType; } interface JSDoc extends Node { + kind: SyntaxKind.JSDocComment; tags: NodeArray | undefined; comment: string | undefined; } interface JSDocTag extends Node { - atToken: Node; + atToken: AtToken; tagName: Identifier; comment: string | undefined; } + interface JSDocUnknownTag extends JSDocTag { + kind: SyntaxKind.JSDocTag; + } interface JSDocTemplateTag extends JSDocTag { + kind: SyntaxKind.JSDocTemplateTag; typeParameters: NodeArray; } interface JSDocReturnTag extends JSDocTag { + kind: SyntaxKind.JSDocReturnTag; typeExpression: JSDocTypeExpression; } interface JSDocTypeTag extends JSDocTag { + kind: SyntaxKind.JSDocTypeTag; typeExpression: JSDocTypeExpression; } interface JSDocTypedefTag extends JSDocTag, Declaration { + kind: SyntaxKind.JSDocTypedefTag; name?: Identifier; typeExpression?: JSDocTypeExpression; jsDocTypeLiteral?: JSDocTypeLiteral; } interface JSDocPropertyTag extends JSDocTag, TypeElement { + kind: SyntaxKind.JSDocPropertyTag; name: Identifier; typeExpression: JSDocTypeExpression; } interface JSDocTypeLiteral extends JSDocType { + kind: SyntaxKind.JSDocTypeLiteral; jsDocPropertyTags?: NodeArray; jsDocTypeTag?: JSDocTypeTag; } interface JSDocParameterTag extends JSDocTag { + kind: SyntaxKind.JSDocParameterTag; /** the parameter name, if provided *before* the type (TypeScript-style) */ preParameterName?: Identifier; typeExpression?: JSDocTypeExpression; @@ -1149,7 +1361,7 @@ declare namespace ts { id?: number; } interface FlowStart extends FlowNode { - container?: FunctionExpression | ArrowFunction; + container?: FunctionExpression | ArrowFunction | MethodDeclaration; } interface FlowLabel extends FlowNode { antecedents: FlowNode[]; @@ -1178,8 +1390,9 @@ declare namespace ts { name: string; } interface SourceFile extends Declaration { + kind: SyntaxKind.SourceFile; statements: NodeArray; - endOfFileToken: Node; + endOfFileToken: Token; fileName: string; path: Path; text: string; @@ -1245,7 +1458,7 @@ declare namespace ts { * used for writing the JavaScript and declaration files. Otherwise, the writeFile parameter * will be invoked when writing the JavaScript and declaration files. */ - emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken): EmitResult; + emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean): EmitResult; getOptionsDiagnostics(cancellationToken?: CancellationToken): Diagnostic[]; getGlobalDiagnostics(cancellationToken?: CancellationToken): Diagnostic[]; getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; @@ -1372,6 +1585,7 @@ declare namespace ts { UseFullyQualifiedType = 128, InFirstTypeArgument = 256, InTypeAlias = 512, + UseTypeAliasValue = 1024, } enum SymbolFormatFlags { None = 0, @@ -1387,9 +1601,10 @@ declare namespace ts { type: Type; } interface ThisTypePredicate extends TypePredicateBase { - _thisTypePredicateBrand: any; + kind: TypePredicateKind.This; } interface IdentifierTypePredicate extends TypePredicateBase { + kind: TypePredicateKind.Identifier; parameterName: string; parameterIndex: number; } @@ -1495,8 +1710,6 @@ declare namespace ts { Intersection = 1048576, Anonymous = 2097152, Instantiated = 4194304, - ThisType = 268435456, - ObjectLiteralPatternWithComputedProperties = 536870912, Literal = 480, StringOrNumberLiteral = 96, PossiblyFalsy = 7406, @@ -1509,7 +1722,7 @@ declare namespace ts { StructuredType = 4161536, StructuredOrTypeParameter = 4177920, Narrowable = 4178943, - NotUnionOrUnit = 2589191, + NotUnionOrUnit = 2589185, } type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; interface Type { @@ -1531,6 +1744,7 @@ declare namespace ts { baseType: EnumType & UnionType; } interface ObjectType extends Type { + isObjectLiteralPatternWithComputedProperties?: boolean; } interface InterfaceType extends ObjectType { typeParameters: TypeParameter[]; @@ -1614,15 +1828,13 @@ declare namespace ts { Classic = 1, NodeJs = 2, } - type RootPaths = string[]; - type PathSubstitutions = MapLike; - type TsConfigOnlyOptions = RootPaths | PathSubstitutions; - type CompilerOptionsValue = string | number | boolean | (string | number)[] | TsConfigOnlyOptions; + type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike; interface CompilerOptions { allowJs?: boolean; allowSyntheticDefaultImports?: boolean; allowUnreachableCode?: boolean; allowUnusedLabels?: boolean; + alwaysStrict?: boolean; baseUrl?: string; charset?: string; declaration?: boolean; @@ -1660,13 +1872,13 @@ declare namespace ts { out?: string; outDir?: string; outFile?: string; - paths?: PathSubstitutions; + paths?: MapLike; preserveConstEnums?: boolean; project?: string; reactNamespace?: string; removeComments?: boolean; rootDir?: string; - rootDirs?: RootPaths; + rootDirs?: string[]; skipLibCheck?: boolean; skipDefaultLibCheck?: boolean; sourceMap?: boolean; @@ -1742,6 +1954,7 @@ declare namespace ts { raw?: any; errors: Diagnostic[]; wildcardDirectories?: MapLike; + compileOnSave?: boolean; } enum WatchDirectoryFlags { None = 0, @@ -1846,7 +2059,7 @@ declare namespace ts { directoryName: string; referenceCount: number; } - var sys: System; + let sys: System; } declare namespace ts { interface ErrorCallback { @@ -1944,10 +2157,6 @@ declare namespace ts { function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; } declare namespace ts { - /** The version of the TypeScript compiler release */ - const version = "2.1.0"; - function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName?: string): string; - function resolveTripleslashReference(moduleName: string, containingFile: string): string; function getEffectiveTypeRoots(options: CompilerOptions, host: { directoryExists?: (directoryName: string) => boolean; getCurrentDirectory?: () => string; @@ -1958,18 +2167,6 @@ declare namespace ts { * is assumed to be the same as root directory of the project. */ function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string, options: CompilerOptions, host: ModuleResolutionHost): ResolvedTypeReferenceDirectiveWithFailedLookupLocations; - function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; - function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; - function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; - function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; - function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; - interface FormatDiagnosticsHost { - getCurrentDirectory(): string; - getCanonicalFileName(fileName: string): string; - getNewLine(): string; - } - function formatDiagnostics(diagnostics: Diagnostic[], host: FormatDiagnosticsHost): string; - function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string; /** * Given a set of options, returns the set of type directive names * that should be included for this program automatically. @@ -1979,6 +2176,24 @@ declare namespace ts { * this list is only the set of defaults that are implicitly included. */ function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[]; + function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; + function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; + function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; +} +declare namespace ts { + /** The version of the TypeScript compiler release */ + const version = "2.1.0"; + function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName?: string): string; + function resolveTripleslashReference(moduleName: string, containingFile: string): string; + function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; + function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; + interface FormatDiagnosticsHost { + getCurrentDirectory(): string; + getCanonicalFileName(fileName: string): string; + getNewLine(): string; + } + function formatDiagnostics(diagnostics: Diagnostic[], host: FormatDiagnosticsHost): string; + function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string; function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program; } declare namespace ts { @@ -1995,7 +2210,7 @@ declare namespace ts { * @param fileName The path to the config file * @param jsonText The text of the config file */ - function parseConfigFileTextToJson(fileName: string, jsonText: string): { + function parseConfigFileTextToJson(fileName: string, jsonText: string, stripComments?: boolean): { config?: any; error?: Diagnostic; }; @@ -2007,12 +2222,13 @@ declare namespace ts { * file to. e.g. outDir */ function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[]): ParsedCommandLine; + function convertCompileOnSaveOptionFromJson(jsonOption: any, basePath: string, errors: Diagnostic[]): boolean; function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: CompilerOptions; errors: Diagnostic[]; }; function convertTypingOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { - options: CompilerOptions; + options: TypingOptions; errors: Diagnostic[]; }; } @@ -2118,6 +2334,7 @@ declare namespace ts { readDirectory?(path: string, extensions?: string[], exclude?: string[], include?: string[]): string[]; readFile?(path: string, encoding?: string): string; fileExists?(path: string): boolean; + getTypeRootsVersion?(): number; resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[]; resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; directoryExists?(directoryName: string): boolean; @@ -2155,18 +2372,20 @@ declare namespace ts { getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[]; /** @deprecated */ getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[]; - getNavigateToItems(searchValue: string, maxResultCount?: number, fileName?: string): NavigateToItem[]; + getNavigateToItems(searchValue: string, maxResultCount?: number, fileName?: string, excludeDtsFiles?: boolean): NavigateToItem[]; getNavigationBarItems(fileName: string): NavigationBarItem[]; + getNavigationTree(fileName: string): NavigationTree; getOutliningSpans(fileName: string): OutliningSpan[]; getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[]; getBraceMatchingAtPosition(fileName: string, position: number): TextSpan[]; - getIndentationAtPosition(fileName: string, position: number, options: EditorOptions): number; - getFormattingEditsForRange(fileName: string, start: number, end: number, options: FormatCodeOptions): TextChange[]; - getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions): TextChange[]; - getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): TextChange[]; + getIndentationAtPosition(fileName: string, position: number, options: EditorOptions | EditorSettings): number; + getFormattingEditsForRange(fileName: string, start: number, end: number, options: FormatCodeOptions | FormatCodeSettings): TextChange[]; + getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions | FormatCodeSettings): TextChange[]; + getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions | FormatCodeSettings): TextChange[]; getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion; isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean; - getEmitOutput(fileName: string): EmitOutput; + getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[]): CodeAction[]; + getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean): EmitOutput; getProgram(): Program; dispose(): void; } @@ -2178,6 +2397,12 @@ declare namespace ts { textSpan: TextSpan; classificationType: string; } + /** + * Navigation bar interface designed for visual studio's dual-column layout. + * This does not form a proper tree. + * The navbar is returned as a list of top-level items, each of which has a list of child items. + * Child items always have an empty array for their `childItems`. + */ interface NavigationBarItem { text: string; kind: string; @@ -2188,6 +2413,25 @@ declare namespace ts { bolded: boolean; grayed: boolean; } + /** + * Node in a tree of nested declarations in a file. + * The top node is always a script or module node. + */ + interface NavigationTree { + /** Name of the declaration, or a short description, e.g. "". */ + text: string; + /** A ScriptElementKind */ + kind: string; + /** ScriptElementKindModifier separated by commas, e.g. "public,abstract" */ + kindModifiers: string; + /** + * Spans of the nodes that generated this declaration. + * There will be more than one if this is the result of merging. + */ + spans: TextSpan[]; + /** Present if non-empty */ + childItems?: NavigationTree[]; + } interface TodoCommentDescriptor { text: string; priority: number; @@ -2201,6 +2445,16 @@ declare namespace ts { span: TextSpan; newText: string; } + interface FileTextChanges { + fileName: string; + textChanges: TextChange[]; + } + interface CodeAction { + /** Description of the code action to display in the UI of the editor */ + description: string; + /** Text changes to apply to each file as part of the code action */ + changes: FileTextChanges[]; + } interface TextInsertion { newText: string; /** The position in newText the caret should point to after the insertion. */ @@ -2246,6 +2500,11 @@ declare namespace ts { containerName: string; containerKind: string; } + enum IndentStyle { + None = 0, + Block = 1, + Smart = 2, + } interface EditorOptions { BaseIndentSize?: number; IndentSize: number; @@ -2254,10 +2513,13 @@ declare namespace ts { ConvertTabsToSpaces: boolean; IndentStyle: IndentStyle; } - enum IndentStyle { - None = 0, - Block = 1, - Smart = 2, + interface EditorSettings { + baseIndentSize?: number; + indentSize?: number; + tabSize?: number; + newLineCharacter?: string; + convertTabsToSpaces?: boolean; + indentStyle?: IndentStyle; } interface FormatCodeOptions extends EditorOptions { InsertSpaceAfterCommaDelimiter: boolean; @@ -2273,7 +2535,21 @@ declare namespace ts { InsertSpaceAfterTypeAssertion?: boolean; PlaceOpenBraceOnNewLineForFunctions: boolean; PlaceOpenBraceOnNewLineForControlBlocks: boolean; - [s: string]: boolean | number | string | undefined; + } + interface FormatCodeSettings extends EditorSettings { + insertSpaceAfterCommaDelimiter?: boolean; + insertSpaceAfterSemicolonInForStatements?: boolean; + insertSpaceBeforeAndAfterBinaryOperators?: boolean; + insertSpaceAfterKeywordsInControlFlowStatements?: boolean; + insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; + insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; + insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean; + insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces?: boolean; + insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; + insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; + insertSpaceAfterTypeAssertion?: boolean; + placeOpenBraceOnNewLineForFunctions?: boolean; + placeOpenBraceOnNewLineForControlBlocks?: boolean; } interface DefinitionInfo { fileName: string; @@ -2366,7 +2642,11 @@ declare namespace ts { argumentCount: number; } interface CompletionInfo { + isGlobalCompletion: boolean; isMemberCompletion: boolean; + /** + * true when the current location also allows for a new identifier + */ isNewIdentifierLocation: boolean; entries: CompletionEntry[]; } @@ -2687,8 +2967,10 @@ declare namespace ts { interface DisplayPartsSymbolWriter extends SymbolWriter { displayParts(): SymbolDisplayPart[]; } + function toEditorSettings(options: EditorOptions | EditorSettings): EditorSettings; function displayPartsToString(displayParts: SymbolDisplayPart[]): string; function getDefaultCompilerOptions(): CompilerOptions; + function getSupportedCodeFixes(): string[]; function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean, scriptKind?: ScriptKind): SourceFile; let disableIncrementalParsing: boolean; function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index 14fbdce59a8..c534a725901 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -502,6 +502,7 @@ var ts; TypeFormatFlags[TypeFormatFlags["UseFullyQualifiedType"] = 128] = "UseFullyQualifiedType"; TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 256] = "InFirstTypeArgument"; TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 512] = "InTypeAlias"; + TypeFormatFlags[TypeFormatFlags["UseTypeAliasValue"] = 1024] = "UseTypeAliasValue"; })(ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); var TypeFormatFlags = ts.TypeFormatFlags; (function (SymbolFormatFlags) { @@ -685,8 +686,6 @@ var ts; TypeFlags[TypeFlags["ContainsObjectLiteral"] = 67108864] = "ContainsObjectLiteral"; /* @internal */ TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 134217728] = "ContainsAnyFunctionType"; - TypeFlags[TypeFlags["ThisType"] = 268435456] = "ThisType"; - TypeFlags[TypeFlags["ObjectLiteralPatternWithComputedProperties"] = 536870912] = "ObjectLiteralPatternWithComputedProperties"; /* @internal */ TypeFlags[TypeFlags["Nullable"] = 6144] = "Nullable"; TypeFlags[TypeFlags["Literal"] = 480] = "Literal"; @@ -709,7 +708,7 @@ var ts; // 'Narrowable' types are types where narrowing actually narrows. // This *should* be every type other than null, undefined, void, and never TypeFlags[TypeFlags["Narrowable"] = 4178943] = "Narrowable"; - TypeFlags[TypeFlags["NotUnionOrUnit"] = 2589191] = "NotUnionOrUnit"; + TypeFlags[TypeFlags["NotUnionOrUnit"] = 2589185] = "NotUnionOrUnit"; /* @internal */ TypeFlags[TypeFlags["RequiresWidening"] = 100663296] = "RequiresWidening"; /* @internal */ @@ -993,36 +992,44 @@ var ts; })(ts.TransformFlags || (ts.TransformFlags = {})); var TransformFlags = ts.TransformFlags; /* @internal */ - (function (NodeEmitFlags) { - NodeEmitFlags[NodeEmitFlags["EmitEmitHelpers"] = 1] = "EmitEmitHelpers"; - NodeEmitFlags[NodeEmitFlags["EmitExportStar"] = 2] = "EmitExportStar"; - NodeEmitFlags[NodeEmitFlags["EmitSuperHelper"] = 4] = "EmitSuperHelper"; - NodeEmitFlags[NodeEmitFlags["EmitAdvancedSuperHelper"] = 8] = "EmitAdvancedSuperHelper"; - NodeEmitFlags[NodeEmitFlags["UMDDefine"] = 16] = "UMDDefine"; - NodeEmitFlags[NodeEmitFlags["SingleLine"] = 32] = "SingleLine"; - NodeEmitFlags[NodeEmitFlags["AdviseOnEmitNode"] = 64] = "AdviseOnEmitNode"; - NodeEmitFlags[NodeEmitFlags["NoSubstitution"] = 128] = "NoSubstitution"; - NodeEmitFlags[NodeEmitFlags["CapturesThis"] = 256] = "CapturesThis"; - NodeEmitFlags[NodeEmitFlags["NoLeadingSourceMap"] = 512] = "NoLeadingSourceMap"; - NodeEmitFlags[NodeEmitFlags["NoTrailingSourceMap"] = 1024] = "NoTrailingSourceMap"; - NodeEmitFlags[NodeEmitFlags["NoSourceMap"] = 1536] = "NoSourceMap"; - NodeEmitFlags[NodeEmitFlags["NoNestedSourceMaps"] = 2048] = "NoNestedSourceMaps"; - NodeEmitFlags[NodeEmitFlags["NoTokenLeadingSourceMaps"] = 4096] = "NoTokenLeadingSourceMaps"; - NodeEmitFlags[NodeEmitFlags["NoTokenTrailingSourceMaps"] = 8192] = "NoTokenTrailingSourceMaps"; - NodeEmitFlags[NodeEmitFlags["NoTokenSourceMaps"] = 12288] = "NoTokenSourceMaps"; - NodeEmitFlags[NodeEmitFlags["NoLeadingComments"] = 16384] = "NoLeadingComments"; - NodeEmitFlags[NodeEmitFlags["NoTrailingComments"] = 32768] = "NoTrailingComments"; - NodeEmitFlags[NodeEmitFlags["NoComments"] = 49152] = "NoComments"; - NodeEmitFlags[NodeEmitFlags["NoNestedComments"] = 65536] = "NoNestedComments"; - NodeEmitFlags[NodeEmitFlags["ExportName"] = 131072] = "ExportName"; - NodeEmitFlags[NodeEmitFlags["LocalName"] = 262144] = "LocalName"; - NodeEmitFlags[NodeEmitFlags["Indented"] = 524288] = "Indented"; - NodeEmitFlags[NodeEmitFlags["NoIndentation"] = 1048576] = "NoIndentation"; - NodeEmitFlags[NodeEmitFlags["AsyncFunctionBody"] = 2097152] = "AsyncFunctionBody"; - NodeEmitFlags[NodeEmitFlags["ReuseTempVariableScope"] = 4194304] = "ReuseTempVariableScope"; - NodeEmitFlags[NodeEmitFlags["CustomPrologue"] = 8388608] = "CustomPrologue"; - })(ts.NodeEmitFlags || (ts.NodeEmitFlags = {})); - var NodeEmitFlags = ts.NodeEmitFlags; + (function (EmitFlags) { + EmitFlags[EmitFlags["EmitEmitHelpers"] = 1] = "EmitEmitHelpers"; + EmitFlags[EmitFlags["EmitExportStar"] = 2] = "EmitExportStar"; + EmitFlags[EmitFlags["EmitSuperHelper"] = 4] = "EmitSuperHelper"; + EmitFlags[EmitFlags["EmitAdvancedSuperHelper"] = 8] = "EmitAdvancedSuperHelper"; + EmitFlags[EmitFlags["UMDDefine"] = 16] = "UMDDefine"; + EmitFlags[EmitFlags["SingleLine"] = 32] = "SingleLine"; + EmitFlags[EmitFlags["AdviseOnEmitNode"] = 64] = "AdviseOnEmitNode"; + EmitFlags[EmitFlags["NoSubstitution"] = 128] = "NoSubstitution"; + EmitFlags[EmitFlags["CapturesThis"] = 256] = "CapturesThis"; + EmitFlags[EmitFlags["NoLeadingSourceMap"] = 512] = "NoLeadingSourceMap"; + EmitFlags[EmitFlags["NoTrailingSourceMap"] = 1024] = "NoTrailingSourceMap"; + EmitFlags[EmitFlags["NoSourceMap"] = 1536] = "NoSourceMap"; + EmitFlags[EmitFlags["NoNestedSourceMaps"] = 2048] = "NoNestedSourceMaps"; + EmitFlags[EmitFlags["NoTokenLeadingSourceMaps"] = 4096] = "NoTokenLeadingSourceMaps"; + EmitFlags[EmitFlags["NoTokenTrailingSourceMaps"] = 8192] = "NoTokenTrailingSourceMaps"; + EmitFlags[EmitFlags["NoTokenSourceMaps"] = 12288] = "NoTokenSourceMaps"; + EmitFlags[EmitFlags["NoLeadingComments"] = 16384] = "NoLeadingComments"; + EmitFlags[EmitFlags["NoTrailingComments"] = 32768] = "NoTrailingComments"; + EmitFlags[EmitFlags["NoComments"] = 49152] = "NoComments"; + EmitFlags[EmitFlags["NoNestedComments"] = 65536] = "NoNestedComments"; + EmitFlags[EmitFlags["ExportName"] = 131072] = "ExportName"; + EmitFlags[EmitFlags["LocalName"] = 262144] = "LocalName"; + EmitFlags[EmitFlags["Indented"] = 524288] = "Indented"; + EmitFlags[EmitFlags["NoIndentation"] = 1048576] = "NoIndentation"; + EmitFlags[EmitFlags["AsyncFunctionBody"] = 2097152] = "AsyncFunctionBody"; + EmitFlags[EmitFlags["ReuseTempVariableScope"] = 4194304] = "ReuseTempVariableScope"; + EmitFlags[EmitFlags["CustomPrologue"] = 8388608] = "CustomPrologue"; + })(ts.EmitFlags || (ts.EmitFlags = {})); + var EmitFlags = ts.EmitFlags; + /* @internal */ + (function (EmitContext) { + EmitContext[EmitContext["SourceFile"] = 0] = "SourceFile"; + EmitContext[EmitContext["Expression"] = 1] = "Expression"; + EmitContext[EmitContext["IdentifierName"] = 2] = "IdentifierName"; + EmitContext[EmitContext["Unspecified"] = 3] = "Unspecified"; + })(ts.EmitContext || (ts.EmitContext = {})); + var EmitContext = ts.EmitContext; })(ts || (ts = {})); /*@internal*/ var ts; @@ -1032,7 +1039,6 @@ var ts; })(ts || (ts = {})); /*@internal*/ /** Performance measurements for the compiler. */ -var ts; (function (ts) { var performance; (function (performance) { @@ -1164,6 +1170,7 @@ var ts; contains: contains, remove: remove, forEachValue: forEachValueInMap, + getKeys: getKeys, clear: clear }; function forEachValueInMap(f) { @@ -1171,6 +1178,13 @@ var ts; f(key, files[key]); } } + function getKeys() { + var keys = []; + for (var key in files) { + keys.push(key); + } + return keys; + } // path should already be well-formed so it does not need to be normalized function get(path) { return files[toKey(path)]; @@ -1501,6 +1515,7 @@ var ts; return array1.concat(array2); } ts.concatenate = concatenate; + // TODO: fixme (N^2) - add optional comparer so collection can be sorted before deduplication. function deduplicate(array, areEqual) { var result; if (array) { @@ -1604,16 +1619,22 @@ var ts; * @param array A sorted array whose first element must be no larger than number * @param number The value to be searched for in the array. */ - function binarySearch(array, value) { + function binarySearch(array, value, comparer) { + if (!array || array.length === 0) { + return -1; + } var low = 0; var high = array.length - 1; + comparer = comparer !== undefined + ? comparer + : function (v1, v2) { return (v1 < v2 ? -1 : (v1 > v2 ? 1 : 0)); }; while (low <= high) { var middle = low + ((high - low) >> 1); var midValue = array[middle]; - if (midValue === value) { + if (comparer(midValue, value) === 0) { return middle; } - else if (midValue > value) { + else if (comparer(midValue, value) > 0) { high = middle - 1; } else { @@ -1929,6 +1950,56 @@ var ts; }; } ts.memoize = memoize; + function chain(a, b, c, d, e) { + if (e) { + var args_2 = []; + for (var i = 0; i < arguments.length; i++) { + args_2[i] = arguments[i]; + } + return function (t) { return compose.apply(void 0, map(args_2, function (f) { return f(t); })); }; + } + else if (d) { + return function (t) { return compose(a(t), b(t), c(t), d(t)); }; + } + else if (c) { + return function (t) { return compose(a(t), b(t), c(t)); }; + } + else if (b) { + return function (t) { return compose(a(t), b(t)); }; + } + else if (a) { + return function (t) { return compose(a(t)); }; + } + else { + return function (t) { return function (u) { return u; }; }; + } + } + ts.chain = chain; + function compose(a, b, c, d, e) { + if (e) { + var args_3 = []; + for (var i = 0; i < arguments.length; i++) { + args_3[i] = arguments[i]; + } + return function (t) { return reduceLeft(args_3, function (u, f) { return f(u); }, t); }; + } + else if (d) { + return function (t) { return d(c(b(a(t)))); }; + } + else if (c) { + return function (t) { return c(b(a(t))); }; + } + else if (b) { + return function (t) { return b(a(t)); }; + } + else if (a) { + return function (t) { return a(t); }; + } + else { + return function (t) { return t; }; + } + } + ts.compose = compose; function formatStringFromArgs(text, args, baseIndex) { baseIndex = baseIndex || 0; return text.replace(/{(\d+)}/g, function (match, index) { return args[+index + baseIndex]; }); @@ -2096,7 +2167,9 @@ var ts; return path.replace(/\\/g, "/"); } ts.normalizeSlashes = normalizeSlashes; - // Returns length of path root (i.e. length of "/", "x:/", "//server/share/, file:///user/files") + /** + * Returns length of path root (i.e. length of "/", "x:/", "//server/share/, file:///user/files") + */ function getRootLength(path) { if (path.charCodeAt(0) === 47 /* slash */) { if (path.charCodeAt(1) !== 47 /* slash */) @@ -2129,6 +2202,11 @@ var ts; return 0; } ts.getRootLength = getRootLength; + /** + * Internally, we represent paths as strings with '/' as the directory separator. + * When we make system calls (eg: LanguageServiceHost.getDirectory()), + * we expect the host to correctly handle paths in our specified format. + */ ts.directorySeparator = "/"; var directorySeparatorCharCode = 47 /* slash */; function getNormalizedParts(normalizedSlashedPath, rootLength) { @@ -2178,10 +2256,49 @@ var ts; return path && !isRootedDiskPath(path) && path.indexOf("://") !== -1; } ts.isUrl = isUrl; + 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 /^\.\.?($|[\\/])/.test(moduleName); + } + ts.isExternalModuleNameRelative = isExternalModuleNameRelative; + function getEmitScriptTarget(compilerOptions) { + return compilerOptions.target || 0 /* ES3 */; + } + ts.getEmitScriptTarget = getEmitScriptTarget; + function getEmitModuleKind(compilerOptions) { + return typeof compilerOptions.module === "number" ? + compilerOptions.module : + getEmitScriptTarget(compilerOptions) === 2 /* ES6 */ ? ts.ModuleKind.ES6 : ts.ModuleKind.CommonJS; + } + ts.getEmitModuleKind = getEmitModuleKind; + /* @internal */ + function hasZeroOrOneAsteriskCharacter(str) { + var seenAsterisk = false; + for (var i = 0; i < str.length; i++) { + if (str.charCodeAt(i) === 42 /* asterisk */) { + if (!seenAsterisk) { + seenAsterisk = true; + } + else { + // have already seen asterisk + return false; + } + } + } + return true; + } + ts.hasZeroOrOneAsteriskCharacter = hasZeroOrOneAsteriskCharacter; function isRootedDiskPath(path) { return getRootLength(path) !== 0; } ts.isRootedDiskPath = isRootedDiskPath; + function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) { + return !isRootedDiskPath(absoluteOrRelativePath) + ? absoluteOrRelativePath + : getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); + } + ts.convertToRelativePath = convertToRelativePath; function normalizedPathComponents(path, rootLength) { var normalizedParts = getNormalizedParts(path, rootLength); return [path.substr(0, rootLength)].concat(normalizedParts); @@ -2625,6 +2742,14 @@ var ts; return options && options.allowJs ? allSupportedExtensions : ts.supportedTypeScriptExtensions; } ts.getSupportedExtensions = getSupportedExtensions; + function hasJavaScriptFileExtension(fileName) { + return forEach(ts.supportedJavascriptExtensions, function (extension) { return fileExtensionIs(fileName, extension); }); + } + ts.hasJavaScriptFileExtension = hasJavaScriptFileExtension; + function hasTypeScriptFileExtension(fileName) { + return forEach(ts.supportedTypeScriptExtensions, function (extension) { return fileExtensionIs(fileName, extension); }); + } + ts.hasTypeScriptFileExtension = hasTypeScriptFileExtension; function isSupportedSourceFileName(fileName, compilerOptions) { if (!fileName) { return false; @@ -2737,7 +2862,6 @@ var ts; this.transformFlags = 0 /* None */; this.parent = undefined; this.original = undefined; - this.transformId = 0; } ts.objectAllocator = { getNodeConstructor: function () { return Node; }, @@ -2757,9 +2881,9 @@ var ts; var AssertionLevel = ts.AssertionLevel; var Debug; (function (Debug) { - var currentAssertionLevel; + Debug.currentAssertionLevel = 0 /* None */; function shouldAssert(level) { - return getCurrentAssertionLevel() >= level; + return Debug.currentAssertionLevel >= level; } Debug.shouldAssert = shouldAssert; function assert(expression, message, verboseDebugInfo) { @@ -2777,30 +2901,7 @@ var ts; Debug.assert(/*expression*/ false, message); } Debug.fail = fail; - function getCurrentAssertionLevel() { - if (currentAssertionLevel !== undefined) { - return currentAssertionLevel; - } - if (ts.sys === undefined) { - return 0 /* None */; - } - var developmentMode = /^development$/i.test(getEnvironmentVariable("NODE_ENV")); - currentAssertionLevel = developmentMode - ? 1 /* Normal */ - : 0 /* None */; - return currentAssertionLevel; - } })(Debug = ts.Debug || (ts.Debug = {})); - function getEnvironmentVariable(name, host) { - if (host && host.getEnvironmentVariable) { - return host.getEnvironmentVariable(name); - } - if (ts.sys && ts.sys.getEnvironmentVariable) { - return ts.sys.getEnvironmentVariable(name); - } - return ""; - } - ts.getEnvironmentVariable = getEnvironmentVariable; /** Remove an item from an array, moving everything to its right one space left. */ function orderedRemoveItemAt(array, index) { // This seems to be faster than either `array.splice(i, 1)` or `array.copyWithin(i, i+ 1)`. @@ -2836,6 +2937,84 @@ var ts; : (function (fileName) { return fileName.toLowerCase(); }); } ts.createGetCanonicalFileName = createGetCanonicalFileName; + /** + * patternStrings contains both pattern strings (containing "*") and regular strings. + * Return an exact match if possible, or a pattern match, or undefined. + * (These are verified by verifyCompilerOptions to have 0 or 1 "*" characters.) + */ + /* @internal */ + function matchPatternOrExact(patternStrings, candidate) { + var patterns = []; + for (var _i = 0, patternStrings_1 = patternStrings; _i < patternStrings_1.length; _i++) { + var patternString = patternStrings_1[_i]; + var pattern = tryParsePattern(patternString); + if (pattern) { + patterns.push(pattern); + } + else if (patternString === candidate) { + // pattern was matched as is - no need to search further + return patternString; + } + } + return findBestPatternMatch(patterns, function (_) { return _; }, candidate); + } + ts.matchPatternOrExact = matchPatternOrExact; + /* @internal */ + function patternText(_a) { + var prefix = _a.prefix, suffix = _a.suffix; + return prefix + "*" + suffix; + } + ts.patternText = patternText; + /** + * Given that candidate matches pattern, returns the text matching the '*'. + * E.g.: matchedText(tryParsePattern("foo*baz"), "foobarbaz") === "bar" + */ + /* @internal */ + function matchedText(pattern, candidate) { + Debug.assert(isPatternMatch(pattern, candidate)); + return candidate.substr(pattern.prefix.length, candidate.length - pattern.suffix.length); + } + ts.matchedText = matchedText; + /** Return the object corresponding to the best pattern to match `candidate`. */ + /* @internal */ + function findBestPatternMatch(values, getPattern, candidate) { + var matchedValue = undefined; + // use length of prefix as betterness criteria + var longestMatchPrefixLength = -1; + for (var _i = 0, values_1 = values; _i < values_1.length; _i++) { + var v = values_1[_i]; + var pattern = getPattern(v); + if (isPatternMatch(pattern, candidate) && pattern.prefix.length > longestMatchPrefixLength) { + longestMatchPrefixLength = pattern.prefix.length; + matchedValue = v; + } + } + return matchedValue; + } + ts.findBestPatternMatch = findBestPatternMatch; + function isPatternMatch(_a, candidate) { + var prefix = _a.prefix, suffix = _a.suffix; + return candidate.length >= prefix.length + suffix.length && + startsWith(candidate, prefix) && + endsWith(candidate, suffix); + } + /* @internal */ + function tryParsePattern(pattern) { + // This should be verified outside of here and a proper error thrown. + Debug.assert(hasZeroOrOneAsteriskCharacter(pattern)); + var indexOfStar = pattern.indexOf("*"); + return indexOfStar === -1 ? undefined : { + prefix: pattern.substr(0, indexOfStar), + suffix: pattern.substr(indexOfStar + 1) + }; + } + ts.tryParsePattern = tryParsePattern; + function positionIsSynthesized(pos) { + // This is a fast way of testing the following conditions: + // pos === undefined || pos === null || isNaN(pos) || pos < 0; + return !(pos >= 0); + } + ts.positionIsSynthesized = positionIsSynthesized; })(ts || (ts = {})); /// var ts; @@ -3040,9 +3219,17 @@ var ts; function isNode4OrLater() { return parseInt(process.version.charAt(1)) >= 4; } + function isFileSystemCaseSensitive() { + // win32\win64 are case insensitive platforms + if (platform === "win32" || platform === "win64") { + return false; + } + // convert current file name to upper case / lower case and check if file exists + // (guards against cases when name is already all uppercase or lowercase) + return !fileExists(__filename.toUpperCase()) || !fileExists(__filename.toLowerCase()); + } var platform = _os.platform(); - // win32\win64 are case insensitive platforms, MacOS (darwin) by default is also case insensitive - var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin"; + var useCaseSensitiveFileNames = isFileSystemCaseSensitive(); function readFile(fileName, encoding) { if (!fileExists(fileName)) { return undefined; @@ -3182,6 +3369,9 @@ var ts; // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows // (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643) var options; + if (!directoryExists(directoryName)) { + return; + } if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) { options = { persistent: true, recursive: !!recursive }; } @@ -3299,21 +3489,46 @@ var ts; realpath: realpath }; } + function recursiveCreateDirectory(directoryPath, sys) { + var basePath = ts.getDirectoryPath(directoryPath); + var shouldCreateParent = directoryPath !== basePath && !sys.directoryExists(basePath); + if (shouldCreateParent) { + recursiveCreateDirectory(basePath, sys); + } + if (shouldCreateParent || !sys.directoryExists(directoryPath)) { + sys.createDirectory(directoryPath); + } + } + var sys; if (typeof ChakraHost !== "undefined") { - return getChakraSystem(); + sys = getChakraSystem(); } else if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { - return getWScriptSystem(); + sys = getWScriptSystem(); } else if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof require !== "undefined") { // process and process.nextTick checks if current environment is node-like // process.browser check excludes webpack and browserify - return getNodeSystem(); + sys = getNodeSystem(); } - else { - return undefined; // Unsupported host + if (sys) { + // patch writefile to create folder before writing the file + var originalWriteFile_1 = sys.writeFile; + sys.writeFile = function (path, data, writeBom) { + var directoryPath = ts.getDirectoryPath(ts.normalizeSlashes(path)); + if (directoryPath && !sys.directoryExists(directoryPath)) { + recursiveCreateDirectory(directoryPath, sys); + } + originalWriteFile_1.call(sys, path, data, writeBom); + }; } + return sys; })(); + if (ts.sys && ts.sys.getEnvironmentVariable) { + ts.Debug.currentAssertionLevel = /^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV")) + ? 1 /* Normal */ + : 0 /* None */; + } })(ts || (ts = {})); // /// @@ -3641,7 +3856,7 @@ var ts; The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2407, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_2407", message: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter." }, Setters_cannot_return_a_value: { code: 2408, category: ts.DiagnosticCategory.Error, key: "Setters_cannot_return_a_value_2408", message: "Setters cannot return a value." }, Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { code: 2409, category: ts.DiagnosticCategory.Error, key: "Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class_2409", message: "Return type of constructor signature must be assignable to the instance type of the class" }, - All_symbols_within_a_with_block_will_be_resolved_to_any: { code: 2410, category: ts.DiagnosticCategory.Error, key: "All_symbols_within_a_with_block_will_be_resolved_to_any_2410", message: "All symbols within a 'with' block will be resolved to 'any'." }, + The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any: { code: 2410, category: ts.DiagnosticCategory.Error, key: "The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any_2410", message: "The 'with' statement is not supported. All symbols in a 'with' block will have type 'any'." }, Property_0_of_type_1_is_not_assignable_to_string_index_type_2: { code: 2411, category: ts.DiagnosticCategory.Error, key: "Property_0_of_type_1_is_not_assignable_to_string_index_type_2_2411", message: "Property '{0}' of type '{1}' is not assignable to string index type '{2}'." }, Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2: { code: 2412, category: ts.DiagnosticCategory.Error, key: "Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2_2412", message: "Property '{0}' of type '{1}' is not assignable to numeric index type '{2}'." }, Numeric_index_type_0_is_not_assignable_to_string_index_type_1: { code: 2413, category: ts.DiagnosticCategory.Error, key: "Numeric_index_type_0_is_not_assignable_to_string_index_type_1_2413", message: "Numeric index type '{0}' is not assignable to string index type '{1}'." }, @@ -3802,7 +4017,7 @@ var ts; this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation: { code: 2683, category: ts.DiagnosticCategory.Error, key: "this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_2683", message: "'this' implicitly has type 'any' because it does not have a type annotation." }, The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1: { code: 2684, category: ts.DiagnosticCategory.Error, key: "The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1_2684", message: "The 'this' context of type '{0}' is not assignable to method's 'this' of type '{1}'." }, The_this_types_of_each_signature_are_incompatible: { code: 2685, category: ts.DiagnosticCategory.Error, key: "The_this_types_of_each_signature_are_incompatible_2685", message: "The 'this' types of each signature are incompatible." }, - Identifier_0_must_be_imported_from_a_module: { code: 2686, category: ts.DiagnosticCategory.Error, key: "Identifier_0_must_be_imported_from_a_module_2686", message: "Identifier '{0}' must be imported from a module" }, + _0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead: { code: 2686, category: ts.DiagnosticCategory.Error, key: "_0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead_2686", message: "'{0}' refers to a UMD global, but the current file is a module. Consider adding an import instead." }, All_declarations_of_0_must_have_identical_modifiers: { code: 2687, category: ts.DiagnosticCategory.Error, key: "All_declarations_of_0_must_have_identical_modifiers_2687", message: "All declarations of '{0}' must have identical modifiers." }, Cannot_find_type_definition_file_for_0: { code: 2688, category: ts.DiagnosticCategory.Error, key: "Cannot_find_type_definition_file_for_0_2688", message: "Cannot find type definition file for '{0}'." }, Cannot_extend_an_interface_0_Did_you_mean_implements: { code: 2689, category: ts.DiagnosticCategory.Error, key: "Cannot_extend_an_interface_0_Did_you_mean_implements_2689", message: "Cannot extend an interface '{0}'. Did you mean 'implements'?" }, @@ -4035,6 +4250,8 @@ var ts; No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0: { code: 6137, category: ts.DiagnosticCategory.Message, key: "No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0_6137", message: "No types specified in 'package.json' but 'allowJs' is set, so returning 'main' value of '{0}'" }, Property_0_is_declared_but_never_used: { code: 6138, category: ts.DiagnosticCategory.Error, key: "Property_0_is_declared_but_never_used_6138", message: "Property '{0}' is declared but never used." }, Import_emit_helpers_from_tslib: { code: 6139, category: ts.DiagnosticCategory.Message, key: "Import_emit_helpers_from_tslib_6139", message: "Import emit helpers from 'tslib'." }, + Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: { code: 6140, category: ts.DiagnosticCategory.Error, key: "Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using__6140", message: "Auto discovery for typings is enabled in project '{0}'. Running extra resolution pass for module '{1}' using cache location '{2}'." }, + Parse_in_strict_mode_and_emit_use_strict_for_each_source_file: { code: 6141, category: ts.DiagnosticCategory.Message, key: "Parse_in_strict_mode_and_emit_use_strict_for_each_source_file_6141", message: "Parse in strict mode and emit \"use strict\" for each source file" }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter_0_implicitly_has_an_1_type_7006", message: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member_0_implicitly_has_an_1_type_7008", message: "Member '{0}' implicitly has an '{1}' type." }, @@ -4059,6 +4276,7 @@ var ts; Binding_element_0_implicitly_has_an_1_type: { code: 7031, category: ts.DiagnosticCategory.Error, key: "Binding_element_0_implicitly_has_an_1_type_7031", message: "Binding element '{0}' implicitly has an '{1}' type." }, Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation: { code: 7032, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation_7032", message: "Property '{0}' implicitly has type 'any', because its set accessor lacks a parameter type annotation." }, Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation: { code: 7033, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation_7033", message: "Property '{0}' implicitly has type 'any', because its get accessor lacks a return type annotation." }, + Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined: { code: 7034, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined_7034", message: "Variable '{0}' implicitly has type 'any' in some locations where its type cannot be determined." }, You_cannot_rename_this_element: { code: 8000, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_this_element_8000", message: "You cannot rename this element." }, You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", message: "You cannot rename elements that are defined in the standard TypeScript library." }, import_can_only_be_used_in_a_ts_file: { code: 8002, category: ts.DiagnosticCategory.Error, key: "import_can_only_be_used_in_a_ts_file_8002", message: "'import ... =' can only be used in a .ts file." }, @@ -4088,7 +4306,14 @@ var ts; super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class: { code: 17009, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class_17009", message: "'super' must be called before accessing 'this' in the constructor of a derived class." }, Unknown_typing_option_0: { code: 17010, category: ts.DiagnosticCategory.Error, key: "Unknown_typing_option_0_17010", message: "Unknown typing option '{0}'." }, Circularity_detected_while_resolving_configuration_Colon_0: { code: 18000, category: ts.DiagnosticCategory.Error, key: "Circularity_detected_while_resolving_configuration_Colon_0_18000", message: "Circularity detected while resolving configuration: {0}" }, - The_path_in_an_extends_options_must_be_relative_or_rooted: { code: 18001, category: ts.DiagnosticCategory.Error, key: "The_path_in_an_extends_options_must_be_relative_or_rooted_18001", message: "The path in an 'extends' options must be relative or rooted." } + The_path_in_an_extends_options_must_be_relative_or_rooted: { code: 18001, category: ts.DiagnosticCategory.Error, key: "The_path_in_an_extends_options_must_be_relative_or_rooted_18001", message: "The path in an 'extends' options must be relative or rooted." }, + Add_missing_super_call: { code: 90001, category: ts.DiagnosticCategory.Message, key: "Add_missing_super_call_90001", message: "Add missing 'super()' call." }, + Make_super_call_the_first_statement_in_the_constructor: { code: 90002, category: ts.DiagnosticCategory.Message, key: "Make_super_call_the_first_statement_in_the_constructor_90002", message: "Make 'super()' call the first statement in the constructor." }, + Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'" }, + Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers" }, + Implement_interface_on_reference: { code: 90005, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_reference_90005", message: "Implement interface on reference" }, + Implement_interface_on_class: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_class_90006", message: "Implement interface on class" }, + Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" } }; })(ts || (ts = {})); /// @@ -5145,7 +5370,7 @@ var ts; return token = 69 /* Identifier */; } function scanBinaryOrOctalDigits(base) { - ts.Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8"); + ts.Debug.assert(base === 2 || base === 8, "Expected either base 2 or base 8"); var value = 0; // For counting number of digits; Valid binaryIntegerLiteral must have at least one binary digit following B or b. // Similarly valid octalIntegerLiteral must have at least one octal digit following o or O. @@ -6364,10 +6589,10 @@ var ts; return !!(ts.getCombinedNodeFlags(node) & 1 /* Let */); } ts.isLet = isLet; - function isSuperCallExpression(n) { + function isSuperCall(n) { return n.kind === 174 /* CallExpression */ && n.expression.kind === 95 /* SuperKeyword */; } - ts.isSuperCallExpression = isSuperCallExpression; + ts.isSuperCall = isSuperCall; function isPrologueDirective(node) { return node.kind === 202 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; } @@ -6636,6 +6861,12 @@ var ts; return node && node.kind === 147 /* MethodDeclaration */ && node.parent.kind === 171 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; + function isObjectLiteralOrClassExpressionMethod(node) { + return node.kind === 147 /* MethodDeclaration */ && + (node.parent.kind === 171 /* ObjectLiteralExpression */ || + node.parent.kind === 192 /* ClassExpression */); + } + ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { return predicate && predicate.kind === 1 /* Identifier */; } @@ -6723,11 +6954,11 @@ var ts; } ts.getThisContainer = getThisContainer; /** - * Given an super call\property node returns a closest node where either - * - super call\property is legal in the node and not legal in the parent node the node. + * Given an super call/property node, returns the closest node where + * - a super call/property access is legal in the node and not legal in the parent node the node. * i.e. super call is legal in constructor but not legal in the class body. - * - node is arrow function (so caller might need to call getSuperContainer in case it needs to climb higher) - * - super call\property is definitely illegal in the node (but might be legal in some subnode) + * - the container is an arrow function (so caller might need to call getSuperContainer again in case it needs to climb higher) + * - a super call/property is definitely illegal in the container (but might be legal in some subnode) * i.e. super property access is illegal in function declaration but can be legal in the statement list */ function getSuperContainer(node, stopOnFunctions) { @@ -6988,12 +7219,6 @@ var ts; return false; } ts.isPartOfExpression = isPartOfExpression; - 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 /^\.\.?($|[\\/])/.test(moduleName); - } - ts.isExternalModuleNameRelative = isExternalModuleNameRelative; function isInstantiatedModule(node, preserveConstEnums) { var moduleState = ts.getModuleInstanceState(node); return moduleState === 1 /* Instantiated */ || @@ -7655,16 +7880,10 @@ var ts; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { - return positionIsSynthesized(node.pos) - || positionIsSynthesized(node.end); + return ts.positionIsSynthesized(node.pos) + || ts.positionIsSynthesized(node.end); } ts.nodeIsSynthesized = nodeIsSynthesized; - function positionIsSynthesized(pos) { - // This is a fast way of testing the following conditions: - // pos === undefined || pos === null || isNaN(pos) || pos < 0; - return !(pos >= 0); - } - ts.positionIsSynthesized = positionIsSynthesized; function getOriginalNode(node) { if (node) { while (node.original !== undefined) { @@ -8125,24 +8344,12 @@ var ts; function getDeclarationEmitOutputFilePath(sourceFile, host) { var options = host.getCompilerOptions(); var outputDir = options.declarationDir || options.outDir; // Prefer declaration folder if specified - if (options.declaration) { - var path = outputDir - ? getSourceFilePathInNewDir(sourceFile, host, outputDir) - : sourceFile.fileName; - return ts.removeFileExtension(path) + ".d.ts"; - } + var path = outputDir + ? getSourceFilePathInNewDir(sourceFile, host, outputDir) + : sourceFile.fileName; + return ts.removeFileExtension(path) + ".d.ts"; } ts.getDeclarationEmitOutputFilePath = getDeclarationEmitOutputFilePath; - function getEmitScriptTarget(compilerOptions) { - return compilerOptions.target || 0 /* ES3 */; - } - ts.getEmitScriptTarget = getEmitScriptTarget; - function getEmitModuleKind(compilerOptions) { - return typeof compilerOptions.module === "number" ? - compilerOptions.module : - getEmitScriptTarget(compilerOptions) === 2 /* ES6 */ ? ts.ModuleKind.ES6 : ts.ModuleKind.CommonJS; - } - ts.getEmitModuleKind = getEmitModuleKind; /** * Gets the source files that are expected to have an emit output. * @@ -8155,7 +8362,7 @@ var ts; function getSourceFilesToEmit(host, targetSourceFile) { var options = host.getCompilerOptions(); if (options.outFile || options.out) { - var moduleKind = getEmitModuleKind(options); + var moduleKind = ts.getEmitModuleKind(options); var moduleEmitEnabled = moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System; var sourceFiles = host.getSourceFiles(); // Can emit only sources that are not declaration file and are either non module code or module with --module or --target es6 specified @@ -8184,7 +8391,7 @@ var ts; * @param sourceFiles The transformed source files to emit. * @param action The action to execute. */ - function forEachTransformedEmitFile(host, sourceFiles, action) { + function forEachTransformedEmitFile(host, sourceFiles, action, emitOnlyDtsFiles) { var options = host.getCompilerOptions(); // Emit on each source file if (options.outFile || options.out) { @@ -8217,7 +8424,7 @@ var ts; } var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = !isSourceFileJavaScript(sourceFile) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; + var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (options.declaration || emitOnlyDtsFiles) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; action(jsFilePath, sourceMapFilePath, declarationFilePath, [sourceFile], /*isBundledEmit*/ false); } function onBundledEmit(host, sourceFiles) { @@ -8242,7 +8449,7 @@ var ts; * @param action The action to execute. * @param targetSourceFile An optional target source file to emit. */ - function forEachExpectedEmitFile(host, action, targetSourceFile) { + function forEachExpectedEmitFile(host, action, targetSourceFile, emitOnlyDtsFiles) { var options = host.getCompilerOptions(); // Emit on each source file if (options.outFile || options.out) { @@ -8275,12 +8482,13 @@ var ts; } } var jsFilePath = getOwnEmitOutputFilePath(sourceFile, host, extension); + var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (emitOnlyDtsFiles || options.declaration) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; var emitFileNames = { jsFilePath: jsFilePath, sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), - declarationFilePath: !isSourceFileJavaScript(sourceFile) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined + declarationFilePath: declarationFilePath }; - action(emitFileNames, [sourceFile], /*isBundledEmit*/ false); + action(emitFileNames, [sourceFile], /*isBundledEmit*/ false, emitOnlyDtsFiles); } function onBundledEmit(host) { // Can emit only sources that are not declaration file and are either non module code or module with @@ -8288,7 +8496,7 @@ var ts; var bundledSources = ts.filter(host.getSourceFiles(), function (sourceFile) { return !isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile) && (!ts.isExternalModule(sourceFile) || - !!getEmitModuleKind(options)); }); + !!ts.getEmitModuleKind(options)); }); if (bundledSources.length) { var jsFilePath = options.outFile || options.out; var emitFileNames = { @@ -8296,7 +8504,7 @@ var ts; sourceMapFilePath: getSourceMapFilePath(jsFilePath, options), declarationFilePath: options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined }; - action(emitFileNames, bundledSources, /*isBundledEmit*/ true); + action(emitFileNames, bundledSources, /*isBundledEmit*/ true, emitOnlyDtsFiles); } } } @@ -8331,15 +8539,35 @@ var ts; }); } ts.getFirstConstructorWithBody = getFirstConstructorWithBody; + /** Get the type annotaion for the value parameter. */ function getSetAccessorTypeAnnotationNode(accessor) { if (accessor && accessor.parameters.length > 0) { - var hasThis = accessor.parameters.length === 2 && - accessor.parameters[0].name.kind === 69 /* Identifier */ && - accessor.parameters[0].name.originalKeywordKind === 97 /* ThisKeyword */; + var hasThis = accessor.parameters.length === 2 && parameterIsThisKeyword(accessor.parameters[0]); return accessor.parameters[hasThis ? 1 : 0].type; } } ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode; + function getThisParameter(signature) { + if (signature.parameters.length) { + var thisParameter = signature.parameters[0]; + if (parameterIsThisKeyword(thisParameter)) { + return thisParameter; + } + } + } + ts.getThisParameter = getThisParameter; + function parameterIsThisKeyword(parameter) { + return isThisIdentifier(parameter.name); + } + ts.parameterIsThisKeyword = parameterIsThisKeyword; + function isThisIdentifier(node) { + return node && node.kind === 69 /* Identifier */ && identifierIsThisKeyword(node); + } + ts.isThisIdentifier = isThisIdentifier; + function identifierIsThisKeyword(id) { + return id.originalKeywordKind === 97 /* ThisKeyword */; + } + ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { var firstAccessor; var secondAccessor; @@ -8700,14 +8928,6 @@ var ts; return symbol && symbol.valueDeclaration && hasModifier(symbol.valueDeclaration, 512 /* Default */) ? symbol.valueDeclaration.localSymbol : undefined; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; - function hasJavaScriptFileExtension(fileName) { - return ts.forEach(ts.supportedJavascriptExtensions, function (extension) { return ts.fileExtensionIs(fileName, extension); }); - } - ts.hasJavaScriptFileExtension = hasJavaScriptFileExtension; - function hasTypeScriptFileExtension(fileName) { - return ts.forEach(ts.supportedTypeScriptExtensions, function (extension) { return ts.fileExtensionIs(fileName, extension); }); - } - ts.hasTypeScriptFileExtension = hasTypeScriptFileExtension; /** Return ".ts", ".d.ts", or ".tsx", if that is the extension. */ function tryExtractTypeScriptExtension(fileName) { return ts.find(ts.supportedTypescriptExtensionsForExtractExtension, function (extension) { return ts.fileExtensionIs(fileName, extension); }); @@ -8820,12 +9040,6 @@ var ts; return result; } ts.convertToBase64 = convertToBase64; - function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) { - return !ts.isRootedDiskPath(absoluteOrRelativePath) - ? absoluteOrRelativePath - : ts.getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, /* isAbsolutePathAnUrl */ false); - } - ts.convertToRelativePath = convertToRelativePath; var carriageReturnLineFeed = "\r\n"; var lineFeed = "\n"; function getNewLineCharacter(options) { @@ -8938,7 +9152,7 @@ var ts; * @param value The delta. */ function movePos(pos, value) { - return positionIsSynthesized(pos) ? -1 : pos + value; + return ts.positionIsSynthesized(pos) ? -1 : pos + value; } ts.movePos = movePos; /** @@ -9054,7 +9268,7 @@ var ts; } ts.positionsAreOnSameLine = positionsAreOnSameLine; function getStartPositionOfRange(range, sourceFile) { - return positionIsSynthesized(range.pos) ? -1 : ts.skipTrivia(sourceFile.text, range.pos); + return ts.positionIsSynthesized(range.pos) ? -1 : ts.skipTrivia(sourceFile.text, range.pos); } ts.getStartPositionOfRange = getStartPositionOfRange; function collectExternalModuleInfo(sourceFile, resolver) { @@ -9179,15 +9393,16 @@ var ts; return 11 /* FirstTemplateToken */ <= kind && kind <= 14 /* LastTemplateToken */; } ts.isTemplateLiteralKind = isTemplateLiteralKind; - function isTemplateLiteralFragmentKind(kind) { - return kind === 12 /* TemplateHead */ - || kind === 13 /* TemplateMiddle */ + function isTemplateHead(node) { + return node.kind === 12 /* TemplateHead */; + } + ts.isTemplateHead = isTemplateHead; + function isTemplateMiddleOrTemplateTail(node) { + var kind = node.kind; + return kind === 13 /* TemplateMiddle */ || kind === 14 /* TemplateTail */; } - function isTemplateLiteralFragment(node) { - return isTemplateLiteralFragmentKind(node.kind); - } - ts.isTemplateLiteralFragment = isTemplateLiteralFragment; + ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; // Identifiers function isIdentifier(node) { return node.kind === 69 /* Identifier */; @@ -9340,12 +9555,12 @@ var ts; return node.kind === 174 /* CallExpression */; } ts.isCallExpression = isCallExpression; - function isTemplate(node) { + function isTemplateLiteral(node) { var kind = node.kind; return kind === 189 /* TemplateExpression */ || kind === 11 /* NoSubstitutionTemplateLiteral */; } - ts.isTemplate = isTemplate; + ts.isTemplateLiteral = isTemplateLiteral; function isSpreadElementExpression(node) { return node.kind === 191 /* SpreadElementExpression */; } @@ -9688,7 +9903,6 @@ var ts; } ts.isWatchSet = isWatchSet; })(ts || (ts = {})); -var ts; (function (ts) { function getDefaultLibFileName(options) { return options.target === 2 /* ES6 */ ? "lib.es6.d.ts" : "lib.d.ts"; @@ -10029,7 +10243,7 @@ var ts; // the original node. We also need to exclude specific properties and only include own- // properties (to skip members already defined on the shared prototype). var clone = createNode(node.kind, /*location*/ undefined, node.flags); - clone.original = node; + setOriginalNode(clone, node); for (var key in node) { if (clone.hasOwnProperty(key) || !node.hasOwnProperty(key)) { continue; @@ -10064,7 +10278,7 @@ var ts; node.text = value; return node; } - else { + else if (value) { var node = createNode(9 /* StringLiteral */, location, /*flags*/ undefined); node.textSourceNode = value; node.text = value.text; @@ -10364,7 +10578,7 @@ var ts; function createPropertyAccess(expression, name, location, flags) { var node = createNode(172 /* PropertyAccessExpression */, location, flags); node.expression = parenthesizeForAccess(expression); - node.emitFlags = 1048576 /* NoIndentation */; + (node.emitNode || (node.emitNode = {})).flags |= 1048576 /* NoIndentation */; node.name = typeof name === "string" ? createIdentifier(name) : name; return node; } @@ -10373,7 +10587,7 @@ var ts; if (node.expression !== expression || node.name !== name) { var propertyAccess = createPropertyAccess(expression, name, /*location*/ node, node.flags); // Because we are updating existed propertyAccess we want to inherit its emitFlags instead of using default from createPropertyAccess - propertyAccess.emitFlags = node.emitFlags; + (propertyAccess.emitNode || (propertyAccess.emitNode = {})).flags = getEmitFlags(node); return updateNode(propertyAccess, node); } return node; @@ -10477,7 +10691,7 @@ var ts; node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; node.parameters = createNodeArray(parameters); node.type = type; - node.equalsGreaterThanToken = equalsGreaterThanToken || createNode(34 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(34 /* EqualsGreaterThanToken */); node.body = parenthesizeConciseBody(body); return node; } @@ -10570,7 +10784,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right, location) { - var operatorToken = typeof operator === "number" ? createSynthesizedNode(operator) : operator; + var operatorToken = typeof operator === "number" ? createToken(operator) : operator; var operatorKind = operatorToken.kind; var node = createNode(187 /* BinaryExpression */, location); node.left = parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); @@ -11492,7 +11706,7 @@ var ts; } else { var expression = ts.isIdentifier(memberName) ? createPropertyAccess(target, memberName, location) : createElementAccess(target, memberName, location); - expression.emitFlags |= 2048 /* NoNestedSourceMaps */; + (expression.emitNode || (expression.emitNode = {})).flags |= 2048 /* NoNestedSourceMaps */; return expression; } } @@ -11500,7 +11714,7 @@ var ts; function createRestParameter(name) { return createParameterDeclaration( /*decorators*/ undefined, - /*modifiers*/ undefined, createSynthesizedNode(22 /* DotDotDotToken */), name, + /*modifiers*/ undefined, createToken(22 /* DotDotDotToken */), name, /*questionToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined); @@ -11630,13 +11844,13 @@ var ts; } ts.createDecorateHelper = createDecorateHelper; function createAwaiterHelper(externalHelpersModuleName, hasLexicalArguments, promiseConstructor, body) { - var generatorFunc = createFunctionExpression(createNode(37 /* AsteriskToken */), + var generatorFunc = createFunctionExpression(createToken(37 /* AsteriskToken */), /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ [], /*type*/ undefined, body); // Mark this node as originally an async function - generatorFunc.emitFlags |= 2097152 /* AsyncFunctionBody */; + (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 2097152 /* AsyncFunctionBody */; return createCall(createHelperName(externalHelpersModuleName, "__awaiter"), /*typeArguments*/ undefined, [ createThis(), @@ -11953,7 +12167,7 @@ var ts; target.push(startOnNewLine(createStatement(createLiteral("use strict")))); foundUseStrict = true; } - if (statement.emitFlags & 8388608 /* CustomPrologue */) { + if (getEmitFlags(statement) & 8388608 /* CustomPrologue */) { target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); } else { @@ -11965,6 +12179,34 @@ var ts; return statementOffset; } ts.addPrologueDirectives = addPrologueDirectives; + /** + * Ensures "use strict" directive is added + * + * @param node source file + */ + function ensureUseStrict(node) { + var foundUseStrict = false; + for (var _i = 0, _a = node.statements; _i < _a.length; _i++) { + var statement = _a[_i]; + if (ts.isPrologueDirective(statement)) { + if (isUseStrictPrologue(statement)) { + foundUseStrict = true; + break; + } + } + else { + break; + } + } + if (!foundUseStrict) { + var statements = []; + statements.push(startOnNewLine(createStatement(createLiteral("use strict")))); + // add "use strict" as the first statement + return updateSourceFileNode(node, statements.concat(node.statements)); + } + return node; + } + ts.ensureUseStrict = ensureUseStrict; /** * Wraps the operand to a BinaryExpression in parentheses if they are needed to preserve the intended * order of operations. @@ -12323,17 +12565,180 @@ var ts; function setOriginalNode(node, original) { node.original = original; if (original) { - var emitFlags = original.emitFlags, commentRange = original.commentRange, sourceMapRange = original.sourceMapRange; - if (emitFlags) - node.emitFlags = emitFlags; - if (commentRange) - node.commentRange = commentRange; - if (sourceMapRange) - node.sourceMapRange = sourceMapRange; + var emitNode = original.emitNode; + if (emitNode) + node.emitNode = mergeEmitNode(emitNode, node.emitNode); } return node; } ts.setOriginalNode = setOriginalNode; + function mergeEmitNode(sourceEmitNode, destEmitNode) { + var flags = sourceEmitNode.flags, commentRange = sourceEmitNode.commentRange, sourceMapRange = sourceEmitNode.sourceMapRange, tokenSourceMapRanges = sourceEmitNode.tokenSourceMapRanges; + if (!destEmitNode && (flags || commentRange || sourceMapRange || tokenSourceMapRanges)) + destEmitNode = {}; + if (flags) + destEmitNode.flags = flags; + if (commentRange) + destEmitNode.commentRange = commentRange; + if (sourceMapRange) + destEmitNode.sourceMapRange = sourceMapRange; + if (tokenSourceMapRanges) + destEmitNode.tokenSourceMapRanges = mergeTokenSourceMapRanges(tokenSourceMapRanges, destEmitNode.tokenSourceMapRanges); + return destEmitNode; + } + function mergeTokenSourceMapRanges(sourceRanges, destRanges) { + if (!destRanges) + destRanges = ts.createMap(); + ts.copyProperties(sourceRanges, destRanges); + return destRanges; + } + /** + * Clears any EmitNode entries from parse-tree nodes. + * @param sourceFile A source file. + */ + function disposeEmitNodes(sourceFile) { + // During transformation we may need to annotate a parse tree node with transient + // transformation properties. As parse tree nodes live longer than transformation + // nodes, we need to make sure we reclaim any memory allocated for custom ranges + // from these nodes to ensure we do not hold onto entire subtrees just for position + // information. We also need to reset these nodes to a pre-transformation state + // for incremental parsing scenarios so that we do not impact later emit. + sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(sourceFile)); + var emitNode = sourceFile && sourceFile.emitNode; + var annotatedNodes = emitNode && emitNode.annotatedNodes; + if (annotatedNodes) { + for (var _i = 0, annotatedNodes_1 = annotatedNodes; _i < annotatedNodes_1.length; _i++) { + var node = annotatedNodes_1[_i]; + node.emitNode = undefined; + } + } + } + ts.disposeEmitNodes = disposeEmitNodes; + /** + * Associates a node with the current transformation, initializing + * various transient transformation properties. + * + * @param node The node. + */ + function getOrCreateEmitNode(node) { + if (!node.emitNode) { + if (ts.isParseTreeNode(node)) { + // To avoid holding onto transformation artifacts, we keep track of any + // parse tree node we are annotating. This allows us to clean them up after + // all transformations have completed. + if (node.kind === 256 /* SourceFile */) { + return node.emitNode = { annotatedNodes: [node] }; + } + var sourceFile = ts.getSourceFileOfNode(node); + getOrCreateEmitNode(sourceFile).annotatedNodes.push(node); + } + node.emitNode = {}; + } + return node.emitNode; + } + /** + * Gets flags that control emit behavior of a node. + * + * @param node The node. + */ + function getEmitFlags(node) { + var emitNode = node.emitNode; + return emitNode && emitNode.flags; + } + ts.getEmitFlags = getEmitFlags; + /** + * Sets flags that control emit behavior of a node. + * + * @param node The node. + * @param emitFlags The NodeEmitFlags for the node. + */ + function setEmitFlags(node, emitFlags) { + getOrCreateEmitNode(node).flags = emitFlags; + return node; + } + ts.setEmitFlags = setEmitFlags; + /** + * Sets a custom text range to use when emitting source maps. + * + * @param node The node. + * @param range The text range. + */ + function setSourceMapRange(node, range) { + getOrCreateEmitNode(node).sourceMapRange = range; + return node; + } + ts.setSourceMapRange = setSourceMapRange; + /** + * Sets the TextRange to use for source maps for a token of a node. + * + * @param node The node. + * @param token The token. + * @param range The text range. + */ + function setTokenSourceMapRange(node, token, range) { + var emitNode = getOrCreateEmitNode(node); + var tokenSourceMapRanges = emitNode.tokenSourceMapRanges || (emitNode.tokenSourceMapRanges = ts.createMap()); + tokenSourceMapRanges[token] = range; + return node; + } + ts.setTokenSourceMapRange = setTokenSourceMapRange; + /** + * Sets a custom text range to use when emitting comments. + */ + function setCommentRange(node, range) { + getOrCreateEmitNode(node).commentRange = range; + return node; + } + ts.setCommentRange = setCommentRange; + /** + * Gets a custom text range to use when emitting comments. + * + * @param node The node. + */ + function getCommentRange(node) { + var emitNode = node.emitNode; + return (emitNode && emitNode.commentRange) || node; + } + ts.getCommentRange = getCommentRange; + /** + * Gets a custom text range to use when emitting source maps. + * + * @param node The node. + */ + function getSourceMapRange(node) { + var emitNode = node.emitNode; + return (emitNode && emitNode.sourceMapRange) || node; + } + ts.getSourceMapRange = getSourceMapRange; + /** + * Gets the TextRange to use for source maps for a token of a node. + * + * @param node The node. + * @param token The token. + */ + function getTokenSourceMapRange(node, token) { + var emitNode = node.emitNode; + var tokenSourceMapRanges = emitNode && emitNode.tokenSourceMapRanges; + return tokenSourceMapRanges && tokenSourceMapRanges[token]; + } + ts.getTokenSourceMapRange = getTokenSourceMapRange; + /** + * Gets the constant value to emit for an expression. + */ + function getConstantValue(node) { + var emitNode = node.emitNode; + return emitNode && emitNode.constantValue; + } + ts.getConstantValue = getConstantValue; + /** + * Sets the constant value to emit for an expression. + */ + function setConstantValue(node, value) { + var emitNode = getOrCreateEmitNode(node); + emitNode.constantValue = value; + return node; + } + ts.setConstantValue = setConstantValue; function setTextRange(node, location) { if (location) { node.pos = location.pos; @@ -12376,13 +12781,13 @@ var ts; } ts.getLocalNameForExternalImport = getLocalNameForExternalImport; /** - * Get the name of a target module from an import/export declaration as should be written in the emitted output. - * The emitted output name can be different from the input if: - * 1. The module has a /// - * 2. --out or --outFile is used, making the name relative to the rootDir - * 3- The containing SourceFile has an entry in renamedDependencies for the import as requested by some module loaders (e.g. System). - * Otherwise, a new StringLiteral node representing the module name will be returned. - */ + * Get the name of a target module from an import/export declaration as should be written in the emitted output. + * The emitted output name can be different from the input if: + * 1. The module has a /// + * 2. --out or --outFile is used, making the name relative to the rootDir + * 3- The containing SourceFile has an entry in renamedDependencies for the import as requested by some module loaders (e.g. System). + * Otherwise, a new StringLiteral node representing the module name will be returned. + */ function getExternalModuleNameLiteral(importNode, sourceFile, host, resolver, compilerOptions) { var moduleName = ts.getExternalModuleName(importNode); if (moduleName.kind === 9 /* StringLiteral */) { @@ -13683,8 +14088,8 @@ var ts; // Tokens other than ')' and ']' (the latter for index signatures) are here for better error recovery return token() === 18 /* CloseParenToken */ || token() === 20 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; case 18 /* TypeArguments */: - // Tokens other than '>' are here for better error recovery - return token() === 27 /* GreaterThanToken */ || token() === 17 /* OpenParenToken */; + // All other tokens should cause the type-argument to terminate except comma token + return token() !== 24 /* CommaToken */; case 20 /* HeritageClauses */: return token() === 15 /* OpenBraceToken */ || token() === 16 /* CloseBraceToken */; case 13 /* JsxAttributes */: @@ -14135,7 +14540,7 @@ var ts; } function parseTemplateExpression() { var template = createNode(189 /* TemplateExpression */); - template.head = parseTemplateLiteralFragment(); + template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 12 /* TemplateHead */, "Template head has wrong token kind"); var templateSpans = createNodeArray(); do { @@ -14151,7 +14556,7 @@ var ts; var literal; if (token() === 16 /* CloseBraceToken */) { reScanTemplateToken(); - literal = parseTemplateLiteralFragment(); + literal = parseTemplateMiddleOrTemplateTail(); } else { literal = parseExpectedToken(14 /* TemplateTail */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(16 /* CloseBraceToken */)); @@ -14162,8 +14567,15 @@ var ts; function parseLiteralNode(internName) { return parseLiteralLikeNode(token(), internName); } - function parseTemplateLiteralFragment() { - return parseLiteralLikeNode(token(), /*internName*/ false); + function parseTemplateHead() { + var fragment = parseLiteralLikeNode(token(), /*internName*/ false); + ts.Debug.assert(fragment.kind === 12 /* TemplateHead */, "Template head has wrong token kind"); + return fragment; + } + function parseTemplateMiddleOrTemplateTail() { + var fragment = parseLiteralLikeNode(token(), /*internName*/ false); + ts.Debug.assert(fragment.kind === 13 /* TemplateMiddle */ || fragment.kind === 14 /* TemplateTail */, "Template fragment has wrong token kind"); + return fragment; } function parseLiteralLikeNode(kind, internName) { var node = createNode(kind); @@ -17144,7 +17556,7 @@ var ts; parseExpected(56 /* EqualsToken */); node.type = parseType(); parseSemicolon(); - return finishNode(node); + return addJSDocComment(finishNode(node)); } // In an ambient declaration, the grammar only allows integer literals as initializers. // In a non-ambient declaration, the grammar allows uninitialized members only in a @@ -17702,6 +18114,7 @@ var ts; var parameter = createNode(142 /* Parameter */); parameter.type = parseJSDocType(); if (parseOptional(56 /* EqualsToken */)) { + // TODO(rbuckton): Can this be changed to SyntaxKind.QuestionToken? parameter.questionToken = createNode(56 /* EqualsToken */); } return finishNode(parameter); @@ -18895,6 +19308,7 @@ var ts; ContainerFlags[ContainerFlags["IsFunctionExpression"] = 16] = "IsFunctionExpression"; ContainerFlags[ContainerFlags["HasLocals"] = 32] = "HasLocals"; ContainerFlags[ContainerFlags["IsInterface"] = 64] = "IsInterface"; + ContainerFlags[ContainerFlags["IsObjectLiteralOrClassExpressionMethod"] = 128] = "IsObjectLiteralOrClassExpressionMethod"; })(ContainerFlags || (ContainerFlags = {})); var binder = createBinder(); function bindSourceFile(file, options) { @@ -18927,7 +19341,8 @@ var ts; var emitFlags; // 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). + // not depending on if we see "use strict" in certain places or if we hit a class/namespace + // or if compiler options contain alwaysStrict. var inStrictMode; var symbolCount = 0; var Symbol; @@ -18941,7 +19356,7 @@ var ts; file = f; options = opts; languageVersion = ts.getEmitScriptTarget(options); - inStrictMode = !!file.externalModuleIndicator; + inStrictMode = bindInStrictMode(file, opts); classifiableNames = ts.createMap(); symbolCount = 0; skipTransformFlagAggregation = ts.isDeclarationFile(file); @@ -18971,6 +19386,15 @@ var ts; subtreeTransformFlags = 0 /* None */; } return bindSourceFile; + function bindInStrictMode(file, opts) { + if (opts.alwaysStrict && !ts.isDeclarationFile(file)) { + // bind in strict mode source files with alwaysStrict option + return true; + } + else { + return !!file.externalModuleIndicator; + } + } function createSymbol(flags, name) { symbolCount++; return new Symbol(flags, name); @@ -19134,11 +19558,24 @@ var ts; var message_1 = symbol.flags & 2 /* BlockScopedVariable */ ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; - ts.forEach(symbol.declarations, function (declaration) { - if (ts.hasModifier(declaration, 512 /* Default */)) { + if (symbol.declarations && symbol.declarations.length) { + // If the current node is a default export of some sort, then check if + // there are any other default exports that we need to error on. + // We'll know whether we have other default exports depending on if `symbol` already has a declaration list set. + if (isDefaultExport) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } - }); + else { + // This is to properly report an error in the case "export default { }" is after export default of class declaration or function declaration. + // Error on multiple export default in the following case: + // 1. multiple export default of class declaration or function declaration by checking NodeFlags.Default + // 2. multiple export default of export assignment. This one doesn't have NodeFlags.Default on (as export default doesn't considered as modifiers) + if (symbol.declarations && symbol.declarations.length && + (isDefaultExport || (node.kind === 235 /* ExportAssignment */ && !node.isExportEquals))) { + message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; + } + } + } ts.forEach(symbol.declarations, function (declaration) { file.bindDiagnostics.push(ts.createDiagnosticForNode(declaration.name || declaration, message_1, getDisplayName(declaration))); }); @@ -19243,7 +19680,7 @@ var ts; } else { currentFlow = { flags: 2 /* Start */ }; - if (containerFlags & 16 /* IsFunctionExpression */) { + if (containerFlags & (16 /* IsFunctionExpression */ | 128 /* IsObjectLiteralOrClassExpressionMethod */)) { currentFlow.container = node; } currentReturnTarget = undefined; @@ -19705,7 +20142,11 @@ var ts; currentFlow = preTryFlow; bind(node.finallyBlock); } - currentFlow = finishFlowLabel(postFinallyLabel); + // if try statement has finally block and flow after finally block is unreachable - keep it + // otherwise use whatever flow was accumulated at postFinallyLabel + if (!node.finallyBlock || !(currentFlow.flags & 1 /* Unreachable */)) { + currentFlow = finishFlowLabel(postFinallyLabel); + } } function bindSwitchStatement(node) { var postSwitchLabel = createBranchLabel(); @@ -19840,7 +20281,7 @@ var ts; } else { ts.forEachChild(node, bind); - if (node.operator === 57 /* PlusEqualsToken */ || node.operator === 42 /* MinusMinusToken */) { + if (node.operator === 41 /* PlusPlusToken */ || node.operator === 42 /* MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } @@ -19942,9 +20383,12 @@ var ts; return 1 /* IsContainer */ | 32 /* HasLocals */; case 256 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; + case 147 /* MethodDeclaration */: + if (ts.isObjectLiteralOrClassExpressionMethod(node)) { + return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; + } case 148 /* Constructor */: case 220 /* FunctionDeclaration */: - case 147 /* MethodDeclaration */: case 146 /* MethodSignature */: case 149 /* GetAccessor */: case 150 /* SetAccessor */: @@ -20588,10 +21032,13 @@ var ts; bindAnonymousDeclaration(node, 8388608 /* Alias */, getDeclarationName(node)); } else { + // An export default clause with an expression exports a value + // We want to exclude both class and function here, this is necessary to issue an error when there are both + // default export-assignment and default export function and class declaration. var flags = node.kind === 235 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) ? 8388608 /* Alias */ : 4 /* Property */; - declareSymbol(container.symbol.exports, container.symbol, node, flags, 0 /* PropertyExcludes */ | 8388608 /* AliasExcludes */); + declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 /* Property */ | 8388608 /* AliasExcludes */ | 32 /* Class */ | 16 /* Function */); } } function bindNamespaceExportDeclaration(node) { @@ -20829,6 +21276,9 @@ var ts; emitFlags |= 2048 /* HasDecorators */; } } + if (currentFlow && ts.isObjectLiteralOrClassExpressionMethod(node)) { + node.flowNode = currentFlow; + } return ts.hasDynamicName(node) ? bindAnonymousDeclaration(node, symbolFlags, "__computed") : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); @@ -20994,8 +21444,7 @@ var ts; transformFlags |= 3 /* AssertTypeScript */; } // If the parameter's name is 'this', then it is TypeScript syntax. - if (subtreeFlags & 2048 /* ContainsDecorators */ - || (name && ts.isIdentifier(name) && name.originalKeywordKind === 97 /* ThisKeyword */)) { + if (subtreeFlags & 2048 /* ContainsDecorators */ || ts.isThisIdentifier(name)) { transformFlags |= 3 /* AssertTypeScript */; } // If a parameter has an accessibility modifier, then it is TypeScript syntax. @@ -21128,7 +21577,7 @@ var ts; transformFlags |= 3 /* AssertTypeScript */; } // Currently, we only support generators that were originally async function bodies. - if (asteriskToken && node.emitFlags & 2097152 /* AsyncFunctionBody */) { + if (asteriskToken && ts.getEmitFlags(node) & 2097152 /* AsyncFunctionBody */) { transformFlags |= 1536 /* AssertGenerator */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; @@ -21190,7 +21639,7 @@ var ts; // down-level generator. // Currently we do not support transforming any other generator fucntions // down level. - if (asteriskToken && node.emitFlags & 2097152 /* AsyncFunctionBody */) { + if (asteriskToken && ts.getEmitFlags(node) & 2097152 /* AsyncFunctionBody */) { transformFlags |= 1536 /* AssertGenerator */; } } @@ -21216,7 +21665,7 @@ var ts; // down-level generator. // Currently we do not support transforming any other generator fucntions // down level. - if (asteriskToken && node.emitFlags & 2097152 /* AsyncFunctionBody */) { + if (asteriskToken && ts.getEmitFlags(node) & 2097152 /* AsyncFunctionBody */) { transformFlags |= 1536 /* AssertGenerator */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; @@ -21500,6 +21949,677 @@ var ts; return transformFlags & ~excludeFlags; } })(ts || (ts = {})); +/// +/// +var ts; +(function (ts) { + function trace(host, message) { + host.trace(ts.formatMessage.apply(undefined, arguments)); + } + ts.trace = trace; + /* @internal */ + function isTraceEnabled(compilerOptions, host) { + return compilerOptions.traceResolution && host.trace !== undefined; + } + ts.isTraceEnabled = isTraceEnabled; + /* @internal */ + function createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations) { + return { resolvedModule: resolvedFileName ? { resolvedFileName: resolvedFileName, isExternalLibraryImport: isExternalLibraryImport } : undefined, failedLookupLocations: failedLookupLocations }; + } + ts.createResolvedModule = createResolvedModule; + function moduleHasNonRelativeName(moduleName) { + return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); + } + function tryReadTypesSection(packageJsonPath, baseDirectory, state) { + var jsonContent = readJson(packageJsonPath, state.host); + function tryReadFromField(fieldName) { + if (ts.hasProperty(jsonContent, fieldName)) { + var typesFile = jsonContent[fieldName]; + if (typeof typesFile === "string") { + var typesFilePath_1 = ts.normalizePath(ts.combinePaths(baseDirectory, typesFile)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath_1); + } + return typesFilePath_1; + } + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof typesFile); + } + } + } + } + var typesFilePath = tryReadFromField("typings") || tryReadFromField("types"); + if (typesFilePath) { + return typesFilePath; + } + // Use the main module for inferring types if no types package specified and the allowJs is set + if (state.compilerOptions.allowJs && jsonContent.main && typeof jsonContent.main === "string") { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0, jsonContent.main); + } + var mainFilePath = ts.normalizePath(ts.combinePaths(baseDirectory, jsonContent.main)); + return mainFilePath; + } + return undefined; + } + function readJson(path, host) { + try { + var jsonText = host.readFile(path); + return jsonText ? JSON.parse(jsonText) : {}; + } + catch (e) { + // gracefully handle if readFile fails or returns not JSON + return {}; + } + } + var typeReferenceExtensions = [".d.ts"]; + function getEffectiveTypeRoots(options, host) { + if (options.typeRoots) { + return options.typeRoots; + } + var currentDirectory; + if (options.configFilePath) { + currentDirectory = ts.getDirectoryPath(options.configFilePath); + } + else if (host.getCurrentDirectory) { + currentDirectory = host.getCurrentDirectory(); + } + return currentDirectory !== undefined && getDefaultTypeRoots(currentDirectory, host); + } + ts.getEffectiveTypeRoots = getEffectiveTypeRoots; + /** + * Returns the path to every node_modules/@types directory from some ancestor directory. + * Returns undefined if there are none. + */ + function getDefaultTypeRoots(currentDirectory, host) { + if (!host.directoryExists) { + return [ts.combinePaths(currentDirectory, nodeModulesAtTypes)]; + } + var typeRoots; + while (true) { + var atTypes = ts.combinePaths(currentDirectory, nodeModulesAtTypes); + if (host.directoryExists(atTypes)) { + (typeRoots || (typeRoots = [])).push(atTypes); + } + var parent_7 = ts.getDirectoryPath(currentDirectory); + if (parent_7 === currentDirectory) { + break; + } + currentDirectory = parent_7; + } + return typeRoots; + } + var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types"); + /** + * @param {string | undefined} containingFile - file that contains type reference directive, can be undefined if containing file is unknown. + * This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups + * is assumed to be the same as root directory of the project. + */ + function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host) { + var traceEnabled = isTraceEnabled(options, host); + var moduleResolutionState = { + compilerOptions: options, + host: host, + skipTsx: true, + traceEnabled: traceEnabled + }; + var typeRoots = getEffectiveTypeRoots(options, host); + if (traceEnabled) { + if (containingFile === undefined) { + if (typeRoots === undefined) { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set, typeReferenceDirectiveName); + } + else { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1, typeReferenceDirectiveName, typeRoots); + } + } + else { + if (typeRoots === undefined) { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set, typeReferenceDirectiveName, containingFile); + } + else { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, typeRoots); + } + } + } + var failedLookupLocations = []; + // Check primary library paths + if (typeRoots && typeRoots.length) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", ")); + } + var primarySearchPaths = typeRoots; + for (var _i = 0, primarySearchPaths_1 = primarySearchPaths; _i < primarySearchPaths_1.length; _i++) { + var typeRoot = primarySearchPaths_1[_i]; + var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); + var candidateDirectory = ts.getDirectoryPath(candidate); + var resolvedFile_1 = loadNodeModuleFromDirectory(typeReferenceExtensions, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState); + if (resolvedFile_1) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile_1, true); + } + return { + resolvedTypeReferenceDirective: { primary: true, resolvedFileName: resolvedFile_1 }, + failedLookupLocations: failedLookupLocations + }; + } + } + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths); + } + } + var resolvedFile; + var initialLocationForSecondaryLookup; + if (containingFile) { + initialLocationForSecondaryLookup = ts.getDirectoryPath(containingFile); + } + if (initialLocationForSecondaryLookup !== undefined) { + // check secondary locations + if (traceEnabled) { + trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); + } + resolvedFile = loadModuleFromNodeModules(typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, /*checkOneLevel*/ false); + if (traceEnabled) { + if (resolvedFile) { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile, false); + } + else { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); + } + } + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder); + } + } + return { + resolvedTypeReferenceDirective: resolvedFile + ? { primary: false, resolvedFileName: resolvedFile } + : undefined, + failedLookupLocations: failedLookupLocations + }; + } + ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective; + /** + * Given a set of options, returns the set of type directive names + * that should be included for this program automatically. + * This list could either come from the config file, + * or from enumerating the types root + initial secondary types lookup location. + * More type directives might appear in the program later as a result of loading actual source files; + * this list is only the set of defaults that are implicitly included. + */ + function getAutomaticTypeDirectiveNames(options, host) { + // Use explicit type list from tsconfig.json + if (options.types) { + return options.types; + } + // Walk the primary type lookup locations + var result = []; + if (host.directoryExists && host.getDirectories) { + var typeRoots = getEffectiveTypeRoots(options, host); + if (typeRoots) { + for (var _i = 0, typeRoots_1 = typeRoots; _i < typeRoots_1.length; _i++) { + var root = typeRoots_1[_i]; + if (host.directoryExists(root)) { + for (var _a = 0, _b = host.getDirectories(root); _a < _b.length; _a++) { + var typeDirectivePath = _b[_a]; + var normalized = ts.normalizePath(typeDirectivePath); + var packageJsonPath = pathToPackageJson(ts.combinePaths(root, normalized)); + // tslint:disable-next-line:no-null-keyword + var isNotNeededPackage = host.fileExists(packageJsonPath) && readJson(packageJsonPath, host).typings === null; + if (!isNotNeededPackage) { + // Return just the type directive names + result.push(ts.getBaseFileName(normalized)); + } + } + } + } + } + } + return result; + } + ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; + function resolveModuleName(moduleName, containingFile, compilerOptions, host) { + var traceEnabled = isTraceEnabled(compilerOptions, host); + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); + } + var moduleResolution = compilerOptions.moduleResolution; + if (moduleResolution === undefined) { + moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + if (traceEnabled) { + trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + else { + if (traceEnabled) { + trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); + } + } + var result; + switch (moduleResolution) { + case ts.ModuleResolutionKind.NodeJs: + result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host); + break; + case ts.ModuleResolutionKind.Classic: + result = classicNameResolver(moduleName, containingFile, compilerOptions, host); + break; + } + if (traceEnabled) { + if (result.resolvedModule) { + trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.resolvedModule.resolvedFileName); + } + else { + trace(host, ts.Diagnostics.Module_name_0_was_not_resolved, moduleName); + } + } + return result; + } + ts.resolveModuleName = resolveModuleName; + /** + * Any module resolution kind can be augmented with optional settings: 'baseUrl', 'paths' and 'rootDirs' - they are used to + * mitigate differences between design time structure of the project and its runtime counterpart so the same import name + * can be resolved successfully by TypeScript compiler and runtime module loader. + * If these settings are set then loading procedure will try to use them to resolve module name and it can of failure it will + * fallback to standard resolution routine. + * + * - baseUrl - this setting controls how non-relative module names are resolved. If this setting is specified then non-relative + * names will be resolved relative to baseUrl: i.e. if baseUrl is '/a/b' then candidate location to resolve module name 'c/d' will + * be '/a/b/c/d' + * - paths - this setting can only be used when baseUrl is specified. allows to tune how non-relative module names + * will be resolved based on the content of the module name. + * Structure of 'paths' compiler options + * 'paths': { + * pattern-1: [...substitutions], + * pattern-2: [...substitutions], + * ... + * pattern-n: [...substitutions] + * } + * Pattern here is a string that can contain zero or one '*' character. During module resolution module name will be matched against + * all patterns in the list. Matching for patterns that don't contain '*' means that module name must be equal to pattern respecting the case. + * If pattern contains '*' then to match pattern "*" module name must start with the and end with . + * denotes part of the module name between and . + * If module name can be matches with multiple patterns then pattern with the longest prefix will be picked. + * After selecting pattern we'll use list of substitutions to get candidate locations of the module and the try to load module + * from the candidate location. + * Substitution is a string that can contain zero or one '*'. To get candidate location from substitution we'll pick every + * substitution in the list and replace '*' with string. If candidate location is not rooted it + * will be converted to absolute using baseUrl. + * For example: + * baseUrl: /a/b/c + * "paths": { + * // match all module names + * "*": [ + * "*", // use matched name as is, + * // will be looked as /a/b/c/ + * + * "folder1/*" // substitution will convert matched name to 'folder1/', + * // since it is not rooted then final candidate location will be /a/b/c/folder1/ + * ], + * // match module names that start with 'components/' + * "components/*": [ "/root/components/*" ] // substitution will convert /components/folder1/ to '/root/components/folder1/', + * // it is rooted so it will be final candidate location + * } + * + * 'rootDirs' allows the project to be spreaded across multiple locations and resolve modules with relative names as if + * they were in the same location. For example lets say there are two files + * '/local/src/content/file1.ts' + * '/shared/components/contracts/src/content/protocols/file2.ts' + * After bundling content of '/shared/components/contracts/src' will be merged with '/local/src' so + * if file1 has the following import 'import {x} from "./protocols/file2"' it will be resolved successfully in runtime. + * 'rootDirs' provides the way to tell compiler that in order to get the whole project it should behave as if content of all + * root dirs were merged together. + * I.e. for the example above 'rootDirs' will have two entries: [ '/local/src', '/shared/components/contracts/src' ]. + * Compiler will first convert './protocols/file2' into absolute path relative to the location of containing file: + * '/local/src/content/protocols/file2' and try to load it - failure. + * Then it will search 'rootDirs' looking for a longest matching prefix of this absolute path and if such prefix is found - absolute path will + * be converted to a path relative to found rootDir entry './content/protocols/file2' (*). As a last step compiler will check all remaining + * entries in 'rootDirs', use them to build absolute path out of (*) and try to resolve module from this location. + */ + function tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { + if (moduleHasNonRelativeName(moduleName)) { + return tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state); + } + else { + return tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state); + } + } + function tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { + if (!state.compilerOptions.rootDirs) { + return undefined; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0, moduleName); + } + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var matchedRootDir; + var matchedNormalizedPrefix; + for (var _i = 0, _a = state.compilerOptions.rootDirs; _i < _a.length; _i++) { + var rootDir = _a[_i]; + // rootDirs are expected to be absolute + // in case of tsconfig.json this will happen automatically - compiler will expand relative names + // using location of tsconfig.json as base location + var normalizedRoot = ts.normalizePath(rootDir); + if (!ts.endsWith(normalizedRoot, ts.directorySeparator)) { + normalizedRoot += ts.directorySeparator; + } + var isLongestMatchingPrefix = ts.startsWith(candidate, normalizedRoot) && + (matchedNormalizedPrefix === undefined || matchedNormalizedPrefix.length < normalizedRoot.length); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Checking_if_0_is_the_longest_matching_prefix_for_1_2, normalizedRoot, candidate, isLongestMatchingPrefix); + } + if (isLongestMatchingPrefix) { + matchedNormalizedPrefix = normalizedRoot; + matchedRootDir = rootDir; + } + } + if (matchedNormalizedPrefix) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Longest_matching_prefix_for_0_is_1, candidate, matchedNormalizedPrefix); + } + var suffix = candidate.substr(matchedNormalizedPrefix.length); + // first - try to load from a initial location + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, matchedNormalizedPrefix, candidate); + } + var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(containingDirectory, state.host), state); + if (resolvedFileName) { + return resolvedFileName; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Trying_other_entries_in_rootDirs); + } + // then try to resolve using remaining entries in rootDirs + for (var _b = 0, _c = state.compilerOptions.rootDirs; _b < _c.length; _b++) { + var rootDir = _c[_b]; + if (rootDir === matchedRootDir) { + // skip the initially matched entry + continue; + } + var candidate_1 = ts.combinePaths(ts.normalizePath(rootDir), suffix); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, rootDir, candidate_1); + } + var baseDirectory = ts.getDirectoryPath(candidate_1); + var resolvedFileName_1 = loader(candidate_1, supportedExtensions, failedLookupLocations, !directoryProbablyExists(baseDirectory, state.host), state); + if (resolvedFileName_1) { + return resolvedFileName_1; + } + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Module_resolution_using_rootDirs_has_failed); + } + } + return undefined; + } + function tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state) { + if (!state.compilerOptions.baseUrl) { + return undefined; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, state.compilerOptions.baseUrl, moduleName); + } + // string is for exact match + var matchedPattern = undefined; + if (state.compilerOptions.paths) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); + } + matchedPattern = ts.matchPatternOrExact(ts.getOwnKeys(state.compilerOptions.paths), moduleName); + } + if (matchedPattern) { + var matchedStar = typeof matchedPattern === "string" ? undefined : ts.matchedText(matchedPattern, moduleName); + var matchedPatternText = typeof matchedPattern === "string" ? matchedPattern : ts.patternText(matchedPattern); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPatternText); + } + for (var _i = 0, _a = state.compilerOptions.paths[matchedPatternText]; _i < _a.length; _i++) { + var subst = _a[_i]; + var path = matchedStar ? subst.replace("*", matchedStar) : subst; + var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, path)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path); + } + var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + if (resolvedFileName) { + return resolvedFileName; + } + } + return undefined; + } + else { + var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, moduleName)); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Resolving_module_name_0_relative_to_base_url_1_2, moduleName, state.compilerOptions.baseUrl, candidate); + } + return loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + } + } + function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host) { + var containingDirectory = ts.getDirectoryPath(containingFile); + var supportedExtensions = ts.getSupportedExtensions(compilerOptions); + var traceEnabled = isTraceEnabled(compilerOptions, host); + var failedLookupLocations = []; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: false }; + var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, supportedExtensions, state); + var isExternalLibraryImport = false; + if (!resolvedFileName) { + if (moduleHasNonRelativeName(moduleName)) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder, moduleName); + } + resolvedFileName = loadModuleFromNodeModules(moduleName, containingDirectory, failedLookupLocations, state, /*checkOneLevel*/ false); + isExternalLibraryImport = resolvedFileName !== undefined; + } + else { + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + resolvedFileName = nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, /*onlyRecordFailures*/ false, state); + } + } + if (resolvedFileName && host.realpath) { + var originalFileName = resolvedFileName; + resolvedFileName = ts.normalizePath(host.realpath(resolvedFileName)); + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, originalFileName, resolvedFileName); + } + } + return createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations); + } + ts.nodeModuleNameResolver = nodeModuleNameResolver; + function nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate); + } + var resolvedFileName = !ts.pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state); + return resolvedFileName || loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, onlyRecordFailures, state); + } + /* @internal */ + function directoryProbablyExists(directoryName, host) { + // if host does not support 'directoryExists' assume that directory will exist + return !host.directoryExists || host.directoryExists(directoryName); + } + ts.directoryProbablyExists = directoryProbablyExists; + /** + * @param {boolean} onlyRecordFailures - if true then function won't try to actually load files but instead record all attempts as failures. This flag is necessary + * in cases when we know upfront that all load attempts will fail (because containing folder does not exists) however we still need to record all failed lookup locations. + */ + function loadModuleFromFile(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) { + // First, try adding an extension. An import of "foo" could be matched by a file "foo.ts", or "foo.js" by "foo.js.ts" + var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state); + if (resolvedByAddingExtension) { + return resolvedByAddingExtension; + } + // If that didn't work, try stripping a ".js" or ".jsx" extension and replacing it with a TypeScript one; + // e.g. "./foo.js" can be matched by "./foo.ts" or "./foo.d.ts" + if (ts.hasJavaScriptFileExtension(candidate)) { + var extensionless = ts.removeFileExtension(candidate); + if (state.traceEnabled) { + var extension = candidate.substring(extensionless.length); + trace(state.host, ts.Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension); + } + return tryAddingExtensions(extensionless, extensions, failedLookupLocation, onlyRecordFailures, state); + } + } + /** Try to return an existing file that adds one of the `extensions` to `candidate`. */ + function tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) { + if (!onlyRecordFailures) { + // check if containing folder exists - if it doesn't then just record failures for all supported extensions without disk probing + var directory = ts.getDirectoryPath(candidate); + if (directory) { + onlyRecordFailures = !directoryProbablyExists(directory, state.host); + } + } + return ts.forEach(extensions, function (ext) { + return !(state.skipTsx && ts.isJsxOrTsxExtension(ext)) && tryFile(candidate + ext, failedLookupLocation, onlyRecordFailures, state); + }); + } + /** Return the file if it exists. */ + function tryFile(fileName, failedLookupLocation, onlyRecordFailures, state) { + if (!onlyRecordFailures && state.host.fileExists(fileName)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); + } + return fileName; + } + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); + } + failedLookupLocation.push(fileName); + return undefined; + } + } + function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocation, onlyRecordFailures, state) { + var packageJsonPath = pathToPackageJson(candidate); + var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); + if (directoryExists && state.host.fileExists(packageJsonPath)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); + } + var typesFile = tryReadTypesSection(packageJsonPath, candidate, state); + if (typesFile) { + var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(typesFile), state.host); + // A package.json "typings" may specify an exact filename, or may choose to omit an extension. + var result = tryFile(typesFile, failedLookupLocation, onlyRecordFailures_1, state) || + tryAddingExtensions(typesFile, extensions, failedLookupLocation, onlyRecordFailures_1, state); + if (result) { + return result; + } + } + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_does_not_have_types_field); + } + } + } + else { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); + } + // 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 loadModuleFromFile(ts.combinePaths(candidate, "index"), extensions, failedLookupLocation, !directoryExists, state); + } + function pathToPackageJson(directory) { + return ts.combinePaths(directory, "package.json"); + } + function loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state) { + var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); + var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); + var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); + var supportedExtensions = ts.getSupportedExtensions(state.compilerOptions); + var result = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, !nodeModulesFolderExists, state); + if (result) { + return result; + } + result = loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); + if (result) { + return result; + } + } + /* @internal */ + function loadModuleFromNodeModules(moduleName, directory, failedLookupLocations, state, checkOneLevel) { + return loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, checkOneLevel, /*typesOnly*/ false); + } + ts.loadModuleFromNodeModules = loadModuleFromNodeModules; + function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) { + return loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, /*checkOneLevel*/ false, /*typesOnly*/ true); + } + function loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, checkOneLevel, typesOnly) { + directory = ts.normalizeSlashes(directory); + while (true) { + var baseName = ts.getBaseFileName(directory); + if (baseName !== "node_modules") { + var packageResult = void 0; + if (!typesOnly) { + // Try to load source from the package + packageResult = loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state); + if (packageResult && ts.hasTypeScriptFileExtension(packageResult)) { + // Always prefer a TypeScript (.ts, .tsx, .d.ts) file shipped with the package + return packageResult; + } + } + // Else prefer a types package over non-TypeScript results (e.g. JavaScript files) + var typesResult = loadModuleFromNodeModulesFolder(ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); + if (typesResult || packageResult) { + return typesResult || packageResult; + } + } + var parentPath = ts.getDirectoryPath(directory); + if (parentPath === directory || checkOneLevel) { + break; + } + directory = parentPath; + } + return undefined; + } + function classicNameResolver(moduleName, containingFile, compilerOptions, host) { + var traceEnabled = isTraceEnabled(compilerOptions, host); + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: !compilerOptions.jsx }; + var failedLookupLocations = []; + var supportedExtensions = ts.getSupportedExtensions(compilerOptions); + var containingDirectory = ts.getDirectoryPath(containingFile); + var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, supportedExtensions, state); + if (resolvedFileName) { + return createResolvedModule(resolvedFileName, /*isExternalLibraryImport*/ false, failedLookupLocations); + } + var referencedSourceFile; + if (moduleHasNonRelativeName(moduleName)) { + referencedSourceFile = referencedSourceFile = loadModuleFromAncestorDirectories(moduleName, containingDirectory, supportedExtensions, failedLookupLocations, state) || + // If we didn't find the file normally, look it up in @types. + loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); + } + else { + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + referencedSourceFile = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, /*onlyRecordFailures*/ false, state); + } + return referencedSourceFile + ? { resolvedModule: { resolvedFileName: referencedSourceFile }, failedLookupLocations: failedLookupLocations } + : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; + } + ts.classicNameResolver = classicNameResolver; + /** Climb up parent directories looking for a module. */ + function loadModuleFromAncestorDirectories(moduleName, containingDirectory, supportedExtensions, failedLookupLocations, state) { + while (true) { + var searchName = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var referencedSourceFile = loadModuleFromFile(searchName, supportedExtensions, failedLookupLocations, /*onlyRecordFailures*/ false, state); + if (referencedSourceFile) { + return referencedSourceFile; + } + var parentPath = ts.getDirectoryPath(containingDirectory); + if (parentPath === containingDirectory) { + return undefined; + } + containingDirectory = parentPath; + } + } +})(ts || (ts = {})); +/// /// /* @internal */ var ts; @@ -21607,6 +22727,7 @@ var ts; var unknownSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "unknown"); var resolvingSymbol = createSymbol(67108864 /* Transient */, "__resolving__"); var anyType = createIntrinsicType(1 /* Any */, "any"); + var autoType = createIntrinsicType(1 /* Any */, "any"); var unknownType = createIntrinsicType(1 /* Any */, "unknown"); var undefinedType = createIntrinsicType(2048 /* Undefined */, "undefined"); var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(2048 /* Undefined */ | 33554432 /* ContainsWideningType */, "undefined"); @@ -22350,7 +23471,7 @@ var ts; if (result && isInExternalModule && (meaning & 107455 /* Value */) === 107455 /* Value */) { var decls = result.declarations; if (decls && decls.length === 1 && decls[0].kind === 228 /* NamespaceExportDeclaration */) { - error(errorLocation, ts.Diagnostics.Identifier_0_must_be_imported_from_a_module, name); + error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } } @@ -22833,6 +23954,8 @@ var ts; } function getExportsForModule(moduleSymbol) { var visitedSymbols = []; + // A module defined by an 'export=' consists on one export that needs to be resolved + moduleSymbol = resolveExternalModuleSymbol(moduleSymbol); return visit(moduleSymbol) || moduleSymbol.exports; // The ES6 spec permits export * declarations in a module to circularly reference the module itself. For example, // module 'a' can 'export * from "b"' and 'b' can 'export * from "a"' without error. @@ -23407,9 +24530,9 @@ var ts; if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { // Go up and add our parent. - var parent_7 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); - if (parent_7) { - walkSymbol(parent_7, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); + var parent_8 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent_8) { + walkSymbol(parent_8, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); } } if (accessibleSymbolChain) { @@ -23453,7 +24576,7 @@ var ts; ? "any" : type.intrinsicName); } - else if (type.flags & 268435456 /* ThisType */) { + else if (type.flags & 16384 /* TypeParameter */ && type.isThisType) { if (inObjectTypeLiteral) { writer.reportInaccessibleThisError(); } @@ -23471,9 +24594,14 @@ var ts; // The specified symbol flags need to be reinterpreted as type flags buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 793064 /* Type */, 0 /* None */, nextFlags); } - else if (!(flags & 512 /* InTypeAlias */) && type.flags & (2097152 /* Anonymous */ | 1572864 /* UnionOrIntersection */) && type.aliasSymbol && + else if (!(flags & 512 /* InTypeAlias */) && ((type.flags & 2097152 /* Anonymous */ && !type.target) || type.flags & 1572864 /* UnionOrIntersection */) && type.aliasSymbol && isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, 793064 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false).accessibility === 0 /* Accessible */) { - // Only write out inferred type with its corresponding type-alias if type-alias is visible + // We emit inferred type as type-alias at the current localtion if all the following is true + // the input type is has alias symbol that is accessible + // the input type is a union, intersection or anonymous type that is fully instantiated (if not we want to keep dive into) + // e.g.: export type Bar = () => [X, Y]; + // export type Foo = Bar; + // export const y = (x: Foo) => 1 // we want to emit as ...x: () => [any, string]) var typeArguments = type.aliasTypeArguments; writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments.length : 0, nextFlags); } @@ -23549,14 +24677,14 @@ var ts; while (i < length_1) { // Find group of type arguments for type parameters with the same declaring container. var start = i; - var parent_8 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + var parent_9 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_8); + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_9); // 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_8, typeArguments, start, i, flags); + writeSymbolTypeReference(parent_9, typeArguments, start, i, flags); writePunctuation(writer, 21 /* DotToken */); } } @@ -23960,14 +25088,14 @@ var ts; if (ts.isExternalModuleAugmentation(node)) { return true; } - var parent_9 = getDeclarationContainer(node); + var parent_10 = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedModifierFlags(node) & 1 /* Export */) && - !(node.kind !== 229 /* ImportEqualsDeclaration */ && parent_9.kind !== 256 /* SourceFile */ && ts.isInAmbientContext(parent_9))) { - return isGlobalSourceFile(parent_9); + !(node.kind !== 229 /* ImportEqualsDeclaration */ && parent_10.kind !== 256 /* SourceFile */ && ts.isInAmbientContext(parent_10))) { + return isGlobalSourceFile(parent_10); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible - return isDeclarationVisible(parent_9); + return isDeclarationVisible(parent_10); case 145 /* PropertyDeclaration */: case 144 /* PropertySignature */: case 149 /* GetAccessor */: @@ -24274,6 +25402,10 @@ var ts; } return undefined; } + function isAutoVariableInitializer(initializer) { + var expr = initializer && ts.skipParentheses(initializer); + return !expr || expr.kind === 93 /* NullKeyword */ || expr.kind === 69 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; + } function addOptionality(type, optional) { return strictNullChecks && optional ? includeFalsyTypes(type, 2048 /* Undefined */) : type; } @@ -24306,6 +25438,13 @@ var ts; if (declaration.type) { return addOptionality(getTypeFromTypeNode(declaration.type), /*optional*/ declaration.questionToken && includeOptionality); } + // Use control flow type inference for non-ambient, non-exported var or let variables with no initializer + // or a 'null' or 'undefined' initializer. + if (declaration.kind === 218 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + !(ts.getCombinedNodeFlags(declaration) & 2 /* Const */) && !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && + !ts.isInAmbientContext(declaration) && isAutoVariableInitializer(declaration.initializer)) { + return autoType; + } if (declaration.kind === 142 /* Parameter */) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present @@ -24389,7 +25528,7 @@ var ts; result.pattern = pattern; } if (hasComputedProperties) { - result.flags |= 536870912 /* ObjectLiteralPatternWithComputedProperties */; + result.isObjectLiteralPatternWithComputedProperties = true; } return result; } @@ -24935,7 +26074,8 @@ var ts; type.instantiations[getTypeListId(type.typeParameters)] = type; type.target = type; type.typeArguments = type.typeParameters; - type.thisType = createType(16384 /* TypeParameter */ | 268435456 /* ThisType */); + type.thisType = createType(16384 /* TypeParameter */); + type.thisType.isThisType = true; type.thisType.symbol = symbol; type.thisType.constraint = type; } @@ -25509,7 +26649,7 @@ var ts; var current = _a[_i]; for (var _b = 0, _c = getPropertiesOfType(current); _b < _c.length; _b++) { var prop = _c[_b]; - getPropertyOfUnionOrIntersectionType(type, prop.name); + getUnionOrIntersectionProperty(type, prop.name); } // The properties of a union type are those that are present in all constituent types, so // we only need to check the properties of the first type @@ -25517,7 +26657,19 @@ var ts; break; } } - return type.resolvedProperties ? symbolsToArray(type.resolvedProperties) : emptyArray; + var props = type.resolvedProperties; + if (props) { + var result = []; + for (var key in props) { + var prop = props[key]; + // We need to filter out partial properties in union types + if (!(prop.flags & 268435456 /* SyntheticProperty */ && prop.isPartial)) { + result.push(prop); + } + } + return result; + } + return emptyArray; } function getPropertiesOfType(type) { type = getApparentType(type); @@ -25566,6 +26718,7 @@ var ts; // Flags we want to propagate to the result if they exist in all source symbols var commonFlags = (containingType.flags & 1048576 /* Intersection */) ? 536870912 /* Optional */ : 0 /* None */; var isReadonly = false; + var isPartial = false; for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { var current = types_2[_i]; var type = getApparentType(current); @@ -25584,21 +26737,20 @@ var ts; } } else if (containingType.flags & 524288 /* Union */) { - // A union type requires the property to be present in all constituent types - return undefined; + isPartial = true; } } } if (!props) { return undefined; } - if (props.length === 1) { + if (props.length === 1 && !isPartial) { return props[0]; } var propTypes = []; var declarations = []; var commonType = undefined; - var hasCommonType = true; + var hasNonUniformType = false; for (var _a = 0, props_1 = props; _a < props_1.length; _a++) { var prop = props_1[_a]; if (prop.declarations) { @@ -25609,22 +26761,25 @@ var ts; commonType = type; } else if (type !== commonType) { - hasCommonType = false; + hasNonUniformType = true; } - propTypes.push(getTypeOfSymbol(prop)); + propTypes.push(type); } - var result = createSymbol(4 /* Property */ | - 67108864 /* Transient */ | - 268435456 /* SyntheticProperty */ | - commonFlags, name); + var result = createSymbol(4 /* Property */ | 67108864 /* Transient */ | 268435456 /* SyntheticProperty */ | commonFlags, name); result.containingType = containingType; - result.hasCommonType = hasCommonType; + result.hasNonUniformType = hasNonUniformType; + result.isPartial = isPartial; result.declarations = declarations; result.isReadonly = isReadonly; result.type = containingType.flags & 524288 /* Union */ ? getUnionType(propTypes) : getIntersectionType(propTypes); return result; } - function getPropertyOfUnionOrIntersectionType(type, name) { + // Return the symbol for a given property in a union or intersection type, or undefined if the property + // does not exist in any constituent type. Note that the returned property may only be present in some + // constituents, in which case the isPartial flag is set when the containing type is union type. We need + // these partial properties when identifying discriminant properties, but otherwise they are filtered out + // and do not appear to be present in the union type. + function getUnionOrIntersectionProperty(type, name) { var properties = type.resolvedProperties || (type.resolvedProperties = ts.createMap()); var property = properties[name]; if (!property) { @@ -25635,6 +26790,11 @@ var ts; } return property; } + function getPropertyOfUnionOrIntersectionType(type, name) { + var property = getUnionOrIntersectionProperty(type, name); + // We need to filter out partial properties in union types + return property && !(property.flags & 268435456 /* SyntheticProperty */ && property.isPartial) ? property : undefined; + } /** * Return the symbol for the property with the given name in the given type. Creates synthetic union properties when * necessary, maps primitive types and type parameters are to their apparent types, and augments with properties from @@ -26040,7 +27200,7 @@ var ts; } function hasConstraintReferenceTo(type, target) { var checked; - while (type && !(type.flags & 268435456 /* ThisType */) && type.flags & 16384 /* TypeParameter */ && !ts.contains(checked, type)) { + while (type && type.flags & 16384 /* TypeParameter */ && !(type.isThisType) && !ts.contains(checked, type)) { if (type === target) { return true; } @@ -26365,7 +27525,8 @@ var ts; type.instantiations[getTypeListId(type.typeParameters)] = type; type.target = type; type.typeArguments = type.typeParameters; - type.thisType = createType(16384 /* TypeParameter */ | 268435456 /* ThisType */); + type.thisType = createType(16384 /* TypeParameter */); + type.thisType.isThisType = true; type.thisType.constraint = type; type.declaredProperties = properties; type.declaredCallSignatures = emptyArray; @@ -26466,7 +27627,24 @@ var ts; } return false; } + function isSetOfLiteralsFromSameEnum(types) { + var first = types[0]; + if (first.flags & 256 /* EnumLiteral */) { + var firstEnum = getParentOfSymbol(first.symbol); + for (var i = 1; i < types.length; i++) { + var other = types[i]; + if (!(other.flags & 256 /* EnumLiteral */) || (firstEnum !== getParentOfSymbol(other.symbol))) { + return false; + } + } + return true; + } + return false; + } function removeSubtypes(types) { + if (types.length === 0 || isSetOfLiteralsFromSameEnum(types)) { + return; + } var i = types.length; while (i > 0) { i--; @@ -27553,7 +28731,8 @@ var ts; !t.numberIndexInfo; } function hasExcessProperties(source, target, reportErrors) { - if (!(target.flags & 536870912 /* ObjectLiteralPatternWithComputedProperties */) && maybeTypeOfKind(target, 2588672 /* ObjectType */)) { + if (maybeTypeOfKind(target, 2588672 /* ObjectType */) && + (!(target.flags & 2588672 /* ObjectType */) || !target.isObjectLiteralPatternWithComputedProperties)) { for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { var prop = _a[_i]; if (!isKnownProperty(target, prop.name)) { @@ -28917,21 +30096,10 @@ var ts; } function isDiscriminantProperty(type, name) { if (type && type.flags & 524288 /* Union */) { - var prop = getPropertyOfType(type, name); - if (!prop) { - // The type may be a union that includes nullable or primitive types. If filtering - // those out produces a different type, get the property from that type instead. - // Effectively, we're checking if this *could* be a discriminant property once nullable - // and primitive types are removed by other type guards. - var filteredType = getTypeWithFacts(type, 4194304 /* Discriminatable */); - if (filteredType !== type && filteredType.flags & 524288 /* Union */) { - prop = getPropertyOfType(filteredType, name); - } - } + var prop = getUnionOrIntersectionProperty(type, name); if (prop && prop.flags & 268435456 /* SyntheticProperty */) { if (prop.isDiscriminantProperty === undefined) { - prop.isDiscriminantProperty = !prop.hasCommonType && - isLiteralType(getTypeOfSymbol(prop)); + prop.isDiscriminantProperty = prop.hasNonUniformType && isLiteralType(getTypeOfSymbol(prop)); } return prop.isDiscriminantProperty; } @@ -29218,6 +30386,26 @@ var ts; } return f(type) ? type : neverType; } + function mapType(type, f) { + return type.flags & 524288 /* Union */ ? getUnionType(ts.map(type.types, f)) : f(type); + } + function extractTypesOfKind(type, kind) { + return filterType(type, function (t) { return (t.flags & kind) !== 0; }); + } + // Return a new type in which occurrences of the string and number primitive types in + // typeWithPrimitives have been replaced with occurrences of string literals and numeric + // literals in typeWithLiterals, respectively. + function replacePrimitivesWithLiterals(typeWithPrimitives, typeWithLiterals) { + if (isTypeSubsetOf(stringType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 32 /* StringLiteral */) || + isTypeSubsetOf(numberType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 64 /* NumberLiteral */)) { + return mapType(typeWithPrimitives, function (t) { + return t.flags & 2 /* String */ ? extractTypesOfKind(typeWithLiterals, 2 /* String */ | 32 /* StringLiteral */) : + t.flags & 4 /* Number */ ? extractTypesOfKind(typeWithLiterals, 4 /* Number */ | 64 /* NumberLiteral */) : + t; + }); + } + return typeWithPrimitives; + } function isIncomplete(flowType) { return flowType.flags === 0; } @@ -29232,7 +30420,9 @@ var ts; if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 4178943 /* Narrowable */)) { return declaredType; } - var initialType = assumeInitialized ? declaredType : includeFalsyTypes(declaredType, 2048 /* Undefined */); + var initialType = assumeInitialized ? declaredType : + declaredType === autoType ? undefinedType : + includeFalsyTypes(declaredType, 2048 /* Undefined */); var visitedFlowStart = visitedFlowCount; var result = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); visitedFlowCount = visitedFlowStart; @@ -29304,10 +30494,13 @@ var ts; // Assignments only narrow the computed type if the declared type is a union type. Thus, we // only need to evaluate the assigned type if the declared type is a union type. if (isMatchingReference(reference, node)) { - var isIncrementOrDecrement = node.parent.kind === 185 /* PrefixUnaryExpression */ || node.parent.kind === 186 /* PostfixUnaryExpression */; - return declaredType.flags & 524288 /* Union */ && !isIncrementOrDecrement ? - getAssignmentReducedType(declaredType, getInitialOrAssignedType(node)) : - declaredType; + if (node.parent.kind === 185 /* PrefixUnaryExpression */ || node.parent.kind === 186 /* PostfixUnaryExpression */) { + var flowType = getTypeAtFlowNode(flow.antecedent); + return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType)); + } + return declaredType === autoType ? getBaseTypeOfLiteralType(getInitialOrAssignedType(node)) : + declaredType.flags & 524288 /* Union */ ? getAssignmentReducedType(declaredType, getInitialOrAssignedType(node)) : + declaredType; } // We didn't have a direct match. However, if the reference is a dotted name, this // may be an assignment to a left hand part of the reference. For example, for a @@ -29531,12 +30724,12 @@ var ts; assumeTrue ? 16384 /* EQUndefined */ : 131072 /* NEUndefined */; return getTypeWithFacts(type, facts); } - if (type.flags & 2589191 /* NotUnionOrUnit */) { + if (type.flags & 2589185 /* NotUnionOrUnit */) { return type; } if (assumeTrue) { var narrowedType = filterType(type, function (t) { return areTypesComparable(t, valueType); }); - return narrowedType.flags & 8192 /* Never */ ? type : narrowedType; + return narrowedType.flags & 8192 /* Never */ ? type : replacePrimitivesWithLiterals(narrowedType, valueType); } if (isUnitType(valueType)) { var regularType_1 = getRegularTypeOfLiteralType(valueType); @@ -29581,7 +30774,8 @@ var ts; var clauseTypes = switchTypes.slice(clauseStart, clauseEnd); var hasDefaultClause = clauseStart === clauseEnd || ts.contains(clauseTypes, neverType); var discriminantType = getUnionType(clauseTypes); - var caseType = discriminantType.flags & 8192 /* Never */ ? neverType : filterType(type, function (t) { return isTypeComparableTo(discriminantType, t); }); + var caseType = discriminantType.flags & 8192 /* Never */ ? neverType : + replacePrimitivesWithLiterals(filterType(type, function (t) { return isTypeComparableTo(discriminantType, t); }), discriminantType); if (!hasDefaultClause) { return caseType; } @@ -29728,7 +30922,7 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } - if (ts.isExpression(location) && !ts.isAssignmentTarget(location)) { + if (ts.isPartOfExpression(location) && !ts.isAssignmentTarget(location)) { var type = checkExpression(location); if (getExportSymbolOfValueSymbolIfExported(getNodeLinks(location).resolvedSymbol) === symbol) { return type; @@ -29877,20 +31071,32 @@ var ts; // a const variable or parameter from an outer function, we extend the origin of the control flow // analysis to include the immediately enclosing function. while (flowContainer !== declarationContainer && - (flowContainer.kind === 179 /* FunctionExpression */ || flowContainer.kind === 180 /* ArrowFunction */) && + (flowContainer.kind === 179 /* FunctionExpression */ || + flowContainer.kind === 180 /* ArrowFunction */ || + ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isReadonlySymbol(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } // We only look for uninitialized variables in strict null checking mode, and only when we can analyze // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). - var assumeInitialized = !strictNullChecks || (type.flags & 1 /* Any */) !== 0 || isParameter || - isOuterVariable || ts.isInAmbientContext(declaration); + var assumeInitialized = isParameter || isOuterVariable || + type !== autoType && (!strictNullChecks || (type.flags & 1 /* Any */) !== 0) || + ts.isInAmbientContext(declaration); var flowType = getFlowTypeOfReference(node, type, assumeInitialized, flowContainer); // A variable is considered uninitialized when it is possible to analyze the entire control flow graph // from declaration to use, and when the variable's declared type doesn't include undefined but the // control flow based type does include undefined. - if (!assumeInitialized && !(getFalsyFlags(type) & 2048 /* Undefined */) && getFalsyFlags(flowType) & 2048 /* Undefined */) { + if (type === autoType) { + if (flowType === autoType) { + if (compilerOptions.noImplicitAny) { + error(declaration.name, ts.Diagnostics.Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol)); + error(node, ts.Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(anyType)); + } + return anyType; + } + } + else if (!assumeInitialized && !(getFalsyFlags(type) & 2048 /* Undefined */) && getFalsyFlags(flowType) & 2048 /* Undefined */) { error(node, ts.Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol)); // Return the declared type to reduce follow-on errors return type; @@ -29988,7 +31194,7 @@ var ts; } } function findFirstSuperCall(n) { - if (ts.isSuperCallExpression(n)) { + if (ts.isSuperCall(n)) { return n; } else if (ts.isFunctionLike(n)) { @@ -30081,7 +31287,7 @@ var ts; captureLexicalThis(node, container); } if (ts.isFunctionLike(container) && - (!isInParameterInitializerBeforeContainingFunction(node) || getFunctionLikeThisParameter(container))) { + (!isInParameterInitializerBeforeContainingFunction(node) || ts.getThisParameter(container))) { // Note: a parameter initializer should refer to class-this unless function-this is explicitly annotated. // If this is a function in a JS file, it might be a class method. Check if it's the RHS // of a x.prototype.y = function [name]() { .... } @@ -30141,8 +31347,8 @@ var ts; var isCallExpression = node.parent.kind === 174 /* CallExpression */ && node.parent.expression === node; var container = ts.getSuperContainer(node, /*stopOnFunctions*/ true); var needToCaptureLexicalThis = false; + // adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting if (!isCallExpression) { - // adjust the container reference in case if super is used inside arrow functions with arbitrary deep nesting while (container && container.kind === 180 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES6 */; @@ -30954,7 +32160,8 @@ var ts; patternWithComputedProperties = true; } } - else if (contextualTypeHasPattern && !(contextualType.flags & 536870912 /* ObjectLiteralPatternWithComputedProperties */)) { + else if (contextualTypeHasPattern && + !(contextualType.flags & 2588672 /* ObjectType */ && contextualType.isObjectLiteralPatternWithComputedProperties)) { // If object literal is contextually typed by the implied type of a binding pattern, and if the // binding pattern specifies a default value for the property, make the property optional. var impliedProp = getPropertyOfType(contextualType, member.name); @@ -31014,7 +32221,10 @@ var ts; var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, propertiesArray, 1 /* Number */) : undefined; var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 16777216 /* FreshLiteral */; - result.flags |= 8388608 /* ObjectLiteral */ | 67108864 /* ContainsObjectLiteral */ | freshObjectLiteralFlag | (typeFlags & 234881024 /* PropagatingFlags */) | (patternWithComputedProperties ? 536870912 /* ObjectLiteralPatternWithComputedProperties */ : 0); + result.flags |= 8388608 /* ObjectLiteral */ | 67108864 /* ContainsObjectLiteral */ | freshObjectLiteralFlag | (typeFlags & 234881024 /* PropagatingFlags */); + if (patternWithComputedProperties) { + result.isObjectLiteralPatternWithComputedProperties = true; + } if (inDestructuringPattern) { result.pattern = node; } @@ -31523,7 +32733,7 @@ var ts; return true; } // An instance property must be accessed through an instance of the enclosing class - if (type.flags & 268435456 /* ThisType */) { + if (type.flags & 16384 /* TypeParameter */ && type.isThisType) { // get the original type -- represented as the type constraint of the 'this' type type = getConstraintOfTypeParameter(type); } @@ -31567,7 +32777,7 @@ var ts; var prop = getPropertyOfType(apparentType, right.text); if (!prop) { if (right.text && !checkAndReportErrorForExtendingInterface(node)) { - reportNonexistentProperty(right, type.flags & 268435456 /* ThisType */ ? apparentType : type); + reportNonexistentProperty(right, type.flags & 16384 /* TypeParameter */ && type.isThisType ? apparentType : type); } return unknownType; } @@ -31848,13 +33058,13 @@ var ts; for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var signature = signatures_2[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_10 = signature.declaration && signature.declaration.parent; + var parent_11 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_10 === lastParent) { + if (lastParent && parent_11 === lastParent) { index++; } else { - lastParent = parent_10; + lastParent = parent_11; index = cutoffIndex; } } @@ -31862,7 +33072,7 @@ var ts; // current declaration belongs to a different symbol // set cutoffIndex so re-orderings in the future won't change result set from 0 to cutoffIndex index = cutoffIndex = result.length; - lastParent = parent_10; + lastParent = parent_11; } lastSymbol = symbol; // specialized signatures always need to be placed before non-specialized signatures regardless @@ -33121,7 +34331,9 @@ var ts; if (!contextualSignature) { reportErrorsFromWidening(func, type); } - if (isUnitType(type) && !(contextualSignature && isLiteralContextualType(getReturnTypeOfSignature(contextualSignature)))) { + if (isUnitType(type) && + !(contextualSignature && + isLiteralContextualType(contextualSignature === getSignatureFromDeclaration(func) ? type : getReturnTypeOfSignature(contextualSignature)))) { type = getWidenedLiteralType(type); } var widenedType = getWidenedType(type); @@ -33305,7 +34517,7 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 147 /* MethodDeclaration */ && node.kind !== 146 /* MethodSignature */) { + if (produceDiagnostics && node.kind !== 147 /* MethodDeclaration */) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } @@ -34388,9 +35600,9 @@ var ts; case 156 /* FunctionType */: case 147 /* MethodDeclaration */: case 146 /* MethodSignature */: - var parent_11 = node.parent; - if (node === parent_11.type) { - return parent_11; + var parent_12 = node.parent; + if (node === parent_12.type) { + return parent_12; } } } @@ -34628,7 +35840,7 @@ var ts; return n.name && containsSuperCall(n.name); } function containsSuperCall(n) { - if (ts.isSuperCallExpression(n)) { + if (ts.isSuperCall(n)) { return true; } else if (ts.isFunctionLike(n)) { @@ -34657,6 +35869,7 @@ var ts; // constructors of derived classes must contain at least one super call somewhere in their function body. var containingClassDecl = node.parent; if (ts.getClassExtendsHeritageClauseElement(containingClassDecl)) { + captureLexicalThis(node.parent, containingClassDecl); var classExtendsNull = classDeclarationExtendsNull(containingClassDecl); var superCall = getSuperCallInConstructor(node); if (superCall) { @@ -34677,7 +35890,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 202 /* ExpressionStatement */ && ts.isSuperCallExpression(statement.expression)) { + if (statement.kind === 202 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -35607,7 +36820,7 @@ var ts; var parameter = local.valueDeclaration; if (compilerOptions.noUnusedParameters && !ts.isParameterPropertyDeclaration(parameter) && - !parameterIsThisKeyword(parameter) && + !ts.parameterIsThisKeyword(parameter) && !parameterNameStartsWithUnderscore(parameter)) { error(local.valueDeclaration.name, ts.Diagnostics._0_is_declared_but_never_used, local.name); } @@ -35622,9 +36835,6 @@ var ts; } } } - function parameterIsThisKeyword(parameter) { - return parameter.name && parameter.name.originalKeywordKind === 97 /* ThisKeyword */; - } function parameterNameStartsWithUnderscore(parameter) { return parameter.name && parameter.name.kind === 69 /* Identifier */ && parameter.name.text.charCodeAt(0) === 95 /* _ */; } @@ -35772,6 +36982,10 @@ var ts; } } function checkCollisionWithRequireExportsInGeneratedCode(node, name) { + // No need to check for require or exports for ES6 modules and later + if (modulekind >= ts.ModuleKind.ES6) { + return; + } if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } @@ -35926,6 +37140,9 @@ var ts; } } } + function convertAutoToAny(type) { + return type === autoType ? anyType : type; + } // Check variable, parameter, or property declaration function checkVariableLikeDeclaration(node) { checkDecorators(node); @@ -35946,12 +37163,12 @@ var ts; checkComputedPropertyName(node.propertyName); } // check private/protected variable access - var parent_12 = node.parent.parent; - var parentType = getTypeForBindingElementParent(parent_12); + var parent_13 = node.parent.parent; + var parentType = getTypeForBindingElementParent(parent_13); var name_21 = node.propertyName || node.name; var property = getPropertyOfType(parentType, getTextOfPropertyName(name_21)); - if (parent_12.initializer && property && getParentOfSymbol(property)) { - checkClassPropertyAccess(parent_12, parent_12.initializer, parentType, property); + if (parent_13.initializer && property && getParentOfSymbol(property)) { + checkClassPropertyAccess(parent_13, parent_13.initializer, parentType, property); } } // For a binding pattern, check contained binding elements @@ -35973,7 +37190,7 @@ var ts; return; } var symbol = getSymbolOfNode(node); - var type = getTypeOfVariableOrParameterOrProperty(symbol); + var type = convertAutoToAny(getTypeOfVariableOrParameterOrProperty(symbol)); if (node === symbol.valueDeclaration) { // Node is the primary declaration of the symbol, just validate the initializer // Don't validate for-in initializer as it is already an error @@ -35985,7 +37202,7 @@ var ts; else { // Node is a secondary declaration, check that type is identical to primary declaration and check that // initializer is consistent with type associated with the node - var declarationType = getWidenedTypeForVariableLikeDeclaration(node); + var declarationType = convertAutoToAny(getWidenedTypeForVariableLikeDeclaration(node)); if (type !== unknownType && declarationType !== unknownType && !isTypeIdenticalTo(type, declarationType)) { error(node.name, ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2, ts.declarationNameToString(node.name), typeToString(type), typeToString(declarationType)); } @@ -36480,7 +37697,12 @@ var ts; } } checkExpression(node.expression); - error(node.expression, ts.Diagnostics.All_symbols_within_a_with_block_will_be_resolved_to_any); + var sourceFile = ts.getSourceFileOfNode(node); + if (!hasParseDiagnostics(sourceFile)) { + var start = ts.getSpanOfTokenAtPosition(sourceFile, node.pos).start; + var end = node.statement.pos; + grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any); + } } function checkSwitchStatement(node) { // Grammar checking @@ -37288,9 +38510,11 @@ var ts; grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } } - checkCollisionWithCapturedThisVariable(node, node.name); - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); + if (ts.isIdentifier(node.name)) { + checkCollisionWithCapturedThisVariable(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); + checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); + } checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); // The following checks only apply on a non-ambient instantiated module declaration. @@ -37568,9 +38792,11 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - if (node.parent.kind !== 256 /* SourceFile */ && node.parent.kind !== 226 /* ModuleBlock */ && node.parent.kind !== 225 /* ModuleDeclaration */) { - return grammarErrorOnFirstToken(node, errorMessage); + var isInAppropriateContext = node.parent.kind === 256 /* SourceFile */ || node.parent.kind === 226 /* ModuleBlock */ || node.parent.kind === 225 /* ModuleDeclaration */; + if (!isInAppropriateContext) { + grammarErrorOnFirstToken(node, errorMessage); } + return !isInAppropriateContext; } function checkExportSpecifier(node) { checkAliasSymbol(node); @@ -37668,7 +38894,8 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return declaration.kind !== 220 /* FunctionDeclaration */ || !!declaration.body; + return (declaration.kind !== 220 /* FunctionDeclaration */ && declaration.kind !== 147 /* MethodDeclaration */) || + !!declaration.body; } } function checkSourceElement(node) { @@ -38202,6 +39429,9 @@ var ts; node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } + if (ts.isInJavaScriptFile(node) && ts.isRequireCall(node.parent, /*checkArgumentIsStringLiteral*/ false)) { + return resolveExternalModuleName(node, node); + } // Fall through case 8 /* NumericLiteral */: // index access @@ -38726,9 +39956,9 @@ var ts; if (startInDeclarationContainer) { // When resolving the name of a declaration as a value, we need to start resolution // at a point outside of the declaration. - var parent_13 = reference.parent; - if (ts.isDeclaration(parent_13) && reference === parent_13.name) { - location = getDeclarationContainer(parent_13); + var parent_14 = reference.parent; + if (ts.isDeclaration(parent_14) && reference === parent_14.name) { + location = getDeclarationContainer(parent_14); } } return resolveName(location, reference.text, 107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); @@ -38852,9 +40082,9 @@ var ts; // external modules cannot define or contribute to type declaration files var current = symbol; while (true) { - var parent_14 = getParentOfSymbol(current); - if (parent_14) { - current = parent_14; + var parent_15 = getParentOfSymbol(current); + if (parent_15) { + current = parent_15; } else { break; @@ -39437,8 +40667,8 @@ var ts; function checkGrammarForOmittedArgument(node, args) { if (args) { var sourceFile = ts.getSourceFileOfNode(node); - for (var _i = 0, args_2 = args; _i < args_2.length; _i++) { - var arg = args_2[_i]; + for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { + var arg = args_4[_i]; if (arg.kind === 193 /* OmittedExpression */) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } @@ -39550,8 +40780,7 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; var name_24 = prop.name; - if (prop.kind === 193 /* OmittedExpression */ || - name_24.kind === 140 /* ComputedPropertyName */) { + if (name_24.kind === 140 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name_24); } @@ -39731,17 +40960,8 @@ var ts; return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 149 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 149 /* GetAccessor */ ? 1 : 2) && - accessor.parameters[0].name.kind === 69 /* Identifier */ && - accessor.parameters[0].name.originalKeywordKind === 97 /* ThisKeyword */) { - return accessor.parameters[0]; - } - } - function getFunctionLikeThisParameter(func) { - if (func.parameters.length && - func.parameters[0].name.kind === 69 /* Identifier */ && - func.parameters[0].name.originalKeywordKind === 97 /* ThisKeyword */) { - return func.parameters[0]; + if (accessor.parameters.length === (accessor.kind === 149 /* GetAccessor */ ? 1 : 2)) { + return ts.getThisParameter(accessor); } } function checkGrammarForNonSymbolComputedProperty(node, message) { @@ -40673,7 +41893,7 @@ var ts; case 175 /* NewExpression */: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); case 176 /* TaggedTemplateExpression */: - return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplate)); + return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); case 178 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); case 179 /* FunctionExpression */: @@ -40697,7 +41917,7 @@ var ts; case 188 /* ConditionalExpression */: return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); case 189 /* TemplateExpression */: - return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateLiteralFragment), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); + return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); case 190 /* YieldExpression */: return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); case 191 /* SpreadElementExpression */: @@ -40708,7 +41928,7 @@ var ts; return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); // Misc case 197 /* TemplateSpan */: - return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateLiteralFragment)); + return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element case 199 /* Block */: return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); @@ -41055,7 +42275,7 @@ var ts; var expression = ts.createAssignment(name, value, location); // NOTE: this completely disables source maps, but aligns with the behavior of // `emitAssignment` in the old emitter. - context.setNodeEmitFlags(expression, 2048 /* NoNestedSourceMaps */); + ts.setEmitFlags(expression, 2048 /* NoNestedSourceMaps */); ts.aggregateTransformFlags(expression); expressions.push(expression); } @@ -41081,7 +42301,7 @@ var ts; var declaration = ts.createVariableDeclaration(name, /*type*/ undefined, value, location); // NOTE: this completely disables source maps, but aligns with the behavior of // `emitAssignment` in the old emitter. - context.setNodeEmitFlags(declaration, 2048 /* NoNestedSourceMaps */); + ts.setEmitFlags(declaration, 2048 /* NoNestedSourceMaps */); ts.aggregateTransformFlags(declaration); declarations.push(declaration); } @@ -41114,7 +42334,7 @@ var ts; declaration.original = original; // NOTE: this completely disables source maps, but aligns with the behavior of // `emitAssignment` in the old emitter. - context.setNodeEmitFlags(declaration, 2048 /* NoNestedSourceMaps */); + ts.setEmitFlags(declaration, 2048 /* NoNestedSourceMaps */); declarations.push(declaration); ts.aggregateTransformFlags(declaration); } @@ -41164,7 +42384,7 @@ var ts; expression.original = original; // NOTE: this completely disables source maps, but aligns with the behavior of // `emitAssignment` in the old emitter. - context.setNodeEmitFlags(expression, 2048 /* NoNestedSourceMaps */); + ts.setEmitFlags(expression, 2048 /* NoNestedSourceMaps */); pendingAssignments.push(expression); return expression; } @@ -41210,8 +42430,8 @@ var ts; } else { var name_26 = ts.getMutableClone(target); - context.setSourceMapRange(name_26, target); - context.setCommentRange(name_26, target); + ts.setSourceMapRange(name_26, target); + ts.setCommentRange(name_26, target); emitAssignment(name_26, value, location, /*original*/ undefined); } } @@ -41380,7 +42600,7 @@ var ts; TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["NonQualifiedEnumMembers"] = 8] = "NonQualifiedEnumMembers"; })(TypeScriptSubstitutionFlags || (TypeScriptSubstitutionFlags = {})); function transformTypeScript(context) { - var getNodeEmitFlags = context.getNodeEmitFlags, setNodeEmitFlags = context.setNodeEmitFlags, setCommentRange = context.setCommentRange, setSourceMapRange = context.setSourceMapRange, startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); var compilerOptions = context.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); @@ -41391,11 +42611,15 @@ var ts; // Set new transformation hooks. context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; + // Enable substitution for property/element access to emit const enum values. + context.enableSubstitution(172 /* PropertyAccessExpression */); + context.enableSubstitution(173 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; var currentNamespaceContainerName; var currentScope; + var currentScopeFirstDeclarationsOfName; var currentSourceFileExternalHelpersModuleName; /** * Keeps track of whether expression substitution has been enabled for specific edge cases. @@ -41424,6 +42648,9 @@ var ts; * @param node A SourceFile node. */ function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } return ts.visitNode(node, visitor, ts.isSourceFile); } /** @@ -41434,10 +42661,14 @@ var ts; function saveStateAndInvoke(node, f) { // Save state var savedCurrentScope = currentScope; + var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName; // Handle state changes before visiting a node. onBeforeVisitNode(node); var visited = f(node); // Restore state + if (currentScope !== savedCurrentScope) { + currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; + } currentScope = savedCurrentScope; return visited; } @@ -41702,11 +42933,23 @@ var ts; case 226 /* ModuleBlock */: case 199 /* Block */: currentScope = node; + currentScopeFirstDeclarationsOfName = undefined; + break; + case 221 /* ClassDeclaration */: + case 220 /* FunctionDeclaration */: + if (ts.hasModifier(node, 2 /* Ambient */)) { + break; + } + recordEmittedDeclarationInScope(node); break; } } function visitSourceFile(node) { currentSourceFile = node; + // ensure "use strict" is emitted in all scenarios in alwaysStrict mode + if (compilerOptions.alwaysStrict) { + node = ts.ensureUseStrict(node); + } // If the source file requires any helpers and is an external module, and // the importHelpers compiler option is enabled, emit a synthesized import // statement for the helpers library. @@ -41733,7 +42976,7 @@ var ts; else { node = ts.visitEachChild(node, visitor, context); } - setNodeEmitFlags(node, 1 /* EmitEmitHelpers */ | node.emitFlags); + ts.setEmitFlags(node, 1 /* EmitEmitHelpers */ | ts.getEmitFlags(node)); return node; } /** @@ -41792,7 +43035,7 @@ var ts; // To better align with the old emitter, we should not emit a trailing source map // entry if the class has static properties. if (staticProperties.length > 0) { - setNodeEmitFlags(classDeclaration, 1024 /* NoTrailingSourceMap */ | getNodeEmitFlags(classDeclaration)); + ts.setEmitFlags(classDeclaration, 1024 /* NoTrailingSourceMap */ | ts.getEmitFlags(classDeclaration)); } statements.push(classDeclaration); } @@ -41951,7 +43194,7 @@ var ts; /*type*/ undefined, classExpression) ]), /*location*/ location); - setCommentRange(transformedClassExpression, node); + ts.setCommentRange(transformedClassExpression, node); statements.push(ts.setOriginalNode( /*node*/ transformedClassExpression, /*original*/ node)); @@ -41996,7 +43239,7 @@ var ts; } // To preserve the behavior of the old emitter, we explicitly indent // the body of a class with static initializers. - setNodeEmitFlags(classExpression, 524288 /* Indented */ | getNodeEmitFlags(classExpression)); + ts.setEmitFlags(classExpression, 524288 /* Indented */ | ts.getEmitFlags(classExpression)); expressions.push(ts.startOnNewLine(ts.createAssignment(temp, classExpression))); ts.addRange(expressions, generateInitializedPropertyExpressions(node, staticProperties, temp)); expressions.push(ts.startOnNewLine(temp)); @@ -42151,7 +43394,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 202 /* ExpressionStatement */ && ts.isSuperCallExpression(statement.expression)) { + if (statement.kind === 202 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -42185,9 +43428,9 @@ var ts; ts.Debug.assert(ts.isIdentifier(node.name)); var name = node.name; var propertyName = ts.getMutableClone(name); - setNodeEmitFlags(propertyName, 49152 /* NoComments */ | 1536 /* NoSourceMap */); + ts.setEmitFlags(propertyName, 49152 /* NoComments */ | 1536 /* NoSourceMap */); var localName = ts.getMutableClone(name); - setNodeEmitFlags(localName, 49152 /* NoComments */); + ts.setEmitFlags(localName, 49152 /* NoComments */); return ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createThis(), propertyName, /*location*/ node.name), localName), /*location*/ ts.moveRangePos(node, -1))); @@ -42239,8 +43482,8 @@ var ts; for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) { var property = properties_7[_i]; var statement = ts.createStatement(transformInitializedProperty(node, property, receiver)); - setSourceMapRange(statement, ts.moveRangePastModifiers(property)); - setCommentRange(statement, property); + ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property)); + ts.setCommentRange(statement, property); statements.push(statement); } } @@ -42257,8 +43500,8 @@ var ts; var property = properties_8[_i]; var expression = transformInitializedProperty(node, property, receiver); expression.startsOnNewLine = true; - setSourceMapRange(expression, ts.moveRangePastModifiers(property)); - setCommentRange(expression, property); + ts.setSourceMapRange(expression, ts.moveRangePastModifiers(property)); + ts.setCommentRange(expression, property); expressions.push(expression); } return expressions; @@ -42524,7 +43767,7 @@ var ts; : ts.createNull() : undefined; var helper = ts.createDecorateHelper(currentSourceFileExternalHelpersModuleName, decoratorExpressions, prefix, memberName, descriptor, ts.moveRangePastDecorators(member)); - setNodeEmitFlags(helper, 49152 /* NoComments */); + ts.setEmitFlags(helper, 49152 /* NoComments */); return helper; } /** @@ -42562,12 +43805,12 @@ var ts; if (decoratedClassAlias) { var expression = ts.createAssignment(decoratedClassAlias, ts.createDecorateHelper(currentSourceFileExternalHelpersModuleName, decoratorExpressions, getDeclarationName(node))); var result = ts.createAssignment(getDeclarationName(node), expression, ts.moveRangePastDecorators(node)); - setNodeEmitFlags(result, 49152 /* NoComments */); + ts.setEmitFlags(result, 49152 /* NoComments */); return result; } else { var result = ts.createAssignment(getDeclarationName(node), ts.createDecorateHelper(currentSourceFileExternalHelpersModuleName, decoratorExpressions, getDeclarationName(node)), ts.moveRangePastDecorators(node)); - setNodeEmitFlags(result, 49152 /* NoComments */); + ts.setEmitFlags(result, 49152 /* NoComments */); return result; } } @@ -42593,7 +43836,7 @@ var ts; var decorator = decorators_1[_i]; var helper = ts.createParamHelper(currentSourceFileExternalHelpersModuleName, transformDecorator(decorator), parameterOffset, /*location*/ decorator.expression); - setNodeEmitFlags(helper, 49152 /* NoComments */); + ts.setEmitFlags(helper, 49152 /* NoComments */); expressions.push(helper); } } @@ -42824,10 +44067,38 @@ var ts; : ts.createIdentifier("Symbol"); case 155 /* TypeReference */: return serializeTypeReferenceNode(node); + case 163 /* IntersectionType */: + case 162 /* UnionType */: + { + var unionOrIntersection = node; + var serializedUnion = void 0; + for (var _i = 0, _a = unionOrIntersection.types; _i < _a.length; _i++) { + var typeNode = _a[_i]; + var serializedIndividual = serializeTypeNode(typeNode); + // Non identifier + if (serializedIndividual.kind !== 69 /* Identifier */) { + serializedUnion = undefined; + break; + } + // One of the individual is global object, return immediately + if (serializedIndividual.text === "Object") { + return serializedIndividual; + } + // Different types + if (serializedUnion && serializedUnion.text !== serializedIndividual.text) { + serializedUnion = undefined; + break; + } + serializedUnion = serializedIndividual; + } + // If we were able to find common type + if (serializedUnion) { + return serializedUnion; + } + } + // Fallthrough case 158 /* TypeQuery */: case 159 /* TypeLiteral */: - case 162 /* UnionType */: - case 163 /* IntersectionType */: case 117 /* AnyKeyword */: case 165 /* ThisType */: break; @@ -43027,8 +44298,8 @@ var ts; /*location*/ node); // While we emit the source map for the node after skipping decorators and modifiers, // we need to emit the comments for the original range. - setCommentRange(method, node); - setSourceMapRange(method, ts.moveRangePastDecorators(node)); + ts.setCommentRange(method, node); + ts.setSourceMapRange(method, ts.moveRangePastDecorators(node)); ts.setOriginalNode(method, node); return method; } @@ -43060,8 +44331,8 @@ var ts; /*location*/ node); // While we emit the source map for the node after skipping decorators and modifiers, // we need to emit the comments for the original range. - setCommentRange(accessor, node); - setSourceMapRange(accessor, ts.moveRangePastDecorators(node)); + ts.setCommentRange(accessor, node); + ts.setSourceMapRange(accessor, ts.moveRangePastDecorators(node)); ts.setOriginalNode(accessor, node); return accessor; } @@ -43083,8 +44354,8 @@ var ts; /*location*/ node); // While we emit the source map for the node after skipping decorators and modifiers, // we need to emit the comments for the original range. - setCommentRange(accessor, node); - setSourceMapRange(accessor, ts.moveRangePastDecorators(node)); + ts.setCommentRange(accessor, node); + ts.setSourceMapRange(accessor, ts.moveRangePastDecorators(node)); ts.setOriginalNode(accessor, node); return accessor; } @@ -43220,11 +44491,11 @@ var ts; if (languageVersion >= 2 /* ES6 */) { if (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) { enableSubstitutionForAsyncMethodsWithSuper(); - setNodeEmitFlags(block, 8 /* EmitAdvancedSuperHelper */); + ts.setEmitFlags(block, 8 /* EmitAdvancedSuperHelper */); } else if (resolver.getNodeCheckFlags(node) & 2048 /* AsyncMethodWithSuper */) { enableSubstitutionForAsyncMethodsWithSuper(); - setNodeEmitFlags(block, 4 /* EmitSuperHelper */); + ts.setEmitFlags(block, 4 /* EmitSuperHelper */); } } return block; @@ -43244,7 +44515,7 @@ var ts; * @param node The parameter declaration node. */ function visitParameter(node) { - if (node.name && ts.isIdentifier(node.name) && node.name.originalKeywordKind === 97 /* ThisKeyword */) { + if (ts.parameterIsThisKeyword(node)) { return undefined; } var parameter = ts.createParameterDeclaration( @@ -43256,9 +44527,9 @@ var ts; // While we emit the source map for the node after skipping decorators and modifiers, // we need to emit the comments for the original range. ts.setOriginalNode(parameter, node); - setCommentRange(parameter, node); - setSourceMapRange(parameter, ts.moveRangePastModifiers(node)); - setNodeEmitFlags(parameter.name, 1024 /* NoTrailingSourceMap */); + ts.setCommentRange(parameter, node); + ts.setSourceMapRange(parameter, ts.moveRangePastModifiers(node)); + ts.setEmitFlags(parameter.name, 1024 /* NoTrailingSourceMap */); return parameter; } /** @@ -43351,8 +44622,9 @@ var ts; || compilerOptions.isolatedModules; } function shouldEmitVarForEnumDeclaration(node) { - return !ts.hasModifier(node, 1 /* Export */) - || (isES6ExportedDeclaration(node) && ts.isFirstDeclarationOfKind(node, node.kind)); + return isFirstEmittedDeclarationInScope(node) + && (!ts.hasModifier(node, 1 /* Export */) + || isES6ExportedDeclaration(node)); } /* * Adds a trailing VariableStatement for an enum or module declaration. @@ -43361,7 +44633,7 @@ var ts; var statement = ts.createVariableStatement( /*modifiers*/ undefined, [ts.createVariableDeclaration(getDeclarationName(node), /*type*/ undefined, getExportName(node))]); - setSourceMapRange(statement, node); + ts.setSourceMapRange(statement, node); statements.push(statement); } /** @@ -43382,6 +44654,7 @@ var ts; // If needed, we should emit a variable declaration for the enum. If we emit // a leading variable declaration, we should not emit leading comments for the // enum body. + recordEmittedDeclarationInScope(node); if (shouldEmitVarForEnumDeclaration(node)) { addVarForEnumOrModuleDeclaration(statements, node); // We should still emit the comments if we are emitting a system module. @@ -43407,7 +44680,7 @@ var ts; /*typeArguments*/ undefined, [ts.createLogicalOr(exportName, ts.createAssignment(exportName, ts.createObjectLiteral()))]), /*location*/ node); ts.setOriginalNode(enumStatement, node); - setNodeEmitFlags(enumStatement, emitFlags); + ts.setEmitFlags(enumStatement, emitFlags); statements.push(enumStatement); if (isNamespaceExport(node)) { addVarForEnumExportedFromNamespace(statements, node); @@ -43473,18 +44746,43 @@ var ts; function shouldEmitModuleDeclaration(node) { return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); } - function isModuleMergedWithES6Class(node) { - return languageVersion === 2 /* ES6 */ - && ts.isMergedWithClass(node); - } function isES6ExportedDeclaration(node) { return isExternalModuleExport(node) && moduleKind === ts.ModuleKind.ES6; } + /** + * Records that a declaration was emitted in the current scope, if it was the first + * declaration for the provided symbol. + * + * NOTE: if there is ever a transformation above this one, we may not be able to rely + * on symbol names. + */ + function recordEmittedDeclarationInScope(node) { + var name = node.symbol && node.symbol.name; + if (name) { + if (!currentScopeFirstDeclarationsOfName) { + currentScopeFirstDeclarationsOfName = ts.createMap(); + } + if (!(name in currentScopeFirstDeclarationsOfName)) { + currentScopeFirstDeclarationsOfName[name] = node; + } + } + } + /** + * Determines whether a declaration is the first declaration with the same name emitted + * in the current scope. + */ + function isFirstEmittedDeclarationInScope(node) { + if (currentScopeFirstDeclarationsOfName) { + var name_28 = node.symbol && node.symbol.name; + if (name_28) { + return currentScopeFirstDeclarationsOfName[name_28] === node; + } + } + return false; + } function shouldEmitVarForModuleDeclaration(node) { - return !isModuleMergedWithES6Class(node) - && (!isES6ExportedDeclaration(node) - || ts.isFirstDeclarationOfKind(node, node.kind)); + return isFirstEmittedDeclarationInScope(node); } /** * Adds a leading VariableStatement for a enum or module declaration. @@ -43499,10 +44797,10 @@ var ts; ts.setOriginalNode(statement, /*original*/ node); // Adjust the source map emit to match the old emitter. if (node.kind === 224 /* EnumDeclaration */) { - setSourceMapRange(statement.declarationList, node); + ts.setSourceMapRange(statement.declarationList, node); } else { - setSourceMapRange(statement, node); + ts.setSourceMapRange(statement, node); } // Trailing comments for module declaration should be emitted after the function closure // instead of the variable statement: @@ -43522,8 +44820,8 @@ var ts; // } // })(m1 || (m1 = {})); // trailing comment module // - setCommentRange(statement, node); - setNodeEmitFlags(statement, 32768 /* NoTrailingComments */); + ts.setCommentRange(statement, node); + ts.setEmitFlags(statement, 32768 /* NoTrailingComments */); statements.push(statement); } /** @@ -43546,6 +44844,7 @@ var ts; // If needed, we should emit a variable declaration for the module. If we emit // a leading variable declaration, we should not emit leading comments for the // module body. + recordEmittedDeclarationInScope(node); if (shouldEmitVarForModuleDeclaration(node)) { addVarForEnumOrModuleDeclaration(statements, node); // We should still emit the comments if we are emitting a system module. @@ -43579,7 +44878,7 @@ var ts; /*typeArguments*/ undefined, [moduleArg]), /*location*/ node); ts.setOriginalNode(moduleStatement, node); - setNodeEmitFlags(moduleStatement, emitFlags); + ts.setEmitFlags(moduleStatement, emitFlags); statements.push(moduleStatement); return statements; } @@ -43591,8 +44890,10 @@ var ts; function transformModuleBody(node, namespaceLocalName) { var savedCurrentNamespaceContainerName = currentNamespaceContainerName; var savedCurrentNamespace = currentNamespace; + var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName; currentNamespaceContainerName = namespaceLocalName; currentNamespace = node; + currentScopeFirstDeclarationsOfName = undefined; var statements = []; startLexicalEnvironment(); var statementsLocation; @@ -43619,6 +44920,7 @@ var ts; ts.addRange(statements, endLexicalEnvironment()); currentNamespaceContainerName = savedCurrentNamespaceContainerName; currentNamespace = savedCurrentNamespace; + currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; var block = ts.createBlock(ts.createNodeArray(statements, /*location*/ statementsLocation), /*location*/ blockLocation, @@ -43644,7 +44946,7 @@ var ts; // })(hello || (hello = {})); // We only want to emit comment on the namespace which contains block body itself, not the containing namespaces. if (body.kind !== 226 /* ModuleBlock */) { - setNodeEmitFlags(block, block.emitFlags | 49152 /* NoComments */); + ts.setEmitFlags(block, ts.getEmitFlags(block) | 49152 /* NoComments */); } return block; } @@ -43680,7 +44982,7 @@ var ts; return undefined; } var moduleReference = ts.createExpressionFromEntityName(node.moduleReference); - setNodeEmitFlags(moduleReference, 49152 /* NoComments */ | 65536 /* NoNestedComments */); + ts.setEmitFlags(moduleReference, 49152 /* NoComments */ | 65536 /* NoNestedComments */); if (isNamedExternalModuleExport(node) || !isNamespaceExport(node)) { // export var ${name} = ${moduleReference}; // var ${name} = ${moduleReference}; @@ -43736,9 +45038,9 @@ var ts; } function addExportMemberAssignment(statements, node) { var expression = ts.createAssignment(getExportName(node), getLocalName(node, /*noSourceMaps*/ true)); - setSourceMapRange(expression, ts.createRange(node.name.pos, node.end)); + ts.setSourceMapRange(expression, ts.createRange(node.name.pos, node.end)); var statement = ts.createStatement(expression); - setSourceMapRange(statement, ts.createRange(-1, node.end)); + ts.setSourceMapRange(statement, ts.createRange(-1, node.end)); statements.push(statement); } function createNamespaceExport(exportName, exportValue, location) { @@ -43761,7 +45063,7 @@ var ts; emitFlags |= 1536 /* NoSourceMap */; } if (emitFlags) { - setNodeEmitFlags(qualifiedName, emitFlags); + ts.setEmitFlags(qualifiedName, emitFlags); } return qualifiedName; } @@ -43773,7 +45075,7 @@ var ts; */ function getNamespaceParameterName(node) { var name = ts.getGeneratedNameForNode(node); - setSourceMapRange(name, node.name); + ts.setSourceMapRange(name, node.name); return name; } /** @@ -43822,8 +45124,8 @@ var ts; */ function getDeclarationName(node, allowComments, allowSourceMaps, emitFlags) { if (node.name) { - var name_28 = ts.getMutableClone(node.name); - emitFlags |= getNodeEmitFlags(node.name); + var name_29 = ts.getMutableClone(node.name); + emitFlags |= ts.getEmitFlags(node.name); if (!allowSourceMaps) { emitFlags |= 1536 /* NoSourceMap */; } @@ -43831,9 +45133,9 @@ var ts; emitFlags |= 49152 /* NoComments */; } if (emitFlags) { - setNodeEmitFlags(name_28, emitFlags); + ts.setEmitFlags(name_29, emitFlags); } - return name_28; + return name_29; } else { return ts.getGeneratedNameForNode(node); @@ -43910,7 +45212,7 @@ var ts; * @param node The node to emit. * @param emit A callback used to emit the node in the printer. */ - function onEmitNode(node, emit) { + function onEmitNode(emitContext, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; var savedCurrentSuperContainer = currentSuperContainer; // If we need to support substitutions for `super` in an async method, @@ -43924,7 +45226,7 @@ var ts; if (enabledSubstitutions & 8 /* NonQualifiedEnumMembers */ && isTransformedEnumDeclaration(node)) { applicableSubstitutions |= 8 /* NonQualifiedEnumMembers */; } - previousOnEmitNode(node, emit); + previousOnEmitNode(emitContext, node, emitCallback); applicableSubstitutions = savedApplicableSubstitutions; currentSuperContainer = savedCurrentSuperContainer; } @@ -43935,9 +45237,9 @@ var ts; * @param isExpression A value indicating whether the node is to be used in an expression * position. */ - function onSubstituteNode(node, isExpression) { - node = previousOnSubstituteNode(node, isExpression); - if (isExpression) { + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1 /* Expression */) { return substituteExpression(node); } else if (ts.isShorthandPropertyAssignment(node)) { @@ -43947,16 +45249,16 @@ var ts; } function substituteShorthandPropertyAssignment(node) { if (enabledSubstitutions & 2 /* NamespaceExports */) { - var name_29 = node.name; - var exportedName = trySubstituteNamespaceExportedName(name_29); + var name_30 = node.name; + var exportedName = trySubstituteNamespaceExportedName(name_30); if (exportedName) { // A shorthand property with an assignment initializer is probably part of a // destructuring assignment if (node.objectAssignmentInitializer) { var initializer = ts.createAssignment(exportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name_29, initializer, /*location*/ node); + return ts.createPropertyAssignment(name_30, initializer, /*location*/ node); } - return ts.createPropertyAssignment(name_29, exportedName, /*location*/ node); + return ts.createPropertyAssignment(name_30, exportedName, /*location*/ node); } } return node; @@ -43965,16 +45267,15 @@ var ts; switch (node.kind) { case 69 /* Identifier */: return substituteExpressionIdentifier(node); - } - if (enabledSubstitutions & 4 /* AsyncMethodsWithSuper */) { - switch (node.kind) { - case 174 /* CallExpression */: + case 172 /* PropertyAccessExpression */: + return substitutePropertyAccessExpression(node); + case 173 /* ElementAccessExpression */: + return substituteElementAccessExpression(node); + case 174 /* CallExpression */: + if (enabledSubstitutions & 4 /* AsyncMethodsWithSuper */) { return substituteCallExpression(node); - case 172 /* PropertyAccessExpression */: - return substitutePropertyAccessExpression(node); - case 173 /* ElementAccessExpression */: - return substituteElementAccessExpression(node); - } + } + break; } return node; } @@ -43996,8 +45297,8 @@ var ts; var classAlias = classAliases[declaration.id]; if (classAlias) { var clone_4 = ts.getSynthesizedClone(classAlias); - setSourceMapRange(clone_4, node); - setCommentRange(clone_4, node); + ts.setSourceMapRange(clone_4, node); + ts.setCommentRange(clone_4, node); return clone_4; } } @@ -44007,7 +45308,7 @@ var ts; } function trySubstituteNamespaceExportedName(node) { // If this is explicitly a local name, do not substitute. - if (enabledSubstitutions & applicableSubstitutions && (getNodeEmitFlags(node) & 262144 /* LocalName */) === 0) { + if (enabledSubstitutions & applicableSubstitutions && (ts.getEmitFlags(node) & 262144 /* LocalName */) === 0) { // If we are nested within a namespace declaration, we may need to qualifiy // an identifier that is exported from a merged namespace. var container = resolver.getReferencedExportContainer(node, /*prefixLocals*/ false); @@ -44038,23 +45339,48 @@ var ts; return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 95 /* SuperKeyword */) { + if (enabledSubstitutions & 4 /* AsyncMethodsWithSuper */ && node.expression.kind === 95 /* SuperKeyword */) { var flags = getSuperContainerAsyncMethodFlags(); if (flags) { return createSuperAccessInAsyncMethod(ts.createLiteral(node.name.text), flags, node); } } - return node; + return substituteConstantValue(node); } function substituteElementAccessExpression(node) { - if (node.expression.kind === 95 /* SuperKeyword */) { + if (enabledSubstitutions & 4 /* AsyncMethodsWithSuper */ && node.expression.kind === 95 /* SuperKeyword */) { var flags = getSuperContainerAsyncMethodFlags(); if (flags) { return createSuperAccessInAsyncMethod(node.argumentExpression, flags, node); } } + return substituteConstantValue(node); + } + function substituteConstantValue(node) { + var constantValue = tryGetConstEnumValue(node); + if (constantValue !== undefined) { + var substitute = ts.createLiteral(constantValue); + ts.setSourceMapRange(substitute, node); + ts.setCommentRange(substitute, node); + if (!compilerOptions.removeComments) { + var propertyName = ts.isPropertyAccessExpression(node) + ? ts.declarationNameToString(node.name) + : ts.getTextOfNode(node.argumentExpression); + substitute.trailingComment = " " + propertyName + " "; + } + ts.setConstantValue(node, constantValue); + return substitute; + } return node; } + function tryGetConstEnumValue(node) { + if (compilerOptions.isolatedModules) { + return undefined; + } + return ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node) + ? resolver.getConstantValue(node) + : undefined; + } function createSuperAccessInAsyncMethod(argumentExpression, flags, location) { if (flags & 4096 /* AsyncMethodWithSuperBinding */) { return ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), @@ -44083,6 +45409,9 @@ var ts; var currentSourceFile; return transformSourceFile; function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { currentSourceFile = node; return ts.visitEachChild(node, visitor, context); @@ -44201,7 +45530,7 @@ var ts; var ts; (function (ts) { function transformSystemModule(context) { - var getNodeEmitFlags = context.getNodeEmitFlags, setNodeEmitFlags = context.setNodeEmitFlags, startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration, hoistFunctionDeclaration = context.hoistFunctionDeclaration; + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration, hoistFunctionDeclaration = context.hoistFunctionDeclaration; var compilerOptions = context.getCompilerOptions(); var resolver = context.getEmitResolver(); var host = context.getEmitHost(); @@ -44230,6 +45559,9 @@ var ts; var currentNode; return transformSourceFile; function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { currentSourceFile = node; currentNode = node; @@ -44283,7 +45615,7 @@ var ts; ts.createParameter(exportFunctionForFile), ts.createParameter(contextObjectForFile) ], - /*type*/ undefined, setNodeEmitFlags(ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true), 1 /* EmitEmitHelpers */)); + /*type*/ undefined, ts.setEmitFlags(ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true), 1 /* EmitEmitHelpers */)); // Write the call to `System.register` // Clear the emit-helpers flag for later passes since we'll have already used it in the module body // So the helper will be emit at the correct position instead of at the top of the source-file @@ -44292,7 +45624,7 @@ var ts; /*typeArguments*/ undefined, moduleName ? [moduleName, dependencies, body] : [dependencies, body])) - ], /*nodeEmitFlags*/ ~1 /* EmitEmitHelpers */ & getNodeEmitFlags(node)); + ], /*nodeEmitFlags*/ ~1 /* EmitEmitHelpers */ & ts.getEmitFlags(node)); var _a; } /** @@ -44676,17 +46008,17 @@ var ts; function visitFunctionDeclaration(node) { if (ts.hasModifier(node, 1 /* Export */)) { // If the function is exported, ensure it has a name and rewrite the function without any export flags. - var name_30 = node.name || ts.getGeneratedNameForNode(node); + var name_31 = node.name || ts.getGeneratedNameForNode(node); var newNode = ts.createFunctionDeclaration( /*decorators*/ undefined, - /*modifiers*/ undefined, node.asteriskToken, name_30, + /*modifiers*/ undefined, node.asteriskToken, name_31, /*typeParameters*/ undefined, node.parameters, /*type*/ undefined, node.body, /*location*/ node); // Record a declaration export in the outer module body function. recordExportedFunctionDeclaration(node); if (!ts.hasModifier(node, 512 /* Default */)) { - recordExportName(name_30); + recordExportName(name_31); } ts.setOriginalNode(newNode, node); node = newNode; @@ -44698,16 +46030,16 @@ var ts; function visitExpressionStatement(node) { var originalNode = ts.getOriginalNode(node); if ((originalNode.kind === 225 /* ModuleDeclaration */ || originalNode.kind === 224 /* EnumDeclaration */) && ts.hasModifier(originalNode, 1 /* Export */)) { - var name_31 = getDeclarationName(originalNode); + var name_32 = getDeclarationName(originalNode); // We only need to hoistVariableDeclaration for EnumDeclaration // as ModuleDeclaration is already hoisted when the transformer call visitVariableStatement // which then call transformsVariable for each declaration in declarationList if (originalNode.kind === 224 /* EnumDeclaration */) { - hoistVariableDeclaration(name_31); + hoistVariableDeclaration(name_32); } return [ node, - createExportStatement(name_31, name_31) + createExportStatement(name_32, name_32) ]; } return node; @@ -44952,14 +46284,14 @@ var ts; // // Substitutions // - function onEmitNode(node, emit) { + function onEmitNode(emitContext, node, emitCallback) { if (node.kind === 256 /* SourceFile */) { exportFunctionForFile = exportFunctionForFileMap[ts.getOriginalNodeId(node)]; - previousOnEmitNode(node, emit); + previousOnEmitNode(emitContext, node, emitCallback); exportFunctionForFile = undefined; } else { - previousOnEmitNode(node, emit); + previousOnEmitNode(emitContext, node, emitCallback); } } /** @@ -44969,9 +46301,9 @@ var ts; * @param isExpression A value indicating whether the node is to be used in an expression * position. */ - function onSubstituteNode(node, isExpression) { - node = previousOnSubstituteNode(node, isExpression); - if (isExpression) { + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1 /* Expression */) { return substituteExpression(node); } return node; @@ -45013,7 +46345,7 @@ var ts; return node; } function substituteAssignmentExpression(node) { - setNodeEmitFlags(node, 128 /* NoSubstitution */); + ts.setEmitFlags(node, 128 /* NoSubstitution */); var left = node.left; switch (left.kind) { case 69 /* Identifier */: @@ -45118,7 +46450,7 @@ var ts; var exportDeclaration = resolver.getReferencedExportContainer(operand); if (exportDeclaration) { var expr = ts.createPrefix(node.operator, operand, node); - setNodeEmitFlags(expr, 128 /* NoSubstitution */); + ts.setEmitFlags(expr, 128 /* NoSubstitution */); var call = createExportExpression(operand, expr); if (node.kind === 185 /* PrefixUnaryExpression */) { return call; @@ -45165,7 +46497,7 @@ var ts; ts.createForIn(ts.createVariableDeclarationList([ ts.createVariableDeclaration(n, /*type*/ undefined) ]), m, ts.createBlock([ - setNodeEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 32 /* SingleLine */) + ts.setEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 32 /* SingleLine */) ])), ts.createStatement(ts.createCall(exportFunctionForFile, /*typeArguments*/ undefined, [exports])) @@ -45283,7 +46615,7 @@ var ts; function updateSourceFile(node, statements, nodeEmitFlags) { var updated = ts.getMutableClone(node); updated.statements = ts.createNodeArray(statements, node.statements); - setNodeEmitFlags(updated, nodeEmitFlags); + ts.setEmitFlags(updated, nodeEmitFlags); return updated; } } @@ -45301,7 +46633,7 @@ var ts; _a[ts.ModuleKind.AMD] = transformAMDModule, _a[ts.ModuleKind.UMD] = transformUMDModule, _a)); - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration, setNodeEmitFlags = context.setNodeEmitFlags, getNodeEmitFlags = context.getNodeEmitFlags, setSourceMapRange = context.setSourceMapRange; + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var compilerOptions = context.getCompilerOptions(); var resolver = context.getEmitResolver(); var host = context.getEmitHost(); @@ -45333,6 +46665,9 @@ var ts; * @param node The SourceFile node. */ function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { currentSourceFile = node; // Collect information about the external module. @@ -45365,7 +46700,7 @@ var ts; addExportEqualsIfNeeded(statements, /*emitAsReturn*/ false); var updated = updateSourceFile(node, statements); if (hasExportStarsToExportValues) { - setNodeEmitFlags(updated, 2 /* EmitExportStar */ | getNodeEmitFlags(node)); + ts.setEmitFlags(updated, 2 /* EmitExportStar */ | ts.getEmitFlags(node)); } return updated; } @@ -45386,7 +46721,7 @@ var ts; */ function transformUMDModule(node) { var define = ts.createIdentifier("define"); - setNodeEmitFlags(define, 16 /* UMDDefine */); + ts.setEmitFlags(define, 16 /* UMDDefine */); return transformAsynchronousModule(node, define, /*moduleName*/ undefined, /*includeNonAmdDependencies*/ false); } /** @@ -45466,7 +46801,7 @@ var ts; if (hasExportStarsToExportValues) { // If we have any `export * from ...` declarations // we need to inform the emitter to add the __export helper. - setNodeEmitFlags(body, 2 /* EmitExportStar */); + ts.setEmitFlags(body, 2 /* EmitExportStar */); } return body; } @@ -45475,13 +46810,13 @@ var ts; if (emitAsReturn) { var statement = ts.createReturn(exportEquals.expression, /*location*/ exportEquals); - setNodeEmitFlags(statement, 12288 /* NoTokenSourceMaps */ | 49152 /* NoComments */); + ts.setEmitFlags(statement, 12288 /* NoTokenSourceMaps */ | 49152 /* NoComments */); statements.push(statement); } else { var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), exportEquals.expression), /*location*/ exportEquals); - setNodeEmitFlags(statement, 49152 /* NoComments */); + ts.setEmitFlags(statement, 49152 /* NoComments */); statements.push(statement); } } @@ -45574,7 +46909,7 @@ var ts; } // Set emitFlags on the name of the importEqualsDeclaration // This is so the printer will not substitute the identifier - setNodeEmitFlags(node.name, 128 /* NoSubstitution */); + ts.setEmitFlags(node.name, 128 /* NoSubstitution */); var statements = []; if (moduleKind !== ts.ModuleKind.AMD) { if (ts.hasModifier(node, 1 /* Export */)) { @@ -45678,16 +47013,16 @@ var ts; else { var names = ts.reduceEachChild(node, collectExportMembers, []); for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_32 = names_1[_i]; - addExportMemberAssignments(statements, name_32); + var name_33 = names_1[_i]; + addExportMemberAssignments(statements, name_33); } } } function collectExportMembers(names, node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node) && ts.isDeclaration(node)) { - var name_33 = node.name; - if (ts.isIdentifier(name_33)) { - names.push(name_33); + var name_34 = node.name; + if (ts.isIdentifier(name_34)) { + names.push(name_34); } } return ts.reduceEachChild(node, collectExportMembers, names); @@ -45706,7 +47041,7 @@ var ts; addExportDefault(statements, getDeclarationName(node), /*location*/ node); } else { - statements.push(createExportStatement(node.name, setNodeEmitFlags(ts.getSynthesizedClone(node.name), 262144 /* LocalName */), /*location*/ node)); + statements.push(createExportStatement(node.name, ts.setEmitFlags(ts.getSynthesizedClone(node.name), 262144 /* LocalName */), /*location*/ node)); } } function visitVariableStatement(node) { @@ -45856,20 +47191,20 @@ var ts; /*modifiers*/ undefined, [ts.createVariableDeclaration(getDeclarationName(node), /*type*/ undefined, ts.createPropertyAccess(ts.createIdentifier("exports"), getDeclarationName(node)))], /*location*/ node); - setNodeEmitFlags(transformedStatement, 49152 /* NoComments */); + ts.setEmitFlags(transformedStatement, 49152 /* NoComments */); statements.push(transformedStatement); } function getDeclarationName(node) { return node.name ? ts.getSynthesizedClone(node.name) : ts.getGeneratedNameForNode(node); } - function onEmitNode(node, emit) { + function onEmitNode(emitContext, node, emitCallback) { if (node.kind === 256 /* SourceFile */) { bindingNameExportSpecifiersMap = bindingNameExportSpecifiersForFileMap[ts.getOriginalNodeId(node)]; - previousOnEmitNode(node, emit); + previousOnEmitNode(emitContext, node, emitCallback); bindingNameExportSpecifiersMap = undefined; } else { - previousOnEmitNode(node, emit); + previousOnEmitNode(emitContext, node, emitCallback); } } /** @@ -45879,9 +47214,9 @@ var ts; * @param isExpression A value indicating whether the node is to be used in an expression * position. */ - function onSubstituteNode(node, isExpression) { - node = previousOnSubstituteNode(node, isExpression); - if (isExpression) { + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1 /* Expression */) { return substituteExpression(node); } else if (ts.isShorthandPropertyAssignment(node)) { @@ -45925,7 +47260,7 @@ var ts; // If the left-hand-side of the binaryExpression is an identifier and its is export through export Specifier if (ts.isIdentifier(left) && ts.isAssignmentOperator(node.operatorToken.kind)) { if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, left.text)) { - setNodeEmitFlags(node, 128 /* NoSubstitution */); + ts.setEmitFlags(node, 128 /* NoSubstitution */); var nestedExportAssignment = void 0; for (var _i = 0, _a = bindingNameExportSpecifiersMap[left.text]; _i < _a.length; _i++) { var specifier = _a[_i]; @@ -45945,13 +47280,13 @@ var ts; var operand = node.operand; if (ts.isIdentifier(operand) && bindingNameExportSpecifiersForFileMap) { if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, operand.text)) { - setNodeEmitFlags(node, 128 /* NoSubstitution */); + ts.setEmitFlags(node, 128 /* NoSubstitution */); var transformedUnaryExpression = void 0; if (node.kind === 186 /* PostfixUnaryExpression */) { - transformedUnaryExpression = ts.createBinary(operand, ts.createNode(operator === 41 /* PlusPlusToken */ ? 57 /* PlusEqualsToken */ : 58 /* MinusEqualsToken */), ts.createLiteral(1), + transformedUnaryExpression = ts.createBinary(operand, ts.createToken(operator === 41 /* PlusPlusToken */ ? 57 /* PlusEqualsToken */ : 58 /* MinusEqualsToken */), ts.createLiteral(1), /*location*/ node); // We have to set no substitution flag here to prevent visit the binary expression and substitute it again as we will preform all necessary substitution in here - setNodeEmitFlags(transformedUnaryExpression, 128 /* NoSubstitution */); + ts.setEmitFlags(transformedUnaryExpression, 128 /* NoSubstitution */); } var nestedExportAssignment = void 0; for (var _i = 0, _a = bindingNameExportSpecifiersMap[operand.text]; _i < _a.length; _i++) { @@ -45966,7 +47301,7 @@ var ts; return node; } function trySubstituteExportedName(node) { - var emitFlags = getNodeEmitFlags(node); + var emitFlags = ts.getEmitFlags(node); if ((emitFlags & 262144 /* LocalName */) === 0) { var container = resolver.getReferencedExportContainer(node, (emitFlags & 131072 /* ExportName */) !== 0); if (container) { @@ -45979,7 +47314,7 @@ var ts; return undefined; } function trySubstituteImportedName(node) { - if ((getNodeEmitFlags(node) & 262144 /* LocalName */) === 0) { + if ((ts.getEmitFlags(node) & 262144 /* LocalName */) === 0) { var declaration = resolver.getReferencedImportDeclaration(node); if (declaration) { if (ts.isImportClause(declaration)) { @@ -45994,14 +47329,14 @@ var ts; } } else if (ts.isImportSpecifier(declaration)) { - var name_34 = declaration.propertyName || declaration.name; - if (name_34.originalKeywordKind === 77 /* DefaultKeyword */ && languageVersion <= 0 /* ES3 */) { + var name_35 = declaration.propertyName || declaration.name; + if (name_35.originalKeywordKind === 77 /* DefaultKeyword */ && languageVersion <= 0 /* ES3 */) { // TODO: ES3 transform to handle x.default -> x["default"] - return ts.createElementAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.createLiteral(name_34.text), + return ts.createElementAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.createLiteral(name_35.text), /*location*/ node); } else { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.getSynthesizedClone(name_34), + return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.getSynthesizedClone(name_35), /*location*/ node); } } @@ -46025,7 +47360,7 @@ var ts; var statement = ts.createStatement(createExportAssignment(name, value)); statement.startsOnNewLine = true; if (location) { - setSourceMapRange(statement, location); + ts.setSourceMapRange(statement, location); } return statement; } @@ -46063,7 +47398,7 @@ var ts; if (includeNonAmdDependencies && importAliasName) { // Set emitFlags on the name of the classDeclaration // This is so that when printer will not substitute the identifier - setNodeEmitFlags(importAliasName, 128 /* NoSubstitution */); + ts.setEmitFlags(importAliasName, 128 /* NoSubstitution */); aliasedModuleNames.push(externalModuleName); importAliasNames.push(ts.createParameter(importAliasName)); } @@ -46098,6 +47433,9 @@ var ts; * @param node A SourceFile node. */ function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } currentSourceFile = node; node = ts.visitEachChild(node, visitor, context); currentSourceFile = undefined; @@ -46280,12 +47618,12 @@ var ts; return getTagName(node.openingElement); } else { - var name_35 = node.tagName; - if (ts.isIdentifier(name_35) && ts.isIntrinsicJsxName(name_35.text)) { - return ts.createLiteral(name_35.text); + var name_36 = node.tagName; + if (ts.isIdentifier(name_36) && ts.isIntrinsicJsxName(name_36.text)) { + return ts.createLiteral(name_36.text); } else { - return ts.createExpressionFromEntityName(name_35); + return ts.createExpressionFromEntityName(name_36); } } } @@ -46575,6 +47913,9 @@ var ts; var hoistVariableDeclaration = context.hoistVariableDeclaration; return transformSourceFile; function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } return ts.visitEachChild(node, visitor, context); } function visitor(node) { @@ -46820,7 +48161,7 @@ var ts; _a[7 /* Endfinally */] = "endfinally", _a)); function transformGenerators(context) { - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistFunctionDeclaration = context.hoistFunctionDeclaration, hoistVariableDeclaration = context.hoistVariableDeclaration, setSourceMapRange = context.setSourceMapRange, setCommentRange = context.setCommentRange, setNodeEmitFlags = context.setNodeEmitFlags; + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistFunctionDeclaration = context.hoistFunctionDeclaration, hoistVariableDeclaration = context.hoistVariableDeclaration; var compilerOptions = context.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var resolver = context.getEmitResolver(); @@ -46870,6 +48211,9 @@ var ts; var withBlockStack; // A stack containing `with` blocks. return transformSourceFile; function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } if (node.transformFlags & 1024 /* ContainsGenerator */) { currentSourceFile = node; node = ts.visitEachChild(node, visitor, context); @@ -47011,7 +48355,7 @@ var ts; */ function visitFunctionDeclaration(node) { // Currently, we only support generators that were originally async functions. - if (node.asteriskToken && node.emitFlags & 2097152 /* AsyncFunctionBody */) { + if (node.asteriskToken && ts.getEmitFlags(node) & 2097152 /* AsyncFunctionBody */) { node = ts.setOriginalNode(ts.createFunctionDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -47050,7 +48394,7 @@ var ts; */ function visitFunctionExpression(node) { // Currently, we only support generators that were originally async functions. - if (node.asteriskToken && node.emitFlags & 2097152 /* AsyncFunctionBody */) { + if (node.asteriskToken && ts.getEmitFlags(node) & 2097152 /* AsyncFunctionBody */) { node = ts.setOriginalNode(ts.createFunctionExpression( /*asteriskToken*/ undefined, node.name, /*typeParameters*/ undefined, node.parameters, @@ -47099,6 +48443,7 @@ var ts; var savedBlocks = blocks; var savedBlockOffsets = blockOffsets; var savedBlockActions = blockActions; + var savedBlockStack = blockStack; var savedLabelOffsets = labelOffsets; var savedLabelExpressions = labelExpressions; var savedNextLabelId = nextLabelId; @@ -47112,6 +48457,7 @@ var ts; blocks = undefined; blockOffsets = undefined; blockActions = undefined; + blockStack = undefined; labelOffsets = undefined; labelExpressions = undefined; nextLabelId = 1; @@ -47132,6 +48478,7 @@ var ts; blocks = savedBlocks; blockOffsets = savedBlockOffsets; blockActions = savedBlockActions; + blockStack = savedBlockStack; labelOffsets = savedLabelOffsets; labelExpressions = savedLabelExpressions; nextLabelId = savedNextLabelId; @@ -47156,7 +48503,7 @@ var ts; } else { // Do not hoist custom prologues. - if (node.emitFlags & 8388608 /* CustomPrologue */) { + if (ts.getEmitFlags(node) & 8388608 /* CustomPrologue */) { return node; } for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { @@ -48202,9 +49549,9 @@ var ts; } return -1; } - function onSubstituteNode(node, isExpression) { - node = previousOnSubstituteNode(node, isExpression); - if (isExpression) { + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1 /* Expression */) { return substituteExpression(node); } return node; @@ -48221,11 +49568,11 @@ var ts; if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - var name_36 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); - if (name_36) { - var clone_7 = ts.getMutableClone(name_36); - setSourceMapRange(clone_7, node); - setCommentRange(clone_7, node); + var name_37 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); + if (name_37) { + var clone_7 = ts.getMutableClone(name_37); + ts.setSourceMapRange(clone_7, node); + ts.setCommentRange(clone_7, node); return clone_7; } } @@ -48815,7 +50162,7 @@ var ts; return ts.createCall(ts.createHelperName(currentSourceFile.externalHelpersModuleName, "__generator"), /*typeArguments*/ undefined, [ ts.createThis(), - setNodeEmitFlags(ts.createFunctionExpression( + ts.setEmitFlags(ts.createFunctionExpression( /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, [ts.createParameter(state)], @@ -49218,8 +50565,32 @@ var ts; Jump[Jump["Continue"] = 4] = "Continue"; Jump[Jump["Return"] = 8] = "Return"; })(Jump || (Jump = {})); + var SuperCaptureResult; + (function (SuperCaptureResult) { + /** + * A capture may have been added for calls to 'super', but + * the caller should emit subsequent statements normally. + */ + SuperCaptureResult[SuperCaptureResult["NoReplacement"] = 0] = "NoReplacement"; + /** + * A call to 'super()' got replaced with a capturing statement like: + * + * var _this = _super.call(...) || this; + * + * Callers should skip the current statement. + */ + SuperCaptureResult[SuperCaptureResult["ReplaceSuperCapture"] = 1] = "ReplaceSuperCapture"; + /** + * A call to 'super()' got replaced with a capturing statement like: + * + * return _super.call(...) || this; + * + * Callers should skip the current statement and avoid any returns of '_this'. + */ + SuperCaptureResult[SuperCaptureResult["ReplaceWithReturn"] = 2] = "ReplaceWithReturn"; + })(SuperCaptureResult || (SuperCaptureResult = {})); function transformES6(context) { - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration, getNodeEmitFlags = context.getNodeEmitFlags, setNodeEmitFlags = context.setNodeEmitFlags, getCommentRange = context.getCommentRange, setCommentRange = context.setCommentRange, getSourceMapRange = context.getSourceMapRange, setSourceMapRange = context.setSourceMapRange, setTokenSourceMapRange = context.setTokenSourceMapRange; + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); var previousOnSubstituteNode = context.onSubstituteNode; var previousOnEmitNode = context.onEmitNode; @@ -49247,6 +50618,9 @@ var ts; var enabledSubstitutions; return transformSourceFile; function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } currentSourceFile = node; currentText = node.text; return ts.visitNode(node, visitor, ts.isSourceFile); @@ -49418,7 +50792,7 @@ var ts; enclosingFunction = currentNode; if (currentNode.kind !== 180 /* ArrowFunction */) { enclosingNonArrowFunction = currentNode; - if (!(currentNode.emitFlags & 2097152 /* AsyncFunctionBody */)) { + if (!(ts.getEmitFlags(currentNode) & 2097152 /* AsyncFunctionBody */)) { enclosingNonAsyncFunctionBody = currentNode; } } @@ -49634,17 +51008,17 @@ var ts; // To preserve the behavior of the old emitter, we explicitly indent // the body of the function here if it was requested in an earlier // transformation. - if (getNodeEmitFlags(node) & 524288 /* Indented */) { - setNodeEmitFlags(classFunction, 524288 /* Indented */); + if (ts.getEmitFlags(node) & 524288 /* Indented */) { + ts.setEmitFlags(classFunction, 524288 /* Indented */); } // "inner" and "outer" below are added purely to preserve source map locations from // the old emitter var inner = ts.createPartiallyEmittedExpression(classFunction); inner.end = node.end; - setNodeEmitFlags(inner, 49152 /* NoComments */); + ts.setEmitFlags(inner, 49152 /* NoComments */); var outer = ts.createPartiallyEmittedExpression(inner); outer.end = ts.skipTrivia(currentText, node.pos); - setNodeEmitFlags(outer, 49152 /* NoComments */); + ts.setEmitFlags(outer, 49152 /* NoComments */); return ts.createParen(ts.createCall(outer, /*typeArguments*/ undefined, extendsClauseElement ? [ts.visitNode(extendsClauseElement.expression, visitor, ts.isExpression)] @@ -49669,14 +51043,14 @@ var ts; // emit with the original emitter. var outer = ts.createPartiallyEmittedExpression(localName); outer.end = closingBraceLocation.end; - setNodeEmitFlags(outer, 49152 /* NoComments */); + ts.setEmitFlags(outer, 49152 /* NoComments */); var statement = ts.createReturn(outer); statement.pos = closingBraceLocation.pos; - setNodeEmitFlags(statement, 49152 /* NoComments */ | 12288 /* NoTokenSourceMaps */); + ts.setEmitFlags(statement, 49152 /* NoComments */ | 12288 /* NoTokenSourceMaps */); statements.push(statement); ts.addRange(statements, endLexicalEnvironment()); var block = ts.createBlock(ts.createNodeArray(statements, /*location*/ node.members), /*location*/ undefined, /*multiLine*/ true); - setNodeEmitFlags(block, 49152 /* NoComments */); + ts.setEmitFlags(block, 49152 /* NoComments */); return block; } /** @@ -49702,13 +51076,17 @@ var ts; function addConstructor(statements, node, extendsClauseElement) { var constructor = ts.getFirstConstructorWithBody(node); var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); - statements.push(ts.createFunctionDeclaration( + var constructorFunction = ts.createFunctionDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, /*asteriskToken*/ undefined, getDeclarationName(node), /*typeParameters*/ undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), /*type*/ undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), - /*location*/ constructor || node)); + /*location*/ constructor || node); + if (extendsClauseElement) { + ts.setEmitFlags(constructorFunction, 256 /* CapturesThis */); + } + statements.push(constructorFunction); } /** * Transforms the parameters of the constructor declaration of a class. @@ -49740,51 +51118,146 @@ var ts; function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { var statements = []; startLexicalEnvironment(); + var statementOffset = -1; + if (hasSynthesizedSuper) { + // If a super call has already been synthesized, + // we're going to assume that we should just transform everything after that. + // The assumption is that no prior step in the pipeline has added any prologue directives. + statementOffset = 1; + } + else if (constructor) { + // Otherwise, try to emit all potential prologue directives first. + statementOffset = ts.addPrologueDirectives(statements, constructor.body.statements, /*ensureUseStrict*/ false, visitor); + } if (constructor) { - addCaptureThisForNodeIfNeeded(statements, constructor); addDefaultValueAssignmentsIfNeeded(statements, constructor); addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); + ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); + } + var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, !!extendsClauseElement, hasSynthesizedSuper, statementOffset); + // The last statement expression was replaced. Skip it. + if (superCaptureStatus === 1 /* ReplaceSuperCapture */ || superCaptureStatus === 2 /* ReplaceWithReturn */) { + statementOffset++; } - addDefaultSuperCallIfNeeded(statements, constructor, extendsClauseElement, hasSynthesizedSuper); if (constructor) { - var body = saveStateAndInvoke(constructor, hasSynthesizedSuper ? transformConstructorBodyWithSynthesizedSuper : transformConstructorBodyWithoutSynthesizedSuper); + var body = saveStateAndInvoke(constructor, function (constructor) { return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, /*start*/ statementOffset); }); ts.addRange(statements, body); } + // Return `_this` unless we're sure enough that it would be pointless to add a return statement. + // If there's a constructor that we can tell returns in enough places, then we *do not* want to add a return. + if (extendsClauseElement + && superCaptureStatus !== 2 /* ReplaceWithReturn */ + && !(constructor && isSufficientlyCoveredByReturnStatements(constructor.body))) { + statements.push(ts.createReturn(ts.createIdentifier("_this"))); + } ts.addRange(statements, endLexicalEnvironment()); var block = ts.createBlock(ts.createNodeArray(statements, /*location*/ constructor ? constructor.body.statements : node.members), /*location*/ constructor ? constructor.body : node, /*multiLine*/ true); if (!constructor) { - setNodeEmitFlags(block, 49152 /* NoComments */); + ts.setEmitFlags(block, 49152 /* NoComments */); } return block; } - function transformConstructorBodyWithSynthesizedSuper(node) { - return ts.visitNodes(node.body.statements, visitor, ts.isStatement, 1); - } - function transformConstructorBodyWithoutSynthesizedSuper(node) { - return ts.visitNodes(node.body.statements, visitor, ts.isStatement, 0); + /** + * We want to try to avoid emitting a return statement in certain cases if a user already returned something. + * It would generate obviously dead code, so we'll try to make things a little bit prettier + * by doing a minimal check on whether some common patterns always explicitly return. + */ + function isSufficientlyCoveredByReturnStatements(statement) { + // A return statement is considered covered. + if (statement.kind === 211 /* ReturnStatement */) { + return true; + } + else if (statement.kind === 203 /* IfStatement */) { + var ifStatement = statement; + if (ifStatement.elseStatement) { + return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && + isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); + } + } + else if (statement.kind === 199 /* Block */) { + var lastStatement = ts.lastOrUndefined(statement.statements); + if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { + return true; + } + } + return false; } /** - * Adds a synthesized call to `_super` if it is needed. + * Declares a `_this` variable for derived classes and for when arrow functions capture `this`. * - * @param statements The statements for the new constructor body. - * @param constructor The constructor for the class. - * @param extendsClauseElement The expression for the class `extends` clause. - * @param hasSynthesizedSuper A value indicating whether the constructor starts with a - * synthesized `super` call. + * @returns The new statement offset into the `statements` array. */ - function addDefaultSuperCallIfNeeded(statements, constructor, extendsClauseElement, hasSynthesizedSuper) { - // If the TypeScript transformer needed to synthesize a constructor for property - // initializers, it would have also added a synthetic `...args` parameter and - // `super` call. - // If this is the case, or if the class has an `extends` clause but no - // constructor, we emit a synthesized call to `_super`. - if (constructor ? hasSynthesizedSuper : extendsClauseElement) { - statements.push(ts.createStatement(ts.createFunctionApply(ts.createIdentifier("_super"), ts.createThis(), ts.createIdentifier("arguments")), - /*location*/ extendsClauseElement)); + function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, hasExtendsClause, hasSynthesizedSuper, statementOffset) { + // If this isn't a derived class, just capture 'this' for arrow functions if necessary. + if (!hasExtendsClause) { + if (ctor) { + addCaptureThisForNodeIfNeeded(statements, ctor); + } + return 0 /* NoReplacement */; } + // We must be here because the user didn't write a constructor + // but we needed to call 'super(...args)' anyway as per 14.5.14 of the ES2016 spec. + // If that's the case we can just immediately return the result of a 'super()' call. + if (!ctor) { + statements.push(ts.createReturn(createDefaultSuperCallOrThis())); + return 2 /* ReplaceWithReturn */; + } + // The constructor exists, but it and the 'super()' call it contains were generated + // for something like property initializers. + // Create a captured '_this' variable and assume it will subsequently be used. + if (hasSynthesizedSuper) { + captureThisForNode(statements, ctor, createDefaultSuperCallOrThis()); + enableSubstitutionsForCapturedThis(); + return 1 /* ReplaceSuperCapture */; + } + // Most of the time, a 'super' call will be the first real statement in a constructor body. + // In these cases, we'd like to transform these into a *single* statement instead of a declaration + // followed by an assignment statement for '_this'. For instance, if we emitted without an initializer, + // we'd get: + // + // var _this; + // _this = _super.call(...) || this; + // + // instead of + // + // var _this = _super.call(...) || this; + // + // Additionally, if the 'super()' call is the last statement, we should just avoid capturing + // entirely and immediately return the result like so: + // + // return _super.call(...) || this; + // + var firstStatement; + var superCallExpression; + var ctorStatements = ctor.body.statements; + if (statementOffset < ctorStatements.length) { + firstStatement = ctorStatements[statementOffset]; + if (firstStatement.kind === 202 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { + var superCall = firstStatement.expression; + superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); + } + } + // Return the result if we have an immediate super() call on the last statement. + if (superCallExpression && statementOffset === ctorStatements.length - 1) { + statements.push(ts.createReturn(superCallExpression)); + return 2 /* ReplaceWithReturn */; + } + // Perform the capture. + captureThisForNode(statements, ctor, superCallExpression, firstStatement); + // If we're actually replacing the original statement, we need to signal this to the caller. + if (superCallExpression) { + return 1 /* ReplaceSuperCapture */; + } + return 0 /* NoReplacement */; + } + function createDefaultSuperCallOrThis() { + var actualThis = ts.createThis(); + ts.setEmitFlags(actualThis, 128 /* NoSubstitution */); + var superCall = ts.createFunctionApply(ts.createIdentifier("_super"), actualThis, ts.createIdentifier("arguments")); + return ts.createLogicalOr(superCall, actualThis); } /** * Visits a parameter declaration. @@ -49837,17 +51310,17 @@ var ts; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { var parameter = _a[_i]; - var name_37 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; + var name_38 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; // A rest parameter cannot have a binding pattern or an initializer, // so let's just ignore it. if (dotDotDotToken) { continue; } - if (ts.isBindingPattern(name_37)) { - addDefaultValueAssignmentForBindingPattern(statements, parameter, name_37, initializer); + if (ts.isBindingPattern(name_38)) { + addDefaultValueAssignmentForBindingPattern(statements, parameter, name_38, initializer); } else if (initializer) { - addDefaultValueAssignmentForInitializer(statements, parameter, name_37, initializer); + addDefaultValueAssignmentForInitializer(statements, parameter, name_38, initializer); } } } @@ -49865,11 +51338,11 @@ var ts; // we usually don't want to emit a var declaration; however, in the presence // of an initializer, we must emit that expression to preserve side effects. if (name.elements.length > 0) { - statements.push(setNodeEmitFlags(ts.createVariableStatement( + statements.push(ts.setEmitFlags(ts.createVariableStatement( /*modifiers*/ undefined, ts.createVariableDeclarationList(ts.flattenParameterDestructuring(context, parameter, temp, visitor))), 8388608 /* CustomPrologue */)); } else if (initializer) { - statements.push(setNodeEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 8388608 /* CustomPrologue */)); + statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 8388608 /* CustomPrologue */)); } } /** @@ -49882,14 +51355,14 @@ var ts; */ function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) { initializer = ts.visitNode(initializer, visitor, ts.isExpression); - var statement = ts.createIf(ts.createStrictEquality(ts.getSynthesizedClone(name), ts.createVoidZero()), setNodeEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(setNodeEmitFlags(ts.getMutableClone(name), 1536 /* NoSourceMap */), setNodeEmitFlags(initializer, 1536 /* NoSourceMap */ | getNodeEmitFlags(initializer)), + var statement = ts.createIf(ts.createStrictEquality(ts.getSynthesizedClone(name), ts.createVoidZero()), ts.setEmitFlags(ts.createBlock([ + ts.createStatement(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 1536 /* NoSourceMap */), ts.setEmitFlags(initializer, 1536 /* NoSourceMap */ | ts.getEmitFlags(initializer)), /*location*/ parameter)) ], /*location*/ parameter), 32 /* SingleLine */ | 1024 /* NoTrailingSourceMap */ | 12288 /* NoTokenSourceMaps */), /*elseStatement*/ undefined, /*location*/ parameter); statement.startsOnNewLine = true; - setNodeEmitFlags(statement, 12288 /* NoTokenSourceMaps */ | 1024 /* NoTrailingSourceMap */ | 8388608 /* CustomPrologue */); + ts.setEmitFlags(statement, 12288 /* NoTokenSourceMaps */ | 1024 /* NoTrailingSourceMap */ | 8388608 /* CustomPrologue */); statements.push(statement); } /** @@ -49919,13 +51392,13 @@ var ts; } // `declarationName` is the name of the local declaration for the parameter. var declarationName = ts.getMutableClone(parameter.name); - setNodeEmitFlags(declarationName, 1536 /* NoSourceMap */); + ts.setEmitFlags(declarationName, 1536 /* NoSourceMap */); // `expressionName` is the name of the parameter used in expressions. var expressionName = ts.getSynthesizedClone(parameter.name); var restIndex = node.parameters.length - 1; var temp = ts.createLoopVariable(); // var param = []; - statements.push(setNodeEmitFlags(ts.createVariableStatement( + statements.push(ts.setEmitFlags(ts.createVariableStatement( /*modifiers*/ undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration(declarationName, /*type*/ undefined, ts.createArrayLiteral([])) @@ -49941,7 +51414,7 @@ var ts; ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp)), /*location*/ parameter)) ])); - setNodeEmitFlags(forStatement, 8388608 /* CustomPrologue */); + ts.setEmitFlags(forStatement, 8388608 /* CustomPrologue */); ts.startOnNewLine(forStatement); statements.push(forStatement); } @@ -49953,17 +51426,20 @@ var ts; */ function addCaptureThisForNodeIfNeeded(statements, node) { if (node.transformFlags & 16384 /* ContainsCapturedLexicalThis */ && node.kind !== 180 /* ArrowFunction */) { - enableSubstitutionsForCapturedThis(); - var captureThisStatement = ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration("_this", - /*type*/ undefined, ts.createThis()) - ])); - setNodeEmitFlags(captureThisStatement, 49152 /* NoComments */ | 8388608 /* CustomPrologue */); - setSourceMapRange(captureThisStatement, node); - statements.push(captureThisStatement); + captureThisForNode(statements, node, ts.createThis()); } } + function captureThisForNode(statements, node, initializer, originalStatement) { + enableSubstitutionsForCapturedThis(); + var captureThisStatement = ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration("_this", + /*type*/ undefined, initializer) + ]), originalStatement); + ts.setEmitFlags(captureThisStatement, 49152 /* NoComments */ | 8388608 /* CustomPrologue */); + ts.setSourceMapRange(captureThisStatement, node); + statements.push(captureThisStatement); + } /** * Adds statements to the class body function for a class to define the members of the * class. @@ -50012,20 +51488,20 @@ var ts; * @param member The MethodDeclaration node. */ function transformClassMethodDeclarationToStatement(receiver, member) { - var commentRange = getCommentRange(member); - var sourceMapRange = getSourceMapRange(member); + var commentRange = ts.getCommentRange(member); + var sourceMapRange = ts.getSourceMapRange(member); var func = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined); - setNodeEmitFlags(func, 49152 /* NoComments */); - setSourceMapRange(func, sourceMapRange); + ts.setEmitFlags(func, 49152 /* NoComments */); + ts.setSourceMapRange(func, sourceMapRange); var statement = ts.createStatement(ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), /*location*/ member.name), func), /*location*/ member); ts.setOriginalNode(statement, member); - setCommentRange(statement, commentRange); + ts.setCommentRange(statement, commentRange); // The location for the statement is used to emit comments only. // No source map should be emitted for this statement to align with the // old emitter. - setNodeEmitFlags(statement, 1536 /* NoSourceMap */); + ts.setEmitFlags(statement, 1536 /* NoSourceMap */); return statement; } /** @@ -50036,11 +51512,11 @@ var ts; */ function transformAccessorsToStatement(receiver, accessors) { var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, /*startsOnNewLine*/ false), - /*location*/ getSourceMapRange(accessors.firstAccessor)); + /*location*/ ts.getSourceMapRange(accessors.firstAccessor)); // The location for the statement is used to emit source maps only. // No comments should be emitted for this statement to align with the // old emitter. - setNodeEmitFlags(statement, 49152 /* NoComments */); + ts.setEmitFlags(statement, 49152 /* NoComments */); return statement; } /** @@ -50054,24 +51530,24 @@ var ts; // To align with source maps in the old emitter, the receiver and property name // arguments are both mapped contiguously to the accessor name. var target = ts.getMutableClone(receiver); - setNodeEmitFlags(target, 49152 /* NoComments */ | 1024 /* NoTrailingSourceMap */); - setSourceMapRange(target, firstAccessor.name); + ts.setEmitFlags(target, 49152 /* NoComments */ | 1024 /* NoTrailingSourceMap */); + ts.setSourceMapRange(target, firstAccessor.name); var propertyName = ts.createExpressionForPropertyName(ts.visitNode(firstAccessor.name, visitor, ts.isPropertyName)); - setNodeEmitFlags(propertyName, 49152 /* NoComments */ | 512 /* NoLeadingSourceMap */); - setSourceMapRange(propertyName, firstAccessor.name); + ts.setEmitFlags(propertyName, 49152 /* NoComments */ | 512 /* NoLeadingSourceMap */); + ts.setSourceMapRange(propertyName, firstAccessor.name); var properties = []; if (getAccessor) { var getterFunction = transformFunctionLikeToExpression(getAccessor, /*location*/ undefined, /*name*/ undefined); - setSourceMapRange(getterFunction, getSourceMapRange(getAccessor)); + ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); var getter = ts.createPropertyAssignment("get", getterFunction); - setCommentRange(getter, getCommentRange(getAccessor)); + ts.setCommentRange(getter, ts.getCommentRange(getAccessor)); properties.push(getter); } if (setAccessor) { var setterFunction = transformFunctionLikeToExpression(setAccessor, /*location*/ undefined, /*name*/ undefined); - setSourceMapRange(setterFunction, getSourceMapRange(setAccessor)); + ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); var setter = ts.createPropertyAssignment("set", setterFunction); - setCommentRange(setter, getCommentRange(setAccessor)); + ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); properties.push(setter); } properties.push(ts.createPropertyAssignment("enumerable", ts.createLiteral(true)), ts.createPropertyAssignment("configurable", ts.createLiteral(true))); @@ -50096,7 +51572,7 @@ var ts; enableSubstitutionsForCapturedThis(); } var func = transformFunctionLikeToExpression(node, /*location*/ node, /*name*/ undefined); - setNodeEmitFlags(func, 256 /* CapturesThis */); + ts.setEmitFlags(func, 256 /* CapturesThis */); return func; } /** @@ -50191,7 +51667,7 @@ var ts; } var expression = ts.visitNode(body, visitor, ts.isExpression); var returnStatement = ts.createReturn(expression, /*location*/ body); - setNodeEmitFlags(returnStatement, 12288 /* NoTokenSourceMaps */ | 1024 /* NoTrailingSourceMap */ | 32768 /* NoTrailingComments */); + ts.setEmitFlags(returnStatement, 12288 /* NoTokenSourceMaps */ | 1024 /* NoTrailingSourceMap */ | 32768 /* NoTrailingComments */); statements.push(returnStatement); // To align with the source map emit for the old emitter, we set a custom // source map location for the close brace. @@ -50205,10 +51681,10 @@ var ts; } var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), node.body, multiLine); if (!multiLine && singleLine) { - setNodeEmitFlags(block, 32 /* SingleLine */); + ts.setEmitFlags(block, 32 /* SingleLine */); } if (closeBraceLocation) { - setTokenSourceMapRange(block, 16 /* CloseBraceToken */, closeBraceLocation); + ts.setTokenSourceMapRange(block, 16 /* CloseBraceToken */, closeBraceLocation); } ts.setOriginalNode(block, node.body); return block; @@ -50274,7 +51750,7 @@ var ts; assignment = ts.flattenVariableDestructuringToExpression(context, decl, hoistVariableDeclaration, /*nameSubstitution*/ undefined, visitor); } else { - assignment = ts.createBinary(decl.name, 56 /* EqualsToken */, decl.initializer); + assignment = ts.createBinary(decl.name, 56 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); } (assignments || (assignments = [])).push(assignment); } @@ -50303,7 +51779,7 @@ var ts; : visitVariableDeclaration)); var declarationList = ts.createVariableDeclarationList(declarations, /*location*/ node); ts.setOriginalNode(declarationList, node); - setCommentRange(declarationList, node); + ts.setCommentRange(declarationList, node); if (node.transformFlags & 2097152 /* ContainsBindingPattern */ && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { @@ -50311,7 +51787,7 @@ var ts; // the source map range for the declaration list. var firstDeclaration = ts.firstOrUndefined(declarations); var lastDeclaration = ts.lastOrUndefined(declarations); - setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); } return declarationList; } @@ -50501,7 +51977,7 @@ var ts; // emitter. var firstDeclaration = declarations[0]; var lastDeclaration = ts.lastOrUndefined(declarations); - setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); statements.push(ts.createVariableStatement( /*modifiers*/ undefined, declarationList)); } @@ -50549,12 +52025,12 @@ var ts; } } // The old emitter does not emit source maps for the expression - setNodeEmitFlags(expression, 1536 /* NoSourceMap */ | getNodeEmitFlags(expression)); + ts.setEmitFlags(expression, 1536 /* NoSourceMap */ | ts.getEmitFlags(expression)); // The old emitter does not emit source maps for the block. // We add the location to preserve comments. var body = ts.createBlock(ts.createNodeArray(statements, /*location*/ statementsLocation), /*location*/ bodyLocation); - setNodeEmitFlags(body, 1536 /* NoSourceMap */ | 12288 /* NoTokenSourceMaps */); + ts.setEmitFlags(body, 1536 /* NoSourceMap */ | 12288 /* NoTokenSourceMaps */); var forStatement = ts.createFor(ts.createVariableDeclarationList([ ts.createVariableDeclaration(counter, /*type*/ undefined, ts.createLiteral(0), /*location*/ ts.moveRangePos(node.expression, -1)), ts.createVariableDeclaration(rhsReference, /*type*/ undefined, expression, /*location*/ node.expression) @@ -50562,7 +52038,7 @@ var ts; /*location*/ node.expression), ts.createPostfixIncrement(counter, /*location*/ node.expression), body, /*location*/ node); // Disable trailing source maps for the OpenParenToken to align source map emit with the old emitter. - setNodeEmitFlags(forStatement, 8192 /* NoTokenTrailingSourceMaps */); + ts.setEmitFlags(forStatement, 8192 /* NoTokenTrailingSourceMaps */); return forStatement; } /** @@ -50591,7 +52067,7 @@ var ts; var temp = ts.createTempVariable(hoistVariableDeclaration); // Write out the first non-computed properties, then emit the rest through indexing on the temp variable. var expressions = []; - var assignment = ts.createAssignment(temp, setNodeEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), + var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), /*location*/ undefined, node.multiLine), 524288 /* Indented */)); if (node.multiLine) { assignment.startsOnNewLine = true; @@ -50698,7 +52174,7 @@ var ts; loopBody = ts.createBlock([loopBody], /*location*/ undefined, /*multiline*/ true); } var isAsyncBlockContainingAwait = enclosingNonArrowFunction - && (enclosingNonArrowFunction.emitFlags & 2097152 /* AsyncFunctionBody */) !== 0 + && (ts.getEmitFlags(enclosingNonArrowFunction) & 2097152 /* AsyncFunctionBody */) !== 0 && (node.statement.transformFlags & 4194304 /* ContainsYield */) !== 0; var loopBodyFlags = 0; if (currentState.containsLexicalThis) { @@ -50710,7 +52186,7 @@ var ts; var convertedLoopVariable = ts.createVariableStatement( /*modifiers*/ undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration(functionName, - /*type*/ undefined, setNodeEmitFlags(ts.createFunctionExpression(isAsyncBlockContainingAwait ? ts.createToken(37 /* AsteriskToken */) : undefined, + /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression(isAsyncBlockContainingAwait ? ts.createToken(37 /* AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, loopParameters, /*type*/ undefined, loopBody), loopBodyFlags)) @@ -50756,8 +52232,8 @@ var ts; extraVariableDeclarations = []; } // hoist collected variable declarations - for (var name_38 in currentState.hoistedLocalVariables) { - var identifier = currentState.hoistedLocalVariables[name_38]; + for (var _b = 0, _c = currentState.hoistedLocalVariables; _b < _c.length; _b++) { + var identifier = _c[_b]; extraVariableDeclarations.push(ts.createVariableDeclaration(identifier)); } } @@ -50767,8 +52243,8 @@ var ts; if (!extraVariableDeclarations) { extraVariableDeclarations = []; } - for (var _b = 0, loopOutParameters_1 = loopOutParameters; _b < loopOutParameters_1.length; _b++) { - var outParam = loopOutParameters_1[_b]; + for (var _d = 0, loopOutParameters_1 = loopOutParameters; _d < loopOutParameters_1.length; _d++) { + var outParam = loopOutParameters_1[_d]; extraVariableDeclarations.push(ts.createVariableDeclaration(outParam.outParamName)); } } @@ -51003,7 +52479,7 @@ var ts; // Methods with computed property names are handled in visitObjectLiteralExpression. ts.Debug.assert(!ts.isComputedPropertyName(node.name)); var functionExpression = transformFunctionLikeToExpression(node, /*location*/ ts.moveRangePos(node, -1), /*name*/ undefined); - setNodeEmitFlags(functionExpression, 16384 /* NoLeadingComments */ | getNodeEmitFlags(functionExpression)); + ts.setEmitFlags(functionExpression, 16384 /* NoLeadingComments */ | ts.getEmitFlags(functionExpression)); return ts.createPropertyAssignment(node.name, functionExpression, /*location*/ node); } @@ -51040,9 +52516,19 @@ var ts; * @param node a CallExpression. */ function visitCallExpression(node) { + return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); + } + function visitImmediateSuperCallInBody(node) { + return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ false); + } + function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) { // We are here either because SuperKeyword was used somewhere in the expression, or // because we contain a SpreadElementExpression. var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; + if (node.expression.kind === 95 /* SuperKeyword */) { + ts.setEmitFlags(thisArg, 128 /* NoSubstitution */); + } + var resultingCall; if (node.transformFlags & 262144 /* ContainsSpreadElementExpression */) { // [source] // f(...a, b) @@ -51057,7 +52543,7 @@ var ts; // _super.apply(this, a.concat([b])) // _super.m.apply(this, a.concat([b])) // _super.prototype.m.apply(this, a.concat([b])) - return ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); + resultingCall = ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); } else { // [source] @@ -51069,9 +52555,18 @@ var ts; // _super.call(this, a) // _super.m.call(this, a) // _super.prototype.m.call(this, a) - return ts.createFunctionCall(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), + resultingCall = ts.createFunctionCall(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), /*location*/ node); } + if (node.expression.kind === 95 /* SuperKeyword */) { + var actualThis = ts.createThis(); + ts.setEmitFlags(actualThis, 128 /* NoSubstitution */); + var initializer = ts.createLogicalOr(resultingCall, actualThis); + return assignToCapturedThis + ? ts.createAssignment(ts.createIdentifier("_this"), initializer) + : initializer; + } + return resultingCall; } /** * Visits a NewExpression that contains a spread element. @@ -51313,13 +52808,13 @@ var ts; * * @param node The node to be printed. */ - function onEmitNode(node, emit) { + function onEmitNode(emitContext, node, emitCallback) { var savedEnclosingFunction = enclosingFunction; if (enabledSubstitutions & 1 /* CapturedThis */ && ts.isFunctionLike(node)) { // If we are tracking a captured `this`, keep track of the enclosing function. enclosingFunction = node; } - previousOnEmitNode(node, emit); + previousOnEmitNode(emitContext, node, emitCallback); enclosingFunction = savedEnclosingFunction; } /** @@ -51356,9 +52851,9 @@ var ts; * @param isExpression A value indicating whether the node is to be used in an expression * position. */ - function onSubstituteNode(node, isExpression) { - node = previousOnSubstituteNode(node, isExpression); - if (isExpression) { + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1 /* Expression */) { return substituteExpression(node); } if (ts.isIdentifier(node)) { @@ -51434,7 +52929,7 @@ var ts; function substituteThisKeyword(node) { if (enabledSubstitutions & 1 /* CapturedThis */ && enclosingFunction - && enclosingFunction.emitFlags & 256 /* CapturesThis */) { + && ts.getEmitFlags(enclosingFunction) & 256 /* CapturesThis */) { return ts.createIdentifier("_this", /*location*/ node); } return node; @@ -51461,7 +52956,7 @@ var ts; function getDeclarationName(node, allowComments, allowSourceMaps, emitFlags) { if (node.name && !ts.isGeneratedIdentifier(node.name)) { var name_39 = ts.getMutableClone(node.name); - emitFlags |= getNodeEmitFlags(node.name); + emitFlags |= ts.getEmitFlags(node.name); if (!allowSourceMaps) { emitFlags |= 1536 /* NoSourceMap */; } @@ -51469,7 +52964,7 @@ var ts; emitFlags |= 49152 /* NoComments */; } if (emitFlags) { - setNodeEmitFlags(name_39, emitFlags); + ts.setEmitFlags(name_39, emitFlags); } return name_39; } @@ -51552,13 +53047,6 @@ var ts; return transformers; } ts.getTransformers = getTransformers; - /** - * Tracks a monotonically increasing transformation id used to associate a node with a specific - * transformation. This ensures transient properties related to transformations can be safely - * stored on source tree nodes that may be reused across multiple transformations (such as - * with compile-on-save). - */ - var nextTransformId = 1; /** * Transforms an array of SourceFiles by passing them through each transformer. * @@ -51568,16 +53056,9 @@ var ts; * @param transforms An array of Transformers. */ function transformFiles(resolver, host, sourceFiles, transformers) { - var transformId = nextTransformId; - nextTransformId++; - var tokenSourceMapRanges = ts.createMap(); var lexicalEnvironmentVariableDeclarationsStack = []; var lexicalEnvironmentFunctionDeclarationsStack = []; var enabledSyntaxKindFeatures = new Array(289 /* Count */); - var parseTreeNodesWithAnnotations = []; - var lastTokenSourceMapRangeNode; - var lastTokenSourceMapRangeToken; - var lastTokenSourceMapRange; var lexicalEnvironmentStackOffset = 0; var hoistedVariableDeclarations; var hoistedFunctionDeclarations; @@ -51588,56 +53069,27 @@ var ts; getCompilerOptions: function () { return host.getCompilerOptions(); }, getEmitResolver: function () { return resolver; }, getEmitHost: function () { return host; }, - getNodeEmitFlags: getNodeEmitFlags, - setNodeEmitFlags: setNodeEmitFlags, - getSourceMapRange: getSourceMapRange, - setSourceMapRange: setSourceMapRange, - getTokenSourceMapRange: getTokenSourceMapRange, - setTokenSourceMapRange: setTokenSourceMapRange, - getCommentRange: getCommentRange, - setCommentRange: setCommentRange, hoistVariableDeclaration: hoistVariableDeclaration, hoistFunctionDeclaration: hoistFunctionDeclaration, startLexicalEnvironment: startLexicalEnvironment, endLexicalEnvironment: endLexicalEnvironment, - onSubstituteNode: onSubstituteNode, + onSubstituteNode: function (emitContext, node) { return node; }, enableSubstitution: enableSubstitution, isSubstitutionEnabled: isSubstitutionEnabled, - onEmitNode: onEmitNode, + onEmitNode: function (node, emitContext, emitCallback) { return emitCallback(node, emitContext); }, enableEmitNotification: enableEmitNotification, isEmitNotificationEnabled: isEmitNotificationEnabled }; // Chain together and initialize each transformer. - var transformation = chain.apply(void 0, transformers)(context); + var transformation = ts.chain.apply(void 0, transformers)(context); // Transform each source file. var transformed = ts.map(sourceFiles, transformSourceFile); // Disable modification of the lexical environment. lexicalEnvironmentDisabled = true; return { - getSourceFiles: function () { return transformed; }, - getTokenSourceMapRange: getTokenSourceMapRange, - isSubstitutionEnabled: isSubstitutionEnabled, - isEmitNotificationEnabled: isEmitNotificationEnabled, - onSubstituteNode: context.onSubstituteNode, - onEmitNode: context.onEmitNode, - dispose: function () { - // During transformation we may need to annotate a parse tree node with transient - // transformation properties. As parse tree nodes live longer than transformation - // nodes, we need to make sure we reclaim any memory allocated for custom ranges - // from these nodes to ensure we do not hold onto entire subtrees just for position - // information. We also need to reset these nodes to a pre-transformation state - // for incremental parsing scenarios so that we do not impact later emit. - for (var _i = 0, parseTreeNodesWithAnnotations_1 = parseTreeNodesWithAnnotations; _i < parseTreeNodesWithAnnotations_1.length; _i++) { - var node = parseTreeNodesWithAnnotations_1[_i]; - if (node.transformId === transformId) { - node.transformId = 0; - node.emitFlags = 0; - node.commentRange = undefined; - node.sourceMapRange = undefined; - } - } - parseTreeNodesWithAnnotations.length = 0; - } + transformed: transformed, + emitNodeWithSubstitution: emitNodeWithSubstitution, + emitNodeWithNotification: emitNodeWithNotification }; /** * Transforms a source file. @@ -51660,17 +53112,27 @@ var ts; * Determines whether expression substitutions are enabled for the provided node. */ function isSubstitutionEnabled(node) { - return (enabledSyntaxKindFeatures[node.kind] & 1 /* Substitution */) !== 0; + return (enabledSyntaxKindFeatures[node.kind] & 1 /* Substitution */) !== 0 + && (ts.getEmitFlags(node) & 128 /* NoSubstitution */) === 0; } /** - * Default hook for node substitutions. + * Emits a node with possible substitution. * - * @param node The node to substitute. - * @param isExpression A value indicating whether the node is to be used in an expression - * position. + * @param emitContext The current emit context. + * @param node The node to emit. + * @param emitCallback The callback used to emit the node or its substitute. */ - function onSubstituteNode(node, isExpression) { - return node; + function emitNodeWithSubstitution(emitContext, node, emitCallback) { + if (node) { + if (isSubstitutionEnabled(node)) { + var substitute = context.onSubstituteNode(emitContext, node); + if (substitute && substitute !== node) { + emitCallback(emitContext, substitute); + return; + } + } + emitCallback(emitContext, node); + } } /** * Enables before/after emit notifications in the pretty printer for the provided SyntaxKind. @@ -51684,141 +53146,24 @@ var ts; */ function isEmitNotificationEnabled(node) { return (enabledSyntaxKindFeatures[node.kind] & 2 /* EmitNotifications */) !== 0 - || (getNodeEmitFlags(node) & 64 /* AdviseOnEmitNode */) !== 0; + || (ts.getEmitFlags(node) & 64 /* AdviseOnEmitNode */) !== 0; } /** - * Default hook for node emit. + * Emits a node with possible emit notification. * + * @param emitContext The current emit context. * @param node The node to emit. - * @param emit A callback used to emit the node in the printer. + * @param emitCallback The callback used to emit the node. */ - function onEmitNode(node, emit) { - emit(node); - } - /** - * Associates a node with the current transformation, initializing - * various transient transformation properties. - * - * @param node The node. - */ - function beforeSetAnnotation(node) { - if ((node.flags & 8 /* Synthesized */) === 0 && node.transformId !== transformId) { - // To avoid holding onto transformation artifacts, we keep track of any - // parse tree node we are annotating. This allows us to clean them up after - // all transformations have completed. - parseTreeNodesWithAnnotations.push(node); - node.transformId = transformId; - } - } - /** - * Gets flags that control emit behavior of a node. - * - * If the node does not have its own NodeEmitFlags set, the node emit flags of its - * original pointer are used. - * - * @param node The node. - */ - function getNodeEmitFlags(node) { - return node.emitFlags; - } - /** - * Sets flags that control emit behavior of a node. - * - * @param node The node. - * @param emitFlags The NodeEmitFlags for the node. - */ - function setNodeEmitFlags(node, emitFlags) { - beforeSetAnnotation(node); - node.emitFlags = emitFlags; - return node; - } - /** - * Gets a custom text range to use when emitting source maps. - * - * If a node does not have its own custom source map text range, the custom source map - * text range of its original pointer is used. - * - * @param node The node. - */ - function getSourceMapRange(node) { - return node.sourceMapRange || node; - } - /** - * Sets a custom text range to use when emitting source maps. - * - * @param node The node. - * @param range The text range. - */ - function setSourceMapRange(node, range) { - beforeSetAnnotation(node); - node.sourceMapRange = range; - return node; - } - /** - * Gets the TextRange to use for source maps for a token of a node. - * - * If a node does not have its own custom source map text range for a token, the custom - * source map text range for the token of its original pointer is used. - * - * @param node The node. - * @param token The token. - */ - function getTokenSourceMapRange(node, token) { - // As a performance optimization, use the cached value of the most recent node. - // This helps for cases where this function is called repeatedly for the same node. - if (lastTokenSourceMapRangeNode === node && lastTokenSourceMapRangeToken === token) { - return lastTokenSourceMapRange; - } - // Get the custom token source map range for a node or from one of its original nodes. - // Custom token ranges are not stored on the node to avoid the GC burden. - var range; - var current = node; - while (current) { - range = current.id ? tokenSourceMapRanges[current.id + "-" + token] : undefined; - if (range !== undefined) { - break; + function emitNodeWithNotification(emitContext, node, emitCallback) { + if (node) { + if (isEmitNotificationEnabled(node)) { + context.onEmitNode(emitContext, node, emitCallback); + } + else { + emitCallback(emitContext, node); } - current = current.original; } - // Cache the most recently requested value. - lastTokenSourceMapRangeNode = node; - lastTokenSourceMapRangeToken = token; - lastTokenSourceMapRange = range; - return range; - } - /** - * Sets the TextRange to use for source maps for a token of a node. - * - * @param node The node. - * @param token The token. - * @param range The text range. - */ - function setTokenSourceMapRange(node, token, range) { - // Cache the most recently requested value. - lastTokenSourceMapRangeNode = node; - lastTokenSourceMapRangeToken = token; - lastTokenSourceMapRange = range; - tokenSourceMapRanges[ts.getNodeId(node) + "-" + token] = range; - return node; - } - /** - * Gets a custom text range to use when emitting comments. - * - * If a node does not have its own custom source map text range, the custom source map - * text range of its original pointer is used. - * - * @param node The node. - */ - function getCommentRange(node) { - return node.commentRange || node; - } - /** - * Sets a custom text range to use when emitting comments. - */ - function setCommentRange(node, range) { - beforeSetAnnotation(node); - node.commentRange = range; - return node; } /** * Records a hoisted variable declaration for the provided name within a lexical environment. @@ -51891,95 +53236,12 @@ var ts; } } ts.transformFiles = transformFiles; - function chain(a, b, c, d, e) { - if (e) { - var args_3 = []; - for (var i = 0; i < arguments.length; i++) { - args_3[i] = arguments[i]; - } - return function (t) { return compose.apply(void 0, ts.map(args_3, function (f) { return f(t); })); }; - } - else if (d) { - return function (t) { return compose(a(t), b(t), c(t), d(t)); }; - } - else if (c) { - return function (t) { return compose(a(t), b(t), c(t)); }; - } - else if (b) { - return function (t) { return compose(a(t), b(t)); }; - } - else if (a) { - return function (t) { return compose(a(t)); }; - } - else { - return function (t) { return function (u) { return u; }; }; - } - } - function compose(a, b, c, d, e) { - if (e) { - var args_4 = []; - for (var i = 0; i < arguments.length; i++) { - args_4[i] = arguments[i]; - } - return function (t) { return ts.reduceLeft(args_4, function (u, f) { return f(u); }, t); }; - } - else if (d) { - return function (t) { return d(c(b(a(t)))); }; - } - else if (c) { - return function (t) { return c(b(a(t))); }; - } - else if (b) { - return function (t) { return b(a(t)); }; - } - else if (a) { - return function (t) { return a(t); }; - } - else { - return function (t) { return t; }; - } - } var _a; })(ts || (ts = {})); /// /* @internal */ var ts; (function (ts) { - function createSourceMapWriter(host, writer) { - var compilerOptions = host.getCompilerOptions(); - if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) { - if (compilerOptions.extendedDiagnostics) { - return createSourceMapWriterWithExtendedDiagnostics(host, writer); - } - return createSourceMapWriterWorker(host, writer); - } - else { - return getNullSourceMapWriter(); - } - } - ts.createSourceMapWriter = createSourceMapWriter; - var nullSourceMapWriter; - function getNullSourceMapWriter() { - if (nullSourceMapWriter === undefined) { - nullSourceMapWriter = { - initialize: function (filePath, sourceMapFilePath, sourceFiles, isBundledEmit) { }, - reset: function () { }, - getSourceMapData: function () { return undefined; }, - setSourceFile: function (sourceFile) { }, - emitPos: function (pos) { }, - emitStart: function (range, contextNode, ignoreNodeCallback, ignoreChildrenCallback, getTextRangeCallback) { }, - emitEnd: function (range, contextNode, ignoreNodeCallback, ignoreChildrenCallback, getTextRangeCallback) { }, - emitTokenStart: function (token, pos, contextNode, ignoreTokenCallback, getTokenTextRangeCallback) { return -1; }, - emitTokenEnd: function (token, end, contextNode, ignoreTokenCallback, getTokenTextRangeCallback) { return -1; }, - changeEmitSourcePos: function () { }, - stopOverridingSpan: function () { }, - getText: function () { return undefined; }, - getSourceMappingURL: function () { return undefined; } - }; - } - return nullSourceMapWriter; - } - ts.getNullSourceMapWriter = getNullSourceMapWriter; // Used for initialize lastEncodedSourceMapSpan and reset lastEncodedSourceMapSpan when updateLastEncodedAndRecordedSpans var defaultLastEncodedSourceMapSpan = { emittedLine: 1, @@ -51988,14 +53250,12 @@ var ts; sourceColumn: 1, sourceIndex: 0 }; - function createSourceMapWriterWorker(host, writer) { + function createSourceMapWriter(host, writer) { var compilerOptions = host.getCompilerOptions(); var extendedDiagnostics = compilerOptions.extendedDiagnostics; var currentSourceFile; var currentSourceText; var sourceMapDir; // The directory in which sourcemap will be - var stopOverridingSpan = false; - var modifyLastSourcePos = false; // Current source map file and its index in the sources list var sourceMapSourceIndex; // Last recorded and encoded spans @@ -52004,24 +53264,15 @@ var ts; var lastEncodedNameIndex; // Source map data var sourceMapData; - // This keeps track of the number of times `disable` has been called without a - // corresponding call to `enable`. As long as this value is non-zero, mappings will not - // be recorded. - // This is primarily used to provide a better experience when debugging binding - // patterns and destructuring assignments for simple expressions. - var disableDepth; + var disabled = !(compilerOptions.sourceMap || compilerOptions.inlineSourceMap); return { initialize: initialize, reset: reset, getSourceMapData: function () { return sourceMapData; }, setSourceFile: setSourceFile, emitPos: emitPos, - emitStart: emitStart, - emitEnd: emitEnd, - emitTokenStart: emitTokenStart, - emitTokenEnd: emitTokenEnd, - changeEmitSourcePos: changeEmitSourcePos, - stopOverridingSpan: function () { return stopOverridingSpan = true; }, + emitNodeWithSourceMap: emitNodeWithSourceMap, + emitTokenWithSourceMap: emitTokenWithSourceMap, getText: getText, getSourceMappingURL: getSourceMappingURL }; @@ -52034,12 +53285,14 @@ var ts; * @param isBundledEmit A value indicating whether the generated output file is a bundle. */ function initialize(filePath, sourceMapFilePath, sourceFiles, isBundledEmit) { + if (disabled) { + return; + } if (sourceMapData) { reset(); } currentSourceFile = undefined; currentSourceText = undefined; - disableDepth = 0; // Current source map file and its index in the sources list sourceMapSourceIndex = -1; // Last recorded and encoded spans @@ -52093,6 +53346,9 @@ var ts; * Reset the SourceMapWriter to an empty state. */ function reset() { + if (disabled) { + return; + } currentSourceFile = undefined; sourceMapDir = undefined; sourceMapSourceIndex = undefined; @@ -52100,56 +53356,6 @@ var ts; lastEncodedSourceMapSpan = undefined; lastEncodedNameIndex = undefined; sourceMapData = undefined; - disableDepth = 0; - } - /** - * Re-enables the recording of mappings. - */ - function enable() { - if (disableDepth > 0) { - disableDepth--; - } - } - /** - * Disables the recording of mappings. - */ - function disable() { - disableDepth++; - } - function updateLastEncodedAndRecordedSpans() { - if (modifyLastSourcePos) { - // Reset the source pos - modifyLastSourcePos = false; - // Change Last recorded Map with last encoded emit line and character - lastRecordedSourceMapSpan.emittedLine = lastEncodedSourceMapSpan.emittedLine; - lastRecordedSourceMapSpan.emittedColumn = lastEncodedSourceMapSpan.emittedColumn; - // Pop sourceMapDecodedMappings to remove last entry - sourceMapData.sourceMapDecodedMappings.pop(); - // Point the lastEncodedSourceMapSpace to the previous encoded sourceMapSpan - // If the list is empty which indicates that we are at the beginning of the file, - // we have to reset it to default value (same value when we first initialize sourceMapWriter) - lastEncodedSourceMapSpan = sourceMapData.sourceMapDecodedMappings.length ? - sourceMapData.sourceMapDecodedMappings[sourceMapData.sourceMapDecodedMappings.length - 1] : - defaultLastEncodedSourceMapSpan; - // TODO: Update lastEncodedNameIndex - // Since we dont support this any more, lets not worry about it right now. - // When we start supporting nameIndex, we will get back to this - // Change the encoded source map - var sourceMapMappings = sourceMapData.sourceMapMappings; - var lenthToSet = sourceMapMappings.length - 1; - for (; lenthToSet >= 0; lenthToSet--) { - var currentChar = sourceMapMappings.charAt(lenthToSet); - if (currentChar === ",") { - // Separator for the entry found - break; - } - if (currentChar === ";" && lenthToSet !== 0 && sourceMapMappings.charAt(lenthToSet - 1) !== ";") { - // Last line separator found - break; - } - } - sourceMapData.sourceMapMappings = sourceMapMappings.substr(0, Math.max(0, lenthToSet)); - } } // Encoding for sourcemap span function encodeLastRecordedSourceMapSpan() { @@ -52197,7 +53403,7 @@ var ts; * @param pos The position. */ function emitPos(pos) { - if (ts.positionIsSynthesized(pos) || disableDepth > 0) { + if (disabled || ts.positionIsSynthesized(pos)) { return; } if (extendedDiagnostics) { @@ -52226,84 +53432,78 @@ var ts; sourceColumn: sourceLinePos.character, sourceIndex: sourceMapSourceIndex }; - stopOverridingSpan = false; } - else if (!stopOverridingSpan) { + else { // Take the new pos instead since there is no change in emittedLine and column since last location lastRecordedSourceMapSpan.sourceLine = sourceLinePos.line; lastRecordedSourceMapSpan.sourceColumn = sourceLinePos.character; lastRecordedSourceMapSpan.sourceIndex = sourceMapSourceIndex; } - updateLastEncodedAndRecordedSpans(); if (extendedDiagnostics) { ts.performance.mark("afterSourcemap"); ts.performance.measure("Source Map", "beforeSourcemap", "afterSourcemap"); } } - function getStartPosPastDecorators(range) { - var rangeHasDecorators = !!range.decorators; - return ts.skipTrivia(currentSourceText, rangeHasDecorators ? range.decorators.end : range.pos); - } - function emitStart(range, contextNode, ignoreNodeCallback, ignoreChildrenCallback, getTextRangeCallback) { - if (contextNode) { - if (!ignoreNodeCallback(contextNode)) { - range = getTextRangeCallback(contextNode) || range; - emitPos(getStartPosPastDecorators(range)); - } - if (ignoreChildrenCallback(contextNode)) { - disable(); - } + /** + * Emits a node with possible leading and trailing source maps. + * + * @param node The node to emit. + * @param emitCallback The callback used to emit the node. + */ + function emitNodeWithSourceMap(emitContext, node, emitCallback) { + if (disabled) { + return emitCallback(emitContext, node); } - else { - emitPos(getStartPosPastDecorators(range)); + if (node) { + var emitNode = node.emitNode; + var emitFlags = emitNode && emitNode.flags; + var _a = emitNode && emitNode.sourceMapRange || node, pos = _a.pos, end = _a.end; + if (node.kind !== 287 /* NotEmittedStatement */ + && (emitFlags & 512 /* NoLeadingSourceMap */) === 0 + && pos >= 0) { + emitPos(ts.skipTrivia(currentSourceText, pos)); + } + if (emitFlags & 2048 /* NoNestedSourceMaps */) { + disabled = true; + emitCallback(emitContext, node); + disabled = false; + } + else { + emitCallback(emitContext, node); + } + if (node.kind !== 287 /* NotEmittedStatement */ + && (emitFlags & 1024 /* NoTrailingSourceMap */) === 0 + && end >= 0) { + emitPos(end); + } } } - function emitEnd(range, contextNode, ignoreNodeCallback, ignoreChildrenCallback, getTextRangeCallback) { - if (contextNode) { - if (ignoreChildrenCallback(contextNode)) { - enable(); - } - if (!ignoreNodeCallback(contextNode)) { - range = getTextRangeCallback(contextNode) || range; - emitPos(range.end); - } + /** + * Emits a token of a node with possible leading and trailing source maps. + * + * @param node The node containing the token. + * @param token The token to emit. + * @param tokenStartPos The start pos of the token. + * @param emitCallback The callback used to emit the token. + */ + function emitTokenWithSourceMap(node, token, tokenPos, emitCallback) { + if (disabled) { + return emitCallback(token, tokenPos); } - else { - emitPos(range.end); + var emitNode = node && node.emitNode; + var emitFlags = emitNode && emitNode.flags; + var range = emitNode && emitNode.tokenSourceMapRanges && emitNode.tokenSourceMapRanges[token]; + tokenPos = ts.skipTrivia(currentSourceText, range ? range.pos : tokenPos); + if ((emitFlags & 4096 /* NoTokenLeadingSourceMaps */) === 0 && tokenPos >= 0) { + emitPos(tokenPos); } - stopOverridingSpan = false; - } - function emitTokenStart(token, tokenStartPos, contextNode, ignoreTokenCallback, getTokenTextRangeCallback) { - if (contextNode) { - if (ignoreTokenCallback(contextNode, token)) { - return ts.skipTrivia(currentSourceText, tokenStartPos); - } - var range = getTokenTextRangeCallback(contextNode, token); - if (range) { - tokenStartPos = range.pos; - } + tokenPos = emitCallback(token, tokenPos); + if (range) + tokenPos = range.end; + if ((emitFlags & 8192 /* NoTokenTrailingSourceMaps */) === 0 && tokenPos >= 0) { + emitPos(tokenPos); } - tokenStartPos = ts.skipTrivia(currentSourceText, tokenStartPos); - emitPos(tokenStartPos); - return tokenStartPos; - } - function emitTokenEnd(token, tokenEndPos, contextNode, ignoreTokenCallback, getTokenTextRangeCallback) { - if (contextNode) { - if (ignoreTokenCallback(contextNode, token)) { - return tokenEndPos; - } - var range = getTokenTextRangeCallback(contextNode, token); - if (range) { - tokenEndPos = range.end; - } - } - emitPos(tokenEndPos); - return tokenEndPos; - } - // @deprecated - function changeEmitSourcePos() { - ts.Debug.assert(!modifyLastSourcePos); - modifyLastSourcePos = true; + return tokenPos; } /** * Set the current source file. @@ -52311,6 +53511,9 @@ var ts; * @param sourceFile The source file. */ function setSourceFile(sourceFile) { + if (disabled) { + return; + } currentSourceFile = sourceFile; currentSourceText = currentSourceFile.text; // Add the file to tsFilePaths @@ -52334,6 +53537,9 @@ var ts; * Gets the text for the source map. */ function getText() { + if (disabled) { + return; + } encodeLastRecordedSourceMapSpan(); return ts.stringify({ version: 3, @@ -52349,6 +53555,9 @@ var ts; * Gets the SourceMappingURL for the source map. */ function getSourceMappingURL() { + if (disabled) { + return; + } if (compilerOptions.inlineSourceMap) { // Encode the sourceMap into the sourceMap url var base64SourceMapText = ts.convertToBase64(getText()); @@ -52359,46 +53568,7 @@ var ts; } } } - function createSourceMapWriterWithExtendedDiagnostics(host, writer) { - var _a = createSourceMapWriterWorker(host, writer), initialize = _a.initialize, reset = _a.reset, getSourceMapData = _a.getSourceMapData, setSourceFile = _a.setSourceFile, emitPos = _a.emitPos, emitStart = _a.emitStart, emitEnd = _a.emitEnd, emitTokenStart = _a.emitTokenStart, emitTokenEnd = _a.emitTokenEnd, changeEmitSourcePos = _a.changeEmitSourcePos, stopOverridingSpan = _a.stopOverridingSpan, getText = _a.getText, getSourceMappingURL = _a.getSourceMappingURL; - return { - initialize: initialize, - reset: reset, - getSourceMapData: getSourceMapData, - setSourceFile: setSourceFile, - emitPos: function (pos) { - ts.performance.mark("sourcemapStart"); - emitPos(pos); - ts.performance.measure("sourceMapTime", "sourcemapStart"); - }, - emitStart: function (range, contextNode, ignoreNodeCallback, ignoreChildrenCallback, getTextRangeCallback) { - ts.performance.mark("emitSourcemap:emitStart"); - emitStart(range, contextNode, ignoreNodeCallback, ignoreChildrenCallback, getTextRangeCallback); - ts.performance.measure("sourceMapTime", "emitSourcemap:emitStart"); - }, - emitEnd: function (range, contextNode, ignoreNodeCallback, ignoreChildrenCallback, getTextRangeCallback) { - ts.performance.mark("emitSourcemap:emitEnd"); - emitEnd(range, contextNode, ignoreNodeCallback, ignoreChildrenCallback, getTextRangeCallback); - ts.performance.measure("sourceMapTime", "emitSourcemap:emitEnd"); - }, - emitTokenStart: function (token, tokenStartPos, contextNode, ignoreTokenCallback, getTokenTextRangeCallback) { - ts.performance.mark("emitSourcemap:emitTokenStart"); - tokenStartPos = emitTokenStart(token, tokenStartPos, contextNode, ignoreTokenCallback, getTokenTextRangeCallback); - ts.performance.measure("sourceMapTime", "emitSourcemap:emitTokenStart"); - return tokenStartPos; - }, - emitTokenEnd: function (token, tokenEndPos, contextNode, ignoreTokenCallback, getTokenTextRangeCallback) { - ts.performance.mark("emitSourcemap:emitTokenEnd"); - tokenEndPos = emitTokenEnd(token, tokenEndPos, contextNode, ignoreTokenCallback, getTokenTextRangeCallback); - ts.performance.measure("sourceMapTime", "emitSourcemap:emitTokenEnd"); - return tokenEndPos; - }, - changeEmitSourcePos: changeEmitSourcePos, - stopOverridingSpan: stopOverridingSpan, - getText: getText, - getSourceMappingURL: getSourceMappingURL - }; - } + ts.createSourceMapWriter = createSourceMapWriter; var base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; function base64FormatEncode(inValue) { if (inValue < 64) { @@ -52457,21 +53627,23 @@ var ts; emitBodyWithDetachedComments: emitBodyWithDetachedComments, emitTrailingCommentsOfPosition: emitTrailingCommentsOfPosition }; - function emitNodeWithComments(node, emitCallback) { + function emitNodeWithComments(emitContext, node, emitCallback) { if (disabled) { - emitCallback(node); + emitCallback(emitContext, node); return; } if (node) { - var _a = node.commentRange || node, pos = _a.pos, end = _a.end; - var emitFlags = node.emitFlags; + var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; + var emitFlags = ts.getEmitFlags(node); if ((pos < 0 && end < 0) || (pos === end)) { // Both pos and end are synthesized, so just emit the node without comments. if (emitFlags & 65536 /* NoNestedComments */) { - disableCommentsAndEmit(node, emitCallback); + disabled = true; + emitCallback(emitContext, node); + disabled = false; } else { - emitCallback(node); + emitCallback(emitContext, node); } } else { @@ -52505,10 +53677,12 @@ var ts; ts.performance.measure("commentTime", "preEmitNodeWithComment"); } if (emitFlags & 65536 /* NoNestedComments */) { - disableCommentsAndEmit(node, emitCallback); + disabled = true; + emitCallback(emitContext, node); + disabled = false; } else { - emitCallback(node); + emitCallback(emitContext, node); } if (extendedDiagnostics) { ts.performance.mark("beginEmitNodeWithComment"); @@ -52533,7 +53707,7 @@ var ts; ts.performance.mark("preEmitBodyWithDetachedComments"); } var pos = detachedRange.pos, end = detachedRange.end; - var emitFlags = node.emitFlags; + var emitFlags = ts.getEmitFlags(node); var skipLeadingComments = pos < 0 || (emitFlags & 16384 /* NoLeadingComments */) !== 0; var skipTrailingComments = disabled || end < 0 || (emitFlags & 32768 /* NoTrailingComments */) !== 0; if (!skipLeadingComments) { @@ -52542,8 +53716,10 @@ var ts; if (extendedDiagnostics) { ts.performance.measure("commentTime", "preEmitBodyWithDetachedComments"); } - if (emitFlags & 65536 /* NoNestedComments */) { - disableCommentsAndEmit(node, emitCallback); + if (emitFlags & 65536 /* NoNestedComments */ && !disabled) { + disabled = true; + emitCallback(node); + disabled = false; } else { emitCallback(node); @@ -52664,16 +53840,6 @@ var ts; currentLineMap = ts.getLineStarts(currentSourceFile); detachedCommentsInfo = undefined; } - function disableCommentsAndEmit(node, emitCallback) { - if (disabled) { - emitCallback(node); - } - else { - disabled = true; - emitCallback(node); - disabled = false; - } - } function hasDetachedComments(pos) { return detachedCommentsInfo !== undefined && ts.lastOrUndefined(detachedCommentsInfo).nodePos === pos; } @@ -52735,11 +53901,11 @@ var ts; return declarationDiagnostics.getDiagnostics(targetSourceFile ? targetSourceFile.fileName : undefined); function getDeclarationDiagnosticsFromFile(_a, sources, isBundledEmit) { var declarationFilePath = _a.declarationFilePath; - emitDeclarations(host, resolver, declarationDiagnostics, declarationFilePath, sources, isBundledEmit); + emitDeclarations(host, resolver, declarationDiagnostics, declarationFilePath, sources, isBundledEmit, /*emitOnlyDtsFiles*/ false); } } ts.getDeclarationDiagnostics = getDeclarationDiagnostics; - function emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFiles, isBundledEmit) { + function emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFiles, isBundledEmit, emitOnlyDtsFiles) { var newLine = host.getNewLine(); var compilerOptions = host.getCompilerOptions(); var write; @@ -52786,7 +53952,7 @@ var ts; // global file reference is added only // - if it is not bundled emit (because otherwise it would be self reference) // - and it is not already added - if (writeReferencePath(referencedFile, !isBundledEmit && !addedGlobalFileReference)) { + if (writeReferencePath(referencedFile, !isBundledEmit && !addedGlobalFileReference, emitOnlyDtsFiles)) { addedGlobalFileReference = true; } emittedReferencedFiles.push(referencedFile); @@ -52987,7 +54153,7 @@ var ts; } else { errorNameNode = declaration.name; - resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); + resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2 /* UseTypeOfFunction */ | 1024 /* UseTypeAliasValue */, writer); errorNameNode = undefined; } } @@ -53000,7 +54166,7 @@ var ts; } else { errorNameNode = signature.name; - resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); + resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, 2 /* UseTypeOfFunction */ | 1024 /* UseTypeAliasValue */, writer); errorNameNode = undefined; } } @@ -53202,7 +54368,7 @@ var ts; write(tempVarName); write(": "); writer.getSymbolAccessibilityDiagnostic = getDefaultExportAccessibilityDiagnostic; - resolver.writeTypeOfExpression(node.expression, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); + resolver.writeTypeOfExpression(node.expression, enclosingDeclaration, 2 /* UseTypeOfFunction */ | 1024 /* UseTypeAliasValue */, writer); write(";"); writeLine(); write(node.isExportEquals ? "export = " : "export default "); @@ -53624,7 +54790,7 @@ var ts; } else { writer.getSymbolAccessibilityDiagnostic = getHeritageClauseVisibilityError; - resolver.writeBaseConstructorTypeOfClass(enclosingDeclaration, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); + resolver.writeBaseConstructorTypeOfClass(enclosingDeclaration, enclosingDeclaration, 2 /* UseTypeOfFunction */ | 1024 /* UseTypeAliasValue */, writer); } function getHeritageClauseVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; @@ -54265,7 +55431,7 @@ var ts; * @param referencedFile * @param addBundledFileReference Determines if global file reference corresponding to bundled file should be emitted or not */ - function writeReferencePath(referencedFile, addBundledFileReference) { + function writeReferencePath(referencedFile, addBundledFileReference, emitOnlyDtsFiles) { var declFileName; var addedBundledEmitReference = false; if (ts.isDeclarationFile(referencedFile)) { @@ -54274,7 +55440,7 @@ var ts; } else { // Get the declaration file path - ts.forEachExpectedEmitFile(host, getDeclFileName, referencedFile); + ts.forEachExpectedEmitFile(host, getDeclFileName, referencedFile, emitOnlyDtsFiles); } if (declFileName) { declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(declarationFilePath)), declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, @@ -54294,8 +55460,8 @@ var ts; } } /* @internal */ - function writeDeclarationFile(declarationFilePath, sourceFiles, isBundledEmit, host, resolver, emitterDiagnostics) { - var emitDeclarationResult = emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFiles, isBundledEmit); + function writeDeclarationFile(declarationFilePath, sourceFiles, isBundledEmit, host, resolver, emitterDiagnostics, emitOnlyDtsFiles) { + var emitDeclarationResult = emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFiles, isBundledEmit, emitOnlyDtsFiles); var emitSkipped = emitDeclarationResult.reportedDeclarationError || host.isEmitBlocked(declarationFilePath) || host.getCompilerOptions().noEmit; if (!emitSkipped) { var declarationOutput = emitDeclarationResult.referencesOutput @@ -54335,8 +55501,10 @@ var ts; TempFlags[TempFlags["CountMask"] = 268435455] = "CountMask"; TempFlags[TempFlags["_i"] = 268435456] = "_i"; })(TempFlags || (TempFlags = {})); + var id = function (s) { return s; }; + var nullTransformers = [function (ctx) { return id; }]; // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature - function emitFiles(resolver, host, targetSourceFile) { + function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles) { var delimiters = createDelimiterMap(); var brackets = createBracketsMap(); // emit output for the __extends helper function @@ -54352,7 +55520,7 @@ var ts; // emit output for the __param helper function var paramHelper = "\nvar __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; // emit output for the __awaiter helper function - var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments)).next());\n });\n};"; + var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments)).next());\n });\n};"; // The __generator helper is used by down-level transformations to emulate the runtime // semantics of an ES2015 generator function. When called, this helper returns an // object that implements the Iterator protocol, in that it has `next`, `return`, and @@ -54426,11 +55594,11 @@ var ts; var emittedFilesList = compilerOptions.listEmittedFiles ? [] : undefined; var emitterDiagnostics = ts.createDiagnosticCollection(); var newLine = host.getNewLine(); - var transformers = ts.getTransformers(compilerOptions); + var transformers = emitOnlyDtsFiles ? nullTransformers : ts.getTransformers(compilerOptions); var writer = ts.createTextWriter(newLine); var write = writer.write, writeLine = writer.writeLine, increaseIndent = writer.increaseIndent, decreaseIndent = writer.decreaseIndent; var sourceMap = ts.createSourceMapWriter(host, writer); - var emitStart = sourceMap.emitStart, emitEnd = sourceMap.emitEnd, emitTokenStart = sourceMap.emitTokenStart, emitTokenEnd = sourceMap.emitTokenEnd; + var emitNodeWithSourceMap = sourceMap.emitNodeWithSourceMap, emitTokenWithSourceMap = sourceMap.emitTokenWithSourceMap; var comments = ts.createCommentWriter(host, writer, sourceMap); var emitNodeWithComments = comments.emitNodeWithComments, emitBodyWithDetachedComments = comments.emitBodyWithDetachedComments, emitTrailingCommentsOfPosition = comments.emitTrailingCommentsOfPosition; var nodeIdToGeneratedName; @@ -54447,18 +55615,20 @@ var ts; var awaiterEmitted; var isOwnFileEmit; var emitSkipped = false; - ts.performance.mark("beforeTransform"); + var sourceFiles = ts.getSourceFilesToEmit(host, targetSourceFile); // Transform the source files - var transformed = ts.transformFiles(resolver, host, ts.getSourceFilesToEmit(host, targetSourceFile), transformers); + ts.performance.mark("beforeTransform"); + var _a = ts.transformFiles(resolver, host, sourceFiles, transformers), transformed = _a.transformed, emitNodeWithSubstitution = _a.emitNodeWithSubstitution, emitNodeWithNotification = _a.emitNodeWithNotification; ts.performance.measure("transformTime", "beforeTransform"); - // Extract helpers from the result - var getTokenSourceMapRange = transformed.getTokenSourceMapRange, isSubstitutionEnabled = transformed.isSubstitutionEnabled, isEmitNotificationEnabled = transformed.isEmitNotificationEnabled, onSubstituteNode = transformed.onSubstituteNode, onEmitNode = transformed.onEmitNode; - ts.performance.mark("beforePrint"); // Emit each output file - ts.forEachTransformedEmitFile(host, transformed.getSourceFiles(), emitFile); - // Clean up after transformation - transformed.dispose(); + ts.performance.mark("beforePrint"); + ts.forEachTransformedEmitFile(host, transformed, emitFile, emitOnlyDtsFiles); ts.performance.measure("printTime", "beforePrint"); + // Clean up emit nodes on parse tree + for (var _b = 0, sourceFiles_4 = sourceFiles; _b < sourceFiles_4.length; _b++) { + var sourceFile = sourceFiles_4[_b]; + ts.disposeEmitNodes(sourceFile); + } return { emitSkipped: emitSkipped, diagnostics: emitterDiagnostics.getDiagnostics(), @@ -54468,16 +55638,20 @@ var ts; function emitFile(jsFilePath, sourceMapFilePath, declarationFilePath, sourceFiles, isBundledEmit) { // Make sure not to write js file and source map file if any of them cannot be written if (!host.isEmitBlocked(jsFilePath) && !compilerOptions.noEmit) { - printFile(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit); + if (!emitOnlyDtsFiles) { + printFile(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit); + } } else { emitSkipped = true; } if (declarationFilePath) { - emitSkipped = ts.writeDeclarationFile(declarationFilePath, ts.getOriginalSourceFiles(sourceFiles), isBundledEmit, host, resolver, emitterDiagnostics) || emitSkipped; + emitSkipped = ts.writeDeclarationFile(declarationFilePath, ts.getOriginalSourceFiles(sourceFiles), isBundledEmit, host, resolver, emitterDiagnostics, emitOnlyDtsFiles) || emitSkipped; } if (!emitSkipped && emittedFilesList) { - emittedFilesList.push(jsFilePath); + if (!emitOnlyDtsFiles) { + emittedFilesList.push(jsFilePath); + } if (sourceMapFilePath) { emittedFilesList.push(sourceMapFilePath); } @@ -54494,8 +55668,8 @@ var ts; isOwnFileEmit = !isBundledEmit; // Emit helpers from all the files if (isBundledEmit && moduleKind) { - for (var _a = 0, sourceFiles_4 = sourceFiles; _a < sourceFiles_4.length; _a++) { - var sourceFile = sourceFiles_4[_a]; + for (var _a = 0, sourceFiles_5 = sourceFiles; _a < sourceFiles_5.length; _a++) { + var sourceFile = sourceFiles_5[_a]; emitEmitHelpers(sourceFile); } } @@ -54536,135 +55710,124 @@ var ts; currentFileIdentifiers = node.identifiers; sourceMap.setSourceFile(node); comments.setSourceFile(node); - emitNodeWithNotification(node, emitWorker); + pipelineEmitWithNotification(0 /* SourceFile */, node); } /** * Emits a node. */ function emit(node) { - emitNodeWithNotification(node, emitWithComments); + pipelineEmitWithNotification(3 /* Unspecified */, node); } /** - * Emits a node with comments. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called indirectly from emit. + * Emits an IdentifierName. */ - function emitWithComments(node) { - emitNodeWithComments(node, emitWithSourceMap); - } - /** - * Emits a node with source maps. - * - * NOTE: Do not call this method directly. It is part of the emit pipeline - * and should only be called indirectly from emitWithComments. - */ - function emitWithSourceMap(node) { - emitNodeWithSourceMap(node, emitWorker); - } function emitIdentifierName(node) { - if (node) { - emitNodeWithNotification(node, emitIdentifierNameWithComments); - } - } - function emitIdentifierNameWithComments(node) { - emitNodeWithComments(node, emitWorker); + pipelineEmitWithNotification(2 /* IdentifierName */, node); } /** * Emits an expression node. */ function emitExpression(node) { - emitNodeWithNotification(node, emitExpressionWithComments); + pipelineEmitWithNotification(1 /* Expression */, node); } /** - * Emits an expression with comments. + * Emits a node with possible notification. * - * NOTE: Do not call this method directly. It is part of the emitExpression pipeline - * and should only be called indirectly from emitExpression. + * NOTE: Do not call this method directly. It is part of the emit pipeline + * and should only be called from printSourceFile, emit, emitExpression, or + * emitIdentifierName. */ - function emitExpressionWithComments(node) { - emitNodeWithComments(node, emitExpressionWithSourceMap); + function pipelineEmitWithNotification(emitContext, node) { + emitNodeWithNotification(emitContext, node, pipelineEmitWithComments); } /** - * Emits an expression with source maps. + * Emits a node with comments. * - * NOTE: Do not call this method directly. It is part of the emitExpression pipeline - * and should only be called indirectly from emitExpressionWithComments. + * NOTE: Do not call this method directly. It is part of the emit pipeline + * and should only be called indirectly from pipelineEmitWithNotification. */ - function emitExpressionWithSourceMap(node) { - emitNodeWithSourceMap(node, emitExpressionWorker); - } - /** - * Emits a node with emit notification if available. - */ - function emitNodeWithNotification(node, emitCallback) { - if (node) { - if (isEmitNotificationEnabled(node)) { - onEmitNode(node, emitCallback); - } - else { - emitCallback(node); - } - } - } - function emitNodeWithSourceMap(node, emitCallback) { - if (node) { - emitStart(/*range*/ node, /*contextNode*/ node, shouldSkipLeadingSourceMapForNode, shouldSkipSourceMapForChildren, getSourceMapRange); - emitCallback(node); - emitEnd(/*range*/ node, /*contextNode*/ node, shouldSkipTrailingSourceMapForNode, shouldSkipSourceMapForChildren, getSourceMapRange); - } - } - function getSourceMapRange(node) { - return node.sourceMapRange || node; - } - /** - * Determines whether to skip leading comment emit for a node. - * - * We do not emit comments for NotEmittedStatement nodes or any node that has - * NodeEmitFlags.NoLeadingComments. - * - * @param node A Node. - */ - function shouldSkipLeadingCommentsForNode(node) { - return ts.isNotEmittedStatement(node) - || (node.emitFlags & 16384 /* NoLeadingComments */) !== 0; - } - /** - * Determines whether to skip source map emit for the start position of a node. - * - * We do not emit source maps for NotEmittedStatement nodes or any node that - * has NodeEmitFlags.NoLeadingSourceMap. - * - * @param node A Node. - */ - function shouldSkipLeadingSourceMapForNode(node) { - return ts.isNotEmittedStatement(node) - || (node.emitFlags & 512 /* NoLeadingSourceMap */) !== 0; - } - /** - * Determines whether to skip source map emit for the end position of a node. - * - * We do not emit source maps for NotEmittedStatement nodes or any node that - * has NodeEmitFlags.NoTrailingSourceMap. - * - * @param node A Node. - */ - function shouldSkipTrailingSourceMapForNode(node) { - return ts.isNotEmittedStatement(node) - || (node.emitFlags & 1024 /* NoTrailingSourceMap */) !== 0; - } - /** - * Determines whether to skip source map emit for a node and its children. - * - * We do not emit source maps for a node that has NodeEmitFlags.NoNestedSourceMaps. - */ - function shouldSkipSourceMapForChildren(node) { - return (node.emitFlags & 2048 /* NoNestedSourceMaps */) !== 0; - } - function emitWorker(node) { - if (tryEmitSubstitute(node, emitWorker, /*isExpression*/ false)) { + function pipelineEmitWithComments(emitContext, node) { + // Do not emit comments for SourceFile + if (emitContext === 0 /* SourceFile */) { + pipelineEmitWithSourceMap(emitContext, node); return; } + emitNodeWithComments(emitContext, node, pipelineEmitWithSourceMap); + } + /** + * Emits a node with source maps. + * + * NOTE: Do not call this method directly. It is part of the emit pipeline + * and should only be called indirectly from pipelineEmitWithComments. + */ + function pipelineEmitWithSourceMap(emitContext, node) { + // Do not emit source mappings for SourceFile or IdentifierName + if (emitContext === 0 /* SourceFile */ + || emitContext === 2 /* IdentifierName */) { + pipelineEmitWithSubstitution(emitContext, node); + return; + } + emitNodeWithSourceMap(emitContext, node, pipelineEmitWithSubstitution); + } + /** + * Emits a node with possible substitution. + * + * NOTE: Do not call this method directly. It is part of the emit pipeline + * and should only be called indirectly from pipelineEmitWithSourceMap or + * pipelineEmitInUnspecifiedContext (when picking a more specific context). + */ + function pipelineEmitWithSubstitution(emitContext, node) { + emitNodeWithSubstitution(emitContext, node, pipelineEmitForContext); + } + /** + * Emits a node. + * + * NOTE: Do not call this method directly. It is part of the emit pipeline + * and should only be called indirectly from pipelineEmitWithSubstitution. + */ + function pipelineEmitForContext(emitContext, node) { + switch (emitContext) { + case 0 /* SourceFile */: return pipelineEmitInSourceFileContext(node); + case 2 /* IdentifierName */: return pipelineEmitInIdentifierNameContext(node); + case 3 /* Unspecified */: return pipelineEmitInUnspecifiedContext(node); + case 1 /* Expression */: return pipelineEmitInExpressionContext(node); + } + } + /** + * Emits a node in the SourceFile EmitContext. + * + * NOTE: Do not call this method directly. It is part of the emit pipeline + * and should only be called indirectly from pipelineEmitForContext. + */ + function pipelineEmitInSourceFileContext(node) { + var kind = node.kind; + switch (kind) { + // Top-level nodes + case 256 /* SourceFile */: + return emitSourceFile(node); + } + } + /** + * Emits a node in the IdentifierName EmitContext. + * + * NOTE: Do not call this method directly. It is part of the emit pipeline + * and should only be called indirectly from pipelineEmitForContext. + */ + function pipelineEmitInIdentifierNameContext(node) { + var kind = node.kind; + switch (kind) { + // Identifiers + case 69 /* Identifier */: + return emitIdentifier(node); + } + } + /** + * Emits a node in the Unspecified EmitContext. + * + * NOTE: Do not call this method directly. It is part of the emit pipeline + * and should only be called indirectly from pipelineEmitForContext. + */ + function pipelineEmitInUnspecifiedContext(node) { var kind = node.kind; switch (kind) { // Pseudo-literals @@ -54696,7 +55859,8 @@ var ts; case 132 /* StringKeyword */: case 133 /* SymbolKeyword */: case 137 /* GlobalKeyword */: - return writeTokenNode(node); + writeTokenText(kind); + return; // Parse tree nodes // Names case 139 /* QualifiedName */: @@ -54886,18 +56050,20 @@ var ts; // Enum case 255 /* EnumMember */: return emitEnumMember(node); - // Top-level nodes - case 256 /* SourceFile */: - return emitSourceFile(node); } + // If the node is an expression, try to emit it as an expression with + // substitution. if (ts.isExpression(node)) { - return emitExpressionWorker(node); + return pipelineEmitWithSubstitution(1 /* Expression */, node); } } - function emitExpressionWorker(node) { - if (tryEmitSubstitute(node, emitExpressionWorker, /*isExpression*/ true)) { - return; - } + /** + * Emits a node in the Expression EmitContext. + * + * NOTE: Do not call this method directly. It is part of the emit pipeline + * and should only be called indirectly from pipelineEmitForContext. + */ + function pipelineEmitInExpressionContext(node) { var kind = node.kind; switch (kind) { // Literals @@ -54916,7 +56082,8 @@ var ts; case 95 /* SuperKeyword */: case 99 /* TrueKeyword */: case 97 /* ThisKeyword */: - return writeTokenNode(node); + writeTokenText(kind); + return; // Expressions case 170 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); @@ -55010,7 +56177,7 @@ var ts; // Identifiers // function emitIdentifier(node) { - if (node.emitFlags & 16 /* UMDDefine */) { + if (ts.getEmitFlags(node) & 16 /* UMDDefine */) { writeLines(umdHelper); } else { @@ -55243,7 +56410,7 @@ var ts; write("{}"); } else { - var indentedFlag = node.emitFlags & 524288 /* Indented */; + var indentedFlag = ts.getEmitFlags(node) & 524288 /* Indented */; if (indentedFlag) { increaseIndent(); } @@ -55256,21 +56423,18 @@ var ts; } } function emitPropertyAccessExpression(node) { - if (tryEmitConstantValue(node)) { - return; - } var indentBeforeDot = false; var indentAfterDot = false; - if (!(node.emitFlags & 1048576 /* NoIndentation */)) { + if (!(ts.getEmitFlags(node) & 1048576 /* NoIndentation */)) { var dotRangeStart = node.expression.end; var dotRangeEnd = ts.skipTrivia(currentText, node.expression.end) + 1; var dotToken = { kind: 21 /* DotToken */, pos: dotRangeStart, end: dotRangeEnd }; indentBeforeDot = needsIndentation(node, node.expression, dotToken); indentAfterDot = needsIndentation(node, dotToken, node.name); } - var shouldEmitDotDot = !indentBeforeDot && needsDotDotForPropertyAccess(node.expression); emitExpression(node.expression); increaseIndentIf(indentBeforeDot); + var shouldEmitDotDot = !indentBeforeDot && needsDotDotForPropertyAccess(node.expression); write(shouldEmitDotDot ? ".." : "."); increaseIndentIf(indentAfterDot); emit(node.name); @@ -55284,17 +56448,16 @@ var ts; var text = getLiteralTextOfNode(expression); return text.indexOf(ts.tokenToString(21 /* DotToken */)) < 0; } - else { + else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { // check if constant enum value is integer - var constantValue = tryGetConstEnumValue(expression); + var constantValue = ts.getConstantValue(expression); // isFinite handles cases when constantValue is undefined - return isFinite(constantValue) && Math.floor(constantValue) === constantValue; + return isFinite(constantValue) + && Math.floor(constantValue) === constantValue + && compilerOptions.removeComments; } } function emitElementAccessExpression(node) { - if (tryEmitConstantValue(node)) { - return; - } emitExpression(node.expression); write("["); emitExpression(node.argumentExpression); @@ -55467,7 +56630,7 @@ var ts; } } function emitBlockStatements(node) { - if (node.emitFlags & 32 /* SingleLine */) { + if (ts.getEmitFlags(node) & 32 /* SingleLine */) { emitList(node, node.statements, 384 /* SingleLineBlockStatements */); } else { @@ -55645,11 +56808,11 @@ var ts; var body = node.body; if (body) { if (ts.isBlock(body)) { - var indentedFlag = node.emitFlags & 524288 /* Indented */; + var indentedFlag = ts.getEmitFlags(node) & 524288 /* Indented */; if (indentedFlag) { increaseIndent(); } - if (node.emitFlags & 4194304 /* ReuseTempVariableScope */) { + if (ts.getEmitFlags(node) & 4194304 /* ReuseTempVariableScope */) { emitSignatureHead(node); emitBlockFunctionBody(node, body); } @@ -55687,7 +56850,7 @@ var ts; // * The body is explicitly marked as multi-line. // * A non-synthesized body's start and end position are on different lines. // * Any statement in the body starts on a new line. - if (body.emitFlags & 32 /* SingleLine */) { + if (ts.getEmitFlags(body) & 32 /* SingleLine */) { return true; } if (body.multiLine) { @@ -55743,7 +56906,7 @@ var ts; emitModifiers(node, node.modifiers); write("class"); emitNodeWithPrefix(" ", node.name, emitIdentifierName); - var indentedFlag = node.emitFlags & 524288 /* Indented */; + var indentedFlag = ts.getEmitFlags(node) & 524288 /* Indented */; if (indentedFlag) { increaseIndent(); } @@ -55805,7 +56968,7 @@ var ts; emit(body); } function emitModuleBlock(node) { - if (isSingleLineEmptyBlock(node)) { + if (isEmptyBlock(node)) { write("{ }"); } else { @@ -56023,8 +57186,8 @@ var ts; // "comment1" is not considered to be leading comment for node.initializer // but rather a trailing comment on the previous node. var initializer = node.initializer; - if (!shouldSkipLeadingCommentsForNode(initializer)) { - var commentRange = initializer.commentRange || initializer; + if ((ts.getEmitFlags(initializer) & 16384 /* NoLeadingComments */) === 0) { + var commentRange = ts.getCommentRange(initializer); emitTrailingCommentsOfPosition(commentRange.pos); } emitExpression(initializer); @@ -56084,7 +57247,7 @@ var ts; return statements.length; } function emitHelpers(node) { - var emitFlags = node.emitFlags; + var emitFlags = ts.getEmitFlags(node); var helpersEmitted = false; if (emitFlags & 1 /* EmitEmitHelpers */) { helpersEmitted = emitEmitHelpers(currentSourceFile); @@ -56197,31 +57360,6 @@ var ts; write(suffix); } } - function tryEmitSubstitute(node, emitNode, isExpression) { - if (isSubstitutionEnabled(node) && (node.emitFlags & 128 /* NoSubstitution */) === 0) { - var substitute = onSubstituteNode(node, isExpression); - if (substitute !== node) { - substitute.emitFlags |= 128 /* NoSubstitution */; - emitNode(substitute); - return true; - } - } - return false; - } - function tryEmitConstantValue(node) { - var constantValue = tryGetConstEnumValue(node); - if (constantValue !== undefined) { - write(String(constantValue)); - if (!compilerOptions.removeComments) { - var propertyName = ts.isPropertyAccessExpression(node) - ? ts.declarationNameToString(node.name) - : getTextOfNode(node.argumentExpression); - write(" /* " + propertyName + " */"); - } - return true; - } - return false; - } function emitEmbeddedStatement(node) { if (ts.isBlock(node)) { write(" "); @@ -56329,7 +57467,7 @@ var ts; } } if (shouldEmitInterveningComments) { - var commentRange = child.commentRange || child; + var commentRange = ts.getCommentRange(child); emitTrailingCommentsOfPosition(commentRange.pos); } else { @@ -56375,27 +57513,12 @@ var ts; } } function writeToken(token, pos, contextNode) { - var tokenStartPos = emitTokenStart(token, pos, contextNode, shouldSkipLeadingSourceMapForToken, getTokenSourceMapRange); - var tokenEndPos = writeTokenText(token, tokenStartPos); - return emitTokenEnd(token, tokenEndPos, contextNode, shouldSkipTrailingSourceMapForToken, getTokenSourceMapRange); - } - function shouldSkipLeadingSourceMapForToken(contextNode) { - return (contextNode.emitFlags & 4096 /* NoTokenLeadingSourceMaps */) !== 0; - } - function shouldSkipTrailingSourceMapForToken(contextNode) { - return (contextNode.emitFlags & 8192 /* NoTokenTrailingSourceMaps */) !== 0; + return emitTokenWithSourceMap(contextNode, token, pos, writeTokenText); } function writeTokenText(token, pos) { var tokenString = ts.tokenToString(token); write(tokenString); - return ts.positionIsSynthesized(pos) ? -1 : pos + tokenString.length; - } - function writeTokenNode(node) { - if (node) { - emitStart(/*range*/ node, /*contextNode*/ node, shouldSkipLeadingSourceMapForNode, shouldSkipSourceMapForChildren, getSourceMapRange); - writeTokenText(node.kind); - emitEnd(/*range*/ node, /*contextNode*/ node, shouldSkipTrailingSourceMapForNode, shouldSkipSourceMapForChildren, getSourceMapRange); - } + return pos < 0 ? pos : pos + tokenString.length; } function increaseIndentIf(value, valueToWriteWhenNotIndenting) { if (value) { @@ -56539,17 +57662,12 @@ var ts; } return ts.getLiteralText(node, currentSourceFile, languageVersion); } - function tryGetConstEnumValue(node) { - if (compilerOptions.isolatedModules) { - return undefined; - } - return ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node) - ? resolver.getConstantValue(node) - : undefined; - } function isSingleLineEmptyBlock(block) { return !block.multiLine - && block.statements.length === 0 + && isEmptyBlock(block); + } + function isEmptyBlock(block) { + return block.statements.length === 0 && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function isUniqueName(name) { @@ -56878,695 +57996,6 @@ var ts; return ts.getNormalizedPathFromPathComponents(commonPathComponents); } ts.computeCommonSourceDirectoryOfFilenames = computeCommonSourceDirectoryOfFilenames; - function trace(host, message) { - host.trace(ts.formatMessage.apply(undefined, arguments)); - } - function isTraceEnabled(compilerOptions, host) { - return compilerOptions.traceResolution && host.trace !== undefined; - } - /* @internal */ - function hasZeroOrOneAsteriskCharacter(str) { - var seenAsterisk = false; - for (var i = 0; i < str.length; i++) { - if (str.charCodeAt(i) === 42 /* asterisk */) { - if (!seenAsterisk) { - seenAsterisk = true; - } - else { - // have already seen asterisk - return false; - } - } - } - return true; - } - ts.hasZeroOrOneAsteriskCharacter = hasZeroOrOneAsteriskCharacter; - function createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations) { - return { resolvedModule: resolvedFileName ? { resolvedFileName: resolvedFileName, isExternalLibraryImport: isExternalLibraryImport } : undefined, failedLookupLocations: failedLookupLocations }; - } - function moduleHasNonRelativeName(moduleName) { - return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); - } - function tryReadTypesSection(packageJsonPath, baseDirectory, state) { - var jsonContent = readJson(packageJsonPath, state.host); - function tryReadFromField(fieldName) { - if (ts.hasProperty(jsonContent, fieldName)) { - var typesFile = jsonContent[fieldName]; - if (typeof typesFile === "string") { - var typesFilePath_1 = ts.normalizePath(ts.combinePaths(baseDirectory, typesFile)); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath_1); - } - return typesFilePath_1; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof typesFile); - } - } - } - } - var typesFilePath = tryReadFromField("typings") || tryReadFromField("types"); - if (typesFilePath) { - return typesFilePath; - } - // Use the main module for inferring types if no types package specified and the allowJs is set - if (state.compilerOptions.allowJs && jsonContent.main && typeof jsonContent.main === "string") { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0, jsonContent.main); - } - var mainFilePath = ts.normalizePath(ts.combinePaths(baseDirectory, jsonContent.main)); - return mainFilePath; - } - return undefined; - } - function readJson(path, host) { - try { - var jsonText = host.readFile(path); - return jsonText ? JSON.parse(jsonText) : {}; - } - catch (e) { - // gracefully handle if readFile fails or returns not JSON - return {}; - } - } - var typeReferenceExtensions = [".d.ts"]; - function getEffectiveTypeRoots(options, host) { - if (options.typeRoots) { - return options.typeRoots; - } - var currentDirectory; - if (options.configFilePath) { - currentDirectory = ts.getDirectoryPath(options.configFilePath); - } - else if (host.getCurrentDirectory) { - currentDirectory = host.getCurrentDirectory(); - } - return currentDirectory && getDefaultTypeRoots(currentDirectory, host); - } - ts.getEffectiveTypeRoots = getEffectiveTypeRoots; - /** - * Returns the path to every node_modules/@types directory from some ancestor directory. - * Returns undefined if there are none. - */ - function getDefaultTypeRoots(currentDirectory, host) { - if (!host.directoryExists) { - return [ts.combinePaths(currentDirectory, nodeModulesAtTypes)]; - } - var typeRoots; - while (true) { - var atTypes = ts.combinePaths(currentDirectory, nodeModulesAtTypes); - if (host.directoryExists(atTypes)) { - (typeRoots || (typeRoots = [])).push(atTypes); - } - var parent_15 = ts.getDirectoryPath(currentDirectory); - if (parent_15 === currentDirectory) { - break; - } - currentDirectory = parent_15; - } - return typeRoots; - } - var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types"); - /** - * @param {string | undefined} containingFile - file that contains type reference directive, can be undefined if containing file is unknown. - * This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups - * is assumed to be the same as root directory of the project. - */ - function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host) { - var traceEnabled = isTraceEnabled(options, host); - var moduleResolutionState = { - compilerOptions: options, - host: host, - skipTsx: true, - traceEnabled: traceEnabled - }; - var typeRoots = getEffectiveTypeRoots(options, host); - if (traceEnabled) { - if (containingFile === undefined) { - if (typeRoots === undefined) { - trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set, typeReferenceDirectiveName); - } - else { - trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1, typeReferenceDirectiveName, typeRoots); - } - } - else { - if (typeRoots === undefined) { - trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set, typeReferenceDirectiveName, containingFile); - } - else { - trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, typeRoots); - } - } - } - var failedLookupLocations = []; - // Check primary library paths - if (typeRoots && typeRoots.length) { - if (traceEnabled) { - trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", ")); - } - var primarySearchPaths = typeRoots; - for (var _i = 0, primarySearchPaths_1 = primarySearchPaths; _i < primarySearchPaths_1.length; _i++) { - var typeRoot = primarySearchPaths_1[_i]; - var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); - var candidateDirectory = ts.getDirectoryPath(candidate); - var resolvedFile_1 = loadNodeModuleFromDirectory(typeReferenceExtensions, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState); - if (resolvedFile_1) { - if (traceEnabled) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile_1, true); - } - return { - resolvedTypeReferenceDirective: { primary: true, resolvedFileName: resolvedFile_1 }, - failedLookupLocations: failedLookupLocations - }; - } - } - } - else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths); - } - } - var resolvedFile; - var initialLocationForSecondaryLookup; - if (containingFile) { - initialLocationForSecondaryLookup = ts.getDirectoryPath(containingFile); - } - if (initialLocationForSecondaryLookup !== undefined) { - // check secondary locations - if (traceEnabled) { - trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); - } - resolvedFile = loadModuleFromNodeModules(typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState); - if (traceEnabled) { - if (resolvedFile) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile, false); - } - else { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); - } - } - } - else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder); - } - } - return { - resolvedTypeReferenceDirective: resolvedFile - ? { primary: false, resolvedFileName: resolvedFile } - : undefined, - failedLookupLocations: failedLookupLocations - }; - } - ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective; - function resolveModuleName(moduleName, containingFile, compilerOptions, host) { - var traceEnabled = isTraceEnabled(compilerOptions, host); - if (traceEnabled) { - trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile); - } - var moduleResolution = compilerOptions.moduleResolution; - if (moduleResolution === undefined) { - moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; - if (traceEnabled) { - trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); - } - } - else { - if (traceEnabled) { - trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]); - } - } - var result; - switch (moduleResolution) { - case ts.ModuleResolutionKind.NodeJs: - result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host); - break; - case ts.ModuleResolutionKind.Classic: - result = classicNameResolver(moduleName, containingFile, compilerOptions, host); - break; - } - if (traceEnabled) { - if (result.resolvedModule) { - trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.resolvedModule.resolvedFileName); - } - else { - trace(host, ts.Diagnostics.Module_name_0_was_not_resolved, moduleName); - } - } - return result; - } - ts.resolveModuleName = resolveModuleName; - /** - * Any module resolution kind can be augmented with optional settings: 'baseUrl', 'paths' and 'rootDirs' - they are used to - * mitigate differences between design time structure of the project and its runtime counterpart so the same import name - * can be resolved successfully by TypeScript compiler and runtime module loader. - * If these settings are set then loading procedure will try to use them to resolve module name and it can of failure it will - * fallback to standard resolution routine. - * - * - baseUrl - this setting controls how non-relative module names are resolved. If this setting is specified then non-relative - * names will be resolved relative to baseUrl: i.e. if baseUrl is '/a/b' then candidate location to resolve module name 'c/d' will - * be '/a/b/c/d' - * - paths - this setting can only be used when baseUrl is specified. allows to tune how non-relative module names - * will be resolved based on the content of the module name. - * Structure of 'paths' compiler options - * 'paths': { - * pattern-1: [...substitutions], - * pattern-2: [...substitutions], - * ... - * pattern-n: [...substitutions] - * } - * Pattern here is a string that can contain zero or one '*' character. During module resolution module name will be matched against - * all patterns in the list. Matching for patterns that don't contain '*' means that module name must be equal to pattern respecting the case. - * If pattern contains '*' then to match pattern "*" module name must start with the and end with . - * denotes part of the module name between and . - * If module name can be matches with multiple patterns then pattern with the longest prefix will be picked. - * After selecting pattern we'll use list of substitutions to get candidate locations of the module and the try to load module - * from the candidate location. - * Substitution is a string that can contain zero or one '*'. To get candidate location from substitution we'll pick every - * substitution in the list and replace '*' with string. If candidate location is not rooted it - * will be converted to absolute using baseUrl. - * For example: - * baseUrl: /a/b/c - * "paths": { - * // match all module names - * "*": [ - * "*", // use matched name as is, - * // will be looked as /a/b/c/ - * - * "folder1/*" // substitution will convert matched name to 'folder1/', - * // since it is not rooted then final candidate location will be /a/b/c/folder1/ - * ], - * // match module names that start with 'components/' - * "components/*": [ "/root/components/*" ] // substitution will convert /components/folder1/ to '/root/components/folder1/', - * // it is rooted so it will be final candidate location - * } - * - * 'rootDirs' allows the project to be spreaded across multiple locations and resolve modules with relative names as if - * they were in the same location. For example lets say there are two files - * '/local/src/content/file1.ts' - * '/shared/components/contracts/src/content/protocols/file2.ts' - * After bundling content of '/shared/components/contracts/src' will be merged with '/local/src' so - * if file1 has the following import 'import {x} from "./protocols/file2"' it will be resolved successfully in runtime. - * 'rootDirs' provides the way to tell compiler that in order to get the whole project it should behave as if content of all - * root dirs were merged together. - * I.e. for the example above 'rootDirs' will have two entries: [ '/local/src', '/shared/components/contracts/src' ]. - * Compiler will first convert './protocols/file2' into absolute path relative to the location of containing file: - * '/local/src/content/protocols/file2' and try to load it - failure. - * Then it will search 'rootDirs' looking for a longest matching prefix of this absolute path and if such prefix is found - absolute path will - * be converted to a path relative to found rootDir entry './content/protocols/file2' (*). As a last step compiler will check all remaining - * entries in 'rootDirs', use them to build absolute path out of (*) and try to resolve module from this location. - */ - function tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { - if (moduleHasNonRelativeName(moduleName)) { - return tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state); - } - else { - return tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state); - } - } - function tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { - if (!state.compilerOptions.rootDirs) { - return undefined; - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0, moduleName); - } - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var matchedRootDir; - var matchedNormalizedPrefix; - for (var _i = 0, _a = state.compilerOptions.rootDirs; _i < _a.length; _i++) { - var rootDir = _a[_i]; - // rootDirs are expected to be absolute - // in case of tsconfig.json this will happen automatically - compiler will expand relative names - // using location of tsconfig.json as base location - var normalizedRoot = ts.normalizePath(rootDir); - if (!ts.endsWith(normalizedRoot, ts.directorySeparator)) { - normalizedRoot += ts.directorySeparator; - } - var isLongestMatchingPrefix = ts.startsWith(candidate, normalizedRoot) && - (matchedNormalizedPrefix === undefined || matchedNormalizedPrefix.length < normalizedRoot.length); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Checking_if_0_is_the_longest_matching_prefix_for_1_2, normalizedRoot, candidate, isLongestMatchingPrefix); - } - if (isLongestMatchingPrefix) { - matchedNormalizedPrefix = normalizedRoot; - matchedRootDir = rootDir; - } - } - if (matchedNormalizedPrefix) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Longest_matching_prefix_for_0_is_1, candidate, matchedNormalizedPrefix); - } - var suffix = candidate.substr(matchedNormalizedPrefix.length); - // first - try to load from a initial location - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, matchedNormalizedPrefix, candidate); - } - var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(containingDirectory, state.host), state); - if (resolvedFileName) { - return resolvedFileName; - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Trying_other_entries_in_rootDirs); - } - // then try to resolve using remaining entries in rootDirs - for (var _b = 0, _c = state.compilerOptions.rootDirs; _b < _c.length; _b++) { - var rootDir = _c[_b]; - if (rootDir === matchedRootDir) { - // skip the initially matched entry - continue; - } - var candidate_1 = ts.combinePaths(ts.normalizePath(rootDir), suffix); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, rootDir, candidate_1); - } - var baseDirectory = ts.getDirectoryPath(candidate_1); - var resolvedFileName_1 = loader(candidate_1, supportedExtensions, failedLookupLocations, !directoryProbablyExists(baseDirectory, state.host), state); - if (resolvedFileName_1) { - return resolvedFileName_1; - } - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Module_resolution_using_rootDirs_has_failed); - } - } - return undefined; - } - function tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state) { - if (!state.compilerOptions.baseUrl) { - return undefined; - } - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, state.compilerOptions.baseUrl, moduleName); - } - // string is for exact match - var matchedPattern = undefined; - if (state.compilerOptions.paths) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); - } - matchedPattern = matchPatternOrExact(ts.getOwnKeys(state.compilerOptions.paths), moduleName); - } - if (matchedPattern) { - var matchedStar = typeof matchedPattern === "string" ? undefined : matchedText(matchedPattern, moduleName); - var matchedPatternText = typeof matchedPattern === "string" ? matchedPattern : patternText(matchedPattern); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPatternText); - } - for (var _i = 0, _a = state.compilerOptions.paths[matchedPatternText]; _i < _a.length; _i++) { - var subst = _a[_i]; - var path = matchedStar ? subst.replace("*", matchedStar) : subst; - var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, path)); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path); - } - var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); - if (resolvedFileName) { - return resolvedFileName; - } - } - return undefined; - } - else { - var candidate = ts.normalizePath(ts.combinePaths(state.compilerOptions.baseUrl, moduleName)); - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Resolving_module_name_0_relative_to_base_url_1_2, moduleName, state.compilerOptions.baseUrl, candidate); - } - return loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); - } - } - /** - * patternStrings contains both pattern strings (containing "*") and regular strings. - * Return an exact match if possible, or a pattern match, or undefined. - * (These are verified by verifyCompilerOptions to have 0 or 1 "*" characters.) - */ - function matchPatternOrExact(patternStrings, candidate) { - var patterns = []; - for (var _i = 0, patternStrings_1 = patternStrings; _i < patternStrings_1.length; _i++) { - var patternString = patternStrings_1[_i]; - var pattern = tryParsePattern(patternString); - if (pattern) { - patterns.push(pattern); - } - else if (patternString === candidate) { - // pattern was matched as is - no need to search further - return patternString; - } - } - return findBestPatternMatch(patterns, function (_) { return _; }, candidate); - } - function patternText(_a) { - var prefix = _a.prefix, suffix = _a.suffix; - return prefix + "*" + suffix; - } - /** - * Given that candidate matches pattern, returns the text matching the '*'. - * E.g.: matchedText(tryParsePattern("foo*baz"), "foobarbaz") === "bar" - */ - function matchedText(pattern, candidate) { - ts.Debug.assert(isPatternMatch(pattern, candidate)); - return candidate.substr(pattern.prefix.length, candidate.length - pattern.suffix.length); - } - /** Return the object corresponding to the best pattern to match `candidate`. */ - /* @internal */ - function findBestPatternMatch(values, getPattern, candidate) { - var matchedValue = undefined; - // use length of prefix as betterness criteria - var longestMatchPrefixLength = -1; - for (var _i = 0, values_1 = values; _i < values_1.length; _i++) { - var v = values_1[_i]; - var pattern = getPattern(v); - if (isPatternMatch(pattern, candidate) && pattern.prefix.length > longestMatchPrefixLength) { - longestMatchPrefixLength = pattern.prefix.length; - matchedValue = v; - } - } - return matchedValue; - } - ts.findBestPatternMatch = findBestPatternMatch; - function isPatternMatch(_a, candidate) { - var prefix = _a.prefix, suffix = _a.suffix; - return candidate.length >= prefix.length + suffix.length && - ts.startsWith(candidate, prefix) && - ts.endsWith(candidate, suffix); - } - /* @internal */ - function tryParsePattern(pattern) { - // This should be verified outside of here and a proper error thrown. - ts.Debug.assert(hasZeroOrOneAsteriskCharacter(pattern)); - var indexOfStar = pattern.indexOf("*"); - return indexOfStar === -1 ? undefined : { - prefix: pattern.substr(0, indexOfStar), - suffix: pattern.substr(indexOfStar + 1) - }; - } - ts.tryParsePattern = tryParsePattern; - function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host) { - var containingDirectory = ts.getDirectoryPath(containingFile); - var supportedExtensions = ts.getSupportedExtensions(compilerOptions); - var traceEnabled = isTraceEnabled(compilerOptions, host); - var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: false }; - var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, supportedExtensions, state); - var isExternalLibraryImport = false; - if (!resolvedFileName) { - if (moduleHasNonRelativeName(moduleName)) { - if (traceEnabled) { - trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder, moduleName); - } - resolvedFileName = loadModuleFromNodeModules(moduleName, containingDirectory, failedLookupLocations, state); - isExternalLibraryImport = resolvedFileName !== undefined; - } - else { - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - resolvedFileName = nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, /*onlyRecordFailures*/ false, state); - } - } - if (resolvedFileName && host.realpath) { - var originalFileName = resolvedFileName; - resolvedFileName = ts.normalizePath(host.realpath(resolvedFileName)); - if (traceEnabled) { - trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, originalFileName, resolvedFileName); - } - } - return createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations); - } - ts.nodeModuleNameResolver = nodeModuleNameResolver; - function nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate); - } - var resolvedFileName = !ts.pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state); - return resolvedFileName || loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, onlyRecordFailures, state); - } - /* @internal */ - function directoryProbablyExists(directoryName, host) { - // if host does not support 'directoryExists' assume that directory will exist - return !host.directoryExists || host.directoryExists(directoryName); - } - ts.directoryProbablyExists = directoryProbablyExists; - /** - * @param {boolean} onlyRecordFailures - if true then function won't try to actually load files but instead record all attempts as failures. This flag is necessary - * in cases when we know upfront that all load attempts will fail (because containing folder does not exists) however we still need to record all failed lookup locations. - */ - function loadModuleFromFile(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) { - // First, try adding an extension. An import of "foo" could be matched by a file "foo.ts", or "foo.js" by "foo.js.ts" - var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state); - if (resolvedByAddingExtension) { - return resolvedByAddingExtension; - } - // If that didn't work, try stripping a ".js" or ".jsx" extension and replacing it with a TypeScript one; - // e.g. "./foo.js" can be matched by "./foo.ts" or "./foo.d.ts" - if (ts.hasJavaScriptFileExtension(candidate)) { - var extensionless = ts.removeFileExtension(candidate); - if (state.traceEnabled) { - var extension = candidate.substring(extensionless.length); - trace(state.host, ts.Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension); - } - return tryAddingExtensions(extensionless, extensions, failedLookupLocation, onlyRecordFailures, state); - } - } - /** Try to return an existing file that adds one of the `extensions` to `candidate`. */ - function tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) { - if (!onlyRecordFailures) { - // check if containing folder exists - if it doesn't then just record failures for all supported extensions without disk probing - var directory = ts.getDirectoryPath(candidate); - if (directory) { - onlyRecordFailures = !directoryProbablyExists(directory, state.host); - } - } - return ts.forEach(extensions, function (ext) { - return !(state.skipTsx && ts.isJsxOrTsxExtension(ext)) && tryFile(candidate + ext, failedLookupLocation, onlyRecordFailures, state); - }); - } - /** Return the file if it exists. */ - function tryFile(fileName, failedLookupLocation, onlyRecordFailures, state) { - if (!onlyRecordFailures && state.host.fileExists(fileName)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); - } - return fileName; - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName); - } - failedLookupLocation.push(fileName); - return undefined; - } - } - function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocation, onlyRecordFailures, state) { - var packageJsonPath = pathToPackageJson(candidate); - var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); - if (directoryExists && state.host.fileExists(packageJsonPath)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); - } - var typesFile = tryReadTypesSection(packageJsonPath, candidate, state); - if (typesFile) { - var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(typesFile), state.host); - // A package.json "typings" may specify an exact filename, or may choose to omit an extension. - var result = tryFile(typesFile, failedLookupLocation, onlyRecordFailures_1, state) || - tryAddingExtensions(typesFile, extensions, failedLookupLocation, onlyRecordFailures_1, state); - if (result) { - return result; - } - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_does_not_have_types_field); - } - } - } - else { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); - } - // 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 loadModuleFromFile(ts.combinePaths(candidate, "index"), extensions, failedLookupLocation, !directoryExists, state); - } - function pathToPackageJson(directory) { - return ts.combinePaths(directory, "package.json"); - } - function loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state) { - var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); - var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); - var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); - var supportedExtensions = ts.getSupportedExtensions(state.compilerOptions); - var result = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, !nodeModulesFolderExists, state); - if (result) { - return result; - } - result = loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); - if (result) { - return result; - } - } - function loadModuleFromNodeModules(moduleName, directory, failedLookupLocations, state) { - directory = ts.normalizeSlashes(directory); - while (true) { - var baseName = ts.getBaseFileName(directory); - if (baseName !== "node_modules") { - // Try to load source from the package - var packageResult = loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state); - if (packageResult && ts.hasTypeScriptFileExtension(packageResult)) { - // Always prefer a TypeScript (.ts, .tsx, .d.ts) file shipped with the package - return packageResult; - } - else { - // Else prefer a types package over non-TypeScript results (e.g. JavaScript files) - var typesResult = loadModuleFromNodeModulesFolder(ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); - if (typesResult || packageResult) { - return typesResult || packageResult; - } - } - } - var parentPath = ts.getDirectoryPath(directory); - if (parentPath === directory) { - break; - } - directory = parentPath; - } - return undefined; - } - function classicNameResolver(moduleName, containingFile, compilerOptions, host) { - var traceEnabled = isTraceEnabled(compilerOptions, host); - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: !compilerOptions.jsx }; - var failedLookupLocations = []; - var supportedExtensions = ts.getSupportedExtensions(compilerOptions); - var containingDirectory = ts.getDirectoryPath(containingFile); - var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, supportedExtensions, state); - if (resolvedFileName) { - return createResolvedModule(resolvedFileName, /*isExternalLibraryImport*/ false, failedLookupLocations); - } - var referencedSourceFile; - if (moduleHasNonRelativeName(moduleName)) { - while (true) { - var searchName = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - referencedSourceFile = loadModuleFromFile(searchName, supportedExtensions, failedLookupLocations, /*onlyRecordFailures*/ false, state); - if (referencedSourceFile) { - break; - } - var parentPath = ts.getDirectoryPath(containingDirectory); - if (parentPath === containingDirectory) { - break; - } - containingDirectory = parentPath; - } - } - else { - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - referencedSourceFile = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, /*onlyRecordFailures*/ false, state); - } - return referencedSourceFile - ? { resolvedModule: { resolvedFileName: referencedSourceFile }, failedLookupLocations: failedLookupLocations } - : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; - } - ts.classicNameResolver = classicNameResolver; function createCompilerHost(options, setParentNodes) { var existingDirectories = ts.createMap(); function getCanonicalFileName(fileName) { @@ -57672,7 +58101,7 @@ var ts; readFile: function (fileName) { return ts.sys.readFile(fileName); }, trace: function (s) { return ts.sys.write(s + newLine); }, directoryExists: function (directoryName) { return ts.sys.directoryExists(directoryName); }, - getEnvironmentVariable: function (name) { return ts.getEnvironmentVariable(name, /*host*/ undefined); }, + getEnvironmentVariable: function (name) { return ts.sys.getEnvironmentVariable ? ts.sys.getEnvironmentVariable(name) : ""; }, getDirectories: function (path) { return ts.sys.getDirectories(path); }, realpath: realpath }; @@ -57740,45 +58169,6 @@ var ts; } return resolutions; } - /** - * Given a set of options, returns the set of type directive names - * that should be included for this program automatically. - * This list could either come from the config file, - * or from enumerating the types root + initial secondary types lookup location. - * More type directives might appear in the program later as a result of loading actual source files; - * this list is only the set of defaults that are implicitly included. - */ - function getAutomaticTypeDirectiveNames(options, host) { - // Use explicit type list from tsconfig.json - if (options.types) { - return options.types; - } - // Walk the primary type lookup locations - var result = []; - if (host.directoryExists && host.getDirectories) { - var typeRoots = getEffectiveTypeRoots(options, host); - if (typeRoots) { - for (var _i = 0, typeRoots_1 = typeRoots; _i < typeRoots_1.length; _i++) { - var root = typeRoots_1[_i]; - if (host.directoryExists(root)) { - for (var _a = 0, _b = host.getDirectories(root); _a < _b.length; _a++) { - var typeDirectivePath = _b[_a]; - var normalized = ts.normalizePath(typeDirectivePath); - var packageJsonPath = pathToPackageJson(ts.combinePaths(root, normalized)); - // tslint:disable-next-line:no-null-keyword - var isNotNeededPackage = host.fileExists(packageJsonPath) && readJson(packageJsonPath, host).typings === null; - if (!isNotNeededPackage) { - // Return just the type directive names - result.push(ts.getBaseFileName(normalized)); - } - } - } - } - } - } - return result; - } - ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; function createProgram(rootNames, options, host, oldProgram) { var program; var files = []; @@ -57815,7 +58205,7 @@ var ts; resolveModuleNamesWorker = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }; } else { - var loader_1 = function (moduleName, containingFile) { return resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }; + var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }; resolveModuleNamesWorker = function (moduleNames, containingFile) { return loadWithLocalCache(moduleNames, containingFile, loader_1); }; } var resolveTypeReferenceDirectiveNamesWorker; @@ -57823,7 +58213,7 @@ var ts; resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile) { return host.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile); }; } else { - var loader_2 = function (typesRef, containingFile) { return resolveTypeReferenceDirective(typesRef, containingFile, options, host).resolvedTypeReferenceDirective; }; + var loader_2 = function (typesRef, containingFile) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host).resolvedTypeReferenceDirective; }; resolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile) { return loadWithLocalCache(typeReferenceDirectiveNames, containingFile, loader_2); }; } var filesByName = ts.createFileMap(); @@ -57833,8 +58223,8 @@ var ts; if (!tryReuseStructureFromOldProgram()) { ts.forEach(rootNames, function (name) { return processRootFile(name, /*isDefaultLib*/ false); }); // load type declarations specified via 'types' argument or implicitly from types/ and node_modules/@types folders - var typeReferences = getAutomaticTypeDirectiveNames(options, host); - if (typeReferences) { + var typeReferences = ts.getAutomaticTypeDirectiveNames(options, host); + if (typeReferences.length) { // This containingFilename needs to match with the one used in managed-side var containingFilename = ts.combinePaths(host.getCurrentDirectory(), "__inferred type names__.ts"); var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename); @@ -57884,7 +58274,8 @@ var ts; getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); }, getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); }, getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; }, - getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; } + getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; }, + dropDiagnosticsProducingTypeChecker: dropDiagnosticsProducingTypeChecker }; verifyCompilerOptions(); ts.performance.mark("afterProgram"); @@ -57938,6 +58329,7 @@ var ts; (oldOptions.configFilePath !== options.configFilePath) || (oldOptions.baseUrl !== options.baseUrl) || (oldOptions.maxNodeModuleJsDepth !== options.maxNodeModuleJsDepth) || + !ts.arrayIsEqualTo(oldOptions.lib, options.lib) || !ts.arrayIsEqualTo(oldOptions.typeRoots, oldOptions.typeRoots) || !ts.arrayIsEqualTo(oldOptions.rootDirs, options.rootDirs) || !ts.equalOwnProperties(oldOptions.paths, options.paths)) { @@ -58054,16 +58446,19 @@ var ts; function getDiagnosticsProducingTypeChecker() { return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ true)); } + function dropDiagnosticsProducingTypeChecker() { + diagnosticsProducingTypeChecker = undefined; + } function getTypeChecker() { return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ false)); } - function emit(sourceFile, writeFileCallback, cancellationToken) { - return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken); }); + function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles) { + return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles); }); } function isEmitBlocked(emitFileName) { return hasEmitBlockingDiagnostics.contains(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName)); } - function emitWorker(program, sourceFile, writeFileCallback, cancellationToken) { + function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles) { var declarationDiagnostics = []; if (options.noEmit) { return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true }; @@ -58095,7 +58490,7 @@ var ts; // checked is to not pass the file to getEmitResolver. var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile); ts.performance.mark("beforeEmit"); - var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile); + var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, emitOnlyDtsFiles); ts.performance.mark("afterEmit"); ts.performance.measure("Emit", "beforeEmit", "afterEmit"); return emitResult; @@ -58659,7 +59054,6 @@ var ts; for (var i = 0; i < moduleNames.length; i++) { var resolution = resolutions[i]; ts.setResolvedModule(file, moduleNames[i], resolution); - var resolvedPath = resolution ? ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName) : undefined; // add file to program only if: // - resolution was successful // - noResolve is falsy @@ -58676,7 +59070,7 @@ var ts; modulesWithElidedImports[file.path] = true; } else if (shouldAddFile) { - findSourceFile(resolution.resolvedFileName, resolvedPath, + findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), /*isDefaultLib*/ false, /*isReference*/ false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); } if (isFromNodeModulesSearch) { @@ -58692,8 +59086,8 @@ var ts; } function computeCommonSourceDirectory(sourceFiles) { var fileNames = []; - for (var _i = 0, sourceFiles_5 = sourceFiles; _i < sourceFiles_5.length; _i++) { - var file = sourceFiles_5[_i]; + for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { + var file = sourceFiles_6[_i]; if (!file.isDeclarationFile) { fileNames.push(file.fileName); } @@ -58704,8 +59098,8 @@ var ts; var allFilesBelongToPath = true; if (sourceFiles) { var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); - for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { - var sourceFile = sourceFiles_6[_i]; + for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { + var sourceFile = sourceFiles_7[_i]; if (!ts.isDeclarationFile(sourceFile)) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { @@ -58748,7 +59142,7 @@ var ts; if (!ts.hasProperty(options.paths, key)) { continue; } - if (!hasZeroOrOneAsteriskCharacter(key)) { + if (!ts.hasZeroOrOneAsteriskCharacter(key)) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Pattern_0_can_have_at_most_one_Asterisk_character, key)); } if (ts.isArray(options.paths[key])) { @@ -58759,7 +59153,7 @@ var ts; var subst = _a[_i]; var typeOfSubst = typeof subst; if (typeOfSubst === "string") { - if (!hasZeroOrOneAsteriskCharacter(subst)) { + if (!ts.hasZeroOrOneAsteriskCharacter(subst)) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character, subst, key)); } } @@ -58799,6 +59193,9 @@ var ts; if (options.lib && options.noLib) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "lib", "noLib")); } + if (options.noImplicitUseStrict && options.alwaysStrict) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noImplicitUseStrict", "alwaysStrict")); + } var languageVersion = options.target || 0 /* ES3 */; var outFile = options.outFile || options.out; var firstNonAmbientExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) && !ts.isDeclarationFile(f) ? f : undefined; }); @@ -58891,12 +59288,15 @@ var ts; /// var ts; (function (ts) { + /* @internal */ + ts.compileOnSaveCommandLineOption = { name: "compileOnSave", type: "boolean" }; /* @internal */ ts.optionDeclarations = [ { name: "charset", type: "string" }, + ts.compileOnSaveCommandLineOption, { name: "declaration", shortName: "d", @@ -59327,6 +59727,11 @@ var ts; name: "importHelpers", type: "boolean", description: ts.Diagnostics.Import_emit_helpers_from_tslib + }, + { + name: "alwaysStrict", + type: "boolean", + description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file } ]; /* @internal */ @@ -59547,10 +59952,11 @@ var ts; * @param fileName The path to the config file * @param jsonText The text of the config file */ - function parseConfigFileTextToJson(fileName, jsonText) { + function parseConfigFileTextToJson(fileName, jsonText, stripComments) { + if (stripComments === void 0) { stripComments = true; } try { - var jsonTextWithoutComments = removeComments(jsonText); - return { config: /\S/.test(jsonTextWithoutComments) ? JSON.parse(jsonTextWithoutComments) : {} }; + var jsonTextToParse = stripComments ? removeComments(jsonText) : jsonText; + return { config: /\S/.test(jsonTextToParse) ? JSON.parse(jsonTextToParse) : {} }; } catch (e) { return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) }; @@ -59712,13 +60118,15 @@ var ts; options = ts.extend(existingOptions, options); options.configFilePath = configFileName; var _c = getFileNames(errors), fileNames = _c.fileNames, wildcardDirectories = _c.wildcardDirectories; + var compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors); return { options: options, fileNames: fileNames, typingOptions: typingOptions, raw: json, errors: errors, - wildcardDirectories: wildcardDirectories + wildcardDirectories: wildcardDirectories, + compileOnSave: compileOnSave }; function tryExtendsName(extendedConfig) { // If the path isn't a rooted or relative path, don't try to resolve it (we reserve the right to special case module-id like paths in the future) @@ -59799,6 +60207,17 @@ var ts; var _b; } ts.parseJsonConfigFileContent = parseJsonConfigFileContent; + function convertCompileOnSaveOptionFromJson(jsonOption, basePath, errors) { + if (!ts.hasProperty(jsonOption, ts.compileOnSaveCommandLineOption.name)) { + return false; + } + var result = convertJsonOption(ts.compileOnSaveCommandLineOption, jsonOption["compileOnSave"], basePath, errors); + if (typeof result === "boolean" && result) { + return result; + } + return false; + } + ts.convertCompileOnSaveOptionFromJson = convertCompileOnSaveOptionFromJson; function convertCompilerOptionsFromJson(jsonOptions, basePath, configFileName) { var errors = []; var options = convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName); @@ -59812,7 +60231,9 @@ var ts; } ts.convertTypingOptionsFromJson = convertTypingOptionsFromJson; function convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { - var options = ts.getBaseFileName(configFileName) === "jsconfig.json" ? { allowJs: true, maxNodeModuleJsDepth: 2 } : {}; + var options = ts.getBaseFileName(configFileName) === "jsconfig.json" + ? { allowJs: true, maxNodeModuleJsDepth: 2, allowSyntheticDefaultImports: true, skipLibCheck: true } + : {}; convertOptionsFromJson(ts.optionDeclarations, jsonOptions, basePath, options, ts.Diagnostics.Unknown_compiler_option_0, errors); return options; } @@ -60742,7 +61163,7 @@ var ts; return true; case 69 /* Identifier */: // 'this' as a parameter - return node.originalKeywordKind === 97 /* ThisKeyword */ && node.parent.kind === 142 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 142 /* Parameter */; default: return false; } @@ -61420,7 +61841,6 @@ var ts; })(ts || (ts = {})); // Display-part writer helpers /* @internal */ -var ts; (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 142 /* Parameter */; @@ -61657,7 +62077,7 @@ var ts; return ts.ensureScriptKind(fileName, scriptKind); } ts.getScriptKind = getScriptKind; - function parseAndReEmitConfigJSONFile(content) { + function sanitizeConfigFile(configFileName, content) { var options = { fileName: "config.js", compilerOptions: { @@ -61671,14 +62091,17 @@ var ts; // also, the emitted result will have "(" in the beginning and ");" in the end. We need to strip these // as well var trimmedOutput = outputText.trim(); - var configJsonObject = JSON.parse(trimmedOutput.substring(1, trimmedOutput.length - 2)); for (var _i = 0, diagnostics_2 = diagnostics; _i < diagnostics_2.length; _i++) { var diagnostic = diagnostics_2[_i]; diagnostic.start = diagnostic.start - 1; } - return { configJsonObject: configJsonObject, diagnostics: diagnostics }; + var _b = ts.parseConfigFileTextToJson(configFileName, trimmedOutput.substring(1, trimmedOutput.length - 2), /*stripComments*/ false), config = _b.config, error = _b.error; + return { + configJsonObject: config || {}, + diagnostics: error ? ts.concatenate(diagnostics, [error]) : diagnostics + }; } - ts.parseAndReEmitConfigJSONFile = parseAndReEmitConfigJSONFile; + ts.sanitizeConfigFile = sanitizeConfigFile; })(ts || (ts = {})); var ts; (function (ts) { @@ -62538,8 +62961,7 @@ var ts; return; case 142 /* Parameter */: if (token.parent.name === token) { - var isThis_1 = token.kind === 69 /* Identifier */ && token.originalKeywordKind === 97 /* ThisKeyword */; - return isThis_1 ? 3 /* keyword */ : 17 /* parameterName */; + return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; } return; } @@ -62583,14 +63005,14 @@ var ts; if (!completionData) { return undefined; } - var symbols = completionData.symbols, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isJsDocTagName = completionData.isJsDocTagName; + var symbols = completionData.symbols, isGlobalCompletion = completionData.isGlobalCompletion, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isJsDocTagName = completionData.isJsDocTagName; 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: ts.JsDoc.getAllJsDocCompletionEntries() }; + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: ts.JsDoc.getAllJsDocCompletionEntries() }; } var entries = []; if (ts.isSourceFileJavaScript(sourceFile)) { - var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ false); + var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true); ts.addRange(entries, getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames)); } else { @@ -62619,7 +63041,7 @@ var ts; if (!isMemberCompletion && !isJsDocTagName) { ts.addRange(entries, keywordCompletions); } - return { isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation || ts.isSourceFileJavaScript(sourceFile), entries: entries }; + return { isGlobalCompletion: isGlobalCompletion, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames) { var entries = []; var nameTable = ts.getNameTable(sourceFile); @@ -62690,7 +63112,9 @@ var ts; if (!node || node.kind !== 9 /* StringLiteral */) { return undefined; } - if (node.parent.kind === 253 /* PropertyAssignment */ && node.parent.parent.kind === 171 /* ObjectLiteralExpression */) { + if (node.parent.kind === 253 /* PropertyAssignment */ && + node.parent.parent.kind === 171 /* ObjectLiteralExpression */ && + node.parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { // 'jspm:dev': string @@ -62740,7 +63164,7 @@ var ts; if (type) { getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, element, /*performCharacterChecks*/ false); if (entries.length) { - return { isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; + return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; } } } @@ -62756,7 +63180,7 @@ var ts; } } if (entries.length) { - return { isMemberCompletion: false, isNewIdentifierLocation: true, entries: entries }; + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: true, entries: entries }; } return undefined; } @@ -62766,7 +63190,7 @@ var ts; if (type) { getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, node, /*performCharacterChecks*/ false); if (entries.length) { - return { isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; + return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; } } return undefined; @@ -62777,7 +63201,7 @@ var ts; var entries_2 = []; addStringLiteralCompletionsFromType(type, entries_2); if (entries_2.length) { - return { isMemberCompletion: false, isNewIdentifierLocation: false, entries: entries_2 }; + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: entries_2 }; } } return undefined; @@ -62819,6 +63243,7 @@ var ts; entries = getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, span); } return { + isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: true, entries: entries @@ -62854,15 +63279,24 @@ var ts; } return result; } + /** + * Given a path ending at a directory, gets the completions for the path, and filters for those entries containing the basename. + */ function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, extensions, includeExtensions, span, exclude, result) { if (result === void 0) { result = []; } + if (fragment === undefined) { + fragment = ""; + } + fragment = ts.normalizeSlashes(fragment); + /** + * Remove the basename from the path. Note that we don't use the basename to filter completions; + * the client is responsible for refining completions. + */ fragment = ts.getDirectoryPath(fragment); - if (!fragment) { - fragment = "./"; - } - else { - fragment = ts.ensureTrailingDirectorySeparator(fragment); + if (fragment === "") { + fragment = "." + ts.directorySeparator; } + fragment = ts.ensureTrailingDirectorySeparator(fragment); var absolutePath = normalizeAndPreserveTrailingSlash(ts.isRootedDiskPath(fragment) ? fragment : ts.combinePaths(scriptPath, fragment)); var baseDirectory = ts.getDirectoryPath(absolutePath); var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); @@ -62870,6 +63304,12 @@ var ts; // Enumerate the available files if possible var files = tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]); if (files) { + /** + * Multiple file entries might map to the same truncated name once we remove extensions + * (happens iff includeExtensions === false)so we use a set-like data structure. Eg: + * + * both foo.ts and foo.tsx become foo + */ var foundFiles = ts.createMap(); for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { var filePath = files_3[_i]; @@ -63039,6 +63479,19 @@ var ts; if (!range) { return undefined; } + var completionInfo = { + /** + * We don't want the editor to offer any other completions, such as snippets, inside a comment. + */ + isGlobalCompletion: false, + isMemberCompletion: false, + /** + * The user may type in a path that doesn't yet exist, creating a "new identifier" + * with respect to the collection of identifiers the server is aware of. + */ + isNewIdentifierLocation: true, + entries: [] + }; var text = sourceFile.text.substr(range.pos, position - range.pos); var match = tripleSlashDirectiveFragmentRegex.exec(text); if (match) { @@ -63046,24 +63499,18 @@ var ts; var kind = match[2]; var toComplete = match[3]; var scriptPath = ts.getDirectoryPath(sourceFile.path); - var entries_3; if (kind === "path") { // Give completions for a relative path var span_10 = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length); - entries_3 = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, ts.getSupportedExtensions(compilerOptions), /*includeExtensions*/ true, span_10, sourceFile.path); + completionInfo.entries = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, ts.getSupportedExtensions(compilerOptions), /*includeExtensions*/ true, span_10, sourceFile.path); } else { // Give completions based on the typings available var span_11 = { start: range.pos + prefix.length, length: match[0].length - prefix.length }; - entries_3 = getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span_11); + completionInfo.entries = getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span_11); } - return { - isMemberCompletion: false, - isNewIdentifierLocation: true, - entries: entries_3 - }; } - return undefined; + return completionInfo; } function getCompletionEntriesFromTypings(host, options, scriptPath, span, result) { if (result === void 0) { result = []; } @@ -63285,7 +63732,7 @@ var ts; } } if (isJsDocTagName) { - return { symbols: undefined, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, isJsDocTagName: isJsDocTagName }; + return { symbols: undefined, isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, isJsDocTagName: isJsDocTagName }; } if (!insideJsDocTagExpression) { // Proceed if the current position is in jsDoc tag expression; otherwise it is a normal @@ -63349,6 +63796,7 @@ var ts; } } var semanticStart = ts.timestamp(); + var isGlobalCompletion = false; var isMemberCompletion; var isNewIdentifierLocation; var symbols = []; @@ -63382,11 +63830,13 @@ var ts; if (!tryGetGlobalSymbols()) { return undefined; } + isGlobalCompletion = true; } log("getCompletionData: Semantic work: " + (ts.timestamp() - semanticStart)); - return { symbols: symbols, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName: isJsDocTagName }; + return { symbols: symbols, isGlobalCompletion: isGlobalCompletion, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName: isJsDocTagName }; function getTypeScriptMemberSymbols() { // Right of dot member completion list + isGlobalCompletion = false; isMemberCompletion = true; isNewIdentifierLocation = false; if (node.kind === 69 /* Identifier */ || node.kind === 139 /* QualifiedName */ || node.kind === 172 /* PropertyAccessExpression */) { @@ -63448,6 +63898,7 @@ var ts; if ((jsxContainer.kind === 242 /* JsxSelfClosingElement */) || (jsxContainer.kind === 243 /* JsxOpeningElement */)) { // Cursor is inside a JSX self-closing element or opening element attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); + isGlobalCompletion = false; if (attrsType) { symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); isMemberCompletion = true; @@ -64026,9 +64477,15 @@ var ts; * Matches a triple slash reference directive with an incomplete string literal for its path. Used * to determine if the caret is currently within the string literal and capture the literal fragment * for completions. - * For example, this matches /// +/// +/// +/// /* @internal */ var ts; (function (ts) { @@ -66442,6 +66901,7 @@ var ts; // A map of loose file names to library names // that we are confident require typings var safeList; + var EmptySafeList = ts.createMap(); /** * @param host is the object providing I/O related operations. * @param fileNames are the file names that belong to the same project @@ -66458,10 +66918,13 @@ var ts; return { cachedTypingPaths: [], newTypingNames: [], filesToWatch: [] }; } // Only infer typings for .js and .jsx files - fileNames = ts.filter(ts.map(fileNames, ts.normalizePath), function (f) { return ts.scriptKindIs(f, /*LanguageServiceHost*/ undefined, 1 /* JS */, 2 /* JSX */); }); + fileNames = ts.filter(ts.map(fileNames, ts.normalizePath), function (f) { + var kind = ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)); + return kind === 1 /* JS */ || kind === 2 /* JSX */; + }); if (!safeList) { var result = ts.readConfigFile(safeListPath, function (path) { return host.readFile(path); }); - safeList = ts.createMap(result.config); + safeList = result.config ? ts.createMap(result.config) : EmptySafeList; } var filesToWatch = []; // Directories to search for package.json, bower.json and other typing information @@ -66552,13 +67015,10 @@ var ts; var jsFileNames = ts.filter(fileNames, ts.hasJavaScriptFileExtension); var inferredTypingNames = ts.map(jsFileNames, function (f) { return ts.removeFileExtension(ts.getBaseFileName(f.toLowerCase())); }); var cleanedTypingNames = ts.map(inferredTypingNames, function (f) { return f.replace(/((?:\.|-)min(?=\.|$))|((?:-|\.)\d+)/g, ""); }); - if (safeList === undefined) { - mergeTypings(cleanedTypingNames); - } - else { + if (safeList !== EmptySafeList) { mergeTypings(ts.filter(cleanedTypingNames, function (f) { return f in safeList; })); } - var hasJsxFile = ts.forEach(fileNames, function (f) { return ts.scriptKindIs(f, /*LanguageServiceHost*/ undefined, 2 /* JSX */); }); + var hasJsxFile = ts.forEach(fileNames, function (f) { return ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)) === 2 /* JSX */; }); if (hasJsxFile) { mergeTypings(["react"]); } @@ -66573,7 +67033,7 @@ var ts; return; } var typingNames = []; - var fileNames = host.readDirectory(nodeModulesPath, ["*.json"], /*excludes*/ undefined, /*includes*/ undefined, /*depth*/ 2); + var fileNames = host.readDirectory(nodeModulesPath, [".json"], /*excludes*/ undefined, /*includes*/ undefined, /*depth*/ 2); for (var _i = 0, fileNames_2 = fileNames; _i < fileNames_2.length; _i++) { var fileName = fileNames_2[_i]; var normalizedFileName = ts.normalizePath(fileName); @@ -66616,7 +67076,7 @@ var ts; (function (ts) { var NavigateTo; (function (NavigateTo) { - function getNavigateToItems(sourceFiles, checker, cancellationToken, searchValue, maxResultCount) { + function getNavigateToItems(sourceFiles, checker, cancellationToken, searchValue, maxResultCount, excludeDtsFiles) { var patternMatcher = ts.createPatternMatcher(searchValue); var rawItems = []; // This means "compare in a case insensitive manner." @@ -66624,6 +67084,9 @@ var ts; // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] ts.forEach(sourceFiles, function (sourceFile) { cancellationToken.throwIfCancellationRequested(); + if (excludeDtsFiles && ts.fileExtensionIs(sourceFile.fileName, ".d.ts")) { + return; + } var nameToDeclarations = sourceFile.getNamedDeclarations(); for (var name_49 in nameToDeclarations) { var declarations = nameToDeclarations[name_49]; @@ -66803,6 +67266,13 @@ var ts; return result; } NavigationBar.getNavigationBarItems = getNavigationBarItems; + function getNavigationTree(sourceFile) { + curSourceFile = sourceFile; + var result = convertToTree(rootNavigationBarNode(sourceFile)); + curSourceFile = undefined; + return result; + } + NavigationBar.getNavigationTree = getNavigationTree; // Keep sourceFile handy so we don't have to search for it every time we need to call `getText`. var curSourceFile; function nodeText(node) { @@ -67077,7 +67547,7 @@ var ts; } } // More efficient to create a collator once and use its `compare` than to call `a.localeCompare(b)` many times. - var collator = typeof Intl === "undefined" ? undefined : new Intl.Collator(); + var collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; // Intl is missing in Safari, and node 0.10 treats "a" as greater than "B". var localeCompareIsCorrect = collator && collator.compare("a", "B") < 0; var localeCompareFix = localeCompareIsCorrect ? collator.compare : function (a, b) { @@ -67242,6 +67712,15 @@ var ts; } // NavigationBarItem requires an array, but will not mutate it, so just give it this for performance. var emptyChildItemArray = []; + function convertToTree(n) { + return { + text: getItemName(n.node), + kind: ts.getNodeKind(n.node), + kindModifiers: ts.getNodeModifiers(n.node), + spans: getSpans(n), + childItems: ts.map(n.children, convertToTree) + }; + } function convertToTopLevelItem(n) { return { text: getItemName(n.node), @@ -67265,16 +67744,16 @@ var ts; grayed: false }; } - function getSpans(n) { - var spans = [getNodeSpan(n.node)]; - if (n.additionalNodes) { - for (var _i = 0, _a = n.additionalNodes; _i < _a.length; _i++) { - var node = _a[_i]; - spans.push(getNodeSpan(node)); - } + } + function getSpans(n) { + var spans = [getNodeSpan(n.node)]; + if (n.additionalNodes) { + for (var _i = 0, _a = n.additionalNodes; _i < _a.length; _i++) { + var node = _a[_i]; + spans.push(getNodeSpan(node)); } - return spans; } + return spans; } function getModuleName(moduleDeclaration) { // We want to maintain quotation marks. @@ -71005,25 +71484,25 @@ var ts; }; RulesProvider.prototype.createActiveRules = function (options) { var rules = this.globalRules.HighPriorityCommonRules.slice(0); - if (options.InsertSpaceAfterCommaDelimiter) { + if (options.insertSpaceAfterCommaDelimiter) { rules.push(this.globalRules.SpaceAfterComma); } else { rules.push(this.globalRules.NoSpaceAfterComma); } - if (options.InsertSpaceAfterFunctionKeywordForAnonymousFunctions) { + if (options.insertSpaceAfterFunctionKeywordForAnonymousFunctions) { rules.push(this.globalRules.SpaceAfterAnonymousFunctionKeyword); } else { rules.push(this.globalRules.NoSpaceAfterAnonymousFunctionKeyword); } - if (options.InsertSpaceAfterKeywordsInControlFlowStatements) { + if (options.insertSpaceAfterKeywordsInControlFlowStatements) { rules.push(this.globalRules.SpaceAfterKeywordInControl); } else { rules.push(this.globalRules.NoSpaceAfterKeywordInControl); } - if (options.InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis) { + if (options.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis) { rules.push(this.globalRules.SpaceAfterOpenParen); rules.push(this.globalRules.SpaceBeforeCloseParen); rules.push(this.globalRules.NoSpaceBetweenParens); @@ -71033,7 +71512,7 @@ var ts; rules.push(this.globalRules.NoSpaceBeforeCloseParen); rules.push(this.globalRules.NoSpaceBetweenParens); } - if (options.InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets) { + if (options.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets) { rules.push(this.globalRules.SpaceAfterOpenBracket); rules.push(this.globalRules.SpaceBeforeCloseBracket); rules.push(this.globalRules.NoSpaceBetweenBrackets); @@ -71045,7 +71524,7 @@ var ts; } // The default value of InsertSpaceAfterOpeningAndBeforeClosingNonemptyBraces is true // so if the option is undefined, we should treat it as true as well - if (options.InsertSpaceAfterOpeningAndBeforeClosingNonemptyBraces !== false) { + if (options.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces !== false) { rules.push(this.globalRules.SpaceAfterOpenBrace); rules.push(this.globalRules.SpaceBeforeCloseBrace); rules.push(this.globalRules.NoSpaceBetweenEmptyBraceBrackets); @@ -71055,7 +71534,7 @@ var ts; rules.push(this.globalRules.NoSpaceBeforeCloseBrace); rules.push(this.globalRules.NoSpaceBetweenEmptyBraceBrackets); } - if (options.InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces) { + if (options.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces) { rules.push(this.globalRules.SpaceAfterTemplateHeadAndMiddle); rules.push(this.globalRules.SpaceBeforeTemplateMiddleAndTail); } @@ -71063,7 +71542,7 @@ var ts; rules.push(this.globalRules.NoSpaceAfterTemplateHeadAndMiddle); rules.push(this.globalRules.NoSpaceBeforeTemplateMiddleAndTail); } - if (options.InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces) { + if (options.insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces) { rules.push(this.globalRules.SpaceAfterOpenBraceInJsxExpression); rules.push(this.globalRules.SpaceBeforeCloseBraceInJsxExpression); } @@ -71071,13 +71550,13 @@ var ts; rules.push(this.globalRules.NoSpaceAfterOpenBraceInJsxExpression); rules.push(this.globalRules.NoSpaceBeforeCloseBraceInJsxExpression); } - if (options.InsertSpaceAfterSemicolonInForStatements) { + if (options.insertSpaceAfterSemicolonInForStatements) { rules.push(this.globalRules.SpaceAfterSemicolonInFor); } else { rules.push(this.globalRules.NoSpaceAfterSemicolonInFor); } - if (options.InsertSpaceBeforeAndAfterBinaryOperators) { + if (options.insertSpaceBeforeAndAfterBinaryOperators) { rules.push(this.globalRules.SpaceBeforeBinaryOperator); rules.push(this.globalRules.SpaceAfterBinaryOperator); } @@ -71085,14 +71564,14 @@ var ts; rules.push(this.globalRules.NoSpaceBeforeBinaryOperator); rules.push(this.globalRules.NoSpaceAfterBinaryOperator); } - if (options.PlaceOpenBraceOnNewLineForControlBlocks) { + if (options.placeOpenBraceOnNewLineForControlBlocks) { rules.push(this.globalRules.NewLineBeforeOpenBraceInControl); } - if (options.PlaceOpenBraceOnNewLineForFunctions) { + if (options.placeOpenBraceOnNewLineForFunctions) { rules.push(this.globalRules.NewLineBeforeOpenBraceInFunction); rules.push(this.globalRules.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock); } - if (options.InsertSpaceAfterTypeAssertion) { + if (options.insertSpaceAfterTypeAssertion) { rules.push(this.globalRules.SpaceAfterTypeAssertion); } else { @@ -71222,7 +71701,7 @@ var ts; return ts.rangeContainsRange(parent.members, node); case 225 /* ModuleDeclaration */: var body = parent.body; - return body && body.kind === 199 /* Block */ && ts.rangeContainsRange(body.statements, node); + return body && body.kind === 226 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); case 256 /* SourceFile */: case 199 /* Block */: case 226 /* ModuleBlock */: @@ -71332,7 +71811,7 @@ var ts; break; } if (formatting.SmartIndenter.shouldIndentChildNode(n, child)) { - return options.IndentSize; + return options.indentSize; } previousLine = line; child = n; @@ -71404,7 +71883,7 @@ var ts; } function computeIndentation(node, startLine, inheritedIndentation, parent, parentDynamicIndentation, effectiveParentStartLine) { var indentation = inheritedIndentation; - var delta = formatting.SmartIndenter.shouldIndentChildNode(node) ? options.IndentSize : 0; + var delta = formatting.SmartIndenter.shouldIndentChildNode(node) ? options.indentSize : 0; if (effectiveParentStartLine === startLine) { // if node is located on the same line with the parent // - inherit indentation from the parent @@ -71412,7 +71891,7 @@ var ts; indentation = startLine === lastIndentedLine ? indentationOnLastIndentedLine : parentDynamicIndentation.getIndentation(); - delta = Math.min(options.IndentSize, parentDynamicIndentation.getDelta(node) + delta); + delta = Math.min(options.indentSize, parentDynamicIndentation.getDelta(node) + delta); } else if (indentation === -1 /* Unknown */) { if (formatting.SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement(parent, node, startLine, sourceFile)) { @@ -71493,13 +71972,13 @@ var ts; recomputeIndentation: function (lineAdded) { if (node.parent && formatting.SmartIndenter.shouldIndentChildNode(node.parent, node)) { if (lineAdded) { - indentation += options.IndentSize; + indentation += options.indentSize; } else { - indentation -= options.IndentSize; + indentation -= options.indentSize; } if (formatting.SmartIndenter.shouldIndentChildNode(node)) { - delta = options.IndentSize; + delta = options.indentSize; } else { delta = 0; @@ -71919,7 +72398,7 @@ var ts; // edit should not be applied only if we have one line feed between elements var lineDelta = currentStartLine - previousStartLine; if (lineDelta !== 1) { - recordReplace(previousRange.end, currentRange.pos - previousRange.end, options.NewLineCharacter); + recordReplace(previousRange.end, currentRange.pos - previousRange.end, options.newLineCharacter); } break; case 2 /* Space */: @@ -71980,14 +72459,14 @@ var ts; var internedSpacesIndentation; function getIndentationString(indentation, options) { // reset interned strings if FormatCodeOptions were changed - var resetInternedStrings = !internedSizes || (internedSizes.tabSize !== options.TabSize || internedSizes.indentSize !== options.IndentSize); + var resetInternedStrings = !internedSizes || (internedSizes.tabSize !== options.tabSize || internedSizes.indentSize !== options.indentSize); if (resetInternedStrings) { - internedSizes = { tabSize: options.TabSize, indentSize: options.IndentSize }; + internedSizes = { tabSize: options.tabSize, indentSize: options.indentSize }; internedTabsIndentation = internedSpacesIndentation = undefined; } - if (!options.ConvertTabsToSpaces) { - var tabs = Math.floor(indentation / options.TabSize); - var spaces = indentation - tabs * options.TabSize; + if (!options.convertTabsToSpaces) { + var tabs = Math.floor(indentation / options.tabSize); + var spaces = indentation - tabs * options.tabSize; var tabString = void 0; if (!internedTabsIndentation) { internedTabsIndentation = []; @@ -72002,13 +72481,13 @@ var ts; } else { var spacesString = void 0; - var quotient = Math.floor(indentation / options.IndentSize); - var remainder = indentation % options.IndentSize; + var quotient = Math.floor(indentation / options.indentSize); + var remainder = indentation % options.indentSize; if (!internedSpacesIndentation) { internedSpacesIndentation = []; } if (internedSpacesIndentation[quotient] === undefined) { - spacesString = repeat(" ", options.IndentSize * quotient); + spacesString = repeat(" ", options.indentSize * quotient); internedSpacesIndentation[quotient] = spacesString; } else { @@ -72045,7 +72524,7 @@ var ts; } // no indentation when the indent style is set to none, // so we can return fast - if (options.IndentStyle === ts.IndentStyle.None) { + if (options.indentStyle === ts.IndentStyle.None) { return 0; } var precedingToken = ts.findPrecedingToken(position, sourceFile); @@ -72061,7 +72540,7 @@ var ts; // 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) { + 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; @@ -72095,7 +72574,7 @@ var ts; indentationDelta = 0; } else { - indentationDelta = lineAtPosition !== currentStart.line ? options.IndentSize : 0; + indentationDelta = lineAtPosition !== currentStart.line ? options.indentSize : 0; } break; } @@ -72106,7 +72585,7 @@ var ts; } actualIndentation = getLineIndentationWhenExpressionIsInMultiLine(current, sourceFile, options); if (actualIndentation !== -1 /* Unknown */) { - return actualIndentation + options.IndentSize; + return actualIndentation + options.indentSize; } previous = current; current = current.parent; @@ -72118,15 +72597,15 @@ var ts; return getIndentationForNodeWorker(current, currentStart, /*ignoreActualIndentationRange*/ undefined, indentationDelta, sourceFile, options); } SmartIndenter.getIndentation = getIndentation; - function getBaseIndentation(options) { - return options.BaseIndentSize || 0; - } - SmartIndenter.getBaseIndentation = getBaseIndentation; function getIndentationForNode(n, ignoreActualIndentationRange, sourceFile, options) { var start = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); return getIndentationForNodeWorker(n, start, ignoreActualIndentationRange, /*indentationDelta*/ 0, sourceFile, options); } SmartIndenter.getIndentationForNode = getIndentationForNode; + function getBaseIndentation(options) { + return options.baseIndentSize || 0; + } + SmartIndenter.getBaseIndentation = getBaseIndentation; function getIndentationForNodeWorker(current, currentStart, ignoreActualIndentationRange, indentationDelta, sourceFile, options) { var parent = current.parent; var parentStart; @@ -72161,7 +72640,7 @@ var ts; } // increase indentation if parent node wants its content to be indented and parent and child nodes don't start on the same line if (shouldIndentChildNode(parent, current) && !parentAndChildShareLine) { - indentationDelta += options.IndentSize; + indentationDelta += options.indentSize; } current = parent; currentStart = parentStart; @@ -72371,7 +72850,7 @@ var ts; break; } if (ch === 9 /* tab */) { - column += options.TabSize + (column % options.TabSize); + column += options.tabSize + (column % options.tabSize); } else { column++; @@ -72473,6 +72952,117 @@ var ts; })(SmartIndenter = formatting.SmartIndenter || (formatting.SmartIndenter = {})); })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var codefix; + (function (codefix) { + var codeFixes = ts.createMap(); + function registerCodeFix(action) { + ts.forEach(action.errorCodes, function (error) { + var fixes = codeFixes[error]; + if (!fixes) { + fixes = []; + codeFixes[error] = fixes; + } + fixes.push(action); + }); + } + codefix.registerCodeFix = registerCodeFix; + function getSupportedErrorCodes() { + return Object.keys(codeFixes); + } + codefix.getSupportedErrorCodes = getSupportedErrorCodes; + function getFixes(context) { + var fixes = codeFixes[context.errorCode]; + var allActions = []; + ts.forEach(fixes, function (f) { + var actions = f.getCodeActions(context); + if (actions && actions.length > 0) { + allActions = allActions.concat(actions); + } + }); + return allActions; + } + codefix.getFixes = getFixes; + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var codefix; + (function (codefix) { + function getOpenBraceEnd(constructor, sourceFile) { + // First token is the open curly, this is where we want to put the 'super' call. + return constructor.body.getFirstToken(sourceFile).getEnd(); + } + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call.code], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var token = ts.getTokenAtPosition(sourceFile, context.span.start); + if (token.kind !== 121 /* ConstructorKeyword */) { + return undefined; + } + var newPosition = getOpenBraceEnd(token.parent, sourceFile); + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_missing_super_call), + changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "super();", span: { start: newPosition, length: 0 } }] }] + }]; + } + }); + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class.code], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var token = ts.getTokenAtPosition(sourceFile, context.span.start); + if (token.kind !== 97 /* ThisKeyword */) { + return undefined; + } + var constructor = ts.getContainingFunction(token); + var superCall = findSuperCall(constructor.body); + if (!superCall) { + return undefined; + } + // figure out if the this access is actuall inside the supercall + // i.e. super(this.a), since in that case we won't suggest a fix + if (superCall.expression && superCall.expression.kind == 174 /* CallExpression */) { + var arguments_1 = superCall.expression.arguments; + for (var i = 0; i < arguments_1.length; i++) { + if (arguments_1[i].expression === token) { + return undefined; + } + } + } + var newPosition = getOpenBraceEnd(constructor, sourceFile); + var changes = [{ + fileName: sourceFile.fileName, textChanges: [{ + newText: superCall.getText(sourceFile), + span: { start: newPosition, length: 0 } + }, + { + newText: "", + span: { start: superCall.getStart(sourceFile), length: superCall.getWidth(sourceFile) } + }] + }]; + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Make_super_call_the_first_statement_in_the_constructor), + changes: changes + }]; + function findSuperCall(n) { + if (n.kind === 202 /* ExpressionStatement */ && ts.isSuperCall(n.expression)) { + return n; + } + if (ts.isFunctionLike(n)) { + return undefined; + } + return ts.forEachChild(n, findSuperCall); + } + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/// /// /// /// @@ -72498,13 +73088,15 @@ var ts; /// /// /// +/// +/// var ts; (function (ts) { /** The version of the language service API */ ts.servicesVersion = "0.5"; function createNode(kind, pos, end, parent) { var node = kind >= 139 /* FirstNode */ ? new NodeObject(kind, pos, end) : - kind === 69 /* Identifier */ ? new IdentifierObject(kind, pos, end) : + kind === 69 /* Identifier */ ? new IdentifierObject(69 /* Identifier */, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; return node; @@ -72732,15 +73324,16 @@ var ts; var TokenObject = (function (_super) { __extends(TokenObject, _super); function TokenObject(kind, pos, end) { - _super.call(this, pos, end); - this.kind = kind; + var _this = _super.call(this, pos, end) || this; + _this.kind = kind; + return _this; } return TokenObject; }(TokenOrIdentifierObject)); var IdentifierObject = (function (_super) { __extends(IdentifierObject, _super); function IdentifierObject(kind, pos, end) { - _super.call(this, pos, end); + return _super.call(this, pos, end) || this; } return IdentifierObject; }(TokenOrIdentifierObject)); @@ -72816,7 +73409,7 @@ var ts; var SourceFileObject = (function (_super) { __extends(SourceFileObject, _super); function SourceFileObject(kind, pos, end) { - _super.call(this, kind, pos, end); + return _super.call(this, kind, pos, end) || this; } SourceFileObject.prototype.update = function (newText, textChangeRange) { return ts.updateSourceFile(this, newText, textChangeRange); @@ -72985,6 +73578,30 @@ var ts; getSignatureConstructor: function () { return SignatureObject; } }; } + function toEditorSettings(optionsAsMap) { + var allPropertiesAreCamelCased = true; + for (var key in optionsAsMap) { + if (ts.hasProperty(optionsAsMap, key) && !isCamelCase(key)) { + allPropertiesAreCamelCased = false; + break; + } + } + if (allPropertiesAreCamelCased) { + return optionsAsMap; + } + var settings = {}; + for (var key in optionsAsMap) { + if (ts.hasProperty(optionsAsMap, key)) { + var newKey = isCamelCase(key) ? key : key.charAt(0).toLowerCase() + key.substr(1); + settings[newKey] = optionsAsMap[key]; + } + } + return settings; + } + ts.toEditorSettings = toEditorSettings; + function isCamelCase(s) { + return !s.length || s.charAt(0) === s.charAt(0).toLowerCase(); + } function displayPartsToString(displayParts) { if (displayParts) { return ts.map(displayParts, function (displayPart) { return displayPart.text; }).join(""); @@ -73000,9 +73617,13 @@ var ts; }; } ts.getDefaultCompilerOptions = getDefaultCompilerOptions; - // Cache host information about script should be refreshed + function getSupportedCodeFixes() { + return ts.codefix.getSupportedErrorCodes(); + } + ts.getSupportedCodeFixes = getSupportedCodeFixes; + // Cache host information about script Should be refreshed // at each language service public entry point, since we don't know when - // set of scripts handled by the host changes. + // the set of scripts handled by the host changes. var HostCache = (function () { function HostCache(host, getCanonicalFileName) { this.host = host; @@ -73185,7 +73806,8 @@ var ts; var ruleProvider; var program; var lastProjectVersion; - var useCaseSensitivefileNames = false; + var lastTypesRootVersion = 0; + var useCaseSensitivefileNames = host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(); var cancellationToken = new CancellationTokenObject(host.getCancellationToken && host.getCancellationToken()); var currentDirectory = host.getCurrentDirectory(); // Check if the localized messages json is set, otherwise query the host for it @@ -73224,6 +73846,12 @@ var ts; lastProjectVersion = hostProjectVersion; } } + var typeRootsVersion = host.getTypeRootsVersion ? host.getTypeRootsVersion() : 0; + if (lastTypesRootVersion !== typeRootsVersion) { + log("TypeRoots version has changed; provide new program"); + program = undefined; + lastTypesRootVersion = typeRootsVersion; + } // Get a fresh cache of the host information var hostCache = new HostCache(host, getCanonicalFileName); // If the program is already up-to-date, we can reuse it @@ -73553,12 +74181,12 @@ var ts; return ts.FindAllReferences.findReferencedSymbols(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position, findInStrings, findInComments); } /// NavigateTo - function getNavigateToItems(searchValue, maxResultCount, fileName) { + function getNavigateToItems(searchValue, maxResultCount, fileName, excludeDtsFiles) { synchronizeHostData(); var sourceFiles = fileName ? [getValidSourceFile(fileName)] : program.getSourceFiles(); - return ts.NavigateTo.getNavigateToItems(sourceFiles, program.getTypeChecker(), cancellationToken, searchValue, maxResultCount); + return ts.NavigateTo.getNavigateToItems(sourceFiles, program.getTypeChecker(), cancellationToken, searchValue, maxResultCount, excludeDtsFiles); } - function getEmitOutput(fileName) { + function getEmitOutput(fileName, emitOnlyDtsFiles) { synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); var outputFiles = []; @@ -73569,7 +74197,7 @@ var ts; text: data }); } - var emitOutput = program.emit(sourceFile, writeFile, cancellationToken); + var emitOutput = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles); return { outputFiles: outputFiles, emitSkipped: emitOutput.emitSkipped @@ -73647,14 +74275,28 @@ var ts; return ts.BreakpointResolver.spanInSourceFileAtLocation(sourceFile, position); } function getNavigationBarItems(fileName) { - var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - return ts.NavigationBar.getNavigationBarItems(sourceFile); + return ts.NavigationBar.getNavigationBarItems(syntaxTreeCache.getCurrentSourceFile(fileName)); + } + function getNavigationTree(fileName) { + return ts.NavigationBar.getNavigationTree(syntaxTreeCache.getCurrentSourceFile(fileName)); + } + function isTsOrTsxFile(fileName) { + var kind = ts.getScriptKind(fileName, host); + return kind === 3 /* TS */ || kind === 4 /* TSX */; } function getSemanticClassifications(fileName, span) { + if (!isTsOrTsxFile(fileName)) { + // do not run semantic classification on non-ts-or-tsx files + return []; + } synchronizeHostData(); return ts.getSemanticClassifications(program.getTypeChecker(), cancellationToken, getValidSourceFile(fileName), program.getClassifiableNames(), span); } function getEncodedSemanticClassifications(fileName, span) { + if (!isTsOrTsxFile(fileName)) { + // do not run semantic classification on non-ts-or-tsx files + return { spans: [], endOfLineState: 0 /* None */ }; + } synchronizeHostData(); return ts.getEncodedSemanticClassifications(program.getTypeChecker(), cancellationToken, getValidSourceFile(fileName), program.getClassifiableNames(), span); } @@ -73715,34 +74357,60 @@ var ts; } function getIndentationAtPosition(fileName, position, editorOptions) { var start = ts.timestamp(); + var settings = toEditorSettings(editorOptions); var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); log("getIndentationAtPosition: getCurrentSourceFile: " + (ts.timestamp() - start)); start = ts.timestamp(); - var result = ts.formatting.SmartIndenter.getIndentation(position, sourceFile, editorOptions); + var result = ts.formatting.SmartIndenter.getIndentation(position, sourceFile, settings); log("getIndentationAtPosition: computeIndentation : " + (ts.timestamp() - start)); return result; } function getFormattingEditsForRange(fileName, start, end, options) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - return ts.formatting.formatSelection(start, end, sourceFile, getRuleProvider(options), options); + var settings = toEditorSettings(options); + return ts.formatting.formatSelection(start, end, sourceFile, getRuleProvider(settings), settings); } function getFormattingEditsForDocument(fileName, options) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - return ts.formatting.formatDocument(sourceFile, getRuleProvider(options), options); + var settings = toEditorSettings(options); + return ts.formatting.formatDocument(sourceFile, getRuleProvider(settings), settings); } function getFormattingEditsAfterKeystroke(fileName, position, key, options) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + var settings = toEditorSettings(options); if (key === "}") { - return ts.formatting.formatOnClosingCurly(position, sourceFile, getRuleProvider(options), options); + return ts.formatting.formatOnClosingCurly(position, sourceFile, getRuleProvider(settings), settings); } else if (key === ";") { - return ts.formatting.formatOnSemicolon(position, sourceFile, getRuleProvider(options), options); + return ts.formatting.formatOnSemicolon(position, sourceFile, getRuleProvider(settings), settings); } else if (key === "\n") { - return ts.formatting.formatOnEnter(position, sourceFile, getRuleProvider(options), options); + return ts.formatting.formatOnEnter(position, sourceFile, getRuleProvider(settings), settings); } return []; } + function getCodeFixesAtPosition(fileName, start, end, errorCodes) { + synchronizeHostData(); + var sourceFile = getValidSourceFile(fileName); + var span = { start: start, length: end - start }; + var newLineChar = ts.getNewLineOrDefaultFromHost(host); + var allFixes = []; + ts.forEach(errorCodes, function (error) { + cancellationToken.throwIfCancellationRequested(); + var context = { + errorCode: error, + sourceFile: sourceFile, + span: span, + program: program, + newLineCharacter: newLineChar + }; + var fixes = ts.codefix.getFixes(context); + if (fixes) { + allFixes = allFixes.concat(fixes); + } + }); + return allFixes; + } function getDocCommentTemplateAtPosition(fileName, position) { return ts.JsDoc.getDocCommentTemplateAtPosition(ts.getNewLineOrDefaultFromHost(host), syntaxTreeCache.getCurrentSourceFile(fileName), position); } @@ -73926,6 +74594,7 @@ var ts; getRenameInfo: getRenameInfo, findRenameLocations: findRenameLocations, getNavigationBarItems: getNavigationBarItems, + getNavigationTree: getNavigationTree, getOutliningSpans: getOutliningSpans, getTodoComments: getTodoComments, getBraceMatchingAtPosition: getBraceMatchingAtPosition, @@ -73935,6 +74604,7 @@ var ts; getFormattingEditsAfterKeystroke: getFormattingEditsAfterKeystroke, getDocCommentTemplateAtPosition: getDocCommentTemplateAtPosition, isValidBraceCompletionAtPosition: isValidBraceCompletionAtPosition, + getCodeFixesAtPosition: getCodeFixesAtPosition, getEmitOutput: getEmitOutput, getNonBoundSourceFile: getNonBoundSourceFile, getSourceFile: getSourceFile, @@ -74624,7 +75294,7 @@ var ts; // /// /* @internal */ -var debugObjectHost = new Function("return this")(); +var debugObjectHost = (function () { return this; })(); // We need to use 'null' to interface with the managed side. /* tslint:disable:no-null-keyword */ /* tslint:disable:no-in-operator */ @@ -74712,6 +75382,12 @@ var ts; } return this.shimHost.getProjectVersion(); }; + LanguageServiceShimHostAdapter.prototype.getTypeRootsVersion = function () { + if (!this.shimHost.getTypeRootsVersion) { + return 0; + } + return this.shimHost.getTypeRootsVersion(); + }; LanguageServiceShimHostAdapter.prototype.useCaseSensitiveFileNames = function () { return this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false; }; @@ -74914,11 +75590,12 @@ var ts; var LanguageServiceShimObject = (function (_super) { __extends(LanguageServiceShimObject, _super); function LanguageServiceShimObject(factory, host, languageService) { - _super.call(this, factory); - this.host = host; - this.languageService = languageService; - this.logPerformance = false; - this.logger = this.host; + var _this = _super.call(this, factory) || this; + _this.host = host; + _this.languageService = languageService; + _this.logPerformance = false; + _this.logger = _this.host; + return _this; } LanguageServiceShimObject.prototype.forwardJSONCall = function (actionDescription, action) { return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); @@ -75156,6 +75833,10 @@ var ts; var _this = this; return this.forwardJSONCall("getNavigationBarItems('" + fileName + "')", function () { return _this.languageService.getNavigationBarItems(fileName); }); }; + LanguageServiceShimObject.prototype.getNavigationTree = function (fileName) { + var _this = this; + return this.forwardJSONCall("getNavigationTree('" + fileName + "')", function () { return _this.languageService.getNavigationTree(fileName); }); + }; LanguageServiceShimObject.prototype.getOutliningSpans = function (fileName) { var _this = this; return this.forwardJSONCall("getOutliningSpans('" + fileName + "')", function () { return _this.languageService.getOutliningSpans(fileName); }); @@ -75182,10 +75863,11 @@ var ts; var ClassifierShimObject = (function (_super) { __extends(ClassifierShimObject, _super); function ClassifierShimObject(factory, logger) { - _super.call(this, factory); - this.logger = logger; - this.logPerformance = false; - this.classifier = ts.createClassifier(); + var _this = _super.call(this, factory) || this; + _this.logger = logger; + _this.logPerformance = false; + _this.classifier = ts.createClassifier(); + return _this; } ClassifierShimObject.prototype.getEncodedLexicalClassifications = function (text, lexState, syntacticClassifierAbsent) { var _this = this; @@ -75208,10 +75890,11 @@ var ts; var CoreServicesShimObject = (function (_super) { __extends(CoreServicesShimObject, _super); function CoreServicesShimObject(factory, logger, host) { - _super.call(this, factory); - this.logger = logger; - this.host = host; - this.logPerformance = false; + var _this = _super.call(this, factory) || this; + _this.logger = logger; + _this.host = host; + _this.logPerformance = false; + return _this; } CoreServicesShimObject.prototype.forwardJSONCall = function (actionDescription, action) { return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index b1248c700fa..577a8ee4fc9 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -72,7 +72,6 @@ var ts; (function (ts) { ts.timestamp = typeof performance !== "undefined" && performance.now ? function () { return performance.now(); } : Date.now ? Date.now : function () { return +(new Date()); }; })(ts || (ts = {})); -var ts; (function (ts) { var performance; (function (performance) { @@ -790,6 +789,56 @@ var ts; }; } ts.memoize = memoize; + function chain(a, b, c, d, e) { + if (e) { + var args_2 = []; + for (var i = 0; i < arguments.length; i++) { + args_2[i] = arguments[i]; + } + return function (t) { return compose.apply(void 0, map(args_2, function (f) { return f(t); })); }; + } + else if (d) { + return function (t) { return compose(a(t), b(t), c(t), d(t)); }; + } + else if (c) { + return function (t) { return compose(a(t), b(t), c(t)); }; + } + else if (b) { + return function (t) { return compose(a(t), b(t)); }; + } + else if (a) { + return function (t) { return compose(a(t)); }; + } + else { + return function (t) { return function (u) { return u; }; }; + } + } + ts.chain = chain; + function compose(a, b, c, d, e) { + if (e) { + var args_3 = []; + for (var i = 0; i < arguments.length; i++) { + args_3[i] = arguments[i]; + } + return function (t) { return reduceLeft(args_3, function (u, f) { return f(u); }, t); }; + } + else if (d) { + return function (t) { return d(c(b(a(t)))); }; + } + else if (c) { + return function (t) { return c(b(a(t))); }; + } + else if (b) { + return function (t) { return b(a(t)); }; + } + else if (a) { + return function (t) { return a(t); }; + } + else { + return function (t) { return t; }; + } + } + ts.compose = compose; function formatStringFromArgs(text, args, baseIndex) { baseIndex = baseIndex || 0; return text.replace(/{(\d+)}/g, function (match, index) { return args[+index + baseIndex]; }); @@ -1537,7 +1586,6 @@ var ts; this.transformFlags = 0; this.parent = undefined; this.original = undefined; - this.transformId = 0; } ts.objectAllocator = { getNodeConstructor: function () { return Node; }, @@ -1550,9 +1598,9 @@ var ts; }; var Debug; (function (Debug) { - var currentAssertionLevel; + Debug.currentAssertionLevel = 0; function shouldAssert(level) { - return getCurrentAssertionLevel() >= level; + return Debug.currentAssertionLevel >= level; } Debug.shouldAssert = shouldAssert; function assert(expression, message, verboseDebugInfo) { @@ -1570,30 +1618,7 @@ var ts; Debug.assert(false, message); } Debug.fail = fail; - function getCurrentAssertionLevel() { - if (currentAssertionLevel !== undefined) { - return currentAssertionLevel; - } - if (ts.sys === undefined) { - return 0; - } - var developmentMode = /^development$/i.test(getEnvironmentVariable("NODE_ENV")); - currentAssertionLevel = developmentMode - ? 1 - : 0; - return currentAssertionLevel; - } })(Debug = ts.Debug || (ts.Debug = {})); - function getEnvironmentVariable(name, host) { - if (host && host.getEnvironmentVariable) { - return host.getEnvironmentVariable(name); - } - if (ts.sys && ts.sys.getEnvironmentVariable) { - return ts.sys.getEnvironmentVariable(name); - } - return ""; - } - ts.getEnvironmentVariable = getEnvironmentVariable; function orderedRemoveItemAt(array, index) { for (var i = index; i < array.length - 1; i++) { array[i] = array[i + 1]; @@ -1624,6 +1649,60 @@ var ts; : (function (fileName) { return fileName.toLowerCase(); }); } ts.createGetCanonicalFileName = createGetCanonicalFileName; + function matchPatternOrExact(patternStrings, candidate) { + var patterns = []; + for (var _i = 0, patternStrings_1 = patternStrings; _i < patternStrings_1.length; _i++) { + var patternString = patternStrings_1[_i]; + var pattern = tryParsePattern(patternString); + if (pattern) { + patterns.push(pattern); + } + else if (patternString === candidate) { + return patternString; + } + } + return findBestPatternMatch(patterns, function (_) { return _; }, candidate); + } + ts.matchPatternOrExact = matchPatternOrExact; + function patternText(_a) { + var prefix = _a.prefix, suffix = _a.suffix; + return prefix + "*" + suffix; + } + ts.patternText = patternText; + function matchedText(pattern, candidate) { + Debug.assert(isPatternMatch(pattern, candidate)); + return candidate.substr(pattern.prefix.length, candidate.length - pattern.suffix.length); + } + ts.matchedText = matchedText; + function findBestPatternMatch(values, getPattern, candidate) { + var matchedValue = undefined; + var longestMatchPrefixLength = -1; + for (var _i = 0, values_1 = values; _i < values_1.length; _i++) { + var v = values_1[_i]; + var pattern = getPattern(v); + if (isPatternMatch(pattern, candidate) && pattern.prefix.length > longestMatchPrefixLength) { + longestMatchPrefixLength = pattern.prefix.length; + matchedValue = v; + } + } + return matchedValue; + } + ts.findBestPatternMatch = findBestPatternMatch; + function isPatternMatch(_a, candidate) { + var prefix = _a.prefix, suffix = _a.suffix; + return candidate.length >= prefix.length + suffix.length && + startsWith(candidate, prefix) && + endsWith(candidate, suffix); + } + function tryParsePattern(pattern) { + Debug.assert(hasZeroOrOneAsteriskCharacter(pattern)); + var indexOfStar = pattern.indexOf("*"); + return indexOfStar === -1 ? undefined : { + prefix: pattern.substr(0, indexOfStar), + suffix: pattern.substr(indexOfStar + 1) + }; + } + ts.tryParsePattern = tryParsePattern; function positionIsSynthesized(pos) { return !(pos >= 0); } @@ -1821,8 +1900,14 @@ var ts; function isNode4OrLater() { return parseInt(process.version.charAt(1)) >= 4; } + function isFileSystemCaseSensitive() { + if (platform === "win32" || platform === "win64") { + return false; + } + return !fileExists(__filename.toUpperCase()) || !fileExists(__filename.toLowerCase()); + } var platform = _os.platform(); - var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin"; + var useCaseSensitiveFileNames = isFileSystemCaseSensitive(); function readFile(fileName, encoding) { if (!fileExists(fileName)) { return undefined; @@ -1947,6 +2032,9 @@ var ts; }, watchDirectory: function (directoryName, callback, recursive) { var options; + if (!directoryExists(directoryName)) { + return; + } if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) { options = { persistent: true, recursive: !!recursive }; } @@ -2090,6 +2178,11 @@ var ts; } return sys; })(); + if (ts.sys && ts.sys.getEnvironmentVariable) { + ts.Debug.currentAssertionLevel = /^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV")) + ? 1 + : 0; + } })(ts || (ts = {})); var ts; (function (ts) { @@ -2414,7 +2507,7 @@ var ts; The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2407, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_2407", message: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter." }, Setters_cannot_return_a_value: { code: 2408, category: ts.DiagnosticCategory.Error, key: "Setters_cannot_return_a_value_2408", message: "Setters cannot return a value." }, Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { code: 2409, category: ts.DiagnosticCategory.Error, key: "Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class_2409", message: "Return type of constructor signature must be assignable to the instance type of the class" }, - All_symbols_within_a_with_block_will_be_resolved_to_any: { code: 2410, category: ts.DiagnosticCategory.Error, key: "All_symbols_within_a_with_block_will_be_resolved_to_any_2410", message: "All symbols within a 'with' block will be resolved to 'any'." }, + The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any: { code: 2410, category: ts.DiagnosticCategory.Error, key: "The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any_2410", message: "The 'with' statement is not supported. All symbols in a 'with' block will have type 'any'." }, Property_0_of_type_1_is_not_assignable_to_string_index_type_2: { code: 2411, category: ts.DiagnosticCategory.Error, key: "Property_0_of_type_1_is_not_assignable_to_string_index_type_2_2411", message: "Property '{0}' of type '{1}' is not assignable to string index type '{2}'." }, Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2: { code: 2412, category: ts.DiagnosticCategory.Error, key: "Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2_2412", message: "Property '{0}' of type '{1}' is not assignable to numeric index type '{2}'." }, Numeric_index_type_0_is_not_assignable_to_string_index_type_1: { code: 2413, category: ts.DiagnosticCategory.Error, key: "Numeric_index_type_0_is_not_assignable_to_string_index_type_1_2413", message: "Numeric index type '{0}' is not assignable to string index type '{1}'." }, @@ -2575,7 +2668,7 @@ var ts; this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation: { code: 2683, category: ts.DiagnosticCategory.Error, key: "this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_2683", message: "'this' implicitly has type 'any' because it does not have a type annotation." }, The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1: { code: 2684, category: ts.DiagnosticCategory.Error, key: "The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1_2684", message: "The 'this' context of type '{0}' is not assignable to method's 'this' of type '{1}'." }, The_this_types_of_each_signature_are_incompatible: { code: 2685, category: ts.DiagnosticCategory.Error, key: "The_this_types_of_each_signature_are_incompatible_2685", message: "The 'this' types of each signature are incompatible." }, - Identifier_0_must_be_imported_from_a_module: { code: 2686, category: ts.DiagnosticCategory.Error, key: "Identifier_0_must_be_imported_from_a_module_2686", message: "Identifier '{0}' must be imported from a module" }, + _0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead: { code: 2686, category: ts.DiagnosticCategory.Error, key: "_0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead_2686", message: "'{0}' refers to a UMD global, but the current file is a module. Consider adding an import instead." }, All_declarations_of_0_must_have_identical_modifiers: { code: 2687, category: ts.DiagnosticCategory.Error, key: "All_declarations_of_0_must_have_identical_modifiers_2687", message: "All declarations of '{0}' must have identical modifiers." }, Cannot_find_type_definition_file_for_0: { code: 2688, category: ts.DiagnosticCategory.Error, key: "Cannot_find_type_definition_file_for_0_2688", message: "Cannot find type definition file for '{0}'." }, Cannot_extend_an_interface_0_Did_you_mean_implements: { code: 2689, category: ts.DiagnosticCategory.Error, key: "Cannot_extend_an_interface_0_Did_you_mean_implements_2689", message: "Cannot extend an interface '{0}'. Did you mean 'implements'?" }, @@ -2809,6 +2902,7 @@ var ts; Property_0_is_declared_but_never_used: { code: 6138, category: ts.DiagnosticCategory.Error, key: "Property_0_is_declared_but_never_used_6138", message: "Property '{0}' is declared but never used." }, Import_emit_helpers_from_tslib: { code: 6139, category: ts.DiagnosticCategory.Message, key: "Import_emit_helpers_from_tslib_6139", message: "Import emit helpers from 'tslib'." }, Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: { code: 6140, category: ts.DiagnosticCategory.Error, key: "Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using__6140", message: "Auto discovery for typings is enabled in project '{0}'. Running extra resolution pass for module '{1}' using cache location '{2}'." }, + Parse_in_strict_mode_and_emit_use_strict_for_each_source_file: { code: 6141, category: ts.DiagnosticCategory.Message, key: "Parse_in_strict_mode_and_emit_use_strict_for_each_source_file_6141", message: "Parse in strict mode and emit \"use strict\" for each source file" }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter_0_implicitly_has_an_1_type_7006", message: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member_0_implicitly_has_an_1_type_7008", message: "Member '{0}' implicitly has an '{1}' type." }, @@ -2833,6 +2927,7 @@ var ts; Binding_element_0_implicitly_has_an_1_type: { code: 7031, category: ts.DiagnosticCategory.Error, key: "Binding_element_0_implicitly_has_an_1_type_7031", message: "Binding element '{0}' implicitly has an '{1}' type." }, Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation: { code: 7032, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation_7032", message: "Property '{0}' implicitly has type 'any', because its set accessor lacks a parameter type annotation." }, Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation: { code: 7033, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation_7033", message: "Property '{0}' implicitly has type 'any', because its get accessor lacks a return type annotation." }, + Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined: { code: 7034, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined_7034", message: "Variable '{0}' implicitly has type 'any' in some locations where its type cannot be determined." }, You_cannot_rename_this_element: { code: 8000, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_this_element_8000", message: "You cannot rename this element." }, You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", message: "You cannot rename elements that are defined in the standard TypeScript library." }, import_can_only_be_used_in_a_ts_file: { code: 8002, category: ts.DiagnosticCategory.Error, key: "import_can_only_be_used_in_a_ts_file_8002", message: "'import ... =' can only be used in a .ts file." }, @@ -2862,7 +2957,14 @@ var ts; super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class: { code: 17009, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class_17009", message: "'super' must be called before accessing 'this' in the constructor of a derived class." }, Unknown_typing_option_0: { code: 17010, category: ts.DiagnosticCategory.Error, key: "Unknown_typing_option_0_17010", message: "Unknown typing option '{0}'." }, Circularity_detected_while_resolving_configuration_Colon_0: { code: 18000, category: ts.DiagnosticCategory.Error, key: "Circularity_detected_while_resolving_configuration_Colon_0_18000", message: "Circularity detected while resolving configuration: {0}" }, - The_path_in_an_extends_options_must_be_relative_or_rooted: { code: 18001, category: ts.DiagnosticCategory.Error, key: "The_path_in_an_extends_options_must_be_relative_or_rooted_18001", message: "The path in an 'extends' options must be relative or rooted." } + The_path_in_an_extends_options_must_be_relative_or_rooted: { code: 18001, category: ts.DiagnosticCategory.Error, key: "The_path_in_an_extends_options_must_be_relative_or_rooted_18001", message: "The path in an 'extends' options must be relative or rooted." }, + Add_missing_super_call: { code: 90001, category: ts.DiagnosticCategory.Message, key: "Add_missing_super_call_90001", message: "Add missing 'super()' call." }, + Make_super_call_the_first_statement_in_the_constructor: { code: 90002, category: ts.DiagnosticCategory.Message, key: "Make_super_call_the_first_statement_in_the_constructor_90002", message: "Make 'super()' call the first statement in the constructor." }, + Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'" }, + Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers" }, + Implement_interface_on_reference: { code: 90005, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_reference_90005", message: "Implement interface on reference" }, + Implement_interface_on_class: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_class_90006", message: "Implement interface on class" }, + Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" } }; })(ts || (ts = {})); var ts; @@ -3772,7 +3874,7 @@ var ts; return token = 69; } function scanBinaryOrOctalDigits(base) { - ts.Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8"); + ts.Debug.assert(base === 2 || base === 8, "Expected either base 2 or base 8"); var value = 0; var numberOfDigits = 0; while (true) { @@ -4844,6 +4946,11 @@ var ts; name: "importHelpers", type: "boolean", description: ts.Diagnostics.Import_emit_helpers_from_tslib + }, + { + name: "alwaysStrict", + type: "boolean", + description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file } ]; ts.typingOptionDeclarations = [ @@ -5294,7 +5401,7 @@ var ts; ts.convertTypingOptionsFromJson = convertTypingOptionsFromJson; function convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { var options = ts.getBaseFileName(configFileName) === "jsconfig.json" - ? { allowJs: true, maxNodeModuleJsDepth: 2, allowSyntheticDefaultImports: true } + ? { allowJs: true, maxNodeModuleJsDepth: 2, allowSyntheticDefaultImports: true, skipLibCheck: true } : {}; convertOptionsFromJson(ts.optionDeclarations, jsonOptions, basePath, options, ts.Diagnostics.Unknown_compiler_option_0, errors); return options; @@ -5704,7 +5811,7 @@ var ts; else if (host.getCurrentDirectory) { currentDirectory = host.getCurrentDirectory(); } - return currentDirectory && getDefaultTypeRoots(currentDirectory, host); + return currentDirectory !== undefined && getDefaultTypeRoots(currentDirectory, host); } ts.getEffectiveTypeRoots = getEffectiveTypeRoots; function getDefaultTypeRoots(currentDirectory, host) { @@ -5958,11 +6065,11 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); } - matchedPattern = matchPatternOrExact(ts.getOwnKeys(state.compilerOptions.paths), moduleName); + matchedPattern = ts.matchPatternOrExact(ts.getOwnKeys(state.compilerOptions.paths), moduleName); } if (matchedPattern) { - var matchedStar = typeof matchedPattern === "string" ? undefined : matchedText(matchedPattern, moduleName); - var matchedPatternText = typeof matchedPattern === "string" ? matchedPattern : patternText(matchedPattern); + var matchedStar = typeof matchedPattern === "string" ? undefined : ts.matchedText(matchedPattern, moduleName); + var matchedPatternText = typeof matchedPattern === "string" ? matchedPattern : ts.patternText(matchedPattern); if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPatternText); } @@ -5988,57 +6095,6 @@ var ts; return loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); } } - function matchPatternOrExact(patternStrings, candidate) { - var patterns = []; - for (var _i = 0, patternStrings_1 = patternStrings; _i < patternStrings_1.length; _i++) { - var patternString = patternStrings_1[_i]; - var pattern = tryParsePattern(patternString); - if (pattern) { - patterns.push(pattern); - } - else if (patternString === candidate) { - return patternString; - } - } - return findBestPatternMatch(patterns, function (_) { return _; }, candidate); - } - function patternText(_a) { - var prefix = _a.prefix, suffix = _a.suffix; - return prefix + "*" + suffix; - } - function matchedText(pattern, candidate) { - ts.Debug.assert(isPatternMatch(pattern, candidate)); - return candidate.substr(pattern.prefix.length, candidate.length - pattern.suffix.length); - } - function findBestPatternMatch(values, getPattern, candidate) { - var matchedValue = undefined; - var longestMatchPrefixLength = -1; - for (var _i = 0, values_1 = values; _i < values_1.length; _i++) { - var v = values_1[_i]; - var pattern = getPattern(v); - if (isPatternMatch(pattern, candidate) && pattern.prefix.length > longestMatchPrefixLength) { - longestMatchPrefixLength = pattern.prefix.length; - matchedValue = v; - } - } - return matchedValue; - } - ts.findBestPatternMatch = findBestPatternMatch; - function isPatternMatch(_a, candidate) { - var prefix = _a.prefix, suffix = _a.suffix; - return candidate.length >= prefix.length + suffix.length && - ts.startsWith(candidate, prefix) && - ts.endsWith(candidate, suffix); - } - function tryParsePattern(pattern) { - ts.Debug.assert(ts.hasZeroOrOneAsteriskCharacter(pattern)); - var indexOfStar = pattern.indexOf("*"); - return indexOfStar === -1 ? undefined : { - prefix: pattern.substr(0, indexOfStar), - suffix: pattern.substr(indexOfStar + 1) - }; - } - ts.tryParsePattern = tryParsePattern; function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host) { var containingDirectory = ts.getDirectoryPath(containingFile); var supportedExtensions = ts.getSupportedExtensions(compilerOptions); @@ -6169,20 +6225,28 @@ var ts; } } function loadModuleFromNodeModules(moduleName, directory, failedLookupLocations, state, checkOneLevel) { + return loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, checkOneLevel, false); + } + ts.loadModuleFromNodeModules = loadModuleFromNodeModules; + function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) { + return loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, false, true); + } + function loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, checkOneLevel, typesOnly) { directory = ts.normalizeSlashes(directory); while (true) { var baseName = ts.getBaseFileName(directory); if (baseName !== "node_modules") { - var packageResult = loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state); - if (packageResult && ts.hasTypeScriptFileExtension(packageResult)) { - return packageResult; - } - else { - var typesResult = loadModuleFromNodeModulesFolder(ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); - if (typesResult || packageResult) { - return typesResult || packageResult; + var packageResult = void 0; + if (!typesOnly) { + packageResult = loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state); + if (packageResult && ts.hasTypeScriptFileExtension(packageResult)) { + return packageResult; } } + var typesResult = loadModuleFromNodeModulesFolder(ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); + if (typesResult || packageResult) { + return typesResult || packageResult; + } } var parentPath = ts.getDirectoryPath(directory); if (parentPath === directory || checkOneLevel) { @@ -6192,7 +6256,6 @@ var ts; } return undefined; } - ts.loadModuleFromNodeModules = loadModuleFromNodeModules; function classicNameResolver(moduleName, containingFile, compilerOptions, host) { var traceEnabled = isTraceEnabled(compilerOptions, host); var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: !compilerOptions.jsx }; @@ -6205,18 +6268,8 @@ var ts; } var referencedSourceFile; if (moduleHasNonRelativeName(moduleName)) { - while (true) { - var searchName = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - referencedSourceFile = loadModuleFromFile(searchName, supportedExtensions, failedLookupLocations, false, state); - if (referencedSourceFile) { - break; - } - var parentPath = ts.getDirectoryPath(containingDirectory); - if (parentPath === containingDirectory) { - break; - } - containingDirectory = parentPath; - } + referencedSourceFile = referencedSourceFile = loadModuleFromAncestorDirectories(moduleName, containingDirectory, supportedExtensions, failedLookupLocations, state) || + loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); @@ -6227,6 +6280,20 @@ var ts; : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; } ts.classicNameResolver = classicNameResolver; + function loadModuleFromAncestorDirectories(moduleName, containingDirectory, supportedExtensions, failedLookupLocations, state) { + while (true) { + var searchName = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + var referencedSourceFile = loadModuleFromFile(searchName, supportedExtensions, failedLookupLocations, false, state); + if (referencedSourceFile) { + return referencedSourceFile; + } + var parentPath = ts.getDirectoryPath(containingDirectory); + if (parentPath === containingDirectory) { + return undefined; + } + containingDirectory = parentPath; + } + } })(ts || (ts = {})); var ts; (function (ts) { @@ -6242,6 +6309,36 @@ var ts; var result = ts.resolveModuleName(packageName, ts.combinePaths(cachePath, "index.d.ts"), { moduleResolution: ts.ModuleResolutionKind.NodeJs }, installTypingHost); return result.resolvedModule && result.resolvedModule.resolvedFileName; } + (function (PackageNameValidationResult) { + PackageNameValidationResult[PackageNameValidationResult["Ok"] = 0] = "Ok"; + PackageNameValidationResult[PackageNameValidationResult["ScopedPackagesNotSupported"] = 1] = "ScopedPackagesNotSupported"; + PackageNameValidationResult[PackageNameValidationResult["NameTooLong"] = 2] = "NameTooLong"; + PackageNameValidationResult[PackageNameValidationResult["NameStartsWithDot"] = 3] = "NameStartsWithDot"; + PackageNameValidationResult[PackageNameValidationResult["NameStartsWithUnderscore"] = 4] = "NameStartsWithUnderscore"; + PackageNameValidationResult[PackageNameValidationResult["NameContainsNonURISafeCharacters"] = 5] = "NameContainsNonURISafeCharacters"; + })(typingsInstaller.PackageNameValidationResult || (typingsInstaller.PackageNameValidationResult = {})); + var PackageNameValidationResult = typingsInstaller.PackageNameValidationResult; + typingsInstaller.MaxPackageNameLength = 214; + function validatePackageName(packageName) { + ts.Debug.assert(!!packageName, "Package name is not specified"); + if (packageName.length > typingsInstaller.MaxPackageNameLength) { + return PackageNameValidationResult.NameTooLong; + } + if (packageName.charCodeAt(0) === 46) { + return PackageNameValidationResult.NameStartsWithDot; + } + if (packageName.charCodeAt(0) === 95) { + return PackageNameValidationResult.NameStartsWithUnderscore; + } + if (/^@[^/]+\/[^/]+$/.test(packageName)) { + return PackageNameValidationResult.ScopedPackagesNotSupported; + } + if (encodeURIComponent(packageName) !== packageName) { + return PackageNameValidationResult.NameContainsNonURISafeCharacters; + } + return PackageNameValidationResult.Ok; + } + typingsInstaller.validatePackageName = validatePackageName; typingsInstaller.NpmViewRequest = "npm view"; typingsInstaller.NpmInstallRequest = "npm install"; var TypingsInstaller = (function () { @@ -6364,15 +6461,54 @@ var ts; } this.knownCachesSet[cacheLocation] = true; }; + TypingsInstaller.prototype.filterTypings = function (typingsToInstall) { + if (typingsToInstall.length === 0) { + return typingsToInstall; + } + var result = []; + for (var _i = 0, typingsToInstall_1 = typingsToInstall; _i < typingsToInstall_1.length; _i++) { + var typing = typingsToInstall_1[_i]; + if (this.missingTypingsSet[typing]) { + continue; + } + var validationResult = validatePackageName(typing); + if (validationResult === PackageNameValidationResult.Ok) { + result.push(typing); + } + else { + this.missingTypingsSet[typing] = true; + if (this.log.isEnabled()) { + switch (validationResult) { + case PackageNameValidationResult.NameTooLong: + this.log.writeLine("Package name '" + typing + "' should be less than " + typingsInstaller.MaxPackageNameLength + " characters"); + break; + case PackageNameValidationResult.NameStartsWithDot: + this.log.writeLine("Package name '" + typing + "' cannot start with '.'"); + break; + case PackageNameValidationResult.NameStartsWithUnderscore: + this.log.writeLine("Package name '" + typing + "' cannot start with '_'"); + break; + case PackageNameValidationResult.ScopedPackagesNotSupported: + this.log.writeLine("Package '" + typing + "' is scoped and currently is not supported"); + break; + case PackageNameValidationResult.NameContainsNonURISafeCharacters: + this.log.writeLine("Package name '" + typing + "' contains non URI safe characters"); + break; + } + } + } + } + return result; + }; TypingsInstaller.prototype.installTypings = function (req, cachePath, currentlyCachedTypings, typingsToInstall) { var _this = this; if (this.log.isEnabled()) { this.log.writeLine("Installing typings " + JSON.stringify(typingsToInstall)); } - typingsToInstall = ts.filter(typingsToInstall, function (x) { return !_this.missingTypingsSet[x]; }); + typingsToInstall = this.filterTypings(typingsToInstall); if (typingsToInstall.length === 0) { if (this.log.isEnabled()) { - this.log.writeLine("All typings are known to be missing - no need to go any further"); + this.log.writeLine("All typings are known to be missing or invalid - no need to go any further"); } return; } @@ -6412,8 +6548,8 @@ var ts; if (_this.log.isEnabled()) { _this.log.writeLine("Installed typing files " + JSON.stringify(installedTypingFiles)); } - for (var _a = 0, typingsToInstall_1 = typingsToInstall; _a < typingsToInstall_1.length; _a++) { - var toInstall = typingsToInstall_1[_a]; + for (var _a = 0, typingsToInstall_2 = typingsToInstall; _a < typingsToInstall_2.length; _a++) { + var toInstall = typingsToInstall_2[_a]; if (!installedPackages[toInstall]) { if (_this.log.isEnabled()) { _this.log.writeLine("New missing typing package '" + toInstall + "'"); @@ -6429,8 +6565,8 @@ var ts; this.installRunCount++; var execInstallCmdCount = 0; var filteredTypings = []; - for (var _i = 0, typingsToInstall_2 = typingsToInstall; _i < typingsToInstall_2.length; _i++) { - var typing = typingsToInstall_2[_i]; + for (var _i = 0, typingsToInstall_3 = typingsToInstall; _i < typingsToInstall_3.length; _i++) { + var typing = typingsToInstall_3[_i]; execNpmViewTyping(this, typing); } function execNpmViewTyping(self, typing) { @@ -6553,13 +6689,14 @@ var ts; var NodeTypingsInstaller = (function (_super) { __extends(NodeTypingsInstaller, _super); function NodeTypingsInstaller(globalTypingsCacheLocation, throttleLimit, log) { - _super.call(this, globalTypingsCacheLocation, getNPMLocation(process.argv[0]), ts.toPath("typingSafeList.json", __dirname, ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)), throttleLimit, log); - this.installTypingHost = ts.sys; - if (this.log.isEnabled()) { - this.log.writeLine("Process id: " + process.pid); + var _this = _super.call(this, globalTypingsCacheLocation, getNPMLocation(process.argv[0]), ts.toPath("typingSafeList.json", __dirname, ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)), throttleLimit, log) || this; + _this.installTypingHost = ts.sys; + if (_this.log.isEnabled()) { + _this.log.writeLine("Process id: " + process.pid); } var exec = require("child_process").exec; - this.exec = exec; + _this.exec = exec; + return _this; } NodeTypingsInstaller.prototype.init = function () { var _this = this; From 2cd404038eb0ca962350674fbdbbbe1bcf07810d Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 13 Oct 2016 17:11:03 -0700 Subject: [PATCH 095/173] Port fix in https://github.com/Microsoft/TypeScript/pull/11293 to correct file --- src/lib/es5.d.ts | 3 +++ tests/cases/fourslash/functionTypes.ts | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index ccff01a8722..2c457a432c6 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -244,6 +244,9 @@ interface Function { */ bind(this: Function, thisArg: any, ...argArray: any[]): any; + /** Returns a string representation of a function. */ + toString(): string; + prototype: any; readonly length: number; diff --git a/tests/cases/fourslash/functionTypes.ts b/tests/cases/fourslash/functionTypes.ts index 8973f73431b..0baccba286e 100644 --- a/tests/cases/fourslash/functionTypes.ts +++ b/tests/cases/fourslash/functionTypes.ts @@ -23,7 +23,7 @@ verify.numberOfErrorsInCurrentFile(0); for (var i = 1; i <= 7; i++) { goTo.marker('' + i); - verify.memberListCount(7); + verify.memberListCount(8); verify.completionListContains('apply'); verify.completionListContains('arguments'); verify.completionListContains('bind'); @@ -31,4 +31,5 @@ for (var i = 1; i <= 7; i++) { verify.completionListContains('length'); verify.completionListContains('caller'); verify.completionListContains('prototype'); + verify.completionListContains('toString'); } From cdafc9dca1df725e6684a84433d147710870e2bd Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 13 Oct 2016 17:29:03 -0700 Subject: [PATCH 096/173] Update LKG --- lib/lib.d.ts | 3 +++ lib/lib.es5.d.ts | 3 +++ lib/lib.es6.d.ts | 3 +++ lib/tsc.js | 2 -- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/lib.d.ts b/lib/lib.d.ts index 87280fedba4..922820b5d90 100644 --- a/lib/lib.d.ts +++ b/lib/lib.d.ts @@ -260,6 +260,9 @@ interface Function { */ bind(this: Function, thisArg: any, ...argArray: any[]): any; + /** Returns a string representation of a function. */ + toString(): string; + prototype: any; readonly length: number; diff --git a/lib/lib.es5.d.ts b/lib/lib.es5.d.ts index d20c7d1e3a7..a13ffc92d04 100644 --- a/lib/lib.es5.d.ts +++ b/lib/lib.es5.d.ts @@ -260,6 +260,9 @@ interface Function { */ bind(this: Function, thisArg: any, ...argArray: any[]): any; + /** Returns a string representation of a function. */ + toString(): string; + prototype: any; readonly length: number; diff --git a/lib/lib.es6.d.ts b/lib/lib.es6.d.ts index 6067d810b44..4c8806dd7dd 100644 --- a/lib/lib.es6.d.ts +++ b/lib/lib.es6.d.ts @@ -260,6 +260,9 @@ interface Function { */ bind(this: Function, thisArg: any, ...argArray: any[]): any; + /** Returns a string representation of a function. */ + toString(): string; + prototype: any; readonly length: number; diff --git a/lib/tsc.js b/lib/tsc.js index 7f46b1dddb4..b1fac7955d0 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -67,7 +67,6 @@ var ts; (function (ts) { ts.timestamp = typeof performance !== "undefined" && performance.now ? function () { return performance.now(); } : Date.now ? Date.now : function () { return +(new Date()); }; })(ts || (ts = {})); -var ts; (function (ts) { var performance; (function (performance) { @@ -7937,7 +7936,6 @@ var ts; } ts.isWatchSet = isWatchSet; })(ts || (ts = {})); -var ts; (function (ts) { function getDefaultLibFileName(options) { return options.target === 2 ? "lib.es6.d.ts" : "lib.d.ts"; From c4300e017f8b2f05e591af8f6c65c43dffa96403 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Thu, 13 Oct 2016 17:53:44 -0700 Subject: [PATCH 097/173] Adds ES5 to ES3 transformer for reserved words --- Jakefile.js | 18 ++- src/compiler/transformer.ts | 5 + src/compiler/transformers/es5.ts | 83 ++++++++++ src/compiler/transformers/module/module.ts | 53 ++----- src/compiler/transformers/module/system.ts | 8 +- src/compiler/tsconfig.json | 1 + src/harness/tsconfig.json | 1 + src/services/tsconfig.json | 1 + .../allowSyntheticDefaultImports10.js | 4 +- .../baselines/reference/bluebirdStaticThis.js | 6 +- .../reference/classMethodWithKeywordName1.js | 2 +- ...constructorWithIncompleteTypeAnnotation.js | 10 +- .../baselines/reference/convertKeywordsYes.js | 144 +++++++++--------- .../destructuringParameterDeclaration6.js | 8 +- tests/baselines/reference/es6ClassTest5.js | 2 +- .../reference/fatarrowfunctionsErrors.js | 2 +- tests/baselines/reference/keywordField.js | 6 +- .../reference/keywordInJsxIdentifier.js | 4 +- .../reference/nestedClassDeclaration.js | 2 +- ...bjectBindingPatternKeywordIdentifiers01.js | 2 +- ...bjectBindingPatternKeywordIdentifiers02.js | 2 +- ...bjectBindingPatternKeywordIdentifiers03.js | 2 +- ...bjectBindingPatternKeywordIdentifiers04.js | 2 +- ...ndPropertiesErrorFromNotUsingIdentifier.js | 12 +- ...ctTypesIdentityWithConstructSignatures2.js | 2 +- ...ConstructSignaturesDifferingParamCounts.js | 2 +- ...nstructSignaturesDifferingByConstraints.js | 2 +- ...structSignaturesDifferingByConstraints2.js | 2 +- ...structSignaturesDifferingByConstraints3.js | 2 +- ...onstructSignaturesDifferingByReturnType.js | 2 +- ...nstructSignaturesDifferingByReturnType2.js | 2 +- ...tSignaturesDifferingTypeParameterCounts.js | 2 +- ...ctSignaturesDifferingTypeParameterNames.js | 2 +- ...enericConstructSignaturesOptionalParams.js | 2 +- ...nericConstructSignaturesOptionalParams2.js | 2 +- ...nericConstructSignaturesOptionalParams3.js | 2 +- .../parserErrorRecovery_ObjectLiteral2.js | 2 +- .../parserErrorRecovery_ObjectLiteral3.js | 2 +- .../parserErrorRecovery_ObjectLiteral4.js | 2 +- .../parserErrorRecovery_ObjectLiteral5.js | 2 +- .../parserExportAsFunctionIdentifier.js | 2 +- .../parserKeywordsAsIdentifierName1.js | 6 +- .../parserShorthandPropertyAssignment2.js | 2 +- .../reference/parserSuperExpression3.js | 2 +- .../prototypeOnConstructorFunctions.js | 2 +- tests/baselines/reference/reservedWords.js | 18 +-- tests/baselines/reference/reservedWords2.js | 4 +- tests/baselines/reference/super1.js | 2 +- .../reference/tsxReactEmitNesting.js | 24 +-- .../reference/typeQueryWithReservedWords.js | 4 +- 50 files changed, 270 insertions(+), 208 deletions(-) create mode 100644 src/compiler/transformers/es5.ts diff --git a/Jakefile.js b/Jakefile.js index 64a8553ef39..ff6a9f1bd1a 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -70,13 +70,14 @@ var compilerSources = [ "visitor.ts", "transformers/destructuring.ts", "transformers/ts.ts", + "transformers/jsx.ts", + "transformers/es7.ts", + "transformers/es6.ts", + "transformers/es5.ts", + "transformers/generators.ts", "transformers/module/es6.ts", "transformers/module/system.ts", "transformers/module/module.ts", - "transformers/jsx.ts", - "transformers/es7.ts", - "transformers/generators.ts", - "transformers/es6.ts", "transformer.ts", "sourcemap.ts", "comments.ts", @@ -104,13 +105,14 @@ var servicesSources = [ "visitor.ts", "transformers/destructuring.ts", "transformers/ts.ts", + "transformers/jsx.ts", + "transformers/es7.ts", + "transformers/es6.ts", + "transformers/es5.ts", + "transformers/generators.ts", "transformers/module/es6.ts", "transformers/module/system.ts", "transformers/module/module.ts", - "transformers/jsx.ts", - "transformers/es7.ts", - "transformers/generators.ts", - "transformers/es6.ts", "transformer.ts", "sourcemap.ts", "comments.ts", diff --git a/src/compiler/transformer.ts b/src/compiler/transformer.ts index 92407af2bb9..1d2df002865 100644 --- a/src/compiler/transformer.ts +++ b/src/compiler/transformer.ts @@ -3,6 +3,7 @@ /// /// /// +/// /// /// /// @@ -122,6 +123,10 @@ namespace ts { transformers.push(transformGenerators); } + if (languageVersion < ScriptTarget.ES5) { + transformers.push(transformES5); + } + return transformers; } diff --git a/src/compiler/transformers/es5.ts b/src/compiler/transformers/es5.ts new file mode 100644 index 00000000000..9e5a72c2bad --- /dev/null +++ b/src/compiler/transformers/es5.ts @@ -0,0 +1,83 @@ +/// +/// + +/*@internal*/ +namespace ts { + /** + * Transforms ES5 syntax into ES3 syntax. + * + * @param context Context and state information for the transformation. + */ + export function transformES5(context: TransformationContext) { + const previousOnSubstituteNode = context.onSubstituteNode; + context.onSubstituteNode = onSubstituteNode; + context.enableSubstitution(SyntaxKind.PropertyAccessExpression); + context.enableSubstitution(SyntaxKind.PropertyAssignment); + return transformSourceFile; + + /** + * Transforms an ES5 source file to ES3. + * + * @param node A SourceFile + */ + function transformSourceFile(node: SourceFile) { + return node; + } + + /** + * Hooks node substitutions. + * + * @param emitContext The context for the emitter. + * @param node The node to substitute. + */ + function onSubstituteNode(emitContext: EmitContext, node: Node) { + node = previousOnSubstituteNode(emitContext, node); + if (isPropertyAccessExpression(node)) { + return substitutePropertyAccessExpression(node); + } + else if (isPropertyAssignment(node)) { + return substitutePropertyAssignment(node); + } + return node; + } + + /** + * Substitutes a PropertyAccessExpression whose name is a reserved word. + * + * @param node A PropertyAccessExpression + */ + function substitutePropertyAccessExpression(node: PropertyAccessExpression): Expression { + const literalName = trySubstituteReservedName(node.name); + if (literalName) { + return createElementAccess(node.expression, literalName, /*location*/ node); + } + return node; + } + + /** + * Substitutes a PropertyAssignment whose name is a reserved word. + * + * @param node A PropertyAssignment + */ + function substitutePropertyAssignment(node: PropertyAssignment): PropertyAssignment { + const literalName = isIdentifier(node.name) && trySubstituteReservedName(node.name); + if (literalName) { + return updatePropertyAssignment(node, literalName, node.initializer); + } + return node; + } + + /** + * If an identifier name is a reserved word, returns a string literal for the name. + * + * @param name An Identifier + */ + function trySubstituteReservedName(name: Identifier) { + const token = name.originalKeywordKind || (nodeIsSynthesized(name) ? stringToToken(name.text) : undefined); + if (token >= SyntaxKind.FirstReservedWord && token <= SyntaxKind.LastReservedWord) { + return createLiteral(name, /*location*/ name); + } + return undefined; + } + } +} \ No newline at end of file diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index 94852616037..edbc0f43a68 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -955,39 +955,19 @@ namespace ts { const declaration = resolver.getReferencedImportDeclaration(node); if (declaration) { if (isImportClause(declaration)) { - if (languageVersion >= ScriptTarget.ES5) { - return createPropertyAccess( - getGeneratedNameForNode(declaration.parent), - createIdentifier("default"), - /*location*/ node - ); - } - else { - // TODO: ES3 transform to handle x.default -> x["default"] - return createElementAccess( - getGeneratedNameForNode(declaration.parent), - createLiteral("default"), - /*location*/ node - ); - } + return createPropertyAccess( + getGeneratedNameForNode(declaration.parent), + createIdentifier("default"), + /*location*/ node + ); } else if (isImportSpecifier(declaration)) { const name = declaration.propertyName || declaration.name; - if (name.originalKeywordKind === SyntaxKind.DefaultKeyword && languageVersion <= ScriptTarget.ES3) { - // TODO: ES3 transform to handle x.default -> x["default"] - return createElementAccess( - getGeneratedNameForNode(declaration.parent.parent.parent), - createLiteral(name.text), - /*location*/ node - ); - } - else { - return createPropertyAccess( - getGeneratedNameForNode(declaration.parent.parent.parent), - getSynthesizedClone(name), - /*location*/ node - ); - } + return createPropertyAccess( + getGeneratedNameForNode(declaration.parent.parent.parent), + getSynthesizedClone(name), + /*location*/ node + ); } } } @@ -1024,15 +1004,10 @@ namespace ts { function createExportAssignment(name: Identifier, value: Expression) { return createAssignment( - name.originalKeywordKind === SyntaxKind.DefaultKeyword && languageVersion === ScriptTarget.ES3 - ? createElementAccess( - createIdentifier("exports"), - createLiteral(name.text) - ) - : createPropertyAccess( - createIdentifier("exports"), - getSynthesizedClone(name) - ), + createPropertyAccess( + createIdentifier("exports"), + getSynthesizedClone(name) + ), value ); } diff --git a/src/compiler/transformers/module/system.ts b/src/compiler/transformers/module/system.ts index 0bb188eb390..349d035f459 100644 --- a/src/compiler/transformers/module/system.ts +++ b/src/compiler/transformers/module/system.ts @@ -19,7 +19,6 @@ namespace ts { const compilerOptions = context.getCompilerOptions(); const resolver = context.getEmitResolver(); const host = context.getEmitHost(); - const languageVersion = getEmitScriptTarget(compilerOptions); const previousOnSubstituteNode = context.onSubstituteNode; const previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; @@ -1312,12 +1311,7 @@ namespace ts { return undefined; } - if (name.originalKeywordKind && languageVersion === ScriptTarget.ES3) { - return createElementAccess(importAlias, createLiteral(name.text)); - } - else { - return createPropertyAccess(importAlias, getSynthesizedClone(name)); - } + return createPropertyAccess(importAlias, getSynthesizedClone(name)); } function collectDependencyGroups(externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[]) { diff --git a/src/compiler/tsconfig.json b/src/compiler/tsconfig.json index f128c994af1..894ad9683f7 100644 --- a/src/compiler/tsconfig.json +++ b/src/compiler/tsconfig.json @@ -26,6 +26,7 @@ "transformers/jsx.ts", "transformers/es7.ts", "transformers/es6.ts", + "transformers/es5.ts", "transformers/generators.ts", "transformers/destructuring.ts", "transformers/module/module.ts", diff --git a/src/harness/tsconfig.json b/src/harness/tsconfig.json index f9d302ace81..ffd3f30e293 100644 --- a/src/harness/tsconfig.json +++ b/src/harness/tsconfig.json @@ -28,6 +28,7 @@ "../compiler/transformers/jsx.ts", "../compiler/transformers/es7.ts", "../compiler/transformers/es6.ts", + "../compiler/transformers/es5.ts", "../compiler/transformers/generators.ts", "../compiler/transformers/destructuring.ts", "../compiler/transformers/module/module.ts", diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index 58312c6f38f..cfad296aba2 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -27,6 +27,7 @@ "../compiler/transformers/jsx.ts", "../compiler/transformers/es7.ts", "../compiler/transformers/es6.ts", + "../compiler/transformers/es5.ts", "../compiler/transformers/generators.ts", "../compiler/transformers/destructuring.ts", "../compiler/transformers/module/module.ts", diff --git a/tests/baselines/reference/allowSyntheticDefaultImports10.js b/tests/baselines/reference/allowSyntheticDefaultImports10.js index 746997c4c89..396cd75b574 100644 --- a/tests/baselines/reference/allowSyntheticDefaultImports10.js +++ b/tests/baselines/reference/allowSyntheticDefaultImports10.js @@ -13,5 +13,5 @@ Foo.default.default.foo(); //// [a.js] "use strict"; var Foo = require("./b"); -Foo.default.bar(); -Foo.default.default.foo(); +Foo["default"].bar(); +Foo["default"]["default"].foo(); diff --git a/tests/baselines/reference/bluebirdStaticThis.js b/tests/baselines/reference/bluebirdStaticThis.js index 301f32319a7..606f778323f 100644 --- a/tests/baselines/reference/bluebirdStaticThis.js +++ b/tests/baselines/reference/bluebirdStaticThis.js @@ -146,12 +146,12 @@ var x; var arr; var foo; var fooProm; -fooProm = Promise.try(Promise, function () { +fooProm = Promise["try"](Promise, function () { return foo; }); -fooProm = Promise.try(Promise, function () { +fooProm = Promise["try"](Promise, function () { return foo; }, arr); -fooProm = Promise.try(Promise, function () { +fooProm = Promise["try"](Promise, function () { return foo; }, arr, x); diff --git a/tests/baselines/reference/classMethodWithKeywordName1.js b/tests/baselines/reference/classMethodWithKeywordName1.js index 6e1faee005c..a7cb994bfb3 100644 --- a/tests/baselines/reference/classMethodWithKeywordName1.js +++ b/tests/baselines/reference/classMethodWithKeywordName1.js @@ -7,6 +7,6 @@ class C { var C = (function () { function C() { } - C.try = function () { }; + C["try"] = function () { }; return C; }()); diff --git a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.js b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.js index 2e3190c15c8..1ee309b0eb4 100644 --- a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.js +++ b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.js @@ -292,7 +292,7 @@ var TypeScriptAllInOne; (function (TypeScriptAllInOne) { var Program = (function () { function Program() { - this.case = bfs.STATEMENTS(4); + this["case"] = bfs.STATEMENTS(4); } Program.Main = function () { var args = []; @@ -305,13 +305,13 @@ var TypeScriptAllInOne; retValue = bfs.VARIABLES(); if (retValue != 0) ^= { - return: 1 + "return": 1 }; } finally { } }; - Program.prototype.if = function (retValue) { + Program.prototype["if"] = function (retValue) { if (retValue === void 0) { retValue = != 0; } return 1; ^ @@ -327,7 +327,7 @@ var TypeScriptAllInOne; return 1; } }; - Program.prototype.catch = function (e) { + Program.prototype["catch"] = function (e) { console.log(e); }; return Program; @@ -364,7 +364,7 @@ var BasicFeatures = (function () { ; var quoted = '"', quoted2 = "'"; var reg = /\w*/; - var objLit = { "var": number = 42, equals: function (x) { return x["var"] === 42; }, instanceof: function () { return 'objLit{42}'; } }; + var objLit = { "var": number = 42, equals: function (x) { return x["var"] === 42; }, "instanceof": function () { return 'objLit{42}'; } }; var weekday = Weekdays.Monday; var con = char + f + hexchar + float.toString() + float2.toString() + reg.toString() + objLit + weekday; // diff --git a/tests/baselines/reference/convertKeywordsYes.js b/tests/baselines/reference/convertKeywordsYes.js index ba3c661d1d0..b7bd60e4a95 100644 --- a/tests/baselines/reference/convertKeywordsYes.js +++ b/tests/baselines/reference/convertKeywordsYes.js @@ -344,43 +344,43 @@ var bigObject = { string: 0, get: 0, yield: 0, - break: 0, - case: 0, - catch: 0, - class: 0, - continue: 0, - const: 0, - debugger: 0, + "break": 0, + "case": 0, + "catch": 0, + "class": 0, + "continue": 0, + "const": 0, + "debugger": 0, declare: 0, - default: 0, - delete: 0, - do: 0, - else: 0, - enum: 0, - export: 0, - extends: 0, - false: 0, - finally: 0, - for: 0, - function: 0, - if: 0, - import: 0, - in: 0, - instanceof: 0, - new: 0, - null: 0, - return: 0, - super: 0, - switch: 0, - this: 0, - throw: 0, - true: 0, - try: 0, - typeof: 0, - var: 0, - void: 0, - while: 0, - with: 0 + "default": 0, + "delete": 0, + "do": 0, + "else": 0, + "enum": 0, + "export": 0, + "extends": 0, + "false": 0, + "finally": 0, + "for": 0, + "function": 0, + "if": 0, + "import": 0, + "in": 0, + "instanceof": 0, + "new": 0, + "null": 0, + "return": 0, + "super": 0, + "switch": 0, + "this": 0, + "throw": 0, + "true": 0, + "try": 0, + "typeof": 0, + "var": 0, + "void": 0, + "while": 0, + "with": 0 }; var bigClass = (function () { function bigClass() { @@ -401,43 +401,43 @@ var bigClass = (function () { this.string = 0; this.get = 0; this.yield = 0; - this.break = 0; - this.case = 0; - this.catch = 0; - this.class = 0; - this.continue = 0; - this.const = 0; - this.debugger = 0; + this["break"] = 0; + this["case"] = 0; + this["catch"] = 0; + this["class"] = 0; + this["continue"] = 0; + this["const"] = 0; + this["debugger"] = 0; this.declare = 0; - this.default = 0; - this.delete = 0; - this.do = 0; - this.else = 0; - this.enum = 0; - this.export = 0; - this.extends = 0; - this.false = 0; - this.finally = 0; - this.for = 0; - this.function = 0; - this.if = 0; - this.import = 0; - this.in = 0; - this.instanceof = 0; - this.new = 0; - this.null = 0; - this.return = 0; - this.super = 0; - this.switch = 0; - this.this = 0; - this.throw = 0; - this.true = 0; - this.try = 0; - this.typeof = 0; - this.var = 0; - this.void = 0; - this.while = 0; - this.with = 0; + this["default"] = 0; + this["delete"] = 0; + this["do"] = 0; + this["else"] = 0; + this["enum"] = 0; + this["export"] = 0; + this["extends"] = 0; + this["false"] = 0; + this["finally"] = 0; + this["for"] = 0; + this["function"] = 0; + this["if"] = 0; + this["import"] = 0; + this["in"] = 0; + this["instanceof"] = 0; + this["new"] = 0; + this["null"] = 0; + this["return"] = 0; + this["super"] = 0; + this["switch"] = 0; + this["this"] = 0; + this["throw"] = 0; + this["true"] = 0; + this["try"] = 0; + this["typeof"] = 0; + this["var"] = 0; + this["void"] = 0; + this["while"] = 0; + this["with"] = 0; } return bigClass; }()); diff --git a/tests/baselines/reference/destructuringParameterDeclaration6.js b/tests/baselines/reference/destructuringParameterDeclaration6.js index ad86b2983b3..03307415b65 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration6.js +++ b/tests/baselines/reference/destructuringParameterDeclaration6.js @@ -27,7 +27,7 @@ b2({ while: 1 }); "use strict"; // Error function a(_a) { - var = _a.while; + var = _a["while"]; } function a1(_a) { var public = _a.public; @@ -56,13 +56,13 @@ function a7() { a[_i - 0] = arguments[_i]; } } -a({ while: 1 }); +a({ "while": 1 }); // No Error function b1(_a) { var x = _a.public; } function b2(_a) { - var y = _a.while; + var y = _a["while"]; } b1({ public: 1 }); -b2({ while: 1 }); +b2({ "while": 1 }); diff --git a/tests/baselines/reference/es6ClassTest5.js b/tests/baselines/reference/es6ClassTest5.js index b909fac58b5..7d4238fda65 100644 --- a/tests/baselines/reference/es6ClassTest5.js +++ b/tests/baselines/reference/es6ClassTest5.js @@ -23,7 +23,7 @@ var C1T5 = (function () { }()); var bigClass = (function () { function bigClass() { - this.break = 1; + this["break"] = 1; } return bigClass; }()); diff --git a/tests/baselines/reference/fatarrowfunctionsErrors.js b/tests/baselines/reference/fatarrowfunctionsErrors.js index 2ac20f1966a..ced4660d8d1 100644 --- a/tests/baselines/reference/fatarrowfunctionsErrors.js +++ b/tests/baselines/reference/fatarrowfunctionsErrors.js @@ -20,7 +20,7 @@ foo(function () { } return 0; }); -foo((1), { return: 0 }); +foo((1), { "return": 0 }); foo(function (x) { return x; }); foo(function (x) { if (x === void 0) { x = 0; } diff --git a/tests/baselines/reference/keywordField.js b/tests/baselines/reference/keywordField.js index 581d5afa14a..a146cffade8 100644 --- a/tests/baselines/reference/keywordField.js +++ b/tests/baselines/reference/keywordField.js @@ -12,7 +12,7 @@ var q = a["if"]; //// [keywordField.js] var obj = {}; -obj.if = 1; -var a = { if: "test" }; -var n = a.if; +obj["if"] = 1; +var a = { "if": "test" }; +var n = a["if"]; var q = a["if"]; diff --git a/tests/baselines/reference/keywordInJsxIdentifier.js b/tests/baselines/reference/keywordInJsxIdentifier.js index 6009e1980e6..d9c3b51e9a3 100644 --- a/tests/baselines/reference/keywordInJsxIdentifier.js +++ b/tests/baselines/reference/keywordInJsxIdentifier.js @@ -9,6 +9,6 @@ declare var React: any; //// [keywordInJsxIdentifier.js] React.createElement("foo", { "class-id": true }); -React.createElement("foo", { class: true }); +React.createElement("foo", { "class": true }); React.createElement("foo", { "class-id": "1" }); -React.createElement("foo", { class: "1" }); +React.createElement("foo", { "class": "1" }); diff --git a/tests/baselines/reference/nestedClassDeclaration.js b/tests/baselines/reference/nestedClassDeclaration.js index 04e2f6348ef..cc300ec75a3 100644 --- a/tests/baselines/reference/nestedClassDeclaration.js +++ b/tests/baselines/reference/nestedClassDeclaration.js @@ -38,5 +38,5 @@ function foo() { }()); } var x = { - class: C4 + "class": C4 }, _a = void 0; diff --git a/tests/baselines/reference/objectBindingPatternKeywordIdentifiers01.js b/tests/baselines/reference/objectBindingPatternKeywordIdentifiers01.js index cd339bb5907..a905e53f221 100644 --- a/tests/baselines/reference/objectBindingPatternKeywordIdentifiers01.js +++ b/tests/baselines/reference/objectBindingPatternKeywordIdentifiers01.js @@ -3,4 +3,4 @@ var { while } = { while: 1 } //// [objectBindingPatternKeywordIdentifiers01.js] -var = { while: 1 }.while; +var = { "while": 1 }["while"]; diff --git a/tests/baselines/reference/objectBindingPatternKeywordIdentifiers02.js b/tests/baselines/reference/objectBindingPatternKeywordIdentifiers02.js index 0286a78ba82..5bc6e1f9963 100644 --- a/tests/baselines/reference/objectBindingPatternKeywordIdentifiers02.js +++ b/tests/baselines/reference/objectBindingPatternKeywordIdentifiers02.js @@ -3,4 +3,4 @@ var { while: while } = { while: 1 } //// [objectBindingPatternKeywordIdentifiers02.js] -var _a = { while: 1 }, = _a.while, = _a.while; +var _a = { "while": 1 }, = _a["while"], = _a["while"]; diff --git a/tests/baselines/reference/objectBindingPatternKeywordIdentifiers03.js b/tests/baselines/reference/objectBindingPatternKeywordIdentifiers03.js index 4bbb1afb4cb..3d8643d63ce 100644 --- a/tests/baselines/reference/objectBindingPatternKeywordIdentifiers03.js +++ b/tests/baselines/reference/objectBindingPatternKeywordIdentifiers03.js @@ -3,4 +3,4 @@ var { "while" } = { while: 1 } //// [objectBindingPatternKeywordIdentifiers03.js] -var = { while: 1 }["while"]; +var = { "while": 1 }["while"]; diff --git a/tests/baselines/reference/objectBindingPatternKeywordIdentifiers04.js b/tests/baselines/reference/objectBindingPatternKeywordIdentifiers04.js index 4e53b13c0a6..de7608a77d2 100644 --- a/tests/baselines/reference/objectBindingPatternKeywordIdentifiers04.js +++ b/tests/baselines/reference/objectBindingPatternKeywordIdentifiers04.js @@ -3,4 +3,4 @@ var { "while": while } = { while: 1 } //// [objectBindingPatternKeywordIdentifiers04.js] -var _a = { while: 1 }, = _a["while"], = _a.while; +var _a = { "while": 1 }, = _a["while"], = _a["while"]; diff --git a/tests/baselines/reference/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.js b/tests/baselines/reference/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.js index b72f0351b9c..7b9c9f5d328 100644 --- a/tests/baselines/reference/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.js +++ b/tests/baselines/reference/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.js @@ -27,15 +27,15 @@ var y = { 42: , get e() { }, set f() { }, - this: , - super: , - var: , - class: , - typeof: + "this": , + "super": , + "var": , + "class": , + "typeof": }; var x = { a: .b, a: ["ss"], a: [1] }; -var v = { class: }; // error +var v = { "class": }; // error diff --git a/tests/baselines/reference/objectTypesIdentityWithConstructSignatures2.js b/tests/baselines/reference/objectTypesIdentityWithConstructSignatures2.js index 315e079d429..0a422dbda6f 100644 --- a/tests/baselines/reference/objectTypesIdentityWithConstructSignatures2.js +++ b/tests/baselines/reference/objectTypesIdentityWithConstructSignatures2.js @@ -91,7 +91,7 @@ var C = (function () { return C; }()); var a; -var b = { new: function (x) { return ''; } }; // not a construct signature, function called new +var b = { "new": function (x) { return ''; } }; // not a construct signature, function called new function foo1b(x) { } function foo1c(x) { } function foo2(x) { } diff --git a/tests/baselines/reference/objectTypesIdentityWithConstructSignaturesDifferingParamCounts.js b/tests/baselines/reference/objectTypesIdentityWithConstructSignaturesDifferingParamCounts.js index a61bedfd52f..5fa148b541d 100644 --- a/tests/baselines/reference/objectTypesIdentityWithConstructSignaturesDifferingParamCounts.js +++ b/tests/baselines/reference/objectTypesIdentityWithConstructSignaturesDifferingParamCounts.js @@ -91,7 +91,7 @@ var C = (function () { return C; }()); var a; -var b = { new: function (x) { return ''; } }; // not a construct signature, function called new +var b = { "new": function (x) { return ''; } }; // not a construct signature, function called new function foo1b(x) { } function foo1c(x) { } function foo2(x) { } diff --git a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByConstraints.js b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByConstraints.js index c15c53b9bf8..6a66e8bbda3 100644 --- a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByConstraints.js +++ b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByConstraints.js @@ -92,7 +92,7 @@ var C = (function () { return C; }()); var a; -var b = { new: function (x) { return ''; } }; // not a construct signature, function called new +var b = { "new": function (x) { return ''; } }; // not a construct signature, function called new function foo1b(x) { } function foo1c(x) { } function foo2(x) { } diff --git a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByConstraints2.js b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByConstraints2.js index f8aff596dc9..e19837a9f7f 100644 --- a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByConstraints2.js +++ b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByConstraints2.js @@ -109,7 +109,7 @@ var D = (function () { return D; }()); var a; -var b = { new: function (x, y) { return ''; } }; // not a construct signature, function called new +var b = { "new": function (x, y) { return ''; } }; // not a construct signature, function called new function foo1b(x) { } function foo1c(x) { } function foo2(x) { } diff --git a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByConstraints3.js b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByConstraints3.js index 141aa86823b..735c5bdc2d6 100644 --- a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByConstraints3.js +++ b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByConstraints3.js @@ -128,7 +128,7 @@ var D = (function () { return D; }()); var a; -var b = { new: function (x, y) { return ''; } }; // not a construct signature, function called new +var b = { "new": function (x, y) { return ''; } }; // not a construct signature, function called new function foo1b(x) { } function foo1c(x) { } function foo2(x) { } diff --git a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByReturnType.js b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByReturnType.js index b651d368f33..6eab84a49dd 100644 --- a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByReturnType.js +++ b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByReturnType.js @@ -99,7 +99,7 @@ var C = (function () { return C; }()); var a; -var b = { new: function (x) { return null; } }; // not a construct signature, function called new +var b = { "new": function (x) { return null; } }; // not a construct signature, function called new function foo1b(x) { } function foo1c(x) { } function foo2(x) { } diff --git a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByReturnType2.js b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByReturnType2.js index ff7095c4ea1..d927a8e082a 100644 --- a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByReturnType2.js +++ b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByReturnType2.js @@ -95,7 +95,7 @@ var C = (function () { return C; }()); var a; -var b = { new: function (x) { return null; } }; // not a construct signature, function called new +var b = { "new": function (x) { return null; } }; // not a construct signature, function called new function foo1b(x) { } function foo1c(x) { } function foo2(x) { } diff --git a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingTypeParameterCounts.js b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingTypeParameterCounts.js index 314eb700c4b..512bebb3b0e 100644 --- a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingTypeParameterCounts.js +++ b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingTypeParameterCounts.js @@ -87,7 +87,7 @@ var C = (function () { return C; }()); var a; -var b = { new: function (x) { return x; } }; +var b = { "new": function (x) { return x; } }; function foo1b(x) { } function foo1c(x) { } function foo2(x) { } diff --git a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingTypeParameterNames.js b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingTypeParameterNames.js index 182cf8263b7..80cfcd23ec9 100644 --- a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingTypeParameterNames.js +++ b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingTypeParameterNames.js @@ -87,7 +87,7 @@ var C = (function () { return C; }()); var a; -var b = { new: function (x) { return new C(x); } }; +var b = { "new": function (x) { return new C(x); } }; function foo1b(x) { } function foo1c(x) { } function foo2(x) { } diff --git a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesOptionalParams.js b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesOptionalParams.js index 5c5dd26c331..87cb0b33531 100644 --- a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesOptionalParams.js +++ b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesOptionalParams.js @@ -91,7 +91,7 @@ var C = (function () { return C; }()); var a; -var b = { new: function (x, y) { return new C(x, y); } }; // not a construct signature, function called new +var b = { "new": function (x, y) { return new C(x, y); } }; // not a construct signature, function called new function foo1b(x) { } function foo1c(x) { } function foo2(x) { } diff --git a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesOptionalParams2.js b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesOptionalParams2.js index 14b2ec3c0ca..6b0e91f817f 100644 --- a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesOptionalParams2.js +++ b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesOptionalParams2.js @@ -91,7 +91,7 @@ var C = (function () { return C; }()); var a; -var b = { new: function (x, y) { return new C(x, y); } }; // not a construct signature, function called new +var b = { "new": function (x, y) { return new C(x, y); } }; // not a construct signature, function called new function foo1b(x) { } function foo1c(x) { } function foo2(x) { } diff --git a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesOptionalParams3.js b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesOptionalParams3.js index ffc238cacae..55f2a0217e9 100644 --- a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesOptionalParams3.js +++ b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesOptionalParams3.js @@ -91,7 +91,7 @@ var C = (function () { return C; }()); var a; -var b = { new: function (x, y) { return new C(x, y); } }; // not a construct signature, function called new +var b = { "new": function (x, y) { return new C(x, y); } }; // not a construct signature, function called new function foo1b(x) { } function foo1c(x) { } function foo2(x) { } diff --git a/tests/baselines/reference/parserErrorRecovery_ObjectLiteral2.js b/tests/baselines/reference/parserErrorRecovery_ObjectLiteral2.js index 6a703759fff..c206a30237a 100644 --- a/tests/baselines/reference/parserErrorRecovery_ObjectLiteral2.js +++ b/tests/baselines/reference/parserErrorRecovery_ObjectLiteral2.js @@ -4,4 +4,4 @@ return; //// [parserErrorRecovery_ObjectLiteral2.js] var v = { a: , - return: }; + "return": }; diff --git a/tests/baselines/reference/parserErrorRecovery_ObjectLiteral3.js b/tests/baselines/reference/parserErrorRecovery_ObjectLiteral3.js index eecf45fea4f..6cee2b42725 100644 --- a/tests/baselines/reference/parserErrorRecovery_ObjectLiteral3.js +++ b/tests/baselines/reference/parserErrorRecovery_ObjectLiteral3.js @@ -4,4 +4,4 @@ return; //// [parserErrorRecovery_ObjectLiteral3.js] var v = { a: , - return: }; + "return": }; diff --git a/tests/baselines/reference/parserErrorRecovery_ObjectLiteral4.js b/tests/baselines/reference/parserErrorRecovery_ObjectLiteral4.js index 87a1a31437e..23d17c8047b 100644 --- a/tests/baselines/reference/parserErrorRecovery_ObjectLiteral4.js +++ b/tests/baselines/reference/parserErrorRecovery_ObjectLiteral4.js @@ -4,4 +4,4 @@ return; //// [parserErrorRecovery_ObjectLiteral4.js] var v = { a: 1, - return: }; + "return": }; diff --git a/tests/baselines/reference/parserErrorRecovery_ObjectLiteral5.js b/tests/baselines/reference/parserErrorRecovery_ObjectLiteral5.js index 97e618946a0..7b83132bf0f 100644 --- a/tests/baselines/reference/parserErrorRecovery_ObjectLiteral5.js +++ b/tests/baselines/reference/parserErrorRecovery_ObjectLiteral5.js @@ -4,4 +4,4 @@ return; //// [parserErrorRecovery_ObjectLiteral5.js] var v = { a: 1, - return: }; + "return": }; diff --git a/tests/baselines/reference/parserExportAsFunctionIdentifier.js b/tests/baselines/reference/parserExportAsFunctionIdentifier.js index 7ed76bb87d9..62429c76855 100644 --- a/tests/baselines/reference/parserExportAsFunctionIdentifier.js +++ b/tests/baselines/reference/parserExportAsFunctionIdentifier.js @@ -9,4 +9,4 @@ var x = f.export(); //// [parserExportAsFunctionIdentifier.js] var f; -var x = f.export(); +var x = f["export"](); diff --git a/tests/baselines/reference/parserKeywordsAsIdentifierName1.js b/tests/baselines/reference/parserKeywordsAsIdentifierName1.js index c0c8c844364..a717abcc08b 100644 --- a/tests/baselines/reference/parserKeywordsAsIdentifierName1.js +++ b/tests/baselines/reference/parserKeywordsAsIdentifierName1.js @@ -8,7 +8,7 @@ var big = { //// [parserKeywordsAsIdentifierName1.js] var big = { - break: 0, - super: 0, - const: 0 + "break": 0, + "super": 0, + "const": 0 }; diff --git a/tests/baselines/reference/parserShorthandPropertyAssignment2.js b/tests/baselines/reference/parserShorthandPropertyAssignment2.js index 0de0fa3829f..95d2f32ffad 100644 --- a/tests/baselines/reference/parserShorthandPropertyAssignment2.js +++ b/tests/baselines/reference/parserShorthandPropertyAssignment2.js @@ -2,4 +2,4 @@ var v = { class }; //// [parserShorthandPropertyAssignment2.js] -var v = { class: }; +var v = { "class": }; diff --git a/tests/baselines/reference/parserSuperExpression3.js b/tests/baselines/reference/parserSuperExpression3.js index f311efcd0f6..064353669c8 100644 --- a/tests/baselines/reference/parserSuperExpression3.js +++ b/tests/baselines/reference/parserSuperExpression3.js @@ -10,7 +10,7 @@ var C = (function () { function C() { } C.prototype.M = function () { - this.super(0); + this["super"](0); }; return C; }()); diff --git a/tests/baselines/reference/prototypeOnConstructorFunctions.js b/tests/baselines/reference/prototypeOnConstructorFunctions.js index d2e5ddde925..de1fec1f7e8 100644 --- a/tests/baselines/reference/prototypeOnConstructorFunctions.js +++ b/tests/baselines/reference/prototypeOnConstructorFunctions.js @@ -12,4 +12,4 @@ i.const.prototype.prop = "yo"; //// [prototypeOnConstructorFunctions.js] var i; -i.const.prototype.prop = "yo"; +i["const"].prototype.prop = "yo"; diff --git a/tests/baselines/reference/reservedWords.js b/tests/baselines/reference/reservedWords.js index 12fbcae0c65..3424c054181 100644 --- a/tests/baselines/reference/reservedWords.js +++ b/tests/baselines/reference/reservedWords.js @@ -19,16 +19,16 @@ var obj2 = { //// [reservedWords.js] var obj = { - if: 0, - debugger: 2, - break: 3, - function: 4 + "if": 0, + "debugger": 2, + "break": 3, + "function": 4 }; //This compiles. var obj2 = { - if: 0, - while: 1, - debugger: 2, - break: 3, - function: 4 + "if": 0, + "while": 1, + "debugger": 2, + "break": 3, + "function": 4 }; diff --git a/tests/baselines/reference/reservedWords2.js b/tests/baselines/reference/reservedWords2.js index a79a0564c78..d9c8105c35f 100644 --- a/tests/baselines/reference/reservedWords2.js +++ b/tests/baselines/reference/reservedWords2.js @@ -27,8 +27,8 @@ function () { } throw function () { }; module; void {}; -var _a = { while: 1, return: 2 }, = _a.while, = _a.return; -var _b = { this: 1, switch: { continue: 2 } }, = _b.this, = _b.switch.continue; +var _a = { "while": 1, "return": 2 }, = _a["while"], = _a["return"]; +var _b = { "this": 1, "switch": { "continue": 2 } }, = _b["this"], = _b["switch"]["continue"]; var _c = void 0; debugger; if () diff --git a/tests/baselines/reference/super1.js b/tests/baselines/reference/super1.js index 9f1289dce55..0094f696faf 100644 --- a/tests/baselines/reference/super1.js +++ b/tests/baselines/reference/super1.js @@ -97,7 +97,7 @@ var SubSub1 = (function (_super) { return _super.apply(this, arguments) || this; } SubSub1.prototype.bar = function () { - return _super.prototype.super.foo; + return _super.prototype["super"].foo; }; return SubSub1; }(Sub1)); diff --git a/tests/baselines/reference/tsxReactEmitNesting.js b/tests/baselines/reference/tsxReactEmitNesting.js index 29e948f687b..eaee315c340 100644 --- a/tests/baselines/reference/tsxReactEmitNesting.js +++ b/tests/baselines/reference/tsxReactEmitNesting.js @@ -38,21 +38,21 @@ let render = (ctrl, model) => //// [file.js] // A simple render function with nesting and control statements var render = function (ctrl, model) { - return vdom.createElement("section", { class: "todoapp" }, - vdom.createElement("header", { class: "header" }, + return vdom.createElement("section", { "class": "todoapp" }, + vdom.createElement("header", { "class": "header" }, vdom.createElement("h1", null, "todos "), - vdom.createElement("input", { class: "new-todo", autofocus: true, autocomplete: "off", placeholder: "What needs to be done?", value: model.newTodo, onKeyup: ctrl.addTodo.bind(ctrl, model) })), - vdom.createElement("section", { class: "main", style: { display: (model.todos && model.todos.length) ? "block" : "none" } }, - vdom.createElement("input", { class: "toggle-all", type: "checkbox", onChange: ctrl.toggleAll.bind(ctrl) }), - vdom.createElement("ul", { class: "todo-list" }, model.filteredTodos.map(function (todo) { - return vdom.createElement("li", { class: { todo: true, completed: todo.completed, editing: todo == model.editedTodo } }, - vdom.createElement("div", { class: "view" }, + vdom.createElement("input", { "class": "new-todo", autofocus: true, autocomplete: "off", placeholder: "What needs to be done?", value: model.newTodo, onKeyup: ctrl.addTodo.bind(ctrl, model) })), + vdom.createElement("section", { "class": "main", style: { display: (model.todos && model.todos.length) ? "block" : "none" } }, + vdom.createElement("input", { "class": "toggle-all", type: "checkbox", onChange: ctrl.toggleAll.bind(ctrl) }), + vdom.createElement("ul", { "class": "todo-list" }, model.filteredTodos.map(function (todo) { + return vdom.createElement("li", { "class": { todo: true, completed: todo.completed, editing: todo == model.editedTodo } }, + vdom.createElement("div", { "class": "view" }, (!todo.editable) ? - vdom.createElement("input", { class: "toggle", type: "checkbox" }) + vdom.createElement("input", { "class": "toggle", type: "checkbox" }) : null, vdom.createElement("label", { onDoubleClick: function () { ctrl.editTodo(todo); } }, todo.title), - vdom.createElement("button", { class: "destroy", onClick: ctrl.removeTodo.bind(ctrl, todo) }), - vdom.createElement("div", { class: "iconBorder" }, - vdom.createElement("div", { class: "icon" })))); + vdom.createElement("button", { "class": "destroy", onClick: ctrl.removeTodo.bind(ctrl, todo) }), + vdom.createElement("div", { "class": "iconBorder" }, + vdom.createElement("div", { "class": "icon" })))); })))); }; diff --git a/tests/baselines/reference/typeQueryWithReservedWords.js b/tests/baselines/reference/typeQueryWithReservedWords.js index 7561eeddb75..09c3b642a36 100644 --- a/tests/baselines/reference/typeQueryWithReservedWords.js +++ b/tests/baselines/reference/typeQueryWithReservedWords.js @@ -21,9 +21,9 @@ var Controller = (function () { } Controller.prototype.create = function () { }; - Controller.prototype.delete = function () { + Controller.prototype["delete"] = function () { }; - Controller.prototype.var = function () { + Controller.prototype["var"] = function () { }; return Controller; }()); From 86784a5eef6c9d4e5fbb68e5c7a1eedfc23ed8a8 Mon Sep 17 00:00:00 2001 From: Andrej Baran Date: Fri, 14 Oct 2016 10:54:54 +0200 Subject: [PATCH 098/173] Get rid of ES6 completely --- src/compiler/commandLineParser.ts | 4 ++-- src/compiler/types.ts | 6 ++---- tests/baselines/reference/APISample_linter.js | 4 ++-- tests/cases/compiler/APISample_linter.ts | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 553efa9e3af..545c7f3e708 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -101,7 +101,7 @@ namespace ts { "amd": ModuleKind.AMD, "system": ModuleKind.System, "umd": ModuleKind.UMD, - "es6": ModuleKind.ES6, + "es6": ModuleKind.ES2015, "es2015": ModuleKind.ES2015, }), description: Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, @@ -261,7 +261,7 @@ namespace ts { type: createMap({ "es3": ScriptTarget.ES3, "es5": ScriptTarget.ES5, - "es6": ScriptTarget.ES6, + "es6": ScriptTarget.ES2015, "es2015": ScriptTarget.ES2015, "es2016": ScriptTarget.ES2016, "es2017": ScriptTarget.ES2017, diff --git a/src/compiler/types.ts b/src/compiler/types.ts index ae9502c21d2..68bda608238 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3019,8 +3019,7 @@ namespace ts { AMD = 2, UMD = 3, System = 4, - ES6 = 5, - ES2015 = ES6, + ES2015 = 5, } export const enum JsxEmit { @@ -3053,8 +3052,7 @@ namespace ts { export const enum ScriptTarget { ES3 = 0, ES5 = 1, - ES6 = 2, - ES2015 = ES6, + ES2015 = 2, ES2016 = 3, ES2017 = 4, Latest = ES2017, diff --git a/tests/baselines/reference/APISample_linter.js b/tests/baselines/reference/APISample_linter.js index 4e563c7cac3..1421b53a00c 100644 --- a/tests/baselines/reference/APISample_linter.js +++ b/tests/baselines/reference/APISample_linter.js @@ -58,7 +58,7 @@ export function delint(sourceFile: ts.SourceFile) { const fileNames: string[] = process.argv.slice(2); fileNames.forEach(fileName => { // Parse a file - let sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true); + let sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES2015, /*setParentNodes */ true); // delint it delint(sourceFile); @@ -113,7 +113,7 @@ exports.delint = delint; var fileNames = process.argv.slice(2); fileNames.forEach(function (fileName) { // Parse a file - var sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true); + var sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES2015, /*setParentNodes */ true); // delint it delint(sourceFile); }); diff --git a/tests/cases/compiler/APISample_linter.ts b/tests/cases/compiler/APISample_linter.ts index 89f0be7a0f5..dc5e2644b4f 100644 --- a/tests/cases/compiler/APISample_linter.ts +++ b/tests/cases/compiler/APISample_linter.ts @@ -61,7 +61,7 @@ export function delint(sourceFile: ts.SourceFile) { const fileNames: string[] = process.argv.slice(2); fileNames.forEach(fileName => { // Parse a file - let sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true); + let sourceFile = ts.createSourceFile(fileName, readFileSync(fileName).toString(), ts.ScriptTarget.ES2015, /*setParentNodes */ true); // delint it delint(sourceFile); From 6417dab60bfb5f3775d82487979d940376b5d24a Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Fri, 14 Oct 2016 08:11:23 -0700 Subject: [PATCH 099/173] Merge pull request #11605 from Microsoft/vladima/convert-enums-to-const convert all enums to const enums when building protocol.d.ts --- .gitignore | 1 + scripts/buildProtocol.ts | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 5e4bc0af5ea..f1ea04e3efb 100644 --- a/.gitignore +++ b/.gitignore @@ -41,6 +41,7 @@ tests/cases/**/*.js.map scripts/debug.bat scripts/run.bat scripts/word2md.js +scripts/buildProtocol.js scripts/ior.js scripts/buildProtocol.js scripts/*.js.map diff --git a/scripts/buildProtocol.ts b/scripts/buildProtocol.ts index 8d49262a470..55ad086815c 100644 --- a/scripts/buildProtocol.ts +++ b/scripts/buildProtocol.ts @@ -42,7 +42,14 @@ class DeclarationsWalker { return; } // splice declaration in final d.ts file - const text = decl.getFullText(); + let text = decl.getFullText(); + if (decl.kind === ts.SyntaxKind.EnumDeclaration && !(decl.flags & ts.NodeFlags.Const)) { + // patch enum declaration to make them constan + const declStart = decl.getStart() - decl.getFullStart(); + const prefix = text.substring(0, declStart); + const suffix = text.substring(declStart + "enum".length, decl.getEnd() - decl.getFullStart()); + text = prefix + "const enum" + suffix; + } this.text += `${text}\n`; // recursively pull all dependencies into result dts file From 4304eab6549720cdca02376d841446372126c038 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Fri, 14 Oct 2016 11:12:47 -0700 Subject: [PATCH 100/173] JSX Text belongs with its other token friends --- src/compiler/types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 638504e613f..138e6097292 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -45,6 +45,7 @@ namespace ts { // Literals NumericLiteral, StringLiteral, + JsxText, RegularExpressionLiteral, NoSubstitutionTemplateLiteral, // Pseudo-literals @@ -302,7 +303,6 @@ namespace ts { JsxElement, JsxSelfClosingElement, JsxOpeningElement, - JsxText, JsxClosingElement, JsxAttribute, JsxSpreadAttribute, From eb4bb4a9e0f7b1e63ac8957239b7d15cfdfd9b6e Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Fri, 14 Oct 2016 12:08:41 -0700 Subject: [PATCH 101/173] Fix-ups around formatting and assertions --- src/services/formatting/formatting.ts | 5 +++-- src/services/formatting/formattingScanner.ts | 4 ++-- src/services/formatting/rulesMap.ts | 2 +- src/services/utilities.ts | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 16108450d2c..2b7d0f8d68c 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -624,10 +624,11 @@ namespace ts.formatting { return inheritedIndentation; } - if (isToken(child)) { + // JSX text shouldn't affect indenting + if (isToken(child) && child.kind !== SyntaxKind.JsxText) { // if child node is a token, it does not impact indentation, proceed it using parent indentation scope rules const tokenInfo = formattingScanner.readTokenInfo(child); - Debug.assert(tokenInfo.token.end === child.end); + Debug.assert(tokenInfo.token.end === child.end, "Token end is child end"); consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } diff --git a/src/services/formatting/formattingScanner.ts b/src/services/formatting/formattingScanner.ts index 7822e4a72fc..2020352f86b 100644 --- a/src/services/formatting/formattingScanner.ts +++ b/src/services/formatting/formattingScanner.ts @@ -31,7 +31,7 @@ namespace ts.formatting { } export function getFormattingScanner(sourceFile: SourceFile, startPos: number, endPos: number): FormattingScanner { - Debug.assert(scanner === undefined); + Debug.assert(scanner === undefined, "Scanner should be undefined"); scanner = sourceFile.languageVariant === LanguageVariant.JSX ? jsxScanner : standardScanner; scanner.setText(sourceFile.text); @@ -62,7 +62,7 @@ namespace ts.formatting { }; function advance(): void { - Debug.assert(scanner !== undefined); + Debug.assert(scanner !== undefined, "Scanner should be present"); lastTokenInfo = undefined; const isStarted = scanner.getStartPos() !== startPos; diff --git a/src/services/formatting/rulesMap.ts b/src/services/formatting/rulesMap.ts index 65c30908863..cd6f2e539d6 100644 --- a/src/services/formatting/rulesMap.ts +++ b/src/services/formatting/rulesMap.ts @@ -35,8 +35,8 @@ namespace ts.formatting { } private GetRuleBucketIndex(row: number, column: number): number { + Debug.assert(row <= SyntaxKind.LastKeyword && column <= SyntaxKind.LastKeyword, "Must compute formatting context from tokens"); const rulesBucketIndex = (row * this.mapRowLength) + column; - // Debug.Assert(rulesBucketIndex < this.map.Length, "Trying to access an index outside the array."); return rulesBucketIndex; } diff --git a/src/services/utilities.ts b/src/services/utilities.ts index b58c4188e0d..936abfbb2ed 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -750,7 +750,7 @@ namespace ts { return find(startNode || sourceFile); function findRightmostToken(n: Node): Node { - if (isToken(n) || n.kind === SyntaxKind.JsxText) { + if (isToken(n)) { return n; } @@ -761,7 +761,7 @@ namespace ts { } function find(n: Node): Node { - if (isToken(n) || n.kind === SyntaxKind.JsxText) { + if (isToken(n)) { return n; } From a69fc67986dc87406ea4ed2f69ea2118a15e75b9 Mon Sep 17 00:00:00 2001 From: Jason Ramsay Date: Fri, 14 Oct 2016 16:04:51 -0700 Subject: [PATCH 102/173] Restrict IsGlobalCompletion to: - SourceFile - Template Expression - Statements --- src/services/completions.ts | 11 ++-- .../completionListIsGlobalCompletion.ts | 51 +++++++++++++------ 2 files changed, 43 insertions(+), 19 deletions(-) diff --git a/src/services/completions.ts b/src/services/completions.ts index c8d7c019e54..cd4d64b3b09 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -1,3 +1,5 @@ +/// + /* @internal */ namespace ts.Completions { export function getCompletionsAtPosition(host: LanguageServiceHost, typeChecker: TypeChecker, log: (message: string) => void, compilerOptions: CompilerOptions, sourceFile: SourceFile, position: number): CompletionInfo { @@ -951,7 +953,6 @@ namespace ts.Completions { if (!tryGetGlobalSymbols()) { return undefined; } - isGlobalCompletion = true; } log("getCompletionData: Semantic work: " + (timestamp() - semanticStart)); @@ -1030,7 +1031,6 @@ namespace ts.Completions { if ((jsxContainer.kind === SyntaxKind.JsxSelfClosingElement) || (jsxContainer.kind === SyntaxKind.JsxOpeningElement)) { // Cursor is inside a JSX self-closing element or opening element attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); - isGlobalCompletion = false; if (attrsType) { symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), (jsxContainer).attributes); @@ -1038,7 +1038,6 @@ namespace ts.Completions { isNewIdentifierLocation = false; return true; } - } } @@ -1079,6 +1078,12 @@ namespace ts.Completions { position; const scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; + if (scopeNode) { + isGlobalCompletion = + scopeNode.kind === SyntaxKind.SourceFile || + scopeNode.kind === SyntaxKind.TemplateExpression || + isStatement(scopeNode); + } /// TODO filter meaning based on the current context const symbolMeanings = SymbolFlags.Type | SymbolFlags.Value | SymbolFlags.Namespace | SymbolFlags.Alias; diff --git a/tests/cases/fourslash/completionListIsGlobalCompletion.ts b/tests/cases/fourslash/completionListIsGlobalCompletion.ts index 73cb6bb2176..3961f4fadae 100644 --- a/tests/cases/fourslash/completionListIsGlobalCompletion.ts +++ b/tests/cases/fourslash/completionListIsGlobalCompletion.ts @@ -1,27 +1,38 @@ /// +// @Filename: file.ts +////export var x = 10; +////export var y = 10; +////export default class C { +////} + +// @Filename: a.ts +////import { /*1*/ } from "./file.ts"; // no globals in imports - export found + //@Filename: file.tsx -/////// // no globals in reference paths -////import { /*2*/ } from "./file.ts"; // no globals in imports -////var test = "/*3*/"; // no globals in strings -/////*4*/class A { // insert globals +/////// // no globals in reference paths +////import { /*3*/ } from "./file1.ts"; // no globals in imports - export not found +////var test = "/*4*/"; // no globals in strings +/////*5*/class A { // insert globals //// foo(): string { return ''; } ////} //// -////class /*5*/B extends A { // no globals after class keyword +////class /*6*/B extends A { // no globals after class keyword //// bar(): string { -//// /*6*/ // insert globals +//// /*7*/ // insert globals //// return ''; //// } ////} //// -////class C { // no globals at beginning of generics +////class C { // no globals at beginning of generics //// x: U; -//// y = this./*8*/x; // no globals inserted for member completions -//// /*9*/ // insert globals +//// y = this./*9*/x; // no globals inserted for member completions +//// /*10*/ // insert globals ////} -/////*10*/ // insert globals -////const y =
; +/////*11*/ // insert globals +////const y =
; // no globals in jsx attribute found +////const z =
; // no globals in jsx attribute with syntax error +////const x = `/*14*/ ${/*15*/}`; // globals only in template expression goTo.marker("1"); verify.completionListIsGlobal(false); goTo.marker("2"); @@ -29,18 +40,26 @@ verify.completionListIsGlobal(false); goTo.marker("3"); verify.completionListIsGlobal(false); goTo.marker("4"); -verify.completionListIsGlobal(true); +verify.completionListIsGlobal(false); goTo.marker("5"); -verify.completionListIsGlobal(false); -goTo.marker("6"); verify.completionListIsGlobal(true); -goTo.marker("7"); +goTo.marker("6"); verify.completionListIsGlobal(false); +goTo.marker("7"); +verify.completionListIsGlobal(true); goTo.marker("8"); verify.completionListIsGlobal(false); goTo.marker("9"); -verify.completionListIsGlobal(true); +verify.completionListIsGlobal(false); goTo.marker("10"); verify.completionListIsGlobal(true); goTo.marker("11"); +verify.completionListIsGlobal(true); +goTo.marker("12"); verify.completionListIsGlobal(false); +goTo.marker("13"); +verify.completionListIsGlobal(false); +goTo.marker("14"); +verify.completionListIsGlobal(false); +goTo.marker("15"); +verify.completionListIsGlobal(true); \ No newline at end of file From 7352e971215a07026c8f7ab7786ed2c9a900e70b Mon Sep 17 00:00:00 2001 From: Andrej Baran Date: Sat, 15 Oct 2016 01:16:11 +0200 Subject: [PATCH 103/173] Cleanup ES2017 async tests --- .../reference/asyncAliasReturnType_es2017.js | 9 --- .../asyncAliasReturnType_es2017.symbols | 11 ---- .../asyncAliasReturnType_es2017.types | 11 ---- .../reference/asyncClass_es2017.errors.txt | 8 --- .../baselines/reference/asyncClass_es2017.js | 7 -- .../asyncConstructor_es2017.errors.txt | 10 --- .../reference/asyncConstructor_es2017.js | 11 ---- .../reference/asyncDeclare_es2017.errors.txt | 7 -- .../reference/asyncDeclare_es2017.js | 4 -- .../reference/asyncEnum_es2017.errors.txt | 9 --- tests/baselines/reference/asyncEnum_es2017.js | 10 --- ...yncFunctionDeclaration15_es2017.errors.txt | 48 -------------- .../asyncFunctionDeclaration15_es2017.js | 64 ------------------- .../reference/asyncGetter_es2017.errors.txt | 13 ---- .../baselines/reference/asyncGetter_es2017.js | 11 ---- .../asyncImportedPromise_es2017.errors.txt | 13 ---- .../reference/asyncImportedPromise_es2017.js | 21 ------ .../asyncInterface_es2017.errors.txt | 8 --- .../reference/asyncInterface_es2017.js | 5 -- .../reference/asyncModule_es2017.errors.txt | 8 --- .../baselines/reference/asyncModule_es2017.js | 5 -- .../reference/asyncMultiFile_es2017.js | 11 ---- .../reference/asyncMultiFile_es2017.symbols | 8 --- .../reference/asyncMultiFile_es2017.types | 8 --- ...asyncQualifiedReturnType_es2017.errors.txt | 13 ---- .../asyncQualifiedReturnType_es2017.js | 18 ------ .../reference/asyncSetter_es2017.errors.txt | 10 --- .../baselines/reference/asyncSetter_es2017.js | 11 ---- .../baselines/reference/awaitUnion_es2017.js | 22 ------- .../reference/awaitUnion_es2017.symbols | 44 ------------- .../reference/awaitUnion_es2017.types | 49 -------------- tests/baselines/reference/es2017basicAsync.js | 4 +- .../reference/es2017basicAsync.symbols | 4 +- .../reference/es2017basicAsync.types | 4 +- tests/cases/compiler/es2017basicAsync.ts | 2 +- .../es2017/asyncAliasReturnType_es2017.ts | 6 -- .../async/es2017/asyncClass_es2017.ts | 4 -- .../async/es2017/asyncConstructor_es2017.ts | 6 -- .../async/es2017/asyncDeclare_es2017.ts | 3 - .../async/es2017/asyncEnum_es2017.ts | 5 -- .../async/es2017/asyncGetter_es2017.ts | 6 -- .../es2017/asyncImportedPromise_es2017.ts | 10 --- .../async/es2017/asyncInterface_es2017.ts | 4 -- .../async/es2017/asyncModule_es2017.ts | 4 -- .../async/es2017/asyncMultiFile_es2017.ts | 5 -- .../es2017/asyncQualifiedReturnType_es2017.ts | 9 --- .../async/es2017/asyncSetter_es2017.ts | 6 -- .../async/es2017/awaitUnion_es2017.ts | 14 ---- .../asyncFunctionDeclaration15_es2017.ts | 25 -------- 49 files changed, 7 insertions(+), 601 deletions(-) delete mode 100644 tests/baselines/reference/asyncAliasReturnType_es2017.js delete mode 100644 tests/baselines/reference/asyncAliasReturnType_es2017.symbols delete mode 100644 tests/baselines/reference/asyncAliasReturnType_es2017.types delete mode 100644 tests/baselines/reference/asyncClass_es2017.errors.txt delete mode 100644 tests/baselines/reference/asyncClass_es2017.js delete mode 100644 tests/baselines/reference/asyncConstructor_es2017.errors.txt delete mode 100644 tests/baselines/reference/asyncConstructor_es2017.js delete mode 100644 tests/baselines/reference/asyncDeclare_es2017.errors.txt delete mode 100644 tests/baselines/reference/asyncDeclare_es2017.js delete mode 100644 tests/baselines/reference/asyncEnum_es2017.errors.txt delete mode 100644 tests/baselines/reference/asyncEnum_es2017.js delete mode 100644 tests/baselines/reference/asyncFunctionDeclaration15_es2017.errors.txt delete mode 100644 tests/baselines/reference/asyncFunctionDeclaration15_es2017.js delete mode 100644 tests/baselines/reference/asyncGetter_es2017.errors.txt delete mode 100644 tests/baselines/reference/asyncGetter_es2017.js delete mode 100644 tests/baselines/reference/asyncImportedPromise_es2017.errors.txt delete mode 100644 tests/baselines/reference/asyncImportedPromise_es2017.js delete mode 100644 tests/baselines/reference/asyncInterface_es2017.errors.txt delete mode 100644 tests/baselines/reference/asyncInterface_es2017.js delete mode 100644 tests/baselines/reference/asyncModule_es2017.errors.txt delete mode 100644 tests/baselines/reference/asyncModule_es2017.js delete mode 100644 tests/baselines/reference/asyncMultiFile_es2017.js delete mode 100644 tests/baselines/reference/asyncMultiFile_es2017.symbols delete mode 100644 tests/baselines/reference/asyncMultiFile_es2017.types delete mode 100644 tests/baselines/reference/asyncQualifiedReturnType_es2017.errors.txt delete mode 100644 tests/baselines/reference/asyncQualifiedReturnType_es2017.js delete mode 100644 tests/baselines/reference/asyncSetter_es2017.errors.txt delete mode 100644 tests/baselines/reference/asyncSetter_es2017.js delete mode 100644 tests/baselines/reference/awaitUnion_es2017.js delete mode 100644 tests/baselines/reference/awaitUnion_es2017.symbols delete mode 100644 tests/baselines/reference/awaitUnion_es2017.types delete mode 100644 tests/cases/conformance/async/es2017/asyncAliasReturnType_es2017.ts delete mode 100644 tests/cases/conformance/async/es2017/asyncClass_es2017.ts delete mode 100644 tests/cases/conformance/async/es2017/asyncConstructor_es2017.ts delete mode 100644 tests/cases/conformance/async/es2017/asyncDeclare_es2017.ts delete mode 100644 tests/cases/conformance/async/es2017/asyncEnum_es2017.ts delete mode 100644 tests/cases/conformance/async/es2017/asyncGetter_es2017.ts delete mode 100644 tests/cases/conformance/async/es2017/asyncImportedPromise_es2017.ts delete mode 100644 tests/cases/conformance/async/es2017/asyncInterface_es2017.ts delete mode 100644 tests/cases/conformance/async/es2017/asyncModule_es2017.ts delete mode 100644 tests/cases/conformance/async/es2017/asyncMultiFile_es2017.ts delete mode 100644 tests/cases/conformance/async/es2017/asyncQualifiedReturnType_es2017.ts delete mode 100644 tests/cases/conformance/async/es2017/asyncSetter_es2017.ts delete mode 100644 tests/cases/conformance/async/es2017/awaitUnion_es2017.ts delete mode 100644 tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts diff --git a/tests/baselines/reference/asyncAliasReturnType_es2017.js b/tests/baselines/reference/asyncAliasReturnType_es2017.js deleted file mode 100644 index f76f2b13b45..00000000000 --- a/tests/baselines/reference/asyncAliasReturnType_es2017.js +++ /dev/null @@ -1,9 +0,0 @@ -//// [asyncAliasReturnType_es2017.ts] -type PromiseAlias = Promise; - -async function f(): PromiseAlias { -} - -//// [asyncAliasReturnType_es2017.js] -async function f() { -} diff --git a/tests/baselines/reference/asyncAliasReturnType_es2017.symbols b/tests/baselines/reference/asyncAliasReturnType_es2017.symbols deleted file mode 100644 index cc4fc5b8096..00000000000 --- a/tests/baselines/reference/asyncAliasReturnType_es2017.symbols +++ /dev/null @@ -1,11 +0,0 @@ -=== tests/cases/conformance/async/es2017/asyncAliasReturnType_es2017.ts === -type PromiseAlias = Promise; ->PromiseAlias : Symbol(PromiseAlias, Decl(asyncAliasReturnType_es2017.ts, 0, 0)) ->T : Symbol(T, Decl(asyncAliasReturnType_es2017.ts, 0, 18)) ->Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->T : Symbol(T, Decl(asyncAliasReturnType_es2017.ts, 0, 18)) - -async function f(): PromiseAlias { ->f : Symbol(f, Decl(asyncAliasReturnType_es2017.ts, 0, 34)) ->PromiseAlias : Symbol(PromiseAlias, Decl(asyncAliasReturnType_es2017.ts, 0, 0)) -} diff --git a/tests/baselines/reference/asyncAliasReturnType_es2017.types b/tests/baselines/reference/asyncAliasReturnType_es2017.types deleted file mode 100644 index 67c521b77fa..00000000000 --- a/tests/baselines/reference/asyncAliasReturnType_es2017.types +++ /dev/null @@ -1,11 +0,0 @@ -=== tests/cases/conformance/async/es2017/asyncAliasReturnType_es2017.ts === -type PromiseAlias = Promise; ->PromiseAlias : Promise ->T : T ->Promise : Promise ->T : T - -async function f(): PromiseAlias { ->f : () => Promise ->PromiseAlias : Promise -} diff --git a/tests/baselines/reference/asyncClass_es2017.errors.txt b/tests/baselines/reference/asyncClass_es2017.errors.txt deleted file mode 100644 index 37612b0b0f2..00000000000 --- a/tests/baselines/reference/asyncClass_es2017.errors.txt +++ /dev/null @@ -1,8 +0,0 @@ -tests/cases/conformance/async/es2017/asyncClass_es2017.ts(1,1): error TS1042: 'async' modifier cannot be used here. - - -==== tests/cases/conformance/async/es2017/asyncClass_es2017.ts (1 errors) ==== - async class C { - ~~~~~ -!!! error TS1042: 'async' modifier cannot be used here. - } \ No newline at end of file diff --git a/tests/baselines/reference/asyncClass_es2017.js b/tests/baselines/reference/asyncClass_es2017.js deleted file mode 100644 index e619bd50b97..00000000000 --- a/tests/baselines/reference/asyncClass_es2017.js +++ /dev/null @@ -1,7 +0,0 @@ -//// [asyncClass_es2017.ts] -async class C { -} - -//// [asyncClass_es2017.js] -async class C { -} diff --git a/tests/baselines/reference/asyncConstructor_es2017.errors.txt b/tests/baselines/reference/asyncConstructor_es2017.errors.txt deleted file mode 100644 index 3b0c1b42fa9..00000000000 --- a/tests/baselines/reference/asyncConstructor_es2017.errors.txt +++ /dev/null @@ -1,10 +0,0 @@ -tests/cases/conformance/async/es2017/asyncConstructor_es2017.ts(2,3): error TS1089: 'async' modifier cannot appear on a constructor declaration. - - -==== tests/cases/conformance/async/es2017/asyncConstructor_es2017.ts (1 errors) ==== - class C { - async constructor() { - ~~~~~ -!!! error TS1089: 'async' modifier cannot appear on a constructor declaration. - } - } \ No newline at end of file diff --git a/tests/baselines/reference/asyncConstructor_es2017.js b/tests/baselines/reference/asyncConstructor_es2017.js deleted file mode 100644 index 7dcd6ec6943..00000000000 --- a/tests/baselines/reference/asyncConstructor_es2017.js +++ /dev/null @@ -1,11 +0,0 @@ -//// [asyncConstructor_es2017.ts] -class C { - async constructor() { - } -} - -//// [asyncConstructor_es2017.js] -class C { - async constructor() { - } -} diff --git a/tests/baselines/reference/asyncDeclare_es2017.errors.txt b/tests/baselines/reference/asyncDeclare_es2017.errors.txt deleted file mode 100644 index bb74a3865d5..00000000000 --- a/tests/baselines/reference/asyncDeclare_es2017.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -tests/cases/conformance/async/es2017/asyncDeclare_es2017.ts(1,9): error TS1040: 'async' modifier cannot be used in an ambient context. - - -==== tests/cases/conformance/async/es2017/asyncDeclare_es2017.ts (1 errors) ==== - declare async function foo(): Promise; - ~~~~~ -!!! error TS1040: 'async' modifier cannot be used in an ambient context. \ No newline at end of file diff --git a/tests/baselines/reference/asyncDeclare_es2017.js b/tests/baselines/reference/asyncDeclare_es2017.js deleted file mode 100644 index 2ff588b2851..00000000000 --- a/tests/baselines/reference/asyncDeclare_es2017.js +++ /dev/null @@ -1,4 +0,0 @@ -//// [asyncDeclare_es2017.ts] -declare async function foo(): Promise; - -//// [asyncDeclare_es2017.js] diff --git a/tests/baselines/reference/asyncEnum_es2017.errors.txt b/tests/baselines/reference/asyncEnum_es2017.errors.txt deleted file mode 100644 index 8e0015d0b24..00000000000 --- a/tests/baselines/reference/asyncEnum_es2017.errors.txt +++ /dev/null @@ -1,9 +0,0 @@ -tests/cases/conformance/async/es2017/asyncEnum_es2017.ts(1,1): error TS1042: 'async' modifier cannot be used here. - - -==== tests/cases/conformance/async/es2017/asyncEnum_es2017.ts (1 errors) ==== - async enum E { - ~~~~~ -!!! error TS1042: 'async' modifier cannot be used here. - Value - } \ No newline at end of file diff --git a/tests/baselines/reference/asyncEnum_es2017.js b/tests/baselines/reference/asyncEnum_es2017.js deleted file mode 100644 index df1f846c2f9..00000000000 --- a/tests/baselines/reference/asyncEnum_es2017.js +++ /dev/null @@ -1,10 +0,0 @@ -//// [asyncEnum_es2017.ts] -async enum E { - Value -} - -//// [asyncEnum_es2017.js] -var E; -(function (E) { - E[E["Value"] = 0] = "Value"; -})(E || (E = {})); diff --git a/tests/baselines/reference/asyncFunctionDeclaration15_es2017.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration15_es2017.errors.txt deleted file mode 100644 index efc1e2440bf..00000000000 --- a/tests/baselines/reference/asyncFunctionDeclaration15_es2017.errors.txt +++ /dev/null @@ -1,48 +0,0 @@ -tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts(6,23): error TS1064: The return type of an async function or method must be the global Promise type. -tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts(7,23): error TS1064: The return type of an async function or method must be the global Promise type. -tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts(8,23): error TS1064: The return type of an async function or method must be the global Promise type. -tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts(9,23): error TS1064: The return type of an async function or method must be the global Promise type. -tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts(10,23): error TS1064: The return type of an async function or method must be the global Promise type. -tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts(17,16): error TS1059: Return expression in async function does not have a valid callable 'then' member. -tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts(23,25): error TS1058: Operand for 'await' does not have a valid callable 'then' member. - - -==== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts (7 errors) ==== - declare class Thenable { then(): void; } - declare let a: any; - declare let obj: { then: string; }; - declare let thenable: Thenable; - async function fn1() { } // valid: Promise - async function fn2(): { } { } // error - ~~~ -!!! error TS1064: The return type of an async function or method must be the global Promise type. - async function fn3(): any { } // error - ~~~ -!!! error TS1064: The return type of an async function or method must be the global Promise type. - async function fn4(): number { } // error - ~~~~~~ -!!! error TS1064: The return type of an async function or method must be the global Promise type. - async function fn5(): PromiseLike { } // error - ~~~~~~~~~~~~~~~~~ -!!! error TS1064: The return type of an async function or method must be the global Promise type. - async function fn6(): Thenable { } // error - ~~~~~~~~ -!!! error TS1064: The return type of an async function or method must be the global Promise type. - async function fn7() { return; } // valid: Promise - async function fn8() { return 1; } // valid: Promise - async function fn9() { return null; } // valid: Promise - async function fn10() { return undefined; } // valid: Promise - async function fn11() { return a; } // valid: Promise - async function fn12() { return obj; } // valid: Promise<{ then: string; }> - async function fn13() { return thenable; } // error - ~~~~ -!!! error TS1059: Return expression in async function does not have a valid callable 'then' member. - async function fn14() { await 1; } // valid: Promise - async function fn15() { await null; } // valid: Promise - async function fn16() { await undefined; } // valid: Promise - async function fn17() { await a; } // valid: Promise - async function fn18() { await obj; } // valid: Promise - async function fn19() { await thenable; } // error - ~~~~~~~~~~~~~~ -!!! error TS1058: Operand for 'await' does not have a valid callable 'then' member. - \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration15_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration15_es2017.js deleted file mode 100644 index 5704366025e..00000000000 --- a/tests/baselines/reference/asyncFunctionDeclaration15_es2017.js +++ /dev/null @@ -1,64 +0,0 @@ -//// [asyncFunctionDeclaration15_es2017.ts] -declare class Thenable { then(): void; } -declare let a: any; -declare let obj: { then: string; }; -declare let thenable: Thenable; -async function fn1() { } // valid: Promise -async function fn2(): { } { } // error -async function fn3(): any { } // error -async function fn4(): number { } // error -async function fn5(): PromiseLike { } // error -async function fn6(): Thenable { } // error -async function fn7() { return; } // valid: Promise -async function fn8() { return 1; } // valid: Promise -async function fn9() { return null; } // valid: Promise -async function fn10() { return undefined; } // valid: Promise -async function fn11() { return a; } // valid: Promise -async function fn12() { return obj; } // valid: Promise<{ then: string; }> -async function fn13() { return thenable; } // error -async function fn14() { await 1; } // valid: Promise -async function fn15() { await null; } // valid: Promise -async function fn16() { await undefined; } // valid: Promise -async function fn17() { await a; } // valid: Promise -async function fn18() { await obj; } // valid: Promise -async function fn19() { await thenable; } // error - - -//// [asyncFunctionDeclaration15_es2017.js] -async function fn1() { } // valid: Promise -// valid: Promise -async function fn2() { } // error -// error -async function fn3() { } // error -// error -async function fn4() { } // error -// error -async function fn5() { } // error -// error -async function fn6() { } // error -// error -async function fn7() { return; } // valid: Promise -// valid: Promise -async function fn8() { return 1; } // valid: Promise -// valid: Promise -async function fn9() { return null; } // valid: Promise -// valid: Promise -async function fn10() { return undefined; } // valid: Promise -// valid: Promise -async function fn11() { return a; } // valid: Promise -// valid: Promise -async function fn12() { return obj; } // valid: Promise<{ then: string; }> -// valid: Promise<{ then: string; }> -async function fn13() { return thenable; } // error -// error -async function fn14() { await 1; } // valid: Promise -// valid: Promise -async function fn15() { await null; } // valid: Promise -// valid: Promise -async function fn16() { await undefined; } // valid: Promise -// valid: Promise -async function fn17() { await a; } // valid: Promise -// valid: Promise -async function fn18() { await obj; } // valid: Promise -// valid: Promise -async function fn19() { await thenable; } // error diff --git a/tests/baselines/reference/asyncGetter_es2017.errors.txt b/tests/baselines/reference/asyncGetter_es2017.errors.txt deleted file mode 100644 index 386e95d5977..00000000000 --- a/tests/baselines/reference/asyncGetter_es2017.errors.txt +++ /dev/null @@ -1,13 +0,0 @@ -tests/cases/conformance/async/es2017/asyncGetter_es2017.ts(2,3): error TS1042: 'async' modifier cannot be used here. -tests/cases/conformance/async/es2017/asyncGetter_es2017.ts(2,13): error TS2378: A 'get' accessor must return a value. - - -==== tests/cases/conformance/async/es2017/asyncGetter_es2017.ts (2 errors) ==== - class C { - async get foo() { - ~~~~~ -!!! error TS1042: 'async' modifier cannot be used here. - ~~~ -!!! error TS2378: A 'get' accessor must return a value. - } - } \ No newline at end of file diff --git a/tests/baselines/reference/asyncGetter_es2017.js b/tests/baselines/reference/asyncGetter_es2017.js deleted file mode 100644 index ad8fa347cb5..00000000000 --- a/tests/baselines/reference/asyncGetter_es2017.js +++ /dev/null @@ -1,11 +0,0 @@ -//// [asyncGetter_es2017.ts] -class C { - async get foo() { - } -} - -//// [asyncGetter_es2017.js] -class C { - async get foo() { - } -} diff --git a/tests/baselines/reference/asyncImportedPromise_es2017.errors.txt b/tests/baselines/reference/asyncImportedPromise_es2017.errors.txt deleted file mode 100644 index a0348b2e691..00000000000 --- a/tests/baselines/reference/asyncImportedPromise_es2017.errors.txt +++ /dev/null @@ -1,13 +0,0 @@ -tests/cases/conformance/async/es2017/test.ts(3,25): error TS1064: The return type of an async function or method must be the global Promise type. - - -==== tests/cases/conformance/async/es2017/task.ts (0 errors) ==== - export class Task extends Promise { } - -==== tests/cases/conformance/async/es2017/test.ts (1 errors) ==== - import { Task } from "./task"; - class Test { - async example(): Task { return; } - ~~~~~~~ -!!! error TS1064: The return type of an async function or method must be the global Promise type. - } \ No newline at end of file diff --git a/tests/baselines/reference/asyncImportedPromise_es2017.js b/tests/baselines/reference/asyncImportedPromise_es2017.js deleted file mode 100644 index a48c58c1707..00000000000 --- a/tests/baselines/reference/asyncImportedPromise_es2017.js +++ /dev/null @@ -1,21 +0,0 @@ -//// [tests/cases/conformance/async/es2017/asyncImportedPromise_es2017.ts] //// - -//// [task.ts] -export class Task extends Promise { } - -//// [test.ts] -import { Task } from "./task"; -class Test { - async example(): Task { return; } -} - -//// [task.js] -"use strict"; -class Task extends Promise { -} -exports.Task = Task; -//// [test.js] -"use strict"; -class Test { - async example() { return; } -} diff --git a/tests/baselines/reference/asyncInterface_es2017.errors.txt b/tests/baselines/reference/asyncInterface_es2017.errors.txt deleted file mode 100644 index dfbc8789797..00000000000 --- a/tests/baselines/reference/asyncInterface_es2017.errors.txt +++ /dev/null @@ -1,8 +0,0 @@ -tests/cases/conformance/async/es2017/asyncInterface_es2017.ts(1,1): error TS1042: 'async' modifier cannot be used here. - - -==== tests/cases/conformance/async/es2017/asyncInterface_es2017.ts (1 errors) ==== - async interface I { - ~~~~~ -!!! error TS1042: 'async' modifier cannot be used here. - } \ No newline at end of file diff --git a/tests/baselines/reference/asyncInterface_es2017.js b/tests/baselines/reference/asyncInterface_es2017.js deleted file mode 100644 index 4d897389538..00000000000 --- a/tests/baselines/reference/asyncInterface_es2017.js +++ /dev/null @@ -1,5 +0,0 @@ -//// [asyncInterface_es2017.ts] -async interface I { -} - -//// [asyncInterface_es2017.js] diff --git a/tests/baselines/reference/asyncModule_es2017.errors.txt b/tests/baselines/reference/asyncModule_es2017.errors.txt deleted file mode 100644 index 8b6a4c3dc66..00000000000 --- a/tests/baselines/reference/asyncModule_es2017.errors.txt +++ /dev/null @@ -1,8 +0,0 @@ -tests/cases/conformance/async/es2017/asyncModule_es2017.ts(1,1): error TS1042: 'async' modifier cannot be used here. - - -==== tests/cases/conformance/async/es2017/asyncModule_es2017.ts (1 errors) ==== - async module M { - ~~~~~ -!!! error TS1042: 'async' modifier cannot be used here. - } \ No newline at end of file diff --git a/tests/baselines/reference/asyncModule_es2017.js b/tests/baselines/reference/asyncModule_es2017.js deleted file mode 100644 index fe3e17d5e74..00000000000 --- a/tests/baselines/reference/asyncModule_es2017.js +++ /dev/null @@ -1,5 +0,0 @@ -//// [asyncModule_es2017.ts] -async module M { -} - -//// [asyncModule_es2017.js] diff --git a/tests/baselines/reference/asyncMultiFile_es2017.js b/tests/baselines/reference/asyncMultiFile_es2017.js deleted file mode 100644 index 804a58e4b4c..00000000000 --- a/tests/baselines/reference/asyncMultiFile_es2017.js +++ /dev/null @@ -1,11 +0,0 @@ -//// [tests/cases/conformance/async/es2017/asyncMultiFile_es2017.ts] //// - -//// [a.ts] -async function f() {} -//// [b.ts] -function g() { } - -//// [a.js] -async function f() { } -//// [b.js] -function g() { } diff --git a/tests/baselines/reference/asyncMultiFile_es2017.symbols b/tests/baselines/reference/asyncMultiFile_es2017.symbols deleted file mode 100644 index 9d8ff6dbe85..00000000000 --- a/tests/baselines/reference/asyncMultiFile_es2017.symbols +++ /dev/null @@ -1,8 +0,0 @@ -=== tests/cases/conformance/async/es2017/a.ts === -async function f() {} ->f : Symbol(f, Decl(a.ts, 0, 0)) - -=== tests/cases/conformance/async/es2017/b.ts === -function g() { } ->g : Symbol(g, Decl(b.ts, 0, 0)) - diff --git a/tests/baselines/reference/asyncMultiFile_es2017.types b/tests/baselines/reference/asyncMultiFile_es2017.types deleted file mode 100644 index e1f8da34c94..00000000000 --- a/tests/baselines/reference/asyncMultiFile_es2017.types +++ /dev/null @@ -1,8 +0,0 @@ -=== tests/cases/conformance/async/es2017/a.ts === -async function f() {} ->f : () => Promise - -=== tests/cases/conformance/async/es2017/b.ts === -function g() { } ->g : () => void - diff --git a/tests/baselines/reference/asyncQualifiedReturnType_es2017.errors.txt b/tests/baselines/reference/asyncQualifiedReturnType_es2017.errors.txt deleted file mode 100644 index b9027c36539..00000000000 --- a/tests/baselines/reference/asyncQualifiedReturnType_es2017.errors.txt +++ /dev/null @@ -1,13 +0,0 @@ -tests/cases/conformance/async/es2017/asyncQualifiedReturnType_es2017.ts(6,21): error TS1064: The return type of an async function or method must be the global Promise type. - - -==== tests/cases/conformance/async/es2017/asyncQualifiedReturnType_es2017.ts (1 errors) ==== - namespace X { - export class MyPromise extends Promise { - } - } - - async function f(): X.MyPromise { - ~~~~~~~~~~~~~~~~~ -!!! error TS1064: The return type of an async function or method must be the global Promise type. - } \ No newline at end of file diff --git a/tests/baselines/reference/asyncQualifiedReturnType_es2017.js b/tests/baselines/reference/asyncQualifiedReturnType_es2017.js deleted file mode 100644 index 164a4fef610..00000000000 --- a/tests/baselines/reference/asyncQualifiedReturnType_es2017.js +++ /dev/null @@ -1,18 +0,0 @@ -//// [asyncQualifiedReturnType_es2017.ts] -namespace X { - export class MyPromise extends Promise { - } -} - -async function f(): X.MyPromise { -} - -//// [asyncQualifiedReturnType_es2017.js] -var X; -(function (X) { - class MyPromise extends Promise { - } - X.MyPromise = MyPromise; -})(X || (X = {})); -async function f() { -} diff --git a/tests/baselines/reference/asyncSetter_es2017.errors.txt b/tests/baselines/reference/asyncSetter_es2017.errors.txt deleted file mode 100644 index 0acd8538f20..00000000000 --- a/tests/baselines/reference/asyncSetter_es2017.errors.txt +++ /dev/null @@ -1,10 +0,0 @@ -tests/cases/conformance/async/es2017/asyncSetter_es2017.ts(2,3): error TS1042: 'async' modifier cannot be used here. - - -==== tests/cases/conformance/async/es2017/asyncSetter_es2017.ts (1 errors) ==== - class C { - async set foo(value) { - ~~~~~ -!!! error TS1042: 'async' modifier cannot be used here. - } - } \ No newline at end of file diff --git a/tests/baselines/reference/asyncSetter_es2017.js b/tests/baselines/reference/asyncSetter_es2017.js deleted file mode 100644 index 8260c5232a2..00000000000 --- a/tests/baselines/reference/asyncSetter_es2017.js +++ /dev/null @@ -1,11 +0,0 @@ -//// [asyncSetter_es2017.ts] -class C { - async set foo(value) { - } -} - -//// [asyncSetter_es2017.js] -class C { - async set foo(value) { - } -} diff --git a/tests/baselines/reference/awaitUnion_es2017.js b/tests/baselines/reference/awaitUnion_es2017.js deleted file mode 100644 index 12f8b95a652..00000000000 --- a/tests/baselines/reference/awaitUnion_es2017.js +++ /dev/null @@ -1,22 +0,0 @@ -//// [awaitUnion_es2017.ts] -declare let a: number | string; -declare let b: PromiseLike | PromiseLike; -declare let c: PromiseLike; -declare let d: number | PromiseLike; -declare let e: number | PromiseLike; -async function f() { - let await_a = await a; - let await_b = await b; - let await_c = await c; - let await_d = await d; - let await_e = await e; -} - -//// [awaitUnion_es2017.js] -async function f() { - let await_a = await a; - let await_b = await b; - let await_c = await c; - let await_d = await d; - let await_e = await e; -} diff --git a/tests/baselines/reference/awaitUnion_es2017.symbols b/tests/baselines/reference/awaitUnion_es2017.symbols deleted file mode 100644 index e70abce4f0b..00000000000 --- a/tests/baselines/reference/awaitUnion_es2017.symbols +++ /dev/null @@ -1,44 +0,0 @@ -=== tests/cases/conformance/async/es2017/awaitUnion_es2017.ts === -declare let a: number | string; ->a : Symbol(a, Decl(awaitUnion_es2017.ts, 0, 11)) - -declare let b: PromiseLike | PromiseLike; ->b : Symbol(b, Decl(awaitUnion_es2017.ts, 1, 11)) ->PromiseLike : Symbol(PromiseLike, Decl(lib.es5.d.ts, --, --)) ->PromiseLike : Symbol(PromiseLike, Decl(lib.es5.d.ts, --, --)) - -declare let c: PromiseLike; ->c : Symbol(c, Decl(awaitUnion_es2017.ts, 2, 11)) ->PromiseLike : Symbol(PromiseLike, Decl(lib.es5.d.ts, --, --)) - -declare let d: number | PromiseLike; ->d : Symbol(d, Decl(awaitUnion_es2017.ts, 3, 11)) ->PromiseLike : Symbol(PromiseLike, Decl(lib.es5.d.ts, --, --)) - -declare let e: number | PromiseLike; ->e : Symbol(e, Decl(awaitUnion_es2017.ts, 4, 11)) ->PromiseLike : Symbol(PromiseLike, Decl(lib.es5.d.ts, --, --)) - -async function f() { ->f : Symbol(f, Decl(awaitUnion_es2017.ts, 4, 53)) - - let await_a = await a; ->await_a : Symbol(await_a, Decl(awaitUnion_es2017.ts, 6, 4)) ->a : Symbol(a, Decl(awaitUnion_es2017.ts, 0, 11)) - - let await_b = await b; ->await_b : Symbol(await_b, Decl(awaitUnion_es2017.ts, 7, 4)) ->b : Symbol(b, Decl(awaitUnion_es2017.ts, 1, 11)) - - let await_c = await c; ->await_c : Symbol(await_c, Decl(awaitUnion_es2017.ts, 8, 4)) ->c : Symbol(c, Decl(awaitUnion_es2017.ts, 2, 11)) - - let await_d = await d; ->await_d : Symbol(await_d, Decl(awaitUnion_es2017.ts, 9, 4)) ->d : Symbol(d, Decl(awaitUnion_es2017.ts, 3, 11)) - - let await_e = await e; ->await_e : Symbol(await_e, Decl(awaitUnion_es2017.ts, 10, 4)) ->e : Symbol(e, Decl(awaitUnion_es2017.ts, 4, 11)) -} diff --git a/tests/baselines/reference/awaitUnion_es2017.types b/tests/baselines/reference/awaitUnion_es2017.types deleted file mode 100644 index 58f8a4ec4b4..00000000000 --- a/tests/baselines/reference/awaitUnion_es2017.types +++ /dev/null @@ -1,49 +0,0 @@ -=== tests/cases/conformance/async/es2017/awaitUnion_es2017.ts === -declare let a: number | string; ->a : string | number - -declare let b: PromiseLike | PromiseLike; ->b : PromiseLike | PromiseLike ->PromiseLike : PromiseLike ->PromiseLike : PromiseLike - -declare let c: PromiseLike; ->c : PromiseLike ->PromiseLike : PromiseLike - -declare let d: number | PromiseLike; ->d : number | PromiseLike ->PromiseLike : PromiseLike - -declare let e: number | PromiseLike; ->e : number | PromiseLike ->PromiseLike : PromiseLike - -async function f() { ->f : () => Promise - - let await_a = await a; ->await_a : string | number ->await a : string | number ->a : string | number - - let await_b = await b; ->await_b : string | number ->await b : string | number ->b : PromiseLike | PromiseLike - - let await_c = await c; ->await_c : string | number ->await c : string | number ->c : PromiseLike - - let await_d = await d; ->await_d : string | number ->await d : string | number ->d : number | PromiseLike - - let await_e = await e; ->await_e : string | number ->await e : string | number ->e : number | PromiseLike -} diff --git a/tests/baselines/reference/es2017basicAsync.js b/tests/baselines/reference/es2017basicAsync.js index b19eaa4b0ba..d0443c1899c 100644 --- a/tests/baselines/reference/es2017basicAsync.js +++ b/tests/baselines/reference/es2017basicAsync.js @@ -8,7 +8,7 @@ async function asyncFunc() { await 0; } -const asycnArrowFunc = async (): Promise => { +const asyncArrowFunc = async (): Promise => { await 0; } @@ -54,7 +54,7 @@ async () => { async function asyncFunc() { await 0; } -const asycnArrowFunc = async () => { +const asyncArrowFunc = async () => { await 0; }; async function asyncIIFE() { diff --git a/tests/baselines/reference/es2017basicAsync.symbols b/tests/baselines/reference/es2017basicAsync.symbols index 75f4d2cfa76..d79faf1502a 100644 --- a/tests/baselines/reference/es2017basicAsync.symbols +++ b/tests/baselines/reference/es2017basicAsync.symbols @@ -12,8 +12,8 @@ async function asyncFunc() { await 0; } -const asycnArrowFunc = async (): Promise => { ->asycnArrowFunc : Symbol(asycnArrowFunc, Decl(es2017basicAsync.ts, 9, 5)) +const asyncArrowFunc = async (): Promise => { +>asyncArrowFunc : Symbol(asyncArrowFunc, Decl(es2017basicAsync.ts, 9, 5)) >Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) await 0; diff --git a/tests/baselines/reference/es2017basicAsync.types b/tests/baselines/reference/es2017basicAsync.types index 71c2dbe50f3..30d19cb4dfe 100644 --- a/tests/baselines/reference/es2017basicAsync.types +++ b/tests/baselines/reference/es2017basicAsync.types @@ -17,8 +17,8 @@ async function asyncFunc() { >0 : 0 } -const asycnArrowFunc = async (): Promise => { ->asycnArrowFunc : () => Promise +const asyncArrowFunc = async (): Promise => { +>asyncArrowFunc : () => Promise >async (): Promise => { await 0;} : () => Promise >Promise : Promise diff --git a/tests/cases/compiler/es2017basicAsync.ts b/tests/cases/compiler/es2017basicAsync.ts index b13a5d29bc0..b08ee6a18ae 100644 --- a/tests/cases/compiler/es2017basicAsync.ts +++ b/tests/cases/compiler/es2017basicAsync.ts @@ -10,7 +10,7 @@ async function asyncFunc() { await 0; } -const asycnArrowFunc = async (): Promise => { +const asyncArrowFunc = async (): Promise => { await 0; } diff --git a/tests/cases/conformance/async/es2017/asyncAliasReturnType_es2017.ts b/tests/cases/conformance/async/es2017/asyncAliasReturnType_es2017.ts deleted file mode 100644 index 87bbc42e166..00000000000 --- a/tests/cases/conformance/async/es2017/asyncAliasReturnType_es2017.ts +++ /dev/null @@ -1,6 +0,0 @@ -// @target: es2017 -// @noEmitHelpers: true -type PromiseAlias = Promise; - -async function f(): PromiseAlias { -} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncClass_es2017.ts b/tests/cases/conformance/async/es2017/asyncClass_es2017.ts deleted file mode 100644 index 78746c972d0..00000000000 --- a/tests/cases/conformance/async/es2017/asyncClass_es2017.ts +++ /dev/null @@ -1,4 +0,0 @@ -// @target: es2017 -// @noEmitHelpers: true -async class C { -} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncConstructor_es2017.ts b/tests/cases/conformance/async/es2017/asyncConstructor_es2017.ts deleted file mode 100644 index 874c0b99239..00000000000 --- a/tests/cases/conformance/async/es2017/asyncConstructor_es2017.ts +++ /dev/null @@ -1,6 +0,0 @@ -// @target: es2017 -// @noEmitHelpers: true -class C { - async constructor() { - } -} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncDeclare_es2017.ts b/tests/cases/conformance/async/es2017/asyncDeclare_es2017.ts deleted file mode 100644 index d7fd4888fed..00000000000 --- a/tests/cases/conformance/async/es2017/asyncDeclare_es2017.ts +++ /dev/null @@ -1,3 +0,0 @@ -// @target: es2017 -// @noEmitHelpers: true -declare async function foo(): Promise; \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncEnum_es2017.ts b/tests/cases/conformance/async/es2017/asyncEnum_es2017.ts deleted file mode 100644 index dc995206e84..00000000000 --- a/tests/cases/conformance/async/es2017/asyncEnum_es2017.ts +++ /dev/null @@ -1,5 +0,0 @@ -// @target: es2017 -// @noEmitHelpers: true -async enum E { - Value -} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncGetter_es2017.ts b/tests/cases/conformance/async/es2017/asyncGetter_es2017.ts deleted file mode 100644 index 340c33138cf..00000000000 --- a/tests/cases/conformance/async/es2017/asyncGetter_es2017.ts +++ /dev/null @@ -1,6 +0,0 @@ -// @target: es2017 -// @noEmitHelpers: true -class C { - async get foo() { - } -} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncImportedPromise_es2017.ts b/tests/cases/conformance/async/es2017/asyncImportedPromise_es2017.ts deleted file mode 100644 index 81f5b690edd..00000000000 --- a/tests/cases/conformance/async/es2017/asyncImportedPromise_es2017.ts +++ /dev/null @@ -1,10 +0,0 @@ -// @target: es2017 -// @module: commonjs -// @filename: task.ts -export class Task extends Promise { } - -// @filename: test.ts -import { Task } from "./task"; -class Test { - async example(): Task { return; } -} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncInterface_es2017.ts b/tests/cases/conformance/async/es2017/asyncInterface_es2017.ts deleted file mode 100644 index 252730f9ff6..00000000000 --- a/tests/cases/conformance/async/es2017/asyncInterface_es2017.ts +++ /dev/null @@ -1,4 +0,0 @@ -// @target: es2017 -// @noEmitHelpers: true -async interface I { -} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncModule_es2017.ts b/tests/cases/conformance/async/es2017/asyncModule_es2017.ts deleted file mode 100644 index 7c577e27fb9..00000000000 --- a/tests/cases/conformance/async/es2017/asyncModule_es2017.ts +++ /dev/null @@ -1,4 +0,0 @@ -// @target: es2017 -// @noEmitHelpers: true -async module M { -} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncMultiFile_es2017.ts b/tests/cases/conformance/async/es2017/asyncMultiFile_es2017.ts deleted file mode 100644 index 920bdfb8bda..00000000000 --- a/tests/cases/conformance/async/es2017/asyncMultiFile_es2017.ts +++ /dev/null @@ -1,5 +0,0 @@ -// @target: es2017 -// @filename: a.ts -async function f() {} -// @filename: b.ts -function g() { } \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncQualifiedReturnType_es2017.ts b/tests/cases/conformance/async/es2017/asyncQualifiedReturnType_es2017.ts deleted file mode 100644 index 95695168cea..00000000000 --- a/tests/cases/conformance/async/es2017/asyncQualifiedReturnType_es2017.ts +++ /dev/null @@ -1,9 +0,0 @@ -// @target: es2017 -// @noEmitHelpers: true -namespace X { - export class MyPromise extends Promise { - } -} - -async function f(): X.MyPromise { -} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/asyncSetter_es2017.ts b/tests/cases/conformance/async/es2017/asyncSetter_es2017.ts deleted file mode 100644 index 658c07d42e8..00000000000 --- a/tests/cases/conformance/async/es2017/asyncSetter_es2017.ts +++ /dev/null @@ -1,6 +0,0 @@ -// @target: es2017 -// @noEmitHelpers: true -class C { - async set foo(value) { - } -} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/awaitUnion_es2017.ts b/tests/cases/conformance/async/es2017/awaitUnion_es2017.ts deleted file mode 100644 index 493aa838ffe..00000000000 --- a/tests/cases/conformance/async/es2017/awaitUnion_es2017.ts +++ /dev/null @@ -1,14 +0,0 @@ -// @target: es2017 -// @noEmitHelpers: true -declare let a: number | string; -declare let b: PromiseLike | PromiseLike; -declare let c: PromiseLike; -declare let d: number | PromiseLike; -declare let e: number | PromiseLike; -async function f() { - let await_a = await a; - let await_b = await b; - let await_c = await c; - let await_d = await d; - let await_e = await e; -} \ No newline at end of file diff --git a/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts b/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts deleted file mode 100644 index 2585dc666f4..00000000000 --- a/tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration15_es2017.ts +++ /dev/null @@ -1,25 +0,0 @@ -// @target: es2017 -// @noEmitHelpers: true -declare class Thenable { then(): void; } -declare let a: any; -declare let obj: { then: string; }; -declare let thenable: Thenable; -async function fn1() { } // valid: Promise -async function fn2(): { } { } // error -async function fn3(): any { } // error -async function fn4(): number { } // error -async function fn5(): PromiseLike { } // error -async function fn6(): Thenable { } // error -async function fn7() { return; } // valid: Promise -async function fn8() { return 1; } // valid: Promise -async function fn9() { return null; } // valid: Promise -async function fn10() { return undefined; } // valid: Promise -async function fn11() { return a; } // valid: Promise -async function fn12() { return obj; } // valid: Promise<{ then: string; }> -async function fn13() { return thenable; } // error -async function fn14() { await 1; } // valid: Promise -async function fn15() { await null; } // valid: Promise -async function fn16() { await undefined; } // valid: Promise -async function fn17() { await a; } // valid: Promise -async function fn18() { await obj; } // valid: Promise -async function fn19() { await thenable; } // error From 980a8947875fdf78231ea546767dee47393fabfa Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Fri, 14 Oct 2016 18:10:34 -0700 Subject: [PATCH 104/173] Fix emit issue regarding null/undefined in type annotations --- src/compiler/binder.ts | 113 +++++++++++------- src/compiler/emitter.ts | 19 ++- src/compiler/transformers/es6.ts | 2 + src/compiler/transformers/ts.ts | 46 ++++++- src/compiler/types.ts | 2 + .../reference/constructorArgsErrors1.js | 2 +- .../reference/constructorArgsErrors5.js | 2 +- .../parserErrorRecovery_ParameterList6.js | 1 - .../transformsElideNullUndefinedType.js | 54 +++++++++ .../transformsElideNullUndefinedType.symbols | 72 +++++++++++ .../transformsElideNullUndefinedType.types | 94 +++++++++++++++ .../reference/typeGuardFunctionErrors.js | 2 - .../transformsElideNullUndefinedType.ts | 32 +++++ 13 files changed, 392 insertions(+), 49 deletions(-) create mode 100644 tests/baselines/reference/transformsElideNullUndefinedType.js create mode 100644 tests/baselines/reference/transformsElideNullUndefinedType.symbols create mode 100644 tests/baselines/reference/transformsElideNullUndefinedType.types create mode 100644 tests/cases/compiler/transformsElideNullUndefinedType.ts diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index b9e26e4f38d..4f01607289d 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -2330,6 +2330,9 @@ namespace ts { case SyntaxKind.CallExpression: return computeCallExpression(node, subtreeFlags); + case SyntaxKind.NewExpression: + return computeNewExpression(node, subtreeFlags); + case SyntaxKind.ModuleDeclaration: return computeModuleDeclaration(node, subtreeFlags); @@ -2407,6 +2410,10 @@ namespace ts { const expression = node.expression; const expressionKind = expression.kind; + if (node.typeArguments) { + transformFlags |= TransformFlags.AssertTypeScript; + } + if (subtreeFlags & TransformFlags.ContainsSpreadElementExpression || isSuperOrSuperProperty(expression, expressionKind)) { // If the this node contains a SpreadElementExpression, or is a super call, then it is an ES6 @@ -2433,6 +2440,21 @@ namespace ts { return false; } + function computeNewExpression(node: NewExpression, subtreeFlags: TransformFlags) { + let transformFlags = subtreeFlags; + if (node.typeArguments) { + transformFlags |= TransformFlags.AssertTypeScript; + } + if (subtreeFlags & TransformFlags.ContainsSpreadElementExpression) { + // If the this node contains a SpreadElementExpression then it is an ES6 + // node. + transformFlags |= TransformFlags.AssertES6; + } + node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; + return transformFlags & ~TransformFlags.ArrayLiteralOrCallOrNewExcludes; + } + + function computeBinaryExpression(node: BinaryExpression, subtreeFlags: TransformFlags) { let transformFlags = subtreeFlags; const operatorTokenKind = node.operatorToken.kind; @@ -2461,13 +2483,12 @@ namespace ts { const initializer = node.initializer; const dotDotDotToken = node.dotDotDotToken; - // If the parameter has a question token, then it is TypeScript syntax. - if (node.questionToken) { - transformFlags |= TransformFlags.AssertTypeScript; - } - - // If the parameter's name is 'this', then it is TypeScript syntax. - if (subtreeFlags & TransformFlags.ContainsDecorators || isThisIdentifier(name)) { + // The '?' token, type annotations, decorators, and 'this' parameters are TypeSCript + // syntax. + if (node.questionToken + || node.type + || subtreeFlags & TransformFlags.ContainsDecorators + || isThisIdentifier(name)) { transformFlags |= TransformFlags.AssertTypeScript; } @@ -2526,7 +2547,8 @@ namespace ts { // TypeScript syntax. // An exported declaration may be TypeScript syntax. if ((subtreeFlags & TransformFlags.TypeScriptClassSyntaxMask) - || (modifierFlags & ModifierFlags.Export)) { + || (modifierFlags & ModifierFlags.Export) + || node.typeParameters) { transformFlags |= TransformFlags.AssertTypeScript; } @@ -2547,7 +2569,8 @@ namespace ts { // A class with a parameter property assignment, property initializer, or decorator is // TypeScript syntax. - if (subtreeFlags & TransformFlags.TypeScriptClassSyntaxMask) { + if (subtreeFlags & TransformFlags.TypeScriptClassSyntaxMask + || node.typeParameters) { transformFlags |= TransformFlags.AssertTypeScript; } @@ -2601,10 +2624,10 @@ namespace ts { function computeConstructor(node: ConstructorDeclaration, subtreeFlags: TransformFlags) { let transformFlags = subtreeFlags; - const body = node.body; - if (body === undefined) { - // An overload constructor is TypeScript syntax. + // TypeScript-specific modifiers and overloads are TypeScript syntax + if (hasModifier(node, ModifierFlags.TypeScriptModifier) + || !node.body) { transformFlags |= TransformFlags.AssertTypeScript; } @@ -2615,22 +2638,19 @@ namespace ts { function computeMethod(node: MethodDeclaration, subtreeFlags: TransformFlags) { // A MethodDeclaration is ES6 syntax. let transformFlags = subtreeFlags | TransformFlags.AssertES6; - const modifierFlags = getModifierFlags(node); - const body = node.body; - const typeParameters = node.typeParameters; - const asteriskToken = node.asteriskToken; - // A MethodDeclaration is TypeScript syntax if it is either async, abstract, overloaded, - // generic, or has a decorator. - if (!body - || typeParameters - || (modifierFlags & (ModifierFlags.Async | ModifierFlags.Abstract)) - || (subtreeFlags & TransformFlags.ContainsDecorators)) { + // Decorators, TypeScript-specific modifiers, type parameters, type annotations, and + // overloads are TypeScript syntax. + if (node.decorators + || hasModifier(node, ModifierFlags.TypeScriptModifier) + || node.typeParameters + || node.type + || !node.body) { transformFlags |= TransformFlags.AssertTypeScript; } // Currently, we only support generators that were originally async function bodies. - if (asteriskToken && getEmitFlags(node) & EmitFlags.AsyncFunctionBody) { + if (node.asteriskToken && getEmitFlags(node) & EmitFlags.AsyncFunctionBody) { transformFlags |= TransformFlags.AssertGenerator; } @@ -2640,14 +2660,13 @@ namespace ts { function computeAccessor(node: AccessorDeclaration, subtreeFlags: TransformFlags) { let transformFlags = subtreeFlags; - const modifierFlags = getModifierFlags(node); - const body = node.body; - // A MethodDeclaration is TypeScript syntax if it is either async, abstract, overloaded, - // generic, or has a decorator. - if (!body - || (modifierFlags & (ModifierFlags.Async | ModifierFlags.Abstract)) - || (subtreeFlags & TransformFlags.ContainsDecorators)) { + // Decorators, TypeScript-specific modifiers, type annotations, and overloads are + // TypeScript syntax. + if (node.decorators + || hasModifier(node, ModifierFlags.TypeScriptModifier) + || node.type + || !node.body) { transformFlags |= TransformFlags.AssertTypeScript; } @@ -2673,7 +2692,6 @@ namespace ts { let transformFlags: TransformFlags; const modifierFlags = getModifierFlags(node); const body = node.body; - const asteriskToken = node.asteriskToken; if (!body || (modifierFlags & ModifierFlags.Ambient)) { // An ambient declaration is TypeScript syntax. @@ -2688,8 +2706,11 @@ namespace ts { transformFlags |= TransformFlags.AssertTypeScript | TransformFlags.AssertES6; } - // If a FunctionDeclaration is async, then it is TypeScript syntax. - if (modifierFlags & ModifierFlags.Async) { + // TypeScript-specific modifiers, type parameters, and type annotations are TypeScript + // syntax. + if (modifierFlags & ModifierFlags.TypeScriptModifier + || node.typeParameters + || node.type) { transformFlags |= TransformFlags.AssertTypeScript; } @@ -2705,7 +2726,7 @@ namespace ts { // down-level generator. // Currently we do not support transforming any other generator fucntions // down level. - if (asteriskToken && getEmitFlags(node) & EmitFlags.AsyncFunctionBody) { + if (node.asteriskToken && getEmitFlags(node) & EmitFlags.AsyncFunctionBody) { transformFlags |= TransformFlags.AssertGenerator; } } @@ -2716,11 +2737,12 @@ namespace ts { function computeFunctionExpression(node: FunctionExpression, subtreeFlags: TransformFlags) { let transformFlags = subtreeFlags; - const modifierFlags = getModifierFlags(node); - const asteriskToken = node.asteriskToken; - // An async function expression is TypeScript syntax. - if (modifierFlags & ModifierFlags.Async) { + // TypeScript-specific modifiers, type parameters, and type annotations are TypeScript + // syntax. + if (hasModifier(node, ModifierFlags.TypeScriptModifier) + || node.typeParameters + || node.type) { transformFlags |= TransformFlags.AssertTypeScript; } @@ -2736,7 +2758,7 @@ namespace ts { // down-level generator. // Currently we do not support transforming any other generator fucntions // down level. - if (asteriskToken && getEmitFlags(node) & EmitFlags.AsyncFunctionBody) { + if (node.asteriskToken && getEmitFlags(node) & EmitFlags.AsyncFunctionBody) { transformFlags |= TransformFlags.AssertGenerator; } @@ -2747,10 +2769,12 @@ namespace ts { function computeArrowFunction(node: ArrowFunction, subtreeFlags: TransformFlags) { // An ArrowFunction is ES6 syntax, and excludes markers that should not escape the scope of an ArrowFunction. let transformFlags = subtreeFlags | TransformFlags.AssertES6; - const modifierFlags = getModifierFlags(node); - // An async arrow function is TypeScript syntax. - if (modifierFlags & ModifierFlags.Async) { + // TypeScript-specific modifiers, type parameters, and type annotations are TypeScript + // syntax. + if (hasModifier(node, ModifierFlags.TypeScriptModifier) + || node.typeParameters + || node.type) { transformFlags |= TransformFlags.AssertTypeScript; } @@ -2787,6 +2811,11 @@ namespace ts { transformFlags |= TransformFlags.AssertES6 | TransformFlags.ContainsBindingPattern; } + // Type annotations are TypeScript syntax. + if (node.type) { + transformFlags |= TransformFlags.AssertTypeScript; + } + node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; return transformFlags & ~TransformFlags.NodeExcludes; } diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 270fb0ca624..a77096618d6 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -504,15 +504,29 @@ const _super = (function (geti, seti) { // Contextual keywords case SyntaxKind.AbstractKeyword: + case SyntaxKind.AsKeyword: case SyntaxKind.AnyKeyword: case SyntaxKind.AsyncKeyword: + case SyntaxKind.AwaitKeyword: case SyntaxKind.BooleanKeyword: + case SyntaxKind.ConstructorKeyword: case SyntaxKind.DeclareKeyword: - case SyntaxKind.NumberKeyword: + case SyntaxKind.GetKeyword: + case SyntaxKind.IsKeyword: + case SyntaxKind.ModuleKeyword: + case SyntaxKind.NamespaceKeyword: + case SyntaxKind.NeverKeyword: case SyntaxKind.ReadonlyKeyword: + case SyntaxKind.RequireKeyword: + case SyntaxKind.NumberKeyword: + case SyntaxKind.SetKeyword: case SyntaxKind.StringKeyword: case SyntaxKind.SymbolKeyword: + case SyntaxKind.TypeKeyword: + case SyntaxKind.UndefinedKeyword: + case SyntaxKind.FromKeyword: case SyntaxKind.GlobalKeyword: + case SyntaxKind.OfKeyword: writeTokenText(kind); return; @@ -1198,12 +1212,14 @@ const _super = (function (geti, seti) { function emitCallExpression(node: CallExpression) { emitExpression(node.expression); + emitTypeArguments(node, node.typeArguments); emitExpressionList(node, node.arguments, ListFormat.CallExpressionArguments); } function emitNewExpression(node: NewExpression) { write("new "); emitExpression(node.expression); + emitTypeArguments(node, node.typeArguments); emitExpressionList(node, node.arguments, ListFormat.NewExpressionArguments); } @@ -1575,6 +1591,7 @@ const _super = (function (geti, seti) { function emitVariableDeclaration(node: VariableDeclaration) { emit(node.name); + emitWithPrefix(": ", node.type); emitExpressionWithPrefix(" = ", node.initializer); } diff --git a/src/compiler/transformers/es6.ts b/src/compiler/transformers/es6.ts index 8d8a817c183..fd9f7d2406c 100644 --- a/src/compiler/transformers/es6.ts +++ b/src/compiler/transformers/es6.ts @@ -1416,6 +1416,7 @@ namespace ts { if (getAccessor) { const getterFunction = transformFunctionLikeToExpression(getAccessor, /*location*/ undefined, /*name*/ undefined); setSourceMapRange(getterFunction, getSourceMapRange(getAccessor)); + setEmitFlags(getterFunction, EmitFlags.NoLeadingComments); const getter = createPropertyAssignment("get", getterFunction); setCommentRange(getter, getCommentRange(getAccessor)); properties.push(getter); @@ -1424,6 +1425,7 @@ namespace ts { if (setAccessor) { const setterFunction = transformFunctionLikeToExpression(setAccessor, /*location*/ undefined, /*name*/ undefined); setSourceMapRange(setterFunction, getSourceMapRange(setAccessor)); + setEmitFlags(setterFunction, EmitFlags.NoLeadingComments); const setter = createPropertyAssignment("set", setterFunction); setCommentRange(setter, getCommentRange(setAccessor)); properties.push(setter); diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 2c146c91bc3..f1ff9856bad 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -287,7 +287,7 @@ namespace ts { case SyntaxKind.Constructor: // TypeScript constructors are transformed in `visitClassDeclaration`. - return undefined; + return visitConstructor(node); case SyntaxKind.InterfaceDeclaration: // TypeScript interfaces are elided, but some comments may be preserved. @@ -377,6 +377,12 @@ namespace ts { // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); + case SyntaxKind.CallExpression: + return visitCallExpression(node); + + case SyntaxKind.NewExpression: + return visitNewExpression(node); + case SyntaxKind.NonNullExpression: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); @@ -393,6 +399,9 @@ namespace ts { // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); + case SyntaxKind.VariableDeclaration: + return visitVariableDeclaration(node); + case SyntaxKind.ModuleDeclaration: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); @@ -2088,6 +2097,14 @@ namespace ts { return !nodeIsMissing(node.body); } + function visitConstructor(node: ConstructorDeclaration) { + if (!shouldEmitFunctionLikeDeclaration(node)) { + return undefined; + } + + return visitEachChild(node, visitor, context); + } + /** * Visits a method declaration of a class. * @@ -2295,13 +2312,16 @@ namespace ts { function transformFunctionBodyWorker(body: Block, start = 0) { const savedCurrentScope = currentScope; + const savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName; currentScope = body; + currentScopeFirstDeclarationsOfName = createMap(); startLexicalEnvironment(); const statements = visitNodes(body.statements, visitor, isStatement, start); const visited = updateBlock(body, statements); const declarations = endLexicalEnvironment(); currentScope = savedCurrentScope; + currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; return mergeFunctionBodyLexicalEnvironment(visited, declarations); } @@ -2481,6 +2501,14 @@ namespace ts { } } + function visitVariableDeclaration(node: VariableDeclaration) { + return updateVariableDeclaration( + node, + visitNode(node.name, visitor, isBindingName), + /*type*/ undefined, + visitNode(node.initializer, visitor, isExpression)); + } + /** * Visits an await expression. * @@ -2541,6 +2569,22 @@ namespace ts { return createPartiallyEmittedExpression(expression, node); } + function visitCallExpression(node: CallExpression) { + return updateCall( + node, + visitNode(node.expression, visitor, isExpression), + /*typeArguments*/ undefined, + visitNodes(node.arguments, visitor, isExpression)); + } + + function visitNewExpression(node: NewExpression) { + return updateNew( + node, + visitNode(node.expression, visitor, isExpression), + /*typeArguments*/ undefined, + visitNodes(node.arguments, visitor, isExpression)); + } + /** * Determines whether to emit an enum declaration. * diff --git a/src/compiler/types.ts b/src/compiler/types.ts index e87fa3e786f..d66677910f8 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -456,6 +456,8 @@ namespace ts { // Accessibility modifiers and 'readonly' can be attached to a parameter in a constructor to make it a property. ParameterPropertyModifier = AccessibilityModifier | Readonly, NonPublicAccessibilityModifier = Private | Protected, + + TypeScriptModifier = Ambient | Public | Private | Protected | Readonly | Abstract | Async | Const } export const enum JsxFlags { diff --git a/tests/baselines/reference/constructorArgsErrors1.js b/tests/baselines/reference/constructorArgsErrors1.js index 15c5e64952b..bb0725ab8b9 100644 --- a/tests/baselines/reference/constructorArgsErrors1.js +++ b/tests/baselines/reference/constructorArgsErrors1.js @@ -6,7 +6,7 @@ class foo { //// [constructorArgsErrors1.js] var foo = (function () { - function foo(static a) { + function foo(a) { } return foo; }()); diff --git a/tests/baselines/reference/constructorArgsErrors5.js b/tests/baselines/reference/constructorArgsErrors5.js index 6ba68cb88b4..c481d6f323c 100644 --- a/tests/baselines/reference/constructorArgsErrors5.js +++ b/tests/baselines/reference/constructorArgsErrors5.js @@ -7,7 +7,7 @@ class foo { //// [constructorArgsErrors5.js] var foo = (function () { - function foo(export a) { + function foo(a) { } return foo; }()); diff --git a/tests/baselines/reference/parserErrorRecovery_ParameterList6.js b/tests/baselines/reference/parserErrorRecovery_ParameterList6.js index c3d5a838f88..7c221aaa20a 100644 --- a/tests/baselines/reference/parserErrorRecovery_ParameterList6.js +++ b/tests/baselines/reference/parserErrorRecovery_ParameterList6.js @@ -7,7 +7,6 @@ class Foo { var Foo = (function () { function Foo() { } - Foo.prototype.banana = function (x) { }; return Foo; }()); break ; diff --git a/tests/baselines/reference/transformsElideNullUndefinedType.js b/tests/baselines/reference/transformsElideNullUndefinedType.js new file mode 100644 index 00000000000..a5e27eee08b --- /dev/null +++ b/tests/baselines/reference/transformsElideNullUndefinedType.js @@ -0,0 +1,54 @@ +//// [transformsElideNullUndefinedType.ts] + +var v0: null; +var v1: undefined; + +function f0(): null { return null; } +function f1(): undefined { return undefined; } + +var f2 = function (): null { return null; } +var f3 = function (): undefined { return undefined; } + +var f4 = (): null => null; +var f5 = (): undefined => undefined; + +function f6(p0: null) { } +function f7(p1: undefined) { } + +class C { + m0(): null { return null; } + m1(): undefined { return undefined; } + + get a0(): null { return null; } + get a1(): undefined { return undefined; } +} + +declare function fn(); + +fn(); +fn(); + +new C(); +new C(); + +//// [transformsElideNullUndefinedType.js] +var v0; +var v1; +function f0() { return null; } +function f1() { return undefined; } +var f2 = function () { return null; }; +var f3 = function () { return undefined; }; +var f4 = () => null; +var f5 = () => undefined; +function f6(p0) { } +function f7(p1) { } +class C { + m0() { return null; } + m1() { return undefined; } + get a0() { return null; } + get a1() { return undefined; } +} +fn(); +fn(); +new C(); +new C(); diff --git a/tests/baselines/reference/transformsElideNullUndefinedType.symbols b/tests/baselines/reference/transformsElideNullUndefinedType.symbols new file mode 100644 index 00000000000..0c9333d9820 --- /dev/null +++ b/tests/baselines/reference/transformsElideNullUndefinedType.symbols @@ -0,0 +1,72 @@ +=== tests/cases/compiler/transformsElideNullUndefinedType.ts === + +var v0: null; +>v0 : Symbol(v0, Decl(transformsElideNullUndefinedType.ts, 1, 3)) + +var v1: undefined; +>v1 : Symbol(v1, Decl(transformsElideNullUndefinedType.ts, 2, 3)) + +function f0(): null { return null; } +>f0 : Symbol(f0, Decl(transformsElideNullUndefinedType.ts, 2, 18)) + +function f1(): undefined { return undefined; } +>f1 : Symbol(f1, Decl(transformsElideNullUndefinedType.ts, 4, 36)) +>undefined : Symbol(undefined) + +var f2 = function (): null { return null; } +>f2 : Symbol(f2, Decl(transformsElideNullUndefinedType.ts, 7, 3)) + +var f3 = function (): undefined { return undefined; } +>f3 : Symbol(f3, Decl(transformsElideNullUndefinedType.ts, 8, 3)) +>undefined : Symbol(undefined) + +var f4 = (): null => null; +>f4 : Symbol(f4, Decl(transformsElideNullUndefinedType.ts, 10, 3)) + +var f5 = (): undefined => undefined; +>f5 : Symbol(f5, Decl(transformsElideNullUndefinedType.ts, 11, 3)) +>undefined : Symbol(undefined) + +function f6(p0: null) { } +>f6 : Symbol(f6, Decl(transformsElideNullUndefinedType.ts, 11, 36)) +>p0 : Symbol(p0, Decl(transformsElideNullUndefinedType.ts, 13, 12)) + +function f7(p1: undefined) { } +>f7 : Symbol(f7, Decl(transformsElideNullUndefinedType.ts, 13, 25)) +>p1 : Symbol(p1, Decl(transformsElideNullUndefinedType.ts, 14, 12)) + +class C { +>C : Symbol(C, Decl(transformsElideNullUndefinedType.ts, 14, 30)) +>T : Symbol(T, Decl(transformsElideNullUndefinedType.ts, 16, 8)) + + m0(): null { return null; } +>m0 : Symbol(C.m0, Decl(transformsElideNullUndefinedType.ts, 16, 12)) + + m1(): undefined { return undefined; } +>m1 : Symbol(C.m1, Decl(transformsElideNullUndefinedType.ts, 17, 31)) +>undefined : Symbol(undefined) + + get a0(): null { return null; } +>a0 : Symbol(C.a0, Decl(transformsElideNullUndefinedType.ts, 18, 41)) + + get a1(): undefined { return undefined; } +>a1 : Symbol(C.a1, Decl(transformsElideNullUndefinedType.ts, 20, 35)) +>undefined : Symbol(undefined) +} + +declare function fn(); +>fn : Symbol(fn, Decl(transformsElideNullUndefinedType.ts, 22, 1)) +>T : Symbol(T, Decl(transformsElideNullUndefinedType.ts, 24, 20)) + +fn(); +>fn : Symbol(fn, Decl(transformsElideNullUndefinedType.ts, 22, 1)) + +fn(); +>fn : Symbol(fn, Decl(transformsElideNullUndefinedType.ts, 22, 1)) + +new C(); +>C : Symbol(C, Decl(transformsElideNullUndefinedType.ts, 14, 30)) + +new C(); +>C : Symbol(C, Decl(transformsElideNullUndefinedType.ts, 14, 30)) + diff --git a/tests/baselines/reference/transformsElideNullUndefinedType.types b/tests/baselines/reference/transformsElideNullUndefinedType.types new file mode 100644 index 00000000000..66a73c83141 --- /dev/null +++ b/tests/baselines/reference/transformsElideNullUndefinedType.types @@ -0,0 +1,94 @@ +=== tests/cases/compiler/transformsElideNullUndefinedType.ts === + +var v0: null; +>v0 : null +>null : null + +var v1: undefined; +>v1 : undefined + +function f0(): null { return null; } +>f0 : () => null +>null : null +>null : null + +function f1(): undefined { return undefined; } +>f1 : () => undefined +>undefined : undefined + +var f2 = function (): null { return null; } +>f2 : () => null +>function (): null { return null; } : () => null +>null : null +>null : null + +var f3 = function (): undefined { return undefined; } +>f3 : () => undefined +>function (): undefined { return undefined; } : () => undefined +>undefined : undefined + +var f4 = (): null => null; +>f4 : () => null +>(): null => null : () => null +>null : null +>null : null + +var f5 = (): undefined => undefined; +>f5 : () => undefined +>(): undefined => undefined : () => undefined +>undefined : undefined + +function f6(p0: null) { } +>f6 : (p0: null) => void +>p0 : null +>null : null + +function f7(p1: undefined) { } +>f7 : (p1: undefined) => void +>p1 : undefined + +class C { +>C : C +>T : T + + m0(): null { return null; } +>m0 : () => null +>null : null +>null : null + + m1(): undefined { return undefined; } +>m1 : () => undefined +>undefined : undefined + + get a0(): null { return null; } +>a0 : null +>null : null +>null : null + + get a1(): undefined { return undefined; } +>a1 : undefined +>undefined : undefined +} + +declare function fn(); +>fn : () => any +>T : T + +fn(); +>fn() : any +>fn : () => any +>null : null + +fn(); +>fn() : any +>fn : () => any + +new C(); +>new C() : C +>C : typeof C +>null : null + +new C(); +>new C() : C +>C : typeof C + diff --git a/tests/baselines/reference/typeGuardFunctionErrors.js b/tests/baselines/reference/typeGuardFunctionErrors.js index 6f0880ad7f5..244b0df3333 100644 --- a/tests/baselines/reference/typeGuardFunctionErrors.js +++ b/tests/baselines/reference/typeGuardFunctionErrors.js @@ -171,7 +171,6 @@ var C = (function (_super) { function hasANonBooleanReturnStatement(x) { return ''; } -function hasTypeGuardTypeInsideTypeGuardType(x) { } is; A; { @@ -232,7 +231,6 @@ function b2(a, A) { if (a === void 0) { a = is; } } ; -function b3() { } is; A; { diff --git a/tests/cases/compiler/transformsElideNullUndefinedType.ts b/tests/cases/compiler/transformsElideNullUndefinedType.ts new file mode 100644 index 00000000000..244f2ea9c75 --- /dev/null +++ b/tests/cases/compiler/transformsElideNullUndefinedType.ts @@ -0,0 +1,32 @@ +// @target: es6 + +var v0: null; +var v1: undefined; + +function f0(): null { return null; } +function f1(): undefined { return undefined; } + +var f2 = function (): null { return null; } +var f3 = function (): undefined { return undefined; } + +var f4 = (): null => null; +var f5 = (): undefined => undefined; + +function f6(p0: null) { } +function f7(p1: undefined) { } + +class C { + m0(): null { return null; } + m1(): undefined { return undefined; } + + get a0(): null { return null; } + get a1(): undefined { return undefined; } +} + +declare function fn(); + +fn(); +fn(); + +new C(); +new C(); \ No newline at end of file From a1cbfcae4b2560f2709a88e4d41185ac548c5e5c Mon Sep 17 00:00:00 2001 From: Zhengbo Li Date: Fri, 14 Oct 2016 20:50:12 -0700 Subject: [PATCH 105/173] Add missing trigger file (#11641) * Add missing trigger file property for config file diags * Add test --- src/harness/unittests/tsserverProjectSystem.ts | 10 +++++++++- src/server/editorServices.ts | 12 ++++++------ src/server/session.ts | 2 +- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index 468d6aac14b..9d086e4549e 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -135,7 +135,7 @@ namespace ts.projectSystem { } export class TestServerEventManager { - private events: server.ProjectServiceEvent[] = []; + public events: server.ProjectServiceEvent[] = []; handler: server.ProjectServiceEventHandler = (event: server.ProjectServiceEvent) => { this.events.push(event); @@ -2286,6 +2286,14 @@ namespace ts.projectSystem { const session = createSession(host, /*typingsInstaller*/ undefined, serverEventManager.handler); openFilesForSession([file], session); serverEventManager.checkEventCountOfType("configFileDiag", 1); + + for (const event of serverEventManager.events) { + if (event.eventName === "configFileDiag") { + assert.equal(event.data.configFileName, configFile.path); + assert.equal(event.data.triggerFile, file.path); + return; + } + } }); it("are generated when the config file doesn't have errors", () => { diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 91b9f90c88b..54b257242fd 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -11,7 +11,7 @@ namespace ts.server { export const maxProgramSizeForNonTsFiles = 20 * 1024 * 1024; export type ProjectServiceEvent = - { eventName: "context", data: { project: Project, fileName: NormalizedPath } } | { eventName: "configFileDiag", data: { triggerFile?: string, configFileName: string, diagnostics: Diagnostic[] } }; + { eventName: "context", data: { project: Project, fileName: NormalizedPath } } | { eventName: "configFileDiag", data: { triggerFile: string, configFileName: string, diagnostics: Diagnostic[] } }; export interface ProjectServiceEventHandler { (event: ProjectServiceEvent): void; @@ -392,12 +392,12 @@ namespace ts.server { this.throttledOperations.schedule( project.configFileName, /*delay*/250, - () => this.handleChangeInSourceFileForConfiguredProject(project)); + () => this.handleChangeInSourceFileForConfiguredProject(project, fileName)); } - private handleChangeInSourceFileForConfiguredProject(project: ConfiguredProject) { + private handleChangeInSourceFileForConfiguredProject(project: ConfiguredProject, triggerFile: string) { const { projectOptions, configFileErrors } = this.convertConfigFileContentToProjectOptions(project.configFileName); - this.reportConfigFileDiagnostics(project.getProjectName(), configFileErrors); + this.reportConfigFileDiagnostics(project.getProjectName(), configFileErrors, triggerFile); const newRootFiles = projectOptions.files.map((f => this.getCanonicalFileName(f))); const currentRootFiles = project.getRootFiles().map((f => this.getCanonicalFileName(f))); @@ -434,7 +434,7 @@ namespace ts.server { } const { configFileErrors } = this.convertConfigFileContentToProjectOptions(fileName); - this.reportConfigFileDiagnostics(fileName, configFileErrors); + this.reportConfigFileDiagnostics(fileName, configFileErrors, fileName); this.logger.info(`Detected newly added tsconfig file: ${fileName}`); this.reloadProjects(); @@ -757,7 +757,7 @@ namespace ts.server { return project; } - private reportConfigFileDiagnostics(configFileName: string, diagnostics: Diagnostic[], triggerFile?: string) { + private reportConfigFileDiagnostics(configFileName: string, diagnostics: Diagnostic[], triggerFile: string) { if (!this.eventHandler) { return; } diff --git a/src/server/session.ts b/src/server/session.ts index 539142eff18..3df6a1acb51 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -761,7 +761,7 @@ namespace ts.server { if (this.eventHander) { this.eventHander({ eventName: "configFileDiag", - data: { fileName, configFileName, diagnostics: configFileErrors || [] } + data: { triggerFile: fileName, configFileName, diagnostics: configFileErrors || [] } }); } } From 40e99e7f6691b356c3a4d1da873cd799812d29d4 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Fri, 14 Oct 2016 21:34:59 -0700 Subject: [PATCH 106/173] Updated comment --- src/compiler/transformers/ts.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index f1ff9856bad..1189c1380ab 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -286,7 +286,6 @@ namespace ts { // TypeScript property declarations are elided. case SyntaxKind.Constructor: - // TypeScript constructors are transformed in `visitClassDeclaration`. return visitConstructor(node); case SyntaxKind.InterfaceDeclaration: From a4a7c237b3b55ad250fa2c55a66fd1cce4c3f071 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Sat, 15 Oct 2016 15:18:32 -0700 Subject: [PATCH 107/173] Fix issues from merge --- src/compiler/binder.ts | 8 +- src/compiler/binder.ts.orig | 3181 ----------------------------------- 2 files changed, 4 insertions(+), 3185 deletions(-) delete mode 100644 src/compiler/binder.ts.orig diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index d71e6ea2c85..4711d54e0b2 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -2469,7 +2469,7 @@ namespace ts { if (subtreeFlags & TransformFlags.ContainsSpreadElementExpression) { // If the this node contains a SpreadElementExpression then it is an ES6 // node. - transformFlags |= TransformFlags.AssertES6; + transformFlags |= TransformFlags.AssertES2015; } node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; return transformFlags & ~TransformFlags.ArrayLiteralOrCallOrNewExcludes; @@ -2671,7 +2671,7 @@ namespace ts { } // An async method declaration is ES2017 syntax. - if (modifierFlags & ModifierFlags.Async) { + if (hasModifier(node, ModifierFlags.Async)) { transformFlags |= TransformFlags.AssertES2017; } @@ -2778,7 +2778,7 @@ namespace ts { } // An async function expression is ES2017 syntax. - if (modifierFlags & ModifierFlags.Async) { + if (hasModifier(node, ModifierFlags.Async)) { transformFlags |= TransformFlags.AssertES2017; } @@ -2815,7 +2815,7 @@ namespace ts { } // An async arrow function is ES2017 syntax. - if (modifierFlags & ModifierFlags.Async) { + if (hasModifier(node, ModifierFlags.Async)) { transformFlags |= TransformFlags.AssertES2017; } diff --git a/src/compiler/binder.ts.orig b/src/compiler/binder.ts.orig deleted file mode 100644 index 6cbd7d746d1..00000000000 --- a/src/compiler/binder.ts.orig +++ /dev/null @@ -1,3181 +0,0 @@ -/// -/// - -/* @internal */ -namespace ts { - export const enum ModuleInstanceState { - NonInstantiated = 0, - Instantiated = 1, - ConstEnumOnly = 2 - } - - interface ActiveLabel { - name: string; - breakTarget: FlowLabel; - continueTarget: FlowLabel; - referenced: boolean; - } - - export function getModuleInstanceState(node: Node): ModuleInstanceState { - // A module is uninstantiated if it contains only - // 1. interface declarations, type alias declarations - if (node.kind === SyntaxKind.InterfaceDeclaration || node.kind === SyntaxKind.TypeAliasDeclaration) { - return ModuleInstanceState.NonInstantiated; - } - // 2. const enum declarations - else if (isConstEnumDeclaration(node)) { - return ModuleInstanceState.ConstEnumOnly; - } - // 3. non-exported import declarations - else if ((node.kind === SyntaxKind.ImportDeclaration || node.kind === SyntaxKind.ImportEqualsDeclaration) && !(hasModifier(node, ModifierFlags.Export))) { - return ModuleInstanceState.NonInstantiated; - } - // 4. other uninstantiated module declarations. - else if (node.kind === SyntaxKind.ModuleBlock) { - let state = ModuleInstanceState.NonInstantiated; - forEachChild(node, n => { - switch (getModuleInstanceState(n)) { - case ModuleInstanceState.NonInstantiated: - // child is non-instantiated - continue searching - return false; - case ModuleInstanceState.ConstEnumOnly: - // child is const enum only - record state and continue searching - state = ModuleInstanceState.ConstEnumOnly; - return false; - case ModuleInstanceState.Instantiated: - // child is instantiated - record state and stop - state = ModuleInstanceState.Instantiated; - return true; - } - }); - return state; - } - else if (node.kind === SyntaxKind.ModuleDeclaration) { - const body = (node).body; - return body ? getModuleInstanceState(body) : ModuleInstanceState.Instantiated; - } - else { - return ModuleInstanceState.Instantiated; - } - } - - const enum ContainerFlags { - // The current node is not a container, and no container manipulation should happen before - // recursing into it. - None = 0, - - // The current node is a container. It should be set as the current container (and block- - // container) before recursing into it. The current node does not have locals. Examples: - // - // Classes, ObjectLiterals, TypeLiterals, Interfaces... - IsContainer = 1 << 0, - - // The current node is a block-scoped-container. It should be set as the current block- - // container before recursing into it. Examples: - // - // Blocks (when not parented by functions), Catch clauses, For/For-in/For-of statements... - IsBlockScopedContainer = 1 << 1, - - // The current node is the container of a control flow path. The current control flow should - // be saved and restored, and a new control flow initialized within the container. - IsControlFlowContainer = 1 << 2, - - IsFunctionLike = 1 << 3, - IsFunctionExpression = 1 << 4, - HasLocals = 1 << 5, - IsInterface = 1 << 6, - IsObjectLiteralOrClassExpressionMethod = 1 << 7, - } - - const binder = createBinder(); - - export function bindSourceFile(file: SourceFile, options: CompilerOptions) { - performance.mark("beforeBind"); - binder(file, options); - performance.mark("afterBind"); - performance.measure("Bind", "beforeBind", "afterBind"); - } - - function createBinder(): (file: SourceFile, options: CompilerOptions) => void { - let file: SourceFile; - let options: CompilerOptions; - let languageVersion: ScriptTarget; - let parent: Node; - let container: Node; - let blockScopeContainer: Node; - let lastContainer: Node; - let seenThisKeyword: boolean; - - // state used by control flow analysis - let currentFlow: FlowNode; - let currentBreakTarget: FlowLabel; - let currentContinueTarget: FlowLabel; - let currentReturnTarget: FlowLabel; - let currentTrueTarget: FlowLabel; - let currentFalseTarget: FlowLabel; - let preSwitchCaseFlow: FlowNode; - let activeLabels: ActiveLabel[]; - let hasExplicitReturn: boolean; - - // state used for emit helpers - let emitFlags: NodeFlags; - - // 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 - // or if compiler options contain alwaysStrict. - let inStrictMode: boolean; - - let symbolCount = 0; - let Symbol: { new (flags: SymbolFlags, name: string): Symbol }; - let classifiableNames: Map; - - const unreachableFlow: FlowNode = { flags: FlowFlags.Unreachable }; - const reportedUnreachableFlow: FlowNode = { flags: FlowFlags.Unreachable }; - - // state used to aggregate transform flags during bind. - let subtreeTransformFlags: TransformFlags = TransformFlags.None; - let skipTransformFlagAggregation: boolean; - - function bindSourceFile(f: SourceFile, opts: CompilerOptions) { - file = f; - options = opts; - languageVersion = getEmitScriptTarget(options); - inStrictMode = bindInStrictMode(file, opts); - classifiableNames = createMap(); - symbolCount = 0; - skipTransformFlagAggregation = isDeclarationFile(file); - - Symbol = objectAllocator.getSymbolConstructor(); - - if (!file.locals) { - bind(file); - file.symbolCount = symbolCount; - file.classifiableNames = classifiableNames; - } - - file = undefined; - options = undefined; - languageVersion = undefined; - parent = undefined; - container = undefined; - blockScopeContainer = undefined; - lastContainer = undefined; - seenThisKeyword = false; - currentFlow = undefined; - currentBreakTarget = undefined; - currentContinueTarget = undefined; - currentReturnTarget = undefined; - currentTrueTarget = undefined; - currentFalseTarget = undefined; - activeLabels = undefined; - hasExplicitReturn = false; - emitFlags = NodeFlags.None; - subtreeTransformFlags = TransformFlags.None; - } - - return bindSourceFile; - - function bindInStrictMode(file: SourceFile, opts: CompilerOptions): boolean { - if (opts.alwaysStrict && !isDeclarationFile(file)) { - // bind in strict mode source files with alwaysStrict option - return true; - } - else { - return !!file.externalModuleIndicator; - } - } - - function createSymbol(flags: SymbolFlags, name: string): Symbol { - symbolCount++; - return new Symbol(flags, name); - } - - function addDeclarationToSymbol(symbol: Symbol, node: Declaration, symbolFlags: SymbolFlags) { - symbol.flags |= symbolFlags; - - node.symbol = symbol; - - if (!symbol.declarations) { - symbol.declarations = []; - } - symbol.declarations.push(node); - - if (symbolFlags & SymbolFlags.HasExports && !symbol.exports) { - symbol.exports = createMap(); - } - - if (symbolFlags & SymbolFlags.HasMembers && !symbol.members) { - symbol.members = createMap(); - } - - if (symbolFlags & SymbolFlags.Value) { - const valueDeclaration = symbol.valueDeclaration; - if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === SyntaxKind.ModuleDeclaration)) { - // other kinds of value declarations take precedence over modules - symbol.valueDeclaration = node; - } - } - } - - // Should not be called on a declaration with a computed property name, - // unless it is a well known Symbol. - function getDeclarationName(node: Declaration): string { - if (node.name) { - if (isAmbientModule(node)) { - return isGlobalScopeAugmentation(node) ? "__global" : `"${(node.name).text}"`; - } - if (node.name.kind === SyntaxKind.ComputedPropertyName) { - const nameExpression = (node.name).expression; - // treat computed property names where expression is string/numeric literal as just string/numeric literal - if (isStringOrNumericLiteral(nameExpression.kind)) { - return (nameExpression).text; - } - - Debug.assert(isWellKnownSymbolSyntactically(nameExpression)); - return getPropertyNameForKnownSymbolName((nameExpression).name.text); - } - return (node.name).text; - } - switch (node.kind) { - case SyntaxKind.Constructor: - return "__constructor"; - case SyntaxKind.FunctionType: - case SyntaxKind.CallSignature: - return "__call"; - case SyntaxKind.ConstructorType: - case SyntaxKind.ConstructSignature: - return "__new"; - case SyntaxKind.IndexSignature: - return "__index"; - case SyntaxKind.ExportDeclaration: - return "__export"; - case SyntaxKind.ExportAssignment: - return (node).isExportEquals ? "export=" : "default"; - case SyntaxKind.BinaryExpression: - switch (getSpecialPropertyAssignmentKind(node)) { - case SpecialPropertyAssignmentKind.ModuleExports: - // module.exports = ... - return "export="; - case SpecialPropertyAssignmentKind.ExportsProperty: - case SpecialPropertyAssignmentKind.ThisProperty: - // exports.x = ... or this.y = ... - return ((node as BinaryExpression).left as PropertyAccessExpression).name.text; - case SpecialPropertyAssignmentKind.PrototypeProperty: - // className.prototype.methodName = ... - return (((node as BinaryExpression).left as PropertyAccessExpression).expression as PropertyAccessExpression).name.text; - } - Debug.fail("Unknown binary declaration kind"); - break; - - case SyntaxKind.FunctionDeclaration: - case SyntaxKind.ClassDeclaration: - return hasModifier(node, ModifierFlags.Default) ? "default" : undefined; - case SyntaxKind.JSDocFunctionType: - return isJSDocConstructSignature(node) ? "__new" : "__call"; - case SyntaxKind.Parameter: - // Parameters with names are handled at the top of this function. Parameters - // without names can only come from JSDocFunctionTypes. - Debug.assert(node.parent.kind === SyntaxKind.JSDocFunctionType); - let functionType = node.parent; - let index = indexOf(functionType.parameters, node); - return "arg" + index; - case SyntaxKind.JSDocTypedefTag: - const parentNode = node.parent && node.parent.parent; - let nameFromParentNode: string; - if (parentNode && parentNode.kind === SyntaxKind.VariableStatement) { - if ((parentNode).declarationList.declarations.length > 0) { - const nameIdentifier = (parentNode).declarationList.declarations[0].name; - if (nameIdentifier.kind === SyntaxKind.Identifier) { - nameFromParentNode = (nameIdentifier).text; - } - } - } - return nameFromParentNode; - } - } - - function getDisplayName(node: Declaration): string { - return node.name ? declarationNameToString(node.name) : getDeclarationName(node); - } - - /** - * Declares a Symbol for the node and adds it to symbols. Reports errors for conflicting identifier names. - * @param symbolTable - The symbol table which node will be added to. - * @param parent - node's parent declaration. - * @param node - The declaration to be added to the symbol table - * @param includes - The SymbolFlags that node has in addition to its declaration type (eg: export, ambient, etc.) - * @param excludes - The flags which node cannot be declared alongside in a symbol table. Used to report forbidden declarations. - */ - function declareSymbol(symbolTable: SymbolTable, parent: Symbol, node: Declaration, includes: SymbolFlags, excludes: SymbolFlags): Symbol { - Debug.assert(!hasDynamicName(node)); - - const isDefaultExport = hasModifier(node, ModifierFlags.Default); - - // The exported symbol for an export default function/class node is always named "default" - const name = isDefaultExport && parent ? "default" : getDeclarationName(node); - - let symbol: Symbol; - if (name === undefined) { - symbol = createSymbol(SymbolFlags.None, "__missing"); - } - else { - // Check and see if the symbol table already has a symbol with this name. If not, - // create a new symbol with this name and add it to the table. Note that we don't - // give the new symbol any flags *yet*. This ensures that it will not conflict - // with the 'excludes' flags we pass in. - // - // If we do get an existing symbol, see if it conflicts with the new symbol we're - // creating. For example, a 'var' symbol and a 'class' symbol will conflict within - // the same symbol table. If we have a conflict, report the issue on each - // declaration we have for this symbol, and then create a new symbol for this - // declaration. - // - // Note that when properties declared in Javascript constructors - // (marked by isReplaceableByMethod) conflict with another symbol, the property loses. - // Always. This allows the common Javascript pattern of overwriting a prototype method - // with an bound instance method of the same type: `this.method = this.method.bind(this)` - // - // If we created a new symbol, either because we didn't have a symbol with this name - // in the symbol table, or we conflicted with an existing symbol, then just add this - // node as the sole declaration of the new symbol. - // - // Otherwise, we'll be merging into a compatible existing symbol (for example when - // you have multiple 'vars' with the same name in the same container). In this case - // just add this node into the declarations list of the symbol. - symbol = symbolTable[name] || (symbolTable[name] = createSymbol(SymbolFlags.None, name)); - - if (name && (includes & SymbolFlags.Classifiable)) { - classifiableNames[name] = name; - } - - if (symbol.flags & excludes) { - if (symbol.isReplaceableByMethod) { - // Javascript constructor-declared symbols can be discarded in favor of - // prototype symbols like methods. - symbol = symbolTable[name] = createSymbol(SymbolFlags.None, name); - } - else { - if (node.name) { - node.name.parent = node; - } - - // Report errors every position with duplicate declaration - // Report errors on previous encountered declarations - let message = symbol.flags & SymbolFlags.BlockScopedVariable - ? Diagnostics.Cannot_redeclare_block_scoped_variable_0 - : Diagnostics.Duplicate_identifier_0; - - if (symbol.declarations && symbol.declarations.length) { - // If the current node is a default export of some sort, then check if - // there are any other default exports that we need to error on. - // We'll know whether we have other default exports depending on if `symbol` already has a declaration list set. - if (isDefaultExport) { - message = Diagnostics.A_module_cannot_have_multiple_default_exports; - } - else { - // This is to properly report an error in the case "export default { }" is after export default of class declaration or function declaration. - // Error on multiple export default in the following case: - // 1. multiple export default of class declaration or function declaration by checking NodeFlags.Default - // 2. multiple export default of export assignment. This one doesn't have NodeFlags.Default on (as export default doesn't considered as modifiers) - if (symbol.declarations && symbol.declarations.length && - (isDefaultExport || (node.kind === SyntaxKind.ExportAssignment && !(node).isExportEquals))) { - message = Diagnostics.A_module_cannot_have_multiple_default_exports; - } - } - } - - forEach(symbol.declarations, declaration => { - file.bindDiagnostics.push(createDiagnosticForNode(declaration.name || declaration, message, getDisplayName(declaration))); - }); - file.bindDiagnostics.push(createDiagnosticForNode(node.name || node, message, getDisplayName(node))); - - symbol = createSymbol(SymbolFlags.None, name); - } - } - } - - addDeclarationToSymbol(symbol, node, includes); - symbol.parent = parent; - - return symbol; - } - - function declareModuleMember(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags): Symbol { - const hasExportModifier = getCombinedModifierFlags(node) & ModifierFlags.Export; - if (symbolFlags & SymbolFlags.Alias) { - if (node.kind === SyntaxKind.ExportSpecifier || (node.kind === SyntaxKind.ImportEqualsDeclaration && hasExportModifier)) { - return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - } - else { - return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); - } - } - else { - // Exported module members are given 2 symbols: A local symbol that is classified with an ExportValue, - // ExportType, or ExportContainer flag, and an associated export symbol with all the correct flags set - // on it. There are 2 main reasons: - // - // 1. We treat locals and exports of the same name as mutually exclusive within a container. - // That means the binder will issue a Duplicate Identifier error if you mix locals and exports - // with the same name in the same container. - // TODO: Make this a more specific error and decouple it from the exclusion logic. - // 2. When we checkIdentifier in the checker, we set its resolved symbol to the local symbol, - // but return the export symbol (by calling getExportSymbolOfValueSymbolIfExported). That way - // when the emitter comes back to it, it knows not to qualify the name if it was found in a containing scope. - - // NOTE: Nested ambient modules always should go to to 'locals' table to prevent their automatic merge - // during global merging in the checker. Why? The only case when ambient module is permitted inside another module is module augmentation - // and this case is specially handled. Module augmentations should only be merged with original module definition - // and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed. - if (!isAmbientModule(node) && (hasExportModifier || container.flags & NodeFlags.ExportContext)) { - const exportKind = - (symbolFlags & SymbolFlags.Value ? SymbolFlags.ExportValue : 0) | - (symbolFlags & SymbolFlags.Type ? SymbolFlags.ExportType : 0) | - (symbolFlags & SymbolFlags.Namespace ? SymbolFlags.ExportNamespace : 0); - const local = declareSymbol(container.locals, undefined, node, exportKind, symbolExcludes); - local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - node.localSymbol = local; - return local; - } - else { - return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); - } - } - } - - // All container nodes are kept on a linked list in declaration order. This list is used by - // the getLocalNameOfContainer function in the type checker to validate that the local name - // used for a container is unique. - function bindContainer(node: Node, containerFlags: ContainerFlags) { - // Before we recurse into a node's children, we first save the existing parent, container - // and block-container. Then after we pop out of processing the children, we restore - // these saved values. - const saveContainer = container; - const savedBlockScopeContainer = blockScopeContainer; - - // Depending on what kind of node this is, we may have to adjust the current container - // and block-container. If the current node is a container, then it is automatically - // considered the current block-container as well. Also, for containers that we know - // may contain locals, we proactively initialize the .locals field. We do this because - // it's highly likely that the .locals will be needed to place some child in (for example, - // a parameter, or variable declaration). - // - // However, we do not proactively create the .locals for block-containers because it's - // totally normal and common for block-containers to never actually have a block-scoped - // variable in them. We don't want to end up allocating an object for every 'block' we - // run into when most of them won't be necessary. - // - // Finally, if this is a block-container, then we clear out any existing .locals object - // it may contain within it. This happens in incremental scenarios. Because we can be - // reusing a node from a previous compilation, that node may have had 'locals' created - // for it. We must clear this so we don't accidentally move any stale data forward from - // a previous compilation. - if (containerFlags & ContainerFlags.IsContainer) { - container = blockScopeContainer = node; - if (containerFlags & ContainerFlags.HasLocals) { - container.locals = createMap(); - } - addToContainerChain(container); - } - else if (containerFlags & ContainerFlags.IsBlockScopedContainer) { - blockScopeContainer = node; - blockScopeContainer.locals = undefined; - } - if (containerFlags & ContainerFlags.IsControlFlowContainer) { - const saveCurrentFlow = currentFlow; - const saveBreakTarget = currentBreakTarget; - const saveContinueTarget = currentContinueTarget; - const saveReturnTarget = currentReturnTarget; - const saveActiveLabels = activeLabels; - const saveHasExplicitReturn = hasExplicitReturn; - const isIIFE = containerFlags & ContainerFlags.IsFunctionExpression && !!getImmediatelyInvokedFunctionExpression(node); - // An IIFE is considered part of the containing control flow. Return statements behave - // similarly to break statements that exit to a label just past the statement body. - if (isIIFE) { - currentReturnTarget = createBranchLabel(); - } - else { - currentFlow = { flags: FlowFlags.Start }; - if (containerFlags & (ContainerFlags.IsFunctionExpression | ContainerFlags.IsObjectLiteralOrClassExpressionMethod)) { - (currentFlow).container = node; - } - currentReturnTarget = undefined; - } - currentBreakTarget = undefined; - currentContinueTarget = undefined; - activeLabels = undefined; - hasExplicitReturn = false; - bindChildren(node); - // Reset all reachability check related flags on node (for incremental scenarios) - // Reset all emit helper flags on node (for incremental scenarios) - node.flags &= ~NodeFlags.ReachabilityAndEmitFlags; - if (!(currentFlow.flags & FlowFlags.Unreachable) && containerFlags & ContainerFlags.IsFunctionLike && nodeIsPresent((node).body)) { - node.flags |= NodeFlags.HasImplicitReturn; - if (hasExplicitReturn) node.flags |= NodeFlags.HasExplicitReturn; - } - if (node.kind === SyntaxKind.SourceFile) { - node.flags |= emitFlags; - } - if (isIIFE) { - addAntecedent(currentReturnTarget, currentFlow); - currentFlow = finishFlowLabel(currentReturnTarget); - } - else { - currentFlow = saveCurrentFlow; - } - currentBreakTarget = saveBreakTarget; - currentContinueTarget = saveContinueTarget; - currentReturnTarget = saveReturnTarget; - activeLabels = saveActiveLabels; - hasExplicitReturn = saveHasExplicitReturn; - } - else if (containerFlags & ContainerFlags.IsInterface) { - seenThisKeyword = false; - bindChildren(node); - node.flags = seenThisKeyword ? node.flags | NodeFlags.ContainsThis : node.flags & ~NodeFlags.ContainsThis; - } - else { - bindChildren(node); - } - container = saveContainer; - blockScopeContainer = savedBlockScopeContainer; - } - - function bindChildren(node: Node): void { - if (skipTransformFlagAggregation) { - bindChildrenWorker(node); - } - else if (node.transformFlags & TransformFlags.HasComputedFlags) { - skipTransformFlagAggregation = true; - bindChildrenWorker(node); - skipTransformFlagAggregation = false; - } - else { - const savedSubtreeTransformFlags = subtreeTransformFlags; - subtreeTransformFlags = 0; - bindChildrenWorker(node); - subtreeTransformFlags = savedSubtreeTransformFlags | computeTransformFlagsForNode(node, subtreeTransformFlags); - } - } - - function bindChildrenWorker(node: Node): void { - // Binding of JsDocComment should be done before the current block scope container changes. - // because the scope of JsDocComment should not be affected by whether the current node is a - // container or not. - if (isInJavaScriptFile(node) && node.jsDocComments) { - forEach(node.jsDocComments, bind); - } - if (checkUnreachable(node)) { - forEachChild(node, bind); - return; - } - switch (node.kind) { - case SyntaxKind.WhileStatement: - bindWhileStatement(node); - break; - case SyntaxKind.DoStatement: - bindDoStatement(node); - break; - case SyntaxKind.ForStatement: - bindForStatement(node); - break; - case SyntaxKind.ForInStatement: - case SyntaxKind.ForOfStatement: - bindForInOrForOfStatement(node); - break; - case SyntaxKind.IfStatement: - bindIfStatement(node); - break; - case SyntaxKind.ReturnStatement: - case SyntaxKind.ThrowStatement: - bindReturnOrThrow(node); - break; - case SyntaxKind.BreakStatement: - case SyntaxKind.ContinueStatement: - bindBreakOrContinueStatement(node); - break; - case SyntaxKind.TryStatement: - bindTryStatement(node); - break; - case SyntaxKind.SwitchStatement: - bindSwitchStatement(node); - break; - case SyntaxKind.CaseBlock: - bindCaseBlock(node); - break; - case SyntaxKind.CaseClause: - bindCaseClause(node); - break; - case SyntaxKind.LabeledStatement: - bindLabeledStatement(node); - break; - case SyntaxKind.PrefixUnaryExpression: - bindPrefixUnaryExpressionFlow(node); - break; - case SyntaxKind.PostfixUnaryExpression: - bindPostfixUnaryExpressionFlow(node); - break; - case SyntaxKind.BinaryExpression: - bindBinaryExpressionFlow(node); - break; - case SyntaxKind.DeleteExpression: - bindDeleteExpressionFlow(node); - break; - case SyntaxKind.ConditionalExpression: - bindConditionalExpressionFlow(node); - break; - case SyntaxKind.VariableDeclaration: - bindVariableDeclarationFlow(node); - break; - case SyntaxKind.CallExpression: - bindCallExpressionFlow(node); - break; - default: - forEachChild(node, bind); - break; - } - } - - function isNarrowingExpression(expr: Expression): boolean { - switch (expr.kind) { - case SyntaxKind.Identifier: - case SyntaxKind.ThisKeyword: - case SyntaxKind.PropertyAccessExpression: - return isNarrowableReference(expr); - case SyntaxKind.CallExpression: - return hasNarrowableArgument(expr); - case SyntaxKind.ParenthesizedExpression: - return isNarrowingExpression((expr).expression); - case SyntaxKind.BinaryExpression: - return isNarrowingBinaryExpression(expr); - case SyntaxKind.PrefixUnaryExpression: - return (expr).operator === SyntaxKind.ExclamationToken && isNarrowingExpression((expr).operand); - } - return false; - } - - function isNarrowableReference(expr: Expression): boolean { - return expr.kind === SyntaxKind.Identifier || - expr.kind === SyntaxKind.ThisKeyword || - expr.kind === SyntaxKind.PropertyAccessExpression && isNarrowableReference((expr).expression); - } - - function hasNarrowableArgument(expr: CallExpression) { - if (expr.arguments) { - for (const argument of expr.arguments) { - if (isNarrowableReference(argument)) { - return true; - } - } - } - if (expr.expression.kind === SyntaxKind.PropertyAccessExpression && - isNarrowableReference((expr.expression).expression)) { - return true; - } - return false; - } - - function isNarrowingTypeofOperands(expr1: Expression, expr2: Expression) { - return expr1.kind === SyntaxKind.TypeOfExpression && isNarrowableOperand((expr1).expression) && expr2.kind === SyntaxKind.StringLiteral; - } - - function isNarrowingBinaryExpression(expr: BinaryExpression) { - switch (expr.operatorToken.kind) { - case SyntaxKind.EqualsToken: - return isNarrowableReference(expr.left); - case SyntaxKind.EqualsEqualsToken: - case SyntaxKind.ExclamationEqualsToken: - case SyntaxKind.EqualsEqualsEqualsToken: - case SyntaxKind.ExclamationEqualsEqualsToken: - return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || - isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case SyntaxKind.InstanceOfKeyword: - return isNarrowableOperand(expr.left); - case SyntaxKind.CommaToken: - return isNarrowingExpression(expr.right); - } - return false; - } - - function isNarrowableOperand(expr: Expression): boolean { - switch (expr.kind) { - case SyntaxKind.ParenthesizedExpression: - return isNarrowableOperand((expr).expression); - case SyntaxKind.BinaryExpression: - switch ((expr).operatorToken.kind) { - case SyntaxKind.EqualsToken: - return isNarrowableOperand((expr).left); - case SyntaxKind.CommaToken: - return isNarrowableOperand((expr).right); - } - } - return isNarrowableReference(expr); - } - - function createBranchLabel(): FlowLabel { - return { - flags: FlowFlags.BranchLabel, - antecedents: undefined - }; - } - - function createLoopLabel(): FlowLabel { - return { - flags: FlowFlags.LoopLabel, - antecedents: undefined - }; - } - - function setFlowNodeReferenced(flow: FlowNode) { - // On first reference we set the Referenced flag, thereafter we set the Shared flag - flow.flags |= flow.flags & FlowFlags.Referenced ? FlowFlags.Shared : FlowFlags.Referenced; - } - - function addAntecedent(label: FlowLabel, antecedent: FlowNode): void { - if (!(antecedent.flags & FlowFlags.Unreachable) && !contains(label.antecedents, antecedent)) { - (label.antecedents || (label.antecedents = [])).push(antecedent); - setFlowNodeReferenced(antecedent); - } - } - - function createFlowCondition(flags: FlowFlags, antecedent: FlowNode, expression: Expression): FlowNode { - if (antecedent.flags & FlowFlags.Unreachable) { - return antecedent; - } - if (!expression) { - return flags & FlowFlags.TrueCondition ? antecedent : unreachableFlow; - } - if (expression.kind === SyntaxKind.TrueKeyword && flags & FlowFlags.FalseCondition || - expression.kind === SyntaxKind.FalseKeyword && flags & FlowFlags.TrueCondition) { - return unreachableFlow; - } - if (!isNarrowingExpression(expression)) { - return antecedent; - } - setFlowNodeReferenced(antecedent); - return { - flags, - expression, - antecedent - }; - } - - function createFlowSwitchClause(antecedent: FlowNode, switchStatement: SwitchStatement, clauseStart: number, clauseEnd: number): FlowNode { - if (!isNarrowingExpression(switchStatement.expression)) { - return antecedent; - } - setFlowNodeReferenced(antecedent); - return { - flags: FlowFlags.SwitchClause, - switchStatement, - clauseStart, - clauseEnd, - antecedent - }; - } - - function createFlowAssignment(antecedent: FlowNode, node: Expression | VariableDeclaration | BindingElement): FlowNode { - setFlowNodeReferenced(antecedent); - return { - flags: FlowFlags.Assignment, - antecedent, - node - }; - } - - function createFlowArrayMutation(antecedent: FlowNode, node: CallExpression | BinaryExpression): FlowNode { - setFlowNodeReferenced(antecedent); - return { - flags: FlowFlags.ArrayMutation, - antecedent, - node - }; - } - - function finishFlowLabel(flow: FlowLabel): FlowNode { - const antecedents = flow.antecedents; - if (!antecedents) { - return unreachableFlow; - } - if (antecedents.length === 1) { - return antecedents[0]; - } - return flow; - } - - function isStatementCondition(node: Node) { - const parent = node.parent; - switch (parent.kind) { - case SyntaxKind.IfStatement: - case SyntaxKind.WhileStatement: - case SyntaxKind.DoStatement: - return (parent).expression === node; - case SyntaxKind.ForStatement: - case SyntaxKind.ConditionalExpression: - return (parent).condition === node; - } - return false; - } - - function isLogicalExpression(node: Node) { - while (true) { - if (node.kind === SyntaxKind.ParenthesizedExpression) { - node = (node).expression; - } - else if (node.kind === SyntaxKind.PrefixUnaryExpression && (node).operator === SyntaxKind.ExclamationToken) { - node = (node).operand; - } - else { - return node.kind === SyntaxKind.BinaryExpression && ( - (node).operatorToken.kind === SyntaxKind.AmpersandAmpersandToken || - (node).operatorToken.kind === SyntaxKind.BarBarToken); - } - } - } - - function isTopLevelLogicalExpression(node: Node): boolean { - while (node.parent.kind === SyntaxKind.ParenthesizedExpression || - node.parent.kind === SyntaxKind.PrefixUnaryExpression && - (node.parent).operator === SyntaxKind.ExclamationToken) { - node = node.parent; - } - return !isStatementCondition(node) && !isLogicalExpression(node.parent); - } - - function bindCondition(node: Expression, trueTarget: FlowLabel, falseTarget: FlowLabel) { - const saveTrueTarget = currentTrueTarget; - const saveFalseTarget = currentFalseTarget; - currentTrueTarget = trueTarget; - currentFalseTarget = falseTarget; - bind(node); - currentTrueTarget = saveTrueTarget; - currentFalseTarget = saveFalseTarget; - if (!node || !isLogicalExpression(node)) { - addAntecedent(trueTarget, createFlowCondition(FlowFlags.TrueCondition, currentFlow, node)); - addAntecedent(falseTarget, createFlowCondition(FlowFlags.FalseCondition, currentFlow, node)); - } - } - - function bindIterativeStatement(node: Statement, breakTarget: FlowLabel, continueTarget: FlowLabel): void { - const saveBreakTarget = currentBreakTarget; - const saveContinueTarget = currentContinueTarget; - currentBreakTarget = breakTarget; - currentContinueTarget = continueTarget; - bind(node); - currentBreakTarget = saveBreakTarget; - currentContinueTarget = saveContinueTarget; - } - - function bindWhileStatement(node: WhileStatement): void { - const preWhileLabel = createLoopLabel(); - const preBodyLabel = createBranchLabel(); - const postWhileLabel = createBranchLabel(); - addAntecedent(preWhileLabel, currentFlow); - currentFlow = preWhileLabel; - bindCondition(node.expression, preBodyLabel, postWhileLabel); - currentFlow = finishFlowLabel(preBodyLabel); - bindIterativeStatement(node.statement, postWhileLabel, preWhileLabel); - addAntecedent(preWhileLabel, currentFlow); - currentFlow = finishFlowLabel(postWhileLabel); - } - - function bindDoStatement(node: DoStatement): void { - const preDoLabel = createLoopLabel(); - const preConditionLabel = createBranchLabel(); - const postDoLabel = createBranchLabel(); - addAntecedent(preDoLabel, currentFlow); - currentFlow = preDoLabel; - bindIterativeStatement(node.statement, postDoLabel, preConditionLabel); - addAntecedent(preConditionLabel, currentFlow); - currentFlow = finishFlowLabel(preConditionLabel); - bindCondition(node.expression, preDoLabel, postDoLabel); - currentFlow = finishFlowLabel(postDoLabel); - } - - function bindForStatement(node: ForStatement): void { - const preLoopLabel = createLoopLabel(); - const preBodyLabel = createBranchLabel(); - const postLoopLabel = createBranchLabel(); - bind(node.initializer); - addAntecedent(preLoopLabel, currentFlow); - currentFlow = preLoopLabel; - bindCondition(node.condition, preBodyLabel, postLoopLabel); - currentFlow = finishFlowLabel(preBodyLabel); - bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); - bind(node.incrementor); - addAntecedent(preLoopLabel, currentFlow); - currentFlow = finishFlowLabel(postLoopLabel); - } - - function bindForInOrForOfStatement(node: ForInStatement | ForOfStatement): void { - const preLoopLabel = createLoopLabel(); - const postLoopLabel = createBranchLabel(); - addAntecedent(preLoopLabel, currentFlow); - currentFlow = preLoopLabel; - bind(node.expression); - addAntecedent(postLoopLabel, currentFlow); - bind(node.initializer); - if (node.initializer.kind !== SyntaxKind.VariableDeclarationList) { - bindAssignmentTargetFlow(node.initializer); - } - bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); - addAntecedent(preLoopLabel, currentFlow); - currentFlow = finishFlowLabel(postLoopLabel); - } - - function bindIfStatement(node: IfStatement): void { - const thenLabel = createBranchLabel(); - const elseLabel = createBranchLabel(); - const postIfLabel = createBranchLabel(); - bindCondition(node.expression, thenLabel, elseLabel); - currentFlow = finishFlowLabel(thenLabel); - bind(node.thenStatement); - addAntecedent(postIfLabel, currentFlow); - currentFlow = finishFlowLabel(elseLabel); - bind(node.elseStatement); - addAntecedent(postIfLabel, currentFlow); - currentFlow = finishFlowLabel(postIfLabel); - } - - function bindReturnOrThrow(node: ReturnStatement | ThrowStatement): void { - bind(node.expression); - if (node.kind === SyntaxKind.ReturnStatement) { - hasExplicitReturn = true; - if (currentReturnTarget) { - addAntecedent(currentReturnTarget, currentFlow); - } - } - currentFlow = unreachableFlow; - } - - function findActiveLabel(name: string) { - if (activeLabels) { - for (const label of activeLabels) { - if (label.name === name) { - return label; - } - } - } - return undefined; - } - - function bindbreakOrContinueFlow(node: BreakOrContinueStatement, breakTarget: FlowLabel, continueTarget: FlowLabel) { - const flowLabel = node.kind === SyntaxKind.BreakStatement ? breakTarget : continueTarget; - if (flowLabel) { - addAntecedent(flowLabel, currentFlow); - currentFlow = unreachableFlow; - } - } - - function bindBreakOrContinueStatement(node: BreakOrContinueStatement): void { - bind(node.label); - if (node.label) { - const activeLabel = findActiveLabel(node.label.text); - if (activeLabel) { - activeLabel.referenced = true; - bindbreakOrContinueFlow(node, activeLabel.breakTarget, activeLabel.continueTarget); - } - } - else { - bindbreakOrContinueFlow(node, currentBreakTarget, currentContinueTarget); - } - } - - function bindTryStatement(node: TryStatement): void { - const postFinallyLabel = createBranchLabel(); - const preTryFlow = currentFlow; - // TODO: Every statement in try block is potentially an exit point! - bind(node.tryBlock); - addAntecedent(postFinallyLabel, currentFlow); - if (node.catchClause) { - currentFlow = preTryFlow; - bind(node.catchClause); - addAntecedent(postFinallyLabel, currentFlow); - } - if (node.finallyBlock) { - currentFlow = preTryFlow; - bind(node.finallyBlock); - } - // if try statement has finally block and flow after finally block is unreachable - keep it - // otherwise use whatever flow was accumulated at postFinallyLabel - if (!node.finallyBlock || !(currentFlow.flags & FlowFlags.Unreachable)) { - currentFlow = finishFlowLabel(postFinallyLabel); - } - } - - function bindSwitchStatement(node: SwitchStatement): void { - const postSwitchLabel = createBranchLabel(); - bind(node.expression); - const saveBreakTarget = currentBreakTarget; - const savePreSwitchCaseFlow = preSwitchCaseFlow; - currentBreakTarget = postSwitchLabel; - preSwitchCaseFlow = currentFlow; - bind(node.caseBlock); - addAntecedent(postSwitchLabel, currentFlow); - const hasDefault = forEach(node.caseBlock.clauses, c => c.kind === SyntaxKind.DefaultClause); - // We mark a switch statement as possibly exhaustive if it has no default clause and if all - // case clauses have unreachable end points (e.g. they all return). - node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; - if (!hasDefault) { - addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0)); - } - currentBreakTarget = saveBreakTarget; - preSwitchCaseFlow = savePreSwitchCaseFlow; - currentFlow = finishFlowLabel(postSwitchLabel); - } - - function bindCaseBlock(node: CaseBlock): void { - const clauses = node.clauses; - let fallthroughFlow = unreachableFlow; - for (let i = 0; i < clauses.length; i++) { - const clauseStart = i; - while (!clauses[i].statements.length && i + 1 < clauses.length) { - bind(clauses[i]); - i++; - } - const preCaseLabel = createBranchLabel(); - addAntecedent(preCaseLabel, createFlowSwitchClause(preSwitchCaseFlow, node.parent, clauseStart, i + 1)); - addAntecedent(preCaseLabel, fallthroughFlow); - currentFlow = finishFlowLabel(preCaseLabel); - const clause = clauses[i]; - bind(clause); - fallthroughFlow = currentFlow; - if (!(currentFlow.flags & FlowFlags.Unreachable) && i !== clauses.length - 1 && options.noFallthroughCasesInSwitch) { - errorOnFirstToken(clause, Diagnostics.Fallthrough_case_in_switch); - } - } - } - - function bindCaseClause(node: CaseClause): void { - const saveCurrentFlow = currentFlow; - currentFlow = preSwitchCaseFlow; - bind(node.expression); - currentFlow = saveCurrentFlow; - forEach(node.statements, bind); - } - - function pushActiveLabel(name: string, breakTarget: FlowLabel, continueTarget: FlowLabel): ActiveLabel { - const activeLabel = { - name, - breakTarget, - continueTarget, - referenced: false - }; - (activeLabels || (activeLabels = [])).push(activeLabel); - return activeLabel; - } - - function popActiveLabel() { - activeLabels.pop(); - } - - function bindLabeledStatement(node: LabeledStatement): void { - const preStatementLabel = createLoopLabel(); - const postStatementLabel = createBranchLabel(); - bind(node.label); - addAntecedent(preStatementLabel, currentFlow); - const activeLabel = pushActiveLabel(node.label.text, postStatementLabel, preStatementLabel); - bind(node.statement); - popActiveLabel(); - if (!activeLabel.referenced && !options.allowUnusedLabels) { - file.bindDiagnostics.push(createDiagnosticForNode(node.label, Diagnostics.Unused_label)); - } - addAntecedent(postStatementLabel, currentFlow); - currentFlow = finishFlowLabel(postStatementLabel); - } - - function bindDestructuringTargetFlow(node: Expression) { - if (node.kind === SyntaxKind.BinaryExpression && (node).operatorToken.kind === SyntaxKind.EqualsToken) { - bindAssignmentTargetFlow((node).left); - } - else { - bindAssignmentTargetFlow(node); - } - } - - function bindAssignmentTargetFlow(node: Expression) { - if (isNarrowableReference(node)) { - currentFlow = createFlowAssignment(currentFlow, node); - } - else if (node.kind === SyntaxKind.ArrayLiteralExpression) { - for (const e of (node).elements) { - if (e.kind === SyntaxKind.SpreadElementExpression) { - bindAssignmentTargetFlow((e).expression); - } - else { - bindDestructuringTargetFlow(e); - } - } - } - else if (node.kind === SyntaxKind.ObjectLiteralExpression) { - for (const p of (node).properties) { - if (p.kind === SyntaxKind.PropertyAssignment) { - bindDestructuringTargetFlow((p).initializer); - } - else if (p.kind === SyntaxKind.ShorthandPropertyAssignment) { - bindAssignmentTargetFlow((p).name); - } - } - } - } - - function bindLogicalExpression(node: BinaryExpression, trueTarget: FlowLabel, falseTarget: FlowLabel) { - const preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === SyntaxKind.AmpersandAmpersandToken) { - bindCondition(node.left, preRightLabel, falseTarget); - } - else { - bindCondition(node.left, trueTarget, preRightLabel); - } - currentFlow = finishFlowLabel(preRightLabel); - bind(node.operatorToken); - bindCondition(node.right, trueTarget, falseTarget); - } - - function bindPrefixUnaryExpressionFlow(node: PrefixUnaryExpression) { - if (node.operator === SyntaxKind.ExclamationToken) { - const saveTrueTarget = currentTrueTarget; - currentTrueTarget = currentFalseTarget; - currentFalseTarget = saveTrueTarget; - forEachChild(node, bind); - currentFalseTarget = currentTrueTarget; - currentTrueTarget = saveTrueTarget; - } - else { - forEachChild(node, bind); - if (node.operator === SyntaxKind.PlusPlusToken || node.operator === SyntaxKind.MinusMinusToken) { - bindAssignmentTargetFlow(node.operand); - } - } - } - - function bindPostfixUnaryExpressionFlow(node: PostfixUnaryExpression) { - forEachChild(node, bind); - if (node.operator === SyntaxKind.PlusPlusToken || node.operator === SyntaxKind.MinusMinusToken) { - bindAssignmentTargetFlow(node.operand); - } - } - - function bindBinaryExpressionFlow(node: BinaryExpression) { - const operator = node.operatorToken.kind; - if (operator === SyntaxKind.AmpersandAmpersandToken || operator === SyntaxKind.BarBarToken) { - if (isTopLevelLogicalExpression(node)) { - const postExpressionLabel = createBranchLabel(); - bindLogicalExpression(node, postExpressionLabel, postExpressionLabel); - currentFlow = finishFlowLabel(postExpressionLabel); - } - else { - bindLogicalExpression(node, currentTrueTarget, currentFalseTarget); - } - } - else { - forEachChild(node, bind); - if (operator === SyntaxKind.EqualsToken && !isAssignmentTarget(node)) { - bindAssignmentTargetFlow(node.left); - if (node.left.kind === SyntaxKind.ElementAccessExpression) { - const elementAccess = node.left; - if (isNarrowableOperand(elementAccess.expression)) { - currentFlow = createFlowArrayMutation(currentFlow, node); - } - } - } - } - } - - function bindDeleteExpressionFlow(node: DeleteExpression) { - forEachChild(node, bind); - if (node.expression.kind === SyntaxKind.PropertyAccessExpression) { - bindAssignmentTargetFlow(node.expression); - } - } - - function bindConditionalExpressionFlow(node: ConditionalExpression) { - const trueLabel = createBranchLabel(); - const falseLabel = createBranchLabel(); - const postExpressionLabel = createBranchLabel(); - bindCondition(node.condition, trueLabel, falseLabel); - currentFlow = finishFlowLabel(trueLabel); - bind(node.whenTrue); - addAntecedent(postExpressionLabel, currentFlow); - currentFlow = finishFlowLabel(falseLabel); - bind(node.whenFalse); - addAntecedent(postExpressionLabel, currentFlow); - currentFlow = finishFlowLabel(postExpressionLabel); - } - - function bindInitializedVariableFlow(node: VariableDeclaration | ArrayBindingElement) { - const name = !isOmittedExpression(node) ? node.name : undefined; - if (isBindingPattern(name)) { - for (const child of name.elements) { - bindInitializedVariableFlow(child); - } - } - else { - currentFlow = createFlowAssignment(currentFlow, node); - } - } - - function bindVariableDeclarationFlow(node: VariableDeclaration) { - forEachChild(node, bind); - if (node.initializer || node.parent.parent.kind === SyntaxKind.ForInStatement || node.parent.parent.kind === SyntaxKind.ForOfStatement) { - bindInitializedVariableFlow(node); - } - } - - function bindCallExpressionFlow(node: CallExpression) { - // If the target of the call expression is a function expression or arrow function we have - // an immediately invoked function expression (IIFE). Initialize the flowNode property to - // the current control flow (which includes evaluation of the IIFE arguments). - let expr: Expression = node.expression; - while (expr.kind === SyntaxKind.ParenthesizedExpression) { - expr = (expr).expression; - } - if (expr.kind === SyntaxKind.FunctionExpression || expr.kind === SyntaxKind.ArrowFunction) { - forEach(node.typeArguments, bind); - forEach(node.arguments, bind); - bind(node.expression); - } - else { - forEachChild(node, bind); - } - if (node.expression.kind === SyntaxKind.PropertyAccessExpression) { - const propertyAccess = node.expression; - if (isNarrowableOperand(propertyAccess.expression) && isPushOrUnshiftIdentifier(propertyAccess.name)) { - currentFlow = createFlowArrayMutation(currentFlow, node); - } - } - } - - function getContainerFlags(node: Node): ContainerFlags { - switch (node.kind) { - case SyntaxKind.ClassExpression: - case SyntaxKind.ClassDeclaration: - case SyntaxKind.EnumDeclaration: - case SyntaxKind.ObjectLiteralExpression: - case SyntaxKind.TypeLiteral: - case SyntaxKind.JSDocTypeLiteral: - case SyntaxKind.JSDocRecordType: - return ContainerFlags.IsContainer; - - case SyntaxKind.InterfaceDeclaration: - return ContainerFlags.IsContainer | ContainerFlags.IsInterface; - - case SyntaxKind.JSDocFunctionType: - case SyntaxKind.ModuleDeclaration: - case SyntaxKind.TypeAliasDeclaration: - return ContainerFlags.IsContainer | ContainerFlags.HasLocals; - - case SyntaxKind.SourceFile: - return ContainerFlags.IsContainer | ContainerFlags.IsControlFlowContainer | ContainerFlags.HasLocals; - - case SyntaxKind.MethodDeclaration: - if (isObjectLiteralOrClassExpressionMethod(node)) { - return ContainerFlags.IsContainer | ContainerFlags.IsControlFlowContainer | ContainerFlags.HasLocals | ContainerFlags.IsFunctionLike | ContainerFlags.IsObjectLiteralOrClassExpressionMethod; - } - case SyntaxKind.Constructor: - case SyntaxKind.FunctionDeclaration: - case SyntaxKind.MethodSignature: - case SyntaxKind.GetAccessor: - case SyntaxKind.SetAccessor: - case SyntaxKind.CallSignature: - case SyntaxKind.ConstructSignature: - case SyntaxKind.IndexSignature: - case SyntaxKind.FunctionType: - case SyntaxKind.ConstructorType: - return ContainerFlags.IsContainer | ContainerFlags.IsControlFlowContainer | ContainerFlags.HasLocals | ContainerFlags.IsFunctionLike; - - case SyntaxKind.FunctionExpression: - case SyntaxKind.ArrowFunction: - return ContainerFlags.IsContainer | ContainerFlags.IsControlFlowContainer | ContainerFlags.HasLocals | ContainerFlags.IsFunctionLike | ContainerFlags.IsFunctionExpression; - - case SyntaxKind.ModuleBlock: - return ContainerFlags.IsControlFlowContainer; - case SyntaxKind.PropertyDeclaration: - return (node).initializer ? ContainerFlags.IsControlFlowContainer : 0; - - case SyntaxKind.CatchClause: - case SyntaxKind.ForStatement: - case SyntaxKind.ForInStatement: - case SyntaxKind.ForOfStatement: - case SyntaxKind.CaseBlock: - return ContainerFlags.IsBlockScopedContainer; - - case SyntaxKind.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. Otherwise 'x' - // would not appear to be a redeclaration of a block scoped local in the following - // example: - // - // function foo() { - // var x; - // let x; - // } - // - // If we placed 'var x' into the function locals and 'let x' into the locals of - // the block, then there would be no collision. - // - // By not creating a new block-scoped-container here, we ensure that both 'var x' - // and 'let x' go into the Function-container's locals, and we do get a collision - // conflict. - return isFunctionLike(node.parent) ? ContainerFlags.None : ContainerFlags.IsBlockScopedContainer; - } - - return ContainerFlags.None; - } - - function addToContainerChain(next: Node) { - if (lastContainer) { - lastContainer.nextContainer = next; - } - - lastContainer = next; - } - - function declareSymbolAndAddToSymbolTable(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags): Symbol { - // Just call this directly so that the return type of this function stays "void". - return declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes); - } - - function declareSymbolAndAddToSymbolTableWorker(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags): Symbol { - switch (container.kind) { - // Modules, source files, and classes need specialized handling for how their - // 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 SyntaxKind.ModuleDeclaration: - return declareModuleMember(node, symbolFlags, symbolExcludes); - - case SyntaxKind.SourceFile: - return declareSourceFileMember(node, symbolFlags, symbolExcludes); - - case SyntaxKind.ClassExpression: - case SyntaxKind.ClassDeclaration: - return declareClassMember(node, symbolFlags, symbolExcludes); - - case SyntaxKind.EnumDeclaration: - return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - - case SyntaxKind.TypeLiteral: - case SyntaxKind.ObjectLiteralExpression: - case SyntaxKind.InterfaceDeclaration: - case SyntaxKind.JSDocRecordType: - case SyntaxKind.JSDocTypeLiteral: - // 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 SyntaxKind.FunctionType: - case SyntaxKind.ConstructorType: - case SyntaxKind.CallSignature: - case SyntaxKind.ConstructSignature: - case SyntaxKind.IndexSignature: - case SyntaxKind.MethodDeclaration: - case SyntaxKind.MethodSignature: - case SyntaxKind.Constructor: - case SyntaxKind.GetAccessor: - case SyntaxKind.SetAccessor: - case SyntaxKind.FunctionDeclaration: - case SyntaxKind.FunctionExpression: - case SyntaxKind.ArrowFunction: - case SyntaxKind.JSDocFunctionType: - case SyntaxKind.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 - // their container in the tree. To accomplish this, we simply add their declared - // symbol to the 'locals' of the container. These symbols can then be found as - // the type checker walks up the containers, checking them for matching names. - return declareSymbol(container.locals, /*parent*/ undefined, node, symbolFlags, symbolExcludes); - } - } - - function declareClassMember(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags) { - return hasModifier(node, ModifierFlags.Static) - ? declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes) - : declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - } - - function declareSourceFileMember(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags) { - return isExternalModule(file) - ? declareModuleMember(node, symbolFlags, symbolExcludes) - : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); - } - - function hasExportDeclarations(node: ModuleDeclaration | SourceFile): boolean { - const body = node.kind === SyntaxKind.SourceFile ? node : (node).body; - if (body && (body.kind === SyntaxKind.SourceFile || body.kind === SyntaxKind.ModuleBlock)) { - for (const stat of (body).statements) { - if (stat.kind === SyntaxKind.ExportDeclaration || stat.kind === SyntaxKind.ExportAssignment) { - return true; - } - } - } - return false; - } - - function setExportContextFlag(node: ModuleDeclaration | SourceFile) { - // A declaration source file or ambient module declaration that contains no export declarations (but possibly regular - // declarations with export modifiers) is an export context in which declarations are implicitly exported. - if (isInAmbientContext(node) && !hasExportDeclarations(node)) { - node.flags |= NodeFlags.ExportContext; - } - else { - node.flags &= ~NodeFlags.ExportContext; - } - } - - function bindModuleDeclaration(node: ModuleDeclaration) { - setExportContextFlag(node); - if (isAmbientModule(node)) { - if (hasModifier(node, ModifierFlags.Export)) { - errorOnFirstToken(node, Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible); - } - if (isExternalModuleAugmentation(node)) { - declareSymbolAndAddToSymbolTable(node, SymbolFlags.NamespaceModule, SymbolFlags.NamespaceModuleExcludes); - } - else { - let pattern: Pattern | undefined; - if (node.name.kind === SyntaxKind.StringLiteral) { - const text = (node.name).text; - if (hasZeroOrOneAsteriskCharacter(text)) { - pattern = tryParsePattern(text); - } - else { - errorOnFirstToken(node.name, Diagnostics.Pattern_0_can_have_at_most_one_Asterisk_character, text); - } - } - - const symbol = declareSymbolAndAddToSymbolTable(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes); - - if (pattern) { - (file.patternAmbientModules || (file.patternAmbientModules = [])).push({ pattern, symbol }); - } - } - } - else { - const state = getModuleInstanceState(node); - if (state === ModuleInstanceState.NonInstantiated) { - declareSymbolAndAddToSymbolTable(node, SymbolFlags.NamespaceModule, SymbolFlags.NamespaceModuleExcludes); - } - else { - declareSymbolAndAddToSymbolTable(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes); - if (node.symbol.flags & (SymbolFlags.Function | SymbolFlags.Class | SymbolFlags.RegularEnum)) { - // if module was already merged with some function, class or non-const enum - // treat is a non-const-enum-only - node.symbol.constEnumOnlyModule = false; - } - else { - const currentModuleIsConstEnumOnly = state === ModuleInstanceState.ConstEnumOnly; - if (node.symbol.constEnumOnlyModule === undefined) { - // non-merged case - use the current state - node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly; - } - else { - // merged case: module is const enum only if all its pieces are non-instantiated or const enum - node.symbol.constEnumOnlyModule = node.symbol.constEnumOnlyModule && currentModuleIsConstEnumOnly; - } - } - } - } - } - - function bindFunctionOrConstructorType(node: SignatureDeclaration): void { - // For a given function symbol "<...>(...) => T" we want to generate a symbol identical - // to the one we would get for: { <...>(...): T } - // - // We do that by making an anonymous type literal symbol, and then setting the function - // symbol as its sole member. To the rest of the system, this symbol will be indistinguishable - // from an actual type literal symbol you would have gotten had you used the long form. - const symbol = createSymbol(SymbolFlags.Signature, getDeclarationName(node)); - addDeclarationToSymbol(symbol, node, SymbolFlags.Signature); - - const typeLiteralSymbol = createSymbol(SymbolFlags.TypeLiteral, "__type"); - addDeclarationToSymbol(typeLiteralSymbol, node, SymbolFlags.TypeLiteral); - typeLiteralSymbol.members = createMap(); - typeLiteralSymbol.members[symbol.name] = symbol; - } - - function bindObjectLiteralExpression(node: ObjectLiteralExpression) { - const enum ElementKind { - Property = 1, - Accessor = 2 - } - - if (inStrictMode) { - const seen = createMap(); - - for (const prop of node.properties) { - if (prop.name.kind !== SyntaxKind.Identifier) { - continue; - } - - const identifier = prop.name; - - // ECMA-262 11.1.5 Object Initializer - // 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 - // IsDataDescriptor(propId.descriptor) is true. - // b.IsDataDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true. - // 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 - const currentKind = prop.kind === SyntaxKind.PropertyAssignment || prop.kind === SyntaxKind.ShorthandPropertyAssignment || prop.kind === SyntaxKind.MethodDeclaration - ? ElementKind.Property - : ElementKind.Accessor; - - const existingKind = seen[identifier.text]; - if (!existingKind) { - seen[identifier.text] = currentKind; - continue; - } - - if (currentKind === ElementKind.Property && existingKind === ElementKind.Property) { - const span = getErrorSpanForNode(file, identifier); - file.bindDiagnostics.push(createFileDiagnostic(file, span.start, span.length, - Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode)); - } - } - } - - return bindAnonymousDeclaration(node, SymbolFlags.ObjectLiteral, "__object"); - } - - function bindAnonymousDeclaration(node: Declaration, symbolFlags: SymbolFlags, name: string) { - const symbol = createSymbol(symbolFlags, name); - addDeclarationToSymbol(symbol, node, symbolFlags); - } - - function bindBlockScopedDeclaration(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags) { - switch (blockScopeContainer.kind) { - case SyntaxKind.ModuleDeclaration: - declareModuleMember(node, symbolFlags, symbolExcludes); - break; - case SyntaxKind.SourceFile: - if (isExternalModule(container)) { - declareModuleMember(node, symbolFlags, symbolExcludes); - break; - } - // fall through. - default: - if (!blockScopeContainer.locals) { - blockScopeContainer.locals = createMap(); - addToContainerChain(blockScopeContainer); - } - declareSymbol(blockScopeContainer.locals, undefined, node, symbolFlags, symbolExcludes); - } - } - - function bindBlockScopedVariableDeclaration(node: Declaration) { - bindBlockScopedDeclaration(node, SymbolFlags.BlockScopedVariable, SymbolFlags.BlockScopedVariableExcludes); - } - - // The binder visits every node in the syntax tree so it is a convenient place to perform a single localized - // check for reserved words used as identifiers in strict mode code. - function checkStrictModeIdentifier(node: Identifier) { - if (inStrictMode && - node.originalKeywordKind >= SyntaxKind.FirstFutureReservedWord && - node.originalKeywordKind <= SyntaxKind.LastFutureReservedWord && - !isIdentifierName(node) && - !isInAmbientContext(node)) { - - // Report error only if there are no parse errors in file - if (!file.parseDiagnostics.length) { - file.bindDiagnostics.push(createDiagnosticForNode(node, - getStrictModeIdentifierMessage(node), declarationNameToString(node))); - } - } - } - - function getStrictModeIdentifierMessage(node: Node) { - // Provide specialized messages to help the user understand why we think they're in - // strict mode. - if (getContainingClass(node)) { - return Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode; - } - - if (file.externalModuleIndicator) { - return Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode; - } - - return Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode; - } - - function checkStrictModeBinaryExpression(node: BinaryExpression) { - if (inStrictMode && isLeftHandSideExpression(node.left) && isAssignmentOperator(node.operatorToken.kind)) { - // ECMA 262 (Annex C) The identifier eval or arguments may not appear as the LeftHandSideExpression of an - // Assignment operator(11.13) or of a PostfixExpression(11.3) - checkStrictModeEvalOrArguments(node, node.left); - } - } - - function checkStrictModeCatchClause(node: CatchClause) { - // It is a SyntaxError if a TryStatement with a Catch occurs within strict code and the Identifier of the - // Catch production is eval or arguments - if (inStrictMode && node.variableDeclaration) { - checkStrictModeEvalOrArguments(node, node.variableDeclaration.name); - } - } - - function checkStrictModeDeleteExpression(node: DeleteExpression) { - // Grammar checking - if (inStrictMode && node.expression.kind === SyntaxKind.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 - const span = getErrorSpanForNode(file, node.expression); - file.bindDiagnostics.push(createFileDiagnostic(file, span.start, span.length, Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode)); - } - } - - function isEvalOrArgumentsIdentifier(node: Node): boolean { - return node.kind === SyntaxKind.Identifier && - ((node).text === "eval" || (node).text === "arguments"); - } - - function checkStrictModeEvalOrArguments(contextNode: Node, name: Node) { - if (name && name.kind === SyntaxKind.Identifier) { - const identifier = name; - if (isEvalOrArgumentsIdentifier(identifier)) { - // We check first if the name is inside class declaration or class expression; if so give explicit message - // otherwise report generic error message. - const span = getErrorSpanForNode(file, name); - file.bindDiagnostics.push(createFileDiagnostic(file, span.start, span.length, - getStrictModeEvalOrArgumentsMessage(contextNode), identifier.text)); - } - } - } - - function getStrictModeEvalOrArgumentsMessage(node: Node) { - // Provide specialized messages to help the user understand why we think they're in - // strict mode. - if (getContainingClass(node)) { - return Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode; - } - - if (file.externalModuleIndicator) { - return Diagnostics.Invalid_use_of_0_Modules_are_automatically_in_strict_mode; - } - - return Diagnostics.Invalid_use_of_0_in_strict_mode; - } - - function checkStrictModeFunctionName(node: FunctionLikeDeclaration) { - if (inStrictMode) { - // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a strict mode FunctionDeclaration or FunctionExpression (13.1)) - checkStrictModeEvalOrArguments(node, node.name); - } - } - - function getStrictModeBlockScopeFunctionDeclarationMessage(node: Node) { - // Provide specialized messages to help the user understand why we think they're in - // strict mode. - if (getContainingClass(node)) { - return Diagnostics.Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Class_definitions_are_automatically_in_strict_mode; - } - - if (file.externalModuleIndicator) { - return Diagnostics.Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_are_automatically_in_strict_mode; - } - - return Diagnostics.Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5; - } - - function checkStrictModeFunctionDeclaration(node: FunctionDeclaration) { - if (languageVersion < ScriptTarget.ES2015) { - // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== SyntaxKind.SourceFile && - blockScopeContainer.kind !== SyntaxKind.ModuleDeclaration && - !isFunctionLike(blockScopeContainer)) { - // We check first if the name is inside class declaration or class expression; if so give explicit message - // otherwise report generic error message. - const errorSpan = getErrorSpanForNode(file, node); - file.bindDiagnostics.push(createFileDiagnostic(file, errorSpan.start, errorSpan.length, - getStrictModeBlockScopeFunctionDeclarationMessage(node))); - } - } - } - - function checkStrictModeNumericLiteral(node: NumericLiteral) { - if (inStrictMode && node.isOctalLiteral) { - file.bindDiagnostics.push(createDiagnosticForNode(node, Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); - } - } - - function checkStrictModePostfixUnaryExpression(node: PostfixUnaryExpression) { - // Grammar checking - // The identifier eval or arguments may not appear as the LeftHandSideExpression of an - // Assignment operator(11.13) or of a PostfixExpression(11.3) or as the UnaryExpression - // operated upon by a Prefix Increment(11.4.4) or a Prefix Decrement(11.4.5) operator. - if (inStrictMode) { - checkStrictModeEvalOrArguments(node, node.operand); - } - } - - function checkStrictModePrefixUnaryExpression(node: PrefixUnaryExpression) { - // Grammar checking - if (inStrictMode) { - if (node.operator === SyntaxKind.PlusPlusToken || node.operator === SyntaxKind.MinusMinusToken) { - checkStrictModeEvalOrArguments(node, node.operand); - } - } - } - - function checkStrictModeWithStatement(node: WithStatement) { - // Grammar checking for withStatement - if (inStrictMode) { - errorOnFirstToken(node, Diagnostics.with_statements_are_not_allowed_in_strict_mode); - } - } - - function errorOnFirstToken(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any) { - const span = getSpanOfTokenAtPosition(file, node.pos); - file.bindDiagnostics.push(createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2)); - } - - function getDestructuringParameterName(node: Declaration) { - return "__" + indexOf((node.parent).parameters, node); - } - - function bind(node: Node): void { - if (!node) { - return; - } - node.parent = parent; - const saveInStrictMode = inStrictMode; - // First we bind declaration nodes to a symbol if possible. We'll both create a symbol - // and then potentially add the symbol to an appropriate symbol table. Possible - // destination symbol tables are: - // - // 1) The 'exports' table of the current container's symbol. - // 2) The 'members' table of the current container's symbol. - // 3) The 'locals' table of the current container. - // - // However, not all symbols will end up in any of these tables. 'Anonymous' symbols - // (like TypeLiterals for example) will not be put in any table. - bindWorker(node); - // Then we recurse into the children of the node to bind them as well. For certain - // symbols we do specialized work when we recurse. For example, we'll keep track of - // the current 'container' node when it changes. This helps us know which symbol table - // a local should go into for example. Since terminal nodes are known not to have - // children, as an optimization we don't process those. - if (node.kind > SyntaxKind.LastToken) { - const saveParent = parent; - parent = node; - const containerFlags = getContainerFlags(node); - if (containerFlags === ContainerFlags.None) { - bindChildren(node); - } - else { - bindContainer(node, containerFlags); - } - parent = saveParent; - } - else if (!skipTransformFlagAggregation && (node.transformFlags & TransformFlags.HasComputedFlags) === 0) { - subtreeTransformFlags |= computeTransformFlagsForNode(node, 0); - } - inStrictMode = saveInStrictMode; - } - - function updateStrictModeStatementList(statements: NodeArray) { - if (!inStrictMode) { - for (const statement of statements) { - if (!isPrologueDirective(statement)) { - return; - } - - if (isUseStrictPrologueDirective(statement)) { - inStrictMode = true; - return; - } - } - } - } - - /// Should be called only on prologue directives (isPrologueDirective(node) should be true) - function isUseStrictPrologueDirective(node: ExpressionStatement): boolean { - const nodeText = getTextOfNodeFromSourceText(file.text, node.expression); - - // Note: the node text must be exactly "use strict" or 'use strict'. It is not ok for the - // string to contain unicode escapes (as per ES5). - return nodeText === '"use strict"' || nodeText === "'use strict'"; - } - - function bindWorker(node: Node) { - switch (node.kind) { - /* Strict mode checks */ - case SyntaxKind.Identifier: - case SyntaxKind.ThisKeyword: - if (currentFlow && (isExpression(node) || parent.kind === SyntaxKind.ShorthandPropertyAssignment)) { - node.flowNode = currentFlow; - } - return checkStrictModeIdentifier(node); - case SyntaxKind.PropertyAccessExpression: - if (currentFlow && isNarrowableReference(node)) { - node.flowNode = currentFlow; - } - break; - case SyntaxKind.BinaryExpression: - if (isInJavaScriptFile(node)) { - const specialKind = getSpecialPropertyAssignmentKind(node); - switch (specialKind) { - case SpecialPropertyAssignmentKind.ExportsProperty: - bindExportsPropertyAssignment(node); - break; - case SpecialPropertyAssignmentKind.ModuleExports: - bindModuleExportsAssignment(node); - break; - case SpecialPropertyAssignmentKind.PrototypeProperty: - bindPrototypePropertyAssignment(node); - break; - case SpecialPropertyAssignmentKind.ThisProperty: - bindThisPropertyAssignment(node); - break; - case SpecialPropertyAssignmentKind.None: - // Nothing to do - break; - default: - Debug.fail("Unknown special property assignment kind"); - } - } - return checkStrictModeBinaryExpression(node); - case SyntaxKind.CatchClause: - return checkStrictModeCatchClause(node); - case SyntaxKind.DeleteExpression: - return checkStrictModeDeleteExpression(node); - case SyntaxKind.NumericLiteral: - return checkStrictModeNumericLiteral(node); - case SyntaxKind.PostfixUnaryExpression: - return checkStrictModePostfixUnaryExpression(node); - case SyntaxKind.PrefixUnaryExpression: - return checkStrictModePrefixUnaryExpression(node); - case SyntaxKind.WithStatement: - return checkStrictModeWithStatement(node); - case SyntaxKind.ThisType: - seenThisKeyword = true; - return; - case SyntaxKind.TypePredicate: - return checkTypePredicate(node as TypePredicateNode); - case SyntaxKind.TypeParameter: - return declareSymbolAndAddToSymbolTable(node, SymbolFlags.TypeParameter, SymbolFlags.TypeParameterExcludes); - case SyntaxKind.Parameter: - return bindParameter(node); - case SyntaxKind.VariableDeclaration: - case SyntaxKind.BindingElement: - return bindVariableDeclarationOrBindingElement(node); - case SyntaxKind.PropertyDeclaration: - case SyntaxKind.PropertySignature: - case SyntaxKind.JSDocRecordMember: - return bindPropertyOrMethodOrAccessor(node, SymbolFlags.Property | ((node).questionToken ? SymbolFlags.Optional : SymbolFlags.None), SymbolFlags.PropertyExcludes); - case SyntaxKind.JSDocPropertyTag: - return bindJSDocProperty(node); - case SyntaxKind.PropertyAssignment: - case SyntaxKind.ShorthandPropertyAssignment: - return bindPropertyOrMethodOrAccessor(node, SymbolFlags.Property, SymbolFlags.PropertyExcludes); - case SyntaxKind.EnumMember: - return bindPropertyOrMethodOrAccessor(node, SymbolFlags.EnumMember, SymbolFlags.EnumMemberExcludes); - - case SyntaxKind.JsxSpreadAttribute: - emitFlags |= NodeFlags.HasJsxSpreadAttributes; - return; - - case SyntaxKind.CallSignature: - case SyntaxKind.ConstructSignature: - case SyntaxKind.IndexSignature: - return declareSymbolAndAddToSymbolTable(node, SymbolFlags.Signature, SymbolFlags.None); - case SyntaxKind.MethodDeclaration: - case SyntaxKind.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, SymbolFlags.Method | ((node).questionToken ? SymbolFlags.Optional : SymbolFlags.None), - isObjectLiteralMethod(node) ? SymbolFlags.PropertyExcludes : SymbolFlags.MethodExcludes); - case SyntaxKind.FunctionDeclaration: - return bindFunctionDeclaration(node); - case SyntaxKind.Constructor: - return declareSymbolAndAddToSymbolTable(node, SymbolFlags.Constructor, /*symbolExcludes:*/ SymbolFlags.None); - case SyntaxKind.GetAccessor: - return bindPropertyOrMethodOrAccessor(node, SymbolFlags.GetAccessor, SymbolFlags.GetAccessorExcludes); - case SyntaxKind.SetAccessor: - return bindPropertyOrMethodOrAccessor(node, SymbolFlags.SetAccessor, SymbolFlags.SetAccessorExcludes); - case SyntaxKind.FunctionType: - case SyntaxKind.ConstructorType: - case SyntaxKind.JSDocFunctionType: - return bindFunctionOrConstructorType(node); - case SyntaxKind.TypeLiteral: - case SyntaxKind.JSDocTypeLiteral: - case SyntaxKind.JSDocRecordType: - return bindAnonymousDeclaration(node, SymbolFlags.TypeLiteral, "__type"); - case SyntaxKind.ObjectLiteralExpression: - return bindObjectLiteralExpression(node); - case SyntaxKind.FunctionExpression: - case SyntaxKind.ArrowFunction: - return bindFunctionExpression(node); - - case SyntaxKind.CallExpression: - if (isInJavaScriptFile(node)) { - bindCallExpression(node); - } - break; - - // Members of classes, interfaces, and modules - case SyntaxKind.ClassExpression: - case SyntaxKind.ClassDeclaration: - // All classes are automatically in strict mode in ES6. - inStrictMode = true; - return bindClassLikeDeclaration(node); - case SyntaxKind.InterfaceDeclaration: - return bindBlockScopedDeclaration(node, SymbolFlags.Interface, SymbolFlags.InterfaceExcludes); - case SyntaxKind.JSDocTypedefTag: - case SyntaxKind.TypeAliasDeclaration: - return bindBlockScopedDeclaration(node, SymbolFlags.TypeAlias, SymbolFlags.TypeAliasExcludes); - case SyntaxKind.EnumDeclaration: - return bindEnumDeclaration(node); - case SyntaxKind.ModuleDeclaration: - return bindModuleDeclaration(node); - - // Imports and exports - case SyntaxKind.ImportEqualsDeclaration: - case SyntaxKind.NamespaceImport: - case SyntaxKind.ImportSpecifier: - case SyntaxKind.ExportSpecifier: - return declareSymbolAndAddToSymbolTable(node, SymbolFlags.Alias, SymbolFlags.AliasExcludes); - case SyntaxKind.NamespaceExportDeclaration: - return bindNamespaceExportDeclaration(node); - case SyntaxKind.ImportClause: - return bindImportClause(node); - case SyntaxKind.ExportDeclaration: - return bindExportDeclaration(node); - case SyntaxKind.ExportAssignment: - return bindExportAssignment(node); - case SyntaxKind.SourceFile: - updateStrictModeStatementList((node).statements); - return bindSourceFileIfExternalModule(); - case SyntaxKind.Block: - if (!isFunctionLike(node.parent)) { - return; - } - // Fall through - case SyntaxKind.ModuleBlock: - return updateStrictModeStatementList((node).statements); - } - } - - function checkTypePredicate(node: TypePredicateNode) { - const { parameterName, type } = node; - if (parameterName && parameterName.kind === SyntaxKind.Identifier) { - checkStrictModeIdentifier(parameterName as Identifier); - } - if (parameterName && parameterName.kind === SyntaxKind.ThisType) { - seenThisKeyword = true; - } - bind(type); - } - - function bindSourceFileIfExternalModule() { - setExportContextFlag(file); - if (isExternalModule(file)) { - bindSourceFileAsExternalModule(); - } - } - - function bindSourceFileAsExternalModule() { - bindAnonymousDeclaration(file, SymbolFlags.ValueModule, `"${removeFileExtension(file.fileName) }"`); - } - - function bindExportAssignment(node: ExportAssignment | BinaryExpression) { - if (!container.symbol || !container.symbol.exports) { - // Export assignment in some sort of block construct - bindAnonymousDeclaration(node, SymbolFlags.Alias, getDeclarationName(node)); - } - else { - // An export default clause with an expression exports a value - // We want to exclude both class and function here, this is necessary to issue an error when there are both - // default export-assignment and default export function and class declaration. - const flags = node.kind === SyntaxKind.ExportAssignment && exportAssignmentIsAlias(node) - // An export default clause with an EntityNameExpression exports all meanings of that identifier - ? SymbolFlags.Alias - // An export default clause with any other expression exports a value - : SymbolFlags.Property; - declareSymbol(container.symbol.exports, container.symbol, node, flags, SymbolFlags.Property | SymbolFlags.AliasExcludes | SymbolFlags.Class | SymbolFlags.Function); - } - } - - function bindNamespaceExportDeclaration(node: NamespaceExportDeclaration) { - if (node.modifiers && node.modifiers.length) { - file.bindDiagnostics.push(createDiagnosticForNode(node, Diagnostics.Modifiers_cannot_appear_here)); - } - - if (node.parent.kind !== SyntaxKind.SourceFile) { - file.bindDiagnostics.push(createDiagnosticForNode(node, Diagnostics.Global_module_exports_may_only_appear_at_top_level)); - return; - } - else { - const parent = node.parent as SourceFile; - - if (!isExternalModule(parent)) { - file.bindDiagnostics.push(createDiagnosticForNode(node, Diagnostics.Global_module_exports_may_only_appear_in_module_files)); - return; - } - - if (!parent.isDeclarationFile) { - file.bindDiagnostics.push(createDiagnosticForNode(node, Diagnostics.Global_module_exports_may_only_appear_in_declaration_files)); - return; - } - } - - file.symbol.globalExports = file.symbol.globalExports || createMap(); - declareSymbol(file.symbol.globalExports, file.symbol, node, SymbolFlags.Alias, SymbolFlags.AliasExcludes); - } - - function bindExportDeclaration(node: ExportDeclaration) { - if (!container.symbol || !container.symbol.exports) { - // Export * in some sort of block construct - bindAnonymousDeclaration(node, SymbolFlags.ExportStar, getDeclarationName(node)); - } - else if (!node.exportClause) { - // All export * declarations are collected in an __export symbol - declareSymbol(container.symbol.exports, container.symbol, node, SymbolFlags.ExportStar, SymbolFlags.None); - } - } - - function bindImportClause(node: ImportClause) { - if (node.name) { - declareSymbolAndAddToSymbolTable(node, SymbolFlags.Alias, SymbolFlags.AliasExcludes); - } - } - - 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.Property | SymbolFlags.Export | SymbolFlags.ValueModule, SymbolFlags.None); - } - - function bindThisPropertyAssignment(node: BinaryExpression) { - Debug.assert(isInJavaScriptFile(node)); - // Declare a 'member' if the container is an ES5 class or ES6 constructor - if (container.kind === SyntaxKind.FunctionDeclaration || container.kind === SyntaxKind.FunctionExpression) { - container.symbol.members = container.symbol.members || createMap(); - // It's acceptable for multiple 'this' assignments of the same identifier to occur - declareSymbol(container.symbol.members, container.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes & ~SymbolFlags.Property); - } - else if (container.kind === SyntaxKind.Constructor) { - // this.foo assignment in a JavaScript class - // Bind this property to the containing class - const saveContainer = container; - container = container.parent; - const symbol = bindPropertyOrMethodOrAccessor(node, SymbolFlags.Property, SymbolFlags.None); - if (symbol) { - // constructor-declared symbols can be overwritten by subsequent method declarations - (symbol as Symbol).isReplaceableByMethod = true; - } - container = saveContainer; - } - } - - function bindPrototypePropertyAssignment(node: BinaryExpression) { - // We saw a node of the form 'x.prototype.y = z'. Declare a 'member' y on x if x was a function. - - // Look up the function in the local scope, since prototype assignments should - // follow the function declaration - const leftSideOfAssignment = node.left as PropertyAccessExpression; - const classPrototype = leftSideOfAssignment.expression as PropertyAccessExpression; - const constructorFunction = classPrototype.expression as Identifier; - - // Fix up parent pointers since we're going to use these nodes before we bind into them - leftSideOfAssignment.parent = node; - constructorFunction.parent = classPrototype; - classPrototype.parent = leftSideOfAssignment; - - const funcSymbol = container.locals[constructorFunction.text]; - if (!funcSymbol || !(funcSymbol.flags & SymbolFlags.Function || isDeclarationOfFunctionExpression(funcSymbol))) { - return; - } - - // Set up the members collection if it doesn't exist already - if (!funcSymbol.members) { - funcSymbol.members = createMap(); - } - - // Declare the method/property - declareSymbol(funcSymbol.members, funcSymbol, leftSideOfAssignment, SymbolFlags.Property, SymbolFlags.PropertyExcludes); - } - - function bindCallExpression(node: 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 (!file.commonJsModuleIndicator && isRequireCall(node, /*checkArgumentIsStringLiteral*/false)) { - setCommonJsModuleIndicator(node); - } - } - - function bindClassLikeDeclaration(node: ClassLikeDeclaration) { - if (!isDeclarationFile(file) && !isInAmbientContext(node)) { - if (getClassExtendsHeritageClauseElement(node) !== undefined) { - emitFlags |= NodeFlags.HasClassExtends; - } - if (nodeIsDecorated(node)) { - emitFlags |= NodeFlags.HasDecorators; - } - } - - if (node.kind === SyntaxKind.ClassDeclaration) { - bindBlockScopedDeclaration(node, SymbolFlags.Class, SymbolFlags.ClassExcludes); - } - else { - const bindingName = node.name ? node.name.text : "__class"; - bindAnonymousDeclaration(node, SymbolFlags.Class, bindingName); - // Add name of class expression into the map for semantic classifier - if (node.name) { - classifiableNames[node.name.text] = node.name.text; - } - } - - const symbol = node.symbol; - - // TypeScript 1.0 spec (April 2014): 8.4 - // Every class automatically contains a static property member named 'prototype', the - // type of which is an instantiation of the class type with type Any supplied as a type - // argument for each type parameter. It is an error to explicitly declare a static - // property member with the name 'prototype'. - // - // Note: we check for this here because this class may be merging into a module. The - // module might have an exported variable called 'prototype'. We can't allow that as - // that would clash with the built-in 'prototype' for the class. - const prototypeSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Prototype, "prototype"); - if (symbol.exports[prototypeSymbol.name]) { - if (node.name) { - node.name.parent = node; - } - file.bindDiagnostics.push(createDiagnosticForNode(symbol.exports[prototypeSymbol.name].declarations[0], - Diagnostics.Duplicate_identifier_0, prototypeSymbol.name)); - } - symbol.exports[prototypeSymbol.name] = prototypeSymbol; - prototypeSymbol.parent = symbol; - } - - function bindEnumDeclaration(node: EnumDeclaration) { - return isConst(node) - ? bindBlockScopedDeclaration(node, SymbolFlags.ConstEnum, SymbolFlags.ConstEnumExcludes) - : bindBlockScopedDeclaration(node, SymbolFlags.RegularEnum, SymbolFlags.RegularEnumExcludes); - } - - function bindVariableDeclarationOrBindingElement(node: VariableDeclaration | BindingElement) { - if (inStrictMode) { - checkStrictModeEvalOrArguments(node, node.name); - } - - if (!isBindingPattern(node.name)) { - if (isBlockOrCatchScoped(node)) { - bindBlockScopedVariableDeclaration(node); - } - else if (isParameterDeclaration(node)) { - // It is safe to walk up parent chain to find whether the node is a destructing parameter declaration - // because its parent chain has already been set up, since parents are set before descending into children. - // - // If node is a binding element in parameter declaration, we need to use ParameterExcludes. - // Using ParameterExcludes flag allows the compiler to report an error on duplicate identifiers in Parameter Declaration - // For example: - // function foo([a,a]) {} // Duplicate Identifier error - // function bar(a,a) {} // Duplicate Identifier error, parameter declaration in this case is handled in bindParameter - // // which correctly set excluded symbols - declareSymbolAndAddToSymbolTable(node, SymbolFlags.FunctionScopedVariable, SymbolFlags.ParameterExcludes); - } - else { - declareSymbolAndAddToSymbolTable(node, SymbolFlags.FunctionScopedVariable, SymbolFlags.FunctionScopedVariableExcludes); - } - } - } - - function bindParameter(node: ParameterDeclaration) { - if (!isDeclarationFile(file) && - !isInAmbientContext(node) && - nodeIsDecorated(node)) { - emitFlags |= (NodeFlags.HasDecorators | NodeFlags.HasParamDecorators); - } - - if (inStrictMode) { - // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a - // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) - checkStrictModeEvalOrArguments(node, node.name); - } - - if (isBindingPattern(node.name)) { - bindAnonymousDeclaration(node, SymbolFlags.FunctionScopedVariable, getDestructuringParameterName(node)); - } - else { - declareSymbolAndAddToSymbolTable(node, SymbolFlags.FunctionScopedVariable, SymbolFlags.ParameterExcludes); - } - - // If this is a property-parameter, then also declare the property symbol into the - // containing class. - if (isParameterPropertyDeclaration(node)) { - const classDeclaration = node.parent.parent; - declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, SymbolFlags.Property | (node.questionToken ? SymbolFlags.Optional : SymbolFlags.None), SymbolFlags.PropertyExcludes); - } - } - - function bindFunctionDeclaration(node: FunctionDeclaration) { - if (!isDeclarationFile(file) && !isInAmbientContext(node)) { - if (isAsyncFunctionLike(node)) { - emitFlags |= NodeFlags.HasAsyncFunctions; - } - } - - checkStrictModeFunctionName(node); - if (inStrictMode) { - checkStrictModeFunctionDeclaration(node); - bindBlockScopedDeclaration(node, SymbolFlags.Function, SymbolFlags.FunctionExcludes); - } - else { - declareSymbolAndAddToSymbolTable(node, SymbolFlags.Function, SymbolFlags.FunctionExcludes); - } - } - - function bindFunctionExpression(node: FunctionExpression) { - if (!isDeclarationFile(file) && !isInAmbientContext(node)) { - if (isAsyncFunctionLike(node)) { - emitFlags |= NodeFlags.HasAsyncFunctions; - } - } - if (currentFlow) { - node.flowNode = currentFlow; - } - checkStrictModeFunctionName(node); - const bindingName = node.name ? node.name.text : "__function"; - return bindAnonymousDeclaration(node, SymbolFlags.Function, bindingName); - } - - function bindPropertyOrMethodOrAccessor(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags) { - if (!isDeclarationFile(file) && !isInAmbientContext(node)) { - if (isAsyncFunctionLike(node)) { - emitFlags |= NodeFlags.HasAsyncFunctions; - } - if (nodeIsDecorated(node)) { - emitFlags |= NodeFlags.HasDecorators; - } - } - - if (currentFlow && isObjectLiteralOrClassExpressionMethod(node)) { - node.flowNode = currentFlow; - } - - return hasDynamicName(node) - ? bindAnonymousDeclaration(node, symbolFlags, "__computed") - : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); - } - - function bindJSDocProperty(node: JSDocPropertyTag) { - return declareSymbolAndAddToSymbolTable(node, SymbolFlags.Property, SymbolFlags.PropertyExcludes); - } - - // reachability checks - - function shouldReportErrorOnModuleDeclaration(node: ModuleDeclaration): boolean { - const instanceState = getModuleInstanceState(node); - return instanceState === ModuleInstanceState.Instantiated || (instanceState === ModuleInstanceState.ConstEnumOnly && options.preserveConstEnums); - } - - function checkUnreachable(node: Node): boolean { - if (!(currentFlow.flags & FlowFlags.Unreachable)) { - return false; - } - if (currentFlow === unreachableFlow) { - const reportError = - // report error on all statements except empty ones - (isStatementButNotDeclaration(node) && node.kind !== SyntaxKind.EmptyStatement) || - // report error on class declarations - node.kind === SyntaxKind.ClassDeclaration || - // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === SyntaxKind.ModuleDeclaration && shouldReportErrorOnModuleDeclaration(node)) || - // report error on regular enums and const enums if preserveConstEnums is set - (node.kind === SyntaxKind.EnumDeclaration && (!isConstEnumDeclaration(node) || options.preserveConstEnums)); - - if (reportError) { - currentFlow = reportedUnreachableFlow; - - // unreachable code is reported if - // - user has explicitly asked about it AND - // - statement is in not ambient context (statements in ambient context is already an error - // so we should not report extras) AND - // - node is not variable statement OR - // - node is block scoped variable statement OR - // - node is not block scoped variable statement and at least one variable declaration has initializer - // Rationale: we don't want to report errors on non-initialized var's since they are hoisted - // On the other side we do want to report errors on non-initialized 'lets' because of TDZ - const reportUnreachableCode = - !options.allowUnreachableCode && - !isInAmbientContext(node) && - ( - node.kind !== SyntaxKind.VariableStatement || - getCombinedNodeFlags((node).declarationList) & NodeFlags.BlockScoped || - forEach((node).declarationList.declarations, d => d.initializer) - ); - - if (reportUnreachableCode) { - errorOnFirstToken(node, Diagnostics.Unreachable_code_detected); - } - } - } - return true; - } - } - - /** - * Computes the transform flags for a node, given the transform flags of its subtree - * - * @param node The node to analyze - * @param subtreeFlags Transform flags computed for this node's subtree - */ - export function computeTransformFlagsForNode(node: Node, subtreeFlags: TransformFlags): TransformFlags { - const kind = node.kind; - switch (kind) { - case SyntaxKind.CallExpression: - return computeCallExpression(node, subtreeFlags); - - case SyntaxKind.NewExpression: - return computeNewExpression(node, subtreeFlags); - - case SyntaxKind.ModuleDeclaration: - return computeModuleDeclaration(node, subtreeFlags); - - case SyntaxKind.ParenthesizedExpression: - return computeParenthesizedExpression(node, subtreeFlags); - - case SyntaxKind.BinaryExpression: - return computeBinaryExpression(node, subtreeFlags); - - case SyntaxKind.ExpressionStatement: - return computeExpressionStatement(node, subtreeFlags); - - case SyntaxKind.Parameter: - return computeParameter(node, subtreeFlags); - - case SyntaxKind.ArrowFunction: - return computeArrowFunction(node, subtreeFlags); - - case SyntaxKind.FunctionExpression: - return computeFunctionExpression(node, subtreeFlags); - - case SyntaxKind.FunctionDeclaration: - return computeFunctionDeclaration(node, subtreeFlags); - - case SyntaxKind.VariableDeclaration: - return computeVariableDeclaration(node, subtreeFlags); - - case SyntaxKind.VariableDeclarationList: - return computeVariableDeclarationList(node, subtreeFlags); - - case SyntaxKind.VariableStatement: - return computeVariableStatement(node, subtreeFlags); - - case SyntaxKind.LabeledStatement: - return computeLabeledStatement(node, subtreeFlags); - - case SyntaxKind.ClassDeclaration: - return computeClassDeclaration(node, subtreeFlags); - - case SyntaxKind.ClassExpression: - return computeClassExpression(node, subtreeFlags); - - case SyntaxKind.HeritageClause: - return computeHeritageClause(node, subtreeFlags); - - case SyntaxKind.ExpressionWithTypeArguments: - return computeExpressionWithTypeArguments(node, subtreeFlags); - - case SyntaxKind.Constructor: - return computeConstructor(node, subtreeFlags); - - case SyntaxKind.PropertyDeclaration: - return computePropertyDeclaration(node, subtreeFlags); - - case SyntaxKind.MethodDeclaration: - return computeMethod(node, subtreeFlags); - - case SyntaxKind.GetAccessor: - case SyntaxKind.SetAccessor: - return computeAccessor(node, subtreeFlags); - - case SyntaxKind.ImportEqualsDeclaration: - return computeImportEquals(node, subtreeFlags); - - case SyntaxKind.PropertyAccessExpression: - return computePropertyAccess(node, subtreeFlags); - - default: - return computeOther(node, kind, subtreeFlags); - } - } - - function computeCallExpression(node: CallExpression, subtreeFlags: TransformFlags) { - let transformFlags = subtreeFlags; - const expression = node.expression; - const expressionKind = expression.kind; - - if (node.typeArguments) { - transformFlags |= TransformFlags.AssertTypeScript; - } - - if (subtreeFlags & TransformFlags.ContainsSpreadElementExpression - || isSuperOrSuperProperty(expression, expressionKind)) { - // If the this node contains a SpreadElementExpression, or is a super call, then it is an ES6 - // node. - transformFlags |= TransformFlags.AssertES2015; - } - - node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; - return transformFlags & ~TransformFlags.ArrayLiteralOrCallOrNewExcludes; - } - - function isSuperOrSuperProperty(node: Node, kind: SyntaxKind) { - switch (kind) { - case SyntaxKind.SuperKeyword: - return true; - - case SyntaxKind.PropertyAccessExpression: - case SyntaxKind.ElementAccessExpression: - const expression = (node).expression; - const expressionKind = expression.kind; - return expressionKind === SyntaxKind.SuperKeyword; - } - - return false; - } - - function computeNewExpression(node: NewExpression, subtreeFlags: TransformFlags) { - let transformFlags = subtreeFlags; - if (node.typeArguments) { - transformFlags |= TransformFlags.AssertTypeScript; - } - if (subtreeFlags & TransformFlags.ContainsSpreadElementExpression) { - // If the this node contains a SpreadElementExpression then it is an ES6 - // node. - transformFlags |= TransformFlags.AssertES6; - } - node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; - return transformFlags & ~TransformFlags.ArrayLiteralOrCallOrNewExcludes; - } - - - function computeBinaryExpression(node: BinaryExpression, subtreeFlags: TransformFlags) { - let transformFlags = subtreeFlags; - const operatorTokenKind = node.operatorToken.kind; - const leftKind = node.left.kind; - - if (operatorTokenKind === SyntaxKind.EqualsToken - && (leftKind === SyntaxKind.ObjectLiteralExpression - || leftKind === SyntaxKind.ArrayLiteralExpression)) { - // Destructuring assignments are ES6 syntax. - transformFlags |= TransformFlags.AssertES2015 | TransformFlags.DestructuringAssignment; - } - else if (operatorTokenKind === SyntaxKind.AsteriskAsteriskToken - || operatorTokenKind === SyntaxKind.AsteriskAsteriskEqualsToken) { - // Exponentiation is ES2016 syntax. - transformFlags |= TransformFlags.AssertES2016; - } - - node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; - return transformFlags & ~TransformFlags.NodeExcludes; - } - - function computeParameter(node: ParameterDeclaration, subtreeFlags: TransformFlags) { - let transformFlags = subtreeFlags; - const modifierFlags = getModifierFlags(node); - const name = node.name; - const initializer = node.initializer; - const dotDotDotToken = node.dotDotDotToken; - - // The '?' token, type annotations, decorators, and 'this' parameters are TypeSCript - // syntax. - if (node.questionToken - || node.type - || subtreeFlags & TransformFlags.ContainsDecorators - || isThisIdentifier(name)) { - transformFlags |= TransformFlags.AssertTypeScript; - } - - // If a parameter has an accessibility modifier, then it is TypeScript syntax. - if (modifierFlags & ModifierFlags.ParameterPropertyModifier) { - transformFlags |= TransformFlags.AssertTypeScript | TransformFlags.ContainsParameterPropertyAssignments; - } - - // If a parameter has an initializer, a binding pattern or a dotDotDot token, then - // it is ES6 syntax and its container must emit default value assignments or parameter destructuring downlevel. - if (subtreeFlags & TransformFlags.ContainsBindingPattern || initializer || dotDotDotToken) { - transformFlags |= TransformFlags.AssertES2015 | TransformFlags.ContainsDefaultValueAssignments; - } - - node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; - return transformFlags & ~TransformFlags.ParameterExcludes; - } - - function computeParenthesizedExpression(node: ParenthesizedExpression, subtreeFlags: TransformFlags) { - let transformFlags = subtreeFlags; - const expression = node.expression; - const expressionKind = expression.kind; - const expressionTransformFlags = expression.transformFlags; - - // 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 (expressionKind === SyntaxKind.AsExpression - || expressionKind === SyntaxKind.TypeAssertionExpression) { - transformFlags |= TransformFlags.AssertTypeScript; - } - - // If the expression of a ParenthesizedExpression is a destructuring assignment, - // then the ParenthesizedExpression is a destructuring assignment. - if (expressionTransformFlags & TransformFlags.DestructuringAssignment) { - transformFlags |= TransformFlags.DestructuringAssignment; - } - - node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; - return transformFlags & ~TransformFlags.NodeExcludes; - } - - function computeClassDeclaration(node: ClassDeclaration, subtreeFlags: TransformFlags) { - let transformFlags: TransformFlags; - const modifierFlags = getModifierFlags(node); - - if (modifierFlags & ModifierFlags.Ambient) { - // An ambient declaration is TypeScript syntax. - transformFlags = TransformFlags.AssertTypeScript; - } - else { - // A ClassDeclaration is ES6 syntax. - transformFlags = subtreeFlags | TransformFlags.AssertES2015; - - // A class with a parameter property assignment, property initializer, or decorator is - // TypeScript syntax. - // An exported declaration may be TypeScript syntax. - if ((subtreeFlags & TransformFlags.TypeScriptClassSyntaxMask) - || (modifierFlags & ModifierFlags.Export) - || node.typeParameters) { - transformFlags |= TransformFlags.AssertTypeScript; - } - - if (subtreeFlags & TransformFlags.ContainsLexicalThisInComputedPropertyName) { - // A computed property name containing `this` might need to be rewritten, - // so propagate the ContainsLexicalThis flag upward. - transformFlags |= TransformFlags.ContainsLexicalThis; - } - } - - node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; - return transformFlags & ~TransformFlags.ClassExcludes; - } - - function computeClassExpression(node: ClassExpression, subtreeFlags: TransformFlags) { - // A ClassExpression is ES6 syntax. - let transformFlags = subtreeFlags | TransformFlags.AssertES2015; - - // A class with a parameter property assignment, property initializer, or decorator is - // TypeScript syntax. - if (subtreeFlags & TransformFlags.TypeScriptClassSyntaxMask - || node.typeParameters) { - transformFlags |= TransformFlags.AssertTypeScript; - } - - if (subtreeFlags & TransformFlags.ContainsLexicalThisInComputedPropertyName) { - // A computed property name containing `this` might need to be rewritten, - // so propagate the ContainsLexicalThis flag upward. - transformFlags |= TransformFlags.ContainsLexicalThis; - } - - node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; - return transformFlags & ~TransformFlags.ClassExcludes; - } - - function computeHeritageClause(node: HeritageClause, subtreeFlags: TransformFlags) { - let transformFlags = subtreeFlags; - - switch (node.token) { - case SyntaxKind.ExtendsKeyword: - // An `extends` HeritageClause is ES6 syntax. - transformFlags |= TransformFlags.AssertES2015; - break; - - case SyntaxKind.ImplementsKeyword: - // An `implements` HeritageClause is TypeScript syntax. - transformFlags |= TransformFlags.AssertTypeScript; - break; - - default: - Debug.fail("Unexpected token for heritage clause"); - break; - } - - node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; - return transformFlags & ~TransformFlags.NodeExcludes; - } - - function computeExpressionWithTypeArguments(node: ExpressionWithTypeArguments, subtreeFlags: TransformFlags) { - // An ExpressionWithTypeArguments is ES6 syntax, as it is used in the - // extends clause of a class. - let transformFlags = subtreeFlags | TransformFlags.AssertES2015; - - // If an ExpressionWithTypeArguments contains type arguments, then it - // is TypeScript syntax. - if (node.typeArguments) { - transformFlags |= TransformFlags.AssertTypeScript; - } - - node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; - return transformFlags & ~TransformFlags.NodeExcludes; - } - - function computeConstructor(node: ConstructorDeclaration, subtreeFlags: TransformFlags) { - let transformFlags = subtreeFlags; - - // TypeScript-specific modifiers and overloads are TypeScript syntax - if (hasModifier(node, ModifierFlags.TypeScriptModifier) - || !node.body) { - transformFlags |= TransformFlags.AssertTypeScript; - } - - node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; - return transformFlags & ~TransformFlags.ConstructorExcludes; - } - - function computeMethod(node: MethodDeclaration, subtreeFlags: TransformFlags) { - // A MethodDeclaration is ES6 syntax. -<<<<<<< HEAD - let transformFlags = subtreeFlags | TransformFlags.AssertES6; - - // Decorators, TypeScript-specific modifiers, type parameters, type annotations, and - // overloads are TypeScript syntax. - if (node.decorators - || hasModifier(node, ModifierFlags.TypeScriptModifier) - || node.typeParameters - || node.type - || !node.body) { -======= - let transformFlags = subtreeFlags | TransformFlags.AssertES2015; - const modifierFlags = getModifierFlags(node); - const body = node.body; - const typeParameters = node.typeParameters; - const asteriskToken = node.asteriskToken; - - // A MethodDeclaration is TypeScript syntax if it is either abstract, overloaded, - // generic, or has a decorator. - if (!body - || typeParameters - || (modifierFlags & ModifierFlags.Abstract) - || (subtreeFlags & TransformFlags.ContainsDecorators)) { ->>>>>>> master - transformFlags |= TransformFlags.AssertTypeScript; - } - - // An async method declaration is ES2017 syntax. - if (modifierFlags & ModifierFlags.Async) { - transformFlags |= TransformFlags.AssertES2017; - } - - // Currently, we only support generators that were originally async function bodies. - if (node.asteriskToken && getEmitFlags(node) & EmitFlags.AsyncFunctionBody) { - transformFlags |= TransformFlags.AssertGenerator; - } - - node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; - return transformFlags & ~TransformFlags.MethodOrAccessorExcludes; - } - - function computeAccessor(node: AccessorDeclaration, subtreeFlags: TransformFlags) { - let transformFlags = subtreeFlags; - -<<<<<<< HEAD - // Decorators, TypeScript-specific modifiers, type annotations, and overloads are - // TypeScript syntax. - if (node.decorators - || hasModifier(node, ModifierFlags.TypeScriptModifier) - || node.type - || !node.body) { -======= - // An accessor is TypeScript syntax if it is either abstract, overloaded, - // generic, or has a decorator. - if (!body - || (modifierFlags & ModifierFlags.Abstract) - || (subtreeFlags & TransformFlags.ContainsDecorators)) { ->>>>>>> master - transformFlags |= TransformFlags.AssertTypeScript; - } - - node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; - return transformFlags & ~TransformFlags.MethodOrAccessorExcludes; - } - - function computePropertyDeclaration(node: PropertyDeclaration, subtreeFlags: TransformFlags) { - // A PropertyDeclaration is TypeScript syntax. - let transformFlags = subtreeFlags | TransformFlags.AssertTypeScript; - - // If the PropertyDeclaration has an initializer, we need to inform its ancestor - // so that it handle the transformation. - if (node.initializer) { - transformFlags |= TransformFlags.ContainsPropertyInitializer; - } - - node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; - return transformFlags & ~TransformFlags.NodeExcludes; - } - - function computeFunctionDeclaration(node: FunctionDeclaration, subtreeFlags: TransformFlags) { - let transformFlags: TransformFlags; - const modifierFlags = getModifierFlags(node); - const body = node.body; - - if (!body || (modifierFlags & ModifierFlags.Ambient)) { - // An ambient declaration is TypeScript syntax. - // A FunctionDeclaration without a body is an overload and is TypeScript syntax. - transformFlags = TransformFlags.AssertTypeScript; - } - else { - transformFlags = subtreeFlags | TransformFlags.ContainsHoistedDeclarationOrCompletion; - - // If a FunctionDeclaration is exported, then it is either ES6 or TypeScript syntax. - if (modifierFlags & ModifierFlags.Export) { - transformFlags |= TransformFlags.AssertTypeScript | TransformFlags.AssertES2015; - } - -<<<<<<< HEAD - // TypeScript-specific modifiers, type parameters, and type annotations are TypeScript - // syntax. - if (modifierFlags & ModifierFlags.TypeScriptModifier - || node.typeParameters - || node.type) { - transformFlags |= TransformFlags.AssertTypeScript; -======= - // An async function declaration is ES2017 syntax. - if (modifierFlags & ModifierFlags.Async) { - transformFlags |= TransformFlags.AssertES2017; ->>>>>>> master - } - - // If a FunctionDeclaration's subtree has marked the container as needing to capture the - // lexical this, or the function contains parameters with initializers, then this node is - // ES6 syntax. - if (subtreeFlags & TransformFlags.ES2015FunctionSyntaxMask) { - transformFlags |= TransformFlags.AssertES2015; - } - - // If a FunctionDeclaration is generator function and is the body of a - // transformed async function, then this node can be transformed to a - // down-level generator. - // Currently we do not support transforming any other generator fucntions - // down level. - if (node.asteriskToken && getEmitFlags(node) & EmitFlags.AsyncFunctionBody) { - transformFlags |= TransformFlags.AssertGenerator; - } - } - - node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; - return transformFlags & ~TransformFlags.FunctionExcludes; - } - - function computeFunctionExpression(node: FunctionExpression, subtreeFlags: TransformFlags) { - let transformFlags = subtreeFlags; - -<<<<<<< HEAD - // TypeScript-specific modifiers, type parameters, and type annotations are TypeScript - // syntax. - if (hasModifier(node, ModifierFlags.TypeScriptModifier) - || node.typeParameters - || node.type) { - transformFlags |= TransformFlags.AssertTypeScript; -======= - // An async function expression is ES2017 syntax. - if (modifierFlags & ModifierFlags.Async) { - transformFlags |= TransformFlags.AssertES2017; ->>>>>>> master - } - - // If a FunctionExpression's subtree has marked the container as needing to capture the - // lexical this, or the function contains parameters with initializers, then this node is - // ES6 syntax. - if (subtreeFlags & TransformFlags.ES2015FunctionSyntaxMask) { - transformFlags |= TransformFlags.AssertES2015; - } - - // If a FunctionExpression is generator function and is the body of a - // transformed async function, then this node can be transformed to a - // down-level generator. - // Currently we do not support transforming any other generator fucntions - // down level. - if (node.asteriskToken && getEmitFlags(node) & EmitFlags.AsyncFunctionBody) { - transformFlags |= TransformFlags.AssertGenerator; - } - - node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; - return transformFlags & ~TransformFlags.FunctionExcludes; - } - - function computeArrowFunction(node: ArrowFunction, subtreeFlags: TransformFlags) { - // An ArrowFunction is ES6 syntax, and excludes markers that should not escape the scope of an ArrowFunction. -<<<<<<< HEAD - let transformFlags = subtreeFlags | TransformFlags.AssertES6; - - // TypeScript-specific modifiers, type parameters, and type annotations are TypeScript - // syntax. - if (hasModifier(node, ModifierFlags.TypeScriptModifier) - || node.typeParameters - || node.type) { - transformFlags |= TransformFlags.AssertTypeScript; -======= - let transformFlags = subtreeFlags | TransformFlags.AssertES2015; - const modifierFlags = getModifierFlags(node); - - // An async arrow function is ES2017 syntax. - if (modifierFlags & ModifierFlags.Async) { - transformFlags |= TransformFlags.AssertES2017; ->>>>>>> master - } - - // If an ArrowFunction contains a lexical this, its container must capture the lexical this. - if (subtreeFlags & TransformFlags.ContainsLexicalThis) { - transformFlags |= TransformFlags.ContainsCapturedLexicalThis; - } - - node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; - return transformFlags & ~TransformFlags.ArrowFunctionExcludes; - } - - function computePropertyAccess(node: PropertyAccessExpression, subtreeFlags: TransformFlags) { - let transformFlags = subtreeFlags; - const expression = node.expression; - const expressionKind = expression.kind; - - // If a PropertyAccessExpression starts with a super keyword, then it is - // ES6 syntax, and requires a lexical `this` binding. - if (expressionKind === SyntaxKind.SuperKeyword) { - transformFlags |= TransformFlags.ContainsLexicalThis; - } - - node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; - return transformFlags & ~TransformFlags.NodeExcludes; - } - - function computeVariableDeclaration(node: VariableDeclaration, subtreeFlags: TransformFlags) { - let transformFlags = subtreeFlags; - const nameKind = node.name.kind; - - // A VariableDeclaration with a binding pattern is ES6 syntax. - if (nameKind === SyntaxKind.ObjectBindingPattern || nameKind === SyntaxKind.ArrayBindingPattern) { - transformFlags |= TransformFlags.AssertES2015 | TransformFlags.ContainsBindingPattern; - } - - // Type annotations are TypeScript syntax. - if (node.type) { - transformFlags |= TransformFlags.AssertTypeScript; - } - - node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; - return transformFlags & ~TransformFlags.NodeExcludes; - } - - function computeVariableStatement(node: VariableStatement, subtreeFlags: TransformFlags) { - let transformFlags: TransformFlags; - const modifierFlags = getModifierFlags(node); - const declarationListTransformFlags = node.declarationList.transformFlags; - - // An ambient declaration is TypeScript syntax. - if (modifierFlags & ModifierFlags.Ambient) { - transformFlags = TransformFlags.AssertTypeScript; - } - else { - transformFlags = subtreeFlags; - - // If a VariableStatement is exported, then it is either ES6 or TypeScript syntax. - if (modifierFlags & ModifierFlags.Export) { - transformFlags |= TransformFlags.AssertES2015 | TransformFlags.AssertTypeScript; - } - - if (declarationListTransformFlags & TransformFlags.ContainsBindingPattern) { - transformFlags |= TransformFlags.AssertES2015; - } - } - - node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; - return transformFlags & ~TransformFlags.NodeExcludes; - } - - function computeLabeledStatement(node: LabeledStatement, subtreeFlags: TransformFlags) { - let transformFlags = subtreeFlags; - - // A labeled statement containing a block scoped binding *may* need to be transformed from ES6. - if (subtreeFlags & TransformFlags.ContainsBlockScopedBinding - && isIterationStatement(node, /*lookInLabeledStatements*/ true)) { - transformFlags |= TransformFlags.AssertES2015; - } - - node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; - return transformFlags & ~TransformFlags.NodeExcludes; - } - - function computeImportEquals(node: ImportEqualsDeclaration, subtreeFlags: TransformFlags) { - let transformFlags = subtreeFlags; - - // An ImportEqualsDeclaration with a namespace reference is TypeScript. - if (!isExternalModuleImportEqualsDeclaration(node)) { - transformFlags |= TransformFlags.AssertTypeScript; - } - - node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; - return transformFlags & ~TransformFlags.NodeExcludes; - } - - function computeExpressionStatement(node: ExpressionStatement, subtreeFlags: TransformFlags) { - let transformFlags = subtreeFlags; - - // If the expression of an expression statement is a destructuring assignment, - // then we treat the statement as ES6 so that we can indicate that we do not - // need to hold on to the right-hand side. - if (node.expression.transformFlags & TransformFlags.DestructuringAssignment) { - transformFlags |= TransformFlags.AssertES2015; - } - - node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; - return transformFlags & ~TransformFlags.NodeExcludes; - } - - function computeModuleDeclaration(node: ModuleDeclaration, subtreeFlags: TransformFlags) { - let transformFlags = TransformFlags.AssertTypeScript; - const modifierFlags = getModifierFlags(node); - - if ((modifierFlags & ModifierFlags.Ambient) === 0) { - transformFlags |= subtreeFlags; - } - - node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; - return transformFlags & ~TransformFlags.ModuleExcludes; - } - - function computeVariableDeclarationList(node: VariableDeclarationList, subtreeFlags: TransformFlags) { - let transformFlags = subtreeFlags | TransformFlags.ContainsHoistedDeclarationOrCompletion; - - if (subtreeFlags & TransformFlags.ContainsBindingPattern) { - transformFlags |= TransformFlags.AssertES2015; - } - - // If a VariableDeclarationList is `let` or `const`, then it is ES6 syntax. - if (node.flags & NodeFlags.BlockScoped) { - transformFlags |= TransformFlags.AssertES2015 | TransformFlags.ContainsBlockScopedBinding; - } - - node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; - return transformFlags & ~TransformFlags.VariableDeclarationListExcludes; - } - - function computeOther(node: Node, kind: SyntaxKind, subtreeFlags: TransformFlags) { - // Mark transformations needed for each node - let transformFlags = subtreeFlags; - let excludeFlags = TransformFlags.NodeExcludes; - - switch (kind) { - case SyntaxKind.AsyncKeyword: - case SyntaxKind.AwaitExpression: - // async/await is ES2017 syntax - transformFlags |= TransformFlags.AssertES2017; - break; - - case SyntaxKind.PublicKeyword: - case SyntaxKind.PrivateKeyword: - case SyntaxKind.ProtectedKeyword: - case SyntaxKind.AbstractKeyword: - case SyntaxKind.DeclareKeyword: - case SyntaxKind.ConstKeyword: - case SyntaxKind.EnumDeclaration: - case SyntaxKind.EnumMember: - case SyntaxKind.TypeAssertionExpression: - case SyntaxKind.AsExpression: - case SyntaxKind.NonNullExpression: - case SyntaxKind.ReadonlyKeyword: - // These nodes are TypeScript syntax. - transformFlags |= TransformFlags.AssertTypeScript; - break; - - case SyntaxKind.JsxElement: - case SyntaxKind.JsxSelfClosingElement: - case SyntaxKind.JsxOpeningElement: - case SyntaxKind.JsxText: - case SyntaxKind.JsxClosingElement: - case SyntaxKind.JsxAttribute: - case SyntaxKind.JsxSpreadAttribute: - case SyntaxKind.JsxExpression: - // These nodes are Jsx syntax. - transformFlags |= TransformFlags.AssertJsx; - break; - - case SyntaxKind.ExportKeyword: - // This node is both ES6 and TypeScript syntax. - transformFlags |= TransformFlags.AssertES2015 | TransformFlags.AssertTypeScript; - break; - - case SyntaxKind.DefaultKeyword: - case SyntaxKind.NoSubstitutionTemplateLiteral: - case SyntaxKind.TemplateHead: - case SyntaxKind.TemplateMiddle: - case SyntaxKind.TemplateTail: - case SyntaxKind.TemplateExpression: - case SyntaxKind.TaggedTemplateExpression: - case SyntaxKind.ShorthandPropertyAssignment: - case SyntaxKind.ForOfStatement: - // These nodes are ES6 syntax. - transformFlags |= TransformFlags.AssertES2015; - break; - - case SyntaxKind.YieldExpression: - // This node is ES6 syntax. - transformFlags |= TransformFlags.AssertES2015 | TransformFlags.ContainsYield; - break; - - case SyntaxKind.AnyKeyword: - case SyntaxKind.NumberKeyword: - case SyntaxKind.NeverKeyword: - case SyntaxKind.StringKeyword: - case SyntaxKind.BooleanKeyword: - case SyntaxKind.SymbolKeyword: - case SyntaxKind.VoidKeyword: - case SyntaxKind.TypeParameter: - case SyntaxKind.PropertySignature: - case SyntaxKind.MethodSignature: - case SyntaxKind.CallSignature: - case SyntaxKind.ConstructSignature: - case SyntaxKind.IndexSignature: - case SyntaxKind.TypePredicate: - case SyntaxKind.TypeReference: - case SyntaxKind.FunctionType: - case SyntaxKind.ConstructorType: - case SyntaxKind.TypeQuery: - case SyntaxKind.TypeLiteral: - case SyntaxKind.ArrayType: - case SyntaxKind.TupleType: - case SyntaxKind.UnionType: - case SyntaxKind.IntersectionType: - case SyntaxKind.ParenthesizedType: - case SyntaxKind.InterfaceDeclaration: - case SyntaxKind.TypeAliasDeclaration: - case SyntaxKind.ThisType: - case SyntaxKind.LiteralType: - // Types and signatures are TypeScript syntax, and exclude all other facts. - transformFlags = TransformFlags.AssertTypeScript; - excludeFlags = TransformFlags.TypeExcludes; - break; - - case SyntaxKind.ComputedPropertyName: - // Even though computed property names are ES6, we don't treat them as such. - // This is so that they can flow through PropertyName transforms unaffected. - // Instead, we mark the container as ES6, so that it can properly handle the transform. - transformFlags |= TransformFlags.ContainsComputedPropertyName; - if (subtreeFlags & TransformFlags.ContainsLexicalThis) { - // A computed method name like `[this.getName()](x: string) { ... }` needs to - // distinguish itself from the normal case of a method body containing `this`: - // `this` inside a method doesn't need to be rewritten (the method provides `this`), - // whereas `this` inside a computed name *might* need to be rewritten if the class/object - // is inside an arrow function: - // `_this = this; () => class K { [_this.getName()]() { ... } }` - // To make this distinction, use ContainsLexicalThisInComputedPropertyName - // instead of ContainsLexicalThis for computed property names - transformFlags |= TransformFlags.ContainsLexicalThisInComputedPropertyName; - } - break; - - case SyntaxKind.SpreadElementExpression: - // This node is ES6 syntax, but is handled by a containing node. - transformFlags |= TransformFlags.ContainsSpreadElementExpression; - break; - - case SyntaxKind.SuperKeyword: - // This node is ES6 syntax. - transformFlags |= TransformFlags.AssertES2015; - break; - - case SyntaxKind.ThisKeyword: - // Mark this node and its ancestors as containing a lexical `this` keyword. - transformFlags |= TransformFlags.ContainsLexicalThis; - break; - - case SyntaxKind.ObjectBindingPattern: - case SyntaxKind.ArrayBindingPattern: - // These nodes are ES6 syntax. - transformFlags |= TransformFlags.AssertES2015 | TransformFlags.ContainsBindingPattern; - break; - - case SyntaxKind.Decorator: - // This node is TypeScript syntax, and marks its container as also being TypeScript syntax. - transformFlags |= TransformFlags.AssertTypeScript | TransformFlags.ContainsDecorators; - break; - - case SyntaxKind.ObjectLiteralExpression: - excludeFlags = TransformFlags.ObjectLiteralExcludes; - if (subtreeFlags & TransformFlags.ContainsComputedPropertyName) { - // If an ObjectLiteralExpression contains a ComputedPropertyName, then it - // is an ES6 node. - transformFlags |= TransformFlags.AssertES2015; - } - - if (subtreeFlags & TransformFlags.ContainsLexicalThisInComputedPropertyName) { - // A computed property name containing `this` might need to be rewritten, - // so propagate the ContainsLexicalThis flag upward. - transformFlags |= TransformFlags.ContainsLexicalThis; - } - - break; - - case SyntaxKind.ArrayLiteralExpression: - case SyntaxKind.NewExpression: - excludeFlags = TransformFlags.ArrayLiteralOrCallOrNewExcludes; - if (subtreeFlags & TransformFlags.ContainsSpreadElementExpression) { - // If the this node contains a SpreadElementExpression, then it is an ES6 - // node. - transformFlags |= TransformFlags.AssertES2015; - } - - break; - - case SyntaxKind.DoStatement: - case SyntaxKind.WhileStatement: - case SyntaxKind.ForStatement: - case SyntaxKind.ForInStatement: - // A loop containing a block scoped binding *may* need to be transformed from ES6. - if (subtreeFlags & TransformFlags.ContainsBlockScopedBinding) { - transformFlags |= TransformFlags.AssertES2015; - } - - break; - - case SyntaxKind.SourceFile: - if (subtreeFlags & TransformFlags.ContainsCapturedLexicalThis) { - transformFlags |= TransformFlags.AssertES2015; - } - - break; - - case SyntaxKind.ReturnStatement: - case SyntaxKind.ContinueStatement: - case SyntaxKind.BreakStatement: - transformFlags |= TransformFlags.ContainsHoistedDeclarationOrCompletion; - break; - } - - node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; - return transformFlags & ~excludeFlags; - } -} From db76a9ca0720199852c39eef1c8956d5c55bacb7 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Sat, 15 Oct 2016 17:29:03 -0700 Subject: [PATCH 108/173] More tests --- .../transformsElideNullUndefinedType.js | 68 ++++++++++-- .../transformsElideNullUndefinedType.symbols | 101 ++++++++++++++--- .../transformsElideNullUndefinedType.types | 102 ++++++++++++++++-- .../transformsElideNullUndefinedType.ts | 36 ++++++- 4 files changed, 272 insertions(+), 35 deletions(-) diff --git a/tests/baselines/reference/transformsElideNullUndefinedType.js b/tests/baselines/reference/transformsElideNullUndefinedType.js index a5e27eee08b..63bc77559c1 100644 --- a/tests/baselines/reference/transformsElideNullUndefinedType.js +++ b/tests/baselines/reference/transformsElideNullUndefinedType.js @@ -15,21 +15,49 @@ var f5 = (): undefined => undefined; function f6(p0: null) { } function f7(p1: undefined) { } -class C { +var f8 = function (p2: null) { } +var f9 = function (p3: undefined) { } + +var f10 = (p4: null) => { } +var f11 = (p5: undefined) => { } + +class C1 { m0(): null { return null; } m1(): undefined { return undefined; } + m3(p6: null) { } + m4(p7: undefined) { } + get a0(): null { return null; } get a1(): undefined { return undefined; } + + set a2(p8: null) { } + set a3(p9: undefined) { } } -declare function fn(); +class C2 { constructor(p10: null) { } } +class C3 { constructor(p11: undefined) { } } +class C4 { + f1; + constructor(p12: null) { } +} + +class C5 { + f2; + constructor(p13: undefined) { } +} + +var C6 = class { constructor(p12: null) { } } +var C7 = class { constructor(p13: undefined) { } } + +declare function fn(); fn(); fn(); -new C(); -new C(); +declare class D {} +new D(); +new D(); //// [transformsElideNullUndefinedType.js] var v0; @@ -42,13 +70,39 @@ var f4 = () => null; var f5 = () => undefined; function f6(p0) { } function f7(p1) { } -class C { +var f8 = function (p2) { }; +var f9 = function (p3) { }; +var f10 = (p4) => { }; +var f11 = (p5) => { }; +class C1 { m0() { return null; } m1() { return undefined; } + m3(p6) { } + m4(p7) { } get a0() { return null; } get a1() { return undefined; } + set a2(p8) { } + set a3(p9) { } } +class C2 { + constructor(p10) { } +} +class C3 { + constructor(p11) { } +} +class C4 { + constructor(p12) { } +} +class C5 { + constructor(p13) { } +} +var C6 = class { + constructor(p12) { } +}; +var C7 = class { + constructor(p13) { } +}; fn(); fn(); -new C(); -new C(); +new D(); +new D(); diff --git a/tests/baselines/reference/transformsElideNullUndefinedType.symbols b/tests/baselines/reference/transformsElideNullUndefinedType.symbols index 0c9333d9820..b651784a61c 100644 --- a/tests/baselines/reference/transformsElideNullUndefinedType.symbols +++ b/tests/baselines/reference/transformsElideNullUndefinedType.symbols @@ -35,38 +35,109 @@ function f7(p1: undefined) { } >f7 : Symbol(f7, Decl(transformsElideNullUndefinedType.ts, 13, 25)) >p1 : Symbol(p1, Decl(transformsElideNullUndefinedType.ts, 14, 12)) -class C { ->C : Symbol(C, Decl(transformsElideNullUndefinedType.ts, 14, 30)) ->T : Symbol(T, Decl(transformsElideNullUndefinedType.ts, 16, 8)) +var f8 = function (p2: null) { } +>f8 : Symbol(f8, Decl(transformsElideNullUndefinedType.ts, 16, 3)) +>p2 : Symbol(p2, Decl(transformsElideNullUndefinedType.ts, 16, 19)) + +var f9 = function (p3: undefined) { } +>f9 : Symbol(f9, Decl(transformsElideNullUndefinedType.ts, 17, 3)) +>p3 : Symbol(p3, Decl(transformsElideNullUndefinedType.ts, 17, 19)) + +var f10 = (p4: null) => { } +>f10 : Symbol(f10, Decl(transformsElideNullUndefinedType.ts, 19, 3)) +>p4 : Symbol(p4, Decl(transformsElideNullUndefinedType.ts, 19, 11)) + +var f11 = (p5: undefined) => { } +>f11 : Symbol(f11, Decl(transformsElideNullUndefinedType.ts, 20, 3)) +>p5 : Symbol(p5, Decl(transformsElideNullUndefinedType.ts, 20, 11)) + +class C1 { +>C1 : Symbol(C1, Decl(transformsElideNullUndefinedType.ts, 20, 32)) m0(): null { return null; } ->m0 : Symbol(C.m0, Decl(transformsElideNullUndefinedType.ts, 16, 12)) +>m0 : Symbol(C1.m0, Decl(transformsElideNullUndefinedType.ts, 22, 10)) m1(): undefined { return undefined; } ->m1 : Symbol(C.m1, Decl(transformsElideNullUndefinedType.ts, 17, 31)) +>m1 : Symbol(C1.m1, Decl(transformsElideNullUndefinedType.ts, 23, 31)) >undefined : Symbol(undefined) + m3(p6: null) { } +>m3 : Symbol(C1.m3, Decl(transformsElideNullUndefinedType.ts, 24, 41)) +>p6 : Symbol(p6, Decl(transformsElideNullUndefinedType.ts, 26, 7)) + + m4(p7: undefined) { } +>m4 : Symbol(C1.m4, Decl(transformsElideNullUndefinedType.ts, 26, 20)) +>p7 : Symbol(p7, Decl(transformsElideNullUndefinedType.ts, 27, 7)) + get a0(): null { return null; } ->a0 : Symbol(C.a0, Decl(transformsElideNullUndefinedType.ts, 18, 41)) +>a0 : Symbol(C1.a0, Decl(transformsElideNullUndefinedType.ts, 27, 25)) get a1(): undefined { return undefined; } ->a1 : Symbol(C.a1, Decl(transformsElideNullUndefinedType.ts, 20, 35)) +>a1 : Symbol(C1.a1, Decl(transformsElideNullUndefinedType.ts, 29, 35)) >undefined : Symbol(undefined) + + set a2(p8: null) { } +>a2 : Symbol(C1.a2, Decl(transformsElideNullUndefinedType.ts, 30, 45)) +>p8 : Symbol(p8, Decl(transformsElideNullUndefinedType.ts, 32, 11)) + + set a3(p9: undefined) { } +>a3 : Symbol(C1.a3, Decl(transformsElideNullUndefinedType.ts, 32, 24)) +>p9 : Symbol(p9, Decl(transformsElideNullUndefinedType.ts, 33, 11)) } +class C2 { constructor(p10: null) { } } +>C2 : Symbol(C2, Decl(transformsElideNullUndefinedType.ts, 34, 1)) +>p10 : Symbol(p10, Decl(transformsElideNullUndefinedType.ts, 36, 23)) + +class C3 { constructor(p11: undefined) { } } +>C3 : Symbol(C3, Decl(transformsElideNullUndefinedType.ts, 36, 39)) +>p11 : Symbol(p11, Decl(transformsElideNullUndefinedType.ts, 37, 23)) + +class C4 { +>C4 : Symbol(C4, Decl(transformsElideNullUndefinedType.ts, 37, 44)) + + f1; +>f1 : Symbol(C4.f1, Decl(transformsElideNullUndefinedType.ts, 39, 10)) + + constructor(p12: null) { } +>p12 : Symbol(p12, Decl(transformsElideNullUndefinedType.ts, 41, 16)) +} + +class C5 { +>C5 : Symbol(C5, Decl(transformsElideNullUndefinedType.ts, 42, 1)) + + f2; +>f2 : Symbol(C5.f2, Decl(transformsElideNullUndefinedType.ts, 44, 10)) + + constructor(p13: undefined) { } +>p13 : Symbol(p13, Decl(transformsElideNullUndefinedType.ts, 46, 16)) +} + +var C6 = class { constructor(p12: null) { } } +>C6 : Symbol(C6, Decl(transformsElideNullUndefinedType.ts, 49, 3)) +>p12 : Symbol(p12, Decl(transformsElideNullUndefinedType.ts, 49, 29)) + +var C7 = class { constructor(p13: undefined) { } } +>C7 : Symbol(C7, Decl(transformsElideNullUndefinedType.ts, 50, 3)) +>p13 : Symbol(p13, Decl(transformsElideNullUndefinedType.ts, 50, 29)) + declare function fn(); ->fn : Symbol(fn, Decl(transformsElideNullUndefinedType.ts, 22, 1)) ->T : Symbol(T, Decl(transformsElideNullUndefinedType.ts, 24, 20)) +>fn : Symbol(fn, Decl(transformsElideNullUndefinedType.ts, 50, 50)) +>T : Symbol(T, Decl(transformsElideNullUndefinedType.ts, 52, 20)) fn(); ->fn : Symbol(fn, Decl(transformsElideNullUndefinedType.ts, 22, 1)) +>fn : Symbol(fn, Decl(transformsElideNullUndefinedType.ts, 50, 50)) fn(); ->fn : Symbol(fn, Decl(transformsElideNullUndefinedType.ts, 22, 1)) +>fn : Symbol(fn, Decl(transformsElideNullUndefinedType.ts, 50, 50)) -new C(); ->C : Symbol(C, Decl(transformsElideNullUndefinedType.ts, 14, 30)) +declare class D {} +>D : Symbol(D, Decl(transformsElideNullUndefinedType.ts, 54, 16)) +>T : Symbol(T, Decl(transformsElideNullUndefinedType.ts, 56, 16)) -new C(); ->C : Symbol(C, Decl(transformsElideNullUndefinedType.ts, 14, 30)) +new D(); +>D : Symbol(D, Decl(transformsElideNullUndefinedType.ts, 54, 16)) + +new D(); +>D : Symbol(D, Decl(transformsElideNullUndefinedType.ts, 54, 16)) diff --git a/tests/baselines/reference/transformsElideNullUndefinedType.types b/tests/baselines/reference/transformsElideNullUndefinedType.types index 66a73c83141..7f48d8a00e9 100644 --- a/tests/baselines/reference/transformsElideNullUndefinedType.types +++ b/tests/baselines/reference/transformsElideNullUndefinedType.types @@ -47,9 +47,30 @@ function f7(p1: undefined) { } >f7 : (p1: undefined) => void >p1 : undefined -class C { ->C : C ->T : T +var f8 = function (p2: null) { } +>f8 : (p2: null) => void +>function (p2: null) { } : (p2: null) => void +>p2 : null +>null : null + +var f9 = function (p3: undefined) { } +>f9 : (p3: undefined) => void +>function (p3: undefined) { } : (p3: undefined) => void +>p3 : undefined + +var f10 = (p4: null) => { } +>f10 : (p4: null) => void +>(p4: null) => { } : (p4: null) => void +>p4 : null +>null : null + +var f11 = (p5: undefined) => { } +>f11 : (p5: undefined) => void +>(p5: undefined) => { } : (p5: undefined) => void +>p5 : undefined + +class C1 { +>C1 : C1 m0(): null { return null; } >m0 : () => null @@ -60,6 +81,15 @@ class C { >m1 : () => undefined >undefined : undefined + m3(p6: null) { } +>m3 : (p6: null) => void +>p6 : null +>null : null + + m4(p7: undefined) { } +>m4 : (p7: undefined) => void +>p7 : undefined + get a0(): null { return null; } >a0 : null >null : null @@ -68,8 +98,58 @@ class C { get a1(): undefined { return undefined; } >a1 : undefined >undefined : undefined + + set a2(p8: null) { } +>a2 : null +>p8 : null +>null : null + + set a3(p9: undefined) { } +>a3 : undefined +>p9 : undefined } +class C2 { constructor(p10: null) { } } +>C2 : C2 +>p10 : null +>null : null + +class C3 { constructor(p11: undefined) { } } +>C3 : C3 +>p11 : undefined + +class C4 { +>C4 : C4 + + f1; +>f1 : any + + constructor(p12: null) { } +>p12 : null +>null : null +} + +class C5 { +>C5 : C5 + + f2; +>f2 : any + + constructor(p13: undefined) { } +>p13 : undefined +} + +var C6 = class { constructor(p12: null) { } } +>C6 : typeof (Anonymous class) +>class { constructor(p12: null) { } } : typeof (Anonymous class) +>p12 : null +>null : null + +var C7 = class { constructor(p13: undefined) { } } +>C7 : typeof (Anonymous class) +>class { constructor(p13: undefined) { } } : typeof (Anonymous class) +>p13 : undefined + declare function fn(); >fn : () => any >T : T @@ -83,12 +163,16 @@ fn(); >fn() : any >fn : () => any -new C(); ->new C() : C ->C : typeof C +declare class D {} +>D : D +>T : T + +new D(); +>new D() : D +>D : typeof D >null : null -new C(); ->new C() : C ->C : typeof C +new D(); +>new D() : D +>D : typeof D diff --git a/tests/cases/compiler/transformsElideNullUndefinedType.ts b/tests/cases/compiler/transformsElideNullUndefinedType.ts index 244f2ea9c75..4a493a91d88 100644 --- a/tests/cases/compiler/transformsElideNullUndefinedType.ts +++ b/tests/cases/compiler/transformsElideNullUndefinedType.ts @@ -15,18 +15,46 @@ var f5 = (): undefined => undefined; function f6(p0: null) { } function f7(p1: undefined) { } -class C { +var f8 = function (p2: null) { } +var f9 = function (p3: undefined) { } + +var f10 = (p4: null) => { } +var f11 = (p5: undefined) => { } + +class C1 { m0(): null { return null; } m1(): undefined { return undefined; } + m3(p6: null) { } + m4(p7: undefined) { } + get a0(): null { return null; } get a1(): undefined { return undefined; } + + set a2(p8: null) { } + set a3(p9: undefined) { } } -declare function fn(); +class C2 { constructor(p10: null) { } } +class C3 { constructor(p11: undefined) { } } +class C4 { + f1; + constructor(p12: null) { } +} + +class C5 { + f2; + constructor(p13: undefined) { } +} + +var C6 = class { constructor(p12: null) { } } +var C7 = class { constructor(p13: undefined) { } } + +declare function fn(); fn(); fn(); -new C(); -new C(); \ No newline at end of file +declare class D {} +new D(); +new D(); \ No newline at end of file From 8094b2c5def5ed39e5a9ddc18bfd09bab731aa11 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 16 Oct 2016 17:28:45 -0700 Subject: [PATCH 109/173] Improve contextual typing of partially annotated signatures --- src/compiler/checker.ts | 66 +++++++++++++++++++++++++++++------------ 1 file changed, 47 insertions(+), 19 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 22ab44ee089..b3b6557c98b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3144,8 +3144,7 @@ namespace ts { // Use contextual parameter type if one is available let type: Type; if (declaration.symbol.name === "this") { - const thisParameter = getContextualThisParameter(func); - type = thisParameter ? getTypeOfSymbol(thisParameter) : undefined; + type = getContextualThisParameterType(func); } else { type = getContextuallyTypedParameterType(declaration); @@ -4789,9 +4788,6 @@ namespace ts { if (isJSConstructSignature) { minArgumentCount--; } - if (!thisParameter && isObjectLiteralMethod(declaration)) { - thisParameter = getContextualThisParameter(declaration); - } const classType = declaration.kind === SyntaxKind.Constructor ? getDeclaredTypeOfClassOrInterface(getMergedSymbol((declaration.parent).symbol)) @@ -6101,9 +6097,24 @@ namespace ts { } function isContextSensitiveFunctionLikeDeclaration(node: FunctionLikeDeclaration) { - const areAllParametersUntyped = !forEach(node.parameters, p => p.type); - const isNullaryArrow = node.kind === SyntaxKind.ArrowFunction && !node.parameters.length; - return !node.typeParameters && areAllParametersUntyped && !isNullaryArrow; + // Functions with type parameters are not context sensitive. + if (node.typeParameters) { + return false; + } + // Functions with any parameters that lack type annotations are context sensitive. + if (forEach(node.parameters, p => !p.type)) { + return true; + } + // For arrow functions we now know we're not context sensitive. + if (node.kind === SyntaxKind.ArrowFunction) { + return false; + } + // If the first parameter is not an explicit 'this' parameter, then the function has + // an implicit 'this' parameter which is subject to contextual typing. Otherwise we + // know that all parameters (including 'this') have type annotations and nothing is + // subject to contextual typing. + const parameter = firstOrUndefined(node.parameters); + return !(parameter && parameter.name.kind === SyntaxKind.Identifier && (parameter.name).text === "this"); } function isContextSensitiveFunctionOrObjectLiteralMethod(func: Node): func is FunctionExpression | ArrowFunction | MethodDeclaration { @@ -9629,7 +9640,7 @@ namespace ts { } } - const thisType = getThisTypeOfDeclaration(container); + let thisType = getThisTypeOfDeclaration(container) || getContextualThisParameterType(container); if (thisType) { return thisType; } @@ -9869,14 +9880,16 @@ namespace ts { } } - function getContextualThisParameter(func: FunctionLikeDeclaration): Symbol { + function getContextualThisParameterType(func: FunctionLikeDeclaration): Type { if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== SyntaxKind.ArrowFunction) { const contextualSignature = getContextualSignature(func); if (contextualSignature) { - return contextualSignature.thisParameter; + const thisParameter = contextualSignature.thisParameter; + if (thisParameter) { + return getTypeOfSymbol(thisParameter); + } } } - return undefined; } @@ -12840,21 +12853,36 @@ namespace ts { function assignContextualParameterTypes(signature: Signature, context: Signature, mapper: TypeMapper) { const len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + if (isInferentialContext(mapper)) { + for (let i = 0; i < len; i++) { + const declaration = signature.parameters[i].valueDeclaration; + if (declaration.type) { + inferTypes(mapper.context, getTypeFromTypeNode(declaration.type), getTypeAtPosition(context, i)); + } + } + } if (context.thisParameter) { - if (!signature.thisParameter) { - signature.thisParameter = createTransientSymbol(context.thisParameter, undefined); + const parameter = signature.thisParameter; + if (!parameter || parameter.valueDeclaration && !(parameter.valueDeclaration).type) { + if (!parameter) { + signature.thisParameter = createTransientSymbol(context.thisParameter, undefined); + } + assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper); } - assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper); } for (let i = 0; i < len; i++) { const parameter = signature.parameters[i]; - const contextualParameterType = getTypeAtPosition(context, i); - assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + if (!(parameter.valueDeclaration).type) { + const contextualParameterType = getTypeAtPosition(context, i); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + } } if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) { const parameter = lastOrUndefined(signature.parameters); - const contextualParameterType = getTypeOfSymbol(lastOrUndefined(context.parameters)); - assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + if (!(parameter.valueDeclaration).type) { + const contextualParameterType = getTypeOfSymbol(lastOrUndefined(context.parameters)); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + } } } From 808db07ce44d46574e88d15ba706bb79bdd160f3 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 16 Oct 2016 17:31:57 -0700 Subject: [PATCH 110/173] Accept new baselines --- tests/baselines/reference/thisTypeInFunctions.types | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/baselines/reference/thisTypeInFunctions.types b/tests/baselines/reference/thisTypeInFunctions.types index 44bf23ad509..a2aaba4cdd7 100644 --- a/tests/baselines/reference/thisTypeInFunctions.types +++ b/tests/baselines/reference/thisTypeInFunctions.types @@ -453,7 +453,7 @@ let anyToSpecified: (this: { y: number }, x: number) => number = function(x: num >this : { y: number; } >y : number >x : number ->function(x: number): number { return x + 12; } : (x: number) => number +>function(x: number): number { return x + 12; } : (this: { y: number; }, x: number) => number >x : number >x + 12 : number >x : number From 6425f0ccfdbec7f7f189589cd8f49a829ef785a8 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 16 Oct 2016 17:37:37 -0700 Subject: [PATCH 111/173] Fix lint error --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b3b6557c98b..db95eb9bc17 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9640,7 +9640,7 @@ namespace ts { } } - let thisType = getThisTypeOfDeclaration(container) || getContextualThisParameterType(container); + const thisType = getThisTypeOfDeclaration(container) || getContextualThisParameterType(container); if (thisType) { return thisType; } From ebba1c3d1a3c7d0a52a0531c2ec5edb9b2f94597 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Sun, 16 Oct 2016 20:57:51 -0700 Subject: [PATCH 112/173] fix flow in finally blocks --- src/compiler/binder.ts | 36 ++++++++++++++----- tests/baselines/reference/flowInFinally1.js | 33 +++++++++++++++++ .../reference/flowInFinally1.symbols | 29 +++++++++++++++ .../baselines/reference/flowInFinally1.types | 34 ++++++++++++++++++ tests/cases/compiler/flowInFinally1.ts | 16 +++++++++ 5 files changed, 140 insertions(+), 8 deletions(-) create mode 100644 tests/baselines/reference/flowInFinally1.js create mode 100644 tests/baselines/reference/flowInFinally1.symbols create mode 100644 tests/baselines/reference/flowInFinally1.types create mode 100644 tests/cases/compiler/flowInFinally1.ts diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 4711d54e0b2..31732bc833f 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -984,24 +984,44 @@ namespace ts { } function bindTryStatement(node: TryStatement): void { - const postFinallyLabel = createBranchLabel(); + const preFinallyLabel = createBranchLabel(); const preTryFlow = currentFlow; // TODO: Every statement in try block is potentially an exit point! bind(node.tryBlock); - addAntecedent(postFinallyLabel, currentFlow); + addAntecedent(preFinallyLabel, currentFlow); + + const flowAfterTry = currentFlow; + let flowAfterCatch = unreachableFlow; + if (node.catchClause) { currentFlow = preTryFlow; bind(node.catchClause); - addAntecedent(postFinallyLabel, currentFlow); + addAntecedent(preFinallyLabel, currentFlow); + + flowAfterCatch = currentFlow; } if (node.finallyBlock) { - currentFlow = preTryFlow; + // in finally flow is combined from pre-try/flow from try/flow from catch + // pre-flow is necessary to make sure that finally is reachable even if finaly flows in both try and finally blocks are unreachable + addAntecedent(preFinallyLabel, preTryFlow); + currentFlow = finishFlowLabel(preFinallyLabel); bind(node.finallyBlock); + // if flow after finally is unreachable - keep it + // otherwise check if flows after try and after catch are unreachable + // if yes - convert current flow to unreachable + // i.e. + // try { return "1" } finally { console.log(1); } + // console.log(2); // this line should be unreachable even if flow falls out of finally block + if (!(currentFlow.flags & FlowFlags.Unreachable)) { + if ((flowAfterTry.flags & FlowFlags.Unreachable) && (flowAfterCatch.flags & FlowFlags.Unreachable)) { + currentFlow = flowAfterTry == reportedUnreachableFlow || flowAfterCatch === reportedUnreachableFlow + ? reportedUnreachableFlow + : unreachableFlow; + } + } } - // if try statement has finally block and flow after finally block is unreachable - keep it - // otherwise use whatever flow was accumulated at postFinallyLabel - if (!node.finallyBlock || !(currentFlow.flags & FlowFlags.Unreachable)) { - currentFlow = finishFlowLabel(postFinallyLabel); + else { + currentFlow = finishFlowLabel(preFinallyLabel); } } diff --git a/tests/baselines/reference/flowInFinally1.js b/tests/baselines/reference/flowInFinally1.js new file mode 100644 index 00000000000..b6bf494e832 --- /dev/null +++ b/tests/baselines/reference/flowInFinally1.js @@ -0,0 +1,33 @@ +//// [flowInFinally1.ts] + +class A { + constructor() { } + method() { } +} + +let a: A | null = null; + +try { + a = new A(); +} finally { + if (a) { + a.method(); + } +} + +//// [flowInFinally1.js] +var A = (function () { + function A() { + } + A.prototype.method = function () { }; + return A; +}()); +var a = null; +try { + a = new A(); +} +finally { + if (a) { + a.method(); + } +} diff --git a/tests/baselines/reference/flowInFinally1.symbols b/tests/baselines/reference/flowInFinally1.symbols new file mode 100644 index 00000000000..2ecedaee025 --- /dev/null +++ b/tests/baselines/reference/flowInFinally1.symbols @@ -0,0 +1,29 @@ +=== tests/cases/compiler/flowInFinally1.ts === + +class A { +>A : Symbol(A, Decl(flowInFinally1.ts, 0, 0)) + + constructor() { } + method() { } +>method : Symbol(A.method, Decl(flowInFinally1.ts, 2, 19)) +} + +let a: A | null = null; +>a : Symbol(a, Decl(flowInFinally1.ts, 6, 3)) +>A : Symbol(A, Decl(flowInFinally1.ts, 0, 0)) + +try { + a = new A(); +>a : Symbol(a, Decl(flowInFinally1.ts, 6, 3)) +>A : Symbol(A, Decl(flowInFinally1.ts, 0, 0)) + +} finally { + if (a) { +>a : Symbol(a, Decl(flowInFinally1.ts, 6, 3)) + + a.method(); +>a.method : Symbol(A.method, Decl(flowInFinally1.ts, 2, 19)) +>a : Symbol(a, Decl(flowInFinally1.ts, 6, 3)) +>method : Symbol(A.method, Decl(flowInFinally1.ts, 2, 19)) + } +} diff --git a/tests/baselines/reference/flowInFinally1.types b/tests/baselines/reference/flowInFinally1.types new file mode 100644 index 00000000000..c9cbab6dbd1 --- /dev/null +++ b/tests/baselines/reference/flowInFinally1.types @@ -0,0 +1,34 @@ +=== tests/cases/compiler/flowInFinally1.ts === + +class A { +>A : A + + constructor() { } + method() { } +>method : () => void +} + +let a: A | null = null; +>a : A | null +>A : A +>null : null +>null : null + +try { + a = new A(); +>a = new A() : A +>a : A | null +>new A() : A +>A : typeof A + +} finally { + if (a) { +>a : A | null + + a.method(); +>a.method() : void +>a.method : () => void +>a : A +>method : () => void + } +} diff --git a/tests/cases/compiler/flowInFinally1.ts b/tests/cases/compiler/flowInFinally1.ts new file mode 100644 index 00000000000..4ab2977e7df --- /dev/null +++ b/tests/cases/compiler/flowInFinally1.ts @@ -0,0 +1,16 @@ +// @strictNullChecks: true + +class A { + constructor() { } + method() { } +} + +let a: A | null = null; + +try { + a = new A(); +} finally { + if (a) { + a.method(); + } +} \ No newline at end of file From 8a2d16134d0001d5c0ce8f1b1df451f4a93af982 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 17 Oct 2016 06:09:19 -0700 Subject: [PATCH 113/173] Remove unnecessary assert --- src/server/scriptInfo.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/server/scriptInfo.ts b/src/server/scriptInfo.ts index 68dd59d2d32..2792b3e47a9 100644 --- a/src/server/scriptInfo.ts +++ b/src/server/scriptInfo.ts @@ -84,11 +84,7 @@ namespace ts.server { } getDefaultProject() { - if (this.containingProjects.length === 0) { - return Errors.ThrowNoProject(); - } - Debug.assert(this.containingProjects.length !== 0); - return this.containingProjects[0]; + return this.containingProjects.length === 0 ? Errors.ThrowNoProject() : this.containingProjects[0]; } setFormatOptions(formatSettings: FormatCodeSettings): void { From df58df17f66f13d66d304bb4076849e07c4645f7 Mon Sep 17 00:00:00 2001 From: Herrington Darkholme Date: Mon, 17 Oct 2016 09:04:16 -0700 Subject: [PATCH 114/173] Add partially annotated function tests --- ...AnnotatedFunctionInferenceError.errors.txt | 27 ++++ ...artiallyAnnotatedFunctionInferenceError.js | 39 +++++ ...tatedFunctionInferenceWithTypeParameter.js | 85 +++++++++++ ...FunctionInferenceWithTypeParameter.symbols | 114 +++++++++++++++ ...edFunctionInferenceWithTypeParameter.types | 136 ++++++++++++++++++ ...llyAnnotatedFunctionWitoutTypeParameter.js | 12 ++ ...notatedFunctionWitoutTypeParameter.symbols | 19 +++ ...AnnotatedFunctionWitoutTypeParameter.types | 23 +++ ...artiallyAnnotatedFunctionInferenceError.ts | 14 ++ ...tatedFunctionInferenceWithTypeParameter.ts | 33 +++++ ...llyAnnotatedFunctionWitoutTypeParameter.ts | 7 + 11 files changed, 509 insertions(+) create mode 100644 tests/baselines/reference/partiallyAnnotatedFunctionInferenceError.errors.txt create mode 100644 tests/baselines/reference/partiallyAnnotatedFunctionInferenceError.js create mode 100644 tests/baselines/reference/partiallyAnnotatedFunctionInferenceWithTypeParameter.js create mode 100644 tests/baselines/reference/partiallyAnnotatedFunctionInferenceWithTypeParameter.symbols create mode 100644 tests/baselines/reference/partiallyAnnotatedFunctionInferenceWithTypeParameter.types create mode 100644 tests/baselines/reference/partiallyAnnotatedFunctionWitoutTypeParameter.js create mode 100644 tests/baselines/reference/partiallyAnnotatedFunctionWitoutTypeParameter.symbols create mode 100644 tests/baselines/reference/partiallyAnnotatedFunctionWitoutTypeParameter.types create mode 100644 tests/cases/conformance/types/contextualTypes/partiallyAnnotatedFunction/partiallyAnnotatedFunctionInferenceError.ts create mode 100644 tests/cases/conformance/types/contextualTypes/partiallyAnnotatedFunction/partiallyAnnotatedFunctionInferenceWithTypeParameter.ts create mode 100644 tests/cases/conformance/types/contextualTypes/partiallyAnnotatedFunction/partiallyAnnotatedFunctionWitoutTypeParameter.ts diff --git a/tests/baselines/reference/partiallyAnnotatedFunctionInferenceError.errors.txt b/tests/baselines/reference/partiallyAnnotatedFunctionInferenceError.errors.txt new file mode 100644 index 00000000000..a9fc9b68cf8 --- /dev/null +++ b/tests/baselines/reference/partiallyAnnotatedFunctionInferenceError.errors.txt @@ -0,0 +1,27 @@ +tests/cases/conformance/types/contextualTypes/partiallyAnnotatedFunction/partiallyAnnotatedFunctionInferenceError.ts(12,11): error TS2345: Argument of type '(t1: D, t2: D, t3: any) => void' is not assignable to parameter of type '(t: D, t1: D) => void'. +tests/cases/conformance/types/contextualTypes/partiallyAnnotatedFunction/partiallyAnnotatedFunctionInferenceError.ts(13,11): error TS2345: Argument of type '(t1: D, t2: D, t3: any) => void' is not assignable to parameter of type '(t: D, t1: D) => void'. +tests/cases/conformance/types/contextualTypes/partiallyAnnotatedFunction/partiallyAnnotatedFunctionInferenceError.ts(14,11): error TS2345: Argument of type '(t1: C, t2: C, t3: D) => void' is not assignable to parameter of type '(t: C, t1: C) => void'. + + +==== tests/cases/conformance/types/contextualTypes/partiallyAnnotatedFunction/partiallyAnnotatedFunctionInferenceError.ts (3 errors) ==== + class C { + test: string + } + + class D extends C { + test2: string + } + + declare function testError(a: (t: T, t1: T) => void): T + + // more args + testError((t1: D, t2, t3) => {}) + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '(t1: D, t2: D, t3: any) => void' is not assignable to parameter of type '(t: D, t1: D) => void'. + testError((t1, t2: D, t3) => {}) + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '(t1: D, t2: D, t3: any) => void' is not assignable to parameter of type '(t: D, t1: D) => void'. + testError((t1, t2, t3: D) => {}) + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type '(t1: C, t2: C, t3: D) => void' is not assignable to parameter of type '(t: C, t1: C) => void'. + \ No newline at end of file diff --git a/tests/baselines/reference/partiallyAnnotatedFunctionInferenceError.js b/tests/baselines/reference/partiallyAnnotatedFunctionInferenceError.js new file mode 100644 index 00000000000..9702595fffb --- /dev/null +++ b/tests/baselines/reference/partiallyAnnotatedFunctionInferenceError.js @@ -0,0 +1,39 @@ +//// [partiallyAnnotatedFunctionInferenceError.ts] +class C { + test: string +} + +class D extends C { + test2: string +} + +declare function testError(a: (t: T, t1: T) => void): T + +// more args +testError((t1: D, t2, t3) => {}) +testError((t1, t2: D, t3) => {}) +testError((t1, t2, t3: D) => {}) + + +//// [partiallyAnnotatedFunctionInferenceError.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var C = (function () { + function C() { + } + return C; +}()); +var D = (function (_super) { + __extends(D, _super); + function D() { + return _super.apply(this, arguments) || this; + } + return D; +}(C)); +// more args +testError(function (t1, t2, t3) { }); +testError(function (t1, t2, t3) { }); +testError(function (t1, t2, t3) { }); diff --git a/tests/baselines/reference/partiallyAnnotatedFunctionInferenceWithTypeParameter.js b/tests/baselines/reference/partiallyAnnotatedFunctionInferenceWithTypeParameter.js new file mode 100644 index 00000000000..d485fb11d7f --- /dev/null +++ b/tests/baselines/reference/partiallyAnnotatedFunctionInferenceWithTypeParameter.js @@ -0,0 +1,85 @@ +//// [partiallyAnnotatedFunctionInferenceWithTypeParameter.ts] +class C { + test: string +} + +class D extends C { + test2: string +} + +declare function test(a: (t: T, t1: T) => void): T + +declare function testRest(a: (t: T, t1: T, ...ts: T[]) => void): T + + +// exactly +test((t1: D, t2) => { t2.test2 }) +test((t1, t2: D) => { t2.test2 }) + +// zero arg +test(() => {}) + +// fewer args +test((t1: D) => {}) + +// rest arg +test((...ts: D[]) => {}) + +// source function has rest arg +testRest((t1: D) => {}) +testRest((t1, t2, t3) => {}) +testRest((t1: D, t2, t3) => {}) +testRest((t1, t2: D, t3) => {}) +testRest((t2: D, ...t3) => {}) +testRest((t2, ...t3: D[]) => {}) + + +//// [partiallyAnnotatedFunctionInferenceWithTypeParameter.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var C = (function () { + function C() { + } + return C; +}()); +var D = (function (_super) { + __extends(D, _super); + function D() { + return _super.apply(this, arguments) || this; + } + return D; +}(C)); +// exactly +test(function (t1, t2) { t2.test2; }); +test(function (t1, t2) { t2.test2; }); +// zero arg +test(function () { }); +// fewer args +test(function (t1) { }); +// rest arg +test(function () { + var ts = []; + for (var _i = 0; _i < arguments.length; _i++) { + ts[_i - 0] = arguments[_i]; + } +}); +// source function has rest arg +testRest(function (t1) { }); +testRest(function (t1, t2, t3) { }); +testRest(function (t1, t2, t3) { }); +testRest(function (t1, t2, t3) { }); +testRest(function (t2) { + var t3 = []; + for (var _i = 1; _i < arguments.length; _i++) { + t3[_i - 1] = arguments[_i]; + } +}); +testRest(function (t2) { + var t3 = []; + for (var _i = 1; _i < arguments.length; _i++) { + t3[_i - 1] = arguments[_i]; + } +}); diff --git a/tests/baselines/reference/partiallyAnnotatedFunctionInferenceWithTypeParameter.symbols b/tests/baselines/reference/partiallyAnnotatedFunctionInferenceWithTypeParameter.symbols new file mode 100644 index 00000000000..b3c66f8f8cd --- /dev/null +++ b/tests/baselines/reference/partiallyAnnotatedFunctionInferenceWithTypeParameter.symbols @@ -0,0 +1,114 @@ +=== tests/cases/conformance/types/contextualTypes/partiallyAnnotatedFunction/partiallyAnnotatedFunctionInferenceWithTypeParameter.ts === +class C { +>C : Symbol(C, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 0, 0)) + + test: string +>test : Symbol(C.test, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 0, 9)) +} + +class D extends C { +>D : Symbol(D, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 2, 1)) +>C : Symbol(C, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 0, 0)) + + test2: string +>test2 : Symbol(D.test2, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 4, 19)) +} + +declare function test(a: (t: T, t1: T) => void): T +>test : Symbol(test, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 6, 1)) +>T : Symbol(T, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 8, 22)) +>C : Symbol(C, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 0, 0)) +>a : Symbol(a, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 8, 35)) +>t : Symbol(t, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 8, 39)) +>T : Symbol(T, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 8, 22)) +>t1 : Symbol(t1, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 8, 44)) +>T : Symbol(T, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 8, 22)) +>T : Symbol(T, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 8, 22)) + +declare function testRest(a: (t: T, t1: T, ...ts: T[]) => void): T +>testRest : Symbol(testRest, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 8, 63)) +>T : Symbol(T, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 10, 26)) +>C : Symbol(C, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 0, 0)) +>a : Symbol(a, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 10, 39)) +>t : Symbol(t, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 10, 43)) +>T : Symbol(T, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 10, 26)) +>t1 : Symbol(t1, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 10, 48)) +>T : Symbol(T, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 10, 26)) +>ts : Symbol(ts, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 10, 55)) +>T : Symbol(T, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 10, 26)) +>T : Symbol(T, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 10, 26)) + + +// exactly +test((t1: D, t2) => { t2.test2 }) +>test : Symbol(test, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 6, 1)) +>t1 : Symbol(t1, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 14, 6)) +>D : Symbol(D, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 2, 1)) +>t2 : Symbol(t2, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 14, 12)) +>t2.test2 : Symbol(D.test2, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 4, 19)) +>t2 : Symbol(t2, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 14, 12)) +>test2 : Symbol(D.test2, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 4, 19)) + +test((t1, t2: D) => { t2.test2 }) +>test : Symbol(test, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 6, 1)) +>t1 : Symbol(t1, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 15, 6)) +>t2 : Symbol(t2, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 15, 9)) +>D : Symbol(D, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 2, 1)) +>t2.test2 : Symbol(D.test2, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 4, 19)) +>t2 : Symbol(t2, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 15, 9)) +>test2 : Symbol(D.test2, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 4, 19)) + +// zero arg +test(() => {}) +>test : Symbol(test, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 6, 1)) + +// fewer args +test((t1: D) => {}) +>test : Symbol(test, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 6, 1)) +>t1 : Symbol(t1, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 21, 6)) +>D : Symbol(D, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 2, 1)) + +// rest arg +test((...ts: D[]) => {}) +>test : Symbol(test, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 6, 1)) +>ts : Symbol(ts, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 24, 6)) +>D : Symbol(D, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 2, 1)) + +// source function has rest arg +testRest((t1: D) => {}) +>testRest : Symbol(testRest, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 8, 63)) +>t1 : Symbol(t1, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 27, 10)) +>D : Symbol(D, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 2, 1)) + +testRest((t1, t2, t3) => {}) +>testRest : Symbol(testRest, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 8, 63)) +>t1 : Symbol(t1, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 28, 10)) +>t2 : Symbol(t2, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 28, 13)) +>t3 : Symbol(t3, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 28, 17)) + +testRest((t1: D, t2, t3) => {}) +>testRest : Symbol(testRest, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 8, 63)) +>t1 : Symbol(t1, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 29, 10)) +>D : Symbol(D, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 2, 1)) +>t2 : Symbol(t2, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 29, 16)) +>t3 : Symbol(t3, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 29, 20)) + +testRest((t1, t2: D, t3) => {}) +>testRest : Symbol(testRest, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 8, 63)) +>t1 : Symbol(t1, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 30, 10)) +>t2 : Symbol(t2, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 30, 13)) +>D : Symbol(D, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 2, 1)) +>t3 : Symbol(t3, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 30, 20)) + +testRest((t2: D, ...t3) => {}) +>testRest : Symbol(testRest, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 8, 63)) +>t2 : Symbol(t2, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 31, 10)) +>D : Symbol(D, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 2, 1)) +>t3 : Symbol(t3, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 31, 16)) + +testRest((t2, ...t3: D[]) => {}) +>testRest : Symbol(testRest, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 8, 63)) +>t2 : Symbol(t2, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 32, 10)) +>t3 : Symbol(t3, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 32, 13)) +>D : Symbol(D, Decl(partiallyAnnotatedFunctionInferenceWithTypeParameter.ts, 2, 1)) + diff --git a/tests/baselines/reference/partiallyAnnotatedFunctionInferenceWithTypeParameter.types b/tests/baselines/reference/partiallyAnnotatedFunctionInferenceWithTypeParameter.types new file mode 100644 index 00000000000..c2113ae4d75 --- /dev/null +++ b/tests/baselines/reference/partiallyAnnotatedFunctionInferenceWithTypeParameter.types @@ -0,0 +1,136 @@ +=== tests/cases/conformance/types/contextualTypes/partiallyAnnotatedFunction/partiallyAnnotatedFunctionInferenceWithTypeParameter.ts === +class C { +>C : C + + test: string +>test : string +} + +class D extends C { +>D : D +>C : C + + test2: string +>test2 : string +} + +declare function test(a: (t: T, t1: T) => void): T +>test : (a: (t: T, t1: T) => void) => T +>T : T +>C : C +>a : (t: T, t1: T) => void +>t : T +>T : T +>t1 : T +>T : T +>T : T + +declare function testRest(a: (t: T, t1: T, ...ts: T[]) => void): T +>testRest : (a: (t: T, t1: T, ...ts: T[]) => void) => T +>T : T +>C : C +>a : (t: T, t1: T, ...ts: T[]) => void +>t : T +>T : T +>t1 : T +>T : T +>ts : T[] +>T : T +>T : T + + +// exactly +test((t1: D, t2) => { t2.test2 }) +>test((t1: D, t2) => { t2.test2 }) : D +>test : (a: (t: T, t1: T) => void) => T +>(t1: D, t2) => { t2.test2 } : (t1: D, t2: D) => void +>t1 : D +>D : D +>t2 : D +>t2.test2 : string +>t2 : D +>test2 : string + +test((t1, t2: D) => { t2.test2 }) +>test((t1, t2: D) => { t2.test2 }) : D +>test : (a: (t: T, t1: T) => void) => T +>(t1, t2: D) => { t2.test2 } : (t1: D, t2: D) => void +>t1 : D +>t2 : D +>D : D +>t2.test2 : string +>t2 : D +>test2 : string + +// zero arg +test(() => {}) +>test(() => {}) : C +>test : (a: (t: T, t1: T) => void) => T +>() => {} : () => void + +// fewer args +test((t1: D) => {}) +>test((t1: D) => {}) : D +>test : (a: (t: T, t1: T) => void) => T +>(t1: D) => {} : (t1: D) => void +>t1 : D +>D : D + +// rest arg +test((...ts: D[]) => {}) +>test((...ts: D[]) => {}) : D +>test : (a: (t: T, t1: T) => void) => T +>(...ts: D[]) => {} : (...ts: D[]) => void +>ts : D[] +>D : D + +// source function has rest arg +testRest((t1: D) => {}) +>testRest((t1: D) => {}) : D +>testRest : (a: (t: T, t1: T, ...ts: T[]) => void) => T +>(t1: D) => {} : (t1: D) => void +>t1 : D +>D : D + +testRest((t1, t2, t3) => {}) +>testRest((t1, t2, t3) => {}) : C +>testRest : (a: (t: T, t1: T, ...ts: T[]) => void) => T +>(t1, t2, t3) => {} : (t1: C, t2: C, t3: C) => void +>t1 : C +>t2 : C +>t3 : C + +testRest((t1: D, t2, t3) => {}) +>testRest((t1: D, t2, t3) => {}) : D +>testRest : (a: (t: T, t1: T, ...ts: T[]) => void) => T +>(t1: D, t2, t3) => {} : (t1: D, t2: D, t3: D) => void +>t1 : D +>D : D +>t2 : D +>t3 : D + +testRest((t1, t2: D, t3) => {}) +>testRest((t1, t2: D, t3) => {}) : D +>testRest : (a: (t: T, t1: T, ...ts: T[]) => void) => T +>(t1, t2: D, t3) => {} : (t1: D, t2: D, t3: D) => void +>t1 : D +>t2 : D +>D : D +>t3 : D + +testRest((t2: D, ...t3) => {}) +>testRest((t2: D, ...t3) => {}) : any +>testRest : (a: (t: T, t1: T, ...ts: T[]) => void) => T +>(t2: D, ...t3) => {} : (t2: D, ...t3: any[]) => void +>t2 : D +>D : D +>t3 : any[] + +testRest((t2, ...t3: D[]) => {}) +>testRest((t2, ...t3: D[]) => {}) : C +>testRest : (a: (t: T, t1: T, ...ts: T[]) => void) => T +>(t2, ...t3: D[]) => {} : (t2: C, ...t3: D[]) => void +>t2 : C +>t3 : D[] +>D : D + diff --git a/tests/baselines/reference/partiallyAnnotatedFunctionWitoutTypeParameter.js b/tests/baselines/reference/partiallyAnnotatedFunctionWitoutTypeParameter.js new file mode 100644 index 00000000000..8b81ff506fe --- /dev/null +++ b/tests/baselines/reference/partiallyAnnotatedFunctionWitoutTypeParameter.js @@ -0,0 +1,12 @@ +//// [partiallyAnnotatedFunctionWitoutTypeParameter.ts] + +// simple case +declare function simple(f: (a: number, b: number) => void): {} + +simple((a: number, b) => {}) +simple((a, b: number) => {}) + + +//// [partiallyAnnotatedFunctionWitoutTypeParameter.js] +simple(function (a, b) { }); +simple(function (a, b) { }); diff --git a/tests/baselines/reference/partiallyAnnotatedFunctionWitoutTypeParameter.symbols b/tests/baselines/reference/partiallyAnnotatedFunctionWitoutTypeParameter.symbols new file mode 100644 index 00000000000..a7ed6b67d83 --- /dev/null +++ b/tests/baselines/reference/partiallyAnnotatedFunctionWitoutTypeParameter.symbols @@ -0,0 +1,19 @@ +=== tests/cases/conformance/types/contextualTypes/partiallyAnnotatedFunction/partiallyAnnotatedFunctionWitoutTypeParameter.ts === + +// simple case +declare function simple(f: (a: number, b: number) => void): {} +>simple : Symbol(simple, Decl(partiallyAnnotatedFunctionWitoutTypeParameter.ts, 0, 0)) +>f : Symbol(f, Decl(partiallyAnnotatedFunctionWitoutTypeParameter.ts, 2, 24)) +>a : Symbol(a, Decl(partiallyAnnotatedFunctionWitoutTypeParameter.ts, 2, 28)) +>b : Symbol(b, Decl(partiallyAnnotatedFunctionWitoutTypeParameter.ts, 2, 38)) + +simple((a: number, b) => {}) +>simple : Symbol(simple, Decl(partiallyAnnotatedFunctionWitoutTypeParameter.ts, 0, 0)) +>a : Symbol(a, Decl(partiallyAnnotatedFunctionWitoutTypeParameter.ts, 4, 8)) +>b : Symbol(b, Decl(partiallyAnnotatedFunctionWitoutTypeParameter.ts, 4, 18)) + +simple((a, b: number) => {}) +>simple : Symbol(simple, Decl(partiallyAnnotatedFunctionWitoutTypeParameter.ts, 0, 0)) +>a : Symbol(a, Decl(partiallyAnnotatedFunctionWitoutTypeParameter.ts, 5, 8)) +>b : Symbol(b, Decl(partiallyAnnotatedFunctionWitoutTypeParameter.ts, 5, 10)) + diff --git a/tests/baselines/reference/partiallyAnnotatedFunctionWitoutTypeParameter.types b/tests/baselines/reference/partiallyAnnotatedFunctionWitoutTypeParameter.types new file mode 100644 index 00000000000..f07cd5a8928 --- /dev/null +++ b/tests/baselines/reference/partiallyAnnotatedFunctionWitoutTypeParameter.types @@ -0,0 +1,23 @@ +=== tests/cases/conformance/types/contextualTypes/partiallyAnnotatedFunction/partiallyAnnotatedFunctionWitoutTypeParameter.ts === + +// simple case +declare function simple(f: (a: number, b: number) => void): {} +>simple : (f: (a: number, b: number) => void) => {} +>f : (a: number, b: number) => void +>a : number +>b : number + +simple((a: number, b) => {}) +>simple((a: number, b) => {}) : {} +>simple : (f: (a: number, b: number) => void) => {} +>(a: number, b) => {} : (a: number, b: number) => void +>a : number +>b : number + +simple((a, b: number) => {}) +>simple((a, b: number) => {}) : {} +>simple : (f: (a: number, b: number) => void) => {} +>(a, b: number) => {} : (a: number, b: number) => void +>a : number +>b : number + diff --git a/tests/cases/conformance/types/contextualTypes/partiallyAnnotatedFunction/partiallyAnnotatedFunctionInferenceError.ts b/tests/cases/conformance/types/contextualTypes/partiallyAnnotatedFunction/partiallyAnnotatedFunctionInferenceError.ts new file mode 100644 index 00000000000..867b6526c12 --- /dev/null +++ b/tests/cases/conformance/types/contextualTypes/partiallyAnnotatedFunction/partiallyAnnotatedFunctionInferenceError.ts @@ -0,0 +1,14 @@ +class C { + test: string +} + +class D extends C { + test2: string +} + +declare function testError(a: (t: T, t1: T) => void): T + +// more args +testError((t1: D, t2, t3) => {}) +testError((t1, t2: D, t3) => {}) +testError((t1, t2, t3: D) => {}) diff --git a/tests/cases/conformance/types/contextualTypes/partiallyAnnotatedFunction/partiallyAnnotatedFunctionInferenceWithTypeParameter.ts b/tests/cases/conformance/types/contextualTypes/partiallyAnnotatedFunction/partiallyAnnotatedFunctionInferenceWithTypeParameter.ts new file mode 100644 index 00000000000..530d506f64c --- /dev/null +++ b/tests/cases/conformance/types/contextualTypes/partiallyAnnotatedFunction/partiallyAnnotatedFunctionInferenceWithTypeParameter.ts @@ -0,0 +1,33 @@ +class C { + test: string +} + +class D extends C { + test2: string +} + +declare function test(a: (t: T, t1: T) => void): T + +declare function testRest(a: (t: T, t1: T, ...ts: T[]) => void): T + + +// exactly +test((t1: D, t2) => { t2.test2 }) +test((t1, t2: D) => { t2.test2 }) + +// zero arg +test(() => {}) + +// fewer args +test((t1: D) => {}) + +// rest arg +test((...ts: D[]) => {}) + +// source function has rest arg +testRest((t1: D) => {}) +testRest((t1, t2, t3) => {}) +testRest((t1: D, t2, t3) => {}) +testRest((t1, t2: D, t3) => {}) +testRest((t2: D, ...t3) => {}) +testRest((t2, ...t3: D[]) => {}) diff --git a/tests/cases/conformance/types/contextualTypes/partiallyAnnotatedFunction/partiallyAnnotatedFunctionWitoutTypeParameter.ts b/tests/cases/conformance/types/contextualTypes/partiallyAnnotatedFunction/partiallyAnnotatedFunctionWitoutTypeParameter.ts new file mode 100644 index 00000000000..994df11e247 --- /dev/null +++ b/tests/cases/conformance/types/contextualTypes/partiallyAnnotatedFunction/partiallyAnnotatedFunctionWitoutTypeParameter.ts @@ -0,0 +1,7 @@ +// @noImplicitAny: true + +// simple case +declare function simple(f: (a: number, b: number) => void): {} + +simple((a: number, b) => {}) +simple((a, b: number) => {}) From 8aa56c1ccedb4070a8d6d8f3f703cd80b9841317 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 17 Oct 2016 09:12:15 -0700 Subject: [PATCH 115/173] Add fourslash test for contextually-typed `this` Regression test for #10972 --- tests/cases/fourslash/memberListOnContextualThis.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 tests/cases/fourslash/memberListOnContextualThis.ts diff --git a/tests/cases/fourslash/memberListOnContextualThis.ts b/tests/cases/fourslash/memberListOnContextualThis.ts new file mode 100644 index 00000000000..7eeb67dc620 --- /dev/null +++ b/tests/cases/fourslash/memberListOnContextualThis.ts @@ -0,0 +1,12 @@ +/// +////interface A { +//// a: string; +////} +////declare function ctx(callback: (this: A) => string): string; +////ctx(function () { return th/*1*/is./*2*/a }); + +goTo.marker('1'); +verify.quickInfoIs("this: A"); +goTo.marker('2'); +verify.memberListContains('a', '(property) A.a: string'); + From 6a59948ea125bc8c7d0205ef732f451a706bf68b Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 17 Oct 2016 09:46:26 -0700 Subject: [PATCH 116/173] Add lib-concatting newlines to jakefile as well --- Jakefile.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Jakefile.js b/Jakefile.js index 64a8553ef39..18cafccd4e4 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -355,6 +355,7 @@ function concatenateFiles(destinationFile, sourceFiles) { if (!fs.existsSync(sourceFiles[i])) { fail(sourceFiles[i] + " does not exist!"); } + fs.appendFileSync(temp, "\n\n"); fs.appendFileSync(temp, fs.readFileSync(sourceFiles[i])); } // Move the file to the final destination From 4c5a72831466c2738c81dfe3fa5634c11ae093a0 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 17 Oct 2016 10:15:13 -0700 Subject: [PATCH 117/173] Don't use ternary operator --- src/server/scriptInfo.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/server/scriptInfo.ts b/src/server/scriptInfo.ts index 2792b3e47a9..78127925958 100644 --- a/src/server/scriptInfo.ts +++ b/src/server/scriptInfo.ts @@ -84,7 +84,10 @@ namespace ts.server { } getDefaultProject() { - return this.containingProjects.length === 0 ? Errors.ThrowNoProject() : this.containingProjects[0]; + if (this.containingProjects.length === 0) { + return Errors.ThrowNoProject(); + } + return this.containingProjects[0]; } setFormatOptions(formatSettings: FormatCodeSettings): void { From b71e8a21679d5c0b5020802b8851d109ec0d1a32 Mon Sep 17 00:00:00 2001 From: Jason Ramsay Date: Mon, 17 Oct 2016 13:11:13 -0700 Subject: [PATCH 118/173] Add isSemantic check to getDiagnosticsWorker --- src/server/session.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/server/session.ts b/src/server/session.ts index 3df6a1acb51..40110d94d53 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -389,9 +389,9 @@ namespace ts.server { }); } - private getDiagnosticsWorker(args: protocol.FileRequestArgs, selector: (project: Project, file: string) => Diagnostic[], includeLinePosition: boolean) { + private getDiagnosticsWorker(args: protocol.FileRequestArgs, isSemantic: boolean, selector: (project: Project, file: string) => Diagnostic[], includeLinePosition: boolean) { const { project, file } = this.getFileAndProject(args); - if (shouldSkipSematicCheck(project)) { + if (isSemantic && shouldSkipSematicCheck(project)) { return []; } const scriptInfo = project.getScriptInfoForNormalizedPath(file); @@ -492,11 +492,11 @@ namespace ts.server { } private getSyntacticDiagnosticsSync(args: protocol.SyntacticDiagnosticsSyncRequestArgs): protocol.Diagnostic[] | protocol.DiagnosticWithLinePosition[] { - return this.getDiagnosticsWorker(args, (project, file) => project.getLanguageService().getSyntacticDiagnostics(file), args.includeLinePosition); + return this.getDiagnosticsWorker(args, /*isSemantic*/ false, (project, file) => project.getLanguageService().getSyntacticDiagnostics(file), args.includeLinePosition); } private getSemanticDiagnosticsSync(args: protocol.SemanticDiagnosticsSyncRequestArgs): protocol.Diagnostic[] | protocol.DiagnosticWithLinePosition[] { - return this.getDiagnosticsWorker(args, (project, file) => project.getLanguageService().getSemanticDiagnostics(file), args.includeLinePosition); + return this.getDiagnosticsWorker(args, /*isSemantic*/ true, (project, file) => project.getLanguageService().getSemanticDiagnostics(file), args.includeLinePosition); } private getDocumentHighlights(args: protocol.DocumentHighlightsRequestArgs, simplifiedResult: boolean): protocol.DocumentHighlightsItem[] | DocumentHighlights[] { From 45253f85cf69f17daf401cc2b02cd8cb1c788b83 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 17 Oct 2016 14:00:49 -0700 Subject: [PATCH 119/173] Remove baseline-accept warning from CONTRIBUTING It's not longer true. You can baseline-accept after running just a few tests. --- CONTRIBUTING.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1c242022979..6dbb7e514a0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -183,5 +183,3 @@ jake baseline-accept ``` to establish the new baselines as the desired behavior. This will change the files in `tests\baselines\reference`, which should be included as part of your commit. It's important to carefully validate changes in the baselines. - -**Note** that `baseline-accept` should only be run after a full test run! Accepting baselines after running a subset of tests will delete baseline files for the tests that didn't run. From 09b9ea5507b8b70d5a7c9e325e2d7126b17404d9 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Mon, 17 Oct 2016 14:29:24 -0700 Subject: [PATCH 120/173] address PR feedback --- src/compiler/binder.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 31732bc833f..086ec9dd927 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -1002,7 +1002,7 @@ namespace ts { } if (node.finallyBlock) { // in finally flow is combined from pre-try/flow from try/flow from catch - // pre-flow is necessary to make sure that finally is reachable even if finaly flows in both try and finally blocks are unreachable + // pre-flow is necessary to make sure that finally is reachable even if finally flows in both try and finally blocks are unreachable addAntecedent(preFinallyLabel, preTryFlow); currentFlow = finishFlowLabel(preFinallyLabel); bind(node.finallyBlock); @@ -1014,7 +1014,7 @@ namespace ts { // console.log(2); // this line should be unreachable even if flow falls out of finally block if (!(currentFlow.flags & FlowFlags.Unreachable)) { if ((flowAfterTry.flags & FlowFlags.Unreachable) && (flowAfterCatch.flags & FlowFlags.Unreachable)) { - currentFlow = flowAfterTry == reportedUnreachableFlow || flowAfterCatch === reportedUnreachableFlow + currentFlow = flowAfterTry === reportedUnreachableFlow || flowAfterCatch === reportedUnreachableFlow ? reportedUnreachableFlow : unreachableFlow; } From af52b6314c553195474ba11d38b4b952ef2f15fa Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 17 Oct 2016 15:34:03 -0700 Subject: [PATCH 121/173] Address CR feedback --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index db95eb9bc17..41fc483f4ee 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6114,7 +6114,7 @@ namespace ts { // know that all parameters (including 'this') have type annotations and nothing is // subject to contextual typing. const parameter = firstOrUndefined(node.parameters); - return !(parameter && parameter.name.kind === SyntaxKind.Identifier && (parameter.name).text === "this"); + return !(parameter && parameterIsThisKeyword(parameter)); } function isContextSensitiveFunctionOrObjectLiteralMethod(func: Node): func is FunctionExpression | ArrowFunction | MethodDeclaration { From 05ebd1d5fb464405a7b7112b969d740fb3879b71 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Mon, 17 Oct 2016 15:46:05 -0700 Subject: [PATCH 122/173] Merge pull request #11651 from Microsoft/vladima/literals-in-protocol switch enums in protocol to unions of literal types --- scripts/buildProtocol.ts | 69 +++++++++---- src/harness/unittests/session.ts | 69 ++++++++++--- src/server/editorServices.ts | 85 ++++++++++++++-- src/server/protocol.ts | 163 +++++++++++++++++++++++++++++-- src/server/session.ts | 28 ++---- 5 files changed, 346 insertions(+), 68 deletions(-) diff --git a/scripts/buildProtocol.ts b/scripts/buildProtocol.ts index 55ad086815c..66f29f577d9 100644 --- a/scripts/buildProtocol.ts +++ b/scripts/buildProtocol.ts @@ -10,6 +10,8 @@ function endsWith(s: string, suffix: string) { class DeclarationsWalker { private visitedTypes: ts.Type[] = []; private text = ""; + private removedTypes: ts.Type[] = []; + private constructor(private typeChecker: ts.TypeChecker, private protocolFile: ts.SourceFile) { } @@ -17,9 +19,18 @@ class DeclarationsWalker { let text = "declare namespace ts.server.protocol {\n"; var walker = new DeclarationsWalker(typeChecker, protocolFile); walker.visitTypeNodes(protocolFile); - return walker.text + text = walker.text ? `declare namespace ts.server.protocol {\n${walker.text}}` : ""; + if (walker.removedTypes) { + text += "\ndeclare namespace ts {\n"; + text += " // these types are empty stubs for types from services and should not be used directly\n" + for (const type of walker.removedTypes) { + text += ` export type ${type.symbol.name} = never;\n`; + } + text += "}" + } + return text; } private processType(type: ts.Type): void { @@ -41,19 +52,18 @@ class DeclarationsWalker { if (sourceFile === this.protocolFile || path.basename(sourceFile.fileName) === "lib.d.ts") { return; } - // splice declaration in final d.ts file - let text = decl.getFullText(); - if (decl.kind === ts.SyntaxKind.EnumDeclaration && !(decl.flags & ts.NodeFlags.Const)) { - // patch enum declaration to make them constan - const declStart = decl.getStart() - decl.getFullStart(); - const prefix = text.substring(0, declStart); - const suffix = text.substring(declStart + "enum".length, decl.getEnd() - decl.getFullStart()); - text = prefix + "const enum" + suffix; + if (decl.kind === ts.SyntaxKind.EnumDeclaration) { + this.removedTypes.push(type); + return; } - this.text += `${text}\n`; + else { + // splice declaration in final d.ts file + let text = decl.getFullText(); + this.text += `${text}\n`; + // recursively pull all dependencies into result dts file - // recursively pull all dependencies into result dts file - this.visitTypeNodes(decl); + this.visitTypeNodes(decl); + } } } } @@ -69,15 +79,37 @@ class DeclarationsWalker { case ts.SyntaxKind.Parameter: case ts.SyntaxKind.IndexSignature: if (((node.parent).type) === node) { - const type = this.typeChecker.getTypeAtLocation(node); - if (type && !(type.flags & ts.TypeFlags.TypeParameter)) { - this.processType(type); - } + this.processTypeOfNode(node); } break; + case ts.SyntaxKind.InterfaceDeclaration: + const heritageClauses = (node.parent).heritageClauses; + if (heritageClauses) { + if (heritageClauses[0].token !== ts.SyntaxKind.ExtendsKeyword) { + throw new Error(`Unexpected kind of heritage clause: ${ts.SyntaxKind[heritageClauses[0].kind]}`); + } + for (const type of heritageClauses[0].types) { + this.processTypeOfNode(type); + } + } + break; } } ts.forEachChild(node, n => this.visitTypeNodes(n)); + } + + private processTypeOfNode(node: ts.Node): void { + if (node.kind === ts.SyntaxKind.UnionType) { + for (const t of (node).types) { + this.processTypeOfNode(t); + } + } + else { + const type = this.typeChecker.getTypeAtLocation(node); + if (type && !(type.flags & (ts.TypeFlags.TypeParameter))) { + this.processType(type); + } + } } } @@ -128,9 +160,12 @@ function generateProtocolFile(protocolTs: string, typeScriptServicesDts: string) if (extraDeclarations) { protocolDts += extraDeclarations; } + protocolDts += "\nimport protocol = ts.server.protocol;"; + protocolDts += "\nexport = protocol;"; + protocolDts += "\nexport as namespace protocol;"; // do sanity check and try to compile generated text as standalone program const sanityCheckProgram = getProgramWithProtocolText(protocolDts, /*includeTypeScriptServices*/ false); - const diagnostics = [...program.getSyntacticDiagnostics(), ...program.getSemanticDiagnostics(), ...program.getGlobalDiagnostics()]; + const diagnostics = [...sanityCheckProgram.getSyntacticDiagnostics(), ...sanityCheckProgram.getSemanticDiagnostics(), ...sanityCheckProgram.getGlobalDiagnostics()]; if (diagnostics.length) { const flattenedDiagnostics = diagnostics.map(d => ts.flattenDiagnosticMessageText(d.messageText, "\n")).join("\n"); throw new Error(`Unexpected errors during sanity check: ${flattenedDiagnostics}`); diff --git a/src/harness/unittests/session.ts b/src/harness/unittests/session.ts index badbbaf526b..9099f0a4285 100644 --- a/src/harness/unittests/session.ts +++ b/src/harness/unittests/session.ts @@ -39,12 +39,18 @@ namespace ts.server { getLogFileName: (): string => undefined }; + class TestSession extends Session { + getProjectService() { + return this.projectService; + } + } + describe("the Session class", () => { - let session: Session; + let session: TestSession; let lastSent: protocol.Message; beforeEach(() => { - session = new Session(mockHost, nullCancellationToken, /*useOneInferredProject*/ false, /*typingsInstaller*/ undefined, Utils.byteLength, process.hrtime, mockLogger, /*canUseEvents*/ true); + session = new TestSession(mockHost, nullCancellationToken, /*useOneInferredProject*/ false, /*typingsInstaller*/ undefined, Utils.byteLength, process.hrtime, mockLogger, /*canUseEvents*/ true); session.send = (msg: protocol.Message) => { lastSent = msg; }; @@ -55,7 +61,7 @@ namespace ts.server { const req: protocol.FileRequest = { command: CommandNames.Open, seq: 0, - type: "command", + type: "request", arguments: { file: undefined } @@ -67,7 +73,7 @@ namespace ts.server { const req: protocol.Request = { command: "foobar", seq: 0, - type: "command" + type: "request" }; session.executeCommand(req); @@ -85,7 +91,7 @@ namespace ts.server { const req: protocol.ConfigureRequest = { command: CommandNames.Configure, seq: 0, - type: "command", + type: "request", arguments: { hostInfo: "unit test", formatOptions: { @@ -106,6 +112,47 @@ namespace ts.server { body: undefined }); }); + it ("should handle literal types in request", () => { + const configureRequest: protocol.ConfigureRequest = { + command: CommandNames.Configure, + seq: 0, + type: "request", + arguments: { + formatOptions: { + indentStyle: "Block" + } + } + }; + + session.onMessage(JSON.stringify(configureRequest)); + + assert.equal(session.getProjectService().getFormatCodeOptions().indentStyle, IndentStyle.Block); + + const setOptionsRequest: protocol.SetCompilerOptionsForInferredProjectsRequest = { + command: CommandNames.CompilerOptionsForInferredProjects, + seq: 1, + type: "request", + arguments: { + options: { + module: "System", + target: "ES5", + jsx: "React", + newLine: "Lf", + moduleResolution: "Node" + } + } + }; + session.onMessage(JSON.stringify(setOptionsRequest)); + assert.deepEqual( + session.getProjectService().getCompilerOptionsForInferredProjects(), + { + module: ModuleKind.System, + target: ScriptTarget.ES5, + jsx: JsxEmit.React, + newLine: NewLineKind.LineFeed, + moduleResolution: ModuleResolutionKind.NodeJs + }); + }); }); describe("onMessage", () => { @@ -118,7 +165,7 @@ namespace ts.server { const req: protocol.Request = { command: name, seq: i, - type: "command" + type: "request" }; i++; session.onMessage(JSON.stringify(req)); @@ -151,7 +198,7 @@ namespace ts.server { const req: protocol.ConfigureRequest = { command: CommandNames.Configure, seq: 0, - type: "command", + type: "request", arguments: { hostInfo: "unit test", formatOptions: { @@ -175,7 +222,7 @@ namespace ts.server { describe("send", () => { it("is an overrideable handle which sends protocol messages over the wire", () => { - const msg = { seq: 0, type: "none" }; + const msg: server.protocol.Request = { seq: 0, type: "request", command: "" }; const strmsg = JSON.stringify(msg); const len = 1 + Utils.byteLength(strmsg, "utf8"); const resultMsg = `Content-Length: ${len}\r\n\r\n${strmsg}\n`; @@ -203,7 +250,7 @@ namespace ts.server { expect(session.executeCommand({ command, seq: 0, - type: "command" + type: "request" })).to.deep.equal(result); }); it("throws when a duplicate handler is passed", () => { @@ -304,7 +351,7 @@ namespace ts.server { expect(session.executeCommand({ seq: 0, - type: "command", + type: "request", command: session.customHandler })).to.deep.equal({ response: undefined, @@ -405,7 +452,7 @@ namespace ts.server { this.seq++; this.server.enqueue({ seq: this.seq, - type: "command", + type: "request", command, arguments: args }); diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 54b257242fd..6556aa01460 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -17,6 +17,68 @@ namespace ts.server { (event: ProjectServiceEvent): void; } + function prepareConvertersForEnumLikeCompilerOptions(commandLineOptions: CommandLineOption[]): Map> { + const map: Map> = createMap>(); + for (const option of commandLineOptions) { + if (typeof option.type === "object") { + const optionMap = >option.type; + // verify that map contains only numbers + for (const id in optionMap) { + Debug.assert(typeof optionMap[id] === "number"); + } + map[option.name] = optionMap; + } + } + return map; + } + + const compilerOptionConverters = prepareConvertersForEnumLikeCompilerOptions(optionDeclarations); + const indentStyle = createMap({ + "none": IndentStyle.None, + "block": IndentStyle.Block, + "smart": IndentStyle.Smart + }); + + export function convertFormatOptions(protocolOptions: protocol.FormatCodeSettings): FormatCodeSettings { + if (typeof protocolOptions.indentStyle === "string") { + protocolOptions.indentStyle = indentStyle[protocolOptions.indentStyle.toLowerCase()]; + Debug.assert(protocolOptions.indentStyle !== undefined); + } + return protocolOptions; + } + + export function convertCompilerOptions(protocolOptions: protocol.ExternalProjectCompilerOptions): CompilerOptions & protocol.CompileOnSaveMixin { + for (const id in compilerOptionConverters) { + const propertyValue = protocolOptions[id]; + if (typeof propertyValue === "string") { + const mappedValues = compilerOptionConverters[id]; + protocolOptions[id] = mappedValues[propertyValue.toLowerCase()]; + } + } + return protocolOptions; + } + + export function tryConvertScriptKindName(scriptKindName: protocol.ScriptKindName | ScriptKind): ScriptKind { + return typeof scriptKindName === "string" + ? convertScriptKindName(scriptKindName) + : scriptKindName; + } + + export function convertScriptKindName(scriptKindName: protocol.ScriptKindName) { + switch (scriptKindName) { + case "JS": + return ScriptKind.JS; + case "JSX": + return ScriptKind.JSX; + case "TS": + return ScriptKind.TS; + case "TSX": + return ScriptKind.TSX; + default: + return ScriptKind.Unknown; + } + } + /** * This helper function processes a list of projects and return the concatenated, sortd and deduplicated output of processing each project. */ @@ -63,7 +125,7 @@ namespace ts.server { const externalFilePropertyReader: FilePropertyReader = { getFileName: x => x.fileName, - getScriptKind: x => x.scriptKind, + getScriptKind: x => tryConvertScriptKindName(x.scriptKind), hasMixedContent: x => x.hasMixedContent }; @@ -214,6 +276,10 @@ namespace ts.server { this.ensureInferredProjectsUpToDate(); } + getCompilerOptionsForInferredProjects() { + return this.compilerOptionsForInferredProjects; + } + updateTypingsForProject(response: SetTypings | InvalidateCachedTypings): void { const project = this.findProject(response.projectName); if (!project) { @@ -231,10 +297,10 @@ namespace ts.server { } setCompilerOptionsForInferredProjects(projectCompilerOptions: protocol.ExternalProjectCompilerOptions): void { - this.compilerOptionsForInferredProjects = projectCompilerOptions; + this.compilerOptionsForInferredProjects = convertCompilerOptions(projectCompilerOptions); this.compileOnSaveForInferredProjects = projectCompilerOptions.compileOnSave; for (const proj of this.inferredProjects) { - proj.setCompilerOptions(projectCompilerOptions); + proj.setCompilerOptions(this.compilerOptionsForInferredProjects); proj.compileOnSaveEnabled = projectCompilerOptions.compileOnSave; } this.updateProjectGraphs(this.inferredProjects); @@ -744,12 +810,13 @@ namespace ts.server { } private createAndAddExternalProject(projectFileName: string, files: protocol.ExternalFile[], options: protocol.ExternalProjectCompilerOptions, typingOptions: TypingOptions) { + const compilerOptions = convertCompilerOptions(options); const project = new ExternalProject( projectFileName, this, this.documentRegistry, - options, - /*languageServiceEnabled*/ !this.exceededTotalSizeLimitForNonTsFiles(options, files, externalFilePropertyReader), + compilerOptions, + /*languageServiceEnabled*/ !this.exceededTotalSizeLimitForNonTsFiles(compilerOptions, files, externalFilePropertyReader), options.compileOnSave === undefined ? true : options.compileOnSave); this.addFilesToProjectAndUpdateGraph(project, files, externalFilePropertyReader, /*clientFileName*/ undefined, typingOptions, /*configFileErrors*/ undefined); @@ -1018,7 +1085,7 @@ namespace ts.server { if (args.file) { const info = this.getScriptInfoForNormalizedPath(toNormalizedPath(args.file)); if (info) { - info.setFormatOptions(args.formatOptions); + info.setFormatOptions(convertFormatOptions(args.formatOptions)); this.logger.info(`Host configuration update for file ${args.file}`); } } @@ -1028,7 +1095,7 @@ namespace ts.server { this.logger.info(`Host information ${args.hostInfo}`); } if (args.formatOptions) { - mergeMaps(this.hostConfiguration.formatCodeOptions, args.formatOptions); + mergeMaps(this.hostConfiguration.formatCodeOptions, convertFormatOptions(args.formatOptions)); this.logger.info("Format host information updated"); } } @@ -1142,7 +1209,7 @@ namespace ts.server { const scriptInfo = this.getScriptInfo(file.fileName); Debug.assert(!scriptInfo || !scriptInfo.isOpen); const normalizedPath = scriptInfo ? scriptInfo.fileName : toNormalizedPath(file.fileName); - this.openClientFileWithNormalizedPath(normalizedPath, file.content, file.scriptKind, file.hasMixedContent); + this.openClientFileWithNormalizedPath(normalizedPath, file.content, tryConvertScriptKindName(file.scriptKind), file.hasMixedContent); } } @@ -1235,7 +1302,7 @@ namespace ts.server { if (externalProject) { if (!tsConfigFiles) { // external project already exists and not config files were added - update the project and return; - this.updateNonInferredProject(externalProject, proj.rootFiles, externalFilePropertyReader, proj.options, proj.typingOptions, proj.options.compileOnSave, /*configFileErrors*/ undefined); + this.updateNonInferredProject(externalProject, proj.rootFiles, externalFilePropertyReader, convertCompilerOptions(proj.options), proj.typingOptions, proj.options.compileOnSave, /*configFileErrors*/ undefined); return; } // some config files were added to external project (that previously were not there) diff --git a/src/server/protocol.ts b/src/server/protocol.ts index 80623f05aec..7da95e49575 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -109,7 +109,7 @@ namespace ts.server.protocol { /** * One of "request", "response", or "event" */ - type: string; + type: "request" | "response" | "event"; } /** @@ -833,7 +833,7 @@ namespace ts.server.protocol { /** * Script kind of the file */ - scriptKind?: ScriptKind; + scriptKind?: ScriptKindName | ts.ScriptKind; /** * Whether file has mixed content (i.e. .cshtml file that combines html markup with C#/JavaScript) */ @@ -866,20 +866,23 @@ namespace ts.server.protocol { typingOptions?: TypingOptions; } - /** - * For external projects, some of the project settings are sent together with - * compiler settings. - */ - export interface ExternalProjectCompilerOptions extends CompilerOptions { + export interface CompileOnSaveMixin { /** * If compile on save is enabled for the project */ compileOnSave?: boolean; } + /** + * For external projects, some of the project settings are sent together with + * compiler settings. + */ + export type ExternalProjectCompilerOptions = CompilerOptions & CompileOnSaveMixin; + /** * Contains information about current project version */ + /* @internal */ export interface ProjectVersionInfo { /** * Project name @@ -896,7 +899,7 @@ namespace ts.server.protocol { /** * Current set of compiler options for project */ - options: CompilerOptions; + options: ts.CompilerOptions; } /** @@ -920,6 +923,7 @@ namespace ts.server.protocol { * if changes is set - then this is the set of changes that should be applied to existing project * otherwise - assume that nothing is changed */ + /* @internal */ export interface ProjectFiles { /** * Information abount project verison @@ -938,6 +942,7 @@ namespace ts.server.protocol { /** * Combines project information with project level errors. */ + /* @internal */ export interface ProjectFilesWithDiagnostics extends ProjectFiles { /** * List of errors in project @@ -1012,9 +1017,11 @@ namespace ts.server.protocol { * Used to specify the script kind of the file explicitly. It could be one of the following: * "TS", "JS", "TSX", "JSX" */ - scriptKindName?: "TS" | "JS" | "TSX" | "JSX"; + scriptKindName?: ScriptKindName; } + export type ScriptKindName = "TS" | "JS" | "TSX" | "JSX"; + /** * Open request; value of command field is "open". Notify the * server that the client has file open. The server will not @@ -1109,6 +1116,7 @@ namespace ts.server.protocol { /** * Arguments to SynchronizeProjectListRequest */ + /* @internal */ export interface SynchronizeProjectListRequestArgs { /** * List of last known projects @@ -2056,4 +2064,141 @@ namespace ts.server.protocol { export interface NavTreeResponse extends Response { body?: NavigationTree; } + + export namespace IndentStyle { + export type None = "None"; + export type Block = "Block"; + export type Smart = "Smart"; + } + + export type IndentStyle = IndentStyle.None | IndentStyle.Block | IndentStyle.Smart; + + export interface EditorSettings { + baseIndentSize?: number; + indentSize?: number; + tabSize?: number; + newLineCharacter?: string; + convertTabsToSpaces?: boolean; + indentStyle?: IndentStyle | ts.IndentStyle; + } + + export interface FormatCodeSettings extends EditorSettings { + insertSpaceAfterCommaDelimiter?: boolean; + insertSpaceAfterSemicolonInForStatements?: boolean; + insertSpaceBeforeAndAfterBinaryOperators?: boolean; + insertSpaceAfterKeywordsInControlFlowStatements?: boolean; + insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; + insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; + insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean; + insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; + insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; + placeOpenBraceOnNewLineForFunctions?: boolean; + placeOpenBraceOnNewLineForControlBlocks?: boolean; + } + + export interface CompilerOptions { + allowJs?: boolean; + allowSyntheticDefaultImports?: boolean; + allowUnreachableCode?: boolean; + allowUnusedLabels?: boolean; + baseUrl?: string; + charset?: string; + declaration?: boolean; + declarationDir?: string; + disableSizeLimit?: boolean; + emitBOM?: boolean; + emitDecoratorMetadata?: boolean; + experimentalDecorators?: boolean; + forceConsistentCasingInFileNames?: boolean; + inlineSourceMap?: boolean; + inlineSources?: boolean; + isolatedModules?: boolean; + jsx?: JsxEmit | ts.JsxEmit; + lib?: string[]; + locale?: string; + mapRoot?: string; + maxNodeModuleJsDepth?: number; + module?: ModuleKind | ts.ModuleKind; + moduleResolution?: ModuleResolutionKind | ts.ModuleResolutionKind; + newLine?: NewLineKind | ts.NewLineKind; + noEmit?: boolean; + noEmitHelpers?: boolean; + noEmitOnError?: boolean; + noErrorTruncation?: boolean; + noFallthroughCasesInSwitch?: boolean; + noImplicitAny?: boolean; + noImplicitReturns?: boolean; + noImplicitThis?: boolean; + noUnusedLocals?: boolean; + noUnusedParameters?: boolean; + noImplicitUseStrict?: boolean; + noLib?: boolean; + noResolve?: boolean; + out?: string; + outDir?: string; + outFile?: string; + paths?: MapLike; + preserveConstEnums?: boolean; + project?: string; + reactNamespace?: string; + removeComments?: boolean; + rootDir?: string; + rootDirs?: string[]; + skipLibCheck?: boolean; + skipDefaultLibCheck?: boolean; + sourceMap?: boolean; + sourceRoot?: string; + strictNullChecks?: boolean; + suppressExcessPropertyErrors?: boolean; + suppressImplicitAnyIndexErrors?: boolean; + target?: ScriptTarget | ts.ScriptTarget; + traceResolution?: boolean; + types?: string[]; + /** Paths used to used to compute primary types search locations */ + typeRoots?: string[]; + [option: string]: CompilerOptionsValue | undefined; + } + + export namespace JsxEmit { + export type None = "None"; + export type Preserve = "Preserve"; + export type React = "React"; + } + + export type JsxEmit = JsxEmit.None | JsxEmit.Preserve | JsxEmit.React; + + export namespace ModuleKind { + export type None = "None"; + export type CommonJS = "CommonJS"; + export type AMD = "AMD"; + export type UMD = "UMD"; + export type System = "System"; + export type ES6 = "ES6"; + export type ES2015 = "ES2015"; + } + + export type ModuleKind = ModuleKind.None | ModuleKind.CommonJS | ModuleKind.AMD | ModuleKind.UMD | ModuleKind.System | ModuleKind.ES6 | ModuleKind.ES2015; + + export namespace ModuleResolutionKind { + export type Classic = "Classic"; + export type Node = "Node"; + } + + export type ModuleResolutionKind = ModuleResolutionKind.Classic | ModuleResolutionKind.Node; + + export namespace NewLineKind { + export type Crlf = "Crlf"; + export type Lf = "Lf"; + } + + export type NewLineKind = NewLineKind.Crlf | NewLineKind.Lf; + + export namespace ScriptTarget { + export type ES3 = "ES3"; + export type ES5 = "ES5"; + export type ES6 = "ES6"; + export type ES2015 = "ES2015"; + } + + export type ScriptTarget = ScriptTarget.ES3 | ScriptTarget.ES5 | ScriptTarget.ES6 | ScriptTarget.ES2015; } diff --git a/src/server/session.ts b/src/server/session.ts index 3df6a1acb51..bf179c90773 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -807,7 +807,7 @@ namespace ts.server { private getIndentation(args: protocol.IndentationRequestArgs) { const { file, project } = this.getFileAndProjectWithoutRefreshingInferredProjects(args); const position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); - const options = args.options || this.projectService.getFormatCodeOptions(file); + const options = args.options ? convertFormatOptions(args.options) : this.projectService.getFormatCodeOptions(file); const indentation = project.getLanguageService(/*ensureSynchronized*/ false).getIndentationAtPosition(file, position, options); return { position, indentation }; } @@ -874,19 +874,19 @@ namespace ts.server { private getFormattingEditsForRangeFull(args: protocol.FormatRequestArgs) { const { file, project } = this.getFileAndProjectWithoutRefreshingInferredProjects(args); - const options = args.options || this.projectService.getFormatCodeOptions(file); + const options = args.options ? convertFormatOptions(args.options) : this.projectService.getFormatCodeOptions(file); return project.getLanguageService(/*ensureSynchronized*/ false).getFormattingEditsForRange(file, args.position, args.endPosition, options); } private getFormattingEditsForDocumentFull(args: protocol.FormatRequestArgs) { const { file, project } = this.getFileAndProjectWithoutRefreshingInferredProjects(args); - const options = args.options || this.projectService.getFormatCodeOptions(file); + const options = args.options ? convertFormatOptions(args.options) : this.projectService.getFormatCodeOptions(file); return project.getLanguageService(/*ensureSynchronized*/ false).getFormattingEditsForDocument(file, options); } private getFormattingEditsAfterKeystrokeFull(args: protocol.FormatOnKeyRequestArgs) { const { file, project } = this.getFileAndProjectWithoutRefreshingInferredProjects(args); - const options = args.options || this.projectService.getFormatCodeOptions(file); + const options = args.options ? convertFormatOptions(args.options) : this.projectService.getFormatCodeOptions(file); return project.getLanguageService(/*ensureSynchronized*/ false).getFormattingEditsAfterKeystroke(file, args.position, args.key, options); } @@ -1426,24 +1426,8 @@ namespace ts.server { [CommandNames.RenameInfoFull]: (request: protocol.FileLocationRequest) => { return this.requiredResponse(this.getRenameInfo(request.arguments)); }, - [CommandNames.Open]: (request: protocol.Request) => { - const openArgs = request.arguments; - let scriptKind: ScriptKind; - switch (openArgs.scriptKindName) { - case "TS": - scriptKind = ScriptKind.TS; - break; - case "JS": - scriptKind = ScriptKind.JS; - break; - case "TSX": - scriptKind = ScriptKind.TSX; - break; - case "JSX": - scriptKind = ScriptKind.JSX; - break; - } - this.openClientFile(toNormalizedPath(openArgs.file), openArgs.fileContent, scriptKind); + [CommandNames.Open]: (request: protocol.OpenRequest) => { + this.openClientFile(toNormalizedPath(request.arguments.file), request.arguments.fileContent, convertScriptKindName(request.arguments.scriptKindName)); return this.notRequired(); }, [CommandNames.Quickinfo]: (request: protocol.QuickInfoRequest) => { From 722e72339209470858dde59a08e31d8a9a598ab8 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Mon, 17 Oct 2016 15:47:33 -0700 Subject: [PATCH 123/173] Include the correct file by default (#11685) --- src/compiler/utilities.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 7d4a1444074..952a3205250 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -4172,7 +4172,7 @@ namespace ts { case ScriptTarget.ES2016: return "lib.es2016.d.ts"; case ScriptTarget.ES2015: - return "lib.es2015.d.ts"; + return "lib.es6.d.ts"; default: return "lib.d.ts"; From 28899f386011353aeee3ccb17accab03a927f444 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 17 Oct 2016 16:08:00 -0700 Subject: [PATCH 124/173] Update the resolveName symbol flags for 'require' resolution --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1354002a29e..7ac93d2e318 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -12538,7 +12538,7 @@ namespace ts { if (isInJavaScriptFile(node) && isRequireCall(node, /*checkArgumentIsStringLiteral*/true) && // Make sure require is not a local function - !resolveName(node.expression, (node.expression).text, SymbolFlags.Value | SymbolFlags.ExportValue, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined)) { + !resolveName(node.expression, (node.expression).text, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined)) { return resolveExternalModuleTypeByLiteral(node.arguments[0]); } From deb344907733d37822bb8e2f56b16f55d64c7c6c Mon Sep 17 00:00:00 2001 From: Jason Ramsay Date: Mon, 17 Oct 2016 14:50:03 -0700 Subject: [PATCH 125/173] Add getSyntacticDiagnostics unit test --- src/server/client.ts | 28 +++++++++++-------- .../getJavaScriptSyntacticDiagnostics01.ts | 23 +++++++++++++++ 2 files changed, 40 insertions(+), 11 deletions(-) create mode 100644 tests/cases/fourslash/server/getJavaScriptSyntacticDiagnostics01.ts diff --git a/src/server/client.ts b/src/server/client.ts index b0bc2c5dac0..6d8ef419a7a 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -424,33 +424,39 @@ namespace ts.server { } getSyntacticDiagnostics(fileName: string): Diagnostic[] { - const args: protocol.SyntacticDiagnosticsSyncRequestArgs = { file: fileName }; + const args: protocol.SyntacticDiagnosticsSyncRequestArgs = { file: fileName, includeLinePosition: true }; const request = this.processRequest(CommandNames.SyntacticDiagnosticsSync, args); const response = this.processResponse(request); - return (response.body).map(entry => this.convertDiagnostic(entry, fileName)); + return (response.body).map(entry => this.convertDiagnostic(entry, fileName)); } getSemanticDiagnostics(fileName: string): Diagnostic[] { - const args: protocol.SemanticDiagnosticsSyncRequestArgs = { file: fileName }; + const args: protocol.SemanticDiagnosticsSyncRequestArgs = { file: fileName, includeLinePosition: true }; const request = this.processRequest(CommandNames.SemanticDiagnosticsSync, args); const response = this.processResponse(request); - return (response.body).map(entry => this.convertDiagnostic(entry, fileName)); + return (response.body).map(entry => this.convertDiagnostic(entry, fileName)); } - convertDiagnostic(entry: protocol.Diagnostic, fileName: string): Diagnostic { - const start = this.lineOffsetToPosition(fileName, entry.start); - const end = this.lineOffsetToPosition(fileName, entry.end); + convertDiagnostic(entry: protocol.DiagnosticWithLinePosition, fileName: string): Diagnostic { + let category: DiagnosticCategory; + for (const id in DiagnosticCategory) { + if (typeof id === "string" && entry.category === id.toLowerCase()) { + category = (DiagnosticCategory)[id]; + } + } + + Debug.assert(category !== undefined, "convertDiagnostic: category should not be undefined"); return { file: undefined, - start: start, - length: end - start, - messageText: entry.text, - category: undefined, + start: entry.start, + length: entry.length, + messageText: entry.message, + category: category, code: entry.code }; } diff --git a/tests/cases/fourslash/server/getJavaScriptSyntacticDiagnostics01.ts b/tests/cases/fourslash/server/getJavaScriptSyntacticDiagnostics01.ts new file mode 100644 index 00000000000..0aa88ebd90c --- /dev/null +++ b/tests/cases/fourslash/server/getJavaScriptSyntacticDiagnostics01.ts @@ -0,0 +1,23 @@ +/// + +// @allowJs: true +// @Filename: a.js +//// var ===; + +verify.getSyntacticDiagnostics(`[ + { + "message": "Variable declaration expected.", + "start": 4, + "length": 3, + "category": "error", + "code": 1134 + }, + { + "message": "Expression expected.", + "start": 7, + "length": 1, + "category": "error", + "code": 1109 + } +]`); +verify.getSemanticDiagnostics(`[]`); \ No newline at end of file From 121f51e5523a6bcc6ac6d3790f4cd7fee68ac2ab Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Mon, 17 Oct 2016 23:15:22 -0700 Subject: [PATCH 126/173] Merge pull request #11694 from Microsoft/vladima/reload-tmp allow reload from temp files --- .../unittests/tsserverProjectSystem.ts | 62 ++++++++++++++++++- src/server/project.ts | 4 +- src/server/scriptInfo.ts | 4 +- src/server/session.ts | 3 +- 4 files changed, 66 insertions(+), 7 deletions(-) diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index 9d086e4549e..c3962c77494 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -170,11 +170,18 @@ namespace ts.projectSystem { return host; } + class TestSession extends server.Session { + getProjectService() { + return this.projectService; + } + }; + export function createSession(host: server.ServerHost, typingsInstaller?: server.ITypingsInstaller, projectServiceEventHandler?: server.ProjectServiceEventHandler) { if (typingsInstaller === undefined) { typingsInstaller = new TestTypingsInstaller("/a/data/", /*throttleLimit*/5, host); } - return new server.Session(host, nullCancellationToken, /*useSingleInferredProject*/ false, typingsInstaller, Utils.byteLength, process.hrtime, nullLogger, /*canUseEvents*/ projectServiceEventHandler !== undefined, projectServiceEventHandler); + + return new TestSession(host, nullCancellationToken, /*useSingleInferredProject*/ false, typingsInstaller, Utils.byteLength, process.hrtime, nullLogger, /*canUseEvents*/ projectServiceEventHandler !== undefined, projectServiceEventHandler); } export interface CreateProjectServiceParameters { @@ -515,11 +522,13 @@ namespace ts.projectSystem { this.reloadFS(filesOrFolders); } + write(s: string) { + } + readonly readFile = (s: string) => (this.fs.get(this.toPath(s))).content; readonly resolvePath = (s: string) => s; readonly getExecutingFilePath = () => this.executingFilePath; readonly getCurrentDirectory = () => this.currentDirectory; - readonly write = (s: string) => notImplemented(); readonly exit = () => notImplemented(); readonly getEnvironmentVariable = (v: string) => notImplemented(); } @@ -2420,4 +2429,53 @@ namespace ts.projectSystem { assert.isTrue(inferredProject.containsFile(file1.path)); }); }); + + describe("reload", () => { + it("should work with temp file", () => { + const f1 = { + path: "/a/b/app.ts", + content: "let x = 1" + }; + const tmp = { + path: "/a/b/app.tmp", + content: "const y = 42" + }; + const host = createServerHost([f1, tmp]); + const session = createSession(host); + + // send open request + session.executeCommand({ + type: "request", + command: "open", + seq: 1, + arguments: { file: f1.path } + }); + + // reload from tmp file + session.executeCommand({ + type: "request", + command: "reload", + seq: 2, + arguments: { file: f1.path, tmpfile: tmp.path } + }); + + // verify content + const projectServiice = session.getProjectService(); + const snap1 = projectServiice.getScriptInfo(f1.path).snap(); + assert.equal(snap1.getText(0, snap1.getLength()), tmp.content, "content should be equal to the content of temp file"); + + // reload from original file file + session.executeCommand({ + type: "request", + command: "reload", + seq: 2, + arguments: { file: f1.path } + }); + + // verify content + const snap2 = projectServiice.getScriptInfo(f1.path).snap(); + assert.equal(snap2.getText(0, snap2.getLength()), f1.content, "content should be equal to the content of original file"); + + }); + }); } \ No newline at end of file diff --git a/src/server/project.ts b/src/server/project.ts index a355d75f942..dd8902e83d1 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -437,11 +437,11 @@ namespace ts.server { } } - reloadScript(filename: NormalizedPath): boolean { + reloadScript(filename: NormalizedPath, tempFileName?: NormalizedPath): boolean { const script = this.projectService.getScriptInfoForNormalizedPath(filename); if (script) { Debug.assert(script.isAttached(this)); - script.reloadFromFile(); + script.reloadFromFile(tempFileName); return true; } return false; diff --git a/src/server/scriptInfo.ts b/src/server/scriptInfo.ts index 78127925958..84649863a7b 100644 --- a/src/server/scriptInfo.ts +++ b/src/server/scriptInfo.ts @@ -125,12 +125,12 @@ namespace ts.server { this.host.writeFile(fileName, snap.getText(0, snap.getLength())); } - reloadFromFile() { + reloadFromFile(tempFileName?: NormalizedPath) { if (this.hasMixedContent) { this.reload(""); } else { - this.svc.reloadFromFile(this.fileName); + this.svc.reloadFromFile(tempFileName || this.fileName); this.markContainingProjectsAsDirty(); } } diff --git a/src/server/session.ts b/src/server/session.ts index f029dc4a5d0..3bf4acd2486 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -1076,11 +1076,12 @@ namespace ts.server { private reload(args: protocol.ReloadRequestArgs, reqSeq: number) { const file = toNormalizedPath(args.file); + const tempFileName = args.tmpfile && toNormalizedPath(args.tmpfile); const project = this.projectService.getDefaultProjectForFile(file, /*refreshInferredProjects*/ true); if (project) { this.changeSeq++; // make sure no changes happen before this one is finished - if (project.reloadScript(file)) { + if (project.reloadScript(file, tempFileName)) { this.output(undefined, CommandNames.Reload, reqSeq); } } From de876bdfc96d942115ab22aef8b6130c210eaee3 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 18 Oct 2016 07:34:48 -0700 Subject: [PATCH 127/173] Use an ES5 target --- Jakefile.js | 2 ++ src/compiler/tsconfig.json | 3 ++- src/harness/tsconfig.json | 3 ++- src/server/cancellationToken/tsconfig.json | 3 ++- src/server/tsconfig.json | 3 ++- src/server/tsconfig.library.json | 3 ++- src/server/typingsInstaller/tsconfig.json | 3 ++- src/services/tsconfig.json | 3 ++- 8 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Jakefile.js b/Jakefile.js index 6592347b59e..301dc574eb6 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -448,6 +448,8 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts options += " --stripInternal"; } + options += " --target es5"; + var cmd = host + " " + compilerPath + " " + options + " "; cmd = cmd + sources.join(" "); console.log(cmd + "\n"); diff --git a/src/compiler/tsconfig.json b/src/compiler/tsconfig.json index 92a3ea38551..65ba20f18d2 100644 --- a/src/compiler/tsconfig.json +++ b/src/compiler/tsconfig.json @@ -8,7 +8,8 @@ "outFile": "../../built/local/tsc.js", "sourceMap": true, "declaration": true, - "stripInternal": true + "stripInternal": true, + "target": "es5" }, "files": [ "core.ts", diff --git a/src/harness/tsconfig.json b/src/harness/tsconfig.json index bbc1a49a0f7..d0f500e27aa 100644 --- a/src/harness/tsconfig.json +++ b/src/harness/tsconfig.json @@ -10,7 +10,8 @@ "stripInternal": true, "types": [ "node", "mocha", "chai" - ] + ], + "target": "es5" }, "files": [ "../compiler/core.ts", diff --git a/src/server/cancellationToken/tsconfig.json b/src/server/cancellationToken/tsconfig.json index 1245fc34fd5..bcfe5ddb465 100644 --- a/src/server/cancellationToken/tsconfig.json +++ b/src/server/cancellationToken/tsconfig.json @@ -10,7 +10,8 @@ "stripInternal": true, "types": [ "node" - ] + ], + "target": "es5" }, "files": [ "cancellationToken.ts" diff --git a/src/server/tsconfig.json b/src/server/tsconfig.json index 9f907446c03..5308abb0c84 100644 --- a/src/server/tsconfig.json +++ b/src/server/tsconfig.json @@ -10,7 +10,8 @@ "stripInternal": true, "types": [ "node" - ] + ], + "target": "es5" }, "files": [ "../services/shims.ts", diff --git a/src/server/tsconfig.library.json b/src/server/tsconfig.library.json index a450b591a7e..a287a77fed5 100644 --- a/src/server/tsconfig.library.json +++ b/src/server/tsconfig.library.json @@ -7,7 +7,8 @@ "sourceMap": true, "stripInternal": true, "declaration": true, - "types": [] + "types": [], + "target": "es5" }, "files": [ "../services/shims.ts", diff --git a/src/server/typingsInstaller/tsconfig.json b/src/server/typingsInstaller/tsconfig.json index fc4b896f267..58805081de6 100644 --- a/src/server/typingsInstaller/tsconfig.json +++ b/src/server/typingsInstaller/tsconfig.json @@ -10,7 +10,8 @@ "stripInternal": true, "types": [ "node" - ] + ], + "target": "es5" }, "files": [ "../types.d.ts", diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index a3482a63c31..4e130c7dfb2 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -9,7 +9,8 @@ "sourceMap": true, "stripInternal": true, "noResolve": false, - "declaration": true + "declaration": true, + "target": "es5" }, "files": [ "../compiler/core.ts", From 64e8221a4498179cd90ea91a9e5ceacd14bafa6d Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 18 Oct 2016 08:18:01 -0700 Subject: [PATCH 128/173] Use single `concat` call instead of repeated calls --- src/compiler/program.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 50e53ab9484..06e9f6f30f1 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -766,7 +766,7 @@ namespace ts { const fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); const programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); - return bindDiagnostics.concat(checkDiagnostics).concat(fileProcessingDiagnosticsInFile).concat(programDiagnosticsInFile); + return bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); }); } From 1f7f67de17879bb70825d8c5955e3b7c036ace10 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 18 Oct 2016 08:09:56 -0700 Subject: [PATCH 129/173] Type arguments to formatStringFromArgs as strings instead of implicitly stringifying --- src/compiler/checker.ts | 16 +++++++++------- src/compiler/commandLineParser.ts | 5 +---- src/compiler/core.ts | 6 +++--- src/compiler/utilities.ts | 2 +- src/harness/unittests/commandLineParsing.ts | 16 ++++++++-------- .../convertCompilerOptionsFromJson.ts | 18 +++++++++--------- ...ions module-kind is out-of-range.errors.txt | 4 ++-- ...ns target-script is out-of-range.errors.txt | 4 ++-- 8 files changed, 35 insertions(+), 36 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d3f15f2367b..0fee5611c60 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -368,7 +368,7 @@ namespace ts { return emitResolver; } - function error(location: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): void { + function error(location: Node, message: DiagnosticMessage, arg0?: string, arg1?: string, arg2?: string): void { const diagnostic = location ? createDiagnosticForNode(location, message, arg0, arg1, arg2) : createCompilerDiagnostic(message, arg0, arg1, arg2); @@ -3004,7 +3004,8 @@ namespace ts { : elementType; if (!type) { if (isTupleType(parentType)) { - error(declaration, Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(parentType), getTypeReferenceArity(parentType), pattern.elements.length); + error(declaration, Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, + typeToString(parentType), getTypeReferenceArity(parentType).toString(), pattern.elements.length.toString()); } else { error(declaration, Diagnostics.Type_0_has_no_property_1, typeToString(parentType), propName); @@ -5103,7 +5104,7 @@ namespace ts { const typeParameters = type.localTypeParameters; if (typeParameters) { if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { - error(node, Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, /*enclosingDeclaration*/ undefined, TypeFormatFlags.WriteArrayAsGenericType), typeParameters.length); + error(node, Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, /*enclosingDeclaration*/ undefined, TypeFormatFlags.WriteArrayAsGenericType), typeParameters.length.toString()); return unknownType; } // In a type reference, the outer type parameters of the referenced class or interface are automatically @@ -5127,7 +5128,7 @@ namespace ts { const typeParameters = links.typeParameters; if (typeParameters) { if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { - error(node, Diagnostics.Generic_type_0_requires_1_type_argument_s, symbolToString(symbol), typeParameters.length); + error(node, Diagnostics.Generic_type_0_requires_1_type_argument_s, symbolToString(symbol), typeParameters.length.toString()); return unknownType; } const typeArguments = map(node.typeArguments, getTypeFromTypeNodeNoAlias); @@ -5270,7 +5271,7 @@ namespace ts { return arity ? emptyGenericType : emptyObjectType; } if (((type).typeParameters ? (type).typeParameters.length : 0) !== arity) { - error(getTypeDeclaration(symbol), Diagnostics.Global_type_0_must_have_1_type_parameter_s, symbol.name, arity); + error(getTypeDeclaration(symbol), Diagnostics.Global_type_0_must_have_1_type_parameter_s, symbol.name, arity.toString()); return arity ? emptyGenericType : emptyObjectType; } return type; @@ -8537,7 +8538,7 @@ namespace ts { // An evolving array type tracks the element types that have so far been seen in an // 'x.push(value)' or 'x[n] = value' operation along the control flow graph. Evolving // array types are ultimately converted into manifest array types (using getFinalArrayType) - // and never escape the getFlowTypeOfReference function. + // and never escape the getFlowTypeOfReference function. function createEvolvingArrayType(elementType: Type): AnonymousType { const result = createObjectType(TypeFlags.Anonymous); result.elementType = elementType; @@ -13630,7 +13631,8 @@ namespace ts { // such as NodeCheckFlags.LexicalThis on "this"expression. checkExpression(element); if (isTupleType(sourceType)) { - error(element, Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(sourceType), getTypeReferenceArity(sourceType), elements.length); + error(element, Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, + typeToString(sourceType), getTypeReferenceArity(sourceType).toString(), elements.length.toString()); } else { error(element, Diagnostics.Type_0_has_no_property_1, typeToString(sourceType), propName); diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index d5207e4ce9a..d6c7dad0e8e 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -515,10 +515,7 @@ namespace ts { /* @internal */ export function createCompilerDiagnosticForInvalidCustomType(opt: CommandLineOptionOfCustomType): Diagnostic { - const namesOfType: string[] = []; - for (const key in opt.type) { - namesOfType.push(` '${key}'`); - } + const namesOfType = Object.keys(opt.type).map(key => `'${key}'`).join(", "); return createCompilerDiagnostic(Diagnostics.Argument_for_0_option_must_be_Colon_1, `--${opt.name}`, namesOfType); } diff --git a/src/compiler/core.ts b/src/compiler/core.ts index befa30b6006..fd0724db311 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -940,7 +940,7 @@ namespace ts { } } - function formatStringFromArgs(text: string, args: { [index: number]: any; }, baseIndex?: number): string { + function formatStringFromArgs(text: string, args: { [index: number]: string; }, baseIndex?: number): string { baseIndex = baseIndex || 0; return text.replace(/{(\d+)}/g, (match, index?) => args[+index + baseIndex]); @@ -952,7 +952,7 @@ namespace ts { return localizedDiagnosticMessages && localizedDiagnosticMessages[message.key] || message.message; } - export function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ...args: any[]): Diagnostic; + export function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ...args: string[]): Diagnostic; export function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage): Diagnostic { const end = start + length; @@ -992,7 +992,7 @@ namespace ts { return text; } - export function createCompilerDiagnostic(message: DiagnosticMessage, ...args: any[]): Diagnostic; + export function createCompilerDiagnostic(message: DiagnosticMessage, ...args: string[]): Diagnostic; export function createCompilerDiagnostic(message: DiagnosticMessage): Diagnostic { let text = getLocaleSpecificMessage(message); diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 952a3205250..dfdfae9c259 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -503,7 +503,7 @@ namespace ts { return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); } - export function createDiagnosticForNode(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): Diagnostic { + export function createDiagnosticForNode(node: Node, message: DiagnosticMessage, arg0?: string, arg1?: string, arg2?: string): Diagnostic { const sourceFile = getSourceFileOfNode(node); const span = getErrorSpanForNode(sourceFile, node); return createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2); diff --git a/src/harness/unittests/commandLineParsing.ts b/src/harness/unittests/commandLineParsing.ts index cd9bf88df60..67bc1e9b795 100644 --- a/src/harness/unittests/commandLineParsing.ts +++ b/src/harness/unittests/commandLineParsing.ts @@ -60,7 +60,7 @@ namespace ts { assertParseResult(["--lib", "es5,invalidOption", "0.ts"], { errors: [{ - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory'", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory'", category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code, @@ -87,7 +87,7 @@ namespace ts { start: undefined, length: undefined, }, { - messageText: "Argument for '--jsx' option must be: 'preserve', 'react'", + messageText: "Argument for '--jsx' option must be: 'preserve', 'react'", category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code, @@ -113,7 +113,7 @@ namespace ts { start: undefined, length: undefined, }, { - messageText: "Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015'", + messageText: "Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015'", category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code, @@ -139,7 +139,7 @@ namespace ts { start: undefined, length: undefined, }, { - messageText: "Argument for '--newLine' option must be: 'crlf', 'lf'", + messageText: "Argument for '--newLine' option must be: 'crlf', 'lf'", category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code, @@ -165,7 +165,7 @@ namespace ts { start: undefined, length: undefined, }, { - messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015', 'es2016', 'es2017'", + messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015', 'es2016', 'es2017'", category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code, @@ -191,7 +191,7 @@ namespace ts { start: undefined, length: undefined, }, { - messageText: "Argument for '--moduleResolution' option must be: 'node', 'classic'", + messageText: "Argument for '--moduleResolution' option must be: 'node', 'classic'", category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code, @@ -263,7 +263,7 @@ namespace ts { assertParseResult(["--lib", "es5,", "es7", "0.ts"], { errors: [{ - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory'", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory'", category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code, @@ -283,7 +283,7 @@ namespace ts { assertParseResult(["--lib", "es5, ", "es7", "0.ts"], { errors: [{ - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory'", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory'", category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code, diff --git a/src/harness/unittests/convertCompilerOptionsFromJson.ts b/src/harness/unittests/convertCompilerOptionsFromJson.ts index a2174c17e41..2942675f0ac 100644 --- a/src/harness/unittests/convertCompilerOptionsFromJson.ts +++ b/src/harness/unittests/convertCompilerOptionsFromJson.ts @@ -94,7 +94,7 @@ namespace ts { file: undefined, start: 0, length: 0, - messageText: "Argument for '--jsx' option must be: 'preserve', 'react'", + messageText: "Argument for '--jsx' option must be: 'preserve', 'react'", code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category }] @@ -122,7 +122,7 @@ namespace ts { file: undefined, start: 0, length: 0, - messageText: "Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015'", + messageText: "Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015'", code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category }] @@ -150,7 +150,7 @@ namespace ts { file: undefined, start: 0, length: 0, - messageText: "Argument for '--newLine' option must be: 'crlf', 'lf'", + messageText: "Argument for '--newLine' option must be: 'crlf', 'lf'", code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category }] @@ -176,7 +176,7 @@ namespace ts { file: undefined, start: 0, length: 0, - messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015', 'es2016', 'es2017'", + messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015', 'es2016', 'es2017'", code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category }] @@ -202,7 +202,7 @@ namespace ts { file: undefined, start: 0, length: 0, - messageText: "Argument for '--moduleResolution' option must be: 'node', 'classic'", + messageText: "Argument for '--moduleResolution' option must be: 'node', 'classic'", code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category }] @@ -233,7 +233,7 @@ namespace ts { file: undefined, start: 0, length: 0, - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory'", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory'", code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category }] @@ -264,7 +264,7 @@ namespace ts { file: undefined, start: 0, length: 0, - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory'", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory'", code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category }] @@ -295,7 +295,7 @@ namespace ts { file: undefined, start: 0, length: 0, - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory'", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory'", code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category }] @@ -326,7 +326,7 @@ namespace ts { file: undefined, start: 0, length: 0, - messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory'", + messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory'", code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category }] diff --git a/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.errors.txt b/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.errors.txt index d7d6eb69300..7778f6c23c5 100644 --- a/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.errors.txt +++ b/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.errors.txt @@ -1,6 +1,6 @@ -error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015' +error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015' -!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015' +!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015' ==== file.ts (0 errors) ==== \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.errors.txt b/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.errors.txt index d7d6eb69300..7778f6c23c5 100644 --- a/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.errors.txt +++ b/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.errors.txt @@ -1,6 +1,6 @@ -error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015' +error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015' -!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015' +!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015' ==== file.ts (0 errors) ==== \ No newline at end of file From ff17eeda8f3487fb1a1659beb4bb233efcbc08d3 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Tue, 18 Oct 2016 11:35:22 -0700 Subject: [PATCH 130/173] check heritage clause for the presence of entry with Extends keyword (#11711) --- src/compiler/transformers/ts.ts | 2 +- tests/baselines/reference/classExpressions.js | 20 ++++++++++++++++++ .../reference/classExpressions.symbols | 19 +++++++++++++++++ .../reference/classExpressions.types | 21 +++++++++++++++++++ tests/cases/compiler/classExpressions.ts | 8 +++++++ 5 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/classExpressions.js create mode 100644 tests/baselines/reference/classExpressions.symbols create mode 100644 tests/baselines/reference/classExpressions.types create mode 100644 tests/cases/compiler/classExpressions.ts diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 1d930c3c21e..a1190efee10 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -795,7 +795,7 @@ namespace ts { function visitClassExpression(node: ClassExpression): Expression { const staticProperties = getInitializedProperties(node, /*isStatic*/ true); const heritageClauses = visitNodes(node.heritageClauses, visitor, isHeritageClause); - const members = transformClassMembers(node, heritageClauses !== undefined); + const members = transformClassMembers(node, some(heritageClauses, c => c.token === SyntaxKind.ExtendsKeyword)); const classExpression = setOriginalNode( createClassExpression( diff --git a/tests/baselines/reference/classExpressions.js b/tests/baselines/reference/classExpressions.js new file mode 100644 index 00000000000..3932fa5045b --- /dev/null +++ b/tests/baselines/reference/classExpressions.js @@ -0,0 +1,20 @@ +//// [classExpressions.ts] +interface A {} +let x = class B implements A { + prop: number; + onStart(): void { + } + func = () => { + } +}; + +//// [classExpressions.js] +var x = (function () { + function B() { + this.func = function () { + }; + } + B.prototype.onStart = function () { + }; + return B; +}()); diff --git a/tests/baselines/reference/classExpressions.symbols b/tests/baselines/reference/classExpressions.symbols new file mode 100644 index 00000000000..038b1b81116 --- /dev/null +++ b/tests/baselines/reference/classExpressions.symbols @@ -0,0 +1,19 @@ +=== tests/cases/compiler/classExpressions.ts === +interface A {} +>A : Symbol(A, Decl(classExpressions.ts, 0, 0)) + +let x = class B implements A { +>x : Symbol(x, Decl(classExpressions.ts, 1, 3)) +>B : Symbol(B, Decl(classExpressions.ts, 1, 7)) +>A : Symbol(A, Decl(classExpressions.ts, 0, 0)) + + prop: number; +>prop : Symbol(B.prop, Decl(classExpressions.ts, 1, 30)) + + onStart(): void { +>onStart : Symbol(B.onStart, Decl(classExpressions.ts, 2, 17)) + } + func = () => { +>func : Symbol(B.func, Decl(classExpressions.ts, 4, 5)) + } +}; diff --git a/tests/baselines/reference/classExpressions.types b/tests/baselines/reference/classExpressions.types new file mode 100644 index 00000000000..3fcff32c4a4 --- /dev/null +++ b/tests/baselines/reference/classExpressions.types @@ -0,0 +1,21 @@ +=== tests/cases/compiler/classExpressions.ts === +interface A {} +>A : A + +let x = class B implements A { +>x : typeof B +>class B implements A { prop: number; onStart(): void { } func = () => { }} : typeof B +>B : typeof B +>A : A + + prop: number; +>prop : number + + onStart(): void { +>onStart : () => void + } + func = () => { +>func : () => void +>() => { } : () => void + } +}; diff --git a/tests/cases/compiler/classExpressions.ts b/tests/cases/compiler/classExpressions.ts new file mode 100644 index 00000000000..fc7ce376469 --- /dev/null +++ b/tests/cases/compiler/classExpressions.ts @@ -0,0 +1,8 @@ +interface A {} +let x = class B implements A { + prop: number; + onStart(): void { + } + func = () => { + } +}; \ No newline at end of file From ef5f3c90a457ba50484da59000c39a2797150240 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 18 Oct 2016 11:53:26 -0700 Subject: [PATCH 131/173] Normalize intersection and union types --- src/compiler/checker.ts | 15 +++++++++++++++ src/compiler/core.ts | 6 ++++++ 2 files changed, 21 insertions(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d3f15f2367b..879e2dec9df 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5603,6 +5603,11 @@ namespace ts { } } + // We normalize combinations of intersection and union types based on the distributive property of the '&' + // operator. Specifically, because X & (A | B) is equivalent to X & A | X & B, we can transform intersection + // types with union type constituents into equivalent union types with intersection type constituents and + // effectively ensure that union types are always at the top level in type representations. + // // We do not perform structural deduplication on intersection types. Intersection types are created only by the & // type operator and we can't reduce those because we want to support recursive intersection types. For example, // a type alias of the form "type List = T & { next: List }" cannot be reduced during its declaration. @@ -5612,6 +5617,16 @@ namespace ts { if (types.length === 0) { return emptyObjectType; } + for (let i = 0; i < types.length; i++) { + const type = types[i]; + if (type.flags & TypeFlags.Union) { + // We are attempting to construct a type of the form X & (A | B) & Y. Transform this into a type of + // the form X & A & Y | X & B & Y and recursively reduce until no union type constituents remain. + let unionType = types[i]; + return getUnionType(map((type).types, t => getIntersectionType(replaceElement(types, i, t))), + /*subtypeReduction*/ false, aliasSymbol, aliasTypeArguments); + } + } const typeSet = [] as TypeSet; addTypesToIntersection(typeSet, types); if (typeSet.containsAny) { diff --git a/src/compiler/core.ts b/src/compiler/core.ts index befa30b6006..b9a3becba72 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -532,6 +532,12 @@ namespace ts { : undefined; } + export function replaceElement(array: T[], index: number, value: T): T[] { + const result = array.slice(0); + result[index] = value; + return result; + } + /** * Performs a binary search, finding the index at which 'value' occurs in 'array'. * If no such index is found, returns the 2's-complement of first index at which From eb7d2cbe9bbc7fd8332488fa084c9293ca29e53a Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 18 Oct 2016 11:54:26 -0700 Subject: [PATCH 132/173] Accept new baselines --- ...rrorMessagesIntersectionTypes04.errors.txt | 6 +- .../intersectionAndUnionTypes.errors.txt | 74 ++++++++++--------- ...itchCaseWithIntersectionTypes01.errors.txt | 10 ++- .../reference/typeGuardsWithInstanceOf.types | 4 +- 4 files changed, 50 insertions(+), 44 deletions(-) diff --git a/tests/baselines/reference/errorMessagesIntersectionTypes04.errors.txt b/tests/baselines/reference/errorMessagesIntersectionTypes04.errors.txt index 7582c68ecec..d2e81844da1 100644 --- a/tests/baselines/reference/errorMessagesIntersectionTypes04.errors.txt +++ b/tests/baselines/reference/errorMessagesIntersectionTypes04.errors.txt @@ -1,7 +1,8 @@ tests/cases/compiler/errorMessagesIntersectionTypes04.ts(17,5): error TS2322: Type 'A & B' is not assignable to type 'number'. tests/cases/compiler/errorMessagesIntersectionTypes04.ts(18,5): error TS2322: Type 'A & B' is not assignable to type 'boolean'. tests/cases/compiler/errorMessagesIntersectionTypes04.ts(19,5): error TS2322: Type 'A & B' is not assignable to type 'string'. -tests/cases/compiler/errorMessagesIntersectionTypes04.ts(21,5): error TS2322: Type 'number & boolean' is not assignable to type 'string'. +tests/cases/compiler/errorMessagesIntersectionTypes04.ts(21,5): error TS2322: Type '(number & true) | (number & false)' is not assignable to type 'string'. + Type 'number & true' is not assignable to type 'string'. ==== tests/cases/compiler/errorMessagesIntersectionTypes04.ts (4 errors) ==== @@ -33,5 +34,6 @@ tests/cases/compiler/errorMessagesIntersectionTypes04.ts(21,5): error TS2322: Ty str = num_and_bool; ~~~ -!!! error TS2322: Type 'number & boolean' is not assignable to type 'string'. +!!! error TS2322: Type '(number & true) | (number & false)' is not assignable to type 'string'. +!!! error TS2322: Type 'number & true' is not assignable to type 'string'. } \ No newline at end of file diff --git a/tests/baselines/reference/intersectionAndUnionTypes.errors.txt b/tests/baselines/reference/intersectionAndUnionTypes.errors.txt index 5a04d4f25d3..62ddfd497a3 100644 --- a/tests/baselines/reference/intersectionAndUnionTypes.errors.txt +++ b/tests/baselines/reference/intersectionAndUnionTypes.errors.txt @@ -30,28 +30,29 @@ tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(29,1): e Type 'A & B' is not assignable to type 'C | D'. Type 'A & B' is not assignable to type 'D'. Property 'd' is missing in type 'A & B'. -tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(31,1): error TS2322: Type 'A & B' is not assignable to type '(A | B) & (C | D)'. - Type 'A & B' is not assignable to type 'C | D'. +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(31,1): error TS2322: Type 'A & B' is not assignable to type '(A & C) | (A & D) | (B & C) | (B & D)'. + Type 'A & B' is not assignable to type 'B & D'. Type 'A & B' is not assignable to type 'D'. -tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(32,1): error TS2322: Type 'A | B' is not assignable to type '(A | B) & (C | D)'. - Type 'A' is not assignable to type '(A | B) & (C | D)'. - Type 'A' is not assignable to type 'C | D'. - Type 'A' is not assignable to type 'D'. - Property 'd' is missing in type 'A'. -tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(33,1): error TS2322: Type 'C & D' is not assignable to type '(A | B) & (C | D)'. - Type 'C & D' is not assignable to type 'A | B'. +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(32,1): error TS2322: Type 'A | B' is not assignable to type '(A & C) | (A & D) | (B & C) | (B & D)'. + Type 'A' is not assignable to type '(A & C) | (A & D) | (B & C) | (B & D)'. + Type 'A' is not assignable to type 'B & D'. + Type 'A' is not assignable to type 'B'. +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(33,1): error TS2322: Type 'C & D' is not assignable to type '(A & C) | (A & D) | (B & C) | (B & D)'. + Type 'C & D' is not assignable to type 'B & D'. Type 'C & D' is not assignable to type 'B'. -tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(34,1): error TS2322: Type 'C | D' is not assignable to type '(A | B) & (C | D)'. - Type 'C' is not assignable to type '(A | B) & (C | D)'. - Type 'C' is not assignable to type 'A | B'. +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(34,1): error TS2322: Type 'C | D' is not assignable to type '(A & C) | (A & D) | (B & C) | (B & D)'. + Type 'C' is not assignable to type '(A & C) | (A & D) | (B & C) | (B & D)'. + Type 'C' is not assignable to type 'B & D'. Type 'C' is not assignable to type 'B'. Property 'b' is missing in type 'C'. -tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(35,1): error TS2322: Type '(A | B) & (C | D)' is not assignable to type 'A & B'. - Type '(A | B) & (C | D)' is not assignable to type 'A'. - Property 'a' is missing in type '(A | B) & (C | D)'. -tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(37,1): error TS2322: Type '(A | B) & (C | D)' is not assignable to type 'C & D'. - Type '(A | B) & (C | D)' is not assignable to type 'C'. - Property 'c' is missing in type '(A | B) & (C | D)'. +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(35,1): error TS2322: Type '(A & C) | (A & D) | (B & C) | (B & D)' is not assignable to type 'A & B'. + Type 'A & C' is not assignable to type 'A & B'. + Type 'A & C' is not assignable to type 'B'. + Property 'b' is missing in type 'A & C'. +tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(37,1): error TS2322: Type '(A & C) | (A & D) | (B & C) | (B & D)' is not assignable to type 'C & D'. + Type 'A & C' is not assignable to type 'C & D'. + Type 'A & C' is not assignable to type 'D'. + Property 'd' is missing in type 'A & C'. ==== tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts (14 errors) ==== @@ -127,38 +128,39 @@ tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(37,1): e y = anb; ~ -!!! error TS2322: Type 'A & B' is not assignable to type '(A | B) & (C | D)'. -!!! error TS2322: Type 'A & B' is not assignable to type 'C | D'. +!!! error TS2322: Type 'A & B' is not assignable to type '(A & C) | (A & D) | (B & C) | (B & D)'. +!!! error TS2322: Type 'A & B' is not assignable to type 'B & D'. !!! error TS2322: Type 'A & B' is not assignable to type 'D'. y = aob; ~ -!!! error TS2322: Type 'A | B' is not assignable to type '(A | B) & (C | D)'. -!!! error TS2322: Type 'A' is not assignable to type '(A | B) & (C | D)'. -!!! error TS2322: Type 'A' is not assignable to type 'C | D'. -!!! error TS2322: Type 'A' is not assignable to type 'D'. -!!! error TS2322: Property 'd' is missing in type 'A'. +!!! error TS2322: Type 'A | B' is not assignable to type '(A & C) | (A & D) | (B & C) | (B & D)'. +!!! error TS2322: Type 'A' is not assignable to type '(A & C) | (A & D) | (B & C) | (B & D)'. +!!! error TS2322: Type 'A' is not assignable to type 'B & D'. +!!! error TS2322: Type 'A' is not assignable to type 'B'. y = cnd; ~ -!!! error TS2322: Type 'C & D' is not assignable to type '(A | B) & (C | D)'. -!!! error TS2322: Type 'C & D' is not assignable to type 'A | B'. +!!! error TS2322: Type 'C & D' is not assignable to type '(A & C) | (A & D) | (B & C) | (B & D)'. +!!! error TS2322: Type 'C & D' is not assignable to type 'B & D'. !!! error TS2322: Type 'C & D' is not assignable to type 'B'. y = cod; ~ -!!! error TS2322: Type 'C | D' is not assignable to type '(A | B) & (C | D)'. -!!! error TS2322: Type 'C' is not assignable to type '(A | B) & (C | D)'. -!!! error TS2322: Type 'C' is not assignable to type 'A | B'. +!!! error TS2322: Type 'C | D' is not assignable to type '(A & C) | (A & D) | (B & C) | (B & D)'. +!!! error TS2322: Type 'C' is not assignable to type '(A & C) | (A & D) | (B & C) | (B & D)'. +!!! error TS2322: Type 'C' is not assignable to type 'B & D'. !!! error TS2322: Type 'C' is not assignable to type 'B'. !!! error TS2322: Property 'b' is missing in type 'C'. anb = y; ~~~ -!!! error TS2322: Type '(A | B) & (C | D)' is not assignable to type 'A & B'. -!!! error TS2322: Type '(A | B) & (C | D)' is not assignable to type 'A'. -!!! error TS2322: Property 'a' is missing in type '(A | B) & (C | D)'. +!!! error TS2322: Type '(A & C) | (A & D) | (B & C) | (B & D)' is not assignable to type 'A & B'. +!!! error TS2322: Type 'A & C' is not assignable to type 'A & B'. +!!! error TS2322: Type 'A & C' is not assignable to type 'B'. +!!! error TS2322: Property 'b' is missing in type 'A & C'. aob = y; // Ok cnd = y; ~~~ -!!! error TS2322: Type '(A | B) & (C | D)' is not assignable to type 'C & D'. -!!! error TS2322: Type '(A | B) & (C | D)' is not assignable to type 'C'. -!!! error TS2322: Property 'c' is missing in type '(A | B) & (C | D)'. +!!! error TS2322: Type '(A & C) | (A & D) | (B & C) | (B & D)' is not assignable to type 'C & D'. +!!! error TS2322: Type 'A & C' is not assignable to type 'C & D'. +!!! error TS2322: Type 'A & C' is not assignable to type 'D'. +!!! error TS2322: Property 'd' is missing in type 'A & C'. cod = y; // Ok \ No newline at end of file diff --git a/tests/baselines/reference/switchCaseWithIntersectionTypes01.errors.txt b/tests/baselines/reference/switchCaseWithIntersectionTypes01.errors.txt index ad2ca8bc123..d31a005842c 100644 --- a/tests/baselines/reference/switchCaseWithIntersectionTypes01.errors.txt +++ b/tests/baselines/reference/switchCaseWithIntersectionTypes01.errors.txt @@ -1,5 +1,6 @@ -tests/cases/conformance/types/typeRelationships/comparable/switchCaseWithIntersectionTypes01.ts(19,10): error TS2678: Type 'number & boolean' is not comparable to type 'string & number'. - Type 'number & boolean' is not comparable to type 'string'. +tests/cases/conformance/types/typeRelationships/comparable/switchCaseWithIntersectionTypes01.ts(19,10): error TS2678: Type '(number & true) | (number & false)' is not comparable to type 'string & number'. + Type 'number & false' is not comparable to type 'string & number'. + Type 'number & false' is not comparable to type 'string'. tests/cases/conformance/types/typeRelationships/comparable/switchCaseWithIntersectionTypes01.ts(23,10): error TS2678: Type 'boolean' is not comparable to type 'string & number'. @@ -24,8 +25,9 @@ tests/cases/conformance/types/typeRelationships/comparable/switchCaseWithInterse // Overlap in constituents case numAndBool: ~~~~~~~~~~ -!!! error TS2678: Type 'number & boolean' is not comparable to type 'string & number'. -!!! error TS2678: Type 'number & boolean' is not comparable to type 'string'. +!!! error TS2678: Type '(number & true) | (number & false)' is not comparable to type 'string & number'. +!!! error TS2678: Type 'number & false' is not comparable to type 'string & number'. +!!! error TS2678: Type 'number & false' is not comparable to type 'string'. break; // No relation diff --git a/tests/baselines/reference/typeGuardsWithInstanceOf.types b/tests/baselines/reference/typeGuardsWithInstanceOf.types index f54498f93c8..7fce8cd4559 100644 --- a/tests/baselines/reference/typeGuardsWithInstanceOf.types +++ b/tests/baselines/reference/typeGuardsWithInstanceOf.types @@ -25,7 +25,7 @@ if (!(result instanceof RegExp)) { } else if (!result.global) { >!result.global : boolean ->result.global : string & boolean +>result.global : (string & true) | (string & false) >result : I & RegExp ->global : string & boolean +>global : (string & true) | (string & false) } From 8dc9523fb0530bc5d35743e3250d3a4f0a67ce8d Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 18 Oct 2016 11:53:27 -0700 Subject: [PATCH 133/173] Allow number too --- src/compiler/checker.ts | 14 ++++++-------- src/compiler/core.ts | 4 ++-- src/compiler/utilities.ts | 2 +- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 0fee5611c60..3708ea3582c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -368,7 +368,7 @@ namespace ts { return emitResolver; } - function error(location: Node, message: DiagnosticMessage, arg0?: string, arg1?: string, arg2?: string): void { + function error(location: Node, message: DiagnosticMessage, arg0?: string | number, arg1?: string | number, arg2?: string | number): void { const diagnostic = location ? createDiagnosticForNode(location, message, arg0, arg1, arg2) : createCompilerDiagnostic(message, arg0, arg1, arg2); @@ -3004,8 +3004,7 @@ namespace ts { : elementType; if (!type) { if (isTupleType(parentType)) { - error(declaration, Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, - typeToString(parentType), getTypeReferenceArity(parentType).toString(), pattern.elements.length.toString()); + error(declaration, Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(parentType), getTypeReferenceArity(parentType), pattern.elements.length); } else { error(declaration, Diagnostics.Type_0_has_no_property_1, typeToString(parentType), propName); @@ -5104,7 +5103,7 @@ namespace ts { const typeParameters = type.localTypeParameters; if (typeParameters) { if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { - error(node, Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, /*enclosingDeclaration*/ undefined, TypeFormatFlags.WriteArrayAsGenericType), typeParameters.length.toString()); + error(node, Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, /*enclosingDeclaration*/ undefined, TypeFormatFlags.WriteArrayAsGenericType), typeParameters.length); return unknownType; } // In a type reference, the outer type parameters of the referenced class or interface are automatically @@ -5128,7 +5127,7 @@ namespace ts { const typeParameters = links.typeParameters; if (typeParameters) { if (!node.typeArguments || node.typeArguments.length !== typeParameters.length) { - error(node, Diagnostics.Generic_type_0_requires_1_type_argument_s, symbolToString(symbol), typeParameters.length.toString()); + error(node, Diagnostics.Generic_type_0_requires_1_type_argument_s, symbolToString(symbol), typeParameters.length); return unknownType; } const typeArguments = map(node.typeArguments, getTypeFromTypeNodeNoAlias); @@ -5271,7 +5270,7 @@ namespace ts { return arity ? emptyGenericType : emptyObjectType; } if (((type).typeParameters ? (type).typeParameters.length : 0) !== arity) { - error(getTypeDeclaration(symbol), Diagnostics.Global_type_0_must_have_1_type_parameter_s, symbol.name, arity.toString()); + error(getTypeDeclaration(symbol), Diagnostics.Global_type_0_must_have_1_type_parameter_s, symbol.name, arity); return arity ? emptyGenericType : emptyObjectType; } return type; @@ -13631,8 +13630,7 @@ namespace ts { // such as NodeCheckFlags.LexicalThis on "this"expression. checkExpression(element); if (isTupleType(sourceType)) { - error(element, Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, - typeToString(sourceType), getTypeReferenceArity(sourceType).toString(), elements.length.toString()); + error(element, Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(sourceType), getTypeReferenceArity(sourceType), elements.length); } else { error(element, Diagnostics.Type_0_has_no_property_1, typeToString(sourceType), propName); diff --git a/src/compiler/core.ts b/src/compiler/core.ts index fd0724db311..b41f382badf 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -952,7 +952,7 @@ namespace ts { return localizedDiagnosticMessages && localizedDiagnosticMessages[message.key] || message.message; } - export function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ...args: string[]): Diagnostic; + export function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ...args: (string | number)[]): Diagnostic; export function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage): Diagnostic { const end = start + length; @@ -992,7 +992,7 @@ namespace ts { return text; } - export function createCompilerDiagnostic(message: DiagnosticMessage, ...args: string[]): Diagnostic; + export function createCompilerDiagnostic(message: DiagnosticMessage, ...args: (string | number)[]): Diagnostic; export function createCompilerDiagnostic(message: DiagnosticMessage): Diagnostic { let text = getLocaleSpecificMessage(message); diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index dfdfae9c259..efdac40c287 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -503,7 +503,7 @@ namespace ts { return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); } - export function createDiagnosticForNode(node: Node, message: DiagnosticMessage, arg0?: string, arg1?: string, arg2?: string): Diagnostic { + export function createDiagnosticForNode(node: Node, message: DiagnosticMessage, arg0?: string | number, arg1?: string | number, arg2?: string | number): Diagnostic { const sourceFile = getSourceFileOfNode(node); const span = getErrorSpanForNode(sourceFile, node); return createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2); From 7685e6af157d28dd6647def5de33c653efd37a17 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 10 Oct 2016 13:06:58 -0700 Subject: [PATCH 134/173] Forbid unused locals/parameters in compiler --- src/compiler/checker.ts | 49 ++++++++++------------ src/compiler/comments.ts | 10 ++--- src/compiler/core.ts | 17 ++++---- src/compiler/declarationEmitter.ts | 14 +++---- src/compiler/emitter.ts | 26 ++++++------ src/compiler/moduleNameResolver.ts | 2 +- src/compiler/parser.ts | 14 +++---- src/compiler/performance.ts | 2 +- src/compiler/program.ts | 49 +++++++++++----------- src/compiler/scanner.ts | 2 +- src/compiler/sys.ts | 12 ++---- src/compiler/transformer.ts | 2 +- src/compiler/transformers/destructuring.ts | 12 ++---- src/compiler/transformers/es2015.ts | 27 ++++++------ src/compiler/transformers/generators.ts | 6 +-- src/compiler/transformers/module/es2015.ts | 8 +--- src/compiler/transformers/module/module.ts | 1 - src/compiler/transformers/module/system.ts | 4 +- src/compiler/transformers/ts.ts | 25 +++++------ src/compiler/tsc.ts | 8 ++-- src/compiler/tsconfig.json | 4 +- src/compiler/utilities.ts | 4 +- src/compiler/visitor.ts | 6 +-- src/services/shims.ts | 4 +- 24 files changed, 142 insertions(+), 166 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3708ea3582c..f24f72491b0 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1054,7 +1054,7 @@ namespace ts { if (node.moduleReference.kind === SyntaxKind.ExternalModuleReference) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, getExternalModuleImportEqualsDeclarationExpression(node))); } - return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); + return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); } function getTargetOfImportClause(node: ImportClause): Symbol { @@ -1267,7 +1267,7 @@ namespace ts { } // This function is only for imports with entity names - function getSymbolOfPartOfRightHandSideOfImportEquals(entityName: EntityName, importDeclaration: ImportEqualsDeclaration, dontResolveAlias?: boolean): Symbol { + function getSymbolOfPartOfRightHandSideOfImportEquals(entityName: EntityName, dontResolveAlias?: boolean): Symbol { // There are three things we might try to look for. In the following examples, // the search term is enclosed in |...|: // @@ -2583,7 +2583,7 @@ namespace ts { } } - function buildDisplayForTypeArgumentsAndDelimiters(typeParameters: TypeParameter[], mapper: TypeMapper, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, symbolStack?: Symbol[]) { + function buildDisplayForTypeArgumentsAndDelimiters(typeParameters: TypeParameter[], mapper: TypeMapper, writer: SymbolWriter, enclosingDeclaration?: Node) { if (typeParameters && typeParameters.length) { writePunctuation(writer, SyntaxKind.LessThanToken); let flags = TypeFormatFlags.InFirstTypeArgument; @@ -4795,7 +4795,7 @@ namespace ts { const typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : getTypeParametersFromJSDocTemplate(declaration); - const returnType = getSignatureReturnTypeFromDeclaration(declaration, minArgumentCount, isJSConstructSignature, classType); + const returnType = getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType); const typePredicate = declaration.type && declaration.type.kind === SyntaxKind.TypePredicate ? createTypePredicateFromTypePredicateNode(declaration.type as TypePredicateNode) : undefined; @@ -4805,7 +4805,7 @@ namespace ts { return links.resolvedSignature; } - function getSignatureReturnTypeFromDeclaration(declaration: SignatureDeclaration, minArgumentCount: number, isJSConstructSignature: boolean, classType: Type) { + function getSignatureReturnTypeFromDeclaration(declaration: SignatureDeclaration, isJSConstructSignature: boolean, classType: Type) { if (isJSConstructSignature) { return getTypeFromTypeNode(declaration.parameters[0].type); } @@ -5170,10 +5170,7 @@ namespace ts { return undefined; } - function resolveTypeReferenceName( - node: TypeReferenceNode | ExpressionWithTypeArguments | JSDocTypeReference, - typeReferenceName: EntityNameExpression | EntityName) { - + function resolveTypeReferenceName(typeReferenceName: EntityNameExpression | EntityName) { if (!typeReferenceName) { return unknownSymbol; } @@ -5211,7 +5208,7 @@ namespace ts { let type: Type; if (node.kind === SyntaxKind.JSDocTypeReference) { const typeReferenceName = getTypeReferenceName(node); - symbol = resolveTypeReferenceName(node, typeReferenceName); + symbol = resolveTypeReferenceName(typeReferenceName); type = getTypeReferenceType(node, symbol); } else { @@ -6673,8 +6670,8 @@ namespace ts { } if (source.flags & TypeFlags.Union && target.flags & TypeFlags.Union || source.flags & TypeFlags.Intersection && target.flags & TypeFlags.Intersection) { - if (result = eachTypeRelatedToSomeType(source, target, /*reportErrors*/ false)) { - if (result &= eachTypeRelatedToSomeType(target, source, /*reportErrors*/ false)) { + if (result = eachTypeRelatedToSomeType(source, target)) { + if (result &= eachTypeRelatedToSomeType(target, source)) { return result; } } @@ -6735,7 +6732,7 @@ namespace ts { return false; } - function eachTypeRelatedToSomeType(source: UnionOrIntersectionType, target: UnionOrIntersectionType, reportErrors: boolean): Ternary { + function eachTypeRelatedToSomeType(source: UnionOrIntersectionType, target: UnionOrIntersectionType): Ternary { let result = Ternary.True; const sourceTypes = source.types; for (const sourceType of sourceTypes) { @@ -11772,7 +11769,7 @@ namespace ts { // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. if (arg === undefined || arg.kind !== SyntaxKind.OmittedExpression) { const paramType = getTypeAtPosition(signature, i); - let argType = getEffectiveArgumentType(node, i, arg); + let argType = getEffectiveArgumentType(node, i); // If the effective argument type is 'undefined', there is no synthetic type // for the argument. In that case, we should check the argument. @@ -11858,7 +11855,7 @@ namespace ts { if (arg === undefined || arg.kind !== SyntaxKind.OmittedExpression) { // Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter) const paramType = getTypeAtPosition(signature, i); - let argType = getEffectiveArgumentType(node, i, arg); + let argType = getEffectiveArgumentType(node, i); // If the effective argument type is 'undefined', there is no synthetic type // for the argument. In that case, we should check the argument. @@ -12151,7 +12148,7 @@ namespace ts { /** * Gets the effective argument type for an argument in a call expression. */ - function getEffectiveArgumentType(node: CallLikeExpression, argIndex: number, arg: Expression): Type { + function getEffectiveArgumentType(node: CallLikeExpression, argIndex: number): Type { // 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 @@ -13556,15 +13553,15 @@ namespace ts { return booleanType; } - function checkObjectLiteralAssignment(node: ObjectLiteralExpression, sourceType: Type, contextualMapper?: TypeMapper): Type { + function checkObjectLiteralAssignment(node: ObjectLiteralExpression, sourceType: Type): Type { const properties = node.properties; for (const p of properties) { - checkObjectLiteralDestructuringPropertyAssignment(sourceType, p, contextualMapper); + checkObjectLiteralDestructuringPropertyAssignment(sourceType, p); } return sourceType; } - function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType: Type, property: ObjectLiteralElementLike, contextualMapper?: TypeMapper) { + function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType: Type, property: ObjectLiteralElementLike) { if (property.kind === SyntaxKind.PropertyAssignment || property.kind === SyntaxKind.ShorthandPropertyAssignment) { const name = (property).name; if (name.kind === SyntaxKind.ComputedPropertyName) { @@ -13679,7 +13676,7 @@ namespace ts { target = (target).left; } if (target.kind === SyntaxKind.ObjectLiteralExpression) { - return checkObjectLiteralAssignment(target, sourceType, contextualMapper); + return checkObjectLiteralAssignment(target, sourceType); } if (target.kind === SyntaxKind.ArrayLiteralExpression) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); @@ -18588,7 +18585,7 @@ namespace ts { // Since we already checked for ExportAssignment, this really could only be an Import const importEqualsDeclaration = getAncestor(entityName, SyntaxKind.ImportEqualsDeclaration); Debug.assert(importEqualsDeclaration !== undefined); - return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importEqualsDeclaration, /*dontResolveAlias*/ true); + return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } if (isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { @@ -19971,7 +19968,7 @@ namespace ts { } } - function checkGrammarTypeParameterList(node: FunctionLikeDeclaration, typeParameters: NodeArray, file: SourceFile): boolean { + function checkGrammarTypeParameterList(typeParameters: NodeArray, file: SourceFile): boolean { if (checkGrammarForDisallowedTrailingComma(typeParameters)) { return true; } @@ -20022,7 +20019,7 @@ namespace ts { function checkGrammarFunctionLikeDeclaration(node: FunctionLikeDeclaration): boolean { // Prevent cascading error by short-circuit const file = getSourceFileOfNode(node); - return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node, node.typeParameters, file) || + return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node.typeParameters, file) || checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } @@ -20208,7 +20205,7 @@ namespace ts { } } - function checkGrammarForInvalidQuestionMark(node: Declaration, questionToken: Node, message: DiagnosticMessage): boolean { + function checkGrammarForInvalidQuestionMark(questionToken: Node, message: DiagnosticMessage): boolean { if (questionToken) { return grammarErrorOnNode(questionToken, message); } @@ -20254,7 +20251,7 @@ namespace ts { let currentKind: number; if (prop.kind === SyntaxKind.PropertyAssignment || prop.kind === SyntaxKind.ShorthandPropertyAssignment) { // Grammar checking for computedPropertyName and shorthandPropertyAssignment - checkGrammarForInvalidQuestionMark(prop, (prop).questionToken, Diagnostics.An_object_member_cannot_be_declared_optional); + checkGrammarForInvalidQuestionMark((prop).questionToken, Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === SyntaxKind.NumericLiteral) { checkGrammarNumericLiteral(name); } @@ -20438,7 +20435,7 @@ namespace ts { } if (node.parent.kind === SyntaxKind.ObjectLiteralExpression) { - if (checkGrammarForInvalidQuestionMark(node, node.questionToken, Diagnostics.An_object_member_cannot_be_declared_optional)) { + if (checkGrammarForInvalidQuestionMark(node.questionToken, Diagnostics.An_object_member_cannot_be_declared_optional)) { return true; } else if (node.body === undefined) { diff --git a/src/compiler/comments.ts b/src/compiler/comments.ts index 116a8e849a3..c2cf49eeb6a 100644 --- a/src/compiler/comments.ts +++ b/src/compiler/comments.ts @@ -182,13 +182,13 @@ namespace ts { } } - function emitTripleSlashLeadingComment(commentPos: number, commentEnd: number, kind: SyntaxKind, hasTrailingNewLine: boolean, rangePos: number) { + function emitTripleSlashLeadingComment(commentPos: number, commentEnd: number, _kind: SyntaxKind, hasTrailingNewLine: boolean, rangePos: number) { if (isTripleSlashComment(commentPos, commentEnd)) { - emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos); + emitLeadingComment(commentPos, commentEnd, _kind, hasTrailingNewLine, rangePos); } } - function emitLeadingComment(commentPos: number, commentEnd: number, kind: SyntaxKind, hasTrailingNewLine: boolean, rangePos: number) { + function emitLeadingComment(commentPos: number, commentEnd: number, _kind: SyntaxKind, hasTrailingNewLine: boolean, rangePos: number) { if (!hasWrittenComment) { emitNewLineBeforeLeadingCommentOfPosition(currentLineMap, writer, rangePos, commentPos); hasWrittenComment = true; @@ -211,7 +211,7 @@ namespace ts { forEachTrailingCommentToEmit(pos, emitTrailingComment); } - function emitTrailingComment(commentPos: number, commentEnd: number, kind: SyntaxKind, hasTrailingNewLine: boolean) { + function emitTrailingComment(commentPos: number, commentEnd: number, _kind: SyntaxKind, hasTrailingNewLine: boolean) { // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment2*/ if (!writer.isAtStartOfLine()) { writer.write(" "); @@ -242,7 +242,7 @@ namespace ts { } } - function emitTrailingCommentOfPosition(commentPos: number, commentEnd: number, kind: SyntaxKind, hasTrailingNewLine: boolean) { + function emitTrailingCommentOfPosition(commentPos: number, commentEnd: number, _kind: SyntaxKind, hasTrailingNewLine: boolean) { // trailing comments of a position are emitted at /*trailing comment1 */space/*trailing comment*/space emitPos(commentPos); diff --git a/src/compiler/core.ts b/src/compiler/core.ts index b41f382badf..05efc6db909 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -903,7 +903,7 @@ namespace ts { return t => compose(a(t)); } else { - return t => u => u; + return _t => u => u; } } @@ -943,7 +943,7 @@ namespace ts { function formatStringFromArgs(text: string, args: { [index: number]: string; }, baseIndex?: number): string { baseIndex = baseIndex || 0; - return text.replace(/{(\d+)}/g, (match, index?) => args[+index + baseIndex]); + return text.replace(/{(\d+)}/g, (_match, index?) => args[+index + baseIndex]); } export let localizedDiagnosticMessages: Map = undefined; @@ -982,7 +982,7 @@ namespace ts { } /* internal */ - export function formatMessage(dummy: any, message: DiagnosticMessage): string { + export function formatMessage(_dummy: any, message: DiagnosticMessage): string { let text = getLocaleSpecificMessage(message); if (arguments.length > 2) { @@ -1623,7 +1623,7 @@ namespace ts { basePaths: string[]; } - export function getFileMatcherPatterns(path: string, extensions: string[], excludes: string[], includes: string[], useCaseSensitiveFileNames: boolean, currentDirectory: string): FileMatcherPatterns { + export function getFileMatcherPatterns(path: string, excludes: string[], includes: string[], useCaseSensitiveFileNames: boolean, currentDirectory: string): FileMatcherPatterns { path = normalizePath(path); currentDirectory = normalizePath(currentDirectory); const absolutePath = combinePaths(currentDirectory, path); @@ -1640,7 +1640,7 @@ namespace ts { path = normalizePath(path); currentDirectory = normalizePath(currentDirectory); - const patterns = getFileMatcherPatterns(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory); + const patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory); const regexFlag = useCaseSensitiveFileNames ? "" : "i"; const includeFileRegex = patterns.includeFilePattern && new RegExp(patterns.includeFilePattern, regexFlag); @@ -1874,11 +1874,11 @@ namespace ts { this.declarations = undefined; } - function Type(this: Type, checker: TypeChecker, flags: TypeFlags) { + function Type(this: Type, _checker: TypeChecker, flags: TypeFlags) { this.flags = flags; } - function Signature(checker: TypeChecker) { + function Signature() { } function Node(this: Node, kind: SyntaxKind, pos: number, end: number) { @@ -1911,9 +1911,6 @@ namespace ts { } export namespace Debug { - declare var process: any; - declare var require: any; - export let currentAssertionLevel = AssertionLevel.None; export function shouldAssert(level: AssertionLevel): boolean { diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index 8bcce86c31f..27751a1dfc2 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -63,7 +63,7 @@ namespace ts { let isCurrentFileExternalModule: boolean; let reportedDeclarationError = false; let errorNameNode: DeclarationName; - const emitJsDocComments = compilerOptions.removeComments ? function (declaration: Node) { } : writeJsDocComments; + const emitJsDocComments = compilerOptions.removeComments ? () => {} : writeJsDocComments; const emit = compilerOptions.stripInternal ? stripInternal : emitNode; let noDeclare: boolean; @@ -580,7 +580,7 @@ namespace ts { writeAsynchronousModuleElements(nodes); } - function getDefaultExportAccessibilityDiagnostic(diagnostic: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic { + function getDefaultExportAccessibilityDiagnostic(): SymbolAccessibilityDiagnostic { return { diagnosticMessage: Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, errorNode: node @@ -710,7 +710,7 @@ namespace ts { } writer.writeLine(); - function getImportEntityNameVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic { + function getImportEntityNameVisibilityError(): SymbolAccessibilityDiagnostic { return { diagnosticMessage: Diagnostics.Import_declaration_0_is_using_private_name_1, errorNode: node, @@ -888,7 +888,7 @@ namespace ts { writeLine(); enclosingDeclaration = prevEnclosingDeclaration; - function getTypeAliasDeclarationVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic { + function getTypeAliasDeclarationVisibilityError(): SymbolAccessibilityDiagnostic { return { diagnosticMessage: Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, errorNode: node.type, @@ -955,7 +955,7 @@ namespace ts { } } - function getTypeParameterConstraintVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic { + function getTypeParameterConstraintVisibilityError(): SymbolAccessibilityDiagnostic { // Type parameter constraints are named by user so we should always be able to name it let diagnosticMessage: DiagnosticMessage; switch (node.parent.kind) { @@ -1029,7 +1029,7 @@ namespace ts { resolver.writeBaseConstructorTypeOfClass(enclosingDeclaration, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction | TypeFormatFlags.UseTypeAliasValue, writer); } - function getHeritageClauseVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic { + function getHeritageClauseVisibilityError(): SymbolAccessibilityDiagnostic { let diagnosticMessage: DiagnosticMessage; // Heritage clause is written by user so it can always be named if (node.parent.parent.kind === SyntaxKind.ClassDeclaration) { @@ -1743,7 +1743,7 @@ namespace ts { } return addedBundledEmitReference; - function getDeclFileName(emitFileNames: EmitFileNames, sourceFiles: SourceFile[], isBundledEmit: boolean) { + function getDeclFileName(emitFileNames: EmitFileNames, _sourceFiles: SourceFile[], isBundledEmit: boolean) { // Dont add reference path to this file if it is a bundled emit and caller asked not emit bundled file path if (isBundledEmit && !addBundledFileReference) { return; diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 16f7e5a1c8a..bf540f6a0cd 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -14,7 +14,7 @@ namespace ts { } const id = (s: SourceFile) => s; - const nullTransformers: Transformer[] = [ctx => id]; + const nullTransformers: Transformer[] = [_ctx => id]; // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature export function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFile: SourceFile, emitOnlyDtsFiles?: boolean): EmitResult { @@ -593,7 +593,7 @@ const _super = (function (geti, seti) { case SyntaxKind.ExpressionWithTypeArguments: return emitExpressionWithTypeArguments(node); case SyntaxKind.ThisType: - return emitThisType(node); + return emitThisType(); case SyntaxKind.LiteralType: return emitLiteralType(node); @@ -609,7 +609,7 @@ const _super = (function (geti, seti) { case SyntaxKind.TemplateSpan: return emitTemplateSpan(node); case SyntaxKind.SemicolonClassElement: - return emitSemicolonClassElement(node); + return emitSemicolonClassElement(); // Statements case SyntaxKind.Block: @@ -617,7 +617,7 @@ const _super = (function (geti, seti) { case SyntaxKind.VariableStatement: return emitVariableStatement(node); case SyntaxKind.EmptyStatement: - return emitEmptyStatement(node); + return emitEmptyStatement(); case SyntaxKind.ExpressionStatement: return emitExpressionStatement(node); case SyntaxKind.IfStatement: @@ -1014,7 +1014,7 @@ const _super = (function (geti, seti) { write(";"); } - function emitSemicolonClassElement(node: SemicolonClassElement) { + function emitSemicolonClassElement() { write(";"); } @@ -1084,7 +1084,7 @@ const _super = (function (geti, seti) { write(")"); } - function emitThisType(node: ThisTypeNode) { + function emitThisType() { write("this"); } @@ -1397,7 +1397,7 @@ const _super = (function (geti, seti) { // Statements // - function emitBlock(node: Block, format?: ListFormat) { + function emitBlock(node: Block) { if (isSingleLineEmptyBlock(node)) { writeToken(SyntaxKind.OpenBraceToken, node.pos, /*contextNode*/ node); write(" "); @@ -1425,7 +1425,7 @@ const _super = (function (geti, seti) { write(";"); } - function emitEmptyStatement(node: EmptyStatement) { + function emitEmptyStatement() { write(";"); } @@ -1623,13 +1623,13 @@ const _super = (function (geti, seti) { if (getEmitFlags(node) & EmitFlags.ReuseTempVariableScope) { emitSignatureHead(node); - emitBlockFunctionBody(node, body); + emitBlockFunctionBody(body); } else { const savedTempFlags = tempFlags; tempFlags = 0; emitSignatureHead(node); - emitBlockFunctionBody(node, body); + emitBlockFunctionBody(body); tempFlags = savedTempFlags; } @@ -1656,7 +1656,7 @@ const _super = (function (geti, seti) { emitWithPrefix(": ", node.type); } - function shouldEmitBlockFunctionBodyOnSingleLine(parentNode: Node, body: Block) { + function shouldEmitBlockFunctionBodyOnSingleLine(body: Block) { // We must emit a function body as a single-line body in the following case: // * The body has NodeEmitFlags.SingleLine specified. @@ -1694,12 +1694,12 @@ const _super = (function (geti, seti) { return true; } - function emitBlockFunctionBody(parentNode: Node, body: Block) { + function emitBlockFunctionBody(body: Block) { write(" {"); increaseIndent(); emitBodyWithDetachedComments(body, body.statements, - shouldEmitBlockFunctionBodyOnSingleLine(parentNode, body) + shouldEmitBlockFunctionBodyOnSingleLine(body) ? emitBlockFunctionBodyOnSingleLine : emitBlockFunctionBodyWorker); diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index 4ebdc59e6dd..ba1f8497559 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -5,7 +5,7 @@ namespace ts { /* @internal */ export function trace(host: ModuleResolutionHost, message: DiagnosticMessage, ...args: any[]): void; - export function trace(host: ModuleResolutionHost, message: DiagnosticMessage): void { + export function trace(host: ModuleResolutionHost, _message: DiagnosticMessage): void { host.trace(formatMessage.apply(undefined, arguments)); } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 62ae61e4cb4..5481dc657b8 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -575,7 +575,7 @@ namespace ts { export function parseSourceFile(fileName: string, _sourceText: string, languageVersion: ScriptTarget, _syntaxCursor: IncrementalParser.SyntaxCursor, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile { scriptKind = ensureScriptKind(fileName, scriptKind); - initializeState(fileName, _sourceText, languageVersion, _syntaxCursor, scriptKind); + initializeState(_sourceText, languageVersion, _syntaxCursor, scriptKind); const result = parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind); @@ -589,7 +589,7 @@ namespace ts { return scriptKind === ScriptKind.TSX || scriptKind === ScriptKind.JSX || scriptKind === ScriptKind.JS ? LanguageVariant.JSX : LanguageVariant.Standard; } - function initializeState(fileName: string, _sourceText: string, languageVersion: ScriptTarget, _syntaxCursor: IncrementalParser.SyntaxCursor, scriptKind: ScriptKind) { + function initializeState(_sourceText: string, languageVersion: ScriptTarget, _syntaxCursor: IncrementalParser.SyntaxCursor, scriptKind: ScriptKind) { NodeConstructor = objectAllocator.getNodeConstructor(); TokenConstructor = objectAllocator.getTokenConstructor(); IdentifierConstructor = objectAllocator.getIdentifierConstructor(); @@ -5259,7 +5259,7 @@ namespace ts { parseExpected(SyntaxKind.ClassKeyword); node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); - node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ true); + node.heritageClauses = parseHeritageClauses(); if (parseExpected(SyntaxKind.OpenBraceToken)) { // ClassTail[Yield,Await] : (Modified) See 14.5 @@ -5289,7 +5289,7 @@ namespace ts { return token() === SyntaxKind.ImplementsKeyword && lookAhead(nextTokenIsIdentifierOrKeyword); } - function parseHeritageClauses(isClassHeritageClause: boolean): NodeArray { + function parseHeritageClauses(): NodeArray { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } @@ -5337,7 +5337,7 @@ namespace ts { parseExpected(SyntaxKind.InterfaceKeyword); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ false); + node.heritageClauses = parseHeritageClauses(); node.members = parseObjectTypeMembers(); return addJSDocComment(finishNode(node)); } @@ -5817,7 +5817,7 @@ namespace ts { } export function parseJSDocTypeExpressionForTests(content: string, start: number, length: number) { - initializeState("file.js", content, ScriptTarget.Latest, /*_syntaxCursor:*/ undefined, ScriptKind.JS); + initializeState(content, ScriptTarget.Latest, /*_syntaxCursor:*/ undefined, ScriptKind.JS); sourceFile = createSourceFile("file.js", ScriptTarget.Latest, ScriptKind.JS); scanner.setText(content, start, length); currentToken = scanner.scan(); @@ -6134,7 +6134,7 @@ namespace ts { } export function parseIsolatedJSDocComment(content: string, start: number, length: number) { - initializeState("file.js", content, ScriptTarget.Latest, /*_syntaxCursor:*/ undefined, ScriptKind.JS); + initializeState(content, ScriptTarget.Latest, /*_syntaxCursor:*/ undefined, ScriptKind.JS); sourceFile = { languageVariant: LanguageVariant.Standard, text: content }; const jsDoc = parseJSDocCommentWorker(start, length); const diagnostics = parseDiagnostics; diff --git a/src/compiler/performance.ts b/src/compiler/performance.ts index e8f064e81cd..a48eb117e28 100644 --- a/src/compiler/performance.ts +++ b/src/compiler/performance.ts @@ -12,7 +12,7 @@ namespace ts.performance { const profilerEvent = typeof onProfilerEvent === "function" && onProfilerEvent.profiler === true ? onProfilerEvent - : (markName: string) => { }; + : (_markName: string) => { }; let enabled = false; let profilerStart = 0; diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 06e9f6f30f1..b34791b7198 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -724,7 +724,7 @@ namespace ts { } } - function getSyntacticDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { + function getSyntacticDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] { return sourceFile.parseDiagnostics; } @@ -761,7 +761,7 @@ namespace ts { // Instead, we just report errors for using TypeScript-only constructs from within a // JavaScript file. const checkDiagnostics = isSourceFileJavaScript(sourceFile) ? - getJavaScriptSemanticDiagnosticsForFile(sourceFile, cancellationToken) : + getJavaScriptSemanticDiagnosticsForFile(sourceFile) : typeChecker.getDiagnostics(sourceFile, cancellationToken); const fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); const programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); @@ -770,7 +770,7 @@ namespace ts { }); } - function getJavaScriptSemanticDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { + function getJavaScriptSemanticDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] { return runWithCancellationToken(() => { const diagnostics: Diagnostic[] = []; walk(sourceFile); @@ -977,7 +977,7 @@ namespace ts { } function processRootFile(fileName: string, isDefaultLib: boolean) { - processSourceFile(normalizePath(fileName), isDefaultLib, /*isReference*/ true); + processSourceFile(normalizePath(fileName), isDefaultLib); } function fileReferenceIsEqualTo(a: FileReference, b: FileReference): boolean { @@ -1088,7 +1088,7 @@ namespace ts { /** * 'isReference' indicates whether the file was brought in via a reference directive (rather than an import declaration) */ - function processSourceFile(fileName: string, isDefaultLib: boolean, isReference: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number) { + function processSourceFile(fileName: string, isDefaultLib: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number) { let diagnosticArgument: string[]; let diagnostic: DiagnosticMessage; if (hasExtension(fileName)) { @@ -1096,7 +1096,7 @@ namespace ts { diagnostic = Diagnostics.File_0_has_unsupported_extension_The_only_supported_extensions_are_1; diagnosticArgument = [fileName, "'" + supportedExtensions.join("', '") + "'"]; } - else if (!findSourceFile(fileName, toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, isReference, refFile, refPos, refEnd)) { + else if (!findSourceFile(fileName, toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd)) { diagnostic = Diagnostics.File_0_not_found; diagnosticArgument = [fileName]; } @@ -1106,13 +1106,13 @@ namespace ts { } } else { - const nonTsFile: SourceFile = options.allowNonTsExtensions && findSourceFile(fileName, toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, isReference, refFile, refPos, refEnd); + const nonTsFile: SourceFile = options.allowNonTsExtensions && findSourceFile(fileName, toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd); if (!nonTsFile) { if (options.allowNonTsExtensions) { diagnostic = Diagnostics.File_0_not_found; diagnosticArgument = [fileName]; } - else if (!forEach(supportedExtensions, extension => findSourceFile(fileName + extension, toPath(fileName + extension, currentDirectory, getCanonicalFileName), isDefaultLib, isReference, refFile, refPos, refEnd))) { + else if (!forEach(supportedExtensions, extension => findSourceFile(fileName + extension, toPath(fileName + extension, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd))) { diagnostic = Diagnostics.File_0_not_found; fileName += ".ts"; diagnosticArgument = [fileName]; @@ -1141,7 +1141,7 @@ namespace ts { } // Get source file from normalized fileName - function findSourceFile(fileName: string, path: Path, isDefaultLib: boolean, isReference: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number): SourceFile { + function findSourceFile(fileName: string, path: Path, isDefaultLib: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number): SourceFile { if (filesByName.contains(path)) { const file = filesByName.get(path); // try to check if we've already seen this file but with a different casing in path @@ -1155,18 +1155,18 @@ namespace ts { if (file && sourceFilesFoundSearchingNodeModules[file.path] && currentNodeModulesDepth == 0) { sourceFilesFoundSearchingNodeModules[file.path] = false; if (!options.noResolve) { - processReferencedFiles(file, getDirectoryPath(fileName), isDefaultLib); + processReferencedFiles(file, isDefaultLib); processTypeReferenceDirectives(file); } modulesWithElidedImports[file.path] = false; - processImportedModules(file, getDirectoryPath(fileName)); + processImportedModules(file); } // See if we need to reprocess the imports due to prior skipped imports else if (file && modulesWithElidedImports[file.path]) { if (currentNodeModulesDepth < maxNodeModulesJsDepth) { modulesWithElidedImports[file.path] = false; - processImportedModules(file, getDirectoryPath(fileName)); + processImportedModules(file); } } @@ -1202,14 +1202,13 @@ namespace ts { skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; - const basePath = getDirectoryPath(fileName); if (!options.noResolve) { - processReferencedFiles(file, basePath, isDefaultLib); + processReferencedFiles(file, isDefaultLib); processTypeReferenceDirectives(file); } // always process imported modules to record module name resolutions - processImportedModules(file, basePath); + processImportedModules(file); if (isDefaultLib) { files.unshift(file); @@ -1222,10 +1221,10 @@ namespace ts { return file; } - function processReferencedFiles(file: SourceFile, basePath: string, isDefaultLib: boolean) { + function processReferencedFiles(file: SourceFile, isDefaultLib: boolean) { forEach(file.referencedFiles, ref => { const referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName); - processSourceFile(referencedFileName, isDefaultLib, /*isReference*/ true, file, ref.pos, ref.end); + processSourceFile(referencedFileName, isDefaultLib, file, ref.pos, ref.end); }); } @@ -1256,7 +1255,7 @@ namespace ts { if (resolvedTypeReferenceDirective) { if (resolvedTypeReferenceDirective.primary) { // resolved from the primary path - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*isReference*/ true, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, refFile, refPos, refEnd); } else { // If we already resolved to this file, it must have been a secondary reference. Check file contents @@ -1276,7 +1275,7 @@ namespace ts { } else { // First resolution of this library - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*isReference*/ true, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, refFile, refPos, refEnd); } } } @@ -1302,7 +1301,7 @@ namespace ts { return host.getCanonicalFileName(fileName); } - function processImportedModules(file: SourceFile, basePath: string) { + function processImportedModules(file: SourceFile) { collectExternalModuleReferences(file); if (file.imports.length || file.moduleAugmentations.length) { file.resolvedModules = createMap(); @@ -1333,7 +1332,7 @@ namespace ts { else if (shouldAddFile) { findSourceFile(resolution.resolvedFileName, toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), - /*isDefaultLib*/ false, /*isReference*/ false, + /*isDefaultLib*/ false, file, skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); @@ -1541,7 +1540,7 @@ namespace ts { if (!options.noEmit && !options.suppressOutputPathCheck) { const emitHost = getEmitHost(); const emitFilesSeen = createFileMap(!host.useCaseSensitiveFileNames() ? key => key.toLocaleLowerCase() : undefined); - forEachExpectedEmitFile(emitHost, (emitFileNames, sourceFiles, isBundledEmit) => { + forEachExpectedEmitFile(emitHost, (emitFileNames) => { verifyEmitFilePath(emitFileNames.jsFilePath, emitFilesSeen); verifyEmitFilePath(emitFileNames.declarationFilePath, emitFilesSeen); }); @@ -1553,13 +1552,13 @@ namespace ts { const emitFilePath = toPath(emitFileName, currentDirectory, getCanonicalFileName); // Report error if the output overwrites input file if (filesByName.contains(emitFilePath)) { - createEmitBlockingDiagnostics(emitFileName, emitFilePath, Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file); + createEmitBlockingDiagnostics(emitFileName, Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file); } // Report error if multiple files write into same file if (emitFilesSeen.contains(emitFilePath)) { // Already seen the same emit file - report error - createEmitBlockingDiagnostics(emitFileName, emitFilePath, Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files); + createEmitBlockingDiagnostics(emitFileName, Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files); } else { emitFilesSeen.set(emitFilePath, true); @@ -1568,7 +1567,7 @@ namespace ts { } } - function createEmitBlockingDiagnostics(emitFileName: string, emitFilePath: Path, message: DiagnosticMessage) { + function createEmitBlockingDiagnostics(emitFileName: string, message: DiagnosticMessage) { hasEmitBlockingDiagnostics.set(toPath(emitFileName, currentDirectory, getCanonicalFileName), true); programDiagnostics.add(createCompilerDiagnostic(message, emitFileName)); } diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index b79106766da..ab76c7ffa19 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -723,7 +723,7 @@ namespace ts { return iterateCommentRanges(/*reduce*/ true, text, pos, /*trailing*/ true, cb, state, initial); } - function appendCommentRange(pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: any, comments: CommentRange[]) { + function appendCommentRange(pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, _state: any, comments: CommentRange[]) { if (!comments) { comments = []; } diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 1efa1e2b010..bb945824b4d 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -46,13 +46,9 @@ namespace ts { } declare var require: any; - declare var module: any; declare var process: any; declare var global: any; declare var __filename: string; - declare var Buffer: { - new (str: string, encoding?: string): any; - }; declare class Enumerator { public atEnd(): boolean; @@ -324,7 +320,7 @@ namespace ts { const platform: string = _os.platform(); const useCaseSensitiveFileNames = isFileSystemCaseSensitive(); - function readFile(fileName: string, encoding?: string): string { + function readFile(fileName: string, _encoding?: string): string { if (!fileExists(fileName)) { return undefined; } @@ -576,7 +572,7 @@ namespace ts { args: ChakraHost.args, useCaseSensitiveFileNames: !!ChakraHost.useCaseSensitiveFileNames, write: ChakraHost.echo, - readFile(path: string, encoding?: string) { + readFile(path: string, _encoding?: string) { // encoding is automatically handled by the implementation in ChakraHost return ChakraHost.readFile(path); }, @@ -595,9 +591,9 @@ namespace ts { getExecutingFilePath: () => ChakraHost.executingFile, getCurrentDirectory: () => ChakraHost.currentDirectory, getDirectories: ChakraHost.getDirectories, - getEnvironmentVariable: ChakraHost.getEnvironmentVariable || ((name: string) => ""), + getEnvironmentVariable: ChakraHost.getEnvironmentVariable || ((_name: string) => ""), readDirectory: (path: string, extensions?: string[], excludes?: string[], includes?: string[]) => { - const pattern = getFileMatcherPatterns(path, extensions, excludes, includes, !!ChakraHost.useCaseSensitiveFileNames, ChakraHost.currentDirectory); + const pattern = getFileMatcherPatterns(path, excludes, includes, !!ChakraHost.useCaseSensitiveFileNames, ChakraHost.currentDirectory); return ChakraHost.readDirectory(path, extensions, pattern.basePaths, pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern); }, exit: ChakraHost.quit, diff --git a/src/compiler/transformer.ts b/src/compiler/transformer.ts index e1e83a6b850..b27c8f6e79f 100644 --- a/src/compiler/transformer.ts +++ b/src/compiler/transformer.ts @@ -165,7 +165,7 @@ namespace ts { hoistFunctionDeclaration, startLexicalEnvironment, endLexicalEnvironment, - onSubstituteNode: (emitContext, node) => node, + onSubstituteNode: (_emitContext, node) => node, enableSubstitution, isSubstitutionEnabled, onEmitNode: (node, emitContext, emitCallback) => emitCallback(node, emitContext), diff --git a/src/compiler/transformers/destructuring.ts b/src/compiler/transformers/destructuring.ts index c7219866df7..3eaa1b764a9 100644 --- a/src/compiler/transformers/destructuring.ts +++ b/src/compiler/transformers/destructuring.ts @@ -51,7 +51,7 @@ namespace ts { location = value; } - flattenDestructuring(context, node, value, location, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, location, emitAssignment, emitTempVariableAssignment, visitor); if (needsValue) { expressions.push(value); @@ -87,13 +87,12 @@ namespace ts { * @param visitor An optional visitor to use to visit expressions. */ export function flattenParameterDestructuring( - context: TransformationContext, node: ParameterDeclaration, value: Expression, visitor?: (node: Node) => VisitResult) { const declarations: VariableDeclaration[] = []; - flattenDestructuring(context, node, value, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, visitor); return declarations; @@ -123,7 +122,6 @@ namespace ts { * @param visitor An optional visitor to use to visit expressions. */ export function flattenVariableDestructuring( - context: TransformationContext, node: VariableDeclaration, value?: Expression, visitor?: (node: Node) => VisitResult, @@ -131,7 +129,7 @@ namespace ts { const declarations: VariableDeclaration[] = []; let pendingAssignments: Expression[]; - flattenDestructuring(context, node, value, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, visitor); return declarations; @@ -180,7 +178,6 @@ namespace ts { * @param visitor An optional visitor to use to visit expressions. */ export function flattenVariableDestructuringToExpression( - context: TransformationContext, node: VariableDeclaration, recordTempVariable: (name: Identifier) => void, nameSubstitution?: (name: Identifier) => Expression, @@ -188,7 +185,7 @@ namespace ts { const pendingAssignments: Expression[] = []; - flattenDestructuring(context, node, /*value*/ undefined, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, /*value*/ undefined, node, emitAssignment, emitTempVariableAssignment, visitor); const expression = inlineExpressions(pendingAssignments); aggregateTransformFlags(expression); @@ -219,7 +216,6 @@ namespace ts { } function flattenDestructuring( - context: TransformationContext, root: VariableDeclaration | ParameterDeclaration | BindingElement | BinaryExpression, value: Expression, location: TextRange, diff --git a/src/compiler/transformers/es2015.ts b/src/compiler/transformers/es2015.ts index bb2e8ac2aa5..9972f339c16 100644 --- a/src/compiler/transformers/es2015.ts +++ b/src/compiler/transformers/es2015.ts @@ -396,7 +396,7 @@ namespace ts { return visitYieldExpression(node); case SyntaxKind.SuperKeyword: - return visitSuperKeyword(node); + return visitSuperKeyword(); case SyntaxKind.YieldExpression: // `yield` will be handled by a generators transform. @@ -1118,7 +1118,7 @@ namespace ts { createVariableStatement( /*modifiers*/ undefined, createVariableDeclarationList( - flattenParameterDestructuring(context, parameter, temp, visitor) + flattenParameterDestructuring(parameter, temp, visitor) ) ), EmitFlags.CustomPrologue @@ -1690,7 +1690,7 @@ namespace ts { if (decl.initializer) { let assignment: Expression; if (isBindingPattern(decl.name)) { - assignment = flattenVariableDestructuringToExpression(context, decl, hoistVariableDeclaration, /*nameSubstitution*/ undefined, visitor); + assignment = flattenVariableDestructuringToExpression(decl, hoistVariableDeclaration, /*nameSubstitution*/ undefined, visitor); } else { assignment = createBinary(decl.name, SyntaxKind.EqualsToken, visitNode(decl.initializer, visitor, isExpression)); @@ -1843,7 +1843,7 @@ namespace ts { if (isBindingPattern(node.name)) { const recordTempVariablesInLine = !enclosingVariableStatement || !hasModifier(enclosingVariableStatement, ModifierFlags.Export); - return flattenVariableDestructuring(context, node, /*value*/ undefined, visitor, + return flattenVariableDestructuring(node, /*value*/ undefined, visitor, recordTempVariablesInLine ? undefined : hoistVariableDeclaration); } @@ -1946,7 +1946,6 @@ namespace ts { // This works whether the declaration is a var, let, or const. // It will use rhsIterationValue _a[_i] as the initializer. const declarations = flattenVariableDestructuring( - context, firstOriginalDeclaration, createElementAccess(rhsReference, counter), visitor @@ -2539,15 +2538,15 @@ namespace ts { break; case SyntaxKind.PropertyAssignment: - expressions.push(transformPropertyAssignmentToExpression(node, property, receiver, node.multiLine)); + expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; case SyntaxKind.ShorthandPropertyAssignment: - expressions.push(transformShorthandPropertyAssignmentToExpression(node, property, receiver, node.multiLine)); + expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; case SyntaxKind.MethodDeclaration: - expressions.push(transformObjectLiteralMethodDeclarationToExpression(node, property, receiver, node.multiLine)); + expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node.multiLine)); break; default: @@ -2564,7 +2563,7 @@ namespace ts { * @param property The PropertyAssignment node. * @param receiver The receiver for the assignment. */ - function transformPropertyAssignmentToExpression(node: ObjectLiteralExpression, property: PropertyAssignment, receiver: Expression, startsOnNewLine: boolean) { + function transformPropertyAssignmentToExpression(property: PropertyAssignment, receiver: Expression, startsOnNewLine: boolean) { const expression = createAssignment( createMemberAccessForPropertyName( receiver, @@ -2586,7 +2585,7 @@ namespace ts { * @param property The ShorthandPropertyAssignment node. * @param receiver The receiver for the assignment. */ - function transformShorthandPropertyAssignmentToExpression(node: ObjectLiteralExpression, property: ShorthandPropertyAssignment, receiver: Expression, startsOnNewLine: boolean) { + function transformShorthandPropertyAssignmentToExpression(property: ShorthandPropertyAssignment, receiver: Expression, startsOnNewLine: boolean) { const expression = createAssignment( createMemberAccessForPropertyName( receiver, @@ -2608,7 +2607,7 @@ namespace ts { * @param method The MethodDeclaration node. * @param receiver The receiver for the assignment. */ - function transformObjectLiteralMethodDeclarationToExpression(node: ObjectLiteralExpression, method: MethodDeclaration, receiver: Expression, startsOnNewLine: boolean) { + function transformObjectLiteralMethodDeclarationToExpression(method: MethodDeclaration, receiver: Expression, startsOnNewLine: boolean) { const expression = createAssignment( createMemberAccessForPropertyName( receiver, @@ -2798,7 +2797,7 @@ namespace ts { // expressions into an array literal. const numElements = elements.length; const segments = flatten( - spanMap(elements, partitionSpreadElement, (partition, visitPartition, start, end) => + spanMap(elements, partitionSpreadElement, (partition, visitPartition, _start, end) => visitPartition(partition, multiLine, hasTrailingComma && end === numElements) ) ); @@ -2820,7 +2819,7 @@ namespace ts { : visitSpanOfNonSpreadElements; } - function visitSpanOfSpreadElements(chunk: Expression[], multiLine: boolean, hasTrailingComma: boolean): VisitResult { + function visitSpanOfSpreadElements(chunk: Expression[]): VisitResult { return map(chunk, visitExpressionOfSpreadElement); } @@ -3009,7 +3008,7 @@ namespace ts { /** * Visits the `super` keyword */ - function visitSuperKeyword(node: PrimaryExpression): LeftHandSideExpression { + function visitSuperKeyword(): LeftHandSideExpression { return enclosingNonAsyncFunctionBody && isClassElement(enclosingNonAsyncFunctionBody) && !hasModifier(enclosingNonAsyncFunctionBody, ModifierFlags.Static) diff --git a/src/compiler/transformers/generators.ts b/src/compiler/transformers/generators.ts index aaf9014c5cc..200e5ec7296 100644 --- a/src/compiler/transformers/generators.ts +++ b/src/compiler/transformers/generators.ts @@ -956,7 +956,7 @@ namespace ts { * @param elements The elements to visit. * @param multiLine Whether array literals created should be emitted on multiple lines. */ - function visitElements(elements: NodeArray, multiLine: boolean) { + function visitElements(elements: NodeArray, _multiLine?: boolean) { // [source] // ar = [1, yield, 2]; // @@ -1102,7 +1102,7 @@ namespace ts { createFunctionApply( cacheExpression(visitNode(target, visitor, isLeftHandSideExpression)), thisArg, - visitElements(node.arguments, /*multiLine*/ false), + visitElements(node.arguments), /*location*/ node ), node @@ -1131,7 +1131,7 @@ namespace ts { createFunctionApply( cacheExpression(visitNode(target, visitor, isExpression)), thisArg, - visitElements(node.arguments, /*multiLine*/ false) + visitElements(node.arguments) ), /*typeArguments*/ undefined, [], diff --git a/src/compiler/transformers/module/es2015.ts b/src/compiler/transformers/module/es2015.ts index 23fb444b6ff..93aa108617a 100644 --- a/src/compiler/transformers/module/es2015.ts +++ b/src/compiler/transformers/module/es2015.ts @@ -22,7 +22,8 @@ namespace ts { function visitor(node: Node): VisitResult { switch (node.kind) { case SyntaxKind.ImportEqualsDeclaration: - return visitImportEqualsDeclaration(node); + // Elide `import=` as it is not legal with --module ES6 + return undefined; case SyntaxKind.ExportAssignment: return visitExportAssignment(node); } @@ -30,11 +31,6 @@ namespace ts { return node; } - function visitImportEqualsDeclaration(node: ImportEqualsDeclaration): VisitResult { - // Elide `import=` as it is not legal with --module ES6 - return undefined; - } - function visitExportAssignment(node: ExportAssignment): VisitResult { // Elide `export=` as it is not legal with --module ES6 return node.isExportEquals ? undefined : node; diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index 1cca7a21777..1f56670c932 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -680,7 +680,6 @@ namespace ts { const name = node.name; if (isBindingPattern(name)) { return flattenVariableDestructuringToExpression( - context, node, hoistVariableDeclaration, getModuleMemberName, diff --git a/src/compiler/transformers/module/system.ts b/src/compiler/transformers/module/system.ts index 775d8fc34f9..61f2d5c0509 100644 --- a/src/compiler/transformers/module/system.ts +++ b/src/compiler/transformers/module/system.ts @@ -646,7 +646,7 @@ namespace ts { } else { // If the variable has a BindingPattern, flatten the variable into multiple assignment expressions. - return flattenVariableDestructuringToExpression(context, node, hoistVariableDeclaration); + return flattenVariableDestructuringToExpression(node, hoistVariableDeclaration); } } @@ -795,7 +795,7 @@ namespace ts { const name = firstDeclaration.name; return isIdentifier(name) ? name - : flattenVariableDestructuringToExpression(context, firstDeclaration, hoistVariableDeclaration); + : flattenVariableDestructuringToExpression(firstDeclaration, hoistVariableDeclaration); } /** diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index a1190efee10..925869da385 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -580,7 +580,7 @@ namespace ts { // HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using // a lexical declaration such as a LexicalDeclaration or a ClassDeclaration. if (staticProperties.length) { - addInitializedPropertyStatements(statements, node, staticProperties, getLocalName(node, /*noSourceMaps*/ true)); + addInitializedPropertyStatements(statements, staticProperties, getLocalName(node, /*noSourceMaps*/ true)); } // Write any decorators of the node. @@ -822,7 +822,7 @@ namespace ts { // the body of a class with static initializers. setEmitFlags(classExpression, EmitFlags.Indented | getEmitFlags(classExpression)); expressions.push(startOnNewLine(createAssignment(temp, classExpression))); - addRange(expressions, generateInitializedPropertyExpressions(node, staticProperties, temp)); + addRange(expressions, generateInitializedPropertyExpressions(staticProperties, temp)); expressions.push(startOnNewLine(temp)); return inlineExpressions(expressions); } @@ -868,7 +868,7 @@ namespace ts { } const parameters = transformConstructorParameters(constructor); - const body = transformConstructorBody(node, constructor, hasExtendsClause, parameters); + const body = transformConstructorBody(node, constructor, hasExtendsClause); // constructor(${parameters}) { // ${body} @@ -922,9 +922,8 @@ namespace ts { * @param node The current class. * @param constructor The current class constructor. * @param hasExtendsClause A value indicating whether the class has an extends clause. - * @param parameters The transformed parameters for the constructor. */ - function transformConstructorBody(node: ClassExpression | ClassDeclaration, constructor: ConstructorDeclaration, hasExtendsClause: boolean, parameters: ParameterDeclaration[]) { + function transformConstructorBody(node: ClassExpression | ClassDeclaration, constructor: ConstructorDeclaration, hasExtendsClause: boolean) { const statements: Statement[] = []; let indexOfFirstStatement = 0; @@ -976,7 +975,7 @@ namespace ts { // } // const properties = getInitializedProperties(node, /*isStatic*/ false); - addInitializedPropertyStatements(statements, node, properties, createThis()); + addInitializedPropertyStatements(statements, properties, createThis()); if (constructor) { // The class already had a constructor, so we should add the existing statements, skipping the initial super call. @@ -1116,13 +1115,12 @@ namespace ts { /** * Generates assignment statements for property initializers. * - * @param node The class node. * @param properties An array of property declarations to transform. * @param receiver The receiver on which each property should be assigned. */ - function addInitializedPropertyStatements(statements: Statement[], node: ClassExpression | ClassDeclaration, properties: PropertyDeclaration[], receiver: LeftHandSideExpression) { + function addInitializedPropertyStatements(statements: Statement[], properties: PropertyDeclaration[], receiver: LeftHandSideExpression) { for (const property of properties) { - const statement = createStatement(transformInitializedProperty(node, property, receiver)); + const statement = createStatement(transformInitializedProperty(property, receiver)); setSourceMapRange(statement, moveRangePastModifiers(property)); setCommentRange(statement, property); statements.push(statement); @@ -1132,14 +1130,13 @@ namespace ts { /** * Generates assignment expressions for property initializers. * - * @param node The class node. * @param properties An array of property declarations to transform. * @param receiver The receiver on which each property should be assigned. */ - function generateInitializedPropertyExpressions(node: ClassExpression | ClassDeclaration, properties: PropertyDeclaration[], receiver: LeftHandSideExpression) { + function generateInitializedPropertyExpressions(properties: PropertyDeclaration[], receiver: LeftHandSideExpression) { const expressions: Expression[] = []; for (const property of properties) { - const expression = transformInitializedProperty(node, property, receiver); + const expression = transformInitializedProperty(property, receiver); expression.startsOnNewLine = true; setSourceMapRange(expression, moveRangePastModifiers(property)); setCommentRange(expression, property); @@ -1152,11 +1149,10 @@ namespace ts { /** * Transforms a property initializer into an assignment statement. * - * @param node The class containing the property. * @param property The property declaration. * @param receiver The object receiving the property assignment. */ - function transformInitializedProperty(node: ClassExpression | ClassDeclaration, property: PropertyDeclaration, receiver: LeftHandSideExpression) { + function transformInitializedProperty(property: PropertyDeclaration, receiver: LeftHandSideExpression) { const propertyName = visitPropertyNameOfClassElement(property); const initializer = visitNode(property.initializer, visitor, isExpression); const memberAccess = createMemberAccessForPropertyName(receiver, propertyName, /*location*/ propertyName); @@ -2423,7 +2419,6 @@ namespace ts { const name = node.name; if (isBindingPattern(name)) { return flattenVariableDestructuringToExpression( - context, node, hoistVariableDeclaration, getNamespaceMemberNameWithSourceMapsAndWithoutComments, diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index b39c017384e..aa277c9b507 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -29,7 +29,7 @@ namespace ts { } } - function reportEmittedFiles(files: string[], host: CompilerHost): void { + function reportEmittedFiles(files: string[]): void { if (!files || files.length == 0) { return; } @@ -111,7 +111,7 @@ namespace ts { return count; } - function getDiagnosticText(message: DiagnosticMessage, ...args: any[]): string { + function getDiagnosticText(_message: DiagnosticMessage, ..._args: any[]): string { const diagnostic = createCompilerDiagnostic.apply(undefined, arguments); return diagnostic.messageText; } @@ -456,7 +456,7 @@ namespace ts { const sourceFile = hostGetSourceFile(fileName, languageVersion, onError); if (sourceFile && isWatchSet(compilerOptions) && sys.watchFile) { // Attach a file watcher - sourceFile.fileWatcher = sys.watchFile(sourceFile.fileName, (fileName: string, removed?: boolean) => sourceFileChanged(sourceFile, removed)); + sourceFile.fileWatcher = sys.watchFile(sourceFile.fileName, (_fileName: string, removed?: boolean) => sourceFileChanged(sourceFile, removed)); } return sourceFile; } @@ -617,7 +617,7 @@ namespace ts { reportDiagnostics(sortAndDeduplicateDiagnostics(diagnostics), compilerHost); - reportEmittedFiles(emitOutput.emittedFiles, compilerHost); + reportEmittedFiles(emitOutput.emittedFiles); if (emitOutput.emitSkipped && diagnostics.length > 0) { // If the emitter didn't emit anything, then pass that value along. diff --git a/src/compiler/tsconfig.json b/src/compiler/tsconfig.json index 65ba20f18d2..a6c03d1b680 100644 --- a/src/compiler/tsconfig.json +++ b/src/compiler/tsconfig.json @@ -9,7 +9,9 @@ "sourceMap": true, "declaration": true, "stripInternal": true, - "target": "es5" + "target": "es5", + "noUnusedLocals": true, + "noUnusedParameters": true }, "files": [ "core.ts", diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index efdac40c287..55374a1cd74 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -2566,7 +2566,7 @@ namespace ts { const options = host.getCompilerOptions(); // Emit on each source file if (options.outFile || options.out) { - onBundledEmit(host, sourceFiles); + onBundledEmit(sourceFiles); } else { for (const sourceFile of sourceFiles) { @@ -2599,7 +2599,7 @@ namespace ts { action(jsFilePath, sourceMapFilePath, declarationFilePath, [sourceFile], /*isBundledEmit*/ false); } - function onBundledEmit(host: EmitHost, sourceFiles: SourceFile[]) { + function onBundledEmit(sourceFiles: SourceFile[]) { if (sourceFiles.length) { const jsFilePath = options.outFile || options.out; const sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index 8dca78fec97..5c152c88e47 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -1331,18 +1331,18 @@ namespace ts { export namespace Debug { export const failNotOptional = shouldAssert(AssertionLevel.Normal) ? (message?: string) => assert(false, message || "Node not optional.") - : (message?: string) => {}; + : () => {}; export const failBadSyntaxKind = shouldAssert(AssertionLevel.Normal) ? (node: Node, message?: string) => assert(false, message || "Unexpected node.", () => `Node ${formatSyntaxKind(node.kind)} was unexpected.`) - : (node: Node, message?: string) => {}; + : () => {}; export const assertNode = shouldAssert(AssertionLevel.Normal) ? (node: Node, test: (node: Node) => boolean, message?: string) => assert( test === undefined || test(node), message || "Unexpected node.", () => `Node ${formatSyntaxKind(node.kind)} did not pass test '${getFunctionName(test)}'.`) - : (node: Node, test: (node: Node) => boolean, message?: string) => {}; + : () => {}; function getFunctionName(func: Function) { if (typeof func !== "function") { diff --git a/src/services/shims.ts b/src/services/shims.ts index 7ed1786640d..571f009d866 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -444,7 +444,7 @@ namespace ts { } public readDirectory(path: string, extensions?: string[], exclude?: string[], include?: string[], depth?: number): string[] { - const pattern = getFileMatcherPatterns(path, extensions, exclude, include, + const pattern = getFileMatcherPatterns(path, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); return JSON.parse(this.shimHost.readDirectory( path, @@ -509,7 +509,7 @@ namespace ts { // Wrap the API changes for 2.0 release. This try/catch // should be removed once TypeScript 2.0 has shipped. try { - const pattern = getFileMatcherPatterns(rootDir, extensions, exclude, include, + const pattern = getFileMatcherPatterns(rootDir, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); return JSON.parse(this.shimHost.readDirectory( rootDir, From dba03377b816123149046030b869baa70ae35291 Mon Sep 17 00:00:00 2001 From: Jason Ramsay Date: Tue, 18 Oct 2016 14:04:21 -0700 Subject: [PATCH 135/173] Adding JSXExpression check for isGlobalCompletion and associated tests --- src/services/completions.ts | 1 + .../fourslash/completionListIsGlobalCompletion.ts | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/services/completions.ts b/src/services/completions.ts index cd4d64b3b09..3b76fdc8c3b 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -1082,6 +1082,7 @@ namespace ts.Completions { isGlobalCompletion = scopeNode.kind === SyntaxKind.SourceFile || scopeNode.kind === SyntaxKind.TemplateExpression || + scopeNode.kind === SyntaxKind.JsxExpression || isStatement(scopeNode); } diff --git a/tests/cases/fourslash/completionListIsGlobalCompletion.ts b/tests/cases/fourslash/completionListIsGlobalCompletion.ts index 3961f4fadae..a1fadc6bb12 100644 --- a/tests/cases/fourslash/completionListIsGlobalCompletion.ts +++ b/tests/cases/fourslash/completionListIsGlobalCompletion.ts @@ -33,6 +33,7 @@ ////const y =
; // no globals in jsx attribute found ////const z =
; // no globals in jsx attribute with syntax error ////const x = `/*14*/ ${/*15*/}`; // globals only in template expression +////var user = ; // globals only in JSX expression (but not in JSX expression strings) goTo.marker("1"); verify.completionListIsGlobal(false); goTo.marker("2"); @@ -62,4 +63,12 @@ verify.completionListIsGlobal(false); goTo.marker("14"); verify.completionListIsGlobal(false); goTo.marker("15"); -verify.completionListIsGlobal(true); \ No newline at end of file +verify.completionListIsGlobal(true); +goTo.marker("16"); +verify.completionListIsGlobal(false); +goTo.marker("17"); +verify.completionListIsGlobal(false); +goTo.marker("18"); +verify.completionListIsGlobal(true); +goTo.marker("19"); +verify.completionListIsGlobal(false); \ No newline at end of file From 6a0f72916eb31ded2a011dd9dd4e701145b85d78 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 18 Oct 2016 14:13:19 -0700 Subject: [PATCH 136/173] Simplify logic in checkTypeRelatedTo --- src/compiler/checker.ts | 57 ++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 32 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 879e2dec9df..c395343ea35 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5622,7 +5622,6 @@ namespace ts { if (type.flags & TypeFlags.Union) { // We are attempting to construct a type of the form X & (A | B) & Y. Transform this into a type of // the form X & A & Y | X & B & Y and recursively reduce until no union type constituents remain. - let unionType = types[i]; return getUnionType(map((type).types, t => getIntersectionType(replaceElement(types, i, t))), /*subtypeReduction*/ false, aliasSymbol, aliasTypeArguments); } @@ -6574,7 +6573,9 @@ namespace ts { const saveErrorInfo = errorInfo; - // Note that these checks are specifically ordered to produce correct results. + // Note that these checks are specifically ordered to produce correct results. In particular, + // we need to deconstruct unions before intersections (because unions are always at the top), + // and we need to handle "each" relations before "some" relations for the same kind of type. if (source.flags & TypeFlags.Union) { if (relation === comparableRelation) { result = someTypeRelatedToType(source as UnionType, target, reportErrors && !(source.flags & TypeFlags.Primitive)); @@ -6582,44 +6583,36 @@ namespace ts { else { result = eachTypeRelatedToType(source as UnionType, target, reportErrors && !(source.flags & TypeFlags.Primitive)); } - if (result) { return result; } } + else if (target.flags & TypeFlags.Union) { + if (result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & TypeFlags.Primitive) && !(target.flags & TypeFlags.Primitive))) { + return result; + } + } else if (target.flags & TypeFlags.Intersection) { - result = typeRelatedToEachType(source, target as IntersectionType, reportErrors); - - if (result) { + if (result = typeRelatedToEachType(source, target as IntersectionType, reportErrors)) { return result; } } - else { - // It is necessary to try these "some" checks on both sides because there may be nested "each" checks - // on either side that need to be prioritized. For example, A | B = (A | B) & (C | D) or - // A & B = (A & B) | (C & D). - if (source.flags & TypeFlags.Intersection) { - // Check to see if any constituents of the intersection are immediately related to the target. - // - // Don't report errors though. Checking whether a constituent is related to the source is not actually - // useful and leads to some confusing error messages. Instead it is better to let the below checks - // take care of this, or to not elaborate at all. For instance, - // - // - For an object type (such as 'C = A & B'), users are usually more interested in structural errors. - // - // - For a union type (such as '(A | B) = (C & D)'), it's better to hold onto the whole intersection - // than to report that 'D' is not assignable to 'A' or 'B'. - // - // - For a primitive type or type parameter (such as 'number = A & B') there is no point in - // breaking the intersection apart. - if (result = someTypeRelatedToType(source, target, /*reportErrors*/ false)) { - return result; - } - } - if (target.flags & TypeFlags.Union) { - if (result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & TypeFlags.Primitive) && !(target.flags & TypeFlags.Primitive))) { - return result; - } + else if (source.flags & TypeFlags.Intersection) { + // Check to see if any constituents of the intersection are immediately related to the target. + // + // Don't report errors though. Checking whether a constituent is related to the source is not actually + // useful and leads to some confusing error messages. Instead it is better to let the below checks + // take care of this, or to not elaborate at all. For instance, + // + // - For an object type (such as 'C = A & B'), users are usually more interested in structural errors. + // + // - For a union type (such as '(A | B) = (C & D)'), it's better to hold onto the whole intersection + // than to report that 'D' is not assignable to 'A' or 'B'. + // + // - For a primitive type or type parameter (such as 'number = A & B') there is no point in + // breaking the intersection apart. + if (result = someTypeRelatedToType(source, target, /*reportErrors*/ false)) { + return result; } } From bf7f2e2999cf7f36d0f735def0ac7711f3bb2275 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 18 Oct 2016 14:13:30 -0700 Subject: [PATCH 137/173] Add tests --- .../intersectionTypeNormalization.js | 79 ++++++ .../intersectionTypeNormalization.symbols | 242 +++++++++++++++++ .../intersectionTypeNormalization.types | 246 ++++++++++++++++++ .../compiler/intersectionTypeNormalization.ts | 60 +++++ 4 files changed, 627 insertions(+) create mode 100644 tests/baselines/reference/intersectionTypeNormalization.js create mode 100644 tests/baselines/reference/intersectionTypeNormalization.symbols create mode 100644 tests/baselines/reference/intersectionTypeNormalization.types create mode 100644 tests/cases/compiler/intersectionTypeNormalization.ts diff --git a/tests/baselines/reference/intersectionTypeNormalization.js b/tests/baselines/reference/intersectionTypeNormalization.js new file mode 100644 index 00000000000..8309b17f198 --- /dev/null +++ b/tests/baselines/reference/intersectionTypeNormalization.js @@ -0,0 +1,79 @@ +//// [intersectionTypeNormalization.ts] +interface A { a: string } +interface B { b: string } +interface C { c: string } +interface D { d: string } + +// Identical ways of writing the same type +type X1 = (A | B) & (C | D); +type X2 = A & (C | D) | B & (C | D) +type X3 = A & C | A & D | B & C | B & D; + +var x: X1; +var x: X2; +var x: X3; + +interface X { x: string } +interface Y { y: string } + +// Identical ways of writing the same type +type Y1 = (A | X & Y) & (C | D); +type Y2 = A & (C | D) | X & Y & (C | D) +type Y3 = A & C | A & D | X & Y & C | X & Y & D; + +var y: Y1; +var y: Y2; +var y: Y3; + +interface M { m: string } +interface N { n: string } + +// Identical ways of writing the same type +type Z1 = (A | X & (M | N)) & (C | D); +type Z2 = A & (C | D) | X & (M | N) & (C | D) +type Z3 = A & C | A & D | X & (M | N) & C | X & (M | N) & D; +type Z4 = A & C | A & D | X & M & C | X & N & C | X & M & D | X & N & D; + +var z: Z1; +var z: Z2; +var z: Z3; +var z: Z4; + +// Repro from #9919 + +type ToString = { + toString(): string; +} + +type BoxedValue = { kind: 'int', num: number } + | { kind: 'string', str: string } + +type IntersectionFail = BoxedValue & ToString + +type IntersectionInline = { kind: 'int', num: number } & ToString + | { kind: 'string', str: string } & ToString + +function getValueAsString(value: IntersectionFail): string { + if (value.kind === 'int') { + return '' + value.num; + } + return value.str; +} + +//// [intersectionTypeNormalization.js] +var x; +var x; +var x; +var y; +var y; +var y; +var z; +var z; +var z; +var z; +function getValueAsString(value) { + if (value.kind === 'int') { + return '' + value.num; + } + return value.str; +} diff --git a/tests/baselines/reference/intersectionTypeNormalization.symbols b/tests/baselines/reference/intersectionTypeNormalization.symbols new file mode 100644 index 00000000000..a5a00c70407 --- /dev/null +++ b/tests/baselines/reference/intersectionTypeNormalization.symbols @@ -0,0 +1,242 @@ +=== tests/cases/compiler/intersectionTypeNormalization.ts === +interface A { a: string } +>A : Symbol(A, Decl(intersectionTypeNormalization.ts, 0, 0)) +>a : Symbol(A.a, Decl(intersectionTypeNormalization.ts, 0, 13)) + +interface B { b: string } +>B : Symbol(B, Decl(intersectionTypeNormalization.ts, 0, 25)) +>b : Symbol(B.b, Decl(intersectionTypeNormalization.ts, 1, 13)) + +interface C { c: string } +>C : Symbol(C, Decl(intersectionTypeNormalization.ts, 1, 25)) +>c : Symbol(C.c, Decl(intersectionTypeNormalization.ts, 2, 13)) + +interface D { d: string } +>D : Symbol(D, Decl(intersectionTypeNormalization.ts, 2, 25)) +>d : Symbol(D.d, Decl(intersectionTypeNormalization.ts, 3, 13)) + +// Identical ways of writing the same type +type X1 = (A | B) & (C | D); +>X1 : Symbol(X1, Decl(intersectionTypeNormalization.ts, 3, 25)) +>A : Symbol(A, Decl(intersectionTypeNormalization.ts, 0, 0)) +>B : Symbol(B, Decl(intersectionTypeNormalization.ts, 0, 25)) +>C : Symbol(C, Decl(intersectionTypeNormalization.ts, 1, 25)) +>D : Symbol(D, Decl(intersectionTypeNormalization.ts, 2, 25)) + +type X2 = A & (C | D) | B & (C | D) +>X2 : Symbol(X2, Decl(intersectionTypeNormalization.ts, 6, 28)) +>A : Symbol(A, Decl(intersectionTypeNormalization.ts, 0, 0)) +>C : Symbol(C, Decl(intersectionTypeNormalization.ts, 1, 25)) +>D : Symbol(D, Decl(intersectionTypeNormalization.ts, 2, 25)) +>B : Symbol(B, Decl(intersectionTypeNormalization.ts, 0, 25)) +>C : Symbol(C, Decl(intersectionTypeNormalization.ts, 1, 25)) +>D : Symbol(D, Decl(intersectionTypeNormalization.ts, 2, 25)) + +type X3 = A & C | A & D | B & C | B & D; +>X3 : Symbol(X3, Decl(intersectionTypeNormalization.ts, 7, 35)) +>A : Symbol(A, Decl(intersectionTypeNormalization.ts, 0, 0)) +>C : Symbol(C, Decl(intersectionTypeNormalization.ts, 1, 25)) +>A : Symbol(A, Decl(intersectionTypeNormalization.ts, 0, 0)) +>D : Symbol(D, Decl(intersectionTypeNormalization.ts, 2, 25)) +>B : Symbol(B, Decl(intersectionTypeNormalization.ts, 0, 25)) +>C : Symbol(C, Decl(intersectionTypeNormalization.ts, 1, 25)) +>B : Symbol(B, Decl(intersectionTypeNormalization.ts, 0, 25)) +>D : Symbol(D, Decl(intersectionTypeNormalization.ts, 2, 25)) + +var x: X1; +>x : Symbol(x, Decl(intersectionTypeNormalization.ts, 10, 3), Decl(intersectionTypeNormalization.ts, 11, 3), Decl(intersectionTypeNormalization.ts, 12, 3)) +>X1 : Symbol(X1, Decl(intersectionTypeNormalization.ts, 3, 25)) + +var x: X2; +>x : Symbol(x, Decl(intersectionTypeNormalization.ts, 10, 3), Decl(intersectionTypeNormalization.ts, 11, 3), Decl(intersectionTypeNormalization.ts, 12, 3)) +>X2 : Symbol(X2, Decl(intersectionTypeNormalization.ts, 6, 28)) + +var x: X3; +>x : Symbol(x, Decl(intersectionTypeNormalization.ts, 10, 3), Decl(intersectionTypeNormalization.ts, 11, 3), Decl(intersectionTypeNormalization.ts, 12, 3)) +>X3 : Symbol(X3, Decl(intersectionTypeNormalization.ts, 7, 35)) + +interface X { x: string } +>X : Symbol(X, Decl(intersectionTypeNormalization.ts, 12, 10)) +>x : Symbol(X.x, Decl(intersectionTypeNormalization.ts, 14, 13)) + +interface Y { y: string } +>Y : Symbol(Y, Decl(intersectionTypeNormalization.ts, 14, 25)) +>y : Symbol(Y.y, Decl(intersectionTypeNormalization.ts, 15, 13)) + +// Identical ways of writing the same type +type Y1 = (A | X & Y) & (C | D); +>Y1 : Symbol(Y1, Decl(intersectionTypeNormalization.ts, 15, 25)) +>A : Symbol(A, Decl(intersectionTypeNormalization.ts, 0, 0)) +>X : Symbol(X, Decl(intersectionTypeNormalization.ts, 12, 10)) +>Y : Symbol(Y, Decl(intersectionTypeNormalization.ts, 14, 25)) +>C : Symbol(C, Decl(intersectionTypeNormalization.ts, 1, 25)) +>D : Symbol(D, Decl(intersectionTypeNormalization.ts, 2, 25)) + +type Y2 = A & (C | D) | X & Y & (C | D) +>Y2 : Symbol(Y2, Decl(intersectionTypeNormalization.ts, 18, 32)) +>A : Symbol(A, Decl(intersectionTypeNormalization.ts, 0, 0)) +>C : Symbol(C, Decl(intersectionTypeNormalization.ts, 1, 25)) +>D : Symbol(D, Decl(intersectionTypeNormalization.ts, 2, 25)) +>X : Symbol(X, Decl(intersectionTypeNormalization.ts, 12, 10)) +>Y : Symbol(Y, Decl(intersectionTypeNormalization.ts, 14, 25)) +>C : Symbol(C, Decl(intersectionTypeNormalization.ts, 1, 25)) +>D : Symbol(D, Decl(intersectionTypeNormalization.ts, 2, 25)) + +type Y3 = A & C | A & D | X & Y & C | X & Y & D; +>Y3 : Symbol(Y3, Decl(intersectionTypeNormalization.ts, 19, 39)) +>A : Symbol(A, Decl(intersectionTypeNormalization.ts, 0, 0)) +>C : Symbol(C, Decl(intersectionTypeNormalization.ts, 1, 25)) +>A : Symbol(A, Decl(intersectionTypeNormalization.ts, 0, 0)) +>D : Symbol(D, Decl(intersectionTypeNormalization.ts, 2, 25)) +>X : Symbol(X, Decl(intersectionTypeNormalization.ts, 12, 10)) +>Y : Symbol(Y, Decl(intersectionTypeNormalization.ts, 14, 25)) +>C : Symbol(C, Decl(intersectionTypeNormalization.ts, 1, 25)) +>X : Symbol(X, Decl(intersectionTypeNormalization.ts, 12, 10)) +>Y : Symbol(Y, Decl(intersectionTypeNormalization.ts, 14, 25)) +>D : Symbol(D, Decl(intersectionTypeNormalization.ts, 2, 25)) + +var y: Y1; +>y : Symbol(y, Decl(intersectionTypeNormalization.ts, 22, 3), Decl(intersectionTypeNormalization.ts, 23, 3), Decl(intersectionTypeNormalization.ts, 24, 3)) +>Y1 : Symbol(Y1, Decl(intersectionTypeNormalization.ts, 15, 25)) + +var y: Y2; +>y : Symbol(y, Decl(intersectionTypeNormalization.ts, 22, 3), Decl(intersectionTypeNormalization.ts, 23, 3), Decl(intersectionTypeNormalization.ts, 24, 3)) +>Y2 : Symbol(Y2, Decl(intersectionTypeNormalization.ts, 18, 32)) + +var y: Y3; +>y : Symbol(y, Decl(intersectionTypeNormalization.ts, 22, 3), Decl(intersectionTypeNormalization.ts, 23, 3), Decl(intersectionTypeNormalization.ts, 24, 3)) +>Y3 : Symbol(Y3, Decl(intersectionTypeNormalization.ts, 19, 39)) + +interface M { m: string } +>M : Symbol(M, Decl(intersectionTypeNormalization.ts, 24, 10)) +>m : Symbol(M.m, Decl(intersectionTypeNormalization.ts, 26, 13)) + +interface N { n: string } +>N : Symbol(N, Decl(intersectionTypeNormalization.ts, 26, 25)) +>n : Symbol(N.n, Decl(intersectionTypeNormalization.ts, 27, 13)) + +// Identical ways of writing the same type +type Z1 = (A | X & (M | N)) & (C | D); +>Z1 : Symbol(Z1, Decl(intersectionTypeNormalization.ts, 27, 25)) +>A : Symbol(A, Decl(intersectionTypeNormalization.ts, 0, 0)) +>X : Symbol(X, Decl(intersectionTypeNormalization.ts, 12, 10)) +>M : Symbol(M, Decl(intersectionTypeNormalization.ts, 24, 10)) +>N : Symbol(N, Decl(intersectionTypeNormalization.ts, 26, 25)) +>C : Symbol(C, Decl(intersectionTypeNormalization.ts, 1, 25)) +>D : Symbol(D, Decl(intersectionTypeNormalization.ts, 2, 25)) + +type Z2 = A & (C | D) | X & (M | N) & (C | D) +>Z2 : Symbol(Z2, Decl(intersectionTypeNormalization.ts, 30, 38)) +>A : Symbol(A, Decl(intersectionTypeNormalization.ts, 0, 0)) +>C : Symbol(C, Decl(intersectionTypeNormalization.ts, 1, 25)) +>D : Symbol(D, Decl(intersectionTypeNormalization.ts, 2, 25)) +>X : Symbol(X, Decl(intersectionTypeNormalization.ts, 12, 10)) +>M : Symbol(M, Decl(intersectionTypeNormalization.ts, 24, 10)) +>N : Symbol(N, Decl(intersectionTypeNormalization.ts, 26, 25)) +>C : Symbol(C, Decl(intersectionTypeNormalization.ts, 1, 25)) +>D : Symbol(D, Decl(intersectionTypeNormalization.ts, 2, 25)) + +type Z3 = A & C | A & D | X & (M | N) & C | X & (M | N) & D; +>Z3 : Symbol(Z3, Decl(intersectionTypeNormalization.ts, 31, 45)) +>A : Symbol(A, Decl(intersectionTypeNormalization.ts, 0, 0)) +>C : Symbol(C, Decl(intersectionTypeNormalization.ts, 1, 25)) +>A : Symbol(A, Decl(intersectionTypeNormalization.ts, 0, 0)) +>D : Symbol(D, Decl(intersectionTypeNormalization.ts, 2, 25)) +>X : Symbol(X, Decl(intersectionTypeNormalization.ts, 12, 10)) +>M : Symbol(M, Decl(intersectionTypeNormalization.ts, 24, 10)) +>N : Symbol(N, Decl(intersectionTypeNormalization.ts, 26, 25)) +>C : Symbol(C, Decl(intersectionTypeNormalization.ts, 1, 25)) +>X : Symbol(X, Decl(intersectionTypeNormalization.ts, 12, 10)) +>M : Symbol(M, Decl(intersectionTypeNormalization.ts, 24, 10)) +>N : Symbol(N, Decl(intersectionTypeNormalization.ts, 26, 25)) +>D : Symbol(D, Decl(intersectionTypeNormalization.ts, 2, 25)) + +type Z4 = A & C | A & D | X & M & C | X & N & C | X & M & D | X & N & D; +>Z4 : Symbol(Z4, Decl(intersectionTypeNormalization.ts, 32, 60)) +>A : Symbol(A, Decl(intersectionTypeNormalization.ts, 0, 0)) +>C : Symbol(C, Decl(intersectionTypeNormalization.ts, 1, 25)) +>A : Symbol(A, Decl(intersectionTypeNormalization.ts, 0, 0)) +>D : Symbol(D, Decl(intersectionTypeNormalization.ts, 2, 25)) +>X : Symbol(X, Decl(intersectionTypeNormalization.ts, 12, 10)) +>M : Symbol(M, Decl(intersectionTypeNormalization.ts, 24, 10)) +>C : Symbol(C, Decl(intersectionTypeNormalization.ts, 1, 25)) +>X : Symbol(X, Decl(intersectionTypeNormalization.ts, 12, 10)) +>N : Symbol(N, Decl(intersectionTypeNormalization.ts, 26, 25)) +>C : Symbol(C, Decl(intersectionTypeNormalization.ts, 1, 25)) +>X : Symbol(X, Decl(intersectionTypeNormalization.ts, 12, 10)) +>M : Symbol(M, Decl(intersectionTypeNormalization.ts, 24, 10)) +>D : Symbol(D, Decl(intersectionTypeNormalization.ts, 2, 25)) +>X : Symbol(X, Decl(intersectionTypeNormalization.ts, 12, 10)) +>N : Symbol(N, Decl(intersectionTypeNormalization.ts, 26, 25)) +>D : Symbol(D, Decl(intersectionTypeNormalization.ts, 2, 25)) + +var z: Z1; +>z : Symbol(z, Decl(intersectionTypeNormalization.ts, 35, 3), Decl(intersectionTypeNormalization.ts, 36, 3), Decl(intersectionTypeNormalization.ts, 37, 3), Decl(intersectionTypeNormalization.ts, 38, 3)) +>Z1 : Symbol(Z1, Decl(intersectionTypeNormalization.ts, 27, 25)) + +var z: Z2; +>z : Symbol(z, Decl(intersectionTypeNormalization.ts, 35, 3), Decl(intersectionTypeNormalization.ts, 36, 3), Decl(intersectionTypeNormalization.ts, 37, 3), Decl(intersectionTypeNormalization.ts, 38, 3)) +>Z2 : Symbol(Z2, Decl(intersectionTypeNormalization.ts, 30, 38)) + +var z: Z3; +>z : Symbol(z, Decl(intersectionTypeNormalization.ts, 35, 3), Decl(intersectionTypeNormalization.ts, 36, 3), Decl(intersectionTypeNormalization.ts, 37, 3), Decl(intersectionTypeNormalization.ts, 38, 3)) +>Z3 : Symbol(Z3, Decl(intersectionTypeNormalization.ts, 31, 45)) + +var z: Z4; +>z : Symbol(z, Decl(intersectionTypeNormalization.ts, 35, 3), Decl(intersectionTypeNormalization.ts, 36, 3), Decl(intersectionTypeNormalization.ts, 37, 3), Decl(intersectionTypeNormalization.ts, 38, 3)) +>Z4 : Symbol(Z4, Decl(intersectionTypeNormalization.ts, 32, 60)) + +// Repro from #9919 + +type ToString = { +>ToString : Symbol(ToString, Decl(intersectionTypeNormalization.ts, 38, 10)) + + toString(): string; +>toString : Symbol(toString, Decl(intersectionTypeNormalization.ts, 42, 17)) +} + +type BoxedValue = { kind: 'int', num: number } +>BoxedValue : Symbol(BoxedValue, Decl(intersectionTypeNormalization.ts, 44, 1)) +>kind : Symbol(kind, Decl(intersectionTypeNormalization.ts, 46, 19)) +>num : Symbol(num, Decl(intersectionTypeNormalization.ts, 46, 32)) + + | { kind: 'string', str: string } +>kind : Symbol(kind, Decl(intersectionTypeNormalization.ts, 47, 19)) +>str : Symbol(str, Decl(intersectionTypeNormalization.ts, 47, 35)) + +type IntersectionFail = BoxedValue & ToString +>IntersectionFail : Symbol(IntersectionFail, Decl(intersectionTypeNormalization.ts, 47, 49)) +>BoxedValue : Symbol(BoxedValue, Decl(intersectionTypeNormalization.ts, 44, 1)) +>ToString : Symbol(ToString, Decl(intersectionTypeNormalization.ts, 38, 10)) + +type IntersectionInline = { kind: 'int', num: number } & ToString +>IntersectionInline : Symbol(IntersectionInline, Decl(intersectionTypeNormalization.ts, 49, 45)) +>kind : Symbol(kind, Decl(intersectionTypeNormalization.ts, 51, 27)) +>num : Symbol(num, Decl(intersectionTypeNormalization.ts, 51, 40)) +>ToString : Symbol(ToString, Decl(intersectionTypeNormalization.ts, 38, 10)) + + | { kind: 'string', str: string } & ToString +>kind : Symbol(kind, Decl(intersectionTypeNormalization.ts, 52, 27)) +>str : Symbol(str, Decl(intersectionTypeNormalization.ts, 52, 43)) +>ToString : Symbol(ToString, Decl(intersectionTypeNormalization.ts, 38, 10)) + +function getValueAsString(value: IntersectionFail): string { +>getValueAsString : Symbol(getValueAsString, Decl(intersectionTypeNormalization.ts, 52, 68)) +>value : Symbol(value, Decl(intersectionTypeNormalization.ts, 54, 26)) +>IntersectionFail : Symbol(IntersectionFail, Decl(intersectionTypeNormalization.ts, 47, 49)) + + if (value.kind === 'int') { +>value.kind : Symbol(kind, Decl(intersectionTypeNormalization.ts, 46, 19), Decl(intersectionTypeNormalization.ts, 47, 19)) +>value : Symbol(value, Decl(intersectionTypeNormalization.ts, 54, 26)) +>kind : Symbol(kind, Decl(intersectionTypeNormalization.ts, 46, 19), Decl(intersectionTypeNormalization.ts, 47, 19)) + + return '' + value.num; +>value.num : Symbol(num, Decl(intersectionTypeNormalization.ts, 46, 32)) +>value : Symbol(value, Decl(intersectionTypeNormalization.ts, 54, 26)) +>num : Symbol(num, Decl(intersectionTypeNormalization.ts, 46, 32)) + } + return value.str; +>value.str : Symbol(str, Decl(intersectionTypeNormalization.ts, 47, 35)) +>value : Symbol(value, Decl(intersectionTypeNormalization.ts, 54, 26)) +>str : Symbol(str, Decl(intersectionTypeNormalization.ts, 47, 35)) +} diff --git a/tests/baselines/reference/intersectionTypeNormalization.types b/tests/baselines/reference/intersectionTypeNormalization.types new file mode 100644 index 00000000000..10ef50ae1b4 --- /dev/null +++ b/tests/baselines/reference/intersectionTypeNormalization.types @@ -0,0 +1,246 @@ +=== tests/cases/compiler/intersectionTypeNormalization.ts === +interface A { a: string } +>A : A +>a : string + +interface B { b: string } +>B : B +>b : string + +interface C { c: string } +>C : C +>c : string + +interface D { d: string } +>D : D +>d : string + +// Identical ways of writing the same type +type X1 = (A | B) & (C | D); +>X1 : X1 +>A : A +>B : B +>C : C +>D : D + +type X2 = A & (C | D) | B & (C | D) +>X2 : X1 +>A : A +>C : C +>D : D +>B : B +>C : C +>D : D + +type X3 = A & C | A & D | B & C | B & D; +>X3 : X1 +>A : A +>C : C +>A : A +>D : D +>B : B +>C : C +>B : B +>D : D + +var x: X1; +>x : X1 +>X1 : X1 + +var x: X2; +>x : X1 +>X2 : X1 + +var x: X3; +>x : X1 +>X3 : X1 + +interface X { x: string } +>X : X +>x : string + +interface Y { y: string } +>Y : Y +>y : string + +// Identical ways of writing the same type +type Y1 = (A | X & Y) & (C | D); +>Y1 : Y1 +>A : A +>X : X +>Y : Y +>C : C +>D : D + +type Y2 = A & (C | D) | X & Y & (C | D) +>Y2 : Y1 +>A : A +>C : C +>D : D +>X : X +>Y : Y +>C : C +>D : D + +type Y3 = A & C | A & D | X & Y & C | X & Y & D; +>Y3 : Y1 +>A : A +>C : C +>A : A +>D : D +>X : X +>Y : Y +>C : C +>X : X +>Y : Y +>D : D + +var y: Y1; +>y : Y1 +>Y1 : Y1 + +var y: Y2; +>y : Y1 +>Y2 : Y1 + +var y: Y3; +>y : Y1 +>Y3 : Y1 + +interface M { m: string } +>M : M +>m : string + +interface N { n: string } +>N : N +>n : string + +// Identical ways of writing the same type +type Z1 = (A | X & (M | N)) & (C | D); +>Z1 : Z1 +>A : A +>X : X +>M : M +>N : N +>C : C +>D : D + +type Z2 = A & (C | D) | X & (M | N) & (C | D) +>Z2 : Z1 +>A : A +>C : C +>D : D +>X : X +>M : M +>N : N +>C : C +>D : D + +type Z3 = A & C | A & D | X & (M | N) & C | X & (M | N) & D; +>Z3 : Z1 +>A : A +>C : C +>A : A +>D : D +>X : X +>M : M +>N : N +>C : C +>X : X +>M : M +>N : N +>D : D + +type Z4 = A & C | A & D | X & M & C | X & N & C | X & M & D | X & N & D; +>Z4 : Z1 +>A : A +>C : C +>A : A +>D : D +>X : X +>M : M +>C : C +>X : X +>N : N +>C : C +>X : X +>M : M +>D : D +>X : X +>N : N +>D : D + +var z: Z1; +>z : Z1 +>Z1 : Z1 + +var z: Z2; +>z : Z1 +>Z2 : Z1 + +var z: Z3; +>z : Z1 +>Z3 : Z1 + +var z: Z4; +>z : Z1 +>Z4 : Z1 + +// Repro from #9919 + +type ToString = { +>ToString : { toString(): string; } + + toString(): string; +>toString : () => string +} + +type BoxedValue = { kind: 'int', num: number } +>BoxedValue : BoxedValue +>kind : "int" +>num : number + + | { kind: 'string', str: string } +>kind : "string" +>str : string + +type IntersectionFail = BoxedValue & ToString +>IntersectionFail : IntersectionFail +>BoxedValue : BoxedValue +>ToString : { toString(): string; } + +type IntersectionInline = { kind: 'int', num: number } & ToString +>IntersectionInline : IntersectionInline +>kind : "int" +>num : number +>ToString : { toString(): string; } + + | { kind: 'string', str: string } & ToString +>kind : "string" +>str : string +>ToString : { toString(): string; } + +function getValueAsString(value: IntersectionFail): string { +>getValueAsString : (value: IntersectionFail) => string +>value : IntersectionFail +>IntersectionFail : IntersectionFail + + if (value.kind === 'int') { +>value.kind === 'int' : boolean +>value.kind : "int" | "string" +>value : IntersectionFail +>kind : "int" | "string" +>'int' : "int" + + return '' + value.num; +>'' + value.num : string +>'' : "" +>value.num : number +>value : { kind: "int"; num: number; } & { toString(): string; } +>num : number + } + return value.str; +>value.str : string +>value : { kind: "string"; str: string; } & { toString(): string; } +>str : string +} diff --git a/tests/cases/compiler/intersectionTypeNormalization.ts b/tests/cases/compiler/intersectionTypeNormalization.ts new file mode 100644 index 00000000000..f31c3d49014 --- /dev/null +++ b/tests/cases/compiler/intersectionTypeNormalization.ts @@ -0,0 +1,60 @@ +interface A { a: string } +interface B { b: string } +interface C { c: string } +interface D { d: string } + +// Identical ways of writing the same type +type X1 = (A | B) & (C | D); +type X2 = A & (C | D) | B & (C | D) +type X3 = A & C | A & D | B & C | B & D; + +var x: X1; +var x: X2; +var x: X3; + +interface X { x: string } +interface Y { y: string } + +// Identical ways of writing the same type +type Y1 = (A | X & Y) & (C | D); +type Y2 = A & (C | D) | X & Y & (C | D) +type Y3 = A & C | A & D | X & Y & C | X & Y & D; + +var y: Y1; +var y: Y2; +var y: Y3; + +interface M { m: string } +interface N { n: string } + +// Identical ways of writing the same type +type Z1 = (A | X & (M | N)) & (C | D); +type Z2 = A & (C | D) | X & (M | N) & (C | D) +type Z3 = A & C | A & D | X & (M | N) & C | X & (M | N) & D; +type Z4 = A & C | A & D | X & M & C | X & N & C | X & M & D | X & N & D; + +var z: Z1; +var z: Z2; +var z: Z3; +var z: Z4; + +// Repro from #9919 + +type ToString = { + toString(): string; +} + +type BoxedValue = { kind: 'int', num: number } + | { kind: 'string', str: string } + +type IntersectionFail = BoxedValue & ToString + +type IntersectionInline = { kind: 'int', num: number } & ToString + | { kind: 'string', str: string } & ToString + +function getValueAsString(value: IntersectionFail): string { + if (value.kind === 'int') { + return '' + value.num; + } + return value.str; +} \ No newline at end of file From 17cf4357adbb363ba796a810150fef28d8bac10e Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Tue, 18 Oct 2016 12:24:41 -0700 Subject: [PATCH 138/173] Add testcase when error is reported about unused react --- .../reference/unusedImports13.errors.txt | 25 +++++++++++++ tests/baselines/reference/unusedImports13.js | 27 ++++++++++++++ tests/baselines/reference/unusedImports14.js | 27 ++++++++++++++ .../reference/unusedImports14.symbols | 36 ++++++++++++++++++ .../baselines/reference/unusedImports14.types | 37 +++++++++++++++++++ tests/cases/compiler/unusedImports13.ts | 23 ++++++++++++ tests/cases/compiler/unusedImports14.ts | 23 ++++++++++++ 7 files changed, 198 insertions(+) create mode 100644 tests/baselines/reference/unusedImports13.errors.txt create mode 100644 tests/baselines/reference/unusedImports13.js create mode 100644 tests/baselines/reference/unusedImports14.js create mode 100644 tests/baselines/reference/unusedImports14.symbols create mode 100644 tests/baselines/reference/unusedImports14.types create mode 100644 tests/cases/compiler/unusedImports13.ts create mode 100644 tests/cases/compiler/unusedImports14.ts diff --git a/tests/baselines/reference/unusedImports13.errors.txt b/tests/baselines/reference/unusedImports13.errors.txt new file mode 100644 index 00000000000..0e870795eb6 --- /dev/null +++ b/tests/baselines/reference/unusedImports13.errors.txt @@ -0,0 +1,25 @@ +tests/cases/compiler/foo.tsx(2,8): error TS6133: 'React' is declared but never used. + + +==== tests/cases/compiler/foo.tsx (1 errors) ==== + + import React = require("react"); + ~~~~~ +!!! error TS6133: 'React' is declared but never used. + + export const FooComponent =
+ +==== tests/cases/compiler/node_modules/@types/react/index.d.ts (0 errors) ==== + export = React; + export as namespace React; + + declare namespace React { + function createClass(spec); + } + declare global { + namespace JSX { + } + } + + + \ No newline at end of file diff --git a/tests/baselines/reference/unusedImports13.js b/tests/baselines/reference/unusedImports13.js new file mode 100644 index 00000000000..01e91abc14b --- /dev/null +++ b/tests/baselines/reference/unusedImports13.js @@ -0,0 +1,27 @@ +//// [tests/cases/compiler/unusedImports13.ts] //// + +//// [foo.tsx] + +import React = require("react"); + +export const FooComponent =
+ +//// [index.d.ts] +export = React; +export as namespace React; + +declare namespace React { + function createClass(spec); +} +declare global { + namespace JSX { + } +} + + + + +//// [foo.jsx] +"use strict"; +var React = require("react"); +exports.FooComponent =
; diff --git a/tests/baselines/reference/unusedImports14.js b/tests/baselines/reference/unusedImports14.js new file mode 100644 index 00000000000..f3c51590e49 --- /dev/null +++ b/tests/baselines/reference/unusedImports14.js @@ -0,0 +1,27 @@ +//// [tests/cases/compiler/unusedImports14.ts] //// + +//// [foo.tsx] + +import React = require("react"); + +export const FooComponent =
+ +//// [index.d.ts] +export = React; +export as namespace React; + +declare namespace React { + function createClass(spec); +} +declare global { + namespace JSX { + } +} + + + + +//// [foo.js] +"use strict"; +var React = require("react"); +exports.FooComponent = React.createElement("div", null); diff --git a/tests/baselines/reference/unusedImports14.symbols b/tests/baselines/reference/unusedImports14.symbols new file mode 100644 index 00000000000..3ac44d17533 --- /dev/null +++ b/tests/baselines/reference/unusedImports14.symbols @@ -0,0 +1,36 @@ +=== tests/cases/compiler/foo.tsx === + +import React = require("react"); +>React : Symbol(React, Decl(foo.tsx, 0, 0)) + +export const FooComponent =
+>FooComponent : Symbol(FooComponent, Decl(foo.tsx, 3, 12)) +>div : Symbol(unknown) +>div : Symbol(unknown) + +=== tests/cases/compiler/node_modules/@types/react/index.d.ts === +export = React; +>React : Symbol(React, Decl(index.d.ts, 1, 26)) + +export as namespace React; +>React : Symbol(React, Decl(index.d.ts, 0, 15)) + +declare namespace React { +>React : Symbol(React, Decl(index.d.ts, 1, 26)) + + function createClass(spec); +>createClass : Symbol(createClass, Decl(index.d.ts, 3, 25)) +>P : Symbol(P, Decl(index.d.ts, 4, 25)) +>S : Symbol(S, Decl(index.d.ts, 4, 27)) +>spec : Symbol(spec, Decl(index.d.ts, 4, 31)) +} +declare global { +>global : Symbol(global, Decl(index.d.ts, 5, 1)) + + namespace JSX { +>JSX : Symbol(JSX, Decl(index.d.ts, 6, 16)) + } +} + + + diff --git a/tests/baselines/reference/unusedImports14.types b/tests/baselines/reference/unusedImports14.types new file mode 100644 index 00000000000..b19531b3e2d --- /dev/null +++ b/tests/baselines/reference/unusedImports14.types @@ -0,0 +1,37 @@ +=== tests/cases/compiler/foo.tsx === + +import React = require("react"); +>React : typeof React + +export const FooComponent =
+>FooComponent : any +>
: any +>div : any +>div : any + +=== tests/cases/compiler/node_modules/@types/react/index.d.ts === +export = React; +>React : typeof React + +export as namespace React; +>React : typeof React + +declare namespace React { +>React : typeof React + + function createClass(spec); +>createClass : (spec: any) => any +>P : P +>S : S +>spec : any +} +declare global { +>global : any + + namespace JSX { +>JSX : any + } +} + + + diff --git a/tests/cases/compiler/unusedImports13.ts b/tests/cases/compiler/unusedImports13.ts new file mode 100644 index 00000000000..875e36abab2 --- /dev/null +++ b/tests/cases/compiler/unusedImports13.ts @@ -0,0 +1,23 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true +//@module: commonjs +//@jsx: preserve + +// @filename: foo.tsx +import React = require("react"); + +export const FooComponent =
+ +// @filename: node_modules/@types/react/index.d.ts +export = React; +export as namespace React; + +declare namespace React { + function createClass(spec); +} +declare global { + namespace JSX { + } +} + + diff --git a/tests/cases/compiler/unusedImports14.ts b/tests/cases/compiler/unusedImports14.ts new file mode 100644 index 00000000000..89e4b31cb13 --- /dev/null +++ b/tests/cases/compiler/unusedImports14.ts @@ -0,0 +1,23 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true +//@module: commonjs +//@jsx: react + +// @filename: foo.tsx +import React = require("react"); + +export const FooComponent =
+ +// @filename: node_modules/@types/react/index.d.ts +export = React; +export as namespace React; + +declare namespace React { + function createClass(spec); +} +declare global { + namespace JSX { + } +} + + From 96a7b7b00f108cad190257c019d07d60abd83b41 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Tue, 18 Oct 2016 12:24:41 -0700 Subject: [PATCH 139/173] Mark local "react" symbol as referenced since it might not be marked if there was no error message being displayed Fixes #10312 --- src/compiler/checker.ts | 10 ++++- .../reference/unusedImports13.errors.txt | 25 ------------- .../reference/unusedImports13.symbols | 36 ++++++++++++++++++ .../baselines/reference/unusedImports13.types | 37 +++++++++++++++++++ 4 files changed, 81 insertions(+), 27 deletions(-) delete mode 100644 tests/baselines/reference/unusedImports13.errors.txt create mode 100644 tests/baselines/reference/unusedImports13.symbols create mode 100644 tests/baselines/reference/unusedImports13.types diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d3f15f2367b..a4d53c40d4d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11070,14 +11070,20 @@ namespace ts { function checkJsxOpeningLikeElement(node: JsxOpeningLikeElement) { checkGrammarJsxElement(node); checkJsxPreconditions(node); - // The reactNamespace symbol should be marked as 'used' so we don't incorrectly elide its import. And if there // is no reactNamespace symbol in scope when targeting React emit, we should issue an error. const reactRefErr = compilerOptions.jsx === JsxEmit.React ? Diagnostics.Cannot_find_name_0 : undefined; const reactNamespace = compilerOptions.reactNamespace ? compilerOptions.reactNamespace : "React"; const reactSym = resolveName(node.tagName, reactNamespace, SymbolFlags.Value, reactRefErr, reactNamespace); if (reactSym) { - getSymbolLinks(reactSym).referenced = true; + // Mark local symbol as referenced here because it might not have been marked + // if jsx emit was not react as there wont be error being emitted + reactSym.isReferenced = true; + + // If react symbol is alias, mark it as refereced + if (reactSym.flags & SymbolFlags.Alias && !isConstEnumOrConstEnumOnlyModule(resolveAlias(reactSym))) { + markAliasSymbolAsReferenced(reactSym); + } } const targetAttributesType = getJsxElementAttributesType(node); diff --git a/tests/baselines/reference/unusedImports13.errors.txt b/tests/baselines/reference/unusedImports13.errors.txt deleted file mode 100644 index 0e870795eb6..00000000000 --- a/tests/baselines/reference/unusedImports13.errors.txt +++ /dev/null @@ -1,25 +0,0 @@ -tests/cases/compiler/foo.tsx(2,8): error TS6133: 'React' is declared but never used. - - -==== tests/cases/compiler/foo.tsx (1 errors) ==== - - import React = require("react"); - ~~~~~ -!!! error TS6133: 'React' is declared but never used. - - export const FooComponent =
- -==== tests/cases/compiler/node_modules/@types/react/index.d.ts (0 errors) ==== - export = React; - export as namespace React; - - declare namespace React { - function createClass(spec); - } - declare global { - namespace JSX { - } - } - - - \ No newline at end of file diff --git a/tests/baselines/reference/unusedImports13.symbols b/tests/baselines/reference/unusedImports13.symbols new file mode 100644 index 00000000000..3ac44d17533 --- /dev/null +++ b/tests/baselines/reference/unusedImports13.symbols @@ -0,0 +1,36 @@ +=== tests/cases/compiler/foo.tsx === + +import React = require("react"); +>React : Symbol(React, Decl(foo.tsx, 0, 0)) + +export const FooComponent =
+>FooComponent : Symbol(FooComponent, Decl(foo.tsx, 3, 12)) +>div : Symbol(unknown) +>div : Symbol(unknown) + +=== tests/cases/compiler/node_modules/@types/react/index.d.ts === +export = React; +>React : Symbol(React, Decl(index.d.ts, 1, 26)) + +export as namespace React; +>React : Symbol(React, Decl(index.d.ts, 0, 15)) + +declare namespace React { +>React : Symbol(React, Decl(index.d.ts, 1, 26)) + + function createClass(spec); +>createClass : Symbol(createClass, Decl(index.d.ts, 3, 25)) +>P : Symbol(P, Decl(index.d.ts, 4, 25)) +>S : Symbol(S, Decl(index.d.ts, 4, 27)) +>spec : Symbol(spec, Decl(index.d.ts, 4, 31)) +} +declare global { +>global : Symbol(global, Decl(index.d.ts, 5, 1)) + + namespace JSX { +>JSX : Symbol(JSX, Decl(index.d.ts, 6, 16)) + } +} + + + diff --git a/tests/baselines/reference/unusedImports13.types b/tests/baselines/reference/unusedImports13.types new file mode 100644 index 00000000000..b19531b3e2d --- /dev/null +++ b/tests/baselines/reference/unusedImports13.types @@ -0,0 +1,37 @@ +=== tests/cases/compiler/foo.tsx === + +import React = require("react"); +>React : typeof React + +export const FooComponent =
+>FooComponent : any +>
: any +>div : any +>div : any + +=== tests/cases/compiler/node_modules/@types/react/index.d.ts === +export = React; +>React : typeof React + +export as namespace React; +>React : typeof React + +declare namespace React { +>React : typeof React + + function createClass(spec); +>createClass : (spec: any) => any +>P : P +>S : S +>spec : any +} +declare global { +>global : any + + namespace JSX { +>JSX : any + } +} + + + From f11dbc1ad160dde5209d06dd552f5d73cd832bac Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Wed, 19 Oct 2016 06:26:50 -0700 Subject: [PATCH 140/173] Respond to PR feedback --- src/compiler/comments.ts | 4 ++-- src/compiler/core.ts | 2 +- src/compiler/emitter.ts | 2 +- src/compiler/moduleNameResolver.ts | 2 +- src/compiler/parser.ts | 4 ++-- src/compiler/sys.ts | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/compiler/comments.ts b/src/compiler/comments.ts index c2cf49eeb6a..cd96981c093 100644 --- a/src/compiler/comments.ts +++ b/src/compiler/comments.ts @@ -182,9 +182,9 @@ namespace ts { } } - function emitTripleSlashLeadingComment(commentPos: number, commentEnd: number, _kind: SyntaxKind, hasTrailingNewLine: boolean, rangePos: number) { + function emitTripleSlashLeadingComment(commentPos: number, commentEnd: number, kind: SyntaxKind, hasTrailingNewLine: boolean, rangePos: number) { if (isTripleSlashComment(commentPos, commentEnd)) { - emitLeadingComment(commentPos, commentEnd, _kind, hasTrailingNewLine, rangePos); + emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos); } } diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 05efc6db909..2f77b3040b3 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -903,7 +903,7 @@ namespace ts { return t => compose(a(t)); } else { - return _t => u => u; + return _ => u => u; } } diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index bf540f6a0cd..1051c9adca9 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -14,7 +14,7 @@ namespace ts { } const id = (s: SourceFile) => s; - const nullTransformers: Transformer[] = [_ctx => id]; + const nullTransformers: Transformer[] = [_ => id]; // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature export function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFile: SourceFile, emitOnlyDtsFiles?: boolean): EmitResult { diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index ba1f8497559..3fa54f127e1 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -5,7 +5,7 @@ namespace ts { /* @internal */ export function trace(host: ModuleResolutionHost, message: DiagnosticMessage, ...args: any[]): void; - export function trace(host: ModuleResolutionHost, _message: DiagnosticMessage): void { + export function trace(host: ModuleResolutionHost): void { host.trace(formatMessage.apply(undefined, arguments)); } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 5481dc657b8..8cdbf956d42 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -572,10 +572,10 @@ namespace ts { // attached to the EOF token. let parseErrorBeforeNextFinishedNode = false; - export function parseSourceFile(fileName: string, _sourceText: string, languageVersion: ScriptTarget, _syntaxCursor: IncrementalParser.SyntaxCursor, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile { + export function parseSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, syntaxCursor: IncrementalParser.SyntaxCursor, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile { scriptKind = ensureScriptKind(fileName, scriptKind); - initializeState(_sourceText, languageVersion, _syntaxCursor, scriptKind); + initializeState(sourceText, languageVersion, syntaxCursor, scriptKind); const result = parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind); diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index bb945824b4d..585fb60df32 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -591,7 +591,7 @@ namespace ts { getExecutingFilePath: () => ChakraHost.executingFile, getCurrentDirectory: () => ChakraHost.currentDirectory, getDirectories: ChakraHost.getDirectories, - getEnvironmentVariable: ChakraHost.getEnvironmentVariable || ((_name: string) => ""), + getEnvironmentVariable: ChakraHost.getEnvironmentVariable || (() => ""), readDirectory: (path: string, extensions?: string[], excludes?: string[], includes?: string[]) => { const pattern = getFileMatcherPatterns(path, excludes, includes, !!ChakraHost.useCaseSensitiveFileNames, ChakraHost.currentDirectory); return ChakraHost.readDirectory(path, extensions, pattern.basePaths, pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern); From 6814c1d883791a1ad976f3146315de30e00dc0b9 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Wed, 19 Oct 2016 08:27:49 -0700 Subject: [PATCH 141/173] Forbid unused locals/parameters anywhere --- Jakefile.js | 2 +- lib/cancellationToken.js | 2 + lib/lib.d.ts | 12 +- lib/lib.dom.d.ts | 4 + lib/lib.dom.iterable.d.ts | 4 + lib/lib.es2015.collection.d.ts | 4 + lib/lib.es2015.core.d.ts | 4 + lib/lib.es2015.d.ts | 4 + lib/lib.es2015.generator.d.ts | 4 + lib/lib.es2015.iterable.d.ts | 4 + lib/lib.es2015.promise.d.ts | 4 + lib/lib.es2015.proxy.d.ts | 4 + lib/lib.es2015.reflect.d.ts | 4 + lib/lib.es2015.symbol.d.ts | 4 + lib/lib.es2015.symbol.wellknown.d.ts | 4 + lib/lib.es2016.array.include.d.ts | 4 + lib/lib.es2016.d.ts | 4 + lib/lib.es2017.d.ts | 4 + lib/lib.es2017.object.d.ts | 4 + lib/lib.es2017.sharedmemory.d.ts | 4 + lib/lib.es5.d.ts | 4 + lib/lib.es6.d.ts | 44 +- lib/lib.scripthost.d.ts | 4 + lib/lib.webworker.d.ts | 4 + lib/tsc.js | 17048 +++++++----- lib/tsserver.js | 21907 ++++++++------- lib/tsserverlibrary.d.ts | 9338 +------ lib/tsserverlibrary.js | 21895 ++++++++------- lib/typescript.d.ts | 528 +- lib/typescript.js | 23183 ++++++++-------- lib/typescriptServices.d.ts | 528 +- lib/typescriptServices.js | 23183 ++++++++-------- lib/typingsInstaller.js | 1600 +- src/harness/fourslash.ts | 54 +- src/harness/harness.ts | 25 +- src/harness/harnessLanguageService.ts | 60 +- src/harness/loggedIO.ts | 26 +- src/harness/projectsRunner.ts | 4 +- src/harness/tsconfig.json | 4 +- .../unittests/cachingInServerLSHost.ts | 45 +- src/harness/unittests/jsDocParsing.ts | 2 +- src/harness/unittests/moduleResolution.ts | 10 +- .../unittests/reuseProgramStructure.ts | 18 +- .../unittests/services/documentRegistry.ts | 2 +- src/harness/unittests/session.ts | 18 +- .../unittests/tsserverProjectSystem.ts | 21 +- src/harness/unittests/typingsInstaller.ts | 22 +- src/server/builder.ts | 2 +- src/server/cancellationToken/tsconfig.json | 4 +- src/server/client.ts | 43 +- src/server/scriptVersionCache.ts | 8 +- src/server/server.ts | 12 +- src/server/session.ts | 8 +- src/server/tsconfig.json | 4 +- src/server/tsconfig.library.json | 4 +- src/server/typingsCache.ts | 4 +- .../typingsInstaller/nodeTypingsInstaller.ts | 2 +- src/server/typingsInstaller/tsconfig.json | 4 +- .../typingsInstaller/typingsInstaller.ts | 7 +- src/services/completions.ts | 18 +- src/services/findAllReferences.ts | 4 +- src/services/formatting/formatting.ts | 2 +- src/services/formatting/tokenRange.ts | 2 +- src/services/jsDoc.ts | 2 +- src/services/jsTyping.ts | 3 +- src/services/services.ts | 25 +- src/services/shims.ts | 9 +- src/services/transpile.ts | 10 +- src/services/tsconfig.json | 4 +- src/services/types.ts | 2 +- src/services/utilities.ts | 4 +- 71 files changed, 60338 insertions(+), 59510 deletions(-) diff --git a/Jakefile.js b/Jakefile.js index 301dc574eb6..cda7e2ca882 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -448,7 +448,7 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts options += " --stripInternal"; } - options += " --target es5"; + options += " --target es5 --noUnusedLocals --noUnusedParameters"; var cmd = host + " " + compilerPath + " " + options + " "; cmd = cmd + sources.join(" "); diff --git a/lib/cancellationToken.js b/lib/cancellationToken.js index 8af21172df4..f5a28f8d52d 100644 --- a/lib/cancellationToken.js +++ b/lib/cancellationToken.js @@ -39,3 +39,5 @@ function createCancellationToken(args) { }; } module.exports = createCancellationToken; + +//# sourceMappingURL=cancellationToken.js.map diff --git a/lib/lib.d.ts b/lib/lib.d.ts index 922820b5d90..969bf70448c 100644 --- a/lib/lib.d.ts +++ b/lib/lib.d.ts @@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + + /// + + ///////////////////////////// /// ECMAScript APIs ///////////////////////////// @@ -4149,6 +4153,8 @@ interface Date { */ toLocaleTimeString(locales?: string | string[], options?: Intl.DateTimeFormatOptions): string; } + + ///////////////////////////// /// IE DOM APIs @@ -18774,12 +18780,16 @@ type ScrollLogicalPosition = "start" | "center" | "end" | "nearest"; type IDBValidKey = number | string | Date | IDBArrayKey; type BufferSource = ArrayBuffer | ArrayBufferView; type MouseWheelEvent = WheelEvent; -type ScrollRestoration = "auto" | "manual"; +type ScrollRestoration = "auto" | "manual"; + + ///////////////////////////// /// WorkerGlobalScope APIs ///////////////////////////// // These are only available in a Web Worker declare function importScripts(...urls: string[]): void; + + ///////////////////////////// diff --git a/lib/lib.dom.d.ts b/lib/lib.dom.d.ts index 4c19c878064..b80f167b7a8 100644 --- a/lib/lib.dom.d.ts +++ b/lib/lib.dom.d.ts @@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + + /// + + ///////////////////////////// /// IE DOM APIs diff --git a/lib/lib.dom.iterable.d.ts b/lib/lib.dom.iterable.d.ts index 397e0ab111e..2b62054765b 100644 --- a/lib/lib.dom.iterable.d.ts +++ b/lib/lib.dom.iterable.d.ts @@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + + /// + + /// interface DOMTokenList { diff --git a/lib/lib.es2015.collection.d.ts b/lib/lib.es2015.collection.d.ts index 24c737df74b..eabd6319de6 100644 --- a/lib/lib.es2015.collection.d.ts +++ b/lib/lib.es2015.collection.d.ts @@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + + /// + + interface Map { clear(): void; delete(key: K): boolean; diff --git a/lib/lib.es2015.core.d.ts b/lib/lib.es2015.core.d.ts index 669c80944ec..499d0de52db 100644 --- a/lib/lib.es2015.core.d.ts +++ b/lib/lib.es2015.core.d.ts @@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + + /// + + declare type PropertyKey = string | number | symbol; interface Array { diff --git a/lib/lib.es2015.d.ts b/lib/lib.es2015.d.ts index 973d5180989..ff5c555bfee 100644 --- a/lib/lib.es2015.d.ts +++ b/lib/lib.es2015.d.ts @@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + + /// + + /// /// /// diff --git a/lib/lib.es2015.generator.d.ts b/lib/lib.es2015.generator.d.ts index 003f325e4e0..20d6725f66b 100644 --- a/lib/lib.es2015.generator.d.ts +++ b/lib/lib.es2015.generator.d.ts @@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + + /// + + interface GeneratorFunction extends Function { } interface GeneratorFunctionConstructor { diff --git a/lib/lib.es2015.iterable.d.ts b/lib/lib.es2015.iterable.d.ts index 1c27525d432..cb92cb4b8aa 100644 --- a/lib/lib.es2015.iterable.d.ts +++ b/lib/lib.es2015.iterable.d.ts @@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + + /// + + /// interface SymbolConstructor { diff --git a/lib/lib.es2015.promise.d.ts b/lib/lib.es2015.promise.d.ts index 36fe9e7777f..02352da4061 100644 --- a/lib/lib.es2015.promise.d.ts +++ b/lib/lib.es2015.promise.d.ts @@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + + /// + + /** * Represents the completion of an asynchronous operation */ diff --git a/lib/lib.es2015.proxy.d.ts b/lib/lib.es2015.proxy.d.ts index 3908e97c17c..03996c6ad9f 100644 --- a/lib/lib.es2015.proxy.d.ts +++ b/lib/lib.es2015.proxy.d.ts @@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + + /// + + interface ProxyHandler { getPrototypeOf? (target: T): any; setPrototypeOf? (target: T, v: any): boolean; diff --git a/lib/lib.es2015.reflect.d.ts b/lib/lib.es2015.reflect.d.ts index 0f1a491ebcf..b6a6853457a 100644 --- a/lib/lib.es2015.reflect.d.ts +++ b/lib/lib.es2015.reflect.d.ts @@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + + /// + + declare namespace Reflect { function apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; function construct(target: Function, argumentsList: ArrayLike, newTarget?: any): any; diff --git a/lib/lib.es2015.symbol.d.ts b/lib/lib.es2015.symbol.d.ts index 4ab7b4374f1..c0474aec011 100644 --- a/lib/lib.es2015.symbol.d.ts +++ b/lib/lib.es2015.symbol.d.ts @@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + + /// + + interface Symbol { /** Returns a string representation of an object. */ toString(): string; diff --git a/lib/lib.es2015.symbol.wellknown.d.ts b/lib/lib.es2015.symbol.wellknown.d.ts index 2d122d1284e..42299fe7d09 100644 --- a/lib/lib.es2015.symbol.wellknown.d.ts +++ b/lib/lib.es2015.symbol.wellknown.d.ts @@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + + /// + + /// interface SymbolConstructor { diff --git a/lib/lib.es2016.array.include.d.ts b/lib/lib.es2016.array.include.d.ts index a4677e7cf1e..42b95c478d0 100644 --- a/lib/lib.es2016.array.include.d.ts +++ b/lib/lib.es2016.array.include.d.ts @@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + + /// + + interface Array { /** * Determines whether an array includes a certain element, returning true or false as appropriate. diff --git a/lib/lib.es2016.d.ts b/lib/lib.es2016.d.ts index 04a23379676..5921e060d0f 100644 --- a/lib/lib.es2016.d.ts +++ b/lib/lib.es2016.d.ts @@ -13,6 +13,10 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + + /// + + /// /// \ No newline at end of file diff --git a/lib/lib.es2017.d.ts b/lib/lib.es2017.d.ts index 24d23994d96..8354de37f7f 100644 --- a/lib/lib.es2017.d.ts +++ b/lib/lib.es2017.d.ts @@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + + /// + + /// /// /// \ No newline at end of file diff --git a/lib/lib.es2017.object.d.ts b/lib/lib.es2017.object.d.ts index ac3a16ab370..996147a9746 100644 --- a/lib/lib.es2017.object.d.ts +++ b/lib/lib.es2017.object.d.ts @@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + + /// + + interface ObjectConstructor { /** * Returns an array of values of the enumerable properties of an object diff --git a/lib/lib.es2017.sharedmemory.d.ts b/lib/lib.es2017.sharedmemory.d.ts index 639ca7530e4..c59e1255519 100644 --- a/lib/lib.es2017.sharedmemory.d.ts +++ b/lib/lib.es2017.sharedmemory.d.ts @@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + + /// + + /// /// diff --git a/lib/lib.es5.d.ts b/lib/lib.es5.d.ts index a13ffc92d04..2cf3f742522 100644 --- a/lib/lib.es5.d.ts +++ b/lib/lib.es5.d.ts @@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + + /// + + ///////////////////////////// /// ECMAScript APIs ///////////////////////////// diff --git a/lib/lib.es6.d.ts b/lib/lib.es6.d.ts index 4c8806dd7dd..1ace5f499b1 100644 --- a/lib/lib.es6.d.ts +++ b/lib/lib.es6.d.ts @@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + + /// + + ///////////////////////////// /// ECMAScript APIs ///////////////////////////// @@ -4149,6 +4153,8 @@ interface Date { */ toLocaleTimeString(locales?: string | string[], options?: Intl.DateTimeFormatOptions): string; } + + declare type PropertyKey = string | number | symbol; interface Array { @@ -4673,6 +4679,8 @@ interface StringConstructor { */ raw(template: TemplateStringsArray, ...substitutions: any[]): string; } + + interface Map { clear(): void; delete(key: K): boolean; @@ -4745,6 +4753,8 @@ interface WeakSetConstructor { readonly prototype: WeakSet; } declare var WeakSet: WeakSetConstructor; + + interface GeneratorFunction extends Function { } interface GeneratorFunctionConstructor { @@ -4757,6 +4767,8 @@ interface GeneratorFunctionConstructor { readonly prototype: GeneratorFunction; } declare var GeneratorFunction: GeneratorFunctionConstructor; + + /// interface SymbolConstructor { @@ -5201,7 +5213,9 @@ interface Float64ArrayConstructor { * @param thisArg Value of 'this' used to invoke the mapfn. */ from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; -}/** +} + +/** * Represents the completion of an asynchronous operation */ interface Promise { @@ -5454,7 +5468,9 @@ interface PromiseConstructor { resolve(): Promise; } -declare var Promise: PromiseConstructor;interface ProxyHandler { +declare var Promise: PromiseConstructor; + +interface ProxyHandler { getPrototypeOf? (target: T): any; setPrototypeOf? (target: T, v: any): boolean; isExtensible? (target: T): boolean; @@ -5475,7 +5491,9 @@ interface ProxyConstructor { revocable(target: T, handler: ProxyHandler): { proxy: T; revoke: () => void; }; new (target: T, handler: ProxyHandler): T } -declare var Proxy: ProxyConstructor;declare namespace Reflect { +declare var Proxy: ProxyConstructor; + +declare namespace Reflect { function apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; function construct(target: Function, argumentsList: ArrayLike, newTarget?: any): any; function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; @@ -5489,7 +5507,9 @@ declare var Proxy: ProxyConstructor;declare namespace Reflect { function preventExtensions(target: any): boolean; function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean; function setPrototypeOf(target: any, proto: any): boolean; -}interface Symbol { +} + +interface Symbol { /** Returns a string representation of an object. */ toString(): string; @@ -5524,7 +5544,9 @@ interface SymbolConstructor { keyFor(sym: symbol): string | undefined; } -declare var Symbol: SymbolConstructor;/// +declare var Symbol: SymbolConstructor; + +/// interface SymbolConstructor { /** @@ -5850,7 +5872,9 @@ interface Float32Array { */ interface Float64Array { readonly [Symbol.toStringTag]: "Float64Array"; -} +} + + ///////////////////////////// /// IE DOM APIs ///////////////////////////// @@ -20475,12 +20499,16 @@ type ScrollLogicalPosition = "start" | "center" | "end" | "nearest"; type IDBValidKey = number | string | Date | IDBArrayKey; type BufferSource = ArrayBuffer | ArrayBufferView; type MouseWheelEvent = WheelEvent; -type ScrollRestoration = "auto" | "manual"; +type ScrollRestoration = "auto" | "manual"; + + ///////////////////////////// /// WorkerGlobalScope APIs ///////////////////////////// // These are only available in a Web Worker declare function importScripts(...urls: string[]): void; + + ///////////////////////////// @@ -20772,6 +20800,8 @@ interface DateConstructor { interface Date { getVarDate: () => VarDate; } + + /// interface DOMTokenList { diff --git a/lib/lib.scripthost.d.ts b/lib/lib.scripthost.d.ts index b4e52a342f1..2d2f4df3b70 100644 --- a/lib/lib.scripthost.d.ts +++ b/lib/lib.scripthost.d.ts @@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + + /// + + ///////////////////////////// diff --git a/lib/lib.webworker.d.ts b/lib/lib.webworker.d.ts index 6cb14c5b184..53129567256 100644 --- a/lib/lib.webworker.d.ts +++ b/lib/lib.webworker.d.ts @@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + + /// + + ///////////////////////////// /// IE Worker APIs diff --git a/lib/tsc.js b/lib/tsc.js index b1fac7955d0..fbfe07a4588 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -15,6 +15,418 @@ and limitations under the License. var ts; (function (ts) { + (function (SyntaxKind) { + SyntaxKind[SyntaxKind["Unknown"] = 0] = "Unknown"; + SyntaxKind[SyntaxKind["EndOfFileToken"] = 1] = "EndOfFileToken"; + SyntaxKind[SyntaxKind["SingleLineCommentTrivia"] = 2] = "SingleLineCommentTrivia"; + SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 3] = "MultiLineCommentTrivia"; + SyntaxKind[SyntaxKind["NewLineTrivia"] = 4] = "NewLineTrivia"; + SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 5] = "WhitespaceTrivia"; + SyntaxKind[SyntaxKind["ShebangTrivia"] = 6] = "ShebangTrivia"; + SyntaxKind[SyntaxKind["ConflictMarkerTrivia"] = 7] = "ConflictMarkerTrivia"; + SyntaxKind[SyntaxKind["NumericLiteral"] = 8] = "NumericLiteral"; + SyntaxKind[SyntaxKind["StringLiteral"] = 9] = "StringLiteral"; + SyntaxKind[SyntaxKind["JsxText"] = 10] = "JsxText"; + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 11] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 12] = "NoSubstitutionTemplateLiteral"; + SyntaxKind[SyntaxKind["TemplateHead"] = 13] = "TemplateHead"; + SyntaxKind[SyntaxKind["TemplateMiddle"] = 14] = "TemplateMiddle"; + SyntaxKind[SyntaxKind["TemplateTail"] = 15] = "TemplateTail"; + SyntaxKind[SyntaxKind["OpenBraceToken"] = 16] = "OpenBraceToken"; + SyntaxKind[SyntaxKind["CloseBraceToken"] = 17] = "CloseBraceToken"; + SyntaxKind[SyntaxKind["OpenParenToken"] = 18] = "OpenParenToken"; + SyntaxKind[SyntaxKind["CloseParenToken"] = 19] = "CloseParenToken"; + SyntaxKind[SyntaxKind["OpenBracketToken"] = 20] = "OpenBracketToken"; + SyntaxKind[SyntaxKind["CloseBracketToken"] = 21] = "CloseBracketToken"; + SyntaxKind[SyntaxKind["DotToken"] = 22] = "DotToken"; + SyntaxKind[SyntaxKind["DotDotDotToken"] = 23] = "DotDotDotToken"; + SyntaxKind[SyntaxKind["SemicolonToken"] = 24] = "SemicolonToken"; + SyntaxKind[SyntaxKind["CommaToken"] = 25] = "CommaToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 26] = "LessThanToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 27] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 28] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 29] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 30] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 31] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 32] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 33] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 34] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 35] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 36] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 37] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 38] = "AsteriskToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 39] = "AsteriskAsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 40] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 41] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 42] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 43] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 44] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 45] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 46] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 47] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 48] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 49] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 50] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 51] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 52] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 53] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 54] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 55] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 56] = "AtToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 57] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 58] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 59] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 60] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 61] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 62] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 63] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 64] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 65] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 66] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 67] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 68] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 69] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["Identifier"] = 70] = "Identifier"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 71] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 72] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 73] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 74] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 75] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 76] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 77] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 78] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 79] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 80] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 81] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 82] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 83] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 84] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 85] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 86] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 87] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 88] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 89] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 90] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 91] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 92] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 93] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 94] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 95] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 96] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 97] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 98] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 99] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 100] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 101] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 102] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 103] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 104] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 105] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 106] = "WithKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 107] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 108] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 109] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 110] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 111] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 112] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 113] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 114] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 115] = "YieldKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 116] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 117] = "AsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 118] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 119] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 120] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 121] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 122] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 123] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 124] = "GetKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 125] = "IsKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 126] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 127] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 128] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 129] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 130] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 131] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 132] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 133] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 134] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 135] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 136] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 137] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 138] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 139] = "OfKeyword"; + SyntaxKind[SyntaxKind["QualifiedName"] = 140] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 141] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["TypeParameter"] = 142] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 143] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 144] = "Decorator"; + SyntaxKind[SyntaxKind["PropertySignature"] = 145] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 146] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 147] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 148] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 149] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 150] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 151] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 152] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 153] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 154] = "IndexSignature"; + SyntaxKind[SyntaxKind["TypePredicate"] = 155] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 156] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 157] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 158] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 159] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 160] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 161] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 162] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 163] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 164] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 165] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 166] = "ThisType"; + SyntaxKind[SyntaxKind["LiteralType"] = 167] = "LiteralType"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 168] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 169] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 170] = "BindingElement"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 171] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 172] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 173] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 174] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 175] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 176] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 177] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 178] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 179] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 180] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 181] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 182] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 183] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 184] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 185] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 186] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 187] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 188] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 189] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 190] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 191] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElementExpression"] = 192] = "SpreadElementExpression"; + SyntaxKind[SyntaxKind["ClassExpression"] = 193] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 194] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 195] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 196] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 197] = "NonNullExpression"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 198] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 199] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["Block"] = 200] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 201] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 202] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 203] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 204] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 205] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 206] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 207] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 208] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 209] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 210] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 211] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 212] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 213] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 214] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 215] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 216] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 217] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 218] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 219] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 220] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 221] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 222] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 223] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 224] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 225] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 226] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 227] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 228] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 229] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 230] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 231] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 232] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 233] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 234] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 235] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 236] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 237] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 238] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 239] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 240] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 241] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["JsxElement"] = 242] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 243] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 244] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 245] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 246] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 247] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 248] = "JsxExpression"; + SyntaxKind[SyntaxKind["CaseClause"] = 249] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 250] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 251] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 252] = "CatchClause"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 253] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 254] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["EnumMember"] = 255] = "EnumMember"; + SyntaxKind[SyntaxKind["SourceFile"] = 256] = "SourceFile"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 257] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 258] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 259] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 260] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 261] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 262] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 263] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 264] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 265] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 266] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 267] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 268] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 269] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 270] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 271] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 272] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 273] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 274] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 275] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 276] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 277] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 278] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 279] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 280] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 281] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocLiteralType"] = 282] = "JSDocLiteralType"; + SyntaxKind[SyntaxKind["JSDocNullKeyword"] = 283] = "JSDocNullKeyword"; + SyntaxKind[SyntaxKind["JSDocUndefinedKeyword"] = 284] = "JSDocUndefinedKeyword"; + SyntaxKind[SyntaxKind["JSDocNeverKeyword"] = 285] = "JSDocNeverKeyword"; + SyntaxKind[SyntaxKind["SyntaxList"] = 286] = "SyntaxList"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 287] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 288] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["Count"] = 289] = "Count"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 57] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 69] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 58] = "FirstCompoundAssignment"; + SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 69] = "LastCompoundAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 71] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 106] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 71] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 139] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 107] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 115] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 155] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 167] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstPunctuation"] = 16] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 69] = "LastPunctuation"; + SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; + SyntaxKind[SyntaxKind["LastToken"] = 139] = "LastToken"; + SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; + SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; + SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; + SyntaxKind[SyntaxKind["LastLiteralToken"] = 12] = "LastLiteralToken"; + SyntaxKind[SyntaxKind["FirstTemplateToken"] = 12] = "FirstTemplateToken"; + SyntaxKind[SyntaxKind["LastTemplateToken"] = 15] = "LastTemplateToken"; + SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 26] = "FirstBinaryOperator"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 69] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstNode"] = 140] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 257] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 282] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 273] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 285] = "LastJSDocTagNode"; + })(ts.SyntaxKind || (ts.SyntaxKind = {})); + var SyntaxKind = ts.SyntaxKind; + (function (NodeFlags) { + NodeFlags[NodeFlags["None"] = 0] = "None"; + NodeFlags[NodeFlags["Let"] = 1] = "Let"; + NodeFlags[NodeFlags["Const"] = 2] = "Const"; + NodeFlags[NodeFlags["NestedNamespace"] = 4] = "NestedNamespace"; + NodeFlags[NodeFlags["Synthesized"] = 8] = "Synthesized"; + NodeFlags[NodeFlags["Namespace"] = 16] = "Namespace"; + NodeFlags[NodeFlags["ExportContext"] = 32] = "ExportContext"; + NodeFlags[NodeFlags["ContainsThis"] = 64] = "ContainsThis"; + NodeFlags[NodeFlags["HasImplicitReturn"] = 128] = "HasImplicitReturn"; + NodeFlags[NodeFlags["HasExplicitReturn"] = 256] = "HasExplicitReturn"; + NodeFlags[NodeFlags["GlobalAugmentation"] = 512] = "GlobalAugmentation"; + NodeFlags[NodeFlags["HasClassExtends"] = 1024] = "HasClassExtends"; + NodeFlags[NodeFlags["HasDecorators"] = 2048] = "HasDecorators"; + NodeFlags[NodeFlags["HasParamDecorators"] = 4096] = "HasParamDecorators"; + NodeFlags[NodeFlags["HasAsyncFunctions"] = 8192] = "HasAsyncFunctions"; + NodeFlags[NodeFlags["HasJsxSpreadAttributes"] = 16384] = "HasJsxSpreadAttributes"; + NodeFlags[NodeFlags["DisallowInContext"] = 32768] = "DisallowInContext"; + NodeFlags[NodeFlags["YieldContext"] = 65536] = "YieldContext"; + NodeFlags[NodeFlags["DecoratorContext"] = 131072] = "DecoratorContext"; + NodeFlags[NodeFlags["AwaitContext"] = 262144] = "AwaitContext"; + NodeFlags[NodeFlags["ThisNodeHasError"] = 524288] = "ThisNodeHasError"; + NodeFlags[NodeFlags["JavaScriptFile"] = 1048576] = "JavaScriptFile"; + NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 2097152] = "ThisNodeOrAnySubNodesHasError"; + NodeFlags[NodeFlags["HasAggregatedChildData"] = 4194304] = "HasAggregatedChildData"; + NodeFlags[NodeFlags["BlockScoped"] = 3] = "BlockScoped"; + NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 384] = "ReachabilityCheckFlags"; + NodeFlags[NodeFlags["EmitHelperFlags"] = 31744] = "EmitHelperFlags"; + NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 32128] = "ReachabilityAndEmitFlags"; + NodeFlags[NodeFlags["ContextFlags"] = 1540096] = "ContextFlags"; + NodeFlags[NodeFlags["TypeExcludesFlags"] = 327680] = "TypeExcludesFlags"; + })(ts.NodeFlags || (ts.NodeFlags = {})); + var NodeFlags = ts.NodeFlags; + (function (ModifierFlags) { + ModifierFlags[ModifierFlags["None"] = 0] = "None"; + ModifierFlags[ModifierFlags["Export"] = 1] = "Export"; + ModifierFlags[ModifierFlags["Ambient"] = 2] = "Ambient"; + ModifierFlags[ModifierFlags["Public"] = 4] = "Public"; + ModifierFlags[ModifierFlags["Private"] = 8] = "Private"; + ModifierFlags[ModifierFlags["Protected"] = 16] = "Protected"; + ModifierFlags[ModifierFlags["Static"] = 32] = "Static"; + ModifierFlags[ModifierFlags["Readonly"] = 64] = "Readonly"; + ModifierFlags[ModifierFlags["Abstract"] = 128] = "Abstract"; + ModifierFlags[ModifierFlags["Async"] = 256] = "Async"; + ModifierFlags[ModifierFlags["Default"] = 512] = "Default"; + ModifierFlags[ModifierFlags["Const"] = 2048] = "Const"; + ModifierFlags[ModifierFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; + ModifierFlags[ModifierFlags["AccessibilityModifier"] = 28] = "AccessibilityModifier"; + ModifierFlags[ModifierFlags["ParameterPropertyModifier"] = 92] = "ParameterPropertyModifier"; + ModifierFlags[ModifierFlags["NonPublicAccessibilityModifier"] = 24] = "NonPublicAccessibilityModifier"; + ModifierFlags[ModifierFlags["TypeScriptModifier"] = 2270] = "TypeScriptModifier"; + })(ts.ModifierFlags || (ts.ModifierFlags = {})); + var ModifierFlags = ts.ModifierFlags; + (function (JsxFlags) { + JsxFlags[JsxFlags["None"] = 0] = "None"; + JsxFlags[JsxFlags["IntrinsicNamedElement"] = 1] = "IntrinsicNamedElement"; + JsxFlags[JsxFlags["IntrinsicIndexedElement"] = 2] = "IntrinsicIndexedElement"; + JsxFlags[JsxFlags["IntrinsicElement"] = 3] = "IntrinsicElement"; + })(ts.JsxFlags || (ts.JsxFlags = {})); + var JsxFlags = ts.JsxFlags; + (function (RelationComparisonResult) { + RelationComparisonResult[RelationComparisonResult["Succeeded"] = 1] = "Succeeded"; + RelationComparisonResult[RelationComparisonResult["Failed"] = 2] = "Failed"; + RelationComparisonResult[RelationComparisonResult["FailedAndReported"] = 3] = "FailedAndReported"; + })(ts.RelationComparisonResult || (ts.RelationComparisonResult = {})); + var RelationComparisonResult = ts.RelationComparisonResult; + (function (GeneratedIdentifierKind) { + GeneratedIdentifierKind[GeneratedIdentifierKind["None"] = 0] = "None"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Auto"] = 1] = "Auto"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Loop"] = 2] = "Loop"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Unique"] = 3] = "Unique"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Node"] = 4] = "Node"; + })(ts.GeneratedIdentifierKind || (ts.GeneratedIdentifierKind = {})); + var GeneratedIdentifierKind = ts.GeneratedIdentifierKind; + (function (FlowFlags) { + FlowFlags[FlowFlags["Unreachable"] = 1] = "Unreachable"; + FlowFlags[FlowFlags["Start"] = 2] = "Start"; + FlowFlags[FlowFlags["BranchLabel"] = 4] = "BranchLabel"; + FlowFlags[FlowFlags["LoopLabel"] = 8] = "LoopLabel"; + FlowFlags[FlowFlags["Assignment"] = 16] = "Assignment"; + FlowFlags[FlowFlags["TrueCondition"] = 32] = "TrueCondition"; + FlowFlags[FlowFlags["FalseCondition"] = 64] = "FalseCondition"; + FlowFlags[FlowFlags["SwitchClause"] = 128] = "SwitchClause"; + FlowFlags[FlowFlags["ArrayMutation"] = 256] = "ArrayMutation"; + FlowFlags[FlowFlags["Referenced"] = 512] = "Referenced"; + FlowFlags[FlowFlags["Shared"] = 1024] = "Shared"; + FlowFlags[FlowFlags["Label"] = 12] = "Label"; + FlowFlags[FlowFlags["Condition"] = 96] = "Condition"; + })(ts.FlowFlags || (ts.FlowFlags = {})); + var FlowFlags = ts.FlowFlags; var OperationCanceledException = (function () { function OperationCanceledException() { } @@ -27,6 +439,38 @@ var ts; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; })(ts.ExitStatus || (ts.ExitStatus = {})); var ExitStatus = ts.ExitStatus; + (function (TypeFormatFlags) { + TypeFormatFlags[TypeFormatFlags["None"] = 0] = "None"; + TypeFormatFlags[TypeFormatFlags["WriteArrayAsGenericType"] = 1] = "WriteArrayAsGenericType"; + TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 2] = "UseTypeOfFunction"; + TypeFormatFlags[TypeFormatFlags["NoTruncation"] = 4] = "NoTruncation"; + TypeFormatFlags[TypeFormatFlags["WriteArrowStyleSignature"] = 8] = "WriteArrowStyleSignature"; + TypeFormatFlags[TypeFormatFlags["WriteOwnNameForAnyLike"] = 16] = "WriteOwnNameForAnyLike"; + TypeFormatFlags[TypeFormatFlags["WriteTypeArgumentsOfSignature"] = 32] = "WriteTypeArgumentsOfSignature"; + TypeFormatFlags[TypeFormatFlags["InElementType"] = 64] = "InElementType"; + TypeFormatFlags[TypeFormatFlags["UseFullyQualifiedType"] = 128] = "UseFullyQualifiedType"; + TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 256] = "InFirstTypeArgument"; + TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 512] = "InTypeAlias"; + TypeFormatFlags[TypeFormatFlags["UseTypeAliasValue"] = 1024] = "UseTypeAliasValue"; + })(ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); + var TypeFormatFlags = ts.TypeFormatFlags; + (function (SymbolFormatFlags) { + SymbolFormatFlags[SymbolFormatFlags["None"] = 0] = "None"; + SymbolFormatFlags[SymbolFormatFlags["WriteTypeParametersOrArguments"] = 1] = "WriteTypeParametersOrArguments"; + SymbolFormatFlags[SymbolFormatFlags["UseOnlyExternalAliasing"] = 2] = "UseOnlyExternalAliasing"; + })(ts.SymbolFormatFlags || (ts.SymbolFormatFlags = {})); + var SymbolFormatFlags = ts.SymbolFormatFlags; + (function (SymbolAccessibility) { + SymbolAccessibility[SymbolAccessibility["Accessible"] = 0] = "Accessible"; + SymbolAccessibility[SymbolAccessibility["NotAccessible"] = 1] = "NotAccessible"; + SymbolAccessibility[SymbolAccessibility["CannotBeNamed"] = 2] = "CannotBeNamed"; + })(ts.SymbolAccessibility || (ts.SymbolAccessibility = {})); + var SymbolAccessibility = ts.SymbolAccessibility; + (function (TypePredicateKind) { + TypePredicateKind[TypePredicateKind["This"] = 0] = "This"; + TypePredicateKind[TypePredicateKind["Identifier"] = 1] = "Identifier"; + })(ts.TypePredicateKind || (ts.TypePredicateKind = {})); + var TypePredicateKind = ts.TypePredicateKind; (function (TypeReferenceSerializationKind) { TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; @@ -41,6 +485,166 @@ var ts; TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 10] = "ObjectType"; })(ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); var TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind; + (function (SymbolFlags) { + SymbolFlags[SymbolFlags["None"] = 0] = "None"; + SymbolFlags[SymbolFlags["FunctionScopedVariable"] = 1] = "FunctionScopedVariable"; + SymbolFlags[SymbolFlags["BlockScopedVariable"] = 2] = "BlockScopedVariable"; + SymbolFlags[SymbolFlags["Property"] = 4] = "Property"; + SymbolFlags[SymbolFlags["EnumMember"] = 8] = "EnumMember"; + SymbolFlags[SymbolFlags["Function"] = 16] = "Function"; + SymbolFlags[SymbolFlags["Class"] = 32] = "Class"; + SymbolFlags[SymbolFlags["Interface"] = 64] = "Interface"; + SymbolFlags[SymbolFlags["ConstEnum"] = 128] = "ConstEnum"; + SymbolFlags[SymbolFlags["RegularEnum"] = 256] = "RegularEnum"; + SymbolFlags[SymbolFlags["ValueModule"] = 512] = "ValueModule"; + SymbolFlags[SymbolFlags["NamespaceModule"] = 1024] = "NamespaceModule"; + SymbolFlags[SymbolFlags["TypeLiteral"] = 2048] = "TypeLiteral"; + SymbolFlags[SymbolFlags["ObjectLiteral"] = 4096] = "ObjectLiteral"; + SymbolFlags[SymbolFlags["Method"] = 8192] = "Method"; + SymbolFlags[SymbolFlags["Constructor"] = 16384] = "Constructor"; + SymbolFlags[SymbolFlags["GetAccessor"] = 32768] = "GetAccessor"; + SymbolFlags[SymbolFlags["SetAccessor"] = 65536] = "SetAccessor"; + SymbolFlags[SymbolFlags["Signature"] = 131072] = "Signature"; + SymbolFlags[SymbolFlags["TypeParameter"] = 262144] = "TypeParameter"; + SymbolFlags[SymbolFlags["TypeAlias"] = 524288] = "TypeAlias"; + SymbolFlags[SymbolFlags["ExportValue"] = 1048576] = "ExportValue"; + SymbolFlags[SymbolFlags["ExportType"] = 2097152] = "ExportType"; + SymbolFlags[SymbolFlags["ExportNamespace"] = 4194304] = "ExportNamespace"; + SymbolFlags[SymbolFlags["Alias"] = 8388608] = "Alias"; + SymbolFlags[SymbolFlags["Instantiated"] = 16777216] = "Instantiated"; + SymbolFlags[SymbolFlags["Merged"] = 33554432] = "Merged"; + SymbolFlags[SymbolFlags["Transient"] = 67108864] = "Transient"; + SymbolFlags[SymbolFlags["Prototype"] = 134217728] = "Prototype"; + SymbolFlags[SymbolFlags["SyntheticProperty"] = 268435456] = "SyntheticProperty"; + SymbolFlags[SymbolFlags["Optional"] = 536870912] = "Optional"; + SymbolFlags[SymbolFlags["ExportStar"] = 1073741824] = "ExportStar"; + SymbolFlags[SymbolFlags["Enum"] = 384] = "Enum"; + SymbolFlags[SymbolFlags["Variable"] = 3] = "Variable"; + SymbolFlags[SymbolFlags["Value"] = 107455] = "Value"; + SymbolFlags[SymbolFlags["Type"] = 793064] = "Type"; + SymbolFlags[SymbolFlags["Namespace"] = 1920] = "Namespace"; + SymbolFlags[SymbolFlags["Module"] = 1536] = "Module"; + SymbolFlags[SymbolFlags["Accessor"] = 98304] = "Accessor"; + SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 107454] = "FunctionScopedVariableExcludes"; + SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 107455] = "BlockScopedVariableExcludes"; + SymbolFlags[SymbolFlags["ParameterExcludes"] = 107455] = "ParameterExcludes"; + SymbolFlags[SymbolFlags["PropertyExcludes"] = 0] = "PropertyExcludes"; + SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 900095] = "EnumMemberExcludes"; + SymbolFlags[SymbolFlags["FunctionExcludes"] = 106927] = "FunctionExcludes"; + SymbolFlags[SymbolFlags["ClassExcludes"] = 899519] = "ClassExcludes"; + SymbolFlags[SymbolFlags["InterfaceExcludes"] = 792968] = "InterfaceExcludes"; + SymbolFlags[SymbolFlags["RegularEnumExcludes"] = 899327] = "RegularEnumExcludes"; + SymbolFlags[SymbolFlags["ConstEnumExcludes"] = 899967] = "ConstEnumExcludes"; + SymbolFlags[SymbolFlags["ValueModuleExcludes"] = 106639] = "ValueModuleExcludes"; + SymbolFlags[SymbolFlags["NamespaceModuleExcludes"] = 0] = "NamespaceModuleExcludes"; + SymbolFlags[SymbolFlags["MethodExcludes"] = 99263] = "MethodExcludes"; + SymbolFlags[SymbolFlags["GetAccessorExcludes"] = 41919] = "GetAccessorExcludes"; + SymbolFlags[SymbolFlags["SetAccessorExcludes"] = 74687] = "SetAccessorExcludes"; + SymbolFlags[SymbolFlags["TypeParameterExcludes"] = 530920] = "TypeParameterExcludes"; + SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 793064] = "TypeAliasExcludes"; + SymbolFlags[SymbolFlags["AliasExcludes"] = 8388608] = "AliasExcludes"; + SymbolFlags[SymbolFlags["ModuleMember"] = 8914931] = "ModuleMember"; + SymbolFlags[SymbolFlags["ExportHasLocal"] = 944] = "ExportHasLocal"; + SymbolFlags[SymbolFlags["HasExports"] = 1952] = "HasExports"; + SymbolFlags[SymbolFlags["HasMembers"] = 6240] = "HasMembers"; + SymbolFlags[SymbolFlags["BlockScoped"] = 418] = "BlockScoped"; + SymbolFlags[SymbolFlags["PropertyOrAccessor"] = 98308] = "PropertyOrAccessor"; + SymbolFlags[SymbolFlags["Export"] = 7340032] = "Export"; + SymbolFlags[SymbolFlags["ClassMember"] = 106500] = "ClassMember"; + SymbolFlags[SymbolFlags["Classifiable"] = 788448] = "Classifiable"; + })(ts.SymbolFlags || (ts.SymbolFlags = {})); + var SymbolFlags = ts.SymbolFlags; + (function (NodeCheckFlags) { + NodeCheckFlags[NodeCheckFlags["TypeChecked"] = 1] = "TypeChecked"; + NodeCheckFlags[NodeCheckFlags["LexicalThis"] = 2] = "LexicalThis"; + NodeCheckFlags[NodeCheckFlags["CaptureThis"] = 4] = "CaptureThis"; + NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 256] = "SuperInstance"; + NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 512] = "SuperStatic"; + NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 1024] = "ContextChecked"; + NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuper"] = 2048] = "AsyncMethodWithSuper"; + NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuperBinding"] = 4096] = "AsyncMethodWithSuperBinding"; + NodeCheckFlags[NodeCheckFlags["CaptureArguments"] = 8192] = "CaptureArguments"; + NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 16384] = "EnumValuesComputed"; + NodeCheckFlags[NodeCheckFlags["LexicalModuleMergesWithClass"] = 32768] = "LexicalModuleMergesWithClass"; + NodeCheckFlags[NodeCheckFlags["LoopWithCapturedBlockScopedBinding"] = 65536] = "LoopWithCapturedBlockScopedBinding"; + NodeCheckFlags[NodeCheckFlags["CapturedBlockScopedBinding"] = 131072] = "CapturedBlockScopedBinding"; + NodeCheckFlags[NodeCheckFlags["BlockScopedBindingInLoop"] = 262144] = "BlockScopedBindingInLoop"; + NodeCheckFlags[NodeCheckFlags["ClassWithBodyScopedClassBinding"] = 524288] = "ClassWithBodyScopedClassBinding"; + NodeCheckFlags[NodeCheckFlags["BodyScopedClassBinding"] = 1048576] = "BodyScopedClassBinding"; + NodeCheckFlags[NodeCheckFlags["NeedsLoopOutParameter"] = 2097152] = "NeedsLoopOutParameter"; + NodeCheckFlags[NodeCheckFlags["AssignmentsMarked"] = 4194304] = "AssignmentsMarked"; + NodeCheckFlags[NodeCheckFlags["ClassWithConstructorReference"] = 8388608] = "ClassWithConstructorReference"; + NodeCheckFlags[NodeCheckFlags["ConstructorReferenceInClass"] = 16777216] = "ConstructorReferenceInClass"; + })(ts.NodeCheckFlags || (ts.NodeCheckFlags = {})); + var NodeCheckFlags = ts.NodeCheckFlags; + (function (TypeFlags) { + TypeFlags[TypeFlags["Any"] = 1] = "Any"; + TypeFlags[TypeFlags["String"] = 2] = "String"; + TypeFlags[TypeFlags["Number"] = 4] = "Number"; + TypeFlags[TypeFlags["Boolean"] = 8] = "Boolean"; + TypeFlags[TypeFlags["Enum"] = 16] = "Enum"; + TypeFlags[TypeFlags["StringLiteral"] = 32] = "StringLiteral"; + TypeFlags[TypeFlags["NumberLiteral"] = 64] = "NumberLiteral"; + TypeFlags[TypeFlags["BooleanLiteral"] = 128] = "BooleanLiteral"; + TypeFlags[TypeFlags["EnumLiteral"] = 256] = "EnumLiteral"; + TypeFlags[TypeFlags["ESSymbol"] = 512] = "ESSymbol"; + TypeFlags[TypeFlags["Void"] = 1024] = "Void"; + TypeFlags[TypeFlags["Undefined"] = 2048] = "Undefined"; + TypeFlags[TypeFlags["Null"] = 4096] = "Null"; + TypeFlags[TypeFlags["Never"] = 8192] = "Never"; + TypeFlags[TypeFlags["TypeParameter"] = 16384] = "TypeParameter"; + TypeFlags[TypeFlags["Class"] = 32768] = "Class"; + TypeFlags[TypeFlags["Interface"] = 65536] = "Interface"; + TypeFlags[TypeFlags["Reference"] = 131072] = "Reference"; + TypeFlags[TypeFlags["Tuple"] = 262144] = "Tuple"; + TypeFlags[TypeFlags["Union"] = 524288] = "Union"; + TypeFlags[TypeFlags["Intersection"] = 1048576] = "Intersection"; + TypeFlags[TypeFlags["Anonymous"] = 2097152] = "Anonymous"; + TypeFlags[TypeFlags["Instantiated"] = 4194304] = "Instantiated"; + TypeFlags[TypeFlags["ObjectLiteral"] = 8388608] = "ObjectLiteral"; + TypeFlags[TypeFlags["FreshLiteral"] = 16777216] = "FreshLiteral"; + TypeFlags[TypeFlags["ContainsWideningType"] = 33554432] = "ContainsWideningType"; + TypeFlags[TypeFlags["ContainsObjectLiteral"] = 67108864] = "ContainsObjectLiteral"; + TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 134217728] = "ContainsAnyFunctionType"; + TypeFlags[TypeFlags["Nullable"] = 6144] = "Nullable"; + TypeFlags[TypeFlags["Literal"] = 480] = "Literal"; + TypeFlags[TypeFlags["StringOrNumberLiteral"] = 96] = "StringOrNumberLiteral"; + TypeFlags[TypeFlags["DefinitelyFalsy"] = 7392] = "DefinitelyFalsy"; + TypeFlags[TypeFlags["PossiblyFalsy"] = 7406] = "PossiblyFalsy"; + TypeFlags[TypeFlags["Intrinsic"] = 16015] = "Intrinsic"; + TypeFlags[TypeFlags["Primitive"] = 8190] = "Primitive"; + TypeFlags[TypeFlags["StringLike"] = 34] = "StringLike"; + TypeFlags[TypeFlags["NumberLike"] = 340] = "NumberLike"; + TypeFlags[TypeFlags["BooleanLike"] = 136] = "BooleanLike"; + TypeFlags[TypeFlags["EnumLike"] = 272] = "EnumLike"; + TypeFlags[TypeFlags["ObjectType"] = 2588672] = "ObjectType"; + TypeFlags[TypeFlags["UnionOrIntersection"] = 1572864] = "UnionOrIntersection"; + TypeFlags[TypeFlags["StructuredType"] = 4161536] = "StructuredType"; + TypeFlags[TypeFlags["StructuredOrTypeParameter"] = 4177920] = "StructuredOrTypeParameter"; + TypeFlags[TypeFlags["Narrowable"] = 4178943] = "Narrowable"; + TypeFlags[TypeFlags["NotUnionOrUnit"] = 2589185] = "NotUnionOrUnit"; + TypeFlags[TypeFlags["RequiresWidening"] = 100663296] = "RequiresWidening"; + TypeFlags[TypeFlags["PropagatingFlags"] = 234881024] = "PropagatingFlags"; + })(ts.TypeFlags || (ts.TypeFlags = {})); + var TypeFlags = ts.TypeFlags; + (function (SignatureKind) { + SignatureKind[SignatureKind["Call"] = 0] = "Call"; + SignatureKind[SignatureKind["Construct"] = 1] = "Construct"; + })(ts.SignatureKind || (ts.SignatureKind = {})); + var SignatureKind = ts.SignatureKind; + (function (IndexKind) { + IndexKind[IndexKind["String"] = 0] = "String"; + IndexKind[IndexKind["Number"] = 1] = "Number"; + })(ts.IndexKind || (ts.IndexKind = {})); + var IndexKind = ts.IndexKind; + (function (SpecialPropertyAssignmentKind) { + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["None"] = 0] = "None"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ExportsProperty"] = 1] = "ExportsProperty"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ModuleExports"] = 2] = "ModuleExports"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["PrototypeProperty"] = 3] = "PrototypeProperty"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ThisProperty"] = 4] = "ThisProperty"; + })(ts.SpecialPropertyAssignmentKind || (ts.SpecialPropertyAssignmentKind = {})); + var SpecialPropertyAssignmentKind = ts.SpecialPropertyAssignmentKind; (function (DiagnosticCategory) { DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; @@ -58,10 +662,267 @@ var ts; ModuleKind[ModuleKind["AMD"] = 2] = "AMD"; ModuleKind[ModuleKind["UMD"] = 3] = "UMD"; ModuleKind[ModuleKind["System"] = 4] = "System"; - ModuleKind[ModuleKind["ES6"] = 5] = "ES6"; ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015"; })(ts.ModuleKind || (ts.ModuleKind = {})); var ModuleKind = ts.ModuleKind; + (function (JsxEmit) { + JsxEmit[JsxEmit["None"] = 0] = "None"; + JsxEmit[JsxEmit["Preserve"] = 1] = "Preserve"; + JsxEmit[JsxEmit["React"] = 2] = "React"; + })(ts.JsxEmit || (ts.JsxEmit = {})); + var JsxEmit = ts.JsxEmit; + (function (NewLineKind) { + NewLineKind[NewLineKind["CarriageReturnLineFeed"] = 0] = "CarriageReturnLineFeed"; + NewLineKind[NewLineKind["LineFeed"] = 1] = "LineFeed"; + })(ts.NewLineKind || (ts.NewLineKind = {})); + var NewLineKind = ts.NewLineKind; + (function (ScriptKind) { + ScriptKind[ScriptKind["Unknown"] = 0] = "Unknown"; + ScriptKind[ScriptKind["JS"] = 1] = "JS"; + ScriptKind[ScriptKind["JSX"] = 2] = "JSX"; + ScriptKind[ScriptKind["TS"] = 3] = "TS"; + ScriptKind[ScriptKind["TSX"] = 4] = "TSX"; + })(ts.ScriptKind || (ts.ScriptKind = {})); + var ScriptKind = ts.ScriptKind; + (function (ScriptTarget) { + ScriptTarget[ScriptTarget["ES3"] = 0] = "ES3"; + ScriptTarget[ScriptTarget["ES5"] = 1] = "ES5"; + ScriptTarget[ScriptTarget["ES2015"] = 2] = "ES2015"; + ScriptTarget[ScriptTarget["ES2016"] = 3] = "ES2016"; + ScriptTarget[ScriptTarget["ES2017"] = 4] = "ES2017"; + ScriptTarget[ScriptTarget["Latest"] = 4] = "Latest"; + })(ts.ScriptTarget || (ts.ScriptTarget = {})); + var ScriptTarget = ts.ScriptTarget; + (function (LanguageVariant) { + LanguageVariant[LanguageVariant["Standard"] = 0] = "Standard"; + LanguageVariant[LanguageVariant["JSX"] = 1] = "JSX"; + })(ts.LanguageVariant || (ts.LanguageVariant = {})); + var LanguageVariant = ts.LanguageVariant; + (function (DiagnosticStyle) { + DiagnosticStyle[DiagnosticStyle["Simple"] = 0] = "Simple"; + DiagnosticStyle[DiagnosticStyle["Pretty"] = 1] = "Pretty"; + })(ts.DiagnosticStyle || (ts.DiagnosticStyle = {})); + var DiagnosticStyle = ts.DiagnosticStyle; + (function (WatchDirectoryFlags) { + WatchDirectoryFlags[WatchDirectoryFlags["None"] = 0] = "None"; + WatchDirectoryFlags[WatchDirectoryFlags["Recursive"] = 1] = "Recursive"; + })(ts.WatchDirectoryFlags || (ts.WatchDirectoryFlags = {})); + var WatchDirectoryFlags = ts.WatchDirectoryFlags; + (function (CharacterCodes) { + CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; + CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 127] = "maxAsciiCharacter"; + CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed"; + CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn"; + CharacterCodes[CharacterCodes["lineSeparator"] = 8232] = "lineSeparator"; + CharacterCodes[CharacterCodes["paragraphSeparator"] = 8233] = "paragraphSeparator"; + CharacterCodes[CharacterCodes["nextLine"] = 133] = "nextLine"; + CharacterCodes[CharacterCodes["space"] = 32] = "space"; + CharacterCodes[CharacterCodes["nonBreakingSpace"] = 160] = "nonBreakingSpace"; + CharacterCodes[CharacterCodes["enQuad"] = 8192] = "enQuad"; + CharacterCodes[CharacterCodes["emQuad"] = 8193] = "emQuad"; + CharacterCodes[CharacterCodes["enSpace"] = 8194] = "enSpace"; + CharacterCodes[CharacterCodes["emSpace"] = 8195] = "emSpace"; + CharacterCodes[CharacterCodes["threePerEmSpace"] = 8196] = "threePerEmSpace"; + CharacterCodes[CharacterCodes["fourPerEmSpace"] = 8197] = "fourPerEmSpace"; + CharacterCodes[CharacterCodes["sixPerEmSpace"] = 8198] = "sixPerEmSpace"; + CharacterCodes[CharacterCodes["figureSpace"] = 8199] = "figureSpace"; + CharacterCodes[CharacterCodes["punctuationSpace"] = 8200] = "punctuationSpace"; + CharacterCodes[CharacterCodes["thinSpace"] = 8201] = "thinSpace"; + CharacterCodes[CharacterCodes["hairSpace"] = 8202] = "hairSpace"; + CharacterCodes[CharacterCodes["zeroWidthSpace"] = 8203] = "zeroWidthSpace"; + CharacterCodes[CharacterCodes["narrowNoBreakSpace"] = 8239] = "narrowNoBreakSpace"; + CharacterCodes[CharacterCodes["ideographicSpace"] = 12288] = "ideographicSpace"; + CharacterCodes[CharacterCodes["mathematicalSpace"] = 8287] = "mathematicalSpace"; + CharacterCodes[CharacterCodes["ogham"] = 5760] = "ogham"; + CharacterCodes[CharacterCodes["_"] = 95] = "_"; + CharacterCodes[CharacterCodes["$"] = 36] = "$"; + CharacterCodes[CharacterCodes["_0"] = 48] = "_0"; + CharacterCodes[CharacterCodes["_1"] = 49] = "_1"; + CharacterCodes[CharacterCodes["_2"] = 50] = "_2"; + CharacterCodes[CharacterCodes["_3"] = 51] = "_3"; + CharacterCodes[CharacterCodes["_4"] = 52] = "_4"; + CharacterCodes[CharacterCodes["_5"] = 53] = "_5"; + CharacterCodes[CharacterCodes["_6"] = 54] = "_6"; + CharacterCodes[CharacterCodes["_7"] = 55] = "_7"; + CharacterCodes[CharacterCodes["_8"] = 56] = "_8"; + CharacterCodes[CharacterCodes["_9"] = 57] = "_9"; + CharacterCodes[CharacterCodes["a"] = 97] = "a"; + CharacterCodes[CharacterCodes["b"] = 98] = "b"; + CharacterCodes[CharacterCodes["c"] = 99] = "c"; + CharacterCodes[CharacterCodes["d"] = 100] = "d"; + CharacterCodes[CharacterCodes["e"] = 101] = "e"; + CharacterCodes[CharacterCodes["f"] = 102] = "f"; + CharacterCodes[CharacterCodes["g"] = 103] = "g"; + CharacterCodes[CharacterCodes["h"] = 104] = "h"; + CharacterCodes[CharacterCodes["i"] = 105] = "i"; + CharacterCodes[CharacterCodes["j"] = 106] = "j"; + CharacterCodes[CharacterCodes["k"] = 107] = "k"; + CharacterCodes[CharacterCodes["l"] = 108] = "l"; + CharacterCodes[CharacterCodes["m"] = 109] = "m"; + CharacterCodes[CharacterCodes["n"] = 110] = "n"; + CharacterCodes[CharacterCodes["o"] = 111] = "o"; + CharacterCodes[CharacterCodes["p"] = 112] = "p"; + CharacterCodes[CharacterCodes["q"] = 113] = "q"; + CharacterCodes[CharacterCodes["r"] = 114] = "r"; + CharacterCodes[CharacterCodes["s"] = 115] = "s"; + CharacterCodes[CharacterCodes["t"] = 116] = "t"; + CharacterCodes[CharacterCodes["u"] = 117] = "u"; + CharacterCodes[CharacterCodes["v"] = 118] = "v"; + CharacterCodes[CharacterCodes["w"] = 119] = "w"; + CharacterCodes[CharacterCodes["x"] = 120] = "x"; + CharacterCodes[CharacterCodes["y"] = 121] = "y"; + CharacterCodes[CharacterCodes["z"] = 122] = "z"; + CharacterCodes[CharacterCodes["A"] = 65] = "A"; + CharacterCodes[CharacterCodes["B"] = 66] = "B"; + CharacterCodes[CharacterCodes["C"] = 67] = "C"; + CharacterCodes[CharacterCodes["D"] = 68] = "D"; + CharacterCodes[CharacterCodes["E"] = 69] = "E"; + CharacterCodes[CharacterCodes["F"] = 70] = "F"; + CharacterCodes[CharacterCodes["G"] = 71] = "G"; + CharacterCodes[CharacterCodes["H"] = 72] = "H"; + CharacterCodes[CharacterCodes["I"] = 73] = "I"; + CharacterCodes[CharacterCodes["J"] = 74] = "J"; + CharacterCodes[CharacterCodes["K"] = 75] = "K"; + CharacterCodes[CharacterCodes["L"] = 76] = "L"; + CharacterCodes[CharacterCodes["M"] = 77] = "M"; + CharacterCodes[CharacterCodes["N"] = 78] = "N"; + CharacterCodes[CharacterCodes["O"] = 79] = "O"; + CharacterCodes[CharacterCodes["P"] = 80] = "P"; + CharacterCodes[CharacterCodes["Q"] = 81] = "Q"; + CharacterCodes[CharacterCodes["R"] = 82] = "R"; + CharacterCodes[CharacterCodes["S"] = 83] = "S"; + CharacterCodes[CharacterCodes["T"] = 84] = "T"; + CharacterCodes[CharacterCodes["U"] = 85] = "U"; + CharacterCodes[CharacterCodes["V"] = 86] = "V"; + CharacterCodes[CharacterCodes["W"] = 87] = "W"; + CharacterCodes[CharacterCodes["X"] = 88] = "X"; + CharacterCodes[CharacterCodes["Y"] = 89] = "Y"; + CharacterCodes[CharacterCodes["Z"] = 90] = "Z"; + CharacterCodes[CharacterCodes["ampersand"] = 38] = "ampersand"; + CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk"; + CharacterCodes[CharacterCodes["at"] = 64] = "at"; + CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash"; + CharacterCodes[CharacterCodes["backtick"] = 96] = "backtick"; + CharacterCodes[CharacterCodes["bar"] = 124] = "bar"; + CharacterCodes[CharacterCodes["caret"] = 94] = "caret"; + CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace"; + CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket"; + CharacterCodes[CharacterCodes["closeParen"] = 41] = "closeParen"; + CharacterCodes[CharacterCodes["colon"] = 58] = "colon"; + CharacterCodes[CharacterCodes["comma"] = 44] = "comma"; + CharacterCodes[CharacterCodes["dot"] = 46] = "dot"; + CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote"; + CharacterCodes[CharacterCodes["equals"] = 61] = "equals"; + CharacterCodes[CharacterCodes["exclamation"] = 33] = "exclamation"; + CharacterCodes[CharacterCodes["greaterThan"] = 62] = "greaterThan"; + CharacterCodes[CharacterCodes["hash"] = 35] = "hash"; + CharacterCodes[CharacterCodes["lessThan"] = 60] = "lessThan"; + CharacterCodes[CharacterCodes["minus"] = 45] = "minus"; + CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace"; + CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket"; + CharacterCodes[CharacterCodes["openParen"] = 40] = "openParen"; + CharacterCodes[CharacterCodes["percent"] = 37] = "percent"; + CharacterCodes[CharacterCodes["plus"] = 43] = "plus"; + CharacterCodes[CharacterCodes["question"] = 63] = "question"; + CharacterCodes[CharacterCodes["semicolon"] = 59] = "semicolon"; + CharacterCodes[CharacterCodes["singleQuote"] = 39] = "singleQuote"; + CharacterCodes[CharacterCodes["slash"] = 47] = "slash"; + CharacterCodes[CharacterCodes["tilde"] = 126] = "tilde"; + CharacterCodes[CharacterCodes["backspace"] = 8] = "backspace"; + CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed"; + CharacterCodes[CharacterCodes["byteOrderMark"] = 65279] = "byteOrderMark"; + CharacterCodes[CharacterCodes["tab"] = 9] = "tab"; + CharacterCodes[CharacterCodes["verticalTab"] = 11] = "verticalTab"; + })(ts.CharacterCodes || (ts.CharacterCodes = {})); + var CharacterCodes = ts.CharacterCodes; + (function (TransformFlags) { + TransformFlags[TransformFlags["None"] = 0] = "None"; + TransformFlags[TransformFlags["TypeScript"] = 1] = "TypeScript"; + TransformFlags[TransformFlags["ContainsTypeScript"] = 2] = "ContainsTypeScript"; + TransformFlags[TransformFlags["Jsx"] = 4] = "Jsx"; + TransformFlags[TransformFlags["ContainsJsx"] = 8] = "ContainsJsx"; + TransformFlags[TransformFlags["ES2017"] = 16] = "ES2017"; + TransformFlags[TransformFlags["ContainsES2017"] = 32] = "ContainsES2017"; + TransformFlags[TransformFlags["ES2016"] = 64] = "ES2016"; + TransformFlags[TransformFlags["ContainsES2016"] = 128] = "ContainsES2016"; + TransformFlags[TransformFlags["ES2015"] = 256] = "ES2015"; + TransformFlags[TransformFlags["ContainsES2015"] = 512] = "ContainsES2015"; + TransformFlags[TransformFlags["DestructuringAssignment"] = 1024] = "DestructuringAssignment"; + TransformFlags[TransformFlags["Generator"] = 2048] = "Generator"; + TransformFlags[TransformFlags["ContainsGenerator"] = 4096] = "ContainsGenerator"; + TransformFlags[TransformFlags["ContainsDecorators"] = 8192] = "ContainsDecorators"; + TransformFlags[TransformFlags["ContainsPropertyInitializer"] = 16384] = "ContainsPropertyInitializer"; + TransformFlags[TransformFlags["ContainsLexicalThis"] = 32768] = "ContainsLexicalThis"; + TransformFlags[TransformFlags["ContainsCapturedLexicalThis"] = 65536] = "ContainsCapturedLexicalThis"; + TransformFlags[TransformFlags["ContainsLexicalThisInComputedPropertyName"] = 131072] = "ContainsLexicalThisInComputedPropertyName"; + TransformFlags[TransformFlags["ContainsDefaultValueAssignments"] = 262144] = "ContainsDefaultValueAssignments"; + TransformFlags[TransformFlags["ContainsParameterPropertyAssignments"] = 524288] = "ContainsParameterPropertyAssignments"; + TransformFlags[TransformFlags["ContainsSpreadElementExpression"] = 1048576] = "ContainsSpreadElementExpression"; + TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 2097152] = "ContainsComputedPropertyName"; + TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 4194304] = "ContainsBlockScopedBinding"; + TransformFlags[TransformFlags["ContainsBindingPattern"] = 8388608] = "ContainsBindingPattern"; + TransformFlags[TransformFlags["ContainsYield"] = 16777216] = "ContainsYield"; + TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 33554432] = "ContainsHoistedDeclarationOrCompletion"; + TransformFlags[TransformFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; + TransformFlags[TransformFlags["AssertTypeScript"] = 3] = "AssertTypeScript"; + TransformFlags[TransformFlags["AssertJsx"] = 12] = "AssertJsx"; + TransformFlags[TransformFlags["AssertES2017"] = 48] = "AssertES2017"; + TransformFlags[TransformFlags["AssertES2016"] = 192] = "AssertES2016"; + TransformFlags[TransformFlags["AssertES2015"] = 768] = "AssertES2015"; + TransformFlags[TransformFlags["AssertGenerator"] = 6144] = "AssertGenerator"; + TransformFlags[TransformFlags["NodeExcludes"] = 536874325] = "NodeExcludes"; + TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 592227669] = "ArrowFunctionExcludes"; + TransformFlags[TransformFlags["FunctionExcludes"] = 592293205] = "FunctionExcludes"; + TransformFlags[TransformFlags["ConstructorExcludes"] = 591760725] = "ConstructorExcludes"; + TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 591760725] = "MethodOrAccessorExcludes"; + TransformFlags[TransformFlags["ClassExcludes"] = 539749717] = "ClassExcludes"; + TransformFlags[TransformFlags["ModuleExcludes"] = 574729557] = "ModuleExcludes"; + TransformFlags[TransformFlags["TypeExcludes"] = -3] = "TypeExcludes"; + TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 539110741] = "ObjectLiteralExcludes"; + TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 537922901] = "ArrayLiteralOrCallOrNewExcludes"; + TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 545262933] = "VariableDeclarationListExcludes"; + TransformFlags[TransformFlags["ParameterExcludes"] = 545262933] = "ParameterExcludes"; + TransformFlags[TransformFlags["TypeScriptClassSyntaxMask"] = 548864] = "TypeScriptClassSyntaxMask"; + TransformFlags[TransformFlags["ES2015FunctionSyntaxMask"] = 327680] = "ES2015FunctionSyntaxMask"; + })(ts.TransformFlags || (ts.TransformFlags = {})); + var TransformFlags = ts.TransformFlags; + (function (EmitFlags) { + EmitFlags[EmitFlags["EmitEmitHelpers"] = 1] = "EmitEmitHelpers"; + EmitFlags[EmitFlags["EmitExportStar"] = 2] = "EmitExportStar"; + EmitFlags[EmitFlags["EmitSuperHelper"] = 4] = "EmitSuperHelper"; + EmitFlags[EmitFlags["EmitAdvancedSuperHelper"] = 8] = "EmitAdvancedSuperHelper"; + EmitFlags[EmitFlags["UMDDefine"] = 16] = "UMDDefine"; + EmitFlags[EmitFlags["SingleLine"] = 32] = "SingleLine"; + EmitFlags[EmitFlags["AdviseOnEmitNode"] = 64] = "AdviseOnEmitNode"; + EmitFlags[EmitFlags["NoSubstitution"] = 128] = "NoSubstitution"; + EmitFlags[EmitFlags["CapturesThis"] = 256] = "CapturesThis"; + EmitFlags[EmitFlags["NoLeadingSourceMap"] = 512] = "NoLeadingSourceMap"; + EmitFlags[EmitFlags["NoTrailingSourceMap"] = 1024] = "NoTrailingSourceMap"; + EmitFlags[EmitFlags["NoSourceMap"] = 1536] = "NoSourceMap"; + EmitFlags[EmitFlags["NoNestedSourceMaps"] = 2048] = "NoNestedSourceMaps"; + EmitFlags[EmitFlags["NoTokenLeadingSourceMaps"] = 4096] = "NoTokenLeadingSourceMaps"; + EmitFlags[EmitFlags["NoTokenTrailingSourceMaps"] = 8192] = "NoTokenTrailingSourceMaps"; + EmitFlags[EmitFlags["NoTokenSourceMaps"] = 12288] = "NoTokenSourceMaps"; + EmitFlags[EmitFlags["NoLeadingComments"] = 16384] = "NoLeadingComments"; + EmitFlags[EmitFlags["NoTrailingComments"] = 32768] = "NoTrailingComments"; + EmitFlags[EmitFlags["NoComments"] = 49152] = "NoComments"; + EmitFlags[EmitFlags["NoNestedComments"] = 65536] = "NoNestedComments"; + EmitFlags[EmitFlags["ExportName"] = 131072] = "ExportName"; + EmitFlags[EmitFlags["LocalName"] = 262144] = "LocalName"; + EmitFlags[EmitFlags["Indented"] = 524288] = "Indented"; + EmitFlags[EmitFlags["NoIndentation"] = 1048576] = "NoIndentation"; + EmitFlags[EmitFlags["AsyncFunctionBody"] = 2097152] = "AsyncFunctionBody"; + EmitFlags[EmitFlags["ReuseTempVariableScope"] = 4194304] = "ReuseTempVariableScope"; + EmitFlags[EmitFlags["CustomPrologue"] = 8388608] = "CustomPrologue"; + })(ts.EmitFlags || (ts.EmitFlags = {})); + var EmitFlags = ts.EmitFlags; + (function (EmitContext) { + EmitContext[EmitContext["SourceFile"] = 0] = "SourceFile"; + EmitContext[EmitContext["Expression"] = 1] = "Expression"; + EmitContext[EmitContext["IdentifierName"] = 2] = "IdentifierName"; + EmitContext[EmitContext["Unspecified"] = 3] = "Unspecified"; + })(ts.EmitContext || (ts.EmitContext = {})); + var EmitContext = ts.EmitContext; })(ts || (ts = {})); var ts; (function (ts) { @@ -72,7 +933,7 @@ var ts; (function (performance) { var profilerEvent = typeof onProfilerEvent === "function" && onProfilerEvent.profiler === true ? onProfilerEvent - : function (markName) { }; + : function (_markName) { }; var enabled = false; var profilerStart = 0; var counts; @@ -124,7 +985,14 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + (function (Ternary) { + Ternary[Ternary["False"] = 0] = "False"; + Ternary[Ternary["Maybe"] = 1] = "Maybe"; + Ternary[Ternary["True"] = -1] = "True"; + })(ts.Ternary || (ts.Ternary = {})); + var Ternary = ts.Ternary; var createObject = Object.create; + ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; function createMap(template) { var map = createObject(null); map["__"] = undefined; @@ -145,7 +1013,7 @@ var ts; remove: remove, forEachValue: forEachValueInMap, getKeys: getKeys, - clear: clear + clear: clear, }; function forEachValueInMap(f) { for (var key in files) { @@ -187,6 +1055,12 @@ var ts; return getCanonicalFileName(nonCanonicalizedPath); } ts.toPath = toPath; + (function (Comparison) { + Comparison[Comparison["LessThan"] = -1] = "LessThan"; + Comparison[Comparison["EqualTo"] = 0] = "EqualTo"; + Comparison[Comparison["GreaterThan"] = 1] = "GreaterThan"; + })(ts.Comparison || (ts.Comparison = {})); + var Comparison = ts.Comparison; function forEach(array, callback) { if (array) { for (var i = 0, len = array.length; i < len; i++) { @@ -330,13 +1204,32 @@ var ts; if (array) { result = []; for (var i = 0; i < array.length; i++) { - var v = array[i]; - result.push(f(v, i)); + result.push(f(array[i], i)); } } return result; } ts.map = map; + function sameMap(array, f) { + var result; + if (array) { + for (var i = 0; i < array.length; i++) { + if (result) { + result.push(f(array[i], i)); + } + else { + var item = array[i]; + var mapped = f(item, i); + if (item !== mapped) { + result = array.slice(0, i); + result.push(mapped); + } + } + } + } + return result || array; + } + ts.sameMap = sameMap; function flatten(array) { var result; if (array) { @@ -437,6 +1330,18 @@ var ts; return result; } ts.mapObject = mapObject; + function some(array, predicate) { + if (array) { + for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { + var v = array_5[_i]; + if (!predicate || predicate(v)) { + return true; + } + } + } + return false; + } + ts.some = some; function concatenate(array1, array2) { if (!array2 || !array2.length) return array1; @@ -449,8 +1354,8 @@ var ts; var result; if (array) { result = []; - loop: for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { - var item = array_5[_i]; + loop: for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { + var item = array_6[_i]; for (var _a = 0, result_1 = result; _a < result_1.length; _a++) { var res = result_1[_a]; if (areEqual ? areEqual(res, item) : res === item) { @@ -483,8 +1388,8 @@ var ts; ts.compact = compact; function sum(array, prop) { var result = 0; - for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { - var v = array_6[_i]; + for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { + var v = array_7[_i]; result += v[prop]; } return result; @@ -703,8 +1608,8 @@ var ts; ts.equalOwnProperties = equalOwnProperties; function arrayToMap(array, makeKey, makeValue) { var result = createMap(); - for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { - var value = array_7[_i]; + for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { + var value = array_8[_i]; result[makeKey(value)] = makeValue ? makeValue(value) : value; } return result; @@ -805,7 +1710,7 @@ var ts; return function (t) { return compose(a(t)); }; } else { - return function (t) { return function (u) { return u; }; }; + return function (_) { return function (u) { return u; }; }; } } ts.chain = chain; @@ -836,7 +1741,7 @@ var ts; ts.compose = compose; function formatStringFromArgs(text, args, baseIndex) { baseIndex = baseIndex || 0; - return text.replace(/{(\d+)}/g, function (match, index) { return args[+index + baseIndex]; }); + return text.replace(/{(\d+)}/g, function (_match, index) { return args[+index + baseIndex]; }); } ts.localizedDiagnosticMessages = undefined; function getLocaleSpecificMessage(message) { @@ -861,11 +1766,11 @@ var ts; length: length, messageText: text, category: message.category, - code: message.code + code: message.code, }; } ts.createFileDiagnostic = createFileDiagnostic; - function formatMessage(dummy, message) { + function formatMessage(_dummy, message) { var text = getLocaleSpecificMessage(message); if (arguments.length > 2) { text = formatStringFromArgs(text, arguments, 2); @@ -928,7 +1833,7 @@ var ts; if (b === undefined) return 1; if (ignoreCase) { - if (String.prototype.localeCompare) { + if (ts.collator && String.prototype.localeCompare) { var result = a.localeCompare(b, undefined, { usage: "sort", sensitivity: "accent" }); return result < 0 ? -1 : result > 0 ? 1 : 0; } @@ -1081,7 +1986,7 @@ var ts; function getEmitModuleKind(compilerOptions) { return typeof compilerOptions.module === "number" ? compilerOptions.module : - getEmitScriptTarget(compilerOptions) === 2 ? ts.ModuleKind.ES6 : ts.ModuleKind.CommonJS; + getEmitScriptTarget(compilerOptions) >= 2 ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS; } ts.getEmitModuleKind = getEmitModuleKind; function hasZeroOrOneAsteriskCharacter(str) { @@ -1378,7 +2283,7 @@ var ts; function replaceWildcardCharacter(match, singleAsteriskRegexFragment) { return match === "*" ? singleAsteriskRegexFragment : match === "?" ? "[^/]" : "\\" + match; } - function getFileMatcherPatterns(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory) { + function getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory) { path = normalizePath(path); currentDirectory = normalizePath(currentDirectory); var absolutePath = combinePaths(currentDirectory, path); @@ -1393,7 +2298,7 @@ var ts; function matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, getFileSystemEntries) { path = normalizePath(path); currentDirectory = normalizePath(currentDirectory); - var patterns = getFileMatcherPatterns(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory); + var patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory); var regexFlag = useCaseSensitiveFileNames ? "" : "i"; var includeFileRegex = patterns.includeFilePattern && new RegExp(patterns.includeFilePattern, regexFlag); var includeDirectoryRegex = patterns.includeDirectoryPattern && new RegExp(patterns.includeDirectoryPattern, regexFlag); @@ -1503,6 +2408,14 @@ var ts; return false; } ts.isSupportedSourceFileName = isSupportedSourceFileName; + (function (ExtensionPriority) { + ExtensionPriority[ExtensionPriority["TypeScriptFiles"] = 0] = "TypeScriptFiles"; + ExtensionPriority[ExtensionPriority["DeclarationAndJavaScriptFiles"] = 2] = "DeclarationAndJavaScriptFiles"; + ExtensionPriority[ExtensionPriority["Limit"] = 5] = "Limit"; + ExtensionPriority[ExtensionPriority["Highest"] = 0] = "Highest"; + ExtensionPriority[ExtensionPriority["Lowest"] = 2] = "Lowest"; + })(ts.ExtensionPriority || (ts.ExtensionPriority = {})); + var ExtensionPriority = ts.ExtensionPriority; function getExtensionPriority(path, supportedExtensions) { for (var i = supportedExtensions.length - 1; i >= 0; i--) { if (fileExtensionIs(path, supportedExtensions[i])) { @@ -1566,10 +2479,10 @@ var ts; this.name = name; this.declarations = undefined; } - function Type(checker, flags) { + function Type(_checker, flags) { this.flags = flags; } - function Signature(checker) { + function Signature() { } function Node(kind, pos, end) { this.id = 0; @@ -1591,6 +2504,13 @@ var ts; getTypeConstructor: function () { return Type; }, getSignatureConstructor: function () { return Signature; } }; + (function (AssertionLevel) { + AssertionLevel[AssertionLevel["None"] = 0] = "None"; + AssertionLevel[AssertionLevel["Normal"] = 1] = "Normal"; + AssertionLevel[AssertionLevel["Aggressive"] = 2] = "Aggressive"; + AssertionLevel[AssertionLevel["VeryAggressive"] = 3] = "VeryAggressive"; + })(ts.AssertionLevel || (ts.AssertionLevel = {})); + var AssertionLevel = ts.AssertionLevel; var Debug; (function (Debug) { Debug.currentAssertionLevel = 0; @@ -1903,7 +2823,7 @@ var ts; } var platform = _os.platform(); var useCaseSensitiveFileNames = isFileSystemCaseSensitive(); - function readFile(fileName, encoding) { + function readFile(fileName, _encoding) { if (!fileExists(fileName)) { return undefined; } @@ -1975,6 +2895,11 @@ var ts; function readDirectory(path, extensions, excludes, includes) { return ts.matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, process.cwd(), getAccessibleFileSystemEntries); } + var FileSystemEntryKind; + (function (FileSystemEntryKind) { + FileSystemEntryKind[FileSystemEntryKind["File"] = 0] = "File"; + FileSystemEntryKind[FileSystemEntryKind["Directory"] = 1] = "Directory"; + })(FileSystemEntryKind || (FileSystemEntryKind = {})); function fileSystemEntryExists(path, entryKind) { try { var stat = _fs.statSync(path); @@ -2116,7 +3041,7 @@ var ts; args: ChakraHost.args, useCaseSensitiveFileNames: !!ChakraHost.useCaseSensitiveFileNames, write: ChakraHost.echo, - readFile: function (path, encoding) { + readFile: function (path, _encoding) { return ChakraHost.readFile(path); }, writeFile: function (path, data, writeByteOrderMark) { @@ -2132,9 +3057,9 @@ var ts; getExecutingFilePath: function () { return ChakraHost.executingFile; }, getCurrentDirectory: function () { return ChakraHost.currentDirectory; }, getDirectories: ChakraHost.getDirectories, - getEnvironmentVariable: ChakraHost.getEnvironmentVariable || (function (name) { return ""; }), + getEnvironmentVariable: ChakraHost.getEnvironmentVariable || (function () { return ""; }), readDirectory: function (path, extensions, excludes, includes) { - var pattern = ts.getFileMatcherPatterns(path, extensions, excludes, includes, !!ChakraHost.useCaseSensitiveFileNames, ChakraHost.currentDirectory); + var pattern = ts.getFileMatcherPatterns(path, excludes, includes, !!ChakraHost.useCaseSensitiveFileNames, ChakraHost.currentDirectory); return ChakraHost.readDirectory(path, extensions, pattern.basePaths, pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern); }, exit: ChakraHost.quit, @@ -2922,7 +3847,7 @@ var ts; Binding_element_0_implicitly_has_an_1_type: { code: 7031, category: ts.DiagnosticCategory.Error, key: "Binding_element_0_implicitly_has_an_1_type_7031", message: "Binding element '{0}' implicitly has an '{1}' type." }, Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation: { code: 7032, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation_7032", message: "Property '{0}' implicitly has type 'any', because its set accessor lacks a parameter type annotation." }, Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation: { code: 7033, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation_7033", message: "Property '{0}' implicitly has type 'any', because its get accessor lacks a return type annotation." }, - Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined: { code: 7034, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined_7034", message: "Variable '{0}' implicitly has type 'any' in some locations where its type cannot be determined." }, + Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined: { code: 7034, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined_7034", message: "Variable '{0}' implicitly has type '{1}' in some locations where its type cannot be determined." }, You_cannot_rename_this_element: { code: 8000, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_this_element_8000", message: "You cannot rename this element." }, You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", message: "You cannot rename elements that are defined in the standard TypeScript library." }, import_can_only_be_used_in_a_ts_file: { code: 8002, category: ts.DiagnosticCategory.Error, key: "import_can_only_be_used_in_a_ts_file_8002", message: "'import ... =' can only be used in a .ts file." }, @@ -2959,139 +3884,139 @@ var ts; Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers" }, Implement_interface_on_reference: { code: 90005, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_reference_90005", message: "Implement interface on reference" }, Implement_interface_on_class: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_class_90006", message: "Implement interface on class" }, - Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" } + Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" }, }; })(ts || (ts = {})); var ts; (function (ts) { function tokenIsIdentifierOrKeyword(token) { - return token >= 69; + return token >= 70; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; var textToToken = ts.createMap({ - "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": 136, - "function": 87, - "get": 123, - "if": 88, - "implements": 106, - "import": 89, - "in": 90, - "instanceof": 91, - "interface": 107, - "is": 124, - "let": 108, - "module": 125, - "namespace": 126, - "never": 127, - "new": 92, - "null": 93, - "number": 130, - "package": 109, - "private": 110, - "protected": 111, - "public": 112, - "readonly": 128, - "require": 129, - "global": 137, - "return": 94, - "set": 131, - "static": 113, - "string": 132, - "super": 95, - "switch": 96, - "symbol": 133, - "this": 97, - "throw": 98, - "true": 99, - "try": 100, - "type": 134, - "typeof": 101, - "undefined": 135, - "var": 102, - "void": 103, - "while": 104, - "with": 105, - "yield": 114, - "async": 118, - "await": 119, - "of": 138, - "{": 15, - "}": 16, - "(": 17, - ")": 18, - "[": 19, - "]": 20, - ".": 21, - "...": 22, - ";": 23, - ",": 24, - "<": 25, - ">": 27, - "<=": 28, - ">=": 29, - "==": 30, - "!=": 31, - "===": 32, - "!==": 33, - "=>": 34, - "+": 35, - "-": 36, - "**": 38, - "*": 37, - "/": 39, - "%": 40, - "++": 41, - "--": 42, - "<<": 43, - ">": 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 + "abstract": 116, + "any": 118, + "as": 117, + "boolean": 121, + "break": 71, + "case": 72, + "catch": 73, + "class": 74, + "continue": 76, + "const": 75, + "constructor": 122, + "debugger": 77, + "declare": 123, + "default": 78, + "delete": 79, + "do": 80, + "else": 81, + "enum": 82, + "export": 83, + "extends": 84, + "false": 85, + "finally": 86, + "for": 87, + "from": 137, + "function": 88, + "get": 124, + "if": 89, + "implements": 107, + "import": 90, + "in": 91, + "instanceof": 92, + "interface": 108, + "is": 125, + "let": 109, + "module": 126, + "namespace": 127, + "never": 128, + "new": 93, + "null": 94, + "number": 131, + "package": 110, + "private": 111, + "protected": 112, + "public": 113, + "readonly": 129, + "require": 130, + "global": 138, + "return": 95, + "set": 132, + "static": 114, + "string": 133, + "super": 96, + "switch": 97, + "symbol": 134, + "this": 98, + "throw": 99, + "true": 100, + "try": 101, + "type": 135, + "typeof": 102, + "undefined": 136, + "var": 103, + "void": 104, + "while": 105, + "with": 106, + "yield": 115, + "async": 119, + "await": 120, + "of": 139, + "{": 16, + "}": 17, + "(": 18, + ")": 19, + "[": 20, + "]": 21, + ".": 22, + "...": 23, + ";": 24, + ",": 25, + "<": 26, + ">": 28, + "<=": 29, + ">=": 30, + "==": 31, + "!=": 32, + "===": 33, + "!==": 34, + "=>": 35, + "+": 36, + "-": 37, + "**": 39, + "*": 38, + "/": 40, + "%": 41, + "++": 42, + "--": 43, + "<<": 44, + ">": 45, + ">>>": 46, + "&": 47, + "|": 48, + "^": 49, + "!": 50, + "~": 51, + "&&": 52, + "||": 53, + "?": 54, + ":": 55, + "=": 57, + "+=": 58, + "-=": 59, + "*=": 60, + "**=": 61, + "/=": 62, + "%=": 63, + "<<=": 64, + ">>=": 65, + ">>>=": 66, + "&=": 67, + "|=": 68, + "^=": 69, + "@": 56, }); 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,]; @@ -3488,7 +4413,7 @@ var ts; return iterateCommentRanges(true, text, pos, true, cb, state, initial); } ts.reduceEachTrailingCommentRange = reduceEachTrailingCommentRange; - function appendCommentRange(pos, end, kind, hasTrailingNewLine, state, comments) { + function appendCommentRange(pos, end, kind, hasTrailingNewLine, _state, comments) { if (!comments) { comments = []; } @@ -3554,8 +4479,8 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 69 || token > 105; }, - isReservedWord: function () { return token >= 70 && token <= 105; }, + isIdentifier: function () { return token === 70 || token > 106; }, + isReservedWord: function () { return token >= 71 && token <= 106; }, isUnterminated: function () { return tokenIsUnterminated; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, @@ -3574,7 +4499,7 @@ var ts; setTextPos: setTextPos, tryScan: tryScan, lookAhead: lookAhead, - scanRange: scanRange + scanRange: scanRange, }; function error(message, length) { if (onError) { @@ -3691,20 +4616,20 @@ var ts; contents += text.substring(start, pos); tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 11 : 14; + resultingToken = startedWithBacktick ? 12 : 15; break; } var currChar = text.charCodeAt(pos); if (currChar === 96) { contents += text.substring(start, pos); pos++; - resultingToken = startedWithBacktick ? 11 : 14; + resultingToken = startedWithBacktick ? 12 : 15; break; } if (currChar === 36 && pos + 1 < end && text.charCodeAt(pos + 1) === 123) { contents += text.substring(start, pos); pos += 2; - resultingToken = startedWithBacktick ? 12 : 13; + resultingToken = startedWithBacktick ? 13 : 14; break; } if (currChar === 92) { @@ -3866,7 +4791,7 @@ var ts; return token = textToToken[tokenValue]; } } - return token = 69; + return token = 70; } function scanBinaryOrOctalDigits(base) { ts.Debug.assert(base === 2 || base === 8, "Expected either base 2 or base 8"); @@ -3941,12 +4866,12 @@ var ts; case 33: if (text.charCodeAt(pos + 1) === 61) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 33; + return pos += 3, token = 34; } - return pos += 2, token = 31; + return pos += 2, token = 32; } pos++; - return token = 49; + return token = 50; case 34: case 39: tokenValue = scanString(); @@ -3955,51 +4880,39 @@ var ts; return token = scanTemplateAndSetTokenValue(); case 37: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 62; + return pos += 2, token = 63; } pos++; - return token = 40; + return token = 41; case 38: if (text.charCodeAt(pos + 1) === 38) { - return pos += 2, token = 51; + return pos += 2, token = 52; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 66; + return pos += 2, token = 67; } pos++; - return token = 46; + return token = 47; case 40: pos++; - return token = 17; + return token = 18; case 41: pos++; - return token = 18; + return token = 19; case 42: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 59; + return pos += 2, token = 60; } if (text.charCodeAt(pos + 1) === 42) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 60; + return pos += 3, token = 61; } - return pos += 2, token = 38; + return pos += 2, token = 39; } pos++; - return token = 37; + return token = 38; case 43: if (text.charCodeAt(pos + 1) === 43) { - return pos += 2, token = 41; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 57; - } - pos++; - return token = 35; - case 44: - pos++; - return token = 24; - case 45: - if (text.charCodeAt(pos + 1) === 45) { return pos += 2, token = 42; } if (text.charCodeAt(pos + 1) === 61) { @@ -4007,16 +4920,28 @@ var ts; } pos++; return token = 36; + case 44: + pos++; + return token = 25; + case 45: + if (text.charCodeAt(pos + 1) === 45) { + return pos += 2, token = 43; + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 59; + } + pos++; + return token = 37; case 46: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = scanNumber(); return token = 8; } if (text.charCodeAt(pos + 1) === 46 && text.charCodeAt(pos + 2) === 46) { - return pos += 3, token = 22; + return pos += 3, token = 23; } pos++; - return token = 21; + return token = 22; case 47: if (text.charCodeAt(pos + 1) === 47) { pos += 2; @@ -4060,10 +4985,10 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 61; + return pos += 2, token = 62; } pos++; - return token = 39; + return token = 40; case 48: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 || text.charCodeAt(pos + 1) === 120)) { pos += 2; @@ -4112,10 +5037,10 @@ var ts; return token = 8; case 58: pos++; - return token = 54; + return token = 55; case 59: pos++; - return token = 23; + return token = 24; case 60: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -4128,20 +5053,20 @@ var ts; } if (text.charCodeAt(pos + 1) === 60) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 63; + return pos += 3, token = 64; } - return pos += 2, token = 43; + return pos += 2, token = 44; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 28; + return pos += 2, token = 29; } if (languageVariant === 1 && text.charCodeAt(pos + 1) === 47 && text.charCodeAt(pos + 2) !== 42) { - return pos += 2, token = 26; + return pos += 2, token = 27; } pos++; - return token = 25; + return token = 26; case 61: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -4154,15 +5079,15 @@ var ts; } if (text.charCodeAt(pos + 1) === 61) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 32; + return pos += 3, token = 33; } - return pos += 2, token = 30; + return pos += 2, token = 31; } if (text.charCodeAt(pos + 1) === 62) { - return pos += 2, token = 34; + return pos += 2, token = 35; } pos++; - return token = 56; + return token = 57; case 62: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -4174,43 +5099,43 @@ var ts; } } pos++; - return token = 27; + return token = 28; case 63: pos++; - return token = 53; + return token = 54; case 91: pos++; - return token = 19; + return token = 20; case 93: pos++; - return token = 20; + return token = 21; case 94: + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 69; + } + pos++; + return token = 49; + case 123: + pos++; + return token = 16; + case 124: + if (text.charCodeAt(pos + 1) === 124) { + return pos += 2, token = 53; + } if (text.charCodeAt(pos + 1) === 61) { return pos += 2, token = 68; } pos++; return token = 48; - case 123: - pos++; - return token = 15; - case 124: - if (text.charCodeAt(pos + 1) === 124) { - return pos += 2, token = 52; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 67; - } - pos++; - return token = 47; case 125: pos++; - return token = 16; + return token = 17; case 126: pos++; - return token = 50; + return token = 51; case 64: pos++; - return token = 55; + return token = 56; case 92: var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { @@ -4248,29 +5173,29 @@ var ts; } } function reScanGreaterToken() { - if (token === 27) { + if (token === 28) { if (text.charCodeAt(pos) === 62) { if (text.charCodeAt(pos + 1) === 62) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 65; + return pos += 3, token = 66; } - return pos += 2, token = 45; + return pos += 2, token = 46; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 64; + return pos += 2, token = 65; } pos++; - return token = 44; + return token = 45; } if (text.charCodeAt(pos) === 61) { pos++; - return token = 29; + return token = 30; } } return token; } function reScanSlashToken() { - if (token === 39 || token === 61) { + if (token === 40 || token === 62) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -4309,12 +5234,12 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 10; + token = 11; } return token; } function reScanTemplateToken() { - ts.Debug.assert(token === 16, "'reScanTemplateToken' should only be called on a '}'"); + ts.Debug.assert(token === 17, "'reScanTemplateToken' should only be called on a '}'"); pos = tokenPos; return token = scanTemplateAndSetTokenValue(); } @@ -4331,14 +5256,14 @@ var ts; if (char === 60) { if (text.charCodeAt(pos + 1) === 47) { pos += 2; - return token = 26; + return token = 27; } pos++; - return token = 25; + return token = 26; } if (char === 123) { pos++; - return token = 15; + return token = 16; } while (pos < end) { pos++; @@ -4347,7 +5272,7 @@ var ts; break; } } - return token = 244; + return token = 10; } function scanJsxIdentifier() { if (tokenIsIdentifierOrKeyword(token)) { @@ -4394,39 +5319,39 @@ var ts; return token = 5; case 64: pos++; - return token = 55; + return token = 56; case 10: case 13: pos++; return token = 4; case 42: pos++; - return token = 37; + return token = 38; case 123: pos++; - return token = 15; + return token = 16; case 125: pos++; - return token = 16; + return token = 17; case 91: pos++; - return token = 19; + return token = 20; case 93: pos++; - return token = 20; + return token = 21; case 61: pos++; - return token = 56; + return token = 57; case 44: pos++; - return token = 24; + return token = 25; } - if (isIdentifierStart(ch, 2)) { + if (isIdentifierStart(ch, 4)) { pos++; - while (isIdentifierPart(text.charCodeAt(pos), 2) && pos < end) { + while (isIdentifierPart(text.charCodeAt(pos), 4) && pos < end) { pos++; } - return token = 69; + return token = 70; } else { return pos += 1, token = 0; @@ -4647,11 +5572,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 199: - case 227: - case 206: + case 200: + case 228: case 207: case 208: + case 209: return true; } return false; @@ -4772,13 +5697,13 @@ var ts; switch (node.kind) { case 9: return getQuotedEscapedLiteralText('"', node.text, '"'); - case 11: - return getQuotedEscapedLiteralText("`", node.text, "`"); case 12: - return getQuotedEscapedLiteralText("`", node.text, "${"); + return getQuotedEscapedLiteralText("`", node.text, "`"); case 13: - return getQuotedEscapedLiteralText("}", node.text, "${"); + return getQuotedEscapedLiteralText("`", node.text, "${"); case 14: + return getQuotedEscapedLiteralText("}", node.text, "${"); + case 15: return getQuotedEscapedLiteralText("}", node.text, "`"); case 8: return node.text; @@ -4820,7 +5745,7 @@ var ts; } ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isAmbientModule(node) { - return node && node.kind === 225 && + return node && node.kind === 226 && (node.name.kind === 9 || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; @@ -4829,11 +5754,11 @@ var ts; } ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { - return node.kind === 225 && (!node.body); + return node.kind === 226 && (!node.body); } function isBlockScopedContainerTopLevel(node) { return node.kind === 256 || - node.kind === 225 || + node.kind === 226 || isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -4848,7 +5773,7 @@ var ts; switch (node.parent.kind) { case 256: return ts.isExternalModule(node.parent); - case 226: + case 227: return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -4857,21 +5782,21 @@ var ts; function isBlockScope(node, parentNode) { switch (node.kind) { case 256: - case 227: + case 228: case 252: - case 225: - case 206: + case 226: case 207: case 208: - case 148: - case 147: + case 209: case 149: + case 148: case 150: - case 220: - case 179: + case 151: + case 221: case 180: + case 181: return true; - case 199: + case 200: return parentNode && !isFunctionLike(parentNode); } return false; @@ -4889,7 +5814,7 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 218 && + declaration.kind === 219 && declaration.parent && declaration.parent.kind === 252; } @@ -4926,7 +5851,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 199) { + if (node.body && node.body.kind === 200) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -4944,23 +5869,23 @@ var ts; return ts.createTextSpan(0, 0); } return getSpanOfTokenAtPosition(sourceFile, pos_1); - case 218: - case 169: - case 221: - case 192: + case 219: + case 170: case 222: - case 225: - case 224: - case 255: - case 220: - case 179: - case 147: - case 149: - case 150: + case 193: case 223: + case 226: + case 225: + case 255: + case 221: + case 180: + case 148: + case 150: + case 151: + case 224: errorNode = node.name; break; - case 180: + case 181: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -4981,7 +5906,7 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 224 && isConst(node); + return node.kind === 225 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -4994,11 +5919,11 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 174 && n.expression.kind === 95; + return n.kind === 175 && n.expression.kind === 96; } ts.isSuperCall = isSuperCall; function isPrologueDirective(node) { - return node.kind === 202 && node.expression.kind === 9; + return node.kind === 203 && node.expression.kind === 9; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { @@ -5014,10 +5939,10 @@ var ts; } ts.getJsDocComments = getJsDocComments; function getJsDocCommentsFromText(node, text) { - var commentRanges = (node.kind === 142 || - node.kind === 141 || - node.kind === 179 || - node.kind === 180) ? + var commentRanges = (node.kind === 143 || + node.kind === 142 || + node.kind === 180 || + node.kind === 181) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : getLeadingCommentRangesOfNodeFromText(node, text); return ts.filter(commentRanges, isJsDocComment); @@ -5032,69 +5957,69 @@ var ts; ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (154 <= node.kind && node.kind <= 166) { + if (155 <= node.kind && node.kind <= 167) { return true; } switch (node.kind) { - case 117: - case 130: - case 132: - case 120: + case 118: + case 131: case 133: - case 135: - case 127: + case 121: + case 134: + case 136: + case 128: return true; - case 103: - return node.parent.kind !== 183; - case 194: + case 104: + return node.parent.kind !== 184; + case 195: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 69: - if (node.parent.kind === 139 && node.parent.right === node) { + case 70: + if (node.parent.kind === 140 && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 172 && node.parent.name === node) { + else if (node.parent.kind === 173 && node.parent.name === node) { node = node.parent; } - ts.Debug.assert(node.kind === 69 || node.kind === 139 || node.kind === 172, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); - case 139: - case 172: - case 97: + ts.Debug.assert(node.kind === 70 || node.kind === 140 || node.kind === 173, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + case 140: + case 173: + case 98: var parent_1 = node.parent; - if (parent_1.kind === 158) { + if (parent_1.kind === 159) { return false; } - if (154 <= parent_1.kind && parent_1.kind <= 166) { + if (155 <= parent_1.kind && parent_1.kind <= 167) { return true; } switch (parent_1.kind) { - case 194: + case 195: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 141: - return node === parent_1.constraint; - case 145: - case 144: case 142: - case 218: + return node === parent_1.constraint; + case 146: + case 145: + case 143: + case 219: return node === parent_1.type; - case 220: - case 179: + case 221: case 180: + case 181: + case 149: case 148: case 147: - case 146: - case 149: case 150: - return node === parent_1.type; case 151: + return node === parent_1.type; case 152: case 153: + case 154: return node === parent_1.type; - case 177: + case 178: return node === parent_1.type; - case 174: case 175: - return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; case 176: + return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; + case 177: return false; } } @@ -5105,22 +6030,22 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 211: + case 212: return visitor(node); - case 227: - case 199: - case 203: + case 228: + case 200: case 204: case 205: case 206: case 207: case 208: - case 212: + case 209: case 213: + case 214: case 249: case 250: - case 214: - case 216: + case 215: + case 217: case 252: return ts.forEachChild(node, traverse); } @@ -5131,23 +6056,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 190: + case 191: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 224: - case 222: case 225: case 223: - case 221: - case 192: + case 226: + case 224: + case 222: + case 193: return; default: if (isFunctionLike(node)) { var name_5 = node.name; - if (name_5 && name_5.kind === 140) { + if (name_5 && name_5.kind === 141) { traverse(name_5.expression); return; } @@ -5162,14 +6087,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 169: + case 170: case 255: - case 142: + case 143: case 253: + case 146: case 145: - case 144: case 254: - case 218: + case 219: return true; } } @@ -5177,11 +6102,11 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 149 || node.kind === 150); + return node && (node.kind === 150 || node.kind === 151); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 221 || node.kind === 192); + return node && (node.kind === 222 || node.kind === 193); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -5190,19 +6115,19 @@ var ts; ts.isFunctionLike = isFunctionLike; function isFunctionLikeKind(kind) { switch (kind) { - case 148: - case 179: - case 220: - case 180: - case 147: - case 146: case 149: + case 180: + case 221: + case 181: + case 148: + case 147: case 150: case 151: case 152: case 153: - case 156: + case 154: case 157: + case 158: return true; } return false; @@ -5210,13 +6135,13 @@ var ts; ts.isFunctionLikeKind = isFunctionLikeKind; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 147: - case 146: case 148: + case 147: case 149: case 150: - case 220: - case 179: + case 151: + case 221: + case 180: return true; } return false; @@ -5224,30 +6149,30 @@ var ts; ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 206: case 207: case 208: - case 204: + case 209: case 205: + case 206: return true; - case 214: + case 215: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; function isFunctionBlock(node) { - return node && node.kind === 199 && isFunctionLike(node.parent); + return node && node.kind === 200 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 147 && node.parent.kind === 171; + return node && node.kind === 148 && node.parent.kind === 172; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 147 && - (node.parent.kind === 171 || - node.parent.kind === 192); + return node.kind === 148 && + (node.parent.kind === 172 || + node.parent.kind === 193); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -5283,38 +6208,38 @@ var ts; return undefined; } switch (node.kind) { - case 140: + case 141: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 143: - if (node.parent.kind === 142 && isClassElement(node.parent.parent)) { + case 144: + if (node.parent.kind === 143 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 180: + case 181: if (!includeArrowFunctions) { continue; } - case 220: - case 179: - case 225: - case 145: - case 144: - case 147: + case 221: + case 180: + case 226: case 146: + case 145: case 148: + case 147: case 149: case 150: case 151: case 152: case 153: - case 224: + case 154: + case 225: case 256: return node; } @@ -5328,25 +6253,25 @@ var ts; return node; } switch (node.kind) { - case 140: + case 141: node = node.parent; break; - case 220: - case 179: + case 221: case 180: + case 181: if (!stopOnFunctions) { continue; } - case 145: - case 144: - case 147: case 146: + case 145: case 148: + case 147: case 149: case 150: + case 151: return node; - case 143: - if (node.parent.kind === 142 && isClassElement(node.parent.parent)) { + case 144: + if (node.parent.kind === 143 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { @@ -5358,14 +6283,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 179 || func.kind === 180) { + if (func.kind === 180 || func.kind === 181) { var prev = func; var parent_2 = func.parent; - while (parent_2.kind === 178) { + while (parent_2.kind === 179) { prev = parent_2; parent_2 = parent_2.parent; } - if (parent_2.kind === 174 && parent_2.expression === prev) { + if (parent_2.kind === 175 && parent_2.expression === prev) { return parent_2; } } @@ -5373,20 +6298,20 @@ var ts; ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperProperty(node) { var kind = node.kind; - return (kind === 172 || kind === 173) - && node.expression.kind === 95; + return (kind === 173 || kind === 174) + && node.expression.kind === 96; } ts.isSuperProperty = isSuperProperty; function getEntityNameFromTypeNode(node) { if (node) { switch (node.kind) { - case 155: + case 156: return node.typeName; - case 194: + case 195: ts.Debug.assert(isEntityNameExpression(node.expression)); return node.expression; - case 69: - case 139: + case 70: + case 140: return node; } } @@ -5395,10 +6320,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function isCallLikeExpression(node) { switch (node.kind) { - case 174: case 175: case 176: - case 143: + case 177: + case 144: return true; default: return false; @@ -5406,7 +6331,7 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function getInvokedExpression(node) { - if (node.kind === 176) { + if (node.kind === 177) { return node.tag; } return node.expression; @@ -5414,21 +6339,21 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 221: + case 222: return true; - case 145: - return node.parent.kind === 221; - case 149: + case 146: + return node.parent.kind === 222; case 150: - case 147: + case 151: + case 148: return node.body !== undefined - && node.parent.kind === 221; - case 142: + && node.parent.kind === 222; + case 143: return node.parent.body !== undefined - && (node.parent.kind === 148 - || node.parent.kind === 147 - || node.parent.kind === 150) - && node.parent.parent.kind === 221; + && (node.parent.kind === 149 + || node.parent.kind === 148 + || node.parent.kind === 151) + && node.parent.parent.kind === 222; } return false; } @@ -5444,18 +6369,18 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 221: + case 222: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 147: - case 150: + case 148: + case 151: return ts.forEach(node.parameters, nodeIsDecorated); } } ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 243 || - parent.kind === 242 || + if (parent.kind === 244 || + parent.kind === 243 || parent.kind === 245) { return parent.tagName === node; } @@ -5464,97 +6389,97 @@ var ts; ts.isJSXTagName = isJSXTagName; function isPartOfExpression(node) { switch (node.kind) { - case 97: - case 95: - case 93: - case 99: - case 84: - case 10: - case 170: + case 98: + case 96: + case 94: + case 100: + case 85: + case 11: case 171: case 172: case 173: case 174: case 175: case 176: - case 195: case 177: case 196: case 178: + case 197: case 179: - case 192: case 180: - case 183: + case 193: case 181: + case 184: case 182: - case 185: + case 183: case 186: case 187: case 188: - case 191: case 189: - case 11: - case 193: - case 241: - case 242: + case 192: case 190: - case 184: + case 12: + case 194: + case 242: + case 243: + case 191: + case 185: return true; - case 139: - while (node.parent.kind === 139) { + case 140: + while (node.parent.kind === 140) { node = node.parent; } - return node.parent.kind === 158 || isJSXTagName(node); - case 69: - if (node.parent.kind === 158 || isJSXTagName(node)) { + return node.parent.kind === 159 || isJSXTagName(node); + case 70: + if (node.parent.kind === 159 || isJSXTagName(node)) { return true; } case 8: case 9: - case 97: + case 98: var parent_3 = node.parent; switch (parent_3.kind) { - case 218: - case 142: + case 219: + case 143: + case 146: case 145: - case 144: case 255: case 253: - case 169: + case 170: return parent_3.initializer === node; - case 202: case 203: case 204: case 205: - case 211: + case 206: case 212: case 213: + case 214: case 249: - case 215: - case 213: + case 216: + case 214: return parent_3.expression === node; - case 206: + case 207: var forStatement = parent_3; - return (forStatement.initializer === node && forStatement.initializer.kind !== 219) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 220) || forStatement.condition === node || forStatement.incrementor === node; - case 207: case 208: + case 209: var forInStatement = parent_3; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 219) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 220) || forInStatement.expression === node; - case 177: - case 195: + case 178: + case 196: return node === parent_3.expression; - case 197: + case 198: return node === parent_3.expression; - case 140: + case 141: return node === parent_3.expression; - case 143: + case 144: case 248: case 247: return true; - case 194: + case 195: return parent_3.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_3); default: if (isPartOfExpression(parent_3)) { @@ -5572,7 +6497,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 229 && node.moduleReference.kind === 240; + return node.kind === 230 && node.moduleReference.kind === 241; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -5581,7 +6506,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 229 && node.moduleReference.kind !== 240; + return node.kind === 230 && node.moduleReference.kind !== 241; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -5593,8 +6518,8 @@ var ts; } ts.isInJavaScriptFile = isInJavaScriptFile; function isRequireCall(expression, checkArgumentIsStringLiteral) { - var isRequire = expression.kind === 174 && - expression.expression.kind === 69 && + var isRequire = expression.kind === 175 && + expression.expression.kind === 70 && expression.expression.text === "require" && expression.arguments.length === 1; return isRequire && (!checkArgumentIsStringLiteral || expression.arguments[0].kind === 9); @@ -5605,9 +6530,9 @@ var ts; } ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote; function isDeclarationOfFunctionExpression(s) { - if (s.valueDeclaration && s.valueDeclaration.kind === 218) { + if (s.valueDeclaration && s.valueDeclaration.kind === 219) { var declaration = s.valueDeclaration; - return declaration.initializer && declaration.initializer.kind === 179; + return declaration.initializer && declaration.initializer.kind === 180; } return false; } @@ -5616,15 +6541,15 @@ var ts; if (!isInJavaScriptFile(expression)) { return 0; } - if (expression.kind !== 187) { + if (expression.kind !== 188) { return 0; } var expr = expression; - if (expr.operatorToken.kind !== 56 || expr.left.kind !== 172) { + if (expr.operatorToken.kind !== 57 || expr.left.kind !== 173) { return 0; } var lhs = expr.left; - if (lhs.expression.kind === 69) { + if (lhs.expression.kind === 70) { var lhsId = lhs.expression; if (lhsId.text === "exports") { return 1; @@ -5633,12 +6558,12 @@ var ts; return 2; } } - else if (lhs.expression.kind === 97) { + else if (lhs.expression.kind === 98) { return 4; } - else if (lhs.expression.kind === 172) { + else if (lhs.expression.kind === 173) { var innerPropertyAccess = lhs.expression; - if (innerPropertyAccess.expression.kind === 69) { + if (innerPropertyAccess.expression.kind === 70) { var innerPropertyAccessIdentifier = innerPropertyAccess.expression; if (innerPropertyAccessIdentifier.text === "module" && innerPropertyAccess.name.text === "exports") { return 1; @@ -5652,35 +6577,35 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 230) { + if (node.kind === 231) { return node.moduleSpecifier; } - if (node.kind === 229) { + if (node.kind === 230) { var reference = node.moduleReference; - if (reference.kind === 240) { + if (reference.kind === 241) { return reference.expression; } } - if (node.kind === 236) { + if (node.kind === 237) { return node.moduleSpecifier; } - if (node.kind === 225 && node.name.kind === 9) { + if (node.kind === 226 && node.name.kind === 9) { return node.name; } } ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { - if (node.kind === 229) { + if (node.kind === 230) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 232) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 233) { return importClause.namedBindings; } } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 230 + return node.kind === 231 && node.importClause && !!node.importClause.name; } @@ -5688,13 +6613,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 142: + case 143: + case 148: case 147: - case 146: case 254: case 253: + case 146: case 145: - case 144: return node.questionToken !== undefined; } } @@ -5755,24 +6680,24 @@ var ts; if (checkParentVariableStatement) { var isInitializerOfVariableDeclarationInStatement = isVariableLike(node.parent) && (node.parent).initializer === node && - node.parent.parent.parent.kind === 200; + node.parent.parent.parent.kind === 201; var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - node.parent.parent.kind === 200; + node.parent.parent.kind === 201; var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? node.parent.parent.parent : isVariableOfVariableDeclarationStatement ? node.parent.parent : undefined; if (variableStatementNode) { result = append(result, getJSDocs(variableStatementNode, checkParentVariableStatement, getDocs, getTags)); } - if (node.kind === 225 && - node.parent && node.parent.kind === 225) { + if (node.kind === 226 && + node.parent && node.parent.kind === 226) { result = append(result, getJSDocs(node.parent, checkParentVariableStatement, getDocs, getTags)); } var parent_4 = node.parent; var isSourceOfAssignmentExpressionStatement = parent_4 && parent_4.parent && - parent_4.kind === 187 && - parent_4.operatorToken.kind === 56 && - parent_4.parent.kind === 202; + parent_4.kind === 188 && + parent_4.operatorToken.kind === 57 && + parent_4.parent.kind === 203; if (isSourceOfAssignmentExpressionStatement) { result = append(result, getJSDocs(parent_4.parent, checkParentVariableStatement, getDocs, getTags)); } @@ -5780,7 +6705,7 @@ var ts; if (isPropertyAssignmentExpression) { result = append(result, getJSDocs(parent_4, checkParentVariableStatement, getDocs, getTags)); } - if (node.kind === 142) { + if (node.kind === 143) { var paramTags = getJSDocParameterTag(node, checkParentVariableStatement); if (paramTags) { result = append(result, getTags(paramTags)); @@ -5810,7 +6735,7 @@ var ts; return [paramTags[i]]; } } - else if (param.name.kind === 69) { + else if (param.name.kind === 70) { var name_6 = param.name.text; var paramTags = ts.filter(tags, function (tag) { return tag.kind === 275 && tag.parameterName.text === name_6; }); if (paramTags) { @@ -5834,7 +6759,7 @@ var ts; } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { - if (parameter.name && parameter.name.kind === 69) { + if (parameter.name && parameter.name.kind === 70) { var parameterName = parameter.name.text; var jsDocTags = getJSDocTags(parameter.parent, true); if (!jsDocTags) { @@ -5879,12 +6804,12 @@ var ts; } ts.isDeclaredRestParam = isDeclaredRestParam; function isAssignmentTarget(node) { - while (node.parent.kind === 178) { + while (node.parent.kind === 179) { node = node.parent; } while (true) { var parent_5 = node.parent; - if (parent_5.kind === 170 || parent_5.kind === 191) { + if (parent_5.kind === 171 || parent_5.kind === 192) { node = parent_5; continue; } @@ -5892,10 +6817,10 @@ var ts; node = parent_5.parent; continue; } - return parent_5.kind === 187 && + return parent_5.kind === 188 && isAssignmentOperator(parent_5.operatorToken.kind) && parent_5.left === node || - (parent_5.kind === 207 || parent_5.kind === 208) && + (parent_5.kind === 208 || parent_5.kind === 209) && parent_5.initializer === node; } } @@ -5920,11 +6845,11 @@ var ts; } ts.isInAmbientContext = isInAmbientContext; function isDeclarationName(name) { - if (name.kind !== 69 && name.kind !== 9 && name.kind !== 8) { + if (name.kind !== 70 && name.kind !== 9 && name.kind !== 8) { return false; } var parent = name.parent; - if (parent.kind === 234 || parent.kind === 238) { + if (parent.kind === 235 || parent.kind === 239) { if (parent.propertyName) { return true; } @@ -5937,48 +6862,48 @@ var ts; ts.isDeclarationName = isDeclarationName; function isLiteralComputedPropertyDeclarationName(node) { return (node.kind === 9 || node.kind === 8) && - node.parent.kind === 140 && + node.parent.kind === 141 && isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 145: - case 144: - case 147: case 146: - case 149: + case 145: + case 148: + case 147: case 150: + case 151: case 255: case 253: - case 172: + case 173: return parent.name === node; - case 139: + case 140: if (parent.right === node) { - while (parent.kind === 139) { + while (parent.kind === 140) { parent = parent.parent; } - return parent.kind === 158; + return parent.kind === 159; } return false; - case 169: - case 234: + case 170: + case 235: return parent.propertyName === node; - case 238: + case 239: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 229 || - node.kind === 228 || - node.kind === 231 && !!node.name || - node.kind === 232 || - node.kind === 234 || - node.kind === 238 || - node.kind === 235 && exportAssignmentIsAlias(node); + return node.kind === 230 || + node.kind === 229 || + node.kind === 232 && !!node.name || + node.kind === 233 || + node.kind === 235 || + node.kind === 239 || + node.kind === 236 && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function exportAssignmentIsAlias(node) { @@ -5986,17 +6911,17 @@ var ts; } ts.exportAssignmentIsAlias = exportAssignmentIsAlias; function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 83); + var heritageClause = getHeritageClause(node.heritageClauses, 84); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 106); + var heritageClause = getHeritageClause(node.heritageClauses, 107); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 83); + var heritageClause = getHeritageClause(node.heritageClauses, 84); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -6064,7 +6989,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 70 <= token && token <= 138; + return 71 <= token && token <= 139; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -6084,7 +7009,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 140 && + return name.kind === 141 && !isStringOrNumericLiteral(name.expression.kind) && !isWellKnownSymbolSyntactically(name.expression); } @@ -6094,10 +7019,10 @@ var ts; } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 69 || name.kind === 9 || name.kind === 8 || name.kind === 142) { + if (name.kind === 70 || name.kind === 9 || name.kind === 8 || name.kind === 143) { return name.text; } - if (name.kind === 140) { + if (name.kind === 141) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -6115,22 +7040,26 @@ var ts; } ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; function isESSymbolIdentifier(node) { - return node.kind === 69 && node.text === "Symbol"; + return node.kind === 70 && node.text === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; + function isPushOrUnshiftIdentifier(node) { + return node.text === "push" || node.text === "unshift"; + } + ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isModifierKind(token) { switch (token) { - case 115: - case 118: - case 74: - case 122: - case 77: - case 82: - case 112: - case 110: - case 111: - case 128: + case 116: + case 119: + case 75: + case 123: + case 78: + case 83: case 113: + case 111: + case 112: + case 129: + case 114: return true; } return false; @@ -6138,11 +7067,11 @@ var ts; ts.isModifierKind = isModifierKind; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 142; + return root.kind === 143; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 169) { + while (node.kind === 170) { node = node.parent.parent; } return node; @@ -6150,14 +7079,14 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 148 - || kind === 179 - || kind === 220 + return kind === 149 || kind === 180 - || kind === 147 - || kind === 149 + || kind === 221 + || kind === 181 + || kind === 148 || kind === 150 - || kind === 225 + || kind === 151 + || kind === 226 || kind === 256; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; @@ -6207,40 +7136,45 @@ var ts; return node ? ts.getNodeId(node) : 0; } ts.getOriginalNodeId = getOriginalNodeId; + (function (Associativity) { + Associativity[Associativity["Left"] = 0] = "Left"; + Associativity[Associativity["Right"] = 1] = "Right"; + })(ts.Associativity || (ts.Associativity = {})); + var Associativity = ts.Associativity; function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 175 && expression.arguments !== undefined; + var hasArguments = expression.kind === 176 && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 175: + case 176: return hasArguments ? 0 : 1; - case 185: - case 182: + case 186: case 183: - case 181: case 184: - case 188: - case 190: + case 182: + case 185: + case 189: + case 191: return 1; - case 187: + case 188: switch (operator) { - case 38: - case 56: + case 39: case 57: case 58: - case 60: case 59: case 61: + case 60: case 62: case 63: case 64: case 65: case 66: - case 68: case 67: + case 69: + case 68: return 1; } } @@ -6249,15 +7183,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 175 && expression.arguments !== undefined; + var hasArguments = expression.kind === 176 && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 187) { + if (expression.kind === 188) { return expression.operatorToken.kind; } - else if (expression.kind === 185 || expression.kind === 186) { + else if (expression.kind === 186 || expression.kind === 187) { return expression.operator; } else { @@ -6267,106 +7201,106 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 97: - case 95: - case 69: - case 93: - case 99: - case 84: + case 98: + case 96: + case 70: + case 94: + case 100: + case 85: case 8: case 9: - case 170: case 171: - case 179: - case 180: - case 192: - case 241: - case 242: - case 10: - case 11: - case 189: - case 178: - case 193: - return 19; - case 176: case 172: - case 173: - return 18; - case 175: - return hasArguments ? 18 : 17; - case 174: - return 17; - case 186: - return 16; - case 185: - case 182: - case 183: + case 180: case 181: - case 184: - return 15; + case 193: + case 242: + case 243: + case 11: + case 12: + case 190: + case 179: + case 194: + return 19; + case 177: + case 173: + case 174: + return 18; + case 176: + return hasArguments ? 18 : 17; + case 175: + return 17; case 187: + return 16; + case 186: + case 183: + case 184: + case 182: + case 185: + return 15; + case 188: switch (operatorKind) { - case 49: case 50: + case 51: return 15; - case 38: - case 37: case 39: + case 38: case 40: + case 41: return 14; - case 35: case 36: + case 37: return 13; - case 43: case 44: case 45: + case 46: return 12; - case 25: - case 28: - case 27: + case 26: case 29: - case 90: - case 91: - return 11; + case 28: case 30: - case 32: + case 91: + case 92: + return 11; case 31: case 33: + case 32: + case 34: return 10; - case 46: - return 9; - case 48: - return 8; case 47: + return 9; + case 49: + return 8; + case 48: return 7; - case 51: - return 6; case 52: + return 6; + case 53: return 5; - case 56: case 57: case 58: - case 60: case 59: case 61: + case 60: case 62: case 63: case 64: case 65: case 66: - case 68: case 67: + case 69: + case 68: return 3; - case 24: + case 25: return 0; default: return -1; } - case 188: + case 189: return 4; - case 190: - return 2; case 191: + return 2; + case 192: return 1; default: return -1; @@ -6630,7 +7564,7 @@ var ts; function forEachTransformedEmitFile(host, sourceFiles, action, emitOnlyDtsFiles) { var options = host.getCompilerOptions(); if (options.outFile || options.out) { - onBundledEmit(host, sourceFiles); + onBundledEmit(sourceFiles); } else { for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { @@ -6657,7 +7591,7 @@ var ts; var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (options.declaration || emitOnlyDtsFiles) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; action(jsFilePath, sourceMapFilePath, declarationFilePath, [sourceFile], false); } - function onBundledEmit(host, sourceFiles) { + function onBundledEmit(sourceFiles) { if (sourceFiles.length) { var jsFilePath = options.outFile || options.out; var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); @@ -6746,7 +7680,7 @@ var ts; ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 148 && nodeIsPresent(member.body)) { + if (member.kind === 149 && nodeIsPresent(member.body)) { return member; } }); @@ -6773,11 +7707,11 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return node && node.kind === 69 && identifierIsThisKeyword(node); + return node && node.kind === 70 && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 97; + return id.originalKeywordKind === 98; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -6787,10 +7721,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 149) { + if (accessor.kind === 150) { getAccessor = accessor; } - else if (accessor.kind === 150) { + else if (accessor.kind === 151) { setAccessor = accessor; } else { @@ -6799,7 +7733,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 149 || member.kind === 150) + if ((member.kind === 150 || member.kind === 151) && hasModifier(member, 32) === hasModifier(accessor, 32)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -6810,10 +7744,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 149 && !getAccessor) { + if (member.kind === 150 && !getAccessor) { getAccessor = member; } - if (member.kind === 150 && !setAccessor) { + if (member.kind === 151 && !setAccessor) { setAccessor = member; } } @@ -7005,34 +7939,34 @@ var ts; ts.getModifierFlags = getModifierFlags; function modifierToFlag(token) { switch (token) { - case 113: return 32; - case 112: return 4; - case 111: return 16; - case 110: return 8; - case 115: return 128; - case 82: return 1; - case 122: return 2; - case 74: return 2048; - case 77: return 512; - case 118: return 256; - case 128: return 64; + case 114: return 32; + case 113: return 4; + case 112: return 16; + case 111: return 8; + case 116: return 128; + case 83: return 1; + case 123: return 2; + case 75: return 2048; + case 78: return 512; + case 119: return 256; + case 129: return 64; } return 0; } ts.modifierToFlag = modifierToFlag; function isLogicalOperator(token) { - return token === 52 - || token === 51 - || token === 49; + return token === 53 + || token === 52 + || token === 50; } ts.isLogicalOperator = isLogicalOperator; function isAssignmentOperator(token) { - return token >= 56 && token <= 68; + return token >= 57 && token <= 69; } ts.isAssignmentOperator = isAssignmentOperator; function tryGetClassExtendingExpressionWithTypeArguments(node) { - if (node.kind === 194 && - node.parent.token === 83 && + if (node.kind === 195 && + node.parent.token === 84 && isClassLike(node.parent.parent)) { return node.parent.parent; } @@ -7040,10 +7974,10 @@ var ts; ts.tryGetClassExtendingExpressionWithTypeArguments = tryGetClassExtendingExpressionWithTypeArguments; function isDestructuringAssignment(node) { if (isBinaryExpression(node)) { - if (node.operatorToken.kind === 56) { + if (node.operatorToken.kind === 57) { var kind = node.left.kind; - return kind === 171 - || kind === 170; + return kind === 172 + || kind === 171; } } return false; @@ -7054,7 +7988,7 @@ var ts; } ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 69) { + if (node.kind === 70) { return true; } else if (isPropertyAccessExpression(node)) { @@ -7069,21 +8003,21 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { - return node.kind === 69 || - node.kind === 172 && isEntityNameExpression(node.expression); + return node.kind === 70 || + node.kind === 173 && isEntityNameExpression(node.expression); } ts.isEntityNameExpression = isEntityNameExpression; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 139 && node.parent.right === node) || - (node.parent.kind === 172 && node.parent.name === node); + return (node.parent.kind === 140 && node.parent.right === node) || + (node.parent.kind === 173 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteralOrArrayLiteral(expression) { var kind = expression.kind; - if (kind === 171) { + if (kind === 172) { return expression.properties.length === 0; } - if (kind === 170) { + if (kind === 171) { return expression.elements.length === 0; } return false; @@ -7207,49 +8141,49 @@ var ts; var kind = node.kind; if (kind === 9 || kind === 8 - || kind === 10 || kind === 11 - || kind === 69 - || kind === 97 - || kind === 95 - || kind === 99 - || kind === 84 - || kind === 93) { + || kind === 12 + || kind === 70 + || kind === 98 + || kind === 96 + || kind === 100 + || kind === 85 + || kind === 94) { return true; } - else if (kind === 172) { + else if (kind === 173) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 173) { + else if (kind === 174) { return isSimpleExpressionWorker(node.expression, depth + 1) && isSimpleExpressionWorker(node.argumentExpression, depth + 1); } - else if (kind === 185 - || kind === 186) { + else if (kind === 186 + || kind === 187) { return isSimpleExpressionWorker(node.operand, depth + 1); } - else if (kind === 187) { - return node.operatorToken.kind !== 38 + else if (kind === 188) { + return node.operatorToken.kind !== 39 && isSimpleExpressionWorker(node.left, depth + 1) && isSimpleExpressionWorker(node.right, depth + 1); } - else if (kind === 188) { + else if (kind === 189) { return isSimpleExpressionWorker(node.condition, depth + 1) && isSimpleExpressionWorker(node.whenTrue, depth + 1) && isSimpleExpressionWorker(node.whenFalse, depth + 1); } - else if (kind === 183 - || kind === 182 - || kind === 181) { + else if (kind === 184 + || kind === 183 + || kind === 182) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 170) { + else if (kind === 171) { return node.elements.length === 0; } - else if (kind === 171) { + else if (kind === 172) { return node.properties.length === 0; } - else if (kind === 174) { + else if (kind === 175) { if (!isSimpleExpressionWorker(node.expression, depth + 1)) { return false; } @@ -7355,7 +8289,7 @@ var ts; return ts.positionIsSynthesized(range.pos) ? -1 : ts.skipTrivia(sourceFile.text, range.pos); } ts.getStartPositionOfRange = getStartPositionOfRange; - function collectExternalModuleInfo(sourceFile, resolver) { + function collectExternalModuleInfo(sourceFile) { var externalImports = []; var exportSpecifiers = ts.createMap(); var exportEquals = undefined; @@ -7363,26 +8297,21 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { + case 231: + externalImports.push(node); + break; case 230: - if (!node.importClause || - resolver.isReferencedAliasDeclaration(node.importClause, true)) { + if (node.moduleReference.kind === 241) { externalImports.push(node); } break; - case 229: - if (node.moduleReference.kind === 240 && resolver.isReferencedAliasDeclaration(node)) { - externalImports.push(node); - } - break; - case 236: + case 237: if (node.moduleSpecifier) { if (!node.exportClause) { - if (resolver.moduleExportsSomeValue(node.moduleSpecifier)) { - externalImports.push(node); - hasExportStarsToExportValues = true; - } + externalImports.push(node); + hasExportStarsToExportValues = true; } - else if (resolver.isValueAliasDeclaration(node)) { + else { externalImports.push(node); } } @@ -7394,7 +8323,7 @@ var ts; } } break; - case 235: + case 236: if (node.isExportEquals && !exportEquals) { exportEquals = node; } @@ -7415,7 +8344,7 @@ var ts; if (node.symbol) { for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 221 && declaration !== node) { + if (declaration.kind === 222 && declaration !== node) { return true; } } @@ -7433,15 +8362,15 @@ var ts; } ts.isNodeArray = isNodeArray; function isNoSubstitutionTemplateLiteral(node) { - return node.kind === 11; + return node.kind === 12; } ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral; function isLiteralKind(kind) { - return 8 <= kind && kind <= 11; + return 8 <= kind && kind <= 12; } ts.isLiteralKind = isLiteralKind; function isTextualLiteralKind(kind) { - return kind === 9 || kind === 11; + return kind === 9 || kind === 12; } ts.isTextualLiteralKind = isTextualLiteralKind; function isLiteralExpression(node) { @@ -7449,21 +8378,21 @@ var ts; } ts.isLiteralExpression = isLiteralExpression; function isTemplateLiteralKind(kind) { - return 11 <= kind && kind <= 14; + return 12 <= kind && kind <= 15; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isTemplateHead(node) { - return node.kind === 12; + return node.kind === 13; } ts.isTemplateHead = isTemplateHead; function isTemplateMiddleOrTemplateTail(node) { var kind = node.kind; - return kind === 13 - || kind === 14; + return kind === 14 + || kind === 15; } ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; function isIdentifier(node) { - return node.kind === 69; + return node.kind === 70; } ts.isIdentifier = isIdentifier; function isGeneratedIdentifier(node) { @@ -7475,87 +8404,87 @@ var ts; } ts.isModifier = isModifier; function isQualifiedName(node) { - return node.kind === 139; + return node.kind === 140; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 140; + return node.kind === 141; } ts.isComputedPropertyName = isComputedPropertyName; function isEntityName(node) { var kind = node.kind; - return kind === 139 - || kind === 69; + return kind === 140 + || kind === 70; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 69 + return kind === 70 || kind === 9 || kind === 8 - || kind === 140; + || kind === 141; } ts.isPropertyName = isPropertyName; function isModuleName(node) { var kind = node.kind; - return kind === 69 + return kind === 70 || kind === 9; } ts.isModuleName = isModuleName; function isBindingName(node) { var kind = node.kind; - return kind === 69 - || kind === 167 - || kind === 168; + return kind === 70 + || kind === 168 + || kind === 169; } ts.isBindingName = isBindingName; function isTypeParameter(node) { - return node.kind === 141; + return node.kind === 142; } ts.isTypeParameter = isTypeParameter; function isParameter(node) { - return node.kind === 142; + return node.kind === 143; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 143; + return node.kind === 144; } ts.isDecorator = isDecorator; function isMethodDeclaration(node) { - return node.kind === 147; + return node.kind === 148; } ts.isMethodDeclaration = isMethodDeclaration; function isClassElement(node) { var kind = node.kind; - return kind === 148 - || kind === 145 - || kind === 147 - || kind === 149 + return kind === 149 + || kind === 146 + || kind === 148 || kind === 150 - || kind === 153 - || kind === 198; + || kind === 151 + || kind === 154 + || kind === 199; } ts.isClassElement = isClassElement; function isObjectLiteralElementLike(node) { var kind = node.kind; return kind === 253 || kind === 254 - || kind === 147 - || kind === 149 + || kind === 148 || kind === 150 - || kind === 239; + || kind === 151 + || kind === 240; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; function isTypeNodeKind(kind) { - return (kind >= 154 && kind <= 166) - || kind === 117 - || kind === 130 - || kind === 120 - || kind === 132 + return (kind >= 155 && kind <= 167) + || kind === 118 + || kind === 131 + || kind === 121 || kind === 133 - || kind === 103 - || kind === 127 - || kind === 194; + || kind === 134 + || kind === 104 + || kind === 128 + || kind === 195; } function isTypeNode(node) { return isTypeNodeKind(node.kind); @@ -7564,94 +8493,94 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 168 - || kind === 167; + return kind === 169 + || kind === 168; } return false; } ts.isBindingPattern = isBindingPattern; function isBindingElement(node) { - return node.kind === 169; + return node.kind === 170; } ts.isBindingElement = isBindingElement; function isArrayBindingElement(node) { var kind = node.kind; - return kind === 169 - || kind === 193; + return kind === 170 + || kind === 194; } ts.isArrayBindingElement = isArrayBindingElement; function isPropertyAccessExpression(node) { - return node.kind === 172; + return node.kind === 173; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 173; + return node.kind === 174; } ts.isElementAccessExpression = isElementAccessExpression; function isBinaryExpression(node) { - return node.kind === 187; + return node.kind === 188; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 188; + return node.kind === 189; } ts.isConditionalExpression = isConditionalExpression; function isCallExpression(node) { - return node.kind === 174; + return node.kind === 175; } ts.isCallExpression = isCallExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 189 - || kind === 11; + return kind === 190 + || kind === 12; } ts.isTemplateLiteral = isTemplateLiteral; function isSpreadElementExpression(node) { - return node.kind === 191; + return node.kind === 192; } ts.isSpreadElementExpression = isSpreadElementExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 194; + return node.kind === 195; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isLeftHandSideExpressionKind(kind) { - return kind === 172 - || kind === 173 - || kind === 175 + return kind === 173 || kind === 174 - || kind === 241 - || kind === 242 || kind === 176 - || kind === 170 - || kind === 178 + || kind === 175 + || kind === 242 + || kind === 243 + || kind === 177 || kind === 171 - || kind === 192 || kind === 179 - || kind === 69 - || kind === 10 + || kind === 172 + || kind === 193 + || kind === 180 + || kind === 70 + || kind === 11 || kind === 8 || kind === 9 - || kind === 11 - || kind === 189 - || kind === 84 - || kind === 93 - || kind === 97 - || kind === 99 - || kind === 95 - || kind === 196; + || kind === 12 + || kind === 190 + || kind === 85 + || kind === 94 + || kind === 98 + || kind === 100 + || kind === 96 + || kind === 197; } function isLeftHandSideExpression(node) { return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isUnaryExpressionKind(kind) { - return kind === 185 - || kind === 186 - || kind === 181 + return kind === 186 + || kind === 187 || kind === 182 || kind === 183 || kind === 184 - || kind === 177 + || kind === 185 + || kind === 178 || isLeftHandSideExpressionKind(kind); } function isUnaryExpression(node) { @@ -7659,13 +8588,13 @@ var ts; } ts.isUnaryExpression = isUnaryExpression; function isExpressionKind(kind) { - return kind === 188 - || kind === 190 - || kind === 180 - || kind === 187 + return kind === 189 || kind === 191 - || kind === 195 - || kind === 193 + || kind === 181 + || kind === 188 + || kind === 192 + || kind === 196 + || kind === 194 || isUnaryExpressionKind(kind); } function isExpression(node) { @@ -7674,8 +8603,8 @@ var ts; ts.isExpression = isExpression; function isAssertionExpression(node) { var kind = node.kind; - return kind === 177 - || kind === 195; + return kind === 178 + || kind === 196; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { @@ -7692,15 +8621,15 @@ var ts; } ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isOmittedExpression(node) { - return node.kind === 193; + return node.kind === 194; } ts.isOmittedExpression = isOmittedExpression; function isTemplateSpan(node) { - return node.kind === 197; + return node.kind === 198; } ts.isTemplateSpan = isTemplateSpan; function isBlock(node) { - return node.kind === 199; + return node.kind === 200; } ts.isBlock = isBlock; function isConciseBody(node) { @@ -7718,118 +8647,118 @@ var ts; } ts.isForInitializer = isForInitializer; function isVariableDeclaration(node) { - return node.kind === 218; + return node.kind === 219; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 219; + return node.kind === 220; } ts.isVariableDeclarationList = isVariableDeclarationList; function isCaseBlock(node) { - return node.kind === 227; + return node.kind === 228; } ts.isCaseBlock = isCaseBlock; function isModuleBody(node) { var kind = node.kind; - return kind === 226 - || kind === 225; + return kind === 227 + || kind === 226; } ts.isModuleBody = isModuleBody; function isImportEqualsDeclaration(node) { - return node.kind === 229; + return node.kind === 230; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportClause(node) { - return node.kind === 231; + return node.kind === 232; } ts.isImportClause = isImportClause; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 233 - || kind === 232; + return kind === 234 + || kind === 233; } ts.isNamedImportBindings = isNamedImportBindings; function isImportSpecifier(node) { - return node.kind === 234; + return node.kind === 235; } ts.isImportSpecifier = isImportSpecifier; function isNamedExports(node) { - return node.kind === 237; + return node.kind === 238; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 238; + return node.kind === 239; } ts.isExportSpecifier = isExportSpecifier; function isModuleOrEnumDeclaration(node) { - return node.kind === 225 || node.kind === 224; + return node.kind === 226 || node.kind === 225; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 180 - || kind === 169 - || kind === 221 - || kind === 192 - || kind === 148 - || kind === 224 - || kind === 255 - || kind === 238 - || kind === 220 - || kind === 179 - || kind === 149 - || kind === 231 - || kind === 229 - || kind === 234 + return kind === 181 + || kind === 170 || kind === 222 - || kind === 147 - || kind === 146 + || kind === 193 + || kind === 149 || kind === 225 - || kind === 228 - || kind === 232 - || kind === 142 - || kind === 253 - || kind === 145 - || kind === 144 + || kind === 255 + || kind === 239 + || kind === 221 + || kind === 180 || kind === 150 - || kind === 254 + || kind === 232 + || kind === 230 + || kind === 235 || kind === 223 - || kind === 141 - || kind === 218 + || kind === 148 + || kind === 147 + || kind === 226 + || kind === 229 + || kind === 233 + || kind === 143 + || kind === 253 + || kind === 146 + || kind === 145 + || kind === 151 + || kind === 254 + || kind === 224 + || kind === 142 + || kind === 219 || kind === 279; } function isDeclarationStatementKind(kind) { - return kind === 220 - || kind === 239 - || kind === 221 + return kind === 221 + || kind === 240 || kind === 222 || kind === 223 || kind === 224 || kind === 225 + || kind === 226 + || kind === 231 || kind === 230 - || kind === 229 + || kind === 237 || kind === 236 - || kind === 235 - || kind === 228; + || kind === 229; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 210 - || kind === 209 - || kind === 217 - || kind === 204 - || kind === 202 - || kind === 201 - || kind === 207 - || kind === 208 - || kind === 206 - || kind === 203 - || kind === 214 - || kind === 211 - || kind === 213 - || kind === 215 - || kind === 216 - || kind === 200 + return kind === 211 + || kind === 210 + || kind === 218 || kind === 205 + || kind === 203 + || kind === 202 + || kind === 208 + || kind === 209 + || kind === 207 + || kind === 204 + || kind === 215 || kind === 212 + || kind === 214 + || kind === 216 + || kind === 217 + || kind === 201 + || kind === 206 + || kind === 213 || kind === 287; } function isDeclaration(node) { @@ -7848,18 +8777,18 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 199; + || kind === 200; } ts.isStatement = isStatement; function isModuleReference(node) { var kind = node.kind; - return kind === 240 - || kind === 139 - || kind === 69; + return kind === 241 + || kind === 140 + || kind === 70; } ts.isModuleReference = isModuleReference; function isJsxOpeningElement(node) { - return node.kind === 243; + return node.kind === 244; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { @@ -7868,17 +8797,17 @@ var ts; ts.isJsxClosingElement = isJsxClosingElement; function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 97 - || kind === 69 - || kind === 172; + return kind === 98 + || kind === 70 + || kind === 173; } ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 241 + return kind === 242 || kind === 248 - || kind === 242 - || kind === 244; + || kind === 243 + || kind === 10; } ts.isJsxChild = isJsxChild; function isJsxAttributeLike(node) { @@ -7938,7 +8867,16 @@ var ts; })(ts || (ts = {})); (function (ts) { function getDefaultLibFileName(options) { - return options.target === 2 ? "lib.es6.d.ts" : "lib.d.ts"; + switch (options.target) { + case 4: + return "lib.es2017.d.ts"; + case 3: + return "lib.es2016.d.ts"; + case 2: + return "lib.es6.d.ts"; + default: + return "lib.d.ts"; + } } ts.getDefaultLibFileName = getDefaultLibFileName; function textSpanEnd(span) { @@ -8057,9 +8995,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 141) { + if (d && d.kind === 142) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 222) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 223) { return current; } } @@ -8067,11 +9005,11 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92) && node.parent.kind === 148 && ts.isClassLike(node.parent.parent); + return ts.hasModifier(node, 92) && node.parent.kind === 149 && ts.isClassLike(node.parent.parent); } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 169 || ts.isBindingPattern(node))) { + while (node && (node.kind === 170 || ts.isBindingPattern(node))) { node = node.parent; } return node; @@ -8079,14 +9017,14 @@ var ts; function getCombinedModifierFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = ts.getModifierFlags(node); - if (node.kind === 218) { + if (node.kind === 219) { node = node.parent; } - if (node && node.kind === 219) { + if (node && node.kind === 220) { flags |= ts.getModifierFlags(node); node = node.parent; } - if (node && node.kind === 200) { + if (node && node.kind === 201) { flags |= ts.getModifierFlags(node); } return flags; @@ -8095,14 +9033,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 218) { + if (node.kind === 219) { node = node.parent; } - if (node && node.kind === 219) { + if (node && node.kind === 220) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 200) { + if (node && node.kind === 201) { flags |= node.flags; } return flags; @@ -8195,7 +9133,7 @@ var ts; return node; } else if (typeof value === "boolean") { - return createNode(value ? 99 : 84, location, undefined); + return createNode(value ? 100 : 85, location, undefined); } else if (typeof value === "string") { var node = createNode(9, location, undefined); @@ -8212,7 +9150,7 @@ var ts; ts.createLiteral = createLiteral; var nextAutoGenerateId = 0; function createIdentifier(text, location) { - var node = createNode(69, location); + var node = createNode(70, location); node.text = ts.escapeIdentifier(text); node.originalKeywordKind = ts.stringToToken(text); node.autoGenerateKind = 0; @@ -8221,7 +9159,7 @@ var ts; } ts.createIdentifier = createIdentifier; function createTempVariable(recordTempVariable, location) { - var name = createNode(69, location); + var name = createNode(70, location); name.text = ""; name.originalKeywordKind = 0; name.autoGenerateKind = 1; @@ -8234,7 +9172,7 @@ var ts; } ts.createTempVariable = createTempVariable; function createLoopVariable(location) { - var name = createNode(69, location); + var name = createNode(70, location); name.text = ""; name.originalKeywordKind = 0; name.autoGenerateKind = 2; @@ -8244,7 +9182,7 @@ var ts; } ts.createLoopVariable = createLoopVariable; function createUniqueName(text, location) { - var name = createNode(69, location); + var name = createNode(70, location); name.text = text; name.originalKeywordKind = 0; name.autoGenerateKind = 3; @@ -8254,7 +9192,7 @@ var ts; } ts.createUniqueName = createUniqueName; function getGeneratedNameForNode(node, location) { - var name = createNode(69, location); + var name = createNode(70, location); name.original = node; name.text = ""; name.originalKeywordKind = 0; @@ -8269,22 +9207,22 @@ var ts; } ts.createToken = createToken; function createSuper() { - var node = createNode(95); + var node = createNode(96); return node; } ts.createSuper = createSuper; function createThis(location) { - var node = createNode(97, location); + var node = createNode(98, location); return node; } ts.createThis = createThis; function createNull() { - var node = createNode(93); + var node = createNode(94); return node; } ts.createNull = createNull; function createComputedPropertyName(expression, location) { - var node = createNode(140, location); + var node = createNode(141, location); node.expression = expression; return node; } @@ -8301,7 +9239,7 @@ var ts; } ts.createParameter = createParameter; function createParameterDeclaration(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer, location, flags) { - var node = createNode(142, location, flags); + var node = createNode(143, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.dotDotDotToken = dotDotDotToken; @@ -8320,7 +9258,7 @@ var ts; } ts.updateParameterDeclaration = updateParameterDeclaration; function createProperty(decorators, modifiers, name, questionToken, type, initializer, location) { - var node = createNode(145, location); + var node = createNode(146, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -8338,7 +9276,7 @@ var ts; } ts.updateProperty = updateProperty; function createMethod(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(147, location, flags); + var node = createNode(148, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; @@ -8358,7 +9296,7 @@ var ts; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body, location, flags) { - var node = createNode(148, location, flags); + var node = createNode(149, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.typeParameters = undefined; @@ -8376,7 +9314,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body, location, flags) { - var node = createNode(149, location, flags); + var node = createNode(150, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -8395,7 +9333,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body, location, flags) { - var node = createNode(150, location, flags); + var node = createNode(151, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -8413,7 +9351,7 @@ var ts; } ts.updateSetAccessor = updateSetAccessor; function createObjectBindingPattern(elements, location) { - var node = createNode(167, location); + var node = createNode(168, location); node.elements = createNodeArray(elements); return node; } @@ -8426,7 +9364,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements, location) { - var node = createNode(168, location); + var node = createNode(169, location); node.elements = createNodeArray(elements); return node; } @@ -8439,7 +9377,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(propertyName, dotDotDotToken, name, initializer, location) { - var node = createNode(169, location); + var node = createNode(170, location); node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; node.dotDotDotToken = dotDotDotToken; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -8455,7 +9393,7 @@ var ts; } ts.updateBindingElement = updateBindingElement; function createArrayLiteral(elements, location, multiLine) { - var node = createNode(170, location); + var node = createNode(171, location); node.elements = parenthesizeListElements(createNodeArray(elements)); if (multiLine) { node.multiLine = true; @@ -8471,7 +9409,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, location, multiLine) { - var node = createNode(171, location); + var node = createNode(172, location); node.properties = createNodeArray(properties); if (multiLine) { node.multiLine = true; @@ -8487,7 +9425,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name, location, flags) { - var node = createNode(172, location, flags); + var node = createNode(173, location, flags); node.expression = parenthesizeForAccess(expression); (node.emitNode || (node.emitNode = {})).flags |= 1048576; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -8504,7 +9442,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index, location) { - var node = createNode(173, location); + var node = createNode(174, location); node.expression = parenthesizeForAccess(expression); node.argumentExpression = typeof index === "number" ? createLiteral(index) : index; return node; @@ -8518,7 +9456,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(174, location, flags); + var node = createNode(175, location, flags); node.expression = parenthesizeForAccess(expression); if (typeArguments) { node.typeArguments = createNodeArray(typeArguments); @@ -8535,7 +9473,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(175, location, flags); + var node = createNode(176, location, flags); node.expression = parenthesizeForNew(expression); node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; node.arguments = argumentsArray ? parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -8550,7 +9488,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, template, location) { - var node = createNode(176, location); + var node = createNode(177, location); node.tag = parenthesizeForAccess(tag); node.template = template; return node; @@ -8564,7 +9502,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createParen(expression, location) { - var node = createNode(178, location); + var node = createNode(179, location); node.expression = expression; return node; } @@ -8576,9 +9514,9 @@ var ts; return node; } ts.updateParen = updateParen; - function createFunctionExpression(asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(179, location, flags); - node.modifiers = undefined; + function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { + var node = createNode(180, location, flags); + node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; node.name = typeof name === "string" ? createIdentifier(name) : name; node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; @@ -8588,20 +9526,20 @@ var ts; return node; } ts.createFunctionExpression = createFunctionExpression; - function updateFunctionExpression(node, name, typeParameters, parameters, type, body) { - if (node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createFunctionExpression(node.asteriskToken, name, typeParameters, parameters, type, body, node, node.flags), node); + function updateFunctionExpression(node, modifiers, name, typeParameters, parameters, type, body) { + if (node.name !== name || node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { + return updateNode(createFunctionExpression(modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, node, node.flags), node); } return node; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body, location, flags) { - var node = createNode(180, location, flags); + var node = createNode(181, location, flags); node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; node.parameters = createNodeArray(parameters); node.type = type; - node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(34); + node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(35); node.body = parenthesizeConciseBody(body); return node; } @@ -8614,7 +9552,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression, location) { - var node = createNode(181, location); + var node = createNode(182, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -8627,7 +9565,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression, location) { - var node = createNode(182, location); + var node = createNode(183, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -8640,7 +9578,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression, location) { - var node = createNode(183, location); + var node = createNode(184, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -8653,7 +9591,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression, location) { - var node = createNode(184, location); + var node = createNode(185, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -8666,7 +9604,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand, location) { - var node = createNode(185, location); + var node = createNode(186, location); node.operator = operator; node.operand = parenthesizePrefixOperand(operand); return node; @@ -8680,7 +9618,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator, location) { - var node = createNode(186, location); + var node = createNode(187, location); node.operand = parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -8696,7 +9634,7 @@ var ts; function createBinary(left, operator, right, location) { var operatorToken = typeof operator === "number" ? createToken(operator) : operator; var operatorKind = operatorToken.kind; - var node = createNode(187, location); + var node = createNode(188, location); node.left = parenthesizeBinaryOperand(operatorKind, left, true, undefined); node.operatorToken = operatorToken; node.right = parenthesizeBinaryOperand(operatorKind, right, false, node.left); @@ -8711,7 +9649,7 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionToken, whenTrue, colonToken, whenFalse, location) { - var node = createNode(188, location); + var node = createNode(189, location); node.condition = condition; node.questionToken = questionToken; node.whenTrue = whenTrue; @@ -8728,7 +9666,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans, location) { - var node = createNode(189, location); + var node = createNode(190, location); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -8742,7 +9680,7 @@ var ts; } ts.updateTemplateExpression = updateTemplateExpression; function createYield(asteriskToken, expression, location) { - var node = createNode(190, location); + var node = createNode(191, location); node.asteriskToken = asteriskToken; node.expression = expression; return node; @@ -8756,7 +9694,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression, location) { - var node = createNode(191, location); + var node = createNode(192, location); node.expression = parenthesizeExpressionForList(expression); return node; } @@ -8769,7 +9707,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(192, location); + var node = createNode(193, location); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -8787,12 +9725,12 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression(location) { - var node = createNode(193, location); + var node = createNode(194, location); return node; } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression, location) { - var node = createNode(194, location); + var node = createNode(195, location); node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; node.expression = parenthesizeForAccess(expression); return node; @@ -8806,7 +9744,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createTemplateSpan(expression, literal, location) { - var node = createNode(197, location); + var node = createNode(198, location); node.expression = expression; node.literal = literal; return node; @@ -8820,7 +9758,7 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createBlock(statements, location, multiLine, flags) { - var block = createNode(199, location, flags); + var block = createNode(200, location, flags); block.statements = createNodeArray(statements); if (multiLine) { block.multiLine = true; @@ -8836,7 +9774,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList, location, flags) { - var node = createNode(200, location, flags); + var node = createNode(201, location, flags); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -8851,7 +9789,7 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createVariableDeclarationList(declarations, location, flags) { - var node = createNode(219, location, flags); + var node = createNode(220, location, flags); node.declarations = createNodeArray(declarations); return node; } @@ -8864,7 +9802,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createVariableDeclaration(name, type, initializer, location, flags) { - var node = createNode(218, location, flags); + var node = createNode(219, location, flags); node.name = typeof name === "string" ? createIdentifier(name) : name; node.type = type; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -8879,11 +9817,11 @@ var ts; } ts.updateVariableDeclaration = updateVariableDeclaration; function createEmptyStatement(location) { - return createNode(201, location); + return createNode(202, location); } ts.createEmptyStatement = createEmptyStatement; function createStatement(expression, location, flags) { - var node = createNode(202, location, flags); + var node = createNode(203, location, flags); node.expression = parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -8896,7 +9834,7 @@ var ts; } ts.updateStatement = updateStatement; function createIf(expression, thenStatement, elseStatement, location) { - var node = createNode(203, location); + var node = createNode(204, location); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -8911,7 +9849,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression, location) { - var node = createNode(204, location); + var node = createNode(205, location); node.statement = statement; node.expression = expression; return node; @@ -8925,7 +9863,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement, location) { - var node = createNode(205, location); + var node = createNode(206, location); node.expression = expression; node.statement = statement; return node; @@ -8939,7 +9877,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement, location) { - var node = createNode(206, location, undefined); + var node = createNode(207, location, undefined); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -8955,7 +9893,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement, location) { - var node = createNode(207, location); + var node = createNode(208, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -8970,7 +9908,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(initializer, expression, statement, location) { - var node = createNode(208, location); + var node = createNode(209, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -8985,7 +9923,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label, location) { - var node = createNode(209, location); + var node = createNode(210, location); if (label) { node.label = label; } @@ -9000,7 +9938,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label, location) { - var node = createNode(210, location); + var node = createNode(211, location); if (label) { node.label = label; } @@ -9015,7 +9953,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression, location) { - var node = createNode(211, location); + var node = createNode(212, location); node.expression = expression; return node; } @@ -9028,7 +9966,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement, location) { - var node = createNode(212, location); + var node = createNode(213, location); node.expression = expression; node.statement = statement; return node; @@ -9042,7 +9980,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock, location) { - var node = createNode(213, location); + var node = createNode(214, location); node.expression = parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -9056,7 +9994,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement, location) { - var node = createNode(214, location); + var node = createNode(215, location); node.label = typeof label === "string" ? createIdentifier(label) : label; node.statement = statement; return node; @@ -9070,7 +10008,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression, location) { - var node = createNode(215, location); + var node = createNode(216, location); node.expression = expression; return node; } @@ -9083,7 +10021,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock, location) { - var node = createNode(216, location); + var node = createNode(217, location); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -9098,7 +10036,7 @@ var ts; } ts.updateTry = updateTry; function createCaseBlock(clauses, location) { - var node = createNode(227, location); + var node = createNode(228, location); node.clauses = createNodeArray(clauses); return node; } @@ -9111,7 +10049,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(220, location, flags); + var node = createNode(221, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; @@ -9131,7 +10069,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(221, location); + var node = createNode(222, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -9149,7 +10087,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, location) { - var node = createNode(230, location); + var node = createNode(231, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.importClause = importClause; @@ -9165,7 +10103,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings, location) { - var node = createNode(231, location); + var node = createNode(232, location); node.name = name; node.namedBindings = namedBindings; return node; @@ -9179,7 +10117,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name, location) { - var node = createNode(232, location); + var node = createNode(233, location); node.name = name; return node; } @@ -9192,7 +10130,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements, location) { - var node = createNode(233, location); + var node = createNode(234, location); node.elements = createNodeArray(elements); return node; } @@ -9205,7 +10143,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name, location) { - var node = createNode(234, location); + var node = createNode(235, location); node.propertyName = propertyName; node.name = name; return node; @@ -9219,7 +10157,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression, location) { - var node = createNode(235, location); + var node = createNode(236, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.isExportEquals = isExportEquals; @@ -9235,7 +10173,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, location) { - var node = createNode(236, location); + var node = createNode(237, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.exportClause = exportClause; @@ -9251,7 +10189,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements, location) { - var node = createNode(237, location); + var node = createNode(238, location); node.elements = createNodeArray(elements); return node; } @@ -9264,7 +10202,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(name, propertyName, location) { - var node = createNode(238, location); + var node = createNode(239, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; return node; @@ -9278,7 +10216,7 @@ var ts; } ts.updateExportSpecifier = updateExportSpecifier; function createJsxElement(openingElement, children, closingElement, location) { - var node = createNode(241, location); + var node = createNode(242, location); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -9293,7 +10231,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, attributes, location) { - var node = createNode(242, location); + var node = createNode(243, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -9307,7 +10245,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, attributes, location) { - var node = createNode(243, location); + var node = createNode(244, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -9541,47 +10479,47 @@ var ts; } ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function createComma(left, right) { - return createBinary(left, 24, right); + return createBinary(left, 25, right); } ts.createComma = createComma; function createLessThan(left, right, location) { - return createBinary(left, 25, right, location); + return createBinary(left, 26, right, location); } ts.createLessThan = createLessThan; function createAssignment(left, right, location) { - return createBinary(left, 56, right, location); + return createBinary(left, 57, right, location); } ts.createAssignment = createAssignment; function createStrictEquality(left, right) { - return createBinary(left, 32, right); + return createBinary(left, 33, right); } ts.createStrictEquality = createStrictEquality; function createStrictInequality(left, right) { - return createBinary(left, 33, right); + return createBinary(left, 34, right); } ts.createStrictInequality = createStrictInequality; function createAdd(left, right) { - return createBinary(left, 35, right); + return createBinary(left, 36, right); } ts.createAdd = createAdd; function createSubtract(left, right) { - return createBinary(left, 36, right); + return createBinary(left, 37, right); } ts.createSubtract = createSubtract; function createPostfixIncrement(operand, location) { - return createPostfix(operand, 41, location); + return createPostfix(operand, 42, location); } ts.createPostfixIncrement = createPostfixIncrement; function createLogicalAnd(left, right) { - return createBinary(left, 51, right); + return createBinary(left, 52, right); } ts.createLogicalAnd = createLogicalAnd; function createLogicalOr(left, right) { - return createBinary(left, 52, right); + return createBinary(left, 53, right); } ts.createLogicalOr = createLogicalOr; function createLogicalNot(operand) { - return createPrefix(49, operand); + return createPrefix(50, operand); } ts.createLogicalNot = createLogicalNot; function createVoidZero() { @@ -9600,7 +10538,7 @@ var ts; } ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName; function createRestParameter(name) { - return createParameterDeclaration(undefined, undefined, createToken(22), name, undefined, undefined, undefined); + return createParameterDeclaration(undefined, undefined, createToken(23), name, undefined, undefined, undefined); } ts.createRestParameter = createRestParameter; function createFunctionCall(func, thisArg, argumentsList, location) { @@ -9714,7 +10652,7 @@ var ts; } ts.createDecorateHelper = createDecorateHelper; function createAwaiterHelper(externalHelpersModuleName, hasLexicalArguments, promiseConstructor, body) { - var generatorFunc = createFunctionExpression(createToken(37), undefined, undefined, [], undefined, body); + var generatorFunc = createFunctionExpression(undefined, createToken(38), undefined, undefined, [], undefined, body); (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 2097152; return createCall(createHelperName(externalHelpersModuleName, "__awaiter"), undefined, [ createThis(), @@ -9758,7 +10696,7 @@ var ts; setter ])))))); return createVariableStatement(undefined, createConstDeclarationList([ - createVariableDeclaration("_super", undefined, createCall(createParen(createFunctionExpression(undefined, undefined, undefined, [ + createVariableDeclaration("_super", undefined, createCall(createParen(createFunctionExpression(undefined, undefined, undefined, undefined, [ createParameter("geti"), createParameter("seti") ], undefined, createBlock([ @@ -9780,19 +10718,19 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = skipParentheses(node); switch (target.kind) { - case 69: + case 70: return cacheIdentifiers; - case 97: + case 98: case 8: case 9: return false; - case 170: + case 171: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 171: + case 172: return target.properties.length > 0; default: return true; @@ -9806,13 +10744,13 @@ var ts; thisArg = createThis(); target = callee; } - else if (callee.kind === 95) { + else if (callee.kind === 96) { thisArg = createThis(); target = languageVersion < 2 ? createIdentifier("_super", callee) : callee; } else { switch (callee.kind) { - case 172: { + case 173: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { thisArg = createTempVariable(recordTempVariable); target = createPropertyAccess(createAssignment(thisArg, callee.expression, callee.expression), callee.name, callee); @@ -9823,7 +10761,7 @@ var ts; } break; } - case 173: { + case 174: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { thisArg = createTempVariable(recordTempVariable); target = createElementAccess(createAssignment(thisArg, callee.expression, callee.expression), callee.argumentExpression, callee); @@ -9873,14 +10811,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 149: case 150: + case 151: return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); case 253: return createExpressionForPropertyAssignment(property, receiver); case 254: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 147: + case 148: return createExpressionForMethodDeclaration(property, receiver); } } @@ -9890,13 +10828,13 @@ var ts; if (property === firstAccessor) { var properties_1 = []; if (getAccessor) { - var getterFunction = createFunctionExpression(undefined, undefined, undefined, getAccessor.parameters, undefined, getAccessor.body, getAccessor); + var getterFunction = createFunctionExpression(getAccessor.modifiers, undefined, undefined, undefined, getAccessor.parameters, undefined, getAccessor.body, getAccessor); setOriginalNode(getterFunction, getAccessor); var getter = createPropertyAssignment("get", getterFunction); properties_1.push(getter); } if (setAccessor) { - var setterFunction = createFunctionExpression(undefined, undefined, undefined, setAccessor.parameters, undefined, setAccessor.body, setAccessor); + var setterFunction = createFunctionExpression(setAccessor.modifiers, undefined, undefined, undefined, setAccessor.parameters, undefined, setAccessor.body, setAccessor); setOriginalNode(setterFunction, setAccessor); var setter = createPropertyAssignment("set", setterFunction); properties_1.push(setter); @@ -9919,13 +10857,13 @@ var ts; return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, property.name, property.name), getSynthesizedClone(property.name), property), property)); } function createExpressionForMethodDeclaration(method, receiver) { - return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, method.name, method.name), setOriginalNode(createFunctionExpression(method.asteriskToken, undefined, undefined, method.parameters, undefined, method.body, method), method), method), method)); + return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, method.name, method.name), setOriginalNode(createFunctionExpression(method.modifiers, method.asteriskToken, undefined, undefined, method.parameters, undefined, method.body, method), method), method), method)); } function isUseStrictPrologue(node) { return node.expression.text === "use strict"; } function addPrologueDirectives(target, source, ensureUseStrict, visitor) { - ts.Debug.assert(target.length === 0, "PrologueDirectives should be at the first statement in the target statements array"); + ts.Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array"); var foundUseStrict = false; var statementOffset = 0; var numStatements = source.length; @@ -9938,16 +10876,20 @@ var ts; target.push(statement); } else { - if (ensureUseStrict && !foundUseStrict) { - target.push(startOnNewLine(createStatement(createLiteral("use strict")))); - foundUseStrict = true; - } - if (getEmitFlags(statement) & 8388608) { - target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); - } - else { - break; - } + break; + } + statementOffset++; + } + if (ensureUseStrict && !foundUseStrict) { + target.push(startOnNewLine(createStatement(createLiteral("use strict")))); + } + while (statementOffset < numStatements) { + var statement = source[statementOffset]; + if (getEmitFlags(statement) & 8388608) { + target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); + } + else { + break; } statementOffset++; } @@ -9978,7 +10920,7 @@ var ts; ts.ensureUseStrict = ensureUseStrict; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = skipPartiallyEmittedExpressions(operand); - if (skipped.kind === 178) { + if (skipped.kind === 179) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -9987,15 +10929,15 @@ var ts; } ts.parenthesizeBinaryOperand = parenthesizeBinaryOperand; function binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { - var binaryOperatorPrecedence = ts.getOperatorPrecedence(187, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(187, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(188, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(188, binaryOperator); var emittedOperand = skipPartiallyEmittedExpressions(operand); var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { case -1: if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 - && operand.kind === 190) { + && operand.kind === 191) { return false; } return true; @@ -10011,7 +10953,7 @@ var ts; if (operatorHasAssociativeProperty(binaryOperator)) { return false; } - if (binaryOperator === 35) { + if (binaryOperator === 36) { var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0; if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { return false; @@ -10024,17 +10966,17 @@ var ts; } } function operatorHasAssociativeProperty(binaryOperator) { - return binaryOperator === 37 + return binaryOperator === 38 + || binaryOperator === 48 || binaryOperator === 47 - || binaryOperator === 46 - || binaryOperator === 48; + || binaryOperator === 49; } function getLiteralKindOfBinaryPlusOperand(node) { node = skipPartiallyEmittedExpressions(node); if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 187 && node.operatorToken.kind === 35) { + if (node.kind === 188 && node.operatorToken.kind === 36) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -10051,9 +10993,9 @@ var ts; function parenthesizeForNew(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); switch (emittedExpression.kind) { - case 174: - return createParen(expression); case 175: + return createParen(expression); + case 176: return emittedExpression.arguments ? expression : createParen(expression); @@ -10064,7 +11006,7 @@ var ts; function parenthesizeForAccess(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 175 || emittedExpression.arguments) + && (emittedExpression.kind !== 176 || emittedExpression.arguments) && emittedExpression.kind !== 8) { return expression; } @@ -10102,7 +11044,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(187, 24); + var commaPrecedence = ts.getOperatorPrecedence(188, 25); return expressionPrecedence > commaPrecedence ? expression : createParen(expression, expression); @@ -10113,7 +11055,7 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = skipPartiallyEmittedExpressions(callee).kind; - if (kind === 179 || kind === 180) { + if (kind === 180 || kind === 181) { var mutableCall = getMutableClone(emittedExpression); mutableCall.expression = createParen(callee, callee); return recreatePartiallyEmittedExpressions(expression, mutableCall); @@ -10121,7 +11063,7 @@ var ts; } else { var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; - if (leftmostExpressionKind === 171 || leftmostExpressionKind === 179) { + if (leftmostExpressionKind === 172 || leftmostExpressionKind === 180) { return createParen(expression, expression); } } @@ -10139,18 +11081,18 @@ var ts; function getLeftmostExpression(node) { while (true) { switch (node.kind) { - case 186: + case 187: node = node.operand; continue; - case 187: + case 188: node = node.left; continue; - case 188: + case 189: node = node.condition; continue; + case 175: case 174: case 173: - case 172: node = node.expression; continue; case 288: @@ -10162,12 +11104,19 @@ var ts; } function parenthesizeConciseBody(body) { var emittedBody = skipPartiallyEmittedExpressions(body); - if (emittedBody.kind === 171) { + if (emittedBody.kind === 172) { return createParen(body, body); } return body; } ts.parenthesizeConciseBody = parenthesizeConciseBody; + (function (OuterExpressionKinds) { + OuterExpressionKinds[OuterExpressionKinds["Parentheses"] = 1] = "Parentheses"; + OuterExpressionKinds[OuterExpressionKinds["Assertions"] = 2] = "Assertions"; + OuterExpressionKinds[OuterExpressionKinds["PartiallyEmittedExpressions"] = 4] = "PartiallyEmittedExpressions"; + OuterExpressionKinds[OuterExpressionKinds["All"] = 7] = "All"; + })(ts.OuterExpressionKinds || (ts.OuterExpressionKinds = {})); + var OuterExpressionKinds = ts.OuterExpressionKinds; function skipOuterExpressions(node, kinds) { if (kinds === void 0) { kinds = 7; } var previousNode; @@ -10187,7 +11136,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipParentheses(node) { - while (node.kind === 178) { + while (node.kind === 179) { node = node.expression; } return node; @@ -10350,10 +11299,10 @@ var ts; var name_9 = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name_9) ? name_9 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); } - if (node.kind === 230 && node.importClause) { + if (node.kind === 231 && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 236 && node.moduleSpecifier) { + if (node.kind === 237 && node.moduleSpecifier) { return getGeneratedNameForNode(node); } return undefined; @@ -10402,10 +11351,10 @@ var ts; if (kind === 256) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } - else if (kind === 69) { + else if (kind === 70) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } - else if (kind < 139) { + else if (kind < 140) { return new (TokenConstructor || (TokenConstructor = ts.objectAllocator.getTokenConstructor()))(kind, pos, end); } else { @@ -10441,10 +11390,10 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 139: + case 140: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 141: + case 142: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); @@ -10455,12 +11404,12 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 142: + case 143: + case 146: case 145: - case 144: case 253: - case 218: - case 169: + case 219: + case 170: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -10469,24 +11418,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 156: case 157: - case 151: + case 158: case 152: case 153: + case 154: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 147: - case 146: case 148: + case 147: case 149: case 150: - case 179: - case 220: + case 151: case 180: + case 221: + case 181: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -10497,163 +11446,156 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 155: + case 156: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 154: + case 155: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 158: - return visitNode(cbNode, node.exprName); case 159: - return visitNodes(cbNodes, node.members); + return visitNode(cbNode, node.exprName); case 160: - return visitNode(cbNode, node.elementType); + return visitNodes(cbNodes, node.members); case 161: - return visitNodes(cbNodes, node.elementTypes); + return visitNode(cbNode, node.elementType); case 162: + return visitNodes(cbNodes, node.elementTypes); case 163: - return visitNodes(cbNodes, node.types); case 164: + return visitNodes(cbNodes, node.types); + case 165: return visitNode(cbNode, node.type); - case 166: - return visitNode(cbNode, node.literal); case 167: + return visitNode(cbNode, node.literal); case 168: - return visitNodes(cbNodes, node.elements); - case 170: + case 169: return visitNodes(cbNodes, node.elements); case 171: - return visitNodes(cbNodes, node.properties); + return visitNodes(cbNodes, node.elements); case 172: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.name); + return visitNodes(cbNodes, node.properties); case 173: return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.argumentExpression); + visitNode(cbNode, node.name); case 174: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.argumentExpression); case 175: + case 176: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 176: + case 177: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 177: + case 178: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 178: - return visitNode(cbNode, node.expression); - case 181: + case 179: return visitNode(cbNode, node.expression); case 182: return visitNode(cbNode, node.expression); case 183: return visitNode(cbNode, node.expression); - case 185: - return visitNode(cbNode, node.operand); - case 190: - return visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.expression); case 184: return visitNode(cbNode, node.expression); case 186: return visitNode(cbNode, node.operand); + case 191: + return visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.expression); + case 185: + return visitNode(cbNode, node.expression); case 187: + return visitNode(cbNode, node.operand); + case 188: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 195: + case 196: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 196: + case 197: return visitNode(cbNode, node.expression); - case 188: + case 189: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 191: + case 192: return visitNode(cbNode, node.expression); - case 199: - case 226: + case 200: + case 227: return visitNodes(cbNodes, node.statements); case 256: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 200: + case 201: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 219: + case 220: return visitNodes(cbNodes, node.declarations); - case 202: - return visitNode(cbNode, node.expression); case 203: + return visitNode(cbNode, node.expression); + case 204: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 204: + case 205: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 205: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); case 206: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.condition) || - visitNode(cbNode, node.incrementor) || + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 207: return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || + visitNode(cbNode, node.condition) || + visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); case 208: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 209: - case 210: - return visitNode(cbNode, node.label); - case 211: - return visitNode(cbNode, node.expression); - case 212: - return visitNode(cbNode, node.expression) || + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); + case 210: + case 211: + return visitNode(cbNode, node.label); + case 212: + return visitNode(cbNode, node.expression); case 213: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 214: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 227: + case 228: return visitNodes(cbNodes, node.clauses); case 249: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); case 250: return visitNodes(cbNodes, node.statements); - case 214: + case 215: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 215: - return visitNode(cbNode, node.expression); case 216: + return visitNode(cbNode, node.expression); + case 217: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); case 252: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 143: + case 144: return visitNode(cbNode, node.expression); - case 221: - case 192: - 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 222: + case 193: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -10665,8 +11607,15 @@ var ts; visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || - visitNode(cbNode, node.type); + visitNodes(cbNodes, node.heritageClauses) || + visitNodes(cbNodes, node.members); case 224: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNode(cbNode, node.type); + case 225: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -10674,65 +11623,65 @@ var ts; case 255: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 225: + case 226: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 229: + case 230: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 230: + case 231: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 231: + case 232: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 228: - return visitNode(cbNode, node.name); - case 232: + case 229: return visitNode(cbNode, node.name); case 233: - case 237: + return visitNode(cbNode, node.name); + case 234: + case 238: return visitNodes(cbNodes, node.elements); - case 236: + case 237: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 234: - case 238: + case 235: + case 239: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 235: + case 236: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 189: + case 190: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 197: + case 198: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 140: + case 141: return visitNode(cbNode, node.expression); case 251: return visitNodes(cbNodes, node.types); - case 194: + case 195: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 240: - return visitNode(cbNode, node.expression); - case 239: - return visitNodes(cbNodes, node.decorators); case 241: + return visitNode(cbNode, node.expression); + case 240: + return visitNodes(cbNodes, node.decorators); + case 242: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 242: case 243: + case 244: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); case 246: @@ -10834,7 +11783,7 @@ var ts; ts.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; var Parser; (function (Parser) { - var scanner = ts.createScanner(2, true); + var scanner = ts.createScanner(4, true); var disallowInAndDecoratorContext = 32768 | 131072; var NodeConstructor; var TokenConstructor; @@ -10851,9 +11800,9 @@ var ts; var parsingContext; var contextFlags; var parseErrorBeforeNextFinishedNode = false; - function parseSourceFile(fileName, _sourceText, languageVersion, _syntaxCursor, setParentNodes, scriptKind) { + function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes, scriptKind) { scriptKind = ts.ensureScriptKind(fileName, scriptKind); - initializeState(fileName, _sourceText, languageVersion, _syntaxCursor, scriptKind); + initializeState(sourceText, languageVersion, syntaxCursor, scriptKind); var result = parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind); clearState(); return result; @@ -10862,7 +11811,7 @@ var ts; function getLanguageVariant(scriptKind) { return scriptKind === 4 || scriptKind === 2 || scriptKind === 1 ? 1 : 0; } - function initializeState(fileName, _sourceText, languageVersion, _syntaxCursor, scriptKind) { + function initializeState(_sourceText, languageVersion, _syntaxCursor, scriptKind) { NodeConstructor = ts.objectAllocator.getNodeConstructor(); TokenConstructor = ts.objectAllocator.getTokenConstructor(); IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor(); @@ -11105,16 +12054,16 @@ var ts; return speculationHelper(callback, false); } function isIdentifier() { - if (token() === 69) { + if (token() === 70) { return true; } - if (token() === 114 && inYieldContext()) { + if (token() === 115 && inYieldContext()) { return false; } - if (token() === 119 && inAwaitContext()) { + if (token() === 120 && inAwaitContext()) { return false; } - return token() > 105; + return token() > 106; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -11155,20 +12104,20 @@ var ts; return finishNode(node); } function canParseSemicolon() { - if (token() === 23) { + if (token() === 24) { return true; } - return token() === 16 || token() === 1 || scanner.hasPrecedingLineBreak(); + return token() === 17 || token() === 1 || scanner.hasPrecedingLineBreak(); } function parseSemicolon() { if (canParseSemicolon()) { - if (token() === 23) { + if (token() === 24) { nextToken(); } return true; } else { - return parseExpected(23); + return parseExpected(24); } } function createNode(kind, pos) { @@ -11176,8 +12125,8 @@ var ts; if (!(pos >= 0)) { pos = scanner.getStartPos(); } - return kind >= 139 ? new NodeConstructor(kind, pos, pos) : - kind === 69 ? new IdentifierConstructor(kind, pos, pos) : + return kind >= 140 ? new NodeConstructor(kind, pos, pos) : + kind === 70 ? new IdentifierConstructor(kind, pos, pos) : new TokenConstructor(kind, pos, pos); } function createNodeArray(elements, pos) { @@ -11218,15 +12167,15 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(69); - if (token() !== 69) { + var node = createNode(70); + if (token() !== 70) { node.originalKeywordKind = token(); } node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - return createMissingNode(69, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(70, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -11243,7 +12192,7 @@ var ts; if (token() === 9 || token() === 8) { return parseLiteralNode(true); } - if (allowComputedPropertyNames && token() === 19) { + if (allowComputedPropertyNames && token() === 20) { return parseComputedPropertyName(); } return parseIdentifierName(); @@ -11258,10 +12207,10 @@ var ts; return token() === 9 || token() === 8 || ts.tokenIsIdentifierOrKeyword(token()); } function parseComputedPropertyName() { - var node = createNode(140); - parseExpected(19); - node.expression = allowInAnd(parseExpression); + var node = createNode(141); parseExpected(20); + node.expression = allowInAnd(parseExpression); + parseExpected(21); return finishNode(node); } function parseContextualModifier(t) { @@ -11275,20 +12224,20 @@ var ts; return canFollowModifier(); } function nextTokenCanFollowModifier() { - if (token() === 74) { - return nextToken() === 81; + if (token() === 75) { + return nextToken() === 82; } - if (token() === 82) { + if (token() === 83) { nextToken(); - if (token() === 77) { + if (token() === 78) { return lookAhead(nextTokenIsClassOrFunctionOrAsync); } - return token() !== 37 && token() !== 116 && token() !== 15 && canFollowModifier(); + return token() !== 38 && token() !== 117 && token() !== 16 && canFollowModifier(); } - if (token() === 77) { + if (token() === 78) { return nextTokenIsClassOrFunctionOrAsync(); } - if (token() === 113) { + if (token() === 114) { nextToken(); return canFollowModifier(); } @@ -11298,16 +12247,16 @@ var ts; return ts.isModifierKind(token()) && tryParse(nextTokenCanFollowModifier); } function canFollowModifier() { - return token() === 19 - || token() === 15 - || token() === 37 - || token() === 22 + return token() === 20 + || token() === 16 + || token() === 38 + || token() === 23 || isLiteralPropertyName(); } function nextTokenIsClassOrFunctionOrAsync() { nextToken(); - return token() === 73 || token() === 87 || - (token() === 118 && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 74 || token() === 88 || + (token() === 119 && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } function isListElement(parsingContext, inErrorRecovery) { var node = currentNode(parsingContext); @@ -11318,21 +12267,21 @@ var ts; case 0: case 1: case 3: - return !(token() === 23 && inErrorRecovery) && isStartOfStatement(); + return !(token() === 24 && inErrorRecovery) && isStartOfStatement(); case 2: - return token() === 71 || token() === 77; + return token() === 72 || token() === 78; case 4: return lookAhead(isTypeMemberStart); case 5: - return lookAhead(isClassMemberStart) || (token() === 23 && !inErrorRecovery); + return lookAhead(isClassMemberStart) || (token() === 24 && !inErrorRecovery); case 6: - return token() === 19 || isLiteralPropertyName(); + return token() === 20 || isLiteralPropertyName(); case 12: - return token() === 19 || token() === 37 || isLiteralPropertyName(); + return token() === 20 || token() === 38 || isLiteralPropertyName(); case 9: - return token() === 19 || isLiteralPropertyName(); + return token() === 20 || isLiteralPropertyName(); case 7: - if (token() === 15) { + if (token() === 16) { return lookAhead(isValidHeritageClauseObjectLiteral); } if (!inErrorRecovery) { @@ -11344,23 +12293,23 @@ var ts; case 8: return isIdentifierOrPattern(); case 10: - return token() === 24 || token() === 22 || isIdentifierOrPattern(); + return token() === 25 || token() === 23 || isIdentifierOrPattern(); case 17: return isIdentifier(); case 11: case 15: - return token() === 24 || token() === 22 || isStartOfExpression(); + return token() === 25 || token() === 23 || isStartOfExpression(); case 16: return isStartOfParameter(); case 18: case 19: - return token() === 24 || isStartOfType(); + return token() === 25 || isStartOfType(); case 20: return isHeritageClause(); case 21: return ts.tokenIsIdentifierOrKeyword(token()); case 13: - return ts.tokenIsIdentifierOrKeyword(token()) || token() === 15; + return ts.tokenIsIdentifierOrKeyword(token()) || token() === 16; case 14: return true; case 22: @@ -11373,10 +12322,10 @@ var ts; ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token() === 15); - if (nextToken() === 16) { + ts.Debug.assert(token() === 16); + if (nextToken() === 17) { var next = nextToken(); - return next === 24 || next === 15 || next === 83 || next === 106; + return next === 25 || next === 16 || next === 84 || next === 107; } return true; } @@ -11389,8 +12338,8 @@ var ts; return ts.tokenIsIdentifierOrKeyword(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 106 || - token() === 83) { + if (token() === 107 || + token() === 84) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -11412,39 +12361,39 @@ var ts; case 12: case 9: case 21: - return token() === 16; + return token() === 17; case 3: - return token() === 16 || token() === 71 || token() === 77; + return token() === 17 || token() === 72 || token() === 78; case 7: - return token() === 15 || token() === 83 || token() === 106; + return token() === 16 || token() === 84 || token() === 107; case 8: return isVariableDeclaratorListTerminator(); case 17: - return token() === 27 || token() === 17 || token() === 15 || token() === 83 || token() === 106; + return token() === 28 || token() === 18 || token() === 16 || token() === 84 || token() === 107; case 11: - return token() === 18 || token() === 23; + return token() === 19 || token() === 24; case 15: case 19: case 10: - return token() === 20; + return token() === 21; case 16: - return token() === 18 || token() === 20; + return token() === 19 || token() === 21; case 18: - return token() !== 24; + return token() !== 25; case 20: - return token() === 15 || token() === 16; + return token() === 16 || token() === 17; case 13: - return token() === 27 || token() === 39; + return token() === 28 || token() === 40; case 14: - return token() === 25 && lookAhead(nextTokenIsSlash); + return token() === 26 && lookAhead(nextTokenIsSlash); case 22: - return token() === 18 || token() === 54 || token() === 16; + return token() === 19 || token() === 55 || token() === 17; case 23: - return token() === 27 || token() === 16; + return token() === 28 || token() === 17; case 25: - return token() === 20 || token() === 16; + return token() === 21 || token() === 17; case 24: - return token() === 16; + return token() === 17; } } function isVariableDeclaratorListTerminator() { @@ -11454,7 +12403,7 @@ var ts; if (isInOrOfKeyword(token())) { return true; } - if (token() === 34) { + if (token() === 35) { return true; } return false; @@ -11558,17 +12507,17 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 148: - case 153: case 149: + case 154: case 150: - case 145: - case 198: + case 151: + case 146: + case 199: return true; - case 147: + case 148: var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 69 && - methodDeclaration.name.originalKeywordKind === 121; + var nameIsConstructor = methodDeclaration.name.kind === 70 && + methodDeclaration.name.originalKeywordKind === 122; return !nameIsConstructor; } } @@ -11587,35 +12536,35 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 220: + case 221: + case 201: case 200: - case 199: + case 204: case 203: - case 202: - case 215: + case 216: + case 212: + case 214: case 211: - case 213: case 210: + case 208: case 209: case 207: - case 208: case 206: - case 205: - case 212: - case 201: - case 216: - case 214: - case 204: + case 213: + case 202: case 217: + case 215: + case 205: + case 218: + case 231: case 230: - case 229: + case 237: case 236: - case 235: - case 225: - case 221: + case 226: case 222: - case 224: case 223: + case 225: + case 224: return true; } } @@ -11627,25 +12576,25 @@ var ts; function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 152: - case 146: case 153: - case 144: - case 151: + case 147: + case 154: + case 145: + case 152: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 218) { + if (node.kind !== 219) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 142) { + if (node.kind !== 143) { return false; } var parameter = node; @@ -11699,15 +12648,15 @@ var ts; if (isListElement(kind, false)) { result.push(parseListElement(kind, parseElement)); commaStart = scanner.getTokenPos(); - if (parseOptional(24)) { + if (parseOptional(25)) { continue; } commaStart = -1; if (isListTerminator(kind)) { break; } - parseExpected(24); - if (considerSemicolonAsDelimiter && token() === 23 && !scanner.hasPrecedingLineBreak()) { + parseExpected(25); + if (considerSemicolonAsDelimiter && token() === 24 && !scanner.hasPrecedingLineBreak()) { nextToken(); } continue; @@ -11739,8 +12688,8 @@ var ts; } function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); - while (parseOptional(21)) { - var node = createNode(139, entity.pos); + while (parseOptional(22)) { + var node = createNode(140, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -11751,33 +12700,33 @@ var ts; if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token())) { var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); if (matchesPattern) { - return createMissingNode(69, true, ts.Diagnostics.Identifier_expected); + return createMissingNode(70, true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(189); + var template = createNode(190); template.head = parseTemplateHead(); - ts.Debug.assert(template.head.kind === 12, "Template head has wrong token kind"); + ts.Debug.assert(template.head.kind === 13, "Template head has wrong token kind"); var templateSpans = createNodeArray(); do { templateSpans.push(parseTemplateSpan()); - } while (ts.lastOrUndefined(templateSpans).literal.kind === 13); + } while (ts.lastOrUndefined(templateSpans).literal.kind === 14); templateSpans.end = getNodeEnd(); template.templateSpans = templateSpans; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(197); + var span = createNode(198); span.expression = allowInAnd(parseExpression); var literal; - if (token() === 16) { + if (token() === 17) { reScanTemplateToken(); literal = parseTemplateMiddleOrTemplateTail(); } else { - literal = parseExpectedToken(14, false, ts.Diagnostics._0_expected, ts.tokenToString(16)); + literal = parseExpectedToken(15, false, ts.Diagnostics._0_expected, ts.tokenToString(17)); } span.literal = literal; return finishNode(span); @@ -11787,12 +12736,12 @@ var ts; } function parseTemplateHead() { var fragment = parseLiteralLikeNode(token(), false); - ts.Debug.assert(fragment.kind === 12, "Template head has wrong token kind"); + ts.Debug.assert(fragment.kind === 13, "Template head has wrong token kind"); return fragment; } function parseTemplateMiddleOrTemplateTail() { var fragment = parseLiteralLikeNode(token(), false); - ts.Debug.assert(fragment.kind === 13 || fragment.kind === 14, "Template fragment has wrong token kind"); + ts.Debug.assert(fragment.kind === 14 || fragment.kind === 15, "Template fragment has wrong token kind"); return fragment; } function parseLiteralLikeNode(kind, internName) { @@ -11817,35 +12766,35 @@ var ts; } function parseTypeReference() { var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - var node = createNode(155, typeName.pos); + var node = createNode(156, typeName.pos); node.typeName = typeName; - if (!scanner.hasPrecedingLineBreak() && token() === 25) { - node.typeArguments = parseBracketedList(18, parseType, 25, 27); + if (!scanner.hasPrecedingLineBreak() && token() === 26) { + node.typeArguments = parseBracketedList(18, parseType, 26, 28); } return finishNode(node); } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(154, lhs.pos); + var node = createNode(155, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(165); + var node = createNode(166); nextToken(); return finishNode(node); } function parseTypeQuery() { - var node = createNode(158); - parseExpected(101); + var node = createNode(159); + parseExpected(102); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(141); + var node = createNode(142); node.name = parseIdentifier(); - if (parseOptional(83)) { + if (parseOptional(84)) { if (isStartOfType() || !isStartOfExpression()) { node.constraint = parseType(); } @@ -11856,34 +12805,34 @@ var ts; return finishNode(node); } function parseTypeParameters() { - if (token() === 25) { - return parseBracketedList(17, parseTypeParameter, 25, 27); + if (token() === 26) { + return parseBracketedList(17, parseTypeParameter, 26, 28); } } function parseParameterType() { - if (parseOptional(54)) { + if (parseOptional(55)) { return parseType(); } return undefined; } function isStartOfParameter() { - return token() === 22 || isIdentifierOrPattern() || ts.isModifierKind(token()) || token() === 55 || token() === 97; + return token() === 23 || isIdentifierOrPattern() || ts.isModifierKind(token()) || token() === 56 || token() === 98; } function parseParameter() { - var node = createNode(142); - if (token() === 97) { + var node = createNode(143); + if (token() === 98) { node.name = createIdentifier(true, undefined); node.type = parseParameterType(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - node.dotDotDotToken = parseOptionalToken(22); + node.dotDotDotToken = parseOptionalToken(23); node.name = parseIdentifierOrPattern(); if (ts.getFullWidth(node.name) === 0 && !ts.hasModifiers(node) && ts.isModifierKind(token())) { nextToken(); } - node.questionToken = parseOptionalToken(53); + node.questionToken = parseOptionalToken(54); node.type = parseParameterType(); node.initializer = parseBindingElementInitializer(true); return addJSDocComment(finishNode(node)); @@ -11895,7 +12844,7 @@ var ts; return parseInitializer(true); } function fillSignature(returnToken, yieldContext, awaitContext, requireCompleteParameterList, signature) { - var returnTokenRequired = returnToken === 34; + var returnTokenRequired = returnToken === 35; signature.typeParameters = parseTypeParameters(); signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); if (returnTokenRequired) { @@ -11907,7 +12856,7 @@ var ts; } } function parseParameterList(yieldContext, awaitContext, requireCompleteParameterList) { - if (parseExpected(17)) { + if (parseExpected(18)) { var savedYieldContext = inYieldContext(); var savedAwaitContext = inAwaitContext(); setYieldContext(yieldContext); @@ -11915,7 +12864,7 @@ var ts; var result = parseDelimitedList(16, parseParameter); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); - if (!parseExpected(18) && requireCompleteParameterList) { + if (!parseExpected(19) && requireCompleteParameterList) { return undefined; } return result; @@ -11923,29 +12872,29 @@ var ts; return requireCompleteParameterList ? undefined : createMissingList(); } function parseTypeMemberSemicolon() { - if (parseOptional(24)) { + if (parseOptional(25)) { return; } parseSemicolon(); } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 152) { - parseExpected(92); + if (kind === 153) { + parseExpected(93); } - fillSignature(54, false, false, false, node); + fillSignature(55, false, false, false, node); parseTypeMemberSemicolon(); return addJSDocComment(finishNode(node)); } function isIndexSignature() { - if (token() !== 19) { + if (token() !== 20) { return false; } return lookAhead(isUnambiguouslyIndexSignature); } function isUnambiguouslyIndexSignature() { nextToken(); - if (token() === 22 || token() === 20) { + if (token() === 23 || token() === 21) { return true; } if (ts.isModifierKind(token())) { @@ -11960,43 +12909,43 @@ var ts; else { nextToken(); } - if (token() === 54 || token() === 24) { + if (token() === 55 || token() === 25) { return true; } - if (token() !== 53) { + if (token() !== 54) { return false; } nextToken(); - return token() === 54 || token() === 24 || token() === 20; + return token() === 55 || token() === 25 || token() === 21; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(153, fullStart); + var node = createNode(154, fullStart); node.decorators = decorators; node.modifiers = modifiers; - node.parameters = parseBracketedList(16, parseParameter, 19, 20); + node.parameters = parseBracketedList(16, parseParameter, 20, 21); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); return finishNode(node); } function parsePropertyOrMethodSignature(fullStart, modifiers) { var name = parsePropertyName(); - var questionToken = parseOptionalToken(53); - if (token() === 17 || token() === 25) { - var method = createNode(146, fullStart); + var questionToken = parseOptionalToken(54); + if (token() === 18 || token() === 26) { + var method = createNode(147, fullStart); method.modifiers = modifiers; method.name = name; method.questionToken = questionToken; - fillSignature(54, false, false, false, method); + fillSignature(55, false, false, false, method); parseTypeMemberSemicolon(); return addJSDocComment(finishNode(method)); } else { - var property = createNode(144, fullStart); + var property = createNode(145, fullStart); property.modifiers = modifiers; property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); - if (token() === 56) { + if (token() === 57) { property.initializer = parseNonParameterInitializer(); } parseTypeMemberSemicolon(); @@ -12005,14 +12954,14 @@ var ts; } function isTypeMemberStart() { var idToken; - if (token() === 17 || token() === 25) { + if (token() === 18 || token() === 26) { return true; } while (ts.isModifierKind(token())) { idToken = token(); nextToken(); } - if (token() === 19) { + if (token() === 20) { return true; } if (isLiteralPropertyName()) { @@ -12020,22 +12969,22 @@ var ts; nextToken(); } if (idToken) { - return token() === 17 || - token() === 25 || - token() === 53 || + return token() === 18 || + token() === 26 || token() === 54 || - token() === 24 || + token() === 55 || + token() === 25 || canParseSemicolon(); } return false; } function parseTypeMember() { - if (token() === 17 || token() === 25) { - return parseSignatureMember(151); - } - if (token() === 92 && lookAhead(isStartOfConstructSignature)) { + if (token() === 18 || token() === 26) { return parseSignatureMember(152); } + if (token() === 93 && lookAhead(isStartOfConstructSignature)) { + return parseSignatureMember(153); + } var fullStart = getNodePos(); var modifiers = parseModifiers(); if (isIndexSignature()) { @@ -12045,18 +12994,18 @@ var ts; } function isStartOfConstructSignature() { nextToken(); - return token() === 17 || token() === 25; + return token() === 18 || token() === 26; } function parseTypeLiteral() { - var node = createNode(159); + var node = createNode(160); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseObjectTypeMembers() { var members; - if (parseExpected(15)) { + if (parseExpected(16)) { members = parseList(4, parseTypeMember); - parseExpected(16); + parseExpected(17); } else { members = createMissingList(); @@ -12064,31 +13013,31 @@ var ts; return members; } function parseTupleType() { - var node = createNode(161); - node.elementTypes = parseBracketedList(19, parseType, 19, 20); + var node = createNode(162); + node.elementTypes = parseBracketedList(19, parseType, 20, 21); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(164); - parseExpected(17); - node.type = parseType(); + var node = createNode(165); parseExpected(18); + node.type = parseType(); + parseExpected(19); return finishNode(node); } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 157) { - parseExpected(92); + if (kind === 158) { + parseExpected(93); } - fillSignature(34, false, false, false, node); + fillSignature(35, false, false, false, node); return finishNode(node); } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token() === 21 ? undefined : node; + return token() === 22 ? undefined : node; } function parseLiteralTypeNode() { - var node = createNode(166); + var node = createNode(167); node.literal = parseSimpleUnaryExpression(); finishNode(node); return node; @@ -12098,41 +13047,41 @@ var ts; } function parseNonArrayType() { switch (token()) { - case 117: - case 132: - case 130: - case 120: + case 118: case 133: - case 135: - case 127: + case 131: + case 121: + case 134: + case 136: + case 128: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); case 9: case 8: - case 99: - case 84: + case 100: + case 85: return parseLiteralTypeNode(); - case 36: + case 37: return lookAhead(nextTokenIsNumericLiteral) ? parseLiteralTypeNode() : parseTypeReference(); - case 103: - case 93: + case 104: + case 94: return parseTokenNode(); - case 97: { + case 98: { var thisKeyword = parseThisTypeNode(); - if (token() === 124 && !scanner.hasPrecedingLineBreak()) { + if (token() === 125 && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 101: + case 102: return parseTypeQuery(); - case 15: + case 16: return parseTypeLiteral(); - case 19: + case 20: return parseTupleType(); - case 17: + case 18: return parseParenthesizedType(); default: return parseTypeReference(); @@ -12140,29 +13089,29 @@ var ts; } function isStartOfType() { switch (token()) { - case 117: - case 132: - case 130: - case 120: + case 118: case 133: - case 103: - case 135: + case 131: + case 121: + case 134: + case 104: + case 136: + case 94: + case 98: + case 102: + case 128: + case 16: + case 20: + case 26: case 93: - case 97: - case 101: - case 127: - case 15: - case 19: - case 25: - case 92: case 9: case 8: - case 99: - case 84: + case 100: + case 85: return true; - case 36: + case 37: return lookAhead(nextTokenIsNumericLiteral); - case 17: + case 18: return lookAhead(isStartOfParenthesizedOrFunctionType); default: return isIdentifier(); @@ -12170,13 +13119,13 @@ var ts; } function isStartOfParenthesizedOrFunctionType() { nextToken(); - return token() === 18 || isStartOfParameter() || isStartOfType(); + return token() === 19 || isStartOfParameter() || isStartOfType(); } function parseArrayTypeOrHigher() { var type = parseNonArrayType(); - while (!scanner.hasPrecedingLineBreak() && parseOptional(19)) { - parseExpected(20); - var node = createNode(160, type.pos); + while (!scanner.hasPrecedingLineBreak() && parseOptional(20)) { + parseExpected(21); + var node = createNode(161, type.pos); node.elementType = type; type = finishNode(node); } @@ -12197,26 +13146,26 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(163, parseArrayTypeOrHigher, 46); + return parseUnionOrIntersectionType(164, parseArrayTypeOrHigher, 47); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(162, parseIntersectionTypeOrHigher, 47); + return parseUnionOrIntersectionType(163, parseIntersectionTypeOrHigher, 48); } function isStartOfFunctionType() { - if (token() === 25) { + if (token() === 26) { return true; } - return token() === 17 && lookAhead(isUnambiguouslyStartOfFunctionType); + return token() === 18 && lookAhead(isUnambiguouslyStartOfFunctionType); } function skipParameterStart() { if (ts.isModifierKind(token())) { parseModifiers(); } - if (isIdentifier() || token() === 97) { + if (isIdentifier() || token() === 98) { nextToken(); return true; } - if (token() === 19 || token() === 15) { + if (token() === 20 || token() === 16) { var previousErrorCount = parseDiagnostics.length; parseIdentifierOrPattern(); return previousErrorCount === parseDiagnostics.length; @@ -12225,17 +13174,17 @@ var ts; } function isUnambiguouslyStartOfFunctionType() { nextToken(); - if (token() === 18 || token() === 22) { + if (token() === 19 || token() === 23) { return true; } if (skipParameterStart()) { - if (token() === 54 || token() === 24 || - token() === 53 || token() === 56) { + if (token() === 55 || token() === 25 || + token() === 54 || token() === 57) { return true; } - if (token() === 18) { + if (token() === 19) { nextToken(); - if (token() === 34) { + if (token() === 35) { return true; } } @@ -12246,7 +13195,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(154, typePredicateVariable.pos); + var node = createNode(155, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -12257,7 +13206,7 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 124 && !scanner.hasPrecedingLineBreak()) { + if (token() === 125 && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } @@ -12267,36 +13216,36 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(156); - } - if (token() === 92) { return parseFunctionOrConstructorType(157); } + if (token() === 93) { + return parseFunctionOrConstructorType(158); + } return parseUnionTypeOrHigher(); } function parseTypeAnnotation() { - return parseOptional(54) ? parseType() : undefined; + return parseOptional(55) ? parseType() : undefined; } function isStartOfLeftHandSideExpression() { switch (token()) { - case 97: - case 95: - case 93: - case 99: - case 84: + case 98: + case 96: + case 94: + case 100: + case 85: case 8: case 9: - case 11: case 12: - case 17: - case 19: - case 15: - case 87: - case 73: - case 92: - case 39: - case 61: - case 69: + case 13: + case 18: + case 20: + case 16: + case 88: + case 74: + case 93: + case 40: + case 62: + case 70: return true; default: return isIdentifier(); @@ -12307,18 +13256,18 @@ var ts; return true; } switch (token()) { - case 35: case 36: + case 37: + case 51: case 50: - case 49: - case 78: - case 101: - case 103: - case 41: + case 79: + case 102: + case 104: case 42: - case 25: - case 119: - case 114: + case 43: + case 26: + case 120: + case 115: return true; default: if (isBinaryOperator()) { @@ -12328,10 +13277,10 @@ var ts; } } function isStartOfExpressionStatement() { - return token() !== 15 && - token() !== 87 && - token() !== 73 && - token() !== 55 && + return token() !== 16 && + token() !== 88 && + token() !== 74 && + token() !== 56 && isStartOfExpression(); } function parseExpression() { @@ -12341,7 +13290,7 @@ var ts; } var expr = parseAssignmentExpressionOrHigher(); var operatorToken; - while ((operatorToken = parseOptionalToken(24))) { + while ((operatorToken = parseOptionalToken(25))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); } if (saveDecoratorContext) { @@ -12350,12 +13299,12 @@ var ts; return expr; } function parseInitializer(inParameter) { - if (token() !== 56) { - if (scanner.hasPrecedingLineBreak() || (inParameter && token() === 15) || !isStartOfExpression()) { + if (token() !== 57) { + if (scanner.hasPrecedingLineBreak() || (inParameter && token() === 16) || !isStartOfExpression()) { return undefined; } } - parseExpected(56); + parseExpected(57); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { @@ -12367,7 +13316,7 @@ var ts; return arrowExpression; } var expr = parseBinaryExpressionOrHigher(0); - if (expr.kind === 69 && token() === 34) { + if (expr.kind === 70 && token() === 35) { return parseSimpleArrowFunctionExpression(expr); } if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) { @@ -12376,7 +13325,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token() === 114) { + if (token() === 115) { if (inYieldContext()) { return true; } @@ -12389,11 +13338,11 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(190); + var node = createNode(191); nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token() === 37 || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(37); + (token() === 38 || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(38); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -12402,21 +13351,21 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier, asyncModifier) { - ts.Debug.assert(token() === 34, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + ts.Debug.assert(token() === 35, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(180, asyncModifier.pos); + node = createNode(181, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(180, identifier.pos); + node = createNode(181, identifier.pos); } - var parameter = createNode(142, identifier.pos); + var parameter = createNode(143, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos); node.parameters.end = parameter.end; - node.equalsGreaterThanToken = parseExpectedToken(34, false, ts.Diagnostics._0_expected, "=>"); + node.equalsGreaterThanToken = parseExpectedToken(35, false, ts.Diagnostics._0_expected, "=>"); node.body = parseArrowFunctionExpressionBody(!!asyncModifier); return addJSDocComment(finishNode(node)); } @@ -12433,78 +13382,78 @@ var ts; } var isAsync = !!(ts.getModifierFlags(arrowFunction) & 256); var lastToken = token(); - arrowFunction.equalsGreaterThanToken = parseExpectedToken(34, false, ts.Diagnostics._0_expected, "=>"); - arrowFunction.body = (lastToken === 34 || lastToken === 15) + arrowFunction.equalsGreaterThanToken = parseExpectedToken(35, false, ts.Diagnostics._0_expected, "=>"); + arrowFunction.body = (lastToken === 35 || lastToken === 16) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return addJSDocComment(finishNode(arrowFunction)); } function isParenthesizedArrowFunctionExpression() { - if (token() === 17 || token() === 25 || token() === 118) { + if (token() === 18 || token() === 26 || token() === 119) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token() === 34) { + if (token() === 35) { return 1; } return 0; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 118) { + if (token() === 119) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0; } - if (token() !== 17 && token() !== 25) { + if (token() !== 18 && token() !== 26) { return 0; } } var first = token(); var second = nextToken(); - if (first === 17) { - if (second === 18) { + if (first === 18) { + if (second === 19) { var third = nextToken(); switch (third) { - case 34: - case 54: - case 15: + case 35: + case 55: + case 16: return 1; default: return 0; } } - if (second === 19 || second === 15) { + if (second === 20 || second === 16) { return 2; } - if (second === 22) { + if (second === 23) { return 1; } if (!isIdentifier()) { return 0; } - if (nextToken() === 54) { + if (nextToken() === 55) { return 1; } return 2; } else { - ts.Debug.assert(first === 25); + ts.Debug.assert(first === 26); if (!isIdentifier()) { return 0; } if (sourceFile.languageVariant === 1) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 83) { + if (third === 84) { var fourth = nextToken(); switch (fourth) { - case 56: - case 27: + case 57: + case 28: return false; default: return true; } } - else if (third === 24) { + else if (third === 25) { return true; } return false; @@ -12521,7 +13470,7 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function tryParseAsyncSimpleArrowFunctionExpression() { - if (token() === 118) { + if (token() === 119) { var isUnParenthesizedAsyncArrowFunction = lookAhead(isUnParenthesizedAsyncArrowFunctionWorker); if (isUnParenthesizedAsyncArrowFunction === 1) { var asyncModifier = parseModifiersForArrowFunction(); @@ -12532,38 +13481,38 @@ var ts; return undefined; } function isUnParenthesizedAsyncArrowFunctionWorker() { - if (token() === 118) { + if (token() === 119) { nextToken(); - if (scanner.hasPrecedingLineBreak() || token() === 34) { + if (scanner.hasPrecedingLineBreak() || token() === 35) { return 0; } var expr = parseBinaryExpressionOrHigher(0); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 69 && token() === 34) { + if (!scanner.hasPrecedingLineBreak() && expr.kind === 70 && token() === 35) { return 1; } } return 0; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(180); + var node = createNode(181); node.modifiers = parseModifiersForArrowFunction(); var isAsync = !!(ts.getModifierFlags(node) & 256); - fillSignature(54, false, isAsync, !allowAmbiguity, node); + fillSignature(55, false, isAsync, !allowAmbiguity, node); if (!node.parameters) { return undefined; } - if (!allowAmbiguity && token() !== 34 && token() !== 15) { + if (!allowAmbiguity && token() !== 35 && token() !== 16) { return undefined; } return node; } function parseArrowFunctionExpressionBody(isAsync) { - if (token() === 15) { + if (token() === 16) { return parseFunctionBlock(false, isAsync, false); } - if (token() !== 23 && - token() !== 87 && - token() !== 73 && + if (token() !== 24 && + token() !== 88 && + token() !== 74 && isStartOfStatement() && !isStartOfExpressionStatement()) { return parseFunctionBlock(false, isAsync, true); @@ -12573,15 +13522,15 @@ var ts; : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); } function parseConditionalExpressionRest(leftOperand) { - var questionToken = parseOptionalToken(53); + var questionToken = parseOptionalToken(54); if (!questionToken) { return leftOperand; } - var node = createNode(188, leftOperand.pos); + var node = createNode(189, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(54, false, ts.Diagnostics._0_expected, ts.tokenToString(54)); + node.colonToken = parseExpectedToken(55, false, ts.Diagnostics._0_expected, ts.tokenToString(55)); node.whenFalse = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -12590,22 +13539,22 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 90 || t === 138; + return t === 91 || t === 139; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { reScanGreaterToken(); var newPrecedence = getBinaryOperatorPrecedence(); - var consumeCurrentOperator = token() === 38 ? + var consumeCurrentOperator = token() === 39 ? newPrecedence >= precedence : newPrecedence > precedence; if (!consumeCurrentOperator) { break; } - if (token() === 90 && inDisallowInContext()) { + if (token() === 91 && inDisallowInContext()) { break; } - if (token() === 116) { + if (token() === 117) { if (scanner.hasPrecedingLineBreak()) { break; } @@ -12621,92 +13570,92 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 90) { + if (inDisallowInContext() && token() === 91) { return false; } return getBinaryOperatorPrecedence() > 0; } function getBinaryOperatorPrecedence() { switch (token()) { - case 52: + case 53: return 1; - case 51: + case 52: return 2; - case 47: - return 3; case 48: + return 3; + case 49: return 4; - case 46: + case 47: return 5; - case 30: case 31: case 32: case 33: + case 34: return 6; - case 25: - case 27: + case 26: case 28: case 29: + case 30: + case 92: case 91: - case 90: - case 116: + case 117: return 7; - case 43: case 44: case 45: + case 46: return 8; - case 35: case 36: - return 9; case 37: - case 39: - case 40: - return 10; + return 9; case 38: + case 40: + case 41: + return 10; + case 39: return 11; } return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(187, left.pos); + var node = createNode(188, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(195, left.pos); + var node = createNode(196, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(185); + var node = createNode(186); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(181); - nextToken(); - node.expression = parseSimpleUnaryExpression(); - return finishNode(node); - } - function parseTypeOfExpression() { var node = createNode(182); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } - function parseVoidExpression() { + function parseTypeOfExpression() { var node = createNode(183); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } + function parseVoidExpression() { + var node = createNode(184); + nextToken(); + node.expression = parseSimpleUnaryExpression(); + return finishNode(node); + } function isAwaitExpression() { - if (token() === 119) { + if (token() === 120) { if (inAwaitContext()) { return true; } @@ -12715,7 +13664,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(184); + var node = createNode(185); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -12723,15 +13672,15 @@ var ts; function parseUnaryExpressionOrHigher() { if (isUpdateExpression()) { var incrementExpression = parseIncrementExpression(); - return token() === 38 ? + return token() === 39 ? parseBinaryExpressionRest(getBinaryOperatorPrecedence(), incrementExpression) : incrementExpression; } var unaryOperator = token(); var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token() === 38) { + if (token() === 39) { var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); - if (simpleUnaryExpression.kind === 177) { + if (simpleUnaryExpression.kind === 178) { 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 { @@ -12742,20 +13691,20 @@ var ts; } function parseSimpleUnaryExpression() { switch (token()) { - case 35: case 36: + case 37: + case 51: case 50: - case 49: return parsePrefixUnaryExpression(); - case 78: + case 79: return parseDeleteExpression(); - case 101: + case 102: return parseTypeOfExpression(); - case 103: + case 104: return parseVoidExpression(); - case 25: + case 26: return parseTypeAssertion(); - case 119: + case 120: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -12765,16 +13714,16 @@ var ts; } function isUpdateExpression() { switch (token()) { - case 35: case 36: + case 37: + case 51: case 50: - case 49: - case 78: - case 101: - case 103: - case 119: + case 79: + case 102: + case 104: + case 120: return false; - case 25: + case 26: if (sourceFile.languageVariant !== 1) { return false; } @@ -12783,20 +13732,20 @@ var ts; } } function parseIncrementExpression() { - if (token() === 41 || token() === 42) { - var node = createNode(185); + if (token() === 42 || token() === 43) { + var node = createNode(186); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); return finishNode(node); } - else if (sourceFile.languageVariant === 1 && token() === 25 && lookAhead(nextTokenIsIdentifierOrKeyword)) { + else if (sourceFile.languageVariant === 1 && token() === 26 && lookAhead(nextTokenIsIdentifierOrKeyword)) { return parseJsxElementOrSelfClosingElement(true); } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token() === 41 || token() === 42) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(186, expression.pos); + if ((token() === 42 || token() === 43) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(187, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -12805,7 +13754,7 @@ var ts; return expression; } function parseLeftHandSideExpressionOrHigher() { - var expression = token() === 95 + var expression = token() === 96 ? parseSuperExpression() : parseMemberExpressionOrHigher(); return parseCallExpressionRest(expression); @@ -12816,12 +13765,12 @@ var ts; } function parseSuperExpression() { var expression = parseTokenNode(); - if (token() === 17 || token() === 21 || token() === 19) { + if (token() === 18 || token() === 22 || token() === 20) { return expression; } - var node = createNode(172, expression.pos); + var node = createNode(173, expression.pos); node.expression = expression; - parseExpectedToken(21, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + parseExpectedToken(22, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); return finishNode(node); } @@ -12829,10 +13778,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 69) { + if (lhs.kind === 70) { return lhs.text === rhs.text; } - if (lhs.kind === 97) { + if (lhs.kind === 98) { return true; } return lhs.name.text === rhs.name.text && @@ -12841,8 +13790,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 243) { - var node = createNode(241, opening.pos); + if (opening.kind === 244) { + var node = createNode(242, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -12852,18 +13801,18 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 242); + ts.Debug.assert(opening.kind === 243); result = opening; } - if (inExpressionContext && token() === 25) { + if (inExpressionContext && token() === 26) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(187, result.pos); + var badNode = createNode(188, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; - badNode.operatorToken = createMissingNode(24, false, undefined); + badNode.operatorToken = createMissingNode(25, false, undefined); badNode.operatorToken.pos = badNode.operatorToken.end = badNode.right.pos; return badNode; } @@ -12871,17 +13820,17 @@ var ts; return result; } function parseJsxText() { - var node = createNode(244, scanner.getStartPos()); + var node = createNode(10, scanner.getStartPos()); currentToken = scanner.scanJsxToken(); return finishNode(node); } function parseJsxChild() { switch (token()) { - case 244: + case 10: return parseJsxText(); - case 15: + case 16: return parseJsxExpression(false); - case 25: + case 26: return parseJsxElementOrSelfClosingElement(false); } ts.Debug.fail("Unknown JSX child kind " + token()); @@ -12892,7 +13841,7 @@ var ts; parsingContext |= 1 << 14; while (true) { currentToken = scanner.reScanJsxToken(); - if (token() === 26) { + if (token() === 27) { break; } else if (token() === 1) { @@ -12907,24 +13856,24 @@ var ts; } function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { var fullStart = scanner.getStartPos(); - parseExpected(25); + parseExpected(26); var tagName = parseJsxElementName(); var attributes = parseList(13, parseJsxAttribute); var node; - if (token() === 27) { - node = createNode(243, fullStart); + if (token() === 28) { + node = createNode(244, fullStart); scanJsxText(); } else { - parseExpected(39); + parseExpected(40); if (inExpressionContext) { - parseExpected(27); + parseExpected(28); } else { - parseExpected(27, undefined, false); + parseExpected(28, undefined, false); scanJsxText(); } - node = createNode(242, fullStart); + node = createNode(243, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -12932,10 +13881,10 @@ var ts; } function parseJsxElementName() { scanJsxIdentifier(); - var expression = token() === 97 ? + var expression = token() === 98 ? parseTokenNode() : parseIdentifierName(); - while (parseOptional(21)) { - var propertyAccess = createNode(172, expression.pos); + while (parseOptional(22)) { + var propertyAccess = createNode(173, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -12944,27 +13893,27 @@ var ts; } function parseJsxExpression(inExpressionContext) { var node = createNode(248); - parseExpected(15); - if (token() !== 16) { + parseExpected(16); + if (token() !== 17) { node.expression = parseAssignmentExpressionOrHigher(); } if (inExpressionContext) { - parseExpected(16); + parseExpected(17); } else { - parseExpected(16, undefined, false); + parseExpected(17, undefined, false); scanJsxText(); } return finishNode(node); } function parseJsxAttribute() { - if (token() === 15) { + if (token() === 16) { return parseJsxSpreadAttribute(); } scanJsxIdentifier(); var node = createNode(246); node.name = parseIdentifierName(); - if (token() === 56) { + if (token() === 57) { switch (scanJsxAttributeValue()) { case 9: node.initializer = parseLiteralNode(); @@ -12978,68 +13927,68 @@ var ts; } function parseJsxSpreadAttribute() { var node = createNode(247); - parseExpected(15); - parseExpected(22); - node.expression = parseExpression(); parseExpected(16); + parseExpected(23); + node.expression = parseExpression(); + parseExpected(17); return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { var node = createNode(245); - parseExpected(26); + parseExpected(27); node.tagName = parseJsxElementName(); if (inExpressionContext) { - parseExpected(27); + parseExpected(28); } else { - parseExpected(27, undefined, false); + parseExpected(28, undefined, false); scanJsxText(); } return finishNode(node); } function parseTypeAssertion() { - var node = createNode(177); - parseExpected(25); + var node = createNode(178); + parseExpected(26); node.type = parseType(); - parseExpected(27); + parseExpected(28); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseMemberExpressionRest(expression) { while (true) { - var dotToken = parseOptionalToken(21); + var dotToken = parseOptionalToken(22); if (dotToken) { - var propertyAccess = createNode(172, expression.pos); + var propertyAccess = createNode(173, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); continue; } - if (token() === 49 && !scanner.hasPrecedingLineBreak()) { + if (token() === 50 && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(196, expression.pos); + var nonNullExpression = createNode(197, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } - if (!inDecoratorContext() && parseOptional(19)) { - var indexedAccess = createNode(173, expression.pos); + if (!inDecoratorContext() && parseOptional(20)) { + var indexedAccess = createNode(174, expression.pos); indexedAccess.expression = expression; - if (token() !== 20) { + if (token() !== 21) { indexedAccess.argumentExpression = allowInAnd(parseExpression); if (indexedAccess.argumentExpression.kind === 9 || indexedAccess.argumentExpression.kind === 8) { var literal = indexedAccess.argumentExpression; literal.text = internIdentifier(literal.text); } } - parseExpected(20); + parseExpected(21); expression = finishNode(indexedAccess); continue; } - if (token() === 11 || token() === 12) { - var tagExpression = createNode(176, expression.pos); + if (token() === 12 || token() === 13) { + var tagExpression = createNode(177, expression.pos); tagExpression.tag = expression; - tagExpression.template = token() === 11 + tagExpression.template = token() === 12 ? parseLiteralNode() : parseTemplateExpression(); expression = finishNode(tagExpression); @@ -13051,20 +14000,20 @@ var ts; function parseCallExpressionRest(expression) { while (true) { expression = parseMemberExpressionRest(expression); - if (token() === 25) { + if (token() === 26) { var typeArguments = tryParse(parseTypeArgumentsInExpression); if (!typeArguments) { return expression; } - var callExpr = createNode(174, expression.pos); + var callExpr = createNode(175, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); continue; } - else if (token() === 17) { - var callExpr = createNode(174, expression.pos); + else if (token() === 18) { + var callExpr = createNode(175, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -13074,17 +14023,17 @@ var ts; } } function parseArgumentList() { - parseExpected(17); - var result = parseDelimitedList(11, parseArgumentExpression); parseExpected(18); + var result = parseDelimitedList(11, parseArgumentExpression); + parseExpected(19); return result; } function parseTypeArgumentsInExpression() { - if (!parseOptional(25)) { + if (!parseOptional(26)) { return undefined; } var typeArguments = parseDelimitedList(18, parseType); - if (!parseExpected(27)) { + if (!parseExpected(28)) { return undefined; } return typeArguments && canFollowTypeArgumentsInExpression() @@ -13093,27 +14042,27 @@ var ts; } function canFollowTypeArgumentsInExpression() { switch (token()) { - case 17: - case 21: case 18: - case 20: + case 22: + case 19: + case 21: + case 55: + case 24: case 54: - case 23: - case 53: - case 30: - case 32: case 31: case 33: - case 51: + case 32: + case 34: case 52: - case 48: - case 46: + case 53: + case 49: case 47: - case 16: + case 48: + case 17: case 1: return true; - case 24: - case 15: + case 25: + case 16: default: return false; } @@ -13122,80 +14071,80 @@ var ts; switch (token()) { case 8: case 9: - case 11: + case 12: return parseLiteralNode(); - case 97: - case 95: - case 93: - case 99: - case 84: + case 98: + case 96: + case 94: + case 100: + case 85: return parseTokenNode(); - case 17: + case 18: return parseParenthesizedExpression(); - case 19: + case 20: return parseArrayLiteralExpression(); - case 15: + case 16: return parseObjectLiteralExpression(); - case 118: + case 119: if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) { break; } return parseFunctionExpression(); - case 73: + case 74: return parseClassExpression(); - case 87: + case 88: return parseFunctionExpression(); - case 92: + case 93: return parseNewExpression(); - case 39: - case 61: - if (reScanSlashToken() === 10) { + case 40: + case 62: + if (reScanSlashToken() === 11) { return parseLiteralNode(); } break; - case 12: + case 13: return parseTemplateExpression(); } return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(178); - parseExpected(17); - node.expression = allowInAnd(parseExpression); + var node = createNode(179); parseExpected(18); + node.expression = allowInAnd(parseExpression); + parseExpected(19); return finishNode(node); } function parseSpreadElement() { - var node = createNode(191); - parseExpected(22); + var node = createNode(192); + parseExpected(23); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { - return token() === 22 ? parseSpreadElement() : - token() === 24 ? createNode(193) : + return token() === 23 ? parseSpreadElement() : + token() === 25 ? createNode(194) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(170); - parseExpected(19); + var node = createNode(171); + parseExpected(20); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.elements = parseDelimitedList(15, parseArgumentOrArrayLiteralElement); - parseExpected(20); + parseExpected(21); return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { - if (parseContextualModifier(123)) { - return parseAccessorDeclaration(149, fullStart, decorators, modifiers); - } - else if (parseContextualModifier(131)) { + if (parseContextualModifier(124)) { return parseAccessorDeclaration(150, fullStart, decorators, modifiers); } + else if (parseContextualModifier(132)) { + return parseAccessorDeclaration(151, fullStart, decorators, modifiers); + } return undefined; } function parseObjectLiteralElement() { @@ -13206,19 +14155,19 @@ var ts; if (accessor) { return accessor; } - var asteriskToken = parseOptionalToken(37); + var asteriskToken = parseOptionalToken(38); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - var questionToken = parseOptionalToken(53); - if (asteriskToken || token() === 17 || token() === 25) { + var questionToken = parseOptionalToken(54); + if (asteriskToken || token() === 18 || token() === 26) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } - var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 24 || token() === 16 || token() === 56); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 25 || token() === 17 || token() === 57); if (isShorthandPropertyAssignment) { var shorthandDeclaration = createNode(254, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; - var equalsToken = parseOptionalToken(56); + var equalsToken = parseOptionalToken(57); if (equalsToken) { shorthandDeclaration.equalsToken = equalsToken; shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); @@ -13230,19 +14179,19 @@ var ts; propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; - parseExpected(54); + parseExpected(55); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); return addJSDocComment(finishNode(propertyAssignment)); } } function parseObjectLiteralExpression() { - var node = createNode(171); - parseExpected(15); + var node = createNode(172); + parseExpected(16); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.properties = parseDelimitedList(12, parseObjectLiteralElement, true); - parseExpected(16); + parseExpected(17); return finishNode(node); } function parseFunctionExpression() { @@ -13250,10 +14199,10 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(179); + var node = createNode(180); node.modifiers = parseModifiers(); - parseExpected(87); - node.asteriskToken = parseOptionalToken(37); + parseExpected(88); + node.asteriskToken = parseOptionalToken(38); var isGenerator = !!node.asteriskToken; var isAsync = !!(ts.getModifierFlags(node) & 256); node.name = @@ -13261,7 +14210,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(54, isGenerator, isAsync, false, node); + fillSignature(55, isGenerator, isAsync, false, node); node.body = parseFunctionBlock(isGenerator, isAsync, false); if (saveDecoratorContext) { setDecoratorContext(true); @@ -13272,23 +14221,23 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(175); - parseExpected(92); + var node = createNode(176); + parseExpected(93); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); - if (node.typeArguments || token() === 17) { + if (node.typeArguments || token() === 18) { node.arguments = parseArgumentList(); } return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(199); - if (parseExpected(15, diagnosticMessage) || ignoreMissingOpenBrace) { + var node = createNode(200); + if (parseExpected(16, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.statements = parseList(1, parseStatement); - parseExpected(16); + parseExpected(17); } else { node.statements = createMissingList(); @@ -13313,47 +14262,47 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(201); - parseExpected(23); + var node = createNode(202); + parseExpected(24); return finishNode(node); } function parseIfStatement() { - var node = createNode(203); - parseExpected(88); - parseExpected(17); - node.expression = allowInAnd(parseExpression); + var node = createNode(204); + parseExpected(89); parseExpected(18); + node.expression = allowInAnd(parseExpression); + parseExpected(19); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(80) ? parseStatement() : undefined; + node.elseStatement = parseOptional(81) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(204); - parseExpected(79); + var node = createNode(205); + parseExpected(80); node.statement = parseStatement(); - parseExpected(104); - parseExpected(17); - node.expression = allowInAnd(parseExpression); + parseExpected(105); parseExpected(18); - parseOptional(23); + node.expression = allowInAnd(parseExpression); + parseExpected(19); + parseOptional(24); return finishNode(node); } function parseWhileStatement() { - var node = createNode(205); - parseExpected(104); - parseExpected(17); - node.expression = allowInAnd(parseExpression); + var node = createNode(206); + parseExpected(105); parseExpected(18); + node.expression = allowInAnd(parseExpression); + parseExpected(19); node.statement = parseStatement(); return finishNode(node); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(86); - parseExpected(17); + parseExpected(87); + parseExpected(18); var initializer = undefined; - if (token() !== 23) { - if (token() === 102 || token() === 108 || token() === 74) { + if (token() !== 24) { + if (token() === 103 || token() === 109 || token() === 75) { initializer = parseVariableDeclarationList(true); } else { @@ -13361,32 +14310,32 @@ var ts; } } var forOrForInOrForOfStatement; - if (parseOptional(90)) { - var forInStatement = createNode(207, pos); + if (parseOptional(91)) { + var forInStatement = createNode(208, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); - parseExpected(18); + parseExpected(19); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(138)) { - var forOfStatement = createNode(208, pos); + else if (parseOptional(139)) { + var forOfStatement = createNode(209, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); - parseExpected(18); + parseExpected(19); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(206, pos); + var forStatement = createNode(207, pos); forStatement.initializer = initializer; - parseExpected(23); - if (token() !== 23 && token() !== 18) { + parseExpected(24); + if (token() !== 24 && token() !== 19) { forStatement.condition = allowInAnd(parseExpression); } - parseExpected(23); - if (token() !== 18) { + parseExpected(24); + if (token() !== 19) { forStatement.incrementor = allowInAnd(parseExpression); } - parseExpected(18); + parseExpected(19); forOrForInOrForOfStatement = forStatement; } forOrForInOrForOfStatement.statement = parseStatement(); @@ -13394,7 +14343,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 210 ? 70 : 75); + parseExpected(kind === 211 ? 71 : 76); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -13402,8 +14351,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(211); - parseExpected(94); + var node = createNode(212); + parseExpected(95); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -13411,90 +14360,90 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(212); - parseExpected(105); - parseExpected(17); - node.expression = allowInAnd(parseExpression); + var node = createNode(213); + parseExpected(106); parseExpected(18); + node.expression = allowInAnd(parseExpression); + parseExpected(19); node.statement = parseStatement(); return finishNode(node); } function parseCaseClause() { var node = createNode(249); - parseExpected(71); + parseExpected(72); node.expression = allowInAnd(parseExpression); - parseExpected(54); + parseExpected(55); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseDefaultClause() { var node = createNode(250); - parseExpected(77); - parseExpected(54); + parseExpected(78); + parseExpected(55); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token() === 71 ? parseCaseClause() : parseDefaultClause(); + return token() === 72 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(213); - parseExpected(96); - parseExpected(17); - node.expression = allowInAnd(parseExpression); + var node = createNode(214); + parseExpected(97); parseExpected(18); - var caseBlock = createNode(227, scanner.getStartPos()); - parseExpected(15); - caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); + node.expression = allowInAnd(parseExpression); + parseExpected(19); + var caseBlock = createNode(228, scanner.getStartPos()); parseExpected(16); + caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); + parseExpected(17); node.caseBlock = finishNode(caseBlock); return finishNode(node); } function parseThrowStatement() { - var node = createNode(215); - parseExpected(98); + var node = createNode(216); + parseExpected(99); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(216); - parseExpected(100); + var node = createNode(217); + parseExpected(101); node.tryBlock = parseBlock(false); - node.catchClause = token() === 72 ? parseCatchClause() : undefined; - if (!node.catchClause || token() === 85) { - parseExpected(85); + node.catchClause = token() === 73 ? parseCatchClause() : undefined; + if (!node.catchClause || token() === 86) { + parseExpected(86); node.finallyBlock = parseBlock(false); } return finishNode(node); } function parseCatchClause() { var result = createNode(252); - parseExpected(72); - if (parseExpected(17)) { + parseExpected(73); + if (parseExpected(18)) { result.variableDeclaration = parseVariableDeclaration(); } - parseExpected(18); + parseExpected(19); result.block = parseBlock(false); return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(217); - parseExpected(76); + var node = createNode(218); + parseExpected(77); parseSemicolon(); return finishNode(node); } function parseExpressionOrLabeledStatement() { var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); - if (expression.kind === 69 && parseOptional(54)) { - var labeledStatement = createNode(214, fullStart); + if (expression.kind === 70 && parseOptional(55)) { + var labeledStatement = createNode(215, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(202, fullStart); + var expressionStatement = createNode(203, fullStart); expressionStatement.expression = expression; parseSemicolon(); return addJSDocComment(finishNode(expressionStatement)); @@ -13506,7 +14455,7 @@ var ts; } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 87 && !scanner.hasPrecedingLineBreak(); + return token() === 88 && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { nextToken(); @@ -13515,47 +14464,47 @@ var ts; function isDeclaration() { while (true) { switch (token()) { - case 102: - case 108: + case 103: + case 109: + case 75: + case 88: case 74: - case 87: - case 73: - case 81: + case 82: return true; - case 107: - case 134: + case 108: + case 135: return nextTokenIsIdentifierOnSameLine(); - case 125: case 126: + case 127: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 115: - case 118: - case 122: - case 110: + case 116: + case 119: + case 123: case 111: case 112: - case 128: + case 113: + case 129: nextToken(); if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 137: + case 138: nextToken(); - return token() === 15 || token() === 69 || token() === 82; - case 89: + return token() === 16 || token() === 70 || token() === 83; + case 90: nextToken(); - return token() === 9 || token() === 37 || - token() === 15 || ts.tokenIsIdentifierOrKeyword(token()); - case 82: + return token() === 9 || token() === 38 || + token() === 16 || ts.tokenIsIdentifierOrKeyword(token()); + case 83: nextToken(); - if (token() === 56 || token() === 37 || - token() === 15 || token() === 77 || - token() === 116) { + if (token() === 57 || token() === 38 || + token() === 16 || token() === 78 || + token() === 117) { return true; } continue; - case 113: + case 114: nextToken(); continue; default: @@ -13568,46 +14517,46 @@ var ts; } function isStartOfStatement() { switch (token()) { - case 55: - case 23: - case 15: - case 102: - case 108: - case 87: - case 73: - case 81: + case 56: + case 24: + case 16: + case 103: + case 109: case 88: - case 79: - case 104: - case 86: - case 75: - case 70: - case 94: - case 105: - case 96: - case 98: - case 100: - case 76: - case 72: - case 85: - return true; case 74: case 82: case 89: + case 80: + case 105: + case 87: + case 76: + case 71: + case 95: + case 106: + case 97: + case 99: + case 101: + case 77: + case 73: + case 86: + return true; + case 75: + case 83: + case 90: return isStartOfDeclaration(); - case 118: - case 122: - case 107: - case 125: + case 119: + case 123: + case 108: case 126: - case 134: - case 137: + case 127: + case 135: + case 138: return true; - case 112: - case 110: - case 111: case 113: - case 128: + case 111: + case 112: + case 114: + case 129: return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); default: return isStartOfExpression(); @@ -13615,73 +14564,73 @@ var ts; } function nextTokenIsIdentifierOrStartOfDestructuring() { nextToken(); - return isIdentifier() || token() === 15 || token() === 19; + return isIdentifier() || token() === 16 || token() === 20; } function isLetDeclaration() { return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring); } function parseStatement() { switch (token()) { - case 23: + case 24: return parseEmptyStatement(); - case 15: + case 16: return parseBlock(false); - case 102: + case 103: return parseVariableStatement(scanner.getStartPos(), undefined, undefined); - case 108: + case 109: if (isLetDeclaration()) { return parseVariableStatement(scanner.getStartPos(), undefined, undefined); } break; - case 87: - return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); - case 73: - return parseClassDeclaration(scanner.getStartPos(), undefined, undefined); case 88: - return parseIfStatement(); - case 79: - return parseDoStatement(); - case 104: - return parseWhileStatement(); - case 86: - return parseForOrForInOrForOfStatement(); - case 75: - return parseBreakOrContinueStatement(209); - case 70: - return parseBreakOrContinueStatement(210); - case 94: - return parseReturnStatement(); - case 105: - return parseWithStatement(); - case 96: - return parseSwitchStatement(); - case 98: - return parseThrowStatement(); - case 100: - case 72: - case 85: - return parseTryStatement(); - case 76: - return parseDebuggerStatement(); - case 55: - return parseDeclaration(); - case 118: - case 107: - case 134: - case 125: - case 126: - case 122: + return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); case 74: - case 81: - case 82: + return parseClassDeclaration(scanner.getStartPos(), undefined, undefined); case 89: - case 110: + return parseIfStatement(); + case 80: + return parseDoStatement(); + case 105: + return parseWhileStatement(); + case 87: + return parseForOrForInOrForOfStatement(); + case 76: + return parseBreakOrContinueStatement(210); + case 71: + return parseBreakOrContinueStatement(211); + case 95: + return parseReturnStatement(); + case 106: + return parseWithStatement(); + case 97: + return parseSwitchStatement(); + case 99: + return parseThrowStatement(); + case 101: + case 73: + case 86: + return parseTryStatement(); + case 77: + return parseDebuggerStatement(); + case 56: + return parseDeclaration(); + case 119: + case 108: + case 135: + case 126: + case 127: + case 123: + case 75: + case 82: + case 83: + case 90: case 111: case 112: - case 115: case 113: - case 128: - case 137: + case 116: + case 114: + case 129: + case 138: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -13694,40 +14643,40 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(); switch (token()) { - case 102: - case 108: - case 74: + case 103: + case 109: + case 75: return parseVariableStatement(fullStart, decorators, modifiers); - case 87: + case 88: return parseFunctionDeclaration(fullStart, decorators, modifiers); - case 73: + case 74: return parseClassDeclaration(fullStart, decorators, modifiers); - case 107: + case 108: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 134: + case 135: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); - case 81: - return parseEnumDeclaration(fullStart, decorators, modifiers); - case 137: - case 125: - case 126: - return parseModuleDeclaration(fullStart, decorators, modifiers); - case 89: - return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); case 82: + return parseEnumDeclaration(fullStart, decorators, modifiers); + case 138: + case 126: + case 127: + return parseModuleDeclaration(fullStart, decorators, modifiers); + case 90: + return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); + case 83: nextToken(); switch (token()) { - case 77: - case 56: + case 78: + case 57: return parseExportAssignment(fullStart, decorators, modifiers); - case 116: + case 117: return parseNamespaceExportDeclaration(fullStart, decorators, modifiers); default: return parseExportDeclaration(fullStart, decorators, modifiers); } default: if (decorators || modifiers) { - var node = createMissingNode(239, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(240, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; node.modifiers = modifiers; @@ -13740,31 +14689,31 @@ var ts; return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 9); } function parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage) { - if (token() !== 15 && canParseSemicolon()) { + if (token() !== 16 && canParseSemicolon()) { parseSemicolon(); return; } return parseFunctionBlock(isGenerator, isAsync, false, diagnosticMessage); } function parseArrayBindingElement() { - if (token() === 24) { - return createNode(193); + if (token() === 25) { + return createNode(194); } - var node = createNode(169); - node.dotDotDotToken = parseOptionalToken(22); + var node = createNode(170); + node.dotDotDotToken = parseOptionalToken(23); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(169); + var node = createNode(170); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token() !== 54) { + if (tokenIsIdentifier && token() !== 55) { node.name = propertyName; } else { - parseExpected(54); + parseExpected(55); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -13772,33 +14721,33 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(167); - parseExpected(15); - node.elements = parseDelimitedList(9, parseObjectBindingElement); + var node = createNode(168); parseExpected(16); + node.elements = parseDelimitedList(9, parseObjectBindingElement); + parseExpected(17); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(168); - parseExpected(19); - node.elements = parseDelimitedList(10, parseArrayBindingElement); + var node = createNode(169); parseExpected(20); + node.elements = parseDelimitedList(10, parseArrayBindingElement); + parseExpected(21); return finishNode(node); } function isIdentifierOrPattern() { - return token() === 15 || token() === 19 || isIdentifier(); + return token() === 16 || token() === 20 || isIdentifier(); } function parseIdentifierOrPattern() { - if (token() === 19) { + if (token() === 20) { return parseArrayBindingPattern(); } - if (token() === 15) { + if (token() === 16) { return parseObjectBindingPattern(); } return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(218); + var node = createNode(219); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { @@ -13807,21 +14756,21 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(219); + var node = createNode(220); switch (token()) { - case 102: + case 103: break; - case 108: + case 109: node.flags |= 1; break; - case 74: + case 75: node.flags |= 2; break; default: ts.Debug.fail(); } nextToken(); - if (token() === 138 && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 139 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -13833,10 +14782,10 @@ var ts; return finishNode(node); } function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 18; + return nextTokenIsIdentifier() && nextToken() === 19; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(200, fullStart); + var node = createNode(201, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.declarationList = parseVariableDeclarationList(false); @@ -13844,29 +14793,29 @@ var ts; return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(220, fullStart); + var node = createNode(221, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(87); - node.asteriskToken = parseOptionalToken(37); + parseExpected(88); + node.asteriskToken = parseOptionalToken(38); node.name = ts.hasModifier(node, 512) ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = !!node.asteriskToken; var isAsync = ts.hasModifier(node, 256); - fillSignature(54, isGenerator, isAsync, false, node); + fillSignature(55, isGenerator, isAsync, false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return addJSDocComment(finishNode(node)); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(148, pos); + var node = createNode(149, pos); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(121); - fillSignature(54, false, false, false, node); + parseExpected(122); + fillSignature(55, false, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, false, ts.Diagnostics.or_expected); return addJSDocComment(finishNode(node)); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(147, fullStart); + var method = createNode(148, fullStart); method.decorators = decorators; method.modifiers = modifiers; method.asteriskToken = asteriskToken; @@ -13874,12 +14823,12 @@ var ts; method.questionToken = questionToken; var isGenerator = !!asteriskToken; var isAsync = ts.hasModifier(method, 256); - fillSignature(54, isGenerator, isAsync, false, method); + fillSignature(55, isGenerator, isAsync, false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return addJSDocComment(finishNode(method)); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(145, fullStart); + var property = createNode(146, fullStart); property.decorators = decorators; property.modifiers = modifiers; property.name = name; @@ -13892,10 +14841,10 @@ var ts; return addJSDocComment(finishNode(property)); } function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { - var asteriskToken = parseOptionalToken(37); + var asteriskToken = parseOptionalToken(38); var name = parsePropertyName(); - var questionToken = parseOptionalToken(53); - if (asteriskToken || token() === 17 || token() === 25) { + var questionToken = parseOptionalToken(54); + if (asteriskToken || token() === 18 || token() === 26) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); } else { @@ -13910,17 +14859,17 @@ var ts; node.decorators = decorators; node.modifiers = modifiers; node.name = parsePropertyName(); - fillSignature(54, false, false, false, node); + fillSignature(55, false, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, false); return addJSDocComment(finishNode(node)); } function isClassMemberModifier(idToken) { switch (idToken) { - case 112: - case 110: - case 111: case 113: - case 128: + case 111: + case 112: + case 114: + case 129: return true; default: return false; @@ -13928,7 +14877,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token() === 55) { + if (token() === 56) { return true; } while (ts.isModifierKind(token())) { @@ -13938,26 +14887,26 @@ var ts; } nextToken(); } - if (token() === 37) { + if (token() === 38) { return true; } if (isLiteralPropertyName()) { idToken = token(); nextToken(); } - if (token() === 19) { + if (token() === 20) { return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 131 || idToken === 123) { + if (!ts.isKeyword(idToken) || idToken === 132 || idToken === 124) { return true; } switch (token()) { - case 17: - case 25: + case 18: + case 26: + case 55: + case 57: case 54: - case 56: - case 53: return true; default: return canParseSemicolon(); @@ -13969,10 +14918,10 @@ var ts; var decorators; while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(55)) { + if (!parseOptional(56)) { break; } - var decorator = createNode(143, decoratorStart); + var decorator = createNode(144, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); if (!decorators) { @@ -13992,7 +14941,7 @@ var ts; while (true) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); - if (token() === 74 && permitInvalidConstAsModifier) { + if (token() === 75 && permitInvalidConstAsModifier) { if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) { break; } @@ -14017,7 +14966,7 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 118) { + if (token() === 119) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); nextToken(); @@ -14028,8 +14977,8 @@ var ts; return modifiers; } function parseClassElement() { - if (token() === 23) { - var result = createNode(198); + if (token() === 24) { + var result = createNode(199); nextToken(); return finishNode(result); } @@ -14040,7 +14989,7 @@ var ts; if (accessor) { return accessor; } - if (token() === 121) { + if (token() === 122) { return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { @@ -14049,33 +14998,33 @@ var ts; if (ts.tokenIsIdentifierOrKeyword(token()) || token() === 9 || token() === 8 || - token() === 37 || - token() === 19) { + token() === 38 || + token() === 20) { return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { - var name_10 = createMissingNode(69, true, ts.Diagnostics.Declaration_expected); + var name_10 = createMissingNode(70, true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(fullStart, decorators, modifiers, name_10, undefined); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 192); + return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 193); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 221); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 222); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(73); + parseExpected(74); node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); - node.heritageClauses = parseHeritageClauses(true); - if (parseExpected(15)) { + node.heritageClauses = parseHeritageClauses(); + if (parseExpected(16)) { node.members = parseClassMembers(); - parseExpected(16); + parseExpected(17); } else { node.members = createMissingList(); @@ -14088,16 +15037,16 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 106 && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 107 && lookAhead(nextTokenIsIdentifierOrKeyword); } - function parseHeritageClauses(isClassHeritageClause) { + function parseHeritageClauses() { if (isHeritageClause()) { return parseList(20, parseHeritageClause); } return undefined; } function parseHeritageClause() { - if (token() === 83 || token() === 106) { + if (token() === 84 || token() === 107) { var node = createNode(251); node.token = token(); nextToken(); @@ -14107,38 +15056,38 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(194); + var node = createNode(195); node.expression = parseLeftHandSideExpressionOrHigher(); - if (token() === 25) { - node.typeArguments = parseBracketedList(18, parseType, 25, 27); + if (token() === 26) { + node.typeArguments = parseBracketedList(18, parseType, 26, 28); } return finishNode(node); } function isHeritageClause() { - return token() === 83 || token() === 106; + return token() === 84 || token() === 107; } function parseClassMembers() { return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(222, fullStart); + var node = createNode(223, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(107); + parseExpected(108); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - node.heritageClauses = parseHeritageClauses(false); + node.heritageClauses = parseHeritageClauses(); node.members = parseObjectTypeMembers(); return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(223, fullStart); + var node = createNode(224, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(134); + parseExpected(135); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(56); + parseExpected(57); node.type = parseType(); parseSemicolon(); return addJSDocComment(finishNode(node)); @@ -14150,14 +15099,14 @@ var ts; return addJSDocComment(finishNode(node)); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(224, fullStart); + var node = createNode(225, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(81); + parseExpected(82); node.name = parseIdentifier(); - if (parseExpected(15)) { + if (parseExpected(16)) { node.members = parseDelimitedList(6, parseEnumMember); - parseExpected(16); + parseExpected(17); } else { node.members = createMissingList(); @@ -14165,10 +15114,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseModuleBlock() { - var node = createNode(226, scanner.getStartPos()); - if (parseExpected(15)) { + var node = createNode(227, scanner.getStartPos()); + if (parseExpected(16)) { node.statements = parseList(1, parseStatement); - parseExpected(16); + parseExpected(17); } else { node.statements = createMissingList(); @@ -14176,29 +15125,29 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(225, fullStart); + var node = createNode(226, fullStart); var namespaceFlag = flags & 16; node.decorators = decorators; node.modifiers = modifiers; node.flags |= flags; node.name = parseIdentifier(); - node.body = parseOptional(21) + node.body = parseOptional(22) ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 4 | namespaceFlag) : parseModuleBlock(); return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(225, fullStart); + var node = createNode(226, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (token() === 137) { + if (token() === 138) { node.name = parseIdentifier(); node.flags |= 512; } else { node.name = parseLiteralNode(true); } - if (token() === 15) { + if (token() === 16) { node.body = parseModuleBlock(); } else { @@ -14208,14 +15157,14 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = 0; - if (token() === 137) { + if (token() === 138) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } - else if (parseOptional(126)) { + else if (parseOptional(127)) { flags |= 16; } else { - parseExpected(125); + parseExpected(126); if (token() === 9) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -14223,63 +15172,63 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token() === 129 && + return token() === 130 && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { - return nextToken() === 17; + return nextToken() === 18; } function nextTokenIsSlash() { - return nextToken() === 39; + return nextToken() === 40; } function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { - var exportDeclaration = createNode(228, fullStart); + var exportDeclaration = createNode(229, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; - parseExpected(116); - parseExpected(126); + parseExpected(117); + parseExpected(127); exportDeclaration.name = parseIdentifier(); - parseExpected(23); + parseExpected(24); return finishNode(exportDeclaration); } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { - parseExpected(89); + parseExpected(90); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 24 && token() !== 136) { - var importEqualsDeclaration = createNode(229, fullStart); + if (token() !== 25 && token() !== 137) { + var importEqualsDeclaration = createNode(230, fullStart); importEqualsDeclaration.decorators = decorators; importEqualsDeclaration.modifiers = modifiers; importEqualsDeclaration.name = identifier; - parseExpected(56); + parseExpected(57); importEqualsDeclaration.moduleReference = parseModuleReference(); parseSemicolon(); return addJSDocComment(finishNode(importEqualsDeclaration)); } } - var importDeclaration = createNode(230, fullStart); + var importDeclaration = createNode(231, fullStart); importDeclaration.decorators = decorators; importDeclaration.modifiers = modifiers; if (identifier || - token() === 37 || - token() === 15) { + token() === 38 || + token() === 16) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(136); + parseExpected(137); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(importDeclaration); } function parseImportClause(identifier, fullStart) { - var importClause = createNode(231, fullStart); + var importClause = createNode(232, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || - parseOptional(24)) { - importClause.namedBindings = token() === 37 ? parseNamespaceImport() : parseNamedImportsOrExports(233); + parseOptional(25)) { + importClause.namedBindings = token() === 38 ? parseNamespaceImport() : parseNamedImportsOrExports(234); } return finishNode(importClause); } @@ -14289,11 +15238,11 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(240); - parseExpected(129); - parseExpected(17); - node.expression = parseModuleSpecifier(); + var node = createNode(241); + parseExpected(130); parseExpected(18); + node.expression = parseModuleSpecifier(); + parseExpected(19); return finishNode(node); } function parseModuleSpecifier() { @@ -14307,22 +15256,22 @@ var ts; } } function parseNamespaceImport() { - var namespaceImport = createNode(232); - parseExpected(37); - parseExpected(116); + var namespaceImport = createNode(233); + parseExpected(38); + parseExpected(117); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(21, kind === 233 ? parseImportSpecifier : parseExportSpecifier, 15, 16); + node.elements = parseBracketedList(21, kind === 234 ? parseImportSpecifier : parseExportSpecifier, 16, 17); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(238); + return parseImportOrExportSpecifier(239); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(234); + return parseImportOrExportSpecifier(235); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -14330,9 +15279,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token() === 116) { + if (token() === 117) { node.propertyName = identifierName; - parseExpected(116); + parseExpected(117); checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -14341,23 +15290,23 @@ var ts; else { node.name = identifierName; } - if (kind === 234 && checkIdentifierIsKeyword) { + if (kind === 235 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(236, fullStart); + var node = createNode(237, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (parseOptional(37)) { - parseExpected(136); + if (parseOptional(38)) { + parseExpected(137); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(237); - if (token() === 136 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { - parseExpected(136); + node.exportClause = parseNamedImportsOrExports(238); + if (token() === 137 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { + parseExpected(137); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -14365,14 +15314,14 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(235, fullStart); + var node = createNode(236, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (parseOptional(56)) { + if (parseOptional(57)) { node.isExportEquals = true; } else { - parseExpected(77); + parseExpected(78); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -14444,36 +15393,72 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return ts.hasModifier(node, 1) - || node.kind === 229 && node.moduleReference.kind === 240 - || node.kind === 230 - || node.kind === 235 + || node.kind === 230 && node.moduleReference.kind === 241 + || node.kind === 231 || node.kind === 236 + || node.kind === 237 ? node : undefined; }); } + var ParsingContext; + (function (ParsingContext) { + ParsingContext[ParsingContext["SourceElements"] = 0] = "SourceElements"; + ParsingContext[ParsingContext["BlockStatements"] = 1] = "BlockStatements"; + ParsingContext[ParsingContext["SwitchClauses"] = 2] = "SwitchClauses"; + ParsingContext[ParsingContext["SwitchClauseStatements"] = 3] = "SwitchClauseStatements"; + ParsingContext[ParsingContext["TypeMembers"] = 4] = "TypeMembers"; + ParsingContext[ParsingContext["ClassMembers"] = 5] = "ClassMembers"; + ParsingContext[ParsingContext["EnumMembers"] = 6] = "EnumMembers"; + ParsingContext[ParsingContext["HeritageClauseElement"] = 7] = "HeritageClauseElement"; + ParsingContext[ParsingContext["VariableDeclarations"] = 8] = "VariableDeclarations"; + ParsingContext[ParsingContext["ObjectBindingElements"] = 9] = "ObjectBindingElements"; + ParsingContext[ParsingContext["ArrayBindingElements"] = 10] = "ArrayBindingElements"; + ParsingContext[ParsingContext["ArgumentExpressions"] = 11] = "ArgumentExpressions"; + ParsingContext[ParsingContext["ObjectLiteralMembers"] = 12] = "ObjectLiteralMembers"; + ParsingContext[ParsingContext["JsxAttributes"] = 13] = "JsxAttributes"; + ParsingContext[ParsingContext["JsxChildren"] = 14] = "JsxChildren"; + ParsingContext[ParsingContext["ArrayLiteralMembers"] = 15] = "ArrayLiteralMembers"; + ParsingContext[ParsingContext["Parameters"] = 16] = "Parameters"; + ParsingContext[ParsingContext["TypeParameters"] = 17] = "TypeParameters"; + ParsingContext[ParsingContext["TypeArguments"] = 18] = "TypeArguments"; + ParsingContext[ParsingContext["TupleElementTypes"] = 19] = "TupleElementTypes"; + ParsingContext[ParsingContext["HeritageClauses"] = 20] = "HeritageClauses"; + ParsingContext[ParsingContext["ImportOrExportSpecifiers"] = 21] = "ImportOrExportSpecifiers"; + ParsingContext[ParsingContext["JSDocFunctionParameters"] = 22] = "JSDocFunctionParameters"; + ParsingContext[ParsingContext["JSDocTypeArguments"] = 23] = "JSDocTypeArguments"; + ParsingContext[ParsingContext["JSDocRecordMembers"] = 24] = "JSDocRecordMembers"; + ParsingContext[ParsingContext["JSDocTupleTypes"] = 25] = "JSDocTupleTypes"; + ParsingContext[ParsingContext["Count"] = 26] = "Count"; + })(ParsingContext || (ParsingContext = {})); + var Tristate; + (function (Tristate) { + Tristate[Tristate["False"] = 0] = "False"; + Tristate[Tristate["True"] = 1] = "True"; + Tristate[Tristate["Unknown"] = 2] = "Unknown"; + })(Tristate || (Tristate = {})); var JSDocParser; (function (JSDocParser) { function isJSDocType() { switch (token()) { - case 37: - case 53: - case 17: - case 19: - case 49: - case 15: - case 87: - case 22: - case 92: - case 97: + case 38: + case 54: + case 18: + case 20: + case 50: + case 16: + case 88: + case 23: + case 93: + case 98: return true; } return ts.tokenIsIdentifierOrKeyword(token()); } JSDocParser.isJSDocType = isJSDocType; function parseJSDocTypeExpressionForTests(content, start, length) { - initializeState("file.js", content, 2, undefined, 1); - sourceFile = createSourceFile("file.js", 2, 1); + initializeState(content, 4, undefined, 1); + sourceFile = createSourceFile("file.js", 4, 1); scanner.setText(content, start, length); currentToken = scanner.scan(); var jsDocTypeExpression = parseJSDocTypeExpression(); @@ -14484,21 +15469,21 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; function parseJSDocTypeExpression() { var result = createNode(257, scanner.getTokenPos()); - parseExpected(15); - result.type = parseJSDocTopLevelType(); parseExpected(16); + result.type = parseJSDocTopLevelType(); + parseExpected(17); fixupParentReferences(result); return finishNode(result); } JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocTopLevelType() { var type = parseJSDocType(); - if (token() === 47) { + if (token() === 48) { var unionType = createNode(261, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } - if (token() === 56) { + if (token() === 57) { var optionalType = createNode(268, type.pos); nextToken(); optionalType.type = type; @@ -14509,20 +15494,20 @@ var ts; function parseJSDocType() { var type = parseBasicTypeExpression(); while (true) { - if (token() === 19) { + if (token() === 20) { var arrayType = createNode(260, type.pos); arrayType.elementType = type; nextToken(); - parseExpected(20); + parseExpected(21); type = finishNode(arrayType); } - else if (token() === 53) { + else if (token() === 54) { var nullableType = createNode(263, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } - else if (token() === 49) { + else if (token() === 50) { var nonNullableType = createNode(264, type.pos); nonNullableType.type = type; nextToken(); @@ -14536,40 +15521,40 @@ var ts; } function parseBasicTypeExpression() { switch (token()) { - case 37: + case 38: return parseJSDocAllType(); - case 53: + case 54: return parseJSDocUnknownOrNullableType(); - case 17: + case 18: return parseJSDocUnionType(); - case 19: + case 20: return parseJSDocTupleType(); - case 49: + case 50: return parseJSDocNonNullableType(); - case 15: + case 16: return parseJSDocRecordType(); - case 87: + case 88: return parseJSDocFunctionType(); - case 22: + case 23: return parseJSDocVariadicType(); - case 92: - return parseJSDocConstructorType(); - case 97: - return parseJSDocThisType(); - case 117: - case 132: - case 130: - case 120: - case 133: - case 103: case 93: - case 135: - case 127: + return parseJSDocConstructorType(); + case 98: + return parseJSDocThisType(); + case 118: + case 133: + case 131: + case 121: + case 134: + case 104: + case 94: + case 136: + case 128: return parseTokenNode(); case 9: case 8: - case 99: - case 84: + case 100: + case 85: return parseJSDocLiteralType(); } return parseJSDocTypeReference(); @@ -14577,14 +15562,14 @@ var ts; function parseJSDocThisType() { var result = createNode(272); nextToken(); - parseExpected(54); + parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { var result = createNode(271); nextToken(); - parseExpected(54); + parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } @@ -14597,33 +15582,33 @@ var ts; function parseJSDocFunctionType() { var result = createNode(269); nextToken(); - parseExpected(17); + parseExpected(18); result.parameters = parseDelimitedList(22, parseJSDocParameter); checkForTrailingComma(result.parameters); - parseExpected(18); - if (token() === 54) { + parseExpected(19); + if (token() === 55) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(142); + var parameter = createNode(143); parameter.type = parseJSDocType(); - if (parseOptional(56)) { - parameter.questionToken = createNode(56); + if (parseOptional(57)) { + parameter.questionToken = createNode(57); } return finishNode(parameter); } function parseJSDocTypeReference() { var result = createNode(267); result.name = parseSimplePropertyName(); - if (token() === 25) { + if (token() === 26) { result.typeArguments = parseTypeArguments(); } else { - while (parseOptional(21)) { - if (token() === 25) { + while (parseOptional(22)) { + if (token() === 26) { result.typeArguments = parseTypeArguments(); break; } @@ -14639,7 +15624,7 @@ var ts; var typeArguments = parseDelimitedList(23, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); - parseExpected(27); + parseExpected(28); return typeArguments; } function checkForEmptyTypeArgumentList(typeArguments) { @@ -14650,7 +15635,7 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(139, left.pos); + var result = createNode(140, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); @@ -14671,7 +15656,7 @@ var ts; nextToken(); result.types = parseDelimitedList(25, parseJSDocType); checkForTrailingComma(result.types); - parseExpected(20); + parseExpected(21); return finishNode(result); } function checkForTrailingComma(list) { @@ -14684,13 +15669,13 @@ var ts; var result = createNode(261); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); - parseExpected(18); + parseExpected(19); return finishNode(result); } function parseJSDocTypeList(firstType) { ts.Debug.assert(!!firstType); var types = createNodeArray([firstType], firstType.pos); - while (parseOptional(47)) { + while (parseOptional(48)) { types.push(parseJSDocType()); } types.end = scanner.getStartPos(); @@ -14709,12 +15694,12 @@ var ts; function parseJSDocUnknownOrNullableType() { var pos = scanner.getStartPos(); nextToken(); - if (token() === 24 || - token() === 16 || - token() === 18 || - token() === 27 || - token() === 56 || - token() === 47) { + if (token() === 25 || + token() === 17 || + token() === 19 || + token() === 28 || + token() === 57 || + token() === 48) { var result = createNode(259, pos); return finishNode(result); } @@ -14725,7 +15710,7 @@ var ts; } } function parseIsolatedJSDocComment(content, start, length) { - initializeState("file.js", content, 2, undefined, 1); + initializeState(content, 4, undefined, 1); sourceFile = { languageVariant: 0, text: content }; var jsDoc = parseJSDocCommentWorker(start, length); var diagnostics = parseDiagnostics; @@ -14747,6 +15732,12 @@ var ts; return comment; } JSDocParser.parseJSDocComment = parseJSDocComment; + var JSDocState; + (function (JSDocState) { + JSDocState[JSDocState["BeginningOfLine"] = 0] = "BeginningOfLine"; + JSDocState[JSDocState["SawAsterisk"] = 1] = "SawAsterisk"; + JSDocState[JSDocState["SavingComments"] = 2] = "SavingComments"; + })(JSDocState || (JSDocState = {})); function parseJSDocCommentWorker(start, length) { var content = sourceText; start = start || 0; @@ -14783,7 +15774,7 @@ var ts; } while (token() !== 1) { switch (token()) { - case 55: + case 56: if (state === 0 || state === 1) { removeTrailingNewlines(comments); parseTag(indent); @@ -14801,7 +15792,7 @@ var ts; state = 0; indent = 0; break; - case 37: + case 38: var asterisk = scanner.getTokenText(); if (state === 1) { state = 2; @@ -14812,7 +15803,7 @@ var ts; indent += asterisk.length; } break; - case 69: + case 70: pushComment(scanner.getTokenText()); state = 2; break; @@ -14869,8 +15860,8 @@ var ts; } } function parseTag(indent) { - ts.Debug.assert(token() === 55); - var atToken = createNode(55, scanner.getTokenPos()); + ts.Debug.assert(token() === 56); + var atToken = createNode(56, scanner.getTokenPos()); atToken.end = scanner.getTextPos(); nextJSDocToken(); var tagName = parseJSDocIdentifierName(); @@ -14921,7 +15912,7 @@ var ts; comments.push(text); indent += text.length; } - while (token() !== 55 && token() !== 1) { + while (token() !== 56 && token() !== 1) { switch (token()) { case 4: if (state >= 1) { @@ -14930,7 +15921,7 @@ var ts; } indent = 0; break; - case 55: + case 56: break; case 5: if (state === 2) { @@ -14944,7 +15935,7 @@ var ts; indent += whitespace.length; } break; - case 37: + case 38: if (state === 0) { state = 1; indent += scanner.getTokenText().length; @@ -14955,7 +15946,7 @@ var ts; pushComment(scanner.getTokenText()); break; } - if (token() === 55) { + if (token() === 56) { break; } nextJSDocToken(); @@ -14983,7 +15974,7 @@ var ts; function tryParseTypeExpression() { return tryParse(function () { skipWhitespace(); - if (token() !== 15) { + if (token() !== 16) { return undefined; } return parseJSDocTypeExpression(); @@ -14994,14 +15985,14 @@ var ts; skipWhitespace(); var name; var isBracketed; - if (parseOptionalToken(19)) { + if (parseOptionalToken(20)) { name = parseJSDocIdentifierName(); skipWhitespace(); isBracketed = true; - if (parseOptionalToken(56)) { + if (parseOptionalToken(57)) { parseExpression(); } - parseExpected(20); + parseExpected(21); } else if (ts.tokenIsIdentifierOrKeyword(token())) { name = parseJSDocIdentifierName(); @@ -15078,7 +16069,7 @@ var ts; if (typeExpression) { if (typeExpression.type.kind === 267) { var jsDocTypeReference = typeExpression.type; - if (jsDocTypeReference.name.kind === 69) { + if (jsDocTypeReference.name.kind === 70) { var name_11 = jsDocTypeReference.name; if (name_11.text === "Object") { typedefTag.jsDocTypeLiteral = scanChildTags(); @@ -15102,7 +16093,7 @@ var ts; while (token() !== 1 && !parentTagTerminated) { nextJSDocToken(); switch (token()) { - case 55: + case 56: if (canParseTag) { parentTagTerminated = !tryParseChildTag(jsDocTypeLiteral); if (!parentTagTerminated) { @@ -15116,13 +16107,13 @@ var ts; canParseTag = true; seenAsterisk = false; break; - case 37: + case 38: if (seenAsterisk) { canParseTag = false; } seenAsterisk = true; break; - case 69: + case 70: canParseTag = false; case 1: break; @@ -15133,8 +16124,8 @@ var ts; } } function tryParseChildTag(parentTag) { - ts.Debug.assert(token() === 55); - var atToken = createNode(55, scanner.getStartPos()); + ts.Debug.assert(token() === 56); + var atToken = createNode(56, scanner.getStartPos()); atToken.end = scanner.getTextPos(); nextJSDocToken(); var tagName = parseJSDocIdentifierName(); @@ -15172,11 +16163,11 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(141, name_12.pos); + var typeParameter = createNode(142, name_12.pos); typeParameter.name = name_12; finishNode(typeParameter); typeParameters.push(typeParameter); - if (token() === 24) { + if (token() === 25) { nextJSDocToken(); skipWhitespace(); } @@ -15205,7 +16196,7 @@ var ts; } var pos = scanner.getTokenPos(); var end = scanner.getTextPos(); - var result = createNode(69, pos); + var result = createNode(70, pos); result.text = content.substring(pos, end); finishNode(result, end); nextJSDocToken(); @@ -15276,8 +16267,8 @@ var ts; array._children = undefined; array.pos += delta; array.end += delta; - for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { - var node = array_8[_i]; + for (var _i = 0, array_9 = array; _i < array_9.length; _i++) { + var node = array_9[_i]; visitNode(node); } } @@ -15286,7 +16277,7 @@ var ts; switch (node.kind) { case 9: case 8: - case 69: + case 70: return true; } return false; @@ -15349,8 +16340,8 @@ var ts; array.intersectsChange = true; array._children = undefined; adjustIntersectingElement(array, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta); - for (var _i = 0, array_9 = array; _i < array_9.length; _i++) { - var node = array_9[_i]; + for (var _i = 0, array_10 = array; _i < array_10.length; _i++) { + var node = array_10[_i]; visitNode(node); } return; @@ -15498,21 +16489,31 @@ var ts; } } } + var InvalidPosition; + (function (InvalidPosition) { + InvalidPosition[InvalidPosition["Value"] = -1] = "Value"; + })(InvalidPosition || (InvalidPosition = {})); })(IncrementalParser || (IncrementalParser = {})); })(ts || (ts = {})); var ts; (function (ts) { + (function (ModuleInstanceState) { + ModuleInstanceState[ModuleInstanceState["NonInstantiated"] = 0] = "NonInstantiated"; + ModuleInstanceState[ModuleInstanceState["Instantiated"] = 1] = "Instantiated"; + ModuleInstanceState[ModuleInstanceState["ConstEnumOnly"] = 2] = "ConstEnumOnly"; + })(ts.ModuleInstanceState || (ts.ModuleInstanceState = {})); + var ModuleInstanceState = ts.ModuleInstanceState; function getModuleInstanceState(node) { - if (node.kind === 222 || node.kind === 223) { + if (node.kind === 223 || node.kind === 224) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 230 || node.kind === 229) && !(ts.hasModifier(node, 1))) { + else if ((node.kind === 231 || node.kind === 230) && !(ts.hasModifier(node, 1))) { return 0; } - else if (node.kind === 226) { + else if (node.kind === 227) { var state_1 = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -15528,7 +16529,7 @@ var ts; }); return state_1; } - else if (node.kind === 225) { + else if (node.kind === 226) { var body = node.body; return body ? getModuleInstanceState(body) : 1; } @@ -15537,6 +16538,18 @@ var ts; } } ts.getModuleInstanceState = getModuleInstanceState; + var ContainerFlags; + (function (ContainerFlags) { + ContainerFlags[ContainerFlags["None"] = 0] = "None"; + ContainerFlags[ContainerFlags["IsContainer"] = 1] = "IsContainer"; + ContainerFlags[ContainerFlags["IsBlockScopedContainer"] = 2] = "IsBlockScopedContainer"; + ContainerFlags[ContainerFlags["IsControlFlowContainer"] = 4] = "IsControlFlowContainer"; + ContainerFlags[ContainerFlags["IsFunctionLike"] = 8] = "IsFunctionLike"; + ContainerFlags[ContainerFlags["IsFunctionExpression"] = 16] = "IsFunctionExpression"; + ContainerFlags[ContainerFlags["HasLocals"] = 32] = "HasLocals"; + ContainerFlags[ContainerFlags["IsInterface"] = 64] = "IsInterface"; + ContainerFlags[ContainerFlags["IsObjectLiteralOrClassExpressionMethod"] = 128] = "IsObjectLiteralOrClassExpressionMethod"; + })(ContainerFlags || (ContainerFlags = {})); var binder = createBinder(); function bindSourceFile(file, options) { ts.performance.mark("beforeBind"); @@ -15634,7 +16647,7 @@ var ts; if (symbolFlags & 107455) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 225)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 226)) { symbol.valueDeclaration = node; } } @@ -15644,7 +16657,7 @@ var ts; if (ts.isAmbientModule(node)) { return ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + node.name.text + "\""; } - if (node.name.kind === 140) { + if (node.name.kind === 141) { var nameExpression = node.name.expression; if (ts.isStringOrNumericLiteral(nameExpression.kind)) { return nameExpression.text; @@ -15655,21 +16668,21 @@ var ts; return node.name.text; } switch (node.kind) { - case 148: + case 149: return "__constructor"; - case 156: - case 151: - return "__call"; case 157: case 152: - return "__new"; + return "__call"; + case 158: case 153: + return "__new"; + case 154: return "__index"; - case 236: + case 237: return "__export"; - case 235: + case 236: return node.isExportEquals ? "export=" : "default"; - case 187: + case 188: switch (ts.getSpecialPropertyAssignmentKind(node)) { case 2: return "export="; @@ -15681,12 +16694,12 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 220: case 221: + case 222: return ts.hasModifier(node, 512) ? "default" : undefined; case 269: return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; - case 142: + case 143: ts.Debug.assert(node.parent.kind === 269); var functionType = node.parent; var index = ts.indexOf(functionType.parameters, node); @@ -15694,10 +16707,10 @@ var ts; case 279: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 200) { + if (parentNode && parentNode.kind === 201) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; - if (nameIdentifier.kind === 69) { + if (nameIdentifier.kind === 70) { nameFromParentNode = nameIdentifier.text; } } @@ -15738,7 +16751,7 @@ var ts; } else { if (symbol.declarations && symbol.declarations.length && - (isDefaultExport || (node.kind === 235 && !node.isExportEquals))) { + (isDefaultExport || (node.kind === 236 && !node.isExportEquals))) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -15758,7 +16771,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1; if (symbolFlags & 8388608) { - if (node.kind === 238 || (node.kind === 229 && hasExportModifier)) { + if (node.kind === 239 || (node.kind === 230 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -15875,64 +16888,64 @@ var ts; return; } switch (node.kind) { - case 205: + case 206: bindWhileStatement(node); break; - case 204: + case 205: bindDoStatement(node); break; - case 206: + case 207: bindForStatement(node); break; - case 207: case 208: + case 209: bindForInOrForOfStatement(node); break; - case 203: + case 204: bindIfStatement(node); break; - case 211: - case 215: + case 212: + case 216: bindReturnOrThrow(node); break; + case 211: case 210: - case 209: bindBreakOrContinueStatement(node); break; - case 216: + case 217: bindTryStatement(node); break; - case 213: + case 214: bindSwitchStatement(node); break; - case 227: + case 228: bindCaseBlock(node); break; case 249: bindCaseClause(node); break; - case 214: + case 215: bindLabeledStatement(node); break; - case 185: + case 186: bindPrefixUnaryExpressionFlow(node); break; - case 186: + case 187: bindPostfixUnaryExpressionFlow(node); break; - case 187: + case 188: bindBinaryExpressionFlow(node); break; - case 181: + case 182: bindDeleteExpressionFlow(node); break; - case 188: + case 189: bindConditionalExpressionFlow(node); break; - case 218: + case 219: bindVariableDeclarationFlow(node); break; - case 174: + case 175: bindCallExpressionFlow(node); break; default: @@ -15942,25 +16955,25 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 69: - case 97: - case 172: + case 70: + case 98: + case 173: return isNarrowableReference(expr); - case 174: + case 175: return hasNarrowableArgument(expr); - case 178: + case 179: return isNarrowingExpression(expr.expression); - case 187: + case 188: return isNarrowingBinaryExpression(expr); - case 185: - return expr.operator === 49 && isNarrowingExpression(expr.operand); + case 186: + return expr.operator === 50 && isNarrowingExpression(expr.operand); } return false; } function isNarrowableReference(expr) { - return expr.kind === 69 || - expr.kind === 97 || - expr.kind === 172 && isNarrowableReference(expr.expression); + return expr.kind === 70 || + expr.kind === 98 || + expr.kind === 173 && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -15971,41 +16984,41 @@ var ts; } } } - if (expr.expression.kind === 172 && + if (expr.expression.kind === 173 && isNarrowableReference(expr.expression.expression)) { return true; } return false; } function isNarrowingTypeofOperands(expr1, expr2) { - return expr1.kind === 182 && isNarrowableOperand(expr1.expression) && expr2.kind === 9; + return expr1.kind === 183 && isNarrowableOperand(expr1.expression) && expr2.kind === 9; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 56: + case 57: return isNarrowableReference(expr.left); - case 30: case 31: case 32: case 33: + case 34: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 91: + case 92: return isNarrowableOperand(expr.left); - case 24: + case 25: return isNarrowingExpression(expr.right); } return false; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 178: + case 179: return isNarrowableOperand(expr.expression); - case 187: + case 188: switch (expr.operatorToken.kind) { - case 56: + case 57: return isNarrowableOperand(expr.left); - case 24: + case 25: return isNarrowableOperand(expr.right); } } @@ -16024,7 +17037,7 @@ var ts; }; } function setFlowNodeReferenced(flow) { - flow.flags |= flow.flags & 256 ? 512 : 256; + flow.flags |= flow.flags & 512 ? 1024 : 512; } function addAntecedent(label, antecedent) { if (!(antecedent.flags & 1) && !ts.contains(label.antecedents, antecedent)) { @@ -16039,8 +17052,8 @@ var ts; if (!expression) { return flags & 32 ? antecedent : unreachableFlow; } - if (expression.kind === 99 && flags & 64 || - expression.kind === 84 && flags & 32) { + if (expression.kind === 100 && flags & 64 || + expression.kind === 85 && flags & 32) { return unreachableFlow; } if (!isNarrowingExpression(expression)) { @@ -16074,6 +17087,14 @@ var ts; node: node }; } + function createFlowArrayMutation(antecedent, node) { + setFlowNodeReferenced(antecedent); + return { + flags: 256, + antecedent: antecedent, + node: node + }; + } function finishFlowLabel(flow) { var antecedents = flow.antecedents; if (!antecedents) { @@ -16087,34 +17108,34 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 203: - case 205: case 204: - return parent.expression === node; case 206: - case 188: + case 205: + return parent.expression === node; + case 207: + case 189: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 178) { + if (node.kind === 179) { node = node.expression; } - else if (node.kind === 185 && node.operator === 49) { + else if (node.kind === 186 && node.operator === 50) { node = node.operand; } else { - return node.kind === 187 && (node.operatorToken.kind === 51 || - node.operatorToken.kind === 52); + return node.kind === 188 && (node.operatorToken.kind === 52 || + node.operatorToken.kind === 53); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 178 || - node.parent.kind === 185 && - node.parent.operator === 49) { + while (node.parent.kind === 179 || + node.parent.kind === 186 && + node.parent.operator === 50) { node = node.parent; } return !isStatementCondition(node) && !isLogicalExpression(node.parent); @@ -16187,7 +17208,7 @@ var ts; bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 219) { + if (node.initializer.kind !== 220) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -16209,7 +17230,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 211) { + if (node.kind === 212) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -16229,7 +17250,7 @@ var ts; return undefined; } function bindbreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 210 ? breakTarget : continueTarget; + var flowLabel = node.kind === 211 ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -16249,21 +17270,32 @@ var ts; } } function bindTryStatement(node) { - var postFinallyLabel = createBranchLabel(); + var preFinallyLabel = createBranchLabel(); var preTryFlow = currentFlow; bind(node.tryBlock); - addAntecedent(postFinallyLabel, currentFlow); + addAntecedent(preFinallyLabel, currentFlow); + var flowAfterTry = currentFlow; + var flowAfterCatch = unreachableFlow; if (node.catchClause) { currentFlow = preTryFlow; bind(node.catchClause); - addAntecedent(postFinallyLabel, currentFlow); + addAntecedent(preFinallyLabel, currentFlow); + flowAfterCatch = currentFlow; } if (node.finallyBlock) { - currentFlow = preTryFlow; + addAntecedent(preFinallyLabel, preTryFlow); + currentFlow = finishFlowLabel(preFinallyLabel); bind(node.finallyBlock); + if (!(currentFlow.flags & 1)) { + if ((flowAfterTry.flags & 1) && (flowAfterCatch.flags & 1)) { + currentFlow = flowAfterTry === reportedUnreachableFlow || flowAfterCatch === reportedUnreachableFlow + ? reportedUnreachableFlow + : unreachableFlow; + } + } } - if (!node.finallyBlock || !(currentFlow.flags & 1)) { - currentFlow = finishFlowLabel(postFinallyLabel); + else { + currentFlow = finishFlowLabel(preFinallyLabel); } } function bindSwitchStatement(node) { @@ -16340,7 +17372,7 @@ var ts; currentFlow = finishFlowLabel(postStatementLabel); } function bindDestructuringTargetFlow(node) { - if (node.kind === 187 && node.operatorToken.kind === 56) { + if (node.kind === 188 && node.operatorToken.kind === 57) { bindAssignmentTargetFlow(node.left); } else { @@ -16351,10 +17383,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 170) { + else if (node.kind === 171) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 191) { + if (e.kind === 192) { bindAssignmentTargetFlow(e.expression); } else { @@ -16362,7 +17394,7 @@ var ts; } } } - else if (node.kind === 171) { + else if (node.kind === 172) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; if (p.kind === 253) { @@ -16376,7 +17408,7 @@ var ts; } function bindLogicalExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 51) { + if (node.operatorToken.kind === 52) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -16387,7 +17419,7 @@ var ts; bindCondition(node.right, trueTarget, falseTarget); } function bindPrefixUnaryExpressionFlow(node) { - if (node.operator === 49) { + if (node.operator === 50) { var saveTrueTarget = currentTrueTarget; currentTrueTarget = currentFalseTarget; currentFalseTarget = saveTrueTarget; @@ -16397,20 +17429,20 @@ var ts; } else { ts.forEachChild(node, bind); - if (node.operator === 41 || node.operator === 42) { + if (node.operator === 42 || node.operator === 43) { bindAssignmentTargetFlow(node.operand); } } } function bindPostfixUnaryExpressionFlow(node) { ts.forEachChild(node, bind); - if (node.operator === 41 || node.operator === 42) { + if (node.operator === 42 || node.operator === 43) { bindAssignmentTargetFlow(node.operand); } } function bindBinaryExpressionFlow(node) { var operator = node.operatorToken.kind; - if (operator === 51 || operator === 52) { + if (operator === 52 || operator === 53) { if (isTopLevelLogicalExpression(node)) { var postExpressionLabel = createBranchLabel(); bindLogicalExpression(node, postExpressionLabel, postExpressionLabel); @@ -16422,14 +17454,20 @@ var ts; } else { ts.forEachChild(node, bind); - if (operator === 56 && !ts.isAssignmentTarget(node)) { + if (operator === 57 && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); + if (node.left.kind === 174) { + var elementAccess = node.left; + if (isNarrowableOperand(elementAccess.expression)) { + currentFlow = createFlowArrayMutation(currentFlow, node); + } + } } } } function bindDeleteExpressionFlow(node) { ts.forEachChild(node, bind); - if (node.expression.kind === 172) { + if (node.expression.kind === 173) { bindAssignmentTargetFlow(node.expression); } } @@ -16460,16 +17498,16 @@ var ts; } function bindVariableDeclarationFlow(node) { ts.forEachChild(node, bind); - if (node.initializer || node.parent.parent.kind === 207 || node.parent.parent.kind === 208) { + if (node.initializer || node.parent.parent.kind === 208 || node.parent.parent.kind === 209) { bindInitializedVariableFlow(node); } } function bindCallExpressionFlow(node) { var expr = node.expression; - while (expr.kind === 178) { + while (expr.kind === 179) { expr = expr.expression; } - if (expr.kind === 179 || expr.kind === 180) { + if (expr.kind === 180 || expr.kind === 181) { ts.forEach(node.typeArguments, bind); ts.forEach(node.arguments, bind); bind(node.expression); @@ -16477,54 +17515,60 @@ var ts; else { ts.forEachChild(node, bind); } + if (node.expression.kind === 173) { + var propertyAccess = node.expression; + if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { + currentFlow = createFlowArrayMutation(currentFlow, node); + } + } } function getContainerFlags(node) { switch (node.kind) { - case 192: - case 221: - case 224: - case 171: - case 159: + case 193: + case 222: + case 225: + case 172: + case 160: case 281: case 265: return 1; - case 222: + case 223: return 1 | 64; case 269: - case 225: - case 223: + case 226: + case 224: return 1 | 32; case 256: return 1 | 4 | 32; - case 147: + case 148: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 | 4 | 32 | 8 | 128; } - case 148: - case 220: - case 146: case 149: + case 221: + case 147: case 150: case 151: case 152: case 153: - case 156: + case 154: case 157: + case 158: return 1 | 4 | 32 | 8; - case 179: case 180: + case 181: return 1 | 4 | 32 | 8 | 16; - case 226: + case 227: return 4; - case 145: + case 146: return node.initializer ? 4 : 0; case 252: - case 206: case 207: case 208: - case 227: + case 209: + case 228: return 2; - case 199: + case 200: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -16540,36 +17584,36 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 225: + case 226: return declareModuleMember(node, symbolFlags, symbolExcludes); case 256: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 192: - case 221: - return declareClassMember(node, symbolFlags, symbolExcludes); - case 224: - return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 159: - case 171: + case 193: case 222: + return declareClassMember(node, symbolFlags, symbolExcludes); + case 225: + return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); + case 160: + case 172: + case 223: case 265: case 281: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 156: case 157: - case 151: + case 158: case 152: case 153: - case 147: - case 146: + case 154: case 148: + case 147: case 149: case 150: - case 220: - case 179: + case 151: + case 221: case 180: + case 181: case 269: - case 223: + case 224: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -16585,10 +17629,10 @@ var ts; } function hasExportDeclarations(node) { var body = node.kind === 256 ? node : node.body; - if (body && (body.kind === 256 || body.kind === 226)) { + if (body && (body.kind === 256 || body.kind === 227)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 236 || stat.kind === 235) { + if (stat.kind === 237 || stat.kind === 236) { return true; } } @@ -16660,15 +17704,20 @@ var ts; typeLiteralSymbol.members[symbol.name] = symbol; } function bindObjectLiteralExpression(node) { + var ElementKind; + (function (ElementKind) { + ElementKind[ElementKind["Property"] = 1] = "Property"; + ElementKind[ElementKind["Accessor"] = 2] = "Accessor"; + })(ElementKind || (ElementKind = {})); if (inStrictMode) { var seen = ts.createMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.name.kind !== 69) { + if (prop.name.kind !== 70) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 253 || prop.kind === 254 || prop.kind === 147 + var currentKind = prop.kind === 253 || prop.kind === 254 || prop.kind === 148 ? 1 : 2; var existingKind = seen[identifier.text]; @@ -16690,7 +17739,7 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 225: + case 226: declareModuleMember(node, symbolFlags, symbolExcludes); break; case 256: @@ -16711,8 +17760,8 @@ var ts; } function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 106 && - node.originalKeywordKind <= 114 && + node.originalKeywordKind >= 107 && + node.originalKeywordKind <= 115 && !ts.isIdentifierName(node) && !ts.isInAmbientContext(node)) { if (!file.parseDiagnostics.length) { @@ -16740,17 +17789,17 @@ var ts; } } function checkStrictModeDeleteExpression(node) { - if (inStrictMode && node.expression.kind === 69) { + if (inStrictMode && node.expression.kind === 70) { var span_2 = ts.getErrorSpanForNode(file, node.expression); file.bindDiagnostics.push(ts.createFileDiagnostic(file, span_2.start, span_2.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode)); } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 69 && + return node.kind === 70 && (node.text === "eval" || node.text === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 69) { + if (name && name.kind === 70) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { var span_3 = ts.getErrorSpanForNode(file, name); @@ -16784,7 +17833,7 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2) { if (blockScopeContainer.kind !== 256 && - blockScopeContainer.kind !== 225 && + blockScopeContainer.kind !== 226 && !ts.isFunctionLike(blockScopeContainer)) { var errorSpan = ts.getErrorSpanForNode(file, node); file.bindDiagnostics.push(ts.createFileDiagnostic(file, errorSpan.start, errorSpan.length, getStrictModeBlockScopeFunctionDeclarationMessage(node))); @@ -16803,7 +17852,7 @@ var ts; } function checkStrictModePrefixUnaryExpression(node) { if (inStrictMode) { - if (node.operator === 41 || node.operator === 42) { + if (node.operator === 42 || node.operator === 43) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -16827,7 +17876,7 @@ var ts; node.parent = parent; var saveInStrictMode = inStrictMode; bindWorker(node); - if (node.kind > 138) { + if (node.kind > 139) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -16864,18 +17913,18 @@ var ts; } function bindWorker(node) { switch (node.kind) { - case 69: - case 97: + case 70: + case 98: if (currentFlow && (ts.isExpression(node) || parent.kind === 254)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 172: + case 173: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } break; - case 187: + case 188: if (ts.isInJavaScriptFile(node)) { var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { @@ -16900,30 +17949,30 @@ var ts; return checkStrictModeBinaryExpression(node); case 252: return checkStrictModeCatchClause(node); - case 181: + case 182: return checkStrictModeDeleteExpression(node); case 8: return checkStrictModeNumericLiteral(node); - case 186: + case 187: return checkStrictModePostfixUnaryExpression(node); - case 185: + case 186: return checkStrictModePrefixUnaryExpression(node); - case 212: + case 213: return checkStrictModeWithStatement(node); - case 165: + case 166: seenThisKeyword = true; return; - case 154: + case 155: return checkTypePredicate(node); - case 141: - return declareSymbolAndAddToSymbolTable(node, 262144, 530920); case 142: + return declareSymbolAndAddToSymbolTable(node, 262144, 530920); + case 143: return bindParameter(node); - case 218: - case 169: + case 219: + case 170: return bindVariableDeclarationOrBindingElement(node); + case 146: case 145: - case 144: case 266: return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 0); case 280: @@ -16936,82 +17985,82 @@ var ts; case 247: emitFlags |= 16384; return; - case 151: case 152: case 153: + case 154: return declareSymbolAndAddToSymbolTable(node, 131072, 0); - case 147: - case 146: - return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 0 : 99263); - case 220: - return bindFunctionDeclaration(node); case 148: - return declareSymbolAndAddToSymbolTable(node, 16384, 0); + case 147: + return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 0 : 99263); + case 221: + return bindFunctionDeclaration(node); case 149: - return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + return declareSymbolAndAddToSymbolTable(node, 16384, 0); case 150: + return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + case 151: return bindPropertyOrMethodOrAccessor(node, 65536, 74687); - case 156: case 157: + case 158: case 269: return bindFunctionOrConstructorType(node); - case 159: + case 160: case 281: case 265: return bindAnonymousDeclaration(node, 2048, "__type"); - case 171: + case 172: return bindObjectLiteralExpression(node); - case 179: case 180: + case 181: return bindFunctionExpression(node); - case 174: + case 175: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; - case 192: - case 221: + case 193: + case 222: inStrictMode = true; return bindClassLikeDeclaration(node); - case 222: + case 223: return bindBlockScopedDeclaration(node, 64, 792968); case 279: - case 223: - return bindBlockScopedDeclaration(node, 524288, 793064); case 224: - return bindEnumDeclaration(node); + return bindBlockScopedDeclaration(node, 524288, 793064); case 225: + return bindEnumDeclaration(node); + case 226: return bindModuleDeclaration(node); - case 229: - case 232: - case 234: - case 238: - return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); - case 228: - return bindNamespaceExportDeclaration(node); - case 231: - return bindImportClause(node); - case 236: - return bindExportDeclaration(node); + case 230: + case 233: case 235: + case 239: + return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + case 229: + return bindNamespaceExportDeclaration(node); + case 232: + return bindImportClause(node); + case 237: + return bindExportDeclaration(node); + case 236: return bindExportAssignment(node); case 256: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 199: + case 200: if (!ts.isFunctionLike(node.parent)) { return; } - case 226: + case 227: return updateStrictModeStatementList(node.statements); } } function checkTypePredicate(node) { var parameterName = node.parameterName, type = node.type; - if (parameterName && parameterName.kind === 69) { + if (parameterName && parameterName.kind === 70) { checkStrictModeIdentifier(parameterName); } - if (parameterName && parameterName.kind === 165) { + if (parameterName && parameterName.kind === 166) { seenThisKeyword = true; } bind(type); @@ -17030,7 +18079,7 @@ var ts; bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); } else { - var flags = node.kind === 235 && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 236 && ts.exportAssignmentIsAlias(node) ? 8388608 : 4; declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 | 8388608 | 32 | 16); @@ -17074,7 +18123,9 @@ var ts; function setCommonJsModuleIndicator(node) { if (!file.commonJsModuleIndicator) { file.commonJsModuleIndicator = node; - bindSourceFileAsExternalModule(); + if (!file.externalModuleIndicator) { + bindSourceFileAsExternalModule(); + } } } function bindExportsPropertyAssignment(node) { @@ -17087,11 +18138,11 @@ var ts; } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJavaScriptFile(node)); - if (container.kind === 220 || container.kind === 179) { + if (container.kind === 221 || container.kind === 180) { container.symbol.members = container.symbol.members || ts.createMap(); declareSymbol(container.symbol.members, container.symbol, node, 4, 0 & ~4); } - else if (container.kind === 148) { + else if (container.kind === 149) { var saveContainer = container; container = container.parent; var symbol = bindPropertyOrMethodOrAccessor(node, 4, 0); @@ -17131,7 +18182,7 @@ var ts; emitFlags |= 2048; } } - if (node.kind === 221) { + if (node.kind === 222) { bindBlockScopedDeclaration(node, 32, 899519); } else { @@ -17249,15 +18300,15 @@ var ts; return false; } if (currentFlow === unreachableFlow) { - var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 201) || - node.kind === 221 || - (node.kind === 225 && shouldReportErrorOnModuleDeclaration(node)) || - (node.kind === 224 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 202) || + node.kind === 222 || + (node.kind === 226 && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 225 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 200 || + (node.kind !== 201 || ts.getCombinedNodeFlags(node.declarationList) & 3 || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -17271,52 +18322,54 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 174: + case 175: return computeCallExpression(node, subtreeFlags); - case 225: + case 176: + return computeNewExpression(node, subtreeFlags); + case 226: return computeModuleDeclaration(node, subtreeFlags); - case 178: - return computeParenthesizedExpression(node, subtreeFlags); - case 187: - return computeBinaryExpression(node, subtreeFlags); - case 202: - return computeExpressionStatement(node, subtreeFlags); - case 142: - return computeParameter(node, subtreeFlags); - case 180: - return computeArrowFunction(node, subtreeFlags); case 179: + return computeParenthesizedExpression(node, subtreeFlags); + case 188: + return computeBinaryExpression(node, subtreeFlags); + case 203: + return computeExpressionStatement(node, subtreeFlags); + case 143: + return computeParameter(node, subtreeFlags); + case 181: + return computeArrowFunction(node, subtreeFlags); + case 180: return computeFunctionExpression(node, subtreeFlags); - case 220: - return computeFunctionDeclaration(node, subtreeFlags); - case 218: - return computeVariableDeclaration(node, subtreeFlags); - case 219: - return computeVariableDeclarationList(node, subtreeFlags); - case 200: - return computeVariableStatement(node, subtreeFlags); - case 214: - return computeLabeledStatement(node, subtreeFlags); case 221: + return computeFunctionDeclaration(node, subtreeFlags); + case 219: + return computeVariableDeclaration(node, subtreeFlags); + case 220: + return computeVariableDeclarationList(node, subtreeFlags); + case 201: + return computeVariableStatement(node, subtreeFlags); + case 215: + return computeLabeledStatement(node, subtreeFlags); + case 222: return computeClassDeclaration(node, subtreeFlags); - case 192: + case 193: return computeClassExpression(node, subtreeFlags); case 251: return computeHeritageClause(node, subtreeFlags); - case 194: + case 195: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 148: - return computeConstructor(node, subtreeFlags); - case 145: - return computePropertyDeclaration(node, subtreeFlags); - case 147: - return computeMethod(node, subtreeFlags); case 149: + return computeConstructor(node, subtreeFlags); + case 146: + return computePropertyDeclaration(node, subtreeFlags); + case 148: + return computeMethod(node, subtreeFlags); case 150: + case 151: return computeAccessor(node, subtreeFlags); - case 229: + case 230: return computeImportEquals(node, subtreeFlags); - case 172: + case 173: return computePropertyAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -17327,40 +18380,54 @@ var ts; var transformFlags = subtreeFlags; var expression = node.expression; var expressionKind = expression.kind; - if (subtreeFlags & 262144 + if (node.typeArguments) { + transformFlags |= 3; + } + if (subtreeFlags & 1048576 || isSuperOrSuperProperty(expression, expressionKind)) { - transformFlags |= 192; + transformFlags |= 768; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~537133909; + return transformFlags & ~537922901; } function isSuperOrSuperProperty(node, kind) { switch (kind) { - case 95: + case 96: return true; - case 172: case 173: + case 174: var expression = node.expression; var expressionKind = expression.kind; - return expressionKind === 95; + return expressionKind === 96; } return false; } + function computeNewExpression(node, subtreeFlags) { + var transformFlags = subtreeFlags; + if (node.typeArguments) { + transformFlags |= 3; + } + if (subtreeFlags & 1048576) { + transformFlags |= 768; + } + node.transformFlags = transformFlags | 536870912; + return transformFlags & ~537922901; + } function computeBinaryExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 56 - && (leftKind === 171 - || leftKind === 170)) { - transformFlags |= 192 | 256; + if (operatorTokenKind === 57 + && (leftKind === 172 + || leftKind === 171)) { + transformFlags |= 768 | 1024; } - else if (operatorTokenKind === 38 - || operatorTokenKind === 60) { - transformFlags |= 48; + else if (operatorTokenKind === 39 + || operatorTokenKind === 61) { + transformFlags |= 192; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeParameter(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -17368,35 +18435,35 @@ var ts; var name = node.name; var initializer = node.initializer; var dotDotDotToken = node.dotDotDotToken; - if (node.questionToken) { - transformFlags |= 3; - } - if (subtreeFlags & 2048 || ts.isThisIdentifier(name)) { + if (node.questionToken + || node.type + || subtreeFlags & 8192 + || ts.isThisIdentifier(name)) { transformFlags |= 3; } if (modifierFlags & 92) { - transformFlags |= 3 | 131072; + transformFlags |= 3 | 524288; } - if (subtreeFlags & 2097152 || initializer || dotDotDotToken) { - transformFlags |= 192 | 65536; + if (subtreeFlags & 8388608 || initializer || dotDotDotToken) { + transformFlags |= 768 | 262144; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~538968917; + return transformFlags & ~545262933; } function computeParenthesizedExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; var expression = node.expression; var expressionKind = expression.kind; var expressionTransformFlags = expression.transformFlags; - if (expressionKind === 195 - || expressionKind === 177) { + if (expressionKind === 196 + || expressionKind === 178) { transformFlags |= 3; } - if (expressionTransformFlags & 256) { - transformFlags |= 256; + if (expressionTransformFlags & 1024) { + transformFlags |= 1024; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeClassDeclaration(node, subtreeFlags) { var transformFlags; @@ -17405,36 +18472,38 @@ var ts; transformFlags = 3; } else { - transformFlags = subtreeFlags | 192; - if ((subtreeFlags & 137216) - || (modifierFlags & 1)) { + transformFlags = subtreeFlags | 768; + if ((subtreeFlags & 548864) + || (modifierFlags & 1) + || node.typeParameters) { transformFlags |= 3; } - if (subtreeFlags & 32768) { - transformFlags |= 8192; + if (subtreeFlags & 131072) { + transformFlags |= 32768; } } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~537590613; + return transformFlags & ~539749717; } function computeClassExpression(node, subtreeFlags) { - var transformFlags = subtreeFlags | 192; - if (subtreeFlags & 137216) { + var transformFlags = subtreeFlags | 768; + if (subtreeFlags & 548864 + || node.typeParameters) { transformFlags |= 3; } - if (subtreeFlags & 32768) { - transformFlags |= 8192; + if (subtreeFlags & 131072) { + transformFlags |= 32768; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~537590613; + return transformFlags & ~539749717; } function computeHeritageClause(node, subtreeFlags) { var transformFlags = subtreeFlags; switch (node.token) { - case 83: - transformFlags |= 192; + case 84: + transformFlags |= 768; break; - case 106: + case 107: transformFlags |= 3; break; default: @@ -17442,135 +18511,148 @@ var ts; break; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeExpressionWithTypeArguments(node, subtreeFlags) { - var transformFlags = subtreeFlags | 192; + var transformFlags = subtreeFlags | 768; if (node.typeArguments) { transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeConstructor(node, subtreeFlags) { var transformFlags = subtreeFlags; - var body = node.body; - if (body === undefined) { + if (ts.hasModifier(node, 2270) + || !node.body) { transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~550593365; + return transformFlags & ~591760725; } function computeMethod(node, subtreeFlags) { - var transformFlags = subtreeFlags | 192; - var modifierFlags = ts.getModifierFlags(node); - var body = node.body; - var typeParameters = node.typeParameters; - var asteriskToken = node.asteriskToken; - if (!body - || typeParameters - || (modifierFlags & (256 | 128)) - || (subtreeFlags & 2048)) { + var transformFlags = subtreeFlags | 768; + if (node.decorators + || ts.hasModifier(node, 2270) + || node.typeParameters + || node.type + || !node.body) { transformFlags |= 3; } - if (asteriskToken && ts.getEmitFlags(node) & 2097152) { - transformFlags |= 1536; + if (ts.hasModifier(node, 256)) { + transformFlags |= 48; + } + if (node.asteriskToken && ts.getEmitFlags(node) & 2097152) { + transformFlags |= 6144; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~550593365; + return transformFlags & ~591760725; } function computeAccessor(node, subtreeFlags) { var transformFlags = subtreeFlags; - var modifierFlags = ts.getModifierFlags(node); - var body = node.body; - if (!body - || (modifierFlags & (256 | 128)) - || (subtreeFlags & 2048)) { + if (node.decorators + || ts.hasModifier(node, 2270) + || node.type + || !node.body) { transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~550593365; + return transformFlags & ~591760725; } function computePropertyDeclaration(node, subtreeFlags) { var transformFlags = subtreeFlags | 3; if (node.initializer) { - transformFlags |= 4096; + transformFlags |= 16384; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeFunctionDeclaration(node, subtreeFlags) { var transformFlags; var modifierFlags = ts.getModifierFlags(node); var body = node.body; - var asteriskToken = node.asteriskToken; if (!body || (modifierFlags & 2)) { transformFlags = 3; } else { - transformFlags = subtreeFlags | 8388608; + transformFlags = subtreeFlags | 33554432; if (modifierFlags & 1) { - transformFlags |= 3 | 192; + transformFlags |= 3 | 768; } - if (modifierFlags & 256) { + if (modifierFlags & 2270 + || node.typeParameters + || node.type) { transformFlags |= 3; } - if (subtreeFlags & 81920) { - transformFlags |= 192; + if (modifierFlags & 256) { + transformFlags |= 48; } - if (asteriskToken && ts.getEmitFlags(node) & 2097152) { - transformFlags |= 1536; + if (subtreeFlags & 327680) { + transformFlags |= 768; + } + if (node.asteriskToken && ts.getEmitFlags(node) & 2097152) { + transformFlags |= 6144; } } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~550726485; + return transformFlags & ~592293205; } function computeFunctionExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; - var modifierFlags = ts.getModifierFlags(node); - var asteriskToken = node.asteriskToken; - if (modifierFlags & 256) { + if (ts.hasModifier(node, 2270) + || node.typeParameters + || node.type) { transformFlags |= 3; } - if (subtreeFlags & 81920) { - transformFlags |= 192; + if (ts.hasModifier(node, 256)) { + transformFlags |= 48; } - if (asteriskToken && ts.getEmitFlags(node) & 2097152) { - transformFlags |= 1536; + if (subtreeFlags & 327680) { + transformFlags |= 768; + } + if (node.asteriskToken && ts.getEmitFlags(node) & 2097152) { + transformFlags |= 6144; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~550726485; + return transformFlags & ~592293205; } function computeArrowFunction(node, subtreeFlags) { - var transformFlags = subtreeFlags | 192; - var modifierFlags = ts.getModifierFlags(node); - if (modifierFlags & 256) { + var transformFlags = subtreeFlags | 768; + if (ts.hasModifier(node, 2270) + || node.typeParameters + || node.type) { transformFlags |= 3; } - if (subtreeFlags & 8192) { - transformFlags |= 16384; + if (ts.hasModifier(node, 256)) { + transformFlags |= 48; + } + if (subtreeFlags & 32768) { + transformFlags |= 65536; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~550710101; + return transformFlags & ~592227669; } function computePropertyAccess(node, subtreeFlags) { var transformFlags = subtreeFlags; var expression = node.expression; var expressionKind = expression.kind; - if (expressionKind === 95) { - transformFlags |= 8192; + if (expressionKind === 96) { + transformFlags |= 32768; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeVariableDeclaration(node, subtreeFlags) { var transformFlags = subtreeFlags; var nameKind = node.name.kind; - if (nameKind === 167 || nameKind === 168) { - transformFlags |= 192 | 2097152; + if (nameKind === 168 || nameKind === 169) { + transformFlags |= 768 | 8388608; + } + if (node.type) { + transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeVariableStatement(node, subtreeFlags) { var transformFlags; @@ -17582,23 +18664,23 @@ var ts; else { transformFlags = subtreeFlags; if (modifierFlags & 1) { - transformFlags |= 192 | 3; + transformFlags |= 768 | 3; } - if (declarationListTransformFlags & 2097152) { - transformFlags |= 192; + if (declarationListTransformFlags & 8388608) { + transformFlags |= 768; } } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeLabeledStatement(node, subtreeFlags) { var transformFlags = subtreeFlags; - if (subtreeFlags & 1048576 + if (subtreeFlags & 4194304 && ts.isIterationStatement(node, true)) { - transformFlags |= 192; + transformFlags |= 768; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeImportEquals(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -17606,15 +18688,15 @@ var ts; transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeExpressionStatement(node, subtreeFlags) { var transformFlags = subtreeFlags; - if (node.expression.transformFlags & 256) { - transformFlags |= 192; + if (node.expression.transformFlags & 1024) { + transformFlags |= 768; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeModuleDeclaration(node, subtreeFlags) { var transformFlags = 3; @@ -17623,77 +18705,78 @@ var ts; transformFlags |= subtreeFlags; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~546335573; + return transformFlags & ~574729557; } function computeVariableDeclarationList(node, subtreeFlags) { - var transformFlags = subtreeFlags | 8388608; - if (subtreeFlags & 2097152) { - transformFlags |= 192; + var transformFlags = subtreeFlags | 33554432; + if (subtreeFlags & 8388608) { + transformFlags |= 768; } if (node.flags & 3) { - transformFlags |= 192 | 1048576; + transformFlags |= 768 | 4194304; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~538968917; + return transformFlags & ~545262933; } function computeOther(node, kind, subtreeFlags) { var transformFlags = subtreeFlags; - var excludeFlags = 536871765; + var excludeFlags = 536874325; switch (kind) { - case 112: - case 110: + case 119: + case 185: + transformFlags |= 48; + break; + case 113: case 111: - case 115: - case 122: - case 118: - case 74: - case 184: - case 224: + case 112: + case 116: + case 123: + case 75: + case 225: case 255: - case 177: - case 195: + case 178: case 196: - case 128: + case 197: + case 129: transformFlags |= 3; break; - case 241: case 242: case 243: case 244: + case 10: case 245: case 246: case 247: case 248: transformFlags |= 12; break; - case 82: - transformFlags |= 192 | 3; + case 83: + transformFlags |= 768 | 3; break; - case 77: - case 11: + case 78: case 12: case 13: case 14: - case 189: - case 176: - case 254: - case 208: - transformFlags |= 192; - break; + case 15: case 190: - transformFlags |= 192 | 4194304; + case 177: + case 254: + case 209: + transformFlags |= 768; break; - case 117: - case 130: - case 127: - case 132: - case 120: + case 191: + transformFlags |= 768 | 16777216; + break; + case 118: + case 131: + case 128: case 133: - case 103: - case 141: - case 144: - case 146: - case 151: + case 121: + case 134: + case 104: + case 142: + case 145: + case 147: case 152: case 153: case 154: @@ -17707,68 +18790,69 @@ var ts; case 162: case 163: case 164: - case 222: - case 223: case 165: + case 223: + case 224: case 166: + case 167: transformFlags = 3; excludeFlags = -3; break; - case 140: - transformFlags |= 524288; - if (subtreeFlags & 8192) { + case 141: + transformFlags |= 2097152; + if (subtreeFlags & 32768) { + transformFlags |= 131072; + } + break; + case 192: + transformFlags |= 1048576; + break; + case 96: + transformFlags |= 768; + break; + case 98: + transformFlags |= 32768; + break; + case 168: + case 169: + transformFlags |= 768 | 8388608; + break; + case 144: + transformFlags |= 3 | 8192; + break; + case 172: + excludeFlags = 539110741; + if (subtreeFlags & 2097152) { + transformFlags |= 768; + } + if (subtreeFlags & 131072) { transformFlags |= 32768; } break; - case 191: - transformFlags |= 262144; - break; - case 95: - transformFlags |= 192; - break; - case 97: - transformFlags |= 8192; - break; - case 167: - case 168: - transformFlags |= 192 | 2097152; - break; - case 143: - transformFlags |= 3 | 2048; - break; case 171: - excludeFlags = 537430869; - if (subtreeFlags & 524288) { - transformFlags |= 192; - } - if (subtreeFlags & 32768) { - transformFlags |= 8192; + case 176: + excludeFlags = 537922901; + if (subtreeFlags & 1048576) { + transformFlags |= 768; } break; - case 170: - case 175: - excludeFlags = 537133909; - if (subtreeFlags & 262144) { - transformFlags |= 192; - } - break; - case 204: case 205: case 206: case 207: - if (subtreeFlags & 1048576) { - transformFlags |= 192; + case 208: + if (subtreeFlags & 4194304) { + transformFlags |= 768; } break; case 256: - if (subtreeFlags & 16384) { - transformFlags |= 192; + if (subtreeFlags & 65536) { + transformFlags |= 768; } break; - case 211: - case 209: + case 212: case 210: - transformFlags |= 8388608; + case 211: + transformFlags |= 33554432; break; } node.transformFlags = transformFlags | 536870912; @@ -17777,7 +18861,7 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function trace(host, message) { + function trace(host) { host.trace(ts.formatMessage.apply(undefined, arguments)); } ts.trace = trace; @@ -18422,6 +19506,7 @@ var ts; var intersectionTypes = ts.createMap(); var stringLiteralTypes = ts.createMap(); var numericLiteralTypes = ts.createMap(); + var evolvingArrayTypes = []; var unknownSymbol = createSymbol(4 | 67108864, "unknown"); var resolvingSymbol = createSymbol(67108864, "__resolving__"); var anyType = createIntrinsicType(1, "any"); @@ -18465,6 +19550,7 @@ var ts; var globalBooleanType; var globalRegExpType; var anyArrayType; + var autoArrayType; var anyReadonlyArrayType; var getGlobalTemplateStringsArrayType; var getGlobalESSymbolType; @@ -18505,6 +19591,66 @@ var ts; var potentialThisCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); + var TypeFacts; + (function (TypeFacts) { + TypeFacts[TypeFacts["None"] = 0] = "None"; + TypeFacts[TypeFacts["TypeofEQString"] = 1] = "TypeofEQString"; + TypeFacts[TypeFacts["TypeofEQNumber"] = 2] = "TypeofEQNumber"; + TypeFacts[TypeFacts["TypeofEQBoolean"] = 4] = "TypeofEQBoolean"; + TypeFacts[TypeFacts["TypeofEQSymbol"] = 8] = "TypeofEQSymbol"; + TypeFacts[TypeFacts["TypeofEQObject"] = 16] = "TypeofEQObject"; + TypeFacts[TypeFacts["TypeofEQFunction"] = 32] = "TypeofEQFunction"; + TypeFacts[TypeFacts["TypeofEQHostObject"] = 64] = "TypeofEQHostObject"; + TypeFacts[TypeFacts["TypeofNEString"] = 128] = "TypeofNEString"; + TypeFacts[TypeFacts["TypeofNENumber"] = 256] = "TypeofNENumber"; + TypeFacts[TypeFacts["TypeofNEBoolean"] = 512] = "TypeofNEBoolean"; + TypeFacts[TypeFacts["TypeofNESymbol"] = 1024] = "TypeofNESymbol"; + TypeFacts[TypeFacts["TypeofNEObject"] = 2048] = "TypeofNEObject"; + TypeFacts[TypeFacts["TypeofNEFunction"] = 4096] = "TypeofNEFunction"; + TypeFacts[TypeFacts["TypeofNEHostObject"] = 8192] = "TypeofNEHostObject"; + TypeFacts[TypeFacts["EQUndefined"] = 16384] = "EQUndefined"; + TypeFacts[TypeFacts["EQNull"] = 32768] = "EQNull"; + TypeFacts[TypeFacts["EQUndefinedOrNull"] = 65536] = "EQUndefinedOrNull"; + TypeFacts[TypeFacts["NEUndefined"] = 131072] = "NEUndefined"; + TypeFacts[TypeFacts["NENull"] = 262144] = "NENull"; + TypeFacts[TypeFacts["NEUndefinedOrNull"] = 524288] = "NEUndefinedOrNull"; + TypeFacts[TypeFacts["Truthy"] = 1048576] = "Truthy"; + TypeFacts[TypeFacts["Falsy"] = 2097152] = "Falsy"; + TypeFacts[TypeFacts["Discriminatable"] = 4194304] = "Discriminatable"; + TypeFacts[TypeFacts["All"] = 8388607] = "All"; + TypeFacts[TypeFacts["BaseStringStrictFacts"] = 933633] = "BaseStringStrictFacts"; + TypeFacts[TypeFacts["BaseStringFacts"] = 3145473] = "BaseStringFacts"; + TypeFacts[TypeFacts["StringStrictFacts"] = 4079361] = "StringStrictFacts"; + TypeFacts[TypeFacts["StringFacts"] = 4194049] = "StringFacts"; + TypeFacts[TypeFacts["EmptyStringStrictFacts"] = 3030785] = "EmptyStringStrictFacts"; + TypeFacts[TypeFacts["EmptyStringFacts"] = 3145473] = "EmptyStringFacts"; + TypeFacts[TypeFacts["NonEmptyStringStrictFacts"] = 1982209] = "NonEmptyStringStrictFacts"; + TypeFacts[TypeFacts["NonEmptyStringFacts"] = 4194049] = "NonEmptyStringFacts"; + TypeFacts[TypeFacts["BaseNumberStrictFacts"] = 933506] = "BaseNumberStrictFacts"; + TypeFacts[TypeFacts["BaseNumberFacts"] = 3145346] = "BaseNumberFacts"; + TypeFacts[TypeFacts["NumberStrictFacts"] = 4079234] = "NumberStrictFacts"; + TypeFacts[TypeFacts["NumberFacts"] = 4193922] = "NumberFacts"; + TypeFacts[TypeFacts["ZeroStrictFacts"] = 3030658] = "ZeroStrictFacts"; + TypeFacts[TypeFacts["ZeroFacts"] = 3145346] = "ZeroFacts"; + TypeFacts[TypeFacts["NonZeroStrictFacts"] = 1982082] = "NonZeroStrictFacts"; + TypeFacts[TypeFacts["NonZeroFacts"] = 4193922] = "NonZeroFacts"; + TypeFacts[TypeFacts["BaseBooleanStrictFacts"] = 933252] = "BaseBooleanStrictFacts"; + TypeFacts[TypeFacts["BaseBooleanFacts"] = 3145092] = "BaseBooleanFacts"; + TypeFacts[TypeFacts["BooleanStrictFacts"] = 4078980] = "BooleanStrictFacts"; + TypeFacts[TypeFacts["BooleanFacts"] = 4193668] = "BooleanFacts"; + TypeFacts[TypeFacts["FalseStrictFacts"] = 3030404] = "FalseStrictFacts"; + TypeFacts[TypeFacts["FalseFacts"] = 3145092] = "FalseFacts"; + TypeFacts[TypeFacts["TrueStrictFacts"] = 1981828] = "TrueStrictFacts"; + TypeFacts[TypeFacts["TrueFacts"] = 4193668] = "TrueFacts"; + TypeFacts[TypeFacts["SymbolStrictFacts"] = 1981320] = "SymbolStrictFacts"; + TypeFacts[TypeFacts["SymbolFacts"] = 4193160] = "SymbolFacts"; + TypeFacts[TypeFacts["ObjectStrictFacts"] = 6166480] = "ObjectStrictFacts"; + TypeFacts[TypeFacts["ObjectFacts"] = 8378320] = "ObjectFacts"; + TypeFacts[TypeFacts["FunctionStrictFacts"] = 6164448] = "FunctionStrictFacts"; + TypeFacts[TypeFacts["FunctionFacts"] = 8376288] = "FunctionFacts"; + TypeFacts[TypeFacts["UndefinedFacts"] = 2457472] = "UndefinedFacts"; + TypeFacts[TypeFacts["NullFacts"] = 2340752] = "NullFacts"; + })(TypeFacts || (TypeFacts = {})); var typeofEQFacts = ts.createMap({ "string": 1, "number": 2, @@ -18547,6 +19693,13 @@ var ts; var identityRelation = ts.createMap(); var enumRelation = ts.createMap(); var _displayBuilder; + var TypeSystemPropertyName; + (function (TypeSystemPropertyName) { + TypeSystemPropertyName[TypeSystemPropertyName["Type"] = 0] = "Type"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstructorType"] = 1] = "ResolvedBaseConstructorType"; + TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; + })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); var builtinGlobals = ts.createMap(); builtinGlobals[undefinedSymbol.name] = undefinedSymbol; initializeTypeChecker(); @@ -18631,7 +19784,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 225 && source.valueDeclaration.kind !== 225))) { + (target.valueDeclaration.kind === 226 && source.valueDeclaration.kind !== 226))) { target.valueDeclaration = source.valueDeclaration; } ts.forEach(source.declarations, function (node) { @@ -18766,24 +19919,24 @@ var ts; return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); } if (declaration.pos <= usage.pos) { - return declaration.kind !== 218 || + return declaration.kind !== 219 || !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } return isUsedInFunctionOrNonStaticProperty(declaration, usage); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 200: - case 206: - case 208: + case 201: + case 207: + case 209: if (isSameScopeDescendentOf(usage, declaration, container)) { return true; } break; } switch (declaration.parent.parent.kind) { - case 207: case 208: + case 209: if (isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container)) { return true; } @@ -18801,7 +19954,7 @@ var ts; return true; } var initializerOfNonStaticProperty = current.parent && - current.parent.kind === 145 && + current.parent.kind === 146 && (ts.getModifierFlags(current.parent) & 32) === 0 && current.parent.initializer === current; if (initializerOfNonStaticProperty) { @@ -18827,15 +19980,15 @@ var ts; if (meaning & result.flags & 793064 && lastLocation.kind !== 273) { useResult = result.flags & 262144 ? lastLocation === location.type || - lastLocation.kind === 142 || - lastLocation.kind === 141 + lastLocation.kind === 143 || + lastLocation.kind === 142 : false; } if (meaning & 107455 && result.flags & 1) { useResult = - lastLocation.kind === 142 || + lastLocation.kind === 143 || (lastLocation === location.type && - result.valueDeclaration.kind === 142); + result.valueDeclaration.kind === 143); } } if (useResult) { @@ -18851,7 +20004,7 @@ var ts; if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 225: + case 226: var moduleExports = getSymbolOfNode(location).exports; if (location.kind === 256 || ts.isAmbientModule(location)) { if (result = moduleExports["default"]) { @@ -18863,7 +20016,7 @@ var ts; } if (moduleExports[name] && moduleExports[name].flags === 8388608 && - ts.getDeclarationOfKind(moduleExports[name], 238)) { + ts.getDeclarationOfKind(moduleExports[name], 239)) { break; } } @@ -18871,13 +20024,13 @@ var ts; break loop; } break; - case 224: + case 225: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; + case 146: case 145: - case 144: if (ts.isClassLike(location.parent) && !(ts.getModifierFlags(location) & 32)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { @@ -18887,9 +20040,9 @@ var ts; } } break; - case 221: - case 192: case 222: + case 193: + case 223: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793064)) { if (lastLocation && ts.getModifierFlags(lastLocation) & 32) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); @@ -18897,7 +20050,7 @@ var ts; } break loop; } - if (location.kind === 192 && meaning & 32) { + if (location.kind === 193 && meaning & 32) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -18905,28 +20058,28 @@ var ts; } } break; - case 140: + case 141: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 222) { + if (ts.isClassLike(grandparent) || grandparent.kind === 223) { if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793064)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 147: - case 146: case 148: + case 147: case 149: case 150: - case 220: - case 180: + case 151: + case 221: + case 181: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 179: + case 180: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -18939,8 +20092,8 @@ var ts; } } break; - case 143: - if (location.parent && location.parent.kind === 142) { + case 144: + if (location.parent && location.parent.kind === 143) { location = location.parent; } if (location.parent && ts.isClassElement(location.parent)) { @@ -18982,7 +20135,7 @@ var ts; } if (result && isInExternalModule && (meaning & 107455) === 107455) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 228) { + if (decls && decls.length === 1 && decls[0].kind === 229) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } @@ -18990,7 +20143,7 @@ var ts; return result; } function checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) { - if ((errorLocation.kind === 69 && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { + if ((errorLocation.kind === 70 && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { return false; } var container = ts.getThisContainer(errorLocation, true); @@ -19028,10 +20181,10 @@ var ts; } function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 69: - case 172: + case 70: + case 173: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 194: + case 195: ts.Debug.assert(ts.isEntityNameExpression(node.expression)); return node.expression; default: @@ -19052,7 +20205,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"); - if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 218), errorLocation)) { + if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 219), errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -19069,10 +20222,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 229) { + if (node.kind === 230) { return node; } - while (node && node.kind !== 230) { + while (node && node.kind !== 231) { node = node.parent; } return node; @@ -19082,10 +20235,10 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 240) { + if (node.moduleReference.kind === 241) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } - return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); + return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); } function getTargetOfImportClause(node) { var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier); @@ -19186,19 +20339,19 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 229: + case 230: return getTargetOfImportEqualsDeclaration(node); - case 231: - return getTargetOfImportClause(node); case 232: + return getTargetOfImportClause(node); + case 233: return getTargetOfNamespaceImport(node); - case 234: - return getTargetOfImportSpecifier(node); - case 238: - return getTargetOfExportSpecifier(node); case 235: + return getTargetOfImportSpecifier(node); + case 239: + return getTargetOfExportSpecifier(node); + case 236: return getTargetOfExportAssignment(node); - case 228: + case 229: return getTargetOfNamespaceExportDeclaration(node); } } @@ -19242,10 +20395,10 @@ var ts; links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); ts.Debug.assert(!!node); - if (node.kind === 235) { + if (node.kind === 236) { checkExpressionCached(node.expression); } - else if (node.kind === 238) { + else if (node.kind === 239) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -19253,15 +20406,15 @@ var ts; } } } - function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration, dontResolveAlias) { - if (entityName.kind === 69 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, dontResolveAlias) { + if (entityName.kind === 70 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 69 || entityName.parent.kind === 139) { + if (entityName.kind === 70 || entityName.parent.kind === 140) { return resolveEntityName(entityName, 1920, false, dontResolveAlias); } else { - ts.Debug.assert(entityName.parent.kind === 229); + ts.Debug.assert(entityName.parent.kind === 230); return resolveEntityName(entityName, 107455 | 793064 | 1920, false, dontResolveAlias); } } @@ -19273,16 +20426,16 @@ var ts; return undefined; } var symbol; - if (name.kind === 69) { + if (name.kind === 70) { var message = meaning === 1920 ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; symbol = resolveName(location || name, name.text, meaning, ignoreErrors ? undefined : message, name); if (!symbol) { return undefined; } } - else if (name.kind === 139 || name.kind === 172) { - var left = name.kind === 139 ? name.left : name.expression; - var right = name.kind === 139 ? name.right : name.name; + else if (name.kind === 140 || name.kind === 173) { + var left = name.kind === 140 ? name.left : name.expression; + var right = name.kind === 140 ? name.right : name.name; var namespace = resolveEntityName(left, 1920, ignoreErrors, false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -19465,7 +20618,7 @@ var ts; var members = node.members; for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { var member = members_1[_i]; - if (member.kind === 148 && ts.nodeIsPresent(member.body)) { + if (member.kind === 149 && ts.nodeIsPresent(member.body)) { return member; } } @@ -19539,7 +20692,7 @@ var ts; if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 225: + case 226: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } @@ -19572,7 +20725,7 @@ var ts; return ts.forEachProperty(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 238)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 239)) { if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -19603,7 +20756,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 238)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 239)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -19617,10 +20770,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 145: - case 147: - case 149: + case 146: + case 148: case 150: + case 151: continue; default: return false; @@ -19642,7 +20795,7 @@ var ts; return { accessibility: 1, errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), - errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, 1920) : undefined + errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, 1920) : undefined, }; } return hasAccessibleDeclarations; @@ -19663,7 +20816,7 @@ var ts; } return { accessibility: 1, - errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning) + errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), }; } return { accessibility: 0 }; @@ -19710,11 +20863,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 158 || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + if (entityName.parent.kind === 159 || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning = 107455 | 1048576; } - else if (entityName.kind === 139 || entityName.kind === 172 || - entityName.parent.kind === 229) { + else if (entityName.kind === 140 || entityName.kind === 173 || + entityName.parent.kind === 230) { meaning = 1920; } else { @@ -19806,10 +20959,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { var node = type.symbol.declarations[0].parent; - while (node.kind === 164) { + while (node.kind === 165) { node = node.parent; } - if (node.kind === 223) { + if (node.kind === 224) { return getSymbolOfNode(node); } } @@ -19817,7 +20970,7 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 226 && + node.parent.kind === 227 && ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { @@ -19831,10 +20984,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 192: + case 193: return "(Anonymous class)"; - case 179: case 180: + case 181: return "(Anonymous function)"; } } @@ -19848,17 +21001,17 @@ var ts; var firstChar = symbolName.charCodeAt(0); var needsElementAccess = !ts.isIdentifierStart(firstChar, languageVersion); if (needsElementAccess) { - writePunctuation(writer, 19); + writePunctuation(writer, 20); if (ts.isSingleOrDoubleQuote(firstChar)) { writer.writeStringLiteral(symbolName); } else { writer.writeSymbol(symbolName, symbol); } - writePunctuation(writer, 20); + writePunctuation(writer, 21); } else { - writePunctuation(writer, 21); + writePunctuation(writer, 22); writer.writeSymbol(symbolName, symbol); } } @@ -19934,7 +21087,7 @@ var ts; } else if (type.flags & 256) { buildSymbolDisplay(getParentOfSymbol(type.symbol), writer, enclosingDeclaration, 793064, 0, nextFlags); - writePunctuation(writer, 21); + writePunctuation(writer, 22); appendSymbolNameOnly(type.symbol, writer); } else if (type.flags & (32768 | 65536 | 16 | 16384)) { @@ -19955,23 +21108,23 @@ var ts; writer.writeStringLiteral(literalTypeToString(type)); } else { - writePunctuation(writer, 15); - writeSpace(writer); - writePunctuation(writer, 22); - writeSpace(writer); writePunctuation(writer, 16); + writeSpace(writer); + writePunctuation(writer, 23); + writeSpace(writer); + writePunctuation(writer, 17); } } function writeTypeList(types, delimiter) { for (var i = 0; i < types.length; i++) { if (i > 0) { - if (delimiter !== 24) { + if (delimiter !== 25) { writeSpace(writer); } writePunctuation(writer, delimiter); writeSpace(writer); } - writeType(types[i], delimiter === 24 ? 0 : 64); + writeType(types[i], delimiter === 25 ? 0 : 64); } } function writeSymbolTypeReference(symbol, typeArguments, pos, end, flags) { @@ -19979,29 +21132,29 @@ var ts; buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793064, 0, flags); } if (pos < end) { - writePunctuation(writer, 25); + writePunctuation(writer, 26); writeType(typeArguments[pos], 256); pos++; while (pos < end) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); writeSpace(writer); writeType(typeArguments[pos], 0); pos++; } - writePunctuation(writer, 27); + writePunctuation(writer, 28); } } function writeTypeReference(type, flags) { var typeArguments = type.typeArguments || emptyArray; if (type.target === globalArrayType && !(flags & 1)) { writeType(typeArguments[0], 64); - writePunctuation(writer, 19); writePunctuation(writer, 20); + writePunctuation(writer, 21); } else if (type.target.flags & 262144) { - writePunctuation(writer, 19); - writeTypeList(type.typeArguments.slice(0, getTypeReferenceArity(type)), 24); writePunctuation(writer, 20); + writeTypeList(type.typeArguments.slice(0, getTypeReferenceArity(type)), 25); + writePunctuation(writer, 21); } else { var outerTypeParameters = type.target.outerTypeParameters; @@ -20016,7 +21169,7 @@ var ts; } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_9); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { writeSymbolTypeReference(parent_9, typeArguments, start, i, flags); - writePunctuation(writer, 21); + writePunctuation(writer, 22); } } } @@ -20026,16 +21179,16 @@ var ts; } function writeUnionOrIntersectionType(type, flags) { if (flags & 64) { - writePunctuation(writer, 17); + writePunctuation(writer, 18); } if (type.flags & 524288) { - writeTypeList(formatUnionTypes(type.types), 47); + writeTypeList(formatUnionTypes(type.types), 48); } else { - writeTypeList(type.types, 46); + writeTypeList(type.types, 47); } if (flags & 64) { - writePunctuation(writer, 18); + writePunctuation(writer, 19); } } function writeAnonymousType(type, flags) { @@ -20053,7 +21206,7 @@ var ts; buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793064, 0, flags); } else { - writeKeyword(writer, 117); + writeKeyword(writer, 118); } } else { @@ -20074,7 +21227,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 256 || declaration.parent.kind === 226; + return declaration.parent.kind === 256 || declaration.parent.kind === 227; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -20083,37 +21236,37 @@ var ts; } } function writeTypeOfSymbol(type, typeFormatFlags) { - writeKeyword(writer, 101); + writeKeyword(writer, 102); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455, 0, typeFormatFlags); } function writeIndexSignature(info, keyword) { if (info) { if (info.isReadonly) { - writeKeyword(writer, 128); + writeKeyword(writer, 129); writeSpace(writer); } - writePunctuation(writer, 19); + writePunctuation(writer, 20); writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); - writePunctuation(writer, 54); + writePunctuation(writer, 55); writeSpace(writer); writeKeyword(writer, keyword); - writePunctuation(writer, 20); - writePunctuation(writer, 54); + writePunctuation(writer, 21); + writePunctuation(writer, 55); writeSpace(writer); writeType(info.type, 0); - writePunctuation(writer, 23); + writePunctuation(writer, 24); writer.writeLine(); } } function writePropertyWithModifiers(prop) { if (isReadonlySymbol(prop)) { - writeKeyword(writer, 128); + writeKeyword(writer, 129); writeSpace(writer); } buildSymbolDisplay(prop, writer); if (prop.flags & 536870912) { - writePunctuation(writer, 53); + writePunctuation(writer, 54); } } function shouldAddParenthesisAroundFunctionType(callSignature, flags) { @@ -20131,53 +21284,53 @@ var ts; var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { - writePunctuation(writer, 15); writePunctuation(writer, 16); + writePunctuation(writer, 17); return; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var parenthesizeSignature = shouldAddParenthesisAroundFunctionType(resolved.callSignatures[0], flags); if (parenthesizeSignature) { - writePunctuation(writer, 17); + writePunctuation(writer, 18); } buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, undefined, symbolStack); if (parenthesizeSignature) { - writePunctuation(writer, 18); + writePunctuation(writer, 19); } return; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { if (flags & 64) { - writePunctuation(writer, 17); + writePunctuation(writer, 18); } - writeKeyword(writer, 92); + writeKeyword(writer, 93); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, undefined, symbolStack); if (flags & 64) { - writePunctuation(writer, 18); + writePunctuation(writer, 19); } return; } } var saveInObjectTypeLiteral = inObjectTypeLiteral; inObjectTypeLiteral = true; - writePunctuation(writer, 15); + writePunctuation(writer, 16); writer.writeLine(); writer.increaseIndent(); for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, undefined, symbolStack); - writePunctuation(writer, 23); + writePunctuation(writer, 24); writer.writeLine(); } for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, 1, symbolStack); - writePunctuation(writer, 23); + writePunctuation(writer, 24); writer.writeLine(); } - writeIndexSignature(resolved.stringIndexInfo, 132); - writeIndexSignature(resolved.numberIndexInfo, 130); + writeIndexSignature(resolved.stringIndexInfo, 133); + writeIndexSignature(resolved.numberIndexInfo, 131); for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); @@ -20187,21 +21340,21 @@ var ts; var signature = signatures_1[_f]; writePropertyWithModifiers(p); buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, undefined, symbolStack); - writePunctuation(writer, 23); + writePunctuation(writer, 24); writer.writeLine(); } } else { writePropertyWithModifiers(p); - writePunctuation(writer, 54); + writePunctuation(writer, 55); writeSpace(writer); writeType(t, 0); - writePunctuation(writer, 23); + writePunctuation(writer, 24); writer.writeLine(); } } writer.decreaseIndent(); - writePunctuation(writer, 16); + writePunctuation(writer, 17); inObjectTypeLiteral = saveInObjectTypeLiteral; } } @@ -20216,7 +21369,7 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 83); + writeKeyword(writer, 84); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } @@ -20224,7 +21377,7 @@ var ts; function buildParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack) { var parameterNode = p.valueDeclaration; if (ts.isRestParameter(parameterNode)) { - writePunctuation(writer, 22); + writePunctuation(writer, 23); } if (ts.isBindingPattern(parameterNode.name)) { buildBindingPatternDisplay(parameterNode.name, writer, enclosingDeclaration, flags, symbolStack); @@ -20233,36 +21386,36 @@ var ts; appendSymbolNameOnly(p, writer); } if (isOptionalParameter(parameterNode)) { - writePunctuation(writer, 53); + writePunctuation(writer, 54); } - writePunctuation(writer, 54); + writePunctuation(writer, 55); writeSpace(writer); buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); } function buildBindingPatternDisplay(bindingPattern, writer, enclosingDeclaration, flags, symbolStack) { - if (bindingPattern.kind === 167) { - writePunctuation(writer, 15); - buildDisplayForCommaSeparatedList(bindingPattern.elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); + if (bindingPattern.kind === 168) { writePunctuation(writer, 16); + buildDisplayForCommaSeparatedList(bindingPattern.elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); + writePunctuation(writer, 17); } - else if (bindingPattern.kind === 168) { - writePunctuation(writer, 19); + else if (bindingPattern.kind === 169) { + writePunctuation(writer, 20); var elements = bindingPattern.elements; buildDisplayForCommaSeparatedList(elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); if (elements && elements.hasTrailingComma) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); } - writePunctuation(writer, 20); + writePunctuation(writer, 21); } } function buildBindingElementDisplay(bindingElement, writer, enclosingDeclaration, flags, symbolStack) { if (ts.isOmittedExpression(bindingElement)) { return; } - ts.Debug.assert(bindingElement.kind === 169); + ts.Debug.assert(bindingElement.kind === 170); if (bindingElement.propertyName) { writer.writeSymbol(ts.getTextOfNode(bindingElement.propertyName), bindingElement.symbol); - writePunctuation(writer, 54); + writePunctuation(writer, 55); writeSpace(writer); } if (ts.isBindingPattern(bindingElement.name)) { @@ -20270,75 +21423,75 @@ var ts; } else { if (bindingElement.dotDotDotToken) { - writePunctuation(writer, 22); + writePunctuation(writer, 23); } appendSymbolNameOnly(bindingElement.symbol, writer); } } function buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, flags, symbolStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 25); + writePunctuation(writer, 26); buildDisplayForCommaSeparatedList(typeParameters, writer, function (p) { return buildTypeParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack); }); - writePunctuation(writer, 27); + writePunctuation(writer, 28); } } function buildDisplayForCommaSeparatedList(list, writer, action) { for (var i = 0; i < list.length; i++) { if (i > 0) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); writeSpace(writer); } action(list[i]); } } - function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration, flags, symbolStack) { + function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 25); - var flags_1 = 256; + writePunctuation(writer, 26); + var flags = 256; for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); writeSpace(writer); - flags_1 = 0; + flags = 0; } - buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, flags_1); + buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, flags); } - writePunctuation(writer, 27); + writePunctuation(writer, 28); } } function buildDisplayForParametersAndDelimiters(thisParameter, parameters, writer, enclosingDeclaration, flags, symbolStack) { - writePunctuation(writer, 17); + writePunctuation(writer, 18); if (thisParameter) { buildParameterDisplay(thisParameter, writer, enclosingDeclaration, flags, symbolStack); } for (var i = 0; i < parameters.length; i++) { if (i > 0 || thisParameter) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); writeSpace(writer); } buildParameterDisplay(parameters[i], writer, enclosingDeclaration, flags, symbolStack); } - writePunctuation(writer, 18); + writePunctuation(writer, 19); } function buildTypePredicateDisplay(predicate, writer, enclosingDeclaration, flags, symbolStack) { if (ts.isIdentifierTypePredicate(predicate)) { writer.writeParameter(predicate.parameterName); } else { - writeKeyword(writer, 97); + writeKeyword(writer, 98); } writeSpace(writer); - writeKeyword(writer, 124); + writeKeyword(writer, 125); writeSpace(writer); buildTypeDisplay(predicate.type, writer, enclosingDeclaration, flags, symbolStack); } function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { if (flags & 8) { writeSpace(writer); - writePunctuation(writer, 34); + writePunctuation(writer, 35); } else { - writePunctuation(writer, 54); + writePunctuation(writer, 55); } writeSpace(writer); if (signature.typePredicate) { @@ -20351,7 +21504,7 @@ var ts; } function buildSignatureDisplay(signature, writer, enclosingDeclaration, flags, kind, symbolStack) { if (kind === 1) { - writeKeyword(writer, 92); + writeKeyword(writer, 93); writeSpace(writer); } if (signature.target && (flags & 32)) { @@ -20387,64 +21540,64 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 169: + case 170: return isDeclarationVisible(node.parent.parent); - case 218: + case 219: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 225: - case 221: + case 226: case 222: case 223: - case 220: case 224: - case 229: + case 221: + case 225: + case 230: if (ts.isExternalModuleAugmentation(node)) { return true; } var parent_10 = getDeclarationContainer(node); if (!(ts.getCombinedModifierFlags(node) & 1) && - !(node.kind !== 229 && parent_10.kind !== 256 && ts.isInAmbientContext(parent_10))) { + !(node.kind !== 230 && parent_10.kind !== 256 && ts.isInAmbientContext(parent_10))) { return isGlobalSourceFile(parent_10); } return isDeclarationVisible(parent_10); - case 145: - case 144: - case 149: - case 150: - case 147: case 146: + case 145: + case 150: + case 151: + case 148: + case 147: if (ts.getModifierFlags(node) & (8 | 16)) { return false; } - case 148: - case 152: - case 151: + case 149: case 153: - case 142: - case 226: - case 156: + case 152: + case 154: + case 143: + case 227: case 157: - case 159: - case 155: + case 158: case 160: + case 156: case 161: case 162: case 163: case 164: + case 165: return isDeclarationVisible(node.parent); - case 231: case 232: - case 234: - return false; - case 141: - case 256: - case 228: - return true; + case 233: case 235: return false; + case 142: + case 256: + case 229: + return true; + case 236: + return false; default: return false; } @@ -20452,10 +21605,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 235) { + if (node.parent && node.parent.kind === 236) { exportSymbol = resolveName(node.parent, node.text, 107455 | 793064 | 1920 | 8388608, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 238) { + else if (node.parent.kind === 239) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -20534,12 +21687,12 @@ var ts; node = ts.getRootDeclaration(node); while (node) { switch (node.kind) { - case 218: case 219: + case 220: + case 235: case 234: case 233: case 232: - case 231: node = node.parent; break; default: @@ -20567,12 +21720,12 @@ var ts; } function getTextOfPropertyName(name) { switch (name.kind) { - case 69: + case 70: return name.text; case 9: case 8: return name.text; - case 140: + case 141: if (ts.isStringOrNumericLiteral(name.expression.kind)) { return name.expression.text; } @@ -20580,7 +21733,7 @@ var ts; return undefined; } function isComputedNonLiteralName(name) { - return name.kind === 140 && !ts.isStringOrNumericLiteral(name.expression.kind); + return name.kind === 141 && !ts.isStringOrNumericLiteral(name.expression.kind); } function getTypeForBindingElement(declaration) { var pattern = declaration.parent; @@ -20595,7 +21748,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 167) { + if (pattern.kind === 168) { var name_14 = declaration.propertyName || declaration.name; if (isComputedNonLiteralName(name_14)) { return anyType; @@ -20651,15 +21804,15 @@ var ts; if (typeTag && typeTag.typeExpression) { return typeTag.typeExpression.type; } - if (declaration.kind === 218 && - declaration.parent.kind === 219 && - declaration.parent.parent.kind === 200) { + if (declaration.kind === 219 && + declaration.parent.kind === 220 && + declaration.parent.parent.kind === 201) { var annotation = ts.getJSDocTypeTag(declaration.parent.parent); if (annotation && annotation.typeExpression) { return annotation.typeExpression.type; } } - else if (declaration.kind === 142) { + else if (declaration.kind === 143) { var paramTag = ts.getCorrespondingJSDocParameterTag(declaration); if (paramTag && paramTag.typeExpression) { return paramTag.typeExpression.type; @@ -20667,9 +21820,13 @@ var ts; } return undefined; } - function isAutoVariableInitializer(initializer) { - var expr = initializer && ts.skipParentheses(initializer); - return !expr || expr.kind === 93 || expr.kind === 69 && getResolvedSymbol(expr) === undefinedSymbol; + function isNullOrUndefined(node) { + var expr = ts.skipParentheses(node); + return expr.kind === 94 || expr.kind === 70 && getResolvedSymbol(expr) === undefinedSymbol; + } + function isEmptyArrayLiteral(node) { + var expr = ts.skipParentheses(node); + return expr.kind === 171 && expr.elements.length === 0; } function addOptionality(type, optional) { return strictNullChecks && optional ? includeFalsyTypes(type, 2048) : type; @@ -20681,10 +21838,10 @@ var ts; return type; } } - if (declaration.parent.parent.kind === 207) { + if (declaration.parent.parent.kind === 208) { return stringType; } - if (declaration.parent.parent.kind === 208) { + if (declaration.parent.parent.kind === 209) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -20693,15 +21850,19 @@ var ts; if (declaration.type) { return addOptionality(getTypeFromTypeNode(declaration.type), declaration.questionToken && includeOptionality); } - if (declaration.kind === 218 && !ts.isBindingPattern(declaration.name) && - !(ts.getCombinedNodeFlags(declaration) & 2) && !(ts.getCombinedModifierFlags(declaration) & 1) && - !ts.isInAmbientContext(declaration) && isAutoVariableInitializer(declaration.initializer)) { - return autoType; + if (declaration.kind === 219 && !ts.isBindingPattern(declaration.name) && + !(ts.getCombinedModifierFlags(declaration) & 1) && !ts.isInAmbientContext(declaration)) { + if (!(ts.getCombinedNodeFlags(declaration) & 2) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { + return autoType; + } + if (declaration.initializer && isEmptyArrayLiteral(declaration.initializer)) { + return autoArrayType; + } } - if (declaration.kind === 142) { + if (declaration.kind === 143) { var func = declaration.parent; - if (func.kind === 150 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 149); + if (func.kind === 151 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 150); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -20714,8 +21875,7 @@ var ts; } var type = void 0; if (declaration.symbol.name === "this") { - var thisParameter = getContextualThisParameter(func); - type = thisParameter ? getTypeOfSymbol(thisParameter) : undefined; + type = getContextualThisParameterType(func); } else { type = getContextuallyTypedParameterType(declaration); @@ -20788,7 +21948,7 @@ var ts; return result; } function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { - return pattern.kind === 167 + return pattern.kind === 168 ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -20813,7 +21973,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 142 ? root.parent : root; + var memberDeclaration = root.kind === 143 ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function getTypeOfVariableOrParameterOrProperty(symbol) { @@ -20826,7 +21986,7 @@ var ts; if (declaration.parent.kind === 252) { return links.type = anyType; } - if (declaration.kind === 235) { + if (declaration.kind === 236) { return links.type = checkExpression(declaration.expression); } if (declaration.flags & 1048576 && declaration.kind === 280 && declaration.typeExpression) { @@ -20836,15 +21996,15 @@ var ts; return unknownType; } var type = void 0; - if (declaration.kind === 187 || - declaration.kind === 172 && declaration.parent.kind === 187) { + if (declaration.kind === 188 || + declaration.kind === 173 && declaration.parent.kind === 188) { if (declaration.flags & 1048576) { var typeTag = ts.getJSDocTypeTag(declaration.parent); if (typeTag && typeTag.typeExpression) { return links.type = getTypeFromTypeNode(typeTag.typeExpression.type); } } - var declaredTypes = ts.map(symbol.declarations, function (decl) { return decl.kind === 187 ? + var declaredTypes = ts.map(symbol.declarations, function (decl) { return decl.kind === 188 ? checkExpressionCached(decl.right) : checkExpressionCached(decl.parent.right); }); type = getUnionType(declaredTypes, true); @@ -20870,7 +22030,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 149) { + if (accessor.kind === 150) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -20890,8 +22050,8 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - var getter = ts.getDeclarationOfKind(symbol, 149); - var setter = ts.getDeclarationOfKind(symbol, 150); + var getter = ts.getDeclarationOfKind(symbol, 150); + var setter = ts.getDeclarationOfKind(symbol, 151); if (getter && getter.flags & 1048576) { var jsDocType = getTypeForVariableLikeDeclarationFromJSDocComment(getter); if (jsDocType) { @@ -20932,7 +22092,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 149); + var getter_1 = ts.getDeclarationOfKind(symbol, 150); 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)); } } @@ -20943,7 +22103,7 @@ var ts; function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (symbol.valueDeclaration.kind === 225 && ts.isShorthandAmbientModuleSymbol(symbol)) { + if (symbol.valueDeclaration.kind === 226 && ts.isShorthandAmbientModuleSymbol(symbol)) { links.type = anyType; } else { @@ -21028,9 +22188,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 221 || node.kind === 192 || - node.kind === 220 || node.kind === 179 || - node.kind === 147 || node.kind === 180) { + if (node.kind === 222 || node.kind === 193 || + node.kind === 221 || node.kind === 180 || + node.kind === 148 || node.kind === 181) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -21039,15 +22199,15 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 222); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 223); 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 === 222 || node.kind === 221 || - node.kind === 192 || node.kind === 223) { + if (node.kind === 223 || node.kind === 222 || + node.kind === 193 || node.kind === 224) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -21173,7 +22333,7 @@ var ts; type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 222 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 223 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -21202,7 +22362,7 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 222) { + if (declaration.kind === 223) { if (declaration.flags & 64) { return false; } @@ -21264,7 +22424,7 @@ var ts; } } else { - declaration = ts.getDeclarationOfKind(symbol, 223); + declaration = ts.getDeclarationOfKind(symbol, 224); type = getTypeFromTypeNode(declaration.type, symbol, typeParameters); } if (popTypeResolution()) { @@ -21288,14 +22448,14 @@ var ts; return !ts.isInAmbientContext(member); } return expr.kind === 8 || - expr.kind === 185 && expr.operator === 36 && + expr.kind === 186 && expr.operator === 37 && expr.operand.kind === 8 || - expr.kind === 69 && !!symbol.exports[expr.text]; + expr.kind === 70 && !!symbol.exports[expr.text]; } function enumHasLiteralMembers(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 224) { + if (declaration.kind === 225) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (!isLiteralEnumMember(symbol, member)) { @@ -21323,7 +22483,7 @@ var ts; var memberTypes = ts.createMap(); for (var _i = 0, _a = enumType.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 224) { + if (declaration.kind === 225) { computeEnumMemberValues(declaration); for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; @@ -21361,7 +22521,7 @@ var ts; if (!links.declaredType) { var type = createType(16384); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 141).constraint) { + if (!ts.getDeclarationOfKind(symbol, 142).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -21410,20 +22570,20 @@ var ts; } function isIndependentType(node) { switch (node.kind) { - case 117: - case 132: - case 130: - case 120: + case 118: case 133: - case 103: - case 135: - case 93: - case 127: - case 166: + case 131: + case 121: + case 134: + case 104: + case 136: + case 94: + case 128: + case 167: return true; - case 160: + case 161: return isIndependentType(node.elementType); - case 155: + case 156: return isIndependentTypeReference(node); } return false; @@ -21432,7 +22592,7 @@ var ts; return node.type && isIndependentType(node.type) || !node.type && !node.initializer; } function isIndependentFunctionLikeDeclaration(node) { - if (node.kind !== 148 && (!node.type || !isIndependentType(node.type))) { + if (node.kind !== 149 && (!node.type || !isIndependentType(node.type))) { return false; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { @@ -21448,12 +22608,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 145: - case 144: - return isIndependentVariableLikeDeclaration(declaration); - case 147: case 146: + case 145: + return isIndependentVariableLikeDeclaration(declaration); case 148: + case 147: + case 149: return isIndependentFunctionLikeDeclaration(declaration); } } @@ -22019,7 +23179,7 @@ var ts; return false; } function createTypePredicateFromTypePredicateNode(node) { - if (node.parameterName.kind === 69) { + if (node.parameterName.kind === 70) { var parameterName = node.parameterName; return { kind: 1, @@ -22058,7 +23218,7 @@ var ts; else { parameters.push(paramSymbol); } - if (param.type && param.type.kind === 166) { + if (param.type && param.type.kind === 167) { hasLiteralTypes = true; } if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) { @@ -22070,10 +23230,10 @@ var ts; minArgumentCount = -1; } } - if ((declaration.kind === 149 || declaration.kind === 150) && + if ((declaration.kind === 150 || declaration.kind === 151) && !ts.hasDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 149 ? 150 : 149; + var otherKind = declaration.kind === 150 ? 151 : 150; var other = ts.getDeclarationOfKind(declaration.symbol, otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); @@ -22085,24 +23245,21 @@ var ts; if (isJSConstructSignature) { minArgumentCount--; } - if (!thisParameter && ts.isObjectLiteralMethod(declaration)) { - thisParameter = getContextualThisParameter(declaration); - } - var classType = declaration.kind === 148 ? + var classType = declaration.kind === 149 ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : getTypeParametersFromJSDocTemplate(declaration); - var returnType = getSignatureReturnTypeFromDeclaration(declaration, minArgumentCount, isJSConstructSignature, classType); - var typePredicate = declaration.type && declaration.type.kind === 154 ? + var returnType = getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType); + var typePredicate = declaration.type && declaration.type.kind === 155 ? createTypePredicateFromTypePredicateNode(declaration.type) : undefined; links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasLiteralTypes); } return links.resolvedSignature; } - function getSignatureReturnTypeFromDeclaration(declaration, minArgumentCount, isJSConstructSignature, classType) { + function getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType) { if (isJSConstructSignature) { return getTypeFromTypeNode(declaration.parameters[0].type); } @@ -22118,8 +23275,8 @@ var ts; return type; } } - if (declaration.kind === 149 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 150); + if (declaration.kind === 150 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 151); return getAnnotatedAccessorType(setter); } if (ts.nodeIsMissing(declaration.body)) { @@ -22133,19 +23290,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 156: case 157: - case 220: - case 147: - case 146: + case 158: + case 221: case 148: - case 151: + case 147: + case 149: case 152: case 153: - case 149: + case 154: case 150: - case 179: + case 151: case 180: + case 181: case 269: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; @@ -22226,7 +23383,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 148 || signature.declaration.kind === 152; + var isConstructor = signature.declaration.kind === 149 || signature.declaration.kind === 153; var type = createObjectType(2097152); type.members = emptySymbols; type.properties = emptyArray; @@ -22240,7 +23397,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 130 : 132; + var syntaxKind = kind === 1 ? 131 : 133; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -22267,7 +23424,7 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - return ts.getDeclarationOfKind(type.symbol, 141).constraint; + return ts.getDeclarationOfKind(type.symbol, 142).constraint; } function hasConstraintReferenceTo(type, target) { var checked; @@ -22300,7 +23457,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 141).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 142).parent); } function getTypeListId(types) { var result = ""; @@ -22400,11 +23557,11 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 155: + case 156: return node.typeName; case 267: return node.name; - case 194: + case 195: var expr = node.expression; if (ts.isEntityNameExpression(expr)) { return expr; @@ -22412,7 +23569,7 @@ var ts; } return undefined; } - function resolveTypeReferenceName(node, typeReferenceName) { + function resolveTypeReferenceName(typeReferenceName) { if (!typeReferenceName) { return unknownSymbol; } @@ -22440,11 +23597,11 @@ var ts; var type = void 0; if (node.kind === 267) { var typeReferenceName = getTypeReferenceName(node); - symbol = resolveTypeReferenceName(node, typeReferenceName); + symbol = resolveTypeReferenceName(typeReferenceName); type = getTypeReferenceType(node, symbol); } else { - var typeNameOrExpression = node.kind === 155 + var typeNameOrExpression = node.kind === 156 ? node.typeName : ts.isEntityNameExpression(node.expression) ? node.expression @@ -22473,9 +23630,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 221: case 222: - case 224: + case 223: + case 225: return declaration; } } @@ -22850,9 +24007,9 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 222)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 223)) { if (!(ts.getModifierFlags(container) & 32) && - (container.kind !== 148 || ts.isNodeDescendantOf(node, container.body))) { + (container.kind !== 149 || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -22871,25 +24028,25 @@ var ts; } function getTypeFromTypeNode(node, aliasSymbol, aliasTypeArguments) { switch (node.kind) { - case 117: + case 118: case 258: case 259: return anyType; - case 132: - return stringType; - case 130: - return numberType; - case 120: - return booleanType; case 133: + return stringType; + case 131: + return numberType; + case 121: + return booleanType; + case 134: return esSymbolType; - case 103: + case 104: return voidType; - case 135: + case 136: return undefinedType; - case 93: + case 94: return nullType; - case 127: + case 128: return neverType; case 283: return nullType; @@ -22897,33 +24054,33 @@ var ts; return undefinedType; case 285: return neverType; - case 165: - case 97: - return getTypeFromThisTypeNode(node); case 166: + case 98: + return getTypeFromThisTypeNode(node); + case 167: return getTypeFromLiteralTypeNode(node); case 282: return getTypeFromLiteralTypeNode(node.literal); - case 155: + case 156: case 267: return getTypeFromTypeReference(node); - case 154: + case 155: return booleanType; - case 194: + case 195: return getTypeFromTypeReference(node); - case 158: + case 159: return getTypeFromTypeQueryNode(node); - case 160: + case 161: case 260: return getTypeFromArrayTypeNode(node); - case 161: - return getTypeFromTupleTypeNode(node); case 162: + return getTypeFromTupleTypeNode(node); + case 163: case 261: return getTypeFromUnionTypeNode(node, aliasSymbol, aliasTypeArguments); - case 163: - return getTypeFromIntersectionTypeNode(node, aliasSymbol, aliasTypeArguments); case 164: + return getTypeFromIntersectionTypeNode(node, aliasSymbol, aliasTypeArguments); + case 165: case 263: case 264: case 271: @@ -22932,14 +24089,14 @@ var ts; return getTypeFromTypeNode(node.type); case 265: return getTypeFromTypeNode(node.literal); - case 156: case 157: - case 159: + case 158: + case 160: case 281: case 269: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node, aliasSymbol, aliasTypeArguments); - case 69: - case 139: + case 70: + case 140: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); case 262: @@ -23095,23 +24252,23 @@ var ts; var node = symbol.declarations[0].parent; while (node) { switch (node.kind) { - case 156: case 157: - case 220: - case 147: - case 146: + case 158: + case 221: case 148: - case 151: + case 147: + case 149: case 152: case 153: - case 149: + case 154: case 150: - case 179: + case 151: case 180: - case 221: - case 192: + case 181: case 222: + case 193: case 223: + case 224: var declaration = node; if (declaration.typeParameters) { for (var _i = 0, _a = declaration.typeParameters; _i < _a.length; _i++) { @@ -23121,14 +24278,14 @@ var ts; } } } - if (ts.isClassLike(node) || node.kind === 222) { + if (ts.isClassLike(node) || node.kind === 223) { var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; if (thisType && ts.contains(mappedTypes, thisType)) { return true; } } break; - case 225: + case 226: case 256: return false; } @@ -23163,35 +24320,43 @@ var ts; return info && createIndexInfo(instantiateType(info.type, mapper), info.isReadonly, info.declaration); } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 147 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 148 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 179: case 180: + case 181: return isContextSensitiveFunctionLikeDeclaration(node); - case 171: + case 172: return ts.forEach(node.properties, isContextSensitive); - case 170: + case 171: return ts.forEach(node.elements, isContextSensitive); - case 188: + case 189: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 187: - return node.operatorToken.kind === 52 && + case 188: + return node.operatorToken.kind === 53 && (isContextSensitive(node.left) || isContextSensitive(node.right)); case 253: return isContextSensitive(node.initializer); + case 148: case 147: - case 146: return isContextSensitiveFunctionLikeDeclaration(node); - case 178: + case 179: return isContextSensitive(node.expression); } return false; } function isContextSensitiveFunctionLikeDeclaration(node) { - var areAllParametersUntyped = !ts.forEach(node.parameters, function (p) { return p.type; }); - var isNullaryArrow = node.kind === 180 && !node.parameters.length; - return !node.typeParameters && areAllParametersUntyped && !isNullaryArrow; + if (node.typeParameters) { + return false; + } + if (ts.forEach(node.parameters, function (p) { return !p.type; })) { + return true; + } + if (node.kind === 181) { + return false; + } + var parameter = ts.firstOrUndefined(node.parameters); + return !(parameter && ts.parameterIsThisKeyword(parameter)); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func); @@ -23611,8 +24776,8 @@ var ts; } if (source.flags & 524288 && target.flags & 524288 || source.flags & 1048576 && target.flags & 1048576) { - if (result = eachTypeRelatedToSomeType(source, target, false)) { - if (result &= eachTypeRelatedToSomeType(target, source, false)) { + if (result = eachTypeRelatedToSomeType(source, target)) { + if (result &= eachTypeRelatedToSomeType(target, source)) { return result; } } @@ -23663,7 +24828,7 @@ var ts; } return false; } - function eachTypeRelatedToSomeType(source, target, reportErrors) { + function eachTypeRelatedToSomeType(source, target) { var result = -1; var sourceTypes = source.types; for (var _i = 0, sourceTypes_1 = sourceTypes; _i < sourceTypes_1.length; _i++) { @@ -24260,7 +25425,7 @@ var ts; type.flags & 64 ? numberType : type.flags & 128 ? booleanType : type.flags & 256 ? type.baseType : - type.flags & 524288 && !(type.flags & 16) ? getUnionType(ts.map(type.types, getBaseTypeOfLiteralType)) : + type.flags & 524288 && !(type.flags & 16) ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) : type; } function getWidenedLiteralType(type) { @@ -24268,7 +25433,7 @@ var ts; type.flags & 64 && type.flags & 16777216 ? numberType : type.flags & 128 ? booleanType : type.flags & 256 ? type.baseType : - type.flags & 524288 && !(type.flags & 16) ? getUnionType(ts.map(type.types, getWidenedLiteralType)) : + type.flags & 524288 && !(type.flags & 16) ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) : type; } function isTupleType(type) { @@ -24379,10 +25544,10 @@ var ts; return getWidenedTypeOfObjectLiteral(type); } if (type.flags & 524288) { - return getUnionType(ts.map(type.types, getWidenedConstituentType)); + return getUnionType(ts.sameMap(type.types, getWidenedConstituentType)); } if (isArrayType(type) || isTupleType(type)) { - return createTypeReference(type.target, ts.map(type.typeArguments, getWidenedType)); + return createTypeReference(type.target, ts.sameMap(type.typeArguments, getWidenedType)); } } return type; @@ -24423,25 +25588,25 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { + case 146: case 145: - case 144: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 142: + case 143: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 169: + case 170: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 220: + case 221: + case 148: case 147: - case 146: - case 149: case 150: - case 179: + case 151: case 180: + case 181: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -24486,7 +25651,7 @@ var ts; signature: signature, inferUnionTypes: inferUnionTypes, inferences: inferences, - inferredTypes: new Array(signature.typeParameters.length) + inferredTypes: new Array(signature.typeParameters.length), }; } function createTypeInferencesObject() { @@ -24494,7 +25659,7 @@ var ts; primary: undefined, secondary: undefined, topLevel: true, - isFixed: false + isFixed: false, }; } function couldContainTypeParameters(type) { @@ -24735,7 +25900,7 @@ var ts; var widenLiteralTypes = context.inferences[index].topLevel && !hasPrimitiveConstraint(signature.typeParameters[index]) && (context.inferences[index].isFixed || !isTypeParameterAtTopLevel(getReturnTypeOfSignature(signature), signature.typeParameters[index])); - var baseInferences = widenLiteralTypes ? ts.map(inferences, getWidenedLiteralType) : inferences; + var baseInferences = widenLiteralTypes ? ts.sameMap(inferences, getWidenedLiteralType) : inferences; var unionOrSuperType = context.inferUnionTypes ? getUnionType(baseInferences, true) : getCommonSupertype(baseInferences); inferredType = unionOrSuperType ? getWidenedType(unionOrSuperType) : unknownType; inferenceSucceeded = !!unionOrSuperType; @@ -24776,10 +25941,10 @@ var ts; function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 158: + case 159: return true; - case 69: - case 139: + case 70: + case 140: node = node.parent; continue; default: @@ -24789,14 +25954,14 @@ var ts; ts.Debug.fail("should not get here"); } function getFlowCacheKey(node) { - if (node.kind === 69) { + if (node.kind === 70) { var symbol = getResolvedSymbol(node); return symbol !== unknownSymbol ? "" + getSymbolId(symbol) : undefined; } - if (node.kind === 97) { + if (node.kind === 98) { return "0"; } - if (node.kind === 172) { + if (node.kind === 173) { var key = getFlowCacheKey(node.expression); return key && key + "." + node.name.text; } @@ -24804,31 +25969,31 @@ var ts; } function getLeftmostIdentifierOrThis(node) { switch (node.kind) { - case 69: - case 97: + case 70: + case 98: return node; - case 172: + case 173: return getLeftmostIdentifierOrThis(node.expression); } return undefined; } function isMatchingReference(source, target) { switch (source.kind) { - case 69: - return target.kind === 69 && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 218 || target.kind === 169) && + case 70: + return target.kind === 70 && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 219 || target.kind === 170) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 97: - return target.kind === 97; - case 172: - return target.kind === 172 && + case 98: + return target.kind === 98; + case 173: + return target.kind === 173 && source.name.text === target.name.text && isMatchingReference(source.expression, target.expression); } return false; } function containsMatchingReference(source, target) { - while (source.kind === 172) { + while (source.kind === 173) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -24837,15 +26002,15 @@ var ts; return false; } function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 172 && + return target.kind === 173 && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.text); } function getDeclaredTypeOfReference(expr) { - if (expr.kind === 69) { + if (expr.kind === 70) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 172) { + if (expr.kind === 173) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.text); } @@ -24875,7 +26040,7 @@ var ts; } } } - if (callExpression.expression.kind === 172 && + if (callExpression.expression.kind === 173 && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -25001,7 +26166,7 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, undefined, false) || unknownType); } function getAssignedTypeOfBinaryExpression(node) { - return node.parent.kind === 170 || node.parent.kind === 253 ? + return node.parent.kind === 171 || node.parent.kind === 253 ? getTypeWithDefault(getAssignedType(node), node.right) : checkExpression(node.right); } @@ -25020,17 +26185,17 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 207: - return stringType; case 208: + return stringType; + case 209: return checkRightHandSideOfForOf(parent.expression) || unknownType; - case 187: + case 188: return getAssignedTypeOfBinaryExpression(parent); - case 181: + case 182: return undefinedType; - case 170: + case 171: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 191: + case 192: return getAssignedTypeOfSpreadElement(parent); case 253: return getAssignedTypeOfPropertyAssignment(parent); @@ -25042,7 +26207,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 167 ? + var type = pattern.kind === 168 ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, ts.indexOf(pattern.elements, node)) : @@ -25057,38 +26222,51 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 207) { + if (node.parent.parent.kind === 208) { return stringType; } - if (node.parent.parent.kind === 208) { + if (node.parent.parent.kind === 209) { return checkRightHandSideOfForOf(node.parent.parent.expression) || unknownType; } return unknownType; } function getInitialType(node) { - return node.kind === 218 ? + return node.kind === 219 ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 218 || node.kind === 169 ? + return node.kind === 219 || node.kind === 170 ? getInitialType(node) : getAssignedType(node); } + function isEmptyArrayAssignment(node) { + return node.kind === 219 && node.initializer && + isEmptyArrayLiteral(node.initializer) || + node.kind !== 170 && node.parent.kind === 188 && + isEmptyArrayLiteral(node.parent.right); + } function getReferenceCandidate(node) { switch (node.kind) { - case 178: + case 179: return getReferenceCandidate(node.expression); - case 187: + case 188: switch (node.operatorToken.kind) { - case 56: + case 57: return getReferenceCandidate(node.left); - case 24: + case 25: return getReferenceCandidate(node.right); } } return node; } + function getReferenceRoot(node) { + var parent = node.parent; + return parent.kind === 179 || + parent.kind === 188 && parent.operatorToken.kind === 57 && parent.left === node || + parent.kind === 188 && parent.operatorToken.kind === 25 && parent.right === node ? + getReferenceRoot(parent) : node; + } function getTypeOfSwitchClause(clause) { if (clause.kind === 249) { var caseType = getRegularTypeOfLiteralType(checkExpression(clause.expression)); @@ -25159,24 +26337,88 @@ var ts; function createFlowType(type, incomplete) { return incomplete ? { flags: 0, type: type } : type; } + function createEvolvingArrayType(elementType) { + var result = createObjectType(2097152); + result.elementType = elementType; + return result; + } + function getEvolvingArrayType(elementType) { + return evolvingArrayTypes[elementType.id] || (evolvingArrayTypes[elementType.id] = createEvolvingArrayType(elementType)); + } + function addEvolvingArrayElementType(evolvingArrayType, node) { + var elementType = getBaseTypeOfLiteralType(checkExpression(node)); + return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType])); + } + function isEvolvingArrayType(type) { + return !!(type.flags & 2097152 && type.elementType); + } + function createFinalArrayType(elementType) { + return elementType.flags & 8192 ? + autoArrayType : + createArrayType(elementType.flags & 524288 ? + getUnionType(elementType.types, true) : + elementType); + } + function getFinalArrayType(evolvingArrayType) { + return evolvingArrayType.finalArrayType || (evolvingArrayType.finalArrayType = createFinalArrayType(evolvingArrayType.elementType)); + } + function finalizeEvolvingArrayType(type) { + return isEvolvingArrayType(type) ? getFinalArrayType(type) : type; + } + function getElementTypeOfEvolvingArrayType(type) { + return isEvolvingArrayType(type) ? type.elementType : neverType; + } + function isEvolvingArrayTypeList(types) { + var hasEvolvingArrayType = false; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; + if (!(t.flags & 8192)) { + if (!isEvolvingArrayType(t)) { + return false; + } + hasEvolvingArrayType = true; + } + } + return hasEvolvingArrayType; + } + function getUnionOrEvolvingArrayType(types, subtypeReduction) { + return isEvolvingArrayTypeList(types) ? + getEvolvingArrayType(getUnionType(ts.map(types, getElementTypeOfEvolvingArrayType))) : + getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction); + } + function isEvolvingArrayOperationTarget(node) { + var root = getReferenceRoot(node); + var parent = root.parent; + var isLengthPushOrUnshift = parent.kind === 173 && (parent.name.text === "length" || + parent.parent.kind === 175 && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 174 && + parent.expression === root && + parent.parent.kind === 188 && + parent.parent.operatorToken.kind === 57 && + parent.parent.left === parent && + !ts.isAssignmentTarget(parent.parent) && + isTypeAnyOrAllConstituentTypesHaveKind(checkExpression(parent.argumentExpression), 340 | 2048); + return isLengthPushOrUnshift || isElementAssignment; + } function getFlowTypeOfReference(reference, declaredType, assumeInitialized, flowContainer) { var key; if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 4178943)) { return declaredType; } var initialType = assumeInitialized ? declaredType : - declaredType === autoType ? undefinedType : + declaredType === autoType || declaredType === autoArrayType ? undefinedType : includeFalsyTypes(declaredType, 2048); var visitedFlowStart = visitedFlowCount; - var result = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); + var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); visitedFlowCount = visitedFlowStart; - if (reference.parent.kind === 196 && getTypeWithFacts(result, 524288).flags & 8192) { + var resultType = isEvolvingArrayType(evolvedType) && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); + if (reference.parent.kind === 197 && getTypeWithFacts(resultType, 524288).flags & 8192) { return declaredType; } - return result; + return resultType; function getTypeAtFlowNode(flow) { while (true) { - if (flow.flags & 512) { + if (flow.flags & 1024) { for (var i = visitedFlowStart; i < visitedFlowCount; i++) { if (visitedFlowNodes[i] === flow) { return visitedFlowTypes[i]; @@ -25206,18 +26448,25 @@ var ts; getTypeAtFlowBranchLabel(flow) : getTypeAtFlowLoopLabel(flow); } + else if (flow.flags & 256) { + type = getTypeAtFlowArrayMutation(flow); + if (!type) { + flow = flow.antecedent; + continue; + } + } else if (flow.flags & 2) { var container = flow.container; - if (container && container !== flowContainer && reference.kind !== 172) { + if (container && container !== flowContainer && reference.kind !== 173) { flow = container.flowNode; continue; } type = initialType; } else { - type = declaredType; + type = convertAutoToAny(declaredType); } - if (flow.flags & 512) { + if (flow.flags & 1024) { visitedFlowNodes[visitedFlowCount] = flow; visitedFlowTypes[visitedFlowCount] = type; visitedFlowCount++; @@ -25228,30 +26477,70 @@ var ts; function getTypeAtFlowAssignment(flow) { var node = flow.node; if (isMatchingReference(reference, node)) { - if (node.parent.kind === 185 || node.parent.kind === 186) { + if (node.parent.kind === 186 || node.parent.kind === 187) { var flowType = getTypeAtFlowNode(flow.antecedent); return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType)); } - return declaredType === autoType ? getBaseTypeOfLiteralType(getInitialOrAssignedType(node)) : - declaredType.flags & 524288 ? getAssignmentReducedType(declaredType, getInitialOrAssignedType(node)) : - declaredType; + if (declaredType === autoType || declaredType === autoArrayType) { + if (isEmptyArrayAssignment(node)) { + return getEvolvingArrayType(neverType); + } + var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(node)); + return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; + } + if (declaredType.flags & 524288) { + return getAssignmentReducedType(declaredType, getInitialOrAssignedType(node)); + } + return declaredType; } if (containsMatchingReference(reference, node)) { return declaredType; } return undefined; } + function getTypeAtFlowArrayMutation(flow) { + var node = flow.node; + var expr = node.kind === 175 ? + node.expression.expression : + node.left.expression; + if (isMatchingReference(reference, getReferenceCandidate(expr))) { + var flowType = getTypeAtFlowNode(flow.antecedent); + var type = getTypeFromFlowType(flowType); + if (isEvolvingArrayType(type)) { + var evolvedType_1 = type; + if (node.kind === 175) { + for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { + var arg = _a[_i]; + evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); + } + } + else { + var indexType = checkExpression(node.left.argumentExpression); + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 340 | 2048)) { + evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); + } + } + return evolvedType_1 === type ? flowType : createFlowType(evolvedType_1, isIncomplete(flowType)); + } + return flowType; + } + return undefined; + } function getTypeAtFlowCondition(flow) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (!(type.flags & 8192)) { - var assumeTrue = (flow.flags & 32) !== 0; - type = narrowType(type, flow.expression, assumeTrue); - if (type.flags & 8192 && isIncomplete(flowType)) { - type = silentNeverType; - } + if (type.flags & 8192) { + return flowType; } - return createFlowType(type, isIncomplete(flowType)); + var assumeTrue = (flow.flags & 32) !== 0; + var nonEvolvingType = finalizeEvolvingArrayType(type); + var narrowedType = narrowType(nonEvolvingType, flow.expression, assumeTrue); + if (narrowedType === nonEvolvingType) { + return flowType; + } + var incomplete = isIncomplete(flowType); + var resultType = incomplete && narrowedType.flags & 8192 ? silentNeverType : narrowedType; + return createFlowType(resultType, incomplete); } function getTypeAtSwitchClause(flow) { var flowType = getTypeAtFlowNode(flow.antecedent); @@ -25286,7 +26575,7 @@ var ts; seenIncomplete = true; } } - return createFlowType(getUnionType(antecedentTypes, subtypeReduction), seenIncomplete); + return createFlowType(getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction), seenIncomplete); } function getTypeAtFlowLoopLabel(flow) { var id = getFlowNodeId(flow); @@ -25298,8 +26587,8 @@ var ts; return cache[key]; } for (var i = flowLoopStart; i < flowLoopCount; i++) { - if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key) { - return createFlowType(getUnionType(flowLoopTypes[i]), true); + if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key && flowLoopTypes[i].length) { + return createFlowType(getUnionOrEvolvingArrayType(flowLoopTypes[i], false), true); } } var antecedentTypes = []; @@ -25330,14 +26619,14 @@ var ts; break; } } - var result = getUnionType(antecedentTypes, subtypeReduction); + var result = getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction); if (isIncomplete(firstAntecedentType)) { return createFlowType(result, true); } return cache[key] = result; } function isMatchingReferenceDiscriminant(expr) { - return expr.kind === 172 && + return expr.kind === 173 && declaredType.flags & 524288 && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(declaredType, expr.name.text); @@ -25362,19 +26651,19 @@ var ts; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 56: + case 57: return narrowTypeByTruthiness(type, expr.left, assumeTrue); - case 30: case 31: case 32: case 33: + case 34: var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 182 && right_1.kind === 9) { + if (left_1.kind === 183 && right_1.kind === 9) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 182 && left_1.kind === 9) { + if (right_1.kind === 183 && left_1.kind === 9) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -25393,9 +26682,9 @@ var ts; return declaredType; } break; - case 91: + case 92: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 24: + case 25: return narrowType(type, expr.right, assumeTrue); } return type; @@ -25404,7 +26693,7 @@ var ts; if (type.flags & 1) { return type; } - if (operator === 31 || operator === 33) { + if (operator === 32 || operator === 34) { assumeTrue = !assumeTrue; } var valueType = checkExpression(value); @@ -25412,10 +26701,10 @@ var ts; if (!strictNullChecks) { return type; } - var doubleEquals = operator === 30 || operator === 31; + var doubleEquals = operator === 31 || operator === 32; var facts = doubleEquals ? assumeTrue ? 65536 : 524288 : - value.kind === 93 ? + value.kind === 94 ? assumeTrue ? 32768 : 262144 : assumeTrue ? 16384 : 131072; return getTypeWithFacts(type, facts); @@ -25441,7 +26730,7 @@ var ts; } return type; } - if (operator === 31 || operator === 33) { + if (operator === 32 || operator === 34) { assumeTrue = !assumeTrue; } if (assumeTrue && !(type.flags & 524288)) { @@ -25552,7 +26841,7 @@ var ts; } else { var invokedExpression = skipParenthesizedNodes(callExpression.expression); - if (invokedExpression.kind === 173 || invokedExpression.kind === 172) { + if (invokedExpression.kind === 174 || invokedExpression.kind === 173) { var accessExpression = invokedExpression; var possibleReference = skipParenthesizedNodes(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -25567,18 +26856,18 @@ var ts; } function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 69: - case 97: - case 172: + case 70: + case 98: + case 173: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 174: + case 175: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 178: + case 179: return narrowType(type, expr.expression, assumeTrue); - case 187: + case 188: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 185: - if (expr.operator === 49) { + case 186: + if (expr.operator === 50) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -25587,7 +26876,7 @@ var ts; } } function getTypeOfSymbolAtLocation(symbol, location) { - if (location.kind === 69) { + if (location.kind === 70) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } @@ -25601,7 +26890,7 @@ var ts; return getTypeOfSymbol(symbol); } function skipParenthesizedNodes(expression) { - while (expression.kind === 178) { + while (expression.kind === 179) { expression = expression.expression; } return expression; @@ -25610,9 +26899,9 @@ var ts; while (true) { node = node.parent; if (ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 226 || + node.kind === 227 || node.kind === 256 || - node.kind === 145) { + node.kind === 146) { return node; } } @@ -25640,10 +26929,10 @@ var ts; } } function markParameterAssignments(node) { - if (node.kind === 69) { + if (node.kind === 70) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 142) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 143) { symbol.isAssigned = true; } } @@ -25652,12 +26941,15 @@ var ts; ts.forEachChild(node, markParameterAssignments); } } + function isConstVariable(symbol) { + return symbol.flags & 3 && (getDeclarationNodeFlagsFromSymbol(symbol) & 2) !== 0 && getTypeOfSymbol(symbol) !== autoArrayType; + } function checkIdentifier(node) { var symbol = getResolvedSymbol(node); if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2) { - if (container.kind === 180) { + if (container.kind === 181) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } else if (ts.hasModifier(container, 256)) { @@ -25675,7 +26967,7 @@ var ts; if (localOrExportSymbol.flags & 32) { var declaration_1 = localOrExportSymbol.valueDeclaration; if (languageVersion === 2 - && declaration_1.kind === 221 + && declaration_1.kind === 222 && ts.nodeIsDecorated(declaration_1)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -25687,11 +26979,11 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration_1.kind === 192) { + else if (declaration_1.kind === 193) { var container = ts.getThisContainer(node, false); while (container !== undefined) { if (container.parent === declaration_1) { - if (container.kind === 145 && ts.hasModifier(container, 32)) { + if (container.kind === 146 && ts.hasModifier(container, 32)) { getNodeLinks(declaration_1).flags |= 8388608; getNodeLinks(node).flags |= 16777216; } @@ -25709,28 +27001,26 @@ var ts; if (!(localOrExportSymbol.flags & 3) || ts.isAssignmentTarget(node) || !declaration) { return type; } - var isParameter = ts.getRootDeclaration(declaration).kind === 142; + var isParameter = ts.getRootDeclaration(declaration).kind === 143; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; - while (flowContainer !== declarationContainer && - (flowContainer.kind === 179 || - flowContainer.kind === 180 || - ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && - (isReadonlySymbol(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { + while (flowContainer !== declarationContainer && (flowContainer.kind === 180 || + flowContainer.kind === 181 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } var assumeInitialized = isParameter || isOuterVariable || - type !== autoType && (!strictNullChecks || (type.flags & 1) !== 0) || + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1) !== 0) || ts.isInAmbientContext(declaration); var flowType = getFlowTypeOfReference(node, type, assumeInitialized, flowContainer); - if (type === autoType) { - if (flowType === autoType) { + if (type === autoType || type === autoArrayType) { + if (flowType === autoType || flowType === autoArrayType) { if (compilerOptions.noImplicitAny) { - error(declaration.name, ts.Diagnostics.Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol)); - error(node, ts.Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(anyType)); + error(declaration.name, ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol), typeToString(flowType)); + error(node, ts.Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(flowType)); } - return anyType; + return convertAutoToAny(flowType); } } else if (!assumeInitialized && !(getFalsyFlags(type) & 2048) && getFalsyFlags(flowType) & 2048) { @@ -25770,8 +27060,8 @@ var ts; if (usedInFunction) { getNodeLinks(current).flags |= 65536; } - if (container.kind === 206 && - ts.getAncestor(symbol.valueDeclaration, 219).parent === container && + if (container.kind === 207 && + ts.getAncestor(symbol.valueDeclaration, 220).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152; } @@ -25783,16 +27073,16 @@ var ts; } function isAssignedInBodyOfForStatement(node, container) { var current = node; - while (current.parent.kind === 178) { + while (current.parent.kind === 179) { current = current.parent; } var isAssigned = false; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 185 || current.parent.kind === 186)) { + else if ((current.parent.kind === 186 || current.parent.kind === 187)) { var expr = current.parent; - isAssigned = expr.operator === 41 || expr.operator === 42; + isAssigned = expr.operator === 42 || expr.operator === 43; } if (!isAssigned) { return false; @@ -25809,7 +27099,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2; - if (container.kind === 145 || container.kind === 148) { + if (container.kind === 146 || container.kind === 149) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4; } @@ -25843,7 +27133,7 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 148) { + if (container.kind === 149) { var containingClassDecl = container.parent; var baseTypeNode = ts.getClassExtendsHeritageClauseElement(containingClassDecl); if (baseTypeNode && !classDeclarationExtendsNull(containingClassDecl)) { @@ -25853,29 +27143,29 @@ var ts; } } } - if (container.kind === 180) { + if (container.kind === 181) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 225: + case 226: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 224: + case 225: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 148: + case 149: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; + case 146: case 145: - case 144: if (ts.getModifierFlags(container) & 32) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 140: + case 141: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -25884,7 +27174,7 @@ var ts; } if (ts.isFunctionLike(container) && (!isInParameterInitializerBeforeContainingFunction(node) || ts.getThisParameter(container))) { - if (container.kind === 179 && + if (container.kind === 180 && ts.isInJavaScriptFile(container.parent) && ts.getSpecialPropertyAssignmentKind(container.parent) === 3) { var className = container.parent @@ -25896,7 +27186,7 @@ var ts; return getInferredClassType(classSymbol); } } - var thisType = getThisTypeOfDeclaration(container); + var thisType = getThisTypeOfDeclaration(container) || getContextualThisParameterType(container); if (thisType) { return thisType; } @@ -25928,18 +27218,18 @@ var ts; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 142) { + if (n.kind === 143) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 174 && node.parent.expression === node; + var isCallExpression = node.parent.kind === 175 && node.parent.expression === node; var container = ts.getSuperContainer(node, true); var needToCaptureLexicalThis = false; if (!isCallExpression) { - while (container && container.kind === 180) { + while (container && container.kind === 181) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } @@ -25948,16 +27238,16 @@ var ts; var nodeCheckFlag = 0; if (!canUseSuperExpression) { var current = node; - while (current && current !== container && current.kind !== 140) { + while (current && current !== container && current.kind !== 141) { current = current.parent; } - if (current && current.kind === 140) { + if (current && current.kind === 141) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); } - else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 171)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 172)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -25972,7 +27262,7 @@ var ts; nodeCheckFlag = 256; } getNodeLinks(node).flags |= nodeCheckFlag; - if (container.kind === 147 && ts.getModifierFlags(container) & 256) { + if (container.kind === 148 && ts.getModifierFlags(container) & 256) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096; } @@ -25983,7 +27273,7 @@ var ts; if (needToCaptureLexicalThis) { captureLexicalThis(node.parent, container); } - if (container.parent.kind === 171) { + if (container.parent.kind === 172) { if (languageVersion < 2) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return unknownType; @@ -26001,7 +27291,7 @@ var ts; } return unknownType; } - if (container.kind === 148 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 149 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return unknownType; } @@ -26013,35 +27303,38 @@ var ts; return false; } if (isCallExpression) { - return container.kind === 148; + return container.kind === 149; } else { - if (ts.isClassLike(container.parent) || container.parent.kind === 171) { + if (ts.isClassLike(container.parent) || container.parent.kind === 172) { if (ts.getModifierFlags(container) & 32) { - return container.kind === 147 || - container.kind === 146 || - container.kind === 149 || - container.kind === 150; + return container.kind === 148 || + container.kind === 147 || + container.kind === 150 || + container.kind === 151; } else { - return container.kind === 147 || - container.kind === 146 || - container.kind === 149 || + return container.kind === 148 || + container.kind === 147 || container.kind === 150 || + container.kind === 151 || + container.kind === 146 || container.kind === 145 || - container.kind === 144 || - container.kind === 148; + container.kind === 149; } } } return false; } } - function getContextualThisParameter(func) { - if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 180) { + function getContextualThisParameterType(func) { + if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 181) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { - return contextualSignature.thisParameter; + var thisParameter = contextualSignature.thisParameter; + if (thisParameter) { + return getTypeOfSymbol(thisParameter); + } } } return undefined; @@ -26091,7 +27384,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 142) { + if (declaration.kind === 143) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -26143,7 +27436,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 142 && node.parent.initializer === node) { + if (node.parent.kind === 143 && node.parent.initializer === node) { return true; } node = node.parent; @@ -26152,8 +27445,8 @@ var ts; } function getContextualReturnType(functionDecl) { if (functionDecl.type || - functionDecl.kind === 148 || - functionDecl.kind === 149 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 150))) { + functionDecl.kind === 149 || + functionDecl.kind === 150 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 151))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); @@ -26172,7 +27465,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 176) { + if (template.parent.kind === 177) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -26180,7 +27473,7 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operatorToken.kind; - if (operator >= 56 && operator <= 68) { + if (operator >= 57 && operator <= 69) { if (ts.getSpecialPropertyAssignmentKind(binaryExpression) !== 0) { return undefined; } @@ -26188,14 +27481,14 @@ var ts; return checkExpression(binaryExpression.left); } } - else if (operator === 52) { + else if (operator === 53) { var type = getContextualType(binaryExpression); if (!type && node === binaryExpression.right) { type = checkExpression(binaryExpression.left); } return type; } - else if (operator === 51 || operator === 24) { + else if (operator === 52 || operator === 25) { if (node === binaryExpression.right) { return getContextualType(binaryExpression); } @@ -26209,8 +27502,8 @@ var ts; var types = type.types; var mappedType; var mappedTypes; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var current = types_12[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var current = types_13[_i]; var t = mapper(current); if (t) { if (!mappedType) { @@ -26304,36 +27597,36 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 218: - case 142: + case 219: + case 143: + case 146: case 145: - case 144: - case 169: + case 170: return getContextualTypeForInitializerExpression(node); - case 180: - case 211: + case 181: + case 212: return getContextualTypeForReturnExpression(node); - case 190: + case 191: return getContextualTypeForYieldOperand(parent); - case 174: case 175: + case 176: return getContextualTypeForArgument(parent, node); - case 177: - case 195: + case 178: + case 196: return getTypeFromTypeNode(parent.type); - case 187: + case 188: return getContextualTypeForBinaryOperand(node); case 253: case 254: return getContextualTypeForObjectLiteralElement(parent); - case 170: + case 171: return getContextualTypeForElementExpression(node); - case 188: + case 189: return getContextualTypeForConditionalOperand(node); - case 197: - ts.Debug.assert(parent.parent.kind === 189); + case 198: + ts.Debug.assert(parent.parent.kind === 190); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 178: + case 179: return getContextualType(parent); case 248: return getContextualType(parent); @@ -26353,7 +27646,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 179 || node.kind === 180; + return node.kind === 180 || node.kind === 181; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -26366,7 +27659,7 @@ var ts; getApparentTypeOfContextualType(node); } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 147 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 148 || ts.isObjectLiteralMethod(node)); var type = getContextualTypeForFunctionLikeDeclaration(node); if (!type) { return undefined; @@ -26376,8 +27669,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var current = types_13[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var current = types_14[_i]; var signature = getNonGenericSignature(current); if (signature) { if (!signatureList) { @@ -26407,8 +27700,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false); } function hasDefaultValue(node) { - return (node.kind === 169 && !!node.initializer) || - (node.kind === 187 && node.operatorToken.kind === 56); + return (node.kind === 170 && !!node.initializer) || + (node.kind === 188 && node.operatorToken.kind === 57); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -26417,7 +27710,7 @@ var ts; var inDestructuringPattern = ts.isAssignmentTarget(node); for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { var e = elements_1[_i]; - if (inDestructuringPattern && e.kind === 191) { + if (inDestructuringPattern && e.kind === 192) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); @@ -26429,7 +27722,7 @@ var ts; var type = checkExpressionForMutableLocation(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 191; + hasSpreadElement = hasSpreadElement || e.kind === 192; } if (!hasSpreadElement) { if (inDestructuringPattern && elementTypes.length) { @@ -26440,7 +27733,7 @@ var ts; var contextualType = getApparentTypeOfContextualType(node); if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { var pattern = contextualType.pattern; - if (pattern && (pattern.kind === 168 || pattern.kind === 170)) { + if (pattern && (pattern.kind === 169 || pattern.kind === 171)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -26448,7 +27741,7 @@ var ts; elementTypes.push(contextualType.typeArguments[i]); } else { - if (patternElement.kind !== 193) { + if (patternElement.kind !== 194) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -26465,7 +27758,7 @@ var ts; strictNullChecks ? neverType : undefinedWideningType); } function isNumericName(name) { - return name.kind === 140 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 141 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 340); @@ -26509,7 +27802,7 @@ var ts; var propertiesArray = []; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 167 || contextualType.pattern.kind === 171); + (contextualType.pattern.kind === 168 || contextualType.pattern.kind === 172); var typeFlags = 0; var patternWithComputedProperties = false; var hasComputedStringProperty = false; @@ -26524,7 +27817,7 @@ var ts; if (memberDecl.kind === 253) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 147) { + else if (memberDecl.kind === 148) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { @@ -26563,7 +27856,7 @@ var ts; member = prop; } else { - ts.Debug.assert(memberDecl.kind === 149 || memberDecl.kind === 150); + ts.Debug.assert(memberDecl.kind === 150 || memberDecl.kind === 151); checkAccessorDeclaration(memberDecl); } if (ts.hasDynamicName(memberDecl)) { @@ -26622,10 +27915,10 @@ var ts; case 248: checkJsxExpression(child); break; - case 241: + case 242: checkJsxElement(child); break; - case 242: + case 243: checkJsxSelfClosingElement(child); break; } @@ -26636,7 +27929,7 @@ var ts; return name.indexOf("-") < 0; } function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 172 || tagName.kind === 97) { + if (tagName.kind === 173 || tagName.kind === 98) { return false; } else { @@ -26739,7 +28032,7 @@ var ts; return unknownType; } } - return getUnionType(signatures.map(getReturnTypeOfSignature), true); + return getUnionType(ts.map(signatures, getReturnTypeOfSignature), true); } function getJsxElementPropertiesName() { var jsxNamespace = getGlobalSymbol(JsxNames.JSX, 1920, undefined); @@ -26768,7 +28061,7 @@ var ts; } if (elemType.flags & 524288) { var types = elemType.types; - return getUnionType(types.map(function (type) { + return getUnionType(ts.map(types, function (type) { return getResolvedJsxType(node, type, elemClassType); }), true); } @@ -26944,7 +28237,7 @@ var ts; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 145; + return s.valueDeclaration ? s.valueDeclaration.kind : 146; } function getDeclarationModifierFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedModifierFlags(s.valueDeclaration) : s.flags & 134217728 ? 4 | 32 : 0; @@ -26955,11 +28248,11 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationModifierFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(getParentOfSymbol(prop)); - var errorNode = node.kind === 172 || node.kind === 218 ? + var errorNode = node.kind === 173 || node.kind === 219 ? node.name : node.right; - if (left.kind === 95) { - if (languageVersion < 2 && getDeclarationKindFromSymbol(prop) !== 147) { + if (left.kind === 96) { + if (languageVersion < 2 && getDeclarationKindFromSymbol(prop) !== 148) { error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); return false; } @@ -26979,7 +28272,7 @@ var ts; } return true; } - if (left.kind === 95) { + if (left.kind === 96) { return true; } var enclosingClass = forEachEnclosingClass(node, function (enclosingDeclaration) { @@ -27053,7 +28346,7 @@ var ts; checkClassPropertyAccess(node, left, apparentType, prop); } var propType = getTypeOfSymbol(prop); - if (node.kind !== 172 || ts.isAssignmentTarget(node) || + if (node.kind !== 173 || ts.isAssignmentTarget(node) || !(prop.flags & (3 | 4 | 98304)) && !(prop.flags & 8192 && propType.flags & 524288)) { return propType; @@ -27075,7 +28368,7 @@ var ts; } } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 172 + var left = node.kind === 173 ? node.expression : node.left; var type = checkExpression(left); @@ -27089,13 +28382,13 @@ var ts; } function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 219) { + if (initializer.kind === 220) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 69) { + else if (initializer.kind === 70) { return getResolvedSymbol(initializer); } return undefined; @@ -27105,13 +28398,13 @@ var ts; } function isForInVariableForNumericPropertyNames(expr) { var e = skipParenthesizedNodes(expr); - if (e.kind === 69) { + if (e.kind === 70) { var symbol = getResolvedSymbol(e); if (symbol.flags & 3) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 207 && + if (node.kind === 208 && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(checkExpression(node.expression))) { @@ -27127,7 +28420,7 @@ var ts; function checkIndexedAccess(node) { if (!node.argumentExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 175 && node.parent.expression === node) { + if (node.parent.kind === 176 && 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); @@ -27191,7 +28484,7 @@ var ts; if (indexArgumentExpression.kind === 9 || indexArgumentExpression.kind === 8) { return indexArgumentExpression.text; } - if (indexArgumentExpression.kind === 173 || indexArgumentExpression.kind === 172) { + if (indexArgumentExpression.kind === 174 || indexArgumentExpression.kind === 173) { var value = getConstantValue(indexArgumentExpression); if (value !== undefined) { return value.toString(); @@ -27234,10 +28527,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 176) { + if (node.kind === 177) { checkExpression(node.template); } - else if (node.kind !== 143) { + else if (node.kind !== 144) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -27288,7 +28581,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 191) { + if (arg && arg.kind === 192) { return i; } } @@ -27301,11 +28594,11 @@ var ts; var callIsIncomplete; var isDecorator; var spreadArgIndex = -1; - if (node.kind === 176) { + if (node.kind === 177) { var tagExpression = node; argCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 189) { + if (tagExpression.template.kind === 190) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -27313,11 +28606,11 @@ var ts; } else { var templateLiteral = tagExpression.template; - ts.Debug.assert(templateLiteral.kind === 11); + ts.Debug.assert(templateLiteral.kind === 12); callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 143) { + else if (node.kind === 144) { isDecorator = true; typeArguments = undefined; argCount = getEffectiveArgumentCount(node, undefined, signature); @@ -27325,7 +28618,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 175); + ts.Debug.assert(callExpression.kind === 176); return signature.minArgumentCount === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -27384,9 +28677,9 @@ 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 !== 193) { + if (arg === undefined || arg.kind !== 194) { var paramType = getTypeAtPosition(signature, i); - var argType = getEffectiveArgumentType(node, i, arg); + var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { var mapper = excludeArgument && excludeArgument[i] !== undefined ? identityMapper : inferenceMapper; argType = checkExpressionWithContextualType(arg, paramType, mapper); @@ -27431,7 +28724,7 @@ var ts; } function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 175) { + if (thisType && thisType !== voidType && node.kind !== 176) { var thisArgumentNode = getThisArgumentOfCall(node); var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; var errorNode = reportErrors ? (thisArgumentNode || node) : undefined; @@ -27444,9 +28737,9 @@ 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 !== 193) { + if (arg === undefined || arg.kind !== 194) { var paramType = getTypeAtPosition(signature, i); - var argType = getEffectiveArgumentType(node, i, arg); + var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { argType = checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); } @@ -27459,28 +28752,28 @@ var ts; return true; } function getThisArgumentOfCall(node) { - if (node.kind === 174) { + if (node.kind === 175) { var callee = node.expression; - if (callee.kind === 172) { + if (callee.kind === 173) { return callee.expression; } - else if (callee.kind === 173) { + else if (callee.kind === 174) { return callee.expression; } } } function getEffectiveCallArguments(node) { var args; - if (node.kind === 176) { + if (node.kind === 177) { var template = node.template; args = [undefined]; - if (template.kind === 189) { + if (template.kind === 190) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 143) { + else if (node.kind === 144) { return undefined; } else { @@ -27489,21 +28782,21 @@ var ts; return args; } function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 143) { + if (node.kind === 144) { switch (node.parent.kind) { - case 221: - case 192: + case 222: + case 193: return 1; - case 145: + case 146: return 2; - case 147: - case 149: + case 148: case 150: + case 151: if (languageVersion === 0) { return 2; } return signature.parameters.length >= 3 ? 3 : 2; - case 142: + case 143: return 3; } } @@ -27512,48 +28805,48 @@ var ts; } } function getEffectiveDecoratorFirstArgumentType(node) { - if (node.kind === 221) { + if (node.kind === 222) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } - if (node.kind === 142) { + if (node.kind === 143) { node = node.parent; - if (node.kind === 148) { + if (node.kind === 149) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } } - if (node.kind === 145 || - node.kind === 147 || - node.kind === 149 || - node.kind === 150) { + if (node.kind === 146 || + node.kind === 148 || + node.kind === 150 || + node.kind === 151) { return getParentTypeOfClassElement(node); } ts.Debug.fail("Unsupported decorator target."); return unknownType; } function getEffectiveDecoratorSecondArgumentType(node) { - if (node.kind === 221) { + if (node.kind === 222) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } - if (node.kind === 142) { + if (node.kind === 143) { node = node.parent; - if (node.kind === 148) { + if (node.kind === 149) { return anyType; } } - if (node.kind === 145 || - node.kind === 147 || - node.kind === 149 || - node.kind === 150) { + if (node.kind === 146 || + node.kind === 148 || + node.kind === 150 || + node.kind === 151) { var element = node; switch (element.name.kind) { - case 69: + case 70: case 8: case 9: return getLiteralTypeForText(32, element.name.text); - case 140: + case 141: var nameType = checkComputedPropertyName(element.name); if (isTypeOfKind(nameType, 512)) { return nameType; @@ -27570,20 +28863,20 @@ var ts; return unknownType; } function getEffectiveDecoratorThirdArgumentType(node) { - if (node.kind === 221) { + if (node.kind === 222) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 142) { + if (node.kind === 143) { return numberType; } - if (node.kind === 145) { + if (node.kind === 146) { ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 147 || - node.kind === 149 || - node.kind === 150) { + if (node.kind === 148 || + node.kind === 150 || + node.kind === 151) { var propertyType = getTypeOfNode(node); return createTypedPropertyDescriptorType(propertyType); } @@ -27603,27 +28896,27 @@ var ts; ts.Debug.fail("Decorators should not have a fourth synthetic argument."); return unknownType; } - function getEffectiveArgumentType(node, argIndex, arg) { - if (node.kind === 143) { + function getEffectiveArgumentType(node, argIndex) { + if (node.kind === 144) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 176) { + else if (argIndex === 0 && node.kind === 177) { return getGlobalTemplateStringsArrayType(); } return undefined; } function getEffectiveArgument(node, args, argIndex) { - if (node.kind === 143 || - (argIndex === 0 && node.kind === 176)) { + if (node.kind === 144 || + (argIndex === 0 && node.kind === 177)) { return undefined; } return args[argIndex]; } function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 143) { + if (node.kind === 144) { return node.expression; } - else if (argIndex === 0 && node.kind === 176) { + else if (argIndex === 0 && node.kind === 177) { return node.template; } else { @@ -27631,12 +28924,12 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 176; - var isDecorator = node.kind === 143; + var isTaggedTemplate = node.kind === 177; + var isDecorator = node.kind === 144; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; - if (node.expression.kind !== 95) { + if (node.expression.kind !== 96) { ts.forEach(typeArguments, checkSourceElement); } } @@ -27662,7 +28955,7 @@ var ts; var candidateForTypeArgumentError; var resultOfFailedInference; var result; - var signatureHelpTrailingComma = candidatesOutArray && node.kind === 174 && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 175 && node.arguments.hasTrailingComma; if (candidates.length > 1) { result = chooseOverload(candidates, subtypeRelation, signatureHelpTrailingComma); } @@ -27777,7 +29070,7 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 95) { + if (node.expression.kind === 96) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); @@ -27930,16 +29223,16 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 221: - case 192: + case 222: + case 193: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 142: + case 143: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 145: + case 146: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 147: - case 149: + case 148: case 150: + case 151: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -27966,13 +29259,13 @@ var ts; } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 174: - return resolveCallExpression(node, candidatesOutArray); case 175: - return resolveNewExpression(node, candidatesOutArray); + return resolveCallExpression(node, candidatesOutArray); case 176: + return resolveNewExpression(node, candidatesOutArray); + case 177: return resolveTaggedTemplateExpression(node, candidatesOutArray); - case 143: + case 144: return resolveDecorator(node, candidatesOutArray); } ts.Debug.fail("Branch in 'resolveSignature' should be unreachable."); @@ -28001,17 +29294,17 @@ var ts; function checkCallExpression(node) { checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 95) { + if (node.expression.kind === 96) { return voidType; } - if (node.kind === 175) { + if (node.kind === 176) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 148 && - declaration.kind !== 152 && - declaration.kind !== 157 && + declaration.kind !== 149 && + declaration.kind !== 153 && + declaration.kind !== 158 && !ts.isJSDocConstructSignature(declaration)) { - var funcSymbol = node.expression.kind === 69 ? + var funcSymbol = node.expression.kind === 70 ? getResolvedSymbol(node.expression) : checkExpression(node.expression).symbol; if (funcSymbol && funcSymbol.members && (funcSymbol.flags & 16 || ts.isDeclarationOfFunctionExpression(funcSymbol))) { @@ -28023,7 +29316,9 @@ var ts; return anyType; } } - if (ts.isInJavaScriptFile(node) && ts.isRequireCall(node, true)) { + if (ts.isInJavaScriptFile(node) && + ts.isRequireCall(node, true) && + !resolveName(node.expression, node.expression.text, 107455, undefined, undefined)) { return resolveExternalModuleTypeByLiteral(node.arguments[0]); } return getReturnTypeOfSignature(signature); @@ -28063,21 +29358,36 @@ var ts; } function assignContextualParameterTypes(signature, context, mapper) { var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + if (isInferentialContext(mapper)) { + for (var i = 0; i < len; i++) { + var declaration = signature.parameters[i].valueDeclaration; + if (declaration.type) { + inferTypes(mapper.context, getTypeFromTypeNode(declaration.type), getTypeAtPosition(context, i)); + } + } + } if (context.thisParameter) { - if (!signature.thisParameter) { - signature.thisParameter = createTransientSymbol(context.thisParameter, undefined); + var parameter = signature.thisParameter; + if (!parameter || parameter.valueDeclaration && !parameter.valueDeclaration.type) { + if (!parameter) { + signature.thisParameter = createTransientSymbol(context.thisParameter, undefined); + } + assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper); } - assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper); } for (var i = 0; i < len; i++) { var parameter = signature.parameters[i]; - var contextualParameterType = getTypeAtPosition(context, i); - assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + if (!parameter.valueDeclaration.type) { + var contextualParameterType = getTypeAtPosition(context, i); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + } } if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) { var parameter = ts.lastOrUndefined(signature.parameters); - var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); - assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + if (!parameter.valueDeclaration.type) { + var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + } } } function assignBindingElementTypes(node) { @@ -28085,7 +29395,7 @@ var ts; for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { var element = _a[_i]; if (!ts.isOmittedExpression(element)) { - if (element.name.kind === 69) { + if (element.name.kind === 70) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } assignBindingElementTypes(element); @@ -28098,8 +29408,8 @@ var ts; if (!links.type) { links.type = instantiateType(contextualType, mapper); if (links.type === emptyObjectType && - (parameter.valueDeclaration.name.kind === 167 || - parameter.valueDeclaration.name.kind === 168)) { + (parameter.valueDeclaration.name.kind === 168 || + parameter.valueDeclaration.name.kind === 169)) { links.type = getTypeFromBindingPattern(parameter.valueDeclaration.name); } assignBindingElementTypes(parameter.valueDeclaration); @@ -28138,7 +29448,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 199) { + if (func.body.kind !== 200) { 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); @@ -28217,7 +29527,7 @@ var ts; return false; } var lastStatement = ts.lastOrUndefined(func.body.statements); - if (lastStatement && lastStatement.kind === 213 && isExhaustiveSwitchStatement(lastStatement)) { + if (lastStatement && lastStatement.kind === 214 && isExhaustiveSwitchStatement(lastStatement)) { return false; } return true; @@ -28246,7 +29556,7 @@ var ts; } }); if (aggregatedTypes.length === 0 && !hasReturnWithNoExpression && (hasReturnOfTypeNever || - func.kind === 179 || func.kind === 180)) { + func.kind === 180 || func.kind === 181)) { return undefined; } if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression) { @@ -28263,7 +29573,7 @@ var ts; if (returnType && maybeTypeOfKind(returnType, 1 | 1024)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 199 || !functionHasImplicitReturn(func)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 200 || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256; @@ -28290,9 +29600,9 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 147 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 148 || ts.isObjectLiteralMethod(node)); var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 179) { + if (!hasGrammarError && node.kind === 180) { checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { @@ -28326,14 +29636,14 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 147) { + if (produceDiagnostics && node.kind !== 148) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 147 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 148 || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); if (!node.asteriskToken) { @@ -28343,7 +29653,7 @@ var ts; if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 199) { + if (node.body.kind === 200) { checkSourceElement(node.body); } else { @@ -28378,10 +29688,10 @@ var ts; function isReferenceToReadonlyEntity(expr, symbol) { if (isReadonlySymbol(symbol)) { if (symbol.flags & 4 && - (expr.kind === 172 || expr.kind === 173) && - expr.expression.kind === 97) { + (expr.kind === 173 || expr.kind === 174) && + expr.expression.kind === 98) { var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 148)) + if (!(func && func.kind === 149)) return true; return !(func.parent === symbol.valueDeclaration.parent || func === symbol.valueDeclaration.parent); } @@ -28390,13 +29700,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 172 || expr.kind === 173) { + if (expr.kind === 173 || expr.kind === 174) { var node = skipParenthesizedNodes(expr.expression); - if (node.kind === 69) { + if (node.kind === 70) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 8388608) { var declaration = getDeclarationOfAliasSymbol(symbol); - return declaration && declaration.kind === 232; + return declaration && declaration.kind === 233; } } } @@ -28404,7 +29714,7 @@ var ts; } function checkReferenceExpression(expr, invalidReferenceMessage, constantVariableMessage) { var node = skipParenthesizedNodes(expr); - if (node.kind !== 69 && node.kind !== 172 && node.kind !== 173) { + if (node.kind !== 70 && node.kind !== 173 && node.kind !== 174) { error(expr, invalidReferenceMessage); return false; } @@ -28412,7 +29722,7 @@ var ts; var symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol); if (symbol) { if (symbol !== unknownSymbol && symbol !== argumentsSymbol) { - if (node.kind === 69 && !(symbol.flags & 3)) { + if (node.kind === 70 && !(symbol.flags & 3)) { error(expr, invalidReferenceMessage); return false; } @@ -28422,7 +29732,7 @@ var ts; } } } - else if (node.kind === 173) { + else if (node.kind === 174) { if (links.resolvedIndexInfo && links.resolvedIndexInfo.isReadonly) { error(expr, constantVariableMessage); return false; @@ -28459,24 +29769,24 @@ var ts; if (operandType === silentNeverType) { return silentNeverType; } - if (node.operator === 36 && node.operand.kind === 8) { + if (node.operator === 37 && node.operand.kind === 8) { return getFreshTypeOfLiteralType(getLiteralTypeForText(64, "" + -node.operand.text)); } switch (node.operator) { - case 35: case 36: - case 50: + case 37: + case 51: if (maybeTypeOfKind(operandType, 512)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; - case 49: + case 50: var facts = getTypeFacts(operandType) & (1048576 | 2097152); return facts === 1048576 ? falseType : facts === 2097152 ? trueType : booleanType; - case 41: case 42: + case 43: var ok = checkArithmeticOperandType(node.operand, getNonNullableType(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_or_a_read_only_property); @@ -28502,8 +29812,8 @@ var ts; } if (type.flags & 1572864) { var types = type.types; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var t = types_14[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var t = types_15[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -28517,8 +29827,8 @@ var ts; } if (type.flags & 524288) { var types = type.types; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var t = types_15[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var t = types_16[_i]; if (!isTypeOfKind(t, kind)) { return false; } @@ -28527,8 +29837,8 @@ var ts; } if (type.flags & 1048576) { var types = type.types; - for (var _a = 0, types_16 = types; _a < types_16.length; _a++) { - var t = types_16[_a]; + for (var _a = 0, types_17 = types; _a < types_17.length; _a++) { + var t = types_17[_a]; if (isTypeOfKind(t, kind)) { return true; } @@ -28566,18 +29876,18 @@ var ts; } return booleanType; } - function checkObjectLiteralAssignment(node, sourceType, contextualMapper) { + function checkObjectLiteralAssignment(node, sourceType) { var properties = node.properties; for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { var p = properties_4[_i]; - checkObjectLiteralDestructuringPropertyAssignment(sourceType, p, contextualMapper); + checkObjectLiteralDestructuringPropertyAssignment(sourceType, p); } return sourceType; } - function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, contextualMapper) { + function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property) { if (property.kind === 253 || property.kind === 254) { var name_17 = property.name; - if (name_17.kind === 140) { + if (name_17.kind === 141) { checkComputedPropertyName(name_17); } if (isComputedNonLiteralName(name_17)) { @@ -28616,8 +29926,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, contextualMapper) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 193) { - if (element.kind !== 191) { + if (element.kind !== 194) { + if (element.kind !== 192) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType @@ -28643,7 +29953,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 187 && restExpression.operatorToken.kind === 56) { + if (restExpression.kind === 188 && restExpression.operatorToken.kind === 57) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -28670,14 +29980,14 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 187 && target.operatorToken.kind === 56) { + if (target.kind === 188 && target.operatorToken.kind === 57) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 171) { - return checkObjectLiteralAssignment(target, sourceType, contextualMapper); + if (target.kind === 172) { + return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 170) { + if (target.kind === 171) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -28692,49 +30002,49 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 69: + case 70: case 9: - case 10: - case 176: - case 189: case 11: + case 177: + case 190: + case 12: case 8: - case 99: - case 84: - case 93: - case 135: - case 179: - case 192: + case 100: + case 85: + case 94: + case 136: case 180: - case 170: + case 193: + case 181: case 171: - case 182: - case 196: + case 172: + case 183: + case 197: + case 243: case 242: - case 241: return true; - case 188: + case 189: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 187: + case 188: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 185: case 186: + case 187: switch (node.operator) { - case 49: - case 35: - case 36: case 50: + case 36: + case 37: + case 51: return true; } return false; - case 183: - case 177: - case 195: + case 184: + case 178: + case 196: default: return false; } @@ -28754,34 +30064,34 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { var operator = operatorToken.kind; - if (operator === 56 && (left.kind === 171 || left.kind === 170)) { + if (operator === 57 && (left.kind === 172 || left.kind === 171)) { return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } var leftType = checkExpression(left, contextualMapper); var rightType = checkExpression(right, contextualMapper); switch (operator) { - case 37: case 38: - case 59: - case 60: case 39: + case 60: case 61: case 40: case 62: - case 36: - case 58: - case 43: + case 41: case 63: + case 37: + case 59: case 44: case 64: case 45: case 65: - case 47: - case 67: - case 48: - case 68: case 46: case 66: + case 48: + case 68: + case 49: + case 69: + case 47: + case 67: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -28805,8 +30115,8 @@ var ts; } } return numberType; - case 35: - case 57: + case 36: + case 58: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -28835,24 +30145,24 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 57) { + if (operator === 58) { checkAssignmentOperator(resultType); } return resultType; - case 25: - case 27: + case 26: case 28: case 29: + case 30: if (checkForDisallowedESSymbolOperand(operator)) { if (!isTypeComparableTo(leftType, rightType) && !isTypeComparableTo(rightType, leftType)) { reportOperatorError(); } } return booleanType; - case 30: case 31: case 32: case 33: + case 34: var leftIsLiteral = isLiteralType(leftType); var rightIsLiteral = isLiteralType(rightType); if (!leftIsLiteral || !rightIsLiteral) { @@ -28863,22 +30173,22 @@ var ts; reportOperatorError(); } return booleanType; - case 91: + case 92: return checkInstanceOfExpression(left, right, leftType, rightType); - case 90: + case 91: return checkInExpression(left, right, leftType, rightType); - case 51: + case 52: return getTypeFacts(leftType) & 1048576 ? includeFalsyTypes(rightType, getFalsyFlags(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType))) : leftType; - case 52: + case 53: return getTypeFacts(leftType) & 2097152 ? getBestChoiceType(removeDefinitelyFalsyTypes(leftType), rightType) : leftType; - case 56: + case 57: checkAssignmentOperator(rightType); return getRegularTypeOfObjectLiteral(rightType); - case 24: + case 25: if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left)) { error(left, ts.Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects); } @@ -28896,21 +30206,21 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { + case 48: + case 68: + return 53; + case 49: + case 69: + return 34; case 47: case 67: return 52; - case 48: - case 68: - return 33; - case 46: - case 66: - return 51; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 56 && operator <= 68) { + if (produceDiagnostics && operator >= 57 && operator <= 69) { 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_or_a_read_only_property); if (ok) { checkTypeAssignableTo(valueType, leftType, left, undefined); @@ -28982,9 +30292,9 @@ var ts; return getFreshTypeOfLiteralType(getLiteralTypeForText(32, node.text)); case 8: return getFreshTypeOfLiteralType(getLiteralTypeForText(64, node.text)); - case 99: + case 100: return trueType; - case 84: + case 85: return falseType; } } @@ -29013,7 +30323,7 @@ var ts; } function isTypeAssertion(node) { node = skipParenthesizedNodes(node); - return node.kind === 177 || node.kind === 195; + return node.kind === 178 || node.kind === 196; } function checkDeclarationInitializer(declaration) { var type = checkExpressionCached(declaration.initializer); @@ -29039,14 +30349,14 @@ var ts; return isTypeAssertion(node) || isLiteralContextualType(getContextualType(node)) ? type : getWidenedLiteralType(type); } function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 140) { + if (node.name.kind === 141) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, contextualMapper); } function checkObjectLiteralMethod(node, contextualMapper) { checkGrammarMethod(node); - if (node.name.kind === 140) { + if (node.name.kind === 141) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -29069,7 +30379,7 @@ var ts; } function checkExpression(node, contextualMapper) { var type; - if (node.kind === 139) { + if (node.kind === 140) { type = checkQualifiedName(node); } else { @@ -29077,9 +30387,9 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 172 && node.parent.expression === node) || - (node.parent.kind === 173 && node.parent.expression === node) || - ((node.kind === 69 || node.kind === 139) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 173 && node.parent.expression === node) || + (node.parent.kind === 174 && node.parent.expression === node) || + ((node.kind === 70 || node.kind === 140) && 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); } @@ -29088,79 +30398,79 @@ var ts; } function checkExpressionWorker(node, contextualMapper) { switch (node.kind) { - case 69: + case 70: return checkIdentifier(node); - case 97: + case 98: return checkThisExpression(node); - case 95: + case 96: return checkSuperExpression(node); - case 93: + case 94: return nullWideningType; case 9: case 8: - case 99: - case 84: + case 100: + case 85: return checkLiteralExpression(node); - case 189: - return checkTemplateExpression(node); - case 11: - return stringType; - case 10: - return globalRegExpType; - case 170: - return checkArrayLiteral(node, contextualMapper); - case 171: - return checkObjectLiteral(node, contextualMapper); - case 172: - return checkPropertyAccessExpression(node); - case 173: - return checkIndexedAccess(node); - case 174: - case 175: - return checkCallExpression(node); - case 176: - return checkTaggedTemplateExpression(node); - case 178: - return checkExpression(node.expression, contextualMapper); - case 192: - return checkClassExpression(node); - case 179: - case 180: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 182: - return checkTypeOfExpression(node); - case 177: - case 195: - return checkAssertion(node); - case 196: - return checkNonNullAssertion(node); - case 181: - return checkDeleteExpression(node); - case 183: - return checkVoidExpression(node); - case 184: - return checkAwaitExpression(node); - case 185: - return checkPrefixUnaryExpression(node); - case 186: - return checkPostfixUnaryExpression(node); - case 187: - return checkBinaryExpression(node, contextualMapper); - case 188: - return checkConditionalExpression(node, contextualMapper); - case 191: - return checkSpreadElementExpression(node, contextualMapper); - case 193: - return undefinedWideningType; case 190: + return checkTemplateExpression(node); + case 12: + return stringType; + case 11: + return globalRegExpType; + case 171: + return checkArrayLiteral(node, contextualMapper); + case 172: + return checkObjectLiteral(node, contextualMapper); + case 173: + return checkPropertyAccessExpression(node); + case 174: + return checkIndexedAccess(node); + case 175: + case 176: + return checkCallExpression(node); + case 177: + return checkTaggedTemplateExpression(node); + case 179: + return checkExpression(node.expression, contextualMapper); + case 193: + return checkClassExpression(node); + case 180: + case 181: + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + case 183: + return checkTypeOfExpression(node); + case 178: + case 196: + return checkAssertion(node); + case 197: + return checkNonNullAssertion(node); + case 182: + return checkDeleteExpression(node); + case 184: + return checkVoidExpression(node); + case 185: + return checkAwaitExpression(node); + case 186: + return checkPrefixUnaryExpression(node); + case 187: + return checkPostfixUnaryExpression(node); + case 188: + return checkBinaryExpression(node, contextualMapper); + case 189: + return checkConditionalExpression(node, contextualMapper); + case 192: + return checkSpreadElementExpression(node, contextualMapper); + case 194: + return undefinedWideningType; + case 191: return checkYieldExpression(node); case 248: return checkJsxExpression(node); - case 241: - return checkJsxElement(node); case 242: - return checkJsxSelfClosingElement(node); + return checkJsxElement(node); case 243: + return checkJsxSelfClosingElement(node); + case 244: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -29181,7 +30491,7 @@ var ts; var func = ts.getContainingFunction(node); if (ts.getModifierFlags(node) & 92) { func = ts.getContainingFunction(node); - if (!(func.kind === 148 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 149 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -29192,7 +30502,7 @@ var ts; if (ts.indexOf(func.parameters, node) !== 0) { error(node, ts.Diagnostics.A_this_parameter_must_be_the_first_parameter); } - if (func.kind === 148 || func.kind === 152 || func.kind === 157) { + if (func.kind === 149 || func.kind === 153 || func.kind === 158) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } } @@ -29204,15 +30514,15 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 147 || - node.kind === 220 || - node.kind === 179; + return node.kind === 148 || + node.kind === 221 || + node.kind === 180; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 69 && + if (param.name.kind === 70 && param.name.text === parameter.text) { return i; } @@ -29262,13 +30572,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { + case 181: + case 152: + case 221: case 180: - case 151: - case 220: - case 179: - case 156: + case 157: + case 148: case 147: - case 146: var parent_12 = node.parent; if (node === parent_12.type) { return parent_12; @@ -29282,13 +30592,13 @@ var ts; continue; } var name_19 = element.name; - if (name_19.kind === 69 && + if (name_19.kind === 70 && name_19.text === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name_19.kind === 168 || - name_19.kind === 167) { + else if (name_19.kind === 169 || + name_19.kind === 168) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_19, predicateVariableNode, predicateVariableName)) { return true; } @@ -29296,12 +30606,12 @@ var ts; } } function checkSignatureDeclaration(node) { - if (node.kind === 153) { + if (node.kind === 154) { checkGrammarIndexSignature(node); } - else if (node.kind === 156 || node.kind === 220 || node.kind === 157 || - node.kind === 151 || node.kind === 148 || - node.kind === 152) { + else if (node.kind === 157 || node.kind === 221 || node.kind === 158 || + node.kind === 152 || node.kind === 149 || + node.kind === 153) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); @@ -29313,10 +30623,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 152: + case 153: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 151: + case 152: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -29343,11 +30653,17 @@ var ts; } } function checkClassForDuplicateDeclarations(node) { + var Accessor; + (function (Accessor) { + Accessor[Accessor["Getter"] = 1] = "Getter"; + Accessor[Accessor["Setter"] = 2] = "Setter"; + Accessor[Accessor["Property"] = 3] = "Property"; + })(Accessor || (Accessor = {})); var instanceNames = ts.createMap(); var staticNames = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 148) { + if (member.kind === 149) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param)) { @@ -29356,18 +30672,18 @@ var ts; } } else { - var isStatic = ts.forEach(member.modifiers, function (m) { return m.kind === 113; }); + var isStatic = ts.forEach(member.modifiers, function (m) { return m.kind === 114; }); var names = isStatic ? staticNames : instanceNames; var memberName = member.name && ts.getPropertyNameForPropertyNameNode(member.name); if (memberName) { switch (member.kind) { - case 149: + case 150: addName(names, member.name, memberName, 1); break; - case 150: + case 151: addName(names, member.name, memberName, 2); break; - case 145: + case 146: addName(names, member.name, memberName, 3); break; } @@ -29393,12 +30709,12 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind == 144) { + if (member.kind == 145) { var memberName = void 0; switch (member.name.kind) { case 9: case 8: - case 69: + case 70: memberName = member.name.text; break; default: @@ -29415,7 +30731,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 222) { + if (node.kind === 223) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -29430,7 +30746,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 132: + case 133: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -29438,7 +30754,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 130: + case 131: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -29494,15 +30810,15 @@ var ts; return ts.forEachChild(n, containsSuperCall); } function markThisReferencesAsErrors(n) { - if (n.kind === 97) { + if (n.kind === 98) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 179 && n.kind !== 220) { + else if (n.kind !== 180 && n.kind !== 221) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 145 && + return n.kind === 146 && !(ts.getModifierFlags(n) & 32) && !!n.initializer; } @@ -29522,7 +30838,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 202 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 203 && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -29545,18 +30861,18 @@ var ts; checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 149) { + if (node.kind === 150) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 128)) { if (!(node.flags & 256)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); } } } - if (node.name.kind === 140) { + if (node.name.kind === 141) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { - var otherKind = node.kind === 149 ? 150 : 149; + var otherKind = node.kind === 150 ? 151 : 150; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if ((ts.getModifierFlags(node) & 28) !== (ts.getModifierFlags(otherAccessor) & 28)) { @@ -29570,11 +30886,11 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 149) { + if (node.kind === 150) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } - if (node.parent.kind !== 171) { + if (node.parent.kind !== 172) { checkSourceElement(node.body); registerForUnusedIdentifiersCheck(node); } @@ -29660,9 +30976,9 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); - if (n.parent.kind !== 222 && - n.parent.kind !== 221 && - n.parent.kind !== 192 && + if (n.parent.kind !== 223 && + n.parent.kind !== 222 && + n.parent.kind !== 193 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { flags |= 1; @@ -29739,7 +31055,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) { - var reportError = (node.kind === 147 || node.kind === 146) && + var reportError = (node.kind === 148 || node.kind === 147) && (ts.getModifierFlags(node) & 32) !== (ts.getModifierFlags(subsequentNode) & 32); if (reportError) { var diagnostic = ts.getModifierFlags(node) & 32 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; @@ -29772,11 +31088,11 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 222 || node.parent.kind === 159 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 223 || node.parent.kind === 160 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 220 || node.kind === 147 || node.kind === 146 || node.kind === 148) { + if (node.kind === 221 || node.kind === 148 || node.kind === 147 || node.kind === 149) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -29887,16 +31203,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 222: + case 223: return 2097152; - case 225: + case 226: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 221: - case 224: + case 222: + case 225: return 2097152 | 1048576; - case 229: + case 230: var result_2 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_2 |= getDeclarationSpaces(d); }); @@ -30044,22 +31360,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 221: + case 222: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 142: + case 143: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 145: + case 146: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 147: - case 149: + case 148: case 150: + case 151: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -30068,9 +31384,9 @@ var ts; checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, errorInfo); } function checkTypeNodeAsExpression(node) { - if (node && node.kind === 155) { + if (node && node.kind === 156) { var root = getFirstIdentifier(node.typeName); - var meaning = root.parent.kind === 155 ? 793064 : 1920; + var meaning = root.parent.kind === 156 ? 793064 : 1920; var rootSymbol = resolveName(root, root.text, meaning | 8388608, undefined, undefined); if (rootSymbol && rootSymbol.flags & 8388608) { var aliasTarget = resolveAlias(rootSymbol); @@ -30104,20 +31420,20 @@ var ts; } if (compilerOptions.emitDecoratorMetadata) { switch (node.kind) { - case 221: + case 222: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 147: - case 149: + case 148: case 150: + case 151: checkParameterTypeAnnotationsAsExpressions(node); checkReturnTypeAnnotationAsExpression(node); break; - case 145: - case 142: + case 146: + case 143: checkTypeAnnotationAsExpression(node); break; } @@ -30137,7 +31453,7 @@ var ts; checkDecorators(node); checkSignatureDeclaration(node); var isAsync = ts.isAsyncFunctionLike(node); - if (node.name && node.name.kind === 140) { + if (node.name && node.name.kind === 141) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { @@ -30180,42 +31496,42 @@ var ts; var node = deferredUnusedIdentifierNodes_1[_i]; switch (node.kind) { case 256: - case 225: + case 226: checkUnusedModuleMembers(node); break; - case 221: - case 192: + case 222: + case 193: checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; - case 222: + case 223: checkUnusedTypeParameters(node); break; - case 199: - case 227: - case 206: + case 200: + case 228: case 207: case 208: + case 209: checkUnusedLocalsAndParameters(node); break; - case 148: - case 179: - case 220: - case 180: - case 147: case 149: + case 180: + case 221: + case 181: + case 148: case 150: + case 151: if (node.body) { checkUnusedLocalsAndParameters(node); } checkUnusedTypeParameters(node); break; - case 146: - case 151: + case 147: case 152: case 153: - case 156: + case 154: case 157: + case 158: checkUnusedTypeParameters(node); break; } @@ -30224,11 +31540,11 @@ var ts; } } function checkUnusedLocalsAndParameters(node) { - if (node.parent.kind !== 222 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { + if (node.parent.kind !== 223 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { var _loop_1 = function (key) { var local = node.locals[key]; if (!local.isReferenced) { - if (local.valueDeclaration && local.valueDeclaration.kind === 142) { + if (local.valueDeclaration && local.valueDeclaration.kind === 143) { var parameter = local.valueDeclaration; if (compilerOptions.noUnusedParameters && !ts.isParameterPropertyDeclaration(parameter) && @@ -30248,19 +31564,19 @@ var ts; } } function parameterNameStartsWithUnderscore(parameter) { - return parameter.name && parameter.name.kind === 69 && parameter.name.text.charCodeAt(0) === 95; + return parameter.name && parameter.name.kind === 70 && parameter.name.text.charCodeAt(0) === 95; } function checkUnusedClassMembers(node) { if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) { if (node.members) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 147 || member.kind === 145) { + if (member.kind === 148 || member.kind === 146) { if (!member.symbol.isReferenced && ts.getModifierFlags(member) & 8) { error(member.name, ts.Diagnostics._0_is_declared_but_never_used, member.symbol.name); } } - else if (member.kind === 148) { + else if (member.kind === 149) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.getModifierFlags(parameter) & 8) { @@ -30305,7 +31621,7 @@ var ts; } } function checkBlock(node) { - if (node.kind === 199) { + if (node.kind === 200) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -30327,19 +31643,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 145 || - node.kind === 144 || + if (node.kind === 146 || + node.kind === 145 || + node.kind === 148 || node.kind === 147 || - node.kind === 146 || - node.kind === 149 || - node.kind === 150) { + node.kind === 150 || + node.kind === 151) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 142 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 143 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -30353,7 +31669,7 @@ var ts; var current = node; while (current) { if (getNodeCheckFlags(current) & 4) { - var isDeclaration_1 = node.kind !== 69; + var isDeclaration_1 = node.kind !== 70; if (isDeclaration_1) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -30374,7 +31690,7 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 69; + var isDeclaration_2 = node.kind !== 70; if (isDeclaration_2) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -30384,13 +31700,13 @@ var ts; } } function checkCollisionWithRequireExportsInGeneratedCode(node, name) { - if (modulekind >= ts.ModuleKind.ES6) { + if (modulekind >= ts.ModuleKind.ES2015) { return; } if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 225 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 226 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); @@ -30402,7 +31718,7 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "Promise")) { return; } - if (node.kind === 225 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 226 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); @@ -30414,7 +31730,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 3) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 218 && !node.initializer) { + if (node.kind === 219 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -30424,14 +31740,14 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 219); - var container = varDeclList.parent.kind === 200 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 220); + var container = varDeclList.parent.kind === 201 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 199 && ts.isFunctionLike(container.parent) || + (container.kind === 200 && ts.isFunctionLike(container.parent) || + container.kind === 227 || container.kind === 226 || - container.kind === 225 || container.kind === 256); if (!namesShareScope) { var name_20 = symbolToString(localDeclarationSymbol); @@ -30442,7 +31758,7 @@ var ts; } } function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 142) { + if (ts.getRootDeclaration(node).kind !== 143) { return; } var func = ts.getContainingFunction(node); @@ -30451,10 +31767,10 @@ var ts; if (ts.isTypeNode(n) || ts.isDeclarationName(n)) { return; } - if (n.kind === 172) { + if (n.kind === 173) { return visit(n.expression); } - else if (n.kind === 69) { + else if (n.kind === 70) { var symbol = resolveName(n, n.text, 107455 | 8388608, undefined, undefined); if (!symbol || symbol === unknownSymbol || !symbol.valueDeclaration) { return; @@ -30465,7 +31781,7 @@ var ts; } var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 142) { + if (symbol.valueDeclaration.kind === 143) { if (symbol.valueDeclaration.pos < node.pos) { return; } @@ -30474,7 +31790,7 @@ var ts; if (ts.isFunctionLike(current.parent)) { return; } - if (current.parent.kind === 145 && + if (current.parent.kind === 146 && !(ts.hasModifier(current.parent, 32)) && ts.isClassLike(current.parent.parent)) { return; @@ -30491,19 +31807,19 @@ var ts; } } function convertAutoToAny(type) { - return type === autoType ? anyType : type; + return type === autoType ? anyType : type === autoArrayType ? anyArrayType : type; } function checkVariableLikeDeclaration(node) { checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 140) { + if (node.name.kind === 141) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 169) { - if (node.propertyName && node.propertyName.kind === 140) { + if (node.kind === 170) { + if (node.propertyName && node.propertyName.kind === 141) { checkComputedPropertyName(node.propertyName); } var parent_13 = node.parent.parent; @@ -30517,12 +31833,12 @@ var ts; if (ts.isBindingPattern(node.name)) { ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 142 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 143 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } if (ts.isBindingPattern(node.name)) { - if (node.initializer && node.parent.parent.kind !== 207) { + if (node.initializer && node.parent.parent.kind !== 208) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, undefined); checkParameterInitializer(node); } @@ -30531,7 +31847,7 @@ var ts; var symbol = getSymbolOfNode(node); var type = convertAutoToAny(getTypeOfVariableOrParameterOrProperty(symbol)); if (node === symbol.valueDeclaration) { - if (node.initializer && node.parent.parent.kind !== 207) { + if (node.initializer && node.parent.parent.kind !== 208) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); checkParameterInitializer(node); } @@ -30549,9 +31865,9 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 145 && node.kind !== 144) { + if (node.kind !== 146 && node.kind !== 145) { checkExportsOnMergedDeclarations(node); - if (node.kind === 218 || node.kind === 169) { + if (node.kind === 219 || node.kind === 170) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -30561,8 +31877,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 142 && right.kind === 218) || - (left.kind === 218 && right.kind === 142)) { + if ((left.kind === 143 && right.kind === 219) || + (left.kind === 219 && right.kind === 143)) { return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { @@ -30589,7 +31905,7 @@ var ts; ts.forEach(node.declarationList.declarations, checkSourceElement); } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { - if (node.modifiers && node.parent.kind === 171) { + if (node.modifiers && node.parent.kind === 172) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -30608,7 +31924,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 201) { + if (node.thenStatement.kind === 202) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -30625,12 +31941,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 219) { + if (node.initializer && node.initializer.kind === 220) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 219) { + if (node.initializer.kind === 220) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -30648,13 +31964,13 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 219) { + if (node.initializer.kind === 220) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 170 || varExpr.kind === 171) { + if (varExpr.kind === 171 || varExpr.kind === 172) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { @@ -30672,7 +31988,7 @@ var ts; } function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 219) { + if (node.initializer.kind === 220) { 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); @@ -30682,7 +31998,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 170 || varExpr.kind === 171) { + if (varExpr.kind === 171 || varExpr.kind === 172) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 34)) { @@ -30855,7 +32171,7 @@ var ts; checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatedSetAccessor(node) { - return !!(node.kind === 149 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 150))); + return !!(node.kind === 150 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 151))); } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { var unwrappedReturnType = ts.isAsyncFunctionLike(func) ? getPromisedType(returnType) : returnType; @@ -30877,12 +32193,12 @@ var ts; if (func.asteriskToken) { return; } - if (func.kind === 150) { + if (func.kind === 151) { if (node.expression) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 148) { + else if (func.kind === 149) { if (node.expression && !checkTypeAssignableTo(exprType, returnType, node.expression)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -30900,7 +32216,7 @@ var ts; } } } - else if (func.kind !== 148 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 149 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } } @@ -30957,7 +32273,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 214 && current.label.text === node.label.text) { + if (current.kind === 215 && 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; @@ -30983,7 +32299,7 @@ var ts; var catchClause = node.catchClause; if (catchClause) { if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 69) { + if (catchClause.variableDeclaration.name.kind !== 70) { grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); } else if (catchClause.variableDeclaration.type) { @@ -31051,7 +32367,7 @@ var ts; return; } var errorNode; - if (prop.valueDeclaration.name.kind === 140 || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 141 || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -31102,7 +32418,7 @@ var ts; var firstDecl; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 221 || declaration.kind === 222) { + if (declaration.kind === 222 || declaration.kind === 223) { if (!firstDecl) { firstDecl = declaration; } @@ -31239,7 +32555,7 @@ var ts; if (derived === base) { var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); if (baseDeclarationFlags & 128 && (!derivedClassDecl || !(ts.getModifierFlags(derivedClassDecl) & 128))) { - if (derivedClassDecl.kind === 192) { + if (derivedClassDecl.kind === 193) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -31283,7 +32599,7 @@ var ts; } } function isAccessor(kind) { - return kind === 149 || kind === 150; + return kind === 150 || kind === 151; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -31350,7 +32666,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(node, symbol); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 222); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 223); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -31445,18 +32761,18 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 185: + case 186: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; } switch (e.operator) { - case 35: return value_1; - case 36: return -value_1; - case 50: return ~value_1; + case 36: return value_1; + case 37: return -value_1; + case 51: return ~value_1; } return undefined; - case 187: + case 188: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -31466,37 +32782,37 @@ var ts; return undefined; } switch (e.operatorToken.kind) { - 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 39: return left / right; - case 35: return left + right; - case 36: return left - right; - case 40: return left % right; + case 48: return left | right; + case 47: return left & right; + case 45: return left >> right; + case 46: return left >>> right; + case 44: return left << right; + case 49: return left ^ right; + case 38: return left * right; + case 40: return left / right; + case 36: return left + right; + case 37: return left - right; + case 41: return left % right; } return undefined; case 8: return +e.text; - case 178: + case 179: return evalConstant(e.expression); - case 69: + case 70: + case 174: case 173: - case 172: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; var propertyName = void 0; - if (e.kind === 69) { + if (e.kind === 70) { enumType_1 = currentType; propertyName = e.text; } else { var expression = void 0; - if (e.kind === 173) { + if (e.kind === 174) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9) { return undefined; @@ -31510,10 +32826,10 @@ var ts; } var current = expression; while (current) { - if (current.kind === 69) { + if (current.kind === 70) { break; } - else if (current.kind === 172) { + else if (current.kind === 173) { current = current.expression; } else { @@ -31573,7 +32889,7 @@ var ts; } var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 224) { + if (declaration.kind !== 225) { return false; } var enumDeclaration = declaration; @@ -31596,8 +32912,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { var declaration = declarations_5[_i]; - if ((declaration.kind === 221 || - (declaration.kind === 220 && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 222 || + (declaration.kind === 221 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -31656,7 +32972,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, 221); + var mergedClass = ts.getDeclarationOfKind(symbol, 222); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -31699,22 +33015,22 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 200: + case 201: for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 235: case 236: + case 237: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 229: case 230: + case 231: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 169: - case 218: + case 170: + case 219: var name_22 = node.name; if (ts.isBindingPattern(name_22)) { for (var _b = 0, _c = name_22.elements; _b < _c.length; _b++) { @@ -31723,12 +33039,12 @@ var ts; } break; } - case 221: - case 224: - case 220: case 222: case 225: + case 221: case 223: + case 226: + case 224: if (isGlobalAugmentation) { return; } @@ -31744,17 +33060,17 @@ var ts; } function getFirstIdentifier(node) { switch (node.kind) { - case 69: + case 70: return node; - case 139: + case 140: do { node = node.left; - } while (node.kind !== 69); + } while (node.kind !== 70); return node; - case 172: + case 173: do { node = node.expression; - } while (node.kind !== 69); + } while (node.kind !== 70); return node; } } @@ -31764,9 +33080,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 226 && ts.isAmbientModule(node.parent.parent); + var inAmbientExternalModule = node.parent.kind === 227 && ts.isAmbientModule(node.parent.parent); if (node.parent.kind !== 256 && !inAmbientExternalModule) { - error(moduleName, node.kind === 236 ? + error(moduleName, node.kind === 237 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -31787,7 +33103,7 @@ var ts; (symbol.flags & 793064 ? 793064 : 0) | (symbol.flags & 1920 ? 1920 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 238 ? + var message = node.kind === 239 ? 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)); @@ -31814,7 +33130,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 232) { + if (importClause.namedBindings.kind === 233) { checkImportBinding(importClause.namedBindings); } else { @@ -31849,7 +33165,7 @@ var ts; } } else { - if (modulekind === ts.ModuleKind.ES6 && !ts.isInAmbientContext(node)) { + if (modulekind === ts.ModuleKind.ES2015 && !ts.isInAmbientContext(node)) { grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } } @@ -31865,7 +33181,7 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 226 && ts.isAmbientModule(node.parent.parent); + var inAmbientExternalModule = node.parent.kind === 227 && ts.isAmbientModule(node.parent.parent); if (node.parent.kind !== 256 && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } @@ -31879,7 +33195,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 256 || node.parent.kind === 226 || node.parent.kind === 225; + var isInAppropriateContext = node.parent.kind === 256 || node.parent.kind === 227 || node.parent.kind === 226; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -31903,14 +33219,14 @@ var ts; return; } var container = node.parent.kind === 256 ? node.parent : node.parent.parent; - if (container.kind === 225 && !ts.isAmbientModule(container)) { + if (container.kind === 226 && !ts.isAmbientModule(container)) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.getModifierFlags(node) !== 0) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 69) { + if (node.expression.kind === 70) { markExportAsReferenced(node); } else { @@ -31918,7 +33234,7 @@ var ts; } checkExternalModuleExports(container); if (node.isExportEquals && !ts.isInAmbientContext(node)) { - if (modulekind === ts.ModuleKind.ES6) { + if (modulekind === ts.ModuleKind.ES2015) { grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_export_default_or_another_module_format_instead); } else if (modulekind === ts.ModuleKind.System) { @@ -31970,7 +33286,7 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return (declaration.kind !== 220 && declaration.kind !== 147) || + return (declaration.kind !== 221 && declaration.kind !== 148) || !!declaration.body; } } @@ -31981,118 +33297,118 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { - case 225: - case 221: + case 226: case 222: - case 220: + case 223: + case 221: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 141: - return checkTypeParameter(node); case 142: + return checkTypeParameter(node); + case 143: return checkParameter(node); + case 146: case 145: - case 144: return checkPropertyDeclaration(node); - case 156: case 157: - case 151: + case 158: case 152: - return checkSignatureDeclaration(node); case 153: return checkSignatureDeclaration(node); - case 147: - case 146: - return checkMethodDeclaration(node); - case 148: - return checkConstructorDeclaration(node); - case 149: - case 150: - return checkAccessorDeclaration(node); - case 155: - return checkTypeReferenceNode(node); case 154: + return checkSignatureDeclaration(node); + case 148: + case 147: + return checkMethodDeclaration(node); + case 149: + return checkConstructorDeclaration(node); + case 150: + case 151: + return checkAccessorDeclaration(node); + case 156: + return checkTypeReferenceNode(node); + case 155: return checkTypePredicate(node); - case 158: - return checkTypeQuery(node); case 159: - return checkTypeLiteral(node); + return checkTypeQuery(node); case 160: - return checkArrayType(node); + return checkTypeLiteral(node); case 161: - return checkTupleType(node); + return checkArrayType(node); case 162: + return checkTupleType(node); case 163: - return checkUnionOrIntersectionType(node); case 164: + return checkUnionOrIntersectionType(node); + case 165: return checkSourceElement(node.type); - case 220: - return checkFunctionDeclaration(node); - case 199: - case 226: - return checkBlock(node); - case 200: - return checkVariableStatement(node); - case 202: - return checkExpressionStatement(node); - case 203: - return checkIfStatement(node); - case 204: - return checkDoStatement(node); - case 205: - return checkWhileStatement(node); - case 206: - return checkForStatement(node); - case 207: - return checkForInStatement(node); - case 208: - return checkForOfStatement(node); - case 209: - case 210: - return checkBreakOrContinueStatement(node); - case 211: - return checkReturnStatement(node); - case 212: - return checkWithStatement(node); - case 213: - return checkSwitchStatement(node); - case 214: - return checkLabeledStatement(node); - case 215: - return checkThrowStatement(node); - case 216: - return checkTryStatement(node); - case 218: - return checkVariableDeclaration(node); - case 169: - return checkBindingElement(node); case 221: - return checkClassDeclaration(node); - case 222: - return checkInterfaceDeclaration(node); - case 223: - return checkTypeAliasDeclaration(node); - case 224: - return checkEnumDeclaration(node); - case 225: - return checkModuleDeclaration(node); - case 230: - return checkImportDeclaration(node); - case 229: - return checkImportEqualsDeclaration(node); - case 236: - return checkExportDeclaration(node); - case 235: - return checkExportAssignment(node); + return checkFunctionDeclaration(node); + case 200: + case 227: + return checkBlock(node); case 201: - checkGrammarStatementInAmbientContext(node); - return; + return checkVariableStatement(node); + case 203: + return checkExpressionStatement(node); + case 204: + return checkIfStatement(node); + case 205: + return checkDoStatement(node); + case 206: + return checkWhileStatement(node); + case 207: + return checkForStatement(node); + case 208: + return checkForInStatement(node); + case 209: + return checkForOfStatement(node); + case 210: + case 211: + return checkBreakOrContinueStatement(node); + case 212: + return checkReturnStatement(node); + case 213: + return checkWithStatement(node); + case 214: + return checkSwitchStatement(node); + case 215: + return checkLabeledStatement(node); + case 216: + return checkThrowStatement(node); case 217: + return checkTryStatement(node); + case 219: + return checkVariableDeclaration(node); + case 170: + return checkBindingElement(node); + case 222: + return checkClassDeclaration(node); + case 223: + return checkInterfaceDeclaration(node); + case 224: + return checkTypeAliasDeclaration(node); + case 225: + return checkEnumDeclaration(node); + case 226: + return checkModuleDeclaration(node); + case 231: + return checkImportDeclaration(node); + case 230: + return checkImportEqualsDeclaration(node); + case 237: + return checkExportDeclaration(node); + case 236: + return checkExportAssignment(node); + case 202: checkGrammarStatementInAmbientContext(node); return; - case 239: + case 218: + checkGrammarStatementInAmbientContext(node); + return; + case 240: return checkMissingDeclaration(node); } } @@ -32105,17 +33421,17 @@ var ts; for (var _i = 0, deferredNodes_1 = deferredNodes; _i < deferredNodes_1.length; _i++) { var node = deferredNodes_1[_i]; switch (node.kind) { - case 179: case 180: + case 181: + case 148: case 147: - case 146: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 149: case 150: + case 151: checkAccessorDeferred(node); break; - case 192: + case 193: checkClassExpressionDeferred(node); break; } @@ -32187,7 +33503,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 212 && node.parent.statement === node) { + if (node.parent.kind === 213 && node.parent.statement === node) { return true; } node = node.parent; @@ -32213,24 +33529,24 @@ var ts; if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 225: + case 226: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 224: + case 225: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 192: + case 193: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 221: case 222: + case 223: if (!(memberFlags & 32)) { copySymbols(getSymbolOfNode(location).members, meaning & 793064); } break; - case 179: + case 180: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -32263,33 +33579,33 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 69 && + return name.kind === 70 && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 141: - case 221: + case 142: case 222: case 223: case 224: + case 225: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 139) { + while (node.parent && node.parent.kind === 140) { node = node.parent; } - return node.parent && (node.parent.kind === 155 || node.parent.kind === 267); + return node.parent && (node.parent.kind === 156 || node.parent.kind === 267); } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 172) { + while (node.parent && node.parent.kind === 173) { node = node.parent; } - return node.parent && node.parent.kind === 194; + return node.parent && node.parent.kind === 195; } function forEachEnclosingClass(node, callback) { var result; @@ -32306,13 +33622,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 139) { + while (nodeOnRightSide.parent.kind === 140) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 229) { + if (nodeOnRightSide.parent.kind === 230) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 235) { + if (nodeOnRightSide.parent.kind === 236) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -32324,7 +33640,7 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 172) { + if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 173) { var specialPropertyAssignmentKind = ts.getSpecialPropertyAssignmentKind(entityName.parent.parent); switch (specialPropertyAssignmentKind) { case 1: @@ -32336,20 +33652,20 @@ var ts; default: } } - if (entityName.parent.kind === 235 && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 236 && ts.isEntityNameExpression(entityName)) { return resolveEntityName(entityName, 107455 | 793064 | 1920 | 8388608); } - if (entityName.kind !== 172 && isInRightSideOfImportOrExportAssignment(entityName)) { - var importEqualsDeclaration = ts.getAncestor(entityName, 229); + if (entityName.kind !== 173 && isInRightSideOfImportOrExportAssignment(entityName)) { + var importEqualsDeclaration = ts.getAncestor(entityName, 230); ts.Debug.assert(importEqualsDeclaration !== undefined); - return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importEqualsDeclaration, true); + return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, true); } if (ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0; - if (entityName.parent.kind === 194) { + if (entityName.parent.kind === 195) { meaning = 793064; if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning |= 107455; @@ -32365,20 +33681,20 @@ var ts; if (ts.nodeIsMissing(entityName)) { return undefined; } - if (entityName.kind === 69) { + if (entityName.kind === 70) { if (ts.isJSXTagName(entityName) && isJsxIntrinsicIdentifier(entityName)) { return getIntrinsicTagSymbol(entityName.parent); } return resolveEntityName(entityName, 107455, false, true); } - else if (entityName.kind === 172) { + else if (entityName.kind === 173) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 139) { + else if (entityName.kind === 140) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -32387,13 +33703,13 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = (entityName.parent.kind === 155 || entityName.parent.kind === 267) ? 793064 : 1920; + var meaning = (entityName.parent.kind === 156 || entityName.parent.kind === 267) ? 793064 : 1920; return resolveEntityName(entityName, meaning, false, true); } else if (entityName.parent.kind === 246) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 154) { + if (entityName.parent.kind === 155) { return resolveEntityName(entityName, 1); } return undefined; @@ -32411,12 +33727,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(node.parent.parent); } - if (node.kind === 69) { + if (node.kind === 70) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (node.parent.kind === 169 && - node.parent.parent.kind === 167 && + else if (node.parent.kind === 170 && + node.parent.parent.kind === 168 && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -32426,11 +33742,11 @@ var ts; } } switch (node.kind) { - case 69: - case 172: - case 139: + case 70: + case 173: + case 140: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 97: + case 98: var container = ts.getThisContainer(node, false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -32438,21 +33754,21 @@ var ts; return sig.thisParameter; } } - case 95: + case 96: var type = ts.isPartOfExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 165: + case 166: return getTypeFromTypeNode(node).symbol; - case 121: + case 122: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 148) { + if (constructorDeclaration && constructorDeclaration.kind === 149) { return constructorDeclaration.parent.symbol; } return undefined; case 9: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 230 || node.parent.kind === 236) && + ((node.parent.kind === 231 || node.parent.kind === 237) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } @@ -32460,7 +33776,7 @@ var ts; return resolveExternalModuleName(node, node); } case 8: - if (node.parent.kind === 173 && node.parent.argumentExpression === node) { + if (node.parent.kind === 174 && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -32524,12 +33840,12 @@ var ts; return unknownType; } function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 171 || expr.kind === 170); - if (expr.parent.kind === 208) { + ts.Debug.assert(expr.kind === 172 || expr.kind === 171); + if (expr.parent.kind === 209) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression); return checkDestructuringAssignment(expr, iteratedType || unknownType); } - if (expr.parent.kind === 187) { + if (expr.parent.kind === 188) { var iteratedType = checkExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || unknownType); } @@ -32537,7 +33853,7 @@ var ts; var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent); } - ts.Debug.assert(expr.parent.kind === 170); + ts.Debug.assert(expr.parent.kind === 171); var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, false) || unknownType; return checkArrayLiteralDestructuringElementAssignment(expr.parent, typeOfArrayLiteral, ts.indexOf(expr.parent.elements, expr), elementType || unknownType); @@ -32678,7 +33994,7 @@ var ts; else if (nodeLinks_1.flags & 131072) { var isDeclaredInLoop = nodeLinks_1.flags & 262144; var inLoopInitializer = ts.isIterationStatement(container, false); - var inLoopBodyBlock = container.kind === 199 && ts.isIterationStatement(container.parent, false); + var inLoopBodyBlock = container.kind === 200 && ts.isIterationStatement(container.parent, false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -32718,18 +34034,18 @@ var ts; return true; } switch (node.kind) { - case 229: - case 231: + case 230: case 232: - case 234: - case 238: + case 233: + case 235: + case 239: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 236: + case 237: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 235: + case 236: return node.expression - && node.expression.kind === 69 + && node.expression.kind === 70 ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : true; } @@ -32961,7 +34277,7 @@ var ts; if (!fileToDirective) { return undefined; } - var meaning = (node.kind === 172) || (node.kind === 69 && isInTypeQuery(node)) + var meaning = (node.kind === 173) || (node.kind === 70 && isInTypeQuery(node)) ? 107455 | 1048576 : 793064 | 1920; var symbol = resolveEntityName(node, meaning, true); @@ -33108,6 +34424,7 @@ var ts; getGlobalIterableIteratorType = ts.memoize(function () { return emptyGenericType; }); } anyArrayType = createArrayType(anyType); + autoArrayType = createArrayType(autoType); var symbol = getGlobalSymbol("ReadonlyArray", 793064, undefined); globalReadonlyArrayType = symbol && getTypeOfGlobalSymbol(symbol, 1); anyReadonlyArrayType = globalReadonlyArrayType ? createTypeFromGenericGlobalType(globalReadonlyArrayType, [anyType]) : anyArrayType; @@ -33167,14 +34484,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node)) { - if (node.kind === 147 && !ts.nodeIsPresent(node.body)) { + if (node.kind === 148 && !ts.nodeIsPresent(node.body)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload); } else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } } - else if (node.kind === 149 || node.kind === 150) { + else if (node.kind === 150 || node.kind === 151) { 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); @@ -33191,28 +34508,28 @@ var ts; var flags = 0; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 128) { - if (node.kind === 144 || node.kind === 146) { + if (modifier.kind !== 129) { + if (node.kind === 145 || node.kind === 147) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 153) { + if (node.kind === 154) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 74: - if (node.kind !== 224 && node.parent.kind === 221) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(74)); + case 75: + if (node.kind !== 225 && node.parent.kind === 222) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(75)); } break; + case 113: case 112: case 111: - case 110: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); - if (modifier.kind === 111) { + if (modifier.kind === 112) { lastProtected = modifier; } - else if (modifier.kind === 110) { + else if (modifier.kind === 111) { lastPrivate = modifier; } if (flags & 28) { @@ -33227,11 +34544,11 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 226 || node.parent.kind === 256) { + else if (node.parent.kind === 227 || node.parent.kind === 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128) { - if (modifier.kind === 110) { + if (modifier.kind === 111) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -33240,7 +34557,7 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 113: + case 114: if (flags & 32) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } @@ -33250,10 +34567,10 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 226 || node.parent.kind === 256) { + else if (node.parent.kind === 227 || node.parent.kind === 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 142) { + else if (node.kind === 143) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128) { @@ -33262,17 +34579,17 @@ var ts; flags |= 32; lastStatic = modifier; break; - case 128: + case 129: if (flags & 64) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 145 && node.kind !== 144 && node.kind !== 153 && node.kind !== 142) { + else if (node.kind !== 146 && node.kind !== 145 && node.kind !== 154 && node.kind !== 143) { return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } flags |= 64; lastReadonly = modifier; break; - case 82: + case 83: if (flags & 1) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -33285,45 +34602,45 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 221) { + else if (node.parent.kind === 222) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 142) { + else if (node.kind === 143) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; break; - case 122: + case 123: if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 221) { + else if (node.parent.kind === 222) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 142) { + else if (node.kind === 143) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 226) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 227) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; lastDeclare = modifier; break; - case 115: + case 116: if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 221) { - if (node.kind !== 147 && - node.kind !== 145 && - node.kind !== 149 && - node.kind !== 150) { + if (node.kind !== 222) { + if (node.kind !== 148 && + node.kind !== 146 && + node.kind !== 150 && + node.kind !== 151) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 221 && ts.getModifierFlags(node.parent) & 128)) { + if (!(node.parent.kind === 222 && ts.getModifierFlags(node.parent) & 128)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32) { @@ -33335,14 +34652,14 @@ var ts; } flags |= 128; break; - case 118: + case 119: if (flags & 256) { 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 === 142) { + else if (node.kind === 143) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256; @@ -33350,7 +34667,7 @@ var ts; break; } } - if (node.kind === 148) { + if (node.kind === 149) { if (flags & 32) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -33365,13 +34682,13 @@ var ts; } return; } - else if ((node.kind === 230 || node.kind === 229) && flags & 2) { + else if ((node.kind === 231 || node.kind === 230) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 142 && (flags & 92) && ts.isBindingPattern(node.name)) { + else if (node.kind === 143 && (flags & 92) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 142 && (flags & 92) && node.dotDotDotToken) { + else if (node.kind === 143 && (flags & 92) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256) { @@ -33387,38 +34704,38 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 149: case 150: - case 148: - case 145: - case 144: - case 147: + case 151: + case 149: case 146: - case 153: - case 225: + case 145: + case 148: + case 147: + case 154: + case 226: + case 231: case 230: - case 229: + case 237: case 236: - case 235: - case 179: case 180: - case 142: + case 181: + case 143: return false; default: - if (node.parent.kind === 226 || node.parent.kind === 256) { + if (node.parent.kind === 227 || node.parent.kind === 256) { return false; } switch (node.kind) { - case 220: - return nodeHasAnyModifiersExcept(node, 118); case 221: - return nodeHasAnyModifiersExcept(node, 115); + return nodeHasAnyModifiersExcept(node, 119); case 222: - case 200: + return nodeHasAnyModifiersExcept(node, 116); case 223: - return true; + case 201: case 224: - return nodeHasAnyModifiersExcept(node, 74); + return true; + case 225: + return nodeHasAnyModifiersExcept(node, 75); default: ts.Debug.fail(); return false; @@ -33430,10 +34747,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 147: - case 220: - case 179: + case 148: + case 221: case 180: + case 181: if (!node.asteriskToken) { return false; } @@ -33449,7 +34766,7 @@ var ts; return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Trailing_comma_not_allowed); } } - function checkGrammarTypeParameterList(node, typeParameters, file) { + function checkGrammarTypeParameterList(typeParameters, file) { if (checkGrammarForDisallowedTrailingComma(typeParameters)) { return true; } @@ -33491,11 +34808,11 @@ var ts; } function checkGrammarFunctionLikeDeclaration(node) { var file = ts.getSourceFileOfNode(node); - return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node, node.typeParameters, file) || + return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node.typeParameters, file) || checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 180) { + if (node.kind === 181) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -33530,7 +34847,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 !== 132 && parameter.type.kind !== 130) { + if (parameter.type.kind !== 133 && parameter.type.kind !== 131) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -33557,7 +34874,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 193) { + if (arg.kind === 194) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -33583,7 +34900,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 === 83) { + if (heritageClause.token === 84) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -33596,7 +34913,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 106); + ts.Debug.assert(heritageClause.token === 107); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -33611,14 +34928,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 83) { + if (heritageClause.token === 84) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 106); + ts.Debug.assert(heritageClause.token === 107); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } checkGrammarHeritageClause(heritageClause); @@ -33627,19 +34944,19 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 140) { + if (node.kind !== 141) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 187 && computedPropertyName.expression.operatorToken.kind === 24) { + if (computedPropertyName.expression.kind === 188 && computedPropertyName.expression.operatorToken.kind === 25) { 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 === 220 || - node.kind === 179 || - node.kind === 147); + ts.Debug.assert(node.kind === 221 || + node.kind === 180 || + node.kind === 148); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -33651,7 +34968,7 @@ var ts; } } } - function checkGrammarForInvalidQuestionMark(node, questionToken, message) { + function checkGrammarForInvalidQuestionMark(questionToken, message) { if (questionToken) { return grammarErrorOnNode(questionToken, message); } @@ -33665,7 +34982,7 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; var name_24 = prop.name; - if (name_24.kind === 140) { + if (name_24.kind === 141) { checkGrammarComputedPropertyName(name_24); } if (prop.kind === 254 && !inDestructuring && prop.objectAssignmentInitializer) { @@ -33674,26 +34991,26 @@ var ts; if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (mod.kind !== 118 || prop.kind !== 147) { + if (mod.kind !== 119 || prop.kind !== 148) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } } var currentKind = void 0; if (prop.kind === 253 || prop.kind === 254) { - checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); + checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name_24.kind === 8) { checkGrammarNumericLiteral(name_24); } currentKind = Property; } - else if (prop.kind === 147) { + else if (prop.kind === 148) { currentKind = Property; } - else if (prop.kind === 149) { + else if (prop.kind === 150) { currentKind = GetAccessor; } - else if (prop.kind === 150) { + else if (prop.kind === 151) { currentKind = SetAccessor; } else { @@ -33750,7 +35067,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 219) { + if (forInOrOfStatement.initializer.kind === 220) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -33758,20 +35075,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 207 + var diagnostic = forInOrOfStatement.kind === 208 ? 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 = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 207 + var diagnostic = forInOrOfStatement.kind === 208 ? 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 === 207 + var diagnostic = forInOrOfStatement.kind === 208 ? 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); @@ -33795,11 +35112,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 149 ? + return grammarErrorOnNode(accessor.name, kind === 150 ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 150) { + else if (kind === 151) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -33818,10 +35135,10 @@ var ts; } } function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 149 ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 150 ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 149 ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 150 ? 1 : 2)) { return ts.getThisParameter(accessor); } } @@ -33836,8 +35153,8 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 171) { - if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { + if (node.parent.kind === 172) { + if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { return true; } else if (node.body === undefined) { @@ -33852,10 +35169,10 @@ 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 === 222) { + else if (node.parent.kind === 223) { 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 === 159) { + else if (node.parent.kind === 160) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } @@ -33866,9 +35183,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 214: + case 215: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 209 + var isMisplacedContinueLabel = node.kind === 210 && !ts.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); @@ -33876,8 +35193,8 @@ var ts; return false; } break; - case 213: - if (node.kind === 210 && !node.label) { + case 214: + if (node.kind === 211 && !node.label) { return false; } break; @@ -33890,13 +35207,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 210 + var message = node.kind === 211 ? 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 === 210 + var message = node.kind === 211 ? 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); @@ -33908,7 +35225,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 === 168 || node.name.kind === 167) { + if (node.name.kind === 169 || node.name.kind === 168) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -33918,11 +35235,11 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 || expr.kind === 8 || - expr.kind === 185 && expr.operator === 36 && + expr.kind === 186 && expr.operator === 37 && expr.operand.kind === 8; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 207 && node.parent.parent.kind !== 208) { + if (node.parent.parent.kind !== 208 && node.parent.parent.kind !== 209) { if (ts.isInAmbientContext(node)) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -33953,8 +35270,8 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 69) { - if (name.originalKeywordKind === 108) { + if (name.kind === 70) { + if (name.originalKeywordKind === 109) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -33979,15 +35296,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 203: case 204: case 205: - case 212: case 206: + case 213: case 207: case 208: + case 209: return false; - case 214: + case 215: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -34042,7 +35359,7 @@ var ts; return true; } } - else if (node.parent.kind === 222) { + else if (node.parent.kind === 223) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -34050,7 +35367,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 159) { + else if (node.parent.kind === 160) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -34063,13 +35380,13 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 222 || - node.kind === 223 || + if (node.kind === 223 || + node.kind === 224 || + node.kind === 231 || node.kind === 230 || - node.kind === 229 || + node.kind === 237 || node.kind === 236 || - node.kind === 235 || - node.kind === 228 || + node.kind === 229 || ts.getModifierFlags(node) & (2 | 1 | 512)) { return false; } @@ -34078,7 +35395,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 === 200) { + if (ts.isDeclaration(decl) || decl.kind === 201) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -34097,7 +35414,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 === 199 || node.parent.kind === 226 || node.parent.kind === 256) { + if (node.parent.kind === 200 || node.parent.kind === 227 || node.parent.kind === 256) { 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); @@ -34136,46 +35453,46 @@ var ts; (function (ts) { ; var nodeEdgeTraversalMap = ts.createMap((_a = {}, - _a[139] = [ + _a[140] = [ { name: "left", test: ts.isEntityName }, { name: "right", test: ts.isIdentifier } ], - _a[143] = [ + _a[144] = [ { name: "expression", test: ts.isLeftHandSideExpression } ], - _a[177] = [ + _a[178] = [ { name: "type", test: ts.isTypeNode }, { name: "expression", test: ts.isUnaryExpression } ], - _a[195] = [ + _a[196] = [ { name: "expression", test: ts.isExpression }, { name: "type", test: ts.isTypeNode } ], - _a[196] = [ + _a[197] = [ { name: "expression", test: ts.isLeftHandSideExpression } ], - _a[224] = [ + _a[225] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "members", test: ts.isEnumMember } ], - _a[225] = [ + _a[226] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isModuleName }, { name: "body", test: ts.isModuleBody } ], - _a[226] = [ + _a[227] = [ { name: "statements", test: ts.isStatement } ], - _a[229] = [ + _a[230] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "moduleReference", test: ts.isModuleReference } ], - _a[240] = [ + _a[241] = [ { name: "expression", test: ts.isExpression, optional: true } ], _a[255] = [ @@ -34191,41 +35508,41 @@ var ts; return initial; } var kind = node.kind; - if ((kind > 0 && kind <= 138)) { + if ((kind > 0 && kind <= 139)) { return initial; } - if ((kind >= 154 && kind <= 166)) { + if ((kind >= 155 && kind <= 167)) { return initial; } var result = initial; switch (node.kind) { - case 198: - case 201: - case 193: - case 217: + case 199: + case 202: + case 194: + case 218: case 287: break; - case 140: + case 141: result = reduceNode(node.expression, f, result); break; - case 142: - result = ts.reduceLeft(node.decorators, f, result); - result = ts.reduceLeft(node.modifiers, f, result); - result = reduceNode(node.name, f, result); - result = reduceNode(node.type, f, result); - result = reduceNode(node.initializer, f, result); - break; case 143: - result = reduceNode(node.expression, f, result); - break; - case 145: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.initializer, f, result); break; - case 147: + case 144: + result = reduceNode(node.expression, f, result); + break; + case 146: + result = ts.reduceLeft(node.decorators, f, result); + result = ts.reduceLeft(node.modifiers, f, result); + result = reduceNode(node.name, f, result); + result = reduceNode(node.type, f, result); + result = reduceNode(node.initializer, f, result); + break; + case 148: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -34234,53 +35551,48 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 148: - result = ts.reduceLeft(node.modifiers, f, result); - result = ts.reduceLeft(node.parameters, f, result); - result = reduceNode(node.body, f, result); - break; case 149: - result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); - result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.parameters, f, result); - result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; case 150: + result = ts.reduceLeft(node.decorators, f, result); + result = ts.reduceLeft(node.modifiers, f, result); + result = reduceNode(node.name, f, result); + result = ts.reduceLeft(node.parameters, f, result); + result = reduceNode(node.type, f, result); + result = reduceNode(node.body, f, result); + break; + case 151: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.parameters, f, result); result = reduceNode(node.body, f, result); break; - case 167: case 168: + case 169: result = ts.reduceLeft(node.elements, f, result); break; - case 169: + case 170: result = reduceNode(node.propertyName, f, result); result = reduceNode(node.name, f, result); result = reduceNode(node.initializer, f, result); break; - case 170: + case 171: result = ts.reduceLeft(node.elements, f, result); break; - case 171: - result = ts.reduceLeft(node.properties, f, result); - break; case 172: - result = reduceNode(node.expression, f, result); - result = reduceNode(node.name, f, result); + result = ts.reduceLeft(node.properties, f, result); break; case 173: result = reduceNode(node.expression, f, result); - result = reduceNode(node.argumentExpression, f, result); + result = reduceNode(node.name, f, result); break; case 174: result = reduceNode(node.expression, f, result); - result = ts.reduceLeft(node.typeArguments, f, result); - result = ts.reduceLeft(node.arguments, f, result); + result = reduceNode(node.argumentExpression, f, result); break; case 175: result = reduceNode(node.expression, f, result); @@ -34288,10 +35600,15 @@ var ts; result = ts.reduceLeft(node.arguments, f, result); break; case 176: + result = reduceNode(node.expression, f, result); + result = ts.reduceLeft(node.typeArguments, f, result); + result = ts.reduceLeft(node.arguments, f, result); + break; + case 177: result = reduceNode(node.tag, f, result); result = reduceNode(node.template, f, result); break; - case 179: + case 180: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.typeParameters, f, result); @@ -34299,126 +35616,126 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 180: + case 181: result = ts.reduceLeft(node.modifiers, f, result); result = ts.reduceLeft(node.typeParameters, f, result); result = ts.reduceLeft(node.parameters, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 178: - case 181: + case 179: case 182: case 183: case 184: - case 190: + case 185: case 191: - case 196: + case 192: + case 197: result = reduceNode(node.expression, f, result); break; - case 185: case 186: + case 187: result = reduceNode(node.operand, f, result); break; - case 187: + case 188: result = reduceNode(node.left, f, result); result = reduceNode(node.right, f, result); break; - case 188: + case 189: result = reduceNode(node.condition, f, result); result = reduceNode(node.whenTrue, f, result); result = reduceNode(node.whenFalse, f, result); break; - case 189: + case 190: result = reduceNode(node.head, f, result); result = ts.reduceLeft(node.templateSpans, f, result); break; - case 192: + case 193: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.typeParameters, f, result); result = ts.reduceLeft(node.heritageClauses, f, result); result = ts.reduceLeft(node.members, f, result); break; - case 194: + case 195: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); break; - case 197: + case 198: result = reduceNode(node.expression, f, result); result = reduceNode(node.literal, f, result); break; - case 199: + case 200: result = ts.reduceLeft(node.statements, f, result); break; - case 200: + case 201: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.declarationList, f, result); break; - case 202: + case 203: result = reduceNode(node.expression, f, result); break; - case 203: + case 204: result = reduceNode(node.expression, f, result); result = reduceNode(node.thenStatement, f, result); result = reduceNode(node.elseStatement, f, result); break; - case 204: - result = reduceNode(node.statement, f, result); - result = reduceNode(node.expression, f, result); - break; case 205: - case 212: - result = reduceNode(node.expression, f, result); result = reduceNode(node.statement, f, result); + result = reduceNode(node.expression, f, result); break; case 206: + case 213: + result = reduceNode(node.expression, f, result); + result = reduceNode(node.statement, f, result); + break; + case 207: result = reduceNode(node.initializer, f, result); result = reduceNode(node.condition, f, result); result = reduceNode(node.incrementor, f, result); result = reduceNode(node.statement, f, result); break; - case 207: case 208: + case 209: result = reduceNode(node.initializer, f, result); result = reduceNode(node.expression, f, result); result = reduceNode(node.statement, f, result); break; - case 211: - case 215: + case 212: + case 216: result = reduceNode(node.expression, f, result); break; - case 213: + case 214: result = reduceNode(node.expression, f, result); result = reduceNode(node.caseBlock, f, result); break; - case 214: + case 215: result = reduceNode(node.label, f, result); result = reduceNode(node.statement, f, result); break; - case 216: + case 217: result = reduceNode(node.tryBlock, f, result); result = reduceNode(node.catchClause, f, result); result = reduceNode(node.finallyBlock, f, result); break; - case 218: + case 219: result = reduceNode(node.name, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.initializer, f, result); break; - case 219: - result = ts.reduceLeft(node.declarations, f, result); - break; case 220: - result = ts.reduceLeft(node.decorators, f, result); - result = ts.reduceLeft(node.modifiers, f, result); - result = reduceNode(node.name, f, result); - result = ts.reduceLeft(node.typeParameters, f, result); - result = ts.reduceLeft(node.parameters, f, result); - result = reduceNode(node.type, f, result); - result = reduceNode(node.body, f, result); + result = ts.reduceLeft(node.declarations, f, result); break; case 221: + result = ts.reduceLeft(node.decorators, f, result); + result = ts.reduceLeft(node.modifiers, f, result); + result = reduceNode(node.name, f, result); + result = ts.reduceLeft(node.typeParameters, f, result); + result = ts.reduceLeft(node.parameters, f, result); + result = reduceNode(node.type, f, result); + result = reduceNode(node.body, f, result); + break; + case 222: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -34426,49 +35743,49 @@ var ts; result = ts.reduceLeft(node.heritageClauses, f, result); result = ts.reduceLeft(node.members, f, result); break; - case 227: + case 228: result = ts.reduceLeft(node.clauses, f, result); break; - case 230: + case 231: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.importClause, f, result); result = reduceNode(node.moduleSpecifier, f, result); break; - case 231: + case 232: result = reduceNode(node.name, f, result); result = reduceNode(node.namedBindings, f, result); break; - case 232: - result = reduceNode(node.name, f, result); - break; case 233: - case 237: - result = ts.reduceLeft(node.elements, f, result); + result = reduceNode(node.name, f, result); break; case 234: case 238: + result = ts.reduceLeft(node.elements, f, result); + break; + case 235: + case 239: result = reduceNode(node.propertyName, f, result); result = reduceNode(node.name, f, result); break; - case 235: + case 236: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.expression, f, result); break; - case 236: + case 237: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.exportClause, f, result); result = reduceNode(node.moduleSpecifier, f, result); break; - case 241: + case 242: result = reduceNode(node.openingElement, f, result); result = ts.reduceLeft(node.children, f, result); result = reduceNode(node.closingElement, f, result); break; - case 242: case 243: + case 244: result = reduceNode(node.tagName, f, result); result = ts.reduceLeft(node.attributes, f, result); break; @@ -34611,153 +35928,153 @@ var ts; return undefined; } var kind = node.kind; - if ((kind > 0 && kind <= 138)) { + if ((kind > 0 && kind <= 139)) { return node; } - if ((kind >= 154 && kind <= 166)) { + if ((kind >= 155 && kind <= 167)) { return node; } switch (node.kind) { - case 198: - case 201: - case 193: - case 217: - return node; - case 140: - return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); - case 142: - return ts.updateParameterDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 145: - return ts.updateProperty(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 147: - return ts.updateMethod(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); - case 148: - return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); - case 149: - return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); - case 150: - return ts.updateSetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); - case 167: - return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); - case 168: - return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); - case 169: - return ts.updateBindingElement(node, visitNode(node.propertyName, visitor, ts.isPropertyName, true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 170: - return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); - case 171: - return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 172: - return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 173: - return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 174: - return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); - case 175: - return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); - case 176: - return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 178: - return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 179: - return ts.updateFunctionExpression(node, visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); - case 180: - return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isConciseBody, true), context.endLexicalEnvironment())); - case 181: - return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 182: - return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 183: - return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 184: - return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 187: - return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); - case 185: - return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 186: - return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 188: - return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); - case 189: - return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); - case 190: - return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); - case 191: - return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 192: - return ts.updateClassExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 194: - return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 197: - return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); case 199: - return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 200: - return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); case 202: - return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 203: - return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, true, liftToBlock)); - case 204: - return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 205: - return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 206: - return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 207: - return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 208: - return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 209: - return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, true)); - case 210: - return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); - case 211: - return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, true)); - case 212: - return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 213: - return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 214: - return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 215: - return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 216: - return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause, true), visitNode(node.finallyBlock, visitor, ts.isBlock, true)); + case 194: case 218: - return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); + return node; + case 141: + return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); + case 143: + return ts.updateParameterDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); + case 146: + return ts.updateProperty(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); + case 148: + return ts.updateMethod(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + case 149: + return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + case 150: + return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + case 151: + return ts.updateSetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + case 168: + return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); + case 169: + return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); + case 170: + return ts.updateBindingElement(node, visitNode(node.propertyName, visitor, ts.isPropertyName, true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, true)); + case 171: + return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); + case 172: + return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); + case 173: + return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); + case 174: + return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); + case 175: + return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); + case 176: + return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); + case 177: + return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); + case 179: + return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); + case 180: + return ts.updateFunctionExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + case 181: + return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isConciseBody, true), context.endLexicalEnvironment())); + case 182: + return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); + case 183: + return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); + case 184: + return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); + case 185: + return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); + case 188: + return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); + case 186: + return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); + case 187: + return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); + case 189: + return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); + case 190: + return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); + case 191: + return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); + case 192: + return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); + case 193: + return ts.updateClassExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); + case 195: + return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); + case 198: + return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); + case 200: + return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); + case 201: + return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); + case 203: + return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); + case 204: + return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, true, liftToBlock)); + case 205: + return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); + case 206: + return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 207: + return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 208: + return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 209: + return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 210: + return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, true)); + case 211: + return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); + case 212: + return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, true)); + case 213: + return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 214: + return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); + case 215: + return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 216: + return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); + case 217: + return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause, true), visitNode(node.finallyBlock, visitor, ts.isBlock, true)); case 219: - return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); + return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); case 220: - return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); case 221: + return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + case 222: return ts.updateClassDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 227: + case 228: return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 230: - return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); case 231: - return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true)); + return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); case 232: - return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true)); case 233: - return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); + return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); case 234: - return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); case 235: - return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); case 236: - return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, true)); + return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); case 237: - return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); + return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, true)); case 238: + return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); + case 239: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); - case 241: - return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); case 242: - return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); + return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); case 243: + return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); + case 244: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); case 245: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); @@ -34858,67 +36175,67 @@ var ts; return transformFlags | aggregateTransformFlagsForNode(child); } function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 154 && kind <= 166) { + if (kind >= 155 && kind <= 167) { return -3; } switch (kind) { - case 174: case 175: - case 170: - return 537133909; - case 225: - return 546335573; - case 142: - return 538968917; + case 176: + case 171: + return 537922901; + case 226: + return 574729557; + case 143: + return 545262933; + case 181: + return 592227669; case 180: - return 550710101; - case 179: - case 220: - return 550726485; - case 219: - return 538968917; case 221: - case 192: - return 537590613; - case 148: - return 550593365; - case 147: + return 592293205; + case 220: + return 545262933; + case 222: + case 193: + return 539749717; case 149: + return 591760725; + case 148: case 150: - return 550593365; - case 117: - case 130: - case 127: - case 132: - case 120: - case 133: - case 103: - case 141: - case 144: - case 146: case 151: + return 591760725; + case 118: + case 131: + case 128: + case 133: + case 121: + case 134: + case 104: + case 142: + case 145: + case 147: case 152: case 153: - case 222: + case 154: case 223: + case 224: return -3; - case 171: - return 537430869; + case 172: + return 539110741; default: - return 536871765; + return 536874325; } } var Debug; (function (Debug) { Debug.failNotOptional = Debug.shouldAssert(1) ? function (message) { return Debug.assert(false, message || "Node not optional."); } - : function (message) { }; + : function () { }; Debug.failBadSyntaxKind = Debug.shouldAssert(1) ? function (node, message) { return Debug.assert(false, message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " was unexpected."; }); } - : function (node, message) { }; + : function () { }; Debug.assertNode = Debug.shouldAssert(1) ? function (node, test, message) { return Debug.assert(test === undefined || test(node), message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }); } - : function (node, test, message) { }; + : function () { }; function getFunctionName(func) { if (typeof func !== "function") { return ""; @@ -34956,7 +36273,7 @@ var ts; else if (ts.nodeIsSynthesized(node)) { location = value; } - flattenDestructuring(context, node, value, location, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, location, emitAssignment, emitTempVariableAssignment, visitor); if (needsValue) { expressions.push(value); } @@ -34976,9 +36293,9 @@ var ts; } } ts.flattenDestructuringAssignment = flattenDestructuringAssignment; - function flattenParameterDestructuring(context, node, value, visitor) { + function flattenParameterDestructuring(node, value, visitor) { var declarations = []; - flattenDestructuring(context, node, value, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, visitor); return declarations; function emitAssignment(name, value, location) { var declaration = ts.createVariableDeclaration(name, undefined, value, location); @@ -34993,10 +36310,10 @@ var ts; } } ts.flattenParameterDestructuring = flattenParameterDestructuring; - function flattenVariableDestructuring(context, node, value, visitor, recordTempVariable) { + function flattenVariableDestructuring(node, value, visitor, recordTempVariable) { var declarations = []; var pendingAssignments; - flattenDestructuring(context, node, value, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, visitor); return declarations; function emitAssignment(name, value, location, original) { if (pendingAssignments) { @@ -35028,9 +36345,9 @@ var ts; } } ts.flattenVariableDestructuring = flattenVariableDestructuring; - function flattenVariableDestructuringToExpression(context, node, recordTempVariable, nameSubstitution, visitor) { + function flattenVariableDestructuringToExpression(node, recordTempVariable, nameSubstitution, visitor) { var pendingAssignments = []; - flattenDestructuring(context, node, undefined, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, undefined, node, emitAssignment, emitTempVariableAssignment, visitor); var expression = ts.inlineExpressions(pendingAssignments); ts.aggregateTransformFlags(expression); return expression; @@ -35052,7 +36369,7 @@ var ts; } } ts.flattenVariableDestructuringToExpression = flattenVariableDestructuringToExpression; - function flattenDestructuring(context, root, value, location, emitAssignment, emitTempVariableAssignment, visitor) { + function flattenDestructuring(root, value, location, emitAssignment, emitTempVariableAssignment, visitor) { if (value && visitor) { value = ts.visitNode(value, visitor, ts.isExpression); } @@ -35073,7 +36390,7 @@ var ts; } target = bindingTarget.name; } - else if (ts.isBinaryExpression(bindingTarget) && bindingTarget.operatorToken.kind === 56) { + else if (ts.isBinaryExpression(bindingTarget) && bindingTarget.operatorToken.kind === 57) { var initializer = visitor ? ts.visitNode(bindingTarget.right, visitor, ts.isExpression) : bindingTarget.right; @@ -35083,10 +36400,10 @@ var ts; else { target = bindingTarget; } - if (target.kind === 171) { + if (target.kind === 172) { emitObjectLiteralAssignment(target, value, location); } - else if (target.kind === 170) { + else if (target.kind === 171) { emitArrayLiteralAssignment(target, value, location); } else { @@ -35118,8 +36435,8 @@ var ts; } for (var i = 0; i < numElements; i++) { var e = elements[i]; - if (e.kind !== 193) { - if (e.kind !== 191) { + if (e.kind !== 194) { + if (e.kind !== 192) { emitDestructuringAssignment(e, ts.createElementAccess(value, ts.createLiteral(i)), e); } else if (i === numElements - 1) { @@ -35148,7 +36465,7 @@ var ts; if (ts.isOmittedExpression(element)) { continue; } - else if (name.kind === 167) { + else if (name.kind === 168) { var propName = element.propertyName || element.name; emitBindingElement(element, createDestructuringPropertyAccess(value, propName)); } @@ -35168,7 +36485,7 @@ var ts; } function createDefaultValueCheck(value, defaultValue, location) { value = ensureIdentifier(value, true, location, emitTempVariableAssignment); - return ts.createConditional(ts.createStrictEquality(value, ts.createVoidZero()), ts.createToken(53), defaultValue, ts.createToken(54), value); + return ts.createConditional(ts.createStrictEquality(value, ts.createVoidZero()), ts.createToken(54), defaultValue, ts.createToken(55), value); } function createDestructuringPropertyAccess(expression, propertyName) { if (ts.isComputedPropertyName(propertyName)) { @@ -35206,6 +36523,12 @@ var ts; var ts; (function (ts) { var USE_NEW_TYPE_METADATA_FORMAT = false; + var TypeScriptSubstitutionFlags; + (function (TypeScriptSubstitutionFlags) { + TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["ClassAliases"] = 1] = "ClassAliases"; + TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["NamespaceExports"] = 2] = "NamespaceExports"; + TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["NonQualifiedEnumMembers"] = 8] = "NonQualifiedEnumMembers"; + })(TypeScriptSubstitutionFlags || (TypeScriptSubstitutionFlags = {})); function transformTypeScript(context) { var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); @@ -35216,8 +36539,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(172); context.enableSubstitution(173); + context.enableSubstitution(174); var currentSourceFile; var currentNamespace; var currentNamespaceContainerName; @@ -35227,7 +36550,6 @@ var ts; var enabledSubstitutions; var classAliases; var applicableSubstitutions; - var currentSuperContainer; return transformSourceFile; function transformSourceFile(node) { if (ts.isDeclarationFile(node)) { @@ -35261,15 +36583,32 @@ var ts; } return node; } + function sourceElementVisitor(node) { + return saveStateAndInvoke(node, sourceElementVisitorWorker); + } + function sourceElementVisitorWorker(node) { + switch (node.kind) { + case 231: + return visitImportDeclaration(node); + case 230: + return visitImportEqualsDeclaration(node); + case 236: + return visitExportAssignment(node); + case 237: + return visitExportDeclaration(node); + default: + return visitorWorker(node); + } + } function namespaceElementVisitor(node) { return saveStateAndInvoke(node, namespaceElementVisitorWorker); } function namespaceElementVisitorWorker(node) { - if (node.kind === 236 || - node.kind === 230 || + if (node.kind === 237 || node.kind === 231 || - (node.kind === 229 && - node.moduleReference.kind === 240)) { + node.kind === 232 || + (node.kind === 230 && + node.moduleReference.kind === 241)) { return undefined; } else if (node.transformFlags & 1 || ts.hasModifier(node, 1)) { @@ -35285,15 +36624,15 @@ var ts; } function classElementVisitorWorker(node) { switch (node.kind) { - case 148: - return undefined; - case 145: - case 153: case 149: + return undefined; + case 146: + case 154: case 150: - case 147: + case 151: + case 148: return visitorWorker(node); - case 198: + case 199: return node; default: ts.Debug.failBadSyntaxKind(node); @@ -35305,84 +36644,87 @@ var ts; return ts.createNotEmittedStatement(node); } switch (node.kind) { - case 82: - case 77: + case 83: + case 78: return currentNamespace ? undefined : node; - case 112: - case 110: + case 113: case 111: - case 115: - case 118: - case 74: - case 122: - case 128: - case 160: + case 112: + case 116: + case 75: + case 123: + case 129: case 161: - case 159: - case 154: - case 141: - case 117: - case 120: - case 132: - case 130: - case 127: - case 103: - case 133: - case 157: - case 156: - case 158: - case 155: case 162: + case 160: + case 155: + case 142: + case 118: + case 121: + case 133: + case 131: + case 128: + case 104: + case 134: + case 158: + case 157: + case 159: + case 156: case 163: case 164: case 165: case 166: - case 153: - case 143: + case 167: + case 154: + case 144: + case 224: + case 146: + case 149: + return visitConstructor(node); case 223: - case 145: - case 148: - return undefined; - case 222: return ts.createNotEmittedStatement(node); - case 221: + case 222: return visitClassDeclaration(node); - case 192: + case 193: return visitClassExpression(node); case 251: return visitHeritageClause(node); - case 194: - return visitExpressionWithTypeArguments(node); - case 147: - return visitMethodDeclaration(node); - case 149: - return visitGetAccessor(node); - case 150: - return visitSetAccessor(node); - case 220: - return visitFunctionDeclaration(node); - case 179: - return visitFunctionExpression(node); - case 180: - return visitArrowFunction(node); - case 142: - return visitParameter(node); - case 178: - return visitParenthesizedExpression(node); - case 177: case 195: - return visitAssertionExpression(node); + return visitExpressionWithTypeArguments(node); + case 148: + return visitMethodDeclaration(node); + case 150: + return visitGetAccessor(node); + case 151: + return visitSetAccessor(node); + case 221: + return visitFunctionDeclaration(node); + case 180: + return visitFunctionExpression(node); + case 181: + return visitArrowFunction(node); + case 143: + return visitParameter(node); + case 179: + return visitParenthesizedExpression(node); + case 178: case 196: + return visitAssertionExpression(node); + case 175: + return visitCallExpression(node); + case 176: + return visitNewExpression(node); + case 197: return visitNonNullExpression(node); - case 224: - return visitEnumDeclaration(node); - case 184: - return visitAwaitExpression(node); - case 200: - return visitVariableStatement(node); case 225: + return visitEnumDeclaration(node); + case 201: + return visitVariableStatement(node); + case 219: + return visitVariableDeclaration(node); + case 226: return visitModuleDeclaration(node); - case 229: + case 230: return visitImportEqualsDeclaration(node); default: ts.Debug.failBadSyntaxKind(node); @@ -35392,14 +36734,14 @@ var ts; function onBeforeVisitNode(node) { switch (node.kind) { case 256: + case 228: case 227: - case 226: - case 199: + case 200: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; + case 222: case 221: - case 220: if (ts.hasModifier(node, 2)) { break; } @@ -35424,14 +36766,14 @@ var ts; externalHelpersModuleImport.flags &= ~8; statements.push(externalHelpersModuleImport); currentSourceFileExternalHelpersModuleName = externalHelpersModuleName; - ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); + ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); currentSourceFileExternalHelpersModuleName = undefined; node = ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); node.externalHelpersModuleName = externalHelpersModuleName; } else { - node = ts.visitEachChild(node, visitor, context); + node = ts.visitEachChild(node, sourceElementVisitor, context); } ts.setEmitFlags(node, 1 | ts.getEmitFlags(node)); return node; @@ -35471,7 +36813,7 @@ var ts; classAlias = addClassDeclarationHeadWithDecorators(statements, node, name, hasExtendsClause); } if (staticProperties.length) { - addInitializedPropertyStatements(statements, node, staticProperties, getLocalName(node, true)); + addInitializedPropertyStatements(statements, staticProperties, getLocalName(node, true)); } addClassElementDecorationStatements(statements, node, false); addClassElementDecorationStatements(statements, node, true); @@ -35517,7 +36859,7 @@ var ts; function visitClassExpression(node) { var staticProperties = getInitializedProperties(node, true); var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); - var members = transformClassMembers(node, heritageClauses !== undefined); + var members = transformClassMembers(node, ts.some(heritageClauses, function (c) { return c.token === 84; })); var classExpression = ts.setOriginalNode(ts.createClassExpression(undefined, node.name, undefined, heritageClauses, members, node), node); if (staticProperties.length > 0) { var expressions = []; @@ -35528,7 +36870,7 @@ var ts; } ts.setEmitFlags(classExpression, 524288 | ts.getEmitFlags(classExpression)); expressions.push(ts.startOnNewLine(ts.createAssignment(temp, classExpression))); - ts.addRange(expressions, generateInitializedPropertyExpressions(node, staticProperties, temp)); + ts.addRange(expressions, generateInitializedPropertyExpressions(staticProperties, temp)); expressions.push(ts.startOnNewLine(temp)); return ts.inlineExpressions(expressions); } @@ -35545,13 +36887,13 @@ var ts; } function transformConstructor(node, hasExtendsClause) { var hasInstancePropertyWithInitializer = ts.forEach(node.members, isInstanceInitializedProperty); - var hasParameterPropertyAssignments = node.transformFlags & 131072; + var hasParameterPropertyAssignments = node.transformFlags & 524288; var constructor = ts.getFirstConstructorWithBody(node); if (!hasInstancePropertyWithInitializer && !hasParameterPropertyAssignments) { return ts.visitEachChild(constructor, visitor, context); } var parameters = transformConstructorParameters(constructor); - var body = transformConstructorBody(node, constructor, hasExtendsClause, parameters); + var body = transformConstructorBody(node, constructor, hasExtendsClause); return ts.startOnNewLine(ts.setOriginalNode(ts.createConstructor(undefined, undefined, parameters, body, constructor || node), constructor)); } function transformConstructorParameters(constructor) { @@ -35559,7 +36901,7 @@ var ts; ? ts.visitNodes(constructor.parameters, visitor, ts.isParameter) : []; } - function transformConstructorBody(node, constructor, hasExtendsClause, parameters) { + function transformConstructorBody(node, constructor, hasExtendsClause) { var statements = []; var indexOfFirstStatement = 0; startLexicalEnvironment(); @@ -35572,7 +36914,7 @@ var ts; statements.push(ts.createStatement(ts.createCall(ts.createSuper(), undefined, [ts.createSpread(ts.createIdentifier("arguments"))]))); } var properties = getInitializedProperties(node, false); - addInitializedPropertyStatements(statements, node, properties, ts.createThis()); + addInitializedPropertyStatements(statements, properties, ts.createThis()); if (constructor) { ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement)); } @@ -35587,7 +36929,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 202 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 203 && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -35621,24 +36963,24 @@ var ts; return isInitializedProperty(member, false); } function isInitializedProperty(member, isStatic) { - return member.kind === 145 + return member.kind === 146 && isStatic === ts.hasModifier(member, 32) && member.initializer !== undefined; } - function addInitializedPropertyStatements(statements, node, properties, receiver) { + function addInitializedPropertyStatements(statements, properties, receiver) { for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) { var property = properties_7[_i]; - var statement = ts.createStatement(transformInitializedProperty(node, property, receiver)); + var statement = ts.createStatement(transformInitializedProperty(property, receiver)); ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property)); ts.setCommentRange(statement, property); statements.push(statement); } } - function generateInitializedPropertyExpressions(node, properties, receiver) { + function generateInitializedPropertyExpressions(properties, receiver) { var expressions = []; for (var _i = 0, properties_8 = properties; _i < properties_8.length; _i++) { var property = properties_8[_i]; - var expression = transformInitializedProperty(node, property, receiver); + var expression = transformInitializedProperty(property, receiver); expression.startsOnNewLine = true; ts.setSourceMapRange(expression, ts.moveRangePastModifiers(property)); ts.setCommentRange(expression, property); @@ -35646,7 +36988,7 @@ var ts; } return expressions; } - function transformInitializedProperty(node, property, receiver) { + function transformInitializedProperty(property, receiver) { var propertyName = visitPropertyNameOfClassElement(property); var initializer = ts.visitNode(property.initializer, visitor, ts.isExpression); var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, propertyName); @@ -35694,12 +37036,12 @@ var ts; } function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 149: case 150: + case 151: return getAllDecoratorsOfAccessors(node, member); - case 147: + case 148: return getAllDecoratorsOfMethod(member); - case 145: + case 146: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -35777,7 +37119,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, true); var descriptor = languageVersion > 0 - ? member.kind === 145 + ? member.kind === 146 ? ts.createVoidZero() : ts.createNull() : undefined; @@ -35865,43 +37207,43 @@ var ts; } function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 147 - || kind === 149 + return kind === 148 || kind === 150 - || kind === 145; + || kind === 151 + || kind === 146; } function shouldAddReturnTypeMetadata(node) { - return node.kind === 147; + return node.kind === 148; } function shouldAddParamTypesMetadata(node) { var kind = node.kind; - return kind === 221 - || kind === 192 - || kind === 147 - || kind === 149 - || kind === 150; + return kind === 222 + || kind === 193 + || kind === 148 + || kind === 150 + || kind === 151; } function serializeTypeOfNode(node) { switch (node.kind) { - case 145: - case 142: - case 149: - return serializeTypeNode(node.type); + case 146: + case 143: case 150: + return serializeTypeNode(node.type); + case 151: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 221: - case 192: - case 147: + case 222: + case 193: + case 148: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); } } function getRestParameterElementType(node) { - if (node && node.kind === 160) { + if (node && node.kind === 161) { return node.elementType; } - else if (node && node.kind === 155) { + else if (node && node.kind === 156) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -35947,52 +37289,52 @@ var ts; return ts.createIdentifier("Object"); } switch (node.kind) { - case 103: + case 104: return ts.createVoidZero(); - case 164: + case 165: return serializeTypeNode(node.type); - case 156: case 157: + case 158: return ts.createIdentifier("Function"); - case 160: case 161: + case 162: return ts.createIdentifier("Array"); - case 154: - case 120: + case 155: + case 121: return ts.createIdentifier("Boolean"); - case 132: + case 133: return ts.createIdentifier("String"); - case 166: + case 167: switch (node.literal.kind) { case 9: return ts.createIdentifier("String"); case 8: return ts.createIdentifier("Number"); - case 99: - case 84: + case 100: + case 85: return ts.createIdentifier("Boolean"); default: ts.Debug.failBadSyntaxKind(node.literal); break; } break; - case 130: + case 131: return ts.createIdentifier("Number"); - case 133: + case 134: return languageVersion < 2 ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 155: + case 156: return serializeTypeReferenceNode(node); + case 164: case 163: - case 162: { var unionOrIntersection = node; var serializedUnion = void 0; for (var _i = 0, _a = unionOrIntersection.types; _i < _a.length; _i++) { var typeNode = _a[_i]; var serializedIndividual = serializeTypeNode(typeNode); - if (serializedIndividual.kind !== 69) { + if (serializedIndividual.kind !== 70) { serializedUnion = undefined; break; } @@ -36009,10 +37351,10 @@ var ts; return serializedUnion; } } - case 158: case 159: - case 117: - case 165: + case 160: + case 118: + case 166: break; default: ts.Debug.failBadSyntaxKind(node); @@ -36053,7 +37395,7 @@ var ts; } function serializeEntityNameAsExpression(node, useFallback) { switch (node.kind) { - case 69: + case 70: var name_27 = ts.getMutableClone(node); name_27.flags &= ~8; name_27.original = undefined; @@ -36062,13 +37404,13 @@ var ts; return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_27), ts.createLiteral("undefined")), name_27); } return name_27; - case 139: + case 140: return serializeQualifiedNameAsExpression(node, useFallback); } } function serializeQualifiedNameAsExpression(node, useFallback) { var left; - if (node.left.kind === 69) { + if (node.left.kind === 70) { left = serializeEntityNameAsExpression(node.left, useFallback); } else if (useFallback) { @@ -36081,7 +37423,7 @@ var ts; return ts.createPropertyAccess(left, node.right); } function getGlobalSymbolNameWithFallback() { - return ts.createConditional(ts.createStrictEquality(ts.createTypeOf(ts.createIdentifier("Symbol")), ts.createLiteral("function")), ts.createToken(53), ts.createIdentifier("Symbol"), ts.createToken(54), ts.createIdentifier("Object")); + return ts.createConditional(ts.createStrictEquality(ts.createTypeOf(ts.createIdentifier("Symbol")), ts.createLiteral("function")), ts.createToken(54), ts.createIdentifier("Symbol"), ts.createToken(55), ts.createIdentifier("Object")); } function getExpressionForPropertyName(member, generateNameForComputedPropertyName) { var name = member.name; @@ -36113,9 +37455,9 @@ var ts; } } function visitHeritageClause(node) { - if (node.token === 83) { + if (node.token === 84) { var types = ts.visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments, 0, 1); - return ts.createHeritageClause(83, types, node); + return ts.createHeritageClause(84, types, node); } return undefined; } @@ -36126,6 +37468,12 @@ var ts; function shouldEmitFunctionLikeDeclaration(node) { return !ts.nodeIsMissing(node.body); } + function visitConstructor(node) { + if (!shouldEmitFunctionLikeDeclaration(node)) { + return undefined; + } + return ts.visitEachChild(node, visitor, context); + } function visitMethodDeclaration(node) { if (!shouldEmitFunctionLikeDeclaration(node)) { return undefined; @@ -36176,36 +37524,33 @@ var ts; if (ts.nodeIsMissing(node.body)) { return ts.createOmittedExpression(); } - var func = ts.createFunctionExpression(node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); + var func = ts.createFunctionExpression(ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); ts.setOriginalNode(func, node); return func; } function visitArrowFunction(node) { - var func = ts.createArrowFunction(undefined, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, node.equalsGreaterThanToken, transformConciseBody(node), node); + var func = ts.createArrowFunction(ts.visitNodes(node.modifiers, visitor, ts.isModifier), undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, node.equalsGreaterThanToken, transformConciseBody(node), node); ts.setOriginalNode(func, node); return func; } function transformFunctionBody(node) { - if (ts.isAsyncFunctionLike(node)) { - return transformAsyncFunctionBody(node); - } return transformFunctionBodyWorker(node.body); } function transformFunctionBodyWorker(body, start) { if (start === void 0) { start = 0; } var savedCurrentScope = currentScope; + var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName; currentScope = body; + currentScopeFirstDeclarationsOfName = ts.createMap(); startLexicalEnvironment(); var statements = ts.visitNodes(body.statements, visitor, ts.isStatement, start); var visited = ts.updateBlock(body, statements); var declarations = endLexicalEnvironment(); currentScope = savedCurrentScope; + currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; return ts.mergeFunctionBodyLexicalEnvironment(visited, declarations); } function transformConciseBody(node) { - if (ts.isAsyncFunctionLike(node)) { - return transformAsyncFunctionBody(node); - } return transformConciseBodyWorker(node.body, false); } function transformConciseBodyWorker(body, forceBlockFunctionBody) { @@ -36227,42 +37572,6 @@ var ts; } } } - function getPromiseConstructor(type) { - var typeName = ts.getEntityNameFromTypeNode(type); - if (typeName && ts.isEntityName(typeName)) { - var serializationKind = resolver.getTypeReferenceSerializationKind(typeName); - if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue - || serializationKind === ts.TypeReferenceSerializationKind.Unknown) { - return typeName; - } - } - return undefined; - } - function transformAsyncFunctionBody(node) { - var promiseConstructor = languageVersion < 2 ? getPromiseConstructor(node.type) : undefined; - var isArrowFunction = node.kind === 180; - var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0; - if (!isArrowFunction) { - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.body.statements, false, visitor); - statements.push(ts.createReturn(ts.createAwaiterHelper(currentSourceFileExternalHelpersModuleName, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body, statementOffset)))); - var block = ts.createBlock(statements, node.body, true); - if (languageVersion >= 2) { - if (resolver.getNodeCheckFlags(node) & 4096) { - enableSubstitutionForAsyncMethodsWithSuper(); - ts.setEmitFlags(block, 8); - } - else if (resolver.getNodeCheckFlags(node) & 2048) { - enableSubstitutionForAsyncMethodsWithSuper(); - ts.setEmitFlags(block, 4); - } - } - return block; - } - else { - return ts.createAwaiterHelper(currentSourceFileExternalHelpersModuleName, hasLexicalArguments, promiseConstructor, transformConciseBodyWorker(node.body, true)); - } - } function visitParameter(node) { if (ts.parameterIsThisKeyword(node)) { return undefined; @@ -36289,14 +37598,14 @@ var ts; function transformInitializedVariable(node) { var name = node.name; if (ts.isBindingPattern(name)) { - return ts.flattenVariableDestructuringToExpression(context, node, hoistVariableDeclaration, getNamespaceMemberNameWithSourceMapsAndWithoutComments, visitor); + return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, getNamespaceMemberNameWithSourceMapsAndWithoutComments, visitor); } else { return ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(name), ts.visitNode(node.initializer, visitor, ts.isExpression), node); } } - function visitAwaitExpression(node) { - return ts.setOriginalNode(ts.createYield(undefined, ts.visitNode(node.expression, visitor, ts.isExpression), node), node); + function visitVariableDeclaration(node) { + return ts.updateVariableDeclaration(node, ts.visitNode(node.name, visitor, ts.isBindingName), undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)); } function visitParenthesizedExpression(node) { var innerExpression = ts.skipOuterExpressions(node.expression, ~2); @@ -36314,6 +37623,12 @@ var ts; var expression = ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression); return ts.createPartiallyEmittedExpression(expression, node); } + function visitCallExpression(node) { + return ts.updateCall(node, ts.visitNode(node.expression, visitor, ts.isExpression), undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression)); + } + function visitNewExpression(node) { + return ts.updateNew(node, ts.visitNode(node.expression, visitor, ts.isExpression), undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression)); + } function shouldEmitEnumDeclaration(node) { return !ts.isConst(node) || compilerOptions.preserveConstEnums @@ -36345,7 +37660,7 @@ var ts; var parameterName = getNamespaceParameterName(node); var containerName = getNamespaceContainerName(node); var exportName = getExportName(node); - var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, transformEnumBody(node, containerName)), undefined, [ts.createLogicalOr(exportName, ts.createAssignment(exportName, ts.createObjectLiteral()))]), node); + var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, transformEnumBody(node, containerName)), undefined, [ts.createLogicalOr(exportName, ts.createAssignment(exportName, ts.createObjectLiteral()))]), node); ts.setOriginalNode(enumStatement, node); ts.setEmitFlags(enumStatement, emitFlags); statements.push(enumStatement); @@ -36388,7 +37703,7 @@ var ts; } function isES6ExportedDeclaration(node) { return isExternalModuleExport(node) - && moduleKind === ts.ModuleKind.ES6; + && moduleKind === ts.ModuleKind.ES2015; } function recordEmittedDeclarationInScope(node) { var name = node.symbol && node.symbol.name; @@ -36420,7 +37735,7 @@ var ts; ts.createVariableDeclaration(getDeclarationName(node, false, true)) ]); ts.setOriginalNode(statement, node); - if (node.kind === 224) { + if (node.kind === 225) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -36453,7 +37768,7 @@ var ts; var localName = getLocalName(node); moduleArg = ts.createAssignment(localName, moduleArg); } - var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, transformModuleBody(node, containerName)), undefined, [moduleArg]), node); + var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, transformModuleBody(node, containerName)), undefined, [moduleArg]), node); ts.setOriginalNode(moduleStatement, node); ts.setEmitFlags(moduleStatement, emitFlags); statements.push(moduleStatement); @@ -36471,7 +37786,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 226) { + if (body.kind === 227) { ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); statementsLocation = body.statements; blockLocation = body; @@ -36494,17 +37809,67 @@ var ts; currentNamespace = savedCurrentNamespace; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), blockLocation, true); - if (body.kind !== 226) { + if (body.kind !== 227) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 49152); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 225) { + if (moduleDeclaration.body.kind === 226) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } } + function visitImportDeclaration(node) { + if (!node.importClause) { + return node; + } + var importClause = ts.visitNode(node.importClause, visitImportClause, ts.isImportClause, true); + return importClause + ? ts.updateImportDeclaration(node, undefined, undefined, importClause, node.moduleSpecifier) + : undefined; + } + function visitImportClause(node) { + var name = resolver.isReferencedAliasDeclaration(node) ? node.name : undefined; + var namedBindings = ts.visitNode(node.namedBindings, visitNamedImportBindings, ts.isNamedImportBindings, true); + return (name || namedBindings) ? ts.updateImportClause(node, name, namedBindings) : undefined; + } + function visitNamedImportBindings(node) { + if (node.kind === 233) { + return resolver.isReferencedAliasDeclaration(node) ? node : undefined; + } + else { + var elements = ts.visitNodes(node.elements, visitImportSpecifier, ts.isImportSpecifier); + return ts.some(elements) ? ts.updateNamedImports(node, elements) : undefined; + } + } + function visitImportSpecifier(node) { + return resolver.isReferencedAliasDeclaration(node) ? node : undefined; + } + function visitExportAssignment(node) { + return resolver.isValueAliasDeclaration(node) + ? ts.visitEachChild(node, visitor, context) + : undefined; + } + function visitExportDeclaration(node) { + if (!node.exportClause) { + return resolver.moduleExportsSomeValue(node.moduleSpecifier) ? node : undefined; + } + if (!resolver.isValueAliasDeclaration(node)) { + return undefined; + } + var exportClause = ts.visitNode(node.exportClause, visitNamedExports, ts.isNamedExports, true); + return exportClause + ? ts.updateExportDeclaration(node, undefined, undefined, exportClause, node.moduleSpecifier) + : undefined; + } + function visitNamedExports(node) { + var elements = ts.visitNodes(node.elements, visitExportSpecifier, ts.isExportSpecifier); + return ts.some(elements) ? ts.updateNamedExports(node, elements) : undefined; + } + function visitExportSpecifier(node) { + return resolver.isValueAliasDeclaration(node) ? node : undefined; + } function shouldEmitImportEqualsDeclaration(node) { return resolver.isReferencedAliasDeclaration(node) || (!ts.isExternalModule(currentSourceFile) @@ -36512,7 +37877,9 @@ var ts; } function visitImportEqualsDeclaration(node) { if (ts.isExternalModuleImportEqualsDeclaration(node)) { - return ts.visitEachChild(node, visitor, context); + return resolver.isReferencedAliasDeclaration(node) + ? ts.visitEachChild(node, visitor, context) + : undefined; } if (!shouldEmitImportEqualsDeclaration(node)) { return undefined; @@ -36624,57 +37991,32 @@ var ts; function enableSubstitutionForNonQualifiedEnumMembers() { if ((enabledSubstitutions & 8) === 0) { enabledSubstitutions |= 8; - context.enableSubstitution(69); - } - } - function enableSubstitutionForAsyncMethodsWithSuper() { - if ((enabledSubstitutions & 4) === 0) { - enabledSubstitutions |= 4; - context.enableSubstitution(174); - context.enableSubstitution(172); - context.enableSubstitution(173); - context.enableEmitNotification(221); - context.enableEmitNotification(147); - context.enableEmitNotification(149); - context.enableEmitNotification(150); - context.enableEmitNotification(148); + context.enableSubstitution(70); } } function enableSubstitutionForClassAliases() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(69); + context.enableSubstitution(70); classAliases = ts.createMap(); } } function enableSubstitutionForNamespaceExports() { if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; - context.enableSubstitution(69); + context.enableSubstitution(70); context.enableSubstitution(254); - context.enableEmitNotification(225); + context.enableEmitNotification(226); } } - function isSuperContainer(node) { - var kind = node.kind; - return kind === 221 - || kind === 148 - || kind === 147 - || kind === 149 - || kind === 150; - } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 225; + return ts.getOriginalNode(node).kind === 226; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 224; + return ts.getOriginalNode(node).kind === 225; } function onEmitNode(emitContext, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; - var savedCurrentSuperContainer = currentSuperContainer; - if (enabledSubstitutions & 4 && isSuperContainer(node)) { - currentSuperContainer = node; - } if (enabledSubstitutions & 2 && isTransformedModuleDeclaration(node)) { applicableSubstitutions |= 2; } @@ -36683,7 +38025,6 @@ var ts; } previousOnEmitNode(emitContext, node, emitCallback); applicableSubstitutions = savedApplicableSubstitutions; - currentSuperContainer = savedCurrentSuperContainer; } function onSubstituteNode(emitContext, node) { node = previousOnSubstituteNode(emitContext, node); @@ -36711,17 +38052,12 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 69: + case 70: return substituteExpressionIdentifier(node); - case 172: - return substitutePropertyAccessExpression(node); case 173: - return substituteElementAccessExpression(node); + return substitutePropertyAccessExpression(node); case 174: - if (enabledSubstitutions & 4) { - return substituteCallExpression(node); - } - break; + return substituteElementAccessExpression(node); } return node; } @@ -36751,8 +38087,8 @@ var ts; if (enabledSubstitutions & applicableSubstitutions && (ts.getEmitFlags(node) & 262144) === 0) { var container = resolver.getReferencedExportContainer(node, false); if (container) { - var substitute = (applicableSubstitutions & 2 && container.kind === 225) || - (applicableSubstitutions & 8 && container.kind === 224); + var substitute = (applicableSubstitutions & 2 && container.kind === 226) || + (applicableSubstitutions & 8 && container.kind === 225); if (substitute) { return ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node, node); } @@ -36760,37 +38096,10 @@ var ts; } return undefined; } - function substituteCallExpression(node) { - var expression = node.expression; - if (ts.isSuperProperty(expression)) { - var flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - var argumentExpression = ts.isPropertyAccessExpression(expression) - ? substitutePropertyAccessExpression(expression) - : substituteElementAccessExpression(expression); - return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), undefined, [ - ts.createThis() - ].concat(node.arguments)); - } - } - return node; - } function substitutePropertyAccessExpression(node) { - if (enabledSubstitutions & 4 && node.expression.kind === 95) { - var flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - return createSuperAccessInAsyncMethod(ts.createLiteral(node.name.text), flags, node); - } - } return substituteConstantValue(node); } function substituteElementAccessExpression(node) { - if (enabledSubstitutions & 4 && node.expression.kind === 95) { - var flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - return createSuperAccessInAsyncMethod(node.argumentExpression, flags, node); - } - } return substituteConstantValue(node); } function substituteConstantValue(node) { @@ -36818,1524 +38127,10 @@ var ts; ? resolver.getConstantValue(node) : undefined; } - function createSuperAccessInAsyncMethod(argumentExpression, flags, location) { - if (flags & 4096) { - return ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), "value", location); - } - else { - return ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression], location); - } - } - function getSuperContainerAsyncMethodFlags() { - return currentSuperContainer !== undefined - && resolver.getNodeCheckFlags(currentSuperContainer) & (2048 | 4096); - } } ts.transformTypeScript = transformTypeScript; })(ts || (ts = {})); var ts; -(function (ts) { - function transformES6Module(context) { - var compilerOptions = context.getCompilerOptions(); - var resolver = context.getEmitResolver(); - var currentSourceFile; - return transformSourceFile; - function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { - return node; - } - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - currentSourceFile = node; - return ts.visitEachChild(node, visitor, context); - } - return node; - } - function visitor(node) { - switch (node.kind) { - case 230: - return visitImportDeclaration(node); - case 229: - return visitImportEqualsDeclaration(node); - case 231: - return visitImportClause(node); - case 233: - case 232: - return visitNamedBindings(node); - case 234: - return visitImportSpecifier(node); - case 235: - return visitExportAssignment(node); - case 236: - return visitExportDeclaration(node); - case 237: - return visitNamedExports(node); - case 238: - return visitExportSpecifier(node); - } - return node; - } - function visitExportAssignment(node) { - if (node.isExportEquals) { - return undefined; - } - var original = ts.getOriginalNode(node); - return ts.nodeIsSynthesized(original) || resolver.isValueAliasDeclaration(original) ? node : undefined; - } - function visitExportDeclaration(node) { - if (!node.exportClause) { - return resolver.moduleExportsSomeValue(node.moduleSpecifier) ? node : undefined; - } - if (!resolver.isValueAliasDeclaration(node)) { - return undefined; - } - var newExportClause = ts.visitNode(node.exportClause, visitor, ts.isNamedExports, true); - if (node.exportClause === newExportClause) { - return node; - } - return newExportClause - ? ts.createExportDeclaration(undefined, undefined, newExportClause, node.moduleSpecifier) - : undefined; - } - function visitNamedExports(node) { - var newExports = ts.visitNodes(node.elements, visitor, ts.isExportSpecifier); - if (node.elements === newExports) { - return node; - } - return newExports.length ? ts.createNamedExports(newExports) : undefined; - } - function visitExportSpecifier(node) { - return resolver.isValueAliasDeclaration(node) ? node : undefined; - } - function visitImportEqualsDeclaration(node) { - return !ts.isExternalModuleImportEqualsDeclaration(node) || resolver.isReferencedAliasDeclaration(node) ? node : undefined; - } - function visitImportDeclaration(node) { - if (node.importClause) { - var newImportClause = ts.visitNode(node.importClause, visitor, ts.isImportClause); - if (!newImportClause.name && !newImportClause.namedBindings) { - return undefined; - } - else if (newImportClause !== node.importClause) { - return ts.createImportDeclaration(undefined, undefined, newImportClause, node.moduleSpecifier); - } - } - return node; - } - function visitImportClause(node) { - var newDefaultImport = node.name; - if (!resolver.isReferencedAliasDeclaration(node)) { - newDefaultImport = undefined; - } - var newNamedBindings = ts.visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true); - return newDefaultImport !== node.name || newNamedBindings !== node.namedBindings - ? ts.createImportClause(newDefaultImport, newNamedBindings) - : node; - } - function visitNamedBindings(node) { - if (node.kind === 232) { - return resolver.isReferencedAliasDeclaration(node) ? node : undefined; - } - else { - var newNamedImportElements = ts.visitNodes(node.elements, visitor, ts.isImportSpecifier); - if (!newNamedImportElements || newNamedImportElements.length == 0) { - return undefined; - } - if (newNamedImportElements === node.elements) { - return node; - } - return ts.createNamedImports(newNamedImportElements); - } - } - function visitImportSpecifier(node) { - return resolver.isReferencedAliasDeclaration(node) ? node : undefined; - } - } - ts.transformES6Module = transformES6Module; -})(ts || (ts = {})); -var ts; -(function (ts) { - function transformSystemModule(context) { - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration, hoistFunctionDeclaration = context.hoistFunctionDeclaration; - var compilerOptions = context.getCompilerOptions(); - var resolver = context.getEmitResolver(); - var host = context.getEmitHost(); - var languageVersion = ts.getEmitScriptTarget(compilerOptions); - var previousOnSubstituteNode = context.onSubstituteNode; - var previousOnEmitNode = context.onEmitNode; - context.onSubstituteNode = onSubstituteNode; - context.onEmitNode = onEmitNode; - context.enableSubstitution(69); - context.enableSubstitution(187); - context.enableSubstitution(185); - context.enableSubstitution(186); - context.enableEmitNotification(256); - var exportFunctionForFileMap = []; - var currentSourceFile; - var externalImports; - var exportSpecifiers; - var exportEquals; - var hasExportStarsToExportValues; - var exportFunctionForFile; - var contextObjectForFile; - var exportedLocalNames; - var exportedFunctionDeclarations; - var enclosingBlockScopedContainer; - var currentParent; - var currentNode; - return transformSourceFile; - function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { - return node; - } - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - currentSourceFile = node; - currentNode = node; - var updated = transformSystemModuleWorker(node); - ts.aggregateTransformFlags(updated); - currentSourceFile = undefined; - externalImports = undefined; - exportSpecifiers = undefined; - exportEquals = undefined; - hasExportStarsToExportValues = false; - exportFunctionForFile = undefined; - contextObjectForFile = undefined; - exportedLocalNames = undefined; - exportedFunctionDeclarations = undefined; - return updated; - } - return node; - } - function transformSystemModuleWorker(node) { - ts.Debug.assert(!exportFunctionForFile); - (_a = ts.collectExternalModuleInfo(node, resolver), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); - exportFunctionForFile = ts.createUniqueName("exports"); - contextObjectForFile = ts.createUniqueName("context"); - exportFunctionForFileMap[ts.getOriginalNodeId(node)] = exportFunctionForFile; - var dependencyGroups = collectDependencyGroups(externalImports); - var statements = []; - addSystemModuleBody(statements, node, dependencyGroups); - var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); - var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, getNameOfDependencyGroup)); - var body = ts.createFunctionExpression(undefined, undefined, undefined, [ - ts.createParameter(exportFunctionForFile), - ts.createParameter(contextObjectForFile) - ], undefined, ts.setEmitFlags(ts.createBlock(statements, undefined, true), 1)); - return updateSourceFile(node, [ - ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), undefined, moduleName - ? [moduleName, dependencies, body] - : [dependencies, body])) - ], ~1 & ts.getEmitFlags(node)); - var _a; - } - function addSystemModuleBody(statements, node, dependencyGroups) { - startLexicalEnvironment(); - var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, visitSourceElement); - statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration("__moduleName", undefined, ts.createLogicalAnd(contextObjectForFile, ts.createPropertyAccess(contextObjectForFile, "id"))) - ]))); - var executeStatements = ts.visitNodes(node.statements, visitSourceElement, ts.isStatement, statementOffset); - ts.addRange(statements, endLexicalEnvironment()); - ts.addRange(statements, exportedFunctionDeclarations); - var exportStarFunction = addExportStarIfNeeded(statements); - statements.push(ts.createReturn(ts.setMultiLine(ts.createObjectLiteral([ - ts.createPropertyAssignment("setters", generateSetters(exportStarFunction, dependencyGroups)), - ts.createPropertyAssignment("execute", ts.createFunctionExpression(undefined, undefined, undefined, [], undefined, ts.createBlock(executeStatements, undefined, true))) - ]), true))); - } - function addExportStarIfNeeded(statements) { - if (!hasExportStarsToExportValues) { - return; - } - if (!exportedLocalNames && ts.isEmpty(exportSpecifiers)) { - var hasExportDeclarationWithExportClause = false; - for (var _i = 0, externalImports_1 = externalImports; _i < externalImports_1.length; _i++) { - var externalImport = externalImports_1[_i]; - if (externalImport.kind === 236 && externalImport.exportClause) { - hasExportDeclarationWithExportClause = true; - break; - } - } - if (!hasExportDeclarationWithExportClause) { - return addExportStarFunction(statements, undefined); - } - } - var exportedNames = []; - if (exportedLocalNames) { - for (var _a = 0, exportedLocalNames_1 = exportedLocalNames; _a < exportedLocalNames_1.length; _a++) { - var exportedLocalName = exportedLocalNames_1[_a]; - exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName.text), ts.createLiteral(true))); - } - } - for (var _b = 0, externalImports_2 = externalImports; _b < externalImports_2.length; _b++) { - var externalImport = externalImports_2[_b]; - if (externalImport.kind !== 236) { - continue; - } - var exportDecl = externalImport; - if (!exportDecl.exportClause) { - continue; - } - for (var _c = 0, _d = exportDecl.exportClause.elements; _c < _d.length; _c++) { - var element = _d[_c]; - exportedNames.push(ts.createPropertyAssignment(ts.createLiteral((element.name || element.propertyName).text), ts.createLiteral(true))); - } - } - var exportedNamesStorageRef = ts.createUniqueName("exportedNames"); - statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(exportedNamesStorageRef, undefined, ts.createObjectLiteral(exportedNames, undefined, true)) - ]))); - return addExportStarFunction(statements, exportedNamesStorageRef); - } - function generateSetters(exportStarFunction, dependencyGroups) { - var setters = []; - for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { - var group = dependencyGroups_1[_i]; - var localName = ts.forEach(group.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); - var parameterName = localName ? ts.getGeneratedNameForNode(localName) : ts.createUniqueName(""); - var statements = []; - for (var _a = 0, _b = group.externalImports; _a < _b.length; _a++) { - var entry = _b[_a]; - var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); - switch (entry.kind) { - case 230: - if (!entry.importClause) { - break; - } - case 229: - ts.Debug.assert(importVariableName !== undefined); - statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); - break; - case 236: - ts.Debug.assert(importVariableName !== undefined); - if (entry.exportClause) { - var properties = []; - for (var _c = 0, _d = entry.exportClause.elements; _c < _d.length; _c++) { - var e = _d[_c]; - properties.push(ts.createPropertyAssignment(ts.createLiteral(e.name.text), ts.createElementAccess(parameterName, ts.createLiteral((e.propertyName || e.name).text)))); - } - statements.push(ts.createStatement(ts.createCall(exportFunctionForFile, undefined, [ts.createObjectLiteral(properties, undefined, true)]))); - } - else { - statements.push(ts.createStatement(ts.createCall(exportStarFunction, undefined, [parameterName]))); - } - break; - } - } - setters.push(ts.createFunctionExpression(undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, ts.createBlock(statements, undefined, true))); - } - return ts.createArrayLiteral(setters, undefined, true); - } - function visitSourceElement(node) { - switch (node.kind) { - case 230: - return visitImportDeclaration(node); - case 229: - return visitImportEqualsDeclaration(node); - case 236: - return visitExportDeclaration(node); - case 235: - return visitExportAssignment(node); - default: - return visitNestedNode(node); - } - } - function visitNestedNode(node) { - var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; - var savedCurrentParent = currentParent; - var savedCurrentNode = currentNode; - var currentGrandparent = currentParent; - currentParent = currentNode; - currentNode = node; - if (currentParent && ts.isBlockScope(currentParent, currentGrandparent)) { - enclosingBlockScopedContainer = currentParent; - } - var result = visitNestedNodeWorker(node); - enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; - currentParent = savedCurrentParent; - currentNode = savedCurrentNode; - return result; - } - function visitNestedNodeWorker(node) { - switch (node.kind) { - case 200: - return visitVariableStatement(node); - case 220: - return visitFunctionDeclaration(node); - case 221: - return visitClassDeclaration(node); - case 206: - return visitForStatement(node); - case 207: - return visitForInStatement(node); - case 208: - return visitForOfStatement(node); - case 204: - return visitDoStatement(node); - case 205: - return visitWhileStatement(node); - case 214: - return visitLabeledStatement(node); - case 212: - return visitWithStatement(node); - case 213: - return visitSwitchStatement(node); - case 227: - return visitCaseBlock(node); - case 249: - return visitCaseClause(node); - case 250: - return visitDefaultClause(node); - case 216: - return visitTryStatement(node); - case 252: - return visitCatchClause(node); - case 199: - return visitBlock(node); - case 202: - return visitExpressionStatement(node); - default: - return node; - } - } - function visitImportDeclaration(node) { - if (node.importClause && ts.contains(externalImports, node)) { - hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); - } - return undefined; - } - function visitImportEqualsDeclaration(node) { - if (ts.contains(externalImports, node)) { - hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); - } - return undefined; - } - function visitExportDeclaration(node) { - if (!node.moduleSpecifier) { - var statements = []; - ts.addRange(statements, ts.map(node.exportClause.elements, visitExportSpecifier)); - return statements; - } - return undefined; - } - function visitExportSpecifier(specifier) { - if (resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) - || resolver.isValueAliasDeclaration(specifier)) { - recordExportName(specifier.name); - return createExportStatement(specifier.name, specifier.propertyName || specifier.name); - } - return undefined; - } - function visitExportAssignment(node) { - if (!node.isExportEquals) { - if (ts.nodeIsSynthesized(node) || resolver.isValueAliasDeclaration(node)) { - return createExportStatement(ts.createLiteral("default"), node.expression); - } - } - return undefined; - } - function visitVariableStatement(node) { - var shouldHoist = ((ts.getCombinedNodeFlags(ts.getOriginalNode(node.declarationList)) & 3) == 0) || - enclosingBlockScopedContainer.kind === 256; - if (!shouldHoist) { - return node; - } - var isExported = ts.hasModifier(node, 1); - var expressions = []; - for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { - var variable = _a[_i]; - var visited = transformVariable(variable, isExported); - if (visited) { - expressions.push(visited); - } - } - if (expressions.length) { - return ts.createStatement(ts.inlineExpressions(expressions), node); - } - return undefined; - } - function transformVariable(node, isExported) { - hoistBindingElement(node, isExported); - if (!node.initializer) { - return; - } - var name = node.name; - if (ts.isIdentifier(name)) { - return ts.createAssignment(name, node.initializer); - } - else { - return ts.flattenVariableDestructuringToExpression(context, node, hoistVariableDeclaration); - } - } - function visitFunctionDeclaration(node) { - if (ts.hasModifier(node, 1)) { - var name_31 = node.name || ts.getGeneratedNameForNode(node); - var newNode = ts.createFunctionDeclaration(undefined, undefined, node.asteriskToken, name_31, undefined, node.parameters, undefined, node.body, node); - recordExportedFunctionDeclaration(node); - if (!ts.hasModifier(node, 512)) { - recordExportName(name_31); - } - ts.setOriginalNode(newNode, node); - node = newNode; - } - hoistFunctionDeclaration(node); - return undefined; - } - function visitExpressionStatement(node) { - var originalNode = ts.getOriginalNode(node); - if ((originalNode.kind === 225 || originalNode.kind === 224) && ts.hasModifier(originalNode, 1)) { - var name_32 = getDeclarationName(originalNode); - if (originalNode.kind === 224) { - hoistVariableDeclaration(name_32); - } - return [ - node, - createExportStatement(name_32, name_32) - ]; - } - return node; - } - function visitClassDeclaration(node) { - var name = getDeclarationName(node); - hoistVariableDeclaration(name); - var statements = []; - statements.push(ts.createStatement(ts.createAssignment(name, ts.createClassExpression(undefined, node.name, undefined, node.heritageClauses, node.members, node)), node)); - if (ts.hasModifier(node, 1)) { - if (!ts.hasModifier(node, 512)) { - recordExportName(name); - } - statements.push(createDeclarationExport(node)); - } - return statements; - } - function shouldHoistLoopInitializer(node) { - return ts.isVariableDeclarationList(node) && (ts.getCombinedNodeFlags(node) & 3) === 0; - } - function visitForStatement(node) { - var initializer = node.initializer; - if (shouldHoistLoopInitializer(initializer)) { - var expressions = []; - for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) { - var variable = _a[_i]; - var visited = transformVariable(variable, false); - if (visited) { - expressions.push(visited); - } - } - ; - return ts.createFor(expressions.length - ? ts.inlineExpressions(expressions) - : ts.createSynthesizedNode(193), node.condition, node.incrementor, ts.visitNode(node.statement, visitNestedNode, ts.isStatement), node); - } - else { - return ts.visitEachChild(node, visitNestedNode, context); - } - } - function transformForBinding(node) { - var firstDeclaration = ts.firstOrUndefined(node.declarations); - hoistBindingElement(firstDeclaration, false); - var name = firstDeclaration.name; - return ts.isIdentifier(name) - ? name - : ts.flattenVariableDestructuringToExpression(context, firstDeclaration, hoistVariableDeclaration); - } - function visitForInStatement(node) { - var initializer = node.initializer; - if (shouldHoistLoopInitializer(initializer)) { - var updated = ts.getMutableClone(node); - updated.initializer = transformForBinding(initializer); - updated.statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, false, ts.liftToBlock); - return updated; - } - else { - return ts.visitEachChild(node, visitNestedNode, context); - } - } - function visitForOfStatement(node) { - var initializer = node.initializer; - if (shouldHoistLoopInitializer(initializer)) { - var updated = ts.getMutableClone(node); - updated.initializer = transformForBinding(initializer); - updated.statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, false, ts.liftToBlock); - return updated; - } - else { - return ts.visitEachChild(node, visitNestedNode, context); - } - } - function visitDoStatement(node) { - var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, false, ts.liftToBlock); - if (statement !== node.statement) { - var updated = ts.getMutableClone(node); - updated.statement = statement; - return updated; - } - return node; - } - function visitWhileStatement(node) { - var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, false, ts.liftToBlock); - if (statement !== node.statement) { - var updated = ts.getMutableClone(node); - updated.statement = statement; - return updated; - } - return node; - } - function visitLabeledStatement(node) { - var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, false, ts.liftToBlock); - if (statement !== node.statement) { - var updated = ts.getMutableClone(node); - updated.statement = statement; - return updated; - } - return node; - } - function visitWithStatement(node) { - var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, false, ts.liftToBlock); - if (statement !== node.statement) { - var updated = ts.getMutableClone(node); - updated.statement = statement; - return updated; - } - return node; - } - function visitSwitchStatement(node) { - var caseBlock = ts.visitNode(node.caseBlock, visitNestedNode, ts.isCaseBlock); - if (caseBlock !== node.caseBlock) { - var updated = ts.getMutableClone(node); - updated.caseBlock = caseBlock; - return updated; - } - return node; - } - function visitCaseBlock(node) { - var clauses = ts.visitNodes(node.clauses, visitNestedNode, ts.isCaseOrDefaultClause); - if (clauses !== node.clauses) { - var updated = ts.getMutableClone(node); - updated.clauses = clauses; - return updated; - } - return node; - } - function visitCaseClause(node) { - var statements = ts.visitNodes(node.statements, visitNestedNode, ts.isStatement); - if (statements !== node.statements) { - var updated = ts.getMutableClone(node); - updated.statements = statements; - return updated; - } - return node; - } - function visitDefaultClause(node) { - return ts.visitEachChild(node, visitNestedNode, context); - } - function visitTryStatement(node) { - return ts.visitEachChild(node, visitNestedNode, context); - } - function visitCatchClause(node) { - var block = ts.visitNode(node.block, visitNestedNode, ts.isBlock); - if (block !== node.block) { - var updated = ts.getMutableClone(node); - updated.block = block; - return updated; - } - return node; - } - function visitBlock(node) { - return ts.visitEachChild(node, visitNestedNode, context); - } - function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 256) { - exportFunctionForFile = exportFunctionForFileMap[ts.getOriginalNodeId(node)]; - previousOnEmitNode(emitContext, node, emitCallback); - exportFunctionForFile = undefined; - } - else { - previousOnEmitNode(emitContext, node, emitCallback); - } - } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1) { - return substituteExpression(node); - } - return node; - } - function substituteExpression(node) { - switch (node.kind) { - case 69: - return substituteExpressionIdentifier(node); - case 187: - return substituteBinaryExpression(node); - case 185: - case 186: - return substituteUnaryExpression(node); - } - return node; - } - function substituteExpressionIdentifier(node) { - var importDeclaration = resolver.getReferencedImportDeclaration(node); - if (importDeclaration) { - var importBinding = createImportBinding(importDeclaration); - if (importBinding) { - return importBinding; - } - } - return node; - } - function substituteBinaryExpression(node) { - if (ts.isAssignmentOperator(node.operatorToken.kind)) { - return substituteAssignmentExpression(node); - } - return node; - } - function substituteAssignmentExpression(node) { - ts.setEmitFlags(node, 128); - var left = node.left; - switch (left.kind) { - case 69: - var exportDeclaration = resolver.getReferencedExportContainer(left); - if (exportDeclaration) { - return createExportExpression(left, node); - } - break; - case 171: - case 170: - if (hasExportedReferenceInDestructuringPattern(left)) { - return substituteDestructuring(node); - } - break; - } - return node; - } - function isExportedBinding(name) { - var container = resolver.getReferencedExportContainer(name); - return container && container.kind === 256; - } - function hasExportedReferenceInDestructuringPattern(node) { - switch (node.kind) { - case 69: - return isExportedBinding(node); - case 171: - for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { - var property = _a[_i]; - if (hasExportedReferenceInObjectDestructuringElement(property)) { - return true; - } - } - break; - case 170: - for (var _b = 0, _c = node.elements; _b < _c.length; _b++) { - var element = _c[_b]; - if (hasExportedReferenceInArrayDestructuringElement(element)) { - return true; - } - } - break; - } - return false; - } - function hasExportedReferenceInObjectDestructuringElement(node) { - if (ts.isShorthandPropertyAssignment(node)) { - return isExportedBinding(node.name); - } - else if (ts.isPropertyAssignment(node)) { - return hasExportedReferenceInDestructuringElement(node.initializer); - } - else { - return false; - } - } - function hasExportedReferenceInArrayDestructuringElement(node) { - if (ts.isSpreadElementExpression(node)) { - var expression = node.expression; - return ts.isIdentifier(expression) && isExportedBinding(expression); - } - else { - return hasExportedReferenceInDestructuringElement(node); - } - } - function hasExportedReferenceInDestructuringElement(node) { - if (ts.isBinaryExpression(node)) { - var left = node.left; - return node.operatorToken.kind === 56 - && isDestructuringPattern(left) - && hasExportedReferenceInDestructuringPattern(left); - } - else if (ts.isIdentifier(node)) { - return isExportedBinding(node); - } - else if (ts.isSpreadElementExpression(node)) { - var expression = node.expression; - return ts.isIdentifier(expression) && isExportedBinding(expression); - } - else if (isDestructuringPattern(node)) { - return hasExportedReferenceInDestructuringPattern(node); - } - else { - return false; - } - } - function isDestructuringPattern(node) { - var kind = node.kind; - return kind === 69 - || kind === 171 - || kind === 170; - } - function substituteDestructuring(node) { - return ts.flattenDestructuringAssignment(context, node, true, hoistVariableDeclaration); - } - function substituteUnaryExpression(node) { - var operand = node.operand; - var operator = node.operator; - var substitute = ts.isIdentifier(operand) && - (node.kind === 186 || - (node.kind === 185 && (operator === 41 || operator === 42))); - if (substitute) { - var exportDeclaration = resolver.getReferencedExportContainer(operand); - if (exportDeclaration) { - var expr = ts.createPrefix(node.operator, operand, node); - ts.setEmitFlags(expr, 128); - var call = createExportExpression(operand, expr); - if (node.kind === 185) { - return call; - } - else { - return operator === 41 - ? ts.createSubtract(call, ts.createLiteral(1)) - : ts.createAdd(call, ts.createLiteral(1)); - } - } - } - return node; - } - function getDeclarationName(node) { - return node.name ? ts.getSynthesizedClone(node.name) : ts.getGeneratedNameForNode(node); - } - function addExportStarFunction(statements, localNames) { - var exportStarFunction = ts.createUniqueName("exportStar"); - var m = ts.createIdentifier("m"); - var n = ts.createIdentifier("n"); - var exports = ts.createIdentifier("exports"); - var condition = ts.createStrictInequality(n, ts.createLiteral("default")); - if (localNames) { - condition = ts.createLogicalAnd(condition, ts.createLogicalNot(ts.createHasOwnProperty(localNames, n))); - } - statements.push(ts.createFunctionDeclaration(undefined, undefined, undefined, exportStarFunction, undefined, [ts.createParameter(m)], undefined, ts.createBlock([ - ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(exports, undefined, ts.createObjectLiteral([])) - ])), - ts.createForIn(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(n, undefined) - ]), m, ts.createBlock([ - ts.setEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 32) - ])), - ts.createStatement(ts.createCall(exportFunctionForFile, undefined, [exports])) - ], undefined, true))); - return exportStarFunction; - } - function createExportExpression(name, value) { - var exportName = ts.isIdentifier(name) ? ts.createLiteral(name.text) : name; - return ts.createCall(exportFunctionForFile, undefined, [exportName, value]); - } - function createExportStatement(name, value) { - return ts.createStatement(createExportExpression(name, value)); - } - function createDeclarationExport(node) { - var declarationName = getDeclarationName(node); - var exportName = ts.hasModifier(node, 512) ? ts.createLiteral("default") : declarationName; - return createExportStatement(exportName, declarationName); - } - function createImportBinding(importDeclaration) { - var importAlias; - var name; - if (ts.isImportClause(importDeclaration)) { - importAlias = ts.getGeneratedNameForNode(importDeclaration.parent); - name = ts.createIdentifier("default"); - } - else if (ts.isImportSpecifier(importDeclaration)) { - importAlias = ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent); - name = importDeclaration.propertyName || importDeclaration.name; - } - else { - return undefined; - } - if (name.originalKeywordKind && languageVersion === 0) { - return ts.createElementAccess(importAlias, ts.createLiteral(name.text)); - } - else { - return ts.createPropertyAccess(importAlias, ts.getSynthesizedClone(name)); - } - } - function collectDependencyGroups(externalImports) { - var groupIndices = ts.createMap(); - var dependencyGroups = []; - for (var i = 0; i < externalImports.length; i++) { - var externalImport = externalImports[i]; - var externalModuleName = ts.getExternalModuleNameLiteral(externalImport, currentSourceFile, host, resolver, compilerOptions); - var text = externalModuleName.text; - if (ts.hasProperty(groupIndices, text)) { - var groupIndex = groupIndices[text]; - dependencyGroups[groupIndex].externalImports.push(externalImport); - continue; - } - else { - groupIndices[text] = dependencyGroups.length; - dependencyGroups.push({ - name: externalModuleName, - externalImports: [externalImport] - }); - } - } - return dependencyGroups; - } - function getNameOfDependencyGroup(dependencyGroup) { - return dependencyGroup.name; - } - function recordExportName(name) { - if (!exportedLocalNames) { - exportedLocalNames = []; - } - exportedLocalNames.push(name); - } - function recordExportedFunctionDeclaration(node) { - if (!exportedFunctionDeclarations) { - exportedFunctionDeclarations = []; - } - exportedFunctionDeclarations.push(createDeclarationExport(node)); - } - function hoistBindingElement(node, isExported) { - if (ts.isOmittedExpression(node)) { - return; - } - var name = node.name; - if (ts.isIdentifier(name)) { - hoistVariableDeclaration(ts.getSynthesizedClone(name)); - if (isExported) { - recordExportName(name); - } - } - else if (ts.isBindingPattern(name)) { - ts.forEach(name.elements, isExported ? hoistExportedBindingElement : hoistNonExportedBindingElement); - } - } - function hoistExportedBindingElement(node) { - hoistBindingElement(node, true); - } - function hoistNonExportedBindingElement(node) { - hoistBindingElement(node, false); - } - function updateSourceFile(node, statements, nodeEmitFlags) { - var updated = ts.getMutableClone(node); - updated.statements = ts.createNodeArray(statements, node.statements); - ts.setEmitFlags(updated, nodeEmitFlags); - return updated; - } - } - ts.transformSystemModule = transformSystemModule; -})(ts || (ts = {})); -var ts; -(function (ts) { - function transformModule(context) { - var transformModuleDelegates = ts.createMap((_a = {}, - _a[ts.ModuleKind.None] = transformCommonJSModule, - _a[ts.ModuleKind.CommonJS] = transformCommonJSModule, - _a[ts.ModuleKind.AMD] = transformAMDModule, - _a[ts.ModuleKind.UMD] = transformUMDModule, - _a)); - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; - var compilerOptions = context.getCompilerOptions(); - var resolver = context.getEmitResolver(); - var host = context.getEmitHost(); - var languageVersion = ts.getEmitScriptTarget(compilerOptions); - var moduleKind = ts.getEmitModuleKind(compilerOptions); - var previousOnSubstituteNode = context.onSubstituteNode; - var previousOnEmitNode = context.onEmitNode; - context.onSubstituteNode = onSubstituteNode; - context.onEmitNode = onEmitNode; - context.enableSubstitution(69); - context.enableSubstitution(187); - context.enableSubstitution(185); - context.enableSubstitution(186); - context.enableSubstitution(254); - context.enableEmitNotification(256); - var currentSourceFile; - var externalImports; - var exportSpecifiers; - var exportEquals; - var bindingNameExportSpecifiersMap; - var bindingNameExportSpecifiersForFileMap = ts.createMap(); - var hasExportStarsToExportValues; - return transformSourceFile; - function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { - return node; - } - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - currentSourceFile = node; - (_a = ts.collectExternalModuleInfo(node, resolver), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); - var transformModule_1 = transformModuleDelegates[moduleKind] || transformModuleDelegates[ts.ModuleKind.None]; - var updated = transformModule_1(node); - ts.aggregateTransformFlags(updated); - currentSourceFile = undefined; - externalImports = undefined; - exportSpecifiers = undefined; - exportEquals = undefined; - hasExportStarsToExportValues = false; - return updated; - } - return node; - var _a; - } - function transformCommonJSModule(node) { - startLexicalEnvironment(); - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, visitor); - ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); - ts.addRange(statements, endLexicalEnvironment()); - addExportEqualsIfNeeded(statements, false); - var updated = updateSourceFile(node, statements); - if (hasExportStarsToExportValues) { - ts.setEmitFlags(updated, 2 | ts.getEmitFlags(node)); - } - return updated; - } - function transformAMDModule(node) { - var define = ts.createIdentifier("define"); - var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); - return transformAsynchronousModule(node, define, moduleName, true); - } - function transformUMDModule(node) { - var define = ts.createIdentifier("define"); - ts.setEmitFlags(define, 16); - return transformAsynchronousModule(node, define, undefined, false); - } - function transformAsynchronousModule(node, define, moduleName, includeNonAmdDependencies) { - var _a = collectAsynchronousDependencies(node, includeNonAmdDependencies), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; - return updateSourceFile(node, [ - ts.createStatement(ts.createCall(define, undefined, (moduleName ? [moduleName] : []).concat([ - ts.createArrayLiteral([ - ts.createLiteral("require"), - ts.createLiteral("exports") - ].concat(aliasedModuleNames, unaliasedModuleNames)), - ts.createFunctionExpression(undefined, undefined, undefined, [ - ts.createParameter("require"), - ts.createParameter("exports") - ].concat(importAliasNames), undefined, transformAsynchronousModuleBody(node)) - ]))) - ]); - } - function transformAsynchronousModuleBody(node) { - startLexicalEnvironment(); - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, visitor); - ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); - ts.addRange(statements, endLexicalEnvironment()); - addExportEqualsIfNeeded(statements, true); - var body = ts.createBlock(statements, undefined, true); - if (hasExportStarsToExportValues) { - ts.setEmitFlags(body, 2); - } - return body; - } - function addExportEqualsIfNeeded(statements, emitAsReturn) { - if (exportEquals && resolver.isValueAliasDeclaration(exportEquals)) { - if (emitAsReturn) { - var statement = ts.createReturn(exportEquals.expression, exportEquals); - ts.setEmitFlags(statement, 12288 | 49152); - statements.push(statement); - } - else { - var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), exportEquals.expression), exportEquals); - ts.setEmitFlags(statement, 49152); - statements.push(statement); - } - } - } - function visitor(node) { - switch (node.kind) { - case 230: - return visitImportDeclaration(node); - case 229: - return visitImportEqualsDeclaration(node); - case 236: - return visitExportDeclaration(node); - case 235: - return visitExportAssignment(node); - case 200: - return visitVariableStatement(node); - case 220: - return visitFunctionDeclaration(node); - case 221: - return visitClassDeclaration(node); - case 202: - return visitExpressionStatement(node); - default: - return node; - } - } - function visitImportDeclaration(node) { - if (!ts.contains(externalImports, node)) { - return undefined; - } - var statements = []; - var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); - if (moduleKind !== ts.ModuleKind.AMD) { - if (!node.importClause) { - statements.push(ts.createStatement(createRequireCall(node), node)); - } - else { - var variables = []; - if (namespaceDeclaration && !ts.isDefaultImport(node)) { - variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, createRequireCall(node))); - } - else { - variables.push(ts.createVariableDeclaration(ts.getGeneratedNameForNode(node), undefined, createRequireCall(node))); - if (namespaceDeclaration && ts.isDefaultImport(node)) { - variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, ts.getGeneratedNameForNode(node))); - } - } - statements.push(ts.createVariableStatement(undefined, ts.createConstDeclarationList(variables), node)); - } - } - else if (namespaceDeclaration && ts.isDefaultImport(node)) { - statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, ts.getGeneratedNameForNode(node), node) - ]))); - } - addExportImportAssignments(statements, node); - return ts.singleOrMany(statements); - } - function visitImportEqualsDeclaration(node) { - if (!ts.contains(externalImports, node)) { - return undefined; - } - ts.setEmitFlags(node.name, 128); - var statements = []; - if (moduleKind !== ts.ModuleKind.AMD) { - if (ts.hasModifier(node, 1)) { - statements.push(ts.createStatement(createExportAssignment(node.name, createRequireCall(node)), node)); - } - else { - statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(ts.getSynthesizedClone(node.name), undefined, createRequireCall(node)) - ], undefined, languageVersion >= 2 ? 2 : 0), node)); - } - } - else { - if (ts.hasModifier(node, 1)) { - statements.push(ts.createStatement(createExportAssignment(node.name, node.name), node)); - } - } - addExportImportAssignments(statements, node); - return statements; - } - function visitExportDeclaration(node) { - if (!ts.contains(externalImports, node)) { - return undefined; - } - var generatedName = ts.getGeneratedNameForNode(node); - if (node.exportClause) { - var statements = []; - if (moduleKind !== ts.ModuleKind.AMD) { - statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(generatedName, undefined, createRequireCall(node)) - ]), node)); - } - for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { - var specifier = _a[_i]; - if (resolver.isValueAliasDeclaration(specifier)) { - var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); - statements.push(ts.createStatement(createExportAssignment(specifier.name, exportedValue), specifier)); - } - } - return ts.singleOrMany(statements); - } - else if (resolver.moduleExportsSomeValue(node.moduleSpecifier)) { - return ts.createStatement(ts.createCall(ts.createIdentifier("__export"), undefined, [ - moduleKind !== ts.ModuleKind.AMD - ? createRequireCall(node) - : generatedName - ]), node); - } - } - function visitExportAssignment(node) { - if (!node.isExportEquals) { - if (ts.nodeIsSynthesized(node) || resolver.isValueAliasDeclaration(node)) { - var statements = []; - addExportDefault(statements, node.expression, node); - return statements; - } - } - return undefined; - } - function addExportDefault(statements, expression, location) { - tryAddExportDefaultCompat(statements); - statements.push(ts.createStatement(createExportAssignment(ts.createIdentifier("default"), expression), location)); - } - function tryAddExportDefaultCompat(statements) { - var original = ts.getOriginalNode(currentSourceFile); - ts.Debug.assert(original.kind === 256); - if (!original.symbol.exports["___esModule"]) { - if (languageVersion === 0) { - statements.push(ts.createStatement(createExportAssignment(ts.createIdentifier("__esModule"), ts.createLiteral(true)))); - } - else { - statements.push(ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ - ts.createIdentifier("exports"), - ts.createLiteral("__esModule"), - ts.createObjectLiteral([ - ts.createPropertyAssignment("value", ts.createLiteral(true)) - ]) - ]))); - } - } - } - function addExportImportAssignments(statements, node) { - if (ts.isImportEqualsDeclaration(node)) { - addExportMemberAssignments(statements, node.name); - } - else { - var names = ts.reduceEachChild(node, collectExportMembers, []); - for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_33 = names_1[_i]; - addExportMemberAssignments(statements, name_33); - } - } - } - function collectExportMembers(names, node) { - if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node) && ts.isDeclaration(node)) { - var name_34 = node.name; - if (ts.isIdentifier(name_34)) { - names.push(name_34); - } - } - return ts.reduceEachChild(node, collectExportMembers, names); - } - function addExportMemberAssignments(statements, name) { - if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { - for (var _i = 0, _a = exportSpecifiers[name.text]; _i < _a.length; _i++) { - var specifier = _a[_i]; - statements.push(ts.startOnNewLine(ts.createStatement(createExportAssignment(specifier.name, name), specifier.name))); - } - } - } - function addExportMemberAssignment(statements, node) { - if (ts.hasModifier(node, 512)) { - addExportDefault(statements, getDeclarationName(node), node); - } - else { - statements.push(createExportStatement(node.name, ts.setEmitFlags(ts.getSynthesizedClone(node.name), 262144), node)); - } - } - function visitVariableStatement(node) { - var originalKind = ts.getOriginalNode(node).kind; - if (originalKind === 225 || - originalKind === 224 || - originalKind === 221) { - if (!ts.hasModifier(node, 1)) { - return node; - } - return ts.setOriginalNode(ts.createVariableStatement(undefined, node.declarationList), node); - } - var resultStatements = []; - if (ts.hasModifier(node, 1)) { - var variables = ts.getInitializedVariables(node.declarationList); - if (variables.length > 0) { - var inlineAssignments = ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable)), node); - resultStatements.push(inlineAssignments); - } - } - else { - resultStatements.push(node); - } - for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - addExportMemberAssignmentsForBindingName(resultStatements, decl.name); - } - return resultStatements; - } - function addExportMemberAssignmentsForBindingName(resultStatements, name) { - if (ts.isBindingPattern(name)) { - for (var _i = 0, _a = name.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (!ts.isOmittedExpression(element)) { - addExportMemberAssignmentsForBindingName(resultStatements, element.name); - } - } - } - else { - if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { - var sourceFileId = ts.getOriginalNodeId(currentSourceFile); - if (!bindingNameExportSpecifiersForFileMap[sourceFileId]) { - bindingNameExportSpecifiersForFileMap[sourceFileId] = ts.createMap(); - } - bindingNameExportSpecifiersForFileMap[sourceFileId][name.text] = exportSpecifiers[name.text]; - addExportMemberAssignments(resultStatements, name); - } - } - } - function transformInitializedVariable(node) { - var name = node.name; - if (ts.isBindingPattern(name)) { - return ts.flattenVariableDestructuringToExpression(context, node, hoistVariableDeclaration, getModuleMemberName, visitor); - } - else { - return ts.createAssignment(getModuleMemberName(name), ts.visitNode(node.initializer, visitor, ts.isExpression)); - } - } - function visitFunctionDeclaration(node) { - var statements = []; - var name = node.name || ts.getGeneratedNameForNode(node); - if (ts.hasModifier(node, 1)) { - statements.push(ts.setOriginalNode(ts.createFunctionDeclaration(undefined, undefined, node.asteriskToken, name, undefined, node.parameters, undefined, node.body, node), node)); - addExportMemberAssignment(statements, node); - } - else { - statements.push(node); - } - if (node.name) { - addExportMemberAssignments(statements, node.name); - } - return ts.singleOrMany(statements); - } - function visitClassDeclaration(node) { - var statements = []; - var name = node.name || ts.getGeneratedNameForNode(node); - if (ts.hasModifier(node, 1)) { - statements.push(ts.setOriginalNode(ts.createClassDeclaration(undefined, undefined, name, undefined, node.heritageClauses, node.members, node), node)); - addExportMemberAssignment(statements, node); - } - else { - statements.push(node); - } - if (node.name && !(node.decorators && node.decorators.length)) { - addExportMemberAssignments(statements, node.name); - } - return ts.singleOrMany(statements); - } - function visitExpressionStatement(node) { - var original = ts.getOriginalNode(node); - var origKind = original.kind; - if (origKind === 224 || origKind === 225) { - return visitExpressionStatementForEnumOrNamespaceDeclaration(node, original); - } - else if (origKind === 221) { - var classDecl = original; - if (classDecl.name) { - var statements = [node]; - addExportMemberAssignments(statements, classDecl.name); - return statements; - } - } - return node; - } - function visitExpressionStatementForEnumOrNamespaceDeclaration(node, original) { - var statements = [node]; - if (ts.hasModifier(original, 1) && - original.kind === 224 && - ts.isFirstDeclarationOfKind(original, 224)) { - addVarForExportedEnumOrNamespaceDeclaration(statements, original); - } - addExportMemberAssignments(statements, original.name); - return statements; - } - function addVarForExportedEnumOrNamespaceDeclaration(statements, node) { - var transformedStatement = ts.createVariableStatement(undefined, [ts.createVariableDeclaration(getDeclarationName(node), undefined, ts.createPropertyAccess(ts.createIdentifier("exports"), getDeclarationName(node)))], node); - ts.setEmitFlags(transformedStatement, 49152); - statements.push(transformedStatement); - } - function getDeclarationName(node) { - return node.name ? ts.getSynthesizedClone(node.name) : ts.getGeneratedNameForNode(node); - } - function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 256) { - bindingNameExportSpecifiersMap = bindingNameExportSpecifiersForFileMap[ts.getOriginalNodeId(node)]; - previousOnEmitNode(emitContext, node, emitCallback); - bindingNameExportSpecifiersMap = undefined; - } - else { - previousOnEmitNode(emitContext, node, emitCallback); - } - } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1) { - return substituteExpression(node); - } - else if (ts.isShorthandPropertyAssignment(node)) { - return substituteShorthandPropertyAssignment(node); - } - return node; - } - function substituteShorthandPropertyAssignment(node) { - var name = node.name; - var exportedOrImportedName = substituteExpressionIdentifier(name); - if (exportedOrImportedName !== name) { - if (node.objectAssignmentInitializer) { - var initializer = ts.createAssignment(exportedOrImportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name, initializer, node); - } - return ts.createPropertyAssignment(name, exportedOrImportedName, node); - } - return node; - } - function substituteExpression(node) { - switch (node.kind) { - case 69: - return substituteExpressionIdentifier(node); - case 187: - return substituteBinaryExpression(node); - case 186: - case 185: - return substituteUnaryExpression(node); - } - return node; - } - function substituteExpressionIdentifier(node) { - return trySubstituteExportedName(node) - || trySubstituteImportedName(node) - || node; - } - function substituteBinaryExpression(node) { - var left = node.left; - if (ts.isIdentifier(left) && ts.isAssignmentOperator(node.operatorToken.kind)) { - if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, left.text)) { - ts.setEmitFlags(node, 128); - var nestedExportAssignment = void 0; - for (var _i = 0, _a = bindingNameExportSpecifiersMap[left.text]; _i < _a.length; _i++) { - var specifier = _a[_i]; - nestedExportAssignment = nestedExportAssignment ? - createExportAssignment(specifier.name, nestedExportAssignment) : - createExportAssignment(specifier.name, node); - } - return nestedExportAssignment; - } - } - return node; - } - function substituteUnaryExpression(node) { - var operator = node.operator; - var operand = node.operand; - if (ts.isIdentifier(operand) && bindingNameExportSpecifiersForFileMap) { - if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, operand.text)) { - ts.setEmitFlags(node, 128); - var transformedUnaryExpression = void 0; - if (node.kind === 186) { - transformedUnaryExpression = ts.createBinary(operand, ts.createToken(operator === 41 ? 57 : 58), ts.createLiteral(1), node); - ts.setEmitFlags(transformedUnaryExpression, 128); - } - var nestedExportAssignment = void 0; - for (var _i = 0, _a = bindingNameExportSpecifiersMap[operand.text]; _i < _a.length; _i++) { - var specifier = _a[_i]; - nestedExportAssignment = nestedExportAssignment ? - createExportAssignment(specifier.name, nestedExportAssignment) : - createExportAssignment(specifier.name, transformedUnaryExpression || node); - } - return nestedExportAssignment; - } - } - return node; - } - function trySubstituteExportedName(node) { - var emitFlags = ts.getEmitFlags(node); - if ((emitFlags & 262144) === 0) { - var container = resolver.getReferencedExportContainer(node, (emitFlags & 131072) !== 0); - if (container) { - if (container.kind === 256) { - return ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node), node); - } - } - } - return undefined; - } - function trySubstituteImportedName(node) { - if ((ts.getEmitFlags(node) & 262144) === 0) { - var declaration = resolver.getReferencedImportDeclaration(node); - if (declaration) { - if (ts.isImportClause(declaration)) { - if (languageVersion >= 1) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent), ts.createIdentifier("default"), node); - } - else { - return ts.createElementAccess(ts.getGeneratedNameForNode(declaration.parent), ts.createLiteral("default"), node); - } - } - else if (ts.isImportSpecifier(declaration)) { - var name_35 = declaration.propertyName || declaration.name; - if (name_35.originalKeywordKind === 77 && languageVersion <= 0) { - return ts.createElementAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.createLiteral(name_35.text), node); - } - else { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.getSynthesizedClone(name_35), node); - } - } - } - } - return undefined; - } - function getModuleMemberName(name) { - return ts.createPropertyAccess(ts.createIdentifier("exports"), name, name); - } - function createRequireCall(importNode) { - var moduleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); - var args = []; - if (ts.isDefined(moduleName)) { - args.push(moduleName); - } - return ts.createCall(ts.createIdentifier("require"), undefined, args); - } - function createExportStatement(name, value, location) { - var statement = ts.createStatement(createExportAssignment(name, value)); - statement.startsOnNewLine = true; - if (location) { - ts.setSourceMapRange(statement, location); - } - return statement; - } - function createExportAssignment(name, value) { - return ts.createAssignment(name.originalKeywordKind === 77 && languageVersion === 0 - ? ts.createElementAccess(ts.createIdentifier("exports"), ts.createLiteral(name.text)) - : ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value); - } - function collectAsynchronousDependencies(node, includeNonAmdDependencies) { - var aliasedModuleNames = []; - var unaliasedModuleNames = []; - var importAliasNames = []; - for (var _i = 0, _a = node.amdDependencies; _i < _a.length; _i++) { - var amdDependency = _a[_i]; - if (amdDependency.name) { - aliasedModuleNames.push(ts.createLiteral(amdDependency.path)); - importAliasNames.push(ts.createParameter(amdDependency.name)); - } - else { - unaliasedModuleNames.push(ts.createLiteral(amdDependency.path)); - } - } - for (var _b = 0, externalImports_3 = externalImports; _b < externalImports_3.length; _b++) { - var importNode = externalImports_3[_b]; - var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); - var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile); - if (includeNonAmdDependencies && importAliasName) { - ts.setEmitFlags(importAliasName, 128); - aliasedModuleNames.push(externalModuleName); - importAliasNames.push(ts.createParameter(importAliasName)); - } - else { - unaliasedModuleNames.push(externalModuleName); - } - } - return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; - } - function updateSourceFile(node, statements) { - var updated = ts.getMutableClone(node); - updated.statements = ts.createNodeArray(statements, node.statements); - return updated; - } - var _a; - } - ts.transformModule = transformModule; -})(ts || (ts = {})); -var ts; (function (ts) { var entities = createEntitiesMap(); function transformJsx(context) { @@ -38364,9 +38159,9 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 241: - return visitJsxElement(node, false); case 242: + return visitJsxElement(node, false); + case 243: return visitJsxSelfClosingElement(node, false); case 248: return visitJsxExpression(node); @@ -38377,13 +38172,13 @@ var ts; } function transformJsxChildToExpression(node) { switch (node.kind) { - case 244: + case 10: return visitJsxText(node); case 248: return visitJsxExpression(node); - case 241: - return visitJsxElement(node, true); case 242: + return visitJsxElement(node, true); + case 243: return visitJsxSelfClosingElement(node, true); default: ts.Debug.failBadSyntaxKind(node); @@ -38500,16 +38295,16 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 241) { + if (node.kind === 242) { return getTagName(node.openingElement); } else { - var name_36 = node.tagName; - if (ts.isIdentifier(name_36) && ts.isIntrinsicJsxName(name_36.text)) { - return ts.createLiteral(name_36.text); + var name_31 = node.tagName; + if (ts.isIdentifier(name_31) && ts.isIntrinsicJsxName(name_31.text)) { + return ts.createLiteral(name_31.text); } else { - return ts.createExpressionFromEntityName(name_36); + return ts.createExpressionFromEntityName(name_31); } } } @@ -38787,13 +38582,30 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function transformES7(context) { - var hoistVariableDeclaration = context.hoistVariableDeclaration; + function transformES2017(context) { + var ES2017SubstitutionFlags; + (function (ES2017SubstitutionFlags) { + ES2017SubstitutionFlags[ES2017SubstitutionFlags["AsyncMethodsWithSuper"] = 1] = "AsyncMethodsWithSuper"; + })(ES2017SubstitutionFlags || (ES2017SubstitutionFlags = {})); + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; + var resolver = context.getEmitResolver(); + var compilerOptions = context.getCompilerOptions(); + var languageVersion = ts.getEmitScriptTarget(compilerOptions); + var currentSourceFileExternalHelpersModuleName; + var enabledSubstitutions; + var applicableSubstitutions; + var currentSuperContainer; + var previousOnEmitNode = context.onEmitNode; + var previousOnSubstituteNode = context.onSubstituteNode; + context.onEmitNode = onEmitNode; + context.onSubstituteNode = onSubstituteNode; + var currentScope; return transformSourceFile; function transformSourceFile(node) { if (ts.isDeclarationFile(node)) { return node; } + currentSourceFileExternalHelpersModuleName = node.externalHelpersModuleName; return ts.visitEachChild(node, visitor, context); } function visitor(node) { @@ -38803,13 +38615,265 @@ var ts; else if (node.transformFlags & 32) { return ts.visitEachChild(node, visitor, context); } + return node; + } + function visitorWorker(node) { + switch (node.kind) { + case 119: + return undefined; + case 185: + return visitAwaitExpression(node); + case 148: + return visitMethodDeclaration(node); + case 221: + return visitFunctionDeclaration(node); + case 180: + return visitFunctionExpression(node); + case 181: + return visitArrowFunction(node); + default: + ts.Debug.failBadSyntaxKind(node); + return node; + } + } + function visitAwaitExpression(node) { + return ts.setOriginalNode(ts.createYield(undefined, ts.visitNode(node.expression, visitor, ts.isExpression), node), node); + } + function visitMethodDeclaration(node) { + if (!ts.isAsyncFunctionLike(node)) { + return node; + } + var method = ts.createMethod(undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); + ts.setCommentRange(method, node); + ts.setSourceMapRange(method, ts.moveRangePastDecorators(node)); + ts.setOriginalNode(method, node); + return method; + } + function visitFunctionDeclaration(node) { + if (!ts.isAsyncFunctionLike(node)) { + return node; + } + var func = ts.createFunctionDeclaration(undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); + ts.setOriginalNode(func, node); + return func; + } + function visitFunctionExpression(node) { + if (!ts.isAsyncFunctionLike(node)) { + return node; + } + if (ts.nodeIsMissing(node.body)) { + return ts.createOmittedExpression(); + } + var func = ts.createFunctionExpression(undefined, node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); + ts.setOriginalNode(func, node); + return func; + } + function visitArrowFunction(node) { + if (!ts.isAsyncFunctionLike(node)) { + return node; + } + var func = ts.createArrowFunction(ts.visitNodes(node.modifiers, visitor, ts.isModifier), undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, node.equalsGreaterThanToken, transformConciseBody(node), node); + ts.setOriginalNode(func, node); + return func; + } + function transformFunctionBody(node) { + return transformAsyncFunctionBody(node); + } + function transformConciseBody(node) { + return transformAsyncFunctionBody(node); + } + function transformFunctionBodyWorker(body, start) { + if (start === void 0) { start = 0; } + var savedCurrentScope = currentScope; + currentScope = body; + startLexicalEnvironment(); + var statements = ts.visitNodes(body.statements, visitor, ts.isStatement, start); + var visited = ts.updateBlock(body, statements); + var declarations = endLexicalEnvironment(); + currentScope = savedCurrentScope; + return ts.mergeFunctionBodyLexicalEnvironment(visited, declarations); + } + function transformAsyncFunctionBody(node) { + var nodeType = node.original ? node.original.type : node.type; + var promiseConstructor = languageVersion < 2 ? getPromiseConstructor(nodeType) : undefined; + var isArrowFunction = node.kind === 181; + var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0; + if (!isArrowFunction) { + var statements = []; + var statementOffset = ts.addPrologueDirectives(statements, node.body.statements, false, visitor); + statements.push(ts.createReturn(ts.createAwaiterHelper(currentSourceFileExternalHelpersModuleName, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body, statementOffset)))); + var block = ts.createBlock(statements, node.body, true); + if (languageVersion >= 2) { + if (resolver.getNodeCheckFlags(node) & 4096) { + enableSubstitutionForAsyncMethodsWithSuper(); + ts.setEmitFlags(block, 8); + } + else if (resolver.getNodeCheckFlags(node) & 2048) { + enableSubstitutionForAsyncMethodsWithSuper(); + ts.setEmitFlags(block, 4); + } + } + return block; + } + else { + return ts.createAwaiterHelper(currentSourceFileExternalHelpersModuleName, hasLexicalArguments, promiseConstructor, transformConciseBodyWorker(node.body, true)); + } + } + function transformConciseBodyWorker(body, forceBlockFunctionBody) { + if (ts.isBlock(body)) { + return transformFunctionBodyWorker(body); + } + else { + startLexicalEnvironment(); + var visited = ts.visitNode(body, visitor, ts.isConciseBody); + var declarations = endLexicalEnvironment(); + var merged = ts.mergeFunctionBodyLexicalEnvironment(visited, declarations); + if (forceBlockFunctionBody && !ts.isBlock(merged)) { + return ts.createBlock([ + ts.createReturn(merged) + ]); + } + else { + return merged; + } + } + } + function getPromiseConstructor(type) { + var typeName = ts.getEntityNameFromTypeNode(type); + if (typeName && ts.isEntityName(typeName)) { + var serializationKind = resolver.getTypeReferenceSerializationKind(typeName); + if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue + || serializationKind === ts.TypeReferenceSerializationKind.Unknown) { + return typeName; + } + } + return undefined; + } + function enableSubstitutionForAsyncMethodsWithSuper() { + if ((enabledSubstitutions & 1) === 0) { + enabledSubstitutions |= 1; + context.enableSubstitution(175); + context.enableSubstitution(173); + context.enableSubstitution(174); + context.enableEmitNotification(222); + context.enableEmitNotification(148); + context.enableEmitNotification(150); + context.enableEmitNotification(151); + context.enableEmitNotification(149); + } + } + function substituteExpression(node) { + switch (node.kind) { + case 173: + return substitutePropertyAccessExpression(node); + case 174: + return substituteElementAccessExpression(node); + case 175: + if (enabledSubstitutions & 1) { + return substituteCallExpression(node); + } + break; + } + return node; + } + function substitutePropertyAccessExpression(node) { + if (enabledSubstitutions & 1 && node.expression.kind === 96) { + var flags = getSuperContainerAsyncMethodFlags(); + if (flags) { + return createSuperAccessInAsyncMethod(ts.createLiteral(node.name.text), flags, node); + } + } + return node; + } + function substituteElementAccessExpression(node) { + if (enabledSubstitutions & 1 && node.expression.kind === 96) { + var flags = getSuperContainerAsyncMethodFlags(); + if (flags) { + return createSuperAccessInAsyncMethod(node.argumentExpression, flags, node); + } + } + return node; + } + function substituteCallExpression(node) { + var expression = node.expression; + if (ts.isSuperProperty(expression)) { + var flags = getSuperContainerAsyncMethodFlags(); + if (flags) { + var argumentExpression = ts.isPropertyAccessExpression(expression) + ? substitutePropertyAccessExpression(expression) + : substituteElementAccessExpression(expression); + return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), undefined, [ + ts.createThis() + ].concat(node.arguments)); + } + } + return node; + } + function isSuperContainer(node) { + var kind = node.kind; + return kind === 222 + || kind === 149 + || kind === 148 + || kind === 150 + || kind === 151; + } + function onEmitNode(emitContext, node, emitCallback) { + var savedApplicableSubstitutions = applicableSubstitutions; + var savedCurrentSuperContainer = currentSuperContainer; + if (enabledSubstitutions & 1 && isSuperContainer(node)) { + currentSuperContainer = node; + } + previousOnEmitNode(emitContext, node, emitCallback); + applicableSubstitutions = savedApplicableSubstitutions; + currentSuperContainer = savedCurrentSuperContainer; + } + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1) { + return substituteExpression(node); + } + return node; + } + function createSuperAccessInAsyncMethod(argumentExpression, flags, location) { + if (flags & 4096) { + return ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), "value", location); + } + else { + return ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression], location); + } + } + function getSuperContainerAsyncMethodFlags() { + return currentSuperContainer !== undefined + && resolver.getNodeCheckFlags(currentSuperContainer) & (2048 | 4096); + } + } + ts.transformES2017 = transformES2017; +})(ts || (ts = {})); +var ts; +(function (ts) { + function transformES2016(context) { + var hoistVariableDeclaration = context.hoistVariableDeclaration; + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } + return ts.visitEachChild(node, visitor, context); + } + function visitor(node) { + if (node.transformFlags & 64) { + return visitorWorker(node); + } + else if (node.transformFlags & 128) { + return ts.visitEachChild(node, visitor, context); + } else { return node; } } function visitorWorker(node) { switch (node.kind) { - case 187: + case 188: return visitBinaryExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -38819,7 +38883,7 @@ var ts; function visitBinaryExpression(node) { var left = ts.visitNode(node.left, visitor, ts.isExpression); var right = ts.visitNode(node.right, visitor, ts.isExpression); - if (node.operatorToken.kind === 60) { + if (node.operatorToken.kind === 61) { var target = void 0; var value = void 0; if (ts.isElementAccessExpression(left)) { @@ -38839,7 +38903,7 @@ var ts; } return ts.createAssignment(target, ts.createMathPow(value, right, node), node); } - else if (node.operatorToken.kind === 38) { + else if (node.operatorToken.kind === 39) { return ts.createMathPow(left, right, node); } else { @@ -38848,10 +38912,1644 @@ var ts; } } } - ts.transformES7 = transformES7; + ts.transformES2016 = transformES2016; })(ts || (ts = {})); var ts; (function (ts) { + var ES2015SubstitutionFlags; + (function (ES2015SubstitutionFlags) { + ES2015SubstitutionFlags[ES2015SubstitutionFlags["CapturedThis"] = 1] = "CapturedThis"; + ES2015SubstitutionFlags[ES2015SubstitutionFlags["BlockScopedBindings"] = 2] = "BlockScopedBindings"; + })(ES2015SubstitutionFlags || (ES2015SubstitutionFlags = {})); + var CopyDirection; + (function (CopyDirection) { + CopyDirection[CopyDirection["ToOriginal"] = 0] = "ToOriginal"; + CopyDirection[CopyDirection["ToOutParameter"] = 1] = "ToOutParameter"; + })(CopyDirection || (CopyDirection = {})); + var Jump; + (function (Jump) { + Jump[Jump["Break"] = 2] = "Break"; + Jump[Jump["Continue"] = 4] = "Continue"; + Jump[Jump["Return"] = 8] = "Return"; + })(Jump || (Jump = {})); + var SuperCaptureResult; + (function (SuperCaptureResult) { + SuperCaptureResult[SuperCaptureResult["NoReplacement"] = 0] = "NoReplacement"; + SuperCaptureResult[SuperCaptureResult["ReplaceSuperCapture"] = 1] = "ReplaceSuperCapture"; + SuperCaptureResult[SuperCaptureResult["ReplaceWithReturn"] = 2] = "ReplaceWithReturn"; + })(SuperCaptureResult || (SuperCaptureResult = {})); + function transformES2015(context) { + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; + var resolver = context.getEmitResolver(); + var previousOnSubstituteNode = context.onSubstituteNode; + var previousOnEmitNode = context.onEmitNode; + context.onEmitNode = onEmitNode; + context.onSubstituteNode = onSubstituteNode; + var currentSourceFile; + var currentText; + var currentParent; + var currentNode; + var enclosingVariableStatement; + var enclosingBlockScopeContainer; + var enclosingBlockScopeContainerParent; + var enclosingFunction; + var enclosingNonArrowFunction; + var enclosingNonAsyncFunctionBody; + var convertedLoopState; + var enabledSubstitutions; + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } + currentSourceFile = node; + currentText = node.text; + return ts.visitNode(node, visitor, ts.isSourceFile); + } + function visitor(node) { + return saveStateAndInvoke(node, dispatcher); + } + function dispatcher(node) { + return convertedLoopState + ? visitorForConvertedLoopWorker(node) + : visitorWorker(node); + } + function saveStateAndInvoke(node, f) { + var savedEnclosingFunction = enclosingFunction; + var savedEnclosingNonArrowFunction = enclosingNonArrowFunction; + var savedEnclosingNonAsyncFunctionBody = enclosingNonAsyncFunctionBody; + var savedEnclosingBlockScopeContainer = enclosingBlockScopeContainer; + var savedEnclosingBlockScopeContainerParent = enclosingBlockScopeContainerParent; + var savedEnclosingVariableStatement = enclosingVariableStatement; + var savedCurrentParent = currentParent; + var savedCurrentNode = currentNode; + var savedConvertedLoopState = convertedLoopState; + if (ts.nodeStartsNewLexicalEnvironment(node)) { + convertedLoopState = undefined; + } + onBeforeVisitNode(node); + var visited = f(node); + convertedLoopState = savedConvertedLoopState; + enclosingFunction = savedEnclosingFunction; + enclosingNonArrowFunction = savedEnclosingNonArrowFunction; + enclosingNonAsyncFunctionBody = savedEnclosingNonAsyncFunctionBody; + enclosingBlockScopeContainer = savedEnclosingBlockScopeContainer; + enclosingBlockScopeContainerParent = savedEnclosingBlockScopeContainerParent; + enclosingVariableStatement = savedEnclosingVariableStatement; + currentParent = savedCurrentParent; + currentNode = savedCurrentNode; + return visited; + } + function shouldCheckNode(node) { + return (node.transformFlags & 256) !== 0 || + node.kind === 215 || + (ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node)); + } + function visitorWorker(node) { + if (shouldCheckNode(node)) { + return visitJavaScript(node); + } + else if (node.transformFlags & 512) { + return ts.visitEachChild(node, visitor, context); + } + else { + return node; + } + } + function visitorForConvertedLoopWorker(node) { + var result; + if (shouldCheckNode(node)) { + result = visitJavaScript(node); + } + else { + result = visitNodesInConvertedLoop(node); + } + return result; + } + function visitNodesInConvertedLoop(node) { + switch (node.kind) { + case 212: + return visitReturnStatement(node); + case 201: + return visitVariableStatement(node); + case 214: + return visitSwitchStatement(node); + case 211: + case 210: + return visitBreakOrContinueStatement(node); + case 98: + return visitThisKeyword(node); + case 70: + return visitIdentifier(node); + default: + return ts.visitEachChild(node, visitor, context); + } + } + function visitJavaScript(node) { + switch (node.kind) { + case 83: + return node; + case 222: + return visitClassDeclaration(node); + case 193: + return visitClassExpression(node); + case 143: + return visitParameter(node); + case 221: + return visitFunctionDeclaration(node); + case 181: + return visitArrowFunction(node); + case 180: + return visitFunctionExpression(node); + case 219: + return visitVariableDeclaration(node); + case 70: + return visitIdentifier(node); + case 220: + return visitVariableDeclarationList(node); + case 215: + return visitLabeledStatement(node); + case 205: + return visitDoStatement(node); + case 206: + return visitWhileStatement(node); + case 207: + return visitForStatement(node); + case 208: + return visitForInStatement(node); + case 209: + return visitForOfStatement(node); + case 203: + return visitExpressionStatement(node); + case 172: + return visitObjectLiteralExpression(node); + case 254: + return visitShorthandPropertyAssignment(node); + case 171: + return visitArrayLiteralExpression(node); + case 175: + return visitCallExpression(node); + case 176: + return visitNewExpression(node); + case 179: + return visitParenthesizedExpression(node, true); + case 188: + return visitBinaryExpression(node, true); + case 12: + case 13: + case 14: + case 15: + return visitTemplateLiteral(node); + case 177: + return visitTaggedTemplateExpression(node); + case 190: + return visitTemplateExpression(node); + case 191: + return visitYieldExpression(node); + case 96: + return visitSuperKeyword(); + case 191: + return ts.visitEachChild(node, visitor, context); + case 148: + return visitMethodDeclaration(node); + case 256: + return visitSourceFileNode(node); + case 201: + return visitVariableStatement(node); + default: + ts.Debug.failBadSyntaxKind(node); + return ts.visitEachChild(node, visitor, context); + } + } + function onBeforeVisitNode(node) { + if (currentNode) { + if (ts.isBlockScope(currentNode, currentParent)) { + enclosingBlockScopeContainer = currentNode; + enclosingBlockScopeContainerParent = currentParent; + } + if (ts.isFunctionLike(currentNode)) { + enclosingFunction = currentNode; + if (currentNode.kind !== 181) { + enclosingNonArrowFunction = currentNode; + if (!(ts.getEmitFlags(currentNode) & 2097152)) { + enclosingNonAsyncFunctionBody = currentNode; + } + } + } + switch (currentNode.kind) { + case 201: + enclosingVariableStatement = currentNode; + break; + case 220: + case 219: + case 170: + case 168: + case 169: + break; + default: + enclosingVariableStatement = undefined; + } + } + currentParent = currentNode; + currentNode = node; + } + function visitSwitchStatement(node) { + ts.Debug.assert(convertedLoopState !== undefined); + var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; + convertedLoopState.allowedNonLabeledJumps |= 2; + var result = ts.visitEachChild(node, visitor, context); + convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; + return result; + } + function visitReturnStatement(node) { + ts.Debug.assert(convertedLoopState !== undefined); + convertedLoopState.nonLocalJumps |= 8; + return ts.createReturn(ts.createObjectLiteral([ + ts.createPropertyAssignment(ts.createIdentifier("value"), node.expression + ? ts.visitNode(node.expression, visitor, ts.isExpression) + : ts.createVoidZero()) + ])); + } + function visitThisKeyword(node) { + ts.Debug.assert(convertedLoopState !== undefined); + if (enclosingFunction && enclosingFunction.kind === 181) { + convertedLoopState.containsLexicalThis = true; + return node; + } + return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this")); + } + function visitIdentifier(node) { + if (!convertedLoopState) { + return node; + } + if (ts.isGeneratedIdentifier(node)) { + return node; + } + if (node.text !== "arguments" && !resolver.isArgumentsLocalBinding(node)) { + return node; + } + return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = ts.createUniqueName("arguments")); + } + function visitBreakOrContinueStatement(node) { + if (convertedLoopState) { + var jump = node.kind === 211 ? 2 : 4; + var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || + (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); + if (!canUseBreakOrContinue) { + var labelMarker = void 0; + if (!node.label) { + if (node.kind === 211) { + convertedLoopState.nonLocalJumps |= 2; + labelMarker = "break"; + } + else { + convertedLoopState.nonLocalJumps |= 4; + labelMarker = "continue"; + } + } + else { + if (node.kind === 211) { + labelMarker = "break-" + node.label.text; + setLabeledJump(convertedLoopState, true, node.label.text, labelMarker); + } + else { + labelMarker = "continue-" + node.label.text; + setLabeledJump(convertedLoopState, false, node.label.text, labelMarker); + } + } + var returnExpression = ts.createLiteral(labelMarker); + if (convertedLoopState.loopOutParameters.length) { + var outParams = convertedLoopState.loopOutParameters; + var expr = void 0; + for (var i = 0; i < outParams.length; i++) { + var copyExpr = copyOutParameter(outParams[i], 1); + if (i === 0) { + expr = copyExpr; + } + else { + expr = ts.createBinary(expr, 25, copyExpr); + } + } + returnExpression = ts.createBinary(expr, 25, returnExpression); + } + return ts.createReturn(returnExpression); + } + } + return ts.visitEachChild(node, visitor, context); + } + function visitClassDeclaration(node) { + var modifierFlags = ts.getModifierFlags(node); + var isExported = modifierFlags & 1; + var isDefault = modifierFlags & 512; + var modifiers = isExported && !isDefault + ? ts.filter(node.modifiers, isExportModifier) + : undefined; + var statement = ts.createVariableStatement(modifiers, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(getDeclarationName(node, true), undefined, transformClassLikeDeclarationToExpression(node)) + ]), node); + ts.setOriginalNode(statement, node); + ts.startOnNewLine(statement); + if (isExported && isDefault) { + var statements = [statement]; + statements.push(ts.createExportAssignment(undefined, undefined, false, getDeclarationName(node, false))); + return statements; + } + return statement; + } + function isExportModifier(node) { + return node.kind === 83; + } + function visitClassExpression(node) { + return transformClassLikeDeclarationToExpression(node); + } + function transformClassLikeDeclarationToExpression(node) { + if (node.name) { + enableSubstitutionsForBlockScopedBindings(); + } + var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); + var classFunction = ts.createFunctionExpression(undefined, undefined, undefined, undefined, extendsClauseElement ? [ts.createParameter("_super")] : [], undefined, transformClassBody(node, extendsClauseElement)); + if (ts.getEmitFlags(node) & 524288) { + ts.setEmitFlags(classFunction, 524288); + } + var inner = ts.createPartiallyEmittedExpression(classFunction); + inner.end = node.end; + ts.setEmitFlags(inner, 49152); + var outer = ts.createPartiallyEmittedExpression(inner); + outer.end = ts.skipTrivia(currentText, node.pos); + ts.setEmitFlags(outer, 49152); + return ts.createParen(ts.createCall(outer, undefined, extendsClauseElement + ? [ts.visitNode(extendsClauseElement.expression, visitor, ts.isExpression)] + : [])); + } + function transformClassBody(node, extendsClauseElement) { + var statements = []; + startLexicalEnvironment(); + addExtendsHelperIfNeeded(statements, node, extendsClauseElement); + addConstructor(statements, node, extendsClauseElement); + addClassMembers(statements, node); + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 17); + var localName = getLocalName(node); + var outer = ts.createPartiallyEmittedExpression(localName); + outer.end = closingBraceLocation.end; + ts.setEmitFlags(outer, 49152); + var statement = ts.createReturn(outer); + statement.pos = closingBraceLocation.pos; + ts.setEmitFlags(statement, 49152 | 12288); + statements.push(statement); + ts.addRange(statements, endLexicalEnvironment()); + var block = ts.createBlock(ts.createNodeArray(statements, node.members), undefined, true); + ts.setEmitFlags(block, 49152); + return block; + } + function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) { + if (extendsClauseElement) { + statements.push(ts.createStatement(ts.createExtendsHelper(currentSourceFile.externalHelpersModuleName, getDeclarationName(node)), extendsClauseElement)); + } + } + function addConstructor(statements, node, extendsClauseElement) { + var constructor = ts.getFirstConstructorWithBody(node); + var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); + var constructorFunction = ts.createFunctionDeclaration(undefined, undefined, undefined, getDeclarationName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), constructor || node); + if (extendsClauseElement) { + ts.setEmitFlags(constructorFunction, 256); + } + statements.push(constructorFunction); + } + function transformConstructorParameters(constructor, hasSynthesizedSuper) { + if (constructor && !hasSynthesizedSuper) { + return ts.visitNodes(constructor.parameters, visitor, ts.isParameter); + } + return []; + } + function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { + var statements = []; + startLexicalEnvironment(); + var statementOffset = -1; + if (hasSynthesizedSuper) { + statementOffset = 1; + } + else if (constructor) { + statementOffset = ts.addPrologueDirectives(statements, constructor.body.statements, false, visitor); + } + if (constructor) { + addDefaultValueAssignmentsIfNeeded(statements, constructor); + addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); + ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); + } + var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, !!extendsClauseElement, hasSynthesizedSuper, statementOffset); + if (superCaptureStatus === 1 || superCaptureStatus === 2) { + statementOffset++; + } + if (constructor) { + var body = saveStateAndInvoke(constructor, function (constructor) { return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset); }); + ts.addRange(statements, body); + } + if (extendsClauseElement + && superCaptureStatus !== 2 + && !(constructor && isSufficientlyCoveredByReturnStatements(constructor.body))) { + statements.push(ts.createReturn(ts.createIdentifier("_this"))); + } + ts.addRange(statements, endLexicalEnvironment()); + var block = ts.createBlock(ts.createNodeArray(statements, constructor ? constructor.body.statements : node.members), constructor ? constructor.body : node, true); + if (!constructor) { + ts.setEmitFlags(block, 49152); + } + return block; + } + function isSufficientlyCoveredByReturnStatements(statement) { + if (statement.kind === 212) { + return true; + } + else if (statement.kind === 204) { + var ifStatement = statement; + if (ifStatement.elseStatement) { + return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && + isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); + } + } + else if (statement.kind === 200) { + var lastStatement = ts.lastOrUndefined(statement.statements); + if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { + return true; + } + } + return false; + } + function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, hasExtendsClause, hasSynthesizedSuper, statementOffset) { + if (!hasExtendsClause) { + if (ctor) { + addCaptureThisForNodeIfNeeded(statements, ctor); + } + return 0; + } + if (!ctor) { + statements.push(ts.createReturn(createDefaultSuperCallOrThis())); + return 2; + } + if (hasSynthesizedSuper) { + captureThisForNode(statements, ctor, createDefaultSuperCallOrThis()); + enableSubstitutionsForCapturedThis(); + return 1; + } + var firstStatement; + var superCallExpression; + var ctorStatements = ctor.body.statements; + if (statementOffset < ctorStatements.length) { + firstStatement = ctorStatements[statementOffset]; + if (firstStatement.kind === 203 && ts.isSuperCall(firstStatement.expression)) { + var superCall = firstStatement.expression; + superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); + } + } + if (superCallExpression && statementOffset === ctorStatements.length - 1) { + statements.push(ts.createReturn(superCallExpression)); + return 2; + } + captureThisForNode(statements, ctor, superCallExpression, firstStatement); + if (superCallExpression) { + return 1; + } + return 0; + } + function createDefaultSuperCallOrThis() { + var actualThis = ts.createThis(); + ts.setEmitFlags(actualThis, 128); + var superCall = ts.createFunctionApply(ts.createIdentifier("_super"), actualThis, ts.createIdentifier("arguments")); + return ts.createLogicalOr(superCall, actualThis); + } + function visitParameter(node) { + if (node.dotDotDotToken) { + return undefined; + } + else if (ts.isBindingPattern(node.name)) { + return ts.setOriginalNode(ts.createParameter(ts.getGeneratedNameForNode(node), undefined, node), node); + } + else if (node.initializer) { + return ts.setOriginalNode(ts.createParameter(node.name, undefined, node), node); + } + else { + return node; + } + } + function shouldAddDefaultValueAssignments(node) { + return (node.transformFlags & 262144) !== 0; + } + function addDefaultValueAssignmentsIfNeeded(statements, node) { + if (!shouldAddDefaultValueAssignments(node)) { + return; + } + for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { + var parameter = _a[_i]; + var name_32 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; + if (dotDotDotToken) { + continue; + } + if (ts.isBindingPattern(name_32)) { + addDefaultValueAssignmentForBindingPattern(statements, parameter, name_32, initializer); + } + else if (initializer) { + addDefaultValueAssignmentForInitializer(statements, parameter, name_32, initializer); + } + } + } + function addDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer) { + var temp = ts.getGeneratedNameForNode(parameter); + if (name.elements.length > 0) { + statements.push(ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(ts.flattenParameterDestructuring(parameter, temp, visitor))), 8388608)); + } + else if (initializer) { + statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 8388608)); + } + } + function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) { + initializer = ts.visitNode(initializer, visitor, ts.isExpression); + var statement = ts.createIf(ts.createStrictEquality(ts.getSynthesizedClone(name), ts.createVoidZero()), ts.setEmitFlags(ts.createBlock([ + ts.createStatement(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 1536), ts.setEmitFlags(initializer, 1536 | ts.getEmitFlags(initializer)), parameter)) + ], parameter), 32 | 1024 | 12288), undefined, parameter); + statement.startsOnNewLine = true; + ts.setEmitFlags(statement, 12288 | 1024 | 8388608); + statements.push(statement); + } + function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) { + return node && node.dotDotDotToken && node.name.kind === 70 && !inConstructorWithSynthesizedSuper; + } + function addRestParameterIfNeeded(statements, node, inConstructorWithSynthesizedSuper) { + var parameter = ts.lastOrUndefined(node.parameters); + if (!shouldAddRestParameter(parameter, inConstructorWithSynthesizedSuper)) { + return; + } + var declarationName = ts.getMutableClone(parameter.name); + ts.setEmitFlags(declarationName, 1536); + var expressionName = ts.getSynthesizedClone(parameter.name); + var restIndex = node.parameters.length - 1; + var temp = ts.createLoopVariable(); + statements.push(ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(declarationName, undefined, ts.createArrayLiteral([])) + ]), parameter), 8388608)); + var forStatement = ts.createFor(ts.createVariableDeclarationList([ + ts.createVariableDeclaration(temp, undefined, ts.createLiteral(restIndex)) + ], parameter), ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length"), parameter), ts.createPostfixIncrement(temp, parameter), ts.createBlock([ + ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp)), parameter)) + ])); + ts.setEmitFlags(forStatement, 8388608); + ts.startOnNewLine(forStatement); + statements.push(forStatement); + } + function addCaptureThisForNodeIfNeeded(statements, node) { + if (node.transformFlags & 65536 && node.kind !== 181) { + captureThisForNode(statements, node, ts.createThis()); + } + } + function captureThisForNode(statements, node, initializer, originalStatement) { + enableSubstitutionsForCapturedThis(); + var captureThisStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration("_this", undefined, initializer) + ]), originalStatement); + ts.setEmitFlags(captureThisStatement, 49152 | 8388608); + ts.setSourceMapRange(captureThisStatement, node); + statements.push(captureThisStatement); + } + function addClassMembers(statements, node) { + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + switch (member.kind) { + case 199: + statements.push(transformSemicolonClassElementToStatement(member)); + break; + case 148: + statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member)); + break; + case 150: + case 151: + var accessors = ts.getAllAccessorDeclarations(node.members, member); + if (member === accessors.firstAccessor) { + statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors)); + } + break; + case 149: + break; + default: + ts.Debug.failBadSyntaxKind(node); + break; + } + } + } + function transformSemicolonClassElementToStatement(member) { + return ts.createEmptyStatement(member); + } + function transformClassMethodDeclarationToStatement(receiver, member) { + var commentRange = ts.getCommentRange(member); + var sourceMapRange = ts.getSourceMapRange(member); + var func = transformFunctionLikeToExpression(member, member, undefined); + ts.setEmitFlags(func, 49152); + ts.setSourceMapRange(func, sourceMapRange); + var statement = ts.createStatement(ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), member.name), func), member); + ts.setOriginalNode(statement, member); + ts.setCommentRange(statement, commentRange); + ts.setEmitFlags(statement, 1536); + return statement; + } + function transformAccessorsToStatement(receiver, accessors) { + var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, false), ts.getSourceMapRange(accessors.firstAccessor)); + ts.setEmitFlags(statement, 49152); + return statement; + } + function transformAccessorsToExpression(receiver, _a, startsOnNewLine) { + var firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; + var target = ts.getMutableClone(receiver); + ts.setEmitFlags(target, 49152 | 1024); + ts.setSourceMapRange(target, firstAccessor.name); + var propertyName = ts.createExpressionForPropertyName(ts.visitNode(firstAccessor.name, visitor, ts.isPropertyName)); + ts.setEmitFlags(propertyName, 49152 | 512); + ts.setSourceMapRange(propertyName, firstAccessor.name); + var properties = []; + if (getAccessor) { + var getterFunction = transformFunctionLikeToExpression(getAccessor, undefined, undefined); + ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); + ts.setEmitFlags(getterFunction, 16384); + var getter = ts.createPropertyAssignment("get", getterFunction); + ts.setCommentRange(getter, ts.getCommentRange(getAccessor)); + properties.push(getter); + } + if (setAccessor) { + var setterFunction = transformFunctionLikeToExpression(setAccessor, undefined, undefined); + ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); + ts.setEmitFlags(setterFunction, 16384); + var setter = ts.createPropertyAssignment("set", setterFunction); + ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); + properties.push(setter); + } + properties.push(ts.createPropertyAssignment("enumerable", ts.createLiteral(true)), ts.createPropertyAssignment("configurable", ts.createLiteral(true))); + var call = ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ + target, + propertyName, + ts.createObjectLiteral(properties, undefined, true) + ]); + if (startsOnNewLine) { + call.startsOnNewLine = true; + } + return call; + } + function visitArrowFunction(node) { + if (node.transformFlags & 32768) { + enableSubstitutionsForCapturedThis(); + } + var func = transformFunctionLikeToExpression(node, node, undefined); + ts.setEmitFlags(func, 256); + return func; + } + function visitFunctionExpression(node) { + return transformFunctionLikeToExpression(node, node, node.name); + } + function visitFunctionDeclaration(node) { + return ts.setOriginalNode(ts.createFunctionDeclaration(undefined, node.modifiers, node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node), node); + } + function transformFunctionLikeToExpression(node, location, name) { + var savedContainingNonArrowFunction = enclosingNonArrowFunction; + if (node.kind !== 181) { + enclosingNonArrowFunction = node; + } + var expression = ts.setOriginalNode(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, saveStateAndInvoke(node, transformFunctionBody), location), node); + enclosingNonArrowFunction = savedContainingNonArrowFunction; + return expression; + } + function transformFunctionBody(node) { + var multiLine = false; + var singleLine = false; + var statementsLocation; + var closeBraceLocation; + var statements = []; + var body = node.body; + var statementOffset; + startLexicalEnvironment(); + if (ts.isBlock(body)) { + statementOffset = ts.addPrologueDirectives(statements, body.statements, false, visitor); + } + addCaptureThisForNodeIfNeeded(statements, node); + addDefaultValueAssignmentsIfNeeded(statements, node); + addRestParameterIfNeeded(statements, node, false); + if (!multiLine && statements.length > 0) { + multiLine = true; + } + if (ts.isBlock(body)) { + statementsLocation = body.statements; + ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, statementOffset)); + if (!multiLine && body.multiLine) { + multiLine = true; + } + } + else { + ts.Debug.assert(node.kind === 181); + statementsLocation = ts.moveRangeEnd(body, -1); + var equalsGreaterThanToken = node.equalsGreaterThanToken; + if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { + if (ts.rangeEndIsOnSameLineAsRangeStart(equalsGreaterThanToken, body, currentSourceFile)) { + singleLine = true; + } + else { + multiLine = true; + } + } + var expression = ts.visitNode(body, visitor, ts.isExpression); + var returnStatement = ts.createReturn(expression, body); + ts.setEmitFlags(returnStatement, 12288 | 1024 | 32768); + statements.push(returnStatement); + closeBraceLocation = body; + } + var lexicalEnvironment = endLexicalEnvironment(); + ts.addRange(statements, lexicalEnvironment); + if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { + multiLine = true; + } + var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), node.body, multiLine); + if (!multiLine && singleLine) { + ts.setEmitFlags(block, 32); + } + if (closeBraceLocation) { + ts.setTokenSourceMapRange(block, 17, closeBraceLocation); + } + ts.setOriginalNode(block, node.body); + return block; + } + function visitExpressionStatement(node) { + switch (node.expression.kind) { + case 179: + return ts.updateStatement(node, visitParenthesizedExpression(node.expression, false)); + case 188: + return ts.updateStatement(node, visitBinaryExpression(node.expression, false)); + } + return ts.visitEachChild(node, visitor, context); + } + function visitParenthesizedExpression(node, needsDestructuringValue) { + if (needsDestructuringValue) { + switch (node.expression.kind) { + case 179: + return ts.createParen(visitParenthesizedExpression(node.expression, true), node); + case 188: + return ts.createParen(visitBinaryExpression(node.expression, true), node); + } + } + return ts.visitEachChild(node, visitor, context); + } + function visitBinaryExpression(node, needsDestructuringValue) { + ts.Debug.assert(ts.isDestructuringAssignment(node)); + return ts.flattenDestructuringAssignment(context, node, needsDestructuringValue, hoistVariableDeclaration, visitor); + } + function visitVariableStatement(node) { + if (convertedLoopState && (ts.getCombinedNodeFlags(node.declarationList) & 3) == 0) { + var assignments = void 0; + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + hoistVariableDeclarationDeclaredInConvertedLoop(convertedLoopState, decl); + if (decl.initializer) { + var assignment = void 0; + if (ts.isBindingPattern(decl.name)) { + assignment = ts.flattenVariableDestructuringToExpression(decl, hoistVariableDeclaration, undefined, visitor); + } + else { + assignment = ts.createBinary(decl.name, 57, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + } + (assignments || (assignments = [])).push(assignment); + } + } + if (assignments) { + return ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25, acc); }), node); + } + else { + return undefined; + } + } + return ts.visitEachChild(node, visitor, context); + } + function visitVariableDeclarationList(node) { + if (node.flags & 3) { + enableSubstitutionsForBlockScopedBindings(); + } + var declarations = ts.flatten(ts.map(node.declarations, node.flags & 1 + ? visitVariableDeclarationInLetDeclarationList + : visitVariableDeclaration)); + var declarationList = ts.createVariableDeclarationList(declarations, node); + ts.setOriginalNode(declarationList, node); + ts.setCommentRange(declarationList, node); + if (node.transformFlags & 8388608 + && (ts.isBindingPattern(node.declarations[0].name) + || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { + var firstDeclaration = ts.firstOrUndefined(declarations); + var lastDeclaration = ts.lastOrUndefined(declarations); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + } + return declarationList; + } + function shouldEmitExplicitInitializerForLetDeclaration(node) { + var flags = resolver.getNodeCheckFlags(node); + var isCapturedInFunction = flags & 131072; + var isDeclaredInLoop = flags & 262144; + var emittedAsTopLevel = ts.isBlockScopedContainerTopLevel(enclosingBlockScopeContainer) + || (isCapturedInFunction + && isDeclaredInLoop + && ts.isBlock(enclosingBlockScopeContainer) + && ts.isIterationStatement(enclosingBlockScopeContainerParent, false)); + var emitExplicitInitializer = !emittedAsTopLevel + && enclosingBlockScopeContainer.kind !== 208 + && enclosingBlockScopeContainer.kind !== 209 + && (!resolver.isDeclarationWithCollidingName(node) + || (isDeclaredInLoop + && !isCapturedInFunction + && !ts.isIterationStatement(enclosingBlockScopeContainer, false))); + return emitExplicitInitializer; + } + function visitVariableDeclarationInLetDeclarationList(node) { + var name = node.name; + if (ts.isBindingPattern(name)) { + return visitVariableDeclaration(node); + } + if (!node.initializer && shouldEmitExplicitInitializerForLetDeclaration(node)) { + var clone_5 = ts.getMutableClone(node); + clone_5.initializer = ts.createVoidZero(); + return clone_5; + } + return ts.visitEachChild(node, visitor, context); + } + function visitVariableDeclaration(node) { + if (ts.isBindingPattern(node.name)) { + var recordTempVariablesInLine = !enclosingVariableStatement + || !ts.hasModifier(enclosingVariableStatement, 1); + return ts.flattenVariableDestructuring(node, undefined, visitor, recordTempVariablesInLine ? undefined : hoistVariableDeclaration); + } + return ts.visitEachChild(node, visitor, context); + } + function visitLabeledStatement(node) { + if (convertedLoopState) { + if (!convertedLoopState.labels) { + convertedLoopState.labels = ts.createMap(); + } + convertedLoopState.labels[node.label.text] = node.label.text; + } + var result; + if (ts.isIterationStatement(node.statement, false) && shouldConvertIterationStatementBody(node.statement)) { + result = ts.visitNodes(ts.createNodeArray([node.statement]), visitor, ts.isStatement); + } + else { + result = ts.visitEachChild(node, visitor, context); + } + if (convertedLoopState) { + convertedLoopState.labels[node.label.text] = undefined; + } + return result; + } + function visitDoStatement(node) { + return convertIterationStatementBodyIfNecessary(node); + } + function visitWhileStatement(node) { + return convertIterationStatementBodyIfNecessary(node); + } + function visitForStatement(node) { + return convertIterationStatementBodyIfNecessary(node); + } + function visitForInStatement(node) { + return convertIterationStatementBodyIfNecessary(node); + } + function visitForOfStatement(node) { + return convertIterationStatementBodyIfNecessary(node, convertForOfToFor); + } + function convertForOfToFor(node, convertedLoopBodyStatements) { + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + var initializer = node.initializer; + var statements = []; + var counter = ts.createLoopVariable(); + var rhsReference = expression.kind === 70 + ? ts.createUniqueName(expression.text) + : ts.createTempVariable(undefined); + if (ts.isVariableDeclarationList(initializer)) { + if (initializer.flags & 3) { + enableSubstitutionsForBlockScopedBindings(); + } + var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); + if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { + var declarations = ts.flattenVariableDestructuring(firstOriginalDeclaration, ts.createElementAccess(rhsReference, counter), visitor); + var declarationList = ts.createVariableDeclarationList(declarations, initializer); + ts.setOriginalNode(declarationList, initializer); + var firstDeclaration = declarations[0]; + var lastDeclaration = ts.lastOrUndefined(declarations); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + statements.push(ts.createVariableStatement(undefined, declarationList)); + } + else { + statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(undefined), undefined, ts.createElementAccess(rhsReference, counter)) + ], ts.moveRangePos(initializer, -1)), ts.moveRangeEnd(initializer, -1))); + } + } + else { + var assignment = ts.createAssignment(initializer, ts.createElementAccess(rhsReference, counter)); + if (ts.isDestructuringAssignment(assignment)) { + statements.push(ts.createStatement(ts.flattenDestructuringAssignment(context, assignment, false, hoistVariableDeclaration, visitor))); + } + else { + assignment.end = initializer.end; + statements.push(ts.createStatement(assignment, ts.moveRangeEnd(initializer, -1))); + } + } + var bodyLocation; + var statementsLocation; + if (convertedLoopBodyStatements) { + ts.addRange(statements, convertedLoopBodyStatements); + } + else { + var statement = ts.visitNode(node.statement, visitor, ts.isStatement); + if (ts.isBlock(statement)) { + ts.addRange(statements, statement.statements); + bodyLocation = statement; + statementsLocation = statement.statements; + } + else { + statements.push(statement); + } + } + ts.setEmitFlags(expression, 1536 | ts.getEmitFlags(expression)); + var body = ts.createBlock(ts.createNodeArray(statements, statementsLocation), bodyLocation); + ts.setEmitFlags(body, 1536 | 12288); + var forStatement = ts.createFor(ts.createVariableDeclarationList([ + ts.createVariableDeclaration(counter, undefined, ts.createLiteral(0), ts.moveRangePos(node.expression, -1)), + ts.createVariableDeclaration(rhsReference, undefined, expression, node.expression) + ], node.expression), ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length"), node.expression), ts.createPostfixIncrement(counter, node.expression), body, node); + ts.setEmitFlags(forStatement, 8192); + return forStatement; + } + function visitObjectLiteralExpression(node) { + var properties = node.properties; + var numProperties = properties.length; + var numInitialProperties = numProperties; + for (var i = 0; i < numProperties; i++) { + var property = properties[i]; + if (property.transformFlags & 16777216 + || property.name.kind === 141) { + numInitialProperties = i; + break; + } + } + ts.Debug.assert(numInitialProperties !== numProperties); + var temp = ts.createTempVariable(hoistVariableDeclaration); + var expressions = []; + var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), undefined, node.multiLine), 524288)); + if (node.multiLine) { + assignment.startsOnNewLine = true; + } + expressions.push(assignment); + addObjectLiteralMembers(expressions, node, temp, numInitialProperties); + expressions.push(node.multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); + return ts.inlineExpressions(expressions); + } + function shouldConvertIterationStatementBody(node) { + return (resolver.getNodeCheckFlags(node) & 65536) !== 0; + } + function hoistVariableDeclarationDeclaredInConvertedLoop(state, node) { + if (!state.hoistedLocalVariables) { + state.hoistedLocalVariables = []; + } + visit(node.name); + function visit(node) { + if (node.kind === 70) { + state.hoistedLocalVariables.push(node); + } + else { + for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!ts.isOmittedExpression(element)) { + visit(element.name); + } + } + } + } + } + function convertIterationStatementBodyIfNecessary(node, convert) { + if (!shouldConvertIterationStatementBody(node)) { + var saveAllowedNonLabeledJumps = void 0; + if (convertedLoopState) { + saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; + convertedLoopState.allowedNonLabeledJumps = 2 | 4; + } + var result = convert ? convert(node, undefined) : ts.visitEachChild(node, visitor, context); + if (convertedLoopState) { + convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps; + } + return result; + } + var functionName = ts.createUniqueName("_loop"); + var loopInitializer; + switch (node.kind) { + case 207: + case 208: + case 209: + var initializer = node.initializer; + if (initializer && initializer.kind === 220) { + loopInitializer = initializer; + } + break; + } + var loopParameters = []; + var loopOutParameters = []; + if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3)) { + for (var _i = 0, _a = loopInitializer.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + processLoopVariableDeclaration(decl, loopParameters, loopOutParameters); + } + } + var outerConvertedLoopState = convertedLoopState; + convertedLoopState = { loopOutParameters: loopOutParameters }; + if (outerConvertedLoopState) { + if (outerConvertedLoopState.argumentsName) { + convertedLoopState.argumentsName = outerConvertedLoopState.argumentsName; + } + if (outerConvertedLoopState.thisName) { + convertedLoopState.thisName = outerConvertedLoopState.thisName; + } + if (outerConvertedLoopState.hoistedLocalVariables) { + convertedLoopState.hoistedLocalVariables = outerConvertedLoopState.hoistedLocalVariables; + } + } + var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement); + var currentState = convertedLoopState; + convertedLoopState = outerConvertedLoopState; + if (loopOutParameters.length) { + var statements_3 = ts.isBlock(loopBody) ? loopBody.statements.slice() : [loopBody]; + copyOutParameters(loopOutParameters, 1, statements_3); + loopBody = ts.createBlock(statements_3, undefined, true); + } + if (!ts.isBlock(loopBody)) { + loopBody = ts.createBlock([loopBody], undefined, true); + } + var isAsyncBlockContainingAwait = enclosingNonArrowFunction + && (ts.getEmitFlags(enclosingNonArrowFunction) & 2097152) !== 0 + && (node.statement.transformFlags & 16777216) !== 0; + var loopBodyFlags = 0; + if (currentState.containsLexicalThis) { + loopBodyFlags |= 256; + } + if (isAsyncBlockContainingAwait) { + loopBodyFlags |= 2097152; + } + var convertedLoopVariable = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(functionName, undefined, ts.setEmitFlags(ts.createFunctionExpression(undefined, isAsyncBlockContainingAwait ? ts.createToken(38) : undefined, undefined, undefined, loopParameters, undefined, loopBody), loopBodyFlags)) + ])); + var statements = [convertedLoopVariable]; + var extraVariableDeclarations; + if (currentState.argumentsName) { + if (outerConvertedLoopState) { + outerConvertedLoopState.argumentsName = currentState.argumentsName; + } + else { + (extraVariableDeclarations || (extraVariableDeclarations = [])).push(ts.createVariableDeclaration(currentState.argumentsName, undefined, ts.createIdentifier("arguments"))); + } + } + if (currentState.thisName) { + if (outerConvertedLoopState) { + outerConvertedLoopState.thisName = currentState.thisName; + } + else { + (extraVariableDeclarations || (extraVariableDeclarations = [])).push(ts.createVariableDeclaration(currentState.thisName, undefined, ts.createIdentifier("this"))); + } + } + if (currentState.hoistedLocalVariables) { + if (outerConvertedLoopState) { + outerConvertedLoopState.hoistedLocalVariables = currentState.hoistedLocalVariables; + } + else { + if (!extraVariableDeclarations) { + extraVariableDeclarations = []; + } + for (var _b = 0, _c = currentState.hoistedLocalVariables; _b < _c.length; _b++) { + var identifier = _c[_b]; + extraVariableDeclarations.push(ts.createVariableDeclaration(identifier)); + } + } + } + if (loopOutParameters.length) { + if (!extraVariableDeclarations) { + extraVariableDeclarations = []; + } + for (var _d = 0, loopOutParameters_1 = loopOutParameters; _d < loopOutParameters_1.length; _d++) { + var outParam = loopOutParameters_1[_d]; + extraVariableDeclarations.push(ts.createVariableDeclaration(outParam.outParamName)); + } + } + if (extraVariableDeclarations) { + statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(extraVariableDeclarations))); + } + var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, isAsyncBlockContainingAwait); + var loop; + if (convert) { + loop = convert(node, convertedLoopBodyStatements); + } + else { + loop = ts.getMutableClone(node); + loop.statement = undefined; + loop = ts.visitEachChild(loop, visitor, context); + loop.statement = ts.createBlock(convertedLoopBodyStatements, undefined, true); + loop.transformFlags = 0; + ts.aggregateTransformFlags(loop); + } + statements.push(currentParent.kind === 215 + ? ts.createLabel(currentParent.label, loop) + : loop); + return statements; + } + function copyOutParameter(outParam, copyDirection) { + var source = copyDirection === 0 ? outParam.outParamName : outParam.originalName; + var target = copyDirection === 0 ? outParam.originalName : outParam.outParamName; + return ts.createBinary(target, 57, source); + } + function copyOutParameters(outParams, copyDirection, statements) { + for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { + var outParam = outParams_1[_i]; + statements.push(ts.createStatement(copyOutParameter(outParam, copyDirection))); + } + } + function generateCallToConvertedLoop(loopFunctionExpressionName, parameters, state, isAsyncBlockContainingAwait) { + var outerConvertedLoopState = convertedLoopState; + var statements = []; + var isSimpleLoop = !(state.nonLocalJumps & ~4) && + !state.labeledNonLocalBreaks && + !state.labeledNonLocalContinues; + var call = ts.createCall(loopFunctionExpressionName, undefined, ts.map(parameters, function (p) { return p.name; })); + var callResult = isAsyncBlockContainingAwait ? ts.createYield(ts.createToken(38), call) : call; + if (isSimpleLoop) { + statements.push(ts.createStatement(callResult)); + copyOutParameters(state.loopOutParameters, 0, statements); + } + else { + var loopResultName = ts.createUniqueName("state"); + var stateVariable = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ts.createVariableDeclaration(loopResultName, undefined, callResult)])); + statements.push(stateVariable); + copyOutParameters(state.loopOutParameters, 0, statements); + if (state.nonLocalJumps & 8) { + var returnStatement = void 0; + if (outerConvertedLoopState) { + outerConvertedLoopState.nonLocalJumps |= 8; + returnStatement = ts.createReturn(loopResultName); + } + else { + returnStatement = ts.createReturn(ts.createPropertyAccess(loopResultName, "value")); + } + statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 33, ts.createLiteral("object")), returnStatement)); + } + if (state.nonLocalJumps & 2) { + statements.push(ts.createIf(ts.createBinary(loopResultName, 33, ts.createLiteral("break")), ts.createBreak())); + } + if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { + var caseClauses = []; + processLabeledJumps(state.labeledNonLocalBreaks, true, loopResultName, outerConvertedLoopState, caseClauses); + processLabeledJumps(state.labeledNonLocalContinues, false, loopResultName, outerConvertedLoopState, caseClauses); + statements.push(ts.createSwitch(loopResultName, ts.createCaseBlock(caseClauses))); + } + } + return statements; + } + function setLabeledJump(state, isBreak, labelText, labelMarker) { + if (isBreak) { + if (!state.labeledNonLocalBreaks) { + state.labeledNonLocalBreaks = ts.createMap(); + } + state.labeledNonLocalBreaks[labelText] = labelMarker; + } + else { + if (!state.labeledNonLocalContinues) { + state.labeledNonLocalContinues = ts.createMap(); + } + state.labeledNonLocalContinues[labelText] = labelMarker; + } + } + function processLabeledJumps(table, isBreak, loopResultName, outerLoop, caseClauses) { + if (!table) { + return; + } + for (var labelText in table) { + var labelMarker = table[labelText]; + var statements = []; + if (!outerLoop || (outerLoop.labels && outerLoop.labels[labelText])) { + var label = ts.createIdentifier(labelText); + statements.push(isBreak ? ts.createBreak(label) : ts.createContinue(label)); + } + else { + setLabeledJump(outerLoop, isBreak, labelText, labelMarker); + statements.push(ts.createReturn(loopResultName)); + } + caseClauses.push(ts.createCaseClause(ts.createLiteral(labelMarker), statements)); + } + } + function processLoopVariableDeclaration(decl, loopParameters, loopOutParameters) { + var name = decl.name; + if (ts.isBindingPattern(name)) { + for (var _i = 0, _a = name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!ts.isOmittedExpression(element)) { + processLoopVariableDeclaration(element, loopParameters, loopOutParameters); + } + } + } + else { + loopParameters.push(ts.createParameter(name)); + if (resolver.getNodeCheckFlags(decl) & 2097152) { + var outParamName = ts.createUniqueName("out_" + name.text); + loopOutParameters.push({ originalName: name, outParamName: outParamName }); + } + } + } + function addObjectLiteralMembers(expressions, node, receiver, start) { + var properties = node.properties; + var numProperties = properties.length; + for (var i = start; i < numProperties; i++) { + var property = properties[i]; + switch (property.kind) { + case 150: + case 151: + var accessors = ts.getAllAccessorDeclarations(node.properties, property); + if (property === accessors.firstAccessor) { + expressions.push(transformAccessorsToExpression(receiver, accessors, node.multiLine)); + } + break; + case 253: + expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); + break; + case 254: + expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); + break; + case 148: + expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node.multiLine)); + break; + default: + ts.Debug.failBadSyntaxKind(node); + break; + } + } + } + function transformPropertyAssignmentToExpression(property, receiver, startsOnNewLine) { + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.visitNode(property.initializer, visitor, ts.isExpression), property); + if (startsOnNewLine) { + expression.startsOnNewLine = true; + } + return expression; + } + function transformShorthandPropertyAssignmentToExpression(property, receiver, startsOnNewLine) { + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.getSynthesizedClone(property.name), property); + if (startsOnNewLine) { + expression.startsOnNewLine = true; + } + return expression; + } + function transformObjectLiteralMethodDeclarationToExpression(method, receiver, startsOnNewLine) { + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, method, undefined), method); + if (startsOnNewLine) { + expression.startsOnNewLine = true; + } + return expression; + } + function visitMethodDeclaration(node) { + ts.Debug.assert(!ts.isComputedPropertyName(node.name)); + var functionExpression = transformFunctionLikeToExpression(node, ts.moveRangePos(node, -1), undefined); + ts.setEmitFlags(functionExpression, 16384 | ts.getEmitFlags(functionExpression)); + return ts.createPropertyAssignment(node.name, functionExpression, node); + } + function visitShorthandPropertyAssignment(node) { + return ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name), node); + } + function visitYieldExpression(node) { + return ts.visitEachChild(node, visitor, context); + } + function visitArrayLiteralExpression(node) { + return transformAndSpreadElements(node.elements, true, node.multiLine, node.elements.hasTrailingComma); + } + function visitCallExpression(node) { + return visitCallExpressionWithPotentialCapturedThisAssignment(node, true); + } + function visitImmediateSuperCallInBody(node) { + return visitCallExpressionWithPotentialCapturedThisAssignment(node, false); + } + function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) { + var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; + if (node.expression.kind === 96) { + ts.setEmitFlags(thisArg, 128); + } + var resultingCall; + if (node.transformFlags & 1048576) { + resultingCall = ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, false, false, false)); + } + else { + resultingCall = ts.createFunctionCall(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), node); + } + if (node.expression.kind === 96) { + var actualThis = ts.createThis(); + ts.setEmitFlags(actualThis, 128); + var initializer = ts.createLogicalOr(resultingCall, actualThis); + return assignToCapturedThis + ? ts.createAssignment(ts.createIdentifier("_this"), initializer) + : initializer; + } + return resultingCall; + } + function visitNewExpression(node) { + ts.Debug.assert((node.transformFlags & 1048576) !== 0); + var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; + return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), false, false, false)), undefined, []); + } + function transformAndSpreadElements(elements, needsUniqueCopy, multiLine, hasTrailingComma) { + var numElements = elements.length; + var segments = ts.flatten(ts.spanMap(elements, partitionSpreadElement, function (partition, visitPartition, _start, end) { + return visitPartition(partition, multiLine, hasTrailingComma && end === numElements); + })); + if (segments.length === 1) { + var firstElement = elements[0]; + return needsUniqueCopy && ts.isSpreadElementExpression(firstElement) && firstElement.expression.kind !== 171 + ? ts.createArraySlice(segments[0]) + : segments[0]; + } + return ts.createArrayConcat(segments.shift(), segments); + } + function partitionSpreadElement(node) { + return ts.isSpreadElementExpression(node) + ? visitSpanOfSpreadElements + : visitSpanOfNonSpreadElements; + } + function visitSpanOfSpreadElements(chunk) { + return ts.map(chunk, visitExpressionOfSpreadElement); + } + function visitSpanOfNonSpreadElements(chunk, multiLine, hasTrailingComma) { + return ts.createArrayLiteral(ts.visitNodes(ts.createNodeArray(chunk, undefined, hasTrailingComma), visitor, ts.isExpression), undefined, multiLine); + } + function visitExpressionOfSpreadElement(node) { + return ts.visitNode(node.expression, visitor, ts.isExpression); + } + function visitTemplateLiteral(node) { + return ts.createLiteral(node.text, node); + } + function visitTaggedTemplateExpression(node) { + var tag = ts.visitNode(node.tag, visitor, ts.isExpression); + var temp = ts.createTempVariable(hoistVariableDeclaration); + var templateArguments = [temp]; + var cookedStrings = []; + var rawStrings = []; + var template = node.template; + if (ts.isNoSubstitutionTemplateLiteral(template)) { + cookedStrings.push(ts.createLiteral(template.text)); + rawStrings.push(getRawLiteral(template)); + } + else { + cookedStrings.push(ts.createLiteral(template.head.text)); + rawStrings.push(getRawLiteral(template.head)); + for (var _i = 0, _a = template.templateSpans; _i < _a.length; _i++) { + var templateSpan = _a[_i]; + cookedStrings.push(ts.createLiteral(templateSpan.literal.text)); + rawStrings.push(getRawLiteral(templateSpan.literal)); + templateArguments.push(ts.visitNode(templateSpan.expression, visitor, ts.isExpression)); + } + } + return ts.createParen(ts.inlineExpressions([ + ts.createAssignment(temp, ts.createArrayLiteral(cookedStrings)), + ts.createAssignment(ts.createPropertyAccess(temp, "raw"), ts.createArrayLiteral(rawStrings)), + ts.createCall(tag, undefined, templateArguments) + ])); + } + function getRawLiteral(node) { + var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); + var isLast = node.kind === 12 || node.kind === 15; + text = text.substring(1, text.length - (isLast ? 1 : 2)); + text = text.replace(/\r\n?/g, "\n"); + return ts.createLiteral(text, node); + } + function visitTemplateExpression(node) { + var expressions = []; + addTemplateHead(expressions, node); + addTemplateSpans(expressions, node); + var expression = ts.reduceLeft(expressions, ts.createAdd); + if (ts.nodeIsSynthesized(expression)) { + ts.setTextRange(expression, node); + } + return expression; + } + function shouldAddTemplateHead(node) { + ts.Debug.assert(node.templateSpans.length !== 0); + return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0; + } + function addTemplateHead(expressions, node) { + if (!shouldAddTemplateHead(node)) { + return; + } + expressions.push(ts.createLiteral(node.head.text)); + } + function addTemplateSpans(expressions, node) { + for (var _i = 0, _a = node.templateSpans; _i < _a.length; _i++) { + var span_6 = _a[_i]; + expressions.push(ts.visitNode(span_6.expression, visitor, ts.isExpression)); + if (span_6.literal.text.length !== 0) { + expressions.push(ts.createLiteral(span_6.literal.text)); + } + } + } + function visitSuperKeyword() { + return enclosingNonAsyncFunctionBody + && ts.isClassElement(enclosingNonAsyncFunctionBody) + && !ts.hasModifier(enclosingNonAsyncFunctionBody, 32) + && currentParent.kind !== 175 + ? ts.createPropertyAccess(ts.createIdentifier("_super"), "prototype") + : ts.createIdentifier("_super"); + } + function visitSourceFileNode(node) { + var _a = ts.span(node.statements, ts.isPrologueDirective), prologue = _a[0], remaining = _a[1]; + var statements = []; + startLexicalEnvironment(); + ts.addRange(statements, prologue); + addCaptureThisForNodeIfNeeded(statements, node); + ts.addRange(statements, ts.visitNodes(ts.createNodeArray(remaining), visitor, ts.isStatement)); + ts.addRange(statements, endLexicalEnvironment()); + var clone = ts.getMutableClone(node); + clone.statements = ts.createNodeArray(statements, node.statements); + return clone; + } + function onEmitNode(emitContext, node, emitCallback) { + var savedEnclosingFunction = enclosingFunction; + if (enabledSubstitutions & 1 && ts.isFunctionLike(node)) { + enclosingFunction = node; + } + previousOnEmitNode(emitContext, node, emitCallback); + enclosingFunction = savedEnclosingFunction; + } + function enableSubstitutionsForBlockScopedBindings() { + if ((enabledSubstitutions & 2) === 0) { + enabledSubstitutions |= 2; + context.enableSubstitution(70); + } + } + function enableSubstitutionsForCapturedThis() { + if ((enabledSubstitutions & 1) === 0) { + enabledSubstitutions |= 1; + context.enableSubstitution(98); + context.enableEmitNotification(149); + context.enableEmitNotification(148); + context.enableEmitNotification(150); + context.enableEmitNotification(151); + context.enableEmitNotification(181); + context.enableEmitNotification(180); + context.enableEmitNotification(221); + } + } + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1) { + return substituteExpression(node); + } + if (ts.isIdentifier(node)) { + return substituteIdentifier(node); + } + return node; + } + function substituteIdentifier(node) { + if (enabledSubstitutions & 2) { + var original = ts.getParseTreeNode(node, ts.isIdentifier); + if (original && isNameOfDeclarationWithCollidingName(original)) { + return ts.getGeneratedNameForNode(original); + } + } + return node; + } + function isNameOfDeclarationWithCollidingName(node) { + var parent = node.parent; + switch (parent.kind) { + case 170: + case 222: + case 225: + case 219: + return parent.name === node + && resolver.isDeclarationWithCollidingName(parent); + } + return false; + } + function substituteExpression(node) { + switch (node.kind) { + case 70: + return substituteExpressionIdentifier(node); + case 98: + return substituteThisKeyword(node); + } + return node; + } + function substituteExpressionIdentifier(node) { + if (enabledSubstitutions & 2) { + var declaration = resolver.getReferencedDeclarationWithCollidingName(node); + if (declaration) { + return ts.getGeneratedNameForNode(declaration.name); + } + } + return node; + } + function substituteThisKeyword(node) { + if (enabledSubstitutions & 1 + && enclosingFunction + && ts.getEmitFlags(enclosingFunction) & 256) { + return ts.createIdentifier("_this", node); + } + return node; + } + function getLocalName(node, allowComments, allowSourceMaps) { + return getDeclarationName(node, allowComments, allowSourceMaps, 262144); + } + function getDeclarationName(node, allowComments, allowSourceMaps, emitFlags) { + if (node.name && !ts.isGeneratedIdentifier(node.name)) { + var name_33 = ts.getMutableClone(node.name); + emitFlags |= ts.getEmitFlags(node.name); + if (!allowSourceMaps) { + emitFlags |= 1536; + } + if (!allowComments) { + emitFlags |= 49152; + } + if (emitFlags) { + ts.setEmitFlags(name_33, emitFlags); + } + return name_33; + } + return ts.getGeneratedNameForNode(node); + } + function getClassMemberPrefix(node, member) { + var expression = getLocalName(node); + return ts.hasModifier(member, 32) ? expression : ts.createPropertyAccess(expression, "prototype"); + } + function hasSynthesizedDefaultSuperCall(constructor, hasExtendsClause) { + if (!constructor || !hasExtendsClause) { + return false; + } + var parameter = ts.singleOrUndefined(constructor.parameters); + if (!parameter || !ts.nodeIsSynthesized(parameter) || !parameter.dotDotDotToken) { + return false; + } + var statement = ts.firstOrUndefined(constructor.body.statements); + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 203) { + return false; + } + var statementExpression = statement.expression; + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 175) { + return false; + } + var callTarget = statementExpression.expression; + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 96) { + return false; + } + var callArgument = ts.singleOrUndefined(statementExpression.arguments); + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 192) { + return false; + } + var expression = callArgument.expression; + return ts.isIdentifier(expression) && expression === parameter.name; + } + } + ts.transformES2015 = transformES2015; +})(ts || (ts = {})); +var ts; +(function (ts) { + var OpCode; + (function (OpCode) { + OpCode[OpCode["Nop"] = 0] = "Nop"; + OpCode[OpCode["Statement"] = 1] = "Statement"; + OpCode[OpCode["Assign"] = 2] = "Assign"; + OpCode[OpCode["Break"] = 3] = "Break"; + OpCode[OpCode["BreakWhenTrue"] = 4] = "BreakWhenTrue"; + OpCode[OpCode["BreakWhenFalse"] = 5] = "BreakWhenFalse"; + OpCode[OpCode["Yield"] = 6] = "Yield"; + OpCode[OpCode["YieldStar"] = 7] = "YieldStar"; + OpCode[OpCode["Return"] = 8] = "Return"; + OpCode[OpCode["Throw"] = 9] = "Throw"; + OpCode[OpCode["Endfinally"] = 10] = "Endfinally"; + })(OpCode || (OpCode = {})); + var BlockAction; + (function (BlockAction) { + BlockAction[BlockAction["Open"] = 0] = "Open"; + BlockAction[BlockAction["Close"] = 1] = "Close"; + })(BlockAction || (BlockAction = {})); + var CodeBlockKind; + (function (CodeBlockKind) { + CodeBlockKind[CodeBlockKind["Exception"] = 0] = "Exception"; + CodeBlockKind[CodeBlockKind["With"] = 1] = "With"; + CodeBlockKind[CodeBlockKind["Switch"] = 2] = "Switch"; + CodeBlockKind[CodeBlockKind["Loop"] = 3] = "Loop"; + CodeBlockKind[CodeBlockKind["Labeled"] = 4] = "Labeled"; + })(CodeBlockKind || (CodeBlockKind = {})); + var ExceptionBlockState; + (function (ExceptionBlockState) { + ExceptionBlockState[ExceptionBlockState["Try"] = 0] = "Try"; + ExceptionBlockState[ExceptionBlockState["Catch"] = 1] = "Catch"; + ExceptionBlockState[ExceptionBlockState["Finally"] = 2] = "Finally"; + ExceptionBlockState[ExceptionBlockState["Done"] = 3] = "Done"; + })(ExceptionBlockState || (ExceptionBlockState = {})); + var Instruction; + (function (Instruction) { + Instruction[Instruction["Next"] = 0] = "Next"; + Instruction[Instruction["Throw"] = 1] = "Throw"; + Instruction[Instruction["Return"] = 2] = "Return"; + Instruction[Instruction["Break"] = 3] = "Break"; + Instruction[Instruction["Yield"] = 4] = "Yield"; + Instruction[Instruction["YieldStar"] = 5] = "YieldStar"; + Instruction[Instruction["Catch"] = 6] = "Catch"; + Instruction[Instruction["Endfinally"] = 7] = "Endfinally"; + })(Instruction || (Instruction = {})); var instructionNames = ts.createMap((_a = {}, _a[2] = "return", _a[3] = "break", @@ -38897,7 +40595,7 @@ var ts; if (ts.isDeclarationFile(node)) { return node; } - if (node.transformFlags & 1024) { + if (node.transformFlags & 4096) { currentSourceFile = node; node = ts.visitEachChild(node, visitor, context); currentSourceFile = undefined; @@ -38912,10 +40610,10 @@ var ts; else if (inGeneratorFunctionBody) { return visitJavaScriptInGeneratorFunctionBody(node); } - else if (transformFlags & 512) { + else if (transformFlags & 2048) { return visitGenerator(node); } - else if (transformFlags & 1024) { + else if (transformFlags & 4096) { return ts.visitEachChild(node, visitor, context); } else { @@ -38924,13 +40622,13 @@ var ts; } function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 204: - return visitDoStatement(node); case 205: + return visitDoStatement(node); + case 206: return visitWhileStatement(node); - case 213: - return visitSwitchStatement(node); case 214: + return visitSwitchStatement(node); + case 215: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -38938,30 +40636,30 @@ var ts; } function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 220: + case 221: return visitFunctionDeclaration(node); - case 179: + case 180: return visitFunctionExpression(node); - case 149: case 150: + case 151: return visitAccessorDeclaration(node); - case 200: + case 201: return visitVariableStatement(node); - case 206: - return visitForStatement(node); case 207: + return visitForStatement(node); + case 208: return visitForInStatement(node); - case 210: - return visitBreakStatement(node); - case 209: - return visitContinueStatement(node); case 211: + return visitBreakStatement(node); + case 210: + return visitContinueStatement(node); + case 212: return visitReturnStatement(node); default: - if (node.transformFlags & 4194304) { + if (node.transformFlags & 16777216) { return visitJavaScriptContainingYield(node); } - else if (node.transformFlags & (1024 | 8388608)) { + else if (node.transformFlags & (4096 | 33554432)) { return ts.visitEachChild(node, visitor, context); } else { @@ -38971,21 +40669,21 @@ var ts; } function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 187: - return visitBinaryExpression(node); case 188: + return visitBinaryExpression(node); + case 189: return visitConditionalExpression(node); - case 190: + case 191: return visitYieldExpression(node); - case 170: - return visitArrayLiteralExpression(node); case 171: + return visitArrayLiteralExpression(node); + case 172: return visitObjectLiteralExpression(node); - case 173: - return visitElementAccessExpression(node); case 174: - return visitCallExpression(node); + return visitElementAccessExpression(node); case 175: + return visitCallExpression(node); + case 176: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -38993,9 +40691,9 @@ var ts; } function visitGenerator(node) { switch (node.kind) { - case 220: + case 221: return visitFunctionDeclaration(node); - case 179: + case 180: return visitFunctionExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -39025,7 +40723,7 @@ var ts; } function visitFunctionExpression(node) { if (node.asteriskToken && ts.getEmitFlags(node) & 2097152) { - node = ts.setOriginalNode(ts.createFunctionExpression(undefined, node.name, undefined, node.parameters, undefined, transformGeneratorFunctionBody(node.body), node), node); + node = ts.setOriginalNode(ts.createFunctionExpression(undefined, undefined, node.name, undefined, node.parameters, undefined, transformGeneratorFunctionBody(node.body), node), node); } else { var savedInGeneratorFunctionBody = inGeneratorFunctionBody; @@ -39098,7 +40796,7 @@ var ts; return ts.createBlock(statements, body, body.multiLine); } function visitVariableStatement(node) { - if (node.transformFlags & 4194304) { + if (node.transformFlags & 16777216) { transformAndEmitVariableDeclarationList(node.declarationList); return undefined; } @@ -39128,23 +40826,23 @@ var ts; } } function isCompoundAssignment(kind) { - return kind >= 57 - && kind <= 68; + return kind >= 58 + && kind <= 69; } function getOperatorForCompoundAssignment(kind) { switch (kind) { - case 57: return 35; case 58: return 36; case 59: return 37; case 60: return 38; case 61: return 39; case 62: return 40; - case 63: return 43; + case 63: return 41; case 64: return 44; case 65: return 45; case 66: return 46; case 67: return 47; case 68: return 48; + case 69: return 49; } } function visitRightAssociativeBinaryExpression(node) { @@ -39152,10 +40850,10 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 172: + case 173: target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 173: + case 174: target = ts.updateElementAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), cacheExpression(ts.visitNode(left.argumentExpression, visitor, ts.isExpression))); break; default: @@ -39164,7 +40862,7 @@ var ts; } var operator = node.operatorToken.kind; if (isCompoundAssignment(operator)) { - return ts.createBinary(target, 56, ts.createBinary(cacheExpression(target), getOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression), node), node); + return ts.createBinary(target, 57, ts.createBinary(cacheExpression(target), getOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression), node), node); } else { return ts.updateBinary(node, target, ts.visitNode(right, visitor, ts.isExpression)); @@ -39177,13 +40875,13 @@ var ts; if (ts.isLogicalOperator(node.operatorToken.kind)) { return visitLogicalBinaryExpression(node); } - else if (node.operatorToken.kind === 24) { + else if (node.operatorToken.kind === 25) { return visitCommaExpression(node); } - var clone_5 = ts.getMutableClone(node); - clone_5.left = cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression)); - clone_5.right = ts.visitNode(node.right, visitor, ts.isExpression); - return clone_5; + var clone_6 = ts.getMutableClone(node); + clone_6.left = cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression)); + clone_6.right = ts.visitNode(node.right, visitor, ts.isExpression); + return clone_6; } return ts.visitEachChild(node, visitor, context); } @@ -39191,7 +40889,7 @@ var ts; var resultLabel = defineLabel(); var resultLocal = declareLocal(); emitAssignment(resultLocal, ts.visitNode(node.left, visitor, ts.isExpression), node.left); - if (node.operatorToken.kind === 51) { + if (node.operatorToken.kind === 52) { emitBreakWhenFalse(resultLabel, resultLocal, node.left); } else { @@ -39207,7 +40905,7 @@ var ts; visit(node.right); return ts.inlineExpressions(pendingExpressions); function visit(node) { - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 24) { + if (ts.isBinaryExpression(node) && node.operatorToken.kind === 25) { visit(node.left); visit(node.right); } @@ -39250,7 +40948,7 @@ var ts; function visitArrayLiteralExpression(node) { return visitElements(node.elements, node.multiLine); } - function visitElements(elements, multiLine) { + function visitElements(elements, _multiLine) { var numInitialElements = countInitialNodesWithoutYield(elements); var temp = declareLocal(); var hasAssignedTemp = false; @@ -39301,24 +40999,24 @@ var ts; } function visitElementAccessExpression(node) { if (containsYield(node.argumentExpression)) { - var clone_6 = ts.getMutableClone(node); - clone_6.expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); - clone_6.argumentExpression = ts.visitNode(node.argumentExpression, visitor, ts.isExpression); - return clone_6; + var clone_7 = ts.getMutableClone(node); + clone_7.expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); + clone_7.argumentExpression = ts.visitNode(node.argumentExpression, visitor, ts.isExpression); + return clone_7; } return ts.visitEachChild(node, visitor, context); } function visitCallExpression(node) { if (ts.forEach(node.arguments, containsYield)) { var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration, languageVersion, true), target = _a.target, thisArg = _a.thisArg; - return ts.setOriginalNode(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isLeftHandSideExpression)), thisArg, visitElements(node.arguments, false), node), node); + return ts.setOriginalNode(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isLeftHandSideExpression)), thisArg, visitElements(node.arguments), node), node); } return ts.visitEachChild(node, visitor, context); } function visitNewExpression(node) { if (ts.forEach(node.arguments, containsYield)) { var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.setOriginalNode(ts.createNew(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isExpression)), thisArg, visitElements(node.arguments, false)), undefined, [], node), node); + return ts.setOriginalNode(ts.createNew(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isExpression)), thisArg, visitElements(node.arguments)), undefined, [], node), node); } return ts.visitEachChild(node, visitor, context); } @@ -39347,35 +41045,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 199: + case 200: return transformAndEmitBlock(node); - case 202: - return transformAndEmitExpressionStatement(node); case 203: - return transformAndEmitIfStatement(node); + return transformAndEmitExpressionStatement(node); case 204: - return transformAndEmitDoStatement(node); + return transformAndEmitIfStatement(node); case 205: - return transformAndEmitWhileStatement(node); + return transformAndEmitDoStatement(node); case 206: - return transformAndEmitForStatement(node); + return transformAndEmitWhileStatement(node); case 207: + return transformAndEmitForStatement(node); + case 208: return transformAndEmitForInStatement(node); - case 209: - return transformAndEmitContinueStatement(node); case 210: - return transformAndEmitBreakStatement(node); + return transformAndEmitContinueStatement(node); case 211: - return transformAndEmitReturnStatement(node); + return transformAndEmitBreakStatement(node); case 212: - return transformAndEmitWithStatement(node); + return transformAndEmitReturnStatement(node); case 213: - return transformAndEmitSwitchStatement(node); + return transformAndEmitWithStatement(node); case 214: - return transformAndEmitLabeledStatement(node); + return transformAndEmitSwitchStatement(node); case 215: - return transformAndEmitThrowStatement(node); + return transformAndEmitLabeledStatement(node); case 216: + return transformAndEmitThrowStatement(node); + case 217: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement, true)); @@ -39760,7 +41458,7 @@ var ts; } } function containsYield(node) { - return node && (node.transformFlags & 4194304) !== 0; + return node && (node.transformFlags & 16777216) !== 0; } function countInitialNodesWithoutYield(nodes) { var numNodes = nodes.length; @@ -39790,12 +41488,12 @@ var ts; if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - var name_37 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); - if (name_37) { - var clone_7 = ts.getMutableClone(name_37); - ts.setSourceMapRange(clone_7, node); - ts.setCommentRange(clone_7, node); - return clone_7; + var name_34 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); + if (name_34) { + var clone_8 = ts.getMutableClone(name_34); + ts.setSourceMapRange(clone_8, node); + ts.setCommentRange(clone_8, node); + return clone_8; } } } @@ -39901,7 +41599,7 @@ var ts; if (!renamedCatchVariables) { renamedCatchVariables = ts.createMap(); renamedCatchVariableDeclarations = ts.createMap(); - context.enableSubstitution(69); + context.enableSubstitution(70); } renamedCatchVariables[text] = true; renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; @@ -40100,7 +41798,7 @@ var ts; } return expression; } - return ts.createNode(193); + return ts.createNode(194); } function createInstruction(instruction) { var literal = ts.createLiteral(instruction); @@ -40188,7 +41886,7 @@ var ts; var buildResult = buildStatements(); return ts.createCall(ts.createHelperName(currentSourceFile.externalHelpersModuleName, "__generator"), undefined, [ ts.createThis(), - ts.setEmitFlags(ts.createFunctionExpression(undefined, undefined, undefined, [ts.createParameter(state)], undefined, ts.createBlock(buildResult, undefined, buildResult.length > 0)), 4194304) + ts.setEmitFlags(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(state)], undefined, ts.createBlock(buildResult, undefined, buildResult.length > 0)), 4194304) ]); } function buildStatements() { @@ -40456,1456 +42154,468 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function transformES6(context) { + function transformES5(context) { + var previousOnSubstituteNode = context.onSubstituteNode; + context.onSubstituteNode = onSubstituteNode; + context.enableSubstitution(173); + context.enableSubstitution(253); + return transformSourceFile; + function transformSourceFile(node) { + return node; + } + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (ts.isPropertyAccessExpression(node)) { + return substitutePropertyAccessExpression(node); + } + else if (ts.isPropertyAssignment(node)) { + return substitutePropertyAssignment(node); + } + return node; + } + function substitutePropertyAccessExpression(node) { + var literalName = trySubstituteReservedName(node.name); + if (literalName) { + return ts.createElementAccess(node.expression, literalName, node); + } + return node; + } + function substitutePropertyAssignment(node) { + var literalName = ts.isIdentifier(node.name) && trySubstituteReservedName(node.name); + if (literalName) { + return ts.updatePropertyAssignment(node, literalName, node.initializer); + } + return node; + } + function trySubstituteReservedName(name) { + var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(name.text) : undefined); + if (token >= 71 && token <= 106) { + return ts.createLiteral(name, name); + } + return undefined; + } + } + ts.transformES5 = transformES5; +})(ts || (ts = {})); +var ts; +(function (ts) { + function transformModule(context) { + var transformModuleDelegates = ts.createMap((_a = {}, + _a[ts.ModuleKind.None] = transformCommonJSModule, + _a[ts.ModuleKind.CommonJS] = transformCommonJSModule, + _a[ts.ModuleKind.AMD] = transformAMDModule, + _a[ts.ModuleKind.UMD] = transformUMDModule, + _a)); var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; + var compilerOptions = context.getCompilerOptions(); var resolver = context.getEmitResolver(); + var host = context.getEmitHost(); + var languageVersion = ts.getEmitScriptTarget(compilerOptions); + var moduleKind = ts.getEmitModuleKind(compilerOptions); var previousOnSubstituteNode = context.onSubstituteNode; var previousOnEmitNode = context.onEmitNode; - context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; + context.onEmitNode = onEmitNode; + context.enableSubstitution(70); + context.enableSubstitution(188); + context.enableSubstitution(186); + context.enableSubstitution(187); + context.enableSubstitution(254); + context.enableEmitNotification(256); var currentSourceFile; - var currentText; - var currentParent; - var currentNode; - var enclosingVariableStatement; - var enclosingBlockScopeContainer; - var enclosingBlockScopeContainerParent; - var enclosingFunction; - var enclosingNonArrowFunction; - var enclosingNonAsyncFunctionBody; - var convertedLoopState; - var enabledSubstitutions; + var externalImports; + var exportSpecifiers; + var exportEquals; + var bindingNameExportSpecifiersMap; + var bindingNameExportSpecifiersForFileMap = ts.createMap(); + var hasExportStarsToExportValues; return transformSourceFile; function transformSourceFile(node) { if (ts.isDeclarationFile(node)) { return node; } - currentSourceFile = node; - currentText = node.text; - return ts.visitNode(node, visitor, ts.isSourceFile); - } - function visitor(node) { - return saveStateAndInvoke(node, dispatcher); - } - function dispatcher(node) { - return convertedLoopState - ? visitorForConvertedLoopWorker(node) - : visitorWorker(node); - } - function saveStateAndInvoke(node, f) { - var savedEnclosingFunction = enclosingFunction; - var savedEnclosingNonArrowFunction = enclosingNonArrowFunction; - var savedEnclosingNonAsyncFunctionBody = enclosingNonAsyncFunctionBody; - var savedEnclosingBlockScopeContainer = enclosingBlockScopeContainer; - var savedEnclosingBlockScopeContainerParent = enclosingBlockScopeContainerParent; - var savedEnclosingVariableStatement = enclosingVariableStatement; - var savedCurrentParent = currentParent; - var savedCurrentNode = currentNode; - var savedConvertedLoopState = convertedLoopState; - if (ts.nodeStartsNewLexicalEnvironment(node)) { - convertedLoopState = undefined; + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + currentSourceFile = node; + (_a = ts.collectExternalModuleInfo(node), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); + var transformModule_1 = transformModuleDelegates[moduleKind] || transformModuleDelegates[ts.ModuleKind.None]; + var updated = transformModule_1(node); + ts.aggregateTransformFlags(updated); + currentSourceFile = undefined; + externalImports = undefined; + exportSpecifiers = undefined; + exportEquals = undefined; + hasExportStarsToExportValues = false; + return updated; } - onBeforeVisitNode(node); - var visited = f(node); - convertedLoopState = savedConvertedLoopState; - enclosingFunction = savedEnclosingFunction; - enclosingNonArrowFunction = savedEnclosingNonArrowFunction; - enclosingNonAsyncFunctionBody = savedEnclosingNonAsyncFunctionBody; - enclosingBlockScopeContainer = savedEnclosingBlockScopeContainer; - enclosingBlockScopeContainerParent = savedEnclosingBlockScopeContainerParent; - enclosingVariableStatement = savedEnclosingVariableStatement; - currentParent = savedCurrentParent; - currentNode = savedCurrentNode; - return visited; + return node; + var _a; } - function shouldCheckNode(node) { - return (node.transformFlags & 64) !== 0 || - node.kind === 214 || - (ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node)); - } - function visitorWorker(node) { - if (shouldCheckNode(node)) { - return visitJavaScript(node); - } - else if (node.transformFlags & 128) { - return ts.visitEachChild(node, visitor, context); - } - else { - return node; - } - } - function visitorForConvertedLoopWorker(node) { - var result; - if (shouldCheckNode(node)) { - result = visitJavaScript(node); - } - else { - result = visitNodesInConvertedLoop(node); - } - return result; - } - function visitNodesInConvertedLoop(node) { - switch (node.kind) { - case 211: - return visitReturnStatement(node); - case 200: - return visitVariableStatement(node); - case 213: - return visitSwitchStatement(node); - case 210: - case 209: - return visitBreakOrContinueStatement(node); - case 97: - return visitThisKeyword(node); - case 69: - return visitIdentifier(node); - default: - return ts.visitEachChild(node, visitor, context); - } - } - function visitJavaScript(node) { - switch (node.kind) { - case 82: - return node; - case 221: - return visitClassDeclaration(node); - case 192: - return visitClassExpression(node); - case 142: - return visitParameter(node); - case 220: - return visitFunctionDeclaration(node); - case 180: - return visitArrowFunction(node); - case 179: - return visitFunctionExpression(node); - case 218: - return visitVariableDeclaration(node); - case 69: - return visitIdentifier(node); - case 219: - return visitVariableDeclarationList(node); - case 214: - return visitLabeledStatement(node); - case 204: - return visitDoStatement(node); - case 205: - return visitWhileStatement(node); - case 206: - return visitForStatement(node); - case 207: - return visitForInStatement(node); - case 208: - return visitForOfStatement(node); - case 202: - return visitExpressionStatement(node); - case 171: - return visitObjectLiteralExpression(node); - case 254: - return visitShorthandPropertyAssignment(node); - case 170: - return visitArrayLiteralExpression(node); - case 174: - return visitCallExpression(node); - case 175: - return visitNewExpression(node); - case 178: - return visitParenthesizedExpression(node, true); - case 187: - return visitBinaryExpression(node, true); - case 11: - case 12: - case 13: - case 14: - return visitTemplateLiteral(node); - case 176: - return visitTaggedTemplateExpression(node); - case 189: - return visitTemplateExpression(node); - case 190: - return visitYieldExpression(node); - case 95: - return visitSuperKeyword(node); - case 190: - return ts.visitEachChild(node, visitor, context); - case 147: - return visitMethodDeclaration(node); - case 256: - return visitSourceFileNode(node); - case 200: - return visitVariableStatement(node); - default: - ts.Debug.failBadSyntaxKind(node); - return ts.visitEachChild(node, visitor, context); - } - } - function onBeforeVisitNode(node) { - if (currentNode) { - if (ts.isBlockScope(currentNode, currentParent)) { - enclosingBlockScopeContainer = currentNode; - enclosingBlockScopeContainerParent = currentParent; - } - if (ts.isFunctionLike(currentNode)) { - enclosingFunction = currentNode; - if (currentNode.kind !== 180) { - enclosingNonArrowFunction = currentNode; - if (!(ts.getEmitFlags(currentNode) & 2097152)) { - enclosingNonAsyncFunctionBody = currentNode; - } - } - } - switch (currentNode.kind) { - case 200: - enclosingVariableStatement = currentNode; - break; - case 219: - case 218: - case 169: - case 167: - case 168: - break; - default: - enclosingVariableStatement = undefined; - } - } - currentParent = currentNode; - currentNode = node; - } - function visitSwitchStatement(node) { - ts.Debug.assert(convertedLoopState !== undefined); - var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; - convertedLoopState.allowedNonLabeledJumps |= 2; - var result = ts.visitEachChild(node, visitor, context); - convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; - return result; - } - function visitReturnStatement(node) { - ts.Debug.assert(convertedLoopState !== undefined); - convertedLoopState.nonLocalJumps |= 8; - return ts.createReturn(ts.createObjectLiteral([ - ts.createPropertyAssignment(ts.createIdentifier("value"), node.expression - ? ts.visitNode(node.expression, visitor, ts.isExpression) - : ts.createVoidZero()) - ])); - } - function visitThisKeyword(node) { - ts.Debug.assert(convertedLoopState !== undefined); - if (enclosingFunction && enclosingFunction.kind === 180) { - convertedLoopState.containsLexicalThis = true; - return node; - } - return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this")); - } - function visitIdentifier(node) { - if (!convertedLoopState) { - return node; - } - if (ts.isGeneratedIdentifier(node)) { - return node; - } - if (node.text !== "arguments" && !resolver.isArgumentsLocalBinding(node)) { - return node; - } - return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = ts.createUniqueName("arguments")); - } - function visitBreakOrContinueStatement(node) { - if (convertedLoopState) { - var jump = node.kind === 210 ? 2 : 4; - var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || - (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); - if (!canUseBreakOrContinue) { - var labelMarker = void 0; - if (!node.label) { - if (node.kind === 210) { - convertedLoopState.nonLocalJumps |= 2; - labelMarker = "break"; - } - else { - convertedLoopState.nonLocalJumps |= 4; - labelMarker = "continue"; - } - } - else { - if (node.kind === 210) { - labelMarker = "break-" + node.label.text; - setLabeledJump(convertedLoopState, true, node.label.text, labelMarker); - } - else { - labelMarker = "continue-" + node.label.text; - setLabeledJump(convertedLoopState, false, node.label.text, labelMarker); - } - } - var returnExpression = ts.createLiteral(labelMarker); - if (convertedLoopState.loopOutParameters.length) { - var outParams = convertedLoopState.loopOutParameters; - var expr = void 0; - for (var i = 0; i < outParams.length; i++) { - var copyExpr = copyOutParameter(outParams[i], 1); - if (i === 0) { - expr = copyExpr; - } - else { - expr = ts.createBinary(expr, 24, copyExpr); - } - } - returnExpression = ts.createBinary(expr, 24, returnExpression); - } - return ts.createReturn(returnExpression); - } - } - return ts.visitEachChild(node, visitor, context); - } - function visitClassDeclaration(node) { - var modifierFlags = ts.getModifierFlags(node); - var isExported = modifierFlags & 1; - var isDefault = modifierFlags & 512; - var modifiers = isExported && !isDefault - ? ts.filter(node.modifiers, isExportModifier) - : undefined; - var statement = ts.createVariableStatement(modifiers, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(getDeclarationName(node, true), undefined, transformClassLikeDeclarationToExpression(node)) - ]), node); - ts.setOriginalNode(statement, node); - ts.startOnNewLine(statement); - if (isExported && isDefault) { - var statements = [statement]; - statements.push(ts.createExportAssignment(undefined, undefined, false, getDeclarationName(node, false))); - return statements; - } - return statement; - } - function isExportModifier(node) { - return node.kind === 82; - } - function visitClassExpression(node) { - return transformClassLikeDeclarationToExpression(node); - } - function transformClassLikeDeclarationToExpression(node) { - if (node.name) { - enableSubstitutionsForBlockScopedBindings(); - } - var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); - var classFunction = ts.createFunctionExpression(undefined, undefined, undefined, extendsClauseElement ? [ts.createParameter("_super")] : [], undefined, transformClassBody(node, extendsClauseElement)); - if (ts.getEmitFlags(node) & 524288) { - ts.setEmitFlags(classFunction, 524288); - } - var inner = ts.createPartiallyEmittedExpression(classFunction); - inner.end = node.end; - ts.setEmitFlags(inner, 49152); - var outer = ts.createPartiallyEmittedExpression(inner); - outer.end = ts.skipTrivia(currentText, node.pos); - ts.setEmitFlags(outer, 49152); - return ts.createParen(ts.createCall(outer, undefined, extendsClauseElement - ? [ts.visitNode(extendsClauseElement.expression, visitor, ts.isExpression)] - : [])); - } - function transformClassBody(node, extendsClauseElement) { - var statements = []; + function transformCommonJSModule(node) { startLexicalEnvironment(); - addExtendsHelperIfNeeded(statements, node, extendsClauseElement); - addConstructor(statements, node, extendsClauseElement); - addClassMembers(statements, node); - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 16); - var localName = getLocalName(node); - var outer = ts.createPartiallyEmittedExpression(localName); - outer.end = closingBraceLocation.end; - ts.setEmitFlags(outer, 49152); - var statement = ts.createReturn(outer); - statement.pos = closingBraceLocation.pos; - ts.setEmitFlags(statement, 49152 | 12288); - statements.push(statement); - ts.addRange(statements, endLexicalEnvironment()); - var block = ts.createBlock(ts.createNodeArray(statements, node.members), undefined, true); - ts.setEmitFlags(block, 49152); - return block; - } - function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) { - if (extendsClauseElement) { - statements.push(ts.createStatement(ts.createExtendsHelper(currentSourceFile.externalHelpersModuleName, getDeclarationName(node)), extendsClauseElement)); - } - } - function addConstructor(statements, node, extendsClauseElement) { - var constructor = ts.getFirstConstructorWithBody(node); - var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); - var constructorFunction = ts.createFunctionDeclaration(undefined, undefined, undefined, getDeclarationName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), constructor || node); - if (extendsClauseElement) { - ts.setEmitFlags(constructorFunction, 256); - } - statements.push(constructorFunction); - } - function transformConstructorParameters(constructor, hasSynthesizedSuper) { - if (constructor && !hasSynthesizedSuper) { - return ts.visitNodes(constructor.parameters, visitor, ts.isParameter); - } - return []; - } - function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { var statements = []; - startLexicalEnvironment(); - var statementOffset = -1; - if (hasSynthesizedSuper) { - statementOffset = 1; - } - else if (constructor) { - statementOffset = ts.addPrologueDirectives(statements, constructor.body.statements, false, visitor); - } - if (constructor) { - addDefaultValueAssignmentsIfNeeded(statements, constructor); - addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); - ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); - } - var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, !!extendsClauseElement, hasSynthesizedSuper, statementOffset); - if (superCaptureStatus === 1 || superCaptureStatus === 2) { - statementOffset++; - } - if (constructor) { - var body = saveStateAndInvoke(constructor, function (constructor) { return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset); }); - ts.addRange(statements, body); - } - if (extendsClauseElement - && superCaptureStatus !== 2 - && !(constructor && isSufficientlyCoveredByReturnStatements(constructor.body))) { - statements.push(ts.createReturn(ts.createIdentifier("_this"))); - } + var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, visitor); + ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); - var block = ts.createBlock(ts.createNodeArray(statements, constructor ? constructor.body.statements : node.members), constructor ? constructor.body : node, true); - if (!constructor) { - ts.setEmitFlags(block, 49152); + addExportEqualsIfNeeded(statements, false); + var updated = updateSourceFile(node, statements); + if (hasExportStarsToExportValues) { + ts.setEmitFlags(updated, 2 | ts.getEmitFlags(node)); } - return block; + return updated; } - function isSufficientlyCoveredByReturnStatements(statement) { - if (statement.kind === 211) { - return true; - } - else if (statement.kind === 203) { - var ifStatement = statement; - if (ifStatement.elseStatement) { - return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && - isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); - } - } - else if (statement.kind === 199) { - var lastStatement = ts.lastOrUndefined(statement.statements); - if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { - return true; - } - } - return false; + function transformAMDModule(node) { + var define = ts.createIdentifier("define"); + var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); + return transformAsynchronousModule(node, define, moduleName, true); } - function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, hasExtendsClause, hasSynthesizedSuper, statementOffset) { - if (!hasExtendsClause) { - if (ctor) { - addCaptureThisForNodeIfNeeded(statements, ctor); - } - return 0; - } - if (!ctor) { - statements.push(ts.createReturn(createDefaultSuperCallOrThis())); - return 2; - } - if (hasSynthesizedSuper) { - captureThisForNode(statements, ctor, createDefaultSuperCallOrThis()); - enableSubstitutionsForCapturedThis(); - return 1; - } - var firstStatement; - var superCallExpression; - var ctorStatements = ctor.body.statements; - if (statementOffset < ctorStatements.length) { - firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 202 && ts.isSuperCall(firstStatement.expression)) { - var superCall = firstStatement.expression; - superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); - } - } - if (superCallExpression && statementOffset === ctorStatements.length - 1) { - statements.push(ts.createReturn(superCallExpression)); - return 2; - } - captureThisForNode(statements, ctor, superCallExpression, firstStatement); - if (superCallExpression) { - return 1; - } - return 0; + function transformUMDModule(node) { + var define = ts.createIdentifier("define"); + ts.setEmitFlags(define, 16); + return transformAsynchronousModule(node, define, undefined, false); } - function createDefaultSuperCallOrThis() { - var actualThis = ts.createThis(); - ts.setEmitFlags(actualThis, 128); - var superCall = ts.createFunctionApply(ts.createIdentifier("_super"), actualThis, ts.createIdentifier("arguments")); - return ts.createLogicalOr(superCall, actualThis); - } - function visitParameter(node) { - if (node.dotDotDotToken) { - return undefined; - } - else if (ts.isBindingPattern(node.name)) { - return ts.setOriginalNode(ts.createParameter(ts.getGeneratedNameForNode(node), undefined, node), node); - } - else if (node.initializer) { - return ts.setOriginalNode(ts.createParameter(node.name, undefined, node), node); - } - else { - return node; - } - } - function shouldAddDefaultValueAssignments(node) { - return (node.transformFlags & 65536) !== 0; - } - function addDefaultValueAssignmentsIfNeeded(statements, node) { - if (!shouldAddDefaultValueAssignments(node)) { - return; - } - for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { - var parameter = _a[_i]; - var name_38 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; - if (dotDotDotToken) { - continue; - } - if (ts.isBindingPattern(name_38)) { - addDefaultValueAssignmentForBindingPattern(statements, parameter, name_38, initializer); - } - else if (initializer) { - addDefaultValueAssignmentForInitializer(statements, parameter, name_38, initializer); - } - } - } - function addDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer) { - var temp = ts.getGeneratedNameForNode(parameter); - if (name.elements.length > 0) { - statements.push(ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(ts.flattenParameterDestructuring(context, parameter, temp, visitor))), 8388608)); - } - else if (initializer) { - statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 8388608)); - } - } - function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) { - initializer = ts.visitNode(initializer, visitor, ts.isExpression); - var statement = ts.createIf(ts.createStrictEquality(ts.getSynthesizedClone(name), ts.createVoidZero()), ts.setEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 1536), ts.setEmitFlags(initializer, 1536 | ts.getEmitFlags(initializer)), parameter)) - ], parameter), 32 | 1024 | 12288), undefined, parameter); - statement.startsOnNewLine = true; - ts.setEmitFlags(statement, 12288 | 1024 | 8388608); - statements.push(statement); - } - function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) { - return node && node.dotDotDotToken && node.name.kind === 69 && !inConstructorWithSynthesizedSuper; - } - function addRestParameterIfNeeded(statements, node, inConstructorWithSynthesizedSuper) { - var parameter = ts.lastOrUndefined(node.parameters); - if (!shouldAddRestParameter(parameter, inConstructorWithSynthesizedSuper)) { - return; - } - var declarationName = ts.getMutableClone(parameter.name); - ts.setEmitFlags(declarationName, 1536); - var expressionName = ts.getSynthesizedClone(parameter.name); - var restIndex = node.parameters.length - 1; - var temp = ts.createLoopVariable(); - statements.push(ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(declarationName, undefined, ts.createArrayLiteral([])) - ]), parameter), 8388608)); - var forStatement = ts.createFor(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(temp, undefined, ts.createLiteral(restIndex)) - ], parameter), ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length"), parameter), ts.createPostfixIncrement(temp, parameter), ts.createBlock([ - ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp)), parameter)) - ])); - ts.setEmitFlags(forStatement, 8388608); - ts.startOnNewLine(forStatement); - statements.push(forStatement); - } - function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 16384 && node.kind !== 180) { - captureThisForNode(statements, node, ts.createThis()); - } - } - function captureThisForNode(statements, node, initializer, originalStatement) { - enableSubstitutionsForCapturedThis(); - var captureThisStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration("_this", undefined, initializer) - ]), originalStatement); - ts.setEmitFlags(captureThisStatement, 49152 | 8388608); - ts.setSourceMapRange(captureThisStatement, node); - statements.push(captureThisStatement); - } - function addClassMembers(statements, node) { - for (var _i = 0, _a = node.members; _i < _a.length; _i++) { - var member = _a[_i]; - switch (member.kind) { - case 198: - statements.push(transformSemicolonClassElementToStatement(member)); - break; - case 147: - statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member)); - break; - case 149: - case 150: - var accessors = ts.getAllAccessorDeclarations(node.members, member); - if (member === accessors.firstAccessor) { - statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors)); - } - break; - case 148: - break; - default: - ts.Debug.failBadSyntaxKind(node); - break; - } - } - } - function transformSemicolonClassElementToStatement(member) { - return ts.createEmptyStatement(member); - } - function transformClassMethodDeclarationToStatement(receiver, member) { - var commentRange = ts.getCommentRange(member); - var sourceMapRange = ts.getSourceMapRange(member); - var func = transformFunctionLikeToExpression(member, member, undefined); - ts.setEmitFlags(func, 49152); - ts.setSourceMapRange(func, sourceMapRange); - var statement = ts.createStatement(ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), member.name), func), member); - ts.setOriginalNode(statement, member); - ts.setCommentRange(statement, commentRange); - ts.setEmitFlags(statement, 1536); - return statement; - } - function transformAccessorsToStatement(receiver, accessors) { - var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, false), ts.getSourceMapRange(accessors.firstAccessor)); - ts.setEmitFlags(statement, 49152); - return statement; - } - function transformAccessorsToExpression(receiver, _a, startsOnNewLine) { - var firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; - var target = ts.getMutableClone(receiver); - ts.setEmitFlags(target, 49152 | 1024); - ts.setSourceMapRange(target, firstAccessor.name); - var propertyName = ts.createExpressionForPropertyName(ts.visitNode(firstAccessor.name, visitor, ts.isPropertyName)); - ts.setEmitFlags(propertyName, 49152 | 512); - ts.setSourceMapRange(propertyName, firstAccessor.name); - var properties = []; - if (getAccessor) { - var getterFunction = transformFunctionLikeToExpression(getAccessor, undefined, undefined); - ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); - var getter = ts.createPropertyAssignment("get", getterFunction); - ts.setCommentRange(getter, ts.getCommentRange(getAccessor)); - properties.push(getter); - } - if (setAccessor) { - var setterFunction = transformFunctionLikeToExpression(setAccessor, undefined, undefined); - ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); - var setter = ts.createPropertyAssignment("set", setterFunction); - ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); - properties.push(setter); - } - properties.push(ts.createPropertyAssignment("enumerable", ts.createLiteral(true)), ts.createPropertyAssignment("configurable", ts.createLiteral(true))); - var call = ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ - target, - propertyName, - ts.createObjectLiteral(properties, undefined, true) + function transformAsynchronousModule(node, define, moduleName, includeNonAmdDependencies) { + var _a = collectAsynchronousDependencies(node, includeNonAmdDependencies), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + return updateSourceFile(node, [ + ts.createStatement(ts.createCall(define, undefined, (moduleName ? [moduleName] : []).concat([ + ts.createArrayLiteral([ + ts.createLiteral("require"), + ts.createLiteral("exports") + ].concat(aliasedModuleNames, unaliasedModuleNames)), + ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ + ts.createParameter("require"), + ts.createParameter("exports") + ].concat(importAliasNames), undefined, transformAsynchronousModuleBody(node)) + ]))) ]); - if (startsOnNewLine) { - call.startsOnNewLine = true; - } - return call; } - function visitArrowFunction(node) { - if (node.transformFlags & 8192) { - enableSubstitutionsForCapturedThis(); - } - var func = transformFunctionLikeToExpression(node, node, undefined); - ts.setEmitFlags(func, 256); - return func; - } - function visitFunctionExpression(node) { - return transformFunctionLikeToExpression(node, node, node.name); - } - function visitFunctionDeclaration(node) { - return ts.setOriginalNode(ts.createFunctionDeclaration(undefined, node.modifiers, node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node), node); - } - function transformFunctionLikeToExpression(node, location, name) { - var savedContainingNonArrowFunction = enclosingNonArrowFunction; - if (node.kind !== 180) { - enclosingNonArrowFunction = node; - } - var expression = ts.setOriginalNode(ts.createFunctionExpression(node.asteriskToken, name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, saveStateAndInvoke(node, transformFunctionBody), location), node); - enclosingNonArrowFunction = savedContainingNonArrowFunction; - return expression; - } - function transformFunctionBody(node) { - var multiLine = false; - var singleLine = false; - var statementsLocation; - var closeBraceLocation; - var statements = []; - var body = node.body; - var statementOffset; + function transformAsynchronousModuleBody(node) { startLexicalEnvironment(); - if (ts.isBlock(body)) { - statementOffset = ts.addPrologueDirectives(statements, body.statements, false, visitor); - } - addCaptureThisForNodeIfNeeded(statements, node); - addDefaultValueAssignmentsIfNeeded(statements, node); - addRestParameterIfNeeded(statements, node, false); - if (!multiLine && statements.length > 0) { - multiLine = true; - } - if (ts.isBlock(body)) { - statementsLocation = body.statements; - ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, statementOffset)); - if (!multiLine && body.multiLine) { - multiLine = true; - } - } - else { - ts.Debug.assert(node.kind === 180); - statementsLocation = ts.moveRangeEnd(body, -1); - var equalsGreaterThanToken = node.equalsGreaterThanToken; - if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { - if (ts.rangeEndIsOnSameLineAsRangeStart(equalsGreaterThanToken, body, currentSourceFile)) { - singleLine = true; - } - else { - multiLine = true; - } - } - var expression = ts.visitNode(body, visitor, ts.isExpression); - var returnStatement = ts.createReturn(expression, body); - ts.setEmitFlags(returnStatement, 12288 | 1024 | 32768); - statements.push(returnStatement); - closeBraceLocation = body; - } - var lexicalEnvironment = endLexicalEnvironment(); - ts.addRange(statements, lexicalEnvironment); - if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { - multiLine = true; - } - var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), node.body, multiLine); - if (!multiLine && singleLine) { - ts.setEmitFlags(block, 32); - } - if (closeBraceLocation) { - ts.setTokenSourceMapRange(block, 16, closeBraceLocation); - } - ts.setOriginalNode(block, node.body); - return block; - } - function visitExpressionStatement(node) { - switch (node.expression.kind) { - case 178: - return ts.updateStatement(node, visitParenthesizedExpression(node.expression, false)); - case 187: - return ts.updateStatement(node, visitBinaryExpression(node.expression, false)); - } - return ts.visitEachChild(node, visitor, context); - } - function visitParenthesizedExpression(node, needsDestructuringValue) { - if (needsDestructuringValue) { - switch (node.expression.kind) { - case 178: - return ts.createParen(visitParenthesizedExpression(node.expression, true), node); - case 187: - return ts.createParen(visitBinaryExpression(node.expression, true), node); - } - } - return ts.visitEachChild(node, visitor, context); - } - function visitBinaryExpression(node, needsDestructuringValue) { - ts.Debug.assert(ts.isDestructuringAssignment(node)); - return ts.flattenDestructuringAssignment(context, node, needsDestructuringValue, hoistVariableDeclaration, visitor); - } - function visitVariableStatement(node) { - if (convertedLoopState && (ts.getCombinedNodeFlags(node.declarationList) & 3) == 0) { - var assignments = void 0; - for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - hoistVariableDeclarationDeclaredInConvertedLoop(convertedLoopState, decl); - if (decl.initializer) { - var assignment = void 0; - if (ts.isBindingPattern(decl.name)) { - assignment = ts.flattenVariableDestructuringToExpression(context, decl, hoistVariableDeclaration, undefined, visitor); - } - else { - assignment = ts.createBinary(decl.name, 56, ts.visitNode(decl.initializer, visitor, ts.isExpression)); - } - (assignments || (assignments = [])).push(assignment); - } - } - if (assignments) { - return ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 24, acc); }), node); - } - else { - return undefined; - } - } - return ts.visitEachChild(node, visitor, context); - } - function visitVariableDeclarationList(node) { - if (node.flags & 3) { - enableSubstitutionsForBlockScopedBindings(); - } - var declarations = ts.flatten(ts.map(node.declarations, node.flags & 1 - ? visitVariableDeclarationInLetDeclarationList - : visitVariableDeclaration)); - var declarationList = ts.createVariableDeclarationList(declarations, node); - ts.setOriginalNode(declarationList, node); - ts.setCommentRange(declarationList, node); - if (node.transformFlags & 2097152 - && (ts.isBindingPattern(node.declarations[0].name) - || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { - var firstDeclaration = ts.firstOrUndefined(declarations); - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); - } - return declarationList; - } - function shouldEmitExplicitInitializerForLetDeclaration(node) { - var flags = resolver.getNodeCheckFlags(node); - var isCapturedInFunction = flags & 131072; - var isDeclaredInLoop = flags & 262144; - var emittedAsTopLevel = ts.isBlockScopedContainerTopLevel(enclosingBlockScopeContainer) - || (isCapturedInFunction - && isDeclaredInLoop - && ts.isBlock(enclosingBlockScopeContainer) - && ts.isIterationStatement(enclosingBlockScopeContainerParent, false)); - var emitExplicitInitializer = !emittedAsTopLevel - && enclosingBlockScopeContainer.kind !== 207 - && enclosingBlockScopeContainer.kind !== 208 - && (!resolver.isDeclarationWithCollidingName(node) - || (isDeclaredInLoop - && !isCapturedInFunction - && !ts.isIterationStatement(enclosingBlockScopeContainer, false))); - return emitExplicitInitializer; - } - function visitVariableDeclarationInLetDeclarationList(node) { - var name = node.name; - if (ts.isBindingPattern(name)) { - return visitVariableDeclaration(node); - } - if (!node.initializer && shouldEmitExplicitInitializerForLetDeclaration(node)) { - var clone_8 = ts.getMutableClone(node); - clone_8.initializer = ts.createVoidZero(); - return clone_8; - } - return ts.visitEachChild(node, visitor, context); - } - function visitVariableDeclaration(node) { - if (ts.isBindingPattern(node.name)) { - var recordTempVariablesInLine = !enclosingVariableStatement - || !ts.hasModifier(enclosingVariableStatement, 1); - return ts.flattenVariableDestructuring(context, node, undefined, visitor, recordTempVariablesInLine ? undefined : hoistVariableDeclaration); - } - return ts.visitEachChild(node, visitor, context); - } - function visitLabeledStatement(node) { - if (convertedLoopState) { - if (!convertedLoopState.labels) { - convertedLoopState.labels = ts.createMap(); - } - convertedLoopState.labels[node.label.text] = node.label.text; - } - var result; - if (ts.isIterationStatement(node.statement, false) && shouldConvertIterationStatementBody(node.statement)) { - result = ts.visitNodes(ts.createNodeArray([node.statement]), visitor, ts.isStatement); - } - else { - result = ts.visitEachChild(node, visitor, context); - } - if (convertedLoopState) { - convertedLoopState.labels[node.label.text] = undefined; - } - return result; - } - function visitDoStatement(node) { - return convertIterationStatementBodyIfNecessary(node); - } - function visitWhileStatement(node) { - return convertIterationStatementBodyIfNecessary(node); - } - function visitForStatement(node) { - return convertIterationStatementBodyIfNecessary(node); - } - function visitForInStatement(node) { - return convertIterationStatementBodyIfNecessary(node); - } - function visitForOfStatement(node) { - return convertIterationStatementBodyIfNecessary(node, convertForOfToFor); - } - function convertForOfToFor(node, convertedLoopBodyStatements) { - var expression = ts.visitNode(node.expression, visitor, ts.isExpression); - var initializer = node.initializer; var statements = []; - var counter = ts.createLoopVariable(); - var rhsReference = expression.kind === 69 - ? ts.createUniqueName(expression.text) - : ts.createTempVariable(undefined); - if (ts.isVariableDeclarationList(initializer)) { - if (initializer.flags & 3) { - enableSubstitutionsForBlockScopedBindings(); - } - var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); - if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { - var declarations = ts.flattenVariableDestructuring(context, firstOriginalDeclaration, ts.createElementAccess(rhsReference, counter), visitor); - var declarationList = ts.createVariableDeclarationList(declarations, initializer); - ts.setOriginalNode(declarationList, initializer); - var firstDeclaration = declarations[0]; - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); - statements.push(ts.createVariableStatement(undefined, declarationList)); - } - else { - statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(undefined), undefined, ts.createElementAccess(rhsReference, counter)) - ], ts.moveRangePos(initializer, -1)), ts.moveRangeEnd(initializer, -1))); - } + var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, visitor); + ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); + ts.addRange(statements, endLexicalEnvironment()); + addExportEqualsIfNeeded(statements, true); + var body = ts.createBlock(statements, undefined, true); + if (hasExportStarsToExportValues) { + ts.setEmitFlags(body, 2); } - else { - var assignment = ts.createAssignment(initializer, ts.createElementAccess(rhsReference, counter)); - if (ts.isDestructuringAssignment(assignment)) { - statements.push(ts.createStatement(ts.flattenDestructuringAssignment(context, assignment, false, hoistVariableDeclaration, visitor))); - } - else { - assignment.end = initializer.end; - statements.push(ts.createStatement(assignment, ts.moveRangeEnd(initializer, -1))); - } - } - var bodyLocation; - var statementsLocation; - if (convertedLoopBodyStatements) { - ts.addRange(statements, convertedLoopBodyStatements); - } - else { - var statement = ts.visitNode(node.statement, visitor, ts.isStatement); - if (ts.isBlock(statement)) { - ts.addRange(statements, statement.statements); - bodyLocation = statement; - statementsLocation = statement.statements; + return body; + } + function addExportEqualsIfNeeded(statements, emitAsReturn) { + if (exportEquals) { + if (emitAsReturn) { + var statement = ts.createReturn(exportEquals.expression, exportEquals); + ts.setEmitFlags(statement, 12288 | 49152); + statements.push(statement); } else { + var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), exportEquals.expression), exportEquals); + ts.setEmitFlags(statement, 49152); statements.push(statement); } } - ts.setEmitFlags(expression, 1536 | ts.getEmitFlags(expression)); - var body = ts.createBlock(ts.createNodeArray(statements, statementsLocation), bodyLocation); - ts.setEmitFlags(body, 1536 | 12288); - var forStatement = ts.createFor(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(counter, undefined, ts.createLiteral(0), ts.moveRangePos(node.expression, -1)), - ts.createVariableDeclaration(rhsReference, undefined, expression, node.expression) - ], node.expression), ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length"), node.expression), ts.createPostfixIncrement(counter, node.expression), body, node); - ts.setEmitFlags(forStatement, 8192); - return forStatement; } - function visitObjectLiteralExpression(node) { - var properties = node.properties; - var numProperties = properties.length; - var numInitialProperties = numProperties; - for (var i = 0; i < numProperties; i++) { - var property = properties[i]; - if (property.transformFlags & 4194304 - || property.name.kind === 140) { - numInitialProperties = i; - break; - } - } - ts.Debug.assert(numInitialProperties !== numProperties); - var temp = ts.createTempVariable(hoistVariableDeclaration); - var expressions = []; - var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), undefined, node.multiLine), 524288)); - if (node.multiLine) { - assignment.startsOnNewLine = true; - } - expressions.push(assignment); - addObjectLiteralMembers(expressions, node, temp, numInitialProperties); - expressions.push(node.multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); - return ts.inlineExpressions(expressions); - } - function shouldConvertIterationStatementBody(node) { - return (resolver.getNodeCheckFlags(node) & 65536) !== 0; - } - function hoistVariableDeclarationDeclaredInConvertedLoop(state, node) { - if (!state.hoistedLocalVariables) { - state.hoistedLocalVariables = []; - } - visit(node.name); - function visit(node) { - if (node.kind === 69) { - state.hoistedLocalVariables.push(node); - } - else { - for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (!ts.isOmittedExpression(element)) { - visit(element.name); - } - } - } - } - } - function convertIterationStatementBodyIfNecessary(node, convert) { - if (!shouldConvertIterationStatementBody(node)) { - var saveAllowedNonLabeledJumps = void 0; - if (convertedLoopState) { - saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; - convertedLoopState.allowedNonLabeledJumps = 2 | 4; - } - var result = convert ? convert(node, undefined) : ts.visitEachChild(node, visitor, context); - if (convertedLoopState) { - convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps; - } - return result; - } - var functionName = ts.createUniqueName("_loop"); - var loopInitializer; + function visitor(node) { switch (node.kind) { - case 206: - case 207: - case 208: - var initializer = node.initializer; - if (initializer && initializer.kind === 219) { - loopInitializer = initializer; - } - break; - } - var loopParameters = []; - var loopOutParameters = []; - if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3)) { - for (var _i = 0, _a = loopInitializer.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - processLoopVariableDeclaration(decl, loopParameters, loopOutParameters); - } - } - var outerConvertedLoopState = convertedLoopState; - convertedLoopState = { loopOutParameters: loopOutParameters }; - if (outerConvertedLoopState) { - if (outerConvertedLoopState.argumentsName) { - convertedLoopState.argumentsName = outerConvertedLoopState.argumentsName; - } - if (outerConvertedLoopState.thisName) { - convertedLoopState.thisName = outerConvertedLoopState.thisName; - } - if (outerConvertedLoopState.hoistedLocalVariables) { - convertedLoopState.hoistedLocalVariables = outerConvertedLoopState.hoistedLocalVariables; - } - } - var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement); - var currentState = convertedLoopState; - convertedLoopState = outerConvertedLoopState; - if (loopOutParameters.length) { - var statements_3 = ts.isBlock(loopBody) ? loopBody.statements.slice() : [loopBody]; - copyOutParameters(loopOutParameters, 1, statements_3); - loopBody = ts.createBlock(statements_3, undefined, true); - } - if (!ts.isBlock(loopBody)) { - loopBody = ts.createBlock([loopBody], undefined, true); - } - var isAsyncBlockContainingAwait = enclosingNonArrowFunction - && (ts.getEmitFlags(enclosingNonArrowFunction) & 2097152) !== 0 - && (node.statement.transformFlags & 4194304) !== 0; - var loopBodyFlags = 0; - if (currentState.containsLexicalThis) { - loopBodyFlags |= 256; - } - if (isAsyncBlockContainingAwait) { - loopBodyFlags |= 2097152; - } - var convertedLoopVariable = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(functionName, undefined, ts.setEmitFlags(ts.createFunctionExpression(isAsyncBlockContainingAwait ? ts.createToken(37) : undefined, undefined, undefined, loopParameters, undefined, loopBody), loopBodyFlags)) - ])); - var statements = [convertedLoopVariable]; - var extraVariableDeclarations; - if (currentState.argumentsName) { - if (outerConvertedLoopState) { - outerConvertedLoopState.argumentsName = currentState.argumentsName; - } - else { - (extraVariableDeclarations || (extraVariableDeclarations = [])).push(ts.createVariableDeclaration(currentState.argumentsName, undefined, ts.createIdentifier("arguments"))); - } - } - if (currentState.thisName) { - if (outerConvertedLoopState) { - outerConvertedLoopState.thisName = currentState.thisName; - } - else { - (extraVariableDeclarations || (extraVariableDeclarations = [])).push(ts.createVariableDeclaration(currentState.thisName, undefined, ts.createIdentifier("this"))); - } - } - if (currentState.hoistedLocalVariables) { - if (outerConvertedLoopState) { - outerConvertedLoopState.hoistedLocalVariables = currentState.hoistedLocalVariables; - } - else { - if (!extraVariableDeclarations) { - extraVariableDeclarations = []; - } - for (var _b = 0, _c = currentState.hoistedLocalVariables; _b < _c.length; _b++) { - var identifier = _c[_b]; - extraVariableDeclarations.push(ts.createVariableDeclaration(identifier)); - } - } - } - if (loopOutParameters.length) { - if (!extraVariableDeclarations) { - extraVariableDeclarations = []; - } - for (var _d = 0, loopOutParameters_1 = loopOutParameters; _d < loopOutParameters_1.length; _d++) { - var outParam = loopOutParameters_1[_d]; - extraVariableDeclarations.push(ts.createVariableDeclaration(outParam.outParamName)); - } - } - if (extraVariableDeclarations) { - statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(extraVariableDeclarations))); - } - var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, isAsyncBlockContainingAwait); - var loop; - if (convert) { - loop = convert(node, convertedLoopBodyStatements); - } - else { - loop = ts.getMutableClone(node); - loop.statement = undefined; - loop = ts.visitEachChild(loop, visitor, context); - loop.statement = ts.createBlock(convertedLoopBodyStatements, undefined, true); - loop.transformFlags = 0; - ts.aggregateTransformFlags(loop); - } - statements.push(currentParent.kind === 214 - ? ts.createLabel(currentParent.label, loop) - : loop); - return statements; - } - function copyOutParameter(outParam, copyDirection) { - var source = copyDirection === 0 ? outParam.outParamName : outParam.originalName; - var target = copyDirection === 0 ? outParam.originalName : outParam.outParamName; - return ts.createBinary(target, 56, source); - } - function copyOutParameters(outParams, copyDirection, statements) { - for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { - var outParam = outParams_1[_i]; - statements.push(ts.createStatement(copyOutParameter(outParam, copyDirection))); + case 231: + return visitImportDeclaration(node); + case 230: + return visitImportEqualsDeclaration(node); + case 237: + return visitExportDeclaration(node); + case 236: + return visitExportAssignment(node); + case 201: + return visitVariableStatement(node); + case 221: + return visitFunctionDeclaration(node); + case 222: + return visitClassDeclaration(node); + case 203: + return visitExpressionStatement(node); + default: + return node; } } - function generateCallToConvertedLoop(loopFunctionExpressionName, parameters, state, isAsyncBlockContainingAwait) { - var outerConvertedLoopState = convertedLoopState; + function visitImportDeclaration(node) { + if (!ts.contains(externalImports, node)) { + return undefined; + } var statements = []; - var isSimpleLoop = !(state.nonLocalJumps & ~4) && - !state.labeledNonLocalBreaks && - !state.labeledNonLocalContinues; - var call = ts.createCall(loopFunctionExpressionName, undefined, ts.map(parameters, function (p) { return p.name; })); - var callResult = isAsyncBlockContainingAwait ? ts.createYield(ts.createToken(37), call) : call; - if (isSimpleLoop) { - statements.push(ts.createStatement(callResult)); - copyOutParameters(state.loopOutParameters, 0, statements); - } - else { - var loopResultName = ts.createUniqueName("state"); - var stateVariable = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ts.createVariableDeclaration(loopResultName, undefined, callResult)])); - statements.push(stateVariable); - copyOutParameters(state.loopOutParameters, 0, statements); - if (state.nonLocalJumps & 8) { - var returnStatement = void 0; - if (outerConvertedLoopState) { - outerConvertedLoopState.nonLocalJumps |= 8; - returnStatement = ts.createReturn(loopResultName); + var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); + if (moduleKind !== ts.ModuleKind.AMD) { + if (!node.importClause) { + statements.push(ts.createStatement(createRequireCall(node), node)); + } + else { + var variables = []; + if (namespaceDeclaration && !ts.isDefaultImport(node)) { + variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, createRequireCall(node))); } else { - returnStatement = ts.createReturn(ts.createPropertyAccess(loopResultName, "value")); + variables.push(ts.createVariableDeclaration(ts.getGeneratedNameForNode(node), undefined, createRequireCall(node))); + if (namespaceDeclaration && ts.isDefaultImport(node)) { + variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, ts.getGeneratedNameForNode(node))); + } } - statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 32, ts.createLiteral("object")), returnStatement)); - } - if (state.nonLocalJumps & 2) { - statements.push(ts.createIf(ts.createBinary(loopResultName, 32, ts.createLiteral("break")), ts.createBreak())); - } - if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { - var caseClauses = []; - processLabeledJumps(state.labeledNonLocalBreaks, true, loopResultName, outerConvertedLoopState, caseClauses); - processLabeledJumps(state.labeledNonLocalContinues, false, loopResultName, outerConvertedLoopState, caseClauses); - statements.push(ts.createSwitch(loopResultName, ts.createCaseBlock(caseClauses))); + statements.push(ts.createVariableStatement(undefined, ts.createConstDeclarationList(variables), node)); } } - return statements; + else if (namespaceDeclaration && ts.isDefaultImport(node)) { + statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, ts.getGeneratedNameForNode(node), node) + ]))); + } + addExportImportAssignments(statements, node); + return ts.singleOrMany(statements); } - function setLabeledJump(state, isBreak, labelText, labelMarker) { - if (isBreak) { - if (!state.labeledNonLocalBreaks) { - state.labeledNonLocalBreaks = ts.createMap(); - } - state.labeledNonLocalBreaks[labelText] = labelMarker; + function visitImportEqualsDeclaration(node) { + if (!ts.contains(externalImports, node)) { + return undefined; } - else { - if (!state.labeledNonLocalContinues) { - state.labeledNonLocalContinues = ts.createMap(); - } - state.labeledNonLocalContinues[labelText] = labelMarker; - } - } - function processLabeledJumps(table, isBreak, loopResultName, outerLoop, caseClauses) { - if (!table) { - return; - } - for (var labelText in table) { - var labelMarker = table[labelText]; - var statements = []; - if (!outerLoop || (outerLoop.labels && outerLoop.labels[labelText])) { - var label = ts.createIdentifier(labelText); - statements.push(isBreak ? ts.createBreak(label) : ts.createContinue(label)); + ts.setEmitFlags(node.name, 128); + var statements = []; + if (moduleKind !== ts.ModuleKind.AMD) { + if (ts.hasModifier(node, 1)) { + statements.push(ts.createStatement(createExportAssignment(node.name, createRequireCall(node)), node)); } else { - setLabeledJump(outerLoop, isBreak, labelText, labelMarker); - statements.push(ts.createReturn(loopResultName)); + statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(ts.getSynthesizedClone(node.name), undefined, createRequireCall(node)) + ], undefined, languageVersion >= 2 ? 2 : 0), node)); } - caseClauses.push(ts.createCaseClause(ts.createLiteral(labelMarker), statements)); + } + else { + if (ts.hasModifier(node, 1)) { + statements.push(ts.createStatement(createExportAssignment(node.name, node.name), node)); + } + } + addExportImportAssignments(statements, node); + return statements; + } + function visitExportDeclaration(node) { + if (!ts.contains(externalImports, node)) { + return undefined; + } + var generatedName = ts.getGeneratedNameForNode(node); + if (node.exportClause) { + var statements = []; + if (moduleKind !== ts.ModuleKind.AMD) { + statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(generatedName, undefined, createRequireCall(node)) + ]), node)); + } + for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { + var specifier = _a[_i]; + var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); + statements.push(ts.createStatement(createExportAssignment(specifier.name, exportedValue), specifier)); + } + return ts.singleOrMany(statements); + } + else { + return ts.createStatement(ts.createCall(ts.createIdentifier("__export"), undefined, [ + moduleKind !== ts.ModuleKind.AMD + ? createRequireCall(node) + : generatedName + ]), node); } } - function processLoopVariableDeclaration(decl, loopParameters, loopOutParameters) { - var name = decl.name; + function visitExportAssignment(node) { + if (node.isExportEquals) { + return undefined; + } + var statements = []; + addExportDefault(statements, node.expression, node); + return statements; + } + function addExportDefault(statements, expression, location) { + tryAddExportDefaultCompat(statements); + statements.push(ts.createStatement(createExportAssignment(ts.createIdentifier("default"), expression), location)); + } + function tryAddExportDefaultCompat(statements) { + var original = ts.getOriginalNode(currentSourceFile); + ts.Debug.assert(original.kind === 256); + if (!original.symbol.exports["___esModule"]) { + if (languageVersion === 0) { + statements.push(ts.createStatement(createExportAssignment(ts.createIdentifier("__esModule"), ts.createLiteral(true)))); + } + else { + statements.push(ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ + ts.createIdentifier("exports"), + ts.createLiteral("__esModule"), + ts.createObjectLiteral([ + ts.createPropertyAssignment("value", ts.createLiteral(true)) + ]) + ]))); + } + } + } + function addExportImportAssignments(statements, node) { + if (ts.isImportEqualsDeclaration(node)) { + addExportMemberAssignments(statements, node.name); + } + else { + var names = ts.reduceEachChild(node, collectExportMembers, []); + for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { + var name_35 = names_1[_i]; + addExportMemberAssignments(statements, name_35); + } + } + } + function collectExportMembers(names, node) { + if (ts.isAliasSymbolDeclaration(node) && ts.isDeclaration(node)) { + var name_36 = node.name; + if (ts.isIdentifier(name_36)) { + names.push(name_36); + } + } + return ts.reduceEachChild(node, collectExportMembers, names); + } + function addExportMemberAssignments(statements, name) { + if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { + for (var _i = 0, _a = exportSpecifiers[name.text]; _i < _a.length; _i++) { + var specifier = _a[_i]; + statements.push(ts.startOnNewLine(ts.createStatement(createExportAssignment(specifier.name, name), specifier.name))); + } + } + } + function addExportMemberAssignment(statements, node) { + if (ts.hasModifier(node, 512)) { + addExportDefault(statements, getDeclarationName(node), node); + } + else { + statements.push(createExportStatement(node.name, ts.setEmitFlags(ts.getSynthesizedClone(node.name), 262144), node)); + } + } + function visitVariableStatement(node) { + var originalKind = ts.getOriginalNode(node).kind; + if (originalKind === 226 || + originalKind === 225 || + originalKind === 222) { + if (!ts.hasModifier(node, 1)) { + return node; + } + return ts.setOriginalNode(ts.createVariableStatement(undefined, node.declarationList), node); + } + var resultStatements = []; + if (ts.hasModifier(node, 1)) { + var variables = ts.getInitializedVariables(node.declarationList); + if (variables.length > 0) { + var inlineAssignments = ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable)), node); + resultStatements.push(inlineAssignments); + } + } + else { + resultStatements.push(node); + } + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + addExportMemberAssignmentsForBindingName(resultStatements, decl.name); + } + return resultStatements; + } + function addExportMemberAssignmentsForBindingName(resultStatements, name) { if (ts.isBindingPattern(name)) { for (var _i = 0, _a = name.elements; _i < _a.length; _i++) { var element = _a[_i]; if (!ts.isOmittedExpression(element)) { - processLoopVariableDeclaration(element, loopParameters, loopOutParameters); + addExportMemberAssignmentsForBindingName(resultStatements, element.name); } } } else { - loopParameters.push(ts.createParameter(name)); - if (resolver.getNodeCheckFlags(decl) & 2097152) { - var outParamName = ts.createUniqueName("out_" + name.text); - loopOutParameters.push({ originalName: name, outParamName: outParamName }); + if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { + var sourceFileId = ts.getOriginalNodeId(currentSourceFile); + if (!bindingNameExportSpecifiersForFileMap[sourceFileId]) { + bindingNameExportSpecifiersForFileMap[sourceFileId] = ts.createMap(); + } + bindingNameExportSpecifiersForFileMap[sourceFileId][name.text] = exportSpecifiers[name.text]; + addExportMemberAssignments(resultStatements, name); } } } - function addObjectLiteralMembers(expressions, node, receiver, start) { - var properties = node.properties; - var numProperties = properties.length; - for (var i = start; i < numProperties; i++) { - var property = properties[i]; - switch (property.kind) { - case 149: - case 150: - var accessors = ts.getAllAccessorDeclarations(node.properties, property); - if (property === accessors.firstAccessor) { - expressions.push(transformAccessorsToExpression(receiver, accessors, node.multiLine)); - } - break; - case 253: - expressions.push(transformPropertyAssignmentToExpression(node, property, receiver, node.multiLine)); - break; - case 254: - expressions.push(transformShorthandPropertyAssignmentToExpression(node, property, receiver, node.multiLine)); - break; - case 147: - expressions.push(transformObjectLiteralMethodDeclarationToExpression(node, property, receiver, node.multiLine)); - break; - default: - ts.Debug.failBadSyntaxKind(node); - break; - } - } - } - function transformPropertyAssignmentToExpression(node, property, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.visitNode(property.initializer, visitor, ts.isExpression), property); - if (startsOnNewLine) { - expression.startsOnNewLine = true; - } - return expression; - } - function transformShorthandPropertyAssignmentToExpression(node, property, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.getSynthesizedClone(property.name), property); - if (startsOnNewLine) { - expression.startsOnNewLine = true; - } - return expression; - } - function transformObjectLiteralMethodDeclarationToExpression(node, method, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, method, undefined), method); - if (startsOnNewLine) { - expression.startsOnNewLine = true; - } - return expression; - } - function visitMethodDeclaration(node) { - ts.Debug.assert(!ts.isComputedPropertyName(node.name)); - var functionExpression = transformFunctionLikeToExpression(node, ts.moveRangePos(node, -1), undefined); - ts.setEmitFlags(functionExpression, 16384 | ts.getEmitFlags(functionExpression)); - return ts.createPropertyAssignment(node.name, functionExpression, node); - } - function visitShorthandPropertyAssignment(node) { - return ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name), node); - } - function visitYieldExpression(node) { - return ts.visitEachChild(node, visitor, context); - } - function visitArrayLiteralExpression(node) { - return transformAndSpreadElements(node.elements, true, node.multiLine, node.elements.hasTrailingComma); - } - function visitCallExpression(node) { - return visitCallExpressionWithPotentialCapturedThisAssignment(node, true); - } - function visitImmediateSuperCallInBody(node) { - return visitCallExpressionWithPotentialCapturedThisAssignment(node, false); - } - function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) { - var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 95) { - ts.setEmitFlags(thisArg, 128); - } - var resultingCall; - if (node.transformFlags & 262144) { - resultingCall = ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, false, false, false)); + function transformInitializedVariable(node) { + var name = node.name; + if (ts.isBindingPattern(name)) { + return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, getModuleMemberName, visitor); } else { - resultingCall = ts.createFunctionCall(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), node); - } - if (node.expression.kind === 95) { - var actualThis = ts.createThis(); - ts.setEmitFlags(actualThis, 128); - var initializer = ts.createLogicalOr(resultingCall, actualThis); - return assignToCapturedThis - ? ts.createAssignment(ts.createIdentifier("_this"), initializer) - : initializer; - } - return resultingCall; - } - function visitNewExpression(node) { - ts.Debug.assert((node.transformFlags & 262144) !== 0); - var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), false, false, false)), undefined, []); - } - function transformAndSpreadElements(elements, needsUniqueCopy, multiLine, hasTrailingComma) { - var numElements = elements.length; - var segments = ts.flatten(ts.spanMap(elements, partitionSpreadElement, function (partition, visitPartition, start, end) { - return visitPartition(partition, multiLine, hasTrailingComma && end === numElements); - })); - if (segments.length === 1) { - var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadElementExpression(firstElement) && firstElement.expression.kind !== 170 - ? ts.createArraySlice(segments[0]) - : segments[0]; - } - return ts.createArrayConcat(segments.shift(), segments); - } - function partitionSpreadElement(node) { - return ts.isSpreadElementExpression(node) - ? visitSpanOfSpreadElements - : visitSpanOfNonSpreadElements; - } - function visitSpanOfSpreadElements(chunk, multiLine, hasTrailingComma) { - return ts.map(chunk, visitExpressionOfSpreadElement); - } - function visitSpanOfNonSpreadElements(chunk, multiLine, hasTrailingComma) { - return ts.createArrayLiteral(ts.visitNodes(ts.createNodeArray(chunk, undefined, hasTrailingComma), visitor, ts.isExpression), undefined, multiLine); - } - function visitExpressionOfSpreadElement(node) { - return ts.visitNode(node.expression, visitor, ts.isExpression); - } - function visitTemplateLiteral(node) { - return ts.createLiteral(node.text, node); - } - function visitTaggedTemplateExpression(node) { - var tag = ts.visitNode(node.tag, visitor, ts.isExpression); - var temp = ts.createTempVariable(hoistVariableDeclaration); - var templateArguments = [temp]; - var cookedStrings = []; - var rawStrings = []; - var template = node.template; - if (ts.isNoSubstitutionTemplateLiteral(template)) { - cookedStrings.push(ts.createLiteral(template.text)); - rawStrings.push(getRawLiteral(template)); - } - else { - cookedStrings.push(ts.createLiteral(template.head.text)); - rawStrings.push(getRawLiteral(template.head)); - for (var _i = 0, _a = template.templateSpans; _i < _a.length; _i++) { - var templateSpan = _a[_i]; - cookedStrings.push(ts.createLiteral(templateSpan.literal.text)); - rawStrings.push(getRawLiteral(templateSpan.literal)); - templateArguments.push(ts.visitNode(templateSpan.expression, visitor, ts.isExpression)); - } - } - return ts.createParen(ts.inlineExpressions([ - ts.createAssignment(temp, ts.createArrayLiteral(cookedStrings)), - ts.createAssignment(ts.createPropertyAccess(temp, "raw"), ts.createArrayLiteral(rawStrings)), - ts.createCall(tag, undefined, templateArguments) - ])); - } - function getRawLiteral(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"); - return ts.createLiteral(text, node); - } - function visitTemplateExpression(node) { - var expressions = []; - addTemplateHead(expressions, node); - addTemplateSpans(expressions, node); - var expression = ts.reduceLeft(expressions, ts.createAdd); - if (ts.nodeIsSynthesized(expression)) { - ts.setTextRange(expression, node); - } - return expression; - } - function shouldAddTemplateHead(node) { - ts.Debug.assert(node.templateSpans.length !== 0); - return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0; - } - function addTemplateHead(expressions, node) { - if (!shouldAddTemplateHead(node)) { - return; - } - expressions.push(ts.createLiteral(node.head.text)); - } - function addTemplateSpans(expressions, node) { - for (var _i = 0, _a = node.templateSpans; _i < _a.length; _i++) { - var span_6 = _a[_i]; - expressions.push(ts.visitNode(span_6.expression, visitor, ts.isExpression)); - if (span_6.literal.text.length !== 0) { - expressions.push(ts.createLiteral(span_6.literal.text)); - } + return ts.createAssignment(getModuleMemberName(name), ts.visitNode(node.initializer, visitor, ts.isExpression)); } } - function visitSuperKeyword(node) { - return enclosingNonAsyncFunctionBody - && ts.isClassElement(enclosingNonAsyncFunctionBody) - && !ts.hasModifier(enclosingNonAsyncFunctionBody, 32) - && currentParent.kind !== 174 - ? ts.createPropertyAccess(ts.createIdentifier("_super"), "prototype") - : ts.createIdentifier("_super"); - } - function visitSourceFileNode(node) { - var _a = ts.span(node.statements, ts.isPrologueDirective), prologue = _a[0], remaining = _a[1]; + function visitFunctionDeclaration(node) { var statements = []; - startLexicalEnvironment(); - ts.addRange(statements, prologue); - addCaptureThisForNodeIfNeeded(statements, node); - ts.addRange(statements, ts.visitNodes(ts.createNodeArray(remaining), visitor, ts.isStatement)); - ts.addRange(statements, endLexicalEnvironment()); - var clone = ts.getMutableClone(node); - clone.statements = ts.createNodeArray(statements, node.statements); - return clone; + var name = node.name || ts.getGeneratedNameForNode(node); + if (ts.hasModifier(node, 1)) { + var isAsync = ts.hasModifier(node, 256); + statements.push(ts.setOriginalNode(ts.createFunctionDeclaration(undefined, isAsync ? [ts.createNode(119)] : undefined, node.asteriskToken, name, undefined, node.parameters, undefined, node.body, node), node)); + addExportMemberAssignment(statements, node); + } + else { + statements.push(node); + } + if (node.name) { + addExportMemberAssignments(statements, node.name); + } + return ts.singleOrMany(statements); + } + function visitClassDeclaration(node) { + var statements = []; + var name = node.name || ts.getGeneratedNameForNode(node); + if (ts.hasModifier(node, 1)) { + statements.push(ts.setOriginalNode(ts.createClassDeclaration(undefined, undefined, name, undefined, node.heritageClauses, node.members, node), node)); + addExportMemberAssignment(statements, node); + } + else { + statements.push(node); + } + if (node.name && !(node.decorators && node.decorators.length)) { + addExportMemberAssignments(statements, node.name); + } + return ts.singleOrMany(statements); + } + function visitExpressionStatement(node) { + var original = ts.getOriginalNode(node); + var origKind = original.kind; + if (origKind === 225 || origKind === 226) { + return visitExpressionStatementForEnumOrNamespaceDeclaration(node, original); + } + else if (origKind === 222) { + var classDecl = original; + if (classDecl.name) { + var statements = [node]; + addExportMemberAssignments(statements, classDecl.name); + return statements; + } + } + return node; + } + function visitExpressionStatementForEnumOrNamespaceDeclaration(node, original) { + var statements = [node]; + if (ts.hasModifier(original, 1) && + original.kind === 225 && + ts.isFirstDeclarationOfKind(original, 225)) { + addVarForExportedEnumOrNamespaceDeclaration(statements, original); + } + addExportMemberAssignments(statements, original.name); + return statements; + } + function addVarForExportedEnumOrNamespaceDeclaration(statements, node) { + var transformedStatement = ts.createVariableStatement(undefined, [ts.createVariableDeclaration(getDeclarationName(node), undefined, ts.createPropertyAccess(ts.createIdentifier("exports"), getDeclarationName(node)))], node); + ts.setEmitFlags(transformedStatement, 49152); + statements.push(transformedStatement); + } + function getDeclarationName(node) { + return node.name ? ts.getSynthesizedClone(node.name) : ts.getGeneratedNameForNode(node); } function onEmitNode(emitContext, node, emitCallback) { - var savedEnclosingFunction = enclosingFunction; - if (enabledSubstitutions & 1 && ts.isFunctionLike(node)) { - enclosingFunction = node; + if (node.kind === 256) { + bindingNameExportSpecifiersMap = bindingNameExportSpecifiersForFileMap[ts.getOriginalNodeId(node)]; + previousOnEmitNode(emitContext, node, emitCallback); + bindingNameExportSpecifiersMap = undefined; } - previousOnEmitNode(emitContext, node, emitCallback); - enclosingFunction = savedEnclosingFunction; - } - function enableSubstitutionsForBlockScopedBindings() { - if ((enabledSubstitutions & 2) === 0) { - enabledSubstitutions |= 2; - context.enableSubstitution(69); - } - } - function enableSubstitutionsForCapturedThis() { - if ((enabledSubstitutions & 1) === 0) { - enabledSubstitutions |= 1; - context.enableSubstitution(97); - context.enableEmitNotification(148); - context.enableEmitNotification(147); - context.enableEmitNotification(149); - context.enableEmitNotification(150); - context.enableEmitNotification(180); - context.enableEmitNotification(179); - context.enableEmitNotification(220); + else { + previousOnEmitNode(emitContext, node, emitCallback); } } function onSubstituteNode(emitContext, node) { @@ -41913,122 +42623,981 @@ var ts; if (emitContext === 1) { return substituteExpression(node); } - if (ts.isIdentifier(node)) { - return substituteIdentifier(node); + else if (ts.isShorthandPropertyAssignment(node)) { + return substituteShorthandPropertyAssignment(node); } return node; } - function substituteIdentifier(node) { - if (enabledSubstitutions & 2) { - var original = ts.getParseTreeNode(node, ts.isIdentifier); - if (original && isNameOfDeclarationWithCollidingName(original)) { - return ts.getGeneratedNameForNode(original); + function substituteShorthandPropertyAssignment(node) { + var name = node.name; + var exportedOrImportedName = substituteExpressionIdentifier(name); + if (exportedOrImportedName !== name) { + if (node.objectAssignmentInitializer) { + var initializer = ts.createAssignment(exportedOrImportedName, node.objectAssignmentInitializer); + return ts.createPropertyAssignment(name, initializer, node); } + return ts.createPropertyAssignment(name, exportedOrImportedName, node); } return node; } - function isNameOfDeclarationWithCollidingName(node) { - var parent = node.parent; - switch (parent.kind) { - case 169: - case 221: - case 224: - case 218: - return parent.name === node - && resolver.isDeclarationWithCollidingName(parent); - } - return false; - } function substituteExpression(node) { switch (node.kind) { - case 69: + case 70: return substituteExpressionIdentifier(node); - case 97: - return substituteThisKeyword(node); + case 188: + return substituteBinaryExpression(node); + case 187: + case 186: + return substituteUnaryExpression(node); } return node; } function substituteExpressionIdentifier(node) { - if (enabledSubstitutions & 2) { - var declaration = resolver.getReferencedDeclarationWithCollidingName(node); + return trySubstituteExportedName(node) + || trySubstituteImportedName(node) + || node; + } + function substituteBinaryExpression(node) { + var left = node.left; + if (ts.isIdentifier(left) && ts.isAssignmentOperator(node.operatorToken.kind)) { + if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, left.text)) { + ts.setEmitFlags(node, 128); + var nestedExportAssignment = void 0; + for (var _i = 0, _a = bindingNameExportSpecifiersMap[left.text]; _i < _a.length; _i++) { + var specifier = _a[_i]; + nestedExportAssignment = nestedExportAssignment ? + createExportAssignment(specifier.name, nestedExportAssignment) : + createExportAssignment(specifier.name, node); + } + return nestedExportAssignment; + } + } + return node; + } + function substituteUnaryExpression(node) { + var operator = node.operator; + var operand = node.operand; + if (ts.isIdentifier(operand) && bindingNameExportSpecifiersForFileMap) { + if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, operand.text)) { + ts.setEmitFlags(node, 128); + var transformedUnaryExpression = void 0; + if (node.kind === 187) { + transformedUnaryExpression = ts.createBinary(operand, ts.createToken(operator === 42 ? 58 : 59), ts.createLiteral(1), node); + ts.setEmitFlags(transformedUnaryExpression, 128); + } + var nestedExportAssignment = void 0; + for (var _i = 0, _a = bindingNameExportSpecifiersMap[operand.text]; _i < _a.length; _i++) { + var specifier = _a[_i]; + nestedExportAssignment = nestedExportAssignment ? + createExportAssignment(specifier.name, nestedExportAssignment) : + createExportAssignment(specifier.name, transformedUnaryExpression || node); + } + return nestedExportAssignment; + } + } + return node; + } + function trySubstituteExportedName(node) { + var emitFlags = ts.getEmitFlags(node); + if ((emitFlags & 262144) === 0) { + var container = resolver.getReferencedExportContainer(node, (emitFlags & 131072) !== 0); + if (container) { + if (container.kind === 256) { + return ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node), node); + } + } + } + return undefined; + } + function trySubstituteImportedName(node) { + if ((ts.getEmitFlags(node) & 262144) === 0) { + var declaration = resolver.getReferencedImportDeclaration(node); if (declaration) { - return ts.getGeneratedNameForNode(declaration.name); + if (ts.isImportClause(declaration)) { + return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent), ts.createIdentifier("default"), node); + } + else if (ts.isImportSpecifier(declaration)) { + var name_37 = declaration.propertyName || declaration.name; + return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.getSynthesizedClone(name_37), node); + } + } + } + return undefined; + } + function getModuleMemberName(name) { + return ts.createPropertyAccess(ts.createIdentifier("exports"), name, name); + } + function createRequireCall(importNode) { + var moduleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); + var args = []; + if (ts.isDefined(moduleName)) { + args.push(moduleName); + } + return ts.createCall(ts.createIdentifier("require"), undefined, args); + } + function createExportStatement(name, value, location) { + var statement = ts.createStatement(createExportAssignment(name, value)); + statement.startsOnNewLine = true; + if (location) { + ts.setSourceMapRange(statement, location); + } + return statement; + } + function createExportAssignment(name, value) { + return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value); + } + function collectAsynchronousDependencies(node, includeNonAmdDependencies) { + var aliasedModuleNames = []; + var unaliasedModuleNames = []; + var importAliasNames = []; + for (var _i = 0, _a = node.amdDependencies; _i < _a.length; _i++) { + var amdDependency = _a[_i]; + if (amdDependency.name) { + aliasedModuleNames.push(ts.createLiteral(amdDependency.path)); + importAliasNames.push(ts.createParameter(amdDependency.name)); + } + else { + unaliasedModuleNames.push(ts.createLiteral(amdDependency.path)); + } + } + for (var _b = 0, externalImports_1 = externalImports; _b < externalImports_1.length; _b++) { + var importNode = externalImports_1[_b]; + var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); + var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile); + if (includeNonAmdDependencies && importAliasName) { + ts.setEmitFlags(importAliasName, 128); + aliasedModuleNames.push(externalModuleName); + importAliasNames.push(ts.createParameter(importAliasName)); + } + else { + unaliasedModuleNames.push(externalModuleName); + } + } + return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; + } + function updateSourceFile(node, statements) { + var updated = ts.getMutableClone(node); + updated.statements = ts.createNodeArray(statements, node.statements); + return updated; + } + var _a; + } + ts.transformModule = transformModule; +})(ts || (ts = {})); +var ts; +(function (ts) { + function transformSystemModule(context) { + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration, hoistFunctionDeclaration = context.hoistFunctionDeclaration; + var compilerOptions = context.getCompilerOptions(); + var resolver = context.getEmitResolver(); + var host = context.getEmitHost(); + var previousOnSubstituteNode = context.onSubstituteNode; + var previousOnEmitNode = context.onEmitNode; + context.onSubstituteNode = onSubstituteNode; + context.onEmitNode = onEmitNode; + context.enableSubstitution(70); + context.enableSubstitution(188); + context.enableSubstitution(186); + context.enableSubstitution(187); + context.enableEmitNotification(256); + var exportFunctionForFileMap = []; + var currentSourceFile; + var externalImports; + var exportSpecifiers; + var exportEquals; + var hasExportStarsToExportValues; + var exportFunctionForFile; + var contextObjectForFile; + var exportedLocalNames; + var exportedFunctionDeclarations; + var enclosingBlockScopedContainer; + var currentParent; + var currentNode; + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + currentSourceFile = node; + currentNode = node; + var updated = transformSystemModuleWorker(node); + ts.aggregateTransformFlags(updated); + currentSourceFile = undefined; + externalImports = undefined; + exportSpecifiers = undefined; + exportEquals = undefined; + hasExportStarsToExportValues = false; + exportFunctionForFile = undefined; + contextObjectForFile = undefined; + exportedLocalNames = undefined; + exportedFunctionDeclarations = undefined; + return updated; + } + return node; + } + function transformSystemModuleWorker(node) { + ts.Debug.assert(!exportFunctionForFile); + (_a = ts.collectExternalModuleInfo(node), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); + exportFunctionForFile = ts.createUniqueName("exports"); + contextObjectForFile = ts.createUniqueName("context"); + exportFunctionForFileMap[ts.getOriginalNodeId(node)] = exportFunctionForFile; + var dependencyGroups = collectDependencyGroups(externalImports); + var statements = []; + addSystemModuleBody(statements, node, dependencyGroups); + var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); + var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, getNameOfDependencyGroup)); + var body = ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ + ts.createParameter(exportFunctionForFile), + ts.createParameter(contextObjectForFile) + ], undefined, ts.setEmitFlags(ts.createBlock(statements, undefined, true), 1)); + return updateSourceFile(node, [ + ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), undefined, moduleName + ? [moduleName, dependencies, body] + : [dependencies, body])) + ], ~1 & ts.getEmitFlags(node)); + var _a; + } + function addSystemModuleBody(statements, node, dependencyGroups) { + startLexicalEnvironment(); + var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, visitSourceElement); + statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration("__moduleName", undefined, ts.createLogicalAnd(contextObjectForFile, ts.createPropertyAccess(contextObjectForFile, "id"))) + ]))); + var executeStatements = ts.visitNodes(node.statements, visitSourceElement, ts.isStatement, statementOffset); + ts.addRange(statements, endLexicalEnvironment()); + ts.addRange(statements, exportedFunctionDeclarations); + var exportStarFunction = addExportStarIfNeeded(statements); + statements.push(ts.createReturn(ts.setMultiLine(ts.createObjectLiteral([ + ts.createPropertyAssignment("setters", generateSetters(exportStarFunction, dependencyGroups)), + ts.createPropertyAssignment("execute", ts.createFunctionExpression(undefined, undefined, undefined, undefined, [], undefined, ts.createBlock(executeStatements, undefined, true))) + ]), true))); + } + function addExportStarIfNeeded(statements) { + if (!hasExportStarsToExportValues) { + return; + } + if (!exportedLocalNames && ts.isEmpty(exportSpecifiers)) { + var hasExportDeclarationWithExportClause = false; + for (var _i = 0, externalImports_2 = externalImports; _i < externalImports_2.length; _i++) { + var externalImport = externalImports_2[_i]; + if (externalImport.kind === 237 && externalImport.exportClause) { + hasExportDeclarationWithExportClause = true; + break; + } + } + if (!hasExportDeclarationWithExportClause) { + return addExportStarFunction(statements, undefined); + } + } + var exportedNames = []; + if (exportedLocalNames) { + for (var _a = 0, exportedLocalNames_1 = exportedLocalNames; _a < exportedLocalNames_1.length; _a++) { + var exportedLocalName = exportedLocalNames_1[_a]; + exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName.text), ts.createLiteral(true))); + } + } + for (var _b = 0, externalImports_3 = externalImports; _b < externalImports_3.length; _b++) { + var externalImport = externalImports_3[_b]; + if (externalImport.kind !== 237) { + continue; + } + var exportDecl = externalImport; + if (!exportDecl.exportClause) { + continue; + } + for (var _c = 0, _d = exportDecl.exportClause.elements; _c < _d.length; _c++) { + var element = _d[_c]; + exportedNames.push(ts.createPropertyAssignment(ts.createLiteral((element.name || element.propertyName).text), ts.createLiteral(true))); + } + } + var exportedNamesStorageRef = ts.createUniqueName("exportedNames"); + statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(exportedNamesStorageRef, undefined, ts.createObjectLiteral(exportedNames, undefined, true)) + ]))); + return addExportStarFunction(statements, exportedNamesStorageRef); + } + function generateSetters(exportStarFunction, dependencyGroups) { + var setters = []; + for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { + var group = dependencyGroups_1[_i]; + var localName = ts.forEach(group.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); + var parameterName = localName ? ts.getGeneratedNameForNode(localName) : ts.createUniqueName(""); + var statements = []; + for (var _a = 0, _b = group.externalImports; _a < _b.length; _a++) { + var entry = _b[_a]; + var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); + switch (entry.kind) { + case 231: + if (!entry.importClause) { + break; + } + case 230: + ts.Debug.assert(importVariableName !== undefined); + statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); + break; + case 237: + ts.Debug.assert(importVariableName !== undefined); + if (entry.exportClause) { + var properties = []; + for (var _c = 0, _d = entry.exportClause.elements; _c < _d.length; _c++) { + var e = _d[_c]; + properties.push(ts.createPropertyAssignment(ts.createLiteral(e.name.text), ts.createElementAccess(parameterName, ts.createLiteral((e.propertyName || e.name).text)))); + } + statements.push(ts.createStatement(ts.createCall(exportFunctionForFile, undefined, [ts.createObjectLiteral(properties, undefined, true)]))); + } + else { + statements.push(ts.createStatement(ts.createCall(exportStarFunction, undefined, [parameterName]))); + } + break; + } + } + setters.push(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, ts.createBlock(statements, undefined, true))); + } + return ts.createArrayLiteral(setters, undefined, true); + } + function visitSourceElement(node) { + switch (node.kind) { + case 231: + return visitImportDeclaration(node); + case 230: + return visitImportEqualsDeclaration(node); + case 237: + return visitExportDeclaration(node); + case 236: + return visitExportAssignment(node); + default: + return visitNestedNode(node); + } + } + function visitNestedNode(node) { + var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; + var savedCurrentParent = currentParent; + var savedCurrentNode = currentNode; + var currentGrandparent = currentParent; + currentParent = currentNode; + currentNode = node; + if (currentParent && ts.isBlockScope(currentParent, currentGrandparent)) { + enclosingBlockScopedContainer = currentParent; + } + var result = visitNestedNodeWorker(node); + enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; + currentParent = savedCurrentParent; + currentNode = savedCurrentNode; + return result; + } + function visitNestedNodeWorker(node) { + switch (node.kind) { + case 201: + return visitVariableStatement(node); + case 221: + return visitFunctionDeclaration(node); + case 222: + return visitClassDeclaration(node); + case 207: + return visitForStatement(node); + case 208: + return visitForInStatement(node); + case 209: + return visitForOfStatement(node); + case 205: + return visitDoStatement(node); + case 206: + return visitWhileStatement(node); + case 215: + return visitLabeledStatement(node); + case 213: + return visitWithStatement(node); + case 214: + return visitSwitchStatement(node); + case 228: + return visitCaseBlock(node); + case 249: + return visitCaseClause(node); + case 250: + return visitDefaultClause(node); + case 217: + return visitTryStatement(node); + case 252: + return visitCatchClause(node); + case 200: + return visitBlock(node); + case 203: + return visitExpressionStatement(node); + default: + return node; + } + } + function visitImportDeclaration(node) { + if (node.importClause && ts.contains(externalImports, node)) { + hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); + } + return undefined; + } + function visitImportEqualsDeclaration(node) { + if (ts.contains(externalImports, node)) { + hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); + } + return undefined; + } + function visitExportDeclaration(node) { + if (!node.moduleSpecifier) { + var statements = []; + ts.addRange(statements, ts.map(node.exportClause.elements, visitExportSpecifier)); + return statements; + } + return undefined; + } + function visitExportSpecifier(specifier) { + recordExportName(specifier.name); + return createExportStatement(specifier.name, specifier.propertyName || specifier.name); + } + function visitExportAssignment(node) { + if (node.isExportEquals) { + return undefined; + } + return createExportStatement(ts.createLiteral("default"), node.expression); + } + function visitVariableStatement(node) { + var shouldHoist = ((ts.getCombinedNodeFlags(ts.getOriginalNode(node.declarationList)) & 3) == 0) || + enclosingBlockScopedContainer.kind === 256; + if (!shouldHoist) { + return node; + } + var isExported = ts.hasModifier(node, 1); + var expressions = []; + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var variable = _a[_i]; + var visited = transformVariable(variable, isExported); + if (visited) { + expressions.push(visited); + } + } + if (expressions.length) { + return ts.createStatement(ts.inlineExpressions(expressions), node); + } + return undefined; + } + function transformVariable(node, isExported) { + hoistBindingElement(node, isExported); + if (!node.initializer) { + return; + } + var name = node.name; + if (ts.isIdentifier(name)) { + return ts.createAssignment(name, node.initializer); + } + else { + return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration); + } + } + function visitFunctionDeclaration(node) { + if (ts.hasModifier(node, 1)) { + var name_38 = node.name || ts.getGeneratedNameForNode(node); + var isAsync = ts.hasModifier(node, 256); + var newNode = ts.createFunctionDeclaration(undefined, isAsync ? [ts.createNode(119)] : undefined, node.asteriskToken, name_38, undefined, node.parameters, undefined, node.body, node); + recordExportedFunctionDeclaration(node); + if (!ts.hasModifier(node, 512)) { + recordExportName(name_38); + } + ts.setOriginalNode(newNode, node); + node = newNode; + } + hoistFunctionDeclaration(node); + return undefined; + } + function visitExpressionStatement(node) { + var originalNode = ts.getOriginalNode(node); + if ((originalNode.kind === 226 || originalNode.kind === 225) && ts.hasModifier(originalNode, 1)) { + var name_39 = getDeclarationName(originalNode); + if (originalNode.kind === 225) { + hoistVariableDeclaration(name_39); + } + return [ + node, + createExportStatement(name_39, name_39) + ]; + } + return node; + } + function visitClassDeclaration(node) { + var name = getDeclarationName(node); + hoistVariableDeclaration(name); + var statements = []; + statements.push(ts.createStatement(ts.createAssignment(name, ts.createClassExpression(undefined, node.name, undefined, node.heritageClauses, node.members, node)), node)); + if (ts.hasModifier(node, 1)) { + if (!ts.hasModifier(node, 512)) { + recordExportName(name); + } + statements.push(createDeclarationExport(node)); + } + return statements; + } + function shouldHoistLoopInitializer(node) { + return ts.isVariableDeclarationList(node) && (ts.getCombinedNodeFlags(node) & 3) === 0; + } + function visitForStatement(node) { + var initializer = node.initializer; + if (shouldHoistLoopInitializer(initializer)) { + var expressions = []; + for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) { + var variable = _a[_i]; + var visited = transformVariable(variable, false); + if (visited) { + expressions.push(visited); + } + } + ; + return ts.createFor(expressions.length + ? ts.inlineExpressions(expressions) + : ts.createSynthesizedNode(194), node.condition, node.incrementor, ts.visitNode(node.statement, visitNestedNode, ts.isStatement), node); + } + else { + return ts.visitEachChild(node, visitNestedNode, context); + } + } + function transformForBinding(node) { + var firstDeclaration = ts.firstOrUndefined(node.declarations); + hoistBindingElement(firstDeclaration, false); + var name = firstDeclaration.name; + return ts.isIdentifier(name) + ? name + : ts.flattenVariableDestructuringToExpression(firstDeclaration, hoistVariableDeclaration); + } + function visitForInStatement(node) { + var initializer = node.initializer; + if (shouldHoistLoopInitializer(initializer)) { + var updated = ts.getMutableClone(node); + updated.initializer = transformForBinding(initializer); + updated.statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, false, ts.liftToBlock); + return updated; + } + else { + return ts.visitEachChild(node, visitNestedNode, context); + } + } + function visitForOfStatement(node) { + var initializer = node.initializer; + if (shouldHoistLoopInitializer(initializer)) { + var updated = ts.getMutableClone(node); + updated.initializer = transformForBinding(initializer); + updated.statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, false, ts.liftToBlock); + return updated; + } + else { + return ts.visitEachChild(node, visitNestedNode, context); + } + } + function visitDoStatement(node) { + var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, false, ts.liftToBlock); + if (statement !== node.statement) { + var updated = ts.getMutableClone(node); + updated.statement = statement; + return updated; + } + return node; + } + function visitWhileStatement(node) { + var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, false, ts.liftToBlock); + if (statement !== node.statement) { + var updated = ts.getMutableClone(node); + updated.statement = statement; + return updated; + } + return node; + } + function visitLabeledStatement(node) { + var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, false, ts.liftToBlock); + if (statement !== node.statement) { + var updated = ts.getMutableClone(node); + updated.statement = statement; + return updated; + } + return node; + } + function visitWithStatement(node) { + var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, false, ts.liftToBlock); + if (statement !== node.statement) { + var updated = ts.getMutableClone(node); + updated.statement = statement; + return updated; + } + return node; + } + function visitSwitchStatement(node) { + var caseBlock = ts.visitNode(node.caseBlock, visitNestedNode, ts.isCaseBlock); + if (caseBlock !== node.caseBlock) { + var updated = ts.getMutableClone(node); + updated.caseBlock = caseBlock; + return updated; + } + return node; + } + function visitCaseBlock(node) { + var clauses = ts.visitNodes(node.clauses, visitNestedNode, ts.isCaseOrDefaultClause); + if (clauses !== node.clauses) { + var updated = ts.getMutableClone(node); + updated.clauses = clauses; + return updated; + } + return node; + } + function visitCaseClause(node) { + var statements = ts.visitNodes(node.statements, visitNestedNode, ts.isStatement); + if (statements !== node.statements) { + var updated = ts.getMutableClone(node); + updated.statements = statements; + return updated; + } + return node; + } + function visitDefaultClause(node) { + return ts.visitEachChild(node, visitNestedNode, context); + } + function visitTryStatement(node) { + return ts.visitEachChild(node, visitNestedNode, context); + } + function visitCatchClause(node) { + var block = ts.visitNode(node.block, visitNestedNode, ts.isBlock); + if (block !== node.block) { + var updated = ts.getMutableClone(node); + updated.block = block; + return updated; + } + return node; + } + function visitBlock(node) { + return ts.visitEachChild(node, visitNestedNode, context); + } + function onEmitNode(emitContext, node, emitCallback) { + if (node.kind === 256) { + exportFunctionForFile = exportFunctionForFileMap[ts.getOriginalNodeId(node)]; + previousOnEmitNode(emitContext, node, emitCallback); + exportFunctionForFile = undefined; + } + else { + previousOnEmitNode(emitContext, node, emitCallback); + } + } + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1) { + return substituteExpression(node); + } + return node; + } + function substituteExpression(node) { + switch (node.kind) { + case 70: + return substituteExpressionIdentifier(node); + case 188: + return substituteBinaryExpression(node); + case 186: + case 187: + return substituteUnaryExpression(node); + } + return node; + } + function substituteExpressionIdentifier(node) { + var importDeclaration = resolver.getReferencedImportDeclaration(node); + if (importDeclaration) { + var importBinding = createImportBinding(importDeclaration); + if (importBinding) { + return importBinding; } } return node; } - function substituteThisKeyword(node) { - if (enabledSubstitutions & 1 - && enclosingFunction - && ts.getEmitFlags(enclosingFunction) & 256) { - return ts.createIdentifier("_this", node); + function substituteBinaryExpression(node) { + if (ts.isAssignmentOperator(node.operatorToken.kind)) { + return substituteAssignmentExpression(node); } return node; } - function getLocalName(node, allowComments, allowSourceMaps) { - return getDeclarationName(node, allowComments, allowSourceMaps, 262144); + function substituteAssignmentExpression(node) { + ts.setEmitFlags(node, 128); + var left = node.left; + switch (left.kind) { + case 70: + var exportDeclaration = resolver.getReferencedExportContainer(left); + if (exportDeclaration) { + return createExportExpression(left, node); + } + break; + case 172: + case 171: + if (hasExportedReferenceInDestructuringPattern(left)) { + return substituteDestructuring(node); + } + break; + } + return node; } - function getDeclarationName(node, allowComments, allowSourceMaps, emitFlags) { - if (node.name && !ts.isGeneratedIdentifier(node.name)) { - var name_39 = ts.getMutableClone(node.name); - emitFlags |= ts.getEmitFlags(node.name); - if (!allowSourceMaps) { - emitFlags |= 1536; - } - if (!allowComments) { - emitFlags |= 49152; - } - if (emitFlags) { - ts.setEmitFlags(name_39, emitFlags); - } - return name_39; - } - return ts.getGeneratedNameForNode(node); + function isExportedBinding(name) { + var container = resolver.getReferencedExportContainer(name); + return container && container.kind === 256; } - function getClassMemberPrefix(node, member) { - var expression = getLocalName(node); - return ts.hasModifier(member, 32) ? expression : ts.createPropertyAccess(expression, "prototype"); + function hasExportedReferenceInDestructuringPattern(node) { + switch (node.kind) { + case 70: + return isExportedBinding(node); + case 172: + for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { + var property = _a[_i]; + if (hasExportedReferenceInObjectDestructuringElement(property)) { + return true; + } + } + break; + case 171: + for (var _b = 0, _c = node.elements; _b < _c.length; _b++) { + var element = _c[_b]; + if (hasExportedReferenceInArrayDestructuringElement(element)) { + return true; + } + } + break; + } + return false; } - function hasSynthesizedDefaultSuperCall(constructor, hasExtendsClause) { - if (!constructor || !hasExtendsClause) { + function hasExportedReferenceInObjectDestructuringElement(node) { + if (ts.isShorthandPropertyAssignment(node)) { + return isExportedBinding(node.name); + } + else if (ts.isPropertyAssignment(node)) { + return hasExportedReferenceInDestructuringElement(node.initializer); + } + else { return false; } - var parameter = ts.singleOrUndefined(constructor.parameters); - if (!parameter || !ts.nodeIsSynthesized(parameter) || !parameter.dotDotDotToken) { + } + function hasExportedReferenceInArrayDestructuringElement(node) { + if (ts.isSpreadElementExpression(node)) { + var expression = node.expression; + return ts.isIdentifier(expression) && isExportedBinding(expression); + } + else { + return hasExportedReferenceInDestructuringElement(node); + } + } + function hasExportedReferenceInDestructuringElement(node) { + if (ts.isBinaryExpression(node)) { + var left = node.left; + return node.operatorToken.kind === 57 + && isDestructuringPattern(left) + && hasExportedReferenceInDestructuringPattern(left); + } + else if (ts.isIdentifier(node)) { + return isExportedBinding(node); + } + else if (ts.isSpreadElementExpression(node)) { + var expression = node.expression; + return ts.isIdentifier(expression) && isExportedBinding(expression); + } + else if (isDestructuringPattern(node)) { + return hasExportedReferenceInDestructuringPattern(node); + } + else { return false; } - var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 202) { - return false; + } + function isDestructuringPattern(node) { + var kind = node.kind; + return kind === 70 + || kind === 172 + || kind === 171; + } + function substituteDestructuring(node) { + return ts.flattenDestructuringAssignment(context, node, true, hoistVariableDeclaration); + } + function substituteUnaryExpression(node) { + var operand = node.operand; + var operator = node.operator; + var substitute = ts.isIdentifier(operand) && + (node.kind === 187 || + (node.kind === 186 && (operator === 42 || operator === 43))); + if (substitute) { + var exportDeclaration = resolver.getReferencedExportContainer(operand); + if (exportDeclaration) { + var expr = ts.createPrefix(node.operator, operand, node); + ts.setEmitFlags(expr, 128); + var call = createExportExpression(operand, expr); + if (node.kind === 186) { + return call; + } + else { + return operator === 42 + ? ts.createSubtract(call, ts.createLiteral(1)) + : ts.createAdd(call, ts.createLiteral(1)); + } + } } - var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 174) { - return false; + return node; + } + function getDeclarationName(node) { + return node.name ? ts.getSynthesizedClone(node.name) : ts.getGeneratedNameForNode(node); + } + function addExportStarFunction(statements, localNames) { + var exportStarFunction = ts.createUniqueName("exportStar"); + var m = ts.createIdentifier("m"); + var n = ts.createIdentifier("n"); + var exports = ts.createIdentifier("exports"); + var condition = ts.createStrictInequality(n, ts.createLiteral("default")); + if (localNames) { + condition = ts.createLogicalAnd(condition, ts.createLogicalNot(ts.createHasOwnProperty(localNames, n))); } - var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 95) { - return false; + statements.push(ts.createFunctionDeclaration(undefined, undefined, undefined, exportStarFunction, undefined, [ts.createParameter(m)], undefined, ts.createBlock([ + ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(exports, undefined, ts.createObjectLiteral([])) + ])), + ts.createForIn(ts.createVariableDeclarationList([ + ts.createVariableDeclaration(n, undefined) + ]), m, ts.createBlock([ + ts.setEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 32) + ])), + ts.createStatement(ts.createCall(exportFunctionForFile, undefined, [exports])) + ], undefined, true))); + return exportStarFunction; + } + function createExportExpression(name, value) { + var exportName = ts.isIdentifier(name) ? ts.createLiteral(name.text) : name; + return ts.createCall(exportFunctionForFile, undefined, [exportName, value]); + } + function createExportStatement(name, value) { + return ts.createStatement(createExportExpression(name, value)); + } + function createDeclarationExport(node) { + var declarationName = getDeclarationName(node); + var exportName = ts.hasModifier(node, 512) ? ts.createLiteral("default") : declarationName; + return createExportStatement(exportName, declarationName); + } + function createImportBinding(importDeclaration) { + var importAlias; + var name; + if (ts.isImportClause(importDeclaration)) { + importAlias = ts.getGeneratedNameForNode(importDeclaration.parent); + name = ts.createIdentifier("default"); } - var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 191) { - return false; + else if (ts.isImportSpecifier(importDeclaration)) { + importAlias = ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent); + name = importDeclaration.propertyName || importDeclaration.name; } - var expression = callArgument.expression; - return ts.isIdentifier(expression) && expression === parameter.name; + else { + return undefined; + } + return ts.createPropertyAccess(importAlias, ts.getSynthesizedClone(name)); + } + function collectDependencyGroups(externalImports) { + var groupIndices = ts.createMap(); + var dependencyGroups = []; + for (var i = 0; i < externalImports.length; i++) { + var externalImport = externalImports[i]; + var externalModuleName = ts.getExternalModuleNameLiteral(externalImport, currentSourceFile, host, resolver, compilerOptions); + var text = externalModuleName.text; + if (ts.hasProperty(groupIndices, text)) { + var groupIndex = groupIndices[text]; + dependencyGroups[groupIndex].externalImports.push(externalImport); + continue; + } + else { + groupIndices[text] = dependencyGroups.length; + dependencyGroups.push({ + name: externalModuleName, + externalImports: [externalImport] + }); + } + } + return dependencyGroups; + } + function getNameOfDependencyGroup(dependencyGroup) { + return dependencyGroup.name; + } + function recordExportName(name) { + if (!exportedLocalNames) { + exportedLocalNames = []; + } + exportedLocalNames.push(name); + } + function recordExportedFunctionDeclaration(node) { + if (!exportedFunctionDeclarations) { + exportedFunctionDeclarations = []; + } + exportedFunctionDeclarations.push(createDeclarationExport(node)); + } + function hoistBindingElement(node, isExported) { + if (ts.isOmittedExpression(node)) { + return; + } + var name = node.name; + if (ts.isIdentifier(name)) { + hoistVariableDeclaration(ts.getSynthesizedClone(name)); + if (isExported) { + recordExportName(name); + } + } + else if (ts.isBindingPattern(name)) { + ts.forEach(name.elements, isExported ? hoistExportedBindingElement : hoistNonExportedBindingElement); + } + } + function hoistExportedBindingElement(node) { + hoistBindingElement(node, true); + } + function hoistNonExportedBindingElement(node) { + hoistBindingElement(node, false); + } + function updateSourceFile(node, statements, nodeEmitFlags) { + var updated = ts.getMutableClone(node); + updated.statements = ts.createNodeArray(statements, node.statements); + ts.setEmitFlags(updated, nodeEmitFlags); + return updated; } } - ts.transformES6 = transformES6; + ts.transformSystemModule = transformSystemModule; +})(ts || (ts = {})); +var ts; +(function (ts) { + function transformES2015Module(context) { + var compilerOptions = context.getCompilerOptions(); + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + return ts.visitEachChild(node, visitor, context); + } + return node; + } + function visitor(node) { + switch (node.kind) { + case 230: + return undefined; + case 236: + return visitExportAssignment(node); + } + return node; + } + function visitExportAssignment(node) { + return node.isExportEquals ? undefined : node; + } + } + ts.transformES2015Module = transformES2015Module; })(ts || (ts = {})); var ts; (function (ts) { var moduleTransformerMap = ts.createMap((_a = {}, - _a[ts.ModuleKind.ES6] = ts.transformES6Module, + _a[ts.ModuleKind.ES2015] = ts.transformES2015Module, _a[ts.ModuleKind.System] = ts.transformSystemModule, _a[ts.ModuleKind.AMD] = ts.transformModule, _a[ts.ModuleKind.CommonJS] = ts.transformModule, _a[ts.ModuleKind.UMD] = ts.transformModule, _a[ts.ModuleKind.None] = ts.transformModule, _a)); + var SyntaxKindFeatureFlags; + (function (SyntaxKindFeatureFlags) { + SyntaxKindFeatureFlags[SyntaxKindFeatureFlags["Substitution"] = 1] = "Substitution"; + SyntaxKindFeatureFlags[SyntaxKindFeatureFlags["EmitNotifications"] = 2] = "EmitNotifications"; + })(SyntaxKindFeatureFlags || (SyntaxKindFeatureFlags = {})); function getTransformers(compilerOptions) { var jsx = compilerOptions.jsx; var languageVersion = ts.getEmitScriptTarget(compilerOptions); @@ -42039,11 +43608,19 @@ var ts; if (jsx === 2) { transformers.push(ts.transformJsx); } - transformers.push(ts.transformES7); + if (languageVersion < 4) { + transformers.push(ts.transformES2017); + } + if (languageVersion < 3) { + transformers.push(ts.transformES2016); + } if (languageVersion < 2) { - transformers.push(ts.transformES6); + transformers.push(ts.transformES2015); transformers.push(ts.transformGenerators); } + if (languageVersion < 1) { + transformers.push(ts.transformES5); + } return transformers; } ts.getTransformers = getTransformers; @@ -42063,7 +43640,7 @@ var ts; hoistFunctionDeclaration: hoistFunctionDeclaration, startLexicalEnvironment: startLexicalEnvironment, endLexicalEnvironment: endLexicalEnvironment, - onSubstituteNode: function (emitContext, node) { return node; }, + onSubstituteNode: function (_emitContext, node) { return node; }, enableSubstitution: enableSubstitution, isSubstitutionEnabled: isSubstitutionEnabled, onEmitNode: function (node, emitContext, emitCallback) { return emitCallback(node, emitContext); }, @@ -42203,7 +43780,7 @@ var ts; emitNodeWithSourceMap: emitNodeWithSourceMap, emitTokenWithSourceMap: emitTokenWithSourceMap, getText: getText, - getSourceMappingURL: getSourceMappingURL + getSourceMappingURL: getSourceMappingURL, }; function initialize(filePath, sourceMapFilePath, sourceFiles, isBundledEmit) { if (disabled) { @@ -42406,7 +43983,7 @@ var ts; sources: sourceMapData.sourceMapSources, names: sourceMapData.sourceMapNames, mappings: sourceMapData.sourceMapMappings, - sourcesContent: sourceMapData.sourceMapSourcesContent + sourcesContent: sourceMapData.sourceMapSourcesContent, }); } function getSourceMappingURL() { @@ -42470,7 +44047,7 @@ var ts; setSourceFile: setSourceFile, emitNodeWithComments: emitNodeWithComments, emitBodyWithDetachedComments: emitBodyWithDetachedComments, - emitTrailingCommentsOfPosition: emitTrailingCommentsOfPosition + emitTrailingCommentsOfPosition: emitTrailingCommentsOfPosition, }; function emitNodeWithComments(emitContext, node, emitCallback) { if (disabled) { @@ -42508,7 +44085,7 @@ var ts; } if (!skipTrailingComments) { containerEnd = end; - if (node.kind === 219) { + if (node.kind === 220) { declarationListContainerEnd = end; } } @@ -42584,7 +44161,7 @@ var ts; emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos); } } - function emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) { + function emitLeadingComment(commentPos, commentEnd, _kind, hasTrailingNewLine, rangePos) { if (!hasWrittenComment) { ts.emitNewLineBeforeLeadingCommentOfPosition(currentLineMap, writer, rangePos, commentPos); hasWrittenComment = true; @@ -42602,7 +44179,7 @@ var ts; function emitTrailingComments(pos) { forEachTrailingCommentToEmit(pos, emitTrailingComment); } - function emitTrailingComment(commentPos, commentEnd, kind, hasTrailingNewLine) { + function emitTrailingComment(commentPos, commentEnd, _kind, hasTrailingNewLine) { if (!writer.isAtStartOfLine()) { writer.write(" "); } @@ -42625,7 +44202,7 @@ var ts; ts.performance.measure("commentTime", "beforeEmitTrailingCommentsOfPosition"); } } - function emitTrailingCommentOfPosition(commentPos, commentEnd, kind, hasTrailingNewLine) { + function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) { emitPos(commentPos); ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); emitPos(commentEnd); @@ -42736,7 +44313,7 @@ var ts; var isCurrentFileExternalModule; var reportedDeclarationError = false; var errorNameNode; - var emitJsDocComments = compilerOptions.removeComments ? function (declaration) { } : writeJsDocComments; + var emitJsDocComments = compilerOptions.removeComments ? function () { } : writeJsDocComments; var emit = compilerOptions.stripInternal ? stripInternal : emitNode; var noDeclare; var moduleElementDeclarationEmitInfo = []; @@ -42780,7 +44357,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 230); + ts.Debug.assert(aliasEmitInfo.node.kind === 231); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -42811,7 +44388,7 @@ var ts; reportedDeclarationError: reportedDeclarationError, moduleElementDeclarationEmitInfo: allSourcesModuleElementDeclarationEmitInfo, synchronousDeclarationOutput: writer.getText(), - referencesOutput: referencesOutput + referencesOutput: referencesOutput, }; function hasInternalAnnotation(range) { var comment = currentText.substring(range.pos, range.end); @@ -42851,10 +44428,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 218) { + if (declaration.kind === 219) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 233 || declaration.kind === 234 || declaration.kind === 231) { + else if (declaration.kind === 234 || declaration.kind === 235 || declaration.kind === 232) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -42865,7 +44442,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 230) { + if (moduleElementEmitInfo.node.kind === 231) { moduleElementEmitInfo.isVisible = true; } else { @@ -42873,12 +44450,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 225) { + if (nodeToCheck.kind === 226) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 225) { + if (nodeToCheck.kind === 226) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -42990,67 +44567,67 @@ var ts; } function emitType(type) { switch (type.kind) { - case 117: - case 132: - case 130: - case 120: + case 118: case 133: - case 103: - case 135: - case 93: - case 127: - case 165: + case 131: + case 121: + case 134: + case 104: + case 136: + case 94: + case 128: case 166: + case 167: return writeTextOfNode(currentText, type); - case 194: + case 195: return emitExpressionWithTypeArguments(type); - case 155: - return emitTypeReference(type); - case 158: - return emitTypeQuery(type); - case 160: - return emitArrayType(type); - case 161: - return emitTupleType(type); - case 162: - return emitUnionType(type); - case 163: - return emitIntersectionType(type); - case 164: - return emitParenType(type); case 156: - case 157: - return emitSignatureDeclarationWithJsDocComments(type); + return emitTypeReference(type); case 159: + return emitTypeQuery(type); + case 161: + return emitArrayType(type); + case 162: + return emitTupleType(type); + case 163: + return emitUnionType(type); + case 164: + return emitIntersectionType(type); + case 165: + return emitParenType(type); + case 157: + case 158: + return emitSignatureDeclarationWithJsDocComments(type); + case 160: return emitTypeLiteral(type); - case 69: + case 70: return emitEntityName(type); - case 139: + case 140: return emitEntityName(type); - case 154: + case 155: return emitTypePredicate(type); } function writeEntityName(entityName) { - if (entityName.kind === 69) { + if (entityName.kind === 70) { writeTextOfNode(currentText, entityName); } else { - var left = entityName.kind === 139 ? entityName.left : entityName.expression; - var right = entityName.kind === 139 ? entityName.right : entityName.name; + var left = entityName.kind === 140 ? entityName.left : entityName.expression; + var right = entityName.kind === 140 ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentText, right); } } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 229 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 230 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isEntityNameExpression(node.expression)) { - ts.Debug.assert(node.expression.kind === 69 || node.expression.kind === 172); + ts.Debug.assert(node.expression.kind === 70 || node.expression.kind === 173); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -43131,7 +44708,7 @@ var ts; } } function emitExportAssignment(node) { - if (node.expression.kind === 69) { + if (node.expression.kind === 70) { write(node.isExportEquals ? "export = " : "export default "); writeTextOfNode(currentText, node.expression); } @@ -43152,11 +44729,11 @@ var ts; } write(";"); writeLine(); - if (node.expression.kind === 69) { + if (node.expression.kind === 70) { var nodes = resolver.collectLinkedAliases(node.expression); writeAsynchronousModuleElements(nodes); } - function getDefaultExportAccessibilityDiagnostic(diagnostic) { + function getDefaultExportAccessibilityDiagnostic() { return { diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, errorNode: node @@ -43170,7 +44747,7 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 229 || + else if (node.kind === 230 || (node.parent.kind === 256 && isCurrentFileExternalModule)) { var isVisible = void 0; if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 256) { @@ -43182,7 +44759,7 @@ var ts; }); } else { - if (node.kind === 230) { + if (node.kind === 231) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -43200,23 +44777,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 220: - return writeFunctionDeclaration(node); - case 200: - return writeVariableStatement(node); - case 222: - return writeInterfaceDeclaration(node); case 221: - return writeClassDeclaration(node); + return writeFunctionDeclaration(node); + case 201: + return writeVariableStatement(node); case 223: - return writeTypeAliasDeclaration(node); + return writeInterfaceDeclaration(node); + case 222: + return writeClassDeclaration(node); case 224: - return writeEnumDeclaration(node); + return writeTypeAliasDeclaration(node); case 225: + return writeEnumDeclaration(node); + case 226: return writeModuleDeclaration(node); - case 229: - return writeImportEqualsDeclaration(node); case 230: + return writeImportEqualsDeclaration(node); + case 231: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -43231,7 +44808,7 @@ var ts; if (modifiers & 512) { write("default "); } - else if (node.kind !== 222 && !noDeclare) { + else if (node.kind !== 223 && !noDeclare) { write("declare "); } } @@ -43271,7 +44848,7 @@ var ts; write(");"); } writer.writeLine(); - function getImportEntityNameVisibilityError(symbolAccessibilityResult) { + function getImportEntityNameVisibilityError() { return { diagnosticMessage: ts.Diagnostics.Import_declaration_0_is_using_private_name_1, errorNode: node, @@ -43281,7 +44858,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 232) { + if (namedBindings.kind === 233) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -43304,7 +44881,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 232) { + if (node.importClause.namedBindings.kind === 233) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -43321,13 +44898,13 @@ var ts; writer.writeLine(); } function emitExternalModuleSpecifier(parent) { - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 225; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 226; var moduleSpecifier; - if (parent.kind === 229) { + if (parent.kind === 230) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 225) { + else if (parent.kind === 226) { moduleSpecifier = parent.name; } else { @@ -43395,7 +44972,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body && node.body.kind !== 226) { + while (node.body && node.body.kind !== 227) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -43429,7 +45006,7 @@ var ts; write(";"); writeLine(); enclosingDeclaration = prevEnclosingDeclaration; - function getTypeAliasDeclarationVisibilityError(symbolAccessibilityResult) { + function getTypeAliasDeclarationVisibilityError() { return { diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, errorNode: node.type, @@ -43465,7 +45042,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 147 && ts.hasModifier(node.parent, 8); + return node.parent.kind === 148 && ts.hasModifier(node.parent, 8); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -43475,49 +45052,49 @@ var ts; writeTextOfNode(currentText, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 156 || - node.parent.kind === 157 || - (node.parent.parent && node.parent.parent.kind === 159)) { - ts.Debug.assert(node.parent.kind === 147 || - node.parent.kind === 146 || - node.parent.kind === 156 || + if (node.parent.kind === 157 || + node.parent.kind === 158 || + (node.parent.parent && node.parent.parent.kind === 160)) { + ts.Debug.assert(node.parent.kind === 148 || + node.parent.kind === 147 || node.parent.kind === 157 || - node.parent.kind === 151 || - node.parent.kind === 152); + node.parent.kind === 158 || + node.parent.kind === 152 || + node.parent.kind === 153); emitType(node.constraint); } else { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.constraint, getTypeParameterConstraintVisibilityError); } } - function getTypeParameterConstraintVisibilityError(symbolAccessibilityResult) { + function getTypeParameterConstraintVisibilityError() { var diagnosticMessage; switch (node.parent.kind) { - case 221: + case 222: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 222: + case 223: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 152: + case 153: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 151: + case 152: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; + case 148: case 147: - case 146: if (ts.hasModifier(node.parent, 32)) { 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 === 221) { + else if (node.parent.parent.kind === 222) { 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 220: + case 221: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -43545,16 +45122,16 @@ var ts; if (ts.isEntityNameExpression(node.expression)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } - else if (!isImplementsList && node.expression.kind === 93) { + else if (!isImplementsList && node.expression.kind === 94) { write("null"); } else { writer.getSymbolAccessibilityDiagnostic = getHeritageClauseVisibilityError; resolver.writeBaseConstructorTypeOfClass(enclosingDeclaration, enclosingDeclaration, 2 | 1024, writer); } - function getHeritageClauseVisibilityError(symbolAccessibilityResult) { + function getHeritageClauseVisibilityError() { var diagnosticMessage; - if (node.parent.parent.kind === 221) { + if (node.parent.parent.kind === 222) { 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; @@ -43634,17 +45211,17 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 218 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 219 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } else { writeTextOfNode(currentText, node.name); - if ((node.kind === 145 || node.kind === 144 || - (node.kind === 142 && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { + if ((node.kind === 146 || node.kind === 145 || + (node.kind === 143 && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 145 || node.kind === 144) && node.parent.kind === 159) { + if ((node.kind === 146 || node.kind === 145) && node.parent.kind === 160) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (resolver.isLiteralConstDeclaration(node)) { @@ -43657,14 +45234,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 218) { + if (node.kind === 219) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 === 145 || node.kind === 144) { + else if (node.kind === 146 || node.kind === 145) { if (ts.hasModifier(node, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -43672,7 +45249,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 === 221) { + else if (node.parent.kind === 222) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -43698,7 +45275,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 193) { + if (element.kind !== 194) { elements.push(element); } } @@ -43764,7 +45341,7 @@ var ts; accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 149 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 150 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -43777,7 +45354,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 149 + return accessor.kind === 150 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -43786,7 +45363,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 150) { + if (accessorWithTypeAnnotation.kind === 151) { if (ts.hasModifier(accessorWithTypeAnnotation.parent, 32)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : @@ -43832,17 +45409,17 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 220) { + if (node.kind === 221) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 147 || node.kind === 148) { + else if (node.kind === 148 || node.kind === 149) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); } - if (node.kind === 220) { + if (node.kind === 221) { write("function "); writeTextOfNode(currentText, node.name); } - else if (node.kind === 148) { + else if (node.kind === 149) { write("constructor"); } else { @@ -43862,15 +45439,15 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; var closeParenthesizedFunctionType = false; - if (node.kind === 153) { + if (node.kind === 154) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); write("["); } else { - if (node.kind === 152 || node.kind === 157) { + if (node.kind === 153 || node.kind === 158) { write("new "); } - else if (node.kind === 156) { + else if (node.kind === 157) { var currentOutput = writer.getText(); if (node.typeParameters && currentOutput.charAt(currentOutput.length - 1) === "<") { closeParenthesizedFunctionType = true; @@ -43881,20 +45458,20 @@ var ts; write("("); } emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 153) { + if (node.kind === 154) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 156 || node.kind === 157; - if (isFunctionTypeOrConstructorType || node.parent.kind === 159) { + var isFunctionTypeOrConstructorType = node.kind === 157 || node.kind === 158; + if (isFunctionTypeOrConstructorType || node.parent.kind === 160) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 148 && !ts.hasModifier(node, 8)) { + else if (node.kind !== 149 && !ts.hasModifier(node, 8)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -43908,23 +45485,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 152: + case 153: diagnosticMessage = symbolAccessibilityResult.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 151: + case 152: diagnosticMessage = symbolAccessibilityResult.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 153: + case 154: diagnosticMessage = symbolAccessibilityResult.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 148: case 147: - case 146: if (ts.hasModifier(node, 32)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -43932,7 +45509,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 === 221) { + else if (node.parent.kind === 222) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 : @@ -43945,7 +45522,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 220: + case 221: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -43977,9 +45554,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 156 || - node.parent.kind === 157 || - node.parent.parent.kind === 159) { + if (node.parent.kind === 157 || + node.parent.kind === 158 || + node.parent.parent.kind === 160) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!ts.hasModifier(node.parent, 8)) { @@ -43995,22 +45572,22 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 148: + case 149: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 152: + case 153: return symbolAccessibilityResult.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 151: + case 152: return symbolAccessibilityResult.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 148: case 147: - case 146: if (ts.hasModifier(node.parent, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -44018,7 +45595,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 === 221) { + else if (node.parent.parent.kind === 222) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 : @@ -44030,7 +45607,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 220: + case 221: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -44041,12 +45618,12 @@ var ts; } } function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 167) { + if (bindingPattern.kind === 168) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 168) { + else if (bindingPattern.kind === 169) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -44057,10 +45634,10 @@ var ts; } } function emitBindingElement(bindingElement) { - if (bindingElement.kind === 193) { + if (bindingElement.kind === 194) { write(" "); } - else if (bindingElement.kind === 169) { + else if (bindingElement.kind === 170) { if (bindingElement.propertyName) { writeTextOfNode(currentText, bindingElement.propertyName); write(": "); @@ -44070,7 +45647,7 @@ var ts; emitBindingPattern(bindingElement.name); } else { - ts.Debug.assert(bindingElement.name.kind === 69); + ts.Debug.assert(bindingElement.name.kind === 70); if (bindingElement.dotDotDotToken) { write("..."); } @@ -44082,37 +45659,37 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 220: - case 225: - case 229: - case 222: case 221: - case 223: - case 224: - return emitModuleElement(node, isModuleElementVisible(node)); - case 200: - return emitModuleElement(node, isVariableStatementVisible(node)); + case 226: case 230: + case 223: + case 222: + case 224: + case 225: + return emitModuleElement(node, isModuleElementVisible(node)); + case 201: + return emitModuleElement(node, isVariableStatementVisible(node)); + case 231: return emitModuleElement(node, !node.importClause); - case 236: + case 237: return emitExportDeclaration(node); + case 149: case 148: case 147: - case 146: return writeFunctionDeclaration(node); - case 152: - case 151: case 153: + case 152: + case 154: return emitSignatureDeclarationWithJsDocComments(node); - case 149: case 150: + case 151: return emitAccessorDeclaration(node); + case 146: case 145: - case 144: return emitPropertyDeclaration(node); case 255: return emitEnumMemberDeclaration(node); - case 235: + case 236: return emitExportAssignment(node); case 256: return emitSourceFile(node); @@ -44132,7 +45709,7 @@ var ts; referencesOutput += "/// " + newLine; } return addedBundledEmitReference; - function getDeclFileName(emitFileNames, sourceFiles, isBundledEmit) { + function getDeclFileName(emitFileNames, _sourceFiles, isBundledEmit) { if (isBundledEmit && !addBundledFileReference) { return; } @@ -44169,8 +45746,14 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + var TempFlags; + (function (TempFlags) { + TempFlags[TempFlags["Auto"] = 0] = "Auto"; + TempFlags[TempFlags["CountMask"] = 268435455] = "CountMask"; + TempFlags[TempFlags["_i"] = 268435456] = "_i"; + })(TempFlags || (TempFlags = {})); var id = function (s) { return s; }; - var nullTransformers = [function (ctx) { return id; }]; + var nullTransformers = [function (_) { return id; }]; function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles) { var delimiters = createDelimiterMap(); var brackets = createBracketsMap(); @@ -44348,191 +45931,205 @@ var ts; function pipelineEmitInIdentifierNameContext(node) { var kind = node.kind; switch (kind) { - case 69: + case 70: return emitIdentifier(node); } } function pipelineEmitInUnspecifiedContext(node) { var kind = node.kind; switch (kind) { - case 12: case 13: case 14: + case 15: return emitLiteral(node); - case 69: + case 70: return emitIdentifier(node); - case 74: - case 77: - case 82: - case 103: - case 110: + case 75: + case 78: + case 83: + case 104: case 111: case 112: case 113: - case 115: + case 114: + case 116: case 117: case 118: + case 119: case 120: + case 121: case 122: - case 130: + case 123: + case 124: + case 125: + case 126: + case 127: case 128: + case 129: + case 130: + case 131: case 132: case 133: + case 134: + case 135: + case 136: case 137: + case 138: + case 139: writeTokenText(kind); return; - case 139: - return emitQualifiedName(node); case 140: - return emitComputedPropertyName(node); + return emitQualifiedName(node); case 141: - return emitTypeParameter(node); + return emitComputedPropertyName(node); case 142: - return emitParameter(node); + return emitTypeParameter(node); case 143: - return emitDecorator(node); + return emitParameter(node); case 144: - return emitPropertySignature(node); + return emitDecorator(node); case 145: - return emitPropertyDeclaration(node); + return emitPropertySignature(node); case 146: - return emitMethodSignature(node); + return emitPropertyDeclaration(node); case 147: - return emitMethodDeclaration(node); + return emitMethodSignature(node); case 148: - return emitConstructor(node); + return emitMethodDeclaration(node); case 149: + return emitConstructor(node); case 150: - return emitAccessorDeclaration(node); case 151: - return emitCallSignature(node); + return emitAccessorDeclaration(node); case 152: - return emitConstructSignature(node); + return emitCallSignature(node); case 153: - return emitIndexSignature(node); + return emitConstructSignature(node); case 154: - return emitTypePredicate(node); + return emitIndexSignature(node); case 155: - return emitTypeReference(node); + return emitTypePredicate(node); case 156: - return emitFunctionType(node); + return emitTypeReference(node); case 157: - return emitConstructorType(node); + return emitFunctionType(node); case 158: - return emitTypeQuery(node); + return emitConstructorType(node); case 159: - return emitTypeLiteral(node); + return emitTypeQuery(node); case 160: - return emitArrayType(node); + return emitTypeLiteral(node); case 161: - return emitTupleType(node); + return emitArrayType(node); case 162: - return emitUnionType(node); + return emitTupleType(node); case 163: - return emitIntersectionType(node); + return emitUnionType(node); case 164: - return emitParenthesizedType(node); - case 194: - return emitExpressionWithTypeArguments(node); + return emitIntersectionType(node); case 165: - return emitThisType(node); + return emitParenthesizedType(node); + case 195: + return emitExpressionWithTypeArguments(node); case 166: - return emitLiteralType(node); + return emitThisType(); case 167: - return emitObjectBindingPattern(node); + return emitLiteralType(node); case 168: - return emitArrayBindingPattern(node); + return emitObjectBindingPattern(node); case 169: + return emitArrayBindingPattern(node); + case 170: return emitBindingElement(node); - case 197: - return emitTemplateSpan(node); case 198: - return emitSemicolonClassElement(node); + return emitTemplateSpan(node); case 199: - return emitBlock(node); + return emitSemicolonClassElement(); case 200: - return emitVariableStatement(node); + return emitBlock(node); case 201: - return emitEmptyStatement(node); + return emitVariableStatement(node); case 202: - return emitExpressionStatement(node); + return emitEmptyStatement(); case 203: - return emitIfStatement(node); + return emitExpressionStatement(node); case 204: - return emitDoStatement(node); + return emitIfStatement(node); case 205: - return emitWhileStatement(node); + return emitDoStatement(node); case 206: - return emitForStatement(node); + return emitWhileStatement(node); case 207: - return emitForInStatement(node); + return emitForStatement(node); case 208: - return emitForOfStatement(node); + return emitForInStatement(node); case 209: - return emitContinueStatement(node); + return emitForOfStatement(node); case 210: - return emitBreakStatement(node); + return emitContinueStatement(node); case 211: - return emitReturnStatement(node); + return emitBreakStatement(node); case 212: - return emitWithStatement(node); + return emitReturnStatement(node); case 213: - return emitSwitchStatement(node); + return emitWithStatement(node); case 214: - return emitLabeledStatement(node); + return emitSwitchStatement(node); case 215: - return emitThrowStatement(node); + return emitLabeledStatement(node); case 216: - return emitTryStatement(node); + return emitThrowStatement(node); case 217: - return emitDebuggerStatement(node); + return emitTryStatement(node); case 218: - return emitVariableDeclaration(node); + return emitDebuggerStatement(node); case 219: - return emitVariableDeclarationList(node); + return emitVariableDeclaration(node); case 220: - return emitFunctionDeclaration(node); + return emitVariableDeclarationList(node); case 221: - return emitClassDeclaration(node); + return emitFunctionDeclaration(node); case 222: - return emitInterfaceDeclaration(node); + return emitClassDeclaration(node); case 223: - return emitTypeAliasDeclaration(node); + return emitInterfaceDeclaration(node); case 224: - return emitEnumDeclaration(node); + return emitTypeAliasDeclaration(node); case 225: - return emitModuleDeclaration(node); + return emitEnumDeclaration(node); case 226: - return emitModuleBlock(node); + return emitModuleDeclaration(node); case 227: + return emitModuleBlock(node); + case 228: return emitCaseBlock(node); - case 229: - return emitImportEqualsDeclaration(node); case 230: - return emitImportDeclaration(node); + return emitImportEqualsDeclaration(node); case 231: - return emitImportClause(node); + return emitImportDeclaration(node); case 232: - return emitNamespaceImport(node); + return emitImportClause(node); case 233: - return emitNamedImports(node); + return emitNamespaceImport(node); case 234: - return emitImportSpecifier(node); + return emitNamedImports(node); case 235: - return emitExportAssignment(node); + return emitImportSpecifier(node); case 236: - return emitExportDeclaration(node); + return emitExportAssignment(node); case 237: - return emitNamedExports(node); + return emitExportDeclaration(node); case 238: - return emitExportSpecifier(node); + return emitNamedExports(node); case 239: - return; + return emitExportSpecifier(node); case 240: + return; + case 241: return emitExternalModuleReference(node); - case 244: + case 10: return emitJsxText(node); - case 243: + case 244: return emitJsxOpeningElement(node); case 245: return emitJsxClosingElement(node); @@ -44567,73 +46164,73 @@ var ts; case 8: return emitNumericLiteral(node); case 9: - case 10: case 11: + case 12: return emitLiteral(node); - case 69: + case 70: return emitIdentifier(node); - case 84: - case 93: - case 95: - case 99: - case 97: + case 85: + case 94: + case 96: + case 100: + case 98: writeTokenText(kind); return; - case 170: - return emitArrayLiteralExpression(node); case 171: - return emitObjectLiteralExpression(node); + return emitArrayLiteralExpression(node); case 172: - return emitPropertyAccessExpression(node); + return emitObjectLiteralExpression(node); case 173: - return emitElementAccessExpression(node); + return emitPropertyAccessExpression(node); case 174: - return emitCallExpression(node); + return emitElementAccessExpression(node); case 175: - return emitNewExpression(node); + return emitCallExpression(node); case 176: - return emitTaggedTemplateExpression(node); + return emitNewExpression(node); case 177: - return emitTypeAssertionExpression(node); + return emitTaggedTemplateExpression(node); case 178: - return emitParenthesizedExpression(node); + return emitTypeAssertionExpression(node); case 179: - return emitFunctionExpression(node); + return emitParenthesizedExpression(node); case 180: - return emitArrowFunction(node); + return emitFunctionExpression(node); case 181: - return emitDeleteExpression(node); + return emitArrowFunction(node); case 182: - return emitTypeOfExpression(node); + return emitDeleteExpression(node); case 183: - return emitVoidExpression(node); + return emitTypeOfExpression(node); case 184: - return emitAwaitExpression(node); + return emitVoidExpression(node); case 185: - return emitPrefixUnaryExpression(node); + return emitAwaitExpression(node); case 186: - return emitPostfixUnaryExpression(node); + return emitPrefixUnaryExpression(node); case 187: - return emitBinaryExpression(node); + return emitPostfixUnaryExpression(node); case 188: - return emitConditionalExpression(node); + return emitBinaryExpression(node); case 189: - return emitTemplateExpression(node); + return emitConditionalExpression(node); case 190: - return emitYieldExpression(node); + return emitTemplateExpression(node); case 191: - return emitSpreadElementExpression(node); + return emitYieldExpression(node); case 192: - return emitClassExpression(node); + return emitSpreadElementExpression(node); case 193: + return emitClassExpression(node); + case 194: return; - case 195: - return emitAsExpression(node); case 196: + return emitAsExpression(node); + case 197: return emitNonNullExpression(node); - case 241: - return emitJsxElement(node); case 242: + return emitJsxElement(node); + case 243: return emitJsxSelfClosingElement(node); case 288: return emitPartiallyEmittedExpression(node); @@ -44669,7 +46266,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 69) { + if (node.kind === 70) { emitExpression(node); } else { @@ -44739,7 +46336,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - write(node.kind === 149 ? "get " : "set "); + write(node.kind === 150 ? "get " : "set "); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); } @@ -44767,7 +46364,7 @@ var ts; emitWithPrefix(": ", node.type); write(";"); } - function emitSemicolonClassElement(node) { + function emitSemicolonClassElement() { write(";"); } function emitTypePredicate(node) { @@ -44821,7 +46418,7 @@ var ts; emit(node.type); write(")"); } - function emitThisType(node) { + function emitThisType() { write("this"); } function emitLiteralType(node) { @@ -44889,7 +46486,7 @@ var ts; if (!(ts.getEmitFlags(node) & 1048576)) { var dotRangeStart = node.expression.end; var dotRangeEnd = ts.skipTrivia(currentText, node.expression.end) + 1; - var dotToken = { kind: 21, pos: dotRangeStart, end: dotRangeEnd }; + var dotToken = { kind: 22, pos: dotRangeStart, end: dotRangeEnd }; indentBeforeDot = needsIndentation(node, node.expression, dotToken); indentAfterDot = needsIndentation(node, dotToken, node.name); } @@ -44904,7 +46501,7 @@ var ts; function needsDotDotForPropertyAccess(expression) { if (expression.kind === 8) { var text = getLiteralTextOfNode(expression); - return text.indexOf(ts.tokenToString(21)) < 0; + return text.indexOf(ts.tokenToString(22)) < 0; } else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { var constantValue = ts.getConstantValue(expression); @@ -44921,11 +46518,13 @@ var ts; } function emitCallExpression(node) { emitExpression(node.expression); + emitTypeArguments(node, node.typeArguments); emitExpressionList(node, node.arguments, 1296); } function emitNewExpression(node) { write("new "); emitExpression(node.expression); + emitTypeArguments(node, node.typeArguments); emitExpressionList(node, node.arguments, 9488); } function emitTaggedTemplateExpression(node) { @@ -44985,16 +46584,16 @@ var ts; } function shouldEmitWhitespaceBeforeOperand(node) { var operand = node.operand; - return operand.kind === 185 - && ((node.operator === 35 && (operand.operator === 35 || operand.operator === 41)) - || (node.operator === 36 && (operand.operator === 36 || operand.operator === 42))); + return operand.kind === 186 + && ((node.operator === 36 && (operand.operator === 36 || operand.operator === 42)) + || (node.operator === 37 && (operand.operator === 37 || operand.operator === 43))); } function emitPostfixUnaryExpression(node) { emitExpression(node.operand); writeTokenText(node.operator); } function emitBinaryExpression(node) { - var isCommaOperator = node.operatorToken.kind !== 24; + var isCommaOperator = node.operatorToken.kind !== 25; var indentBeforeOperator = needsIndentation(node, node.left, node.operatorToken); var indentAfterOperator = needsIndentation(node, node.operatorToken, node.right); emitExpression(node.left); @@ -45055,16 +46654,16 @@ var ts; emitExpression(node.expression); emit(node.literal); } - function emitBlock(node, format) { + function emitBlock(node) { if (isSingleLineEmptyBlock(node)) { - writeToken(15, node.pos, node); + writeToken(16, node.pos, node); write(" "); - writeToken(16, node.statements.end, node); + writeToken(17, node.statements.end, node); } else { - writeToken(15, node.pos, node); + writeToken(16, node.pos, node); emitBlockStatements(node); - writeToken(16, node.statements.end, node); + writeToken(17, node.statements.end, node); } } function emitBlockStatements(node) { @@ -45080,7 +46679,7 @@ var ts; emit(node.declarationList); write(";"); } - function emitEmptyStatement(node) { + function emitEmptyStatement() { write(";"); } function emitExpressionStatement(node) { @@ -45088,16 +46687,16 @@ var ts; write(";"); } function emitIfStatement(node) { - var openParenPos = writeToken(88, node.pos, node); + var openParenPos = writeToken(89, node.pos, node); write(" "); - writeToken(17, openParenPos, node); + writeToken(18, openParenPos, node); emitExpression(node.expression); - writeToken(18, node.expression.end, node); + writeToken(19, node.expression.end, node); emitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { writeLine(); - writeToken(80, node.thenStatement.end, node); - if (node.elseStatement.kind === 203) { + writeToken(81, node.thenStatement.end, node); + if (node.elseStatement.kind === 204) { write(" "); emit(node.elseStatement); } @@ -45126,9 +46725,9 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForStatement(node) { - var openParenPos = writeToken(86, node.pos); + var openParenPos = writeToken(87, node.pos); write(" "); - writeToken(17, openParenPos, node); + writeToken(18, openParenPos, node); emitForBinding(node.initializer); write(";"); emitExpressionWithPrefix(" ", node.condition); @@ -45138,28 +46737,28 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInStatement(node) { - var openParenPos = writeToken(86, node.pos); + var openParenPos = writeToken(87, node.pos); write(" "); - writeToken(17, openParenPos); + writeToken(18, openParenPos); emitForBinding(node.initializer); write(" in "); emitExpression(node.expression); - writeToken(18, node.expression.end); + writeToken(19, node.expression.end); emitEmbeddedStatement(node.statement); } function emitForOfStatement(node) { - var openParenPos = writeToken(86, node.pos); + var openParenPos = writeToken(87, node.pos); write(" "); - writeToken(17, openParenPos); + writeToken(18, openParenPos); emitForBinding(node.initializer); write(" of "); emitExpression(node.expression); - writeToken(18, node.expression.end); + writeToken(19, node.expression.end); emitEmbeddedStatement(node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 219) { + if (node.kind === 220) { emit(node); } else { @@ -45168,17 +46767,17 @@ var ts; } } function emitContinueStatement(node) { - writeToken(75, node.pos); + writeToken(76, node.pos); emitWithPrefix(" ", node.label); write(";"); } function emitBreakStatement(node) { - writeToken(70, node.pos); + writeToken(71, node.pos); emitWithPrefix(" ", node.label); write(";"); } function emitReturnStatement(node) { - writeToken(94, node.pos, node); + writeToken(95, node.pos, node); emitExpressionWithPrefix(" ", node.expression); write(";"); } @@ -45189,11 +46788,11 @@ var ts; emitEmbeddedStatement(node.statement); } function emitSwitchStatement(node) { - var openParenPos = writeToken(96, node.pos); + var openParenPos = writeToken(97, node.pos); write(" "); - writeToken(17, openParenPos); + writeToken(18, openParenPos); emitExpression(node.expression); - writeToken(18, node.expression.end); + writeToken(19, node.expression.end); write(" "); emit(node.caseBlock); } @@ -45218,11 +46817,12 @@ var ts; } } function emitDebuggerStatement(node) { - writeToken(76, node.pos); + writeToken(77, node.pos); write(";"); } function emitVariableDeclaration(node) { emit(node.name); + emitWithPrefix(": ", node.type); emitExpressionWithPrefix(" = ", node.initializer); } function emitVariableDeclarationList(node) { @@ -45249,13 +46849,13 @@ var ts; } if (ts.getEmitFlags(node) & 4194304) { emitSignatureHead(node); - emitBlockFunctionBody(node, body); + emitBlockFunctionBody(body); } else { var savedTempFlags = tempFlags; tempFlags = 0; emitSignatureHead(node); - emitBlockFunctionBody(node, body); + emitBlockFunctionBody(body); tempFlags = savedTempFlags; } if (indentedFlag) { @@ -45278,7 +46878,7 @@ var ts; emitParameters(node, node.parameters); emitWithPrefix(": ", node.type); } - function shouldEmitBlockFunctionBodyOnSingleLine(parentNode, body) { + function shouldEmitBlockFunctionBodyOnSingleLine(body) { if (ts.getEmitFlags(body) & 32) { return true; } @@ -45302,14 +46902,14 @@ var ts; } return true; } - function emitBlockFunctionBody(parentNode, body) { + function emitBlockFunctionBody(body) { write(" {"); increaseIndent(); - emitBodyWithDetachedComments(body, body.statements, shouldEmitBlockFunctionBodyOnSingleLine(parentNode, body) + emitBodyWithDetachedComments(body, body.statements, shouldEmitBlockFunctionBodyOnSingleLine(body) ? emitBlockFunctionBodyOnSingleLine : emitBlockFunctionBodyWorker); decreaseIndent(); - writeToken(16, body.statements.end, body); + writeToken(17, body.statements.end, body); } function emitBlockFunctionBodyOnSingleLine(body) { emitBlockFunctionBodyWorker(body, true); @@ -45387,7 +46987,7 @@ var ts; write(node.flags & 16 ? "namespace " : "module "); emit(node.name); var body = node.body; - while (body.kind === 225) { + while (body.kind === 226) { write("."); emit(body.name); body = body.body; @@ -45410,9 +47010,9 @@ var ts; } } function emitCaseBlock(node) { - writeToken(15, node.pos); + writeToken(16, node.pos); emitList(node, node.clauses, 65); - writeToken(16, node.clauses.end); + writeToken(17, node.clauses.end); } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); @@ -45423,7 +47023,7 @@ var ts; write(";"); } function emitModuleReference(node) { - if (node.kind === 69) { + if (node.kind === 70) { emitExpression(node); } else { @@ -45543,7 +47143,7 @@ var ts; } } function emitJsxTagName(node) { - if (node.kind === 69) { + if (node.kind === 70) { emitExpression(node); } else { @@ -45581,11 +47181,11 @@ var ts; } function emitCatchClause(node) { writeLine(); - var openParenPos = writeToken(72, node.pos); + var openParenPos = writeToken(73, node.pos); write(" "); - writeToken(17, openParenPos); + writeToken(18, openParenPos); emit(node.variableDeclaration); - writeToken(18, node.variableDeclaration ? node.variableDeclaration.end : openParenPos); + writeToken(19, node.variableDeclaration ? node.variableDeclaration.end : openParenPos); write(" "); emit(node.block); } @@ -45692,7 +47292,7 @@ var ts; paramEmitted = true; helpersEmitted = true; } - if (!awaiterEmitted && node.flags & 8192) { + if ((languageVersion < 4) && (!awaiterEmitted && node.flags & 8192)) { writeLines(awaiterHelper); if (languageVersion < 2) { writeLines(generatorHelper); @@ -46001,7 +47601,7 @@ var ts; && !ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 178 && ts.nodeIsSynthesized(node)) { + while (node.kind === 179 && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -46108,19 +47708,19 @@ var ts; } function generateNameForNode(node) { switch (node.kind) { - case 69: + case 70: return makeUniqueName(getTextOfNode(node)); + case 226: case 225: - case 224: return generateNameForModuleOrEnum(node); - case 230: - case 236: + case 231: + case 237: return generateNameForImportOrExportDeclaration(node); - case 220: case 221: - case 235: + case 222: + case 236: return generateNameForExportDefault(); - case 192: + case 193: return generateNameForClassExpression(); default: return makeTempVariableName(0); @@ -46190,6 +47790,68 @@ var ts; } } ts.emitFiles = emitFiles; + var ListFormat; + (function (ListFormat) { + ListFormat[ListFormat["None"] = 0] = "None"; + ListFormat[ListFormat["SingleLine"] = 0] = "SingleLine"; + ListFormat[ListFormat["MultiLine"] = 1] = "MultiLine"; + ListFormat[ListFormat["PreserveLines"] = 2] = "PreserveLines"; + ListFormat[ListFormat["LinesMask"] = 3] = "LinesMask"; + ListFormat[ListFormat["NotDelimited"] = 0] = "NotDelimited"; + ListFormat[ListFormat["BarDelimited"] = 4] = "BarDelimited"; + ListFormat[ListFormat["AmpersandDelimited"] = 8] = "AmpersandDelimited"; + ListFormat[ListFormat["CommaDelimited"] = 16] = "CommaDelimited"; + ListFormat[ListFormat["DelimitersMask"] = 28] = "DelimitersMask"; + ListFormat[ListFormat["AllowTrailingComma"] = 32] = "AllowTrailingComma"; + ListFormat[ListFormat["Indented"] = 64] = "Indented"; + ListFormat[ListFormat["SpaceBetweenBraces"] = 128] = "SpaceBetweenBraces"; + ListFormat[ListFormat["SpaceBetweenSiblings"] = 256] = "SpaceBetweenSiblings"; + ListFormat[ListFormat["Braces"] = 512] = "Braces"; + ListFormat[ListFormat["Parenthesis"] = 1024] = "Parenthesis"; + ListFormat[ListFormat["AngleBrackets"] = 2048] = "AngleBrackets"; + ListFormat[ListFormat["SquareBrackets"] = 4096] = "SquareBrackets"; + ListFormat[ListFormat["BracketsMask"] = 7680] = "BracketsMask"; + ListFormat[ListFormat["OptionalIfUndefined"] = 8192] = "OptionalIfUndefined"; + ListFormat[ListFormat["OptionalIfEmpty"] = 16384] = "OptionalIfEmpty"; + ListFormat[ListFormat["Optional"] = 24576] = "Optional"; + ListFormat[ListFormat["PreferNewLine"] = 32768] = "PreferNewLine"; + ListFormat[ListFormat["NoTrailingNewLine"] = 65536] = "NoTrailingNewLine"; + ListFormat[ListFormat["NoInterveningComments"] = 131072] = "NoInterveningComments"; + ListFormat[ListFormat["Modifiers"] = 256] = "Modifiers"; + ListFormat[ListFormat["HeritageClauses"] = 256] = "HeritageClauses"; + ListFormat[ListFormat["TypeLiteralMembers"] = 65] = "TypeLiteralMembers"; + ListFormat[ListFormat["TupleTypeElements"] = 336] = "TupleTypeElements"; + ListFormat[ListFormat["UnionTypeConstituents"] = 260] = "UnionTypeConstituents"; + ListFormat[ListFormat["IntersectionTypeConstituents"] = 264] = "IntersectionTypeConstituents"; + ListFormat[ListFormat["ObjectBindingPatternElements"] = 432] = "ObjectBindingPatternElements"; + ListFormat[ListFormat["ArrayBindingPatternElements"] = 304] = "ArrayBindingPatternElements"; + ListFormat[ListFormat["ObjectLiteralExpressionProperties"] = 978] = "ObjectLiteralExpressionProperties"; + ListFormat[ListFormat["ArrayLiteralExpressionElements"] = 4466] = "ArrayLiteralExpressionElements"; + ListFormat[ListFormat["CallExpressionArguments"] = 1296] = "CallExpressionArguments"; + ListFormat[ListFormat["NewExpressionArguments"] = 9488] = "NewExpressionArguments"; + ListFormat[ListFormat["TemplateExpressionSpans"] = 131072] = "TemplateExpressionSpans"; + ListFormat[ListFormat["SingleLineBlockStatements"] = 384] = "SingleLineBlockStatements"; + ListFormat[ListFormat["MultiLineBlockStatements"] = 65] = "MultiLineBlockStatements"; + ListFormat[ListFormat["VariableDeclarationList"] = 272] = "VariableDeclarationList"; + ListFormat[ListFormat["SingleLineFunctionBodyStatements"] = 384] = "SingleLineFunctionBodyStatements"; + ListFormat[ListFormat["MultiLineFunctionBodyStatements"] = 1] = "MultiLineFunctionBodyStatements"; + ListFormat[ListFormat["ClassHeritageClauses"] = 256] = "ClassHeritageClauses"; + ListFormat[ListFormat["ClassMembers"] = 65] = "ClassMembers"; + ListFormat[ListFormat["InterfaceMembers"] = 65] = "InterfaceMembers"; + ListFormat[ListFormat["EnumMembers"] = 81] = "EnumMembers"; + ListFormat[ListFormat["CaseBlockClauses"] = 65] = "CaseBlockClauses"; + ListFormat[ListFormat["NamedImportsOrExportsElements"] = 432] = "NamedImportsOrExportsElements"; + ListFormat[ListFormat["JsxElementChildren"] = 131072] = "JsxElementChildren"; + ListFormat[ListFormat["JsxElementAttributes"] = 131328] = "JsxElementAttributes"; + ListFormat[ListFormat["CaseOrDefaultClauseStatements"] = 81985] = "CaseOrDefaultClauseStatements"; + ListFormat[ListFormat["HeritageClauseTypes"] = 272] = "HeritageClauseTypes"; + ListFormat[ListFormat["SourceFileStatements"] = 65537] = "SourceFileStatements"; + ListFormat[ListFormat["Decorators"] = 24577] = "Decorators"; + ListFormat[ListFormat["TypeArguments"] = 26960] = "TypeArguments"; + ListFormat[ListFormat["TypeParameters"] = 26960] = "TypeParameters"; + ListFormat[ListFormat["Parameters"] = 1360] = "Parameters"; + ListFormat[ListFormat["IndexSignatureParameters"] = 4432] = "IndexSignatureParameters"; + })(ListFormat || (ListFormat = {})); })(ts || (ts = {})); var ts; (function (ts) { @@ -46643,7 +48305,7 @@ var ts; getSourceFiles: program.getSourceFiles, isSourceFileFromExternalLibrary: function (file) { return !!sourceFilesFoundSearchingNodeModules[file.path]; }, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), - isEmitBlocked: isEmitBlocked + isEmitBlocked: isEmitBlocked, }; } function getDiagnosticsProducingTypeChecker() { @@ -46721,7 +48383,7 @@ var ts; return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile, cancellationToken); } } - function getSyntacticDiagnosticsForFile(sourceFile, cancellationToken) { + function getSyntacticDiagnosticsForFile(sourceFile) { return sourceFile.parseDiagnostics; } function runWithCancellationToken(func) { @@ -46742,14 +48404,14 @@ var ts; ts.Debug.assert(!!sourceFile.bindDiagnostics); var bindDiagnostics = sourceFile.bindDiagnostics; var checkDiagnostics = ts.isSourceFileJavaScript(sourceFile) ? - getJavaScriptSemanticDiagnosticsForFile(sourceFile, cancellationToken) : + getJavaScriptSemanticDiagnosticsForFile(sourceFile) : typeChecker.getDiagnostics(sourceFile, cancellationToken); var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); - return bindDiagnostics.concat(checkDiagnostics).concat(fileProcessingDiagnosticsInFile).concat(programDiagnosticsInFile); + return bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); }); } - function getJavaScriptSemanticDiagnosticsForFile(sourceFile, cancellationToken) { + function getJavaScriptSemanticDiagnosticsForFile(sourceFile) { return runWithCancellationToken(function () { var diagnostics = []; walk(sourceFile); @@ -46759,16 +48421,16 @@ var ts; return false; } switch (node.kind) { - case 229: + case 230: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return true; - case 235: + case 236: if (node.isExportEquals) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return true; } break; - case 221: + case 222: var classDeclaration = node; if (checkModifiers(classDeclaration.modifiers) || checkTypeParameters(classDeclaration.typeParameters)) { @@ -46777,29 +48439,29 @@ var ts; break; case 251: var heritageClause = node; - if (heritageClause.token === 106) { + if (heritageClause.token === 107) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return true; } break; - case 222: + case 223: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return true; - case 225: + case 226: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return true; - case 223: + case 224: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return true; - case 147: - case 146: case 148: + case 147: case 149: case 150: - case 179: - case 220: + case 151: case 180: - case 220: + case 221: + case 181: + case 221: var functionDeclaration = node; if (checkModifiers(functionDeclaration.modifiers) || checkTypeParameters(functionDeclaration.typeParameters) || @@ -46807,20 +48469,20 @@ var ts; return true; } break; - case 200: + case 201: var variableStatement = node; if (checkModifiers(variableStatement.modifiers)) { return true; } break; - case 218: + case 219: var variableDeclaration = node; if (checkTypeAnnotation(variableDeclaration.type)) { return true; } break; - case 174: case 175: + case 176: var expression = node; if (expression.typeArguments && expression.typeArguments.length > 0) { var start = expression.typeArguments.pos; @@ -46828,7 +48490,7 @@ var ts; return true; } break; - case 142: + case 143: var parameter = node; if (parameter.modifiers) { var start = parameter.modifiers.pos; @@ -46844,12 +48506,12 @@ var ts; return true; } break; - case 145: + case 146: var propertyDeclaration = node; if (propertyDeclaration.modifiers) { for (var _i = 0, _a = propertyDeclaration.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 113) { + if (modifier.kind !== 114) { diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); return true; } @@ -46859,14 +48521,14 @@ var ts; return true; } break; - case 224: + case 225: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return true; - case 177: + case 178: 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 143: + case 144: if (!options.experimentalDecorators) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning)); } @@ -46894,18 +48556,18 @@ var ts; for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { var modifier = modifiers_1[_i]; switch (modifier.kind) { - case 112: - case 110: + case 113: case 111: - case 128: - case 122: + case 112: + case 129: + case 123: diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); return true; - case 113: - case 82: - case 74: - case 77: - case 115: + case 114: + case 83: + case 75: + case 78: + case 116: } } } @@ -46938,7 +48600,7 @@ var ts; return ts.getBaseFileName(fileName).indexOf(".") >= 0; } function processRootFile(fileName, isDefaultLib) { - processSourceFile(ts.normalizePath(fileName), isDefaultLib, true); + processSourceFile(ts.normalizePath(fileName), isDefaultLib); } function fileReferenceIsEqualTo(a, b) { return a.fileName === b.fileName; @@ -46977,9 +48639,9 @@ var ts; return; function collectModuleReferences(node, inAmbientModule) { switch (node.kind) { + case 231: case 230: - case 229: - case 236: + case 237: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9) { break; @@ -46991,7 +48653,7 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 225: + case 226: if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasModifier(node, 2) || ts.isDeclarationFile(file))) { var moduleName = node.name; if (isExternalModuleFile || (inAmbientModule && !ts.isExternalModuleNameRelative(moduleName.text))) { @@ -47018,7 +48680,7 @@ var ts; } } } - function processSourceFile(fileName, isDefaultLib, isReference, refFile, refPos, refEnd) { + function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { var diagnosticArgument; var diagnostic; if (hasExtension(fileName)) { @@ -47026,7 +48688,7 @@ var ts; diagnostic = ts.Diagnostics.File_0_has_unsupported_extension_The_only_supported_extensions_are_1; diagnosticArgument = [fileName, "'" + supportedExtensions.join("', '") + "'"]; } - else if (!findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, isReference, refFile, refPos, refEnd)) { + else if (!findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd)) { diagnostic = ts.Diagnostics.File_0_not_found; diagnosticArgument = [fileName]; } @@ -47036,13 +48698,13 @@ var ts; } } else { - var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, isReference, refFile, refPos, refEnd); + var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd); if (!nonTsFile) { if (options.allowNonTsExtensions) { diagnostic = ts.Diagnostics.File_0_not_found; diagnosticArgument = [fileName]; } - else if (!ts.forEach(supportedExtensions, function (extension) { return findSourceFile(fileName + extension, ts.toPath(fileName + extension, currentDirectory, getCanonicalFileName), isDefaultLib, isReference, refFile, refPos, refEnd); })) { + else if (!ts.forEach(supportedExtensions, function (extension) { return findSourceFile(fileName + extension, ts.toPath(fileName + extension, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd); })) { diagnostic = ts.Diagnostics.File_0_not_found; fileName += ".ts"; diagnosticArgument = [fileName]; @@ -47066,7 +48728,7 @@ var ts; fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); } } - function findSourceFile(fileName, path, isDefaultLib, isReference, refFile, refPos, refEnd) { + function findSourceFile(fileName, path, isDefaultLib, refFile, refPos, refEnd) { if (filesByName.contains(path)) { var file_1 = filesByName.get(path); if (file_1 && options.forceConsistentCasingInFileNames && ts.getNormalizedAbsolutePath(file_1.fileName, currentDirectory) !== ts.getNormalizedAbsolutePath(fileName, currentDirectory)) { @@ -47075,16 +48737,16 @@ var ts; if (file_1 && sourceFilesFoundSearchingNodeModules[file_1.path] && currentNodeModulesDepth == 0) { sourceFilesFoundSearchingNodeModules[file_1.path] = false; if (!options.noResolve) { - processReferencedFiles(file_1, ts.getDirectoryPath(fileName), isDefaultLib); + processReferencedFiles(file_1, isDefaultLib); processTypeReferenceDirectives(file_1); } modulesWithElidedImports[file_1.path] = false; - processImportedModules(file_1, ts.getDirectoryPath(fileName)); + processImportedModules(file_1); } else if (file_1 && modulesWithElidedImports[file_1.path]) { if (currentNodeModulesDepth < maxNodeModulesJsDepth) { modulesWithElidedImports[file_1.path] = false; - processImportedModules(file_1, ts.getDirectoryPath(fileName)); + processImportedModules(file_1); } } return file_1; @@ -47111,12 +48773,11 @@ var ts; } } skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; - var basePath = ts.getDirectoryPath(fileName); if (!options.noResolve) { - processReferencedFiles(file, basePath, isDefaultLib); + processReferencedFiles(file, isDefaultLib); processTypeReferenceDirectives(file); } - processImportedModules(file, basePath); + processImportedModules(file); if (isDefaultLib) { files.unshift(file); } @@ -47126,10 +48787,10 @@ var ts; } return file; } - function processReferencedFiles(file, basePath, isDefaultLib) { + function processReferencedFiles(file, isDefaultLib) { ts.forEach(file.referencedFiles, function (ref) { var referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName); - processSourceFile(referencedFileName, isDefaultLib, true, file, ref.pos, ref.end); + processSourceFile(referencedFileName, isDefaultLib, file, ref.pos, ref.end); }); } function processTypeReferenceDirectives(file) { @@ -47151,7 +48812,7 @@ var ts; var saveResolution = true; if (resolvedTypeReferenceDirective) { if (resolvedTypeReferenceDirective.primary) { - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, true, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, refFile, refPos, refEnd); } else { if (previousResolution) { @@ -47162,7 +48823,7 @@ var ts; saveResolution = false; } else { - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, true, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, refFile, refPos, refEnd); } } } @@ -47188,7 +48849,7 @@ var ts; function getCanonicalFileName(fileName) { return host.getCanonicalFileName(fileName); } - function processImportedModules(file, basePath) { + function processImportedModules(file) { collectExternalModuleReferences(file); if (file.imports.length || file.moduleAugmentations.length) { file.resolvedModules = ts.createMap(); @@ -47208,7 +48869,7 @@ var ts; modulesWithElidedImports[file.path] = true; } else if (shouldAddFile) { - findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), false, false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); + findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); } if (isFromNodeModulesSearch) { currentNodeModulesDepth--; @@ -47378,7 +49039,7 @@ var ts; if (!options.noEmit && !options.suppressOutputPathCheck) { var emitHost = getEmitHost(); var emitFilesSeen_1 = ts.createFileMap(!host.useCaseSensitiveFileNames() ? function (key) { return key.toLocaleLowerCase(); } : undefined); - ts.forEachExpectedEmitFile(emitHost, function (emitFileNames, sourceFiles, isBundledEmit) { + ts.forEachExpectedEmitFile(emitHost, function (emitFileNames) { verifyEmitFilePath(emitFileNames.jsFilePath, emitFilesSeen_1); verifyEmitFilePath(emitFileNames.declarationFilePath, emitFilesSeen_1); }); @@ -47387,10 +49048,10 @@ var ts; if (emitFileName) { var emitFilePath = ts.toPath(emitFileName, currentDirectory, getCanonicalFileName); if (filesByName.contains(emitFilePath)) { - createEmitBlockingDiagnostics(emitFileName, emitFilePath, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file); + createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file); } if (emitFilesSeen.contains(emitFilePath)) { - createEmitBlockingDiagnostics(emitFileName, emitFilePath, ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files); + createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files); } else { emitFilesSeen.set(emitFilePath, true); @@ -47398,7 +49059,7 @@ var ts; } } } - function createEmitBlockingDiagnostics(emitFileName, emitFilePath, message) { + function createEmitBlockingDiagnostics(emitFileName, message) { hasEmitBlockingDiagnostics.set(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName), true); programDiagnostics.add(ts.createCompilerDiagnostic(message, emitFileName)); } @@ -47411,24 +49072,24 @@ var ts; ts.optionDeclarations = [ { name: "charset", - type: "string" + type: "string", }, ts.compileOnSaveCommandLineOption, { name: "declaration", shortName: "d", type: "boolean", - description: ts.Diagnostics.Generates_corresponding_d_ts_file + description: ts.Diagnostics.Generates_corresponding_d_ts_file, }, { name: "declarationDir", type: "string", isFilePath: true, - paramType: ts.Diagnostics.DIRECTORY + paramType: ts.Diagnostics.DIRECTORY, }, { name: "diagnostics", - type: "boolean" + type: "boolean", }, { name: "extendedDiagnostics", @@ -47443,7 +49104,7 @@ var ts; name: "help", shortName: "h", type: "boolean", - description: ts.Diagnostics.Print_this_message + description: ts.Diagnostics.Print_this_message, }, { name: "help", @@ -47453,15 +49114,15 @@ var ts; { name: "init", type: "boolean", - description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file + description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file, }, { name: "inlineSourceMap", - type: "boolean" + type: "boolean", }, { name: "inlineSources", - type: "boolean" + type: "boolean", }, { name: "jsx", @@ -47470,7 +49131,7 @@ var ts; "react": 2 }), paramType: ts.Diagnostics.KIND, - description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react + description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, }, { name: "reactNamespace", @@ -47479,18 +49140,18 @@ var ts; }, { name: "listFiles", - type: "boolean" + type: "boolean", }, { name: "locale", - type: "string" + type: "string", }, { name: "mapRoot", type: "string", isFilePath: true, description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, - paramType: ts.Diagnostics.LOCATION + paramType: ts.Diagnostics.LOCATION, }, { name: "module", @@ -47501,11 +49162,11 @@ var ts; "amd": ts.ModuleKind.AMD, "system": ts.ModuleKind.System, "umd": ts.ModuleKind.UMD, - "es6": ts.ModuleKind.ES6, - "es2015": ts.ModuleKind.ES2015 + "es6": ts.ModuleKind.ES2015, + "es2015": ts.ModuleKind.ES2015, }), description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, - paramType: ts.Diagnostics.KIND + paramType: ts.Diagnostics.KIND, }, { name: "newLine", @@ -47514,12 +49175,12 @@ var ts; "lf": 1 }), description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, - paramType: ts.Diagnostics.NEWLINE + paramType: ts.Diagnostics.NEWLINE, }, { name: "noEmit", type: "boolean", - description: ts.Diagnostics.Do_not_emit_outputs + description: ts.Diagnostics.Do_not_emit_outputs, }, { name: "noEmitHelpers", @@ -47528,7 +49189,7 @@ var ts; { name: "noEmitOnError", type: "boolean", - description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported + description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, }, { name: "noErrorTruncation", @@ -47537,59 +49198,59 @@ var ts; { name: "noImplicitAny", type: "boolean", - description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type + description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type, }, { name: "noImplicitThis", type: "boolean", - description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type + description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, }, { name: "noUnusedLocals", type: "boolean", - description: ts.Diagnostics.Report_errors_on_unused_locals + description: ts.Diagnostics.Report_errors_on_unused_locals, }, { name: "noUnusedParameters", type: "boolean", - description: ts.Diagnostics.Report_errors_on_unused_parameters + description: ts.Diagnostics.Report_errors_on_unused_parameters, }, { name: "noLib", - type: "boolean" + type: "boolean", }, { name: "noResolve", - type: "boolean" + type: "boolean", }, { name: "skipDefaultLibCheck", - type: "boolean" + type: "boolean", }, { name: "skipLibCheck", type: "boolean", - description: ts.Diagnostics.Skip_type_checking_of_declaration_files + description: ts.Diagnostics.Skip_type_checking_of_declaration_files, }, { name: "out", type: "string", isFilePath: false, - paramType: ts.Diagnostics.FILE + paramType: ts.Diagnostics.FILE, }, { name: "outFile", type: "string", isFilePath: true, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, - paramType: ts.Diagnostics.FILE + paramType: ts.Diagnostics.FILE, }, { name: "outDir", type: "string", isFilePath: true, description: ts.Diagnostics.Redirect_output_structure_to_the_directory, - paramType: ts.Diagnostics.DIRECTORY + paramType: ts.Diagnostics.DIRECTORY, }, { name: "preserveConstEnums", @@ -47612,30 +49273,30 @@ var ts; { name: "removeComments", type: "boolean", - description: ts.Diagnostics.Do_not_emit_comments_to_output + description: ts.Diagnostics.Do_not_emit_comments_to_output, }, { name: "rootDir", type: "string", isFilePath: true, paramType: ts.Diagnostics.LOCATION, - description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir + description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, }, { name: "isolatedModules", - type: "boolean" + type: "boolean", }, { name: "sourceMap", type: "boolean", - description: ts.Diagnostics.Generates_corresponding_map_file + description: ts.Diagnostics.Generates_corresponding_map_file, }, { name: "sourceRoot", type: "string", isFilePath: true, description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, - paramType: ts.Diagnostics.LOCATION + paramType: ts.Diagnostics.LOCATION, }, { name: "suppressExcessPropertyErrors", @@ -47646,7 +49307,7 @@ var ts; { name: "suppressImplicitAnyIndexErrors", type: "boolean", - description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures + description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, }, { name: "stripInternal", @@ -47661,22 +49322,24 @@ var ts; "es3": 0, "es5": 1, "es6": 2, - "es2015": 2 + "es2015": 2, + "es2016": 3, + "es2017": 4, }), description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015, - paramType: ts.Diagnostics.VERSION + paramType: ts.Diagnostics.VERSION, }, { name: "version", shortName: "v", type: "boolean", - description: ts.Diagnostics.Print_the_compiler_s_version + description: ts.Diagnostics.Print_the_compiler_s_version, }, { name: "watch", shortName: "w", type: "boolean", - description: ts.Diagnostics.Watch_input_files + description: ts.Diagnostics.Watch_input_files, }, { name: "experimentalDecorators", @@ -47693,10 +49356,10 @@ var ts; name: "moduleResolution", type: ts.createMap({ "node": ts.ModuleResolutionKind.NodeJs, - "classic": ts.ModuleResolutionKind.Classic + "classic": ts.ModuleResolutionKind.Classic, }), description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, - paramType: ts.Diagnostics.STRATEGY + paramType: ts.Diagnostics.STRATEGY, }, { name: "allowUnusedLabels", @@ -47819,7 +49482,7 @@ var ts; "es2016.array.include": "lib.es2016.array.include.d.ts", "es2017.object": "lib.es2017.object.d.ts", "es2017.sharedmemory": "lib.es2017.sharedmemory.d.ts" - }) + }), }, description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon }, @@ -47846,7 +49509,7 @@ var ts; ts.typingOptionDeclarations = [ { name: "enableAutoDiscovery", - type: "boolean" + type: "boolean", }, { name: "include", @@ -47869,7 +49532,7 @@ var ts; module: ts.ModuleKind.CommonJS, target: 1, noImplicitAny: false, - sourceMap: false + sourceMap: false, }; var optionNameMapCache; function getOptionNameMap() { @@ -47889,10 +49552,7 @@ var ts; } ts.getOptionNameMap = getOptionNameMap; function createCompilerDiagnosticForInvalidCustomType(opt) { - var namesOfType = []; - for (var key in opt.type) { - namesOfType.push(" '" + key + "'"); - } + var namesOfType = Object.keys(opt.type).map(function (key) { return "'" + key + "'"; }).join(", "); return ts.createCompilerDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); } ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; @@ -48507,7 +50167,7 @@ var ts; reportDiagnostic(diagnostic, host); } } - function reportEmittedFiles(files, host) { + function reportEmittedFiles(files) { if (!files || files.length == 0) { return; } @@ -48566,10 +50226,10 @@ var ts; }); return count; } - function getDiagnosticText(message) { - var args = []; + function getDiagnosticText(_message) { + var _args = []; for (var _i = 1; _i < arguments.length; _i++) { - args[_i - 1] = arguments[_i]; + _args[_i - 1] = arguments[_i]; } var diagnostic = ts.createCompilerDiagnostic.apply(undefined, arguments); return diagnostic.messageText; @@ -48841,7 +50501,7 @@ var ts; } var sourceFile = hostGetSourceFile(fileName, languageVersion, onError); if (sourceFile && ts.isWatchSet(compilerOptions) && ts.sys.watchFile) { - sourceFile.fileWatcher = ts.sys.watchFile(sourceFile.fileName, function (fileName, removed) { return sourceFileChanged(sourceFile, removed); }); + sourceFile.fileWatcher = ts.sys.watchFile(sourceFile.fileName, function (_fileName, removed) { return sourceFileChanged(sourceFile, removed); }); } return sourceFile; } @@ -48963,7 +50623,7 @@ var ts; var emitOutput = program.emit(); diagnostics = diagnostics.concat(emitOutput.diagnostics); reportDiagnostics(ts.sortAndDeduplicateDiagnostics(diagnostics), compilerHost); - reportEmittedFiles(emitOutput.emittedFiles, compilerHost); + reportEmittedFiles(emitOutput.emittedFiles); if (emitOutput.emitSkipped && diagnostics.length > 0) { return ts.ExitStatus.DiagnosticsPresent_OutputsSkipped; } @@ -49105,3 +50765,5 @@ if (ts.sys.tryEnableSourceMapsForHost && /^development$/i.test(ts.sys.getEnviron ts.sys.tryEnableSourceMapsForHost(); } ts.executeCommandLine(ts.sys.args); + +//# sourceMappingURL=tsc.js.map diff --git a/lib/tsserver.js b/lib/tsserver.js index f5437988c1a..be6578b0762 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -20,6 +20,418 @@ var __extends = (this && this.__extends) || function (d, b) { }; var ts; (function (ts) { + (function (SyntaxKind) { + SyntaxKind[SyntaxKind["Unknown"] = 0] = "Unknown"; + SyntaxKind[SyntaxKind["EndOfFileToken"] = 1] = "EndOfFileToken"; + SyntaxKind[SyntaxKind["SingleLineCommentTrivia"] = 2] = "SingleLineCommentTrivia"; + SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 3] = "MultiLineCommentTrivia"; + SyntaxKind[SyntaxKind["NewLineTrivia"] = 4] = "NewLineTrivia"; + SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 5] = "WhitespaceTrivia"; + SyntaxKind[SyntaxKind["ShebangTrivia"] = 6] = "ShebangTrivia"; + SyntaxKind[SyntaxKind["ConflictMarkerTrivia"] = 7] = "ConflictMarkerTrivia"; + SyntaxKind[SyntaxKind["NumericLiteral"] = 8] = "NumericLiteral"; + SyntaxKind[SyntaxKind["StringLiteral"] = 9] = "StringLiteral"; + SyntaxKind[SyntaxKind["JsxText"] = 10] = "JsxText"; + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 11] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 12] = "NoSubstitutionTemplateLiteral"; + SyntaxKind[SyntaxKind["TemplateHead"] = 13] = "TemplateHead"; + SyntaxKind[SyntaxKind["TemplateMiddle"] = 14] = "TemplateMiddle"; + SyntaxKind[SyntaxKind["TemplateTail"] = 15] = "TemplateTail"; + SyntaxKind[SyntaxKind["OpenBraceToken"] = 16] = "OpenBraceToken"; + SyntaxKind[SyntaxKind["CloseBraceToken"] = 17] = "CloseBraceToken"; + SyntaxKind[SyntaxKind["OpenParenToken"] = 18] = "OpenParenToken"; + SyntaxKind[SyntaxKind["CloseParenToken"] = 19] = "CloseParenToken"; + SyntaxKind[SyntaxKind["OpenBracketToken"] = 20] = "OpenBracketToken"; + SyntaxKind[SyntaxKind["CloseBracketToken"] = 21] = "CloseBracketToken"; + SyntaxKind[SyntaxKind["DotToken"] = 22] = "DotToken"; + SyntaxKind[SyntaxKind["DotDotDotToken"] = 23] = "DotDotDotToken"; + SyntaxKind[SyntaxKind["SemicolonToken"] = 24] = "SemicolonToken"; + SyntaxKind[SyntaxKind["CommaToken"] = 25] = "CommaToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 26] = "LessThanToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 27] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 28] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 29] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 30] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 31] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 32] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 33] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 34] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 35] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 36] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 37] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 38] = "AsteriskToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 39] = "AsteriskAsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 40] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 41] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 42] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 43] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 44] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 45] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 46] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 47] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 48] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 49] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 50] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 51] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 52] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 53] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 54] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 55] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 56] = "AtToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 57] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 58] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 59] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 60] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 61] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 62] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 63] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 64] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 65] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 66] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 67] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 68] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 69] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["Identifier"] = 70] = "Identifier"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 71] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 72] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 73] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 74] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 75] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 76] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 77] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 78] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 79] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 80] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 81] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 82] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 83] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 84] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 85] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 86] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 87] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 88] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 89] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 90] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 91] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 92] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 93] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 94] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 95] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 96] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 97] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 98] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 99] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 100] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 101] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 102] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 103] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 104] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 105] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 106] = "WithKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 107] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 108] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 109] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 110] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 111] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 112] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 113] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 114] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 115] = "YieldKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 116] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 117] = "AsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 118] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 119] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 120] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 121] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 122] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 123] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 124] = "GetKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 125] = "IsKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 126] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 127] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 128] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 129] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 130] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 131] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 132] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 133] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 134] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 135] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 136] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 137] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 138] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 139] = "OfKeyword"; + SyntaxKind[SyntaxKind["QualifiedName"] = 140] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 141] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["TypeParameter"] = 142] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 143] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 144] = "Decorator"; + SyntaxKind[SyntaxKind["PropertySignature"] = 145] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 146] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 147] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 148] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 149] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 150] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 151] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 152] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 153] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 154] = "IndexSignature"; + SyntaxKind[SyntaxKind["TypePredicate"] = 155] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 156] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 157] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 158] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 159] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 160] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 161] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 162] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 163] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 164] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 165] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 166] = "ThisType"; + SyntaxKind[SyntaxKind["LiteralType"] = 167] = "LiteralType"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 168] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 169] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 170] = "BindingElement"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 171] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 172] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 173] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 174] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 175] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 176] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 177] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 178] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 179] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 180] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 181] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 182] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 183] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 184] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 185] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 186] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 187] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 188] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 189] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 190] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 191] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElementExpression"] = 192] = "SpreadElementExpression"; + SyntaxKind[SyntaxKind["ClassExpression"] = 193] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 194] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 195] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 196] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 197] = "NonNullExpression"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 198] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 199] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["Block"] = 200] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 201] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 202] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 203] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 204] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 205] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 206] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 207] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 208] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 209] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 210] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 211] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 212] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 213] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 214] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 215] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 216] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 217] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 218] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 219] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 220] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 221] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 222] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 223] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 224] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 225] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 226] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 227] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 228] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 229] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 230] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 231] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 232] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 233] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 234] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 235] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 236] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 237] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 238] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 239] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 240] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 241] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["JsxElement"] = 242] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 243] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 244] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 245] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 246] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 247] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 248] = "JsxExpression"; + SyntaxKind[SyntaxKind["CaseClause"] = 249] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 250] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 251] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 252] = "CatchClause"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 253] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 254] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["EnumMember"] = 255] = "EnumMember"; + SyntaxKind[SyntaxKind["SourceFile"] = 256] = "SourceFile"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 257] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 258] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 259] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 260] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 261] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 262] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 263] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 264] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 265] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 266] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 267] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 268] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 269] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 270] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 271] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 272] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 273] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 274] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 275] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 276] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 277] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 278] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 279] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 280] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 281] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocLiteralType"] = 282] = "JSDocLiteralType"; + SyntaxKind[SyntaxKind["JSDocNullKeyword"] = 283] = "JSDocNullKeyword"; + SyntaxKind[SyntaxKind["JSDocUndefinedKeyword"] = 284] = "JSDocUndefinedKeyword"; + SyntaxKind[SyntaxKind["JSDocNeverKeyword"] = 285] = "JSDocNeverKeyword"; + SyntaxKind[SyntaxKind["SyntaxList"] = 286] = "SyntaxList"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 287] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 288] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["Count"] = 289] = "Count"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 57] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 69] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 58] = "FirstCompoundAssignment"; + SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 69] = "LastCompoundAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 71] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 106] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 71] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 139] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 107] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 115] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 155] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 167] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstPunctuation"] = 16] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 69] = "LastPunctuation"; + SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; + SyntaxKind[SyntaxKind["LastToken"] = 139] = "LastToken"; + SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; + SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; + SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; + SyntaxKind[SyntaxKind["LastLiteralToken"] = 12] = "LastLiteralToken"; + SyntaxKind[SyntaxKind["FirstTemplateToken"] = 12] = "FirstTemplateToken"; + SyntaxKind[SyntaxKind["LastTemplateToken"] = 15] = "LastTemplateToken"; + SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 26] = "FirstBinaryOperator"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 69] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstNode"] = 140] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 257] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 282] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 273] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 285] = "LastJSDocTagNode"; + })(ts.SyntaxKind || (ts.SyntaxKind = {})); + var SyntaxKind = ts.SyntaxKind; + (function (NodeFlags) { + NodeFlags[NodeFlags["None"] = 0] = "None"; + NodeFlags[NodeFlags["Let"] = 1] = "Let"; + NodeFlags[NodeFlags["Const"] = 2] = "Const"; + NodeFlags[NodeFlags["NestedNamespace"] = 4] = "NestedNamespace"; + NodeFlags[NodeFlags["Synthesized"] = 8] = "Synthesized"; + NodeFlags[NodeFlags["Namespace"] = 16] = "Namespace"; + NodeFlags[NodeFlags["ExportContext"] = 32] = "ExportContext"; + NodeFlags[NodeFlags["ContainsThis"] = 64] = "ContainsThis"; + NodeFlags[NodeFlags["HasImplicitReturn"] = 128] = "HasImplicitReturn"; + NodeFlags[NodeFlags["HasExplicitReturn"] = 256] = "HasExplicitReturn"; + NodeFlags[NodeFlags["GlobalAugmentation"] = 512] = "GlobalAugmentation"; + NodeFlags[NodeFlags["HasClassExtends"] = 1024] = "HasClassExtends"; + NodeFlags[NodeFlags["HasDecorators"] = 2048] = "HasDecorators"; + NodeFlags[NodeFlags["HasParamDecorators"] = 4096] = "HasParamDecorators"; + NodeFlags[NodeFlags["HasAsyncFunctions"] = 8192] = "HasAsyncFunctions"; + NodeFlags[NodeFlags["HasJsxSpreadAttributes"] = 16384] = "HasJsxSpreadAttributes"; + NodeFlags[NodeFlags["DisallowInContext"] = 32768] = "DisallowInContext"; + NodeFlags[NodeFlags["YieldContext"] = 65536] = "YieldContext"; + NodeFlags[NodeFlags["DecoratorContext"] = 131072] = "DecoratorContext"; + NodeFlags[NodeFlags["AwaitContext"] = 262144] = "AwaitContext"; + NodeFlags[NodeFlags["ThisNodeHasError"] = 524288] = "ThisNodeHasError"; + NodeFlags[NodeFlags["JavaScriptFile"] = 1048576] = "JavaScriptFile"; + NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 2097152] = "ThisNodeOrAnySubNodesHasError"; + NodeFlags[NodeFlags["HasAggregatedChildData"] = 4194304] = "HasAggregatedChildData"; + NodeFlags[NodeFlags["BlockScoped"] = 3] = "BlockScoped"; + NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 384] = "ReachabilityCheckFlags"; + NodeFlags[NodeFlags["EmitHelperFlags"] = 31744] = "EmitHelperFlags"; + NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 32128] = "ReachabilityAndEmitFlags"; + NodeFlags[NodeFlags["ContextFlags"] = 1540096] = "ContextFlags"; + NodeFlags[NodeFlags["TypeExcludesFlags"] = 327680] = "TypeExcludesFlags"; + })(ts.NodeFlags || (ts.NodeFlags = {})); + var NodeFlags = ts.NodeFlags; + (function (ModifierFlags) { + ModifierFlags[ModifierFlags["None"] = 0] = "None"; + ModifierFlags[ModifierFlags["Export"] = 1] = "Export"; + ModifierFlags[ModifierFlags["Ambient"] = 2] = "Ambient"; + ModifierFlags[ModifierFlags["Public"] = 4] = "Public"; + ModifierFlags[ModifierFlags["Private"] = 8] = "Private"; + ModifierFlags[ModifierFlags["Protected"] = 16] = "Protected"; + ModifierFlags[ModifierFlags["Static"] = 32] = "Static"; + ModifierFlags[ModifierFlags["Readonly"] = 64] = "Readonly"; + ModifierFlags[ModifierFlags["Abstract"] = 128] = "Abstract"; + ModifierFlags[ModifierFlags["Async"] = 256] = "Async"; + ModifierFlags[ModifierFlags["Default"] = 512] = "Default"; + ModifierFlags[ModifierFlags["Const"] = 2048] = "Const"; + ModifierFlags[ModifierFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; + ModifierFlags[ModifierFlags["AccessibilityModifier"] = 28] = "AccessibilityModifier"; + ModifierFlags[ModifierFlags["ParameterPropertyModifier"] = 92] = "ParameterPropertyModifier"; + ModifierFlags[ModifierFlags["NonPublicAccessibilityModifier"] = 24] = "NonPublicAccessibilityModifier"; + ModifierFlags[ModifierFlags["TypeScriptModifier"] = 2270] = "TypeScriptModifier"; + })(ts.ModifierFlags || (ts.ModifierFlags = {})); + var ModifierFlags = ts.ModifierFlags; + (function (JsxFlags) { + JsxFlags[JsxFlags["None"] = 0] = "None"; + JsxFlags[JsxFlags["IntrinsicNamedElement"] = 1] = "IntrinsicNamedElement"; + JsxFlags[JsxFlags["IntrinsicIndexedElement"] = 2] = "IntrinsicIndexedElement"; + JsxFlags[JsxFlags["IntrinsicElement"] = 3] = "IntrinsicElement"; + })(ts.JsxFlags || (ts.JsxFlags = {})); + var JsxFlags = ts.JsxFlags; + (function (RelationComparisonResult) { + RelationComparisonResult[RelationComparisonResult["Succeeded"] = 1] = "Succeeded"; + RelationComparisonResult[RelationComparisonResult["Failed"] = 2] = "Failed"; + RelationComparisonResult[RelationComparisonResult["FailedAndReported"] = 3] = "FailedAndReported"; + })(ts.RelationComparisonResult || (ts.RelationComparisonResult = {})); + var RelationComparisonResult = ts.RelationComparisonResult; + (function (GeneratedIdentifierKind) { + GeneratedIdentifierKind[GeneratedIdentifierKind["None"] = 0] = "None"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Auto"] = 1] = "Auto"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Loop"] = 2] = "Loop"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Unique"] = 3] = "Unique"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Node"] = 4] = "Node"; + })(ts.GeneratedIdentifierKind || (ts.GeneratedIdentifierKind = {})); + var GeneratedIdentifierKind = ts.GeneratedIdentifierKind; + (function (FlowFlags) { + FlowFlags[FlowFlags["Unreachable"] = 1] = "Unreachable"; + FlowFlags[FlowFlags["Start"] = 2] = "Start"; + FlowFlags[FlowFlags["BranchLabel"] = 4] = "BranchLabel"; + FlowFlags[FlowFlags["LoopLabel"] = 8] = "LoopLabel"; + FlowFlags[FlowFlags["Assignment"] = 16] = "Assignment"; + FlowFlags[FlowFlags["TrueCondition"] = 32] = "TrueCondition"; + FlowFlags[FlowFlags["FalseCondition"] = 64] = "FalseCondition"; + FlowFlags[FlowFlags["SwitchClause"] = 128] = "SwitchClause"; + FlowFlags[FlowFlags["ArrayMutation"] = 256] = "ArrayMutation"; + FlowFlags[FlowFlags["Referenced"] = 512] = "Referenced"; + FlowFlags[FlowFlags["Shared"] = 1024] = "Shared"; + FlowFlags[FlowFlags["Label"] = 12] = "Label"; + FlowFlags[FlowFlags["Condition"] = 96] = "Condition"; + })(ts.FlowFlags || (ts.FlowFlags = {})); + var FlowFlags = ts.FlowFlags; var OperationCanceledException = (function () { function OperationCanceledException() { } @@ -32,6 +444,38 @@ var ts; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; })(ts.ExitStatus || (ts.ExitStatus = {})); var ExitStatus = ts.ExitStatus; + (function (TypeFormatFlags) { + TypeFormatFlags[TypeFormatFlags["None"] = 0] = "None"; + TypeFormatFlags[TypeFormatFlags["WriteArrayAsGenericType"] = 1] = "WriteArrayAsGenericType"; + TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 2] = "UseTypeOfFunction"; + TypeFormatFlags[TypeFormatFlags["NoTruncation"] = 4] = "NoTruncation"; + TypeFormatFlags[TypeFormatFlags["WriteArrowStyleSignature"] = 8] = "WriteArrowStyleSignature"; + TypeFormatFlags[TypeFormatFlags["WriteOwnNameForAnyLike"] = 16] = "WriteOwnNameForAnyLike"; + TypeFormatFlags[TypeFormatFlags["WriteTypeArgumentsOfSignature"] = 32] = "WriteTypeArgumentsOfSignature"; + TypeFormatFlags[TypeFormatFlags["InElementType"] = 64] = "InElementType"; + TypeFormatFlags[TypeFormatFlags["UseFullyQualifiedType"] = 128] = "UseFullyQualifiedType"; + TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 256] = "InFirstTypeArgument"; + TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 512] = "InTypeAlias"; + TypeFormatFlags[TypeFormatFlags["UseTypeAliasValue"] = 1024] = "UseTypeAliasValue"; + })(ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); + var TypeFormatFlags = ts.TypeFormatFlags; + (function (SymbolFormatFlags) { + SymbolFormatFlags[SymbolFormatFlags["None"] = 0] = "None"; + SymbolFormatFlags[SymbolFormatFlags["WriteTypeParametersOrArguments"] = 1] = "WriteTypeParametersOrArguments"; + SymbolFormatFlags[SymbolFormatFlags["UseOnlyExternalAliasing"] = 2] = "UseOnlyExternalAliasing"; + })(ts.SymbolFormatFlags || (ts.SymbolFormatFlags = {})); + var SymbolFormatFlags = ts.SymbolFormatFlags; + (function (SymbolAccessibility) { + SymbolAccessibility[SymbolAccessibility["Accessible"] = 0] = "Accessible"; + SymbolAccessibility[SymbolAccessibility["NotAccessible"] = 1] = "NotAccessible"; + SymbolAccessibility[SymbolAccessibility["CannotBeNamed"] = 2] = "CannotBeNamed"; + })(ts.SymbolAccessibility || (ts.SymbolAccessibility = {})); + var SymbolAccessibility = ts.SymbolAccessibility; + (function (TypePredicateKind) { + TypePredicateKind[TypePredicateKind["This"] = 0] = "This"; + TypePredicateKind[TypePredicateKind["Identifier"] = 1] = "Identifier"; + })(ts.TypePredicateKind || (ts.TypePredicateKind = {})); + var TypePredicateKind = ts.TypePredicateKind; (function (TypeReferenceSerializationKind) { TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; @@ -46,6 +490,166 @@ var ts; TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 10] = "ObjectType"; })(ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); var TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind; + (function (SymbolFlags) { + SymbolFlags[SymbolFlags["None"] = 0] = "None"; + SymbolFlags[SymbolFlags["FunctionScopedVariable"] = 1] = "FunctionScopedVariable"; + SymbolFlags[SymbolFlags["BlockScopedVariable"] = 2] = "BlockScopedVariable"; + SymbolFlags[SymbolFlags["Property"] = 4] = "Property"; + SymbolFlags[SymbolFlags["EnumMember"] = 8] = "EnumMember"; + SymbolFlags[SymbolFlags["Function"] = 16] = "Function"; + SymbolFlags[SymbolFlags["Class"] = 32] = "Class"; + SymbolFlags[SymbolFlags["Interface"] = 64] = "Interface"; + SymbolFlags[SymbolFlags["ConstEnum"] = 128] = "ConstEnum"; + SymbolFlags[SymbolFlags["RegularEnum"] = 256] = "RegularEnum"; + SymbolFlags[SymbolFlags["ValueModule"] = 512] = "ValueModule"; + SymbolFlags[SymbolFlags["NamespaceModule"] = 1024] = "NamespaceModule"; + SymbolFlags[SymbolFlags["TypeLiteral"] = 2048] = "TypeLiteral"; + SymbolFlags[SymbolFlags["ObjectLiteral"] = 4096] = "ObjectLiteral"; + SymbolFlags[SymbolFlags["Method"] = 8192] = "Method"; + SymbolFlags[SymbolFlags["Constructor"] = 16384] = "Constructor"; + SymbolFlags[SymbolFlags["GetAccessor"] = 32768] = "GetAccessor"; + SymbolFlags[SymbolFlags["SetAccessor"] = 65536] = "SetAccessor"; + SymbolFlags[SymbolFlags["Signature"] = 131072] = "Signature"; + SymbolFlags[SymbolFlags["TypeParameter"] = 262144] = "TypeParameter"; + SymbolFlags[SymbolFlags["TypeAlias"] = 524288] = "TypeAlias"; + SymbolFlags[SymbolFlags["ExportValue"] = 1048576] = "ExportValue"; + SymbolFlags[SymbolFlags["ExportType"] = 2097152] = "ExportType"; + SymbolFlags[SymbolFlags["ExportNamespace"] = 4194304] = "ExportNamespace"; + SymbolFlags[SymbolFlags["Alias"] = 8388608] = "Alias"; + SymbolFlags[SymbolFlags["Instantiated"] = 16777216] = "Instantiated"; + SymbolFlags[SymbolFlags["Merged"] = 33554432] = "Merged"; + SymbolFlags[SymbolFlags["Transient"] = 67108864] = "Transient"; + SymbolFlags[SymbolFlags["Prototype"] = 134217728] = "Prototype"; + SymbolFlags[SymbolFlags["SyntheticProperty"] = 268435456] = "SyntheticProperty"; + SymbolFlags[SymbolFlags["Optional"] = 536870912] = "Optional"; + SymbolFlags[SymbolFlags["ExportStar"] = 1073741824] = "ExportStar"; + SymbolFlags[SymbolFlags["Enum"] = 384] = "Enum"; + SymbolFlags[SymbolFlags["Variable"] = 3] = "Variable"; + SymbolFlags[SymbolFlags["Value"] = 107455] = "Value"; + SymbolFlags[SymbolFlags["Type"] = 793064] = "Type"; + SymbolFlags[SymbolFlags["Namespace"] = 1920] = "Namespace"; + SymbolFlags[SymbolFlags["Module"] = 1536] = "Module"; + SymbolFlags[SymbolFlags["Accessor"] = 98304] = "Accessor"; + SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 107454] = "FunctionScopedVariableExcludes"; + SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 107455] = "BlockScopedVariableExcludes"; + SymbolFlags[SymbolFlags["ParameterExcludes"] = 107455] = "ParameterExcludes"; + SymbolFlags[SymbolFlags["PropertyExcludes"] = 0] = "PropertyExcludes"; + SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 900095] = "EnumMemberExcludes"; + SymbolFlags[SymbolFlags["FunctionExcludes"] = 106927] = "FunctionExcludes"; + SymbolFlags[SymbolFlags["ClassExcludes"] = 899519] = "ClassExcludes"; + SymbolFlags[SymbolFlags["InterfaceExcludes"] = 792968] = "InterfaceExcludes"; + SymbolFlags[SymbolFlags["RegularEnumExcludes"] = 899327] = "RegularEnumExcludes"; + SymbolFlags[SymbolFlags["ConstEnumExcludes"] = 899967] = "ConstEnumExcludes"; + SymbolFlags[SymbolFlags["ValueModuleExcludes"] = 106639] = "ValueModuleExcludes"; + SymbolFlags[SymbolFlags["NamespaceModuleExcludes"] = 0] = "NamespaceModuleExcludes"; + SymbolFlags[SymbolFlags["MethodExcludes"] = 99263] = "MethodExcludes"; + SymbolFlags[SymbolFlags["GetAccessorExcludes"] = 41919] = "GetAccessorExcludes"; + SymbolFlags[SymbolFlags["SetAccessorExcludes"] = 74687] = "SetAccessorExcludes"; + SymbolFlags[SymbolFlags["TypeParameterExcludes"] = 530920] = "TypeParameterExcludes"; + SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 793064] = "TypeAliasExcludes"; + SymbolFlags[SymbolFlags["AliasExcludes"] = 8388608] = "AliasExcludes"; + SymbolFlags[SymbolFlags["ModuleMember"] = 8914931] = "ModuleMember"; + SymbolFlags[SymbolFlags["ExportHasLocal"] = 944] = "ExportHasLocal"; + SymbolFlags[SymbolFlags["HasExports"] = 1952] = "HasExports"; + SymbolFlags[SymbolFlags["HasMembers"] = 6240] = "HasMembers"; + SymbolFlags[SymbolFlags["BlockScoped"] = 418] = "BlockScoped"; + SymbolFlags[SymbolFlags["PropertyOrAccessor"] = 98308] = "PropertyOrAccessor"; + SymbolFlags[SymbolFlags["Export"] = 7340032] = "Export"; + SymbolFlags[SymbolFlags["ClassMember"] = 106500] = "ClassMember"; + SymbolFlags[SymbolFlags["Classifiable"] = 788448] = "Classifiable"; + })(ts.SymbolFlags || (ts.SymbolFlags = {})); + var SymbolFlags = ts.SymbolFlags; + (function (NodeCheckFlags) { + NodeCheckFlags[NodeCheckFlags["TypeChecked"] = 1] = "TypeChecked"; + NodeCheckFlags[NodeCheckFlags["LexicalThis"] = 2] = "LexicalThis"; + NodeCheckFlags[NodeCheckFlags["CaptureThis"] = 4] = "CaptureThis"; + NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 256] = "SuperInstance"; + NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 512] = "SuperStatic"; + NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 1024] = "ContextChecked"; + NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuper"] = 2048] = "AsyncMethodWithSuper"; + NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuperBinding"] = 4096] = "AsyncMethodWithSuperBinding"; + NodeCheckFlags[NodeCheckFlags["CaptureArguments"] = 8192] = "CaptureArguments"; + NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 16384] = "EnumValuesComputed"; + NodeCheckFlags[NodeCheckFlags["LexicalModuleMergesWithClass"] = 32768] = "LexicalModuleMergesWithClass"; + NodeCheckFlags[NodeCheckFlags["LoopWithCapturedBlockScopedBinding"] = 65536] = "LoopWithCapturedBlockScopedBinding"; + NodeCheckFlags[NodeCheckFlags["CapturedBlockScopedBinding"] = 131072] = "CapturedBlockScopedBinding"; + NodeCheckFlags[NodeCheckFlags["BlockScopedBindingInLoop"] = 262144] = "BlockScopedBindingInLoop"; + NodeCheckFlags[NodeCheckFlags["ClassWithBodyScopedClassBinding"] = 524288] = "ClassWithBodyScopedClassBinding"; + NodeCheckFlags[NodeCheckFlags["BodyScopedClassBinding"] = 1048576] = "BodyScopedClassBinding"; + NodeCheckFlags[NodeCheckFlags["NeedsLoopOutParameter"] = 2097152] = "NeedsLoopOutParameter"; + NodeCheckFlags[NodeCheckFlags["AssignmentsMarked"] = 4194304] = "AssignmentsMarked"; + NodeCheckFlags[NodeCheckFlags["ClassWithConstructorReference"] = 8388608] = "ClassWithConstructorReference"; + NodeCheckFlags[NodeCheckFlags["ConstructorReferenceInClass"] = 16777216] = "ConstructorReferenceInClass"; + })(ts.NodeCheckFlags || (ts.NodeCheckFlags = {})); + var NodeCheckFlags = ts.NodeCheckFlags; + (function (TypeFlags) { + TypeFlags[TypeFlags["Any"] = 1] = "Any"; + TypeFlags[TypeFlags["String"] = 2] = "String"; + TypeFlags[TypeFlags["Number"] = 4] = "Number"; + TypeFlags[TypeFlags["Boolean"] = 8] = "Boolean"; + TypeFlags[TypeFlags["Enum"] = 16] = "Enum"; + TypeFlags[TypeFlags["StringLiteral"] = 32] = "StringLiteral"; + TypeFlags[TypeFlags["NumberLiteral"] = 64] = "NumberLiteral"; + TypeFlags[TypeFlags["BooleanLiteral"] = 128] = "BooleanLiteral"; + TypeFlags[TypeFlags["EnumLiteral"] = 256] = "EnumLiteral"; + TypeFlags[TypeFlags["ESSymbol"] = 512] = "ESSymbol"; + TypeFlags[TypeFlags["Void"] = 1024] = "Void"; + TypeFlags[TypeFlags["Undefined"] = 2048] = "Undefined"; + TypeFlags[TypeFlags["Null"] = 4096] = "Null"; + TypeFlags[TypeFlags["Never"] = 8192] = "Never"; + TypeFlags[TypeFlags["TypeParameter"] = 16384] = "TypeParameter"; + TypeFlags[TypeFlags["Class"] = 32768] = "Class"; + TypeFlags[TypeFlags["Interface"] = 65536] = "Interface"; + TypeFlags[TypeFlags["Reference"] = 131072] = "Reference"; + TypeFlags[TypeFlags["Tuple"] = 262144] = "Tuple"; + TypeFlags[TypeFlags["Union"] = 524288] = "Union"; + TypeFlags[TypeFlags["Intersection"] = 1048576] = "Intersection"; + TypeFlags[TypeFlags["Anonymous"] = 2097152] = "Anonymous"; + TypeFlags[TypeFlags["Instantiated"] = 4194304] = "Instantiated"; + TypeFlags[TypeFlags["ObjectLiteral"] = 8388608] = "ObjectLiteral"; + TypeFlags[TypeFlags["FreshLiteral"] = 16777216] = "FreshLiteral"; + TypeFlags[TypeFlags["ContainsWideningType"] = 33554432] = "ContainsWideningType"; + TypeFlags[TypeFlags["ContainsObjectLiteral"] = 67108864] = "ContainsObjectLiteral"; + TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 134217728] = "ContainsAnyFunctionType"; + TypeFlags[TypeFlags["Nullable"] = 6144] = "Nullable"; + TypeFlags[TypeFlags["Literal"] = 480] = "Literal"; + TypeFlags[TypeFlags["StringOrNumberLiteral"] = 96] = "StringOrNumberLiteral"; + TypeFlags[TypeFlags["DefinitelyFalsy"] = 7392] = "DefinitelyFalsy"; + TypeFlags[TypeFlags["PossiblyFalsy"] = 7406] = "PossiblyFalsy"; + TypeFlags[TypeFlags["Intrinsic"] = 16015] = "Intrinsic"; + TypeFlags[TypeFlags["Primitive"] = 8190] = "Primitive"; + TypeFlags[TypeFlags["StringLike"] = 34] = "StringLike"; + TypeFlags[TypeFlags["NumberLike"] = 340] = "NumberLike"; + TypeFlags[TypeFlags["BooleanLike"] = 136] = "BooleanLike"; + TypeFlags[TypeFlags["EnumLike"] = 272] = "EnumLike"; + TypeFlags[TypeFlags["ObjectType"] = 2588672] = "ObjectType"; + TypeFlags[TypeFlags["UnionOrIntersection"] = 1572864] = "UnionOrIntersection"; + TypeFlags[TypeFlags["StructuredType"] = 4161536] = "StructuredType"; + TypeFlags[TypeFlags["StructuredOrTypeParameter"] = 4177920] = "StructuredOrTypeParameter"; + TypeFlags[TypeFlags["Narrowable"] = 4178943] = "Narrowable"; + TypeFlags[TypeFlags["NotUnionOrUnit"] = 2589185] = "NotUnionOrUnit"; + TypeFlags[TypeFlags["RequiresWidening"] = 100663296] = "RequiresWidening"; + TypeFlags[TypeFlags["PropagatingFlags"] = 234881024] = "PropagatingFlags"; + })(ts.TypeFlags || (ts.TypeFlags = {})); + var TypeFlags = ts.TypeFlags; + (function (SignatureKind) { + SignatureKind[SignatureKind["Call"] = 0] = "Call"; + SignatureKind[SignatureKind["Construct"] = 1] = "Construct"; + })(ts.SignatureKind || (ts.SignatureKind = {})); + var SignatureKind = ts.SignatureKind; + (function (IndexKind) { + IndexKind[IndexKind["String"] = 0] = "String"; + IndexKind[IndexKind["Number"] = 1] = "Number"; + })(ts.IndexKind || (ts.IndexKind = {})); + var IndexKind = ts.IndexKind; + (function (SpecialPropertyAssignmentKind) { + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["None"] = 0] = "None"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ExportsProperty"] = 1] = "ExportsProperty"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ModuleExports"] = 2] = "ModuleExports"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["PrototypeProperty"] = 3] = "PrototypeProperty"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ThisProperty"] = 4] = "ThisProperty"; + })(ts.SpecialPropertyAssignmentKind || (ts.SpecialPropertyAssignmentKind = {})); + var SpecialPropertyAssignmentKind = ts.SpecialPropertyAssignmentKind; (function (DiagnosticCategory) { DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; @@ -63,10 +667,267 @@ var ts; ModuleKind[ModuleKind["AMD"] = 2] = "AMD"; ModuleKind[ModuleKind["UMD"] = 3] = "UMD"; ModuleKind[ModuleKind["System"] = 4] = "System"; - ModuleKind[ModuleKind["ES6"] = 5] = "ES6"; ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015"; })(ts.ModuleKind || (ts.ModuleKind = {})); var ModuleKind = ts.ModuleKind; + (function (JsxEmit) { + JsxEmit[JsxEmit["None"] = 0] = "None"; + JsxEmit[JsxEmit["Preserve"] = 1] = "Preserve"; + JsxEmit[JsxEmit["React"] = 2] = "React"; + })(ts.JsxEmit || (ts.JsxEmit = {})); + var JsxEmit = ts.JsxEmit; + (function (NewLineKind) { + NewLineKind[NewLineKind["CarriageReturnLineFeed"] = 0] = "CarriageReturnLineFeed"; + NewLineKind[NewLineKind["LineFeed"] = 1] = "LineFeed"; + })(ts.NewLineKind || (ts.NewLineKind = {})); + var NewLineKind = ts.NewLineKind; + (function (ScriptKind) { + ScriptKind[ScriptKind["Unknown"] = 0] = "Unknown"; + ScriptKind[ScriptKind["JS"] = 1] = "JS"; + ScriptKind[ScriptKind["JSX"] = 2] = "JSX"; + ScriptKind[ScriptKind["TS"] = 3] = "TS"; + ScriptKind[ScriptKind["TSX"] = 4] = "TSX"; + })(ts.ScriptKind || (ts.ScriptKind = {})); + var ScriptKind = ts.ScriptKind; + (function (ScriptTarget) { + ScriptTarget[ScriptTarget["ES3"] = 0] = "ES3"; + ScriptTarget[ScriptTarget["ES5"] = 1] = "ES5"; + ScriptTarget[ScriptTarget["ES2015"] = 2] = "ES2015"; + ScriptTarget[ScriptTarget["ES2016"] = 3] = "ES2016"; + ScriptTarget[ScriptTarget["ES2017"] = 4] = "ES2017"; + ScriptTarget[ScriptTarget["Latest"] = 4] = "Latest"; + })(ts.ScriptTarget || (ts.ScriptTarget = {})); + var ScriptTarget = ts.ScriptTarget; + (function (LanguageVariant) { + LanguageVariant[LanguageVariant["Standard"] = 0] = "Standard"; + LanguageVariant[LanguageVariant["JSX"] = 1] = "JSX"; + })(ts.LanguageVariant || (ts.LanguageVariant = {})); + var LanguageVariant = ts.LanguageVariant; + (function (DiagnosticStyle) { + DiagnosticStyle[DiagnosticStyle["Simple"] = 0] = "Simple"; + DiagnosticStyle[DiagnosticStyle["Pretty"] = 1] = "Pretty"; + })(ts.DiagnosticStyle || (ts.DiagnosticStyle = {})); + var DiagnosticStyle = ts.DiagnosticStyle; + (function (WatchDirectoryFlags) { + WatchDirectoryFlags[WatchDirectoryFlags["None"] = 0] = "None"; + WatchDirectoryFlags[WatchDirectoryFlags["Recursive"] = 1] = "Recursive"; + })(ts.WatchDirectoryFlags || (ts.WatchDirectoryFlags = {})); + var WatchDirectoryFlags = ts.WatchDirectoryFlags; + (function (CharacterCodes) { + CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; + CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 127] = "maxAsciiCharacter"; + CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed"; + CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn"; + CharacterCodes[CharacterCodes["lineSeparator"] = 8232] = "lineSeparator"; + CharacterCodes[CharacterCodes["paragraphSeparator"] = 8233] = "paragraphSeparator"; + CharacterCodes[CharacterCodes["nextLine"] = 133] = "nextLine"; + CharacterCodes[CharacterCodes["space"] = 32] = "space"; + CharacterCodes[CharacterCodes["nonBreakingSpace"] = 160] = "nonBreakingSpace"; + CharacterCodes[CharacterCodes["enQuad"] = 8192] = "enQuad"; + CharacterCodes[CharacterCodes["emQuad"] = 8193] = "emQuad"; + CharacterCodes[CharacterCodes["enSpace"] = 8194] = "enSpace"; + CharacterCodes[CharacterCodes["emSpace"] = 8195] = "emSpace"; + CharacterCodes[CharacterCodes["threePerEmSpace"] = 8196] = "threePerEmSpace"; + CharacterCodes[CharacterCodes["fourPerEmSpace"] = 8197] = "fourPerEmSpace"; + CharacterCodes[CharacterCodes["sixPerEmSpace"] = 8198] = "sixPerEmSpace"; + CharacterCodes[CharacterCodes["figureSpace"] = 8199] = "figureSpace"; + CharacterCodes[CharacterCodes["punctuationSpace"] = 8200] = "punctuationSpace"; + CharacterCodes[CharacterCodes["thinSpace"] = 8201] = "thinSpace"; + CharacterCodes[CharacterCodes["hairSpace"] = 8202] = "hairSpace"; + CharacterCodes[CharacterCodes["zeroWidthSpace"] = 8203] = "zeroWidthSpace"; + CharacterCodes[CharacterCodes["narrowNoBreakSpace"] = 8239] = "narrowNoBreakSpace"; + CharacterCodes[CharacterCodes["ideographicSpace"] = 12288] = "ideographicSpace"; + CharacterCodes[CharacterCodes["mathematicalSpace"] = 8287] = "mathematicalSpace"; + CharacterCodes[CharacterCodes["ogham"] = 5760] = "ogham"; + CharacterCodes[CharacterCodes["_"] = 95] = "_"; + CharacterCodes[CharacterCodes["$"] = 36] = "$"; + CharacterCodes[CharacterCodes["_0"] = 48] = "_0"; + CharacterCodes[CharacterCodes["_1"] = 49] = "_1"; + CharacterCodes[CharacterCodes["_2"] = 50] = "_2"; + CharacterCodes[CharacterCodes["_3"] = 51] = "_3"; + CharacterCodes[CharacterCodes["_4"] = 52] = "_4"; + CharacterCodes[CharacterCodes["_5"] = 53] = "_5"; + CharacterCodes[CharacterCodes["_6"] = 54] = "_6"; + CharacterCodes[CharacterCodes["_7"] = 55] = "_7"; + CharacterCodes[CharacterCodes["_8"] = 56] = "_8"; + CharacterCodes[CharacterCodes["_9"] = 57] = "_9"; + CharacterCodes[CharacterCodes["a"] = 97] = "a"; + CharacterCodes[CharacterCodes["b"] = 98] = "b"; + CharacterCodes[CharacterCodes["c"] = 99] = "c"; + CharacterCodes[CharacterCodes["d"] = 100] = "d"; + CharacterCodes[CharacterCodes["e"] = 101] = "e"; + CharacterCodes[CharacterCodes["f"] = 102] = "f"; + CharacterCodes[CharacterCodes["g"] = 103] = "g"; + CharacterCodes[CharacterCodes["h"] = 104] = "h"; + CharacterCodes[CharacterCodes["i"] = 105] = "i"; + CharacterCodes[CharacterCodes["j"] = 106] = "j"; + CharacterCodes[CharacterCodes["k"] = 107] = "k"; + CharacterCodes[CharacterCodes["l"] = 108] = "l"; + CharacterCodes[CharacterCodes["m"] = 109] = "m"; + CharacterCodes[CharacterCodes["n"] = 110] = "n"; + CharacterCodes[CharacterCodes["o"] = 111] = "o"; + CharacterCodes[CharacterCodes["p"] = 112] = "p"; + CharacterCodes[CharacterCodes["q"] = 113] = "q"; + CharacterCodes[CharacterCodes["r"] = 114] = "r"; + CharacterCodes[CharacterCodes["s"] = 115] = "s"; + CharacterCodes[CharacterCodes["t"] = 116] = "t"; + CharacterCodes[CharacterCodes["u"] = 117] = "u"; + CharacterCodes[CharacterCodes["v"] = 118] = "v"; + CharacterCodes[CharacterCodes["w"] = 119] = "w"; + CharacterCodes[CharacterCodes["x"] = 120] = "x"; + CharacterCodes[CharacterCodes["y"] = 121] = "y"; + CharacterCodes[CharacterCodes["z"] = 122] = "z"; + CharacterCodes[CharacterCodes["A"] = 65] = "A"; + CharacterCodes[CharacterCodes["B"] = 66] = "B"; + CharacterCodes[CharacterCodes["C"] = 67] = "C"; + CharacterCodes[CharacterCodes["D"] = 68] = "D"; + CharacterCodes[CharacterCodes["E"] = 69] = "E"; + CharacterCodes[CharacterCodes["F"] = 70] = "F"; + CharacterCodes[CharacterCodes["G"] = 71] = "G"; + CharacterCodes[CharacterCodes["H"] = 72] = "H"; + CharacterCodes[CharacterCodes["I"] = 73] = "I"; + CharacterCodes[CharacterCodes["J"] = 74] = "J"; + CharacterCodes[CharacterCodes["K"] = 75] = "K"; + CharacterCodes[CharacterCodes["L"] = 76] = "L"; + CharacterCodes[CharacterCodes["M"] = 77] = "M"; + CharacterCodes[CharacterCodes["N"] = 78] = "N"; + CharacterCodes[CharacterCodes["O"] = 79] = "O"; + CharacterCodes[CharacterCodes["P"] = 80] = "P"; + CharacterCodes[CharacterCodes["Q"] = 81] = "Q"; + CharacterCodes[CharacterCodes["R"] = 82] = "R"; + CharacterCodes[CharacterCodes["S"] = 83] = "S"; + CharacterCodes[CharacterCodes["T"] = 84] = "T"; + CharacterCodes[CharacterCodes["U"] = 85] = "U"; + CharacterCodes[CharacterCodes["V"] = 86] = "V"; + CharacterCodes[CharacterCodes["W"] = 87] = "W"; + CharacterCodes[CharacterCodes["X"] = 88] = "X"; + CharacterCodes[CharacterCodes["Y"] = 89] = "Y"; + CharacterCodes[CharacterCodes["Z"] = 90] = "Z"; + CharacterCodes[CharacterCodes["ampersand"] = 38] = "ampersand"; + CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk"; + CharacterCodes[CharacterCodes["at"] = 64] = "at"; + CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash"; + CharacterCodes[CharacterCodes["backtick"] = 96] = "backtick"; + CharacterCodes[CharacterCodes["bar"] = 124] = "bar"; + CharacterCodes[CharacterCodes["caret"] = 94] = "caret"; + CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace"; + CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket"; + CharacterCodes[CharacterCodes["closeParen"] = 41] = "closeParen"; + CharacterCodes[CharacterCodes["colon"] = 58] = "colon"; + CharacterCodes[CharacterCodes["comma"] = 44] = "comma"; + CharacterCodes[CharacterCodes["dot"] = 46] = "dot"; + CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote"; + CharacterCodes[CharacterCodes["equals"] = 61] = "equals"; + CharacterCodes[CharacterCodes["exclamation"] = 33] = "exclamation"; + CharacterCodes[CharacterCodes["greaterThan"] = 62] = "greaterThan"; + CharacterCodes[CharacterCodes["hash"] = 35] = "hash"; + CharacterCodes[CharacterCodes["lessThan"] = 60] = "lessThan"; + CharacterCodes[CharacterCodes["minus"] = 45] = "minus"; + CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace"; + CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket"; + CharacterCodes[CharacterCodes["openParen"] = 40] = "openParen"; + CharacterCodes[CharacterCodes["percent"] = 37] = "percent"; + CharacterCodes[CharacterCodes["plus"] = 43] = "plus"; + CharacterCodes[CharacterCodes["question"] = 63] = "question"; + CharacterCodes[CharacterCodes["semicolon"] = 59] = "semicolon"; + CharacterCodes[CharacterCodes["singleQuote"] = 39] = "singleQuote"; + CharacterCodes[CharacterCodes["slash"] = 47] = "slash"; + CharacterCodes[CharacterCodes["tilde"] = 126] = "tilde"; + CharacterCodes[CharacterCodes["backspace"] = 8] = "backspace"; + CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed"; + CharacterCodes[CharacterCodes["byteOrderMark"] = 65279] = "byteOrderMark"; + CharacterCodes[CharacterCodes["tab"] = 9] = "tab"; + CharacterCodes[CharacterCodes["verticalTab"] = 11] = "verticalTab"; + })(ts.CharacterCodes || (ts.CharacterCodes = {})); + var CharacterCodes = ts.CharacterCodes; + (function (TransformFlags) { + TransformFlags[TransformFlags["None"] = 0] = "None"; + TransformFlags[TransformFlags["TypeScript"] = 1] = "TypeScript"; + TransformFlags[TransformFlags["ContainsTypeScript"] = 2] = "ContainsTypeScript"; + TransformFlags[TransformFlags["Jsx"] = 4] = "Jsx"; + TransformFlags[TransformFlags["ContainsJsx"] = 8] = "ContainsJsx"; + TransformFlags[TransformFlags["ES2017"] = 16] = "ES2017"; + TransformFlags[TransformFlags["ContainsES2017"] = 32] = "ContainsES2017"; + TransformFlags[TransformFlags["ES2016"] = 64] = "ES2016"; + TransformFlags[TransformFlags["ContainsES2016"] = 128] = "ContainsES2016"; + TransformFlags[TransformFlags["ES2015"] = 256] = "ES2015"; + TransformFlags[TransformFlags["ContainsES2015"] = 512] = "ContainsES2015"; + TransformFlags[TransformFlags["DestructuringAssignment"] = 1024] = "DestructuringAssignment"; + TransformFlags[TransformFlags["Generator"] = 2048] = "Generator"; + TransformFlags[TransformFlags["ContainsGenerator"] = 4096] = "ContainsGenerator"; + TransformFlags[TransformFlags["ContainsDecorators"] = 8192] = "ContainsDecorators"; + TransformFlags[TransformFlags["ContainsPropertyInitializer"] = 16384] = "ContainsPropertyInitializer"; + TransformFlags[TransformFlags["ContainsLexicalThis"] = 32768] = "ContainsLexicalThis"; + TransformFlags[TransformFlags["ContainsCapturedLexicalThis"] = 65536] = "ContainsCapturedLexicalThis"; + TransformFlags[TransformFlags["ContainsLexicalThisInComputedPropertyName"] = 131072] = "ContainsLexicalThisInComputedPropertyName"; + TransformFlags[TransformFlags["ContainsDefaultValueAssignments"] = 262144] = "ContainsDefaultValueAssignments"; + TransformFlags[TransformFlags["ContainsParameterPropertyAssignments"] = 524288] = "ContainsParameterPropertyAssignments"; + TransformFlags[TransformFlags["ContainsSpreadElementExpression"] = 1048576] = "ContainsSpreadElementExpression"; + TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 2097152] = "ContainsComputedPropertyName"; + TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 4194304] = "ContainsBlockScopedBinding"; + TransformFlags[TransformFlags["ContainsBindingPattern"] = 8388608] = "ContainsBindingPattern"; + TransformFlags[TransformFlags["ContainsYield"] = 16777216] = "ContainsYield"; + TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 33554432] = "ContainsHoistedDeclarationOrCompletion"; + TransformFlags[TransformFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; + TransformFlags[TransformFlags["AssertTypeScript"] = 3] = "AssertTypeScript"; + TransformFlags[TransformFlags["AssertJsx"] = 12] = "AssertJsx"; + TransformFlags[TransformFlags["AssertES2017"] = 48] = "AssertES2017"; + TransformFlags[TransformFlags["AssertES2016"] = 192] = "AssertES2016"; + TransformFlags[TransformFlags["AssertES2015"] = 768] = "AssertES2015"; + TransformFlags[TransformFlags["AssertGenerator"] = 6144] = "AssertGenerator"; + TransformFlags[TransformFlags["NodeExcludes"] = 536874325] = "NodeExcludes"; + TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 592227669] = "ArrowFunctionExcludes"; + TransformFlags[TransformFlags["FunctionExcludes"] = 592293205] = "FunctionExcludes"; + TransformFlags[TransformFlags["ConstructorExcludes"] = 591760725] = "ConstructorExcludes"; + TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 591760725] = "MethodOrAccessorExcludes"; + TransformFlags[TransformFlags["ClassExcludes"] = 539749717] = "ClassExcludes"; + TransformFlags[TransformFlags["ModuleExcludes"] = 574729557] = "ModuleExcludes"; + TransformFlags[TransformFlags["TypeExcludes"] = -3] = "TypeExcludes"; + TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 539110741] = "ObjectLiteralExcludes"; + TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 537922901] = "ArrayLiteralOrCallOrNewExcludes"; + TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 545262933] = "VariableDeclarationListExcludes"; + TransformFlags[TransformFlags["ParameterExcludes"] = 545262933] = "ParameterExcludes"; + TransformFlags[TransformFlags["TypeScriptClassSyntaxMask"] = 548864] = "TypeScriptClassSyntaxMask"; + TransformFlags[TransformFlags["ES2015FunctionSyntaxMask"] = 327680] = "ES2015FunctionSyntaxMask"; + })(ts.TransformFlags || (ts.TransformFlags = {})); + var TransformFlags = ts.TransformFlags; + (function (EmitFlags) { + EmitFlags[EmitFlags["EmitEmitHelpers"] = 1] = "EmitEmitHelpers"; + EmitFlags[EmitFlags["EmitExportStar"] = 2] = "EmitExportStar"; + EmitFlags[EmitFlags["EmitSuperHelper"] = 4] = "EmitSuperHelper"; + EmitFlags[EmitFlags["EmitAdvancedSuperHelper"] = 8] = "EmitAdvancedSuperHelper"; + EmitFlags[EmitFlags["UMDDefine"] = 16] = "UMDDefine"; + EmitFlags[EmitFlags["SingleLine"] = 32] = "SingleLine"; + EmitFlags[EmitFlags["AdviseOnEmitNode"] = 64] = "AdviseOnEmitNode"; + EmitFlags[EmitFlags["NoSubstitution"] = 128] = "NoSubstitution"; + EmitFlags[EmitFlags["CapturesThis"] = 256] = "CapturesThis"; + EmitFlags[EmitFlags["NoLeadingSourceMap"] = 512] = "NoLeadingSourceMap"; + EmitFlags[EmitFlags["NoTrailingSourceMap"] = 1024] = "NoTrailingSourceMap"; + EmitFlags[EmitFlags["NoSourceMap"] = 1536] = "NoSourceMap"; + EmitFlags[EmitFlags["NoNestedSourceMaps"] = 2048] = "NoNestedSourceMaps"; + EmitFlags[EmitFlags["NoTokenLeadingSourceMaps"] = 4096] = "NoTokenLeadingSourceMaps"; + EmitFlags[EmitFlags["NoTokenTrailingSourceMaps"] = 8192] = "NoTokenTrailingSourceMaps"; + EmitFlags[EmitFlags["NoTokenSourceMaps"] = 12288] = "NoTokenSourceMaps"; + EmitFlags[EmitFlags["NoLeadingComments"] = 16384] = "NoLeadingComments"; + EmitFlags[EmitFlags["NoTrailingComments"] = 32768] = "NoTrailingComments"; + EmitFlags[EmitFlags["NoComments"] = 49152] = "NoComments"; + EmitFlags[EmitFlags["NoNestedComments"] = 65536] = "NoNestedComments"; + EmitFlags[EmitFlags["ExportName"] = 131072] = "ExportName"; + EmitFlags[EmitFlags["LocalName"] = 262144] = "LocalName"; + EmitFlags[EmitFlags["Indented"] = 524288] = "Indented"; + EmitFlags[EmitFlags["NoIndentation"] = 1048576] = "NoIndentation"; + EmitFlags[EmitFlags["AsyncFunctionBody"] = 2097152] = "AsyncFunctionBody"; + EmitFlags[EmitFlags["ReuseTempVariableScope"] = 4194304] = "ReuseTempVariableScope"; + EmitFlags[EmitFlags["CustomPrologue"] = 8388608] = "CustomPrologue"; + })(ts.EmitFlags || (ts.EmitFlags = {})); + var EmitFlags = ts.EmitFlags; + (function (EmitContext) { + EmitContext[EmitContext["SourceFile"] = 0] = "SourceFile"; + EmitContext[EmitContext["Expression"] = 1] = "Expression"; + EmitContext[EmitContext["IdentifierName"] = 2] = "IdentifierName"; + EmitContext[EmitContext["Unspecified"] = 3] = "Unspecified"; + })(ts.EmitContext || (ts.EmitContext = {})); + var EmitContext = ts.EmitContext; })(ts || (ts = {})); var ts; (function (ts) { @@ -77,7 +938,7 @@ var ts; (function (performance) { var profilerEvent = typeof onProfilerEvent === "function" && onProfilerEvent.profiler === true ? onProfilerEvent - : function (markName) { }; + : function (_markName) { }; var enabled = false; var profilerStart = 0; var counts; @@ -129,7 +990,14 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + (function (Ternary) { + Ternary[Ternary["False"] = 0] = "False"; + Ternary[Ternary["Maybe"] = 1] = "Maybe"; + Ternary[Ternary["True"] = -1] = "True"; + })(ts.Ternary || (ts.Ternary = {})); + var Ternary = ts.Ternary; var createObject = Object.create; + ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; function createMap(template) { var map = createObject(null); map["__"] = undefined; @@ -150,7 +1018,7 @@ var ts; remove: remove, forEachValue: forEachValueInMap, getKeys: getKeys, - clear: clear + clear: clear, }; function forEachValueInMap(f) { for (var key in files) { @@ -192,6 +1060,12 @@ var ts; return getCanonicalFileName(nonCanonicalizedPath); } ts.toPath = toPath; + (function (Comparison) { + Comparison[Comparison["LessThan"] = -1] = "LessThan"; + Comparison[Comparison["EqualTo"] = 0] = "EqualTo"; + Comparison[Comparison["GreaterThan"] = 1] = "GreaterThan"; + })(ts.Comparison || (ts.Comparison = {})); + var Comparison = ts.Comparison; function forEach(array, callback) { if (array) { for (var i = 0, len = array.length; i < len; i++) { @@ -335,13 +1209,32 @@ var ts; if (array) { result = []; for (var i = 0; i < array.length; i++) { - var v = array[i]; - result.push(f(v, i)); + result.push(f(array[i], i)); } } return result; } ts.map = map; + function sameMap(array, f) { + var result; + if (array) { + for (var i = 0; i < array.length; i++) { + if (result) { + result.push(f(array[i], i)); + } + else { + var item = array[i]; + var mapped = f(item, i); + if (item !== mapped) { + result = array.slice(0, i); + result.push(mapped); + } + } + } + } + return result || array; + } + ts.sameMap = sameMap; function flatten(array) { var result; if (array) { @@ -442,6 +1335,18 @@ var ts; return result; } ts.mapObject = mapObject; + function some(array, predicate) { + if (array) { + for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { + var v = array_5[_i]; + if (!predicate || predicate(v)) { + return true; + } + } + } + return false; + } + ts.some = some; function concatenate(array1, array2) { if (!array2 || !array2.length) return array1; @@ -454,8 +1359,8 @@ var ts; var result; if (array) { result = []; - loop: for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { - var item = array_5[_i]; + loop: for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { + var item = array_6[_i]; for (var _a = 0, result_1 = result; _a < result_1.length; _a++) { var res = result_1[_a]; if (areEqual ? areEqual(res, item) : res === item) { @@ -488,8 +1393,8 @@ var ts; ts.compact = compact; function sum(array, prop) { var result = 0; - for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { - var v = array_6[_i]; + for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { + var v = array_7[_i]; result += v[prop]; } return result; @@ -708,8 +1613,8 @@ var ts; ts.equalOwnProperties = equalOwnProperties; function arrayToMap(array, makeKey, makeValue) { var result = createMap(); - for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { - var value = array_7[_i]; + for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { + var value = array_8[_i]; result[makeKey(value)] = makeValue ? makeValue(value) : value; } return result; @@ -810,7 +1715,7 @@ var ts; return function (t) { return compose(a(t)); }; } else { - return function (t) { return function (u) { return u; }; }; + return function (_) { return function (u) { return u; }; }; } } ts.chain = chain; @@ -841,7 +1746,7 @@ var ts; ts.compose = compose; function formatStringFromArgs(text, args, baseIndex) { baseIndex = baseIndex || 0; - return text.replace(/{(\d+)}/g, function (match, index) { return args[+index + baseIndex]; }); + return text.replace(/{(\d+)}/g, function (_match, index) { return args[+index + baseIndex]; }); } ts.localizedDiagnosticMessages = undefined; function getLocaleSpecificMessage(message) { @@ -866,11 +1771,11 @@ var ts; length: length, messageText: text, category: message.category, - code: message.code + code: message.code, }; } ts.createFileDiagnostic = createFileDiagnostic; - function formatMessage(dummy, message) { + function formatMessage(_dummy, message) { var text = getLocaleSpecificMessage(message); if (arguments.length > 2) { text = formatStringFromArgs(text, arguments, 2); @@ -933,7 +1838,7 @@ var ts; if (b === undefined) return 1; if (ignoreCase) { - if (String.prototype.localeCompare) { + if (ts.collator && String.prototype.localeCompare) { var result = a.localeCompare(b, undefined, { usage: "sort", sensitivity: "accent" }); return result < 0 ? -1 : result > 0 ? 1 : 0; } @@ -1086,7 +1991,7 @@ var ts; function getEmitModuleKind(compilerOptions) { return typeof compilerOptions.module === "number" ? compilerOptions.module : - getEmitScriptTarget(compilerOptions) === 2 ? ts.ModuleKind.ES6 : ts.ModuleKind.CommonJS; + getEmitScriptTarget(compilerOptions) >= 2 ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS; } ts.getEmitModuleKind = getEmitModuleKind; function hasZeroOrOneAsteriskCharacter(str) { @@ -1383,7 +2288,7 @@ var ts; function replaceWildcardCharacter(match, singleAsteriskRegexFragment) { return match === "*" ? singleAsteriskRegexFragment : match === "?" ? "[^/]" : "\\" + match; } - function getFileMatcherPatterns(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory) { + function getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory) { path = normalizePath(path); currentDirectory = normalizePath(currentDirectory); var absolutePath = combinePaths(currentDirectory, path); @@ -1398,7 +2303,7 @@ var ts; function matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, getFileSystemEntries) { path = normalizePath(path); currentDirectory = normalizePath(currentDirectory); - var patterns = getFileMatcherPatterns(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory); + var patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory); var regexFlag = useCaseSensitiveFileNames ? "" : "i"; var includeFileRegex = patterns.includeFilePattern && new RegExp(patterns.includeFilePattern, regexFlag); var includeDirectoryRegex = patterns.includeDirectoryPattern && new RegExp(patterns.includeDirectoryPattern, regexFlag); @@ -1508,6 +2413,14 @@ var ts; return false; } ts.isSupportedSourceFileName = isSupportedSourceFileName; + (function (ExtensionPriority) { + ExtensionPriority[ExtensionPriority["TypeScriptFiles"] = 0] = "TypeScriptFiles"; + ExtensionPriority[ExtensionPriority["DeclarationAndJavaScriptFiles"] = 2] = "DeclarationAndJavaScriptFiles"; + ExtensionPriority[ExtensionPriority["Limit"] = 5] = "Limit"; + ExtensionPriority[ExtensionPriority["Highest"] = 0] = "Highest"; + ExtensionPriority[ExtensionPriority["Lowest"] = 2] = "Lowest"; + })(ts.ExtensionPriority || (ts.ExtensionPriority = {})); + var ExtensionPriority = ts.ExtensionPriority; function getExtensionPriority(path, supportedExtensions) { for (var i = supportedExtensions.length - 1; i >= 0; i--) { if (fileExtensionIs(path, supportedExtensions[i])) { @@ -1571,10 +2484,10 @@ var ts; this.name = name; this.declarations = undefined; } - function Type(checker, flags) { + function Type(_checker, flags) { this.flags = flags; } - function Signature(checker) { + function Signature() { } function Node(kind, pos, end) { this.id = 0; @@ -1596,6 +2509,13 @@ var ts; getTypeConstructor: function () { return Type; }, getSignatureConstructor: function () { return Signature; } }; + (function (AssertionLevel) { + AssertionLevel[AssertionLevel["None"] = 0] = "None"; + AssertionLevel[AssertionLevel["Normal"] = 1] = "Normal"; + AssertionLevel[AssertionLevel["Aggressive"] = 2] = "Aggressive"; + AssertionLevel[AssertionLevel["VeryAggressive"] = 3] = "VeryAggressive"; + })(ts.AssertionLevel || (ts.AssertionLevel = {})); + var AssertionLevel = ts.AssertionLevel; var Debug; (function (Debug) { Debug.currentAssertionLevel = 0; @@ -1908,7 +2828,7 @@ var ts; } var platform = _os.platform(); var useCaseSensitiveFileNames = isFileSystemCaseSensitive(); - function readFile(fileName, encoding) { + function readFile(fileName, _encoding) { if (!fileExists(fileName)) { return undefined; } @@ -1980,6 +2900,11 @@ var ts; function readDirectory(path, extensions, excludes, includes) { return ts.matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, process.cwd(), getAccessibleFileSystemEntries); } + var FileSystemEntryKind; + (function (FileSystemEntryKind) { + FileSystemEntryKind[FileSystemEntryKind["File"] = 0] = "File"; + FileSystemEntryKind[FileSystemEntryKind["Directory"] = 1] = "Directory"; + })(FileSystemEntryKind || (FileSystemEntryKind = {})); function fileSystemEntryExists(path, entryKind) { try { var stat = _fs.statSync(path); @@ -2121,7 +3046,7 @@ var ts; args: ChakraHost.args, useCaseSensitiveFileNames: !!ChakraHost.useCaseSensitiveFileNames, write: ChakraHost.echo, - readFile: function (path, encoding) { + readFile: function (path, _encoding) { return ChakraHost.readFile(path); }, writeFile: function (path, data, writeByteOrderMark) { @@ -2137,9 +3062,9 @@ var ts; getExecutingFilePath: function () { return ChakraHost.executingFile; }, getCurrentDirectory: function () { return ChakraHost.currentDirectory; }, getDirectories: ChakraHost.getDirectories, - getEnvironmentVariable: ChakraHost.getEnvironmentVariable || (function (name) { return ""; }), + getEnvironmentVariable: ChakraHost.getEnvironmentVariable || (function () { return ""; }), readDirectory: function (path, extensions, excludes, includes) { - var pattern = ts.getFileMatcherPatterns(path, extensions, excludes, includes, !!ChakraHost.useCaseSensitiveFileNames, ChakraHost.currentDirectory); + var pattern = ts.getFileMatcherPatterns(path, excludes, includes, !!ChakraHost.useCaseSensitiveFileNames, ChakraHost.currentDirectory); return ChakraHost.readDirectory(path, extensions, pattern.basePaths, pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern); }, exit: ChakraHost.quit, @@ -2927,7 +3852,7 @@ var ts; Binding_element_0_implicitly_has_an_1_type: { code: 7031, category: ts.DiagnosticCategory.Error, key: "Binding_element_0_implicitly_has_an_1_type_7031", message: "Binding element '{0}' implicitly has an '{1}' type." }, Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation: { code: 7032, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation_7032", message: "Property '{0}' implicitly has type 'any', because its set accessor lacks a parameter type annotation." }, Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation: { code: 7033, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation_7033", message: "Property '{0}' implicitly has type 'any', because its get accessor lacks a return type annotation." }, - Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined: { code: 7034, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined_7034", message: "Variable '{0}' implicitly has type 'any' in some locations where its type cannot be determined." }, + Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined: { code: 7034, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined_7034", message: "Variable '{0}' implicitly has type '{1}' in some locations where its type cannot be determined." }, You_cannot_rename_this_element: { code: 8000, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_this_element_8000", message: "You cannot rename this element." }, You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", message: "You cannot rename elements that are defined in the standard TypeScript library." }, import_can_only_be_used_in_a_ts_file: { code: 8002, category: ts.DiagnosticCategory.Error, key: "import_can_only_be_used_in_a_ts_file_8002", message: "'import ... =' can only be used in a .ts file." }, @@ -2964,3022 +3889,12 @@ var ts; Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers" }, Implement_interface_on_reference: { code: 90005, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_reference_90005", message: "Implement interface on reference" }, Implement_interface_on_class: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_class_90006", message: "Implement interface on class" }, - Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" } + Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" }, }; })(ts || (ts = {})); var ts; (function (ts) { - function tokenIsIdentifierOrKeyword(token) { - return token >= 69; - } - ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; - var textToToken = ts.createMap({ - "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": 136, - "function": 87, - "get": 123, - "if": 88, - "implements": 106, - "import": 89, - "in": 90, - "instanceof": 91, - "interface": 107, - "is": 124, - "let": 108, - "module": 125, - "namespace": 126, - "never": 127, - "new": 92, - "null": 93, - "number": 130, - "package": 109, - "private": 110, - "protected": 111, - "public": 112, - "readonly": 128, - "require": 129, - "global": 137, - "return": 94, - "set": 131, - "static": 113, - "string": 132, - "super": 95, - "switch": 96, - "symbol": 133, - "this": 97, - "throw": 98, - "true": 99, - "try": 100, - "type": 134, - "typeof": 101, - "undefined": 135, - "var": 102, - "void": 103, - "while": 104, - "with": 105, - "yield": 114, - "async": 118, - "await": 119, - "of": 138, - "{": 15, - "}": 16, - "(": 17, - ")": 18, - "[": 19, - "]": 20, - ".": 21, - "...": 22, - ";": 23, - ",": 24, - "<": 25, - ">": 27, - "<=": 28, - ">=": 29, - "==": 30, - "!=": 31, - "===": 32, - "!==": 33, - "=>": 34, - "+": 35, - "-": 36, - "**": 38, - "*": 37, - "/": 39, - "%": 40, - "++": 41, - "--": 42, - "<<": 43, - ">": 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,]; - var unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 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, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 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, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 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, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 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, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; - var unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 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, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 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, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 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, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; - function lookupInUnicodeMap(code, map) { - if (code < map[0]) { - return false; - } - var lo = 0; - var hi = map.length; - var mid; - while (lo + 1 < hi) { - mid = lo + (hi - lo) / 2; - mid -= mid % 2; - if (map[mid] <= code && code <= map[mid + 1]) { - return true; - } - if (code < map[mid]) { - hi = mid; - } - else { - lo = mid + 2; - } - } - return false; - } - function isUnicodeIdentifierStart(code, languageVersion) { - return languageVersion >= 1 ? - lookupInUnicodeMap(code, unicodeES5IdentifierStart) : - lookupInUnicodeMap(code, unicodeES3IdentifierStart); - } - ts.isUnicodeIdentifierStart = isUnicodeIdentifierStart; - function isUnicodeIdentifierPart(code, languageVersion) { - return languageVersion >= 1 ? - lookupInUnicodeMap(code, unicodeES5IdentifierPart) : - lookupInUnicodeMap(code, unicodeES3IdentifierPart); - } - function makeReverseMap(source) { - var result = []; - for (var name_4 in source) { - result[source[name_4]] = name_4; - } - return result; - } - var tokenStrings = makeReverseMap(textToToken); - function tokenToString(t) { - return tokenStrings[t]; - } - ts.tokenToString = tokenToString; - function stringToToken(s) { - return textToToken[s]; - } - ts.stringToToken = stringToToken; - function computeLineStarts(text) { - var result = new Array(); - var pos = 0; - var lineStart = 0; - while (pos < text.length) { - var ch = text.charCodeAt(pos); - pos++; - switch (ch) { - case 13: - if (text.charCodeAt(pos) === 10) { - pos++; - } - case 10: - result.push(lineStart); - lineStart = pos; - break; - default: - if (ch > 127 && isLineBreak(ch)) { - result.push(lineStart); - lineStart = pos; - } - break; - } - } - result.push(lineStart); - return result; - } - ts.computeLineStarts = computeLineStarts; - function getPositionOfLineAndCharacter(sourceFile, line, character) { - return computePositionOfLineAndCharacter(getLineStarts(sourceFile), line, character); - } - ts.getPositionOfLineAndCharacter = getPositionOfLineAndCharacter; - function computePositionOfLineAndCharacter(lineStarts, line, character) { - ts.Debug.assert(line >= 0 && line < lineStarts.length); - return lineStarts[line] + character; - } - ts.computePositionOfLineAndCharacter = computePositionOfLineAndCharacter; - function getLineStarts(sourceFile) { - return sourceFile.lineMap || (sourceFile.lineMap = computeLineStarts(sourceFile.text)); - } - ts.getLineStarts = getLineStarts; - function computeLineAndCharacterOfPosition(lineStarts, position) { - var lineNumber = ts.binarySearch(lineStarts, position); - if (lineNumber < 0) { - lineNumber = ~lineNumber - 1; - ts.Debug.assert(lineNumber !== -1, "position cannot precede the beginning of the file"); - } - return { - line: lineNumber, - character: position - lineStarts[lineNumber] - }; - } - ts.computeLineAndCharacterOfPosition = computeLineAndCharacterOfPosition; - function getLineAndCharacterOfPosition(sourceFile, position) { - return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position); - } - ts.getLineAndCharacterOfPosition = getLineAndCharacterOfPosition; - var hasOwnProperty = Object.prototype.hasOwnProperty; - function isWhiteSpace(ch) { - return isWhiteSpaceSingleLine(ch) || isLineBreak(ch); - } - ts.isWhiteSpace = isWhiteSpace; - function isWhiteSpaceSingleLine(ch) { - return ch === 32 || - ch === 9 || - ch === 11 || - ch === 12 || - ch === 160 || - ch === 133 || - ch === 5760 || - ch >= 8192 && ch <= 8203 || - ch === 8239 || - ch === 8287 || - ch === 12288 || - ch === 65279; - } - ts.isWhiteSpaceSingleLine = isWhiteSpaceSingleLine; - function isLineBreak(ch) { - return ch === 10 || - ch === 13 || - ch === 8232 || - ch === 8233; - } - ts.isLineBreak = isLineBreak; - function isDigit(ch) { - return ch >= 48 && ch <= 57; - } - function isOctalDigit(ch) { - return ch >= 48 && ch <= 55; - } - ts.isOctalDigit = isOctalDigit; - function couldStartTrivia(text, pos) { - var ch = text.charCodeAt(pos); - switch (ch) { - case 13: - case 10: - case 9: - case 11: - case 12: - case 32: - case 47: - case 60: - case 61: - case 62: - return true; - case 35: - return pos === 0; - default: - return ch > 127; - } - } - ts.couldStartTrivia = couldStartTrivia; - function skipTrivia(text, pos, stopAfterLineBreak, stopAtComments) { - if (stopAtComments === void 0) { stopAtComments = false; } - if (ts.positionIsSynthesized(pos)) { - return pos; - } - while (true) { - var ch = text.charCodeAt(pos); - switch (ch) { - case 13: - if (text.charCodeAt(pos + 1) === 10) { - pos++; - } - case 10: - pos++; - if (stopAfterLineBreak) { - return pos; - } - continue; - case 9: - case 11: - case 12: - case 32: - pos++; - continue; - case 47: - if (stopAtComments) { - break; - } - if (text.charCodeAt(pos + 1) === 47) { - pos += 2; - while (pos < text.length) { - if (isLineBreak(text.charCodeAt(pos))) { - break; - } - pos++; - } - continue; - } - if (text.charCodeAt(pos + 1) === 42) { - pos += 2; - while (pos < text.length) { - if (text.charCodeAt(pos) === 42 && text.charCodeAt(pos + 1) === 47) { - pos += 2; - break; - } - pos++; - } - continue; - } - break; - case 60: - case 61: - case 62: - if (isConflictMarkerTrivia(text, pos)) { - pos = scanConflictMarkerTrivia(text, pos); - continue; - } - break; - case 35: - if (pos === 0 && isShebangTrivia(text, pos)) { - pos = scanShebangTrivia(text, pos); - continue; - } - break; - default: - if (ch > 127 && (isWhiteSpace(ch))) { - pos++; - continue; - } - break; - } - return pos; - } - } - ts.skipTrivia = skipTrivia; - var mergeConflictMarkerLength = "<<<<<<<".length; - function isConflictMarkerTrivia(text, pos) { - ts.Debug.assert(pos >= 0); - if (pos === 0 || isLineBreak(text.charCodeAt(pos - 1))) { - var ch = text.charCodeAt(pos); - if ((pos + mergeConflictMarkerLength) < text.length) { - for (var i = 0, n = mergeConflictMarkerLength; i < n; i++) { - if (text.charCodeAt(pos + i) !== ch) { - return false; - } - } - return ch === 61 || - text.charCodeAt(pos + mergeConflictMarkerLength) === 32; - } - } - return false; - } - function scanConflictMarkerTrivia(text, pos, error) { - if (error) { - error(ts.Diagnostics.Merge_conflict_marker_encountered, mergeConflictMarkerLength); - } - var ch = text.charCodeAt(pos); - var len = text.length; - if (ch === 60 || ch === 62) { - while (pos < len && !isLineBreak(text.charCodeAt(pos))) { - pos++; - } - } - else { - ts.Debug.assert(ch === 61); - while (pos < len) { - var ch_1 = text.charCodeAt(pos); - if (ch_1 === 62 && isConflictMarkerTrivia(text, pos)) { - break; - } - pos++; - } - } - return pos; - } - var shebangTriviaRegex = /^#!.*/; - function isShebangTrivia(text, pos) { - ts.Debug.assert(pos === 0); - return shebangTriviaRegex.test(text); - } - function scanShebangTrivia(text, pos) { - var shebang = shebangTriviaRegex.exec(text)[0]; - pos = pos + shebang.length; - return pos; - } - function iterateCommentRanges(reduce, text, pos, trailing, cb, state, initial) { - var pendingPos; - var pendingEnd; - var pendingKind; - var pendingHasTrailingNewLine; - var hasPendingCommentRange = false; - var collecting = trailing || pos === 0; - var accumulator = initial; - scan: while (pos >= 0 && pos < text.length) { - var ch = text.charCodeAt(pos); - switch (ch) { - case 13: - if (text.charCodeAt(pos + 1) === 10) { - pos++; - } - case 10: - pos++; - if (trailing) { - break scan; - } - collecting = true; - if (hasPendingCommentRange) { - pendingHasTrailingNewLine = true; - } - continue; - case 9: - case 11: - case 12: - case 32: - pos++; - continue; - case 47: - var nextChar = text.charCodeAt(pos + 1); - var hasTrailingNewLine = false; - if (nextChar === 47 || nextChar === 42) { - var kind = nextChar === 47 ? 2 : 3; - var startPos = pos; - pos += 2; - if (nextChar === 47) { - while (pos < text.length) { - if (isLineBreak(text.charCodeAt(pos))) { - hasTrailingNewLine = true; - break; - } - pos++; - } - } - else { - while (pos < text.length) { - if (text.charCodeAt(pos) === 42 && text.charCodeAt(pos + 1) === 47) { - pos += 2; - break; - } - pos++; - } - } - if (collecting) { - if (hasPendingCommentRange) { - accumulator = cb(pendingPos, pendingEnd, pendingKind, pendingHasTrailingNewLine, state, accumulator); - if (!reduce && accumulator) { - return accumulator; - } - hasPendingCommentRange = false; - } - pendingPos = startPos; - pendingEnd = pos; - pendingKind = kind; - pendingHasTrailingNewLine = hasTrailingNewLine; - hasPendingCommentRange = true; - } - continue; - } - break scan; - default: - if (ch > 127 && (isWhiteSpace(ch))) { - if (hasPendingCommentRange && isLineBreak(ch)) { - pendingHasTrailingNewLine = true; - } - pos++; - continue; - } - break scan; - } - } - if (hasPendingCommentRange) { - accumulator = cb(pendingPos, pendingEnd, pendingKind, pendingHasTrailingNewLine, state, accumulator); - } - return accumulator; - } - function forEachLeadingCommentRange(text, pos, cb, state) { - return iterateCommentRanges(false, text, pos, false, cb, state); - } - ts.forEachLeadingCommentRange = forEachLeadingCommentRange; - function forEachTrailingCommentRange(text, pos, cb, state) { - return iterateCommentRanges(false, text, pos, true, cb, state); - } - ts.forEachTrailingCommentRange = forEachTrailingCommentRange; - function reduceEachLeadingCommentRange(text, pos, cb, state, initial) { - return iterateCommentRanges(true, text, pos, false, cb, state, initial); - } - ts.reduceEachLeadingCommentRange = reduceEachLeadingCommentRange; - function reduceEachTrailingCommentRange(text, pos, cb, state, initial) { - return iterateCommentRanges(true, text, pos, true, cb, state, initial); - } - ts.reduceEachTrailingCommentRange = reduceEachTrailingCommentRange; - function appendCommentRange(pos, end, kind, hasTrailingNewLine, state, comments) { - if (!comments) { - comments = []; - } - comments.push({ pos: pos, end: end, hasTrailingNewLine: hasTrailingNewLine, kind: kind }); - return comments; - } - function getLeadingCommentRanges(text, pos) { - return reduceEachLeadingCommentRange(text, pos, appendCommentRange, undefined, undefined); - } - ts.getLeadingCommentRanges = getLeadingCommentRanges; - function getTrailingCommentRanges(text, pos) { - return reduceEachTrailingCommentRange(text, pos, appendCommentRange, undefined, undefined); - } - ts.getTrailingCommentRanges = getTrailingCommentRanges; - function getShebang(text) { - return shebangTriviaRegex.test(text) - ? shebangTriviaRegex.exec(text)[0] - : undefined; - } - ts.getShebang = getShebang; - function isIdentifierStart(ch, languageVersion) { - return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || - ch === 36 || ch === 95 || - ch > 127 && isUnicodeIdentifierStart(ch, languageVersion); - } - ts.isIdentifierStart = isIdentifierStart; - function isIdentifierPart(ch, languageVersion) { - return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || - ch >= 48 && ch <= 57 || ch === 36 || ch === 95 || - ch > 127 && isUnicodeIdentifierPart(ch, languageVersion); - } - ts.isIdentifierPart = isIdentifierPart; - function isIdentifierText(name, languageVersion) { - if (!isIdentifierStart(name.charCodeAt(0), languageVersion)) { - return false; - } - for (var i = 1, n = name.length; i < n; i++) { - if (!isIdentifierPart(name.charCodeAt(i), languageVersion)) { - return false; - } - } - return true; - } - ts.isIdentifierText = isIdentifierText; - function createScanner(languageVersion, skipTrivia, languageVariant, text, onError, start, length) { - if (languageVariant === void 0) { languageVariant = 0; } - var pos; - var end; - var startPos; - var tokenPos; - var token; - var tokenValue; - var precedingLineBreak; - var hasExtendedUnicodeEscape; - var tokenIsUnterminated; - setText(text, start, length); - return { - getStartPos: function () { return startPos; }, - getTextPos: function () { return pos; }, - getToken: function () { return token; }, - getTokenPos: function () { return tokenPos; }, - getTokenText: function () { return text.substring(tokenPos, pos); }, - getTokenValue: function () { return tokenValue; }, - hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, - hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 69 || token > 105; }, - isReservedWord: function () { return token >= 70 && token <= 105; }, - isUnterminated: function () { return tokenIsUnterminated; }, - reScanGreaterToken: reScanGreaterToken, - reScanSlashToken: reScanSlashToken, - reScanTemplateToken: reScanTemplateToken, - scanJsxIdentifier: scanJsxIdentifier, - scanJsxAttributeValue: scanJsxAttributeValue, - reScanJsxToken: reScanJsxToken, - scanJsxToken: scanJsxToken, - scanJSDocToken: scanJSDocToken, - scan: scan, - getText: getText, - setText: setText, - setScriptTarget: setScriptTarget, - setLanguageVariant: setLanguageVariant, - setOnError: setOnError, - setTextPos: setTextPos, - tryScan: tryScan, - lookAhead: lookAhead, - scanRange: scanRange - }; - function error(message, length) { - if (onError) { - onError(message, length || 0); - } - } - function scanNumber() { - var start = pos; - while (isDigit(text.charCodeAt(pos))) - pos++; - if (text.charCodeAt(pos) === 46) { - pos++; - while (isDigit(text.charCodeAt(pos))) - pos++; - } - var end = pos; - if (text.charCodeAt(pos) === 69 || text.charCodeAt(pos) === 101) { - pos++; - if (text.charCodeAt(pos) === 43 || text.charCodeAt(pos) === 45) - pos++; - if (isDigit(text.charCodeAt(pos))) { - pos++; - while (isDigit(text.charCodeAt(pos))) - pos++; - end = pos; - } - else { - error(ts.Diagnostics.Digit_expected); - } - } - return "" + +(text.substring(start, end)); - } - function scanOctalDigits() { - var start = pos; - while (isOctalDigit(text.charCodeAt(pos))) { - pos++; - } - return +(text.substring(start, pos)); - } - function scanExactNumberOfHexDigits(count) { - return scanHexDigits(count, false); - } - function scanMinimumNumberOfHexDigits(count) { - return scanHexDigits(count, true); - } - function scanHexDigits(minCount, scanAsManyAsPossible) { - var digits = 0; - var value = 0; - while (digits < minCount || scanAsManyAsPossible) { - var ch = text.charCodeAt(pos); - if (ch >= 48 && ch <= 57) { - value = value * 16 + ch - 48; - } - else if (ch >= 65 && ch <= 70) { - value = value * 16 + ch - 65 + 10; - } - else if (ch >= 97 && ch <= 102) { - value = value * 16 + ch - 97 + 10; - } - else { - break; - } - pos++; - digits++; - } - if (digits < minCount) { - value = -1; - } - return value; - } - function scanString(allowEscapes) { - if (allowEscapes === void 0) { allowEscapes = true; } - var quote = text.charCodeAt(pos); - pos++; - var result = ""; - var start = pos; - while (true) { - if (pos >= end) { - result += text.substring(start, pos); - tokenIsUnterminated = true; - error(ts.Diagnostics.Unterminated_string_literal); - break; - } - var ch = text.charCodeAt(pos); - if (ch === quote) { - result += text.substring(start, pos); - pos++; - break; - } - if (ch === 92 && allowEscapes) { - result += text.substring(start, pos); - result += scanEscapeSequence(); - start = pos; - continue; - } - if (isLineBreak(ch)) { - result += text.substring(start, pos); - tokenIsUnterminated = true; - error(ts.Diagnostics.Unterminated_string_literal); - break; - } - pos++; - } - return result; - } - function scanTemplateAndSetTokenValue() { - var startedWithBacktick = text.charCodeAt(pos) === 96; - pos++; - var start = pos; - var contents = ""; - var resultingToken; - while (true) { - if (pos >= end) { - contents += text.substring(start, pos); - tokenIsUnterminated = true; - error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 11 : 14; - break; - } - var currChar = text.charCodeAt(pos); - if (currChar === 96) { - contents += text.substring(start, pos); - pos++; - resultingToken = startedWithBacktick ? 11 : 14; - break; - } - if (currChar === 36 && pos + 1 < end && text.charCodeAt(pos + 1) === 123) { - contents += text.substring(start, pos); - pos += 2; - resultingToken = startedWithBacktick ? 12 : 13; - break; - } - if (currChar === 92) { - contents += text.substring(start, pos); - contents += scanEscapeSequence(); - start = pos; - continue; - } - if (currChar === 13) { - contents += text.substring(start, pos); - pos++; - if (pos < end && text.charCodeAt(pos) === 10) { - pos++; - } - contents += "\n"; - start = pos; - continue; - } - pos++; - } - ts.Debug.assert(resultingToken !== undefined); - tokenValue = contents; - return resultingToken; - } - function scanEscapeSequence() { - pos++; - if (pos >= end) { - error(ts.Diagnostics.Unexpected_end_of_text); - return ""; - } - var ch = text.charCodeAt(pos); - pos++; - switch (ch) { - case 48: - return "\0"; - case 98: - return "\b"; - case 116: - return "\t"; - case 110: - return "\n"; - case 118: - return "\v"; - case 102: - return "\f"; - case 114: - return "\r"; - case 39: - return "\'"; - case 34: - return "\""; - case 117: - if (pos < end && text.charCodeAt(pos) === 123) { - hasExtendedUnicodeEscape = true; - pos++; - return scanExtendedUnicodeEscape(); - } - return scanHexadecimalEscape(4); - case 120: - return scanHexadecimalEscape(2); - case 13: - if (pos < end && text.charCodeAt(pos) === 10) { - pos++; - } - case 10: - case 8232: - case 8233: - return ""; - default: - return String.fromCharCode(ch); - } - } - function scanHexadecimalEscape(numDigits) { - var escapedValue = scanExactNumberOfHexDigits(numDigits); - if (escapedValue >= 0) { - return String.fromCharCode(escapedValue); - } - else { - error(ts.Diagnostics.Hexadecimal_digit_expected); - return ""; - } - } - function scanExtendedUnicodeEscape() { - var escapedValue = scanMinimumNumberOfHexDigits(1); - var isInvalidExtendedEscape = false; - if (escapedValue < 0) { - error(ts.Diagnostics.Hexadecimal_digit_expected); - isInvalidExtendedEscape = true; - } - else if (escapedValue > 0x10FFFF) { - error(ts.Diagnostics.An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive); - isInvalidExtendedEscape = true; - } - if (pos >= end) { - error(ts.Diagnostics.Unexpected_end_of_text); - isInvalidExtendedEscape = true; - } - else if (text.charCodeAt(pos) === 125) { - pos++; - } - else { - error(ts.Diagnostics.Unterminated_Unicode_escape_sequence); - isInvalidExtendedEscape = true; - } - if (isInvalidExtendedEscape) { - return ""; - } - return utf16EncodeAsString(escapedValue); - } - function utf16EncodeAsString(codePoint) { - ts.Debug.assert(0x0 <= codePoint && codePoint <= 0x10FFFF); - if (codePoint <= 65535) { - return String.fromCharCode(codePoint); - } - var codeUnit1 = Math.floor((codePoint - 65536) / 1024) + 0xD800; - var codeUnit2 = ((codePoint - 65536) % 1024) + 0xDC00; - return String.fromCharCode(codeUnit1, codeUnit2); - } - function peekUnicodeEscape() { - if (pos + 5 < end && text.charCodeAt(pos + 1) === 117) { - var start_1 = pos; - pos += 2; - var value = scanExactNumberOfHexDigits(4); - pos = start_1; - return value; - } - return -1; - } - function scanIdentifierParts() { - var result = ""; - var start = pos; - while (pos < end) { - var ch = text.charCodeAt(pos); - if (isIdentifierPart(ch, languageVersion)) { - pos++; - } - else if (ch === 92) { - ch = peekUnicodeEscape(); - if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { - break; - } - result += text.substring(start, pos); - result += String.fromCharCode(ch); - pos += 6; - start = pos; - } - else { - break; - } - } - result += text.substring(start, pos); - return result; - } - function getIdentifierToken() { - var len = tokenValue.length; - if (len >= 2 && len <= 11) { - var ch = tokenValue.charCodeAt(0); - if (ch >= 97 && ch <= 122 && hasOwnProperty.call(textToToken, tokenValue)) { - return token = textToToken[tokenValue]; - } - } - return token = 69; - } - function scanBinaryOrOctalDigits(base) { - ts.Debug.assert(base === 2 || base === 8, "Expected either base 2 or base 8"); - var value = 0; - var numberOfDigits = 0; - while (true) { - var ch = text.charCodeAt(pos); - var valueOfCh = ch - 48; - if (!isDigit(ch) || valueOfCh >= base) { - break; - } - value = value * base + valueOfCh; - pos++; - numberOfDigits++; - } - if (numberOfDigits === 0) { - return -1; - } - return value; - } - function scan() { - startPos = pos; - hasExtendedUnicodeEscape = false; - precedingLineBreak = false; - tokenIsUnterminated = false; - while (true) { - tokenPos = pos; - if (pos >= end) { - return token = 1; - } - var ch = text.charCodeAt(pos); - if (ch === 35 && pos === 0 && isShebangTrivia(text, pos)) { - pos = scanShebangTrivia(text, pos); - if (skipTrivia) { - continue; - } - else { - return token = 6; - } - } - switch (ch) { - case 10: - case 13: - precedingLineBreak = true; - if (skipTrivia) { - pos++; - continue; - } - else { - if (ch === 13 && pos + 1 < end && text.charCodeAt(pos + 1) === 10) { - pos += 2; - } - else { - pos++; - } - return token = 4; - } - case 9: - case 11: - case 12: - case 32: - if (skipTrivia) { - pos++; - continue; - } - else { - while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) { - pos++; - } - return token = 5; - } - case 33: - if (text.charCodeAt(pos + 1) === 61) { - if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 33; - } - return pos += 2, token = 31; - } - pos++; - return token = 49; - case 34: - case 39: - tokenValue = scanString(); - return token = 9; - case 96: - return token = scanTemplateAndSetTokenValue(); - case 37: - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 62; - } - pos++; - return token = 40; - case 38: - if (text.charCodeAt(pos + 1) === 38) { - return pos += 2, token = 51; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 66; - } - pos++; - return token = 46; - case 40: - pos++; - return token = 17; - case 41: - pos++; - return token = 18; - case 42: - if (text.charCodeAt(pos + 1) === 61) { - 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; - } - pos++; - return token = 37; - case 43: - if (text.charCodeAt(pos + 1) === 43) { - return pos += 2, token = 41; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 57; - } - pos++; - return token = 35; - case 44: - pos++; - return token = 24; - case 45: - if (text.charCodeAt(pos + 1) === 45) { - return pos += 2, token = 42; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 58; - } - pos++; - return token = 36; - case 46: - if (isDigit(text.charCodeAt(pos + 1))) { - tokenValue = scanNumber(); - return token = 8; - } - if (text.charCodeAt(pos + 1) === 46 && text.charCodeAt(pos + 2) === 46) { - return pos += 3, token = 22; - } - pos++; - return token = 21; - case 47: - if (text.charCodeAt(pos + 1) === 47) { - pos += 2; - while (pos < end) { - if (isLineBreak(text.charCodeAt(pos))) { - break; - } - pos++; - } - if (skipTrivia) { - continue; - } - else { - return token = 2; - } - } - if (text.charCodeAt(pos + 1) === 42) { - pos += 2; - var commentClosed = false; - while (pos < end) { - var ch_2 = text.charCodeAt(pos); - if (ch_2 === 42 && text.charCodeAt(pos + 1) === 47) { - pos += 2; - commentClosed = true; - break; - } - if (isLineBreak(ch_2)) { - precedingLineBreak = true; - } - pos++; - } - if (!commentClosed) { - error(ts.Diagnostics.Asterisk_Slash_expected); - } - if (skipTrivia) { - continue; - } - else { - tokenIsUnterminated = !commentClosed; - return token = 3; - } - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 61; - } - pos++; - return token = 39; - case 48: - if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 || text.charCodeAt(pos + 1) === 120)) { - pos += 2; - var value = scanMinimumNumberOfHexDigits(1); - if (value < 0) { - error(ts.Diagnostics.Hexadecimal_digit_expected); - value = 0; - } - tokenValue = "" + value; - return token = 8; - } - else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 || text.charCodeAt(pos + 1) === 98)) { - pos += 2; - var value = scanBinaryOrOctalDigits(2); - if (value < 0) { - error(ts.Diagnostics.Binary_digit_expected); - value = 0; - } - tokenValue = "" + value; - return token = 8; - } - else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 || text.charCodeAt(pos + 1) === 111)) { - pos += 2; - var value = scanBinaryOrOctalDigits(8); - if (value < 0) { - error(ts.Diagnostics.Octal_digit_expected); - value = 0; - } - tokenValue = "" + value; - return token = 8; - } - if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { - tokenValue = "" + scanOctalDigits(); - return token = 8; - } - case 49: - case 50: - case 51: - case 52: - case 53: - case 54: - case 55: - case 56: - case 57: - tokenValue = scanNumber(); - return token = 8; - case 58: - pos++; - return token = 54; - case 59: - pos++; - return token = 23; - case 60: - if (isConflictMarkerTrivia(text, pos)) { - pos = scanConflictMarkerTrivia(text, pos, error); - if (skipTrivia) { - continue; - } - else { - return token = 7; - } - } - if (text.charCodeAt(pos + 1) === 60) { - if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 63; - } - return pos += 2, token = 43; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 28; - } - if (languageVariant === 1 && - text.charCodeAt(pos + 1) === 47 && - text.charCodeAt(pos + 2) !== 42) { - return pos += 2, token = 26; - } - pos++; - return token = 25; - case 61: - if (isConflictMarkerTrivia(text, pos)) { - pos = scanConflictMarkerTrivia(text, pos, error); - if (skipTrivia) { - continue; - } - else { - return token = 7; - } - } - if (text.charCodeAt(pos + 1) === 61) { - if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 32; - } - return pos += 2, token = 30; - } - if (text.charCodeAt(pos + 1) === 62) { - return pos += 2, token = 34; - } - pos++; - return token = 56; - case 62: - if (isConflictMarkerTrivia(text, pos)) { - pos = scanConflictMarkerTrivia(text, pos, error); - if (skipTrivia) { - continue; - } - else { - return token = 7; - } - } - pos++; - return token = 27; - case 63: - pos++; - return token = 53; - case 91: - pos++; - return token = 19; - case 93: - pos++; - return token = 20; - case 94: - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 68; - } - pos++; - return token = 48; - case 123: - pos++; - return token = 15; - case 124: - if (text.charCodeAt(pos + 1) === 124) { - return pos += 2, token = 52; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 67; - } - pos++; - return token = 47; - case 125: - pos++; - return token = 16; - case 126: - pos++; - return token = 50; - case 64: - pos++; - return token = 55; - case 92: - var cookedChar = peekUnicodeEscape(); - if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { - pos += 6; - tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); - return token = getIdentifierToken(); - } - error(ts.Diagnostics.Invalid_character); - pos++; - return token = 0; - default: - if (isIdentifierStart(ch, languageVersion)) { - pos++; - while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) - pos++; - tokenValue = text.substring(tokenPos, pos); - if (ch === 92) { - tokenValue += scanIdentifierParts(); - } - return token = getIdentifierToken(); - } - else if (isWhiteSpaceSingleLine(ch)) { - pos++; - continue; - } - else if (isLineBreak(ch)) { - precedingLineBreak = true; - pos++; - continue; - } - error(ts.Diagnostics.Invalid_character); - pos++; - return token = 0; - } - } - } - function reScanGreaterToken() { - if (token === 27) { - if (text.charCodeAt(pos) === 62) { - if (text.charCodeAt(pos + 1) === 62) { - if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 65; - } - return pos += 2, token = 45; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 64; - } - pos++; - return token = 44; - } - if (text.charCodeAt(pos) === 61) { - pos++; - return token = 29; - } - } - return token; - } - function reScanSlashToken() { - if (token === 39 || token === 61) { - var p = tokenPos + 1; - var inEscape = false; - var inCharacterClass = false; - while (true) { - if (p >= end) { - tokenIsUnterminated = true; - error(ts.Diagnostics.Unterminated_regular_expression_literal); - break; - } - var ch = text.charCodeAt(p); - if (isLineBreak(ch)) { - tokenIsUnterminated = true; - error(ts.Diagnostics.Unterminated_regular_expression_literal); - break; - } - if (inEscape) { - inEscape = false; - } - else if (ch === 47 && !inCharacterClass) { - p++; - break; - } - else if (ch === 91) { - inCharacterClass = true; - } - else if (ch === 92) { - inEscape = true; - } - else if (ch === 93) { - inCharacterClass = false; - } - p++; - } - while (p < end && isIdentifierPart(text.charCodeAt(p), languageVersion)) { - p++; - } - pos = p; - tokenValue = text.substring(tokenPos, pos); - token = 10; - } - return token; - } - function reScanTemplateToken() { - ts.Debug.assert(token === 16, "'reScanTemplateToken' should only be called on a '}'"); - pos = tokenPos; - return token = scanTemplateAndSetTokenValue(); - } - function reScanJsxToken() { - pos = tokenPos = startPos; - return token = scanJsxToken(); - } - function scanJsxToken() { - startPos = tokenPos = pos; - if (pos >= end) { - return token = 1; - } - var char = text.charCodeAt(pos); - if (char === 60) { - if (text.charCodeAt(pos + 1) === 47) { - pos += 2; - return token = 26; - } - pos++; - return token = 25; - } - if (char === 123) { - pos++; - return token = 15; - } - while (pos < end) { - pos++; - char = text.charCodeAt(pos); - if ((char === 123) || (char === 60)) { - break; - } - } - return token = 244; - } - function scanJsxIdentifier() { - if (tokenIsIdentifierOrKeyword(token)) { - var firstCharPosition = pos; - while (pos < end) { - var ch = text.charCodeAt(pos); - if (ch === 45 || ((firstCharPosition === pos) ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion))) { - pos++; - } - else { - break; - } - } - tokenValue += text.substr(firstCharPosition, pos - firstCharPosition); - } - return token; - } - function scanJsxAttributeValue() { - startPos = pos; - switch (text.charCodeAt(pos)) { - case 34: - case 39: - tokenValue = scanString(false); - return token = 9; - default: - return scan(); - } - } - function scanJSDocToken() { - if (pos >= end) { - return token = 1; - } - startPos = pos; - tokenPos = pos; - var ch = text.charCodeAt(pos); - switch (ch) { - case 9: - case 11: - case 12: - case 32: - while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) { - pos++; - } - return token = 5; - case 64: - pos++; - return token = 55; - case 10: - case 13: - pos++; - return token = 4; - case 42: - pos++; - return token = 37; - case 123: - pos++; - return token = 15; - case 125: - pos++; - return token = 16; - case 91: - pos++; - return token = 19; - case 93: - pos++; - return token = 20; - case 61: - pos++; - return token = 56; - case 44: - pos++; - return token = 24; - } - if (isIdentifierStart(ch, 2)) { - pos++; - while (isIdentifierPart(text.charCodeAt(pos), 2) && pos < end) { - pos++; - } - return token = 69; - } - else { - return pos += 1, token = 0; - } - } - function speculationHelper(callback, isLookahead) { - var savePos = pos; - var saveStartPos = startPos; - var saveTokenPos = tokenPos; - var saveToken = token; - var saveTokenValue = tokenValue; - var savePrecedingLineBreak = precedingLineBreak; - var result = callback(); - if (!result || isLookahead) { - pos = savePos; - startPos = saveStartPos; - tokenPos = saveTokenPos; - token = saveToken; - tokenValue = saveTokenValue; - precedingLineBreak = savePrecedingLineBreak; - } - return result; - } - function scanRange(start, length, callback) { - var saveEnd = end; - var savePos = pos; - var saveStartPos = startPos; - var saveTokenPos = tokenPos; - var saveToken = token; - var savePrecedingLineBreak = precedingLineBreak; - var saveTokenValue = tokenValue; - var saveHasExtendedUnicodeEscape = hasExtendedUnicodeEscape; - var saveTokenIsUnterminated = tokenIsUnterminated; - setText(text, start, length); - var result = callback(); - end = saveEnd; - pos = savePos; - startPos = saveStartPos; - tokenPos = saveTokenPos; - token = saveToken; - precedingLineBreak = savePrecedingLineBreak; - tokenValue = saveTokenValue; - hasExtendedUnicodeEscape = saveHasExtendedUnicodeEscape; - tokenIsUnterminated = saveTokenIsUnterminated; - return result; - } - function lookAhead(callback) { - return speculationHelper(callback, true); - } - function tryScan(callback) { - return speculationHelper(callback, false); - } - function getText() { - return text; - } - function setText(newText, start, length) { - text = newText || ""; - end = length === undefined ? text.length : start + length; - setTextPos(start || 0); - } - function setOnError(errorCallback) { - onError = errorCallback; - } - function setScriptTarget(scriptTarget) { - languageVersion = scriptTarget; - } - function setLanguageVariant(variant) { - languageVariant = variant; - } - function setTextPos(textPos) { - ts.Debug.assert(textPos >= 0); - pos = textPos; - startPos = textPos; - tokenPos = textPos; - token = 0; - precedingLineBreak = false; - tokenValue = undefined; - hasExtendedUnicodeEscape = false; - tokenIsUnterminated = false; - } - } - ts.createScanner = createScanner; -})(ts || (ts = {})); -var ts; -(function (ts) { - ts.compileOnSaveCommandLineOption = { name: "compileOnSave", type: "boolean" }; - ts.optionDeclarations = [ - { - name: "charset", - type: "string" - }, - ts.compileOnSaveCommandLineOption, - { - name: "declaration", - shortName: "d", - type: "boolean", - description: ts.Diagnostics.Generates_corresponding_d_ts_file - }, - { - name: "declarationDir", - type: "string", - isFilePath: true, - paramType: ts.Diagnostics.DIRECTORY - }, - { - name: "diagnostics", - type: "boolean" - }, - { - name: "extendedDiagnostics", - type: "boolean", - experimental: true - }, - { - name: "emitBOM", - type: "boolean" - }, - { - name: "help", - shortName: "h", - type: "boolean", - description: ts.Diagnostics.Print_this_message - }, - { - name: "help", - shortName: "?", - type: "boolean" - }, - { - name: "init", - type: "boolean", - description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file - }, - { - name: "inlineSourceMap", - type: "boolean" - }, - { - name: "inlineSources", - type: "boolean" - }, - { - name: "jsx", - type: ts.createMap({ - "preserve": 1, - "react": 2 - }), - paramType: ts.Diagnostics.KIND, - description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react - }, - { - name: "reactNamespace", - type: "string", - description: ts.Diagnostics.Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit - }, - { - name: "listFiles", - type: "boolean" - }, - { - name: "locale", - type: "string" - }, - { - name: "mapRoot", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, - paramType: ts.Diagnostics.LOCATION - }, - { - name: "module", - shortName: "m", - type: ts.createMap({ - "none": ts.ModuleKind.None, - "commonjs": ts.ModuleKind.CommonJS, - "amd": ts.ModuleKind.AMD, - "system": ts.ModuleKind.System, - "umd": ts.ModuleKind.UMD, - "es6": ts.ModuleKind.ES6, - "es2015": ts.ModuleKind.ES2015 - }), - description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, - paramType: ts.Diagnostics.KIND - }, - { - name: "newLine", - type: ts.createMap({ - "crlf": 0, - "lf": 1 - }), - description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, - paramType: ts.Diagnostics.NEWLINE - }, - { - name: "noEmit", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_outputs - }, - { - name: "noEmitHelpers", - type: "boolean" - }, - { - name: "noEmitOnError", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported - }, - { - name: "noErrorTruncation", - type: "boolean" - }, - { - name: "noImplicitAny", - type: "boolean", - description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type - }, - { - name: "noImplicitThis", - type: "boolean", - description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type - }, - { - name: "noUnusedLocals", - type: "boolean", - description: ts.Diagnostics.Report_errors_on_unused_locals - }, - { - name: "noUnusedParameters", - type: "boolean", - description: ts.Diagnostics.Report_errors_on_unused_parameters - }, - { - name: "noLib", - type: "boolean" - }, - { - name: "noResolve", - type: "boolean" - }, - { - name: "skipDefaultLibCheck", - type: "boolean" - }, - { - name: "skipLibCheck", - type: "boolean", - description: ts.Diagnostics.Skip_type_checking_of_declaration_files - }, - { - name: "out", - type: "string", - isFilePath: false, - paramType: ts.Diagnostics.FILE - }, - { - name: "outFile", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, - paramType: ts.Diagnostics.FILE - }, - { - name: "outDir", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Redirect_output_structure_to_the_directory, - paramType: ts.Diagnostics.DIRECTORY - }, - { - name: "preserveConstEnums", - type: "boolean", - description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code - }, - { - name: "pretty", - description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental, - type: "boolean" - }, - { - name: "project", - shortName: "p", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Compile_the_project_in_the_given_directory, - paramType: ts.Diagnostics.DIRECTORY - }, - { - name: "removeComments", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_comments_to_output - }, - { - name: "rootDir", - type: "string", - isFilePath: true, - paramType: ts.Diagnostics.LOCATION, - description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir - }, - { - name: "isolatedModules", - type: "boolean" - }, - { - name: "sourceMap", - type: "boolean", - description: ts.Diagnostics.Generates_corresponding_map_file - }, - { - name: "sourceRoot", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, - paramType: ts.Diagnostics.LOCATION - }, - { - name: "suppressExcessPropertyErrors", - type: "boolean", - description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals, - experimental: true - }, - { - name: "suppressImplicitAnyIndexErrors", - type: "boolean", - description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures - }, - { - name: "stripInternal", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation, - experimental: true - }, - { - name: "target", - shortName: "t", - type: ts.createMap({ - "es3": 0, - "es5": 1, - "es6": 2, - "es2015": 2 - }), - description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015, - paramType: ts.Diagnostics.VERSION - }, - { - name: "version", - shortName: "v", - type: "boolean", - description: ts.Diagnostics.Print_the_compiler_s_version - }, - { - name: "watch", - shortName: "w", - type: "boolean", - description: ts.Diagnostics.Watch_input_files - }, - { - name: "experimentalDecorators", - type: "boolean", - description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators - }, - { - name: "emitDecoratorMetadata", - type: "boolean", - experimental: true, - description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators - }, - { - name: "moduleResolution", - type: ts.createMap({ - "node": ts.ModuleResolutionKind.NodeJs, - "classic": ts.ModuleResolutionKind.Classic - }), - description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, - paramType: ts.Diagnostics.STRATEGY - }, - { - name: "allowUnusedLabels", - type: "boolean", - description: ts.Diagnostics.Do_not_report_errors_on_unused_labels - }, - { - name: "noImplicitReturns", - type: "boolean", - description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value - }, - { - name: "noFallthroughCasesInSwitch", - type: "boolean", - description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement - }, - { - name: "allowUnreachableCode", - type: "boolean", - description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code - }, - { - name: "forceConsistentCasingInFileNames", - type: "boolean", - description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file - }, - { - name: "baseUrl", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Base_directory_to_resolve_non_absolute_module_names - }, - { - name: "paths", - type: "object", - isTSConfigOnly: true - }, - { - name: "rootDirs", - type: "list", - isTSConfigOnly: true, - element: { - name: "rootDirs", - type: "string", - isFilePath: true - } - }, - { - name: "typeRoots", - type: "list", - element: { - name: "typeRoots", - type: "string", - isFilePath: true - } - }, - { - name: "types", - type: "list", - element: { - name: "types", - type: "string" - }, - description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation - }, - { - name: "traceResolution", - type: "boolean", - description: ts.Diagnostics.Enable_tracing_of_the_name_resolution_process - }, - { - name: "allowJs", - type: "boolean", - description: ts.Diagnostics.Allow_javascript_files_to_be_compiled - }, - { - name: "allowSyntheticDefaultImports", - type: "boolean", - description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking - }, - { - name: "noImplicitUseStrict", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_use_strict_directives_in_module_output - }, - { - name: "maxNodeModuleJsDepth", - type: "number", - description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files - }, - { - name: "listEmittedFiles", - type: "boolean" - }, - { - name: "lib", - type: "list", - element: { - name: "lib", - type: ts.createMap({ - "es5": "lib.es5.d.ts", - "es6": "lib.es2015.d.ts", - "es2015": "lib.es2015.d.ts", - "es7": "lib.es2016.d.ts", - "es2016": "lib.es2016.d.ts", - "es2017": "lib.es2017.d.ts", - "dom": "lib.dom.d.ts", - "dom.iterable": "lib.dom.iterable.d.ts", - "webworker": "lib.webworker.d.ts", - "scripthost": "lib.scripthost.d.ts", - "es2015.core": "lib.es2015.core.d.ts", - "es2015.collection": "lib.es2015.collection.d.ts", - "es2015.generator": "lib.es2015.generator.d.ts", - "es2015.iterable": "lib.es2015.iterable.d.ts", - "es2015.promise": "lib.es2015.promise.d.ts", - "es2015.proxy": "lib.es2015.proxy.d.ts", - "es2015.reflect": "lib.es2015.reflect.d.ts", - "es2015.symbol": "lib.es2015.symbol.d.ts", - "es2015.symbol.wellknown": "lib.es2015.symbol.wellknown.d.ts", - "es2016.array.include": "lib.es2016.array.include.d.ts", - "es2017.object": "lib.es2017.object.d.ts", - "es2017.sharedmemory": "lib.es2017.sharedmemory.d.ts" - }) - }, - description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon - }, - { - name: "disableSizeLimit", - type: "boolean" - }, - { - name: "strictNullChecks", - type: "boolean", - description: ts.Diagnostics.Enable_strict_null_checks - }, - { - name: "importHelpers", - type: "boolean", - description: ts.Diagnostics.Import_emit_helpers_from_tslib - }, - { - name: "alwaysStrict", - type: "boolean", - description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file - } - ]; - ts.typingOptionDeclarations = [ - { - name: "enableAutoDiscovery", - type: "boolean" - }, - { - name: "include", - type: "list", - element: { - name: "include", - type: "string" - } - }, - { - name: "exclude", - type: "list", - element: { - name: "exclude", - type: "string" - } - } - ]; - ts.defaultInitCompilerOptions = { - module: ts.ModuleKind.CommonJS, - target: 1, - noImplicitAny: false, - sourceMap: false - }; - var optionNameMapCache; - function getOptionNameMap() { - if (optionNameMapCache) { - return optionNameMapCache; - } - var optionNameMap = ts.createMap(); - var shortOptionNames = ts.createMap(); - ts.forEach(ts.optionDeclarations, function (option) { - optionNameMap[option.name.toLowerCase()] = option; - if (option.shortName) { - shortOptionNames[option.shortName] = option.name; - } - }); - optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames }; - return optionNameMapCache; - } - ts.getOptionNameMap = getOptionNameMap; - function createCompilerDiagnosticForInvalidCustomType(opt) { - var namesOfType = []; - for (var key in opt.type) { - namesOfType.push(" '" + key + "'"); - } - return ts.createCompilerDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); - } - ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; - function parseCustomTypeOption(opt, value, errors) { - var key = trimString((value || "")).toLowerCase(); - var map = opt.type; - if (key in map) { - return map[key]; - } - else { - errors.push(createCompilerDiagnosticForInvalidCustomType(opt)); - } - } - ts.parseCustomTypeOption = parseCustomTypeOption; - function parseListTypeOption(opt, value, errors) { - if (value === void 0) { value = ""; } - value = trimString(value); - if (ts.startsWith(value, "-")) { - return undefined; - } - if (value === "") { - return []; - } - var values = value.split(","); - switch (opt.element.type) { - case "number": - return ts.map(values, parseInt); - case "string": - return ts.map(values, function (v) { return v || ""; }); - default: - return ts.filter(ts.map(values, function (v) { return parseCustomTypeOption(opt.element, v, errors); }), function (v) { return !!v; }); - } - } - ts.parseListTypeOption = parseListTypeOption; - function parseCommandLine(commandLine, readFile) { - var options = {}; - var fileNames = []; - var errors = []; - var _a = getOptionNameMap(), optionNameMap = _a.optionNameMap, shortOptionNames = _a.shortOptionNames; - parseStrings(commandLine); - return { - options: options, - fileNames: fileNames, - errors: errors - }; - function parseStrings(args) { - var i = 0; - while (i < args.length) { - var s = args[i]; - i++; - if (s.charCodeAt(0) === 64) { - parseResponseFile(s.slice(1)); - } - else if (s.charCodeAt(0) === 45) { - s = s.slice(s.charCodeAt(1) === 45 ? 2 : 1).toLowerCase(); - if (s in shortOptionNames) { - s = shortOptionNames[s]; - } - if (s in optionNameMap) { - var opt = optionNameMap[s]; - if (opt.isTSConfigOnly) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file, opt.name)); - } - else { - if (!args[i] && opt.type !== "boolean") { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_expects_an_argument, opt.name)); - } - switch (opt.type) { - case "number": - options[opt.name] = parseInt(args[i]); - i++; - break; - case "boolean": - options[opt.name] = true; - break; - case "string": - options[opt.name] = args[i] || ""; - i++; - break; - case "list": - var result = parseListTypeOption(opt, args[i], errors); - options[opt.name] = result || []; - if (result) { - i++; - } - break; - default: - options[opt.name] = parseCustomTypeOption(opt, args[i], errors); - i++; - break; - } - } - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_compiler_option_0, s)); - } - } - else { - fileNames.push(s); - } - } - } - function parseResponseFile(fileName) { - var text = readFile ? readFile(fileName) : ts.sys.readFile(fileName); - if (!text) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, fileName)); - return; - } - var args = []; - var pos = 0; - while (true) { - while (pos < text.length && text.charCodeAt(pos) <= 32) - pos++; - if (pos >= text.length) - break; - var start = pos; - if (text.charCodeAt(start) === 34) { - pos++; - while (pos < text.length && text.charCodeAt(pos) !== 34) - pos++; - if (pos < text.length) { - args.push(text.substring(start + 1, pos)); - pos++; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unterminated_quoted_string_in_response_file_0, fileName)); - } - } - else { - while (text.charCodeAt(pos) > 32) - pos++; - args.push(text.substring(start, pos)); - } - } - parseStrings(args); - } - } - ts.parseCommandLine = parseCommandLine; - function readConfigFile(fileName, readFile) { - var text = ""; - try { - text = readFile(fileName); - } - catch (e) { - return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) }; - } - return parseConfigFileTextToJson(fileName, text); - } - ts.readConfigFile = readConfigFile; - function parseConfigFileTextToJson(fileName, jsonText, stripComments) { - if (stripComments === void 0) { stripComments = true; } - try { - var jsonTextToParse = stripComments ? removeComments(jsonText) : jsonText; - return { config: /\S/.test(jsonTextToParse) ? JSON.parse(jsonTextToParse) : {} }; - } - catch (e) { - return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) }; - } - } - ts.parseConfigFileTextToJson = parseConfigFileTextToJson; - function generateTSConfig(options, fileNames) { - var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions); - var configurations = { - compilerOptions: serializeCompilerOptions(compilerOptions) - }; - if (fileNames && fileNames.length) { - configurations.files = fileNames; - } - return configurations; - function getCustomTypeMapOfCommandLineOption(optionDefinition) { - if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean") { - return undefined; - } - else if (optionDefinition.type === "list") { - return getCustomTypeMapOfCommandLineOption(optionDefinition.element); - } - else { - return optionDefinition.type; - } - } - function getNameOfCompilerOptionValue(value, customTypeMap) { - for (var key in customTypeMap) { - if (customTypeMap[key] === value) { - return key; - } - } - return undefined; - } - function serializeCompilerOptions(options) { - var result = ts.createMap(); - var optionsNameMap = getOptionNameMap().optionNameMap; - for (var name_5 in options) { - if (ts.hasProperty(options, name_5)) { - switch (name_5) { - case "init": - case "watch": - case "version": - case "help": - case "project": - break; - default: - var value = options[name_5]; - var optionDefinition = optionsNameMap[name_5.toLowerCase()]; - if (optionDefinition) { - var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); - if (!customTypeMap) { - result[name_5] = value; - } - else { - if (optionDefinition.type === "list") { - var convertedValue = []; - for (var _i = 0, _a = value; _i < _a.length; _i++) { - var element = _a[_i]; - convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); - } - result[name_5] = convertedValue; - } - else { - result[name_5] = getNameOfCompilerOptionValue(value, customTypeMap); - } - } - } - break; - } - } - } - return result; - } - } - ts.generateTSConfig = generateTSConfig; - function removeComments(jsonText) { - var output = ""; - var scanner = ts.createScanner(1, false, 0, jsonText); - var token; - while ((token = scanner.scan()) !== 1) { - switch (token) { - case 2: - case 3: - output += scanner.getTokenText().replace(/\S/g, " "); - break; - default: - output += scanner.getTokenText(); - break; - } - } - return output; - } - function parseJsonConfigFileContent(json, host, basePath, existingOptions, configFileName, resolutionStack) { - if (existingOptions === void 0) { existingOptions = {}; } - if (resolutionStack === void 0) { resolutionStack = []; } - var errors = []; - var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); - var resolvedPath = ts.toPath(configFileName || "", basePath, getCanonicalFileName); - if (resolutionStack.indexOf(resolvedPath) >= 0) { - return { - options: {}, - fileNames: [], - typingOptions: {}, - raw: json, - errors: [ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, resolutionStack.concat([resolvedPath]).join(" -> "))], - wildcardDirectories: {} - }; - } - var options = convertCompilerOptionsFromJsonWorker(json["compilerOptions"], basePath, errors, configFileName); - var typingOptions = convertTypingOptionsFromJsonWorker(json["typingOptions"], basePath, errors, configFileName); - if (json["extends"]) { - var _a = [undefined, undefined, undefined, {}], include = _a[0], exclude = _a[1], files = _a[2], baseOptions = _a[3]; - if (typeof json["extends"] === "string") { - _b = (tryExtendsName(json["extends"]) || [include, exclude, files, baseOptions]), include = _b[0], exclude = _b[1], files = _b[2], baseOptions = _b[3]; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string")); - } - if (include && !json["include"]) { - json["include"] = include; - } - if (exclude && !json["exclude"]) { - json["exclude"] = exclude; - } - if (files && !json["files"]) { - json["files"] = files; - } - options = ts.assign({}, baseOptions, options); - } - options = ts.extend(existingOptions, options); - options.configFilePath = configFileName; - var _c = getFileNames(errors), fileNames = _c.fileNames, wildcardDirectories = _c.wildcardDirectories; - var compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors); - return { - options: options, - fileNames: fileNames, - typingOptions: typingOptions, - raw: json, - errors: errors, - wildcardDirectories: wildcardDirectories, - compileOnSave: compileOnSave - }; - function tryExtendsName(extendedConfig) { - if (!(ts.isRootedDiskPath(extendedConfig) || ts.startsWith(ts.normalizeSlashes(extendedConfig), "./") || ts.startsWith(ts.normalizeSlashes(extendedConfig), "../"))) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.The_path_in_an_extends_options_must_be_relative_or_rooted)); - return; - } - var extendedConfigPath = ts.toPath(extendedConfig, basePath, getCanonicalFileName); - if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json")) { - extendedConfigPath = extendedConfigPath + ".json"; - if (!host.fileExists(extendedConfigPath)) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig)); - return; - } - } - var extendedResult = readConfigFile(extendedConfigPath, function (path) { return host.readFile(path); }); - if (extendedResult.error) { - errors.push(extendedResult.error); - return; - } - var extendedDirname = ts.getDirectoryPath(extendedConfigPath); - var relativeDifference = ts.convertToRelativePath(extendedDirname, basePath, getCanonicalFileName); - var updatePath = function (path) { return ts.isRootedDiskPath(path) ? path : ts.combinePaths(relativeDifference, path); }; - var result = parseJsonConfigFileContent(extendedResult.config, host, extendedDirname, undefined, ts.getBaseFileName(extendedConfigPath), resolutionStack.concat([resolvedPath])); - errors.push.apply(errors, result.errors); - var _a = ts.map(["include", "exclude", "files"], function (key) { - if (!json[key] && extendedResult.config[key]) { - return ts.map(extendedResult.config[key], updatePath); - } - }), include = _a[0], exclude = _a[1], files = _a[2]; - return [include, exclude, files, result.options]; - } - function getFileNames(errors) { - var fileNames; - if (ts.hasProperty(json, "files")) { - if (ts.isArray(json["files"])) { - fileNames = json["files"]; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array")); - } - } - var includeSpecs; - if (ts.hasProperty(json, "include")) { - if (ts.isArray(json["include"])) { - includeSpecs = json["include"]; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "include", "Array")); - } - } - var excludeSpecs; - if (ts.hasProperty(json, "exclude")) { - if (ts.isArray(json["exclude"])) { - excludeSpecs = json["exclude"]; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "exclude", "Array")); - } - } - else if (ts.hasProperty(json, "excludes")) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_option_excludes_Did_you_mean_exclude)); - } - else { - excludeSpecs = ["node_modules", "bower_components", "jspm_packages"]; - var outDir = json["compilerOptions"] && json["compilerOptions"]["outDir"]; - if (outDir) { - excludeSpecs.push(outDir); - } - } - if (fileNames === undefined && includeSpecs === undefined) { - includeSpecs = ["**/*"]; - } - return matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors); - } - var _b; - } - ts.parseJsonConfigFileContent = parseJsonConfigFileContent; - function convertCompileOnSaveOptionFromJson(jsonOption, basePath, errors) { - if (!ts.hasProperty(jsonOption, ts.compileOnSaveCommandLineOption.name)) { - return false; - } - var result = convertJsonOption(ts.compileOnSaveCommandLineOption, jsonOption["compileOnSave"], basePath, errors); - if (typeof result === "boolean" && result) { - return result; - } - return false; - } - ts.convertCompileOnSaveOptionFromJson = convertCompileOnSaveOptionFromJson; - function convertCompilerOptionsFromJson(jsonOptions, basePath, configFileName) { - var errors = []; - var options = convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName); - return { options: options, errors: errors }; - } - ts.convertCompilerOptionsFromJson = convertCompilerOptionsFromJson; - function convertTypingOptionsFromJson(jsonOptions, basePath, configFileName) { - var errors = []; - var options = convertTypingOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName); - return { options: options, errors: errors }; - } - ts.convertTypingOptionsFromJson = convertTypingOptionsFromJson; - function convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { - var options = ts.getBaseFileName(configFileName) === "jsconfig.json" - ? { allowJs: true, maxNodeModuleJsDepth: 2, allowSyntheticDefaultImports: true, skipLibCheck: true } - : {}; - convertOptionsFromJson(ts.optionDeclarations, jsonOptions, basePath, options, ts.Diagnostics.Unknown_compiler_option_0, errors); - return options; - } - function convertTypingOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { - var options = ts.getBaseFileName(configFileName) === "jsconfig.json" - ? { enableAutoDiscovery: true, include: [], exclude: [] } - : { enableAutoDiscovery: false, include: [], exclude: [] }; - convertOptionsFromJson(ts.typingOptionDeclarations, jsonOptions, basePath, options, ts.Diagnostics.Unknown_typing_option_0, errors); - return options; - } - function convertOptionsFromJson(optionDeclarations, jsonOptions, basePath, defaultOptions, diagnosticMessage, errors) { - if (!jsonOptions) { - return; - } - var optionNameMap = ts.arrayToMap(optionDeclarations, function (opt) { return opt.name; }); - for (var id in jsonOptions) { - if (id in optionNameMap) { - var opt = optionNameMap[id]; - defaultOptions[opt.name] = convertJsonOption(opt, jsonOptions[id], basePath, errors); - } - else { - errors.push(ts.createCompilerDiagnostic(diagnosticMessage, id)); - } - } - } - function convertJsonOption(opt, value, basePath, errors) { - var optType = opt.type; - var expectedType = typeof optType === "string" ? optType : "string"; - if (optType === "list" && ts.isArray(value)) { - return convertJsonOptionOfListType(opt, value, basePath, errors); - } - else if (typeof value === expectedType) { - if (typeof optType !== "string") { - return convertJsonOptionOfCustomType(opt, value, errors); - } - else { - if (opt.isFilePath) { - value = ts.normalizePath(ts.combinePaths(basePath, value)); - if (value === "") { - value = "."; - } - } - } - return value; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, opt.name, expectedType)); - } - } - function convertJsonOptionOfCustomType(opt, value, errors) { - var key = value.toLowerCase(); - if (key in opt.type) { - return opt.type[key]; - } - else { - errors.push(createCompilerDiagnosticForInvalidCustomType(opt)); - } - } - function convertJsonOptionOfListType(option, values, basePath, errors) { - return ts.filter(ts.map(values, function (v) { return convertJsonOption(option.element, v, basePath, errors); }), function (v) { return !!v; }); - } - function trimString(s) { - return typeof s.trim === "function" ? s.trim() : s.replace(/^[\s]+|[\s]+$/g, ""); - } - var invalidTrailingRecursionPattern = /(^|\/)\*\*\/?$/; - var invalidMultipleRecursionPatterns = /(^|\/)\*\*\/(.*\/)?\*\*($|\/)/; - var invalidDotDotAfterRecursiveWildcardPattern = /(^|\/)\*\*\/(.*\/)?\.\.($|\/)/; - var watchRecursivePattern = /\/[^/]*?[*?][^/]*\//; - var wildcardDirectoryPattern = /^[^*?]*(?=\/[^/]*[*?])/; - function matchFileNames(fileNames, include, exclude, basePath, options, host, errors) { - basePath = ts.normalizePath(basePath); - var keyMapper = host.useCaseSensitiveFileNames ? caseSensitiveKeyMapper : caseInsensitiveKeyMapper; - var literalFileMap = ts.createMap(); - var wildcardFileMap = ts.createMap(); - if (include) { - include = validateSpecs(include, errors, false); - } - if (exclude) { - exclude = validateSpecs(exclude, errors, true); - } - var wildcardDirectories = getWildcardDirectories(include, exclude, basePath, host.useCaseSensitiveFileNames); - var supportedExtensions = ts.getSupportedExtensions(options); - if (fileNames) { - for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) { - var fileName = fileNames_1[_i]; - var file = ts.combinePaths(basePath, fileName); - literalFileMap[keyMapper(file)] = file; - } - } - if (include && include.length > 0) { - for (var _a = 0, _b = host.readDirectory(basePath, supportedExtensions, exclude, include); _a < _b.length; _a++) { - var file = _b[_a]; - if (hasFileWithHigherPriorityExtension(file, literalFileMap, wildcardFileMap, supportedExtensions, keyMapper)) { - continue; - } - removeWildcardFilesWithLowerPriorityExtension(file, wildcardFileMap, supportedExtensions, keyMapper); - var key = keyMapper(file); - if (!(key in literalFileMap) && !(key in wildcardFileMap)) { - wildcardFileMap[key] = file; - } - } - } - var literalFiles = ts.reduceProperties(literalFileMap, addFileToOutput, []); - var wildcardFiles = ts.reduceProperties(wildcardFileMap, addFileToOutput, []); - wildcardFiles.sort(host.useCaseSensitiveFileNames ? ts.compareStrings : ts.compareStringsCaseInsensitive); - return { - fileNames: literalFiles.concat(wildcardFiles), - wildcardDirectories: wildcardDirectories - }; - } - function validateSpecs(specs, errors, allowTrailingRecursion) { - var validSpecs = []; - for (var _i = 0, specs_2 = specs; _i < specs_2.length; _i++) { - var spec = specs_2[_i]; - if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); - } - else if (invalidMultipleRecursionPatterns.test(spec)) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0, spec)); - } - else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); - } - else { - validSpecs.push(spec); - } - } - return validSpecs; - } - function getWildcardDirectories(include, exclude, path, useCaseSensitiveFileNames) { - var rawExcludeRegex = ts.getRegularExpressionForWildcard(exclude, path, "exclude"); - var excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames ? "" : "i"); - var wildcardDirectories = ts.createMap(); - if (include !== undefined) { - var recursiveKeys = []; - for (var _i = 0, include_1 = include; _i < include_1.length; _i++) { - var file = include_1[_i]; - var name_6 = ts.normalizePath(ts.combinePaths(path, file)); - if (excludeRegex && excludeRegex.test(name_6)) { - continue; - } - var match = wildcardDirectoryPattern.exec(name_6); - if (match) { - var key = useCaseSensitiveFileNames ? match[0] : match[0].toLowerCase(); - var flags = watchRecursivePattern.test(name_6) ? 1 : 0; - var existingFlags = wildcardDirectories[key]; - if (existingFlags === undefined || existingFlags < flags) { - wildcardDirectories[key] = flags; - if (flags === 1) { - recursiveKeys.push(key); - } - } - } - } - for (var key in wildcardDirectories) { - for (var _a = 0, recursiveKeys_1 = recursiveKeys; _a < recursiveKeys_1.length; _a++) { - var recursiveKey = recursiveKeys_1[_a]; - if (key !== recursiveKey && ts.containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) { - delete wildcardDirectories[key]; - } - } - } - } - return wildcardDirectories; - } - function hasFileWithHigherPriorityExtension(file, literalFiles, wildcardFiles, extensions, keyMapper) { - var extensionPriority = ts.getExtensionPriority(file, extensions); - var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority); - for (var i = 0; i < adjustedExtensionPriority; i++) { - var higherPriorityExtension = extensions[i]; - var higherPriorityPath = keyMapper(ts.changeExtension(file, higherPriorityExtension)); - if (higherPriorityPath in literalFiles || higherPriorityPath in wildcardFiles) { - return true; - } - } - return false; - } - function removeWildcardFilesWithLowerPriorityExtension(file, wildcardFiles, extensions, keyMapper) { - var extensionPriority = ts.getExtensionPriority(file, extensions); - var nextExtensionPriority = ts.getNextLowestExtensionPriority(extensionPriority); - for (var i = nextExtensionPriority; i < extensions.length; i++) { - var lowerPriorityExtension = extensions[i]; - var lowerPriorityPath = keyMapper(ts.changeExtension(file, lowerPriorityExtension)); - delete wildcardFiles[lowerPriorityPath]; - } - } - function addFileToOutput(output, file) { - output.push(file); - return output; - } - function caseSensitiveKeyMapper(key) { - return key; - } - function caseInsensitiveKeyMapper(key) { - return key.toLowerCase(); - } -})(ts || (ts = {})); -var ts; -(function (ts) { - var JsTyping; - (function (JsTyping) { - ; - ; - var safeList; - var EmptySafeList = ts.createMap(); - function discoverTypings(host, fileNames, projectRootPath, safeListPath, packageNameToTypingLocation, typingOptions, compilerOptions) { - var inferredTypings = ts.createMap(); - if (!typingOptions || !typingOptions.enableAutoDiscovery) { - return { cachedTypingPaths: [], newTypingNames: [], filesToWatch: [] }; - } - fileNames = ts.filter(ts.map(fileNames, ts.normalizePath), function (f) { - var kind = ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)); - return kind === 1 || kind === 2; - }); - if (!safeList) { - var result = ts.readConfigFile(safeListPath, function (path) { return host.readFile(path); }); - safeList = result.config ? ts.createMap(result.config) : EmptySafeList; - } - var filesToWatch = []; - var searchDirs = []; - var exclude = []; - mergeTypings(typingOptions.include); - exclude = typingOptions.exclude || []; - var possibleSearchDirs = ts.map(fileNames, ts.getDirectoryPath); - if (projectRootPath !== undefined) { - possibleSearchDirs.push(projectRootPath); - } - searchDirs = ts.deduplicate(possibleSearchDirs); - for (var _i = 0, searchDirs_1 = searchDirs; _i < searchDirs_1.length; _i++) { - var searchDir = searchDirs_1[_i]; - var packageJsonPath = ts.combinePaths(searchDir, "package.json"); - getTypingNamesFromJson(packageJsonPath, filesToWatch); - var bowerJsonPath = ts.combinePaths(searchDir, "bower.json"); - getTypingNamesFromJson(bowerJsonPath, filesToWatch); - var nodeModulesPath = ts.combinePaths(searchDir, "node_modules"); - getTypingNamesFromNodeModuleFolder(nodeModulesPath); - } - getTypingNamesFromSourceFileNames(fileNames); - for (var name_7 in packageNameToTypingLocation) { - if (name_7 in inferredTypings && !inferredTypings[name_7]) { - inferredTypings[name_7] = packageNameToTypingLocation[name_7]; - } - } - for (var _a = 0, exclude_1 = exclude; _a < exclude_1.length; _a++) { - var excludeTypingName = exclude_1[_a]; - delete inferredTypings[excludeTypingName]; - } - var newTypingNames = []; - var cachedTypingPaths = []; - for (var typing in inferredTypings) { - if (inferredTypings[typing] !== undefined) { - cachedTypingPaths.push(inferredTypings[typing]); - } - else { - newTypingNames.push(typing); - } - } - return { cachedTypingPaths: cachedTypingPaths, newTypingNames: newTypingNames, filesToWatch: filesToWatch }; - function mergeTypings(typingNames) { - if (!typingNames) { - return; - } - for (var _i = 0, typingNames_1 = typingNames; _i < typingNames_1.length; _i++) { - var typing = typingNames_1[_i]; - if (!(typing in inferredTypings)) { - inferredTypings[typing] = undefined; - } - } - } - function getTypingNamesFromJson(jsonPath, filesToWatch) { - var result = ts.readConfigFile(jsonPath, function (path) { return host.readFile(path); }); - if (result.config) { - var jsonConfig = result.config; - filesToWatch.push(jsonPath); - if (jsonConfig.dependencies) { - mergeTypings(ts.getOwnKeys(jsonConfig.dependencies)); - } - if (jsonConfig.devDependencies) { - mergeTypings(ts.getOwnKeys(jsonConfig.devDependencies)); - } - if (jsonConfig.optionalDependencies) { - mergeTypings(ts.getOwnKeys(jsonConfig.optionalDependencies)); - } - if (jsonConfig.peerDependencies) { - mergeTypings(ts.getOwnKeys(jsonConfig.peerDependencies)); - } - } - } - function getTypingNamesFromSourceFileNames(fileNames) { - var jsFileNames = ts.filter(fileNames, ts.hasJavaScriptFileExtension); - var inferredTypingNames = ts.map(jsFileNames, function (f) { return ts.removeFileExtension(ts.getBaseFileName(f.toLowerCase())); }); - var cleanedTypingNames = ts.map(inferredTypingNames, function (f) { return f.replace(/((?:\.|-)min(?=\.|$))|((?:-|\.)\d+)/g, ""); }); - if (safeList !== EmptySafeList) { - mergeTypings(ts.filter(cleanedTypingNames, function (f) { return f in safeList; })); - } - var hasJsxFile = ts.forEach(fileNames, function (f) { return ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)) === 2; }); - if (hasJsxFile) { - mergeTypings(["react"]); - } - } - function getTypingNamesFromNodeModuleFolder(nodeModulesPath) { - if (!host.directoryExists(nodeModulesPath)) { - return; - } - var typingNames = []; - var fileNames = host.readDirectory(nodeModulesPath, [".json"], undefined, undefined, 2); - for (var _i = 0, fileNames_2 = fileNames; _i < fileNames_2.length; _i++) { - var fileName = fileNames_2[_i]; - var normalizedFileName = ts.normalizePath(fileName); - if (ts.getBaseFileName(normalizedFileName) !== "package.json") { - continue; - } - var result = ts.readConfigFile(normalizedFileName, function (path) { return host.readFile(path); }); - if (!result.config) { - continue; - } - var packageJson = result.config; - if (packageJson._requiredBy && - ts.filter(packageJson._requiredBy, function (r) { return r[0] === "#" || r === "/"; }).length === 0) { - continue; - } - if (!packageJson.name) { - continue; - } - if (packageJson.typings) { - var absolutePath = ts.getNormalizedAbsolutePath(packageJson.typings, ts.getDirectoryPath(normalizedFileName)); - inferredTypings[packageJson.name] = absolutePath; - } - else { - typingNames.push(packageJson.name); - } - } - mergeTypings(typingNames); - } - } - JsTyping.discoverTypings = discoverTypings; - })(JsTyping = ts.JsTyping || (ts.JsTyping = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var server; - (function (server) { - (function (LogLevel) { - LogLevel[LogLevel["terse"] = 0] = "terse"; - LogLevel[LogLevel["normal"] = 1] = "normal"; - LogLevel[LogLevel["requestTime"] = 2] = "requestTime"; - LogLevel[LogLevel["verbose"] = 3] = "verbose"; - })(server.LogLevel || (server.LogLevel = {})); - var LogLevel = server.LogLevel; - server.emptyArray = []; - var Msg; - (function (Msg) { - Msg.Err = "Err"; - Msg.Info = "Info"; - Msg.Perf = "Perf"; - })(Msg = server.Msg || (server.Msg = {})); - function getProjectRootPath(project) { - switch (project.projectKind) { - case server.ProjectKind.Configured: - return ts.getDirectoryPath(project.getProjectName()); - case server.ProjectKind.Inferred: - return ""; - case server.ProjectKind.External: - var projectName = ts.normalizeSlashes(project.getProjectName()); - return project.projectService.host.fileExists(projectName) ? ts.getDirectoryPath(projectName) : projectName; - } - } - function createInstallTypingsRequest(project, typingOptions, cachePath) { - return { - projectName: project.getProjectName(), - fileNames: project.getFileNames(), - compilerOptions: project.getCompilerOptions(), - typingOptions: typingOptions, - projectRootPath: getProjectRootPath(project), - cachePath: cachePath, - kind: "discover" - }; - } - server.createInstallTypingsRequest = createInstallTypingsRequest; - var Errors; - (function (Errors) { - function ThrowNoProject() { - throw new Error("No Project."); - } - Errors.ThrowNoProject = ThrowNoProject; - function ThrowProjectLanguageServiceDisabled() { - throw new Error("The project's language service is disabled."); - } - Errors.ThrowProjectLanguageServiceDisabled = ThrowProjectLanguageServiceDisabled; - function ThrowProjectDoesNotContainDocument(fileName, project) { - throw new Error("Project '" + project.getProjectName() + "' does not contain document '" + fileName + "'"); - } - Errors.ThrowProjectDoesNotContainDocument = ThrowProjectDoesNotContainDocument; - })(Errors = server.Errors || (server.Errors = {})); - function getDefaultFormatCodeSettings(host) { - return { - indentSize: 4, - tabSize: 4, - newLineCharacter: host.newLine || "\n", - convertTabsToSpaces: true, - indentStyle: ts.IndentStyle.Smart, - insertSpaceAfterCommaDelimiter: true, - insertSpaceAfterSemicolonInForStatements: true, - insertSpaceBeforeAndAfterBinaryOperators: true, - insertSpaceAfterKeywordsInControlFlowStatements: true, - insertSpaceAfterFunctionKeywordForAnonymousFunctions: false, - insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, - insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, - insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, - insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, - placeOpenBraceOnNewLineForFunctions: false, - placeOpenBraceOnNewLineForControlBlocks: false - }; - } - server.getDefaultFormatCodeSettings = getDefaultFormatCodeSettings; - function mergeMaps(target, source) { - for (var key in source) { - if (ts.hasProperty(source, key)) { - target[key] = source[key]; - } - } - } - server.mergeMaps = mergeMaps; - function removeItemFromSet(items, itemToRemove) { - if (items.length === 0) { - return; - } - var index = items.indexOf(itemToRemove); - if (index < 0) { - return; - } - if (index === items.length - 1) { - items.pop(); - } - else { - items[index] = items.pop(); - } - } - server.removeItemFromSet = removeItemFromSet; - function toNormalizedPath(fileName) { - return ts.normalizePath(fileName); - } - server.toNormalizedPath = toNormalizedPath; - function normalizedPathToPath(normalizedPath, currentDirectory, getCanonicalFileName) { - var f = ts.isRootedDiskPath(normalizedPath) ? normalizedPath : ts.getNormalizedAbsolutePath(normalizedPath, currentDirectory); - return getCanonicalFileName(f); - } - server.normalizedPathToPath = normalizedPathToPath; - function asNormalizedPath(fileName) { - return fileName; - } - server.asNormalizedPath = asNormalizedPath; - function createNormalizedPathMap() { - var map = Object.create(null); - return { - get: function (path) { - return map[path]; - }, - set: function (path, value) { - map[path] = value; - }, - contains: function (path) { - return ts.hasProperty(map, path); - }, - remove: function (path) { - delete map[path]; - } - }; - } - server.createNormalizedPathMap = createNormalizedPathMap; - function throwLanguageServiceIsDisabledError() { - throw new Error("LanguageService is disabled"); - } - server.nullLanguageService = { - cleanupSemanticCache: throwLanguageServiceIsDisabledError, - getSyntacticDiagnostics: throwLanguageServiceIsDisabledError, - getSemanticDiagnostics: throwLanguageServiceIsDisabledError, - getCompilerOptionsDiagnostics: throwLanguageServiceIsDisabledError, - getSyntacticClassifications: throwLanguageServiceIsDisabledError, - getEncodedSyntacticClassifications: throwLanguageServiceIsDisabledError, - getSemanticClassifications: throwLanguageServiceIsDisabledError, - getEncodedSemanticClassifications: throwLanguageServiceIsDisabledError, - getCompletionsAtPosition: throwLanguageServiceIsDisabledError, - findReferences: throwLanguageServiceIsDisabledError, - getCompletionEntryDetails: throwLanguageServiceIsDisabledError, - getQuickInfoAtPosition: throwLanguageServiceIsDisabledError, - findRenameLocations: throwLanguageServiceIsDisabledError, - getNameOrDottedNameSpan: throwLanguageServiceIsDisabledError, - getBreakpointStatementAtPosition: throwLanguageServiceIsDisabledError, - getBraceMatchingAtPosition: throwLanguageServiceIsDisabledError, - getSignatureHelpItems: throwLanguageServiceIsDisabledError, - getDefinitionAtPosition: throwLanguageServiceIsDisabledError, - getRenameInfo: throwLanguageServiceIsDisabledError, - getTypeDefinitionAtPosition: throwLanguageServiceIsDisabledError, - getReferencesAtPosition: throwLanguageServiceIsDisabledError, - getDocumentHighlights: throwLanguageServiceIsDisabledError, - getOccurrencesAtPosition: throwLanguageServiceIsDisabledError, - getNavigateToItems: throwLanguageServiceIsDisabledError, - getNavigationBarItems: throwLanguageServiceIsDisabledError, - getNavigationTree: throwLanguageServiceIsDisabledError, - getOutliningSpans: throwLanguageServiceIsDisabledError, - getTodoComments: throwLanguageServiceIsDisabledError, - getIndentationAtPosition: throwLanguageServiceIsDisabledError, - getFormattingEditsForRange: throwLanguageServiceIsDisabledError, - getFormattingEditsForDocument: throwLanguageServiceIsDisabledError, - getFormattingEditsAfterKeystroke: throwLanguageServiceIsDisabledError, - getDocCommentTemplateAtPosition: throwLanguageServiceIsDisabledError, - isValidBraceCompletionAtPosition: throwLanguageServiceIsDisabledError, - getEmitOutput: throwLanguageServiceIsDisabledError, - getProgram: throwLanguageServiceIsDisabledError, - getNonBoundSourceFile: throwLanguageServiceIsDisabledError, - dispose: throwLanguageServiceIsDisabledError, - getCompletionEntrySymbol: throwLanguageServiceIsDisabledError, - getImplementationAtPosition: throwLanguageServiceIsDisabledError, - getSourceFile: throwLanguageServiceIsDisabledError, - getCodeFixesAtPosition: throwLanguageServiceIsDisabledError - }; - server.nullLanguageServiceHost = { - setCompilationSettings: function () { return undefined; }, - notifyFileRemoved: function () { return undefined; } - }; - function isInferredProjectName(name) { - return /dev\/null\/inferredProject\d+\*/.test(name); - } - server.isInferredProjectName = isInferredProjectName; - function makeInferredProjectName(counter) { - return "/dev/null/inferredProject" + counter + "*"; - } - server.makeInferredProjectName = makeInferredProjectName; - var ThrottledOperations = (function () { - function ThrottledOperations(host) { - this.host = host; - this.pendingTimeouts = ts.createMap(); - } - ThrottledOperations.prototype.schedule = function (operationId, delay, cb) { - if (ts.hasProperty(this.pendingTimeouts, operationId)) { - this.host.clearTimeout(this.pendingTimeouts[operationId]); - } - this.pendingTimeouts[operationId] = this.host.setTimeout(ThrottledOperations.run, delay, this, operationId, cb); - }; - ThrottledOperations.run = function (self, operationId, cb) { - delete self.pendingTimeouts[operationId]; - cb(); - }; - return ThrottledOperations; - }()); - server.ThrottledOperations = ThrottledOperations; - var GcTimer = (function () { - function GcTimer(host, delay, logger) { - this.host = host; - this.delay = delay; - this.logger = logger; - } - GcTimer.prototype.scheduleCollect = function () { - if (!this.host.gc || this.timerId != undefined) { - return; - } - this.timerId = this.host.setTimeout(GcTimer.run, this.delay, this); - }; - GcTimer.run = function (self) { - self.timerId = undefined; - var log = self.logger.hasLevel(LogLevel.requestTime); - var before = log && self.host.getMemoryUsage(); - self.host.gc(); - if (log) { - var after = self.host.getMemoryUsage(); - self.logger.perftrc("GC::before " + before + ", after " + after); - } - }; - return GcTimer; - }()); - server.GcTimer = GcTimer; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - function trace(host, message) { + function trace(host) { host.trace(ts.formatMessage.apply(undefined, arguments)); } ts.trace = trace; @@ -6668,11 +4583,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 199: - case 227: - case 206: + case 200: + case 228: case 207: case 208: + case 209: return true; } return false; @@ -6793,13 +4708,13 @@ var ts; switch (node.kind) { case 9: return getQuotedEscapedLiteralText('"', node.text, '"'); - case 11: - return getQuotedEscapedLiteralText("`", node.text, "`"); case 12: - return getQuotedEscapedLiteralText("`", node.text, "${"); + return getQuotedEscapedLiteralText("`", node.text, "`"); case 13: - return getQuotedEscapedLiteralText("}", node.text, "${"); + return getQuotedEscapedLiteralText("`", node.text, "${"); case 14: + return getQuotedEscapedLiteralText("}", node.text, "${"); + case 15: return getQuotedEscapedLiteralText("}", node.text, "`"); case 8: return node.text; @@ -6841,7 +4756,7 @@ var ts; } ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isAmbientModule(node) { - return node && node.kind === 225 && + return node && node.kind === 226 && (node.name.kind === 9 || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; @@ -6850,11 +4765,11 @@ var ts; } ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { - return node.kind === 225 && (!node.body); + return node.kind === 226 && (!node.body); } function isBlockScopedContainerTopLevel(node) { return node.kind === 256 || - node.kind === 225 || + node.kind === 226 || isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -6869,7 +4784,7 @@ var ts; switch (node.parent.kind) { case 256: return ts.isExternalModule(node.parent); - case 226: + case 227: return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -6878,21 +4793,21 @@ var ts; function isBlockScope(node, parentNode) { switch (node.kind) { case 256: - case 227: + case 228: case 252: - case 225: - case 206: + case 226: case 207: case 208: - case 148: - case 147: + case 209: case 149: + case 148: case 150: - case 220: - case 179: + case 151: + case 221: case 180: + case 181: return true; - case 199: + case 200: return parentNode && !isFunctionLike(parentNode); } return false; @@ -6910,7 +4825,7 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 218 && + declaration.kind === 219 && declaration.parent && declaration.parent.kind === 252; } @@ -6947,7 +4862,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 199) { + if (node.body && node.body.kind === 200) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -6965,23 +4880,23 @@ var ts; return ts.createTextSpan(0, 0); } return getSpanOfTokenAtPosition(sourceFile, pos_1); - case 218: - case 169: - case 221: - case 192: + case 219: + case 170: case 222: - case 225: - case 224: - case 255: - case 220: - case 179: - case 147: - case 149: - case 150: + case 193: case 223: + case 226: + case 225: + case 255: + case 221: + case 180: + case 148: + case 150: + case 151: + case 224: errorNode = node.name; break; - case 180: + case 181: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -7002,7 +4917,7 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 224 && isConst(node); + return node.kind === 225 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -7015,11 +4930,11 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 174 && n.expression.kind === 95; + return n.kind === 175 && n.expression.kind === 96; } ts.isSuperCall = isSuperCall; function isPrologueDirective(node) { - return node.kind === 202 && node.expression.kind === 9; + return node.kind === 203 && node.expression.kind === 9; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { @@ -7035,10 +4950,10 @@ var ts; } ts.getJsDocComments = getJsDocComments; function getJsDocCommentsFromText(node, text) { - var commentRanges = (node.kind === 142 || - node.kind === 141 || - node.kind === 179 || - node.kind === 180) ? + var commentRanges = (node.kind === 143 || + node.kind === 142 || + node.kind === 180 || + node.kind === 181) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : getLeadingCommentRangesOfNodeFromText(node, text); return ts.filter(commentRanges, isJsDocComment); @@ -7053,69 +4968,69 @@ var ts; ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (154 <= node.kind && node.kind <= 166) { + if (155 <= node.kind && node.kind <= 167) { return true; } switch (node.kind) { - case 117: - case 130: - case 132: - case 120: + case 118: + case 131: case 133: - case 135: - case 127: + case 121: + case 134: + case 136: + case 128: return true; - case 103: - return node.parent.kind !== 183; - case 194: + case 104: + return node.parent.kind !== 184; + case 195: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 69: - if (node.parent.kind === 139 && node.parent.right === node) { + case 70: + if (node.parent.kind === 140 && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 172 && node.parent.name === node) { + else if (node.parent.kind === 173 && node.parent.name === node) { node = node.parent; } - ts.Debug.assert(node.kind === 69 || node.kind === 139 || node.kind === 172, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); - case 139: - case 172: - case 97: + ts.Debug.assert(node.kind === 70 || node.kind === 140 || node.kind === 173, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + case 140: + case 173: + case 98: var parent_2 = node.parent; - if (parent_2.kind === 158) { + if (parent_2.kind === 159) { return false; } - if (154 <= parent_2.kind && parent_2.kind <= 166) { + if (155 <= parent_2.kind && parent_2.kind <= 167) { return true; } switch (parent_2.kind) { - case 194: + case 195: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); - case 141: - return node === parent_2.constraint; - case 145: - case 144: case 142: - case 218: + return node === parent_2.constraint; + case 146: + case 145: + case 143: + case 219: return node === parent_2.type; - case 220: - case 179: + case 221: case 180: + case 181: + case 149: case 148: case 147: - case 146: - case 149: case 150: - return node === parent_2.type; case 151: + return node === parent_2.type; case 152: case 153: + case 154: return node === parent_2.type; - case 177: + case 178: return node === parent_2.type; - case 174: case 175: - return parent_2.typeArguments && ts.indexOf(parent_2.typeArguments, node) >= 0; case 176: + return parent_2.typeArguments && ts.indexOf(parent_2.typeArguments, node) >= 0; + case 177: return false; } } @@ -7126,22 +5041,22 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 211: + case 212: return visitor(node); - case 227: - case 199: - case 203: + case 228: + case 200: case 204: case 205: case 206: case 207: case 208: - case 212: + case 209: case 213: + case 214: case 249: case 250: - case 214: - case 216: + case 215: + case 217: case 252: return ts.forEachChild(node, traverse); } @@ -7152,24 +5067,24 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 190: + case 191: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 224: - case 222: case 225: case 223: - case 221: - case 192: + case 226: + case 224: + case 222: + case 193: return; default: if (isFunctionLike(node)) { - var name_8 = node.name; - if (name_8 && name_8.kind === 140) { - traverse(name_8.expression); + var name_4 = node.name; + if (name_4 && name_4.kind === 141) { + traverse(name_4.expression); return; } } @@ -7183,14 +5098,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 169: + case 170: case 255: - case 142: + case 143: case 253: + case 146: case 145: - case 144: case 254: - case 218: + case 219: return true; } } @@ -7198,11 +5113,11 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 149 || node.kind === 150); + return node && (node.kind === 150 || node.kind === 151); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 221 || node.kind === 192); + return node && (node.kind === 222 || node.kind === 193); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -7211,19 +5126,19 @@ var ts; ts.isFunctionLike = isFunctionLike; function isFunctionLikeKind(kind) { switch (kind) { - case 148: - case 179: - case 220: - case 180: - case 147: - case 146: case 149: + case 180: + case 221: + case 181: + case 148: + case 147: case 150: case 151: case 152: case 153: - case 156: + case 154: case 157: + case 158: return true; } return false; @@ -7231,13 +5146,13 @@ var ts; ts.isFunctionLikeKind = isFunctionLikeKind; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 147: - case 146: case 148: + case 147: case 149: case 150: - case 220: - case 179: + case 151: + case 221: + case 180: return true; } return false; @@ -7245,30 +5160,30 @@ var ts; ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 206: case 207: case 208: - case 204: + case 209: case 205: + case 206: return true; - case 214: + case 215: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; function isFunctionBlock(node) { - return node && node.kind === 199 && isFunctionLike(node.parent); + return node && node.kind === 200 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 147 && node.parent.kind === 171; + return node && node.kind === 148 && node.parent.kind === 172; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 147 && - (node.parent.kind === 171 || - node.parent.kind === 192); + return node.kind === 148 && + (node.parent.kind === 172 || + node.parent.kind === 193); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -7304,38 +5219,38 @@ var ts; return undefined; } switch (node.kind) { - case 140: + case 141: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 143: - if (node.parent.kind === 142 && isClassElement(node.parent.parent)) { + case 144: + if (node.parent.kind === 143 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 180: + case 181: if (!includeArrowFunctions) { continue; } - case 220: - case 179: - case 225: - case 145: - case 144: - case 147: + case 221: + case 180: + case 226: case 146: + case 145: case 148: + case 147: case 149: case 150: case 151: case 152: case 153: - case 224: + case 154: + case 225: case 256: return node; } @@ -7349,25 +5264,25 @@ var ts; return node; } switch (node.kind) { - case 140: + case 141: node = node.parent; break; - case 220: - case 179: + case 221: case 180: + case 181: if (!stopOnFunctions) { continue; } - case 145: - case 144: - case 147: case 146: + case 145: case 148: + case 147: case 149: case 150: + case 151: return node; - case 143: - if (node.parent.kind === 142 && isClassElement(node.parent.parent)) { + case 144: + if (node.parent.kind === 143 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { @@ -7379,14 +5294,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 179 || func.kind === 180) { + if (func.kind === 180 || func.kind === 181) { var prev = func; var parent_3 = func.parent; - while (parent_3.kind === 178) { + while (parent_3.kind === 179) { prev = parent_3; parent_3 = parent_3.parent; } - if (parent_3.kind === 174 && parent_3.expression === prev) { + if (parent_3.kind === 175 && parent_3.expression === prev) { return parent_3; } } @@ -7394,20 +5309,20 @@ var ts; ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperProperty(node) { var kind = node.kind; - return (kind === 172 || kind === 173) - && node.expression.kind === 95; + return (kind === 173 || kind === 174) + && node.expression.kind === 96; } ts.isSuperProperty = isSuperProperty; function getEntityNameFromTypeNode(node) { if (node) { switch (node.kind) { - case 155: + case 156: return node.typeName; - case 194: + case 195: ts.Debug.assert(isEntityNameExpression(node.expression)); return node.expression; - case 69: - case 139: + case 70: + case 140: return node; } } @@ -7416,10 +5331,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function isCallLikeExpression(node) { switch (node.kind) { - case 174: case 175: case 176: - case 143: + case 177: + case 144: return true; default: return false; @@ -7427,7 +5342,7 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function getInvokedExpression(node) { - if (node.kind === 176) { + if (node.kind === 177) { return node.tag; } return node.expression; @@ -7435,21 +5350,21 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 221: + case 222: return true; - case 145: - return node.parent.kind === 221; - case 149: + case 146: + return node.parent.kind === 222; case 150: - case 147: + case 151: + case 148: return node.body !== undefined - && node.parent.kind === 221; - case 142: + && node.parent.kind === 222; + case 143: return node.parent.body !== undefined - && (node.parent.kind === 148 - || node.parent.kind === 147 - || node.parent.kind === 150) - && node.parent.parent.kind === 221; + && (node.parent.kind === 149 + || node.parent.kind === 148 + || node.parent.kind === 151) + && node.parent.parent.kind === 222; } return false; } @@ -7465,18 +5380,18 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 221: + case 222: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 147: - case 150: + case 148: + case 151: return ts.forEach(node.parameters, nodeIsDecorated); } } ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 243 || - parent.kind === 242 || + if (parent.kind === 244 || + parent.kind === 243 || parent.kind === 245) { return parent.tagName === node; } @@ -7485,97 +5400,97 @@ var ts; ts.isJSXTagName = isJSXTagName; function isPartOfExpression(node) { switch (node.kind) { - case 97: - case 95: - case 93: - case 99: - case 84: - case 10: - case 170: + case 98: + case 96: + case 94: + case 100: + case 85: + case 11: case 171: case 172: case 173: case 174: case 175: case 176: - case 195: case 177: case 196: case 178: + case 197: case 179: - case 192: case 180: - case 183: + case 193: case 181: + case 184: case 182: - case 185: + case 183: case 186: case 187: case 188: - case 191: case 189: - case 11: - case 193: - case 241: - case 242: + case 192: case 190: - case 184: + case 12: + case 194: + case 242: + case 243: + case 191: + case 185: return true; - case 139: - while (node.parent.kind === 139) { + case 140: + while (node.parent.kind === 140) { node = node.parent; } - return node.parent.kind === 158 || isJSXTagName(node); - case 69: - if (node.parent.kind === 158 || isJSXTagName(node)) { + return node.parent.kind === 159 || isJSXTagName(node); + case 70: + if (node.parent.kind === 159 || isJSXTagName(node)) { return true; } case 8: case 9: - case 97: + case 98: var parent_4 = node.parent; switch (parent_4.kind) { - case 218: - case 142: + case 219: + case 143: + case 146: case 145: - case 144: case 255: case 253: - case 169: + case 170: return parent_4.initializer === node; - case 202: case 203: case 204: case 205: - case 211: + case 206: case 212: case 213: + case 214: case 249: - case 215: - case 213: + case 216: + case 214: return parent_4.expression === node; - case 206: + case 207: var forStatement = parent_4; - return (forStatement.initializer === node && forStatement.initializer.kind !== 219) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 220) || forStatement.condition === node || forStatement.incrementor === node; - case 207: case 208: + case 209: var forInStatement = parent_4; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 219) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 220) || forInStatement.expression === node; - case 177: - case 195: + case 178: + case 196: return node === parent_4.expression; - case 197: + case 198: return node === parent_4.expression; - case 140: + case 141: return node === parent_4.expression; - case 143: + case 144: case 248: case 247: return true; - case 194: + case 195: return parent_4.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_4); default: if (isPartOfExpression(parent_4)) { @@ -7593,7 +5508,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 229 && node.moduleReference.kind === 240; + return node.kind === 230 && node.moduleReference.kind === 241; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -7602,7 +5517,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 229 && node.moduleReference.kind !== 240; + return node.kind === 230 && node.moduleReference.kind !== 241; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -7614,8 +5529,8 @@ var ts; } ts.isInJavaScriptFile = isInJavaScriptFile; function isRequireCall(expression, checkArgumentIsStringLiteral) { - var isRequire = expression.kind === 174 && - expression.expression.kind === 69 && + var isRequire = expression.kind === 175 && + expression.expression.kind === 70 && expression.expression.text === "require" && expression.arguments.length === 1; return isRequire && (!checkArgumentIsStringLiteral || expression.arguments[0].kind === 9); @@ -7626,9 +5541,9 @@ var ts; } ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote; function isDeclarationOfFunctionExpression(s) { - if (s.valueDeclaration && s.valueDeclaration.kind === 218) { + if (s.valueDeclaration && s.valueDeclaration.kind === 219) { var declaration = s.valueDeclaration; - return declaration.initializer && declaration.initializer.kind === 179; + return declaration.initializer && declaration.initializer.kind === 180; } return false; } @@ -7637,15 +5552,15 @@ var ts; if (!isInJavaScriptFile(expression)) { return 0; } - if (expression.kind !== 187) { + if (expression.kind !== 188) { return 0; } var expr = expression; - if (expr.operatorToken.kind !== 56 || expr.left.kind !== 172) { + if (expr.operatorToken.kind !== 57 || expr.left.kind !== 173) { return 0; } var lhs = expr.left; - if (lhs.expression.kind === 69) { + if (lhs.expression.kind === 70) { var lhsId = lhs.expression; if (lhsId.text === "exports") { return 1; @@ -7654,12 +5569,12 @@ var ts; return 2; } } - else if (lhs.expression.kind === 97) { + else if (lhs.expression.kind === 98) { return 4; } - else if (lhs.expression.kind === 172) { + else if (lhs.expression.kind === 173) { var innerPropertyAccess = lhs.expression; - if (innerPropertyAccess.expression.kind === 69) { + if (innerPropertyAccess.expression.kind === 70) { var innerPropertyAccessIdentifier = innerPropertyAccess.expression; if (innerPropertyAccessIdentifier.text === "module" && innerPropertyAccess.name.text === "exports") { return 1; @@ -7673,35 +5588,35 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 230) { + if (node.kind === 231) { return node.moduleSpecifier; } - if (node.kind === 229) { + if (node.kind === 230) { var reference = node.moduleReference; - if (reference.kind === 240) { + if (reference.kind === 241) { return reference.expression; } } - if (node.kind === 236) { + if (node.kind === 237) { return node.moduleSpecifier; } - if (node.kind === 225 && node.name.kind === 9) { + if (node.kind === 226 && node.name.kind === 9) { return node.name; } } ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { - if (node.kind === 229) { + if (node.kind === 230) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 232) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 233) { return importClause.namedBindings; } } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 230 + return node.kind === 231 && node.importClause && !!node.importClause.name; } @@ -7709,13 +5624,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 142: + case 143: + case 148: case 147: - case 146: case 254: case 253: + case 146: case 145: - case 144: return node.questionToken !== undefined; } } @@ -7776,24 +5691,24 @@ var ts; if (checkParentVariableStatement) { var isInitializerOfVariableDeclarationInStatement = isVariableLike(node.parent) && (node.parent).initializer === node && - node.parent.parent.parent.kind === 200; + node.parent.parent.parent.kind === 201; var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - node.parent.parent.kind === 200; + node.parent.parent.kind === 201; var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? node.parent.parent.parent : isVariableOfVariableDeclarationStatement ? node.parent.parent : undefined; if (variableStatementNode) { result = append(result, getJSDocs(variableStatementNode, checkParentVariableStatement, getDocs, getTags)); } - if (node.kind === 225 && - node.parent && node.parent.kind === 225) { + if (node.kind === 226 && + node.parent && node.parent.kind === 226) { result = append(result, getJSDocs(node.parent, checkParentVariableStatement, getDocs, getTags)); } var parent_5 = node.parent; var isSourceOfAssignmentExpressionStatement = parent_5 && parent_5.parent && - parent_5.kind === 187 && - parent_5.operatorToken.kind === 56 && - parent_5.parent.kind === 202; + parent_5.kind === 188 && + parent_5.operatorToken.kind === 57 && + parent_5.parent.kind === 203; if (isSourceOfAssignmentExpressionStatement) { result = append(result, getJSDocs(parent_5.parent, checkParentVariableStatement, getDocs, getTags)); } @@ -7801,7 +5716,7 @@ var ts; if (isPropertyAssignmentExpression) { result = append(result, getJSDocs(parent_5, checkParentVariableStatement, getDocs, getTags)); } - if (node.kind === 142) { + if (node.kind === 143) { var paramTags = getJSDocParameterTag(node, checkParentVariableStatement); if (paramTags) { result = append(result, getTags(paramTags)); @@ -7831,9 +5746,9 @@ var ts; return [paramTags[i]]; } } - else if (param.name.kind === 69) { - var name_9 = param.name.text; - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 275 && tag.parameterName.text === name_9; }); + else if (param.name.kind === 70) { + var name_5 = param.name.text; + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 275 && tag.parameterName.text === name_5; }); if (paramTags) { return paramTags; } @@ -7855,7 +5770,7 @@ var ts; } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { - if (parameter.name && parameter.name.kind === 69) { + if (parameter.name && parameter.name.kind === 70) { var parameterName = parameter.name.text; var jsDocTags = getJSDocTags(parameter.parent, true); if (!jsDocTags) { @@ -7900,12 +5815,12 @@ var ts; } ts.isDeclaredRestParam = isDeclaredRestParam; function isAssignmentTarget(node) { - while (node.parent.kind === 178) { + while (node.parent.kind === 179) { node = node.parent; } while (true) { var parent_6 = node.parent; - if (parent_6.kind === 170 || parent_6.kind === 191) { + if (parent_6.kind === 171 || parent_6.kind === 192) { node = parent_6; continue; } @@ -7913,10 +5828,10 @@ var ts; node = parent_6.parent; continue; } - return parent_6.kind === 187 && + return parent_6.kind === 188 && isAssignmentOperator(parent_6.operatorToken.kind) && parent_6.left === node || - (parent_6.kind === 207 || parent_6.kind === 208) && + (parent_6.kind === 208 || parent_6.kind === 209) && parent_6.initializer === node; } } @@ -7941,11 +5856,11 @@ var ts; } ts.isInAmbientContext = isInAmbientContext; function isDeclarationName(name) { - if (name.kind !== 69 && name.kind !== 9 && name.kind !== 8) { + if (name.kind !== 70 && name.kind !== 9 && name.kind !== 8) { return false; } var parent = name.parent; - if (parent.kind === 234 || parent.kind === 238) { + if (parent.kind === 235 || parent.kind === 239) { if (parent.propertyName) { return true; } @@ -7958,48 +5873,48 @@ var ts; ts.isDeclarationName = isDeclarationName; function isLiteralComputedPropertyDeclarationName(node) { return (node.kind === 9 || node.kind === 8) && - node.parent.kind === 140 && + node.parent.kind === 141 && isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 145: - case 144: - case 147: case 146: - case 149: + case 145: + case 148: + case 147: case 150: + case 151: case 255: case 253: - case 172: + case 173: return parent.name === node; - case 139: + case 140: if (parent.right === node) { - while (parent.kind === 139) { + while (parent.kind === 140) { parent = parent.parent; } - return parent.kind === 158; + return parent.kind === 159; } return false; - case 169: - case 234: + case 170: + case 235: return parent.propertyName === node; - case 238: + case 239: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 229 || - node.kind === 228 || - node.kind === 231 && !!node.name || - node.kind === 232 || - node.kind === 234 || - node.kind === 238 || - node.kind === 235 && exportAssignmentIsAlias(node); + return node.kind === 230 || + node.kind === 229 || + node.kind === 232 && !!node.name || + node.kind === 233 || + node.kind === 235 || + node.kind === 239 || + node.kind === 236 && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function exportAssignmentIsAlias(node) { @@ -8007,17 +5922,17 @@ var ts; } ts.exportAssignmentIsAlias = exportAssignmentIsAlias; function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 83); + var heritageClause = getHeritageClause(node.heritageClauses, 84); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 106); + var heritageClause = getHeritageClause(node.heritageClauses, 107); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 83); + var heritageClause = getHeritageClause(node.heritageClauses, 84); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -8085,7 +6000,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 70 <= token && token <= 138; + return 71 <= token && token <= 139; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -8105,7 +6020,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 140 && + return name.kind === 141 && !isStringOrNumericLiteral(name.expression.kind) && !isWellKnownSymbolSyntactically(name.expression); } @@ -8115,10 +6030,10 @@ var ts; } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 69 || name.kind === 9 || name.kind === 8 || name.kind === 142) { + if (name.kind === 70 || name.kind === 9 || name.kind === 8 || name.kind === 143) { return name.text; } - if (name.kind === 140) { + if (name.kind === 141) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -8136,22 +6051,26 @@ var ts; } ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; function isESSymbolIdentifier(node) { - return node.kind === 69 && node.text === "Symbol"; + return node.kind === 70 && node.text === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; + function isPushOrUnshiftIdentifier(node) { + return node.text === "push" || node.text === "unshift"; + } + ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isModifierKind(token) { switch (token) { - case 115: - case 118: - case 74: - case 122: - case 77: - case 82: - case 112: - case 110: - case 111: - case 128: + case 116: + case 119: + case 75: + case 123: + case 78: + case 83: case 113: + case 111: + case 112: + case 129: + case 114: return true; } return false; @@ -8159,11 +6078,11 @@ var ts; ts.isModifierKind = isModifierKind; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 142; + return root.kind === 143; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 169) { + while (node.kind === 170) { node = node.parent.parent; } return node; @@ -8171,14 +6090,14 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 148 - || kind === 179 - || kind === 220 + return kind === 149 || kind === 180 - || kind === 147 - || kind === 149 + || kind === 221 + || kind === 181 + || kind === 148 || kind === 150 - || kind === 225 + || kind === 151 + || kind === 226 || kind === 256; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; @@ -8228,40 +6147,45 @@ var ts; return node ? ts.getNodeId(node) : 0; } ts.getOriginalNodeId = getOriginalNodeId; + (function (Associativity) { + Associativity[Associativity["Left"] = 0] = "Left"; + Associativity[Associativity["Right"] = 1] = "Right"; + })(ts.Associativity || (ts.Associativity = {})); + var Associativity = ts.Associativity; function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 175 && expression.arguments !== undefined; + var hasArguments = expression.kind === 176 && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 175: + case 176: return hasArguments ? 0 : 1; - case 185: - case 182: + case 186: case 183: - case 181: case 184: - case 188: - case 190: + case 182: + case 185: + case 189: + case 191: return 1; - case 187: + case 188: switch (operator) { - case 38: - case 56: + case 39: case 57: case 58: - case 60: case 59: case 61: + case 60: case 62: case 63: case 64: case 65: case 66: - case 68: case 67: + case 69: + case 68: return 1; } } @@ -8270,15 +6194,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 175 && expression.arguments !== undefined; + var hasArguments = expression.kind === 176 && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 187) { + if (expression.kind === 188) { return expression.operatorToken.kind; } - else if (expression.kind === 185 || expression.kind === 186) { + else if (expression.kind === 186 || expression.kind === 187) { return expression.operator; } else { @@ -8288,106 +6212,106 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 97: - case 95: - case 69: - case 93: - case 99: - case 84: + case 98: + case 96: + case 70: + case 94: + case 100: + case 85: case 8: case 9: - case 170: case 171: - case 179: - case 180: - case 192: - case 241: - case 242: - case 10: - case 11: - case 189: - case 178: - case 193: - return 19; - case 176: case 172: - case 173: - return 18; - case 175: - return hasArguments ? 18 : 17; - case 174: - return 17; - case 186: - return 16; - case 185: - case 182: - case 183: + case 180: case 181: - case 184: - return 15; + case 193: + case 242: + case 243: + case 11: + case 12: + case 190: + case 179: + case 194: + return 19; + case 177: + case 173: + case 174: + return 18; + case 176: + return hasArguments ? 18 : 17; + case 175: + return 17; case 187: + return 16; + case 186: + case 183: + case 184: + case 182: + case 185: + return 15; + case 188: switch (operatorKind) { - case 49: case 50: + case 51: return 15; - case 38: - case 37: case 39: + case 38: case 40: + case 41: return 14; - case 35: case 36: + case 37: return 13; - case 43: case 44: case 45: + case 46: return 12; - case 25: - case 28: - case 27: + case 26: case 29: - case 90: - case 91: - return 11; + case 28: case 30: - case 32: + case 91: + case 92: + return 11; case 31: case 33: + case 32: + case 34: return 10; - case 46: - return 9; - case 48: - return 8; case 47: + return 9; + case 49: + return 8; + case 48: return 7; - case 51: - return 6; case 52: + return 6; + case 53: return 5; - case 56: case 57: case 58: - case 60: case 59: case 61: + case 60: case 62: case 63: case 64: case 65: case 66: - case 68: case 67: + case 69: + case 68: return 3; - case 24: + case 25: return 0; default: return -1; } - case 188: + case 189: return 4; - case 190: - return 2; case 191: + return 2; + case 192: return 1; default: return -1; @@ -8651,7 +6575,7 @@ var ts; function forEachTransformedEmitFile(host, sourceFiles, action, emitOnlyDtsFiles) { var options = host.getCompilerOptions(); if (options.outFile || options.out) { - onBundledEmit(host, sourceFiles); + onBundledEmit(sourceFiles); } else { for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { @@ -8678,7 +6602,7 @@ var ts; var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (options.declaration || emitOnlyDtsFiles) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; action(jsFilePath, sourceMapFilePath, declarationFilePath, [sourceFile], false); } - function onBundledEmit(host, sourceFiles) { + function onBundledEmit(sourceFiles) { if (sourceFiles.length) { var jsFilePath = options.outFile || options.out; var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); @@ -8767,7 +6691,7 @@ var ts; ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 148 && nodeIsPresent(member.body)) { + if (member.kind === 149 && nodeIsPresent(member.body)) { return member; } }); @@ -8794,11 +6718,11 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return node && node.kind === 69 && identifierIsThisKeyword(node); + return node && node.kind === 70 && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 97; + return id.originalKeywordKind === 98; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -8808,10 +6732,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 149) { + if (accessor.kind === 150) { getAccessor = accessor; } - else if (accessor.kind === 150) { + else if (accessor.kind === 151) { setAccessor = accessor; } else { @@ -8820,7 +6744,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 149 || member.kind === 150) + if ((member.kind === 150 || member.kind === 151) && hasModifier(member, 32) === hasModifier(accessor, 32)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -8831,10 +6755,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 149 && !getAccessor) { + if (member.kind === 150 && !getAccessor) { getAccessor = member; } - if (member.kind === 150 && !setAccessor) { + if (member.kind === 151 && !setAccessor) { setAccessor = member; } } @@ -9026,34 +6950,34 @@ var ts; ts.getModifierFlags = getModifierFlags; function modifierToFlag(token) { switch (token) { - case 113: return 32; - case 112: return 4; - case 111: return 16; - case 110: return 8; - case 115: return 128; - case 82: return 1; - case 122: return 2; - case 74: return 2048; - case 77: return 512; - case 118: return 256; - case 128: return 64; + case 114: return 32; + case 113: return 4; + case 112: return 16; + case 111: return 8; + case 116: return 128; + case 83: return 1; + case 123: return 2; + case 75: return 2048; + case 78: return 512; + case 119: return 256; + case 129: return 64; } return 0; } ts.modifierToFlag = modifierToFlag; function isLogicalOperator(token) { - return token === 52 - || token === 51 - || token === 49; + return token === 53 + || token === 52 + || token === 50; } ts.isLogicalOperator = isLogicalOperator; function isAssignmentOperator(token) { - return token >= 56 && token <= 68; + return token >= 57 && token <= 69; } ts.isAssignmentOperator = isAssignmentOperator; function tryGetClassExtendingExpressionWithTypeArguments(node) { - if (node.kind === 194 && - node.parent.token === 83 && + if (node.kind === 195 && + node.parent.token === 84 && isClassLike(node.parent.parent)) { return node.parent.parent; } @@ -9061,10 +6985,10 @@ var ts; ts.tryGetClassExtendingExpressionWithTypeArguments = tryGetClassExtendingExpressionWithTypeArguments; function isDestructuringAssignment(node) { if (isBinaryExpression(node)) { - if (node.operatorToken.kind === 56) { + if (node.operatorToken.kind === 57) { var kind = node.left.kind; - return kind === 171 - || kind === 170; + return kind === 172 + || kind === 171; } } return false; @@ -9075,7 +6999,7 @@ var ts; } ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 69) { + if (node.kind === 70) { return true; } else if (isPropertyAccessExpression(node)) { @@ -9090,21 +7014,21 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { - return node.kind === 69 || - node.kind === 172 && isEntityNameExpression(node.expression); + return node.kind === 70 || + node.kind === 173 && isEntityNameExpression(node.expression); } ts.isEntityNameExpression = isEntityNameExpression; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 139 && node.parent.right === node) || - (node.parent.kind === 172 && node.parent.name === node); + return (node.parent.kind === 140 && node.parent.right === node) || + (node.parent.kind === 173 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteralOrArrayLiteral(expression) { var kind = expression.kind; - if (kind === 171) { + if (kind === 172) { return expression.properties.length === 0; } - if (kind === 170) { + if (kind === 171) { return expression.elements.length === 0; } return false; @@ -9228,49 +7152,49 @@ var ts; var kind = node.kind; if (kind === 9 || kind === 8 - || kind === 10 || kind === 11 - || kind === 69 - || kind === 97 - || kind === 95 - || kind === 99 - || kind === 84 - || kind === 93) { + || kind === 12 + || kind === 70 + || kind === 98 + || kind === 96 + || kind === 100 + || kind === 85 + || kind === 94) { return true; } - else if (kind === 172) { + else if (kind === 173) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 173) { + else if (kind === 174) { return isSimpleExpressionWorker(node.expression, depth + 1) && isSimpleExpressionWorker(node.argumentExpression, depth + 1); } - else if (kind === 185 - || kind === 186) { + else if (kind === 186 + || kind === 187) { return isSimpleExpressionWorker(node.operand, depth + 1); } - else if (kind === 187) { - return node.operatorToken.kind !== 38 + else if (kind === 188) { + return node.operatorToken.kind !== 39 && isSimpleExpressionWorker(node.left, depth + 1) && isSimpleExpressionWorker(node.right, depth + 1); } - else if (kind === 188) { + else if (kind === 189) { return isSimpleExpressionWorker(node.condition, depth + 1) && isSimpleExpressionWorker(node.whenTrue, depth + 1) && isSimpleExpressionWorker(node.whenFalse, depth + 1); } - else if (kind === 183 - || kind === 182 - || kind === 181) { + else if (kind === 184 + || kind === 183 + || kind === 182) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 170) { + else if (kind === 171) { return node.elements.length === 0; } - else if (kind === 171) { + else if (kind === 172) { return node.properties.length === 0; } - else if (kind === 174) { + else if (kind === 175) { if (!isSimpleExpressionWorker(node.expression, depth + 1)) { return false; } @@ -9292,9 +7216,9 @@ var ts; if (syntaxKindCache[kind]) { return syntaxKindCache[kind]; } - for (var name_10 in syntaxKindEnum) { - if (syntaxKindEnum[name_10] === kind) { - return syntaxKindCache[kind] = kind.toString() + " (" + name_10 + ")"; + for (var name_6 in syntaxKindEnum) { + if (syntaxKindEnum[name_6] === kind) { + return syntaxKindCache[kind] = kind.toString() + " (" + name_6 + ")"; } } } @@ -9376,7 +7300,7 @@ var ts; return ts.positionIsSynthesized(range.pos) ? -1 : ts.skipTrivia(sourceFile.text, range.pos); } ts.getStartPositionOfRange = getStartPositionOfRange; - function collectExternalModuleInfo(sourceFile, resolver) { + function collectExternalModuleInfo(sourceFile) { var externalImports = []; var exportSpecifiers = ts.createMap(); var exportEquals = undefined; @@ -9384,38 +7308,33 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { + case 231: + externalImports.push(node); + break; case 230: - if (!node.importClause || - resolver.isReferencedAliasDeclaration(node.importClause, true)) { + if (node.moduleReference.kind === 241) { externalImports.push(node); } break; - case 229: - if (node.moduleReference.kind === 240 && resolver.isReferencedAliasDeclaration(node)) { - externalImports.push(node); - } - break; - case 236: + case 237: if (node.moduleSpecifier) { if (!node.exportClause) { - if (resolver.moduleExportsSomeValue(node.moduleSpecifier)) { - externalImports.push(node); - hasExportStarsToExportValues = true; - } + externalImports.push(node); + hasExportStarsToExportValues = true; } - else if (resolver.isValueAliasDeclaration(node)) { + else { externalImports.push(node); } } else { for (var _b = 0, _c = node.exportClause.elements; _b < _c.length; _b++) { var specifier = _c[_b]; - var name_11 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_11] || (exportSpecifiers[name_11] = [])).push(specifier); + var name_7 = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[name_7] || (exportSpecifiers[name_7] = [])).push(specifier); } } break; - case 235: + case 236: if (node.isExportEquals && !exportEquals) { exportEquals = node; } @@ -9436,7 +7355,7 @@ var ts; if (node.symbol) { for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 221 && declaration !== node) { + if (declaration.kind === 222 && declaration !== node) { return true; } } @@ -9454,15 +7373,15 @@ var ts; } ts.isNodeArray = isNodeArray; function isNoSubstitutionTemplateLiteral(node) { - return node.kind === 11; + return node.kind === 12; } ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral; function isLiteralKind(kind) { - return 8 <= kind && kind <= 11; + return 8 <= kind && kind <= 12; } ts.isLiteralKind = isLiteralKind; function isTextualLiteralKind(kind) { - return kind === 9 || kind === 11; + return kind === 9 || kind === 12; } ts.isTextualLiteralKind = isTextualLiteralKind; function isLiteralExpression(node) { @@ -9470,21 +7389,21 @@ var ts; } ts.isLiteralExpression = isLiteralExpression; function isTemplateLiteralKind(kind) { - return 11 <= kind && kind <= 14; + return 12 <= kind && kind <= 15; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isTemplateHead(node) { - return node.kind === 12; + return node.kind === 13; } ts.isTemplateHead = isTemplateHead; function isTemplateMiddleOrTemplateTail(node) { var kind = node.kind; - return kind === 13 - || kind === 14; + return kind === 14 + || kind === 15; } ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; function isIdentifier(node) { - return node.kind === 69; + return node.kind === 70; } ts.isIdentifier = isIdentifier; function isGeneratedIdentifier(node) { @@ -9496,87 +7415,87 @@ var ts; } ts.isModifier = isModifier; function isQualifiedName(node) { - return node.kind === 139; + return node.kind === 140; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 140; + return node.kind === 141; } ts.isComputedPropertyName = isComputedPropertyName; function isEntityName(node) { var kind = node.kind; - return kind === 139 - || kind === 69; + return kind === 140 + || kind === 70; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 69 + return kind === 70 || kind === 9 || kind === 8 - || kind === 140; + || kind === 141; } ts.isPropertyName = isPropertyName; function isModuleName(node) { var kind = node.kind; - return kind === 69 + return kind === 70 || kind === 9; } ts.isModuleName = isModuleName; function isBindingName(node) { var kind = node.kind; - return kind === 69 - || kind === 167 - || kind === 168; + return kind === 70 + || kind === 168 + || kind === 169; } ts.isBindingName = isBindingName; function isTypeParameter(node) { - return node.kind === 141; + return node.kind === 142; } ts.isTypeParameter = isTypeParameter; function isParameter(node) { - return node.kind === 142; + return node.kind === 143; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 143; + return node.kind === 144; } ts.isDecorator = isDecorator; function isMethodDeclaration(node) { - return node.kind === 147; + return node.kind === 148; } ts.isMethodDeclaration = isMethodDeclaration; function isClassElement(node) { var kind = node.kind; - return kind === 148 - || kind === 145 - || kind === 147 - || kind === 149 + return kind === 149 + || kind === 146 + || kind === 148 || kind === 150 - || kind === 153 - || kind === 198; + || kind === 151 + || kind === 154 + || kind === 199; } ts.isClassElement = isClassElement; function isObjectLiteralElementLike(node) { var kind = node.kind; return kind === 253 || kind === 254 - || kind === 147 - || kind === 149 + || kind === 148 || kind === 150 - || kind === 239; + || kind === 151 + || kind === 240; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; function isTypeNodeKind(kind) { - return (kind >= 154 && kind <= 166) - || kind === 117 - || kind === 130 - || kind === 120 - || kind === 132 + return (kind >= 155 && kind <= 167) + || kind === 118 + || kind === 131 + || kind === 121 || kind === 133 - || kind === 103 - || kind === 127 - || kind === 194; + || kind === 134 + || kind === 104 + || kind === 128 + || kind === 195; } function isTypeNode(node) { return isTypeNodeKind(node.kind); @@ -9585,94 +7504,94 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 168 - || kind === 167; + return kind === 169 + || kind === 168; } return false; } ts.isBindingPattern = isBindingPattern; function isBindingElement(node) { - return node.kind === 169; + return node.kind === 170; } ts.isBindingElement = isBindingElement; function isArrayBindingElement(node) { var kind = node.kind; - return kind === 169 - || kind === 193; + return kind === 170 + || kind === 194; } ts.isArrayBindingElement = isArrayBindingElement; function isPropertyAccessExpression(node) { - return node.kind === 172; + return node.kind === 173; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 173; + return node.kind === 174; } ts.isElementAccessExpression = isElementAccessExpression; function isBinaryExpression(node) { - return node.kind === 187; + return node.kind === 188; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 188; + return node.kind === 189; } ts.isConditionalExpression = isConditionalExpression; function isCallExpression(node) { - return node.kind === 174; + return node.kind === 175; } ts.isCallExpression = isCallExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 189 - || kind === 11; + return kind === 190 + || kind === 12; } ts.isTemplateLiteral = isTemplateLiteral; function isSpreadElementExpression(node) { - return node.kind === 191; + return node.kind === 192; } ts.isSpreadElementExpression = isSpreadElementExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 194; + return node.kind === 195; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isLeftHandSideExpressionKind(kind) { - return kind === 172 - || kind === 173 - || kind === 175 + return kind === 173 || kind === 174 - || kind === 241 - || kind === 242 || kind === 176 - || kind === 170 - || kind === 178 + || kind === 175 + || kind === 242 + || kind === 243 + || kind === 177 || kind === 171 - || kind === 192 || kind === 179 - || kind === 69 - || kind === 10 + || kind === 172 + || kind === 193 + || kind === 180 + || kind === 70 + || kind === 11 || kind === 8 || kind === 9 - || kind === 11 - || kind === 189 - || kind === 84 - || kind === 93 - || kind === 97 - || kind === 99 - || kind === 95 - || kind === 196; + || kind === 12 + || kind === 190 + || kind === 85 + || kind === 94 + || kind === 98 + || kind === 100 + || kind === 96 + || kind === 197; } function isLeftHandSideExpression(node) { return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isUnaryExpressionKind(kind) { - return kind === 185 - || kind === 186 - || kind === 181 + return kind === 186 + || kind === 187 || kind === 182 || kind === 183 || kind === 184 - || kind === 177 + || kind === 185 + || kind === 178 || isLeftHandSideExpressionKind(kind); } function isUnaryExpression(node) { @@ -9680,13 +7599,13 @@ var ts; } ts.isUnaryExpression = isUnaryExpression; function isExpressionKind(kind) { - return kind === 188 - || kind === 190 - || kind === 180 - || kind === 187 + return kind === 189 || kind === 191 - || kind === 195 - || kind === 193 + || kind === 181 + || kind === 188 + || kind === 192 + || kind === 196 + || kind === 194 || isUnaryExpressionKind(kind); } function isExpression(node) { @@ -9695,8 +7614,8 @@ var ts; ts.isExpression = isExpression; function isAssertionExpression(node) { var kind = node.kind; - return kind === 177 - || kind === 195; + return kind === 178 + || kind === 196; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { @@ -9713,15 +7632,15 @@ var ts; } ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isOmittedExpression(node) { - return node.kind === 193; + return node.kind === 194; } ts.isOmittedExpression = isOmittedExpression; function isTemplateSpan(node) { - return node.kind === 197; + return node.kind === 198; } ts.isTemplateSpan = isTemplateSpan; function isBlock(node) { - return node.kind === 199; + return node.kind === 200; } ts.isBlock = isBlock; function isConciseBody(node) { @@ -9739,118 +7658,118 @@ var ts; } ts.isForInitializer = isForInitializer; function isVariableDeclaration(node) { - return node.kind === 218; + return node.kind === 219; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 219; + return node.kind === 220; } ts.isVariableDeclarationList = isVariableDeclarationList; function isCaseBlock(node) { - return node.kind === 227; + return node.kind === 228; } ts.isCaseBlock = isCaseBlock; function isModuleBody(node) { var kind = node.kind; - return kind === 226 - || kind === 225; + return kind === 227 + || kind === 226; } ts.isModuleBody = isModuleBody; function isImportEqualsDeclaration(node) { - return node.kind === 229; + return node.kind === 230; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportClause(node) { - return node.kind === 231; + return node.kind === 232; } ts.isImportClause = isImportClause; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 233 - || kind === 232; + return kind === 234 + || kind === 233; } ts.isNamedImportBindings = isNamedImportBindings; function isImportSpecifier(node) { - return node.kind === 234; + return node.kind === 235; } ts.isImportSpecifier = isImportSpecifier; function isNamedExports(node) { - return node.kind === 237; + return node.kind === 238; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 238; + return node.kind === 239; } ts.isExportSpecifier = isExportSpecifier; function isModuleOrEnumDeclaration(node) { - return node.kind === 225 || node.kind === 224; + return node.kind === 226 || node.kind === 225; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 180 - || kind === 169 - || kind === 221 - || kind === 192 - || kind === 148 - || kind === 224 - || kind === 255 - || kind === 238 - || kind === 220 - || kind === 179 - || kind === 149 - || kind === 231 - || kind === 229 - || kind === 234 + return kind === 181 + || kind === 170 || kind === 222 - || kind === 147 - || kind === 146 + || kind === 193 + || kind === 149 || kind === 225 - || kind === 228 - || kind === 232 - || kind === 142 - || kind === 253 - || kind === 145 - || kind === 144 + || kind === 255 + || kind === 239 + || kind === 221 + || kind === 180 || kind === 150 - || kind === 254 + || kind === 232 + || kind === 230 + || kind === 235 || kind === 223 - || kind === 141 - || kind === 218 + || kind === 148 + || kind === 147 + || kind === 226 + || kind === 229 + || kind === 233 + || kind === 143 + || kind === 253 + || kind === 146 + || kind === 145 + || kind === 151 + || kind === 254 + || kind === 224 + || kind === 142 + || kind === 219 || kind === 279; } function isDeclarationStatementKind(kind) { - return kind === 220 - || kind === 239 - || kind === 221 + return kind === 221 + || kind === 240 || kind === 222 || kind === 223 || kind === 224 || kind === 225 + || kind === 226 + || kind === 231 || kind === 230 - || kind === 229 + || kind === 237 || kind === 236 - || kind === 235 - || kind === 228; + || kind === 229; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 210 - || kind === 209 - || kind === 217 - || kind === 204 - || kind === 202 - || kind === 201 - || kind === 207 - || kind === 208 - || kind === 206 - || kind === 203 - || kind === 214 - || kind === 211 - || kind === 213 - || kind === 215 - || kind === 216 - || kind === 200 + return kind === 211 + || kind === 210 + || kind === 218 || kind === 205 + || kind === 203 + || kind === 202 + || kind === 208 + || kind === 209 + || kind === 207 + || kind === 204 + || kind === 215 || kind === 212 + || kind === 214 + || kind === 216 + || kind === 217 + || kind === 201 + || kind === 206 + || kind === 213 || kind === 287; } function isDeclaration(node) { @@ -9869,18 +7788,18 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 199; + || kind === 200; } ts.isStatement = isStatement; function isModuleReference(node) { var kind = node.kind; - return kind === 240 - || kind === 139 - || kind === 69; + return kind === 241 + || kind === 140 + || kind === 70; } ts.isModuleReference = isModuleReference; function isJsxOpeningElement(node) { - return node.kind === 243; + return node.kind === 244; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { @@ -9889,17 +7808,17 @@ var ts; ts.isJsxClosingElement = isJsxClosingElement; function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 97 - || kind === 69 - || kind === 172; + return kind === 98 + || kind === 70 + || kind === 173; } ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 241 + return kind === 242 || kind === 248 - || kind === 242 - || kind === 244; + || kind === 243 + || kind === 10; } ts.isJsxChild = isJsxChild; function isJsxAttributeLike(node) { @@ -9959,7 +7878,16 @@ var ts; })(ts || (ts = {})); (function (ts) { function getDefaultLibFileName(options) { - return options.target === 2 ? "lib.es6.d.ts" : "lib.d.ts"; + switch (options.target) { + case 4: + return "lib.es2017.d.ts"; + case 3: + return "lib.es2016.d.ts"; + case 2: + return "lib.es6.d.ts"; + default: + return "lib.d.ts"; + } } ts.getDefaultLibFileName = getDefaultLibFileName; function textSpanEnd(span) { @@ -10078,9 +8006,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 141) { + if (d && d.kind === 142) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 222) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 223) { return current; } } @@ -10088,11 +8016,11 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92) && node.parent.kind === 148 && ts.isClassLike(node.parent.parent); + return ts.hasModifier(node, 92) && node.parent.kind === 149 && ts.isClassLike(node.parent.parent); } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 169 || ts.isBindingPattern(node))) { + while (node && (node.kind === 170 || ts.isBindingPattern(node))) { node = node.parent; } return node; @@ -10100,14 +8028,14 @@ var ts; function getCombinedModifierFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = ts.getModifierFlags(node); - if (node.kind === 218) { + if (node.kind === 219) { node = node.parent; } - if (node && node.kind === 219) { + if (node && node.kind === 220) { flags |= ts.getModifierFlags(node); node = node.parent; } - if (node && node.kind === 200) { + if (node && node.kind === 201) { flags |= ts.getModifierFlags(node); } return flags; @@ -10116,14 +8044,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 218) { + if (node.kind === 219) { node = node.parent; } - if (node && node.kind === 219) { + if (node && node.kind === 220) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 200) { + if (node && node.kind === 201) { flags |= node.flags; } return flags; @@ -10131,6 +8059,1554 @@ var ts; ts.getCombinedNodeFlags = getCombinedNodeFlags; })(ts || (ts = {})); var ts; +(function (ts) { + function tokenIsIdentifierOrKeyword(token) { + return token >= 70; + } + ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; + var textToToken = ts.createMap({ + "abstract": 116, + "any": 118, + "as": 117, + "boolean": 121, + "break": 71, + "case": 72, + "catch": 73, + "class": 74, + "continue": 76, + "const": 75, + "constructor": 122, + "debugger": 77, + "declare": 123, + "default": 78, + "delete": 79, + "do": 80, + "else": 81, + "enum": 82, + "export": 83, + "extends": 84, + "false": 85, + "finally": 86, + "for": 87, + "from": 137, + "function": 88, + "get": 124, + "if": 89, + "implements": 107, + "import": 90, + "in": 91, + "instanceof": 92, + "interface": 108, + "is": 125, + "let": 109, + "module": 126, + "namespace": 127, + "never": 128, + "new": 93, + "null": 94, + "number": 131, + "package": 110, + "private": 111, + "protected": 112, + "public": 113, + "readonly": 129, + "require": 130, + "global": 138, + "return": 95, + "set": 132, + "static": 114, + "string": 133, + "super": 96, + "switch": 97, + "symbol": 134, + "this": 98, + "throw": 99, + "true": 100, + "try": 101, + "type": 135, + "typeof": 102, + "undefined": 136, + "var": 103, + "void": 104, + "while": 105, + "with": 106, + "yield": 115, + "async": 119, + "await": 120, + "of": 139, + "{": 16, + "}": 17, + "(": 18, + ")": 19, + "[": 20, + "]": 21, + ".": 22, + "...": 23, + ";": 24, + ",": 25, + "<": 26, + ">": 28, + "<=": 29, + ">=": 30, + "==": 31, + "!=": 32, + "===": 33, + "!==": 34, + "=>": 35, + "+": 36, + "-": 37, + "**": 39, + "*": 38, + "/": 40, + "%": 41, + "++": 42, + "--": 43, + "<<": 44, + ">": 45, + ">>>": 46, + "&": 47, + "|": 48, + "^": 49, + "!": 50, + "~": 51, + "&&": 52, + "||": 53, + "?": 54, + ":": 55, + "=": 57, + "+=": 58, + "-=": 59, + "*=": 60, + "**=": 61, + "/=": 62, + "%=": 63, + "<<=": 64, + ">>=": 65, + ">>>=": 66, + "&=": 67, + "|=": 68, + "^=": 69, + "@": 56, + }); + 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,]; + var unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 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, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 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, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 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, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 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, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; + var unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 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, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 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, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 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, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; + function lookupInUnicodeMap(code, map) { + if (code < map[0]) { + return false; + } + var lo = 0; + var hi = map.length; + var mid; + while (lo + 1 < hi) { + mid = lo + (hi - lo) / 2; + mid -= mid % 2; + if (map[mid] <= code && code <= map[mid + 1]) { + return true; + } + if (code < map[mid]) { + hi = mid; + } + else { + lo = mid + 2; + } + } + return false; + } + function isUnicodeIdentifierStart(code, languageVersion) { + return languageVersion >= 1 ? + lookupInUnicodeMap(code, unicodeES5IdentifierStart) : + lookupInUnicodeMap(code, unicodeES3IdentifierStart); + } + ts.isUnicodeIdentifierStart = isUnicodeIdentifierStart; + function isUnicodeIdentifierPart(code, languageVersion) { + return languageVersion >= 1 ? + lookupInUnicodeMap(code, unicodeES5IdentifierPart) : + lookupInUnicodeMap(code, unicodeES3IdentifierPart); + } + function makeReverseMap(source) { + var result = []; + for (var name_8 in source) { + result[source[name_8]] = name_8; + } + return result; + } + var tokenStrings = makeReverseMap(textToToken); + function tokenToString(t) { + return tokenStrings[t]; + } + ts.tokenToString = tokenToString; + function stringToToken(s) { + return textToToken[s]; + } + ts.stringToToken = stringToToken; + function computeLineStarts(text) { + var result = new Array(); + var pos = 0; + var lineStart = 0; + while (pos < text.length) { + var ch = text.charCodeAt(pos); + pos++; + switch (ch) { + case 13: + if (text.charCodeAt(pos) === 10) { + pos++; + } + case 10: + result.push(lineStart); + lineStart = pos; + break; + default: + if (ch > 127 && isLineBreak(ch)) { + result.push(lineStart); + lineStart = pos; + } + break; + } + } + result.push(lineStart); + return result; + } + ts.computeLineStarts = computeLineStarts; + function getPositionOfLineAndCharacter(sourceFile, line, character) { + return computePositionOfLineAndCharacter(getLineStarts(sourceFile), line, character); + } + ts.getPositionOfLineAndCharacter = getPositionOfLineAndCharacter; + function computePositionOfLineAndCharacter(lineStarts, line, character) { + ts.Debug.assert(line >= 0 && line < lineStarts.length); + return lineStarts[line] + character; + } + ts.computePositionOfLineAndCharacter = computePositionOfLineAndCharacter; + function getLineStarts(sourceFile) { + return sourceFile.lineMap || (sourceFile.lineMap = computeLineStarts(sourceFile.text)); + } + ts.getLineStarts = getLineStarts; + function computeLineAndCharacterOfPosition(lineStarts, position) { + var lineNumber = ts.binarySearch(lineStarts, position); + if (lineNumber < 0) { + lineNumber = ~lineNumber - 1; + ts.Debug.assert(lineNumber !== -1, "position cannot precede the beginning of the file"); + } + return { + line: lineNumber, + character: position - lineStarts[lineNumber] + }; + } + ts.computeLineAndCharacterOfPosition = computeLineAndCharacterOfPosition; + function getLineAndCharacterOfPosition(sourceFile, position) { + return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position); + } + ts.getLineAndCharacterOfPosition = getLineAndCharacterOfPosition; + var hasOwnProperty = Object.prototype.hasOwnProperty; + function isWhiteSpace(ch) { + return isWhiteSpaceSingleLine(ch) || isLineBreak(ch); + } + ts.isWhiteSpace = isWhiteSpace; + function isWhiteSpaceSingleLine(ch) { + return ch === 32 || + ch === 9 || + ch === 11 || + ch === 12 || + ch === 160 || + ch === 133 || + ch === 5760 || + ch >= 8192 && ch <= 8203 || + ch === 8239 || + ch === 8287 || + ch === 12288 || + ch === 65279; + } + ts.isWhiteSpaceSingleLine = isWhiteSpaceSingleLine; + function isLineBreak(ch) { + return ch === 10 || + ch === 13 || + ch === 8232 || + ch === 8233; + } + ts.isLineBreak = isLineBreak; + function isDigit(ch) { + return ch >= 48 && ch <= 57; + } + function isOctalDigit(ch) { + return ch >= 48 && ch <= 55; + } + ts.isOctalDigit = isOctalDigit; + function couldStartTrivia(text, pos) { + var ch = text.charCodeAt(pos); + switch (ch) { + case 13: + case 10: + case 9: + case 11: + case 12: + case 32: + case 47: + case 60: + case 61: + case 62: + return true; + case 35: + return pos === 0; + default: + return ch > 127; + } + } + ts.couldStartTrivia = couldStartTrivia; + function skipTrivia(text, pos, stopAfterLineBreak, stopAtComments) { + if (stopAtComments === void 0) { stopAtComments = false; } + if (ts.positionIsSynthesized(pos)) { + return pos; + } + while (true) { + var ch = text.charCodeAt(pos); + switch (ch) { + case 13: + if (text.charCodeAt(pos + 1) === 10) { + pos++; + } + case 10: + pos++; + if (stopAfterLineBreak) { + return pos; + } + continue; + case 9: + case 11: + case 12: + case 32: + pos++; + continue; + case 47: + if (stopAtComments) { + break; + } + if (text.charCodeAt(pos + 1) === 47) { + pos += 2; + while (pos < text.length) { + if (isLineBreak(text.charCodeAt(pos))) { + break; + } + pos++; + } + continue; + } + if (text.charCodeAt(pos + 1) === 42) { + pos += 2; + while (pos < text.length) { + if (text.charCodeAt(pos) === 42 && text.charCodeAt(pos + 1) === 47) { + pos += 2; + break; + } + pos++; + } + continue; + } + break; + case 60: + case 61: + case 62: + if (isConflictMarkerTrivia(text, pos)) { + pos = scanConflictMarkerTrivia(text, pos); + continue; + } + break; + case 35: + if (pos === 0 && isShebangTrivia(text, pos)) { + pos = scanShebangTrivia(text, pos); + continue; + } + break; + default: + if (ch > 127 && (isWhiteSpace(ch))) { + pos++; + continue; + } + break; + } + return pos; + } + } + ts.skipTrivia = skipTrivia; + var mergeConflictMarkerLength = "<<<<<<<".length; + function isConflictMarkerTrivia(text, pos) { + ts.Debug.assert(pos >= 0); + if (pos === 0 || isLineBreak(text.charCodeAt(pos - 1))) { + var ch = text.charCodeAt(pos); + if ((pos + mergeConflictMarkerLength) < text.length) { + for (var i = 0, n = mergeConflictMarkerLength; i < n; i++) { + if (text.charCodeAt(pos + i) !== ch) { + return false; + } + } + return ch === 61 || + text.charCodeAt(pos + mergeConflictMarkerLength) === 32; + } + } + return false; + } + function scanConflictMarkerTrivia(text, pos, error) { + if (error) { + error(ts.Diagnostics.Merge_conflict_marker_encountered, mergeConflictMarkerLength); + } + var ch = text.charCodeAt(pos); + var len = text.length; + if (ch === 60 || ch === 62) { + while (pos < len && !isLineBreak(text.charCodeAt(pos))) { + pos++; + } + } + else { + ts.Debug.assert(ch === 61); + while (pos < len) { + var ch_1 = text.charCodeAt(pos); + if (ch_1 === 62 && isConflictMarkerTrivia(text, pos)) { + break; + } + pos++; + } + } + return pos; + } + var shebangTriviaRegex = /^#!.*/; + function isShebangTrivia(text, pos) { + ts.Debug.assert(pos === 0); + return shebangTriviaRegex.test(text); + } + function scanShebangTrivia(text, pos) { + var shebang = shebangTriviaRegex.exec(text)[0]; + pos = pos + shebang.length; + return pos; + } + function iterateCommentRanges(reduce, text, pos, trailing, cb, state, initial) { + var pendingPos; + var pendingEnd; + var pendingKind; + var pendingHasTrailingNewLine; + var hasPendingCommentRange = false; + var collecting = trailing || pos === 0; + var accumulator = initial; + scan: while (pos >= 0 && pos < text.length) { + var ch = text.charCodeAt(pos); + switch (ch) { + case 13: + if (text.charCodeAt(pos + 1) === 10) { + pos++; + } + case 10: + pos++; + if (trailing) { + break scan; + } + collecting = true; + if (hasPendingCommentRange) { + pendingHasTrailingNewLine = true; + } + continue; + case 9: + case 11: + case 12: + case 32: + pos++; + continue; + case 47: + var nextChar = text.charCodeAt(pos + 1); + var hasTrailingNewLine = false; + if (nextChar === 47 || nextChar === 42) { + var kind = nextChar === 47 ? 2 : 3; + var startPos = pos; + pos += 2; + if (nextChar === 47) { + while (pos < text.length) { + if (isLineBreak(text.charCodeAt(pos))) { + hasTrailingNewLine = true; + break; + } + pos++; + } + } + else { + while (pos < text.length) { + if (text.charCodeAt(pos) === 42 && text.charCodeAt(pos + 1) === 47) { + pos += 2; + break; + } + pos++; + } + } + if (collecting) { + if (hasPendingCommentRange) { + accumulator = cb(pendingPos, pendingEnd, pendingKind, pendingHasTrailingNewLine, state, accumulator); + if (!reduce && accumulator) { + return accumulator; + } + hasPendingCommentRange = false; + } + pendingPos = startPos; + pendingEnd = pos; + pendingKind = kind; + pendingHasTrailingNewLine = hasTrailingNewLine; + hasPendingCommentRange = true; + } + continue; + } + break scan; + default: + if (ch > 127 && (isWhiteSpace(ch))) { + if (hasPendingCommentRange && isLineBreak(ch)) { + pendingHasTrailingNewLine = true; + } + pos++; + continue; + } + break scan; + } + } + if (hasPendingCommentRange) { + accumulator = cb(pendingPos, pendingEnd, pendingKind, pendingHasTrailingNewLine, state, accumulator); + } + return accumulator; + } + function forEachLeadingCommentRange(text, pos, cb, state) { + return iterateCommentRanges(false, text, pos, false, cb, state); + } + ts.forEachLeadingCommentRange = forEachLeadingCommentRange; + function forEachTrailingCommentRange(text, pos, cb, state) { + return iterateCommentRanges(false, text, pos, true, cb, state); + } + ts.forEachTrailingCommentRange = forEachTrailingCommentRange; + function reduceEachLeadingCommentRange(text, pos, cb, state, initial) { + return iterateCommentRanges(true, text, pos, false, cb, state, initial); + } + ts.reduceEachLeadingCommentRange = reduceEachLeadingCommentRange; + function reduceEachTrailingCommentRange(text, pos, cb, state, initial) { + return iterateCommentRanges(true, text, pos, true, cb, state, initial); + } + ts.reduceEachTrailingCommentRange = reduceEachTrailingCommentRange; + function appendCommentRange(pos, end, kind, hasTrailingNewLine, _state, comments) { + if (!comments) { + comments = []; + } + comments.push({ pos: pos, end: end, hasTrailingNewLine: hasTrailingNewLine, kind: kind }); + return comments; + } + function getLeadingCommentRanges(text, pos) { + return reduceEachLeadingCommentRange(text, pos, appendCommentRange, undefined, undefined); + } + ts.getLeadingCommentRanges = getLeadingCommentRanges; + function getTrailingCommentRanges(text, pos) { + return reduceEachTrailingCommentRange(text, pos, appendCommentRange, undefined, undefined); + } + ts.getTrailingCommentRanges = getTrailingCommentRanges; + function getShebang(text) { + return shebangTriviaRegex.test(text) + ? shebangTriviaRegex.exec(text)[0] + : undefined; + } + ts.getShebang = getShebang; + function isIdentifierStart(ch, languageVersion) { + return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || + ch === 36 || ch === 95 || + ch > 127 && isUnicodeIdentifierStart(ch, languageVersion); + } + ts.isIdentifierStart = isIdentifierStart; + function isIdentifierPart(ch, languageVersion) { + return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || + ch >= 48 && ch <= 57 || ch === 36 || ch === 95 || + ch > 127 && isUnicodeIdentifierPart(ch, languageVersion); + } + ts.isIdentifierPart = isIdentifierPart; + function isIdentifierText(name, languageVersion) { + if (!isIdentifierStart(name.charCodeAt(0), languageVersion)) { + return false; + } + for (var i = 1, n = name.length; i < n; i++) { + if (!isIdentifierPart(name.charCodeAt(i), languageVersion)) { + return false; + } + } + return true; + } + ts.isIdentifierText = isIdentifierText; + function createScanner(languageVersion, skipTrivia, languageVariant, text, onError, start, length) { + if (languageVariant === void 0) { languageVariant = 0; } + var pos; + var end; + var startPos; + var tokenPos; + var token; + var tokenValue; + var precedingLineBreak; + var hasExtendedUnicodeEscape; + var tokenIsUnterminated; + setText(text, start, length); + return { + getStartPos: function () { return startPos; }, + getTextPos: function () { return pos; }, + getToken: function () { return token; }, + getTokenPos: function () { return tokenPos; }, + getTokenText: function () { return text.substring(tokenPos, pos); }, + getTokenValue: function () { return tokenValue; }, + hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, + hasPrecedingLineBreak: function () { return precedingLineBreak; }, + isIdentifier: function () { return token === 70 || token > 106; }, + isReservedWord: function () { return token >= 71 && token <= 106; }, + isUnterminated: function () { return tokenIsUnterminated; }, + reScanGreaterToken: reScanGreaterToken, + reScanSlashToken: reScanSlashToken, + reScanTemplateToken: reScanTemplateToken, + scanJsxIdentifier: scanJsxIdentifier, + scanJsxAttributeValue: scanJsxAttributeValue, + reScanJsxToken: reScanJsxToken, + scanJsxToken: scanJsxToken, + scanJSDocToken: scanJSDocToken, + scan: scan, + getText: getText, + setText: setText, + setScriptTarget: setScriptTarget, + setLanguageVariant: setLanguageVariant, + setOnError: setOnError, + setTextPos: setTextPos, + tryScan: tryScan, + lookAhead: lookAhead, + scanRange: scanRange, + }; + function error(message, length) { + if (onError) { + onError(message, length || 0); + } + } + function scanNumber() { + var start = pos; + while (isDigit(text.charCodeAt(pos))) + pos++; + if (text.charCodeAt(pos) === 46) { + pos++; + while (isDigit(text.charCodeAt(pos))) + pos++; + } + var end = pos; + if (text.charCodeAt(pos) === 69 || text.charCodeAt(pos) === 101) { + pos++; + if (text.charCodeAt(pos) === 43 || text.charCodeAt(pos) === 45) + pos++; + if (isDigit(text.charCodeAt(pos))) { + pos++; + while (isDigit(text.charCodeAt(pos))) + pos++; + end = pos; + } + else { + error(ts.Diagnostics.Digit_expected); + } + } + return "" + +(text.substring(start, end)); + } + function scanOctalDigits() { + var start = pos; + while (isOctalDigit(text.charCodeAt(pos))) { + pos++; + } + return +(text.substring(start, pos)); + } + function scanExactNumberOfHexDigits(count) { + return scanHexDigits(count, false); + } + function scanMinimumNumberOfHexDigits(count) { + return scanHexDigits(count, true); + } + function scanHexDigits(minCount, scanAsManyAsPossible) { + var digits = 0; + var value = 0; + while (digits < minCount || scanAsManyAsPossible) { + var ch = text.charCodeAt(pos); + if (ch >= 48 && ch <= 57) { + value = value * 16 + ch - 48; + } + else if (ch >= 65 && ch <= 70) { + value = value * 16 + ch - 65 + 10; + } + else if (ch >= 97 && ch <= 102) { + value = value * 16 + ch - 97 + 10; + } + else { + break; + } + pos++; + digits++; + } + if (digits < minCount) { + value = -1; + } + return value; + } + function scanString(allowEscapes) { + if (allowEscapes === void 0) { allowEscapes = true; } + var quote = text.charCodeAt(pos); + pos++; + var result = ""; + var start = pos; + while (true) { + if (pos >= end) { + result += text.substring(start, pos); + tokenIsUnterminated = true; + error(ts.Diagnostics.Unterminated_string_literal); + break; + } + var ch = text.charCodeAt(pos); + if (ch === quote) { + result += text.substring(start, pos); + pos++; + break; + } + if (ch === 92 && allowEscapes) { + result += text.substring(start, pos); + result += scanEscapeSequence(); + start = pos; + continue; + } + if (isLineBreak(ch)) { + result += text.substring(start, pos); + tokenIsUnterminated = true; + error(ts.Diagnostics.Unterminated_string_literal); + break; + } + pos++; + } + return result; + } + function scanTemplateAndSetTokenValue() { + var startedWithBacktick = text.charCodeAt(pos) === 96; + pos++; + var start = pos; + var contents = ""; + var resultingToken; + while (true) { + if (pos >= end) { + contents += text.substring(start, pos); + tokenIsUnterminated = true; + error(ts.Diagnostics.Unterminated_template_literal); + resultingToken = startedWithBacktick ? 12 : 15; + break; + } + var currChar = text.charCodeAt(pos); + if (currChar === 96) { + contents += text.substring(start, pos); + pos++; + resultingToken = startedWithBacktick ? 12 : 15; + break; + } + if (currChar === 36 && pos + 1 < end && text.charCodeAt(pos + 1) === 123) { + contents += text.substring(start, pos); + pos += 2; + resultingToken = startedWithBacktick ? 13 : 14; + break; + } + if (currChar === 92) { + contents += text.substring(start, pos); + contents += scanEscapeSequence(); + start = pos; + continue; + } + if (currChar === 13) { + contents += text.substring(start, pos); + pos++; + if (pos < end && text.charCodeAt(pos) === 10) { + pos++; + } + contents += "\n"; + start = pos; + continue; + } + pos++; + } + ts.Debug.assert(resultingToken !== undefined); + tokenValue = contents; + return resultingToken; + } + function scanEscapeSequence() { + pos++; + if (pos >= end) { + error(ts.Diagnostics.Unexpected_end_of_text); + return ""; + } + var ch = text.charCodeAt(pos); + pos++; + switch (ch) { + case 48: + return "\0"; + case 98: + return "\b"; + case 116: + return "\t"; + case 110: + return "\n"; + case 118: + return "\v"; + case 102: + return "\f"; + case 114: + return "\r"; + case 39: + return "\'"; + case 34: + return "\""; + case 117: + if (pos < end && text.charCodeAt(pos) === 123) { + hasExtendedUnicodeEscape = true; + pos++; + return scanExtendedUnicodeEscape(); + } + return scanHexadecimalEscape(4); + case 120: + return scanHexadecimalEscape(2); + case 13: + if (pos < end && text.charCodeAt(pos) === 10) { + pos++; + } + case 10: + case 8232: + case 8233: + return ""; + default: + return String.fromCharCode(ch); + } + } + function scanHexadecimalEscape(numDigits) { + var escapedValue = scanExactNumberOfHexDigits(numDigits); + if (escapedValue >= 0) { + return String.fromCharCode(escapedValue); + } + else { + error(ts.Diagnostics.Hexadecimal_digit_expected); + return ""; + } + } + function scanExtendedUnicodeEscape() { + var escapedValue = scanMinimumNumberOfHexDigits(1); + var isInvalidExtendedEscape = false; + if (escapedValue < 0) { + error(ts.Diagnostics.Hexadecimal_digit_expected); + isInvalidExtendedEscape = true; + } + else if (escapedValue > 0x10FFFF) { + error(ts.Diagnostics.An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive); + isInvalidExtendedEscape = true; + } + if (pos >= end) { + error(ts.Diagnostics.Unexpected_end_of_text); + isInvalidExtendedEscape = true; + } + else if (text.charCodeAt(pos) === 125) { + pos++; + } + else { + error(ts.Diagnostics.Unterminated_Unicode_escape_sequence); + isInvalidExtendedEscape = true; + } + if (isInvalidExtendedEscape) { + return ""; + } + return utf16EncodeAsString(escapedValue); + } + function utf16EncodeAsString(codePoint) { + ts.Debug.assert(0x0 <= codePoint && codePoint <= 0x10FFFF); + if (codePoint <= 65535) { + return String.fromCharCode(codePoint); + } + var codeUnit1 = Math.floor((codePoint - 65536) / 1024) + 0xD800; + var codeUnit2 = ((codePoint - 65536) % 1024) + 0xDC00; + return String.fromCharCode(codeUnit1, codeUnit2); + } + function peekUnicodeEscape() { + if (pos + 5 < end && text.charCodeAt(pos + 1) === 117) { + var start_1 = pos; + pos += 2; + var value = scanExactNumberOfHexDigits(4); + pos = start_1; + return value; + } + return -1; + } + function scanIdentifierParts() { + var result = ""; + var start = pos; + while (pos < end) { + var ch = text.charCodeAt(pos); + if (isIdentifierPart(ch, languageVersion)) { + pos++; + } + else if (ch === 92) { + ch = peekUnicodeEscape(); + if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { + break; + } + result += text.substring(start, pos); + result += String.fromCharCode(ch); + pos += 6; + start = pos; + } + else { + break; + } + } + result += text.substring(start, pos); + return result; + } + function getIdentifierToken() { + var len = tokenValue.length; + if (len >= 2 && len <= 11) { + var ch = tokenValue.charCodeAt(0); + if (ch >= 97 && ch <= 122 && hasOwnProperty.call(textToToken, tokenValue)) { + return token = textToToken[tokenValue]; + } + } + return token = 70; + } + function scanBinaryOrOctalDigits(base) { + ts.Debug.assert(base === 2 || base === 8, "Expected either base 2 or base 8"); + var value = 0; + var numberOfDigits = 0; + while (true) { + var ch = text.charCodeAt(pos); + var valueOfCh = ch - 48; + if (!isDigit(ch) || valueOfCh >= base) { + break; + } + value = value * base + valueOfCh; + pos++; + numberOfDigits++; + } + if (numberOfDigits === 0) { + return -1; + } + return value; + } + function scan() { + startPos = pos; + hasExtendedUnicodeEscape = false; + precedingLineBreak = false; + tokenIsUnterminated = false; + while (true) { + tokenPos = pos; + if (pos >= end) { + return token = 1; + } + var ch = text.charCodeAt(pos); + if (ch === 35 && pos === 0 && isShebangTrivia(text, pos)) { + pos = scanShebangTrivia(text, pos); + if (skipTrivia) { + continue; + } + else { + return token = 6; + } + } + switch (ch) { + case 10: + case 13: + precedingLineBreak = true; + if (skipTrivia) { + pos++; + continue; + } + else { + if (ch === 13 && pos + 1 < end && text.charCodeAt(pos + 1) === 10) { + pos += 2; + } + else { + pos++; + } + return token = 4; + } + case 9: + case 11: + case 12: + case 32: + if (skipTrivia) { + pos++; + continue; + } + else { + while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) { + pos++; + } + return token = 5; + } + case 33: + if (text.charCodeAt(pos + 1) === 61) { + if (text.charCodeAt(pos + 2) === 61) { + return pos += 3, token = 34; + } + return pos += 2, token = 32; + } + pos++; + return token = 50; + case 34: + case 39: + tokenValue = scanString(); + return token = 9; + case 96: + return token = scanTemplateAndSetTokenValue(); + case 37: + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 63; + } + pos++; + return token = 41; + case 38: + if (text.charCodeAt(pos + 1) === 38) { + return pos += 2, token = 52; + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 67; + } + pos++; + return token = 47; + case 40: + pos++; + return token = 18; + case 41: + pos++; + return token = 19; + case 42: + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 60; + } + if (text.charCodeAt(pos + 1) === 42) { + if (text.charCodeAt(pos + 2) === 61) { + return pos += 3, token = 61; + } + return pos += 2, token = 39; + } + pos++; + return token = 38; + case 43: + if (text.charCodeAt(pos + 1) === 43) { + return pos += 2, token = 42; + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 58; + } + pos++; + return token = 36; + case 44: + pos++; + return token = 25; + case 45: + if (text.charCodeAt(pos + 1) === 45) { + return pos += 2, token = 43; + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 59; + } + pos++; + return token = 37; + case 46: + if (isDigit(text.charCodeAt(pos + 1))) { + tokenValue = scanNumber(); + return token = 8; + } + if (text.charCodeAt(pos + 1) === 46 && text.charCodeAt(pos + 2) === 46) { + return pos += 3, token = 23; + } + pos++; + return token = 22; + case 47: + if (text.charCodeAt(pos + 1) === 47) { + pos += 2; + while (pos < end) { + if (isLineBreak(text.charCodeAt(pos))) { + break; + } + pos++; + } + if (skipTrivia) { + continue; + } + else { + return token = 2; + } + } + if (text.charCodeAt(pos + 1) === 42) { + pos += 2; + var commentClosed = false; + while (pos < end) { + var ch_2 = text.charCodeAt(pos); + if (ch_2 === 42 && text.charCodeAt(pos + 1) === 47) { + pos += 2; + commentClosed = true; + break; + } + if (isLineBreak(ch_2)) { + precedingLineBreak = true; + } + pos++; + } + if (!commentClosed) { + error(ts.Diagnostics.Asterisk_Slash_expected); + } + if (skipTrivia) { + continue; + } + else { + tokenIsUnterminated = !commentClosed; + return token = 3; + } + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 62; + } + pos++; + return token = 40; + case 48: + if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 || text.charCodeAt(pos + 1) === 120)) { + pos += 2; + var value = scanMinimumNumberOfHexDigits(1); + if (value < 0) { + error(ts.Diagnostics.Hexadecimal_digit_expected); + value = 0; + } + tokenValue = "" + value; + return token = 8; + } + else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 || text.charCodeAt(pos + 1) === 98)) { + pos += 2; + var value = scanBinaryOrOctalDigits(2); + if (value < 0) { + error(ts.Diagnostics.Binary_digit_expected); + value = 0; + } + tokenValue = "" + value; + return token = 8; + } + else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 || text.charCodeAt(pos + 1) === 111)) { + pos += 2; + var value = scanBinaryOrOctalDigits(8); + if (value < 0) { + error(ts.Diagnostics.Octal_digit_expected); + value = 0; + } + tokenValue = "" + value; + return token = 8; + } + if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { + tokenValue = "" + scanOctalDigits(); + return token = 8; + } + case 49: + case 50: + case 51: + case 52: + case 53: + case 54: + case 55: + case 56: + case 57: + tokenValue = scanNumber(); + return token = 8; + case 58: + pos++; + return token = 55; + case 59: + pos++; + return token = 24; + case 60: + if (isConflictMarkerTrivia(text, pos)) { + pos = scanConflictMarkerTrivia(text, pos, error); + if (skipTrivia) { + continue; + } + else { + return token = 7; + } + } + if (text.charCodeAt(pos + 1) === 60) { + if (text.charCodeAt(pos + 2) === 61) { + return pos += 3, token = 64; + } + return pos += 2, token = 44; + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 29; + } + if (languageVariant === 1 && + text.charCodeAt(pos + 1) === 47 && + text.charCodeAt(pos + 2) !== 42) { + return pos += 2, token = 27; + } + pos++; + return token = 26; + case 61: + if (isConflictMarkerTrivia(text, pos)) { + pos = scanConflictMarkerTrivia(text, pos, error); + if (skipTrivia) { + continue; + } + else { + return token = 7; + } + } + if (text.charCodeAt(pos + 1) === 61) { + if (text.charCodeAt(pos + 2) === 61) { + return pos += 3, token = 33; + } + return pos += 2, token = 31; + } + if (text.charCodeAt(pos + 1) === 62) { + return pos += 2, token = 35; + } + pos++; + return token = 57; + case 62: + if (isConflictMarkerTrivia(text, pos)) { + pos = scanConflictMarkerTrivia(text, pos, error); + if (skipTrivia) { + continue; + } + else { + return token = 7; + } + } + pos++; + return token = 28; + case 63: + pos++; + return token = 54; + case 91: + pos++; + return token = 20; + case 93: + pos++; + return token = 21; + case 94: + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 69; + } + pos++; + return token = 49; + case 123: + pos++; + return token = 16; + case 124: + if (text.charCodeAt(pos + 1) === 124) { + return pos += 2, token = 53; + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 68; + } + pos++; + return token = 48; + case 125: + pos++; + return token = 17; + case 126: + pos++; + return token = 51; + case 64: + pos++; + return token = 56; + case 92: + var cookedChar = peekUnicodeEscape(); + if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { + pos += 6; + tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); + return token = getIdentifierToken(); + } + error(ts.Diagnostics.Invalid_character); + pos++; + return token = 0; + default: + if (isIdentifierStart(ch, languageVersion)) { + pos++; + while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) + pos++; + tokenValue = text.substring(tokenPos, pos); + if (ch === 92) { + tokenValue += scanIdentifierParts(); + } + return token = getIdentifierToken(); + } + else if (isWhiteSpaceSingleLine(ch)) { + pos++; + continue; + } + else if (isLineBreak(ch)) { + precedingLineBreak = true; + pos++; + continue; + } + error(ts.Diagnostics.Invalid_character); + pos++; + return token = 0; + } + } + } + function reScanGreaterToken() { + if (token === 28) { + if (text.charCodeAt(pos) === 62) { + if (text.charCodeAt(pos + 1) === 62) { + if (text.charCodeAt(pos + 2) === 61) { + return pos += 3, token = 66; + } + return pos += 2, token = 46; + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 65; + } + pos++; + return token = 45; + } + if (text.charCodeAt(pos) === 61) { + pos++; + return token = 30; + } + } + return token; + } + function reScanSlashToken() { + if (token === 40 || token === 62) { + var p = tokenPos + 1; + var inEscape = false; + var inCharacterClass = false; + while (true) { + if (p >= end) { + tokenIsUnterminated = true; + error(ts.Diagnostics.Unterminated_regular_expression_literal); + break; + } + var ch = text.charCodeAt(p); + if (isLineBreak(ch)) { + tokenIsUnterminated = true; + error(ts.Diagnostics.Unterminated_regular_expression_literal); + break; + } + if (inEscape) { + inEscape = false; + } + else if (ch === 47 && !inCharacterClass) { + p++; + break; + } + else if (ch === 91) { + inCharacterClass = true; + } + else if (ch === 92) { + inEscape = true; + } + else if (ch === 93) { + inCharacterClass = false; + } + p++; + } + while (p < end && isIdentifierPart(text.charCodeAt(p), languageVersion)) { + p++; + } + pos = p; + tokenValue = text.substring(tokenPos, pos); + token = 11; + } + return token; + } + function reScanTemplateToken() { + ts.Debug.assert(token === 17, "'reScanTemplateToken' should only be called on a '}'"); + pos = tokenPos; + return token = scanTemplateAndSetTokenValue(); + } + function reScanJsxToken() { + pos = tokenPos = startPos; + return token = scanJsxToken(); + } + function scanJsxToken() { + startPos = tokenPos = pos; + if (pos >= end) { + return token = 1; + } + var char = text.charCodeAt(pos); + if (char === 60) { + if (text.charCodeAt(pos + 1) === 47) { + pos += 2; + return token = 27; + } + pos++; + return token = 26; + } + if (char === 123) { + pos++; + return token = 16; + } + while (pos < end) { + pos++; + char = text.charCodeAt(pos); + if ((char === 123) || (char === 60)) { + break; + } + } + return token = 10; + } + function scanJsxIdentifier() { + if (tokenIsIdentifierOrKeyword(token)) { + var firstCharPosition = pos; + while (pos < end) { + var ch = text.charCodeAt(pos); + if (ch === 45 || ((firstCharPosition === pos) ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion))) { + pos++; + } + else { + break; + } + } + tokenValue += text.substr(firstCharPosition, pos - firstCharPosition); + } + return token; + } + function scanJsxAttributeValue() { + startPos = pos; + switch (text.charCodeAt(pos)) { + case 34: + case 39: + tokenValue = scanString(false); + return token = 9; + default: + return scan(); + } + } + function scanJSDocToken() { + if (pos >= end) { + return token = 1; + } + startPos = pos; + tokenPos = pos; + var ch = text.charCodeAt(pos); + switch (ch) { + case 9: + case 11: + case 12: + case 32: + while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) { + pos++; + } + return token = 5; + case 64: + pos++; + return token = 56; + case 10: + case 13: + pos++; + return token = 4; + case 42: + pos++; + return token = 38; + case 123: + pos++; + return token = 16; + case 125: + pos++; + return token = 17; + case 91: + pos++; + return token = 20; + case 93: + pos++; + return token = 21; + case 61: + pos++; + return token = 57; + case 44: + pos++; + return token = 25; + } + if (isIdentifierStart(ch, 4)) { + pos++; + while (isIdentifierPart(text.charCodeAt(pos), 4) && pos < end) { + pos++; + } + return token = 70; + } + else { + return pos += 1, token = 0; + } + } + function speculationHelper(callback, isLookahead) { + var savePos = pos; + var saveStartPos = startPos; + var saveTokenPos = tokenPos; + var saveToken = token; + var saveTokenValue = tokenValue; + var savePrecedingLineBreak = precedingLineBreak; + var result = callback(); + if (!result || isLookahead) { + pos = savePos; + startPos = saveStartPos; + tokenPos = saveTokenPos; + token = saveToken; + tokenValue = saveTokenValue; + precedingLineBreak = savePrecedingLineBreak; + } + return result; + } + function scanRange(start, length, callback) { + var saveEnd = end; + var savePos = pos; + var saveStartPos = startPos; + var saveTokenPos = tokenPos; + var saveToken = token; + var savePrecedingLineBreak = precedingLineBreak; + var saveTokenValue = tokenValue; + var saveHasExtendedUnicodeEscape = hasExtendedUnicodeEscape; + var saveTokenIsUnterminated = tokenIsUnterminated; + setText(text, start, length); + var result = callback(); + end = saveEnd; + pos = savePos; + startPos = saveStartPos; + tokenPos = saveTokenPos; + token = saveToken; + precedingLineBreak = savePrecedingLineBreak; + tokenValue = saveTokenValue; + hasExtendedUnicodeEscape = saveHasExtendedUnicodeEscape; + tokenIsUnterminated = saveTokenIsUnterminated; + return result; + } + function lookAhead(callback) { + return speculationHelper(callback, true); + } + function tryScan(callback) { + return speculationHelper(callback, false); + } + function getText() { + return text; + } + function setText(newText, start, length) { + text = newText || ""; + end = length === undefined ? text.length : start + length; + setTextPos(start || 0); + } + function setOnError(errorCallback) { + onError = errorCallback; + } + function setScriptTarget(scriptTarget) { + languageVersion = scriptTarget; + } + function setLanguageVariant(variant) { + languageVariant = variant; + } + function setTextPos(textPos) { + ts.Debug.assert(textPos >= 0); + pos = textPos; + startPos = textPos; + tokenPos = textPos; + token = 0; + precedingLineBreak = false; + tokenValue = undefined; + hasExtendedUnicodeEscape = false; + tokenIsUnterminated = false; + } + } + ts.createScanner = createScanner; +})(ts || (ts = {})); +var ts; (function (ts) { var NodeConstructor; var SourceFileConstructor; @@ -10216,7 +9692,7 @@ var ts; return node; } else if (typeof value === "boolean") { - return createNode(value ? 99 : 84, location, undefined); + return createNode(value ? 100 : 85, location, undefined); } else if (typeof value === "string") { var node = createNode(9, location, undefined); @@ -10233,7 +9709,7 @@ var ts; ts.createLiteral = createLiteral; var nextAutoGenerateId = 0; function createIdentifier(text, location) { - var node = createNode(69, location); + var node = createNode(70, location); node.text = ts.escapeIdentifier(text); node.originalKeywordKind = ts.stringToToken(text); node.autoGenerateKind = 0; @@ -10242,7 +9718,7 @@ var ts; } ts.createIdentifier = createIdentifier; function createTempVariable(recordTempVariable, location) { - var name = createNode(69, location); + var name = createNode(70, location); name.text = ""; name.originalKeywordKind = 0; name.autoGenerateKind = 1; @@ -10255,7 +9731,7 @@ var ts; } ts.createTempVariable = createTempVariable; function createLoopVariable(location) { - var name = createNode(69, location); + var name = createNode(70, location); name.text = ""; name.originalKeywordKind = 0; name.autoGenerateKind = 2; @@ -10265,7 +9741,7 @@ var ts; } ts.createLoopVariable = createLoopVariable; function createUniqueName(text, location) { - var name = createNode(69, location); + var name = createNode(70, location); name.text = text; name.originalKeywordKind = 0; name.autoGenerateKind = 3; @@ -10275,7 +9751,7 @@ var ts; } ts.createUniqueName = createUniqueName; function getGeneratedNameForNode(node, location) { - var name = createNode(69, location); + var name = createNode(70, location); name.original = node; name.text = ""; name.originalKeywordKind = 0; @@ -10290,22 +9766,22 @@ var ts; } ts.createToken = createToken; function createSuper() { - var node = createNode(95); + var node = createNode(96); return node; } ts.createSuper = createSuper; function createThis(location) { - var node = createNode(97, location); + var node = createNode(98, location); return node; } ts.createThis = createThis; function createNull() { - var node = createNode(93); + var node = createNode(94); return node; } ts.createNull = createNull; function createComputedPropertyName(expression, location) { - var node = createNode(140, location); + var node = createNode(141, location); node.expression = expression; return node; } @@ -10322,7 +9798,7 @@ var ts; } ts.createParameter = createParameter; function createParameterDeclaration(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer, location, flags) { - var node = createNode(142, location, flags); + var node = createNode(143, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.dotDotDotToken = dotDotDotToken; @@ -10341,7 +9817,7 @@ var ts; } ts.updateParameterDeclaration = updateParameterDeclaration; function createProperty(decorators, modifiers, name, questionToken, type, initializer, location) { - var node = createNode(145, location); + var node = createNode(146, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10359,7 +9835,7 @@ var ts; } ts.updateProperty = updateProperty; function createMethod(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(147, location, flags); + var node = createNode(148, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; @@ -10379,7 +9855,7 @@ var ts; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body, location, flags) { - var node = createNode(148, location, flags); + var node = createNode(149, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.typeParameters = undefined; @@ -10397,7 +9873,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body, location, flags) { - var node = createNode(149, location, flags); + var node = createNode(150, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10416,7 +9892,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body, location, flags) { - var node = createNode(150, location, flags); + var node = createNode(151, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10434,7 +9910,7 @@ var ts; } ts.updateSetAccessor = updateSetAccessor; function createObjectBindingPattern(elements, location) { - var node = createNode(167, location); + var node = createNode(168, location); node.elements = createNodeArray(elements); return node; } @@ -10447,7 +9923,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements, location) { - var node = createNode(168, location); + var node = createNode(169, location); node.elements = createNodeArray(elements); return node; } @@ -10460,7 +9936,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(propertyName, dotDotDotToken, name, initializer, location) { - var node = createNode(169, location); + var node = createNode(170, location); node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; node.dotDotDotToken = dotDotDotToken; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10476,7 +9952,7 @@ var ts; } ts.updateBindingElement = updateBindingElement; function createArrayLiteral(elements, location, multiLine) { - var node = createNode(170, location); + var node = createNode(171, location); node.elements = parenthesizeListElements(createNodeArray(elements)); if (multiLine) { node.multiLine = true; @@ -10492,7 +9968,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, location, multiLine) { - var node = createNode(171, location); + var node = createNode(172, location); node.properties = createNodeArray(properties); if (multiLine) { node.multiLine = true; @@ -10508,7 +9984,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name, location, flags) { - var node = createNode(172, location, flags); + var node = createNode(173, location, flags); node.expression = parenthesizeForAccess(expression); (node.emitNode || (node.emitNode = {})).flags |= 1048576; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10525,7 +10001,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index, location) { - var node = createNode(173, location); + var node = createNode(174, location); node.expression = parenthesizeForAccess(expression); node.argumentExpression = typeof index === "number" ? createLiteral(index) : index; return node; @@ -10539,7 +10015,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(174, location, flags); + var node = createNode(175, location, flags); node.expression = parenthesizeForAccess(expression); if (typeArguments) { node.typeArguments = createNodeArray(typeArguments); @@ -10556,7 +10032,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(175, location, flags); + var node = createNode(176, location, flags); node.expression = parenthesizeForNew(expression); node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; node.arguments = argumentsArray ? parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -10571,7 +10047,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, template, location) { - var node = createNode(176, location); + var node = createNode(177, location); node.tag = parenthesizeForAccess(tag); node.template = template; return node; @@ -10585,7 +10061,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createParen(expression, location) { - var node = createNode(178, location); + var node = createNode(179, location); node.expression = expression; return node; } @@ -10597,9 +10073,9 @@ var ts; return node; } ts.updateParen = updateParen; - function createFunctionExpression(asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(179, location, flags); - node.modifiers = undefined; + function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { + var node = createNode(180, location, flags); + node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; node.name = typeof name === "string" ? createIdentifier(name) : name; node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; @@ -10609,20 +10085,20 @@ var ts; return node; } ts.createFunctionExpression = createFunctionExpression; - function updateFunctionExpression(node, name, typeParameters, parameters, type, body) { - if (node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createFunctionExpression(node.asteriskToken, name, typeParameters, parameters, type, body, node, node.flags), node); + function updateFunctionExpression(node, modifiers, name, typeParameters, parameters, type, body) { + if (node.name !== name || node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { + return updateNode(createFunctionExpression(modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, node, node.flags), node); } return node; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body, location, flags) { - var node = createNode(180, location, flags); + var node = createNode(181, location, flags); node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; node.parameters = createNodeArray(parameters); node.type = type; - node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(34); + node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(35); node.body = parenthesizeConciseBody(body); return node; } @@ -10635,7 +10111,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression, location) { - var node = createNode(181, location); + var node = createNode(182, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10648,7 +10124,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression, location) { - var node = createNode(182, location); + var node = createNode(183, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10661,7 +10137,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression, location) { - var node = createNode(183, location); + var node = createNode(184, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10674,7 +10150,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression, location) { - var node = createNode(184, location); + var node = createNode(185, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10687,7 +10163,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand, location) { - var node = createNode(185, location); + var node = createNode(186, location); node.operator = operator; node.operand = parenthesizePrefixOperand(operand); return node; @@ -10701,7 +10177,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator, location) { - var node = createNode(186, location); + var node = createNode(187, location); node.operand = parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -10717,7 +10193,7 @@ var ts; function createBinary(left, operator, right, location) { var operatorToken = typeof operator === "number" ? createToken(operator) : operator; var operatorKind = operatorToken.kind; - var node = createNode(187, location); + var node = createNode(188, location); node.left = parenthesizeBinaryOperand(operatorKind, left, true, undefined); node.operatorToken = operatorToken; node.right = parenthesizeBinaryOperand(operatorKind, right, false, node.left); @@ -10732,7 +10208,7 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionToken, whenTrue, colonToken, whenFalse, location) { - var node = createNode(188, location); + var node = createNode(189, location); node.condition = condition; node.questionToken = questionToken; node.whenTrue = whenTrue; @@ -10749,7 +10225,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans, location) { - var node = createNode(189, location); + var node = createNode(190, location); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -10763,7 +10239,7 @@ var ts; } ts.updateTemplateExpression = updateTemplateExpression; function createYield(asteriskToken, expression, location) { - var node = createNode(190, location); + var node = createNode(191, location); node.asteriskToken = asteriskToken; node.expression = expression; return node; @@ -10777,7 +10253,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression, location) { - var node = createNode(191, location); + var node = createNode(192, location); node.expression = parenthesizeExpressionForList(expression); return node; } @@ -10790,7 +10266,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(192, location); + var node = createNode(193, location); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -10808,12 +10284,12 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression(location) { - var node = createNode(193, location); + var node = createNode(194, location); return node; } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression, location) { - var node = createNode(194, location); + var node = createNode(195, location); node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; node.expression = parenthesizeForAccess(expression); return node; @@ -10827,7 +10303,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createTemplateSpan(expression, literal, location) { - var node = createNode(197, location); + var node = createNode(198, location); node.expression = expression; node.literal = literal; return node; @@ -10841,7 +10317,7 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createBlock(statements, location, multiLine, flags) { - var block = createNode(199, location, flags); + var block = createNode(200, location, flags); block.statements = createNodeArray(statements); if (multiLine) { block.multiLine = true; @@ -10857,7 +10333,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList, location, flags) { - var node = createNode(200, location, flags); + var node = createNode(201, location, flags); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -10872,7 +10348,7 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createVariableDeclarationList(declarations, location, flags) { - var node = createNode(219, location, flags); + var node = createNode(220, location, flags); node.declarations = createNodeArray(declarations); return node; } @@ -10885,7 +10361,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createVariableDeclaration(name, type, initializer, location, flags) { - var node = createNode(218, location, flags); + var node = createNode(219, location, flags); node.name = typeof name === "string" ? createIdentifier(name) : name; node.type = type; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -10900,11 +10376,11 @@ var ts; } ts.updateVariableDeclaration = updateVariableDeclaration; function createEmptyStatement(location) { - return createNode(201, location); + return createNode(202, location); } ts.createEmptyStatement = createEmptyStatement; function createStatement(expression, location, flags) { - var node = createNode(202, location, flags); + var node = createNode(203, location, flags); node.expression = parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -10917,7 +10393,7 @@ var ts; } ts.updateStatement = updateStatement; function createIf(expression, thenStatement, elseStatement, location) { - var node = createNode(203, location); + var node = createNode(204, location); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -10932,7 +10408,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression, location) { - var node = createNode(204, location); + var node = createNode(205, location); node.statement = statement; node.expression = expression; return node; @@ -10946,7 +10422,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement, location) { - var node = createNode(205, location); + var node = createNode(206, location); node.expression = expression; node.statement = statement; return node; @@ -10960,7 +10436,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement, location) { - var node = createNode(206, location, undefined); + var node = createNode(207, location, undefined); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -10976,7 +10452,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement, location) { - var node = createNode(207, location); + var node = createNode(208, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -10991,7 +10467,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(initializer, expression, statement, location) { - var node = createNode(208, location); + var node = createNode(209, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11006,7 +10482,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label, location) { - var node = createNode(209, location); + var node = createNode(210, location); if (label) { node.label = label; } @@ -11021,7 +10497,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label, location) { - var node = createNode(210, location); + var node = createNode(211, location); if (label) { node.label = label; } @@ -11036,7 +10512,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression, location) { - var node = createNode(211, location); + var node = createNode(212, location); node.expression = expression; return node; } @@ -11049,7 +10525,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement, location) { - var node = createNode(212, location); + var node = createNode(213, location); node.expression = expression; node.statement = statement; return node; @@ -11063,7 +10539,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock, location) { - var node = createNode(213, location); + var node = createNode(214, location); node.expression = parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -11077,7 +10553,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement, location) { - var node = createNode(214, location); + var node = createNode(215, location); node.label = typeof label === "string" ? createIdentifier(label) : label; node.statement = statement; return node; @@ -11091,7 +10567,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression, location) { - var node = createNode(215, location); + var node = createNode(216, location); node.expression = expression; return node; } @@ -11104,7 +10580,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock, location) { - var node = createNode(216, location); + var node = createNode(217, location); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -11119,7 +10595,7 @@ var ts; } ts.updateTry = updateTry; function createCaseBlock(clauses, location) { - var node = createNode(227, location); + var node = createNode(228, location); node.clauses = createNodeArray(clauses); return node; } @@ -11132,7 +10608,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(220, location, flags); + var node = createNode(221, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; @@ -11152,7 +10628,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(221, location); + var node = createNode(222, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -11170,7 +10646,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, location) { - var node = createNode(230, location); + var node = createNode(231, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.importClause = importClause; @@ -11186,7 +10662,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings, location) { - var node = createNode(231, location); + var node = createNode(232, location); node.name = name; node.namedBindings = namedBindings; return node; @@ -11200,7 +10676,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name, location) { - var node = createNode(232, location); + var node = createNode(233, location); node.name = name; return node; } @@ -11213,7 +10689,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements, location) { - var node = createNode(233, location); + var node = createNode(234, location); node.elements = createNodeArray(elements); return node; } @@ -11226,7 +10702,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name, location) { - var node = createNode(234, location); + var node = createNode(235, location); node.propertyName = propertyName; node.name = name; return node; @@ -11240,7 +10716,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression, location) { - var node = createNode(235, location); + var node = createNode(236, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.isExportEquals = isExportEquals; @@ -11256,7 +10732,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, location) { - var node = createNode(236, location); + var node = createNode(237, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.exportClause = exportClause; @@ -11272,7 +10748,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements, location) { - var node = createNode(237, location); + var node = createNode(238, location); node.elements = createNodeArray(elements); return node; } @@ -11285,7 +10761,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(name, propertyName, location) { - var node = createNode(238, location); + var node = createNode(239, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; return node; @@ -11299,7 +10775,7 @@ var ts; } ts.updateExportSpecifier = updateExportSpecifier; function createJsxElement(openingElement, children, closingElement, location) { - var node = createNode(241, location); + var node = createNode(242, location); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -11314,7 +10790,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, attributes, location) { - var node = createNode(242, location); + var node = createNode(243, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -11328,7 +10804,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, attributes, location) { - var node = createNode(243, location); + var node = createNode(244, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -11562,47 +11038,47 @@ var ts; } ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function createComma(left, right) { - return createBinary(left, 24, right); + return createBinary(left, 25, right); } ts.createComma = createComma; function createLessThan(left, right, location) { - return createBinary(left, 25, right, location); + return createBinary(left, 26, right, location); } ts.createLessThan = createLessThan; function createAssignment(left, right, location) { - return createBinary(left, 56, right, location); + return createBinary(left, 57, right, location); } ts.createAssignment = createAssignment; function createStrictEquality(left, right) { - return createBinary(left, 32, right); + return createBinary(left, 33, right); } ts.createStrictEquality = createStrictEquality; function createStrictInequality(left, right) { - return createBinary(left, 33, right); + return createBinary(left, 34, right); } ts.createStrictInequality = createStrictInequality; function createAdd(left, right) { - return createBinary(left, 35, right); + return createBinary(left, 36, right); } ts.createAdd = createAdd; function createSubtract(left, right) { - return createBinary(left, 36, right); + return createBinary(left, 37, right); } ts.createSubtract = createSubtract; function createPostfixIncrement(operand, location) { - return createPostfix(operand, 41, location); + return createPostfix(operand, 42, location); } ts.createPostfixIncrement = createPostfixIncrement; function createLogicalAnd(left, right) { - return createBinary(left, 51, right); + return createBinary(left, 52, right); } ts.createLogicalAnd = createLogicalAnd; function createLogicalOr(left, right) { - return createBinary(left, 52, right); + return createBinary(left, 53, right); } ts.createLogicalOr = createLogicalOr; function createLogicalNot(operand) { - return createPrefix(49, operand); + return createPrefix(50, operand); } ts.createLogicalNot = createLogicalNot; function createVoidZero() { @@ -11621,7 +11097,7 @@ var ts; } ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName; function createRestParameter(name) { - return createParameterDeclaration(undefined, undefined, createToken(22), name, undefined, undefined, undefined); + return createParameterDeclaration(undefined, undefined, createToken(23), name, undefined, undefined, undefined); } ts.createRestParameter = createRestParameter; function createFunctionCall(func, thisArg, argumentsList, location) { @@ -11735,7 +11211,7 @@ var ts; } ts.createDecorateHelper = createDecorateHelper; function createAwaiterHelper(externalHelpersModuleName, hasLexicalArguments, promiseConstructor, body) { - var generatorFunc = createFunctionExpression(createToken(37), undefined, undefined, [], undefined, body); + var generatorFunc = createFunctionExpression(undefined, createToken(38), undefined, undefined, [], undefined, body); (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 2097152; return createCall(createHelperName(externalHelpersModuleName, "__awaiter"), undefined, [ createThis(), @@ -11779,7 +11255,7 @@ var ts; setter ])))))); return createVariableStatement(undefined, createConstDeclarationList([ - createVariableDeclaration("_super", undefined, createCall(createParen(createFunctionExpression(undefined, undefined, undefined, [ + createVariableDeclaration("_super", undefined, createCall(createParen(createFunctionExpression(undefined, undefined, undefined, undefined, [ createParameter("geti"), createParameter("seti") ], undefined, createBlock([ @@ -11801,19 +11277,19 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = skipParentheses(node); switch (target.kind) { - case 69: + case 70: return cacheIdentifiers; - case 97: + case 98: case 8: case 9: return false; - case 170: + case 171: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 171: + case 172: return target.properties.length > 0; default: return true; @@ -11827,13 +11303,13 @@ var ts; thisArg = createThis(); target = callee; } - else if (callee.kind === 95) { + else if (callee.kind === 96) { thisArg = createThis(); target = languageVersion < 2 ? createIdentifier("_super", callee) : callee; } else { switch (callee.kind) { - case 172: { + case 173: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { thisArg = createTempVariable(recordTempVariable); target = createPropertyAccess(createAssignment(thisArg, callee.expression, callee.expression), callee.name, callee); @@ -11844,7 +11320,7 @@ var ts; } break; } - case 173: { + case 174: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { thisArg = createTempVariable(recordTempVariable); target = createElementAccess(createAssignment(thisArg, callee.expression, callee.expression), callee.argumentExpression, callee); @@ -11894,14 +11370,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 149: case 150: + case 151: return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); case 253: return createExpressionForPropertyAssignment(property, receiver); case 254: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 147: + case 148: return createExpressionForMethodDeclaration(property, receiver); } } @@ -11911,13 +11387,13 @@ var ts; if (property === firstAccessor) { var properties_1 = []; if (getAccessor) { - var getterFunction = createFunctionExpression(undefined, undefined, undefined, getAccessor.parameters, undefined, getAccessor.body, getAccessor); + var getterFunction = createFunctionExpression(getAccessor.modifiers, undefined, undefined, undefined, getAccessor.parameters, undefined, getAccessor.body, getAccessor); setOriginalNode(getterFunction, getAccessor); var getter = createPropertyAssignment("get", getterFunction); properties_1.push(getter); } if (setAccessor) { - var setterFunction = createFunctionExpression(undefined, undefined, undefined, setAccessor.parameters, undefined, setAccessor.body, setAccessor); + var setterFunction = createFunctionExpression(setAccessor.modifiers, undefined, undefined, undefined, setAccessor.parameters, undefined, setAccessor.body, setAccessor); setOriginalNode(setterFunction, setAccessor); var setter = createPropertyAssignment("set", setterFunction); properties_1.push(setter); @@ -11940,13 +11416,13 @@ var ts; return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, property.name, property.name), getSynthesizedClone(property.name), property), property)); } function createExpressionForMethodDeclaration(method, receiver) { - return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, method.name, method.name), setOriginalNode(createFunctionExpression(method.asteriskToken, undefined, undefined, method.parameters, undefined, method.body, method), method), method), method)); + return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, method.name, method.name), setOriginalNode(createFunctionExpression(method.modifiers, method.asteriskToken, undefined, undefined, method.parameters, undefined, method.body, method), method), method), method)); } function isUseStrictPrologue(node) { return node.expression.text === "use strict"; } function addPrologueDirectives(target, source, ensureUseStrict, visitor) { - ts.Debug.assert(target.length === 0, "PrologueDirectives should be at the first statement in the target statements array"); + ts.Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array"); var foundUseStrict = false; var statementOffset = 0; var numStatements = source.length; @@ -11959,16 +11435,20 @@ var ts; target.push(statement); } else { - if (ensureUseStrict && !foundUseStrict) { - target.push(startOnNewLine(createStatement(createLiteral("use strict")))); - foundUseStrict = true; - } - if (getEmitFlags(statement) & 8388608) { - target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); - } - else { - break; - } + break; + } + statementOffset++; + } + if (ensureUseStrict && !foundUseStrict) { + target.push(startOnNewLine(createStatement(createLiteral("use strict")))); + } + while (statementOffset < numStatements) { + var statement = source[statementOffset]; + if (getEmitFlags(statement) & 8388608) { + target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); + } + else { + break; } statementOffset++; } @@ -11999,7 +11479,7 @@ var ts; ts.ensureUseStrict = ensureUseStrict; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = skipPartiallyEmittedExpressions(operand); - if (skipped.kind === 178) { + if (skipped.kind === 179) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -12008,15 +11488,15 @@ var ts; } ts.parenthesizeBinaryOperand = parenthesizeBinaryOperand; function binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { - var binaryOperatorPrecedence = ts.getOperatorPrecedence(187, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(187, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(188, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(188, binaryOperator); var emittedOperand = skipPartiallyEmittedExpressions(operand); var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { case -1: if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 - && operand.kind === 190) { + && operand.kind === 191) { return false; } return true; @@ -12032,7 +11512,7 @@ var ts; if (operatorHasAssociativeProperty(binaryOperator)) { return false; } - if (binaryOperator === 35) { + if (binaryOperator === 36) { var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0; if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { return false; @@ -12045,17 +11525,17 @@ var ts; } } function operatorHasAssociativeProperty(binaryOperator) { - return binaryOperator === 37 + return binaryOperator === 38 + || binaryOperator === 48 || binaryOperator === 47 - || binaryOperator === 46 - || binaryOperator === 48; + || binaryOperator === 49; } function getLiteralKindOfBinaryPlusOperand(node) { node = skipPartiallyEmittedExpressions(node); if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 187 && node.operatorToken.kind === 35) { + if (node.kind === 188 && node.operatorToken.kind === 36) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -12072,9 +11552,9 @@ var ts; function parenthesizeForNew(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); switch (emittedExpression.kind) { - case 174: - return createParen(expression); case 175: + return createParen(expression); + case 176: return emittedExpression.arguments ? expression : createParen(expression); @@ -12085,7 +11565,7 @@ var ts; function parenthesizeForAccess(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 175 || emittedExpression.arguments) + && (emittedExpression.kind !== 176 || emittedExpression.arguments) && emittedExpression.kind !== 8) { return expression; } @@ -12123,7 +11603,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(187, 24); + var commaPrecedence = ts.getOperatorPrecedence(188, 25); return expressionPrecedence > commaPrecedence ? expression : createParen(expression, expression); @@ -12134,7 +11614,7 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = skipPartiallyEmittedExpressions(callee).kind; - if (kind === 179 || kind === 180) { + if (kind === 180 || kind === 181) { var mutableCall = getMutableClone(emittedExpression); mutableCall.expression = createParen(callee, callee); return recreatePartiallyEmittedExpressions(expression, mutableCall); @@ -12142,7 +11622,7 @@ var ts; } else { var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; - if (leftmostExpressionKind === 171 || leftmostExpressionKind === 179) { + if (leftmostExpressionKind === 172 || leftmostExpressionKind === 180) { return createParen(expression, expression); } } @@ -12160,18 +11640,18 @@ var ts; function getLeftmostExpression(node) { while (true) { switch (node.kind) { - case 186: + case 187: node = node.operand; continue; - case 187: + case 188: node = node.left; continue; - case 188: + case 189: node = node.condition; continue; + case 175: case 174: case 173: - case 172: node = node.expression; continue; case 288: @@ -12183,12 +11663,19 @@ var ts; } function parenthesizeConciseBody(body) { var emittedBody = skipPartiallyEmittedExpressions(body); - if (emittedBody.kind === 171) { + if (emittedBody.kind === 172) { return createParen(body, body); } return body; } ts.parenthesizeConciseBody = parenthesizeConciseBody; + (function (OuterExpressionKinds) { + OuterExpressionKinds[OuterExpressionKinds["Parentheses"] = 1] = "Parentheses"; + OuterExpressionKinds[OuterExpressionKinds["Assertions"] = 2] = "Assertions"; + OuterExpressionKinds[OuterExpressionKinds["PartiallyEmittedExpressions"] = 4] = "PartiallyEmittedExpressions"; + OuterExpressionKinds[OuterExpressionKinds["All"] = 7] = "All"; + })(ts.OuterExpressionKinds || (ts.OuterExpressionKinds = {})); + var OuterExpressionKinds = ts.OuterExpressionKinds; function skipOuterExpressions(node, kinds) { if (kinds === void 0) { kinds = 7; } var previousNode; @@ -12208,7 +11695,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipParentheses(node) { - while (node.kind === 178) { + while (node.kind === 179) { node = node.expression; } return node; @@ -12368,13 +11855,13 @@ var ts; function getLocalNameForExternalImport(node, sourceFile) { var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); if (namespaceDeclaration && !ts.isDefaultImport(node)) { - var name_12 = namespaceDeclaration.name; - return ts.isGeneratedIdentifier(name_12) ? name_12 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); + var name_9 = namespaceDeclaration.name; + return ts.isGeneratedIdentifier(name_9) ? name_9 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); } - if (node.kind === 230 && node.importClause) { + if (node.kind === 231 && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 236 && node.moduleSpecifier) { + if (node.kind === 237 && node.moduleSpecifier) { return getGeneratedNameForNode(node); } return undefined; @@ -12423,10 +11910,10 @@ var ts; if (kind === 256) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } - else if (kind === 69) { + else if (kind === 70) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } - else if (kind < 139) { + else if (kind < 140) { return new (TokenConstructor || (TokenConstructor = ts.objectAllocator.getTokenConstructor()))(kind, pos, end); } else { @@ -12462,10 +11949,10 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 139: + case 140: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 141: + case 142: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); @@ -12476,12 +11963,12 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 142: + case 143: + case 146: case 145: - case 144: case 253: - case 218: - case 169: + case 219: + case 170: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -12490,24 +11977,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 156: case 157: - case 151: + case 158: case 152: case 153: + case 154: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 147: - case 146: case 148: + case 147: case 149: case 150: - case 179: - case 220: + case 151: case 180: + case 221: + case 181: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -12518,163 +12005,156 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 155: + case 156: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 154: + case 155: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 158: - return visitNode(cbNode, node.exprName); case 159: - return visitNodes(cbNodes, node.members); + return visitNode(cbNode, node.exprName); case 160: - return visitNode(cbNode, node.elementType); + return visitNodes(cbNodes, node.members); case 161: - return visitNodes(cbNodes, node.elementTypes); + return visitNode(cbNode, node.elementType); case 162: + return visitNodes(cbNodes, node.elementTypes); case 163: - return visitNodes(cbNodes, node.types); case 164: + return visitNodes(cbNodes, node.types); + case 165: return visitNode(cbNode, node.type); - case 166: - return visitNode(cbNode, node.literal); case 167: + return visitNode(cbNode, node.literal); case 168: - return visitNodes(cbNodes, node.elements); - case 170: + case 169: return visitNodes(cbNodes, node.elements); case 171: - return visitNodes(cbNodes, node.properties); + return visitNodes(cbNodes, node.elements); case 172: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.name); + return visitNodes(cbNodes, node.properties); case 173: return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.argumentExpression); + visitNode(cbNode, node.name); case 174: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.argumentExpression); case 175: + case 176: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 176: + case 177: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 177: + case 178: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 178: - return visitNode(cbNode, node.expression); - case 181: + case 179: return visitNode(cbNode, node.expression); case 182: return visitNode(cbNode, node.expression); case 183: return visitNode(cbNode, node.expression); - case 185: - return visitNode(cbNode, node.operand); - case 190: - return visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.expression); case 184: return visitNode(cbNode, node.expression); case 186: return visitNode(cbNode, node.operand); + case 191: + return visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.expression); + case 185: + return visitNode(cbNode, node.expression); case 187: + return visitNode(cbNode, node.operand); + case 188: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 195: + case 196: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 196: + case 197: return visitNode(cbNode, node.expression); - case 188: + case 189: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 191: + case 192: return visitNode(cbNode, node.expression); - case 199: - case 226: + case 200: + case 227: return visitNodes(cbNodes, node.statements); case 256: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 200: + case 201: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 219: + case 220: return visitNodes(cbNodes, node.declarations); - case 202: - return visitNode(cbNode, node.expression); case 203: + return visitNode(cbNode, node.expression); + case 204: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 204: + case 205: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 205: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); case 206: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.condition) || - visitNode(cbNode, node.incrementor) || + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 207: return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || + visitNode(cbNode, node.condition) || + visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); case 208: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 209: - case 210: - return visitNode(cbNode, node.label); - case 211: - return visitNode(cbNode, node.expression); - case 212: - return visitNode(cbNode, node.expression) || + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); + case 210: + case 211: + return visitNode(cbNode, node.label); + case 212: + return visitNode(cbNode, node.expression); case 213: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 214: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 227: + case 228: return visitNodes(cbNodes, node.clauses); case 249: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); case 250: return visitNodes(cbNodes, node.statements); - case 214: + case 215: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 215: - return visitNode(cbNode, node.expression); case 216: + return visitNode(cbNode, node.expression); + case 217: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); case 252: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 143: + case 144: return visitNode(cbNode, node.expression); - case 221: - case 192: - 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 222: + case 193: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -12686,8 +12166,15 @@ var ts; visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || - visitNode(cbNode, node.type); + visitNodes(cbNodes, node.heritageClauses) || + visitNodes(cbNodes, node.members); case 224: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNode(cbNode, node.type); + case 225: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -12695,65 +12182,65 @@ var ts; case 255: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 225: + case 226: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 229: + case 230: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 230: + case 231: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 231: + case 232: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 228: - return visitNode(cbNode, node.name); - case 232: + case 229: return visitNode(cbNode, node.name); case 233: - case 237: + return visitNode(cbNode, node.name); + case 234: + case 238: return visitNodes(cbNodes, node.elements); - case 236: + case 237: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 234: - case 238: + case 235: + case 239: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 235: + case 236: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 189: + case 190: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 197: + case 198: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 140: + case 141: return visitNode(cbNode, node.expression); case 251: return visitNodes(cbNodes, node.types); - case 194: + case 195: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 240: - return visitNode(cbNode, node.expression); - case 239: - return visitNodes(cbNodes, node.decorators); case 241: + return visitNode(cbNode, node.expression); + case 240: + return visitNodes(cbNodes, node.decorators); + case 242: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 242: case 243: + case 244: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); case 246: @@ -12855,7 +12342,7 @@ var ts; ts.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; var Parser; (function (Parser) { - var scanner = ts.createScanner(2, true); + var scanner = ts.createScanner(4, true); var disallowInAndDecoratorContext = 32768 | 131072; var NodeConstructor; var TokenConstructor; @@ -12872,9 +12359,9 @@ var ts; var parsingContext; var contextFlags; var parseErrorBeforeNextFinishedNode = false; - function parseSourceFile(fileName, _sourceText, languageVersion, _syntaxCursor, setParentNodes, scriptKind) { + function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes, scriptKind) { scriptKind = ts.ensureScriptKind(fileName, scriptKind); - initializeState(fileName, _sourceText, languageVersion, _syntaxCursor, scriptKind); + initializeState(sourceText, languageVersion, syntaxCursor, scriptKind); var result = parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind); clearState(); return result; @@ -12883,7 +12370,7 @@ var ts; function getLanguageVariant(scriptKind) { return scriptKind === 4 || scriptKind === 2 || scriptKind === 1 ? 1 : 0; } - function initializeState(fileName, _sourceText, languageVersion, _syntaxCursor, scriptKind) { + function initializeState(_sourceText, languageVersion, _syntaxCursor, scriptKind) { NodeConstructor = ts.objectAllocator.getNodeConstructor(); TokenConstructor = ts.objectAllocator.getTokenConstructor(); IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor(); @@ -13126,16 +12613,16 @@ var ts; return speculationHelper(callback, false); } function isIdentifier() { - if (token() === 69) { + if (token() === 70) { return true; } - if (token() === 114 && inYieldContext()) { + if (token() === 115 && inYieldContext()) { return false; } - if (token() === 119 && inAwaitContext()) { + if (token() === 120 && inAwaitContext()) { return false; } - return token() > 105; + return token() > 106; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -13176,20 +12663,20 @@ var ts; return finishNode(node); } function canParseSemicolon() { - if (token() === 23) { + if (token() === 24) { return true; } - return token() === 16 || token() === 1 || scanner.hasPrecedingLineBreak(); + return token() === 17 || token() === 1 || scanner.hasPrecedingLineBreak(); } function parseSemicolon() { if (canParseSemicolon()) { - if (token() === 23) { + if (token() === 24) { nextToken(); } return true; } else { - return parseExpected(23); + return parseExpected(24); } } function createNode(kind, pos) { @@ -13197,8 +12684,8 @@ var ts; if (!(pos >= 0)) { pos = scanner.getStartPos(); } - return kind >= 139 ? new NodeConstructor(kind, pos, pos) : - kind === 69 ? new IdentifierConstructor(kind, pos, pos) : + return kind >= 140 ? new NodeConstructor(kind, pos, pos) : + kind === 70 ? new IdentifierConstructor(kind, pos, pos) : new TokenConstructor(kind, pos, pos); } function createNodeArray(elements, pos) { @@ -13239,15 +12726,15 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(69); - if (token() !== 69) { + var node = createNode(70); + if (token() !== 70) { node.originalKeywordKind = token(); } node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - return createMissingNode(69, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(70, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -13264,7 +12751,7 @@ var ts; if (token() === 9 || token() === 8) { return parseLiteralNode(true); } - if (allowComputedPropertyNames && token() === 19) { + if (allowComputedPropertyNames && token() === 20) { return parseComputedPropertyName(); } return parseIdentifierName(); @@ -13279,10 +12766,10 @@ var ts; return token() === 9 || token() === 8 || ts.tokenIsIdentifierOrKeyword(token()); } function parseComputedPropertyName() { - var node = createNode(140); - parseExpected(19); - node.expression = allowInAnd(parseExpression); + var node = createNode(141); parseExpected(20); + node.expression = allowInAnd(parseExpression); + parseExpected(21); return finishNode(node); } function parseContextualModifier(t) { @@ -13296,20 +12783,20 @@ var ts; return canFollowModifier(); } function nextTokenCanFollowModifier() { - if (token() === 74) { - return nextToken() === 81; + if (token() === 75) { + return nextToken() === 82; } - if (token() === 82) { + if (token() === 83) { nextToken(); - if (token() === 77) { + if (token() === 78) { return lookAhead(nextTokenIsClassOrFunctionOrAsync); } - return token() !== 37 && token() !== 116 && token() !== 15 && canFollowModifier(); + return token() !== 38 && token() !== 117 && token() !== 16 && canFollowModifier(); } - if (token() === 77) { + if (token() === 78) { return nextTokenIsClassOrFunctionOrAsync(); } - if (token() === 113) { + if (token() === 114) { nextToken(); return canFollowModifier(); } @@ -13319,16 +12806,16 @@ var ts; return ts.isModifierKind(token()) && tryParse(nextTokenCanFollowModifier); } function canFollowModifier() { - return token() === 19 - || token() === 15 - || token() === 37 - || token() === 22 + return token() === 20 + || token() === 16 + || token() === 38 + || token() === 23 || isLiteralPropertyName(); } function nextTokenIsClassOrFunctionOrAsync() { nextToken(); - return token() === 73 || token() === 87 || - (token() === 118 && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 74 || token() === 88 || + (token() === 119 && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } function isListElement(parsingContext, inErrorRecovery) { var node = currentNode(parsingContext); @@ -13339,21 +12826,21 @@ var ts; case 0: case 1: case 3: - return !(token() === 23 && inErrorRecovery) && isStartOfStatement(); + return !(token() === 24 && inErrorRecovery) && isStartOfStatement(); case 2: - return token() === 71 || token() === 77; + return token() === 72 || token() === 78; case 4: return lookAhead(isTypeMemberStart); case 5: - return lookAhead(isClassMemberStart) || (token() === 23 && !inErrorRecovery); + return lookAhead(isClassMemberStart) || (token() === 24 && !inErrorRecovery); case 6: - return token() === 19 || isLiteralPropertyName(); + return token() === 20 || isLiteralPropertyName(); case 12: - return token() === 19 || token() === 37 || isLiteralPropertyName(); + return token() === 20 || token() === 38 || isLiteralPropertyName(); case 9: - return token() === 19 || isLiteralPropertyName(); + return token() === 20 || isLiteralPropertyName(); case 7: - if (token() === 15) { + if (token() === 16) { return lookAhead(isValidHeritageClauseObjectLiteral); } if (!inErrorRecovery) { @@ -13365,23 +12852,23 @@ var ts; case 8: return isIdentifierOrPattern(); case 10: - return token() === 24 || token() === 22 || isIdentifierOrPattern(); + return token() === 25 || token() === 23 || isIdentifierOrPattern(); case 17: return isIdentifier(); case 11: case 15: - return token() === 24 || token() === 22 || isStartOfExpression(); + return token() === 25 || token() === 23 || isStartOfExpression(); case 16: return isStartOfParameter(); case 18: case 19: - return token() === 24 || isStartOfType(); + return token() === 25 || isStartOfType(); case 20: return isHeritageClause(); case 21: return ts.tokenIsIdentifierOrKeyword(token()); case 13: - return ts.tokenIsIdentifierOrKeyword(token()) || token() === 15; + return ts.tokenIsIdentifierOrKeyword(token()) || token() === 16; case 14: return true; case 22: @@ -13394,10 +12881,10 @@ var ts; ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token() === 15); - if (nextToken() === 16) { + ts.Debug.assert(token() === 16); + if (nextToken() === 17) { var next = nextToken(); - return next === 24 || next === 15 || next === 83 || next === 106; + return next === 25 || next === 16 || next === 84 || next === 107; } return true; } @@ -13410,8 +12897,8 @@ var ts; return ts.tokenIsIdentifierOrKeyword(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 106 || - token() === 83) { + if (token() === 107 || + token() === 84) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -13433,39 +12920,39 @@ var ts; case 12: case 9: case 21: - return token() === 16; + return token() === 17; case 3: - return token() === 16 || token() === 71 || token() === 77; + return token() === 17 || token() === 72 || token() === 78; case 7: - return token() === 15 || token() === 83 || token() === 106; + return token() === 16 || token() === 84 || token() === 107; case 8: return isVariableDeclaratorListTerminator(); case 17: - return token() === 27 || token() === 17 || token() === 15 || token() === 83 || token() === 106; + return token() === 28 || token() === 18 || token() === 16 || token() === 84 || token() === 107; case 11: - return token() === 18 || token() === 23; + return token() === 19 || token() === 24; case 15: case 19: case 10: - return token() === 20; + return token() === 21; case 16: - return token() === 18 || token() === 20; + return token() === 19 || token() === 21; case 18: - return token() !== 24; + return token() !== 25; case 20: - return token() === 15 || token() === 16; + return token() === 16 || token() === 17; case 13: - return token() === 27 || token() === 39; + return token() === 28 || token() === 40; case 14: - return token() === 25 && lookAhead(nextTokenIsSlash); + return token() === 26 && lookAhead(nextTokenIsSlash); case 22: - return token() === 18 || token() === 54 || token() === 16; + return token() === 19 || token() === 55 || token() === 17; case 23: - return token() === 27 || token() === 16; + return token() === 28 || token() === 17; case 25: - return token() === 20 || token() === 16; + return token() === 21 || token() === 17; case 24: - return token() === 16; + return token() === 17; } } function isVariableDeclaratorListTerminator() { @@ -13475,7 +12962,7 @@ var ts; if (isInOrOfKeyword(token())) { return true; } - if (token() === 34) { + if (token() === 35) { return true; } return false; @@ -13579,17 +13066,17 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 148: - case 153: case 149: + case 154: case 150: - case 145: - case 198: + case 151: + case 146: + case 199: return true; - case 147: + case 148: var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 69 && - methodDeclaration.name.originalKeywordKind === 121; + var nameIsConstructor = methodDeclaration.name.kind === 70 && + methodDeclaration.name.originalKeywordKind === 122; return !nameIsConstructor; } } @@ -13608,35 +13095,35 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 220: + case 221: + case 201: case 200: - case 199: + case 204: case 203: - case 202: - case 215: + case 216: + case 212: + case 214: case 211: - case 213: case 210: + case 208: case 209: case 207: - case 208: case 206: - case 205: - case 212: - case 201: - case 216: - case 214: - case 204: + case 213: + case 202: case 217: + case 215: + case 205: + case 218: + case 231: case 230: - case 229: + case 237: case 236: - case 235: - case 225: - case 221: + case 226: case 222: - case 224: case 223: + case 225: + case 224: return true; } } @@ -13648,25 +13135,25 @@ var ts; function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 152: - case 146: case 153: - case 144: - case 151: + case 147: + case 154: + case 145: + case 152: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 218) { + if (node.kind !== 219) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 142) { + if (node.kind !== 143) { return false; } var parameter = node; @@ -13720,15 +13207,15 @@ var ts; if (isListElement(kind, false)) { result.push(parseListElement(kind, parseElement)); commaStart = scanner.getTokenPos(); - if (parseOptional(24)) { + if (parseOptional(25)) { continue; } commaStart = -1; if (isListTerminator(kind)) { break; } - parseExpected(24); - if (considerSemicolonAsDelimiter && token() === 23 && !scanner.hasPrecedingLineBreak()) { + parseExpected(25); + if (considerSemicolonAsDelimiter && token() === 24 && !scanner.hasPrecedingLineBreak()) { nextToken(); } continue; @@ -13760,8 +13247,8 @@ var ts; } function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); - while (parseOptional(21)) { - var node = createNode(139, entity.pos); + while (parseOptional(22)) { + var node = createNode(140, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -13772,33 +13259,33 @@ var ts; if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token())) { var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); if (matchesPattern) { - return createMissingNode(69, true, ts.Diagnostics.Identifier_expected); + return createMissingNode(70, true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(189); + var template = createNode(190); template.head = parseTemplateHead(); - ts.Debug.assert(template.head.kind === 12, "Template head has wrong token kind"); + ts.Debug.assert(template.head.kind === 13, "Template head has wrong token kind"); var templateSpans = createNodeArray(); do { templateSpans.push(parseTemplateSpan()); - } while (ts.lastOrUndefined(templateSpans).literal.kind === 13); + } while (ts.lastOrUndefined(templateSpans).literal.kind === 14); templateSpans.end = getNodeEnd(); template.templateSpans = templateSpans; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(197); + var span = createNode(198); span.expression = allowInAnd(parseExpression); var literal; - if (token() === 16) { + if (token() === 17) { reScanTemplateToken(); literal = parseTemplateMiddleOrTemplateTail(); } else { - literal = parseExpectedToken(14, false, ts.Diagnostics._0_expected, ts.tokenToString(16)); + literal = parseExpectedToken(15, false, ts.Diagnostics._0_expected, ts.tokenToString(17)); } span.literal = literal; return finishNode(span); @@ -13808,12 +13295,12 @@ var ts; } function parseTemplateHead() { var fragment = parseLiteralLikeNode(token(), false); - ts.Debug.assert(fragment.kind === 12, "Template head has wrong token kind"); + ts.Debug.assert(fragment.kind === 13, "Template head has wrong token kind"); return fragment; } function parseTemplateMiddleOrTemplateTail() { var fragment = parseLiteralLikeNode(token(), false); - ts.Debug.assert(fragment.kind === 13 || fragment.kind === 14, "Template fragment has wrong token kind"); + ts.Debug.assert(fragment.kind === 14 || fragment.kind === 15, "Template fragment has wrong token kind"); return fragment; } function parseLiteralLikeNode(kind, internName) { @@ -13838,35 +13325,35 @@ var ts; } function parseTypeReference() { var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - var node = createNode(155, typeName.pos); + var node = createNode(156, typeName.pos); node.typeName = typeName; - if (!scanner.hasPrecedingLineBreak() && token() === 25) { - node.typeArguments = parseBracketedList(18, parseType, 25, 27); + if (!scanner.hasPrecedingLineBreak() && token() === 26) { + node.typeArguments = parseBracketedList(18, parseType, 26, 28); } return finishNode(node); } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(154, lhs.pos); + var node = createNode(155, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(165); + var node = createNode(166); nextToken(); return finishNode(node); } function parseTypeQuery() { - var node = createNode(158); - parseExpected(101); + var node = createNode(159); + parseExpected(102); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(141); + var node = createNode(142); node.name = parseIdentifier(); - if (parseOptional(83)) { + if (parseOptional(84)) { if (isStartOfType() || !isStartOfExpression()) { node.constraint = parseType(); } @@ -13877,34 +13364,34 @@ var ts; return finishNode(node); } function parseTypeParameters() { - if (token() === 25) { - return parseBracketedList(17, parseTypeParameter, 25, 27); + if (token() === 26) { + return parseBracketedList(17, parseTypeParameter, 26, 28); } } function parseParameterType() { - if (parseOptional(54)) { + if (parseOptional(55)) { return parseType(); } return undefined; } function isStartOfParameter() { - return token() === 22 || isIdentifierOrPattern() || ts.isModifierKind(token()) || token() === 55 || token() === 97; + return token() === 23 || isIdentifierOrPattern() || ts.isModifierKind(token()) || token() === 56 || token() === 98; } function parseParameter() { - var node = createNode(142); - if (token() === 97) { + var node = createNode(143); + if (token() === 98) { node.name = createIdentifier(true, undefined); node.type = parseParameterType(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - node.dotDotDotToken = parseOptionalToken(22); + node.dotDotDotToken = parseOptionalToken(23); node.name = parseIdentifierOrPattern(); if (ts.getFullWidth(node.name) === 0 && !ts.hasModifiers(node) && ts.isModifierKind(token())) { nextToken(); } - node.questionToken = parseOptionalToken(53); + node.questionToken = parseOptionalToken(54); node.type = parseParameterType(); node.initializer = parseBindingElementInitializer(true); return addJSDocComment(finishNode(node)); @@ -13916,7 +13403,7 @@ var ts; return parseInitializer(true); } function fillSignature(returnToken, yieldContext, awaitContext, requireCompleteParameterList, signature) { - var returnTokenRequired = returnToken === 34; + var returnTokenRequired = returnToken === 35; signature.typeParameters = parseTypeParameters(); signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); if (returnTokenRequired) { @@ -13928,7 +13415,7 @@ var ts; } } function parseParameterList(yieldContext, awaitContext, requireCompleteParameterList) { - if (parseExpected(17)) { + if (parseExpected(18)) { var savedYieldContext = inYieldContext(); var savedAwaitContext = inAwaitContext(); setYieldContext(yieldContext); @@ -13936,7 +13423,7 @@ var ts; var result = parseDelimitedList(16, parseParameter); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); - if (!parseExpected(18) && requireCompleteParameterList) { + if (!parseExpected(19) && requireCompleteParameterList) { return undefined; } return result; @@ -13944,29 +13431,29 @@ var ts; return requireCompleteParameterList ? undefined : createMissingList(); } function parseTypeMemberSemicolon() { - if (parseOptional(24)) { + if (parseOptional(25)) { return; } parseSemicolon(); } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 152) { - parseExpected(92); + if (kind === 153) { + parseExpected(93); } - fillSignature(54, false, false, false, node); + fillSignature(55, false, false, false, node); parseTypeMemberSemicolon(); return addJSDocComment(finishNode(node)); } function isIndexSignature() { - if (token() !== 19) { + if (token() !== 20) { return false; } return lookAhead(isUnambiguouslyIndexSignature); } function isUnambiguouslyIndexSignature() { nextToken(); - if (token() === 22 || token() === 20) { + if (token() === 23 || token() === 21) { return true; } if (ts.isModifierKind(token())) { @@ -13981,43 +13468,43 @@ var ts; else { nextToken(); } - if (token() === 54 || token() === 24) { + if (token() === 55 || token() === 25) { return true; } - if (token() !== 53) { + if (token() !== 54) { return false; } nextToken(); - return token() === 54 || token() === 24 || token() === 20; + return token() === 55 || token() === 25 || token() === 21; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(153, fullStart); + var node = createNode(154, fullStart); node.decorators = decorators; node.modifiers = modifiers; - node.parameters = parseBracketedList(16, parseParameter, 19, 20); + node.parameters = parseBracketedList(16, parseParameter, 20, 21); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); return finishNode(node); } function parsePropertyOrMethodSignature(fullStart, modifiers) { var name = parsePropertyName(); - var questionToken = parseOptionalToken(53); - if (token() === 17 || token() === 25) { - var method = createNode(146, fullStart); + var questionToken = parseOptionalToken(54); + if (token() === 18 || token() === 26) { + var method = createNode(147, fullStart); method.modifiers = modifiers; method.name = name; method.questionToken = questionToken; - fillSignature(54, false, false, false, method); + fillSignature(55, false, false, false, method); parseTypeMemberSemicolon(); return addJSDocComment(finishNode(method)); } else { - var property = createNode(144, fullStart); + var property = createNode(145, fullStart); property.modifiers = modifiers; property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); - if (token() === 56) { + if (token() === 57) { property.initializer = parseNonParameterInitializer(); } parseTypeMemberSemicolon(); @@ -14026,14 +13513,14 @@ var ts; } function isTypeMemberStart() { var idToken; - if (token() === 17 || token() === 25) { + if (token() === 18 || token() === 26) { return true; } while (ts.isModifierKind(token())) { idToken = token(); nextToken(); } - if (token() === 19) { + if (token() === 20) { return true; } if (isLiteralPropertyName()) { @@ -14041,22 +13528,22 @@ var ts; nextToken(); } if (idToken) { - return token() === 17 || - token() === 25 || - token() === 53 || + return token() === 18 || + token() === 26 || token() === 54 || - token() === 24 || + token() === 55 || + token() === 25 || canParseSemicolon(); } return false; } function parseTypeMember() { - if (token() === 17 || token() === 25) { - return parseSignatureMember(151); - } - if (token() === 92 && lookAhead(isStartOfConstructSignature)) { + if (token() === 18 || token() === 26) { return parseSignatureMember(152); } + if (token() === 93 && lookAhead(isStartOfConstructSignature)) { + return parseSignatureMember(153); + } var fullStart = getNodePos(); var modifiers = parseModifiers(); if (isIndexSignature()) { @@ -14066,18 +13553,18 @@ var ts; } function isStartOfConstructSignature() { nextToken(); - return token() === 17 || token() === 25; + return token() === 18 || token() === 26; } function parseTypeLiteral() { - var node = createNode(159); + var node = createNode(160); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseObjectTypeMembers() { var members; - if (parseExpected(15)) { + if (parseExpected(16)) { members = parseList(4, parseTypeMember); - parseExpected(16); + parseExpected(17); } else { members = createMissingList(); @@ -14085,31 +13572,31 @@ var ts; return members; } function parseTupleType() { - var node = createNode(161); - node.elementTypes = parseBracketedList(19, parseType, 19, 20); + var node = createNode(162); + node.elementTypes = parseBracketedList(19, parseType, 20, 21); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(164); - parseExpected(17); - node.type = parseType(); + var node = createNode(165); parseExpected(18); + node.type = parseType(); + parseExpected(19); return finishNode(node); } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 157) { - parseExpected(92); + if (kind === 158) { + parseExpected(93); } - fillSignature(34, false, false, false, node); + fillSignature(35, false, false, false, node); return finishNode(node); } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token() === 21 ? undefined : node; + return token() === 22 ? undefined : node; } function parseLiteralTypeNode() { - var node = createNode(166); + var node = createNode(167); node.literal = parseSimpleUnaryExpression(); finishNode(node); return node; @@ -14119,41 +13606,41 @@ var ts; } function parseNonArrayType() { switch (token()) { - case 117: - case 132: - case 130: - case 120: + case 118: case 133: - case 135: - case 127: + case 131: + case 121: + case 134: + case 136: + case 128: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); case 9: case 8: - case 99: - case 84: + case 100: + case 85: return parseLiteralTypeNode(); - case 36: + case 37: return lookAhead(nextTokenIsNumericLiteral) ? parseLiteralTypeNode() : parseTypeReference(); - case 103: - case 93: + case 104: + case 94: return parseTokenNode(); - case 97: { + case 98: { var thisKeyword = parseThisTypeNode(); - if (token() === 124 && !scanner.hasPrecedingLineBreak()) { + if (token() === 125 && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 101: + case 102: return parseTypeQuery(); - case 15: + case 16: return parseTypeLiteral(); - case 19: + case 20: return parseTupleType(); - case 17: + case 18: return parseParenthesizedType(); default: return parseTypeReference(); @@ -14161,29 +13648,29 @@ var ts; } function isStartOfType() { switch (token()) { - case 117: - case 132: - case 130: - case 120: + case 118: case 133: - case 103: - case 135: + case 131: + case 121: + case 134: + case 104: + case 136: + case 94: + case 98: + case 102: + case 128: + case 16: + case 20: + case 26: case 93: - case 97: - case 101: - case 127: - case 15: - case 19: - case 25: - case 92: case 9: case 8: - case 99: - case 84: + case 100: + case 85: return true; - case 36: + case 37: return lookAhead(nextTokenIsNumericLiteral); - case 17: + case 18: return lookAhead(isStartOfParenthesizedOrFunctionType); default: return isIdentifier(); @@ -14191,13 +13678,13 @@ var ts; } function isStartOfParenthesizedOrFunctionType() { nextToken(); - return token() === 18 || isStartOfParameter() || isStartOfType(); + return token() === 19 || isStartOfParameter() || isStartOfType(); } function parseArrayTypeOrHigher() { var type = parseNonArrayType(); - while (!scanner.hasPrecedingLineBreak() && parseOptional(19)) { - parseExpected(20); - var node = createNode(160, type.pos); + while (!scanner.hasPrecedingLineBreak() && parseOptional(20)) { + parseExpected(21); + var node = createNode(161, type.pos); node.elementType = type; type = finishNode(node); } @@ -14218,26 +13705,26 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(163, parseArrayTypeOrHigher, 46); + return parseUnionOrIntersectionType(164, parseArrayTypeOrHigher, 47); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(162, parseIntersectionTypeOrHigher, 47); + return parseUnionOrIntersectionType(163, parseIntersectionTypeOrHigher, 48); } function isStartOfFunctionType() { - if (token() === 25) { + if (token() === 26) { return true; } - return token() === 17 && lookAhead(isUnambiguouslyStartOfFunctionType); + return token() === 18 && lookAhead(isUnambiguouslyStartOfFunctionType); } function skipParameterStart() { if (ts.isModifierKind(token())) { parseModifiers(); } - if (isIdentifier() || token() === 97) { + if (isIdentifier() || token() === 98) { nextToken(); return true; } - if (token() === 19 || token() === 15) { + if (token() === 20 || token() === 16) { var previousErrorCount = parseDiagnostics.length; parseIdentifierOrPattern(); return previousErrorCount === parseDiagnostics.length; @@ -14246,17 +13733,17 @@ var ts; } function isUnambiguouslyStartOfFunctionType() { nextToken(); - if (token() === 18 || token() === 22) { + if (token() === 19 || token() === 23) { return true; } if (skipParameterStart()) { - if (token() === 54 || token() === 24 || - token() === 53 || token() === 56) { + if (token() === 55 || token() === 25 || + token() === 54 || token() === 57) { return true; } - if (token() === 18) { + if (token() === 19) { nextToken(); - if (token() === 34) { + if (token() === 35) { return true; } } @@ -14267,7 +13754,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(154, typePredicateVariable.pos); + var node = createNode(155, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -14278,7 +13765,7 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 124 && !scanner.hasPrecedingLineBreak()) { + if (token() === 125 && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } @@ -14288,36 +13775,36 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(156); - } - if (token() === 92) { return parseFunctionOrConstructorType(157); } + if (token() === 93) { + return parseFunctionOrConstructorType(158); + } return parseUnionTypeOrHigher(); } function parseTypeAnnotation() { - return parseOptional(54) ? parseType() : undefined; + return parseOptional(55) ? parseType() : undefined; } function isStartOfLeftHandSideExpression() { switch (token()) { - case 97: - case 95: - case 93: - case 99: - case 84: + case 98: + case 96: + case 94: + case 100: + case 85: case 8: case 9: - case 11: case 12: - case 17: - case 19: - case 15: - case 87: - case 73: - case 92: - case 39: - case 61: - case 69: + case 13: + case 18: + case 20: + case 16: + case 88: + case 74: + case 93: + case 40: + case 62: + case 70: return true; default: return isIdentifier(); @@ -14328,18 +13815,18 @@ var ts; return true; } switch (token()) { - case 35: case 36: + case 37: + case 51: case 50: - case 49: - case 78: - case 101: - case 103: - case 41: + case 79: + case 102: + case 104: case 42: - case 25: - case 119: - case 114: + case 43: + case 26: + case 120: + case 115: return true; default: if (isBinaryOperator()) { @@ -14349,10 +13836,10 @@ var ts; } } function isStartOfExpressionStatement() { - return token() !== 15 && - token() !== 87 && - token() !== 73 && - token() !== 55 && + return token() !== 16 && + token() !== 88 && + token() !== 74 && + token() !== 56 && isStartOfExpression(); } function parseExpression() { @@ -14362,7 +13849,7 @@ var ts; } var expr = parseAssignmentExpressionOrHigher(); var operatorToken; - while ((operatorToken = parseOptionalToken(24))) { + while ((operatorToken = parseOptionalToken(25))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); } if (saveDecoratorContext) { @@ -14371,12 +13858,12 @@ var ts; return expr; } function parseInitializer(inParameter) { - if (token() !== 56) { - if (scanner.hasPrecedingLineBreak() || (inParameter && token() === 15) || !isStartOfExpression()) { + if (token() !== 57) { + if (scanner.hasPrecedingLineBreak() || (inParameter && token() === 16) || !isStartOfExpression()) { return undefined; } } - parseExpected(56); + parseExpected(57); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { @@ -14388,7 +13875,7 @@ var ts; return arrowExpression; } var expr = parseBinaryExpressionOrHigher(0); - if (expr.kind === 69 && token() === 34) { + if (expr.kind === 70 && token() === 35) { return parseSimpleArrowFunctionExpression(expr); } if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) { @@ -14397,7 +13884,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token() === 114) { + if (token() === 115) { if (inYieldContext()) { return true; } @@ -14410,11 +13897,11 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(190); + var node = createNode(191); nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token() === 37 || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(37); + (token() === 38 || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(38); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -14423,21 +13910,21 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier, asyncModifier) { - ts.Debug.assert(token() === 34, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + ts.Debug.assert(token() === 35, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(180, asyncModifier.pos); + node = createNode(181, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(180, identifier.pos); + node = createNode(181, identifier.pos); } - var parameter = createNode(142, identifier.pos); + var parameter = createNode(143, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos); node.parameters.end = parameter.end; - node.equalsGreaterThanToken = parseExpectedToken(34, false, ts.Diagnostics._0_expected, "=>"); + node.equalsGreaterThanToken = parseExpectedToken(35, false, ts.Diagnostics._0_expected, "=>"); node.body = parseArrowFunctionExpressionBody(!!asyncModifier); return addJSDocComment(finishNode(node)); } @@ -14454,78 +13941,78 @@ var ts; } var isAsync = !!(ts.getModifierFlags(arrowFunction) & 256); var lastToken = token(); - arrowFunction.equalsGreaterThanToken = parseExpectedToken(34, false, ts.Diagnostics._0_expected, "=>"); - arrowFunction.body = (lastToken === 34 || lastToken === 15) + arrowFunction.equalsGreaterThanToken = parseExpectedToken(35, false, ts.Diagnostics._0_expected, "=>"); + arrowFunction.body = (lastToken === 35 || lastToken === 16) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return addJSDocComment(finishNode(arrowFunction)); } function isParenthesizedArrowFunctionExpression() { - if (token() === 17 || token() === 25 || token() === 118) { + if (token() === 18 || token() === 26 || token() === 119) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token() === 34) { + if (token() === 35) { return 1; } return 0; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 118) { + if (token() === 119) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0; } - if (token() !== 17 && token() !== 25) { + if (token() !== 18 && token() !== 26) { return 0; } } var first = token(); var second = nextToken(); - if (first === 17) { - if (second === 18) { + if (first === 18) { + if (second === 19) { var third = nextToken(); switch (third) { - case 34: - case 54: - case 15: + case 35: + case 55: + case 16: return 1; default: return 0; } } - if (second === 19 || second === 15) { + if (second === 20 || second === 16) { return 2; } - if (second === 22) { + if (second === 23) { return 1; } if (!isIdentifier()) { return 0; } - if (nextToken() === 54) { + if (nextToken() === 55) { return 1; } return 2; } else { - ts.Debug.assert(first === 25); + ts.Debug.assert(first === 26); if (!isIdentifier()) { return 0; } if (sourceFile.languageVariant === 1) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 83) { + if (third === 84) { var fourth = nextToken(); switch (fourth) { - case 56: - case 27: + case 57: + case 28: return false; default: return true; } } - else if (third === 24) { + else if (third === 25) { return true; } return false; @@ -14542,7 +14029,7 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function tryParseAsyncSimpleArrowFunctionExpression() { - if (token() === 118) { + if (token() === 119) { var isUnParenthesizedAsyncArrowFunction = lookAhead(isUnParenthesizedAsyncArrowFunctionWorker); if (isUnParenthesizedAsyncArrowFunction === 1) { var asyncModifier = parseModifiersForArrowFunction(); @@ -14553,38 +14040,38 @@ var ts; return undefined; } function isUnParenthesizedAsyncArrowFunctionWorker() { - if (token() === 118) { + if (token() === 119) { nextToken(); - if (scanner.hasPrecedingLineBreak() || token() === 34) { + if (scanner.hasPrecedingLineBreak() || token() === 35) { return 0; } var expr = parseBinaryExpressionOrHigher(0); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 69 && token() === 34) { + if (!scanner.hasPrecedingLineBreak() && expr.kind === 70 && token() === 35) { return 1; } } return 0; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(180); + var node = createNode(181); node.modifiers = parseModifiersForArrowFunction(); var isAsync = !!(ts.getModifierFlags(node) & 256); - fillSignature(54, false, isAsync, !allowAmbiguity, node); + fillSignature(55, false, isAsync, !allowAmbiguity, node); if (!node.parameters) { return undefined; } - if (!allowAmbiguity && token() !== 34 && token() !== 15) { + if (!allowAmbiguity && token() !== 35 && token() !== 16) { return undefined; } return node; } function parseArrowFunctionExpressionBody(isAsync) { - if (token() === 15) { + if (token() === 16) { return parseFunctionBlock(false, isAsync, false); } - if (token() !== 23 && - token() !== 87 && - token() !== 73 && + if (token() !== 24 && + token() !== 88 && + token() !== 74 && isStartOfStatement() && !isStartOfExpressionStatement()) { return parseFunctionBlock(false, isAsync, true); @@ -14594,15 +14081,15 @@ var ts; : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); } function parseConditionalExpressionRest(leftOperand) { - var questionToken = parseOptionalToken(53); + var questionToken = parseOptionalToken(54); if (!questionToken) { return leftOperand; } - var node = createNode(188, leftOperand.pos); + var node = createNode(189, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(54, false, ts.Diagnostics._0_expected, ts.tokenToString(54)); + node.colonToken = parseExpectedToken(55, false, ts.Diagnostics._0_expected, ts.tokenToString(55)); node.whenFalse = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -14611,22 +14098,22 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 90 || t === 138; + return t === 91 || t === 139; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { reScanGreaterToken(); var newPrecedence = getBinaryOperatorPrecedence(); - var consumeCurrentOperator = token() === 38 ? + var consumeCurrentOperator = token() === 39 ? newPrecedence >= precedence : newPrecedence > precedence; if (!consumeCurrentOperator) { break; } - if (token() === 90 && inDisallowInContext()) { + if (token() === 91 && inDisallowInContext()) { break; } - if (token() === 116) { + if (token() === 117) { if (scanner.hasPrecedingLineBreak()) { break; } @@ -14642,92 +14129,92 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 90) { + if (inDisallowInContext() && token() === 91) { return false; } return getBinaryOperatorPrecedence() > 0; } function getBinaryOperatorPrecedence() { switch (token()) { - case 52: + case 53: return 1; - case 51: + case 52: return 2; - case 47: - return 3; case 48: + return 3; + case 49: return 4; - case 46: + case 47: return 5; - case 30: case 31: case 32: case 33: + case 34: return 6; - case 25: - case 27: + case 26: case 28: case 29: + case 30: + case 92: case 91: - case 90: - case 116: + case 117: return 7; - case 43: case 44: case 45: + case 46: return 8; - case 35: case 36: - return 9; case 37: - case 39: - case 40: - return 10; + return 9; case 38: + case 40: + case 41: + return 10; + case 39: return 11; } return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(187, left.pos); + var node = createNode(188, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(195, left.pos); + var node = createNode(196, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(185); + var node = createNode(186); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(181); - nextToken(); - node.expression = parseSimpleUnaryExpression(); - return finishNode(node); - } - function parseTypeOfExpression() { var node = createNode(182); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } - function parseVoidExpression() { + function parseTypeOfExpression() { var node = createNode(183); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } + function parseVoidExpression() { + var node = createNode(184); + nextToken(); + node.expression = parseSimpleUnaryExpression(); + return finishNode(node); + } function isAwaitExpression() { - if (token() === 119) { + if (token() === 120) { if (inAwaitContext()) { return true; } @@ -14736,7 +14223,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(184); + var node = createNode(185); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -14744,15 +14231,15 @@ var ts; function parseUnaryExpressionOrHigher() { if (isUpdateExpression()) { var incrementExpression = parseIncrementExpression(); - return token() === 38 ? + return token() === 39 ? parseBinaryExpressionRest(getBinaryOperatorPrecedence(), incrementExpression) : incrementExpression; } var unaryOperator = token(); var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token() === 38) { + if (token() === 39) { var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); - if (simpleUnaryExpression.kind === 177) { + if (simpleUnaryExpression.kind === 178) { 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 { @@ -14763,20 +14250,20 @@ var ts; } function parseSimpleUnaryExpression() { switch (token()) { - case 35: case 36: + case 37: + case 51: case 50: - case 49: return parsePrefixUnaryExpression(); - case 78: + case 79: return parseDeleteExpression(); - case 101: + case 102: return parseTypeOfExpression(); - case 103: + case 104: return parseVoidExpression(); - case 25: + case 26: return parseTypeAssertion(); - case 119: + case 120: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -14786,16 +14273,16 @@ var ts; } function isUpdateExpression() { switch (token()) { - case 35: case 36: + case 37: + case 51: case 50: - case 49: - case 78: - case 101: - case 103: - case 119: + case 79: + case 102: + case 104: + case 120: return false; - case 25: + case 26: if (sourceFile.languageVariant !== 1) { return false; } @@ -14804,20 +14291,20 @@ var ts; } } function parseIncrementExpression() { - if (token() === 41 || token() === 42) { - var node = createNode(185); + if (token() === 42 || token() === 43) { + var node = createNode(186); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); return finishNode(node); } - else if (sourceFile.languageVariant === 1 && token() === 25 && lookAhead(nextTokenIsIdentifierOrKeyword)) { + else if (sourceFile.languageVariant === 1 && token() === 26 && lookAhead(nextTokenIsIdentifierOrKeyword)) { return parseJsxElementOrSelfClosingElement(true); } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token() === 41 || token() === 42) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(186, expression.pos); + if ((token() === 42 || token() === 43) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(187, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -14826,7 +14313,7 @@ var ts; return expression; } function parseLeftHandSideExpressionOrHigher() { - var expression = token() === 95 + var expression = token() === 96 ? parseSuperExpression() : parseMemberExpressionOrHigher(); return parseCallExpressionRest(expression); @@ -14837,12 +14324,12 @@ var ts; } function parseSuperExpression() { var expression = parseTokenNode(); - if (token() === 17 || token() === 21 || token() === 19) { + if (token() === 18 || token() === 22 || token() === 20) { return expression; } - var node = createNode(172, expression.pos); + var node = createNode(173, expression.pos); node.expression = expression; - parseExpectedToken(21, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + parseExpectedToken(22, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); return finishNode(node); } @@ -14850,10 +14337,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 69) { + if (lhs.kind === 70) { return lhs.text === rhs.text; } - if (lhs.kind === 97) { + if (lhs.kind === 98) { return true; } return lhs.name.text === rhs.name.text && @@ -14862,8 +14349,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 243) { - var node = createNode(241, opening.pos); + if (opening.kind === 244) { + var node = createNode(242, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -14873,18 +14360,18 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 242); + ts.Debug.assert(opening.kind === 243); result = opening; } - if (inExpressionContext && token() === 25) { + if (inExpressionContext && token() === 26) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(187, result.pos); + var badNode = createNode(188, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; - badNode.operatorToken = createMissingNode(24, false, undefined); + badNode.operatorToken = createMissingNode(25, false, undefined); badNode.operatorToken.pos = badNode.operatorToken.end = badNode.right.pos; return badNode; } @@ -14892,17 +14379,17 @@ var ts; return result; } function parseJsxText() { - var node = createNode(244, scanner.getStartPos()); + var node = createNode(10, scanner.getStartPos()); currentToken = scanner.scanJsxToken(); return finishNode(node); } function parseJsxChild() { switch (token()) { - case 244: + case 10: return parseJsxText(); - case 15: + case 16: return parseJsxExpression(false); - case 25: + case 26: return parseJsxElementOrSelfClosingElement(false); } ts.Debug.fail("Unknown JSX child kind " + token()); @@ -14913,7 +14400,7 @@ var ts; parsingContext |= 1 << 14; while (true) { currentToken = scanner.reScanJsxToken(); - if (token() === 26) { + if (token() === 27) { break; } else if (token() === 1) { @@ -14928,24 +14415,24 @@ var ts; } function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { var fullStart = scanner.getStartPos(); - parseExpected(25); + parseExpected(26); var tagName = parseJsxElementName(); var attributes = parseList(13, parseJsxAttribute); var node; - if (token() === 27) { - node = createNode(243, fullStart); + if (token() === 28) { + node = createNode(244, fullStart); scanJsxText(); } else { - parseExpected(39); + parseExpected(40); if (inExpressionContext) { - parseExpected(27); + parseExpected(28); } else { - parseExpected(27, undefined, false); + parseExpected(28, undefined, false); scanJsxText(); } - node = createNode(242, fullStart); + node = createNode(243, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -14953,10 +14440,10 @@ var ts; } function parseJsxElementName() { scanJsxIdentifier(); - var expression = token() === 97 ? + var expression = token() === 98 ? parseTokenNode() : parseIdentifierName(); - while (parseOptional(21)) { - var propertyAccess = createNode(172, expression.pos); + while (parseOptional(22)) { + var propertyAccess = createNode(173, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -14965,27 +14452,27 @@ var ts; } function parseJsxExpression(inExpressionContext) { var node = createNode(248); - parseExpected(15); - if (token() !== 16) { + parseExpected(16); + if (token() !== 17) { node.expression = parseAssignmentExpressionOrHigher(); } if (inExpressionContext) { - parseExpected(16); + parseExpected(17); } else { - parseExpected(16, undefined, false); + parseExpected(17, undefined, false); scanJsxText(); } return finishNode(node); } function parseJsxAttribute() { - if (token() === 15) { + if (token() === 16) { return parseJsxSpreadAttribute(); } scanJsxIdentifier(); var node = createNode(246); node.name = parseIdentifierName(); - if (token() === 56) { + if (token() === 57) { switch (scanJsxAttributeValue()) { case 9: node.initializer = parseLiteralNode(); @@ -14999,68 +14486,68 @@ var ts; } function parseJsxSpreadAttribute() { var node = createNode(247); - parseExpected(15); - parseExpected(22); - node.expression = parseExpression(); parseExpected(16); + parseExpected(23); + node.expression = parseExpression(); + parseExpected(17); return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { var node = createNode(245); - parseExpected(26); + parseExpected(27); node.tagName = parseJsxElementName(); if (inExpressionContext) { - parseExpected(27); + parseExpected(28); } else { - parseExpected(27, undefined, false); + parseExpected(28, undefined, false); scanJsxText(); } return finishNode(node); } function parseTypeAssertion() { - var node = createNode(177); - parseExpected(25); + var node = createNode(178); + parseExpected(26); node.type = parseType(); - parseExpected(27); + parseExpected(28); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseMemberExpressionRest(expression) { while (true) { - var dotToken = parseOptionalToken(21); + var dotToken = parseOptionalToken(22); if (dotToken) { - var propertyAccess = createNode(172, expression.pos); + var propertyAccess = createNode(173, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); continue; } - if (token() === 49 && !scanner.hasPrecedingLineBreak()) { + if (token() === 50 && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(196, expression.pos); + var nonNullExpression = createNode(197, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } - if (!inDecoratorContext() && parseOptional(19)) { - var indexedAccess = createNode(173, expression.pos); + if (!inDecoratorContext() && parseOptional(20)) { + var indexedAccess = createNode(174, expression.pos); indexedAccess.expression = expression; - if (token() !== 20) { + if (token() !== 21) { indexedAccess.argumentExpression = allowInAnd(parseExpression); if (indexedAccess.argumentExpression.kind === 9 || indexedAccess.argumentExpression.kind === 8) { var literal = indexedAccess.argumentExpression; literal.text = internIdentifier(literal.text); } } - parseExpected(20); + parseExpected(21); expression = finishNode(indexedAccess); continue; } - if (token() === 11 || token() === 12) { - var tagExpression = createNode(176, expression.pos); + if (token() === 12 || token() === 13) { + var tagExpression = createNode(177, expression.pos); tagExpression.tag = expression; - tagExpression.template = token() === 11 + tagExpression.template = token() === 12 ? parseLiteralNode() : parseTemplateExpression(); expression = finishNode(tagExpression); @@ -15072,20 +14559,20 @@ var ts; function parseCallExpressionRest(expression) { while (true) { expression = parseMemberExpressionRest(expression); - if (token() === 25) { + if (token() === 26) { var typeArguments = tryParse(parseTypeArgumentsInExpression); if (!typeArguments) { return expression; } - var callExpr = createNode(174, expression.pos); + var callExpr = createNode(175, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); continue; } - else if (token() === 17) { - var callExpr = createNode(174, expression.pos); + else if (token() === 18) { + var callExpr = createNode(175, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -15095,17 +14582,17 @@ var ts; } } function parseArgumentList() { - parseExpected(17); - var result = parseDelimitedList(11, parseArgumentExpression); parseExpected(18); + var result = parseDelimitedList(11, parseArgumentExpression); + parseExpected(19); return result; } function parseTypeArgumentsInExpression() { - if (!parseOptional(25)) { + if (!parseOptional(26)) { return undefined; } var typeArguments = parseDelimitedList(18, parseType); - if (!parseExpected(27)) { + if (!parseExpected(28)) { return undefined; } return typeArguments && canFollowTypeArgumentsInExpression() @@ -15114,27 +14601,27 @@ var ts; } function canFollowTypeArgumentsInExpression() { switch (token()) { - case 17: - case 21: case 18: - case 20: + case 22: + case 19: + case 21: + case 55: + case 24: case 54: - case 23: - case 53: - case 30: - case 32: case 31: case 33: - case 51: + case 32: + case 34: case 52: - case 48: - case 46: + case 53: + case 49: case 47: - case 16: + case 48: + case 17: case 1: return true; - case 24: - case 15: + case 25: + case 16: default: return false; } @@ -15143,80 +14630,80 @@ var ts; switch (token()) { case 8: case 9: - case 11: + case 12: return parseLiteralNode(); - case 97: - case 95: - case 93: - case 99: - case 84: + case 98: + case 96: + case 94: + case 100: + case 85: return parseTokenNode(); - case 17: + case 18: return parseParenthesizedExpression(); - case 19: + case 20: return parseArrayLiteralExpression(); - case 15: + case 16: return parseObjectLiteralExpression(); - case 118: + case 119: if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) { break; } return parseFunctionExpression(); - case 73: + case 74: return parseClassExpression(); - case 87: + case 88: return parseFunctionExpression(); - case 92: + case 93: return parseNewExpression(); - case 39: - case 61: - if (reScanSlashToken() === 10) { + case 40: + case 62: + if (reScanSlashToken() === 11) { return parseLiteralNode(); } break; - case 12: + case 13: return parseTemplateExpression(); } return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(178); - parseExpected(17); - node.expression = allowInAnd(parseExpression); + var node = createNode(179); parseExpected(18); + node.expression = allowInAnd(parseExpression); + parseExpected(19); return finishNode(node); } function parseSpreadElement() { - var node = createNode(191); - parseExpected(22); + var node = createNode(192); + parseExpected(23); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { - return token() === 22 ? parseSpreadElement() : - token() === 24 ? createNode(193) : + return token() === 23 ? parseSpreadElement() : + token() === 25 ? createNode(194) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(170); - parseExpected(19); + var node = createNode(171); + parseExpected(20); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.elements = parseDelimitedList(15, parseArgumentOrArrayLiteralElement); - parseExpected(20); + parseExpected(21); return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { - if (parseContextualModifier(123)) { - return parseAccessorDeclaration(149, fullStart, decorators, modifiers); - } - else if (parseContextualModifier(131)) { + if (parseContextualModifier(124)) { return parseAccessorDeclaration(150, fullStart, decorators, modifiers); } + else if (parseContextualModifier(132)) { + return parseAccessorDeclaration(151, fullStart, decorators, modifiers); + } return undefined; } function parseObjectLiteralElement() { @@ -15227,19 +14714,19 @@ var ts; if (accessor) { return accessor; } - var asteriskToken = parseOptionalToken(37); + var asteriskToken = parseOptionalToken(38); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - var questionToken = parseOptionalToken(53); - if (asteriskToken || token() === 17 || token() === 25) { + var questionToken = parseOptionalToken(54); + if (asteriskToken || token() === 18 || token() === 26) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } - var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 24 || token() === 16 || token() === 56); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 25 || token() === 17 || token() === 57); if (isShorthandPropertyAssignment) { var shorthandDeclaration = createNode(254, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; - var equalsToken = parseOptionalToken(56); + var equalsToken = parseOptionalToken(57); if (equalsToken) { shorthandDeclaration.equalsToken = equalsToken; shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); @@ -15251,19 +14738,19 @@ var ts; propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; - parseExpected(54); + parseExpected(55); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); return addJSDocComment(finishNode(propertyAssignment)); } } function parseObjectLiteralExpression() { - var node = createNode(171); - parseExpected(15); + var node = createNode(172); + parseExpected(16); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.properties = parseDelimitedList(12, parseObjectLiteralElement, true); - parseExpected(16); + parseExpected(17); return finishNode(node); } function parseFunctionExpression() { @@ -15271,10 +14758,10 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(179); + var node = createNode(180); node.modifiers = parseModifiers(); - parseExpected(87); - node.asteriskToken = parseOptionalToken(37); + parseExpected(88); + node.asteriskToken = parseOptionalToken(38); var isGenerator = !!node.asteriskToken; var isAsync = !!(ts.getModifierFlags(node) & 256); node.name = @@ -15282,7 +14769,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(54, isGenerator, isAsync, false, node); + fillSignature(55, isGenerator, isAsync, false, node); node.body = parseFunctionBlock(isGenerator, isAsync, false); if (saveDecoratorContext) { setDecoratorContext(true); @@ -15293,23 +14780,23 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(175); - parseExpected(92); + var node = createNode(176); + parseExpected(93); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); - if (node.typeArguments || token() === 17) { + if (node.typeArguments || token() === 18) { node.arguments = parseArgumentList(); } return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(199); - if (parseExpected(15, diagnosticMessage) || ignoreMissingOpenBrace) { + var node = createNode(200); + if (parseExpected(16, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.statements = parseList(1, parseStatement); - parseExpected(16); + parseExpected(17); } else { node.statements = createMissingList(); @@ -15334,47 +14821,47 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(201); - parseExpected(23); + var node = createNode(202); + parseExpected(24); return finishNode(node); } function parseIfStatement() { - var node = createNode(203); - parseExpected(88); - parseExpected(17); - node.expression = allowInAnd(parseExpression); + var node = createNode(204); + parseExpected(89); parseExpected(18); + node.expression = allowInAnd(parseExpression); + parseExpected(19); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(80) ? parseStatement() : undefined; + node.elseStatement = parseOptional(81) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(204); - parseExpected(79); + var node = createNode(205); + parseExpected(80); node.statement = parseStatement(); - parseExpected(104); - parseExpected(17); - node.expression = allowInAnd(parseExpression); + parseExpected(105); parseExpected(18); - parseOptional(23); + node.expression = allowInAnd(parseExpression); + parseExpected(19); + parseOptional(24); return finishNode(node); } function parseWhileStatement() { - var node = createNode(205); - parseExpected(104); - parseExpected(17); - node.expression = allowInAnd(parseExpression); + var node = createNode(206); + parseExpected(105); parseExpected(18); + node.expression = allowInAnd(parseExpression); + parseExpected(19); node.statement = parseStatement(); return finishNode(node); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(86); - parseExpected(17); + parseExpected(87); + parseExpected(18); var initializer = undefined; - if (token() !== 23) { - if (token() === 102 || token() === 108 || token() === 74) { + if (token() !== 24) { + if (token() === 103 || token() === 109 || token() === 75) { initializer = parseVariableDeclarationList(true); } else { @@ -15382,32 +14869,32 @@ var ts; } } var forOrForInOrForOfStatement; - if (parseOptional(90)) { - var forInStatement = createNode(207, pos); + if (parseOptional(91)) { + var forInStatement = createNode(208, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); - parseExpected(18); + parseExpected(19); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(138)) { - var forOfStatement = createNode(208, pos); + else if (parseOptional(139)) { + var forOfStatement = createNode(209, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); - parseExpected(18); + parseExpected(19); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(206, pos); + var forStatement = createNode(207, pos); forStatement.initializer = initializer; - parseExpected(23); - if (token() !== 23 && token() !== 18) { + parseExpected(24); + if (token() !== 24 && token() !== 19) { forStatement.condition = allowInAnd(parseExpression); } - parseExpected(23); - if (token() !== 18) { + parseExpected(24); + if (token() !== 19) { forStatement.incrementor = allowInAnd(parseExpression); } - parseExpected(18); + parseExpected(19); forOrForInOrForOfStatement = forStatement; } forOrForInOrForOfStatement.statement = parseStatement(); @@ -15415,7 +14902,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 210 ? 70 : 75); + parseExpected(kind === 211 ? 71 : 76); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -15423,8 +14910,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(211); - parseExpected(94); + var node = createNode(212); + parseExpected(95); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -15432,90 +14919,90 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(212); - parseExpected(105); - parseExpected(17); - node.expression = allowInAnd(parseExpression); + var node = createNode(213); + parseExpected(106); parseExpected(18); + node.expression = allowInAnd(parseExpression); + parseExpected(19); node.statement = parseStatement(); return finishNode(node); } function parseCaseClause() { var node = createNode(249); - parseExpected(71); + parseExpected(72); node.expression = allowInAnd(parseExpression); - parseExpected(54); + parseExpected(55); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseDefaultClause() { var node = createNode(250); - parseExpected(77); - parseExpected(54); + parseExpected(78); + parseExpected(55); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token() === 71 ? parseCaseClause() : parseDefaultClause(); + return token() === 72 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(213); - parseExpected(96); - parseExpected(17); - node.expression = allowInAnd(parseExpression); + var node = createNode(214); + parseExpected(97); parseExpected(18); - var caseBlock = createNode(227, scanner.getStartPos()); - parseExpected(15); - caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); + node.expression = allowInAnd(parseExpression); + parseExpected(19); + var caseBlock = createNode(228, scanner.getStartPos()); parseExpected(16); + caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); + parseExpected(17); node.caseBlock = finishNode(caseBlock); return finishNode(node); } function parseThrowStatement() { - var node = createNode(215); - parseExpected(98); + var node = createNode(216); + parseExpected(99); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(216); - parseExpected(100); + var node = createNode(217); + parseExpected(101); node.tryBlock = parseBlock(false); - node.catchClause = token() === 72 ? parseCatchClause() : undefined; - if (!node.catchClause || token() === 85) { - parseExpected(85); + node.catchClause = token() === 73 ? parseCatchClause() : undefined; + if (!node.catchClause || token() === 86) { + parseExpected(86); node.finallyBlock = parseBlock(false); } return finishNode(node); } function parseCatchClause() { var result = createNode(252); - parseExpected(72); - if (parseExpected(17)) { + parseExpected(73); + if (parseExpected(18)) { result.variableDeclaration = parseVariableDeclaration(); } - parseExpected(18); + parseExpected(19); result.block = parseBlock(false); return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(217); - parseExpected(76); + var node = createNode(218); + parseExpected(77); parseSemicolon(); return finishNode(node); } function parseExpressionOrLabeledStatement() { var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); - if (expression.kind === 69 && parseOptional(54)) { - var labeledStatement = createNode(214, fullStart); + if (expression.kind === 70 && parseOptional(55)) { + var labeledStatement = createNode(215, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(202, fullStart); + var expressionStatement = createNode(203, fullStart); expressionStatement.expression = expression; parseSemicolon(); return addJSDocComment(finishNode(expressionStatement)); @@ -15527,7 +15014,7 @@ var ts; } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 87 && !scanner.hasPrecedingLineBreak(); + return token() === 88 && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { nextToken(); @@ -15536,47 +15023,47 @@ var ts; function isDeclaration() { while (true) { switch (token()) { - case 102: - case 108: + case 103: + case 109: + case 75: + case 88: case 74: - case 87: - case 73: - case 81: + case 82: return true; - case 107: - case 134: + case 108: + case 135: return nextTokenIsIdentifierOnSameLine(); - case 125: case 126: + case 127: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 115: - case 118: - case 122: - case 110: + case 116: + case 119: + case 123: case 111: case 112: - case 128: + case 113: + case 129: nextToken(); if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 137: + case 138: nextToken(); - return token() === 15 || token() === 69 || token() === 82; - case 89: + return token() === 16 || token() === 70 || token() === 83; + case 90: nextToken(); - return token() === 9 || token() === 37 || - token() === 15 || ts.tokenIsIdentifierOrKeyword(token()); - case 82: + return token() === 9 || token() === 38 || + token() === 16 || ts.tokenIsIdentifierOrKeyword(token()); + case 83: nextToken(); - if (token() === 56 || token() === 37 || - token() === 15 || token() === 77 || - token() === 116) { + if (token() === 57 || token() === 38 || + token() === 16 || token() === 78 || + token() === 117) { return true; } continue; - case 113: + case 114: nextToken(); continue; default: @@ -15589,46 +15076,46 @@ var ts; } function isStartOfStatement() { switch (token()) { - case 55: - case 23: - case 15: - case 102: - case 108: - case 87: - case 73: - case 81: + case 56: + case 24: + case 16: + case 103: + case 109: case 88: - case 79: - case 104: - case 86: - case 75: - case 70: - case 94: - case 105: - case 96: - case 98: - case 100: - case 76: - case 72: - case 85: - return true; case 74: case 82: case 89: + case 80: + case 105: + case 87: + case 76: + case 71: + case 95: + case 106: + case 97: + case 99: + case 101: + case 77: + case 73: + case 86: + return true; + case 75: + case 83: + case 90: return isStartOfDeclaration(); - case 118: - case 122: - case 107: - case 125: + case 119: + case 123: + case 108: case 126: - case 134: - case 137: + case 127: + case 135: + case 138: return true; - case 112: - case 110: - case 111: case 113: - case 128: + case 111: + case 112: + case 114: + case 129: return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); default: return isStartOfExpression(); @@ -15636,73 +15123,73 @@ var ts; } function nextTokenIsIdentifierOrStartOfDestructuring() { nextToken(); - return isIdentifier() || token() === 15 || token() === 19; + return isIdentifier() || token() === 16 || token() === 20; } function isLetDeclaration() { return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring); } function parseStatement() { switch (token()) { - case 23: + case 24: return parseEmptyStatement(); - case 15: + case 16: return parseBlock(false); - case 102: + case 103: return parseVariableStatement(scanner.getStartPos(), undefined, undefined); - case 108: + case 109: if (isLetDeclaration()) { return parseVariableStatement(scanner.getStartPos(), undefined, undefined); } break; - case 87: - return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); - case 73: - return parseClassDeclaration(scanner.getStartPos(), undefined, undefined); case 88: - return parseIfStatement(); - case 79: - return parseDoStatement(); - case 104: - return parseWhileStatement(); - case 86: - return parseForOrForInOrForOfStatement(); - case 75: - return parseBreakOrContinueStatement(209); - case 70: - return parseBreakOrContinueStatement(210); - case 94: - return parseReturnStatement(); - case 105: - return parseWithStatement(); - case 96: - return parseSwitchStatement(); - case 98: - return parseThrowStatement(); - case 100: - case 72: - case 85: - return parseTryStatement(); - case 76: - return parseDebuggerStatement(); - case 55: - return parseDeclaration(); - case 118: - case 107: - case 134: - case 125: - case 126: - case 122: + return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); case 74: - case 81: - case 82: + return parseClassDeclaration(scanner.getStartPos(), undefined, undefined); case 89: - case 110: + return parseIfStatement(); + case 80: + return parseDoStatement(); + case 105: + return parseWhileStatement(); + case 87: + return parseForOrForInOrForOfStatement(); + case 76: + return parseBreakOrContinueStatement(210); + case 71: + return parseBreakOrContinueStatement(211); + case 95: + return parseReturnStatement(); + case 106: + return parseWithStatement(); + case 97: + return parseSwitchStatement(); + case 99: + return parseThrowStatement(); + case 101: + case 73: + case 86: + return parseTryStatement(); + case 77: + return parseDebuggerStatement(); + case 56: + return parseDeclaration(); + case 119: + case 108: + case 135: + case 126: + case 127: + case 123: + case 75: + case 82: + case 83: + case 90: case 111: case 112: - case 115: case 113: - case 128: - case 137: + case 116: + case 114: + case 129: + case 138: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -15715,40 +15202,40 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(); switch (token()) { - case 102: - case 108: - case 74: + case 103: + case 109: + case 75: return parseVariableStatement(fullStart, decorators, modifiers); - case 87: + case 88: return parseFunctionDeclaration(fullStart, decorators, modifiers); - case 73: + case 74: return parseClassDeclaration(fullStart, decorators, modifiers); - case 107: + case 108: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 134: + case 135: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); - case 81: - return parseEnumDeclaration(fullStart, decorators, modifiers); - case 137: - case 125: - case 126: - return parseModuleDeclaration(fullStart, decorators, modifiers); - case 89: - return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); case 82: + return parseEnumDeclaration(fullStart, decorators, modifiers); + case 138: + case 126: + case 127: + return parseModuleDeclaration(fullStart, decorators, modifiers); + case 90: + return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); + case 83: nextToken(); switch (token()) { - case 77: - case 56: + case 78: + case 57: return parseExportAssignment(fullStart, decorators, modifiers); - case 116: + case 117: return parseNamespaceExportDeclaration(fullStart, decorators, modifiers); default: return parseExportDeclaration(fullStart, decorators, modifiers); } default: if (decorators || modifiers) { - var node = createMissingNode(239, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(240, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; node.modifiers = modifiers; @@ -15761,31 +15248,31 @@ var ts; return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 9); } function parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage) { - if (token() !== 15 && canParseSemicolon()) { + if (token() !== 16 && canParseSemicolon()) { parseSemicolon(); return; } return parseFunctionBlock(isGenerator, isAsync, false, diagnosticMessage); } function parseArrayBindingElement() { - if (token() === 24) { - return createNode(193); + if (token() === 25) { + return createNode(194); } - var node = createNode(169); - node.dotDotDotToken = parseOptionalToken(22); + var node = createNode(170); + node.dotDotDotToken = parseOptionalToken(23); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(169); + var node = createNode(170); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token() !== 54) { + if (tokenIsIdentifier && token() !== 55) { node.name = propertyName; } else { - parseExpected(54); + parseExpected(55); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -15793,33 +15280,33 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(167); - parseExpected(15); - node.elements = parseDelimitedList(9, parseObjectBindingElement); + var node = createNode(168); parseExpected(16); + node.elements = parseDelimitedList(9, parseObjectBindingElement); + parseExpected(17); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(168); - parseExpected(19); - node.elements = parseDelimitedList(10, parseArrayBindingElement); + var node = createNode(169); parseExpected(20); + node.elements = parseDelimitedList(10, parseArrayBindingElement); + parseExpected(21); return finishNode(node); } function isIdentifierOrPattern() { - return token() === 15 || token() === 19 || isIdentifier(); + return token() === 16 || token() === 20 || isIdentifier(); } function parseIdentifierOrPattern() { - if (token() === 19) { + if (token() === 20) { return parseArrayBindingPattern(); } - if (token() === 15) { + if (token() === 16) { return parseObjectBindingPattern(); } return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(218); + var node = createNode(219); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { @@ -15828,21 +15315,21 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(219); + var node = createNode(220); switch (token()) { - case 102: + case 103: break; - case 108: + case 109: node.flags |= 1; break; - case 74: + case 75: node.flags |= 2; break; default: ts.Debug.fail(); } nextToken(); - if (token() === 138 && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 139 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -15854,10 +15341,10 @@ var ts; return finishNode(node); } function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 18; + return nextTokenIsIdentifier() && nextToken() === 19; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(200, fullStart); + var node = createNode(201, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.declarationList = parseVariableDeclarationList(false); @@ -15865,29 +15352,29 @@ var ts; return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(220, fullStart); + var node = createNode(221, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(87); - node.asteriskToken = parseOptionalToken(37); + parseExpected(88); + node.asteriskToken = parseOptionalToken(38); node.name = ts.hasModifier(node, 512) ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = !!node.asteriskToken; var isAsync = ts.hasModifier(node, 256); - fillSignature(54, isGenerator, isAsync, false, node); + fillSignature(55, isGenerator, isAsync, false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return addJSDocComment(finishNode(node)); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(148, pos); + var node = createNode(149, pos); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(121); - fillSignature(54, false, false, false, node); + parseExpected(122); + fillSignature(55, false, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, false, ts.Diagnostics.or_expected); return addJSDocComment(finishNode(node)); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(147, fullStart); + var method = createNode(148, fullStart); method.decorators = decorators; method.modifiers = modifiers; method.asteriskToken = asteriskToken; @@ -15895,12 +15382,12 @@ var ts; method.questionToken = questionToken; var isGenerator = !!asteriskToken; var isAsync = ts.hasModifier(method, 256); - fillSignature(54, isGenerator, isAsync, false, method); + fillSignature(55, isGenerator, isAsync, false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return addJSDocComment(finishNode(method)); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(145, fullStart); + var property = createNode(146, fullStart); property.decorators = decorators; property.modifiers = modifiers; property.name = name; @@ -15913,10 +15400,10 @@ var ts; return addJSDocComment(finishNode(property)); } function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { - var asteriskToken = parseOptionalToken(37); + var asteriskToken = parseOptionalToken(38); var name = parsePropertyName(); - var questionToken = parseOptionalToken(53); - if (asteriskToken || token() === 17 || token() === 25) { + var questionToken = parseOptionalToken(54); + if (asteriskToken || token() === 18 || token() === 26) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); } else { @@ -15931,17 +15418,17 @@ var ts; node.decorators = decorators; node.modifiers = modifiers; node.name = parsePropertyName(); - fillSignature(54, false, false, false, node); + fillSignature(55, false, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, false); return addJSDocComment(finishNode(node)); } function isClassMemberModifier(idToken) { switch (idToken) { - case 112: - case 110: - case 111: case 113: - case 128: + case 111: + case 112: + case 114: + case 129: return true; default: return false; @@ -15949,7 +15436,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token() === 55) { + if (token() === 56) { return true; } while (ts.isModifierKind(token())) { @@ -15959,26 +15446,26 @@ var ts; } nextToken(); } - if (token() === 37) { + if (token() === 38) { return true; } if (isLiteralPropertyName()) { idToken = token(); nextToken(); } - if (token() === 19) { + if (token() === 20) { return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 131 || idToken === 123) { + if (!ts.isKeyword(idToken) || idToken === 132 || idToken === 124) { return true; } switch (token()) { - case 17: - case 25: + case 18: + case 26: + case 55: + case 57: case 54: - case 56: - case 53: return true; default: return canParseSemicolon(); @@ -15990,10 +15477,10 @@ var ts; var decorators; while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(55)) { + if (!parseOptional(56)) { break; } - var decorator = createNode(143, decoratorStart); + var decorator = createNode(144, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); if (!decorators) { @@ -16013,7 +15500,7 @@ var ts; while (true) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); - if (token() === 74 && permitInvalidConstAsModifier) { + if (token() === 75 && permitInvalidConstAsModifier) { if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) { break; } @@ -16038,7 +15525,7 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 118) { + if (token() === 119) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); nextToken(); @@ -16049,8 +15536,8 @@ var ts; return modifiers; } function parseClassElement() { - if (token() === 23) { - var result = createNode(198); + if (token() === 24) { + var result = createNode(199); nextToken(); return finishNode(result); } @@ -16061,7 +15548,7 @@ var ts; if (accessor) { return accessor; } - if (token() === 121) { + if (token() === 122) { return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { @@ -16070,33 +15557,33 @@ var ts; if (ts.tokenIsIdentifierOrKeyword(token()) || token() === 9 || token() === 8 || - token() === 37 || - token() === 19) { + token() === 38 || + token() === 20) { return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { - var name_13 = createMissingNode(69, true, ts.Diagnostics.Declaration_expected); - return parsePropertyDeclaration(fullStart, decorators, modifiers, name_13, undefined); + var name_10 = createMissingNode(70, true, ts.Diagnostics.Declaration_expected); + return parsePropertyDeclaration(fullStart, decorators, modifiers, name_10, undefined); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 192); + return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 193); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 221); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 222); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(73); + parseExpected(74); node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); - node.heritageClauses = parseHeritageClauses(true); - if (parseExpected(15)) { + node.heritageClauses = parseHeritageClauses(); + if (parseExpected(16)) { node.members = parseClassMembers(); - parseExpected(16); + parseExpected(17); } else { node.members = createMissingList(); @@ -16109,16 +15596,16 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 106 && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 107 && lookAhead(nextTokenIsIdentifierOrKeyword); } - function parseHeritageClauses(isClassHeritageClause) { + function parseHeritageClauses() { if (isHeritageClause()) { return parseList(20, parseHeritageClause); } return undefined; } function parseHeritageClause() { - if (token() === 83 || token() === 106) { + if (token() === 84 || token() === 107) { var node = createNode(251); node.token = token(); nextToken(); @@ -16128,38 +15615,38 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(194); + var node = createNode(195); node.expression = parseLeftHandSideExpressionOrHigher(); - if (token() === 25) { - node.typeArguments = parseBracketedList(18, parseType, 25, 27); + if (token() === 26) { + node.typeArguments = parseBracketedList(18, parseType, 26, 28); } return finishNode(node); } function isHeritageClause() { - return token() === 83 || token() === 106; + return token() === 84 || token() === 107; } function parseClassMembers() { return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(222, fullStart); + var node = createNode(223, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(107); + parseExpected(108); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - node.heritageClauses = parseHeritageClauses(false); + node.heritageClauses = parseHeritageClauses(); node.members = parseObjectTypeMembers(); return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(223, fullStart); + var node = createNode(224, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(134); + parseExpected(135); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(56); + parseExpected(57); node.type = parseType(); parseSemicolon(); return addJSDocComment(finishNode(node)); @@ -16171,14 +15658,14 @@ var ts; return addJSDocComment(finishNode(node)); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(224, fullStart); + var node = createNode(225, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(81); + parseExpected(82); node.name = parseIdentifier(); - if (parseExpected(15)) { + if (parseExpected(16)) { node.members = parseDelimitedList(6, parseEnumMember); - parseExpected(16); + parseExpected(17); } else { node.members = createMissingList(); @@ -16186,10 +15673,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseModuleBlock() { - var node = createNode(226, scanner.getStartPos()); - if (parseExpected(15)) { + var node = createNode(227, scanner.getStartPos()); + if (parseExpected(16)) { node.statements = parseList(1, parseStatement); - parseExpected(16); + parseExpected(17); } else { node.statements = createMissingList(); @@ -16197,29 +15684,29 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(225, fullStart); + var node = createNode(226, fullStart); var namespaceFlag = flags & 16; node.decorators = decorators; node.modifiers = modifiers; node.flags |= flags; node.name = parseIdentifier(); - node.body = parseOptional(21) + node.body = parseOptional(22) ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 4 | namespaceFlag) : parseModuleBlock(); return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(225, fullStart); + var node = createNode(226, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (token() === 137) { + if (token() === 138) { node.name = parseIdentifier(); node.flags |= 512; } else { node.name = parseLiteralNode(true); } - if (token() === 15) { + if (token() === 16) { node.body = parseModuleBlock(); } else { @@ -16229,14 +15716,14 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = 0; - if (token() === 137) { + if (token() === 138) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } - else if (parseOptional(126)) { + else if (parseOptional(127)) { flags |= 16; } else { - parseExpected(125); + parseExpected(126); if (token() === 9) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -16244,63 +15731,63 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token() === 129 && + return token() === 130 && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { - return nextToken() === 17; + return nextToken() === 18; } function nextTokenIsSlash() { - return nextToken() === 39; + return nextToken() === 40; } function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { - var exportDeclaration = createNode(228, fullStart); + var exportDeclaration = createNode(229, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; - parseExpected(116); - parseExpected(126); + parseExpected(117); + parseExpected(127); exportDeclaration.name = parseIdentifier(); - parseExpected(23); + parseExpected(24); return finishNode(exportDeclaration); } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { - parseExpected(89); + parseExpected(90); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 24 && token() !== 136) { - var importEqualsDeclaration = createNode(229, fullStart); + if (token() !== 25 && token() !== 137) { + var importEqualsDeclaration = createNode(230, fullStart); importEqualsDeclaration.decorators = decorators; importEqualsDeclaration.modifiers = modifiers; importEqualsDeclaration.name = identifier; - parseExpected(56); + parseExpected(57); importEqualsDeclaration.moduleReference = parseModuleReference(); parseSemicolon(); return addJSDocComment(finishNode(importEqualsDeclaration)); } } - var importDeclaration = createNode(230, fullStart); + var importDeclaration = createNode(231, fullStart); importDeclaration.decorators = decorators; importDeclaration.modifiers = modifiers; if (identifier || - token() === 37 || - token() === 15) { + token() === 38 || + token() === 16) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(136); + parseExpected(137); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(importDeclaration); } function parseImportClause(identifier, fullStart) { - var importClause = createNode(231, fullStart); + var importClause = createNode(232, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || - parseOptional(24)) { - importClause.namedBindings = token() === 37 ? parseNamespaceImport() : parseNamedImportsOrExports(233); + parseOptional(25)) { + importClause.namedBindings = token() === 38 ? parseNamespaceImport() : parseNamedImportsOrExports(234); } return finishNode(importClause); } @@ -16310,11 +15797,11 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(240); - parseExpected(129); - parseExpected(17); - node.expression = parseModuleSpecifier(); + var node = createNode(241); + parseExpected(130); parseExpected(18); + node.expression = parseModuleSpecifier(); + parseExpected(19); return finishNode(node); } function parseModuleSpecifier() { @@ -16328,22 +15815,22 @@ var ts; } } function parseNamespaceImport() { - var namespaceImport = createNode(232); - parseExpected(37); - parseExpected(116); + var namespaceImport = createNode(233); + parseExpected(38); + parseExpected(117); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(21, kind === 233 ? parseImportSpecifier : parseExportSpecifier, 15, 16); + node.elements = parseBracketedList(21, kind === 234 ? parseImportSpecifier : parseExportSpecifier, 16, 17); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(238); + return parseImportOrExportSpecifier(239); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(234); + return parseImportOrExportSpecifier(235); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -16351,9 +15838,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token() === 116) { + if (token() === 117) { node.propertyName = identifierName; - parseExpected(116); + parseExpected(117); checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -16362,23 +15849,23 @@ var ts; else { node.name = identifierName; } - if (kind === 234 && checkIdentifierIsKeyword) { + if (kind === 235 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(236, fullStart); + var node = createNode(237, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (parseOptional(37)) { - parseExpected(136); + if (parseOptional(38)) { + parseExpected(137); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(237); - if (token() === 136 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { - parseExpected(136); + node.exportClause = parseNamedImportsOrExports(238); + if (token() === 137 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { + parseExpected(137); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -16386,14 +15873,14 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(235, fullStart); + var node = createNode(236, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (parseOptional(56)) { + if (parseOptional(57)) { node.isExportEquals = true; } else { - parseExpected(77); + parseExpected(78); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -16465,36 +15952,72 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return ts.hasModifier(node, 1) - || node.kind === 229 && node.moduleReference.kind === 240 - || node.kind === 230 - || node.kind === 235 + || node.kind === 230 && node.moduleReference.kind === 241 + || node.kind === 231 || node.kind === 236 + || node.kind === 237 ? node : undefined; }); } + var ParsingContext; + (function (ParsingContext) { + ParsingContext[ParsingContext["SourceElements"] = 0] = "SourceElements"; + ParsingContext[ParsingContext["BlockStatements"] = 1] = "BlockStatements"; + ParsingContext[ParsingContext["SwitchClauses"] = 2] = "SwitchClauses"; + ParsingContext[ParsingContext["SwitchClauseStatements"] = 3] = "SwitchClauseStatements"; + ParsingContext[ParsingContext["TypeMembers"] = 4] = "TypeMembers"; + ParsingContext[ParsingContext["ClassMembers"] = 5] = "ClassMembers"; + ParsingContext[ParsingContext["EnumMembers"] = 6] = "EnumMembers"; + ParsingContext[ParsingContext["HeritageClauseElement"] = 7] = "HeritageClauseElement"; + ParsingContext[ParsingContext["VariableDeclarations"] = 8] = "VariableDeclarations"; + ParsingContext[ParsingContext["ObjectBindingElements"] = 9] = "ObjectBindingElements"; + ParsingContext[ParsingContext["ArrayBindingElements"] = 10] = "ArrayBindingElements"; + ParsingContext[ParsingContext["ArgumentExpressions"] = 11] = "ArgumentExpressions"; + ParsingContext[ParsingContext["ObjectLiteralMembers"] = 12] = "ObjectLiteralMembers"; + ParsingContext[ParsingContext["JsxAttributes"] = 13] = "JsxAttributes"; + ParsingContext[ParsingContext["JsxChildren"] = 14] = "JsxChildren"; + ParsingContext[ParsingContext["ArrayLiteralMembers"] = 15] = "ArrayLiteralMembers"; + ParsingContext[ParsingContext["Parameters"] = 16] = "Parameters"; + ParsingContext[ParsingContext["TypeParameters"] = 17] = "TypeParameters"; + ParsingContext[ParsingContext["TypeArguments"] = 18] = "TypeArguments"; + ParsingContext[ParsingContext["TupleElementTypes"] = 19] = "TupleElementTypes"; + ParsingContext[ParsingContext["HeritageClauses"] = 20] = "HeritageClauses"; + ParsingContext[ParsingContext["ImportOrExportSpecifiers"] = 21] = "ImportOrExportSpecifiers"; + ParsingContext[ParsingContext["JSDocFunctionParameters"] = 22] = "JSDocFunctionParameters"; + ParsingContext[ParsingContext["JSDocTypeArguments"] = 23] = "JSDocTypeArguments"; + ParsingContext[ParsingContext["JSDocRecordMembers"] = 24] = "JSDocRecordMembers"; + ParsingContext[ParsingContext["JSDocTupleTypes"] = 25] = "JSDocTupleTypes"; + ParsingContext[ParsingContext["Count"] = 26] = "Count"; + })(ParsingContext || (ParsingContext = {})); + var Tristate; + (function (Tristate) { + Tristate[Tristate["False"] = 0] = "False"; + Tristate[Tristate["True"] = 1] = "True"; + Tristate[Tristate["Unknown"] = 2] = "Unknown"; + })(Tristate || (Tristate = {})); var JSDocParser; (function (JSDocParser) { function isJSDocType() { switch (token()) { - case 37: - case 53: - case 17: - case 19: - case 49: - case 15: - case 87: - case 22: - case 92: - case 97: + case 38: + case 54: + case 18: + case 20: + case 50: + case 16: + case 88: + case 23: + case 93: + case 98: return true; } return ts.tokenIsIdentifierOrKeyword(token()); } JSDocParser.isJSDocType = isJSDocType; function parseJSDocTypeExpressionForTests(content, start, length) { - initializeState("file.js", content, 2, undefined, 1); - sourceFile = createSourceFile("file.js", 2, 1); + initializeState(content, 4, undefined, 1); + sourceFile = createSourceFile("file.js", 4, 1); scanner.setText(content, start, length); currentToken = scanner.scan(); var jsDocTypeExpression = parseJSDocTypeExpression(); @@ -16505,21 +16028,21 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; function parseJSDocTypeExpression() { var result = createNode(257, scanner.getTokenPos()); - parseExpected(15); - result.type = parseJSDocTopLevelType(); parseExpected(16); + result.type = parseJSDocTopLevelType(); + parseExpected(17); fixupParentReferences(result); return finishNode(result); } JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocTopLevelType() { var type = parseJSDocType(); - if (token() === 47) { + if (token() === 48) { var unionType = createNode(261, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } - if (token() === 56) { + if (token() === 57) { var optionalType = createNode(268, type.pos); nextToken(); optionalType.type = type; @@ -16530,20 +16053,20 @@ var ts; function parseJSDocType() { var type = parseBasicTypeExpression(); while (true) { - if (token() === 19) { + if (token() === 20) { var arrayType = createNode(260, type.pos); arrayType.elementType = type; nextToken(); - parseExpected(20); + parseExpected(21); type = finishNode(arrayType); } - else if (token() === 53) { + else if (token() === 54) { var nullableType = createNode(263, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } - else if (token() === 49) { + else if (token() === 50) { var nonNullableType = createNode(264, type.pos); nonNullableType.type = type; nextToken(); @@ -16557,40 +16080,40 @@ var ts; } function parseBasicTypeExpression() { switch (token()) { - case 37: + case 38: return parseJSDocAllType(); - case 53: + case 54: return parseJSDocUnknownOrNullableType(); - case 17: + case 18: return parseJSDocUnionType(); - case 19: + case 20: return parseJSDocTupleType(); - case 49: + case 50: return parseJSDocNonNullableType(); - case 15: + case 16: return parseJSDocRecordType(); - case 87: + case 88: return parseJSDocFunctionType(); - case 22: + case 23: return parseJSDocVariadicType(); - case 92: - return parseJSDocConstructorType(); - case 97: - return parseJSDocThisType(); - case 117: - case 132: - case 130: - case 120: - case 133: - case 103: case 93: - case 135: - case 127: + return parseJSDocConstructorType(); + case 98: + return parseJSDocThisType(); + case 118: + case 133: + case 131: + case 121: + case 134: + case 104: + case 94: + case 136: + case 128: return parseTokenNode(); case 9: case 8: - case 99: - case 84: + case 100: + case 85: return parseJSDocLiteralType(); } return parseJSDocTypeReference(); @@ -16598,14 +16121,14 @@ var ts; function parseJSDocThisType() { var result = createNode(272); nextToken(); - parseExpected(54); + parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { var result = createNode(271); nextToken(); - parseExpected(54); + parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } @@ -16618,33 +16141,33 @@ var ts; function parseJSDocFunctionType() { var result = createNode(269); nextToken(); - parseExpected(17); + parseExpected(18); result.parameters = parseDelimitedList(22, parseJSDocParameter); checkForTrailingComma(result.parameters); - parseExpected(18); - if (token() === 54) { + parseExpected(19); + if (token() === 55) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(142); + var parameter = createNode(143); parameter.type = parseJSDocType(); - if (parseOptional(56)) { - parameter.questionToken = createNode(56); + if (parseOptional(57)) { + parameter.questionToken = createNode(57); } return finishNode(parameter); } function parseJSDocTypeReference() { var result = createNode(267); result.name = parseSimplePropertyName(); - if (token() === 25) { + if (token() === 26) { result.typeArguments = parseTypeArguments(); } else { - while (parseOptional(21)) { - if (token() === 25) { + while (parseOptional(22)) { + if (token() === 26) { result.typeArguments = parseTypeArguments(); break; } @@ -16660,7 +16183,7 @@ var ts; var typeArguments = parseDelimitedList(23, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); - parseExpected(27); + parseExpected(28); return typeArguments; } function checkForEmptyTypeArgumentList(typeArguments) { @@ -16671,7 +16194,7 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(139, left.pos); + var result = createNode(140, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); @@ -16692,7 +16215,7 @@ var ts; nextToken(); result.types = parseDelimitedList(25, parseJSDocType); checkForTrailingComma(result.types); - parseExpected(20); + parseExpected(21); return finishNode(result); } function checkForTrailingComma(list) { @@ -16705,13 +16228,13 @@ var ts; var result = createNode(261); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); - parseExpected(18); + parseExpected(19); return finishNode(result); } function parseJSDocTypeList(firstType) { ts.Debug.assert(!!firstType); var types = createNodeArray([firstType], firstType.pos); - while (parseOptional(47)) { + while (parseOptional(48)) { types.push(parseJSDocType()); } types.end = scanner.getStartPos(); @@ -16730,12 +16253,12 @@ var ts; function parseJSDocUnknownOrNullableType() { var pos = scanner.getStartPos(); nextToken(); - if (token() === 24 || - token() === 16 || - token() === 18 || - token() === 27 || - token() === 56 || - token() === 47) { + if (token() === 25 || + token() === 17 || + token() === 19 || + token() === 28 || + token() === 57 || + token() === 48) { var result = createNode(259, pos); return finishNode(result); } @@ -16746,7 +16269,7 @@ var ts; } } function parseIsolatedJSDocComment(content, start, length) { - initializeState("file.js", content, 2, undefined, 1); + initializeState(content, 4, undefined, 1); sourceFile = { languageVariant: 0, text: content }; var jsDoc = parseJSDocCommentWorker(start, length); var diagnostics = parseDiagnostics; @@ -16768,6 +16291,12 @@ var ts; return comment; } JSDocParser.parseJSDocComment = parseJSDocComment; + var JSDocState; + (function (JSDocState) { + JSDocState[JSDocState["BeginningOfLine"] = 0] = "BeginningOfLine"; + JSDocState[JSDocState["SawAsterisk"] = 1] = "SawAsterisk"; + JSDocState[JSDocState["SavingComments"] = 2] = "SavingComments"; + })(JSDocState || (JSDocState = {})); function parseJSDocCommentWorker(start, length) { var content = sourceText; start = start || 0; @@ -16804,7 +16333,7 @@ var ts; } while (token() !== 1) { switch (token()) { - case 55: + case 56: if (state === 0 || state === 1) { removeTrailingNewlines(comments); parseTag(indent); @@ -16822,7 +16351,7 @@ var ts; state = 0; indent = 0; break; - case 37: + case 38: var asterisk = scanner.getTokenText(); if (state === 1) { state = 2; @@ -16833,7 +16362,7 @@ var ts; indent += asterisk.length; } break; - case 69: + case 70: pushComment(scanner.getTokenText()); state = 2; break; @@ -16890,8 +16419,8 @@ var ts; } } function parseTag(indent) { - ts.Debug.assert(token() === 55); - var atToken = createNode(55, scanner.getTokenPos()); + ts.Debug.assert(token() === 56); + var atToken = createNode(56, scanner.getTokenPos()); atToken.end = scanner.getTextPos(); nextJSDocToken(); var tagName = parseJSDocIdentifierName(); @@ -16942,7 +16471,7 @@ var ts; comments.push(text); indent += text.length; } - while (token() !== 55 && token() !== 1) { + while (token() !== 56 && token() !== 1) { switch (token()) { case 4: if (state >= 1) { @@ -16951,7 +16480,7 @@ var ts; } indent = 0; break; - case 55: + case 56: break; case 5: if (state === 2) { @@ -16965,7 +16494,7 @@ var ts; indent += whitespace.length; } break; - case 37: + case 38: if (state === 0) { state = 1; indent += scanner.getTokenText().length; @@ -16976,7 +16505,7 @@ var ts; pushComment(scanner.getTokenText()); break; } - if (token() === 55) { + if (token() === 56) { break; } nextJSDocToken(); @@ -17004,7 +16533,7 @@ var ts; function tryParseTypeExpression() { return tryParse(function () { skipWhitespace(); - if (token() !== 15) { + if (token() !== 16) { return undefined; } return parseJSDocTypeExpression(); @@ -17015,14 +16544,14 @@ var ts; skipWhitespace(); var name; var isBracketed; - if (parseOptionalToken(19)) { + if (parseOptionalToken(20)) { name = parseJSDocIdentifierName(); skipWhitespace(); isBracketed = true; - if (parseOptionalToken(56)) { + if (parseOptionalToken(57)) { parseExpression(); } - parseExpected(20); + parseExpected(21); } else if (ts.tokenIsIdentifierOrKeyword(token())) { name = parseJSDocIdentifierName(); @@ -17099,9 +16628,9 @@ var ts; if (typeExpression) { if (typeExpression.type.kind === 267) { var jsDocTypeReference = typeExpression.type; - if (jsDocTypeReference.name.kind === 69) { - var name_14 = jsDocTypeReference.name; - if (name_14.text === "Object") { + if (jsDocTypeReference.name.kind === 70) { + var name_11 = jsDocTypeReference.name; + if (name_11.text === "Object") { typedefTag.jsDocTypeLiteral = scanChildTags(); } } @@ -17123,7 +16652,7 @@ var ts; while (token() !== 1 && !parentTagTerminated) { nextJSDocToken(); switch (token()) { - case 55: + case 56: if (canParseTag) { parentTagTerminated = !tryParseChildTag(jsDocTypeLiteral); if (!parentTagTerminated) { @@ -17137,13 +16666,13 @@ var ts; canParseTag = true; seenAsterisk = false; break; - case 37: + case 38: if (seenAsterisk) { canParseTag = false; } seenAsterisk = true; break; - case 69: + case 70: canParseTag = false; case 1: break; @@ -17154,8 +16683,8 @@ var ts; } } function tryParseChildTag(parentTag) { - ts.Debug.assert(token() === 55); - var atToken = createNode(55, scanner.getStartPos()); + ts.Debug.assert(token() === 56); + var atToken = createNode(56, scanner.getStartPos()); atToken.end = scanner.getTextPos(); nextJSDocToken(); var tagName = parseJSDocIdentifierName(); @@ -17187,17 +16716,17 @@ var ts; } var typeParameters = createNodeArray(); while (true) { - var name_15 = parseJSDocIdentifierName(); + var name_12 = parseJSDocIdentifierName(); skipWhitespace(); - if (!name_15) { + if (!name_12) { parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(141, name_15.pos); - typeParameter.name = name_15; + var typeParameter = createNode(142, name_12.pos); + typeParameter.name = name_12; finishNode(typeParameter); typeParameters.push(typeParameter); - if (token() === 24) { + if (token() === 25) { nextJSDocToken(); skipWhitespace(); } @@ -17226,7 +16755,7 @@ var ts; } var pos = scanner.getTokenPos(); var end = scanner.getTextPos(); - var result = createNode(69, pos); + var result = createNode(70, pos); result.text = content.substring(pos, end); finishNode(result, end); nextJSDocToken(); @@ -17297,8 +16826,8 @@ var ts; array._children = undefined; array.pos += delta; array.end += delta; - for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { - var node = array_8[_i]; + for (var _i = 0, array_9 = array; _i < array_9.length; _i++) { + var node = array_9[_i]; visitNode(node); } } @@ -17307,7 +16836,7 @@ var ts; switch (node.kind) { case 9: case 8: - case 69: + case 70: return true; } return false; @@ -17370,8 +16899,8 @@ var ts; array.intersectsChange = true; array._children = undefined; adjustIntersectingElement(array, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta); - for (var _i = 0, array_9 = array; _i < array_9.length; _i++) { - var node = array_9[_i]; + for (var _i = 0, array_10 = array; _i < array_10.length; _i++) { + var node = array_10[_i]; visitNode(node); } return; @@ -17519,21 +17048,31 @@ var ts; } } } + var InvalidPosition; + (function (InvalidPosition) { + InvalidPosition[InvalidPosition["Value"] = -1] = "Value"; + })(InvalidPosition || (InvalidPosition = {})); })(IncrementalParser || (IncrementalParser = {})); })(ts || (ts = {})); var ts; (function (ts) { + (function (ModuleInstanceState) { + ModuleInstanceState[ModuleInstanceState["NonInstantiated"] = 0] = "NonInstantiated"; + ModuleInstanceState[ModuleInstanceState["Instantiated"] = 1] = "Instantiated"; + ModuleInstanceState[ModuleInstanceState["ConstEnumOnly"] = 2] = "ConstEnumOnly"; + })(ts.ModuleInstanceState || (ts.ModuleInstanceState = {})); + var ModuleInstanceState = ts.ModuleInstanceState; function getModuleInstanceState(node) { - if (node.kind === 222 || node.kind === 223) { + if (node.kind === 223 || node.kind === 224) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 230 || node.kind === 229) && !(ts.hasModifier(node, 1))) { + else if ((node.kind === 231 || node.kind === 230) && !(ts.hasModifier(node, 1))) { return 0; } - else if (node.kind === 226) { + else if (node.kind === 227) { var state_1 = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -17549,7 +17088,7 @@ var ts; }); return state_1; } - else if (node.kind === 225) { + else if (node.kind === 226) { var body = node.body; return body ? getModuleInstanceState(body) : 1; } @@ -17558,6 +17097,18 @@ var ts; } } ts.getModuleInstanceState = getModuleInstanceState; + var ContainerFlags; + (function (ContainerFlags) { + ContainerFlags[ContainerFlags["None"] = 0] = "None"; + ContainerFlags[ContainerFlags["IsContainer"] = 1] = "IsContainer"; + ContainerFlags[ContainerFlags["IsBlockScopedContainer"] = 2] = "IsBlockScopedContainer"; + ContainerFlags[ContainerFlags["IsControlFlowContainer"] = 4] = "IsControlFlowContainer"; + ContainerFlags[ContainerFlags["IsFunctionLike"] = 8] = "IsFunctionLike"; + ContainerFlags[ContainerFlags["IsFunctionExpression"] = 16] = "IsFunctionExpression"; + ContainerFlags[ContainerFlags["HasLocals"] = 32] = "HasLocals"; + ContainerFlags[ContainerFlags["IsInterface"] = 64] = "IsInterface"; + ContainerFlags[ContainerFlags["IsObjectLiteralOrClassExpressionMethod"] = 128] = "IsObjectLiteralOrClassExpressionMethod"; + })(ContainerFlags || (ContainerFlags = {})); var binder = createBinder(); function bindSourceFile(file, options) { ts.performance.mark("beforeBind"); @@ -17655,7 +17206,7 @@ var ts; if (symbolFlags & 107455) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 225)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 226)) { symbol.valueDeclaration = node; } } @@ -17665,7 +17216,7 @@ var ts; if (ts.isAmbientModule(node)) { return ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + node.name.text + "\""; } - if (node.name.kind === 140) { + if (node.name.kind === 141) { var nameExpression = node.name.expression; if (ts.isStringOrNumericLiteral(nameExpression.kind)) { return nameExpression.text; @@ -17676,21 +17227,21 @@ var ts; return node.name.text; } switch (node.kind) { - case 148: + case 149: return "__constructor"; - case 156: - case 151: - return "__call"; case 157: case 152: - return "__new"; + return "__call"; + case 158: case 153: + return "__new"; + case 154: return "__index"; - case 236: + case 237: return "__export"; - case 235: + case 236: return node.isExportEquals ? "export=" : "default"; - case 187: + case 188: switch (ts.getSpecialPropertyAssignmentKind(node)) { case 2: return "export="; @@ -17702,12 +17253,12 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 220: case 221: + case 222: return ts.hasModifier(node, 512) ? "default" : undefined; case 269: return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; - case 142: + case 143: ts.Debug.assert(node.parent.kind === 269); var functionType = node.parent; var index = ts.indexOf(functionType.parameters, node); @@ -17715,10 +17266,10 @@ var ts; case 279: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 200) { + if (parentNode && parentNode.kind === 201) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; - if (nameIdentifier.kind === 69) { + if (nameIdentifier.kind === 70) { nameFromParentNode = nameIdentifier.text; } } @@ -17759,7 +17310,7 @@ var ts; } else { if (symbol.declarations && symbol.declarations.length && - (isDefaultExport || (node.kind === 235 && !node.isExportEquals))) { + (isDefaultExport || (node.kind === 236 && !node.isExportEquals))) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -17779,7 +17330,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1; if (symbolFlags & 8388608) { - if (node.kind === 238 || (node.kind === 229 && hasExportModifier)) { + if (node.kind === 239 || (node.kind === 230 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -17896,64 +17447,64 @@ var ts; return; } switch (node.kind) { - case 205: + case 206: bindWhileStatement(node); break; - case 204: + case 205: bindDoStatement(node); break; - case 206: + case 207: bindForStatement(node); break; - case 207: case 208: + case 209: bindForInOrForOfStatement(node); break; - case 203: + case 204: bindIfStatement(node); break; - case 211: - case 215: + case 212: + case 216: bindReturnOrThrow(node); break; + case 211: case 210: - case 209: bindBreakOrContinueStatement(node); break; - case 216: + case 217: bindTryStatement(node); break; - case 213: + case 214: bindSwitchStatement(node); break; - case 227: + case 228: bindCaseBlock(node); break; case 249: bindCaseClause(node); break; - case 214: + case 215: bindLabeledStatement(node); break; - case 185: + case 186: bindPrefixUnaryExpressionFlow(node); break; - case 186: + case 187: bindPostfixUnaryExpressionFlow(node); break; - case 187: + case 188: bindBinaryExpressionFlow(node); break; - case 181: + case 182: bindDeleteExpressionFlow(node); break; - case 188: + case 189: bindConditionalExpressionFlow(node); break; - case 218: + case 219: bindVariableDeclarationFlow(node); break; - case 174: + case 175: bindCallExpressionFlow(node); break; default: @@ -17963,25 +17514,25 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 69: - case 97: - case 172: + case 70: + case 98: + case 173: return isNarrowableReference(expr); - case 174: + case 175: return hasNarrowableArgument(expr); - case 178: + case 179: return isNarrowingExpression(expr.expression); - case 187: + case 188: return isNarrowingBinaryExpression(expr); - case 185: - return expr.operator === 49 && isNarrowingExpression(expr.operand); + case 186: + return expr.operator === 50 && isNarrowingExpression(expr.operand); } return false; } function isNarrowableReference(expr) { - return expr.kind === 69 || - expr.kind === 97 || - expr.kind === 172 && isNarrowableReference(expr.expression); + return expr.kind === 70 || + expr.kind === 98 || + expr.kind === 173 && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -17992,41 +17543,41 @@ var ts; } } } - if (expr.expression.kind === 172 && + if (expr.expression.kind === 173 && isNarrowableReference(expr.expression.expression)) { return true; } return false; } function isNarrowingTypeofOperands(expr1, expr2) { - return expr1.kind === 182 && isNarrowableOperand(expr1.expression) && expr2.kind === 9; + return expr1.kind === 183 && isNarrowableOperand(expr1.expression) && expr2.kind === 9; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 56: + case 57: return isNarrowableReference(expr.left); - case 30: case 31: case 32: case 33: + case 34: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 91: + case 92: return isNarrowableOperand(expr.left); - case 24: + case 25: return isNarrowingExpression(expr.right); } return false; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 178: + case 179: return isNarrowableOperand(expr.expression); - case 187: + case 188: switch (expr.operatorToken.kind) { - case 56: + case 57: return isNarrowableOperand(expr.left); - case 24: + case 25: return isNarrowableOperand(expr.right); } } @@ -18045,7 +17596,7 @@ var ts; }; } function setFlowNodeReferenced(flow) { - flow.flags |= flow.flags & 256 ? 512 : 256; + flow.flags |= flow.flags & 512 ? 1024 : 512; } function addAntecedent(label, antecedent) { if (!(antecedent.flags & 1) && !ts.contains(label.antecedents, antecedent)) { @@ -18060,8 +17611,8 @@ var ts; if (!expression) { return flags & 32 ? antecedent : unreachableFlow; } - if (expression.kind === 99 && flags & 64 || - expression.kind === 84 && flags & 32) { + if (expression.kind === 100 && flags & 64 || + expression.kind === 85 && flags & 32) { return unreachableFlow; } if (!isNarrowingExpression(expression)) { @@ -18095,6 +17646,14 @@ var ts; node: node }; } + function createFlowArrayMutation(antecedent, node) { + setFlowNodeReferenced(antecedent); + return { + flags: 256, + antecedent: antecedent, + node: node + }; + } function finishFlowLabel(flow) { var antecedents = flow.antecedents; if (!antecedents) { @@ -18108,34 +17667,34 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 203: - case 205: case 204: - return parent.expression === node; case 206: - case 188: + case 205: + return parent.expression === node; + case 207: + case 189: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 178) { + if (node.kind === 179) { node = node.expression; } - else if (node.kind === 185 && node.operator === 49) { + else if (node.kind === 186 && node.operator === 50) { node = node.operand; } else { - return node.kind === 187 && (node.operatorToken.kind === 51 || - node.operatorToken.kind === 52); + return node.kind === 188 && (node.operatorToken.kind === 52 || + node.operatorToken.kind === 53); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 178 || - node.parent.kind === 185 && - node.parent.operator === 49) { + while (node.parent.kind === 179 || + node.parent.kind === 186 && + node.parent.operator === 50) { node = node.parent; } return !isStatementCondition(node) && !isLogicalExpression(node.parent); @@ -18208,7 +17767,7 @@ var ts; bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 219) { + if (node.initializer.kind !== 220) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -18230,7 +17789,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 211) { + if (node.kind === 212) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -18250,7 +17809,7 @@ var ts; return undefined; } function bindbreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 210 ? breakTarget : continueTarget; + var flowLabel = node.kind === 211 ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -18270,21 +17829,32 @@ var ts; } } function bindTryStatement(node) { - var postFinallyLabel = createBranchLabel(); + var preFinallyLabel = createBranchLabel(); var preTryFlow = currentFlow; bind(node.tryBlock); - addAntecedent(postFinallyLabel, currentFlow); + addAntecedent(preFinallyLabel, currentFlow); + var flowAfterTry = currentFlow; + var flowAfterCatch = unreachableFlow; if (node.catchClause) { currentFlow = preTryFlow; bind(node.catchClause); - addAntecedent(postFinallyLabel, currentFlow); + addAntecedent(preFinallyLabel, currentFlow); + flowAfterCatch = currentFlow; } if (node.finallyBlock) { - currentFlow = preTryFlow; + addAntecedent(preFinallyLabel, preTryFlow); + currentFlow = finishFlowLabel(preFinallyLabel); bind(node.finallyBlock); + if (!(currentFlow.flags & 1)) { + if ((flowAfterTry.flags & 1) && (flowAfterCatch.flags & 1)) { + currentFlow = flowAfterTry === reportedUnreachableFlow || flowAfterCatch === reportedUnreachableFlow + ? reportedUnreachableFlow + : unreachableFlow; + } + } } - if (!node.finallyBlock || !(currentFlow.flags & 1)) { - currentFlow = finishFlowLabel(postFinallyLabel); + else { + currentFlow = finishFlowLabel(preFinallyLabel); } } function bindSwitchStatement(node) { @@ -18361,7 +17931,7 @@ var ts; currentFlow = finishFlowLabel(postStatementLabel); } function bindDestructuringTargetFlow(node) { - if (node.kind === 187 && node.operatorToken.kind === 56) { + if (node.kind === 188 && node.operatorToken.kind === 57) { bindAssignmentTargetFlow(node.left); } else { @@ -18372,10 +17942,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 170) { + else if (node.kind === 171) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 191) { + if (e.kind === 192) { bindAssignmentTargetFlow(e.expression); } else { @@ -18383,7 +17953,7 @@ var ts; } } } - else if (node.kind === 171) { + else if (node.kind === 172) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; if (p.kind === 253) { @@ -18397,7 +17967,7 @@ var ts; } function bindLogicalExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 51) { + if (node.operatorToken.kind === 52) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -18408,7 +17978,7 @@ var ts; bindCondition(node.right, trueTarget, falseTarget); } function bindPrefixUnaryExpressionFlow(node) { - if (node.operator === 49) { + if (node.operator === 50) { var saveTrueTarget = currentTrueTarget; currentTrueTarget = currentFalseTarget; currentFalseTarget = saveTrueTarget; @@ -18418,20 +17988,20 @@ var ts; } else { ts.forEachChild(node, bind); - if (node.operator === 41 || node.operator === 42) { + if (node.operator === 42 || node.operator === 43) { bindAssignmentTargetFlow(node.operand); } } } function bindPostfixUnaryExpressionFlow(node) { ts.forEachChild(node, bind); - if (node.operator === 41 || node.operator === 42) { + if (node.operator === 42 || node.operator === 43) { bindAssignmentTargetFlow(node.operand); } } function bindBinaryExpressionFlow(node) { var operator = node.operatorToken.kind; - if (operator === 51 || operator === 52) { + if (operator === 52 || operator === 53) { if (isTopLevelLogicalExpression(node)) { var postExpressionLabel = createBranchLabel(); bindLogicalExpression(node, postExpressionLabel, postExpressionLabel); @@ -18443,14 +18013,20 @@ var ts; } else { ts.forEachChild(node, bind); - if (operator === 56 && !ts.isAssignmentTarget(node)) { + if (operator === 57 && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); + if (node.left.kind === 174) { + var elementAccess = node.left; + if (isNarrowableOperand(elementAccess.expression)) { + currentFlow = createFlowArrayMutation(currentFlow, node); + } + } } } } function bindDeleteExpressionFlow(node) { ts.forEachChild(node, bind); - if (node.expression.kind === 172) { + if (node.expression.kind === 173) { bindAssignmentTargetFlow(node.expression); } } @@ -18481,16 +18057,16 @@ var ts; } function bindVariableDeclarationFlow(node) { ts.forEachChild(node, bind); - if (node.initializer || node.parent.parent.kind === 207 || node.parent.parent.kind === 208) { + if (node.initializer || node.parent.parent.kind === 208 || node.parent.parent.kind === 209) { bindInitializedVariableFlow(node); } } function bindCallExpressionFlow(node) { var expr = node.expression; - while (expr.kind === 178) { + while (expr.kind === 179) { expr = expr.expression; } - if (expr.kind === 179 || expr.kind === 180) { + if (expr.kind === 180 || expr.kind === 181) { ts.forEach(node.typeArguments, bind); ts.forEach(node.arguments, bind); bind(node.expression); @@ -18498,54 +18074,60 @@ var ts; else { ts.forEachChild(node, bind); } + if (node.expression.kind === 173) { + var propertyAccess = node.expression; + if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { + currentFlow = createFlowArrayMutation(currentFlow, node); + } + } } function getContainerFlags(node) { switch (node.kind) { - case 192: - case 221: - case 224: - case 171: - case 159: + case 193: + case 222: + case 225: + case 172: + case 160: case 281: case 265: return 1; - case 222: + case 223: return 1 | 64; case 269: - case 225: - case 223: + case 226: + case 224: return 1 | 32; case 256: return 1 | 4 | 32; - case 147: + case 148: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 | 4 | 32 | 8 | 128; } - case 148: - case 220: - case 146: case 149: + case 221: + case 147: case 150: case 151: case 152: case 153: - case 156: + case 154: case 157: + case 158: return 1 | 4 | 32 | 8; - case 179: case 180: + case 181: return 1 | 4 | 32 | 8 | 16; - case 226: + case 227: return 4; - case 145: + case 146: return node.initializer ? 4 : 0; case 252: - case 206: case 207: case 208: - case 227: + case 209: + case 228: return 2; - case 199: + case 200: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -18561,36 +18143,36 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 225: + case 226: return declareModuleMember(node, symbolFlags, symbolExcludes); case 256: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 192: - case 221: - return declareClassMember(node, symbolFlags, symbolExcludes); - case 224: - return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 159: - case 171: + case 193: case 222: + return declareClassMember(node, symbolFlags, symbolExcludes); + case 225: + return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); + case 160: + case 172: + case 223: case 265: case 281: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 156: case 157: - case 151: + case 158: case 152: case 153: - case 147: - case 146: + case 154: case 148: + case 147: case 149: case 150: - case 220: - case 179: + case 151: + case 221: case 180: + case 181: case 269: - case 223: + case 224: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -18606,10 +18188,10 @@ var ts; } function hasExportDeclarations(node) { var body = node.kind === 256 ? node : node.body; - if (body && (body.kind === 256 || body.kind === 226)) { + if (body && (body.kind === 256 || body.kind === 227)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 236 || stat.kind === 235) { + if (stat.kind === 237 || stat.kind === 236) { return true; } } @@ -18681,15 +18263,20 @@ var ts; typeLiteralSymbol.members[symbol.name] = symbol; } function bindObjectLiteralExpression(node) { + var ElementKind; + (function (ElementKind) { + ElementKind[ElementKind["Property"] = 1] = "Property"; + ElementKind[ElementKind["Accessor"] = 2] = "Accessor"; + })(ElementKind || (ElementKind = {})); if (inStrictMode) { var seen = ts.createMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.name.kind !== 69) { + if (prop.name.kind !== 70) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 253 || prop.kind === 254 || prop.kind === 147 + var currentKind = prop.kind === 253 || prop.kind === 254 || prop.kind === 148 ? 1 : 2; var existingKind = seen[identifier.text]; @@ -18711,7 +18298,7 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 225: + case 226: declareModuleMember(node, symbolFlags, symbolExcludes); break; case 256: @@ -18732,8 +18319,8 @@ var ts; } function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 106 && - node.originalKeywordKind <= 114 && + node.originalKeywordKind >= 107 && + node.originalKeywordKind <= 115 && !ts.isIdentifierName(node) && !ts.isInAmbientContext(node)) { if (!file.parseDiagnostics.length) { @@ -18761,17 +18348,17 @@ var ts; } } function checkStrictModeDeleteExpression(node) { - if (inStrictMode && node.expression.kind === 69) { + if (inStrictMode && node.expression.kind === 70) { var span_2 = ts.getErrorSpanForNode(file, node.expression); file.bindDiagnostics.push(ts.createFileDiagnostic(file, span_2.start, span_2.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode)); } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 69 && + return node.kind === 70 && (node.text === "eval" || node.text === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 69) { + if (name && name.kind === 70) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { var span_3 = ts.getErrorSpanForNode(file, name); @@ -18805,7 +18392,7 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2) { if (blockScopeContainer.kind !== 256 && - blockScopeContainer.kind !== 225 && + blockScopeContainer.kind !== 226 && !ts.isFunctionLike(blockScopeContainer)) { var errorSpan = ts.getErrorSpanForNode(file, node); file.bindDiagnostics.push(ts.createFileDiagnostic(file, errorSpan.start, errorSpan.length, getStrictModeBlockScopeFunctionDeclarationMessage(node))); @@ -18824,7 +18411,7 @@ var ts; } function checkStrictModePrefixUnaryExpression(node) { if (inStrictMode) { - if (node.operator === 41 || node.operator === 42) { + if (node.operator === 42 || node.operator === 43) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -18848,7 +18435,7 @@ var ts; node.parent = parent; var saveInStrictMode = inStrictMode; bindWorker(node); - if (node.kind > 138) { + if (node.kind > 139) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -18885,18 +18472,18 @@ var ts; } function bindWorker(node) { switch (node.kind) { - case 69: - case 97: + case 70: + case 98: if (currentFlow && (ts.isExpression(node) || parent.kind === 254)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 172: + case 173: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } break; - case 187: + case 188: if (ts.isInJavaScriptFile(node)) { var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { @@ -18921,30 +18508,30 @@ var ts; return checkStrictModeBinaryExpression(node); case 252: return checkStrictModeCatchClause(node); - case 181: + case 182: return checkStrictModeDeleteExpression(node); case 8: return checkStrictModeNumericLiteral(node); - case 186: + case 187: return checkStrictModePostfixUnaryExpression(node); - case 185: + case 186: return checkStrictModePrefixUnaryExpression(node); - case 212: + case 213: return checkStrictModeWithStatement(node); - case 165: + case 166: seenThisKeyword = true; return; - case 154: + case 155: return checkTypePredicate(node); - case 141: - return declareSymbolAndAddToSymbolTable(node, 262144, 530920); case 142: + return declareSymbolAndAddToSymbolTable(node, 262144, 530920); + case 143: return bindParameter(node); - case 218: - case 169: + case 219: + case 170: return bindVariableDeclarationOrBindingElement(node); + case 146: case 145: - case 144: case 266: return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 0); case 280: @@ -18957,82 +18544,82 @@ var ts; case 247: emitFlags |= 16384; return; - case 151: case 152: case 153: + case 154: return declareSymbolAndAddToSymbolTable(node, 131072, 0); - case 147: - case 146: - return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 0 : 99263); - case 220: - return bindFunctionDeclaration(node); case 148: - return declareSymbolAndAddToSymbolTable(node, 16384, 0); + case 147: + return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 0 : 99263); + case 221: + return bindFunctionDeclaration(node); case 149: - return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + return declareSymbolAndAddToSymbolTable(node, 16384, 0); case 150: + return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + case 151: return bindPropertyOrMethodOrAccessor(node, 65536, 74687); - case 156: case 157: + case 158: case 269: return bindFunctionOrConstructorType(node); - case 159: + case 160: case 281: case 265: return bindAnonymousDeclaration(node, 2048, "__type"); - case 171: + case 172: return bindObjectLiteralExpression(node); - case 179: case 180: + case 181: return bindFunctionExpression(node); - case 174: + case 175: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; - case 192: - case 221: + case 193: + case 222: inStrictMode = true; return bindClassLikeDeclaration(node); - case 222: + case 223: return bindBlockScopedDeclaration(node, 64, 792968); case 279: - case 223: - return bindBlockScopedDeclaration(node, 524288, 793064); case 224: - return bindEnumDeclaration(node); + return bindBlockScopedDeclaration(node, 524288, 793064); case 225: + return bindEnumDeclaration(node); + case 226: return bindModuleDeclaration(node); - case 229: - case 232: - case 234: - case 238: - return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); - case 228: - return bindNamespaceExportDeclaration(node); - case 231: - return bindImportClause(node); - case 236: - return bindExportDeclaration(node); + case 230: + case 233: case 235: + case 239: + return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + case 229: + return bindNamespaceExportDeclaration(node); + case 232: + return bindImportClause(node); + case 237: + return bindExportDeclaration(node); + case 236: return bindExportAssignment(node); case 256: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 199: + case 200: if (!ts.isFunctionLike(node.parent)) { return; } - case 226: + case 227: return updateStrictModeStatementList(node.statements); } } function checkTypePredicate(node) { var parameterName = node.parameterName, type = node.type; - if (parameterName && parameterName.kind === 69) { + if (parameterName && parameterName.kind === 70) { checkStrictModeIdentifier(parameterName); } - if (parameterName && parameterName.kind === 165) { + if (parameterName && parameterName.kind === 166) { seenThisKeyword = true; } bind(type); @@ -19051,7 +18638,7 @@ var ts; bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); } else { - var flags = node.kind === 235 && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 236 && ts.exportAssignmentIsAlias(node) ? 8388608 : 4; declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 | 8388608 | 32 | 16); @@ -19095,7 +18682,9 @@ var ts; function setCommonJsModuleIndicator(node) { if (!file.commonJsModuleIndicator) { file.commonJsModuleIndicator = node; - bindSourceFileAsExternalModule(); + if (!file.externalModuleIndicator) { + bindSourceFileAsExternalModule(); + } } } function bindExportsPropertyAssignment(node) { @@ -19108,11 +18697,11 @@ var ts; } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJavaScriptFile(node)); - if (container.kind === 220 || container.kind === 179) { + if (container.kind === 221 || container.kind === 180) { container.symbol.members = container.symbol.members || ts.createMap(); declareSymbol(container.symbol.members, container.symbol, node, 4, 0 & ~4); } - else if (container.kind === 148) { + else if (container.kind === 149) { var saveContainer = container; container = container.parent; var symbol = bindPropertyOrMethodOrAccessor(node, 4, 0); @@ -19152,7 +18741,7 @@ var ts; emitFlags |= 2048; } } - if (node.kind === 221) { + if (node.kind === 222) { bindBlockScopedDeclaration(node, 32, 899519); } else { @@ -19270,15 +18859,15 @@ var ts; return false; } if (currentFlow === unreachableFlow) { - var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 201) || - node.kind === 221 || - (node.kind === 225 && shouldReportErrorOnModuleDeclaration(node)) || - (node.kind === 224 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 202) || + node.kind === 222 || + (node.kind === 226 && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 225 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 200 || + (node.kind !== 201 || ts.getCombinedNodeFlags(node.declarationList) & 3 || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -19292,52 +18881,54 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 174: + case 175: return computeCallExpression(node, subtreeFlags); - case 225: + case 176: + return computeNewExpression(node, subtreeFlags); + case 226: return computeModuleDeclaration(node, subtreeFlags); - case 178: - return computeParenthesizedExpression(node, subtreeFlags); - case 187: - return computeBinaryExpression(node, subtreeFlags); - case 202: - return computeExpressionStatement(node, subtreeFlags); - case 142: - return computeParameter(node, subtreeFlags); - case 180: - return computeArrowFunction(node, subtreeFlags); case 179: + return computeParenthesizedExpression(node, subtreeFlags); + case 188: + return computeBinaryExpression(node, subtreeFlags); + case 203: + return computeExpressionStatement(node, subtreeFlags); + case 143: + return computeParameter(node, subtreeFlags); + case 181: + return computeArrowFunction(node, subtreeFlags); + case 180: return computeFunctionExpression(node, subtreeFlags); - case 220: - return computeFunctionDeclaration(node, subtreeFlags); - case 218: - return computeVariableDeclaration(node, subtreeFlags); - case 219: - return computeVariableDeclarationList(node, subtreeFlags); - case 200: - return computeVariableStatement(node, subtreeFlags); - case 214: - return computeLabeledStatement(node, subtreeFlags); case 221: + return computeFunctionDeclaration(node, subtreeFlags); + case 219: + return computeVariableDeclaration(node, subtreeFlags); + case 220: + return computeVariableDeclarationList(node, subtreeFlags); + case 201: + return computeVariableStatement(node, subtreeFlags); + case 215: + return computeLabeledStatement(node, subtreeFlags); + case 222: return computeClassDeclaration(node, subtreeFlags); - case 192: + case 193: return computeClassExpression(node, subtreeFlags); case 251: return computeHeritageClause(node, subtreeFlags); - case 194: + case 195: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 148: - return computeConstructor(node, subtreeFlags); - case 145: - return computePropertyDeclaration(node, subtreeFlags); - case 147: - return computeMethod(node, subtreeFlags); case 149: + return computeConstructor(node, subtreeFlags); + case 146: + return computePropertyDeclaration(node, subtreeFlags); + case 148: + return computeMethod(node, subtreeFlags); case 150: + case 151: return computeAccessor(node, subtreeFlags); - case 229: + case 230: return computeImportEquals(node, subtreeFlags); - case 172: + case 173: return computePropertyAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -19348,40 +18939,54 @@ var ts; var transformFlags = subtreeFlags; var expression = node.expression; var expressionKind = expression.kind; - if (subtreeFlags & 262144 + if (node.typeArguments) { + transformFlags |= 3; + } + if (subtreeFlags & 1048576 || isSuperOrSuperProperty(expression, expressionKind)) { - transformFlags |= 192; + transformFlags |= 768; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~537133909; + return transformFlags & ~537922901; } function isSuperOrSuperProperty(node, kind) { switch (kind) { - case 95: + case 96: return true; - case 172: case 173: + case 174: var expression = node.expression; var expressionKind = expression.kind; - return expressionKind === 95; + return expressionKind === 96; } return false; } + function computeNewExpression(node, subtreeFlags) { + var transformFlags = subtreeFlags; + if (node.typeArguments) { + transformFlags |= 3; + } + if (subtreeFlags & 1048576) { + transformFlags |= 768; + } + node.transformFlags = transformFlags | 536870912; + return transformFlags & ~537922901; + } function computeBinaryExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 56 - && (leftKind === 171 - || leftKind === 170)) { - transformFlags |= 192 | 256; + if (operatorTokenKind === 57 + && (leftKind === 172 + || leftKind === 171)) { + transformFlags |= 768 | 1024; } - else if (operatorTokenKind === 38 - || operatorTokenKind === 60) { - transformFlags |= 48; + else if (operatorTokenKind === 39 + || operatorTokenKind === 61) { + transformFlags |= 192; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeParameter(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -19389,35 +18994,35 @@ var ts; var name = node.name; var initializer = node.initializer; var dotDotDotToken = node.dotDotDotToken; - if (node.questionToken) { - transformFlags |= 3; - } - if (subtreeFlags & 2048 || ts.isThisIdentifier(name)) { + if (node.questionToken + || node.type + || subtreeFlags & 8192 + || ts.isThisIdentifier(name)) { transformFlags |= 3; } if (modifierFlags & 92) { - transformFlags |= 3 | 131072; + transformFlags |= 3 | 524288; } - if (subtreeFlags & 2097152 || initializer || dotDotDotToken) { - transformFlags |= 192 | 65536; + if (subtreeFlags & 8388608 || initializer || dotDotDotToken) { + transformFlags |= 768 | 262144; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~538968917; + return transformFlags & ~545262933; } function computeParenthesizedExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; var expression = node.expression; var expressionKind = expression.kind; var expressionTransformFlags = expression.transformFlags; - if (expressionKind === 195 - || expressionKind === 177) { + if (expressionKind === 196 + || expressionKind === 178) { transformFlags |= 3; } - if (expressionTransformFlags & 256) { - transformFlags |= 256; + if (expressionTransformFlags & 1024) { + transformFlags |= 1024; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeClassDeclaration(node, subtreeFlags) { var transformFlags; @@ -19426,36 +19031,38 @@ var ts; transformFlags = 3; } else { - transformFlags = subtreeFlags | 192; - if ((subtreeFlags & 137216) - || (modifierFlags & 1)) { + transformFlags = subtreeFlags | 768; + if ((subtreeFlags & 548864) + || (modifierFlags & 1) + || node.typeParameters) { transformFlags |= 3; } - if (subtreeFlags & 32768) { - transformFlags |= 8192; + if (subtreeFlags & 131072) { + transformFlags |= 32768; } } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~537590613; + return transformFlags & ~539749717; } function computeClassExpression(node, subtreeFlags) { - var transformFlags = subtreeFlags | 192; - if (subtreeFlags & 137216) { + var transformFlags = subtreeFlags | 768; + if (subtreeFlags & 548864 + || node.typeParameters) { transformFlags |= 3; } - if (subtreeFlags & 32768) { - transformFlags |= 8192; + if (subtreeFlags & 131072) { + transformFlags |= 32768; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~537590613; + return transformFlags & ~539749717; } function computeHeritageClause(node, subtreeFlags) { var transformFlags = subtreeFlags; switch (node.token) { - case 83: - transformFlags |= 192; + case 84: + transformFlags |= 768; break; - case 106: + case 107: transformFlags |= 3; break; default: @@ -19463,135 +19070,148 @@ var ts; break; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeExpressionWithTypeArguments(node, subtreeFlags) { - var transformFlags = subtreeFlags | 192; + var transformFlags = subtreeFlags | 768; if (node.typeArguments) { transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeConstructor(node, subtreeFlags) { var transformFlags = subtreeFlags; - var body = node.body; - if (body === undefined) { + if (ts.hasModifier(node, 2270) + || !node.body) { transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~550593365; + return transformFlags & ~591760725; } function computeMethod(node, subtreeFlags) { - var transformFlags = subtreeFlags | 192; - var modifierFlags = ts.getModifierFlags(node); - var body = node.body; - var typeParameters = node.typeParameters; - var asteriskToken = node.asteriskToken; - if (!body - || typeParameters - || (modifierFlags & (256 | 128)) - || (subtreeFlags & 2048)) { + var transformFlags = subtreeFlags | 768; + if (node.decorators + || ts.hasModifier(node, 2270) + || node.typeParameters + || node.type + || !node.body) { transformFlags |= 3; } - if (asteriskToken && ts.getEmitFlags(node) & 2097152) { - transformFlags |= 1536; + if (ts.hasModifier(node, 256)) { + transformFlags |= 48; + } + if (node.asteriskToken && ts.getEmitFlags(node) & 2097152) { + transformFlags |= 6144; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~550593365; + return transformFlags & ~591760725; } function computeAccessor(node, subtreeFlags) { var transformFlags = subtreeFlags; - var modifierFlags = ts.getModifierFlags(node); - var body = node.body; - if (!body - || (modifierFlags & (256 | 128)) - || (subtreeFlags & 2048)) { + if (node.decorators + || ts.hasModifier(node, 2270) + || node.type + || !node.body) { transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~550593365; + return transformFlags & ~591760725; } function computePropertyDeclaration(node, subtreeFlags) { var transformFlags = subtreeFlags | 3; if (node.initializer) { - transformFlags |= 4096; + transformFlags |= 16384; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeFunctionDeclaration(node, subtreeFlags) { var transformFlags; var modifierFlags = ts.getModifierFlags(node); var body = node.body; - var asteriskToken = node.asteriskToken; if (!body || (modifierFlags & 2)) { transformFlags = 3; } else { - transformFlags = subtreeFlags | 8388608; + transformFlags = subtreeFlags | 33554432; if (modifierFlags & 1) { - transformFlags |= 3 | 192; + transformFlags |= 3 | 768; } - if (modifierFlags & 256) { + if (modifierFlags & 2270 + || node.typeParameters + || node.type) { transformFlags |= 3; } - if (subtreeFlags & 81920) { - transformFlags |= 192; + if (modifierFlags & 256) { + transformFlags |= 48; } - if (asteriskToken && ts.getEmitFlags(node) & 2097152) { - transformFlags |= 1536; + if (subtreeFlags & 327680) { + transformFlags |= 768; + } + if (node.asteriskToken && ts.getEmitFlags(node) & 2097152) { + transformFlags |= 6144; } } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~550726485; + return transformFlags & ~592293205; } function computeFunctionExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; - var modifierFlags = ts.getModifierFlags(node); - var asteriskToken = node.asteriskToken; - if (modifierFlags & 256) { + if (ts.hasModifier(node, 2270) + || node.typeParameters + || node.type) { transformFlags |= 3; } - if (subtreeFlags & 81920) { - transformFlags |= 192; + if (ts.hasModifier(node, 256)) { + transformFlags |= 48; } - if (asteriskToken && ts.getEmitFlags(node) & 2097152) { - transformFlags |= 1536; + if (subtreeFlags & 327680) { + transformFlags |= 768; + } + if (node.asteriskToken && ts.getEmitFlags(node) & 2097152) { + transformFlags |= 6144; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~550726485; + return transformFlags & ~592293205; } function computeArrowFunction(node, subtreeFlags) { - var transformFlags = subtreeFlags | 192; - var modifierFlags = ts.getModifierFlags(node); - if (modifierFlags & 256) { + var transformFlags = subtreeFlags | 768; + if (ts.hasModifier(node, 2270) + || node.typeParameters + || node.type) { transformFlags |= 3; } - if (subtreeFlags & 8192) { - transformFlags |= 16384; + if (ts.hasModifier(node, 256)) { + transformFlags |= 48; + } + if (subtreeFlags & 32768) { + transformFlags |= 65536; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~550710101; + return transformFlags & ~592227669; } function computePropertyAccess(node, subtreeFlags) { var transformFlags = subtreeFlags; var expression = node.expression; var expressionKind = expression.kind; - if (expressionKind === 95) { - transformFlags |= 8192; + if (expressionKind === 96) { + transformFlags |= 32768; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeVariableDeclaration(node, subtreeFlags) { var transformFlags = subtreeFlags; var nameKind = node.name.kind; - if (nameKind === 167 || nameKind === 168) { - transformFlags |= 192 | 2097152; + if (nameKind === 168 || nameKind === 169) { + transformFlags |= 768 | 8388608; + } + if (node.type) { + transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeVariableStatement(node, subtreeFlags) { var transformFlags; @@ -19603,23 +19223,23 @@ var ts; else { transformFlags = subtreeFlags; if (modifierFlags & 1) { - transformFlags |= 192 | 3; + transformFlags |= 768 | 3; } - if (declarationListTransformFlags & 2097152) { - transformFlags |= 192; + if (declarationListTransformFlags & 8388608) { + transformFlags |= 768; } } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeLabeledStatement(node, subtreeFlags) { var transformFlags = subtreeFlags; - if (subtreeFlags & 1048576 + if (subtreeFlags & 4194304 && ts.isIterationStatement(node, true)) { - transformFlags |= 192; + transformFlags |= 768; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeImportEquals(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -19627,15 +19247,15 @@ var ts; transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeExpressionStatement(node, subtreeFlags) { var transformFlags = subtreeFlags; - if (node.expression.transformFlags & 256) { - transformFlags |= 192; + if (node.expression.transformFlags & 1024) { + transformFlags |= 768; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeModuleDeclaration(node, subtreeFlags) { var transformFlags = 3; @@ -19644,77 +19264,78 @@ var ts; transformFlags |= subtreeFlags; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~546335573; + return transformFlags & ~574729557; } function computeVariableDeclarationList(node, subtreeFlags) { - var transformFlags = subtreeFlags | 8388608; - if (subtreeFlags & 2097152) { - transformFlags |= 192; + var transformFlags = subtreeFlags | 33554432; + if (subtreeFlags & 8388608) { + transformFlags |= 768; } if (node.flags & 3) { - transformFlags |= 192 | 1048576; + transformFlags |= 768 | 4194304; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~538968917; + return transformFlags & ~545262933; } function computeOther(node, kind, subtreeFlags) { var transformFlags = subtreeFlags; - var excludeFlags = 536871765; + var excludeFlags = 536874325; switch (kind) { - case 112: - case 110: + case 119: + case 185: + transformFlags |= 48; + break; + case 113: case 111: - case 115: - case 122: - case 118: - case 74: - case 184: - case 224: + case 112: + case 116: + case 123: + case 75: + case 225: case 255: - case 177: - case 195: + case 178: case 196: - case 128: + case 197: + case 129: transformFlags |= 3; break; - case 241: case 242: case 243: case 244: + case 10: case 245: case 246: case 247: case 248: transformFlags |= 12; break; - case 82: - transformFlags |= 192 | 3; + case 83: + transformFlags |= 768 | 3; break; - case 77: - case 11: + case 78: case 12: case 13: case 14: - case 189: - case 176: - case 254: - case 208: - transformFlags |= 192; - break; + case 15: case 190: - transformFlags |= 192 | 4194304; + case 177: + case 254: + case 209: + transformFlags |= 768; break; - case 117: - case 130: - case 127: - case 132: - case 120: + case 191: + transformFlags |= 768 | 16777216; + break; + case 118: + case 131: + case 128: case 133: - case 103: - case 141: - case 144: - case 146: - case 151: + case 121: + case 134: + case 104: + case 142: + case 145: + case 147: case 152: case 153: case 154: @@ -19728,68 +19349,69 @@ var ts; case 162: case 163: case 164: - case 222: - case 223: case 165: + case 223: + case 224: case 166: + case 167: transformFlags = 3; excludeFlags = -3; break; - case 140: - transformFlags |= 524288; - if (subtreeFlags & 8192) { + case 141: + transformFlags |= 2097152; + if (subtreeFlags & 32768) { + transformFlags |= 131072; + } + break; + case 192: + transformFlags |= 1048576; + break; + case 96: + transformFlags |= 768; + break; + case 98: + transformFlags |= 32768; + break; + case 168: + case 169: + transformFlags |= 768 | 8388608; + break; + case 144: + transformFlags |= 3 | 8192; + break; + case 172: + excludeFlags = 539110741; + if (subtreeFlags & 2097152) { + transformFlags |= 768; + } + if (subtreeFlags & 131072) { transformFlags |= 32768; } break; - case 191: - transformFlags |= 262144; - break; - case 95: - transformFlags |= 192; - break; - case 97: - transformFlags |= 8192; - break; - case 167: - case 168: - transformFlags |= 192 | 2097152; - break; - case 143: - transformFlags |= 3 | 2048; - break; case 171: - excludeFlags = 537430869; - if (subtreeFlags & 524288) { - transformFlags |= 192; - } - if (subtreeFlags & 32768) { - transformFlags |= 8192; + case 176: + excludeFlags = 537922901; + if (subtreeFlags & 1048576) { + transformFlags |= 768; } break; - case 170: - case 175: - excludeFlags = 537133909; - if (subtreeFlags & 262144) { - transformFlags |= 192; - } - break; - case 204: case 205: case 206: case 207: - if (subtreeFlags & 1048576) { - transformFlags |= 192; + case 208: + if (subtreeFlags & 4194304) { + transformFlags |= 768; } break; case 256: - if (subtreeFlags & 16384) { - transformFlags |= 192; + if (subtreeFlags & 65536) { + transformFlags |= 768; } break; - case 211: - case 209: + case 212: case 210: - transformFlags |= 8388608; + case 211: + transformFlags |= 33554432; break; } node.transformFlags = transformFlags | 536870912; @@ -19889,6 +19511,7 @@ var ts; var intersectionTypes = ts.createMap(); var stringLiteralTypes = ts.createMap(); var numericLiteralTypes = ts.createMap(); + var evolvingArrayTypes = []; var unknownSymbol = createSymbol(4 | 67108864, "unknown"); var resolvingSymbol = createSymbol(67108864, "__resolving__"); var anyType = createIntrinsicType(1, "any"); @@ -19932,6 +19555,7 @@ var ts; var globalBooleanType; var globalRegExpType; var anyArrayType; + var autoArrayType; var anyReadonlyArrayType; var getGlobalTemplateStringsArrayType; var getGlobalESSymbolType; @@ -19972,6 +19596,66 @@ var ts; var potentialThisCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); + var TypeFacts; + (function (TypeFacts) { + TypeFacts[TypeFacts["None"] = 0] = "None"; + TypeFacts[TypeFacts["TypeofEQString"] = 1] = "TypeofEQString"; + TypeFacts[TypeFacts["TypeofEQNumber"] = 2] = "TypeofEQNumber"; + TypeFacts[TypeFacts["TypeofEQBoolean"] = 4] = "TypeofEQBoolean"; + TypeFacts[TypeFacts["TypeofEQSymbol"] = 8] = "TypeofEQSymbol"; + TypeFacts[TypeFacts["TypeofEQObject"] = 16] = "TypeofEQObject"; + TypeFacts[TypeFacts["TypeofEQFunction"] = 32] = "TypeofEQFunction"; + TypeFacts[TypeFacts["TypeofEQHostObject"] = 64] = "TypeofEQHostObject"; + TypeFacts[TypeFacts["TypeofNEString"] = 128] = "TypeofNEString"; + TypeFacts[TypeFacts["TypeofNENumber"] = 256] = "TypeofNENumber"; + TypeFacts[TypeFacts["TypeofNEBoolean"] = 512] = "TypeofNEBoolean"; + TypeFacts[TypeFacts["TypeofNESymbol"] = 1024] = "TypeofNESymbol"; + TypeFacts[TypeFacts["TypeofNEObject"] = 2048] = "TypeofNEObject"; + TypeFacts[TypeFacts["TypeofNEFunction"] = 4096] = "TypeofNEFunction"; + TypeFacts[TypeFacts["TypeofNEHostObject"] = 8192] = "TypeofNEHostObject"; + TypeFacts[TypeFacts["EQUndefined"] = 16384] = "EQUndefined"; + TypeFacts[TypeFacts["EQNull"] = 32768] = "EQNull"; + TypeFacts[TypeFacts["EQUndefinedOrNull"] = 65536] = "EQUndefinedOrNull"; + TypeFacts[TypeFacts["NEUndefined"] = 131072] = "NEUndefined"; + TypeFacts[TypeFacts["NENull"] = 262144] = "NENull"; + TypeFacts[TypeFacts["NEUndefinedOrNull"] = 524288] = "NEUndefinedOrNull"; + TypeFacts[TypeFacts["Truthy"] = 1048576] = "Truthy"; + TypeFacts[TypeFacts["Falsy"] = 2097152] = "Falsy"; + TypeFacts[TypeFacts["Discriminatable"] = 4194304] = "Discriminatable"; + TypeFacts[TypeFacts["All"] = 8388607] = "All"; + TypeFacts[TypeFacts["BaseStringStrictFacts"] = 933633] = "BaseStringStrictFacts"; + TypeFacts[TypeFacts["BaseStringFacts"] = 3145473] = "BaseStringFacts"; + TypeFacts[TypeFacts["StringStrictFacts"] = 4079361] = "StringStrictFacts"; + TypeFacts[TypeFacts["StringFacts"] = 4194049] = "StringFacts"; + TypeFacts[TypeFacts["EmptyStringStrictFacts"] = 3030785] = "EmptyStringStrictFacts"; + TypeFacts[TypeFacts["EmptyStringFacts"] = 3145473] = "EmptyStringFacts"; + TypeFacts[TypeFacts["NonEmptyStringStrictFacts"] = 1982209] = "NonEmptyStringStrictFacts"; + TypeFacts[TypeFacts["NonEmptyStringFacts"] = 4194049] = "NonEmptyStringFacts"; + TypeFacts[TypeFacts["BaseNumberStrictFacts"] = 933506] = "BaseNumberStrictFacts"; + TypeFacts[TypeFacts["BaseNumberFacts"] = 3145346] = "BaseNumberFacts"; + TypeFacts[TypeFacts["NumberStrictFacts"] = 4079234] = "NumberStrictFacts"; + TypeFacts[TypeFacts["NumberFacts"] = 4193922] = "NumberFacts"; + TypeFacts[TypeFacts["ZeroStrictFacts"] = 3030658] = "ZeroStrictFacts"; + TypeFacts[TypeFacts["ZeroFacts"] = 3145346] = "ZeroFacts"; + TypeFacts[TypeFacts["NonZeroStrictFacts"] = 1982082] = "NonZeroStrictFacts"; + TypeFacts[TypeFacts["NonZeroFacts"] = 4193922] = "NonZeroFacts"; + TypeFacts[TypeFacts["BaseBooleanStrictFacts"] = 933252] = "BaseBooleanStrictFacts"; + TypeFacts[TypeFacts["BaseBooleanFacts"] = 3145092] = "BaseBooleanFacts"; + TypeFacts[TypeFacts["BooleanStrictFacts"] = 4078980] = "BooleanStrictFacts"; + TypeFacts[TypeFacts["BooleanFacts"] = 4193668] = "BooleanFacts"; + TypeFacts[TypeFacts["FalseStrictFacts"] = 3030404] = "FalseStrictFacts"; + TypeFacts[TypeFacts["FalseFacts"] = 3145092] = "FalseFacts"; + TypeFacts[TypeFacts["TrueStrictFacts"] = 1981828] = "TrueStrictFacts"; + TypeFacts[TypeFacts["TrueFacts"] = 4193668] = "TrueFacts"; + TypeFacts[TypeFacts["SymbolStrictFacts"] = 1981320] = "SymbolStrictFacts"; + TypeFacts[TypeFacts["SymbolFacts"] = 4193160] = "SymbolFacts"; + TypeFacts[TypeFacts["ObjectStrictFacts"] = 6166480] = "ObjectStrictFacts"; + TypeFacts[TypeFacts["ObjectFacts"] = 8378320] = "ObjectFacts"; + TypeFacts[TypeFacts["FunctionStrictFacts"] = 6164448] = "FunctionStrictFacts"; + TypeFacts[TypeFacts["FunctionFacts"] = 8376288] = "FunctionFacts"; + TypeFacts[TypeFacts["UndefinedFacts"] = 2457472] = "UndefinedFacts"; + TypeFacts[TypeFacts["NullFacts"] = 2340752] = "NullFacts"; + })(TypeFacts || (TypeFacts = {})); var typeofEQFacts = ts.createMap({ "string": 1, "number": 2, @@ -20014,6 +19698,13 @@ var ts; var identityRelation = ts.createMap(); var enumRelation = ts.createMap(); var _displayBuilder; + var TypeSystemPropertyName; + (function (TypeSystemPropertyName) { + TypeSystemPropertyName[TypeSystemPropertyName["Type"] = 0] = "Type"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstructorType"] = 1] = "ResolvedBaseConstructorType"; + TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; + })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); var builtinGlobals = ts.createMap(); builtinGlobals[undefinedSymbol.name] = undefinedSymbol; initializeTypeChecker(); @@ -20098,7 +19789,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 225 && source.valueDeclaration.kind !== 225))) { + (target.valueDeclaration.kind === 226 && source.valueDeclaration.kind !== 226))) { target.valueDeclaration = source.valueDeclaration; } ts.forEach(source.declarations, function (node) { @@ -20233,24 +19924,24 @@ var ts; return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); } if (declaration.pos <= usage.pos) { - return declaration.kind !== 218 || + return declaration.kind !== 219 || !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } return isUsedInFunctionOrNonStaticProperty(declaration, usage); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 200: - case 206: - case 208: + case 201: + case 207: + case 209: if (isSameScopeDescendentOf(usage, declaration, container)) { return true; } break; } switch (declaration.parent.parent.kind) { - case 207: case 208: + case 209: if (isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container)) { return true; } @@ -20268,7 +19959,7 @@ var ts; return true; } var initializerOfNonStaticProperty = current.parent && - current.parent.kind === 145 && + current.parent.kind === 146 && (ts.getModifierFlags(current.parent) & 32) === 0 && current.parent.initializer === current; if (initializerOfNonStaticProperty) { @@ -20294,15 +19985,15 @@ var ts; if (meaning & result.flags & 793064 && lastLocation.kind !== 273) { useResult = result.flags & 262144 ? lastLocation === location.type || - lastLocation.kind === 142 || - lastLocation.kind === 141 + lastLocation.kind === 143 || + lastLocation.kind === 142 : false; } if (meaning & 107455 && result.flags & 1) { useResult = - lastLocation.kind === 142 || + lastLocation.kind === 143 || (lastLocation === location.type && - result.valueDeclaration.kind === 142); + result.valueDeclaration.kind === 143); } } if (useResult) { @@ -20318,7 +20009,7 @@ var ts; if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 225: + case 226: var moduleExports = getSymbolOfNode(location).exports; if (location.kind === 256 || ts.isAmbientModule(location)) { if (result = moduleExports["default"]) { @@ -20330,7 +20021,7 @@ var ts; } if (moduleExports[name] && moduleExports[name].flags === 8388608 && - ts.getDeclarationOfKind(moduleExports[name], 238)) { + ts.getDeclarationOfKind(moduleExports[name], 239)) { break; } } @@ -20338,13 +20029,13 @@ var ts; break loop; } break; - case 224: + case 225: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; + case 146: case 145: - case 144: if (ts.isClassLike(location.parent) && !(ts.getModifierFlags(location) & 32)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { @@ -20354,9 +20045,9 @@ var ts; } } break; - case 221: - case 192: case 222: + case 193: + case 223: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793064)) { if (lastLocation && ts.getModifierFlags(lastLocation) & 32) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); @@ -20364,7 +20055,7 @@ var ts; } break loop; } - if (location.kind === 192 && meaning & 32) { + if (location.kind === 193 && meaning & 32) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -20372,28 +20063,28 @@ var ts; } } break; - case 140: + case 141: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 222) { + if (ts.isClassLike(grandparent) || grandparent.kind === 223) { if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793064)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 147: - case 146: case 148: + case 147: case 149: case 150: - case 220: - case 180: + case 151: + case 221: + case 181: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 179: + case 180: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -20406,8 +20097,8 @@ var ts; } } break; - case 143: - if (location.parent && location.parent.kind === 142) { + case 144: + if (location.parent && location.parent.kind === 143) { location = location.parent; } if (location.parent && ts.isClassElement(location.parent)) { @@ -20449,7 +20140,7 @@ var ts; } if (result && isInExternalModule && (meaning & 107455) === 107455) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 228) { + if (decls && decls.length === 1 && decls[0].kind === 229) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } @@ -20457,7 +20148,7 @@ var ts; return result; } function checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) { - if ((errorLocation.kind === 69 && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { + if ((errorLocation.kind === 70 && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { return false; } var container = ts.getThisContainer(errorLocation, true); @@ -20495,10 +20186,10 @@ var ts; } function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 69: - case 172: + case 70: + case 173: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 194: + case 195: ts.Debug.assert(ts.isEntityNameExpression(node.expression)); return node.expression; default: @@ -20519,7 +20210,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"); - if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 218), errorLocation)) { + if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 219), errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -20536,10 +20227,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 229) { + if (node.kind === 230) { return node; } - while (node && node.kind !== 230) { + while (node && node.kind !== 231) { node = node.parent; } return node; @@ -20549,10 +20240,10 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 240) { + if (node.moduleReference.kind === 241) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } - return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); + return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); } function getTargetOfImportClause(node) { var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier); @@ -20610,28 +20301,28 @@ var ts; var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); if (targetSymbol) { - var name_16 = specifier.propertyName || specifier.name; - if (name_16.text) { + var name_13 = specifier.propertyName || specifier.name; + if (name_13.text) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { return moduleSymbol; } var symbolFromVariable = void 0; if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports["export="]) { - symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name_16.text); + symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name_13.text); } else { - symbolFromVariable = getPropertyOfVariable(targetSymbol, name_16.text); + symbolFromVariable = getPropertyOfVariable(targetSymbol, name_13.text); } symbolFromVariable = resolveSymbol(symbolFromVariable); - var symbolFromModule = getExportOfModule(targetSymbol, name_16.text); - if (!symbolFromModule && allowSyntheticDefaultImports && name_16.text === "default") { + var symbolFromModule = getExportOfModule(targetSymbol, name_13.text); + if (!symbolFromModule && allowSyntheticDefaultImports && name_13.text === "default") { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol); } var symbol = symbolFromModule && symbolFromVariable ? combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : symbolFromModule || symbolFromVariable; if (!symbol) { - error(name_16, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_16)); + error(name_13, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_13)); } return symbol; } @@ -20653,19 +20344,19 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 229: + case 230: return getTargetOfImportEqualsDeclaration(node); - case 231: - return getTargetOfImportClause(node); case 232: + return getTargetOfImportClause(node); + case 233: return getTargetOfNamespaceImport(node); - case 234: - return getTargetOfImportSpecifier(node); - case 238: - return getTargetOfExportSpecifier(node); case 235: + return getTargetOfImportSpecifier(node); + case 239: + return getTargetOfExportSpecifier(node); + case 236: return getTargetOfExportAssignment(node); - case 228: + case 229: return getTargetOfNamespaceExportDeclaration(node); } } @@ -20709,10 +20400,10 @@ var ts; links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); ts.Debug.assert(!!node); - if (node.kind === 235) { + if (node.kind === 236) { checkExpressionCached(node.expression); } - else if (node.kind === 238) { + else if (node.kind === 239) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -20720,15 +20411,15 @@ var ts; } } } - function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration, dontResolveAlias) { - if (entityName.kind === 69 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, dontResolveAlias) { + if (entityName.kind === 70 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 69 || entityName.parent.kind === 139) { + if (entityName.kind === 70 || entityName.parent.kind === 140) { return resolveEntityName(entityName, 1920, false, dontResolveAlias); } else { - ts.Debug.assert(entityName.parent.kind === 229); + ts.Debug.assert(entityName.parent.kind === 230); return resolveEntityName(entityName, 107455 | 793064 | 1920, false, dontResolveAlias); } } @@ -20740,16 +20431,16 @@ var ts; return undefined; } var symbol; - if (name.kind === 69) { + if (name.kind === 70) { var message = meaning === 1920 ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; symbol = resolveName(location || name, name.text, meaning, ignoreErrors ? undefined : message, name); if (!symbol) { return undefined; } } - else if (name.kind === 139 || name.kind === 172) { - var left = name.kind === 139 ? name.left : name.expression; - var right = name.kind === 139 ? name.right : name.name; + else if (name.kind === 140 || name.kind === 173) { + var left = name.kind === 140 ? name.left : name.expression; + var right = name.kind === 140 ? name.right : name.name; var namespace = resolveEntityName(left, 1920, ignoreErrors, false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -20932,7 +20623,7 @@ var ts; var members = node.members; for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { var member = members_1[_i]; - if (member.kind === 148 && ts.nodeIsPresent(member.body)) { + if (member.kind === 149 && ts.nodeIsPresent(member.body)) { return member; } } @@ -21006,7 +20697,7 @@ var ts; if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 225: + case 226: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } @@ -21039,7 +20730,7 @@ var ts; return ts.forEachProperty(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 238)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 239)) { if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -21070,7 +20761,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 238)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 239)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -21084,10 +20775,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 145: - case 147: - case 149: + case 146: + case 148: case 150: + case 151: continue; default: return false; @@ -21109,7 +20800,7 @@ var ts; return { accessibility: 1, errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), - errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, 1920) : undefined + errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, 1920) : undefined, }; } return hasAccessibleDeclarations; @@ -21130,7 +20821,7 @@ var ts; } return { accessibility: 1, - errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning) + errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), }; } return { accessibility: 0 }; @@ -21177,11 +20868,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 158 || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + if (entityName.parent.kind === 159 || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning = 107455 | 1048576; } - else if (entityName.kind === 139 || entityName.kind === 172 || - entityName.parent.kind === 229) { + else if (entityName.kind === 140 || entityName.kind === 173 || + entityName.parent.kind === 230) { meaning = 1920; } else { @@ -21273,10 +20964,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { var node = type.symbol.declarations[0].parent; - while (node.kind === 164) { + while (node.kind === 165) { node = node.parent; } - if (node.kind === 223) { + if (node.kind === 224) { return getSymbolOfNode(node); } } @@ -21284,7 +20975,7 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 226 && + node.parent.kind === 227 && ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { @@ -21298,10 +20989,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 192: + case 193: return "(Anonymous class)"; - case 179: case 180: + case 181: return "(Anonymous function)"; } } @@ -21315,17 +21006,17 @@ var ts; var firstChar = symbolName.charCodeAt(0); var needsElementAccess = !ts.isIdentifierStart(firstChar, languageVersion); if (needsElementAccess) { - writePunctuation(writer, 19); + writePunctuation(writer, 20); if (ts.isSingleOrDoubleQuote(firstChar)) { writer.writeStringLiteral(symbolName); } else { writer.writeSymbol(symbolName, symbol); } - writePunctuation(writer, 20); + writePunctuation(writer, 21); } else { - writePunctuation(writer, 21); + writePunctuation(writer, 22); writer.writeSymbol(symbolName, symbol); } } @@ -21401,7 +21092,7 @@ var ts; } else if (type.flags & 256) { buildSymbolDisplay(getParentOfSymbol(type.symbol), writer, enclosingDeclaration, 793064, 0, nextFlags); - writePunctuation(writer, 21); + writePunctuation(writer, 22); appendSymbolNameOnly(type.symbol, writer); } else if (type.flags & (32768 | 65536 | 16 | 16384)) { @@ -21422,23 +21113,23 @@ var ts; writer.writeStringLiteral(literalTypeToString(type)); } else { - writePunctuation(writer, 15); - writeSpace(writer); - writePunctuation(writer, 22); - writeSpace(writer); writePunctuation(writer, 16); + writeSpace(writer); + writePunctuation(writer, 23); + writeSpace(writer); + writePunctuation(writer, 17); } } function writeTypeList(types, delimiter) { for (var i = 0; i < types.length; i++) { if (i > 0) { - if (delimiter !== 24) { + if (delimiter !== 25) { writeSpace(writer); } writePunctuation(writer, delimiter); writeSpace(writer); } - writeType(types[i], delimiter === 24 ? 0 : 64); + writeType(types[i], delimiter === 25 ? 0 : 64); } } function writeSymbolTypeReference(symbol, typeArguments, pos, end, flags) { @@ -21446,29 +21137,29 @@ var ts; buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793064, 0, flags); } if (pos < end) { - writePunctuation(writer, 25); + writePunctuation(writer, 26); writeType(typeArguments[pos], 256); pos++; while (pos < end) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); writeSpace(writer); writeType(typeArguments[pos], 0); pos++; } - writePunctuation(writer, 27); + writePunctuation(writer, 28); } } function writeTypeReference(type, flags) { var typeArguments = type.typeArguments || emptyArray; if (type.target === globalArrayType && !(flags & 1)) { writeType(typeArguments[0], 64); - writePunctuation(writer, 19); writePunctuation(writer, 20); + writePunctuation(writer, 21); } else if (type.target.flags & 262144) { - writePunctuation(writer, 19); - writeTypeList(type.typeArguments.slice(0, getTypeReferenceArity(type)), 24); writePunctuation(writer, 20); + writeTypeList(type.typeArguments.slice(0, getTypeReferenceArity(type)), 25); + writePunctuation(writer, 21); } else { var outerTypeParameters = type.target.outerTypeParameters; @@ -21483,7 +21174,7 @@ var ts; } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_9); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { writeSymbolTypeReference(parent_9, typeArguments, start, i, flags); - writePunctuation(writer, 21); + writePunctuation(writer, 22); } } } @@ -21493,16 +21184,16 @@ var ts; } function writeUnionOrIntersectionType(type, flags) { if (flags & 64) { - writePunctuation(writer, 17); + writePunctuation(writer, 18); } if (type.flags & 524288) { - writeTypeList(formatUnionTypes(type.types), 47); + writeTypeList(formatUnionTypes(type.types), 48); } else { - writeTypeList(type.types, 46); + writeTypeList(type.types, 47); } if (flags & 64) { - writePunctuation(writer, 18); + writePunctuation(writer, 19); } } function writeAnonymousType(type, flags) { @@ -21520,7 +21211,7 @@ var ts; buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793064, 0, flags); } else { - writeKeyword(writer, 117); + writeKeyword(writer, 118); } } else { @@ -21541,7 +21232,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 256 || declaration.parent.kind === 226; + return declaration.parent.kind === 256 || declaration.parent.kind === 227; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -21550,37 +21241,37 @@ var ts; } } function writeTypeOfSymbol(type, typeFormatFlags) { - writeKeyword(writer, 101); + writeKeyword(writer, 102); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455, 0, typeFormatFlags); } function writeIndexSignature(info, keyword) { if (info) { if (info.isReadonly) { - writeKeyword(writer, 128); + writeKeyword(writer, 129); writeSpace(writer); } - writePunctuation(writer, 19); + writePunctuation(writer, 20); writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); - writePunctuation(writer, 54); + writePunctuation(writer, 55); writeSpace(writer); writeKeyword(writer, keyword); - writePunctuation(writer, 20); - writePunctuation(writer, 54); + writePunctuation(writer, 21); + writePunctuation(writer, 55); writeSpace(writer); writeType(info.type, 0); - writePunctuation(writer, 23); + writePunctuation(writer, 24); writer.writeLine(); } } function writePropertyWithModifiers(prop) { if (isReadonlySymbol(prop)) { - writeKeyword(writer, 128); + writeKeyword(writer, 129); writeSpace(writer); } buildSymbolDisplay(prop, writer); if (prop.flags & 536870912) { - writePunctuation(writer, 53); + writePunctuation(writer, 54); } } function shouldAddParenthesisAroundFunctionType(callSignature, flags) { @@ -21598,53 +21289,53 @@ var ts; var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { - writePunctuation(writer, 15); writePunctuation(writer, 16); + writePunctuation(writer, 17); return; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var parenthesizeSignature = shouldAddParenthesisAroundFunctionType(resolved.callSignatures[0], flags); if (parenthesizeSignature) { - writePunctuation(writer, 17); + writePunctuation(writer, 18); } buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, undefined, symbolStack); if (parenthesizeSignature) { - writePunctuation(writer, 18); + writePunctuation(writer, 19); } return; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { if (flags & 64) { - writePunctuation(writer, 17); + writePunctuation(writer, 18); } - writeKeyword(writer, 92); + writeKeyword(writer, 93); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, undefined, symbolStack); if (flags & 64) { - writePunctuation(writer, 18); + writePunctuation(writer, 19); } return; } } var saveInObjectTypeLiteral = inObjectTypeLiteral; inObjectTypeLiteral = true; - writePunctuation(writer, 15); + writePunctuation(writer, 16); writer.writeLine(); writer.increaseIndent(); for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, undefined, symbolStack); - writePunctuation(writer, 23); + writePunctuation(writer, 24); writer.writeLine(); } for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, 1, symbolStack); - writePunctuation(writer, 23); + writePunctuation(writer, 24); writer.writeLine(); } - writeIndexSignature(resolved.stringIndexInfo, 132); - writeIndexSignature(resolved.numberIndexInfo, 130); + writeIndexSignature(resolved.stringIndexInfo, 133); + writeIndexSignature(resolved.numberIndexInfo, 131); for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); @@ -21654,21 +21345,21 @@ var ts; var signature = signatures_1[_f]; writePropertyWithModifiers(p); buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, undefined, symbolStack); - writePunctuation(writer, 23); + writePunctuation(writer, 24); writer.writeLine(); } } else { writePropertyWithModifiers(p); - writePunctuation(writer, 54); + writePunctuation(writer, 55); writeSpace(writer); writeType(t, 0); - writePunctuation(writer, 23); + writePunctuation(writer, 24); writer.writeLine(); } } writer.decreaseIndent(); - writePunctuation(writer, 16); + writePunctuation(writer, 17); inObjectTypeLiteral = saveInObjectTypeLiteral; } } @@ -21683,7 +21374,7 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 83); + writeKeyword(writer, 84); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } @@ -21691,7 +21382,7 @@ var ts; function buildParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack) { var parameterNode = p.valueDeclaration; if (ts.isRestParameter(parameterNode)) { - writePunctuation(writer, 22); + writePunctuation(writer, 23); } if (ts.isBindingPattern(parameterNode.name)) { buildBindingPatternDisplay(parameterNode.name, writer, enclosingDeclaration, flags, symbolStack); @@ -21700,36 +21391,36 @@ var ts; appendSymbolNameOnly(p, writer); } if (isOptionalParameter(parameterNode)) { - writePunctuation(writer, 53); + writePunctuation(writer, 54); } - writePunctuation(writer, 54); + writePunctuation(writer, 55); writeSpace(writer); buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); } function buildBindingPatternDisplay(bindingPattern, writer, enclosingDeclaration, flags, symbolStack) { - if (bindingPattern.kind === 167) { - writePunctuation(writer, 15); - buildDisplayForCommaSeparatedList(bindingPattern.elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); + if (bindingPattern.kind === 168) { writePunctuation(writer, 16); + buildDisplayForCommaSeparatedList(bindingPattern.elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); + writePunctuation(writer, 17); } - else if (bindingPattern.kind === 168) { - writePunctuation(writer, 19); + else if (bindingPattern.kind === 169) { + writePunctuation(writer, 20); var elements = bindingPattern.elements; buildDisplayForCommaSeparatedList(elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); if (elements && elements.hasTrailingComma) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); } - writePunctuation(writer, 20); + writePunctuation(writer, 21); } } function buildBindingElementDisplay(bindingElement, writer, enclosingDeclaration, flags, symbolStack) { if (ts.isOmittedExpression(bindingElement)) { return; } - ts.Debug.assert(bindingElement.kind === 169); + ts.Debug.assert(bindingElement.kind === 170); if (bindingElement.propertyName) { writer.writeSymbol(ts.getTextOfNode(bindingElement.propertyName), bindingElement.symbol); - writePunctuation(writer, 54); + writePunctuation(writer, 55); writeSpace(writer); } if (ts.isBindingPattern(bindingElement.name)) { @@ -21737,75 +21428,75 @@ var ts; } else { if (bindingElement.dotDotDotToken) { - writePunctuation(writer, 22); + writePunctuation(writer, 23); } appendSymbolNameOnly(bindingElement.symbol, writer); } } function buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, flags, symbolStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 25); + writePunctuation(writer, 26); buildDisplayForCommaSeparatedList(typeParameters, writer, function (p) { return buildTypeParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack); }); - writePunctuation(writer, 27); + writePunctuation(writer, 28); } } function buildDisplayForCommaSeparatedList(list, writer, action) { for (var i = 0; i < list.length; i++) { if (i > 0) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); writeSpace(writer); } action(list[i]); } } - function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration, flags, symbolStack) { + function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 25); - var flags_1 = 256; + writePunctuation(writer, 26); + var flags = 256; for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); writeSpace(writer); - flags_1 = 0; + flags = 0; } - buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, flags_1); + buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, flags); } - writePunctuation(writer, 27); + writePunctuation(writer, 28); } } function buildDisplayForParametersAndDelimiters(thisParameter, parameters, writer, enclosingDeclaration, flags, symbolStack) { - writePunctuation(writer, 17); + writePunctuation(writer, 18); if (thisParameter) { buildParameterDisplay(thisParameter, writer, enclosingDeclaration, flags, symbolStack); } for (var i = 0; i < parameters.length; i++) { if (i > 0 || thisParameter) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); writeSpace(writer); } buildParameterDisplay(parameters[i], writer, enclosingDeclaration, flags, symbolStack); } - writePunctuation(writer, 18); + writePunctuation(writer, 19); } function buildTypePredicateDisplay(predicate, writer, enclosingDeclaration, flags, symbolStack) { if (ts.isIdentifierTypePredicate(predicate)) { writer.writeParameter(predicate.parameterName); } else { - writeKeyword(writer, 97); + writeKeyword(writer, 98); } writeSpace(writer); - writeKeyword(writer, 124); + writeKeyword(writer, 125); writeSpace(writer); buildTypeDisplay(predicate.type, writer, enclosingDeclaration, flags, symbolStack); } function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { if (flags & 8) { writeSpace(writer); - writePunctuation(writer, 34); + writePunctuation(writer, 35); } else { - writePunctuation(writer, 54); + writePunctuation(writer, 55); } writeSpace(writer); if (signature.typePredicate) { @@ -21818,7 +21509,7 @@ var ts; } function buildSignatureDisplay(signature, writer, enclosingDeclaration, flags, kind, symbolStack) { if (kind === 1) { - writeKeyword(writer, 92); + writeKeyword(writer, 93); writeSpace(writer); } if (signature.target && (flags & 32)) { @@ -21854,64 +21545,64 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 169: + case 170: return isDeclarationVisible(node.parent.parent); - case 218: + case 219: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 225: - case 221: + case 226: case 222: case 223: - case 220: case 224: - case 229: + case 221: + case 225: + case 230: if (ts.isExternalModuleAugmentation(node)) { return true; } var parent_10 = getDeclarationContainer(node); if (!(ts.getCombinedModifierFlags(node) & 1) && - !(node.kind !== 229 && parent_10.kind !== 256 && ts.isInAmbientContext(parent_10))) { + !(node.kind !== 230 && parent_10.kind !== 256 && ts.isInAmbientContext(parent_10))) { return isGlobalSourceFile(parent_10); } return isDeclarationVisible(parent_10); - case 145: - case 144: - case 149: - case 150: - case 147: case 146: + case 145: + case 150: + case 151: + case 148: + case 147: if (ts.getModifierFlags(node) & (8 | 16)) { return false; } - case 148: - case 152: - case 151: + case 149: case 153: - case 142: - case 226: - case 156: + case 152: + case 154: + case 143: + case 227: case 157: - case 159: - case 155: + case 158: case 160: + case 156: case 161: case 162: case 163: case 164: + case 165: return isDeclarationVisible(node.parent); - case 231: case 232: - case 234: - return false; - case 141: - case 256: - case 228: - return true; + case 233: case 235: return false; + case 142: + case 256: + case 229: + return true; + case 236: + return false; default: return false; } @@ -21919,10 +21610,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 235) { + if (node.parent && node.parent.kind === 236) { exportSymbol = resolveName(node.parent, node.text, 107455 | 793064 | 1920 | 8388608, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 238) { + else if (node.parent.kind === 239) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -22001,12 +21692,12 @@ var ts; node = ts.getRootDeclaration(node); while (node) { switch (node.kind) { - case 218: case 219: + case 220: + case 235: case 234: case 233: case 232: - case 231: node = node.parent; break; default: @@ -22034,12 +21725,12 @@ var ts; } function getTextOfPropertyName(name) { switch (name.kind) { - case 69: + case 70: return name.text; case 9: case 8: return name.text; - case 140: + case 141: if (ts.isStringOrNumericLiteral(name.expression.kind)) { return name.expression.text; } @@ -22047,7 +21738,7 @@ var ts; return undefined; } function isComputedNonLiteralName(name) { - return name.kind === 140 && !ts.isStringOrNumericLiteral(name.expression.kind); + return name.kind === 141 && !ts.isStringOrNumericLiteral(name.expression.kind); } function getTypeForBindingElement(declaration) { var pattern = declaration.parent; @@ -22062,20 +21753,20 @@ var ts; return parentType; } var type; - if (pattern.kind === 167) { - var name_17 = declaration.propertyName || declaration.name; - if (isComputedNonLiteralName(name_17)) { + if (pattern.kind === 168) { + var name_14 = declaration.propertyName || declaration.name; + if (isComputedNonLiteralName(name_14)) { return anyType; } if (declaration.initializer) { getContextualType(declaration.initializer); } - var text = getTextOfPropertyName(name_17); + var text = getTextOfPropertyName(name_14); type = getTypeOfPropertyOfType(parentType, text) || isNumericLiteralName(text) && getIndexTypeOfType(parentType, 1) || getIndexTypeOfType(parentType, 0); if (!type) { - error(name_17, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_17)); + error(name_14, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_14)); return unknownType; } } @@ -22118,15 +21809,15 @@ var ts; if (typeTag && typeTag.typeExpression) { return typeTag.typeExpression.type; } - if (declaration.kind === 218 && - declaration.parent.kind === 219 && - declaration.parent.parent.kind === 200) { + if (declaration.kind === 219 && + declaration.parent.kind === 220 && + declaration.parent.parent.kind === 201) { var annotation = ts.getJSDocTypeTag(declaration.parent.parent); if (annotation && annotation.typeExpression) { return annotation.typeExpression.type; } } - else if (declaration.kind === 142) { + else if (declaration.kind === 143) { var paramTag = ts.getCorrespondingJSDocParameterTag(declaration); if (paramTag && paramTag.typeExpression) { return paramTag.typeExpression.type; @@ -22134,9 +21825,13 @@ var ts; } return undefined; } - function isAutoVariableInitializer(initializer) { - var expr = initializer && ts.skipParentheses(initializer); - return !expr || expr.kind === 93 || expr.kind === 69 && getResolvedSymbol(expr) === undefinedSymbol; + function isNullOrUndefined(node) { + var expr = ts.skipParentheses(node); + return expr.kind === 94 || expr.kind === 70 && getResolvedSymbol(expr) === undefinedSymbol; + } + function isEmptyArrayLiteral(node) { + var expr = ts.skipParentheses(node); + return expr.kind === 171 && expr.elements.length === 0; } function addOptionality(type, optional) { return strictNullChecks && optional ? includeFalsyTypes(type, 2048) : type; @@ -22148,10 +21843,10 @@ var ts; return type; } } - if (declaration.parent.parent.kind === 207) { + if (declaration.parent.parent.kind === 208) { return stringType; } - if (declaration.parent.parent.kind === 208) { + if (declaration.parent.parent.kind === 209) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -22160,15 +21855,19 @@ var ts; if (declaration.type) { return addOptionality(getTypeFromTypeNode(declaration.type), declaration.questionToken && includeOptionality); } - if (declaration.kind === 218 && !ts.isBindingPattern(declaration.name) && - !(ts.getCombinedNodeFlags(declaration) & 2) && !(ts.getCombinedModifierFlags(declaration) & 1) && - !ts.isInAmbientContext(declaration) && isAutoVariableInitializer(declaration.initializer)) { - return autoType; + if (declaration.kind === 219 && !ts.isBindingPattern(declaration.name) && + !(ts.getCombinedModifierFlags(declaration) & 1) && !ts.isInAmbientContext(declaration)) { + if (!(ts.getCombinedNodeFlags(declaration) & 2) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { + return autoType; + } + if (declaration.initializer && isEmptyArrayLiteral(declaration.initializer)) { + return autoArrayType; + } } - if (declaration.kind === 142) { + if (declaration.kind === 143) { var func = declaration.parent; - if (func.kind === 150 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 149); + if (func.kind === 151 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 150); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -22181,8 +21880,7 @@ var ts; } var type = void 0; if (declaration.symbol.name === "this") { - var thisParameter = getContextualThisParameter(func); - type = thisParameter ? getTypeOfSymbol(thisParameter) : undefined; + type = getContextualThisParameterType(func); } else { type = getContextuallyTypedParameterType(declaration); @@ -22255,7 +21953,7 @@ var ts; return result; } function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { - return pattern.kind === 167 + return pattern.kind === 168 ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -22280,7 +21978,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 142 ? root.parent : root; + var memberDeclaration = root.kind === 143 ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function getTypeOfVariableOrParameterOrProperty(symbol) { @@ -22293,7 +21991,7 @@ var ts; if (declaration.parent.kind === 252) { return links.type = anyType; } - if (declaration.kind === 235) { + if (declaration.kind === 236) { return links.type = checkExpression(declaration.expression); } if (declaration.flags & 1048576 && declaration.kind === 280 && declaration.typeExpression) { @@ -22303,15 +22001,15 @@ var ts; return unknownType; } var type = void 0; - if (declaration.kind === 187 || - declaration.kind === 172 && declaration.parent.kind === 187) { + if (declaration.kind === 188 || + declaration.kind === 173 && declaration.parent.kind === 188) { if (declaration.flags & 1048576) { var typeTag = ts.getJSDocTypeTag(declaration.parent); if (typeTag && typeTag.typeExpression) { return links.type = getTypeFromTypeNode(typeTag.typeExpression.type); } } - var declaredTypes = ts.map(symbol.declarations, function (decl) { return decl.kind === 187 ? + var declaredTypes = ts.map(symbol.declarations, function (decl) { return decl.kind === 188 ? checkExpressionCached(decl.right) : checkExpressionCached(decl.parent.right); }); type = getUnionType(declaredTypes, true); @@ -22337,7 +22035,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 149) { + if (accessor.kind === 150) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -22357,8 +22055,8 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - var getter = ts.getDeclarationOfKind(symbol, 149); - var setter = ts.getDeclarationOfKind(symbol, 150); + var getter = ts.getDeclarationOfKind(symbol, 150); + var setter = ts.getDeclarationOfKind(symbol, 151); if (getter && getter.flags & 1048576) { var jsDocType = getTypeForVariableLikeDeclarationFromJSDocComment(getter); if (jsDocType) { @@ -22399,7 +22097,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 149); + var getter_1 = ts.getDeclarationOfKind(symbol, 150); 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)); } } @@ -22410,7 +22108,7 @@ var ts; function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (symbol.valueDeclaration.kind === 225 && ts.isShorthandAmbientModuleSymbol(symbol)) { + if (symbol.valueDeclaration.kind === 226 && ts.isShorthandAmbientModuleSymbol(symbol)) { links.type = anyType; } else { @@ -22495,9 +22193,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 221 || node.kind === 192 || - node.kind === 220 || node.kind === 179 || - node.kind === 147 || node.kind === 180) { + if (node.kind === 222 || node.kind === 193 || + node.kind === 221 || node.kind === 180 || + node.kind === 148 || node.kind === 181) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -22506,15 +22204,15 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 222); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 223); 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 === 222 || node.kind === 221 || - node.kind === 192 || node.kind === 223) { + if (node.kind === 223 || node.kind === 222 || + node.kind === 193 || node.kind === 224) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -22640,7 +22338,7 @@ var ts; type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 222 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 223 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -22669,7 +22367,7 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 222) { + if (declaration.kind === 223) { if (declaration.flags & 64) { return false; } @@ -22731,7 +22429,7 @@ var ts; } } else { - declaration = ts.getDeclarationOfKind(symbol, 223); + declaration = ts.getDeclarationOfKind(symbol, 224); type = getTypeFromTypeNode(declaration.type, symbol, typeParameters); } if (popTypeResolution()) { @@ -22755,14 +22453,14 @@ var ts; return !ts.isInAmbientContext(member); } return expr.kind === 8 || - expr.kind === 185 && expr.operator === 36 && + expr.kind === 186 && expr.operator === 37 && expr.operand.kind === 8 || - expr.kind === 69 && !!symbol.exports[expr.text]; + expr.kind === 70 && !!symbol.exports[expr.text]; } function enumHasLiteralMembers(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 224) { + if (declaration.kind === 225) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (!isLiteralEnumMember(symbol, member)) { @@ -22790,7 +22488,7 @@ var ts; var memberTypes = ts.createMap(); for (var _i = 0, _a = enumType.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 224) { + if (declaration.kind === 225) { computeEnumMemberValues(declaration); for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; @@ -22828,7 +22526,7 @@ var ts; if (!links.declaredType) { var type = createType(16384); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 141).constraint) { + if (!ts.getDeclarationOfKind(symbol, 142).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -22877,20 +22575,20 @@ var ts; } function isIndependentType(node) { switch (node.kind) { - case 117: - case 132: - case 130: - case 120: + case 118: case 133: - case 103: - case 135: - case 93: - case 127: - case 166: + case 131: + case 121: + case 134: + case 104: + case 136: + case 94: + case 128: + case 167: return true; - case 160: + case 161: return isIndependentType(node.elementType); - case 155: + case 156: return isIndependentTypeReference(node); } return false; @@ -22899,7 +22597,7 @@ var ts; return node.type && isIndependentType(node.type) || !node.type && !node.initializer; } function isIndependentFunctionLikeDeclaration(node) { - if (node.kind !== 148 && (!node.type || !isIndependentType(node.type))) { + if (node.kind !== 149 && (!node.type || !isIndependentType(node.type))) { return false; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { @@ -22915,12 +22613,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 145: - case 144: - return isIndependentVariableLikeDeclaration(declaration); - case 147: case 146: + case 145: + return isIndependentVariableLikeDeclaration(declaration); case 148: + case 147: + case 149: return isIndependentFunctionLikeDeclaration(declaration); } } @@ -23486,7 +23184,7 @@ var ts; return false; } function createTypePredicateFromTypePredicateNode(node) { - if (node.parameterName.kind === 69) { + if (node.parameterName.kind === 70) { var parameterName = node.parameterName; return { kind: 1, @@ -23525,7 +23223,7 @@ var ts; else { parameters.push(paramSymbol); } - if (param.type && param.type.kind === 166) { + if (param.type && param.type.kind === 167) { hasLiteralTypes = true; } if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) { @@ -23537,10 +23235,10 @@ var ts; minArgumentCount = -1; } } - if ((declaration.kind === 149 || declaration.kind === 150) && + if ((declaration.kind === 150 || declaration.kind === 151) && !ts.hasDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 149 ? 150 : 149; + var otherKind = declaration.kind === 150 ? 151 : 150; var other = ts.getDeclarationOfKind(declaration.symbol, otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); @@ -23552,24 +23250,21 @@ var ts; if (isJSConstructSignature) { minArgumentCount--; } - if (!thisParameter && ts.isObjectLiteralMethod(declaration)) { - thisParameter = getContextualThisParameter(declaration); - } - var classType = declaration.kind === 148 ? + var classType = declaration.kind === 149 ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : getTypeParametersFromJSDocTemplate(declaration); - var returnType = getSignatureReturnTypeFromDeclaration(declaration, minArgumentCount, isJSConstructSignature, classType); - var typePredicate = declaration.type && declaration.type.kind === 154 ? + var returnType = getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType); + var typePredicate = declaration.type && declaration.type.kind === 155 ? createTypePredicateFromTypePredicateNode(declaration.type) : undefined; links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasLiteralTypes); } return links.resolvedSignature; } - function getSignatureReturnTypeFromDeclaration(declaration, minArgumentCount, isJSConstructSignature, classType) { + function getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType) { if (isJSConstructSignature) { return getTypeFromTypeNode(declaration.parameters[0].type); } @@ -23585,8 +23280,8 @@ var ts; return type; } } - if (declaration.kind === 149 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 150); + if (declaration.kind === 150 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 151); return getAnnotatedAccessorType(setter); } if (ts.nodeIsMissing(declaration.body)) { @@ -23600,19 +23295,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 156: case 157: - case 220: - case 147: - case 146: + case 158: + case 221: case 148: - case 151: + case 147: + case 149: case 152: case 153: - case 149: + case 154: case 150: - case 179: + case 151: case 180: + case 181: case 269: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; @@ -23693,7 +23388,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 148 || signature.declaration.kind === 152; + var isConstructor = signature.declaration.kind === 149 || signature.declaration.kind === 153; var type = createObjectType(2097152); type.members = emptySymbols; type.properties = emptyArray; @@ -23707,7 +23402,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 130 : 132; + var syntaxKind = kind === 1 ? 131 : 133; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -23734,7 +23429,7 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - return ts.getDeclarationOfKind(type.symbol, 141).constraint; + return ts.getDeclarationOfKind(type.symbol, 142).constraint; } function hasConstraintReferenceTo(type, target) { var checked; @@ -23767,7 +23462,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 141).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 142).parent); } function getTypeListId(types) { var result = ""; @@ -23867,11 +23562,11 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 155: + case 156: return node.typeName; case 267: return node.name; - case 194: + case 195: var expr = node.expression; if (ts.isEntityNameExpression(expr)) { return expr; @@ -23879,7 +23574,7 @@ var ts; } return undefined; } - function resolveTypeReferenceName(node, typeReferenceName) { + function resolveTypeReferenceName(typeReferenceName) { if (!typeReferenceName) { return unknownSymbol; } @@ -23907,11 +23602,11 @@ var ts; var type = void 0; if (node.kind === 267) { var typeReferenceName = getTypeReferenceName(node); - symbol = resolveTypeReferenceName(node, typeReferenceName); + symbol = resolveTypeReferenceName(typeReferenceName); type = getTypeReferenceType(node, symbol); } else { - var typeNameOrExpression = node.kind === 155 + var typeNameOrExpression = node.kind === 156 ? node.typeName : ts.isEntityNameExpression(node.expression) ? node.expression @@ -23940,9 +23635,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 221: case 222: - case 224: + case 223: + case 225: return declaration; } } @@ -24317,9 +24012,9 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 222)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 223)) { if (!(ts.getModifierFlags(container) & 32) && - (container.kind !== 148 || ts.isNodeDescendantOf(node, container.body))) { + (container.kind !== 149 || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -24338,25 +24033,25 @@ var ts; } function getTypeFromTypeNode(node, aliasSymbol, aliasTypeArguments) { switch (node.kind) { - case 117: + case 118: case 258: case 259: return anyType; - case 132: - return stringType; - case 130: - return numberType; - case 120: - return booleanType; case 133: + return stringType; + case 131: + return numberType; + case 121: + return booleanType; + case 134: return esSymbolType; - case 103: + case 104: return voidType; - case 135: + case 136: return undefinedType; - case 93: + case 94: return nullType; - case 127: + case 128: return neverType; case 283: return nullType; @@ -24364,33 +24059,33 @@ var ts; return undefinedType; case 285: return neverType; - case 165: - case 97: - return getTypeFromThisTypeNode(node); case 166: + case 98: + return getTypeFromThisTypeNode(node); + case 167: return getTypeFromLiteralTypeNode(node); case 282: return getTypeFromLiteralTypeNode(node.literal); - case 155: + case 156: case 267: return getTypeFromTypeReference(node); - case 154: + case 155: return booleanType; - case 194: + case 195: return getTypeFromTypeReference(node); - case 158: + case 159: return getTypeFromTypeQueryNode(node); - case 160: + case 161: case 260: return getTypeFromArrayTypeNode(node); - case 161: - return getTypeFromTupleTypeNode(node); case 162: + return getTypeFromTupleTypeNode(node); + case 163: case 261: return getTypeFromUnionTypeNode(node, aliasSymbol, aliasTypeArguments); - case 163: - return getTypeFromIntersectionTypeNode(node, aliasSymbol, aliasTypeArguments); case 164: + return getTypeFromIntersectionTypeNode(node, aliasSymbol, aliasTypeArguments); + case 165: case 263: case 264: case 271: @@ -24399,14 +24094,14 @@ var ts; return getTypeFromTypeNode(node.type); case 265: return getTypeFromTypeNode(node.literal); - case 156: case 157: - case 159: + case 158: + case 160: case 281: case 269: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node, aliasSymbol, aliasTypeArguments); - case 69: - case 139: + case 70: + case 140: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); case 262: @@ -24562,23 +24257,23 @@ var ts; var node = symbol.declarations[0].parent; while (node) { switch (node.kind) { - case 156: case 157: - case 220: - case 147: - case 146: + case 158: + case 221: case 148: - case 151: + case 147: + case 149: case 152: case 153: - case 149: + case 154: case 150: - case 179: + case 151: case 180: - case 221: - case 192: + case 181: case 222: + case 193: case 223: + case 224: var declaration = node; if (declaration.typeParameters) { for (var _i = 0, _a = declaration.typeParameters; _i < _a.length; _i++) { @@ -24588,14 +24283,14 @@ var ts; } } } - if (ts.isClassLike(node) || node.kind === 222) { + if (ts.isClassLike(node) || node.kind === 223) { var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; if (thisType && ts.contains(mappedTypes, thisType)) { return true; } } break; - case 225: + case 226: case 256: return false; } @@ -24630,35 +24325,43 @@ var ts; return info && createIndexInfo(instantiateType(info.type, mapper), info.isReadonly, info.declaration); } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 147 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 148 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 179: case 180: + case 181: return isContextSensitiveFunctionLikeDeclaration(node); - case 171: + case 172: return ts.forEach(node.properties, isContextSensitive); - case 170: + case 171: return ts.forEach(node.elements, isContextSensitive); - case 188: + case 189: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 187: - return node.operatorToken.kind === 52 && + case 188: + return node.operatorToken.kind === 53 && (isContextSensitive(node.left) || isContextSensitive(node.right)); case 253: return isContextSensitive(node.initializer); + case 148: case 147: - case 146: return isContextSensitiveFunctionLikeDeclaration(node); - case 178: + case 179: return isContextSensitive(node.expression); } return false; } function isContextSensitiveFunctionLikeDeclaration(node) { - var areAllParametersUntyped = !ts.forEach(node.parameters, function (p) { return p.type; }); - var isNullaryArrow = node.kind === 180 && !node.parameters.length; - return !node.typeParameters && areAllParametersUntyped && !isNullaryArrow; + if (node.typeParameters) { + return false; + } + if (ts.forEach(node.parameters, function (p) { return !p.type; })) { + return true; + } + if (node.kind === 181) { + return false; + } + var parameter = ts.firstOrUndefined(node.parameters); + return !(parameter && ts.parameterIsThisKeyword(parameter)); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func); @@ -25078,8 +24781,8 @@ var ts; } if (source.flags & 524288 && target.flags & 524288 || source.flags & 1048576 && target.flags & 1048576) { - if (result = eachTypeRelatedToSomeType(source, target, false)) { - if (result &= eachTypeRelatedToSomeType(target, source, false)) { + if (result = eachTypeRelatedToSomeType(source, target)) { + if (result &= eachTypeRelatedToSomeType(target, source)) { return result; } } @@ -25130,7 +24833,7 @@ var ts; } return false; } - function eachTypeRelatedToSomeType(source, target, reportErrors) { + function eachTypeRelatedToSomeType(source, target) { var result = -1; var sourceTypes = source.types; for (var _i = 0, sourceTypes_1 = sourceTypes; _i < sourceTypes_1.length; _i++) { @@ -25727,7 +25430,7 @@ var ts; type.flags & 64 ? numberType : type.flags & 128 ? booleanType : type.flags & 256 ? type.baseType : - type.flags & 524288 && !(type.flags & 16) ? getUnionType(ts.map(type.types, getBaseTypeOfLiteralType)) : + type.flags & 524288 && !(type.flags & 16) ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) : type; } function getWidenedLiteralType(type) { @@ -25735,7 +25438,7 @@ var ts; type.flags & 64 && type.flags & 16777216 ? numberType : type.flags & 128 ? booleanType : type.flags & 256 ? type.baseType : - type.flags & 524288 && !(type.flags & 16) ? getUnionType(ts.map(type.types, getWidenedLiteralType)) : + type.flags & 524288 && !(type.flags & 16) ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) : type; } function isTupleType(type) { @@ -25846,10 +25549,10 @@ var ts; return getWidenedTypeOfObjectLiteral(type); } if (type.flags & 524288) { - return getUnionType(ts.map(type.types, getWidenedConstituentType)); + return getUnionType(ts.sameMap(type.types, getWidenedConstituentType)); } if (isArrayType(type) || isTupleType(type)) { - return createTypeReference(type.target, ts.map(type.typeArguments, getWidenedType)); + return createTypeReference(type.target, ts.sameMap(type.typeArguments, getWidenedType)); } } return type; @@ -25890,25 +25593,25 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { + case 146: case 145: - case 144: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 142: + case 143: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 169: + case 170: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 220: + case 221: + case 148: case 147: - case 146: - case 149: case 150: - case 179: + case 151: case 180: + case 181: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -25953,7 +25656,7 @@ var ts; signature: signature, inferUnionTypes: inferUnionTypes, inferences: inferences, - inferredTypes: new Array(signature.typeParameters.length) + inferredTypes: new Array(signature.typeParameters.length), }; } function createTypeInferencesObject() { @@ -25961,7 +25664,7 @@ var ts; primary: undefined, secondary: undefined, topLevel: true, - isFixed: false + isFixed: false, }; } function couldContainTypeParameters(type) { @@ -26202,7 +25905,7 @@ var ts; var widenLiteralTypes = context.inferences[index].topLevel && !hasPrimitiveConstraint(signature.typeParameters[index]) && (context.inferences[index].isFixed || !isTypeParameterAtTopLevel(getReturnTypeOfSignature(signature), signature.typeParameters[index])); - var baseInferences = widenLiteralTypes ? ts.map(inferences, getWidenedLiteralType) : inferences; + var baseInferences = widenLiteralTypes ? ts.sameMap(inferences, getWidenedLiteralType) : inferences; var unionOrSuperType = context.inferUnionTypes ? getUnionType(baseInferences, true) : getCommonSupertype(baseInferences); inferredType = unionOrSuperType ? getWidenedType(unionOrSuperType) : unknownType; inferenceSucceeded = !!unionOrSuperType; @@ -26243,10 +25946,10 @@ var ts; function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 158: + case 159: return true; - case 69: - case 139: + case 70: + case 140: node = node.parent; continue; default: @@ -26256,14 +25959,14 @@ var ts; ts.Debug.fail("should not get here"); } function getFlowCacheKey(node) { - if (node.kind === 69) { + if (node.kind === 70) { var symbol = getResolvedSymbol(node); return symbol !== unknownSymbol ? "" + getSymbolId(symbol) : undefined; } - if (node.kind === 97) { + if (node.kind === 98) { return "0"; } - if (node.kind === 172) { + if (node.kind === 173) { var key = getFlowCacheKey(node.expression); return key && key + "." + node.name.text; } @@ -26271,31 +25974,31 @@ var ts; } function getLeftmostIdentifierOrThis(node) { switch (node.kind) { - case 69: - case 97: + case 70: + case 98: return node; - case 172: + case 173: return getLeftmostIdentifierOrThis(node.expression); } return undefined; } function isMatchingReference(source, target) { switch (source.kind) { - case 69: - return target.kind === 69 && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 218 || target.kind === 169) && + case 70: + return target.kind === 70 && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 219 || target.kind === 170) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 97: - return target.kind === 97; - case 172: - return target.kind === 172 && + case 98: + return target.kind === 98; + case 173: + return target.kind === 173 && source.name.text === target.name.text && isMatchingReference(source.expression, target.expression); } return false; } function containsMatchingReference(source, target) { - while (source.kind === 172) { + while (source.kind === 173) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -26304,15 +26007,15 @@ var ts; return false; } function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 172 && + return target.kind === 173 && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.text); } function getDeclaredTypeOfReference(expr) { - if (expr.kind === 69) { + if (expr.kind === 70) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 172) { + if (expr.kind === 173) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.text); } @@ -26342,7 +26045,7 @@ var ts; } } } - if (callExpression.expression.kind === 172 && + if (callExpression.expression.kind === 173 && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -26468,7 +26171,7 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, undefined, false) || unknownType); } function getAssignedTypeOfBinaryExpression(node) { - return node.parent.kind === 170 || node.parent.kind === 253 ? + return node.parent.kind === 171 || node.parent.kind === 253 ? getTypeWithDefault(getAssignedType(node), node.right) : checkExpression(node.right); } @@ -26487,17 +26190,17 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 207: - return stringType; case 208: + return stringType; + case 209: return checkRightHandSideOfForOf(parent.expression) || unknownType; - case 187: + case 188: return getAssignedTypeOfBinaryExpression(parent); - case 181: + case 182: return undefinedType; - case 170: + case 171: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 191: + case 192: return getAssignedTypeOfSpreadElement(parent); case 253: return getAssignedTypeOfPropertyAssignment(parent); @@ -26509,7 +26212,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 167 ? + var type = pattern.kind === 168 ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, ts.indexOf(pattern.elements, node)) : @@ -26524,38 +26227,51 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 207) { + if (node.parent.parent.kind === 208) { return stringType; } - if (node.parent.parent.kind === 208) { + if (node.parent.parent.kind === 209) { return checkRightHandSideOfForOf(node.parent.parent.expression) || unknownType; } return unknownType; } function getInitialType(node) { - return node.kind === 218 ? + return node.kind === 219 ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 218 || node.kind === 169 ? + return node.kind === 219 || node.kind === 170 ? getInitialType(node) : getAssignedType(node); } + function isEmptyArrayAssignment(node) { + return node.kind === 219 && node.initializer && + isEmptyArrayLiteral(node.initializer) || + node.kind !== 170 && node.parent.kind === 188 && + isEmptyArrayLiteral(node.parent.right); + } function getReferenceCandidate(node) { switch (node.kind) { - case 178: + case 179: return getReferenceCandidate(node.expression); - case 187: + case 188: switch (node.operatorToken.kind) { - case 56: + case 57: return getReferenceCandidate(node.left); - case 24: + case 25: return getReferenceCandidate(node.right); } } return node; } + function getReferenceRoot(node) { + var parent = node.parent; + return parent.kind === 179 || + parent.kind === 188 && parent.operatorToken.kind === 57 && parent.left === node || + parent.kind === 188 && parent.operatorToken.kind === 25 && parent.right === node ? + getReferenceRoot(parent) : node; + } function getTypeOfSwitchClause(clause) { if (clause.kind === 249) { var caseType = getRegularTypeOfLiteralType(checkExpression(clause.expression)); @@ -26626,24 +26342,88 @@ var ts; function createFlowType(type, incomplete) { return incomplete ? { flags: 0, type: type } : type; } + function createEvolvingArrayType(elementType) { + var result = createObjectType(2097152); + result.elementType = elementType; + return result; + } + function getEvolvingArrayType(elementType) { + return evolvingArrayTypes[elementType.id] || (evolvingArrayTypes[elementType.id] = createEvolvingArrayType(elementType)); + } + function addEvolvingArrayElementType(evolvingArrayType, node) { + var elementType = getBaseTypeOfLiteralType(checkExpression(node)); + return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType])); + } + function isEvolvingArrayType(type) { + return !!(type.flags & 2097152 && type.elementType); + } + function createFinalArrayType(elementType) { + return elementType.flags & 8192 ? + autoArrayType : + createArrayType(elementType.flags & 524288 ? + getUnionType(elementType.types, true) : + elementType); + } + function getFinalArrayType(evolvingArrayType) { + return evolvingArrayType.finalArrayType || (evolvingArrayType.finalArrayType = createFinalArrayType(evolvingArrayType.elementType)); + } + function finalizeEvolvingArrayType(type) { + return isEvolvingArrayType(type) ? getFinalArrayType(type) : type; + } + function getElementTypeOfEvolvingArrayType(type) { + return isEvolvingArrayType(type) ? type.elementType : neverType; + } + function isEvolvingArrayTypeList(types) { + var hasEvolvingArrayType = false; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; + if (!(t.flags & 8192)) { + if (!isEvolvingArrayType(t)) { + return false; + } + hasEvolvingArrayType = true; + } + } + return hasEvolvingArrayType; + } + function getUnionOrEvolvingArrayType(types, subtypeReduction) { + return isEvolvingArrayTypeList(types) ? + getEvolvingArrayType(getUnionType(ts.map(types, getElementTypeOfEvolvingArrayType))) : + getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction); + } + function isEvolvingArrayOperationTarget(node) { + var root = getReferenceRoot(node); + var parent = root.parent; + var isLengthPushOrUnshift = parent.kind === 173 && (parent.name.text === "length" || + parent.parent.kind === 175 && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 174 && + parent.expression === root && + parent.parent.kind === 188 && + parent.parent.operatorToken.kind === 57 && + parent.parent.left === parent && + !ts.isAssignmentTarget(parent.parent) && + isTypeAnyOrAllConstituentTypesHaveKind(checkExpression(parent.argumentExpression), 340 | 2048); + return isLengthPushOrUnshift || isElementAssignment; + } function getFlowTypeOfReference(reference, declaredType, assumeInitialized, flowContainer) { var key; if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 4178943)) { return declaredType; } var initialType = assumeInitialized ? declaredType : - declaredType === autoType ? undefinedType : + declaredType === autoType || declaredType === autoArrayType ? undefinedType : includeFalsyTypes(declaredType, 2048); var visitedFlowStart = visitedFlowCount; - var result = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); + var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); visitedFlowCount = visitedFlowStart; - if (reference.parent.kind === 196 && getTypeWithFacts(result, 524288).flags & 8192) { + var resultType = isEvolvingArrayType(evolvedType) && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); + if (reference.parent.kind === 197 && getTypeWithFacts(resultType, 524288).flags & 8192) { return declaredType; } - return result; + return resultType; function getTypeAtFlowNode(flow) { while (true) { - if (flow.flags & 512) { + if (flow.flags & 1024) { for (var i = visitedFlowStart; i < visitedFlowCount; i++) { if (visitedFlowNodes[i] === flow) { return visitedFlowTypes[i]; @@ -26673,18 +26453,25 @@ var ts; getTypeAtFlowBranchLabel(flow) : getTypeAtFlowLoopLabel(flow); } + else if (flow.flags & 256) { + type = getTypeAtFlowArrayMutation(flow); + if (!type) { + flow = flow.antecedent; + continue; + } + } else if (flow.flags & 2) { var container = flow.container; - if (container && container !== flowContainer && reference.kind !== 172) { + if (container && container !== flowContainer && reference.kind !== 173) { flow = container.flowNode; continue; } type = initialType; } else { - type = declaredType; + type = convertAutoToAny(declaredType); } - if (flow.flags & 512) { + if (flow.flags & 1024) { visitedFlowNodes[visitedFlowCount] = flow; visitedFlowTypes[visitedFlowCount] = type; visitedFlowCount++; @@ -26695,30 +26482,70 @@ var ts; function getTypeAtFlowAssignment(flow) { var node = flow.node; if (isMatchingReference(reference, node)) { - if (node.parent.kind === 185 || node.parent.kind === 186) { + if (node.parent.kind === 186 || node.parent.kind === 187) { var flowType = getTypeAtFlowNode(flow.antecedent); return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType)); } - return declaredType === autoType ? getBaseTypeOfLiteralType(getInitialOrAssignedType(node)) : - declaredType.flags & 524288 ? getAssignmentReducedType(declaredType, getInitialOrAssignedType(node)) : - declaredType; + if (declaredType === autoType || declaredType === autoArrayType) { + if (isEmptyArrayAssignment(node)) { + return getEvolvingArrayType(neverType); + } + var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(node)); + return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; + } + if (declaredType.flags & 524288) { + return getAssignmentReducedType(declaredType, getInitialOrAssignedType(node)); + } + return declaredType; } if (containsMatchingReference(reference, node)) { return declaredType; } return undefined; } + function getTypeAtFlowArrayMutation(flow) { + var node = flow.node; + var expr = node.kind === 175 ? + node.expression.expression : + node.left.expression; + if (isMatchingReference(reference, getReferenceCandidate(expr))) { + var flowType = getTypeAtFlowNode(flow.antecedent); + var type = getTypeFromFlowType(flowType); + if (isEvolvingArrayType(type)) { + var evolvedType_1 = type; + if (node.kind === 175) { + for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { + var arg = _a[_i]; + evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); + } + } + else { + var indexType = checkExpression(node.left.argumentExpression); + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 340 | 2048)) { + evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); + } + } + return evolvedType_1 === type ? flowType : createFlowType(evolvedType_1, isIncomplete(flowType)); + } + return flowType; + } + return undefined; + } function getTypeAtFlowCondition(flow) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (!(type.flags & 8192)) { - var assumeTrue = (flow.flags & 32) !== 0; - type = narrowType(type, flow.expression, assumeTrue); - if (type.flags & 8192 && isIncomplete(flowType)) { - type = silentNeverType; - } + if (type.flags & 8192) { + return flowType; } - return createFlowType(type, isIncomplete(flowType)); + var assumeTrue = (flow.flags & 32) !== 0; + var nonEvolvingType = finalizeEvolvingArrayType(type); + var narrowedType = narrowType(nonEvolvingType, flow.expression, assumeTrue); + if (narrowedType === nonEvolvingType) { + return flowType; + } + var incomplete = isIncomplete(flowType); + var resultType = incomplete && narrowedType.flags & 8192 ? silentNeverType : narrowedType; + return createFlowType(resultType, incomplete); } function getTypeAtSwitchClause(flow) { var flowType = getTypeAtFlowNode(flow.antecedent); @@ -26753,7 +26580,7 @@ var ts; seenIncomplete = true; } } - return createFlowType(getUnionType(antecedentTypes, subtypeReduction), seenIncomplete); + return createFlowType(getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction), seenIncomplete); } function getTypeAtFlowLoopLabel(flow) { var id = getFlowNodeId(flow); @@ -26765,8 +26592,8 @@ var ts; return cache[key]; } for (var i = flowLoopStart; i < flowLoopCount; i++) { - if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key) { - return createFlowType(getUnionType(flowLoopTypes[i]), true); + if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key && flowLoopTypes[i].length) { + return createFlowType(getUnionOrEvolvingArrayType(flowLoopTypes[i], false), true); } } var antecedentTypes = []; @@ -26797,14 +26624,14 @@ var ts; break; } } - var result = getUnionType(antecedentTypes, subtypeReduction); + var result = getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction); if (isIncomplete(firstAntecedentType)) { return createFlowType(result, true); } return cache[key] = result; } function isMatchingReferenceDiscriminant(expr) { - return expr.kind === 172 && + return expr.kind === 173 && declaredType.flags & 524288 && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(declaredType, expr.name.text); @@ -26829,19 +26656,19 @@ var ts; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 56: + case 57: return narrowTypeByTruthiness(type, expr.left, assumeTrue); - case 30: case 31: case 32: case 33: + case 34: var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 182 && right_1.kind === 9) { + if (left_1.kind === 183 && right_1.kind === 9) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 182 && left_1.kind === 9) { + if (right_1.kind === 183 && left_1.kind === 9) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -26860,9 +26687,9 @@ var ts; return declaredType; } break; - case 91: + case 92: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 24: + case 25: return narrowType(type, expr.right, assumeTrue); } return type; @@ -26871,7 +26698,7 @@ var ts; if (type.flags & 1) { return type; } - if (operator === 31 || operator === 33) { + if (operator === 32 || operator === 34) { assumeTrue = !assumeTrue; } var valueType = checkExpression(value); @@ -26879,10 +26706,10 @@ var ts; if (!strictNullChecks) { return type; } - var doubleEquals = operator === 30 || operator === 31; + var doubleEquals = operator === 31 || operator === 32; var facts = doubleEquals ? assumeTrue ? 65536 : 524288 : - value.kind === 93 ? + value.kind === 94 ? assumeTrue ? 32768 : 262144 : assumeTrue ? 16384 : 131072; return getTypeWithFacts(type, facts); @@ -26908,7 +26735,7 @@ var ts; } return type; } - if (operator === 31 || operator === 33) { + if (operator === 32 || operator === 34) { assumeTrue = !assumeTrue; } if (assumeTrue && !(type.flags & 524288)) { @@ -27019,7 +26846,7 @@ var ts; } else { var invokedExpression = skipParenthesizedNodes(callExpression.expression); - if (invokedExpression.kind === 173 || invokedExpression.kind === 172) { + if (invokedExpression.kind === 174 || invokedExpression.kind === 173) { var accessExpression = invokedExpression; var possibleReference = skipParenthesizedNodes(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -27034,18 +26861,18 @@ var ts; } function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 69: - case 97: - case 172: + case 70: + case 98: + case 173: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 174: + case 175: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 178: + case 179: return narrowType(type, expr.expression, assumeTrue); - case 187: + case 188: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 185: - if (expr.operator === 49) { + case 186: + if (expr.operator === 50) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -27054,7 +26881,7 @@ var ts; } } function getTypeOfSymbolAtLocation(symbol, location) { - if (location.kind === 69) { + if (location.kind === 70) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } @@ -27068,7 +26895,7 @@ var ts; return getTypeOfSymbol(symbol); } function skipParenthesizedNodes(expression) { - while (expression.kind === 178) { + while (expression.kind === 179) { expression = expression.expression; } return expression; @@ -27077,9 +26904,9 @@ var ts; while (true) { node = node.parent; if (ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 226 || + node.kind === 227 || node.kind === 256 || - node.kind === 145) { + node.kind === 146) { return node; } } @@ -27107,10 +26934,10 @@ var ts; } } function markParameterAssignments(node) { - if (node.kind === 69) { + if (node.kind === 70) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 142) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 143) { symbol.isAssigned = true; } } @@ -27119,12 +26946,15 @@ var ts; ts.forEachChild(node, markParameterAssignments); } } + function isConstVariable(symbol) { + return symbol.flags & 3 && (getDeclarationNodeFlagsFromSymbol(symbol) & 2) !== 0 && getTypeOfSymbol(symbol) !== autoArrayType; + } function checkIdentifier(node) { var symbol = getResolvedSymbol(node); if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2) { - if (container.kind === 180) { + if (container.kind === 181) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } else if (ts.hasModifier(container, 256)) { @@ -27142,7 +26972,7 @@ var ts; if (localOrExportSymbol.flags & 32) { var declaration_1 = localOrExportSymbol.valueDeclaration; if (languageVersion === 2 - && declaration_1.kind === 221 + && declaration_1.kind === 222 && ts.nodeIsDecorated(declaration_1)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -27154,11 +26984,11 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration_1.kind === 192) { + else if (declaration_1.kind === 193) { var container = ts.getThisContainer(node, false); while (container !== undefined) { if (container.parent === declaration_1) { - if (container.kind === 145 && ts.hasModifier(container, 32)) { + if (container.kind === 146 && ts.hasModifier(container, 32)) { getNodeLinks(declaration_1).flags |= 8388608; getNodeLinks(node).flags |= 16777216; } @@ -27176,28 +27006,26 @@ var ts; if (!(localOrExportSymbol.flags & 3) || ts.isAssignmentTarget(node) || !declaration) { return type; } - var isParameter = ts.getRootDeclaration(declaration).kind === 142; + var isParameter = ts.getRootDeclaration(declaration).kind === 143; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; - while (flowContainer !== declarationContainer && - (flowContainer.kind === 179 || - flowContainer.kind === 180 || - ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && - (isReadonlySymbol(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { + while (flowContainer !== declarationContainer && (flowContainer.kind === 180 || + flowContainer.kind === 181 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } var assumeInitialized = isParameter || isOuterVariable || - type !== autoType && (!strictNullChecks || (type.flags & 1) !== 0) || + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1) !== 0) || ts.isInAmbientContext(declaration); var flowType = getFlowTypeOfReference(node, type, assumeInitialized, flowContainer); - if (type === autoType) { - if (flowType === autoType) { + if (type === autoType || type === autoArrayType) { + if (flowType === autoType || flowType === autoArrayType) { if (compilerOptions.noImplicitAny) { - error(declaration.name, ts.Diagnostics.Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol)); - error(node, ts.Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(anyType)); + error(declaration.name, ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol), typeToString(flowType)); + error(node, ts.Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(flowType)); } - return anyType; + return convertAutoToAny(flowType); } } else if (!assumeInitialized && !(getFalsyFlags(type) & 2048) && getFalsyFlags(flowType) & 2048) { @@ -27237,8 +27065,8 @@ var ts; if (usedInFunction) { getNodeLinks(current).flags |= 65536; } - if (container.kind === 206 && - ts.getAncestor(symbol.valueDeclaration, 219).parent === container && + if (container.kind === 207 && + ts.getAncestor(symbol.valueDeclaration, 220).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152; } @@ -27250,16 +27078,16 @@ var ts; } function isAssignedInBodyOfForStatement(node, container) { var current = node; - while (current.parent.kind === 178) { + while (current.parent.kind === 179) { current = current.parent; } var isAssigned = false; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 185 || current.parent.kind === 186)) { + else if ((current.parent.kind === 186 || current.parent.kind === 187)) { var expr = current.parent; - isAssigned = expr.operator === 41 || expr.operator === 42; + isAssigned = expr.operator === 42 || expr.operator === 43; } if (!isAssigned) { return false; @@ -27276,7 +27104,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2; - if (container.kind === 145 || container.kind === 148) { + if (container.kind === 146 || container.kind === 149) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4; } @@ -27310,7 +27138,7 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 148) { + if (container.kind === 149) { var containingClassDecl = container.parent; var baseTypeNode = ts.getClassExtendsHeritageClauseElement(containingClassDecl); if (baseTypeNode && !classDeclarationExtendsNull(containingClassDecl)) { @@ -27320,29 +27148,29 @@ var ts; } } } - if (container.kind === 180) { + if (container.kind === 181) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 225: + case 226: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 224: + case 225: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 148: + case 149: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; + case 146: case 145: - case 144: if (ts.getModifierFlags(container) & 32) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 140: + case 141: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -27351,7 +27179,7 @@ var ts; } if (ts.isFunctionLike(container) && (!isInParameterInitializerBeforeContainingFunction(node) || ts.getThisParameter(container))) { - if (container.kind === 179 && + if (container.kind === 180 && ts.isInJavaScriptFile(container.parent) && ts.getSpecialPropertyAssignmentKind(container.parent) === 3) { var className = container.parent @@ -27363,7 +27191,7 @@ var ts; return getInferredClassType(classSymbol); } } - var thisType = getThisTypeOfDeclaration(container); + var thisType = getThisTypeOfDeclaration(container) || getContextualThisParameterType(container); if (thisType) { return thisType; } @@ -27395,18 +27223,18 @@ var ts; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 142) { + if (n.kind === 143) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 174 && node.parent.expression === node; + var isCallExpression = node.parent.kind === 175 && node.parent.expression === node; var container = ts.getSuperContainer(node, true); var needToCaptureLexicalThis = false; if (!isCallExpression) { - while (container && container.kind === 180) { + while (container && container.kind === 181) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } @@ -27415,16 +27243,16 @@ var ts; var nodeCheckFlag = 0; if (!canUseSuperExpression) { var current = node; - while (current && current !== container && current.kind !== 140) { + while (current && current !== container && current.kind !== 141) { current = current.parent; } - if (current && current.kind === 140) { + if (current && current.kind === 141) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); } - else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 171)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 172)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -27439,7 +27267,7 @@ var ts; nodeCheckFlag = 256; } getNodeLinks(node).flags |= nodeCheckFlag; - if (container.kind === 147 && ts.getModifierFlags(container) & 256) { + if (container.kind === 148 && ts.getModifierFlags(container) & 256) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096; } @@ -27450,7 +27278,7 @@ var ts; if (needToCaptureLexicalThis) { captureLexicalThis(node.parent, container); } - if (container.parent.kind === 171) { + if (container.parent.kind === 172) { if (languageVersion < 2) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return unknownType; @@ -27468,7 +27296,7 @@ var ts; } return unknownType; } - if (container.kind === 148 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 149 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return unknownType; } @@ -27480,35 +27308,38 @@ var ts; return false; } if (isCallExpression) { - return container.kind === 148; + return container.kind === 149; } else { - if (ts.isClassLike(container.parent) || container.parent.kind === 171) { + if (ts.isClassLike(container.parent) || container.parent.kind === 172) { if (ts.getModifierFlags(container) & 32) { - return container.kind === 147 || - container.kind === 146 || - container.kind === 149 || - container.kind === 150; + return container.kind === 148 || + container.kind === 147 || + container.kind === 150 || + container.kind === 151; } else { - return container.kind === 147 || - container.kind === 146 || - container.kind === 149 || + return container.kind === 148 || + container.kind === 147 || container.kind === 150 || + container.kind === 151 || + container.kind === 146 || container.kind === 145 || - container.kind === 144 || - container.kind === 148; + container.kind === 149; } } } return false; } } - function getContextualThisParameter(func) { - if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 180) { + function getContextualThisParameterType(func) { + if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 181) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { - return contextualSignature.thisParameter; + var thisParameter = contextualSignature.thisParameter; + if (thisParameter) { + return getTypeOfSymbol(thisParameter); + } } } return undefined; @@ -27558,7 +27389,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 142) { + if (declaration.kind === 143) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -27569,11 +27400,11 @@ var ts; } if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; - var name_18 = declaration.propertyName || declaration.name; + var name_15 = declaration.propertyName || declaration.name; if (ts.isVariableLike(parentDeclaration) && parentDeclaration.type && - !ts.isBindingPattern(name_18)) { - var text = getTextOfPropertyName(name_18); + !ts.isBindingPattern(name_15)) { + var text = getTextOfPropertyName(name_15); if (text) { return getTypeOfPropertyOfType(getTypeFromTypeNode(parentDeclaration.type), text); } @@ -27610,7 +27441,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 142 && node.parent.initializer === node) { + if (node.parent.kind === 143 && node.parent.initializer === node) { return true; } node = node.parent; @@ -27619,8 +27450,8 @@ var ts; } function getContextualReturnType(functionDecl) { if (functionDecl.type || - functionDecl.kind === 148 || - functionDecl.kind === 149 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 150))) { + functionDecl.kind === 149 || + functionDecl.kind === 150 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 151))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); @@ -27639,7 +27470,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 176) { + if (template.parent.kind === 177) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -27647,7 +27478,7 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operatorToken.kind; - if (operator >= 56 && operator <= 68) { + if (operator >= 57 && operator <= 69) { if (ts.getSpecialPropertyAssignmentKind(binaryExpression) !== 0) { return undefined; } @@ -27655,14 +27486,14 @@ var ts; return checkExpression(binaryExpression.left); } } - else if (operator === 52) { + else if (operator === 53) { var type = getContextualType(binaryExpression); if (!type && node === binaryExpression.right) { type = checkExpression(binaryExpression.left); } return type; } - else if (operator === 51 || operator === 24) { + else if (operator === 52 || operator === 25) { if (node === binaryExpression.right) { return getContextualType(binaryExpression); } @@ -27676,8 +27507,8 @@ var ts; var types = type.types; var mappedType; var mappedTypes; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var current = types_12[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var current = types_13[_i]; var t = mapper(current); if (t) { if (!mappedType) { @@ -27771,36 +27602,36 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 218: - case 142: + case 219: + case 143: + case 146: case 145: - case 144: - case 169: + case 170: return getContextualTypeForInitializerExpression(node); - case 180: - case 211: + case 181: + case 212: return getContextualTypeForReturnExpression(node); - case 190: + case 191: return getContextualTypeForYieldOperand(parent); - case 174: case 175: + case 176: return getContextualTypeForArgument(parent, node); - case 177: - case 195: + case 178: + case 196: return getTypeFromTypeNode(parent.type); - case 187: + case 188: return getContextualTypeForBinaryOperand(node); case 253: case 254: return getContextualTypeForObjectLiteralElement(parent); - case 170: + case 171: return getContextualTypeForElementExpression(node); - case 188: + case 189: return getContextualTypeForConditionalOperand(node); - case 197: - ts.Debug.assert(parent.parent.kind === 189); + case 198: + ts.Debug.assert(parent.parent.kind === 190); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 178: + case 179: return getContextualType(parent); case 248: return getContextualType(parent); @@ -27820,7 +27651,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 179 || node.kind === 180; + return node.kind === 180 || node.kind === 181; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -27833,7 +27664,7 @@ var ts; getApparentTypeOfContextualType(node); } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 147 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 148 || ts.isObjectLiteralMethod(node)); var type = getContextualTypeForFunctionLikeDeclaration(node); if (!type) { return undefined; @@ -27843,8 +27674,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var current = types_13[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var current = types_14[_i]; var signature = getNonGenericSignature(current); if (signature) { if (!signatureList) { @@ -27874,8 +27705,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false); } function hasDefaultValue(node) { - return (node.kind === 169 && !!node.initializer) || - (node.kind === 187 && node.operatorToken.kind === 56); + return (node.kind === 170 && !!node.initializer) || + (node.kind === 188 && node.operatorToken.kind === 57); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -27884,7 +27715,7 @@ var ts; var inDestructuringPattern = ts.isAssignmentTarget(node); for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { var e = elements_1[_i]; - if (inDestructuringPattern && e.kind === 191) { + if (inDestructuringPattern && e.kind === 192) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); @@ -27896,7 +27727,7 @@ var ts; var type = checkExpressionForMutableLocation(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 191; + hasSpreadElement = hasSpreadElement || e.kind === 192; } if (!hasSpreadElement) { if (inDestructuringPattern && elementTypes.length) { @@ -27907,7 +27738,7 @@ var ts; var contextualType = getApparentTypeOfContextualType(node); if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { var pattern = contextualType.pattern; - if (pattern && (pattern.kind === 168 || pattern.kind === 170)) { + if (pattern && (pattern.kind === 169 || pattern.kind === 171)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -27915,7 +27746,7 @@ var ts; elementTypes.push(contextualType.typeArguments[i]); } else { - if (patternElement.kind !== 193) { + if (patternElement.kind !== 194) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -27932,7 +27763,7 @@ var ts; strictNullChecks ? neverType : undefinedWideningType); } function isNumericName(name) { - return name.kind === 140 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 141 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 340); @@ -27976,7 +27807,7 @@ var ts; var propertiesArray = []; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 167 || contextualType.pattern.kind === 171); + (contextualType.pattern.kind === 168 || contextualType.pattern.kind === 172); var typeFlags = 0; var patternWithComputedProperties = false; var hasComputedStringProperty = false; @@ -27991,7 +27822,7 @@ var ts; if (memberDecl.kind === 253) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 147) { + else if (memberDecl.kind === 148) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { @@ -28030,7 +27861,7 @@ var ts; member = prop; } else { - ts.Debug.assert(memberDecl.kind === 149 || memberDecl.kind === 150); + ts.Debug.assert(memberDecl.kind === 150 || memberDecl.kind === 151); checkAccessorDeclaration(memberDecl); } if (ts.hasDynamicName(memberDecl)) { @@ -28089,10 +27920,10 @@ var ts; case 248: checkJsxExpression(child); break; - case 241: + case 242: checkJsxElement(child); break; - case 242: + case 243: checkJsxSelfClosingElement(child); break; } @@ -28103,7 +27934,7 @@ var ts; return name.indexOf("-") < 0; } function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 172 || tagName.kind === 97) { + if (tagName.kind === 173 || tagName.kind === 98) { return false; } else { @@ -28206,7 +28037,7 @@ var ts; return unknownType; } } - return getUnionType(signatures.map(getReturnTypeOfSignature), true); + return getUnionType(ts.map(signatures, getReturnTypeOfSignature), true); } function getJsxElementPropertiesName() { var jsxNamespace = getGlobalSymbol(JsxNames.JSX, 1920, undefined); @@ -28235,7 +28066,7 @@ var ts; } if (elemType.flags & 524288) { var types = elemType.types; - return getUnionType(types.map(function (type) { + return getUnionType(ts.map(types, function (type) { return getResolvedJsxType(node, type, elemClassType); }), true); } @@ -28411,7 +28242,7 @@ var ts; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 145; + return s.valueDeclaration ? s.valueDeclaration.kind : 146; } function getDeclarationModifierFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedModifierFlags(s.valueDeclaration) : s.flags & 134217728 ? 4 | 32 : 0; @@ -28422,11 +28253,11 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationModifierFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(getParentOfSymbol(prop)); - var errorNode = node.kind === 172 || node.kind === 218 ? + var errorNode = node.kind === 173 || node.kind === 219 ? node.name : node.right; - if (left.kind === 95) { - if (languageVersion < 2 && getDeclarationKindFromSymbol(prop) !== 147) { + if (left.kind === 96) { + if (languageVersion < 2 && getDeclarationKindFromSymbol(prop) !== 148) { error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); return false; } @@ -28446,7 +28277,7 @@ var ts; } return true; } - if (left.kind === 95) { + if (left.kind === 96) { return true; } var enclosingClass = forEachEnclosingClass(node, function (enclosingDeclaration) { @@ -28520,7 +28351,7 @@ var ts; checkClassPropertyAccess(node, left, apparentType, prop); } var propType = getTypeOfSymbol(prop); - if (node.kind !== 172 || ts.isAssignmentTarget(node) || + if (node.kind !== 173 || ts.isAssignmentTarget(node) || !(prop.flags & (3 | 4 | 98304)) && !(prop.flags & 8192 && propType.flags & 524288)) { return propType; @@ -28542,7 +28373,7 @@ var ts; } } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 172 + var left = node.kind === 173 ? node.expression : node.left; var type = checkExpression(left); @@ -28556,13 +28387,13 @@ var ts; } function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 219) { + if (initializer.kind === 220) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 69) { + else if (initializer.kind === 70) { return getResolvedSymbol(initializer); } return undefined; @@ -28572,13 +28403,13 @@ var ts; } function isForInVariableForNumericPropertyNames(expr) { var e = skipParenthesizedNodes(expr); - if (e.kind === 69) { + if (e.kind === 70) { var symbol = getResolvedSymbol(e); if (symbol.flags & 3) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 207 && + if (node.kind === 208 && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(checkExpression(node.expression))) { @@ -28594,7 +28425,7 @@ var ts; function checkIndexedAccess(node) { if (!node.argumentExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 175 && node.parent.expression === node) { + if (node.parent.kind === 176 && 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); @@ -28617,15 +28448,15 @@ var ts; return unknownType; } if (node.argumentExpression) { - var name_19 = getPropertyNameForIndexedAccess(node.argumentExpression, indexType); - if (name_19 !== undefined) { - var prop = getPropertyOfType(objectType, name_19); + var name_16 = getPropertyNameForIndexedAccess(node.argumentExpression, indexType); + if (name_16 !== undefined) { + var prop = getPropertyOfType(objectType, name_16); if (prop) { getNodeLinks(node).resolvedSymbol = prop; return getTypeOfSymbol(prop); } else if (isConstEnum) { - error(node.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_const_enum_1, name_19, symbolToString(objectType.symbol)); + error(node.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_const_enum_1, name_16, symbolToString(objectType.symbol)); return unknownType; } } @@ -28658,7 +28489,7 @@ var ts; if (indexArgumentExpression.kind === 9 || indexArgumentExpression.kind === 8) { return indexArgumentExpression.text; } - if (indexArgumentExpression.kind === 173 || indexArgumentExpression.kind === 172) { + if (indexArgumentExpression.kind === 174 || indexArgumentExpression.kind === 173) { var value = getConstantValue(indexArgumentExpression); if (value !== undefined) { return value.toString(); @@ -28701,10 +28532,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 176) { + if (node.kind === 177) { checkExpression(node.template); } - else if (node.kind !== 143) { + else if (node.kind !== 144) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -28755,7 +28586,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 191) { + if (arg && arg.kind === 192) { return i; } } @@ -28768,11 +28599,11 @@ var ts; var callIsIncomplete; var isDecorator; var spreadArgIndex = -1; - if (node.kind === 176) { + if (node.kind === 177) { var tagExpression = node; argCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 189) { + if (tagExpression.template.kind === 190) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -28780,11 +28611,11 @@ var ts; } else { var templateLiteral = tagExpression.template; - ts.Debug.assert(templateLiteral.kind === 11); + ts.Debug.assert(templateLiteral.kind === 12); callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 143) { + else if (node.kind === 144) { isDecorator = true; typeArguments = undefined; argCount = getEffectiveArgumentCount(node, undefined, signature); @@ -28792,7 +28623,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 175); + ts.Debug.assert(callExpression.kind === 176); return signature.minArgumentCount === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -28851,9 +28682,9 @@ 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 !== 193) { + if (arg === undefined || arg.kind !== 194) { var paramType = getTypeAtPosition(signature, i); - var argType = getEffectiveArgumentType(node, i, arg); + var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { var mapper = excludeArgument && excludeArgument[i] !== undefined ? identityMapper : inferenceMapper; argType = checkExpressionWithContextualType(arg, paramType, mapper); @@ -28898,7 +28729,7 @@ var ts; } function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 175) { + if (thisType && thisType !== voidType && node.kind !== 176) { var thisArgumentNode = getThisArgumentOfCall(node); var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; var errorNode = reportErrors ? (thisArgumentNode || node) : undefined; @@ -28911,9 +28742,9 @@ 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 !== 193) { + if (arg === undefined || arg.kind !== 194) { var paramType = getTypeAtPosition(signature, i); - var argType = getEffectiveArgumentType(node, i, arg); + var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { argType = checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); } @@ -28926,28 +28757,28 @@ var ts; return true; } function getThisArgumentOfCall(node) { - if (node.kind === 174) { + if (node.kind === 175) { var callee = node.expression; - if (callee.kind === 172) { + if (callee.kind === 173) { return callee.expression; } - else if (callee.kind === 173) { + else if (callee.kind === 174) { return callee.expression; } } } function getEffectiveCallArguments(node) { var args; - if (node.kind === 176) { + if (node.kind === 177) { var template = node.template; args = [undefined]; - if (template.kind === 189) { + if (template.kind === 190) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 143) { + else if (node.kind === 144) { return undefined; } else { @@ -28956,21 +28787,21 @@ var ts; return args; } function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 143) { + if (node.kind === 144) { switch (node.parent.kind) { - case 221: - case 192: + case 222: + case 193: return 1; - case 145: + case 146: return 2; - case 147: - case 149: + case 148: case 150: + case 151: if (languageVersion === 0) { return 2; } return signature.parameters.length >= 3 ? 3 : 2; - case 142: + case 143: return 3; } } @@ -28979,48 +28810,48 @@ var ts; } } function getEffectiveDecoratorFirstArgumentType(node) { - if (node.kind === 221) { + if (node.kind === 222) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } - if (node.kind === 142) { + if (node.kind === 143) { node = node.parent; - if (node.kind === 148) { + if (node.kind === 149) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } } - if (node.kind === 145 || - node.kind === 147 || - node.kind === 149 || - node.kind === 150) { + if (node.kind === 146 || + node.kind === 148 || + node.kind === 150 || + node.kind === 151) { return getParentTypeOfClassElement(node); } ts.Debug.fail("Unsupported decorator target."); return unknownType; } function getEffectiveDecoratorSecondArgumentType(node) { - if (node.kind === 221) { + if (node.kind === 222) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } - if (node.kind === 142) { + if (node.kind === 143) { node = node.parent; - if (node.kind === 148) { + if (node.kind === 149) { return anyType; } } - if (node.kind === 145 || - node.kind === 147 || - node.kind === 149 || - node.kind === 150) { + if (node.kind === 146 || + node.kind === 148 || + node.kind === 150 || + node.kind === 151) { var element = node; switch (element.name.kind) { - case 69: + case 70: case 8: case 9: return getLiteralTypeForText(32, element.name.text); - case 140: + case 141: var nameType = checkComputedPropertyName(element.name); if (isTypeOfKind(nameType, 512)) { return nameType; @@ -29037,20 +28868,20 @@ var ts; return unknownType; } function getEffectiveDecoratorThirdArgumentType(node) { - if (node.kind === 221) { + if (node.kind === 222) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 142) { + if (node.kind === 143) { return numberType; } - if (node.kind === 145) { + if (node.kind === 146) { ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 147 || - node.kind === 149 || - node.kind === 150) { + if (node.kind === 148 || + node.kind === 150 || + node.kind === 151) { var propertyType = getTypeOfNode(node); return createTypedPropertyDescriptorType(propertyType); } @@ -29070,27 +28901,27 @@ var ts; ts.Debug.fail("Decorators should not have a fourth synthetic argument."); return unknownType; } - function getEffectiveArgumentType(node, argIndex, arg) { - if (node.kind === 143) { + function getEffectiveArgumentType(node, argIndex) { + if (node.kind === 144) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 176) { + else if (argIndex === 0 && node.kind === 177) { return getGlobalTemplateStringsArrayType(); } return undefined; } function getEffectiveArgument(node, args, argIndex) { - if (node.kind === 143 || - (argIndex === 0 && node.kind === 176)) { + if (node.kind === 144 || + (argIndex === 0 && node.kind === 177)) { return undefined; } return args[argIndex]; } function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 143) { + if (node.kind === 144) { return node.expression; } - else if (argIndex === 0 && node.kind === 176) { + else if (argIndex === 0 && node.kind === 177) { return node.template; } else { @@ -29098,12 +28929,12 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 176; - var isDecorator = node.kind === 143; + var isTaggedTemplate = node.kind === 177; + var isDecorator = node.kind === 144; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; - if (node.expression.kind !== 95) { + if (node.expression.kind !== 96) { ts.forEach(typeArguments, checkSourceElement); } } @@ -29129,7 +28960,7 @@ var ts; var candidateForTypeArgumentError; var resultOfFailedInference; var result; - var signatureHelpTrailingComma = candidatesOutArray && node.kind === 174 && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 175 && node.arguments.hasTrailingComma; if (candidates.length > 1) { result = chooseOverload(candidates, subtypeRelation, signatureHelpTrailingComma); } @@ -29244,7 +29075,7 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 95) { + if (node.expression.kind === 96) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); @@ -29397,16 +29228,16 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 221: - case 192: + case 222: + case 193: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 142: + case 143: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 145: + case 146: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 147: - case 149: + case 148: case 150: + case 151: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -29433,13 +29264,13 @@ var ts; } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 174: - return resolveCallExpression(node, candidatesOutArray); case 175: - return resolveNewExpression(node, candidatesOutArray); + return resolveCallExpression(node, candidatesOutArray); case 176: + return resolveNewExpression(node, candidatesOutArray); + case 177: return resolveTaggedTemplateExpression(node, candidatesOutArray); - case 143: + case 144: return resolveDecorator(node, candidatesOutArray); } ts.Debug.fail("Branch in 'resolveSignature' should be unreachable."); @@ -29468,17 +29299,17 @@ var ts; function checkCallExpression(node) { checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 95) { + if (node.expression.kind === 96) { return voidType; } - if (node.kind === 175) { + if (node.kind === 176) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 148 && - declaration.kind !== 152 && - declaration.kind !== 157 && + declaration.kind !== 149 && + declaration.kind !== 153 && + declaration.kind !== 158 && !ts.isJSDocConstructSignature(declaration)) { - var funcSymbol = node.expression.kind === 69 ? + var funcSymbol = node.expression.kind === 70 ? getResolvedSymbol(node.expression) : checkExpression(node.expression).symbol; if (funcSymbol && funcSymbol.members && (funcSymbol.flags & 16 || ts.isDeclarationOfFunctionExpression(funcSymbol))) { @@ -29490,7 +29321,9 @@ var ts; return anyType; } } - if (ts.isInJavaScriptFile(node) && ts.isRequireCall(node, true)) { + if (ts.isInJavaScriptFile(node) && + ts.isRequireCall(node, true) && + !resolveName(node.expression, node.expression.text, 107455, undefined, undefined)) { return resolveExternalModuleTypeByLiteral(node.arguments[0]); } return getReturnTypeOfSignature(signature); @@ -29530,21 +29363,36 @@ var ts; } function assignContextualParameterTypes(signature, context, mapper) { var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + if (isInferentialContext(mapper)) { + for (var i = 0; i < len; i++) { + var declaration = signature.parameters[i].valueDeclaration; + if (declaration.type) { + inferTypes(mapper.context, getTypeFromTypeNode(declaration.type), getTypeAtPosition(context, i)); + } + } + } if (context.thisParameter) { - if (!signature.thisParameter) { - signature.thisParameter = createTransientSymbol(context.thisParameter, undefined); + var parameter = signature.thisParameter; + if (!parameter || parameter.valueDeclaration && !parameter.valueDeclaration.type) { + if (!parameter) { + signature.thisParameter = createTransientSymbol(context.thisParameter, undefined); + } + assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper); } - assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper); } for (var i = 0; i < len; i++) { var parameter = signature.parameters[i]; - var contextualParameterType = getTypeAtPosition(context, i); - assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + if (!parameter.valueDeclaration.type) { + var contextualParameterType = getTypeAtPosition(context, i); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + } } if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) { var parameter = ts.lastOrUndefined(signature.parameters); - var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); - assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + if (!parameter.valueDeclaration.type) { + var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + } } } function assignBindingElementTypes(node) { @@ -29552,7 +29400,7 @@ var ts; for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { var element = _a[_i]; if (!ts.isOmittedExpression(element)) { - if (element.name.kind === 69) { + if (element.name.kind === 70) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } assignBindingElementTypes(element); @@ -29565,8 +29413,8 @@ var ts; if (!links.type) { links.type = instantiateType(contextualType, mapper); if (links.type === emptyObjectType && - (parameter.valueDeclaration.name.kind === 167 || - parameter.valueDeclaration.name.kind === 168)) { + (parameter.valueDeclaration.name.kind === 168 || + parameter.valueDeclaration.name.kind === 169)) { links.type = getTypeFromBindingPattern(parameter.valueDeclaration.name); } assignBindingElementTypes(parameter.valueDeclaration); @@ -29605,7 +29453,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 199) { + if (func.body.kind !== 200) { 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); @@ -29684,7 +29532,7 @@ var ts; return false; } var lastStatement = ts.lastOrUndefined(func.body.statements); - if (lastStatement && lastStatement.kind === 213 && isExhaustiveSwitchStatement(lastStatement)) { + if (lastStatement && lastStatement.kind === 214 && isExhaustiveSwitchStatement(lastStatement)) { return false; } return true; @@ -29713,7 +29561,7 @@ var ts; } }); if (aggregatedTypes.length === 0 && !hasReturnWithNoExpression && (hasReturnOfTypeNever || - func.kind === 179 || func.kind === 180)) { + func.kind === 180 || func.kind === 181)) { return undefined; } if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression) { @@ -29730,7 +29578,7 @@ var ts; if (returnType && maybeTypeOfKind(returnType, 1 | 1024)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 199 || !functionHasImplicitReturn(func)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 200 || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256; @@ -29757,9 +29605,9 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 147 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 148 || ts.isObjectLiteralMethod(node)); var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 179) { + if (!hasGrammarError && node.kind === 180) { checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { @@ -29793,14 +29641,14 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 147) { + if (produceDiagnostics && node.kind !== 148) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 147 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 148 || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); if (!node.asteriskToken) { @@ -29810,7 +29658,7 @@ var ts; if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 199) { + if (node.body.kind === 200) { checkSourceElement(node.body); } else { @@ -29845,10 +29693,10 @@ var ts; function isReferenceToReadonlyEntity(expr, symbol) { if (isReadonlySymbol(symbol)) { if (symbol.flags & 4 && - (expr.kind === 172 || expr.kind === 173) && - expr.expression.kind === 97) { + (expr.kind === 173 || expr.kind === 174) && + expr.expression.kind === 98) { var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 148)) + if (!(func && func.kind === 149)) return true; return !(func.parent === symbol.valueDeclaration.parent || func === symbol.valueDeclaration.parent); } @@ -29857,13 +29705,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 172 || expr.kind === 173) { + if (expr.kind === 173 || expr.kind === 174) { var node = skipParenthesizedNodes(expr.expression); - if (node.kind === 69) { + if (node.kind === 70) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 8388608) { var declaration = getDeclarationOfAliasSymbol(symbol); - return declaration && declaration.kind === 232; + return declaration && declaration.kind === 233; } } } @@ -29871,7 +29719,7 @@ var ts; } function checkReferenceExpression(expr, invalidReferenceMessage, constantVariableMessage) { var node = skipParenthesizedNodes(expr); - if (node.kind !== 69 && node.kind !== 172 && node.kind !== 173) { + if (node.kind !== 70 && node.kind !== 173 && node.kind !== 174) { error(expr, invalidReferenceMessage); return false; } @@ -29879,7 +29727,7 @@ var ts; var symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol); if (symbol) { if (symbol !== unknownSymbol && symbol !== argumentsSymbol) { - if (node.kind === 69 && !(symbol.flags & 3)) { + if (node.kind === 70 && !(symbol.flags & 3)) { error(expr, invalidReferenceMessage); return false; } @@ -29889,7 +29737,7 @@ var ts; } } } - else if (node.kind === 173) { + else if (node.kind === 174) { if (links.resolvedIndexInfo && links.resolvedIndexInfo.isReadonly) { error(expr, constantVariableMessage); return false; @@ -29926,24 +29774,24 @@ var ts; if (operandType === silentNeverType) { return silentNeverType; } - if (node.operator === 36 && node.operand.kind === 8) { + if (node.operator === 37 && node.operand.kind === 8) { return getFreshTypeOfLiteralType(getLiteralTypeForText(64, "" + -node.operand.text)); } switch (node.operator) { - case 35: case 36: - case 50: + case 37: + case 51: if (maybeTypeOfKind(operandType, 512)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; - case 49: + case 50: var facts = getTypeFacts(operandType) & (1048576 | 2097152); return facts === 1048576 ? falseType : facts === 2097152 ? trueType : booleanType; - case 41: case 42: + case 43: var ok = checkArithmeticOperandType(node.operand, getNonNullableType(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_or_a_read_only_property); @@ -29969,8 +29817,8 @@ var ts; } if (type.flags & 1572864) { var types = type.types; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var t = types_14[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var t = types_15[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -29984,8 +29832,8 @@ var ts; } if (type.flags & 524288) { var types = type.types; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var t = types_15[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var t = types_16[_i]; if (!isTypeOfKind(t, kind)) { return false; } @@ -29994,8 +29842,8 @@ var ts; } if (type.flags & 1048576) { var types = type.types; - for (var _a = 0, types_16 = types; _a < types_16.length; _a++) { - var t = types_16[_a]; + for (var _a = 0, types_17 = types; _a < types_17.length; _a++) { + var t = types_17[_a]; if (isTypeOfKind(t, kind)) { return true; } @@ -30033,24 +29881,24 @@ var ts; } return booleanType; } - function checkObjectLiteralAssignment(node, sourceType, contextualMapper) { + function checkObjectLiteralAssignment(node, sourceType) { var properties = node.properties; for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { var p = properties_4[_i]; - checkObjectLiteralDestructuringPropertyAssignment(sourceType, p, contextualMapper); + checkObjectLiteralDestructuringPropertyAssignment(sourceType, p); } return sourceType; } - function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, contextualMapper) { + function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property) { if (property.kind === 253 || property.kind === 254) { - var name_20 = property.name; - if (name_20.kind === 140) { - checkComputedPropertyName(name_20); + var name_17 = property.name; + if (name_17.kind === 141) { + checkComputedPropertyName(name_17); } - if (isComputedNonLiteralName(name_20)) { + if (isComputedNonLiteralName(name_17)) { return undefined; } - var text = getTextOfPropertyName(name_20); + var text = getTextOfPropertyName(name_17); var type = isTypeAny(objectLiteralType) ? objectLiteralType : getTypeOfPropertyOfType(objectLiteralType, text) || @@ -30065,7 +29913,7 @@ var ts; } } else { - error(name_20, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_20)); + error(name_17, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_17)); } } else { @@ -30083,8 +29931,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, contextualMapper) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 193) { - if (element.kind !== 191) { + if (element.kind !== 194) { + if (element.kind !== 192) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType @@ -30110,7 +29958,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 187 && restExpression.operatorToken.kind === 56) { + if (restExpression.kind === 188 && restExpression.operatorToken.kind === 57) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -30137,14 +29985,14 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 187 && target.operatorToken.kind === 56) { + if (target.kind === 188 && target.operatorToken.kind === 57) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 171) { - return checkObjectLiteralAssignment(target, sourceType, contextualMapper); + if (target.kind === 172) { + return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 170) { + if (target.kind === 171) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -30159,49 +30007,49 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 69: + case 70: case 9: - case 10: - case 176: - case 189: case 11: + case 177: + case 190: + case 12: case 8: - case 99: - case 84: - case 93: - case 135: - case 179: - case 192: + case 100: + case 85: + case 94: + case 136: case 180: - case 170: + case 193: + case 181: case 171: - case 182: - case 196: + case 172: + case 183: + case 197: + case 243: case 242: - case 241: return true; - case 188: + case 189: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 187: + case 188: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 185: case 186: + case 187: switch (node.operator) { - case 49: - case 35: - case 36: case 50: + case 36: + case 37: + case 51: return true; } return false; - case 183: - case 177: - case 195: + case 184: + case 178: + case 196: default: return false; } @@ -30221,34 +30069,34 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { var operator = operatorToken.kind; - if (operator === 56 && (left.kind === 171 || left.kind === 170)) { + if (operator === 57 && (left.kind === 172 || left.kind === 171)) { return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } var leftType = checkExpression(left, contextualMapper); var rightType = checkExpression(right, contextualMapper); switch (operator) { - case 37: case 38: - case 59: - case 60: case 39: + case 60: case 61: case 40: case 62: - case 36: - case 58: - case 43: + case 41: case 63: + case 37: + case 59: case 44: case 64: case 45: case 65: - case 47: - case 67: - case 48: - case 68: case 46: case 66: + case 48: + case 68: + case 49: + case 69: + case 47: + case 67: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -30272,8 +30120,8 @@ var ts; } } return numberType; - case 35: - case 57: + case 36: + case 58: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -30302,24 +30150,24 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 57) { + if (operator === 58) { checkAssignmentOperator(resultType); } return resultType; - case 25: - case 27: + case 26: case 28: case 29: + case 30: if (checkForDisallowedESSymbolOperand(operator)) { if (!isTypeComparableTo(leftType, rightType) && !isTypeComparableTo(rightType, leftType)) { reportOperatorError(); } } return booleanType; - case 30: case 31: case 32: case 33: + case 34: var leftIsLiteral = isLiteralType(leftType); var rightIsLiteral = isLiteralType(rightType); if (!leftIsLiteral || !rightIsLiteral) { @@ -30330,22 +30178,22 @@ var ts; reportOperatorError(); } return booleanType; - case 91: + case 92: return checkInstanceOfExpression(left, right, leftType, rightType); - case 90: + case 91: return checkInExpression(left, right, leftType, rightType); - case 51: + case 52: return getTypeFacts(leftType) & 1048576 ? includeFalsyTypes(rightType, getFalsyFlags(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType))) : leftType; - case 52: + case 53: return getTypeFacts(leftType) & 2097152 ? getBestChoiceType(removeDefinitelyFalsyTypes(leftType), rightType) : leftType; - case 56: + case 57: checkAssignmentOperator(rightType); return getRegularTypeOfObjectLiteral(rightType); - case 24: + case 25: if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left)) { error(left, ts.Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects); } @@ -30363,21 +30211,21 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { + case 48: + case 68: + return 53; + case 49: + case 69: + return 34; case 47: case 67: return 52; - case 48: - case 68: - return 33; - case 46: - case 66: - return 51; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 56 && operator <= 68) { + if (produceDiagnostics && operator >= 57 && operator <= 69) { 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_or_a_read_only_property); if (ok) { checkTypeAssignableTo(valueType, leftType, left, undefined); @@ -30449,9 +30297,9 @@ var ts; return getFreshTypeOfLiteralType(getLiteralTypeForText(32, node.text)); case 8: return getFreshTypeOfLiteralType(getLiteralTypeForText(64, node.text)); - case 99: + case 100: return trueType; - case 84: + case 85: return falseType; } } @@ -30480,7 +30328,7 @@ var ts; } function isTypeAssertion(node) { node = skipParenthesizedNodes(node); - return node.kind === 177 || node.kind === 195; + return node.kind === 178 || node.kind === 196; } function checkDeclarationInitializer(declaration) { var type = checkExpressionCached(declaration.initializer); @@ -30506,14 +30354,14 @@ var ts; return isTypeAssertion(node) || isLiteralContextualType(getContextualType(node)) ? type : getWidenedLiteralType(type); } function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 140) { + if (node.name.kind === 141) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, contextualMapper); } function checkObjectLiteralMethod(node, contextualMapper) { checkGrammarMethod(node); - if (node.name.kind === 140) { + if (node.name.kind === 141) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -30536,7 +30384,7 @@ var ts; } function checkExpression(node, contextualMapper) { var type; - if (node.kind === 139) { + if (node.kind === 140) { type = checkQualifiedName(node); } else { @@ -30544,9 +30392,9 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 172 && node.parent.expression === node) || - (node.parent.kind === 173 && node.parent.expression === node) || - ((node.kind === 69 || node.kind === 139) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 173 && node.parent.expression === node) || + (node.parent.kind === 174 && node.parent.expression === node) || + ((node.kind === 70 || node.kind === 140) && 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); } @@ -30555,79 +30403,79 @@ var ts; } function checkExpressionWorker(node, contextualMapper) { switch (node.kind) { - case 69: + case 70: return checkIdentifier(node); - case 97: + case 98: return checkThisExpression(node); - case 95: + case 96: return checkSuperExpression(node); - case 93: + case 94: return nullWideningType; case 9: case 8: - case 99: - case 84: + case 100: + case 85: return checkLiteralExpression(node); - case 189: - return checkTemplateExpression(node); - case 11: - return stringType; - case 10: - return globalRegExpType; - case 170: - return checkArrayLiteral(node, contextualMapper); - case 171: - return checkObjectLiteral(node, contextualMapper); - case 172: - return checkPropertyAccessExpression(node); - case 173: - return checkIndexedAccess(node); - case 174: - case 175: - return checkCallExpression(node); - case 176: - return checkTaggedTemplateExpression(node); - case 178: - return checkExpression(node.expression, contextualMapper); - case 192: - return checkClassExpression(node); - case 179: - case 180: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 182: - return checkTypeOfExpression(node); - case 177: - case 195: - return checkAssertion(node); - case 196: - return checkNonNullAssertion(node); - case 181: - return checkDeleteExpression(node); - case 183: - return checkVoidExpression(node); - case 184: - return checkAwaitExpression(node); - case 185: - return checkPrefixUnaryExpression(node); - case 186: - return checkPostfixUnaryExpression(node); - case 187: - return checkBinaryExpression(node, contextualMapper); - case 188: - return checkConditionalExpression(node, contextualMapper); - case 191: - return checkSpreadElementExpression(node, contextualMapper); - case 193: - return undefinedWideningType; case 190: + return checkTemplateExpression(node); + case 12: + return stringType; + case 11: + return globalRegExpType; + case 171: + return checkArrayLiteral(node, contextualMapper); + case 172: + return checkObjectLiteral(node, contextualMapper); + case 173: + return checkPropertyAccessExpression(node); + case 174: + return checkIndexedAccess(node); + case 175: + case 176: + return checkCallExpression(node); + case 177: + return checkTaggedTemplateExpression(node); + case 179: + return checkExpression(node.expression, contextualMapper); + case 193: + return checkClassExpression(node); + case 180: + case 181: + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + case 183: + return checkTypeOfExpression(node); + case 178: + case 196: + return checkAssertion(node); + case 197: + return checkNonNullAssertion(node); + case 182: + return checkDeleteExpression(node); + case 184: + return checkVoidExpression(node); + case 185: + return checkAwaitExpression(node); + case 186: + return checkPrefixUnaryExpression(node); + case 187: + return checkPostfixUnaryExpression(node); + case 188: + return checkBinaryExpression(node, contextualMapper); + case 189: + return checkConditionalExpression(node, contextualMapper); + case 192: + return checkSpreadElementExpression(node, contextualMapper); + case 194: + return undefinedWideningType; + case 191: return checkYieldExpression(node); case 248: return checkJsxExpression(node); - case 241: - return checkJsxElement(node); case 242: - return checkJsxSelfClosingElement(node); + return checkJsxElement(node); case 243: + return checkJsxSelfClosingElement(node); + case 244: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -30648,7 +30496,7 @@ var ts; var func = ts.getContainingFunction(node); if (ts.getModifierFlags(node) & 92) { func = ts.getContainingFunction(node); - if (!(func.kind === 148 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 149 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -30659,7 +30507,7 @@ var ts; if (ts.indexOf(func.parameters, node) !== 0) { error(node, ts.Diagnostics.A_this_parameter_must_be_the_first_parameter); } - if (func.kind === 148 || func.kind === 152 || func.kind === 157) { + if (func.kind === 149 || func.kind === 153 || func.kind === 158) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } } @@ -30671,15 +30519,15 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 147 || - node.kind === 220 || - node.kind === 179; + return node.kind === 148 || + node.kind === 221 || + node.kind === 180; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 69 && + if (param.name.kind === 70 && param.name.text === parameter.text) { return i; } @@ -30714,9 +30562,9 @@ var ts; else if (parameterName) { var hasReportedError = false; for (var _i = 0, _a = parent.parameters; _i < _a.length; _i++) { - var name_21 = _a[_i].name; - if (ts.isBindingPattern(name_21) && - checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_21, parameterName, typePredicate.parameterName)) { + var name_18 = _a[_i].name; + if (ts.isBindingPattern(name_18) && + checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_18, parameterName, typePredicate.parameterName)) { hasReportedError = true; break; } @@ -30729,13 +30577,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { + case 181: + case 152: + case 221: case 180: - case 151: - case 220: - case 179: - case 156: + case 157: + case 148: case 147: - case 146: var parent_12 = node.parent; if (node === parent_12.type) { return parent_12; @@ -30748,27 +30596,27 @@ var ts; if (ts.isOmittedExpression(element)) { continue; } - var name_22 = element.name; - if (name_22.kind === 69 && - name_22.text === predicateVariableName) { + var name_19 = element.name; + if (name_19.kind === 70 && + name_19.text === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name_22.kind === 168 || - name_22.kind === 167) { - if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_22, predicateVariableNode, predicateVariableName)) { + else if (name_19.kind === 169 || + name_19.kind === 168) { + if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_19, predicateVariableNode, predicateVariableName)) { return true; } } } } function checkSignatureDeclaration(node) { - if (node.kind === 153) { + if (node.kind === 154) { checkGrammarIndexSignature(node); } - else if (node.kind === 156 || node.kind === 220 || node.kind === 157 || - node.kind === 151 || node.kind === 148 || - node.kind === 152) { + else if (node.kind === 157 || node.kind === 221 || node.kind === 158 || + node.kind === 152 || node.kind === 149 || + node.kind === 153) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); @@ -30780,10 +30628,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 152: + case 153: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 151: + case 152: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -30810,11 +30658,17 @@ var ts; } } function checkClassForDuplicateDeclarations(node) { + var Accessor; + (function (Accessor) { + Accessor[Accessor["Getter"] = 1] = "Getter"; + Accessor[Accessor["Setter"] = 2] = "Setter"; + Accessor[Accessor["Property"] = 3] = "Property"; + })(Accessor || (Accessor = {})); var instanceNames = ts.createMap(); var staticNames = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 148) { + if (member.kind === 149) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param)) { @@ -30823,18 +30677,18 @@ var ts; } } else { - var isStatic = ts.forEach(member.modifiers, function (m) { return m.kind === 113; }); + var isStatic = ts.forEach(member.modifiers, function (m) { return m.kind === 114; }); var names = isStatic ? staticNames : instanceNames; var memberName = member.name && ts.getPropertyNameForPropertyNameNode(member.name); if (memberName) { switch (member.kind) { - case 149: + case 150: addName(names, member.name, memberName, 1); break; - case 150: + case 151: addName(names, member.name, memberName, 2); break; - case 145: + case 146: addName(names, member.name, memberName, 3); break; } @@ -30860,12 +30714,12 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind == 144) { + if (member.kind == 145) { var memberName = void 0; switch (member.name.kind) { case 9: case 8: - case 69: + case 70: memberName = member.name.text; break; default: @@ -30882,7 +30736,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 222) { + if (node.kind === 223) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -30897,7 +30751,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 132: + case 133: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -30905,7 +30759,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 130: + case 131: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -30961,15 +30815,15 @@ var ts; return ts.forEachChild(n, containsSuperCall); } function markThisReferencesAsErrors(n) { - if (n.kind === 97) { + if (n.kind === 98) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 179 && n.kind !== 220) { + else if (n.kind !== 180 && n.kind !== 221) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 145 && + return n.kind === 146 && !(ts.getModifierFlags(n) & 32) && !!n.initializer; } @@ -30989,7 +30843,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 202 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 203 && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -31012,18 +30866,18 @@ var ts; checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 149) { + if (node.kind === 150) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 128)) { if (!(node.flags & 256)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); } } } - if (node.name.kind === 140) { + if (node.name.kind === 141) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { - var otherKind = node.kind === 149 ? 150 : 149; + var otherKind = node.kind === 150 ? 151 : 150; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if ((ts.getModifierFlags(node) & 28) !== (ts.getModifierFlags(otherAccessor) & 28)) { @@ -31037,11 +30891,11 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 149) { + if (node.kind === 150) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } - if (node.parent.kind !== 171) { + if (node.parent.kind !== 172) { checkSourceElement(node.body); registerForUnusedIdentifiersCheck(node); } @@ -31127,9 +30981,9 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); - if (n.parent.kind !== 222 && - n.parent.kind !== 221 && - n.parent.kind !== 192 && + if (n.parent.kind !== 223 && + n.parent.kind !== 222 && + n.parent.kind !== 193 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { flags |= 1; @@ -31206,7 +31060,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) { - var reportError = (node.kind === 147 || node.kind === 146) && + var reportError = (node.kind === 148 || node.kind === 147) && (ts.getModifierFlags(node) & 32) !== (ts.getModifierFlags(subsequentNode) & 32); if (reportError) { var diagnostic = ts.getModifierFlags(node) & 32 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; @@ -31239,11 +31093,11 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 222 || node.parent.kind === 159 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 223 || node.parent.kind === 160 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 220 || node.kind === 147 || node.kind === 146 || node.kind === 148) { + if (node.kind === 221 || node.kind === 148 || node.kind === 147 || node.kind === 149) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -31354,16 +31208,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 222: + case 223: return 2097152; - case 225: + case 226: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 221: - case 224: + case 222: + case 225: return 2097152 | 1048576; - case 229: + case 230: var result_2 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_2 |= getDeclarationSpaces(d); }); @@ -31511,22 +31365,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 221: + case 222: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 142: + case 143: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 145: + case 146: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 147: - case 149: + case 148: case 150: + case 151: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -31535,9 +31389,9 @@ var ts; checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, errorInfo); } function checkTypeNodeAsExpression(node) { - if (node && node.kind === 155) { + if (node && node.kind === 156) { var root = getFirstIdentifier(node.typeName); - var meaning = root.parent.kind === 155 ? 793064 : 1920; + var meaning = root.parent.kind === 156 ? 793064 : 1920; var rootSymbol = resolveName(root, root.text, meaning | 8388608, undefined, undefined); if (rootSymbol && rootSymbol.flags & 8388608) { var aliasTarget = resolveAlias(rootSymbol); @@ -31571,20 +31425,20 @@ var ts; } if (compilerOptions.emitDecoratorMetadata) { switch (node.kind) { - case 221: + case 222: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 147: - case 149: + case 148: case 150: + case 151: checkParameterTypeAnnotationsAsExpressions(node); checkReturnTypeAnnotationAsExpression(node); break; - case 145: - case 142: + case 146: + case 143: checkTypeAnnotationAsExpression(node); break; } @@ -31604,7 +31458,7 @@ var ts; checkDecorators(node); checkSignatureDeclaration(node); var isAsync = ts.isAsyncFunctionLike(node); - if (node.name && node.name.kind === 140) { + if (node.name && node.name.kind === 141) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { @@ -31647,42 +31501,42 @@ var ts; var node = deferredUnusedIdentifierNodes_1[_i]; switch (node.kind) { case 256: - case 225: + case 226: checkUnusedModuleMembers(node); break; - case 221: - case 192: + case 222: + case 193: checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; - case 222: + case 223: checkUnusedTypeParameters(node); break; - case 199: - case 227: - case 206: + case 200: + case 228: case 207: case 208: + case 209: checkUnusedLocalsAndParameters(node); break; - case 148: - case 179: - case 220: - case 180: - case 147: case 149: + case 180: + case 221: + case 181: + case 148: case 150: + case 151: if (node.body) { checkUnusedLocalsAndParameters(node); } checkUnusedTypeParameters(node); break; - case 146: - case 151: + case 147: case 152: case 153: - case 156: + case 154: case 157: + case 158: checkUnusedTypeParameters(node); break; } @@ -31691,11 +31545,11 @@ var ts; } } function checkUnusedLocalsAndParameters(node) { - if (node.parent.kind !== 222 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { + if (node.parent.kind !== 223 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { var _loop_1 = function (key) { var local = node.locals[key]; if (!local.isReferenced) { - if (local.valueDeclaration && local.valueDeclaration.kind === 142) { + if (local.valueDeclaration && local.valueDeclaration.kind === 143) { var parameter = local.valueDeclaration; if (compilerOptions.noUnusedParameters && !ts.isParameterPropertyDeclaration(parameter) && @@ -31715,19 +31569,19 @@ var ts; } } function parameterNameStartsWithUnderscore(parameter) { - return parameter.name && parameter.name.kind === 69 && parameter.name.text.charCodeAt(0) === 95; + return parameter.name && parameter.name.kind === 70 && parameter.name.text.charCodeAt(0) === 95; } function checkUnusedClassMembers(node) { if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) { if (node.members) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 147 || member.kind === 145) { + if (member.kind === 148 || member.kind === 146) { if (!member.symbol.isReferenced && ts.getModifierFlags(member) & 8) { error(member.name, ts.Diagnostics._0_is_declared_but_never_used, member.symbol.name); } } - else if (member.kind === 148) { + else if (member.kind === 149) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.getModifierFlags(parameter) & 8) { @@ -31772,7 +31626,7 @@ var ts; } } function checkBlock(node) { - if (node.kind === 199) { + if (node.kind === 200) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -31794,19 +31648,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 145 || - node.kind === 144 || + if (node.kind === 146 || + node.kind === 145 || + node.kind === 148 || node.kind === 147 || - node.kind === 146 || - node.kind === 149 || - node.kind === 150) { + node.kind === 150 || + node.kind === 151) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 142 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 143 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -31820,7 +31674,7 @@ var ts; var current = node; while (current) { if (getNodeCheckFlags(current) & 4) { - var isDeclaration_1 = node.kind !== 69; + var isDeclaration_1 = node.kind !== 70; if (isDeclaration_1) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -31841,7 +31695,7 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 69; + var isDeclaration_2 = node.kind !== 70; if (isDeclaration_2) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -31851,13 +31705,13 @@ var ts; } } function checkCollisionWithRequireExportsInGeneratedCode(node, name) { - if (modulekind >= ts.ModuleKind.ES6) { + if (modulekind >= ts.ModuleKind.ES2015) { return; } if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 225 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 226 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); @@ -31869,7 +31723,7 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "Promise")) { return; } - if (node.kind === 225 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 226 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); @@ -31881,7 +31735,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 3) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 218 && !node.initializer) { + if (node.kind === 219 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -31891,25 +31745,25 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 219); - var container = varDeclList.parent.kind === 200 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 220); + var container = varDeclList.parent.kind === 201 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 199 && ts.isFunctionLike(container.parent) || + (container.kind === 200 && ts.isFunctionLike(container.parent) || + container.kind === 227 || container.kind === 226 || - container.kind === 225 || container.kind === 256); if (!namesShareScope) { - var name_23 = symbolToString(localDeclarationSymbol); - error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_23, name_23); + var name_20 = symbolToString(localDeclarationSymbol); + error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_20, name_20); } } } } } function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 142) { + if (ts.getRootDeclaration(node).kind !== 143) { return; } var func = ts.getContainingFunction(node); @@ -31918,10 +31772,10 @@ var ts; if (ts.isTypeNode(n) || ts.isDeclarationName(n)) { return; } - if (n.kind === 172) { + if (n.kind === 173) { return visit(n.expression); } - else if (n.kind === 69) { + else if (n.kind === 70) { var symbol = resolveName(n, n.text, 107455 | 8388608, undefined, undefined); if (!symbol || symbol === unknownSymbol || !symbol.valueDeclaration) { return; @@ -31932,7 +31786,7 @@ var ts; } var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 142) { + if (symbol.valueDeclaration.kind === 143) { if (symbol.valueDeclaration.pos < node.pos) { return; } @@ -31941,7 +31795,7 @@ var ts; if (ts.isFunctionLike(current.parent)) { return; } - if (current.parent.kind === 145 && + if (current.parent.kind === 146 && !(ts.hasModifier(current.parent, 32)) && ts.isClassLike(current.parent.parent)) { return; @@ -31958,25 +31812,25 @@ var ts; } } function convertAutoToAny(type) { - return type === autoType ? anyType : type; + return type === autoType ? anyType : type === autoArrayType ? anyArrayType : type; } function checkVariableLikeDeclaration(node) { checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 140) { + if (node.name.kind === 141) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 169) { - if (node.propertyName && node.propertyName.kind === 140) { + if (node.kind === 170) { + if (node.propertyName && node.propertyName.kind === 141) { checkComputedPropertyName(node.propertyName); } var parent_13 = node.parent.parent; var parentType = getTypeForBindingElementParent(parent_13); - var name_24 = node.propertyName || node.name; - var property = getPropertyOfType(parentType, getTextOfPropertyName(name_24)); + var name_21 = node.propertyName || node.name; + var property = getPropertyOfType(parentType, getTextOfPropertyName(name_21)); if (parent_13.initializer && property && getParentOfSymbol(property)) { checkClassPropertyAccess(parent_13, parent_13.initializer, parentType, property); } @@ -31984,12 +31838,12 @@ var ts; if (ts.isBindingPattern(node.name)) { ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 142 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 143 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } if (ts.isBindingPattern(node.name)) { - if (node.initializer && node.parent.parent.kind !== 207) { + if (node.initializer && node.parent.parent.kind !== 208) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, undefined); checkParameterInitializer(node); } @@ -31998,7 +31852,7 @@ var ts; var symbol = getSymbolOfNode(node); var type = convertAutoToAny(getTypeOfVariableOrParameterOrProperty(symbol)); if (node === symbol.valueDeclaration) { - if (node.initializer && node.parent.parent.kind !== 207) { + if (node.initializer && node.parent.parent.kind !== 208) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); checkParameterInitializer(node); } @@ -32016,9 +31870,9 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 145 && node.kind !== 144) { + if (node.kind !== 146 && node.kind !== 145) { checkExportsOnMergedDeclarations(node); - if (node.kind === 218 || node.kind === 169) { + if (node.kind === 219 || node.kind === 170) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -32028,8 +31882,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 142 && right.kind === 218) || - (left.kind === 218 && right.kind === 142)) { + if ((left.kind === 143 && right.kind === 219) || + (left.kind === 219 && right.kind === 143)) { return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { @@ -32056,7 +31910,7 @@ var ts; ts.forEach(node.declarationList.declarations, checkSourceElement); } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { - if (node.modifiers && node.parent.kind === 171) { + if (node.modifiers && node.parent.kind === 172) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -32075,7 +31929,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 201) { + if (node.thenStatement.kind === 202) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -32092,12 +31946,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 219) { + if (node.initializer && node.initializer.kind === 220) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 219) { + if (node.initializer.kind === 220) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -32115,13 +31969,13 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 219) { + if (node.initializer.kind === 220) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 170 || varExpr.kind === 171) { + if (varExpr.kind === 171 || varExpr.kind === 172) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { @@ -32139,7 +31993,7 @@ var ts; } function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 219) { + if (node.initializer.kind === 220) { 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); @@ -32149,7 +32003,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 170 || varExpr.kind === 171) { + if (varExpr.kind === 171 || varExpr.kind === 172) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 34)) { @@ -32322,7 +32176,7 @@ var ts; checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatedSetAccessor(node) { - return !!(node.kind === 149 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 150))); + return !!(node.kind === 150 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 151))); } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { var unwrappedReturnType = ts.isAsyncFunctionLike(func) ? getPromisedType(returnType) : returnType; @@ -32344,12 +32198,12 @@ var ts; if (func.asteriskToken) { return; } - if (func.kind === 150) { + if (func.kind === 151) { if (node.expression) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 148) { + else if (func.kind === 149) { if (node.expression && !checkTypeAssignableTo(exprType, returnType, node.expression)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -32367,7 +32221,7 @@ var ts; } } } - else if (func.kind !== 148 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 149 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } } @@ -32424,7 +32278,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 214 && current.label.text === node.label.text) { + if (current.kind === 215 && 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; @@ -32450,7 +32304,7 @@ var ts; var catchClause = node.catchClause; if (catchClause) { if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 69) { + if (catchClause.variableDeclaration.name.kind !== 70) { grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); } else if (catchClause.variableDeclaration.type) { @@ -32518,7 +32372,7 @@ var ts; return; } var errorNode; - if (prop.valueDeclaration.name.kind === 140 || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 141 || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -32569,7 +32423,7 @@ var ts; var firstDecl; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 221 || declaration.kind === 222) { + if (declaration.kind === 222 || declaration.kind === 223) { if (!firstDecl) { firstDecl = declaration; } @@ -32706,7 +32560,7 @@ var ts; if (derived === base) { var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); if (baseDeclarationFlags & 128 && (!derivedClassDecl || !(ts.getModifierFlags(derivedClassDecl) & 128))) { - if (derivedClassDecl.kind === 192) { + if (derivedClassDecl.kind === 193) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -32750,7 +32604,7 @@ var ts; } } function isAccessor(kind) { - return kind === 149 || kind === 150; + return kind === 150 || kind === 151; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -32817,7 +32671,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(node, symbol); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 222); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 223); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -32912,18 +32766,18 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 185: + case 186: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; } switch (e.operator) { - case 35: return value_1; - case 36: return -value_1; - case 50: return ~value_1; + case 36: return value_1; + case 37: return -value_1; + case 51: return ~value_1; } return undefined; - case 187: + case 188: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -32933,37 +32787,37 @@ var ts; return undefined; } switch (e.operatorToken.kind) { - 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 39: return left / right; - case 35: return left + right; - case 36: return left - right; - case 40: return left % right; + case 48: return left | right; + case 47: return left & right; + case 45: return left >> right; + case 46: return left >>> right; + case 44: return left << right; + case 49: return left ^ right; + case 38: return left * right; + case 40: return left / right; + case 36: return left + right; + case 37: return left - right; + case 41: return left % right; } return undefined; case 8: return +e.text; - case 178: + case 179: return evalConstant(e.expression); - case 69: + case 70: + case 174: case 173: - case 172: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; var propertyName = void 0; - if (e.kind === 69) { + if (e.kind === 70) { enumType_1 = currentType; propertyName = e.text; } else { var expression = void 0; - if (e.kind === 173) { + if (e.kind === 174) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9) { return undefined; @@ -32977,10 +32831,10 @@ var ts; } var current = expression; while (current) { - if (current.kind === 69) { + if (current.kind === 70) { break; } - else if (current.kind === 172) { + else if (current.kind === 173) { current = current.expression; } else { @@ -33040,7 +32894,7 @@ var ts; } var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 224) { + if (declaration.kind !== 225) { return false; } var enumDeclaration = declaration; @@ -33063,8 +32917,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { var declaration = declarations_5[_i]; - if ((declaration.kind === 221 || - (declaration.kind === 220 && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 222 || + (declaration.kind === 221 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -33123,7 +32977,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, 221); + var mergedClass = ts.getDeclarationOfKind(symbol, 222); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -33166,36 +33020,36 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 200: + case 201: for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 235: case 236: + case 237: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 229: case 230: + case 231: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 169: - case 218: - var name_25 = node.name; - if (ts.isBindingPattern(name_25)) { - for (var _b = 0, _c = name_25.elements; _b < _c.length; _b++) { + case 170: + case 219: + var name_22 = node.name; + if (ts.isBindingPattern(name_22)) { + for (var _b = 0, _c = name_22.elements; _b < _c.length; _b++) { var el = _c[_b]; checkModuleAugmentationElement(el, isGlobalAugmentation); } break; } - case 221: - case 224: - case 220: case 222: case 225: + case 221: case 223: + case 226: + case 224: if (isGlobalAugmentation) { return; } @@ -33211,17 +33065,17 @@ var ts; } function getFirstIdentifier(node) { switch (node.kind) { - case 69: + case 70: return node; - case 139: + case 140: do { node = node.left; - } while (node.kind !== 69); + } while (node.kind !== 70); return node; - case 172: + case 173: do { node = node.expression; - } while (node.kind !== 69); + } while (node.kind !== 70); return node; } } @@ -33231,9 +33085,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 226 && ts.isAmbientModule(node.parent.parent); + var inAmbientExternalModule = node.parent.kind === 227 && ts.isAmbientModule(node.parent.parent); if (node.parent.kind !== 256 && !inAmbientExternalModule) { - error(moduleName, node.kind === 236 ? + error(moduleName, node.kind === 237 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -33254,7 +33108,7 @@ var ts; (symbol.flags & 793064 ? 793064 : 0) | (symbol.flags & 1920 ? 1920 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 238 ? + var message = node.kind === 239 ? 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)); @@ -33281,7 +33135,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 232) { + if (importClause.namedBindings.kind === 233) { checkImportBinding(importClause.namedBindings); } else { @@ -33316,7 +33170,7 @@ var ts; } } else { - if (modulekind === ts.ModuleKind.ES6 && !ts.isInAmbientContext(node)) { + if (modulekind === ts.ModuleKind.ES2015 && !ts.isInAmbientContext(node)) { grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } } @@ -33332,7 +33186,7 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 226 && ts.isAmbientModule(node.parent.parent); + var inAmbientExternalModule = node.parent.kind === 227 && ts.isAmbientModule(node.parent.parent); if (node.parent.kind !== 256 && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } @@ -33346,7 +33200,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 256 || node.parent.kind === 226 || node.parent.kind === 225; + var isInAppropriateContext = node.parent.kind === 256 || node.parent.kind === 227 || node.parent.kind === 226; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -33370,14 +33224,14 @@ var ts; return; } var container = node.parent.kind === 256 ? node.parent : node.parent.parent; - if (container.kind === 225 && !ts.isAmbientModule(container)) { + if (container.kind === 226 && !ts.isAmbientModule(container)) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.getModifierFlags(node) !== 0) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 69) { + if (node.expression.kind === 70) { markExportAsReferenced(node); } else { @@ -33385,7 +33239,7 @@ var ts; } checkExternalModuleExports(container); if (node.isExportEquals && !ts.isInAmbientContext(node)) { - if (modulekind === ts.ModuleKind.ES6) { + if (modulekind === ts.ModuleKind.ES2015) { grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_export_default_or_another_module_format_instead); } else if (modulekind === ts.ModuleKind.System) { @@ -33437,7 +33291,7 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return (declaration.kind !== 220 && declaration.kind !== 147) || + return (declaration.kind !== 221 && declaration.kind !== 148) || !!declaration.body; } } @@ -33448,118 +33302,118 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { - case 225: - case 221: + case 226: case 222: - case 220: + case 223: + case 221: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 141: - return checkTypeParameter(node); case 142: + return checkTypeParameter(node); + case 143: return checkParameter(node); + case 146: case 145: - case 144: return checkPropertyDeclaration(node); - case 156: case 157: - case 151: + case 158: case 152: - return checkSignatureDeclaration(node); case 153: return checkSignatureDeclaration(node); - case 147: - case 146: - return checkMethodDeclaration(node); - case 148: - return checkConstructorDeclaration(node); - case 149: - case 150: - return checkAccessorDeclaration(node); - case 155: - return checkTypeReferenceNode(node); case 154: + return checkSignatureDeclaration(node); + case 148: + case 147: + return checkMethodDeclaration(node); + case 149: + return checkConstructorDeclaration(node); + case 150: + case 151: + return checkAccessorDeclaration(node); + case 156: + return checkTypeReferenceNode(node); + case 155: return checkTypePredicate(node); - case 158: - return checkTypeQuery(node); case 159: - return checkTypeLiteral(node); + return checkTypeQuery(node); case 160: - return checkArrayType(node); + return checkTypeLiteral(node); case 161: - return checkTupleType(node); + return checkArrayType(node); case 162: + return checkTupleType(node); case 163: - return checkUnionOrIntersectionType(node); case 164: + return checkUnionOrIntersectionType(node); + case 165: return checkSourceElement(node.type); - case 220: - return checkFunctionDeclaration(node); - case 199: - case 226: - return checkBlock(node); - case 200: - return checkVariableStatement(node); - case 202: - return checkExpressionStatement(node); - case 203: - return checkIfStatement(node); - case 204: - return checkDoStatement(node); - case 205: - return checkWhileStatement(node); - case 206: - return checkForStatement(node); - case 207: - return checkForInStatement(node); - case 208: - return checkForOfStatement(node); - case 209: - case 210: - return checkBreakOrContinueStatement(node); - case 211: - return checkReturnStatement(node); - case 212: - return checkWithStatement(node); - case 213: - return checkSwitchStatement(node); - case 214: - return checkLabeledStatement(node); - case 215: - return checkThrowStatement(node); - case 216: - return checkTryStatement(node); - case 218: - return checkVariableDeclaration(node); - case 169: - return checkBindingElement(node); case 221: - return checkClassDeclaration(node); - case 222: - return checkInterfaceDeclaration(node); - case 223: - return checkTypeAliasDeclaration(node); - case 224: - return checkEnumDeclaration(node); - case 225: - return checkModuleDeclaration(node); - case 230: - return checkImportDeclaration(node); - case 229: - return checkImportEqualsDeclaration(node); - case 236: - return checkExportDeclaration(node); - case 235: - return checkExportAssignment(node); + return checkFunctionDeclaration(node); + case 200: + case 227: + return checkBlock(node); case 201: - checkGrammarStatementInAmbientContext(node); - return; + return checkVariableStatement(node); + case 203: + return checkExpressionStatement(node); + case 204: + return checkIfStatement(node); + case 205: + return checkDoStatement(node); + case 206: + return checkWhileStatement(node); + case 207: + return checkForStatement(node); + case 208: + return checkForInStatement(node); + case 209: + return checkForOfStatement(node); + case 210: + case 211: + return checkBreakOrContinueStatement(node); + case 212: + return checkReturnStatement(node); + case 213: + return checkWithStatement(node); + case 214: + return checkSwitchStatement(node); + case 215: + return checkLabeledStatement(node); + case 216: + return checkThrowStatement(node); case 217: + return checkTryStatement(node); + case 219: + return checkVariableDeclaration(node); + case 170: + return checkBindingElement(node); + case 222: + return checkClassDeclaration(node); + case 223: + return checkInterfaceDeclaration(node); + case 224: + return checkTypeAliasDeclaration(node); + case 225: + return checkEnumDeclaration(node); + case 226: + return checkModuleDeclaration(node); + case 231: + return checkImportDeclaration(node); + case 230: + return checkImportEqualsDeclaration(node); + case 237: + return checkExportDeclaration(node); + case 236: + return checkExportAssignment(node); + case 202: checkGrammarStatementInAmbientContext(node); return; - case 239: + case 218: + checkGrammarStatementInAmbientContext(node); + return; + case 240: return checkMissingDeclaration(node); } } @@ -33572,17 +33426,17 @@ var ts; for (var _i = 0, deferredNodes_1 = deferredNodes; _i < deferredNodes_1.length; _i++) { var node = deferredNodes_1[_i]; switch (node.kind) { - case 179: case 180: + case 181: + case 148: case 147: - case 146: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 149: case 150: + case 151: checkAccessorDeferred(node); break; - case 192: + case 193: checkClassExpressionDeferred(node); break; } @@ -33654,7 +33508,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 212 && node.parent.statement === node) { + if (node.parent.kind === 213 && node.parent.statement === node) { return true; } node = node.parent; @@ -33680,24 +33534,24 @@ var ts; if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 225: + case 226: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 224: + case 225: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 192: + case 193: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 221: case 222: + case 223: if (!(memberFlags & 32)) { copySymbols(getSymbolOfNode(location).members, meaning & 793064); } break; - case 179: + case 180: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -33730,33 +33584,33 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 69 && + return name.kind === 70 && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 141: - case 221: + case 142: case 222: case 223: case 224: + case 225: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 139) { + while (node.parent && node.parent.kind === 140) { node = node.parent; } - return node.parent && (node.parent.kind === 155 || node.parent.kind === 267); + return node.parent && (node.parent.kind === 156 || node.parent.kind === 267); } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 172) { + while (node.parent && node.parent.kind === 173) { node = node.parent; } - return node.parent && node.parent.kind === 194; + return node.parent && node.parent.kind === 195; } function forEachEnclosingClass(node, callback) { var result; @@ -33773,13 +33627,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 139) { + while (nodeOnRightSide.parent.kind === 140) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 229) { + if (nodeOnRightSide.parent.kind === 230) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 235) { + if (nodeOnRightSide.parent.kind === 236) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -33791,7 +33645,7 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 172) { + if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 173) { var specialPropertyAssignmentKind = ts.getSpecialPropertyAssignmentKind(entityName.parent.parent); switch (specialPropertyAssignmentKind) { case 1: @@ -33803,20 +33657,20 @@ var ts; default: } } - if (entityName.parent.kind === 235 && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 236 && ts.isEntityNameExpression(entityName)) { return resolveEntityName(entityName, 107455 | 793064 | 1920 | 8388608); } - if (entityName.kind !== 172 && isInRightSideOfImportOrExportAssignment(entityName)) { - var importEqualsDeclaration = ts.getAncestor(entityName, 229); + if (entityName.kind !== 173 && isInRightSideOfImportOrExportAssignment(entityName)) { + var importEqualsDeclaration = ts.getAncestor(entityName, 230); ts.Debug.assert(importEqualsDeclaration !== undefined); - return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importEqualsDeclaration, true); + return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, true); } if (ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0; - if (entityName.parent.kind === 194) { + if (entityName.parent.kind === 195) { meaning = 793064; if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning |= 107455; @@ -33832,20 +33686,20 @@ var ts; if (ts.nodeIsMissing(entityName)) { return undefined; } - if (entityName.kind === 69) { + if (entityName.kind === 70) { if (ts.isJSXTagName(entityName) && isJsxIntrinsicIdentifier(entityName)) { return getIntrinsicTagSymbol(entityName.parent); } return resolveEntityName(entityName, 107455, false, true); } - else if (entityName.kind === 172) { + else if (entityName.kind === 173) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 139) { + else if (entityName.kind === 140) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -33854,13 +33708,13 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = (entityName.parent.kind === 155 || entityName.parent.kind === 267) ? 793064 : 1920; + var meaning = (entityName.parent.kind === 156 || entityName.parent.kind === 267) ? 793064 : 1920; return resolveEntityName(entityName, meaning, false, true); } else if (entityName.parent.kind === 246) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 154) { + if (entityName.parent.kind === 155) { return resolveEntityName(entityName, 1); } return undefined; @@ -33878,12 +33732,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(node.parent.parent); } - if (node.kind === 69) { + if (node.kind === 70) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (node.parent.kind === 169 && - node.parent.parent.kind === 167 && + else if (node.parent.kind === 170 && + node.parent.parent.kind === 168 && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -33893,11 +33747,11 @@ var ts; } } switch (node.kind) { - case 69: - case 172: - case 139: + case 70: + case 173: + case 140: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 97: + case 98: var container = ts.getThisContainer(node, false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -33905,21 +33759,21 @@ var ts; return sig.thisParameter; } } - case 95: + case 96: var type = ts.isPartOfExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 165: + case 166: return getTypeFromTypeNode(node).symbol; - case 121: + case 122: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 148) { + if (constructorDeclaration && constructorDeclaration.kind === 149) { return constructorDeclaration.parent.symbol; } return undefined; case 9: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 230 || node.parent.kind === 236) && + ((node.parent.kind === 231 || node.parent.kind === 237) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } @@ -33927,7 +33781,7 @@ var ts; return resolveExternalModuleName(node, node); } case 8: - if (node.parent.kind === 173 && node.parent.argumentExpression === node) { + if (node.parent.kind === 174 && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -33991,12 +33845,12 @@ var ts; return unknownType; } function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 171 || expr.kind === 170); - if (expr.parent.kind === 208) { + ts.Debug.assert(expr.kind === 172 || expr.kind === 171); + if (expr.parent.kind === 209) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression); return checkDestructuringAssignment(expr, iteratedType || unknownType); } - if (expr.parent.kind === 187) { + if (expr.parent.kind === 188) { var iteratedType = checkExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || unknownType); } @@ -34004,7 +33858,7 @@ var ts; var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent); } - ts.Debug.assert(expr.parent.kind === 170); + ts.Debug.assert(expr.parent.kind === 171); var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, false) || unknownType; return checkArrayLiteralDestructuringElementAssignment(expr.parent, typeOfArrayLiteral, ts.indexOf(expr.parent.elements, expr), elementType || unknownType); @@ -34040,9 +33894,9 @@ var ts; function getRootSymbols(symbol) { if (symbol.flags & 268435456) { var symbols_3 = []; - var name_26 = symbol.name; + var name_23 = symbol.name; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - var symbol = getPropertyOfType(t, name_26); + var symbol = getPropertyOfType(t, name_23); if (symbol) { symbols_3.push(symbol); } @@ -34145,7 +33999,7 @@ var ts; else if (nodeLinks_1.flags & 131072) { var isDeclaredInLoop = nodeLinks_1.flags & 262144; var inLoopInitializer = ts.isIterationStatement(container, false); - var inLoopBodyBlock = container.kind === 199 && ts.isIterationStatement(container.parent, false); + var inLoopBodyBlock = container.kind === 200 && ts.isIterationStatement(container.parent, false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -34185,18 +34039,18 @@ var ts; return true; } switch (node.kind) { - case 229: - case 231: + case 230: case 232: - case 234: - case 238: + case 233: + case 235: + case 239: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 236: + case 237: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 235: + case 236: return node.expression - && node.expression.kind === 69 + && node.expression.kind === 70 ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : true; } @@ -34428,7 +34282,7 @@ var ts; if (!fileToDirective) { return undefined; } - var meaning = (node.kind === 172) || (node.kind === 69 && isInTypeQuery(node)) + var meaning = (node.kind === 173) || (node.kind === 70 && isInTypeQuery(node)) ? 107455 | 1048576 : 793064 | 1920; var symbol = resolveEntityName(node, meaning, true); @@ -34575,6 +34429,7 @@ var ts; getGlobalIterableIteratorType = ts.memoize(function () { return emptyGenericType; }); } anyArrayType = createArrayType(anyType); + autoArrayType = createArrayType(autoType); var symbol = getGlobalSymbol("ReadonlyArray", 793064, undefined); globalReadonlyArrayType = symbol && getTypeOfGlobalSymbol(symbol, 1); anyReadonlyArrayType = globalReadonlyArrayType ? createTypeFromGenericGlobalType(globalReadonlyArrayType, [anyType]) : anyArrayType; @@ -34634,14 +34489,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node)) { - if (node.kind === 147 && !ts.nodeIsPresent(node.body)) { + if (node.kind === 148 && !ts.nodeIsPresent(node.body)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload); } else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } } - else if (node.kind === 149 || node.kind === 150) { + else if (node.kind === 150 || node.kind === 151) { 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); @@ -34658,28 +34513,28 @@ var ts; var flags = 0; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 128) { - if (node.kind === 144 || node.kind === 146) { + if (modifier.kind !== 129) { + if (node.kind === 145 || node.kind === 147) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 153) { + if (node.kind === 154) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 74: - if (node.kind !== 224 && node.parent.kind === 221) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(74)); + case 75: + if (node.kind !== 225 && node.parent.kind === 222) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(75)); } break; + case 113: case 112: case 111: - case 110: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); - if (modifier.kind === 111) { + if (modifier.kind === 112) { lastProtected = modifier; } - else if (modifier.kind === 110) { + else if (modifier.kind === 111) { lastPrivate = modifier; } if (flags & 28) { @@ -34694,11 +34549,11 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 226 || node.parent.kind === 256) { + else if (node.parent.kind === 227 || node.parent.kind === 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128) { - if (modifier.kind === 110) { + if (modifier.kind === 111) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -34707,7 +34562,7 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 113: + case 114: if (flags & 32) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } @@ -34717,10 +34572,10 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 226 || node.parent.kind === 256) { + else if (node.parent.kind === 227 || node.parent.kind === 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 142) { + else if (node.kind === 143) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128) { @@ -34729,17 +34584,17 @@ var ts; flags |= 32; lastStatic = modifier; break; - case 128: + case 129: if (flags & 64) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 145 && node.kind !== 144 && node.kind !== 153 && node.kind !== 142) { + else if (node.kind !== 146 && node.kind !== 145 && node.kind !== 154 && node.kind !== 143) { return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } flags |= 64; lastReadonly = modifier; break; - case 82: + case 83: if (flags & 1) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -34752,45 +34607,45 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 221) { + else if (node.parent.kind === 222) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 142) { + else if (node.kind === 143) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; break; - case 122: + case 123: if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 221) { + else if (node.parent.kind === 222) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 142) { + else if (node.kind === 143) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 226) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 227) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; lastDeclare = modifier; break; - case 115: + case 116: if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 221) { - if (node.kind !== 147 && - node.kind !== 145 && - node.kind !== 149 && - node.kind !== 150) { + if (node.kind !== 222) { + if (node.kind !== 148 && + node.kind !== 146 && + node.kind !== 150 && + node.kind !== 151) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 221 && ts.getModifierFlags(node.parent) & 128)) { + if (!(node.parent.kind === 222 && ts.getModifierFlags(node.parent) & 128)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32) { @@ -34802,14 +34657,14 @@ var ts; } flags |= 128; break; - case 118: + case 119: if (flags & 256) { 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 === 142) { + else if (node.kind === 143) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256; @@ -34817,7 +34672,7 @@ var ts; break; } } - if (node.kind === 148) { + if (node.kind === 149) { if (flags & 32) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -34832,13 +34687,13 @@ var ts; } return; } - else if ((node.kind === 230 || node.kind === 229) && flags & 2) { + else if ((node.kind === 231 || node.kind === 230) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 142 && (flags & 92) && ts.isBindingPattern(node.name)) { + else if (node.kind === 143 && (flags & 92) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 142 && (flags & 92) && node.dotDotDotToken) { + else if (node.kind === 143 && (flags & 92) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256) { @@ -34854,38 +34709,38 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 149: case 150: - case 148: - case 145: - case 144: - case 147: + case 151: + case 149: case 146: - case 153: - case 225: + case 145: + case 148: + case 147: + case 154: + case 226: + case 231: case 230: - case 229: + case 237: case 236: - case 235: - case 179: case 180: - case 142: + case 181: + case 143: return false; default: - if (node.parent.kind === 226 || node.parent.kind === 256) { + if (node.parent.kind === 227 || node.parent.kind === 256) { return false; } switch (node.kind) { - case 220: - return nodeHasAnyModifiersExcept(node, 118); case 221: - return nodeHasAnyModifiersExcept(node, 115); + return nodeHasAnyModifiersExcept(node, 119); case 222: - case 200: + return nodeHasAnyModifiersExcept(node, 116); case 223: - return true; + case 201: case 224: - return nodeHasAnyModifiersExcept(node, 74); + return true; + case 225: + return nodeHasAnyModifiersExcept(node, 75); default: ts.Debug.fail(); return false; @@ -34897,10 +34752,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 147: - case 220: - case 179: + case 148: + case 221: case 180: + case 181: if (!node.asteriskToken) { return false; } @@ -34916,7 +34771,7 @@ var ts; return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Trailing_comma_not_allowed); } } - function checkGrammarTypeParameterList(node, typeParameters, file) { + function checkGrammarTypeParameterList(typeParameters, file) { if (checkGrammarForDisallowedTrailingComma(typeParameters)) { return true; } @@ -34958,11 +34813,11 @@ var ts; } function checkGrammarFunctionLikeDeclaration(node) { var file = ts.getSourceFileOfNode(node); - return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node, node.typeParameters, file) || + return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node.typeParameters, file) || checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 180) { + if (node.kind === 181) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -34997,7 +34852,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 !== 132 && parameter.type.kind !== 130) { + if (parameter.type.kind !== 133 && parameter.type.kind !== 131) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -35024,7 +34879,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 193) { + if (arg.kind === 194) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -35050,7 +34905,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 === 83) { + if (heritageClause.token === 84) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -35063,7 +34918,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 106); + ts.Debug.assert(heritageClause.token === 107); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -35078,14 +34933,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 83) { + if (heritageClause.token === 84) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 106); + ts.Debug.assert(heritageClause.token === 107); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } checkGrammarHeritageClause(heritageClause); @@ -35094,19 +34949,19 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 140) { + if (node.kind !== 141) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 187 && computedPropertyName.expression.operatorToken.kind === 24) { + if (computedPropertyName.expression.kind === 188 && computedPropertyName.expression.operatorToken.kind === 25) { 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 === 220 || - node.kind === 179 || - node.kind === 147); + ts.Debug.assert(node.kind === 221 || + node.kind === 180 || + node.kind === 148); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -35118,7 +34973,7 @@ var ts; } } } - function checkGrammarForInvalidQuestionMark(node, questionToken, message) { + function checkGrammarForInvalidQuestionMark(questionToken, message) { if (questionToken) { return grammarErrorOnNode(questionToken, message); } @@ -35131,9 +34986,9 @@ var ts; var GetOrSetAccessor = GetAccessor | SetAccessor; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - var name_27 = prop.name; - if (name_27.kind === 140) { - checkGrammarComputedPropertyName(name_27); + var name_24 = prop.name; + if (name_24.kind === 141) { + checkGrammarComputedPropertyName(name_24); } if (prop.kind === 254 && !inDestructuring && prop.objectAssignmentInitializer) { return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); @@ -35141,32 +34996,32 @@ var ts; if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (mod.kind !== 118 || prop.kind !== 147) { + if (mod.kind !== 119 || prop.kind !== 148) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } } var currentKind = void 0; if (prop.kind === 253 || prop.kind === 254) { - checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_27.kind === 8) { - checkGrammarNumericLiteral(name_27); + checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); + if (name_24.kind === 8) { + checkGrammarNumericLiteral(name_24); } currentKind = Property; } - else if (prop.kind === 147) { + else if (prop.kind === 148) { currentKind = Property; } - else if (prop.kind === 149) { + else if (prop.kind === 150) { currentKind = GetAccessor; } - else if (prop.kind === 150) { + else if (prop.kind === 151) { currentKind = SetAccessor; } else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - var effectiveName = ts.getPropertyNameForPropertyNameNode(name_27); + var effectiveName = ts.getPropertyNameForPropertyNameNode(name_24); if (effectiveName === undefined) { continue; } @@ -35176,18 +35031,18 @@ var ts; else { var existingKind = seen[effectiveName]; if (currentKind === Property && existingKind === Property) { - grammarErrorOnNode(name_27, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_27)); + grammarErrorOnNode(name_24, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_24)); } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { seen[effectiveName] = currentKind | existingKind; } else { - return grammarErrorOnNode(name_27, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name_24, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name_27, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name_24, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } @@ -35200,12 +35055,12 @@ var ts; continue; } var jsxAttr = attr; - var name_28 = jsxAttr.name; - if (!seen[name_28.text]) { - seen[name_28.text] = true; + var name_25 = jsxAttr.name; + if (!seen[name_25.text]) { + seen[name_25.text] = true; } else { - return grammarErrorOnNode(name_28, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + return grammarErrorOnNode(name_25, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; if (initializer && initializer.kind === 248 && !initializer.expression) { @@ -35217,7 +35072,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 219) { + if (forInOrOfStatement.initializer.kind === 220) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -35225,20 +35080,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 207 + var diagnostic = forInOrOfStatement.kind === 208 ? 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 = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 207 + var diagnostic = forInOrOfStatement.kind === 208 ? 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 === 207 + var diagnostic = forInOrOfStatement.kind === 208 ? 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); @@ -35262,11 +35117,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 149 ? + return grammarErrorOnNode(accessor.name, kind === 150 ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 150) { + else if (kind === 151) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -35285,10 +35140,10 @@ var ts; } } function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 149 ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 150 ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 149 ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 150 ? 1 : 2)) { return ts.getThisParameter(accessor); } } @@ -35303,8 +35158,8 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 171) { - if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { + if (node.parent.kind === 172) { + if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { return true; } else if (node.body === undefined) { @@ -35319,10 +35174,10 @@ 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 === 222) { + else if (node.parent.kind === 223) { 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 === 159) { + else if (node.parent.kind === 160) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } @@ -35333,9 +35188,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 214: + case 215: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 209 + var isMisplacedContinueLabel = node.kind === 210 && !ts.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); @@ -35343,8 +35198,8 @@ var ts; return false; } break; - case 213: - if (node.kind === 210 && !node.label) { + case 214: + if (node.kind === 211 && !node.label) { return false; } break; @@ -35357,13 +35212,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 210 + var message = node.kind === 211 ? 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 === 210 + var message = node.kind === 211 ? 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); @@ -35375,7 +35230,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 === 168 || node.name.kind === 167) { + if (node.name.kind === 169 || node.name.kind === 168) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -35385,11 +35240,11 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 || expr.kind === 8 || - expr.kind === 185 && expr.operator === 36 && + expr.kind === 186 && expr.operator === 37 && expr.operand.kind === 8; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 207 && node.parent.parent.kind !== 208) { + if (node.parent.parent.kind !== 208 && node.parent.parent.kind !== 209) { if (ts.isInAmbientContext(node)) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -35420,8 +35275,8 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 69) { - if (name.originalKeywordKind === 108) { + if (name.kind === 70) { + if (name.originalKeywordKind === 109) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -35446,15 +35301,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 203: case 204: case 205: - case 212: case 206: + case 213: case 207: case 208: + case 209: return false; - case 214: + case 215: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -35509,7 +35364,7 @@ var ts; return true; } } - else if (node.parent.kind === 222) { + else if (node.parent.kind === 223) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -35517,7 +35372,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 159) { + else if (node.parent.kind === 160) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -35530,13 +35385,13 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 222 || - node.kind === 223 || + if (node.kind === 223 || + node.kind === 224 || + node.kind === 231 || node.kind === 230 || - node.kind === 229 || + node.kind === 237 || node.kind === 236 || - node.kind === 235 || - node.kind === 228 || + node.kind === 229 || ts.getModifierFlags(node) & (2 | 1 | 512)) { return false; } @@ -35545,7 +35400,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 === 200) { + if (ts.isDeclaration(decl) || decl.kind === 201) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -35564,7 +35419,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 === 199 || node.parent.kind === 226 || node.parent.kind === 256) { + if (node.parent.kind === 200 || node.parent.kind === 227 || node.parent.kind === 256) { 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); @@ -35603,46 +35458,46 @@ var ts; (function (ts) { ; var nodeEdgeTraversalMap = ts.createMap((_a = {}, - _a[139] = [ + _a[140] = [ { name: "left", test: ts.isEntityName }, { name: "right", test: ts.isIdentifier } ], - _a[143] = [ + _a[144] = [ { name: "expression", test: ts.isLeftHandSideExpression } ], - _a[177] = [ + _a[178] = [ { name: "type", test: ts.isTypeNode }, { name: "expression", test: ts.isUnaryExpression } ], - _a[195] = [ + _a[196] = [ { name: "expression", test: ts.isExpression }, { name: "type", test: ts.isTypeNode } ], - _a[196] = [ + _a[197] = [ { name: "expression", test: ts.isLeftHandSideExpression } ], - _a[224] = [ + _a[225] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "members", test: ts.isEnumMember } ], - _a[225] = [ + _a[226] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isModuleName }, { name: "body", test: ts.isModuleBody } ], - _a[226] = [ + _a[227] = [ { name: "statements", test: ts.isStatement } ], - _a[229] = [ + _a[230] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "moduleReference", test: ts.isModuleReference } ], - _a[240] = [ + _a[241] = [ { name: "expression", test: ts.isExpression, optional: true } ], _a[255] = [ @@ -35658,41 +35513,41 @@ var ts; return initial; } var kind = node.kind; - if ((kind > 0 && kind <= 138)) { + if ((kind > 0 && kind <= 139)) { return initial; } - if ((kind >= 154 && kind <= 166)) { + if ((kind >= 155 && kind <= 167)) { return initial; } var result = initial; switch (node.kind) { - case 198: - case 201: - case 193: - case 217: + case 199: + case 202: + case 194: + case 218: case 287: break; - case 140: + case 141: result = reduceNode(node.expression, f, result); break; - case 142: - result = ts.reduceLeft(node.decorators, f, result); - result = ts.reduceLeft(node.modifiers, f, result); - result = reduceNode(node.name, f, result); - result = reduceNode(node.type, f, result); - result = reduceNode(node.initializer, f, result); - break; case 143: - result = reduceNode(node.expression, f, result); - break; - case 145: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.initializer, f, result); break; - case 147: + case 144: + result = reduceNode(node.expression, f, result); + break; + case 146: + result = ts.reduceLeft(node.decorators, f, result); + result = ts.reduceLeft(node.modifiers, f, result); + result = reduceNode(node.name, f, result); + result = reduceNode(node.type, f, result); + result = reduceNode(node.initializer, f, result); + break; + case 148: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -35701,53 +35556,48 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 148: - result = ts.reduceLeft(node.modifiers, f, result); - result = ts.reduceLeft(node.parameters, f, result); - result = reduceNode(node.body, f, result); - break; case 149: - result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); - result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.parameters, f, result); - result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; case 150: + result = ts.reduceLeft(node.decorators, f, result); + result = ts.reduceLeft(node.modifiers, f, result); + result = reduceNode(node.name, f, result); + result = ts.reduceLeft(node.parameters, f, result); + result = reduceNode(node.type, f, result); + result = reduceNode(node.body, f, result); + break; + case 151: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.parameters, f, result); result = reduceNode(node.body, f, result); break; - case 167: case 168: + case 169: result = ts.reduceLeft(node.elements, f, result); break; - case 169: + case 170: result = reduceNode(node.propertyName, f, result); result = reduceNode(node.name, f, result); result = reduceNode(node.initializer, f, result); break; - case 170: + case 171: result = ts.reduceLeft(node.elements, f, result); break; - case 171: - result = ts.reduceLeft(node.properties, f, result); - break; case 172: - result = reduceNode(node.expression, f, result); - result = reduceNode(node.name, f, result); + result = ts.reduceLeft(node.properties, f, result); break; case 173: result = reduceNode(node.expression, f, result); - result = reduceNode(node.argumentExpression, f, result); + result = reduceNode(node.name, f, result); break; case 174: result = reduceNode(node.expression, f, result); - result = ts.reduceLeft(node.typeArguments, f, result); - result = ts.reduceLeft(node.arguments, f, result); + result = reduceNode(node.argumentExpression, f, result); break; case 175: result = reduceNode(node.expression, f, result); @@ -35755,10 +35605,15 @@ var ts; result = ts.reduceLeft(node.arguments, f, result); break; case 176: + result = reduceNode(node.expression, f, result); + result = ts.reduceLeft(node.typeArguments, f, result); + result = ts.reduceLeft(node.arguments, f, result); + break; + case 177: result = reduceNode(node.tag, f, result); result = reduceNode(node.template, f, result); break; - case 179: + case 180: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.typeParameters, f, result); @@ -35766,126 +35621,126 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 180: + case 181: result = ts.reduceLeft(node.modifiers, f, result); result = ts.reduceLeft(node.typeParameters, f, result); result = ts.reduceLeft(node.parameters, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 178: - case 181: + case 179: case 182: case 183: case 184: - case 190: + case 185: case 191: - case 196: + case 192: + case 197: result = reduceNode(node.expression, f, result); break; - case 185: case 186: + case 187: result = reduceNode(node.operand, f, result); break; - case 187: + case 188: result = reduceNode(node.left, f, result); result = reduceNode(node.right, f, result); break; - case 188: + case 189: result = reduceNode(node.condition, f, result); result = reduceNode(node.whenTrue, f, result); result = reduceNode(node.whenFalse, f, result); break; - case 189: + case 190: result = reduceNode(node.head, f, result); result = ts.reduceLeft(node.templateSpans, f, result); break; - case 192: + case 193: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.typeParameters, f, result); result = ts.reduceLeft(node.heritageClauses, f, result); result = ts.reduceLeft(node.members, f, result); break; - case 194: + case 195: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); break; - case 197: + case 198: result = reduceNode(node.expression, f, result); result = reduceNode(node.literal, f, result); break; - case 199: + case 200: result = ts.reduceLeft(node.statements, f, result); break; - case 200: + case 201: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.declarationList, f, result); break; - case 202: + case 203: result = reduceNode(node.expression, f, result); break; - case 203: + case 204: result = reduceNode(node.expression, f, result); result = reduceNode(node.thenStatement, f, result); result = reduceNode(node.elseStatement, f, result); break; - case 204: - result = reduceNode(node.statement, f, result); - result = reduceNode(node.expression, f, result); - break; case 205: - case 212: - result = reduceNode(node.expression, f, result); result = reduceNode(node.statement, f, result); + result = reduceNode(node.expression, f, result); break; case 206: + case 213: + result = reduceNode(node.expression, f, result); + result = reduceNode(node.statement, f, result); + break; + case 207: result = reduceNode(node.initializer, f, result); result = reduceNode(node.condition, f, result); result = reduceNode(node.incrementor, f, result); result = reduceNode(node.statement, f, result); break; - case 207: case 208: + case 209: result = reduceNode(node.initializer, f, result); result = reduceNode(node.expression, f, result); result = reduceNode(node.statement, f, result); break; - case 211: - case 215: + case 212: + case 216: result = reduceNode(node.expression, f, result); break; - case 213: + case 214: result = reduceNode(node.expression, f, result); result = reduceNode(node.caseBlock, f, result); break; - case 214: + case 215: result = reduceNode(node.label, f, result); result = reduceNode(node.statement, f, result); break; - case 216: + case 217: result = reduceNode(node.tryBlock, f, result); result = reduceNode(node.catchClause, f, result); result = reduceNode(node.finallyBlock, f, result); break; - case 218: + case 219: result = reduceNode(node.name, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.initializer, f, result); break; - case 219: - result = ts.reduceLeft(node.declarations, f, result); - break; case 220: - result = ts.reduceLeft(node.decorators, f, result); - result = ts.reduceLeft(node.modifiers, f, result); - result = reduceNode(node.name, f, result); - result = ts.reduceLeft(node.typeParameters, f, result); - result = ts.reduceLeft(node.parameters, f, result); - result = reduceNode(node.type, f, result); - result = reduceNode(node.body, f, result); + result = ts.reduceLeft(node.declarations, f, result); break; case 221: + result = ts.reduceLeft(node.decorators, f, result); + result = ts.reduceLeft(node.modifiers, f, result); + result = reduceNode(node.name, f, result); + result = ts.reduceLeft(node.typeParameters, f, result); + result = ts.reduceLeft(node.parameters, f, result); + result = reduceNode(node.type, f, result); + result = reduceNode(node.body, f, result); + break; + case 222: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -35893,49 +35748,49 @@ var ts; result = ts.reduceLeft(node.heritageClauses, f, result); result = ts.reduceLeft(node.members, f, result); break; - case 227: + case 228: result = ts.reduceLeft(node.clauses, f, result); break; - case 230: + case 231: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.importClause, f, result); result = reduceNode(node.moduleSpecifier, f, result); break; - case 231: + case 232: result = reduceNode(node.name, f, result); result = reduceNode(node.namedBindings, f, result); break; - case 232: - result = reduceNode(node.name, f, result); - break; case 233: - case 237: - result = ts.reduceLeft(node.elements, f, result); + result = reduceNode(node.name, f, result); break; case 234: case 238: + result = ts.reduceLeft(node.elements, f, result); + break; + case 235: + case 239: result = reduceNode(node.propertyName, f, result); result = reduceNode(node.name, f, result); break; - case 235: + case 236: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.expression, f, result); break; - case 236: + case 237: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.exportClause, f, result); result = reduceNode(node.moduleSpecifier, f, result); break; - case 241: + case 242: result = reduceNode(node.openingElement, f, result); result = ts.reduceLeft(node.children, f, result); result = reduceNode(node.closingElement, f, result); break; - case 242: case 243: + case 244: result = reduceNode(node.tagName, f, result); result = ts.reduceLeft(node.attributes, f, result); break; @@ -36078,153 +35933,153 @@ var ts; return undefined; } var kind = node.kind; - if ((kind > 0 && kind <= 138)) { + if ((kind > 0 && kind <= 139)) { return node; } - if ((kind >= 154 && kind <= 166)) { + if ((kind >= 155 && kind <= 167)) { return node; } switch (node.kind) { - case 198: - case 201: - case 193: - case 217: - return node; - case 140: - return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); - case 142: - return ts.updateParameterDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 145: - return ts.updateProperty(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 147: - return ts.updateMethod(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); - case 148: - return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); - case 149: - return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); - case 150: - return ts.updateSetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); - case 167: - return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); - case 168: - return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); - case 169: - return ts.updateBindingElement(node, visitNode(node.propertyName, visitor, ts.isPropertyName, true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 170: - return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); - case 171: - return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 172: - return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 173: - return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 174: - return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); - case 175: - return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); - case 176: - return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 178: - return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 179: - return ts.updateFunctionExpression(node, visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); - case 180: - return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isConciseBody, true), context.endLexicalEnvironment())); - case 181: - return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 182: - return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 183: - return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 184: - return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 187: - return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); - case 185: - return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 186: - return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 188: - return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); - case 189: - return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); - case 190: - return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); - case 191: - return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 192: - return ts.updateClassExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 194: - return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 197: - return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); case 199: - return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 200: - return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); case 202: - return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 203: - return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, true, liftToBlock)); - case 204: - return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 205: - return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 206: - return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 207: - return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 208: - return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 209: - return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, true)); - case 210: - return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); - case 211: - return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, true)); - case 212: - return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 213: - return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 214: - return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 215: - return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 216: - return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause, true), visitNode(node.finallyBlock, visitor, ts.isBlock, true)); + case 194: case 218: - return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); + return node; + case 141: + return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); + case 143: + return ts.updateParameterDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); + case 146: + return ts.updateProperty(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); + case 148: + return ts.updateMethod(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + case 149: + return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + case 150: + return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + case 151: + return ts.updateSetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + case 168: + return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); + case 169: + return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); + case 170: + return ts.updateBindingElement(node, visitNode(node.propertyName, visitor, ts.isPropertyName, true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, true)); + case 171: + return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); + case 172: + return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); + case 173: + return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); + case 174: + return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); + case 175: + return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); + case 176: + return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); + case 177: + return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); + case 179: + return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); + case 180: + return ts.updateFunctionExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + case 181: + return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isConciseBody, true), context.endLexicalEnvironment())); + case 182: + return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); + case 183: + return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); + case 184: + return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); + case 185: + return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); + case 188: + return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); + case 186: + return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); + case 187: + return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); + case 189: + return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); + case 190: + return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); + case 191: + return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); + case 192: + return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); + case 193: + return ts.updateClassExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); + case 195: + return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); + case 198: + return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); + case 200: + return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); + case 201: + return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); + case 203: + return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); + case 204: + return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, true, liftToBlock)); + case 205: + return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); + case 206: + return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 207: + return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 208: + return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 209: + return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 210: + return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, true)); + case 211: + return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); + case 212: + return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, true)); + case 213: + return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 214: + return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); + case 215: + return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 216: + return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); + case 217: + return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause, true), visitNode(node.finallyBlock, visitor, ts.isBlock, true)); case 219: - return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); + return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); case 220: - return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); case 221: + return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + case 222: return ts.updateClassDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 227: + case 228: return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 230: - return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); case 231: - return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true)); + return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); case 232: - return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true)); case 233: - return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); + return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); case 234: - return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); case 235: - return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); case 236: - return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, true)); + return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); case 237: - return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); + return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, true)); case 238: + return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); + case 239: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); - case 241: - return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); case 242: - return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); + return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); case 243: + return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); + case 244: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); case 245: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); @@ -36325,67 +36180,67 @@ var ts; return transformFlags | aggregateTransformFlagsForNode(child); } function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 154 && kind <= 166) { + if (kind >= 155 && kind <= 167) { return -3; } switch (kind) { - case 174: case 175: - case 170: - return 537133909; - case 225: - return 546335573; - case 142: - return 538968917; + case 176: + case 171: + return 537922901; + case 226: + return 574729557; + case 143: + return 545262933; + case 181: + return 592227669; case 180: - return 550710101; - case 179: - case 220: - return 550726485; - case 219: - return 538968917; case 221: - case 192: - return 537590613; - case 148: - return 550593365; - case 147: + return 592293205; + case 220: + return 545262933; + case 222: + case 193: + return 539749717; case 149: + return 591760725; + case 148: case 150: - return 550593365; - case 117: - case 130: - case 127: - case 132: - case 120: - case 133: - case 103: - case 141: - case 144: - case 146: case 151: + return 591760725; + case 118: + case 131: + case 128: + case 133: + case 121: + case 134: + case 104: + case 142: + case 145: + case 147: case 152: case 153: - case 222: + case 154: case 223: + case 224: return -3; - case 171: - return 537430869; + case 172: + return 539110741; default: - return 536871765; + return 536874325; } } var Debug; (function (Debug) { Debug.failNotOptional = Debug.shouldAssert(1) ? function (message) { return Debug.assert(false, message || "Node not optional."); } - : function (message) { }; + : function () { }; Debug.failBadSyntaxKind = Debug.shouldAssert(1) ? function (node, message) { return Debug.assert(false, message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " was unexpected."; }); } - : function (node, message) { }; + : function () { }; Debug.assertNode = Debug.shouldAssert(1) ? function (node, test, message) { return Debug.assert(test === undefined || test(node), message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }); } - : function (node, test, message) { }; + : function () { }; function getFunctionName(func) { if (typeof func !== "function") { return ""; @@ -36423,7 +36278,7 @@ var ts; else if (ts.nodeIsSynthesized(node)) { location = value; } - flattenDestructuring(context, node, value, location, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, location, emitAssignment, emitTempVariableAssignment, visitor); if (needsValue) { expressions.push(value); } @@ -36443,9 +36298,9 @@ var ts; } } ts.flattenDestructuringAssignment = flattenDestructuringAssignment; - function flattenParameterDestructuring(context, node, value, visitor) { + function flattenParameterDestructuring(node, value, visitor) { var declarations = []; - flattenDestructuring(context, node, value, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, visitor); return declarations; function emitAssignment(name, value, location) { var declaration = ts.createVariableDeclaration(name, undefined, value, location); @@ -36460,10 +36315,10 @@ var ts; } } ts.flattenParameterDestructuring = flattenParameterDestructuring; - function flattenVariableDestructuring(context, node, value, visitor, recordTempVariable) { + function flattenVariableDestructuring(node, value, visitor, recordTempVariable) { var declarations = []; var pendingAssignments; - flattenDestructuring(context, node, value, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, visitor); return declarations; function emitAssignment(name, value, location, original) { if (pendingAssignments) { @@ -36495,9 +36350,9 @@ var ts; } } ts.flattenVariableDestructuring = flattenVariableDestructuring; - function flattenVariableDestructuringToExpression(context, node, recordTempVariable, nameSubstitution, visitor) { + function flattenVariableDestructuringToExpression(node, recordTempVariable, nameSubstitution, visitor) { var pendingAssignments = []; - flattenDestructuring(context, node, undefined, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, undefined, node, emitAssignment, emitTempVariableAssignment, visitor); var expression = ts.inlineExpressions(pendingAssignments); ts.aggregateTransformFlags(expression); return expression; @@ -36519,7 +36374,7 @@ var ts; } } ts.flattenVariableDestructuringToExpression = flattenVariableDestructuringToExpression; - function flattenDestructuring(context, root, value, location, emitAssignment, emitTempVariableAssignment, visitor) { + function flattenDestructuring(root, value, location, emitAssignment, emitTempVariableAssignment, visitor) { if (value && visitor) { value = ts.visitNode(value, visitor, ts.isExpression); } @@ -36540,7 +36395,7 @@ var ts; } target = bindingTarget.name; } - else if (ts.isBinaryExpression(bindingTarget) && bindingTarget.operatorToken.kind === 56) { + else if (ts.isBinaryExpression(bindingTarget) && bindingTarget.operatorToken.kind === 57) { var initializer = visitor ? ts.visitNode(bindingTarget.right, visitor, ts.isExpression) : bindingTarget.right; @@ -36550,17 +36405,17 @@ var ts; else { target = bindingTarget; } - if (target.kind === 171) { + if (target.kind === 172) { emitObjectLiteralAssignment(target, value, location); } - else if (target.kind === 170) { + else if (target.kind === 171) { emitArrayLiteralAssignment(target, value, location); } else { - var name_29 = ts.getMutableClone(target); - ts.setSourceMapRange(name_29, target); - ts.setCommentRange(name_29, target); - emitAssignment(name_29, value, location, undefined); + var name_26 = ts.getMutableClone(target); + ts.setSourceMapRange(name_26, target); + ts.setCommentRange(name_26, target); + emitAssignment(name_26, value, location, undefined); } } function emitObjectLiteralAssignment(target, value, location) { @@ -36585,8 +36440,8 @@ var ts; } for (var i = 0; i < numElements; i++) { var e = elements[i]; - if (e.kind !== 193) { - if (e.kind !== 191) { + if (e.kind !== 194) { + if (e.kind !== 192) { emitDestructuringAssignment(e, ts.createElementAccess(value, ts.createLiteral(i)), e); } else if (i === numElements - 1) { @@ -36615,7 +36470,7 @@ var ts; if (ts.isOmittedExpression(element)) { continue; } - else if (name.kind === 167) { + else if (name.kind === 168) { var propName = element.propertyName || element.name; emitBindingElement(element, createDestructuringPropertyAccess(value, propName)); } @@ -36635,7 +36490,7 @@ var ts; } function createDefaultValueCheck(value, defaultValue, location) { value = ensureIdentifier(value, true, location, emitTempVariableAssignment); - return ts.createConditional(ts.createStrictEquality(value, ts.createVoidZero()), ts.createToken(53), defaultValue, ts.createToken(54), value); + return ts.createConditional(ts.createStrictEquality(value, ts.createVoidZero()), ts.createToken(54), defaultValue, ts.createToken(55), value); } function createDestructuringPropertyAccess(expression, propertyName) { if (ts.isComputedPropertyName(propertyName)) { @@ -36673,6 +36528,12 @@ var ts; var ts; (function (ts) { var USE_NEW_TYPE_METADATA_FORMAT = false; + var TypeScriptSubstitutionFlags; + (function (TypeScriptSubstitutionFlags) { + TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["ClassAliases"] = 1] = "ClassAliases"; + TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["NamespaceExports"] = 2] = "NamespaceExports"; + TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["NonQualifiedEnumMembers"] = 8] = "NonQualifiedEnumMembers"; + })(TypeScriptSubstitutionFlags || (TypeScriptSubstitutionFlags = {})); function transformTypeScript(context) { var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); @@ -36683,8 +36544,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(172); context.enableSubstitution(173); + context.enableSubstitution(174); var currentSourceFile; var currentNamespace; var currentNamespaceContainerName; @@ -36694,7 +36555,6 @@ var ts; var enabledSubstitutions; var classAliases; var applicableSubstitutions; - var currentSuperContainer; return transformSourceFile; function transformSourceFile(node) { if (ts.isDeclarationFile(node)) { @@ -36728,15 +36588,32 @@ var ts; } return node; } + function sourceElementVisitor(node) { + return saveStateAndInvoke(node, sourceElementVisitorWorker); + } + function sourceElementVisitorWorker(node) { + switch (node.kind) { + case 231: + return visitImportDeclaration(node); + case 230: + return visitImportEqualsDeclaration(node); + case 236: + return visitExportAssignment(node); + case 237: + return visitExportDeclaration(node); + default: + return visitorWorker(node); + } + } function namespaceElementVisitor(node) { return saveStateAndInvoke(node, namespaceElementVisitorWorker); } function namespaceElementVisitorWorker(node) { - if (node.kind === 236 || - node.kind === 230 || + if (node.kind === 237 || node.kind === 231 || - (node.kind === 229 && - node.moduleReference.kind === 240)) { + node.kind === 232 || + (node.kind === 230 && + node.moduleReference.kind === 241)) { return undefined; } else if (node.transformFlags & 1 || ts.hasModifier(node, 1)) { @@ -36752,15 +36629,15 @@ var ts; } function classElementVisitorWorker(node) { switch (node.kind) { - case 148: - return undefined; - case 145: - case 153: case 149: + return undefined; + case 146: + case 154: case 150: - case 147: + case 151: + case 148: return visitorWorker(node); - case 198: + case 199: return node; default: ts.Debug.failBadSyntaxKind(node); @@ -36772,84 +36649,87 @@ var ts; return ts.createNotEmittedStatement(node); } switch (node.kind) { - case 82: - case 77: + case 83: + case 78: return currentNamespace ? undefined : node; - case 112: - case 110: + case 113: case 111: - case 115: - case 118: - case 74: - case 122: - case 128: - case 160: + case 112: + case 116: + case 75: + case 123: + case 129: case 161: - case 159: - case 154: - case 141: - case 117: - case 120: - case 132: - case 130: - case 127: - case 103: - case 133: - case 157: - case 156: - case 158: - case 155: case 162: + case 160: + case 155: + case 142: + case 118: + case 121: + case 133: + case 131: + case 128: + case 104: + case 134: + case 158: + case 157: + case 159: + case 156: case 163: case 164: case 165: case 166: - case 153: - case 143: + case 167: + case 154: + case 144: + case 224: + case 146: + case 149: + return visitConstructor(node); case 223: - case 145: - case 148: - return undefined; - case 222: return ts.createNotEmittedStatement(node); - case 221: + case 222: return visitClassDeclaration(node); - case 192: + case 193: return visitClassExpression(node); case 251: return visitHeritageClause(node); - case 194: - return visitExpressionWithTypeArguments(node); - case 147: - return visitMethodDeclaration(node); - case 149: - return visitGetAccessor(node); - case 150: - return visitSetAccessor(node); - case 220: - return visitFunctionDeclaration(node); - case 179: - return visitFunctionExpression(node); - case 180: - return visitArrowFunction(node); - case 142: - return visitParameter(node); - case 178: - return visitParenthesizedExpression(node); - case 177: case 195: - return visitAssertionExpression(node); + return visitExpressionWithTypeArguments(node); + case 148: + return visitMethodDeclaration(node); + case 150: + return visitGetAccessor(node); + case 151: + return visitSetAccessor(node); + case 221: + return visitFunctionDeclaration(node); + case 180: + return visitFunctionExpression(node); + case 181: + return visitArrowFunction(node); + case 143: + return visitParameter(node); + case 179: + return visitParenthesizedExpression(node); + case 178: case 196: + return visitAssertionExpression(node); + case 175: + return visitCallExpression(node); + case 176: + return visitNewExpression(node); + case 197: return visitNonNullExpression(node); - case 224: - return visitEnumDeclaration(node); - case 184: - return visitAwaitExpression(node); - case 200: - return visitVariableStatement(node); case 225: + return visitEnumDeclaration(node); + case 201: + return visitVariableStatement(node); + case 219: + return visitVariableDeclaration(node); + case 226: return visitModuleDeclaration(node); - case 229: + case 230: return visitImportEqualsDeclaration(node); default: ts.Debug.failBadSyntaxKind(node); @@ -36859,14 +36739,14 @@ var ts; function onBeforeVisitNode(node) { switch (node.kind) { case 256: + case 228: case 227: - case 226: - case 199: + case 200: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; + case 222: case 221: - case 220: if (ts.hasModifier(node, 2)) { break; } @@ -36891,14 +36771,14 @@ var ts; externalHelpersModuleImport.flags &= ~8; statements.push(externalHelpersModuleImport); currentSourceFileExternalHelpersModuleName = externalHelpersModuleName; - ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); + ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); currentSourceFileExternalHelpersModuleName = undefined; node = ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); node.externalHelpersModuleName = externalHelpersModuleName; } else { - node = ts.visitEachChild(node, visitor, context); + node = ts.visitEachChild(node, sourceElementVisitor, context); } ts.setEmitFlags(node, 1 | ts.getEmitFlags(node)); return node; @@ -36938,7 +36818,7 @@ var ts; classAlias = addClassDeclarationHeadWithDecorators(statements, node, name, hasExtendsClause); } if (staticProperties.length) { - addInitializedPropertyStatements(statements, node, staticProperties, getLocalName(node, true)); + addInitializedPropertyStatements(statements, staticProperties, getLocalName(node, true)); } addClassElementDecorationStatements(statements, node, false); addClassElementDecorationStatements(statements, node, true); @@ -36984,7 +36864,7 @@ var ts; function visitClassExpression(node) { var staticProperties = getInitializedProperties(node, true); var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); - var members = transformClassMembers(node, heritageClauses !== undefined); + var members = transformClassMembers(node, ts.some(heritageClauses, function (c) { return c.token === 84; })); var classExpression = ts.setOriginalNode(ts.createClassExpression(undefined, node.name, undefined, heritageClauses, members, node), node); if (staticProperties.length > 0) { var expressions = []; @@ -36995,7 +36875,7 @@ var ts; } ts.setEmitFlags(classExpression, 524288 | ts.getEmitFlags(classExpression)); expressions.push(ts.startOnNewLine(ts.createAssignment(temp, classExpression))); - ts.addRange(expressions, generateInitializedPropertyExpressions(node, staticProperties, temp)); + ts.addRange(expressions, generateInitializedPropertyExpressions(staticProperties, temp)); expressions.push(ts.startOnNewLine(temp)); return ts.inlineExpressions(expressions); } @@ -37012,13 +36892,13 @@ var ts; } function transformConstructor(node, hasExtendsClause) { var hasInstancePropertyWithInitializer = ts.forEach(node.members, isInstanceInitializedProperty); - var hasParameterPropertyAssignments = node.transformFlags & 131072; + var hasParameterPropertyAssignments = node.transformFlags & 524288; var constructor = ts.getFirstConstructorWithBody(node); if (!hasInstancePropertyWithInitializer && !hasParameterPropertyAssignments) { return ts.visitEachChild(constructor, visitor, context); } var parameters = transformConstructorParameters(constructor); - var body = transformConstructorBody(node, constructor, hasExtendsClause, parameters); + var body = transformConstructorBody(node, constructor, hasExtendsClause); return ts.startOnNewLine(ts.setOriginalNode(ts.createConstructor(undefined, undefined, parameters, body, constructor || node), constructor)); } function transformConstructorParameters(constructor) { @@ -37026,7 +36906,7 @@ var ts; ? ts.visitNodes(constructor.parameters, visitor, ts.isParameter) : []; } - function transformConstructorBody(node, constructor, hasExtendsClause, parameters) { + function transformConstructorBody(node, constructor, hasExtendsClause) { var statements = []; var indexOfFirstStatement = 0; startLexicalEnvironment(); @@ -37039,7 +36919,7 @@ var ts; statements.push(ts.createStatement(ts.createCall(ts.createSuper(), undefined, [ts.createSpread(ts.createIdentifier("arguments"))]))); } var properties = getInitializedProperties(node, false); - addInitializedPropertyStatements(statements, node, properties, ts.createThis()); + addInitializedPropertyStatements(statements, properties, ts.createThis()); if (constructor) { ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement)); } @@ -37054,7 +36934,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 202 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 203 && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -37088,24 +36968,24 @@ var ts; return isInitializedProperty(member, false); } function isInitializedProperty(member, isStatic) { - return member.kind === 145 + return member.kind === 146 && isStatic === ts.hasModifier(member, 32) && member.initializer !== undefined; } - function addInitializedPropertyStatements(statements, node, properties, receiver) { + function addInitializedPropertyStatements(statements, properties, receiver) { for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) { var property = properties_7[_i]; - var statement = ts.createStatement(transformInitializedProperty(node, property, receiver)); + var statement = ts.createStatement(transformInitializedProperty(property, receiver)); ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property)); ts.setCommentRange(statement, property); statements.push(statement); } } - function generateInitializedPropertyExpressions(node, properties, receiver) { + function generateInitializedPropertyExpressions(properties, receiver) { var expressions = []; for (var _i = 0, properties_8 = properties; _i < properties_8.length; _i++) { var property = properties_8[_i]; - var expression = transformInitializedProperty(node, property, receiver); + var expression = transformInitializedProperty(property, receiver); expression.startsOnNewLine = true; ts.setSourceMapRange(expression, ts.moveRangePastModifiers(property)); ts.setCommentRange(expression, property); @@ -37113,7 +36993,7 @@ var ts; } return expressions; } - function transformInitializedProperty(node, property, receiver) { + function transformInitializedProperty(property, receiver) { var propertyName = visitPropertyNameOfClassElement(property); var initializer = ts.visitNode(property.initializer, visitor, ts.isExpression); var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, propertyName); @@ -37161,12 +37041,12 @@ var ts; } function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 149: case 150: + case 151: return getAllDecoratorsOfAccessors(node, member); - case 147: + case 148: return getAllDecoratorsOfMethod(member); - case 145: + case 146: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -37244,7 +37124,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, true); var descriptor = languageVersion > 0 - ? member.kind === 145 + ? member.kind === 146 ? ts.createVoidZero() : ts.createNull() : undefined; @@ -37332,43 +37212,43 @@ var ts; } function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 147 - || kind === 149 + return kind === 148 || kind === 150 - || kind === 145; + || kind === 151 + || kind === 146; } function shouldAddReturnTypeMetadata(node) { - return node.kind === 147; + return node.kind === 148; } function shouldAddParamTypesMetadata(node) { var kind = node.kind; - return kind === 221 - || kind === 192 - || kind === 147 - || kind === 149 - || kind === 150; + return kind === 222 + || kind === 193 + || kind === 148 + || kind === 150 + || kind === 151; } function serializeTypeOfNode(node) { switch (node.kind) { - case 145: - case 142: - case 149: - return serializeTypeNode(node.type); + case 146: + case 143: case 150: + return serializeTypeNode(node.type); + case 151: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 221: - case 192: - case 147: + case 222: + case 193: + case 148: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); } } function getRestParameterElementType(node) { - if (node && node.kind === 160) { + if (node && node.kind === 161) { return node.elementType; } - else if (node && node.kind === 155) { + else if (node && node.kind === 156) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -37414,52 +37294,52 @@ var ts; return ts.createIdentifier("Object"); } switch (node.kind) { - case 103: + case 104: return ts.createVoidZero(); - case 164: + case 165: return serializeTypeNode(node.type); - case 156: case 157: + case 158: return ts.createIdentifier("Function"); - case 160: case 161: + case 162: return ts.createIdentifier("Array"); - case 154: - case 120: + case 155: + case 121: return ts.createIdentifier("Boolean"); - case 132: + case 133: return ts.createIdentifier("String"); - case 166: + case 167: switch (node.literal.kind) { case 9: return ts.createIdentifier("String"); case 8: return ts.createIdentifier("Number"); - case 99: - case 84: + case 100: + case 85: return ts.createIdentifier("Boolean"); default: ts.Debug.failBadSyntaxKind(node.literal); break; } break; - case 130: + case 131: return ts.createIdentifier("Number"); - case 133: + case 134: return languageVersion < 2 ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 155: + case 156: return serializeTypeReferenceNode(node); + case 164: case 163: - case 162: { var unionOrIntersection = node; var serializedUnion = void 0; for (var _i = 0, _a = unionOrIntersection.types; _i < _a.length; _i++) { var typeNode = _a[_i]; var serializedIndividual = serializeTypeNode(typeNode); - if (serializedIndividual.kind !== 69) { + if (serializedIndividual.kind !== 70) { serializedUnion = undefined; break; } @@ -37476,10 +37356,10 @@ var ts; return serializedUnion; } } - case 158: case 159: - case 117: - case 165: + case 160: + case 118: + case 166: break; default: ts.Debug.failBadSyntaxKind(node); @@ -37520,22 +37400,22 @@ var ts; } function serializeEntityNameAsExpression(node, useFallback) { switch (node.kind) { - case 69: - var name_30 = ts.getMutableClone(node); - name_30.flags &= ~8; - name_30.original = undefined; - name_30.parent = currentScope; + case 70: + var name_27 = ts.getMutableClone(node); + name_27.flags &= ~8; + name_27.original = undefined; + name_27.parent = currentScope; if (useFallback) { - return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_30), ts.createLiteral("undefined")), name_30); + return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_27), ts.createLiteral("undefined")), name_27); } - return name_30; - case 139: + return name_27; + case 140: return serializeQualifiedNameAsExpression(node, useFallback); } } function serializeQualifiedNameAsExpression(node, useFallback) { var left; - if (node.left.kind === 69) { + if (node.left.kind === 70) { left = serializeEntityNameAsExpression(node.left, useFallback); } else if (useFallback) { @@ -37548,7 +37428,7 @@ var ts; return ts.createPropertyAccess(left, node.right); } function getGlobalSymbolNameWithFallback() { - return ts.createConditional(ts.createStrictEquality(ts.createTypeOf(ts.createIdentifier("Symbol")), ts.createLiteral("function")), ts.createToken(53), ts.createIdentifier("Symbol"), ts.createToken(54), ts.createIdentifier("Object")); + return ts.createConditional(ts.createStrictEquality(ts.createTypeOf(ts.createIdentifier("Symbol")), ts.createLiteral("function")), ts.createToken(54), ts.createIdentifier("Symbol"), ts.createToken(55), ts.createIdentifier("Object")); } function getExpressionForPropertyName(member, generateNameForComputedPropertyName) { var name = member.name; @@ -37580,9 +37460,9 @@ var ts; } } function visitHeritageClause(node) { - if (node.token === 83) { + if (node.token === 84) { var types = ts.visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments, 0, 1); - return ts.createHeritageClause(83, types, node); + return ts.createHeritageClause(84, types, node); } return undefined; } @@ -37593,6 +37473,12 @@ var ts; function shouldEmitFunctionLikeDeclaration(node) { return !ts.nodeIsMissing(node.body); } + function visitConstructor(node) { + if (!shouldEmitFunctionLikeDeclaration(node)) { + return undefined; + } + return ts.visitEachChild(node, visitor, context); + } function visitMethodDeclaration(node) { if (!shouldEmitFunctionLikeDeclaration(node)) { return undefined; @@ -37643,36 +37529,33 @@ var ts; if (ts.nodeIsMissing(node.body)) { return ts.createOmittedExpression(); } - var func = ts.createFunctionExpression(node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); + var func = ts.createFunctionExpression(ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); ts.setOriginalNode(func, node); return func; } function visitArrowFunction(node) { - var func = ts.createArrowFunction(undefined, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, node.equalsGreaterThanToken, transformConciseBody(node), node); + var func = ts.createArrowFunction(ts.visitNodes(node.modifiers, visitor, ts.isModifier), undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, node.equalsGreaterThanToken, transformConciseBody(node), node); ts.setOriginalNode(func, node); return func; } function transformFunctionBody(node) { - if (ts.isAsyncFunctionLike(node)) { - return transformAsyncFunctionBody(node); - } return transformFunctionBodyWorker(node.body); } function transformFunctionBodyWorker(body, start) { if (start === void 0) { start = 0; } var savedCurrentScope = currentScope; + var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName; currentScope = body; + currentScopeFirstDeclarationsOfName = ts.createMap(); startLexicalEnvironment(); var statements = ts.visitNodes(body.statements, visitor, ts.isStatement, start); var visited = ts.updateBlock(body, statements); var declarations = endLexicalEnvironment(); currentScope = savedCurrentScope; + currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; return ts.mergeFunctionBodyLexicalEnvironment(visited, declarations); } function transformConciseBody(node) { - if (ts.isAsyncFunctionLike(node)) { - return transformAsyncFunctionBody(node); - } return transformConciseBodyWorker(node.body, false); } function transformConciseBodyWorker(body, forceBlockFunctionBody) { @@ -37694,42 +37577,6 @@ var ts; } } } - function getPromiseConstructor(type) { - var typeName = ts.getEntityNameFromTypeNode(type); - if (typeName && ts.isEntityName(typeName)) { - var serializationKind = resolver.getTypeReferenceSerializationKind(typeName); - if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue - || serializationKind === ts.TypeReferenceSerializationKind.Unknown) { - return typeName; - } - } - return undefined; - } - function transformAsyncFunctionBody(node) { - var promiseConstructor = languageVersion < 2 ? getPromiseConstructor(node.type) : undefined; - var isArrowFunction = node.kind === 180; - var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0; - if (!isArrowFunction) { - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.body.statements, false, visitor); - statements.push(ts.createReturn(ts.createAwaiterHelper(currentSourceFileExternalHelpersModuleName, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body, statementOffset)))); - var block = ts.createBlock(statements, node.body, true); - if (languageVersion >= 2) { - if (resolver.getNodeCheckFlags(node) & 4096) { - enableSubstitutionForAsyncMethodsWithSuper(); - ts.setEmitFlags(block, 8); - } - else if (resolver.getNodeCheckFlags(node) & 2048) { - enableSubstitutionForAsyncMethodsWithSuper(); - ts.setEmitFlags(block, 4); - } - } - return block; - } - else { - return ts.createAwaiterHelper(currentSourceFileExternalHelpersModuleName, hasLexicalArguments, promiseConstructor, transformConciseBodyWorker(node.body, true)); - } - } function visitParameter(node) { if (ts.parameterIsThisKeyword(node)) { return undefined; @@ -37756,14 +37603,14 @@ var ts; function transformInitializedVariable(node) { var name = node.name; if (ts.isBindingPattern(name)) { - return ts.flattenVariableDestructuringToExpression(context, node, hoistVariableDeclaration, getNamespaceMemberNameWithSourceMapsAndWithoutComments, visitor); + return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, getNamespaceMemberNameWithSourceMapsAndWithoutComments, visitor); } else { return ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(name), ts.visitNode(node.initializer, visitor, ts.isExpression), node); } } - function visitAwaitExpression(node) { - return ts.setOriginalNode(ts.createYield(undefined, ts.visitNode(node.expression, visitor, ts.isExpression), node), node); + function visitVariableDeclaration(node) { + return ts.updateVariableDeclaration(node, ts.visitNode(node.name, visitor, ts.isBindingName), undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)); } function visitParenthesizedExpression(node) { var innerExpression = ts.skipOuterExpressions(node.expression, ~2); @@ -37781,6 +37628,12 @@ var ts; var expression = ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression); return ts.createPartiallyEmittedExpression(expression, node); } + function visitCallExpression(node) { + return ts.updateCall(node, ts.visitNode(node.expression, visitor, ts.isExpression), undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression)); + } + function visitNewExpression(node) { + return ts.updateNew(node, ts.visitNode(node.expression, visitor, ts.isExpression), undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression)); + } function shouldEmitEnumDeclaration(node) { return !ts.isConst(node) || compilerOptions.preserveConstEnums @@ -37812,7 +37665,7 @@ var ts; var parameterName = getNamespaceParameterName(node); var containerName = getNamespaceContainerName(node); var exportName = getExportName(node); - var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, transformEnumBody(node, containerName)), undefined, [ts.createLogicalOr(exportName, ts.createAssignment(exportName, ts.createObjectLiteral()))]), node); + var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, transformEnumBody(node, containerName)), undefined, [ts.createLogicalOr(exportName, ts.createAssignment(exportName, ts.createObjectLiteral()))]), node); ts.setOriginalNode(enumStatement, node); ts.setEmitFlags(enumStatement, emitFlags); statements.push(enumStatement); @@ -37855,7 +37708,7 @@ var ts; } function isES6ExportedDeclaration(node) { return isExternalModuleExport(node) - && moduleKind === ts.ModuleKind.ES6; + && moduleKind === ts.ModuleKind.ES2015; } function recordEmittedDeclarationInScope(node) { var name = node.symbol && node.symbol.name; @@ -37870,9 +37723,9 @@ var ts; } function isFirstEmittedDeclarationInScope(node) { if (currentScopeFirstDeclarationsOfName) { - var name_31 = node.symbol && node.symbol.name; - if (name_31) { - return currentScopeFirstDeclarationsOfName[name_31] === node; + var name_28 = node.symbol && node.symbol.name; + if (name_28) { + return currentScopeFirstDeclarationsOfName[name_28] === node; } } return false; @@ -37887,7 +37740,7 @@ var ts; ts.createVariableDeclaration(getDeclarationName(node, false, true)) ]); ts.setOriginalNode(statement, node); - if (node.kind === 224) { + if (node.kind === 225) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -37920,7 +37773,7 @@ var ts; var localName = getLocalName(node); moduleArg = ts.createAssignment(localName, moduleArg); } - var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, transformModuleBody(node, containerName)), undefined, [moduleArg]), node); + var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, transformModuleBody(node, containerName)), undefined, [moduleArg]), node); ts.setOriginalNode(moduleStatement, node); ts.setEmitFlags(moduleStatement, emitFlags); statements.push(moduleStatement); @@ -37938,7 +37791,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 226) { + if (body.kind === 227) { ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); statementsLocation = body.statements; blockLocation = body; @@ -37961,17 +37814,67 @@ var ts; currentNamespace = savedCurrentNamespace; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), blockLocation, true); - if (body.kind !== 226) { + if (body.kind !== 227) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 49152); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 225) { + if (moduleDeclaration.body.kind === 226) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } } + function visitImportDeclaration(node) { + if (!node.importClause) { + return node; + } + var importClause = ts.visitNode(node.importClause, visitImportClause, ts.isImportClause, true); + return importClause + ? ts.updateImportDeclaration(node, undefined, undefined, importClause, node.moduleSpecifier) + : undefined; + } + function visitImportClause(node) { + var name = resolver.isReferencedAliasDeclaration(node) ? node.name : undefined; + var namedBindings = ts.visitNode(node.namedBindings, visitNamedImportBindings, ts.isNamedImportBindings, true); + return (name || namedBindings) ? ts.updateImportClause(node, name, namedBindings) : undefined; + } + function visitNamedImportBindings(node) { + if (node.kind === 233) { + return resolver.isReferencedAliasDeclaration(node) ? node : undefined; + } + else { + var elements = ts.visitNodes(node.elements, visitImportSpecifier, ts.isImportSpecifier); + return ts.some(elements) ? ts.updateNamedImports(node, elements) : undefined; + } + } + function visitImportSpecifier(node) { + return resolver.isReferencedAliasDeclaration(node) ? node : undefined; + } + function visitExportAssignment(node) { + return resolver.isValueAliasDeclaration(node) + ? ts.visitEachChild(node, visitor, context) + : undefined; + } + function visitExportDeclaration(node) { + if (!node.exportClause) { + return resolver.moduleExportsSomeValue(node.moduleSpecifier) ? node : undefined; + } + if (!resolver.isValueAliasDeclaration(node)) { + return undefined; + } + var exportClause = ts.visitNode(node.exportClause, visitNamedExports, ts.isNamedExports, true); + return exportClause + ? ts.updateExportDeclaration(node, undefined, undefined, exportClause, node.moduleSpecifier) + : undefined; + } + function visitNamedExports(node) { + var elements = ts.visitNodes(node.elements, visitExportSpecifier, ts.isExportSpecifier); + return ts.some(elements) ? ts.updateNamedExports(node, elements) : undefined; + } + function visitExportSpecifier(node) { + return resolver.isValueAliasDeclaration(node) ? node : undefined; + } function shouldEmitImportEqualsDeclaration(node) { return resolver.isReferencedAliasDeclaration(node) || (!ts.isExternalModule(currentSourceFile) @@ -37979,7 +37882,9 @@ var ts; } function visitImportEqualsDeclaration(node) { if (ts.isExternalModuleImportEqualsDeclaration(node)) { - return ts.visitEachChild(node, visitor, context); + return resolver.isReferencedAliasDeclaration(node) + ? ts.visitEachChild(node, visitor, context) + : undefined; } if (!shouldEmitImportEqualsDeclaration(node)) { return undefined; @@ -38063,7 +37968,7 @@ var ts; } function getDeclarationName(node, allowComments, allowSourceMaps, emitFlags) { if (node.name) { - var name_32 = ts.getMutableClone(node.name); + var name_29 = ts.getMutableClone(node.name); emitFlags |= ts.getEmitFlags(node.name); if (!allowSourceMaps) { emitFlags |= 1536; @@ -38072,9 +37977,9 @@ var ts; emitFlags |= 49152; } if (emitFlags) { - ts.setEmitFlags(name_32, emitFlags); + ts.setEmitFlags(name_29, emitFlags); } - return name_32; + return name_29; } else { return ts.getGeneratedNameForNode(node); @@ -38091,57 +37996,32 @@ var ts; function enableSubstitutionForNonQualifiedEnumMembers() { if ((enabledSubstitutions & 8) === 0) { enabledSubstitutions |= 8; - context.enableSubstitution(69); - } - } - function enableSubstitutionForAsyncMethodsWithSuper() { - if ((enabledSubstitutions & 4) === 0) { - enabledSubstitutions |= 4; - context.enableSubstitution(174); - context.enableSubstitution(172); - context.enableSubstitution(173); - context.enableEmitNotification(221); - context.enableEmitNotification(147); - context.enableEmitNotification(149); - context.enableEmitNotification(150); - context.enableEmitNotification(148); + context.enableSubstitution(70); } } function enableSubstitutionForClassAliases() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(69); + context.enableSubstitution(70); classAliases = ts.createMap(); } } function enableSubstitutionForNamespaceExports() { if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; - context.enableSubstitution(69); + context.enableSubstitution(70); context.enableSubstitution(254); - context.enableEmitNotification(225); + context.enableEmitNotification(226); } } - function isSuperContainer(node) { - var kind = node.kind; - return kind === 221 - || kind === 148 - || kind === 147 - || kind === 149 - || kind === 150; - } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 225; + return ts.getOriginalNode(node).kind === 226; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 224; + return ts.getOriginalNode(node).kind === 225; } function onEmitNode(emitContext, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; - var savedCurrentSuperContainer = currentSuperContainer; - if (enabledSubstitutions & 4 && isSuperContainer(node)) { - currentSuperContainer = node; - } if (enabledSubstitutions & 2 && isTransformedModuleDeclaration(node)) { applicableSubstitutions |= 2; } @@ -38150,7 +38030,6 @@ var ts; } previousOnEmitNode(emitContext, node, emitCallback); applicableSubstitutions = savedApplicableSubstitutions; - currentSuperContainer = savedCurrentSuperContainer; } function onSubstituteNode(emitContext, node) { node = previousOnSubstituteNode(emitContext, node); @@ -38164,31 +38043,26 @@ var ts; } function substituteShorthandPropertyAssignment(node) { if (enabledSubstitutions & 2) { - var name_33 = node.name; - var exportedName = trySubstituteNamespaceExportedName(name_33); + var name_30 = node.name; + var exportedName = trySubstituteNamespaceExportedName(name_30); if (exportedName) { if (node.objectAssignmentInitializer) { var initializer = ts.createAssignment(exportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name_33, initializer, node); + return ts.createPropertyAssignment(name_30, initializer, node); } - return ts.createPropertyAssignment(name_33, exportedName, node); + return ts.createPropertyAssignment(name_30, exportedName, node); } } return node; } function substituteExpression(node) { switch (node.kind) { - case 69: + case 70: return substituteExpressionIdentifier(node); - case 172: - return substitutePropertyAccessExpression(node); case 173: - return substituteElementAccessExpression(node); + return substitutePropertyAccessExpression(node); case 174: - if (enabledSubstitutions & 4) { - return substituteCallExpression(node); - } - break; + return substituteElementAccessExpression(node); } return node; } @@ -38218,8 +38092,8 @@ var ts; if (enabledSubstitutions & applicableSubstitutions && (ts.getEmitFlags(node) & 262144) === 0) { var container = resolver.getReferencedExportContainer(node, false); if (container) { - var substitute = (applicableSubstitutions & 2 && container.kind === 225) || - (applicableSubstitutions & 8 && container.kind === 224); + var substitute = (applicableSubstitutions & 2 && container.kind === 226) || + (applicableSubstitutions & 8 && container.kind === 225); if (substitute) { return ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node, node); } @@ -38227,37 +38101,10 @@ var ts; } return undefined; } - function substituteCallExpression(node) { - var expression = node.expression; - if (ts.isSuperProperty(expression)) { - var flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - var argumentExpression = ts.isPropertyAccessExpression(expression) - ? substitutePropertyAccessExpression(expression) - : substituteElementAccessExpression(expression); - return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), undefined, [ - ts.createThis() - ].concat(node.arguments)); - } - } - return node; - } function substitutePropertyAccessExpression(node) { - if (enabledSubstitutions & 4 && node.expression.kind === 95) { - var flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - return createSuperAccessInAsyncMethod(ts.createLiteral(node.name.text), flags, node); - } - } return substituteConstantValue(node); } function substituteElementAccessExpression(node) { - if (enabledSubstitutions & 4 && node.expression.kind === 95) { - var flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - return createSuperAccessInAsyncMethod(node.argumentExpression, flags, node); - } - } return substituteConstantValue(node); } function substituteConstantValue(node) { @@ -38285,18 +38132,6 @@ var ts; ? resolver.getConstantValue(node) : undefined; } - function createSuperAccessInAsyncMethod(argumentExpression, flags, location) { - if (flags & 4096) { - return ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), "value", location); - } - else { - return ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression], location); - } - } - function getSuperContainerAsyncMethodFlags() { - return currentSuperContainer !== undefined - && resolver.getNodeCheckFlags(currentSuperContainer) & (2048 | 4096); - } } ts.transformTypeScript = transformTypeScript; })(ts || (ts = {})); @@ -38329,9 +38164,9 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 241: - return visitJsxElement(node, false); case 242: + return visitJsxElement(node, false); + case 243: return visitJsxSelfClosingElement(node, false); case 248: return visitJsxExpression(node); @@ -38342,13 +38177,13 @@ var ts; } function transformJsxChildToExpression(node) { switch (node.kind) { - case 244: + case 10: return visitJsxText(node); case 248: return visitJsxExpression(node); - case 241: - return visitJsxElement(node, true); case 242: + return visitJsxElement(node, true); + case 243: return visitJsxSelfClosingElement(node, true); default: ts.Debug.failBadSyntaxKind(node); @@ -38465,16 +38300,16 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 241) { + if (node.kind === 242) { return getTagName(node.openingElement); } else { - var name_34 = node.tagName; - if (ts.isIdentifier(name_34) && ts.isIntrinsicJsxName(name_34.text)) { - return ts.createLiteral(name_34.text); + var name_31 = node.tagName; + if (ts.isIdentifier(name_31) && ts.isIntrinsicJsxName(name_31.text)) { + return ts.createLiteral(name_31.text); } else { - return ts.createExpressionFromEntityName(name_34); + return ts.createExpressionFromEntityName(name_31); } } } @@ -38752,13 +38587,30 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function transformES7(context) { - var hoistVariableDeclaration = context.hoistVariableDeclaration; + function transformES2017(context) { + var ES2017SubstitutionFlags; + (function (ES2017SubstitutionFlags) { + ES2017SubstitutionFlags[ES2017SubstitutionFlags["AsyncMethodsWithSuper"] = 1] = "AsyncMethodsWithSuper"; + })(ES2017SubstitutionFlags || (ES2017SubstitutionFlags = {})); + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; + var resolver = context.getEmitResolver(); + var compilerOptions = context.getCompilerOptions(); + var languageVersion = ts.getEmitScriptTarget(compilerOptions); + var currentSourceFileExternalHelpersModuleName; + var enabledSubstitutions; + var applicableSubstitutions; + var currentSuperContainer; + var previousOnEmitNode = context.onEmitNode; + var previousOnSubstituteNode = context.onSubstituteNode; + context.onEmitNode = onEmitNode; + context.onSubstituteNode = onSubstituteNode; + var currentScope; return transformSourceFile; function transformSourceFile(node) { if (ts.isDeclarationFile(node)) { return node; } + currentSourceFileExternalHelpersModuleName = node.externalHelpersModuleName; return ts.visitEachChild(node, visitor, context); } function visitor(node) { @@ -38768,13 +38620,265 @@ var ts; else if (node.transformFlags & 32) { return ts.visitEachChild(node, visitor, context); } + return node; + } + function visitorWorker(node) { + switch (node.kind) { + case 119: + return undefined; + case 185: + return visitAwaitExpression(node); + case 148: + return visitMethodDeclaration(node); + case 221: + return visitFunctionDeclaration(node); + case 180: + return visitFunctionExpression(node); + case 181: + return visitArrowFunction(node); + default: + ts.Debug.failBadSyntaxKind(node); + return node; + } + } + function visitAwaitExpression(node) { + return ts.setOriginalNode(ts.createYield(undefined, ts.visitNode(node.expression, visitor, ts.isExpression), node), node); + } + function visitMethodDeclaration(node) { + if (!ts.isAsyncFunctionLike(node)) { + return node; + } + var method = ts.createMethod(undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); + ts.setCommentRange(method, node); + ts.setSourceMapRange(method, ts.moveRangePastDecorators(node)); + ts.setOriginalNode(method, node); + return method; + } + function visitFunctionDeclaration(node) { + if (!ts.isAsyncFunctionLike(node)) { + return node; + } + var func = ts.createFunctionDeclaration(undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); + ts.setOriginalNode(func, node); + return func; + } + function visitFunctionExpression(node) { + if (!ts.isAsyncFunctionLike(node)) { + return node; + } + if (ts.nodeIsMissing(node.body)) { + return ts.createOmittedExpression(); + } + var func = ts.createFunctionExpression(undefined, node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); + ts.setOriginalNode(func, node); + return func; + } + function visitArrowFunction(node) { + if (!ts.isAsyncFunctionLike(node)) { + return node; + } + var func = ts.createArrowFunction(ts.visitNodes(node.modifiers, visitor, ts.isModifier), undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, node.equalsGreaterThanToken, transformConciseBody(node), node); + ts.setOriginalNode(func, node); + return func; + } + function transformFunctionBody(node) { + return transformAsyncFunctionBody(node); + } + function transformConciseBody(node) { + return transformAsyncFunctionBody(node); + } + function transformFunctionBodyWorker(body, start) { + if (start === void 0) { start = 0; } + var savedCurrentScope = currentScope; + currentScope = body; + startLexicalEnvironment(); + var statements = ts.visitNodes(body.statements, visitor, ts.isStatement, start); + var visited = ts.updateBlock(body, statements); + var declarations = endLexicalEnvironment(); + currentScope = savedCurrentScope; + return ts.mergeFunctionBodyLexicalEnvironment(visited, declarations); + } + function transformAsyncFunctionBody(node) { + var nodeType = node.original ? node.original.type : node.type; + var promiseConstructor = languageVersion < 2 ? getPromiseConstructor(nodeType) : undefined; + var isArrowFunction = node.kind === 181; + var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0; + if (!isArrowFunction) { + var statements = []; + var statementOffset = ts.addPrologueDirectives(statements, node.body.statements, false, visitor); + statements.push(ts.createReturn(ts.createAwaiterHelper(currentSourceFileExternalHelpersModuleName, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body, statementOffset)))); + var block = ts.createBlock(statements, node.body, true); + if (languageVersion >= 2) { + if (resolver.getNodeCheckFlags(node) & 4096) { + enableSubstitutionForAsyncMethodsWithSuper(); + ts.setEmitFlags(block, 8); + } + else if (resolver.getNodeCheckFlags(node) & 2048) { + enableSubstitutionForAsyncMethodsWithSuper(); + ts.setEmitFlags(block, 4); + } + } + return block; + } + else { + return ts.createAwaiterHelper(currentSourceFileExternalHelpersModuleName, hasLexicalArguments, promiseConstructor, transformConciseBodyWorker(node.body, true)); + } + } + function transformConciseBodyWorker(body, forceBlockFunctionBody) { + if (ts.isBlock(body)) { + return transformFunctionBodyWorker(body); + } + else { + startLexicalEnvironment(); + var visited = ts.visitNode(body, visitor, ts.isConciseBody); + var declarations = endLexicalEnvironment(); + var merged = ts.mergeFunctionBodyLexicalEnvironment(visited, declarations); + if (forceBlockFunctionBody && !ts.isBlock(merged)) { + return ts.createBlock([ + ts.createReturn(merged) + ]); + } + else { + return merged; + } + } + } + function getPromiseConstructor(type) { + var typeName = ts.getEntityNameFromTypeNode(type); + if (typeName && ts.isEntityName(typeName)) { + var serializationKind = resolver.getTypeReferenceSerializationKind(typeName); + if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue + || serializationKind === ts.TypeReferenceSerializationKind.Unknown) { + return typeName; + } + } + return undefined; + } + function enableSubstitutionForAsyncMethodsWithSuper() { + if ((enabledSubstitutions & 1) === 0) { + enabledSubstitutions |= 1; + context.enableSubstitution(175); + context.enableSubstitution(173); + context.enableSubstitution(174); + context.enableEmitNotification(222); + context.enableEmitNotification(148); + context.enableEmitNotification(150); + context.enableEmitNotification(151); + context.enableEmitNotification(149); + } + } + function substituteExpression(node) { + switch (node.kind) { + case 173: + return substitutePropertyAccessExpression(node); + case 174: + return substituteElementAccessExpression(node); + case 175: + if (enabledSubstitutions & 1) { + return substituteCallExpression(node); + } + break; + } + return node; + } + function substitutePropertyAccessExpression(node) { + if (enabledSubstitutions & 1 && node.expression.kind === 96) { + var flags = getSuperContainerAsyncMethodFlags(); + if (flags) { + return createSuperAccessInAsyncMethod(ts.createLiteral(node.name.text), flags, node); + } + } + return node; + } + function substituteElementAccessExpression(node) { + if (enabledSubstitutions & 1 && node.expression.kind === 96) { + var flags = getSuperContainerAsyncMethodFlags(); + if (flags) { + return createSuperAccessInAsyncMethod(node.argumentExpression, flags, node); + } + } + return node; + } + function substituteCallExpression(node) { + var expression = node.expression; + if (ts.isSuperProperty(expression)) { + var flags = getSuperContainerAsyncMethodFlags(); + if (flags) { + var argumentExpression = ts.isPropertyAccessExpression(expression) + ? substitutePropertyAccessExpression(expression) + : substituteElementAccessExpression(expression); + return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), undefined, [ + ts.createThis() + ].concat(node.arguments)); + } + } + return node; + } + function isSuperContainer(node) { + var kind = node.kind; + return kind === 222 + || kind === 149 + || kind === 148 + || kind === 150 + || kind === 151; + } + function onEmitNode(emitContext, node, emitCallback) { + var savedApplicableSubstitutions = applicableSubstitutions; + var savedCurrentSuperContainer = currentSuperContainer; + if (enabledSubstitutions & 1 && isSuperContainer(node)) { + currentSuperContainer = node; + } + previousOnEmitNode(emitContext, node, emitCallback); + applicableSubstitutions = savedApplicableSubstitutions; + currentSuperContainer = savedCurrentSuperContainer; + } + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1) { + return substituteExpression(node); + } + return node; + } + function createSuperAccessInAsyncMethod(argumentExpression, flags, location) { + if (flags & 4096) { + return ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), "value", location); + } + else { + return ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression], location); + } + } + function getSuperContainerAsyncMethodFlags() { + return currentSuperContainer !== undefined + && resolver.getNodeCheckFlags(currentSuperContainer) & (2048 | 4096); + } + } + ts.transformES2017 = transformES2017; +})(ts || (ts = {})); +var ts; +(function (ts) { + function transformES2016(context) { + var hoistVariableDeclaration = context.hoistVariableDeclaration; + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } + return ts.visitEachChild(node, visitor, context); + } + function visitor(node) { + if (node.transformFlags & 64) { + return visitorWorker(node); + } + else if (node.transformFlags & 128) { + return ts.visitEachChild(node, visitor, context); + } else { return node; } } function visitorWorker(node) { switch (node.kind) { - case 187: + case 188: return visitBinaryExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -38784,7 +38888,7 @@ var ts; function visitBinaryExpression(node) { var left = ts.visitNode(node.left, visitor, ts.isExpression); var right = ts.visitNode(node.right, visitor, ts.isExpression); - if (node.operatorToken.kind === 60) { + if (node.operatorToken.kind === 61) { var target = void 0; var value = void 0; if (ts.isElementAccessExpression(left)) { @@ -38804,7 +38908,7 @@ var ts; } return ts.createAssignment(target, ts.createMathPow(value, right, node), node); } - else if (node.operatorToken.kind === 38) { + else if (node.operatorToken.kind === 39) { return ts.createMathPow(left, right, node); } else { @@ -38813,11 +38917,33 @@ var ts; } } } - ts.transformES7 = transformES7; + ts.transformES2016 = transformES2016; })(ts || (ts = {})); var ts; (function (ts) { - function transformES6(context) { + var ES2015SubstitutionFlags; + (function (ES2015SubstitutionFlags) { + ES2015SubstitutionFlags[ES2015SubstitutionFlags["CapturedThis"] = 1] = "CapturedThis"; + ES2015SubstitutionFlags[ES2015SubstitutionFlags["BlockScopedBindings"] = 2] = "BlockScopedBindings"; + })(ES2015SubstitutionFlags || (ES2015SubstitutionFlags = {})); + var CopyDirection; + (function (CopyDirection) { + CopyDirection[CopyDirection["ToOriginal"] = 0] = "ToOriginal"; + CopyDirection[CopyDirection["ToOutParameter"] = 1] = "ToOutParameter"; + })(CopyDirection || (CopyDirection = {})); + var Jump; + (function (Jump) { + Jump[Jump["Break"] = 2] = "Break"; + Jump[Jump["Continue"] = 4] = "Continue"; + Jump[Jump["Return"] = 8] = "Return"; + })(Jump || (Jump = {})); + var SuperCaptureResult; + (function (SuperCaptureResult) { + SuperCaptureResult[SuperCaptureResult["NoReplacement"] = 0] = "NoReplacement"; + SuperCaptureResult[SuperCaptureResult["ReplaceSuperCapture"] = 1] = "ReplaceSuperCapture"; + SuperCaptureResult[SuperCaptureResult["ReplaceWithReturn"] = 2] = "ReplaceWithReturn"; + })(SuperCaptureResult || (SuperCaptureResult = {})); + function transformES2015(context) { var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); var previousOnSubstituteNode = context.onSubstituteNode; @@ -38880,15 +39006,15 @@ var ts; return visited; } function shouldCheckNode(node) { - return (node.transformFlags & 64) !== 0 || - node.kind === 214 || + return (node.transformFlags & 256) !== 0 || + node.kind === 215 || (ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node)); } function visitorWorker(node) { if (shouldCheckNode(node)) { return visitJavaScript(node); } - else if (node.transformFlags & 128) { + else if (node.transformFlags & 512) { return ts.visitEachChild(node, visitor, context); } else { @@ -38907,18 +39033,18 @@ var ts; } function visitNodesInConvertedLoop(node) { switch (node.kind) { - case 211: + case 212: return visitReturnStatement(node); - case 200: + case 201: return visitVariableStatement(node); - case 213: + case 214: return visitSwitchStatement(node); + case 211: case 210: - case 209: return visitBreakOrContinueStatement(node); - case 97: + case 98: return visitThisKeyword(node); - case 69: + case 70: return visitIdentifier(node); default: return ts.visitEachChild(node, visitor, context); @@ -38926,74 +39052,74 @@ var ts; } function visitJavaScript(node) { switch (node.kind) { - case 82: + case 83: return node; - case 221: + case 222: return visitClassDeclaration(node); - case 192: + case 193: return visitClassExpression(node); - case 142: + case 143: return visitParameter(node); - case 220: + case 221: return visitFunctionDeclaration(node); - case 180: + case 181: return visitArrowFunction(node); - case 179: + case 180: return visitFunctionExpression(node); - case 218: - return visitVariableDeclaration(node); - case 69: - return visitIdentifier(node); case 219: + return visitVariableDeclaration(node); + case 70: + return visitIdentifier(node); + case 220: return visitVariableDeclarationList(node); - case 214: + case 215: return visitLabeledStatement(node); - case 204: - return visitDoStatement(node); case 205: - return visitWhileStatement(node); + return visitDoStatement(node); case 206: - return visitForStatement(node); + return visitWhileStatement(node); case 207: - return visitForInStatement(node); + return visitForStatement(node); case 208: + return visitForInStatement(node); + case 209: return visitForOfStatement(node); - case 202: + case 203: return visitExpressionStatement(node); - case 171: + case 172: return visitObjectLiteralExpression(node); case 254: return visitShorthandPropertyAssignment(node); - case 170: + case 171: return visitArrayLiteralExpression(node); - case 174: - return visitCallExpression(node); case 175: + return visitCallExpression(node); + case 176: return visitNewExpression(node); - case 178: + case 179: return visitParenthesizedExpression(node, true); - case 187: + case 188: return visitBinaryExpression(node, true); - case 11: case 12: case 13: case 14: + case 15: return visitTemplateLiteral(node); - case 176: + case 177: return visitTaggedTemplateExpression(node); - case 189: + case 190: return visitTemplateExpression(node); - case 190: + case 191: return visitYieldExpression(node); - case 95: - return visitSuperKeyword(node); - case 190: + case 96: + return visitSuperKeyword(); + case 191: return ts.visitEachChild(node, visitor, context); - case 147: + case 148: return visitMethodDeclaration(node); case 256: return visitSourceFileNode(node); - case 200: + case 201: return visitVariableStatement(node); default: ts.Debug.failBadSyntaxKind(node); @@ -39008,7 +39134,7 @@ var ts; } if (ts.isFunctionLike(currentNode)) { enclosingFunction = currentNode; - if (currentNode.kind !== 180) { + if (currentNode.kind !== 181) { enclosingNonArrowFunction = currentNode; if (!(ts.getEmitFlags(currentNode) & 2097152)) { enclosingNonAsyncFunctionBody = currentNode; @@ -39016,14 +39142,14 @@ var ts; } } switch (currentNode.kind) { - case 200: + case 201: enclosingVariableStatement = currentNode; break; + case 220: case 219: - case 218: - case 169: - case 167: + case 170: case 168: + case 169: break; default: enclosingVariableStatement = undefined; @@ -39051,7 +39177,7 @@ var ts; } function visitThisKeyword(node) { ts.Debug.assert(convertedLoopState !== undefined); - if (enclosingFunction && enclosingFunction.kind === 180) { + if (enclosingFunction && enclosingFunction.kind === 181) { convertedLoopState.containsLexicalThis = true; return node; } @@ -39071,13 +39197,13 @@ var ts; } function visitBreakOrContinueStatement(node) { if (convertedLoopState) { - var jump = node.kind === 210 ? 2 : 4; + var jump = node.kind === 211 ? 2 : 4; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; if (!node.label) { - if (node.kind === 210) { + if (node.kind === 211) { convertedLoopState.nonLocalJumps |= 2; labelMarker = "break"; } @@ -39087,7 +39213,7 @@ var ts; } } else { - if (node.kind === 210) { + if (node.kind === 211) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, true, node.label.text, labelMarker); } @@ -39106,10 +39232,10 @@ var ts; expr = copyExpr; } else { - expr = ts.createBinary(expr, 24, copyExpr); + expr = ts.createBinary(expr, 25, copyExpr); } } - returnExpression = ts.createBinary(expr, 24, returnExpression); + returnExpression = ts.createBinary(expr, 25, returnExpression); } return ts.createReturn(returnExpression); } @@ -39136,7 +39262,7 @@ var ts; return statement; } function isExportModifier(node) { - return node.kind === 82; + return node.kind === 83; } function visitClassExpression(node) { return transformClassLikeDeclarationToExpression(node); @@ -39146,7 +39272,7 @@ var ts; enableSubstitutionsForBlockScopedBindings(); } var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); - var classFunction = ts.createFunctionExpression(undefined, undefined, undefined, extendsClauseElement ? [ts.createParameter("_super")] : [], undefined, transformClassBody(node, extendsClauseElement)); + var classFunction = ts.createFunctionExpression(undefined, undefined, undefined, undefined, extendsClauseElement ? [ts.createParameter("_super")] : [], undefined, transformClassBody(node, extendsClauseElement)); if (ts.getEmitFlags(node) & 524288) { ts.setEmitFlags(classFunction, 524288); } @@ -39166,7 +39292,7 @@ var ts; addExtendsHelperIfNeeded(statements, node, extendsClauseElement); addConstructor(statements, node, extendsClauseElement); addClassMembers(statements, node); - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 16); + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 17); var localName = getLocalName(node); var outer = ts.createPartiallyEmittedExpression(localName); outer.end = closingBraceLocation.end; @@ -39236,17 +39362,17 @@ var ts; return block; } function isSufficientlyCoveredByReturnStatements(statement) { - if (statement.kind === 211) { + if (statement.kind === 212) { return true; } - else if (statement.kind === 203) { + else if (statement.kind === 204) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 199) { + else if (statement.kind === 200) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -39275,7 +39401,7 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 202 && ts.isSuperCall(firstStatement.expression)) { + if (firstStatement.kind === 203 && ts.isSuperCall(firstStatement.expression)) { var superCall = firstStatement.expression; superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); } @@ -39311,7 +39437,7 @@ var ts; } } function shouldAddDefaultValueAssignments(node) { - return (node.transformFlags & 65536) !== 0; + return (node.transformFlags & 262144) !== 0; } function addDefaultValueAssignmentsIfNeeded(statements, node) { if (!shouldAddDefaultValueAssignments(node)) { @@ -39319,22 +39445,22 @@ var ts; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { var parameter = _a[_i]; - var name_35 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; + var name_32 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; if (dotDotDotToken) { continue; } - if (ts.isBindingPattern(name_35)) { - addDefaultValueAssignmentForBindingPattern(statements, parameter, name_35, initializer); + if (ts.isBindingPattern(name_32)) { + addDefaultValueAssignmentForBindingPattern(statements, parameter, name_32, initializer); } else if (initializer) { - addDefaultValueAssignmentForInitializer(statements, parameter, name_35, initializer); + addDefaultValueAssignmentForInitializer(statements, parameter, name_32, initializer); } } } function addDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer) { var temp = ts.getGeneratedNameForNode(parameter); if (name.elements.length > 0) { - statements.push(ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(ts.flattenParameterDestructuring(context, parameter, temp, visitor))), 8388608)); + statements.push(ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(ts.flattenParameterDestructuring(parameter, temp, visitor))), 8388608)); } else if (initializer) { statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 8388608)); @@ -39350,7 +39476,7 @@ var ts; statements.push(statement); } function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) { - return node && node.dotDotDotToken && node.name.kind === 69 && !inConstructorWithSynthesizedSuper; + return node && node.dotDotDotToken && node.name.kind === 70 && !inConstructorWithSynthesizedSuper; } function addRestParameterIfNeeded(statements, node, inConstructorWithSynthesizedSuper) { var parameter = ts.lastOrUndefined(node.parameters); @@ -39375,7 +39501,7 @@ var ts; statements.push(forStatement); } function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 16384 && node.kind !== 180) { + if (node.transformFlags & 65536 && node.kind !== 181) { captureThisForNode(statements, node, ts.createThis()); } } @@ -39392,20 +39518,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 198: + case 199: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 147: + case 148: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member)); break; - case 149: case 150: + case 151: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors)); } break; - case 148: + case 149: break; default: ts.Debug.failBadSyntaxKind(node); @@ -39445,6 +39571,7 @@ var ts; if (getAccessor) { var getterFunction = transformFunctionLikeToExpression(getAccessor, undefined, undefined); ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); + ts.setEmitFlags(getterFunction, 16384); var getter = ts.createPropertyAssignment("get", getterFunction); ts.setCommentRange(getter, ts.getCommentRange(getAccessor)); properties.push(getter); @@ -39452,6 +39579,7 @@ var ts; if (setAccessor) { var setterFunction = transformFunctionLikeToExpression(setAccessor, undefined, undefined); ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); + ts.setEmitFlags(setterFunction, 16384); var setter = ts.createPropertyAssignment("set", setterFunction); ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); properties.push(setter); @@ -39468,7 +39596,7 @@ var ts; return call; } function visitArrowFunction(node) { - if (node.transformFlags & 8192) { + if (node.transformFlags & 32768) { enableSubstitutionsForCapturedThis(); } var func = transformFunctionLikeToExpression(node, node, undefined); @@ -39483,10 +39611,10 @@ var ts; } function transformFunctionLikeToExpression(node, location, name) { var savedContainingNonArrowFunction = enclosingNonArrowFunction; - if (node.kind !== 180) { + if (node.kind !== 181) { enclosingNonArrowFunction = node; } - var expression = ts.setOriginalNode(ts.createFunctionExpression(node.asteriskToken, name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, saveStateAndInvoke(node, transformFunctionBody), location), node); + var expression = ts.setOriginalNode(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, saveStateAndInvoke(node, transformFunctionBody), location), node); enclosingNonArrowFunction = savedContainingNonArrowFunction; return expression; } @@ -39516,7 +39644,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 180); + ts.Debug.assert(node.kind === 181); statementsLocation = ts.moveRangeEnd(body, -1); var equalsGreaterThanToken = node.equalsGreaterThanToken; if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { @@ -39543,16 +39671,16 @@ var ts; ts.setEmitFlags(block, 32); } if (closeBraceLocation) { - ts.setTokenSourceMapRange(block, 16, closeBraceLocation); + ts.setTokenSourceMapRange(block, 17, closeBraceLocation); } ts.setOriginalNode(block, node.body); return block; } function visitExpressionStatement(node) { switch (node.expression.kind) { - case 178: + case 179: return ts.updateStatement(node, visitParenthesizedExpression(node.expression, false)); - case 187: + case 188: return ts.updateStatement(node, visitBinaryExpression(node.expression, false)); } return ts.visitEachChild(node, visitor, context); @@ -39560,9 +39688,9 @@ var ts; function visitParenthesizedExpression(node, needsDestructuringValue) { if (needsDestructuringValue) { switch (node.expression.kind) { - case 178: + case 179: return ts.createParen(visitParenthesizedExpression(node.expression, true), node); - case 187: + case 188: return ts.createParen(visitBinaryExpression(node.expression, true), node); } } @@ -39581,16 +39709,16 @@ var ts; if (decl.initializer) { var assignment = void 0; if (ts.isBindingPattern(decl.name)) { - assignment = ts.flattenVariableDestructuringToExpression(context, decl, hoistVariableDeclaration, undefined, visitor); + assignment = ts.flattenVariableDestructuringToExpression(decl, hoistVariableDeclaration, undefined, visitor); } else { - assignment = ts.createBinary(decl.name, 56, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + assignment = ts.createBinary(decl.name, 57, ts.visitNode(decl.initializer, visitor, ts.isExpression)); } (assignments || (assignments = [])).push(assignment); } } if (assignments) { - return ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 24, acc); }), node); + return ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25, acc); }), node); } else { return undefined; @@ -39608,7 +39736,7 @@ var ts; var declarationList = ts.createVariableDeclarationList(declarations, node); ts.setOriginalNode(declarationList, node); ts.setCommentRange(declarationList, node); - if (node.transformFlags & 2097152 + if (node.transformFlags & 8388608 && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { var firstDeclaration = ts.firstOrUndefined(declarations); @@ -39627,8 +39755,8 @@ var ts; && ts.isBlock(enclosingBlockScopeContainer) && ts.isIterationStatement(enclosingBlockScopeContainerParent, false)); var emitExplicitInitializer = !emittedAsTopLevel - && enclosingBlockScopeContainer.kind !== 207 && enclosingBlockScopeContainer.kind !== 208 + && enclosingBlockScopeContainer.kind !== 209 && (!resolver.isDeclarationWithCollidingName(node) || (isDeclaredInLoop && !isCapturedInFunction @@ -39651,7 +39779,7 @@ var ts; if (ts.isBindingPattern(node.name)) { var recordTempVariablesInLine = !enclosingVariableStatement || !ts.hasModifier(enclosingVariableStatement, 1); - return ts.flattenVariableDestructuring(context, node, undefined, visitor, recordTempVariablesInLine ? undefined : hoistVariableDeclaration); + return ts.flattenVariableDestructuring(node, undefined, visitor, recordTempVariablesInLine ? undefined : hoistVariableDeclaration); } return ts.visitEachChild(node, visitor, context); } @@ -39694,7 +39822,7 @@ var ts; var initializer = node.initializer; var statements = []; var counter = ts.createLoopVariable(); - var rhsReference = expression.kind === 69 + var rhsReference = expression.kind === 70 ? ts.createUniqueName(expression.text) : ts.createTempVariable(undefined); if (ts.isVariableDeclarationList(initializer)) { @@ -39703,7 +39831,7 @@ var ts; } var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { - var declarations = ts.flattenVariableDestructuring(context, firstOriginalDeclaration, ts.createElementAccess(rhsReference, counter), visitor); + var declarations = ts.flattenVariableDestructuring(firstOriginalDeclaration, ts.createElementAccess(rhsReference, counter), visitor); var declarationList = ts.createVariableDeclarationList(declarations, initializer); ts.setOriginalNode(declarationList, initializer); var firstDeclaration = declarations[0]; @@ -39759,8 +39887,8 @@ var ts; var numInitialProperties = numProperties; for (var i = 0; i < numProperties; i++) { var property = properties[i]; - if (property.transformFlags & 4194304 - || property.name.kind === 140) { + if (property.transformFlags & 16777216 + || property.name.kind === 141) { numInitialProperties = i; break; } @@ -39786,7 +39914,7 @@ var ts; } visit(node.name); function visit(node) { - if (node.kind === 69) { + if (node.kind === 70) { state.hoistedLocalVariables.push(node); } else { @@ -39815,11 +39943,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 206: case 207: case 208: + case 209: var initializer = node.initializer; - if (initializer && initializer.kind === 219) { + if (initializer && initializer.kind === 220) { loopInitializer = initializer; } break; @@ -39858,7 +39986,7 @@ var ts; } var isAsyncBlockContainingAwait = enclosingNonArrowFunction && (ts.getEmitFlags(enclosingNonArrowFunction) & 2097152) !== 0 - && (node.statement.transformFlags & 4194304) !== 0; + && (node.statement.transformFlags & 16777216) !== 0; var loopBodyFlags = 0; if (currentState.containsLexicalThis) { loopBodyFlags |= 256; @@ -39867,7 +39995,7 @@ var ts; loopBodyFlags |= 2097152; } var convertedLoopVariable = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(functionName, undefined, ts.setEmitFlags(ts.createFunctionExpression(isAsyncBlockContainingAwait ? ts.createToken(37) : undefined, undefined, undefined, loopParameters, undefined, loopBody), loopBodyFlags)) + ts.createVariableDeclaration(functionName, undefined, ts.setEmitFlags(ts.createFunctionExpression(undefined, isAsyncBlockContainingAwait ? ts.createToken(38) : undefined, undefined, undefined, loopParameters, undefined, loopBody), loopBodyFlags)) ])); var statements = [convertedLoopVariable]; var extraVariableDeclarations; @@ -39926,7 +40054,7 @@ var ts; loop.transformFlags = 0; ts.aggregateTransformFlags(loop); } - statements.push(currentParent.kind === 214 + statements.push(currentParent.kind === 215 ? ts.createLabel(currentParent.label, loop) : loop); return statements; @@ -39934,7 +40062,7 @@ var ts; function copyOutParameter(outParam, copyDirection) { var source = copyDirection === 0 ? outParam.outParamName : outParam.originalName; var target = copyDirection === 0 ? outParam.originalName : outParam.outParamName; - return ts.createBinary(target, 56, source); + return ts.createBinary(target, 57, source); } function copyOutParameters(outParams, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { @@ -39949,7 +40077,7 @@ var ts; !state.labeledNonLocalBreaks && !state.labeledNonLocalContinues; var call = ts.createCall(loopFunctionExpressionName, undefined, ts.map(parameters, function (p) { return p.name; })); - var callResult = isAsyncBlockContainingAwait ? ts.createYield(ts.createToken(37), call) : call; + var callResult = isAsyncBlockContainingAwait ? ts.createYield(ts.createToken(38), call) : call; if (isSimpleLoop) { statements.push(ts.createStatement(callResult)); copyOutParameters(state.loopOutParameters, 0, statements); @@ -39968,10 +40096,10 @@ var ts; else { returnStatement = ts.createReturn(ts.createPropertyAccess(loopResultName, "value")); } - statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 32, ts.createLiteral("object")), returnStatement)); + statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 33, ts.createLiteral("object")), returnStatement)); } if (state.nonLocalJumps & 2) { - statements.push(ts.createIf(ts.createBinary(loopResultName, 32, ts.createLiteral("break")), ts.createBreak())); + statements.push(ts.createIf(ts.createBinary(loopResultName, 33, ts.createLiteral("break")), ts.createBreak())); } if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { var caseClauses = []; @@ -40038,21 +40166,21 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 149: case 150: + case 151: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node.multiLine)); } break; case 253: - expressions.push(transformPropertyAssignmentToExpression(node, property, receiver, node.multiLine)); + expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; case 254: - expressions.push(transformShorthandPropertyAssignmentToExpression(node, property, receiver, node.multiLine)); + expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 147: - expressions.push(transformObjectLiteralMethodDeclarationToExpression(node, property, receiver, node.multiLine)); + case 148: + expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node.multiLine)); break; default: ts.Debug.failBadSyntaxKind(node); @@ -40060,21 +40188,21 @@ var ts; } } } - function transformPropertyAssignmentToExpression(node, property, receiver, startsOnNewLine) { + function transformPropertyAssignmentToExpression(property, receiver, startsOnNewLine) { var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.visitNode(property.initializer, visitor, ts.isExpression), property); if (startsOnNewLine) { expression.startsOnNewLine = true; } return expression; } - function transformShorthandPropertyAssignmentToExpression(node, property, receiver, startsOnNewLine) { + function transformShorthandPropertyAssignmentToExpression(property, receiver, startsOnNewLine) { var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.getSynthesizedClone(property.name), property); if (startsOnNewLine) { expression.startsOnNewLine = true; } return expression; } - function transformObjectLiteralMethodDeclarationToExpression(node, method, receiver, startsOnNewLine) { + function transformObjectLiteralMethodDeclarationToExpression(method, receiver, startsOnNewLine) { var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, method, undefined), method); if (startsOnNewLine) { expression.startsOnNewLine = true; @@ -40104,17 +40232,17 @@ var ts; } function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) { var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 95) { + if (node.expression.kind === 96) { ts.setEmitFlags(thisArg, 128); } var resultingCall; - if (node.transformFlags & 262144) { + if (node.transformFlags & 1048576) { resultingCall = ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, false, false, false)); } else { resultingCall = ts.createFunctionCall(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), node); } - if (node.expression.kind === 95) { + if (node.expression.kind === 96) { var actualThis = ts.createThis(); ts.setEmitFlags(actualThis, 128); var initializer = ts.createLogicalOr(resultingCall, actualThis); @@ -40125,18 +40253,18 @@ var ts; return resultingCall; } function visitNewExpression(node) { - ts.Debug.assert((node.transformFlags & 262144) !== 0); + ts.Debug.assert((node.transformFlags & 1048576) !== 0); var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), false, false, false)), undefined, []); } function transformAndSpreadElements(elements, needsUniqueCopy, multiLine, hasTrailingComma) { var numElements = elements.length; - var segments = ts.flatten(ts.spanMap(elements, partitionSpreadElement, function (partition, visitPartition, start, end) { + var segments = ts.flatten(ts.spanMap(elements, partitionSpreadElement, function (partition, visitPartition, _start, end) { return visitPartition(partition, multiLine, hasTrailingComma && end === numElements); })); if (segments.length === 1) { var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadElementExpression(firstElement) && firstElement.expression.kind !== 170 + return needsUniqueCopy && ts.isSpreadElementExpression(firstElement) && firstElement.expression.kind !== 171 ? ts.createArraySlice(segments[0]) : segments[0]; } @@ -40147,7 +40275,7 @@ var ts; ? visitSpanOfSpreadElements : visitSpanOfNonSpreadElements; } - function visitSpanOfSpreadElements(chunk, multiLine, hasTrailingComma) { + function visitSpanOfSpreadElements(chunk) { return ts.map(chunk, visitExpressionOfSpreadElement); } function visitSpanOfNonSpreadElements(chunk, multiLine, hasTrailingComma) { @@ -40188,7 +40316,7 @@ var ts; } function getRawLiteral(node) { var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - var isLast = node.kind === 11 || node.kind === 14; + var isLast = node.kind === 12 || node.kind === 15; text = text.substring(1, text.length - (isLast ? 1 : 2)); text = text.replace(/\r\n?/g, "\n"); return ts.createLiteral(text, node); @@ -40222,11 +40350,11 @@ var ts; } } } - function visitSuperKeyword(node) { + function visitSuperKeyword() { return enclosingNonAsyncFunctionBody && ts.isClassElement(enclosingNonAsyncFunctionBody) && !ts.hasModifier(enclosingNonAsyncFunctionBody, 32) - && currentParent.kind !== 174 + && currentParent.kind !== 175 ? ts.createPropertyAccess(ts.createIdentifier("_super"), "prototype") : ts.createIdentifier("_super"); } @@ -40253,20 +40381,20 @@ var ts; function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; - context.enableSubstitution(69); + context.enableSubstitution(70); } } function enableSubstitutionsForCapturedThis() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(97); - context.enableEmitNotification(148); - context.enableEmitNotification(147); + context.enableSubstitution(98); context.enableEmitNotification(149); + context.enableEmitNotification(148); context.enableEmitNotification(150); + context.enableEmitNotification(151); + context.enableEmitNotification(181); context.enableEmitNotification(180); - context.enableEmitNotification(179); - context.enableEmitNotification(220); + context.enableEmitNotification(221); } } function onSubstituteNode(emitContext, node) { @@ -40291,10 +40419,10 @@ var ts; function isNameOfDeclarationWithCollidingName(node) { var parent = node.parent; switch (parent.kind) { - case 169: - case 221: - case 224: - case 218: + case 170: + case 222: + case 225: + case 219: return parent.name === node && resolver.isDeclarationWithCollidingName(parent); } @@ -40302,9 +40430,9 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 69: + case 70: return substituteExpressionIdentifier(node); - case 97: + case 98: return substituteThisKeyword(node); } return node; @@ -40331,7 +40459,7 @@ var ts; } function getDeclarationName(node, allowComments, allowSourceMaps, emitFlags) { if (node.name && !ts.isGeneratedIdentifier(node.name)) { - var name_36 = ts.getMutableClone(node.name); + var name_33 = ts.getMutableClone(node.name); emitFlags |= ts.getEmitFlags(node.name); if (!allowSourceMaps) { emitFlags |= 1536; @@ -40340,9 +40468,9 @@ var ts; emitFlags |= 49152; } if (emitFlags) { - ts.setEmitFlags(name_36, emitFlags); + ts.setEmitFlags(name_33, emitFlags); } - return name_36; + return name_33; } return ts.getGeneratedNameForNode(node); } @@ -40359,29 +40487,74 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 202) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 203) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 174) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 175) { return false; } var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 95) { + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 96) { return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 191) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 192) { return false; } var expression = callArgument.expression; return ts.isIdentifier(expression) && expression === parameter.name; } } - ts.transformES6 = transformES6; + ts.transformES2015 = transformES2015; })(ts || (ts = {})); var ts; (function (ts) { + var OpCode; + (function (OpCode) { + OpCode[OpCode["Nop"] = 0] = "Nop"; + OpCode[OpCode["Statement"] = 1] = "Statement"; + OpCode[OpCode["Assign"] = 2] = "Assign"; + OpCode[OpCode["Break"] = 3] = "Break"; + OpCode[OpCode["BreakWhenTrue"] = 4] = "BreakWhenTrue"; + OpCode[OpCode["BreakWhenFalse"] = 5] = "BreakWhenFalse"; + OpCode[OpCode["Yield"] = 6] = "Yield"; + OpCode[OpCode["YieldStar"] = 7] = "YieldStar"; + OpCode[OpCode["Return"] = 8] = "Return"; + OpCode[OpCode["Throw"] = 9] = "Throw"; + OpCode[OpCode["Endfinally"] = 10] = "Endfinally"; + })(OpCode || (OpCode = {})); + var BlockAction; + (function (BlockAction) { + BlockAction[BlockAction["Open"] = 0] = "Open"; + BlockAction[BlockAction["Close"] = 1] = "Close"; + })(BlockAction || (BlockAction = {})); + var CodeBlockKind; + (function (CodeBlockKind) { + CodeBlockKind[CodeBlockKind["Exception"] = 0] = "Exception"; + CodeBlockKind[CodeBlockKind["With"] = 1] = "With"; + CodeBlockKind[CodeBlockKind["Switch"] = 2] = "Switch"; + CodeBlockKind[CodeBlockKind["Loop"] = 3] = "Loop"; + CodeBlockKind[CodeBlockKind["Labeled"] = 4] = "Labeled"; + })(CodeBlockKind || (CodeBlockKind = {})); + var ExceptionBlockState; + (function (ExceptionBlockState) { + ExceptionBlockState[ExceptionBlockState["Try"] = 0] = "Try"; + ExceptionBlockState[ExceptionBlockState["Catch"] = 1] = "Catch"; + ExceptionBlockState[ExceptionBlockState["Finally"] = 2] = "Finally"; + ExceptionBlockState[ExceptionBlockState["Done"] = 3] = "Done"; + })(ExceptionBlockState || (ExceptionBlockState = {})); + var Instruction; + (function (Instruction) { + Instruction[Instruction["Next"] = 0] = "Next"; + Instruction[Instruction["Throw"] = 1] = "Throw"; + Instruction[Instruction["Return"] = 2] = "Return"; + Instruction[Instruction["Break"] = 3] = "Break"; + Instruction[Instruction["Yield"] = 4] = "Yield"; + Instruction[Instruction["YieldStar"] = 5] = "YieldStar"; + Instruction[Instruction["Catch"] = 6] = "Catch"; + Instruction[Instruction["Endfinally"] = 7] = "Endfinally"; + })(Instruction || (Instruction = {})); var instructionNames = ts.createMap((_a = {}, _a[2] = "return", _a[3] = "break", @@ -40427,7 +40600,7 @@ var ts; if (ts.isDeclarationFile(node)) { return node; } - if (node.transformFlags & 1024) { + if (node.transformFlags & 4096) { currentSourceFile = node; node = ts.visitEachChild(node, visitor, context); currentSourceFile = undefined; @@ -40442,10 +40615,10 @@ var ts; else if (inGeneratorFunctionBody) { return visitJavaScriptInGeneratorFunctionBody(node); } - else if (transformFlags & 512) { + else if (transformFlags & 2048) { return visitGenerator(node); } - else if (transformFlags & 1024) { + else if (transformFlags & 4096) { return ts.visitEachChild(node, visitor, context); } else { @@ -40454,13 +40627,13 @@ var ts; } function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 204: - return visitDoStatement(node); case 205: + return visitDoStatement(node); + case 206: return visitWhileStatement(node); - case 213: - return visitSwitchStatement(node); case 214: + return visitSwitchStatement(node); + case 215: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -40468,30 +40641,30 @@ var ts; } function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 220: + case 221: return visitFunctionDeclaration(node); - case 179: + case 180: return visitFunctionExpression(node); - case 149: case 150: + case 151: return visitAccessorDeclaration(node); - case 200: + case 201: return visitVariableStatement(node); - case 206: - return visitForStatement(node); case 207: + return visitForStatement(node); + case 208: return visitForInStatement(node); - case 210: - return visitBreakStatement(node); - case 209: - return visitContinueStatement(node); case 211: + return visitBreakStatement(node); + case 210: + return visitContinueStatement(node); + case 212: return visitReturnStatement(node); default: - if (node.transformFlags & 4194304) { + if (node.transformFlags & 16777216) { return visitJavaScriptContainingYield(node); } - else if (node.transformFlags & (1024 | 8388608)) { + else if (node.transformFlags & (4096 | 33554432)) { return ts.visitEachChild(node, visitor, context); } else { @@ -40501,21 +40674,21 @@ var ts; } function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 187: - return visitBinaryExpression(node); case 188: + return visitBinaryExpression(node); + case 189: return visitConditionalExpression(node); - case 190: + case 191: return visitYieldExpression(node); - case 170: - return visitArrayLiteralExpression(node); case 171: + return visitArrayLiteralExpression(node); + case 172: return visitObjectLiteralExpression(node); - case 173: - return visitElementAccessExpression(node); case 174: - return visitCallExpression(node); + return visitElementAccessExpression(node); case 175: + return visitCallExpression(node); + case 176: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -40523,9 +40696,9 @@ var ts; } function visitGenerator(node) { switch (node.kind) { - case 220: + case 221: return visitFunctionDeclaration(node); - case 179: + case 180: return visitFunctionExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -40555,7 +40728,7 @@ var ts; } function visitFunctionExpression(node) { if (node.asteriskToken && ts.getEmitFlags(node) & 2097152) { - node = ts.setOriginalNode(ts.createFunctionExpression(undefined, node.name, undefined, node.parameters, undefined, transformGeneratorFunctionBody(node.body), node), node); + node = ts.setOriginalNode(ts.createFunctionExpression(undefined, undefined, node.name, undefined, node.parameters, undefined, transformGeneratorFunctionBody(node.body), node), node); } else { var savedInGeneratorFunctionBody = inGeneratorFunctionBody; @@ -40628,7 +40801,7 @@ var ts; return ts.createBlock(statements, body, body.multiLine); } function visitVariableStatement(node) { - if (node.transformFlags & 4194304) { + if (node.transformFlags & 16777216) { transformAndEmitVariableDeclarationList(node.declarationList); return undefined; } @@ -40658,23 +40831,23 @@ var ts; } } function isCompoundAssignment(kind) { - return kind >= 57 - && kind <= 68; + return kind >= 58 + && kind <= 69; } function getOperatorForCompoundAssignment(kind) { switch (kind) { - case 57: return 35; case 58: return 36; case 59: return 37; case 60: return 38; case 61: return 39; case 62: return 40; - case 63: return 43; + case 63: return 41; case 64: return 44; case 65: return 45; case 66: return 46; case 67: return 47; case 68: return 48; + case 69: return 49; } } function visitRightAssociativeBinaryExpression(node) { @@ -40682,10 +40855,10 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 172: + case 173: target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 173: + case 174: target = ts.updateElementAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), cacheExpression(ts.visitNode(left.argumentExpression, visitor, ts.isExpression))); break; default: @@ -40694,7 +40867,7 @@ var ts; } var operator = node.operatorToken.kind; if (isCompoundAssignment(operator)) { - return ts.createBinary(target, 56, ts.createBinary(cacheExpression(target), getOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression), node), node); + return ts.createBinary(target, 57, ts.createBinary(cacheExpression(target), getOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression), node), node); } else { return ts.updateBinary(node, target, ts.visitNode(right, visitor, ts.isExpression)); @@ -40707,7 +40880,7 @@ var ts; if (ts.isLogicalOperator(node.operatorToken.kind)) { return visitLogicalBinaryExpression(node); } - else if (node.operatorToken.kind === 24) { + else if (node.operatorToken.kind === 25) { return visitCommaExpression(node); } var clone_6 = ts.getMutableClone(node); @@ -40721,7 +40894,7 @@ var ts; var resultLabel = defineLabel(); var resultLocal = declareLocal(); emitAssignment(resultLocal, ts.visitNode(node.left, visitor, ts.isExpression), node.left); - if (node.operatorToken.kind === 51) { + if (node.operatorToken.kind === 52) { emitBreakWhenFalse(resultLabel, resultLocal, node.left); } else { @@ -40737,7 +40910,7 @@ var ts; visit(node.right); return ts.inlineExpressions(pendingExpressions); function visit(node) { - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 24) { + if (ts.isBinaryExpression(node) && node.operatorToken.kind === 25) { visit(node.left); visit(node.right); } @@ -40780,7 +40953,7 @@ var ts; function visitArrayLiteralExpression(node) { return visitElements(node.elements, node.multiLine); } - function visitElements(elements, multiLine) { + function visitElements(elements, _multiLine) { var numInitialElements = countInitialNodesWithoutYield(elements); var temp = declareLocal(); var hasAssignedTemp = false; @@ -40841,14 +41014,14 @@ var ts; function visitCallExpression(node) { if (ts.forEach(node.arguments, containsYield)) { var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration, languageVersion, true), target = _a.target, thisArg = _a.thisArg; - return ts.setOriginalNode(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isLeftHandSideExpression)), thisArg, visitElements(node.arguments, false), node), node); + return ts.setOriginalNode(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isLeftHandSideExpression)), thisArg, visitElements(node.arguments), node), node); } return ts.visitEachChild(node, visitor, context); } function visitNewExpression(node) { if (ts.forEach(node.arguments, containsYield)) { var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.setOriginalNode(ts.createNew(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isExpression)), thisArg, visitElements(node.arguments, false)), undefined, [], node), node); + return ts.setOriginalNode(ts.createNew(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isExpression)), thisArg, visitElements(node.arguments)), undefined, [], node), node); } return ts.visitEachChild(node, visitor, context); } @@ -40877,35 +41050,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 199: + case 200: return transformAndEmitBlock(node); - case 202: - return transformAndEmitExpressionStatement(node); case 203: - return transformAndEmitIfStatement(node); + return transformAndEmitExpressionStatement(node); case 204: - return transformAndEmitDoStatement(node); + return transformAndEmitIfStatement(node); case 205: - return transformAndEmitWhileStatement(node); + return transformAndEmitDoStatement(node); case 206: - return transformAndEmitForStatement(node); + return transformAndEmitWhileStatement(node); case 207: + return transformAndEmitForStatement(node); + case 208: return transformAndEmitForInStatement(node); - case 209: - return transformAndEmitContinueStatement(node); case 210: - return transformAndEmitBreakStatement(node); + return transformAndEmitContinueStatement(node); case 211: - return transformAndEmitReturnStatement(node); + return transformAndEmitBreakStatement(node); case 212: - return transformAndEmitWithStatement(node); + return transformAndEmitReturnStatement(node); case 213: - return transformAndEmitSwitchStatement(node); + return transformAndEmitWithStatement(node); case 214: - return transformAndEmitLabeledStatement(node); + return transformAndEmitSwitchStatement(node); case 215: - return transformAndEmitThrowStatement(node); + return transformAndEmitLabeledStatement(node); case 216: + return transformAndEmitThrowStatement(node); + case 217: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement, true)); @@ -41290,7 +41463,7 @@ var ts; } } function containsYield(node) { - return node && (node.transformFlags & 4194304) !== 0; + return node && (node.transformFlags & 16777216) !== 0; } function countInitialNodesWithoutYield(nodes) { var numNodes = nodes.length; @@ -41320,9 +41493,9 @@ var ts; if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - var name_37 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); - if (name_37) { - var clone_8 = ts.getMutableClone(name_37); + var name_34 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); + if (name_34) { + var clone_8 = ts.getMutableClone(name_34); ts.setSourceMapRange(clone_8, node); ts.setCommentRange(clone_8, node); return clone_8; @@ -41431,7 +41604,7 @@ var ts; if (!renamedCatchVariables) { renamedCatchVariables = ts.createMap(); renamedCatchVariableDeclarations = ts.createMap(); - context.enableSubstitution(69); + context.enableSubstitution(70); } renamedCatchVariables[text] = true; renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; @@ -41630,7 +41803,7 @@ var ts; } return expression; } - return ts.createNode(193); + return ts.createNode(194); } function createInstruction(instruction) { var literal = ts.createLiteral(instruction); @@ -41718,7 +41891,7 @@ var ts; var buildResult = buildStatements(); return ts.createCall(ts.createHelperName(currentSourceFile.externalHelpersModuleName, "__generator"), undefined, [ ts.createThis(), - ts.setEmitFlags(ts.createFunctionExpression(undefined, undefined, undefined, [ts.createParameter(state)], undefined, ts.createBlock(buildResult, undefined, buildResult.length > 0)), 4194304) + ts.setEmitFlags(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(state)], undefined, ts.createBlock(buildResult, undefined, buildResult.length > 0)), 4194304) ]); } function buildStatements() { @@ -41985,6 +42158,51 @@ var ts; var _a; })(ts || (ts = {})); var ts; +(function (ts) { + function transformES5(context) { + var previousOnSubstituteNode = context.onSubstituteNode; + context.onSubstituteNode = onSubstituteNode; + context.enableSubstitution(173); + context.enableSubstitution(253); + return transformSourceFile; + function transformSourceFile(node) { + return node; + } + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (ts.isPropertyAccessExpression(node)) { + return substitutePropertyAccessExpression(node); + } + else if (ts.isPropertyAssignment(node)) { + return substitutePropertyAssignment(node); + } + return node; + } + function substitutePropertyAccessExpression(node) { + var literalName = trySubstituteReservedName(node.name); + if (literalName) { + return ts.createElementAccess(node.expression, literalName, node); + } + return node; + } + function substitutePropertyAssignment(node) { + var literalName = ts.isIdentifier(node.name) && trySubstituteReservedName(node.name); + if (literalName) { + return ts.updatePropertyAssignment(node, literalName, node.initializer); + } + return node; + } + function trySubstituteReservedName(name) { + var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(name.text) : undefined); + if (token >= 71 && token <= 106) { + return ts.createLiteral(name, name); + } + return undefined; + } + } + ts.transformES5 = transformES5; +})(ts || (ts = {})); +var ts; (function (ts) { function transformModule(context) { var transformModuleDelegates = ts.createMap((_a = {}, @@ -42003,10 +42221,10 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(69); - context.enableSubstitution(187); - context.enableSubstitution(185); + context.enableSubstitution(70); + context.enableSubstitution(188); context.enableSubstitution(186); + context.enableSubstitution(187); context.enableSubstitution(254); context.enableEmitNotification(256); var currentSourceFile; @@ -42023,7 +42241,7 @@ var ts; } if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { currentSourceFile = node; - (_a = ts.collectExternalModuleInfo(node, resolver), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); + (_a = ts.collectExternalModuleInfo(node), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); var transformModule_1 = transformModuleDelegates[moduleKind] || transformModuleDelegates[ts.ModuleKind.None]; var updated = transformModule_1(node); ts.aggregateTransformFlags(updated); @@ -42068,7 +42286,7 @@ var ts; ts.createLiteral("require"), ts.createLiteral("exports") ].concat(aliasedModuleNames, unaliasedModuleNames)), - ts.createFunctionExpression(undefined, undefined, undefined, [ + ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ ts.createParameter("require"), ts.createParameter("exports") ].concat(importAliasNames), undefined, transformAsynchronousModuleBody(node)) @@ -42089,7 +42307,7 @@ var ts; return body; } function addExportEqualsIfNeeded(statements, emitAsReturn) { - if (exportEquals && resolver.isValueAliasDeclaration(exportEquals)) { + if (exportEquals) { if (emitAsReturn) { var statement = ts.createReturn(exportEquals.expression, exportEquals); ts.setEmitFlags(statement, 12288 | 49152); @@ -42104,21 +42322,21 @@ var ts; } function visitor(node) { switch (node.kind) { - case 230: + case 231: return visitImportDeclaration(node); - case 229: + case 230: return visitImportEqualsDeclaration(node); - case 236: + case 237: return visitExportDeclaration(node); - case 235: + case 236: return visitExportAssignment(node); - case 200: + case 201: return visitVariableStatement(node); - case 220: - return visitFunctionDeclaration(node); case 221: + return visitFunctionDeclaration(node); + case 222: return visitClassDeclaration(node); - case 202: + case 203: return visitExpressionStatement(node); default: return node; @@ -42194,14 +42412,12 @@ var ts; } for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; - if (resolver.isValueAliasDeclaration(specifier)) { - var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); - statements.push(ts.createStatement(createExportAssignment(specifier.name, exportedValue), specifier)); - } + var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); + statements.push(ts.createStatement(createExportAssignment(specifier.name, exportedValue), specifier)); } return ts.singleOrMany(statements); } - else if (resolver.moduleExportsSomeValue(node.moduleSpecifier)) { + else { return ts.createStatement(ts.createCall(ts.createIdentifier("__export"), undefined, [ moduleKind !== ts.ModuleKind.AMD ? createRequireCall(node) @@ -42210,14 +42426,12 @@ var ts; } } function visitExportAssignment(node) { - if (!node.isExportEquals) { - if (ts.nodeIsSynthesized(node) || resolver.isValueAliasDeclaration(node)) { - var statements = []; - addExportDefault(statements, node.expression, node); - return statements; - } + if (node.isExportEquals) { + return undefined; } - return undefined; + var statements = []; + addExportDefault(statements, node.expression, node); + return statements; } function addExportDefault(statements, expression, location) { tryAddExportDefaultCompat(statements); @@ -42248,16 +42462,16 @@ var ts; else { var names = ts.reduceEachChild(node, collectExportMembers, []); for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_38 = names_1[_i]; - addExportMemberAssignments(statements, name_38); + var name_35 = names_1[_i]; + addExportMemberAssignments(statements, name_35); } } } function collectExportMembers(names, node) { - if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node) && ts.isDeclaration(node)) { - var name_39 = node.name; - if (ts.isIdentifier(name_39)) { - names.push(name_39); + if (ts.isAliasSymbolDeclaration(node) && ts.isDeclaration(node)) { + var name_36 = node.name; + if (ts.isIdentifier(name_36)) { + names.push(name_36); } } return ts.reduceEachChild(node, collectExportMembers, names); @@ -42280,9 +42494,9 @@ var ts; } function visitVariableStatement(node) { var originalKind = ts.getOriginalNode(node).kind; - if (originalKind === 225 || - originalKind === 224 || - originalKind === 221) { + if (originalKind === 226 || + originalKind === 225 || + originalKind === 222) { if (!ts.hasModifier(node, 1)) { return node; } @@ -42328,7 +42542,7 @@ var ts; function transformInitializedVariable(node) { var name = node.name; if (ts.isBindingPattern(name)) { - return ts.flattenVariableDestructuringToExpression(context, node, hoistVariableDeclaration, getModuleMemberName, visitor); + return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, getModuleMemberName, visitor); } else { return ts.createAssignment(getModuleMemberName(name), ts.visitNode(node.initializer, visitor, ts.isExpression)); @@ -42338,7 +42552,8 @@ var ts; var statements = []; var name = node.name || ts.getGeneratedNameForNode(node); if (ts.hasModifier(node, 1)) { - statements.push(ts.setOriginalNode(ts.createFunctionDeclaration(undefined, undefined, node.asteriskToken, name, undefined, node.parameters, undefined, node.body, node), node)); + var isAsync = ts.hasModifier(node, 256); + statements.push(ts.setOriginalNode(ts.createFunctionDeclaration(undefined, isAsync ? [ts.createNode(119)] : undefined, node.asteriskToken, name, undefined, node.parameters, undefined, node.body, node), node)); addExportMemberAssignment(statements, node); } else { @@ -42367,10 +42582,10 @@ var ts; function visitExpressionStatement(node) { var original = ts.getOriginalNode(node); var origKind = original.kind; - if (origKind === 224 || origKind === 225) { + if (origKind === 225 || origKind === 226) { return visitExpressionStatementForEnumOrNamespaceDeclaration(node, original); } - else if (origKind === 221) { + else if (origKind === 222) { var classDecl = original; if (classDecl.name) { var statements = [node]; @@ -42383,8 +42598,8 @@ var ts; function visitExpressionStatementForEnumOrNamespaceDeclaration(node, original) { var statements = [node]; if (ts.hasModifier(original, 1) && - original.kind === 224 && - ts.isFirstDeclarationOfKind(original, 224)) { + original.kind === 225 && + ts.isFirstDeclarationOfKind(original, 225)) { addVarForExportedEnumOrNamespaceDeclaration(statements, original); } addExportMemberAssignments(statements, original.name); @@ -42432,12 +42647,12 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 69: + case 70: return substituteExpressionIdentifier(node); - case 187: + case 188: return substituteBinaryExpression(node); + case 187: case 186: - case 185: return substituteUnaryExpression(node); } return node; @@ -42471,8 +42686,8 @@ var ts; if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, operand.text)) { ts.setEmitFlags(node, 128); var transformedUnaryExpression = void 0; - if (node.kind === 186) { - transformedUnaryExpression = ts.createBinary(operand, ts.createToken(operator === 41 ? 57 : 58), ts.createLiteral(1), node); + if (node.kind === 187) { + transformedUnaryExpression = ts.createBinary(operand, ts.createToken(operator === 42 ? 58 : 59), ts.createLiteral(1), node); ts.setEmitFlags(transformedUnaryExpression, 128); } var nestedExportAssignment = void 0; @@ -42504,21 +42719,11 @@ var ts; var declaration = resolver.getReferencedImportDeclaration(node); if (declaration) { if (ts.isImportClause(declaration)) { - if (languageVersion >= 1) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent), ts.createIdentifier("default"), node); - } - else { - return ts.createElementAccess(ts.getGeneratedNameForNode(declaration.parent), ts.createLiteral("default"), node); - } + return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent), ts.createIdentifier("default"), node); } else if (ts.isImportSpecifier(declaration)) { - var name_40 = declaration.propertyName || declaration.name; - if (name_40.originalKeywordKind === 77 && languageVersion <= 0) { - return ts.createElementAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.createLiteral(name_40.text), node); - } - else { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.getSynthesizedClone(name_40), node); - } + var name_37 = declaration.propertyName || declaration.name; + return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.getSynthesizedClone(name_37), node); } } } @@ -42544,9 +42749,7 @@ var ts; return statement; } function createExportAssignment(name, value) { - return ts.createAssignment(name.originalKeywordKind === 77 && languageVersion === 0 - ? ts.createElementAccess(ts.createIdentifier("exports"), ts.createLiteral(name.text)) - : ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value); + return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value); } function collectAsynchronousDependencies(node, includeNonAmdDependencies) { var aliasedModuleNames = []; @@ -42593,15 +42796,14 @@ var ts; var compilerOptions = context.getCompilerOptions(); var resolver = context.getEmitResolver(); var host = context.getEmitHost(); - var languageVersion = ts.getEmitScriptTarget(compilerOptions); var previousOnSubstituteNode = context.onSubstituteNode; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(69); - context.enableSubstitution(187); - context.enableSubstitution(185); + context.enableSubstitution(70); + context.enableSubstitution(188); context.enableSubstitution(186); + context.enableSubstitution(187); context.enableEmitNotification(256); var exportFunctionForFileMap = []; var currentSourceFile; @@ -42641,7 +42843,7 @@ var ts; } function transformSystemModuleWorker(node) { ts.Debug.assert(!exportFunctionForFile); - (_a = ts.collectExternalModuleInfo(node, resolver), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); + (_a = ts.collectExternalModuleInfo(node), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); exportFunctionForFile = ts.createUniqueName("exports"); contextObjectForFile = ts.createUniqueName("context"); exportFunctionForFileMap[ts.getOriginalNodeId(node)] = exportFunctionForFile; @@ -42650,7 +42852,7 @@ var ts; addSystemModuleBody(statements, node, dependencyGroups); var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, getNameOfDependencyGroup)); - var body = ts.createFunctionExpression(undefined, undefined, undefined, [ + var body = ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ ts.createParameter(exportFunctionForFile), ts.createParameter(contextObjectForFile) ], undefined, ts.setEmitFlags(ts.createBlock(statements, undefined, true), 1)); @@ -42673,7 +42875,7 @@ var ts; var exportStarFunction = addExportStarIfNeeded(statements); statements.push(ts.createReturn(ts.setMultiLine(ts.createObjectLiteral([ ts.createPropertyAssignment("setters", generateSetters(exportStarFunction, dependencyGroups)), - ts.createPropertyAssignment("execute", ts.createFunctionExpression(undefined, undefined, undefined, [], undefined, ts.createBlock(executeStatements, undefined, true))) + ts.createPropertyAssignment("execute", ts.createFunctionExpression(undefined, undefined, undefined, undefined, [], undefined, ts.createBlock(executeStatements, undefined, true))) ]), true))); } function addExportStarIfNeeded(statements) { @@ -42684,7 +42886,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, externalImports_2 = externalImports; _i < externalImports_2.length; _i++) { var externalImport = externalImports_2[_i]; - if (externalImport.kind === 236 && externalImport.exportClause) { + if (externalImport.kind === 237 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -42702,7 +42904,7 @@ var ts; } for (var _b = 0, externalImports_3 = externalImports; _b < externalImports_3.length; _b++) { var externalImport = externalImports_3[_b]; - if (externalImport.kind !== 236) { + if (externalImport.kind !== 237) { continue; } var exportDecl = externalImport; @@ -42731,15 +42933,15 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); switch (entry.kind) { - case 230: + case 231: if (!entry.importClause) { break; } - case 229: + case 230: ts.Debug.assert(importVariableName !== undefined); statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 236: + case 237: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { var properties = []; @@ -42755,19 +42957,19 @@ var ts; break; } } - setters.push(ts.createFunctionExpression(undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, ts.createBlock(statements, undefined, true))); + setters.push(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, ts.createBlock(statements, undefined, true))); } return ts.createArrayLiteral(setters, undefined, true); } function visitSourceElement(node) { switch (node.kind) { - case 230: + case 231: return visitImportDeclaration(node); - case 229: + case 230: return visitImportEqualsDeclaration(node); - case 236: + case 237: return visitExportDeclaration(node); - case 235: + case 236: return visitExportAssignment(node); default: return visitNestedNode(node); @@ -42791,41 +42993,41 @@ var ts; } function visitNestedNodeWorker(node) { switch (node.kind) { - case 200: + case 201: return visitVariableStatement(node); - case 220: - return visitFunctionDeclaration(node); case 221: + return visitFunctionDeclaration(node); + case 222: return visitClassDeclaration(node); - case 206: - return visitForStatement(node); case 207: - return visitForInStatement(node); + return visitForStatement(node); case 208: + return visitForInStatement(node); + case 209: return visitForOfStatement(node); - case 204: - return visitDoStatement(node); case 205: + return visitDoStatement(node); + case 206: return visitWhileStatement(node); - case 214: + case 215: return visitLabeledStatement(node); - case 212: - return visitWithStatement(node); case 213: + return visitWithStatement(node); + case 214: return visitSwitchStatement(node); - case 227: + case 228: return visitCaseBlock(node); case 249: return visitCaseClause(node); case 250: return visitDefaultClause(node); - case 216: + case 217: return visitTryStatement(node); case 252: return visitCatchClause(node); - case 199: + case 200: return visitBlock(node); - case 202: + case 203: return visitExpressionStatement(node); default: return node; @@ -42852,20 +43054,14 @@ var ts; return undefined; } function visitExportSpecifier(specifier) { - if (resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) - || resolver.isValueAliasDeclaration(specifier)) { - recordExportName(specifier.name); - return createExportStatement(specifier.name, specifier.propertyName || specifier.name); - } - return undefined; + recordExportName(specifier.name); + return createExportStatement(specifier.name, specifier.propertyName || specifier.name); } function visitExportAssignment(node) { - if (!node.isExportEquals) { - if (ts.nodeIsSynthesized(node) || resolver.isValueAliasDeclaration(node)) { - return createExportStatement(ts.createLiteral("default"), node.expression); - } + if (node.isExportEquals) { + return undefined; } - return undefined; + return createExportStatement(ts.createLiteral("default"), node.expression); } function visitVariableStatement(node) { var shouldHoist = ((ts.getCombinedNodeFlags(ts.getOriginalNode(node.declarationList)) & 3) == 0) || @@ -42897,16 +43093,17 @@ var ts; return ts.createAssignment(name, node.initializer); } else { - return ts.flattenVariableDestructuringToExpression(context, node, hoistVariableDeclaration); + return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration); } } function visitFunctionDeclaration(node) { if (ts.hasModifier(node, 1)) { - var name_41 = node.name || ts.getGeneratedNameForNode(node); - var newNode = ts.createFunctionDeclaration(undefined, undefined, node.asteriskToken, name_41, undefined, node.parameters, undefined, node.body, node); + var name_38 = node.name || ts.getGeneratedNameForNode(node); + var isAsync = ts.hasModifier(node, 256); + var newNode = ts.createFunctionDeclaration(undefined, isAsync ? [ts.createNode(119)] : undefined, node.asteriskToken, name_38, undefined, node.parameters, undefined, node.body, node); recordExportedFunctionDeclaration(node); if (!ts.hasModifier(node, 512)) { - recordExportName(name_41); + recordExportName(name_38); } ts.setOriginalNode(newNode, node); node = newNode; @@ -42916,14 +43113,14 @@ var ts; } function visitExpressionStatement(node) { var originalNode = ts.getOriginalNode(node); - if ((originalNode.kind === 225 || originalNode.kind === 224) && ts.hasModifier(originalNode, 1)) { - var name_42 = getDeclarationName(originalNode); - if (originalNode.kind === 224) { - hoistVariableDeclaration(name_42); + if ((originalNode.kind === 226 || originalNode.kind === 225) && ts.hasModifier(originalNode, 1)) { + var name_39 = getDeclarationName(originalNode); + if (originalNode.kind === 225) { + hoistVariableDeclaration(name_39); } return [ node, - createExportStatement(name_42, name_42) + createExportStatement(name_39, name_39) ]; } return node; @@ -42958,7 +43155,7 @@ var ts; ; return ts.createFor(expressions.length ? ts.inlineExpressions(expressions) - : ts.createSynthesizedNode(193), node.condition, node.incrementor, ts.visitNode(node.statement, visitNestedNode, ts.isStatement), node); + : ts.createSynthesizedNode(194), node.condition, node.incrementor, ts.visitNode(node.statement, visitNestedNode, ts.isStatement), node); } else { return ts.visitEachChild(node, visitNestedNode, context); @@ -42970,7 +43167,7 @@ var ts; var name = firstDeclaration.name; return ts.isIdentifier(name) ? name - : ts.flattenVariableDestructuringToExpression(context, firstDeclaration, hoistVariableDeclaration); + : ts.flattenVariableDestructuringToExpression(firstDeclaration, hoistVariableDeclaration); } function visitForInStatement(node) { var initializer = node.initializer; @@ -43096,12 +43293,12 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 69: + case 70: return substituteExpressionIdentifier(node); - case 187: + case 188: return substituteBinaryExpression(node); - case 185: case 186: + case 187: return substituteUnaryExpression(node); } return node; @@ -43126,14 +43323,14 @@ var ts; ts.setEmitFlags(node, 128); var left = node.left; switch (left.kind) { - case 69: + case 70: var exportDeclaration = resolver.getReferencedExportContainer(left); if (exportDeclaration) { return createExportExpression(left, node); } break; + case 172: case 171: - case 170: if (hasExportedReferenceInDestructuringPattern(left)) { return substituteDestructuring(node); } @@ -43147,9 +43344,9 @@ var ts; } function hasExportedReferenceInDestructuringPattern(node) { switch (node.kind) { - case 69: + case 70: return isExportedBinding(node); - case 171: + case 172: for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var property = _a[_i]; if (hasExportedReferenceInObjectDestructuringElement(property)) { @@ -43157,7 +43354,7 @@ var ts; } } break; - case 170: + case 171: for (var _b = 0, _c = node.elements; _b < _c.length; _b++) { var element = _c[_b]; if (hasExportedReferenceInArrayDestructuringElement(element)) { @@ -43191,7 +43388,7 @@ var ts; function hasExportedReferenceInDestructuringElement(node) { if (ts.isBinaryExpression(node)) { var left = node.left; - return node.operatorToken.kind === 56 + return node.operatorToken.kind === 57 && isDestructuringPattern(left) && hasExportedReferenceInDestructuringPattern(left); } @@ -43211,9 +43408,9 @@ var ts; } function isDestructuringPattern(node) { var kind = node.kind; - return kind === 69 - || kind === 171 - || kind === 170; + return kind === 70 + || kind === 172 + || kind === 171; } function substituteDestructuring(node) { return ts.flattenDestructuringAssignment(context, node, true, hoistVariableDeclaration); @@ -43222,19 +43419,19 @@ var ts; var operand = node.operand; var operator = node.operator; var substitute = ts.isIdentifier(operand) && - (node.kind === 186 || - (node.kind === 185 && (operator === 41 || operator === 42))); + (node.kind === 187 || + (node.kind === 186 && (operator === 42 || operator === 43))); if (substitute) { var exportDeclaration = resolver.getReferencedExportContainer(operand); if (exportDeclaration) { var expr = ts.createPrefix(node.operator, operand, node); ts.setEmitFlags(expr, 128); var call = createExportExpression(operand, expr); - if (node.kind === 185) { + if (node.kind === 186) { return call; } else { - return operator === 41 + return operator === 42 ? ts.createSubtract(call, ts.createLiteral(1)) : ts.createAdd(call, ts.createLiteral(1)); } @@ -43293,12 +43490,7 @@ var ts; else { return undefined; } - if (name.originalKeywordKind && languageVersion === 0) { - return ts.createElementAccess(importAlias, ts.createLiteral(name.text)); - } - else { - return ts.createPropertyAccess(importAlias, ts.getSynthesizedClone(name)); - } + return ts.createPropertyAccess(importAlias, ts.getSynthesizedClone(name)); } function collectDependencyGroups(externalImports) { var groupIndices = ts.createMap(); @@ -43369,17 +43561,14 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function transformES6Module(context) { + function transformES2015Module(context) { var compilerOptions = context.getCompilerOptions(); - var resolver = context.getEmitResolver(); - var currentSourceFile; return transformSourceFile; function transformSourceFile(node) { if (ts.isDeclarationFile(node)) { return node; } if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - currentSourceFile = node; return ts.visitEachChild(node, visitor, context); } return node; @@ -43387,115 +43576,33 @@ var ts; function visitor(node) { switch (node.kind) { case 230: - return visitImportDeclaration(node); - case 229: - return visitImportEqualsDeclaration(node); - case 231: - return visitImportClause(node); - case 233: - case 232: - return visitNamedBindings(node); - case 234: - return visitImportSpecifier(node); - case 235: - return visitExportAssignment(node); + return undefined; case 236: - return visitExportDeclaration(node); - case 237: - return visitNamedExports(node); - case 238: - return visitExportSpecifier(node); + return visitExportAssignment(node); } return node; } function visitExportAssignment(node) { - if (node.isExportEquals) { - return undefined; - } - var original = ts.getOriginalNode(node); - return ts.nodeIsSynthesized(original) || resolver.isValueAliasDeclaration(original) ? node : undefined; - } - function visitExportDeclaration(node) { - if (!node.exportClause) { - return resolver.moduleExportsSomeValue(node.moduleSpecifier) ? node : undefined; - } - if (!resolver.isValueAliasDeclaration(node)) { - return undefined; - } - var newExportClause = ts.visitNode(node.exportClause, visitor, ts.isNamedExports, true); - if (node.exportClause === newExportClause) { - return node; - } - return newExportClause - ? ts.createExportDeclaration(undefined, undefined, newExportClause, node.moduleSpecifier) - : undefined; - } - function visitNamedExports(node) { - var newExports = ts.visitNodes(node.elements, visitor, ts.isExportSpecifier); - if (node.elements === newExports) { - return node; - } - return newExports.length ? ts.createNamedExports(newExports) : undefined; - } - function visitExportSpecifier(node) { - return resolver.isValueAliasDeclaration(node) ? node : undefined; - } - function visitImportEqualsDeclaration(node) { - return !ts.isExternalModuleImportEqualsDeclaration(node) || resolver.isReferencedAliasDeclaration(node) ? node : undefined; - } - function visitImportDeclaration(node) { - if (node.importClause) { - var newImportClause = ts.visitNode(node.importClause, visitor, ts.isImportClause); - if (!newImportClause.name && !newImportClause.namedBindings) { - return undefined; - } - else if (newImportClause !== node.importClause) { - return ts.createImportDeclaration(undefined, undefined, newImportClause, node.moduleSpecifier); - } - } - return node; - } - function visitImportClause(node) { - var newDefaultImport = node.name; - if (!resolver.isReferencedAliasDeclaration(node)) { - newDefaultImport = undefined; - } - var newNamedBindings = ts.visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true); - return newDefaultImport !== node.name || newNamedBindings !== node.namedBindings - ? ts.createImportClause(newDefaultImport, newNamedBindings) - : node; - } - function visitNamedBindings(node) { - if (node.kind === 232) { - return resolver.isReferencedAliasDeclaration(node) ? node : undefined; - } - else { - var newNamedImportElements = ts.visitNodes(node.elements, visitor, ts.isImportSpecifier); - if (!newNamedImportElements || newNamedImportElements.length == 0) { - return undefined; - } - if (newNamedImportElements === node.elements) { - return node; - } - return ts.createNamedImports(newNamedImportElements); - } - } - function visitImportSpecifier(node) { - return resolver.isReferencedAliasDeclaration(node) ? node : undefined; + return node.isExportEquals ? undefined : node; } } - ts.transformES6Module = transformES6Module; + ts.transformES2015Module = transformES2015Module; })(ts || (ts = {})); var ts; (function (ts) { var moduleTransformerMap = ts.createMap((_a = {}, - _a[ts.ModuleKind.ES6] = ts.transformES6Module, + _a[ts.ModuleKind.ES2015] = ts.transformES2015Module, _a[ts.ModuleKind.System] = ts.transformSystemModule, _a[ts.ModuleKind.AMD] = ts.transformModule, _a[ts.ModuleKind.CommonJS] = ts.transformModule, _a[ts.ModuleKind.UMD] = ts.transformModule, _a[ts.ModuleKind.None] = ts.transformModule, _a)); + var SyntaxKindFeatureFlags; + (function (SyntaxKindFeatureFlags) { + SyntaxKindFeatureFlags[SyntaxKindFeatureFlags["Substitution"] = 1] = "Substitution"; + SyntaxKindFeatureFlags[SyntaxKindFeatureFlags["EmitNotifications"] = 2] = "EmitNotifications"; + })(SyntaxKindFeatureFlags || (SyntaxKindFeatureFlags = {})); function getTransformers(compilerOptions) { var jsx = compilerOptions.jsx; var languageVersion = ts.getEmitScriptTarget(compilerOptions); @@ -43506,11 +43613,19 @@ var ts; if (jsx === 2) { transformers.push(ts.transformJsx); } - transformers.push(ts.transformES7); + if (languageVersion < 4) { + transformers.push(ts.transformES2017); + } + if (languageVersion < 3) { + transformers.push(ts.transformES2016); + } if (languageVersion < 2) { - transformers.push(ts.transformES6); + transformers.push(ts.transformES2015); transformers.push(ts.transformGenerators); } + if (languageVersion < 1) { + transformers.push(ts.transformES5); + } return transformers; } ts.getTransformers = getTransformers; @@ -43530,7 +43645,7 @@ var ts; hoistFunctionDeclaration: hoistFunctionDeclaration, startLexicalEnvironment: startLexicalEnvironment, endLexicalEnvironment: endLexicalEnvironment, - onSubstituteNode: function (emitContext, node) { return node; }, + onSubstituteNode: function (_emitContext, node) { return node; }, enableSubstitution: enableSubstitution, isSubstitutionEnabled: isSubstitutionEnabled, onEmitNode: function (node, emitContext, emitCallback) { return emitCallback(node, emitContext); }, @@ -43670,7 +43785,7 @@ var ts; var isCurrentFileExternalModule; var reportedDeclarationError = false; var errorNameNode; - var emitJsDocComments = compilerOptions.removeComments ? function (declaration) { } : writeJsDocComments; + var emitJsDocComments = compilerOptions.removeComments ? function () { } : writeJsDocComments; var emit = compilerOptions.stripInternal ? stripInternal : emitNode; var noDeclare; var moduleElementDeclarationEmitInfo = []; @@ -43714,7 +43829,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 230); + ts.Debug.assert(aliasEmitInfo.node.kind === 231); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -43745,7 +43860,7 @@ var ts; reportedDeclarationError: reportedDeclarationError, moduleElementDeclarationEmitInfo: allSourcesModuleElementDeclarationEmitInfo, synchronousDeclarationOutput: writer.getText(), - referencesOutput: referencesOutput + referencesOutput: referencesOutput, }; function hasInternalAnnotation(range) { var comment = currentText.substring(range.pos, range.end); @@ -43785,10 +43900,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 218) { + if (declaration.kind === 219) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 233 || declaration.kind === 234 || declaration.kind === 231) { + else if (declaration.kind === 234 || declaration.kind === 235 || declaration.kind === 232) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -43799,7 +43914,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 230) { + if (moduleElementEmitInfo.node.kind === 231) { moduleElementEmitInfo.isVisible = true; } else { @@ -43807,12 +43922,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 225) { + if (nodeToCheck.kind === 226) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 225) { + if (nodeToCheck.kind === 226) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -43924,67 +44039,67 @@ var ts; } function emitType(type) { switch (type.kind) { - case 117: - case 132: - case 130: - case 120: + case 118: case 133: - case 103: - case 135: - case 93: - case 127: - case 165: + case 131: + case 121: + case 134: + case 104: + case 136: + case 94: + case 128: case 166: + case 167: return writeTextOfNode(currentText, type); - case 194: + case 195: return emitExpressionWithTypeArguments(type); - case 155: - return emitTypeReference(type); - case 158: - return emitTypeQuery(type); - case 160: - return emitArrayType(type); - case 161: - return emitTupleType(type); - case 162: - return emitUnionType(type); - case 163: - return emitIntersectionType(type); - case 164: - return emitParenType(type); case 156: - case 157: - return emitSignatureDeclarationWithJsDocComments(type); + return emitTypeReference(type); case 159: + return emitTypeQuery(type); + case 161: + return emitArrayType(type); + case 162: + return emitTupleType(type); + case 163: + return emitUnionType(type); + case 164: + return emitIntersectionType(type); + case 165: + return emitParenType(type); + case 157: + case 158: + return emitSignatureDeclarationWithJsDocComments(type); + case 160: return emitTypeLiteral(type); - case 69: + case 70: return emitEntityName(type); - case 139: + case 140: return emitEntityName(type); - case 154: + case 155: return emitTypePredicate(type); } function writeEntityName(entityName) { - if (entityName.kind === 69) { + if (entityName.kind === 70) { writeTextOfNode(currentText, entityName); } else { - var left = entityName.kind === 139 ? entityName.left : entityName.expression; - var right = entityName.kind === 139 ? entityName.right : entityName.name; + var left = entityName.kind === 140 ? entityName.left : entityName.expression; + var right = entityName.kind === 140 ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentText, right); } } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 229 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 230 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isEntityNameExpression(node.expression)) { - ts.Debug.assert(node.expression.kind === 69 || node.expression.kind === 172); + ts.Debug.assert(node.expression.kind === 70 || node.expression.kind === 173); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -44058,14 +44173,14 @@ var ts; var count = 0; while (true) { count++; - var name_43 = baseName + "_" + count; - if (!(name_43 in currentIdentifiers)) { - return name_43; + var name_40 = baseName + "_" + count; + if (!(name_40 in currentIdentifiers)) { + return name_40; } } } function emitExportAssignment(node) { - if (node.expression.kind === 69) { + if (node.expression.kind === 70) { write(node.isExportEquals ? "export = " : "export default "); writeTextOfNode(currentText, node.expression); } @@ -44086,11 +44201,11 @@ var ts; } write(";"); writeLine(); - if (node.expression.kind === 69) { + if (node.expression.kind === 70) { var nodes = resolver.collectLinkedAliases(node.expression); writeAsynchronousModuleElements(nodes); } - function getDefaultExportAccessibilityDiagnostic(diagnostic) { + function getDefaultExportAccessibilityDiagnostic() { return { diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, errorNode: node @@ -44104,7 +44219,7 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 229 || + else if (node.kind === 230 || (node.parent.kind === 256 && isCurrentFileExternalModule)) { var isVisible = void 0; if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 256) { @@ -44116,7 +44231,7 @@ var ts; }); } else { - if (node.kind === 230) { + if (node.kind === 231) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -44134,23 +44249,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 220: - return writeFunctionDeclaration(node); - case 200: - return writeVariableStatement(node); - case 222: - return writeInterfaceDeclaration(node); case 221: - return writeClassDeclaration(node); + return writeFunctionDeclaration(node); + case 201: + return writeVariableStatement(node); case 223: - return writeTypeAliasDeclaration(node); + return writeInterfaceDeclaration(node); + case 222: + return writeClassDeclaration(node); case 224: - return writeEnumDeclaration(node); + return writeTypeAliasDeclaration(node); case 225: + return writeEnumDeclaration(node); + case 226: return writeModuleDeclaration(node); - case 229: - return writeImportEqualsDeclaration(node); case 230: + return writeImportEqualsDeclaration(node); + case 231: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -44165,7 +44280,7 @@ var ts; if (modifiers & 512) { write("default "); } - else if (node.kind !== 222 && !noDeclare) { + else if (node.kind !== 223 && !noDeclare) { write("declare "); } } @@ -44205,7 +44320,7 @@ var ts; write(");"); } writer.writeLine(); - function getImportEntityNameVisibilityError(symbolAccessibilityResult) { + function getImportEntityNameVisibilityError() { return { diagnosticMessage: ts.Diagnostics.Import_declaration_0_is_using_private_name_1, errorNode: node, @@ -44215,7 +44330,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 232) { + if (namedBindings.kind === 233) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -44238,7 +44353,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 232) { + if (node.importClause.namedBindings.kind === 233) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -44255,13 +44370,13 @@ var ts; writer.writeLine(); } function emitExternalModuleSpecifier(parent) { - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 225; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 226; var moduleSpecifier; - if (parent.kind === 229) { + if (parent.kind === 230) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 225) { + else if (parent.kind === 226) { moduleSpecifier = parent.name; } else { @@ -44329,7 +44444,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body && node.body.kind !== 226) { + while (node.body && node.body.kind !== 227) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -44363,7 +44478,7 @@ var ts; write(";"); writeLine(); enclosingDeclaration = prevEnclosingDeclaration; - function getTypeAliasDeclarationVisibilityError(symbolAccessibilityResult) { + function getTypeAliasDeclarationVisibilityError() { return { diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, errorNode: node.type, @@ -44399,7 +44514,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 147 && ts.hasModifier(node.parent, 8); + return node.parent.kind === 148 && ts.hasModifier(node.parent, 8); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -44409,49 +44524,49 @@ var ts; writeTextOfNode(currentText, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 156 || - node.parent.kind === 157 || - (node.parent.parent && node.parent.parent.kind === 159)) { - ts.Debug.assert(node.parent.kind === 147 || - node.parent.kind === 146 || - node.parent.kind === 156 || + if (node.parent.kind === 157 || + node.parent.kind === 158 || + (node.parent.parent && node.parent.parent.kind === 160)) { + ts.Debug.assert(node.parent.kind === 148 || + node.parent.kind === 147 || node.parent.kind === 157 || - node.parent.kind === 151 || - node.parent.kind === 152); + node.parent.kind === 158 || + node.parent.kind === 152 || + node.parent.kind === 153); emitType(node.constraint); } else { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.constraint, getTypeParameterConstraintVisibilityError); } } - function getTypeParameterConstraintVisibilityError(symbolAccessibilityResult) { + function getTypeParameterConstraintVisibilityError() { var diagnosticMessage; switch (node.parent.kind) { - case 221: + case 222: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 222: + case 223: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 152: + case 153: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 151: + case 152: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; + case 148: case 147: - case 146: if (ts.hasModifier(node.parent, 32)) { 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 === 221) { + else if (node.parent.parent.kind === 222) { 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 220: + case 221: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -44479,16 +44594,16 @@ var ts; if (ts.isEntityNameExpression(node.expression)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } - else if (!isImplementsList && node.expression.kind === 93) { + else if (!isImplementsList && node.expression.kind === 94) { write("null"); } else { writer.getSymbolAccessibilityDiagnostic = getHeritageClauseVisibilityError; resolver.writeBaseConstructorTypeOfClass(enclosingDeclaration, enclosingDeclaration, 2 | 1024, writer); } - function getHeritageClauseVisibilityError(symbolAccessibilityResult) { + function getHeritageClauseVisibilityError() { var diagnosticMessage; - if (node.parent.parent.kind === 221) { + if (node.parent.parent.kind === 222) { 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; @@ -44568,17 +44683,17 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 218 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 219 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } else { writeTextOfNode(currentText, node.name); - if ((node.kind === 145 || node.kind === 144 || - (node.kind === 142 && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { + if ((node.kind === 146 || node.kind === 145 || + (node.kind === 143 && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 145 || node.kind === 144) && node.parent.kind === 159) { + if ((node.kind === 146 || node.kind === 145) && node.parent.kind === 160) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (resolver.isLiteralConstDeclaration(node)) { @@ -44591,14 +44706,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 218) { + if (node.kind === 219) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 === 145 || node.kind === 144) { + else if (node.kind === 146 || node.kind === 145) { if (ts.hasModifier(node, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -44606,7 +44721,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 === 221) { + else if (node.parent.kind === 222) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -44632,7 +44747,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 193) { + if (element.kind !== 194) { elements.push(element); } } @@ -44698,7 +44813,7 @@ var ts; accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 149 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 150 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -44711,7 +44826,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 149 + return accessor.kind === 150 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -44720,7 +44835,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 150) { + if (accessorWithTypeAnnotation.kind === 151) { if (ts.hasModifier(accessorWithTypeAnnotation.parent, 32)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : @@ -44766,17 +44881,17 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 220) { + if (node.kind === 221) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 147 || node.kind === 148) { + else if (node.kind === 148 || node.kind === 149) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); } - if (node.kind === 220) { + if (node.kind === 221) { write("function "); writeTextOfNode(currentText, node.name); } - else if (node.kind === 148) { + else if (node.kind === 149) { write("constructor"); } else { @@ -44796,15 +44911,15 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; var closeParenthesizedFunctionType = false; - if (node.kind === 153) { + if (node.kind === 154) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); write("["); } else { - if (node.kind === 152 || node.kind === 157) { + if (node.kind === 153 || node.kind === 158) { write("new "); } - else if (node.kind === 156) { + else if (node.kind === 157) { var currentOutput = writer.getText(); if (node.typeParameters && currentOutput.charAt(currentOutput.length - 1) === "<") { closeParenthesizedFunctionType = true; @@ -44815,20 +44930,20 @@ var ts; write("("); } emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 153) { + if (node.kind === 154) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 156 || node.kind === 157; - if (isFunctionTypeOrConstructorType || node.parent.kind === 159) { + var isFunctionTypeOrConstructorType = node.kind === 157 || node.kind === 158; + if (isFunctionTypeOrConstructorType || node.parent.kind === 160) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 148 && !ts.hasModifier(node, 8)) { + else if (node.kind !== 149 && !ts.hasModifier(node, 8)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -44842,23 +44957,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 152: + case 153: diagnosticMessage = symbolAccessibilityResult.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 151: + case 152: diagnosticMessage = symbolAccessibilityResult.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 153: + case 154: diagnosticMessage = symbolAccessibilityResult.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 148: case 147: - case 146: if (ts.hasModifier(node, 32)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -44866,7 +44981,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 === 221) { + else if (node.parent.kind === 222) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 : @@ -44879,7 +44994,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 220: + case 221: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -44911,9 +45026,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 156 || - node.parent.kind === 157 || - node.parent.parent.kind === 159) { + if (node.parent.kind === 157 || + node.parent.kind === 158 || + node.parent.parent.kind === 160) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!ts.hasModifier(node.parent, 8)) { @@ -44929,22 +45044,22 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 148: + case 149: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 152: + case 153: return symbolAccessibilityResult.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 151: + case 152: return symbolAccessibilityResult.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 148: case 147: - case 146: if (ts.hasModifier(node.parent, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -44952,7 +45067,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 === 221) { + else if (node.parent.parent.kind === 222) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 : @@ -44964,7 +45079,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 220: + case 221: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -44975,12 +45090,12 @@ var ts; } } function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 167) { + if (bindingPattern.kind === 168) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 168) { + else if (bindingPattern.kind === 169) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -44991,10 +45106,10 @@ var ts; } } function emitBindingElement(bindingElement) { - if (bindingElement.kind === 193) { + if (bindingElement.kind === 194) { write(" "); } - else if (bindingElement.kind === 169) { + else if (bindingElement.kind === 170) { if (bindingElement.propertyName) { writeTextOfNode(currentText, bindingElement.propertyName); write(": "); @@ -45004,7 +45119,7 @@ var ts; emitBindingPattern(bindingElement.name); } else { - ts.Debug.assert(bindingElement.name.kind === 69); + ts.Debug.assert(bindingElement.name.kind === 70); if (bindingElement.dotDotDotToken) { write("..."); } @@ -45016,37 +45131,37 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 220: - case 225: - case 229: - case 222: case 221: - case 223: - case 224: - return emitModuleElement(node, isModuleElementVisible(node)); - case 200: - return emitModuleElement(node, isVariableStatementVisible(node)); + case 226: case 230: + case 223: + case 222: + case 224: + case 225: + return emitModuleElement(node, isModuleElementVisible(node)); + case 201: + return emitModuleElement(node, isVariableStatementVisible(node)); + case 231: return emitModuleElement(node, !node.importClause); - case 236: + case 237: return emitExportDeclaration(node); + case 149: case 148: case 147: - case 146: return writeFunctionDeclaration(node); - case 152: - case 151: case 153: + case 152: + case 154: return emitSignatureDeclarationWithJsDocComments(node); - case 149: case 150: + case 151: return emitAccessorDeclaration(node); + case 146: case 145: - case 144: return emitPropertyDeclaration(node); case 255: return emitEnumMemberDeclaration(node); - case 235: + case 236: return emitExportAssignment(node); case 256: return emitSourceFile(node); @@ -45066,7 +45181,7 @@ var ts; referencesOutput += "/// " + newLine; } return addedBundledEmitReference; - function getDeclFileName(emitFileNames, sourceFiles, isBundledEmit) { + function getDeclFileName(emitFileNames, _sourceFiles, isBundledEmit) { if (isBundledEmit && !addBundledFileReference) { return; } @@ -45131,7 +45246,7 @@ var ts; emitNodeWithSourceMap: emitNodeWithSourceMap, emitTokenWithSourceMap: emitTokenWithSourceMap, getText: getText, - getSourceMappingURL: getSourceMappingURL + getSourceMappingURL: getSourceMappingURL, }; function initialize(filePath, sourceMapFilePath, sourceFiles, isBundledEmit) { if (disabled) { @@ -45334,7 +45449,7 @@ var ts; sources: sourceMapData.sourceMapSources, names: sourceMapData.sourceMapNames, mappings: sourceMapData.sourceMapMappings, - sourcesContent: sourceMapData.sourceMapSourcesContent + sourcesContent: sourceMapData.sourceMapSourcesContent, }); } function getSourceMappingURL() { @@ -45398,7 +45513,7 @@ var ts; setSourceFile: setSourceFile, emitNodeWithComments: emitNodeWithComments, emitBodyWithDetachedComments: emitBodyWithDetachedComments, - emitTrailingCommentsOfPosition: emitTrailingCommentsOfPosition + emitTrailingCommentsOfPosition: emitTrailingCommentsOfPosition, }; function emitNodeWithComments(emitContext, node, emitCallback) { if (disabled) { @@ -45436,7 +45551,7 @@ var ts; } if (!skipTrailingComments) { containerEnd = end; - if (node.kind === 219) { + if (node.kind === 220) { declarationListContainerEnd = end; } } @@ -45512,7 +45627,7 @@ var ts; emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos); } } - function emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) { + function emitLeadingComment(commentPos, commentEnd, _kind, hasTrailingNewLine, rangePos) { if (!hasWrittenComment) { ts.emitNewLineBeforeLeadingCommentOfPosition(currentLineMap, writer, rangePos, commentPos); hasWrittenComment = true; @@ -45530,7 +45645,7 @@ var ts; function emitTrailingComments(pos) { forEachTrailingCommentToEmit(pos, emitTrailingComment); } - function emitTrailingComment(commentPos, commentEnd, kind, hasTrailingNewLine) { + function emitTrailingComment(commentPos, commentEnd, _kind, hasTrailingNewLine) { if (!writer.isAtStartOfLine()) { writer.write(" "); } @@ -45553,7 +45668,7 @@ var ts; ts.performance.measure("commentTime", "beforeEmitTrailingCommentsOfPosition"); } } - function emitTrailingCommentOfPosition(commentPos, commentEnd, kind, hasTrailingNewLine) { + function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) { emitPos(commentPos); ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); emitPos(commentEnd); @@ -45636,8 +45751,14 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + var TempFlags; + (function (TempFlags) { + TempFlags[TempFlags["Auto"] = 0] = "Auto"; + TempFlags[TempFlags["CountMask"] = 268435455] = "CountMask"; + TempFlags[TempFlags["_i"] = 268435456] = "_i"; + })(TempFlags || (TempFlags = {})); var id = function (s) { return s; }; - var nullTransformers = [function (ctx) { return id; }]; + var nullTransformers = [function (_) { return id; }]; function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles) { var delimiters = createDelimiterMap(); var brackets = createBracketsMap(); @@ -45815,191 +45936,205 @@ var ts; function pipelineEmitInIdentifierNameContext(node) { var kind = node.kind; switch (kind) { - case 69: + case 70: return emitIdentifier(node); } } function pipelineEmitInUnspecifiedContext(node) { var kind = node.kind; switch (kind) { - case 12: case 13: case 14: + case 15: return emitLiteral(node); - case 69: + case 70: return emitIdentifier(node); - case 74: - case 77: - case 82: - case 103: - case 110: + case 75: + case 78: + case 83: + case 104: case 111: case 112: case 113: - case 115: + case 114: + case 116: case 117: case 118: + case 119: case 120: + case 121: case 122: - case 130: + case 123: + case 124: + case 125: + case 126: + case 127: case 128: + case 129: + case 130: + case 131: case 132: case 133: + case 134: + case 135: + case 136: case 137: + case 138: + case 139: writeTokenText(kind); return; - case 139: - return emitQualifiedName(node); case 140: - return emitComputedPropertyName(node); + return emitQualifiedName(node); case 141: - return emitTypeParameter(node); + return emitComputedPropertyName(node); case 142: - return emitParameter(node); + return emitTypeParameter(node); case 143: - return emitDecorator(node); + return emitParameter(node); case 144: - return emitPropertySignature(node); + return emitDecorator(node); case 145: - return emitPropertyDeclaration(node); + return emitPropertySignature(node); case 146: - return emitMethodSignature(node); + return emitPropertyDeclaration(node); case 147: - return emitMethodDeclaration(node); + return emitMethodSignature(node); case 148: - return emitConstructor(node); + return emitMethodDeclaration(node); case 149: + return emitConstructor(node); case 150: - return emitAccessorDeclaration(node); case 151: - return emitCallSignature(node); + return emitAccessorDeclaration(node); case 152: - return emitConstructSignature(node); + return emitCallSignature(node); case 153: - return emitIndexSignature(node); + return emitConstructSignature(node); case 154: - return emitTypePredicate(node); + return emitIndexSignature(node); case 155: - return emitTypeReference(node); + return emitTypePredicate(node); case 156: - return emitFunctionType(node); + return emitTypeReference(node); case 157: - return emitConstructorType(node); + return emitFunctionType(node); case 158: - return emitTypeQuery(node); + return emitConstructorType(node); case 159: - return emitTypeLiteral(node); + return emitTypeQuery(node); case 160: - return emitArrayType(node); + return emitTypeLiteral(node); case 161: - return emitTupleType(node); + return emitArrayType(node); case 162: - return emitUnionType(node); + return emitTupleType(node); case 163: - return emitIntersectionType(node); + return emitUnionType(node); case 164: - return emitParenthesizedType(node); - case 194: - return emitExpressionWithTypeArguments(node); + return emitIntersectionType(node); case 165: - return emitThisType(node); + return emitParenthesizedType(node); + case 195: + return emitExpressionWithTypeArguments(node); case 166: - return emitLiteralType(node); + return emitThisType(); case 167: - return emitObjectBindingPattern(node); + return emitLiteralType(node); case 168: - return emitArrayBindingPattern(node); + return emitObjectBindingPattern(node); case 169: + return emitArrayBindingPattern(node); + case 170: return emitBindingElement(node); - case 197: - return emitTemplateSpan(node); case 198: - return emitSemicolonClassElement(node); + return emitTemplateSpan(node); case 199: - return emitBlock(node); + return emitSemicolonClassElement(); case 200: - return emitVariableStatement(node); + return emitBlock(node); case 201: - return emitEmptyStatement(node); + return emitVariableStatement(node); case 202: - return emitExpressionStatement(node); + return emitEmptyStatement(); case 203: - return emitIfStatement(node); + return emitExpressionStatement(node); case 204: - return emitDoStatement(node); + return emitIfStatement(node); case 205: - return emitWhileStatement(node); + return emitDoStatement(node); case 206: - return emitForStatement(node); + return emitWhileStatement(node); case 207: - return emitForInStatement(node); + return emitForStatement(node); case 208: - return emitForOfStatement(node); + return emitForInStatement(node); case 209: - return emitContinueStatement(node); + return emitForOfStatement(node); case 210: - return emitBreakStatement(node); + return emitContinueStatement(node); case 211: - return emitReturnStatement(node); + return emitBreakStatement(node); case 212: - return emitWithStatement(node); + return emitReturnStatement(node); case 213: - return emitSwitchStatement(node); + return emitWithStatement(node); case 214: - return emitLabeledStatement(node); + return emitSwitchStatement(node); case 215: - return emitThrowStatement(node); + return emitLabeledStatement(node); case 216: - return emitTryStatement(node); + return emitThrowStatement(node); case 217: - return emitDebuggerStatement(node); + return emitTryStatement(node); case 218: - return emitVariableDeclaration(node); + return emitDebuggerStatement(node); case 219: - return emitVariableDeclarationList(node); + return emitVariableDeclaration(node); case 220: - return emitFunctionDeclaration(node); + return emitVariableDeclarationList(node); case 221: - return emitClassDeclaration(node); + return emitFunctionDeclaration(node); case 222: - return emitInterfaceDeclaration(node); + return emitClassDeclaration(node); case 223: - return emitTypeAliasDeclaration(node); + return emitInterfaceDeclaration(node); case 224: - return emitEnumDeclaration(node); + return emitTypeAliasDeclaration(node); case 225: - return emitModuleDeclaration(node); + return emitEnumDeclaration(node); case 226: - return emitModuleBlock(node); + return emitModuleDeclaration(node); case 227: + return emitModuleBlock(node); + case 228: return emitCaseBlock(node); - case 229: - return emitImportEqualsDeclaration(node); case 230: - return emitImportDeclaration(node); + return emitImportEqualsDeclaration(node); case 231: - return emitImportClause(node); + return emitImportDeclaration(node); case 232: - return emitNamespaceImport(node); + return emitImportClause(node); case 233: - return emitNamedImports(node); + return emitNamespaceImport(node); case 234: - return emitImportSpecifier(node); + return emitNamedImports(node); case 235: - return emitExportAssignment(node); + return emitImportSpecifier(node); case 236: - return emitExportDeclaration(node); + return emitExportAssignment(node); case 237: - return emitNamedExports(node); + return emitExportDeclaration(node); case 238: - return emitExportSpecifier(node); + return emitNamedExports(node); case 239: - return; + return emitExportSpecifier(node); case 240: + return; + case 241: return emitExternalModuleReference(node); - case 244: + case 10: return emitJsxText(node); - case 243: + case 244: return emitJsxOpeningElement(node); case 245: return emitJsxClosingElement(node); @@ -46034,73 +46169,73 @@ var ts; case 8: return emitNumericLiteral(node); case 9: - case 10: case 11: + case 12: return emitLiteral(node); - case 69: + case 70: return emitIdentifier(node); - case 84: - case 93: - case 95: - case 99: - case 97: + case 85: + case 94: + case 96: + case 100: + case 98: writeTokenText(kind); return; - case 170: - return emitArrayLiteralExpression(node); case 171: - return emitObjectLiteralExpression(node); + return emitArrayLiteralExpression(node); case 172: - return emitPropertyAccessExpression(node); + return emitObjectLiteralExpression(node); case 173: - return emitElementAccessExpression(node); + return emitPropertyAccessExpression(node); case 174: - return emitCallExpression(node); + return emitElementAccessExpression(node); case 175: - return emitNewExpression(node); + return emitCallExpression(node); case 176: - return emitTaggedTemplateExpression(node); + return emitNewExpression(node); case 177: - return emitTypeAssertionExpression(node); + return emitTaggedTemplateExpression(node); case 178: - return emitParenthesizedExpression(node); + return emitTypeAssertionExpression(node); case 179: - return emitFunctionExpression(node); + return emitParenthesizedExpression(node); case 180: - return emitArrowFunction(node); + return emitFunctionExpression(node); case 181: - return emitDeleteExpression(node); + return emitArrowFunction(node); case 182: - return emitTypeOfExpression(node); + return emitDeleteExpression(node); case 183: - return emitVoidExpression(node); + return emitTypeOfExpression(node); case 184: - return emitAwaitExpression(node); + return emitVoidExpression(node); case 185: - return emitPrefixUnaryExpression(node); + return emitAwaitExpression(node); case 186: - return emitPostfixUnaryExpression(node); + return emitPrefixUnaryExpression(node); case 187: - return emitBinaryExpression(node); + return emitPostfixUnaryExpression(node); case 188: - return emitConditionalExpression(node); + return emitBinaryExpression(node); case 189: - return emitTemplateExpression(node); + return emitConditionalExpression(node); case 190: - return emitYieldExpression(node); + return emitTemplateExpression(node); case 191: - return emitSpreadElementExpression(node); + return emitYieldExpression(node); case 192: - return emitClassExpression(node); + return emitSpreadElementExpression(node); case 193: + return emitClassExpression(node); + case 194: return; - case 195: - return emitAsExpression(node); case 196: + return emitAsExpression(node); + case 197: return emitNonNullExpression(node); - case 241: - return emitJsxElement(node); case 242: + return emitJsxElement(node); + case 243: return emitJsxSelfClosingElement(node); case 288: return emitPartiallyEmittedExpression(node); @@ -46136,7 +46271,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 69) { + if (node.kind === 70) { emitExpression(node); } else { @@ -46206,7 +46341,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - write(node.kind === 149 ? "get " : "set "); + write(node.kind === 150 ? "get " : "set "); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); } @@ -46234,7 +46369,7 @@ var ts; emitWithPrefix(": ", node.type); write(";"); } - function emitSemicolonClassElement(node) { + function emitSemicolonClassElement() { write(";"); } function emitTypePredicate(node) { @@ -46288,7 +46423,7 @@ var ts; emit(node.type); write(")"); } - function emitThisType(node) { + function emitThisType() { write("this"); } function emitLiteralType(node) { @@ -46356,7 +46491,7 @@ var ts; if (!(ts.getEmitFlags(node) & 1048576)) { var dotRangeStart = node.expression.end; var dotRangeEnd = ts.skipTrivia(currentText, node.expression.end) + 1; - var dotToken = { kind: 21, pos: dotRangeStart, end: dotRangeEnd }; + var dotToken = { kind: 22, pos: dotRangeStart, end: dotRangeEnd }; indentBeforeDot = needsIndentation(node, node.expression, dotToken); indentAfterDot = needsIndentation(node, dotToken, node.name); } @@ -46371,7 +46506,7 @@ var ts; function needsDotDotForPropertyAccess(expression) { if (expression.kind === 8) { var text = getLiteralTextOfNode(expression); - return text.indexOf(ts.tokenToString(21)) < 0; + return text.indexOf(ts.tokenToString(22)) < 0; } else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { var constantValue = ts.getConstantValue(expression); @@ -46388,11 +46523,13 @@ var ts; } function emitCallExpression(node) { emitExpression(node.expression); + emitTypeArguments(node, node.typeArguments); emitExpressionList(node, node.arguments, 1296); } function emitNewExpression(node) { write("new "); emitExpression(node.expression); + emitTypeArguments(node, node.typeArguments); emitExpressionList(node, node.arguments, 9488); } function emitTaggedTemplateExpression(node) { @@ -46452,16 +46589,16 @@ var ts; } function shouldEmitWhitespaceBeforeOperand(node) { var operand = node.operand; - return operand.kind === 185 - && ((node.operator === 35 && (operand.operator === 35 || operand.operator === 41)) - || (node.operator === 36 && (operand.operator === 36 || operand.operator === 42))); + return operand.kind === 186 + && ((node.operator === 36 && (operand.operator === 36 || operand.operator === 42)) + || (node.operator === 37 && (operand.operator === 37 || operand.operator === 43))); } function emitPostfixUnaryExpression(node) { emitExpression(node.operand); writeTokenText(node.operator); } function emitBinaryExpression(node) { - var isCommaOperator = node.operatorToken.kind !== 24; + var isCommaOperator = node.operatorToken.kind !== 25; var indentBeforeOperator = needsIndentation(node, node.left, node.operatorToken); var indentAfterOperator = needsIndentation(node, node.operatorToken, node.right); emitExpression(node.left); @@ -46522,16 +46659,16 @@ var ts; emitExpression(node.expression); emit(node.literal); } - function emitBlock(node, format) { + function emitBlock(node) { if (isSingleLineEmptyBlock(node)) { - writeToken(15, node.pos, node); + writeToken(16, node.pos, node); write(" "); - writeToken(16, node.statements.end, node); + writeToken(17, node.statements.end, node); } else { - writeToken(15, node.pos, node); + writeToken(16, node.pos, node); emitBlockStatements(node); - writeToken(16, node.statements.end, node); + writeToken(17, node.statements.end, node); } } function emitBlockStatements(node) { @@ -46547,7 +46684,7 @@ var ts; emit(node.declarationList); write(";"); } - function emitEmptyStatement(node) { + function emitEmptyStatement() { write(";"); } function emitExpressionStatement(node) { @@ -46555,16 +46692,16 @@ var ts; write(";"); } function emitIfStatement(node) { - var openParenPos = writeToken(88, node.pos, node); + var openParenPos = writeToken(89, node.pos, node); write(" "); - writeToken(17, openParenPos, node); + writeToken(18, openParenPos, node); emitExpression(node.expression); - writeToken(18, node.expression.end, node); + writeToken(19, node.expression.end, node); emitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { writeLine(); - writeToken(80, node.thenStatement.end, node); - if (node.elseStatement.kind === 203) { + writeToken(81, node.thenStatement.end, node); + if (node.elseStatement.kind === 204) { write(" "); emit(node.elseStatement); } @@ -46593,9 +46730,9 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForStatement(node) { - var openParenPos = writeToken(86, node.pos); + var openParenPos = writeToken(87, node.pos); write(" "); - writeToken(17, openParenPos, node); + writeToken(18, openParenPos, node); emitForBinding(node.initializer); write(";"); emitExpressionWithPrefix(" ", node.condition); @@ -46605,28 +46742,28 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInStatement(node) { - var openParenPos = writeToken(86, node.pos); + var openParenPos = writeToken(87, node.pos); write(" "); - writeToken(17, openParenPos); + writeToken(18, openParenPos); emitForBinding(node.initializer); write(" in "); emitExpression(node.expression); - writeToken(18, node.expression.end); + writeToken(19, node.expression.end); emitEmbeddedStatement(node.statement); } function emitForOfStatement(node) { - var openParenPos = writeToken(86, node.pos); + var openParenPos = writeToken(87, node.pos); write(" "); - writeToken(17, openParenPos); + writeToken(18, openParenPos); emitForBinding(node.initializer); write(" of "); emitExpression(node.expression); - writeToken(18, node.expression.end); + writeToken(19, node.expression.end); emitEmbeddedStatement(node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 219) { + if (node.kind === 220) { emit(node); } else { @@ -46635,17 +46772,17 @@ var ts; } } function emitContinueStatement(node) { - writeToken(75, node.pos); + writeToken(76, node.pos); emitWithPrefix(" ", node.label); write(";"); } function emitBreakStatement(node) { - writeToken(70, node.pos); + writeToken(71, node.pos); emitWithPrefix(" ", node.label); write(";"); } function emitReturnStatement(node) { - writeToken(94, node.pos, node); + writeToken(95, node.pos, node); emitExpressionWithPrefix(" ", node.expression); write(";"); } @@ -46656,11 +46793,11 @@ var ts; emitEmbeddedStatement(node.statement); } function emitSwitchStatement(node) { - var openParenPos = writeToken(96, node.pos); + var openParenPos = writeToken(97, node.pos); write(" "); - writeToken(17, openParenPos); + writeToken(18, openParenPos); emitExpression(node.expression); - writeToken(18, node.expression.end); + writeToken(19, node.expression.end); write(" "); emit(node.caseBlock); } @@ -46685,11 +46822,12 @@ var ts; } } function emitDebuggerStatement(node) { - writeToken(76, node.pos); + writeToken(77, node.pos); write(";"); } function emitVariableDeclaration(node) { emit(node.name); + emitWithPrefix(": ", node.type); emitExpressionWithPrefix(" = ", node.initializer); } function emitVariableDeclarationList(node) { @@ -46716,13 +46854,13 @@ var ts; } if (ts.getEmitFlags(node) & 4194304) { emitSignatureHead(node); - emitBlockFunctionBody(node, body); + emitBlockFunctionBody(body); } else { var savedTempFlags = tempFlags; tempFlags = 0; emitSignatureHead(node); - emitBlockFunctionBody(node, body); + emitBlockFunctionBody(body); tempFlags = savedTempFlags; } if (indentedFlag) { @@ -46745,7 +46883,7 @@ var ts; emitParameters(node, node.parameters); emitWithPrefix(": ", node.type); } - function shouldEmitBlockFunctionBodyOnSingleLine(parentNode, body) { + function shouldEmitBlockFunctionBodyOnSingleLine(body) { if (ts.getEmitFlags(body) & 32) { return true; } @@ -46769,14 +46907,14 @@ var ts; } return true; } - function emitBlockFunctionBody(parentNode, body) { + function emitBlockFunctionBody(body) { write(" {"); increaseIndent(); - emitBodyWithDetachedComments(body, body.statements, shouldEmitBlockFunctionBodyOnSingleLine(parentNode, body) + emitBodyWithDetachedComments(body, body.statements, shouldEmitBlockFunctionBodyOnSingleLine(body) ? emitBlockFunctionBodyOnSingleLine : emitBlockFunctionBodyWorker); decreaseIndent(); - writeToken(16, body.statements.end, body); + writeToken(17, body.statements.end, body); } function emitBlockFunctionBodyOnSingleLine(body) { emitBlockFunctionBodyWorker(body, true); @@ -46854,7 +46992,7 @@ var ts; write(node.flags & 16 ? "namespace " : "module "); emit(node.name); var body = node.body; - while (body.kind === 225) { + while (body.kind === 226) { write("."); emit(body.name); body = body.body; @@ -46877,9 +47015,9 @@ var ts; } } function emitCaseBlock(node) { - writeToken(15, node.pos); + writeToken(16, node.pos); emitList(node, node.clauses, 65); - writeToken(16, node.clauses.end); + writeToken(17, node.clauses.end); } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); @@ -46890,7 +47028,7 @@ var ts; write(";"); } function emitModuleReference(node) { - if (node.kind === 69) { + if (node.kind === 70) { emitExpression(node); } else { @@ -47010,7 +47148,7 @@ var ts; } } function emitJsxTagName(node) { - if (node.kind === 69) { + if (node.kind === 70) { emitExpression(node); } else { @@ -47048,11 +47186,11 @@ var ts; } function emitCatchClause(node) { writeLine(); - var openParenPos = writeToken(72, node.pos); + var openParenPos = writeToken(73, node.pos); write(" "); - writeToken(17, openParenPos); + writeToken(18, openParenPos); emit(node.variableDeclaration); - writeToken(18, node.variableDeclaration ? node.variableDeclaration.end : openParenPos); + writeToken(19, node.variableDeclaration ? node.variableDeclaration.end : openParenPos); write(" "); emit(node.block); } @@ -47159,7 +47297,7 @@ var ts; paramEmitted = true; helpersEmitted = true; } - if (!awaiterEmitted && node.flags & 8192) { + if ((languageVersion < 4) && (!awaiterEmitted && node.flags & 8192)) { writeLines(awaiterHelper); if (languageVersion < 2) { writeLines(generatorHelper); @@ -47468,7 +47606,7 @@ var ts; && !ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 178 && ts.nodeIsSynthesized(node)) { + while (node.kind === 179 && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -47525,21 +47663,21 @@ var ts; } function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name_44 = flags === 268435456 ? "_i" : "_n"; - if (isUniqueName(name_44)) { + var name_41 = flags === 268435456 ? "_i" : "_n"; + if (isUniqueName(name_41)) { tempFlags |= flags; - return name_44; + return name_41; } } while (true) { var count = tempFlags & 268435455; tempFlags++; if (count !== 8 && count !== 13) { - var name_45 = count < 26 + var name_42 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); - if (isUniqueName(name_45)) { - return name_45; + if (isUniqueName(name_42)) { + return name_42; } } } @@ -47575,19 +47713,19 @@ var ts; } function generateNameForNode(node) { switch (node.kind) { - case 69: + case 70: return makeUniqueName(getTextOfNode(node)); + case 226: case 225: - case 224: return generateNameForModuleOrEnum(node); - case 230: - case 236: + case 231: + case 237: return generateNameForImportOrExportDeclaration(node); - case 220: case 221: - case 235: + case 222: + case 236: return generateNameForExportDefault(); - case 192: + case 193: return generateNameForClassExpression(); default: return makeTempVariableName(0); @@ -47657,6 +47795,68 @@ var ts; } } ts.emitFiles = emitFiles; + var ListFormat; + (function (ListFormat) { + ListFormat[ListFormat["None"] = 0] = "None"; + ListFormat[ListFormat["SingleLine"] = 0] = "SingleLine"; + ListFormat[ListFormat["MultiLine"] = 1] = "MultiLine"; + ListFormat[ListFormat["PreserveLines"] = 2] = "PreserveLines"; + ListFormat[ListFormat["LinesMask"] = 3] = "LinesMask"; + ListFormat[ListFormat["NotDelimited"] = 0] = "NotDelimited"; + ListFormat[ListFormat["BarDelimited"] = 4] = "BarDelimited"; + ListFormat[ListFormat["AmpersandDelimited"] = 8] = "AmpersandDelimited"; + ListFormat[ListFormat["CommaDelimited"] = 16] = "CommaDelimited"; + ListFormat[ListFormat["DelimitersMask"] = 28] = "DelimitersMask"; + ListFormat[ListFormat["AllowTrailingComma"] = 32] = "AllowTrailingComma"; + ListFormat[ListFormat["Indented"] = 64] = "Indented"; + ListFormat[ListFormat["SpaceBetweenBraces"] = 128] = "SpaceBetweenBraces"; + ListFormat[ListFormat["SpaceBetweenSiblings"] = 256] = "SpaceBetweenSiblings"; + ListFormat[ListFormat["Braces"] = 512] = "Braces"; + ListFormat[ListFormat["Parenthesis"] = 1024] = "Parenthesis"; + ListFormat[ListFormat["AngleBrackets"] = 2048] = "AngleBrackets"; + ListFormat[ListFormat["SquareBrackets"] = 4096] = "SquareBrackets"; + ListFormat[ListFormat["BracketsMask"] = 7680] = "BracketsMask"; + ListFormat[ListFormat["OptionalIfUndefined"] = 8192] = "OptionalIfUndefined"; + ListFormat[ListFormat["OptionalIfEmpty"] = 16384] = "OptionalIfEmpty"; + ListFormat[ListFormat["Optional"] = 24576] = "Optional"; + ListFormat[ListFormat["PreferNewLine"] = 32768] = "PreferNewLine"; + ListFormat[ListFormat["NoTrailingNewLine"] = 65536] = "NoTrailingNewLine"; + ListFormat[ListFormat["NoInterveningComments"] = 131072] = "NoInterveningComments"; + ListFormat[ListFormat["Modifiers"] = 256] = "Modifiers"; + ListFormat[ListFormat["HeritageClauses"] = 256] = "HeritageClauses"; + ListFormat[ListFormat["TypeLiteralMembers"] = 65] = "TypeLiteralMembers"; + ListFormat[ListFormat["TupleTypeElements"] = 336] = "TupleTypeElements"; + ListFormat[ListFormat["UnionTypeConstituents"] = 260] = "UnionTypeConstituents"; + ListFormat[ListFormat["IntersectionTypeConstituents"] = 264] = "IntersectionTypeConstituents"; + ListFormat[ListFormat["ObjectBindingPatternElements"] = 432] = "ObjectBindingPatternElements"; + ListFormat[ListFormat["ArrayBindingPatternElements"] = 304] = "ArrayBindingPatternElements"; + ListFormat[ListFormat["ObjectLiteralExpressionProperties"] = 978] = "ObjectLiteralExpressionProperties"; + ListFormat[ListFormat["ArrayLiteralExpressionElements"] = 4466] = "ArrayLiteralExpressionElements"; + ListFormat[ListFormat["CallExpressionArguments"] = 1296] = "CallExpressionArguments"; + ListFormat[ListFormat["NewExpressionArguments"] = 9488] = "NewExpressionArguments"; + ListFormat[ListFormat["TemplateExpressionSpans"] = 131072] = "TemplateExpressionSpans"; + ListFormat[ListFormat["SingleLineBlockStatements"] = 384] = "SingleLineBlockStatements"; + ListFormat[ListFormat["MultiLineBlockStatements"] = 65] = "MultiLineBlockStatements"; + ListFormat[ListFormat["VariableDeclarationList"] = 272] = "VariableDeclarationList"; + ListFormat[ListFormat["SingleLineFunctionBodyStatements"] = 384] = "SingleLineFunctionBodyStatements"; + ListFormat[ListFormat["MultiLineFunctionBodyStatements"] = 1] = "MultiLineFunctionBodyStatements"; + ListFormat[ListFormat["ClassHeritageClauses"] = 256] = "ClassHeritageClauses"; + ListFormat[ListFormat["ClassMembers"] = 65] = "ClassMembers"; + ListFormat[ListFormat["InterfaceMembers"] = 65] = "InterfaceMembers"; + ListFormat[ListFormat["EnumMembers"] = 81] = "EnumMembers"; + ListFormat[ListFormat["CaseBlockClauses"] = 65] = "CaseBlockClauses"; + ListFormat[ListFormat["NamedImportsOrExportsElements"] = 432] = "NamedImportsOrExportsElements"; + ListFormat[ListFormat["JsxElementChildren"] = 131072] = "JsxElementChildren"; + ListFormat[ListFormat["JsxElementAttributes"] = 131328] = "JsxElementAttributes"; + ListFormat[ListFormat["CaseOrDefaultClauseStatements"] = 81985] = "CaseOrDefaultClauseStatements"; + ListFormat[ListFormat["HeritageClauseTypes"] = 272] = "HeritageClauseTypes"; + ListFormat[ListFormat["SourceFileStatements"] = 65537] = "SourceFileStatements"; + ListFormat[ListFormat["Decorators"] = 24577] = "Decorators"; + ListFormat[ListFormat["TypeArguments"] = 26960] = "TypeArguments"; + ListFormat[ListFormat["TypeParameters"] = 26960] = "TypeParameters"; + ListFormat[ListFormat["Parameters"] = 1360] = "Parameters"; + ListFormat[ListFormat["IndexSignatureParameters"] = 4432] = "IndexSignatureParameters"; + })(ListFormat || (ListFormat = {})); })(ts || (ts = {})); var ts; (function (ts) { @@ -47876,10 +48076,10 @@ var ts; var resolutions = []; var cache = ts.createMap(); for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { - var name_46 = names_2[_i]; - var result = name_46 in cache - ? cache[name_46] - : cache[name_46] = loader(name_46, containingFile); + var name_43 = names_2[_i]; + var result = name_43 in cache + ? cache[name_43] + : cache[name_43] = loader(name_43, containingFile); resolutions.push(result); } return resolutions; @@ -48110,7 +48310,7 @@ var ts; getSourceFiles: program.getSourceFiles, isSourceFileFromExternalLibrary: function (file) { return !!sourceFilesFoundSearchingNodeModules[file.path]; }, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), - isEmitBlocked: isEmitBlocked + isEmitBlocked: isEmitBlocked, }; } function getDiagnosticsProducingTypeChecker() { @@ -48188,7 +48388,7 @@ var ts; return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile, cancellationToken); } } - function getSyntacticDiagnosticsForFile(sourceFile, cancellationToken) { + function getSyntacticDiagnosticsForFile(sourceFile) { return sourceFile.parseDiagnostics; } function runWithCancellationToken(func) { @@ -48209,14 +48409,14 @@ var ts; ts.Debug.assert(!!sourceFile.bindDiagnostics); var bindDiagnostics = sourceFile.bindDiagnostics; var checkDiagnostics = ts.isSourceFileJavaScript(sourceFile) ? - getJavaScriptSemanticDiagnosticsForFile(sourceFile, cancellationToken) : + getJavaScriptSemanticDiagnosticsForFile(sourceFile) : typeChecker.getDiagnostics(sourceFile, cancellationToken); var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); - return bindDiagnostics.concat(checkDiagnostics).concat(fileProcessingDiagnosticsInFile).concat(programDiagnosticsInFile); + return bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); }); } - function getJavaScriptSemanticDiagnosticsForFile(sourceFile, cancellationToken) { + function getJavaScriptSemanticDiagnosticsForFile(sourceFile) { return runWithCancellationToken(function () { var diagnostics = []; walk(sourceFile); @@ -48226,16 +48426,16 @@ var ts; return false; } switch (node.kind) { - case 229: + case 230: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return true; - case 235: + case 236: if (node.isExportEquals) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return true; } break; - case 221: + case 222: var classDeclaration = node; if (checkModifiers(classDeclaration.modifiers) || checkTypeParameters(classDeclaration.typeParameters)) { @@ -48244,29 +48444,29 @@ var ts; break; case 251: var heritageClause = node; - if (heritageClause.token === 106) { + if (heritageClause.token === 107) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return true; } break; - case 222: + case 223: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return true; - case 225: + case 226: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return true; - case 223: + case 224: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return true; - case 147: - case 146: case 148: + case 147: case 149: case 150: - case 179: - case 220: + case 151: case 180: - case 220: + case 221: + case 181: + case 221: var functionDeclaration = node; if (checkModifiers(functionDeclaration.modifiers) || checkTypeParameters(functionDeclaration.typeParameters) || @@ -48274,20 +48474,20 @@ var ts; return true; } break; - case 200: + case 201: var variableStatement = node; if (checkModifiers(variableStatement.modifiers)) { return true; } break; - case 218: + case 219: var variableDeclaration = node; if (checkTypeAnnotation(variableDeclaration.type)) { return true; } break; - case 174: case 175: + case 176: var expression = node; if (expression.typeArguments && expression.typeArguments.length > 0) { var start = expression.typeArguments.pos; @@ -48295,7 +48495,7 @@ var ts; return true; } break; - case 142: + case 143: var parameter = node; if (parameter.modifiers) { var start = parameter.modifiers.pos; @@ -48311,12 +48511,12 @@ var ts; return true; } break; - case 145: + case 146: var propertyDeclaration = node; if (propertyDeclaration.modifiers) { for (var _i = 0, _a = propertyDeclaration.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 113) { + if (modifier.kind !== 114) { diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); return true; } @@ -48326,14 +48526,14 @@ var ts; return true; } break; - case 224: + case 225: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return true; - case 177: + case 178: 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 143: + case 144: if (!options.experimentalDecorators) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning)); } @@ -48361,18 +48561,18 @@ var ts; for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { var modifier = modifiers_1[_i]; switch (modifier.kind) { - case 112: - case 110: + case 113: case 111: - case 128: - case 122: + case 112: + case 129: + case 123: diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); return true; - case 113: - case 82: - case 74: - case 77: - case 115: + case 114: + case 83: + case 75: + case 78: + case 116: } } } @@ -48405,7 +48605,7 @@ var ts; return ts.getBaseFileName(fileName).indexOf(".") >= 0; } function processRootFile(fileName, isDefaultLib) { - processSourceFile(ts.normalizePath(fileName), isDefaultLib, true); + processSourceFile(ts.normalizePath(fileName), isDefaultLib); } function fileReferenceIsEqualTo(a, b) { return a.fileName === b.fileName; @@ -48444,9 +48644,9 @@ var ts; return; function collectModuleReferences(node, inAmbientModule) { switch (node.kind) { + case 231: case 230: - case 229: - case 236: + case 237: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9) { break; @@ -48458,7 +48658,7 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 225: + case 226: if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasModifier(node, 2) || ts.isDeclarationFile(file))) { var moduleName = node.name; if (isExternalModuleFile || (inAmbientModule && !ts.isExternalModuleNameRelative(moduleName.text))) { @@ -48485,7 +48685,7 @@ var ts; } } } - function processSourceFile(fileName, isDefaultLib, isReference, refFile, refPos, refEnd) { + function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { var diagnosticArgument; var diagnostic; if (hasExtension(fileName)) { @@ -48493,7 +48693,7 @@ var ts; diagnostic = ts.Diagnostics.File_0_has_unsupported_extension_The_only_supported_extensions_are_1; diagnosticArgument = [fileName, "'" + supportedExtensions.join("', '") + "'"]; } - else if (!findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, isReference, refFile, refPos, refEnd)) { + else if (!findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd)) { diagnostic = ts.Diagnostics.File_0_not_found; diagnosticArgument = [fileName]; } @@ -48503,13 +48703,13 @@ var ts; } } else { - var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, isReference, refFile, refPos, refEnd); + var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd); if (!nonTsFile) { if (options.allowNonTsExtensions) { diagnostic = ts.Diagnostics.File_0_not_found; diagnosticArgument = [fileName]; } - else if (!ts.forEach(supportedExtensions, function (extension) { return findSourceFile(fileName + extension, ts.toPath(fileName + extension, currentDirectory, getCanonicalFileName), isDefaultLib, isReference, refFile, refPos, refEnd); })) { + else if (!ts.forEach(supportedExtensions, function (extension) { return findSourceFile(fileName + extension, ts.toPath(fileName + extension, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd); })) { diagnostic = ts.Diagnostics.File_0_not_found; fileName += ".ts"; diagnosticArgument = [fileName]; @@ -48533,7 +48733,7 @@ var ts; fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); } } - function findSourceFile(fileName, path, isDefaultLib, isReference, refFile, refPos, refEnd) { + function findSourceFile(fileName, path, isDefaultLib, refFile, refPos, refEnd) { if (filesByName.contains(path)) { var file_1 = filesByName.get(path); if (file_1 && options.forceConsistentCasingInFileNames && ts.getNormalizedAbsolutePath(file_1.fileName, currentDirectory) !== ts.getNormalizedAbsolutePath(fileName, currentDirectory)) { @@ -48542,16 +48742,16 @@ var ts; if (file_1 && sourceFilesFoundSearchingNodeModules[file_1.path] && currentNodeModulesDepth == 0) { sourceFilesFoundSearchingNodeModules[file_1.path] = false; if (!options.noResolve) { - processReferencedFiles(file_1, ts.getDirectoryPath(fileName), isDefaultLib); + processReferencedFiles(file_1, isDefaultLib); processTypeReferenceDirectives(file_1); } modulesWithElidedImports[file_1.path] = false; - processImportedModules(file_1, ts.getDirectoryPath(fileName)); + processImportedModules(file_1); } else if (file_1 && modulesWithElidedImports[file_1.path]) { if (currentNodeModulesDepth < maxNodeModulesJsDepth) { modulesWithElidedImports[file_1.path] = false; - processImportedModules(file_1, ts.getDirectoryPath(fileName)); + processImportedModules(file_1); } } return file_1; @@ -48578,12 +48778,11 @@ var ts; } } skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; - var basePath = ts.getDirectoryPath(fileName); if (!options.noResolve) { - processReferencedFiles(file, basePath, isDefaultLib); + processReferencedFiles(file, isDefaultLib); processTypeReferenceDirectives(file); } - processImportedModules(file, basePath); + processImportedModules(file); if (isDefaultLib) { files.unshift(file); } @@ -48593,10 +48792,10 @@ var ts; } return file; } - function processReferencedFiles(file, basePath, isDefaultLib) { + function processReferencedFiles(file, isDefaultLib) { ts.forEach(file.referencedFiles, function (ref) { var referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName); - processSourceFile(referencedFileName, isDefaultLib, true, file, ref.pos, ref.end); + processSourceFile(referencedFileName, isDefaultLib, file, ref.pos, ref.end); }); } function processTypeReferenceDirectives(file) { @@ -48618,7 +48817,7 @@ var ts; var saveResolution = true; if (resolvedTypeReferenceDirective) { if (resolvedTypeReferenceDirective.primary) { - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, true, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, refFile, refPos, refEnd); } else { if (previousResolution) { @@ -48629,7 +48828,7 @@ var ts; saveResolution = false; } else { - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, true, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, refFile, refPos, refEnd); } } } @@ -48655,7 +48854,7 @@ var ts; function getCanonicalFileName(fileName) { return host.getCanonicalFileName(fileName); } - function processImportedModules(file, basePath) { + function processImportedModules(file) { collectExternalModuleReferences(file); if (file.imports.length || file.moduleAugmentations.length) { file.resolvedModules = ts.createMap(); @@ -48675,7 +48874,7 @@ var ts; modulesWithElidedImports[file.path] = true; } else if (shouldAddFile) { - findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), false, false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); + findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); } if (isFromNodeModulesSearch) { currentNodeModulesDepth--; @@ -48845,7 +49044,7 @@ var ts; if (!options.noEmit && !options.suppressOutputPathCheck) { var emitHost = getEmitHost(); var emitFilesSeen_1 = ts.createFileMap(!host.useCaseSensitiveFileNames() ? function (key) { return key.toLocaleLowerCase(); } : undefined); - ts.forEachExpectedEmitFile(emitHost, function (emitFileNames, sourceFiles, isBundledEmit) { + ts.forEachExpectedEmitFile(emitHost, function (emitFileNames) { verifyEmitFilePath(emitFileNames.jsFilePath, emitFilesSeen_1); verifyEmitFilePath(emitFileNames.declarationFilePath, emitFilesSeen_1); }); @@ -48854,10 +49053,10 @@ var ts; if (emitFileName) { var emitFilePath = ts.toPath(emitFileName, currentDirectory, getCanonicalFileName); if (filesByName.contains(emitFilePath)) { - createEmitBlockingDiagnostics(emitFileName, emitFilePath, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file); + createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file); } if (emitFilesSeen.contains(emitFilePath)) { - createEmitBlockingDiagnostics(emitFileName, emitFilePath, ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files); + createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files); } else { emitFilesSeen.set(emitFilePath, true); @@ -48865,7 +49064,7 @@ var ts; } } } - function createEmitBlockingDiagnostics(emitFileName, emitFilePath, message) { + function createEmitBlockingDiagnostics(emitFileName, message) { hasEmitBlockingDiagnostics.set(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName), true); programDiagnostics.add(ts.createCompilerDiagnostic(message, emitFileName)); } @@ -48873,6 +49072,1090 @@ var ts; ts.createProgram = createProgram; })(ts || (ts = {})); var ts; +(function (ts) { + ts.compileOnSaveCommandLineOption = { name: "compileOnSave", type: "boolean" }; + ts.optionDeclarations = [ + { + name: "charset", + type: "string", + }, + ts.compileOnSaveCommandLineOption, + { + name: "declaration", + shortName: "d", + type: "boolean", + description: ts.Diagnostics.Generates_corresponding_d_ts_file, + }, + { + name: "declarationDir", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.DIRECTORY, + }, + { + name: "diagnostics", + type: "boolean", + }, + { + name: "extendedDiagnostics", + type: "boolean", + experimental: true + }, + { + name: "emitBOM", + type: "boolean" + }, + { + name: "help", + shortName: "h", + type: "boolean", + description: ts.Diagnostics.Print_this_message, + }, + { + name: "help", + shortName: "?", + type: "boolean" + }, + { + name: "init", + type: "boolean", + description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file, + }, + { + name: "inlineSourceMap", + type: "boolean", + }, + { + name: "inlineSources", + type: "boolean", + }, + { + name: "jsx", + type: ts.createMap({ + "preserve": 1, + "react": 2 + }), + paramType: ts.Diagnostics.KIND, + description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, + }, + { + name: "reactNamespace", + type: "string", + description: ts.Diagnostics.Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit + }, + { + name: "listFiles", + type: "boolean", + }, + { + name: "locale", + type: "string", + }, + { + name: "mapRoot", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, + paramType: ts.Diagnostics.LOCATION, + }, + { + name: "module", + shortName: "m", + type: ts.createMap({ + "none": ts.ModuleKind.None, + "commonjs": ts.ModuleKind.CommonJS, + "amd": ts.ModuleKind.AMD, + "system": ts.ModuleKind.System, + "umd": ts.ModuleKind.UMD, + "es6": ts.ModuleKind.ES2015, + "es2015": ts.ModuleKind.ES2015, + }), + description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, + paramType: ts.Diagnostics.KIND, + }, + { + name: "newLine", + type: ts.createMap({ + "crlf": 0, + "lf": 1 + }), + description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, + paramType: ts.Diagnostics.NEWLINE, + }, + { + name: "noEmit", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_outputs, + }, + { + name: "noEmitHelpers", + type: "boolean" + }, + { + name: "noEmitOnError", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, + }, + { + name: "noErrorTruncation", + type: "boolean" + }, + { + name: "noImplicitAny", + type: "boolean", + description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type, + }, + { + name: "noImplicitThis", + type: "boolean", + description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, + }, + { + name: "noUnusedLocals", + type: "boolean", + description: ts.Diagnostics.Report_errors_on_unused_locals, + }, + { + name: "noUnusedParameters", + type: "boolean", + description: ts.Diagnostics.Report_errors_on_unused_parameters, + }, + { + name: "noLib", + type: "boolean", + }, + { + name: "noResolve", + type: "boolean", + }, + { + name: "skipDefaultLibCheck", + type: "boolean", + }, + { + name: "skipLibCheck", + type: "boolean", + description: ts.Diagnostics.Skip_type_checking_of_declaration_files, + }, + { + name: "out", + type: "string", + isFilePath: false, + paramType: ts.Diagnostics.FILE, + }, + { + name: "outFile", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, + paramType: ts.Diagnostics.FILE, + }, + { + name: "outDir", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Redirect_output_structure_to_the_directory, + paramType: ts.Diagnostics.DIRECTORY, + }, + { + name: "preserveConstEnums", + type: "boolean", + description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code + }, + { + name: "pretty", + description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental, + type: "boolean" + }, + { + name: "project", + shortName: "p", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Compile_the_project_in_the_given_directory, + paramType: ts.Diagnostics.DIRECTORY + }, + { + name: "removeComments", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_comments_to_output, + }, + { + name: "rootDir", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.LOCATION, + description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, + }, + { + name: "isolatedModules", + type: "boolean", + }, + { + name: "sourceMap", + type: "boolean", + description: ts.Diagnostics.Generates_corresponding_map_file, + }, + { + name: "sourceRoot", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, + paramType: ts.Diagnostics.LOCATION, + }, + { + name: "suppressExcessPropertyErrors", + type: "boolean", + description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals, + experimental: true + }, + { + name: "suppressImplicitAnyIndexErrors", + type: "boolean", + description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, + }, + { + name: "stripInternal", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation, + experimental: true + }, + { + name: "target", + shortName: "t", + type: ts.createMap({ + "es3": 0, + "es5": 1, + "es6": 2, + "es2015": 2, + "es2016": 3, + "es2017": 4, + }), + description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015, + paramType: ts.Diagnostics.VERSION, + }, + { + name: "version", + shortName: "v", + type: "boolean", + description: ts.Diagnostics.Print_the_compiler_s_version, + }, + { + name: "watch", + shortName: "w", + type: "boolean", + description: ts.Diagnostics.Watch_input_files, + }, + { + name: "experimentalDecorators", + type: "boolean", + description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators + }, + { + name: "emitDecoratorMetadata", + type: "boolean", + experimental: true, + description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators + }, + { + name: "moduleResolution", + type: ts.createMap({ + "node": ts.ModuleResolutionKind.NodeJs, + "classic": ts.ModuleResolutionKind.Classic, + }), + description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, + paramType: ts.Diagnostics.STRATEGY, + }, + { + name: "allowUnusedLabels", + type: "boolean", + description: ts.Diagnostics.Do_not_report_errors_on_unused_labels + }, + { + name: "noImplicitReturns", + type: "boolean", + description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value + }, + { + name: "noFallthroughCasesInSwitch", + type: "boolean", + description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement + }, + { + name: "allowUnreachableCode", + type: "boolean", + description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code + }, + { + name: "forceConsistentCasingInFileNames", + type: "boolean", + description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file + }, + { + name: "baseUrl", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Base_directory_to_resolve_non_absolute_module_names + }, + { + name: "paths", + type: "object", + isTSConfigOnly: true + }, + { + name: "rootDirs", + type: "list", + isTSConfigOnly: true, + element: { + name: "rootDirs", + type: "string", + isFilePath: true + } + }, + { + name: "typeRoots", + type: "list", + element: { + name: "typeRoots", + type: "string", + isFilePath: true + } + }, + { + name: "types", + type: "list", + element: { + name: "types", + type: "string" + }, + description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation + }, + { + name: "traceResolution", + type: "boolean", + description: ts.Diagnostics.Enable_tracing_of_the_name_resolution_process + }, + { + name: "allowJs", + type: "boolean", + description: ts.Diagnostics.Allow_javascript_files_to_be_compiled + }, + { + name: "allowSyntheticDefaultImports", + type: "boolean", + description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking + }, + { + name: "noImplicitUseStrict", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_use_strict_directives_in_module_output + }, + { + name: "maxNodeModuleJsDepth", + type: "number", + description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files + }, + { + name: "listEmittedFiles", + type: "boolean" + }, + { + name: "lib", + type: "list", + element: { + name: "lib", + type: ts.createMap({ + "es5": "lib.es5.d.ts", + "es6": "lib.es2015.d.ts", + "es2015": "lib.es2015.d.ts", + "es7": "lib.es2016.d.ts", + "es2016": "lib.es2016.d.ts", + "es2017": "lib.es2017.d.ts", + "dom": "lib.dom.d.ts", + "dom.iterable": "lib.dom.iterable.d.ts", + "webworker": "lib.webworker.d.ts", + "scripthost": "lib.scripthost.d.ts", + "es2015.core": "lib.es2015.core.d.ts", + "es2015.collection": "lib.es2015.collection.d.ts", + "es2015.generator": "lib.es2015.generator.d.ts", + "es2015.iterable": "lib.es2015.iterable.d.ts", + "es2015.promise": "lib.es2015.promise.d.ts", + "es2015.proxy": "lib.es2015.proxy.d.ts", + "es2015.reflect": "lib.es2015.reflect.d.ts", + "es2015.symbol": "lib.es2015.symbol.d.ts", + "es2015.symbol.wellknown": "lib.es2015.symbol.wellknown.d.ts", + "es2016.array.include": "lib.es2016.array.include.d.ts", + "es2017.object": "lib.es2017.object.d.ts", + "es2017.sharedmemory": "lib.es2017.sharedmemory.d.ts" + }), + }, + description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon + }, + { + name: "disableSizeLimit", + type: "boolean" + }, + { + name: "strictNullChecks", + type: "boolean", + description: ts.Diagnostics.Enable_strict_null_checks + }, + { + name: "importHelpers", + type: "boolean", + description: ts.Diagnostics.Import_emit_helpers_from_tslib + }, + { + name: "alwaysStrict", + type: "boolean", + description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file + } + ]; + ts.typingOptionDeclarations = [ + { + name: "enableAutoDiscovery", + type: "boolean", + }, + { + name: "include", + type: "list", + element: { + name: "include", + type: "string" + } + }, + { + name: "exclude", + type: "list", + element: { + name: "exclude", + type: "string" + } + } + ]; + ts.defaultInitCompilerOptions = { + module: ts.ModuleKind.CommonJS, + target: 1, + noImplicitAny: false, + sourceMap: false, + }; + var optionNameMapCache; + function getOptionNameMap() { + if (optionNameMapCache) { + return optionNameMapCache; + } + var optionNameMap = ts.createMap(); + var shortOptionNames = ts.createMap(); + ts.forEach(ts.optionDeclarations, function (option) { + optionNameMap[option.name.toLowerCase()] = option; + if (option.shortName) { + shortOptionNames[option.shortName] = option.name; + } + }); + optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames }; + return optionNameMapCache; + } + ts.getOptionNameMap = getOptionNameMap; + function createCompilerDiagnosticForInvalidCustomType(opt) { + var namesOfType = Object.keys(opt.type).map(function (key) { return "'" + key + "'"; }).join(", "); + return ts.createCompilerDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); + } + ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; + function parseCustomTypeOption(opt, value, errors) { + var key = trimString((value || "")).toLowerCase(); + var map = opt.type; + if (key in map) { + return map[key]; + } + else { + errors.push(createCompilerDiagnosticForInvalidCustomType(opt)); + } + } + ts.parseCustomTypeOption = parseCustomTypeOption; + function parseListTypeOption(opt, value, errors) { + if (value === void 0) { value = ""; } + value = trimString(value); + if (ts.startsWith(value, "-")) { + return undefined; + } + if (value === "") { + return []; + } + var values = value.split(","); + switch (opt.element.type) { + case "number": + return ts.map(values, parseInt); + case "string": + return ts.map(values, function (v) { return v || ""; }); + default: + return ts.filter(ts.map(values, function (v) { return parseCustomTypeOption(opt.element, v, errors); }), function (v) { return !!v; }); + } + } + ts.parseListTypeOption = parseListTypeOption; + function parseCommandLine(commandLine, readFile) { + var options = {}; + var fileNames = []; + var errors = []; + var _a = getOptionNameMap(), optionNameMap = _a.optionNameMap, shortOptionNames = _a.shortOptionNames; + parseStrings(commandLine); + return { + options: options, + fileNames: fileNames, + errors: errors + }; + function parseStrings(args) { + var i = 0; + while (i < args.length) { + var s = args[i]; + i++; + if (s.charCodeAt(0) === 64) { + parseResponseFile(s.slice(1)); + } + else if (s.charCodeAt(0) === 45) { + s = s.slice(s.charCodeAt(1) === 45 ? 2 : 1).toLowerCase(); + if (s in shortOptionNames) { + s = shortOptionNames[s]; + } + if (s in optionNameMap) { + var opt = optionNameMap[s]; + if (opt.isTSConfigOnly) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file, opt.name)); + } + else { + if (!args[i] && opt.type !== "boolean") { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_expects_an_argument, opt.name)); + } + switch (opt.type) { + case "number": + options[opt.name] = parseInt(args[i]); + i++; + break; + case "boolean": + options[opt.name] = true; + break; + case "string": + options[opt.name] = args[i] || ""; + i++; + break; + case "list": + var result = parseListTypeOption(opt, args[i], errors); + options[opt.name] = result || []; + if (result) { + i++; + } + break; + default: + options[opt.name] = parseCustomTypeOption(opt, args[i], errors); + i++; + break; + } + } + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_compiler_option_0, s)); + } + } + else { + fileNames.push(s); + } + } + } + function parseResponseFile(fileName) { + var text = readFile ? readFile(fileName) : ts.sys.readFile(fileName); + if (!text) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, fileName)); + return; + } + var args = []; + var pos = 0; + while (true) { + while (pos < text.length && text.charCodeAt(pos) <= 32) + pos++; + if (pos >= text.length) + break; + var start = pos; + if (text.charCodeAt(start) === 34) { + pos++; + while (pos < text.length && text.charCodeAt(pos) !== 34) + pos++; + if (pos < text.length) { + args.push(text.substring(start + 1, pos)); + pos++; + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unterminated_quoted_string_in_response_file_0, fileName)); + } + } + else { + while (text.charCodeAt(pos) > 32) + pos++; + args.push(text.substring(start, pos)); + } + } + parseStrings(args); + } + } + ts.parseCommandLine = parseCommandLine; + function readConfigFile(fileName, readFile) { + var text = ""; + try { + text = readFile(fileName); + } + catch (e) { + return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) }; + } + return parseConfigFileTextToJson(fileName, text); + } + ts.readConfigFile = readConfigFile; + function parseConfigFileTextToJson(fileName, jsonText, stripComments) { + if (stripComments === void 0) { stripComments = true; } + try { + var jsonTextToParse = stripComments ? removeComments(jsonText) : jsonText; + return { config: /\S/.test(jsonTextToParse) ? JSON.parse(jsonTextToParse) : {} }; + } + catch (e) { + return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) }; + } + } + ts.parseConfigFileTextToJson = parseConfigFileTextToJson; + function generateTSConfig(options, fileNames) { + var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions); + var configurations = { + compilerOptions: serializeCompilerOptions(compilerOptions) + }; + if (fileNames && fileNames.length) { + configurations.files = fileNames; + } + return configurations; + function getCustomTypeMapOfCommandLineOption(optionDefinition) { + if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean") { + return undefined; + } + else if (optionDefinition.type === "list") { + return getCustomTypeMapOfCommandLineOption(optionDefinition.element); + } + else { + return optionDefinition.type; + } + } + function getNameOfCompilerOptionValue(value, customTypeMap) { + for (var key in customTypeMap) { + if (customTypeMap[key] === value) { + return key; + } + } + return undefined; + } + function serializeCompilerOptions(options) { + var result = ts.createMap(); + var optionsNameMap = getOptionNameMap().optionNameMap; + for (var name_44 in options) { + if (ts.hasProperty(options, name_44)) { + switch (name_44) { + case "init": + case "watch": + case "version": + case "help": + case "project": + break; + default: + var value = options[name_44]; + var optionDefinition = optionsNameMap[name_44.toLowerCase()]; + if (optionDefinition) { + var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); + if (!customTypeMap) { + result[name_44] = value; + } + else { + if (optionDefinition.type === "list") { + var convertedValue = []; + for (var _i = 0, _a = value; _i < _a.length; _i++) { + var element = _a[_i]; + convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); + } + result[name_44] = convertedValue; + } + else { + result[name_44] = getNameOfCompilerOptionValue(value, customTypeMap); + } + } + } + break; + } + } + } + return result; + } + } + ts.generateTSConfig = generateTSConfig; + function removeComments(jsonText) { + var output = ""; + var scanner = ts.createScanner(1, false, 0, jsonText); + var token; + while ((token = scanner.scan()) !== 1) { + switch (token) { + case 2: + case 3: + output += scanner.getTokenText().replace(/\S/g, " "); + break; + default: + output += scanner.getTokenText(); + break; + } + } + return output; + } + function parseJsonConfigFileContent(json, host, basePath, existingOptions, configFileName, resolutionStack) { + if (existingOptions === void 0) { existingOptions = {}; } + if (resolutionStack === void 0) { resolutionStack = []; } + var errors = []; + var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); + var resolvedPath = ts.toPath(configFileName || "", basePath, getCanonicalFileName); + if (resolutionStack.indexOf(resolvedPath) >= 0) { + return { + options: {}, + fileNames: [], + typingOptions: {}, + raw: json, + errors: [ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, resolutionStack.concat([resolvedPath]).join(" -> "))], + wildcardDirectories: {} + }; + } + var options = convertCompilerOptionsFromJsonWorker(json["compilerOptions"], basePath, errors, configFileName); + var typingOptions = convertTypingOptionsFromJsonWorker(json["typingOptions"], basePath, errors, configFileName); + if (json["extends"]) { + var _a = [undefined, undefined, undefined, {}], include = _a[0], exclude = _a[1], files = _a[2], baseOptions = _a[3]; + if (typeof json["extends"] === "string") { + _b = (tryExtendsName(json["extends"]) || [include, exclude, files, baseOptions]), include = _b[0], exclude = _b[1], files = _b[2], baseOptions = _b[3]; + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string")); + } + if (include && !json["include"]) { + json["include"] = include; + } + if (exclude && !json["exclude"]) { + json["exclude"] = exclude; + } + if (files && !json["files"]) { + json["files"] = files; + } + options = ts.assign({}, baseOptions, options); + } + options = ts.extend(existingOptions, options); + options.configFilePath = configFileName; + var _c = getFileNames(errors), fileNames = _c.fileNames, wildcardDirectories = _c.wildcardDirectories; + var compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors); + return { + options: options, + fileNames: fileNames, + typingOptions: typingOptions, + raw: json, + errors: errors, + wildcardDirectories: wildcardDirectories, + compileOnSave: compileOnSave + }; + function tryExtendsName(extendedConfig) { + if (!(ts.isRootedDiskPath(extendedConfig) || ts.startsWith(ts.normalizeSlashes(extendedConfig), "./") || ts.startsWith(ts.normalizeSlashes(extendedConfig), "../"))) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.The_path_in_an_extends_options_must_be_relative_or_rooted)); + return; + } + var extendedConfigPath = ts.toPath(extendedConfig, basePath, getCanonicalFileName); + if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json")) { + extendedConfigPath = extendedConfigPath + ".json"; + if (!host.fileExists(extendedConfigPath)) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig)); + return; + } + } + var extendedResult = readConfigFile(extendedConfigPath, function (path) { return host.readFile(path); }); + if (extendedResult.error) { + errors.push(extendedResult.error); + return; + } + var extendedDirname = ts.getDirectoryPath(extendedConfigPath); + var relativeDifference = ts.convertToRelativePath(extendedDirname, basePath, getCanonicalFileName); + var updatePath = function (path) { return ts.isRootedDiskPath(path) ? path : ts.combinePaths(relativeDifference, path); }; + var result = parseJsonConfigFileContent(extendedResult.config, host, extendedDirname, undefined, ts.getBaseFileName(extendedConfigPath), resolutionStack.concat([resolvedPath])); + errors.push.apply(errors, result.errors); + var _a = ts.map(["include", "exclude", "files"], function (key) { + if (!json[key] && extendedResult.config[key]) { + return ts.map(extendedResult.config[key], updatePath); + } + }), include = _a[0], exclude = _a[1], files = _a[2]; + return [include, exclude, files, result.options]; + } + function getFileNames(errors) { + var fileNames; + if (ts.hasProperty(json, "files")) { + if (ts.isArray(json["files"])) { + fileNames = json["files"]; + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array")); + } + } + var includeSpecs; + if (ts.hasProperty(json, "include")) { + if (ts.isArray(json["include"])) { + includeSpecs = json["include"]; + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "include", "Array")); + } + } + var excludeSpecs; + if (ts.hasProperty(json, "exclude")) { + if (ts.isArray(json["exclude"])) { + excludeSpecs = json["exclude"]; + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "exclude", "Array")); + } + } + else if (ts.hasProperty(json, "excludes")) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_option_excludes_Did_you_mean_exclude)); + } + else { + excludeSpecs = ["node_modules", "bower_components", "jspm_packages"]; + var outDir = json["compilerOptions"] && json["compilerOptions"]["outDir"]; + if (outDir) { + excludeSpecs.push(outDir); + } + } + if (fileNames === undefined && includeSpecs === undefined) { + includeSpecs = ["**/*"]; + } + return matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors); + } + var _b; + } + ts.parseJsonConfigFileContent = parseJsonConfigFileContent; + function convertCompileOnSaveOptionFromJson(jsonOption, basePath, errors) { + if (!ts.hasProperty(jsonOption, ts.compileOnSaveCommandLineOption.name)) { + return false; + } + var result = convertJsonOption(ts.compileOnSaveCommandLineOption, jsonOption["compileOnSave"], basePath, errors); + if (typeof result === "boolean" && result) { + return result; + } + return false; + } + ts.convertCompileOnSaveOptionFromJson = convertCompileOnSaveOptionFromJson; + function convertCompilerOptionsFromJson(jsonOptions, basePath, configFileName) { + var errors = []; + var options = convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName); + return { options: options, errors: errors }; + } + ts.convertCompilerOptionsFromJson = convertCompilerOptionsFromJson; + function convertTypingOptionsFromJson(jsonOptions, basePath, configFileName) { + var errors = []; + var options = convertTypingOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName); + return { options: options, errors: errors }; + } + ts.convertTypingOptionsFromJson = convertTypingOptionsFromJson; + function convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { + var options = ts.getBaseFileName(configFileName) === "jsconfig.json" + ? { allowJs: true, maxNodeModuleJsDepth: 2, allowSyntheticDefaultImports: true, skipLibCheck: true } + : {}; + convertOptionsFromJson(ts.optionDeclarations, jsonOptions, basePath, options, ts.Diagnostics.Unknown_compiler_option_0, errors); + return options; + } + function convertTypingOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { + var options = ts.getBaseFileName(configFileName) === "jsconfig.json" + ? { enableAutoDiscovery: true, include: [], exclude: [] } + : { enableAutoDiscovery: false, include: [], exclude: [] }; + convertOptionsFromJson(ts.typingOptionDeclarations, jsonOptions, basePath, options, ts.Diagnostics.Unknown_typing_option_0, errors); + return options; + } + function convertOptionsFromJson(optionDeclarations, jsonOptions, basePath, defaultOptions, diagnosticMessage, errors) { + if (!jsonOptions) { + return; + } + var optionNameMap = ts.arrayToMap(optionDeclarations, function (opt) { return opt.name; }); + for (var id in jsonOptions) { + if (id in optionNameMap) { + var opt = optionNameMap[id]; + defaultOptions[opt.name] = convertJsonOption(opt, jsonOptions[id], basePath, errors); + } + else { + errors.push(ts.createCompilerDiagnostic(diagnosticMessage, id)); + } + } + } + function convertJsonOption(opt, value, basePath, errors) { + var optType = opt.type; + var expectedType = typeof optType === "string" ? optType : "string"; + if (optType === "list" && ts.isArray(value)) { + return convertJsonOptionOfListType(opt, value, basePath, errors); + } + else if (typeof value === expectedType) { + if (typeof optType !== "string") { + return convertJsonOptionOfCustomType(opt, value, errors); + } + else { + if (opt.isFilePath) { + value = ts.normalizePath(ts.combinePaths(basePath, value)); + if (value === "") { + value = "."; + } + } + } + return value; + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, opt.name, expectedType)); + } + } + function convertJsonOptionOfCustomType(opt, value, errors) { + var key = value.toLowerCase(); + if (key in opt.type) { + return opt.type[key]; + } + else { + errors.push(createCompilerDiagnosticForInvalidCustomType(opt)); + } + } + function convertJsonOptionOfListType(option, values, basePath, errors) { + return ts.filter(ts.map(values, function (v) { return convertJsonOption(option.element, v, basePath, errors); }), function (v) { return !!v; }); + } + function trimString(s) { + return typeof s.trim === "function" ? s.trim() : s.replace(/^[\s]+|[\s]+$/g, ""); + } + var invalidTrailingRecursionPattern = /(^|\/)\*\*\/?$/; + var invalidMultipleRecursionPatterns = /(^|\/)\*\*\/(.*\/)?\*\*($|\/)/; + var invalidDotDotAfterRecursiveWildcardPattern = /(^|\/)\*\*\/(.*\/)?\.\.($|\/)/; + var watchRecursivePattern = /\/[^/]*?[*?][^/]*\//; + var wildcardDirectoryPattern = /^[^*?]*(?=\/[^/]*[*?])/; + function matchFileNames(fileNames, include, exclude, basePath, options, host, errors) { + basePath = ts.normalizePath(basePath); + var keyMapper = host.useCaseSensitiveFileNames ? caseSensitiveKeyMapper : caseInsensitiveKeyMapper; + var literalFileMap = ts.createMap(); + var wildcardFileMap = ts.createMap(); + if (include) { + include = validateSpecs(include, errors, false); + } + if (exclude) { + exclude = validateSpecs(exclude, errors, true); + } + var wildcardDirectories = getWildcardDirectories(include, exclude, basePath, host.useCaseSensitiveFileNames); + var supportedExtensions = ts.getSupportedExtensions(options); + if (fileNames) { + for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) { + var fileName = fileNames_1[_i]; + var file = ts.combinePaths(basePath, fileName); + literalFileMap[keyMapper(file)] = file; + } + } + if (include && include.length > 0) { + for (var _a = 0, _b = host.readDirectory(basePath, supportedExtensions, exclude, include); _a < _b.length; _a++) { + var file = _b[_a]; + if (hasFileWithHigherPriorityExtension(file, literalFileMap, wildcardFileMap, supportedExtensions, keyMapper)) { + continue; + } + removeWildcardFilesWithLowerPriorityExtension(file, wildcardFileMap, supportedExtensions, keyMapper); + var key = keyMapper(file); + if (!(key in literalFileMap) && !(key in wildcardFileMap)) { + wildcardFileMap[key] = file; + } + } + } + var literalFiles = ts.reduceProperties(literalFileMap, addFileToOutput, []); + var wildcardFiles = ts.reduceProperties(wildcardFileMap, addFileToOutput, []); + wildcardFiles.sort(host.useCaseSensitiveFileNames ? ts.compareStrings : ts.compareStringsCaseInsensitive); + return { + fileNames: literalFiles.concat(wildcardFiles), + wildcardDirectories: wildcardDirectories + }; + } + function validateSpecs(specs, errors, allowTrailingRecursion) { + var validSpecs = []; + for (var _i = 0, specs_2 = specs; _i < specs_2.length; _i++) { + var spec = specs_2[_i]; + if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); + } + else if (invalidMultipleRecursionPatterns.test(spec)) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0, spec)); + } + else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); + } + else { + validSpecs.push(spec); + } + } + return validSpecs; + } + function getWildcardDirectories(include, exclude, path, useCaseSensitiveFileNames) { + var rawExcludeRegex = ts.getRegularExpressionForWildcard(exclude, path, "exclude"); + var excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames ? "" : "i"); + var wildcardDirectories = ts.createMap(); + if (include !== undefined) { + var recursiveKeys = []; + for (var _i = 0, include_1 = include; _i < include_1.length; _i++) { + var file = include_1[_i]; + var name_45 = ts.normalizePath(ts.combinePaths(path, file)); + if (excludeRegex && excludeRegex.test(name_45)) { + continue; + } + var match = wildcardDirectoryPattern.exec(name_45); + if (match) { + var key = useCaseSensitiveFileNames ? match[0] : match[0].toLowerCase(); + var flags = watchRecursivePattern.test(name_45) ? 1 : 0; + var existingFlags = wildcardDirectories[key]; + if (existingFlags === undefined || existingFlags < flags) { + wildcardDirectories[key] = flags; + if (flags === 1) { + recursiveKeys.push(key); + } + } + } + } + for (var key in wildcardDirectories) { + for (var _a = 0, recursiveKeys_1 = recursiveKeys; _a < recursiveKeys_1.length; _a++) { + var recursiveKey = recursiveKeys_1[_a]; + if (key !== recursiveKey && ts.containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) { + delete wildcardDirectories[key]; + } + } + } + } + return wildcardDirectories; + } + function hasFileWithHigherPriorityExtension(file, literalFiles, wildcardFiles, extensions, keyMapper) { + var extensionPriority = ts.getExtensionPriority(file, extensions); + var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority); + for (var i = 0; i < adjustedExtensionPriority; i++) { + var higherPriorityExtension = extensions[i]; + var higherPriorityPath = keyMapper(ts.changeExtension(file, higherPriorityExtension)); + if (higherPriorityPath in literalFiles || higherPriorityPath in wildcardFiles) { + return true; + } + } + return false; + } + function removeWildcardFilesWithLowerPriorityExtension(file, wildcardFiles, extensions, keyMapper) { + var extensionPriority = ts.getExtensionPriority(file, extensions); + var nextExtensionPriority = ts.getNextLowestExtensionPriority(extensionPriority); + for (var i = nextExtensionPriority; i < extensions.length; i++) { + var lowerPriorityExtension = extensions[i]; + var lowerPriorityPath = keyMapper(ts.changeExtension(file, lowerPriorityExtension)); + delete wildcardFiles[lowerPriorityPath]; + } + } + function addFileToOutput(output, file) { + output.push(file); + return output; + } + function caseSensitiveKeyMapper(key) { + return key; + } + function caseInsensitiveKeyMapper(key) { + return key.toLowerCase(); + } +})(ts || (ts = {})); +var ts; (function (ts) { var ScriptSnapshot; (function (ScriptSnapshot) { @@ -48886,7 +50169,7 @@ var ts; StringScriptSnapshot.prototype.getLength = function () { return this.text.length; }; - StringScriptSnapshot.prototype.getChangeRange = function (oldSnapshot) { + StringScriptSnapshot.prototype.getChangeRange = function () { return undefined; }; return StringScriptSnapshot; @@ -48940,6 +50223,22 @@ var ts; SymbolDisplayPartKind[SymbolDisplayPartKind["regularExpressionLiteral"] = 21] = "regularExpressionLiteral"; })(ts.SymbolDisplayPartKind || (ts.SymbolDisplayPartKind = {})); var SymbolDisplayPartKind = ts.SymbolDisplayPartKind; + (function (OutputFileType) { + OutputFileType[OutputFileType["JavaScript"] = 0] = "JavaScript"; + OutputFileType[OutputFileType["SourceMap"] = 1] = "SourceMap"; + OutputFileType[OutputFileType["Declaration"] = 2] = "Declaration"; + })(ts.OutputFileType || (ts.OutputFileType = {})); + var OutputFileType = ts.OutputFileType; + (function (EndOfLineState) { + EndOfLineState[EndOfLineState["None"] = 0] = "None"; + EndOfLineState[EndOfLineState["InMultiLineCommentTrivia"] = 1] = "InMultiLineCommentTrivia"; + EndOfLineState[EndOfLineState["InSingleQuoteStringLiteral"] = 2] = "InSingleQuoteStringLiteral"; + EndOfLineState[EndOfLineState["InDoubleQuoteStringLiteral"] = 3] = "InDoubleQuoteStringLiteral"; + EndOfLineState[EndOfLineState["InTemplateHeadOrNoSubstitutionTemplate"] = 4] = "InTemplateHeadOrNoSubstitutionTemplate"; + EndOfLineState[EndOfLineState["InTemplateMiddleOrTail"] = 5] = "InTemplateMiddleOrTail"; + EndOfLineState[EndOfLineState["InTemplateSubstitutionPosition"] = 6] = "InTemplateSubstitutionPosition"; + })(ts.EndOfLineState || (ts.EndOfLineState = {})); + var EndOfLineState = ts.EndOfLineState; (function (TokenClass) { TokenClass[TokenClass["Punctuation"] = 0] = "Punctuation"; TokenClass[TokenClass["Keyword"] = 1] = "Keyword"; @@ -49027,40 +50326,75 @@ var ts; ClassificationTypeNames.jsxText = "jsx text"; ClassificationTypeNames.jsxAttributeStringLiteralValue = "jsx attribute string literal value"; ts.ClassificationTypeNames = ClassificationTypeNames; + (function (ClassificationType) { + ClassificationType[ClassificationType["comment"] = 1] = "comment"; + ClassificationType[ClassificationType["identifier"] = 2] = "identifier"; + ClassificationType[ClassificationType["keyword"] = 3] = "keyword"; + ClassificationType[ClassificationType["numericLiteral"] = 4] = "numericLiteral"; + ClassificationType[ClassificationType["operator"] = 5] = "operator"; + ClassificationType[ClassificationType["stringLiteral"] = 6] = "stringLiteral"; + ClassificationType[ClassificationType["regularExpressionLiteral"] = 7] = "regularExpressionLiteral"; + ClassificationType[ClassificationType["whiteSpace"] = 8] = "whiteSpace"; + ClassificationType[ClassificationType["text"] = 9] = "text"; + ClassificationType[ClassificationType["punctuation"] = 10] = "punctuation"; + ClassificationType[ClassificationType["className"] = 11] = "className"; + ClassificationType[ClassificationType["enumName"] = 12] = "enumName"; + ClassificationType[ClassificationType["interfaceName"] = 13] = "interfaceName"; + ClassificationType[ClassificationType["moduleName"] = 14] = "moduleName"; + ClassificationType[ClassificationType["typeParameterName"] = 15] = "typeParameterName"; + ClassificationType[ClassificationType["typeAliasName"] = 16] = "typeAliasName"; + ClassificationType[ClassificationType["parameterName"] = 17] = "parameterName"; + ClassificationType[ClassificationType["docCommentTagName"] = 18] = "docCommentTagName"; + ClassificationType[ClassificationType["jsxOpenTagName"] = 19] = "jsxOpenTagName"; + ClassificationType[ClassificationType["jsxCloseTagName"] = 20] = "jsxCloseTagName"; + ClassificationType[ClassificationType["jsxSelfClosingTagName"] = 21] = "jsxSelfClosingTagName"; + ClassificationType[ClassificationType["jsxAttribute"] = 22] = "jsxAttribute"; + ClassificationType[ClassificationType["jsxText"] = 23] = "jsxText"; + ClassificationType[ClassificationType["jsxAttributeStringLiteralValue"] = 24] = "jsxAttributeStringLiteralValue"; + })(ts.ClassificationType || (ts.ClassificationType = {})); + var ClassificationType = ts.ClassificationType; })(ts || (ts = {})); var ts; (function (ts) { - ts.scanner = ts.createScanner(2, true); + ts.scanner = ts.createScanner(4, true); ts.emptyArray = []; + (function (SemanticMeaning) { + SemanticMeaning[SemanticMeaning["None"] = 0] = "None"; + SemanticMeaning[SemanticMeaning["Value"] = 1] = "Value"; + SemanticMeaning[SemanticMeaning["Type"] = 2] = "Type"; + SemanticMeaning[SemanticMeaning["Namespace"] = 4] = "Namespace"; + SemanticMeaning[SemanticMeaning["All"] = 7] = "All"; + })(ts.SemanticMeaning || (ts.SemanticMeaning = {})); + var SemanticMeaning = ts.SemanticMeaning; function getMeaningFromDeclaration(node) { switch (node.kind) { - case 142: - case 218: - case 169: + case 143: + case 219: + case 170: + case 146: case 145: - case 144: case 253: case 254: case 255: - case 147: - case 146: case 148: + case 147: case 149: case 150: - case 220: - case 179: + case 151: + case 221: case 180: + case 181: case 252: return 1; - case 141: - case 222: + case 142: case 223: - case 159: - return 2; - case 221: case 224: - return 1 | 2; + case 160: + return 2; + case 222: case 225: + return 1 | 2; + case 226: if (ts.isAmbientModule(node)) { return 4 | 1; } @@ -49070,12 +50404,12 @@ var ts; else { return 4; } - case 233: case 234: - case 229: - case 230: case 235: + case 230: + case 231: case 236: + case 237: return 1 | 2 | 4; case 256: return 4 | 1; @@ -49084,7 +50418,7 @@ var ts; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.parent.kind === 235) { + if (node.parent.kind === 236) { return 1 | 2 | 4; } else if (isInRightSideOfImport(node)) { @@ -49105,16 +50439,16 @@ var ts; } ts.getMeaningFromLocation = getMeaningFromLocation; function getMeaningFromRightHandSideOfImportEquals(node) { - ts.Debug.assert(node.kind === 69); - if (node.parent.kind === 139 && + ts.Debug.assert(node.kind === 70); + if (node.parent.kind === 140 && node.parent.right === node && - node.parent.parent.kind === 229) { + node.parent.parent.kind === 230) { return 1 | 2 | 4; } return 4; } function isInRightSideOfImport(node) { - while (node.parent.kind === 139) { + while (node.parent.kind === 140) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -49125,27 +50459,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 139) { - while (root.parent && root.parent.kind === 139) { + if (root.parent.kind === 140) { + while (root.parent && root.parent.kind === 140) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 155 && !isLastClause; + return root.parent.kind === 156 && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 172) { - while (root.parent && root.parent.kind === 172) { + if (root.parent.kind === 173) { + while (root.parent && root.parent.kind === 173) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 194 && root.parent.parent.kind === 251) { + if (!isLastClause && root.parent.kind === 195 && root.parent.parent.kind === 251) { var decl = root.parent.parent.parent; - return (decl.kind === 221 && root.parent.parent.token === 106) || - (decl.kind === 222 && root.parent.parent.token === 83); + return (decl.kind === 222 && root.parent.parent.token === 107) || + (decl.kind === 223 && root.parent.parent.token === 84); } return false; } @@ -49153,17 +50487,17 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 155 || - (node.parent.kind === 194 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || - (node.kind === 97 && !ts.isPartOfExpression(node)) || - node.kind === 165; + return node.parent.kind === 156 || + (node.parent.kind === 195 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || + (node.kind === 98 && !ts.isPartOfExpression(node)) || + node.kind === 166; } function isCallExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 174); + return isCallOrNewExpressionTarget(node, 175); } ts.isCallExpressionTarget = isCallExpressionTarget; function isNewExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 175); + return isCallOrNewExpressionTarget(node, 176); } ts.isNewExpressionTarget = isNewExpressionTarget; function isCallOrNewExpressionTarget(node, kind) { @@ -49176,7 +50510,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 214 && referenceNode.label.text === labelName) { + if (referenceNode.kind === 215 && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -49185,14 +50519,14 @@ var ts; } ts.getTargetLabel = getTargetLabel; function isJumpStatementTarget(node) { - return node.kind === 69 && - (node.parent.kind === 210 || node.parent.kind === 209) && + return node.kind === 70 && + (node.parent.kind === 211 || node.parent.kind === 210) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { - return node.kind === 69 && - node.parent.kind === 214 && + return node.kind === 70 && + node.parent.kind === 215 && node.parent.label === node; } function isLabelName(node) { @@ -49200,38 +50534,38 @@ var ts; } ts.isLabelName = isLabelName; function isRightSideOfQualifiedName(node) { - return node.parent.kind === 139 && node.parent.right === node; + return node.parent.kind === 140 && node.parent.right === node; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 172 && node.parent.name === node; + return node && node.parent && node.parent.kind === 173 && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 225 && node.parent.name === node; + return node.parent.kind === 226 && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { - return node.kind === 69 && + return node.kind === 70 && ts.isFunctionLike(node.parent) && node.parent.name === node; } ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 9 || node.kind === 8) { switch (node.parent.kind) { + case 146: case 145: - case 144: case 253: case 255: + case 148: case 147: - case 146: - case 149: case 150: - case 225: + case 151: + case 226: return node.parent.name === node; - case 173: + case 174: return node.parent.argumentExpression === node; - case 140: + case 141: return true; } } @@ -49276,16 +50610,16 @@ var ts; } switch (node.kind) { case 256: + case 148: case 147: - case 146: - case 220: - case 179: - case 149: - case 150: case 221: + case 180: + case 150: + case 151: case 222: - case 224: + case 223: case 225: + case 226: return node; } } @@ -49295,42 +50629,42 @@ var ts; switch (node.kind) { case 256: return ts.isExternalModule(node) ? ts.ScriptElementKind.moduleElement : ts.ScriptElementKind.scriptElement; - case 225: + case 226: return ts.ScriptElementKind.moduleElement; - case 221: - case 192: + case 222: + case 193: return ts.ScriptElementKind.classElement; - case 222: return ts.ScriptElementKind.interfaceElement; - case 223: return ts.ScriptElementKind.typeElement; - case 224: return ts.ScriptElementKind.enumElement; - case 218: + case 223: return ts.ScriptElementKind.interfaceElement; + case 224: return ts.ScriptElementKind.typeElement; + case 225: return ts.ScriptElementKind.enumElement; + case 219: return getKindOfVariableDeclaration(node); - case 169: + case 170: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); + case 181: + case 221: case 180: - case 220: - case 179: return ts.ScriptElementKind.functionElement; - case 149: return ts.ScriptElementKind.memberGetAccessorElement; - case 150: return ts.ScriptElementKind.memberSetAccessorElement; + case 150: return ts.ScriptElementKind.memberGetAccessorElement; + case 151: return ts.ScriptElementKind.memberSetAccessorElement; + case 148: case 147: - case 146: return ts.ScriptElementKind.memberFunctionElement; + case 146: case 145: - case 144: return ts.ScriptElementKind.memberVariableElement; - case 153: return ts.ScriptElementKind.indexSignatureElement; - case 152: return ts.ScriptElementKind.constructSignatureElement; - case 151: return ts.ScriptElementKind.callSignatureElement; - case 148: return ts.ScriptElementKind.constructorImplementationElement; - case 141: return ts.ScriptElementKind.typeParameterElement; + case 154: return ts.ScriptElementKind.indexSignatureElement; + case 153: return ts.ScriptElementKind.constructSignatureElement; + case 152: return ts.ScriptElementKind.callSignatureElement; + case 149: return ts.ScriptElementKind.constructorImplementationElement; + case 142: return ts.ScriptElementKind.typeParameterElement; case 255: return ts.ScriptElementKind.enumMemberElement; - case 142: return ts.hasModifier(node, 92) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; - case 229: - case 234: - case 231: - case 238: + case 143: return ts.hasModifier(node, 92) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; + case 230: + case 235: case 232: + case 239: + case 233: return ts.ScriptElementKind.alias; case 279: return ts.ScriptElementKind.typeElement; @@ -49347,7 +50681,7 @@ var ts; } ts.getNodeKind = getNodeKind; function getStringLiteralTypeForNode(node, typeChecker) { - var searchNode = node.parent.kind === 166 ? node.parent : node; + var searchNode = node.parent.kind === 167 ? node.parent : node; var type = typeChecker.getTypeAtLocation(searchNode); if (type && type.flags & 32) { return type; @@ -49357,10 +50691,10 @@ var ts; ts.getStringLiteralTypeForNode = getStringLiteralTypeForNode; function isThis(node) { switch (node.kind) { - case 97: + case 98: return true; - case 69: - return ts.identifierIsThisKeyword(node) && node.parent.kind === 142; + case 70: + return ts.identifierIsThisKeyword(node) && node.parent.kind === 143; default: return false; } @@ -49404,107 +50738,107 @@ var ts; return false; } switch (n.kind) { - case 221: case 222: - case 224: - case 171: - case 167: - case 159: - case 199: - case 226: + case 223: + case 225: + case 172: + case 168: + case 160: + case 200: case 227: - case 233: - case 237: - return nodeEndsWith(n, 16, sourceFile); + case 228: + case 234: + case 238: + return nodeEndsWith(n, 17, sourceFile); case 252: return isCompletedNode(n.block, sourceFile); - case 175: + case 176: if (!n.arguments) { return true; } - case 174: - case 178: - case 164: - return nodeEndsWith(n, 18, sourceFile); - case 156: + case 175: + case 179: + case 165: + return nodeEndsWith(n, 19, sourceFile); case 157: + case 158: return isCompletedNode(n.type, sourceFile); - case 148: case 149: case 150: - case 220: - case 179: - case 147: - case 146: - case 152: case 151: + case 221: case 180: + case 148: + case 147: + case 153: + case 152: + case 181: if (n.body) { return isCompletedNode(n.body, sourceFile); } if (n.type) { return isCompletedNode(n.type, sourceFile); } - return hasChildOfKind(n, 18, sourceFile); - case 225: + return hasChildOfKind(n, 19, sourceFile); + case 226: return n.body && isCompletedNode(n.body, sourceFile); - case 203: + case 204: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 202: + case 203: return isCompletedNode(n.expression, sourceFile) || - hasChildOfKind(n, 23); - case 170: - case 168: - case 173: - case 140: - case 161: - return nodeEndsWith(n, 20, sourceFile); - case 153: + hasChildOfKind(n, 24); + case 171: + case 169: + case 174: + case 141: + case 162: + return nodeEndsWith(n, 21, sourceFile); + case 154: if (n.type) { return isCompletedNode(n.type, sourceFile); } - return hasChildOfKind(n, 20, sourceFile); + return hasChildOfKind(n, 21, sourceFile); case 249: case 250: return false; - case 206: case 207: case 208: - case 205: + case 209: + case 206: return isCompletedNode(n.statement, sourceFile); - case 204: - var hasWhileKeyword = findChildOfKind(n, 104, sourceFile); + case 205: + var hasWhileKeyword = findChildOfKind(n, 105, sourceFile); if (hasWhileKeyword) { - return nodeEndsWith(n, 18, sourceFile); + return nodeEndsWith(n, 19, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 158: + case 159: return isCompletedNode(n.exprName, sourceFile); - case 182: - case 181: case 183: - case 190: + case 182: + case 184: case 191: + case 192: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 176: + case 177: return isCompletedNode(n.template, sourceFile); - case 189: + case 190: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 197: + case 198: return ts.nodeIsPresent(n.literal); - case 236: - case 230: + case 237: + case 231: return ts.nodeIsPresent(n.moduleSpecifier); - case 185: + case 186: return isCompletedNode(n.operand, sourceFile); - case 187: - return isCompletedNode(n.right, sourceFile); case 188: + return isCompletedNode(n.right, sourceFile); + case 189: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -49518,7 +50852,7 @@ var ts; if (last.kind === expectedLastToken) { return true; } - else if (last.kind === 23 && children.length !== 1) { + else if (last.kind === 24 && children.length !== 1) { return children[children.length - 2].kind === expectedLastToken; } } @@ -49655,7 +50989,7 @@ var ts; function findPrecedingToken(position, sourceFile, startNode) { return find(startNode || sourceFile); function findRightmostToken(n) { - if (isToken(n) || n.kind === 244) { + if (isToken(n)) { return n; } var children = n.getChildren(); @@ -49663,16 +50997,16 @@ var ts; return candidate && findRightmostToken(candidate); } function find(n) { - if (isToken(n) || n.kind === 244) { + if (isToken(n)) { 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 === 244)) { + if (position < child.end && (nodeHasTokens(child) || child.kind === 10)) { var start = child.getStart(sourceFile); var lookInPreviousChild = (start >= position) || - (child.kind === 244 && start === child.end); + (child.kind === 10 && start === child.end); if (lookInPreviousChild) { var candidate = findRightmostChildNodeWithTokens(children, i); return candidate && findRightmostToken(candidate); @@ -49721,19 +51055,19 @@ var ts; if (!token) { return false; } - if (token.kind === 244) { + if (token.kind === 10) { return true; } - if (token.kind === 25 && token.parent.kind === 244) { + if (token.kind === 26 && token.parent.kind === 10) { return true; } - if (token.kind === 25 && token.parent.kind === 248) { + if (token.kind === 26 && token.parent.kind === 248) { return true; } - if (token && token.kind === 16 && token.parent.kind === 248) { + if (token && token.kind === 17 && token.parent.kind === 248) { return true; } - if (token.kind === 25 && token.parent.kind === 245) { + if (token.kind === 26 && token.parent.kind === 245) { return true; } return false; @@ -49772,9 +51106,9 @@ var ts; var node = ts.getTokenAtPosition(sourceFile, position); if (isToken(node)) { switch (node.kind) { - case 102: - case 108: - case 74: + case 103: + case 109: + case 75: node = node.parent === undefined ? undefined : node.parent.parent; break; default: @@ -49824,21 +51158,21 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 155 || node.kind === 174) { + if (node.kind === 156 || node.kind === 175) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 221 || node.kind === 222) { + if (ts.isFunctionLike(node) || node.kind === 222 || node.kind === 223) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 && n.kind <= 138; + return n.kind >= 0 && n.kind <= 139; } ts.isToken = isToken; function isWord(kind) { - return kind === 69 || ts.isKeyword(kind); + return kind === 70 || ts.isKeyword(kind); } ts.isWord = isWord; function isPropertyName(kind) { @@ -49850,7 +51184,7 @@ var ts; ts.isComment = isComment; function isStringOrRegularExpressionOrTemplateLiteral(kind) { if (kind === 9 - || kind === 10 + || kind === 11 || ts.isTemplateLiteralKind(kind)) { return true; } @@ -49858,7 +51192,7 @@ var ts; } ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; function isPunctuation(kind) { - return 15 <= kind && kind <= 68; + return 16 <= kind && kind <= 69; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position) { @@ -49868,9 +51202,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 112: - case 110: + case 113: case 111: + case 112: return true; } return false; @@ -49893,14 +51227,14 @@ var ts; } ts.compareDataObjects = compareDataObjects; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 170 || - node.kind === 171) { - if (node.parent.kind === 187 && + if (node.kind === 171 || + node.kind === 172) { + if (node.parent.kind === 188 && node.parent.left === node && - node.parent.operatorToken.kind === 56) { + node.parent.operatorToken.kind === 57) { return true; } - if (node.parent.kind === 208 && + if (node.parent.kind === 209 && node.parent.initializer === node) { return true; } @@ -49935,7 +51269,7 @@ var ts; })(ts || (ts = {})); (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 142; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 143; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -49988,7 +51322,7 @@ var ts; } } function symbolPart(text, symbol) { - return displayPart(text, displayPartKind(symbol), symbol); + return displayPart(text, displayPartKind(symbol)); function displayPartKind(symbol) { var flags = symbol.flags; if (flags & 3) { @@ -50037,7 +51371,7 @@ var ts; } } ts.symbolPart = symbolPart; - function displayPart(text, kind, symbol) { + function displayPart(text, kind) { return { text: text, kind: ts.SymbolDisplayPartKind[kind] @@ -50110,7 +51444,7 @@ var ts; return location.getText(); } else if (ts.isStringOrNumericLiteral(location.kind) && - location.parent.kind === 140) { + location.parent.kind === 141) { return location.text; } var localExportDefaultSymbol = ts.getLocalSymbolForExportDefault(symbol); @@ -50120,7 +51454,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 234 || location.parent.kind === 238) && + (location.parent.kind === 235 || location.parent.kind === 239) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -50225,157 +51559,157 @@ var ts; function spanInNode(node) { if (node) { switch (node.kind) { - case 200: + case 201: return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 218: - case 145: - case 144: - return spanInVariableDeclaration(node); - case 142: - return spanInParameterDeclaration(node); - case 220: - case 147: + case 219: case 146: - case 149: - case 150: + case 145: + return spanInVariableDeclaration(node); + case 143: + return spanInParameterDeclaration(node); + case 221: case 148: - case 179: + case 147: + case 150: + case 151: + case 149: case 180: + case 181: return spanInFunctionDeclaration(node); - case 199: + case 200: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } - case 226: + case 227: return spanInBlock(node); case 252: return spanInBlock(node.block); - case 202: - return textSpan(node.expression); - case 211: - return textSpan(node.getChildAt(0), node.expression); - case 205: - return textSpanEndingAtNextToken(node, node.expression); - case 204: - return spanInNode(node.statement); - case 217: - return textSpan(node.getChildAt(0)); case 203: - return textSpanEndingAtNextToken(node, node.expression); - case 214: - return spanInNode(node.statement); - case 210: - case 209: - return textSpan(node.getChildAt(0), node.label); + return textSpan(node.expression); + case 212: + return textSpan(node.getChildAt(0), node.expression); case 206: - return spanInForStatement(node); - case 207: return textSpanEndingAtNextToken(node, node.expression); + case 205: + return spanInNode(node.statement); + case 218: + return textSpan(node.getChildAt(0)); + case 204: + return textSpanEndingAtNextToken(node, node.expression); + case 215: + return spanInNode(node.statement); + case 211: + case 210: + return textSpan(node.getChildAt(0), node.label); + case 207: + return spanInForStatement(node); case 208: + return textSpanEndingAtNextToken(node, node.expression); + case 209: return spanInInitializerOfForLike(node); - case 213: + case 214: return textSpanEndingAtNextToken(node, node.expression); case 249: case 250: return spanInNode(node.statements[0]); - case 216: + case 217: return spanInBlock(node.tryBlock); - case 215: + case 216: return textSpan(node, node.expression); - case 235: - return textSpan(node, node.expression); - case 229: - return textSpan(node, node.moduleReference); - case 230: - return textSpan(node, node.moduleSpecifier); case 236: + return textSpan(node, node.expression); + case 230: + return textSpan(node, node.moduleReference); + case 231: return textSpan(node, node.moduleSpecifier); - case 225: + case 237: + return textSpan(node, node.moduleSpecifier); + case 226: if (ts.getModuleInstanceState(node) !== 1) { return undefined; } - case 221: - case 224: - case 255: - case 169: - return textSpan(node); - case 212: - return spanInNode(node.statement); - case 143: - return spanInNodeArray(node.parent.decorators); - case 167: - case 168: - return spanInBindingPattern(node); case 222: + case 225: + case 255: + case 170: + return textSpan(node); + case 213: + return spanInNode(node.statement); + case 144: + return spanInNodeArray(node.parent.decorators); + case 168: + case 169: + return spanInBindingPattern(node); case 223: + case 224: return undefined; - case 23: + case 24: case 1: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile)); - case 24: - return spanInPreviousNode(node); - case 15: - return spanInOpenBraceToken(node); - case 16: - return spanInCloseBraceToken(node); - case 20: - return spanInCloseBracketToken(node); - case 17: - return spanInOpenParenToken(node); - case 18: - return spanInCloseParenToken(node); - case 54: - return spanInColonToken(node); - case 27: case 25: + return spanInPreviousNode(node); + case 16: + return spanInOpenBraceToken(node); + case 17: + return spanInCloseBraceToken(node); + case 21: + return spanInCloseBracketToken(node); + case 18: + return spanInOpenParenToken(node); + case 19: + return spanInCloseParenToken(node); + case 55: + return spanInColonToken(node); + case 28: + case 26: return spanInGreaterThanOrLessThanToken(node); - case 104: + case 105: return spanInWhileKeyword(node); - case 80: - case 72: - case 85: + case 81: + case 73: + case 86: return spanInNextNode(node); - case 138: + case 139: return spanInOfKeyword(node); default: if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(node); } - if ((node.kind === 69 || - node.kind == 191 || + if ((node.kind === 70 || + node.kind == 192 || node.kind === 253 || node.kind === 254) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { return textSpan(node); } - if (node.kind === 187) { + if (node.kind === 188) { var binaryExpression = node; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left); } - if (binaryExpression.operatorToken.kind === 56 && + if (binaryExpression.operatorToken.kind === 57 && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.parent)) { return textSpan(node); } - if (binaryExpression.operatorToken.kind === 24) { + if (binaryExpression.operatorToken.kind === 25) { return spanInNode(binaryExpression.left); } } if (ts.isPartOfExpression(node)) { switch (node.parent.kind) { - case 204: + case 205: return spanInPreviousNode(node); - case 143: + case 144: return spanInNode(node.parent); - case 206: - case 208: + case 207: + case 209: return textSpan(node); - case 187: - if (node.parent.operatorToken.kind === 24) { + case 188: + if (node.parent.operatorToken.kind === 25) { return textSpan(node); } break; - case 180: + case 181: if (node.parent.body === node) { return textSpan(node); } @@ -50387,14 +51721,14 @@ var ts; !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); } - if (node.parent.kind === 177 && node.parent.type === node) { + if (node.parent.kind === 178 && node.parent.type === node) { return spanInNextNode(node.parent.type); } if (ts.isFunctionLike(node.parent) && node.parent.type === node) { return spanInPreviousNode(node); } - if ((node.parent.kind === 218 || - node.parent.kind === 142)) { + if ((node.parent.kind === 219 || + node.parent.kind === 143)) { var paramOrVarDecl = node.parent; if (paramOrVarDecl.initializer === node || paramOrVarDecl.type === node || @@ -50402,7 +51736,7 @@ var ts; return spanInPreviousNode(node); } } - if (node.parent.kind === 187) { + if (node.parent.kind === 188) { var binaryExpression = node.parent; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left) && (binaryExpression.right === node || @@ -50423,7 +51757,7 @@ var ts; } } function spanInVariableDeclaration(variableDeclaration) { - if (variableDeclaration.parent.parent.kind === 207) { + if (variableDeclaration.parent.parent.kind === 208) { return spanInNode(variableDeclaration.parent.parent); } if (ts.isBindingPattern(variableDeclaration.name)) { @@ -50431,7 +51765,7 @@ var ts; } if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1) || - variableDeclaration.parent.parent.kind === 208) { + variableDeclaration.parent.parent.kind === 209) { return textSpanFromVariableDeclaration(variableDeclaration); } var declarations = variableDeclaration.parent.declarations; @@ -50463,7 +51797,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1) || - (functionDeclaration.parent.kind === 221 && functionDeclaration.kind !== 148); + (functionDeclaration.parent.kind === 222 && functionDeclaration.kind !== 149); } function spanInFunctionDeclaration(functionDeclaration) { if (!functionDeclaration.body) { @@ -50483,22 +51817,22 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 225: + case 226: if (ts.getModuleInstanceState(block.parent) !== 1) { return undefined; } - case 205: - case 203: - case 207: - return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); case 206: + case 204: case 208: + return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); + case 207: + case 209: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } return spanInNode(block.statements[0]); } function spanInInitializerOfForLike(forLikeStatement) { - if (forLikeStatement.initializer.kind === 219) { + if (forLikeStatement.initializer.kind === 220) { var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -50520,62 +51854,62 @@ var ts; } } function spanInBindingPattern(bindingPattern) { - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 193 ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 194 ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } - if (bindingPattern.parent.kind === 169) { + if (bindingPattern.parent.kind === 170) { return textSpan(bindingPattern.parent); } return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 168 && node.kind !== 167); - var elements = node.kind === 170 ? + ts.Debug.assert(node.kind !== 169 && node.kind !== 168); + var elements = node.kind === 171 ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 193 ? element : undefined; }); + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 194 ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } - return textSpan(node.parent.kind === 187 ? node.parent : node); + return textSpan(node.parent.kind === 188 ? node.parent : node); } function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 224: + case 225: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 221: + case 222: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 227: + case 228: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } return spanInNode(node.parent); } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 226: + case 227: if (ts.getModuleInstanceState(node.parent.parent) !== 1) { return undefined; } - case 224: - case 221: + case 225: + case 222: return textSpan(node); - case 199: + case 200: if (ts.isFunctionBlock(node.parent)) { return textSpan(node); } case 252: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 227: + case 228: var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); if (lastClause) { return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 167: + case 168: var bindingPattern = node.parent; return spanInNode(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); default: @@ -50588,7 +51922,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 168: + case 169: var bindingPattern = node.parent; return textSpan(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); default: @@ -50600,33 +51934,33 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 204 || - node.parent.kind === 174 || - node.parent.kind === 175) { + if (node.parent.kind === 205 || + node.parent.kind === 175 || + node.parent.kind === 176) { return spanInPreviousNode(node); } - if (node.parent.kind === 178) { + if (node.parent.kind === 179) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInCloseParenToken(node) { switch (node.parent.kind) { - case 179: - case 220: case 180: - case 147: - case 146: - case 149: - case 150: + case 221: + case 181: case 148: - case 205: - case 204: + case 147: + case 150: + case 151: + case 149: case 206: - case 208: - case 174: + case 205: + case 207: + case 209: case 175: - case 178: + case 176: + case 179: return spanInPreviousNode(node); default: return spanInNode(node.parent); @@ -50635,25 +51969,25 @@ var ts; function spanInColonToken(node) { if (ts.isFunctionLike(node.parent) || node.parent.kind === 253 || - node.parent.kind === 142) { + node.parent.kind === 143) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 177) { + if (node.parent.kind === 178) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 204) { + if (node.parent.kind === 205) { return textSpanEndingAtNextToken(node, node.parent.expression); } return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 208) { + if (node.parent.kind === 209) { return spanInNextNode(node); } return spanInNode(node.parent); @@ -50666,27 +52000,27 @@ var ts; var ts; (function (ts) { function createClassifier() { - var scanner = ts.createScanner(2, false); + var scanner = ts.createScanner(4, false); var noRegexTable = []; - noRegexTable[69] = true; + noRegexTable[70] = true; noRegexTable[9] = true; noRegexTable[8] = true; - noRegexTable[10] = true; - noRegexTable[97] = true; - noRegexTable[41] = true; + noRegexTable[11] = true; + noRegexTable[98] = true; noRegexTable[42] = true; - noRegexTable[18] = true; - noRegexTable[20] = true; - noRegexTable[16] = true; - noRegexTable[99] = true; - noRegexTable[84] = true; + noRegexTable[43] = true; + noRegexTable[19] = true; + noRegexTable[21] = true; + noRegexTable[17] = true; + noRegexTable[100] = true; + noRegexTable[85] = true; var templateStack = []; function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { - if (keyword2 === 123 || - keyword2 === 131 || - keyword2 === 121 || - keyword2 === 113) { + if (keyword2 === 124 || + keyword2 === 132 || + keyword2 === 122 || + keyword2 === 114) { return true; } return false; @@ -50769,7 +52103,7 @@ var ts; text = "}\n" + text; offset = 2; case 6: - templateStack.push(12); + templateStack.push(13); break; } scanner.setText(text); @@ -50781,55 +52115,55 @@ var ts; do { token = scanner.scan(); if (!ts.isTrivia(token)) { - if ((token === 39 || token === 61) && !noRegexTable[lastNonTriviaToken]) { - if (scanner.reScanSlashToken() === 10) { - token = 10; + if ((token === 40 || token === 62) && !noRegexTable[lastNonTriviaToken]) { + if (scanner.reScanSlashToken() === 11) { + token = 11; } } - else if (lastNonTriviaToken === 21 && isKeyword(token)) { - token = 69; + else if (lastNonTriviaToken === 22 && isKeyword(token)) { + token = 70; } else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { - token = 69; + token = 70; } - else if (lastNonTriviaToken === 69 && - token === 25) { + else if (lastNonTriviaToken === 70 && + token === 26) { angleBracketStack++; } - else if (token === 27 && angleBracketStack > 0) { + else if (token === 28 && angleBracketStack > 0) { angleBracketStack--; } - else if (token === 117 || - token === 132 || - token === 130 || - token === 120 || - token === 133) { + else if (token === 118 || + token === 133 || + token === 131 || + token === 121 || + token === 134) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { - token = 69; + token = 70; } } - else if (token === 12) { + else if (token === 13) { templateStack.push(token); } - else if (token === 15) { + else if (token === 16) { if (templateStack.length > 0) { templateStack.push(token); } } - else if (token === 16) { + else if (token === 17) { if (templateStack.length > 0) { var lastTemplateStackToken = ts.lastOrUndefined(templateStack); - if (lastTemplateStackToken === 12) { + if (lastTemplateStackToken === 13) { token = scanner.reScanTemplateToken(); - if (token === 14) { + if (token === 15) { templateStack.pop(); } else { - ts.Debug.assert(token === 13, "Should have been a template middle. Was " + token); + ts.Debug.assert(token === 14, "Should have been a template middle. Was " + token); } } else { - ts.Debug.assert(lastTemplateStackToken === 15, "Should have been an open brace. Was: " + token); + ts.Debug.assert(lastTemplateStackToken === 16, "Should have been an open brace. Was: " + token); templateStack.pop(); } } @@ -50867,10 +52201,10 @@ var ts; } else if (ts.isTemplateLiteralKind(token)) { if (scanner.isUnterminated()) { - if (token === 14) { + if (token === 15) { result.endOfLineState = 5; } - else if (token === 11) { + else if (token === 12) { result.endOfLineState = 4; } else { @@ -50878,7 +52212,7 @@ var ts; } } } - else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 12) { + else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 13) { result.endOfLineState = 6; } } @@ -50902,43 +52236,43 @@ var ts; } function isBinaryExpressionOperatorToken(token) { switch (token) { - case 37: - case 39: + case 38: case 40: - case 35: + case 41: case 36: - case 43: + case 37: case 44: case 45: - case 25: - case 27: + case 46: + case 26: case 28: case 29: - case 91: - case 90: - case 116: case 30: + case 92: + case 91: + case 117: case 31: case 32: case 33: - case 46: - case 48: + case 34: case 47: - case 51: + case 49: + case 48: case 52: - case 67: - case 66: + case 53: case 68: - case 63: + case 67: + case 69: case 64: case 65: - case 57: + case 66: case 58: case 59: - case 61: + case 60: case 62: - case 56: - case 24: + case 63: + case 57: + case 25: return true; default: return false; @@ -50946,19 +52280,19 @@ var ts; } function isPrefixUnaryExpressionOperatorToken(token) { switch (token) { - case 35: case 36: + case 37: + case 51: case 50: - case 49: - case 41: case 42: + case 43: return true; default: return false; } } function isKeyword(token) { - return token >= 70 && token <= 138; + return token >= 71 && token <= 139; } function classFromKind(token) { if (isKeyword(token)) { @@ -50967,7 +52301,7 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5; } - else if (token >= 15 && token <= 68) { + else if (token >= 16 && token <= 69) { return 10; } switch (token) { @@ -50975,7 +52309,7 @@ var ts; return 4; case 9: return 6; - case 10: + case 11: return 7; case 7: case 3: @@ -50984,7 +52318,7 @@ var ts; case 5: case 4: return 8; - case 69: + case 70: default: if (ts.isTemplateLiteralKind(token)) { return 6; @@ -51004,10 +52338,10 @@ var ts; ts.getSemanticClassifications = getSemanticClassifications; function checkForClassificationCancellation(cancellationToken, kind) { switch (kind) { - case 225: - case 221: + case 226: case 222: - case 220: + case 223: + case 221: cancellationToken.throwIfCancellationRequested(); } } @@ -51051,7 +52385,7 @@ var ts; return undefined; function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 225 && + return declaration.kind === 226 && ts.getModuleInstanceState(declaration) === 1; }); } @@ -51060,7 +52394,7 @@ var ts; if (node && ts.textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { var kind = node.kind; checkForClassificationCancellation(cancellationToken, kind); - if (kind === 69 && !ts.nodeIsMissing(node)) { + if (kind === 70 && !ts.nodeIsMissing(node)) { var identifier = node; if (classifiableNames[identifier.text]) { var symbol = typeChecker.getSymbolAtLocation(node); @@ -51123,8 +52457,8 @@ var ts; function getEncodedSyntacticClassifications(cancellationToken, sourceFile, span) { var spanStart = span.start; var spanLength = span.length; - var triviaScanner = ts.createScanner(2, false, sourceFile.languageVariant, sourceFile.text); - var mergeConflictScanner = ts.createScanner(2, false, sourceFile.languageVariant, sourceFile.text); + var triviaScanner = ts.createScanner(4, false, sourceFile.languageVariant, sourceFile.text); + var mergeConflictScanner = ts.createScanner(4, false, sourceFile.languageVariant, sourceFile.text); var result = []; processElement(sourceFile); return { spans: result, endOfLineState: 0 }; @@ -51266,10 +52600,10 @@ var ts; return true; } var classifiedElementName = tryClassifyJsxElementName(node); - if (!ts.isToken(node) && node.kind !== 244 && classifiedElementName === undefined) { + if (!ts.isToken(node) && node.kind !== 10 && classifiedElementName === undefined) { return false; } - var tokenStart = node.kind === 244 ? node.pos : classifyLeadingTriviaAndGetTokenStart(node); + var tokenStart = node.kind === 10 ? node.pos : classifyLeadingTriviaAndGetTokenStart(node); var tokenWidth = node.end - tokenStart; ts.Debug.assert(tokenWidth >= 0); if (tokenWidth > 0) { @@ -51282,7 +52616,7 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 243: + case 244: if (token.parent.tagName === token) { return 19; } @@ -51292,7 +52626,7 @@ var ts; return 20; } break; - case 242: + case 243: if (token.parent.tagName === token) { return 21; } @@ -51309,25 +52643,25 @@ var ts; if (ts.isKeyword(tokenKind)) { return 3; } - if (tokenKind === 25 || tokenKind === 27) { + if (tokenKind === 26 || tokenKind === 28) { if (token && ts.getTypeArgumentOrTypeParameterList(token.parent)) { return 10; } } if (ts.isPunctuation(tokenKind)) { if (token) { - if (tokenKind === 56) { - if (token.parent.kind === 218 || - token.parent.kind === 145 || - token.parent.kind === 142 || + if (tokenKind === 57) { + if (token.parent.kind === 219 || + token.parent.kind === 146 || + token.parent.kind === 143 || token.parent.kind === 246) { return 5; } } - if (token.parent.kind === 187 || - token.parent.kind === 185 || + if (token.parent.kind === 188 || token.parent.kind === 186 || - token.parent.kind === 188) { + token.parent.kind === 187 || + token.parent.kind === 189) { return 5; } } @@ -51339,44 +52673,44 @@ var ts; else if (tokenKind === 9) { return token.parent.kind === 246 ? 24 : 6; } - else if (tokenKind === 10) { + else if (tokenKind === 11) { return 6; } else if (ts.isTemplateLiteralKind(tokenKind)) { return 6; } - else if (tokenKind === 244) { + else if (tokenKind === 10) { return 23; } - else if (tokenKind === 69) { + else if (tokenKind === 70) { if (token) { switch (token.parent.kind) { - case 221: + case 222: if (token.parent.name === token) { return 11; } return; - case 141: + case 142: if (token.parent.name === token) { return 15; } return; - case 222: + case 223: if (token.parent.name === token) { return 13; } return; - case 224: + case 225: if (token.parent.name === token) { return 12; } return; - case 225: + case 226: if (token.parent.name === token) { return 14; } return; - case 142: + case 143: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 : 17; } @@ -51437,7 +52771,7 @@ var ts; name: tagName.text, kind: undefined, kindModifiers: undefined, - sortText: "0" + sortText: "0", }); } else { @@ -51453,13 +52787,13 @@ var ts; function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames) { var entries = []; var nameTable = ts.getNameTable(sourceFile); - for (var name_47 in nameTable) { - if (nameTable[name_47] === position) { + for (var name_46 in nameTable) { + if (nameTable[name_46] === position) { continue; } - if (!uniqueNames[name_47]) { - uniqueNames[name_47] = name_47; - var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_47), compilerOptions.target, true); + if (!uniqueNames[name_46]) { + uniqueNames[name_46] = name_46; + var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_46), compilerOptions.target, true); if (displayName) { var entry = { name: displayName, @@ -51482,7 +52816,7 @@ var ts; name: displayName, kind: ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location), kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), - sortText: "0" + sortText: "0", }; } function getCompletionEntriesFromSymbols(symbols, entries, location, performCharacterChecks) { @@ -51510,20 +52844,20 @@ var ts; return undefined; } if (node.parent.kind === 253 && - node.parent.parent.kind === 171 && + node.parent.parent.kind === 172 && node.parent.name === node) { return getStringLiteralCompletionEntriesFromPropertyAssignment(node.parent); } else if (ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node) { return getStringLiteralCompletionEntriesFromElementAccess(node.parent); } - else if (node.parent.kind === 230 || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { + else if (node.parent.kind === 231 || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { return getStringLiteralCompletionEntriesFromModuleNames(node); } else { var argumentInfo = ts.SignatureHelp.getContainingArgumentInfo(node, position, sourceFile); if (argumentInfo) { - return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo, node); + return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo); } return getStringLiteralCompletionEntriesFromContextualType(node); } @@ -51538,7 +52872,7 @@ var ts; } } } - function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo, location) { + function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo) { var candidates = []; var entries = []; typeChecker.getResolvedSignature(argumentInfo.invocation, candidates); @@ -51848,7 +53182,7 @@ var ts; if (typeRoots) { for (var _b = 0, typeRoots_2 = typeRoots; _b < typeRoots_2.length; _b++) { var root = typeRoots_2[_b]; - getCompletionEntriesFromDirectories(host, options, root, span, result); + getCompletionEntriesFromDirectories(host, root, span, result); } } } @@ -51856,12 +53190,12 @@ var ts; for (var _c = 0, _d = findPackageJsons(scriptPath); _c < _d.length; _c++) { var packageJson = _d[_c]; var typesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules/@types"); - getCompletionEntriesFromDirectories(host, options, typesDir, span, result); + getCompletionEntriesFromDirectories(host, typesDir, span, result); } } return result; } - function getCompletionEntriesFromDirectories(host, options, directory, span, result) { + function getCompletionEntriesFromDirectories(host, directory, span, result) { if (host.getDirectories && tryDirectoryExists(host, directory)) { var directories = tryGetDirectories(host, directory); if (directories) { @@ -52055,12 +53389,12 @@ var ts; return undefined; } var parent_17 = contextToken.parent, kind = contextToken.kind; - if (kind === 21) { - if (parent_17.kind === 172) { + if (kind === 22) { + if (parent_17.kind === 173) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_17.kind === 139) { + else if (parent_17.kind === 140) { node = contextToken.parent.left; isRightOfDot = true; } @@ -52069,11 +53403,11 @@ var ts; } } else if (sourceFile.languageVariant === 1) { - if (kind === 25) { + if (kind === 26) { isRightOfOpenTag = true; location = contextToken; } - else if (kind === 39 && contextToken.parent.kind === 245) { + else if (kind === 40 && contextToken.parent.kind === 245) { isStartingCloseTag = true; location = contextToken; } @@ -52111,7 +53445,6 @@ var ts; if (!tryGetGlobalSymbols()) { return undefined; } - isGlobalCompletion = true; } log("getCompletionData: Semantic work: " + (ts.timestamp() - semanticStart)); return { symbols: symbols, isGlobalCompletion: isGlobalCompletion, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName: isJsDocTagName }; @@ -52119,7 +53452,7 @@ var ts; isGlobalCompletion = false; isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 69 || node.kind === 139 || node.kind === 172) { + if (node.kind === 70 || node.kind === 140 || node.kind === 173) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol && symbol.flags & 8388608) { symbol = typeChecker.getAliasedSymbol(symbol); @@ -52165,9 +53498,8 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType = void 0; - if ((jsxContainer.kind === 242) || (jsxContainer.kind === 243)) { + if ((jsxContainer.kind === 243) || (jsxContainer.kind === 244)) { attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); - isGlobalCompletion = false; if (attrsType) { symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); isMemberCompletion = true; @@ -52185,6 +53517,13 @@ var ts; previousToken.getStart() : position; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; + if (scopeNode) { + isGlobalCompletion = + scopeNode.kind === 256 || + scopeNode.kind === 190 || + scopeNode.kind === 248 || + ts.isStatement(scopeNode); + } var symbolMeanings = 793064 | 107455 | 1920 | 8388608; symbols = typeChecker.getSymbolsInScope(scopeNode, symbolMeanings); return true; @@ -52206,15 +53545,15 @@ var ts; return result; } function isInJsxText(contextToken) { - if (contextToken.kind === 244) { + if (contextToken.kind === 10) { return true; } - if (contextToken.kind === 27 && contextToken.parent) { - if (contextToken.parent.kind === 243) { + if (contextToken.kind === 28 && contextToken.parent) { + if (contextToken.parent.kind === 244) { return true; } - if (contextToken.parent.kind === 245 || contextToken.parent.kind === 242) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 241; + if (contextToken.parent.kind === 245 || contextToken.parent.kind === 243) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 242; } } return false; @@ -52223,41 +53562,41 @@ var ts; if (previousToken) { var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { - case 24: - return containingNodeKind === 174 - || containingNodeKind === 148 - || containingNodeKind === 175 - || containingNodeKind === 170 - || containingNodeKind === 187 - || containingNodeKind === 156; - case 17: - return containingNodeKind === 174 - || containingNodeKind === 148 - || containingNodeKind === 175 - || containingNodeKind === 178 - || containingNodeKind === 164; - case 19: - return containingNodeKind === 170 - || containingNodeKind === 153 - || containingNodeKind === 140; - case 125: + case 25: + return containingNodeKind === 175 + || containingNodeKind === 149 + || containingNodeKind === 176 + || containingNodeKind === 171 + || containingNodeKind === 188 + || containingNodeKind === 157; + case 18: + return containingNodeKind === 175 + || containingNodeKind === 149 + || containingNodeKind === 176 + || containingNodeKind === 179 + || containingNodeKind === 165; + case 20: + return containingNodeKind === 171 + || containingNodeKind === 154 + || containingNodeKind === 141; case 126: + case 127: return true; - case 21: - return containingNodeKind === 225; - case 15: - return containingNodeKind === 221; - case 56: - return containingNodeKind === 218 - || containingNodeKind === 187; - case 12: - return containingNodeKind === 189; + case 22: + return containingNodeKind === 226; + case 16: + return containingNodeKind === 222; + case 57: + return containingNodeKind === 219 + || containingNodeKind === 188; case 13: - return containingNodeKind === 197; - case 112: - case 110: + return containingNodeKind === 190; + case 14: + return containingNodeKind === 198; + case 113: case 111: - return containingNodeKind === 145; + case 112: + return containingNodeKind === 146; } switch (previousToken.getText()) { case "public": @@ -52270,7 +53609,7 @@ var ts; } function isInStringOrRegularExpressionOrTemplateLiteral(contextToken) { if (contextToken.kind === 9 - || contextToken.kind === 10 + || contextToken.kind === 11 || ts.isTemplateLiteralKind(contextToken.kind)) { var start_3 = contextToken.getStart(); var end = contextToken.getEnd(); @@ -52279,7 +53618,7 @@ var ts; } if (position === end) { return !!contextToken.isUnterminated - || contextToken.kind === 10; + || contextToken.kind === 11; } } return false; @@ -52288,22 +53627,22 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 171) { + if (objectLikeContainer.kind === 172) { isNewIdentifierLocation = true; typeForObject = typeChecker.getContextualType(objectLikeContainer); typeForObject = typeForObject && typeForObject.getNonNullableType(); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 167) { + else if (objectLikeContainer.kind === 168) { isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); if (ts.isVariableLike(rootDeclaration)) { var canGetType = !!(rootDeclaration.initializer || rootDeclaration.type); - if (!canGetType && rootDeclaration.kind === 142) { + if (!canGetType && rootDeclaration.kind === 143) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 147 || rootDeclaration.parent.kind === 150) { + else if (rootDeclaration.parent.kind === 148 || rootDeclaration.parent.kind === 151) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -52329,9 +53668,9 @@ var ts; return true; } function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 233 ? - 230 : - 236; + var declarationKind = namedImportsOrExports.kind === 234 ? + 231 : + 237; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -52350,10 +53689,10 @@ var ts; function tryGetObjectLikeCompletionContainer(contextToken) { if (contextToken) { switch (contextToken.kind) { - case 15: - case 24: + case 16: + case 25: var parent_18 = contextToken.parent; - if (parent_18 && (parent_18.kind === 171 || parent_18.kind === 167)) { + if (parent_18 && (parent_18.kind === 172 || parent_18.kind === 168)) { return parent_18; } break; @@ -52364,11 +53703,11 @@ var ts; function tryGetNamedImportsOrExportsForCompletion(contextToken) { if (contextToken) { switch (contextToken.kind) { - case 15: - case 24: + case 16: + case 25: switch (contextToken.parent.kind) { - case 233: - case 237: + case 234: + case 238: return contextToken.parent; } } @@ -52379,12 +53718,12 @@ var ts; if (contextToken) { var parent_19 = contextToken.parent; switch (contextToken.kind) { - case 26: - case 39: - case 69: + case 27: + case 40: + case 70: case 246: case 247: - if (parent_19 && (parent_19.kind === 242 || parent_19.kind === 243)) { + if (parent_19 && (parent_19.kind === 243 || parent_19.kind === 244)) { return parent_19; } else if (parent_19.kind === 246) { @@ -52396,7 +53735,7 @@ var ts; return parent_19.parent; } break; - case 16: + case 17: if (parent_19 && parent_19.kind === 248 && parent_19.parent && @@ -52413,16 +53752,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 179: case 180: - case 220: + case 181: + case 221: + case 148: case 147: - case 146: - case 149: case 150: case 151: case 152: case 153: + case 154: return true; } return false; @@ -52430,67 +53769,67 @@ var ts; function isSolelyIdentifierDefinitionLocation(contextToken) { var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { - case 24: - return containingNodeKind === 218 || - containingNodeKind === 219 || - containingNodeKind === 200 || - containingNodeKind === 224 || + case 25: + return containingNodeKind === 219 || + containingNodeKind === 220 || + containingNodeKind === 201 || + containingNodeKind === 225 || isFunction(containingNodeKind) || - containingNodeKind === 221 || - containingNodeKind === 192 || containingNodeKind === 222 || - containingNodeKind === 168 || - containingNodeKind === 223; - case 21: - return containingNodeKind === 168; - case 54: + containingNodeKind === 193 || + containingNodeKind === 223 || + containingNodeKind === 169 || + containingNodeKind === 224; + case 22: return containingNodeKind === 169; - case 19: - return containingNodeKind === 168; - case 17: + case 55: + return containingNodeKind === 170; + case 20: + return containingNodeKind === 169; + case 18: return containingNodeKind === 252 || isFunction(containingNodeKind); - case 15: - return containingNodeKind === 224 || - containingNodeKind === 222 || - containingNodeKind === 159; - case 23: - return containingNodeKind === 144 && - contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 222 || - contextToken.parent.parent.kind === 159); - case 25: - return containingNodeKind === 221 || - containingNodeKind === 192 || - containingNodeKind === 222 || + case 16: + return containingNodeKind === 225 || containingNodeKind === 223 || + containingNodeKind === 160; + case 24: + return containingNodeKind === 145 && + contextToken.parent && contextToken.parent.parent && + (contextToken.parent.parent.kind === 223 || + contextToken.parent.parent.kind === 160); + case 26: + return containingNodeKind === 222 || + containingNodeKind === 193 || + containingNodeKind === 223 || + containingNodeKind === 224 || isFunction(containingNodeKind); - case 113: - return containingNodeKind === 145; - case 22: - return containingNodeKind === 142 || - (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 168); - case 112: - case 110: - case 111: - return containingNodeKind === 142; - case 116: - return containingNodeKind === 234 || - containingNodeKind === 238 || - containingNodeKind === 232; - case 73: - case 81: - case 107: - case 87: - case 102: - case 123: - case 131: - case 89: - case 108: - case 74: case 114: - case 134: + return containingNodeKind === 146; + case 23: + return containingNodeKind === 143 || + (contextToken.parent && contextToken.parent.parent && + contextToken.parent.parent.kind === 169); + case 113: + case 111: + case 112: + return containingNodeKind === 143; + case 117: + return containingNodeKind === 235 || + containingNodeKind === 239 || + containingNodeKind === 233; + case 74: + case 82: + case 108: + case 88: + case 103: + case 124: + case 132: + case 90: + case 109: + case 75: + case 115: + case 135: return true; } switch (contextToken.getText()) { @@ -52527,8 +53866,8 @@ var ts; if (element.getStart() <= position && position <= element.getEnd()) { continue; } - var name_48 = element.propertyName || element.name; - existingImportsOrExports[name_48.text] = true; + var name_47 = element.propertyName || element.name; + existingImportsOrExports[name_47.text] = true; } if (!ts.someProperties(existingImportsOrExports)) { return ts.filter(exportsOfModule, function (e) { return e.name !== "default"; }); @@ -52544,16 +53883,16 @@ var ts; var m = existingMembers_1[_i]; if (m.kind !== 253 && m.kind !== 254 && - m.kind !== 169 && - m.kind !== 147) { + m.kind !== 170 && + m.kind !== 148) { continue; } if (m.getStart() <= position && position <= m.getEnd()) { continue; } var existingName = void 0; - if (m.kind === 169 && m.propertyName) { - if (m.propertyName.kind === 69) { + if (m.kind === 170 && m.propertyName) { + if (m.propertyName.kind === 70) { existingName = m.propertyName.text; } } @@ -52604,7 +53943,7 @@ var ts; return name; } var keywordCompletions = []; - for (var i = 70; i <= 138; i++) { + for (var i = 71; i <= 139; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ts.ScriptElementKind.keyword, @@ -52666,10 +54005,10 @@ var ts; }; } function getSemanticDocumentHighlights(node) { - if (node.kind === 69 || - node.kind === 97 || - node.kind === 165 || - node.kind === 95 || + if (node.kind === 70 || + node.kind === 98 || + node.kind === 166 || + node.kind === 96 || node.kind === 9 || ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { var referencedSymbols = ts.FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFilesToSearch, false, false, false); @@ -52718,77 +54057,77 @@ var ts; function getHighlightSpans(node) { if (node) { switch (node.kind) { - case 88: - case 80: - if (hasKind(node.parent, 203)) { + case 89: + case 81: + if (hasKind(node.parent, 204)) { return getIfElseOccurrences(node.parent); } break; - case 94: - if (hasKind(node.parent, 211)) { + case 95: + if (hasKind(node.parent, 212)) { return getReturnOccurrences(node.parent); } break; - case 98: - if (hasKind(node.parent, 215)) { + case 99: + if (hasKind(node.parent, 216)) { return getThrowOccurrences(node.parent); } break; - case 72: - if (hasKind(parent(parent(node)), 216)) { + case 73: + if (hasKind(parent(parent(node)), 217)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; - case 100: - case 85: - if (hasKind(parent(node), 216)) { + case 101: + case 86: + if (hasKind(parent(node), 217)) { return getTryCatchFinallyOccurrences(node.parent); } break; - case 96: - if (hasKind(node.parent, 213)) { + case 97: + if (hasKind(node.parent, 214)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; - case 71: - case 77: - if (hasKind(parent(parent(parent(node))), 213)) { + case 72: + case 78: + if (hasKind(parent(parent(parent(node))), 214)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; - case 70: - case 75: - if (hasKind(node.parent, 210) || hasKind(node.parent, 209)) { + case 71: + case 76: + if (hasKind(node.parent, 211) || hasKind(node.parent, 210)) { return getBreakOrContinueStatementOccurrences(node.parent); } break; - case 86: - if (hasKind(node.parent, 206) || - hasKind(node.parent, 207) || - hasKind(node.parent, 208)) { + case 87: + if (hasKind(node.parent, 207) || + hasKind(node.parent, 208) || + hasKind(node.parent, 209)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 104: - case 79: - if (hasKind(node.parent, 205) || hasKind(node.parent, 204)) { + case 105: + case 80: + if (hasKind(node.parent, 206) || hasKind(node.parent, 205)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 121: - if (hasKind(node.parent, 148)) { + case 122: + if (hasKind(node.parent, 149)) { return getConstructorOccurrences(node.parent); } break; - case 123: - case 131: - if (hasKind(node.parent, 149) || hasKind(node.parent, 150)) { + case 124: + case 132: + if (hasKind(node.parent, 150) || hasKind(node.parent, 151)) { return getGetAndSetOccurrences(node.parent); } break; default: if (ts.isModifierKind(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 200)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 201)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -52800,10 +54139,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 215) { + if (node.kind === 216) { statementAccumulator.push(node); } - else if (node.kind === 216) { + else if (node.kind === 217) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -52827,7 +54166,7 @@ var ts; if (ts.isFunctionBlock(parent_20) || parent_20.kind === 256) { return parent_20; } - if (parent_20.kind === 216) { + if (parent_20.kind === 217) { var tryStatement = parent_20; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; @@ -52842,7 +54181,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 210 || node.kind === 209) { + if (node.kind === 211 || node.kind === 210) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -52857,15 +54196,15 @@ var ts; function getBreakOrContinueOwner(statement) { for (var node_1 = statement.parent; node_1; node_1 = node_1.parent) { switch (node_1.kind) { - case 213: - if (statement.kind === 209) { + case 214: + if (statement.kind === 210) { continue; } - case 206: case 207: case 208: + case 209: + case 206: case 205: - case 204: if (!statement.label || isLabeledBy(node_1, statement.label.text)) { return node_1; } @@ -52882,24 +54221,24 @@ var ts; function getModifierOccurrences(modifier, declaration) { var container = declaration.parent; if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 221 || - container.kind === 192 || - (declaration.kind === 142 && hasKind(container, 148)))) { + if (!(container.kind === 222 || + container.kind === 193 || + (declaration.kind === 143 && hasKind(container, 149)))) { return undefined; } } - else if (modifier === 113) { - if (!(container.kind === 221 || container.kind === 192)) { + else if (modifier === 114) { + if (!(container.kind === 222 || container.kind === 193)) { return undefined; } } - else if (modifier === 82 || modifier === 122) { - if (!(container.kind === 226 || container.kind === 256)) { + else if (modifier === 83 || modifier === 123) { + if (!(container.kind === 227 || container.kind === 256)) { return undefined; } } - else if (modifier === 115) { - if (!(container.kind === 221 || declaration.kind === 221)) { + else if (modifier === 116) { + if (!(container.kind === 222 || declaration.kind === 222)) { return undefined; } } @@ -52910,7 +54249,7 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 226: + case 227: case 256: if (modifierFlag & 128) { nodes = declaration.members.concat(declaration); @@ -52919,15 +54258,15 @@ var ts; nodes = container.statements; } break; - case 148: + case 149: nodes = container.parameters.concat(container.parent.members); break; - case 221: - case 192: + case 222: + case 193: nodes = container.members; if (modifierFlag & 28) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 148 && member; + return member.kind === 149 && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -52948,19 +54287,19 @@ var ts; return ts.map(keywords, getHighlightSpanForNode); function getFlagFromModifier(modifier) { switch (modifier) { - case 112: - return 4; - case 110: - return 8; - case 111: - return 16; case 113: + return 4; + case 111: + return 8; + case 112: + return 16; + case 114: return 32; - case 82: + case 83: return 1; - case 122: + case 123: return 2; - case 115: + case 116: return 128; default: ts.Debug.fail(); @@ -52980,13 +54319,13 @@ var ts; } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 149); tryPushAccessorKeyword(accessorDeclaration.symbol, 150); + tryPushAccessorKeyword(accessorDeclaration.symbol, 151); 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, 123, 131); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 124, 132); }); } } } @@ -52995,18 +54334,18 @@ var ts; var keywords = []; ts.forEach(declarations, function (declaration) { ts.forEach(declaration.getChildren(), function (token) { - return pushKeywordIf(keywords, token, 121); + return pushKeywordIf(keywords, token, 122); }); }); return ts.map(keywords, getHighlightSpanForNode); } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 86, 104, 79)) { - if (loopNode.kind === 204) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 87, 105, 80)) { + if (loopNode.kind === 205) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 104)) { + if (pushKeywordIf(keywords, loopTokens[i], 105)) { break; } } @@ -53015,7 +54354,7 @@ var ts; var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 70, 75); + pushKeywordIf(keywords, statement.getFirstToken(), 71, 76); } }); return ts.map(keywords, getHighlightSpanForNode); @@ -53024,13 +54363,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 206: case 207: case 208: - case 204: + case 209: case 205: + case 206: return getLoopBreakContinueOccurrences(owner); - case 213: + case 214: return getSwitchCaseDefaultOccurrences(owner); } } @@ -53038,13 +54377,13 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 96); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 97); ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 71, 77); + pushKeywordIf(keywords, clause.getFirstToken(), 72, 78); var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 70); + pushKeywordIf(keywords, statement.getFirstToken(), 71); } }); }); @@ -53052,13 +54391,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 100); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 101); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 72); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 73); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 85, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 85); + var finallyKeyword = ts.findChildOfKind(tryStatement, 86, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 86); } return ts.map(keywords, getHighlightSpanForNode); } @@ -53069,50 +54408,50 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 98); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 99); }); if (ts.isFunctionBlock(owner)) { ts.forEachReturnStatement(owner, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 94); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 95); }); } return ts.map(keywords, getHighlightSpanForNode); } function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); - if (!(func && hasKind(func.body, 199))) { + if (!(func && hasKind(func.body, 200))) { return undefined; } var keywords = []; ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 94); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 95); }); ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 98); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 99); }); return ts.map(keywords, getHighlightSpanForNode); } function getIfElseOccurrences(ifStatement) { var keywords = []; - while (hasKind(ifStatement.parent, 203) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 204) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } while (ifStatement) { var children = ifStatement.getChildren(); - pushKeywordIf(keywords, children[0], 88); + pushKeywordIf(keywords, children[0], 89); for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 80)) { + if (pushKeywordIf(keywords, children[i], 81)) { break; } } - if (!hasKind(ifStatement.elseStatement, 203)) { + if (!hasKind(ifStatement.elseStatement, 204)) { break; } ifStatement = ifStatement.elseStatement; } var result = []; for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 80 && i < keywords.length - 1) { + if (keywords[i].kind === 81 && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; var shouldCombindElseAndIf = true; @@ -53140,7 +54479,7 @@ var ts; } DocumentHighlights.getDocumentHighlights = getDocumentHighlights; function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 214; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 215; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -53265,9 +54604,9 @@ var ts; if (!ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { break; } - case 69: - case 97: - case 121: + case 70: + case 98: + case 122: case 9: return getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, false); } @@ -53288,7 +54627,7 @@ var ts; if (ts.isThis(node)) { return getReferencesForThisKeyword(node, sourceFiles); } - if (node.kind === 95) { + if (node.kind === 96) { return getReferencesForSuperKeyword(node); } } @@ -53313,7 +54652,7 @@ var ts; getReferencesInNode(scope, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); } else { - var internedName = getInternedName(symbol, node, declarations); + var internedName = getInternedName(symbol, node); for (var _i = 0, sourceFiles_8 = sourceFiles; _i < sourceFiles_8.length; _i++) { var sourceFile = sourceFiles_8[_i]; cancellationToken.throwIfCancellationRequested(); @@ -53344,16 +54683,16 @@ var ts; } function getAliasSymbolForPropertyNameSymbol(symbol, location) { if (symbol.flags & 8388608) { - var defaultImport = ts.getDeclarationOfKind(symbol, 231); + var defaultImport = ts.getDeclarationOfKind(symbol, 232); if (defaultImport) { return typeChecker.getAliasedSymbol(symbol); } - var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 234 || - declaration.kind === 238) ? declaration : undefined; }); + var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 235 || + declaration.kind === 239) ? declaration : undefined; }); if (importOrExportSpecifier && (!importOrExportSpecifier.propertyName || importOrExportSpecifier.propertyName === location)) { - return importOrExportSpecifier.kind === 234 ? + return importOrExportSpecifier.kind === 235 ? typeChecker.getAliasedSymbol(symbol) : typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); } @@ -53368,20 +54707,20 @@ var ts; typeChecker.getPropertySymbolOfDestructuringAssignment(location); } function isObjectBindingPatternElementWithoutPropertyName(symbol) { - var bindingElement = ts.getDeclarationOfKind(symbol, 169); + var bindingElement = ts.getDeclarationOfKind(symbol, 170); return bindingElement && - bindingElement.parent.kind === 167 && + bindingElement.parent.kind === 168 && !bindingElement.propertyName; } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol) { if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { - var bindingElement = ts.getDeclarationOfKind(symbol, 169); + var bindingElement = ts.getDeclarationOfKind(symbol, 170); var typeOfPattern = typeChecker.getTypeAtLocation(bindingElement.parent); return typeOfPattern && typeChecker.getPropertyOfType(typeOfPattern, bindingElement.name.text); } return undefined; } - function getInternedName(symbol, location, declarations) { + function getInternedName(symbol, location) { if (ts.isImportOrExportSpecifierName(location)) { return location.getText(); } @@ -53391,13 +54730,13 @@ var ts; } function getSymbolScope(symbol) { var valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 179 || valueDeclaration.kind === 192)) { + if (valueDeclaration && (valueDeclaration.kind === 180 || valueDeclaration.kind === 193)) { return valueDeclaration; } if (symbol.flags & (4 | 8192)) { var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (ts.getModifierFlags(d) & 8) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 221); + return ts.getAncestor(privateDeclaration, 222); } } if (symbol.flags & 8388608) { @@ -53443,8 +54782,8 @@ var ts; if (position > end) break; var endPosition = position + symbolNameLength; - if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 2)) && - (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 2))) { + if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 4)) && + (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 4))) { positions.push(position); } position = text.indexOf(symbolName, position + symbolNameLength + 1); @@ -53481,7 +54820,7 @@ var ts; function isValidReferencePosition(node, searchSymbolName) { if (node) { switch (node.kind) { - case 69: + case 70: return node.getWidth() === searchSymbolName.length; case 9: if (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || @@ -53531,14 +54870,14 @@ var ts; if (referenceSymbol) { var referenceSymbolDeclaration = referenceSymbol.valueDeclaration; var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); - var relatedSymbol = getRelatedSymbol(searchSymbols_1, referenceSymbol, referenceLocation, searchLocation.kind === 121, parents, inheritsFromCache); + var relatedSymbol = getRelatedSymbol(searchSymbols_1, referenceSymbol, referenceLocation, searchLocation.kind === 122, parents, inheritsFromCache); if (relatedSymbol) { addReferenceToRelatedSymbol(referenceLocation, relatedSymbol); } else if (!(referenceSymbol.flags & 67108864) && searchSymbols_1.indexOf(shorthandValueSymbol) >= 0) { addReferenceToRelatedSymbol(referenceSymbolDeclaration.name, shorthandValueSymbol); } - else if (searchLocation.kind === 121) { + else if (searchLocation.kind === 122) { findAdditionalConstructorReferences(referenceSymbol, referenceLocation); } } @@ -53588,17 +54927,17 @@ var ts; var result = []; for (var _i = 0, _a = classSymbol.members["__constructor"].declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 148); + ts.Debug.assert(decl.kind === 149); var ctrKeyword = decl.getChildAt(0); - ts.Debug.assert(ctrKeyword.kind === 121); + ts.Debug.assert(ctrKeyword.kind === 122); result.push(ctrKeyword); } ts.forEachProperty(classSymbol.exports, function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 147) { + if (decl && decl.kind === 148) { var body = decl.body; if (body) { - forEachDescendantOfKind(body, 97, function (thisKeyword) { + forEachDescendantOfKind(body, 98, function (thisKeyword) { if (ts.isNewExpressionTarget(thisKeyword)) { result.push(thisKeyword); } @@ -53617,10 +54956,10 @@ var ts; var result = []; for (var _i = 0, _a = ctr.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 148); + ts.Debug.assert(decl.kind === 149); var body = decl.body; if (body) { - forEachDescendantOfKind(body, 95, function (node) { + forEachDescendantOfKind(body, 96, function (node) { if (ts.isCallExpressionTarget(node)) { result.push(node); } @@ -53657,7 +54996,7 @@ var ts; if (ts.isDeclarationName(refNode) && isImplementation(refNode.parent)) { result.push(getReferenceEntryFromNode(refNode.parent)); } - else if (refNode.kind === 69) { + else if (refNode.kind === 70) { if (refNode.parent.kind === 254) { getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); } @@ -53673,7 +55012,7 @@ var ts; maybeAdd(getReferenceEntryFromNode(parent_21.initializer)); } else if (ts.isFunctionLike(parent_21) && parent_21.type === containingTypeReference && parent_21.body) { - if (parent_21.body.kind === 199) { + if (parent_21.body.kind === 200) { ts.forEachReturnStatement(parent_21.body, function (returnStatement) { if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); @@ -53720,26 +55059,26 @@ var ts; } function getContainingClassIfInHeritageClause(node) { if (node && node.parent) { - if (node.kind === 194 + if (node.kind === 195 && node.parent.kind === 251 && ts.isClassLike(node.parent.parent)) { return node.parent.parent; } - else if (node.kind === 69 || node.kind === 172) { + else if (node.kind === 70 || node.kind === 173) { return getContainingClassIfInHeritageClause(node.parent); } } return undefined; } function isImplementationExpression(node) { - if (node.kind === 178) { + if (node.kind === 179) { return isImplementationExpression(node.expression); } - return node.kind === 180 || - node.kind === 179 || - node.kind === 171 || - node.kind === 192 || - node.kind === 170; + return node.kind === 181 || + node.kind === 180 || + node.kind === 172 || + node.kind === 193 || + node.kind === 171; } function explicitlyInheritsFrom(child, parent, cachedResults) { var parentIsInterface = parent.getFlags() & 64; @@ -53768,7 +55107,7 @@ var ts; } return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); } - else if (declaration.kind === 222) { + else if (declaration.kind === 223) { if (parentIsInterface) { return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); } @@ -53795,13 +55134,13 @@ var ts; } var staticFlag = 32; switch (searchSpaceNode.kind) { - case 145: - case 144: - case 147: case 146: + case 145: case 148: + case 147: case 149: case 150: + case 151: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; break; @@ -53814,7 +55153,7 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 95) { + if (!node || node.kind !== 96) { return; } var container = ts.getSuperContainer(node, false); @@ -53829,16 +55168,16 @@ var ts; var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); var staticFlag = 32; switch (searchSpaceNode.kind) { + case 148: case 147: - case 146: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } + case 146: case 145: - case 144: - case 148: case 149: case 150: + case 151: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; break; @@ -53846,8 +55185,8 @@ var ts; if (ts.isExternalModule(searchSpaceNode)) { return undefined; } - case 220: - case 179: + case 221: + case 180: break; default: return undefined; @@ -53888,20 +55227,20 @@ var ts; } var container = ts.getThisContainer(node, false); switch (searchSpaceNode.kind) { - case 179: - case 220: + case 180: + case 221: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; + case 148: case 147: - case 146: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 192: - case 221: + case 193: + case 222: if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } @@ -53975,7 +55314,7 @@ var ts; result.push(shorthandValueSymbol); } } - if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 142 && + if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 143 && ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { result = result.concat(typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); } @@ -54006,7 +55345,7 @@ var ts; getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 222) { + else if (declaration.kind === 223) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -54069,7 +55408,7 @@ var ts; }); } function getNameFromObjectLiteralElement(node) { - if (node.name.kind === 140) { + if (node.name.kind === 141) { var nameExpression = node.name.expression; if (ts.isStringOrNumericLiteral(nameExpression.kind)) { return nameExpression.text; @@ -54138,7 +55477,7 @@ var ts; if (node.initializer) { return true; } - else if (node.kind === 218) { + else if (node.kind === 219) { var parentStatement = getParentStatementOfVariableDeclaration(node); return parentStatement && ts.hasModifier(parentStatement, 2); } @@ -54148,18 +55487,18 @@ var ts; } else { switch (node.kind) { - case 221: - case 192: - case 224: + case 222: + case 193: case 225: + case 226: return true; } } return false; } function getParentStatementOfVariableDeclaration(node) { - if (node.parent && node.parent.parent && node.parent.parent.kind === 200) { - ts.Debug.assert(node.parent.kind === 219); + if (node.parent && node.parent.parent && node.parent.parent.kind === 201) { + ts.Debug.assert(node.parent.kind === 220); return node.parent.parent; } } @@ -54192,17 +55531,17 @@ var ts; } FindAllReferences.getReferenceEntryFromNode = getReferenceEntryFromNode; function isWriteAccess(node) { - if (node.kind === 69 && ts.isDeclarationName(node)) { + if (node.kind === 70 && ts.isDeclarationName(node)) { return true; } var parent = node.parent; if (parent) { - if (parent.kind === 186 || parent.kind === 185) { + if (parent.kind === 187 || parent.kind === 186) { return true; } - else if (parent.kind === 187 && parent.left === node) { + else if (parent.kind === 188 && parent.left === node) { var operator = parent.operatorToken.kind; - return 56 <= operator && operator <= 68; + return 57 <= operator && operator <= 69; } } return false; @@ -54219,10 +55558,10 @@ var ts; switch (node.kind) { case 9: case 8: - if (node.parent.kind === 140) { + if (node.parent.kind === 141) { return isObjectLiteralPropertyDeclaration(node.parent.parent) ? node.parent.parent : undefined; } - case 69: + case 70: return isObjectLiteralPropertyDeclaration(node.parent) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -54231,9 +55570,9 @@ var ts; switch (node.kind) { case 253: case 254: - case 147: - case 149: + case 148: case 150: + case 151: return true; } return false; @@ -54290,9 +55629,9 @@ var ts; } if (symbol.flags & 8388608) { var declaration = symbol.declarations[0]; - if (node.kind === 69 && + if (node.kind === 70 && (node.parent === declaration || - (declaration.kind === 234 && declaration.parent && declaration.parent.kind === 233))) { + (declaration.kind === 235 && declaration.parent && declaration.parent.kind === 234))) { symbol = typeChecker.getAliasedSymbol(symbol); } } @@ -54350,7 +55689,7 @@ var ts; } return result; function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) { - if (ts.isNewExpressionTarget(location) || location.kind === 121) { + if (ts.isNewExpressionTarget(location) || location.kind === 122) { if (symbol.flags & 32) { for (var _i = 0, _a = symbol.getDeclarations(); _i < _a.length; _i++) { var declaration = _a[_i]; @@ -54373,8 +55712,8 @@ var ts; var declarations = []; var definition; ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 148) || - (!selectConstructors && (d.kind === 220 || d.kind === 147 || d.kind === 146))) { + if ((selectConstructors && d.kind === 149) || + (!selectConstructors && (d.kind === 221 || d.kind === 148 || d.kind === 147))) { declarations.push(d); if (d.body) definition = d; @@ -54455,7 +55794,7 @@ var ts; ts.FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result); return result.length > 0 ? result : undefined; } - else if (node.kind === 95 || ts.isSuperProperty(node.parent)) { + else if (node.kind === 96 || ts.isSuperProperty(node.parent)) { var symbol = typeChecker.getSymbolAtLocation(node); return symbol.valueDeclaration && [ts.FindAllReferences.getReferenceEntryFromNode(symbol.valueDeclaration)]; } @@ -54519,7 +55858,7 @@ var ts; "version" ]; var jsDocCompletionEntries; - function getJsDocCommentsFromDeclarations(declarations, name, canUseParsedParamTagComments) { + function getJsDocCommentsFromDeclarations(declarations) { var documentationComment = []; forEachUnique(declarations, function (declaration) { var comments = ts.getJSDocComments(declaration, true); @@ -54558,7 +55897,7 @@ var ts; name: tagName, kind: ts.ScriptElementKind.keyword, kindModifiers: "", - sortText: "0" + sortText: "0", }; })); } @@ -54575,16 +55914,16 @@ var ts; var commentOwner; findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 220: - case 147: - case 148: case 221: - case 200: + case 148: + case 149: + case 222: + case 201: break findOwner; case 256: return undefined; - case 225: - if (commentOwner.parent.kind === 225) { + case 226: + if (commentOwner.parent.kind === 226) { return undefined; } break findOwner; @@ -54600,7 +55939,7 @@ var ts; var docParams = ""; for (var i = 0, numParams = parameters.length; i < numParams; i++) { var currentName = parameters[i].name; - var paramName = currentName.kind === 69 ? + var paramName = currentName.kind === 70 ? currentName.text : "param" + i; docParams += indentationStr + " * @param " + paramName + newLine; @@ -54618,7 +55957,7 @@ var ts; if (ts.isFunctionLike(commentOwner)) { return commentOwner.parameters; } - if (commentOwner.kind === 200) { + if (commentOwner.kind === 201) { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; if (varDeclarations.length === 1 && varDeclarations[0].initializer) { @@ -54628,17 +55967,17 @@ var ts; return ts.emptyArray; } function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 178) { + while (rightHandSide.kind === 179) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 179: case 180: + case 181: return rightHandSide.parameters; - case 192: + case 193: for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 148) { + if (member.kind === 149) { return member.parameters; } } @@ -54649,13 +55988,153 @@ var ts; })(JsDoc = ts.JsDoc || (ts.JsDoc = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var JsTyping; + (function (JsTyping) { + ; + ; + var safeList; + var EmptySafeList = ts.createMap(); + function discoverTypings(host, fileNames, projectRootPath, safeListPath, packageNameToTypingLocation, typingOptions) { + var inferredTypings = ts.createMap(); + if (!typingOptions || !typingOptions.enableAutoDiscovery) { + return { cachedTypingPaths: [], newTypingNames: [], filesToWatch: [] }; + } + fileNames = ts.filter(ts.map(fileNames, ts.normalizePath), function (f) { + var kind = ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)); + return kind === 1 || kind === 2; + }); + if (!safeList) { + var result = ts.readConfigFile(safeListPath, function (path) { return host.readFile(path); }); + safeList = result.config ? ts.createMap(result.config) : EmptySafeList; + } + var filesToWatch = []; + var searchDirs = []; + var exclude = []; + mergeTypings(typingOptions.include); + exclude = typingOptions.exclude || []; + var possibleSearchDirs = ts.map(fileNames, ts.getDirectoryPath); + if (projectRootPath !== undefined) { + possibleSearchDirs.push(projectRootPath); + } + searchDirs = ts.deduplicate(possibleSearchDirs); + for (var _i = 0, searchDirs_1 = searchDirs; _i < searchDirs_1.length; _i++) { + var searchDir = searchDirs_1[_i]; + var packageJsonPath = ts.combinePaths(searchDir, "package.json"); + getTypingNamesFromJson(packageJsonPath, filesToWatch); + var bowerJsonPath = ts.combinePaths(searchDir, "bower.json"); + getTypingNamesFromJson(bowerJsonPath, filesToWatch); + var nodeModulesPath = ts.combinePaths(searchDir, "node_modules"); + getTypingNamesFromNodeModuleFolder(nodeModulesPath); + } + getTypingNamesFromSourceFileNames(fileNames); + for (var name_48 in packageNameToTypingLocation) { + if (name_48 in inferredTypings && !inferredTypings[name_48]) { + inferredTypings[name_48] = packageNameToTypingLocation[name_48]; + } + } + for (var _a = 0, exclude_1 = exclude; _a < exclude_1.length; _a++) { + var excludeTypingName = exclude_1[_a]; + delete inferredTypings[excludeTypingName]; + } + var newTypingNames = []; + var cachedTypingPaths = []; + for (var typing in inferredTypings) { + if (inferredTypings[typing] !== undefined) { + cachedTypingPaths.push(inferredTypings[typing]); + } + else { + newTypingNames.push(typing); + } + } + return { cachedTypingPaths: cachedTypingPaths, newTypingNames: newTypingNames, filesToWatch: filesToWatch }; + function mergeTypings(typingNames) { + if (!typingNames) { + return; + } + for (var _i = 0, typingNames_1 = typingNames; _i < typingNames_1.length; _i++) { + var typing = typingNames_1[_i]; + if (!(typing in inferredTypings)) { + inferredTypings[typing] = undefined; + } + } + } + function getTypingNamesFromJson(jsonPath, filesToWatch) { + var result = ts.readConfigFile(jsonPath, function (path) { return host.readFile(path); }); + if (result.config) { + var jsonConfig = result.config; + filesToWatch.push(jsonPath); + if (jsonConfig.dependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.dependencies)); + } + if (jsonConfig.devDependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.devDependencies)); + } + if (jsonConfig.optionalDependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.optionalDependencies)); + } + if (jsonConfig.peerDependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.peerDependencies)); + } + } + } + function getTypingNamesFromSourceFileNames(fileNames) { + var jsFileNames = ts.filter(fileNames, ts.hasJavaScriptFileExtension); + var inferredTypingNames = ts.map(jsFileNames, function (f) { return ts.removeFileExtension(ts.getBaseFileName(f.toLowerCase())); }); + var cleanedTypingNames = ts.map(inferredTypingNames, function (f) { return f.replace(/((?:\.|-)min(?=\.|$))|((?:-|\.)\d+)/g, ""); }); + if (safeList !== EmptySafeList) { + mergeTypings(ts.filter(cleanedTypingNames, function (f) { return f in safeList; })); + } + var hasJsxFile = ts.forEach(fileNames, function (f) { return ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)) === 2; }); + if (hasJsxFile) { + mergeTypings(["react"]); + } + } + function getTypingNamesFromNodeModuleFolder(nodeModulesPath) { + if (!host.directoryExists(nodeModulesPath)) { + return; + } + var typingNames = []; + var fileNames = host.readDirectory(nodeModulesPath, [".json"], undefined, undefined, 2); + for (var _i = 0, fileNames_2 = fileNames; _i < fileNames_2.length; _i++) { + var fileName = fileNames_2[_i]; + var normalizedFileName = ts.normalizePath(fileName); + if (ts.getBaseFileName(normalizedFileName) !== "package.json") { + continue; + } + var result = ts.readConfigFile(normalizedFileName, function (path) { return host.readFile(path); }); + if (!result.config) { + continue; + } + var packageJson = result.config; + if (packageJson._requiredBy && + ts.filter(packageJson._requiredBy, function (r) { return r[0] === "#" || r === "/"; }).length === 0) { + continue; + } + if (!packageJson.name) { + continue; + } + if (packageJson.typings) { + var absolutePath = ts.getNormalizedAbsolutePath(packageJson.typings, ts.getDirectoryPath(normalizedFileName)); + inferredTypings[packageJson.name] = absolutePath; + } + else { + typingNames.push(packageJson.name); + } + } + mergeTypings(typingNames); + } + } + JsTyping.discoverTypings = discoverTypings; + })(JsTyping = ts.JsTyping || (ts.JsTyping = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var NavigateTo; (function (NavigateTo) { function getNavigateToItems(sourceFiles, checker, cancellationToken, searchValue, maxResultCount, excludeDtsFiles) { var patternMatcher = ts.createPatternMatcher(searchValue); var rawItems = []; - var baseSensitivity = { sensitivity: "base" }; ts.forEach(sourceFiles, function (sourceFile) { cancellationToken.throwIfCancellationRequested(); if (excludeDtsFiles && ts.fileExtensionIs(sourceFile.fileName, ".d.ts")) { @@ -54690,7 +56169,7 @@ var ts; }); rawItems = ts.filter(rawItems, function (item) { var decl = item.declaration; - if (decl.kind === 231 || decl.kind === 234 || decl.kind === 229) { + if (decl.kind === 232 || decl.kind === 235 || decl.kind === 230) { var importer = checker.getSymbolAtLocation(decl.name); var imported = checker.getAliasedSymbol(importer); return importer.name !== imported.name; @@ -54717,7 +56196,7 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 69 || + if (node.kind === 70 || node.kind === 9 || node.kind === 8) { return node.text; @@ -54731,7 +56210,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 140) { + else if (declaration.name.kind === 141) { return tryAddComputedPropertyName(declaration.name.expression, containers, true); } else { @@ -54748,7 +56227,7 @@ var ts; } return true; } - if (expression.kind === 172) { + if (expression.kind === 173) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -54759,7 +56238,7 @@ var ts; } function getContainers(declaration) { var containers = []; - if (declaration.name.kind === 140) { + if (declaration.name.kind === 141) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, false)) { return undefined; } @@ -54787,8 +56266,8 @@ var ts; } function compareNavigateToItems(i1, i2) { return i1.matchKind - i2.matchKind || - i1.name.localeCompare(i2.name, undefined, baseSensitivity) || - i1.name.localeCompare(i2.name); + ts.compareStringsCaseInsensitive(i1.name, i2.name) || + ts.compareStrings(i1.name, i2.name); } function createNavigateToItem(rawItem) { var declaration = rawItem.declaration; @@ -54891,7 +56370,7 @@ var ts; return; } switch (node.kind) { - case 148: + case 149: var ctr = node; addNodeWithRecursiveChild(ctr, ctr.body); for (var _i = 0, _a = ctr.parameters; _i < _a.length; _i++) { @@ -54901,28 +56380,28 @@ var ts; } } break; - case 147: - case 149: + case 148: case 150: - case 146: + case 151: + case 147: if (!ts.hasDynamicName(node)) { addNodeWithRecursiveChild(node, node.body); } break; + case 146: case 145: - case 144: if (!ts.hasDynamicName(node)) { addLeafNode(node); } break; - case 231: + case 232: var importClause = node; if (importClause.name) { addLeafNode(importClause); } var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 232) { + if (namedBindings.kind === 233) { addLeafNode(namedBindings); } else { @@ -54933,8 +56412,8 @@ var ts; } } break; - case 169: - case 218: + case 170: + case 219: var decl = node; var name_50 = decl.name; if (ts.isBindingPattern(name_50)) { @@ -54947,12 +56426,12 @@ var ts; addNodeWithRecursiveChild(decl, decl.initializer); } break; + case 181: + case 221: case 180: - case 220: - case 179: addNodeWithRecursiveChild(node, node.body); break; - case 224: + case 225: startNode(node); for (var _d = 0, _e = node.members; _d < _e.length; _d++) { var member = _e[_d]; @@ -54962,9 +56441,9 @@ var ts; } endNode(); break; - case 221: - case 192: case 222: + case 193: + case 223: startNode(node); for (var _f = 0, _g = node.members; _f < _g.length; _f++) { var member = _g[_f]; @@ -54972,15 +56451,15 @@ var ts; } endNode(); break; - case 225: + case 226: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 238: - case 229: - case 153: - case 151: + case 239: + case 230: + case 154: case 152: - case 223: + case 153: + case 224: addLeafNode(node); break; default: @@ -55034,12 +56513,12 @@ var ts; } }); function shouldReallyMerge(a, b) { - return a.kind === b.kind && (a.kind !== 225 || areSameModule(a, b)); + return a.kind === b.kind && (a.kind !== 226 || areSameModule(a, b)); function areSameModule(a, b) { if (a.body.kind !== b.body.kind) { return false; } - if (a.body.kind !== 225) { + if (a.body.kind !== 226) { return true; } return areSameModule(a.body, b.body); @@ -55072,9 +56551,8 @@ var ts; return name1 ? 1 : name2 ? -1 : navigationBarNodeKind(child1) - navigationBarNodeKind(child2); } } - var collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; - var localeCompareIsCorrect = collator && collator.compare("a", "B") < 0; - var localeCompareFix = localeCompareIsCorrect ? collator.compare : function (a, b) { + var localeCompareIsCorrect = ts.collator && ts.collator.compare("a", "B") < 0; + var localeCompareFix = localeCompareIsCorrect ? ts.collator.compare : function (a, b) { for (var i = 0; i < Math.min(a.length, b.length); i++) { var chA = a.charAt(i), chB = b.charAt(i); if (chA === "\"" && chB === "'") { @@ -55083,7 +56561,7 @@ var ts; if (chA === "'" && chB === "\"") { return -1; } - var cmp = chA.toLocaleLowerCase().localeCompare(chB.toLocaleLowerCase()); + var cmp = ts.compareStrings(chA.toLocaleLowerCase(), chB.toLocaleLowerCase()); if (cmp !== 0) { return cmp; } @@ -55091,7 +56569,7 @@ var ts; return a.length - b.length; }; function tryGetName(node) { - if (node.kind === 225) { + if (node.kind === 226) { return getModuleName(node); } var decl = node; @@ -55099,9 +56577,9 @@ var ts; return ts.getPropertyNameForPropertyNameNode(decl.name); } switch (node.kind) { - case 179: case 180: - case 192: + case 181: + case 193: return getFunctionOrClassName(node); case 279: return getJSDocTypedefTagName(node); @@ -55110,7 +56588,7 @@ var ts; } } function getItemName(node) { - if (node.kind === 225) { + if (node.kind === 226) { return getModuleName(node); } var name = node.name; @@ -55126,22 +56604,22 @@ var ts; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 180: - case 220: - case 179: + case 181: case 221: - case 192: + case 180: + case 222: + case 193: if (ts.getModifierFlags(node) & 512) { return "default"; } return getFunctionOrClassName(node); - case 148: + case 149: return "constructor"; - case 152: - return "new()"; - case 151: - return "()"; case 153: + return "new()"; + case 152: + return "()"; + case 154: return "[]"; case 279: return getJSDocTypedefTagName(node); @@ -55155,10 +56633,10 @@ var ts; } else { var parentNode = node.parent && node.parent.parent; - if (parentNode && parentNode.kind === 200) { + if (parentNode && parentNode.kind === 201) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; - if (nameIdentifier.kind === 69) { + if (nameIdentifier.kind === 70) { return nameIdentifier.text; } } @@ -55183,24 +56661,24 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 221: - case 192: - case 224: case 222: + case 193: case 225: - case 256: case 223: + case 226: + case 256: + case 224: case 279: return true; - case 148: - case 147: case 149: + case 148: case 150: - case 218: + case 151: + case 219: return hasSomeImportantChild(item); + case 181: + case 221: case 180: - case 220: - case 179: return isTopLevelFunctionDeclaration(item); default: return false; @@ -55210,10 +56688,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 226: + case 227: case 256: - case 147: case 148: + case 149: return true; default: return hasSomeImportantChild(item); @@ -55222,7 +56700,7 @@ var ts; function hasSomeImportantChild(item) { return ts.forEach(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 218 && childKind !== 169; + return childKind !== 219 && childKind !== 170; }); } } @@ -55277,17 +56755,17 @@ var ts; } var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 225) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 226) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } return result.join("."); } function getInteriorModule(decl) { - return decl.body.kind === 225 ? getInteriorModule(decl.body) : decl; + return decl.body.kind === 226 ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 140; + return !member.name || member.name.kind === 141; } function getNodeSpan(node) { return node.kind === 256 @@ -55298,11 +56776,11 @@ var ts; if (node.name && ts.getFullWidth(node.name) > 0) { return ts.declarationNameToString(node.name); } - else if (node.parent.kind === 218) { + else if (node.parent.kind === 219) { return ts.declarationNameToString(node.parent.name); } - else if (node.parent.kind === 187 && - node.parent.operatorToken.kind === 56) { + else if (node.parent.kind === 188 && + node.parent.operatorToken.kind === 57) { return nodeText(node.parent.left); } else if (node.parent.kind === 253 && node.parent.name) { @@ -55316,7 +56794,7 @@ var ts; } } function isFunctionOrClassExpression(node) { - return node.kind === 179 || node.kind === 180 || node.kind === 192; + return node.kind === 180 || node.kind === 181 || node.kind === 193; } })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); })(ts || (ts = {})); @@ -55388,7 +56866,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 180; + return ts.isFunctionBlock(node) && node.parent.kind !== 181; } var depth = 0; var maxDepth = 20; @@ -55400,30 +56878,30 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 199: + case 200: if (!ts.isFunctionBlock(n)) { var parent_22 = n.parent; - var openBrace = ts.findChildOfKind(n, 15, sourceFile); - var closeBrace = ts.findChildOfKind(n, 16, sourceFile); - if (parent_22.kind === 204 || - parent_22.kind === 207 || + var openBrace = ts.findChildOfKind(n, 16, sourceFile); + var closeBrace = ts.findChildOfKind(n, 17, sourceFile); + if (parent_22.kind === 205 || parent_22.kind === 208 || + parent_22.kind === 209 || + parent_22.kind === 207 || + parent_22.kind === 204 || parent_22.kind === 206 || - parent_22.kind === 203 || - parent_22.kind === 205 || - parent_22.kind === 212 || + parent_22.kind === 213 || parent_22.kind === 252) { addOutliningSpan(parent_22, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_22.kind === 216) { + if (parent_22.kind === 217) { var tryStatement = parent_22; if (tryStatement.tryBlock === n) { addOutliningSpan(parent_22, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 85, sourceFile); + var finallyKeyword = ts.findChildOfKind(tryStatement, 86, sourceFile); if (finallyKeyword) { addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); break; @@ -55439,25 +56917,25 @@ var ts; }); break; } - case 226: { - var openBrace = ts.findChildOfKind(n, 15, sourceFile); - var closeBrace = ts.findChildOfKind(n, 16, sourceFile); + case 227: { + var openBrace = ts.findChildOfKind(n, 16, sourceFile); + var closeBrace = ts.findChildOfKind(n, 17, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 221: case 222: - case 224: - case 171: - case 227: { - var openBrace = ts.findChildOfKind(n, 15, sourceFile); - var closeBrace = ts.findChildOfKind(n, 16, sourceFile); + case 223: + case 225: + case 172: + case 228: { + var openBrace = ts.findChildOfKind(n, 16, sourceFile); + var closeBrace = ts.findChildOfKind(n, 17, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 170: - var openBracket = ts.findChildOfKind(n, 19, sourceFile); - var closeBracket = ts.findChildOfKind(n, 20, sourceFile); + case 171: + var openBracket = ts.findChildOfKind(n, 20, sourceFile); + var closeBracket = ts.findChildOfKind(n, 21, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); break; } @@ -55700,7 +57178,7 @@ var ts; if (ch >= 65 && ch <= 90) { return true; } - if (ch < 127 || !ts.isUnicodeIdentifierStart(ch, 2)) { + if (ch < 127 || !ts.isUnicodeIdentifierStart(ch, 4)) { return false; } var str = String.fromCharCode(ch); @@ -55710,7 +57188,7 @@ var ts; if (ch >= 97 && ch <= 122) { return true; } - if (ch < 127 || !ts.isUnicodeIdentifierStart(ch, 2)) { + if (ch < 127 || !ts.isUnicodeIdentifierStart(ch, 4)) { return false; } var str = String.fromCharCode(ch); @@ -55893,10 +57371,10 @@ var ts; var externalModule = false; function nextToken() { var token = ts.scanner.scan(); - if (token === 15) { + if (token === 16) { braceNesting++; } - else if (token === 16) { + else if (token === 17) { braceNesting--; } return token; @@ -55944,9 +57422,9 @@ var ts; } function tryConsumeDeclare() { var token = ts.scanner.getToken(); - if (token === 122) { + if (token === 123) { token = nextToken(); - if (token === 125) { + if (token === 126) { token = nextToken(); if (token === 9) { recordAmbientExternalModule(); @@ -55958,42 +57436,42 @@ var ts; } function tryConsumeImport() { var token = ts.scanner.getToken(); - if (token === 89) { + if (token === 90) { token = nextToken(); if (token === 9) { recordModuleName(); return true; } else { - if (token === 69 || ts.isKeyword(token)) { + if (token === 70 || ts.isKeyword(token)) { token = nextToken(); - if (token === 136) { + if (token === 137) { token = nextToken(); if (token === 9) { recordModuleName(); return true; } } - else if (token === 56) { + else if (token === 57) { if (tryConsumeRequireCall(true)) { return true; } } - else if (token === 24) { + else if (token === 25) { token = nextToken(); } else { return true; } } - if (token === 15) { + if (token === 16) { token = nextToken(); - while (token !== 16 && token !== 1) { + while (token !== 17 && token !== 1) { token = nextToken(); } - if (token === 16) { + if (token === 17) { token = nextToken(); - if (token === 136) { + if (token === 137) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -56001,13 +57479,13 @@ var ts; } } } - else if (token === 37) { + else if (token === 38) { token = nextToken(); - if (token === 116) { + if (token === 117) { token = nextToken(); - if (token === 69 || ts.isKeyword(token)) { + if (token === 70 || ts.isKeyword(token)) { token = nextToken(); - if (token === 136) { + if (token === 137) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -56023,17 +57501,17 @@ var ts; } function tryConsumeExport() { var token = ts.scanner.getToken(); - if (token === 82) { + if (token === 83) { markAsExternalModuleIfTopLevel(); token = nextToken(); - if (token === 15) { + if (token === 16) { token = nextToken(); - while (token !== 16 && token !== 1) { + while (token !== 17 && token !== 1) { token = nextToken(); } - if (token === 16) { + if (token === 17) { token = nextToken(); - if (token === 136) { + if (token === 137) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -56041,20 +57519,20 @@ var ts; } } } - else if (token === 37) { + else if (token === 38) { token = nextToken(); - if (token === 136) { + if (token === 137) { token = nextToken(); if (token === 9) { recordModuleName(); } } } - else if (token === 89) { + else if (token === 90) { token = nextToken(); - if (token === 69 || ts.isKeyword(token)) { + if (token === 70 || ts.isKeyword(token)) { token = nextToken(); - if (token === 56) { + if (token === 57) { if (tryConsumeRequireCall(true)) { return true; } @@ -56067,9 +57545,9 @@ var ts; } function tryConsumeRequireCall(skipCurrentToken) { var token = skipCurrentToken ? nextToken() : ts.scanner.getToken(); - if (token === 129) { + if (token === 130) { token = nextToken(); - if (token === 17) { + if (token === 18) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -56081,27 +57559,27 @@ var ts; } function tryConsumeDefine() { var token = ts.scanner.getToken(); - if (token === 69 && ts.scanner.getTokenValue() === "define") { + if (token === 70 && ts.scanner.getTokenValue() === "define") { token = nextToken(); - if (token !== 17) { + if (token !== 18) { return true; } token = nextToken(); if (token === 9) { token = nextToken(); - if (token === 24) { + if (token === 25) { token = nextToken(); } else { return true; } } - if (token !== 19) { + if (token !== 20) { return true; } token = nextToken(); var i = 0; - while (token !== 20 && token !== 1) { + while (token !== 21 && token !== 1) { if (token === 9) { recordModuleName(); i++; @@ -56173,7 +57651,7 @@ var ts; var canonicalDefaultLibName = getCanonicalFileName(ts.normalizePath(defaultLibFileName)); var node = ts.getTouchingWord(sourceFile, position, true); if (node) { - if (node.kind === 69 || + if (node.kind === 70 || node.kind === 9 || ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || ts.isThis(node)) { @@ -56261,6 +57739,12 @@ var ts; var SignatureHelp; (function (SignatureHelp) { var emptyArray = []; + (function (ArgumentListKind) { + ArgumentListKind[ArgumentListKind["TypeArguments"] = 0] = "TypeArguments"; + ArgumentListKind[ArgumentListKind["CallArguments"] = 1] = "CallArguments"; + ArgumentListKind[ArgumentListKind["TaggedTemplateArguments"] = 2] = "TaggedTemplateArguments"; + })(SignatureHelp.ArgumentListKind || (SignatureHelp.ArgumentListKind = {})); + var ArgumentListKind = SignatureHelp.ArgumentListKind; function getSignatureHelpItems(program, sourceFile, position, cancellationToken) { var typeChecker = program.getTypeChecker(); var startingToken = ts.findTokenOnLeftOfPosition(sourceFile, position); @@ -56286,14 +57770,14 @@ var ts; } SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; function createJavaScriptSignatureHelpItems(argumentInfo, program) { - if (argumentInfo.invocation.kind !== 174) { + if (argumentInfo.invocation.kind !== 175) { return undefined; } var callExpression = argumentInfo.invocation; var expression = callExpression.expression; - var name = expression.kind === 69 + var name = expression.kind === 70 ? expression - : expression.kind === 172 + : expression.kind === 173 ? expression.name : undefined; if (!name || !name.text) { @@ -56322,10 +57806,10 @@ var ts; } } function getImmediatelyContainingArgumentInfo(node, position, sourceFile) { - if (node.parent.kind === 174 || node.parent.kind === 175) { + if (node.parent.kind === 175 || node.parent.kind === 176) { var callExpression = node.parent; - if (node.kind === 25 || - node.kind === 17) { + if (node.kind === 26 || + node.kind === 18) { var list = getChildListThatStartsWithOpenerToken(callExpression, node, sourceFile); var isTypeArgList = callExpression.typeArguments && callExpression.typeArguments.pos === list.pos; ts.Debug.assert(list !== undefined); @@ -56354,24 +57838,24 @@ var ts; } return undefined; } - else if (node.kind === 11 && node.parent.kind === 176) { + else if (node.kind === 12 && node.parent.kind === 177) { if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, 0, sourceFile); } } - else if (node.kind === 12 && node.parent.parent.kind === 176) { + else if (node.kind === 13 && node.parent.parent.kind === 177) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 189); + ts.Debug.assert(templateExpression.kind === 190); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } - else if (node.parent.kind === 197 && node.parent.parent.parent.kind === 176) { + else if (node.parent.kind === 198 && node.parent.parent.parent.kind === 177) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 189); - if (node.kind === 14 && !ts.isInsideTemplateLiteral(node, position)) { + ts.Debug.assert(templateExpression.kind === 190); + if (node.kind === 15 && !ts.isInsideTemplateLiteral(node, position)) { return undefined; } var spanIndex = templateExpression.templateSpans.indexOf(templateSpan); @@ -56388,7 +57872,7 @@ var ts; if (child === node) { break; } - if (child.kind !== 24) { + if (child.kind !== 25) { argumentIndex++; } } @@ -56396,8 +57880,8 @@ var ts; } function getArgumentCount(argumentsList) { var listChildren = argumentsList.getChildren(); - var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 24; }); - if (listChildren.length > 0 && ts.lastOrUndefined(listChildren).kind === 24) { + var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 25; }); + if (listChildren.length > 0 && ts.lastOrUndefined(listChildren).kind === 25) { argumentCount++; } return argumentCount; @@ -56413,7 +57897,7 @@ var ts; return spanIndex + 1; } function getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile) { - var argumentCount = tagExpression.template.kind === 11 + var argumentCount = tagExpression.template.kind === 12 ? 1 : tagExpression.template.templateSpans.length + 1; ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); @@ -56434,7 +57918,7 @@ var ts; var template = taggedTemplate.template; var applicableSpanStart = template.getStart(); var applicableSpanEnd = template.getEnd(); - if (template.kind === 189) { + if (template.kind === 190) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); @@ -56494,10 +57978,10 @@ var ts; ts.addRange(prefixDisplayParts, callTargetDisplayParts); } if (isTypeParameterList) { - prefixDisplayParts.push(ts.punctuationPart(25)); + prefixDisplayParts.push(ts.punctuationPart(26)); var typeParameters = candidateSignature.typeParameters; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(27)); + suffixDisplayParts.push(ts.punctuationPart(28)); var parameterParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.thisParameter, candidateSignature.parameters, writer, invocation); }); @@ -56508,10 +57992,10 @@ var ts; return typeChecker.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation); }); ts.addRange(prefixDisplayParts, typeParameterParts); - prefixDisplayParts.push(ts.punctuationPart(17)); + prefixDisplayParts.push(ts.punctuationPart(18)); var parameters = candidateSignature.parameters; signatureHelpParameters = parameters.length > 0 ? ts.map(parameters, createSignatureHelpParameterForParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(18)); + suffixDisplayParts.push(ts.punctuationPart(19)); } var returnTypeParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation); @@ -56521,7 +58005,7 @@ var ts; isVariadic: candidateSignature.hasRestParameter, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: suffixDisplayParts, - separatorDisplayParts: [ts.punctuationPart(24), ts.spacePart()], + separatorDisplayParts: [ts.punctuationPart(25), ts.spacePart()], parameters: signatureHelpParameters, documentation: candidateSignature.getDocumentationComment() }; @@ -56572,7 +58056,7 @@ var ts; function getSymbolKind(typeChecker, symbol, location) { var flags = symbol.getFlags(); if (flags & 32) - return ts.getDeclarationOfKind(symbol, 192) ? + return ts.getDeclarationOfKind(symbol, 193) ? ts.ScriptElementKind.localClassElement : ts.ScriptElementKind.classElement; if (flags & 384) return ts.ScriptElementKind.enumElement; @@ -56603,7 +58087,7 @@ var ts; if (typeChecker.isArgumentsSymbol(symbol)) { return ts.ScriptElementKind.localVariableElement; } - if (location.kind === 97 && ts.isExpression(location)) { + if (location.kind === 98 && ts.isExpression(location)) { return ts.ScriptElementKind.parameterElement; } if (flags & 3) { @@ -56663,7 +58147,7 @@ var ts; var symbolFlags = symbol.flags; var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, symbolFlags, location); var hasAddedSymbolInfo; - var isThisExpression = location.kind === 97 && ts.isExpression(location); + var isThisExpression = location.kind === 98 && ts.isExpression(location); var type; if (symbolKind !== ts.ScriptElementKind.unknown || symbolFlags & 32 || symbolFlags & 8388608) { if (symbolKind === ts.ScriptElementKind.memberGetAccessorElement || symbolKind === ts.ScriptElementKind.memberSetAccessorElement) { @@ -56672,14 +58156,14 @@ var ts; var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 172) { + if (location.parent && location.parent.kind === 173) { var right = location.parent.name; if (right === location || (right && right.getFullWidth() === 0)) { location = location.parent; } } var callExpression = void 0; - if (location.kind === 174 || location.kind === 175) { + if (location.kind === 175 || location.kind === 176) { callExpression = location; } else if (ts.isCallExpressionTarget(location) || ts.isNewExpressionTarget(location)) { @@ -56691,7 +58175,7 @@ var ts; if (!signature && candidateSignatures.length) { signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 175 || callExpression.expression.kind === 95; + var useConstructSignatures = callExpression.kind === 176 || callExpression.expression.kind === 96; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { signature = allSignatures.length ? allSignatures[0] : undefined; @@ -56706,7 +58190,7 @@ var ts; pushTypePart(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(92)); + displayParts.push(ts.keywordPart(93)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -56721,10 +58205,10 @@ var ts; case ts.ScriptElementKind.letElement: case ts.ScriptElementKind.parameterElement: case ts.ScriptElementKind.localVariableElement: - displayParts.push(ts.punctuationPart(54)); + displayParts.push(ts.punctuationPart(55)); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(92)); + displayParts.push(ts.keywordPart(93)); displayParts.push(ts.spacePart()); } if (!(type.flags & 2097152) && type.symbol) { @@ -56739,21 +58223,21 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304)) || - (location.kind === 121 && location.parent.kind === 148)) { + (location.kind === 122 && location.parent.kind === 149)) { var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 148 ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration.kind === 149 ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 148) { + if (functionDeclaration.kind === 149) { symbolKind = ts.ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 151 && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 152 && !(type.symbol.flags & 2048 || type.symbol.flags & 4096) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -56762,11 +58246,11 @@ var ts; } } if (symbolFlags & 32 && !hasAddedSymbolInfo && !isThisExpression) { - if (ts.getDeclarationOfKind(symbol, 192)) { + if (ts.getDeclarationOfKind(symbol, 193)) { pushTypePart(ts.ScriptElementKind.localClassElement); } else { - displayParts.push(ts.keywordPart(73)); + displayParts.push(ts.keywordPart(74)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); @@ -56774,72 +58258,72 @@ var ts; } if ((symbolFlags & 64) && (semanticMeaning & 2)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(107)); + displayParts.push(ts.keywordPart(108)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if (symbolFlags & 524288) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(134)); + displayParts.push(ts.keywordPart(135)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(56)); + displayParts.push(ts.operatorPart(57)); displayParts.push(ts.spacePart()); ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 512)); } if (symbolFlags & 384) { addNewLineIfDisplayPartsExist(); if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { - displayParts.push(ts.keywordPart(74)); + displayParts.push(ts.keywordPart(75)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(81)); + displayParts.push(ts.keywordPart(82)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 225); - var isNamespace = declaration && declaration.name && declaration.name.kind === 69; - displayParts.push(ts.keywordPart(isNamespace ? 126 : 125)); + var declaration = ts.getDeclarationOfKind(symbol, 226); + var isNamespace = declaration && declaration.name && declaration.name.kind === 70; + displayParts.push(ts.keywordPart(isNamespace ? 127 : 126)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if ((symbolFlags & 262144) && (semanticMeaning & 2)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.punctuationPart(17)); - displayParts.push(ts.textPart("type parameter")); displayParts.push(ts.punctuationPart(18)); + displayParts.push(ts.textPart("type parameter")); + displayParts.push(ts.punctuationPart(19)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(90)); + displayParts.push(ts.keywordPart(91)); displayParts.push(ts.spacePart()); if (symbol.parent) { addFullSymbolName(symbol.parent, enclosingDeclaration); writeTypeParametersOfSymbol(symbol.parent, enclosingDeclaration); } else { - var declaration = ts.getDeclarationOfKind(symbol, 141); + var declaration = ts.getDeclarationOfKind(symbol, 142); ts.Debug.assert(declaration !== undefined); declaration = declaration.parent; if (declaration) { if (ts.isFunctionLikeKind(declaration.kind)) { var signature = typeChecker.getSignatureFromDeclaration(declaration); - if (declaration.kind === 152) { - displayParts.push(ts.keywordPart(92)); + if (declaration.kind === 153) { + displayParts.push(ts.keywordPart(93)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 151 && declaration.name) { + else if (declaration.kind !== 152 && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32)); } else { - displayParts.push(ts.keywordPart(134)); + displayParts.push(ts.keywordPart(135)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -56854,7 +58338,7 @@ var ts; var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(56)); + displayParts.push(ts.operatorPart(57)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(constantValue.toString(), ts.SymbolDisplayPartKind.numericLiteral)); } @@ -56862,33 +58346,33 @@ var ts; } if (symbolFlags & 8388608) { addNewLineIfDisplayPartsExist(); - if (symbol.declarations[0].kind === 228) { - displayParts.push(ts.keywordPart(82)); + if (symbol.declarations[0].kind === 229) { + displayParts.push(ts.keywordPart(83)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(126)); + displayParts.push(ts.keywordPart(127)); } else { - displayParts.push(ts.keywordPart(89)); + displayParts.push(ts.keywordPart(90)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 229) { + if (declaration.kind === 230) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(56)); + displayParts.push(ts.operatorPart(57)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(129)); - displayParts.push(ts.punctuationPart(17)); - displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); + displayParts.push(ts.keywordPart(130)); displayParts.push(ts.punctuationPart(18)); + displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); + displayParts.push(ts.punctuationPart(19)); } else { var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(56)); + displayParts.push(ts.operatorPart(57)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -56902,7 +58386,7 @@ var ts; if (type) { if (isThisExpression) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(97)); + displayParts.push(ts.keywordPart(98)); } else { addPrefixForAnyFunctionOrVar(symbol, symbolKind); @@ -56911,7 +58395,7 @@ var ts; symbolFlags & 3 || symbolKind === ts.ScriptElementKind.localVariableElement || isThisExpression) { - displayParts.push(ts.punctuationPart(54)); + displayParts.push(ts.punctuationPart(55)); displayParts.push(ts.spacePart()); if (type.symbol && type.symbol.flags & 262144) { var typeParameterParts = ts.mapToDisplayParts(function (writer) { @@ -56944,7 +58428,7 @@ var ts; if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 256; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 187) { + if (!declaration.parent || declaration.parent.kind !== 188) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -56987,9 +58471,9 @@ var ts; displayParts.push(ts.textOrKeywordPart(symbolKind)); return; default: - displayParts.push(ts.punctuationPart(17)); - displayParts.push(ts.textOrKeywordPart(symbolKind)); displayParts.push(ts.punctuationPart(18)); + displayParts.push(ts.textOrKeywordPart(symbolKind)); + displayParts.push(ts.punctuationPart(19)); return; } } @@ -56997,12 +58481,12 @@ var ts; ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32)); if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); - displayParts.push(ts.punctuationPart(17)); - displayParts.push(ts.operatorPart(35)); + displayParts.push(ts.punctuationPart(18)); + displayParts.push(ts.operatorPart(36)); displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), ts.SymbolDisplayPartKind.numericLiteral)); displayParts.push(ts.spacePart()); displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); - displayParts.push(ts.punctuationPart(18)); + displayParts.push(ts.punctuationPart(19)); } documentation = signature.getDocumentationComment(); } @@ -57019,14 +58503,14 @@ var ts; return false; } return ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 179) { + if (declaration.kind === 180) { return true; } - if (declaration.kind !== 218 && declaration.kind !== 220) { + if (declaration.kind !== 219 && declaration.kind !== 221) { return false; } for (var parent_23 = declaration.parent; !ts.isFunctionBlock(parent_23); parent_23 = parent_23.parent) { - if (parent_23.kind === 256 || parent_23.kind === 226) { + if (parent_23.kind === 256 || parent_23.kind === 227) { return false; } } @@ -57067,8 +58551,8 @@ var ts; var outputText; var sourceMapText; var compilerHost = { - getSourceFile: function (fileName, target) { return fileName === ts.normalizePath(inputFileName) ? sourceFile : undefined; }, - writeFile: function (name, text, writeByteOrderMark) { + getSourceFile: function (fileName) { return fileName === ts.normalizePath(inputFileName) ? sourceFile : undefined; }, + writeFile: function (name, text) { if (ts.fileExtensionIs(name, ".map")) { ts.Debug.assert(sourceMapText === undefined, "Unexpected multiple source map outputs for the file '" + name + "'"); sourceMapText = text; @@ -57084,9 +58568,9 @@ var ts; getCurrentDirectory: function () { return ""; }, getNewLine: function () { return newLine; }, fileExists: function (fileName) { return fileName === inputFileName; }, - readFile: function (fileName) { return ""; }, - directoryExists: function (directoryExists) { return true; }, - getDirectories: function (path) { return []; } + readFile: function () { return ""; }, + directoryExists: function () { return true; }, + getDirectories: function () { return []; } }; var program = ts.createProgram([inputFileName], options, compilerHost); if (transpileOptions.reportDiagnostics) { @@ -57135,11 +58619,20 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var standardScanner = ts.createScanner(2, false, 0); - var jsxScanner = ts.createScanner(2, false, 1); + var standardScanner = ts.createScanner(4, false, 0); + var jsxScanner = ts.createScanner(4, false, 1); var scanner; + var ScanAction; + (function (ScanAction) { + ScanAction[ScanAction["Scan"] = 0] = "Scan"; + ScanAction[ScanAction["RescanGreaterThanToken"] = 1] = "RescanGreaterThanToken"; + ScanAction[ScanAction["RescanSlashToken"] = 2] = "RescanSlashToken"; + ScanAction[ScanAction["RescanTemplateToken"] = 3] = "RescanTemplateToken"; + ScanAction[ScanAction["RescanJsxIdentifier"] = 4] = "RescanJsxIdentifier"; + ScanAction[ScanAction["RescanJsxText"] = 5] = "RescanJsxText"; + })(ScanAction || (ScanAction = {})); function getFormattingScanner(sourceFile, startPos, endPos) { - ts.Debug.assert(scanner === undefined); + ts.Debug.assert(scanner === undefined, "Scanner should be undefined"); scanner = sourceFile.languageVariant === 1 ? jsxScanner : standardScanner; scanner.setText(sourceFile.text); scanner.setTextPos(startPos); @@ -57164,7 +58657,7 @@ var ts; } }; function advance() { - ts.Debug.assert(scanner !== undefined); + ts.Debug.assert(scanner !== undefined, "Scanner should be present"); lastTokenInfo = undefined; var isStarted = scanner.getStartPos() !== startPos; if (isStarted) { @@ -57204,11 +58697,11 @@ var ts; function shouldRescanGreaterThanToken(node) { if (node) { switch (node.kind) { - case 29: - case 64: + case 30: case 65: + case 66: + case 46: case 45: - case 44: return true; } } @@ -57218,26 +58711,26 @@ var ts; if (node.parent) { switch (node.parent.kind) { case 246: - case 243: + case 244: case 245: - case 242: - return node.kind === 69; + case 243: + return node.kind === 70; } } return false; } function shouldRescanJsxText(node) { - return node && node.kind === 244; + return node && node.kind === 10; } function shouldRescanSlashToken(container) { - return container.kind === 10; + return container.kind === 11; } function shouldRescanTemplateToken(container) { - return container.kind === 13 || - container.kind === 14; + return container.kind === 14 || + container.kind === 15; } function startsWithSlashToken(t) { - return t === 39 || t === 61; + return t === 40 || t === 62; } function readTokenInfo(n) { ts.Debug.assert(scanner !== undefined); @@ -57268,7 +58761,7 @@ var ts; scanner.scan(); } var currentToken = scanner.getToken(); - if (expectedScanAction === 1 && currentToken === 27) { + if (expectedScanAction === 1 && currentToken === 28) { currentToken = scanner.reScanGreaterToken(); ts.Debug.assert(n.kind === currentToken); lastScanAction = 1; @@ -57278,11 +58771,11 @@ var ts; ts.Debug.assert(n.kind === currentToken); lastScanAction = 2; } - else if (expectedScanAction === 3 && currentToken === 16) { + else if (expectedScanAction === 3 && currentToken === 17) { currentToken = scanner.reScanTemplateToken(); lastScanAction = 3; } - else if (expectedScanAction === 4 && currentToken === 69) { + else if (expectedScanAction === 4 && currentToken === 70) { currentToken = scanner.scanJsxIdentifier(); lastScanAction = 4; } @@ -57416,8 +58909,8 @@ var ts; return startLine === endLine; }; FormattingContext.prototype.BlockIsOnOneLine = function (node) { - var openBrace = ts.findChildOfKind(node, 15, this.sourceFile); - var closeBrace = ts.findChildOfKind(node, 16, this.sourceFile); + var openBrace = ts.findChildOfKind(node, 16, this.sourceFile); + var closeBrace = ts.findChildOfKind(node, 17, this.sourceFile); if (openBrace && closeBrace) { var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line; var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line; @@ -57431,6 +58924,20 @@ var ts; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var formatting; + (function (formatting) { + (function (FormattingRequestKind) { + FormattingRequestKind[FormattingRequestKind["FormatDocument"] = 0] = "FormatDocument"; + FormattingRequestKind[FormattingRequestKind["FormatSelection"] = 1] = "FormatSelection"; + FormattingRequestKind[FormattingRequestKind["FormatOnEnter"] = 2] = "FormatOnEnter"; + FormattingRequestKind[FormattingRequestKind["FormatOnSemicolon"] = 3] = "FormatOnSemicolon"; + FormattingRequestKind[FormattingRequestKind["FormatOnClosingCurlyBrace"] = 4] = "FormatOnClosingCurlyBrace"; + })(formatting.FormattingRequestKind || (formatting.FormattingRequestKind = {})); + var FormattingRequestKind = formatting.FormattingRequestKind; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var formatting; (function (formatting) { @@ -57452,6 +58959,19 @@ var ts; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var formatting; + (function (formatting) { + (function (RuleAction) { + RuleAction[RuleAction["Ignore"] = 1] = "Ignore"; + RuleAction[RuleAction["Space"] = 2] = "Space"; + RuleAction[RuleAction["NewLine"] = 4] = "NewLine"; + RuleAction[RuleAction["Delete"] = 8] = "Delete"; + })(formatting.RuleAction || (formatting.RuleAction = {})); + var RuleAction = formatting.RuleAction; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var formatting; (function (formatting) { @@ -57482,6 +59002,17 @@ var ts; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var formatting; + (function (formatting) { + (function (RuleFlags) { + RuleFlags[RuleFlags["None"] = 0] = "None"; + RuleFlags[RuleFlags["CanDeleteNewLines"] = 1] = "CanDeleteNewLines"; + })(formatting.RuleFlags || (formatting.RuleFlags = {})); + var RuleFlags = formatting.RuleFlags; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var formatting; (function (formatting) { @@ -57546,88 +59077,88 @@ var ts; function Rules() { this.IgnoreBeforeComment = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.Comments), formatting.RuleOperation.create1(1)); this.IgnoreAfterLineComment = new formatting.Rule(formatting.RuleDescriptor.create3(2, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create1(1)); - this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(54, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 2)); - this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(53, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsConditionalOperatorContext), 2)); - this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(53, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(23, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2)); - this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(16, 80), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(16, 104), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 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.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(21, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceBeforeOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), 8)); + this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 55), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(55, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 2)); + this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(54, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsConditionalOperatorContext), 2)); + this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(54, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2)); + this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(17, 81), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(17, 105), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.FromTokens([19, 21, 25, 24])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 22), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(22, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(21, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, 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([69, 3, 73, 82, 89]); - 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, 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)); - this.NoSpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 8)); - this.NoSpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 8)); - this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectContext), 8)); - 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.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); + this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([70, 3, 74, 83, 90]); + this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); + this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([19, 3, 80, 101, 86, 81]); + this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); + this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, 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, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2)); + this.NoSpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 8)); + this.NoSpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 8)); + this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(16, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectContext), 8)); + this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(16, 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, 17), 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.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(41, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(42, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 41), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 42), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(41, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(35, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(35, 41), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(42, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(36, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36, 42), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - 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.IsNonJsxSameLineTokenContext), 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.IsNonJsxSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2)); - this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8)); - 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.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 8)); - this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(103, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsVoidOpContext), 2)); - this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(94, 23), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 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.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, 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.IsNonJsxSameLineTokenContext), 2)); - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123, 131]), 69), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(42, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(43, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 42), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 43), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(42, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(36, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(36, 42), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(43, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(37, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(37, 43), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 25), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([103, 99, 93, 79, 95, 102, 120]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([109, 75]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2)); + this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8)); + this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(88, 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, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 8)); + this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(104, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsVoidOpContext), 2)); + this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(95, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([19, 80, 81, 72]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNotForContext), 2)); + this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([101, 86]), 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([124, 132]), 70), 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.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(121, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([125, 129]), 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 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, 131, 113, 134, 136]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([83, 106, 136])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2)); - this.SpaceBeforeArrow = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 34), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(34, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(22, 69), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(53, formatting.Shared.TokenRange.FromTokens([18, 24])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 25), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); - this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(18, 25), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); - this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(25, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); - this.NoSpaceBeforeCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 27), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); - this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(27, formatting.Shared.TokenRange.FromTokens([17, 19, 27, 24])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); - this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectTypeContext), 8)); - this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 55), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(55, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 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, 131, 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.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2)); - this.SpaceBetweenAsyncAndOpenParen = new formatting.Rule(formatting.RuleDescriptor.create1(118, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(118, 87), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(69, formatting.Shared.TokenRange.FromTokens([11, 12])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceBeforeJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 69), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNextTokenParentJsxAttribute, Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceBeforeSlashInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 39), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create1(39, 27), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceBeforeEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 56), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create3(56, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(122, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([126, 130]), 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116, 74, 123, 78, 82, 83, 84, 124, 107, 90, 108, 126, 127, 111, 113, 112, 132, 114, 135, 137]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([84, 107, 137])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2)); + this.SpaceBeforeArrow = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(35, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(23, 70), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(54, formatting.Shared.TokenRange.FromTokens([19, 25])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 26), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(19, 26), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(26, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceBeforeCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 28), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(28, formatting.Shared.TokenRange.FromTokens([18, 20, 28, 25])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(16, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectTypeContext), 8)); + this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 56), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(56, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([116, 70, 83, 78, 74, 114, 113, 111, 112, 124, 132, 20, 38])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); + this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(88, 38), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8)); + this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(38, formatting.Shared.TokenRange.FromTokens([70, 18])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2)); + this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(115, 38), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8)); + this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([115, 38]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2)); + this.SpaceBetweenAsyncAndOpenParen = new formatting.Rule(formatting.RuleDescriptor.create1(119, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(119, 88), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(70, formatting.Shared.TokenRange.FromTokens([12, 13])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceBeforeJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 70), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNextTokenParentJsxAttribute, Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceBeforeSlashInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 40), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create1(40, 28), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 57), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create3(57, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8)); this.HighPriorityCommonRules = [ this.IgnoreBeforeComment, this.IgnoreAfterLineComment, this.NoSpaceBeforeColon, this.SpaceAfterColon, this.NoSpaceBeforeQuestionMark, this.SpaceAfterQuestionMarkInConditionalOperator, @@ -57682,41 +59213,41 @@ var ts; this.NoSpaceBeforeOpenParenInFuncDecl, this.SpaceBetweenStatements, this.SpaceAfterTryFinally ]; - this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNextTokenNotCloseBracket), 2)); - this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext), 8)); + this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(25, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNextTokenNotCloseBracket), 2)); + this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(25, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext), 8)); this.SpaceBeforeBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.SpaceAfterBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.NoSpaceBeforeBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 8)); this.NoSpaceAfterBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 8)); - this.SpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 2)); - this.NoSpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 8)); - this.NewLineBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 4), 1); - this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 4), 1); - this.NewLineBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), 4), 1); - this.SpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(23, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 2)); - this.NoSpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(23, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 8)); - this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(17, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceBetweenBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(19, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - 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.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([12, 13]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - 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.IsNonJsxSameLineTokenContext), 8)); - this.SpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([13, 14])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(15, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8)); - this.SpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(15, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2)); - this.NoSpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8)); - this.SpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2)); - 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)); - this.NoSpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(27, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 8)); - this.SpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(27, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 2)); + this.SpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 2)); + this.NoSpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 8)); + this.NewLineBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 4), 1); + this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 4), 1); + this.NewLineBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), 4), 1); + this.SpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 2)); + this.NoSpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 8)); + this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(18, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(18, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(18, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceBetweenBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(20, 21), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([13, 14]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([13, 14]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([14, 15])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([14, 15])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8)); + this.SpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2)); + this.NoSpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8)); + this.SpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2)); + this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(88, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(88, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8)); + this.NoSpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(28, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 8)); + this.SpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(28, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 2)); } Rules.prototype.getRuleName = function (rule) { var o = this; @@ -57728,35 +59259,35 @@ var ts; throw new Error("Unknown rule"); }; Rules.IsForContext = function (context) { - return context.contextNode.kind === 206; + return context.contextNode.kind === 207; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 187: case 188: - case 195: - case 238: - case 234: - case 154: - case 162: + case 189: + case 196: + case 239: + case 235: + case 155: case 163: + case 164: return true; - case 169: - case 223: - case 229: - case 218: - case 142: + case 170: + case 224: + case 230: + case 219: + case 143: case 255: + case 146: case 145: - case 144: - return context.currentTokenSpan.kind === 56 || context.nextTokenSpan.kind === 56; - case 207: - return context.currentTokenSpan.kind === 90 || context.nextTokenSpan.kind === 90; + return context.currentTokenSpan.kind === 57 || context.nextTokenSpan.kind === 57; case 208: - return context.currentTokenSpan.kind === 138 || context.nextTokenSpan.kind === 138; + return context.currentTokenSpan.kind === 91 || context.nextTokenSpan.kind === 91; + case 209: + return context.currentTokenSpan.kind === 139 || context.nextTokenSpan.kind === 139; } return false; }; @@ -57764,7 +59295,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 188; + return context.contextNode.kind === 189; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); @@ -57789,76 +59320,76 @@ var ts; return true; } switch (node.kind) { - case 199: + case 200: + case 228: + case 172: case 227: - case 171: - case 226: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 220: + case 221: + case 148: case 147: - case 146: - case 149: case 150: case 151: - case 179: - case 148: + case 152: case 180: - case 222: + case 149: + case 181: + case 223: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 220 || context.contextNode.kind === 179; + return context.contextNode.kind === 221 || context.contextNode.kind === 180; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 221: - case 192: case 222: - case 224: - case 159: + case 193: + case 223: case 225: - case 236: + case 160: + case 226: case 237: - case 230: - case 233: + case 238: + case 231: + case 234: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 221: - case 225: - case 224: - case 199: - case 252: + case 222: case 226: - case 213: + case 225: + case 200: + case 252: + case 227: + case 214: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 203: - case 213: - case 206: + case 204: + case 214: case 207: case 208: + case 209: + case 206: + case 217: case 205: - case 216: - case 204: - case 212: + case 213: case 252: return true; default: @@ -57866,31 +59397,31 @@ var ts; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 171; + return context.contextNode.kind === 172; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 174; + return context.contextNode.kind === 175; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 175; + return context.contextNode.kind === 176; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); }; Rules.IsPreviousTokenNotComma = function (context) { - return context.currentTokenSpan.kind !== 24; + return context.currentTokenSpan.kind !== 25; }; Rules.IsNextTokenNotCloseBracket = function (context) { - return context.nextTokenSpan.kind !== 20; + return context.nextTokenSpan.kind !== 21; }; Rules.IsArrowFunctionContext = function (context) { - return context.contextNode.kind === 180; + return context.contextNode.kind === 181; }; Rules.IsNonJsxSameLineTokenContext = function (context) { - return context.TokensAreOnSameLine() && context.contextNode.kind !== 244; + return context.TokensAreOnSameLine() && context.contextNode.kind !== 10; }; Rules.IsNonJsxElementContext = function (context) { - return context.contextNode.kind !== 241; + return context.contextNode.kind !== 242; }; Rules.IsJsxExpressionContext = function (context) { return context.contextNode.kind === 248; @@ -57902,7 +59433,7 @@ var ts; return context.contextNode.kind === 246; }; Rules.IsJsxSelfClosingElementContext = function (context) { - return context.contextNode.kind === 242; + return context.contextNode.kind === 243; }; Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); @@ -57917,41 +59448,41 @@ var ts; while (ts.isPartOfExpression(node)) { node = node.parent; } - return node.kind === 143; + return node.kind === 144; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 219 && + return context.currentTokenParent.kind === 220 && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { return context.formattingRequestKind !== 2; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 225; + return context.contextNode.kind === 226; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 159; + return context.contextNode.kind === 160; }; Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { - if (token.kind !== 25 && token.kind !== 27) { + if (token.kind !== 26 && token.kind !== 28) { return false; } switch (parent.kind) { - case 155: - case 177: - case 221: - case 192: + case 156: + case 178: case 222: - case 220: - case 179: + case 193: + case 223: + case 221: case 180: + case 181: + case 148: case 147: - case 146: - case 151: case 152: - case 174: + case 153: case 175: - case 194: + case 176: + case 195: return true; default: return false; @@ -57962,13 +59493,13 @@ var ts; Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsTypeAssertionContext = function (context) { - return context.contextNode.kind === 177; + return context.contextNode.kind === 178; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 103 && context.currentTokenParent.kind === 183; + return context.currentTokenSpan.kind === 104 && context.currentTokenParent.kind === 184; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 190 && context.contextNode.expression !== undefined; + return context.contextNode.kind === 191 && context.contextNode.expression !== undefined; }; return Rules; }()); @@ -57990,7 +59521,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 138 + 1; + this.mapRowLength = 139 + 1; this.map = new Array(this.mapRowLength * this.mapRowLength); var rulesBucketConstructionStateList = new Array(this.map.length); this.FillRules(rules, rulesBucketConstructionStateList); @@ -58003,6 +59534,7 @@ var ts; }); }; RulesMap.prototype.GetRuleBucketIndex = function (row, column) { + ts.Debug.assert(row <= 139 && column <= 139, "Must compute formatting context from tokens"); var rulesBucketIndex = (row * this.mapRowLength) + column; return rulesBucketIndex; }; @@ -58166,12 +59698,12 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0; token <= 138; token++) { + for (var token = 0; token <= 139; token++) { result.push(token); } return result; }; - TokenAllAccess.prototype.Contains = function (tokenValue) { + TokenAllAccess.prototype.Contains = function () { return true; }; TokenAllAccess.prototype.toString = function () { @@ -58210,17 +59742,17 @@ var ts; }()); TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3])); - TokenRange.Keywords = TokenRange.FromRange(70, 138); - TokenRange.BinaryOperators = TokenRange.FromRange(25, 68); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([90, 91, 138, 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.Keywords = TokenRange.FromRange(71, 139); + TokenRange.BinaryOperators = TokenRange.FromRange(26, 69); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([91, 92, 139, 117, 125]); + TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([42, 43, 51, 50]); + TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8, 70, 18, 20, 16, 98, 93]); + TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([70, 18, 98, 93]); + TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([70, 19, 21, 93]); + TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([70, 18, 98, 93]); + TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([70, 19, 21, 93]); TokenRange.Comments = TokenRange.FromTokens([2, 3]); - TokenRange.TypeNames = TokenRange.FromTokens([69, 130, 132, 120, 133, 103, 117]); + TokenRange.TypeNames = TokenRange.FromTokens([70, 131, 133, 121, 134, 104, 118]); Shared.TokenRange = TokenRange; })(Shared = formatting.Shared || (formatting.Shared = {})); })(formatting = ts.formatting || (ts.formatting = {})); @@ -58356,6 +59888,10 @@ var ts; (function (ts) { var formatting; (function (formatting) { + var Constants; + (function (Constants) { + Constants[Constants["Unknown"] = -1] = "Unknown"; + })(Constants || (Constants = {})); function formatOnEnter(position, sourceFile, rulesProvider, options) { var line = sourceFile.getLineAndCharacterOfPosition(position).line; if (line === 0) { @@ -58376,11 +59912,11 @@ var ts; } formatting.formatOnEnter = formatOnEnter; function formatOnSemicolon(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 23, sourceFile, options, rulesProvider, 3); + return formatOutermostParent(position, 24, sourceFile, options, rulesProvider, 3); } formatting.formatOnSemicolon = formatOnSemicolon; function formatOnClosingCurly(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 16, sourceFile, options, rulesProvider, 4); + return formatOutermostParent(position, 17, sourceFile, options, rulesProvider, 4); } formatting.formatOnClosingCurly = formatOnClosingCurly; function formatDocument(sourceFile, rulesProvider, options) { @@ -58428,15 +59964,15 @@ var ts; } function isListElement(parent, node) { switch (parent.kind) { - case 221: case 222: + case 223: return ts.rangeContainsRange(parent.members, node); - case 225: - var body = parent.body; - return body && body.kind === 226 && ts.rangeContainsRange(body.statements, node); - case 256: - case 199: case 226: + var body = parent.body; + return body && body.kind === 227 && ts.rangeContainsRange(body.statements, node); + case 256: + case 200: + case 227: return ts.rangeContainsRange(parent.statements, node); case 252: return ts.rangeContainsRange(parent.block.statements, node); @@ -58482,7 +60018,7 @@ var ts; index++; } }; - function rangeHasNoErrors(r) { + function rangeHasNoErrors() { return false; } } @@ -58594,18 +60130,18 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 221: return 73; - case 222: return 107; - case 220: return 87; - case 224: return 224; - case 149: return 123; - case 150: return 131; - case 147: + case 222: return 74; + case 223: return 108; + case 221: return 88; + case 225: return 225; + case 150: return 124; + case 151: return 132; + case 148: if (node.asteriskToken) { - return 37; + return 38; } - case 145: - case 142: + case 146: + case 143: return node.name.kind; } } @@ -58613,9 +60149,9 @@ var ts; return { getIndentationForComment: function (kind, tokenIndentation, container) { switch (kind) { - case 16: - case 20: - case 18: + case 17: + case 21: + case 19: return indentation + getEffectiveDelta(delta, container); } return tokenIndentation !== -1 ? tokenIndentation : indentation; @@ -58627,15 +60163,15 @@ var ts; } } switch (kind) { - case 15: case 16: - case 19: - case 20: case 17: + case 20: + case 21: case 18: - case 80: - case 104: - case 55: + case 19: + case 81: + case 105: + case 56: return indentation; default: return nodeStartLine !== line ? indentation + getEffectiveDelta(delta, container) : indentation; @@ -58715,17 +60251,17 @@ var ts; if (!formattingScanner.isOnToken()) { return inheritedIndentation; } - if (ts.isToken(child)) { + if (ts.isToken(child) && child.kind !== 10) { var tokenInfo = formattingScanner.readTokenInfo(child); - ts.Debug.assert(tokenInfo.token.end === child.end); + ts.Debug.assert(tokenInfo.token.end === child.end, "Token end is child end"); consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 143 ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 144 ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; - if (isFirstListItem && parent.kind === 170 && inheritedIndentation === -1) { + if (isFirstListItem && parent.kind === 171 && inheritedIndentation === -1) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -59029,41 +60565,41 @@ var ts; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 148: - case 220: - case 179: - case 147: - case 146: + case 149: + case 221: case 180: + case 148: + case 147: + case 181: if (node.typeParameters === list) { - return 25; + return 26; } else if (node.parameters === list) { - return 17; + return 18; } break; - case 174: case 175: + case 176: if (node.typeArguments === list) { - return 25; + return 26; } else if (node.arguments === list) { - return 17; + return 18; } break; - case 155: + case 156: if (node.typeArguments === list) { - return 25; + return 26; } } return 0; } function getCloseTokenForOpenToken(kind) { switch (kind) { - case 17: - return 18; - case 25: - return 27; + case 18: + return 19; + case 26: + return 28; } return 0; } @@ -59124,6 +60660,10 @@ var ts; (function (formatting) { var SmartIndenter; (function (SmartIndenter) { + var Value; + (function (Value) { + Value[Value["Unknown"] = -1] = "Unknown"; + })(Value || (Value = {})); function getIndentation(position, sourceFile, options) { if (position > sourceFile.text.length) { return getBaseIndentation(options); @@ -59152,7 +60692,7 @@ var ts; var lineStart = ts.getLineStartPositionForPosition(current_1, sourceFile); return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current_1, sourceFile, options); } - if (precedingToken.kind === 24 && precedingToken.parent.kind !== 187) { + if (precedingToken.kind === 25 && precedingToken.parent.kind !== 188) { var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1) { return actualIndentation; @@ -59265,10 +60805,10 @@ var ts; if (!nextToken) { return false; } - if (nextToken.kind === 15) { + if (nextToken.kind === 16) { return true; } - else if (nextToken.kind === 16) { + else if (nextToken.kind === 17) { var nextTokenStartLine = getStartLineAndCharacterForNode(nextToken, sourceFile).line; return lineAtPosition === nextTokenStartLine; } @@ -59278,8 +60818,8 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 203 && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 80, sourceFile); + if (parent.kind === 204 && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 81, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -59290,23 +60830,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 155: + case 156: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 171: + case 172: return node.parent.properties; - case 170: + case 171: return node.parent.elements; - case 220: - case 179: + case 221: case 180: + case 181: + case 148: case 147: - case 146: - case 151: - case 152: { + case 152: + case 153: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -59317,8 +60857,8 @@ var ts; } break; } - case 175: - case 174: { + case 176: + case 175: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -59343,11 +60883,11 @@ var ts; } } function getLineIndentationWhenExpressionIsInMultiLine(node, sourceFile, options) { - if (node.kind === 18) { + if (node.kind === 19) { return -1; } - if (node.parent && (node.parent.kind === 174 || - node.parent.kind === 175) && + if (node.parent && (node.parent.kind === 175 || + node.parent.kind === 176) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -59365,10 +60905,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 174: case 175: - case 172: + case 176: case 173: + case 174: node = node.expression; break; default: @@ -59382,7 +60922,7 @@ var ts; var node = list[index]; var lineAndCharacter = getStartLineAndCharacterForNode(node, sourceFile); for (var i = index - 1; i >= 0; i--) { - if (list[i].kind === 24) { + if (list[i].kind === 25) { continue; } var prevEndLine = sourceFile.getLineAndCharacterOfPosition(list[i].end).line; @@ -59422,48 +60962,48 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 202: - case 221: - case 192: + case 203: case 222: - case 224: + case 193: case 223: - case 170: - case 199: - case 226: + case 225: + case 224: case 171: - case 159: - case 161: + case 200: case 227: + case 172: + case 160: + case 162: + case 228: case 250: case 249: - case 178: - case 172: - case 174: + case 179: + case 173: case 175: - case 200: - case 218: - case 235: - case 211: - case 188: - case 168: - case 167: - case 243: - case 242: - case 248: - case 146: - case 151: - case 152: - case 142: - case 156: - case 157: - case 164: case 176: - case 184: - case 237: - case 233: + case 201: + case 219: + case 236: + case 212: + case 189: + case 169: + case 168: + case 244: + case 243: + case 248: + case 147: + case 152: + case 153: + case 143: + case 157: + case 158: + case 165: + case 177: + case 185: case 238: case 234: + case 239: + case 235: return true; } return false; @@ -59471,26 +61011,26 @@ var ts; function nodeWillIndentChild(parent, child, indentByDefault) { var childKind = child ? child.kind : 0; switch (parent.kind) { - case 204: case 205: - case 207: - case 208: case 206: - case 203: - case 220: - case 179: - case 147: + case 208: + case 209: + case 207: + case 204: + case 221: case 180: case 148: + case 181: case 149: case 150: - return childKind !== 199; - case 236: - return childKind !== 237; - case 230: - return childKind !== 231 || - (child.namedBindings && child.namedBindings.kind !== 233); - case 241: + case 151: + return childKind !== 200; + case 237: + return childKind !== 238; + case 231: + return childKind !== 232 || + (child.namedBindings && child.namedBindings.kind !== 234); + case 242: return childKind !== 245; } return indentByDefault; @@ -59549,7 +61089,7 @@ var ts; getCodeActions: function (context) { var sourceFile = context.sourceFile; var token = ts.getTokenAtPosition(sourceFile, context.span.start); - if (token.kind !== 121) { + if (token.kind !== 122) { return undefined; } var newPosition = getOpenBraceEnd(token.parent, sourceFile); @@ -59564,7 +61104,7 @@ var ts; getCodeActions: function (context) { var sourceFile = context.sourceFile; var token = ts.getTokenAtPosition(sourceFile, context.span.start); - if (token.kind !== 97) { + if (token.kind !== 98) { return undefined; } var constructor = ts.getContainingFunction(token); @@ -59572,7 +61112,7 @@ var ts; if (!superCall) { return undefined; } - if (superCall.expression && superCall.expression.kind == 174) { + if (superCall.expression && superCall.expression.kind == 175) { var arguments_1 = superCall.expression.arguments; for (var i = 0; i < arguments_1.length; i++) { if (arguments_1[i].expression === token) { @@ -59596,7 +61136,7 @@ var ts; changes: changes }]; function findSuperCall(n) { - if (n.kind === 202 && ts.isSuperCall(n.expression)) { + if (n.kind === 203 && ts.isSuperCall(n.expression)) { return n; } if (ts.isFunctionLike(n)) { @@ -59612,8 +61152,8 @@ var ts; (function (ts) { ts.servicesVersion = "0.5"; function createNode(kind, pos, end, parent) { - var node = kind >= 139 ? new NodeObject(kind, pos, end) : - kind === 69 ? new IdentifierObject(69, pos, end) : + var node = kind >= 140 ? new NodeObject(kind, pos, end) : + kind === 70 ? new IdentifierObject(70, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; return node; @@ -59690,7 +61230,7 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 139) { + if (this.kind >= 140) { ts.scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos_3 = this.pos; @@ -59748,7 +61288,7 @@ var ts; return undefined; } var child = children[0]; - return child.kind < 139 ? child : child.getFirstToken(sourceFile); + return child.kind < 140 ? child : child.getFirstToken(sourceFile); }; NodeObject.prototype.getLastToken = function (sourceFile) { var children = this.getChildren(sourceFile); @@ -59756,7 +61296,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 139 ? child : child.getLastToken(sourceFile); + return child.kind < 140 ? child : child.getLastToken(sourceFile); }; return NodeObject; }()); @@ -59794,19 +61334,19 @@ var ts; TokenOrIdentifierObject.prototype.getText = function (sourceFile) { return (sourceFile || this.getSourceFile()).text.substring(this.getStart(), this.getEnd()); }; - TokenOrIdentifierObject.prototype.getChildCount = function (sourceFile) { + TokenOrIdentifierObject.prototype.getChildCount = function () { return 0; }; - TokenOrIdentifierObject.prototype.getChildAt = function (index, sourceFile) { + TokenOrIdentifierObject.prototype.getChildAt = function () { return undefined; }; - TokenOrIdentifierObject.prototype.getChildren = function (sourceFile) { + TokenOrIdentifierObject.prototype.getChildren = function () { return ts.emptyArray; }; - TokenOrIdentifierObject.prototype.getFirstToken = function (sourceFile) { + TokenOrIdentifierObject.prototype.getFirstToken = function () { return undefined; }; - TokenOrIdentifierObject.prototype.getLastToken = function (sourceFile) { + TokenOrIdentifierObject.prototype.getLastToken = function () { return undefined; }; return TokenOrIdentifierObject; @@ -59827,7 +61367,7 @@ var ts; }; SymbolObject.prototype.getDocumentationComment = function () { if (this.documentationComment === undefined) { - this.documentationComment = ts.JsDoc.getJsDocCommentsFromDeclarations(this.declarations, this.name, !(this.flags & 4)); + this.documentationComment = ts.JsDoc.getJsDocCommentsFromDeclarations(this.declarations); } return this.documentationComment; }; @@ -59844,12 +61384,12 @@ var ts; }(TokenOrIdentifierObject)); var IdentifierObject = (function (_super) { __extends(IdentifierObject, _super); - function IdentifierObject(kind, pos, end) { + function IdentifierObject(_kind, pos, end) { return _super.call(this, pos, end) || this; } return IdentifierObject; }(TokenOrIdentifierObject)); - IdentifierObject.prototype.kind = 69; + IdentifierObject.prototype.kind = 70; var TypeObject = (function () { function TypeObject(checker, flags) { this.checker = checker; @@ -59910,7 +61450,7 @@ var ts; }; SignatureObject.prototype.getDocumentationComment = function () { if (this.documentationComment === undefined) { - this.documentationComment = this.declaration ? ts.JsDoc.getJsDocCommentsFromDeclarations([this.declaration], undefined, false) : []; + this.documentationComment = this.declaration ? ts.JsDoc.getJsDocCommentsFromDeclarations([this.declaration]) : []; } return this.documentationComment; }; @@ -59958,9 +61498,9 @@ var ts; if (result_6 !== undefined) { return result_6; } - if (declaration.name.kind === 140) { + if (declaration.name.kind === 141) { var expr = declaration.name.expression; - if (expr.kind === 172) { + if (expr.kind === 173) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -59970,7 +61510,7 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 69 || + if (node.kind === 70 || node.kind === 9 || node.kind === 8) { return node.text; @@ -59980,10 +61520,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 220: - case 179: + case 221: + case 180: + case 148: case 147: - case 146: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -60000,30 +61540,30 @@ var ts; ts.forEachChild(node, visit); } break; - case 221: - case 192: case 222: + case 193: case 223: case 224: case 225: - case 229: - case 238: - case 234: - case 229: - case 231: + case 226: + case 230: + case 239: + case 235: + case 230: case 232: - case 149: + case 233: case 150: - case 159: + case 151: + case 160: addDeclaration(node); ts.forEachChild(node, visit); break; - case 142: + case 143: if (!ts.hasModifier(node, 92)) { break; } - case 218: - case 169: { + case 219: + case 170: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -60033,23 +61573,23 @@ var ts; visit(decl.initializer); } case 255: + case 146: case 145: - case 144: addDeclaration(node); break; - case 236: + case 237: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 230: + case 231: var importClause = node.importClause; if (importClause) { if (importClause.name) { addDeclaration(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 232) { + if (importClause.namedBindings.kind === 233) { addDeclaration(importClause.namedBindings); } else { @@ -60073,7 +61613,7 @@ var ts; getSourceFileConstructor: function () { return SourceFileObject; }, getSymbolConstructor: function () { return SymbolObject; }, getTypeConstructor: function () { return TypeObject; }, - getSignatureConstructor: function () { return SignatureObject; } + getSignatureConstructor: function () { return SignatureObject; }, }; } function toEditorSettings(optionsAsMap) { @@ -60165,7 +61705,7 @@ var ts; }; HostCache.prototype.getRootFileNames = function () { var fileNames = []; - this.fileNameToEntry.forEachValue(function (path, value) { + this.fileNameToEntry.forEachValue(function (_path, value) { if (value) { fileNames.push(value.hostFileName); } @@ -60195,7 +61735,7 @@ var ts; var version = this.host.getScriptVersion(fileName); var sourceFile; if (this.currentFileName !== fileName) { - sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 2, version, true, scriptKind); + sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 4, version, true, scriptKind); } else if (this.currentFileVersion !== version) { var editRange = scriptSnapshot.getChangeRange(this.currentFileScriptSnapshot); @@ -60348,7 +61888,7 @@ var ts; useCaseSensitiveFileNames: function () { return useCaseSensitivefileNames; }, getNewLine: function () { return ts.getNewLineOrDefaultFromHost(host); }, getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); }, - writeFile: function (fileName, data, writeByteOrderMark) { }, + writeFile: function () { }, getCurrentDirectory: function () { return currentDirectory; }, fileExists: function (fileName) { return hostCache.getOrCreateEntry(fileName) !== undefined; @@ -60490,12 +62030,12 @@ var ts; var symbol = typeChecker.getSymbolAtLocation(node); if (!symbol || typeChecker.isUnknownSymbol(symbol)) { switch (node.kind) { - case 69: - case 172: - case 139: - case 97: - case 165: - case 95: + case 70: + case 173: + case 140: + case 98: + case 166: + case 96: var type = typeChecker.getTypeAtLocation(node); if (type) { return { @@ -60616,23 +62156,23 @@ var ts; function getSourceFile(fileName) { return getNonBoundSourceFile(fileName); } - function getNameOrDottedNameSpan(fileName, startPos, endPos) { + function getNameOrDottedNameSpan(fileName, startPos, _endPos) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); var node = ts.getTouchingPropertyName(sourceFile, startPos); if (node === sourceFile) { return; } switch (node.kind) { - case 172: - case 139: + case 173: + case 140: case 9: - case 84: - case 99: - case 93: - case 95: - case 97: - case 165: - case 69: + case 85: + case 100: + case 94: + case 96: + case 98: + case 166: + case 70: break; default: return; @@ -60643,7 +62183,7 @@ var ts; nodeForStartPos = nodeForStartPos.parent; } else if (ts.isNameOfModuleDeclaration(nodeForStartPos)) { - if (nodeForStartPos.parent.parent.kind === 225 && + if (nodeForStartPos.parent.parent.kind === 226 && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { nodeForStartPos = nodeForStartPos.parent.parent.name; } @@ -60723,14 +62263,14 @@ var ts; return result; function getMatchingTokenKind(token) { switch (token.kind) { - case 15: return 16; - case 17: return 18; - case 19: return 20; - case 25: return 27; - case 16: return 15; - case 18: return 17; - case 20: return 19; - case 27: return 25; + case 16: return 17; + case 18: return 19; + case 20: return 21; + case 26: return 28; + case 17: return 16; + case 19: return 18; + case 21: return 20; + case 28: return 26; } return undefined; } @@ -60933,13 +62473,13 @@ var ts; sourceFile.nameTable = nameTable; function walk(node) { switch (node.kind) { - case 69: + case 70: nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; break; case 9: case 8: if (ts.isDeclarationName(node) || - node.parent.kind === 240 || + node.parent.kind === 241 || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node)) { nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; @@ -60959,7 +62499,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 173 && + node.parent.kind === 174 && node.parent.argumentExpression === node; } function getDefaultLibFilePath(options) { @@ -60974,6 +62514,933 @@ var ts; } initializeServices(); })(ts || (ts = {})); +var debugObjectHost = (function () { return this; })(); +var ts; +(function (ts) { + function logInternalError(logger, err) { + if (logger) { + logger.log("*INTERNAL ERROR* - Exception in typescript services: " + err.message); + } + } + var ScriptSnapshotShimAdapter = (function () { + function ScriptSnapshotShimAdapter(scriptSnapshotShim) { + this.scriptSnapshotShim = scriptSnapshotShim; + } + ScriptSnapshotShimAdapter.prototype.getText = function (start, end) { + return this.scriptSnapshotShim.getText(start, end); + }; + ScriptSnapshotShimAdapter.prototype.getLength = function () { + return this.scriptSnapshotShim.getLength(); + }; + ScriptSnapshotShimAdapter.prototype.getChangeRange = function (oldSnapshot) { + var oldSnapshotShim = oldSnapshot; + var encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim); + if (encoded == null) { + return null; + } + var decoded = JSON.parse(encoded); + return ts.createTextChangeRange(ts.createTextSpan(decoded.span.start, decoded.span.length), decoded.newLength); + }; + ScriptSnapshotShimAdapter.prototype.dispose = function () { + if ("dispose" in this.scriptSnapshotShim) { + this.scriptSnapshotShim.dispose(); + } + }; + return ScriptSnapshotShimAdapter; + }()); + var LanguageServiceShimHostAdapter = (function () { + function LanguageServiceShimHostAdapter(shimHost) { + var _this = this; + this.shimHost = shimHost; + this.loggingEnabled = false; + this.tracingEnabled = false; + if ("getModuleResolutionsForFile" in this.shimHost) { + this.resolveModuleNames = function (moduleNames, containingFile) { + var resolutionsInFile = JSON.parse(_this.shimHost.getModuleResolutionsForFile(containingFile)); + return ts.map(moduleNames, function (name) { + var result = ts.getProperty(resolutionsInFile, name); + return result ? { resolvedFileName: result } : undefined; + }); + }; + } + if ("directoryExists" in this.shimHost) { + this.directoryExists = function (directoryName) { return _this.shimHost.directoryExists(directoryName); }; + } + if ("getTypeReferenceDirectiveResolutionsForFile" in this.shimHost) { + this.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile) { + var typeDirectivesForFile = JSON.parse(_this.shimHost.getTypeReferenceDirectiveResolutionsForFile(containingFile)); + return ts.map(typeDirectiveNames, function (name) { return ts.getProperty(typeDirectivesForFile, name); }); + }; + } + } + LanguageServiceShimHostAdapter.prototype.log = function (s) { + if (this.loggingEnabled) { + this.shimHost.log(s); + } + }; + LanguageServiceShimHostAdapter.prototype.trace = function (s) { + if (this.tracingEnabled) { + this.shimHost.trace(s); + } + }; + LanguageServiceShimHostAdapter.prototype.error = function (s) { + this.shimHost.error(s); + }; + LanguageServiceShimHostAdapter.prototype.getProjectVersion = function () { + if (!this.shimHost.getProjectVersion) { + return undefined; + } + return this.shimHost.getProjectVersion(); + }; + LanguageServiceShimHostAdapter.prototype.getTypeRootsVersion = function () { + if (!this.shimHost.getTypeRootsVersion) { + return 0; + } + return this.shimHost.getTypeRootsVersion(); + }; + LanguageServiceShimHostAdapter.prototype.useCaseSensitiveFileNames = function () { + return this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false; + }; + LanguageServiceShimHostAdapter.prototype.getCompilationSettings = function () { + var settingsJson = this.shimHost.getCompilationSettings(); + if (settingsJson == null || settingsJson == "") { + throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); + } + return JSON.parse(settingsJson); + }; + LanguageServiceShimHostAdapter.prototype.getScriptFileNames = function () { + var encoded = this.shimHost.getScriptFileNames(); + return this.files = JSON.parse(encoded); + }; + LanguageServiceShimHostAdapter.prototype.getScriptSnapshot = function (fileName) { + var scriptSnapshot = this.shimHost.getScriptSnapshot(fileName); + return scriptSnapshot && new ScriptSnapshotShimAdapter(scriptSnapshot); + }; + LanguageServiceShimHostAdapter.prototype.getScriptKind = function (fileName) { + if ("getScriptKind" in this.shimHost) { + return this.shimHost.getScriptKind(fileName); + } + else { + return 0; + } + }; + LanguageServiceShimHostAdapter.prototype.getScriptVersion = function (fileName) { + return this.shimHost.getScriptVersion(fileName); + }; + LanguageServiceShimHostAdapter.prototype.getLocalizedDiagnosticMessages = function () { + var diagnosticMessagesJson = this.shimHost.getLocalizedDiagnosticMessages(); + if (diagnosticMessagesJson == null || diagnosticMessagesJson == "") { + return null; + } + try { + return JSON.parse(diagnosticMessagesJson); + } + catch (e) { + this.log(e.description || "diagnosticMessages.generated.json has invalid JSON format"); + return null; + } + }; + LanguageServiceShimHostAdapter.prototype.getCancellationToken = function () { + var hostCancellationToken = this.shimHost.getCancellationToken(); + return new ThrottledCancellationToken(hostCancellationToken); + }; + LanguageServiceShimHostAdapter.prototype.getCurrentDirectory = function () { + return this.shimHost.getCurrentDirectory(); + }; + LanguageServiceShimHostAdapter.prototype.getDirectories = function (path) { + return JSON.parse(this.shimHost.getDirectories(path)); + }; + LanguageServiceShimHostAdapter.prototype.getDefaultLibFileName = function (options) { + return this.shimHost.getDefaultLibFileName(JSON.stringify(options)); + }; + LanguageServiceShimHostAdapter.prototype.readDirectory = function (path, extensions, exclude, include, depth) { + var pattern = ts.getFileMatcherPatterns(path, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); + return JSON.parse(this.shimHost.readDirectory(path, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); + }; + LanguageServiceShimHostAdapter.prototype.readFile = function (path, encoding) { + return this.shimHost.readFile(path, encoding); + }; + LanguageServiceShimHostAdapter.prototype.fileExists = function (path) { + return this.shimHost.fileExists(path); + }; + return LanguageServiceShimHostAdapter; + }()); + ts.LanguageServiceShimHostAdapter = LanguageServiceShimHostAdapter; + var ThrottledCancellationToken = (function () { + function ThrottledCancellationToken(hostCancellationToken) { + this.hostCancellationToken = hostCancellationToken; + this.lastCancellationCheckTime = 0; + } + ThrottledCancellationToken.prototype.isCancellationRequested = function () { + var time = ts.timestamp(); + var duration = Math.abs(time - this.lastCancellationCheckTime); + if (duration > 10) { + this.lastCancellationCheckTime = time; + return this.hostCancellationToken.isCancellationRequested(); + } + return false; + }; + return ThrottledCancellationToken; + }()); + var CoreServicesShimHostAdapter = (function () { + function CoreServicesShimHostAdapter(shimHost) { + var _this = this; + this.shimHost = shimHost; + this.useCaseSensitiveFileNames = this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false; + if ("directoryExists" in this.shimHost) { + this.directoryExists = function (directoryName) { return _this.shimHost.directoryExists(directoryName); }; + } + if ("realpath" in this.shimHost) { + this.realpath = function (path) { return _this.shimHost.realpath(path); }; + } + } + CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extensions, exclude, include, depth) { + try { + var pattern = ts.getFileMatcherPatterns(rootDir, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); + return JSON.parse(this.shimHost.readDirectory(rootDir, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); + } + catch (e) { + var results = []; + for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) { + var extension = extensions_2[_i]; + for (var _a = 0, _b = this.readDirectoryFallback(rootDir, extension, exclude); _a < _b.length; _a++) { + var file = _b[_a]; + if (!ts.contains(results, file)) { + results.push(file); + } + } + } + return results; + } + }; + CoreServicesShimHostAdapter.prototype.fileExists = function (fileName) { + return this.shimHost.fileExists(fileName); + }; + CoreServicesShimHostAdapter.prototype.readFile = function (fileName) { + return this.shimHost.readFile(fileName); + }; + CoreServicesShimHostAdapter.prototype.readDirectoryFallback = function (rootDir, extension, exclude) { + return JSON.parse(this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude))); + }; + CoreServicesShimHostAdapter.prototype.getDirectories = function (path) { + return JSON.parse(this.shimHost.getDirectories(path)); + }; + return CoreServicesShimHostAdapter; + }()); + ts.CoreServicesShimHostAdapter = CoreServicesShimHostAdapter; + function simpleForwardCall(logger, actionDescription, action, logPerformance) { + var start; + if (logPerformance) { + logger.log(actionDescription); + start = ts.timestamp(); + } + var result = action(); + if (logPerformance) { + var end = ts.timestamp(); + logger.log(actionDescription + " completed in " + (end - start) + " msec"); + if (typeof result === "string") { + var str = result; + if (str.length > 128) { + str = str.substring(0, 128) + "..."; + } + logger.log(" result.length=" + str.length + ", result='" + JSON.stringify(str) + "'"); + } + } + return result; + } + function forwardJSONCall(logger, actionDescription, action, logPerformance) { + return forwardCall(logger, actionDescription, true, action, logPerformance); + } + function forwardCall(logger, actionDescription, returnJson, action, logPerformance) { + try { + var result = simpleForwardCall(logger, actionDescription, action, logPerformance); + return returnJson ? JSON.stringify({ result: result }) : result; + } + catch (err) { + if (err instanceof ts.OperationCanceledException) { + return JSON.stringify({ canceled: true }); + } + logInternalError(logger, err); + err.description = actionDescription; + return JSON.stringify({ error: err }); + } + } + var ShimBase = (function () { + function ShimBase(factory) { + this.factory = factory; + factory.registerShim(this); + } + ShimBase.prototype.dispose = function (_dummy) { + this.factory.unregisterShim(this); + }; + return ShimBase; + }()); + function realizeDiagnostics(diagnostics, newLine) { + return diagnostics.map(function (d) { return realizeDiagnostic(d, newLine); }); + } + ts.realizeDiagnostics = realizeDiagnostics; + function realizeDiagnostic(diagnostic, newLine) { + return { + message: ts.flattenDiagnosticMessageText(diagnostic.messageText, newLine), + start: diagnostic.start, + length: diagnostic.length, + category: ts.DiagnosticCategory[diagnostic.category].toLowerCase(), + code: diagnostic.code + }; + } + var LanguageServiceShimObject = (function (_super) { + __extends(LanguageServiceShimObject, _super); + function LanguageServiceShimObject(factory, host, languageService) { + var _this = _super.call(this, factory) || this; + _this.host = host; + _this.languageService = languageService; + _this.logPerformance = false; + _this.logger = _this.host; + return _this; + } + LanguageServiceShimObject.prototype.forwardJSONCall = function (actionDescription, action) { + return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); + }; + LanguageServiceShimObject.prototype.dispose = function (dummy) { + this.logger.log("dispose()"); + this.languageService.dispose(); + this.languageService = null; + if (debugObjectHost && debugObjectHost.CollectGarbage) { + debugObjectHost.CollectGarbage(); + this.logger.log("CollectGarbage()"); + } + this.logger = null; + _super.prototype.dispose.call(this, dummy); + }; + LanguageServiceShimObject.prototype.refresh = function (throwOnError) { + this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; }); + }; + LanguageServiceShimObject.prototype.cleanupSemanticCache = function () { + var _this = this; + this.forwardJSONCall("cleanupSemanticCache()", function () { + _this.languageService.cleanupSemanticCache(); + return null; + }); + }; + LanguageServiceShimObject.prototype.realizeDiagnostics = function (diagnostics) { + var newLine = ts.getNewLineOrDefaultFromHost(this.host); + return ts.realizeDiagnostics(diagnostics, newLine); + }; + LanguageServiceShimObject.prototype.getSyntacticClassifications = function (fileName, start, length) { + var _this = this; + return this.forwardJSONCall("getSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSyntacticClassifications(fileName, ts.createTextSpan(start, length)); }); + }; + LanguageServiceShimObject.prototype.getSemanticClassifications = function (fileName, start, length) { + var _this = this; + return this.forwardJSONCall("getSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSemanticClassifications(fileName, ts.createTextSpan(start, length)); }); + }; + LanguageServiceShimObject.prototype.getEncodedSyntacticClassifications = function (fileName, start, length) { + var _this = this; + return this.forwardJSONCall("getEncodedSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return convertClassifications(_this.languageService.getEncodedSyntacticClassifications(fileName, ts.createTextSpan(start, length))); }); + }; + LanguageServiceShimObject.prototype.getEncodedSemanticClassifications = function (fileName, start, length) { + var _this = this; + return this.forwardJSONCall("getEncodedSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return convertClassifications(_this.languageService.getEncodedSemanticClassifications(fileName, ts.createTextSpan(start, length))); }); + }; + LanguageServiceShimObject.prototype.getSyntacticDiagnostics = function (fileName) { + var _this = this; + return this.forwardJSONCall("getSyntacticDiagnostics('" + fileName + "')", function () { + var diagnostics = _this.languageService.getSyntacticDiagnostics(fileName); + return _this.realizeDiagnostics(diagnostics); + }); + }; + LanguageServiceShimObject.prototype.getSemanticDiagnostics = function (fileName) { + var _this = this; + return this.forwardJSONCall("getSemanticDiagnostics('" + fileName + "')", function () { + var diagnostics = _this.languageService.getSemanticDiagnostics(fileName); + return _this.realizeDiagnostics(diagnostics); + }); + }; + LanguageServiceShimObject.prototype.getCompilerOptionsDiagnostics = function () { + var _this = this; + return this.forwardJSONCall("getCompilerOptionsDiagnostics()", function () { + var diagnostics = _this.languageService.getCompilerOptionsDiagnostics(); + return _this.realizeDiagnostics(diagnostics); + }); + }; + LanguageServiceShimObject.prototype.getQuickInfoAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getQuickInfoAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getQuickInfoAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getNameOrDottedNameSpan = function (fileName, startPos, endPos) { + var _this = this; + return this.forwardJSONCall("getNameOrDottedNameSpan('" + fileName + "', " + startPos + ", " + endPos + ")", function () { return _this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos); }); + }; + LanguageServiceShimObject.prototype.getBreakpointStatementAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getBreakpointStatementAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBreakpointStatementAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getSignatureHelpItems = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getSignatureHelpItems('" + fileName + "', " + position + ")", function () { return _this.languageService.getSignatureHelpItems(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getDefinitionAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDefinitionAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getTypeDefinitionAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getTypeDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getTypeDefinitionAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getImplementationAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getImplementationAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getImplementationAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position); }); + }; + LanguageServiceShimObject.prototype.findRenameLocations = function (fileName, position, findInStrings, findInComments) { + var _this = this; + return this.forwardJSONCall("findRenameLocations('" + fileName + "', " + position + ", " + findInStrings + ", " + findInComments + ")", function () { return _this.languageService.findRenameLocations(fileName, position, findInStrings, findInComments); }); + }; + LanguageServiceShimObject.prototype.getBraceMatchingAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getBraceMatchingAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBraceMatchingAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.isValidBraceCompletionAtPosition = function (fileName, position, openingBrace) { + var _this = this; + return this.forwardJSONCall("isValidBraceCompletionAtPosition('" + fileName + "', " + position + ", " + openingBrace + ")", function () { return _this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace); }); + }; + LanguageServiceShimObject.prototype.getIndentationAtPosition = function (fileName, position, options) { + var _this = this; + return this.forwardJSONCall("getIndentationAtPosition('" + fileName + "', " + position + ")", function () { + var localOptions = JSON.parse(options); + return _this.languageService.getIndentationAtPosition(fileName, position, localOptions); + }); + }; + LanguageServiceShimObject.prototype.getReferencesAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getReferencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getReferencesAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.findReferences = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("findReferences('" + fileName + "', " + position + ")", function () { return _this.languageService.findReferences(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getOccurrencesAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getOccurrencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getOccurrencesAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getDocumentHighlights = function (fileName, position, filesToSearch) { + var _this = this; + return this.forwardJSONCall("getDocumentHighlights('" + fileName + "', " + position + ")", function () { + var results = _this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); + var normalizedName = ts.normalizeSlashes(fileName).toLowerCase(); + return ts.filter(results, function (r) { return ts.normalizeSlashes(r.fileName).toLowerCase() === normalizedName; }); + }); + }; + LanguageServiceShimObject.prototype.getCompletionsAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getCompletionsAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName) { + var _this = this; + return this.forwardJSONCall("getCompletionEntryDetails('" + fileName + "', " + position + ", '" + entryName + "')", function () { return _this.languageService.getCompletionEntryDetails(fileName, position, entryName); }); + }; + LanguageServiceShimObject.prototype.getFormattingEditsForRange = function (fileName, start, end, options) { + var _this = this; + return this.forwardJSONCall("getFormattingEditsForRange('" + fileName + "', " + start + ", " + end + ")", function () { + var localOptions = JSON.parse(options); + return _this.languageService.getFormattingEditsForRange(fileName, start, end, localOptions); + }); + }; + LanguageServiceShimObject.prototype.getFormattingEditsForDocument = function (fileName, options) { + var _this = this; + return this.forwardJSONCall("getFormattingEditsForDocument('" + fileName + "')", function () { + var localOptions = JSON.parse(options); + return _this.languageService.getFormattingEditsForDocument(fileName, localOptions); + }); + }; + LanguageServiceShimObject.prototype.getFormattingEditsAfterKeystroke = function (fileName, position, key, options) { + var _this = this; + return this.forwardJSONCall("getFormattingEditsAfterKeystroke('" + fileName + "', " + position + ", '" + key + "')", function () { + var localOptions = JSON.parse(options); + return _this.languageService.getFormattingEditsAfterKeystroke(fileName, position, key, localOptions); + }); + }; + LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getNavigateToItems = function (searchValue, maxResultCount, fileName) { + var _this = this; + return this.forwardJSONCall("getNavigateToItems('" + searchValue + "', " + maxResultCount + ", " + fileName + ")", function () { return _this.languageService.getNavigateToItems(searchValue, maxResultCount, fileName); }); + }; + LanguageServiceShimObject.prototype.getNavigationBarItems = function (fileName) { + var _this = this; + return this.forwardJSONCall("getNavigationBarItems('" + fileName + "')", function () { return _this.languageService.getNavigationBarItems(fileName); }); + }; + LanguageServiceShimObject.prototype.getNavigationTree = function (fileName) { + var _this = this; + return this.forwardJSONCall("getNavigationTree('" + fileName + "')", function () { return _this.languageService.getNavigationTree(fileName); }); + }; + LanguageServiceShimObject.prototype.getOutliningSpans = function (fileName) { + var _this = this; + return this.forwardJSONCall("getOutliningSpans('" + fileName + "')", function () { return _this.languageService.getOutliningSpans(fileName); }); + }; + LanguageServiceShimObject.prototype.getTodoComments = function (fileName, descriptors) { + var _this = this; + return this.forwardJSONCall("getTodoComments('" + fileName + "')", function () { return _this.languageService.getTodoComments(fileName, JSON.parse(descriptors)); }); + }; + LanguageServiceShimObject.prototype.getEmitOutput = function (fileName) { + var _this = this; + return this.forwardJSONCall("getEmitOutput('" + fileName + "')", function () { return _this.languageService.getEmitOutput(fileName); }); + }; + LanguageServiceShimObject.prototype.getEmitOutputObject = function (fileName) { + var _this = this; + return forwardCall(this.logger, "getEmitOutput('" + fileName + "')", false, function () { return _this.languageService.getEmitOutput(fileName); }, this.logPerformance); + }; + return LanguageServiceShimObject; + }(ShimBase)); + function convertClassifications(classifications) { + return { spans: classifications.spans.join(","), endOfLineState: classifications.endOfLineState }; + } + var ClassifierShimObject = (function (_super) { + __extends(ClassifierShimObject, _super); + function ClassifierShimObject(factory, logger) { + var _this = _super.call(this, factory) || this; + _this.logger = logger; + _this.logPerformance = false; + _this.classifier = ts.createClassifier(); + return _this; + } + ClassifierShimObject.prototype.getEncodedLexicalClassifications = function (text, lexState, syntacticClassifierAbsent) { + var _this = this; + return forwardJSONCall(this.logger, "getEncodedLexicalClassifications", function () { return convertClassifications(_this.classifier.getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent)); }, this.logPerformance); + }; + ClassifierShimObject.prototype.getClassificationsForLine = function (text, lexState, classifyKeywordsInGenerics) { + var classification = this.classifier.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics); + var result = ""; + for (var _i = 0, _a = classification.entries; _i < _a.length; _i++) { + var item = _a[_i]; + result += item.length + "\n"; + result += item.classification + "\n"; + } + result += classification.finalLexState; + return result; + }; + return ClassifierShimObject; + }(ShimBase)); + var CoreServicesShimObject = (function (_super) { + __extends(CoreServicesShimObject, _super); + function CoreServicesShimObject(factory, logger, host) { + var _this = _super.call(this, factory) || this; + _this.logger = logger; + _this.host = host; + _this.logPerformance = false; + return _this; + } + CoreServicesShimObject.prototype.forwardJSONCall = function (actionDescription, action) { + return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); + }; + CoreServicesShimObject.prototype.resolveModuleName = function (fileName, moduleName, compilerOptionsJson) { + var _this = this; + return this.forwardJSONCall("resolveModuleName('" + fileName + "')", function () { + var compilerOptions = JSON.parse(compilerOptionsJson); + var result = ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host); + return { + resolvedFileName: result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined, + failedLookupLocations: result.failedLookupLocations + }; + }); + }; + CoreServicesShimObject.prototype.resolveTypeReferenceDirective = function (fileName, typeReferenceDirective, compilerOptionsJson) { + var _this = this; + return this.forwardJSONCall("resolveTypeReferenceDirective(" + fileName + ")", function () { + var compilerOptions = JSON.parse(compilerOptionsJson); + var result = ts.resolveTypeReferenceDirective(typeReferenceDirective, ts.normalizeSlashes(fileName), compilerOptions, _this.host); + return { + resolvedFileName: result.resolvedTypeReferenceDirective ? result.resolvedTypeReferenceDirective.resolvedFileName : undefined, + primary: result.resolvedTypeReferenceDirective ? result.resolvedTypeReferenceDirective.primary : true, + failedLookupLocations: result.failedLookupLocations + }; + }); + }; + CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { + var _this = this; + return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { + var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()), true, true); + return { + referencedFiles: _this.convertFileReferences(result.referencedFiles), + importedFiles: _this.convertFileReferences(result.importedFiles), + ambientExternalModules: result.ambientExternalModules, + isLibFile: result.isLibFile, + typeReferenceDirectives: _this.convertFileReferences(result.typeReferenceDirectives) + }; + }); + }; + CoreServicesShimObject.prototype.getAutomaticTypeDirectiveNames = function (compilerOptionsJson) { + var _this = this; + return this.forwardJSONCall("getAutomaticTypeDirectiveNames('" + compilerOptionsJson + "')", function () { + var compilerOptions = JSON.parse(compilerOptionsJson); + return ts.getAutomaticTypeDirectiveNames(compilerOptions, _this.host); + }); + }; + CoreServicesShimObject.prototype.convertFileReferences = function (refs) { + if (!refs) { + return undefined; + } + var result = []; + for (var _i = 0, refs_2 = refs; _i < refs_2.length; _i++) { + var ref = refs_2[_i]; + result.push({ + path: ts.normalizeSlashes(ref.fileName), + position: ref.pos, + length: ref.end - ref.pos + }); + } + return result; + }; + CoreServicesShimObject.prototype.getTSConfigFileInfo = function (fileName, sourceTextSnapshot) { + var _this = this; + return this.forwardJSONCall("getTSConfigFileInfo('" + fileName + "')", function () { + var text = sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()); + var result = ts.parseConfigFileTextToJson(fileName, text); + if (result.error) { + return { + options: {}, + typingOptions: {}, + files: [], + raw: {}, + errors: [realizeDiagnostic(result.error, "\r\n")] + }; + } + var normalizedFileName = ts.normalizeSlashes(fileName); + var configFile = ts.parseJsonConfigFileContent(result.config, _this.host, ts.getDirectoryPath(normalizedFileName), {}, normalizedFileName); + return { + options: configFile.options, + typingOptions: configFile.typingOptions, + files: configFile.fileNames, + raw: configFile.raw, + errors: realizeDiagnostics(configFile.errors, "\r\n") + }; + }); + }; + CoreServicesShimObject.prototype.getDefaultCompilationSettings = function () { + return this.forwardJSONCall("getDefaultCompilationSettings()", function () { return ts.getDefaultCompilerOptions(); }); + }; + CoreServicesShimObject.prototype.discoverTypings = function (discoverTypingsJson) { + var _this = this; + var getCanonicalFileName = ts.createGetCanonicalFileName(false); + return this.forwardJSONCall("discoverTypings()", function () { + var info = JSON.parse(discoverTypingsJson); + return ts.JsTyping.discoverTypings(_this.host, info.fileNames, ts.toPath(info.projectRootPath, info.projectRootPath, getCanonicalFileName), ts.toPath(info.safeListPath, info.safeListPath, getCanonicalFileName), info.packageNameToTypingLocation, info.typingOptions); + }); + }; + return CoreServicesShimObject; + }(ShimBase)); + var TypeScriptServicesFactory = (function () { + function TypeScriptServicesFactory() { + this._shims = []; + } + TypeScriptServicesFactory.prototype.getServicesVersion = function () { + return ts.servicesVersion; + }; + TypeScriptServicesFactory.prototype.createLanguageServiceShim = function (host) { + try { + if (this.documentRegistry === undefined) { + this.documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory()); + } + var hostAdapter = new LanguageServiceShimHostAdapter(host); + var languageService = ts.createLanguageService(hostAdapter, this.documentRegistry); + return new LanguageServiceShimObject(this, host, languageService); + } + catch (err) { + logInternalError(host, err); + throw err; + } + }; + TypeScriptServicesFactory.prototype.createClassifierShim = function (logger) { + try { + return new ClassifierShimObject(this, logger); + } + catch (err) { + logInternalError(logger, err); + throw err; + } + }; + TypeScriptServicesFactory.prototype.createCoreServicesShim = function (host) { + try { + var adapter = new CoreServicesShimHostAdapter(host); + return new CoreServicesShimObject(this, host, adapter); + } + catch (err) { + logInternalError(host, err); + throw err; + } + }; + TypeScriptServicesFactory.prototype.close = function () { + this._shims = []; + this.documentRegistry = undefined; + }; + TypeScriptServicesFactory.prototype.registerShim = function (shim) { + this._shims.push(shim); + }; + TypeScriptServicesFactory.prototype.unregisterShim = function (shim) { + for (var i = 0, n = this._shims.length; i < n; i++) { + if (this._shims[i] === shim) { + delete this._shims[i]; + return; + } + } + throw new Error("Invalid operation"); + }; + return TypeScriptServicesFactory; + }()); + ts.TypeScriptServicesFactory = TypeScriptServicesFactory; + if (typeof module !== "undefined" && module.exports) { + module.exports = ts; + } +})(ts || (ts = {})); +var TypeScript; +(function (TypeScript) { + var Services; + (function (Services) { + Services.TypeScriptServicesFactory = ts.TypeScriptServicesFactory; + })(Services = TypeScript.Services || (TypeScript.Services = {})); +})(TypeScript || (TypeScript = {})); +var toolsVersion = "2.1"; +var ts; +(function (ts) { + var server; + (function (server) { + (function (LogLevel) { + LogLevel[LogLevel["terse"] = 0] = "terse"; + LogLevel[LogLevel["normal"] = 1] = "normal"; + LogLevel[LogLevel["requestTime"] = 2] = "requestTime"; + LogLevel[LogLevel["verbose"] = 3] = "verbose"; + })(server.LogLevel || (server.LogLevel = {})); + var LogLevel = server.LogLevel; + server.emptyArray = []; + var Msg; + (function (Msg) { + Msg.Err = "Err"; + Msg.Info = "Info"; + Msg.Perf = "Perf"; + })(Msg = server.Msg || (server.Msg = {})); + function getProjectRootPath(project) { + switch (project.projectKind) { + case server.ProjectKind.Configured: + return ts.getDirectoryPath(project.getProjectName()); + case server.ProjectKind.Inferred: + return ""; + case server.ProjectKind.External: + var projectName = ts.normalizeSlashes(project.getProjectName()); + return project.projectService.host.fileExists(projectName) ? ts.getDirectoryPath(projectName) : projectName; + } + } + function createInstallTypingsRequest(project, typingOptions, cachePath) { + return { + projectName: project.getProjectName(), + fileNames: project.getFileNames(), + compilerOptions: project.getCompilerOptions(), + typingOptions: typingOptions, + projectRootPath: getProjectRootPath(project), + cachePath: cachePath, + kind: "discover" + }; + } + server.createInstallTypingsRequest = createInstallTypingsRequest; + var Errors; + (function (Errors) { + function ThrowNoProject() { + throw new Error("No Project."); + } + Errors.ThrowNoProject = ThrowNoProject; + function ThrowProjectLanguageServiceDisabled() { + throw new Error("The project's language service is disabled."); + } + Errors.ThrowProjectLanguageServiceDisabled = ThrowProjectLanguageServiceDisabled; + function ThrowProjectDoesNotContainDocument(fileName, project) { + throw new Error("Project '" + project.getProjectName() + "' does not contain document '" + fileName + "'"); + } + Errors.ThrowProjectDoesNotContainDocument = ThrowProjectDoesNotContainDocument; + })(Errors = server.Errors || (server.Errors = {})); + function getDefaultFormatCodeSettings(host) { + return { + indentSize: 4, + tabSize: 4, + newLineCharacter: host.newLine || "\n", + convertTabsToSpaces: true, + indentStyle: ts.IndentStyle.Smart, + insertSpaceAfterCommaDelimiter: true, + insertSpaceAfterSemicolonInForStatements: true, + insertSpaceBeforeAndAfterBinaryOperators: true, + insertSpaceAfterKeywordsInControlFlowStatements: true, + insertSpaceAfterFunctionKeywordForAnonymousFunctions: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, + insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, + insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, + placeOpenBraceOnNewLineForFunctions: false, + placeOpenBraceOnNewLineForControlBlocks: false, + }; + } + server.getDefaultFormatCodeSettings = getDefaultFormatCodeSettings; + function mergeMaps(target, source) { + for (var key in source) { + if (ts.hasProperty(source, key)) { + target[key] = source[key]; + } + } + } + server.mergeMaps = mergeMaps; + function removeItemFromSet(items, itemToRemove) { + if (items.length === 0) { + return; + } + var index = items.indexOf(itemToRemove); + if (index < 0) { + return; + } + if (index === items.length - 1) { + items.pop(); + } + else { + items[index] = items.pop(); + } + } + server.removeItemFromSet = removeItemFromSet; + function toNormalizedPath(fileName) { + return ts.normalizePath(fileName); + } + server.toNormalizedPath = toNormalizedPath; + function normalizedPathToPath(normalizedPath, currentDirectory, getCanonicalFileName) { + var f = ts.isRootedDiskPath(normalizedPath) ? normalizedPath : ts.getNormalizedAbsolutePath(normalizedPath, currentDirectory); + return getCanonicalFileName(f); + } + server.normalizedPathToPath = normalizedPathToPath; + function asNormalizedPath(fileName) { + return fileName; + } + server.asNormalizedPath = asNormalizedPath; + function createNormalizedPathMap() { + var map = Object.create(null); + return { + get: function (path) { + return map[path]; + }, + set: function (path, value) { + map[path] = value; + }, + contains: function (path) { + return ts.hasProperty(map, path); + }, + remove: function (path) { + delete map[path]; + } + }; + } + server.createNormalizedPathMap = createNormalizedPathMap; + function throwLanguageServiceIsDisabledError() { + throw new Error("LanguageService is disabled"); + } + server.nullLanguageService = { + cleanupSemanticCache: throwLanguageServiceIsDisabledError, + getSyntacticDiagnostics: throwLanguageServiceIsDisabledError, + getSemanticDiagnostics: throwLanguageServiceIsDisabledError, + getCompilerOptionsDiagnostics: throwLanguageServiceIsDisabledError, + getSyntacticClassifications: throwLanguageServiceIsDisabledError, + getEncodedSyntacticClassifications: throwLanguageServiceIsDisabledError, + getSemanticClassifications: throwLanguageServiceIsDisabledError, + getEncodedSemanticClassifications: throwLanguageServiceIsDisabledError, + getCompletionsAtPosition: throwLanguageServiceIsDisabledError, + findReferences: throwLanguageServiceIsDisabledError, + getCompletionEntryDetails: throwLanguageServiceIsDisabledError, + getQuickInfoAtPosition: throwLanguageServiceIsDisabledError, + findRenameLocations: throwLanguageServiceIsDisabledError, + getNameOrDottedNameSpan: throwLanguageServiceIsDisabledError, + getBreakpointStatementAtPosition: throwLanguageServiceIsDisabledError, + getBraceMatchingAtPosition: throwLanguageServiceIsDisabledError, + getSignatureHelpItems: throwLanguageServiceIsDisabledError, + getDefinitionAtPosition: throwLanguageServiceIsDisabledError, + getRenameInfo: throwLanguageServiceIsDisabledError, + getTypeDefinitionAtPosition: throwLanguageServiceIsDisabledError, + getReferencesAtPosition: throwLanguageServiceIsDisabledError, + getDocumentHighlights: throwLanguageServiceIsDisabledError, + getOccurrencesAtPosition: throwLanguageServiceIsDisabledError, + getNavigateToItems: throwLanguageServiceIsDisabledError, + getNavigationBarItems: throwLanguageServiceIsDisabledError, + getNavigationTree: throwLanguageServiceIsDisabledError, + getOutliningSpans: throwLanguageServiceIsDisabledError, + getTodoComments: throwLanguageServiceIsDisabledError, + getIndentationAtPosition: throwLanguageServiceIsDisabledError, + getFormattingEditsForRange: throwLanguageServiceIsDisabledError, + getFormattingEditsForDocument: throwLanguageServiceIsDisabledError, + getFormattingEditsAfterKeystroke: throwLanguageServiceIsDisabledError, + getDocCommentTemplateAtPosition: throwLanguageServiceIsDisabledError, + isValidBraceCompletionAtPosition: throwLanguageServiceIsDisabledError, + getEmitOutput: throwLanguageServiceIsDisabledError, + getProgram: throwLanguageServiceIsDisabledError, + getNonBoundSourceFile: throwLanguageServiceIsDisabledError, + dispose: throwLanguageServiceIsDisabledError, + getCompletionEntrySymbol: throwLanguageServiceIsDisabledError, + getImplementationAtPosition: throwLanguageServiceIsDisabledError, + getSourceFile: throwLanguageServiceIsDisabledError, + getCodeFixesAtPosition: throwLanguageServiceIsDisabledError + }; + server.nullLanguageServiceHost = { + setCompilationSettings: function () { return undefined; }, + notifyFileRemoved: function () { return undefined; } + }; + function isInferredProjectName(name) { + return /dev\/null\/inferredProject\d+\*/.test(name); + } + server.isInferredProjectName = isInferredProjectName; + function makeInferredProjectName(counter) { + return "/dev/null/inferredProject" + counter + "*"; + } + server.makeInferredProjectName = makeInferredProjectName; + var ThrottledOperations = (function () { + function ThrottledOperations(host) { + this.host = host; + this.pendingTimeouts = ts.createMap(); + } + ThrottledOperations.prototype.schedule = function (operationId, delay, cb) { + if (ts.hasProperty(this.pendingTimeouts, operationId)) { + this.host.clearTimeout(this.pendingTimeouts[operationId]); + } + this.pendingTimeouts[operationId] = this.host.setTimeout(ThrottledOperations.run, delay, this, operationId, cb); + }; + ThrottledOperations.run = function (self, operationId, cb) { + delete self.pendingTimeouts[operationId]; + cb(); + }; + return ThrottledOperations; + }()); + server.ThrottledOperations = ThrottledOperations; + var GcTimer = (function () { + function GcTimer(host, delay, logger) { + this.host = host; + this.delay = delay; + this.logger = logger; + } + GcTimer.prototype.scheduleCollect = function () { + if (!this.host.gc || this.timerId != undefined) { + return; + } + this.timerId = this.host.setTimeout(GcTimer.run, this.delay, this); + }; + GcTimer.run = function (self) { + self.timerId = undefined; + var log = self.logger.hasLevel(LogLevel.requestTime); + var before = log && self.host.getMemoryUsage(); + self.host.gc(); + if (log) { + var after = self.host.getMemoryUsage(); + self.logger.perftrc("GC::before " + before + ", after " + after); + } + }; + return GcTimer; + }()); + server.GcTimer = GcTimer; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); var ts; (function (ts) { var server; @@ -61045,7 +63512,6 @@ var ts; if (this.containingProjects.length === 0) { return server.Errors.ThrowNoProject(); } - ts.Debug.assert(this.containingProjects.length !== 0); return this.containingProjects[0]; }; ScriptInfo.prototype.setFormatOptions = function (formatSettings) { @@ -61077,12 +63543,12 @@ var ts; var snap = this.snap(); this.host.writeFile(fileName, snap.getText(0, snap.getLength())); }; - ScriptInfo.prototype.reloadFromFile = function () { + ScriptInfo.prototype.reloadFromFile = function (tempFileName) { if (this.hasMixedContent) { this.reload(""); } else { - this.svc.reloadFromFile(this.fileName); + this.svc.reloadFromFile(tempFileName || this.fileName); this.markContainingProjectsAsDirty(); } }; @@ -61294,8 +63760,8 @@ var ts; (function (server) { server.nullTypingsInstaller = { enqueueInstallTypingsRequest: function () { }, - attach: function (projectService) { }, - onProjectClosed: function (p) { }, + attach: function () { }, + onProjectClosed: function () { }, globalTypingsCacheLocation: undefined }; var TypingsCacheEntry = (function () { @@ -61411,7 +63877,7 @@ var ts; BuilderFileInfo.prototype.containsOnlyAmbientModules = function (sourceFile) { for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var statement = _a[_i]; - if (statement.kind !== 225 || statement.name.kind !== 9) { + if (statement.kind !== 226 || statement.name.kind !== 9) { return false; } } @@ -61473,7 +63939,7 @@ var ts; this.fileInfos.remove(path); }; AbstractBuilder.prototype.forEachFileInfo = function (action) { - this.fileInfos.forEachValue(function (path, value) { return action(value); }); + this.fileInfos.forEachValue(function (_path, value) { return action(value); }); }; AbstractBuilder.prototype.emitFile = function (scriptInfo, writeFile) { var fileInfo = this.getFileInfo(scriptInfo.path); @@ -62037,11 +64503,11 @@ var ts; this.markAsDirty(); } }; - Project.prototype.reloadScript = function (filename) { + Project.prototype.reloadScript = function (filename, tempFileName) { var script = this.projectService.getScriptInfoForNormalizedPath(filename); if (script) { ts.Debug.assert(script.isAttached(this)); - script.reloadFromFile(); + script.reloadFromFile(tempFileName); return true; } return false; @@ -62332,6 +64798,66 @@ var ts; var server; (function (server) { server.maxProgramSizeForNonTsFiles = 20 * 1024 * 1024; + function prepareConvertersForEnumLikeCompilerOptions(commandLineOptions) { + var map = ts.createMap(); + for (var _i = 0, commandLineOptions_1 = commandLineOptions; _i < commandLineOptions_1.length; _i++) { + var option = commandLineOptions_1[_i]; + if (typeof option.type === "object") { + var optionMap = option.type; + for (var id in optionMap) { + ts.Debug.assert(typeof optionMap[id] === "number"); + } + map[option.name] = optionMap; + } + } + return map; + } + var compilerOptionConverters = prepareConvertersForEnumLikeCompilerOptions(ts.optionDeclarations); + var indentStyle = ts.createMap({ + "none": ts.IndentStyle.None, + "block": ts.IndentStyle.Block, + "smart": ts.IndentStyle.Smart + }); + function convertFormatOptions(protocolOptions) { + if (typeof protocolOptions.indentStyle === "string") { + protocolOptions.indentStyle = indentStyle[protocolOptions.indentStyle.toLowerCase()]; + ts.Debug.assert(protocolOptions.indentStyle !== undefined); + } + return protocolOptions; + } + server.convertFormatOptions = convertFormatOptions; + function convertCompilerOptions(protocolOptions) { + for (var id in compilerOptionConverters) { + var propertyValue = protocolOptions[id]; + if (typeof propertyValue === "string") { + var mappedValues = compilerOptionConverters[id]; + protocolOptions[id] = mappedValues[propertyValue.toLowerCase()]; + } + } + return protocolOptions; + } + server.convertCompilerOptions = convertCompilerOptions; + function tryConvertScriptKindName(scriptKindName) { + return typeof scriptKindName === "string" + ? convertScriptKindName(scriptKindName) + : scriptKindName; + } + server.tryConvertScriptKindName = tryConvertScriptKindName; + function convertScriptKindName(scriptKindName) { + switch (scriptKindName) { + case "JS": + return 1; + case "JSX": + return 2; + case "TS": + return 3; + case "TSX": + return 4; + default: + return 0; + } + } + server.convertScriptKindName = convertScriptKindName; function combineProjectOutput(projects, action, comparer, areEqual) { var result = projects.reduce(function (previous, current) { return ts.concatenate(previous, action(current)); }, []).sort(comparer); return projects.length > 1 ? ts.deduplicate(result, areEqual) : result; @@ -62344,7 +64870,7 @@ var ts; }; var externalFilePropertyReader = { getFileName: function (x) { return x.fileName; }, - getScriptKind: function (x) { return x.scriptKind; }, + getScriptKind: function (x) { return tryConvertScriptKindName(x.scriptKind); }, hasMixedContent: function (x) { return x.hasMixedContent; } }; function findProjectByName(projectName, projects) { @@ -62429,6 +64955,9 @@ var ts; ProjectService.prototype.ensureInferredProjectsUpToDate_TestOnly = function () { this.ensureInferredProjectsUpToDate(); }; + ProjectService.prototype.getCompilerOptionsForInferredProjects = function () { + return this.compilerOptionsForInferredProjects; + }; ProjectService.prototype.updateTypingsForProject = function (response) { var project = this.findProject(response.projectName); if (!project) { @@ -62445,11 +64974,11 @@ var ts; } }; ProjectService.prototype.setCompilerOptionsForInferredProjects = function (projectCompilerOptions) { - this.compilerOptionsForInferredProjects = projectCompilerOptions; + this.compilerOptionsForInferredProjects = convertCompilerOptions(projectCompilerOptions); this.compileOnSaveForInferredProjects = projectCompilerOptions.compileOnSave; for (var _i = 0, _a = this.inferredProjects; _i < _a.length; _i++) { var proj = _a[_i]; - proj.setCompilerOptions(projectCompilerOptions); + proj.setCompilerOptions(this.compilerOptionsForInferredProjects); proj.compileOnSaveEnabled = projectCompilerOptions.compileOnSave; } this.updateProjectGraphs(this.inferredProjects); @@ -62573,12 +65102,12 @@ var ts; return; } this.logger.info("Detected source file changes: " + fileName); - this.throttledOperations.schedule(project.configFileName, 250, function () { return _this.handleChangeInSourceFileForConfiguredProject(project); }); + this.throttledOperations.schedule(project.configFileName, 250, function () { return _this.handleChangeInSourceFileForConfiguredProject(project, fileName); }); }; - ProjectService.prototype.handleChangeInSourceFileForConfiguredProject = function (project) { + ProjectService.prototype.handleChangeInSourceFileForConfiguredProject = function (project, triggerFile) { var _this = this; var _a = this.convertConfigFileContentToProjectOptions(project.configFileName), projectOptions = _a.projectOptions, configFileErrors = _a.configFileErrors; - this.reportConfigFileDiagnostics(project.getProjectName(), configFileErrors); + this.reportConfigFileDiagnostics(project.getProjectName(), configFileErrors, triggerFile); var newRootFiles = projectOptions.files.map((function (f) { return _this.getCanonicalFileName(f); })); var currentRootFiles = project.getRootFiles().map((function (f) { return _this.getCanonicalFileName(f); })); if (!ts.arrayIsEqualTo(currentRootFiles.sort(), newRootFiles.sort())) { @@ -62598,7 +65127,7 @@ var ts; return; } var configFileErrors = this.convertConfigFileContentToProjectOptions(fileName).configFileErrors; - this.reportConfigFileDiagnostics(fileName, configFileErrors); + this.reportConfigFileDiagnostics(fileName, configFileErrors, fileName); this.logger.info("Detected newly added tsconfig file: " + fileName); this.reloadProjects(); }; @@ -62829,7 +65358,8 @@ var ts; return false; }; ProjectService.prototype.createAndAddExternalProject = function (projectFileName, files, options, typingOptions) { - var project = new server.ExternalProject(projectFileName, this, this.documentRegistry, options, !this.exceededTotalSizeLimitForNonTsFiles(options, files, externalFilePropertyReader), options.compileOnSave === undefined ? true : options.compileOnSave); + var compilerOptions = convertCompilerOptions(options); + var project = new server.ExternalProject(projectFileName, this, this.documentRegistry, compilerOptions, !this.exceededTotalSizeLimitForNonTsFiles(compilerOptions, files, externalFilePropertyReader), options.compileOnSave === undefined ? true : options.compileOnSave); this.addFilesToProjectAndUpdateGraph(project, files, externalFilePropertyReader, undefined, typingOptions, undefined); this.externalProjects.push(project); return project; @@ -63051,7 +65581,7 @@ var ts; if (args.file) { var info = this.getScriptInfoForNormalizedPath(server.toNormalizedPath(args.file)); if (info) { - info.setFormatOptions(args.formatOptions); + info.setFormatOptions(convertFormatOptions(args.formatOptions)); this.logger.info("Host configuration update for file " + args.file); } } @@ -63061,7 +65591,7 @@ var ts; this.logger.info("Host information " + args.hostInfo); } if (args.formatOptions) { - server.mergeMaps(this.hostConfiguration.formatCodeOptions, args.formatOptions); + server.mergeMaps(this.hostConfiguration.formatCodeOptions, convertFormatOptions(args.formatOptions)); this.logger.info("Format host information updated"); } } @@ -63152,7 +65682,7 @@ var ts; var scriptInfo = this.getScriptInfo(file.fileName); ts.Debug.assert(!scriptInfo || !scriptInfo.isOpen); var normalizedPath = scriptInfo ? scriptInfo.fileName : server.toNormalizedPath(file.fileName); - this.openClientFileWithNormalizedPath(normalizedPath, file.content, file.scriptKind, file.hasMixedContent); + this.openClientFileWithNormalizedPath(normalizedPath, file.content, tryConvertScriptKindName(file.scriptKind), file.hasMixedContent); } } if (changedFiles) { @@ -63237,7 +65767,7 @@ var ts; var exisingConfigFiles; if (externalProject) { if (!tsConfigFiles) { - this.updateNonInferredProject(externalProject, proj.rootFiles, externalFilePropertyReader, proj.options, proj.typingOptions, proj.options.compileOnSave, undefined); + this.updateNonInferredProject(externalProject, proj.rootFiles, externalFilePropertyReader, convertCompilerOptions(proj.options), proj.typingOptions, proj.options.compileOnSave, undefined); return; } this.closeExternalProject(proj.projectFileName, true); @@ -63523,23 +66053,7 @@ var ts; return _this.requiredResponse(_this.getRenameInfo(request.arguments)); }, _a[CommandNames.Open] = function (request) { - var openArgs = request.arguments; - var scriptKind; - switch (openArgs.scriptKindName) { - case "TS": - scriptKind = 3; - break; - case "JS": - scriptKind = 1; - break; - case "TSX": - scriptKind = 4; - break; - case "JSX": - scriptKind = 2; - break; - } - _this.openClientFile(server.toNormalizedPath(openArgs.file), openArgs.fileContent, scriptKind); + _this.openClientFile(server.toNormalizedPath(request.arguments.file), request.arguments.fileContent, server.convertScriptKindName(request.arguments.scriptKindName)); return _this.notRequired(); }, _a[CommandNames.Quickinfo] = function (request) { @@ -63611,7 +66125,7 @@ var ts; _a[CommandNames.EncodedSemanticClassificationsFull] = function (request) { return _this.requiredResponse(_this.getEncodedSemanticClassifications(request.arguments)); }, - _a[CommandNames.Cleanup] = function (request) { + _a[CommandNames.Cleanup] = function () { _this.cleanup(); return _this.requiredResponse(true); }, @@ -63686,12 +66200,13 @@ var ts; return _this.requiredResponse(_this.getDocumentHighlights(request.arguments, false)); }, _a[CommandNames.CompilerOptionsForInferredProjects] = function (request) { - return _this.requiredResponse(_this.setCompilerOptionsForInferredProjects(request.arguments)); + _this.setCompilerOptionsForInferredProjects(request.arguments); + return _this.requiredResponse(true); }, _a[CommandNames.ProjectInfo] = function (request) { return _this.requiredResponse(_this.getProjectInfo(request.arguments)); }, - _a[CommandNames.ReloadProjects] = function (request) { + _a[CommandNames.ReloadProjects] = function () { _this.projectService.reloadProjects(); return _this.notRequired(); }, @@ -63701,7 +66216,7 @@ var ts; _a[CommandNames.GetCodeFixesFull] = function (request) { return _this.requiredResponse(_this.getCodeFixes(request.arguments, false)); }, - _a[CommandNames.GetSupportedCodeFixes] = function (request) { + _a[CommandNames.GetSupportedCodeFixes] = function () { return _this.requiredResponse(_this.getSupportedCodeFixes()); }, _a)); @@ -63763,7 +66278,7 @@ var ts; seq: 0, type: "event", event: eventName, - body: info + body: info, }; this.send(ev); }; @@ -63774,7 +66289,7 @@ var ts; type: "response", command: cmdName, request_seq: reqSeq, - success: !errorMsg + success: !errorMsg, }; if (!errorMsg) { res.body = info; @@ -63899,9 +66414,9 @@ var ts; endLocation: scriptInfo && scriptInfo.positionToLineOffset(d.start + d.length) }); }); }; - Session.prototype.getDiagnosticsWorker = function (args, selector, includeLinePosition) { + Session.prototype.getDiagnosticsWorker = function (args, isSemantic, selector, includeLinePosition) { var _a = this.getFileAndProject(args), project = _a.project, file = _a.file; - if (shouldSkipSematicCheck(project)) { + if (isSemantic && shouldSkipSematicCheck(project)) { return []; } var scriptInfo = project.getScriptInfoForNormalizedPath(file); @@ -63985,15 +66500,15 @@ var ts; start: start, end: end, file: fileName, - isWriteAccess: isWriteAccess + isWriteAccess: isWriteAccess, }; }); }; Session.prototype.getSyntacticDiagnosticsSync = function (args) { - return this.getDiagnosticsWorker(args, function (project, file) { return project.getLanguageService().getSyntacticDiagnostics(file); }, args.includeLinePosition); + return this.getDiagnosticsWorker(args, false, function (project, file) { return project.getLanguageService().getSyntacticDiagnostics(file); }, args.includeLinePosition); }; Session.prototype.getSemanticDiagnosticsSync = function (args) { - return this.getDiagnosticsWorker(args, function (project, file) { return project.getLanguageService().getSemanticDiagnostics(file); }, args.includeLinePosition); + return this.getDiagnosticsWorker(args, true, function (project, file) { return project.getLanguageService().getSemanticDiagnostics(file); }, args.includeLinePosition); }; Session.prototype.getDocumentHighlights = function (args, simplifiedResult) { var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; @@ -64090,7 +66605,7 @@ var ts; return { file: location.fileName, start: locationScriptInfo.positionToLineOffset(location.textSpan.start), - end: locationScriptInfo.positionToLineOffset(ts.textSpanEnd(location.textSpan)) + end: locationScriptInfo.positionToLineOffset(ts.textSpanEnd(location.textSpan)), }; }); }, compareRenameLocation, function (a, b) { return a.file === b.file && a.start.line === b.start.line && a.start.offset === b.start.offset; }); @@ -64204,7 +66719,7 @@ var ts; if (this.eventHander) { this.eventHander({ eventName: "configFileDiag", - data: { fileName: fileName, configFileName: configFileName, diagnostics: configFileErrors || [] } + data: { triggerFile: fileName, configFileName: configFileName, diagnostics: configFileErrors || [] } }); } }; @@ -64244,7 +66759,7 @@ var ts; Session.prototype.getIndentation = function (args) { var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; var position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); - var options = args.options || this.projectService.getFormatCodeOptions(file); + var options = args.options ? server.convertFormatOptions(args.options) : this.projectService.getFormatCodeOptions(file); var indentation = project.getLanguageService(false).getIndentationAtPosition(file, position, options); return { position: position, indentation: indentation }; }; @@ -64279,7 +66794,7 @@ var ts; start: scriptInfo.positionToLineOffset(quickInfo.textSpan.start), end: scriptInfo.positionToLineOffset(ts.textSpanEnd(quickInfo.textSpan)), displayString: displayString, - documentation: docString + documentation: docString, }; } else { @@ -64300,17 +66815,17 @@ var ts; }; Session.prototype.getFormattingEditsForRangeFull = function (args) { var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - var options = args.options || this.projectService.getFormatCodeOptions(file); + var options = args.options ? server.convertFormatOptions(args.options) : this.projectService.getFormatCodeOptions(file); return project.getLanguageService(false).getFormattingEditsForRange(file, args.position, args.endPosition, options); }; Session.prototype.getFormattingEditsForDocumentFull = function (args) { var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - var options = args.options || this.projectService.getFormatCodeOptions(file); + var options = args.options ? server.convertFormatOptions(args.options) : this.projectService.getFormatCodeOptions(file); return project.getLanguageService(false).getFormattingEditsForDocument(file, options); }; Session.prototype.getFormattingEditsAfterKeystrokeFull = function (args) { var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - var options = args.options || this.projectService.getFormatCodeOptions(file); + var options = args.options ? server.convertFormatOptions(args.options) : this.projectService.getFormatCodeOptions(file); return project.getLanguageService(false).getFormattingEditsAfterKeystroke(file, args.position, args.key, options); }; Session.prototype.getFormattingEditsAfterKeystroke = function (args) { @@ -64377,7 +66892,7 @@ var ts; result.push({ name: name_53, kind: kind, kindModifiers: kindModifiers, sortText: sortText, replacementSpan: convertedSpan }); } return result; - }, []).sort(function (a, b) { return a.name.localeCompare(b.name); }); + }, []).sort(function (a, b) { return ts.compareStrings(a.name, b.name); }); } else { return completions; @@ -64440,7 +66955,7 @@ var ts; }, selectedItemIndex: helpItems.selectedItemIndex, argumentIndex: helpItems.argumentIndex, - argumentCount: helpItems.argumentCount + argumentCount: helpItems.argumentCount, }; } else { @@ -64477,10 +66992,11 @@ var ts; }; Session.prototype.reload = function (args, reqSeq) { var file = server.toNormalizedPath(args.file); + var tempFileName = args.tmpfile && server.toNormalizedPath(args.tmpfile); var project = this.projectService.getDefaultProjectForFile(file, true); if (project) { this.changeSeq++; - if (project.reloadScript(file)) { + if (project.reloadScript(file, tempFileName)) { this.output(undefined, CommandNames.Reload, reqSeq); } } @@ -64561,7 +67077,7 @@ var ts; kind: navItem.kind, file: navItem.fileName, start: start, - end: end + end: end, }; if (navItem.kindModifiers && (navItem.kindModifiers !== "")) { bakedItem.kindModifiers = navItem.kindModifiers; @@ -64670,7 +67186,7 @@ var ts; if (languageServiceDisabled) { return; } - var fileNamesInProject = fileNames.filter(function (value, index, array) { return value.indexOf("lib.d.ts") < 0; }); + var fileNamesInProject = fileNames.filter(function (value) { return value.indexOf("lib.d.ts") < 0; }); var highPriorityFiles = []; var mediumPriorityFiles = []; var lowPriorityFiles = []; @@ -64790,7 +67306,7 @@ var ts; this.goSubtree = true; this.done = false; } - BaseLineIndexWalker.prototype.leaf = function (rangeStart, rangeLength, ll) { + BaseLineIndexWalker.prototype.leaf = function (_rangeStart, _rangeLength, _ll) { }; return BaseLineIndexWalker; }()); @@ -64885,14 +67401,14 @@ var ts; } return this.lineIndex; }; - EditWalker.prototype.post = function (relativeStart, relativeLength, lineCollection, parent, nodeType) { + EditWalker.prototype.post = function (_relativeStart, _relativeLength, lineCollection) { if (lineCollection === this.lineCollectionAtBranch) { this.state = CharRangeSection.End; } this.stack.length--; return undefined; }; - EditWalker.prototype.pre = function (relativeStart, relativeLength, lineCollection, parent, nodeType) { + EditWalker.prototype.pre = function (_relativeStart, _relativeLength, lineCollection, _parent, nodeType) { var currentNode = this.stack[this.stack.length - 1]; if ((this.state === CharRangeSection.Entire) && (nodeType === CharRangeSection.Start)) { this.state = CharRangeSection.Start; @@ -65117,7 +67633,7 @@ var ts; var starts = [-1]; var count = 1; var pos = 0; - this.index.every(function (ll, s, len) { + this.index.every(function (ll) { starts[count] = pos; count++; pos += ll.text.length; @@ -65411,7 +67927,7 @@ var ts; if (!childInfo.child) { return { line: lineNumber, - offset: charOffset + offset: charOffset, }; } else if (childInfo.childIndex < this.children.length) { @@ -65645,7 +68161,7 @@ var ts; var rl = readline.createInterface({ input: process.stdin, output: process.stdout, - terminal: false + terminal: false, }); var Logger = (function () { function Logger(logFilename, traceToConsole, level) { @@ -65722,7 +68238,6 @@ var ts; function NodeTypingsInstaller(logger, eventPort, globalTypingsCacheLocation, newLine) { var _this = this; this.logger = logger; - this.eventPort = eventPort; this.globalTypingsCacheLocation = globalTypingsCacheLocation; this.newLine = newLine; if (eventPort) { @@ -65784,8 +68299,10 @@ var ts; }()); var IOSession = (function (_super) { __extends(IOSession, _super); - function IOSession(host, cancellationToken, installerEventPort, canUseEvents, useSingleInferredProject, globalTypingsCacheLocation, logger) { - return _super.call(this, host, cancellationToken, useSingleInferredProject, new NodeTypingsInstaller(logger, installerEventPort, globalTypingsCacheLocation, host.newLine), Buffer.byteLength, process.hrtime, logger, canUseEvents) || this; + function IOSession(host, cancellationToken, installerEventPort, canUseEvents, useSingleInferredProject, disableAutomaticTypingAcquisition, globalTypingsCacheLocation, logger) { + return _super.call(this, host, cancellationToken, useSingleInferredProject, disableAutomaticTypingAcquisition + ? server.nullTypingsInstaller + : new NodeTypingsInstaller(logger, installerEventPort, globalTypingsCacheLocation, host.newLine), Buffer.byteLength, process.hrtime, logger, canUseEvents) || this; } IOSession.prototype.exit = function () { this.logger.info("Exiting..."); @@ -65974,7 +68491,8 @@ var ts; } } var useSingleInferredProject = sys.args.indexOf("--useSingleInferredProject") >= 0; - var ioSession = new IOSession(sys, cancellationToken, eventPort, eventPort === undefined, useSingleInferredProject, getGlobalTypingsCacheLocation(), logger); + var disableAutomaticTypingAcquisition = sys.args.indexOf("--disableAutomaticTypingAcquisition") >= 0; + var ioSession = new IOSession(sys, cancellationToken, eventPort, eventPort === undefined, useSingleInferredProject, disableAutomaticTypingAcquisition, getGlobalTypingsCacheLocation(), logger); process.on("uncaughtException", function (err) { ioSession.logError(err, "unknown"); }); @@ -65982,694 +68500,5 @@ var ts; ioSession.listen(); })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); -var debugObjectHost = (function () { return this; })(); -var ts; -(function (ts) { - function logInternalError(logger, err) { - if (logger) { - logger.log("*INTERNAL ERROR* - Exception in typescript services: " + err.message); - } - } - var ScriptSnapshotShimAdapter = (function () { - function ScriptSnapshotShimAdapter(scriptSnapshotShim) { - this.scriptSnapshotShim = scriptSnapshotShim; - } - ScriptSnapshotShimAdapter.prototype.getText = function (start, end) { - return this.scriptSnapshotShim.getText(start, end); - }; - ScriptSnapshotShimAdapter.prototype.getLength = function () { - return this.scriptSnapshotShim.getLength(); - }; - ScriptSnapshotShimAdapter.prototype.getChangeRange = function (oldSnapshot) { - var oldSnapshotShim = oldSnapshot; - var encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim); - if (encoded == null) { - return null; - } - var decoded = JSON.parse(encoded); - return ts.createTextChangeRange(ts.createTextSpan(decoded.span.start, decoded.span.length), decoded.newLength); - }; - ScriptSnapshotShimAdapter.prototype.dispose = function () { - if ("dispose" in this.scriptSnapshotShim) { - this.scriptSnapshotShim.dispose(); - } - }; - return ScriptSnapshotShimAdapter; - }()); - var LanguageServiceShimHostAdapter = (function () { - function LanguageServiceShimHostAdapter(shimHost) { - var _this = this; - this.shimHost = shimHost; - this.loggingEnabled = false; - this.tracingEnabled = false; - if ("getModuleResolutionsForFile" in this.shimHost) { - this.resolveModuleNames = function (moduleNames, containingFile) { - var resolutionsInFile = JSON.parse(_this.shimHost.getModuleResolutionsForFile(containingFile)); - return ts.map(moduleNames, function (name) { - var result = ts.getProperty(resolutionsInFile, name); - return result ? { resolvedFileName: result } : undefined; - }); - }; - } - if ("directoryExists" in this.shimHost) { - this.directoryExists = function (directoryName) { return _this.shimHost.directoryExists(directoryName); }; - } - if ("getTypeReferenceDirectiveResolutionsForFile" in this.shimHost) { - this.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile) { - var typeDirectivesForFile = JSON.parse(_this.shimHost.getTypeReferenceDirectiveResolutionsForFile(containingFile)); - return ts.map(typeDirectiveNames, function (name) { return ts.getProperty(typeDirectivesForFile, name); }); - }; - } - } - LanguageServiceShimHostAdapter.prototype.log = function (s) { - if (this.loggingEnabled) { - this.shimHost.log(s); - } - }; - LanguageServiceShimHostAdapter.prototype.trace = function (s) { - if (this.tracingEnabled) { - this.shimHost.trace(s); - } - }; - LanguageServiceShimHostAdapter.prototype.error = function (s) { - this.shimHost.error(s); - }; - LanguageServiceShimHostAdapter.prototype.getProjectVersion = function () { - if (!this.shimHost.getProjectVersion) { - return undefined; - } - return this.shimHost.getProjectVersion(); - }; - LanguageServiceShimHostAdapter.prototype.getTypeRootsVersion = function () { - if (!this.shimHost.getTypeRootsVersion) { - return 0; - } - return this.shimHost.getTypeRootsVersion(); - }; - LanguageServiceShimHostAdapter.prototype.useCaseSensitiveFileNames = function () { - return this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false; - }; - LanguageServiceShimHostAdapter.prototype.getCompilationSettings = function () { - var settingsJson = this.shimHost.getCompilationSettings(); - if (settingsJson == null || settingsJson == "") { - throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); - } - return JSON.parse(settingsJson); - }; - LanguageServiceShimHostAdapter.prototype.getScriptFileNames = function () { - var encoded = this.shimHost.getScriptFileNames(); - return this.files = JSON.parse(encoded); - }; - LanguageServiceShimHostAdapter.prototype.getScriptSnapshot = function (fileName) { - var scriptSnapshot = this.shimHost.getScriptSnapshot(fileName); - return scriptSnapshot && new ScriptSnapshotShimAdapter(scriptSnapshot); - }; - LanguageServiceShimHostAdapter.prototype.getScriptKind = function (fileName) { - if ("getScriptKind" in this.shimHost) { - return this.shimHost.getScriptKind(fileName); - } - else { - return 0; - } - }; - LanguageServiceShimHostAdapter.prototype.getScriptVersion = function (fileName) { - return this.shimHost.getScriptVersion(fileName); - }; - LanguageServiceShimHostAdapter.prototype.getLocalizedDiagnosticMessages = function () { - var diagnosticMessagesJson = this.shimHost.getLocalizedDiagnosticMessages(); - if (diagnosticMessagesJson == null || diagnosticMessagesJson == "") { - return null; - } - try { - return JSON.parse(diagnosticMessagesJson); - } - catch (e) { - this.log(e.description || "diagnosticMessages.generated.json has invalid JSON format"); - return null; - } - }; - LanguageServiceShimHostAdapter.prototype.getCancellationToken = function () { - var hostCancellationToken = this.shimHost.getCancellationToken(); - return new ThrottledCancellationToken(hostCancellationToken); - }; - LanguageServiceShimHostAdapter.prototype.getCurrentDirectory = function () { - return this.shimHost.getCurrentDirectory(); - }; - LanguageServiceShimHostAdapter.prototype.getDirectories = function (path) { - return JSON.parse(this.shimHost.getDirectories(path)); - }; - LanguageServiceShimHostAdapter.prototype.getDefaultLibFileName = function (options) { - return this.shimHost.getDefaultLibFileName(JSON.stringify(options)); - }; - LanguageServiceShimHostAdapter.prototype.readDirectory = function (path, extensions, exclude, include, depth) { - var pattern = ts.getFileMatcherPatterns(path, extensions, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); - return JSON.parse(this.shimHost.readDirectory(path, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); - }; - LanguageServiceShimHostAdapter.prototype.readFile = function (path, encoding) { - return this.shimHost.readFile(path, encoding); - }; - LanguageServiceShimHostAdapter.prototype.fileExists = function (path) { - return this.shimHost.fileExists(path); - }; - return LanguageServiceShimHostAdapter; - }()); - ts.LanguageServiceShimHostAdapter = LanguageServiceShimHostAdapter; - var ThrottledCancellationToken = (function () { - function ThrottledCancellationToken(hostCancellationToken) { - this.hostCancellationToken = hostCancellationToken; - this.lastCancellationCheckTime = 0; - } - ThrottledCancellationToken.prototype.isCancellationRequested = function () { - var time = ts.timestamp(); - var duration = Math.abs(time - this.lastCancellationCheckTime); - if (duration > 10) { - this.lastCancellationCheckTime = time; - return this.hostCancellationToken.isCancellationRequested(); - } - return false; - }; - return ThrottledCancellationToken; - }()); - var CoreServicesShimHostAdapter = (function () { - function CoreServicesShimHostAdapter(shimHost) { - var _this = this; - this.shimHost = shimHost; - this.useCaseSensitiveFileNames = this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false; - if ("directoryExists" in this.shimHost) { - this.directoryExists = function (directoryName) { return _this.shimHost.directoryExists(directoryName); }; - } - if ("realpath" in this.shimHost) { - this.realpath = function (path) { return _this.shimHost.realpath(path); }; - } - } - CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extensions, exclude, include, depth) { - try { - var pattern = ts.getFileMatcherPatterns(rootDir, extensions, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); - return JSON.parse(this.shimHost.readDirectory(rootDir, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); - } - catch (e) { - var results = []; - for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) { - var extension = extensions_2[_i]; - for (var _a = 0, _b = this.readDirectoryFallback(rootDir, extension, exclude); _a < _b.length; _a++) { - var file = _b[_a]; - if (!ts.contains(results, file)) { - results.push(file); - } - } - } - return results; - } - }; - CoreServicesShimHostAdapter.prototype.fileExists = function (fileName) { - return this.shimHost.fileExists(fileName); - }; - CoreServicesShimHostAdapter.prototype.readFile = function (fileName) { - return this.shimHost.readFile(fileName); - }; - CoreServicesShimHostAdapter.prototype.readDirectoryFallback = function (rootDir, extension, exclude) { - return JSON.parse(this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude))); - }; - CoreServicesShimHostAdapter.prototype.getDirectories = function (path) { - return JSON.parse(this.shimHost.getDirectories(path)); - }; - return CoreServicesShimHostAdapter; - }()); - ts.CoreServicesShimHostAdapter = CoreServicesShimHostAdapter; - function simpleForwardCall(logger, actionDescription, action, logPerformance) { - var start; - if (logPerformance) { - logger.log(actionDescription); - start = ts.timestamp(); - } - var result = action(); - if (logPerformance) { - var end = ts.timestamp(); - logger.log(actionDescription + " completed in " + (end - start) + " msec"); - if (typeof result === "string") { - var str = result; - if (str.length > 128) { - str = str.substring(0, 128) + "..."; - } - logger.log(" result.length=" + str.length + ", result='" + JSON.stringify(str) + "'"); - } - } - return result; - } - function forwardJSONCall(logger, actionDescription, action, logPerformance) { - return forwardCall(logger, actionDescription, true, action, logPerformance); - } - function forwardCall(logger, actionDescription, returnJson, action, logPerformance) { - try { - var result = simpleForwardCall(logger, actionDescription, action, logPerformance); - return returnJson ? JSON.stringify({ result: result }) : result; - } - catch (err) { - if (err instanceof ts.OperationCanceledException) { - return JSON.stringify({ canceled: true }); - } - logInternalError(logger, err); - err.description = actionDescription; - return JSON.stringify({ error: err }); - } - } - var ShimBase = (function () { - function ShimBase(factory) { - this.factory = factory; - factory.registerShim(this); - } - ShimBase.prototype.dispose = function (dummy) { - this.factory.unregisterShim(this); - }; - return ShimBase; - }()); - function realizeDiagnostics(diagnostics, newLine) { - return diagnostics.map(function (d) { return realizeDiagnostic(d, newLine); }); - } - ts.realizeDiagnostics = realizeDiagnostics; - function realizeDiagnostic(diagnostic, newLine) { - return { - message: ts.flattenDiagnosticMessageText(diagnostic.messageText, newLine), - start: diagnostic.start, - length: diagnostic.length, - category: ts.DiagnosticCategory[diagnostic.category].toLowerCase(), - code: diagnostic.code - }; - } - var LanguageServiceShimObject = (function (_super) { - __extends(LanguageServiceShimObject, _super); - function LanguageServiceShimObject(factory, host, languageService) { - var _this = _super.call(this, factory) || this; - _this.host = host; - _this.languageService = languageService; - _this.logPerformance = false; - _this.logger = _this.host; - return _this; - } - LanguageServiceShimObject.prototype.forwardJSONCall = function (actionDescription, action) { - return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); - }; - LanguageServiceShimObject.prototype.dispose = function (dummy) { - this.logger.log("dispose()"); - this.languageService.dispose(); - this.languageService = null; - if (debugObjectHost && debugObjectHost.CollectGarbage) { - debugObjectHost.CollectGarbage(); - this.logger.log("CollectGarbage()"); - } - this.logger = null; - _super.prototype.dispose.call(this, dummy); - }; - LanguageServiceShimObject.prototype.refresh = function (throwOnError) { - this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; }); - }; - LanguageServiceShimObject.prototype.cleanupSemanticCache = function () { - var _this = this; - this.forwardJSONCall("cleanupSemanticCache()", function () { - _this.languageService.cleanupSemanticCache(); - return null; - }); - }; - LanguageServiceShimObject.prototype.realizeDiagnostics = function (diagnostics) { - var newLine = ts.getNewLineOrDefaultFromHost(this.host); - return ts.realizeDiagnostics(diagnostics, newLine); - }; - LanguageServiceShimObject.prototype.getSyntacticClassifications = function (fileName, start, length) { - var _this = this; - return this.forwardJSONCall("getSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSyntacticClassifications(fileName, ts.createTextSpan(start, length)); }); - }; - LanguageServiceShimObject.prototype.getSemanticClassifications = function (fileName, start, length) { - var _this = this; - return this.forwardJSONCall("getSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSemanticClassifications(fileName, ts.createTextSpan(start, length)); }); - }; - LanguageServiceShimObject.prototype.getEncodedSyntacticClassifications = function (fileName, start, length) { - var _this = this; - return this.forwardJSONCall("getEncodedSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return convertClassifications(_this.languageService.getEncodedSyntacticClassifications(fileName, ts.createTextSpan(start, length))); }); - }; - LanguageServiceShimObject.prototype.getEncodedSemanticClassifications = function (fileName, start, length) { - var _this = this; - return this.forwardJSONCall("getEncodedSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return convertClassifications(_this.languageService.getEncodedSemanticClassifications(fileName, ts.createTextSpan(start, length))); }); - }; - LanguageServiceShimObject.prototype.getSyntacticDiagnostics = function (fileName) { - var _this = this; - return this.forwardJSONCall("getSyntacticDiagnostics('" + fileName + "')", function () { - var diagnostics = _this.languageService.getSyntacticDiagnostics(fileName); - return _this.realizeDiagnostics(diagnostics); - }); - }; - LanguageServiceShimObject.prototype.getSemanticDiagnostics = function (fileName) { - var _this = this; - return this.forwardJSONCall("getSemanticDiagnostics('" + fileName + "')", function () { - var diagnostics = _this.languageService.getSemanticDiagnostics(fileName); - return _this.realizeDiagnostics(diagnostics); - }); - }; - LanguageServiceShimObject.prototype.getCompilerOptionsDiagnostics = function () { - var _this = this; - return this.forwardJSONCall("getCompilerOptionsDiagnostics()", function () { - var diagnostics = _this.languageService.getCompilerOptionsDiagnostics(); - return _this.realizeDiagnostics(diagnostics); - }); - }; - LanguageServiceShimObject.prototype.getQuickInfoAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getQuickInfoAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getQuickInfoAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getNameOrDottedNameSpan = function (fileName, startPos, endPos) { - var _this = this; - return this.forwardJSONCall("getNameOrDottedNameSpan('" + fileName + "', " + startPos + ", " + endPos + ")", function () { return _this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos); }); - }; - LanguageServiceShimObject.prototype.getBreakpointStatementAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getBreakpointStatementAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBreakpointStatementAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getSignatureHelpItems = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getSignatureHelpItems('" + fileName + "', " + position + ")", function () { return _this.languageService.getSignatureHelpItems(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getDefinitionAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDefinitionAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getTypeDefinitionAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getTypeDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getTypeDefinitionAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getImplementationAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getImplementationAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getImplementationAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position); }); - }; - LanguageServiceShimObject.prototype.findRenameLocations = function (fileName, position, findInStrings, findInComments) { - var _this = this; - return this.forwardJSONCall("findRenameLocations('" + fileName + "', " + position + ", " + findInStrings + ", " + findInComments + ")", function () { return _this.languageService.findRenameLocations(fileName, position, findInStrings, findInComments); }); - }; - LanguageServiceShimObject.prototype.getBraceMatchingAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getBraceMatchingAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBraceMatchingAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.isValidBraceCompletionAtPosition = function (fileName, position, openingBrace) { - var _this = this; - return this.forwardJSONCall("isValidBraceCompletionAtPosition('" + fileName + "', " + position + ", " + openingBrace + ")", function () { return _this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace); }); - }; - LanguageServiceShimObject.prototype.getIndentationAtPosition = function (fileName, position, options) { - var _this = this; - return this.forwardJSONCall("getIndentationAtPosition('" + fileName + "', " + position + ")", function () { - var localOptions = JSON.parse(options); - return _this.languageService.getIndentationAtPosition(fileName, position, localOptions); - }); - }; - LanguageServiceShimObject.prototype.getReferencesAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getReferencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getReferencesAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.findReferences = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("findReferences('" + fileName + "', " + position + ")", function () { return _this.languageService.findReferences(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getOccurrencesAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getOccurrencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getOccurrencesAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getDocumentHighlights = function (fileName, position, filesToSearch) { - var _this = this; - return this.forwardJSONCall("getDocumentHighlights('" + fileName + "', " + position + ")", function () { - var results = _this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); - var normalizedName = ts.normalizeSlashes(fileName).toLowerCase(); - return ts.filter(results, function (r) { return ts.normalizeSlashes(r.fileName).toLowerCase() === normalizedName; }); - }); - }; - LanguageServiceShimObject.prototype.getCompletionsAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getCompletionsAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName) { - var _this = this; - return this.forwardJSONCall("getCompletionEntryDetails('" + fileName + "', " + position + ", '" + entryName + "')", function () { return _this.languageService.getCompletionEntryDetails(fileName, position, entryName); }); - }; - LanguageServiceShimObject.prototype.getFormattingEditsForRange = function (fileName, start, end, options) { - var _this = this; - return this.forwardJSONCall("getFormattingEditsForRange('" + fileName + "', " + start + ", " + end + ")", function () { - var localOptions = JSON.parse(options); - return _this.languageService.getFormattingEditsForRange(fileName, start, end, localOptions); - }); - }; - LanguageServiceShimObject.prototype.getFormattingEditsForDocument = function (fileName, options) { - var _this = this; - return this.forwardJSONCall("getFormattingEditsForDocument('" + fileName + "')", function () { - var localOptions = JSON.parse(options); - return _this.languageService.getFormattingEditsForDocument(fileName, localOptions); - }); - }; - LanguageServiceShimObject.prototype.getFormattingEditsAfterKeystroke = function (fileName, position, key, options) { - var _this = this; - return this.forwardJSONCall("getFormattingEditsAfterKeystroke('" + fileName + "', " + position + ", '" + key + "')", function () { - var localOptions = JSON.parse(options); - return _this.languageService.getFormattingEditsAfterKeystroke(fileName, position, key, localOptions); - }); - }; - LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getNavigateToItems = function (searchValue, maxResultCount, fileName) { - var _this = this; - return this.forwardJSONCall("getNavigateToItems('" + searchValue + "', " + maxResultCount + ", " + fileName + ")", function () { return _this.languageService.getNavigateToItems(searchValue, maxResultCount, fileName); }); - }; - LanguageServiceShimObject.prototype.getNavigationBarItems = function (fileName) { - var _this = this; - return this.forwardJSONCall("getNavigationBarItems('" + fileName + "')", function () { return _this.languageService.getNavigationBarItems(fileName); }); - }; - LanguageServiceShimObject.prototype.getNavigationTree = function (fileName) { - var _this = this; - return this.forwardJSONCall("getNavigationTree('" + fileName + "')", function () { return _this.languageService.getNavigationTree(fileName); }); - }; - LanguageServiceShimObject.prototype.getOutliningSpans = function (fileName) { - var _this = this; - return this.forwardJSONCall("getOutliningSpans('" + fileName + "')", function () { return _this.languageService.getOutliningSpans(fileName); }); - }; - LanguageServiceShimObject.prototype.getTodoComments = function (fileName, descriptors) { - var _this = this; - return this.forwardJSONCall("getTodoComments('" + fileName + "')", function () { return _this.languageService.getTodoComments(fileName, JSON.parse(descriptors)); }); - }; - LanguageServiceShimObject.prototype.getEmitOutput = function (fileName) { - var _this = this; - return this.forwardJSONCall("getEmitOutput('" + fileName + "')", function () { return _this.languageService.getEmitOutput(fileName); }); - }; - LanguageServiceShimObject.prototype.getEmitOutputObject = function (fileName) { - var _this = this; - return forwardCall(this.logger, "getEmitOutput('" + fileName + "')", false, function () { return _this.languageService.getEmitOutput(fileName); }, this.logPerformance); - }; - return LanguageServiceShimObject; - }(ShimBase)); - function convertClassifications(classifications) { - return { spans: classifications.spans.join(","), endOfLineState: classifications.endOfLineState }; - } - var ClassifierShimObject = (function (_super) { - __extends(ClassifierShimObject, _super); - function ClassifierShimObject(factory, logger) { - var _this = _super.call(this, factory) || this; - _this.logger = logger; - _this.logPerformance = false; - _this.classifier = ts.createClassifier(); - return _this; - } - ClassifierShimObject.prototype.getEncodedLexicalClassifications = function (text, lexState, syntacticClassifierAbsent) { - var _this = this; - return forwardJSONCall(this.logger, "getEncodedLexicalClassifications", function () { return convertClassifications(_this.classifier.getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent)); }, this.logPerformance); - }; - ClassifierShimObject.prototype.getClassificationsForLine = function (text, lexState, classifyKeywordsInGenerics) { - var classification = this.classifier.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics); - var result = ""; - for (var _i = 0, _a = classification.entries; _i < _a.length; _i++) { - var item = _a[_i]; - result += item.length + "\n"; - result += item.classification + "\n"; - } - result += classification.finalLexState; - return result; - }; - return ClassifierShimObject; - }(ShimBase)); - var CoreServicesShimObject = (function (_super) { - __extends(CoreServicesShimObject, _super); - function CoreServicesShimObject(factory, logger, host) { - var _this = _super.call(this, factory) || this; - _this.logger = logger; - _this.host = host; - _this.logPerformance = false; - return _this; - } - CoreServicesShimObject.prototype.forwardJSONCall = function (actionDescription, action) { - return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); - }; - CoreServicesShimObject.prototype.resolveModuleName = function (fileName, moduleName, compilerOptionsJson) { - var _this = this; - return this.forwardJSONCall("resolveModuleName('" + fileName + "')", function () { - var compilerOptions = JSON.parse(compilerOptionsJson); - var result = ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host); - return { - resolvedFileName: result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined, - failedLookupLocations: result.failedLookupLocations - }; - }); - }; - CoreServicesShimObject.prototype.resolveTypeReferenceDirective = function (fileName, typeReferenceDirective, compilerOptionsJson) { - var _this = this; - return this.forwardJSONCall("resolveTypeReferenceDirective(" + fileName + ")", function () { - var compilerOptions = JSON.parse(compilerOptionsJson); - var result = ts.resolveTypeReferenceDirective(typeReferenceDirective, ts.normalizeSlashes(fileName), compilerOptions, _this.host); - return { - resolvedFileName: result.resolvedTypeReferenceDirective ? result.resolvedTypeReferenceDirective.resolvedFileName : undefined, - primary: result.resolvedTypeReferenceDirective ? result.resolvedTypeReferenceDirective.primary : true, - failedLookupLocations: result.failedLookupLocations - }; - }); - }; - CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { - var _this = this; - return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { - var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()), true, true); - return { - referencedFiles: _this.convertFileReferences(result.referencedFiles), - importedFiles: _this.convertFileReferences(result.importedFiles), - ambientExternalModules: result.ambientExternalModules, - isLibFile: result.isLibFile, - typeReferenceDirectives: _this.convertFileReferences(result.typeReferenceDirectives) - }; - }); - }; - CoreServicesShimObject.prototype.getAutomaticTypeDirectiveNames = function (compilerOptionsJson) { - var _this = this; - return this.forwardJSONCall("getAutomaticTypeDirectiveNames('" + compilerOptionsJson + "')", function () { - var compilerOptions = JSON.parse(compilerOptionsJson); - return ts.getAutomaticTypeDirectiveNames(compilerOptions, _this.host); - }); - }; - CoreServicesShimObject.prototype.convertFileReferences = function (refs) { - if (!refs) { - return undefined; - } - var result = []; - for (var _i = 0, refs_2 = refs; _i < refs_2.length; _i++) { - var ref = refs_2[_i]; - result.push({ - path: ts.normalizeSlashes(ref.fileName), - position: ref.pos, - length: ref.end - ref.pos - }); - } - return result; - }; - CoreServicesShimObject.prototype.getTSConfigFileInfo = function (fileName, sourceTextSnapshot) { - var _this = this; - return this.forwardJSONCall("getTSConfigFileInfo('" + fileName + "')", function () { - var text = sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()); - var result = ts.parseConfigFileTextToJson(fileName, text); - if (result.error) { - return { - options: {}, - typingOptions: {}, - files: [], - raw: {}, - errors: [realizeDiagnostic(result.error, "\r\n")] - }; - } - var normalizedFileName = ts.normalizeSlashes(fileName); - var configFile = ts.parseJsonConfigFileContent(result.config, _this.host, ts.getDirectoryPath(normalizedFileName), {}, normalizedFileName); - return { - options: configFile.options, - typingOptions: configFile.typingOptions, - files: configFile.fileNames, - raw: configFile.raw, - errors: realizeDiagnostics(configFile.errors, "\r\n") - }; - }); - }; - CoreServicesShimObject.prototype.getDefaultCompilationSettings = function () { - return this.forwardJSONCall("getDefaultCompilationSettings()", function () { return ts.getDefaultCompilerOptions(); }); - }; - CoreServicesShimObject.prototype.discoverTypings = function (discoverTypingsJson) { - var _this = this; - var getCanonicalFileName = ts.createGetCanonicalFileName(false); - return this.forwardJSONCall("discoverTypings()", function () { - var info = JSON.parse(discoverTypingsJson); - return ts.JsTyping.discoverTypings(_this.host, info.fileNames, ts.toPath(info.projectRootPath, info.projectRootPath, getCanonicalFileName), ts.toPath(info.safeListPath, info.safeListPath, getCanonicalFileName), info.packageNameToTypingLocation, info.typingOptions, info.compilerOptions); - }); - }; - return CoreServicesShimObject; - }(ShimBase)); - var TypeScriptServicesFactory = (function () { - function TypeScriptServicesFactory() { - this._shims = []; - } - TypeScriptServicesFactory.prototype.getServicesVersion = function () { - return ts.servicesVersion; - }; - TypeScriptServicesFactory.prototype.createLanguageServiceShim = function (host) { - try { - if (this.documentRegistry === undefined) { - this.documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory()); - } - var hostAdapter = new LanguageServiceShimHostAdapter(host); - var languageService = ts.createLanguageService(hostAdapter, this.documentRegistry); - return new LanguageServiceShimObject(this, host, languageService); - } - catch (err) { - logInternalError(host, err); - throw err; - } - }; - TypeScriptServicesFactory.prototype.createClassifierShim = function (logger) { - try { - return new ClassifierShimObject(this, logger); - } - catch (err) { - logInternalError(logger, err); - throw err; - } - }; - TypeScriptServicesFactory.prototype.createCoreServicesShim = function (host) { - try { - var adapter = new CoreServicesShimHostAdapter(host); - return new CoreServicesShimObject(this, host, adapter); - } - catch (err) { - logInternalError(host, err); - throw err; - } - }; - TypeScriptServicesFactory.prototype.close = function () { - this._shims = []; - this.documentRegistry = undefined; - }; - TypeScriptServicesFactory.prototype.registerShim = function (shim) { - this._shims.push(shim); - }; - TypeScriptServicesFactory.prototype.unregisterShim = function (shim) { - for (var i = 0, n = this._shims.length; i < n; i++) { - if (this._shims[i] === shim) { - delete this._shims[i]; - return; - } - } - throw new Error("Invalid operation"); - }; - return TypeScriptServicesFactory; - }()); - ts.TypeScriptServicesFactory = TypeScriptServicesFactory; - if (typeof module !== "undefined" && module.exports) { - module.exports = ts; - } -})(ts || (ts = {})); -var TypeScript; -(function (TypeScript) { - var Services; - (function (Services) { - Services.TypeScriptServicesFactory = ts.TypeScriptServicesFactory; - })(Services = TypeScript.Services || (TypeScript.Services = {})); -})(TypeScript || (TypeScript = {})); -var toolsVersion = "2.1"; + +//# sourceMappingURL=tsserver.js.map diff --git a/lib/tsserverlibrary.d.ts b/lib/tsserverlibrary.d.ts index c23bccf0a68..63580ce8dcd 100644 --- a/lib/tsserverlibrary.d.ts +++ b/lib/tsserverlibrary.d.ts @@ -1,700 +1,20 @@ +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + /// /// -declare namespace ts.server.protocol { - namespace CommandTypes { - type Brace = "brace"; - type BraceFull = "brace-full"; - type BraceCompletion = "braceCompletion"; - type Change = "change"; - type Close = "close"; - type Completions = "completions"; - type CompletionsFull = "completions-full"; - type CompletionDetails = "completionEntryDetails"; - type CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList"; - type CompileOnSaveEmitFile = "compileOnSaveEmitFile"; - type Configure = "configure"; - type Definition = "definition"; - type DefinitionFull = "definition-full"; - type Implementation = "implementation"; - type ImplementationFull = "implementation-full"; - type Exit = "exit"; - type Format = "format"; - type Formatonkey = "formatonkey"; - type FormatFull = "format-full"; - type FormatonkeyFull = "formatonkey-full"; - type FormatRangeFull = "formatRange-full"; - type Geterr = "geterr"; - type GeterrForProject = "geterrForProject"; - type SemanticDiagnosticsSync = "semanticDiagnosticsSync"; - type SyntacticDiagnosticsSync = "syntacticDiagnosticsSync"; - type NavBar = "navbar"; - type NavBarFull = "navbar-full"; - type Navto = "navto"; - type NavtoFull = "navto-full"; - type NavTree = "navtree"; - type NavTreeFull = "navtree-full"; - type Occurrences = "occurrences"; - type DocumentHighlights = "documentHighlights"; - type DocumentHighlightsFull = "documentHighlights-full"; - type Open = "open"; - type Quickinfo = "quickinfo"; - type QuickinfoFull = "quickinfo-full"; - type References = "references"; - type ReferencesFull = "references-full"; - type Reload = "reload"; - type Rename = "rename"; - type RenameInfoFull = "rename-full"; - type RenameLocationsFull = "renameLocations-full"; - type Saveto = "saveto"; - type SignatureHelp = "signatureHelp"; - type SignatureHelpFull = "signatureHelp-full"; - type TypeDefinition = "typeDefinition"; - type ProjectInfo = "projectInfo"; - type ReloadProjects = "reloadProjects"; - type Unknown = "unknown"; - type OpenExternalProject = "openExternalProject"; - type OpenExternalProjects = "openExternalProjects"; - type CloseExternalProject = "closeExternalProject"; - type SynchronizeProjectList = "synchronizeProjectList"; - type ApplyChangedToOpenFiles = "applyChangedToOpenFiles"; - type EncodedSemanticClassificationsFull = "encodedSemanticClassifications-full"; - type Cleanup = "cleanup"; - type OutliningSpans = "outliningSpans"; - type TodoComments = "todoComments"; - type Indentation = "indentation"; - type DocCommentTemplate = "docCommentTemplate"; - type CompilerOptionsDiagnosticsFull = "compilerOptionsDiagnostics-full"; - type NameOrDottedNameSpan = "nameOrDottedNameSpan"; - type BreakpointStatement = "breakpointStatement"; - type CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects"; - type GetCodeFixes = "getCodeFixes"; - type GetCodeFixesFull = "getCodeFixes-full"; - type GetSupportedCodeFixes = "getSupportedCodeFixes"; - } - interface Message { - seq: number; - type: string; - } - interface Request extends Message { - command: string; - arguments?: any; - } - interface ReloadProjectsRequest extends Message { - command: CommandTypes.ReloadProjects; - } - interface Event extends Message { - event: string; - body?: any; - } - interface Response extends Message { - request_seq: number; - success: boolean; - command: string; - message?: string; - body?: any; - } - interface FileRequestArgs { - file: string; - projectFileName?: string; - } - interface DocCommentTemplateRequest extends FileLocationRequest { - command: CommandTypes.DocCommentTemplate; - } - interface DocCommandTemplateResponse extends Response { - body?: TextInsertion; - } - interface TodoCommentRequest extends FileRequest { - command: CommandTypes.TodoComments; - arguments: TodoCommentRequestArgs; - } - interface TodoCommentRequestArgs extends FileRequestArgs { - descriptors: TodoCommentDescriptor[]; - } - interface TodoCommentsResponse extends Response { - body?: TodoComment[]; - } - interface OutliningSpansRequest extends FileRequest { - command: CommandTypes.OutliningSpans; - } - interface OutliningSpansResponse extends Response { - body?: OutliningSpan[]; - } - interface IndentationRequest extends FileLocationRequest { - command: CommandTypes.Indentation; - arguments: IndentationRequestArgs; - } - interface IndentationResponse extends Response { - body?: IndentationResult; - } - interface IndentationResult { - position: number; - indentation: number; - } - interface IndentationRequestArgs extends FileLocationRequestArgs { - options?: EditorSettings; - } - interface ProjectInfoRequestArgs extends FileRequestArgs { - needFileNameList: boolean; - } - interface ProjectInfoRequest extends Request { - command: CommandTypes.ProjectInfo; - arguments: ProjectInfoRequestArgs; - } - interface CompilerOptionsDiagnosticsRequest extends Request { - arguments: CompilerOptionsDiagnosticsRequestArgs; - } - interface CompilerOptionsDiagnosticsRequestArgs { - projectFileName: string; - } - interface ProjectInfo { - configFileName: string; - fileNames?: string[]; - languageServiceDisabled?: boolean; - } - interface DiagnosticWithLinePosition { - message: string; - start: number; - length: number; - startLocation: Location; - endLocation: Location; - category: string; - code: number; - } - interface ProjectInfoResponse extends Response { - body?: ProjectInfo; - } - interface FileRequest extends Request { - arguments: FileRequestArgs; - } - interface FileLocationRequestArgs extends FileRequestArgs { - line: number; - offset: number; - position?: number; - } - interface CodeFixRequest extends Request { - command: CommandTypes.GetCodeFixes; - arguments: CodeFixRequestArgs; - } - interface CodeFixRequestArgs extends FileRequestArgs { - startLine: number; - startOffset: number; - startPosition?: number; - endLine: number; - endOffset: number; - endPosition?: number; - errorCodes?: number[]; - } - interface GetCodeFixesResponse extends Response { - body?: CodeAction[]; - } - interface FileLocationRequest extends FileRequest { - arguments: FileLocationRequestArgs; - } - interface GetSupportedCodeFixesRequest extends Request { - command: CommandTypes.GetSupportedCodeFixes; - } - interface GetSupportedCodeFixesResponse extends Response { - body?: string[]; - } - interface EncodedSemanticClassificationsRequest extends FileRequest { - arguments: EncodedSemanticClassificationsRequestArgs; - } - interface EncodedSemanticClassificationsRequestArgs extends FileRequestArgs { - start: number; - length: number; - } - interface DocumentHighlightsRequestArgs extends FileLocationRequestArgs { - filesToSearch: string[]; - } - interface DefinitionRequest extends FileLocationRequest { - command: CommandTypes.Definition; - } - interface TypeDefinitionRequest extends FileLocationRequest { - command: CommandTypes.TypeDefinition; - } - interface ImplementationRequest extends FileLocationRequest { - command: CommandTypes.Implementation; - } - interface Location { - line: number; - offset: number; - } - interface TextSpan { - start: Location; - end: Location; - } - interface FileSpan extends TextSpan { - file: string; - } - interface DefinitionResponse extends Response { - body?: FileSpan[]; - } - interface TypeDefinitionResponse extends Response { - body?: FileSpan[]; - } - interface ImplementationResponse extends Response { - body?: FileSpan[]; - } - interface BraceCompletionRequest extends FileLocationRequest { - command: CommandTypes.BraceCompletion; - arguments: BraceCompletionRequestArgs; - } - interface BraceCompletionRequestArgs extends FileLocationRequestArgs { - openingBrace: string; - } - interface OccurrencesRequest extends FileLocationRequest { - command: CommandTypes.Occurrences; - } - interface OccurrencesResponseItem extends FileSpan { - isWriteAccess: boolean; - } - interface OccurrencesResponse extends Response { - body?: OccurrencesResponseItem[]; - } - interface DocumentHighlightsRequest extends FileLocationRequest { - command: CommandTypes.DocumentHighlights; - arguments: DocumentHighlightsRequestArgs; - } - interface HighlightSpan extends TextSpan { - kind: string; - } - interface DocumentHighlightsItem { - file: string; - highlightSpans: HighlightSpan[]; - } - interface DocumentHighlightsResponse extends Response { - body?: DocumentHighlightsItem[]; - } - interface ReferencesRequest extends FileLocationRequest { - command: CommandTypes.References; - } - interface ReferencesResponseItem extends FileSpan { - lineText: string; - isWriteAccess: boolean; - isDefinition: boolean; - } - interface ReferencesResponseBody { - refs: ReferencesResponseItem[]; - symbolName: string; - symbolStartOffset: number; - symbolDisplayString: string; - } - interface ReferencesResponse extends Response { - body?: ReferencesResponseBody; - } - interface RenameRequestArgs extends FileLocationRequestArgs { - findInComments?: boolean; - findInStrings?: boolean; - } - interface RenameRequest extends FileLocationRequest { - command: CommandTypes.Rename; - arguments: RenameRequestArgs; - } - interface RenameInfo { - canRename: boolean; - localizedErrorMessage?: string; - displayName: string; - fullDisplayName: string; - kind: string; - kindModifiers: string; - } - interface SpanGroup { - file: string; - locs: TextSpan[]; - } - interface RenameResponseBody { - info: RenameInfo; - locs: SpanGroup[]; - } - interface RenameResponse extends Response { - body?: RenameResponseBody; - } - interface ExternalFile { - fileName: string; - scriptKind?: ScriptKind; - hasMixedContent?: boolean; - content?: string; - } - interface ExternalProject { - projectFileName: string; - rootFiles: ExternalFile[]; - options: ExternalProjectCompilerOptions; - typingOptions?: TypingOptions; - } - interface ExternalProjectCompilerOptions extends CompilerOptions { - compileOnSave?: boolean; - } - interface ProjectVersionInfo { - projectName: string; - isInferred: boolean; - version: number; - options: CompilerOptions; - } - interface ProjectChanges { - added: string[]; - removed: string[]; - } - interface ProjectFiles { - info?: ProjectVersionInfo; - files?: string[]; - changes?: ProjectChanges; - } - interface ProjectFilesWithDiagnostics extends ProjectFiles { - projectErrors: DiagnosticWithLinePosition[]; - } - interface ChangedOpenFile { - fileName: string; - changes: ts.TextChange[]; - } - interface ConfigureRequestArguments { - hostInfo?: string; - file?: string; - formatOptions?: FormatCodeSettings; - } - interface ConfigureRequest extends Request { - command: CommandTypes.Configure; - arguments: ConfigureRequestArguments; - } - interface ConfigureResponse extends Response { - } - interface OpenRequestArgs extends FileRequestArgs { - fileContent?: string; - scriptKindName?: "TS" | "JS" | "TSX" | "JSX"; - } - interface OpenRequest extends Request { - command: CommandTypes.Open; - arguments: OpenRequestArgs; - } - interface OpenExternalProjectRequest extends Request { - command: CommandTypes.OpenExternalProject; - arguments: OpenExternalProjectArgs; - } - type OpenExternalProjectArgs = ExternalProject; - interface OpenExternalProjectsRequest extends Request { - command: CommandTypes.OpenExternalProjects; - arguments: OpenExternalProjectsArgs; - } - interface OpenExternalProjectsArgs { - projects: ExternalProject[]; - } - interface OpenExternalProjectResponse extends Response { - } - interface OpenExternalProjectsResponse extends Response { - } - interface CloseExternalProjectRequest extends Request { - command: CommandTypes.CloseExternalProject; - arguments: CloseExternalProjectRequestArgs; - } - interface CloseExternalProjectRequestArgs { - projectFileName: string; - } - interface CloseExternalProjectResponse extends Response { - } - interface SynchronizeProjectListRequest extends Request { - arguments: SynchronizeProjectListRequestArgs; - } - interface SynchronizeProjectListRequestArgs { - knownProjects: protocol.ProjectVersionInfo[]; - } - interface ApplyChangedToOpenFilesRequest extends Request { - arguments: ApplyChangedToOpenFilesRequestArgs; - } - interface ApplyChangedToOpenFilesRequestArgs { - openFiles?: ExternalFile[]; - changedFiles?: ChangedOpenFile[]; - closedFiles?: string[]; - } - interface SetCompilerOptionsForInferredProjectsRequest extends Request { - command: CommandTypes.CompilerOptionsForInferredProjects; - arguments: SetCompilerOptionsForInferredProjectsArgs; - } - interface SetCompilerOptionsForInferredProjectsArgs { - options: ExternalProjectCompilerOptions; - } - interface SetCompilerOptionsForInferredProjectsResponse extends Response { - } - interface ExitRequest extends Request { - command: CommandTypes.Exit; - } - interface CloseRequest extends FileRequest { - command: CommandTypes.Close; - } - interface CompileOnSaveAffectedFileListRequest extends FileRequest { - command: CommandTypes.CompileOnSaveAffectedFileList; - } - interface CompileOnSaveAffectedFileListSingleProject { - projectFileName: string; - fileNames: string[]; - } - interface CompileOnSaveAffectedFileListResponse extends Response { - body: CompileOnSaveAffectedFileListSingleProject[]; - } - interface CompileOnSaveEmitFileRequest extends FileRequest { - command: CommandTypes.CompileOnSaveEmitFile; - arguments: CompileOnSaveEmitFileRequestArgs; - } - interface CompileOnSaveEmitFileRequestArgs extends FileRequestArgs { - forced?: boolean; - } - interface QuickInfoRequest extends FileLocationRequest { - command: CommandTypes.Quickinfo; - } - interface QuickInfoResponseBody { - kind: string; - kindModifiers: string; - start: Location; - end: Location; - displayString: string; - documentation: string; - } - interface QuickInfoResponse extends Response { - body?: QuickInfoResponseBody; - } - interface FormatRequestArgs extends FileLocationRequestArgs { - endLine: number; - endOffset: number; - endPosition?: number; - options?: FormatCodeSettings; - } - interface FormatRequest extends FileLocationRequest { - command: CommandTypes.Format; - arguments: FormatRequestArgs; - } - interface CodeEdit { - start: Location; - end: Location; - newText: string; - } - interface FileCodeEdits { - fileName: string; - textChanges: CodeEdit[]; - } - interface CodeFixResponse extends Response { - body?: CodeAction[]; - } - interface CodeAction { - description: string; - changes: FileCodeEdits[]; - } - interface FormatResponse extends Response { - body?: CodeEdit[]; - } - interface FormatOnKeyRequestArgs extends FileLocationRequestArgs { - key: string; - options?: FormatCodeSettings; - } - interface FormatOnKeyRequest extends FileLocationRequest { - command: CommandTypes.Formatonkey; - arguments: FormatOnKeyRequestArgs; - } - interface CompletionsRequestArgs extends FileLocationRequestArgs { - prefix?: string; - } - interface CompletionsRequest extends FileLocationRequest { - command: CommandTypes.Completions; - arguments: CompletionsRequestArgs; - } - interface CompletionDetailsRequestArgs extends FileLocationRequestArgs { - entryNames: string[]; - } - interface CompletionDetailsRequest extends FileLocationRequest { - command: CommandTypes.CompletionDetails; - arguments: CompletionDetailsRequestArgs; - } - interface SymbolDisplayPart { - text: string; - kind: string; - } - interface CompletionEntry { - name: string; - kind: string; - kindModifiers: string; - sortText: string; - replacementSpan?: TextSpan; - } - interface CompletionEntryDetails { - name: string; - kind: string; - kindModifiers: string; - displayParts: SymbolDisplayPart[]; - documentation: SymbolDisplayPart[]; - } - interface CompletionsResponse extends Response { - body?: CompletionEntry[]; - } - interface CompletionDetailsResponse extends Response { - body?: CompletionEntryDetails[]; - } - interface SignatureHelpParameter { - name: string; - documentation: SymbolDisplayPart[]; - displayParts: SymbolDisplayPart[]; - isOptional: boolean; - } - interface SignatureHelpItem { - isVariadic: boolean; - prefixDisplayParts: SymbolDisplayPart[]; - suffixDisplayParts: SymbolDisplayPart[]; - separatorDisplayParts: SymbolDisplayPart[]; - parameters: SignatureHelpParameter[]; - documentation: SymbolDisplayPart[]; - } - interface SignatureHelpItems { - items: SignatureHelpItem[]; - applicableSpan: TextSpan; - selectedItemIndex: number; - argumentIndex: number; - argumentCount: number; - } - interface SignatureHelpRequestArgs extends FileLocationRequestArgs { - } - interface SignatureHelpRequest extends FileLocationRequest { - command: CommandTypes.SignatureHelp; - arguments: SignatureHelpRequestArgs; - } - interface SignatureHelpResponse extends Response { - body?: SignatureHelpItems; - } - interface SemanticDiagnosticsSyncRequest extends FileRequest { - command: CommandTypes.SemanticDiagnosticsSync; - arguments: SemanticDiagnosticsSyncRequestArgs; - } - interface SemanticDiagnosticsSyncRequestArgs extends FileRequestArgs { - includeLinePosition?: boolean; - } - interface SemanticDiagnosticsSyncResponse extends Response { - body?: Diagnostic[] | DiagnosticWithLinePosition[]; - } - interface SyntacticDiagnosticsSyncRequest extends FileRequest { - command: CommandTypes.SyntacticDiagnosticsSync; - arguments: SyntacticDiagnosticsSyncRequestArgs; - } - interface SyntacticDiagnosticsSyncRequestArgs extends FileRequestArgs { - includeLinePosition?: boolean; - } - interface SyntacticDiagnosticsSyncResponse extends Response { - body?: Diagnostic[] | DiagnosticWithLinePosition[]; - } - interface GeterrForProjectRequestArgs { - file: string; - delay: number; - } - interface GeterrForProjectRequest extends Request { - command: CommandTypes.GeterrForProject; - arguments: GeterrForProjectRequestArgs; - } - interface GeterrRequestArgs { - files: string[]; - delay: number; - } - interface GeterrRequest extends Request { - command: CommandTypes.Geterr; - arguments: GeterrRequestArgs; - } - interface Diagnostic { - start: Location; - end: Location; - text: string; - code?: number; - } - interface DiagnosticEventBody { - file: string; - diagnostics: Diagnostic[]; - } - interface DiagnosticEvent extends Event { - body?: DiagnosticEventBody; - } - interface ConfigFileDiagnosticEventBody { - triggerFile: string; - configFile: string; - diagnostics: Diagnostic[]; - } - interface ConfigFileDiagnosticEvent extends Event { - body?: ConfigFileDiagnosticEventBody; - event: "configFileDiag"; - } - interface ReloadRequestArgs extends FileRequestArgs { - tmpfile: string; - } - interface ReloadRequest extends FileRequest { - command: CommandTypes.Reload; - arguments: ReloadRequestArgs; - } - interface ReloadResponse extends Response { - } - interface SavetoRequestArgs extends FileRequestArgs { - tmpfile: string; - } - interface SavetoRequest extends FileRequest { - command: CommandTypes.Saveto; - arguments: SavetoRequestArgs; - } - interface NavtoRequestArgs extends FileRequestArgs { - searchValue: string; - maxResultCount?: number; - currentFileOnly?: boolean; - projectFileName?: string; - } - interface NavtoRequest extends FileRequest { - command: CommandTypes.Navto; - arguments: NavtoRequestArgs; - } - interface NavtoItem { - name: string; - kind: string; - matchKind?: string; - isCaseSensitive?: boolean; - kindModifiers?: string; - file: string; - start: Location; - end: Location; - containerName?: string; - containerKind?: string; - } - interface NavtoResponse extends Response { - body?: NavtoItem[]; - } - interface ChangeRequestArgs extends FormatRequestArgs { - insertString?: string; - } - interface ChangeRequest extends FileLocationRequest { - command: CommandTypes.Change; - arguments: ChangeRequestArgs; - } - interface BraceResponse extends Response { - body?: TextSpan[]; - } - interface BraceRequest extends FileLocationRequest { - command: CommandTypes.Brace; - } - interface NavBarRequest extends FileRequest { - command: CommandTypes.NavBar; - } - interface NavTreeRequest extends FileRequest { - command: CommandTypes.NavTree; - } - interface NavigationBarItem { - text: string; - kind: string; - kindModifiers?: string; - spans: TextSpan[]; - childItems?: NavigationBarItem[]; - indent: number; - } - interface NavigationTree { - text: string; - kind: string; - kindModifiers: string; - spans: TextSpan[]; - childItems?: NavigationTree[]; - } - interface NavBarResponse extends Response { - body?: NavigationBarItem[]; - } - interface NavTreeResponse extends Response { - body?: NavigationTree; - } -} declare namespace ts { interface MapLike { [index: string]: T; @@ -729,241 +49,241 @@ declare namespace ts { ConflictMarkerTrivia = 7, NumericLiteral = 8, StringLiteral = 9, - RegularExpressionLiteral = 10, - NoSubstitutionTemplateLiteral = 11, - TemplateHead = 12, - TemplateMiddle = 13, - TemplateTail = 14, - OpenBraceToken = 15, - CloseBraceToken = 16, - OpenParenToken = 17, - CloseParenToken = 18, - OpenBracketToken = 19, - CloseBracketToken = 20, - DotToken = 21, - DotDotDotToken = 22, - SemicolonToken = 23, - CommaToken = 24, - LessThanToken = 25, - LessThanSlashToken = 26, - GreaterThanToken = 27, - LessThanEqualsToken = 28, - GreaterThanEqualsToken = 29, - EqualsEqualsToken = 30, - ExclamationEqualsToken = 31, - EqualsEqualsEqualsToken = 32, - ExclamationEqualsEqualsToken = 33, - EqualsGreaterThanToken = 34, - PlusToken = 35, - MinusToken = 36, - AsteriskToken = 37, - 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, - NeverKeyword = 127, - ReadonlyKeyword = 128, - RequireKeyword = 129, - NumberKeyword = 130, - SetKeyword = 131, - StringKeyword = 132, - SymbolKeyword = 133, - TypeKeyword = 134, - UndefinedKeyword = 135, - FromKeyword = 136, - GlobalKeyword = 137, - OfKeyword = 138, - QualifiedName = 139, - ComputedPropertyName = 140, - TypeParameter = 141, - Parameter = 142, - Decorator = 143, - PropertySignature = 144, - PropertyDeclaration = 145, - MethodSignature = 146, - MethodDeclaration = 147, - Constructor = 148, - GetAccessor = 149, - SetAccessor = 150, - CallSignature = 151, - ConstructSignature = 152, - IndexSignature = 153, - TypePredicate = 154, - TypeReference = 155, - FunctionType = 156, - ConstructorType = 157, - TypeQuery = 158, - TypeLiteral = 159, - ArrayType = 160, - TupleType = 161, - UnionType = 162, - IntersectionType = 163, - ParenthesizedType = 164, - ThisType = 165, - LiteralType = 166, - ObjectBindingPattern = 167, - ArrayBindingPattern = 168, - BindingElement = 169, - ArrayLiteralExpression = 170, - ObjectLiteralExpression = 171, - PropertyAccessExpression = 172, - ElementAccessExpression = 173, - CallExpression = 174, - NewExpression = 175, - TaggedTemplateExpression = 176, - TypeAssertionExpression = 177, - ParenthesizedExpression = 178, - FunctionExpression = 179, - ArrowFunction = 180, - DeleteExpression = 181, - TypeOfExpression = 182, - VoidExpression = 183, - AwaitExpression = 184, - PrefixUnaryExpression = 185, - PostfixUnaryExpression = 186, - BinaryExpression = 187, - ConditionalExpression = 188, - TemplateExpression = 189, - YieldExpression = 190, - SpreadElementExpression = 191, - ClassExpression = 192, - OmittedExpression = 193, - ExpressionWithTypeArguments = 194, - AsExpression = 195, - NonNullExpression = 196, - TemplateSpan = 197, - SemicolonClassElement = 198, - Block = 199, - VariableStatement = 200, - EmptyStatement = 201, - ExpressionStatement = 202, - IfStatement = 203, - DoStatement = 204, - WhileStatement = 205, - ForStatement = 206, - ForInStatement = 207, - ForOfStatement = 208, - ContinueStatement = 209, - BreakStatement = 210, - ReturnStatement = 211, - WithStatement = 212, - SwitchStatement = 213, - LabeledStatement = 214, - ThrowStatement = 215, - TryStatement = 216, - DebuggerStatement = 217, - VariableDeclaration = 218, - VariableDeclarationList = 219, - FunctionDeclaration = 220, - ClassDeclaration = 221, - InterfaceDeclaration = 222, - TypeAliasDeclaration = 223, - EnumDeclaration = 224, - ModuleDeclaration = 225, - ModuleBlock = 226, - CaseBlock = 227, - NamespaceExportDeclaration = 228, - ImportEqualsDeclaration = 229, - ImportDeclaration = 230, - ImportClause = 231, - NamespaceImport = 232, - NamedImports = 233, - ImportSpecifier = 234, - ExportAssignment = 235, - ExportDeclaration = 236, - NamedExports = 237, - ExportSpecifier = 238, - MissingDeclaration = 239, - ExternalModuleReference = 240, - JsxElement = 241, - JsxSelfClosingElement = 242, - JsxOpeningElement = 243, - JsxText = 244, + JsxText = 10, + RegularExpressionLiteral = 11, + NoSubstitutionTemplateLiteral = 12, + TemplateHead = 13, + TemplateMiddle = 14, + TemplateTail = 15, + OpenBraceToken = 16, + CloseBraceToken = 17, + OpenParenToken = 18, + CloseParenToken = 19, + OpenBracketToken = 20, + CloseBracketToken = 21, + DotToken = 22, + DotDotDotToken = 23, + SemicolonToken = 24, + CommaToken = 25, + LessThanToken = 26, + LessThanSlashToken = 27, + GreaterThanToken = 28, + LessThanEqualsToken = 29, + GreaterThanEqualsToken = 30, + EqualsEqualsToken = 31, + ExclamationEqualsToken = 32, + EqualsEqualsEqualsToken = 33, + ExclamationEqualsEqualsToken = 34, + EqualsGreaterThanToken = 35, + PlusToken = 36, + MinusToken = 37, + AsteriskToken = 38, + AsteriskAsteriskToken = 39, + SlashToken = 40, + PercentToken = 41, + PlusPlusToken = 42, + MinusMinusToken = 43, + LessThanLessThanToken = 44, + GreaterThanGreaterThanToken = 45, + GreaterThanGreaterThanGreaterThanToken = 46, + AmpersandToken = 47, + BarToken = 48, + CaretToken = 49, + ExclamationToken = 50, + TildeToken = 51, + AmpersandAmpersandToken = 52, + BarBarToken = 53, + QuestionToken = 54, + ColonToken = 55, + AtToken = 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 = 69, + Identifier = 70, + BreakKeyword = 71, + CaseKeyword = 72, + CatchKeyword = 73, + ClassKeyword = 74, + ConstKeyword = 75, + ContinueKeyword = 76, + DebuggerKeyword = 77, + DefaultKeyword = 78, + DeleteKeyword = 79, + DoKeyword = 80, + ElseKeyword = 81, + EnumKeyword = 82, + ExportKeyword = 83, + ExtendsKeyword = 84, + FalseKeyword = 85, + FinallyKeyword = 86, + ForKeyword = 87, + FunctionKeyword = 88, + IfKeyword = 89, + ImportKeyword = 90, + InKeyword = 91, + InstanceOfKeyword = 92, + NewKeyword = 93, + NullKeyword = 94, + ReturnKeyword = 95, + SuperKeyword = 96, + SwitchKeyword = 97, + ThisKeyword = 98, + ThrowKeyword = 99, + TrueKeyword = 100, + TryKeyword = 101, + TypeOfKeyword = 102, + VarKeyword = 103, + VoidKeyword = 104, + WhileKeyword = 105, + WithKeyword = 106, + ImplementsKeyword = 107, + InterfaceKeyword = 108, + LetKeyword = 109, + PackageKeyword = 110, + PrivateKeyword = 111, + ProtectedKeyword = 112, + PublicKeyword = 113, + StaticKeyword = 114, + YieldKeyword = 115, + AbstractKeyword = 116, + AsKeyword = 117, + AnyKeyword = 118, + AsyncKeyword = 119, + AwaitKeyword = 120, + BooleanKeyword = 121, + ConstructorKeyword = 122, + DeclareKeyword = 123, + GetKeyword = 124, + IsKeyword = 125, + ModuleKeyword = 126, + NamespaceKeyword = 127, + NeverKeyword = 128, + ReadonlyKeyword = 129, + RequireKeyword = 130, + NumberKeyword = 131, + SetKeyword = 132, + StringKeyword = 133, + SymbolKeyword = 134, + TypeKeyword = 135, + UndefinedKeyword = 136, + FromKeyword = 137, + GlobalKeyword = 138, + OfKeyword = 139, + QualifiedName = 140, + ComputedPropertyName = 141, + TypeParameter = 142, + Parameter = 143, + Decorator = 144, + PropertySignature = 145, + PropertyDeclaration = 146, + MethodSignature = 147, + MethodDeclaration = 148, + Constructor = 149, + GetAccessor = 150, + SetAccessor = 151, + CallSignature = 152, + ConstructSignature = 153, + IndexSignature = 154, + TypePredicate = 155, + TypeReference = 156, + FunctionType = 157, + ConstructorType = 158, + TypeQuery = 159, + TypeLiteral = 160, + ArrayType = 161, + TupleType = 162, + UnionType = 163, + IntersectionType = 164, + ParenthesizedType = 165, + ThisType = 166, + LiteralType = 167, + ObjectBindingPattern = 168, + ArrayBindingPattern = 169, + BindingElement = 170, + ArrayLiteralExpression = 171, + ObjectLiteralExpression = 172, + PropertyAccessExpression = 173, + ElementAccessExpression = 174, + CallExpression = 175, + NewExpression = 176, + TaggedTemplateExpression = 177, + TypeAssertionExpression = 178, + ParenthesizedExpression = 179, + FunctionExpression = 180, + ArrowFunction = 181, + DeleteExpression = 182, + TypeOfExpression = 183, + VoidExpression = 184, + AwaitExpression = 185, + PrefixUnaryExpression = 186, + PostfixUnaryExpression = 187, + BinaryExpression = 188, + ConditionalExpression = 189, + TemplateExpression = 190, + YieldExpression = 191, + SpreadElementExpression = 192, + ClassExpression = 193, + OmittedExpression = 194, + ExpressionWithTypeArguments = 195, + AsExpression = 196, + NonNullExpression = 197, + TemplateSpan = 198, + SemicolonClassElement = 199, + Block = 200, + VariableStatement = 201, + EmptyStatement = 202, + ExpressionStatement = 203, + IfStatement = 204, + DoStatement = 205, + WhileStatement = 206, + ForStatement = 207, + ForInStatement = 208, + ForOfStatement = 209, + ContinueStatement = 210, + BreakStatement = 211, + ReturnStatement = 212, + WithStatement = 213, + SwitchStatement = 214, + LabeledStatement = 215, + ThrowStatement = 216, + TryStatement = 217, + DebuggerStatement = 218, + VariableDeclaration = 219, + VariableDeclarationList = 220, + FunctionDeclaration = 221, + ClassDeclaration = 222, + InterfaceDeclaration = 223, + TypeAliasDeclaration = 224, + EnumDeclaration = 225, + ModuleDeclaration = 226, + ModuleBlock = 227, + CaseBlock = 228, + NamespaceExportDeclaration = 229, + ImportEqualsDeclaration = 230, + ImportDeclaration = 231, + ImportClause = 232, + NamespaceImport = 233, + NamedImports = 234, + ImportSpecifier = 235, + ExportAssignment = 236, + ExportDeclaration = 237, + NamedExports = 238, + ExportSpecifier = 239, + MissingDeclaration = 240, + ExternalModuleReference = 241, + JsxElement = 242, + JsxSelfClosingElement = 243, + JsxOpeningElement = 244, JsxClosingElement = 245, JsxAttribute = 246, JsxSpreadAttribute = 247, @@ -1009,31 +329,31 @@ declare namespace ts { NotEmittedStatement = 287, PartiallyEmittedExpression = 288, Count = 289, - FirstAssignment = 56, - LastAssignment = 68, - FirstCompoundAssignment = 57, - LastCompoundAssignment = 68, - FirstReservedWord = 70, - LastReservedWord = 105, - FirstKeyword = 70, - LastKeyword = 138, - FirstFutureReservedWord = 106, - LastFutureReservedWord = 114, - FirstTypeNode = 154, - LastTypeNode = 166, - FirstPunctuation = 15, - LastPunctuation = 68, + FirstAssignment = 57, + LastAssignment = 69, + FirstCompoundAssignment = 58, + LastCompoundAssignment = 69, + FirstReservedWord = 71, + LastReservedWord = 106, + FirstKeyword = 71, + LastKeyword = 139, + FirstFutureReservedWord = 107, + LastFutureReservedWord = 115, + FirstTypeNode = 155, + LastTypeNode = 167, + FirstPunctuation = 16, + LastPunctuation = 69, FirstToken = 0, - LastToken = 138, + LastToken = 139, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, - LastLiteralToken = 11, - FirstTemplateToken = 11, - LastTemplateToken = 14, - FirstBinaryOperator = 25, - LastBinaryOperator = 68, - FirstNode = 139, + LastLiteralToken = 12, + FirstTemplateToken = 12, + LastTemplateToken = 15, + FirstBinaryOperator = 26, + LastBinaryOperator = 69, + FirstNode = 140, FirstJSDocNode = 257, LastJSDocNode = 282, FirstJSDocTagNode = 273, @@ -1088,6 +408,7 @@ declare namespace ts { AccessibilityModifier = 28, ParameterPropertyModifier = 92, NonPublicAccessibilityModifier = 24, + TypeScriptModifier = 2270, } const enum JsxFlags { None = 0, @@ -1095,29 +416,12 @@ declare namespace ts { IntrinsicIndexedElement = 2, IntrinsicElement = 3, } - const enum RelationComparisonResult { - Succeeded = 1, - Failed = 2, - FailedAndReported = 3, - } interface Node extends TextRange { kind: SyntaxKind; flags: NodeFlags; - modifierFlagsCache?: ModifierFlags; - transformFlags?: TransformFlags; decorators?: NodeArray; modifiers?: ModifiersArray; - id?: number; parent?: Node; - original?: Node; - startsOnNewLine?: boolean; - jsDocComments?: JSDoc[]; - symbol?: Symbol; - locals?: SymbolTable; - nextContainer?: Node; - localSymbol?: Symbol; - flowNode?: FlowNode; - emitNode?: EmitNode; } interface NodeArray extends Array, TextRange { hasTrailingComma?: boolean; @@ -1135,19 +439,10 @@ declare namespace ts { type AtToken = Token; type Modifier = Token | Token | Token | Token | Token | Token | Token | Token | Token | Token | Token; type ModifiersArray = NodeArray; - const enum GeneratedIdentifierKind { - None = 0, - Auto = 1, - Loop = 2, - Unique = 3, - Node = 4, - } interface Identifier extends PrimaryExpression { kind: SyntaxKind.Identifier; text: string; originalKeywordKind?: SyntaxKind; - autoGenerateKind?: GeneratedIdentifierKind; - autoGenerateId?: number; } interface TransientIdentifier extends Identifier { resolvedSymbol: Symbol; @@ -1380,7 +675,6 @@ declare namespace ts { } interface StringLiteral extends LiteralExpression { kind: SyntaxKind.StringLiteral; - textSourceNode?: Identifier | StringLiteral; } interface Expression extends Node { _expressionBrand: any; @@ -1389,10 +683,6 @@ declare namespace ts { interface OmittedExpression extends Expression { kind: SyntaxKind.OmittedExpression; } - interface PartiallyEmittedExpression extends LeftHandSideExpression { - kind: SyntaxKind.PartiallyEmittedExpression; - expression: Expression; - } interface UnaryExpression extends Expression { _unaryExpressionBrand: any; } @@ -1506,7 +796,6 @@ declare namespace ts { text: string; isUnterminated?: boolean; hasExtendedUnicodeEscape?: boolean; - isOctalLiteral?: boolean; } interface LiteralExpression extends LiteralLikeNode, PrimaryExpression { _literalExpressionBrand: any; @@ -1548,7 +837,6 @@ declare namespace ts { interface ArrayLiteralExpression extends PrimaryExpression { kind: SyntaxKind.ArrayLiteralExpression; elements: NodeArray; - multiLine?: boolean; } interface SpreadElementExpression extends Expression { kind: SyntaxKind.SpreadElementExpression; @@ -1559,7 +847,6 @@ declare namespace ts { } interface ObjectLiteralExpression extends ObjectLiteralExpressionBase { kind: SyntaxKind.ObjectLiteralExpression; - multiLine?: boolean; } type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression; type EntityNameOrEntityNameExpression = EntityName | EntityNameExpression; @@ -1668,9 +955,6 @@ declare namespace ts { interface Statement extends Node { _statementBrand: any; } - interface NotEmittedStatement extends Statement { - kind: SyntaxKind.NotEmittedStatement; - } interface EmptyStatement extends Statement { kind: SyntaxKind.EmptyStatement; } @@ -1685,7 +969,6 @@ declare namespace ts { interface Block extends Statement { kind: SyntaxKind.Block; statements: NodeArray; - multiLine?: boolean; } interface VariableStatement extends Statement { kind: SyntaxKind.VariableStatement; @@ -2051,8 +1334,9 @@ declare namespace ts { TrueCondition = 32, FalseCondition = 64, SwitchClause = 128, - Referenced = 256, - Shared = 512, + ArrayMutation = 256, + Referenced = 512, + Shared = 1024, Label = 12, Condition = 96, } @@ -2080,6 +1364,10 @@ declare namespace ts { clauseEnd: number; antecedent: FlowNode; } + interface FlowArrayMutation extends FlowNode { + node: CallExpression | BinaryExpression; + antecedent: FlowNode; + } type FlowType = Type | IncompleteType; interface IncompleteType { flags: TypeFlags; @@ -2102,26 +1390,8 @@ declare namespace ts { typeReferenceDirectives: FileReference[]; languageVariant: LanguageVariant; isDeclarationFile: boolean; - renamedDependencies?: Map; hasNoDefaultLib: boolean; languageVersion: ScriptTarget; - scriptKind: ScriptKind; - externalModuleIndicator: Node; - commonJsModuleIndicator: Node; - identifiers: Map; - nodeCount: number; - identifierCount: number; - symbolCount: number; - parseDiagnostics: Diagnostic[]; - bindDiagnostics: Diagnostic[]; - lineMap: number[]; - classifiableNames?: Map; - resolvedModules: Map; - resolvedTypeReferenceDirectiveNames: Map; - imports: LiteralExpression[]; - moduleAugmentations: LiteralExpression[]; - patternAmbientModules?: PatternAmbientModule[]; - externalHelpersModuleName?: Identifier; } interface ScriptReferenceHost { getCompilerOptions(): CompilerOptions; @@ -2154,17 +1424,6 @@ declare namespace ts { getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; getTypeChecker(): TypeChecker; - getCommonSourceDirectory(): string; - getDiagnosticsProducingTypeChecker(): TypeChecker; - dropDiagnosticsProducingTypeChecker(): void; - getClassifiableNames(): Map; - getNodeCount(): number; - getIdentifierCount(): number; - getSymbolCount(): number; - getTypeCount(): number; - getFileProcessingDiagnostics(): DiagnosticCollection; - getResolvedTypeReferenceDirectives(): Map; - structureIsReused?: boolean; } interface SourceMapSpan { emittedLine: number; @@ -2195,13 +1454,6 @@ declare namespace ts { emitSkipped: boolean; diagnostics: Diagnostic[]; emittedFiles: string[]; - sourceMaps: SourceMapData[]; - } - interface TypeCheckerHost { - getCompilerOptions(): CompilerOptions; - getSourceFiles(): SourceFile[]; - getSourceFile(fileName: string): SourceFile; - getResolvedTypeReferenceDirectives(): Map; } interface TypeChecker { getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type; @@ -2241,13 +1493,6 @@ declare namespace ts { getJsxIntrinsicTagNames(): Symbol[]; isOptionalParameter(node: ParameterDeclaration): boolean; getAmbientModules(): Symbol[]; - getDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; - getGlobalDiagnostics(): Diagnostic[]; - getEmitResolver(sourceFile?: SourceFile, cancellationToken?: CancellationToken): EmitResolver; - getNodeCount(): number; - getIdentifierCount(): number; - getSymbolCount(): number; - getTypeCount(): number; } interface SymbolDisplayBuilder { buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; @@ -2295,11 +1540,6 @@ declare namespace ts { WriteTypeParametersOrArguments = 1, UseOnlyExternalAliasing = 2, } - const enum SymbolAccessibility { - Accessible = 0, - NotAccessible = 1, - CannotBeNamed = 2, - } const enum TypePredicateKind { This = 0, Identifier = 1, @@ -2317,60 +1557,6 @@ declare namespace ts { parameterIndex: number; } type TypePredicate = IdentifierTypePredicate | ThisTypePredicate; - type AnyImportSyntax = ImportDeclaration | ImportEqualsDeclaration; - interface SymbolVisibilityResult { - accessibility: SymbolAccessibility; - aliasesToMakeVisible?: AnyImportSyntax[]; - errorSymbolName?: string; - errorNode?: Node; - } - interface SymbolAccessibilityResult extends SymbolVisibilityResult { - errorModuleName?: string; - } - enum TypeReferenceSerializationKind { - Unknown = 0, - TypeWithConstructSignatureAndValue = 1, - VoidNullableOrNeverType = 2, - NumberLikeType = 3, - StringLikeType = 4, - BooleanType = 5, - ArrayLikeType = 6, - ESSymbolType = 7, - Promise = 8, - TypeWithCallSignature = 9, - ObjectType = 10, - } - interface EmitResolver { - hasGlobalName(name: string): boolean; - getReferencedExportContainer(node: Identifier, prefixLocals?: boolean): SourceFile | ModuleDeclaration | EnumDeclaration; - getReferencedImportDeclaration(node: Identifier): Declaration; - getReferencedDeclarationWithCollidingName(node: Identifier): Declaration; - isDeclarationWithCollidingName(node: Declaration): boolean; - isValueAliasDeclaration(node: Node): boolean; - isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean; - isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean; - getNodeCheckFlags(node: Node): NodeCheckFlags; - isDeclarationVisible(node: Declaration): boolean; - collectLinkedAliases(node: Identifier): Node[]; - isImplementationOfOverload(node: FunctionLikeDeclaration): boolean; - writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; - writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; - writeTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; - writeBaseConstructorTypeOfClass(node: ClassLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; - isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags, shouldComputeAliasToMarkVisible: boolean): SymbolAccessibilityResult; - isEntityNameVisible(entityName: EntityNameOrEntityNameExpression, enclosingDeclaration: Node): SymbolVisibilityResult; - getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number; - getReferencedValueDeclaration(reference: Identifier): Declaration; - getTypeReferenceSerializationKind(typeName: EntityName, location?: Node): TypeReferenceSerializationKind; - isOptionalParameter(node: ParameterDeclaration): boolean; - moduleExportsSomeValue(moduleReferenceExpression: Expression): boolean; - isArgumentsLocalBinding(node: Identifier): boolean; - getExternalModuleFileFromDeclaration(declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration): SourceFile; - getTypeReferenceDirectivesForEntityName(name: EntityNameOrEntityNameExpression): string[]; - getTypeReferenceDirectivesForSymbol(symbol: Symbol, meaning?: SymbolFlags): string[]; - isLiteralConstDeclaration(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration): boolean; - writeLiteralConstValue(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration, writer: SymbolWriter): void; - } const enum SymbolFlags { None = 0, FunctionScopedVariable = 1, @@ -2437,7 +1623,6 @@ declare namespace ts { PropertyOrAccessor = 98308, Export = 7340032, ClassMember = 106500, - Classifiable = 788448, } interface Symbol { flags: SymbolFlags; @@ -2447,83 +1632,8 @@ declare namespace ts { members?: SymbolTable; exports?: SymbolTable; globalExports?: SymbolTable; - isReadonly?: boolean; - id?: number; - mergeId?: number; - parent?: Symbol; - exportSymbol?: Symbol; - constEnumOnlyModule?: boolean; - isReferenced?: boolean; - isReplaceableByMethod?: boolean; - isAssigned?: boolean; - } - interface SymbolLinks { - target?: Symbol; - type?: Type; - declaredType?: Type; - typeParameters?: TypeParameter[]; - inferredClassType?: Type; - instantiations?: Map; - mapper?: TypeMapper; - referenced?: boolean; - containingType?: UnionOrIntersectionType; - hasNonUniformType?: boolean; - isPartial?: boolean; - isDiscriminantProperty?: boolean; - resolvedExports?: SymbolTable; - exportsChecked?: boolean; - isDeclarationWithCollidingName?: boolean; - bindingElement?: BindingElement; - exportsSomeValue?: boolean; - } - interface TransientSymbol extends Symbol, SymbolLinks { } type SymbolTable = Map; - interface Pattern { - prefix: string; - suffix: string; - } - interface PatternAmbientModule { - pattern: Pattern; - symbol: Symbol; - } - const enum NodeCheckFlags { - TypeChecked = 1, - LexicalThis = 2, - CaptureThis = 4, - SuperInstance = 256, - SuperStatic = 512, - ContextChecked = 1024, - AsyncMethodWithSuper = 2048, - AsyncMethodWithSuperBinding = 4096, - CaptureArguments = 8192, - EnumValuesComputed = 16384, - LexicalModuleMergesWithClass = 32768, - LoopWithCapturedBlockScopedBinding = 65536, - CapturedBlockScopedBinding = 131072, - BlockScopedBindingInLoop = 262144, - ClassWithBodyScopedClassBinding = 524288, - BodyScopedClassBinding = 1048576, - NeedsLoopOutParameter = 2097152, - AssignmentsMarked = 4194304, - ClassWithConstructorReference = 8388608, - ConstructorReferenceInClass = 16777216, - } - interface NodeLinks { - flags?: NodeCheckFlags; - resolvedType?: Type; - resolvedSignature?: Signature; - resolvedSymbol?: Symbol; - resolvedIndexInfo?: IndexInfo; - enumMemberValue?: number; - isVisible?: boolean; - hasReportedStatementInAmbientContext?: boolean; - jsxFlags?: JsxFlags; - resolvedJsxType?: Type; - hasSuperCall?: boolean; - superCall?: ExpressionStatement; - switchTypes?: Type[]; - } const enum TypeFlags { Any = 1, String = 2, @@ -2548,18 +1658,9 @@ declare namespace ts { Intersection = 1048576, Anonymous = 2097152, Instantiated = 4194304, - ObjectLiteral = 8388608, - FreshLiteral = 16777216, - ContainsWideningType = 33554432, - ContainsObjectLiteral = 67108864, - ContainsAnyFunctionType = 134217728, - Nullable = 6144, Literal = 480, StringOrNumberLiteral = 96, - DefinitelyFalsy = 7392, PossiblyFalsy = 7406, - Intrinsic = 16015, - Primitive = 8190, StringLike = 34, NumberLike = 340, BooleanLike = 136, @@ -2570,21 +1671,15 @@ declare namespace ts { StructuredOrTypeParameter = 4177920, Narrowable = 4178943, NotUnionOrUnit = 2589185, - RequiresWidening = 100663296, - PropagatingFlags = 234881024, } type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; interface Type { flags: TypeFlags; - id: number; symbol?: Symbol; pattern?: DestructuringPattern; aliasSymbol?: Symbol; aliasTypeArguments?: Type[]; } - interface IntrinsicType extends Type { - intrinsicName: string; - } interface LiteralType extends Type { text: string; freshType?: LiteralType; @@ -2604,8 +1699,6 @@ declare namespace ts { outerTypeParameters: TypeParameter[]; localTypeParameters: TypeParameter[]; thisType: TypeParameter; - resolvedBaseConstructorType?: Type; - resolvedBaseTypes: ObjectType[]; } interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; @@ -2619,42 +1712,16 @@ declare namespace ts { typeArguments: Type[]; } interface GenericType extends InterfaceType, TypeReference { - instantiations: Map; } interface UnionOrIntersectionType extends Type { types: Type[]; - resolvedProperties: SymbolTable; - couldContainTypeParameters: boolean; } interface UnionType extends UnionOrIntersectionType { } interface IntersectionType extends UnionOrIntersectionType { } - interface AnonymousType extends ObjectType { - target?: AnonymousType; - mapper?: TypeMapper; - } - interface ResolvedType extends ObjectType, UnionOrIntersectionType { - members: SymbolTable; - properties: Symbol[]; - callSignatures: Signature[]; - constructSignatures: Signature[]; - stringIndexInfo?: IndexInfo; - numberIndexInfo?: IndexInfo; - } - interface FreshObjectLiteralType extends ResolvedType { - regularType: ResolvedType; - } - interface IterableOrIteratorType extends ObjectType, UnionType { - iterableElementType?: Type; - iteratorElementType?: Type; - } interface TypeParameter extends Type { constraint: Type; - target?: TypeParameter; - mapper?: TypeMapper; - resolvedApparentType: Type; - isThisType?: boolean; } const enum SignatureKind { Call = 0, @@ -2664,17 +1731,6 @@ declare namespace ts { declaration: SignatureDeclaration; typeParameters: TypeParameter[]; parameters: Symbol[]; - thisParameter?: Symbol; - resolvedReturnType: Type; - minArgumentCount: number; - hasRestParameter: boolean; - hasLiteralTypes: boolean; - target?: Signature; - mapper?: TypeMapper; - unionSignatures?: Signature[]; - erasedSignatureCache?: Signature; - isolatedSignatureType?: ObjectType; - typePredicate?: TypePredicate; } const enum IndexKind { String = 0, @@ -2685,34 +1741,6 @@ declare namespace ts { isReadonly: boolean; declaration?: SignatureDeclaration; } - interface TypeMapper { - (t: TypeParameter): Type; - mappedTypes?: Type[]; - targetTypes?: Type[]; - instantiations?: Type[]; - context?: InferenceContext; - } - interface TypeInferences { - primary: Type[]; - secondary: Type[]; - topLevel: boolean; - isFixed: boolean; - } - interface InferenceContext { - signature: Signature; - inferUnionTypes: boolean; - inferences: TypeInferences[]; - inferredTypes: Type[]; - mapper?: TypeMapper; - failedTypeParameterIndex?: number; - } - const enum SpecialPropertyAssignmentKind { - None = 0, - ExportsProperty = 1, - ModuleExports = 2, - PrototypeProperty = 3, - ThisProperty = 4, - } interface DiagnosticMessage { key: string; category: DiagnosticCategory; @@ -2745,33 +1773,25 @@ declare namespace ts { type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike; interface CompilerOptions { allowJs?: boolean; - allowNonTsExtensions?: boolean; allowSyntheticDefaultImports?: boolean; allowUnreachableCode?: boolean; allowUnusedLabels?: boolean; alwaysStrict?: boolean; baseUrl?: string; charset?: string; - configFilePath?: string; declaration?: boolean; declarationDir?: string; - diagnostics?: boolean; - extendedDiagnostics?: boolean; disableSizeLimit?: boolean; emitBOM?: boolean; emitDecoratorMetadata?: boolean; experimentalDecorators?: boolean; forceConsistentCasingInFileNames?: boolean; - help?: boolean; importHelpers?: boolean; - init?: boolean; inlineSourceMap?: boolean; inlineSources?: boolean; isolatedModules?: boolean; jsx?: JsxEmit; lib?: string[]; - listEmittedFiles?: boolean; - listFiles?: boolean; locale?: string; mapRoot?: string; maxNodeModuleJsDepth?: number; @@ -2797,7 +1817,6 @@ declare namespace ts { paths?: MapLike; preserveConstEnums?: boolean; project?: string; - pretty?: DiagnosticStyle; reactNamespace?: string; removeComments?: boolean; rootDir?: string; @@ -2807,16 +1826,12 @@ declare namespace ts { sourceMap?: boolean; sourceRoot?: string; strictNullChecks?: boolean; - stripInternal?: boolean; suppressExcessPropertyErrors?: boolean; suppressImplicitAnyIndexErrors?: boolean; - suppressOutputPathCheck?: boolean; target?: ScriptTarget; traceResolution?: boolean; types?: string[]; typeRoots?: string[]; - version?: boolean; - watch?: boolean; [option: string]: CompilerOptionsValue | undefined; } interface TypingOptions { @@ -2839,7 +1854,6 @@ declare namespace ts { AMD = 2, UMD = 3, System = 4, - ES6 = 5, ES2015 = 5, } const enum JsxEmit { @@ -2865,18 +1879,15 @@ declare namespace ts { const enum ScriptTarget { ES3 = 0, ES5 = 1, - ES6 = 2, ES2015 = 2, - Latest = 2, + ES2016 = 3, + ES2017 = 4, + Latest = 4, } const enum LanguageVariant { Standard = 0, JSX = 1, } - const enum DiagnosticStyle { - Simple = 0, - Pretty = 1, - } interface ParsedCommandLine { options: CompilerOptions; typingOptions?: TypingOptions; @@ -2894,156 +1905,6 @@ declare namespace ts { fileNames: string[]; wildcardDirectories: MapLike; } - interface CommandLineOptionBase { - name: string; - type: "string" | "number" | "boolean" | "object" | "list" | Map; - isFilePath?: boolean; - shortName?: string; - description?: DiagnosticMessage; - paramType?: DiagnosticMessage; - experimental?: boolean; - isTSConfigOnly?: boolean; - } - interface CommandLineOptionOfPrimitiveType extends CommandLineOptionBase { - type: "string" | "number" | "boolean"; - } - interface CommandLineOptionOfCustomType extends CommandLineOptionBase { - type: Map; - } - interface TsConfigOnlyOption extends CommandLineOptionBase { - type: "object"; - } - interface CommandLineOptionOfListType extends CommandLineOptionBase { - type: "list"; - element: CommandLineOptionOfCustomType | CommandLineOptionOfPrimitiveType; - } - type CommandLineOption = CommandLineOptionOfCustomType | CommandLineOptionOfPrimitiveType | TsConfigOnlyOption | CommandLineOptionOfListType; - const enum CharacterCodes { - nullCharacter = 0, - maxAsciiCharacter = 127, - lineFeed = 10, - carriageReturn = 13, - lineSeparator = 8232, - paragraphSeparator = 8233, - nextLine = 133, - space = 32, - nonBreakingSpace = 160, - enQuad = 8192, - emQuad = 8193, - enSpace = 8194, - emSpace = 8195, - threePerEmSpace = 8196, - fourPerEmSpace = 8197, - sixPerEmSpace = 8198, - figureSpace = 8199, - punctuationSpace = 8200, - thinSpace = 8201, - hairSpace = 8202, - zeroWidthSpace = 8203, - narrowNoBreakSpace = 8239, - ideographicSpace = 12288, - mathematicalSpace = 8287, - ogham = 5760, - _ = 95, - $ = 36, - _0 = 48, - _1 = 49, - _2 = 50, - _3 = 51, - _4 = 52, - _5 = 53, - _6 = 54, - _7 = 55, - _8 = 56, - _9 = 57, - a = 97, - b = 98, - c = 99, - d = 100, - e = 101, - f = 102, - g = 103, - h = 104, - i = 105, - j = 106, - k = 107, - l = 108, - m = 109, - n = 110, - o = 111, - p = 112, - q = 113, - r = 114, - s = 115, - t = 116, - u = 117, - v = 118, - w = 119, - x = 120, - y = 121, - z = 122, - A = 65, - B = 66, - C = 67, - D = 68, - E = 69, - F = 70, - G = 71, - H = 72, - I = 73, - J = 74, - K = 75, - L = 76, - M = 77, - N = 78, - O = 79, - P = 80, - Q = 81, - R = 82, - S = 83, - T = 84, - U = 85, - V = 86, - W = 87, - X = 88, - Y = 89, - Z = 90, - ampersand = 38, - asterisk = 42, - at = 64, - backslash = 92, - backtick = 96, - bar = 124, - caret = 94, - closeBrace = 125, - closeBracket = 93, - closeParen = 41, - colon = 58, - comma = 44, - dot = 46, - doubleQuote = 34, - equals = 61, - exclamation = 33, - greaterThan = 62, - hash = 35, - lessThan = 60, - minus = 45, - openBrace = 123, - openBracket = 91, - openParen = 40, - percent = 37, - plus = 43, - question = 63, - semicolon = 59, - singleQuote = 39, - slash = 47, - tilde = 126, - backspace = 8, - formFeed = 12, - byteOrderMark = 65279, - tab = 9, - verticalTab = 11, - } interface ModuleResolutionHost { fileExists(fileName: string): boolean; readFile(fileName: string): string; @@ -3085,100 +1946,6 @@ declare namespace ts { resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; getEnvironmentVariable?(name: string): string; } - const enum TransformFlags { - None = 0, - TypeScript = 1, - ContainsTypeScript = 2, - Jsx = 4, - ContainsJsx = 8, - ES7 = 16, - ContainsES7 = 32, - ES6 = 64, - ContainsES6 = 128, - DestructuringAssignment = 256, - Generator = 512, - ContainsGenerator = 1024, - ContainsDecorators = 2048, - ContainsPropertyInitializer = 4096, - ContainsLexicalThis = 8192, - ContainsCapturedLexicalThis = 16384, - ContainsLexicalThisInComputedPropertyName = 32768, - ContainsDefaultValueAssignments = 65536, - ContainsParameterPropertyAssignments = 131072, - ContainsSpreadElementExpression = 262144, - ContainsComputedPropertyName = 524288, - ContainsBlockScopedBinding = 1048576, - ContainsBindingPattern = 2097152, - ContainsYield = 4194304, - ContainsHoistedDeclarationOrCompletion = 8388608, - HasComputedFlags = 536870912, - AssertTypeScript = 3, - AssertJsx = 12, - AssertES7 = 48, - AssertES6 = 192, - AssertGenerator = 1536, - NodeExcludes = 536871765, - ArrowFunctionExcludes = 550710101, - FunctionExcludes = 550726485, - ConstructorExcludes = 550593365, - MethodOrAccessorExcludes = 550593365, - ClassExcludes = 537590613, - ModuleExcludes = 546335573, - TypeExcludes = -3, - ObjectLiteralExcludes = 537430869, - ArrayLiteralOrCallOrNewExcludes = 537133909, - VariableDeclarationListExcludes = 538968917, - ParameterExcludes = 538968917, - TypeScriptClassSyntaxMask = 137216, - ES6FunctionSyntaxMask = 81920, - } - interface EmitNode { - flags?: EmitFlags; - commentRange?: TextRange; - sourceMapRange?: TextRange; - tokenSourceMapRanges?: Map; - annotatedNodes?: Node[]; - constantValue?: number; - } - const enum EmitFlags { - EmitEmitHelpers = 1, - EmitExportStar = 2, - EmitSuperHelper = 4, - EmitAdvancedSuperHelper = 8, - UMDDefine = 16, - SingleLine = 32, - AdviseOnEmitNode = 64, - NoSubstitution = 128, - CapturesThis = 256, - NoLeadingSourceMap = 512, - NoTrailingSourceMap = 1024, - NoSourceMap = 1536, - NoNestedSourceMaps = 2048, - NoTokenLeadingSourceMaps = 4096, - NoTokenTrailingSourceMaps = 8192, - NoTokenSourceMaps = 12288, - NoLeadingComments = 16384, - NoTrailingComments = 32768, - NoComments = 49152, - NoNestedComments = 65536, - ExportName = 131072, - LocalName = 262144, - Indented = 524288, - NoIndentation = 1048576, - AsyncFunctionBody = 2097152, - ReuseTempVariableScope = 4194304, - CustomPrologue = 8388608, - } - const enum EmitContext { - SourceFile = 0, - Expression = 1, - IdentifierName = 2, - Unspecified = 3, - } - interface LexicalEnvironment { - startLexicalEnvironment(): void; - endLexicalEnvironment(): Statement[]; - } interface TextSpan { start: number; length: number; @@ -3187,211 +1954,10 @@ declare namespace ts { span: TextSpan; newLength: number; } - interface DiagnosticCollection { - add(diagnostic: Diagnostic): void; - getGlobalDiagnostics(): Diagnostic[]; - getDiagnostics(fileName?: string): Diagnostic[]; - getModificationCount(): number; - reattachFileDiagnostics(newFile: SourceFile): void; - } interface SyntaxList extends Node { _children: Node[]; } } -declare namespace ts { - const timestamp: () => number; -} -declare namespace ts.performance { - function mark(markName: string): void; - function measure(measureName: string, startMarkName?: string, endMarkName?: string): void; - function getCount(markName: string): number; - function getDuration(measureName: string): number; - function forEachMeasure(cb: (measureName: string, duration: number) => void): void; - function enable(): void; - function disable(): void; -} -declare namespace ts { - const enum Ternary { - False = 0, - Maybe = 1, - True = -1, - } - function createMap(template?: MapLike): Map; - function createFileMap(keyMapper?: (key: string) => string): FileMap; - function toPath(fileName: string, basePath: string, getCanonicalFileName: (path: string) => string): Path; - const enum Comparison { - LessThan = -1, - EqualTo = 0, - GreaterThan = 1, - } - function forEach(array: T[] | undefined, callback: (element: T, index: number) => U | undefined): U | undefined; - function every(array: T[], callback: (element: T, index: number) => boolean): boolean; - function find(array: T[], predicate: (element: T, index: number) => boolean): T | undefined; - function findMap(array: T[], callback: (element: T, index: number) => U | undefined): U; - function contains(array: T[], value: T): boolean; - function indexOf(array: T[], value: T): number; - function indexOfAnyCharCode(text: string, charCodes: number[], start?: number): number; - function countWhere(array: T[], predicate: (x: T, i: number) => boolean): number; - function filter(array: T[], f: (x: T) => x is U): U[]; - function filter(array: T[], f: (x: T) => boolean): T[]; - function removeWhere(array: T[], f: (x: T) => boolean): boolean; - function filterMutate(array: T[], f: (x: T) => boolean): void; - function map(array: T[], f: (x: T, i: number) => U): U[]; - function flatten(array: (T | T[])[]): T[]; - function flatMap(array: T[], mapfn: (x: T, i: number) => U | U[]): U[]; - function span(array: T[], f: (x: T, i: number) => boolean): [T[], T[]]; - function spanMap(array: T[], keyfn: (x: T, i: number) => K, mapfn: (chunk: T[], key: K, start: number, end: number) => U): U[]; - function mapObject(object: MapLike, f: (key: string, x: T) => [string, U]): MapLike; - function concatenate(array1: T[], array2: T[]): T[]; - function deduplicate(array: T[], areEqual?: (a: T, b: T) => boolean): T[]; - function compact(array: T[]): T[]; - function sum(array: any[], prop: string): number; - function addRange(to: T[], from: T[]): void; - function rangeEquals(array1: T[], array2: T[], pos: number, end: number): boolean; - function firstOrUndefined(array: T[]): T; - function singleOrUndefined(array: T[]): T; - function singleOrMany(array: T[]): T | T[]; - function lastOrUndefined(array: T[]): T; - function binarySearch(array: T[], value: T, comparer?: (v1: T, v2: T) => number): number; - function reduceLeft(array: T[], f: (memo: U, value: T, i: number) => U, initial: U, start?: number, count?: number): U; - function reduceLeft(array: T[], f: (memo: T, value: T, i: number) => T): T; - function reduceRight(array: T[], f: (memo: U, value: T, i: number) => U, initial: U, start?: number, count?: number): U; - function reduceRight(array: T[], f: (memo: T, value: T, i: number) => T): T; - function hasProperty(map: MapLike, key: string): boolean; - function getProperty(map: MapLike, key: string): T | undefined; - function getOwnKeys(map: MapLike): string[]; - function forEachProperty(map: Map, callback: (value: T, key: string) => U): U; - function someProperties(map: Map, predicate?: (value: T, key: string) => boolean): boolean; - function copyProperties(source: Map, target: MapLike): void; - function assign, T2, T3>(t: T1, arg1: T2, arg2: T3): T1 & T2 & T3; - function assign, T2>(t: T1, arg1: T2): T1 & T2; - function assign>(t: T1, ...args: any[]): any; - function reduceProperties(map: Map, callback: (aggregate: U, value: T, key: string) => U, initial: U): U; - function reduceOwnProperties(map: MapLike, callback: (aggregate: U, value: T, key: string) => U, initial: U): U; - function equalOwnProperties(left: MapLike, right: MapLike, equalityComparer?: (left: T, right: T) => boolean): boolean; - function arrayToMap(array: T[], makeKey: (value: T) => string): Map; - function arrayToMap(array: T[], makeKey: (value: T) => string, makeValue: (value: T) => U): Map; - function isEmpty(map: Map): boolean; - function cloneMap(map: Map): Map; - function clone(object: T): T; - function extend(first: T1, second: T2): T1 & T2; - function multiMapAdd(map: Map, key: string, value: V): V[]; - function multiMapRemove(map: Map, key: string, value: V): void; - function isArray(value: any): value is any[]; - function memoize(callback: () => T): () => T; - function chain(...args: ((t: T) => (u: U) => U)[]): (t: T) => (u: U) => U; - function compose(...args: ((t: T) => T)[]): (t: T) => T; - let localizedDiagnosticMessages: Map; - function getLocaleSpecificMessage(message: DiagnosticMessage): string; - function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ...args: any[]): Diagnostic; - function formatMessage(dummy: any, message: DiagnosticMessage): string; - function createCompilerDiagnostic(message: DiagnosticMessage, ...args: any[]): Diagnostic; - function chainDiagnosticMessages(details: DiagnosticMessageChain, message: DiagnosticMessage, ...args: any[]): DiagnosticMessageChain; - function concatenateDiagnosticMessageChains(headChain: DiagnosticMessageChain, tailChain: DiagnosticMessageChain): DiagnosticMessageChain; - function compareValues(a: T, b: T): Comparison; - function compareStrings(a: string, b: string, ignoreCase?: boolean): Comparison; - function compareStringsCaseInsensitive(a: string, b: string): Comparison; - function compareDiagnostics(d1: Diagnostic, d2: Diagnostic): Comparison; - function sortAndDeduplicateDiagnostics(diagnostics: Diagnostic[]): Diagnostic[]; - function deduplicateSortedDiagnostics(diagnostics: Diagnostic[]): Diagnostic[]; - function normalizeSlashes(path: string): string; - function getRootLength(path: string): number; - const directorySeparator = "/"; - function normalizePath(path: string): string; - function pathEndsWithDirectorySeparator(path: string): boolean; - function getDirectoryPath(path: Path): Path; - function getDirectoryPath(path: string): string; - function isUrl(path: string): boolean; - function isExternalModuleNameRelative(moduleName: string): boolean; - function getEmitScriptTarget(compilerOptions: CompilerOptions): ScriptTarget; - function getEmitModuleKind(compilerOptions: CompilerOptions): ModuleKind; - function hasZeroOrOneAsteriskCharacter(str: string): boolean; - function isRootedDiskPath(path: string): boolean; - function convertToRelativePath(absoluteOrRelativePath: string, basePath: string, getCanonicalFileName: (path: string) => string): string; - function getNormalizedPathComponents(path: string, currentDirectory: string): string[]; - function getNormalizedAbsolutePath(fileName: string, currentDirectory: string): string; - function getNormalizedPathFromPathComponents(pathComponents: string[]): string; - function getRelativePathToDirectoryOrUrl(directoryPathOrUrl: string, relativeOrAbsolutePath: string, currentDirectory: string, getCanonicalFileName: (fileName: string) => string, isAbsolutePathAnUrl: boolean): string; - function getBaseFileName(path: string): string; - function combinePaths(path1: string, path2: string): string; - function removeTrailingDirectorySeparator(path: string): string; - function ensureTrailingDirectorySeparator(path: string): string; - function comparePaths(a: string, b: string, currentDirectory: string, ignoreCase?: boolean): Comparison; - function containsPath(parent: string, child: string, currentDirectory: string, ignoreCase?: boolean): boolean; - function startsWith(str: string, prefix: string): boolean; - function endsWith(str: string, suffix: string): boolean; - function fileExtensionIs(path: string, extension: string): boolean; - function fileExtensionIsAny(path: string, extensions: string[]): boolean; - function getRegularExpressionForWildcard(specs: string[], basePath: string, usage: "files" | "directories" | "exclude"): string; - interface FileSystemEntries { - files: string[]; - directories: string[]; - } - interface FileMatcherPatterns { - includeFilePattern: string; - includeDirectoryPattern: string; - excludePattern: string; - basePaths: string[]; - } - function getFileMatcherPatterns(path: string, extensions: string[], excludes: string[], includes: string[], useCaseSensitiveFileNames: boolean, currentDirectory: string): FileMatcherPatterns; - function matchFiles(path: string, extensions: string[], excludes: string[], includes: string[], useCaseSensitiveFileNames: boolean, currentDirectory: string, getFileSystemEntries: (path: string) => FileSystemEntries): string[]; - function ensureScriptKind(fileName: string, scriptKind?: ScriptKind): ScriptKind; - function getScriptKindFromFileName(fileName: string): ScriptKind; - const supportedTypeScriptExtensions: string[]; - const supportedTypescriptExtensionsForExtractExtension: string[]; - const supportedJavascriptExtensions: string[]; - function getSupportedExtensions(options?: CompilerOptions): string[]; - function hasJavaScriptFileExtension(fileName: string): boolean; - function hasTypeScriptFileExtension(fileName: string): boolean; - function isSupportedSourceFileName(fileName: string, compilerOptions?: CompilerOptions): boolean; - const enum ExtensionPriority { - TypeScriptFiles = 0, - DeclarationAndJavaScriptFiles = 2, - Limit = 5, - Highest = 0, - Lowest = 2, - } - function getExtensionPriority(path: string, supportedExtensions: string[]): ExtensionPriority; - function adjustExtensionPriority(extensionPriority: ExtensionPriority): ExtensionPriority; - function getNextLowestExtensionPriority(extensionPriority: ExtensionPriority): ExtensionPriority; - function removeFileExtension(path: string): string; - function tryRemoveExtension(path: string, extension: string): string | undefined; - function removeExtension(path: string, extension: string): string; - function isJsxOrTsxExtension(ext: string): boolean; - function changeExtension(path: T, newExtension: string): T; - interface ObjectAllocator { - getNodeConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => Node; - getTokenConstructor(): new (kind: TKind, pos?: number, end?: number) => Token; - getIdentifierConstructor(): new (kind: SyntaxKind.Identifier, pos?: number, end?: number) => Identifier; - getSourceFileConstructor(): new (kind: SyntaxKind.SourceFile, pos?: number, end?: number) => SourceFile; - getSymbolConstructor(): new (flags: SymbolFlags, name: string) => Symbol; - getTypeConstructor(): new (checker: TypeChecker, flags: TypeFlags) => Type; - getSignatureConstructor(): new (checker: TypeChecker) => Signature; - } - let objectAllocator: ObjectAllocator; - const enum AssertionLevel { - None = 0, - Normal = 1, - Aggressive = 2, - VeryAggressive = 3, - } - namespace Debug { - let currentAssertionLevel: AssertionLevel; - function shouldAssert(level: AssertionLevel): boolean; - function assert(expression: boolean, message?: string, verboseDebugInfo?: () => string): void; - function fail(message?: string): void; - } - function orderedRemoveItemAt(array: T[], index: number): void; - function unorderedRemoveItemAt(array: T[], index: number): void; - function unorderedRemoveItem(array: T[], item: T): void; - function createGetCanonicalFileName(useCaseSensitiveFileNames: boolean): (fileName: string) => string; - function matchPatternOrExact(patternStrings: string[], candidate: string): string | Pattern | undefined; - function patternText({prefix, suffix}: Pattern): string; - function matchedText(pattern: Pattern, candidate: string): string; - function findBestPatternMatch(values: T[], getPattern: (value: T) => Pattern, candidate: string): T | undefined; - function tryParsePattern(pattern: string): Pattern | undefined; - function positionIsSynthesized(pos: number): boolean; -} declare namespace ts { type FileWatcherCallback = (fileName: string, removed?: boolean) => void; type DirectoryWatcherCallback = (fileName: string) => void; @@ -3423,8 +1989,6 @@ declare namespace ts { getMemoryUsage?(): number; exit(exitCode?: number): void; realpath?(path: string): string; - getEnvironmentVariable(name: string): string; - tryEnableSourceMapsForHost?(): void; } interface FileWatcher { close(): void; @@ -3436,4682 +2000,45 @@ declare namespace ts { let sys: System; } declare namespace ts { - const Diagnostics: { - Unterminated_string_literal: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Identifier_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_file_cannot_have_a_reference_to_itself: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Trailing_comma_not_allowed: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Asterisk_Slash_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unexpected_token: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_rest_parameter_must_be_last_in_a_parameter_list: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_cannot_have_question_mark_and_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_required_parameter_cannot_follow_an_optional_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_index_signature_cannot_have_a_rest_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_index_signature_parameter_cannot_have_an_accessibility_modifier: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_index_signature_parameter_cannot_have_a_question_mark: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_index_signature_parameter_cannot_have_an_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_index_signature_must_have_a_type_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_index_signature_parameter_must_have_a_type_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_index_signature_parameter_type_must_be_string_or_number: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Accessibility_modifier_already_seen: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_must_precede_1_modifier: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_already_seen: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_cannot_appear_on_a_class_element: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - super_must_be_followed_by_an_argument_list_or_member_access: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Only_ambient_modules_can_use_quoted_names: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Statements_are_not_allowed_in_ambient_contexts: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_declare_modifier_cannot_be_used_in_an_already_ambient_context: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Initializers_are_not_allowed_in_ambient_contexts: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_cannot_be_used_in_an_ambient_context: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_cannot_be_used_with_a_class_declaration: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_cannot_be_used_here: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_cannot_appear_on_a_data_property: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_cannot_appear_on_a_module_or_namespace_element: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_0_modifier_cannot_be_used_with_an_interface_declaration: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_rest_parameter_cannot_be_optional: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_rest_parameter_cannot_have_an_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_set_accessor_must_have_exactly_one_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_set_accessor_cannot_have_an_optional_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_set_accessor_parameter_cannot_have_an_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_set_accessor_cannot_have_rest_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_get_accessor_cannot_have_parameters: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_is_not_a_valid_async_function_return_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_async_function_or_method_must_have_a_valid_awaitable_return_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Operand_for_await_does_not_have_a_valid_callable_then_member: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_expression_in_async_function_does_not_have_a_valid_callable_then_member: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Enum_member_must_have_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_export_assignment_cannot_be_used_in_a_namespace: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - In_ambient_enum_declarations_member_initializer_must_be_constant_expression: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unexpected_token_A_constructor_method_accessor_or_property_was_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_cannot_appear_on_a_type_member: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_cannot_appear_on_an_index_signature: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_0_modifier_cannot_be_used_with_an_import_declaration: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Invalid_reference_directive_syntax: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_accessor_cannot_be_declared_in_an_ambient_context: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_cannot_appear_on_a_constructor_declaration: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_cannot_appear_on_a_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameters_cannot_appear_on_a_constructor_declaration: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_annotation_cannot_appear_on_a_constructor_declaration: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_accessor_cannot_have_type_parameters: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_set_accessor_cannot_have_a_return_type_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_index_signature_must_have_exactly_one_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_list_cannot_be_empty: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_list_cannot_be_empty: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_argument_list_cannot_be_empty: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Invalid_use_of_0_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - with_statements_are_not_allowed_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - delete_cannot_be_called_on_an_identifier_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Jump_target_cannot_cross_function_boundary: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_return_statement_can_only_be_used_within_a_function_body: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Expression_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Duplicate_label_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_object_literal_cannot_have_property_and_accessor_with_the_same_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_export_assignment_cannot_have_modifiers: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Octal_literals_are_not_allowed_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_tuple_type_element_list_cannot_be_empty: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Variable_declaration_list_cannot_be_empty: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Digit_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Hexadecimal_digit_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unexpected_end_of_text: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Invalid_character: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Declaration_or_statement_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Statement_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - case_or_default_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_or_signature_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Enum_member_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Variable_declaration_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Argument_expression_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_assignment_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Expression_or_comma_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_declaration_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_declaration_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_argument_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - String_literal_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Line_break_not_permitted_here: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - or_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Declaration_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Import_declarations_in_a_namespace_cannot_reference_a_module: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_use_imports_exports_or_module_augmentations_when_module_is_none: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_name_0_differs_from_already_included_file_name_1_only_in_casing: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - const_declarations_must_be_initialized: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - const_declarations_can_only_be_declared_inside_a_block: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - let_declarations_can_only_be_declared_inside_a_block: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unterminated_template_literal: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unterminated_regular_expression_literal: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_object_member_cannot_be_declared_optional: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_yield_expression_is_only_allowed_in_a_generator_body: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Computed_property_names_are_not_allowed_in_enums: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_comma_expression_is_not_allowed_in_a_computed_property_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - extends_clause_already_seen: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - extends_clause_must_precede_implements_clause: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Classes_can_only_extend_a_single_class: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - implements_clause_already_seen: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Interface_declaration_cannot_have_implements_clause: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Binary_digit_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Octal_digit_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unexpected_token_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_destructuring_pattern_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Array_element_destructuring_pattern_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_destructuring_declaration_must_have_an_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_implementation_cannot_be_declared_in_ambient_contexts: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Modifiers_cannot_appear_here: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Merge_conflict_marker_encountered: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_rest_element_cannot_have_an_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_parameter_property_may_not_be_declared_using_a_binding_pattern: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_import_declaration_cannot_have_modifiers: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_0_has_no_default_export: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_export_declaration_cannot_have_modifiers: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Export_declarations_are_not_permitted_in_a_namespace: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Catch_clause_variable_name_must_be_an_identifier: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Catch_clause_variable_cannot_have_a_type_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Catch_clause_variable_cannot_have_an_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unterminated_Unicode_escape_sequence: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Line_terminator_not_permitted_before_arrow: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Import_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Export_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_export_default_or_another_module_format_instead: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Decorators_are_not_valid_here: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_class_declaration_without_the_default_modifier_must_have_a_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Identifier_expected_0_is_a_reserved_word_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Invalid_use_of_0_Modules_are_automatically_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Export_assignment_is_not_supported_when_module_flag_is_system: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Generators_are_not_allowed_in_an_ambient_context: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_overload_signature_cannot_be_declared_as_a_generator: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_tag_already_specified: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Signature_0_must_have_a_type_predicate: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_find_parameter_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_predicate_0_is_not_assignable_to_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_is_not_in_the_same_position_as_parameter_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_type_predicate_cannot_reference_a_rest_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_export_assignment_can_only_be_used_in_a_module: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_import_declaration_can_only_be_used_in_a_namespace_or_module: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_export_declaration_can_only_be_used_in_a_module: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_modifier_cannot_be_used_with_1_modifier: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Abstract_methods_can_only_appear_within_an_abstract_class: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_interface_property_cannot_have_an_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_type_literal_property_cannot_have_an_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_class_member_cannot_have_the_0_keyword: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_decorator_can_only_decorate_a_method_implementation_not_an_overload: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Class_definitions_are_automatically_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_are_automatically_in_strict_mode: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - with_statements_are_not_allowed_in_an_async_function_block: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - await_expression_is_only_allowed_within_an_async_function: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_body_of_an_if_statement_cannot_be_the_empty_statement: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Global_module_exports_may_only_appear_in_module_files: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Global_module_exports_may_only_appear_in_declaration_files: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Global_module_exports_may_only_appear_at_top_level: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_parameter_property_cannot_be_declared_using_a_rest_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Duplicate_identifier_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Static_members_cannot_reference_class_type_parameters: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Circular_definition_of_import_alias_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_find_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_0_has_no_exported_member_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_0_is_not_a_module: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_find_module_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_recursively_references_itself_as_a_base_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_class_may_only_extend_another_class: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_interface_may_only_extend_a_class_or_another_interface: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_0_has_a_circular_constraint: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Generic_type_0_requires_1_type_argument_s: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_is_not_generic: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Global_type_0_must_be_a_class_or_interface_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Global_type_0_must_have_1_type_parameter_s: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_find_global_type_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Named_property_0_of_types_1_and_2_are_not_identical: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Interface_0_cannot_simultaneously_extend_types_1_and_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Excessive_stack_depth_comparing_types_0_and_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_is_not_assignable_to_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_redeclare_exported_variable_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_is_missing_in_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_is_private_in_type_1_but_not_in_type_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Types_of_property_0_are_incompatible: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_is_optional_in_type_1_but_required_in_type_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Types_of_parameters_0_and_1_are_incompatible: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Index_signature_is_missing_in_type_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Index_signatures_are_incompatible: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - this_cannot_be_referenced_in_a_module_or_namespace_body: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - this_cannot_be_referenced_in_current_location: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - this_cannot_be_referenced_in_constructor_arguments: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - this_cannot_be_referenced_in_a_static_property_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - super_can_only_be_referenced_in_a_derived_class: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - super_cannot_be_referenced_in_constructor_arguments: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_does_not_exist_on_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_is_private_and_only_accessible_within_class_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_does_not_satisfy_the_constraint_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Supplied_parameters_do_not_match_any_signature_of_call_target: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Untyped_function_calls_may_not_accept_type_arguments: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Only_a_void_function_can_be_called_with_the_new_keyword: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_cannot_be_converted_to_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Invalid_left_hand_side_of_assignment_expression: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Operator_0_cannot_be_applied_to_types_1_and_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_name_cannot_be_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_parameter_property_is_only_allowed_in_a_constructor_implementation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_rest_parameter_must_be_of_an_array_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_cannot_be_referenced_in_its_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Duplicate_string_index_signature: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Duplicate_number_index_signature: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Constructors_for_derived_classes_must_contain_a_super_call: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_get_accessor_must_return_a_value: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Getter_and_setter_accessors_do_not_agree_in_visibility: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - get_and_set_accessor_must_have_the_same_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_signature_with_an_implementation_cannot_use_a_string_literal_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Overload_signatures_must_all_be_exported_or_non_exported: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Overload_signatures_must_all_be_ambient_or_non_ambient: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Overload_signatures_must_all_be_public_private_or_protected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Overload_signatures_must_all_be_optional_or_required: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Function_overload_must_be_static: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Function_overload_must_not_be_static: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Function_implementation_name_must_be_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Constructor_implementation_is_missing: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Function_implementation_is_missing_or_not_immediately_following_the_declaration: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Multiple_constructor_implementations_are_not_allowed: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Duplicate_function_implementation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Overload_signature_is_not_compatible_with_function_implementation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Declaration_name_conflicts_with_built_in_global_identifier_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Invalid_left_hand_side_in_for_in_statement: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Setters_cannot_return_a_value: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_of_type_1_is_not_assignable_to_string_index_type_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Numeric_index_type_0_is_not_assignable_to_string_index_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Class_name_cannot_be_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Class_0_incorrectly_extends_base_class_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Class_static_side_0_incorrectly_extends_base_class_static_side_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Class_0_incorrectly_implements_interface_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_class_may_only_implement_another_class_or_interface: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Interface_name_cannot_be_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - All_declarations_of_0_must_have_identical_type_parameters: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Interface_0_incorrectly_extends_interface_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Enum_name_cannot_be_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Ambient_module_declaration_cannot_specify_relative_module_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Import_name_cannot_be_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Import_declaration_conflicts_with_local_declaration_of_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Types_have_separate_declarations_of_a_private_property_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_is_protected_in_type_1_but_public_in_type_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Block_scoped_variable_0_used_before_its_declaration: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_redeclare_block_scoped_variable_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_enum_member_cannot_have_a_numeric_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Variable_0_is_used_before_being_assigned: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_alias_0_circularly_references_itself: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_alias_name_cannot_be_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_AMD_module_cannot_have_multiple_name_assignments: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_has_no_property_1_and_no_string_index_signature: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_has_no_property_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_is_not_an_array_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_rest_element_must_be_last_in_an_array_destructuring_pattern: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_computed_property_name_must_be_of_type_string_number_symbol_or_any: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - this_cannot_be_referenced_in_a_computed_property_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - super_cannot_be_referenced_in_a_computed_property_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_find_global_value_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_0_operator_cannot_be_applied_to_type_symbol: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_computed_property_name_of_the_form_0_must_be_of_type_symbol: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Enum_declarations_must_all_be_const_or_non_const: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - In_const_enum_declarations_member_initializer_must_be_constant_expression: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_const_enum_member_can_only_be_accessed_using_a_string_literal: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - const_enum_member_initializer_was_evaluated_to_a_non_finite_value: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_does_not_exist_on_const_enum_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Export_declaration_conflicts_with_exported_declaration_of_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_left_hand_side_of_a_for_of_statement_cannot_be_a_constant_or_a_read_only_property: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_left_hand_side_of_a_for_in_statement_cannot_be_a_constant_or_a_read_only_property: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Invalid_left_hand_side_in_for_of_statement: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_iterator_must_have_a_next_method: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_redeclare_identifier_0_in_catch_clause: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_is_not_an_array_type_or_a_string_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_0_uses_export_and_cannot_be_used_with_export_Asterisk: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_rest_element_cannot_contain_a_binding_pattern: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_find_namespace_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_generator_cannot_have_a_void_type_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_is_referenced_directly_or_indirectly_in_its_own_base_expression: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_is_not_a_constructor_function_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - No_base_constructor_has_the_specified_number_of_type_arguments: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Base_constructor_return_type_0_is_not_a_class_or_interface_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Base_constructors_must_all_have_the_same_return_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_create_an_instance_of_the_abstract_class_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Overload_signatures_must_all_be_abstract_or_non_abstract: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Classes_containing_abstract_methods_must_be_marked_abstract: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - All_declarations_of_an_abstract_method_must_be_consecutive: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - yield_expressions_cannot_be_used_in_a_parameter_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - await_expressions_cannot_be_used_in_a_parameter_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_module_cannot_have_multiple_default_exports: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_is_incompatible_with_index_signature: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Object_is_possibly_null: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Object_is_possibly_undefined: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Object_is_possibly_null_or_undefined: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_function_returning_never_cannot_have_a_reachable_end_point: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Enum_type_0_has_members_with_initializers_that_are_not_literals: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - JSX_element_attributes_type_0_may_not_be_a_union_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_in_type_1_is_not_assignable_to_type_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - JSX_element_type_0_does_not_have_any_construct_or_call_signatures: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_global_type_JSX_0_may_not_have_more_than_one_property: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_emit_namespaced_JSX_elements_in_React: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - JSX_expressions_must_have_one_parent_element: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_provides_no_match_for_the_signature_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_find_name_0_Did_you_mean_the_static_member_1_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_find_name_0_Did_you_mean_the_instance_member_this_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Invalid_module_name_in_augmentation_module_0_cannot_be_found: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Exports_and_export_assignments_are_not_permitted_in_module_augmentations: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_augment_module_0_because_it_resolves_to_a_non_module_entity: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_assign_a_0_constructor_type_to_a_1_constructor_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_extend_a_class_0_Class_constructor_is_marked_as_private: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Accessors_must_both_be_abstract_or_non_abstract: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_0_is_not_comparable_to_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_function_that_is_called_with_the_new_keyword_cannot_have_a_this_type_that_is_void: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_this_parameter_must_be_the_first_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_constructor_cannot_have_a_this_parameter: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - get_and_set_accessor_must_have_the_same_this_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_this_types_of_each_signature_are_incompatible: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - All_declarations_of_0_must_have_identical_modifiers: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_find_type_definition_file_for_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_extend_an_interface_0_Did_you_mean_implements: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_class_must_be_declared_after_its_base_class: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_only_refers_to_a_type_but_is_being_used_as_a_value_here: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Namespace_0_has_no_exported_member_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Left_side_of_comma_operator_is_unused_and_has_no_side_effects: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Import_declaration_0_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_parameter_0_of_exported_function_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Implements_clause_of_exported_class_0_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Extends_clause_of_exported_class_0_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Exported_variable_0_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Exported_variable_0_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Public_static_property_0_of_exported_class_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Public_property_0_of_exported_class_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_of_exported_interface_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Return_type_of_exported_function_has_or_is_using_private_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_of_exported_function_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Exported_type_alias_0_has_or_is_using_private_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Default_export_of_the_module_has_or_is_using_private_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_current_host_does_not_support_the_0_option: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_find_the_common_subdirectory_path_for_the_input_files: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_read_file_0_Colon_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unsupported_file_encoding: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Failed_to_parse_file_0_Colon_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unknown_compiler_option_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Compiler_option_0_requires_a_value_of_type_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Could_not_write_file_0_Colon_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Option_0_cannot_be_specified_without_specifying_option_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Option_0_cannot_be_specified_with_option_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_tsconfig_json_file_is_already_defined_at_Colon_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_write_file_0_because_it_would_overwrite_input_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_find_a_tsconfig_json_file_at_the_specified_directory_Colon_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_specified_path_does_not_exist_Colon_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Option_paths_cannot_be_used_without_specifying_baseUrl_option: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Pattern_0_can_have_at_most_one_Asterisk_character: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Substitutions_for_pattern_0_should_be_an_array: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Substitutions_for_pattern_0_shouldn_t_be_an_empty_array: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Concatenate_and_emit_output_to_single_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Generates_corresponding_d_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Watch_input_files: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Redirect_output_structure_to_the_directory: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Do_not_erase_const_enum_declarations_in_generated_code: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Do_not_emit_outputs_if_any_errors_were_reported: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Do_not_emit_comments_to_output: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Do_not_emit_outputs: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Skip_type_checking_of_declaration_files: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Print_this_message: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Print_the_compiler_s_version: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Compile_the_project_in_the_given_directory: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Syntax_Colon_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - options: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Examples_Colon_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Options_Colon: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Version_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Insert_command_line_options_and_files_from_a_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_change_detected_Starting_incremental_compilation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - KIND: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - FILE: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - VERSION: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - LOCATION: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - DIRECTORY: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - STRATEGY: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Compilation_complete_Watching_for_file_changes: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Generates_corresponding_map_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Compiler_option_0_expects_an_argument: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unterminated_quoted_string_in_response_file_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Argument_for_0_option_must_be_Colon_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unsupported_locale_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unable_to_open_file_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Corrupted_locale_file_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Raise_error_on_expressions_and_declarations_with_an_implied_any_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_0_not_found: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_0_has_unsupported_extension_The_only_supported_extensions_are_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Do_not_emit_declarations_for_code_that_has_an_internal_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - NEWLINE: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Option_0_can_only_be_specified_in_tsconfig_json_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Enables_experimental_support_for_ES7_decorators: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Enables_experimental_support_for_emitting_type_metadata_for_decorators: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Enables_experimental_support_for_ES7_async_functions: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Successfully_created_a_tsconfig_json_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Suppress_excess_property_checks_for_object_literals: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Stylize_errors_and_messages_using_color_and_context_experimental: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Do_not_report_errors_on_unused_labels: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Report_error_when_not_all_code_paths_in_function_return_a_value: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Report_errors_for_fallthrough_cases_in_switch_statement: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Do_not_report_errors_on_unreachable_code: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Disallow_inconsistently_cased_references_to_the_same_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specify_library_files_to_be_included_in_the_compilation_Colon: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specify_JSX_code_generation_Colon_preserve_or_react: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Only_amd_and_system_modules_are_supported_alongside_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Base_directory_to_resolve_non_absolute_module_names: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Enable_tracing_of_the_name_resolution_process: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Resolving_module_0_from_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Explicitly_specified_module_resolution_kind_Colon_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_resolution_kind_is_not_specified_using_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_name_0_was_successfully_resolved_to_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_name_0_was_not_resolved: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_name_0_matched_pattern_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Trying_substitution_0_candidate_module_location_Colon_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Resolving_module_name_0_relative_to_base_url_1_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Loading_module_as_file_Slash_folder_candidate_module_location_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_0_does_not_exist: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_0_exist_use_it_as_a_name_resolution_result: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Loading_module_0_from_node_modules_folder: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Found_package_json_at_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - package_json_does_not_have_types_field: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - package_json_has_0_field_1_that_references_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Allow_javascript_files_to_be_compiled: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Option_0_should_have_array_of_strings_as_a_value: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Checking_if_0_is_the_longest_matching_prefix_for_1_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Expected_type_of_0_field_in_package_json_to_be_string_got_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Longest_matching_prefix_for_0_is_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Loading_0_from_the_root_dir_1_candidate_location_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Trying_other_entries_in_rootDirs: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Module_resolution_using_rootDirs_has_failed: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Do_not_emit_use_strict_directives_in_module_output: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Enable_strict_null_checks: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unknown_option_excludes_Did_you_mean_exclude: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Raise_error_on_this_expressions_with_an_implied_any_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Resolving_type_reference_directive_0_containing_file_1_root_directory_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Resolving_using_primary_search_paths: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Resolving_from_node_modules_folder: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_reference_directive_0_was_not_resolved: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Resolving_with_primary_search_path_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Root_directory_cannot_be_determined_skipping_primary_search_paths: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Type_declaration_files_to_be_included_in_compilation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Looking_up_in_node_modules_folder_initial_location_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_config_file_0_found_doesn_t_contain_any_source_files: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Resolving_real_path_for_0_result_1: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - File_name_0_has_a_1_extension_stripping_it: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_is_declared_but_never_used: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Report_errors_on_unused_locals: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Report_errors_on_unused_parameters: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_is_declared_but_never_used: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Import_emit_helpers_from_tslib: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parse_in_strict_mode_and_emit_use_strict_for_each_source_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Variable_0_implicitly_has_an_1_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Parameter_0_implicitly_has_an_1_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Member_0_implicitly_has_an_1_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Index_signature_of_object_type_implicitly_has_an_any_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Object_literal_s_property_0_implicitly_has_an_1_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Rest_parameter_0_implicitly_has_an_any_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unreachable_code_detected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unused_label: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Fallthrough_case_in_switch: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Not_all_code_paths_return_a_value: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Binding_element_0_implicitly_has_an_1_type: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - You_cannot_rename_this_element: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - import_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - export_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - type_parameter_declarations_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - implements_clauses_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - interface_declarations_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - module_declarations_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - type_aliases_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - _0_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - types_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - type_arguments_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - parameter_modifiers_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - enum_declarations_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - type_assertion_expressions_can_only_be_used_in_a_ts_file: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - class_expressions_are_not_currently_supported: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - JSX_attributes_must_only_be_assigned_a_non_empty_expression: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - JSX_elements_cannot_have_multiple_attributes_with_the_same_name: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Expected_corresponding_JSX_closing_tag_for_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - JSX_attribute_expected: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Cannot_use_JSX_unless_the_jsx_flag_is_provided: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - 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: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - JSX_element_0_has_no_corresponding_closing_tag: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Unknown_typing_option_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Circularity_detected_while_resolving_configuration_Colon_0: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_path_in_an_extends_options_must_be_relative_or_rooted: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Add_missing_super_call: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Make_super_call_the_first_statement_in_the_constructor: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Change_extends_to_implements: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Remove_unused_identifiers: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Implement_interface_on_reference: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Implement_interface_on_class: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Implement_inherited_abstract_class: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - }; + function getEffectiveTypeRoots(options: CompilerOptions, host: { + directoryExists?: (directoryName: string) => boolean; + getCurrentDirectory?: () => string; + }): string[] | undefined; + function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string, options: CompilerOptions, host: ModuleResolutionHost): ResolvedTypeReferenceDirectiveWithFailedLookupLocations; + function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[]; + function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; + function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; + function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; +} +declare namespace ts { + function getDefaultLibFileName(options: CompilerOptions): string; + function textSpanEnd(span: TextSpan): number; + function textSpanIsEmpty(span: TextSpan): boolean; + function textSpanContainsPosition(span: TextSpan, position: number): boolean; + function textSpanContainsTextSpan(span: TextSpan, other: TextSpan): boolean; + function textSpanOverlapsWith(span: TextSpan, other: TextSpan): boolean; + function textSpanOverlap(span1: TextSpan, span2: TextSpan): TextSpan; + function textSpanIntersectsWithTextSpan(span: TextSpan, other: TextSpan): boolean; + function textSpanIntersectsWith(span: TextSpan, start: number, length: number): boolean; + function decodedTextSpanIntersectsWith(start1: number, length1: number, start2: number, length2: number): boolean; + function textSpanIntersectsWithPosition(span: TextSpan, position: number): boolean; + function textSpanIntersection(span1: TextSpan, span2: TextSpan): TextSpan; + function createTextSpan(start: number, length: number): TextSpan; + function createTextSpanFromBounds(start: number, end: number): TextSpan; + function textChangeRangeNewSpan(range: TextChangeRange): TextSpan; + function textChangeRangeIsUnchanged(range: TextChangeRange): boolean; + function createTextChangeRange(span: TextSpan, newLength: number): TextChangeRange; + let unchangedTextChangeRange: TextChangeRange; + function collapseTextChangeRangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange; + function getTypeParameterOwner(d: Declaration): Declaration; + function isParameterPropertyDeclaration(node: ParameterDeclaration): boolean; + function getCombinedModifierFlags(node: Node): ModifierFlags; + function getCombinedNodeFlags(node: Node): NodeFlags; } declare namespace ts { interface ErrorCallback { (message: DiagnosticMessage, length: number): void; } - function tokenIsIdentifierOrKeyword(token: SyntaxKind): boolean; interface Scanner { getStartPos(): number; getToken(): SyntaxKind; @@ -8143,24 +2070,13 @@ declare namespace ts { scanRange(start: number, length: number, callback: () => T): T; tryScan(callback: () => T): T; } - function isUnicodeIdentifierStart(code: number, languageVersion: ScriptTarget): boolean; function tokenToString(t: SyntaxKind): string; - function stringToToken(s: string): SyntaxKind; - function computeLineStarts(text: string): number[]; function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number; - function computePositionOfLineAndCharacter(lineStarts: number[], line: number, character: number): number; - function getLineStarts(sourceFile: SourceFile): number[]; - function computeLineAndCharacterOfPosition(lineStarts: number[], position: number): { - line: number; - character: number; - }; function getLineAndCharacterOfPosition(sourceFile: SourceFile, position: number): LineAndCharacter; function isWhiteSpace(ch: number): boolean; function isWhiteSpaceSingleLine(ch: number): boolean; function isLineBreak(ch: number): boolean; - function isOctalDigit(ch: number): boolean; function couldStartTrivia(text: string, pos: number): boolean; - function skipTrivia(text: string, pos: number, stopAfterLineBreak?: boolean, stopAtComments?: boolean): number; function forEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U; function forEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U; function reduceEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U; @@ -8170,23 +2086,31 @@ declare namespace ts { function getShebang(text: string): string; function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean; function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean; - function isIdentifierText(name: string, languageVersion: ScriptTarget): boolean; function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, languageVariant?: LanguageVariant, text?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner; } declare namespace ts { - const compileOnSaveCommandLineOption: CommandLineOption; - const optionDeclarations: CommandLineOption[]; - let typingOptionDeclarations: CommandLineOption[]; - interface OptionNameMap { - optionNameMap: Map; - shortOptionNames: Map; + function createNode(kind: SyntaxKind, pos?: number, end?: number): Node; + function forEachChild(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T; + function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile; + function isExternalModule(file: SourceFile): boolean; + function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; +} +declare namespace ts { + const version = "2.1.0"; + function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName?: string): string; + function resolveTripleslashReference(moduleName: string, containingFile: string): string; + function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; + function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; + interface FormatDiagnosticsHost { + getCurrentDirectory(): string; + getCanonicalFileName(fileName: string): string; + getNewLine(): string; } - const defaultInitCompilerOptions: CompilerOptions; - function getOptionNameMap(): OptionNameMap; - function createCompilerDiagnosticForInvalidCustomType(opt: CommandLineOptionOfCustomType): Diagnostic; - function parseCustomTypeOption(opt: CommandLineOptionOfCustomType, value: string, errors: Diagnostic[]): string | number; - function parseListTypeOption(opt: CommandLineOptionOfListType, value: string, errors: Diagnostic[]): (string | number)[] | undefined; - function parseCommandLine(commandLine: string[], readFile?: (path: string) => string): ParsedCommandLine; + function formatDiagnostics(diagnostics: Diagnostic[], host: FormatDiagnosticsHost): string; + function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string; + function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program; +} +declare namespace ts { function readConfigFile(fileName: string, readFile: (path: string) => string): { config?: any; error?: Diagnostic; @@ -8195,9 +2119,6 @@ declare namespace ts { config?: any; error?: Diagnostic; }; - function generateTSConfig(options: CompilerOptions, fileNames: string[]): { - compilerOptions: Map; - }; function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[]): ParsedCommandLine; function convertCompileOnSaveOptionFromJson(jsonOption: any, basePath: string, errors: Diagnostic[]): boolean; function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { @@ -8209,939 +2130,6 @@ declare namespace ts { errors: Diagnostic[]; }; } -declare namespace ts.JsTyping { - interface TypingResolutionHost { - directoryExists: (path: string) => boolean; - fileExists: (fileName: string) => boolean; - readFile: (path: string, encoding?: string) => string; - readDirectory: (rootDir: string, extensions: string[], excludes: string[], includes: string[], depth?: number) => string[]; - } - function discoverTypings(host: TypingResolutionHost, fileNames: string[], projectRootPath: Path, safeListPath: Path, packageNameToTypingLocation: Map, typingOptions: TypingOptions, compilerOptions: CompilerOptions): { - cachedTypingPaths: string[]; - newTypingNames: string[]; - filesToWatch: string[]; - }; -} -declare namespace ts.server { - enum LogLevel { - terse = 0, - normal = 1, - requestTime = 2, - verbose = 3, - } - const emptyArray: ReadonlyArray; - interface Logger { - close(): void; - hasLevel(level: LogLevel): boolean; - loggingEnabled(): boolean; - perftrc(s: string): void; - info(s: string): void; - startGroup(): void; - endGroup(): void; - msg(s: string, type?: Msg.Types): void; - getLogFileName(): string; - } - namespace Msg { - type Err = "Err"; - const Err: Err; - type Info = "Info"; - const Info: Info; - type Perf = "Perf"; - const Perf: Perf; - type Types = Err | Info | Perf; - } - function createInstallTypingsRequest(project: Project, typingOptions: TypingOptions, cachePath?: string): DiscoverTypings; - namespace Errors { - function ThrowNoProject(): never; - function ThrowProjectLanguageServiceDisabled(): never; - function ThrowProjectDoesNotContainDocument(fileName: string, project: Project): never; - } - function getDefaultFormatCodeSettings(host: ServerHost): FormatCodeSettings; - function mergeMaps(target: MapLike, source: MapLike): void; - function removeItemFromSet(items: T[], itemToRemove: T): void; - type NormalizedPath = string & { - __normalizedPathTag: any; - }; - function toNormalizedPath(fileName: string): NormalizedPath; - function normalizedPathToPath(normalizedPath: NormalizedPath, currentDirectory: string, getCanonicalFileName: (f: string) => string): Path; - function asNormalizedPath(fileName: string): NormalizedPath; - interface NormalizedPathMap { - get(path: NormalizedPath): T; - set(path: NormalizedPath, value: T): void; - contains(path: NormalizedPath): boolean; - remove(path: NormalizedPath): void; - } - function createNormalizedPathMap(): NormalizedPathMap; - const nullLanguageService: LanguageService; - interface ServerLanguageServiceHost { - setCompilationSettings(options: CompilerOptions): void; - notifyFileRemoved(info: ScriptInfo): void; - } - const nullLanguageServiceHost: ServerLanguageServiceHost; - interface ProjectOptions { - configHasFilesProperty?: boolean; - files?: string[]; - wildcardDirectories?: Map; - compilerOptions?: CompilerOptions; - typingOptions?: TypingOptions; - compileOnSave?: boolean; - } - function isInferredProjectName(name: string): boolean; - function makeInferredProjectName(counter: number): string; - class ThrottledOperations { - private readonly host; - private pendingTimeouts; - constructor(host: ServerHost); - schedule(operationId: string, delay: number, cb: () => void): void; - private static run(self, operationId, cb); - } - class GcTimer { - private readonly host; - private readonly delay; - private readonly logger; - private timerId; - constructor(host: ServerHost, delay: number, logger: Logger); - scheduleCollect(): void; - private static run(self); - } -} -declare namespace ts { - function trace(host: ModuleResolutionHost, message: DiagnosticMessage, ...args: any[]): void; - function isTraceEnabled(compilerOptions: CompilerOptions, host: ModuleResolutionHost): boolean; - function createResolvedModule(resolvedFileName: string, isExternalLibraryImport: boolean, failedLookupLocations: string[]): ResolvedModuleWithFailedLookupLocations; - interface ModuleResolutionState { - host: ModuleResolutionHost; - compilerOptions: CompilerOptions; - traceEnabled: boolean; - skipTsx: boolean; - } - function getEffectiveTypeRoots(options: CompilerOptions, host: { - directoryExists?: (directoryName: string) => boolean; - getCurrentDirectory?: () => string; - }): string[] | undefined; - function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string, options: CompilerOptions, host: ModuleResolutionHost): ResolvedTypeReferenceDirectiveWithFailedLookupLocations; - function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[]; - function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; - function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; - function directoryProbablyExists(directoryName: string, host: { - directoryExists?: (directoryName: string) => boolean; - }): boolean; - function loadModuleFromNodeModules(moduleName: string, directory: string, failedLookupLocations: string[], state: ModuleResolutionState, checkOneLevel: boolean): string; - function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; -} -declare namespace ts { - const externalHelpersModuleNameText = "tslib"; - interface ReferencePathMatchResult { - fileReference?: FileReference; - diagnosticMessage?: DiagnosticMessage; - isNoDefaultLib?: boolean; - isTypeReferenceDirective?: boolean; - } - function getDeclarationOfKind(symbol: Symbol, kind: SyntaxKind): Declaration; - interface StringSymbolWriter extends SymbolWriter { - string(): string; - } - interface EmitHost extends ScriptReferenceHost { - getSourceFiles(): SourceFile[]; - isSourceFileFromExternalLibrary(file: SourceFile): boolean; - getCommonSourceDirectory(): string; - getCanonicalFileName(fileName: string): string; - getNewLine(): string; - isEmitBlocked(emitFileName: string): boolean; - writeFile: WriteFileCallback; - } - function getSingleLineStringWriter(): StringSymbolWriter; - function releaseStringWriter(writer: StringSymbolWriter): void; - function getFullWidth(node: Node): number; - function arrayIsEqualTo(array1: ReadonlyArray, array2: ReadonlyArray, equaler?: (a: T, b: T) => boolean): boolean; - function hasResolvedModule(sourceFile: SourceFile, moduleNameText: string): boolean; - function getResolvedModule(sourceFile: SourceFile, moduleNameText: string): ResolvedModule; - function setResolvedModule(sourceFile: SourceFile, moduleNameText: string, resolvedModule: ResolvedModule): void; - function setResolvedTypeReferenceDirective(sourceFile: SourceFile, typeReferenceDirectiveName: string, resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective): void; - function moduleResolutionIsEqualTo(oldResolution: ResolvedModule, newResolution: ResolvedModule): boolean; - function typeDirectiveIsEqualTo(oldResolution: ResolvedTypeReferenceDirective, newResolution: ResolvedTypeReferenceDirective): boolean; - function hasChangesInResolutions(names: string[], newResolutions: T[], oldResolutions: Map, comparer: (oldResolution: T, newResolution: T) => boolean): boolean; - function containsParseError(node: Node): boolean; - function getSourceFileOfNode(node: Node): SourceFile; - function isStatementWithLocals(node: Node): boolean; - function getStartPositionOfLine(line: number, sourceFile: SourceFile): number; - function nodePosToString(node: Node): string; - function getStartPosOfNode(node: Node): number; - function isDefined(value: any): boolean; - function getEndLinePosition(line: number, sourceFile: SourceFile): number; - function nodeIsMissing(node: Node): boolean; - function nodeIsPresent(node: Node): boolean; - function getTokenPosOfNode(node: Node, sourceFile?: SourceFile, includeJsDocComment?: boolean): number; - function isJSDocNode(node: Node): boolean; - function isJSDocTag(node: Node): boolean; - function getNonDecoratorTokenPosOfNode(node: Node, sourceFile?: SourceFile): number; - function getSourceTextOfNodeFromSourceFile(sourceFile: SourceFile, node: Node, includeTrivia?: boolean): string; - function getTextOfNodeFromSourceText(sourceText: string, node: Node): string; - function getTextOfNode(node: Node, includeTrivia?: boolean): string; - function getLiteralText(node: LiteralLikeNode, sourceFile: SourceFile, languageVersion: ScriptTarget): string; - function isBinaryOrOctalIntegerLiteral(node: LiteralLikeNode, text: string): boolean; - function escapeIdentifier(identifier: string): string; - function unescapeIdentifier(identifier: string): string; - function makeIdentifierFromModuleName(moduleName: string): string; - function isBlockOrCatchScoped(declaration: Declaration): boolean; - function isAmbientModule(node: Node): boolean; - function isShorthandAmbientModuleSymbol(moduleSymbol: Symbol): boolean; - function isBlockScopedContainerTopLevel(node: Node): boolean; - function isGlobalScopeAugmentation(module: ModuleDeclaration): boolean; - function isExternalModuleAugmentation(node: Node): boolean; - function isBlockScope(node: Node, parentNode: Node): boolean; - function getEnclosingBlockScopeContainer(node: Node): Node; - function isCatchClauseVariableDeclaration(declaration: Declaration): boolean; - function declarationNameToString(name: DeclarationName): string; - function createDiagnosticForNode(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): Diagnostic; - function createDiagnosticForNodeFromMessageChain(node: Node, messageChain: DiagnosticMessageChain): Diagnostic; - function getSpanOfTokenAtPosition(sourceFile: SourceFile, pos: number): TextSpan; - function getErrorSpanForNode(sourceFile: SourceFile, node: Node): TextSpan; - function isExternalOrCommonJsModule(file: SourceFile): boolean; - function isDeclarationFile(file: SourceFile): boolean; - function isConstEnumDeclaration(node: Node): boolean; - function isConst(node: Node): boolean; - function isLet(node: Node): boolean; - function isSuperCall(n: Node): n is SuperCall; - function isPrologueDirective(node: Node): boolean; - function getLeadingCommentRangesOfNode(node: Node, sourceFileOfNode: SourceFile): CommentRange[]; - function getLeadingCommentRangesOfNodeFromText(node: Node, text: string): CommentRange[]; - function getJsDocComments(node: Node, sourceFileOfNode: SourceFile): CommentRange[]; - function getJsDocCommentsFromText(node: Node, text: string): CommentRange[]; - let fullTripleSlashReferencePathRegEx: RegExp; - let fullTripleSlashReferenceTypeReferenceDirectiveRegEx: RegExp; - let fullTripleSlashAMDReferencePathRegEx: RegExp; - function isPartOfTypeNode(node: Node): boolean; - function forEachReturnStatement(body: Block, visitor: (stmt: ReturnStatement) => T): T; - function forEachYieldExpression(body: Block, visitor: (expr: YieldExpression) => void): void; - function isVariableLike(node: Node): node is VariableLikeDeclaration; - function isAccessor(node: Node): node is AccessorDeclaration; - function isClassLike(node: Node): node is ClassLikeDeclaration; - function isFunctionLike(node: Node): node is FunctionLikeDeclaration; - function isFunctionLikeKind(kind: SyntaxKind): boolean; - function introducesArgumentsExoticObject(node: Node): boolean; - function isIterationStatement(node: Node, lookInLabeledStatements: boolean): node is IterationStatement; - function isFunctionBlock(node: Node): boolean; - function isObjectLiteralMethod(node: Node): node is MethodDeclaration; - function isObjectLiteralOrClassExpressionMethod(node: Node): node is MethodDeclaration; - function isIdentifierTypePredicate(predicate: TypePredicate): predicate is IdentifierTypePredicate; - function isThisTypePredicate(predicate: TypePredicate): predicate is ThisTypePredicate; - function getContainingFunction(node: Node): FunctionLikeDeclaration; - function getContainingClass(node: Node): ClassLikeDeclaration; - function getThisContainer(node: Node, includeArrowFunctions: boolean): Node; - function getSuperContainer(node: Node, stopOnFunctions: boolean): Node; - function getImmediatelyInvokedFunctionExpression(func: Node): CallExpression; - function isSuperProperty(node: Node): node is SuperProperty; - function getEntityNameFromTypeNode(node: TypeNode): EntityNameOrEntityNameExpression; - function isCallLikeExpression(node: Node): node is CallLikeExpression; - function getInvokedExpression(node: CallLikeExpression): Expression; - function nodeCanBeDecorated(node: Node): boolean; - function nodeIsDecorated(node: Node): boolean; - function nodeOrChildIsDecorated(node: Node): boolean; - function childIsDecorated(node: Node): boolean; - function isJSXTagName(node: Node): boolean; - function isPartOfExpression(node: Node): boolean; - function isInstantiatedModule(node: ModuleDeclaration, preserveConstEnums: boolean): boolean; - function isExternalModuleImportEqualsDeclaration(node: Node): boolean; - function getExternalModuleImportEqualsDeclarationExpression(node: Node): Expression; - function isInternalModuleImportEqualsDeclaration(node: Node): node is ImportEqualsDeclaration; - function isSourceFileJavaScript(file: SourceFile): boolean; - function isInJavaScriptFile(node: Node): boolean; - function isRequireCall(expression: Node, checkArgumentIsStringLiteral: boolean): expression is CallExpression; - function isSingleOrDoubleQuote(charCode: number): boolean; - function isDeclarationOfFunctionExpression(s: Symbol): boolean; - function getSpecialPropertyAssignmentKind(expression: Node): SpecialPropertyAssignmentKind; - function getExternalModuleName(node: Node): Expression; - function getNamespaceDeclarationNode(node: ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration): ImportEqualsDeclaration | NamespaceImport; - function isDefaultImport(node: ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration): boolean; - function hasQuestionToken(node: Node): boolean; - function isJSDocConstructSignature(node: Node): boolean; - function getJSDocComments(node: Node, checkParentVariableStatement: boolean): string[]; - function getJSDocTypeTag(node: Node): JSDocTypeTag; - function getJSDocReturnTag(node: Node): JSDocReturnTag; - function getJSDocTemplateTag(node: Node): JSDocTemplateTag; - function getCorrespondingJSDocParameterTag(parameter: ParameterDeclaration): JSDocParameterTag; - function hasRestParameter(s: SignatureDeclaration): boolean; - function hasDeclaredRestParameter(s: SignatureDeclaration): boolean; - function isRestParameter(node: ParameterDeclaration): boolean; - function isDeclaredRestParam(node: ParameterDeclaration): boolean; - function isAssignmentTarget(node: Node): boolean; - function isNodeDescendantOf(node: Node, ancestor: Node): boolean; - function isInAmbientContext(node: Node): boolean; - function isDeclarationName(name: Node): boolean; - function isLiteralComputedPropertyDeclarationName(node: Node): boolean; - function isIdentifierName(node: Identifier): boolean; - function isAliasSymbolDeclaration(node: Node): boolean; - function exportAssignmentIsAlias(node: ExportAssignment): boolean; - function getClassExtendsHeritageClauseElement(node: ClassLikeDeclaration | InterfaceDeclaration): ExpressionWithTypeArguments; - function getClassImplementsHeritageClauseElements(node: ClassLikeDeclaration): NodeArray; - function getInterfaceBaseTypeNodes(node: InterfaceDeclaration): NodeArray; - function getHeritageClause(clauses: NodeArray, kind: SyntaxKind): HeritageClause; - function tryResolveScriptReference(host: ScriptReferenceHost, sourceFile: SourceFile, reference: FileReference): SourceFile; - function getAncestor(node: Node, kind: SyntaxKind): Node; - function getFileReferenceFromReferencePath(comment: string, commentRange: CommentRange): ReferencePathMatchResult; - function isKeyword(token: SyntaxKind): boolean; - function isTrivia(token: SyntaxKind): boolean; - function isAsyncFunctionLike(node: Node): boolean; - function isStringOrNumericLiteral(kind: SyntaxKind): boolean; - function hasDynamicName(declaration: Declaration): boolean; - function isDynamicName(name: DeclarationName): boolean; - function isWellKnownSymbolSyntactically(node: Expression): boolean; - function getPropertyNameForPropertyNameNode(name: DeclarationName): string; - function getPropertyNameForKnownSymbolName(symbolName: string): string; - function isESSymbolIdentifier(node: Node): boolean; - function isModifierKind(token: SyntaxKind): boolean; - function isParameterDeclaration(node: VariableLikeDeclaration): boolean; - function getRootDeclaration(node: Node): Node; - function nodeStartsNewLexicalEnvironment(node: Node): boolean; - function nodeIsSynthesized(node: TextRange): boolean; - function getOriginalNode(node: Node): Node; - function isParseTreeNode(node: Node): boolean; - function getParseTreeNode(node: Node): Node; - function getParseTreeNode(node: Node, nodeTest?: (node: Node) => node is T): T; - function getOriginalSourceFiles(sourceFiles: SourceFile[]): SourceFile[]; - function getOriginalNodeId(node: Node): number; - const enum Associativity { - Left = 0, - Right = 1, - } - function getExpressionAssociativity(expression: Expression): Associativity; - function getOperatorAssociativity(kind: SyntaxKind, operator: SyntaxKind, hasArguments?: boolean): Associativity; - function getExpressionPrecedence(expression: Expression): 0 | 1 | -1 | 2 | 4 | 3 | 16 | 10 | 5 | 6 | 11 | 8 | 19 | 18 | 17 | 15 | 14 | 13 | 12 | 9 | 7; - function getOperator(expression: Expression): SyntaxKind.Unknown | SyntaxKind.EndOfFileToken | SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.NumericLiteral | SyntaxKind.StringLiteral | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral | SyntaxKind.TemplateHead | SyntaxKind.TemplateMiddle | SyntaxKind.TemplateTail | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.OpenParenToken | SyntaxKind.CloseParenToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.DotToken | SyntaxKind.DotDotDotToken | SyntaxKind.SemicolonToken | SyntaxKind.CommaToken | SyntaxKind.LessThanToken | SyntaxKind.LessThanSlashToken | SyntaxKind.GreaterThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.EqualsEqualsToken | SyntaxKind.ExclamationEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.EqualsGreaterThanToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.AsteriskToken | SyntaxKind.AsteriskAsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken | SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken | SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken | SyntaxKind.ExclamationToken | SyntaxKind.TildeToken | SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken | SyntaxKind.QuestionToken | SyntaxKind.ColonToken | SyntaxKind.AtToken | SyntaxKind.EqualsToken | SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken | SyntaxKind.Identifier | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.LetKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.StaticKeyword | SyntaxKind.YieldKeyword | SyntaxKind.AbstractKeyword | SyntaxKind.AsKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.GetKeyword | SyntaxKind.IsKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.NumberKeyword | SyntaxKind.SetKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.TypeKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.FromKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.OfKeyword | SyntaxKind.QualifiedName | SyntaxKind.ComputedPropertyName | SyntaxKind.TypeParameter | SyntaxKind.Parameter | SyntaxKind.Decorator | SyntaxKind.PropertySignature | SyntaxKind.PropertyDeclaration | SyntaxKind.MethodSignature | SyntaxKind.MethodDeclaration | SyntaxKind.Constructor | SyntaxKind.GetAccessor | SyntaxKind.SetAccessor | SyntaxKind.CallSignature | SyntaxKind.ConstructSignature | SyntaxKind.IndexSignature | SyntaxKind.TypePredicate | SyntaxKind.TypeReference | SyntaxKind.FunctionType | SyntaxKind.ConstructorType | SyntaxKind.TypeQuery | SyntaxKind.TypeLiteral | SyntaxKind.ArrayType | SyntaxKind.TupleType | SyntaxKind.UnionType | SyntaxKind.IntersectionType | SyntaxKind.ParenthesizedType | SyntaxKind.ThisType | SyntaxKind.LiteralType | SyntaxKind.ObjectBindingPattern | SyntaxKind.ArrayBindingPattern | SyntaxKind.BindingElement | SyntaxKind.ArrayLiteralExpression | SyntaxKind.ObjectLiteralExpression | SyntaxKind.PropertyAccessExpression | SyntaxKind.ElementAccessExpression | SyntaxKind.CallExpression | SyntaxKind.NewExpression | SyntaxKind.TaggedTemplateExpression | SyntaxKind.TypeAssertionExpression | SyntaxKind.ParenthesizedExpression | SyntaxKind.FunctionExpression | SyntaxKind.ArrowFunction | SyntaxKind.DeleteExpression | SyntaxKind.TypeOfExpression | SyntaxKind.VoidExpression | SyntaxKind.AwaitExpression | SyntaxKind.ConditionalExpression | SyntaxKind.TemplateExpression | SyntaxKind.YieldExpression | SyntaxKind.SpreadElementExpression | SyntaxKind.ClassExpression | SyntaxKind.OmittedExpression | SyntaxKind.ExpressionWithTypeArguments | SyntaxKind.AsExpression | SyntaxKind.NonNullExpression | SyntaxKind.TemplateSpan | SyntaxKind.SemicolonClassElement | SyntaxKind.Block | SyntaxKind.VariableStatement | SyntaxKind.EmptyStatement | SyntaxKind.ExpressionStatement | SyntaxKind.IfStatement | SyntaxKind.DoStatement | SyntaxKind.WhileStatement | SyntaxKind.ForStatement | SyntaxKind.ForInStatement | SyntaxKind.ForOfStatement | SyntaxKind.ContinueStatement | SyntaxKind.BreakStatement | SyntaxKind.ReturnStatement | SyntaxKind.WithStatement | SyntaxKind.SwitchStatement | SyntaxKind.LabeledStatement | SyntaxKind.ThrowStatement | SyntaxKind.TryStatement | SyntaxKind.DebuggerStatement | SyntaxKind.VariableDeclaration | SyntaxKind.VariableDeclarationList | SyntaxKind.FunctionDeclaration | SyntaxKind.ClassDeclaration | SyntaxKind.InterfaceDeclaration | SyntaxKind.TypeAliasDeclaration | SyntaxKind.EnumDeclaration | SyntaxKind.ModuleDeclaration | SyntaxKind.ModuleBlock | SyntaxKind.CaseBlock | SyntaxKind.NamespaceExportDeclaration | SyntaxKind.ImportEqualsDeclaration | SyntaxKind.ImportDeclaration | SyntaxKind.ImportClause | SyntaxKind.NamespaceImport | SyntaxKind.NamedImports | SyntaxKind.ImportSpecifier | SyntaxKind.ExportAssignment | SyntaxKind.ExportDeclaration | SyntaxKind.NamedExports | SyntaxKind.ExportSpecifier | SyntaxKind.MissingDeclaration | SyntaxKind.ExternalModuleReference | SyntaxKind.JsxElement | SyntaxKind.JsxSelfClosingElement | SyntaxKind.JsxOpeningElement | SyntaxKind.JsxText | SyntaxKind.JsxClosingElement | SyntaxKind.JsxAttribute | SyntaxKind.JsxSpreadAttribute | SyntaxKind.JsxExpression | SyntaxKind.CaseClause | SyntaxKind.DefaultClause | SyntaxKind.HeritageClause | SyntaxKind.CatchClause | SyntaxKind.PropertyAssignment | SyntaxKind.ShorthandPropertyAssignment | SyntaxKind.EnumMember | SyntaxKind.SourceFile | SyntaxKind.JSDocTypeExpression | SyntaxKind.JSDocAllType | SyntaxKind.JSDocUnknownType | SyntaxKind.JSDocArrayType | SyntaxKind.JSDocUnionType | SyntaxKind.JSDocTupleType | SyntaxKind.JSDocNullableType | SyntaxKind.JSDocNonNullableType | SyntaxKind.JSDocRecordType | SyntaxKind.JSDocRecordMember | SyntaxKind.JSDocTypeReference | SyntaxKind.JSDocOptionalType | SyntaxKind.JSDocFunctionType | SyntaxKind.JSDocVariadicType | SyntaxKind.JSDocConstructorType | SyntaxKind.JSDocThisType | SyntaxKind.JSDocComment | SyntaxKind.JSDocTag | SyntaxKind.JSDocParameterTag | SyntaxKind.JSDocReturnTag | SyntaxKind.JSDocTypeTag | SyntaxKind.JSDocTemplateTag | SyntaxKind.JSDocTypedefTag | SyntaxKind.JSDocPropertyTag | SyntaxKind.JSDocTypeLiteral | SyntaxKind.JSDocLiteralType | SyntaxKind.JSDocNullKeyword | SyntaxKind.JSDocUndefinedKeyword | SyntaxKind.JSDocNeverKeyword | SyntaxKind.SyntaxList | SyntaxKind.NotEmittedStatement | SyntaxKind.PartiallyEmittedExpression | SyntaxKind.Count; - function getOperatorPrecedence(nodeKind: SyntaxKind, operatorKind: SyntaxKind, hasArguments?: boolean): 0 | 1 | -1 | 2 | 4 | 3 | 16 | 10 | 5 | 6 | 11 | 8 | 19 | 18 | 17 | 15 | 14 | 13 | 12 | 9 | 7; - function createDiagnosticCollection(): DiagnosticCollection; - function escapeString(s: string): string; - function isIntrinsicJsxName(name: string): boolean; - function escapeNonAsciiCharacters(s: string): string; - interface EmitTextWriter { - write(s: string): void; - writeTextOfNode(text: string, node: Node): void; - writeLine(): void; - increaseIndent(): void; - decreaseIndent(): void; - getText(): string; - rawWrite(s: string): void; - writeLiteral(s: string): void; - getTextPos(): number; - getLine(): number; - getColumn(): number; - getIndent(): number; - isAtStartOfLine(): boolean; - reset(): void; - } - function getIndentString(level: number): string; - function getIndentSize(): number; - function createTextWriter(newLine: String): EmitTextWriter; - function getResolvedExternalModuleName(host: EmitHost, file: SourceFile): string; - function getExternalModuleNameFromDeclaration(host: EmitHost, resolver: EmitResolver, declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration): string; - function getExternalModuleNameFromPath(host: EmitHost, fileName: string): string; - function getOwnEmitOutputFilePath(sourceFile: SourceFile, host: EmitHost, extension: string): string; - function getDeclarationEmitOutputFilePath(sourceFile: SourceFile, host: EmitHost): string; - interface EmitFileNames { - jsFilePath: string; - sourceMapFilePath: string; - declarationFilePath: string; - } - function getSourceFilesToEmit(host: EmitHost, targetSourceFile?: SourceFile): SourceFile[]; - function forEachTransformedEmitFile(host: EmitHost, sourceFiles: SourceFile[], action: (jsFilePath: string, sourceMapFilePath: string, declarationFilePath: string, sourceFiles: SourceFile[], isBundledEmit: boolean) => void, emitOnlyDtsFiles?: boolean): void; - function forEachExpectedEmitFile(host: EmitHost, action: (emitFileNames: EmitFileNames, sourceFiles: SourceFile[], isBundledEmit: boolean, emitOnlyDtsFiles: boolean) => void, targetSourceFile?: SourceFile, emitOnlyDtsFiles?: boolean): void; - function getSourceFilePathInNewDir(sourceFile: SourceFile, host: EmitHost, newDirPath: string): string; - function writeFile(host: EmitHost, diagnostics: DiagnosticCollection, fileName: string, data: string, writeByteOrderMark: boolean, sourceFiles?: SourceFile[]): void; - function getLineOfLocalPosition(currentSourceFile: SourceFile, pos: number): number; - function getLineOfLocalPositionFromLineMap(lineMap: number[], pos: number): number; - function getFirstConstructorWithBody(node: ClassLikeDeclaration): ConstructorDeclaration; - function getSetAccessorTypeAnnotationNode(accessor: SetAccessorDeclaration): TypeNode; - function getThisParameter(signature: SignatureDeclaration): ParameterDeclaration | undefined; - function parameterIsThisKeyword(parameter: ParameterDeclaration): boolean; - function isThisIdentifier(node: Node | undefined): boolean; - function identifierIsThisKeyword(id: Identifier): boolean; - interface AllAccessorDeclarations { - firstAccessor: AccessorDeclaration; - secondAccessor: AccessorDeclaration; - getAccessor: AccessorDeclaration; - setAccessor: AccessorDeclaration; - } - function getAllAccessorDeclarations(declarations: NodeArray, accessor: AccessorDeclaration): AllAccessorDeclarations; - function emitNewLineBeforeLeadingComments(lineMap: number[], writer: EmitTextWriter, node: TextRange, leadingComments: CommentRange[]): void; - function emitNewLineBeforeLeadingCommentsOfPosition(lineMap: number[], writer: EmitTextWriter, pos: number, leadingComments: CommentRange[]): void; - function emitNewLineBeforeLeadingCommentOfPosition(lineMap: number[], writer: EmitTextWriter, pos: number, commentPos: number): void; - function emitComments(text: string, lineMap: number[], writer: EmitTextWriter, comments: CommentRange[], leadingSeparator: boolean, trailingSeparator: boolean, newLine: string, writeComment: (text: string, lineMap: number[], writer: EmitTextWriter, commentPos: number, commentEnd: number, newLine: string) => void): void; - function emitDetachedComments(text: string, lineMap: number[], writer: EmitTextWriter, writeComment: (text: string, lineMap: number[], writer: EmitTextWriter, commentPos: number, commentEnd: number, newLine: string) => void, node: TextRange, newLine: string, removeComments: boolean): { - nodePos: number; - detachedCommentEndPos: number; - }; - function writeCommentRange(text: string, lineMap: number[], writer: EmitTextWriter, commentPos: number, commentEnd: number, newLine: string): void; - function hasModifiers(node: Node): boolean; - function hasModifier(node: Node, flags: ModifierFlags): boolean; - function getModifierFlags(node: Node): ModifierFlags; - function modifierToFlag(token: SyntaxKind): ModifierFlags; - function isLogicalOperator(token: SyntaxKind): boolean; - function isAssignmentOperator(token: SyntaxKind): boolean; - function tryGetClassExtendingExpressionWithTypeArguments(node: Node): ClassLikeDeclaration | undefined; - function isDestructuringAssignment(node: Node): node is BinaryExpression; - function isSupportedExpressionWithTypeArguments(node: ExpressionWithTypeArguments): boolean; - function isExpressionWithTypeArgumentsInClassExtendsClause(node: Node): boolean; - function isEntityNameExpression(node: Expression): node is EntityNameExpression; - function isRightSideOfQualifiedNameOrPropertyAccess(node: Node): boolean; - function isEmptyObjectLiteralOrArrayLiteral(expression: Node): boolean; - function getLocalSymbolForExportDefault(symbol: Symbol): Symbol; - function tryExtractTypeScriptExtension(fileName: string): string | undefined; - const stringify: (value: any) => string; - function convertToBase64(input: string): string; - function getNewLineCharacter(options: CompilerOptions): string; - function isSimpleExpression(node: Expression): boolean; - function formatSyntaxKind(kind: SyntaxKind): string; - function movePos(pos: number, value: number): number; - function createRange(pos: number, end: number): TextRange; - function moveRangeEnd(range: TextRange, end: number): TextRange; - function moveRangePos(range: TextRange, pos: number): TextRange; - function moveRangePastDecorators(node: Node): TextRange; - function moveRangePastModifiers(node: Node): TextRange; - function isCollapsedRange(range: TextRange): boolean; - function collapseRangeToStart(range: TextRange): TextRange; - function collapseRangeToEnd(range: TextRange): TextRange; - function createTokenRange(pos: number, token: SyntaxKind): TextRange; - function rangeIsOnSingleLine(range: TextRange, sourceFile: SourceFile): boolean; - function rangeStartPositionsAreOnSameLine(range1: TextRange, range2: TextRange, sourceFile: SourceFile): boolean; - function rangeEndPositionsAreOnSameLine(range1: TextRange, range2: TextRange, sourceFile: SourceFile): boolean; - function rangeStartIsOnSameLineAsRangeEnd(range1: TextRange, range2: TextRange, sourceFile: SourceFile): boolean; - function rangeEndIsOnSameLineAsRangeStart(range1: TextRange, range2: TextRange, sourceFile: SourceFile): boolean; - function positionsAreOnSameLine(pos1: number, pos2: number, sourceFile: SourceFile): boolean; - function getStartPositionOfRange(range: TextRange, sourceFile: SourceFile): number; - function collectExternalModuleInfo(sourceFile: SourceFile, resolver: EmitResolver): { - externalImports: (ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration)[]; - exportSpecifiers: Map; - exportEquals: ExportAssignment; - hasExportStarsToExportValues: boolean; - }; - function getInitializedVariables(node: VariableDeclarationList): VariableDeclaration[]; - function isMergedWithClass(node: Node): boolean; - function isFirstDeclarationOfKind(node: Node, kind: SyntaxKind): boolean; - function isNodeArray(array: T[]): array is NodeArray; - function isNoSubstitutionTemplateLiteral(node: Node): node is LiteralExpression; - function isLiteralKind(kind: SyntaxKind): boolean; - function isTextualLiteralKind(kind: SyntaxKind): boolean; - function isLiteralExpression(node: Node): node is LiteralExpression; - function isTemplateLiteralKind(kind: SyntaxKind): boolean; - function isTemplateHead(node: Node): node is TemplateHead; - function isTemplateMiddleOrTemplateTail(node: Node): node is TemplateMiddle | TemplateTail; - function isIdentifier(node: Node): node is Identifier; - function isGeneratedIdentifier(node: Node): boolean; - function isModifier(node: Node): node is Modifier; - function isQualifiedName(node: Node): node is QualifiedName; - function isComputedPropertyName(node: Node): node is ComputedPropertyName; - function isEntityName(node: Node): node is EntityName; - function isPropertyName(node: Node): node is PropertyName; - function isModuleName(node: Node): node is ModuleName; - function isBindingName(node: Node): node is BindingName; - function isTypeParameter(node: Node): node is TypeParameterDeclaration; - function isParameter(node: Node): node is ParameterDeclaration; - function isDecorator(node: Node): node is Decorator; - function isMethodDeclaration(node: Node): node is MethodDeclaration; - function isClassElement(node: Node): node is ClassElement; - function isObjectLiteralElementLike(node: Node): node is ObjectLiteralElementLike; - function isTypeNode(node: Node): node is TypeNode; - function isBindingPattern(node: Node): node is BindingPattern; - function isBindingElement(node: Node): node is BindingElement; - function isArrayBindingElement(node: Node): node is ArrayBindingElement; - function isPropertyAccessExpression(node: Node): node is PropertyAccessExpression; - function isElementAccessExpression(node: Node): node is ElementAccessExpression; - function isBinaryExpression(node: Node): node is BinaryExpression; - function isConditionalExpression(node: Node): node is ConditionalExpression; - function isCallExpression(node: Node): node is CallExpression; - function isTemplateLiteral(node: Node): node is TemplateLiteral; - function isSpreadElementExpression(node: Node): node is SpreadElementExpression; - function isExpressionWithTypeArguments(node: Node): node is ExpressionWithTypeArguments; - function isLeftHandSideExpression(node: Node): node is LeftHandSideExpression; - function isUnaryExpression(node: Node): node is UnaryExpression; - function isExpression(node: Node): node is Expression; - function isAssertionExpression(node: Node): node is AssertionExpression; - function isPartiallyEmittedExpression(node: Node): node is PartiallyEmittedExpression; - function isNotEmittedStatement(node: Node): node is NotEmittedStatement; - function isNotEmittedOrPartiallyEmittedNode(node: Node): node is NotEmittedStatement | PartiallyEmittedExpression; - function isOmittedExpression(node: Node): node is OmittedExpression; - function isTemplateSpan(node: Node): node is TemplateSpan; - function isBlock(node: Node): node is Block; - function isConciseBody(node: Node): node is ConciseBody; - function isFunctionBody(node: Node): node is FunctionBody; - function isForInitializer(node: Node): node is ForInitializer; - function isVariableDeclaration(node: Node): node is VariableDeclaration; - function isVariableDeclarationList(node: Node): node is VariableDeclarationList; - function isCaseBlock(node: Node): node is CaseBlock; - function isModuleBody(node: Node): node is ModuleBody; - function isImportEqualsDeclaration(node: Node): node is ImportEqualsDeclaration; - function isImportClause(node: Node): node is ImportClause; - function isNamedImportBindings(node: Node): node is NamedImportBindings; - function isImportSpecifier(node: Node): node is ImportSpecifier; - function isNamedExports(node: Node): node is NamedExports; - function isExportSpecifier(node: Node): node is ExportSpecifier; - function isModuleOrEnumDeclaration(node: Node): node is ModuleDeclaration | EnumDeclaration; - function isDeclaration(node: Node): node is Declaration; - function isDeclarationStatement(node: Node): node is DeclarationStatement; - function isStatementButNotDeclaration(node: Node): node is Statement; - function isStatement(node: Node): node is Statement; - function isModuleReference(node: Node): node is ModuleReference; - function isJsxOpeningElement(node: Node): node is JsxOpeningElement; - function isJsxClosingElement(node: Node): node is JsxClosingElement; - function isJsxTagNameExpression(node: Node): node is JsxTagNameExpression; - function isJsxChild(node: Node): node is JsxChild; - function isJsxAttributeLike(node: Node): node is JsxAttributeLike; - function isJsxSpreadAttribute(node: Node): node is JsxSpreadAttribute; - function isJsxAttribute(node: Node): node is JsxAttribute; - function isStringLiteralOrJsxExpression(node: Node): node is StringLiteral | JsxExpression; - function isCaseOrDefaultClause(node: Node): node is CaseOrDefaultClause; - function isHeritageClause(node: Node): node is HeritageClause; - function isCatchClause(node: Node): node is CatchClause; - function isPropertyAssignment(node: Node): node is PropertyAssignment; - function isShorthandPropertyAssignment(node: Node): node is ShorthandPropertyAssignment; - function isEnumMember(node: Node): node is EnumMember; - function isSourceFile(node: Node): node is SourceFile; - function isWatchSet(options: CompilerOptions): boolean; -} -declare namespace ts { - function getDefaultLibFileName(options: CompilerOptions): string; - function textSpanEnd(span: TextSpan): number; - function textSpanIsEmpty(span: TextSpan): boolean; - function textSpanContainsPosition(span: TextSpan, position: number): boolean; - function textSpanContainsTextSpan(span: TextSpan, other: TextSpan): boolean; - function textSpanOverlapsWith(span: TextSpan, other: TextSpan): boolean; - function textSpanOverlap(span1: TextSpan, span2: TextSpan): TextSpan; - function textSpanIntersectsWithTextSpan(span: TextSpan, other: TextSpan): boolean; - function textSpanIntersectsWith(span: TextSpan, start: number, length: number): boolean; - function decodedTextSpanIntersectsWith(start1: number, length1: number, start2: number, length2: number): boolean; - function textSpanIntersectsWithPosition(span: TextSpan, position: number): boolean; - function textSpanIntersection(span1: TextSpan, span2: TextSpan): TextSpan; - function createTextSpan(start: number, length: number): TextSpan; - function createTextSpanFromBounds(start: number, end: number): TextSpan; - function textChangeRangeNewSpan(range: TextChangeRange): TextSpan; - function textChangeRangeIsUnchanged(range: TextChangeRange): boolean; - function createTextChangeRange(span: TextSpan, newLength: number): TextChangeRange; - let unchangedTextChangeRange: TextChangeRange; - function collapseTextChangeRangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange; - function getTypeParameterOwner(d: Declaration): Declaration; - function isParameterPropertyDeclaration(node: ParameterDeclaration): boolean; - function getCombinedModifierFlags(node: Node): ModifierFlags; - function getCombinedNodeFlags(node: Node): NodeFlags; -} -declare namespace ts { - function updateNode(updated: T, original: T): T; - function createNodeArray(elements?: T[], location?: TextRange, hasTrailingComma?: boolean): NodeArray; - function createSynthesizedNode(kind: SyntaxKind, startsOnNewLine?: boolean): Node; - function createSynthesizedNodeArray(elements?: T[]): NodeArray; - function getSynthesizedClone(node: T): T; - function getMutableClone(node: T): T; - function createLiteral(textSource: StringLiteral | Identifier, location?: TextRange): StringLiteral; - function createLiteral(value: string, location?: TextRange): StringLiteral; - function createLiteral(value: number, location?: TextRange): NumericLiteral; - function createLiteral(value: boolean, location?: TextRange): BooleanLiteral; - function createLiteral(value: string | number | boolean, location?: TextRange): PrimaryExpression; - function createIdentifier(text: string, location?: TextRange): Identifier; - function createTempVariable(recordTempVariable: ((node: Identifier) => void) | undefined, location?: TextRange): Identifier; - function createLoopVariable(location?: TextRange): Identifier; - function createUniqueName(text: string, location?: TextRange): Identifier; - function getGeneratedNameForNode(node: Node, location?: TextRange): Identifier; - function createToken(token: TKind): Token; - function createSuper(): PrimaryExpression; - function createThis(location?: TextRange): PrimaryExpression; - function createNull(): PrimaryExpression; - function createComputedPropertyName(expression: Expression, location?: TextRange): ComputedPropertyName; - function updateComputedPropertyName(node: ComputedPropertyName, expression: Expression): ComputedPropertyName; - function createParameter(name: string | Identifier | BindingPattern, initializer?: Expression, location?: TextRange): ParameterDeclaration; - function createParameterDeclaration(decorators: Decorator[], modifiers: Modifier[], dotDotDotToken: DotDotDotToken, name: string | Identifier | BindingPattern, questionToken: QuestionToken, type: TypeNode, initializer: Expression, location?: TextRange, flags?: NodeFlags): ParameterDeclaration; - function updateParameterDeclaration(node: ParameterDeclaration, decorators: Decorator[], modifiers: Modifier[], name: BindingName, type: TypeNode, initializer: Expression): ParameterDeclaration; - function createProperty(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, questionToken: QuestionToken, type: TypeNode, initializer: Expression, location?: TextRange): PropertyDeclaration; - function updateProperty(node: PropertyDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, type: TypeNode, initializer: Expression): PropertyDeclaration; - function createMethod(decorators: Decorator[], modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | PropertyName, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags): MethodDeclaration; - function updateMethod(node: MethodDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): MethodDeclaration; - function createConstructor(decorators: Decorator[], modifiers: Modifier[], parameters: ParameterDeclaration[], body: Block, location?: TextRange, flags?: NodeFlags): ConstructorDeclaration; - function updateConstructor(node: ConstructorDeclaration, decorators: Decorator[], modifiers: Modifier[], parameters: ParameterDeclaration[], body: Block): ConstructorDeclaration; - function createGetAccessor(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags): GetAccessorDeclaration; - function updateGetAccessor(node: GetAccessorDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, parameters: ParameterDeclaration[], type: TypeNode, body: Block): GetAccessorDeclaration; - function createSetAccessor(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, parameters: ParameterDeclaration[], body: Block, location?: TextRange, flags?: NodeFlags): SetAccessorDeclaration; - function updateSetAccessor(node: SetAccessorDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, parameters: ParameterDeclaration[], body: Block): SetAccessorDeclaration; - function createObjectBindingPattern(elements: BindingElement[], location?: TextRange): ObjectBindingPattern; - function updateObjectBindingPattern(node: ObjectBindingPattern, elements: BindingElement[]): ObjectBindingPattern; - function createArrayBindingPattern(elements: ArrayBindingElement[], location?: TextRange): ArrayBindingPattern; - function updateArrayBindingPattern(node: ArrayBindingPattern, elements: ArrayBindingElement[]): ArrayBindingPattern; - function createBindingElement(propertyName: string | PropertyName, dotDotDotToken: DotDotDotToken, name: string | BindingName, initializer?: Expression, location?: TextRange): BindingElement; - function updateBindingElement(node: BindingElement, propertyName: PropertyName, name: BindingName, initializer: Expression): BindingElement; - function createArrayLiteral(elements?: Expression[], location?: TextRange, multiLine?: boolean): ArrayLiteralExpression; - function updateArrayLiteral(node: ArrayLiteralExpression, elements: Expression[]): ArrayLiteralExpression; - function createObjectLiteral(properties?: ObjectLiteralElementLike[], location?: TextRange, multiLine?: boolean): ObjectLiteralExpression; - function updateObjectLiteral(node: ObjectLiteralExpression, properties: ObjectLiteralElementLike[]): ObjectLiteralExpression; - function createPropertyAccess(expression: Expression, name: string | Identifier, location?: TextRange, flags?: NodeFlags): PropertyAccessExpression; - function updatePropertyAccess(node: PropertyAccessExpression, expression: Expression, name: Identifier): PropertyAccessExpression; - function createElementAccess(expression: Expression, index: number | Expression, location?: TextRange): ElementAccessExpression; - function updateElementAccess(node: ElementAccessExpression, expression: Expression, argumentExpression: Expression): ElementAccessExpression; - function createCall(expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[], location?: TextRange, flags?: NodeFlags): CallExpression; - function updateCall(node: CallExpression, expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): CallExpression; - function createNew(expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[], location?: TextRange, flags?: NodeFlags): NewExpression; - function updateNew(node: NewExpression, expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): NewExpression; - function createTaggedTemplate(tag: Expression, template: TemplateLiteral, location?: TextRange): TaggedTemplateExpression; - function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; - function createParen(expression: Expression, location?: TextRange): ParenthesizedExpression; - function updateParen(node: ParenthesizedExpression, expression: Expression): ParenthesizedExpression; - function createFunctionExpression(asteriskToken: AsteriskToken, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags): FunctionExpression; - function updateFunctionExpression(node: FunctionExpression, name: Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionExpression; - function createArrowFunction(modifiers: Modifier[], typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, equalsGreaterThanToken: EqualsGreaterThanToken, body: ConciseBody, location?: TextRange, flags?: NodeFlags): ArrowFunction; - function updateArrowFunction(node: ArrowFunction, modifiers: Modifier[], typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: ConciseBody): ArrowFunction; - function createDelete(expression: Expression, location?: TextRange): DeleteExpression; - function updateDelete(node: DeleteExpression, expression: Expression): Expression; - function createTypeOf(expression: Expression, location?: TextRange): TypeOfExpression; - function updateTypeOf(node: TypeOfExpression, expression: Expression): Expression; - function createVoid(expression: Expression, location?: TextRange): VoidExpression; - function updateVoid(node: VoidExpression, expression: Expression): VoidExpression; - function createAwait(expression: Expression, location?: TextRange): AwaitExpression; - function updateAwait(node: AwaitExpression, expression: Expression): AwaitExpression; - function createPrefix(operator: PrefixUnaryOperator, operand: Expression, location?: TextRange): PrefixUnaryExpression; - function updatePrefix(node: PrefixUnaryExpression, operand: Expression): PrefixUnaryExpression; - function createPostfix(operand: Expression, operator: PostfixUnaryOperator, location?: TextRange): PostfixUnaryExpression; - function updatePostfix(node: PostfixUnaryExpression, operand: Expression): PostfixUnaryExpression; - function createBinary(left: Expression, operator: BinaryOperator | BinaryOperatorToken, right: Expression, location?: TextRange): BinaryExpression; - function updateBinary(node: BinaryExpression, left: Expression, right: Expression): BinaryExpression; - function createConditional(condition: Expression, questionToken: QuestionToken, whenTrue: Expression, colonToken: ColonToken, whenFalse: Expression, location?: TextRange): ConditionalExpression; - function updateConditional(node: ConditionalExpression, condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; - function createTemplateExpression(head: TemplateHead, templateSpans: TemplateSpan[], location?: TextRange): TemplateExpression; - function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: TemplateSpan[]): TemplateExpression; - function createYield(asteriskToken: AsteriskToken, expression: Expression, location?: TextRange): YieldExpression; - function updateYield(node: YieldExpression, expression: Expression): YieldExpression; - function createSpread(expression: Expression, location?: TextRange): SpreadElementExpression; - function updateSpread(node: SpreadElementExpression, expression: Expression): SpreadElementExpression; - function createClassExpression(modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[], location?: TextRange): ClassExpression; - function updateClassExpression(node: ClassExpression, modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]): ClassExpression; - function createOmittedExpression(location?: TextRange): OmittedExpression; - function createExpressionWithTypeArguments(typeArguments: TypeNode[], expression: Expression, location?: TextRange): ExpressionWithTypeArguments; - function updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, typeArguments: TypeNode[], expression: Expression): ExpressionWithTypeArguments; - function createTemplateSpan(expression: Expression, literal: TemplateMiddle | TemplateTail, location?: TextRange): TemplateSpan; - function updateTemplateSpan(node: TemplateSpan, expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; - function createBlock(statements: Statement[], location?: TextRange, multiLine?: boolean, flags?: NodeFlags): Block; - function updateBlock(node: Block, statements: Statement[]): Block; - function createVariableStatement(modifiers: Modifier[], declarationList: VariableDeclarationList | VariableDeclaration[], location?: TextRange, flags?: NodeFlags): VariableStatement; - function updateVariableStatement(node: VariableStatement, modifiers: Modifier[], declarationList: VariableDeclarationList): VariableStatement; - function createVariableDeclarationList(declarations: VariableDeclaration[], location?: TextRange, flags?: NodeFlags): VariableDeclarationList; - function updateVariableDeclarationList(node: VariableDeclarationList, declarations: VariableDeclaration[]): VariableDeclarationList; - function createVariableDeclaration(name: string | BindingPattern | Identifier, type?: TypeNode, initializer?: Expression, location?: TextRange, flags?: NodeFlags): VariableDeclaration; - function updateVariableDeclaration(node: VariableDeclaration, name: BindingName, type: TypeNode, initializer: Expression): VariableDeclaration; - function createEmptyStatement(location: TextRange): EmptyStatement; - function createStatement(expression: Expression, location?: TextRange, flags?: NodeFlags): ExpressionStatement; - function updateStatement(node: ExpressionStatement, expression: Expression): ExpressionStatement; - function createIf(expression: Expression, thenStatement: Statement, elseStatement?: Statement, location?: TextRange): IfStatement; - function updateIf(node: IfStatement, expression: Expression, thenStatement: Statement, elseStatement: Statement): IfStatement; - function createDo(statement: Statement, expression: Expression, location?: TextRange): DoStatement; - function updateDo(node: DoStatement, statement: Statement, expression: Expression): DoStatement; - function createWhile(expression: Expression, statement: Statement, location?: TextRange): WhileStatement; - function updateWhile(node: WhileStatement, expression: Expression, statement: Statement): WhileStatement; - function createFor(initializer: ForInitializer, condition: Expression, incrementor: Expression, statement: Statement, location?: TextRange): ForStatement; - function updateFor(node: ForStatement, initializer: ForInitializer, condition: Expression, incrementor: Expression, statement: Statement): ForStatement; - function createForIn(initializer: ForInitializer, expression: Expression, statement: Statement, location?: TextRange): ForInStatement; - function updateForIn(node: ForInStatement, initializer: ForInitializer, expression: Expression, statement: Statement): ForInStatement; - function createForOf(initializer: ForInitializer, expression: Expression, statement: Statement, location?: TextRange): ForOfStatement; - function updateForOf(node: ForOfStatement, initializer: ForInitializer, expression: Expression, statement: Statement): ForOfStatement; - function createContinue(label?: Identifier, location?: TextRange): ContinueStatement; - function updateContinue(node: ContinueStatement, label: Identifier): ContinueStatement; - function createBreak(label?: Identifier, location?: TextRange): BreakStatement; - function updateBreak(node: BreakStatement, label: Identifier): BreakStatement; - function createReturn(expression?: Expression, location?: TextRange): ReturnStatement; - function updateReturn(node: ReturnStatement, expression: Expression): ReturnStatement; - function createWith(expression: Expression, statement: Statement, location?: TextRange): WithStatement; - function updateWith(node: WithStatement, expression: Expression, statement: Statement): WithStatement; - function createSwitch(expression: Expression, caseBlock: CaseBlock, location?: TextRange): SwitchStatement; - function updateSwitch(node: SwitchStatement, expression: Expression, caseBlock: CaseBlock): SwitchStatement; - function createLabel(label: string | Identifier, statement: Statement, location?: TextRange): LabeledStatement; - function updateLabel(node: LabeledStatement, label: Identifier, statement: Statement): LabeledStatement; - function createThrow(expression: Expression, location?: TextRange): ThrowStatement; - function updateThrow(node: ThrowStatement, expression: Expression): ThrowStatement; - function createTry(tryBlock: Block, catchClause: CatchClause, finallyBlock: Block, location?: TextRange): TryStatement; - function updateTry(node: TryStatement, tryBlock: Block, catchClause: CatchClause, finallyBlock: Block): TryStatement; - function createCaseBlock(clauses: CaseOrDefaultClause[], location?: TextRange): CaseBlock; - function updateCaseBlock(node: CaseBlock, clauses: CaseOrDefaultClause[]): CaseBlock; - function createFunctionDeclaration(decorators: Decorator[], modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags): FunctionDeclaration; - function updateFunctionDeclaration(node: FunctionDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionDeclaration; - function createClassDeclaration(decorators: Decorator[], modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[], location?: TextRange): ClassDeclaration; - function updateClassDeclaration(node: ClassDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]): ClassDeclaration; - function createImportDeclaration(decorators: Decorator[], modifiers: Modifier[], importClause: ImportClause, moduleSpecifier?: Expression, location?: TextRange): ImportDeclaration; - function updateImportDeclaration(node: ImportDeclaration, decorators: Decorator[], modifiers: Modifier[], importClause: ImportClause, moduleSpecifier: Expression): ImportDeclaration; - function createImportClause(name: Identifier, namedBindings: NamedImportBindings, location?: TextRange): ImportClause; - function updateImportClause(node: ImportClause, name: Identifier, namedBindings: NamedImportBindings): ImportClause; - function createNamespaceImport(name: Identifier, location?: TextRange): NamespaceImport; - function updateNamespaceImport(node: NamespaceImport, name: Identifier): NamespaceImport; - function createNamedImports(elements: ImportSpecifier[], location?: TextRange): NamedImports; - function updateNamedImports(node: NamedImports, elements: ImportSpecifier[]): NamedImports; - function createImportSpecifier(propertyName: Identifier, name: Identifier, location?: TextRange): ImportSpecifier; - function updateImportSpecifier(node: ImportSpecifier, propertyName: Identifier, name: Identifier): ImportSpecifier; - function createExportAssignment(decorators: Decorator[], modifiers: Modifier[], isExportEquals: boolean, expression: Expression, location?: TextRange): ExportAssignment; - function updateExportAssignment(node: ExportAssignment, decorators: Decorator[], modifiers: Modifier[], expression: Expression): ExportAssignment; - function createExportDeclaration(decorators: Decorator[], modifiers: Modifier[], exportClause: NamedExports, moduleSpecifier?: Expression, location?: TextRange): ExportDeclaration; - function updateExportDeclaration(node: ExportDeclaration, decorators: Decorator[], modifiers: Modifier[], exportClause: NamedExports, moduleSpecifier: Expression): ExportDeclaration; - function createNamedExports(elements: ExportSpecifier[], location?: TextRange): NamedExports; - function updateNamedExports(node: NamedExports, elements: ExportSpecifier[]): NamedExports; - function createExportSpecifier(name: string | Identifier, propertyName?: string | Identifier, location?: TextRange): ExportSpecifier; - function updateExportSpecifier(node: ExportSpecifier, name: Identifier, propertyName: Identifier): ExportSpecifier; - function createJsxElement(openingElement: JsxOpeningElement, children: JsxChild[], closingElement: JsxClosingElement, location?: TextRange): JsxElement; - function updateJsxElement(node: JsxElement, openingElement: JsxOpeningElement, children: JsxChild[], closingElement: JsxClosingElement): JsxElement; - function createJsxSelfClosingElement(tagName: JsxTagNameExpression, attributes: JsxAttributeLike[], location?: TextRange): JsxSelfClosingElement; - function updateJsxSelfClosingElement(node: JsxSelfClosingElement, tagName: JsxTagNameExpression, attributes: JsxAttributeLike[]): JsxSelfClosingElement; - function createJsxOpeningElement(tagName: JsxTagNameExpression, attributes: JsxAttributeLike[], location?: TextRange): JsxOpeningElement; - function updateJsxOpeningElement(node: JsxOpeningElement, tagName: JsxTagNameExpression, attributes: JsxAttributeLike[]): JsxOpeningElement; - function createJsxClosingElement(tagName: JsxTagNameExpression, location?: TextRange): JsxClosingElement; - function updateJsxClosingElement(node: JsxClosingElement, tagName: JsxTagNameExpression): JsxClosingElement; - function createJsxAttribute(name: Identifier, initializer: StringLiteral | JsxExpression, location?: TextRange): JsxAttribute; - function updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: StringLiteral | JsxExpression): JsxAttribute; - function createJsxSpreadAttribute(expression: Expression, location?: TextRange): JsxSpreadAttribute; - function updateJsxSpreadAttribute(node: JsxSpreadAttribute, expression: Expression): JsxSpreadAttribute; - function createJsxExpression(expression: Expression, location?: TextRange): JsxExpression; - function updateJsxExpression(node: JsxExpression, expression: Expression): JsxExpression; - function createHeritageClause(token: SyntaxKind, types: ExpressionWithTypeArguments[], location?: TextRange): HeritageClause; - function updateHeritageClause(node: HeritageClause, types: ExpressionWithTypeArguments[]): HeritageClause; - function createCaseClause(expression: Expression, statements: Statement[], location?: TextRange): CaseClause; - function updateCaseClause(node: CaseClause, expression: Expression, statements: Statement[]): CaseClause; - function createDefaultClause(statements: Statement[], location?: TextRange): DefaultClause; - function updateDefaultClause(node: DefaultClause, statements: Statement[]): DefaultClause; - function createCatchClause(variableDeclaration: string | VariableDeclaration, block: Block, location?: TextRange): CatchClause; - function updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration, block: Block): CatchClause; - function createPropertyAssignment(name: string | PropertyName, initializer: Expression, location?: TextRange): PropertyAssignment; - function updatePropertyAssignment(node: PropertyAssignment, name: PropertyName, initializer: Expression): PropertyAssignment; - function createShorthandPropertyAssignment(name: string | Identifier, objectAssignmentInitializer: Expression, location?: TextRange): ShorthandPropertyAssignment; - function updateShorthandPropertyAssignment(node: ShorthandPropertyAssignment, name: Identifier, objectAssignmentInitializer: Expression): ShorthandPropertyAssignment; - function updateSourceFileNode(node: SourceFile, statements: Statement[]): SourceFile; - function createNotEmittedStatement(original: Node): NotEmittedStatement; - function createPartiallyEmittedExpression(expression: Expression, original?: Node, location?: TextRange): PartiallyEmittedExpression; - function updatePartiallyEmittedExpression(node: PartiallyEmittedExpression, expression: Expression): PartiallyEmittedExpression; - function createComma(left: Expression, right: Expression): Expression; - function createLessThan(left: Expression, right: Expression, location?: TextRange): Expression; - function createAssignment(left: Expression, right: Expression, location?: TextRange): BinaryExpression; - function createStrictEquality(left: Expression, right: Expression): BinaryExpression; - function createStrictInequality(left: Expression, right: Expression): BinaryExpression; - function createAdd(left: Expression, right: Expression): BinaryExpression; - function createSubtract(left: Expression, right: Expression): BinaryExpression; - function createPostfixIncrement(operand: Expression, location?: TextRange): PostfixUnaryExpression; - function createLogicalAnd(left: Expression, right: Expression): BinaryExpression; - function createLogicalOr(left: Expression, right: Expression): BinaryExpression; - function createLogicalNot(operand: Expression): PrefixUnaryExpression; - function createVoidZero(): VoidExpression; - function createMemberAccessForPropertyName(target: Expression, memberName: PropertyName, location?: TextRange): MemberExpression; - function createRestParameter(name: string | Identifier): ParameterDeclaration; - function createFunctionCall(func: Expression, thisArg: Expression, argumentsList: Expression[], location?: TextRange): CallExpression; - function createFunctionApply(func: Expression, thisArg: Expression, argumentsExpression: Expression, location?: TextRange): CallExpression; - function createArraySlice(array: Expression, start?: number | Expression): CallExpression; - function createArrayConcat(array: Expression, values: Expression[]): CallExpression; - function createMathPow(left: Expression, right: Expression, location?: TextRange): CallExpression; - function createReactCreateElement(reactNamespace: string, tagName: Expression, props: Expression, children: Expression[], parentElement: JsxOpeningLikeElement, location: TextRange): LeftHandSideExpression; - function createLetDeclarationList(declarations: VariableDeclaration[], location?: TextRange): VariableDeclarationList; - function createConstDeclarationList(declarations: VariableDeclaration[], location?: TextRange): VariableDeclarationList; - function createHelperName(externalHelpersModuleName: Identifier | undefined, name: string): Identifier | PropertyAccessExpression; - function createExtendsHelper(externalHelpersModuleName: Identifier | undefined, name: Identifier): CallExpression; - function createAssignHelper(externalHelpersModuleName: Identifier | undefined, attributesSegments: Expression[]): CallExpression; - function createParamHelper(externalHelpersModuleName: Identifier | undefined, expression: Expression, parameterOffset: number, location?: TextRange): CallExpression; - function createMetadataHelper(externalHelpersModuleName: Identifier | undefined, metadataKey: string, metadataValue: Expression): CallExpression; - function createDecorateHelper(externalHelpersModuleName: Identifier | undefined, decoratorExpressions: Expression[], target: Expression, memberName?: Expression, descriptor?: Expression, location?: TextRange): CallExpression; - function createAwaiterHelper(externalHelpersModuleName: Identifier | undefined, hasLexicalArguments: boolean, promiseConstructor: EntityName | Expression, body: Block): CallExpression; - function createHasOwnProperty(target: LeftHandSideExpression, propertyName: Expression): CallExpression; - function createAdvancedAsyncSuperHelper(): VariableStatement; - function createSimpleAsyncSuperHelper(): VariableStatement; - interface CallBinding { - target: LeftHandSideExpression; - thisArg: Expression; - } - function createCallBinding(expression: Expression, recordTempVariable: (temp: Identifier) => void, languageVersion?: ScriptTarget, cacheIdentifiers?: boolean): CallBinding; - function inlineExpressions(expressions: Expression[]): Expression; - function createExpressionFromEntityName(node: EntityName | Expression): Expression; - function createExpressionForPropertyName(memberName: PropertyName): Expression; - function createExpressionForObjectLiteralElementLike(node: ObjectLiteralExpression, property: ObjectLiteralElementLike, receiver: Expression): Expression; - function addPrologueDirectives(target: Statement[], source: Statement[], ensureUseStrict?: boolean, visitor?: (node: Node) => VisitResult): number; - function ensureUseStrict(node: SourceFile): SourceFile; - function parenthesizeBinaryOperand(binaryOperator: SyntaxKind, operand: Expression, isLeftSideOfBinary: boolean, leftOperand?: Expression): Expression; - function parenthesizeForNew(expression: Expression): LeftHandSideExpression; - function parenthesizeForAccess(expression: Expression): LeftHandSideExpression; - function parenthesizePostfixOperand(operand: Expression): LeftHandSideExpression; - function parenthesizePrefixOperand(operand: Expression): UnaryExpression; - function parenthesizeExpressionForList(expression: Expression): Expression; - function parenthesizeExpressionForExpressionStatement(expression: Expression): Expression; - function parenthesizeConciseBody(body: ConciseBody): ConciseBody; - const enum OuterExpressionKinds { - Parentheses = 1, - Assertions = 2, - PartiallyEmittedExpressions = 4, - All = 7, - } - function skipOuterExpressions(node: Expression, kinds?: OuterExpressionKinds): Expression; - function skipOuterExpressions(node: Node, kinds?: OuterExpressionKinds): Node; - function skipParentheses(node: Expression): Expression; - function skipParentheses(node: Node): Node; - function skipAssertions(node: Expression): Expression; - function skipAssertions(node: Node): Node; - function skipPartiallyEmittedExpressions(node: Expression): Expression; - function skipPartiallyEmittedExpressions(node: Node): Node; - function startOnNewLine(node: T): T; - function setOriginalNode(node: T, original: Node): T; - function disposeEmitNodes(sourceFile: SourceFile): void; - function getEmitFlags(node: Node): EmitFlags; - function setEmitFlags(node: T, emitFlags: EmitFlags): T; - function setSourceMapRange(node: T, range: TextRange): T; - function setTokenSourceMapRange(node: T, token: SyntaxKind, range: TextRange): T; - function setCommentRange(node: T, range: TextRange): T; - function getCommentRange(node: Node): TextRange; - function getSourceMapRange(node: Node): TextRange; - function getTokenSourceMapRange(node: Node, token: SyntaxKind): TextRange; - function getConstantValue(node: PropertyAccessExpression | ElementAccessExpression): number; - function setConstantValue(node: PropertyAccessExpression | ElementAccessExpression, value: number): PropertyAccessExpression | ElementAccessExpression; - function setTextRange(node: T, location: TextRange): T; - function setNodeFlags(node: T, flags: NodeFlags): T; - function setMultiLine(node: T, multiLine: boolean): T; - function setHasTrailingComma(nodes: NodeArray, hasTrailingComma: boolean): NodeArray; - function getLocalNameForExternalImport(node: ImportDeclaration | ExportDeclaration | ImportEqualsDeclaration, sourceFile: SourceFile): Identifier; - function getExternalModuleNameLiteral(importNode: ImportDeclaration | ExportDeclaration | ImportEqualsDeclaration, sourceFile: SourceFile, host: EmitHost, resolver: EmitResolver, compilerOptions: CompilerOptions): StringLiteral; - function tryGetModuleNameFromFile(file: SourceFile, host: EmitHost, options: CompilerOptions): StringLiteral; -} -declare namespace ts { - function createNode(kind: SyntaxKind, pos?: number, end?: number): Node; - function forEachChild(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T; - function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile; - function isExternalModule(file: SourceFile): boolean; - function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; - function parseIsolatedJSDocComment(content: string, start?: number, length?: number): { - jsDoc: JSDoc; - diagnostics: Diagnostic[]; - }; - function parseJSDocTypeExpressionForTests(content: string, start?: number, length?: number): { - jsDocTypeExpression: JSDocTypeExpression; - diagnostics: Diagnostic[]; - }; -} -declare namespace ts { - const enum ModuleInstanceState { - NonInstantiated = 0, - Instantiated = 1, - ConstEnumOnly = 2, - } - function getModuleInstanceState(node: Node): ModuleInstanceState; - function bindSourceFile(file: SourceFile, options: CompilerOptions): void; - function computeTransformFlagsForNode(node: Node, subtreeFlags: TransformFlags): TransformFlags; -} -declare namespace ts { - function getNodeId(node: Node): number; - function getSymbolId(symbol: Symbol): number; - function createTypeChecker(host: TypeCheckerHost, produceDiagnostics: boolean): TypeChecker; -} -declare namespace ts { - type VisitResult = T | T[]; - function reduceEachChild(node: Node, f: (memo: T, node: Node) => T, initial: T): T; - function visitNode(node: T, visitor: (node: Node) => VisitResult, test: (node: Node) => boolean, optional?: boolean, lift?: (node: NodeArray) => T): T; - function visitNode(node: T, visitor: (node: Node) => VisitResult, test: (node: Node) => boolean, optional: boolean, lift: (node: NodeArray) => T, parenthesize: (node: Node, parentNode: Node) => Node, parentNode: Node): T; - function visitNodes(nodes: NodeArray, visitor: (node: Node) => VisitResult, test: (node: Node) => boolean, start?: number, count?: number): NodeArray; - function visitNodes(nodes: NodeArray, visitor: (node: Node) => VisitResult, test: (node: Node) => boolean, start: number, count: number, parenthesize: (node: Node, parentNode: Node) => Node, parentNode: Node): NodeArray; - function visitEachChild(node: T, visitor: (node: Node) => VisitResult, context: LexicalEnvironment): T; - function mergeFunctionBodyLexicalEnvironment(body: FunctionBody, declarations: Statement[]): FunctionBody; - function mergeFunctionBodyLexicalEnvironment(body: ConciseBody, declarations: Statement[]): ConciseBody; - function liftToBlock(nodes: Node[]): Statement; - function aggregateTransformFlags(node: T): T; - namespace Debug { - const failNotOptional: (message?: string) => void; - const failBadSyntaxKind: (node: Node, message?: string) => void; - const assertNode: (node: Node, test: (node: Node) => boolean, message?: string) => void; - } -} -declare namespace ts { - function flattenDestructuringAssignment(context: TransformationContext, node: BinaryExpression, needsValue: boolean, recordTempVariable: (node: Identifier) => void, visitor?: (node: Node) => VisitResult): Expression; - function flattenParameterDestructuring(context: TransformationContext, node: ParameterDeclaration, value: Expression, visitor?: (node: Node) => VisitResult): VariableDeclaration[]; - function flattenVariableDestructuring(context: TransformationContext, node: VariableDeclaration, value?: Expression, visitor?: (node: Node) => VisitResult, recordTempVariable?: (node: Identifier) => void): VariableDeclaration[]; - function flattenVariableDestructuringToExpression(context: TransformationContext, node: VariableDeclaration, recordTempVariable: (name: Identifier) => void, nameSubstitution?: (name: Identifier) => Expression, visitor?: (node: Node) => VisitResult): Expression; -} -declare namespace ts { - function transformTypeScript(context: TransformationContext): (node: SourceFile) => SourceFile; -} -declare namespace ts { - function transformJsx(context: TransformationContext): (node: SourceFile) => SourceFile; -} -declare namespace ts { - function transformES7(context: TransformationContext): (node: SourceFile) => SourceFile; -} -declare namespace ts { - function transformES6(context: TransformationContext): (node: SourceFile) => SourceFile; -} -declare namespace ts { - function transformGenerators(context: TransformationContext): (node: SourceFile) => SourceFile; -} -declare namespace ts { - function transformModule(context: TransformationContext): (node: SourceFile) => SourceFile; -} -declare namespace ts { - function transformSystemModule(context: TransformationContext): (node: SourceFile) => SourceFile; -} -declare namespace ts { - function transformES6Module(context: TransformationContext): (node: SourceFile) => SourceFile; -} -declare namespace ts { - interface TransformationResult { - transformed: SourceFile[]; - emitNodeWithSubstitution(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void; - emitNodeWithNotification(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void; - } - interface TransformationContext extends LexicalEnvironment { - getCompilerOptions(): CompilerOptions; - getEmitResolver(): EmitResolver; - getEmitHost(): EmitHost; - hoistFunctionDeclaration(node: FunctionDeclaration): void; - hoistVariableDeclaration(node: Identifier): void; - enableSubstitution(kind: SyntaxKind): void; - isSubstitutionEnabled(node: Node): boolean; - onSubstituteNode?: (emitContext: EmitContext, node: Node) => Node; - enableEmitNotification(kind: SyntaxKind): void; - isEmitNotificationEnabled(node: Node): boolean; - onEmitNode?: (emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void) => void; - } - type Transformer = (context: TransformationContext) => (node: SourceFile) => SourceFile; - function getTransformers(compilerOptions: CompilerOptions): Transformer[]; - function transformFiles(resolver: EmitResolver, host: EmitHost, sourceFiles: SourceFile[], transformers: Transformer[]): TransformationResult; -} -declare namespace ts { - function getDeclarationDiagnostics(host: EmitHost, resolver: EmitResolver, targetSourceFile: SourceFile): Diagnostic[]; - function writeDeclarationFile(declarationFilePath: string, sourceFiles: SourceFile[], isBundledEmit: boolean, host: EmitHost, resolver: EmitResolver, emitterDiagnostics: DiagnosticCollection, emitOnlyDtsFiles: boolean): boolean; -} -declare namespace ts { - interface SourceMapWriter { - initialize(filePath: string, sourceMapFilePath: string, sourceFiles: SourceFile[], isBundledEmit: boolean): void; - reset(): void; - setSourceFile(sourceFile: SourceFile): void; - emitPos(pos: number): void; - emitNodeWithSourceMap(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void; - emitTokenWithSourceMap(node: Node, token: SyntaxKind, tokenStartPos: number, emitCallback: (token: SyntaxKind, tokenStartPos: number) => number): number; - getText(): string; - getSourceMappingURL(): string; - getSourceMapData(): SourceMapData; - } - function createSourceMapWriter(host: EmitHost, writer: EmitTextWriter): SourceMapWriter; -} -declare namespace ts { - interface CommentWriter { - reset(): void; - setSourceFile(sourceFile: SourceFile): void; - emitNodeWithComments(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void; - emitBodyWithDetachedComments(node: Node, detachedRange: TextRange, emitCallback: (node: Node) => void): void; - emitTrailingCommentsOfPosition(pos: number): void; - } - function createCommentWriter(host: EmitHost, writer: EmitTextWriter, sourceMap: SourceMapWriter): CommentWriter; -} -declare namespace ts { - function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFile: SourceFile, emitOnlyDtsFiles?: boolean): EmitResult; -} -declare namespace ts { - const version = "2.1.0"; - function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName?: string): string; - function resolveTripleslashReference(moduleName: string, containingFile: string): string; - function computeCommonSourceDirectoryOfFilenames(fileNames: string[], currentDirectory: string, getCanonicalFileName: (fileName: string) => string): string; - function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; - function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; - interface FormatDiagnosticsHost { - getCurrentDirectory(): string; - getCanonicalFileName(fileName: string): string; - getNewLine(): string; - } - function formatDiagnostics(diagnostics: Diagnostic[], host: FormatDiagnosticsHost): string; - function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string; - function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program; -} declare namespace ts { interface Node { getSourceFile(): SourceFile; @@ -9186,10 +2174,6 @@ declare namespace ts { getDocumentationComment(): SymbolDisplayPart[]; } interface SourceFile { - version: string; - scriptSnapshot: IScriptSnapshot; - nameTable: Map; - getNamedDeclarations(): Map; getLineAndCharacterOfPosition(pos: number): LineAndCharacter; getLineStarts(): number[]; getPositionOfLineAndCharacter(line: number, character: number): number; @@ -9279,8 +2263,6 @@ declare namespace ts { getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[]): CodeAction[]; getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean): EmitOutput; getProgram(): Program; - getNonBoundSourceFile(fileName: string): SourceFile; - getSourceFile(fileName: string): SourceFile; dispose(): void; } interface Classifications { @@ -9672,123 +2654,8 @@ declare namespace ts { jsxAttributeStringLiteralValue = 24, } } -declare namespace ts { - const scanner: Scanner; - const emptyArray: any[]; - const enum SemanticMeaning { - None = 0, - Value = 1, - Type = 2, - Namespace = 4, - All = 7, - } - function getMeaningFromDeclaration(node: Node): SemanticMeaning; - function getMeaningFromLocation(node: Node): SemanticMeaning; - function isCallExpressionTarget(node: Node): boolean; - function isNewExpressionTarget(node: Node): boolean; - function climbPastPropertyAccess(node: Node): Node; - function getTargetLabel(referenceNode: Node, labelName: string): Identifier; - function isJumpStatementTarget(node: Node): boolean; - function isLabelName(node: Node): boolean; - function isRightSideOfQualifiedName(node: Node): boolean; - function isRightSideOfPropertyAccess(node: Node): boolean; - function isNameOfModuleDeclaration(node: Node): boolean; - function isNameOfFunctionDeclaration(node: Node): boolean; - function isLiteralNameOfPropertyDeclarationOrIndexAccess(node: Node): boolean; - function isExpressionOfExternalModuleImportEqualsDeclaration(node: Node): boolean; - function isInsideComment(sourceFile: SourceFile, token: Node, position: number): boolean; - function getContainerNode(node: Node): Declaration; - function getNodeKind(node: Node): string; - function getStringLiteralTypeForNode(node: StringLiteral | LiteralTypeNode, typeChecker: TypeChecker): LiteralType; - function isThis(node: Node): boolean; - interface ListItemInfo { - listItemIndex: number; - list: Node; - } - function getLineStartPositionForPosition(position: number, sourceFile: SourceFile): number; - function rangeContainsRange(r1: TextRange, r2: TextRange): boolean; - function startEndContainsRange(start: number, end: number, range: TextRange): boolean; - function rangeContainsStartEnd(range: TextRange, start: number, end: number): boolean; - function rangeOverlapsWithStartEnd(r1: TextRange, start: number, end: number): boolean; - function startEndOverlapsWithStartEnd(start1: number, end1: number, start2: number, end2: number): boolean; - function positionBelongsToNode(candidate: Node, position: number, sourceFile: SourceFile): boolean; - function isCompletedNode(n: Node, sourceFile: SourceFile): boolean; - function findListItemInfo(node: Node): ListItemInfo; - function hasChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): boolean; - function findChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): Node; - function findContainingList(node: Node): Node; - function getTouchingWord(sourceFile: SourceFile, position: number, includeJsDocComment?: boolean): Node; - function getTouchingPropertyName(sourceFile: SourceFile, position: number, includeJsDocComment?: boolean): Node; - function getTouchingToken(sourceFile: SourceFile, position: number, includeItemAtEndPosition?: (n: Node) => boolean, includeJsDocComment?: boolean): Node; - function getTokenAtPosition(sourceFile: SourceFile, position: number, includeJsDocComment?: boolean): Node; - function findTokenOnLeftOfPosition(file: SourceFile, position: number): Node; - function findNextToken(previousToken: Node, parent: Node): Node; - function findPrecedingToken(position: number, sourceFile: SourceFile, startNode?: Node): Node; - function isInString(sourceFile: SourceFile, position: number): boolean; - function isInComment(sourceFile: SourceFile, position: number): boolean; - function isInsideJsxElementOrAttribute(sourceFile: SourceFile, position: number): boolean; - function isInTemplateString(sourceFile: SourceFile, position: number): boolean; - function isInCommentHelper(sourceFile: SourceFile, position: number, predicate?: (c: CommentRange) => boolean): boolean; - function hasDocComment(sourceFile: SourceFile, position: number): boolean; - function getJsDocTagAtPosition(sourceFile: SourceFile, position: number): JSDocTag; - function getNodeModifiers(node: Node): string; - function getTypeArgumentOrTypeParameterList(node: Node): NodeArray; - function isToken(n: Node): boolean; - function isWord(kind: SyntaxKind): boolean; - function isComment(kind: SyntaxKind): boolean; - function isStringOrRegularExpressionOrTemplateLiteral(kind: SyntaxKind): boolean; - function isPunctuation(kind: SyntaxKind): boolean; - function isInsideTemplateLiteral(node: LiteralExpression, position: number): boolean; - function isAccessibilityModifier(kind: SyntaxKind): boolean; - function compareDataObjects(dst: any, src: any): boolean; - function isArrayLiteralOrObjectLiteralDestructuringPattern(node: Node): boolean; - function hasTrailingDirectorySeparator(path: string): boolean; - function isInReferenceComment(sourceFile: SourceFile, position: number): boolean; - function isInNonReferenceComment(sourceFile: SourceFile, position: number): boolean; -} -declare namespace ts { - function isFirstDeclarationOfSymbolParameter(symbol: Symbol): boolean; - function symbolPart(text: string, symbol: Symbol): SymbolDisplayPart; - function displayPart(text: string, kind: SymbolDisplayPartKind, symbol?: Symbol): SymbolDisplayPart; - function spacePart(): SymbolDisplayPart; - function keywordPart(kind: SyntaxKind): SymbolDisplayPart; - function punctuationPart(kind: SyntaxKind): SymbolDisplayPart; - function operatorPart(kind: SyntaxKind): SymbolDisplayPart; - function textOrKeywordPart(text: string): SymbolDisplayPart; - function textPart(text: string): SymbolDisplayPart; - function getNewLineOrDefaultFromHost(host: LanguageServiceHost | LanguageServiceShimHost): string; - function lineBreakPart(): SymbolDisplayPart; - function mapToDisplayParts(writeDisplayParts: (writer: DisplayPartsSymbolWriter) => void): SymbolDisplayPart[]; - function typeToDisplayParts(typechecker: TypeChecker, type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): SymbolDisplayPart[]; - function symbolToDisplayParts(typeChecker: TypeChecker, symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): SymbolDisplayPart[]; - function signatureToDisplayParts(typechecker: TypeChecker, signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags): SymbolDisplayPart[]; - function getDeclaredName(typeChecker: TypeChecker, symbol: Symbol, location: Node): string; - function isImportOrExportSpecifierName(location: Node): boolean; - function stripQuotes(name: string): string; - function scriptKindIs(fileName: string, host: LanguageServiceHost, ...scriptKinds: ScriptKind[]): boolean; - function getScriptKind(fileName: string, host?: LanguageServiceHost): ScriptKind; - function sanitizeConfigFile(configFileName: string, content: string): { - configJsonObject: any; - diagnostics: Diagnostic[]; - }; -} -declare namespace ts.BreakpointResolver { - function spanInSourceFileAtLocation(sourceFile: SourceFile, position: number): TextSpan; -} declare namespace ts { function createClassifier(): Classifier; - function getSemanticClassifications(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFile: SourceFile, classifiableNames: Map, span: TextSpan): ClassifiedSpan[]; - function getEncodedSemanticClassifications(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFile: SourceFile, classifiableNames: Map, span: TextSpan): Classifications; - function getSyntacticClassifications(cancellationToken: CancellationToken, sourceFile: SourceFile, span: TextSpan): ClassifiedSpan[]; - function getEncodedSyntacticClassifications(cancellationToken: CancellationToken, sourceFile: SourceFile, span: TextSpan): Classifications; -} -declare namespace ts.Completions { - function getCompletionsAtPosition(host: LanguageServiceHost, typeChecker: TypeChecker, log: (message: string) => void, compilerOptions: CompilerOptions, sourceFile: SourceFile, position: number): CompletionInfo; - function getCompletionEntryDetails(typeChecker: TypeChecker, log: (message: string) => void, compilerOptions: CompilerOptions, sourceFile: SourceFile, position: number, entryName: string): CompletionEntryDetails; - function getCompletionEntrySymbol(typeChecker: TypeChecker, log: (message: string) => void, compilerOptions: CompilerOptions, sourceFile: SourceFile, position: number, entryName: string): Symbol; -} -declare namespace ts.DocumentHighlights { - function getDocumentHighlights(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFile: SourceFile, position: number, sourceFilesToSearch: SourceFile[]): DocumentHighlights[]; } declare namespace ts { interface DocumentRegistry { @@ -9806,88 +2673,9 @@ declare namespace ts { }; function createDocumentRegistry(useCaseSensitiveFileNames?: boolean, currentDirectory?: string): DocumentRegistry; } -declare namespace ts.FindAllReferences { - function findReferencedSymbols(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFiles: SourceFile[], sourceFile: SourceFile, position: number, findInStrings: boolean, findInComments: boolean): ReferencedSymbol[]; - function getReferencedSymbolsForNode(typeChecker: TypeChecker, cancellationToken: CancellationToken, node: Node, sourceFiles: SourceFile[], findInStrings: boolean, findInComments: boolean, implementations: boolean): ReferencedSymbol[]; - function convertReferences(referenceSymbols: ReferencedSymbol[]): ReferenceEntry[]; - function getReferenceEntriesForShorthandPropertyAssignment(node: Node, typeChecker: TypeChecker, result: ReferenceEntry[]): void; - function getReferenceEntryFromNode(node: Node): ReferenceEntry; -} -declare namespace ts.GoToDefinition { - function getDefinitionAtPosition(program: Program, sourceFile: SourceFile, position: number): DefinitionInfo[]; - function getTypeDefinitionAtPosition(typeChecker: TypeChecker, sourceFile: SourceFile, position: number): DefinitionInfo[]; -} -declare namespace ts.GoToImplementation { - function getImplementationAtPosition(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFiles: SourceFile[], node: Node): ImplementationLocation[]; -} -declare namespace ts.JsDoc { - function getJsDocCommentsFromDeclarations(declarations: Declaration[], name: string, canUseParsedParamTagComments: boolean): SymbolDisplayPart[]; - function getAllJsDocCompletionEntries(): CompletionEntry[]; - function getDocCommentTemplateAtPosition(newLine: string, sourceFile: SourceFile, position: number): TextInsertion; -} -declare namespace ts.NavigateTo { - function getNavigateToItems(sourceFiles: SourceFile[], checker: TypeChecker, cancellationToken: CancellationToken, searchValue: string, maxResultCount: number, excludeDtsFiles: boolean): NavigateToItem[]; -} -declare namespace ts.NavigationBar { - function getNavigationBarItems(sourceFile: SourceFile): NavigationBarItem[]; - function getNavigationTree(sourceFile: SourceFile): NavigationTree; -} -declare namespace ts.OutliningElementsCollector { - function collectElements(sourceFile: SourceFile): OutliningSpan[]; -} -declare namespace ts { - enum PatternMatchKind { - exact = 0, - prefix = 1, - substring = 2, - camelCase = 3, - } - interface PatternMatch { - kind: PatternMatchKind; - camelCaseWeight?: number; - isCaseSensitive: boolean; - punctuationStripped: boolean; - } - interface PatternMatcher { - getMatchesForLastSegmentOfPattern(candidate: string): PatternMatch[]; - getMatches(candidateContainers: string[], candidate: string): PatternMatch[]; - patternContainsDots: boolean; - } - function createPatternMatcher(pattern: string): PatternMatcher; - function breakIntoCharacterSpans(identifier: string): TextSpan[]; - function breakIntoWordSpans(identifier: string): TextSpan[]; -} declare namespace ts { function preProcessFile(sourceText: string, readImportFiles?: boolean, detectJavaScriptImports?: boolean): PreProcessedFileInfo; } -declare namespace ts.Rename { - function getRenameInfo(typeChecker: TypeChecker, defaultLibFileName: string, getCanonicalFileName: (fileName: string) => string, sourceFile: SourceFile, position: number): RenameInfo; -} -declare namespace ts.SignatureHelp { - const enum ArgumentListKind { - TypeArguments = 0, - CallArguments = 1, - TaggedTemplateArguments = 2, - } - interface ArgumentListInfo { - kind: ArgumentListKind; - invocation: CallLikeExpression; - argumentsSpan: TextSpan; - argumentIndex?: number; - argumentCount: number; - } - function getSignatureHelpItems(program: Program, sourceFile: SourceFile, position: number, cancellationToken: CancellationToken): SignatureHelpItems; - function getContainingArgumentInfo(node: Node, position: number, sourceFile: SourceFile): ArgumentListInfo; -} -declare namespace ts.SymbolDisplay { - function getSymbolKind(typeChecker: TypeChecker, symbol: Symbol, location: Node): string; - function getSymbolModifiers(symbol: Symbol): string; - function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker: TypeChecker, symbol: Symbol, sourceFile: SourceFile, enclosingDeclaration: Node, location: Node, semanticMeaning?: SemanticMeaning): { - displayParts: SymbolDisplayPart[]; - documentation: SymbolDisplayPart[]; - symbolKind: string; - }; -} declare namespace ts { interface TranspileOptions { compilerOptions?: CompilerOptions; @@ -9904,438 +2692,11 @@ declare namespace ts { function transpileModule(input: string, transpileOptions: TranspileOptions): TranspileOutput; function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[], moduleName?: string): string; } -declare namespace ts.formatting { - interface FormattingScanner { - advance(): void; - isOnToken(): boolean; - readTokenInfo(n: Node): TokenInfo; - getCurrentLeadingTrivia(): TextRangeWithKind[]; - lastTrailingTriviaWasNewLine(): boolean; - skipToEndOf(node: Node): void; - close(): void; - } - function getFormattingScanner(sourceFile: SourceFile, startPos: number, endPos: number): FormattingScanner; -} -declare namespace ts.formatting { - class FormattingContext { - sourceFile: SourceFile; - formattingRequestKind: FormattingRequestKind; - currentTokenSpan: TextRangeWithKind; - nextTokenSpan: TextRangeWithKind; - contextNode: Node; - currentTokenParent: Node; - nextTokenParent: Node; - private contextNodeAllOnSameLine; - private nextNodeAllOnSameLine; - private tokensAreOnSameLine; - private contextNodeBlockIsOnOneLine; - private nextNodeBlockIsOnOneLine; - constructor(sourceFile: SourceFile, formattingRequestKind: FormattingRequestKind); - updateContext(currentRange: TextRangeWithKind, currentTokenParent: Node, nextRange: TextRangeWithKind, nextTokenParent: Node, commonParent: Node): void; - ContextNodeAllOnSameLine(): boolean; - NextNodeAllOnSameLine(): boolean; - TokensAreOnSameLine(): boolean; - ContextNodeBlockIsOnOneLine(): boolean; - NextNodeBlockIsOnOneLine(): boolean; - private NodeIsOnOneLine(node); - private BlockIsOnOneLine(node); - } -} -declare namespace ts.formatting { - const enum FormattingRequestKind { - FormatDocument = 0, - FormatSelection = 1, - FormatOnEnter = 2, - FormatOnSemicolon = 3, - FormatOnClosingCurlyBrace = 4, - } -} -declare namespace ts.formatting { - class Rule { - Descriptor: RuleDescriptor; - Operation: RuleOperation; - Flag: RuleFlags; - constructor(Descriptor: RuleDescriptor, Operation: RuleOperation, Flag?: RuleFlags); - toString(): string; - } -} -declare namespace ts.formatting { - const enum RuleAction { - Ignore = 1, - Space = 2, - NewLine = 4, - Delete = 8, - } -} -declare namespace ts.formatting { - class RuleDescriptor { - LeftTokenRange: Shared.TokenRange; - RightTokenRange: Shared.TokenRange; - constructor(LeftTokenRange: Shared.TokenRange, RightTokenRange: Shared.TokenRange); - toString(): string; - static create1(left: SyntaxKind, right: SyntaxKind): RuleDescriptor; - static create2(left: Shared.TokenRange, right: SyntaxKind): RuleDescriptor; - static create3(left: SyntaxKind, right: Shared.TokenRange): RuleDescriptor; - static create4(left: Shared.TokenRange, right: Shared.TokenRange): RuleDescriptor; - } -} -declare namespace ts.formatting { - const enum RuleFlags { - None = 0, - CanDeleteNewLines = 1, - } -} -declare namespace ts.formatting { - class RuleOperation { - Context: RuleOperationContext; - Action: RuleAction; - constructor(Context: RuleOperationContext, Action: RuleAction); - toString(): string; - static create1(action: RuleAction): RuleOperation; - static create2(context: RuleOperationContext, action: RuleAction): RuleOperation; - } -} -declare namespace ts.formatting { - class RuleOperationContext { - private customContextChecks; - constructor(...funcs: { - (context: FormattingContext): boolean; - }[]); - static Any: RuleOperationContext; - IsAny(): boolean; - InContext(context: FormattingContext): boolean; - } -} -declare namespace ts.formatting { - class Rules { - getRuleName(rule: Rule): string; - [name: string]: any; - IgnoreBeforeComment: Rule; - IgnoreAfterLineComment: Rule; - NoSpaceBeforeSemicolon: Rule; - NoSpaceBeforeColon: Rule; - NoSpaceBeforeQuestionMark: Rule; - SpaceAfterColon: Rule; - SpaceAfterQuestionMarkInConditionalOperator: Rule; - NoSpaceAfterQuestionMark: Rule; - SpaceAfterSemicolon: Rule; - SpaceAfterCloseBrace: Rule; - SpaceBetweenCloseBraceAndElse: Rule; - SpaceBetweenCloseBraceAndWhile: Rule; - NoSpaceAfterCloseBrace: Rule; - NoSpaceBeforeDot: Rule; - NoSpaceAfterDot: Rule; - NoSpaceBeforeOpenBracket: Rule; - NoSpaceAfterCloseBracket: Rule; - SpaceAfterOpenBrace: Rule; - SpaceBeforeCloseBrace: Rule; - NoSpaceAfterOpenBrace: Rule; - NoSpaceBeforeCloseBrace: Rule; - NoSpaceBetweenEmptyBraceBrackets: Rule; - NewLineAfterOpenBraceInBlockContext: Rule; - NewLineBeforeCloseBraceInBlockContext: Rule; - NoSpaceAfterUnaryPrefixOperator: Rule; - NoSpaceAfterUnaryPreincrementOperator: Rule; - NoSpaceAfterUnaryPredecrementOperator: Rule; - NoSpaceBeforeUnaryPostincrementOperator: Rule; - NoSpaceBeforeUnaryPostdecrementOperator: Rule; - SpaceAfterPostincrementWhenFollowedByAdd: Rule; - SpaceAfterAddWhenFollowedByUnaryPlus: Rule; - SpaceAfterAddWhenFollowedByPreincrement: Rule; - SpaceAfterPostdecrementWhenFollowedBySubtract: Rule; - SpaceAfterSubtractWhenFollowedByUnaryMinus: Rule; - SpaceAfterSubtractWhenFollowedByPredecrement: Rule; - NoSpaceBeforeComma: Rule; - SpaceAfterCertainKeywords: Rule; - SpaceAfterLetConstInVariableDeclaration: Rule; - NoSpaceBeforeOpenParenInFuncCall: Rule; - SpaceAfterFunctionInFuncDecl: Rule; - NoSpaceBeforeOpenParenInFuncDecl: Rule; - SpaceAfterVoidOperator: Rule; - NoSpaceBetweenReturnAndSemicolon: Rule; - SpaceBetweenStatements: Rule; - SpaceAfterTryFinally: Rule; - SpaceAfterGetSetInMember: Rule; - SpaceBeforeBinaryKeywordOperator: Rule; - SpaceAfterBinaryKeywordOperator: Rule; - NoSpaceAfterConstructor: Rule; - NoSpaceAfterModuleImport: Rule; - SpaceAfterCertainTypeScriptKeywords: Rule; - SpaceBeforeCertainTypeScriptKeywords: Rule; - SpaceAfterModuleName: Rule; - SpaceBeforeArrow: Rule; - SpaceAfterArrow: Rule; - NoSpaceAfterEllipsis: Rule; - NoSpaceAfterOptionalParameters: Rule; - NoSpaceBeforeOpenAngularBracket: Rule; - NoSpaceBetweenCloseParenAndAngularBracket: Rule; - NoSpaceAfterOpenAngularBracket: Rule; - NoSpaceBeforeCloseAngularBracket: Rule; - NoSpaceAfterCloseAngularBracket: Rule; - NoSpaceBetweenEmptyInterfaceBraceBrackets: Rule; - HighPriorityCommonRules: Rule[]; - LowPriorityCommonRules: Rule[]; - SpaceAfterComma: Rule; - NoSpaceAfterComma: Rule; - SpaceBeforeBinaryOperator: Rule; - SpaceAfterBinaryOperator: Rule; - NoSpaceBeforeBinaryOperator: Rule; - NoSpaceAfterBinaryOperator: Rule; - SpaceAfterKeywordInControl: Rule; - NoSpaceAfterKeywordInControl: Rule; - FunctionOpenBraceLeftTokenRange: Shared.TokenRange; - SpaceBeforeOpenBraceInFunction: Rule; - NewLineBeforeOpenBraceInFunction: Rule; - TypeScriptOpenBraceLeftTokenRange: Shared.TokenRange; - SpaceBeforeOpenBraceInTypeScriptDeclWithBlock: Rule; - NewLineBeforeOpenBraceInTypeScriptDeclWithBlock: Rule; - ControlOpenBraceLeftTokenRange: Shared.TokenRange; - SpaceBeforeOpenBraceInControl: Rule; - NewLineBeforeOpenBraceInControl: Rule; - SpaceAfterSemicolonInFor: Rule; - NoSpaceAfterSemicolonInFor: Rule; - SpaceAfterOpenParen: Rule; - SpaceBeforeCloseParen: Rule; - NoSpaceBetweenParens: Rule; - NoSpaceAfterOpenParen: Rule; - NoSpaceBeforeCloseParen: Rule; - SpaceAfterOpenBracket: Rule; - SpaceBeforeCloseBracket: Rule; - NoSpaceBetweenBrackets: Rule; - NoSpaceAfterOpenBracket: Rule; - NoSpaceBeforeCloseBracket: Rule; - SpaceAfterAnonymousFunctionKeyword: Rule; - NoSpaceAfterAnonymousFunctionKeyword: Rule; - SpaceBeforeAt: Rule; - NoSpaceAfterAt: Rule; - SpaceAfterDecorator: Rule; - NoSpaceBetweenFunctionKeywordAndStar: Rule; - SpaceAfterStarInGeneratorDeclaration: Rule; - NoSpaceBetweenYieldKeywordAndStar: Rule; - SpaceBetweenYieldOrYieldStarAndOperand: Rule; - SpaceBetweenAsyncAndOpenParen: Rule; - SpaceBetweenAsyncAndFunctionKeyword: Rule; - NoSpaceBetweenTagAndTemplateString: Rule; - NoSpaceAfterTemplateHeadAndMiddle: Rule; - SpaceAfterTemplateHeadAndMiddle: Rule; - NoSpaceBeforeTemplateMiddleAndTail: Rule; - SpaceBeforeTemplateMiddleAndTail: Rule; - NoSpaceAfterOpenBraceInJsxExpression: Rule; - SpaceAfterOpenBraceInJsxExpression: Rule; - NoSpaceBeforeCloseBraceInJsxExpression: Rule; - SpaceBeforeCloseBraceInJsxExpression: Rule; - SpaceBeforeJsxAttribute: Rule; - SpaceBeforeSlashInJsxOpeningElement: Rule; - NoSpaceBeforeGreaterThanTokenInJsxOpeningElement: Rule; - NoSpaceBeforeEqualInJsxAttribute: Rule; - NoSpaceAfterEqualInJsxAttribute: Rule; - NoSpaceAfterTypeAssertion: Rule; - SpaceAfterTypeAssertion: Rule; - constructor(); - static IsForContext(context: FormattingContext): boolean; - static IsNotForContext(context: FormattingContext): boolean; - static IsBinaryOpContext(context: FormattingContext): boolean; - static IsNotBinaryOpContext(context: FormattingContext): boolean; - static IsConditionalOperatorContext(context: FormattingContext): boolean; - static IsSameLineTokenOrBeforeMultilineBlockContext(context: FormattingContext): boolean; - static IsBeforeMultilineBlockContext(context: FormattingContext): boolean; - static IsMultilineBlockContext(context: FormattingContext): boolean; - static IsSingleLineBlockContext(context: FormattingContext): boolean; - static IsBlockContext(context: FormattingContext): boolean; - static IsBeforeBlockContext(context: FormattingContext): boolean; - static NodeIsBlockContext(node: Node): boolean; - static IsFunctionDeclContext(context: FormattingContext): boolean; - static IsFunctionDeclarationOrFunctionExpressionContext(context: FormattingContext): boolean; - static IsTypeScriptDeclWithBlockContext(context: FormattingContext): boolean; - static NodeIsTypeScriptDeclWithBlockContext(node: Node): boolean; - static IsAfterCodeBlockContext(context: FormattingContext): boolean; - static IsControlDeclContext(context: FormattingContext): boolean; - static IsObjectContext(context: FormattingContext): boolean; - static IsFunctionCallContext(context: FormattingContext): boolean; - static IsNewContext(context: FormattingContext): boolean; - static IsFunctionCallOrNewContext(context: FormattingContext): boolean; - static IsPreviousTokenNotComma(context: FormattingContext): boolean; - static IsNextTokenNotCloseBracket(context: FormattingContext): boolean; - static IsArrowFunctionContext(context: FormattingContext): boolean; - static IsNonJsxSameLineTokenContext(context: FormattingContext): boolean; - static IsNonJsxElementContext(context: FormattingContext): boolean; - static IsJsxExpressionContext(context: FormattingContext): boolean; - static IsNextTokenParentJsxAttribute(context: FormattingContext): boolean; - static IsJsxAttributeContext(context: FormattingContext): boolean; - static IsJsxSelfClosingElementContext(context: FormattingContext): boolean; - static IsNotBeforeBlockInFunctionDeclarationContext(context: FormattingContext): boolean; - static IsEndOfDecoratorContextOnSameLine(context: FormattingContext): boolean; - static NodeIsInDecoratorContext(node: Node): boolean; - static IsStartOfVariableDeclarationList(context: FormattingContext): boolean; - static IsNotFormatOnEnter(context: FormattingContext): boolean; - static IsModuleDeclContext(context: FormattingContext): boolean; - static IsObjectTypeContext(context: FormattingContext): boolean; - static IsTypeArgumentOrParameterOrAssertion(token: TextRangeWithKind, parent: Node): boolean; - static IsTypeArgumentOrParameterOrAssertionContext(context: FormattingContext): boolean; - static IsTypeAssertionContext(context: FormattingContext): boolean; - static IsVoidOpContext(context: FormattingContext): boolean; - static IsYieldOrYieldStarWithOperand(context: FormattingContext): boolean; - } -} -declare namespace ts.formatting { - class RulesMap { - map: RulesBucket[]; - mapRowLength: number; - constructor(); - static create(rules: Rule[]): RulesMap; - Initialize(rules: Rule[]): RulesBucket[]; - FillRules(rules: Rule[], rulesBucketConstructionStateList: RulesBucketConstructionState[]): void; - private GetRuleBucketIndex(row, column); - private FillRule(rule, rulesBucketConstructionStateList); - GetRule(context: FormattingContext): Rule; - } - enum RulesPosition { - IgnoreRulesSpecific = 0, - IgnoreRulesAny, - ContextRulesSpecific, - ContextRulesAny, - NoContextRulesSpecific, - NoContextRulesAny, - } - class RulesBucketConstructionState { - private rulesInsertionIndexBitmap; - constructor(); - GetInsertionIndex(maskPosition: RulesPosition): number; - IncreaseInsertionIndex(maskPosition: RulesPosition): void; - } - class RulesBucket { - private rules; - constructor(); - Rules(): Rule[]; - AddRule(rule: Rule, specificTokens: boolean, constructionState: RulesBucketConstructionState[], rulesBucketIndex: number): void; - } -} -declare namespace ts.formatting { - namespace Shared { - interface ITokenAccess { - GetTokens(): SyntaxKind[]; - Contains(token: SyntaxKind): boolean; - } - class TokenRangeAccess implements ITokenAccess { - private tokens; - constructor(from: SyntaxKind, to: SyntaxKind, except: SyntaxKind[]); - GetTokens(): SyntaxKind[]; - Contains(token: SyntaxKind): boolean; - } - class TokenValuesAccess implements ITokenAccess { - private tokens; - constructor(tks: SyntaxKind[]); - GetTokens(): SyntaxKind[]; - Contains(token: SyntaxKind): boolean; - } - class TokenSingleValueAccess implements ITokenAccess { - token: SyntaxKind; - constructor(token: SyntaxKind); - GetTokens(): SyntaxKind[]; - Contains(tokenValue: SyntaxKind): boolean; - } - class TokenAllAccess implements ITokenAccess { - GetTokens(): SyntaxKind[]; - Contains(tokenValue: SyntaxKind): boolean; - toString(): string; - } - class TokenRange { - tokenAccess: ITokenAccess; - constructor(tokenAccess: ITokenAccess); - static FromToken(token: SyntaxKind): TokenRange; - static FromTokens(tokens: SyntaxKind[]): TokenRange; - static FromRange(f: SyntaxKind, to: SyntaxKind, except?: SyntaxKind[]): TokenRange; - static AllTokens(): TokenRange; - GetTokens(): SyntaxKind[]; - Contains(token: SyntaxKind): boolean; - toString(): string; - static Any: TokenRange; - static AnyIncludingMultilineComments: TokenRange; - static Keywords: TokenRange; - static BinaryOperators: TokenRange; - static BinaryKeywordOperators: TokenRange; - static UnaryPrefixOperators: TokenRange; - static UnaryPrefixExpressions: TokenRange; - static UnaryPreincrementExpressions: TokenRange; - static UnaryPostincrementExpressions: TokenRange; - static UnaryPredecrementExpressions: TokenRange; - static UnaryPostdecrementExpressions: TokenRange; - static Comments: TokenRange; - static TypeNames: TokenRange; - } - } -} -declare namespace ts.formatting { - class RulesProvider { - private globalRules; - private options; - private activeRules; - private rulesMap; - constructor(); - getRuleName(rule: Rule): string; - getRuleByName(name: string): Rule; - getRulesMap(): RulesMap; - ensureUpToDate(options: ts.FormatCodeSettings): void; - private createActiveRules(options); - } -} -declare namespace ts.formatting { - interface TextRangeWithKind extends TextRange { - kind: SyntaxKind; - } - interface TokenInfo { - leadingTrivia: TextRangeWithKind[]; - token: TextRangeWithKind; - trailingTrivia: TextRangeWithKind[]; - } - function formatOnEnter(position: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeSettings): TextChange[]; - function formatOnSemicolon(position: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeSettings): TextChange[]; - function formatOnClosingCurly(position: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeSettings): TextChange[]; - function formatDocument(sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeSettings): TextChange[]; - function formatSelection(start: number, end: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeSettings): TextChange[]; - function getIndentationString(indentation: number, options: EditorSettings): string; -} -declare namespace ts.formatting { - namespace SmartIndenter { - function getIndentation(position: number, sourceFile: SourceFile, options: EditorSettings): number; - function getIndentationForNode(n: Node, ignoreActualIndentationRange: TextRange, sourceFile: SourceFile, options: EditorSettings): number; - function getBaseIndentation(options: EditorSettings): number; - function childStartsOnTheSameLineWithElseInIfStatement(parent: Node, child: TextRangeWithKind, childStartLine: number, sourceFile: SourceFile): boolean; - function findFirstNonWhitespaceCharacterAndColumn(startPos: number, endPos: number, sourceFile: SourceFile, options: EditorSettings): { - column: number; - character: number; - }; - function findFirstNonWhitespaceColumn(startPos: number, endPos: number, sourceFile: SourceFile, options: EditorSettings): number; - function nodeWillIndentChild(parent: TextRangeWithKind, child: TextRangeWithKind, indentByDefault: boolean): boolean; - function shouldIndentChildNode(parent: TextRangeWithKind, child?: TextRangeWithKind): boolean; - } -} -declare namespace ts { - interface CodeFix { - errorCodes: number[]; - getCodeActions(context: CodeFixContext): CodeAction[] | undefined; - } - interface CodeFixContext { - errorCode: number; - sourceFile: SourceFile; - span: TextSpan; - program: Program; - newLineCharacter: string; - } - namespace codefix { - function registerCodeFix(action: CodeFix): void; - function getSupportedErrorCodes(): string[]; - function getFixes(context: CodeFixContext): CodeAction[]; - } -} -declare namespace ts.codefix { -} declare namespace ts { const servicesVersion = "0.5"; interface DisplayPartsSymbolWriter extends SymbolWriter { displayParts(): SymbolDisplayPart[]; } - function toEditorSettings(options: FormatCodeOptions | FormatCodeSettings): FormatCodeSettings; function toEditorSettings(options: EditorOptions | EditorSettings): EditorSettings; function displayPartsToString(displayParts: SymbolDisplayPart[]): string; function getDefaultCompilerOptions(): CompilerOptions; @@ -10344,9 +2705,840 @@ declare namespace ts { let disableIncrementalParsing: boolean; function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService; - function getNameTable(sourceFile: SourceFile): Map; function getDefaultLibFilePath(options: CompilerOptions): string; } +declare namespace ts.server { + enum LogLevel { + terse = 0, + normal = 1, + requestTime = 2, + verbose = 3, + } + const emptyArray: ReadonlyArray; + interface Logger { + close(): void; + hasLevel(level: LogLevel): boolean; + loggingEnabled(): boolean; + perftrc(s: string): void; + info(s: string): void; + startGroup(): void; + endGroup(): void; + msg(s: string, type?: Msg.Types): void; + getLogFileName(): string; + } + namespace Msg { + type Err = "Err"; + const Err: Err; + type Info = "Info"; + const Info: Info; + type Perf = "Perf"; + const Perf: Perf; + type Types = Err | Info | Perf; + } + function createInstallTypingsRequest(project: Project, typingOptions: TypingOptions, cachePath?: string): DiscoverTypings; + namespace Errors { + function ThrowNoProject(): never; + function ThrowProjectLanguageServiceDisabled(): never; + function ThrowProjectDoesNotContainDocument(fileName: string, project: Project): never; + } + function getDefaultFormatCodeSettings(host: ServerHost): FormatCodeSettings; + function mergeMaps(target: MapLike, source: MapLike): void; + function removeItemFromSet(items: T[], itemToRemove: T): void; + type NormalizedPath = string & { + __normalizedPathTag: any; + }; + function toNormalizedPath(fileName: string): NormalizedPath; + function normalizedPathToPath(normalizedPath: NormalizedPath, currentDirectory: string, getCanonicalFileName: (f: string) => string): Path; + function asNormalizedPath(fileName: string): NormalizedPath; + interface NormalizedPathMap { + get(path: NormalizedPath): T; + set(path: NormalizedPath, value: T): void; + contains(path: NormalizedPath): boolean; + remove(path: NormalizedPath): void; + } + function createNormalizedPathMap(): NormalizedPathMap; + const nullLanguageService: LanguageService; + interface ServerLanguageServiceHost { + setCompilationSettings(options: CompilerOptions): void; + notifyFileRemoved(info: ScriptInfo): void; + } + const nullLanguageServiceHost: ServerLanguageServiceHost; + interface ProjectOptions { + configHasFilesProperty?: boolean; + files?: string[]; + wildcardDirectories?: Map; + compilerOptions?: CompilerOptions; + typingOptions?: TypingOptions; + compileOnSave?: boolean; + } + function isInferredProjectName(name: string): boolean; + function makeInferredProjectName(counter: number): string; + class ThrottledOperations { + private readonly host; + private pendingTimeouts; + constructor(host: ServerHost); + schedule(operationId: string, delay: number, cb: () => void): void; + private static run(self, operationId, cb); + } + class GcTimer { + private readonly host; + private readonly delay; + private readonly logger; + private timerId; + constructor(host: ServerHost, delay: number, logger: Logger); + scheduleCollect(): void; + private static run(self); + } +} +declare namespace ts.server.protocol { + namespace CommandTypes { + type Brace = "brace"; + type BraceCompletion = "braceCompletion"; + type Change = "change"; + type Close = "close"; + type Completions = "completions"; + type CompletionDetails = "completionEntryDetails"; + type CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList"; + type CompileOnSaveEmitFile = "compileOnSaveEmitFile"; + type Configure = "configure"; + type Definition = "definition"; + type Implementation = "implementation"; + type Exit = "exit"; + type Format = "format"; + type Formatonkey = "formatonkey"; + type Geterr = "geterr"; + type GeterrForProject = "geterrForProject"; + type SemanticDiagnosticsSync = "semanticDiagnosticsSync"; + type SyntacticDiagnosticsSync = "syntacticDiagnosticsSync"; + type NavBar = "navbar"; + type Navto = "navto"; + type NavTree = "navtree"; + type NavTreeFull = "navtree-full"; + type Occurrences = "occurrences"; + type DocumentHighlights = "documentHighlights"; + type Open = "open"; + type Quickinfo = "quickinfo"; + type References = "references"; + type Reload = "reload"; + type Rename = "rename"; + type Saveto = "saveto"; + type SignatureHelp = "signatureHelp"; + type TypeDefinition = "typeDefinition"; + type ProjectInfo = "projectInfo"; + type ReloadProjects = "reloadProjects"; + type Unknown = "unknown"; + type OpenExternalProject = "openExternalProject"; + type OpenExternalProjects = "openExternalProjects"; + type CloseExternalProject = "closeExternalProject"; + type TodoComments = "todoComments"; + type Indentation = "indentation"; + type DocCommentTemplate = "docCommentTemplate"; + type CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects"; + type GetCodeFixes = "getCodeFixes"; + type GetSupportedCodeFixes = "getSupportedCodeFixes"; + } + interface Message { + seq: number; + type: "request" | "response" | "event"; + } + interface Request extends Message { + command: string; + arguments?: any; + } + interface ReloadProjectsRequest extends Message { + command: CommandTypes.ReloadProjects; + } + interface Event extends Message { + event: string; + body?: any; + } + interface Response extends Message { + request_seq: number; + success: boolean; + command: string; + message?: string; + body?: any; + } + interface FileRequestArgs { + file: string; + projectFileName?: string; + } + interface DocCommentTemplateRequest extends FileLocationRequest { + command: CommandTypes.DocCommentTemplate; + } + interface DocCommandTemplateResponse extends Response { + body?: TextInsertion; + } + interface TodoCommentRequest extends FileRequest { + command: CommandTypes.TodoComments; + arguments: TodoCommentRequestArgs; + } + interface TodoCommentRequestArgs extends FileRequestArgs { + descriptors: TodoCommentDescriptor[]; + } + interface TodoCommentsResponse extends Response { + body?: TodoComment[]; + } + interface IndentationRequest extends FileLocationRequest { + command: CommandTypes.Indentation; + arguments: IndentationRequestArgs; + } + interface IndentationResponse extends Response { + body?: IndentationResult; + } + interface IndentationResult { + position: number; + indentation: number; + } + interface IndentationRequestArgs extends FileLocationRequestArgs { + options?: EditorSettings; + } + interface ProjectInfoRequestArgs extends FileRequestArgs { + needFileNameList: boolean; + } + interface ProjectInfoRequest extends Request { + command: CommandTypes.ProjectInfo; + arguments: ProjectInfoRequestArgs; + } + interface CompilerOptionsDiagnosticsRequest extends Request { + arguments: CompilerOptionsDiagnosticsRequestArgs; + } + interface CompilerOptionsDiagnosticsRequestArgs { + projectFileName: string; + } + interface ProjectInfo { + configFileName: string; + fileNames?: string[]; + languageServiceDisabled?: boolean; + } + interface DiagnosticWithLinePosition { + message: string; + start: number; + length: number; + startLocation: Location; + endLocation: Location; + category: string; + code: number; + } + interface ProjectInfoResponse extends Response { + body?: ProjectInfo; + } + interface FileRequest extends Request { + arguments: FileRequestArgs; + } + interface FileLocationRequestArgs extends FileRequestArgs { + line: number; + offset: number; + } + interface CodeFixRequest extends Request { + command: CommandTypes.GetCodeFixes; + arguments: CodeFixRequestArgs; + } + interface CodeFixRequestArgs extends FileRequestArgs { + startLine: number; + startOffset: number; + endLine: number; + endOffset: number; + errorCodes?: number[]; + } + interface GetCodeFixesResponse extends Response { + body?: CodeAction[]; + } + interface FileLocationRequest extends FileRequest { + arguments: FileLocationRequestArgs; + } + interface GetSupportedCodeFixesRequest extends Request { + command: CommandTypes.GetSupportedCodeFixes; + } + interface GetSupportedCodeFixesResponse extends Response { + body?: string[]; + } + interface EncodedSemanticClassificationsRequestArgs extends FileRequestArgs { + start: number; + length: number; + } + interface DocumentHighlightsRequestArgs extends FileLocationRequestArgs { + filesToSearch: string[]; + } + interface DefinitionRequest extends FileLocationRequest { + command: CommandTypes.Definition; + } + interface TypeDefinitionRequest extends FileLocationRequest { + command: CommandTypes.TypeDefinition; + } + interface ImplementationRequest extends FileLocationRequest { + command: CommandTypes.Implementation; + } + interface Location { + line: number; + offset: number; + } + interface TextSpan { + start: Location; + end: Location; + } + interface FileSpan extends TextSpan { + file: string; + } + interface DefinitionResponse extends Response { + body?: FileSpan[]; + } + interface TypeDefinitionResponse extends Response { + body?: FileSpan[]; + } + interface ImplementationResponse extends Response { + body?: FileSpan[]; + } + interface BraceCompletionRequest extends FileLocationRequest { + command: CommandTypes.BraceCompletion; + arguments: BraceCompletionRequestArgs; + } + interface BraceCompletionRequestArgs extends FileLocationRequestArgs { + openingBrace: string; + } + interface OccurrencesRequest extends FileLocationRequest { + command: CommandTypes.Occurrences; + } + interface OccurrencesResponseItem extends FileSpan { + isWriteAccess: boolean; + } + interface OccurrencesResponse extends Response { + body?: OccurrencesResponseItem[]; + } + interface DocumentHighlightsRequest extends FileLocationRequest { + command: CommandTypes.DocumentHighlights; + arguments: DocumentHighlightsRequestArgs; + } + interface HighlightSpan extends TextSpan { + kind: string; + } + interface DocumentHighlightsItem { + file: string; + highlightSpans: HighlightSpan[]; + } + interface DocumentHighlightsResponse extends Response { + body?: DocumentHighlightsItem[]; + } + interface ReferencesRequest extends FileLocationRequest { + command: CommandTypes.References; + } + interface ReferencesResponseItem extends FileSpan { + lineText: string; + isWriteAccess: boolean; + isDefinition: boolean; + } + interface ReferencesResponseBody { + refs: ReferencesResponseItem[]; + symbolName: string; + symbolStartOffset: number; + symbolDisplayString: string; + } + interface ReferencesResponse extends Response { + body?: ReferencesResponseBody; + } + interface RenameRequestArgs extends FileLocationRequestArgs { + findInComments?: boolean; + findInStrings?: boolean; + } + interface RenameRequest extends FileLocationRequest { + command: CommandTypes.Rename; + arguments: RenameRequestArgs; + } + interface RenameInfo { + canRename: boolean; + localizedErrorMessage?: string; + displayName: string; + fullDisplayName: string; + kind: string; + kindModifiers: string; + } + interface SpanGroup { + file: string; + locs: TextSpan[]; + } + interface RenameResponseBody { + info: RenameInfo; + locs: SpanGroup[]; + } + interface RenameResponse extends Response { + body?: RenameResponseBody; + } + interface ExternalFile { + fileName: string; + scriptKind?: ScriptKindName | ts.ScriptKind; + hasMixedContent?: boolean; + content?: string; + } + interface ExternalProject { + projectFileName: string; + rootFiles: ExternalFile[]; + options: ExternalProjectCompilerOptions; + typingOptions?: TypingOptions; + } + interface CompileOnSaveMixin { + compileOnSave?: boolean; + } + type ExternalProjectCompilerOptions = CompilerOptions & CompileOnSaveMixin; + interface ProjectChanges { + added: string[]; + removed: string[]; + } + interface ConfigureRequestArguments { + hostInfo?: string; + file?: string; + formatOptions?: FormatCodeSettings; + } + interface ConfigureRequest extends Request { + command: CommandTypes.Configure; + arguments: ConfigureRequestArguments; + } + interface ConfigureResponse extends Response { + } + interface OpenRequestArgs extends FileRequestArgs { + fileContent?: string; + scriptKindName?: ScriptKindName; + } + type ScriptKindName = "TS" | "JS" | "TSX" | "JSX"; + interface OpenRequest extends Request { + command: CommandTypes.Open; + arguments: OpenRequestArgs; + } + interface OpenExternalProjectRequest extends Request { + command: CommandTypes.OpenExternalProject; + arguments: OpenExternalProjectArgs; + } + type OpenExternalProjectArgs = ExternalProject; + interface OpenExternalProjectsRequest extends Request { + command: CommandTypes.OpenExternalProjects; + arguments: OpenExternalProjectsArgs; + } + interface OpenExternalProjectsArgs { + projects: ExternalProject[]; + } + interface OpenExternalProjectResponse extends Response { + } + interface OpenExternalProjectsResponse extends Response { + } + interface CloseExternalProjectRequest extends Request { + command: CommandTypes.CloseExternalProject; + arguments: CloseExternalProjectRequestArgs; + } + interface CloseExternalProjectRequestArgs { + projectFileName: string; + } + interface CloseExternalProjectResponse extends Response { + } + interface SetCompilerOptionsForInferredProjectsRequest extends Request { + command: CommandTypes.CompilerOptionsForInferredProjects; + arguments: SetCompilerOptionsForInferredProjectsArgs; + } + interface SetCompilerOptionsForInferredProjectsArgs { + options: ExternalProjectCompilerOptions; + } + interface SetCompilerOptionsForInferredProjectsResponse extends Response { + } + interface ExitRequest extends Request { + command: CommandTypes.Exit; + } + interface CloseRequest extends FileRequest { + command: CommandTypes.Close; + } + interface CompileOnSaveAffectedFileListRequest extends FileRequest { + command: CommandTypes.CompileOnSaveAffectedFileList; + } + interface CompileOnSaveAffectedFileListSingleProject { + projectFileName: string; + fileNames: string[]; + } + interface CompileOnSaveAffectedFileListResponse extends Response { + body: CompileOnSaveAffectedFileListSingleProject[]; + } + interface CompileOnSaveEmitFileRequest extends FileRequest { + command: CommandTypes.CompileOnSaveEmitFile; + arguments: CompileOnSaveEmitFileRequestArgs; + } + interface CompileOnSaveEmitFileRequestArgs extends FileRequestArgs { + forced?: boolean; + } + interface QuickInfoRequest extends FileLocationRequest { + command: CommandTypes.Quickinfo; + } + interface QuickInfoResponseBody { + kind: string; + kindModifiers: string; + start: Location; + end: Location; + displayString: string; + documentation: string; + } + interface QuickInfoResponse extends Response { + body?: QuickInfoResponseBody; + } + interface FormatRequestArgs extends FileLocationRequestArgs { + endLine: number; + endOffset: number; + options?: FormatCodeSettings; + } + interface FormatRequest extends FileLocationRequest { + command: CommandTypes.Format; + arguments: FormatRequestArgs; + } + interface CodeEdit { + start: Location; + end: Location; + newText: string; + } + interface FileCodeEdits { + fileName: string; + textChanges: CodeEdit[]; + } + interface CodeFixResponse extends Response { + body?: CodeAction[]; + } + interface CodeAction { + description: string; + changes: FileCodeEdits[]; + } + interface FormatResponse extends Response { + body?: CodeEdit[]; + } + interface FormatOnKeyRequestArgs extends FileLocationRequestArgs { + key: string; + options?: FormatCodeSettings; + } + interface FormatOnKeyRequest extends FileLocationRequest { + command: CommandTypes.Formatonkey; + arguments: FormatOnKeyRequestArgs; + } + interface CompletionsRequestArgs extends FileLocationRequestArgs { + prefix?: string; + } + interface CompletionsRequest extends FileLocationRequest { + command: CommandTypes.Completions; + arguments: CompletionsRequestArgs; + } + interface CompletionDetailsRequestArgs extends FileLocationRequestArgs { + entryNames: string[]; + } + interface CompletionDetailsRequest extends FileLocationRequest { + command: CommandTypes.CompletionDetails; + arguments: CompletionDetailsRequestArgs; + } + interface SymbolDisplayPart { + text: string; + kind: string; + } + interface CompletionEntry { + name: string; + kind: string; + kindModifiers: string; + sortText: string; + replacementSpan?: TextSpan; + } + interface CompletionEntryDetails { + name: string; + kind: string; + kindModifiers: string; + displayParts: SymbolDisplayPart[]; + documentation: SymbolDisplayPart[]; + } + interface CompletionsResponse extends Response { + body?: CompletionEntry[]; + } + interface CompletionDetailsResponse extends Response { + body?: CompletionEntryDetails[]; + } + interface SignatureHelpParameter { + name: string; + documentation: SymbolDisplayPart[]; + displayParts: SymbolDisplayPart[]; + isOptional: boolean; + } + interface SignatureHelpItem { + isVariadic: boolean; + prefixDisplayParts: SymbolDisplayPart[]; + suffixDisplayParts: SymbolDisplayPart[]; + separatorDisplayParts: SymbolDisplayPart[]; + parameters: SignatureHelpParameter[]; + documentation: SymbolDisplayPart[]; + } + interface SignatureHelpItems { + items: SignatureHelpItem[]; + applicableSpan: TextSpan; + selectedItemIndex: number; + argumentIndex: number; + argumentCount: number; + } + interface SignatureHelpRequestArgs extends FileLocationRequestArgs { + } + interface SignatureHelpRequest extends FileLocationRequest { + command: CommandTypes.SignatureHelp; + arguments: SignatureHelpRequestArgs; + } + interface SignatureHelpResponse extends Response { + body?: SignatureHelpItems; + } + interface SemanticDiagnosticsSyncRequest extends FileRequest { + command: CommandTypes.SemanticDiagnosticsSync; + arguments: SemanticDiagnosticsSyncRequestArgs; + } + interface SemanticDiagnosticsSyncRequestArgs extends FileRequestArgs { + includeLinePosition?: boolean; + } + interface SemanticDiagnosticsSyncResponse extends Response { + body?: Diagnostic[] | DiagnosticWithLinePosition[]; + } + interface SyntacticDiagnosticsSyncRequest extends FileRequest { + command: CommandTypes.SyntacticDiagnosticsSync; + arguments: SyntacticDiagnosticsSyncRequestArgs; + } + interface SyntacticDiagnosticsSyncRequestArgs extends FileRequestArgs { + includeLinePosition?: boolean; + } + interface SyntacticDiagnosticsSyncResponse extends Response { + body?: Diagnostic[] | DiagnosticWithLinePosition[]; + } + interface GeterrForProjectRequestArgs { + file: string; + delay: number; + } + interface GeterrForProjectRequest extends Request { + command: CommandTypes.GeterrForProject; + arguments: GeterrForProjectRequestArgs; + } + interface GeterrRequestArgs { + files: string[]; + delay: number; + } + interface GeterrRequest extends Request { + command: CommandTypes.Geterr; + arguments: GeterrRequestArgs; + } + interface Diagnostic { + start: Location; + end: Location; + text: string; + code?: number; + } + interface DiagnosticEventBody { + file: string; + diagnostics: Diagnostic[]; + } + interface DiagnosticEvent extends Event { + body?: DiagnosticEventBody; + } + interface ConfigFileDiagnosticEventBody { + triggerFile: string; + configFile: string; + diagnostics: Diagnostic[]; + } + interface ConfigFileDiagnosticEvent extends Event { + body?: ConfigFileDiagnosticEventBody; + event: "configFileDiag"; + } + interface ReloadRequestArgs extends FileRequestArgs { + tmpfile: string; + } + interface ReloadRequest extends FileRequest { + command: CommandTypes.Reload; + arguments: ReloadRequestArgs; + } + interface ReloadResponse extends Response { + } + interface SavetoRequestArgs extends FileRequestArgs { + tmpfile: string; + } + interface SavetoRequest extends FileRequest { + command: CommandTypes.Saveto; + arguments: SavetoRequestArgs; + } + interface NavtoRequestArgs extends FileRequestArgs { + searchValue: string; + maxResultCount?: number; + currentFileOnly?: boolean; + projectFileName?: string; + } + interface NavtoRequest extends FileRequest { + command: CommandTypes.Navto; + arguments: NavtoRequestArgs; + } + interface NavtoItem { + name: string; + kind: string; + matchKind?: string; + isCaseSensitive?: boolean; + kindModifiers?: string; + file: string; + start: Location; + end: Location; + containerName?: string; + containerKind?: string; + } + interface NavtoResponse extends Response { + body?: NavtoItem[]; + } + interface ChangeRequestArgs extends FormatRequestArgs { + insertString?: string; + } + interface ChangeRequest extends FileLocationRequest { + command: CommandTypes.Change; + arguments: ChangeRequestArgs; + } + interface BraceResponse extends Response { + body?: TextSpan[]; + } + interface BraceRequest extends FileLocationRequest { + command: CommandTypes.Brace; + } + interface NavBarRequest extends FileRequest { + command: CommandTypes.NavBar; + } + interface NavTreeRequest extends FileRequest { + command: CommandTypes.NavTree; + } + interface NavigationBarItem { + text: string; + kind: string; + kindModifiers?: string; + spans: TextSpan[]; + childItems?: NavigationBarItem[]; + indent: number; + } + interface NavigationTree { + text: string; + kind: string; + kindModifiers: string; + spans: TextSpan[]; + childItems?: NavigationTree[]; + } + interface NavBarResponse extends Response { + body?: NavigationBarItem[]; + } + interface NavTreeResponse extends Response { + body?: NavigationTree; + } + namespace IndentStyle { + type None = "None"; + type Block = "Block"; + type Smart = "Smart"; + } + type IndentStyle = IndentStyle.None | IndentStyle.Block | IndentStyle.Smart; + interface EditorSettings { + baseIndentSize?: number; + indentSize?: number; + tabSize?: number; + newLineCharacter?: string; + convertTabsToSpaces?: boolean; + indentStyle?: IndentStyle | ts.IndentStyle; + } + interface FormatCodeSettings extends EditorSettings { + insertSpaceAfterCommaDelimiter?: boolean; + insertSpaceAfterSemicolonInForStatements?: boolean; + insertSpaceBeforeAndAfterBinaryOperators?: boolean; + insertSpaceAfterKeywordsInControlFlowStatements?: boolean; + insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; + insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; + insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean; + insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; + insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; + placeOpenBraceOnNewLineForFunctions?: boolean; + placeOpenBraceOnNewLineForControlBlocks?: boolean; + } + interface CompilerOptions { + allowJs?: boolean; + allowSyntheticDefaultImports?: boolean; + allowUnreachableCode?: boolean; + allowUnusedLabels?: boolean; + baseUrl?: string; + charset?: string; + declaration?: boolean; + declarationDir?: string; + disableSizeLimit?: boolean; + emitBOM?: boolean; + emitDecoratorMetadata?: boolean; + experimentalDecorators?: boolean; + forceConsistentCasingInFileNames?: boolean; + inlineSourceMap?: boolean; + inlineSources?: boolean; + isolatedModules?: boolean; + jsx?: JsxEmit | ts.JsxEmit; + lib?: string[]; + locale?: string; + mapRoot?: string; + maxNodeModuleJsDepth?: number; + module?: ModuleKind | ts.ModuleKind; + moduleResolution?: ModuleResolutionKind | ts.ModuleResolutionKind; + newLine?: NewLineKind | ts.NewLineKind; + noEmit?: boolean; + noEmitHelpers?: boolean; + noEmitOnError?: boolean; + noErrorTruncation?: boolean; + noFallthroughCasesInSwitch?: boolean; + noImplicitAny?: boolean; + noImplicitReturns?: boolean; + noImplicitThis?: boolean; + noUnusedLocals?: boolean; + noUnusedParameters?: boolean; + noImplicitUseStrict?: boolean; + noLib?: boolean; + noResolve?: boolean; + out?: string; + outDir?: string; + outFile?: string; + paths?: MapLike; + preserveConstEnums?: boolean; + project?: string; + reactNamespace?: string; + removeComments?: boolean; + rootDir?: string; + rootDirs?: string[]; + skipLibCheck?: boolean; + skipDefaultLibCheck?: boolean; + sourceMap?: boolean; + sourceRoot?: string; + strictNullChecks?: boolean; + suppressExcessPropertyErrors?: boolean; + suppressImplicitAnyIndexErrors?: boolean; + target?: ScriptTarget | ts.ScriptTarget; + traceResolution?: boolean; + types?: string[]; + typeRoots?: string[]; + [option: string]: CompilerOptionsValue | undefined; + } + namespace JsxEmit { + type None = "None"; + type Preserve = "Preserve"; + type React = "React"; + } + type JsxEmit = JsxEmit.None | JsxEmit.Preserve | JsxEmit.React; + namespace ModuleKind { + type None = "None"; + type CommonJS = "CommonJS"; + type AMD = "AMD"; + type UMD = "UMD"; + type System = "System"; + type ES6 = "ES6"; + type ES2015 = "ES2015"; + } + type ModuleKind = ModuleKind.None | ModuleKind.CommonJS | ModuleKind.AMD | ModuleKind.UMD | ModuleKind.System | ModuleKind.ES6 | ModuleKind.ES2015; + namespace ModuleResolutionKind { + type Classic = "Classic"; + type Node = "Node"; + } + type ModuleResolutionKind = ModuleResolutionKind.Classic | ModuleResolutionKind.Node; + namespace NewLineKind { + type Crlf = "Crlf"; + type Lf = "Lf"; + } + type NewLineKind = NewLineKind.Crlf | NewLineKind.Lf; + namespace ScriptTarget { + type ES3 = "ES3"; + type ES5 = "ES5"; + type ES6 = "ES6"; + type ES2015 = "ES2015"; + } + type ScriptTarget = ScriptTarget.ES3 | ScriptTarget.ES5 | ScriptTarget.ES6 | ScriptTarget.ES2015; +} declare namespace ts.server { class ScriptInfo { private readonly host; @@ -10372,7 +3564,7 @@ declare namespace ts.server { getLatestVersion(): string; reload(script: string): void; saveTo(fileName: string): void; - reloadFromFile(): void; + reloadFromFile(tempFileName?: NormalizedPath): void; snap(): LineIndexSnapshot; getLineInfo(line: number): ILineInfo; editContent(start: number, end: number, newText: string): void; @@ -10529,7 +3721,7 @@ declare namespace ts.server { getScriptInfo(uncheckedFileName: string): ScriptInfo; filesToString(): string; setCompilerOptions(compilerOptions: CompilerOptions): void; - reloadScript(filename: NormalizedPath): boolean; + reloadScript(filename: NormalizedPath, tempFileName?: NormalizedPath): boolean; getChangesSinceVersion(lastKnownVersion?: number): ProjectFilesWithTSDiagnostics; getReferencedFiles(path: Path): Path[]; private removeRootFileIfNecessary(info); @@ -10595,7 +3787,7 @@ declare namespace ts.server { } | { eventName: "configFileDiag"; data: { - triggerFile?: string; + triggerFile: string; configFileName: string; diagnostics: Diagnostic[]; }; @@ -10603,6 +3795,10 @@ declare namespace ts.server { interface ProjectServiceEventHandler { (event: ProjectServiceEvent): void; } + function convertFormatOptions(protocolOptions: protocol.FormatCodeSettings): FormatCodeSettings; + function convertCompilerOptions(protocolOptions: protocol.ExternalProjectCompilerOptions): CompilerOptions & protocol.CompileOnSaveMixin; + function tryConvertScriptKindName(scriptKindName: protocol.ScriptKindName | ScriptKind): ScriptKind; + function convertScriptKindName(scriptKindName: protocol.ScriptKindName): ScriptKind; function combineProjectOutput(projects: Project[], action: (project: Project) => T[], comparer?: (a: T, b: T) => number, areEqual?: (a: T, b: T) => boolean): T[]; interface HostConfiguration { formatCodeOptions: FormatCodeSettings; @@ -10638,6 +3834,7 @@ declare namespace ts.server { constructor(host: ServerHost, logger: Logger, cancellationToken: HostCancellationToken, useSingleInferredProject: boolean, typingsInstaller?: ITypingsInstaller, eventHandler?: ProjectServiceEventHandler); getChangedFiles_TestOnly(): ScriptInfo[]; ensureInferredProjectsUpToDate_TestOnly(): void; + getCompilerOptionsForInferredProjects(): CompilerOptions; updateTypingsForProject(response: SetTypings | InvalidateCachedTypings): void; setCompilerOptionsForInferredProjects(projectCompilerOptions: protocol.ExternalProjectCompilerOptions): void; stopWatchingDirectory(directory: string): void; @@ -10651,7 +3848,7 @@ declare namespace ts.server { private handleDeletedFile(info); private onTypeRootFileChanged(project, fileName); private onSourceFileInDirectoryChangedForConfiguredProject(project, fileName); - private handleChangeInSourceFileForConfiguredProject(project); + private handleChangeInSourceFileForConfiguredProject(project, triggerFile); private onConfigChangedForConfiguredProject(project); private onConfigFileAddedForInferredProject(fileName); private getCanonicalFileName(fileName); @@ -10666,7 +3863,7 @@ declare namespace ts.server { private convertConfigFileContentToProjectOptions(configFilename); private exceededTotalSizeLimitForNonTsFiles(options, fileNames, propertyReader); private createAndAddExternalProject(projectFileName, files, options, typingOptions); - private reportConfigFileDiagnostics(configFileName, diagnostics, triggerFile?); + private reportConfigFileDiagnostics(configFileName, diagnostics, triggerFile); private createAndAddConfiguredProject(configFileName, projectOptions, configFileErrors, clientFileName?); private watchConfigDirectoryForProject(project, options); private addFilesToProjectAndUpdateGraph(project, files, propertyReader, clientFileName, typingOptions, configFileErrors); @@ -10800,7 +3997,7 @@ declare namespace ts.server { private getProject(projectFileName); private getCompilerOptionsDiagnostics(args); private convertToDiagnosticsWithLinePosition(diagnostics, scriptInfo); - private getDiagnosticsWorker(args, selector, includeLinePosition); + private getDiagnosticsWorker(args, isSemantic, selector, includeLinePosition); private getDefinition(args, simplifiedResult); private getTypeDefinition(args); private getImplementation(args, simplifiedResult); @@ -10996,178 +4193,3 @@ declare namespace ts.server { lineCount(): number; } } -declare let debugObjectHost: any; -declare namespace ts { - interface ScriptSnapshotShim { - getText(start: number, end: number): string; - getLength(): number; - getChangeRange(oldSnapshot: ScriptSnapshotShim): string; - dispose?(): void; - } - interface Logger { - log(s: string): void; - trace(s: string): void; - error(s: string): void; - } - interface LanguageServiceShimHost extends Logger { - getCompilationSettings(): string; - getScriptFileNames(): string; - getScriptKind?(fileName: string): ScriptKind; - getScriptVersion(fileName: string): string; - getScriptSnapshot(fileName: string): ScriptSnapshotShim; - getLocalizedDiagnosticMessages(): string; - getCancellationToken(): HostCancellationToken; - getCurrentDirectory(): string; - getDirectories(path: string): string; - getDefaultLibFileName(options: string): string; - getNewLine?(): string; - getProjectVersion?(): string; - useCaseSensitiveFileNames?(): boolean; - getTypeRootsVersion?(): number; - readDirectory(rootDir: string, extension: string, basePaths?: string, excludeEx?: string, includeFileEx?: string, includeDirEx?: string, depth?: number): string; - readFile(path: string, encoding?: string): string; - fileExists(path: string): boolean; - getModuleResolutionsForFile?(fileName: string): string; - getTypeReferenceDirectiveResolutionsForFile?(fileName: string): string; - directoryExists(directoryName: string): boolean; - } - interface CoreServicesShimHost extends Logger { - directoryExists(directoryName: string): boolean; - fileExists(fileName: string): boolean; - getCurrentDirectory(): string; - getDirectories(path: string): string; - readDirectory(rootDir: string, extension: string, basePaths?: string, excludeEx?: string, includeFileEx?: string, includeDirEx?: string, depth?: number): string; - readFile(fileName: string): string; - realpath?(path: string): string; - trace(s: string): void; - useCaseSensitiveFileNames?(): boolean; - } - interface IFileReference { - path: string; - position: number; - length: number; - } - interface ShimFactory { - registerShim(shim: Shim): void; - unregisterShim(shim: Shim): void; - } - interface Shim { - dispose(dummy: any): void; - } - interface LanguageServiceShim extends Shim { - languageService: LanguageService; - dispose(dummy: any): void; - refresh(throwOnError: boolean): void; - cleanupSemanticCache(): void; - getSyntacticDiagnostics(fileName: string): string; - getSemanticDiagnostics(fileName: string): string; - getCompilerOptionsDiagnostics(): string; - getSyntacticClassifications(fileName: string, start: number, length: number): string; - getSemanticClassifications(fileName: string, start: number, length: number): string; - getEncodedSyntacticClassifications(fileName: string, start: number, length: number): string; - getEncodedSemanticClassifications(fileName: string, start: number, length: number): string; - getCompletionsAtPosition(fileName: string, position: number): string; - getCompletionEntryDetails(fileName: string, position: number, entryName: string): string; - getQuickInfoAtPosition(fileName: string, position: number): string; - getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): string; - getBreakpointStatementAtPosition(fileName: string, position: number): string; - getSignatureHelpItems(fileName: string, position: number): string; - getRenameInfo(fileName: string, position: number): string; - findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): string; - getDefinitionAtPosition(fileName: string, position: number): string; - getTypeDefinitionAtPosition(fileName: string, position: number): string; - getImplementationAtPosition(fileName: string, position: number): string; - getReferencesAtPosition(fileName: string, position: number): string; - findReferences(fileName: string, position: number): string; - getOccurrencesAtPosition(fileName: string, position: number): string; - getDocumentHighlights(fileName: string, position: number, filesToSearch: string): string; - getNavigateToItems(searchValue: string, maxResultCount?: number, fileName?: string): string; - getNavigationBarItems(fileName: string): string; - getNavigationTree(fileName: string): string; - getOutliningSpans(fileName: string): string; - getTodoComments(fileName: string, todoCommentDescriptors: string): string; - getBraceMatchingAtPosition(fileName: string, position: number): string; - getIndentationAtPosition(fileName: string, position: number, options: string): string; - getFormattingEditsForRange(fileName: string, start: number, end: number, options: string): string; - getFormattingEditsForDocument(fileName: string, options: string): string; - getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: string): string; - getDocCommentTemplateAtPosition(fileName: string, position: number): string; - isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): string; - getEmitOutput(fileName: string): string; - getEmitOutputObject(fileName: string): EmitOutput; - } - interface ClassifierShim extends Shim { - getEncodedLexicalClassifications(text: string, lexState: EndOfLineState, syntacticClassifierAbsent?: boolean): string; - getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent?: boolean): string; - } - interface CoreServicesShim extends Shim { - getAutomaticTypeDirectiveNames(compilerOptionsJson: string): string; - getPreProcessedFileInfo(fileName: string, sourceText: IScriptSnapshot): string; - getTSConfigFileInfo(fileName: string, sourceText: IScriptSnapshot): string; - getDefaultCompilationSettings(): string; - discoverTypings(discoverTypingsJson: string): string; - } - class LanguageServiceShimHostAdapter implements LanguageServiceHost { - private shimHost; - private files; - private loggingEnabled; - private tracingEnabled; - resolveModuleNames: (moduleName: string[], containingFile: string) => ResolvedModule[]; - resolveTypeReferenceDirectives: (typeDirectiveNames: string[], containingFile: string) => ResolvedTypeReferenceDirective[]; - directoryExists: (directoryName: string) => boolean; - constructor(shimHost: LanguageServiceShimHost); - log(s: string): void; - trace(s: string): void; - error(s: string): void; - getProjectVersion(): string; - getTypeRootsVersion(): number; - useCaseSensitiveFileNames(): boolean; - getCompilationSettings(): CompilerOptions; - getScriptFileNames(): string[]; - getScriptSnapshot(fileName: string): IScriptSnapshot; - getScriptKind(fileName: string): ScriptKind; - getScriptVersion(fileName: string): string; - getLocalizedDiagnosticMessages(): any; - getCancellationToken(): HostCancellationToken; - getCurrentDirectory(): string; - getDirectories(path: string): string[]; - getDefaultLibFileName(options: CompilerOptions): string; - readDirectory(path: string, extensions?: string[], exclude?: string[], include?: string[], depth?: number): string[]; - readFile(path: string, encoding?: string): string; - fileExists(path: string): boolean; - } - class CoreServicesShimHostAdapter implements ParseConfigHost, ModuleResolutionHost { - private shimHost; - directoryExists: (directoryName: string) => boolean; - realpath: (path: string) => string; - useCaseSensitiveFileNames: boolean; - constructor(shimHost: CoreServicesShimHost); - readDirectory(rootDir: string, extensions: string[], exclude: string[], include: string[], depth?: number): string[]; - fileExists(fileName: string): boolean; - readFile(fileName: string): string; - private readDirectoryFallback(rootDir, extension, exclude); - getDirectories(path: string): string[]; - } - function realizeDiagnostics(diagnostics: Diagnostic[], newLine: string): { - message: string; - start: number; - length: number; - category: string; - code: number; - }[]; - class TypeScriptServicesFactory implements ShimFactory { - private _shims; - private documentRegistry; - getServicesVersion(): string; - createLanguageServiceShim(host: LanguageServiceShimHost): LanguageServiceShim; - createClassifierShim(logger: Logger): ClassifierShim; - createCoreServicesShim(host: CoreServicesShimHost): CoreServicesShim; - close(): void; - registerShim(shim: Shim): void; - unregisterShim(shim: Shim): void; - } -} -declare namespace TypeScript.Services { - const TypeScriptServicesFactory: typeof ts.TypeScriptServicesFactory; -} -declare const toolsVersion = "2.1"; diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index a360ac081ec..0a476fd3ed1 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -20,6 +20,418 @@ var __extends = (this && this.__extends) || function (d, b) { }; var ts; (function (ts) { + (function (SyntaxKind) { + SyntaxKind[SyntaxKind["Unknown"] = 0] = "Unknown"; + SyntaxKind[SyntaxKind["EndOfFileToken"] = 1] = "EndOfFileToken"; + SyntaxKind[SyntaxKind["SingleLineCommentTrivia"] = 2] = "SingleLineCommentTrivia"; + SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 3] = "MultiLineCommentTrivia"; + SyntaxKind[SyntaxKind["NewLineTrivia"] = 4] = "NewLineTrivia"; + SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 5] = "WhitespaceTrivia"; + SyntaxKind[SyntaxKind["ShebangTrivia"] = 6] = "ShebangTrivia"; + SyntaxKind[SyntaxKind["ConflictMarkerTrivia"] = 7] = "ConflictMarkerTrivia"; + SyntaxKind[SyntaxKind["NumericLiteral"] = 8] = "NumericLiteral"; + SyntaxKind[SyntaxKind["StringLiteral"] = 9] = "StringLiteral"; + SyntaxKind[SyntaxKind["JsxText"] = 10] = "JsxText"; + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 11] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 12] = "NoSubstitutionTemplateLiteral"; + SyntaxKind[SyntaxKind["TemplateHead"] = 13] = "TemplateHead"; + SyntaxKind[SyntaxKind["TemplateMiddle"] = 14] = "TemplateMiddle"; + SyntaxKind[SyntaxKind["TemplateTail"] = 15] = "TemplateTail"; + SyntaxKind[SyntaxKind["OpenBraceToken"] = 16] = "OpenBraceToken"; + SyntaxKind[SyntaxKind["CloseBraceToken"] = 17] = "CloseBraceToken"; + SyntaxKind[SyntaxKind["OpenParenToken"] = 18] = "OpenParenToken"; + SyntaxKind[SyntaxKind["CloseParenToken"] = 19] = "CloseParenToken"; + SyntaxKind[SyntaxKind["OpenBracketToken"] = 20] = "OpenBracketToken"; + SyntaxKind[SyntaxKind["CloseBracketToken"] = 21] = "CloseBracketToken"; + SyntaxKind[SyntaxKind["DotToken"] = 22] = "DotToken"; + SyntaxKind[SyntaxKind["DotDotDotToken"] = 23] = "DotDotDotToken"; + SyntaxKind[SyntaxKind["SemicolonToken"] = 24] = "SemicolonToken"; + SyntaxKind[SyntaxKind["CommaToken"] = 25] = "CommaToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 26] = "LessThanToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 27] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 28] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 29] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 30] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 31] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 32] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 33] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 34] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 35] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 36] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 37] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 38] = "AsteriskToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 39] = "AsteriskAsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 40] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 41] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 42] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 43] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 44] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 45] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 46] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 47] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 48] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 49] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 50] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 51] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 52] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 53] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 54] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 55] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 56] = "AtToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 57] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 58] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 59] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 60] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 61] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 62] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 63] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 64] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 65] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 66] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 67] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 68] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 69] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["Identifier"] = 70] = "Identifier"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 71] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 72] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 73] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 74] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 75] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 76] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 77] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 78] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 79] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 80] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 81] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 82] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 83] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 84] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 85] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 86] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 87] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 88] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 89] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 90] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 91] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 92] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 93] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 94] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 95] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 96] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 97] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 98] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 99] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 100] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 101] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 102] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 103] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 104] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 105] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 106] = "WithKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 107] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 108] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 109] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 110] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 111] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 112] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 113] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 114] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 115] = "YieldKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 116] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 117] = "AsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 118] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 119] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 120] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 121] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 122] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 123] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 124] = "GetKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 125] = "IsKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 126] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 127] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 128] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 129] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 130] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 131] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 132] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 133] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 134] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 135] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 136] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 137] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 138] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 139] = "OfKeyword"; + SyntaxKind[SyntaxKind["QualifiedName"] = 140] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 141] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["TypeParameter"] = 142] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 143] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 144] = "Decorator"; + SyntaxKind[SyntaxKind["PropertySignature"] = 145] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 146] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 147] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 148] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 149] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 150] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 151] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 152] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 153] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 154] = "IndexSignature"; + SyntaxKind[SyntaxKind["TypePredicate"] = 155] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 156] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 157] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 158] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 159] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 160] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 161] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 162] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 163] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 164] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 165] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 166] = "ThisType"; + SyntaxKind[SyntaxKind["LiteralType"] = 167] = "LiteralType"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 168] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 169] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 170] = "BindingElement"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 171] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 172] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 173] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 174] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 175] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 176] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 177] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 178] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 179] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 180] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 181] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 182] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 183] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 184] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 185] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 186] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 187] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 188] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 189] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 190] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 191] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElementExpression"] = 192] = "SpreadElementExpression"; + SyntaxKind[SyntaxKind["ClassExpression"] = 193] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 194] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 195] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 196] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 197] = "NonNullExpression"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 198] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 199] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["Block"] = 200] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 201] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 202] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 203] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 204] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 205] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 206] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 207] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 208] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 209] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 210] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 211] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 212] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 213] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 214] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 215] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 216] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 217] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 218] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 219] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 220] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 221] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 222] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 223] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 224] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 225] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 226] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 227] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 228] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 229] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 230] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 231] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 232] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 233] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 234] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 235] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 236] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 237] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 238] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 239] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 240] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 241] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["JsxElement"] = 242] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 243] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 244] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 245] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 246] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 247] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 248] = "JsxExpression"; + SyntaxKind[SyntaxKind["CaseClause"] = 249] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 250] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 251] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 252] = "CatchClause"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 253] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 254] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["EnumMember"] = 255] = "EnumMember"; + SyntaxKind[SyntaxKind["SourceFile"] = 256] = "SourceFile"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 257] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 258] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 259] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 260] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 261] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 262] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 263] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 264] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 265] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 266] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 267] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 268] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 269] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 270] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 271] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 272] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 273] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 274] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 275] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 276] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 277] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 278] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 279] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 280] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 281] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocLiteralType"] = 282] = "JSDocLiteralType"; + SyntaxKind[SyntaxKind["JSDocNullKeyword"] = 283] = "JSDocNullKeyword"; + SyntaxKind[SyntaxKind["JSDocUndefinedKeyword"] = 284] = "JSDocUndefinedKeyword"; + SyntaxKind[SyntaxKind["JSDocNeverKeyword"] = 285] = "JSDocNeverKeyword"; + SyntaxKind[SyntaxKind["SyntaxList"] = 286] = "SyntaxList"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 287] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 288] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["Count"] = 289] = "Count"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 57] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 69] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 58] = "FirstCompoundAssignment"; + SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 69] = "LastCompoundAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 71] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 106] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 71] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 139] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 107] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 115] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 155] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 167] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstPunctuation"] = 16] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 69] = "LastPunctuation"; + SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; + SyntaxKind[SyntaxKind["LastToken"] = 139] = "LastToken"; + SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; + SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; + SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; + SyntaxKind[SyntaxKind["LastLiteralToken"] = 12] = "LastLiteralToken"; + SyntaxKind[SyntaxKind["FirstTemplateToken"] = 12] = "FirstTemplateToken"; + SyntaxKind[SyntaxKind["LastTemplateToken"] = 15] = "LastTemplateToken"; + SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 26] = "FirstBinaryOperator"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 69] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstNode"] = 140] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 257] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 282] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 273] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 285] = "LastJSDocTagNode"; + })(ts.SyntaxKind || (ts.SyntaxKind = {})); + var SyntaxKind = ts.SyntaxKind; + (function (NodeFlags) { + NodeFlags[NodeFlags["None"] = 0] = "None"; + NodeFlags[NodeFlags["Let"] = 1] = "Let"; + NodeFlags[NodeFlags["Const"] = 2] = "Const"; + NodeFlags[NodeFlags["NestedNamespace"] = 4] = "NestedNamespace"; + NodeFlags[NodeFlags["Synthesized"] = 8] = "Synthesized"; + NodeFlags[NodeFlags["Namespace"] = 16] = "Namespace"; + NodeFlags[NodeFlags["ExportContext"] = 32] = "ExportContext"; + NodeFlags[NodeFlags["ContainsThis"] = 64] = "ContainsThis"; + NodeFlags[NodeFlags["HasImplicitReturn"] = 128] = "HasImplicitReturn"; + NodeFlags[NodeFlags["HasExplicitReturn"] = 256] = "HasExplicitReturn"; + NodeFlags[NodeFlags["GlobalAugmentation"] = 512] = "GlobalAugmentation"; + NodeFlags[NodeFlags["HasClassExtends"] = 1024] = "HasClassExtends"; + NodeFlags[NodeFlags["HasDecorators"] = 2048] = "HasDecorators"; + NodeFlags[NodeFlags["HasParamDecorators"] = 4096] = "HasParamDecorators"; + NodeFlags[NodeFlags["HasAsyncFunctions"] = 8192] = "HasAsyncFunctions"; + NodeFlags[NodeFlags["HasJsxSpreadAttributes"] = 16384] = "HasJsxSpreadAttributes"; + NodeFlags[NodeFlags["DisallowInContext"] = 32768] = "DisallowInContext"; + NodeFlags[NodeFlags["YieldContext"] = 65536] = "YieldContext"; + NodeFlags[NodeFlags["DecoratorContext"] = 131072] = "DecoratorContext"; + NodeFlags[NodeFlags["AwaitContext"] = 262144] = "AwaitContext"; + NodeFlags[NodeFlags["ThisNodeHasError"] = 524288] = "ThisNodeHasError"; + NodeFlags[NodeFlags["JavaScriptFile"] = 1048576] = "JavaScriptFile"; + NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 2097152] = "ThisNodeOrAnySubNodesHasError"; + NodeFlags[NodeFlags["HasAggregatedChildData"] = 4194304] = "HasAggregatedChildData"; + NodeFlags[NodeFlags["BlockScoped"] = 3] = "BlockScoped"; + NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 384] = "ReachabilityCheckFlags"; + NodeFlags[NodeFlags["EmitHelperFlags"] = 31744] = "EmitHelperFlags"; + NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 32128] = "ReachabilityAndEmitFlags"; + NodeFlags[NodeFlags["ContextFlags"] = 1540096] = "ContextFlags"; + NodeFlags[NodeFlags["TypeExcludesFlags"] = 327680] = "TypeExcludesFlags"; + })(ts.NodeFlags || (ts.NodeFlags = {})); + var NodeFlags = ts.NodeFlags; + (function (ModifierFlags) { + ModifierFlags[ModifierFlags["None"] = 0] = "None"; + ModifierFlags[ModifierFlags["Export"] = 1] = "Export"; + ModifierFlags[ModifierFlags["Ambient"] = 2] = "Ambient"; + ModifierFlags[ModifierFlags["Public"] = 4] = "Public"; + ModifierFlags[ModifierFlags["Private"] = 8] = "Private"; + ModifierFlags[ModifierFlags["Protected"] = 16] = "Protected"; + ModifierFlags[ModifierFlags["Static"] = 32] = "Static"; + ModifierFlags[ModifierFlags["Readonly"] = 64] = "Readonly"; + ModifierFlags[ModifierFlags["Abstract"] = 128] = "Abstract"; + ModifierFlags[ModifierFlags["Async"] = 256] = "Async"; + ModifierFlags[ModifierFlags["Default"] = 512] = "Default"; + ModifierFlags[ModifierFlags["Const"] = 2048] = "Const"; + ModifierFlags[ModifierFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; + ModifierFlags[ModifierFlags["AccessibilityModifier"] = 28] = "AccessibilityModifier"; + ModifierFlags[ModifierFlags["ParameterPropertyModifier"] = 92] = "ParameterPropertyModifier"; + ModifierFlags[ModifierFlags["NonPublicAccessibilityModifier"] = 24] = "NonPublicAccessibilityModifier"; + ModifierFlags[ModifierFlags["TypeScriptModifier"] = 2270] = "TypeScriptModifier"; + })(ts.ModifierFlags || (ts.ModifierFlags = {})); + var ModifierFlags = ts.ModifierFlags; + (function (JsxFlags) { + JsxFlags[JsxFlags["None"] = 0] = "None"; + JsxFlags[JsxFlags["IntrinsicNamedElement"] = 1] = "IntrinsicNamedElement"; + JsxFlags[JsxFlags["IntrinsicIndexedElement"] = 2] = "IntrinsicIndexedElement"; + JsxFlags[JsxFlags["IntrinsicElement"] = 3] = "IntrinsicElement"; + })(ts.JsxFlags || (ts.JsxFlags = {})); + var JsxFlags = ts.JsxFlags; + (function (RelationComparisonResult) { + RelationComparisonResult[RelationComparisonResult["Succeeded"] = 1] = "Succeeded"; + RelationComparisonResult[RelationComparisonResult["Failed"] = 2] = "Failed"; + RelationComparisonResult[RelationComparisonResult["FailedAndReported"] = 3] = "FailedAndReported"; + })(ts.RelationComparisonResult || (ts.RelationComparisonResult = {})); + var RelationComparisonResult = ts.RelationComparisonResult; + (function (GeneratedIdentifierKind) { + GeneratedIdentifierKind[GeneratedIdentifierKind["None"] = 0] = "None"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Auto"] = 1] = "Auto"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Loop"] = 2] = "Loop"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Unique"] = 3] = "Unique"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Node"] = 4] = "Node"; + })(ts.GeneratedIdentifierKind || (ts.GeneratedIdentifierKind = {})); + var GeneratedIdentifierKind = ts.GeneratedIdentifierKind; + (function (FlowFlags) { + FlowFlags[FlowFlags["Unreachable"] = 1] = "Unreachable"; + FlowFlags[FlowFlags["Start"] = 2] = "Start"; + FlowFlags[FlowFlags["BranchLabel"] = 4] = "BranchLabel"; + FlowFlags[FlowFlags["LoopLabel"] = 8] = "LoopLabel"; + FlowFlags[FlowFlags["Assignment"] = 16] = "Assignment"; + FlowFlags[FlowFlags["TrueCondition"] = 32] = "TrueCondition"; + FlowFlags[FlowFlags["FalseCondition"] = 64] = "FalseCondition"; + FlowFlags[FlowFlags["SwitchClause"] = 128] = "SwitchClause"; + FlowFlags[FlowFlags["ArrayMutation"] = 256] = "ArrayMutation"; + FlowFlags[FlowFlags["Referenced"] = 512] = "Referenced"; + FlowFlags[FlowFlags["Shared"] = 1024] = "Shared"; + FlowFlags[FlowFlags["Label"] = 12] = "Label"; + FlowFlags[FlowFlags["Condition"] = 96] = "Condition"; + })(ts.FlowFlags || (ts.FlowFlags = {})); + var FlowFlags = ts.FlowFlags; var OperationCanceledException = (function () { function OperationCanceledException() { } @@ -32,6 +444,38 @@ var ts; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; })(ts.ExitStatus || (ts.ExitStatus = {})); var ExitStatus = ts.ExitStatus; + (function (TypeFormatFlags) { + TypeFormatFlags[TypeFormatFlags["None"] = 0] = "None"; + TypeFormatFlags[TypeFormatFlags["WriteArrayAsGenericType"] = 1] = "WriteArrayAsGenericType"; + TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 2] = "UseTypeOfFunction"; + TypeFormatFlags[TypeFormatFlags["NoTruncation"] = 4] = "NoTruncation"; + TypeFormatFlags[TypeFormatFlags["WriteArrowStyleSignature"] = 8] = "WriteArrowStyleSignature"; + TypeFormatFlags[TypeFormatFlags["WriteOwnNameForAnyLike"] = 16] = "WriteOwnNameForAnyLike"; + TypeFormatFlags[TypeFormatFlags["WriteTypeArgumentsOfSignature"] = 32] = "WriteTypeArgumentsOfSignature"; + TypeFormatFlags[TypeFormatFlags["InElementType"] = 64] = "InElementType"; + TypeFormatFlags[TypeFormatFlags["UseFullyQualifiedType"] = 128] = "UseFullyQualifiedType"; + TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 256] = "InFirstTypeArgument"; + TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 512] = "InTypeAlias"; + TypeFormatFlags[TypeFormatFlags["UseTypeAliasValue"] = 1024] = "UseTypeAliasValue"; + })(ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); + var TypeFormatFlags = ts.TypeFormatFlags; + (function (SymbolFormatFlags) { + SymbolFormatFlags[SymbolFormatFlags["None"] = 0] = "None"; + SymbolFormatFlags[SymbolFormatFlags["WriteTypeParametersOrArguments"] = 1] = "WriteTypeParametersOrArguments"; + SymbolFormatFlags[SymbolFormatFlags["UseOnlyExternalAliasing"] = 2] = "UseOnlyExternalAliasing"; + })(ts.SymbolFormatFlags || (ts.SymbolFormatFlags = {})); + var SymbolFormatFlags = ts.SymbolFormatFlags; + (function (SymbolAccessibility) { + SymbolAccessibility[SymbolAccessibility["Accessible"] = 0] = "Accessible"; + SymbolAccessibility[SymbolAccessibility["NotAccessible"] = 1] = "NotAccessible"; + SymbolAccessibility[SymbolAccessibility["CannotBeNamed"] = 2] = "CannotBeNamed"; + })(ts.SymbolAccessibility || (ts.SymbolAccessibility = {})); + var SymbolAccessibility = ts.SymbolAccessibility; + (function (TypePredicateKind) { + TypePredicateKind[TypePredicateKind["This"] = 0] = "This"; + TypePredicateKind[TypePredicateKind["Identifier"] = 1] = "Identifier"; + })(ts.TypePredicateKind || (ts.TypePredicateKind = {})); + var TypePredicateKind = ts.TypePredicateKind; (function (TypeReferenceSerializationKind) { TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; @@ -46,6 +490,166 @@ var ts; TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 10] = "ObjectType"; })(ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); var TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind; + (function (SymbolFlags) { + SymbolFlags[SymbolFlags["None"] = 0] = "None"; + SymbolFlags[SymbolFlags["FunctionScopedVariable"] = 1] = "FunctionScopedVariable"; + SymbolFlags[SymbolFlags["BlockScopedVariable"] = 2] = "BlockScopedVariable"; + SymbolFlags[SymbolFlags["Property"] = 4] = "Property"; + SymbolFlags[SymbolFlags["EnumMember"] = 8] = "EnumMember"; + SymbolFlags[SymbolFlags["Function"] = 16] = "Function"; + SymbolFlags[SymbolFlags["Class"] = 32] = "Class"; + SymbolFlags[SymbolFlags["Interface"] = 64] = "Interface"; + SymbolFlags[SymbolFlags["ConstEnum"] = 128] = "ConstEnum"; + SymbolFlags[SymbolFlags["RegularEnum"] = 256] = "RegularEnum"; + SymbolFlags[SymbolFlags["ValueModule"] = 512] = "ValueModule"; + SymbolFlags[SymbolFlags["NamespaceModule"] = 1024] = "NamespaceModule"; + SymbolFlags[SymbolFlags["TypeLiteral"] = 2048] = "TypeLiteral"; + SymbolFlags[SymbolFlags["ObjectLiteral"] = 4096] = "ObjectLiteral"; + SymbolFlags[SymbolFlags["Method"] = 8192] = "Method"; + SymbolFlags[SymbolFlags["Constructor"] = 16384] = "Constructor"; + SymbolFlags[SymbolFlags["GetAccessor"] = 32768] = "GetAccessor"; + SymbolFlags[SymbolFlags["SetAccessor"] = 65536] = "SetAccessor"; + SymbolFlags[SymbolFlags["Signature"] = 131072] = "Signature"; + SymbolFlags[SymbolFlags["TypeParameter"] = 262144] = "TypeParameter"; + SymbolFlags[SymbolFlags["TypeAlias"] = 524288] = "TypeAlias"; + SymbolFlags[SymbolFlags["ExportValue"] = 1048576] = "ExportValue"; + SymbolFlags[SymbolFlags["ExportType"] = 2097152] = "ExportType"; + SymbolFlags[SymbolFlags["ExportNamespace"] = 4194304] = "ExportNamespace"; + SymbolFlags[SymbolFlags["Alias"] = 8388608] = "Alias"; + SymbolFlags[SymbolFlags["Instantiated"] = 16777216] = "Instantiated"; + SymbolFlags[SymbolFlags["Merged"] = 33554432] = "Merged"; + SymbolFlags[SymbolFlags["Transient"] = 67108864] = "Transient"; + SymbolFlags[SymbolFlags["Prototype"] = 134217728] = "Prototype"; + SymbolFlags[SymbolFlags["SyntheticProperty"] = 268435456] = "SyntheticProperty"; + SymbolFlags[SymbolFlags["Optional"] = 536870912] = "Optional"; + SymbolFlags[SymbolFlags["ExportStar"] = 1073741824] = "ExportStar"; + SymbolFlags[SymbolFlags["Enum"] = 384] = "Enum"; + SymbolFlags[SymbolFlags["Variable"] = 3] = "Variable"; + SymbolFlags[SymbolFlags["Value"] = 107455] = "Value"; + SymbolFlags[SymbolFlags["Type"] = 793064] = "Type"; + SymbolFlags[SymbolFlags["Namespace"] = 1920] = "Namespace"; + SymbolFlags[SymbolFlags["Module"] = 1536] = "Module"; + SymbolFlags[SymbolFlags["Accessor"] = 98304] = "Accessor"; + SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 107454] = "FunctionScopedVariableExcludes"; + SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 107455] = "BlockScopedVariableExcludes"; + SymbolFlags[SymbolFlags["ParameterExcludes"] = 107455] = "ParameterExcludes"; + SymbolFlags[SymbolFlags["PropertyExcludes"] = 0] = "PropertyExcludes"; + SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 900095] = "EnumMemberExcludes"; + SymbolFlags[SymbolFlags["FunctionExcludes"] = 106927] = "FunctionExcludes"; + SymbolFlags[SymbolFlags["ClassExcludes"] = 899519] = "ClassExcludes"; + SymbolFlags[SymbolFlags["InterfaceExcludes"] = 792968] = "InterfaceExcludes"; + SymbolFlags[SymbolFlags["RegularEnumExcludes"] = 899327] = "RegularEnumExcludes"; + SymbolFlags[SymbolFlags["ConstEnumExcludes"] = 899967] = "ConstEnumExcludes"; + SymbolFlags[SymbolFlags["ValueModuleExcludes"] = 106639] = "ValueModuleExcludes"; + SymbolFlags[SymbolFlags["NamespaceModuleExcludes"] = 0] = "NamespaceModuleExcludes"; + SymbolFlags[SymbolFlags["MethodExcludes"] = 99263] = "MethodExcludes"; + SymbolFlags[SymbolFlags["GetAccessorExcludes"] = 41919] = "GetAccessorExcludes"; + SymbolFlags[SymbolFlags["SetAccessorExcludes"] = 74687] = "SetAccessorExcludes"; + SymbolFlags[SymbolFlags["TypeParameterExcludes"] = 530920] = "TypeParameterExcludes"; + SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 793064] = "TypeAliasExcludes"; + SymbolFlags[SymbolFlags["AliasExcludes"] = 8388608] = "AliasExcludes"; + SymbolFlags[SymbolFlags["ModuleMember"] = 8914931] = "ModuleMember"; + SymbolFlags[SymbolFlags["ExportHasLocal"] = 944] = "ExportHasLocal"; + SymbolFlags[SymbolFlags["HasExports"] = 1952] = "HasExports"; + SymbolFlags[SymbolFlags["HasMembers"] = 6240] = "HasMembers"; + SymbolFlags[SymbolFlags["BlockScoped"] = 418] = "BlockScoped"; + SymbolFlags[SymbolFlags["PropertyOrAccessor"] = 98308] = "PropertyOrAccessor"; + SymbolFlags[SymbolFlags["Export"] = 7340032] = "Export"; + SymbolFlags[SymbolFlags["ClassMember"] = 106500] = "ClassMember"; + SymbolFlags[SymbolFlags["Classifiable"] = 788448] = "Classifiable"; + })(ts.SymbolFlags || (ts.SymbolFlags = {})); + var SymbolFlags = ts.SymbolFlags; + (function (NodeCheckFlags) { + NodeCheckFlags[NodeCheckFlags["TypeChecked"] = 1] = "TypeChecked"; + NodeCheckFlags[NodeCheckFlags["LexicalThis"] = 2] = "LexicalThis"; + NodeCheckFlags[NodeCheckFlags["CaptureThis"] = 4] = "CaptureThis"; + NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 256] = "SuperInstance"; + NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 512] = "SuperStatic"; + NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 1024] = "ContextChecked"; + NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuper"] = 2048] = "AsyncMethodWithSuper"; + NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuperBinding"] = 4096] = "AsyncMethodWithSuperBinding"; + NodeCheckFlags[NodeCheckFlags["CaptureArguments"] = 8192] = "CaptureArguments"; + NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 16384] = "EnumValuesComputed"; + NodeCheckFlags[NodeCheckFlags["LexicalModuleMergesWithClass"] = 32768] = "LexicalModuleMergesWithClass"; + NodeCheckFlags[NodeCheckFlags["LoopWithCapturedBlockScopedBinding"] = 65536] = "LoopWithCapturedBlockScopedBinding"; + NodeCheckFlags[NodeCheckFlags["CapturedBlockScopedBinding"] = 131072] = "CapturedBlockScopedBinding"; + NodeCheckFlags[NodeCheckFlags["BlockScopedBindingInLoop"] = 262144] = "BlockScopedBindingInLoop"; + NodeCheckFlags[NodeCheckFlags["ClassWithBodyScopedClassBinding"] = 524288] = "ClassWithBodyScopedClassBinding"; + NodeCheckFlags[NodeCheckFlags["BodyScopedClassBinding"] = 1048576] = "BodyScopedClassBinding"; + NodeCheckFlags[NodeCheckFlags["NeedsLoopOutParameter"] = 2097152] = "NeedsLoopOutParameter"; + NodeCheckFlags[NodeCheckFlags["AssignmentsMarked"] = 4194304] = "AssignmentsMarked"; + NodeCheckFlags[NodeCheckFlags["ClassWithConstructorReference"] = 8388608] = "ClassWithConstructorReference"; + NodeCheckFlags[NodeCheckFlags["ConstructorReferenceInClass"] = 16777216] = "ConstructorReferenceInClass"; + })(ts.NodeCheckFlags || (ts.NodeCheckFlags = {})); + var NodeCheckFlags = ts.NodeCheckFlags; + (function (TypeFlags) { + TypeFlags[TypeFlags["Any"] = 1] = "Any"; + TypeFlags[TypeFlags["String"] = 2] = "String"; + TypeFlags[TypeFlags["Number"] = 4] = "Number"; + TypeFlags[TypeFlags["Boolean"] = 8] = "Boolean"; + TypeFlags[TypeFlags["Enum"] = 16] = "Enum"; + TypeFlags[TypeFlags["StringLiteral"] = 32] = "StringLiteral"; + TypeFlags[TypeFlags["NumberLiteral"] = 64] = "NumberLiteral"; + TypeFlags[TypeFlags["BooleanLiteral"] = 128] = "BooleanLiteral"; + TypeFlags[TypeFlags["EnumLiteral"] = 256] = "EnumLiteral"; + TypeFlags[TypeFlags["ESSymbol"] = 512] = "ESSymbol"; + TypeFlags[TypeFlags["Void"] = 1024] = "Void"; + TypeFlags[TypeFlags["Undefined"] = 2048] = "Undefined"; + TypeFlags[TypeFlags["Null"] = 4096] = "Null"; + TypeFlags[TypeFlags["Never"] = 8192] = "Never"; + TypeFlags[TypeFlags["TypeParameter"] = 16384] = "TypeParameter"; + TypeFlags[TypeFlags["Class"] = 32768] = "Class"; + TypeFlags[TypeFlags["Interface"] = 65536] = "Interface"; + TypeFlags[TypeFlags["Reference"] = 131072] = "Reference"; + TypeFlags[TypeFlags["Tuple"] = 262144] = "Tuple"; + TypeFlags[TypeFlags["Union"] = 524288] = "Union"; + TypeFlags[TypeFlags["Intersection"] = 1048576] = "Intersection"; + TypeFlags[TypeFlags["Anonymous"] = 2097152] = "Anonymous"; + TypeFlags[TypeFlags["Instantiated"] = 4194304] = "Instantiated"; + TypeFlags[TypeFlags["ObjectLiteral"] = 8388608] = "ObjectLiteral"; + TypeFlags[TypeFlags["FreshLiteral"] = 16777216] = "FreshLiteral"; + TypeFlags[TypeFlags["ContainsWideningType"] = 33554432] = "ContainsWideningType"; + TypeFlags[TypeFlags["ContainsObjectLiteral"] = 67108864] = "ContainsObjectLiteral"; + TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 134217728] = "ContainsAnyFunctionType"; + TypeFlags[TypeFlags["Nullable"] = 6144] = "Nullable"; + TypeFlags[TypeFlags["Literal"] = 480] = "Literal"; + TypeFlags[TypeFlags["StringOrNumberLiteral"] = 96] = "StringOrNumberLiteral"; + TypeFlags[TypeFlags["DefinitelyFalsy"] = 7392] = "DefinitelyFalsy"; + TypeFlags[TypeFlags["PossiblyFalsy"] = 7406] = "PossiblyFalsy"; + TypeFlags[TypeFlags["Intrinsic"] = 16015] = "Intrinsic"; + TypeFlags[TypeFlags["Primitive"] = 8190] = "Primitive"; + TypeFlags[TypeFlags["StringLike"] = 34] = "StringLike"; + TypeFlags[TypeFlags["NumberLike"] = 340] = "NumberLike"; + TypeFlags[TypeFlags["BooleanLike"] = 136] = "BooleanLike"; + TypeFlags[TypeFlags["EnumLike"] = 272] = "EnumLike"; + TypeFlags[TypeFlags["ObjectType"] = 2588672] = "ObjectType"; + TypeFlags[TypeFlags["UnionOrIntersection"] = 1572864] = "UnionOrIntersection"; + TypeFlags[TypeFlags["StructuredType"] = 4161536] = "StructuredType"; + TypeFlags[TypeFlags["StructuredOrTypeParameter"] = 4177920] = "StructuredOrTypeParameter"; + TypeFlags[TypeFlags["Narrowable"] = 4178943] = "Narrowable"; + TypeFlags[TypeFlags["NotUnionOrUnit"] = 2589185] = "NotUnionOrUnit"; + TypeFlags[TypeFlags["RequiresWidening"] = 100663296] = "RequiresWidening"; + TypeFlags[TypeFlags["PropagatingFlags"] = 234881024] = "PropagatingFlags"; + })(ts.TypeFlags || (ts.TypeFlags = {})); + var TypeFlags = ts.TypeFlags; + (function (SignatureKind) { + SignatureKind[SignatureKind["Call"] = 0] = "Call"; + SignatureKind[SignatureKind["Construct"] = 1] = "Construct"; + })(ts.SignatureKind || (ts.SignatureKind = {})); + var SignatureKind = ts.SignatureKind; + (function (IndexKind) { + IndexKind[IndexKind["String"] = 0] = "String"; + IndexKind[IndexKind["Number"] = 1] = "Number"; + })(ts.IndexKind || (ts.IndexKind = {})); + var IndexKind = ts.IndexKind; + (function (SpecialPropertyAssignmentKind) { + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["None"] = 0] = "None"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ExportsProperty"] = 1] = "ExportsProperty"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ModuleExports"] = 2] = "ModuleExports"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["PrototypeProperty"] = 3] = "PrototypeProperty"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ThisProperty"] = 4] = "ThisProperty"; + })(ts.SpecialPropertyAssignmentKind || (ts.SpecialPropertyAssignmentKind = {})); + var SpecialPropertyAssignmentKind = ts.SpecialPropertyAssignmentKind; (function (DiagnosticCategory) { DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; @@ -63,10 +667,267 @@ var ts; ModuleKind[ModuleKind["AMD"] = 2] = "AMD"; ModuleKind[ModuleKind["UMD"] = 3] = "UMD"; ModuleKind[ModuleKind["System"] = 4] = "System"; - ModuleKind[ModuleKind["ES6"] = 5] = "ES6"; ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015"; })(ts.ModuleKind || (ts.ModuleKind = {})); var ModuleKind = ts.ModuleKind; + (function (JsxEmit) { + JsxEmit[JsxEmit["None"] = 0] = "None"; + JsxEmit[JsxEmit["Preserve"] = 1] = "Preserve"; + JsxEmit[JsxEmit["React"] = 2] = "React"; + })(ts.JsxEmit || (ts.JsxEmit = {})); + var JsxEmit = ts.JsxEmit; + (function (NewLineKind) { + NewLineKind[NewLineKind["CarriageReturnLineFeed"] = 0] = "CarriageReturnLineFeed"; + NewLineKind[NewLineKind["LineFeed"] = 1] = "LineFeed"; + })(ts.NewLineKind || (ts.NewLineKind = {})); + var NewLineKind = ts.NewLineKind; + (function (ScriptKind) { + ScriptKind[ScriptKind["Unknown"] = 0] = "Unknown"; + ScriptKind[ScriptKind["JS"] = 1] = "JS"; + ScriptKind[ScriptKind["JSX"] = 2] = "JSX"; + ScriptKind[ScriptKind["TS"] = 3] = "TS"; + ScriptKind[ScriptKind["TSX"] = 4] = "TSX"; + })(ts.ScriptKind || (ts.ScriptKind = {})); + var ScriptKind = ts.ScriptKind; + (function (ScriptTarget) { + ScriptTarget[ScriptTarget["ES3"] = 0] = "ES3"; + ScriptTarget[ScriptTarget["ES5"] = 1] = "ES5"; + ScriptTarget[ScriptTarget["ES2015"] = 2] = "ES2015"; + ScriptTarget[ScriptTarget["ES2016"] = 3] = "ES2016"; + ScriptTarget[ScriptTarget["ES2017"] = 4] = "ES2017"; + ScriptTarget[ScriptTarget["Latest"] = 4] = "Latest"; + })(ts.ScriptTarget || (ts.ScriptTarget = {})); + var ScriptTarget = ts.ScriptTarget; + (function (LanguageVariant) { + LanguageVariant[LanguageVariant["Standard"] = 0] = "Standard"; + LanguageVariant[LanguageVariant["JSX"] = 1] = "JSX"; + })(ts.LanguageVariant || (ts.LanguageVariant = {})); + var LanguageVariant = ts.LanguageVariant; + (function (DiagnosticStyle) { + DiagnosticStyle[DiagnosticStyle["Simple"] = 0] = "Simple"; + DiagnosticStyle[DiagnosticStyle["Pretty"] = 1] = "Pretty"; + })(ts.DiagnosticStyle || (ts.DiagnosticStyle = {})); + var DiagnosticStyle = ts.DiagnosticStyle; + (function (WatchDirectoryFlags) { + WatchDirectoryFlags[WatchDirectoryFlags["None"] = 0] = "None"; + WatchDirectoryFlags[WatchDirectoryFlags["Recursive"] = 1] = "Recursive"; + })(ts.WatchDirectoryFlags || (ts.WatchDirectoryFlags = {})); + var WatchDirectoryFlags = ts.WatchDirectoryFlags; + (function (CharacterCodes) { + CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; + CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 127] = "maxAsciiCharacter"; + CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed"; + CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn"; + CharacterCodes[CharacterCodes["lineSeparator"] = 8232] = "lineSeparator"; + CharacterCodes[CharacterCodes["paragraphSeparator"] = 8233] = "paragraphSeparator"; + CharacterCodes[CharacterCodes["nextLine"] = 133] = "nextLine"; + CharacterCodes[CharacterCodes["space"] = 32] = "space"; + CharacterCodes[CharacterCodes["nonBreakingSpace"] = 160] = "nonBreakingSpace"; + CharacterCodes[CharacterCodes["enQuad"] = 8192] = "enQuad"; + CharacterCodes[CharacterCodes["emQuad"] = 8193] = "emQuad"; + CharacterCodes[CharacterCodes["enSpace"] = 8194] = "enSpace"; + CharacterCodes[CharacterCodes["emSpace"] = 8195] = "emSpace"; + CharacterCodes[CharacterCodes["threePerEmSpace"] = 8196] = "threePerEmSpace"; + CharacterCodes[CharacterCodes["fourPerEmSpace"] = 8197] = "fourPerEmSpace"; + CharacterCodes[CharacterCodes["sixPerEmSpace"] = 8198] = "sixPerEmSpace"; + CharacterCodes[CharacterCodes["figureSpace"] = 8199] = "figureSpace"; + CharacterCodes[CharacterCodes["punctuationSpace"] = 8200] = "punctuationSpace"; + CharacterCodes[CharacterCodes["thinSpace"] = 8201] = "thinSpace"; + CharacterCodes[CharacterCodes["hairSpace"] = 8202] = "hairSpace"; + CharacterCodes[CharacterCodes["zeroWidthSpace"] = 8203] = "zeroWidthSpace"; + CharacterCodes[CharacterCodes["narrowNoBreakSpace"] = 8239] = "narrowNoBreakSpace"; + CharacterCodes[CharacterCodes["ideographicSpace"] = 12288] = "ideographicSpace"; + CharacterCodes[CharacterCodes["mathematicalSpace"] = 8287] = "mathematicalSpace"; + CharacterCodes[CharacterCodes["ogham"] = 5760] = "ogham"; + CharacterCodes[CharacterCodes["_"] = 95] = "_"; + CharacterCodes[CharacterCodes["$"] = 36] = "$"; + CharacterCodes[CharacterCodes["_0"] = 48] = "_0"; + CharacterCodes[CharacterCodes["_1"] = 49] = "_1"; + CharacterCodes[CharacterCodes["_2"] = 50] = "_2"; + CharacterCodes[CharacterCodes["_3"] = 51] = "_3"; + CharacterCodes[CharacterCodes["_4"] = 52] = "_4"; + CharacterCodes[CharacterCodes["_5"] = 53] = "_5"; + CharacterCodes[CharacterCodes["_6"] = 54] = "_6"; + CharacterCodes[CharacterCodes["_7"] = 55] = "_7"; + CharacterCodes[CharacterCodes["_8"] = 56] = "_8"; + CharacterCodes[CharacterCodes["_9"] = 57] = "_9"; + CharacterCodes[CharacterCodes["a"] = 97] = "a"; + CharacterCodes[CharacterCodes["b"] = 98] = "b"; + CharacterCodes[CharacterCodes["c"] = 99] = "c"; + CharacterCodes[CharacterCodes["d"] = 100] = "d"; + CharacterCodes[CharacterCodes["e"] = 101] = "e"; + CharacterCodes[CharacterCodes["f"] = 102] = "f"; + CharacterCodes[CharacterCodes["g"] = 103] = "g"; + CharacterCodes[CharacterCodes["h"] = 104] = "h"; + CharacterCodes[CharacterCodes["i"] = 105] = "i"; + CharacterCodes[CharacterCodes["j"] = 106] = "j"; + CharacterCodes[CharacterCodes["k"] = 107] = "k"; + CharacterCodes[CharacterCodes["l"] = 108] = "l"; + CharacterCodes[CharacterCodes["m"] = 109] = "m"; + CharacterCodes[CharacterCodes["n"] = 110] = "n"; + CharacterCodes[CharacterCodes["o"] = 111] = "o"; + CharacterCodes[CharacterCodes["p"] = 112] = "p"; + CharacterCodes[CharacterCodes["q"] = 113] = "q"; + CharacterCodes[CharacterCodes["r"] = 114] = "r"; + CharacterCodes[CharacterCodes["s"] = 115] = "s"; + CharacterCodes[CharacterCodes["t"] = 116] = "t"; + CharacterCodes[CharacterCodes["u"] = 117] = "u"; + CharacterCodes[CharacterCodes["v"] = 118] = "v"; + CharacterCodes[CharacterCodes["w"] = 119] = "w"; + CharacterCodes[CharacterCodes["x"] = 120] = "x"; + CharacterCodes[CharacterCodes["y"] = 121] = "y"; + CharacterCodes[CharacterCodes["z"] = 122] = "z"; + CharacterCodes[CharacterCodes["A"] = 65] = "A"; + CharacterCodes[CharacterCodes["B"] = 66] = "B"; + CharacterCodes[CharacterCodes["C"] = 67] = "C"; + CharacterCodes[CharacterCodes["D"] = 68] = "D"; + CharacterCodes[CharacterCodes["E"] = 69] = "E"; + CharacterCodes[CharacterCodes["F"] = 70] = "F"; + CharacterCodes[CharacterCodes["G"] = 71] = "G"; + CharacterCodes[CharacterCodes["H"] = 72] = "H"; + CharacterCodes[CharacterCodes["I"] = 73] = "I"; + CharacterCodes[CharacterCodes["J"] = 74] = "J"; + CharacterCodes[CharacterCodes["K"] = 75] = "K"; + CharacterCodes[CharacterCodes["L"] = 76] = "L"; + CharacterCodes[CharacterCodes["M"] = 77] = "M"; + CharacterCodes[CharacterCodes["N"] = 78] = "N"; + CharacterCodes[CharacterCodes["O"] = 79] = "O"; + CharacterCodes[CharacterCodes["P"] = 80] = "P"; + CharacterCodes[CharacterCodes["Q"] = 81] = "Q"; + CharacterCodes[CharacterCodes["R"] = 82] = "R"; + CharacterCodes[CharacterCodes["S"] = 83] = "S"; + CharacterCodes[CharacterCodes["T"] = 84] = "T"; + CharacterCodes[CharacterCodes["U"] = 85] = "U"; + CharacterCodes[CharacterCodes["V"] = 86] = "V"; + CharacterCodes[CharacterCodes["W"] = 87] = "W"; + CharacterCodes[CharacterCodes["X"] = 88] = "X"; + CharacterCodes[CharacterCodes["Y"] = 89] = "Y"; + CharacterCodes[CharacterCodes["Z"] = 90] = "Z"; + CharacterCodes[CharacterCodes["ampersand"] = 38] = "ampersand"; + CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk"; + CharacterCodes[CharacterCodes["at"] = 64] = "at"; + CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash"; + CharacterCodes[CharacterCodes["backtick"] = 96] = "backtick"; + CharacterCodes[CharacterCodes["bar"] = 124] = "bar"; + CharacterCodes[CharacterCodes["caret"] = 94] = "caret"; + CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace"; + CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket"; + CharacterCodes[CharacterCodes["closeParen"] = 41] = "closeParen"; + CharacterCodes[CharacterCodes["colon"] = 58] = "colon"; + CharacterCodes[CharacterCodes["comma"] = 44] = "comma"; + CharacterCodes[CharacterCodes["dot"] = 46] = "dot"; + CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote"; + CharacterCodes[CharacterCodes["equals"] = 61] = "equals"; + CharacterCodes[CharacterCodes["exclamation"] = 33] = "exclamation"; + CharacterCodes[CharacterCodes["greaterThan"] = 62] = "greaterThan"; + CharacterCodes[CharacterCodes["hash"] = 35] = "hash"; + CharacterCodes[CharacterCodes["lessThan"] = 60] = "lessThan"; + CharacterCodes[CharacterCodes["minus"] = 45] = "minus"; + CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace"; + CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket"; + CharacterCodes[CharacterCodes["openParen"] = 40] = "openParen"; + CharacterCodes[CharacterCodes["percent"] = 37] = "percent"; + CharacterCodes[CharacterCodes["plus"] = 43] = "plus"; + CharacterCodes[CharacterCodes["question"] = 63] = "question"; + CharacterCodes[CharacterCodes["semicolon"] = 59] = "semicolon"; + CharacterCodes[CharacterCodes["singleQuote"] = 39] = "singleQuote"; + CharacterCodes[CharacterCodes["slash"] = 47] = "slash"; + CharacterCodes[CharacterCodes["tilde"] = 126] = "tilde"; + CharacterCodes[CharacterCodes["backspace"] = 8] = "backspace"; + CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed"; + CharacterCodes[CharacterCodes["byteOrderMark"] = 65279] = "byteOrderMark"; + CharacterCodes[CharacterCodes["tab"] = 9] = "tab"; + CharacterCodes[CharacterCodes["verticalTab"] = 11] = "verticalTab"; + })(ts.CharacterCodes || (ts.CharacterCodes = {})); + var CharacterCodes = ts.CharacterCodes; + (function (TransformFlags) { + TransformFlags[TransformFlags["None"] = 0] = "None"; + TransformFlags[TransformFlags["TypeScript"] = 1] = "TypeScript"; + TransformFlags[TransformFlags["ContainsTypeScript"] = 2] = "ContainsTypeScript"; + TransformFlags[TransformFlags["Jsx"] = 4] = "Jsx"; + TransformFlags[TransformFlags["ContainsJsx"] = 8] = "ContainsJsx"; + TransformFlags[TransformFlags["ES2017"] = 16] = "ES2017"; + TransformFlags[TransformFlags["ContainsES2017"] = 32] = "ContainsES2017"; + TransformFlags[TransformFlags["ES2016"] = 64] = "ES2016"; + TransformFlags[TransformFlags["ContainsES2016"] = 128] = "ContainsES2016"; + TransformFlags[TransformFlags["ES2015"] = 256] = "ES2015"; + TransformFlags[TransformFlags["ContainsES2015"] = 512] = "ContainsES2015"; + TransformFlags[TransformFlags["DestructuringAssignment"] = 1024] = "DestructuringAssignment"; + TransformFlags[TransformFlags["Generator"] = 2048] = "Generator"; + TransformFlags[TransformFlags["ContainsGenerator"] = 4096] = "ContainsGenerator"; + TransformFlags[TransformFlags["ContainsDecorators"] = 8192] = "ContainsDecorators"; + TransformFlags[TransformFlags["ContainsPropertyInitializer"] = 16384] = "ContainsPropertyInitializer"; + TransformFlags[TransformFlags["ContainsLexicalThis"] = 32768] = "ContainsLexicalThis"; + TransformFlags[TransformFlags["ContainsCapturedLexicalThis"] = 65536] = "ContainsCapturedLexicalThis"; + TransformFlags[TransformFlags["ContainsLexicalThisInComputedPropertyName"] = 131072] = "ContainsLexicalThisInComputedPropertyName"; + TransformFlags[TransformFlags["ContainsDefaultValueAssignments"] = 262144] = "ContainsDefaultValueAssignments"; + TransformFlags[TransformFlags["ContainsParameterPropertyAssignments"] = 524288] = "ContainsParameterPropertyAssignments"; + TransformFlags[TransformFlags["ContainsSpreadElementExpression"] = 1048576] = "ContainsSpreadElementExpression"; + TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 2097152] = "ContainsComputedPropertyName"; + TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 4194304] = "ContainsBlockScopedBinding"; + TransformFlags[TransformFlags["ContainsBindingPattern"] = 8388608] = "ContainsBindingPattern"; + TransformFlags[TransformFlags["ContainsYield"] = 16777216] = "ContainsYield"; + TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 33554432] = "ContainsHoistedDeclarationOrCompletion"; + TransformFlags[TransformFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; + TransformFlags[TransformFlags["AssertTypeScript"] = 3] = "AssertTypeScript"; + TransformFlags[TransformFlags["AssertJsx"] = 12] = "AssertJsx"; + TransformFlags[TransformFlags["AssertES2017"] = 48] = "AssertES2017"; + TransformFlags[TransformFlags["AssertES2016"] = 192] = "AssertES2016"; + TransformFlags[TransformFlags["AssertES2015"] = 768] = "AssertES2015"; + TransformFlags[TransformFlags["AssertGenerator"] = 6144] = "AssertGenerator"; + TransformFlags[TransformFlags["NodeExcludes"] = 536874325] = "NodeExcludes"; + TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 592227669] = "ArrowFunctionExcludes"; + TransformFlags[TransformFlags["FunctionExcludes"] = 592293205] = "FunctionExcludes"; + TransformFlags[TransformFlags["ConstructorExcludes"] = 591760725] = "ConstructorExcludes"; + TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 591760725] = "MethodOrAccessorExcludes"; + TransformFlags[TransformFlags["ClassExcludes"] = 539749717] = "ClassExcludes"; + TransformFlags[TransformFlags["ModuleExcludes"] = 574729557] = "ModuleExcludes"; + TransformFlags[TransformFlags["TypeExcludes"] = -3] = "TypeExcludes"; + TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 539110741] = "ObjectLiteralExcludes"; + TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 537922901] = "ArrayLiteralOrCallOrNewExcludes"; + TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 545262933] = "VariableDeclarationListExcludes"; + TransformFlags[TransformFlags["ParameterExcludes"] = 545262933] = "ParameterExcludes"; + TransformFlags[TransformFlags["TypeScriptClassSyntaxMask"] = 548864] = "TypeScriptClassSyntaxMask"; + TransformFlags[TransformFlags["ES2015FunctionSyntaxMask"] = 327680] = "ES2015FunctionSyntaxMask"; + })(ts.TransformFlags || (ts.TransformFlags = {})); + var TransformFlags = ts.TransformFlags; + (function (EmitFlags) { + EmitFlags[EmitFlags["EmitEmitHelpers"] = 1] = "EmitEmitHelpers"; + EmitFlags[EmitFlags["EmitExportStar"] = 2] = "EmitExportStar"; + EmitFlags[EmitFlags["EmitSuperHelper"] = 4] = "EmitSuperHelper"; + EmitFlags[EmitFlags["EmitAdvancedSuperHelper"] = 8] = "EmitAdvancedSuperHelper"; + EmitFlags[EmitFlags["UMDDefine"] = 16] = "UMDDefine"; + EmitFlags[EmitFlags["SingleLine"] = 32] = "SingleLine"; + EmitFlags[EmitFlags["AdviseOnEmitNode"] = 64] = "AdviseOnEmitNode"; + EmitFlags[EmitFlags["NoSubstitution"] = 128] = "NoSubstitution"; + EmitFlags[EmitFlags["CapturesThis"] = 256] = "CapturesThis"; + EmitFlags[EmitFlags["NoLeadingSourceMap"] = 512] = "NoLeadingSourceMap"; + EmitFlags[EmitFlags["NoTrailingSourceMap"] = 1024] = "NoTrailingSourceMap"; + EmitFlags[EmitFlags["NoSourceMap"] = 1536] = "NoSourceMap"; + EmitFlags[EmitFlags["NoNestedSourceMaps"] = 2048] = "NoNestedSourceMaps"; + EmitFlags[EmitFlags["NoTokenLeadingSourceMaps"] = 4096] = "NoTokenLeadingSourceMaps"; + EmitFlags[EmitFlags["NoTokenTrailingSourceMaps"] = 8192] = "NoTokenTrailingSourceMaps"; + EmitFlags[EmitFlags["NoTokenSourceMaps"] = 12288] = "NoTokenSourceMaps"; + EmitFlags[EmitFlags["NoLeadingComments"] = 16384] = "NoLeadingComments"; + EmitFlags[EmitFlags["NoTrailingComments"] = 32768] = "NoTrailingComments"; + EmitFlags[EmitFlags["NoComments"] = 49152] = "NoComments"; + EmitFlags[EmitFlags["NoNestedComments"] = 65536] = "NoNestedComments"; + EmitFlags[EmitFlags["ExportName"] = 131072] = "ExportName"; + EmitFlags[EmitFlags["LocalName"] = 262144] = "LocalName"; + EmitFlags[EmitFlags["Indented"] = 524288] = "Indented"; + EmitFlags[EmitFlags["NoIndentation"] = 1048576] = "NoIndentation"; + EmitFlags[EmitFlags["AsyncFunctionBody"] = 2097152] = "AsyncFunctionBody"; + EmitFlags[EmitFlags["ReuseTempVariableScope"] = 4194304] = "ReuseTempVariableScope"; + EmitFlags[EmitFlags["CustomPrologue"] = 8388608] = "CustomPrologue"; + })(ts.EmitFlags || (ts.EmitFlags = {})); + var EmitFlags = ts.EmitFlags; + (function (EmitContext) { + EmitContext[EmitContext["SourceFile"] = 0] = "SourceFile"; + EmitContext[EmitContext["Expression"] = 1] = "Expression"; + EmitContext[EmitContext["IdentifierName"] = 2] = "IdentifierName"; + EmitContext[EmitContext["Unspecified"] = 3] = "Unspecified"; + })(ts.EmitContext || (ts.EmitContext = {})); + var EmitContext = ts.EmitContext; })(ts || (ts = {})); var ts; (function (ts) { @@ -77,7 +938,7 @@ var ts; (function (performance) { var profilerEvent = typeof onProfilerEvent === "function" && onProfilerEvent.profiler === true ? onProfilerEvent - : function (markName) { }; + : function (_markName) { }; var enabled = false; var profilerStart = 0; var counts; @@ -129,7 +990,14 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + (function (Ternary) { + Ternary[Ternary["False"] = 0] = "False"; + Ternary[Ternary["Maybe"] = 1] = "Maybe"; + Ternary[Ternary["True"] = -1] = "True"; + })(ts.Ternary || (ts.Ternary = {})); + var Ternary = ts.Ternary; var createObject = Object.create; + ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; function createMap(template) { var map = createObject(null); map["__"] = undefined; @@ -150,7 +1018,7 @@ var ts; remove: remove, forEachValue: forEachValueInMap, getKeys: getKeys, - clear: clear + clear: clear, }; function forEachValueInMap(f) { for (var key in files) { @@ -192,6 +1060,12 @@ var ts; return getCanonicalFileName(nonCanonicalizedPath); } ts.toPath = toPath; + (function (Comparison) { + Comparison[Comparison["LessThan"] = -1] = "LessThan"; + Comparison[Comparison["EqualTo"] = 0] = "EqualTo"; + Comparison[Comparison["GreaterThan"] = 1] = "GreaterThan"; + })(ts.Comparison || (ts.Comparison = {})); + var Comparison = ts.Comparison; function forEach(array, callback) { if (array) { for (var i = 0, len = array.length; i < len; i++) { @@ -335,13 +1209,32 @@ var ts; if (array) { result = []; for (var i = 0; i < array.length; i++) { - var v = array[i]; - result.push(f(v, i)); + result.push(f(array[i], i)); } } return result; } ts.map = map; + function sameMap(array, f) { + var result; + if (array) { + for (var i = 0; i < array.length; i++) { + if (result) { + result.push(f(array[i], i)); + } + else { + var item = array[i]; + var mapped = f(item, i); + if (item !== mapped) { + result = array.slice(0, i); + result.push(mapped); + } + } + } + } + return result || array; + } + ts.sameMap = sameMap; function flatten(array) { var result; if (array) { @@ -442,6 +1335,18 @@ var ts; return result; } ts.mapObject = mapObject; + function some(array, predicate) { + if (array) { + for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { + var v = array_5[_i]; + if (!predicate || predicate(v)) { + return true; + } + } + } + return false; + } + ts.some = some; function concatenate(array1, array2) { if (!array2 || !array2.length) return array1; @@ -454,8 +1359,8 @@ var ts; var result; if (array) { result = []; - loop: for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { - var item = array_5[_i]; + loop: for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { + var item = array_6[_i]; for (var _a = 0, result_1 = result; _a < result_1.length; _a++) { var res = result_1[_a]; if (areEqual ? areEqual(res, item) : res === item) { @@ -488,8 +1393,8 @@ var ts; ts.compact = compact; function sum(array, prop) { var result = 0; - for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { - var v = array_6[_i]; + for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { + var v = array_7[_i]; result += v[prop]; } return result; @@ -708,8 +1613,8 @@ var ts; ts.equalOwnProperties = equalOwnProperties; function arrayToMap(array, makeKey, makeValue) { var result = createMap(); - for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { - var value = array_7[_i]; + for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { + var value = array_8[_i]; result[makeKey(value)] = makeValue ? makeValue(value) : value; } return result; @@ -810,7 +1715,7 @@ var ts; return function (t) { return compose(a(t)); }; } else { - return function (t) { return function (u) { return u; }; }; + return function (_) { return function (u) { return u; }; }; } } ts.chain = chain; @@ -841,7 +1746,7 @@ var ts; ts.compose = compose; function formatStringFromArgs(text, args, baseIndex) { baseIndex = baseIndex || 0; - return text.replace(/{(\d+)}/g, function (match, index) { return args[+index + baseIndex]; }); + return text.replace(/{(\d+)}/g, function (_match, index) { return args[+index + baseIndex]; }); } ts.localizedDiagnosticMessages = undefined; function getLocaleSpecificMessage(message) { @@ -866,11 +1771,11 @@ var ts; length: length, messageText: text, category: message.category, - code: message.code + code: message.code, }; } ts.createFileDiagnostic = createFileDiagnostic; - function formatMessage(dummy, message) { + function formatMessage(_dummy, message) { var text = getLocaleSpecificMessage(message); if (arguments.length > 2) { text = formatStringFromArgs(text, arguments, 2); @@ -933,7 +1838,7 @@ var ts; if (b === undefined) return 1; if (ignoreCase) { - if (String.prototype.localeCompare) { + if (ts.collator && String.prototype.localeCompare) { var result = a.localeCompare(b, undefined, { usage: "sort", sensitivity: "accent" }); return result < 0 ? -1 : result > 0 ? 1 : 0; } @@ -1086,7 +1991,7 @@ var ts; function getEmitModuleKind(compilerOptions) { return typeof compilerOptions.module === "number" ? compilerOptions.module : - getEmitScriptTarget(compilerOptions) === 2 ? ts.ModuleKind.ES6 : ts.ModuleKind.CommonJS; + getEmitScriptTarget(compilerOptions) >= 2 ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS; } ts.getEmitModuleKind = getEmitModuleKind; function hasZeroOrOneAsteriskCharacter(str) { @@ -1383,7 +2288,7 @@ var ts; function replaceWildcardCharacter(match, singleAsteriskRegexFragment) { return match === "*" ? singleAsteriskRegexFragment : match === "?" ? "[^/]" : "\\" + match; } - function getFileMatcherPatterns(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory) { + function getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory) { path = normalizePath(path); currentDirectory = normalizePath(currentDirectory); var absolutePath = combinePaths(currentDirectory, path); @@ -1398,7 +2303,7 @@ var ts; function matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, getFileSystemEntries) { path = normalizePath(path); currentDirectory = normalizePath(currentDirectory); - var patterns = getFileMatcherPatterns(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory); + var patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory); var regexFlag = useCaseSensitiveFileNames ? "" : "i"; var includeFileRegex = patterns.includeFilePattern && new RegExp(patterns.includeFilePattern, regexFlag); var includeDirectoryRegex = patterns.includeDirectoryPattern && new RegExp(patterns.includeDirectoryPattern, regexFlag); @@ -1508,6 +2413,14 @@ var ts; return false; } ts.isSupportedSourceFileName = isSupportedSourceFileName; + (function (ExtensionPriority) { + ExtensionPriority[ExtensionPriority["TypeScriptFiles"] = 0] = "TypeScriptFiles"; + ExtensionPriority[ExtensionPriority["DeclarationAndJavaScriptFiles"] = 2] = "DeclarationAndJavaScriptFiles"; + ExtensionPriority[ExtensionPriority["Limit"] = 5] = "Limit"; + ExtensionPriority[ExtensionPriority["Highest"] = 0] = "Highest"; + ExtensionPriority[ExtensionPriority["Lowest"] = 2] = "Lowest"; + })(ts.ExtensionPriority || (ts.ExtensionPriority = {})); + var ExtensionPriority = ts.ExtensionPriority; function getExtensionPriority(path, supportedExtensions) { for (var i = supportedExtensions.length - 1; i >= 0; i--) { if (fileExtensionIs(path, supportedExtensions[i])) { @@ -1571,10 +2484,10 @@ var ts; this.name = name; this.declarations = undefined; } - function Type(checker, flags) { + function Type(_checker, flags) { this.flags = flags; } - function Signature(checker) { + function Signature() { } function Node(kind, pos, end) { this.id = 0; @@ -1596,6 +2509,13 @@ var ts; getTypeConstructor: function () { return Type; }, getSignatureConstructor: function () { return Signature; } }; + (function (AssertionLevel) { + AssertionLevel[AssertionLevel["None"] = 0] = "None"; + AssertionLevel[AssertionLevel["Normal"] = 1] = "Normal"; + AssertionLevel[AssertionLevel["Aggressive"] = 2] = "Aggressive"; + AssertionLevel[AssertionLevel["VeryAggressive"] = 3] = "VeryAggressive"; + })(ts.AssertionLevel || (ts.AssertionLevel = {})); + var AssertionLevel = ts.AssertionLevel; var Debug; (function (Debug) { Debug.currentAssertionLevel = 0; @@ -1908,7 +2828,7 @@ var ts; } var platform = _os.platform(); var useCaseSensitiveFileNames = isFileSystemCaseSensitive(); - function readFile(fileName, encoding) { + function readFile(fileName, _encoding) { if (!fileExists(fileName)) { return undefined; } @@ -1980,6 +2900,11 @@ var ts; function readDirectory(path, extensions, excludes, includes) { return ts.matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, process.cwd(), getAccessibleFileSystemEntries); } + var FileSystemEntryKind; + (function (FileSystemEntryKind) { + FileSystemEntryKind[FileSystemEntryKind["File"] = 0] = "File"; + FileSystemEntryKind[FileSystemEntryKind["Directory"] = 1] = "Directory"; + })(FileSystemEntryKind || (FileSystemEntryKind = {})); function fileSystemEntryExists(path, entryKind) { try { var stat = _fs.statSync(path); @@ -2121,7 +3046,7 @@ var ts; args: ChakraHost.args, useCaseSensitiveFileNames: !!ChakraHost.useCaseSensitiveFileNames, write: ChakraHost.echo, - readFile: function (path, encoding) { + readFile: function (path, _encoding) { return ChakraHost.readFile(path); }, writeFile: function (path, data, writeByteOrderMark) { @@ -2137,9 +3062,9 @@ var ts; getExecutingFilePath: function () { return ChakraHost.executingFile; }, getCurrentDirectory: function () { return ChakraHost.currentDirectory; }, getDirectories: ChakraHost.getDirectories, - getEnvironmentVariable: ChakraHost.getEnvironmentVariable || (function (name) { return ""; }), + getEnvironmentVariable: ChakraHost.getEnvironmentVariable || (function () { return ""; }), readDirectory: function (path, extensions, excludes, includes) { - var pattern = ts.getFileMatcherPatterns(path, extensions, excludes, includes, !!ChakraHost.useCaseSensitiveFileNames, ChakraHost.currentDirectory); + var pattern = ts.getFileMatcherPatterns(path, excludes, includes, !!ChakraHost.useCaseSensitiveFileNames, ChakraHost.currentDirectory); return ChakraHost.readDirectory(path, extensions, pattern.basePaths, pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern); }, exit: ChakraHost.quit, @@ -2927,7 +3852,7 @@ var ts; Binding_element_0_implicitly_has_an_1_type: { code: 7031, category: ts.DiagnosticCategory.Error, key: "Binding_element_0_implicitly_has_an_1_type_7031", message: "Binding element '{0}' implicitly has an '{1}' type." }, Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation: { code: 7032, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation_7032", message: "Property '{0}' implicitly has type 'any', because its set accessor lacks a parameter type annotation." }, Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation: { code: 7033, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation_7033", message: "Property '{0}' implicitly has type 'any', because its get accessor lacks a return type annotation." }, - Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined: { code: 7034, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined_7034", message: "Variable '{0}' implicitly has type 'any' in some locations where its type cannot be determined." }, + Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined: { code: 7034, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined_7034", message: "Variable '{0}' implicitly has type '{1}' in some locations where its type cannot be determined." }, You_cannot_rename_this_element: { code: 8000, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_this_element_8000", message: "You cannot rename this element." }, You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", message: "You cannot rename elements that are defined in the standard TypeScript library." }, import_can_only_be_used_in_a_ts_file: { code: 8002, category: ts.DiagnosticCategory.Error, key: "import_can_only_be_used_in_a_ts_file_8002", message: "'import ... =' can only be used in a .ts file." }, @@ -2964,3022 +3889,12 @@ var ts; Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers" }, Implement_interface_on_reference: { code: 90005, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_reference_90005", message: "Implement interface on reference" }, Implement_interface_on_class: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_class_90006", message: "Implement interface on class" }, - Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" } + Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" }, }; })(ts || (ts = {})); var ts; (function (ts) { - function tokenIsIdentifierOrKeyword(token) { - return token >= 69; - } - ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; - var textToToken = ts.createMap({ - "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": 136, - "function": 87, - "get": 123, - "if": 88, - "implements": 106, - "import": 89, - "in": 90, - "instanceof": 91, - "interface": 107, - "is": 124, - "let": 108, - "module": 125, - "namespace": 126, - "never": 127, - "new": 92, - "null": 93, - "number": 130, - "package": 109, - "private": 110, - "protected": 111, - "public": 112, - "readonly": 128, - "require": 129, - "global": 137, - "return": 94, - "set": 131, - "static": 113, - "string": 132, - "super": 95, - "switch": 96, - "symbol": 133, - "this": 97, - "throw": 98, - "true": 99, - "try": 100, - "type": 134, - "typeof": 101, - "undefined": 135, - "var": 102, - "void": 103, - "while": 104, - "with": 105, - "yield": 114, - "async": 118, - "await": 119, - "of": 138, - "{": 15, - "}": 16, - "(": 17, - ")": 18, - "[": 19, - "]": 20, - ".": 21, - "...": 22, - ";": 23, - ",": 24, - "<": 25, - ">": 27, - "<=": 28, - ">=": 29, - "==": 30, - "!=": 31, - "===": 32, - "!==": 33, - "=>": 34, - "+": 35, - "-": 36, - "**": 38, - "*": 37, - "/": 39, - "%": 40, - "++": 41, - "--": 42, - "<<": 43, - ">": 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,]; - var unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 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, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 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, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 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, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 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, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; - var unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 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, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 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, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 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, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; - function lookupInUnicodeMap(code, map) { - if (code < map[0]) { - return false; - } - var lo = 0; - var hi = map.length; - var mid; - while (lo + 1 < hi) { - mid = lo + (hi - lo) / 2; - mid -= mid % 2; - if (map[mid] <= code && code <= map[mid + 1]) { - return true; - } - if (code < map[mid]) { - hi = mid; - } - else { - lo = mid + 2; - } - } - return false; - } - function isUnicodeIdentifierStart(code, languageVersion) { - return languageVersion >= 1 ? - lookupInUnicodeMap(code, unicodeES5IdentifierStart) : - lookupInUnicodeMap(code, unicodeES3IdentifierStart); - } - ts.isUnicodeIdentifierStart = isUnicodeIdentifierStart; - function isUnicodeIdentifierPart(code, languageVersion) { - return languageVersion >= 1 ? - lookupInUnicodeMap(code, unicodeES5IdentifierPart) : - lookupInUnicodeMap(code, unicodeES3IdentifierPart); - } - function makeReverseMap(source) { - var result = []; - for (var name_4 in source) { - result[source[name_4]] = name_4; - } - return result; - } - var tokenStrings = makeReverseMap(textToToken); - function tokenToString(t) { - return tokenStrings[t]; - } - ts.tokenToString = tokenToString; - function stringToToken(s) { - return textToToken[s]; - } - ts.stringToToken = stringToToken; - function computeLineStarts(text) { - var result = new Array(); - var pos = 0; - var lineStart = 0; - while (pos < text.length) { - var ch = text.charCodeAt(pos); - pos++; - switch (ch) { - case 13: - if (text.charCodeAt(pos) === 10) { - pos++; - } - case 10: - result.push(lineStart); - lineStart = pos; - break; - default: - if (ch > 127 && isLineBreak(ch)) { - result.push(lineStart); - lineStart = pos; - } - break; - } - } - result.push(lineStart); - return result; - } - ts.computeLineStarts = computeLineStarts; - function getPositionOfLineAndCharacter(sourceFile, line, character) { - return computePositionOfLineAndCharacter(getLineStarts(sourceFile), line, character); - } - ts.getPositionOfLineAndCharacter = getPositionOfLineAndCharacter; - function computePositionOfLineAndCharacter(lineStarts, line, character) { - ts.Debug.assert(line >= 0 && line < lineStarts.length); - return lineStarts[line] + character; - } - ts.computePositionOfLineAndCharacter = computePositionOfLineAndCharacter; - function getLineStarts(sourceFile) { - return sourceFile.lineMap || (sourceFile.lineMap = computeLineStarts(sourceFile.text)); - } - ts.getLineStarts = getLineStarts; - function computeLineAndCharacterOfPosition(lineStarts, position) { - var lineNumber = ts.binarySearch(lineStarts, position); - if (lineNumber < 0) { - lineNumber = ~lineNumber - 1; - ts.Debug.assert(lineNumber !== -1, "position cannot precede the beginning of the file"); - } - return { - line: lineNumber, - character: position - lineStarts[lineNumber] - }; - } - ts.computeLineAndCharacterOfPosition = computeLineAndCharacterOfPosition; - function getLineAndCharacterOfPosition(sourceFile, position) { - return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position); - } - ts.getLineAndCharacterOfPosition = getLineAndCharacterOfPosition; - var hasOwnProperty = Object.prototype.hasOwnProperty; - function isWhiteSpace(ch) { - return isWhiteSpaceSingleLine(ch) || isLineBreak(ch); - } - ts.isWhiteSpace = isWhiteSpace; - function isWhiteSpaceSingleLine(ch) { - return ch === 32 || - ch === 9 || - ch === 11 || - ch === 12 || - ch === 160 || - ch === 133 || - ch === 5760 || - ch >= 8192 && ch <= 8203 || - ch === 8239 || - ch === 8287 || - ch === 12288 || - ch === 65279; - } - ts.isWhiteSpaceSingleLine = isWhiteSpaceSingleLine; - function isLineBreak(ch) { - return ch === 10 || - ch === 13 || - ch === 8232 || - ch === 8233; - } - ts.isLineBreak = isLineBreak; - function isDigit(ch) { - return ch >= 48 && ch <= 57; - } - function isOctalDigit(ch) { - return ch >= 48 && ch <= 55; - } - ts.isOctalDigit = isOctalDigit; - function couldStartTrivia(text, pos) { - var ch = text.charCodeAt(pos); - switch (ch) { - case 13: - case 10: - case 9: - case 11: - case 12: - case 32: - case 47: - case 60: - case 61: - case 62: - return true; - case 35: - return pos === 0; - default: - return ch > 127; - } - } - ts.couldStartTrivia = couldStartTrivia; - function skipTrivia(text, pos, stopAfterLineBreak, stopAtComments) { - if (stopAtComments === void 0) { stopAtComments = false; } - if (ts.positionIsSynthesized(pos)) { - return pos; - } - while (true) { - var ch = text.charCodeAt(pos); - switch (ch) { - case 13: - if (text.charCodeAt(pos + 1) === 10) { - pos++; - } - case 10: - pos++; - if (stopAfterLineBreak) { - return pos; - } - continue; - case 9: - case 11: - case 12: - case 32: - pos++; - continue; - case 47: - if (stopAtComments) { - break; - } - if (text.charCodeAt(pos + 1) === 47) { - pos += 2; - while (pos < text.length) { - if (isLineBreak(text.charCodeAt(pos))) { - break; - } - pos++; - } - continue; - } - if (text.charCodeAt(pos + 1) === 42) { - pos += 2; - while (pos < text.length) { - if (text.charCodeAt(pos) === 42 && text.charCodeAt(pos + 1) === 47) { - pos += 2; - break; - } - pos++; - } - continue; - } - break; - case 60: - case 61: - case 62: - if (isConflictMarkerTrivia(text, pos)) { - pos = scanConflictMarkerTrivia(text, pos); - continue; - } - break; - case 35: - if (pos === 0 && isShebangTrivia(text, pos)) { - pos = scanShebangTrivia(text, pos); - continue; - } - break; - default: - if (ch > 127 && (isWhiteSpace(ch))) { - pos++; - continue; - } - break; - } - return pos; - } - } - ts.skipTrivia = skipTrivia; - var mergeConflictMarkerLength = "<<<<<<<".length; - function isConflictMarkerTrivia(text, pos) { - ts.Debug.assert(pos >= 0); - if (pos === 0 || isLineBreak(text.charCodeAt(pos - 1))) { - var ch = text.charCodeAt(pos); - if ((pos + mergeConflictMarkerLength) < text.length) { - for (var i = 0, n = mergeConflictMarkerLength; i < n; i++) { - if (text.charCodeAt(pos + i) !== ch) { - return false; - } - } - return ch === 61 || - text.charCodeAt(pos + mergeConflictMarkerLength) === 32; - } - } - return false; - } - function scanConflictMarkerTrivia(text, pos, error) { - if (error) { - error(ts.Diagnostics.Merge_conflict_marker_encountered, mergeConflictMarkerLength); - } - var ch = text.charCodeAt(pos); - var len = text.length; - if (ch === 60 || ch === 62) { - while (pos < len && !isLineBreak(text.charCodeAt(pos))) { - pos++; - } - } - else { - ts.Debug.assert(ch === 61); - while (pos < len) { - var ch_1 = text.charCodeAt(pos); - if (ch_1 === 62 && isConflictMarkerTrivia(text, pos)) { - break; - } - pos++; - } - } - return pos; - } - var shebangTriviaRegex = /^#!.*/; - function isShebangTrivia(text, pos) { - ts.Debug.assert(pos === 0); - return shebangTriviaRegex.test(text); - } - function scanShebangTrivia(text, pos) { - var shebang = shebangTriviaRegex.exec(text)[0]; - pos = pos + shebang.length; - return pos; - } - function iterateCommentRanges(reduce, text, pos, trailing, cb, state, initial) { - var pendingPos; - var pendingEnd; - var pendingKind; - var pendingHasTrailingNewLine; - var hasPendingCommentRange = false; - var collecting = trailing || pos === 0; - var accumulator = initial; - scan: while (pos >= 0 && pos < text.length) { - var ch = text.charCodeAt(pos); - switch (ch) { - case 13: - if (text.charCodeAt(pos + 1) === 10) { - pos++; - } - case 10: - pos++; - if (trailing) { - break scan; - } - collecting = true; - if (hasPendingCommentRange) { - pendingHasTrailingNewLine = true; - } - continue; - case 9: - case 11: - case 12: - case 32: - pos++; - continue; - case 47: - var nextChar = text.charCodeAt(pos + 1); - var hasTrailingNewLine = false; - if (nextChar === 47 || nextChar === 42) { - var kind = nextChar === 47 ? 2 : 3; - var startPos = pos; - pos += 2; - if (nextChar === 47) { - while (pos < text.length) { - if (isLineBreak(text.charCodeAt(pos))) { - hasTrailingNewLine = true; - break; - } - pos++; - } - } - else { - while (pos < text.length) { - if (text.charCodeAt(pos) === 42 && text.charCodeAt(pos + 1) === 47) { - pos += 2; - break; - } - pos++; - } - } - if (collecting) { - if (hasPendingCommentRange) { - accumulator = cb(pendingPos, pendingEnd, pendingKind, pendingHasTrailingNewLine, state, accumulator); - if (!reduce && accumulator) { - return accumulator; - } - hasPendingCommentRange = false; - } - pendingPos = startPos; - pendingEnd = pos; - pendingKind = kind; - pendingHasTrailingNewLine = hasTrailingNewLine; - hasPendingCommentRange = true; - } - continue; - } - break scan; - default: - if (ch > 127 && (isWhiteSpace(ch))) { - if (hasPendingCommentRange && isLineBreak(ch)) { - pendingHasTrailingNewLine = true; - } - pos++; - continue; - } - break scan; - } - } - if (hasPendingCommentRange) { - accumulator = cb(pendingPos, pendingEnd, pendingKind, pendingHasTrailingNewLine, state, accumulator); - } - return accumulator; - } - function forEachLeadingCommentRange(text, pos, cb, state) { - return iterateCommentRanges(false, text, pos, false, cb, state); - } - ts.forEachLeadingCommentRange = forEachLeadingCommentRange; - function forEachTrailingCommentRange(text, pos, cb, state) { - return iterateCommentRanges(false, text, pos, true, cb, state); - } - ts.forEachTrailingCommentRange = forEachTrailingCommentRange; - function reduceEachLeadingCommentRange(text, pos, cb, state, initial) { - return iterateCommentRanges(true, text, pos, false, cb, state, initial); - } - ts.reduceEachLeadingCommentRange = reduceEachLeadingCommentRange; - function reduceEachTrailingCommentRange(text, pos, cb, state, initial) { - return iterateCommentRanges(true, text, pos, true, cb, state, initial); - } - ts.reduceEachTrailingCommentRange = reduceEachTrailingCommentRange; - function appendCommentRange(pos, end, kind, hasTrailingNewLine, state, comments) { - if (!comments) { - comments = []; - } - comments.push({ pos: pos, end: end, hasTrailingNewLine: hasTrailingNewLine, kind: kind }); - return comments; - } - function getLeadingCommentRanges(text, pos) { - return reduceEachLeadingCommentRange(text, pos, appendCommentRange, undefined, undefined); - } - ts.getLeadingCommentRanges = getLeadingCommentRanges; - function getTrailingCommentRanges(text, pos) { - return reduceEachTrailingCommentRange(text, pos, appendCommentRange, undefined, undefined); - } - ts.getTrailingCommentRanges = getTrailingCommentRanges; - function getShebang(text) { - return shebangTriviaRegex.test(text) - ? shebangTriviaRegex.exec(text)[0] - : undefined; - } - ts.getShebang = getShebang; - function isIdentifierStart(ch, languageVersion) { - return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || - ch === 36 || ch === 95 || - ch > 127 && isUnicodeIdentifierStart(ch, languageVersion); - } - ts.isIdentifierStart = isIdentifierStart; - function isIdentifierPart(ch, languageVersion) { - return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || - ch >= 48 && ch <= 57 || ch === 36 || ch === 95 || - ch > 127 && isUnicodeIdentifierPart(ch, languageVersion); - } - ts.isIdentifierPart = isIdentifierPart; - function isIdentifierText(name, languageVersion) { - if (!isIdentifierStart(name.charCodeAt(0), languageVersion)) { - return false; - } - for (var i = 1, n = name.length; i < n; i++) { - if (!isIdentifierPart(name.charCodeAt(i), languageVersion)) { - return false; - } - } - return true; - } - ts.isIdentifierText = isIdentifierText; - function createScanner(languageVersion, skipTrivia, languageVariant, text, onError, start, length) { - if (languageVariant === void 0) { languageVariant = 0; } - var pos; - var end; - var startPos; - var tokenPos; - var token; - var tokenValue; - var precedingLineBreak; - var hasExtendedUnicodeEscape; - var tokenIsUnterminated; - setText(text, start, length); - return { - getStartPos: function () { return startPos; }, - getTextPos: function () { return pos; }, - getToken: function () { return token; }, - getTokenPos: function () { return tokenPos; }, - getTokenText: function () { return text.substring(tokenPos, pos); }, - getTokenValue: function () { return tokenValue; }, - hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, - hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 69 || token > 105; }, - isReservedWord: function () { return token >= 70 && token <= 105; }, - isUnterminated: function () { return tokenIsUnterminated; }, - reScanGreaterToken: reScanGreaterToken, - reScanSlashToken: reScanSlashToken, - reScanTemplateToken: reScanTemplateToken, - scanJsxIdentifier: scanJsxIdentifier, - scanJsxAttributeValue: scanJsxAttributeValue, - reScanJsxToken: reScanJsxToken, - scanJsxToken: scanJsxToken, - scanJSDocToken: scanJSDocToken, - scan: scan, - getText: getText, - setText: setText, - setScriptTarget: setScriptTarget, - setLanguageVariant: setLanguageVariant, - setOnError: setOnError, - setTextPos: setTextPos, - tryScan: tryScan, - lookAhead: lookAhead, - scanRange: scanRange - }; - function error(message, length) { - if (onError) { - onError(message, length || 0); - } - } - function scanNumber() { - var start = pos; - while (isDigit(text.charCodeAt(pos))) - pos++; - if (text.charCodeAt(pos) === 46) { - pos++; - while (isDigit(text.charCodeAt(pos))) - pos++; - } - var end = pos; - if (text.charCodeAt(pos) === 69 || text.charCodeAt(pos) === 101) { - pos++; - if (text.charCodeAt(pos) === 43 || text.charCodeAt(pos) === 45) - pos++; - if (isDigit(text.charCodeAt(pos))) { - pos++; - while (isDigit(text.charCodeAt(pos))) - pos++; - end = pos; - } - else { - error(ts.Diagnostics.Digit_expected); - } - } - return "" + +(text.substring(start, end)); - } - function scanOctalDigits() { - var start = pos; - while (isOctalDigit(text.charCodeAt(pos))) { - pos++; - } - return +(text.substring(start, pos)); - } - function scanExactNumberOfHexDigits(count) { - return scanHexDigits(count, false); - } - function scanMinimumNumberOfHexDigits(count) { - return scanHexDigits(count, true); - } - function scanHexDigits(minCount, scanAsManyAsPossible) { - var digits = 0; - var value = 0; - while (digits < minCount || scanAsManyAsPossible) { - var ch = text.charCodeAt(pos); - if (ch >= 48 && ch <= 57) { - value = value * 16 + ch - 48; - } - else if (ch >= 65 && ch <= 70) { - value = value * 16 + ch - 65 + 10; - } - else if (ch >= 97 && ch <= 102) { - value = value * 16 + ch - 97 + 10; - } - else { - break; - } - pos++; - digits++; - } - if (digits < minCount) { - value = -1; - } - return value; - } - function scanString(allowEscapes) { - if (allowEscapes === void 0) { allowEscapes = true; } - var quote = text.charCodeAt(pos); - pos++; - var result = ""; - var start = pos; - while (true) { - if (pos >= end) { - result += text.substring(start, pos); - tokenIsUnterminated = true; - error(ts.Diagnostics.Unterminated_string_literal); - break; - } - var ch = text.charCodeAt(pos); - if (ch === quote) { - result += text.substring(start, pos); - pos++; - break; - } - if (ch === 92 && allowEscapes) { - result += text.substring(start, pos); - result += scanEscapeSequence(); - start = pos; - continue; - } - if (isLineBreak(ch)) { - result += text.substring(start, pos); - tokenIsUnterminated = true; - error(ts.Diagnostics.Unterminated_string_literal); - break; - } - pos++; - } - return result; - } - function scanTemplateAndSetTokenValue() { - var startedWithBacktick = text.charCodeAt(pos) === 96; - pos++; - var start = pos; - var contents = ""; - var resultingToken; - while (true) { - if (pos >= end) { - contents += text.substring(start, pos); - tokenIsUnterminated = true; - error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 11 : 14; - break; - } - var currChar = text.charCodeAt(pos); - if (currChar === 96) { - contents += text.substring(start, pos); - pos++; - resultingToken = startedWithBacktick ? 11 : 14; - break; - } - if (currChar === 36 && pos + 1 < end && text.charCodeAt(pos + 1) === 123) { - contents += text.substring(start, pos); - pos += 2; - resultingToken = startedWithBacktick ? 12 : 13; - break; - } - if (currChar === 92) { - contents += text.substring(start, pos); - contents += scanEscapeSequence(); - start = pos; - continue; - } - if (currChar === 13) { - contents += text.substring(start, pos); - pos++; - if (pos < end && text.charCodeAt(pos) === 10) { - pos++; - } - contents += "\n"; - start = pos; - continue; - } - pos++; - } - ts.Debug.assert(resultingToken !== undefined); - tokenValue = contents; - return resultingToken; - } - function scanEscapeSequence() { - pos++; - if (pos >= end) { - error(ts.Diagnostics.Unexpected_end_of_text); - return ""; - } - var ch = text.charCodeAt(pos); - pos++; - switch (ch) { - case 48: - return "\0"; - case 98: - return "\b"; - case 116: - return "\t"; - case 110: - return "\n"; - case 118: - return "\v"; - case 102: - return "\f"; - case 114: - return "\r"; - case 39: - return "\'"; - case 34: - return "\""; - case 117: - if (pos < end && text.charCodeAt(pos) === 123) { - hasExtendedUnicodeEscape = true; - pos++; - return scanExtendedUnicodeEscape(); - } - return scanHexadecimalEscape(4); - case 120: - return scanHexadecimalEscape(2); - case 13: - if (pos < end && text.charCodeAt(pos) === 10) { - pos++; - } - case 10: - case 8232: - case 8233: - return ""; - default: - return String.fromCharCode(ch); - } - } - function scanHexadecimalEscape(numDigits) { - var escapedValue = scanExactNumberOfHexDigits(numDigits); - if (escapedValue >= 0) { - return String.fromCharCode(escapedValue); - } - else { - error(ts.Diagnostics.Hexadecimal_digit_expected); - return ""; - } - } - function scanExtendedUnicodeEscape() { - var escapedValue = scanMinimumNumberOfHexDigits(1); - var isInvalidExtendedEscape = false; - if (escapedValue < 0) { - error(ts.Diagnostics.Hexadecimal_digit_expected); - isInvalidExtendedEscape = true; - } - else if (escapedValue > 0x10FFFF) { - error(ts.Diagnostics.An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive); - isInvalidExtendedEscape = true; - } - if (pos >= end) { - error(ts.Diagnostics.Unexpected_end_of_text); - isInvalidExtendedEscape = true; - } - else if (text.charCodeAt(pos) === 125) { - pos++; - } - else { - error(ts.Diagnostics.Unterminated_Unicode_escape_sequence); - isInvalidExtendedEscape = true; - } - if (isInvalidExtendedEscape) { - return ""; - } - return utf16EncodeAsString(escapedValue); - } - function utf16EncodeAsString(codePoint) { - ts.Debug.assert(0x0 <= codePoint && codePoint <= 0x10FFFF); - if (codePoint <= 65535) { - return String.fromCharCode(codePoint); - } - var codeUnit1 = Math.floor((codePoint - 65536) / 1024) + 0xD800; - var codeUnit2 = ((codePoint - 65536) % 1024) + 0xDC00; - return String.fromCharCode(codeUnit1, codeUnit2); - } - function peekUnicodeEscape() { - if (pos + 5 < end && text.charCodeAt(pos + 1) === 117) { - var start_1 = pos; - pos += 2; - var value = scanExactNumberOfHexDigits(4); - pos = start_1; - return value; - } - return -1; - } - function scanIdentifierParts() { - var result = ""; - var start = pos; - while (pos < end) { - var ch = text.charCodeAt(pos); - if (isIdentifierPart(ch, languageVersion)) { - pos++; - } - else if (ch === 92) { - ch = peekUnicodeEscape(); - if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { - break; - } - result += text.substring(start, pos); - result += String.fromCharCode(ch); - pos += 6; - start = pos; - } - else { - break; - } - } - result += text.substring(start, pos); - return result; - } - function getIdentifierToken() { - var len = tokenValue.length; - if (len >= 2 && len <= 11) { - var ch = tokenValue.charCodeAt(0); - if (ch >= 97 && ch <= 122 && hasOwnProperty.call(textToToken, tokenValue)) { - return token = textToToken[tokenValue]; - } - } - return token = 69; - } - function scanBinaryOrOctalDigits(base) { - ts.Debug.assert(base === 2 || base === 8, "Expected either base 2 or base 8"); - var value = 0; - var numberOfDigits = 0; - while (true) { - var ch = text.charCodeAt(pos); - var valueOfCh = ch - 48; - if (!isDigit(ch) || valueOfCh >= base) { - break; - } - value = value * base + valueOfCh; - pos++; - numberOfDigits++; - } - if (numberOfDigits === 0) { - return -1; - } - return value; - } - function scan() { - startPos = pos; - hasExtendedUnicodeEscape = false; - precedingLineBreak = false; - tokenIsUnterminated = false; - while (true) { - tokenPos = pos; - if (pos >= end) { - return token = 1; - } - var ch = text.charCodeAt(pos); - if (ch === 35 && pos === 0 && isShebangTrivia(text, pos)) { - pos = scanShebangTrivia(text, pos); - if (skipTrivia) { - continue; - } - else { - return token = 6; - } - } - switch (ch) { - case 10: - case 13: - precedingLineBreak = true; - if (skipTrivia) { - pos++; - continue; - } - else { - if (ch === 13 && pos + 1 < end && text.charCodeAt(pos + 1) === 10) { - pos += 2; - } - else { - pos++; - } - return token = 4; - } - case 9: - case 11: - case 12: - case 32: - if (skipTrivia) { - pos++; - continue; - } - else { - while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) { - pos++; - } - return token = 5; - } - case 33: - if (text.charCodeAt(pos + 1) === 61) { - if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 33; - } - return pos += 2, token = 31; - } - pos++; - return token = 49; - case 34: - case 39: - tokenValue = scanString(); - return token = 9; - case 96: - return token = scanTemplateAndSetTokenValue(); - case 37: - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 62; - } - pos++; - return token = 40; - case 38: - if (text.charCodeAt(pos + 1) === 38) { - return pos += 2, token = 51; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 66; - } - pos++; - return token = 46; - case 40: - pos++; - return token = 17; - case 41: - pos++; - return token = 18; - case 42: - if (text.charCodeAt(pos + 1) === 61) { - 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; - } - pos++; - return token = 37; - case 43: - if (text.charCodeAt(pos + 1) === 43) { - return pos += 2, token = 41; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 57; - } - pos++; - return token = 35; - case 44: - pos++; - return token = 24; - case 45: - if (text.charCodeAt(pos + 1) === 45) { - return pos += 2, token = 42; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 58; - } - pos++; - return token = 36; - case 46: - if (isDigit(text.charCodeAt(pos + 1))) { - tokenValue = scanNumber(); - return token = 8; - } - if (text.charCodeAt(pos + 1) === 46 && text.charCodeAt(pos + 2) === 46) { - return pos += 3, token = 22; - } - pos++; - return token = 21; - case 47: - if (text.charCodeAt(pos + 1) === 47) { - pos += 2; - while (pos < end) { - if (isLineBreak(text.charCodeAt(pos))) { - break; - } - pos++; - } - if (skipTrivia) { - continue; - } - else { - return token = 2; - } - } - if (text.charCodeAt(pos + 1) === 42) { - pos += 2; - var commentClosed = false; - while (pos < end) { - var ch_2 = text.charCodeAt(pos); - if (ch_2 === 42 && text.charCodeAt(pos + 1) === 47) { - pos += 2; - commentClosed = true; - break; - } - if (isLineBreak(ch_2)) { - precedingLineBreak = true; - } - pos++; - } - if (!commentClosed) { - error(ts.Diagnostics.Asterisk_Slash_expected); - } - if (skipTrivia) { - continue; - } - else { - tokenIsUnterminated = !commentClosed; - return token = 3; - } - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 61; - } - pos++; - return token = 39; - case 48: - if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 || text.charCodeAt(pos + 1) === 120)) { - pos += 2; - var value = scanMinimumNumberOfHexDigits(1); - if (value < 0) { - error(ts.Diagnostics.Hexadecimal_digit_expected); - value = 0; - } - tokenValue = "" + value; - return token = 8; - } - else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 || text.charCodeAt(pos + 1) === 98)) { - pos += 2; - var value = scanBinaryOrOctalDigits(2); - if (value < 0) { - error(ts.Diagnostics.Binary_digit_expected); - value = 0; - } - tokenValue = "" + value; - return token = 8; - } - else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 || text.charCodeAt(pos + 1) === 111)) { - pos += 2; - var value = scanBinaryOrOctalDigits(8); - if (value < 0) { - error(ts.Diagnostics.Octal_digit_expected); - value = 0; - } - tokenValue = "" + value; - return token = 8; - } - if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { - tokenValue = "" + scanOctalDigits(); - return token = 8; - } - case 49: - case 50: - case 51: - case 52: - case 53: - case 54: - case 55: - case 56: - case 57: - tokenValue = scanNumber(); - return token = 8; - case 58: - pos++; - return token = 54; - case 59: - pos++; - return token = 23; - case 60: - if (isConflictMarkerTrivia(text, pos)) { - pos = scanConflictMarkerTrivia(text, pos, error); - if (skipTrivia) { - continue; - } - else { - return token = 7; - } - } - if (text.charCodeAt(pos + 1) === 60) { - if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 63; - } - return pos += 2, token = 43; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 28; - } - if (languageVariant === 1 && - text.charCodeAt(pos + 1) === 47 && - text.charCodeAt(pos + 2) !== 42) { - return pos += 2, token = 26; - } - pos++; - return token = 25; - case 61: - if (isConflictMarkerTrivia(text, pos)) { - pos = scanConflictMarkerTrivia(text, pos, error); - if (skipTrivia) { - continue; - } - else { - return token = 7; - } - } - if (text.charCodeAt(pos + 1) === 61) { - if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 32; - } - return pos += 2, token = 30; - } - if (text.charCodeAt(pos + 1) === 62) { - return pos += 2, token = 34; - } - pos++; - return token = 56; - case 62: - if (isConflictMarkerTrivia(text, pos)) { - pos = scanConflictMarkerTrivia(text, pos, error); - if (skipTrivia) { - continue; - } - else { - return token = 7; - } - } - pos++; - return token = 27; - case 63: - pos++; - return token = 53; - case 91: - pos++; - return token = 19; - case 93: - pos++; - return token = 20; - case 94: - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 68; - } - pos++; - return token = 48; - case 123: - pos++; - return token = 15; - case 124: - if (text.charCodeAt(pos + 1) === 124) { - return pos += 2, token = 52; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 67; - } - pos++; - return token = 47; - case 125: - pos++; - return token = 16; - case 126: - pos++; - return token = 50; - case 64: - pos++; - return token = 55; - case 92: - var cookedChar = peekUnicodeEscape(); - if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { - pos += 6; - tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); - return token = getIdentifierToken(); - } - error(ts.Diagnostics.Invalid_character); - pos++; - return token = 0; - default: - if (isIdentifierStart(ch, languageVersion)) { - pos++; - while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) - pos++; - tokenValue = text.substring(tokenPos, pos); - if (ch === 92) { - tokenValue += scanIdentifierParts(); - } - return token = getIdentifierToken(); - } - else if (isWhiteSpaceSingleLine(ch)) { - pos++; - continue; - } - else if (isLineBreak(ch)) { - precedingLineBreak = true; - pos++; - continue; - } - error(ts.Diagnostics.Invalid_character); - pos++; - return token = 0; - } - } - } - function reScanGreaterToken() { - if (token === 27) { - if (text.charCodeAt(pos) === 62) { - if (text.charCodeAt(pos + 1) === 62) { - if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 65; - } - return pos += 2, token = 45; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 64; - } - pos++; - return token = 44; - } - if (text.charCodeAt(pos) === 61) { - pos++; - return token = 29; - } - } - return token; - } - function reScanSlashToken() { - if (token === 39 || token === 61) { - var p = tokenPos + 1; - var inEscape = false; - var inCharacterClass = false; - while (true) { - if (p >= end) { - tokenIsUnterminated = true; - error(ts.Diagnostics.Unterminated_regular_expression_literal); - break; - } - var ch = text.charCodeAt(p); - if (isLineBreak(ch)) { - tokenIsUnterminated = true; - error(ts.Diagnostics.Unterminated_regular_expression_literal); - break; - } - if (inEscape) { - inEscape = false; - } - else if (ch === 47 && !inCharacterClass) { - p++; - break; - } - else if (ch === 91) { - inCharacterClass = true; - } - else if (ch === 92) { - inEscape = true; - } - else if (ch === 93) { - inCharacterClass = false; - } - p++; - } - while (p < end && isIdentifierPart(text.charCodeAt(p), languageVersion)) { - p++; - } - pos = p; - tokenValue = text.substring(tokenPos, pos); - token = 10; - } - return token; - } - function reScanTemplateToken() { - ts.Debug.assert(token === 16, "'reScanTemplateToken' should only be called on a '}'"); - pos = tokenPos; - return token = scanTemplateAndSetTokenValue(); - } - function reScanJsxToken() { - pos = tokenPos = startPos; - return token = scanJsxToken(); - } - function scanJsxToken() { - startPos = tokenPos = pos; - if (pos >= end) { - return token = 1; - } - var char = text.charCodeAt(pos); - if (char === 60) { - if (text.charCodeAt(pos + 1) === 47) { - pos += 2; - return token = 26; - } - pos++; - return token = 25; - } - if (char === 123) { - pos++; - return token = 15; - } - while (pos < end) { - pos++; - char = text.charCodeAt(pos); - if ((char === 123) || (char === 60)) { - break; - } - } - return token = 244; - } - function scanJsxIdentifier() { - if (tokenIsIdentifierOrKeyword(token)) { - var firstCharPosition = pos; - while (pos < end) { - var ch = text.charCodeAt(pos); - if (ch === 45 || ((firstCharPosition === pos) ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion))) { - pos++; - } - else { - break; - } - } - tokenValue += text.substr(firstCharPosition, pos - firstCharPosition); - } - return token; - } - function scanJsxAttributeValue() { - startPos = pos; - switch (text.charCodeAt(pos)) { - case 34: - case 39: - tokenValue = scanString(false); - return token = 9; - default: - return scan(); - } - } - function scanJSDocToken() { - if (pos >= end) { - return token = 1; - } - startPos = pos; - tokenPos = pos; - var ch = text.charCodeAt(pos); - switch (ch) { - case 9: - case 11: - case 12: - case 32: - while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) { - pos++; - } - return token = 5; - case 64: - pos++; - return token = 55; - case 10: - case 13: - pos++; - return token = 4; - case 42: - pos++; - return token = 37; - case 123: - pos++; - return token = 15; - case 125: - pos++; - return token = 16; - case 91: - pos++; - return token = 19; - case 93: - pos++; - return token = 20; - case 61: - pos++; - return token = 56; - case 44: - pos++; - return token = 24; - } - if (isIdentifierStart(ch, 2)) { - pos++; - while (isIdentifierPart(text.charCodeAt(pos), 2) && pos < end) { - pos++; - } - return token = 69; - } - else { - return pos += 1, token = 0; - } - } - function speculationHelper(callback, isLookahead) { - var savePos = pos; - var saveStartPos = startPos; - var saveTokenPos = tokenPos; - var saveToken = token; - var saveTokenValue = tokenValue; - var savePrecedingLineBreak = precedingLineBreak; - var result = callback(); - if (!result || isLookahead) { - pos = savePos; - startPos = saveStartPos; - tokenPos = saveTokenPos; - token = saveToken; - tokenValue = saveTokenValue; - precedingLineBreak = savePrecedingLineBreak; - } - return result; - } - function scanRange(start, length, callback) { - var saveEnd = end; - var savePos = pos; - var saveStartPos = startPos; - var saveTokenPos = tokenPos; - var saveToken = token; - var savePrecedingLineBreak = precedingLineBreak; - var saveTokenValue = tokenValue; - var saveHasExtendedUnicodeEscape = hasExtendedUnicodeEscape; - var saveTokenIsUnterminated = tokenIsUnterminated; - setText(text, start, length); - var result = callback(); - end = saveEnd; - pos = savePos; - startPos = saveStartPos; - tokenPos = saveTokenPos; - token = saveToken; - precedingLineBreak = savePrecedingLineBreak; - tokenValue = saveTokenValue; - hasExtendedUnicodeEscape = saveHasExtendedUnicodeEscape; - tokenIsUnterminated = saveTokenIsUnterminated; - return result; - } - function lookAhead(callback) { - return speculationHelper(callback, true); - } - function tryScan(callback) { - return speculationHelper(callback, false); - } - function getText() { - return text; - } - function setText(newText, start, length) { - text = newText || ""; - end = length === undefined ? text.length : start + length; - setTextPos(start || 0); - } - function setOnError(errorCallback) { - onError = errorCallback; - } - function setScriptTarget(scriptTarget) { - languageVersion = scriptTarget; - } - function setLanguageVariant(variant) { - languageVariant = variant; - } - function setTextPos(textPos) { - ts.Debug.assert(textPos >= 0); - pos = textPos; - startPos = textPos; - tokenPos = textPos; - token = 0; - precedingLineBreak = false; - tokenValue = undefined; - hasExtendedUnicodeEscape = false; - tokenIsUnterminated = false; - } - } - ts.createScanner = createScanner; -})(ts || (ts = {})); -var ts; -(function (ts) { - ts.compileOnSaveCommandLineOption = { name: "compileOnSave", type: "boolean" }; - ts.optionDeclarations = [ - { - name: "charset", - type: "string" - }, - ts.compileOnSaveCommandLineOption, - { - name: "declaration", - shortName: "d", - type: "boolean", - description: ts.Diagnostics.Generates_corresponding_d_ts_file - }, - { - name: "declarationDir", - type: "string", - isFilePath: true, - paramType: ts.Diagnostics.DIRECTORY - }, - { - name: "diagnostics", - type: "boolean" - }, - { - name: "extendedDiagnostics", - type: "boolean", - experimental: true - }, - { - name: "emitBOM", - type: "boolean" - }, - { - name: "help", - shortName: "h", - type: "boolean", - description: ts.Diagnostics.Print_this_message - }, - { - name: "help", - shortName: "?", - type: "boolean" - }, - { - name: "init", - type: "boolean", - description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file - }, - { - name: "inlineSourceMap", - type: "boolean" - }, - { - name: "inlineSources", - type: "boolean" - }, - { - name: "jsx", - type: ts.createMap({ - "preserve": 1, - "react": 2 - }), - paramType: ts.Diagnostics.KIND, - description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react - }, - { - name: "reactNamespace", - type: "string", - description: ts.Diagnostics.Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit - }, - { - name: "listFiles", - type: "boolean" - }, - { - name: "locale", - type: "string" - }, - { - name: "mapRoot", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, - paramType: ts.Diagnostics.LOCATION - }, - { - name: "module", - shortName: "m", - type: ts.createMap({ - "none": ts.ModuleKind.None, - "commonjs": ts.ModuleKind.CommonJS, - "amd": ts.ModuleKind.AMD, - "system": ts.ModuleKind.System, - "umd": ts.ModuleKind.UMD, - "es6": ts.ModuleKind.ES6, - "es2015": ts.ModuleKind.ES2015 - }), - description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, - paramType: ts.Diagnostics.KIND - }, - { - name: "newLine", - type: ts.createMap({ - "crlf": 0, - "lf": 1 - }), - description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, - paramType: ts.Diagnostics.NEWLINE - }, - { - name: "noEmit", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_outputs - }, - { - name: "noEmitHelpers", - type: "boolean" - }, - { - name: "noEmitOnError", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported - }, - { - name: "noErrorTruncation", - type: "boolean" - }, - { - name: "noImplicitAny", - type: "boolean", - description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type - }, - { - name: "noImplicitThis", - type: "boolean", - description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type - }, - { - name: "noUnusedLocals", - type: "boolean", - description: ts.Diagnostics.Report_errors_on_unused_locals - }, - { - name: "noUnusedParameters", - type: "boolean", - description: ts.Diagnostics.Report_errors_on_unused_parameters - }, - { - name: "noLib", - type: "boolean" - }, - { - name: "noResolve", - type: "boolean" - }, - { - name: "skipDefaultLibCheck", - type: "boolean" - }, - { - name: "skipLibCheck", - type: "boolean", - description: ts.Diagnostics.Skip_type_checking_of_declaration_files - }, - { - name: "out", - type: "string", - isFilePath: false, - paramType: ts.Diagnostics.FILE - }, - { - name: "outFile", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, - paramType: ts.Diagnostics.FILE - }, - { - name: "outDir", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Redirect_output_structure_to_the_directory, - paramType: ts.Diagnostics.DIRECTORY - }, - { - name: "preserveConstEnums", - type: "boolean", - description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code - }, - { - name: "pretty", - description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental, - type: "boolean" - }, - { - name: "project", - shortName: "p", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Compile_the_project_in_the_given_directory, - paramType: ts.Diagnostics.DIRECTORY - }, - { - name: "removeComments", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_comments_to_output - }, - { - name: "rootDir", - type: "string", - isFilePath: true, - paramType: ts.Diagnostics.LOCATION, - description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir - }, - { - name: "isolatedModules", - type: "boolean" - }, - { - name: "sourceMap", - type: "boolean", - description: ts.Diagnostics.Generates_corresponding_map_file - }, - { - name: "sourceRoot", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, - paramType: ts.Diagnostics.LOCATION - }, - { - name: "suppressExcessPropertyErrors", - type: "boolean", - description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals, - experimental: true - }, - { - name: "suppressImplicitAnyIndexErrors", - type: "boolean", - description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures - }, - { - name: "stripInternal", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation, - experimental: true - }, - { - name: "target", - shortName: "t", - type: ts.createMap({ - "es3": 0, - "es5": 1, - "es6": 2, - "es2015": 2 - }), - description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015, - paramType: ts.Diagnostics.VERSION - }, - { - name: "version", - shortName: "v", - type: "boolean", - description: ts.Diagnostics.Print_the_compiler_s_version - }, - { - name: "watch", - shortName: "w", - type: "boolean", - description: ts.Diagnostics.Watch_input_files - }, - { - name: "experimentalDecorators", - type: "boolean", - description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators - }, - { - name: "emitDecoratorMetadata", - type: "boolean", - experimental: true, - description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators - }, - { - name: "moduleResolution", - type: ts.createMap({ - "node": ts.ModuleResolutionKind.NodeJs, - "classic": ts.ModuleResolutionKind.Classic - }), - description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, - paramType: ts.Diagnostics.STRATEGY - }, - { - name: "allowUnusedLabels", - type: "boolean", - description: ts.Diagnostics.Do_not_report_errors_on_unused_labels - }, - { - name: "noImplicitReturns", - type: "boolean", - description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value - }, - { - name: "noFallthroughCasesInSwitch", - type: "boolean", - description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement - }, - { - name: "allowUnreachableCode", - type: "boolean", - description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code - }, - { - name: "forceConsistentCasingInFileNames", - type: "boolean", - description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file - }, - { - name: "baseUrl", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Base_directory_to_resolve_non_absolute_module_names - }, - { - name: "paths", - type: "object", - isTSConfigOnly: true - }, - { - name: "rootDirs", - type: "list", - isTSConfigOnly: true, - element: { - name: "rootDirs", - type: "string", - isFilePath: true - } - }, - { - name: "typeRoots", - type: "list", - element: { - name: "typeRoots", - type: "string", - isFilePath: true - } - }, - { - name: "types", - type: "list", - element: { - name: "types", - type: "string" - }, - description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation - }, - { - name: "traceResolution", - type: "boolean", - description: ts.Diagnostics.Enable_tracing_of_the_name_resolution_process - }, - { - name: "allowJs", - type: "boolean", - description: ts.Diagnostics.Allow_javascript_files_to_be_compiled - }, - { - name: "allowSyntheticDefaultImports", - type: "boolean", - description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking - }, - { - name: "noImplicitUseStrict", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_use_strict_directives_in_module_output - }, - { - name: "maxNodeModuleJsDepth", - type: "number", - description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files - }, - { - name: "listEmittedFiles", - type: "boolean" - }, - { - name: "lib", - type: "list", - element: { - name: "lib", - type: ts.createMap({ - "es5": "lib.es5.d.ts", - "es6": "lib.es2015.d.ts", - "es2015": "lib.es2015.d.ts", - "es7": "lib.es2016.d.ts", - "es2016": "lib.es2016.d.ts", - "es2017": "lib.es2017.d.ts", - "dom": "lib.dom.d.ts", - "dom.iterable": "lib.dom.iterable.d.ts", - "webworker": "lib.webworker.d.ts", - "scripthost": "lib.scripthost.d.ts", - "es2015.core": "lib.es2015.core.d.ts", - "es2015.collection": "lib.es2015.collection.d.ts", - "es2015.generator": "lib.es2015.generator.d.ts", - "es2015.iterable": "lib.es2015.iterable.d.ts", - "es2015.promise": "lib.es2015.promise.d.ts", - "es2015.proxy": "lib.es2015.proxy.d.ts", - "es2015.reflect": "lib.es2015.reflect.d.ts", - "es2015.symbol": "lib.es2015.symbol.d.ts", - "es2015.symbol.wellknown": "lib.es2015.symbol.wellknown.d.ts", - "es2016.array.include": "lib.es2016.array.include.d.ts", - "es2017.object": "lib.es2017.object.d.ts", - "es2017.sharedmemory": "lib.es2017.sharedmemory.d.ts" - }) - }, - description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon - }, - { - name: "disableSizeLimit", - type: "boolean" - }, - { - name: "strictNullChecks", - type: "boolean", - description: ts.Diagnostics.Enable_strict_null_checks - }, - { - name: "importHelpers", - type: "boolean", - description: ts.Diagnostics.Import_emit_helpers_from_tslib - }, - { - name: "alwaysStrict", - type: "boolean", - description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file - } - ]; - ts.typingOptionDeclarations = [ - { - name: "enableAutoDiscovery", - type: "boolean" - }, - { - name: "include", - type: "list", - element: { - name: "include", - type: "string" - } - }, - { - name: "exclude", - type: "list", - element: { - name: "exclude", - type: "string" - } - } - ]; - ts.defaultInitCompilerOptions = { - module: ts.ModuleKind.CommonJS, - target: 1, - noImplicitAny: false, - sourceMap: false - }; - var optionNameMapCache; - function getOptionNameMap() { - if (optionNameMapCache) { - return optionNameMapCache; - } - var optionNameMap = ts.createMap(); - var shortOptionNames = ts.createMap(); - ts.forEach(ts.optionDeclarations, function (option) { - optionNameMap[option.name.toLowerCase()] = option; - if (option.shortName) { - shortOptionNames[option.shortName] = option.name; - } - }); - optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames }; - return optionNameMapCache; - } - ts.getOptionNameMap = getOptionNameMap; - function createCompilerDiagnosticForInvalidCustomType(opt) { - var namesOfType = []; - for (var key in opt.type) { - namesOfType.push(" '" + key + "'"); - } - return ts.createCompilerDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); - } - ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; - function parseCustomTypeOption(opt, value, errors) { - var key = trimString((value || "")).toLowerCase(); - var map = opt.type; - if (key in map) { - return map[key]; - } - else { - errors.push(createCompilerDiagnosticForInvalidCustomType(opt)); - } - } - ts.parseCustomTypeOption = parseCustomTypeOption; - function parseListTypeOption(opt, value, errors) { - if (value === void 0) { value = ""; } - value = trimString(value); - if (ts.startsWith(value, "-")) { - return undefined; - } - if (value === "") { - return []; - } - var values = value.split(","); - switch (opt.element.type) { - case "number": - return ts.map(values, parseInt); - case "string": - return ts.map(values, function (v) { return v || ""; }); - default: - return ts.filter(ts.map(values, function (v) { return parseCustomTypeOption(opt.element, v, errors); }), function (v) { return !!v; }); - } - } - ts.parseListTypeOption = parseListTypeOption; - function parseCommandLine(commandLine, readFile) { - var options = {}; - var fileNames = []; - var errors = []; - var _a = getOptionNameMap(), optionNameMap = _a.optionNameMap, shortOptionNames = _a.shortOptionNames; - parseStrings(commandLine); - return { - options: options, - fileNames: fileNames, - errors: errors - }; - function parseStrings(args) { - var i = 0; - while (i < args.length) { - var s = args[i]; - i++; - if (s.charCodeAt(0) === 64) { - parseResponseFile(s.slice(1)); - } - else if (s.charCodeAt(0) === 45) { - s = s.slice(s.charCodeAt(1) === 45 ? 2 : 1).toLowerCase(); - if (s in shortOptionNames) { - s = shortOptionNames[s]; - } - if (s in optionNameMap) { - var opt = optionNameMap[s]; - if (opt.isTSConfigOnly) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file, opt.name)); - } - else { - if (!args[i] && opt.type !== "boolean") { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_expects_an_argument, opt.name)); - } - switch (opt.type) { - case "number": - options[opt.name] = parseInt(args[i]); - i++; - break; - case "boolean": - options[opt.name] = true; - break; - case "string": - options[opt.name] = args[i] || ""; - i++; - break; - case "list": - var result = parseListTypeOption(opt, args[i], errors); - options[opt.name] = result || []; - if (result) { - i++; - } - break; - default: - options[opt.name] = parseCustomTypeOption(opt, args[i], errors); - i++; - break; - } - } - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_compiler_option_0, s)); - } - } - else { - fileNames.push(s); - } - } - } - function parseResponseFile(fileName) { - var text = readFile ? readFile(fileName) : ts.sys.readFile(fileName); - if (!text) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, fileName)); - return; - } - var args = []; - var pos = 0; - while (true) { - while (pos < text.length && text.charCodeAt(pos) <= 32) - pos++; - if (pos >= text.length) - break; - var start = pos; - if (text.charCodeAt(start) === 34) { - pos++; - while (pos < text.length && text.charCodeAt(pos) !== 34) - pos++; - if (pos < text.length) { - args.push(text.substring(start + 1, pos)); - pos++; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unterminated_quoted_string_in_response_file_0, fileName)); - } - } - else { - while (text.charCodeAt(pos) > 32) - pos++; - args.push(text.substring(start, pos)); - } - } - parseStrings(args); - } - } - ts.parseCommandLine = parseCommandLine; - function readConfigFile(fileName, readFile) { - var text = ""; - try { - text = readFile(fileName); - } - catch (e) { - return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) }; - } - return parseConfigFileTextToJson(fileName, text); - } - ts.readConfigFile = readConfigFile; - function parseConfigFileTextToJson(fileName, jsonText, stripComments) { - if (stripComments === void 0) { stripComments = true; } - try { - var jsonTextToParse = stripComments ? removeComments(jsonText) : jsonText; - return { config: /\S/.test(jsonTextToParse) ? JSON.parse(jsonTextToParse) : {} }; - } - catch (e) { - return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) }; - } - } - ts.parseConfigFileTextToJson = parseConfigFileTextToJson; - function generateTSConfig(options, fileNames) { - var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions); - var configurations = { - compilerOptions: serializeCompilerOptions(compilerOptions) - }; - if (fileNames && fileNames.length) { - configurations.files = fileNames; - } - return configurations; - function getCustomTypeMapOfCommandLineOption(optionDefinition) { - if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean") { - return undefined; - } - else if (optionDefinition.type === "list") { - return getCustomTypeMapOfCommandLineOption(optionDefinition.element); - } - else { - return optionDefinition.type; - } - } - function getNameOfCompilerOptionValue(value, customTypeMap) { - for (var key in customTypeMap) { - if (customTypeMap[key] === value) { - return key; - } - } - return undefined; - } - function serializeCompilerOptions(options) { - var result = ts.createMap(); - var optionsNameMap = getOptionNameMap().optionNameMap; - for (var name_5 in options) { - if (ts.hasProperty(options, name_5)) { - switch (name_5) { - case "init": - case "watch": - case "version": - case "help": - case "project": - break; - default: - var value = options[name_5]; - var optionDefinition = optionsNameMap[name_5.toLowerCase()]; - if (optionDefinition) { - var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); - if (!customTypeMap) { - result[name_5] = value; - } - else { - if (optionDefinition.type === "list") { - var convertedValue = []; - for (var _i = 0, _a = value; _i < _a.length; _i++) { - var element = _a[_i]; - convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); - } - result[name_5] = convertedValue; - } - else { - result[name_5] = getNameOfCompilerOptionValue(value, customTypeMap); - } - } - } - break; - } - } - } - return result; - } - } - ts.generateTSConfig = generateTSConfig; - function removeComments(jsonText) { - var output = ""; - var scanner = ts.createScanner(1, false, 0, jsonText); - var token; - while ((token = scanner.scan()) !== 1) { - switch (token) { - case 2: - case 3: - output += scanner.getTokenText().replace(/\S/g, " "); - break; - default: - output += scanner.getTokenText(); - break; - } - } - return output; - } - function parseJsonConfigFileContent(json, host, basePath, existingOptions, configFileName, resolutionStack) { - if (existingOptions === void 0) { existingOptions = {}; } - if (resolutionStack === void 0) { resolutionStack = []; } - var errors = []; - var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); - var resolvedPath = ts.toPath(configFileName || "", basePath, getCanonicalFileName); - if (resolutionStack.indexOf(resolvedPath) >= 0) { - return { - options: {}, - fileNames: [], - typingOptions: {}, - raw: json, - errors: [ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, resolutionStack.concat([resolvedPath]).join(" -> "))], - wildcardDirectories: {} - }; - } - var options = convertCompilerOptionsFromJsonWorker(json["compilerOptions"], basePath, errors, configFileName); - var typingOptions = convertTypingOptionsFromJsonWorker(json["typingOptions"], basePath, errors, configFileName); - if (json["extends"]) { - var _a = [undefined, undefined, undefined, {}], include = _a[0], exclude = _a[1], files = _a[2], baseOptions = _a[3]; - if (typeof json["extends"] === "string") { - _b = (tryExtendsName(json["extends"]) || [include, exclude, files, baseOptions]), include = _b[0], exclude = _b[1], files = _b[2], baseOptions = _b[3]; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string")); - } - if (include && !json["include"]) { - json["include"] = include; - } - if (exclude && !json["exclude"]) { - json["exclude"] = exclude; - } - if (files && !json["files"]) { - json["files"] = files; - } - options = ts.assign({}, baseOptions, options); - } - options = ts.extend(existingOptions, options); - options.configFilePath = configFileName; - var _c = getFileNames(errors), fileNames = _c.fileNames, wildcardDirectories = _c.wildcardDirectories; - var compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors); - return { - options: options, - fileNames: fileNames, - typingOptions: typingOptions, - raw: json, - errors: errors, - wildcardDirectories: wildcardDirectories, - compileOnSave: compileOnSave - }; - function tryExtendsName(extendedConfig) { - if (!(ts.isRootedDiskPath(extendedConfig) || ts.startsWith(ts.normalizeSlashes(extendedConfig), "./") || ts.startsWith(ts.normalizeSlashes(extendedConfig), "../"))) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.The_path_in_an_extends_options_must_be_relative_or_rooted)); - return; - } - var extendedConfigPath = ts.toPath(extendedConfig, basePath, getCanonicalFileName); - if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json")) { - extendedConfigPath = extendedConfigPath + ".json"; - if (!host.fileExists(extendedConfigPath)) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig)); - return; - } - } - var extendedResult = readConfigFile(extendedConfigPath, function (path) { return host.readFile(path); }); - if (extendedResult.error) { - errors.push(extendedResult.error); - return; - } - var extendedDirname = ts.getDirectoryPath(extendedConfigPath); - var relativeDifference = ts.convertToRelativePath(extendedDirname, basePath, getCanonicalFileName); - var updatePath = function (path) { return ts.isRootedDiskPath(path) ? path : ts.combinePaths(relativeDifference, path); }; - var result = parseJsonConfigFileContent(extendedResult.config, host, extendedDirname, undefined, ts.getBaseFileName(extendedConfigPath), resolutionStack.concat([resolvedPath])); - errors.push.apply(errors, result.errors); - var _a = ts.map(["include", "exclude", "files"], function (key) { - if (!json[key] && extendedResult.config[key]) { - return ts.map(extendedResult.config[key], updatePath); - } - }), include = _a[0], exclude = _a[1], files = _a[2]; - return [include, exclude, files, result.options]; - } - function getFileNames(errors) { - var fileNames; - if (ts.hasProperty(json, "files")) { - if (ts.isArray(json["files"])) { - fileNames = json["files"]; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array")); - } - } - var includeSpecs; - if (ts.hasProperty(json, "include")) { - if (ts.isArray(json["include"])) { - includeSpecs = json["include"]; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "include", "Array")); - } - } - var excludeSpecs; - if (ts.hasProperty(json, "exclude")) { - if (ts.isArray(json["exclude"])) { - excludeSpecs = json["exclude"]; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "exclude", "Array")); - } - } - else if (ts.hasProperty(json, "excludes")) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_option_excludes_Did_you_mean_exclude)); - } - else { - excludeSpecs = ["node_modules", "bower_components", "jspm_packages"]; - var outDir = json["compilerOptions"] && json["compilerOptions"]["outDir"]; - if (outDir) { - excludeSpecs.push(outDir); - } - } - if (fileNames === undefined && includeSpecs === undefined) { - includeSpecs = ["**/*"]; - } - return matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors); - } - var _b; - } - ts.parseJsonConfigFileContent = parseJsonConfigFileContent; - function convertCompileOnSaveOptionFromJson(jsonOption, basePath, errors) { - if (!ts.hasProperty(jsonOption, ts.compileOnSaveCommandLineOption.name)) { - return false; - } - var result = convertJsonOption(ts.compileOnSaveCommandLineOption, jsonOption["compileOnSave"], basePath, errors); - if (typeof result === "boolean" && result) { - return result; - } - return false; - } - ts.convertCompileOnSaveOptionFromJson = convertCompileOnSaveOptionFromJson; - function convertCompilerOptionsFromJson(jsonOptions, basePath, configFileName) { - var errors = []; - var options = convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName); - return { options: options, errors: errors }; - } - ts.convertCompilerOptionsFromJson = convertCompilerOptionsFromJson; - function convertTypingOptionsFromJson(jsonOptions, basePath, configFileName) { - var errors = []; - var options = convertTypingOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName); - return { options: options, errors: errors }; - } - ts.convertTypingOptionsFromJson = convertTypingOptionsFromJson; - function convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { - var options = ts.getBaseFileName(configFileName) === "jsconfig.json" - ? { allowJs: true, maxNodeModuleJsDepth: 2, allowSyntheticDefaultImports: true, skipLibCheck: true } - : {}; - convertOptionsFromJson(ts.optionDeclarations, jsonOptions, basePath, options, ts.Diagnostics.Unknown_compiler_option_0, errors); - return options; - } - function convertTypingOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { - var options = ts.getBaseFileName(configFileName) === "jsconfig.json" - ? { enableAutoDiscovery: true, include: [], exclude: [] } - : { enableAutoDiscovery: false, include: [], exclude: [] }; - convertOptionsFromJson(ts.typingOptionDeclarations, jsonOptions, basePath, options, ts.Diagnostics.Unknown_typing_option_0, errors); - return options; - } - function convertOptionsFromJson(optionDeclarations, jsonOptions, basePath, defaultOptions, diagnosticMessage, errors) { - if (!jsonOptions) { - return; - } - var optionNameMap = ts.arrayToMap(optionDeclarations, function (opt) { return opt.name; }); - for (var id in jsonOptions) { - if (id in optionNameMap) { - var opt = optionNameMap[id]; - defaultOptions[opt.name] = convertJsonOption(opt, jsonOptions[id], basePath, errors); - } - else { - errors.push(ts.createCompilerDiagnostic(diagnosticMessage, id)); - } - } - } - function convertJsonOption(opt, value, basePath, errors) { - var optType = opt.type; - var expectedType = typeof optType === "string" ? optType : "string"; - if (optType === "list" && ts.isArray(value)) { - return convertJsonOptionOfListType(opt, value, basePath, errors); - } - else if (typeof value === expectedType) { - if (typeof optType !== "string") { - return convertJsonOptionOfCustomType(opt, value, errors); - } - else { - if (opt.isFilePath) { - value = ts.normalizePath(ts.combinePaths(basePath, value)); - if (value === "") { - value = "."; - } - } - } - return value; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, opt.name, expectedType)); - } - } - function convertJsonOptionOfCustomType(opt, value, errors) { - var key = value.toLowerCase(); - if (key in opt.type) { - return opt.type[key]; - } - else { - errors.push(createCompilerDiagnosticForInvalidCustomType(opt)); - } - } - function convertJsonOptionOfListType(option, values, basePath, errors) { - return ts.filter(ts.map(values, function (v) { return convertJsonOption(option.element, v, basePath, errors); }), function (v) { return !!v; }); - } - function trimString(s) { - return typeof s.trim === "function" ? s.trim() : s.replace(/^[\s]+|[\s]+$/g, ""); - } - var invalidTrailingRecursionPattern = /(^|\/)\*\*\/?$/; - var invalidMultipleRecursionPatterns = /(^|\/)\*\*\/(.*\/)?\*\*($|\/)/; - var invalidDotDotAfterRecursiveWildcardPattern = /(^|\/)\*\*\/(.*\/)?\.\.($|\/)/; - var watchRecursivePattern = /\/[^/]*?[*?][^/]*\//; - var wildcardDirectoryPattern = /^[^*?]*(?=\/[^/]*[*?])/; - function matchFileNames(fileNames, include, exclude, basePath, options, host, errors) { - basePath = ts.normalizePath(basePath); - var keyMapper = host.useCaseSensitiveFileNames ? caseSensitiveKeyMapper : caseInsensitiveKeyMapper; - var literalFileMap = ts.createMap(); - var wildcardFileMap = ts.createMap(); - if (include) { - include = validateSpecs(include, errors, false); - } - if (exclude) { - exclude = validateSpecs(exclude, errors, true); - } - var wildcardDirectories = getWildcardDirectories(include, exclude, basePath, host.useCaseSensitiveFileNames); - var supportedExtensions = ts.getSupportedExtensions(options); - if (fileNames) { - for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) { - var fileName = fileNames_1[_i]; - var file = ts.combinePaths(basePath, fileName); - literalFileMap[keyMapper(file)] = file; - } - } - if (include && include.length > 0) { - for (var _a = 0, _b = host.readDirectory(basePath, supportedExtensions, exclude, include); _a < _b.length; _a++) { - var file = _b[_a]; - if (hasFileWithHigherPriorityExtension(file, literalFileMap, wildcardFileMap, supportedExtensions, keyMapper)) { - continue; - } - removeWildcardFilesWithLowerPriorityExtension(file, wildcardFileMap, supportedExtensions, keyMapper); - var key = keyMapper(file); - if (!(key in literalFileMap) && !(key in wildcardFileMap)) { - wildcardFileMap[key] = file; - } - } - } - var literalFiles = ts.reduceProperties(literalFileMap, addFileToOutput, []); - var wildcardFiles = ts.reduceProperties(wildcardFileMap, addFileToOutput, []); - wildcardFiles.sort(host.useCaseSensitiveFileNames ? ts.compareStrings : ts.compareStringsCaseInsensitive); - return { - fileNames: literalFiles.concat(wildcardFiles), - wildcardDirectories: wildcardDirectories - }; - } - function validateSpecs(specs, errors, allowTrailingRecursion) { - var validSpecs = []; - for (var _i = 0, specs_2 = specs; _i < specs_2.length; _i++) { - var spec = specs_2[_i]; - if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); - } - else if (invalidMultipleRecursionPatterns.test(spec)) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0, spec)); - } - else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); - } - else { - validSpecs.push(spec); - } - } - return validSpecs; - } - function getWildcardDirectories(include, exclude, path, useCaseSensitiveFileNames) { - var rawExcludeRegex = ts.getRegularExpressionForWildcard(exclude, path, "exclude"); - var excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames ? "" : "i"); - var wildcardDirectories = ts.createMap(); - if (include !== undefined) { - var recursiveKeys = []; - for (var _i = 0, include_1 = include; _i < include_1.length; _i++) { - var file = include_1[_i]; - var name_6 = ts.normalizePath(ts.combinePaths(path, file)); - if (excludeRegex && excludeRegex.test(name_6)) { - continue; - } - var match = wildcardDirectoryPattern.exec(name_6); - if (match) { - var key = useCaseSensitiveFileNames ? match[0] : match[0].toLowerCase(); - var flags = watchRecursivePattern.test(name_6) ? 1 : 0; - var existingFlags = wildcardDirectories[key]; - if (existingFlags === undefined || existingFlags < flags) { - wildcardDirectories[key] = flags; - if (flags === 1) { - recursiveKeys.push(key); - } - } - } - } - for (var key in wildcardDirectories) { - for (var _a = 0, recursiveKeys_1 = recursiveKeys; _a < recursiveKeys_1.length; _a++) { - var recursiveKey = recursiveKeys_1[_a]; - if (key !== recursiveKey && ts.containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) { - delete wildcardDirectories[key]; - } - } - } - } - return wildcardDirectories; - } - function hasFileWithHigherPriorityExtension(file, literalFiles, wildcardFiles, extensions, keyMapper) { - var extensionPriority = ts.getExtensionPriority(file, extensions); - var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority); - for (var i = 0; i < adjustedExtensionPriority; i++) { - var higherPriorityExtension = extensions[i]; - var higherPriorityPath = keyMapper(ts.changeExtension(file, higherPriorityExtension)); - if (higherPriorityPath in literalFiles || higherPriorityPath in wildcardFiles) { - return true; - } - } - return false; - } - function removeWildcardFilesWithLowerPriorityExtension(file, wildcardFiles, extensions, keyMapper) { - var extensionPriority = ts.getExtensionPriority(file, extensions); - var nextExtensionPriority = ts.getNextLowestExtensionPriority(extensionPriority); - for (var i = nextExtensionPriority; i < extensions.length; i++) { - var lowerPriorityExtension = extensions[i]; - var lowerPriorityPath = keyMapper(ts.changeExtension(file, lowerPriorityExtension)); - delete wildcardFiles[lowerPriorityPath]; - } - } - function addFileToOutput(output, file) { - output.push(file); - return output; - } - function caseSensitiveKeyMapper(key) { - return key; - } - function caseInsensitiveKeyMapper(key) { - return key.toLowerCase(); - } -})(ts || (ts = {})); -var ts; -(function (ts) { - var JsTyping; - (function (JsTyping) { - ; - ; - var safeList; - var EmptySafeList = ts.createMap(); - function discoverTypings(host, fileNames, projectRootPath, safeListPath, packageNameToTypingLocation, typingOptions, compilerOptions) { - var inferredTypings = ts.createMap(); - if (!typingOptions || !typingOptions.enableAutoDiscovery) { - return { cachedTypingPaths: [], newTypingNames: [], filesToWatch: [] }; - } - fileNames = ts.filter(ts.map(fileNames, ts.normalizePath), function (f) { - var kind = ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)); - return kind === 1 || kind === 2; - }); - if (!safeList) { - var result = ts.readConfigFile(safeListPath, function (path) { return host.readFile(path); }); - safeList = result.config ? ts.createMap(result.config) : EmptySafeList; - } - var filesToWatch = []; - var searchDirs = []; - var exclude = []; - mergeTypings(typingOptions.include); - exclude = typingOptions.exclude || []; - var possibleSearchDirs = ts.map(fileNames, ts.getDirectoryPath); - if (projectRootPath !== undefined) { - possibleSearchDirs.push(projectRootPath); - } - searchDirs = ts.deduplicate(possibleSearchDirs); - for (var _i = 0, searchDirs_1 = searchDirs; _i < searchDirs_1.length; _i++) { - var searchDir = searchDirs_1[_i]; - var packageJsonPath = ts.combinePaths(searchDir, "package.json"); - getTypingNamesFromJson(packageJsonPath, filesToWatch); - var bowerJsonPath = ts.combinePaths(searchDir, "bower.json"); - getTypingNamesFromJson(bowerJsonPath, filesToWatch); - var nodeModulesPath = ts.combinePaths(searchDir, "node_modules"); - getTypingNamesFromNodeModuleFolder(nodeModulesPath); - } - getTypingNamesFromSourceFileNames(fileNames); - for (var name_7 in packageNameToTypingLocation) { - if (name_7 in inferredTypings && !inferredTypings[name_7]) { - inferredTypings[name_7] = packageNameToTypingLocation[name_7]; - } - } - for (var _a = 0, exclude_1 = exclude; _a < exclude_1.length; _a++) { - var excludeTypingName = exclude_1[_a]; - delete inferredTypings[excludeTypingName]; - } - var newTypingNames = []; - var cachedTypingPaths = []; - for (var typing in inferredTypings) { - if (inferredTypings[typing] !== undefined) { - cachedTypingPaths.push(inferredTypings[typing]); - } - else { - newTypingNames.push(typing); - } - } - return { cachedTypingPaths: cachedTypingPaths, newTypingNames: newTypingNames, filesToWatch: filesToWatch }; - function mergeTypings(typingNames) { - if (!typingNames) { - return; - } - for (var _i = 0, typingNames_1 = typingNames; _i < typingNames_1.length; _i++) { - var typing = typingNames_1[_i]; - if (!(typing in inferredTypings)) { - inferredTypings[typing] = undefined; - } - } - } - function getTypingNamesFromJson(jsonPath, filesToWatch) { - var result = ts.readConfigFile(jsonPath, function (path) { return host.readFile(path); }); - if (result.config) { - var jsonConfig = result.config; - filesToWatch.push(jsonPath); - if (jsonConfig.dependencies) { - mergeTypings(ts.getOwnKeys(jsonConfig.dependencies)); - } - if (jsonConfig.devDependencies) { - mergeTypings(ts.getOwnKeys(jsonConfig.devDependencies)); - } - if (jsonConfig.optionalDependencies) { - mergeTypings(ts.getOwnKeys(jsonConfig.optionalDependencies)); - } - if (jsonConfig.peerDependencies) { - mergeTypings(ts.getOwnKeys(jsonConfig.peerDependencies)); - } - } - } - function getTypingNamesFromSourceFileNames(fileNames) { - var jsFileNames = ts.filter(fileNames, ts.hasJavaScriptFileExtension); - var inferredTypingNames = ts.map(jsFileNames, function (f) { return ts.removeFileExtension(ts.getBaseFileName(f.toLowerCase())); }); - var cleanedTypingNames = ts.map(inferredTypingNames, function (f) { return f.replace(/((?:\.|-)min(?=\.|$))|((?:-|\.)\d+)/g, ""); }); - if (safeList !== EmptySafeList) { - mergeTypings(ts.filter(cleanedTypingNames, function (f) { return f in safeList; })); - } - var hasJsxFile = ts.forEach(fileNames, function (f) { return ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)) === 2; }); - if (hasJsxFile) { - mergeTypings(["react"]); - } - } - function getTypingNamesFromNodeModuleFolder(nodeModulesPath) { - if (!host.directoryExists(nodeModulesPath)) { - return; - } - var typingNames = []; - var fileNames = host.readDirectory(nodeModulesPath, [".json"], undefined, undefined, 2); - for (var _i = 0, fileNames_2 = fileNames; _i < fileNames_2.length; _i++) { - var fileName = fileNames_2[_i]; - var normalizedFileName = ts.normalizePath(fileName); - if (ts.getBaseFileName(normalizedFileName) !== "package.json") { - continue; - } - var result = ts.readConfigFile(normalizedFileName, function (path) { return host.readFile(path); }); - if (!result.config) { - continue; - } - var packageJson = result.config; - if (packageJson._requiredBy && - ts.filter(packageJson._requiredBy, function (r) { return r[0] === "#" || r === "/"; }).length === 0) { - continue; - } - if (!packageJson.name) { - continue; - } - if (packageJson.typings) { - var absolutePath = ts.getNormalizedAbsolutePath(packageJson.typings, ts.getDirectoryPath(normalizedFileName)); - inferredTypings[packageJson.name] = absolutePath; - } - else { - typingNames.push(packageJson.name); - } - } - mergeTypings(typingNames); - } - } - JsTyping.discoverTypings = discoverTypings; - })(JsTyping = ts.JsTyping || (ts.JsTyping = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - var server; - (function (server) { - (function (LogLevel) { - LogLevel[LogLevel["terse"] = 0] = "terse"; - LogLevel[LogLevel["normal"] = 1] = "normal"; - LogLevel[LogLevel["requestTime"] = 2] = "requestTime"; - LogLevel[LogLevel["verbose"] = 3] = "verbose"; - })(server.LogLevel || (server.LogLevel = {})); - var LogLevel = server.LogLevel; - server.emptyArray = []; - var Msg; - (function (Msg) { - Msg.Err = "Err"; - Msg.Info = "Info"; - Msg.Perf = "Perf"; - })(Msg = server.Msg || (server.Msg = {})); - function getProjectRootPath(project) { - switch (project.projectKind) { - case server.ProjectKind.Configured: - return ts.getDirectoryPath(project.getProjectName()); - case server.ProjectKind.Inferred: - return ""; - case server.ProjectKind.External: - var projectName = ts.normalizeSlashes(project.getProjectName()); - return project.projectService.host.fileExists(projectName) ? ts.getDirectoryPath(projectName) : projectName; - } - } - function createInstallTypingsRequest(project, typingOptions, cachePath) { - return { - projectName: project.getProjectName(), - fileNames: project.getFileNames(), - compilerOptions: project.getCompilerOptions(), - typingOptions: typingOptions, - projectRootPath: getProjectRootPath(project), - cachePath: cachePath, - kind: "discover" - }; - } - server.createInstallTypingsRequest = createInstallTypingsRequest; - var Errors; - (function (Errors) { - function ThrowNoProject() { - throw new Error("No Project."); - } - Errors.ThrowNoProject = ThrowNoProject; - function ThrowProjectLanguageServiceDisabled() { - throw new Error("The project's language service is disabled."); - } - Errors.ThrowProjectLanguageServiceDisabled = ThrowProjectLanguageServiceDisabled; - function ThrowProjectDoesNotContainDocument(fileName, project) { - throw new Error("Project '" + project.getProjectName() + "' does not contain document '" + fileName + "'"); - } - Errors.ThrowProjectDoesNotContainDocument = ThrowProjectDoesNotContainDocument; - })(Errors = server.Errors || (server.Errors = {})); - function getDefaultFormatCodeSettings(host) { - return { - indentSize: 4, - tabSize: 4, - newLineCharacter: host.newLine || "\n", - convertTabsToSpaces: true, - indentStyle: ts.IndentStyle.Smart, - insertSpaceAfterCommaDelimiter: true, - insertSpaceAfterSemicolonInForStatements: true, - insertSpaceBeforeAndAfterBinaryOperators: true, - insertSpaceAfterKeywordsInControlFlowStatements: true, - insertSpaceAfterFunctionKeywordForAnonymousFunctions: false, - insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, - insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, - insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, - insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, - placeOpenBraceOnNewLineForFunctions: false, - placeOpenBraceOnNewLineForControlBlocks: false - }; - } - server.getDefaultFormatCodeSettings = getDefaultFormatCodeSettings; - function mergeMaps(target, source) { - for (var key in source) { - if (ts.hasProperty(source, key)) { - target[key] = source[key]; - } - } - } - server.mergeMaps = mergeMaps; - function removeItemFromSet(items, itemToRemove) { - if (items.length === 0) { - return; - } - var index = items.indexOf(itemToRemove); - if (index < 0) { - return; - } - if (index === items.length - 1) { - items.pop(); - } - else { - items[index] = items.pop(); - } - } - server.removeItemFromSet = removeItemFromSet; - function toNormalizedPath(fileName) { - return ts.normalizePath(fileName); - } - server.toNormalizedPath = toNormalizedPath; - function normalizedPathToPath(normalizedPath, currentDirectory, getCanonicalFileName) { - var f = ts.isRootedDiskPath(normalizedPath) ? normalizedPath : ts.getNormalizedAbsolutePath(normalizedPath, currentDirectory); - return getCanonicalFileName(f); - } - server.normalizedPathToPath = normalizedPathToPath; - function asNormalizedPath(fileName) { - return fileName; - } - server.asNormalizedPath = asNormalizedPath; - function createNormalizedPathMap() { - var map = Object.create(null); - return { - get: function (path) { - return map[path]; - }, - set: function (path, value) { - map[path] = value; - }, - contains: function (path) { - return ts.hasProperty(map, path); - }, - remove: function (path) { - delete map[path]; - } - }; - } - server.createNormalizedPathMap = createNormalizedPathMap; - function throwLanguageServiceIsDisabledError() { - throw new Error("LanguageService is disabled"); - } - server.nullLanguageService = { - cleanupSemanticCache: throwLanguageServiceIsDisabledError, - getSyntacticDiagnostics: throwLanguageServiceIsDisabledError, - getSemanticDiagnostics: throwLanguageServiceIsDisabledError, - getCompilerOptionsDiagnostics: throwLanguageServiceIsDisabledError, - getSyntacticClassifications: throwLanguageServiceIsDisabledError, - getEncodedSyntacticClassifications: throwLanguageServiceIsDisabledError, - getSemanticClassifications: throwLanguageServiceIsDisabledError, - getEncodedSemanticClassifications: throwLanguageServiceIsDisabledError, - getCompletionsAtPosition: throwLanguageServiceIsDisabledError, - findReferences: throwLanguageServiceIsDisabledError, - getCompletionEntryDetails: throwLanguageServiceIsDisabledError, - getQuickInfoAtPosition: throwLanguageServiceIsDisabledError, - findRenameLocations: throwLanguageServiceIsDisabledError, - getNameOrDottedNameSpan: throwLanguageServiceIsDisabledError, - getBreakpointStatementAtPosition: throwLanguageServiceIsDisabledError, - getBraceMatchingAtPosition: throwLanguageServiceIsDisabledError, - getSignatureHelpItems: throwLanguageServiceIsDisabledError, - getDefinitionAtPosition: throwLanguageServiceIsDisabledError, - getRenameInfo: throwLanguageServiceIsDisabledError, - getTypeDefinitionAtPosition: throwLanguageServiceIsDisabledError, - getReferencesAtPosition: throwLanguageServiceIsDisabledError, - getDocumentHighlights: throwLanguageServiceIsDisabledError, - getOccurrencesAtPosition: throwLanguageServiceIsDisabledError, - getNavigateToItems: throwLanguageServiceIsDisabledError, - getNavigationBarItems: throwLanguageServiceIsDisabledError, - getNavigationTree: throwLanguageServiceIsDisabledError, - getOutliningSpans: throwLanguageServiceIsDisabledError, - getTodoComments: throwLanguageServiceIsDisabledError, - getIndentationAtPosition: throwLanguageServiceIsDisabledError, - getFormattingEditsForRange: throwLanguageServiceIsDisabledError, - getFormattingEditsForDocument: throwLanguageServiceIsDisabledError, - getFormattingEditsAfterKeystroke: throwLanguageServiceIsDisabledError, - getDocCommentTemplateAtPosition: throwLanguageServiceIsDisabledError, - isValidBraceCompletionAtPosition: throwLanguageServiceIsDisabledError, - getEmitOutput: throwLanguageServiceIsDisabledError, - getProgram: throwLanguageServiceIsDisabledError, - getNonBoundSourceFile: throwLanguageServiceIsDisabledError, - dispose: throwLanguageServiceIsDisabledError, - getCompletionEntrySymbol: throwLanguageServiceIsDisabledError, - getImplementationAtPosition: throwLanguageServiceIsDisabledError, - getSourceFile: throwLanguageServiceIsDisabledError, - getCodeFixesAtPosition: throwLanguageServiceIsDisabledError - }; - server.nullLanguageServiceHost = { - setCompilationSettings: function () { return undefined; }, - notifyFileRemoved: function () { return undefined; } - }; - function isInferredProjectName(name) { - return /dev\/null\/inferredProject\d+\*/.test(name); - } - server.isInferredProjectName = isInferredProjectName; - function makeInferredProjectName(counter) { - return "/dev/null/inferredProject" + counter + "*"; - } - server.makeInferredProjectName = makeInferredProjectName; - var ThrottledOperations = (function () { - function ThrottledOperations(host) { - this.host = host; - this.pendingTimeouts = ts.createMap(); - } - ThrottledOperations.prototype.schedule = function (operationId, delay, cb) { - if (ts.hasProperty(this.pendingTimeouts, operationId)) { - this.host.clearTimeout(this.pendingTimeouts[operationId]); - } - this.pendingTimeouts[operationId] = this.host.setTimeout(ThrottledOperations.run, delay, this, operationId, cb); - }; - ThrottledOperations.run = function (self, operationId, cb) { - delete self.pendingTimeouts[operationId]; - cb(); - }; - return ThrottledOperations; - }()); - server.ThrottledOperations = ThrottledOperations; - var GcTimer = (function () { - function GcTimer(host, delay, logger) { - this.host = host; - this.delay = delay; - this.logger = logger; - } - GcTimer.prototype.scheduleCollect = function () { - if (!this.host.gc || this.timerId != undefined) { - return; - } - this.timerId = this.host.setTimeout(GcTimer.run, this.delay, this); - }; - GcTimer.run = function (self) { - self.timerId = undefined; - var log = self.logger.hasLevel(LogLevel.requestTime); - var before = log && self.host.getMemoryUsage(); - self.host.gc(); - if (log) { - var after = self.host.getMemoryUsage(); - self.logger.perftrc("GC::before " + before + ", after " + after); - } - }; - return GcTimer; - }()); - server.GcTimer = GcTimer; - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - function trace(host, message) { + function trace(host) { host.trace(ts.formatMessage.apply(undefined, arguments)); } ts.trace = trace; @@ -6668,11 +4583,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 199: - case 227: - case 206: + case 200: + case 228: case 207: case 208: + case 209: return true; } return false; @@ -6793,13 +4708,13 @@ var ts; switch (node.kind) { case 9: return getQuotedEscapedLiteralText('"', node.text, '"'); - case 11: - return getQuotedEscapedLiteralText("`", node.text, "`"); case 12: - return getQuotedEscapedLiteralText("`", node.text, "${"); + return getQuotedEscapedLiteralText("`", node.text, "`"); case 13: - return getQuotedEscapedLiteralText("}", node.text, "${"); + return getQuotedEscapedLiteralText("`", node.text, "${"); case 14: + return getQuotedEscapedLiteralText("}", node.text, "${"); + case 15: return getQuotedEscapedLiteralText("}", node.text, "`"); case 8: return node.text; @@ -6841,7 +4756,7 @@ var ts; } ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isAmbientModule(node) { - return node && node.kind === 225 && + return node && node.kind === 226 && (node.name.kind === 9 || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; @@ -6850,11 +4765,11 @@ var ts; } ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { - return node.kind === 225 && (!node.body); + return node.kind === 226 && (!node.body); } function isBlockScopedContainerTopLevel(node) { return node.kind === 256 || - node.kind === 225 || + node.kind === 226 || isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -6869,7 +4784,7 @@ var ts; switch (node.parent.kind) { case 256: return ts.isExternalModule(node.parent); - case 226: + case 227: return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -6878,21 +4793,21 @@ var ts; function isBlockScope(node, parentNode) { switch (node.kind) { case 256: - case 227: + case 228: case 252: - case 225: - case 206: + case 226: case 207: case 208: - case 148: - case 147: + case 209: case 149: + case 148: case 150: - case 220: - case 179: + case 151: + case 221: case 180: + case 181: return true; - case 199: + case 200: return parentNode && !isFunctionLike(parentNode); } return false; @@ -6910,7 +4825,7 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 218 && + declaration.kind === 219 && declaration.parent && declaration.parent.kind === 252; } @@ -6947,7 +4862,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 199) { + if (node.body && node.body.kind === 200) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -6965,23 +4880,23 @@ var ts; return ts.createTextSpan(0, 0); } return getSpanOfTokenAtPosition(sourceFile, pos_1); - case 218: - case 169: - case 221: - case 192: + case 219: + case 170: case 222: - case 225: - case 224: - case 255: - case 220: - case 179: - case 147: - case 149: - case 150: + case 193: case 223: + case 226: + case 225: + case 255: + case 221: + case 180: + case 148: + case 150: + case 151: + case 224: errorNode = node.name; break; - case 180: + case 181: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -7002,7 +4917,7 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 224 && isConst(node); + return node.kind === 225 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -7015,11 +4930,11 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 174 && n.expression.kind === 95; + return n.kind === 175 && n.expression.kind === 96; } ts.isSuperCall = isSuperCall; function isPrologueDirective(node) { - return node.kind === 202 && node.expression.kind === 9; + return node.kind === 203 && node.expression.kind === 9; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { @@ -7035,10 +4950,10 @@ var ts; } ts.getJsDocComments = getJsDocComments; function getJsDocCommentsFromText(node, text) { - var commentRanges = (node.kind === 142 || - node.kind === 141 || - node.kind === 179 || - node.kind === 180) ? + var commentRanges = (node.kind === 143 || + node.kind === 142 || + node.kind === 180 || + node.kind === 181) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : getLeadingCommentRangesOfNodeFromText(node, text); return ts.filter(commentRanges, isJsDocComment); @@ -7053,69 +4968,69 @@ var ts; ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (154 <= node.kind && node.kind <= 166) { + if (155 <= node.kind && node.kind <= 167) { return true; } switch (node.kind) { - case 117: - case 130: - case 132: - case 120: + case 118: + case 131: case 133: - case 135: - case 127: + case 121: + case 134: + case 136: + case 128: return true; - case 103: - return node.parent.kind !== 183; - case 194: + case 104: + return node.parent.kind !== 184; + case 195: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 69: - if (node.parent.kind === 139 && node.parent.right === node) { + case 70: + if (node.parent.kind === 140 && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 172 && node.parent.name === node) { + else if (node.parent.kind === 173 && node.parent.name === node) { node = node.parent; } - ts.Debug.assert(node.kind === 69 || node.kind === 139 || node.kind === 172, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); - case 139: - case 172: - case 97: + ts.Debug.assert(node.kind === 70 || node.kind === 140 || node.kind === 173, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + case 140: + case 173: + case 98: var parent_2 = node.parent; - if (parent_2.kind === 158) { + if (parent_2.kind === 159) { return false; } - if (154 <= parent_2.kind && parent_2.kind <= 166) { + if (155 <= parent_2.kind && parent_2.kind <= 167) { return true; } switch (parent_2.kind) { - case 194: + case 195: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); - case 141: - return node === parent_2.constraint; - case 145: - case 144: case 142: - case 218: + return node === parent_2.constraint; + case 146: + case 145: + case 143: + case 219: return node === parent_2.type; - case 220: - case 179: + case 221: case 180: + case 181: + case 149: case 148: case 147: - case 146: - case 149: case 150: - return node === parent_2.type; case 151: + return node === parent_2.type; case 152: case 153: + case 154: return node === parent_2.type; - case 177: + case 178: return node === parent_2.type; - case 174: case 175: - return parent_2.typeArguments && ts.indexOf(parent_2.typeArguments, node) >= 0; case 176: + return parent_2.typeArguments && ts.indexOf(parent_2.typeArguments, node) >= 0; + case 177: return false; } } @@ -7126,22 +5041,22 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 211: + case 212: return visitor(node); - case 227: - case 199: - case 203: + case 228: + case 200: case 204: case 205: case 206: case 207: case 208: - case 212: + case 209: case 213: + case 214: case 249: case 250: - case 214: - case 216: + case 215: + case 217: case 252: return ts.forEachChild(node, traverse); } @@ -7152,24 +5067,24 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 190: + case 191: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 224: - case 222: case 225: case 223: - case 221: - case 192: + case 226: + case 224: + case 222: + case 193: return; default: if (isFunctionLike(node)) { - var name_8 = node.name; - if (name_8 && name_8.kind === 140) { - traverse(name_8.expression); + var name_4 = node.name; + if (name_4 && name_4.kind === 141) { + traverse(name_4.expression); return; } } @@ -7183,14 +5098,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 169: + case 170: case 255: - case 142: + case 143: case 253: + case 146: case 145: - case 144: case 254: - case 218: + case 219: return true; } } @@ -7198,11 +5113,11 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 149 || node.kind === 150); + return node && (node.kind === 150 || node.kind === 151); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 221 || node.kind === 192); + return node && (node.kind === 222 || node.kind === 193); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -7211,19 +5126,19 @@ var ts; ts.isFunctionLike = isFunctionLike; function isFunctionLikeKind(kind) { switch (kind) { - case 148: - case 179: - case 220: - case 180: - case 147: - case 146: case 149: + case 180: + case 221: + case 181: + case 148: + case 147: case 150: case 151: case 152: case 153: - case 156: + case 154: case 157: + case 158: return true; } return false; @@ -7231,13 +5146,13 @@ var ts; ts.isFunctionLikeKind = isFunctionLikeKind; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 147: - case 146: case 148: + case 147: case 149: case 150: - case 220: - case 179: + case 151: + case 221: + case 180: return true; } return false; @@ -7245,30 +5160,30 @@ var ts; ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 206: case 207: case 208: - case 204: + case 209: case 205: + case 206: return true; - case 214: + case 215: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; function isFunctionBlock(node) { - return node && node.kind === 199 && isFunctionLike(node.parent); + return node && node.kind === 200 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 147 && node.parent.kind === 171; + return node && node.kind === 148 && node.parent.kind === 172; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 147 && - (node.parent.kind === 171 || - node.parent.kind === 192); + return node.kind === 148 && + (node.parent.kind === 172 || + node.parent.kind === 193); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -7304,38 +5219,38 @@ var ts; return undefined; } switch (node.kind) { - case 140: + case 141: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 143: - if (node.parent.kind === 142 && isClassElement(node.parent.parent)) { + case 144: + if (node.parent.kind === 143 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 180: + case 181: if (!includeArrowFunctions) { continue; } - case 220: - case 179: - case 225: - case 145: - case 144: - case 147: + case 221: + case 180: + case 226: case 146: + case 145: case 148: + case 147: case 149: case 150: case 151: case 152: case 153: - case 224: + case 154: + case 225: case 256: return node; } @@ -7349,25 +5264,25 @@ var ts; return node; } switch (node.kind) { - case 140: + case 141: node = node.parent; break; - case 220: - case 179: + case 221: case 180: + case 181: if (!stopOnFunctions) { continue; } - case 145: - case 144: - case 147: case 146: + case 145: case 148: + case 147: case 149: case 150: + case 151: return node; - case 143: - if (node.parent.kind === 142 && isClassElement(node.parent.parent)) { + case 144: + if (node.parent.kind === 143 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { @@ -7379,14 +5294,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 179 || func.kind === 180) { + if (func.kind === 180 || func.kind === 181) { var prev = func; var parent_3 = func.parent; - while (parent_3.kind === 178) { + while (parent_3.kind === 179) { prev = parent_3; parent_3 = parent_3.parent; } - if (parent_3.kind === 174 && parent_3.expression === prev) { + if (parent_3.kind === 175 && parent_3.expression === prev) { return parent_3; } } @@ -7394,20 +5309,20 @@ var ts; ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperProperty(node) { var kind = node.kind; - return (kind === 172 || kind === 173) - && node.expression.kind === 95; + return (kind === 173 || kind === 174) + && node.expression.kind === 96; } ts.isSuperProperty = isSuperProperty; function getEntityNameFromTypeNode(node) { if (node) { switch (node.kind) { - case 155: + case 156: return node.typeName; - case 194: + case 195: ts.Debug.assert(isEntityNameExpression(node.expression)); return node.expression; - case 69: - case 139: + case 70: + case 140: return node; } } @@ -7416,10 +5331,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function isCallLikeExpression(node) { switch (node.kind) { - case 174: case 175: case 176: - case 143: + case 177: + case 144: return true; default: return false; @@ -7427,7 +5342,7 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function getInvokedExpression(node) { - if (node.kind === 176) { + if (node.kind === 177) { return node.tag; } return node.expression; @@ -7435,21 +5350,21 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 221: + case 222: return true; - case 145: - return node.parent.kind === 221; - case 149: + case 146: + return node.parent.kind === 222; case 150: - case 147: + case 151: + case 148: return node.body !== undefined - && node.parent.kind === 221; - case 142: + && node.parent.kind === 222; + case 143: return node.parent.body !== undefined - && (node.parent.kind === 148 - || node.parent.kind === 147 - || node.parent.kind === 150) - && node.parent.parent.kind === 221; + && (node.parent.kind === 149 + || node.parent.kind === 148 + || node.parent.kind === 151) + && node.parent.parent.kind === 222; } return false; } @@ -7465,18 +5380,18 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 221: + case 222: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 147: - case 150: + case 148: + case 151: return ts.forEach(node.parameters, nodeIsDecorated); } } ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 243 || - parent.kind === 242 || + if (parent.kind === 244 || + parent.kind === 243 || parent.kind === 245) { return parent.tagName === node; } @@ -7485,97 +5400,97 @@ var ts; ts.isJSXTagName = isJSXTagName; function isPartOfExpression(node) { switch (node.kind) { - case 97: - case 95: - case 93: - case 99: - case 84: - case 10: - case 170: + case 98: + case 96: + case 94: + case 100: + case 85: + case 11: case 171: case 172: case 173: case 174: case 175: case 176: - case 195: case 177: case 196: case 178: + case 197: case 179: - case 192: case 180: - case 183: + case 193: case 181: + case 184: case 182: - case 185: + case 183: case 186: case 187: case 188: - case 191: case 189: - case 11: - case 193: - case 241: - case 242: + case 192: case 190: - case 184: + case 12: + case 194: + case 242: + case 243: + case 191: + case 185: return true; - case 139: - while (node.parent.kind === 139) { + case 140: + while (node.parent.kind === 140) { node = node.parent; } - return node.parent.kind === 158 || isJSXTagName(node); - case 69: - if (node.parent.kind === 158 || isJSXTagName(node)) { + return node.parent.kind === 159 || isJSXTagName(node); + case 70: + if (node.parent.kind === 159 || isJSXTagName(node)) { return true; } case 8: case 9: - case 97: + case 98: var parent_4 = node.parent; switch (parent_4.kind) { - case 218: - case 142: + case 219: + case 143: + case 146: case 145: - case 144: case 255: case 253: - case 169: + case 170: return parent_4.initializer === node; - case 202: case 203: case 204: case 205: - case 211: + case 206: case 212: case 213: + case 214: case 249: - case 215: - case 213: + case 216: + case 214: return parent_4.expression === node; - case 206: + case 207: var forStatement = parent_4; - return (forStatement.initializer === node && forStatement.initializer.kind !== 219) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 220) || forStatement.condition === node || forStatement.incrementor === node; - case 207: case 208: + case 209: var forInStatement = parent_4; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 219) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 220) || forInStatement.expression === node; - case 177: - case 195: + case 178: + case 196: return node === parent_4.expression; - case 197: + case 198: return node === parent_4.expression; - case 140: + case 141: return node === parent_4.expression; - case 143: + case 144: case 248: case 247: return true; - case 194: + case 195: return parent_4.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_4); default: if (isPartOfExpression(parent_4)) { @@ -7593,7 +5508,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 229 && node.moduleReference.kind === 240; + return node.kind === 230 && node.moduleReference.kind === 241; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -7602,7 +5517,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 229 && node.moduleReference.kind !== 240; + return node.kind === 230 && node.moduleReference.kind !== 241; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -7614,8 +5529,8 @@ var ts; } ts.isInJavaScriptFile = isInJavaScriptFile; function isRequireCall(expression, checkArgumentIsStringLiteral) { - var isRequire = expression.kind === 174 && - expression.expression.kind === 69 && + var isRequire = expression.kind === 175 && + expression.expression.kind === 70 && expression.expression.text === "require" && expression.arguments.length === 1; return isRequire && (!checkArgumentIsStringLiteral || expression.arguments[0].kind === 9); @@ -7626,9 +5541,9 @@ var ts; } ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote; function isDeclarationOfFunctionExpression(s) { - if (s.valueDeclaration && s.valueDeclaration.kind === 218) { + if (s.valueDeclaration && s.valueDeclaration.kind === 219) { var declaration = s.valueDeclaration; - return declaration.initializer && declaration.initializer.kind === 179; + return declaration.initializer && declaration.initializer.kind === 180; } return false; } @@ -7637,15 +5552,15 @@ var ts; if (!isInJavaScriptFile(expression)) { return 0; } - if (expression.kind !== 187) { + if (expression.kind !== 188) { return 0; } var expr = expression; - if (expr.operatorToken.kind !== 56 || expr.left.kind !== 172) { + if (expr.operatorToken.kind !== 57 || expr.left.kind !== 173) { return 0; } var lhs = expr.left; - if (lhs.expression.kind === 69) { + if (lhs.expression.kind === 70) { var lhsId = lhs.expression; if (lhsId.text === "exports") { return 1; @@ -7654,12 +5569,12 @@ var ts; return 2; } } - else if (lhs.expression.kind === 97) { + else if (lhs.expression.kind === 98) { return 4; } - else if (lhs.expression.kind === 172) { + else if (lhs.expression.kind === 173) { var innerPropertyAccess = lhs.expression; - if (innerPropertyAccess.expression.kind === 69) { + if (innerPropertyAccess.expression.kind === 70) { var innerPropertyAccessIdentifier = innerPropertyAccess.expression; if (innerPropertyAccessIdentifier.text === "module" && innerPropertyAccess.name.text === "exports") { return 1; @@ -7673,35 +5588,35 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 230) { + if (node.kind === 231) { return node.moduleSpecifier; } - if (node.kind === 229) { + if (node.kind === 230) { var reference = node.moduleReference; - if (reference.kind === 240) { + if (reference.kind === 241) { return reference.expression; } } - if (node.kind === 236) { + if (node.kind === 237) { return node.moduleSpecifier; } - if (node.kind === 225 && node.name.kind === 9) { + if (node.kind === 226 && node.name.kind === 9) { return node.name; } } ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { - if (node.kind === 229) { + if (node.kind === 230) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 232) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 233) { return importClause.namedBindings; } } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 230 + return node.kind === 231 && node.importClause && !!node.importClause.name; } @@ -7709,13 +5624,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 142: + case 143: + case 148: case 147: - case 146: case 254: case 253: + case 146: case 145: - case 144: return node.questionToken !== undefined; } } @@ -7776,24 +5691,24 @@ var ts; if (checkParentVariableStatement) { var isInitializerOfVariableDeclarationInStatement = isVariableLike(node.parent) && (node.parent).initializer === node && - node.parent.parent.parent.kind === 200; + node.parent.parent.parent.kind === 201; var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - node.parent.parent.kind === 200; + node.parent.parent.kind === 201; var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? node.parent.parent.parent : isVariableOfVariableDeclarationStatement ? node.parent.parent : undefined; if (variableStatementNode) { result = append(result, getJSDocs(variableStatementNode, checkParentVariableStatement, getDocs, getTags)); } - if (node.kind === 225 && - node.parent && node.parent.kind === 225) { + if (node.kind === 226 && + node.parent && node.parent.kind === 226) { result = append(result, getJSDocs(node.parent, checkParentVariableStatement, getDocs, getTags)); } var parent_5 = node.parent; var isSourceOfAssignmentExpressionStatement = parent_5 && parent_5.parent && - parent_5.kind === 187 && - parent_5.operatorToken.kind === 56 && - parent_5.parent.kind === 202; + parent_5.kind === 188 && + parent_5.operatorToken.kind === 57 && + parent_5.parent.kind === 203; if (isSourceOfAssignmentExpressionStatement) { result = append(result, getJSDocs(parent_5.parent, checkParentVariableStatement, getDocs, getTags)); } @@ -7801,7 +5716,7 @@ var ts; if (isPropertyAssignmentExpression) { result = append(result, getJSDocs(parent_5, checkParentVariableStatement, getDocs, getTags)); } - if (node.kind === 142) { + if (node.kind === 143) { var paramTags = getJSDocParameterTag(node, checkParentVariableStatement); if (paramTags) { result = append(result, getTags(paramTags)); @@ -7831,9 +5746,9 @@ var ts; return [paramTags[i]]; } } - else if (param.name.kind === 69) { - var name_9 = param.name.text; - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 275 && tag.parameterName.text === name_9; }); + else if (param.name.kind === 70) { + var name_5 = param.name.text; + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 275 && tag.parameterName.text === name_5; }); if (paramTags) { return paramTags; } @@ -7855,7 +5770,7 @@ var ts; } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { - if (parameter.name && parameter.name.kind === 69) { + if (parameter.name && parameter.name.kind === 70) { var parameterName = parameter.name.text; var jsDocTags = getJSDocTags(parameter.parent, true); if (!jsDocTags) { @@ -7900,12 +5815,12 @@ var ts; } ts.isDeclaredRestParam = isDeclaredRestParam; function isAssignmentTarget(node) { - while (node.parent.kind === 178) { + while (node.parent.kind === 179) { node = node.parent; } while (true) { var parent_6 = node.parent; - if (parent_6.kind === 170 || parent_6.kind === 191) { + if (parent_6.kind === 171 || parent_6.kind === 192) { node = parent_6; continue; } @@ -7913,10 +5828,10 @@ var ts; node = parent_6.parent; continue; } - return parent_6.kind === 187 && + return parent_6.kind === 188 && isAssignmentOperator(parent_6.operatorToken.kind) && parent_6.left === node || - (parent_6.kind === 207 || parent_6.kind === 208) && + (parent_6.kind === 208 || parent_6.kind === 209) && parent_6.initializer === node; } } @@ -7941,11 +5856,11 @@ var ts; } ts.isInAmbientContext = isInAmbientContext; function isDeclarationName(name) { - if (name.kind !== 69 && name.kind !== 9 && name.kind !== 8) { + if (name.kind !== 70 && name.kind !== 9 && name.kind !== 8) { return false; } var parent = name.parent; - if (parent.kind === 234 || parent.kind === 238) { + if (parent.kind === 235 || parent.kind === 239) { if (parent.propertyName) { return true; } @@ -7958,48 +5873,48 @@ var ts; ts.isDeclarationName = isDeclarationName; function isLiteralComputedPropertyDeclarationName(node) { return (node.kind === 9 || node.kind === 8) && - node.parent.kind === 140 && + node.parent.kind === 141 && isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 145: - case 144: - case 147: case 146: - case 149: + case 145: + case 148: + case 147: case 150: + case 151: case 255: case 253: - case 172: + case 173: return parent.name === node; - case 139: + case 140: if (parent.right === node) { - while (parent.kind === 139) { + while (parent.kind === 140) { parent = parent.parent; } - return parent.kind === 158; + return parent.kind === 159; } return false; - case 169: - case 234: + case 170: + case 235: return parent.propertyName === node; - case 238: + case 239: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 229 || - node.kind === 228 || - node.kind === 231 && !!node.name || - node.kind === 232 || - node.kind === 234 || - node.kind === 238 || - node.kind === 235 && exportAssignmentIsAlias(node); + return node.kind === 230 || + node.kind === 229 || + node.kind === 232 && !!node.name || + node.kind === 233 || + node.kind === 235 || + node.kind === 239 || + node.kind === 236 && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function exportAssignmentIsAlias(node) { @@ -8007,17 +5922,17 @@ var ts; } ts.exportAssignmentIsAlias = exportAssignmentIsAlias; function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 83); + var heritageClause = getHeritageClause(node.heritageClauses, 84); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 106); + var heritageClause = getHeritageClause(node.heritageClauses, 107); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 83); + var heritageClause = getHeritageClause(node.heritageClauses, 84); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -8085,7 +6000,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 70 <= token && token <= 138; + return 71 <= token && token <= 139; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -8105,7 +6020,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 140 && + return name.kind === 141 && !isStringOrNumericLiteral(name.expression.kind) && !isWellKnownSymbolSyntactically(name.expression); } @@ -8115,10 +6030,10 @@ var ts; } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 69 || name.kind === 9 || name.kind === 8 || name.kind === 142) { + if (name.kind === 70 || name.kind === 9 || name.kind === 8 || name.kind === 143) { return name.text; } - if (name.kind === 140) { + if (name.kind === 141) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -8136,22 +6051,26 @@ var ts; } ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; function isESSymbolIdentifier(node) { - return node.kind === 69 && node.text === "Symbol"; + return node.kind === 70 && node.text === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; + function isPushOrUnshiftIdentifier(node) { + return node.text === "push" || node.text === "unshift"; + } + ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isModifierKind(token) { switch (token) { - case 115: - case 118: - case 74: - case 122: - case 77: - case 82: - case 112: - case 110: - case 111: - case 128: + case 116: + case 119: + case 75: + case 123: + case 78: + case 83: case 113: + case 111: + case 112: + case 129: + case 114: return true; } return false; @@ -8159,11 +6078,11 @@ var ts; ts.isModifierKind = isModifierKind; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 142; + return root.kind === 143; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 169) { + while (node.kind === 170) { node = node.parent.parent; } return node; @@ -8171,14 +6090,14 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 148 - || kind === 179 - || kind === 220 + return kind === 149 || kind === 180 - || kind === 147 - || kind === 149 + || kind === 221 + || kind === 181 + || kind === 148 || kind === 150 - || kind === 225 + || kind === 151 + || kind === 226 || kind === 256; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; @@ -8228,40 +6147,45 @@ var ts; return node ? ts.getNodeId(node) : 0; } ts.getOriginalNodeId = getOriginalNodeId; + (function (Associativity) { + Associativity[Associativity["Left"] = 0] = "Left"; + Associativity[Associativity["Right"] = 1] = "Right"; + })(ts.Associativity || (ts.Associativity = {})); + var Associativity = ts.Associativity; function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 175 && expression.arguments !== undefined; + var hasArguments = expression.kind === 176 && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 175: + case 176: return hasArguments ? 0 : 1; - case 185: - case 182: + case 186: case 183: - case 181: case 184: - case 188: - case 190: + case 182: + case 185: + case 189: + case 191: return 1; - case 187: + case 188: switch (operator) { - case 38: - case 56: + case 39: case 57: case 58: - case 60: case 59: case 61: + case 60: case 62: case 63: case 64: case 65: case 66: - case 68: case 67: + case 69: + case 68: return 1; } } @@ -8270,15 +6194,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 175 && expression.arguments !== undefined; + var hasArguments = expression.kind === 176 && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 187) { + if (expression.kind === 188) { return expression.operatorToken.kind; } - else if (expression.kind === 185 || expression.kind === 186) { + else if (expression.kind === 186 || expression.kind === 187) { return expression.operator; } else { @@ -8288,106 +6212,106 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 97: - case 95: - case 69: - case 93: - case 99: - case 84: + case 98: + case 96: + case 70: + case 94: + case 100: + case 85: case 8: case 9: - case 170: case 171: - case 179: - case 180: - case 192: - case 241: - case 242: - case 10: - case 11: - case 189: - case 178: - case 193: - return 19; - case 176: case 172: - case 173: - return 18; - case 175: - return hasArguments ? 18 : 17; - case 174: - return 17; - case 186: - return 16; - case 185: - case 182: - case 183: + case 180: case 181: - case 184: - return 15; + case 193: + case 242: + case 243: + case 11: + case 12: + case 190: + case 179: + case 194: + return 19; + case 177: + case 173: + case 174: + return 18; + case 176: + return hasArguments ? 18 : 17; + case 175: + return 17; case 187: + return 16; + case 186: + case 183: + case 184: + case 182: + case 185: + return 15; + case 188: switch (operatorKind) { - case 49: case 50: + case 51: return 15; - case 38: - case 37: case 39: + case 38: case 40: + case 41: return 14; - case 35: case 36: + case 37: return 13; - case 43: case 44: case 45: + case 46: return 12; - case 25: - case 28: - case 27: + case 26: case 29: - case 90: - case 91: - return 11; + case 28: case 30: - case 32: + case 91: + case 92: + return 11; case 31: case 33: + case 32: + case 34: return 10; - case 46: - return 9; - case 48: - return 8; case 47: + return 9; + case 49: + return 8; + case 48: return 7; - case 51: - return 6; case 52: + return 6; + case 53: return 5; - case 56: case 57: case 58: - case 60: case 59: case 61: + case 60: case 62: case 63: case 64: case 65: case 66: - case 68: case 67: + case 69: + case 68: return 3; - case 24: + case 25: return 0; default: return -1; } - case 188: + case 189: return 4; - case 190: - return 2; case 191: + return 2; + case 192: return 1; default: return -1; @@ -8651,7 +6575,7 @@ var ts; function forEachTransformedEmitFile(host, sourceFiles, action, emitOnlyDtsFiles) { var options = host.getCompilerOptions(); if (options.outFile || options.out) { - onBundledEmit(host, sourceFiles); + onBundledEmit(sourceFiles); } else { for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { @@ -8678,7 +6602,7 @@ var ts; var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (options.declaration || emitOnlyDtsFiles) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; action(jsFilePath, sourceMapFilePath, declarationFilePath, [sourceFile], false); } - function onBundledEmit(host, sourceFiles) { + function onBundledEmit(sourceFiles) { if (sourceFiles.length) { var jsFilePath = options.outFile || options.out; var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); @@ -8767,7 +6691,7 @@ var ts; ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 148 && nodeIsPresent(member.body)) { + if (member.kind === 149 && nodeIsPresent(member.body)) { return member; } }); @@ -8794,11 +6718,11 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return node && node.kind === 69 && identifierIsThisKeyword(node); + return node && node.kind === 70 && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 97; + return id.originalKeywordKind === 98; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -8808,10 +6732,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 149) { + if (accessor.kind === 150) { getAccessor = accessor; } - else if (accessor.kind === 150) { + else if (accessor.kind === 151) { setAccessor = accessor; } else { @@ -8820,7 +6744,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 149 || member.kind === 150) + if ((member.kind === 150 || member.kind === 151) && hasModifier(member, 32) === hasModifier(accessor, 32)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -8831,10 +6755,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 149 && !getAccessor) { + if (member.kind === 150 && !getAccessor) { getAccessor = member; } - if (member.kind === 150 && !setAccessor) { + if (member.kind === 151 && !setAccessor) { setAccessor = member; } } @@ -9026,34 +6950,34 @@ var ts; ts.getModifierFlags = getModifierFlags; function modifierToFlag(token) { switch (token) { - case 113: return 32; - case 112: return 4; - case 111: return 16; - case 110: return 8; - case 115: return 128; - case 82: return 1; - case 122: return 2; - case 74: return 2048; - case 77: return 512; - case 118: return 256; - case 128: return 64; + case 114: return 32; + case 113: return 4; + case 112: return 16; + case 111: return 8; + case 116: return 128; + case 83: return 1; + case 123: return 2; + case 75: return 2048; + case 78: return 512; + case 119: return 256; + case 129: return 64; } return 0; } ts.modifierToFlag = modifierToFlag; function isLogicalOperator(token) { - return token === 52 - || token === 51 - || token === 49; + return token === 53 + || token === 52 + || token === 50; } ts.isLogicalOperator = isLogicalOperator; function isAssignmentOperator(token) { - return token >= 56 && token <= 68; + return token >= 57 && token <= 69; } ts.isAssignmentOperator = isAssignmentOperator; function tryGetClassExtendingExpressionWithTypeArguments(node) { - if (node.kind === 194 && - node.parent.token === 83 && + if (node.kind === 195 && + node.parent.token === 84 && isClassLike(node.parent.parent)) { return node.parent.parent; } @@ -9061,10 +6985,10 @@ var ts; ts.tryGetClassExtendingExpressionWithTypeArguments = tryGetClassExtendingExpressionWithTypeArguments; function isDestructuringAssignment(node) { if (isBinaryExpression(node)) { - if (node.operatorToken.kind === 56) { + if (node.operatorToken.kind === 57) { var kind = node.left.kind; - return kind === 171 - || kind === 170; + return kind === 172 + || kind === 171; } } return false; @@ -9075,7 +6999,7 @@ var ts; } ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 69) { + if (node.kind === 70) { return true; } else if (isPropertyAccessExpression(node)) { @@ -9090,21 +7014,21 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { - return node.kind === 69 || - node.kind === 172 && isEntityNameExpression(node.expression); + return node.kind === 70 || + node.kind === 173 && isEntityNameExpression(node.expression); } ts.isEntityNameExpression = isEntityNameExpression; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 139 && node.parent.right === node) || - (node.parent.kind === 172 && node.parent.name === node); + return (node.parent.kind === 140 && node.parent.right === node) || + (node.parent.kind === 173 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteralOrArrayLiteral(expression) { var kind = expression.kind; - if (kind === 171) { + if (kind === 172) { return expression.properties.length === 0; } - if (kind === 170) { + if (kind === 171) { return expression.elements.length === 0; } return false; @@ -9228,49 +7152,49 @@ var ts; var kind = node.kind; if (kind === 9 || kind === 8 - || kind === 10 || kind === 11 - || kind === 69 - || kind === 97 - || kind === 95 - || kind === 99 - || kind === 84 - || kind === 93) { + || kind === 12 + || kind === 70 + || kind === 98 + || kind === 96 + || kind === 100 + || kind === 85 + || kind === 94) { return true; } - else if (kind === 172) { + else if (kind === 173) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 173) { + else if (kind === 174) { return isSimpleExpressionWorker(node.expression, depth + 1) && isSimpleExpressionWorker(node.argumentExpression, depth + 1); } - else if (kind === 185 - || kind === 186) { + else if (kind === 186 + || kind === 187) { return isSimpleExpressionWorker(node.operand, depth + 1); } - else if (kind === 187) { - return node.operatorToken.kind !== 38 + else if (kind === 188) { + return node.operatorToken.kind !== 39 && isSimpleExpressionWorker(node.left, depth + 1) && isSimpleExpressionWorker(node.right, depth + 1); } - else if (kind === 188) { + else if (kind === 189) { return isSimpleExpressionWorker(node.condition, depth + 1) && isSimpleExpressionWorker(node.whenTrue, depth + 1) && isSimpleExpressionWorker(node.whenFalse, depth + 1); } - else if (kind === 183 - || kind === 182 - || kind === 181) { + else if (kind === 184 + || kind === 183 + || kind === 182) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 170) { + else if (kind === 171) { return node.elements.length === 0; } - else if (kind === 171) { + else if (kind === 172) { return node.properties.length === 0; } - else if (kind === 174) { + else if (kind === 175) { if (!isSimpleExpressionWorker(node.expression, depth + 1)) { return false; } @@ -9292,9 +7216,9 @@ var ts; if (syntaxKindCache[kind]) { return syntaxKindCache[kind]; } - for (var name_10 in syntaxKindEnum) { - if (syntaxKindEnum[name_10] === kind) { - return syntaxKindCache[kind] = kind.toString() + " (" + name_10 + ")"; + for (var name_6 in syntaxKindEnum) { + if (syntaxKindEnum[name_6] === kind) { + return syntaxKindCache[kind] = kind.toString() + " (" + name_6 + ")"; } } } @@ -9376,7 +7300,7 @@ var ts; return ts.positionIsSynthesized(range.pos) ? -1 : ts.skipTrivia(sourceFile.text, range.pos); } ts.getStartPositionOfRange = getStartPositionOfRange; - function collectExternalModuleInfo(sourceFile, resolver) { + function collectExternalModuleInfo(sourceFile) { var externalImports = []; var exportSpecifiers = ts.createMap(); var exportEquals = undefined; @@ -9384,38 +7308,33 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { + case 231: + externalImports.push(node); + break; case 230: - if (!node.importClause || - resolver.isReferencedAliasDeclaration(node.importClause, true)) { + if (node.moduleReference.kind === 241) { externalImports.push(node); } break; - case 229: - if (node.moduleReference.kind === 240 && resolver.isReferencedAliasDeclaration(node)) { - externalImports.push(node); - } - break; - case 236: + case 237: if (node.moduleSpecifier) { if (!node.exportClause) { - if (resolver.moduleExportsSomeValue(node.moduleSpecifier)) { - externalImports.push(node); - hasExportStarsToExportValues = true; - } + externalImports.push(node); + hasExportStarsToExportValues = true; } - else if (resolver.isValueAliasDeclaration(node)) { + else { externalImports.push(node); } } else { for (var _b = 0, _c = node.exportClause.elements; _b < _c.length; _b++) { var specifier = _c[_b]; - var name_11 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_11] || (exportSpecifiers[name_11] = [])).push(specifier); + var name_7 = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[name_7] || (exportSpecifiers[name_7] = [])).push(specifier); } } break; - case 235: + case 236: if (node.isExportEquals && !exportEquals) { exportEquals = node; } @@ -9436,7 +7355,7 @@ var ts; if (node.symbol) { for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 221 && declaration !== node) { + if (declaration.kind === 222 && declaration !== node) { return true; } } @@ -9454,15 +7373,15 @@ var ts; } ts.isNodeArray = isNodeArray; function isNoSubstitutionTemplateLiteral(node) { - return node.kind === 11; + return node.kind === 12; } ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral; function isLiteralKind(kind) { - return 8 <= kind && kind <= 11; + return 8 <= kind && kind <= 12; } ts.isLiteralKind = isLiteralKind; function isTextualLiteralKind(kind) { - return kind === 9 || kind === 11; + return kind === 9 || kind === 12; } ts.isTextualLiteralKind = isTextualLiteralKind; function isLiteralExpression(node) { @@ -9470,21 +7389,21 @@ var ts; } ts.isLiteralExpression = isLiteralExpression; function isTemplateLiteralKind(kind) { - return 11 <= kind && kind <= 14; + return 12 <= kind && kind <= 15; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isTemplateHead(node) { - return node.kind === 12; + return node.kind === 13; } ts.isTemplateHead = isTemplateHead; function isTemplateMiddleOrTemplateTail(node) { var kind = node.kind; - return kind === 13 - || kind === 14; + return kind === 14 + || kind === 15; } ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; function isIdentifier(node) { - return node.kind === 69; + return node.kind === 70; } ts.isIdentifier = isIdentifier; function isGeneratedIdentifier(node) { @@ -9496,87 +7415,87 @@ var ts; } ts.isModifier = isModifier; function isQualifiedName(node) { - return node.kind === 139; + return node.kind === 140; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 140; + return node.kind === 141; } ts.isComputedPropertyName = isComputedPropertyName; function isEntityName(node) { var kind = node.kind; - return kind === 139 - || kind === 69; + return kind === 140 + || kind === 70; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 69 + return kind === 70 || kind === 9 || kind === 8 - || kind === 140; + || kind === 141; } ts.isPropertyName = isPropertyName; function isModuleName(node) { var kind = node.kind; - return kind === 69 + return kind === 70 || kind === 9; } ts.isModuleName = isModuleName; function isBindingName(node) { var kind = node.kind; - return kind === 69 - || kind === 167 - || kind === 168; + return kind === 70 + || kind === 168 + || kind === 169; } ts.isBindingName = isBindingName; function isTypeParameter(node) { - return node.kind === 141; + return node.kind === 142; } ts.isTypeParameter = isTypeParameter; function isParameter(node) { - return node.kind === 142; + return node.kind === 143; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 143; + return node.kind === 144; } ts.isDecorator = isDecorator; function isMethodDeclaration(node) { - return node.kind === 147; + return node.kind === 148; } ts.isMethodDeclaration = isMethodDeclaration; function isClassElement(node) { var kind = node.kind; - return kind === 148 - || kind === 145 - || kind === 147 - || kind === 149 + return kind === 149 + || kind === 146 + || kind === 148 || kind === 150 - || kind === 153 - || kind === 198; + || kind === 151 + || kind === 154 + || kind === 199; } ts.isClassElement = isClassElement; function isObjectLiteralElementLike(node) { var kind = node.kind; return kind === 253 || kind === 254 - || kind === 147 - || kind === 149 + || kind === 148 || kind === 150 - || kind === 239; + || kind === 151 + || kind === 240; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; function isTypeNodeKind(kind) { - return (kind >= 154 && kind <= 166) - || kind === 117 - || kind === 130 - || kind === 120 - || kind === 132 + return (kind >= 155 && kind <= 167) + || kind === 118 + || kind === 131 + || kind === 121 || kind === 133 - || kind === 103 - || kind === 127 - || kind === 194; + || kind === 134 + || kind === 104 + || kind === 128 + || kind === 195; } function isTypeNode(node) { return isTypeNodeKind(node.kind); @@ -9585,94 +7504,94 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 168 - || kind === 167; + return kind === 169 + || kind === 168; } return false; } ts.isBindingPattern = isBindingPattern; function isBindingElement(node) { - return node.kind === 169; + return node.kind === 170; } ts.isBindingElement = isBindingElement; function isArrayBindingElement(node) { var kind = node.kind; - return kind === 169 - || kind === 193; + return kind === 170 + || kind === 194; } ts.isArrayBindingElement = isArrayBindingElement; function isPropertyAccessExpression(node) { - return node.kind === 172; + return node.kind === 173; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 173; + return node.kind === 174; } ts.isElementAccessExpression = isElementAccessExpression; function isBinaryExpression(node) { - return node.kind === 187; + return node.kind === 188; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 188; + return node.kind === 189; } ts.isConditionalExpression = isConditionalExpression; function isCallExpression(node) { - return node.kind === 174; + return node.kind === 175; } ts.isCallExpression = isCallExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 189 - || kind === 11; + return kind === 190 + || kind === 12; } ts.isTemplateLiteral = isTemplateLiteral; function isSpreadElementExpression(node) { - return node.kind === 191; + return node.kind === 192; } ts.isSpreadElementExpression = isSpreadElementExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 194; + return node.kind === 195; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isLeftHandSideExpressionKind(kind) { - return kind === 172 - || kind === 173 - || kind === 175 + return kind === 173 || kind === 174 - || kind === 241 - || kind === 242 || kind === 176 - || kind === 170 - || kind === 178 + || kind === 175 + || kind === 242 + || kind === 243 + || kind === 177 || kind === 171 - || kind === 192 || kind === 179 - || kind === 69 - || kind === 10 + || kind === 172 + || kind === 193 + || kind === 180 + || kind === 70 + || kind === 11 || kind === 8 || kind === 9 - || kind === 11 - || kind === 189 - || kind === 84 - || kind === 93 - || kind === 97 - || kind === 99 - || kind === 95 - || kind === 196; + || kind === 12 + || kind === 190 + || kind === 85 + || kind === 94 + || kind === 98 + || kind === 100 + || kind === 96 + || kind === 197; } function isLeftHandSideExpression(node) { return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isUnaryExpressionKind(kind) { - return kind === 185 - || kind === 186 - || kind === 181 + return kind === 186 + || kind === 187 || kind === 182 || kind === 183 || kind === 184 - || kind === 177 + || kind === 185 + || kind === 178 || isLeftHandSideExpressionKind(kind); } function isUnaryExpression(node) { @@ -9680,13 +7599,13 @@ var ts; } ts.isUnaryExpression = isUnaryExpression; function isExpressionKind(kind) { - return kind === 188 - || kind === 190 - || kind === 180 - || kind === 187 + return kind === 189 || kind === 191 - || kind === 195 - || kind === 193 + || kind === 181 + || kind === 188 + || kind === 192 + || kind === 196 + || kind === 194 || isUnaryExpressionKind(kind); } function isExpression(node) { @@ -9695,8 +7614,8 @@ var ts; ts.isExpression = isExpression; function isAssertionExpression(node) { var kind = node.kind; - return kind === 177 - || kind === 195; + return kind === 178 + || kind === 196; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { @@ -9713,15 +7632,15 @@ var ts; } ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isOmittedExpression(node) { - return node.kind === 193; + return node.kind === 194; } ts.isOmittedExpression = isOmittedExpression; function isTemplateSpan(node) { - return node.kind === 197; + return node.kind === 198; } ts.isTemplateSpan = isTemplateSpan; function isBlock(node) { - return node.kind === 199; + return node.kind === 200; } ts.isBlock = isBlock; function isConciseBody(node) { @@ -9739,118 +7658,118 @@ var ts; } ts.isForInitializer = isForInitializer; function isVariableDeclaration(node) { - return node.kind === 218; + return node.kind === 219; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 219; + return node.kind === 220; } ts.isVariableDeclarationList = isVariableDeclarationList; function isCaseBlock(node) { - return node.kind === 227; + return node.kind === 228; } ts.isCaseBlock = isCaseBlock; function isModuleBody(node) { var kind = node.kind; - return kind === 226 - || kind === 225; + return kind === 227 + || kind === 226; } ts.isModuleBody = isModuleBody; function isImportEqualsDeclaration(node) { - return node.kind === 229; + return node.kind === 230; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportClause(node) { - return node.kind === 231; + return node.kind === 232; } ts.isImportClause = isImportClause; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 233 - || kind === 232; + return kind === 234 + || kind === 233; } ts.isNamedImportBindings = isNamedImportBindings; function isImportSpecifier(node) { - return node.kind === 234; + return node.kind === 235; } ts.isImportSpecifier = isImportSpecifier; function isNamedExports(node) { - return node.kind === 237; + return node.kind === 238; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 238; + return node.kind === 239; } ts.isExportSpecifier = isExportSpecifier; function isModuleOrEnumDeclaration(node) { - return node.kind === 225 || node.kind === 224; + return node.kind === 226 || node.kind === 225; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 180 - || kind === 169 - || kind === 221 - || kind === 192 - || kind === 148 - || kind === 224 - || kind === 255 - || kind === 238 - || kind === 220 - || kind === 179 - || kind === 149 - || kind === 231 - || kind === 229 - || kind === 234 + return kind === 181 + || kind === 170 || kind === 222 - || kind === 147 - || kind === 146 + || kind === 193 + || kind === 149 || kind === 225 - || kind === 228 - || kind === 232 - || kind === 142 - || kind === 253 - || kind === 145 - || kind === 144 + || kind === 255 + || kind === 239 + || kind === 221 + || kind === 180 || kind === 150 - || kind === 254 + || kind === 232 + || kind === 230 + || kind === 235 || kind === 223 - || kind === 141 - || kind === 218 + || kind === 148 + || kind === 147 + || kind === 226 + || kind === 229 + || kind === 233 + || kind === 143 + || kind === 253 + || kind === 146 + || kind === 145 + || kind === 151 + || kind === 254 + || kind === 224 + || kind === 142 + || kind === 219 || kind === 279; } function isDeclarationStatementKind(kind) { - return kind === 220 - || kind === 239 - || kind === 221 + return kind === 221 + || kind === 240 || kind === 222 || kind === 223 || kind === 224 || kind === 225 + || kind === 226 + || kind === 231 || kind === 230 - || kind === 229 + || kind === 237 || kind === 236 - || kind === 235 - || kind === 228; + || kind === 229; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 210 - || kind === 209 - || kind === 217 - || kind === 204 - || kind === 202 - || kind === 201 - || kind === 207 - || kind === 208 - || kind === 206 - || kind === 203 - || kind === 214 - || kind === 211 - || kind === 213 - || kind === 215 - || kind === 216 - || kind === 200 + return kind === 211 + || kind === 210 + || kind === 218 || kind === 205 + || kind === 203 + || kind === 202 + || kind === 208 + || kind === 209 + || kind === 207 + || kind === 204 + || kind === 215 || kind === 212 + || kind === 214 + || kind === 216 + || kind === 217 + || kind === 201 + || kind === 206 + || kind === 213 || kind === 287; } function isDeclaration(node) { @@ -9869,18 +7788,18 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 199; + || kind === 200; } ts.isStatement = isStatement; function isModuleReference(node) { var kind = node.kind; - return kind === 240 - || kind === 139 - || kind === 69; + return kind === 241 + || kind === 140 + || kind === 70; } ts.isModuleReference = isModuleReference; function isJsxOpeningElement(node) { - return node.kind === 243; + return node.kind === 244; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { @@ -9889,17 +7808,17 @@ var ts; ts.isJsxClosingElement = isJsxClosingElement; function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 97 - || kind === 69 - || kind === 172; + return kind === 98 + || kind === 70 + || kind === 173; } ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 241 + return kind === 242 || kind === 248 - || kind === 242 - || kind === 244; + || kind === 243 + || kind === 10; } ts.isJsxChild = isJsxChild; function isJsxAttributeLike(node) { @@ -9959,7 +7878,16 @@ var ts; })(ts || (ts = {})); (function (ts) { function getDefaultLibFileName(options) { - return options.target === 2 ? "lib.es6.d.ts" : "lib.d.ts"; + switch (options.target) { + case 4: + return "lib.es2017.d.ts"; + case 3: + return "lib.es2016.d.ts"; + case 2: + return "lib.es6.d.ts"; + default: + return "lib.d.ts"; + } } ts.getDefaultLibFileName = getDefaultLibFileName; function textSpanEnd(span) { @@ -10078,9 +8006,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 141) { + if (d && d.kind === 142) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 222) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 223) { return current; } } @@ -10088,11 +8016,11 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92) && node.parent.kind === 148 && ts.isClassLike(node.parent.parent); + return ts.hasModifier(node, 92) && node.parent.kind === 149 && ts.isClassLike(node.parent.parent); } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 169 || ts.isBindingPattern(node))) { + while (node && (node.kind === 170 || ts.isBindingPattern(node))) { node = node.parent; } return node; @@ -10100,14 +8028,14 @@ var ts; function getCombinedModifierFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = ts.getModifierFlags(node); - if (node.kind === 218) { + if (node.kind === 219) { node = node.parent; } - if (node && node.kind === 219) { + if (node && node.kind === 220) { flags |= ts.getModifierFlags(node); node = node.parent; } - if (node && node.kind === 200) { + if (node && node.kind === 201) { flags |= ts.getModifierFlags(node); } return flags; @@ -10116,14 +8044,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 218) { + if (node.kind === 219) { node = node.parent; } - if (node && node.kind === 219) { + if (node && node.kind === 220) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 200) { + if (node && node.kind === 201) { flags |= node.flags; } return flags; @@ -10131,6 +8059,1554 @@ var ts; ts.getCombinedNodeFlags = getCombinedNodeFlags; })(ts || (ts = {})); var ts; +(function (ts) { + function tokenIsIdentifierOrKeyword(token) { + return token >= 70; + } + ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; + var textToToken = ts.createMap({ + "abstract": 116, + "any": 118, + "as": 117, + "boolean": 121, + "break": 71, + "case": 72, + "catch": 73, + "class": 74, + "continue": 76, + "const": 75, + "constructor": 122, + "debugger": 77, + "declare": 123, + "default": 78, + "delete": 79, + "do": 80, + "else": 81, + "enum": 82, + "export": 83, + "extends": 84, + "false": 85, + "finally": 86, + "for": 87, + "from": 137, + "function": 88, + "get": 124, + "if": 89, + "implements": 107, + "import": 90, + "in": 91, + "instanceof": 92, + "interface": 108, + "is": 125, + "let": 109, + "module": 126, + "namespace": 127, + "never": 128, + "new": 93, + "null": 94, + "number": 131, + "package": 110, + "private": 111, + "protected": 112, + "public": 113, + "readonly": 129, + "require": 130, + "global": 138, + "return": 95, + "set": 132, + "static": 114, + "string": 133, + "super": 96, + "switch": 97, + "symbol": 134, + "this": 98, + "throw": 99, + "true": 100, + "try": 101, + "type": 135, + "typeof": 102, + "undefined": 136, + "var": 103, + "void": 104, + "while": 105, + "with": 106, + "yield": 115, + "async": 119, + "await": 120, + "of": 139, + "{": 16, + "}": 17, + "(": 18, + ")": 19, + "[": 20, + "]": 21, + ".": 22, + "...": 23, + ";": 24, + ",": 25, + "<": 26, + ">": 28, + "<=": 29, + ">=": 30, + "==": 31, + "!=": 32, + "===": 33, + "!==": 34, + "=>": 35, + "+": 36, + "-": 37, + "**": 39, + "*": 38, + "/": 40, + "%": 41, + "++": 42, + "--": 43, + "<<": 44, + ">": 45, + ">>>": 46, + "&": 47, + "|": 48, + "^": 49, + "!": 50, + "~": 51, + "&&": 52, + "||": 53, + "?": 54, + ":": 55, + "=": 57, + "+=": 58, + "-=": 59, + "*=": 60, + "**=": 61, + "/=": 62, + "%=": 63, + "<<=": 64, + ">>=": 65, + ">>>=": 66, + "&=": 67, + "|=": 68, + "^=": 69, + "@": 56, + }); + 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,]; + var unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 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, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 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, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 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, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 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, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; + var unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 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, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 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, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 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, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; + function lookupInUnicodeMap(code, map) { + if (code < map[0]) { + return false; + } + var lo = 0; + var hi = map.length; + var mid; + while (lo + 1 < hi) { + mid = lo + (hi - lo) / 2; + mid -= mid % 2; + if (map[mid] <= code && code <= map[mid + 1]) { + return true; + } + if (code < map[mid]) { + hi = mid; + } + else { + lo = mid + 2; + } + } + return false; + } + function isUnicodeIdentifierStart(code, languageVersion) { + return languageVersion >= 1 ? + lookupInUnicodeMap(code, unicodeES5IdentifierStart) : + lookupInUnicodeMap(code, unicodeES3IdentifierStart); + } + ts.isUnicodeIdentifierStart = isUnicodeIdentifierStart; + function isUnicodeIdentifierPart(code, languageVersion) { + return languageVersion >= 1 ? + lookupInUnicodeMap(code, unicodeES5IdentifierPart) : + lookupInUnicodeMap(code, unicodeES3IdentifierPart); + } + function makeReverseMap(source) { + var result = []; + for (var name_8 in source) { + result[source[name_8]] = name_8; + } + return result; + } + var tokenStrings = makeReverseMap(textToToken); + function tokenToString(t) { + return tokenStrings[t]; + } + ts.tokenToString = tokenToString; + function stringToToken(s) { + return textToToken[s]; + } + ts.stringToToken = stringToToken; + function computeLineStarts(text) { + var result = new Array(); + var pos = 0; + var lineStart = 0; + while (pos < text.length) { + var ch = text.charCodeAt(pos); + pos++; + switch (ch) { + case 13: + if (text.charCodeAt(pos) === 10) { + pos++; + } + case 10: + result.push(lineStart); + lineStart = pos; + break; + default: + if (ch > 127 && isLineBreak(ch)) { + result.push(lineStart); + lineStart = pos; + } + break; + } + } + result.push(lineStart); + return result; + } + ts.computeLineStarts = computeLineStarts; + function getPositionOfLineAndCharacter(sourceFile, line, character) { + return computePositionOfLineAndCharacter(getLineStarts(sourceFile), line, character); + } + ts.getPositionOfLineAndCharacter = getPositionOfLineAndCharacter; + function computePositionOfLineAndCharacter(lineStarts, line, character) { + ts.Debug.assert(line >= 0 && line < lineStarts.length); + return lineStarts[line] + character; + } + ts.computePositionOfLineAndCharacter = computePositionOfLineAndCharacter; + function getLineStarts(sourceFile) { + return sourceFile.lineMap || (sourceFile.lineMap = computeLineStarts(sourceFile.text)); + } + ts.getLineStarts = getLineStarts; + function computeLineAndCharacterOfPosition(lineStarts, position) { + var lineNumber = ts.binarySearch(lineStarts, position); + if (lineNumber < 0) { + lineNumber = ~lineNumber - 1; + ts.Debug.assert(lineNumber !== -1, "position cannot precede the beginning of the file"); + } + return { + line: lineNumber, + character: position - lineStarts[lineNumber] + }; + } + ts.computeLineAndCharacterOfPosition = computeLineAndCharacterOfPosition; + function getLineAndCharacterOfPosition(sourceFile, position) { + return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position); + } + ts.getLineAndCharacterOfPosition = getLineAndCharacterOfPosition; + var hasOwnProperty = Object.prototype.hasOwnProperty; + function isWhiteSpace(ch) { + return isWhiteSpaceSingleLine(ch) || isLineBreak(ch); + } + ts.isWhiteSpace = isWhiteSpace; + function isWhiteSpaceSingleLine(ch) { + return ch === 32 || + ch === 9 || + ch === 11 || + ch === 12 || + ch === 160 || + ch === 133 || + ch === 5760 || + ch >= 8192 && ch <= 8203 || + ch === 8239 || + ch === 8287 || + ch === 12288 || + ch === 65279; + } + ts.isWhiteSpaceSingleLine = isWhiteSpaceSingleLine; + function isLineBreak(ch) { + return ch === 10 || + ch === 13 || + ch === 8232 || + ch === 8233; + } + ts.isLineBreak = isLineBreak; + function isDigit(ch) { + return ch >= 48 && ch <= 57; + } + function isOctalDigit(ch) { + return ch >= 48 && ch <= 55; + } + ts.isOctalDigit = isOctalDigit; + function couldStartTrivia(text, pos) { + var ch = text.charCodeAt(pos); + switch (ch) { + case 13: + case 10: + case 9: + case 11: + case 12: + case 32: + case 47: + case 60: + case 61: + case 62: + return true; + case 35: + return pos === 0; + default: + return ch > 127; + } + } + ts.couldStartTrivia = couldStartTrivia; + function skipTrivia(text, pos, stopAfterLineBreak, stopAtComments) { + if (stopAtComments === void 0) { stopAtComments = false; } + if (ts.positionIsSynthesized(pos)) { + return pos; + } + while (true) { + var ch = text.charCodeAt(pos); + switch (ch) { + case 13: + if (text.charCodeAt(pos + 1) === 10) { + pos++; + } + case 10: + pos++; + if (stopAfterLineBreak) { + return pos; + } + continue; + case 9: + case 11: + case 12: + case 32: + pos++; + continue; + case 47: + if (stopAtComments) { + break; + } + if (text.charCodeAt(pos + 1) === 47) { + pos += 2; + while (pos < text.length) { + if (isLineBreak(text.charCodeAt(pos))) { + break; + } + pos++; + } + continue; + } + if (text.charCodeAt(pos + 1) === 42) { + pos += 2; + while (pos < text.length) { + if (text.charCodeAt(pos) === 42 && text.charCodeAt(pos + 1) === 47) { + pos += 2; + break; + } + pos++; + } + continue; + } + break; + case 60: + case 61: + case 62: + if (isConflictMarkerTrivia(text, pos)) { + pos = scanConflictMarkerTrivia(text, pos); + continue; + } + break; + case 35: + if (pos === 0 && isShebangTrivia(text, pos)) { + pos = scanShebangTrivia(text, pos); + continue; + } + break; + default: + if (ch > 127 && (isWhiteSpace(ch))) { + pos++; + continue; + } + break; + } + return pos; + } + } + ts.skipTrivia = skipTrivia; + var mergeConflictMarkerLength = "<<<<<<<".length; + function isConflictMarkerTrivia(text, pos) { + ts.Debug.assert(pos >= 0); + if (pos === 0 || isLineBreak(text.charCodeAt(pos - 1))) { + var ch = text.charCodeAt(pos); + if ((pos + mergeConflictMarkerLength) < text.length) { + for (var i = 0, n = mergeConflictMarkerLength; i < n; i++) { + if (text.charCodeAt(pos + i) !== ch) { + return false; + } + } + return ch === 61 || + text.charCodeAt(pos + mergeConflictMarkerLength) === 32; + } + } + return false; + } + function scanConflictMarkerTrivia(text, pos, error) { + if (error) { + error(ts.Diagnostics.Merge_conflict_marker_encountered, mergeConflictMarkerLength); + } + var ch = text.charCodeAt(pos); + var len = text.length; + if (ch === 60 || ch === 62) { + while (pos < len && !isLineBreak(text.charCodeAt(pos))) { + pos++; + } + } + else { + ts.Debug.assert(ch === 61); + while (pos < len) { + var ch_1 = text.charCodeAt(pos); + if (ch_1 === 62 && isConflictMarkerTrivia(text, pos)) { + break; + } + pos++; + } + } + return pos; + } + var shebangTriviaRegex = /^#!.*/; + function isShebangTrivia(text, pos) { + ts.Debug.assert(pos === 0); + return shebangTriviaRegex.test(text); + } + function scanShebangTrivia(text, pos) { + var shebang = shebangTriviaRegex.exec(text)[0]; + pos = pos + shebang.length; + return pos; + } + function iterateCommentRanges(reduce, text, pos, trailing, cb, state, initial) { + var pendingPos; + var pendingEnd; + var pendingKind; + var pendingHasTrailingNewLine; + var hasPendingCommentRange = false; + var collecting = trailing || pos === 0; + var accumulator = initial; + scan: while (pos >= 0 && pos < text.length) { + var ch = text.charCodeAt(pos); + switch (ch) { + case 13: + if (text.charCodeAt(pos + 1) === 10) { + pos++; + } + case 10: + pos++; + if (trailing) { + break scan; + } + collecting = true; + if (hasPendingCommentRange) { + pendingHasTrailingNewLine = true; + } + continue; + case 9: + case 11: + case 12: + case 32: + pos++; + continue; + case 47: + var nextChar = text.charCodeAt(pos + 1); + var hasTrailingNewLine = false; + if (nextChar === 47 || nextChar === 42) { + var kind = nextChar === 47 ? 2 : 3; + var startPos = pos; + pos += 2; + if (nextChar === 47) { + while (pos < text.length) { + if (isLineBreak(text.charCodeAt(pos))) { + hasTrailingNewLine = true; + break; + } + pos++; + } + } + else { + while (pos < text.length) { + if (text.charCodeAt(pos) === 42 && text.charCodeAt(pos + 1) === 47) { + pos += 2; + break; + } + pos++; + } + } + if (collecting) { + if (hasPendingCommentRange) { + accumulator = cb(pendingPos, pendingEnd, pendingKind, pendingHasTrailingNewLine, state, accumulator); + if (!reduce && accumulator) { + return accumulator; + } + hasPendingCommentRange = false; + } + pendingPos = startPos; + pendingEnd = pos; + pendingKind = kind; + pendingHasTrailingNewLine = hasTrailingNewLine; + hasPendingCommentRange = true; + } + continue; + } + break scan; + default: + if (ch > 127 && (isWhiteSpace(ch))) { + if (hasPendingCommentRange && isLineBreak(ch)) { + pendingHasTrailingNewLine = true; + } + pos++; + continue; + } + break scan; + } + } + if (hasPendingCommentRange) { + accumulator = cb(pendingPos, pendingEnd, pendingKind, pendingHasTrailingNewLine, state, accumulator); + } + return accumulator; + } + function forEachLeadingCommentRange(text, pos, cb, state) { + return iterateCommentRanges(false, text, pos, false, cb, state); + } + ts.forEachLeadingCommentRange = forEachLeadingCommentRange; + function forEachTrailingCommentRange(text, pos, cb, state) { + return iterateCommentRanges(false, text, pos, true, cb, state); + } + ts.forEachTrailingCommentRange = forEachTrailingCommentRange; + function reduceEachLeadingCommentRange(text, pos, cb, state, initial) { + return iterateCommentRanges(true, text, pos, false, cb, state, initial); + } + ts.reduceEachLeadingCommentRange = reduceEachLeadingCommentRange; + function reduceEachTrailingCommentRange(text, pos, cb, state, initial) { + return iterateCommentRanges(true, text, pos, true, cb, state, initial); + } + ts.reduceEachTrailingCommentRange = reduceEachTrailingCommentRange; + function appendCommentRange(pos, end, kind, hasTrailingNewLine, _state, comments) { + if (!comments) { + comments = []; + } + comments.push({ pos: pos, end: end, hasTrailingNewLine: hasTrailingNewLine, kind: kind }); + return comments; + } + function getLeadingCommentRanges(text, pos) { + return reduceEachLeadingCommentRange(text, pos, appendCommentRange, undefined, undefined); + } + ts.getLeadingCommentRanges = getLeadingCommentRanges; + function getTrailingCommentRanges(text, pos) { + return reduceEachTrailingCommentRange(text, pos, appendCommentRange, undefined, undefined); + } + ts.getTrailingCommentRanges = getTrailingCommentRanges; + function getShebang(text) { + return shebangTriviaRegex.test(text) + ? shebangTriviaRegex.exec(text)[0] + : undefined; + } + ts.getShebang = getShebang; + function isIdentifierStart(ch, languageVersion) { + return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || + ch === 36 || ch === 95 || + ch > 127 && isUnicodeIdentifierStart(ch, languageVersion); + } + ts.isIdentifierStart = isIdentifierStart; + function isIdentifierPart(ch, languageVersion) { + return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || + ch >= 48 && ch <= 57 || ch === 36 || ch === 95 || + ch > 127 && isUnicodeIdentifierPart(ch, languageVersion); + } + ts.isIdentifierPart = isIdentifierPart; + function isIdentifierText(name, languageVersion) { + if (!isIdentifierStart(name.charCodeAt(0), languageVersion)) { + return false; + } + for (var i = 1, n = name.length; i < n; i++) { + if (!isIdentifierPart(name.charCodeAt(i), languageVersion)) { + return false; + } + } + return true; + } + ts.isIdentifierText = isIdentifierText; + function createScanner(languageVersion, skipTrivia, languageVariant, text, onError, start, length) { + if (languageVariant === void 0) { languageVariant = 0; } + var pos; + var end; + var startPos; + var tokenPos; + var token; + var tokenValue; + var precedingLineBreak; + var hasExtendedUnicodeEscape; + var tokenIsUnterminated; + setText(text, start, length); + return { + getStartPos: function () { return startPos; }, + getTextPos: function () { return pos; }, + getToken: function () { return token; }, + getTokenPos: function () { return tokenPos; }, + getTokenText: function () { return text.substring(tokenPos, pos); }, + getTokenValue: function () { return tokenValue; }, + hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, + hasPrecedingLineBreak: function () { return precedingLineBreak; }, + isIdentifier: function () { return token === 70 || token > 106; }, + isReservedWord: function () { return token >= 71 && token <= 106; }, + isUnterminated: function () { return tokenIsUnterminated; }, + reScanGreaterToken: reScanGreaterToken, + reScanSlashToken: reScanSlashToken, + reScanTemplateToken: reScanTemplateToken, + scanJsxIdentifier: scanJsxIdentifier, + scanJsxAttributeValue: scanJsxAttributeValue, + reScanJsxToken: reScanJsxToken, + scanJsxToken: scanJsxToken, + scanJSDocToken: scanJSDocToken, + scan: scan, + getText: getText, + setText: setText, + setScriptTarget: setScriptTarget, + setLanguageVariant: setLanguageVariant, + setOnError: setOnError, + setTextPos: setTextPos, + tryScan: tryScan, + lookAhead: lookAhead, + scanRange: scanRange, + }; + function error(message, length) { + if (onError) { + onError(message, length || 0); + } + } + function scanNumber() { + var start = pos; + while (isDigit(text.charCodeAt(pos))) + pos++; + if (text.charCodeAt(pos) === 46) { + pos++; + while (isDigit(text.charCodeAt(pos))) + pos++; + } + var end = pos; + if (text.charCodeAt(pos) === 69 || text.charCodeAt(pos) === 101) { + pos++; + if (text.charCodeAt(pos) === 43 || text.charCodeAt(pos) === 45) + pos++; + if (isDigit(text.charCodeAt(pos))) { + pos++; + while (isDigit(text.charCodeAt(pos))) + pos++; + end = pos; + } + else { + error(ts.Diagnostics.Digit_expected); + } + } + return "" + +(text.substring(start, end)); + } + function scanOctalDigits() { + var start = pos; + while (isOctalDigit(text.charCodeAt(pos))) { + pos++; + } + return +(text.substring(start, pos)); + } + function scanExactNumberOfHexDigits(count) { + return scanHexDigits(count, false); + } + function scanMinimumNumberOfHexDigits(count) { + return scanHexDigits(count, true); + } + function scanHexDigits(minCount, scanAsManyAsPossible) { + var digits = 0; + var value = 0; + while (digits < minCount || scanAsManyAsPossible) { + var ch = text.charCodeAt(pos); + if (ch >= 48 && ch <= 57) { + value = value * 16 + ch - 48; + } + else if (ch >= 65 && ch <= 70) { + value = value * 16 + ch - 65 + 10; + } + else if (ch >= 97 && ch <= 102) { + value = value * 16 + ch - 97 + 10; + } + else { + break; + } + pos++; + digits++; + } + if (digits < minCount) { + value = -1; + } + return value; + } + function scanString(allowEscapes) { + if (allowEscapes === void 0) { allowEscapes = true; } + var quote = text.charCodeAt(pos); + pos++; + var result = ""; + var start = pos; + while (true) { + if (pos >= end) { + result += text.substring(start, pos); + tokenIsUnterminated = true; + error(ts.Diagnostics.Unterminated_string_literal); + break; + } + var ch = text.charCodeAt(pos); + if (ch === quote) { + result += text.substring(start, pos); + pos++; + break; + } + if (ch === 92 && allowEscapes) { + result += text.substring(start, pos); + result += scanEscapeSequence(); + start = pos; + continue; + } + if (isLineBreak(ch)) { + result += text.substring(start, pos); + tokenIsUnterminated = true; + error(ts.Diagnostics.Unterminated_string_literal); + break; + } + pos++; + } + return result; + } + function scanTemplateAndSetTokenValue() { + var startedWithBacktick = text.charCodeAt(pos) === 96; + pos++; + var start = pos; + var contents = ""; + var resultingToken; + while (true) { + if (pos >= end) { + contents += text.substring(start, pos); + tokenIsUnterminated = true; + error(ts.Diagnostics.Unterminated_template_literal); + resultingToken = startedWithBacktick ? 12 : 15; + break; + } + var currChar = text.charCodeAt(pos); + if (currChar === 96) { + contents += text.substring(start, pos); + pos++; + resultingToken = startedWithBacktick ? 12 : 15; + break; + } + if (currChar === 36 && pos + 1 < end && text.charCodeAt(pos + 1) === 123) { + contents += text.substring(start, pos); + pos += 2; + resultingToken = startedWithBacktick ? 13 : 14; + break; + } + if (currChar === 92) { + contents += text.substring(start, pos); + contents += scanEscapeSequence(); + start = pos; + continue; + } + if (currChar === 13) { + contents += text.substring(start, pos); + pos++; + if (pos < end && text.charCodeAt(pos) === 10) { + pos++; + } + contents += "\n"; + start = pos; + continue; + } + pos++; + } + ts.Debug.assert(resultingToken !== undefined); + tokenValue = contents; + return resultingToken; + } + function scanEscapeSequence() { + pos++; + if (pos >= end) { + error(ts.Diagnostics.Unexpected_end_of_text); + return ""; + } + var ch = text.charCodeAt(pos); + pos++; + switch (ch) { + case 48: + return "\0"; + case 98: + return "\b"; + case 116: + return "\t"; + case 110: + return "\n"; + case 118: + return "\v"; + case 102: + return "\f"; + case 114: + return "\r"; + case 39: + return "\'"; + case 34: + return "\""; + case 117: + if (pos < end && text.charCodeAt(pos) === 123) { + hasExtendedUnicodeEscape = true; + pos++; + return scanExtendedUnicodeEscape(); + } + return scanHexadecimalEscape(4); + case 120: + return scanHexadecimalEscape(2); + case 13: + if (pos < end && text.charCodeAt(pos) === 10) { + pos++; + } + case 10: + case 8232: + case 8233: + return ""; + default: + return String.fromCharCode(ch); + } + } + function scanHexadecimalEscape(numDigits) { + var escapedValue = scanExactNumberOfHexDigits(numDigits); + if (escapedValue >= 0) { + return String.fromCharCode(escapedValue); + } + else { + error(ts.Diagnostics.Hexadecimal_digit_expected); + return ""; + } + } + function scanExtendedUnicodeEscape() { + var escapedValue = scanMinimumNumberOfHexDigits(1); + var isInvalidExtendedEscape = false; + if (escapedValue < 0) { + error(ts.Diagnostics.Hexadecimal_digit_expected); + isInvalidExtendedEscape = true; + } + else if (escapedValue > 0x10FFFF) { + error(ts.Diagnostics.An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive); + isInvalidExtendedEscape = true; + } + if (pos >= end) { + error(ts.Diagnostics.Unexpected_end_of_text); + isInvalidExtendedEscape = true; + } + else if (text.charCodeAt(pos) === 125) { + pos++; + } + else { + error(ts.Diagnostics.Unterminated_Unicode_escape_sequence); + isInvalidExtendedEscape = true; + } + if (isInvalidExtendedEscape) { + return ""; + } + return utf16EncodeAsString(escapedValue); + } + function utf16EncodeAsString(codePoint) { + ts.Debug.assert(0x0 <= codePoint && codePoint <= 0x10FFFF); + if (codePoint <= 65535) { + return String.fromCharCode(codePoint); + } + var codeUnit1 = Math.floor((codePoint - 65536) / 1024) + 0xD800; + var codeUnit2 = ((codePoint - 65536) % 1024) + 0xDC00; + return String.fromCharCode(codeUnit1, codeUnit2); + } + function peekUnicodeEscape() { + if (pos + 5 < end && text.charCodeAt(pos + 1) === 117) { + var start_1 = pos; + pos += 2; + var value = scanExactNumberOfHexDigits(4); + pos = start_1; + return value; + } + return -1; + } + function scanIdentifierParts() { + var result = ""; + var start = pos; + while (pos < end) { + var ch = text.charCodeAt(pos); + if (isIdentifierPart(ch, languageVersion)) { + pos++; + } + else if (ch === 92) { + ch = peekUnicodeEscape(); + if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { + break; + } + result += text.substring(start, pos); + result += String.fromCharCode(ch); + pos += 6; + start = pos; + } + else { + break; + } + } + result += text.substring(start, pos); + return result; + } + function getIdentifierToken() { + var len = tokenValue.length; + if (len >= 2 && len <= 11) { + var ch = tokenValue.charCodeAt(0); + if (ch >= 97 && ch <= 122 && hasOwnProperty.call(textToToken, tokenValue)) { + return token = textToToken[tokenValue]; + } + } + return token = 70; + } + function scanBinaryOrOctalDigits(base) { + ts.Debug.assert(base === 2 || base === 8, "Expected either base 2 or base 8"); + var value = 0; + var numberOfDigits = 0; + while (true) { + var ch = text.charCodeAt(pos); + var valueOfCh = ch - 48; + if (!isDigit(ch) || valueOfCh >= base) { + break; + } + value = value * base + valueOfCh; + pos++; + numberOfDigits++; + } + if (numberOfDigits === 0) { + return -1; + } + return value; + } + function scan() { + startPos = pos; + hasExtendedUnicodeEscape = false; + precedingLineBreak = false; + tokenIsUnterminated = false; + while (true) { + tokenPos = pos; + if (pos >= end) { + return token = 1; + } + var ch = text.charCodeAt(pos); + if (ch === 35 && pos === 0 && isShebangTrivia(text, pos)) { + pos = scanShebangTrivia(text, pos); + if (skipTrivia) { + continue; + } + else { + return token = 6; + } + } + switch (ch) { + case 10: + case 13: + precedingLineBreak = true; + if (skipTrivia) { + pos++; + continue; + } + else { + if (ch === 13 && pos + 1 < end && text.charCodeAt(pos + 1) === 10) { + pos += 2; + } + else { + pos++; + } + return token = 4; + } + case 9: + case 11: + case 12: + case 32: + if (skipTrivia) { + pos++; + continue; + } + else { + while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) { + pos++; + } + return token = 5; + } + case 33: + if (text.charCodeAt(pos + 1) === 61) { + if (text.charCodeAt(pos + 2) === 61) { + return pos += 3, token = 34; + } + return pos += 2, token = 32; + } + pos++; + return token = 50; + case 34: + case 39: + tokenValue = scanString(); + return token = 9; + case 96: + return token = scanTemplateAndSetTokenValue(); + case 37: + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 63; + } + pos++; + return token = 41; + case 38: + if (text.charCodeAt(pos + 1) === 38) { + return pos += 2, token = 52; + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 67; + } + pos++; + return token = 47; + case 40: + pos++; + return token = 18; + case 41: + pos++; + return token = 19; + case 42: + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 60; + } + if (text.charCodeAt(pos + 1) === 42) { + if (text.charCodeAt(pos + 2) === 61) { + return pos += 3, token = 61; + } + return pos += 2, token = 39; + } + pos++; + return token = 38; + case 43: + if (text.charCodeAt(pos + 1) === 43) { + return pos += 2, token = 42; + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 58; + } + pos++; + return token = 36; + case 44: + pos++; + return token = 25; + case 45: + if (text.charCodeAt(pos + 1) === 45) { + return pos += 2, token = 43; + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 59; + } + pos++; + return token = 37; + case 46: + if (isDigit(text.charCodeAt(pos + 1))) { + tokenValue = scanNumber(); + return token = 8; + } + if (text.charCodeAt(pos + 1) === 46 && text.charCodeAt(pos + 2) === 46) { + return pos += 3, token = 23; + } + pos++; + return token = 22; + case 47: + if (text.charCodeAt(pos + 1) === 47) { + pos += 2; + while (pos < end) { + if (isLineBreak(text.charCodeAt(pos))) { + break; + } + pos++; + } + if (skipTrivia) { + continue; + } + else { + return token = 2; + } + } + if (text.charCodeAt(pos + 1) === 42) { + pos += 2; + var commentClosed = false; + while (pos < end) { + var ch_2 = text.charCodeAt(pos); + if (ch_2 === 42 && text.charCodeAt(pos + 1) === 47) { + pos += 2; + commentClosed = true; + break; + } + if (isLineBreak(ch_2)) { + precedingLineBreak = true; + } + pos++; + } + if (!commentClosed) { + error(ts.Diagnostics.Asterisk_Slash_expected); + } + if (skipTrivia) { + continue; + } + else { + tokenIsUnterminated = !commentClosed; + return token = 3; + } + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 62; + } + pos++; + return token = 40; + case 48: + if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 || text.charCodeAt(pos + 1) === 120)) { + pos += 2; + var value = scanMinimumNumberOfHexDigits(1); + if (value < 0) { + error(ts.Diagnostics.Hexadecimal_digit_expected); + value = 0; + } + tokenValue = "" + value; + return token = 8; + } + else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 || text.charCodeAt(pos + 1) === 98)) { + pos += 2; + var value = scanBinaryOrOctalDigits(2); + if (value < 0) { + error(ts.Diagnostics.Binary_digit_expected); + value = 0; + } + tokenValue = "" + value; + return token = 8; + } + else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 || text.charCodeAt(pos + 1) === 111)) { + pos += 2; + var value = scanBinaryOrOctalDigits(8); + if (value < 0) { + error(ts.Diagnostics.Octal_digit_expected); + value = 0; + } + tokenValue = "" + value; + return token = 8; + } + if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { + tokenValue = "" + scanOctalDigits(); + return token = 8; + } + case 49: + case 50: + case 51: + case 52: + case 53: + case 54: + case 55: + case 56: + case 57: + tokenValue = scanNumber(); + return token = 8; + case 58: + pos++; + return token = 55; + case 59: + pos++; + return token = 24; + case 60: + if (isConflictMarkerTrivia(text, pos)) { + pos = scanConflictMarkerTrivia(text, pos, error); + if (skipTrivia) { + continue; + } + else { + return token = 7; + } + } + if (text.charCodeAt(pos + 1) === 60) { + if (text.charCodeAt(pos + 2) === 61) { + return pos += 3, token = 64; + } + return pos += 2, token = 44; + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 29; + } + if (languageVariant === 1 && + text.charCodeAt(pos + 1) === 47 && + text.charCodeAt(pos + 2) !== 42) { + return pos += 2, token = 27; + } + pos++; + return token = 26; + case 61: + if (isConflictMarkerTrivia(text, pos)) { + pos = scanConflictMarkerTrivia(text, pos, error); + if (skipTrivia) { + continue; + } + else { + return token = 7; + } + } + if (text.charCodeAt(pos + 1) === 61) { + if (text.charCodeAt(pos + 2) === 61) { + return pos += 3, token = 33; + } + return pos += 2, token = 31; + } + if (text.charCodeAt(pos + 1) === 62) { + return pos += 2, token = 35; + } + pos++; + return token = 57; + case 62: + if (isConflictMarkerTrivia(text, pos)) { + pos = scanConflictMarkerTrivia(text, pos, error); + if (skipTrivia) { + continue; + } + else { + return token = 7; + } + } + pos++; + return token = 28; + case 63: + pos++; + return token = 54; + case 91: + pos++; + return token = 20; + case 93: + pos++; + return token = 21; + case 94: + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 69; + } + pos++; + return token = 49; + case 123: + pos++; + return token = 16; + case 124: + if (text.charCodeAt(pos + 1) === 124) { + return pos += 2, token = 53; + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 68; + } + pos++; + return token = 48; + case 125: + pos++; + return token = 17; + case 126: + pos++; + return token = 51; + case 64: + pos++; + return token = 56; + case 92: + var cookedChar = peekUnicodeEscape(); + if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { + pos += 6; + tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); + return token = getIdentifierToken(); + } + error(ts.Diagnostics.Invalid_character); + pos++; + return token = 0; + default: + if (isIdentifierStart(ch, languageVersion)) { + pos++; + while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) + pos++; + tokenValue = text.substring(tokenPos, pos); + if (ch === 92) { + tokenValue += scanIdentifierParts(); + } + return token = getIdentifierToken(); + } + else if (isWhiteSpaceSingleLine(ch)) { + pos++; + continue; + } + else if (isLineBreak(ch)) { + precedingLineBreak = true; + pos++; + continue; + } + error(ts.Diagnostics.Invalid_character); + pos++; + return token = 0; + } + } + } + function reScanGreaterToken() { + if (token === 28) { + if (text.charCodeAt(pos) === 62) { + if (text.charCodeAt(pos + 1) === 62) { + if (text.charCodeAt(pos + 2) === 61) { + return pos += 3, token = 66; + } + return pos += 2, token = 46; + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 65; + } + pos++; + return token = 45; + } + if (text.charCodeAt(pos) === 61) { + pos++; + return token = 30; + } + } + return token; + } + function reScanSlashToken() { + if (token === 40 || token === 62) { + var p = tokenPos + 1; + var inEscape = false; + var inCharacterClass = false; + while (true) { + if (p >= end) { + tokenIsUnterminated = true; + error(ts.Diagnostics.Unterminated_regular_expression_literal); + break; + } + var ch = text.charCodeAt(p); + if (isLineBreak(ch)) { + tokenIsUnterminated = true; + error(ts.Diagnostics.Unterminated_regular_expression_literal); + break; + } + if (inEscape) { + inEscape = false; + } + else if (ch === 47 && !inCharacterClass) { + p++; + break; + } + else if (ch === 91) { + inCharacterClass = true; + } + else if (ch === 92) { + inEscape = true; + } + else if (ch === 93) { + inCharacterClass = false; + } + p++; + } + while (p < end && isIdentifierPart(text.charCodeAt(p), languageVersion)) { + p++; + } + pos = p; + tokenValue = text.substring(tokenPos, pos); + token = 11; + } + return token; + } + function reScanTemplateToken() { + ts.Debug.assert(token === 17, "'reScanTemplateToken' should only be called on a '}'"); + pos = tokenPos; + return token = scanTemplateAndSetTokenValue(); + } + function reScanJsxToken() { + pos = tokenPos = startPos; + return token = scanJsxToken(); + } + function scanJsxToken() { + startPos = tokenPos = pos; + if (pos >= end) { + return token = 1; + } + var char = text.charCodeAt(pos); + if (char === 60) { + if (text.charCodeAt(pos + 1) === 47) { + pos += 2; + return token = 27; + } + pos++; + return token = 26; + } + if (char === 123) { + pos++; + return token = 16; + } + while (pos < end) { + pos++; + char = text.charCodeAt(pos); + if ((char === 123) || (char === 60)) { + break; + } + } + return token = 10; + } + function scanJsxIdentifier() { + if (tokenIsIdentifierOrKeyword(token)) { + var firstCharPosition = pos; + while (pos < end) { + var ch = text.charCodeAt(pos); + if (ch === 45 || ((firstCharPosition === pos) ? isIdentifierStart(ch, languageVersion) : isIdentifierPart(ch, languageVersion))) { + pos++; + } + else { + break; + } + } + tokenValue += text.substr(firstCharPosition, pos - firstCharPosition); + } + return token; + } + function scanJsxAttributeValue() { + startPos = pos; + switch (text.charCodeAt(pos)) { + case 34: + case 39: + tokenValue = scanString(false); + return token = 9; + default: + return scan(); + } + } + function scanJSDocToken() { + if (pos >= end) { + return token = 1; + } + startPos = pos; + tokenPos = pos; + var ch = text.charCodeAt(pos); + switch (ch) { + case 9: + case 11: + case 12: + case 32: + while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) { + pos++; + } + return token = 5; + case 64: + pos++; + return token = 56; + case 10: + case 13: + pos++; + return token = 4; + case 42: + pos++; + return token = 38; + case 123: + pos++; + return token = 16; + case 125: + pos++; + return token = 17; + case 91: + pos++; + return token = 20; + case 93: + pos++; + return token = 21; + case 61: + pos++; + return token = 57; + case 44: + pos++; + return token = 25; + } + if (isIdentifierStart(ch, 4)) { + pos++; + while (isIdentifierPart(text.charCodeAt(pos), 4) && pos < end) { + pos++; + } + return token = 70; + } + else { + return pos += 1, token = 0; + } + } + function speculationHelper(callback, isLookahead) { + var savePos = pos; + var saveStartPos = startPos; + var saveTokenPos = tokenPos; + var saveToken = token; + var saveTokenValue = tokenValue; + var savePrecedingLineBreak = precedingLineBreak; + var result = callback(); + if (!result || isLookahead) { + pos = savePos; + startPos = saveStartPos; + tokenPos = saveTokenPos; + token = saveToken; + tokenValue = saveTokenValue; + precedingLineBreak = savePrecedingLineBreak; + } + return result; + } + function scanRange(start, length, callback) { + var saveEnd = end; + var savePos = pos; + var saveStartPos = startPos; + var saveTokenPos = tokenPos; + var saveToken = token; + var savePrecedingLineBreak = precedingLineBreak; + var saveTokenValue = tokenValue; + var saveHasExtendedUnicodeEscape = hasExtendedUnicodeEscape; + var saveTokenIsUnterminated = tokenIsUnterminated; + setText(text, start, length); + var result = callback(); + end = saveEnd; + pos = savePos; + startPos = saveStartPos; + tokenPos = saveTokenPos; + token = saveToken; + precedingLineBreak = savePrecedingLineBreak; + tokenValue = saveTokenValue; + hasExtendedUnicodeEscape = saveHasExtendedUnicodeEscape; + tokenIsUnterminated = saveTokenIsUnterminated; + return result; + } + function lookAhead(callback) { + return speculationHelper(callback, true); + } + function tryScan(callback) { + return speculationHelper(callback, false); + } + function getText() { + return text; + } + function setText(newText, start, length) { + text = newText || ""; + end = length === undefined ? text.length : start + length; + setTextPos(start || 0); + } + function setOnError(errorCallback) { + onError = errorCallback; + } + function setScriptTarget(scriptTarget) { + languageVersion = scriptTarget; + } + function setLanguageVariant(variant) { + languageVariant = variant; + } + function setTextPos(textPos) { + ts.Debug.assert(textPos >= 0); + pos = textPos; + startPos = textPos; + tokenPos = textPos; + token = 0; + precedingLineBreak = false; + tokenValue = undefined; + hasExtendedUnicodeEscape = false; + tokenIsUnterminated = false; + } + } + ts.createScanner = createScanner; +})(ts || (ts = {})); +var ts; (function (ts) { var NodeConstructor; var SourceFileConstructor; @@ -10216,7 +9692,7 @@ var ts; return node; } else if (typeof value === "boolean") { - return createNode(value ? 99 : 84, location, undefined); + return createNode(value ? 100 : 85, location, undefined); } else if (typeof value === "string") { var node = createNode(9, location, undefined); @@ -10233,7 +9709,7 @@ var ts; ts.createLiteral = createLiteral; var nextAutoGenerateId = 0; function createIdentifier(text, location) { - var node = createNode(69, location); + var node = createNode(70, location); node.text = ts.escapeIdentifier(text); node.originalKeywordKind = ts.stringToToken(text); node.autoGenerateKind = 0; @@ -10242,7 +9718,7 @@ var ts; } ts.createIdentifier = createIdentifier; function createTempVariable(recordTempVariable, location) { - var name = createNode(69, location); + var name = createNode(70, location); name.text = ""; name.originalKeywordKind = 0; name.autoGenerateKind = 1; @@ -10255,7 +9731,7 @@ var ts; } ts.createTempVariable = createTempVariable; function createLoopVariable(location) { - var name = createNode(69, location); + var name = createNode(70, location); name.text = ""; name.originalKeywordKind = 0; name.autoGenerateKind = 2; @@ -10265,7 +9741,7 @@ var ts; } ts.createLoopVariable = createLoopVariable; function createUniqueName(text, location) { - var name = createNode(69, location); + var name = createNode(70, location); name.text = text; name.originalKeywordKind = 0; name.autoGenerateKind = 3; @@ -10275,7 +9751,7 @@ var ts; } ts.createUniqueName = createUniqueName; function getGeneratedNameForNode(node, location) { - var name = createNode(69, location); + var name = createNode(70, location); name.original = node; name.text = ""; name.originalKeywordKind = 0; @@ -10290,22 +9766,22 @@ var ts; } ts.createToken = createToken; function createSuper() { - var node = createNode(95); + var node = createNode(96); return node; } ts.createSuper = createSuper; function createThis(location) { - var node = createNode(97, location); + var node = createNode(98, location); return node; } ts.createThis = createThis; function createNull() { - var node = createNode(93); + var node = createNode(94); return node; } ts.createNull = createNull; function createComputedPropertyName(expression, location) { - var node = createNode(140, location); + var node = createNode(141, location); node.expression = expression; return node; } @@ -10322,7 +9798,7 @@ var ts; } ts.createParameter = createParameter; function createParameterDeclaration(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer, location, flags) { - var node = createNode(142, location, flags); + var node = createNode(143, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.dotDotDotToken = dotDotDotToken; @@ -10341,7 +9817,7 @@ var ts; } ts.updateParameterDeclaration = updateParameterDeclaration; function createProperty(decorators, modifiers, name, questionToken, type, initializer, location) { - var node = createNode(145, location); + var node = createNode(146, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10359,7 +9835,7 @@ var ts; } ts.updateProperty = updateProperty; function createMethod(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(147, location, flags); + var node = createNode(148, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; @@ -10379,7 +9855,7 @@ var ts; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body, location, flags) { - var node = createNode(148, location, flags); + var node = createNode(149, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.typeParameters = undefined; @@ -10397,7 +9873,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body, location, flags) { - var node = createNode(149, location, flags); + var node = createNode(150, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10416,7 +9892,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body, location, flags) { - var node = createNode(150, location, flags); + var node = createNode(151, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10434,7 +9910,7 @@ var ts; } ts.updateSetAccessor = updateSetAccessor; function createObjectBindingPattern(elements, location) { - var node = createNode(167, location); + var node = createNode(168, location); node.elements = createNodeArray(elements); return node; } @@ -10447,7 +9923,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements, location) { - var node = createNode(168, location); + var node = createNode(169, location); node.elements = createNodeArray(elements); return node; } @@ -10460,7 +9936,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(propertyName, dotDotDotToken, name, initializer, location) { - var node = createNode(169, location); + var node = createNode(170, location); node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; node.dotDotDotToken = dotDotDotToken; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10476,7 +9952,7 @@ var ts; } ts.updateBindingElement = updateBindingElement; function createArrayLiteral(elements, location, multiLine) { - var node = createNode(170, location); + var node = createNode(171, location); node.elements = parenthesizeListElements(createNodeArray(elements)); if (multiLine) { node.multiLine = true; @@ -10492,7 +9968,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, location, multiLine) { - var node = createNode(171, location); + var node = createNode(172, location); node.properties = createNodeArray(properties); if (multiLine) { node.multiLine = true; @@ -10508,7 +9984,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name, location, flags) { - var node = createNode(172, location, flags); + var node = createNode(173, location, flags); node.expression = parenthesizeForAccess(expression); (node.emitNode || (node.emitNode = {})).flags |= 1048576; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10525,7 +10001,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index, location) { - var node = createNode(173, location); + var node = createNode(174, location); node.expression = parenthesizeForAccess(expression); node.argumentExpression = typeof index === "number" ? createLiteral(index) : index; return node; @@ -10539,7 +10015,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(174, location, flags); + var node = createNode(175, location, flags); node.expression = parenthesizeForAccess(expression); if (typeArguments) { node.typeArguments = createNodeArray(typeArguments); @@ -10556,7 +10032,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(175, location, flags); + var node = createNode(176, location, flags); node.expression = parenthesizeForNew(expression); node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; node.arguments = argumentsArray ? parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -10571,7 +10047,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, template, location) { - var node = createNode(176, location); + var node = createNode(177, location); node.tag = parenthesizeForAccess(tag); node.template = template; return node; @@ -10585,7 +10061,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createParen(expression, location) { - var node = createNode(178, location); + var node = createNode(179, location); node.expression = expression; return node; } @@ -10597,9 +10073,9 @@ var ts; return node; } ts.updateParen = updateParen; - function createFunctionExpression(asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(179, location, flags); - node.modifiers = undefined; + function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { + var node = createNode(180, location, flags); + node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; node.name = typeof name === "string" ? createIdentifier(name) : name; node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; @@ -10609,20 +10085,20 @@ var ts; return node; } ts.createFunctionExpression = createFunctionExpression; - function updateFunctionExpression(node, name, typeParameters, parameters, type, body) { - if (node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createFunctionExpression(node.asteriskToken, name, typeParameters, parameters, type, body, node, node.flags), node); + function updateFunctionExpression(node, modifiers, name, typeParameters, parameters, type, body) { + if (node.name !== name || node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { + return updateNode(createFunctionExpression(modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, node, node.flags), node); } return node; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body, location, flags) { - var node = createNode(180, location, flags); + var node = createNode(181, location, flags); node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; node.parameters = createNodeArray(parameters); node.type = type; - node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(34); + node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(35); node.body = parenthesizeConciseBody(body); return node; } @@ -10635,7 +10111,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression, location) { - var node = createNode(181, location); + var node = createNode(182, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10648,7 +10124,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression, location) { - var node = createNode(182, location); + var node = createNode(183, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10661,7 +10137,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression, location) { - var node = createNode(183, location); + var node = createNode(184, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10674,7 +10150,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression, location) { - var node = createNode(184, location); + var node = createNode(185, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10687,7 +10163,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand, location) { - var node = createNode(185, location); + var node = createNode(186, location); node.operator = operator; node.operand = parenthesizePrefixOperand(operand); return node; @@ -10701,7 +10177,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator, location) { - var node = createNode(186, location); + var node = createNode(187, location); node.operand = parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -10717,7 +10193,7 @@ var ts; function createBinary(left, operator, right, location) { var operatorToken = typeof operator === "number" ? createToken(operator) : operator; var operatorKind = operatorToken.kind; - var node = createNode(187, location); + var node = createNode(188, location); node.left = parenthesizeBinaryOperand(operatorKind, left, true, undefined); node.operatorToken = operatorToken; node.right = parenthesizeBinaryOperand(operatorKind, right, false, node.left); @@ -10732,7 +10208,7 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionToken, whenTrue, colonToken, whenFalse, location) { - var node = createNode(188, location); + var node = createNode(189, location); node.condition = condition; node.questionToken = questionToken; node.whenTrue = whenTrue; @@ -10749,7 +10225,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans, location) { - var node = createNode(189, location); + var node = createNode(190, location); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -10763,7 +10239,7 @@ var ts; } ts.updateTemplateExpression = updateTemplateExpression; function createYield(asteriskToken, expression, location) { - var node = createNode(190, location); + var node = createNode(191, location); node.asteriskToken = asteriskToken; node.expression = expression; return node; @@ -10777,7 +10253,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression, location) { - var node = createNode(191, location); + var node = createNode(192, location); node.expression = parenthesizeExpressionForList(expression); return node; } @@ -10790,7 +10266,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(192, location); + var node = createNode(193, location); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -10808,12 +10284,12 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression(location) { - var node = createNode(193, location); + var node = createNode(194, location); return node; } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression, location) { - var node = createNode(194, location); + var node = createNode(195, location); node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; node.expression = parenthesizeForAccess(expression); return node; @@ -10827,7 +10303,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createTemplateSpan(expression, literal, location) { - var node = createNode(197, location); + var node = createNode(198, location); node.expression = expression; node.literal = literal; return node; @@ -10841,7 +10317,7 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createBlock(statements, location, multiLine, flags) { - var block = createNode(199, location, flags); + var block = createNode(200, location, flags); block.statements = createNodeArray(statements); if (multiLine) { block.multiLine = true; @@ -10857,7 +10333,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList, location, flags) { - var node = createNode(200, location, flags); + var node = createNode(201, location, flags); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -10872,7 +10348,7 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createVariableDeclarationList(declarations, location, flags) { - var node = createNode(219, location, flags); + var node = createNode(220, location, flags); node.declarations = createNodeArray(declarations); return node; } @@ -10885,7 +10361,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createVariableDeclaration(name, type, initializer, location, flags) { - var node = createNode(218, location, flags); + var node = createNode(219, location, flags); node.name = typeof name === "string" ? createIdentifier(name) : name; node.type = type; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -10900,11 +10376,11 @@ var ts; } ts.updateVariableDeclaration = updateVariableDeclaration; function createEmptyStatement(location) { - return createNode(201, location); + return createNode(202, location); } ts.createEmptyStatement = createEmptyStatement; function createStatement(expression, location, flags) { - var node = createNode(202, location, flags); + var node = createNode(203, location, flags); node.expression = parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -10917,7 +10393,7 @@ var ts; } ts.updateStatement = updateStatement; function createIf(expression, thenStatement, elseStatement, location) { - var node = createNode(203, location); + var node = createNode(204, location); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -10932,7 +10408,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression, location) { - var node = createNode(204, location); + var node = createNode(205, location); node.statement = statement; node.expression = expression; return node; @@ -10946,7 +10422,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement, location) { - var node = createNode(205, location); + var node = createNode(206, location); node.expression = expression; node.statement = statement; return node; @@ -10960,7 +10436,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement, location) { - var node = createNode(206, location, undefined); + var node = createNode(207, location, undefined); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -10976,7 +10452,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement, location) { - var node = createNode(207, location); + var node = createNode(208, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -10991,7 +10467,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(initializer, expression, statement, location) { - var node = createNode(208, location); + var node = createNode(209, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11006,7 +10482,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label, location) { - var node = createNode(209, location); + var node = createNode(210, location); if (label) { node.label = label; } @@ -11021,7 +10497,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label, location) { - var node = createNode(210, location); + var node = createNode(211, location); if (label) { node.label = label; } @@ -11036,7 +10512,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression, location) { - var node = createNode(211, location); + var node = createNode(212, location); node.expression = expression; return node; } @@ -11049,7 +10525,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement, location) { - var node = createNode(212, location); + var node = createNode(213, location); node.expression = expression; node.statement = statement; return node; @@ -11063,7 +10539,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock, location) { - var node = createNode(213, location); + var node = createNode(214, location); node.expression = parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -11077,7 +10553,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement, location) { - var node = createNode(214, location); + var node = createNode(215, location); node.label = typeof label === "string" ? createIdentifier(label) : label; node.statement = statement; return node; @@ -11091,7 +10567,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression, location) { - var node = createNode(215, location); + var node = createNode(216, location); node.expression = expression; return node; } @@ -11104,7 +10580,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock, location) { - var node = createNode(216, location); + var node = createNode(217, location); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -11119,7 +10595,7 @@ var ts; } ts.updateTry = updateTry; function createCaseBlock(clauses, location) { - var node = createNode(227, location); + var node = createNode(228, location); node.clauses = createNodeArray(clauses); return node; } @@ -11132,7 +10608,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(220, location, flags); + var node = createNode(221, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; @@ -11152,7 +10628,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(221, location); + var node = createNode(222, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -11170,7 +10646,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, location) { - var node = createNode(230, location); + var node = createNode(231, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.importClause = importClause; @@ -11186,7 +10662,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings, location) { - var node = createNode(231, location); + var node = createNode(232, location); node.name = name; node.namedBindings = namedBindings; return node; @@ -11200,7 +10676,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name, location) { - var node = createNode(232, location); + var node = createNode(233, location); node.name = name; return node; } @@ -11213,7 +10689,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements, location) { - var node = createNode(233, location); + var node = createNode(234, location); node.elements = createNodeArray(elements); return node; } @@ -11226,7 +10702,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name, location) { - var node = createNode(234, location); + var node = createNode(235, location); node.propertyName = propertyName; node.name = name; return node; @@ -11240,7 +10716,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression, location) { - var node = createNode(235, location); + var node = createNode(236, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.isExportEquals = isExportEquals; @@ -11256,7 +10732,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, location) { - var node = createNode(236, location); + var node = createNode(237, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.exportClause = exportClause; @@ -11272,7 +10748,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements, location) { - var node = createNode(237, location); + var node = createNode(238, location); node.elements = createNodeArray(elements); return node; } @@ -11285,7 +10761,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(name, propertyName, location) { - var node = createNode(238, location); + var node = createNode(239, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; return node; @@ -11299,7 +10775,7 @@ var ts; } ts.updateExportSpecifier = updateExportSpecifier; function createJsxElement(openingElement, children, closingElement, location) { - var node = createNode(241, location); + var node = createNode(242, location); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -11314,7 +10790,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, attributes, location) { - var node = createNode(242, location); + var node = createNode(243, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -11328,7 +10804,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, attributes, location) { - var node = createNode(243, location); + var node = createNode(244, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -11562,47 +11038,47 @@ var ts; } ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function createComma(left, right) { - return createBinary(left, 24, right); + return createBinary(left, 25, right); } ts.createComma = createComma; function createLessThan(left, right, location) { - return createBinary(left, 25, right, location); + return createBinary(left, 26, right, location); } ts.createLessThan = createLessThan; function createAssignment(left, right, location) { - return createBinary(left, 56, right, location); + return createBinary(left, 57, right, location); } ts.createAssignment = createAssignment; function createStrictEquality(left, right) { - return createBinary(left, 32, right); + return createBinary(left, 33, right); } ts.createStrictEquality = createStrictEquality; function createStrictInequality(left, right) { - return createBinary(left, 33, right); + return createBinary(left, 34, right); } ts.createStrictInequality = createStrictInequality; function createAdd(left, right) { - return createBinary(left, 35, right); + return createBinary(left, 36, right); } ts.createAdd = createAdd; function createSubtract(left, right) { - return createBinary(left, 36, right); + return createBinary(left, 37, right); } ts.createSubtract = createSubtract; function createPostfixIncrement(operand, location) { - return createPostfix(operand, 41, location); + return createPostfix(operand, 42, location); } ts.createPostfixIncrement = createPostfixIncrement; function createLogicalAnd(left, right) { - return createBinary(left, 51, right); + return createBinary(left, 52, right); } ts.createLogicalAnd = createLogicalAnd; function createLogicalOr(left, right) { - return createBinary(left, 52, right); + return createBinary(left, 53, right); } ts.createLogicalOr = createLogicalOr; function createLogicalNot(operand) { - return createPrefix(49, operand); + return createPrefix(50, operand); } ts.createLogicalNot = createLogicalNot; function createVoidZero() { @@ -11621,7 +11097,7 @@ var ts; } ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName; function createRestParameter(name) { - return createParameterDeclaration(undefined, undefined, createToken(22), name, undefined, undefined, undefined); + return createParameterDeclaration(undefined, undefined, createToken(23), name, undefined, undefined, undefined); } ts.createRestParameter = createRestParameter; function createFunctionCall(func, thisArg, argumentsList, location) { @@ -11735,7 +11211,7 @@ var ts; } ts.createDecorateHelper = createDecorateHelper; function createAwaiterHelper(externalHelpersModuleName, hasLexicalArguments, promiseConstructor, body) { - var generatorFunc = createFunctionExpression(createToken(37), undefined, undefined, [], undefined, body); + var generatorFunc = createFunctionExpression(undefined, createToken(38), undefined, undefined, [], undefined, body); (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 2097152; return createCall(createHelperName(externalHelpersModuleName, "__awaiter"), undefined, [ createThis(), @@ -11779,7 +11255,7 @@ var ts; setter ])))))); return createVariableStatement(undefined, createConstDeclarationList([ - createVariableDeclaration("_super", undefined, createCall(createParen(createFunctionExpression(undefined, undefined, undefined, [ + createVariableDeclaration("_super", undefined, createCall(createParen(createFunctionExpression(undefined, undefined, undefined, undefined, [ createParameter("geti"), createParameter("seti") ], undefined, createBlock([ @@ -11801,19 +11277,19 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = skipParentheses(node); switch (target.kind) { - case 69: + case 70: return cacheIdentifiers; - case 97: + case 98: case 8: case 9: return false; - case 170: + case 171: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 171: + case 172: return target.properties.length > 0; default: return true; @@ -11827,13 +11303,13 @@ var ts; thisArg = createThis(); target = callee; } - else if (callee.kind === 95) { + else if (callee.kind === 96) { thisArg = createThis(); target = languageVersion < 2 ? createIdentifier("_super", callee) : callee; } else { switch (callee.kind) { - case 172: { + case 173: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { thisArg = createTempVariable(recordTempVariable); target = createPropertyAccess(createAssignment(thisArg, callee.expression, callee.expression), callee.name, callee); @@ -11844,7 +11320,7 @@ var ts; } break; } - case 173: { + case 174: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { thisArg = createTempVariable(recordTempVariable); target = createElementAccess(createAssignment(thisArg, callee.expression, callee.expression), callee.argumentExpression, callee); @@ -11894,14 +11370,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 149: case 150: + case 151: return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); case 253: return createExpressionForPropertyAssignment(property, receiver); case 254: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 147: + case 148: return createExpressionForMethodDeclaration(property, receiver); } } @@ -11911,13 +11387,13 @@ var ts; if (property === firstAccessor) { var properties_1 = []; if (getAccessor) { - var getterFunction = createFunctionExpression(undefined, undefined, undefined, getAccessor.parameters, undefined, getAccessor.body, getAccessor); + var getterFunction = createFunctionExpression(getAccessor.modifiers, undefined, undefined, undefined, getAccessor.parameters, undefined, getAccessor.body, getAccessor); setOriginalNode(getterFunction, getAccessor); var getter = createPropertyAssignment("get", getterFunction); properties_1.push(getter); } if (setAccessor) { - var setterFunction = createFunctionExpression(undefined, undefined, undefined, setAccessor.parameters, undefined, setAccessor.body, setAccessor); + var setterFunction = createFunctionExpression(setAccessor.modifiers, undefined, undefined, undefined, setAccessor.parameters, undefined, setAccessor.body, setAccessor); setOriginalNode(setterFunction, setAccessor); var setter = createPropertyAssignment("set", setterFunction); properties_1.push(setter); @@ -11940,13 +11416,13 @@ var ts; return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, property.name, property.name), getSynthesizedClone(property.name), property), property)); } function createExpressionForMethodDeclaration(method, receiver) { - return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, method.name, method.name), setOriginalNode(createFunctionExpression(method.asteriskToken, undefined, undefined, method.parameters, undefined, method.body, method), method), method), method)); + return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, method.name, method.name), setOriginalNode(createFunctionExpression(method.modifiers, method.asteriskToken, undefined, undefined, method.parameters, undefined, method.body, method), method), method), method)); } function isUseStrictPrologue(node) { return node.expression.text === "use strict"; } function addPrologueDirectives(target, source, ensureUseStrict, visitor) { - ts.Debug.assert(target.length === 0, "PrologueDirectives should be at the first statement in the target statements array"); + ts.Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array"); var foundUseStrict = false; var statementOffset = 0; var numStatements = source.length; @@ -11959,16 +11435,20 @@ var ts; target.push(statement); } else { - if (ensureUseStrict && !foundUseStrict) { - target.push(startOnNewLine(createStatement(createLiteral("use strict")))); - foundUseStrict = true; - } - if (getEmitFlags(statement) & 8388608) { - target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); - } - else { - break; - } + break; + } + statementOffset++; + } + if (ensureUseStrict && !foundUseStrict) { + target.push(startOnNewLine(createStatement(createLiteral("use strict")))); + } + while (statementOffset < numStatements) { + var statement = source[statementOffset]; + if (getEmitFlags(statement) & 8388608) { + target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); + } + else { + break; } statementOffset++; } @@ -11999,7 +11479,7 @@ var ts; ts.ensureUseStrict = ensureUseStrict; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = skipPartiallyEmittedExpressions(operand); - if (skipped.kind === 178) { + if (skipped.kind === 179) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -12008,15 +11488,15 @@ var ts; } ts.parenthesizeBinaryOperand = parenthesizeBinaryOperand; function binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { - var binaryOperatorPrecedence = ts.getOperatorPrecedence(187, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(187, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(188, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(188, binaryOperator); var emittedOperand = skipPartiallyEmittedExpressions(operand); var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { case -1: if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 - && operand.kind === 190) { + && operand.kind === 191) { return false; } return true; @@ -12032,7 +11512,7 @@ var ts; if (operatorHasAssociativeProperty(binaryOperator)) { return false; } - if (binaryOperator === 35) { + if (binaryOperator === 36) { var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0; if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { return false; @@ -12045,17 +11525,17 @@ var ts; } } function operatorHasAssociativeProperty(binaryOperator) { - return binaryOperator === 37 + return binaryOperator === 38 + || binaryOperator === 48 || binaryOperator === 47 - || binaryOperator === 46 - || binaryOperator === 48; + || binaryOperator === 49; } function getLiteralKindOfBinaryPlusOperand(node) { node = skipPartiallyEmittedExpressions(node); if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 187 && node.operatorToken.kind === 35) { + if (node.kind === 188 && node.operatorToken.kind === 36) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -12072,9 +11552,9 @@ var ts; function parenthesizeForNew(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); switch (emittedExpression.kind) { - case 174: - return createParen(expression); case 175: + return createParen(expression); + case 176: return emittedExpression.arguments ? expression : createParen(expression); @@ -12085,7 +11565,7 @@ var ts; function parenthesizeForAccess(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 175 || emittedExpression.arguments) + && (emittedExpression.kind !== 176 || emittedExpression.arguments) && emittedExpression.kind !== 8) { return expression; } @@ -12123,7 +11603,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(187, 24); + var commaPrecedence = ts.getOperatorPrecedence(188, 25); return expressionPrecedence > commaPrecedence ? expression : createParen(expression, expression); @@ -12134,7 +11614,7 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = skipPartiallyEmittedExpressions(callee).kind; - if (kind === 179 || kind === 180) { + if (kind === 180 || kind === 181) { var mutableCall = getMutableClone(emittedExpression); mutableCall.expression = createParen(callee, callee); return recreatePartiallyEmittedExpressions(expression, mutableCall); @@ -12142,7 +11622,7 @@ var ts; } else { var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; - if (leftmostExpressionKind === 171 || leftmostExpressionKind === 179) { + if (leftmostExpressionKind === 172 || leftmostExpressionKind === 180) { return createParen(expression, expression); } } @@ -12160,18 +11640,18 @@ var ts; function getLeftmostExpression(node) { while (true) { switch (node.kind) { - case 186: + case 187: node = node.operand; continue; - case 187: + case 188: node = node.left; continue; - case 188: + case 189: node = node.condition; continue; + case 175: case 174: case 173: - case 172: node = node.expression; continue; case 288: @@ -12183,12 +11663,19 @@ var ts; } function parenthesizeConciseBody(body) { var emittedBody = skipPartiallyEmittedExpressions(body); - if (emittedBody.kind === 171) { + if (emittedBody.kind === 172) { return createParen(body, body); } return body; } ts.parenthesizeConciseBody = parenthesizeConciseBody; + (function (OuterExpressionKinds) { + OuterExpressionKinds[OuterExpressionKinds["Parentheses"] = 1] = "Parentheses"; + OuterExpressionKinds[OuterExpressionKinds["Assertions"] = 2] = "Assertions"; + OuterExpressionKinds[OuterExpressionKinds["PartiallyEmittedExpressions"] = 4] = "PartiallyEmittedExpressions"; + OuterExpressionKinds[OuterExpressionKinds["All"] = 7] = "All"; + })(ts.OuterExpressionKinds || (ts.OuterExpressionKinds = {})); + var OuterExpressionKinds = ts.OuterExpressionKinds; function skipOuterExpressions(node, kinds) { if (kinds === void 0) { kinds = 7; } var previousNode; @@ -12208,7 +11695,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipParentheses(node) { - while (node.kind === 178) { + while (node.kind === 179) { node = node.expression; } return node; @@ -12368,13 +11855,13 @@ var ts; function getLocalNameForExternalImport(node, sourceFile) { var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); if (namespaceDeclaration && !ts.isDefaultImport(node)) { - var name_12 = namespaceDeclaration.name; - return ts.isGeneratedIdentifier(name_12) ? name_12 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); + var name_9 = namespaceDeclaration.name; + return ts.isGeneratedIdentifier(name_9) ? name_9 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); } - if (node.kind === 230 && node.importClause) { + if (node.kind === 231 && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 236 && node.moduleSpecifier) { + if (node.kind === 237 && node.moduleSpecifier) { return getGeneratedNameForNode(node); } return undefined; @@ -12423,10 +11910,10 @@ var ts; if (kind === 256) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } - else if (kind === 69) { + else if (kind === 70) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } - else if (kind < 139) { + else if (kind < 140) { return new (TokenConstructor || (TokenConstructor = ts.objectAllocator.getTokenConstructor()))(kind, pos, end); } else { @@ -12462,10 +11949,10 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 139: + case 140: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 141: + case 142: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); @@ -12476,12 +11963,12 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 142: + case 143: + case 146: case 145: - case 144: case 253: - case 218: - case 169: + case 219: + case 170: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -12490,24 +11977,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 156: case 157: - case 151: + case 158: case 152: case 153: + case 154: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 147: - case 146: case 148: + case 147: case 149: case 150: - case 179: - case 220: + case 151: case 180: + case 221: + case 181: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -12518,163 +12005,156 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 155: + case 156: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 154: + case 155: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 158: - return visitNode(cbNode, node.exprName); case 159: - return visitNodes(cbNodes, node.members); + return visitNode(cbNode, node.exprName); case 160: - return visitNode(cbNode, node.elementType); + return visitNodes(cbNodes, node.members); case 161: - return visitNodes(cbNodes, node.elementTypes); + return visitNode(cbNode, node.elementType); case 162: + return visitNodes(cbNodes, node.elementTypes); case 163: - return visitNodes(cbNodes, node.types); case 164: + return visitNodes(cbNodes, node.types); + case 165: return visitNode(cbNode, node.type); - case 166: - return visitNode(cbNode, node.literal); case 167: + return visitNode(cbNode, node.literal); case 168: - return visitNodes(cbNodes, node.elements); - case 170: + case 169: return visitNodes(cbNodes, node.elements); case 171: - return visitNodes(cbNodes, node.properties); + return visitNodes(cbNodes, node.elements); case 172: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.name); + return visitNodes(cbNodes, node.properties); case 173: return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.argumentExpression); + visitNode(cbNode, node.name); case 174: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.argumentExpression); case 175: + case 176: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 176: + case 177: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 177: + case 178: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 178: - return visitNode(cbNode, node.expression); - case 181: + case 179: return visitNode(cbNode, node.expression); case 182: return visitNode(cbNode, node.expression); case 183: return visitNode(cbNode, node.expression); - case 185: - return visitNode(cbNode, node.operand); - case 190: - return visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.expression); case 184: return visitNode(cbNode, node.expression); case 186: return visitNode(cbNode, node.operand); + case 191: + return visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.expression); + case 185: + return visitNode(cbNode, node.expression); case 187: + return visitNode(cbNode, node.operand); + case 188: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 195: + case 196: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 196: + case 197: return visitNode(cbNode, node.expression); - case 188: + case 189: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 191: + case 192: return visitNode(cbNode, node.expression); - case 199: - case 226: + case 200: + case 227: return visitNodes(cbNodes, node.statements); case 256: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 200: + case 201: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 219: + case 220: return visitNodes(cbNodes, node.declarations); - case 202: - return visitNode(cbNode, node.expression); case 203: + return visitNode(cbNode, node.expression); + case 204: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 204: + case 205: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 205: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); case 206: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.condition) || - visitNode(cbNode, node.incrementor) || + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 207: return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || + visitNode(cbNode, node.condition) || + visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); case 208: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 209: - case 210: - return visitNode(cbNode, node.label); - case 211: - return visitNode(cbNode, node.expression); - case 212: - return visitNode(cbNode, node.expression) || + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); + case 210: + case 211: + return visitNode(cbNode, node.label); + case 212: + return visitNode(cbNode, node.expression); case 213: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 214: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 227: + case 228: return visitNodes(cbNodes, node.clauses); case 249: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); case 250: return visitNodes(cbNodes, node.statements); - case 214: + case 215: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 215: - return visitNode(cbNode, node.expression); case 216: + return visitNode(cbNode, node.expression); + case 217: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); case 252: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 143: + case 144: return visitNode(cbNode, node.expression); - case 221: - case 192: - 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 222: + case 193: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -12686,8 +12166,15 @@ var ts; visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || - visitNode(cbNode, node.type); + visitNodes(cbNodes, node.heritageClauses) || + visitNodes(cbNodes, node.members); case 224: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNode(cbNode, node.type); + case 225: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -12695,65 +12182,65 @@ var ts; case 255: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 225: + case 226: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 229: + case 230: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 230: + case 231: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 231: + case 232: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 228: - return visitNode(cbNode, node.name); - case 232: + case 229: return visitNode(cbNode, node.name); case 233: - case 237: + return visitNode(cbNode, node.name); + case 234: + case 238: return visitNodes(cbNodes, node.elements); - case 236: + case 237: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 234: - case 238: + case 235: + case 239: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 235: + case 236: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 189: + case 190: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 197: + case 198: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 140: + case 141: return visitNode(cbNode, node.expression); case 251: return visitNodes(cbNodes, node.types); - case 194: + case 195: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 240: - return visitNode(cbNode, node.expression); - case 239: - return visitNodes(cbNodes, node.decorators); case 241: + return visitNode(cbNode, node.expression); + case 240: + return visitNodes(cbNodes, node.decorators); + case 242: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 242: case 243: + case 244: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); case 246: @@ -12855,7 +12342,7 @@ var ts; ts.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; var Parser; (function (Parser) { - var scanner = ts.createScanner(2, true); + var scanner = ts.createScanner(4, true); var disallowInAndDecoratorContext = 32768 | 131072; var NodeConstructor; var TokenConstructor; @@ -12872,9 +12359,9 @@ var ts; var parsingContext; var contextFlags; var parseErrorBeforeNextFinishedNode = false; - function parseSourceFile(fileName, _sourceText, languageVersion, _syntaxCursor, setParentNodes, scriptKind) { + function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes, scriptKind) { scriptKind = ts.ensureScriptKind(fileName, scriptKind); - initializeState(fileName, _sourceText, languageVersion, _syntaxCursor, scriptKind); + initializeState(sourceText, languageVersion, syntaxCursor, scriptKind); var result = parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind); clearState(); return result; @@ -12883,7 +12370,7 @@ var ts; function getLanguageVariant(scriptKind) { return scriptKind === 4 || scriptKind === 2 || scriptKind === 1 ? 1 : 0; } - function initializeState(fileName, _sourceText, languageVersion, _syntaxCursor, scriptKind) { + function initializeState(_sourceText, languageVersion, _syntaxCursor, scriptKind) { NodeConstructor = ts.objectAllocator.getNodeConstructor(); TokenConstructor = ts.objectAllocator.getTokenConstructor(); IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor(); @@ -13126,16 +12613,16 @@ var ts; return speculationHelper(callback, false); } function isIdentifier() { - if (token() === 69) { + if (token() === 70) { return true; } - if (token() === 114 && inYieldContext()) { + if (token() === 115 && inYieldContext()) { return false; } - if (token() === 119 && inAwaitContext()) { + if (token() === 120 && inAwaitContext()) { return false; } - return token() > 105; + return token() > 106; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -13176,20 +12663,20 @@ var ts; return finishNode(node); } function canParseSemicolon() { - if (token() === 23) { + if (token() === 24) { return true; } - return token() === 16 || token() === 1 || scanner.hasPrecedingLineBreak(); + return token() === 17 || token() === 1 || scanner.hasPrecedingLineBreak(); } function parseSemicolon() { if (canParseSemicolon()) { - if (token() === 23) { + if (token() === 24) { nextToken(); } return true; } else { - return parseExpected(23); + return parseExpected(24); } } function createNode(kind, pos) { @@ -13197,8 +12684,8 @@ var ts; if (!(pos >= 0)) { pos = scanner.getStartPos(); } - return kind >= 139 ? new NodeConstructor(kind, pos, pos) : - kind === 69 ? new IdentifierConstructor(kind, pos, pos) : + return kind >= 140 ? new NodeConstructor(kind, pos, pos) : + kind === 70 ? new IdentifierConstructor(kind, pos, pos) : new TokenConstructor(kind, pos, pos); } function createNodeArray(elements, pos) { @@ -13239,15 +12726,15 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(69); - if (token() !== 69) { + var node = createNode(70); + if (token() !== 70) { node.originalKeywordKind = token(); } node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - return createMissingNode(69, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(70, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -13264,7 +12751,7 @@ var ts; if (token() === 9 || token() === 8) { return parseLiteralNode(true); } - if (allowComputedPropertyNames && token() === 19) { + if (allowComputedPropertyNames && token() === 20) { return parseComputedPropertyName(); } return parseIdentifierName(); @@ -13279,10 +12766,10 @@ var ts; return token() === 9 || token() === 8 || ts.tokenIsIdentifierOrKeyword(token()); } function parseComputedPropertyName() { - var node = createNode(140); - parseExpected(19); - node.expression = allowInAnd(parseExpression); + var node = createNode(141); parseExpected(20); + node.expression = allowInAnd(parseExpression); + parseExpected(21); return finishNode(node); } function parseContextualModifier(t) { @@ -13296,20 +12783,20 @@ var ts; return canFollowModifier(); } function nextTokenCanFollowModifier() { - if (token() === 74) { - return nextToken() === 81; + if (token() === 75) { + return nextToken() === 82; } - if (token() === 82) { + if (token() === 83) { nextToken(); - if (token() === 77) { + if (token() === 78) { return lookAhead(nextTokenIsClassOrFunctionOrAsync); } - return token() !== 37 && token() !== 116 && token() !== 15 && canFollowModifier(); + return token() !== 38 && token() !== 117 && token() !== 16 && canFollowModifier(); } - if (token() === 77) { + if (token() === 78) { return nextTokenIsClassOrFunctionOrAsync(); } - if (token() === 113) { + if (token() === 114) { nextToken(); return canFollowModifier(); } @@ -13319,16 +12806,16 @@ var ts; return ts.isModifierKind(token()) && tryParse(nextTokenCanFollowModifier); } function canFollowModifier() { - return token() === 19 - || token() === 15 - || token() === 37 - || token() === 22 + return token() === 20 + || token() === 16 + || token() === 38 + || token() === 23 || isLiteralPropertyName(); } function nextTokenIsClassOrFunctionOrAsync() { nextToken(); - return token() === 73 || token() === 87 || - (token() === 118 && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 74 || token() === 88 || + (token() === 119 && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } function isListElement(parsingContext, inErrorRecovery) { var node = currentNode(parsingContext); @@ -13339,21 +12826,21 @@ var ts; case 0: case 1: case 3: - return !(token() === 23 && inErrorRecovery) && isStartOfStatement(); + return !(token() === 24 && inErrorRecovery) && isStartOfStatement(); case 2: - return token() === 71 || token() === 77; + return token() === 72 || token() === 78; case 4: return lookAhead(isTypeMemberStart); case 5: - return lookAhead(isClassMemberStart) || (token() === 23 && !inErrorRecovery); + return lookAhead(isClassMemberStart) || (token() === 24 && !inErrorRecovery); case 6: - return token() === 19 || isLiteralPropertyName(); + return token() === 20 || isLiteralPropertyName(); case 12: - return token() === 19 || token() === 37 || isLiteralPropertyName(); + return token() === 20 || token() === 38 || isLiteralPropertyName(); case 9: - return token() === 19 || isLiteralPropertyName(); + return token() === 20 || isLiteralPropertyName(); case 7: - if (token() === 15) { + if (token() === 16) { return lookAhead(isValidHeritageClauseObjectLiteral); } if (!inErrorRecovery) { @@ -13365,23 +12852,23 @@ var ts; case 8: return isIdentifierOrPattern(); case 10: - return token() === 24 || token() === 22 || isIdentifierOrPattern(); + return token() === 25 || token() === 23 || isIdentifierOrPattern(); case 17: return isIdentifier(); case 11: case 15: - return token() === 24 || token() === 22 || isStartOfExpression(); + return token() === 25 || token() === 23 || isStartOfExpression(); case 16: return isStartOfParameter(); case 18: case 19: - return token() === 24 || isStartOfType(); + return token() === 25 || isStartOfType(); case 20: return isHeritageClause(); case 21: return ts.tokenIsIdentifierOrKeyword(token()); case 13: - return ts.tokenIsIdentifierOrKeyword(token()) || token() === 15; + return ts.tokenIsIdentifierOrKeyword(token()) || token() === 16; case 14: return true; case 22: @@ -13394,10 +12881,10 @@ var ts; ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token() === 15); - if (nextToken() === 16) { + ts.Debug.assert(token() === 16); + if (nextToken() === 17) { var next = nextToken(); - return next === 24 || next === 15 || next === 83 || next === 106; + return next === 25 || next === 16 || next === 84 || next === 107; } return true; } @@ -13410,8 +12897,8 @@ var ts; return ts.tokenIsIdentifierOrKeyword(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 106 || - token() === 83) { + if (token() === 107 || + token() === 84) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -13433,39 +12920,39 @@ var ts; case 12: case 9: case 21: - return token() === 16; + return token() === 17; case 3: - return token() === 16 || token() === 71 || token() === 77; + return token() === 17 || token() === 72 || token() === 78; case 7: - return token() === 15 || token() === 83 || token() === 106; + return token() === 16 || token() === 84 || token() === 107; case 8: return isVariableDeclaratorListTerminator(); case 17: - return token() === 27 || token() === 17 || token() === 15 || token() === 83 || token() === 106; + return token() === 28 || token() === 18 || token() === 16 || token() === 84 || token() === 107; case 11: - return token() === 18 || token() === 23; + return token() === 19 || token() === 24; case 15: case 19: case 10: - return token() === 20; + return token() === 21; case 16: - return token() === 18 || token() === 20; + return token() === 19 || token() === 21; case 18: - return token() !== 24; + return token() !== 25; case 20: - return token() === 15 || token() === 16; + return token() === 16 || token() === 17; case 13: - return token() === 27 || token() === 39; + return token() === 28 || token() === 40; case 14: - return token() === 25 && lookAhead(nextTokenIsSlash); + return token() === 26 && lookAhead(nextTokenIsSlash); case 22: - return token() === 18 || token() === 54 || token() === 16; + return token() === 19 || token() === 55 || token() === 17; case 23: - return token() === 27 || token() === 16; + return token() === 28 || token() === 17; case 25: - return token() === 20 || token() === 16; + return token() === 21 || token() === 17; case 24: - return token() === 16; + return token() === 17; } } function isVariableDeclaratorListTerminator() { @@ -13475,7 +12962,7 @@ var ts; if (isInOrOfKeyword(token())) { return true; } - if (token() === 34) { + if (token() === 35) { return true; } return false; @@ -13579,17 +13066,17 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 148: - case 153: case 149: + case 154: case 150: - case 145: - case 198: + case 151: + case 146: + case 199: return true; - case 147: + case 148: var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 69 && - methodDeclaration.name.originalKeywordKind === 121; + var nameIsConstructor = methodDeclaration.name.kind === 70 && + methodDeclaration.name.originalKeywordKind === 122; return !nameIsConstructor; } } @@ -13608,35 +13095,35 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 220: + case 221: + case 201: case 200: - case 199: + case 204: case 203: - case 202: - case 215: + case 216: + case 212: + case 214: case 211: - case 213: case 210: + case 208: case 209: case 207: - case 208: case 206: - case 205: - case 212: - case 201: - case 216: - case 214: - case 204: + case 213: + case 202: case 217: + case 215: + case 205: + case 218: + case 231: case 230: - case 229: + case 237: case 236: - case 235: - case 225: - case 221: + case 226: case 222: - case 224: case 223: + case 225: + case 224: return true; } } @@ -13648,25 +13135,25 @@ var ts; function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 152: - case 146: case 153: - case 144: - case 151: + case 147: + case 154: + case 145: + case 152: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 218) { + if (node.kind !== 219) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 142) { + if (node.kind !== 143) { return false; } var parameter = node; @@ -13720,15 +13207,15 @@ var ts; if (isListElement(kind, false)) { result.push(parseListElement(kind, parseElement)); commaStart = scanner.getTokenPos(); - if (parseOptional(24)) { + if (parseOptional(25)) { continue; } commaStart = -1; if (isListTerminator(kind)) { break; } - parseExpected(24); - if (considerSemicolonAsDelimiter && token() === 23 && !scanner.hasPrecedingLineBreak()) { + parseExpected(25); + if (considerSemicolonAsDelimiter && token() === 24 && !scanner.hasPrecedingLineBreak()) { nextToken(); } continue; @@ -13760,8 +13247,8 @@ var ts; } function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); - while (parseOptional(21)) { - var node = createNode(139, entity.pos); + while (parseOptional(22)) { + var node = createNode(140, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -13772,33 +13259,33 @@ var ts; if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token())) { var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); if (matchesPattern) { - return createMissingNode(69, true, ts.Diagnostics.Identifier_expected); + return createMissingNode(70, true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(189); + var template = createNode(190); template.head = parseTemplateHead(); - ts.Debug.assert(template.head.kind === 12, "Template head has wrong token kind"); + ts.Debug.assert(template.head.kind === 13, "Template head has wrong token kind"); var templateSpans = createNodeArray(); do { templateSpans.push(parseTemplateSpan()); - } while (ts.lastOrUndefined(templateSpans).literal.kind === 13); + } while (ts.lastOrUndefined(templateSpans).literal.kind === 14); templateSpans.end = getNodeEnd(); template.templateSpans = templateSpans; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(197); + var span = createNode(198); span.expression = allowInAnd(parseExpression); var literal; - if (token() === 16) { + if (token() === 17) { reScanTemplateToken(); literal = parseTemplateMiddleOrTemplateTail(); } else { - literal = parseExpectedToken(14, false, ts.Diagnostics._0_expected, ts.tokenToString(16)); + literal = parseExpectedToken(15, false, ts.Diagnostics._0_expected, ts.tokenToString(17)); } span.literal = literal; return finishNode(span); @@ -13808,12 +13295,12 @@ var ts; } function parseTemplateHead() { var fragment = parseLiteralLikeNode(token(), false); - ts.Debug.assert(fragment.kind === 12, "Template head has wrong token kind"); + ts.Debug.assert(fragment.kind === 13, "Template head has wrong token kind"); return fragment; } function parseTemplateMiddleOrTemplateTail() { var fragment = parseLiteralLikeNode(token(), false); - ts.Debug.assert(fragment.kind === 13 || fragment.kind === 14, "Template fragment has wrong token kind"); + ts.Debug.assert(fragment.kind === 14 || fragment.kind === 15, "Template fragment has wrong token kind"); return fragment; } function parseLiteralLikeNode(kind, internName) { @@ -13838,35 +13325,35 @@ var ts; } function parseTypeReference() { var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - var node = createNode(155, typeName.pos); + var node = createNode(156, typeName.pos); node.typeName = typeName; - if (!scanner.hasPrecedingLineBreak() && token() === 25) { - node.typeArguments = parseBracketedList(18, parseType, 25, 27); + if (!scanner.hasPrecedingLineBreak() && token() === 26) { + node.typeArguments = parseBracketedList(18, parseType, 26, 28); } return finishNode(node); } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(154, lhs.pos); + var node = createNode(155, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(165); + var node = createNode(166); nextToken(); return finishNode(node); } function parseTypeQuery() { - var node = createNode(158); - parseExpected(101); + var node = createNode(159); + parseExpected(102); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(141); + var node = createNode(142); node.name = parseIdentifier(); - if (parseOptional(83)) { + if (parseOptional(84)) { if (isStartOfType() || !isStartOfExpression()) { node.constraint = parseType(); } @@ -13877,34 +13364,34 @@ var ts; return finishNode(node); } function parseTypeParameters() { - if (token() === 25) { - return parseBracketedList(17, parseTypeParameter, 25, 27); + if (token() === 26) { + return parseBracketedList(17, parseTypeParameter, 26, 28); } } function parseParameterType() { - if (parseOptional(54)) { + if (parseOptional(55)) { return parseType(); } return undefined; } function isStartOfParameter() { - return token() === 22 || isIdentifierOrPattern() || ts.isModifierKind(token()) || token() === 55 || token() === 97; + return token() === 23 || isIdentifierOrPattern() || ts.isModifierKind(token()) || token() === 56 || token() === 98; } function parseParameter() { - var node = createNode(142); - if (token() === 97) { + var node = createNode(143); + if (token() === 98) { node.name = createIdentifier(true, undefined); node.type = parseParameterType(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - node.dotDotDotToken = parseOptionalToken(22); + node.dotDotDotToken = parseOptionalToken(23); node.name = parseIdentifierOrPattern(); if (ts.getFullWidth(node.name) === 0 && !ts.hasModifiers(node) && ts.isModifierKind(token())) { nextToken(); } - node.questionToken = parseOptionalToken(53); + node.questionToken = parseOptionalToken(54); node.type = parseParameterType(); node.initializer = parseBindingElementInitializer(true); return addJSDocComment(finishNode(node)); @@ -13916,7 +13403,7 @@ var ts; return parseInitializer(true); } function fillSignature(returnToken, yieldContext, awaitContext, requireCompleteParameterList, signature) { - var returnTokenRequired = returnToken === 34; + var returnTokenRequired = returnToken === 35; signature.typeParameters = parseTypeParameters(); signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); if (returnTokenRequired) { @@ -13928,7 +13415,7 @@ var ts; } } function parseParameterList(yieldContext, awaitContext, requireCompleteParameterList) { - if (parseExpected(17)) { + if (parseExpected(18)) { var savedYieldContext = inYieldContext(); var savedAwaitContext = inAwaitContext(); setYieldContext(yieldContext); @@ -13936,7 +13423,7 @@ var ts; var result = parseDelimitedList(16, parseParameter); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); - if (!parseExpected(18) && requireCompleteParameterList) { + if (!parseExpected(19) && requireCompleteParameterList) { return undefined; } return result; @@ -13944,29 +13431,29 @@ var ts; return requireCompleteParameterList ? undefined : createMissingList(); } function parseTypeMemberSemicolon() { - if (parseOptional(24)) { + if (parseOptional(25)) { return; } parseSemicolon(); } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 152) { - parseExpected(92); + if (kind === 153) { + parseExpected(93); } - fillSignature(54, false, false, false, node); + fillSignature(55, false, false, false, node); parseTypeMemberSemicolon(); return addJSDocComment(finishNode(node)); } function isIndexSignature() { - if (token() !== 19) { + if (token() !== 20) { return false; } return lookAhead(isUnambiguouslyIndexSignature); } function isUnambiguouslyIndexSignature() { nextToken(); - if (token() === 22 || token() === 20) { + if (token() === 23 || token() === 21) { return true; } if (ts.isModifierKind(token())) { @@ -13981,43 +13468,43 @@ var ts; else { nextToken(); } - if (token() === 54 || token() === 24) { + if (token() === 55 || token() === 25) { return true; } - if (token() !== 53) { + if (token() !== 54) { return false; } nextToken(); - return token() === 54 || token() === 24 || token() === 20; + return token() === 55 || token() === 25 || token() === 21; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(153, fullStart); + var node = createNode(154, fullStart); node.decorators = decorators; node.modifiers = modifiers; - node.parameters = parseBracketedList(16, parseParameter, 19, 20); + node.parameters = parseBracketedList(16, parseParameter, 20, 21); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); return finishNode(node); } function parsePropertyOrMethodSignature(fullStart, modifiers) { var name = parsePropertyName(); - var questionToken = parseOptionalToken(53); - if (token() === 17 || token() === 25) { - var method = createNode(146, fullStart); + var questionToken = parseOptionalToken(54); + if (token() === 18 || token() === 26) { + var method = createNode(147, fullStart); method.modifiers = modifiers; method.name = name; method.questionToken = questionToken; - fillSignature(54, false, false, false, method); + fillSignature(55, false, false, false, method); parseTypeMemberSemicolon(); return addJSDocComment(finishNode(method)); } else { - var property = createNode(144, fullStart); + var property = createNode(145, fullStart); property.modifiers = modifiers; property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); - if (token() === 56) { + if (token() === 57) { property.initializer = parseNonParameterInitializer(); } parseTypeMemberSemicolon(); @@ -14026,14 +13513,14 @@ var ts; } function isTypeMemberStart() { var idToken; - if (token() === 17 || token() === 25) { + if (token() === 18 || token() === 26) { return true; } while (ts.isModifierKind(token())) { idToken = token(); nextToken(); } - if (token() === 19) { + if (token() === 20) { return true; } if (isLiteralPropertyName()) { @@ -14041,22 +13528,22 @@ var ts; nextToken(); } if (idToken) { - return token() === 17 || - token() === 25 || - token() === 53 || + return token() === 18 || + token() === 26 || token() === 54 || - token() === 24 || + token() === 55 || + token() === 25 || canParseSemicolon(); } return false; } function parseTypeMember() { - if (token() === 17 || token() === 25) { - return parseSignatureMember(151); - } - if (token() === 92 && lookAhead(isStartOfConstructSignature)) { + if (token() === 18 || token() === 26) { return parseSignatureMember(152); } + if (token() === 93 && lookAhead(isStartOfConstructSignature)) { + return parseSignatureMember(153); + } var fullStart = getNodePos(); var modifiers = parseModifiers(); if (isIndexSignature()) { @@ -14066,18 +13553,18 @@ var ts; } function isStartOfConstructSignature() { nextToken(); - return token() === 17 || token() === 25; + return token() === 18 || token() === 26; } function parseTypeLiteral() { - var node = createNode(159); + var node = createNode(160); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseObjectTypeMembers() { var members; - if (parseExpected(15)) { + if (parseExpected(16)) { members = parseList(4, parseTypeMember); - parseExpected(16); + parseExpected(17); } else { members = createMissingList(); @@ -14085,31 +13572,31 @@ var ts; return members; } function parseTupleType() { - var node = createNode(161); - node.elementTypes = parseBracketedList(19, parseType, 19, 20); + var node = createNode(162); + node.elementTypes = parseBracketedList(19, parseType, 20, 21); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(164); - parseExpected(17); - node.type = parseType(); + var node = createNode(165); parseExpected(18); + node.type = parseType(); + parseExpected(19); return finishNode(node); } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 157) { - parseExpected(92); + if (kind === 158) { + parseExpected(93); } - fillSignature(34, false, false, false, node); + fillSignature(35, false, false, false, node); return finishNode(node); } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token() === 21 ? undefined : node; + return token() === 22 ? undefined : node; } function parseLiteralTypeNode() { - var node = createNode(166); + var node = createNode(167); node.literal = parseSimpleUnaryExpression(); finishNode(node); return node; @@ -14119,41 +13606,41 @@ var ts; } function parseNonArrayType() { switch (token()) { - case 117: - case 132: - case 130: - case 120: + case 118: case 133: - case 135: - case 127: + case 131: + case 121: + case 134: + case 136: + case 128: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); case 9: case 8: - case 99: - case 84: + case 100: + case 85: return parseLiteralTypeNode(); - case 36: + case 37: return lookAhead(nextTokenIsNumericLiteral) ? parseLiteralTypeNode() : parseTypeReference(); - case 103: - case 93: + case 104: + case 94: return parseTokenNode(); - case 97: { + case 98: { var thisKeyword = parseThisTypeNode(); - if (token() === 124 && !scanner.hasPrecedingLineBreak()) { + if (token() === 125 && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 101: + case 102: return parseTypeQuery(); - case 15: + case 16: return parseTypeLiteral(); - case 19: + case 20: return parseTupleType(); - case 17: + case 18: return parseParenthesizedType(); default: return parseTypeReference(); @@ -14161,29 +13648,29 @@ var ts; } function isStartOfType() { switch (token()) { - case 117: - case 132: - case 130: - case 120: + case 118: case 133: - case 103: - case 135: + case 131: + case 121: + case 134: + case 104: + case 136: + case 94: + case 98: + case 102: + case 128: + case 16: + case 20: + case 26: case 93: - case 97: - case 101: - case 127: - case 15: - case 19: - case 25: - case 92: case 9: case 8: - case 99: - case 84: + case 100: + case 85: return true; - case 36: + case 37: return lookAhead(nextTokenIsNumericLiteral); - case 17: + case 18: return lookAhead(isStartOfParenthesizedOrFunctionType); default: return isIdentifier(); @@ -14191,13 +13678,13 @@ var ts; } function isStartOfParenthesizedOrFunctionType() { nextToken(); - return token() === 18 || isStartOfParameter() || isStartOfType(); + return token() === 19 || isStartOfParameter() || isStartOfType(); } function parseArrayTypeOrHigher() { var type = parseNonArrayType(); - while (!scanner.hasPrecedingLineBreak() && parseOptional(19)) { - parseExpected(20); - var node = createNode(160, type.pos); + while (!scanner.hasPrecedingLineBreak() && parseOptional(20)) { + parseExpected(21); + var node = createNode(161, type.pos); node.elementType = type; type = finishNode(node); } @@ -14218,26 +13705,26 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(163, parseArrayTypeOrHigher, 46); + return parseUnionOrIntersectionType(164, parseArrayTypeOrHigher, 47); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(162, parseIntersectionTypeOrHigher, 47); + return parseUnionOrIntersectionType(163, parseIntersectionTypeOrHigher, 48); } function isStartOfFunctionType() { - if (token() === 25) { + if (token() === 26) { return true; } - return token() === 17 && lookAhead(isUnambiguouslyStartOfFunctionType); + return token() === 18 && lookAhead(isUnambiguouslyStartOfFunctionType); } function skipParameterStart() { if (ts.isModifierKind(token())) { parseModifiers(); } - if (isIdentifier() || token() === 97) { + if (isIdentifier() || token() === 98) { nextToken(); return true; } - if (token() === 19 || token() === 15) { + if (token() === 20 || token() === 16) { var previousErrorCount = parseDiagnostics.length; parseIdentifierOrPattern(); return previousErrorCount === parseDiagnostics.length; @@ -14246,17 +13733,17 @@ var ts; } function isUnambiguouslyStartOfFunctionType() { nextToken(); - if (token() === 18 || token() === 22) { + if (token() === 19 || token() === 23) { return true; } if (skipParameterStart()) { - if (token() === 54 || token() === 24 || - token() === 53 || token() === 56) { + if (token() === 55 || token() === 25 || + token() === 54 || token() === 57) { return true; } - if (token() === 18) { + if (token() === 19) { nextToken(); - if (token() === 34) { + if (token() === 35) { return true; } } @@ -14267,7 +13754,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(154, typePredicateVariable.pos); + var node = createNode(155, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -14278,7 +13765,7 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 124 && !scanner.hasPrecedingLineBreak()) { + if (token() === 125 && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } @@ -14288,36 +13775,36 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(156); - } - if (token() === 92) { return parseFunctionOrConstructorType(157); } + if (token() === 93) { + return parseFunctionOrConstructorType(158); + } return parseUnionTypeOrHigher(); } function parseTypeAnnotation() { - return parseOptional(54) ? parseType() : undefined; + return parseOptional(55) ? parseType() : undefined; } function isStartOfLeftHandSideExpression() { switch (token()) { - case 97: - case 95: - case 93: - case 99: - case 84: + case 98: + case 96: + case 94: + case 100: + case 85: case 8: case 9: - case 11: case 12: - case 17: - case 19: - case 15: - case 87: - case 73: - case 92: - case 39: - case 61: - case 69: + case 13: + case 18: + case 20: + case 16: + case 88: + case 74: + case 93: + case 40: + case 62: + case 70: return true; default: return isIdentifier(); @@ -14328,18 +13815,18 @@ var ts; return true; } switch (token()) { - case 35: case 36: + case 37: + case 51: case 50: - case 49: - case 78: - case 101: - case 103: - case 41: + case 79: + case 102: + case 104: case 42: - case 25: - case 119: - case 114: + case 43: + case 26: + case 120: + case 115: return true; default: if (isBinaryOperator()) { @@ -14349,10 +13836,10 @@ var ts; } } function isStartOfExpressionStatement() { - return token() !== 15 && - token() !== 87 && - token() !== 73 && - token() !== 55 && + return token() !== 16 && + token() !== 88 && + token() !== 74 && + token() !== 56 && isStartOfExpression(); } function parseExpression() { @@ -14362,7 +13849,7 @@ var ts; } var expr = parseAssignmentExpressionOrHigher(); var operatorToken; - while ((operatorToken = parseOptionalToken(24))) { + while ((operatorToken = parseOptionalToken(25))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); } if (saveDecoratorContext) { @@ -14371,12 +13858,12 @@ var ts; return expr; } function parseInitializer(inParameter) { - if (token() !== 56) { - if (scanner.hasPrecedingLineBreak() || (inParameter && token() === 15) || !isStartOfExpression()) { + if (token() !== 57) { + if (scanner.hasPrecedingLineBreak() || (inParameter && token() === 16) || !isStartOfExpression()) { return undefined; } } - parseExpected(56); + parseExpected(57); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { @@ -14388,7 +13875,7 @@ var ts; return arrowExpression; } var expr = parseBinaryExpressionOrHigher(0); - if (expr.kind === 69 && token() === 34) { + if (expr.kind === 70 && token() === 35) { return parseSimpleArrowFunctionExpression(expr); } if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) { @@ -14397,7 +13884,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token() === 114) { + if (token() === 115) { if (inYieldContext()) { return true; } @@ -14410,11 +13897,11 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(190); + var node = createNode(191); nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token() === 37 || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(37); + (token() === 38 || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(38); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -14423,21 +13910,21 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier, asyncModifier) { - ts.Debug.assert(token() === 34, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + ts.Debug.assert(token() === 35, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(180, asyncModifier.pos); + node = createNode(181, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(180, identifier.pos); + node = createNode(181, identifier.pos); } - var parameter = createNode(142, identifier.pos); + var parameter = createNode(143, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos); node.parameters.end = parameter.end; - node.equalsGreaterThanToken = parseExpectedToken(34, false, ts.Diagnostics._0_expected, "=>"); + node.equalsGreaterThanToken = parseExpectedToken(35, false, ts.Diagnostics._0_expected, "=>"); node.body = parseArrowFunctionExpressionBody(!!asyncModifier); return addJSDocComment(finishNode(node)); } @@ -14454,78 +13941,78 @@ var ts; } var isAsync = !!(ts.getModifierFlags(arrowFunction) & 256); var lastToken = token(); - arrowFunction.equalsGreaterThanToken = parseExpectedToken(34, false, ts.Diagnostics._0_expected, "=>"); - arrowFunction.body = (lastToken === 34 || lastToken === 15) + arrowFunction.equalsGreaterThanToken = parseExpectedToken(35, false, ts.Diagnostics._0_expected, "=>"); + arrowFunction.body = (lastToken === 35 || lastToken === 16) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return addJSDocComment(finishNode(arrowFunction)); } function isParenthesizedArrowFunctionExpression() { - if (token() === 17 || token() === 25 || token() === 118) { + if (token() === 18 || token() === 26 || token() === 119) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token() === 34) { + if (token() === 35) { return 1; } return 0; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 118) { + if (token() === 119) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0; } - if (token() !== 17 && token() !== 25) { + if (token() !== 18 && token() !== 26) { return 0; } } var first = token(); var second = nextToken(); - if (first === 17) { - if (second === 18) { + if (first === 18) { + if (second === 19) { var third = nextToken(); switch (third) { - case 34: - case 54: - case 15: + case 35: + case 55: + case 16: return 1; default: return 0; } } - if (second === 19 || second === 15) { + if (second === 20 || second === 16) { return 2; } - if (second === 22) { + if (second === 23) { return 1; } if (!isIdentifier()) { return 0; } - if (nextToken() === 54) { + if (nextToken() === 55) { return 1; } return 2; } else { - ts.Debug.assert(first === 25); + ts.Debug.assert(first === 26); if (!isIdentifier()) { return 0; } if (sourceFile.languageVariant === 1) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 83) { + if (third === 84) { var fourth = nextToken(); switch (fourth) { - case 56: - case 27: + case 57: + case 28: return false; default: return true; } } - else if (third === 24) { + else if (third === 25) { return true; } return false; @@ -14542,7 +14029,7 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function tryParseAsyncSimpleArrowFunctionExpression() { - if (token() === 118) { + if (token() === 119) { var isUnParenthesizedAsyncArrowFunction = lookAhead(isUnParenthesizedAsyncArrowFunctionWorker); if (isUnParenthesizedAsyncArrowFunction === 1) { var asyncModifier = parseModifiersForArrowFunction(); @@ -14553,38 +14040,38 @@ var ts; return undefined; } function isUnParenthesizedAsyncArrowFunctionWorker() { - if (token() === 118) { + if (token() === 119) { nextToken(); - if (scanner.hasPrecedingLineBreak() || token() === 34) { + if (scanner.hasPrecedingLineBreak() || token() === 35) { return 0; } var expr = parseBinaryExpressionOrHigher(0); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 69 && token() === 34) { + if (!scanner.hasPrecedingLineBreak() && expr.kind === 70 && token() === 35) { return 1; } } return 0; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(180); + var node = createNode(181); node.modifiers = parseModifiersForArrowFunction(); var isAsync = !!(ts.getModifierFlags(node) & 256); - fillSignature(54, false, isAsync, !allowAmbiguity, node); + fillSignature(55, false, isAsync, !allowAmbiguity, node); if (!node.parameters) { return undefined; } - if (!allowAmbiguity && token() !== 34 && token() !== 15) { + if (!allowAmbiguity && token() !== 35 && token() !== 16) { return undefined; } return node; } function parseArrowFunctionExpressionBody(isAsync) { - if (token() === 15) { + if (token() === 16) { return parseFunctionBlock(false, isAsync, false); } - if (token() !== 23 && - token() !== 87 && - token() !== 73 && + if (token() !== 24 && + token() !== 88 && + token() !== 74 && isStartOfStatement() && !isStartOfExpressionStatement()) { return parseFunctionBlock(false, isAsync, true); @@ -14594,15 +14081,15 @@ var ts; : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); } function parseConditionalExpressionRest(leftOperand) { - var questionToken = parseOptionalToken(53); + var questionToken = parseOptionalToken(54); if (!questionToken) { return leftOperand; } - var node = createNode(188, leftOperand.pos); + var node = createNode(189, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(54, false, ts.Diagnostics._0_expected, ts.tokenToString(54)); + node.colonToken = parseExpectedToken(55, false, ts.Diagnostics._0_expected, ts.tokenToString(55)); node.whenFalse = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -14611,22 +14098,22 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 90 || t === 138; + return t === 91 || t === 139; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { reScanGreaterToken(); var newPrecedence = getBinaryOperatorPrecedence(); - var consumeCurrentOperator = token() === 38 ? + var consumeCurrentOperator = token() === 39 ? newPrecedence >= precedence : newPrecedence > precedence; if (!consumeCurrentOperator) { break; } - if (token() === 90 && inDisallowInContext()) { + if (token() === 91 && inDisallowInContext()) { break; } - if (token() === 116) { + if (token() === 117) { if (scanner.hasPrecedingLineBreak()) { break; } @@ -14642,92 +14129,92 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 90) { + if (inDisallowInContext() && token() === 91) { return false; } return getBinaryOperatorPrecedence() > 0; } function getBinaryOperatorPrecedence() { switch (token()) { - case 52: + case 53: return 1; - case 51: + case 52: return 2; - case 47: - return 3; case 48: + return 3; + case 49: return 4; - case 46: + case 47: return 5; - case 30: case 31: case 32: case 33: + case 34: return 6; - case 25: - case 27: + case 26: case 28: case 29: + case 30: + case 92: case 91: - case 90: - case 116: + case 117: return 7; - case 43: case 44: case 45: + case 46: return 8; - case 35: case 36: - return 9; case 37: - case 39: - case 40: - return 10; + return 9; case 38: + case 40: + case 41: + return 10; + case 39: return 11; } return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(187, left.pos); + var node = createNode(188, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(195, left.pos); + var node = createNode(196, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(185); + var node = createNode(186); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(181); - nextToken(); - node.expression = parseSimpleUnaryExpression(); - return finishNode(node); - } - function parseTypeOfExpression() { var node = createNode(182); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } - function parseVoidExpression() { + function parseTypeOfExpression() { var node = createNode(183); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } + function parseVoidExpression() { + var node = createNode(184); + nextToken(); + node.expression = parseSimpleUnaryExpression(); + return finishNode(node); + } function isAwaitExpression() { - if (token() === 119) { + if (token() === 120) { if (inAwaitContext()) { return true; } @@ -14736,7 +14223,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(184); + var node = createNode(185); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -14744,15 +14231,15 @@ var ts; function parseUnaryExpressionOrHigher() { if (isUpdateExpression()) { var incrementExpression = parseIncrementExpression(); - return token() === 38 ? + return token() === 39 ? parseBinaryExpressionRest(getBinaryOperatorPrecedence(), incrementExpression) : incrementExpression; } var unaryOperator = token(); var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token() === 38) { + if (token() === 39) { var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); - if (simpleUnaryExpression.kind === 177) { + if (simpleUnaryExpression.kind === 178) { 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 { @@ -14763,20 +14250,20 @@ var ts; } function parseSimpleUnaryExpression() { switch (token()) { - case 35: case 36: + case 37: + case 51: case 50: - case 49: return parsePrefixUnaryExpression(); - case 78: + case 79: return parseDeleteExpression(); - case 101: + case 102: return parseTypeOfExpression(); - case 103: + case 104: return parseVoidExpression(); - case 25: + case 26: return parseTypeAssertion(); - case 119: + case 120: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -14786,16 +14273,16 @@ var ts; } function isUpdateExpression() { switch (token()) { - case 35: case 36: + case 37: + case 51: case 50: - case 49: - case 78: - case 101: - case 103: - case 119: + case 79: + case 102: + case 104: + case 120: return false; - case 25: + case 26: if (sourceFile.languageVariant !== 1) { return false; } @@ -14804,20 +14291,20 @@ var ts; } } function parseIncrementExpression() { - if (token() === 41 || token() === 42) { - var node = createNode(185); + if (token() === 42 || token() === 43) { + var node = createNode(186); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); return finishNode(node); } - else if (sourceFile.languageVariant === 1 && token() === 25 && lookAhead(nextTokenIsIdentifierOrKeyword)) { + else if (sourceFile.languageVariant === 1 && token() === 26 && lookAhead(nextTokenIsIdentifierOrKeyword)) { return parseJsxElementOrSelfClosingElement(true); } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token() === 41 || token() === 42) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(186, expression.pos); + if ((token() === 42 || token() === 43) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(187, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -14826,7 +14313,7 @@ var ts; return expression; } function parseLeftHandSideExpressionOrHigher() { - var expression = token() === 95 + var expression = token() === 96 ? parseSuperExpression() : parseMemberExpressionOrHigher(); return parseCallExpressionRest(expression); @@ -14837,12 +14324,12 @@ var ts; } function parseSuperExpression() { var expression = parseTokenNode(); - if (token() === 17 || token() === 21 || token() === 19) { + if (token() === 18 || token() === 22 || token() === 20) { return expression; } - var node = createNode(172, expression.pos); + var node = createNode(173, expression.pos); node.expression = expression; - parseExpectedToken(21, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + parseExpectedToken(22, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); return finishNode(node); } @@ -14850,10 +14337,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 69) { + if (lhs.kind === 70) { return lhs.text === rhs.text; } - if (lhs.kind === 97) { + if (lhs.kind === 98) { return true; } return lhs.name.text === rhs.name.text && @@ -14862,8 +14349,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 243) { - var node = createNode(241, opening.pos); + if (opening.kind === 244) { + var node = createNode(242, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -14873,18 +14360,18 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 242); + ts.Debug.assert(opening.kind === 243); result = opening; } - if (inExpressionContext && token() === 25) { + if (inExpressionContext && token() === 26) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(187, result.pos); + var badNode = createNode(188, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; - badNode.operatorToken = createMissingNode(24, false, undefined); + badNode.operatorToken = createMissingNode(25, false, undefined); badNode.operatorToken.pos = badNode.operatorToken.end = badNode.right.pos; return badNode; } @@ -14892,17 +14379,17 @@ var ts; return result; } function parseJsxText() { - var node = createNode(244, scanner.getStartPos()); + var node = createNode(10, scanner.getStartPos()); currentToken = scanner.scanJsxToken(); return finishNode(node); } function parseJsxChild() { switch (token()) { - case 244: + case 10: return parseJsxText(); - case 15: + case 16: return parseJsxExpression(false); - case 25: + case 26: return parseJsxElementOrSelfClosingElement(false); } ts.Debug.fail("Unknown JSX child kind " + token()); @@ -14913,7 +14400,7 @@ var ts; parsingContext |= 1 << 14; while (true) { currentToken = scanner.reScanJsxToken(); - if (token() === 26) { + if (token() === 27) { break; } else if (token() === 1) { @@ -14928,24 +14415,24 @@ var ts; } function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { var fullStart = scanner.getStartPos(); - parseExpected(25); + parseExpected(26); var tagName = parseJsxElementName(); var attributes = parseList(13, parseJsxAttribute); var node; - if (token() === 27) { - node = createNode(243, fullStart); + if (token() === 28) { + node = createNode(244, fullStart); scanJsxText(); } else { - parseExpected(39); + parseExpected(40); if (inExpressionContext) { - parseExpected(27); + parseExpected(28); } else { - parseExpected(27, undefined, false); + parseExpected(28, undefined, false); scanJsxText(); } - node = createNode(242, fullStart); + node = createNode(243, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -14953,10 +14440,10 @@ var ts; } function parseJsxElementName() { scanJsxIdentifier(); - var expression = token() === 97 ? + var expression = token() === 98 ? parseTokenNode() : parseIdentifierName(); - while (parseOptional(21)) { - var propertyAccess = createNode(172, expression.pos); + while (parseOptional(22)) { + var propertyAccess = createNode(173, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -14965,27 +14452,27 @@ var ts; } function parseJsxExpression(inExpressionContext) { var node = createNode(248); - parseExpected(15); - if (token() !== 16) { + parseExpected(16); + if (token() !== 17) { node.expression = parseAssignmentExpressionOrHigher(); } if (inExpressionContext) { - parseExpected(16); + parseExpected(17); } else { - parseExpected(16, undefined, false); + parseExpected(17, undefined, false); scanJsxText(); } return finishNode(node); } function parseJsxAttribute() { - if (token() === 15) { + if (token() === 16) { return parseJsxSpreadAttribute(); } scanJsxIdentifier(); var node = createNode(246); node.name = parseIdentifierName(); - if (token() === 56) { + if (token() === 57) { switch (scanJsxAttributeValue()) { case 9: node.initializer = parseLiteralNode(); @@ -14999,68 +14486,68 @@ var ts; } function parseJsxSpreadAttribute() { var node = createNode(247); - parseExpected(15); - parseExpected(22); - node.expression = parseExpression(); parseExpected(16); + parseExpected(23); + node.expression = parseExpression(); + parseExpected(17); return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { var node = createNode(245); - parseExpected(26); + parseExpected(27); node.tagName = parseJsxElementName(); if (inExpressionContext) { - parseExpected(27); + parseExpected(28); } else { - parseExpected(27, undefined, false); + parseExpected(28, undefined, false); scanJsxText(); } return finishNode(node); } function parseTypeAssertion() { - var node = createNode(177); - parseExpected(25); + var node = createNode(178); + parseExpected(26); node.type = parseType(); - parseExpected(27); + parseExpected(28); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseMemberExpressionRest(expression) { while (true) { - var dotToken = parseOptionalToken(21); + var dotToken = parseOptionalToken(22); if (dotToken) { - var propertyAccess = createNode(172, expression.pos); + var propertyAccess = createNode(173, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); continue; } - if (token() === 49 && !scanner.hasPrecedingLineBreak()) { + if (token() === 50 && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(196, expression.pos); + var nonNullExpression = createNode(197, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } - if (!inDecoratorContext() && parseOptional(19)) { - var indexedAccess = createNode(173, expression.pos); + if (!inDecoratorContext() && parseOptional(20)) { + var indexedAccess = createNode(174, expression.pos); indexedAccess.expression = expression; - if (token() !== 20) { + if (token() !== 21) { indexedAccess.argumentExpression = allowInAnd(parseExpression); if (indexedAccess.argumentExpression.kind === 9 || indexedAccess.argumentExpression.kind === 8) { var literal = indexedAccess.argumentExpression; literal.text = internIdentifier(literal.text); } } - parseExpected(20); + parseExpected(21); expression = finishNode(indexedAccess); continue; } - if (token() === 11 || token() === 12) { - var tagExpression = createNode(176, expression.pos); + if (token() === 12 || token() === 13) { + var tagExpression = createNode(177, expression.pos); tagExpression.tag = expression; - tagExpression.template = token() === 11 + tagExpression.template = token() === 12 ? parseLiteralNode() : parseTemplateExpression(); expression = finishNode(tagExpression); @@ -15072,20 +14559,20 @@ var ts; function parseCallExpressionRest(expression) { while (true) { expression = parseMemberExpressionRest(expression); - if (token() === 25) { + if (token() === 26) { var typeArguments = tryParse(parseTypeArgumentsInExpression); if (!typeArguments) { return expression; } - var callExpr = createNode(174, expression.pos); + var callExpr = createNode(175, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); continue; } - else if (token() === 17) { - var callExpr = createNode(174, expression.pos); + else if (token() === 18) { + var callExpr = createNode(175, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -15095,17 +14582,17 @@ var ts; } } function parseArgumentList() { - parseExpected(17); - var result = parseDelimitedList(11, parseArgumentExpression); parseExpected(18); + var result = parseDelimitedList(11, parseArgumentExpression); + parseExpected(19); return result; } function parseTypeArgumentsInExpression() { - if (!parseOptional(25)) { + if (!parseOptional(26)) { return undefined; } var typeArguments = parseDelimitedList(18, parseType); - if (!parseExpected(27)) { + if (!parseExpected(28)) { return undefined; } return typeArguments && canFollowTypeArgumentsInExpression() @@ -15114,27 +14601,27 @@ var ts; } function canFollowTypeArgumentsInExpression() { switch (token()) { - case 17: - case 21: case 18: - case 20: + case 22: + case 19: + case 21: + case 55: + case 24: case 54: - case 23: - case 53: - case 30: - case 32: case 31: case 33: - case 51: + case 32: + case 34: case 52: - case 48: - case 46: + case 53: + case 49: case 47: - case 16: + case 48: + case 17: case 1: return true; - case 24: - case 15: + case 25: + case 16: default: return false; } @@ -15143,80 +14630,80 @@ var ts; switch (token()) { case 8: case 9: - case 11: + case 12: return parseLiteralNode(); - case 97: - case 95: - case 93: - case 99: - case 84: + case 98: + case 96: + case 94: + case 100: + case 85: return parseTokenNode(); - case 17: + case 18: return parseParenthesizedExpression(); - case 19: + case 20: return parseArrayLiteralExpression(); - case 15: + case 16: return parseObjectLiteralExpression(); - case 118: + case 119: if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) { break; } return parseFunctionExpression(); - case 73: + case 74: return parseClassExpression(); - case 87: + case 88: return parseFunctionExpression(); - case 92: + case 93: return parseNewExpression(); - case 39: - case 61: - if (reScanSlashToken() === 10) { + case 40: + case 62: + if (reScanSlashToken() === 11) { return parseLiteralNode(); } break; - case 12: + case 13: return parseTemplateExpression(); } return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(178); - parseExpected(17); - node.expression = allowInAnd(parseExpression); + var node = createNode(179); parseExpected(18); + node.expression = allowInAnd(parseExpression); + parseExpected(19); return finishNode(node); } function parseSpreadElement() { - var node = createNode(191); - parseExpected(22); + var node = createNode(192); + parseExpected(23); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { - return token() === 22 ? parseSpreadElement() : - token() === 24 ? createNode(193) : + return token() === 23 ? parseSpreadElement() : + token() === 25 ? createNode(194) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(170); - parseExpected(19); + var node = createNode(171); + parseExpected(20); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.elements = parseDelimitedList(15, parseArgumentOrArrayLiteralElement); - parseExpected(20); + parseExpected(21); return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { - if (parseContextualModifier(123)) { - return parseAccessorDeclaration(149, fullStart, decorators, modifiers); - } - else if (parseContextualModifier(131)) { + if (parseContextualModifier(124)) { return parseAccessorDeclaration(150, fullStart, decorators, modifiers); } + else if (parseContextualModifier(132)) { + return parseAccessorDeclaration(151, fullStart, decorators, modifiers); + } return undefined; } function parseObjectLiteralElement() { @@ -15227,19 +14714,19 @@ var ts; if (accessor) { return accessor; } - var asteriskToken = parseOptionalToken(37); + var asteriskToken = parseOptionalToken(38); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - var questionToken = parseOptionalToken(53); - if (asteriskToken || token() === 17 || token() === 25) { + var questionToken = parseOptionalToken(54); + if (asteriskToken || token() === 18 || token() === 26) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } - var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 24 || token() === 16 || token() === 56); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 25 || token() === 17 || token() === 57); if (isShorthandPropertyAssignment) { var shorthandDeclaration = createNode(254, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; - var equalsToken = parseOptionalToken(56); + var equalsToken = parseOptionalToken(57); if (equalsToken) { shorthandDeclaration.equalsToken = equalsToken; shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); @@ -15251,19 +14738,19 @@ var ts; propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; - parseExpected(54); + parseExpected(55); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); return addJSDocComment(finishNode(propertyAssignment)); } } function parseObjectLiteralExpression() { - var node = createNode(171); - parseExpected(15); + var node = createNode(172); + parseExpected(16); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.properties = parseDelimitedList(12, parseObjectLiteralElement, true); - parseExpected(16); + parseExpected(17); return finishNode(node); } function parseFunctionExpression() { @@ -15271,10 +14758,10 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(179); + var node = createNode(180); node.modifiers = parseModifiers(); - parseExpected(87); - node.asteriskToken = parseOptionalToken(37); + parseExpected(88); + node.asteriskToken = parseOptionalToken(38); var isGenerator = !!node.asteriskToken; var isAsync = !!(ts.getModifierFlags(node) & 256); node.name = @@ -15282,7 +14769,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(54, isGenerator, isAsync, false, node); + fillSignature(55, isGenerator, isAsync, false, node); node.body = parseFunctionBlock(isGenerator, isAsync, false); if (saveDecoratorContext) { setDecoratorContext(true); @@ -15293,23 +14780,23 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(175); - parseExpected(92); + var node = createNode(176); + parseExpected(93); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); - if (node.typeArguments || token() === 17) { + if (node.typeArguments || token() === 18) { node.arguments = parseArgumentList(); } return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(199); - if (parseExpected(15, diagnosticMessage) || ignoreMissingOpenBrace) { + var node = createNode(200); + if (parseExpected(16, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.statements = parseList(1, parseStatement); - parseExpected(16); + parseExpected(17); } else { node.statements = createMissingList(); @@ -15334,47 +14821,47 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(201); - parseExpected(23); + var node = createNode(202); + parseExpected(24); return finishNode(node); } function parseIfStatement() { - var node = createNode(203); - parseExpected(88); - parseExpected(17); - node.expression = allowInAnd(parseExpression); + var node = createNode(204); + parseExpected(89); parseExpected(18); + node.expression = allowInAnd(parseExpression); + parseExpected(19); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(80) ? parseStatement() : undefined; + node.elseStatement = parseOptional(81) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(204); - parseExpected(79); + var node = createNode(205); + parseExpected(80); node.statement = parseStatement(); - parseExpected(104); - parseExpected(17); - node.expression = allowInAnd(parseExpression); + parseExpected(105); parseExpected(18); - parseOptional(23); + node.expression = allowInAnd(parseExpression); + parseExpected(19); + parseOptional(24); return finishNode(node); } function parseWhileStatement() { - var node = createNode(205); - parseExpected(104); - parseExpected(17); - node.expression = allowInAnd(parseExpression); + var node = createNode(206); + parseExpected(105); parseExpected(18); + node.expression = allowInAnd(parseExpression); + parseExpected(19); node.statement = parseStatement(); return finishNode(node); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(86); - parseExpected(17); + parseExpected(87); + parseExpected(18); var initializer = undefined; - if (token() !== 23) { - if (token() === 102 || token() === 108 || token() === 74) { + if (token() !== 24) { + if (token() === 103 || token() === 109 || token() === 75) { initializer = parseVariableDeclarationList(true); } else { @@ -15382,32 +14869,32 @@ var ts; } } var forOrForInOrForOfStatement; - if (parseOptional(90)) { - var forInStatement = createNode(207, pos); + if (parseOptional(91)) { + var forInStatement = createNode(208, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); - parseExpected(18); + parseExpected(19); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(138)) { - var forOfStatement = createNode(208, pos); + else if (parseOptional(139)) { + var forOfStatement = createNode(209, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); - parseExpected(18); + parseExpected(19); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(206, pos); + var forStatement = createNode(207, pos); forStatement.initializer = initializer; - parseExpected(23); - if (token() !== 23 && token() !== 18) { + parseExpected(24); + if (token() !== 24 && token() !== 19) { forStatement.condition = allowInAnd(parseExpression); } - parseExpected(23); - if (token() !== 18) { + parseExpected(24); + if (token() !== 19) { forStatement.incrementor = allowInAnd(parseExpression); } - parseExpected(18); + parseExpected(19); forOrForInOrForOfStatement = forStatement; } forOrForInOrForOfStatement.statement = parseStatement(); @@ -15415,7 +14902,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 210 ? 70 : 75); + parseExpected(kind === 211 ? 71 : 76); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -15423,8 +14910,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(211); - parseExpected(94); + var node = createNode(212); + parseExpected(95); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -15432,90 +14919,90 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(212); - parseExpected(105); - parseExpected(17); - node.expression = allowInAnd(parseExpression); + var node = createNode(213); + parseExpected(106); parseExpected(18); + node.expression = allowInAnd(parseExpression); + parseExpected(19); node.statement = parseStatement(); return finishNode(node); } function parseCaseClause() { var node = createNode(249); - parseExpected(71); + parseExpected(72); node.expression = allowInAnd(parseExpression); - parseExpected(54); + parseExpected(55); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseDefaultClause() { var node = createNode(250); - parseExpected(77); - parseExpected(54); + parseExpected(78); + parseExpected(55); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token() === 71 ? parseCaseClause() : parseDefaultClause(); + return token() === 72 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(213); - parseExpected(96); - parseExpected(17); - node.expression = allowInAnd(parseExpression); + var node = createNode(214); + parseExpected(97); parseExpected(18); - var caseBlock = createNode(227, scanner.getStartPos()); - parseExpected(15); - caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); + node.expression = allowInAnd(parseExpression); + parseExpected(19); + var caseBlock = createNode(228, scanner.getStartPos()); parseExpected(16); + caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); + parseExpected(17); node.caseBlock = finishNode(caseBlock); return finishNode(node); } function parseThrowStatement() { - var node = createNode(215); - parseExpected(98); + var node = createNode(216); + parseExpected(99); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(216); - parseExpected(100); + var node = createNode(217); + parseExpected(101); node.tryBlock = parseBlock(false); - node.catchClause = token() === 72 ? parseCatchClause() : undefined; - if (!node.catchClause || token() === 85) { - parseExpected(85); + node.catchClause = token() === 73 ? parseCatchClause() : undefined; + if (!node.catchClause || token() === 86) { + parseExpected(86); node.finallyBlock = parseBlock(false); } return finishNode(node); } function parseCatchClause() { var result = createNode(252); - parseExpected(72); - if (parseExpected(17)) { + parseExpected(73); + if (parseExpected(18)) { result.variableDeclaration = parseVariableDeclaration(); } - parseExpected(18); + parseExpected(19); result.block = parseBlock(false); return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(217); - parseExpected(76); + var node = createNode(218); + parseExpected(77); parseSemicolon(); return finishNode(node); } function parseExpressionOrLabeledStatement() { var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); - if (expression.kind === 69 && parseOptional(54)) { - var labeledStatement = createNode(214, fullStart); + if (expression.kind === 70 && parseOptional(55)) { + var labeledStatement = createNode(215, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(202, fullStart); + var expressionStatement = createNode(203, fullStart); expressionStatement.expression = expression; parseSemicolon(); return addJSDocComment(finishNode(expressionStatement)); @@ -15527,7 +15014,7 @@ var ts; } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 87 && !scanner.hasPrecedingLineBreak(); + return token() === 88 && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { nextToken(); @@ -15536,47 +15023,47 @@ var ts; function isDeclaration() { while (true) { switch (token()) { - case 102: - case 108: + case 103: + case 109: + case 75: + case 88: case 74: - case 87: - case 73: - case 81: + case 82: return true; - case 107: - case 134: + case 108: + case 135: return nextTokenIsIdentifierOnSameLine(); - case 125: case 126: + case 127: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 115: - case 118: - case 122: - case 110: + case 116: + case 119: + case 123: case 111: case 112: - case 128: + case 113: + case 129: nextToken(); if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 137: + case 138: nextToken(); - return token() === 15 || token() === 69 || token() === 82; - case 89: + return token() === 16 || token() === 70 || token() === 83; + case 90: nextToken(); - return token() === 9 || token() === 37 || - token() === 15 || ts.tokenIsIdentifierOrKeyword(token()); - case 82: + return token() === 9 || token() === 38 || + token() === 16 || ts.tokenIsIdentifierOrKeyword(token()); + case 83: nextToken(); - if (token() === 56 || token() === 37 || - token() === 15 || token() === 77 || - token() === 116) { + if (token() === 57 || token() === 38 || + token() === 16 || token() === 78 || + token() === 117) { return true; } continue; - case 113: + case 114: nextToken(); continue; default: @@ -15589,46 +15076,46 @@ var ts; } function isStartOfStatement() { switch (token()) { - case 55: - case 23: - case 15: - case 102: - case 108: - case 87: - case 73: - case 81: + case 56: + case 24: + case 16: + case 103: + case 109: case 88: - case 79: - case 104: - case 86: - case 75: - case 70: - case 94: - case 105: - case 96: - case 98: - case 100: - case 76: - case 72: - case 85: - return true; case 74: case 82: case 89: + case 80: + case 105: + case 87: + case 76: + case 71: + case 95: + case 106: + case 97: + case 99: + case 101: + case 77: + case 73: + case 86: + return true; + case 75: + case 83: + case 90: return isStartOfDeclaration(); - case 118: - case 122: - case 107: - case 125: + case 119: + case 123: + case 108: case 126: - case 134: - case 137: + case 127: + case 135: + case 138: return true; - case 112: - case 110: - case 111: case 113: - case 128: + case 111: + case 112: + case 114: + case 129: return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); default: return isStartOfExpression(); @@ -15636,73 +15123,73 @@ var ts; } function nextTokenIsIdentifierOrStartOfDestructuring() { nextToken(); - return isIdentifier() || token() === 15 || token() === 19; + return isIdentifier() || token() === 16 || token() === 20; } function isLetDeclaration() { return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring); } function parseStatement() { switch (token()) { - case 23: + case 24: return parseEmptyStatement(); - case 15: + case 16: return parseBlock(false); - case 102: + case 103: return parseVariableStatement(scanner.getStartPos(), undefined, undefined); - case 108: + case 109: if (isLetDeclaration()) { return parseVariableStatement(scanner.getStartPos(), undefined, undefined); } break; - case 87: - return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); - case 73: - return parseClassDeclaration(scanner.getStartPos(), undefined, undefined); case 88: - return parseIfStatement(); - case 79: - return parseDoStatement(); - case 104: - return parseWhileStatement(); - case 86: - return parseForOrForInOrForOfStatement(); - case 75: - return parseBreakOrContinueStatement(209); - case 70: - return parseBreakOrContinueStatement(210); - case 94: - return parseReturnStatement(); - case 105: - return parseWithStatement(); - case 96: - return parseSwitchStatement(); - case 98: - return parseThrowStatement(); - case 100: - case 72: - case 85: - return parseTryStatement(); - case 76: - return parseDebuggerStatement(); - case 55: - return parseDeclaration(); - case 118: - case 107: - case 134: - case 125: - case 126: - case 122: + return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); case 74: - case 81: - case 82: + return parseClassDeclaration(scanner.getStartPos(), undefined, undefined); case 89: - case 110: + return parseIfStatement(); + case 80: + return parseDoStatement(); + case 105: + return parseWhileStatement(); + case 87: + return parseForOrForInOrForOfStatement(); + case 76: + return parseBreakOrContinueStatement(210); + case 71: + return parseBreakOrContinueStatement(211); + case 95: + return parseReturnStatement(); + case 106: + return parseWithStatement(); + case 97: + return parseSwitchStatement(); + case 99: + return parseThrowStatement(); + case 101: + case 73: + case 86: + return parseTryStatement(); + case 77: + return parseDebuggerStatement(); + case 56: + return parseDeclaration(); + case 119: + case 108: + case 135: + case 126: + case 127: + case 123: + case 75: + case 82: + case 83: + case 90: case 111: case 112: - case 115: case 113: - case 128: - case 137: + case 116: + case 114: + case 129: + case 138: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -15715,40 +15202,40 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(); switch (token()) { - case 102: - case 108: - case 74: + case 103: + case 109: + case 75: return parseVariableStatement(fullStart, decorators, modifiers); - case 87: + case 88: return parseFunctionDeclaration(fullStart, decorators, modifiers); - case 73: + case 74: return parseClassDeclaration(fullStart, decorators, modifiers); - case 107: + case 108: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 134: + case 135: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); - case 81: - return parseEnumDeclaration(fullStart, decorators, modifiers); - case 137: - case 125: - case 126: - return parseModuleDeclaration(fullStart, decorators, modifiers); - case 89: - return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); case 82: + return parseEnumDeclaration(fullStart, decorators, modifiers); + case 138: + case 126: + case 127: + return parseModuleDeclaration(fullStart, decorators, modifiers); + case 90: + return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); + case 83: nextToken(); switch (token()) { - case 77: - case 56: + case 78: + case 57: return parseExportAssignment(fullStart, decorators, modifiers); - case 116: + case 117: return parseNamespaceExportDeclaration(fullStart, decorators, modifiers); default: return parseExportDeclaration(fullStart, decorators, modifiers); } default: if (decorators || modifiers) { - var node = createMissingNode(239, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(240, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; node.modifiers = modifiers; @@ -15761,31 +15248,31 @@ var ts; return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 9); } function parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage) { - if (token() !== 15 && canParseSemicolon()) { + if (token() !== 16 && canParseSemicolon()) { parseSemicolon(); return; } return parseFunctionBlock(isGenerator, isAsync, false, diagnosticMessage); } function parseArrayBindingElement() { - if (token() === 24) { - return createNode(193); + if (token() === 25) { + return createNode(194); } - var node = createNode(169); - node.dotDotDotToken = parseOptionalToken(22); + var node = createNode(170); + node.dotDotDotToken = parseOptionalToken(23); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(169); + var node = createNode(170); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token() !== 54) { + if (tokenIsIdentifier && token() !== 55) { node.name = propertyName; } else { - parseExpected(54); + parseExpected(55); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -15793,33 +15280,33 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(167); - parseExpected(15); - node.elements = parseDelimitedList(9, parseObjectBindingElement); + var node = createNode(168); parseExpected(16); + node.elements = parseDelimitedList(9, parseObjectBindingElement); + parseExpected(17); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(168); - parseExpected(19); - node.elements = parseDelimitedList(10, parseArrayBindingElement); + var node = createNode(169); parseExpected(20); + node.elements = parseDelimitedList(10, parseArrayBindingElement); + parseExpected(21); return finishNode(node); } function isIdentifierOrPattern() { - return token() === 15 || token() === 19 || isIdentifier(); + return token() === 16 || token() === 20 || isIdentifier(); } function parseIdentifierOrPattern() { - if (token() === 19) { + if (token() === 20) { return parseArrayBindingPattern(); } - if (token() === 15) { + if (token() === 16) { return parseObjectBindingPattern(); } return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(218); + var node = createNode(219); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { @@ -15828,21 +15315,21 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(219); + var node = createNode(220); switch (token()) { - case 102: + case 103: break; - case 108: + case 109: node.flags |= 1; break; - case 74: + case 75: node.flags |= 2; break; default: ts.Debug.fail(); } nextToken(); - if (token() === 138 && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 139 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -15854,10 +15341,10 @@ var ts; return finishNode(node); } function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 18; + return nextTokenIsIdentifier() && nextToken() === 19; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(200, fullStart); + var node = createNode(201, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.declarationList = parseVariableDeclarationList(false); @@ -15865,29 +15352,29 @@ var ts; return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(220, fullStart); + var node = createNode(221, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(87); - node.asteriskToken = parseOptionalToken(37); + parseExpected(88); + node.asteriskToken = parseOptionalToken(38); node.name = ts.hasModifier(node, 512) ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = !!node.asteriskToken; var isAsync = ts.hasModifier(node, 256); - fillSignature(54, isGenerator, isAsync, false, node); + fillSignature(55, isGenerator, isAsync, false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return addJSDocComment(finishNode(node)); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(148, pos); + var node = createNode(149, pos); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(121); - fillSignature(54, false, false, false, node); + parseExpected(122); + fillSignature(55, false, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, false, ts.Diagnostics.or_expected); return addJSDocComment(finishNode(node)); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(147, fullStart); + var method = createNode(148, fullStart); method.decorators = decorators; method.modifiers = modifiers; method.asteriskToken = asteriskToken; @@ -15895,12 +15382,12 @@ var ts; method.questionToken = questionToken; var isGenerator = !!asteriskToken; var isAsync = ts.hasModifier(method, 256); - fillSignature(54, isGenerator, isAsync, false, method); + fillSignature(55, isGenerator, isAsync, false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return addJSDocComment(finishNode(method)); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(145, fullStart); + var property = createNode(146, fullStart); property.decorators = decorators; property.modifiers = modifiers; property.name = name; @@ -15913,10 +15400,10 @@ var ts; return addJSDocComment(finishNode(property)); } function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { - var asteriskToken = parseOptionalToken(37); + var asteriskToken = parseOptionalToken(38); var name = parsePropertyName(); - var questionToken = parseOptionalToken(53); - if (asteriskToken || token() === 17 || token() === 25) { + var questionToken = parseOptionalToken(54); + if (asteriskToken || token() === 18 || token() === 26) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); } else { @@ -15931,17 +15418,17 @@ var ts; node.decorators = decorators; node.modifiers = modifiers; node.name = parsePropertyName(); - fillSignature(54, false, false, false, node); + fillSignature(55, false, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, false); return addJSDocComment(finishNode(node)); } function isClassMemberModifier(idToken) { switch (idToken) { - case 112: - case 110: - case 111: case 113: - case 128: + case 111: + case 112: + case 114: + case 129: return true; default: return false; @@ -15949,7 +15436,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token() === 55) { + if (token() === 56) { return true; } while (ts.isModifierKind(token())) { @@ -15959,26 +15446,26 @@ var ts; } nextToken(); } - if (token() === 37) { + if (token() === 38) { return true; } if (isLiteralPropertyName()) { idToken = token(); nextToken(); } - if (token() === 19) { + if (token() === 20) { return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 131 || idToken === 123) { + if (!ts.isKeyword(idToken) || idToken === 132 || idToken === 124) { return true; } switch (token()) { - case 17: - case 25: + case 18: + case 26: + case 55: + case 57: case 54: - case 56: - case 53: return true; default: return canParseSemicolon(); @@ -15990,10 +15477,10 @@ var ts; var decorators; while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(55)) { + if (!parseOptional(56)) { break; } - var decorator = createNode(143, decoratorStart); + var decorator = createNode(144, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); if (!decorators) { @@ -16013,7 +15500,7 @@ var ts; while (true) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); - if (token() === 74 && permitInvalidConstAsModifier) { + if (token() === 75 && permitInvalidConstAsModifier) { if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) { break; } @@ -16038,7 +15525,7 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 118) { + if (token() === 119) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); nextToken(); @@ -16049,8 +15536,8 @@ var ts; return modifiers; } function parseClassElement() { - if (token() === 23) { - var result = createNode(198); + if (token() === 24) { + var result = createNode(199); nextToken(); return finishNode(result); } @@ -16061,7 +15548,7 @@ var ts; if (accessor) { return accessor; } - if (token() === 121) { + if (token() === 122) { return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { @@ -16070,33 +15557,33 @@ var ts; if (ts.tokenIsIdentifierOrKeyword(token()) || token() === 9 || token() === 8 || - token() === 37 || - token() === 19) { + token() === 38 || + token() === 20) { return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { - var name_13 = createMissingNode(69, true, ts.Diagnostics.Declaration_expected); - return parsePropertyDeclaration(fullStart, decorators, modifiers, name_13, undefined); + var name_10 = createMissingNode(70, true, ts.Diagnostics.Declaration_expected); + return parsePropertyDeclaration(fullStart, decorators, modifiers, name_10, undefined); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 192); + return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 193); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 221); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 222); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(73); + parseExpected(74); node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); - node.heritageClauses = parseHeritageClauses(true); - if (parseExpected(15)) { + node.heritageClauses = parseHeritageClauses(); + if (parseExpected(16)) { node.members = parseClassMembers(); - parseExpected(16); + parseExpected(17); } else { node.members = createMissingList(); @@ -16109,16 +15596,16 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 106 && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 107 && lookAhead(nextTokenIsIdentifierOrKeyword); } - function parseHeritageClauses(isClassHeritageClause) { + function parseHeritageClauses() { if (isHeritageClause()) { return parseList(20, parseHeritageClause); } return undefined; } function parseHeritageClause() { - if (token() === 83 || token() === 106) { + if (token() === 84 || token() === 107) { var node = createNode(251); node.token = token(); nextToken(); @@ -16128,38 +15615,38 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(194); + var node = createNode(195); node.expression = parseLeftHandSideExpressionOrHigher(); - if (token() === 25) { - node.typeArguments = parseBracketedList(18, parseType, 25, 27); + if (token() === 26) { + node.typeArguments = parseBracketedList(18, parseType, 26, 28); } return finishNode(node); } function isHeritageClause() { - return token() === 83 || token() === 106; + return token() === 84 || token() === 107; } function parseClassMembers() { return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(222, fullStart); + var node = createNode(223, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(107); + parseExpected(108); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - node.heritageClauses = parseHeritageClauses(false); + node.heritageClauses = parseHeritageClauses(); node.members = parseObjectTypeMembers(); return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(223, fullStart); + var node = createNode(224, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(134); + parseExpected(135); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(56); + parseExpected(57); node.type = parseType(); parseSemicolon(); return addJSDocComment(finishNode(node)); @@ -16171,14 +15658,14 @@ var ts; return addJSDocComment(finishNode(node)); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(224, fullStart); + var node = createNode(225, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(81); + parseExpected(82); node.name = parseIdentifier(); - if (parseExpected(15)) { + if (parseExpected(16)) { node.members = parseDelimitedList(6, parseEnumMember); - parseExpected(16); + parseExpected(17); } else { node.members = createMissingList(); @@ -16186,10 +15673,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseModuleBlock() { - var node = createNode(226, scanner.getStartPos()); - if (parseExpected(15)) { + var node = createNode(227, scanner.getStartPos()); + if (parseExpected(16)) { node.statements = parseList(1, parseStatement); - parseExpected(16); + parseExpected(17); } else { node.statements = createMissingList(); @@ -16197,29 +15684,29 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(225, fullStart); + var node = createNode(226, fullStart); var namespaceFlag = flags & 16; node.decorators = decorators; node.modifiers = modifiers; node.flags |= flags; node.name = parseIdentifier(); - node.body = parseOptional(21) + node.body = parseOptional(22) ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 4 | namespaceFlag) : parseModuleBlock(); return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(225, fullStart); + var node = createNode(226, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (token() === 137) { + if (token() === 138) { node.name = parseIdentifier(); node.flags |= 512; } else { node.name = parseLiteralNode(true); } - if (token() === 15) { + if (token() === 16) { node.body = parseModuleBlock(); } else { @@ -16229,14 +15716,14 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = 0; - if (token() === 137) { + if (token() === 138) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } - else if (parseOptional(126)) { + else if (parseOptional(127)) { flags |= 16; } else { - parseExpected(125); + parseExpected(126); if (token() === 9) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -16244,63 +15731,63 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token() === 129 && + return token() === 130 && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { - return nextToken() === 17; + return nextToken() === 18; } function nextTokenIsSlash() { - return nextToken() === 39; + return nextToken() === 40; } function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { - var exportDeclaration = createNode(228, fullStart); + var exportDeclaration = createNode(229, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; - parseExpected(116); - parseExpected(126); + parseExpected(117); + parseExpected(127); exportDeclaration.name = parseIdentifier(); - parseExpected(23); + parseExpected(24); return finishNode(exportDeclaration); } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { - parseExpected(89); + parseExpected(90); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 24 && token() !== 136) { - var importEqualsDeclaration = createNode(229, fullStart); + if (token() !== 25 && token() !== 137) { + var importEqualsDeclaration = createNode(230, fullStart); importEqualsDeclaration.decorators = decorators; importEqualsDeclaration.modifiers = modifiers; importEqualsDeclaration.name = identifier; - parseExpected(56); + parseExpected(57); importEqualsDeclaration.moduleReference = parseModuleReference(); parseSemicolon(); return addJSDocComment(finishNode(importEqualsDeclaration)); } } - var importDeclaration = createNode(230, fullStart); + var importDeclaration = createNode(231, fullStart); importDeclaration.decorators = decorators; importDeclaration.modifiers = modifiers; if (identifier || - token() === 37 || - token() === 15) { + token() === 38 || + token() === 16) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(136); + parseExpected(137); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(importDeclaration); } function parseImportClause(identifier, fullStart) { - var importClause = createNode(231, fullStart); + var importClause = createNode(232, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || - parseOptional(24)) { - importClause.namedBindings = token() === 37 ? parseNamespaceImport() : parseNamedImportsOrExports(233); + parseOptional(25)) { + importClause.namedBindings = token() === 38 ? parseNamespaceImport() : parseNamedImportsOrExports(234); } return finishNode(importClause); } @@ -16310,11 +15797,11 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(240); - parseExpected(129); - parseExpected(17); - node.expression = parseModuleSpecifier(); + var node = createNode(241); + parseExpected(130); parseExpected(18); + node.expression = parseModuleSpecifier(); + parseExpected(19); return finishNode(node); } function parseModuleSpecifier() { @@ -16328,22 +15815,22 @@ var ts; } } function parseNamespaceImport() { - var namespaceImport = createNode(232); - parseExpected(37); - parseExpected(116); + var namespaceImport = createNode(233); + parseExpected(38); + parseExpected(117); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(21, kind === 233 ? parseImportSpecifier : parseExportSpecifier, 15, 16); + node.elements = parseBracketedList(21, kind === 234 ? parseImportSpecifier : parseExportSpecifier, 16, 17); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(238); + return parseImportOrExportSpecifier(239); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(234); + return parseImportOrExportSpecifier(235); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -16351,9 +15838,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token() === 116) { + if (token() === 117) { node.propertyName = identifierName; - parseExpected(116); + parseExpected(117); checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -16362,23 +15849,23 @@ var ts; else { node.name = identifierName; } - if (kind === 234 && checkIdentifierIsKeyword) { + if (kind === 235 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(236, fullStart); + var node = createNode(237, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (parseOptional(37)) { - parseExpected(136); + if (parseOptional(38)) { + parseExpected(137); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(237); - if (token() === 136 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { - parseExpected(136); + node.exportClause = parseNamedImportsOrExports(238); + if (token() === 137 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { + parseExpected(137); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -16386,14 +15873,14 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(235, fullStart); + var node = createNode(236, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (parseOptional(56)) { + if (parseOptional(57)) { node.isExportEquals = true; } else { - parseExpected(77); + parseExpected(78); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -16465,36 +15952,72 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return ts.hasModifier(node, 1) - || node.kind === 229 && node.moduleReference.kind === 240 - || node.kind === 230 - || node.kind === 235 + || node.kind === 230 && node.moduleReference.kind === 241 + || node.kind === 231 || node.kind === 236 + || node.kind === 237 ? node : undefined; }); } + var ParsingContext; + (function (ParsingContext) { + ParsingContext[ParsingContext["SourceElements"] = 0] = "SourceElements"; + ParsingContext[ParsingContext["BlockStatements"] = 1] = "BlockStatements"; + ParsingContext[ParsingContext["SwitchClauses"] = 2] = "SwitchClauses"; + ParsingContext[ParsingContext["SwitchClauseStatements"] = 3] = "SwitchClauseStatements"; + ParsingContext[ParsingContext["TypeMembers"] = 4] = "TypeMembers"; + ParsingContext[ParsingContext["ClassMembers"] = 5] = "ClassMembers"; + ParsingContext[ParsingContext["EnumMembers"] = 6] = "EnumMembers"; + ParsingContext[ParsingContext["HeritageClauseElement"] = 7] = "HeritageClauseElement"; + ParsingContext[ParsingContext["VariableDeclarations"] = 8] = "VariableDeclarations"; + ParsingContext[ParsingContext["ObjectBindingElements"] = 9] = "ObjectBindingElements"; + ParsingContext[ParsingContext["ArrayBindingElements"] = 10] = "ArrayBindingElements"; + ParsingContext[ParsingContext["ArgumentExpressions"] = 11] = "ArgumentExpressions"; + ParsingContext[ParsingContext["ObjectLiteralMembers"] = 12] = "ObjectLiteralMembers"; + ParsingContext[ParsingContext["JsxAttributes"] = 13] = "JsxAttributes"; + ParsingContext[ParsingContext["JsxChildren"] = 14] = "JsxChildren"; + ParsingContext[ParsingContext["ArrayLiteralMembers"] = 15] = "ArrayLiteralMembers"; + ParsingContext[ParsingContext["Parameters"] = 16] = "Parameters"; + ParsingContext[ParsingContext["TypeParameters"] = 17] = "TypeParameters"; + ParsingContext[ParsingContext["TypeArguments"] = 18] = "TypeArguments"; + ParsingContext[ParsingContext["TupleElementTypes"] = 19] = "TupleElementTypes"; + ParsingContext[ParsingContext["HeritageClauses"] = 20] = "HeritageClauses"; + ParsingContext[ParsingContext["ImportOrExportSpecifiers"] = 21] = "ImportOrExportSpecifiers"; + ParsingContext[ParsingContext["JSDocFunctionParameters"] = 22] = "JSDocFunctionParameters"; + ParsingContext[ParsingContext["JSDocTypeArguments"] = 23] = "JSDocTypeArguments"; + ParsingContext[ParsingContext["JSDocRecordMembers"] = 24] = "JSDocRecordMembers"; + ParsingContext[ParsingContext["JSDocTupleTypes"] = 25] = "JSDocTupleTypes"; + ParsingContext[ParsingContext["Count"] = 26] = "Count"; + })(ParsingContext || (ParsingContext = {})); + var Tristate; + (function (Tristate) { + Tristate[Tristate["False"] = 0] = "False"; + Tristate[Tristate["True"] = 1] = "True"; + Tristate[Tristate["Unknown"] = 2] = "Unknown"; + })(Tristate || (Tristate = {})); var JSDocParser; (function (JSDocParser) { function isJSDocType() { switch (token()) { - case 37: - case 53: - case 17: - case 19: - case 49: - case 15: - case 87: - case 22: - case 92: - case 97: + case 38: + case 54: + case 18: + case 20: + case 50: + case 16: + case 88: + case 23: + case 93: + case 98: return true; } return ts.tokenIsIdentifierOrKeyword(token()); } JSDocParser.isJSDocType = isJSDocType; function parseJSDocTypeExpressionForTests(content, start, length) { - initializeState("file.js", content, 2, undefined, 1); - sourceFile = createSourceFile("file.js", 2, 1); + initializeState(content, 4, undefined, 1); + sourceFile = createSourceFile("file.js", 4, 1); scanner.setText(content, start, length); currentToken = scanner.scan(); var jsDocTypeExpression = parseJSDocTypeExpression(); @@ -16505,21 +16028,21 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; function parseJSDocTypeExpression() { var result = createNode(257, scanner.getTokenPos()); - parseExpected(15); - result.type = parseJSDocTopLevelType(); parseExpected(16); + result.type = parseJSDocTopLevelType(); + parseExpected(17); fixupParentReferences(result); return finishNode(result); } JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocTopLevelType() { var type = parseJSDocType(); - if (token() === 47) { + if (token() === 48) { var unionType = createNode(261, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } - if (token() === 56) { + if (token() === 57) { var optionalType = createNode(268, type.pos); nextToken(); optionalType.type = type; @@ -16530,20 +16053,20 @@ var ts; function parseJSDocType() { var type = parseBasicTypeExpression(); while (true) { - if (token() === 19) { + if (token() === 20) { var arrayType = createNode(260, type.pos); arrayType.elementType = type; nextToken(); - parseExpected(20); + parseExpected(21); type = finishNode(arrayType); } - else if (token() === 53) { + else if (token() === 54) { var nullableType = createNode(263, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } - else if (token() === 49) { + else if (token() === 50) { var nonNullableType = createNode(264, type.pos); nonNullableType.type = type; nextToken(); @@ -16557,40 +16080,40 @@ var ts; } function parseBasicTypeExpression() { switch (token()) { - case 37: + case 38: return parseJSDocAllType(); - case 53: + case 54: return parseJSDocUnknownOrNullableType(); - case 17: + case 18: return parseJSDocUnionType(); - case 19: + case 20: return parseJSDocTupleType(); - case 49: + case 50: return parseJSDocNonNullableType(); - case 15: + case 16: return parseJSDocRecordType(); - case 87: + case 88: return parseJSDocFunctionType(); - case 22: + case 23: return parseJSDocVariadicType(); - case 92: - return parseJSDocConstructorType(); - case 97: - return parseJSDocThisType(); - case 117: - case 132: - case 130: - case 120: - case 133: - case 103: case 93: - case 135: - case 127: + return parseJSDocConstructorType(); + case 98: + return parseJSDocThisType(); + case 118: + case 133: + case 131: + case 121: + case 134: + case 104: + case 94: + case 136: + case 128: return parseTokenNode(); case 9: case 8: - case 99: - case 84: + case 100: + case 85: return parseJSDocLiteralType(); } return parseJSDocTypeReference(); @@ -16598,14 +16121,14 @@ var ts; function parseJSDocThisType() { var result = createNode(272); nextToken(); - parseExpected(54); + parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { var result = createNode(271); nextToken(); - parseExpected(54); + parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } @@ -16618,33 +16141,33 @@ var ts; function parseJSDocFunctionType() { var result = createNode(269); nextToken(); - parseExpected(17); + parseExpected(18); result.parameters = parseDelimitedList(22, parseJSDocParameter); checkForTrailingComma(result.parameters); - parseExpected(18); - if (token() === 54) { + parseExpected(19); + if (token() === 55) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(142); + var parameter = createNode(143); parameter.type = parseJSDocType(); - if (parseOptional(56)) { - parameter.questionToken = createNode(56); + if (parseOptional(57)) { + parameter.questionToken = createNode(57); } return finishNode(parameter); } function parseJSDocTypeReference() { var result = createNode(267); result.name = parseSimplePropertyName(); - if (token() === 25) { + if (token() === 26) { result.typeArguments = parseTypeArguments(); } else { - while (parseOptional(21)) { - if (token() === 25) { + while (parseOptional(22)) { + if (token() === 26) { result.typeArguments = parseTypeArguments(); break; } @@ -16660,7 +16183,7 @@ var ts; var typeArguments = parseDelimitedList(23, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); - parseExpected(27); + parseExpected(28); return typeArguments; } function checkForEmptyTypeArgumentList(typeArguments) { @@ -16671,7 +16194,7 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(139, left.pos); + var result = createNode(140, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); @@ -16692,7 +16215,7 @@ var ts; nextToken(); result.types = parseDelimitedList(25, parseJSDocType); checkForTrailingComma(result.types); - parseExpected(20); + parseExpected(21); return finishNode(result); } function checkForTrailingComma(list) { @@ -16705,13 +16228,13 @@ var ts; var result = createNode(261); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); - parseExpected(18); + parseExpected(19); return finishNode(result); } function parseJSDocTypeList(firstType) { ts.Debug.assert(!!firstType); var types = createNodeArray([firstType], firstType.pos); - while (parseOptional(47)) { + while (parseOptional(48)) { types.push(parseJSDocType()); } types.end = scanner.getStartPos(); @@ -16730,12 +16253,12 @@ var ts; function parseJSDocUnknownOrNullableType() { var pos = scanner.getStartPos(); nextToken(); - if (token() === 24 || - token() === 16 || - token() === 18 || - token() === 27 || - token() === 56 || - token() === 47) { + if (token() === 25 || + token() === 17 || + token() === 19 || + token() === 28 || + token() === 57 || + token() === 48) { var result = createNode(259, pos); return finishNode(result); } @@ -16746,7 +16269,7 @@ var ts; } } function parseIsolatedJSDocComment(content, start, length) { - initializeState("file.js", content, 2, undefined, 1); + initializeState(content, 4, undefined, 1); sourceFile = { languageVariant: 0, text: content }; var jsDoc = parseJSDocCommentWorker(start, length); var diagnostics = parseDiagnostics; @@ -16768,6 +16291,12 @@ var ts; return comment; } JSDocParser.parseJSDocComment = parseJSDocComment; + var JSDocState; + (function (JSDocState) { + JSDocState[JSDocState["BeginningOfLine"] = 0] = "BeginningOfLine"; + JSDocState[JSDocState["SawAsterisk"] = 1] = "SawAsterisk"; + JSDocState[JSDocState["SavingComments"] = 2] = "SavingComments"; + })(JSDocState || (JSDocState = {})); function parseJSDocCommentWorker(start, length) { var content = sourceText; start = start || 0; @@ -16804,7 +16333,7 @@ var ts; } while (token() !== 1) { switch (token()) { - case 55: + case 56: if (state === 0 || state === 1) { removeTrailingNewlines(comments); parseTag(indent); @@ -16822,7 +16351,7 @@ var ts; state = 0; indent = 0; break; - case 37: + case 38: var asterisk = scanner.getTokenText(); if (state === 1) { state = 2; @@ -16833,7 +16362,7 @@ var ts; indent += asterisk.length; } break; - case 69: + case 70: pushComment(scanner.getTokenText()); state = 2; break; @@ -16890,8 +16419,8 @@ var ts; } } function parseTag(indent) { - ts.Debug.assert(token() === 55); - var atToken = createNode(55, scanner.getTokenPos()); + ts.Debug.assert(token() === 56); + var atToken = createNode(56, scanner.getTokenPos()); atToken.end = scanner.getTextPos(); nextJSDocToken(); var tagName = parseJSDocIdentifierName(); @@ -16942,7 +16471,7 @@ var ts; comments.push(text); indent += text.length; } - while (token() !== 55 && token() !== 1) { + while (token() !== 56 && token() !== 1) { switch (token()) { case 4: if (state >= 1) { @@ -16951,7 +16480,7 @@ var ts; } indent = 0; break; - case 55: + case 56: break; case 5: if (state === 2) { @@ -16965,7 +16494,7 @@ var ts; indent += whitespace.length; } break; - case 37: + case 38: if (state === 0) { state = 1; indent += scanner.getTokenText().length; @@ -16976,7 +16505,7 @@ var ts; pushComment(scanner.getTokenText()); break; } - if (token() === 55) { + if (token() === 56) { break; } nextJSDocToken(); @@ -17004,7 +16533,7 @@ var ts; function tryParseTypeExpression() { return tryParse(function () { skipWhitespace(); - if (token() !== 15) { + if (token() !== 16) { return undefined; } return parseJSDocTypeExpression(); @@ -17015,14 +16544,14 @@ var ts; skipWhitespace(); var name; var isBracketed; - if (parseOptionalToken(19)) { + if (parseOptionalToken(20)) { name = parseJSDocIdentifierName(); skipWhitespace(); isBracketed = true; - if (parseOptionalToken(56)) { + if (parseOptionalToken(57)) { parseExpression(); } - parseExpected(20); + parseExpected(21); } else if (ts.tokenIsIdentifierOrKeyword(token())) { name = parseJSDocIdentifierName(); @@ -17099,9 +16628,9 @@ var ts; if (typeExpression) { if (typeExpression.type.kind === 267) { var jsDocTypeReference = typeExpression.type; - if (jsDocTypeReference.name.kind === 69) { - var name_14 = jsDocTypeReference.name; - if (name_14.text === "Object") { + if (jsDocTypeReference.name.kind === 70) { + var name_11 = jsDocTypeReference.name; + if (name_11.text === "Object") { typedefTag.jsDocTypeLiteral = scanChildTags(); } } @@ -17123,7 +16652,7 @@ var ts; while (token() !== 1 && !parentTagTerminated) { nextJSDocToken(); switch (token()) { - case 55: + case 56: if (canParseTag) { parentTagTerminated = !tryParseChildTag(jsDocTypeLiteral); if (!parentTagTerminated) { @@ -17137,13 +16666,13 @@ var ts; canParseTag = true; seenAsterisk = false; break; - case 37: + case 38: if (seenAsterisk) { canParseTag = false; } seenAsterisk = true; break; - case 69: + case 70: canParseTag = false; case 1: break; @@ -17154,8 +16683,8 @@ var ts; } } function tryParseChildTag(parentTag) { - ts.Debug.assert(token() === 55); - var atToken = createNode(55, scanner.getStartPos()); + ts.Debug.assert(token() === 56); + var atToken = createNode(56, scanner.getStartPos()); atToken.end = scanner.getTextPos(); nextJSDocToken(); var tagName = parseJSDocIdentifierName(); @@ -17187,17 +16716,17 @@ var ts; } var typeParameters = createNodeArray(); while (true) { - var name_15 = parseJSDocIdentifierName(); + var name_12 = parseJSDocIdentifierName(); skipWhitespace(); - if (!name_15) { + if (!name_12) { parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(141, name_15.pos); - typeParameter.name = name_15; + var typeParameter = createNode(142, name_12.pos); + typeParameter.name = name_12; finishNode(typeParameter); typeParameters.push(typeParameter); - if (token() === 24) { + if (token() === 25) { nextJSDocToken(); skipWhitespace(); } @@ -17226,7 +16755,7 @@ var ts; } var pos = scanner.getTokenPos(); var end = scanner.getTextPos(); - var result = createNode(69, pos); + var result = createNode(70, pos); result.text = content.substring(pos, end); finishNode(result, end); nextJSDocToken(); @@ -17297,8 +16826,8 @@ var ts; array._children = undefined; array.pos += delta; array.end += delta; - for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { - var node = array_8[_i]; + for (var _i = 0, array_9 = array; _i < array_9.length; _i++) { + var node = array_9[_i]; visitNode(node); } } @@ -17307,7 +16836,7 @@ var ts; switch (node.kind) { case 9: case 8: - case 69: + case 70: return true; } return false; @@ -17370,8 +16899,8 @@ var ts; array.intersectsChange = true; array._children = undefined; adjustIntersectingElement(array, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta); - for (var _i = 0, array_9 = array; _i < array_9.length; _i++) { - var node = array_9[_i]; + for (var _i = 0, array_10 = array; _i < array_10.length; _i++) { + var node = array_10[_i]; visitNode(node); } return; @@ -17519,21 +17048,31 @@ var ts; } } } + var InvalidPosition; + (function (InvalidPosition) { + InvalidPosition[InvalidPosition["Value"] = -1] = "Value"; + })(InvalidPosition || (InvalidPosition = {})); })(IncrementalParser || (IncrementalParser = {})); })(ts || (ts = {})); var ts; (function (ts) { + (function (ModuleInstanceState) { + ModuleInstanceState[ModuleInstanceState["NonInstantiated"] = 0] = "NonInstantiated"; + ModuleInstanceState[ModuleInstanceState["Instantiated"] = 1] = "Instantiated"; + ModuleInstanceState[ModuleInstanceState["ConstEnumOnly"] = 2] = "ConstEnumOnly"; + })(ts.ModuleInstanceState || (ts.ModuleInstanceState = {})); + var ModuleInstanceState = ts.ModuleInstanceState; function getModuleInstanceState(node) { - if (node.kind === 222 || node.kind === 223) { + if (node.kind === 223 || node.kind === 224) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 230 || node.kind === 229) && !(ts.hasModifier(node, 1))) { + else if ((node.kind === 231 || node.kind === 230) && !(ts.hasModifier(node, 1))) { return 0; } - else if (node.kind === 226) { + else if (node.kind === 227) { var state_1 = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -17549,7 +17088,7 @@ var ts; }); return state_1; } - else if (node.kind === 225) { + else if (node.kind === 226) { var body = node.body; return body ? getModuleInstanceState(body) : 1; } @@ -17558,6 +17097,18 @@ var ts; } } ts.getModuleInstanceState = getModuleInstanceState; + var ContainerFlags; + (function (ContainerFlags) { + ContainerFlags[ContainerFlags["None"] = 0] = "None"; + ContainerFlags[ContainerFlags["IsContainer"] = 1] = "IsContainer"; + ContainerFlags[ContainerFlags["IsBlockScopedContainer"] = 2] = "IsBlockScopedContainer"; + ContainerFlags[ContainerFlags["IsControlFlowContainer"] = 4] = "IsControlFlowContainer"; + ContainerFlags[ContainerFlags["IsFunctionLike"] = 8] = "IsFunctionLike"; + ContainerFlags[ContainerFlags["IsFunctionExpression"] = 16] = "IsFunctionExpression"; + ContainerFlags[ContainerFlags["HasLocals"] = 32] = "HasLocals"; + ContainerFlags[ContainerFlags["IsInterface"] = 64] = "IsInterface"; + ContainerFlags[ContainerFlags["IsObjectLiteralOrClassExpressionMethod"] = 128] = "IsObjectLiteralOrClassExpressionMethod"; + })(ContainerFlags || (ContainerFlags = {})); var binder = createBinder(); function bindSourceFile(file, options) { ts.performance.mark("beforeBind"); @@ -17655,7 +17206,7 @@ var ts; if (symbolFlags & 107455) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 225)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 226)) { symbol.valueDeclaration = node; } } @@ -17665,7 +17216,7 @@ var ts; if (ts.isAmbientModule(node)) { return ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + node.name.text + "\""; } - if (node.name.kind === 140) { + if (node.name.kind === 141) { var nameExpression = node.name.expression; if (ts.isStringOrNumericLiteral(nameExpression.kind)) { return nameExpression.text; @@ -17676,21 +17227,21 @@ var ts; return node.name.text; } switch (node.kind) { - case 148: + case 149: return "__constructor"; - case 156: - case 151: - return "__call"; case 157: case 152: - return "__new"; + return "__call"; + case 158: case 153: + return "__new"; + case 154: return "__index"; - case 236: + case 237: return "__export"; - case 235: + case 236: return node.isExportEquals ? "export=" : "default"; - case 187: + case 188: switch (ts.getSpecialPropertyAssignmentKind(node)) { case 2: return "export="; @@ -17702,12 +17253,12 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 220: case 221: + case 222: return ts.hasModifier(node, 512) ? "default" : undefined; case 269: return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; - case 142: + case 143: ts.Debug.assert(node.parent.kind === 269); var functionType = node.parent; var index = ts.indexOf(functionType.parameters, node); @@ -17715,10 +17266,10 @@ var ts; case 279: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 200) { + if (parentNode && parentNode.kind === 201) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; - if (nameIdentifier.kind === 69) { + if (nameIdentifier.kind === 70) { nameFromParentNode = nameIdentifier.text; } } @@ -17759,7 +17310,7 @@ var ts; } else { if (symbol.declarations && symbol.declarations.length && - (isDefaultExport || (node.kind === 235 && !node.isExportEquals))) { + (isDefaultExport || (node.kind === 236 && !node.isExportEquals))) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -17779,7 +17330,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1; if (symbolFlags & 8388608) { - if (node.kind === 238 || (node.kind === 229 && hasExportModifier)) { + if (node.kind === 239 || (node.kind === 230 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -17896,64 +17447,64 @@ var ts; return; } switch (node.kind) { - case 205: + case 206: bindWhileStatement(node); break; - case 204: + case 205: bindDoStatement(node); break; - case 206: + case 207: bindForStatement(node); break; - case 207: case 208: + case 209: bindForInOrForOfStatement(node); break; - case 203: + case 204: bindIfStatement(node); break; - case 211: - case 215: + case 212: + case 216: bindReturnOrThrow(node); break; + case 211: case 210: - case 209: bindBreakOrContinueStatement(node); break; - case 216: + case 217: bindTryStatement(node); break; - case 213: + case 214: bindSwitchStatement(node); break; - case 227: + case 228: bindCaseBlock(node); break; case 249: bindCaseClause(node); break; - case 214: + case 215: bindLabeledStatement(node); break; - case 185: + case 186: bindPrefixUnaryExpressionFlow(node); break; - case 186: + case 187: bindPostfixUnaryExpressionFlow(node); break; - case 187: + case 188: bindBinaryExpressionFlow(node); break; - case 181: + case 182: bindDeleteExpressionFlow(node); break; - case 188: + case 189: bindConditionalExpressionFlow(node); break; - case 218: + case 219: bindVariableDeclarationFlow(node); break; - case 174: + case 175: bindCallExpressionFlow(node); break; default: @@ -17963,25 +17514,25 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 69: - case 97: - case 172: + case 70: + case 98: + case 173: return isNarrowableReference(expr); - case 174: + case 175: return hasNarrowableArgument(expr); - case 178: + case 179: return isNarrowingExpression(expr.expression); - case 187: + case 188: return isNarrowingBinaryExpression(expr); - case 185: - return expr.operator === 49 && isNarrowingExpression(expr.operand); + case 186: + return expr.operator === 50 && isNarrowingExpression(expr.operand); } return false; } function isNarrowableReference(expr) { - return expr.kind === 69 || - expr.kind === 97 || - expr.kind === 172 && isNarrowableReference(expr.expression); + return expr.kind === 70 || + expr.kind === 98 || + expr.kind === 173 && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -17992,41 +17543,41 @@ var ts; } } } - if (expr.expression.kind === 172 && + if (expr.expression.kind === 173 && isNarrowableReference(expr.expression.expression)) { return true; } return false; } function isNarrowingTypeofOperands(expr1, expr2) { - return expr1.kind === 182 && isNarrowableOperand(expr1.expression) && expr2.kind === 9; + return expr1.kind === 183 && isNarrowableOperand(expr1.expression) && expr2.kind === 9; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 56: + case 57: return isNarrowableReference(expr.left); - case 30: case 31: case 32: case 33: + case 34: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 91: + case 92: return isNarrowableOperand(expr.left); - case 24: + case 25: return isNarrowingExpression(expr.right); } return false; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 178: + case 179: return isNarrowableOperand(expr.expression); - case 187: + case 188: switch (expr.operatorToken.kind) { - case 56: + case 57: return isNarrowableOperand(expr.left); - case 24: + case 25: return isNarrowableOperand(expr.right); } } @@ -18045,7 +17596,7 @@ var ts; }; } function setFlowNodeReferenced(flow) { - flow.flags |= flow.flags & 256 ? 512 : 256; + flow.flags |= flow.flags & 512 ? 1024 : 512; } function addAntecedent(label, antecedent) { if (!(antecedent.flags & 1) && !ts.contains(label.antecedents, antecedent)) { @@ -18060,8 +17611,8 @@ var ts; if (!expression) { return flags & 32 ? antecedent : unreachableFlow; } - if (expression.kind === 99 && flags & 64 || - expression.kind === 84 && flags & 32) { + if (expression.kind === 100 && flags & 64 || + expression.kind === 85 && flags & 32) { return unreachableFlow; } if (!isNarrowingExpression(expression)) { @@ -18095,6 +17646,14 @@ var ts; node: node }; } + function createFlowArrayMutation(antecedent, node) { + setFlowNodeReferenced(antecedent); + return { + flags: 256, + antecedent: antecedent, + node: node + }; + } function finishFlowLabel(flow) { var antecedents = flow.antecedents; if (!antecedents) { @@ -18108,34 +17667,34 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 203: - case 205: case 204: - return parent.expression === node; case 206: - case 188: + case 205: + return parent.expression === node; + case 207: + case 189: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 178) { + if (node.kind === 179) { node = node.expression; } - else if (node.kind === 185 && node.operator === 49) { + else if (node.kind === 186 && node.operator === 50) { node = node.operand; } else { - return node.kind === 187 && (node.operatorToken.kind === 51 || - node.operatorToken.kind === 52); + return node.kind === 188 && (node.operatorToken.kind === 52 || + node.operatorToken.kind === 53); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 178 || - node.parent.kind === 185 && - node.parent.operator === 49) { + while (node.parent.kind === 179 || + node.parent.kind === 186 && + node.parent.operator === 50) { node = node.parent; } return !isStatementCondition(node) && !isLogicalExpression(node.parent); @@ -18208,7 +17767,7 @@ var ts; bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 219) { + if (node.initializer.kind !== 220) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -18230,7 +17789,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 211) { + if (node.kind === 212) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -18250,7 +17809,7 @@ var ts; return undefined; } function bindbreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 210 ? breakTarget : continueTarget; + var flowLabel = node.kind === 211 ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -18270,21 +17829,32 @@ var ts; } } function bindTryStatement(node) { - var postFinallyLabel = createBranchLabel(); + var preFinallyLabel = createBranchLabel(); var preTryFlow = currentFlow; bind(node.tryBlock); - addAntecedent(postFinallyLabel, currentFlow); + addAntecedent(preFinallyLabel, currentFlow); + var flowAfterTry = currentFlow; + var flowAfterCatch = unreachableFlow; if (node.catchClause) { currentFlow = preTryFlow; bind(node.catchClause); - addAntecedent(postFinallyLabel, currentFlow); + addAntecedent(preFinallyLabel, currentFlow); + flowAfterCatch = currentFlow; } if (node.finallyBlock) { - currentFlow = preTryFlow; + addAntecedent(preFinallyLabel, preTryFlow); + currentFlow = finishFlowLabel(preFinallyLabel); bind(node.finallyBlock); + if (!(currentFlow.flags & 1)) { + if ((flowAfterTry.flags & 1) && (flowAfterCatch.flags & 1)) { + currentFlow = flowAfterTry === reportedUnreachableFlow || flowAfterCatch === reportedUnreachableFlow + ? reportedUnreachableFlow + : unreachableFlow; + } + } } - if (!node.finallyBlock || !(currentFlow.flags & 1)) { - currentFlow = finishFlowLabel(postFinallyLabel); + else { + currentFlow = finishFlowLabel(preFinallyLabel); } } function bindSwitchStatement(node) { @@ -18361,7 +17931,7 @@ var ts; currentFlow = finishFlowLabel(postStatementLabel); } function bindDestructuringTargetFlow(node) { - if (node.kind === 187 && node.operatorToken.kind === 56) { + if (node.kind === 188 && node.operatorToken.kind === 57) { bindAssignmentTargetFlow(node.left); } else { @@ -18372,10 +17942,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 170) { + else if (node.kind === 171) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 191) { + if (e.kind === 192) { bindAssignmentTargetFlow(e.expression); } else { @@ -18383,7 +17953,7 @@ var ts; } } } - else if (node.kind === 171) { + else if (node.kind === 172) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; if (p.kind === 253) { @@ -18397,7 +17967,7 @@ var ts; } function bindLogicalExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 51) { + if (node.operatorToken.kind === 52) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -18408,7 +17978,7 @@ var ts; bindCondition(node.right, trueTarget, falseTarget); } function bindPrefixUnaryExpressionFlow(node) { - if (node.operator === 49) { + if (node.operator === 50) { var saveTrueTarget = currentTrueTarget; currentTrueTarget = currentFalseTarget; currentFalseTarget = saveTrueTarget; @@ -18418,20 +17988,20 @@ var ts; } else { ts.forEachChild(node, bind); - if (node.operator === 41 || node.operator === 42) { + if (node.operator === 42 || node.operator === 43) { bindAssignmentTargetFlow(node.operand); } } } function bindPostfixUnaryExpressionFlow(node) { ts.forEachChild(node, bind); - if (node.operator === 41 || node.operator === 42) { + if (node.operator === 42 || node.operator === 43) { bindAssignmentTargetFlow(node.operand); } } function bindBinaryExpressionFlow(node) { var operator = node.operatorToken.kind; - if (operator === 51 || operator === 52) { + if (operator === 52 || operator === 53) { if (isTopLevelLogicalExpression(node)) { var postExpressionLabel = createBranchLabel(); bindLogicalExpression(node, postExpressionLabel, postExpressionLabel); @@ -18443,14 +18013,20 @@ var ts; } else { ts.forEachChild(node, bind); - if (operator === 56 && !ts.isAssignmentTarget(node)) { + if (operator === 57 && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); + if (node.left.kind === 174) { + var elementAccess = node.left; + if (isNarrowableOperand(elementAccess.expression)) { + currentFlow = createFlowArrayMutation(currentFlow, node); + } + } } } } function bindDeleteExpressionFlow(node) { ts.forEachChild(node, bind); - if (node.expression.kind === 172) { + if (node.expression.kind === 173) { bindAssignmentTargetFlow(node.expression); } } @@ -18481,16 +18057,16 @@ var ts; } function bindVariableDeclarationFlow(node) { ts.forEachChild(node, bind); - if (node.initializer || node.parent.parent.kind === 207 || node.parent.parent.kind === 208) { + if (node.initializer || node.parent.parent.kind === 208 || node.parent.parent.kind === 209) { bindInitializedVariableFlow(node); } } function bindCallExpressionFlow(node) { var expr = node.expression; - while (expr.kind === 178) { + while (expr.kind === 179) { expr = expr.expression; } - if (expr.kind === 179 || expr.kind === 180) { + if (expr.kind === 180 || expr.kind === 181) { ts.forEach(node.typeArguments, bind); ts.forEach(node.arguments, bind); bind(node.expression); @@ -18498,54 +18074,60 @@ var ts; else { ts.forEachChild(node, bind); } + if (node.expression.kind === 173) { + var propertyAccess = node.expression; + if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { + currentFlow = createFlowArrayMutation(currentFlow, node); + } + } } function getContainerFlags(node) { switch (node.kind) { - case 192: - case 221: - case 224: - case 171: - case 159: + case 193: + case 222: + case 225: + case 172: + case 160: case 281: case 265: return 1; - case 222: + case 223: return 1 | 64; case 269: - case 225: - case 223: + case 226: + case 224: return 1 | 32; case 256: return 1 | 4 | 32; - case 147: + case 148: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 | 4 | 32 | 8 | 128; } - case 148: - case 220: - case 146: case 149: + case 221: + case 147: case 150: case 151: case 152: case 153: - case 156: + case 154: case 157: + case 158: return 1 | 4 | 32 | 8; - case 179: case 180: + case 181: return 1 | 4 | 32 | 8 | 16; - case 226: + case 227: return 4; - case 145: + case 146: return node.initializer ? 4 : 0; case 252: - case 206: case 207: case 208: - case 227: + case 209: + case 228: return 2; - case 199: + case 200: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -18561,36 +18143,36 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 225: + case 226: return declareModuleMember(node, symbolFlags, symbolExcludes); case 256: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 192: - case 221: - return declareClassMember(node, symbolFlags, symbolExcludes); - case 224: - return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 159: - case 171: + case 193: case 222: + return declareClassMember(node, symbolFlags, symbolExcludes); + case 225: + return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); + case 160: + case 172: + case 223: case 265: case 281: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 156: case 157: - case 151: + case 158: case 152: case 153: - case 147: - case 146: + case 154: case 148: + case 147: case 149: case 150: - case 220: - case 179: + case 151: + case 221: case 180: + case 181: case 269: - case 223: + case 224: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -18606,10 +18188,10 @@ var ts; } function hasExportDeclarations(node) { var body = node.kind === 256 ? node : node.body; - if (body && (body.kind === 256 || body.kind === 226)) { + if (body && (body.kind === 256 || body.kind === 227)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 236 || stat.kind === 235) { + if (stat.kind === 237 || stat.kind === 236) { return true; } } @@ -18681,15 +18263,20 @@ var ts; typeLiteralSymbol.members[symbol.name] = symbol; } function bindObjectLiteralExpression(node) { + var ElementKind; + (function (ElementKind) { + ElementKind[ElementKind["Property"] = 1] = "Property"; + ElementKind[ElementKind["Accessor"] = 2] = "Accessor"; + })(ElementKind || (ElementKind = {})); if (inStrictMode) { var seen = ts.createMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.name.kind !== 69) { + if (prop.name.kind !== 70) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 253 || prop.kind === 254 || prop.kind === 147 + var currentKind = prop.kind === 253 || prop.kind === 254 || prop.kind === 148 ? 1 : 2; var existingKind = seen[identifier.text]; @@ -18711,7 +18298,7 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 225: + case 226: declareModuleMember(node, symbolFlags, symbolExcludes); break; case 256: @@ -18732,8 +18319,8 @@ var ts; } function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 106 && - node.originalKeywordKind <= 114 && + node.originalKeywordKind >= 107 && + node.originalKeywordKind <= 115 && !ts.isIdentifierName(node) && !ts.isInAmbientContext(node)) { if (!file.parseDiagnostics.length) { @@ -18761,17 +18348,17 @@ var ts; } } function checkStrictModeDeleteExpression(node) { - if (inStrictMode && node.expression.kind === 69) { + if (inStrictMode && node.expression.kind === 70) { var span_2 = ts.getErrorSpanForNode(file, node.expression); file.bindDiagnostics.push(ts.createFileDiagnostic(file, span_2.start, span_2.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode)); } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 69 && + return node.kind === 70 && (node.text === "eval" || node.text === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 69) { + if (name && name.kind === 70) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { var span_3 = ts.getErrorSpanForNode(file, name); @@ -18805,7 +18392,7 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2) { if (blockScopeContainer.kind !== 256 && - blockScopeContainer.kind !== 225 && + blockScopeContainer.kind !== 226 && !ts.isFunctionLike(blockScopeContainer)) { var errorSpan = ts.getErrorSpanForNode(file, node); file.bindDiagnostics.push(ts.createFileDiagnostic(file, errorSpan.start, errorSpan.length, getStrictModeBlockScopeFunctionDeclarationMessage(node))); @@ -18824,7 +18411,7 @@ var ts; } function checkStrictModePrefixUnaryExpression(node) { if (inStrictMode) { - if (node.operator === 41 || node.operator === 42) { + if (node.operator === 42 || node.operator === 43) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -18848,7 +18435,7 @@ var ts; node.parent = parent; var saveInStrictMode = inStrictMode; bindWorker(node); - if (node.kind > 138) { + if (node.kind > 139) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -18885,18 +18472,18 @@ var ts; } function bindWorker(node) { switch (node.kind) { - case 69: - case 97: + case 70: + case 98: if (currentFlow && (ts.isExpression(node) || parent.kind === 254)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 172: + case 173: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } break; - case 187: + case 188: if (ts.isInJavaScriptFile(node)) { var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { @@ -18921,30 +18508,30 @@ var ts; return checkStrictModeBinaryExpression(node); case 252: return checkStrictModeCatchClause(node); - case 181: + case 182: return checkStrictModeDeleteExpression(node); case 8: return checkStrictModeNumericLiteral(node); - case 186: + case 187: return checkStrictModePostfixUnaryExpression(node); - case 185: + case 186: return checkStrictModePrefixUnaryExpression(node); - case 212: + case 213: return checkStrictModeWithStatement(node); - case 165: + case 166: seenThisKeyword = true; return; - case 154: + case 155: return checkTypePredicate(node); - case 141: - return declareSymbolAndAddToSymbolTable(node, 262144, 530920); case 142: + return declareSymbolAndAddToSymbolTable(node, 262144, 530920); + case 143: return bindParameter(node); - case 218: - case 169: + case 219: + case 170: return bindVariableDeclarationOrBindingElement(node); + case 146: case 145: - case 144: case 266: return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 0); case 280: @@ -18957,82 +18544,82 @@ var ts; case 247: emitFlags |= 16384; return; - case 151: case 152: case 153: + case 154: return declareSymbolAndAddToSymbolTable(node, 131072, 0); - case 147: - case 146: - return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 0 : 99263); - case 220: - return bindFunctionDeclaration(node); case 148: - return declareSymbolAndAddToSymbolTable(node, 16384, 0); + case 147: + return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 0 : 99263); + case 221: + return bindFunctionDeclaration(node); case 149: - return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + return declareSymbolAndAddToSymbolTable(node, 16384, 0); case 150: + return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + case 151: return bindPropertyOrMethodOrAccessor(node, 65536, 74687); - case 156: case 157: + case 158: case 269: return bindFunctionOrConstructorType(node); - case 159: + case 160: case 281: case 265: return bindAnonymousDeclaration(node, 2048, "__type"); - case 171: + case 172: return bindObjectLiteralExpression(node); - case 179: case 180: + case 181: return bindFunctionExpression(node); - case 174: + case 175: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; - case 192: - case 221: + case 193: + case 222: inStrictMode = true; return bindClassLikeDeclaration(node); - case 222: + case 223: return bindBlockScopedDeclaration(node, 64, 792968); case 279: - case 223: - return bindBlockScopedDeclaration(node, 524288, 793064); case 224: - return bindEnumDeclaration(node); + return bindBlockScopedDeclaration(node, 524288, 793064); case 225: + return bindEnumDeclaration(node); + case 226: return bindModuleDeclaration(node); - case 229: - case 232: - case 234: - case 238: - return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); - case 228: - return bindNamespaceExportDeclaration(node); - case 231: - return bindImportClause(node); - case 236: - return bindExportDeclaration(node); + case 230: + case 233: case 235: + case 239: + return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + case 229: + return bindNamespaceExportDeclaration(node); + case 232: + return bindImportClause(node); + case 237: + return bindExportDeclaration(node); + case 236: return bindExportAssignment(node); case 256: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 199: + case 200: if (!ts.isFunctionLike(node.parent)) { return; } - case 226: + case 227: return updateStrictModeStatementList(node.statements); } } function checkTypePredicate(node) { var parameterName = node.parameterName, type = node.type; - if (parameterName && parameterName.kind === 69) { + if (parameterName && parameterName.kind === 70) { checkStrictModeIdentifier(parameterName); } - if (parameterName && parameterName.kind === 165) { + if (parameterName && parameterName.kind === 166) { seenThisKeyword = true; } bind(type); @@ -19051,7 +18638,7 @@ var ts; bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); } else { - var flags = node.kind === 235 && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 236 && ts.exportAssignmentIsAlias(node) ? 8388608 : 4; declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 | 8388608 | 32 | 16); @@ -19095,7 +18682,9 @@ var ts; function setCommonJsModuleIndicator(node) { if (!file.commonJsModuleIndicator) { file.commonJsModuleIndicator = node; - bindSourceFileAsExternalModule(); + if (!file.externalModuleIndicator) { + bindSourceFileAsExternalModule(); + } } } function bindExportsPropertyAssignment(node) { @@ -19108,11 +18697,11 @@ var ts; } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJavaScriptFile(node)); - if (container.kind === 220 || container.kind === 179) { + if (container.kind === 221 || container.kind === 180) { container.symbol.members = container.symbol.members || ts.createMap(); declareSymbol(container.symbol.members, container.symbol, node, 4, 0 & ~4); } - else if (container.kind === 148) { + else if (container.kind === 149) { var saveContainer = container; container = container.parent; var symbol = bindPropertyOrMethodOrAccessor(node, 4, 0); @@ -19152,7 +18741,7 @@ var ts; emitFlags |= 2048; } } - if (node.kind === 221) { + if (node.kind === 222) { bindBlockScopedDeclaration(node, 32, 899519); } else { @@ -19270,15 +18859,15 @@ var ts; return false; } if (currentFlow === unreachableFlow) { - var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 201) || - node.kind === 221 || - (node.kind === 225 && shouldReportErrorOnModuleDeclaration(node)) || - (node.kind === 224 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 202) || + node.kind === 222 || + (node.kind === 226 && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 225 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 200 || + (node.kind !== 201 || ts.getCombinedNodeFlags(node.declarationList) & 3 || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -19292,52 +18881,54 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 174: + case 175: return computeCallExpression(node, subtreeFlags); - case 225: + case 176: + return computeNewExpression(node, subtreeFlags); + case 226: return computeModuleDeclaration(node, subtreeFlags); - case 178: - return computeParenthesizedExpression(node, subtreeFlags); - case 187: - return computeBinaryExpression(node, subtreeFlags); - case 202: - return computeExpressionStatement(node, subtreeFlags); - case 142: - return computeParameter(node, subtreeFlags); - case 180: - return computeArrowFunction(node, subtreeFlags); case 179: + return computeParenthesizedExpression(node, subtreeFlags); + case 188: + return computeBinaryExpression(node, subtreeFlags); + case 203: + return computeExpressionStatement(node, subtreeFlags); + case 143: + return computeParameter(node, subtreeFlags); + case 181: + return computeArrowFunction(node, subtreeFlags); + case 180: return computeFunctionExpression(node, subtreeFlags); - case 220: - return computeFunctionDeclaration(node, subtreeFlags); - case 218: - return computeVariableDeclaration(node, subtreeFlags); - case 219: - return computeVariableDeclarationList(node, subtreeFlags); - case 200: - return computeVariableStatement(node, subtreeFlags); - case 214: - return computeLabeledStatement(node, subtreeFlags); case 221: + return computeFunctionDeclaration(node, subtreeFlags); + case 219: + return computeVariableDeclaration(node, subtreeFlags); + case 220: + return computeVariableDeclarationList(node, subtreeFlags); + case 201: + return computeVariableStatement(node, subtreeFlags); + case 215: + return computeLabeledStatement(node, subtreeFlags); + case 222: return computeClassDeclaration(node, subtreeFlags); - case 192: + case 193: return computeClassExpression(node, subtreeFlags); case 251: return computeHeritageClause(node, subtreeFlags); - case 194: + case 195: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 148: - return computeConstructor(node, subtreeFlags); - case 145: - return computePropertyDeclaration(node, subtreeFlags); - case 147: - return computeMethod(node, subtreeFlags); case 149: + return computeConstructor(node, subtreeFlags); + case 146: + return computePropertyDeclaration(node, subtreeFlags); + case 148: + return computeMethod(node, subtreeFlags); case 150: + case 151: return computeAccessor(node, subtreeFlags); - case 229: + case 230: return computeImportEquals(node, subtreeFlags); - case 172: + case 173: return computePropertyAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -19348,40 +18939,54 @@ var ts; var transformFlags = subtreeFlags; var expression = node.expression; var expressionKind = expression.kind; - if (subtreeFlags & 262144 + if (node.typeArguments) { + transformFlags |= 3; + } + if (subtreeFlags & 1048576 || isSuperOrSuperProperty(expression, expressionKind)) { - transformFlags |= 192; + transformFlags |= 768; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~537133909; + return transformFlags & ~537922901; } function isSuperOrSuperProperty(node, kind) { switch (kind) { - case 95: + case 96: return true; - case 172: case 173: + case 174: var expression = node.expression; var expressionKind = expression.kind; - return expressionKind === 95; + return expressionKind === 96; } return false; } + function computeNewExpression(node, subtreeFlags) { + var transformFlags = subtreeFlags; + if (node.typeArguments) { + transformFlags |= 3; + } + if (subtreeFlags & 1048576) { + transformFlags |= 768; + } + node.transformFlags = transformFlags | 536870912; + return transformFlags & ~537922901; + } function computeBinaryExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 56 - && (leftKind === 171 - || leftKind === 170)) { - transformFlags |= 192 | 256; + if (operatorTokenKind === 57 + && (leftKind === 172 + || leftKind === 171)) { + transformFlags |= 768 | 1024; } - else if (operatorTokenKind === 38 - || operatorTokenKind === 60) { - transformFlags |= 48; + else if (operatorTokenKind === 39 + || operatorTokenKind === 61) { + transformFlags |= 192; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeParameter(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -19389,35 +18994,35 @@ var ts; var name = node.name; var initializer = node.initializer; var dotDotDotToken = node.dotDotDotToken; - if (node.questionToken) { - transformFlags |= 3; - } - if (subtreeFlags & 2048 || ts.isThisIdentifier(name)) { + if (node.questionToken + || node.type + || subtreeFlags & 8192 + || ts.isThisIdentifier(name)) { transformFlags |= 3; } if (modifierFlags & 92) { - transformFlags |= 3 | 131072; + transformFlags |= 3 | 524288; } - if (subtreeFlags & 2097152 || initializer || dotDotDotToken) { - transformFlags |= 192 | 65536; + if (subtreeFlags & 8388608 || initializer || dotDotDotToken) { + transformFlags |= 768 | 262144; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~538968917; + return transformFlags & ~545262933; } function computeParenthesizedExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; var expression = node.expression; var expressionKind = expression.kind; var expressionTransformFlags = expression.transformFlags; - if (expressionKind === 195 - || expressionKind === 177) { + if (expressionKind === 196 + || expressionKind === 178) { transformFlags |= 3; } - if (expressionTransformFlags & 256) { - transformFlags |= 256; + if (expressionTransformFlags & 1024) { + transformFlags |= 1024; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeClassDeclaration(node, subtreeFlags) { var transformFlags; @@ -19426,36 +19031,38 @@ var ts; transformFlags = 3; } else { - transformFlags = subtreeFlags | 192; - if ((subtreeFlags & 137216) - || (modifierFlags & 1)) { + transformFlags = subtreeFlags | 768; + if ((subtreeFlags & 548864) + || (modifierFlags & 1) + || node.typeParameters) { transformFlags |= 3; } - if (subtreeFlags & 32768) { - transformFlags |= 8192; + if (subtreeFlags & 131072) { + transformFlags |= 32768; } } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~537590613; + return transformFlags & ~539749717; } function computeClassExpression(node, subtreeFlags) { - var transformFlags = subtreeFlags | 192; - if (subtreeFlags & 137216) { + var transformFlags = subtreeFlags | 768; + if (subtreeFlags & 548864 + || node.typeParameters) { transformFlags |= 3; } - if (subtreeFlags & 32768) { - transformFlags |= 8192; + if (subtreeFlags & 131072) { + transformFlags |= 32768; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~537590613; + return transformFlags & ~539749717; } function computeHeritageClause(node, subtreeFlags) { var transformFlags = subtreeFlags; switch (node.token) { - case 83: - transformFlags |= 192; + case 84: + transformFlags |= 768; break; - case 106: + case 107: transformFlags |= 3; break; default: @@ -19463,135 +19070,148 @@ var ts; break; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeExpressionWithTypeArguments(node, subtreeFlags) { - var transformFlags = subtreeFlags | 192; + var transformFlags = subtreeFlags | 768; if (node.typeArguments) { transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeConstructor(node, subtreeFlags) { var transformFlags = subtreeFlags; - var body = node.body; - if (body === undefined) { + if (ts.hasModifier(node, 2270) + || !node.body) { transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~550593365; + return transformFlags & ~591760725; } function computeMethod(node, subtreeFlags) { - var transformFlags = subtreeFlags | 192; - var modifierFlags = ts.getModifierFlags(node); - var body = node.body; - var typeParameters = node.typeParameters; - var asteriskToken = node.asteriskToken; - if (!body - || typeParameters - || (modifierFlags & (256 | 128)) - || (subtreeFlags & 2048)) { + var transformFlags = subtreeFlags | 768; + if (node.decorators + || ts.hasModifier(node, 2270) + || node.typeParameters + || node.type + || !node.body) { transformFlags |= 3; } - if (asteriskToken && ts.getEmitFlags(node) & 2097152) { - transformFlags |= 1536; + if (ts.hasModifier(node, 256)) { + transformFlags |= 48; + } + if (node.asteriskToken && ts.getEmitFlags(node) & 2097152) { + transformFlags |= 6144; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~550593365; + return transformFlags & ~591760725; } function computeAccessor(node, subtreeFlags) { var transformFlags = subtreeFlags; - var modifierFlags = ts.getModifierFlags(node); - var body = node.body; - if (!body - || (modifierFlags & (256 | 128)) - || (subtreeFlags & 2048)) { + if (node.decorators + || ts.hasModifier(node, 2270) + || node.type + || !node.body) { transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~550593365; + return transformFlags & ~591760725; } function computePropertyDeclaration(node, subtreeFlags) { var transformFlags = subtreeFlags | 3; if (node.initializer) { - transformFlags |= 4096; + transformFlags |= 16384; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeFunctionDeclaration(node, subtreeFlags) { var transformFlags; var modifierFlags = ts.getModifierFlags(node); var body = node.body; - var asteriskToken = node.asteriskToken; if (!body || (modifierFlags & 2)) { transformFlags = 3; } else { - transformFlags = subtreeFlags | 8388608; + transformFlags = subtreeFlags | 33554432; if (modifierFlags & 1) { - transformFlags |= 3 | 192; + transformFlags |= 3 | 768; } - if (modifierFlags & 256) { + if (modifierFlags & 2270 + || node.typeParameters + || node.type) { transformFlags |= 3; } - if (subtreeFlags & 81920) { - transformFlags |= 192; + if (modifierFlags & 256) { + transformFlags |= 48; } - if (asteriskToken && ts.getEmitFlags(node) & 2097152) { - transformFlags |= 1536; + if (subtreeFlags & 327680) { + transformFlags |= 768; + } + if (node.asteriskToken && ts.getEmitFlags(node) & 2097152) { + transformFlags |= 6144; } } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~550726485; + return transformFlags & ~592293205; } function computeFunctionExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; - var modifierFlags = ts.getModifierFlags(node); - var asteriskToken = node.asteriskToken; - if (modifierFlags & 256) { + if (ts.hasModifier(node, 2270) + || node.typeParameters + || node.type) { transformFlags |= 3; } - if (subtreeFlags & 81920) { - transformFlags |= 192; + if (ts.hasModifier(node, 256)) { + transformFlags |= 48; } - if (asteriskToken && ts.getEmitFlags(node) & 2097152) { - transformFlags |= 1536; + if (subtreeFlags & 327680) { + transformFlags |= 768; + } + if (node.asteriskToken && ts.getEmitFlags(node) & 2097152) { + transformFlags |= 6144; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~550726485; + return transformFlags & ~592293205; } function computeArrowFunction(node, subtreeFlags) { - var transformFlags = subtreeFlags | 192; - var modifierFlags = ts.getModifierFlags(node); - if (modifierFlags & 256) { + var transformFlags = subtreeFlags | 768; + if (ts.hasModifier(node, 2270) + || node.typeParameters + || node.type) { transformFlags |= 3; } - if (subtreeFlags & 8192) { - transformFlags |= 16384; + if (ts.hasModifier(node, 256)) { + transformFlags |= 48; + } + if (subtreeFlags & 32768) { + transformFlags |= 65536; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~550710101; + return transformFlags & ~592227669; } function computePropertyAccess(node, subtreeFlags) { var transformFlags = subtreeFlags; var expression = node.expression; var expressionKind = expression.kind; - if (expressionKind === 95) { - transformFlags |= 8192; + if (expressionKind === 96) { + transformFlags |= 32768; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeVariableDeclaration(node, subtreeFlags) { var transformFlags = subtreeFlags; var nameKind = node.name.kind; - if (nameKind === 167 || nameKind === 168) { - transformFlags |= 192 | 2097152; + if (nameKind === 168 || nameKind === 169) { + transformFlags |= 768 | 8388608; + } + if (node.type) { + transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeVariableStatement(node, subtreeFlags) { var transformFlags; @@ -19603,23 +19223,23 @@ var ts; else { transformFlags = subtreeFlags; if (modifierFlags & 1) { - transformFlags |= 192 | 3; + transformFlags |= 768 | 3; } - if (declarationListTransformFlags & 2097152) { - transformFlags |= 192; + if (declarationListTransformFlags & 8388608) { + transformFlags |= 768; } } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeLabeledStatement(node, subtreeFlags) { var transformFlags = subtreeFlags; - if (subtreeFlags & 1048576 + if (subtreeFlags & 4194304 && ts.isIterationStatement(node, true)) { - transformFlags |= 192; + transformFlags |= 768; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeImportEquals(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -19627,15 +19247,15 @@ var ts; transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeExpressionStatement(node, subtreeFlags) { var transformFlags = subtreeFlags; - if (node.expression.transformFlags & 256) { - transformFlags |= 192; + if (node.expression.transformFlags & 1024) { + transformFlags |= 768; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536871765; + return transformFlags & ~536874325; } function computeModuleDeclaration(node, subtreeFlags) { var transformFlags = 3; @@ -19644,77 +19264,78 @@ var ts; transformFlags |= subtreeFlags; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~546335573; + return transformFlags & ~574729557; } function computeVariableDeclarationList(node, subtreeFlags) { - var transformFlags = subtreeFlags | 8388608; - if (subtreeFlags & 2097152) { - transformFlags |= 192; + var transformFlags = subtreeFlags | 33554432; + if (subtreeFlags & 8388608) { + transformFlags |= 768; } if (node.flags & 3) { - transformFlags |= 192 | 1048576; + transformFlags |= 768 | 4194304; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~538968917; + return transformFlags & ~545262933; } function computeOther(node, kind, subtreeFlags) { var transformFlags = subtreeFlags; - var excludeFlags = 536871765; + var excludeFlags = 536874325; switch (kind) { - case 112: - case 110: + case 119: + case 185: + transformFlags |= 48; + break; + case 113: case 111: - case 115: - case 122: - case 118: - case 74: - case 184: - case 224: + case 112: + case 116: + case 123: + case 75: + case 225: case 255: - case 177: - case 195: + case 178: case 196: - case 128: + case 197: + case 129: transformFlags |= 3; break; - case 241: case 242: case 243: case 244: + case 10: case 245: case 246: case 247: case 248: transformFlags |= 12; break; - case 82: - transformFlags |= 192 | 3; + case 83: + transformFlags |= 768 | 3; break; - case 77: - case 11: + case 78: case 12: case 13: case 14: - case 189: - case 176: - case 254: - case 208: - transformFlags |= 192; - break; + case 15: case 190: - transformFlags |= 192 | 4194304; + case 177: + case 254: + case 209: + transformFlags |= 768; break; - case 117: - case 130: - case 127: - case 132: - case 120: + case 191: + transformFlags |= 768 | 16777216; + break; + case 118: + case 131: + case 128: case 133: - case 103: - case 141: - case 144: - case 146: - case 151: + case 121: + case 134: + case 104: + case 142: + case 145: + case 147: case 152: case 153: case 154: @@ -19728,68 +19349,69 @@ var ts; case 162: case 163: case 164: - case 222: - case 223: case 165: + case 223: + case 224: case 166: + case 167: transformFlags = 3; excludeFlags = -3; break; - case 140: - transformFlags |= 524288; - if (subtreeFlags & 8192) { + case 141: + transformFlags |= 2097152; + if (subtreeFlags & 32768) { + transformFlags |= 131072; + } + break; + case 192: + transformFlags |= 1048576; + break; + case 96: + transformFlags |= 768; + break; + case 98: + transformFlags |= 32768; + break; + case 168: + case 169: + transformFlags |= 768 | 8388608; + break; + case 144: + transformFlags |= 3 | 8192; + break; + case 172: + excludeFlags = 539110741; + if (subtreeFlags & 2097152) { + transformFlags |= 768; + } + if (subtreeFlags & 131072) { transformFlags |= 32768; } break; - case 191: - transformFlags |= 262144; - break; - case 95: - transformFlags |= 192; - break; - case 97: - transformFlags |= 8192; - break; - case 167: - case 168: - transformFlags |= 192 | 2097152; - break; - case 143: - transformFlags |= 3 | 2048; - break; case 171: - excludeFlags = 537430869; - if (subtreeFlags & 524288) { - transformFlags |= 192; - } - if (subtreeFlags & 32768) { - transformFlags |= 8192; + case 176: + excludeFlags = 537922901; + if (subtreeFlags & 1048576) { + transformFlags |= 768; } break; - case 170: - case 175: - excludeFlags = 537133909; - if (subtreeFlags & 262144) { - transformFlags |= 192; - } - break; - case 204: case 205: case 206: case 207: - if (subtreeFlags & 1048576) { - transformFlags |= 192; + case 208: + if (subtreeFlags & 4194304) { + transformFlags |= 768; } break; case 256: - if (subtreeFlags & 16384) { - transformFlags |= 192; + if (subtreeFlags & 65536) { + transformFlags |= 768; } break; - case 211: - case 209: + case 212: case 210: - transformFlags |= 8388608; + case 211: + transformFlags |= 33554432; break; } node.transformFlags = transformFlags | 536870912; @@ -19889,6 +19511,7 @@ var ts; var intersectionTypes = ts.createMap(); var stringLiteralTypes = ts.createMap(); var numericLiteralTypes = ts.createMap(); + var evolvingArrayTypes = []; var unknownSymbol = createSymbol(4 | 67108864, "unknown"); var resolvingSymbol = createSymbol(67108864, "__resolving__"); var anyType = createIntrinsicType(1, "any"); @@ -19932,6 +19555,7 @@ var ts; var globalBooleanType; var globalRegExpType; var anyArrayType; + var autoArrayType; var anyReadonlyArrayType; var getGlobalTemplateStringsArrayType; var getGlobalESSymbolType; @@ -19972,6 +19596,66 @@ var ts; var potentialThisCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); + var TypeFacts; + (function (TypeFacts) { + TypeFacts[TypeFacts["None"] = 0] = "None"; + TypeFacts[TypeFacts["TypeofEQString"] = 1] = "TypeofEQString"; + TypeFacts[TypeFacts["TypeofEQNumber"] = 2] = "TypeofEQNumber"; + TypeFacts[TypeFacts["TypeofEQBoolean"] = 4] = "TypeofEQBoolean"; + TypeFacts[TypeFacts["TypeofEQSymbol"] = 8] = "TypeofEQSymbol"; + TypeFacts[TypeFacts["TypeofEQObject"] = 16] = "TypeofEQObject"; + TypeFacts[TypeFacts["TypeofEQFunction"] = 32] = "TypeofEQFunction"; + TypeFacts[TypeFacts["TypeofEQHostObject"] = 64] = "TypeofEQHostObject"; + TypeFacts[TypeFacts["TypeofNEString"] = 128] = "TypeofNEString"; + TypeFacts[TypeFacts["TypeofNENumber"] = 256] = "TypeofNENumber"; + TypeFacts[TypeFacts["TypeofNEBoolean"] = 512] = "TypeofNEBoolean"; + TypeFacts[TypeFacts["TypeofNESymbol"] = 1024] = "TypeofNESymbol"; + TypeFacts[TypeFacts["TypeofNEObject"] = 2048] = "TypeofNEObject"; + TypeFacts[TypeFacts["TypeofNEFunction"] = 4096] = "TypeofNEFunction"; + TypeFacts[TypeFacts["TypeofNEHostObject"] = 8192] = "TypeofNEHostObject"; + TypeFacts[TypeFacts["EQUndefined"] = 16384] = "EQUndefined"; + TypeFacts[TypeFacts["EQNull"] = 32768] = "EQNull"; + TypeFacts[TypeFacts["EQUndefinedOrNull"] = 65536] = "EQUndefinedOrNull"; + TypeFacts[TypeFacts["NEUndefined"] = 131072] = "NEUndefined"; + TypeFacts[TypeFacts["NENull"] = 262144] = "NENull"; + TypeFacts[TypeFacts["NEUndefinedOrNull"] = 524288] = "NEUndefinedOrNull"; + TypeFacts[TypeFacts["Truthy"] = 1048576] = "Truthy"; + TypeFacts[TypeFacts["Falsy"] = 2097152] = "Falsy"; + TypeFacts[TypeFacts["Discriminatable"] = 4194304] = "Discriminatable"; + TypeFacts[TypeFacts["All"] = 8388607] = "All"; + TypeFacts[TypeFacts["BaseStringStrictFacts"] = 933633] = "BaseStringStrictFacts"; + TypeFacts[TypeFacts["BaseStringFacts"] = 3145473] = "BaseStringFacts"; + TypeFacts[TypeFacts["StringStrictFacts"] = 4079361] = "StringStrictFacts"; + TypeFacts[TypeFacts["StringFacts"] = 4194049] = "StringFacts"; + TypeFacts[TypeFacts["EmptyStringStrictFacts"] = 3030785] = "EmptyStringStrictFacts"; + TypeFacts[TypeFacts["EmptyStringFacts"] = 3145473] = "EmptyStringFacts"; + TypeFacts[TypeFacts["NonEmptyStringStrictFacts"] = 1982209] = "NonEmptyStringStrictFacts"; + TypeFacts[TypeFacts["NonEmptyStringFacts"] = 4194049] = "NonEmptyStringFacts"; + TypeFacts[TypeFacts["BaseNumberStrictFacts"] = 933506] = "BaseNumberStrictFacts"; + TypeFacts[TypeFacts["BaseNumberFacts"] = 3145346] = "BaseNumberFacts"; + TypeFacts[TypeFacts["NumberStrictFacts"] = 4079234] = "NumberStrictFacts"; + TypeFacts[TypeFacts["NumberFacts"] = 4193922] = "NumberFacts"; + TypeFacts[TypeFacts["ZeroStrictFacts"] = 3030658] = "ZeroStrictFacts"; + TypeFacts[TypeFacts["ZeroFacts"] = 3145346] = "ZeroFacts"; + TypeFacts[TypeFacts["NonZeroStrictFacts"] = 1982082] = "NonZeroStrictFacts"; + TypeFacts[TypeFacts["NonZeroFacts"] = 4193922] = "NonZeroFacts"; + TypeFacts[TypeFacts["BaseBooleanStrictFacts"] = 933252] = "BaseBooleanStrictFacts"; + TypeFacts[TypeFacts["BaseBooleanFacts"] = 3145092] = "BaseBooleanFacts"; + TypeFacts[TypeFacts["BooleanStrictFacts"] = 4078980] = "BooleanStrictFacts"; + TypeFacts[TypeFacts["BooleanFacts"] = 4193668] = "BooleanFacts"; + TypeFacts[TypeFacts["FalseStrictFacts"] = 3030404] = "FalseStrictFacts"; + TypeFacts[TypeFacts["FalseFacts"] = 3145092] = "FalseFacts"; + TypeFacts[TypeFacts["TrueStrictFacts"] = 1981828] = "TrueStrictFacts"; + TypeFacts[TypeFacts["TrueFacts"] = 4193668] = "TrueFacts"; + TypeFacts[TypeFacts["SymbolStrictFacts"] = 1981320] = "SymbolStrictFacts"; + TypeFacts[TypeFacts["SymbolFacts"] = 4193160] = "SymbolFacts"; + TypeFacts[TypeFacts["ObjectStrictFacts"] = 6166480] = "ObjectStrictFacts"; + TypeFacts[TypeFacts["ObjectFacts"] = 8378320] = "ObjectFacts"; + TypeFacts[TypeFacts["FunctionStrictFacts"] = 6164448] = "FunctionStrictFacts"; + TypeFacts[TypeFacts["FunctionFacts"] = 8376288] = "FunctionFacts"; + TypeFacts[TypeFacts["UndefinedFacts"] = 2457472] = "UndefinedFacts"; + TypeFacts[TypeFacts["NullFacts"] = 2340752] = "NullFacts"; + })(TypeFacts || (TypeFacts = {})); var typeofEQFacts = ts.createMap({ "string": 1, "number": 2, @@ -20014,6 +19698,13 @@ var ts; var identityRelation = ts.createMap(); var enumRelation = ts.createMap(); var _displayBuilder; + var TypeSystemPropertyName; + (function (TypeSystemPropertyName) { + TypeSystemPropertyName[TypeSystemPropertyName["Type"] = 0] = "Type"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseConstructorType"] = 1] = "ResolvedBaseConstructorType"; + TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; + })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); var builtinGlobals = ts.createMap(); builtinGlobals[undefinedSymbol.name] = undefinedSymbol; initializeTypeChecker(); @@ -20098,7 +19789,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 225 && source.valueDeclaration.kind !== 225))) { + (target.valueDeclaration.kind === 226 && source.valueDeclaration.kind !== 226))) { target.valueDeclaration = source.valueDeclaration; } ts.forEach(source.declarations, function (node) { @@ -20233,24 +19924,24 @@ var ts; return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); } if (declaration.pos <= usage.pos) { - return declaration.kind !== 218 || + return declaration.kind !== 219 || !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } return isUsedInFunctionOrNonStaticProperty(declaration, usage); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 200: - case 206: - case 208: + case 201: + case 207: + case 209: if (isSameScopeDescendentOf(usage, declaration, container)) { return true; } break; } switch (declaration.parent.parent.kind) { - case 207: case 208: + case 209: if (isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container)) { return true; } @@ -20268,7 +19959,7 @@ var ts; return true; } var initializerOfNonStaticProperty = current.parent && - current.parent.kind === 145 && + current.parent.kind === 146 && (ts.getModifierFlags(current.parent) & 32) === 0 && current.parent.initializer === current; if (initializerOfNonStaticProperty) { @@ -20294,15 +19985,15 @@ var ts; if (meaning & result.flags & 793064 && lastLocation.kind !== 273) { useResult = result.flags & 262144 ? lastLocation === location.type || - lastLocation.kind === 142 || - lastLocation.kind === 141 + lastLocation.kind === 143 || + lastLocation.kind === 142 : false; } if (meaning & 107455 && result.flags & 1) { useResult = - lastLocation.kind === 142 || + lastLocation.kind === 143 || (lastLocation === location.type && - result.valueDeclaration.kind === 142); + result.valueDeclaration.kind === 143); } } if (useResult) { @@ -20318,7 +20009,7 @@ var ts; if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 225: + case 226: var moduleExports = getSymbolOfNode(location).exports; if (location.kind === 256 || ts.isAmbientModule(location)) { if (result = moduleExports["default"]) { @@ -20330,7 +20021,7 @@ var ts; } if (moduleExports[name] && moduleExports[name].flags === 8388608 && - ts.getDeclarationOfKind(moduleExports[name], 238)) { + ts.getDeclarationOfKind(moduleExports[name], 239)) { break; } } @@ -20338,13 +20029,13 @@ var ts; break loop; } break; - case 224: + case 225: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; + case 146: case 145: - case 144: if (ts.isClassLike(location.parent) && !(ts.getModifierFlags(location) & 32)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { @@ -20354,9 +20045,9 @@ var ts; } } break; - case 221: - case 192: case 222: + case 193: + case 223: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793064)) { if (lastLocation && ts.getModifierFlags(lastLocation) & 32) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); @@ -20364,7 +20055,7 @@ var ts; } break loop; } - if (location.kind === 192 && meaning & 32) { + if (location.kind === 193 && meaning & 32) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -20372,28 +20063,28 @@ var ts; } } break; - case 140: + case 141: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 222) { + if (ts.isClassLike(grandparent) || grandparent.kind === 223) { if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793064)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 147: - case 146: case 148: + case 147: case 149: case 150: - case 220: - case 180: + case 151: + case 221: + case 181: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 179: + case 180: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -20406,8 +20097,8 @@ var ts; } } break; - case 143: - if (location.parent && location.parent.kind === 142) { + case 144: + if (location.parent && location.parent.kind === 143) { location = location.parent; } if (location.parent && ts.isClassElement(location.parent)) { @@ -20449,7 +20140,7 @@ var ts; } if (result && isInExternalModule && (meaning & 107455) === 107455) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 228) { + if (decls && decls.length === 1 && decls[0].kind === 229) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } @@ -20457,7 +20148,7 @@ var ts; return result; } function checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) { - if ((errorLocation.kind === 69 && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { + if ((errorLocation.kind === 70 && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { return false; } var container = ts.getThisContainer(errorLocation, true); @@ -20495,10 +20186,10 @@ var ts; } function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 69: - case 172: + case 70: + case 173: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 194: + case 195: ts.Debug.assert(ts.isEntityNameExpression(node.expression)); return node.expression; default: @@ -20519,7 +20210,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"); - if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 218), errorLocation)) { + if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 219), errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -20536,10 +20227,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 229) { + if (node.kind === 230) { return node; } - while (node && node.kind !== 230) { + while (node && node.kind !== 231) { node = node.parent; } return node; @@ -20549,10 +20240,10 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 240) { + if (node.moduleReference.kind === 241) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } - return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); + return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); } function getTargetOfImportClause(node) { var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier); @@ -20610,28 +20301,28 @@ var ts; var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); if (targetSymbol) { - var name_16 = specifier.propertyName || specifier.name; - if (name_16.text) { + var name_13 = specifier.propertyName || specifier.name; + if (name_13.text) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { return moduleSymbol; } var symbolFromVariable = void 0; if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports["export="]) { - symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name_16.text); + symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name_13.text); } else { - symbolFromVariable = getPropertyOfVariable(targetSymbol, name_16.text); + symbolFromVariable = getPropertyOfVariable(targetSymbol, name_13.text); } symbolFromVariable = resolveSymbol(symbolFromVariable); - var symbolFromModule = getExportOfModule(targetSymbol, name_16.text); - if (!symbolFromModule && allowSyntheticDefaultImports && name_16.text === "default") { + var symbolFromModule = getExportOfModule(targetSymbol, name_13.text); + if (!symbolFromModule && allowSyntheticDefaultImports && name_13.text === "default") { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol); } var symbol = symbolFromModule && symbolFromVariable ? combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : symbolFromModule || symbolFromVariable; if (!symbol) { - error(name_16, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_16)); + error(name_13, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_13)); } return symbol; } @@ -20653,19 +20344,19 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 229: + case 230: return getTargetOfImportEqualsDeclaration(node); - case 231: - return getTargetOfImportClause(node); case 232: + return getTargetOfImportClause(node); + case 233: return getTargetOfNamespaceImport(node); - case 234: - return getTargetOfImportSpecifier(node); - case 238: - return getTargetOfExportSpecifier(node); case 235: + return getTargetOfImportSpecifier(node); + case 239: + return getTargetOfExportSpecifier(node); + case 236: return getTargetOfExportAssignment(node); - case 228: + case 229: return getTargetOfNamespaceExportDeclaration(node); } } @@ -20709,10 +20400,10 @@ var ts; links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); ts.Debug.assert(!!node); - if (node.kind === 235) { + if (node.kind === 236) { checkExpressionCached(node.expression); } - else if (node.kind === 238) { + else if (node.kind === 239) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -20720,15 +20411,15 @@ var ts; } } } - function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration, dontResolveAlias) { - if (entityName.kind === 69 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, dontResolveAlias) { + if (entityName.kind === 70 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 69 || entityName.parent.kind === 139) { + if (entityName.kind === 70 || entityName.parent.kind === 140) { return resolveEntityName(entityName, 1920, false, dontResolveAlias); } else { - ts.Debug.assert(entityName.parent.kind === 229); + ts.Debug.assert(entityName.parent.kind === 230); return resolveEntityName(entityName, 107455 | 793064 | 1920, false, dontResolveAlias); } } @@ -20740,16 +20431,16 @@ var ts; return undefined; } var symbol; - if (name.kind === 69) { + if (name.kind === 70) { var message = meaning === 1920 ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; symbol = resolveName(location || name, name.text, meaning, ignoreErrors ? undefined : message, name); if (!symbol) { return undefined; } } - else if (name.kind === 139 || name.kind === 172) { - var left = name.kind === 139 ? name.left : name.expression; - var right = name.kind === 139 ? name.right : name.name; + else if (name.kind === 140 || name.kind === 173) { + var left = name.kind === 140 ? name.left : name.expression; + var right = name.kind === 140 ? name.right : name.name; var namespace = resolveEntityName(left, 1920, ignoreErrors, false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -20932,7 +20623,7 @@ var ts; var members = node.members; for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { var member = members_1[_i]; - if (member.kind === 148 && ts.nodeIsPresent(member.body)) { + if (member.kind === 149 && ts.nodeIsPresent(member.body)) { return member; } } @@ -21006,7 +20697,7 @@ var ts; if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 225: + case 226: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } @@ -21039,7 +20730,7 @@ var ts; return ts.forEachProperty(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 238)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 239)) { if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -21070,7 +20761,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 238)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 239)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -21084,10 +20775,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 145: - case 147: - case 149: + case 146: + case 148: case 150: + case 151: continue; default: return false; @@ -21109,7 +20800,7 @@ var ts; return { accessibility: 1, errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), - errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, 1920) : undefined + errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, 1920) : undefined, }; } return hasAccessibleDeclarations; @@ -21130,7 +20821,7 @@ var ts; } return { accessibility: 1, - errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning) + errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), }; } return { accessibility: 0 }; @@ -21177,11 +20868,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 158 || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + if (entityName.parent.kind === 159 || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning = 107455 | 1048576; } - else if (entityName.kind === 139 || entityName.kind === 172 || - entityName.parent.kind === 229) { + else if (entityName.kind === 140 || entityName.kind === 173 || + entityName.parent.kind === 230) { meaning = 1920; } else { @@ -21273,10 +20964,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { var node = type.symbol.declarations[0].parent; - while (node.kind === 164) { + while (node.kind === 165) { node = node.parent; } - if (node.kind === 223) { + if (node.kind === 224) { return getSymbolOfNode(node); } } @@ -21284,7 +20975,7 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 226 && + node.parent.kind === 227 && ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { @@ -21298,10 +20989,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 192: + case 193: return "(Anonymous class)"; - case 179: case 180: + case 181: return "(Anonymous function)"; } } @@ -21315,17 +21006,17 @@ var ts; var firstChar = symbolName.charCodeAt(0); var needsElementAccess = !ts.isIdentifierStart(firstChar, languageVersion); if (needsElementAccess) { - writePunctuation(writer, 19); + writePunctuation(writer, 20); if (ts.isSingleOrDoubleQuote(firstChar)) { writer.writeStringLiteral(symbolName); } else { writer.writeSymbol(symbolName, symbol); } - writePunctuation(writer, 20); + writePunctuation(writer, 21); } else { - writePunctuation(writer, 21); + writePunctuation(writer, 22); writer.writeSymbol(symbolName, symbol); } } @@ -21401,7 +21092,7 @@ var ts; } else if (type.flags & 256) { buildSymbolDisplay(getParentOfSymbol(type.symbol), writer, enclosingDeclaration, 793064, 0, nextFlags); - writePunctuation(writer, 21); + writePunctuation(writer, 22); appendSymbolNameOnly(type.symbol, writer); } else if (type.flags & (32768 | 65536 | 16 | 16384)) { @@ -21422,23 +21113,23 @@ var ts; writer.writeStringLiteral(literalTypeToString(type)); } else { - writePunctuation(writer, 15); - writeSpace(writer); - writePunctuation(writer, 22); - writeSpace(writer); writePunctuation(writer, 16); + writeSpace(writer); + writePunctuation(writer, 23); + writeSpace(writer); + writePunctuation(writer, 17); } } function writeTypeList(types, delimiter) { for (var i = 0; i < types.length; i++) { if (i > 0) { - if (delimiter !== 24) { + if (delimiter !== 25) { writeSpace(writer); } writePunctuation(writer, delimiter); writeSpace(writer); } - writeType(types[i], delimiter === 24 ? 0 : 64); + writeType(types[i], delimiter === 25 ? 0 : 64); } } function writeSymbolTypeReference(symbol, typeArguments, pos, end, flags) { @@ -21446,29 +21137,29 @@ var ts; buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793064, 0, flags); } if (pos < end) { - writePunctuation(writer, 25); + writePunctuation(writer, 26); writeType(typeArguments[pos], 256); pos++; while (pos < end) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); writeSpace(writer); writeType(typeArguments[pos], 0); pos++; } - writePunctuation(writer, 27); + writePunctuation(writer, 28); } } function writeTypeReference(type, flags) { var typeArguments = type.typeArguments || emptyArray; if (type.target === globalArrayType && !(flags & 1)) { writeType(typeArguments[0], 64); - writePunctuation(writer, 19); writePunctuation(writer, 20); + writePunctuation(writer, 21); } else if (type.target.flags & 262144) { - writePunctuation(writer, 19); - writeTypeList(type.typeArguments.slice(0, getTypeReferenceArity(type)), 24); writePunctuation(writer, 20); + writeTypeList(type.typeArguments.slice(0, getTypeReferenceArity(type)), 25); + writePunctuation(writer, 21); } else { var outerTypeParameters = type.target.outerTypeParameters; @@ -21483,7 +21174,7 @@ var ts; } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_9); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { writeSymbolTypeReference(parent_9, typeArguments, start, i, flags); - writePunctuation(writer, 21); + writePunctuation(writer, 22); } } } @@ -21493,16 +21184,16 @@ var ts; } function writeUnionOrIntersectionType(type, flags) { if (flags & 64) { - writePunctuation(writer, 17); + writePunctuation(writer, 18); } if (type.flags & 524288) { - writeTypeList(formatUnionTypes(type.types), 47); + writeTypeList(formatUnionTypes(type.types), 48); } else { - writeTypeList(type.types, 46); + writeTypeList(type.types, 47); } if (flags & 64) { - writePunctuation(writer, 18); + writePunctuation(writer, 19); } } function writeAnonymousType(type, flags) { @@ -21520,7 +21211,7 @@ var ts; buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793064, 0, flags); } else { - writeKeyword(writer, 117); + writeKeyword(writer, 118); } } else { @@ -21541,7 +21232,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 256 || declaration.parent.kind === 226; + return declaration.parent.kind === 256 || declaration.parent.kind === 227; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -21550,37 +21241,37 @@ var ts; } } function writeTypeOfSymbol(type, typeFormatFlags) { - writeKeyword(writer, 101); + writeKeyword(writer, 102); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455, 0, typeFormatFlags); } function writeIndexSignature(info, keyword) { if (info) { if (info.isReadonly) { - writeKeyword(writer, 128); + writeKeyword(writer, 129); writeSpace(writer); } - writePunctuation(writer, 19); + writePunctuation(writer, 20); writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); - writePunctuation(writer, 54); + writePunctuation(writer, 55); writeSpace(writer); writeKeyword(writer, keyword); - writePunctuation(writer, 20); - writePunctuation(writer, 54); + writePunctuation(writer, 21); + writePunctuation(writer, 55); writeSpace(writer); writeType(info.type, 0); - writePunctuation(writer, 23); + writePunctuation(writer, 24); writer.writeLine(); } } function writePropertyWithModifiers(prop) { if (isReadonlySymbol(prop)) { - writeKeyword(writer, 128); + writeKeyword(writer, 129); writeSpace(writer); } buildSymbolDisplay(prop, writer); if (prop.flags & 536870912) { - writePunctuation(writer, 53); + writePunctuation(writer, 54); } } function shouldAddParenthesisAroundFunctionType(callSignature, flags) { @@ -21598,53 +21289,53 @@ var ts; var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { - writePunctuation(writer, 15); writePunctuation(writer, 16); + writePunctuation(writer, 17); return; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var parenthesizeSignature = shouldAddParenthesisAroundFunctionType(resolved.callSignatures[0], flags); if (parenthesizeSignature) { - writePunctuation(writer, 17); + writePunctuation(writer, 18); } buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, undefined, symbolStack); if (parenthesizeSignature) { - writePunctuation(writer, 18); + writePunctuation(writer, 19); } return; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { if (flags & 64) { - writePunctuation(writer, 17); + writePunctuation(writer, 18); } - writeKeyword(writer, 92); + writeKeyword(writer, 93); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, undefined, symbolStack); if (flags & 64) { - writePunctuation(writer, 18); + writePunctuation(writer, 19); } return; } } var saveInObjectTypeLiteral = inObjectTypeLiteral; inObjectTypeLiteral = true; - writePunctuation(writer, 15); + writePunctuation(writer, 16); writer.writeLine(); writer.increaseIndent(); for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, undefined, symbolStack); - writePunctuation(writer, 23); + writePunctuation(writer, 24); writer.writeLine(); } for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, 1, symbolStack); - writePunctuation(writer, 23); + writePunctuation(writer, 24); writer.writeLine(); } - writeIndexSignature(resolved.stringIndexInfo, 132); - writeIndexSignature(resolved.numberIndexInfo, 130); + writeIndexSignature(resolved.stringIndexInfo, 133); + writeIndexSignature(resolved.numberIndexInfo, 131); for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); @@ -21654,21 +21345,21 @@ var ts; var signature = signatures_1[_f]; writePropertyWithModifiers(p); buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, undefined, symbolStack); - writePunctuation(writer, 23); + writePunctuation(writer, 24); writer.writeLine(); } } else { writePropertyWithModifiers(p); - writePunctuation(writer, 54); + writePunctuation(writer, 55); writeSpace(writer); writeType(t, 0); - writePunctuation(writer, 23); + writePunctuation(writer, 24); writer.writeLine(); } } writer.decreaseIndent(); - writePunctuation(writer, 16); + writePunctuation(writer, 17); inObjectTypeLiteral = saveInObjectTypeLiteral; } } @@ -21683,7 +21374,7 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 83); + writeKeyword(writer, 84); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } @@ -21691,7 +21382,7 @@ var ts; function buildParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack) { var parameterNode = p.valueDeclaration; if (ts.isRestParameter(parameterNode)) { - writePunctuation(writer, 22); + writePunctuation(writer, 23); } if (ts.isBindingPattern(parameterNode.name)) { buildBindingPatternDisplay(parameterNode.name, writer, enclosingDeclaration, flags, symbolStack); @@ -21700,36 +21391,36 @@ var ts; appendSymbolNameOnly(p, writer); } if (isOptionalParameter(parameterNode)) { - writePunctuation(writer, 53); + writePunctuation(writer, 54); } - writePunctuation(writer, 54); + writePunctuation(writer, 55); writeSpace(writer); buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); } function buildBindingPatternDisplay(bindingPattern, writer, enclosingDeclaration, flags, symbolStack) { - if (bindingPattern.kind === 167) { - writePunctuation(writer, 15); - buildDisplayForCommaSeparatedList(bindingPattern.elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); + if (bindingPattern.kind === 168) { writePunctuation(writer, 16); + buildDisplayForCommaSeparatedList(bindingPattern.elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); + writePunctuation(writer, 17); } - else if (bindingPattern.kind === 168) { - writePunctuation(writer, 19); + else if (bindingPattern.kind === 169) { + writePunctuation(writer, 20); var elements = bindingPattern.elements; buildDisplayForCommaSeparatedList(elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); if (elements && elements.hasTrailingComma) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); } - writePunctuation(writer, 20); + writePunctuation(writer, 21); } } function buildBindingElementDisplay(bindingElement, writer, enclosingDeclaration, flags, symbolStack) { if (ts.isOmittedExpression(bindingElement)) { return; } - ts.Debug.assert(bindingElement.kind === 169); + ts.Debug.assert(bindingElement.kind === 170); if (bindingElement.propertyName) { writer.writeSymbol(ts.getTextOfNode(bindingElement.propertyName), bindingElement.symbol); - writePunctuation(writer, 54); + writePunctuation(writer, 55); writeSpace(writer); } if (ts.isBindingPattern(bindingElement.name)) { @@ -21737,75 +21428,75 @@ var ts; } else { if (bindingElement.dotDotDotToken) { - writePunctuation(writer, 22); + writePunctuation(writer, 23); } appendSymbolNameOnly(bindingElement.symbol, writer); } } function buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, flags, symbolStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 25); + writePunctuation(writer, 26); buildDisplayForCommaSeparatedList(typeParameters, writer, function (p) { return buildTypeParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack); }); - writePunctuation(writer, 27); + writePunctuation(writer, 28); } } function buildDisplayForCommaSeparatedList(list, writer, action) { for (var i = 0; i < list.length; i++) { if (i > 0) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); writeSpace(writer); } action(list[i]); } } - function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration, flags, symbolStack) { + function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 25); - var flags_1 = 256; + writePunctuation(writer, 26); + var flags = 256; for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); writeSpace(writer); - flags_1 = 0; + flags = 0; } - buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, flags_1); + buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, flags); } - writePunctuation(writer, 27); + writePunctuation(writer, 28); } } function buildDisplayForParametersAndDelimiters(thisParameter, parameters, writer, enclosingDeclaration, flags, symbolStack) { - writePunctuation(writer, 17); + writePunctuation(writer, 18); if (thisParameter) { buildParameterDisplay(thisParameter, writer, enclosingDeclaration, flags, symbolStack); } for (var i = 0; i < parameters.length; i++) { if (i > 0 || thisParameter) { - writePunctuation(writer, 24); + writePunctuation(writer, 25); writeSpace(writer); } buildParameterDisplay(parameters[i], writer, enclosingDeclaration, flags, symbolStack); } - writePunctuation(writer, 18); + writePunctuation(writer, 19); } function buildTypePredicateDisplay(predicate, writer, enclosingDeclaration, flags, symbolStack) { if (ts.isIdentifierTypePredicate(predicate)) { writer.writeParameter(predicate.parameterName); } else { - writeKeyword(writer, 97); + writeKeyword(writer, 98); } writeSpace(writer); - writeKeyword(writer, 124); + writeKeyword(writer, 125); writeSpace(writer); buildTypeDisplay(predicate.type, writer, enclosingDeclaration, flags, symbolStack); } function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { if (flags & 8) { writeSpace(writer); - writePunctuation(writer, 34); + writePunctuation(writer, 35); } else { - writePunctuation(writer, 54); + writePunctuation(writer, 55); } writeSpace(writer); if (signature.typePredicate) { @@ -21818,7 +21509,7 @@ var ts; } function buildSignatureDisplay(signature, writer, enclosingDeclaration, flags, kind, symbolStack) { if (kind === 1) { - writeKeyword(writer, 92); + writeKeyword(writer, 93); writeSpace(writer); } if (signature.target && (flags & 32)) { @@ -21854,64 +21545,64 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 169: + case 170: return isDeclarationVisible(node.parent.parent); - case 218: + case 219: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 225: - case 221: + case 226: case 222: case 223: - case 220: case 224: - case 229: + case 221: + case 225: + case 230: if (ts.isExternalModuleAugmentation(node)) { return true; } var parent_10 = getDeclarationContainer(node); if (!(ts.getCombinedModifierFlags(node) & 1) && - !(node.kind !== 229 && parent_10.kind !== 256 && ts.isInAmbientContext(parent_10))) { + !(node.kind !== 230 && parent_10.kind !== 256 && ts.isInAmbientContext(parent_10))) { return isGlobalSourceFile(parent_10); } return isDeclarationVisible(parent_10); - case 145: - case 144: - case 149: - case 150: - case 147: case 146: + case 145: + case 150: + case 151: + case 148: + case 147: if (ts.getModifierFlags(node) & (8 | 16)) { return false; } - case 148: - case 152: - case 151: + case 149: case 153: - case 142: - case 226: - case 156: + case 152: + case 154: + case 143: + case 227: case 157: - case 159: - case 155: + case 158: case 160: + case 156: case 161: case 162: case 163: case 164: + case 165: return isDeclarationVisible(node.parent); - case 231: case 232: - case 234: - return false; - case 141: - case 256: - case 228: - return true; + case 233: case 235: return false; + case 142: + case 256: + case 229: + return true; + case 236: + return false; default: return false; } @@ -21919,10 +21610,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 235) { + if (node.parent && node.parent.kind === 236) { exportSymbol = resolveName(node.parent, node.text, 107455 | 793064 | 1920 | 8388608, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 238) { + else if (node.parent.kind === 239) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -22001,12 +21692,12 @@ var ts; node = ts.getRootDeclaration(node); while (node) { switch (node.kind) { - case 218: case 219: + case 220: + case 235: case 234: case 233: case 232: - case 231: node = node.parent; break; default: @@ -22034,12 +21725,12 @@ var ts; } function getTextOfPropertyName(name) { switch (name.kind) { - case 69: + case 70: return name.text; case 9: case 8: return name.text; - case 140: + case 141: if (ts.isStringOrNumericLiteral(name.expression.kind)) { return name.expression.text; } @@ -22047,7 +21738,7 @@ var ts; return undefined; } function isComputedNonLiteralName(name) { - return name.kind === 140 && !ts.isStringOrNumericLiteral(name.expression.kind); + return name.kind === 141 && !ts.isStringOrNumericLiteral(name.expression.kind); } function getTypeForBindingElement(declaration) { var pattern = declaration.parent; @@ -22062,20 +21753,20 @@ var ts; return parentType; } var type; - if (pattern.kind === 167) { - var name_17 = declaration.propertyName || declaration.name; - if (isComputedNonLiteralName(name_17)) { + if (pattern.kind === 168) { + var name_14 = declaration.propertyName || declaration.name; + if (isComputedNonLiteralName(name_14)) { return anyType; } if (declaration.initializer) { getContextualType(declaration.initializer); } - var text = getTextOfPropertyName(name_17); + var text = getTextOfPropertyName(name_14); type = getTypeOfPropertyOfType(parentType, text) || isNumericLiteralName(text) && getIndexTypeOfType(parentType, 1) || getIndexTypeOfType(parentType, 0); if (!type) { - error(name_17, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_17)); + error(name_14, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_14)); return unknownType; } } @@ -22118,15 +21809,15 @@ var ts; if (typeTag && typeTag.typeExpression) { return typeTag.typeExpression.type; } - if (declaration.kind === 218 && - declaration.parent.kind === 219 && - declaration.parent.parent.kind === 200) { + if (declaration.kind === 219 && + declaration.parent.kind === 220 && + declaration.parent.parent.kind === 201) { var annotation = ts.getJSDocTypeTag(declaration.parent.parent); if (annotation && annotation.typeExpression) { return annotation.typeExpression.type; } } - else if (declaration.kind === 142) { + else if (declaration.kind === 143) { var paramTag = ts.getCorrespondingJSDocParameterTag(declaration); if (paramTag && paramTag.typeExpression) { return paramTag.typeExpression.type; @@ -22134,9 +21825,13 @@ var ts; } return undefined; } - function isAutoVariableInitializer(initializer) { - var expr = initializer && ts.skipParentheses(initializer); - return !expr || expr.kind === 93 || expr.kind === 69 && getResolvedSymbol(expr) === undefinedSymbol; + function isNullOrUndefined(node) { + var expr = ts.skipParentheses(node); + return expr.kind === 94 || expr.kind === 70 && getResolvedSymbol(expr) === undefinedSymbol; + } + function isEmptyArrayLiteral(node) { + var expr = ts.skipParentheses(node); + return expr.kind === 171 && expr.elements.length === 0; } function addOptionality(type, optional) { return strictNullChecks && optional ? includeFalsyTypes(type, 2048) : type; @@ -22148,10 +21843,10 @@ var ts; return type; } } - if (declaration.parent.parent.kind === 207) { + if (declaration.parent.parent.kind === 208) { return stringType; } - if (declaration.parent.parent.kind === 208) { + if (declaration.parent.parent.kind === 209) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -22160,15 +21855,19 @@ var ts; if (declaration.type) { return addOptionality(getTypeFromTypeNode(declaration.type), declaration.questionToken && includeOptionality); } - if (declaration.kind === 218 && !ts.isBindingPattern(declaration.name) && - !(ts.getCombinedNodeFlags(declaration) & 2) && !(ts.getCombinedModifierFlags(declaration) & 1) && - !ts.isInAmbientContext(declaration) && isAutoVariableInitializer(declaration.initializer)) { - return autoType; + if (declaration.kind === 219 && !ts.isBindingPattern(declaration.name) && + !(ts.getCombinedModifierFlags(declaration) & 1) && !ts.isInAmbientContext(declaration)) { + if (!(ts.getCombinedNodeFlags(declaration) & 2) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { + return autoType; + } + if (declaration.initializer && isEmptyArrayLiteral(declaration.initializer)) { + return autoArrayType; + } } - if (declaration.kind === 142) { + if (declaration.kind === 143) { var func = declaration.parent; - if (func.kind === 150 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 149); + if (func.kind === 151 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 150); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -22181,8 +21880,7 @@ var ts; } var type = void 0; if (declaration.symbol.name === "this") { - var thisParameter = getContextualThisParameter(func); - type = thisParameter ? getTypeOfSymbol(thisParameter) : undefined; + type = getContextualThisParameterType(func); } else { type = getContextuallyTypedParameterType(declaration); @@ -22255,7 +21953,7 @@ var ts; return result; } function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { - return pattern.kind === 167 + return pattern.kind === 168 ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -22280,7 +21978,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 142 ? root.parent : root; + var memberDeclaration = root.kind === 143 ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function getTypeOfVariableOrParameterOrProperty(symbol) { @@ -22293,7 +21991,7 @@ var ts; if (declaration.parent.kind === 252) { return links.type = anyType; } - if (declaration.kind === 235) { + if (declaration.kind === 236) { return links.type = checkExpression(declaration.expression); } if (declaration.flags & 1048576 && declaration.kind === 280 && declaration.typeExpression) { @@ -22303,15 +22001,15 @@ var ts; return unknownType; } var type = void 0; - if (declaration.kind === 187 || - declaration.kind === 172 && declaration.parent.kind === 187) { + if (declaration.kind === 188 || + declaration.kind === 173 && declaration.parent.kind === 188) { if (declaration.flags & 1048576) { var typeTag = ts.getJSDocTypeTag(declaration.parent); if (typeTag && typeTag.typeExpression) { return links.type = getTypeFromTypeNode(typeTag.typeExpression.type); } } - var declaredTypes = ts.map(symbol.declarations, function (decl) { return decl.kind === 187 ? + var declaredTypes = ts.map(symbol.declarations, function (decl) { return decl.kind === 188 ? checkExpressionCached(decl.right) : checkExpressionCached(decl.parent.right); }); type = getUnionType(declaredTypes, true); @@ -22337,7 +22035,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 149) { + if (accessor.kind === 150) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -22357,8 +22055,8 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - var getter = ts.getDeclarationOfKind(symbol, 149); - var setter = ts.getDeclarationOfKind(symbol, 150); + var getter = ts.getDeclarationOfKind(symbol, 150); + var setter = ts.getDeclarationOfKind(symbol, 151); if (getter && getter.flags & 1048576) { var jsDocType = getTypeForVariableLikeDeclarationFromJSDocComment(getter); if (jsDocType) { @@ -22399,7 +22097,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 149); + var getter_1 = ts.getDeclarationOfKind(symbol, 150); 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)); } } @@ -22410,7 +22108,7 @@ var ts; function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (symbol.valueDeclaration.kind === 225 && ts.isShorthandAmbientModuleSymbol(symbol)) { + if (symbol.valueDeclaration.kind === 226 && ts.isShorthandAmbientModuleSymbol(symbol)) { links.type = anyType; } else { @@ -22495,9 +22193,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 221 || node.kind === 192 || - node.kind === 220 || node.kind === 179 || - node.kind === 147 || node.kind === 180) { + if (node.kind === 222 || node.kind === 193 || + node.kind === 221 || node.kind === 180 || + node.kind === 148 || node.kind === 181) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -22506,15 +22204,15 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 222); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 223); 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 === 222 || node.kind === 221 || - node.kind === 192 || node.kind === 223) { + if (node.kind === 223 || node.kind === 222 || + node.kind === 193 || node.kind === 224) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -22640,7 +22338,7 @@ var ts; type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 222 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 223 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -22669,7 +22367,7 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 222) { + if (declaration.kind === 223) { if (declaration.flags & 64) { return false; } @@ -22731,7 +22429,7 @@ var ts; } } else { - declaration = ts.getDeclarationOfKind(symbol, 223); + declaration = ts.getDeclarationOfKind(symbol, 224); type = getTypeFromTypeNode(declaration.type, symbol, typeParameters); } if (popTypeResolution()) { @@ -22755,14 +22453,14 @@ var ts; return !ts.isInAmbientContext(member); } return expr.kind === 8 || - expr.kind === 185 && expr.operator === 36 && + expr.kind === 186 && expr.operator === 37 && expr.operand.kind === 8 || - expr.kind === 69 && !!symbol.exports[expr.text]; + expr.kind === 70 && !!symbol.exports[expr.text]; } function enumHasLiteralMembers(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 224) { + if (declaration.kind === 225) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (!isLiteralEnumMember(symbol, member)) { @@ -22790,7 +22488,7 @@ var ts; var memberTypes = ts.createMap(); for (var _i = 0, _a = enumType.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 224) { + if (declaration.kind === 225) { computeEnumMemberValues(declaration); for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; @@ -22828,7 +22526,7 @@ var ts; if (!links.declaredType) { var type = createType(16384); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 141).constraint) { + if (!ts.getDeclarationOfKind(symbol, 142).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -22877,20 +22575,20 @@ var ts; } function isIndependentType(node) { switch (node.kind) { - case 117: - case 132: - case 130: - case 120: + case 118: case 133: - case 103: - case 135: - case 93: - case 127: - case 166: + case 131: + case 121: + case 134: + case 104: + case 136: + case 94: + case 128: + case 167: return true; - case 160: + case 161: return isIndependentType(node.elementType); - case 155: + case 156: return isIndependentTypeReference(node); } return false; @@ -22899,7 +22597,7 @@ var ts; return node.type && isIndependentType(node.type) || !node.type && !node.initializer; } function isIndependentFunctionLikeDeclaration(node) { - if (node.kind !== 148 && (!node.type || !isIndependentType(node.type))) { + if (node.kind !== 149 && (!node.type || !isIndependentType(node.type))) { return false; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { @@ -22915,12 +22613,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 145: - case 144: - return isIndependentVariableLikeDeclaration(declaration); - case 147: case 146: + case 145: + return isIndependentVariableLikeDeclaration(declaration); case 148: + case 147: + case 149: return isIndependentFunctionLikeDeclaration(declaration); } } @@ -23486,7 +23184,7 @@ var ts; return false; } function createTypePredicateFromTypePredicateNode(node) { - if (node.parameterName.kind === 69) { + if (node.parameterName.kind === 70) { var parameterName = node.parameterName; return { kind: 1, @@ -23525,7 +23223,7 @@ var ts; else { parameters.push(paramSymbol); } - if (param.type && param.type.kind === 166) { + if (param.type && param.type.kind === 167) { hasLiteralTypes = true; } if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) { @@ -23537,10 +23235,10 @@ var ts; minArgumentCount = -1; } } - if ((declaration.kind === 149 || declaration.kind === 150) && + if ((declaration.kind === 150 || declaration.kind === 151) && !ts.hasDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 149 ? 150 : 149; + var otherKind = declaration.kind === 150 ? 151 : 150; var other = ts.getDeclarationOfKind(declaration.symbol, otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); @@ -23552,24 +23250,21 @@ var ts; if (isJSConstructSignature) { minArgumentCount--; } - if (!thisParameter && ts.isObjectLiteralMethod(declaration)) { - thisParameter = getContextualThisParameter(declaration); - } - var classType = declaration.kind === 148 ? + var classType = declaration.kind === 149 ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : getTypeParametersFromJSDocTemplate(declaration); - var returnType = getSignatureReturnTypeFromDeclaration(declaration, minArgumentCount, isJSConstructSignature, classType); - var typePredicate = declaration.type && declaration.type.kind === 154 ? + var returnType = getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType); + var typePredicate = declaration.type && declaration.type.kind === 155 ? createTypePredicateFromTypePredicateNode(declaration.type) : undefined; links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasLiteralTypes); } return links.resolvedSignature; } - function getSignatureReturnTypeFromDeclaration(declaration, minArgumentCount, isJSConstructSignature, classType) { + function getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType) { if (isJSConstructSignature) { return getTypeFromTypeNode(declaration.parameters[0].type); } @@ -23585,8 +23280,8 @@ var ts; return type; } } - if (declaration.kind === 149 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 150); + if (declaration.kind === 150 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 151); return getAnnotatedAccessorType(setter); } if (ts.nodeIsMissing(declaration.body)) { @@ -23600,19 +23295,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 156: case 157: - case 220: - case 147: - case 146: + case 158: + case 221: case 148: - case 151: + case 147: + case 149: case 152: case 153: - case 149: + case 154: case 150: - case 179: + case 151: case 180: + case 181: case 269: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; @@ -23693,7 +23388,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 148 || signature.declaration.kind === 152; + var isConstructor = signature.declaration.kind === 149 || signature.declaration.kind === 153; var type = createObjectType(2097152); type.members = emptySymbols; type.properties = emptyArray; @@ -23707,7 +23402,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 130 : 132; + var syntaxKind = kind === 1 ? 131 : 133; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -23734,7 +23429,7 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - return ts.getDeclarationOfKind(type.symbol, 141).constraint; + return ts.getDeclarationOfKind(type.symbol, 142).constraint; } function hasConstraintReferenceTo(type, target) { var checked; @@ -23767,7 +23462,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 141).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 142).parent); } function getTypeListId(types) { var result = ""; @@ -23867,11 +23562,11 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 155: + case 156: return node.typeName; case 267: return node.name; - case 194: + case 195: var expr = node.expression; if (ts.isEntityNameExpression(expr)) { return expr; @@ -23879,7 +23574,7 @@ var ts; } return undefined; } - function resolveTypeReferenceName(node, typeReferenceName) { + function resolveTypeReferenceName(typeReferenceName) { if (!typeReferenceName) { return unknownSymbol; } @@ -23907,11 +23602,11 @@ var ts; var type = void 0; if (node.kind === 267) { var typeReferenceName = getTypeReferenceName(node); - symbol = resolveTypeReferenceName(node, typeReferenceName); + symbol = resolveTypeReferenceName(typeReferenceName); type = getTypeReferenceType(node, symbol); } else { - var typeNameOrExpression = node.kind === 155 + var typeNameOrExpression = node.kind === 156 ? node.typeName : ts.isEntityNameExpression(node.expression) ? node.expression @@ -23940,9 +23635,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 221: case 222: - case 224: + case 223: + case 225: return declaration; } } @@ -24317,9 +24012,9 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 222)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 223)) { if (!(ts.getModifierFlags(container) & 32) && - (container.kind !== 148 || ts.isNodeDescendantOf(node, container.body))) { + (container.kind !== 149 || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -24338,25 +24033,25 @@ var ts; } function getTypeFromTypeNode(node, aliasSymbol, aliasTypeArguments) { switch (node.kind) { - case 117: + case 118: case 258: case 259: return anyType; - case 132: - return stringType; - case 130: - return numberType; - case 120: - return booleanType; case 133: + return stringType; + case 131: + return numberType; + case 121: + return booleanType; + case 134: return esSymbolType; - case 103: + case 104: return voidType; - case 135: + case 136: return undefinedType; - case 93: + case 94: return nullType; - case 127: + case 128: return neverType; case 283: return nullType; @@ -24364,33 +24059,33 @@ var ts; return undefinedType; case 285: return neverType; - case 165: - case 97: - return getTypeFromThisTypeNode(node); case 166: + case 98: + return getTypeFromThisTypeNode(node); + case 167: return getTypeFromLiteralTypeNode(node); case 282: return getTypeFromLiteralTypeNode(node.literal); - case 155: + case 156: case 267: return getTypeFromTypeReference(node); - case 154: + case 155: return booleanType; - case 194: + case 195: return getTypeFromTypeReference(node); - case 158: + case 159: return getTypeFromTypeQueryNode(node); - case 160: + case 161: case 260: return getTypeFromArrayTypeNode(node); - case 161: - return getTypeFromTupleTypeNode(node); case 162: + return getTypeFromTupleTypeNode(node); + case 163: case 261: return getTypeFromUnionTypeNode(node, aliasSymbol, aliasTypeArguments); - case 163: - return getTypeFromIntersectionTypeNode(node, aliasSymbol, aliasTypeArguments); case 164: + return getTypeFromIntersectionTypeNode(node, aliasSymbol, aliasTypeArguments); + case 165: case 263: case 264: case 271: @@ -24399,14 +24094,14 @@ var ts; return getTypeFromTypeNode(node.type); case 265: return getTypeFromTypeNode(node.literal); - case 156: case 157: - case 159: + case 158: + case 160: case 281: case 269: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node, aliasSymbol, aliasTypeArguments); - case 69: - case 139: + case 70: + case 140: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); case 262: @@ -24562,23 +24257,23 @@ var ts; var node = symbol.declarations[0].parent; while (node) { switch (node.kind) { - case 156: case 157: - case 220: - case 147: - case 146: + case 158: + case 221: case 148: - case 151: + case 147: + case 149: case 152: case 153: - case 149: + case 154: case 150: - case 179: + case 151: case 180: - case 221: - case 192: + case 181: case 222: + case 193: case 223: + case 224: var declaration = node; if (declaration.typeParameters) { for (var _i = 0, _a = declaration.typeParameters; _i < _a.length; _i++) { @@ -24588,14 +24283,14 @@ var ts; } } } - if (ts.isClassLike(node) || node.kind === 222) { + if (ts.isClassLike(node) || node.kind === 223) { var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; if (thisType && ts.contains(mappedTypes, thisType)) { return true; } } break; - case 225: + case 226: case 256: return false; } @@ -24630,35 +24325,43 @@ var ts; return info && createIndexInfo(instantiateType(info.type, mapper), info.isReadonly, info.declaration); } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 147 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 148 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 179: case 180: + case 181: return isContextSensitiveFunctionLikeDeclaration(node); - case 171: + case 172: return ts.forEach(node.properties, isContextSensitive); - case 170: + case 171: return ts.forEach(node.elements, isContextSensitive); - case 188: + case 189: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 187: - return node.operatorToken.kind === 52 && + case 188: + return node.operatorToken.kind === 53 && (isContextSensitive(node.left) || isContextSensitive(node.right)); case 253: return isContextSensitive(node.initializer); + case 148: case 147: - case 146: return isContextSensitiveFunctionLikeDeclaration(node); - case 178: + case 179: return isContextSensitive(node.expression); } return false; } function isContextSensitiveFunctionLikeDeclaration(node) { - var areAllParametersUntyped = !ts.forEach(node.parameters, function (p) { return p.type; }); - var isNullaryArrow = node.kind === 180 && !node.parameters.length; - return !node.typeParameters && areAllParametersUntyped && !isNullaryArrow; + if (node.typeParameters) { + return false; + } + if (ts.forEach(node.parameters, function (p) { return !p.type; })) { + return true; + } + if (node.kind === 181) { + return false; + } + var parameter = ts.firstOrUndefined(node.parameters); + return !(parameter && ts.parameterIsThisKeyword(parameter)); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func); @@ -25078,8 +24781,8 @@ var ts; } if (source.flags & 524288 && target.flags & 524288 || source.flags & 1048576 && target.flags & 1048576) { - if (result = eachTypeRelatedToSomeType(source, target, false)) { - if (result &= eachTypeRelatedToSomeType(target, source, false)) { + if (result = eachTypeRelatedToSomeType(source, target)) { + if (result &= eachTypeRelatedToSomeType(target, source)) { return result; } } @@ -25130,7 +24833,7 @@ var ts; } return false; } - function eachTypeRelatedToSomeType(source, target, reportErrors) { + function eachTypeRelatedToSomeType(source, target) { var result = -1; var sourceTypes = source.types; for (var _i = 0, sourceTypes_1 = sourceTypes; _i < sourceTypes_1.length; _i++) { @@ -25727,7 +25430,7 @@ var ts; type.flags & 64 ? numberType : type.flags & 128 ? booleanType : type.flags & 256 ? type.baseType : - type.flags & 524288 && !(type.flags & 16) ? getUnionType(ts.map(type.types, getBaseTypeOfLiteralType)) : + type.flags & 524288 && !(type.flags & 16) ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) : type; } function getWidenedLiteralType(type) { @@ -25735,7 +25438,7 @@ var ts; type.flags & 64 && type.flags & 16777216 ? numberType : type.flags & 128 ? booleanType : type.flags & 256 ? type.baseType : - type.flags & 524288 && !(type.flags & 16) ? getUnionType(ts.map(type.types, getWidenedLiteralType)) : + type.flags & 524288 && !(type.flags & 16) ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) : type; } function isTupleType(type) { @@ -25846,10 +25549,10 @@ var ts; return getWidenedTypeOfObjectLiteral(type); } if (type.flags & 524288) { - return getUnionType(ts.map(type.types, getWidenedConstituentType)); + return getUnionType(ts.sameMap(type.types, getWidenedConstituentType)); } if (isArrayType(type) || isTupleType(type)) { - return createTypeReference(type.target, ts.map(type.typeArguments, getWidenedType)); + return createTypeReference(type.target, ts.sameMap(type.typeArguments, getWidenedType)); } } return type; @@ -25890,25 +25593,25 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { + case 146: case 145: - case 144: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 142: + case 143: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 169: + case 170: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 220: + case 221: + case 148: case 147: - case 146: - case 149: case 150: - case 179: + case 151: case 180: + case 181: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -25953,7 +25656,7 @@ var ts; signature: signature, inferUnionTypes: inferUnionTypes, inferences: inferences, - inferredTypes: new Array(signature.typeParameters.length) + inferredTypes: new Array(signature.typeParameters.length), }; } function createTypeInferencesObject() { @@ -25961,7 +25664,7 @@ var ts; primary: undefined, secondary: undefined, topLevel: true, - isFixed: false + isFixed: false, }; } function couldContainTypeParameters(type) { @@ -26202,7 +25905,7 @@ var ts; var widenLiteralTypes = context.inferences[index].topLevel && !hasPrimitiveConstraint(signature.typeParameters[index]) && (context.inferences[index].isFixed || !isTypeParameterAtTopLevel(getReturnTypeOfSignature(signature), signature.typeParameters[index])); - var baseInferences = widenLiteralTypes ? ts.map(inferences, getWidenedLiteralType) : inferences; + var baseInferences = widenLiteralTypes ? ts.sameMap(inferences, getWidenedLiteralType) : inferences; var unionOrSuperType = context.inferUnionTypes ? getUnionType(baseInferences, true) : getCommonSupertype(baseInferences); inferredType = unionOrSuperType ? getWidenedType(unionOrSuperType) : unknownType; inferenceSucceeded = !!unionOrSuperType; @@ -26243,10 +25946,10 @@ var ts; function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 158: + case 159: return true; - case 69: - case 139: + case 70: + case 140: node = node.parent; continue; default: @@ -26256,14 +25959,14 @@ var ts; ts.Debug.fail("should not get here"); } function getFlowCacheKey(node) { - if (node.kind === 69) { + if (node.kind === 70) { var symbol = getResolvedSymbol(node); return symbol !== unknownSymbol ? "" + getSymbolId(symbol) : undefined; } - if (node.kind === 97) { + if (node.kind === 98) { return "0"; } - if (node.kind === 172) { + if (node.kind === 173) { var key = getFlowCacheKey(node.expression); return key && key + "." + node.name.text; } @@ -26271,31 +25974,31 @@ var ts; } function getLeftmostIdentifierOrThis(node) { switch (node.kind) { - case 69: - case 97: + case 70: + case 98: return node; - case 172: + case 173: return getLeftmostIdentifierOrThis(node.expression); } return undefined; } function isMatchingReference(source, target) { switch (source.kind) { - case 69: - return target.kind === 69 && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 218 || target.kind === 169) && + case 70: + return target.kind === 70 && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 219 || target.kind === 170) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 97: - return target.kind === 97; - case 172: - return target.kind === 172 && + case 98: + return target.kind === 98; + case 173: + return target.kind === 173 && source.name.text === target.name.text && isMatchingReference(source.expression, target.expression); } return false; } function containsMatchingReference(source, target) { - while (source.kind === 172) { + while (source.kind === 173) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -26304,15 +26007,15 @@ var ts; return false; } function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 172 && + return target.kind === 173 && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.text); } function getDeclaredTypeOfReference(expr) { - if (expr.kind === 69) { + if (expr.kind === 70) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 172) { + if (expr.kind === 173) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.text); } @@ -26342,7 +26045,7 @@ var ts; } } } - if (callExpression.expression.kind === 172 && + if (callExpression.expression.kind === 173 && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -26468,7 +26171,7 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, undefined, false) || unknownType); } function getAssignedTypeOfBinaryExpression(node) { - return node.parent.kind === 170 || node.parent.kind === 253 ? + return node.parent.kind === 171 || node.parent.kind === 253 ? getTypeWithDefault(getAssignedType(node), node.right) : checkExpression(node.right); } @@ -26487,17 +26190,17 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 207: - return stringType; case 208: + return stringType; + case 209: return checkRightHandSideOfForOf(parent.expression) || unknownType; - case 187: + case 188: return getAssignedTypeOfBinaryExpression(parent); - case 181: + case 182: return undefinedType; - case 170: + case 171: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 191: + case 192: return getAssignedTypeOfSpreadElement(parent); case 253: return getAssignedTypeOfPropertyAssignment(parent); @@ -26509,7 +26212,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 167 ? + var type = pattern.kind === 168 ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, ts.indexOf(pattern.elements, node)) : @@ -26524,38 +26227,51 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 207) { + if (node.parent.parent.kind === 208) { return stringType; } - if (node.parent.parent.kind === 208) { + if (node.parent.parent.kind === 209) { return checkRightHandSideOfForOf(node.parent.parent.expression) || unknownType; } return unknownType; } function getInitialType(node) { - return node.kind === 218 ? + return node.kind === 219 ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 218 || node.kind === 169 ? + return node.kind === 219 || node.kind === 170 ? getInitialType(node) : getAssignedType(node); } + function isEmptyArrayAssignment(node) { + return node.kind === 219 && node.initializer && + isEmptyArrayLiteral(node.initializer) || + node.kind !== 170 && node.parent.kind === 188 && + isEmptyArrayLiteral(node.parent.right); + } function getReferenceCandidate(node) { switch (node.kind) { - case 178: + case 179: return getReferenceCandidate(node.expression); - case 187: + case 188: switch (node.operatorToken.kind) { - case 56: + case 57: return getReferenceCandidate(node.left); - case 24: + case 25: return getReferenceCandidate(node.right); } } return node; } + function getReferenceRoot(node) { + var parent = node.parent; + return parent.kind === 179 || + parent.kind === 188 && parent.operatorToken.kind === 57 && parent.left === node || + parent.kind === 188 && parent.operatorToken.kind === 25 && parent.right === node ? + getReferenceRoot(parent) : node; + } function getTypeOfSwitchClause(clause) { if (clause.kind === 249) { var caseType = getRegularTypeOfLiteralType(checkExpression(clause.expression)); @@ -26626,24 +26342,88 @@ var ts; function createFlowType(type, incomplete) { return incomplete ? { flags: 0, type: type } : type; } + function createEvolvingArrayType(elementType) { + var result = createObjectType(2097152); + result.elementType = elementType; + return result; + } + function getEvolvingArrayType(elementType) { + return evolvingArrayTypes[elementType.id] || (evolvingArrayTypes[elementType.id] = createEvolvingArrayType(elementType)); + } + function addEvolvingArrayElementType(evolvingArrayType, node) { + var elementType = getBaseTypeOfLiteralType(checkExpression(node)); + return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType])); + } + function isEvolvingArrayType(type) { + return !!(type.flags & 2097152 && type.elementType); + } + function createFinalArrayType(elementType) { + return elementType.flags & 8192 ? + autoArrayType : + createArrayType(elementType.flags & 524288 ? + getUnionType(elementType.types, true) : + elementType); + } + function getFinalArrayType(evolvingArrayType) { + return evolvingArrayType.finalArrayType || (evolvingArrayType.finalArrayType = createFinalArrayType(evolvingArrayType.elementType)); + } + function finalizeEvolvingArrayType(type) { + return isEvolvingArrayType(type) ? getFinalArrayType(type) : type; + } + function getElementTypeOfEvolvingArrayType(type) { + return isEvolvingArrayType(type) ? type.elementType : neverType; + } + function isEvolvingArrayTypeList(types) { + var hasEvolvingArrayType = false; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; + if (!(t.flags & 8192)) { + if (!isEvolvingArrayType(t)) { + return false; + } + hasEvolvingArrayType = true; + } + } + return hasEvolvingArrayType; + } + function getUnionOrEvolvingArrayType(types, subtypeReduction) { + return isEvolvingArrayTypeList(types) ? + getEvolvingArrayType(getUnionType(ts.map(types, getElementTypeOfEvolvingArrayType))) : + getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction); + } + function isEvolvingArrayOperationTarget(node) { + var root = getReferenceRoot(node); + var parent = root.parent; + var isLengthPushOrUnshift = parent.kind === 173 && (parent.name.text === "length" || + parent.parent.kind === 175 && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 174 && + parent.expression === root && + parent.parent.kind === 188 && + parent.parent.operatorToken.kind === 57 && + parent.parent.left === parent && + !ts.isAssignmentTarget(parent.parent) && + isTypeAnyOrAllConstituentTypesHaveKind(checkExpression(parent.argumentExpression), 340 | 2048); + return isLengthPushOrUnshift || isElementAssignment; + } function getFlowTypeOfReference(reference, declaredType, assumeInitialized, flowContainer) { var key; if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 4178943)) { return declaredType; } var initialType = assumeInitialized ? declaredType : - declaredType === autoType ? undefinedType : + declaredType === autoType || declaredType === autoArrayType ? undefinedType : includeFalsyTypes(declaredType, 2048); var visitedFlowStart = visitedFlowCount; - var result = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); + var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); visitedFlowCount = visitedFlowStart; - if (reference.parent.kind === 196 && getTypeWithFacts(result, 524288).flags & 8192) { + var resultType = isEvolvingArrayType(evolvedType) && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); + if (reference.parent.kind === 197 && getTypeWithFacts(resultType, 524288).flags & 8192) { return declaredType; } - return result; + return resultType; function getTypeAtFlowNode(flow) { while (true) { - if (flow.flags & 512) { + if (flow.flags & 1024) { for (var i = visitedFlowStart; i < visitedFlowCount; i++) { if (visitedFlowNodes[i] === flow) { return visitedFlowTypes[i]; @@ -26673,18 +26453,25 @@ var ts; getTypeAtFlowBranchLabel(flow) : getTypeAtFlowLoopLabel(flow); } + else if (flow.flags & 256) { + type = getTypeAtFlowArrayMutation(flow); + if (!type) { + flow = flow.antecedent; + continue; + } + } else if (flow.flags & 2) { var container = flow.container; - if (container && container !== flowContainer && reference.kind !== 172) { + if (container && container !== flowContainer && reference.kind !== 173) { flow = container.flowNode; continue; } type = initialType; } else { - type = declaredType; + type = convertAutoToAny(declaredType); } - if (flow.flags & 512) { + if (flow.flags & 1024) { visitedFlowNodes[visitedFlowCount] = flow; visitedFlowTypes[visitedFlowCount] = type; visitedFlowCount++; @@ -26695,30 +26482,70 @@ var ts; function getTypeAtFlowAssignment(flow) { var node = flow.node; if (isMatchingReference(reference, node)) { - if (node.parent.kind === 185 || node.parent.kind === 186) { + if (node.parent.kind === 186 || node.parent.kind === 187) { var flowType = getTypeAtFlowNode(flow.antecedent); return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType)); } - return declaredType === autoType ? getBaseTypeOfLiteralType(getInitialOrAssignedType(node)) : - declaredType.flags & 524288 ? getAssignmentReducedType(declaredType, getInitialOrAssignedType(node)) : - declaredType; + if (declaredType === autoType || declaredType === autoArrayType) { + if (isEmptyArrayAssignment(node)) { + return getEvolvingArrayType(neverType); + } + var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(node)); + return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; + } + if (declaredType.flags & 524288) { + return getAssignmentReducedType(declaredType, getInitialOrAssignedType(node)); + } + return declaredType; } if (containsMatchingReference(reference, node)) { return declaredType; } return undefined; } + function getTypeAtFlowArrayMutation(flow) { + var node = flow.node; + var expr = node.kind === 175 ? + node.expression.expression : + node.left.expression; + if (isMatchingReference(reference, getReferenceCandidate(expr))) { + var flowType = getTypeAtFlowNode(flow.antecedent); + var type = getTypeFromFlowType(flowType); + if (isEvolvingArrayType(type)) { + var evolvedType_1 = type; + if (node.kind === 175) { + for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { + var arg = _a[_i]; + evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); + } + } + else { + var indexType = checkExpression(node.left.argumentExpression); + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 340 | 2048)) { + evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); + } + } + return evolvedType_1 === type ? flowType : createFlowType(evolvedType_1, isIncomplete(flowType)); + } + return flowType; + } + return undefined; + } function getTypeAtFlowCondition(flow) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (!(type.flags & 8192)) { - var assumeTrue = (flow.flags & 32) !== 0; - type = narrowType(type, flow.expression, assumeTrue); - if (type.flags & 8192 && isIncomplete(flowType)) { - type = silentNeverType; - } + if (type.flags & 8192) { + return flowType; } - return createFlowType(type, isIncomplete(flowType)); + var assumeTrue = (flow.flags & 32) !== 0; + var nonEvolvingType = finalizeEvolvingArrayType(type); + var narrowedType = narrowType(nonEvolvingType, flow.expression, assumeTrue); + if (narrowedType === nonEvolvingType) { + return flowType; + } + var incomplete = isIncomplete(flowType); + var resultType = incomplete && narrowedType.flags & 8192 ? silentNeverType : narrowedType; + return createFlowType(resultType, incomplete); } function getTypeAtSwitchClause(flow) { var flowType = getTypeAtFlowNode(flow.antecedent); @@ -26753,7 +26580,7 @@ var ts; seenIncomplete = true; } } - return createFlowType(getUnionType(antecedentTypes, subtypeReduction), seenIncomplete); + return createFlowType(getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction), seenIncomplete); } function getTypeAtFlowLoopLabel(flow) { var id = getFlowNodeId(flow); @@ -26765,8 +26592,8 @@ var ts; return cache[key]; } for (var i = flowLoopStart; i < flowLoopCount; i++) { - if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key) { - return createFlowType(getUnionType(flowLoopTypes[i]), true); + if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key && flowLoopTypes[i].length) { + return createFlowType(getUnionOrEvolvingArrayType(flowLoopTypes[i], false), true); } } var antecedentTypes = []; @@ -26797,14 +26624,14 @@ var ts; break; } } - var result = getUnionType(antecedentTypes, subtypeReduction); + var result = getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction); if (isIncomplete(firstAntecedentType)) { return createFlowType(result, true); } return cache[key] = result; } function isMatchingReferenceDiscriminant(expr) { - return expr.kind === 172 && + return expr.kind === 173 && declaredType.flags & 524288 && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(declaredType, expr.name.text); @@ -26829,19 +26656,19 @@ var ts; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 56: + case 57: return narrowTypeByTruthiness(type, expr.left, assumeTrue); - case 30: case 31: case 32: case 33: + case 34: var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 182 && right_1.kind === 9) { + if (left_1.kind === 183 && right_1.kind === 9) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 182 && left_1.kind === 9) { + if (right_1.kind === 183 && left_1.kind === 9) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -26860,9 +26687,9 @@ var ts; return declaredType; } break; - case 91: + case 92: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 24: + case 25: return narrowType(type, expr.right, assumeTrue); } return type; @@ -26871,7 +26698,7 @@ var ts; if (type.flags & 1) { return type; } - if (operator === 31 || operator === 33) { + if (operator === 32 || operator === 34) { assumeTrue = !assumeTrue; } var valueType = checkExpression(value); @@ -26879,10 +26706,10 @@ var ts; if (!strictNullChecks) { return type; } - var doubleEquals = operator === 30 || operator === 31; + var doubleEquals = operator === 31 || operator === 32; var facts = doubleEquals ? assumeTrue ? 65536 : 524288 : - value.kind === 93 ? + value.kind === 94 ? assumeTrue ? 32768 : 262144 : assumeTrue ? 16384 : 131072; return getTypeWithFacts(type, facts); @@ -26908,7 +26735,7 @@ var ts; } return type; } - if (operator === 31 || operator === 33) { + if (operator === 32 || operator === 34) { assumeTrue = !assumeTrue; } if (assumeTrue && !(type.flags & 524288)) { @@ -27019,7 +26846,7 @@ var ts; } else { var invokedExpression = skipParenthesizedNodes(callExpression.expression); - if (invokedExpression.kind === 173 || invokedExpression.kind === 172) { + if (invokedExpression.kind === 174 || invokedExpression.kind === 173) { var accessExpression = invokedExpression; var possibleReference = skipParenthesizedNodes(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -27034,18 +26861,18 @@ var ts; } function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 69: - case 97: - case 172: + case 70: + case 98: + case 173: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 174: + case 175: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 178: + case 179: return narrowType(type, expr.expression, assumeTrue); - case 187: + case 188: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 185: - if (expr.operator === 49) { + case 186: + if (expr.operator === 50) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -27054,7 +26881,7 @@ var ts; } } function getTypeOfSymbolAtLocation(symbol, location) { - if (location.kind === 69) { + if (location.kind === 70) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } @@ -27068,7 +26895,7 @@ var ts; return getTypeOfSymbol(symbol); } function skipParenthesizedNodes(expression) { - while (expression.kind === 178) { + while (expression.kind === 179) { expression = expression.expression; } return expression; @@ -27077,9 +26904,9 @@ var ts; while (true) { node = node.parent; if (ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 226 || + node.kind === 227 || node.kind === 256 || - node.kind === 145) { + node.kind === 146) { return node; } } @@ -27107,10 +26934,10 @@ var ts; } } function markParameterAssignments(node) { - if (node.kind === 69) { + if (node.kind === 70) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 142) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 143) { symbol.isAssigned = true; } } @@ -27119,12 +26946,15 @@ var ts; ts.forEachChild(node, markParameterAssignments); } } + function isConstVariable(symbol) { + return symbol.flags & 3 && (getDeclarationNodeFlagsFromSymbol(symbol) & 2) !== 0 && getTypeOfSymbol(symbol) !== autoArrayType; + } function checkIdentifier(node) { var symbol = getResolvedSymbol(node); if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2) { - if (container.kind === 180) { + if (container.kind === 181) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } else if (ts.hasModifier(container, 256)) { @@ -27142,7 +26972,7 @@ var ts; if (localOrExportSymbol.flags & 32) { var declaration_1 = localOrExportSymbol.valueDeclaration; if (languageVersion === 2 - && declaration_1.kind === 221 + && declaration_1.kind === 222 && ts.nodeIsDecorated(declaration_1)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -27154,11 +26984,11 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration_1.kind === 192) { + else if (declaration_1.kind === 193) { var container = ts.getThisContainer(node, false); while (container !== undefined) { if (container.parent === declaration_1) { - if (container.kind === 145 && ts.hasModifier(container, 32)) { + if (container.kind === 146 && ts.hasModifier(container, 32)) { getNodeLinks(declaration_1).flags |= 8388608; getNodeLinks(node).flags |= 16777216; } @@ -27176,28 +27006,26 @@ var ts; if (!(localOrExportSymbol.flags & 3) || ts.isAssignmentTarget(node) || !declaration) { return type; } - var isParameter = ts.getRootDeclaration(declaration).kind === 142; + var isParameter = ts.getRootDeclaration(declaration).kind === 143; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; - while (flowContainer !== declarationContainer && - (flowContainer.kind === 179 || - flowContainer.kind === 180 || - ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && - (isReadonlySymbol(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { + while (flowContainer !== declarationContainer && (flowContainer.kind === 180 || + flowContainer.kind === 181 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } var assumeInitialized = isParameter || isOuterVariable || - type !== autoType && (!strictNullChecks || (type.flags & 1) !== 0) || + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1) !== 0) || ts.isInAmbientContext(declaration); var flowType = getFlowTypeOfReference(node, type, assumeInitialized, flowContainer); - if (type === autoType) { - if (flowType === autoType) { + if (type === autoType || type === autoArrayType) { + if (flowType === autoType || flowType === autoArrayType) { if (compilerOptions.noImplicitAny) { - error(declaration.name, ts.Diagnostics.Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol)); - error(node, ts.Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(anyType)); + error(declaration.name, ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol), typeToString(flowType)); + error(node, ts.Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(flowType)); } - return anyType; + return convertAutoToAny(flowType); } } else if (!assumeInitialized && !(getFalsyFlags(type) & 2048) && getFalsyFlags(flowType) & 2048) { @@ -27237,8 +27065,8 @@ var ts; if (usedInFunction) { getNodeLinks(current).flags |= 65536; } - if (container.kind === 206 && - ts.getAncestor(symbol.valueDeclaration, 219).parent === container && + if (container.kind === 207 && + ts.getAncestor(symbol.valueDeclaration, 220).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152; } @@ -27250,16 +27078,16 @@ var ts; } function isAssignedInBodyOfForStatement(node, container) { var current = node; - while (current.parent.kind === 178) { + while (current.parent.kind === 179) { current = current.parent; } var isAssigned = false; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 185 || current.parent.kind === 186)) { + else if ((current.parent.kind === 186 || current.parent.kind === 187)) { var expr = current.parent; - isAssigned = expr.operator === 41 || expr.operator === 42; + isAssigned = expr.operator === 42 || expr.operator === 43; } if (!isAssigned) { return false; @@ -27276,7 +27104,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2; - if (container.kind === 145 || container.kind === 148) { + if (container.kind === 146 || container.kind === 149) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4; } @@ -27310,7 +27138,7 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 148) { + if (container.kind === 149) { var containingClassDecl = container.parent; var baseTypeNode = ts.getClassExtendsHeritageClauseElement(containingClassDecl); if (baseTypeNode && !classDeclarationExtendsNull(containingClassDecl)) { @@ -27320,29 +27148,29 @@ var ts; } } } - if (container.kind === 180) { + if (container.kind === 181) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 225: + case 226: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 224: + case 225: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 148: + case 149: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; + case 146: case 145: - case 144: if (ts.getModifierFlags(container) & 32) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 140: + case 141: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -27351,7 +27179,7 @@ var ts; } if (ts.isFunctionLike(container) && (!isInParameterInitializerBeforeContainingFunction(node) || ts.getThisParameter(container))) { - if (container.kind === 179 && + if (container.kind === 180 && ts.isInJavaScriptFile(container.parent) && ts.getSpecialPropertyAssignmentKind(container.parent) === 3) { var className = container.parent @@ -27363,7 +27191,7 @@ var ts; return getInferredClassType(classSymbol); } } - var thisType = getThisTypeOfDeclaration(container); + var thisType = getThisTypeOfDeclaration(container) || getContextualThisParameterType(container); if (thisType) { return thisType; } @@ -27395,18 +27223,18 @@ var ts; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 142) { + if (n.kind === 143) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 174 && node.parent.expression === node; + var isCallExpression = node.parent.kind === 175 && node.parent.expression === node; var container = ts.getSuperContainer(node, true); var needToCaptureLexicalThis = false; if (!isCallExpression) { - while (container && container.kind === 180) { + while (container && container.kind === 181) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } @@ -27415,16 +27243,16 @@ var ts; var nodeCheckFlag = 0; if (!canUseSuperExpression) { var current = node; - while (current && current !== container && current.kind !== 140) { + while (current && current !== container && current.kind !== 141) { current = current.parent; } - if (current && current.kind === 140) { + if (current && current.kind === 141) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); } - else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 171)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 172)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -27439,7 +27267,7 @@ var ts; nodeCheckFlag = 256; } getNodeLinks(node).flags |= nodeCheckFlag; - if (container.kind === 147 && ts.getModifierFlags(container) & 256) { + if (container.kind === 148 && ts.getModifierFlags(container) & 256) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096; } @@ -27450,7 +27278,7 @@ var ts; if (needToCaptureLexicalThis) { captureLexicalThis(node.parent, container); } - if (container.parent.kind === 171) { + if (container.parent.kind === 172) { if (languageVersion < 2) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return unknownType; @@ -27468,7 +27296,7 @@ var ts; } return unknownType; } - if (container.kind === 148 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 149 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return unknownType; } @@ -27480,35 +27308,38 @@ var ts; return false; } if (isCallExpression) { - return container.kind === 148; + return container.kind === 149; } else { - if (ts.isClassLike(container.parent) || container.parent.kind === 171) { + if (ts.isClassLike(container.parent) || container.parent.kind === 172) { if (ts.getModifierFlags(container) & 32) { - return container.kind === 147 || - container.kind === 146 || - container.kind === 149 || - container.kind === 150; + return container.kind === 148 || + container.kind === 147 || + container.kind === 150 || + container.kind === 151; } else { - return container.kind === 147 || - container.kind === 146 || - container.kind === 149 || + return container.kind === 148 || + container.kind === 147 || container.kind === 150 || + container.kind === 151 || + container.kind === 146 || container.kind === 145 || - container.kind === 144 || - container.kind === 148; + container.kind === 149; } } } return false; } } - function getContextualThisParameter(func) { - if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 180) { + function getContextualThisParameterType(func) { + if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 181) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { - return contextualSignature.thisParameter; + var thisParameter = contextualSignature.thisParameter; + if (thisParameter) { + return getTypeOfSymbol(thisParameter); + } } } return undefined; @@ -27558,7 +27389,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 142) { + if (declaration.kind === 143) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -27569,11 +27400,11 @@ var ts; } if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; - var name_18 = declaration.propertyName || declaration.name; + var name_15 = declaration.propertyName || declaration.name; if (ts.isVariableLike(parentDeclaration) && parentDeclaration.type && - !ts.isBindingPattern(name_18)) { - var text = getTextOfPropertyName(name_18); + !ts.isBindingPattern(name_15)) { + var text = getTextOfPropertyName(name_15); if (text) { return getTypeOfPropertyOfType(getTypeFromTypeNode(parentDeclaration.type), text); } @@ -27610,7 +27441,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 142 && node.parent.initializer === node) { + if (node.parent.kind === 143 && node.parent.initializer === node) { return true; } node = node.parent; @@ -27619,8 +27450,8 @@ var ts; } function getContextualReturnType(functionDecl) { if (functionDecl.type || - functionDecl.kind === 148 || - functionDecl.kind === 149 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 150))) { + functionDecl.kind === 149 || + functionDecl.kind === 150 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 151))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); @@ -27639,7 +27470,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 176) { + if (template.parent.kind === 177) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -27647,7 +27478,7 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operatorToken.kind; - if (operator >= 56 && operator <= 68) { + if (operator >= 57 && operator <= 69) { if (ts.getSpecialPropertyAssignmentKind(binaryExpression) !== 0) { return undefined; } @@ -27655,14 +27486,14 @@ var ts; return checkExpression(binaryExpression.left); } } - else if (operator === 52) { + else if (operator === 53) { var type = getContextualType(binaryExpression); if (!type && node === binaryExpression.right) { type = checkExpression(binaryExpression.left); } return type; } - else if (operator === 51 || operator === 24) { + else if (operator === 52 || operator === 25) { if (node === binaryExpression.right) { return getContextualType(binaryExpression); } @@ -27676,8 +27507,8 @@ var ts; var types = type.types; var mappedType; var mappedTypes; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var current = types_12[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var current = types_13[_i]; var t = mapper(current); if (t) { if (!mappedType) { @@ -27771,36 +27602,36 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 218: - case 142: + case 219: + case 143: + case 146: case 145: - case 144: - case 169: + case 170: return getContextualTypeForInitializerExpression(node); - case 180: - case 211: + case 181: + case 212: return getContextualTypeForReturnExpression(node); - case 190: + case 191: return getContextualTypeForYieldOperand(parent); - case 174: case 175: + case 176: return getContextualTypeForArgument(parent, node); - case 177: - case 195: + case 178: + case 196: return getTypeFromTypeNode(parent.type); - case 187: + case 188: return getContextualTypeForBinaryOperand(node); case 253: case 254: return getContextualTypeForObjectLiteralElement(parent); - case 170: + case 171: return getContextualTypeForElementExpression(node); - case 188: + case 189: return getContextualTypeForConditionalOperand(node); - case 197: - ts.Debug.assert(parent.parent.kind === 189); + case 198: + ts.Debug.assert(parent.parent.kind === 190); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 178: + case 179: return getContextualType(parent); case 248: return getContextualType(parent); @@ -27820,7 +27651,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 179 || node.kind === 180; + return node.kind === 180 || node.kind === 181; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -27833,7 +27664,7 @@ var ts; getApparentTypeOfContextualType(node); } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 147 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 148 || ts.isObjectLiteralMethod(node)); var type = getContextualTypeForFunctionLikeDeclaration(node); if (!type) { return undefined; @@ -27843,8 +27674,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var current = types_13[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var current = types_14[_i]; var signature = getNonGenericSignature(current); if (signature) { if (!signatureList) { @@ -27874,8 +27705,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false); } function hasDefaultValue(node) { - return (node.kind === 169 && !!node.initializer) || - (node.kind === 187 && node.operatorToken.kind === 56); + return (node.kind === 170 && !!node.initializer) || + (node.kind === 188 && node.operatorToken.kind === 57); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -27884,7 +27715,7 @@ var ts; var inDestructuringPattern = ts.isAssignmentTarget(node); for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { var e = elements_1[_i]; - if (inDestructuringPattern && e.kind === 191) { + if (inDestructuringPattern && e.kind === 192) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); @@ -27896,7 +27727,7 @@ var ts; var type = checkExpressionForMutableLocation(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 191; + hasSpreadElement = hasSpreadElement || e.kind === 192; } if (!hasSpreadElement) { if (inDestructuringPattern && elementTypes.length) { @@ -27907,7 +27738,7 @@ var ts; var contextualType = getApparentTypeOfContextualType(node); if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { var pattern = contextualType.pattern; - if (pattern && (pattern.kind === 168 || pattern.kind === 170)) { + if (pattern && (pattern.kind === 169 || pattern.kind === 171)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -27915,7 +27746,7 @@ var ts; elementTypes.push(contextualType.typeArguments[i]); } else { - if (patternElement.kind !== 193) { + if (patternElement.kind !== 194) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -27932,7 +27763,7 @@ var ts; strictNullChecks ? neverType : undefinedWideningType); } function isNumericName(name) { - return name.kind === 140 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 141 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 340); @@ -27976,7 +27807,7 @@ var ts; var propertiesArray = []; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 167 || contextualType.pattern.kind === 171); + (contextualType.pattern.kind === 168 || contextualType.pattern.kind === 172); var typeFlags = 0; var patternWithComputedProperties = false; var hasComputedStringProperty = false; @@ -27991,7 +27822,7 @@ var ts; if (memberDecl.kind === 253) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 147) { + else if (memberDecl.kind === 148) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { @@ -28030,7 +27861,7 @@ var ts; member = prop; } else { - ts.Debug.assert(memberDecl.kind === 149 || memberDecl.kind === 150); + ts.Debug.assert(memberDecl.kind === 150 || memberDecl.kind === 151); checkAccessorDeclaration(memberDecl); } if (ts.hasDynamicName(memberDecl)) { @@ -28089,10 +27920,10 @@ var ts; case 248: checkJsxExpression(child); break; - case 241: + case 242: checkJsxElement(child); break; - case 242: + case 243: checkJsxSelfClosingElement(child); break; } @@ -28103,7 +27934,7 @@ var ts; return name.indexOf("-") < 0; } function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 172 || tagName.kind === 97) { + if (tagName.kind === 173 || tagName.kind === 98) { return false; } else { @@ -28206,7 +28037,7 @@ var ts; return unknownType; } } - return getUnionType(signatures.map(getReturnTypeOfSignature), true); + return getUnionType(ts.map(signatures, getReturnTypeOfSignature), true); } function getJsxElementPropertiesName() { var jsxNamespace = getGlobalSymbol(JsxNames.JSX, 1920, undefined); @@ -28235,7 +28066,7 @@ var ts; } if (elemType.flags & 524288) { var types = elemType.types; - return getUnionType(types.map(function (type) { + return getUnionType(ts.map(types, function (type) { return getResolvedJsxType(node, type, elemClassType); }), true); } @@ -28411,7 +28242,7 @@ var ts; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 145; + return s.valueDeclaration ? s.valueDeclaration.kind : 146; } function getDeclarationModifierFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedModifierFlags(s.valueDeclaration) : s.flags & 134217728 ? 4 | 32 : 0; @@ -28422,11 +28253,11 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationModifierFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(getParentOfSymbol(prop)); - var errorNode = node.kind === 172 || node.kind === 218 ? + var errorNode = node.kind === 173 || node.kind === 219 ? node.name : node.right; - if (left.kind === 95) { - if (languageVersion < 2 && getDeclarationKindFromSymbol(prop) !== 147) { + if (left.kind === 96) { + if (languageVersion < 2 && getDeclarationKindFromSymbol(prop) !== 148) { error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); return false; } @@ -28446,7 +28277,7 @@ var ts; } return true; } - if (left.kind === 95) { + if (left.kind === 96) { return true; } var enclosingClass = forEachEnclosingClass(node, function (enclosingDeclaration) { @@ -28520,7 +28351,7 @@ var ts; checkClassPropertyAccess(node, left, apparentType, prop); } var propType = getTypeOfSymbol(prop); - if (node.kind !== 172 || ts.isAssignmentTarget(node) || + if (node.kind !== 173 || ts.isAssignmentTarget(node) || !(prop.flags & (3 | 4 | 98304)) && !(prop.flags & 8192 && propType.flags & 524288)) { return propType; @@ -28542,7 +28373,7 @@ var ts; } } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 172 + var left = node.kind === 173 ? node.expression : node.left; var type = checkExpression(left); @@ -28556,13 +28387,13 @@ var ts; } function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 219) { + if (initializer.kind === 220) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 69) { + else if (initializer.kind === 70) { return getResolvedSymbol(initializer); } return undefined; @@ -28572,13 +28403,13 @@ var ts; } function isForInVariableForNumericPropertyNames(expr) { var e = skipParenthesizedNodes(expr); - if (e.kind === 69) { + if (e.kind === 70) { var symbol = getResolvedSymbol(e); if (symbol.flags & 3) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 207 && + if (node.kind === 208 && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(checkExpression(node.expression))) { @@ -28594,7 +28425,7 @@ var ts; function checkIndexedAccess(node) { if (!node.argumentExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 175 && node.parent.expression === node) { + if (node.parent.kind === 176 && 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); @@ -28617,15 +28448,15 @@ var ts; return unknownType; } if (node.argumentExpression) { - var name_19 = getPropertyNameForIndexedAccess(node.argumentExpression, indexType); - if (name_19 !== undefined) { - var prop = getPropertyOfType(objectType, name_19); + var name_16 = getPropertyNameForIndexedAccess(node.argumentExpression, indexType); + if (name_16 !== undefined) { + var prop = getPropertyOfType(objectType, name_16); if (prop) { getNodeLinks(node).resolvedSymbol = prop; return getTypeOfSymbol(prop); } else if (isConstEnum) { - error(node.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_const_enum_1, name_19, symbolToString(objectType.symbol)); + error(node.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_const_enum_1, name_16, symbolToString(objectType.symbol)); return unknownType; } } @@ -28658,7 +28489,7 @@ var ts; if (indexArgumentExpression.kind === 9 || indexArgumentExpression.kind === 8) { return indexArgumentExpression.text; } - if (indexArgumentExpression.kind === 173 || indexArgumentExpression.kind === 172) { + if (indexArgumentExpression.kind === 174 || indexArgumentExpression.kind === 173) { var value = getConstantValue(indexArgumentExpression); if (value !== undefined) { return value.toString(); @@ -28701,10 +28532,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 176) { + if (node.kind === 177) { checkExpression(node.template); } - else if (node.kind !== 143) { + else if (node.kind !== 144) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -28755,7 +28586,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 191) { + if (arg && arg.kind === 192) { return i; } } @@ -28768,11 +28599,11 @@ var ts; var callIsIncomplete; var isDecorator; var spreadArgIndex = -1; - if (node.kind === 176) { + if (node.kind === 177) { var tagExpression = node; argCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 189) { + if (tagExpression.template.kind === 190) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -28780,11 +28611,11 @@ var ts; } else { var templateLiteral = tagExpression.template; - ts.Debug.assert(templateLiteral.kind === 11); + ts.Debug.assert(templateLiteral.kind === 12); callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 143) { + else if (node.kind === 144) { isDecorator = true; typeArguments = undefined; argCount = getEffectiveArgumentCount(node, undefined, signature); @@ -28792,7 +28623,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 175); + ts.Debug.assert(callExpression.kind === 176); return signature.minArgumentCount === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -28851,9 +28682,9 @@ 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 !== 193) { + if (arg === undefined || arg.kind !== 194) { var paramType = getTypeAtPosition(signature, i); - var argType = getEffectiveArgumentType(node, i, arg); + var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { var mapper = excludeArgument && excludeArgument[i] !== undefined ? identityMapper : inferenceMapper; argType = checkExpressionWithContextualType(arg, paramType, mapper); @@ -28898,7 +28729,7 @@ var ts; } function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 175) { + if (thisType && thisType !== voidType && node.kind !== 176) { var thisArgumentNode = getThisArgumentOfCall(node); var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; var errorNode = reportErrors ? (thisArgumentNode || node) : undefined; @@ -28911,9 +28742,9 @@ 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 !== 193) { + if (arg === undefined || arg.kind !== 194) { var paramType = getTypeAtPosition(signature, i); - var argType = getEffectiveArgumentType(node, i, arg); + var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { argType = checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); } @@ -28926,28 +28757,28 @@ var ts; return true; } function getThisArgumentOfCall(node) { - if (node.kind === 174) { + if (node.kind === 175) { var callee = node.expression; - if (callee.kind === 172) { + if (callee.kind === 173) { return callee.expression; } - else if (callee.kind === 173) { + else if (callee.kind === 174) { return callee.expression; } } } function getEffectiveCallArguments(node) { var args; - if (node.kind === 176) { + if (node.kind === 177) { var template = node.template; args = [undefined]; - if (template.kind === 189) { + if (template.kind === 190) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 143) { + else if (node.kind === 144) { return undefined; } else { @@ -28956,21 +28787,21 @@ var ts; return args; } function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 143) { + if (node.kind === 144) { switch (node.parent.kind) { - case 221: - case 192: + case 222: + case 193: return 1; - case 145: + case 146: return 2; - case 147: - case 149: + case 148: case 150: + case 151: if (languageVersion === 0) { return 2; } return signature.parameters.length >= 3 ? 3 : 2; - case 142: + case 143: return 3; } } @@ -28979,48 +28810,48 @@ var ts; } } function getEffectiveDecoratorFirstArgumentType(node) { - if (node.kind === 221) { + if (node.kind === 222) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } - if (node.kind === 142) { + if (node.kind === 143) { node = node.parent; - if (node.kind === 148) { + if (node.kind === 149) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } } - if (node.kind === 145 || - node.kind === 147 || - node.kind === 149 || - node.kind === 150) { + if (node.kind === 146 || + node.kind === 148 || + node.kind === 150 || + node.kind === 151) { return getParentTypeOfClassElement(node); } ts.Debug.fail("Unsupported decorator target."); return unknownType; } function getEffectiveDecoratorSecondArgumentType(node) { - if (node.kind === 221) { + if (node.kind === 222) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } - if (node.kind === 142) { + if (node.kind === 143) { node = node.parent; - if (node.kind === 148) { + if (node.kind === 149) { return anyType; } } - if (node.kind === 145 || - node.kind === 147 || - node.kind === 149 || - node.kind === 150) { + if (node.kind === 146 || + node.kind === 148 || + node.kind === 150 || + node.kind === 151) { var element = node; switch (element.name.kind) { - case 69: + case 70: case 8: case 9: return getLiteralTypeForText(32, element.name.text); - case 140: + case 141: var nameType = checkComputedPropertyName(element.name); if (isTypeOfKind(nameType, 512)) { return nameType; @@ -29037,20 +28868,20 @@ var ts; return unknownType; } function getEffectiveDecoratorThirdArgumentType(node) { - if (node.kind === 221) { + if (node.kind === 222) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 142) { + if (node.kind === 143) { return numberType; } - if (node.kind === 145) { + if (node.kind === 146) { ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 147 || - node.kind === 149 || - node.kind === 150) { + if (node.kind === 148 || + node.kind === 150 || + node.kind === 151) { var propertyType = getTypeOfNode(node); return createTypedPropertyDescriptorType(propertyType); } @@ -29070,27 +28901,27 @@ var ts; ts.Debug.fail("Decorators should not have a fourth synthetic argument."); return unknownType; } - function getEffectiveArgumentType(node, argIndex, arg) { - if (node.kind === 143) { + function getEffectiveArgumentType(node, argIndex) { + if (node.kind === 144) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 176) { + else if (argIndex === 0 && node.kind === 177) { return getGlobalTemplateStringsArrayType(); } return undefined; } function getEffectiveArgument(node, args, argIndex) { - if (node.kind === 143 || - (argIndex === 0 && node.kind === 176)) { + if (node.kind === 144 || + (argIndex === 0 && node.kind === 177)) { return undefined; } return args[argIndex]; } function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 143) { + if (node.kind === 144) { return node.expression; } - else if (argIndex === 0 && node.kind === 176) { + else if (argIndex === 0 && node.kind === 177) { return node.template; } else { @@ -29098,12 +28929,12 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 176; - var isDecorator = node.kind === 143; + var isTaggedTemplate = node.kind === 177; + var isDecorator = node.kind === 144; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; - if (node.expression.kind !== 95) { + if (node.expression.kind !== 96) { ts.forEach(typeArguments, checkSourceElement); } } @@ -29129,7 +28960,7 @@ var ts; var candidateForTypeArgumentError; var resultOfFailedInference; var result; - var signatureHelpTrailingComma = candidatesOutArray && node.kind === 174 && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 175 && node.arguments.hasTrailingComma; if (candidates.length > 1) { result = chooseOverload(candidates, subtypeRelation, signatureHelpTrailingComma); } @@ -29244,7 +29075,7 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 95) { + if (node.expression.kind === 96) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); @@ -29397,16 +29228,16 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 221: - case 192: + case 222: + case 193: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 142: + case 143: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 145: + case 146: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 147: - case 149: + case 148: case 150: + case 151: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -29433,13 +29264,13 @@ var ts; } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 174: - return resolveCallExpression(node, candidatesOutArray); case 175: - return resolveNewExpression(node, candidatesOutArray); + return resolveCallExpression(node, candidatesOutArray); case 176: + return resolveNewExpression(node, candidatesOutArray); + case 177: return resolveTaggedTemplateExpression(node, candidatesOutArray); - case 143: + case 144: return resolveDecorator(node, candidatesOutArray); } ts.Debug.fail("Branch in 'resolveSignature' should be unreachable."); @@ -29468,17 +29299,17 @@ var ts; function checkCallExpression(node) { checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 95) { + if (node.expression.kind === 96) { return voidType; } - if (node.kind === 175) { + if (node.kind === 176) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 148 && - declaration.kind !== 152 && - declaration.kind !== 157 && + declaration.kind !== 149 && + declaration.kind !== 153 && + declaration.kind !== 158 && !ts.isJSDocConstructSignature(declaration)) { - var funcSymbol = node.expression.kind === 69 ? + var funcSymbol = node.expression.kind === 70 ? getResolvedSymbol(node.expression) : checkExpression(node.expression).symbol; if (funcSymbol && funcSymbol.members && (funcSymbol.flags & 16 || ts.isDeclarationOfFunctionExpression(funcSymbol))) { @@ -29490,7 +29321,9 @@ var ts; return anyType; } } - if (ts.isInJavaScriptFile(node) && ts.isRequireCall(node, true)) { + if (ts.isInJavaScriptFile(node) && + ts.isRequireCall(node, true) && + !resolveName(node.expression, node.expression.text, 107455, undefined, undefined)) { return resolveExternalModuleTypeByLiteral(node.arguments[0]); } return getReturnTypeOfSignature(signature); @@ -29530,21 +29363,36 @@ var ts; } function assignContextualParameterTypes(signature, context, mapper) { var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + if (isInferentialContext(mapper)) { + for (var i = 0; i < len; i++) { + var declaration = signature.parameters[i].valueDeclaration; + if (declaration.type) { + inferTypes(mapper.context, getTypeFromTypeNode(declaration.type), getTypeAtPosition(context, i)); + } + } + } if (context.thisParameter) { - if (!signature.thisParameter) { - signature.thisParameter = createTransientSymbol(context.thisParameter, undefined); + var parameter = signature.thisParameter; + if (!parameter || parameter.valueDeclaration && !parameter.valueDeclaration.type) { + if (!parameter) { + signature.thisParameter = createTransientSymbol(context.thisParameter, undefined); + } + assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper); } - assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper); } for (var i = 0; i < len; i++) { var parameter = signature.parameters[i]; - var contextualParameterType = getTypeAtPosition(context, i); - assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + if (!parameter.valueDeclaration.type) { + var contextualParameterType = getTypeAtPosition(context, i); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + } } if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) { var parameter = ts.lastOrUndefined(signature.parameters); - var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); - assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + if (!parameter.valueDeclaration.type) { + var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + } } } function assignBindingElementTypes(node) { @@ -29552,7 +29400,7 @@ var ts; for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { var element = _a[_i]; if (!ts.isOmittedExpression(element)) { - if (element.name.kind === 69) { + if (element.name.kind === 70) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } assignBindingElementTypes(element); @@ -29565,8 +29413,8 @@ var ts; if (!links.type) { links.type = instantiateType(contextualType, mapper); if (links.type === emptyObjectType && - (parameter.valueDeclaration.name.kind === 167 || - parameter.valueDeclaration.name.kind === 168)) { + (parameter.valueDeclaration.name.kind === 168 || + parameter.valueDeclaration.name.kind === 169)) { links.type = getTypeFromBindingPattern(parameter.valueDeclaration.name); } assignBindingElementTypes(parameter.valueDeclaration); @@ -29605,7 +29453,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 199) { + if (func.body.kind !== 200) { 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); @@ -29684,7 +29532,7 @@ var ts; return false; } var lastStatement = ts.lastOrUndefined(func.body.statements); - if (lastStatement && lastStatement.kind === 213 && isExhaustiveSwitchStatement(lastStatement)) { + if (lastStatement && lastStatement.kind === 214 && isExhaustiveSwitchStatement(lastStatement)) { return false; } return true; @@ -29713,7 +29561,7 @@ var ts; } }); if (aggregatedTypes.length === 0 && !hasReturnWithNoExpression && (hasReturnOfTypeNever || - func.kind === 179 || func.kind === 180)) { + func.kind === 180 || func.kind === 181)) { return undefined; } if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression) { @@ -29730,7 +29578,7 @@ var ts; if (returnType && maybeTypeOfKind(returnType, 1 | 1024)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 199 || !functionHasImplicitReturn(func)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 200 || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256; @@ -29757,9 +29605,9 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 147 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 148 || ts.isObjectLiteralMethod(node)); var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 179) { + if (!hasGrammarError && node.kind === 180) { checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { @@ -29793,14 +29641,14 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 147) { + if (produceDiagnostics && node.kind !== 148) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 147 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 148 || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); if (!node.asteriskToken) { @@ -29810,7 +29658,7 @@ var ts; if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 199) { + if (node.body.kind === 200) { checkSourceElement(node.body); } else { @@ -29845,10 +29693,10 @@ var ts; function isReferenceToReadonlyEntity(expr, symbol) { if (isReadonlySymbol(symbol)) { if (symbol.flags & 4 && - (expr.kind === 172 || expr.kind === 173) && - expr.expression.kind === 97) { + (expr.kind === 173 || expr.kind === 174) && + expr.expression.kind === 98) { var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 148)) + if (!(func && func.kind === 149)) return true; return !(func.parent === symbol.valueDeclaration.parent || func === symbol.valueDeclaration.parent); } @@ -29857,13 +29705,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 172 || expr.kind === 173) { + if (expr.kind === 173 || expr.kind === 174) { var node = skipParenthesizedNodes(expr.expression); - if (node.kind === 69) { + if (node.kind === 70) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 8388608) { var declaration = getDeclarationOfAliasSymbol(symbol); - return declaration && declaration.kind === 232; + return declaration && declaration.kind === 233; } } } @@ -29871,7 +29719,7 @@ var ts; } function checkReferenceExpression(expr, invalidReferenceMessage, constantVariableMessage) { var node = skipParenthesizedNodes(expr); - if (node.kind !== 69 && node.kind !== 172 && node.kind !== 173) { + if (node.kind !== 70 && node.kind !== 173 && node.kind !== 174) { error(expr, invalidReferenceMessage); return false; } @@ -29879,7 +29727,7 @@ var ts; var symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol); if (symbol) { if (symbol !== unknownSymbol && symbol !== argumentsSymbol) { - if (node.kind === 69 && !(symbol.flags & 3)) { + if (node.kind === 70 && !(symbol.flags & 3)) { error(expr, invalidReferenceMessage); return false; } @@ -29889,7 +29737,7 @@ var ts; } } } - else if (node.kind === 173) { + else if (node.kind === 174) { if (links.resolvedIndexInfo && links.resolvedIndexInfo.isReadonly) { error(expr, constantVariableMessage); return false; @@ -29926,24 +29774,24 @@ var ts; if (operandType === silentNeverType) { return silentNeverType; } - if (node.operator === 36 && node.operand.kind === 8) { + if (node.operator === 37 && node.operand.kind === 8) { return getFreshTypeOfLiteralType(getLiteralTypeForText(64, "" + -node.operand.text)); } switch (node.operator) { - case 35: case 36: - case 50: + case 37: + case 51: if (maybeTypeOfKind(operandType, 512)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; - case 49: + case 50: var facts = getTypeFacts(operandType) & (1048576 | 2097152); return facts === 1048576 ? falseType : facts === 2097152 ? trueType : booleanType; - case 41: case 42: + case 43: var ok = checkArithmeticOperandType(node.operand, getNonNullableType(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_or_a_read_only_property); @@ -29969,8 +29817,8 @@ var ts; } if (type.flags & 1572864) { var types = type.types; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var t = types_14[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var t = types_15[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -29984,8 +29832,8 @@ var ts; } if (type.flags & 524288) { var types = type.types; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var t = types_15[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var t = types_16[_i]; if (!isTypeOfKind(t, kind)) { return false; } @@ -29994,8 +29842,8 @@ var ts; } if (type.flags & 1048576) { var types = type.types; - for (var _a = 0, types_16 = types; _a < types_16.length; _a++) { - var t = types_16[_a]; + for (var _a = 0, types_17 = types; _a < types_17.length; _a++) { + var t = types_17[_a]; if (isTypeOfKind(t, kind)) { return true; } @@ -30033,24 +29881,24 @@ var ts; } return booleanType; } - function checkObjectLiteralAssignment(node, sourceType, contextualMapper) { + function checkObjectLiteralAssignment(node, sourceType) { var properties = node.properties; for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { var p = properties_4[_i]; - checkObjectLiteralDestructuringPropertyAssignment(sourceType, p, contextualMapper); + checkObjectLiteralDestructuringPropertyAssignment(sourceType, p); } return sourceType; } - function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, contextualMapper) { + function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property) { if (property.kind === 253 || property.kind === 254) { - var name_20 = property.name; - if (name_20.kind === 140) { - checkComputedPropertyName(name_20); + var name_17 = property.name; + if (name_17.kind === 141) { + checkComputedPropertyName(name_17); } - if (isComputedNonLiteralName(name_20)) { + if (isComputedNonLiteralName(name_17)) { return undefined; } - var text = getTextOfPropertyName(name_20); + var text = getTextOfPropertyName(name_17); var type = isTypeAny(objectLiteralType) ? objectLiteralType : getTypeOfPropertyOfType(objectLiteralType, text) || @@ -30065,7 +29913,7 @@ var ts; } } else { - error(name_20, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_20)); + error(name_17, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_17)); } } else { @@ -30083,8 +29931,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, contextualMapper) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 193) { - if (element.kind !== 191) { + if (element.kind !== 194) { + if (element.kind !== 192) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType @@ -30110,7 +29958,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 187 && restExpression.operatorToken.kind === 56) { + if (restExpression.kind === 188 && restExpression.operatorToken.kind === 57) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -30137,14 +29985,14 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 187 && target.operatorToken.kind === 56) { + if (target.kind === 188 && target.operatorToken.kind === 57) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 171) { - return checkObjectLiteralAssignment(target, sourceType, contextualMapper); + if (target.kind === 172) { + return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 170) { + if (target.kind === 171) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -30159,49 +30007,49 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 69: + case 70: case 9: - case 10: - case 176: - case 189: case 11: + case 177: + case 190: + case 12: case 8: - case 99: - case 84: - case 93: - case 135: - case 179: - case 192: + case 100: + case 85: + case 94: + case 136: case 180: - case 170: + case 193: + case 181: case 171: - case 182: - case 196: + case 172: + case 183: + case 197: + case 243: case 242: - case 241: return true; - case 188: + case 189: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 187: + case 188: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 185: case 186: + case 187: switch (node.operator) { - case 49: - case 35: - case 36: case 50: + case 36: + case 37: + case 51: return true; } return false; - case 183: - case 177: - case 195: + case 184: + case 178: + case 196: default: return false; } @@ -30221,34 +30069,34 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { var operator = operatorToken.kind; - if (operator === 56 && (left.kind === 171 || left.kind === 170)) { + if (operator === 57 && (left.kind === 172 || left.kind === 171)) { return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } var leftType = checkExpression(left, contextualMapper); var rightType = checkExpression(right, contextualMapper); switch (operator) { - case 37: case 38: - case 59: - case 60: case 39: + case 60: case 61: case 40: case 62: - case 36: - case 58: - case 43: + case 41: case 63: + case 37: + case 59: case 44: case 64: case 45: case 65: - case 47: - case 67: - case 48: - case 68: case 46: case 66: + case 48: + case 68: + case 49: + case 69: + case 47: + case 67: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -30272,8 +30120,8 @@ var ts; } } return numberType; - case 35: - case 57: + case 36: + case 58: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -30302,24 +30150,24 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 57) { + if (operator === 58) { checkAssignmentOperator(resultType); } return resultType; - case 25: - case 27: + case 26: case 28: case 29: + case 30: if (checkForDisallowedESSymbolOperand(operator)) { if (!isTypeComparableTo(leftType, rightType) && !isTypeComparableTo(rightType, leftType)) { reportOperatorError(); } } return booleanType; - case 30: case 31: case 32: case 33: + case 34: var leftIsLiteral = isLiteralType(leftType); var rightIsLiteral = isLiteralType(rightType); if (!leftIsLiteral || !rightIsLiteral) { @@ -30330,22 +30178,22 @@ var ts; reportOperatorError(); } return booleanType; - case 91: + case 92: return checkInstanceOfExpression(left, right, leftType, rightType); - case 90: + case 91: return checkInExpression(left, right, leftType, rightType); - case 51: + case 52: return getTypeFacts(leftType) & 1048576 ? includeFalsyTypes(rightType, getFalsyFlags(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType))) : leftType; - case 52: + case 53: return getTypeFacts(leftType) & 2097152 ? getBestChoiceType(removeDefinitelyFalsyTypes(leftType), rightType) : leftType; - case 56: + case 57: checkAssignmentOperator(rightType); return getRegularTypeOfObjectLiteral(rightType); - case 24: + case 25: if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left)) { error(left, ts.Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects); } @@ -30363,21 +30211,21 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { + case 48: + case 68: + return 53; + case 49: + case 69: + return 34; case 47: case 67: return 52; - case 48: - case 68: - return 33; - case 46: - case 66: - return 51; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 56 && operator <= 68) { + if (produceDiagnostics && operator >= 57 && operator <= 69) { 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_or_a_read_only_property); if (ok) { checkTypeAssignableTo(valueType, leftType, left, undefined); @@ -30449,9 +30297,9 @@ var ts; return getFreshTypeOfLiteralType(getLiteralTypeForText(32, node.text)); case 8: return getFreshTypeOfLiteralType(getLiteralTypeForText(64, node.text)); - case 99: + case 100: return trueType; - case 84: + case 85: return falseType; } } @@ -30480,7 +30328,7 @@ var ts; } function isTypeAssertion(node) { node = skipParenthesizedNodes(node); - return node.kind === 177 || node.kind === 195; + return node.kind === 178 || node.kind === 196; } function checkDeclarationInitializer(declaration) { var type = checkExpressionCached(declaration.initializer); @@ -30506,14 +30354,14 @@ var ts; return isTypeAssertion(node) || isLiteralContextualType(getContextualType(node)) ? type : getWidenedLiteralType(type); } function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 140) { + if (node.name.kind === 141) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, contextualMapper); } function checkObjectLiteralMethod(node, contextualMapper) { checkGrammarMethod(node); - if (node.name.kind === 140) { + if (node.name.kind === 141) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -30536,7 +30384,7 @@ var ts; } function checkExpression(node, contextualMapper) { var type; - if (node.kind === 139) { + if (node.kind === 140) { type = checkQualifiedName(node); } else { @@ -30544,9 +30392,9 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 172 && node.parent.expression === node) || - (node.parent.kind === 173 && node.parent.expression === node) || - ((node.kind === 69 || node.kind === 139) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 173 && node.parent.expression === node) || + (node.parent.kind === 174 && node.parent.expression === node) || + ((node.kind === 70 || node.kind === 140) && 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); } @@ -30555,79 +30403,79 @@ var ts; } function checkExpressionWorker(node, contextualMapper) { switch (node.kind) { - case 69: + case 70: return checkIdentifier(node); - case 97: + case 98: return checkThisExpression(node); - case 95: + case 96: return checkSuperExpression(node); - case 93: + case 94: return nullWideningType; case 9: case 8: - case 99: - case 84: + case 100: + case 85: return checkLiteralExpression(node); - case 189: - return checkTemplateExpression(node); - case 11: - return stringType; - case 10: - return globalRegExpType; - case 170: - return checkArrayLiteral(node, contextualMapper); - case 171: - return checkObjectLiteral(node, contextualMapper); - case 172: - return checkPropertyAccessExpression(node); - case 173: - return checkIndexedAccess(node); - case 174: - case 175: - return checkCallExpression(node); - case 176: - return checkTaggedTemplateExpression(node); - case 178: - return checkExpression(node.expression, contextualMapper); - case 192: - return checkClassExpression(node); - case 179: - case 180: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 182: - return checkTypeOfExpression(node); - case 177: - case 195: - return checkAssertion(node); - case 196: - return checkNonNullAssertion(node); - case 181: - return checkDeleteExpression(node); - case 183: - return checkVoidExpression(node); - case 184: - return checkAwaitExpression(node); - case 185: - return checkPrefixUnaryExpression(node); - case 186: - return checkPostfixUnaryExpression(node); - case 187: - return checkBinaryExpression(node, contextualMapper); - case 188: - return checkConditionalExpression(node, contextualMapper); - case 191: - return checkSpreadElementExpression(node, contextualMapper); - case 193: - return undefinedWideningType; case 190: + return checkTemplateExpression(node); + case 12: + return stringType; + case 11: + return globalRegExpType; + case 171: + return checkArrayLiteral(node, contextualMapper); + case 172: + return checkObjectLiteral(node, contextualMapper); + case 173: + return checkPropertyAccessExpression(node); + case 174: + return checkIndexedAccess(node); + case 175: + case 176: + return checkCallExpression(node); + case 177: + return checkTaggedTemplateExpression(node); + case 179: + return checkExpression(node.expression, contextualMapper); + case 193: + return checkClassExpression(node); + case 180: + case 181: + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); + case 183: + return checkTypeOfExpression(node); + case 178: + case 196: + return checkAssertion(node); + case 197: + return checkNonNullAssertion(node); + case 182: + return checkDeleteExpression(node); + case 184: + return checkVoidExpression(node); + case 185: + return checkAwaitExpression(node); + case 186: + return checkPrefixUnaryExpression(node); + case 187: + return checkPostfixUnaryExpression(node); + case 188: + return checkBinaryExpression(node, contextualMapper); + case 189: + return checkConditionalExpression(node, contextualMapper); + case 192: + return checkSpreadElementExpression(node, contextualMapper); + case 194: + return undefinedWideningType; + case 191: return checkYieldExpression(node); case 248: return checkJsxExpression(node); - case 241: - return checkJsxElement(node); case 242: - return checkJsxSelfClosingElement(node); + return checkJsxElement(node); case 243: + return checkJsxSelfClosingElement(node); + case 244: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -30648,7 +30496,7 @@ var ts; var func = ts.getContainingFunction(node); if (ts.getModifierFlags(node) & 92) { func = ts.getContainingFunction(node); - if (!(func.kind === 148 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 149 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -30659,7 +30507,7 @@ var ts; if (ts.indexOf(func.parameters, node) !== 0) { error(node, ts.Diagnostics.A_this_parameter_must_be_the_first_parameter); } - if (func.kind === 148 || func.kind === 152 || func.kind === 157) { + if (func.kind === 149 || func.kind === 153 || func.kind === 158) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } } @@ -30671,15 +30519,15 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 147 || - node.kind === 220 || - node.kind === 179; + return node.kind === 148 || + node.kind === 221 || + node.kind === 180; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 69 && + if (param.name.kind === 70 && param.name.text === parameter.text) { return i; } @@ -30714,9 +30562,9 @@ var ts; else if (parameterName) { var hasReportedError = false; for (var _i = 0, _a = parent.parameters; _i < _a.length; _i++) { - var name_21 = _a[_i].name; - if (ts.isBindingPattern(name_21) && - checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_21, parameterName, typePredicate.parameterName)) { + var name_18 = _a[_i].name; + if (ts.isBindingPattern(name_18) && + checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_18, parameterName, typePredicate.parameterName)) { hasReportedError = true; break; } @@ -30729,13 +30577,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { + case 181: + case 152: + case 221: case 180: - case 151: - case 220: - case 179: - case 156: + case 157: + case 148: case 147: - case 146: var parent_12 = node.parent; if (node === parent_12.type) { return parent_12; @@ -30748,27 +30596,27 @@ var ts; if (ts.isOmittedExpression(element)) { continue; } - var name_22 = element.name; - if (name_22.kind === 69 && - name_22.text === predicateVariableName) { + var name_19 = element.name; + if (name_19.kind === 70 && + name_19.text === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name_22.kind === 168 || - name_22.kind === 167) { - if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_22, predicateVariableNode, predicateVariableName)) { + else if (name_19.kind === 169 || + name_19.kind === 168) { + if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_19, predicateVariableNode, predicateVariableName)) { return true; } } } } function checkSignatureDeclaration(node) { - if (node.kind === 153) { + if (node.kind === 154) { checkGrammarIndexSignature(node); } - else if (node.kind === 156 || node.kind === 220 || node.kind === 157 || - node.kind === 151 || node.kind === 148 || - node.kind === 152) { + else if (node.kind === 157 || node.kind === 221 || node.kind === 158 || + node.kind === 152 || node.kind === 149 || + node.kind === 153) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); @@ -30780,10 +30628,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 152: + case 153: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 151: + case 152: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -30810,11 +30658,17 @@ var ts; } } function checkClassForDuplicateDeclarations(node) { + var Accessor; + (function (Accessor) { + Accessor[Accessor["Getter"] = 1] = "Getter"; + Accessor[Accessor["Setter"] = 2] = "Setter"; + Accessor[Accessor["Property"] = 3] = "Property"; + })(Accessor || (Accessor = {})); var instanceNames = ts.createMap(); var staticNames = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 148) { + if (member.kind === 149) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param)) { @@ -30823,18 +30677,18 @@ var ts; } } else { - var isStatic = ts.forEach(member.modifiers, function (m) { return m.kind === 113; }); + var isStatic = ts.forEach(member.modifiers, function (m) { return m.kind === 114; }); var names = isStatic ? staticNames : instanceNames; var memberName = member.name && ts.getPropertyNameForPropertyNameNode(member.name); if (memberName) { switch (member.kind) { - case 149: + case 150: addName(names, member.name, memberName, 1); break; - case 150: + case 151: addName(names, member.name, memberName, 2); break; - case 145: + case 146: addName(names, member.name, memberName, 3); break; } @@ -30860,12 +30714,12 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind == 144) { + if (member.kind == 145) { var memberName = void 0; switch (member.name.kind) { case 9: case 8: - case 69: + case 70: memberName = member.name.text; break; default: @@ -30882,7 +30736,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 222) { + if (node.kind === 223) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -30897,7 +30751,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 132: + case 133: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -30905,7 +30759,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 130: + case 131: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -30961,15 +30815,15 @@ var ts; return ts.forEachChild(n, containsSuperCall); } function markThisReferencesAsErrors(n) { - if (n.kind === 97) { + if (n.kind === 98) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 179 && n.kind !== 220) { + else if (n.kind !== 180 && n.kind !== 221) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 145 && + return n.kind === 146 && !(ts.getModifierFlags(n) & 32) && !!n.initializer; } @@ -30989,7 +30843,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 202 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 203 && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -31012,18 +30866,18 @@ var ts; checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 149) { + if (node.kind === 150) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 128)) { if (!(node.flags & 256)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); } } } - if (node.name.kind === 140) { + if (node.name.kind === 141) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { - var otherKind = node.kind === 149 ? 150 : 149; + var otherKind = node.kind === 150 ? 151 : 150; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if ((ts.getModifierFlags(node) & 28) !== (ts.getModifierFlags(otherAccessor) & 28)) { @@ -31037,11 +30891,11 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 149) { + if (node.kind === 150) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } - if (node.parent.kind !== 171) { + if (node.parent.kind !== 172) { checkSourceElement(node.body); registerForUnusedIdentifiersCheck(node); } @@ -31127,9 +30981,9 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); - if (n.parent.kind !== 222 && - n.parent.kind !== 221 && - n.parent.kind !== 192 && + if (n.parent.kind !== 223 && + n.parent.kind !== 222 && + n.parent.kind !== 193 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { flags |= 1; @@ -31206,7 +31060,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) { - var reportError = (node.kind === 147 || node.kind === 146) && + var reportError = (node.kind === 148 || node.kind === 147) && (ts.getModifierFlags(node) & 32) !== (ts.getModifierFlags(subsequentNode) & 32); if (reportError) { var diagnostic = ts.getModifierFlags(node) & 32 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; @@ -31239,11 +31093,11 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 222 || node.parent.kind === 159 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 223 || node.parent.kind === 160 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 220 || node.kind === 147 || node.kind === 146 || node.kind === 148) { + if (node.kind === 221 || node.kind === 148 || node.kind === 147 || node.kind === 149) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -31354,16 +31208,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 222: + case 223: return 2097152; - case 225: + case 226: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 221: - case 224: + case 222: + case 225: return 2097152 | 1048576; - case 229: + case 230: var result_2 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_2 |= getDeclarationSpaces(d); }); @@ -31511,22 +31365,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 221: + case 222: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 142: + case 143: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 145: + case 146: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 147: - case 149: + case 148: case 150: + case 151: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -31535,9 +31389,9 @@ var ts; checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, errorInfo); } function checkTypeNodeAsExpression(node) { - if (node && node.kind === 155) { + if (node && node.kind === 156) { var root = getFirstIdentifier(node.typeName); - var meaning = root.parent.kind === 155 ? 793064 : 1920; + var meaning = root.parent.kind === 156 ? 793064 : 1920; var rootSymbol = resolveName(root, root.text, meaning | 8388608, undefined, undefined); if (rootSymbol && rootSymbol.flags & 8388608) { var aliasTarget = resolveAlias(rootSymbol); @@ -31571,20 +31425,20 @@ var ts; } if (compilerOptions.emitDecoratorMetadata) { switch (node.kind) { - case 221: + case 222: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 147: - case 149: + case 148: case 150: + case 151: checkParameterTypeAnnotationsAsExpressions(node); checkReturnTypeAnnotationAsExpression(node); break; - case 145: - case 142: + case 146: + case 143: checkTypeAnnotationAsExpression(node); break; } @@ -31604,7 +31458,7 @@ var ts; checkDecorators(node); checkSignatureDeclaration(node); var isAsync = ts.isAsyncFunctionLike(node); - if (node.name && node.name.kind === 140) { + if (node.name && node.name.kind === 141) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { @@ -31647,42 +31501,42 @@ var ts; var node = deferredUnusedIdentifierNodes_1[_i]; switch (node.kind) { case 256: - case 225: + case 226: checkUnusedModuleMembers(node); break; - case 221: - case 192: + case 222: + case 193: checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; - case 222: + case 223: checkUnusedTypeParameters(node); break; - case 199: - case 227: - case 206: + case 200: + case 228: case 207: case 208: + case 209: checkUnusedLocalsAndParameters(node); break; - case 148: - case 179: - case 220: - case 180: - case 147: case 149: + case 180: + case 221: + case 181: + case 148: case 150: + case 151: if (node.body) { checkUnusedLocalsAndParameters(node); } checkUnusedTypeParameters(node); break; - case 146: - case 151: + case 147: case 152: case 153: - case 156: + case 154: case 157: + case 158: checkUnusedTypeParameters(node); break; } @@ -31691,11 +31545,11 @@ var ts; } } function checkUnusedLocalsAndParameters(node) { - if (node.parent.kind !== 222 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { + if (node.parent.kind !== 223 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { var _loop_1 = function (key) { var local = node.locals[key]; if (!local.isReferenced) { - if (local.valueDeclaration && local.valueDeclaration.kind === 142) { + if (local.valueDeclaration && local.valueDeclaration.kind === 143) { var parameter = local.valueDeclaration; if (compilerOptions.noUnusedParameters && !ts.isParameterPropertyDeclaration(parameter) && @@ -31715,19 +31569,19 @@ var ts; } } function parameterNameStartsWithUnderscore(parameter) { - return parameter.name && parameter.name.kind === 69 && parameter.name.text.charCodeAt(0) === 95; + return parameter.name && parameter.name.kind === 70 && parameter.name.text.charCodeAt(0) === 95; } function checkUnusedClassMembers(node) { if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) { if (node.members) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 147 || member.kind === 145) { + if (member.kind === 148 || member.kind === 146) { if (!member.symbol.isReferenced && ts.getModifierFlags(member) & 8) { error(member.name, ts.Diagnostics._0_is_declared_but_never_used, member.symbol.name); } } - else if (member.kind === 148) { + else if (member.kind === 149) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.getModifierFlags(parameter) & 8) { @@ -31772,7 +31626,7 @@ var ts; } } function checkBlock(node) { - if (node.kind === 199) { + if (node.kind === 200) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -31794,19 +31648,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 145 || - node.kind === 144 || + if (node.kind === 146 || + node.kind === 145 || + node.kind === 148 || node.kind === 147 || - node.kind === 146 || - node.kind === 149 || - node.kind === 150) { + node.kind === 150 || + node.kind === 151) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 142 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 143 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -31820,7 +31674,7 @@ var ts; var current = node; while (current) { if (getNodeCheckFlags(current) & 4) { - var isDeclaration_1 = node.kind !== 69; + var isDeclaration_1 = node.kind !== 70; if (isDeclaration_1) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -31841,7 +31695,7 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 69; + var isDeclaration_2 = node.kind !== 70; if (isDeclaration_2) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -31851,13 +31705,13 @@ var ts; } } function checkCollisionWithRequireExportsInGeneratedCode(node, name) { - if (modulekind >= ts.ModuleKind.ES6) { + if (modulekind >= ts.ModuleKind.ES2015) { return; } if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 225 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 226 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); @@ -31869,7 +31723,7 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "Promise")) { return; } - if (node.kind === 225 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 226 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); @@ -31881,7 +31735,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 3) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 218 && !node.initializer) { + if (node.kind === 219 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -31891,25 +31745,25 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 219); - var container = varDeclList.parent.kind === 200 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 220); + var container = varDeclList.parent.kind === 201 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 199 && ts.isFunctionLike(container.parent) || + (container.kind === 200 && ts.isFunctionLike(container.parent) || + container.kind === 227 || container.kind === 226 || - container.kind === 225 || container.kind === 256); if (!namesShareScope) { - var name_23 = symbolToString(localDeclarationSymbol); - error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_23, name_23); + var name_20 = symbolToString(localDeclarationSymbol); + error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_20, name_20); } } } } } function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 142) { + if (ts.getRootDeclaration(node).kind !== 143) { return; } var func = ts.getContainingFunction(node); @@ -31918,10 +31772,10 @@ var ts; if (ts.isTypeNode(n) || ts.isDeclarationName(n)) { return; } - if (n.kind === 172) { + if (n.kind === 173) { return visit(n.expression); } - else if (n.kind === 69) { + else if (n.kind === 70) { var symbol = resolveName(n, n.text, 107455 | 8388608, undefined, undefined); if (!symbol || symbol === unknownSymbol || !symbol.valueDeclaration) { return; @@ -31932,7 +31786,7 @@ var ts; } var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 142) { + if (symbol.valueDeclaration.kind === 143) { if (symbol.valueDeclaration.pos < node.pos) { return; } @@ -31941,7 +31795,7 @@ var ts; if (ts.isFunctionLike(current.parent)) { return; } - if (current.parent.kind === 145 && + if (current.parent.kind === 146 && !(ts.hasModifier(current.parent, 32)) && ts.isClassLike(current.parent.parent)) { return; @@ -31958,25 +31812,25 @@ var ts; } } function convertAutoToAny(type) { - return type === autoType ? anyType : type; + return type === autoType ? anyType : type === autoArrayType ? anyArrayType : type; } function checkVariableLikeDeclaration(node) { checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 140) { + if (node.name.kind === 141) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 169) { - if (node.propertyName && node.propertyName.kind === 140) { + if (node.kind === 170) { + if (node.propertyName && node.propertyName.kind === 141) { checkComputedPropertyName(node.propertyName); } var parent_13 = node.parent.parent; var parentType = getTypeForBindingElementParent(parent_13); - var name_24 = node.propertyName || node.name; - var property = getPropertyOfType(parentType, getTextOfPropertyName(name_24)); + var name_21 = node.propertyName || node.name; + var property = getPropertyOfType(parentType, getTextOfPropertyName(name_21)); if (parent_13.initializer && property && getParentOfSymbol(property)) { checkClassPropertyAccess(parent_13, parent_13.initializer, parentType, property); } @@ -31984,12 +31838,12 @@ var ts; if (ts.isBindingPattern(node.name)) { ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 142 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 143 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } if (ts.isBindingPattern(node.name)) { - if (node.initializer && node.parent.parent.kind !== 207) { + if (node.initializer && node.parent.parent.kind !== 208) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, undefined); checkParameterInitializer(node); } @@ -31998,7 +31852,7 @@ var ts; var symbol = getSymbolOfNode(node); var type = convertAutoToAny(getTypeOfVariableOrParameterOrProperty(symbol)); if (node === symbol.valueDeclaration) { - if (node.initializer && node.parent.parent.kind !== 207) { + if (node.initializer && node.parent.parent.kind !== 208) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); checkParameterInitializer(node); } @@ -32016,9 +31870,9 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 145 && node.kind !== 144) { + if (node.kind !== 146 && node.kind !== 145) { checkExportsOnMergedDeclarations(node); - if (node.kind === 218 || node.kind === 169) { + if (node.kind === 219 || node.kind === 170) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -32028,8 +31882,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 142 && right.kind === 218) || - (left.kind === 218 && right.kind === 142)) { + if ((left.kind === 143 && right.kind === 219) || + (left.kind === 219 && right.kind === 143)) { return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { @@ -32056,7 +31910,7 @@ var ts; ts.forEach(node.declarationList.declarations, checkSourceElement); } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { - if (node.modifiers && node.parent.kind === 171) { + if (node.modifiers && node.parent.kind === 172) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -32075,7 +31929,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 201) { + if (node.thenStatement.kind === 202) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -32092,12 +31946,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 219) { + if (node.initializer && node.initializer.kind === 220) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 219) { + if (node.initializer.kind === 220) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -32115,13 +31969,13 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 219) { + if (node.initializer.kind === 220) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 170 || varExpr.kind === 171) { + if (varExpr.kind === 171 || varExpr.kind === 172) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { @@ -32139,7 +31993,7 @@ var ts; } function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 219) { + if (node.initializer.kind === 220) { 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); @@ -32149,7 +32003,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 170 || varExpr.kind === 171) { + if (varExpr.kind === 171 || varExpr.kind === 172) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 34)) { @@ -32322,7 +32176,7 @@ var ts; checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatedSetAccessor(node) { - return !!(node.kind === 149 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 150))); + return !!(node.kind === 150 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 151))); } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { var unwrappedReturnType = ts.isAsyncFunctionLike(func) ? getPromisedType(returnType) : returnType; @@ -32344,12 +32198,12 @@ var ts; if (func.asteriskToken) { return; } - if (func.kind === 150) { + if (func.kind === 151) { if (node.expression) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 148) { + else if (func.kind === 149) { if (node.expression && !checkTypeAssignableTo(exprType, returnType, node.expression)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -32367,7 +32221,7 @@ var ts; } } } - else if (func.kind !== 148 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 149 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } } @@ -32424,7 +32278,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 214 && current.label.text === node.label.text) { + if (current.kind === 215 && 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; @@ -32450,7 +32304,7 @@ var ts; var catchClause = node.catchClause; if (catchClause) { if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 69) { + if (catchClause.variableDeclaration.name.kind !== 70) { grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); } else if (catchClause.variableDeclaration.type) { @@ -32518,7 +32372,7 @@ var ts; return; } var errorNode; - if (prop.valueDeclaration.name.kind === 140 || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 141 || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -32569,7 +32423,7 @@ var ts; var firstDecl; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 221 || declaration.kind === 222) { + if (declaration.kind === 222 || declaration.kind === 223) { if (!firstDecl) { firstDecl = declaration; } @@ -32706,7 +32560,7 @@ var ts; if (derived === base) { var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); if (baseDeclarationFlags & 128 && (!derivedClassDecl || !(ts.getModifierFlags(derivedClassDecl) & 128))) { - if (derivedClassDecl.kind === 192) { + if (derivedClassDecl.kind === 193) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -32750,7 +32604,7 @@ var ts; } } function isAccessor(kind) { - return kind === 149 || kind === 150; + return kind === 150 || kind === 151; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -32817,7 +32671,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(node, symbol); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 222); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 223); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -32912,18 +32766,18 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 185: + case 186: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; } switch (e.operator) { - case 35: return value_1; - case 36: return -value_1; - case 50: return ~value_1; + case 36: return value_1; + case 37: return -value_1; + case 51: return ~value_1; } return undefined; - case 187: + case 188: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -32933,37 +32787,37 @@ var ts; return undefined; } switch (e.operatorToken.kind) { - 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 39: return left / right; - case 35: return left + right; - case 36: return left - right; - case 40: return left % right; + case 48: return left | right; + case 47: return left & right; + case 45: return left >> right; + case 46: return left >>> right; + case 44: return left << right; + case 49: return left ^ right; + case 38: return left * right; + case 40: return left / right; + case 36: return left + right; + case 37: return left - right; + case 41: return left % right; } return undefined; case 8: return +e.text; - case 178: + case 179: return evalConstant(e.expression); - case 69: + case 70: + case 174: case 173: - case 172: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; var propertyName = void 0; - if (e.kind === 69) { + if (e.kind === 70) { enumType_1 = currentType; propertyName = e.text; } else { var expression = void 0; - if (e.kind === 173) { + if (e.kind === 174) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9) { return undefined; @@ -32977,10 +32831,10 @@ var ts; } var current = expression; while (current) { - if (current.kind === 69) { + if (current.kind === 70) { break; } - else if (current.kind === 172) { + else if (current.kind === 173) { current = current.expression; } else { @@ -33040,7 +32894,7 @@ var ts; } var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 224) { + if (declaration.kind !== 225) { return false; } var enumDeclaration = declaration; @@ -33063,8 +32917,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { var declaration = declarations_5[_i]; - if ((declaration.kind === 221 || - (declaration.kind === 220 && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 222 || + (declaration.kind === 221 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -33123,7 +32977,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, 221); + var mergedClass = ts.getDeclarationOfKind(symbol, 222); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -33166,36 +33020,36 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 200: + case 201: for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 235: case 236: + case 237: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 229: case 230: + case 231: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 169: - case 218: - var name_25 = node.name; - if (ts.isBindingPattern(name_25)) { - for (var _b = 0, _c = name_25.elements; _b < _c.length; _b++) { + case 170: + case 219: + var name_22 = node.name; + if (ts.isBindingPattern(name_22)) { + for (var _b = 0, _c = name_22.elements; _b < _c.length; _b++) { var el = _c[_b]; checkModuleAugmentationElement(el, isGlobalAugmentation); } break; } - case 221: - case 224: - case 220: case 222: case 225: + case 221: case 223: + case 226: + case 224: if (isGlobalAugmentation) { return; } @@ -33211,17 +33065,17 @@ var ts; } function getFirstIdentifier(node) { switch (node.kind) { - case 69: + case 70: return node; - case 139: + case 140: do { node = node.left; - } while (node.kind !== 69); + } while (node.kind !== 70); return node; - case 172: + case 173: do { node = node.expression; - } while (node.kind !== 69); + } while (node.kind !== 70); return node; } } @@ -33231,9 +33085,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 226 && ts.isAmbientModule(node.parent.parent); + var inAmbientExternalModule = node.parent.kind === 227 && ts.isAmbientModule(node.parent.parent); if (node.parent.kind !== 256 && !inAmbientExternalModule) { - error(moduleName, node.kind === 236 ? + error(moduleName, node.kind === 237 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -33254,7 +33108,7 @@ var ts; (symbol.flags & 793064 ? 793064 : 0) | (symbol.flags & 1920 ? 1920 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 238 ? + var message = node.kind === 239 ? 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)); @@ -33281,7 +33135,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 232) { + if (importClause.namedBindings.kind === 233) { checkImportBinding(importClause.namedBindings); } else { @@ -33316,7 +33170,7 @@ var ts; } } else { - if (modulekind === ts.ModuleKind.ES6 && !ts.isInAmbientContext(node)) { + if (modulekind === ts.ModuleKind.ES2015 && !ts.isInAmbientContext(node)) { grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } } @@ -33332,7 +33186,7 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 226 && ts.isAmbientModule(node.parent.parent); + var inAmbientExternalModule = node.parent.kind === 227 && ts.isAmbientModule(node.parent.parent); if (node.parent.kind !== 256 && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } @@ -33346,7 +33200,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 256 || node.parent.kind === 226 || node.parent.kind === 225; + var isInAppropriateContext = node.parent.kind === 256 || node.parent.kind === 227 || node.parent.kind === 226; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -33370,14 +33224,14 @@ var ts; return; } var container = node.parent.kind === 256 ? node.parent : node.parent.parent; - if (container.kind === 225 && !ts.isAmbientModule(container)) { + if (container.kind === 226 && !ts.isAmbientModule(container)) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.getModifierFlags(node) !== 0) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 69) { + if (node.expression.kind === 70) { markExportAsReferenced(node); } else { @@ -33385,7 +33239,7 @@ var ts; } checkExternalModuleExports(container); if (node.isExportEquals && !ts.isInAmbientContext(node)) { - if (modulekind === ts.ModuleKind.ES6) { + if (modulekind === ts.ModuleKind.ES2015) { grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_export_default_or_another_module_format_instead); } else if (modulekind === ts.ModuleKind.System) { @@ -33437,7 +33291,7 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return (declaration.kind !== 220 && declaration.kind !== 147) || + return (declaration.kind !== 221 && declaration.kind !== 148) || !!declaration.body; } } @@ -33448,118 +33302,118 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { - case 225: - case 221: + case 226: case 222: - case 220: + case 223: + case 221: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 141: - return checkTypeParameter(node); case 142: + return checkTypeParameter(node); + case 143: return checkParameter(node); + case 146: case 145: - case 144: return checkPropertyDeclaration(node); - case 156: case 157: - case 151: + case 158: case 152: - return checkSignatureDeclaration(node); case 153: return checkSignatureDeclaration(node); - case 147: - case 146: - return checkMethodDeclaration(node); - case 148: - return checkConstructorDeclaration(node); - case 149: - case 150: - return checkAccessorDeclaration(node); - case 155: - return checkTypeReferenceNode(node); case 154: + return checkSignatureDeclaration(node); + case 148: + case 147: + return checkMethodDeclaration(node); + case 149: + return checkConstructorDeclaration(node); + case 150: + case 151: + return checkAccessorDeclaration(node); + case 156: + return checkTypeReferenceNode(node); + case 155: return checkTypePredicate(node); - case 158: - return checkTypeQuery(node); case 159: - return checkTypeLiteral(node); + return checkTypeQuery(node); case 160: - return checkArrayType(node); + return checkTypeLiteral(node); case 161: - return checkTupleType(node); + return checkArrayType(node); case 162: + return checkTupleType(node); case 163: - return checkUnionOrIntersectionType(node); case 164: + return checkUnionOrIntersectionType(node); + case 165: return checkSourceElement(node.type); - case 220: - return checkFunctionDeclaration(node); - case 199: - case 226: - return checkBlock(node); - case 200: - return checkVariableStatement(node); - case 202: - return checkExpressionStatement(node); - case 203: - return checkIfStatement(node); - case 204: - return checkDoStatement(node); - case 205: - return checkWhileStatement(node); - case 206: - return checkForStatement(node); - case 207: - return checkForInStatement(node); - case 208: - return checkForOfStatement(node); - case 209: - case 210: - return checkBreakOrContinueStatement(node); - case 211: - return checkReturnStatement(node); - case 212: - return checkWithStatement(node); - case 213: - return checkSwitchStatement(node); - case 214: - return checkLabeledStatement(node); - case 215: - return checkThrowStatement(node); - case 216: - return checkTryStatement(node); - case 218: - return checkVariableDeclaration(node); - case 169: - return checkBindingElement(node); case 221: - return checkClassDeclaration(node); - case 222: - return checkInterfaceDeclaration(node); - case 223: - return checkTypeAliasDeclaration(node); - case 224: - return checkEnumDeclaration(node); - case 225: - return checkModuleDeclaration(node); - case 230: - return checkImportDeclaration(node); - case 229: - return checkImportEqualsDeclaration(node); - case 236: - return checkExportDeclaration(node); - case 235: - return checkExportAssignment(node); + return checkFunctionDeclaration(node); + case 200: + case 227: + return checkBlock(node); case 201: - checkGrammarStatementInAmbientContext(node); - return; + return checkVariableStatement(node); + case 203: + return checkExpressionStatement(node); + case 204: + return checkIfStatement(node); + case 205: + return checkDoStatement(node); + case 206: + return checkWhileStatement(node); + case 207: + return checkForStatement(node); + case 208: + return checkForInStatement(node); + case 209: + return checkForOfStatement(node); + case 210: + case 211: + return checkBreakOrContinueStatement(node); + case 212: + return checkReturnStatement(node); + case 213: + return checkWithStatement(node); + case 214: + return checkSwitchStatement(node); + case 215: + return checkLabeledStatement(node); + case 216: + return checkThrowStatement(node); case 217: + return checkTryStatement(node); + case 219: + return checkVariableDeclaration(node); + case 170: + return checkBindingElement(node); + case 222: + return checkClassDeclaration(node); + case 223: + return checkInterfaceDeclaration(node); + case 224: + return checkTypeAliasDeclaration(node); + case 225: + return checkEnumDeclaration(node); + case 226: + return checkModuleDeclaration(node); + case 231: + return checkImportDeclaration(node); + case 230: + return checkImportEqualsDeclaration(node); + case 237: + return checkExportDeclaration(node); + case 236: + return checkExportAssignment(node); + case 202: checkGrammarStatementInAmbientContext(node); return; - case 239: + case 218: + checkGrammarStatementInAmbientContext(node); + return; + case 240: return checkMissingDeclaration(node); } } @@ -33572,17 +33426,17 @@ var ts; for (var _i = 0, deferredNodes_1 = deferredNodes; _i < deferredNodes_1.length; _i++) { var node = deferredNodes_1[_i]; switch (node.kind) { - case 179: case 180: + case 181: + case 148: case 147: - case 146: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 149: case 150: + case 151: checkAccessorDeferred(node); break; - case 192: + case 193: checkClassExpressionDeferred(node); break; } @@ -33654,7 +33508,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 212 && node.parent.statement === node) { + if (node.parent.kind === 213 && node.parent.statement === node) { return true; } node = node.parent; @@ -33680,24 +33534,24 @@ var ts; if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 225: + case 226: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 224: + case 225: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 192: + case 193: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 221: case 222: + case 223: if (!(memberFlags & 32)) { copySymbols(getSymbolOfNode(location).members, meaning & 793064); } break; - case 179: + case 180: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -33730,33 +33584,33 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 69 && + return name.kind === 70 && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 141: - case 221: + case 142: case 222: case 223: case 224: + case 225: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 139) { + while (node.parent && node.parent.kind === 140) { node = node.parent; } - return node.parent && (node.parent.kind === 155 || node.parent.kind === 267); + return node.parent && (node.parent.kind === 156 || node.parent.kind === 267); } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 172) { + while (node.parent && node.parent.kind === 173) { node = node.parent; } - return node.parent && node.parent.kind === 194; + return node.parent && node.parent.kind === 195; } function forEachEnclosingClass(node, callback) { var result; @@ -33773,13 +33627,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 139) { + while (nodeOnRightSide.parent.kind === 140) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 229) { + if (nodeOnRightSide.parent.kind === 230) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 235) { + if (nodeOnRightSide.parent.kind === 236) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -33791,7 +33645,7 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 172) { + if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 173) { var specialPropertyAssignmentKind = ts.getSpecialPropertyAssignmentKind(entityName.parent.parent); switch (specialPropertyAssignmentKind) { case 1: @@ -33803,20 +33657,20 @@ var ts; default: } } - if (entityName.parent.kind === 235 && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 236 && ts.isEntityNameExpression(entityName)) { return resolveEntityName(entityName, 107455 | 793064 | 1920 | 8388608); } - if (entityName.kind !== 172 && isInRightSideOfImportOrExportAssignment(entityName)) { - var importEqualsDeclaration = ts.getAncestor(entityName, 229); + if (entityName.kind !== 173 && isInRightSideOfImportOrExportAssignment(entityName)) { + var importEqualsDeclaration = ts.getAncestor(entityName, 230); ts.Debug.assert(importEqualsDeclaration !== undefined); - return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importEqualsDeclaration, true); + return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, true); } if (ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0; - if (entityName.parent.kind === 194) { + if (entityName.parent.kind === 195) { meaning = 793064; if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning |= 107455; @@ -33832,20 +33686,20 @@ var ts; if (ts.nodeIsMissing(entityName)) { return undefined; } - if (entityName.kind === 69) { + if (entityName.kind === 70) { if (ts.isJSXTagName(entityName) && isJsxIntrinsicIdentifier(entityName)) { return getIntrinsicTagSymbol(entityName.parent); } return resolveEntityName(entityName, 107455, false, true); } - else if (entityName.kind === 172) { + else if (entityName.kind === 173) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 139) { + else if (entityName.kind === 140) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -33854,13 +33708,13 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = (entityName.parent.kind === 155 || entityName.parent.kind === 267) ? 793064 : 1920; + var meaning = (entityName.parent.kind === 156 || entityName.parent.kind === 267) ? 793064 : 1920; return resolveEntityName(entityName, meaning, false, true); } else if (entityName.parent.kind === 246) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 154) { + if (entityName.parent.kind === 155) { return resolveEntityName(entityName, 1); } return undefined; @@ -33878,12 +33732,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(node.parent.parent); } - if (node.kind === 69) { + if (node.kind === 70) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (node.parent.kind === 169 && - node.parent.parent.kind === 167 && + else if (node.parent.kind === 170 && + node.parent.parent.kind === 168 && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -33893,11 +33747,11 @@ var ts; } } switch (node.kind) { - case 69: - case 172: - case 139: + case 70: + case 173: + case 140: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 97: + case 98: var container = ts.getThisContainer(node, false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -33905,21 +33759,21 @@ var ts; return sig.thisParameter; } } - case 95: + case 96: var type = ts.isPartOfExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 165: + case 166: return getTypeFromTypeNode(node).symbol; - case 121: + case 122: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 148) { + if (constructorDeclaration && constructorDeclaration.kind === 149) { return constructorDeclaration.parent.symbol; } return undefined; case 9: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 230 || node.parent.kind === 236) && + ((node.parent.kind === 231 || node.parent.kind === 237) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } @@ -33927,7 +33781,7 @@ var ts; return resolveExternalModuleName(node, node); } case 8: - if (node.parent.kind === 173 && node.parent.argumentExpression === node) { + if (node.parent.kind === 174 && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -33991,12 +33845,12 @@ var ts; return unknownType; } function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 171 || expr.kind === 170); - if (expr.parent.kind === 208) { + ts.Debug.assert(expr.kind === 172 || expr.kind === 171); + if (expr.parent.kind === 209) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression); return checkDestructuringAssignment(expr, iteratedType || unknownType); } - if (expr.parent.kind === 187) { + if (expr.parent.kind === 188) { var iteratedType = checkExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || unknownType); } @@ -34004,7 +33858,7 @@ var ts; var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent); } - ts.Debug.assert(expr.parent.kind === 170); + ts.Debug.assert(expr.parent.kind === 171); var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, false) || unknownType; return checkArrayLiteralDestructuringElementAssignment(expr.parent, typeOfArrayLiteral, ts.indexOf(expr.parent.elements, expr), elementType || unknownType); @@ -34040,9 +33894,9 @@ var ts; function getRootSymbols(symbol) { if (symbol.flags & 268435456) { var symbols_3 = []; - var name_26 = symbol.name; + var name_23 = symbol.name; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - var symbol = getPropertyOfType(t, name_26); + var symbol = getPropertyOfType(t, name_23); if (symbol) { symbols_3.push(symbol); } @@ -34145,7 +33999,7 @@ var ts; else if (nodeLinks_1.flags & 131072) { var isDeclaredInLoop = nodeLinks_1.flags & 262144; var inLoopInitializer = ts.isIterationStatement(container, false); - var inLoopBodyBlock = container.kind === 199 && ts.isIterationStatement(container.parent, false); + var inLoopBodyBlock = container.kind === 200 && ts.isIterationStatement(container.parent, false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -34185,18 +34039,18 @@ var ts; return true; } switch (node.kind) { - case 229: - case 231: + case 230: case 232: - case 234: - case 238: + case 233: + case 235: + case 239: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 236: + case 237: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 235: + case 236: return node.expression - && node.expression.kind === 69 + && node.expression.kind === 70 ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : true; } @@ -34428,7 +34282,7 @@ var ts; if (!fileToDirective) { return undefined; } - var meaning = (node.kind === 172) || (node.kind === 69 && isInTypeQuery(node)) + var meaning = (node.kind === 173) || (node.kind === 70 && isInTypeQuery(node)) ? 107455 | 1048576 : 793064 | 1920; var symbol = resolveEntityName(node, meaning, true); @@ -34575,6 +34429,7 @@ var ts; getGlobalIterableIteratorType = ts.memoize(function () { return emptyGenericType; }); } anyArrayType = createArrayType(anyType); + autoArrayType = createArrayType(autoType); var symbol = getGlobalSymbol("ReadonlyArray", 793064, undefined); globalReadonlyArrayType = symbol && getTypeOfGlobalSymbol(symbol, 1); anyReadonlyArrayType = globalReadonlyArrayType ? createTypeFromGenericGlobalType(globalReadonlyArrayType, [anyType]) : anyArrayType; @@ -34634,14 +34489,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node)) { - if (node.kind === 147 && !ts.nodeIsPresent(node.body)) { + if (node.kind === 148 && !ts.nodeIsPresent(node.body)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload); } else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } } - else if (node.kind === 149 || node.kind === 150) { + else if (node.kind === 150 || node.kind === 151) { 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); @@ -34658,28 +34513,28 @@ var ts; var flags = 0; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 128) { - if (node.kind === 144 || node.kind === 146) { + if (modifier.kind !== 129) { + if (node.kind === 145 || node.kind === 147) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 153) { + if (node.kind === 154) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 74: - if (node.kind !== 224 && node.parent.kind === 221) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(74)); + case 75: + if (node.kind !== 225 && node.parent.kind === 222) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(75)); } break; + case 113: case 112: case 111: - case 110: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); - if (modifier.kind === 111) { + if (modifier.kind === 112) { lastProtected = modifier; } - else if (modifier.kind === 110) { + else if (modifier.kind === 111) { lastPrivate = modifier; } if (flags & 28) { @@ -34694,11 +34549,11 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 226 || node.parent.kind === 256) { + else if (node.parent.kind === 227 || node.parent.kind === 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128) { - if (modifier.kind === 110) { + if (modifier.kind === 111) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -34707,7 +34562,7 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 113: + case 114: if (flags & 32) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } @@ -34717,10 +34572,10 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 226 || node.parent.kind === 256) { + else if (node.parent.kind === 227 || node.parent.kind === 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 142) { + else if (node.kind === 143) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128) { @@ -34729,17 +34584,17 @@ var ts; flags |= 32; lastStatic = modifier; break; - case 128: + case 129: if (flags & 64) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 145 && node.kind !== 144 && node.kind !== 153 && node.kind !== 142) { + else if (node.kind !== 146 && node.kind !== 145 && node.kind !== 154 && node.kind !== 143) { return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } flags |= 64; lastReadonly = modifier; break; - case 82: + case 83: if (flags & 1) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -34752,45 +34607,45 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 221) { + else if (node.parent.kind === 222) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 142) { + else if (node.kind === 143) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; break; - case 122: + case 123: if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 221) { + else if (node.parent.kind === 222) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 142) { + else if (node.kind === 143) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 226) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 227) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; lastDeclare = modifier; break; - case 115: + case 116: if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 221) { - if (node.kind !== 147 && - node.kind !== 145 && - node.kind !== 149 && - node.kind !== 150) { + if (node.kind !== 222) { + if (node.kind !== 148 && + node.kind !== 146 && + node.kind !== 150 && + node.kind !== 151) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 221 && ts.getModifierFlags(node.parent) & 128)) { + if (!(node.parent.kind === 222 && ts.getModifierFlags(node.parent) & 128)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32) { @@ -34802,14 +34657,14 @@ var ts; } flags |= 128; break; - case 118: + case 119: if (flags & 256) { 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 === 142) { + else if (node.kind === 143) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256; @@ -34817,7 +34672,7 @@ var ts; break; } } - if (node.kind === 148) { + if (node.kind === 149) { if (flags & 32) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -34832,13 +34687,13 @@ var ts; } return; } - else if ((node.kind === 230 || node.kind === 229) && flags & 2) { + else if ((node.kind === 231 || node.kind === 230) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 142 && (flags & 92) && ts.isBindingPattern(node.name)) { + else if (node.kind === 143 && (flags & 92) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 142 && (flags & 92) && node.dotDotDotToken) { + else if (node.kind === 143 && (flags & 92) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256) { @@ -34854,38 +34709,38 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 149: case 150: - case 148: - case 145: - case 144: - case 147: + case 151: + case 149: case 146: - case 153: - case 225: + case 145: + case 148: + case 147: + case 154: + case 226: + case 231: case 230: - case 229: + case 237: case 236: - case 235: - case 179: case 180: - case 142: + case 181: + case 143: return false; default: - if (node.parent.kind === 226 || node.parent.kind === 256) { + if (node.parent.kind === 227 || node.parent.kind === 256) { return false; } switch (node.kind) { - case 220: - return nodeHasAnyModifiersExcept(node, 118); case 221: - return nodeHasAnyModifiersExcept(node, 115); + return nodeHasAnyModifiersExcept(node, 119); case 222: - case 200: + return nodeHasAnyModifiersExcept(node, 116); case 223: - return true; + case 201: case 224: - return nodeHasAnyModifiersExcept(node, 74); + return true; + case 225: + return nodeHasAnyModifiersExcept(node, 75); default: ts.Debug.fail(); return false; @@ -34897,10 +34752,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 147: - case 220: - case 179: + case 148: + case 221: case 180: + case 181: if (!node.asteriskToken) { return false; } @@ -34916,7 +34771,7 @@ var ts; return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Trailing_comma_not_allowed); } } - function checkGrammarTypeParameterList(node, typeParameters, file) { + function checkGrammarTypeParameterList(typeParameters, file) { if (checkGrammarForDisallowedTrailingComma(typeParameters)) { return true; } @@ -34958,11 +34813,11 @@ var ts; } function checkGrammarFunctionLikeDeclaration(node) { var file = ts.getSourceFileOfNode(node); - return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node, node.typeParameters, file) || + return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node.typeParameters, file) || checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 180) { + if (node.kind === 181) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -34997,7 +34852,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 !== 132 && parameter.type.kind !== 130) { + if (parameter.type.kind !== 133 && parameter.type.kind !== 131) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -35024,7 +34879,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 193) { + if (arg.kind === 194) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -35050,7 +34905,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 === 83) { + if (heritageClause.token === 84) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -35063,7 +34918,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 106); + ts.Debug.assert(heritageClause.token === 107); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -35078,14 +34933,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 83) { + if (heritageClause.token === 84) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 106); + ts.Debug.assert(heritageClause.token === 107); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } checkGrammarHeritageClause(heritageClause); @@ -35094,19 +34949,19 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 140) { + if (node.kind !== 141) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 187 && computedPropertyName.expression.operatorToken.kind === 24) { + if (computedPropertyName.expression.kind === 188 && computedPropertyName.expression.operatorToken.kind === 25) { 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 === 220 || - node.kind === 179 || - node.kind === 147); + ts.Debug.assert(node.kind === 221 || + node.kind === 180 || + node.kind === 148); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -35118,7 +34973,7 @@ var ts; } } } - function checkGrammarForInvalidQuestionMark(node, questionToken, message) { + function checkGrammarForInvalidQuestionMark(questionToken, message) { if (questionToken) { return grammarErrorOnNode(questionToken, message); } @@ -35131,9 +34986,9 @@ var ts; var GetOrSetAccessor = GetAccessor | SetAccessor; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - var name_27 = prop.name; - if (name_27.kind === 140) { - checkGrammarComputedPropertyName(name_27); + var name_24 = prop.name; + if (name_24.kind === 141) { + checkGrammarComputedPropertyName(name_24); } if (prop.kind === 254 && !inDestructuring && prop.objectAssignmentInitializer) { return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); @@ -35141,32 +34996,32 @@ var ts; if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (mod.kind !== 118 || prop.kind !== 147) { + if (mod.kind !== 119 || prop.kind !== 148) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } } var currentKind = void 0; if (prop.kind === 253 || prop.kind === 254) { - checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_27.kind === 8) { - checkGrammarNumericLiteral(name_27); + checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); + if (name_24.kind === 8) { + checkGrammarNumericLiteral(name_24); } currentKind = Property; } - else if (prop.kind === 147) { + else if (prop.kind === 148) { currentKind = Property; } - else if (prop.kind === 149) { + else if (prop.kind === 150) { currentKind = GetAccessor; } - else if (prop.kind === 150) { + else if (prop.kind === 151) { currentKind = SetAccessor; } else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - var effectiveName = ts.getPropertyNameForPropertyNameNode(name_27); + var effectiveName = ts.getPropertyNameForPropertyNameNode(name_24); if (effectiveName === undefined) { continue; } @@ -35176,18 +35031,18 @@ var ts; else { var existingKind = seen[effectiveName]; if (currentKind === Property && existingKind === Property) { - grammarErrorOnNode(name_27, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_27)); + grammarErrorOnNode(name_24, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_24)); } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { seen[effectiveName] = currentKind | existingKind; } else { - return grammarErrorOnNode(name_27, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name_24, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name_27, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name_24, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } @@ -35200,12 +35055,12 @@ var ts; continue; } var jsxAttr = attr; - var name_28 = jsxAttr.name; - if (!seen[name_28.text]) { - seen[name_28.text] = true; + var name_25 = jsxAttr.name; + if (!seen[name_25.text]) { + seen[name_25.text] = true; } else { - return grammarErrorOnNode(name_28, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + return grammarErrorOnNode(name_25, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; if (initializer && initializer.kind === 248 && !initializer.expression) { @@ -35217,7 +35072,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 219) { + if (forInOrOfStatement.initializer.kind === 220) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -35225,20 +35080,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 207 + var diagnostic = forInOrOfStatement.kind === 208 ? 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 = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 207 + var diagnostic = forInOrOfStatement.kind === 208 ? 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 === 207 + var diagnostic = forInOrOfStatement.kind === 208 ? 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); @@ -35262,11 +35117,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 149 ? + return grammarErrorOnNode(accessor.name, kind === 150 ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 150) { + else if (kind === 151) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -35285,10 +35140,10 @@ var ts; } } function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 149 ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 150 ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 149 ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 150 ? 1 : 2)) { return ts.getThisParameter(accessor); } } @@ -35303,8 +35158,8 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 171) { - if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { + if (node.parent.kind === 172) { + if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { return true; } else if (node.body === undefined) { @@ -35319,10 +35174,10 @@ 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 === 222) { + else if (node.parent.kind === 223) { 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 === 159) { + else if (node.parent.kind === 160) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } @@ -35333,9 +35188,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 214: + case 215: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 209 + var isMisplacedContinueLabel = node.kind === 210 && !ts.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); @@ -35343,8 +35198,8 @@ var ts; return false; } break; - case 213: - if (node.kind === 210 && !node.label) { + case 214: + if (node.kind === 211 && !node.label) { return false; } break; @@ -35357,13 +35212,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 210 + var message = node.kind === 211 ? 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 === 210 + var message = node.kind === 211 ? 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); @@ -35375,7 +35230,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 === 168 || node.name.kind === 167) { + if (node.name.kind === 169 || node.name.kind === 168) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -35385,11 +35240,11 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 || expr.kind === 8 || - expr.kind === 185 && expr.operator === 36 && + expr.kind === 186 && expr.operator === 37 && expr.operand.kind === 8; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 207 && node.parent.parent.kind !== 208) { + if (node.parent.parent.kind !== 208 && node.parent.parent.kind !== 209) { if (ts.isInAmbientContext(node)) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -35420,8 +35275,8 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 69) { - if (name.originalKeywordKind === 108) { + if (name.kind === 70) { + if (name.originalKeywordKind === 109) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -35446,15 +35301,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 203: case 204: case 205: - case 212: case 206: + case 213: case 207: case 208: + case 209: return false; - case 214: + case 215: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -35509,7 +35364,7 @@ var ts; return true; } } - else if (node.parent.kind === 222) { + else if (node.parent.kind === 223) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -35517,7 +35372,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 159) { + else if (node.parent.kind === 160) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -35530,13 +35385,13 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 222 || - node.kind === 223 || + if (node.kind === 223 || + node.kind === 224 || + node.kind === 231 || node.kind === 230 || - node.kind === 229 || + node.kind === 237 || node.kind === 236 || - node.kind === 235 || - node.kind === 228 || + node.kind === 229 || ts.getModifierFlags(node) & (2 | 1 | 512)) { return false; } @@ -35545,7 +35400,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 === 200) { + if (ts.isDeclaration(decl) || decl.kind === 201) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -35564,7 +35419,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 === 199 || node.parent.kind === 226 || node.parent.kind === 256) { + if (node.parent.kind === 200 || node.parent.kind === 227 || node.parent.kind === 256) { 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); @@ -35603,46 +35458,46 @@ var ts; (function (ts) { ; var nodeEdgeTraversalMap = ts.createMap((_a = {}, - _a[139] = [ + _a[140] = [ { name: "left", test: ts.isEntityName }, { name: "right", test: ts.isIdentifier } ], - _a[143] = [ + _a[144] = [ { name: "expression", test: ts.isLeftHandSideExpression } ], - _a[177] = [ + _a[178] = [ { name: "type", test: ts.isTypeNode }, { name: "expression", test: ts.isUnaryExpression } ], - _a[195] = [ + _a[196] = [ { name: "expression", test: ts.isExpression }, { name: "type", test: ts.isTypeNode } ], - _a[196] = [ + _a[197] = [ { name: "expression", test: ts.isLeftHandSideExpression } ], - _a[224] = [ + _a[225] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "members", test: ts.isEnumMember } ], - _a[225] = [ + _a[226] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isModuleName }, { name: "body", test: ts.isModuleBody } ], - _a[226] = [ + _a[227] = [ { name: "statements", test: ts.isStatement } ], - _a[229] = [ + _a[230] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "moduleReference", test: ts.isModuleReference } ], - _a[240] = [ + _a[241] = [ { name: "expression", test: ts.isExpression, optional: true } ], _a[255] = [ @@ -35658,41 +35513,41 @@ var ts; return initial; } var kind = node.kind; - if ((kind > 0 && kind <= 138)) { + if ((kind > 0 && kind <= 139)) { return initial; } - if ((kind >= 154 && kind <= 166)) { + if ((kind >= 155 && kind <= 167)) { return initial; } var result = initial; switch (node.kind) { - case 198: - case 201: - case 193: - case 217: + case 199: + case 202: + case 194: + case 218: case 287: break; - case 140: + case 141: result = reduceNode(node.expression, f, result); break; - case 142: - result = ts.reduceLeft(node.decorators, f, result); - result = ts.reduceLeft(node.modifiers, f, result); - result = reduceNode(node.name, f, result); - result = reduceNode(node.type, f, result); - result = reduceNode(node.initializer, f, result); - break; case 143: - result = reduceNode(node.expression, f, result); - break; - case 145: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.initializer, f, result); break; - case 147: + case 144: + result = reduceNode(node.expression, f, result); + break; + case 146: + result = ts.reduceLeft(node.decorators, f, result); + result = ts.reduceLeft(node.modifiers, f, result); + result = reduceNode(node.name, f, result); + result = reduceNode(node.type, f, result); + result = reduceNode(node.initializer, f, result); + break; + case 148: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -35701,53 +35556,48 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 148: - result = ts.reduceLeft(node.modifiers, f, result); - result = ts.reduceLeft(node.parameters, f, result); - result = reduceNode(node.body, f, result); - break; case 149: - result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); - result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.parameters, f, result); - result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; case 150: + result = ts.reduceLeft(node.decorators, f, result); + result = ts.reduceLeft(node.modifiers, f, result); + result = reduceNode(node.name, f, result); + result = ts.reduceLeft(node.parameters, f, result); + result = reduceNode(node.type, f, result); + result = reduceNode(node.body, f, result); + break; + case 151: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.parameters, f, result); result = reduceNode(node.body, f, result); break; - case 167: case 168: + case 169: result = ts.reduceLeft(node.elements, f, result); break; - case 169: + case 170: result = reduceNode(node.propertyName, f, result); result = reduceNode(node.name, f, result); result = reduceNode(node.initializer, f, result); break; - case 170: + case 171: result = ts.reduceLeft(node.elements, f, result); break; - case 171: - result = ts.reduceLeft(node.properties, f, result); - break; case 172: - result = reduceNode(node.expression, f, result); - result = reduceNode(node.name, f, result); + result = ts.reduceLeft(node.properties, f, result); break; case 173: result = reduceNode(node.expression, f, result); - result = reduceNode(node.argumentExpression, f, result); + result = reduceNode(node.name, f, result); break; case 174: result = reduceNode(node.expression, f, result); - result = ts.reduceLeft(node.typeArguments, f, result); - result = ts.reduceLeft(node.arguments, f, result); + result = reduceNode(node.argumentExpression, f, result); break; case 175: result = reduceNode(node.expression, f, result); @@ -35755,10 +35605,15 @@ var ts; result = ts.reduceLeft(node.arguments, f, result); break; case 176: + result = reduceNode(node.expression, f, result); + result = ts.reduceLeft(node.typeArguments, f, result); + result = ts.reduceLeft(node.arguments, f, result); + break; + case 177: result = reduceNode(node.tag, f, result); result = reduceNode(node.template, f, result); break; - case 179: + case 180: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.typeParameters, f, result); @@ -35766,126 +35621,126 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 180: + case 181: result = ts.reduceLeft(node.modifiers, f, result); result = ts.reduceLeft(node.typeParameters, f, result); result = ts.reduceLeft(node.parameters, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 178: - case 181: + case 179: case 182: case 183: case 184: - case 190: + case 185: case 191: - case 196: + case 192: + case 197: result = reduceNode(node.expression, f, result); break; - case 185: case 186: + case 187: result = reduceNode(node.operand, f, result); break; - case 187: + case 188: result = reduceNode(node.left, f, result); result = reduceNode(node.right, f, result); break; - case 188: + case 189: result = reduceNode(node.condition, f, result); result = reduceNode(node.whenTrue, f, result); result = reduceNode(node.whenFalse, f, result); break; - case 189: + case 190: result = reduceNode(node.head, f, result); result = ts.reduceLeft(node.templateSpans, f, result); break; - case 192: + case 193: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.typeParameters, f, result); result = ts.reduceLeft(node.heritageClauses, f, result); result = ts.reduceLeft(node.members, f, result); break; - case 194: + case 195: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); break; - case 197: + case 198: result = reduceNode(node.expression, f, result); result = reduceNode(node.literal, f, result); break; - case 199: + case 200: result = ts.reduceLeft(node.statements, f, result); break; - case 200: + case 201: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.declarationList, f, result); break; - case 202: + case 203: result = reduceNode(node.expression, f, result); break; - case 203: + case 204: result = reduceNode(node.expression, f, result); result = reduceNode(node.thenStatement, f, result); result = reduceNode(node.elseStatement, f, result); break; - case 204: - result = reduceNode(node.statement, f, result); - result = reduceNode(node.expression, f, result); - break; case 205: - case 212: - result = reduceNode(node.expression, f, result); result = reduceNode(node.statement, f, result); + result = reduceNode(node.expression, f, result); break; case 206: + case 213: + result = reduceNode(node.expression, f, result); + result = reduceNode(node.statement, f, result); + break; + case 207: result = reduceNode(node.initializer, f, result); result = reduceNode(node.condition, f, result); result = reduceNode(node.incrementor, f, result); result = reduceNode(node.statement, f, result); break; - case 207: case 208: + case 209: result = reduceNode(node.initializer, f, result); result = reduceNode(node.expression, f, result); result = reduceNode(node.statement, f, result); break; - case 211: - case 215: + case 212: + case 216: result = reduceNode(node.expression, f, result); break; - case 213: + case 214: result = reduceNode(node.expression, f, result); result = reduceNode(node.caseBlock, f, result); break; - case 214: + case 215: result = reduceNode(node.label, f, result); result = reduceNode(node.statement, f, result); break; - case 216: + case 217: result = reduceNode(node.tryBlock, f, result); result = reduceNode(node.catchClause, f, result); result = reduceNode(node.finallyBlock, f, result); break; - case 218: + case 219: result = reduceNode(node.name, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.initializer, f, result); break; - case 219: - result = ts.reduceLeft(node.declarations, f, result); - break; case 220: - result = ts.reduceLeft(node.decorators, f, result); - result = ts.reduceLeft(node.modifiers, f, result); - result = reduceNode(node.name, f, result); - result = ts.reduceLeft(node.typeParameters, f, result); - result = ts.reduceLeft(node.parameters, f, result); - result = reduceNode(node.type, f, result); - result = reduceNode(node.body, f, result); + result = ts.reduceLeft(node.declarations, f, result); break; case 221: + result = ts.reduceLeft(node.decorators, f, result); + result = ts.reduceLeft(node.modifiers, f, result); + result = reduceNode(node.name, f, result); + result = ts.reduceLeft(node.typeParameters, f, result); + result = ts.reduceLeft(node.parameters, f, result); + result = reduceNode(node.type, f, result); + result = reduceNode(node.body, f, result); + break; + case 222: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -35893,49 +35748,49 @@ var ts; result = ts.reduceLeft(node.heritageClauses, f, result); result = ts.reduceLeft(node.members, f, result); break; - case 227: + case 228: result = ts.reduceLeft(node.clauses, f, result); break; - case 230: + case 231: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.importClause, f, result); result = reduceNode(node.moduleSpecifier, f, result); break; - case 231: + case 232: result = reduceNode(node.name, f, result); result = reduceNode(node.namedBindings, f, result); break; - case 232: - result = reduceNode(node.name, f, result); - break; case 233: - case 237: - result = ts.reduceLeft(node.elements, f, result); + result = reduceNode(node.name, f, result); break; case 234: case 238: + result = ts.reduceLeft(node.elements, f, result); + break; + case 235: + case 239: result = reduceNode(node.propertyName, f, result); result = reduceNode(node.name, f, result); break; - case 235: + case 236: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.expression, f, result); break; - case 236: + case 237: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.exportClause, f, result); result = reduceNode(node.moduleSpecifier, f, result); break; - case 241: + case 242: result = reduceNode(node.openingElement, f, result); result = ts.reduceLeft(node.children, f, result); result = reduceNode(node.closingElement, f, result); break; - case 242: case 243: + case 244: result = reduceNode(node.tagName, f, result); result = ts.reduceLeft(node.attributes, f, result); break; @@ -36078,153 +35933,153 @@ var ts; return undefined; } var kind = node.kind; - if ((kind > 0 && kind <= 138)) { + if ((kind > 0 && kind <= 139)) { return node; } - if ((kind >= 154 && kind <= 166)) { + if ((kind >= 155 && kind <= 167)) { return node; } switch (node.kind) { - case 198: - case 201: - case 193: - case 217: - return node; - case 140: - return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); - case 142: - return ts.updateParameterDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 145: - return ts.updateProperty(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 147: - return ts.updateMethod(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); - case 148: - return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); - case 149: - return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); - case 150: - return ts.updateSetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); - case 167: - return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); - case 168: - return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); - case 169: - return ts.updateBindingElement(node, visitNode(node.propertyName, visitor, ts.isPropertyName, true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 170: - return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); - case 171: - return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 172: - return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 173: - return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 174: - return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); - case 175: - return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); - case 176: - return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 178: - return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 179: - return ts.updateFunctionExpression(node, visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); - case 180: - return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isConciseBody, true), context.endLexicalEnvironment())); - case 181: - return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 182: - return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 183: - return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 184: - return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 187: - return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); - case 185: - return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 186: - return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 188: - return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); - case 189: - return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); - case 190: - return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); - case 191: - return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 192: - return ts.updateClassExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 194: - return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 197: - return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); case 199: - return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 200: - return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); case 202: - return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 203: - return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, true, liftToBlock)); - case 204: - return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 205: - return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 206: - return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 207: - return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 208: - return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 209: - return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, true)); - case 210: - return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); - case 211: - return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, true)); - case 212: - return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 213: - return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 214: - return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 215: - return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 216: - return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause, true), visitNode(node.finallyBlock, visitor, ts.isBlock, true)); + case 194: case 218: - return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); + return node; + case 141: + return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); + case 143: + return ts.updateParameterDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); + case 146: + return ts.updateProperty(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); + case 148: + return ts.updateMethod(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + case 149: + return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + case 150: + return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + case 151: + return ts.updateSetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + case 168: + return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); + case 169: + return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); + case 170: + return ts.updateBindingElement(node, visitNode(node.propertyName, visitor, ts.isPropertyName, true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, true)); + case 171: + return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); + case 172: + return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); + case 173: + return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); + case 174: + return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); + case 175: + return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); + case 176: + return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); + case 177: + return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); + case 179: + return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); + case 180: + return ts.updateFunctionExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + case 181: + return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isConciseBody, true), context.endLexicalEnvironment())); + case 182: + return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); + case 183: + return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); + case 184: + return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); + case 185: + return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); + case 188: + return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); + case 186: + return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); + case 187: + return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); + case 189: + return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); + case 190: + return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); + case 191: + return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); + case 192: + return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); + case 193: + return ts.updateClassExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); + case 195: + return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); + case 198: + return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); + case 200: + return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); + case 201: + return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); + case 203: + return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); + case 204: + return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, true, liftToBlock)); + case 205: + return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); + case 206: + return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 207: + return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 208: + return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 209: + return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 210: + return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, true)); + case 211: + return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); + case 212: + return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, true)); + case 213: + return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 214: + return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); + case 215: + return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 216: + return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); + case 217: + return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause, true), visitNode(node.finallyBlock, visitor, ts.isBlock, true)); case 219: - return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); + return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); case 220: - return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); case 221: + return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + case 222: return ts.updateClassDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 227: + case 228: return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 230: - return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); case 231: - return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true)); + return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); case 232: - return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true)); case 233: - return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); + return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); case 234: - return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); case 235: - return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); case 236: - return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, true)); + return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); case 237: - return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); + return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, true)); case 238: + return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); + case 239: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); - case 241: - return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); case 242: - return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); + return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); case 243: + return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); + case 244: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); case 245: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); @@ -36325,67 +36180,67 @@ var ts; return transformFlags | aggregateTransformFlagsForNode(child); } function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 154 && kind <= 166) { + if (kind >= 155 && kind <= 167) { return -3; } switch (kind) { - case 174: case 175: - case 170: - return 537133909; - case 225: - return 546335573; - case 142: - return 538968917; + case 176: + case 171: + return 537922901; + case 226: + return 574729557; + case 143: + return 545262933; + case 181: + return 592227669; case 180: - return 550710101; - case 179: - case 220: - return 550726485; - case 219: - return 538968917; case 221: - case 192: - return 537590613; - case 148: - return 550593365; - case 147: + return 592293205; + case 220: + return 545262933; + case 222: + case 193: + return 539749717; case 149: + return 591760725; + case 148: case 150: - return 550593365; - case 117: - case 130: - case 127: - case 132: - case 120: - case 133: - case 103: - case 141: - case 144: - case 146: case 151: + return 591760725; + case 118: + case 131: + case 128: + case 133: + case 121: + case 134: + case 104: + case 142: + case 145: + case 147: case 152: case 153: - case 222: + case 154: case 223: + case 224: return -3; - case 171: - return 537430869; + case 172: + return 539110741; default: - return 536871765; + return 536874325; } } var Debug; (function (Debug) { Debug.failNotOptional = Debug.shouldAssert(1) ? function (message) { return Debug.assert(false, message || "Node not optional."); } - : function (message) { }; + : function () { }; Debug.failBadSyntaxKind = Debug.shouldAssert(1) ? function (node, message) { return Debug.assert(false, message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " was unexpected."; }); } - : function (node, message) { }; + : function () { }; Debug.assertNode = Debug.shouldAssert(1) ? function (node, test, message) { return Debug.assert(test === undefined || test(node), message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }); } - : function (node, test, message) { }; + : function () { }; function getFunctionName(func) { if (typeof func !== "function") { return ""; @@ -36423,7 +36278,7 @@ var ts; else if (ts.nodeIsSynthesized(node)) { location = value; } - flattenDestructuring(context, node, value, location, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, location, emitAssignment, emitTempVariableAssignment, visitor); if (needsValue) { expressions.push(value); } @@ -36443,9 +36298,9 @@ var ts; } } ts.flattenDestructuringAssignment = flattenDestructuringAssignment; - function flattenParameterDestructuring(context, node, value, visitor) { + function flattenParameterDestructuring(node, value, visitor) { var declarations = []; - flattenDestructuring(context, node, value, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, visitor); return declarations; function emitAssignment(name, value, location) { var declaration = ts.createVariableDeclaration(name, undefined, value, location); @@ -36460,10 +36315,10 @@ var ts; } } ts.flattenParameterDestructuring = flattenParameterDestructuring; - function flattenVariableDestructuring(context, node, value, visitor, recordTempVariable) { + function flattenVariableDestructuring(node, value, visitor, recordTempVariable) { var declarations = []; var pendingAssignments; - flattenDestructuring(context, node, value, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, visitor); return declarations; function emitAssignment(name, value, location, original) { if (pendingAssignments) { @@ -36495,9 +36350,9 @@ var ts; } } ts.flattenVariableDestructuring = flattenVariableDestructuring; - function flattenVariableDestructuringToExpression(context, node, recordTempVariable, nameSubstitution, visitor) { + function flattenVariableDestructuringToExpression(node, recordTempVariable, nameSubstitution, visitor) { var pendingAssignments = []; - flattenDestructuring(context, node, undefined, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, undefined, node, emitAssignment, emitTempVariableAssignment, visitor); var expression = ts.inlineExpressions(pendingAssignments); ts.aggregateTransformFlags(expression); return expression; @@ -36519,7 +36374,7 @@ var ts; } } ts.flattenVariableDestructuringToExpression = flattenVariableDestructuringToExpression; - function flattenDestructuring(context, root, value, location, emitAssignment, emitTempVariableAssignment, visitor) { + function flattenDestructuring(root, value, location, emitAssignment, emitTempVariableAssignment, visitor) { if (value && visitor) { value = ts.visitNode(value, visitor, ts.isExpression); } @@ -36540,7 +36395,7 @@ var ts; } target = bindingTarget.name; } - else if (ts.isBinaryExpression(bindingTarget) && bindingTarget.operatorToken.kind === 56) { + else if (ts.isBinaryExpression(bindingTarget) && bindingTarget.operatorToken.kind === 57) { var initializer = visitor ? ts.visitNode(bindingTarget.right, visitor, ts.isExpression) : bindingTarget.right; @@ -36550,17 +36405,17 @@ var ts; else { target = bindingTarget; } - if (target.kind === 171) { + if (target.kind === 172) { emitObjectLiteralAssignment(target, value, location); } - else if (target.kind === 170) { + else if (target.kind === 171) { emitArrayLiteralAssignment(target, value, location); } else { - var name_29 = ts.getMutableClone(target); - ts.setSourceMapRange(name_29, target); - ts.setCommentRange(name_29, target); - emitAssignment(name_29, value, location, undefined); + var name_26 = ts.getMutableClone(target); + ts.setSourceMapRange(name_26, target); + ts.setCommentRange(name_26, target); + emitAssignment(name_26, value, location, undefined); } } function emitObjectLiteralAssignment(target, value, location) { @@ -36585,8 +36440,8 @@ var ts; } for (var i = 0; i < numElements; i++) { var e = elements[i]; - if (e.kind !== 193) { - if (e.kind !== 191) { + if (e.kind !== 194) { + if (e.kind !== 192) { emitDestructuringAssignment(e, ts.createElementAccess(value, ts.createLiteral(i)), e); } else if (i === numElements - 1) { @@ -36615,7 +36470,7 @@ var ts; if (ts.isOmittedExpression(element)) { continue; } - else if (name.kind === 167) { + else if (name.kind === 168) { var propName = element.propertyName || element.name; emitBindingElement(element, createDestructuringPropertyAccess(value, propName)); } @@ -36635,7 +36490,7 @@ var ts; } function createDefaultValueCheck(value, defaultValue, location) { value = ensureIdentifier(value, true, location, emitTempVariableAssignment); - return ts.createConditional(ts.createStrictEquality(value, ts.createVoidZero()), ts.createToken(53), defaultValue, ts.createToken(54), value); + return ts.createConditional(ts.createStrictEquality(value, ts.createVoidZero()), ts.createToken(54), defaultValue, ts.createToken(55), value); } function createDestructuringPropertyAccess(expression, propertyName) { if (ts.isComputedPropertyName(propertyName)) { @@ -36673,6 +36528,12 @@ var ts; var ts; (function (ts) { var USE_NEW_TYPE_METADATA_FORMAT = false; + var TypeScriptSubstitutionFlags; + (function (TypeScriptSubstitutionFlags) { + TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["ClassAliases"] = 1] = "ClassAliases"; + TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["NamespaceExports"] = 2] = "NamespaceExports"; + TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["NonQualifiedEnumMembers"] = 8] = "NonQualifiedEnumMembers"; + })(TypeScriptSubstitutionFlags || (TypeScriptSubstitutionFlags = {})); function transformTypeScript(context) { var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); @@ -36683,8 +36544,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(172); context.enableSubstitution(173); + context.enableSubstitution(174); var currentSourceFile; var currentNamespace; var currentNamespaceContainerName; @@ -36694,7 +36555,6 @@ var ts; var enabledSubstitutions; var classAliases; var applicableSubstitutions; - var currentSuperContainer; return transformSourceFile; function transformSourceFile(node) { if (ts.isDeclarationFile(node)) { @@ -36728,15 +36588,32 @@ var ts; } return node; } + function sourceElementVisitor(node) { + return saveStateAndInvoke(node, sourceElementVisitorWorker); + } + function sourceElementVisitorWorker(node) { + switch (node.kind) { + case 231: + return visitImportDeclaration(node); + case 230: + return visitImportEqualsDeclaration(node); + case 236: + return visitExportAssignment(node); + case 237: + return visitExportDeclaration(node); + default: + return visitorWorker(node); + } + } function namespaceElementVisitor(node) { return saveStateAndInvoke(node, namespaceElementVisitorWorker); } function namespaceElementVisitorWorker(node) { - if (node.kind === 236 || - node.kind === 230 || + if (node.kind === 237 || node.kind === 231 || - (node.kind === 229 && - node.moduleReference.kind === 240)) { + node.kind === 232 || + (node.kind === 230 && + node.moduleReference.kind === 241)) { return undefined; } else if (node.transformFlags & 1 || ts.hasModifier(node, 1)) { @@ -36752,15 +36629,15 @@ var ts; } function classElementVisitorWorker(node) { switch (node.kind) { - case 148: - return undefined; - case 145: - case 153: case 149: + return undefined; + case 146: + case 154: case 150: - case 147: + case 151: + case 148: return visitorWorker(node); - case 198: + case 199: return node; default: ts.Debug.failBadSyntaxKind(node); @@ -36772,84 +36649,87 @@ var ts; return ts.createNotEmittedStatement(node); } switch (node.kind) { - case 82: - case 77: + case 83: + case 78: return currentNamespace ? undefined : node; - case 112: - case 110: + case 113: case 111: - case 115: - case 118: - case 74: - case 122: - case 128: - case 160: + case 112: + case 116: + case 75: + case 123: + case 129: case 161: - case 159: - case 154: - case 141: - case 117: - case 120: - case 132: - case 130: - case 127: - case 103: - case 133: - case 157: - case 156: - case 158: - case 155: case 162: + case 160: + case 155: + case 142: + case 118: + case 121: + case 133: + case 131: + case 128: + case 104: + case 134: + case 158: + case 157: + case 159: + case 156: case 163: case 164: case 165: case 166: - case 153: - case 143: + case 167: + case 154: + case 144: + case 224: + case 146: + case 149: + return visitConstructor(node); case 223: - case 145: - case 148: - return undefined; - case 222: return ts.createNotEmittedStatement(node); - case 221: + case 222: return visitClassDeclaration(node); - case 192: + case 193: return visitClassExpression(node); case 251: return visitHeritageClause(node); - case 194: - return visitExpressionWithTypeArguments(node); - case 147: - return visitMethodDeclaration(node); - case 149: - return visitGetAccessor(node); - case 150: - return visitSetAccessor(node); - case 220: - return visitFunctionDeclaration(node); - case 179: - return visitFunctionExpression(node); - case 180: - return visitArrowFunction(node); - case 142: - return visitParameter(node); - case 178: - return visitParenthesizedExpression(node); - case 177: case 195: - return visitAssertionExpression(node); + return visitExpressionWithTypeArguments(node); + case 148: + return visitMethodDeclaration(node); + case 150: + return visitGetAccessor(node); + case 151: + return visitSetAccessor(node); + case 221: + return visitFunctionDeclaration(node); + case 180: + return visitFunctionExpression(node); + case 181: + return visitArrowFunction(node); + case 143: + return visitParameter(node); + case 179: + return visitParenthesizedExpression(node); + case 178: case 196: + return visitAssertionExpression(node); + case 175: + return visitCallExpression(node); + case 176: + return visitNewExpression(node); + case 197: return visitNonNullExpression(node); - case 224: - return visitEnumDeclaration(node); - case 184: - return visitAwaitExpression(node); - case 200: - return visitVariableStatement(node); case 225: + return visitEnumDeclaration(node); + case 201: + return visitVariableStatement(node); + case 219: + return visitVariableDeclaration(node); + case 226: return visitModuleDeclaration(node); - case 229: + case 230: return visitImportEqualsDeclaration(node); default: ts.Debug.failBadSyntaxKind(node); @@ -36859,14 +36739,14 @@ var ts; function onBeforeVisitNode(node) { switch (node.kind) { case 256: + case 228: case 227: - case 226: - case 199: + case 200: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; + case 222: case 221: - case 220: if (ts.hasModifier(node, 2)) { break; } @@ -36891,14 +36771,14 @@ var ts; externalHelpersModuleImport.flags &= ~8; statements.push(externalHelpersModuleImport); currentSourceFileExternalHelpersModuleName = externalHelpersModuleName; - ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); + ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); currentSourceFileExternalHelpersModuleName = undefined; node = ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); node.externalHelpersModuleName = externalHelpersModuleName; } else { - node = ts.visitEachChild(node, visitor, context); + node = ts.visitEachChild(node, sourceElementVisitor, context); } ts.setEmitFlags(node, 1 | ts.getEmitFlags(node)); return node; @@ -36938,7 +36818,7 @@ var ts; classAlias = addClassDeclarationHeadWithDecorators(statements, node, name, hasExtendsClause); } if (staticProperties.length) { - addInitializedPropertyStatements(statements, node, staticProperties, getLocalName(node, true)); + addInitializedPropertyStatements(statements, staticProperties, getLocalName(node, true)); } addClassElementDecorationStatements(statements, node, false); addClassElementDecorationStatements(statements, node, true); @@ -36984,7 +36864,7 @@ var ts; function visitClassExpression(node) { var staticProperties = getInitializedProperties(node, true); var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); - var members = transformClassMembers(node, heritageClauses !== undefined); + var members = transformClassMembers(node, ts.some(heritageClauses, function (c) { return c.token === 84; })); var classExpression = ts.setOriginalNode(ts.createClassExpression(undefined, node.name, undefined, heritageClauses, members, node), node); if (staticProperties.length > 0) { var expressions = []; @@ -36995,7 +36875,7 @@ var ts; } ts.setEmitFlags(classExpression, 524288 | ts.getEmitFlags(classExpression)); expressions.push(ts.startOnNewLine(ts.createAssignment(temp, classExpression))); - ts.addRange(expressions, generateInitializedPropertyExpressions(node, staticProperties, temp)); + ts.addRange(expressions, generateInitializedPropertyExpressions(staticProperties, temp)); expressions.push(ts.startOnNewLine(temp)); return ts.inlineExpressions(expressions); } @@ -37012,13 +36892,13 @@ var ts; } function transformConstructor(node, hasExtendsClause) { var hasInstancePropertyWithInitializer = ts.forEach(node.members, isInstanceInitializedProperty); - var hasParameterPropertyAssignments = node.transformFlags & 131072; + var hasParameterPropertyAssignments = node.transformFlags & 524288; var constructor = ts.getFirstConstructorWithBody(node); if (!hasInstancePropertyWithInitializer && !hasParameterPropertyAssignments) { return ts.visitEachChild(constructor, visitor, context); } var parameters = transformConstructorParameters(constructor); - var body = transformConstructorBody(node, constructor, hasExtendsClause, parameters); + var body = transformConstructorBody(node, constructor, hasExtendsClause); return ts.startOnNewLine(ts.setOriginalNode(ts.createConstructor(undefined, undefined, parameters, body, constructor || node), constructor)); } function transformConstructorParameters(constructor) { @@ -37026,7 +36906,7 @@ var ts; ? ts.visitNodes(constructor.parameters, visitor, ts.isParameter) : []; } - function transformConstructorBody(node, constructor, hasExtendsClause, parameters) { + function transformConstructorBody(node, constructor, hasExtendsClause) { var statements = []; var indexOfFirstStatement = 0; startLexicalEnvironment(); @@ -37039,7 +36919,7 @@ var ts; statements.push(ts.createStatement(ts.createCall(ts.createSuper(), undefined, [ts.createSpread(ts.createIdentifier("arguments"))]))); } var properties = getInitializedProperties(node, false); - addInitializedPropertyStatements(statements, node, properties, ts.createThis()); + addInitializedPropertyStatements(statements, properties, ts.createThis()); if (constructor) { ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement)); } @@ -37054,7 +36934,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 202 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 203 && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -37088,24 +36968,24 @@ var ts; return isInitializedProperty(member, false); } function isInitializedProperty(member, isStatic) { - return member.kind === 145 + return member.kind === 146 && isStatic === ts.hasModifier(member, 32) && member.initializer !== undefined; } - function addInitializedPropertyStatements(statements, node, properties, receiver) { + function addInitializedPropertyStatements(statements, properties, receiver) { for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) { var property = properties_7[_i]; - var statement = ts.createStatement(transformInitializedProperty(node, property, receiver)); + var statement = ts.createStatement(transformInitializedProperty(property, receiver)); ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property)); ts.setCommentRange(statement, property); statements.push(statement); } } - function generateInitializedPropertyExpressions(node, properties, receiver) { + function generateInitializedPropertyExpressions(properties, receiver) { var expressions = []; for (var _i = 0, properties_8 = properties; _i < properties_8.length; _i++) { var property = properties_8[_i]; - var expression = transformInitializedProperty(node, property, receiver); + var expression = transformInitializedProperty(property, receiver); expression.startsOnNewLine = true; ts.setSourceMapRange(expression, ts.moveRangePastModifiers(property)); ts.setCommentRange(expression, property); @@ -37113,7 +36993,7 @@ var ts; } return expressions; } - function transformInitializedProperty(node, property, receiver) { + function transformInitializedProperty(property, receiver) { var propertyName = visitPropertyNameOfClassElement(property); var initializer = ts.visitNode(property.initializer, visitor, ts.isExpression); var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, propertyName); @@ -37161,12 +37041,12 @@ var ts; } function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 149: case 150: + case 151: return getAllDecoratorsOfAccessors(node, member); - case 147: + case 148: return getAllDecoratorsOfMethod(member); - case 145: + case 146: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -37244,7 +37124,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, true); var descriptor = languageVersion > 0 - ? member.kind === 145 + ? member.kind === 146 ? ts.createVoidZero() : ts.createNull() : undefined; @@ -37332,43 +37212,43 @@ var ts; } function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 147 - || kind === 149 + return kind === 148 || kind === 150 - || kind === 145; + || kind === 151 + || kind === 146; } function shouldAddReturnTypeMetadata(node) { - return node.kind === 147; + return node.kind === 148; } function shouldAddParamTypesMetadata(node) { var kind = node.kind; - return kind === 221 - || kind === 192 - || kind === 147 - || kind === 149 - || kind === 150; + return kind === 222 + || kind === 193 + || kind === 148 + || kind === 150 + || kind === 151; } function serializeTypeOfNode(node) { switch (node.kind) { - case 145: - case 142: - case 149: - return serializeTypeNode(node.type); + case 146: + case 143: case 150: + return serializeTypeNode(node.type); + case 151: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 221: - case 192: - case 147: + case 222: + case 193: + case 148: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); } } function getRestParameterElementType(node) { - if (node && node.kind === 160) { + if (node && node.kind === 161) { return node.elementType; } - else if (node && node.kind === 155) { + else if (node && node.kind === 156) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -37414,52 +37294,52 @@ var ts; return ts.createIdentifier("Object"); } switch (node.kind) { - case 103: + case 104: return ts.createVoidZero(); - case 164: + case 165: return serializeTypeNode(node.type); - case 156: case 157: + case 158: return ts.createIdentifier("Function"); - case 160: case 161: + case 162: return ts.createIdentifier("Array"); - case 154: - case 120: + case 155: + case 121: return ts.createIdentifier("Boolean"); - case 132: + case 133: return ts.createIdentifier("String"); - case 166: + case 167: switch (node.literal.kind) { case 9: return ts.createIdentifier("String"); case 8: return ts.createIdentifier("Number"); - case 99: - case 84: + case 100: + case 85: return ts.createIdentifier("Boolean"); default: ts.Debug.failBadSyntaxKind(node.literal); break; } break; - case 130: + case 131: return ts.createIdentifier("Number"); - case 133: + case 134: return languageVersion < 2 ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 155: + case 156: return serializeTypeReferenceNode(node); + case 164: case 163: - case 162: { var unionOrIntersection = node; var serializedUnion = void 0; for (var _i = 0, _a = unionOrIntersection.types; _i < _a.length; _i++) { var typeNode = _a[_i]; var serializedIndividual = serializeTypeNode(typeNode); - if (serializedIndividual.kind !== 69) { + if (serializedIndividual.kind !== 70) { serializedUnion = undefined; break; } @@ -37476,10 +37356,10 @@ var ts; return serializedUnion; } } - case 158: case 159: - case 117: - case 165: + case 160: + case 118: + case 166: break; default: ts.Debug.failBadSyntaxKind(node); @@ -37520,22 +37400,22 @@ var ts; } function serializeEntityNameAsExpression(node, useFallback) { switch (node.kind) { - case 69: - var name_30 = ts.getMutableClone(node); - name_30.flags &= ~8; - name_30.original = undefined; - name_30.parent = currentScope; + case 70: + var name_27 = ts.getMutableClone(node); + name_27.flags &= ~8; + name_27.original = undefined; + name_27.parent = currentScope; if (useFallback) { - return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_30), ts.createLiteral("undefined")), name_30); + return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_27), ts.createLiteral("undefined")), name_27); } - return name_30; - case 139: + return name_27; + case 140: return serializeQualifiedNameAsExpression(node, useFallback); } } function serializeQualifiedNameAsExpression(node, useFallback) { var left; - if (node.left.kind === 69) { + if (node.left.kind === 70) { left = serializeEntityNameAsExpression(node.left, useFallback); } else if (useFallback) { @@ -37548,7 +37428,7 @@ var ts; return ts.createPropertyAccess(left, node.right); } function getGlobalSymbolNameWithFallback() { - return ts.createConditional(ts.createStrictEquality(ts.createTypeOf(ts.createIdentifier("Symbol")), ts.createLiteral("function")), ts.createToken(53), ts.createIdentifier("Symbol"), ts.createToken(54), ts.createIdentifier("Object")); + return ts.createConditional(ts.createStrictEquality(ts.createTypeOf(ts.createIdentifier("Symbol")), ts.createLiteral("function")), ts.createToken(54), ts.createIdentifier("Symbol"), ts.createToken(55), ts.createIdentifier("Object")); } function getExpressionForPropertyName(member, generateNameForComputedPropertyName) { var name = member.name; @@ -37580,9 +37460,9 @@ var ts; } } function visitHeritageClause(node) { - if (node.token === 83) { + if (node.token === 84) { var types = ts.visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments, 0, 1); - return ts.createHeritageClause(83, types, node); + return ts.createHeritageClause(84, types, node); } return undefined; } @@ -37593,6 +37473,12 @@ var ts; function shouldEmitFunctionLikeDeclaration(node) { return !ts.nodeIsMissing(node.body); } + function visitConstructor(node) { + if (!shouldEmitFunctionLikeDeclaration(node)) { + return undefined; + } + return ts.visitEachChild(node, visitor, context); + } function visitMethodDeclaration(node) { if (!shouldEmitFunctionLikeDeclaration(node)) { return undefined; @@ -37643,36 +37529,33 @@ var ts; if (ts.nodeIsMissing(node.body)) { return ts.createOmittedExpression(); } - var func = ts.createFunctionExpression(node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); + var func = ts.createFunctionExpression(ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); ts.setOriginalNode(func, node); return func; } function visitArrowFunction(node) { - var func = ts.createArrowFunction(undefined, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, node.equalsGreaterThanToken, transformConciseBody(node), node); + var func = ts.createArrowFunction(ts.visitNodes(node.modifiers, visitor, ts.isModifier), undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, node.equalsGreaterThanToken, transformConciseBody(node), node); ts.setOriginalNode(func, node); return func; } function transformFunctionBody(node) { - if (ts.isAsyncFunctionLike(node)) { - return transformAsyncFunctionBody(node); - } return transformFunctionBodyWorker(node.body); } function transformFunctionBodyWorker(body, start) { if (start === void 0) { start = 0; } var savedCurrentScope = currentScope; + var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName; currentScope = body; + currentScopeFirstDeclarationsOfName = ts.createMap(); startLexicalEnvironment(); var statements = ts.visitNodes(body.statements, visitor, ts.isStatement, start); var visited = ts.updateBlock(body, statements); var declarations = endLexicalEnvironment(); currentScope = savedCurrentScope; + currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; return ts.mergeFunctionBodyLexicalEnvironment(visited, declarations); } function transformConciseBody(node) { - if (ts.isAsyncFunctionLike(node)) { - return transformAsyncFunctionBody(node); - } return transformConciseBodyWorker(node.body, false); } function transformConciseBodyWorker(body, forceBlockFunctionBody) { @@ -37694,42 +37577,6 @@ var ts; } } } - function getPromiseConstructor(type) { - var typeName = ts.getEntityNameFromTypeNode(type); - if (typeName && ts.isEntityName(typeName)) { - var serializationKind = resolver.getTypeReferenceSerializationKind(typeName); - if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue - || serializationKind === ts.TypeReferenceSerializationKind.Unknown) { - return typeName; - } - } - return undefined; - } - function transformAsyncFunctionBody(node) { - var promiseConstructor = languageVersion < 2 ? getPromiseConstructor(node.type) : undefined; - var isArrowFunction = node.kind === 180; - var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0; - if (!isArrowFunction) { - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.body.statements, false, visitor); - statements.push(ts.createReturn(ts.createAwaiterHelper(currentSourceFileExternalHelpersModuleName, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body, statementOffset)))); - var block = ts.createBlock(statements, node.body, true); - if (languageVersion >= 2) { - if (resolver.getNodeCheckFlags(node) & 4096) { - enableSubstitutionForAsyncMethodsWithSuper(); - ts.setEmitFlags(block, 8); - } - else if (resolver.getNodeCheckFlags(node) & 2048) { - enableSubstitutionForAsyncMethodsWithSuper(); - ts.setEmitFlags(block, 4); - } - } - return block; - } - else { - return ts.createAwaiterHelper(currentSourceFileExternalHelpersModuleName, hasLexicalArguments, promiseConstructor, transformConciseBodyWorker(node.body, true)); - } - } function visitParameter(node) { if (ts.parameterIsThisKeyword(node)) { return undefined; @@ -37756,14 +37603,14 @@ var ts; function transformInitializedVariable(node) { var name = node.name; if (ts.isBindingPattern(name)) { - return ts.flattenVariableDestructuringToExpression(context, node, hoistVariableDeclaration, getNamespaceMemberNameWithSourceMapsAndWithoutComments, visitor); + return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, getNamespaceMemberNameWithSourceMapsAndWithoutComments, visitor); } else { return ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(name), ts.visitNode(node.initializer, visitor, ts.isExpression), node); } } - function visitAwaitExpression(node) { - return ts.setOriginalNode(ts.createYield(undefined, ts.visitNode(node.expression, visitor, ts.isExpression), node), node); + function visitVariableDeclaration(node) { + return ts.updateVariableDeclaration(node, ts.visitNode(node.name, visitor, ts.isBindingName), undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)); } function visitParenthesizedExpression(node) { var innerExpression = ts.skipOuterExpressions(node.expression, ~2); @@ -37781,6 +37628,12 @@ var ts; var expression = ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression); return ts.createPartiallyEmittedExpression(expression, node); } + function visitCallExpression(node) { + return ts.updateCall(node, ts.visitNode(node.expression, visitor, ts.isExpression), undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression)); + } + function visitNewExpression(node) { + return ts.updateNew(node, ts.visitNode(node.expression, visitor, ts.isExpression), undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression)); + } function shouldEmitEnumDeclaration(node) { return !ts.isConst(node) || compilerOptions.preserveConstEnums @@ -37812,7 +37665,7 @@ var ts; var parameterName = getNamespaceParameterName(node); var containerName = getNamespaceContainerName(node); var exportName = getExportName(node); - var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, transformEnumBody(node, containerName)), undefined, [ts.createLogicalOr(exportName, ts.createAssignment(exportName, ts.createObjectLiteral()))]), node); + var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, transformEnumBody(node, containerName)), undefined, [ts.createLogicalOr(exportName, ts.createAssignment(exportName, ts.createObjectLiteral()))]), node); ts.setOriginalNode(enumStatement, node); ts.setEmitFlags(enumStatement, emitFlags); statements.push(enumStatement); @@ -37855,7 +37708,7 @@ var ts; } function isES6ExportedDeclaration(node) { return isExternalModuleExport(node) - && moduleKind === ts.ModuleKind.ES6; + && moduleKind === ts.ModuleKind.ES2015; } function recordEmittedDeclarationInScope(node) { var name = node.symbol && node.symbol.name; @@ -37870,9 +37723,9 @@ var ts; } function isFirstEmittedDeclarationInScope(node) { if (currentScopeFirstDeclarationsOfName) { - var name_31 = node.symbol && node.symbol.name; - if (name_31) { - return currentScopeFirstDeclarationsOfName[name_31] === node; + var name_28 = node.symbol && node.symbol.name; + if (name_28) { + return currentScopeFirstDeclarationsOfName[name_28] === node; } } return false; @@ -37887,7 +37740,7 @@ var ts; ts.createVariableDeclaration(getDeclarationName(node, false, true)) ]); ts.setOriginalNode(statement, node); - if (node.kind === 224) { + if (node.kind === 225) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -37920,7 +37773,7 @@ var ts; var localName = getLocalName(node); moduleArg = ts.createAssignment(localName, moduleArg); } - var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, transformModuleBody(node, containerName)), undefined, [moduleArg]), node); + var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, transformModuleBody(node, containerName)), undefined, [moduleArg]), node); ts.setOriginalNode(moduleStatement, node); ts.setEmitFlags(moduleStatement, emitFlags); statements.push(moduleStatement); @@ -37938,7 +37791,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 226) { + if (body.kind === 227) { ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); statementsLocation = body.statements; blockLocation = body; @@ -37961,17 +37814,67 @@ var ts; currentNamespace = savedCurrentNamespace; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), blockLocation, true); - if (body.kind !== 226) { + if (body.kind !== 227) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 49152); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 225) { + if (moduleDeclaration.body.kind === 226) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } } + function visitImportDeclaration(node) { + if (!node.importClause) { + return node; + } + var importClause = ts.visitNode(node.importClause, visitImportClause, ts.isImportClause, true); + return importClause + ? ts.updateImportDeclaration(node, undefined, undefined, importClause, node.moduleSpecifier) + : undefined; + } + function visitImportClause(node) { + var name = resolver.isReferencedAliasDeclaration(node) ? node.name : undefined; + var namedBindings = ts.visitNode(node.namedBindings, visitNamedImportBindings, ts.isNamedImportBindings, true); + return (name || namedBindings) ? ts.updateImportClause(node, name, namedBindings) : undefined; + } + function visitNamedImportBindings(node) { + if (node.kind === 233) { + return resolver.isReferencedAliasDeclaration(node) ? node : undefined; + } + else { + var elements = ts.visitNodes(node.elements, visitImportSpecifier, ts.isImportSpecifier); + return ts.some(elements) ? ts.updateNamedImports(node, elements) : undefined; + } + } + function visitImportSpecifier(node) { + return resolver.isReferencedAliasDeclaration(node) ? node : undefined; + } + function visitExportAssignment(node) { + return resolver.isValueAliasDeclaration(node) + ? ts.visitEachChild(node, visitor, context) + : undefined; + } + function visitExportDeclaration(node) { + if (!node.exportClause) { + return resolver.moduleExportsSomeValue(node.moduleSpecifier) ? node : undefined; + } + if (!resolver.isValueAliasDeclaration(node)) { + return undefined; + } + var exportClause = ts.visitNode(node.exportClause, visitNamedExports, ts.isNamedExports, true); + return exportClause + ? ts.updateExportDeclaration(node, undefined, undefined, exportClause, node.moduleSpecifier) + : undefined; + } + function visitNamedExports(node) { + var elements = ts.visitNodes(node.elements, visitExportSpecifier, ts.isExportSpecifier); + return ts.some(elements) ? ts.updateNamedExports(node, elements) : undefined; + } + function visitExportSpecifier(node) { + return resolver.isValueAliasDeclaration(node) ? node : undefined; + } function shouldEmitImportEqualsDeclaration(node) { return resolver.isReferencedAliasDeclaration(node) || (!ts.isExternalModule(currentSourceFile) @@ -37979,7 +37882,9 @@ var ts; } function visitImportEqualsDeclaration(node) { if (ts.isExternalModuleImportEqualsDeclaration(node)) { - return ts.visitEachChild(node, visitor, context); + return resolver.isReferencedAliasDeclaration(node) + ? ts.visitEachChild(node, visitor, context) + : undefined; } if (!shouldEmitImportEqualsDeclaration(node)) { return undefined; @@ -38063,7 +37968,7 @@ var ts; } function getDeclarationName(node, allowComments, allowSourceMaps, emitFlags) { if (node.name) { - var name_32 = ts.getMutableClone(node.name); + var name_29 = ts.getMutableClone(node.name); emitFlags |= ts.getEmitFlags(node.name); if (!allowSourceMaps) { emitFlags |= 1536; @@ -38072,9 +37977,9 @@ var ts; emitFlags |= 49152; } if (emitFlags) { - ts.setEmitFlags(name_32, emitFlags); + ts.setEmitFlags(name_29, emitFlags); } - return name_32; + return name_29; } else { return ts.getGeneratedNameForNode(node); @@ -38091,57 +37996,32 @@ var ts; function enableSubstitutionForNonQualifiedEnumMembers() { if ((enabledSubstitutions & 8) === 0) { enabledSubstitutions |= 8; - context.enableSubstitution(69); - } - } - function enableSubstitutionForAsyncMethodsWithSuper() { - if ((enabledSubstitutions & 4) === 0) { - enabledSubstitutions |= 4; - context.enableSubstitution(174); - context.enableSubstitution(172); - context.enableSubstitution(173); - context.enableEmitNotification(221); - context.enableEmitNotification(147); - context.enableEmitNotification(149); - context.enableEmitNotification(150); - context.enableEmitNotification(148); + context.enableSubstitution(70); } } function enableSubstitutionForClassAliases() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(69); + context.enableSubstitution(70); classAliases = ts.createMap(); } } function enableSubstitutionForNamespaceExports() { if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; - context.enableSubstitution(69); + context.enableSubstitution(70); context.enableSubstitution(254); - context.enableEmitNotification(225); + context.enableEmitNotification(226); } } - function isSuperContainer(node) { - var kind = node.kind; - return kind === 221 - || kind === 148 - || kind === 147 - || kind === 149 - || kind === 150; - } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 225; + return ts.getOriginalNode(node).kind === 226; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 224; + return ts.getOriginalNode(node).kind === 225; } function onEmitNode(emitContext, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; - var savedCurrentSuperContainer = currentSuperContainer; - if (enabledSubstitutions & 4 && isSuperContainer(node)) { - currentSuperContainer = node; - } if (enabledSubstitutions & 2 && isTransformedModuleDeclaration(node)) { applicableSubstitutions |= 2; } @@ -38150,7 +38030,6 @@ var ts; } previousOnEmitNode(emitContext, node, emitCallback); applicableSubstitutions = savedApplicableSubstitutions; - currentSuperContainer = savedCurrentSuperContainer; } function onSubstituteNode(emitContext, node) { node = previousOnSubstituteNode(emitContext, node); @@ -38164,31 +38043,26 @@ var ts; } function substituteShorthandPropertyAssignment(node) { if (enabledSubstitutions & 2) { - var name_33 = node.name; - var exportedName = trySubstituteNamespaceExportedName(name_33); + var name_30 = node.name; + var exportedName = trySubstituteNamespaceExportedName(name_30); if (exportedName) { if (node.objectAssignmentInitializer) { var initializer = ts.createAssignment(exportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name_33, initializer, node); + return ts.createPropertyAssignment(name_30, initializer, node); } - return ts.createPropertyAssignment(name_33, exportedName, node); + return ts.createPropertyAssignment(name_30, exportedName, node); } } return node; } function substituteExpression(node) { switch (node.kind) { - case 69: + case 70: return substituteExpressionIdentifier(node); - case 172: - return substitutePropertyAccessExpression(node); case 173: - return substituteElementAccessExpression(node); + return substitutePropertyAccessExpression(node); case 174: - if (enabledSubstitutions & 4) { - return substituteCallExpression(node); - } - break; + return substituteElementAccessExpression(node); } return node; } @@ -38218,8 +38092,8 @@ var ts; if (enabledSubstitutions & applicableSubstitutions && (ts.getEmitFlags(node) & 262144) === 0) { var container = resolver.getReferencedExportContainer(node, false); if (container) { - var substitute = (applicableSubstitutions & 2 && container.kind === 225) || - (applicableSubstitutions & 8 && container.kind === 224); + var substitute = (applicableSubstitutions & 2 && container.kind === 226) || + (applicableSubstitutions & 8 && container.kind === 225); if (substitute) { return ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node, node); } @@ -38227,37 +38101,10 @@ var ts; } return undefined; } - function substituteCallExpression(node) { - var expression = node.expression; - if (ts.isSuperProperty(expression)) { - var flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - var argumentExpression = ts.isPropertyAccessExpression(expression) - ? substitutePropertyAccessExpression(expression) - : substituteElementAccessExpression(expression); - return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), undefined, [ - ts.createThis() - ].concat(node.arguments)); - } - } - return node; - } function substitutePropertyAccessExpression(node) { - if (enabledSubstitutions & 4 && node.expression.kind === 95) { - var flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - return createSuperAccessInAsyncMethod(ts.createLiteral(node.name.text), flags, node); - } - } return substituteConstantValue(node); } function substituteElementAccessExpression(node) { - if (enabledSubstitutions & 4 && node.expression.kind === 95) { - var flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - return createSuperAccessInAsyncMethod(node.argumentExpression, flags, node); - } - } return substituteConstantValue(node); } function substituteConstantValue(node) { @@ -38285,18 +38132,6 @@ var ts; ? resolver.getConstantValue(node) : undefined; } - function createSuperAccessInAsyncMethod(argumentExpression, flags, location) { - if (flags & 4096) { - return ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), "value", location); - } - else { - return ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression], location); - } - } - function getSuperContainerAsyncMethodFlags() { - return currentSuperContainer !== undefined - && resolver.getNodeCheckFlags(currentSuperContainer) & (2048 | 4096); - } } ts.transformTypeScript = transformTypeScript; })(ts || (ts = {})); @@ -38329,9 +38164,9 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 241: - return visitJsxElement(node, false); case 242: + return visitJsxElement(node, false); + case 243: return visitJsxSelfClosingElement(node, false); case 248: return visitJsxExpression(node); @@ -38342,13 +38177,13 @@ var ts; } function transformJsxChildToExpression(node) { switch (node.kind) { - case 244: + case 10: return visitJsxText(node); case 248: return visitJsxExpression(node); - case 241: - return visitJsxElement(node, true); case 242: + return visitJsxElement(node, true); + case 243: return visitJsxSelfClosingElement(node, true); default: ts.Debug.failBadSyntaxKind(node); @@ -38465,16 +38300,16 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 241) { + if (node.kind === 242) { return getTagName(node.openingElement); } else { - var name_34 = node.tagName; - if (ts.isIdentifier(name_34) && ts.isIntrinsicJsxName(name_34.text)) { - return ts.createLiteral(name_34.text); + var name_31 = node.tagName; + if (ts.isIdentifier(name_31) && ts.isIntrinsicJsxName(name_31.text)) { + return ts.createLiteral(name_31.text); } else { - return ts.createExpressionFromEntityName(name_34); + return ts.createExpressionFromEntityName(name_31); } } } @@ -38752,13 +38587,30 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function transformES7(context) { - var hoistVariableDeclaration = context.hoistVariableDeclaration; + function transformES2017(context) { + var ES2017SubstitutionFlags; + (function (ES2017SubstitutionFlags) { + ES2017SubstitutionFlags[ES2017SubstitutionFlags["AsyncMethodsWithSuper"] = 1] = "AsyncMethodsWithSuper"; + })(ES2017SubstitutionFlags || (ES2017SubstitutionFlags = {})); + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; + var resolver = context.getEmitResolver(); + var compilerOptions = context.getCompilerOptions(); + var languageVersion = ts.getEmitScriptTarget(compilerOptions); + var currentSourceFileExternalHelpersModuleName; + var enabledSubstitutions; + var applicableSubstitutions; + var currentSuperContainer; + var previousOnEmitNode = context.onEmitNode; + var previousOnSubstituteNode = context.onSubstituteNode; + context.onEmitNode = onEmitNode; + context.onSubstituteNode = onSubstituteNode; + var currentScope; return transformSourceFile; function transformSourceFile(node) { if (ts.isDeclarationFile(node)) { return node; } + currentSourceFileExternalHelpersModuleName = node.externalHelpersModuleName; return ts.visitEachChild(node, visitor, context); } function visitor(node) { @@ -38768,13 +38620,265 @@ var ts; else if (node.transformFlags & 32) { return ts.visitEachChild(node, visitor, context); } + return node; + } + function visitorWorker(node) { + switch (node.kind) { + case 119: + return undefined; + case 185: + return visitAwaitExpression(node); + case 148: + return visitMethodDeclaration(node); + case 221: + return visitFunctionDeclaration(node); + case 180: + return visitFunctionExpression(node); + case 181: + return visitArrowFunction(node); + default: + ts.Debug.failBadSyntaxKind(node); + return node; + } + } + function visitAwaitExpression(node) { + return ts.setOriginalNode(ts.createYield(undefined, ts.visitNode(node.expression, visitor, ts.isExpression), node), node); + } + function visitMethodDeclaration(node) { + if (!ts.isAsyncFunctionLike(node)) { + return node; + } + var method = ts.createMethod(undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); + ts.setCommentRange(method, node); + ts.setSourceMapRange(method, ts.moveRangePastDecorators(node)); + ts.setOriginalNode(method, node); + return method; + } + function visitFunctionDeclaration(node) { + if (!ts.isAsyncFunctionLike(node)) { + return node; + } + var func = ts.createFunctionDeclaration(undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); + ts.setOriginalNode(func, node); + return func; + } + function visitFunctionExpression(node) { + if (!ts.isAsyncFunctionLike(node)) { + return node; + } + if (ts.nodeIsMissing(node.body)) { + return ts.createOmittedExpression(); + } + var func = ts.createFunctionExpression(undefined, node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); + ts.setOriginalNode(func, node); + return func; + } + function visitArrowFunction(node) { + if (!ts.isAsyncFunctionLike(node)) { + return node; + } + var func = ts.createArrowFunction(ts.visitNodes(node.modifiers, visitor, ts.isModifier), undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, node.equalsGreaterThanToken, transformConciseBody(node), node); + ts.setOriginalNode(func, node); + return func; + } + function transformFunctionBody(node) { + return transformAsyncFunctionBody(node); + } + function transformConciseBody(node) { + return transformAsyncFunctionBody(node); + } + function transformFunctionBodyWorker(body, start) { + if (start === void 0) { start = 0; } + var savedCurrentScope = currentScope; + currentScope = body; + startLexicalEnvironment(); + var statements = ts.visitNodes(body.statements, visitor, ts.isStatement, start); + var visited = ts.updateBlock(body, statements); + var declarations = endLexicalEnvironment(); + currentScope = savedCurrentScope; + return ts.mergeFunctionBodyLexicalEnvironment(visited, declarations); + } + function transformAsyncFunctionBody(node) { + var nodeType = node.original ? node.original.type : node.type; + var promiseConstructor = languageVersion < 2 ? getPromiseConstructor(nodeType) : undefined; + var isArrowFunction = node.kind === 181; + var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0; + if (!isArrowFunction) { + var statements = []; + var statementOffset = ts.addPrologueDirectives(statements, node.body.statements, false, visitor); + statements.push(ts.createReturn(ts.createAwaiterHelper(currentSourceFileExternalHelpersModuleName, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body, statementOffset)))); + var block = ts.createBlock(statements, node.body, true); + if (languageVersion >= 2) { + if (resolver.getNodeCheckFlags(node) & 4096) { + enableSubstitutionForAsyncMethodsWithSuper(); + ts.setEmitFlags(block, 8); + } + else if (resolver.getNodeCheckFlags(node) & 2048) { + enableSubstitutionForAsyncMethodsWithSuper(); + ts.setEmitFlags(block, 4); + } + } + return block; + } + else { + return ts.createAwaiterHelper(currentSourceFileExternalHelpersModuleName, hasLexicalArguments, promiseConstructor, transformConciseBodyWorker(node.body, true)); + } + } + function transformConciseBodyWorker(body, forceBlockFunctionBody) { + if (ts.isBlock(body)) { + return transformFunctionBodyWorker(body); + } + else { + startLexicalEnvironment(); + var visited = ts.visitNode(body, visitor, ts.isConciseBody); + var declarations = endLexicalEnvironment(); + var merged = ts.mergeFunctionBodyLexicalEnvironment(visited, declarations); + if (forceBlockFunctionBody && !ts.isBlock(merged)) { + return ts.createBlock([ + ts.createReturn(merged) + ]); + } + else { + return merged; + } + } + } + function getPromiseConstructor(type) { + var typeName = ts.getEntityNameFromTypeNode(type); + if (typeName && ts.isEntityName(typeName)) { + var serializationKind = resolver.getTypeReferenceSerializationKind(typeName); + if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue + || serializationKind === ts.TypeReferenceSerializationKind.Unknown) { + return typeName; + } + } + return undefined; + } + function enableSubstitutionForAsyncMethodsWithSuper() { + if ((enabledSubstitutions & 1) === 0) { + enabledSubstitutions |= 1; + context.enableSubstitution(175); + context.enableSubstitution(173); + context.enableSubstitution(174); + context.enableEmitNotification(222); + context.enableEmitNotification(148); + context.enableEmitNotification(150); + context.enableEmitNotification(151); + context.enableEmitNotification(149); + } + } + function substituteExpression(node) { + switch (node.kind) { + case 173: + return substitutePropertyAccessExpression(node); + case 174: + return substituteElementAccessExpression(node); + case 175: + if (enabledSubstitutions & 1) { + return substituteCallExpression(node); + } + break; + } + return node; + } + function substitutePropertyAccessExpression(node) { + if (enabledSubstitutions & 1 && node.expression.kind === 96) { + var flags = getSuperContainerAsyncMethodFlags(); + if (flags) { + return createSuperAccessInAsyncMethod(ts.createLiteral(node.name.text), flags, node); + } + } + return node; + } + function substituteElementAccessExpression(node) { + if (enabledSubstitutions & 1 && node.expression.kind === 96) { + var flags = getSuperContainerAsyncMethodFlags(); + if (flags) { + return createSuperAccessInAsyncMethod(node.argumentExpression, flags, node); + } + } + return node; + } + function substituteCallExpression(node) { + var expression = node.expression; + if (ts.isSuperProperty(expression)) { + var flags = getSuperContainerAsyncMethodFlags(); + if (flags) { + var argumentExpression = ts.isPropertyAccessExpression(expression) + ? substitutePropertyAccessExpression(expression) + : substituteElementAccessExpression(expression); + return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), undefined, [ + ts.createThis() + ].concat(node.arguments)); + } + } + return node; + } + function isSuperContainer(node) { + var kind = node.kind; + return kind === 222 + || kind === 149 + || kind === 148 + || kind === 150 + || kind === 151; + } + function onEmitNode(emitContext, node, emitCallback) { + var savedApplicableSubstitutions = applicableSubstitutions; + var savedCurrentSuperContainer = currentSuperContainer; + if (enabledSubstitutions & 1 && isSuperContainer(node)) { + currentSuperContainer = node; + } + previousOnEmitNode(emitContext, node, emitCallback); + applicableSubstitutions = savedApplicableSubstitutions; + currentSuperContainer = savedCurrentSuperContainer; + } + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1) { + return substituteExpression(node); + } + return node; + } + function createSuperAccessInAsyncMethod(argumentExpression, flags, location) { + if (flags & 4096) { + return ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), "value", location); + } + else { + return ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression], location); + } + } + function getSuperContainerAsyncMethodFlags() { + return currentSuperContainer !== undefined + && resolver.getNodeCheckFlags(currentSuperContainer) & (2048 | 4096); + } + } + ts.transformES2017 = transformES2017; +})(ts || (ts = {})); +var ts; +(function (ts) { + function transformES2016(context) { + var hoistVariableDeclaration = context.hoistVariableDeclaration; + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } + return ts.visitEachChild(node, visitor, context); + } + function visitor(node) { + if (node.transformFlags & 64) { + return visitorWorker(node); + } + else if (node.transformFlags & 128) { + return ts.visitEachChild(node, visitor, context); + } else { return node; } } function visitorWorker(node) { switch (node.kind) { - case 187: + case 188: return visitBinaryExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -38784,7 +38888,7 @@ var ts; function visitBinaryExpression(node) { var left = ts.visitNode(node.left, visitor, ts.isExpression); var right = ts.visitNode(node.right, visitor, ts.isExpression); - if (node.operatorToken.kind === 60) { + if (node.operatorToken.kind === 61) { var target = void 0; var value = void 0; if (ts.isElementAccessExpression(left)) { @@ -38804,7 +38908,7 @@ var ts; } return ts.createAssignment(target, ts.createMathPow(value, right, node), node); } - else if (node.operatorToken.kind === 38) { + else if (node.operatorToken.kind === 39) { return ts.createMathPow(left, right, node); } else { @@ -38813,11 +38917,33 @@ var ts; } } } - ts.transformES7 = transformES7; + ts.transformES2016 = transformES2016; })(ts || (ts = {})); var ts; (function (ts) { - function transformES6(context) { + var ES2015SubstitutionFlags; + (function (ES2015SubstitutionFlags) { + ES2015SubstitutionFlags[ES2015SubstitutionFlags["CapturedThis"] = 1] = "CapturedThis"; + ES2015SubstitutionFlags[ES2015SubstitutionFlags["BlockScopedBindings"] = 2] = "BlockScopedBindings"; + })(ES2015SubstitutionFlags || (ES2015SubstitutionFlags = {})); + var CopyDirection; + (function (CopyDirection) { + CopyDirection[CopyDirection["ToOriginal"] = 0] = "ToOriginal"; + CopyDirection[CopyDirection["ToOutParameter"] = 1] = "ToOutParameter"; + })(CopyDirection || (CopyDirection = {})); + var Jump; + (function (Jump) { + Jump[Jump["Break"] = 2] = "Break"; + Jump[Jump["Continue"] = 4] = "Continue"; + Jump[Jump["Return"] = 8] = "Return"; + })(Jump || (Jump = {})); + var SuperCaptureResult; + (function (SuperCaptureResult) { + SuperCaptureResult[SuperCaptureResult["NoReplacement"] = 0] = "NoReplacement"; + SuperCaptureResult[SuperCaptureResult["ReplaceSuperCapture"] = 1] = "ReplaceSuperCapture"; + SuperCaptureResult[SuperCaptureResult["ReplaceWithReturn"] = 2] = "ReplaceWithReturn"; + })(SuperCaptureResult || (SuperCaptureResult = {})); + function transformES2015(context) { var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); var previousOnSubstituteNode = context.onSubstituteNode; @@ -38880,15 +39006,15 @@ var ts; return visited; } function shouldCheckNode(node) { - return (node.transformFlags & 64) !== 0 || - node.kind === 214 || + return (node.transformFlags & 256) !== 0 || + node.kind === 215 || (ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node)); } function visitorWorker(node) { if (shouldCheckNode(node)) { return visitJavaScript(node); } - else if (node.transformFlags & 128) { + else if (node.transformFlags & 512) { return ts.visitEachChild(node, visitor, context); } else { @@ -38907,18 +39033,18 @@ var ts; } function visitNodesInConvertedLoop(node) { switch (node.kind) { - case 211: + case 212: return visitReturnStatement(node); - case 200: + case 201: return visitVariableStatement(node); - case 213: + case 214: return visitSwitchStatement(node); + case 211: case 210: - case 209: return visitBreakOrContinueStatement(node); - case 97: + case 98: return visitThisKeyword(node); - case 69: + case 70: return visitIdentifier(node); default: return ts.visitEachChild(node, visitor, context); @@ -38926,74 +39052,74 @@ var ts; } function visitJavaScript(node) { switch (node.kind) { - case 82: + case 83: return node; - case 221: + case 222: return visitClassDeclaration(node); - case 192: + case 193: return visitClassExpression(node); - case 142: + case 143: return visitParameter(node); - case 220: + case 221: return visitFunctionDeclaration(node); - case 180: + case 181: return visitArrowFunction(node); - case 179: + case 180: return visitFunctionExpression(node); - case 218: - return visitVariableDeclaration(node); - case 69: - return visitIdentifier(node); case 219: + return visitVariableDeclaration(node); + case 70: + return visitIdentifier(node); + case 220: return visitVariableDeclarationList(node); - case 214: + case 215: return visitLabeledStatement(node); - case 204: - return visitDoStatement(node); case 205: - return visitWhileStatement(node); + return visitDoStatement(node); case 206: - return visitForStatement(node); + return visitWhileStatement(node); case 207: - return visitForInStatement(node); + return visitForStatement(node); case 208: + return visitForInStatement(node); + case 209: return visitForOfStatement(node); - case 202: + case 203: return visitExpressionStatement(node); - case 171: + case 172: return visitObjectLiteralExpression(node); case 254: return visitShorthandPropertyAssignment(node); - case 170: + case 171: return visitArrayLiteralExpression(node); - case 174: - return visitCallExpression(node); case 175: + return visitCallExpression(node); + case 176: return visitNewExpression(node); - case 178: + case 179: return visitParenthesizedExpression(node, true); - case 187: + case 188: return visitBinaryExpression(node, true); - case 11: case 12: case 13: case 14: + case 15: return visitTemplateLiteral(node); - case 176: + case 177: return visitTaggedTemplateExpression(node); - case 189: + case 190: return visitTemplateExpression(node); - case 190: + case 191: return visitYieldExpression(node); - case 95: - return visitSuperKeyword(node); - case 190: + case 96: + return visitSuperKeyword(); + case 191: return ts.visitEachChild(node, visitor, context); - case 147: + case 148: return visitMethodDeclaration(node); case 256: return visitSourceFileNode(node); - case 200: + case 201: return visitVariableStatement(node); default: ts.Debug.failBadSyntaxKind(node); @@ -39008,7 +39134,7 @@ var ts; } if (ts.isFunctionLike(currentNode)) { enclosingFunction = currentNode; - if (currentNode.kind !== 180) { + if (currentNode.kind !== 181) { enclosingNonArrowFunction = currentNode; if (!(ts.getEmitFlags(currentNode) & 2097152)) { enclosingNonAsyncFunctionBody = currentNode; @@ -39016,14 +39142,14 @@ var ts; } } switch (currentNode.kind) { - case 200: + case 201: enclosingVariableStatement = currentNode; break; + case 220: case 219: - case 218: - case 169: - case 167: + case 170: case 168: + case 169: break; default: enclosingVariableStatement = undefined; @@ -39051,7 +39177,7 @@ var ts; } function visitThisKeyword(node) { ts.Debug.assert(convertedLoopState !== undefined); - if (enclosingFunction && enclosingFunction.kind === 180) { + if (enclosingFunction && enclosingFunction.kind === 181) { convertedLoopState.containsLexicalThis = true; return node; } @@ -39071,13 +39197,13 @@ var ts; } function visitBreakOrContinueStatement(node) { if (convertedLoopState) { - var jump = node.kind === 210 ? 2 : 4; + var jump = node.kind === 211 ? 2 : 4; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; if (!node.label) { - if (node.kind === 210) { + if (node.kind === 211) { convertedLoopState.nonLocalJumps |= 2; labelMarker = "break"; } @@ -39087,7 +39213,7 @@ var ts; } } else { - if (node.kind === 210) { + if (node.kind === 211) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, true, node.label.text, labelMarker); } @@ -39106,10 +39232,10 @@ var ts; expr = copyExpr; } else { - expr = ts.createBinary(expr, 24, copyExpr); + expr = ts.createBinary(expr, 25, copyExpr); } } - returnExpression = ts.createBinary(expr, 24, returnExpression); + returnExpression = ts.createBinary(expr, 25, returnExpression); } return ts.createReturn(returnExpression); } @@ -39136,7 +39262,7 @@ var ts; return statement; } function isExportModifier(node) { - return node.kind === 82; + return node.kind === 83; } function visitClassExpression(node) { return transformClassLikeDeclarationToExpression(node); @@ -39146,7 +39272,7 @@ var ts; enableSubstitutionsForBlockScopedBindings(); } var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); - var classFunction = ts.createFunctionExpression(undefined, undefined, undefined, extendsClauseElement ? [ts.createParameter("_super")] : [], undefined, transformClassBody(node, extendsClauseElement)); + var classFunction = ts.createFunctionExpression(undefined, undefined, undefined, undefined, extendsClauseElement ? [ts.createParameter("_super")] : [], undefined, transformClassBody(node, extendsClauseElement)); if (ts.getEmitFlags(node) & 524288) { ts.setEmitFlags(classFunction, 524288); } @@ -39166,7 +39292,7 @@ var ts; addExtendsHelperIfNeeded(statements, node, extendsClauseElement); addConstructor(statements, node, extendsClauseElement); addClassMembers(statements, node); - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 16); + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 17); var localName = getLocalName(node); var outer = ts.createPartiallyEmittedExpression(localName); outer.end = closingBraceLocation.end; @@ -39236,17 +39362,17 @@ var ts; return block; } function isSufficientlyCoveredByReturnStatements(statement) { - if (statement.kind === 211) { + if (statement.kind === 212) { return true; } - else if (statement.kind === 203) { + else if (statement.kind === 204) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 199) { + else if (statement.kind === 200) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -39275,7 +39401,7 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 202 && ts.isSuperCall(firstStatement.expression)) { + if (firstStatement.kind === 203 && ts.isSuperCall(firstStatement.expression)) { var superCall = firstStatement.expression; superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); } @@ -39311,7 +39437,7 @@ var ts; } } function shouldAddDefaultValueAssignments(node) { - return (node.transformFlags & 65536) !== 0; + return (node.transformFlags & 262144) !== 0; } function addDefaultValueAssignmentsIfNeeded(statements, node) { if (!shouldAddDefaultValueAssignments(node)) { @@ -39319,22 +39445,22 @@ var ts; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { var parameter = _a[_i]; - var name_35 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; + var name_32 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; if (dotDotDotToken) { continue; } - if (ts.isBindingPattern(name_35)) { - addDefaultValueAssignmentForBindingPattern(statements, parameter, name_35, initializer); + if (ts.isBindingPattern(name_32)) { + addDefaultValueAssignmentForBindingPattern(statements, parameter, name_32, initializer); } else if (initializer) { - addDefaultValueAssignmentForInitializer(statements, parameter, name_35, initializer); + addDefaultValueAssignmentForInitializer(statements, parameter, name_32, initializer); } } } function addDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer) { var temp = ts.getGeneratedNameForNode(parameter); if (name.elements.length > 0) { - statements.push(ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(ts.flattenParameterDestructuring(context, parameter, temp, visitor))), 8388608)); + statements.push(ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(ts.flattenParameterDestructuring(parameter, temp, visitor))), 8388608)); } else if (initializer) { statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 8388608)); @@ -39350,7 +39476,7 @@ var ts; statements.push(statement); } function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) { - return node && node.dotDotDotToken && node.name.kind === 69 && !inConstructorWithSynthesizedSuper; + return node && node.dotDotDotToken && node.name.kind === 70 && !inConstructorWithSynthesizedSuper; } function addRestParameterIfNeeded(statements, node, inConstructorWithSynthesizedSuper) { var parameter = ts.lastOrUndefined(node.parameters); @@ -39375,7 +39501,7 @@ var ts; statements.push(forStatement); } function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 16384 && node.kind !== 180) { + if (node.transformFlags & 65536 && node.kind !== 181) { captureThisForNode(statements, node, ts.createThis()); } } @@ -39392,20 +39518,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 198: + case 199: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 147: + case 148: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member)); break; - case 149: case 150: + case 151: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors)); } break; - case 148: + case 149: break; default: ts.Debug.failBadSyntaxKind(node); @@ -39445,6 +39571,7 @@ var ts; if (getAccessor) { var getterFunction = transformFunctionLikeToExpression(getAccessor, undefined, undefined); ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); + ts.setEmitFlags(getterFunction, 16384); var getter = ts.createPropertyAssignment("get", getterFunction); ts.setCommentRange(getter, ts.getCommentRange(getAccessor)); properties.push(getter); @@ -39452,6 +39579,7 @@ var ts; if (setAccessor) { var setterFunction = transformFunctionLikeToExpression(setAccessor, undefined, undefined); ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); + ts.setEmitFlags(setterFunction, 16384); var setter = ts.createPropertyAssignment("set", setterFunction); ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); properties.push(setter); @@ -39468,7 +39596,7 @@ var ts; return call; } function visitArrowFunction(node) { - if (node.transformFlags & 8192) { + if (node.transformFlags & 32768) { enableSubstitutionsForCapturedThis(); } var func = transformFunctionLikeToExpression(node, node, undefined); @@ -39483,10 +39611,10 @@ var ts; } function transformFunctionLikeToExpression(node, location, name) { var savedContainingNonArrowFunction = enclosingNonArrowFunction; - if (node.kind !== 180) { + if (node.kind !== 181) { enclosingNonArrowFunction = node; } - var expression = ts.setOriginalNode(ts.createFunctionExpression(node.asteriskToken, name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, saveStateAndInvoke(node, transformFunctionBody), location), node); + var expression = ts.setOriginalNode(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, saveStateAndInvoke(node, transformFunctionBody), location), node); enclosingNonArrowFunction = savedContainingNonArrowFunction; return expression; } @@ -39516,7 +39644,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 180); + ts.Debug.assert(node.kind === 181); statementsLocation = ts.moveRangeEnd(body, -1); var equalsGreaterThanToken = node.equalsGreaterThanToken; if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { @@ -39543,16 +39671,16 @@ var ts; ts.setEmitFlags(block, 32); } if (closeBraceLocation) { - ts.setTokenSourceMapRange(block, 16, closeBraceLocation); + ts.setTokenSourceMapRange(block, 17, closeBraceLocation); } ts.setOriginalNode(block, node.body); return block; } function visitExpressionStatement(node) { switch (node.expression.kind) { - case 178: + case 179: return ts.updateStatement(node, visitParenthesizedExpression(node.expression, false)); - case 187: + case 188: return ts.updateStatement(node, visitBinaryExpression(node.expression, false)); } return ts.visitEachChild(node, visitor, context); @@ -39560,9 +39688,9 @@ var ts; function visitParenthesizedExpression(node, needsDestructuringValue) { if (needsDestructuringValue) { switch (node.expression.kind) { - case 178: + case 179: return ts.createParen(visitParenthesizedExpression(node.expression, true), node); - case 187: + case 188: return ts.createParen(visitBinaryExpression(node.expression, true), node); } } @@ -39581,16 +39709,16 @@ var ts; if (decl.initializer) { var assignment = void 0; if (ts.isBindingPattern(decl.name)) { - assignment = ts.flattenVariableDestructuringToExpression(context, decl, hoistVariableDeclaration, undefined, visitor); + assignment = ts.flattenVariableDestructuringToExpression(decl, hoistVariableDeclaration, undefined, visitor); } else { - assignment = ts.createBinary(decl.name, 56, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + assignment = ts.createBinary(decl.name, 57, ts.visitNode(decl.initializer, visitor, ts.isExpression)); } (assignments || (assignments = [])).push(assignment); } } if (assignments) { - return ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 24, acc); }), node); + return ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25, acc); }), node); } else { return undefined; @@ -39608,7 +39736,7 @@ var ts; var declarationList = ts.createVariableDeclarationList(declarations, node); ts.setOriginalNode(declarationList, node); ts.setCommentRange(declarationList, node); - if (node.transformFlags & 2097152 + if (node.transformFlags & 8388608 && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { var firstDeclaration = ts.firstOrUndefined(declarations); @@ -39627,8 +39755,8 @@ var ts; && ts.isBlock(enclosingBlockScopeContainer) && ts.isIterationStatement(enclosingBlockScopeContainerParent, false)); var emitExplicitInitializer = !emittedAsTopLevel - && enclosingBlockScopeContainer.kind !== 207 && enclosingBlockScopeContainer.kind !== 208 + && enclosingBlockScopeContainer.kind !== 209 && (!resolver.isDeclarationWithCollidingName(node) || (isDeclaredInLoop && !isCapturedInFunction @@ -39651,7 +39779,7 @@ var ts; if (ts.isBindingPattern(node.name)) { var recordTempVariablesInLine = !enclosingVariableStatement || !ts.hasModifier(enclosingVariableStatement, 1); - return ts.flattenVariableDestructuring(context, node, undefined, visitor, recordTempVariablesInLine ? undefined : hoistVariableDeclaration); + return ts.flattenVariableDestructuring(node, undefined, visitor, recordTempVariablesInLine ? undefined : hoistVariableDeclaration); } return ts.visitEachChild(node, visitor, context); } @@ -39694,7 +39822,7 @@ var ts; var initializer = node.initializer; var statements = []; var counter = ts.createLoopVariable(); - var rhsReference = expression.kind === 69 + var rhsReference = expression.kind === 70 ? ts.createUniqueName(expression.text) : ts.createTempVariable(undefined); if (ts.isVariableDeclarationList(initializer)) { @@ -39703,7 +39831,7 @@ var ts; } var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { - var declarations = ts.flattenVariableDestructuring(context, firstOriginalDeclaration, ts.createElementAccess(rhsReference, counter), visitor); + var declarations = ts.flattenVariableDestructuring(firstOriginalDeclaration, ts.createElementAccess(rhsReference, counter), visitor); var declarationList = ts.createVariableDeclarationList(declarations, initializer); ts.setOriginalNode(declarationList, initializer); var firstDeclaration = declarations[0]; @@ -39759,8 +39887,8 @@ var ts; var numInitialProperties = numProperties; for (var i = 0; i < numProperties; i++) { var property = properties[i]; - if (property.transformFlags & 4194304 - || property.name.kind === 140) { + if (property.transformFlags & 16777216 + || property.name.kind === 141) { numInitialProperties = i; break; } @@ -39786,7 +39914,7 @@ var ts; } visit(node.name); function visit(node) { - if (node.kind === 69) { + if (node.kind === 70) { state.hoistedLocalVariables.push(node); } else { @@ -39815,11 +39943,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 206: case 207: case 208: + case 209: var initializer = node.initializer; - if (initializer && initializer.kind === 219) { + if (initializer && initializer.kind === 220) { loopInitializer = initializer; } break; @@ -39858,7 +39986,7 @@ var ts; } var isAsyncBlockContainingAwait = enclosingNonArrowFunction && (ts.getEmitFlags(enclosingNonArrowFunction) & 2097152) !== 0 - && (node.statement.transformFlags & 4194304) !== 0; + && (node.statement.transformFlags & 16777216) !== 0; var loopBodyFlags = 0; if (currentState.containsLexicalThis) { loopBodyFlags |= 256; @@ -39867,7 +39995,7 @@ var ts; loopBodyFlags |= 2097152; } var convertedLoopVariable = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(functionName, undefined, ts.setEmitFlags(ts.createFunctionExpression(isAsyncBlockContainingAwait ? ts.createToken(37) : undefined, undefined, undefined, loopParameters, undefined, loopBody), loopBodyFlags)) + ts.createVariableDeclaration(functionName, undefined, ts.setEmitFlags(ts.createFunctionExpression(undefined, isAsyncBlockContainingAwait ? ts.createToken(38) : undefined, undefined, undefined, loopParameters, undefined, loopBody), loopBodyFlags)) ])); var statements = [convertedLoopVariable]; var extraVariableDeclarations; @@ -39926,7 +40054,7 @@ var ts; loop.transformFlags = 0; ts.aggregateTransformFlags(loop); } - statements.push(currentParent.kind === 214 + statements.push(currentParent.kind === 215 ? ts.createLabel(currentParent.label, loop) : loop); return statements; @@ -39934,7 +40062,7 @@ var ts; function copyOutParameter(outParam, copyDirection) { var source = copyDirection === 0 ? outParam.outParamName : outParam.originalName; var target = copyDirection === 0 ? outParam.originalName : outParam.outParamName; - return ts.createBinary(target, 56, source); + return ts.createBinary(target, 57, source); } function copyOutParameters(outParams, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { @@ -39949,7 +40077,7 @@ var ts; !state.labeledNonLocalBreaks && !state.labeledNonLocalContinues; var call = ts.createCall(loopFunctionExpressionName, undefined, ts.map(parameters, function (p) { return p.name; })); - var callResult = isAsyncBlockContainingAwait ? ts.createYield(ts.createToken(37), call) : call; + var callResult = isAsyncBlockContainingAwait ? ts.createYield(ts.createToken(38), call) : call; if (isSimpleLoop) { statements.push(ts.createStatement(callResult)); copyOutParameters(state.loopOutParameters, 0, statements); @@ -39968,10 +40096,10 @@ var ts; else { returnStatement = ts.createReturn(ts.createPropertyAccess(loopResultName, "value")); } - statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 32, ts.createLiteral("object")), returnStatement)); + statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 33, ts.createLiteral("object")), returnStatement)); } if (state.nonLocalJumps & 2) { - statements.push(ts.createIf(ts.createBinary(loopResultName, 32, ts.createLiteral("break")), ts.createBreak())); + statements.push(ts.createIf(ts.createBinary(loopResultName, 33, ts.createLiteral("break")), ts.createBreak())); } if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { var caseClauses = []; @@ -40038,21 +40166,21 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 149: case 150: + case 151: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node.multiLine)); } break; case 253: - expressions.push(transformPropertyAssignmentToExpression(node, property, receiver, node.multiLine)); + expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; case 254: - expressions.push(transformShorthandPropertyAssignmentToExpression(node, property, receiver, node.multiLine)); + expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 147: - expressions.push(transformObjectLiteralMethodDeclarationToExpression(node, property, receiver, node.multiLine)); + case 148: + expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node.multiLine)); break; default: ts.Debug.failBadSyntaxKind(node); @@ -40060,21 +40188,21 @@ var ts; } } } - function transformPropertyAssignmentToExpression(node, property, receiver, startsOnNewLine) { + function transformPropertyAssignmentToExpression(property, receiver, startsOnNewLine) { var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.visitNode(property.initializer, visitor, ts.isExpression), property); if (startsOnNewLine) { expression.startsOnNewLine = true; } return expression; } - function transformShorthandPropertyAssignmentToExpression(node, property, receiver, startsOnNewLine) { + function transformShorthandPropertyAssignmentToExpression(property, receiver, startsOnNewLine) { var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.getSynthesizedClone(property.name), property); if (startsOnNewLine) { expression.startsOnNewLine = true; } return expression; } - function transformObjectLiteralMethodDeclarationToExpression(node, method, receiver, startsOnNewLine) { + function transformObjectLiteralMethodDeclarationToExpression(method, receiver, startsOnNewLine) { var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, method, undefined), method); if (startsOnNewLine) { expression.startsOnNewLine = true; @@ -40104,17 +40232,17 @@ var ts; } function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) { var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 95) { + if (node.expression.kind === 96) { ts.setEmitFlags(thisArg, 128); } var resultingCall; - if (node.transformFlags & 262144) { + if (node.transformFlags & 1048576) { resultingCall = ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, false, false, false)); } else { resultingCall = ts.createFunctionCall(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), node); } - if (node.expression.kind === 95) { + if (node.expression.kind === 96) { var actualThis = ts.createThis(); ts.setEmitFlags(actualThis, 128); var initializer = ts.createLogicalOr(resultingCall, actualThis); @@ -40125,18 +40253,18 @@ var ts; return resultingCall; } function visitNewExpression(node) { - ts.Debug.assert((node.transformFlags & 262144) !== 0); + ts.Debug.assert((node.transformFlags & 1048576) !== 0); var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), false, false, false)), undefined, []); } function transformAndSpreadElements(elements, needsUniqueCopy, multiLine, hasTrailingComma) { var numElements = elements.length; - var segments = ts.flatten(ts.spanMap(elements, partitionSpreadElement, function (partition, visitPartition, start, end) { + var segments = ts.flatten(ts.spanMap(elements, partitionSpreadElement, function (partition, visitPartition, _start, end) { return visitPartition(partition, multiLine, hasTrailingComma && end === numElements); })); if (segments.length === 1) { var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadElementExpression(firstElement) && firstElement.expression.kind !== 170 + return needsUniqueCopy && ts.isSpreadElementExpression(firstElement) && firstElement.expression.kind !== 171 ? ts.createArraySlice(segments[0]) : segments[0]; } @@ -40147,7 +40275,7 @@ var ts; ? visitSpanOfSpreadElements : visitSpanOfNonSpreadElements; } - function visitSpanOfSpreadElements(chunk, multiLine, hasTrailingComma) { + function visitSpanOfSpreadElements(chunk) { return ts.map(chunk, visitExpressionOfSpreadElement); } function visitSpanOfNonSpreadElements(chunk, multiLine, hasTrailingComma) { @@ -40188,7 +40316,7 @@ var ts; } function getRawLiteral(node) { var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - var isLast = node.kind === 11 || node.kind === 14; + var isLast = node.kind === 12 || node.kind === 15; text = text.substring(1, text.length - (isLast ? 1 : 2)); text = text.replace(/\r\n?/g, "\n"); return ts.createLiteral(text, node); @@ -40222,11 +40350,11 @@ var ts; } } } - function visitSuperKeyword(node) { + function visitSuperKeyword() { return enclosingNonAsyncFunctionBody && ts.isClassElement(enclosingNonAsyncFunctionBody) && !ts.hasModifier(enclosingNonAsyncFunctionBody, 32) - && currentParent.kind !== 174 + && currentParent.kind !== 175 ? ts.createPropertyAccess(ts.createIdentifier("_super"), "prototype") : ts.createIdentifier("_super"); } @@ -40253,20 +40381,20 @@ var ts; function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; - context.enableSubstitution(69); + context.enableSubstitution(70); } } function enableSubstitutionsForCapturedThis() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(97); - context.enableEmitNotification(148); - context.enableEmitNotification(147); + context.enableSubstitution(98); context.enableEmitNotification(149); + context.enableEmitNotification(148); context.enableEmitNotification(150); + context.enableEmitNotification(151); + context.enableEmitNotification(181); context.enableEmitNotification(180); - context.enableEmitNotification(179); - context.enableEmitNotification(220); + context.enableEmitNotification(221); } } function onSubstituteNode(emitContext, node) { @@ -40291,10 +40419,10 @@ var ts; function isNameOfDeclarationWithCollidingName(node) { var parent = node.parent; switch (parent.kind) { - case 169: - case 221: - case 224: - case 218: + case 170: + case 222: + case 225: + case 219: return parent.name === node && resolver.isDeclarationWithCollidingName(parent); } @@ -40302,9 +40430,9 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 69: + case 70: return substituteExpressionIdentifier(node); - case 97: + case 98: return substituteThisKeyword(node); } return node; @@ -40331,7 +40459,7 @@ var ts; } function getDeclarationName(node, allowComments, allowSourceMaps, emitFlags) { if (node.name && !ts.isGeneratedIdentifier(node.name)) { - var name_36 = ts.getMutableClone(node.name); + var name_33 = ts.getMutableClone(node.name); emitFlags |= ts.getEmitFlags(node.name); if (!allowSourceMaps) { emitFlags |= 1536; @@ -40340,9 +40468,9 @@ var ts; emitFlags |= 49152; } if (emitFlags) { - ts.setEmitFlags(name_36, emitFlags); + ts.setEmitFlags(name_33, emitFlags); } - return name_36; + return name_33; } return ts.getGeneratedNameForNode(node); } @@ -40359,29 +40487,74 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 202) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 203) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 174) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 175) { return false; } var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 95) { + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 96) { return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 191) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 192) { return false; } var expression = callArgument.expression; return ts.isIdentifier(expression) && expression === parameter.name; } } - ts.transformES6 = transformES6; + ts.transformES2015 = transformES2015; })(ts || (ts = {})); var ts; (function (ts) { + var OpCode; + (function (OpCode) { + OpCode[OpCode["Nop"] = 0] = "Nop"; + OpCode[OpCode["Statement"] = 1] = "Statement"; + OpCode[OpCode["Assign"] = 2] = "Assign"; + OpCode[OpCode["Break"] = 3] = "Break"; + OpCode[OpCode["BreakWhenTrue"] = 4] = "BreakWhenTrue"; + OpCode[OpCode["BreakWhenFalse"] = 5] = "BreakWhenFalse"; + OpCode[OpCode["Yield"] = 6] = "Yield"; + OpCode[OpCode["YieldStar"] = 7] = "YieldStar"; + OpCode[OpCode["Return"] = 8] = "Return"; + OpCode[OpCode["Throw"] = 9] = "Throw"; + OpCode[OpCode["Endfinally"] = 10] = "Endfinally"; + })(OpCode || (OpCode = {})); + var BlockAction; + (function (BlockAction) { + BlockAction[BlockAction["Open"] = 0] = "Open"; + BlockAction[BlockAction["Close"] = 1] = "Close"; + })(BlockAction || (BlockAction = {})); + var CodeBlockKind; + (function (CodeBlockKind) { + CodeBlockKind[CodeBlockKind["Exception"] = 0] = "Exception"; + CodeBlockKind[CodeBlockKind["With"] = 1] = "With"; + CodeBlockKind[CodeBlockKind["Switch"] = 2] = "Switch"; + CodeBlockKind[CodeBlockKind["Loop"] = 3] = "Loop"; + CodeBlockKind[CodeBlockKind["Labeled"] = 4] = "Labeled"; + })(CodeBlockKind || (CodeBlockKind = {})); + var ExceptionBlockState; + (function (ExceptionBlockState) { + ExceptionBlockState[ExceptionBlockState["Try"] = 0] = "Try"; + ExceptionBlockState[ExceptionBlockState["Catch"] = 1] = "Catch"; + ExceptionBlockState[ExceptionBlockState["Finally"] = 2] = "Finally"; + ExceptionBlockState[ExceptionBlockState["Done"] = 3] = "Done"; + })(ExceptionBlockState || (ExceptionBlockState = {})); + var Instruction; + (function (Instruction) { + Instruction[Instruction["Next"] = 0] = "Next"; + Instruction[Instruction["Throw"] = 1] = "Throw"; + Instruction[Instruction["Return"] = 2] = "Return"; + Instruction[Instruction["Break"] = 3] = "Break"; + Instruction[Instruction["Yield"] = 4] = "Yield"; + Instruction[Instruction["YieldStar"] = 5] = "YieldStar"; + Instruction[Instruction["Catch"] = 6] = "Catch"; + Instruction[Instruction["Endfinally"] = 7] = "Endfinally"; + })(Instruction || (Instruction = {})); var instructionNames = ts.createMap((_a = {}, _a[2] = "return", _a[3] = "break", @@ -40427,7 +40600,7 @@ var ts; if (ts.isDeclarationFile(node)) { return node; } - if (node.transformFlags & 1024) { + if (node.transformFlags & 4096) { currentSourceFile = node; node = ts.visitEachChild(node, visitor, context); currentSourceFile = undefined; @@ -40442,10 +40615,10 @@ var ts; else if (inGeneratorFunctionBody) { return visitJavaScriptInGeneratorFunctionBody(node); } - else if (transformFlags & 512) { + else if (transformFlags & 2048) { return visitGenerator(node); } - else if (transformFlags & 1024) { + else if (transformFlags & 4096) { return ts.visitEachChild(node, visitor, context); } else { @@ -40454,13 +40627,13 @@ var ts; } function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 204: - return visitDoStatement(node); case 205: + return visitDoStatement(node); + case 206: return visitWhileStatement(node); - case 213: - return visitSwitchStatement(node); case 214: + return visitSwitchStatement(node); + case 215: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -40468,30 +40641,30 @@ var ts; } function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 220: + case 221: return visitFunctionDeclaration(node); - case 179: + case 180: return visitFunctionExpression(node); - case 149: case 150: + case 151: return visitAccessorDeclaration(node); - case 200: + case 201: return visitVariableStatement(node); - case 206: - return visitForStatement(node); case 207: + return visitForStatement(node); + case 208: return visitForInStatement(node); - case 210: - return visitBreakStatement(node); - case 209: - return visitContinueStatement(node); case 211: + return visitBreakStatement(node); + case 210: + return visitContinueStatement(node); + case 212: return visitReturnStatement(node); default: - if (node.transformFlags & 4194304) { + if (node.transformFlags & 16777216) { return visitJavaScriptContainingYield(node); } - else if (node.transformFlags & (1024 | 8388608)) { + else if (node.transformFlags & (4096 | 33554432)) { return ts.visitEachChild(node, visitor, context); } else { @@ -40501,21 +40674,21 @@ var ts; } function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 187: - return visitBinaryExpression(node); case 188: + return visitBinaryExpression(node); + case 189: return visitConditionalExpression(node); - case 190: + case 191: return visitYieldExpression(node); - case 170: - return visitArrayLiteralExpression(node); case 171: + return visitArrayLiteralExpression(node); + case 172: return visitObjectLiteralExpression(node); - case 173: - return visitElementAccessExpression(node); case 174: - return visitCallExpression(node); + return visitElementAccessExpression(node); case 175: + return visitCallExpression(node); + case 176: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -40523,9 +40696,9 @@ var ts; } function visitGenerator(node) { switch (node.kind) { - case 220: + case 221: return visitFunctionDeclaration(node); - case 179: + case 180: return visitFunctionExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -40555,7 +40728,7 @@ var ts; } function visitFunctionExpression(node) { if (node.asteriskToken && ts.getEmitFlags(node) & 2097152) { - node = ts.setOriginalNode(ts.createFunctionExpression(undefined, node.name, undefined, node.parameters, undefined, transformGeneratorFunctionBody(node.body), node), node); + node = ts.setOriginalNode(ts.createFunctionExpression(undefined, undefined, node.name, undefined, node.parameters, undefined, transformGeneratorFunctionBody(node.body), node), node); } else { var savedInGeneratorFunctionBody = inGeneratorFunctionBody; @@ -40628,7 +40801,7 @@ var ts; return ts.createBlock(statements, body, body.multiLine); } function visitVariableStatement(node) { - if (node.transformFlags & 4194304) { + if (node.transformFlags & 16777216) { transformAndEmitVariableDeclarationList(node.declarationList); return undefined; } @@ -40658,23 +40831,23 @@ var ts; } } function isCompoundAssignment(kind) { - return kind >= 57 - && kind <= 68; + return kind >= 58 + && kind <= 69; } function getOperatorForCompoundAssignment(kind) { switch (kind) { - case 57: return 35; case 58: return 36; case 59: return 37; case 60: return 38; case 61: return 39; case 62: return 40; - case 63: return 43; + case 63: return 41; case 64: return 44; case 65: return 45; case 66: return 46; case 67: return 47; case 68: return 48; + case 69: return 49; } } function visitRightAssociativeBinaryExpression(node) { @@ -40682,10 +40855,10 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 172: + case 173: target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 173: + case 174: target = ts.updateElementAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), cacheExpression(ts.visitNode(left.argumentExpression, visitor, ts.isExpression))); break; default: @@ -40694,7 +40867,7 @@ var ts; } var operator = node.operatorToken.kind; if (isCompoundAssignment(operator)) { - return ts.createBinary(target, 56, ts.createBinary(cacheExpression(target), getOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression), node), node); + return ts.createBinary(target, 57, ts.createBinary(cacheExpression(target), getOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression), node), node); } else { return ts.updateBinary(node, target, ts.visitNode(right, visitor, ts.isExpression)); @@ -40707,7 +40880,7 @@ var ts; if (ts.isLogicalOperator(node.operatorToken.kind)) { return visitLogicalBinaryExpression(node); } - else if (node.operatorToken.kind === 24) { + else if (node.operatorToken.kind === 25) { return visitCommaExpression(node); } var clone_6 = ts.getMutableClone(node); @@ -40721,7 +40894,7 @@ var ts; var resultLabel = defineLabel(); var resultLocal = declareLocal(); emitAssignment(resultLocal, ts.visitNode(node.left, visitor, ts.isExpression), node.left); - if (node.operatorToken.kind === 51) { + if (node.operatorToken.kind === 52) { emitBreakWhenFalse(resultLabel, resultLocal, node.left); } else { @@ -40737,7 +40910,7 @@ var ts; visit(node.right); return ts.inlineExpressions(pendingExpressions); function visit(node) { - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 24) { + if (ts.isBinaryExpression(node) && node.operatorToken.kind === 25) { visit(node.left); visit(node.right); } @@ -40780,7 +40953,7 @@ var ts; function visitArrayLiteralExpression(node) { return visitElements(node.elements, node.multiLine); } - function visitElements(elements, multiLine) { + function visitElements(elements, _multiLine) { var numInitialElements = countInitialNodesWithoutYield(elements); var temp = declareLocal(); var hasAssignedTemp = false; @@ -40841,14 +41014,14 @@ var ts; function visitCallExpression(node) { if (ts.forEach(node.arguments, containsYield)) { var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration, languageVersion, true), target = _a.target, thisArg = _a.thisArg; - return ts.setOriginalNode(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isLeftHandSideExpression)), thisArg, visitElements(node.arguments, false), node), node); + return ts.setOriginalNode(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isLeftHandSideExpression)), thisArg, visitElements(node.arguments), node), node); } return ts.visitEachChild(node, visitor, context); } function visitNewExpression(node) { if (ts.forEach(node.arguments, containsYield)) { var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.setOriginalNode(ts.createNew(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isExpression)), thisArg, visitElements(node.arguments, false)), undefined, [], node), node); + return ts.setOriginalNode(ts.createNew(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isExpression)), thisArg, visitElements(node.arguments)), undefined, [], node), node); } return ts.visitEachChild(node, visitor, context); } @@ -40877,35 +41050,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 199: + case 200: return transformAndEmitBlock(node); - case 202: - return transformAndEmitExpressionStatement(node); case 203: - return transformAndEmitIfStatement(node); + return transformAndEmitExpressionStatement(node); case 204: - return transformAndEmitDoStatement(node); + return transformAndEmitIfStatement(node); case 205: - return transformAndEmitWhileStatement(node); + return transformAndEmitDoStatement(node); case 206: - return transformAndEmitForStatement(node); + return transformAndEmitWhileStatement(node); case 207: + return transformAndEmitForStatement(node); + case 208: return transformAndEmitForInStatement(node); - case 209: - return transformAndEmitContinueStatement(node); case 210: - return transformAndEmitBreakStatement(node); + return transformAndEmitContinueStatement(node); case 211: - return transformAndEmitReturnStatement(node); + return transformAndEmitBreakStatement(node); case 212: - return transformAndEmitWithStatement(node); + return transformAndEmitReturnStatement(node); case 213: - return transformAndEmitSwitchStatement(node); + return transformAndEmitWithStatement(node); case 214: - return transformAndEmitLabeledStatement(node); + return transformAndEmitSwitchStatement(node); case 215: - return transformAndEmitThrowStatement(node); + return transformAndEmitLabeledStatement(node); case 216: + return transformAndEmitThrowStatement(node); + case 217: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement, true)); @@ -41290,7 +41463,7 @@ var ts; } } function containsYield(node) { - return node && (node.transformFlags & 4194304) !== 0; + return node && (node.transformFlags & 16777216) !== 0; } function countInitialNodesWithoutYield(nodes) { var numNodes = nodes.length; @@ -41320,9 +41493,9 @@ var ts; if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - var name_37 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); - if (name_37) { - var clone_8 = ts.getMutableClone(name_37); + var name_34 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); + if (name_34) { + var clone_8 = ts.getMutableClone(name_34); ts.setSourceMapRange(clone_8, node); ts.setCommentRange(clone_8, node); return clone_8; @@ -41431,7 +41604,7 @@ var ts; if (!renamedCatchVariables) { renamedCatchVariables = ts.createMap(); renamedCatchVariableDeclarations = ts.createMap(); - context.enableSubstitution(69); + context.enableSubstitution(70); } renamedCatchVariables[text] = true; renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; @@ -41630,7 +41803,7 @@ var ts; } return expression; } - return ts.createNode(193); + return ts.createNode(194); } function createInstruction(instruction) { var literal = ts.createLiteral(instruction); @@ -41718,7 +41891,7 @@ var ts; var buildResult = buildStatements(); return ts.createCall(ts.createHelperName(currentSourceFile.externalHelpersModuleName, "__generator"), undefined, [ ts.createThis(), - ts.setEmitFlags(ts.createFunctionExpression(undefined, undefined, undefined, [ts.createParameter(state)], undefined, ts.createBlock(buildResult, undefined, buildResult.length > 0)), 4194304) + ts.setEmitFlags(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(state)], undefined, ts.createBlock(buildResult, undefined, buildResult.length > 0)), 4194304) ]); } function buildStatements() { @@ -41985,6 +42158,51 @@ var ts; var _a; })(ts || (ts = {})); var ts; +(function (ts) { + function transformES5(context) { + var previousOnSubstituteNode = context.onSubstituteNode; + context.onSubstituteNode = onSubstituteNode; + context.enableSubstitution(173); + context.enableSubstitution(253); + return transformSourceFile; + function transformSourceFile(node) { + return node; + } + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (ts.isPropertyAccessExpression(node)) { + return substitutePropertyAccessExpression(node); + } + else if (ts.isPropertyAssignment(node)) { + return substitutePropertyAssignment(node); + } + return node; + } + function substitutePropertyAccessExpression(node) { + var literalName = trySubstituteReservedName(node.name); + if (literalName) { + return ts.createElementAccess(node.expression, literalName, node); + } + return node; + } + function substitutePropertyAssignment(node) { + var literalName = ts.isIdentifier(node.name) && trySubstituteReservedName(node.name); + if (literalName) { + return ts.updatePropertyAssignment(node, literalName, node.initializer); + } + return node; + } + function trySubstituteReservedName(name) { + var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(name.text) : undefined); + if (token >= 71 && token <= 106) { + return ts.createLiteral(name, name); + } + return undefined; + } + } + ts.transformES5 = transformES5; +})(ts || (ts = {})); +var ts; (function (ts) { function transformModule(context) { var transformModuleDelegates = ts.createMap((_a = {}, @@ -42003,10 +42221,10 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(69); - context.enableSubstitution(187); - context.enableSubstitution(185); + context.enableSubstitution(70); + context.enableSubstitution(188); context.enableSubstitution(186); + context.enableSubstitution(187); context.enableSubstitution(254); context.enableEmitNotification(256); var currentSourceFile; @@ -42023,7 +42241,7 @@ var ts; } if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { currentSourceFile = node; - (_a = ts.collectExternalModuleInfo(node, resolver), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); + (_a = ts.collectExternalModuleInfo(node), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); var transformModule_1 = transformModuleDelegates[moduleKind] || transformModuleDelegates[ts.ModuleKind.None]; var updated = transformModule_1(node); ts.aggregateTransformFlags(updated); @@ -42068,7 +42286,7 @@ var ts; ts.createLiteral("require"), ts.createLiteral("exports") ].concat(aliasedModuleNames, unaliasedModuleNames)), - ts.createFunctionExpression(undefined, undefined, undefined, [ + ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ ts.createParameter("require"), ts.createParameter("exports") ].concat(importAliasNames), undefined, transformAsynchronousModuleBody(node)) @@ -42089,7 +42307,7 @@ var ts; return body; } function addExportEqualsIfNeeded(statements, emitAsReturn) { - if (exportEquals && resolver.isValueAliasDeclaration(exportEquals)) { + if (exportEquals) { if (emitAsReturn) { var statement = ts.createReturn(exportEquals.expression, exportEquals); ts.setEmitFlags(statement, 12288 | 49152); @@ -42104,21 +42322,21 @@ var ts; } function visitor(node) { switch (node.kind) { - case 230: + case 231: return visitImportDeclaration(node); - case 229: + case 230: return visitImportEqualsDeclaration(node); - case 236: + case 237: return visitExportDeclaration(node); - case 235: + case 236: return visitExportAssignment(node); - case 200: + case 201: return visitVariableStatement(node); - case 220: - return visitFunctionDeclaration(node); case 221: + return visitFunctionDeclaration(node); + case 222: return visitClassDeclaration(node); - case 202: + case 203: return visitExpressionStatement(node); default: return node; @@ -42194,14 +42412,12 @@ var ts; } for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; - if (resolver.isValueAliasDeclaration(specifier)) { - var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); - statements.push(ts.createStatement(createExportAssignment(specifier.name, exportedValue), specifier)); - } + var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); + statements.push(ts.createStatement(createExportAssignment(specifier.name, exportedValue), specifier)); } return ts.singleOrMany(statements); } - else if (resolver.moduleExportsSomeValue(node.moduleSpecifier)) { + else { return ts.createStatement(ts.createCall(ts.createIdentifier("__export"), undefined, [ moduleKind !== ts.ModuleKind.AMD ? createRequireCall(node) @@ -42210,14 +42426,12 @@ var ts; } } function visitExportAssignment(node) { - if (!node.isExportEquals) { - if (ts.nodeIsSynthesized(node) || resolver.isValueAliasDeclaration(node)) { - var statements = []; - addExportDefault(statements, node.expression, node); - return statements; - } + if (node.isExportEquals) { + return undefined; } - return undefined; + var statements = []; + addExportDefault(statements, node.expression, node); + return statements; } function addExportDefault(statements, expression, location) { tryAddExportDefaultCompat(statements); @@ -42248,16 +42462,16 @@ var ts; else { var names = ts.reduceEachChild(node, collectExportMembers, []); for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_38 = names_1[_i]; - addExportMemberAssignments(statements, name_38); + var name_35 = names_1[_i]; + addExportMemberAssignments(statements, name_35); } } } function collectExportMembers(names, node) { - if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node) && ts.isDeclaration(node)) { - var name_39 = node.name; - if (ts.isIdentifier(name_39)) { - names.push(name_39); + if (ts.isAliasSymbolDeclaration(node) && ts.isDeclaration(node)) { + var name_36 = node.name; + if (ts.isIdentifier(name_36)) { + names.push(name_36); } } return ts.reduceEachChild(node, collectExportMembers, names); @@ -42280,9 +42494,9 @@ var ts; } function visitVariableStatement(node) { var originalKind = ts.getOriginalNode(node).kind; - if (originalKind === 225 || - originalKind === 224 || - originalKind === 221) { + if (originalKind === 226 || + originalKind === 225 || + originalKind === 222) { if (!ts.hasModifier(node, 1)) { return node; } @@ -42328,7 +42542,7 @@ var ts; function transformInitializedVariable(node) { var name = node.name; if (ts.isBindingPattern(name)) { - return ts.flattenVariableDestructuringToExpression(context, node, hoistVariableDeclaration, getModuleMemberName, visitor); + return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, getModuleMemberName, visitor); } else { return ts.createAssignment(getModuleMemberName(name), ts.visitNode(node.initializer, visitor, ts.isExpression)); @@ -42338,7 +42552,8 @@ var ts; var statements = []; var name = node.name || ts.getGeneratedNameForNode(node); if (ts.hasModifier(node, 1)) { - statements.push(ts.setOriginalNode(ts.createFunctionDeclaration(undefined, undefined, node.asteriskToken, name, undefined, node.parameters, undefined, node.body, node), node)); + var isAsync = ts.hasModifier(node, 256); + statements.push(ts.setOriginalNode(ts.createFunctionDeclaration(undefined, isAsync ? [ts.createNode(119)] : undefined, node.asteriskToken, name, undefined, node.parameters, undefined, node.body, node), node)); addExportMemberAssignment(statements, node); } else { @@ -42367,10 +42582,10 @@ var ts; function visitExpressionStatement(node) { var original = ts.getOriginalNode(node); var origKind = original.kind; - if (origKind === 224 || origKind === 225) { + if (origKind === 225 || origKind === 226) { return visitExpressionStatementForEnumOrNamespaceDeclaration(node, original); } - else if (origKind === 221) { + else if (origKind === 222) { var classDecl = original; if (classDecl.name) { var statements = [node]; @@ -42383,8 +42598,8 @@ var ts; function visitExpressionStatementForEnumOrNamespaceDeclaration(node, original) { var statements = [node]; if (ts.hasModifier(original, 1) && - original.kind === 224 && - ts.isFirstDeclarationOfKind(original, 224)) { + original.kind === 225 && + ts.isFirstDeclarationOfKind(original, 225)) { addVarForExportedEnumOrNamespaceDeclaration(statements, original); } addExportMemberAssignments(statements, original.name); @@ -42432,12 +42647,12 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 69: + case 70: return substituteExpressionIdentifier(node); - case 187: + case 188: return substituteBinaryExpression(node); + case 187: case 186: - case 185: return substituteUnaryExpression(node); } return node; @@ -42471,8 +42686,8 @@ var ts; if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, operand.text)) { ts.setEmitFlags(node, 128); var transformedUnaryExpression = void 0; - if (node.kind === 186) { - transformedUnaryExpression = ts.createBinary(operand, ts.createToken(operator === 41 ? 57 : 58), ts.createLiteral(1), node); + if (node.kind === 187) { + transformedUnaryExpression = ts.createBinary(operand, ts.createToken(operator === 42 ? 58 : 59), ts.createLiteral(1), node); ts.setEmitFlags(transformedUnaryExpression, 128); } var nestedExportAssignment = void 0; @@ -42504,21 +42719,11 @@ var ts; var declaration = resolver.getReferencedImportDeclaration(node); if (declaration) { if (ts.isImportClause(declaration)) { - if (languageVersion >= 1) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent), ts.createIdentifier("default"), node); - } - else { - return ts.createElementAccess(ts.getGeneratedNameForNode(declaration.parent), ts.createLiteral("default"), node); - } + return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent), ts.createIdentifier("default"), node); } else if (ts.isImportSpecifier(declaration)) { - var name_40 = declaration.propertyName || declaration.name; - if (name_40.originalKeywordKind === 77 && languageVersion <= 0) { - return ts.createElementAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.createLiteral(name_40.text), node); - } - else { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.getSynthesizedClone(name_40), node); - } + var name_37 = declaration.propertyName || declaration.name; + return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.getSynthesizedClone(name_37), node); } } } @@ -42544,9 +42749,7 @@ var ts; return statement; } function createExportAssignment(name, value) { - return ts.createAssignment(name.originalKeywordKind === 77 && languageVersion === 0 - ? ts.createElementAccess(ts.createIdentifier("exports"), ts.createLiteral(name.text)) - : ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value); + return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value); } function collectAsynchronousDependencies(node, includeNonAmdDependencies) { var aliasedModuleNames = []; @@ -42593,15 +42796,14 @@ var ts; var compilerOptions = context.getCompilerOptions(); var resolver = context.getEmitResolver(); var host = context.getEmitHost(); - var languageVersion = ts.getEmitScriptTarget(compilerOptions); var previousOnSubstituteNode = context.onSubstituteNode; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(69); - context.enableSubstitution(187); - context.enableSubstitution(185); + context.enableSubstitution(70); + context.enableSubstitution(188); context.enableSubstitution(186); + context.enableSubstitution(187); context.enableEmitNotification(256); var exportFunctionForFileMap = []; var currentSourceFile; @@ -42641,7 +42843,7 @@ var ts; } function transformSystemModuleWorker(node) { ts.Debug.assert(!exportFunctionForFile); - (_a = ts.collectExternalModuleInfo(node, resolver), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); + (_a = ts.collectExternalModuleInfo(node), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); exportFunctionForFile = ts.createUniqueName("exports"); contextObjectForFile = ts.createUniqueName("context"); exportFunctionForFileMap[ts.getOriginalNodeId(node)] = exportFunctionForFile; @@ -42650,7 +42852,7 @@ var ts; addSystemModuleBody(statements, node, dependencyGroups); var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, getNameOfDependencyGroup)); - var body = ts.createFunctionExpression(undefined, undefined, undefined, [ + var body = ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ ts.createParameter(exportFunctionForFile), ts.createParameter(contextObjectForFile) ], undefined, ts.setEmitFlags(ts.createBlock(statements, undefined, true), 1)); @@ -42673,7 +42875,7 @@ var ts; var exportStarFunction = addExportStarIfNeeded(statements); statements.push(ts.createReturn(ts.setMultiLine(ts.createObjectLiteral([ ts.createPropertyAssignment("setters", generateSetters(exportStarFunction, dependencyGroups)), - ts.createPropertyAssignment("execute", ts.createFunctionExpression(undefined, undefined, undefined, [], undefined, ts.createBlock(executeStatements, undefined, true))) + ts.createPropertyAssignment("execute", ts.createFunctionExpression(undefined, undefined, undefined, undefined, [], undefined, ts.createBlock(executeStatements, undefined, true))) ]), true))); } function addExportStarIfNeeded(statements) { @@ -42684,7 +42886,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, externalImports_2 = externalImports; _i < externalImports_2.length; _i++) { var externalImport = externalImports_2[_i]; - if (externalImport.kind === 236 && externalImport.exportClause) { + if (externalImport.kind === 237 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -42702,7 +42904,7 @@ var ts; } for (var _b = 0, externalImports_3 = externalImports; _b < externalImports_3.length; _b++) { var externalImport = externalImports_3[_b]; - if (externalImport.kind !== 236) { + if (externalImport.kind !== 237) { continue; } var exportDecl = externalImport; @@ -42731,15 +42933,15 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); switch (entry.kind) { - case 230: + case 231: if (!entry.importClause) { break; } - case 229: + case 230: ts.Debug.assert(importVariableName !== undefined); statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 236: + case 237: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { var properties = []; @@ -42755,19 +42957,19 @@ var ts; break; } } - setters.push(ts.createFunctionExpression(undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, ts.createBlock(statements, undefined, true))); + setters.push(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, ts.createBlock(statements, undefined, true))); } return ts.createArrayLiteral(setters, undefined, true); } function visitSourceElement(node) { switch (node.kind) { - case 230: + case 231: return visitImportDeclaration(node); - case 229: + case 230: return visitImportEqualsDeclaration(node); - case 236: + case 237: return visitExportDeclaration(node); - case 235: + case 236: return visitExportAssignment(node); default: return visitNestedNode(node); @@ -42791,41 +42993,41 @@ var ts; } function visitNestedNodeWorker(node) { switch (node.kind) { - case 200: + case 201: return visitVariableStatement(node); - case 220: - return visitFunctionDeclaration(node); case 221: + return visitFunctionDeclaration(node); + case 222: return visitClassDeclaration(node); - case 206: - return visitForStatement(node); case 207: - return visitForInStatement(node); + return visitForStatement(node); case 208: + return visitForInStatement(node); + case 209: return visitForOfStatement(node); - case 204: - return visitDoStatement(node); case 205: + return visitDoStatement(node); + case 206: return visitWhileStatement(node); - case 214: + case 215: return visitLabeledStatement(node); - case 212: - return visitWithStatement(node); case 213: + return visitWithStatement(node); + case 214: return visitSwitchStatement(node); - case 227: + case 228: return visitCaseBlock(node); case 249: return visitCaseClause(node); case 250: return visitDefaultClause(node); - case 216: + case 217: return visitTryStatement(node); case 252: return visitCatchClause(node); - case 199: + case 200: return visitBlock(node); - case 202: + case 203: return visitExpressionStatement(node); default: return node; @@ -42852,20 +43054,14 @@ var ts; return undefined; } function visitExportSpecifier(specifier) { - if (resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) - || resolver.isValueAliasDeclaration(specifier)) { - recordExportName(specifier.name); - return createExportStatement(specifier.name, specifier.propertyName || specifier.name); - } - return undefined; + recordExportName(specifier.name); + return createExportStatement(specifier.name, specifier.propertyName || specifier.name); } function visitExportAssignment(node) { - if (!node.isExportEquals) { - if (ts.nodeIsSynthesized(node) || resolver.isValueAliasDeclaration(node)) { - return createExportStatement(ts.createLiteral("default"), node.expression); - } + if (node.isExportEquals) { + return undefined; } - return undefined; + return createExportStatement(ts.createLiteral("default"), node.expression); } function visitVariableStatement(node) { var shouldHoist = ((ts.getCombinedNodeFlags(ts.getOriginalNode(node.declarationList)) & 3) == 0) || @@ -42897,16 +43093,17 @@ var ts; return ts.createAssignment(name, node.initializer); } else { - return ts.flattenVariableDestructuringToExpression(context, node, hoistVariableDeclaration); + return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration); } } function visitFunctionDeclaration(node) { if (ts.hasModifier(node, 1)) { - var name_41 = node.name || ts.getGeneratedNameForNode(node); - var newNode = ts.createFunctionDeclaration(undefined, undefined, node.asteriskToken, name_41, undefined, node.parameters, undefined, node.body, node); + var name_38 = node.name || ts.getGeneratedNameForNode(node); + var isAsync = ts.hasModifier(node, 256); + var newNode = ts.createFunctionDeclaration(undefined, isAsync ? [ts.createNode(119)] : undefined, node.asteriskToken, name_38, undefined, node.parameters, undefined, node.body, node); recordExportedFunctionDeclaration(node); if (!ts.hasModifier(node, 512)) { - recordExportName(name_41); + recordExportName(name_38); } ts.setOriginalNode(newNode, node); node = newNode; @@ -42916,14 +43113,14 @@ var ts; } function visitExpressionStatement(node) { var originalNode = ts.getOriginalNode(node); - if ((originalNode.kind === 225 || originalNode.kind === 224) && ts.hasModifier(originalNode, 1)) { - var name_42 = getDeclarationName(originalNode); - if (originalNode.kind === 224) { - hoistVariableDeclaration(name_42); + if ((originalNode.kind === 226 || originalNode.kind === 225) && ts.hasModifier(originalNode, 1)) { + var name_39 = getDeclarationName(originalNode); + if (originalNode.kind === 225) { + hoistVariableDeclaration(name_39); } return [ node, - createExportStatement(name_42, name_42) + createExportStatement(name_39, name_39) ]; } return node; @@ -42958,7 +43155,7 @@ var ts; ; return ts.createFor(expressions.length ? ts.inlineExpressions(expressions) - : ts.createSynthesizedNode(193), node.condition, node.incrementor, ts.visitNode(node.statement, visitNestedNode, ts.isStatement), node); + : ts.createSynthesizedNode(194), node.condition, node.incrementor, ts.visitNode(node.statement, visitNestedNode, ts.isStatement), node); } else { return ts.visitEachChild(node, visitNestedNode, context); @@ -42970,7 +43167,7 @@ var ts; var name = firstDeclaration.name; return ts.isIdentifier(name) ? name - : ts.flattenVariableDestructuringToExpression(context, firstDeclaration, hoistVariableDeclaration); + : ts.flattenVariableDestructuringToExpression(firstDeclaration, hoistVariableDeclaration); } function visitForInStatement(node) { var initializer = node.initializer; @@ -43096,12 +43293,12 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 69: + case 70: return substituteExpressionIdentifier(node); - case 187: + case 188: return substituteBinaryExpression(node); - case 185: case 186: + case 187: return substituteUnaryExpression(node); } return node; @@ -43126,14 +43323,14 @@ var ts; ts.setEmitFlags(node, 128); var left = node.left; switch (left.kind) { - case 69: + case 70: var exportDeclaration = resolver.getReferencedExportContainer(left); if (exportDeclaration) { return createExportExpression(left, node); } break; + case 172: case 171: - case 170: if (hasExportedReferenceInDestructuringPattern(left)) { return substituteDestructuring(node); } @@ -43147,9 +43344,9 @@ var ts; } function hasExportedReferenceInDestructuringPattern(node) { switch (node.kind) { - case 69: + case 70: return isExportedBinding(node); - case 171: + case 172: for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var property = _a[_i]; if (hasExportedReferenceInObjectDestructuringElement(property)) { @@ -43157,7 +43354,7 @@ var ts; } } break; - case 170: + case 171: for (var _b = 0, _c = node.elements; _b < _c.length; _b++) { var element = _c[_b]; if (hasExportedReferenceInArrayDestructuringElement(element)) { @@ -43191,7 +43388,7 @@ var ts; function hasExportedReferenceInDestructuringElement(node) { if (ts.isBinaryExpression(node)) { var left = node.left; - return node.operatorToken.kind === 56 + return node.operatorToken.kind === 57 && isDestructuringPattern(left) && hasExportedReferenceInDestructuringPattern(left); } @@ -43211,9 +43408,9 @@ var ts; } function isDestructuringPattern(node) { var kind = node.kind; - return kind === 69 - || kind === 171 - || kind === 170; + return kind === 70 + || kind === 172 + || kind === 171; } function substituteDestructuring(node) { return ts.flattenDestructuringAssignment(context, node, true, hoistVariableDeclaration); @@ -43222,19 +43419,19 @@ var ts; var operand = node.operand; var operator = node.operator; var substitute = ts.isIdentifier(operand) && - (node.kind === 186 || - (node.kind === 185 && (operator === 41 || operator === 42))); + (node.kind === 187 || + (node.kind === 186 && (operator === 42 || operator === 43))); if (substitute) { var exportDeclaration = resolver.getReferencedExportContainer(operand); if (exportDeclaration) { var expr = ts.createPrefix(node.operator, operand, node); ts.setEmitFlags(expr, 128); var call = createExportExpression(operand, expr); - if (node.kind === 185) { + if (node.kind === 186) { return call; } else { - return operator === 41 + return operator === 42 ? ts.createSubtract(call, ts.createLiteral(1)) : ts.createAdd(call, ts.createLiteral(1)); } @@ -43293,12 +43490,7 @@ var ts; else { return undefined; } - if (name.originalKeywordKind && languageVersion === 0) { - return ts.createElementAccess(importAlias, ts.createLiteral(name.text)); - } - else { - return ts.createPropertyAccess(importAlias, ts.getSynthesizedClone(name)); - } + return ts.createPropertyAccess(importAlias, ts.getSynthesizedClone(name)); } function collectDependencyGroups(externalImports) { var groupIndices = ts.createMap(); @@ -43369,17 +43561,14 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function transformES6Module(context) { + function transformES2015Module(context) { var compilerOptions = context.getCompilerOptions(); - var resolver = context.getEmitResolver(); - var currentSourceFile; return transformSourceFile; function transformSourceFile(node) { if (ts.isDeclarationFile(node)) { return node; } if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - currentSourceFile = node; return ts.visitEachChild(node, visitor, context); } return node; @@ -43387,115 +43576,33 @@ var ts; function visitor(node) { switch (node.kind) { case 230: - return visitImportDeclaration(node); - case 229: - return visitImportEqualsDeclaration(node); - case 231: - return visitImportClause(node); - case 233: - case 232: - return visitNamedBindings(node); - case 234: - return visitImportSpecifier(node); - case 235: - return visitExportAssignment(node); + return undefined; case 236: - return visitExportDeclaration(node); - case 237: - return visitNamedExports(node); - case 238: - return visitExportSpecifier(node); + return visitExportAssignment(node); } return node; } function visitExportAssignment(node) { - if (node.isExportEquals) { - return undefined; - } - var original = ts.getOriginalNode(node); - return ts.nodeIsSynthesized(original) || resolver.isValueAliasDeclaration(original) ? node : undefined; - } - function visitExportDeclaration(node) { - if (!node.exportClause) { - return resolver.moduleExportsSomeValue(node.moduleSpecifier) ? node : undefined; - } - if (!resolver.isValueAliasDeclaration(node)) { - return undefined; - } - var newExportClause = ts.visitNode(node.exportClause, visitor, ts.isNamedExports, true); - if (node.exportClause === newExportClause) { - return node; - } - return newExportClause - ? ts.createExportDeclaration(undefined, undefined, newExportClause, node.moduleSpecifier) - : undefined; - } - function visitNamedExports(node) { - var newExports = ts.visitNodes(node.elements, visitor, ts.isExportSpecifier); - if (node.elements === newExports) { - return node; - } - return newExports.length ? ts.createNamedExports(newExports) : undefined; - } - function visitExportSpecifier(node) { - return resolver.isValueAliasDeclaration(node) ? node : undefined; - } - function visitImportEqualsDeclaration(node) { - return !ts.isExternalModuleImportEqualsDeclaration(node) || resolver.isReferencedAliasDeclaration(node) ? node : undefined; - } - function visitImportDeclaration(node) { - if (node.importClause) { - var newImportClause = ts.visitNode(node.importClause, visitor, ts.isImportClause); - if (!newImportClause.name && !newImportClause.namedBindings) { - return undefined; - } - else if (newImportClause !== node.importClause) { - return ts.createImportDeclaration(undefined, undefined, newImportClause, node.moduleSpecifier); - } - } - return node; - } - function visitImportClause(node) { - var newDefaultImport = node.name; - if (!resolver.isReferencedAliasDeclaration(node)) { - newDefaultImport = undefined; - } - var newNamedBindings = ts.visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true); - return newDefaultImport !== node.name || newNamedBindings !== node.namedBindings - ? ts.createImportClause(newDefaultImport, newNamedBindings) - : node; - } - function visitNamedBindings(node) { - if (node.kind === 232) { - return resolver.isReferencedAliasDeclaration(node) ? node : undefined; - } - else { - var newNamedImportElements = ts.visitNodes(node.elements, visitor, ts.isImportSpecifier); - if (!newNamedImportElements || newNamedImportElements.length == 0) { - return undefined; - } - if (newNamedImportElements === node.elements) { - return node; - } - return ts.createNamedImports(newNamedImportElements); - } - } - function visitImportSpecifier(node) { - return resolver.isReferencedAliasDeclaration(node) ? node : undefined; + return node.isExportEquals ? undefined : node; } } - ts.transformES6Module = transformES6Module; + ts.transformES2015Module = transformES2015Module; })(ts || (ts = {})); var ts; (function (ts) { var moduleTransformerMap = ts.createMap((_a = {}, - _a[ts.ModuleKind.ES6] = ts.transformES6Module, + _a[ts.ModuleKind.ES2015] = ts.transformES2015Module, _a[ts.ModuleKind.System] = ts.transformSystemModule, _a[ts.ModuleKind.AMD] = ts.transformModule, _a[ts.ModuleKind.CommonJS] = ts.transformModule, _a[ts.ModuleKind.UMD] = ts.transformModule, _a[ts.ModuleKind.None] = ts.transformModule, _a)); + var SyntaxKindFeatureFlags; + (function (SyntaxKindFeatureFlags) { + SyntaxKindFeatureFlags[SyntaxKindFeatureFlags["Substitution"] = 1] = "Substitution"; + SyntaxKindFeatureFlags[SyntaxKindFeatureFlags["EmitNotifications"] = 2] = "EmitNotifications"; + })(SyntaxKindFeatureFlags || (SyntaxKindFeatureFlags = {})); function getTransformers(compilerOptions) { var jsx = compilerOptions.jsx; var languageVersion = ts.getEmitScriptTarget(compilerOptions); @@ -43506,11 +43613,19 @@ var ts; if (jsx === 2) { transformers.push(ts.transformJsx); } - transformers.push(ts.transformES7); + if (languageVersion < 4) { + transformers.push(ts.transformES2017); + } + if (languageVersion < 3) { + transformers.push(ts.transformES2016); + } if (languageVersion < 2) { - transformers.push(ts.transformES6); + transformers.push(ts.transformES2015); transformers.push(ts.transformGenerators); } + if (languageVersion < 1) { + transformers.push(ts.transformES5); + } return transformers; } ts.getTransformers = getTransformers; @@ -43530,7 +43645,7 @@ var ts; hoistFunctionDeclaration: hoistFunctionDeclaration, startLexicalEnvironment: startLexicalEnvironment, endLexicalEnvironment: endLexicalEnvironment, - onSubstituteNode: function (emitContext, node) { return node; }, + onSubstituteNode: function (_emitContext, node) { return node; }, enableSubstitution: enableSubstitution, isSubstitutionEnabled: isSubstitutionEnabled, onEmitNode: function (node, emitContext, emitCallback) { return emitCallback(node, emitContext); }, @@ -43670,7 +43785,7 @@ var ts; var isCurrentFileExternalModule; var reportedDeclarationError = false; var errorNameNode; - var emitJsDocComments = compilerOptions.removeComments ? function (declaration) { } : writeJsDocComments; + var emitJsDocComments = compilerOptions.removeComments ? function () { } : writeJsDocComments; var emit = compilerOptions.stripInternal ? stripInternal : emitNode; var noDeclare; var moduleElementDeclarationEmitInfo = []; @@ -43714,7 +43829,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 230); + ts.Debug.assert(aliasEmitInfo.node.kind === 231); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -43745,7 +43860,7 @@ var ts; reportedDeclarationError: reportedDeclarationError, moduleElementDeclarationEmitInfo: allSourcesModuleElementDeclarationEmitInfo, synchronousDeclarationOutput: writer.getText(), - referencesOutput: referencesOutput + referencesOutput: referencesOutput, }; function hasInternalAnnotation(range) { var comment = currentText.substring(range.pos, range.end); @@ -43785,10 +43900,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 218) { + if (declaration.kind === 219) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 233 || declaration.kind === 234 || declaration.kind === 231) { + else if (declaration.kind === 234 || declaration.kind === 235 || declaration.kind === 232) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -43799,7 +43914,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 230) { + if (moduleElementEmitInfo.node.kind === 231) { moduleElementEmitInfo.isVisible = true; } else { @@ -43807,12 +43922,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 225) { + if (nodeToCheck.kind === 226) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 225) { + if (nodeToCheck.kind === 226) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -43924,67 +44039,67 @@ var ts; } function emitType(type) { switch (type.kind) { - case 117: - case 132: - case 130: - case 120: + case 118: case 133: - case 103: - case 135: - case 93: - case 127: - case 165: + case 131: + case 121: + case 134: + case 104: + case 136: + case 94: + case 128: case 166: + case 167: return writeTextOfNode(currentText, type); - case 194: + case 195: return emitExpressionWithTypeArguments(type); - case 155: - return emitTypeReference(type); - case 158: - return emitTypeQuery(type); - case 160: - return emitArrayType(type); - case 161: - return emitTupleType(type); - case 162: - return emitUnionType(type); - case 163: - return emitIntersectionType(type); - case 164: - return emitParenType(type); case 156: - case 157: - return emitSignatureDeclarationWithJsDocComments(type); + return emitTypeReference(type); case 159: + return emitTypeQuery(type); + case 161: + return emitArrayType(type); + case 162: + return emitTupleType(type); + case 163: + return emitUnionType(type); + case 164: + return emitIntersectionType(type); + case 165: + return emitParenType(type); + case 157: + case 158: + return emitSignatureDeclarationWithJsDocComments(type); + case 160: return emitTypeLiteral(type); - case 69: + case 70: return emitEntityName(type); - case 139: + case 140: return emitEntityName(type); - case 154: + case 155: return emitTypePredicate(type); } function writeEntityName(entityName) { - if (entityName.kind === 69) { + if (entityName.kind === 70) { writeTextOfNode(currentText, entityName); } else { - var left = entityName.kind === 139 ? entityName.left : entityName.expression; - var right = entityName.kind === 139 ? entityName.right : entityName.name; + var left = entityName.kind === 140 ? entityName.left : entityName.expression; + var right = entityName.kind === 140 ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentText, right); } } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 229 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 230 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isEntityNameExpression(node.expression)) { - ts.Debug.assert(node.expression.kind === 69 || node.expression.kind === 172); + ts.Debug.assert(node.expression.kind === 70 || node.expression.kind === 173); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -44058,14 +44173,14 @@ var ts; var count = 0; while (true) { count++; - var name_43 = baseName + "_" + count; - if (!(name_43 in currentIdentifiers)) { - return name_43; + var name_40 = baseName + "_" + count; + if (!(name_40 in currentIdentifiers)) { + return name_40; } } } function emitExportAssignment(node) { - if (node.expression.kind === 69) { + if (node.expression.kind === 70) { write(node.isExportEquals ? "export = " : "export default "); writeTextOfNode(currentText, node.expression); } @@ -44086,11 +44201,11 @@ var ts; } write(";"); writeLine(); - if (node.expression.kind === 69) { + if (node.expression.kind === 70) { var nodes = resolver.collectLinkedAliases(node.expression); writeAsynchronousModuleElements(nodes); } - function getDefaultExportAccessibilityDiagnostic(diagnostic) { + function getDefaultExportAccessibilityDiagnostic() { return { diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, errorNode: node @@ -44104,7 +44219,7 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 229 || + else if (node.kind === 230 || (node.parent.kind === 256 && isCurrentFileExternalModule)) { var isVisible = void 0; if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 256) { @@ -44116,7 +44231,7 @@ var ts; }); } else { - if (node.kind === 230) { + if (node.kind === 231) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -44134,23 +44249,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 220: - return writeFunctionDeclaration(node); - case 200: - return writeVariableStatement(node); - case 222: - return writeInterfaceDeclaration(node); case 221: - return writeClassDeclaration(node); + return writeFunctionDeclaration(node); + case 201: + return writeVariableStatement(node); case 223: - return writeTypeAliasDeclaration(node); + return writeInterfaceDeclaration(node); + case 222: + return writeClassDeclaration(node); case 224: - return writeEnumDeclaration(node); + return writeTypeAliasDeclaration(node); case 225: + return writeEnumDeclaration(node); + case 226: return writeModuleDeclaration(node); - case 229: - return writeImportEqualsDeclaration(node); case 230: + return writeImportEqualsDeclaration(node); + case 231: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -44165,7 +44280,7 @@ var ts; if (modifiers & 512) { write("default "); } - else if (node.kind !== 222 && !noDeclare) { + else if (node.kind !== 223 && !noDeclare) { write("declare "); } } @@ -44205,7 +44320,7 @@ var ts; write(");"); } writer.writeLine(); - function getImportEntityNameVisibilityError(symbolAccessibilityResult) { + function getImportEntityNameVisibilityError() { return { diagnosticMessage: ts.Diagnostics.Import_declaration_0_is_using_private_name_1, errorNode: node, @@ -44215,7 +44330,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 232) { + if (namedBindings.kind === 233) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -44238,7 +44353,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 232) { + if (node.importClause.namedBindings.kind === 233) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -44255,13 +44370,13 @@ var ts; writer.writeLine(); } function emitExternalModuleSpecifier(parent) { - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 225; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 226; var moduleSpecifier; - if (parent.kind === 229) { + if (parent.kind === 230) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 225) { + else if (parent.kind === 226) { moduleSpecifier = parent.name; } else { @@ -44329,7 +44444,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body && node.body.kind !== 226) { + while (node.body && node.body.kind !== 227) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -44363,7 +44478,7 @@ var ts; write(";"); writeLine(); enclosingDeclaration = prevEnclosingDeclaration; - function getTypeAliasDeclarationVisibilityError(symbolAccessibilityResult) { + function getTypeAliasDeclarationVisibilityError() { return { diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, errorNode: node.type, @@ -44399,7 +44514,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 147 && ts.hasModifier(node.parent, 8); + return node.parent.kind === 148 && ts.hasModifier(node.parent, 8); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -44409,49 +44524,49 @@ var ts; writeTextOfNode(currentText, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 156 || - node.parent.kind === 157 || - (node.parent.parent && node.parent.parent.kind === 159)) { - ts.Debug.assert(node.parent.kind === 147 || - node.parent.kind === 146 || - node.parent.kind === 156 || + if (node.parent.kind === 157 || + node.parent.kind === 158 || + (node.parent.parent && node.parent.parent.kind === 160)) { + ts.Debug.assert(node.parent.kind === 148 || + node.parent.kind === 147 || node.parent.kind === 157 || - node.parent.kind === 151 || - node.parent.kind === 152); + node.parent.kind === 158 || + node.parent.kind === 152 || + node.parent.kind === 153); emitType(node.constraint); } else { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.constraint, getTypeParameterConstraintVisibilityError); } } - function getTypeParameterConstraintVisibilityError(symbolAccessibilityResult) { + function getTypeParameterConstraintVisibilityError() { var diagnosticMessage; switch (node.parent.kind) { - case 221: + case 222: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 222: + case 223: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 152: + case 153: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 151: + case 152: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; + case 148: case 147: - case 146: if (ts.hasModifier(node.parent, 32)) { 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 === 221) { + else if (node.parent.parent.kind === 222) { 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 220: + case 221: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -44479,16 +44594,16 @@ var ts; if (ts.isEntityNameExpression(node.expression)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } - else if (!isImplementsList && node.expression.kind === 93) { + else if (!isImplementsList && node.expression.kind === 94) { write("null"); } else { writer.getSymbolAccessibilityDiagnostic = getHeritageClauseVisibilityError; resolver.writeBaseConstructorTypeOfClass(enclosingDeclaration, enclosingDeclaration, 2 | 1024, writer); } - function getHeritageClauseVisibilityError(symbolAccessibilityResult) { + function getHeritageClauseVisibilityError() { var diagnosticMessage; - if (node.parent.parent.kind === 221) { + if (node.parent.parent.kind === 222) { 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; @@ -44568,17 +44683,17 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 218 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 219 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } else { writeTextOfNode(currentText, node.name); - if ((node.kind === 145 || node.kind === 144 || - (node.kind === 142 && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { + if ((node.kind === 146 || node.kind === 145 || + (node.kind === 143 && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 145 || node.kind === 144) && node.parent.kind === 159) { + if ((node.kind === 146 || node.kind === 145) && node.parent.kind === 160) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (resolver.isLiteralConstDeclaration(node)) { @@ -44591,14 +44706,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 218) { + if (node.kind === 219) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 === 145 || node.kind === 144) { + else if (node.kind === 146 || node.kind === 145) { if (ts.hasModifier(node, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -44606,7 +44721,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 === 221) { + else if (node.parent.kind === 222) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -44632,7 +44747,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 193) { + if (element.kind !== 194) { elements.push(element); } } @@ -44698,7 +44813,7 @@ var ts; accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 149 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 150 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -44711,7 +44826,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 149 + return accessor.kind === 150 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -44720,7 +44835,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 150) { + if (accessorWithTypeAnnotation.kind === 151) { if (ts.hasModifier(accessorWithTypeAnnotation.parent, 32)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : @@ -44766,17 +44881,17 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 220) { + if (node.kind === 221) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 147 || node.kind === 148) { + else if (node.kind === 148 || node.kind === 149) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); } - if (node.kind === 220) { + if (node.kind === 221) { write("function "); writeTextOfNode(currentText, node.name); } - else if (node.kind === 148) { + else if (node.kind === 149) { write("constructor"); } else { @@ -44796,15 +44911,15 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; var closeParenthesizedFunctionType = false; - if (node.kind === 153) { + if (node.kind === 154) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); write("["); } else { - if (node.kind === 152 || node.kind === 157) { + if (node.kind === 153 || node.kind === 158) { write("new "); } - else if (node.kind === 156) { + else if (node.kind === 157) { var currentOutput = writer.getText(); if (node.typeParameters && currentOutput.charAt(currentOutput.length - 1) === "<") { closeParenthesizedFunctionType = true; @@ -44815,20 +44930,20 @@ var ts; write("("); } emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 153) { + if (node.kind === 154) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 156 || node.kind === 157; - if (isFunctionTypeOrConstructorType || node.parent.kind === 159) { + var isFunctionTypeOrConstructorType = node.kind === 157 || node.kind === 158; + if (isFunctionTypeOrConstructorType || node.parent.kind === 160) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 148 && !ts.hasModifier(node, 8)) { + else if (node.kind !== 149 && !ts.hasModifier(node, 8)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -44842,23 +44957,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 152: + case 153: diagnosticMessage = symbolAccessibilityResult.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 151: + case 152: diagnosticMessage = symbolAccessibilityResult.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 153: + case 154: diagnosticMessage = symbolAccessibilityResult.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 148: case 147: - case 146: if (ts.hasModifier(node, 32)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -44866,7 +44981,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 === 221) { + else if (node.parent.kind === 222) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 : @@ -44879,7 +44994,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 220: + case 221: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -44911,9 +45026,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 156 || - node.parent.kind === 157 || - node.parent.parent.kind === 159) { + if (node.parent.kind === 157 || + node.parent.kind === 158 || + node.parent.parent.kind === 160) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!ts.hasModifier(node.parent, 8)) { @@ -44929,22 +45044,22 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 148: + case 149: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 152: + case 153: return symbolAccessibilityResult.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 151: + case 152: return symbolAccessibilityResult.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 148: case 147: - case 146: if (ts.hasModifier(node.parent, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -44952,7 +45067,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 === 221) { + else if (node.parent.parent.kind === 222) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 : @@ -44964,7 +45079,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 220: + case 221: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -44975,12 +45090,12 @@ var ts; } } function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 167) { + if (bindingPattern.kind === 168) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 168) { + else if (bindingPattern.kind === 169) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -44991,10 +45106,10 @@ var ts; } } function emitBindingElement(bindingElement) { - if (bindingElement.kind === 193) { + if (bindingElement.kind === 194) { write(" "); } - else if (bindingElement.kind === 169) { + else if (bindingElement.kind === 170) { if (bindingElement.propertyName) { writeTextOfNode(currentText, bindingElement.propertyName); write(": "); @@ -45004,7 +45119,7 @@ var ts; emitBindingPattern(bindingElement.name); } else { - ts.Debug.assert(bindingElement.name.kind === 69); + ts.Debug.assert(bindingElement.name.kind === 70); if (bindingElement.dotDotDotToken) { write("..."); } @@ -45016,37 +45131,37 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 220: - case 225: - case 229: - case 222: case 221: - case 223: - case 224: - return emitModuleElement(node, isModuleElementVisible(node)); - case 200: - return emitModuleElement(node, isVariableStatementVisible(node)); + case 226: case 230: + case 223: + case 222: + case 224: + case 225: + return emitModuleElement(node, isModuleElementVisible(node)); + case 201: + return emitModuleElement(node, isVariableStatementVisible(node)); + case 231: return emitModuleElement(node, !node.importClause); - case 236: + case 237: return emitExportDeclaration(node); + case 149: case 148: case 147: - case 146: return writeFunctionDeclaration(node); - case 152: - case 151: case 153: + case 152: + case 154: return emitSignatureDeclarationWithJsDocComments(node); - case 149: case 150: + case 151: return emitAccessorDeclaration(node); + case 146: case 145: - case 144: return emitPropertyDeclaration(node); case 255: return emitEnumMemberDeclaration(node); - case 235: + case 236: return emitExportAssignment(node); case 256: return emitSourceFile(node); @@ -45066,7 +45181,7 @@ var ts; referencesOutput += "/// " + newLine; } return addedBundledEmitReference; - function getDeclFileName(emitFileNames, sourceFiles, isBundledEmit) { + function getDeclFileName(emitFileNames, _sourceFiles, isBundledEmit) { if (isBundledEmit && !addBundledFileReference) { return; } @@ -45131,7 +45246,7 @@ var ts; emitNodeWithSourceMap: emitNodeWithSourceMap, emitTokenWithSourceMap: emitTokenWithSourceMap, getText: getText, - getSourceMappingURL: getSourceMappingURL + getSourceMappingURL: getSourceMappingURL, }; function initialize(filePath, sourceMapFilePath, sourceFiles, isBundledEmit) { if (disabled) { @@ -45334,7 +45449,7 @@ var ts; sources: sourceMapData.sourceMapSources, names: sourceMapData.sourceMapNames, mappings: sourceMapData.sourceMapMappings, - sourcesContent: sourceMapData.sourceMapSourcesContent + sourcesContent: sourceMapData.sourceMapSourcesContent, }); } function getSourceMappingURL() { @@ -45398,7 +45513,7 @@ var ts; setSourceFile: setSourceFile, emitNodeWithComments: emitNodeWithComments, emitBodyWithDetachedComments: emitBodyWithDetachedComments, - emitTrailingCommentsOfPosition: emitTrailingCommentsOfPosition + emitTrailingCommentsOfPosition: emitTrailingCommentsOfPosition, }; function emitNodeWithComments(emitContext, node, emitCallback) { if (disabled) { @@ -45436,7 +45551,7 @@ var ts; } if (!skipTrailingComments) { containerEnd = end; - if (node.kind === 219) { + if (node.kind === 220) { declarationListContainerEnd = end; } } @@ -45512,7 +45627,7 @@ var ts; emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos); } } - function emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) { + function emitLeadingComment(commentPos, commentEnd, _kind, hasTrailingNewLine, rangePos) { if (!hasWrittenComment) { ts.emitNewLineBeforeLeadingCommentOfPosition(currentLineMap, writer, rangePos, commentPos); hasWrittenComment = true; @@ -45530,7 +45645,7 @@ var ts; function emitTrailingComments(pos) { forEachTrailingCommentToEmit(pos, emitTrailingComment); } - function emitTrailingComment(commentPos, commentEnd, kind, hasTrailingNewLine) { + function emitTrailingComment(commentPos, commentEnd, _kind, hasTrailingNewLine) { if (!writer.isAtStartOfLine()) { writer.write(" "); } @@ -45553,7 +45668,7 @@ var ts; ts.performance.measure("commentTime", "beforeEmitTrailingCommentsOfPosition"); } } - function emitTrailingCommentOfPosition(commentPos, commentEnd, kind, hasTrailingNewLine) { + function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) { emitPos(commentPos); ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); emitPos(commentEnd); @@ -45636,8 +45751,14 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + var TempFlags; + (function (TempFlags) { + TempFlags[TempFlags["Auto"] = 0] = "Auto"; + TempFlags[TempFlags["CountMask"] = 268435455] = "CountMask"; + TempFlags[TempFlags["_i"] = 268435456] = "_i"; + })(TempFlags || (TempFlags = {})); var id = function (s) { return s; }; - var nullTransformers = [function (ctx) { return id; }]; + var nullTransformers = [function (_) { return id; }]; function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles) { var delimiters = createDelimiterMap(); var brackets = createBracketsMap(); @@ -45815,191 +45936,205 @@ var ts; function pipelineEmitInIdentifierNameContext(node) { var kind = node.kind; switch (kind) { - case 69: + case 70: return emitIdentifier(node); } } function pipelineEmitInUnspecifiedContext(node) { var kind = node.kind; switch (kind) { - case 12: case 13: case 14: + case 15: return emitLiteral(node); - case 69: + case 70: return emitIdentifier(node); - case 74: - case 77: - case 82: - case 103: - case 110: + case 75: + case 78: + case 83: + case 104: case 111: case 112: case 113: - case 115: + case 114: + case 116: case 117: case 118: + case 119: case 120: + case 121: case 122: - case 130: + case 123: + case 124: + case 125: + case 126: + case 127: case 128: + case 129: + case 130: + case 131: case 132: case 133: + case 134: + case 135: + case 136: case 137: + case 138: + case 139: writeTokenText(kind); return; - case 139: - return emitQualifiedName(node); case 140: - return emitComputedPropertyName(node); + return emitQualifiedName(node); case 141: - return emitTypeParameter(node); + return emitComputedPropertyName(node); case 142: - return emitParameter(node); + return emitTypeParameter(node); case 143: - return emitDecorator(node); + return emitParameter(node); case 144: - return emitPropertySignature(node); + return emitDecorator(node); case 145: - return emitPropertyDeclaration(node); + return emitPropertySignature(node); case 146: - return emitMethodSignature(node); + return emitPropertyDeclaration(node); case 147: - return emitMethodDeclaration(node); + return emitMethodSignature(node); case 148: - return emitConstructor(node); + return emitMethodDeclaration(node); case 149: + return emitConstructor(node); case 150: - return emitAccessorDeclaration(node); case 151: - return emitCallSignature(node); + return emitAccessorDeclaration(node); case 152: - return emitConstructSignature(node); + return emitCallSignature(node); case 153: - return emitIndexSignature(node); + return emitConstructSignature(node); case 154: - return emitTypePredicate(node); + return emitIndexSignature(node); case 155: - return emitTypeReference(node); + return emitTypePredicate(node); case 156: - return emitFunctionType(node); + return emitTypeReference(node); case 157: - return emitConstructorType(node); + return emitFunctionType(node); case 158: - return emitTypeQuery(node); + return emitConstructorType(node); case 159: - return emitTypeLiteral(node); + return emitTypeQuery(node); case 160: - return emitArrayType(node); + return emitTypeLiteral(node); case 161: - return emitTupleType(node); + return emitArrayType(node); case 162: - return emitUnionType(node); + return emitTupleType(node); case 163: - return emitIntersectionType(node); + return emitUnionType(node); case 164: - return emitParenthesizedType(node); - case 194: - return emitExpressionWithTypeArguments(node); + return emitIntersectionType(node); case 165: - return emitThisType(node); + return emitParenthesizedType(node); + case 195: + return emitExpressionWithTypeArguments(node); case 166: - return emitLiteralType(node); + return emitThisType(); case 167: - return emitObjectBindingPattern(node); + return emitLiteralType(node); case 168: - return emitArrayBindingPattern(node); + return emitObjectBindingPattern(node); case 169: + return emitArrayBindingPattern(node); + case 170: return emitBindingElement(node); - case 197: - return emitTemplateSpan(node); case 198: - return emitSemicolonClassElement(node); + return emitTemplateSpan(node); case 199: - return emitBlock(node); + return emitSemicolonClassElement(); case 200: - return emitVariableStatement(node); + return emitBlock(node); case 201: - return emitEmptyStatement(node); + return emitVariableStatement(node); case 202: - return emitExpressionStatement(node); + return emitEmptyStatement(); case 203: - return emitIfStatement(node); + return emitExpressionStatement(node); case 204: - return emitDoStatement(node); + return emitIfStatement(node); case 205: - return emitWhileStatement(node); + return emitDoStatement(node); case 206: - return emitForStatement(node); + return emitWhileStatement(node); case 207: - return emitForInStatement(node); + return emitForStatement(node); case 208: - return emitForOfStatement(node); + return emitForInStatement(node); case 209: - return emitContinueStatement(node); + return emitForOfStatement(node); case 210: - return emitBreakStatement(node); + return emitContinueStatement(node); case 211: - return emitReturnStatement(node); + return emitBreakStatement(node); case 212: - return emitWithStatement(node); + return emitReturnStatement(node); case 213: - return emitSwitchStatement(node); + return emitWithStatement(node); case 214: - return emitLabeledStatement(node); + return emitSwitchStatement(node); case 215: - return emitThrowStatement(node); + return emitLabeledStatement(node); case 216: - return emitTryStatement(node); + return emitThrowStatement(node); case 217: - return emitDebuggerStatement(node); + return emitTryStatement(node); case 218: - return emitVariableDeclaration(node); + return emitDebuggerStatement(node); case 219: - return emitVariableDeclarationList(node); + return emitVariableDeclaration(node); case 220: - return emitFunctionDeclaration(node); + return emitVariableDeclarationList(node); case 221: - return emitClassDeclaration(node); + return emitFunctionDeclaration(node); case 222: - return emitInterfaceDeclaration(node); + return emitClassDeclaration(node); case 223: - return emitTypeAliasDeclaration(node); + return emitInterfaceDeclaration(node); case 224: - return emitEnumDeclaration(node); + return emitTypeAliasDeclaration(node); case 225: - return emitModuleDeclaration(node); + return emitEnumDeclaration(node); case 226: - return emitModuleBlock(node); + return emitModuleDeclaration(node); case 227: + return emitModuleBlock(node); + case 228: return emitCaseBlock(node); - case 229: - return emitImportEqualsDeclaration(node); case 230: - return emitImportDeclaration(node); + return emitImportEqualsDeclaration(node); case 231: - return emitImportClause(node); + return emitImportDeclaration(node); case 232: - return emitNamespaceImport(node); + return emitImportClause(node); case 233: - return emitNamedImports(node); + return emitNamespaceImport(node); case 234: - return emitImportSpecifier(node); + return emitNamedImports(node); case 235: - return emitExportAssignment(node); + return emitImportSpecifier(node); case 236: - return emitExportDeclaration(node); + return emitExportAssignment(node); case 237: - return emitNamedExports(node); + return emitExportDeclaration(node); case 238: - return emitExportSpecifier(node); + return emitNamedExports(node); case 239: - return; + return emitExportSpecifier(node); case 240: + return; + case 241: return emitExternalModuleReference(node); - case 244: + case 10: return emitJsxText(node); - case 243: + case 244: return emitJsxOpeningElement(node); case 245: return emitJsxClosingElement(node); @@ -46034,73 +46169,73 @@ var ts; case 8: return emitNumericLiteral(node); case 9: - case 10: case 11: + case 12: return emitLiteral(node); - case 69: + case 70: return emitIdentifier(node); - case 84: - case 93: - case 95: - case 99: - case 97: + case 85: + case 94: + case 96: + case 100: + case 98: writeTokenText(kind); return; - case 170: - return emitArrayLiteralExpression(node); case 171: - return emitObjectLiteralExpression(node); + return emitArrayLiteralExpression(node); case 172: - return emitPropertyAccessExpression(node); + return emitObjectLiteralExpression(node); case 173: - return emitElementAccessExpression(node); + return emitPropertyAccessExpression(node); case 174: - return emitCallExpression(node); + return emitElementAccessExpression(node); case 175: - return emitNewExpression(node); + return emitCallExpression(node); case 176: - return emitTaggedTemplateExpression(node); + return emitNewExpression(node); case 177: - return emitTypeAssertionExpression(node); + return emitTaggedTemplateExpression(node); case 178: - return emitParenthesizedExpression(node); + return emitTypeAssertionExpression(node); case 179: - return emitFunctionExpression(node); + return emitParenthesizedExpression(node); case 180: - return emitArrowFunction(node); + return emitFunctionExpression(node); case 181: - return emitDeleteExpression(node); + return emitArrowFunction(node); case 182: - return emitTypeOfExpression(node); + return emitDeleteExpression(node); case 183: - return emitVoidExpression(node); + return emitTypeOfExpression(node); case 184: - return emitAwaitExpression(node); + return emitVoidExpression(node); case 185: - return emitPrefixUnaryExpression(node); + return emitAwaitExpression(node); case 186: - return emitPostfixUnaryExpression(node); + return emitPrefixUnaryExpression(node); case 187: - return emitBinaryExpression(node); + return emitPostfixUnaryExpression(node); case 188: - return emitConditionalExpression(node); + return emitBinaryExpression(node); case 189: - return emitTemplateExpression(node); + return emitConditionalExpression(node); case 190: - return emitYieldExpression(node); + return emitTemplateExpression(node); case 191: - return emitSpreadElementExpression(node); + return emitYieldExpression(node); case 192: - return emitClassExpression(node); + return emitSpreadElementExpression(node); case 193: + return emitClassExpression(node); + case 194: return; - case 195: - return emitAsExpression(node); case 196: + return emitAsExpression(node); + case 197: return emitNonNullExpression(node); - case 241: - return emitJsxElement(node); case 242: + return emitJsxElement(node); + case 243: return emitJsxSelfClosingElement(node); case 288: return emitPartiallyEmittedExpression(node); @@ -46136,7 +46271,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 69) { + if (node.kind === 70) { emitExpression(node); } else { @@ -46206,7 +46341,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - write(node.kind === 149 ? "get " : "set "); + write(node.kind === 150 ? "get " : "set "); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); } @@ -46234,7 +46369,7 @@ var ts; emitWithPrefix(": ", node.type); write(";"); } - function emitSemicolonClassElement(node) { + function emitSemicolonClassElement() { write(";"); } function emitTypePredicate(node) { @@ -46288,7 +46423,7 @@ var ts; emit(node.type); write(")"); } - function emitThisType(node) { + function emitThisType() { write("this"); } function emitLiteralType(node) { @@ -46356,7 +46491,7 @@ var ts; if (!(ts.getEmitFlags(node) & 1048576)) { var dotRangeStart = node.expression.end; var dotRangeEnd = ts.skipTrivia(currentText, node.expression.end) + 1; - var dotToken = { kind: 21, pos: dotRangeStart, end: dotRangeEnd }; + var dotToken = { kind: 22, pos: dotRangeStart, end: dotRangeEnd }; indentBeforeDot = needsIndentation(node, node.expression, dotToken); indentAfterDot = needsIndentation(node, dotToken, node.name); } @@ -46371,7 +46506,7 @@ var ts; function needsDotDotForPropertyAccess(expression) { if (expression.kind === 8) { var text = getLiteralTextOfNode(expression); - return text.indexOf(ts.tokenToString(21)) < 0; + return text.indexOf(ts.tokenToString(22)) < 0; } else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { var constantValue = ts.getConstantValue(expression); @@ -46388,11 +46523,13 @@ var ts; } function emitCallExpression(node) { emitExpression(node.expression); + emitTypeArguments(node, node.typeArguments); emitExpressionList(node, node.arguments, 1296); } function emitNewExpression(node) { write("new "); emitExpression(node.expression); + emitTypeArguments(node, node.typeArguments); emitExpressionList(node, node.arguments, 9488); } function emitTaggedTemplateExpression(node) { @@ -46452,16 +46589,16 @@ var ts; } function shouldEmitWhitespaceBeforeOperand(node) { var operand = node.operand; - return operand.kind === 185 - && ((node.operator === 35 && (operand.operator === 35 || operand.operator === 41)) - || (node.operator === 36 && (operand.operator === 36 || operand.operator === 42))); + return operand.kind === 186 + && ((node.operator === 36 && (operand.operator === 36 || operand.operator === 42)) + || (node.operator === 37 && (operand.operator === 37 || operand.operator === 43))); } function emitPostfixUnaryExpression(node) { emitExpression(node.operand); writeTokenText(node.operator); } function emitBinaryExpression(node) { - var isCommaOperator = node.operatorToken.kind !== 24; + var isCommaOperator = node.operatorToken.kind !== 25; var indentBeforeOperator = needsIndentation(node, node.left, node.operatorToken); var indentAfterOperator = needsIndentation(node, node.operatorToken, node.right); emitExpression(node.left); @@ -46522,16 +46659,16 @@ var ts; emitExpression(node.expression); emit(node.literal); } - function emitBlock(node, format) { + function emitBlock(node) { if (isSingleLineEmptyBlock(node)) { - writeToken(15, node.pos, node); + writeToken(16, node.pos, node); write(" "); - writeToken(16, node.statements.end, node); + writeToken(17, node.statements.end, node); } else { - writeToken(15, node.pos, node); + writeToken(16, node.pos, node); emitBlockStatements(node); - writeToken(16, node.statements.end, node); + writeToken(17, node.statements.end, node); } } function emitBlockStatements(node) { @@ -46547,7 +46684,7 @@ var ts; emit(node.declarationList); write(";"); } - function emitEmptyStatement(node) { + function emitEmptyStatement() { write(";"); } function emitExpressionStatement(node) { @@ -46555,16 +46692,16 @@ var ts; write(";"); } function emitIfStatement(node) { - var openParenPos = writeToken(88, node.pos, node); + var openParenPos = writeToken(89, node.pos, node); write(" "); - writeToken(17, openParenPos, node); + writeToken(18, openParenPos, node); emitExpression(node.expression); - writeToken(18, node.expression.end, node); + writeToken(19, node.expression.end, node); emitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { writeLine(); - writeToken(80, node.thenStatement.end, node); - if (node.elseStatement.kind === 203) { + writeToken(81, node.thenStatement.end, node); + if (node.elseStatement.kind === 204) { write(" "); emit(node.elseStatement); } @@ -46593,9 +46730,9 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForStatement(node) { - var openParenPos = writeToken(86, node.pos); + var openParenPos = writeToken(87, node.pos); write(" "); - writeToken(17, openParenPos, node); + writeToken(18, openParenPos, node); emitForBinding(node.initializer); write(";"); emitExpressionWithPrefix(" ", node.condition); @@ -46605,28 +46742,28 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInStatement(node) { - var openParenPos = writeToken(86, node.pos); + var openParenPos = writeToken(87, node.pos); write(" "); - writeToken(17, openParenPos); + writeToken(18, openParenPos); emitForBinding(node.initializer); write(" in "); emitExpression(node.expression); - writeToken(18, node.expression.end); + writeToken(19, node.expression.end); emitEmbeddedStatement(node.statement); } function emitForOfStatement(node) { - var openParenPos = writeToken(86, node.pos); + var openParenPos = writeToken(87, node.pos); write(" "); - writeToken(17, openParenPos); + writeToken(18, openParenPos); emitForBinding(node.initializer); write(" of "); emitExpression(node.expression); - writeToken(18, node.expression.end); + writeToken(19, node.expression.end); emitEmbeddedStatement(node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 219) { + if (node.kind === 220) { emit(node); } else { @@ -46635,17 +46772,17 @@ var ts; } } function emitContinueStatement(node) { - writeToken(75, node.pos); + writeToken(76, node.pos); emitWithPrefix(" ", node.label); write(";"); } function emitBreakStatement(node) { - writeToken(70, node.pos); + writeToken(71, node.pos); emitWithPrefix(" ", node.label); write(";"); } function emitReturnStatement(node) { - writeToken(94, node.pos, node); + writeToken(95, node.pos, node); emitExpressionWithPrefix(" ", node.expression); write(";"); } @@ -46656,11 +46793,11 @@ var ts; emitEmbeddedStatement(node.statement); } function emitSwitchStatement(node) { - var openParenPos = writeToken(96, node.pos); + var openParenPos = writeToken(97, node.pos); write(" "); - writeToken(17, openParenPos); + writeToken(18, openParenPos); emitExpression(node.expression); - writeToken(18, node.expression.end); + writeToken(19, node.expression.end); write(" "); emit(node.caseBlock); } @@ -46685,11 +46822,12 @@ var ts; } } function emitDebuggerStatement(node) { - writeToken(76, node.pos); + writeToken(77, node.pos); write(";"); } function emitVariableDeclaration(node) { emit(node.name); + emitWithPrefix(": ", node.type); emitExpressionWithPrefix(" = ", node.initializer); } function emitVariableDeclarationList(node) { @@ -46716,13 +46854,13 @@ var ts; } if (ts.getEmitFlags(node) & 4194304) { emitSignatureHead(node); - emitBlockFunctionBody(node, body); + emitBlockFunctionBody(body); } else { var savedTempFlags = tempFlags; tempFlags = 0; emitSignatureHead(node); - emitBlockFunctionBody(node, body); + emitBlockFunctionBody(body); tempFlags = savedTempFlags; } if (indentedFlag) { @@ -46745,7 +46883,7 @@ var ts; emitParameters(node, node.parameters); emitWithPrefix(": ", node.type); } - function shouldEmitBlockFunctionBodyOnSingleLine(parentNode, body) { + function shouldEmitBlockFunctionBodyOnSingleLine(body) { if (ts.getEmitFlags(body) & 32) { return true; } @@ -46769,14 +46907,14 @@ var ts; } return true; } - function emitBlockFunctionBody(parentNode, body) { + function emitBlockFunctionBody(body) { write(" {"); increaseIndent(); - emitBodyWithDetachedComments(body, body.statements, shouldEmitBlockFunctionBodyOnSingleLine(parentNode, body) + emitBodyWithDetachedComments(body, body.statements, shouldEmitBlockFunctionBodyOnSingleLine(body) ? emitBlockFunctionBodyOnSingleLine : emitBlockFunctionBodyWorker); decreaseIndent(); - writeToken(16, body.statements.end, body); + writeToken(17, body.statements.end, body); } function emitBlockFunctionBodyOnSingleLine(body) { emitBlockFunctionBodyWorker(body, true); @@ -46854,7 +46992,7 @@ var ts; write(node.flags & 16 ? "namespace " : "module "); emit(node.name); var body = node.body; - while (body.kind === 225) { + while (body.kind === 226) { write("."); emit(body.name); body = body.body; @@ -46877,9 +47015,9 @@ var ts; } } function emitCaseBlock(node) { - writeToken(15, node.pos); + writeToken(16, node.pos); emitList(node, node.clauses, 65); - writeToken(16, node.clauses.end); + writeToken(17, node.clauses.end); } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); @@ -46890,7 +47028,7 @@ var ts; write(";"); } function emitModuleReference(node) { - if (node.kind === 69) { + if (node.kind === 70) { emitExpression(node); } else { @@ -47010,7 +47148,7 @@ var ts; } } function emitJsxTagName(node) { - if (node.kind === 69) { + if (node.kind === 70) { emitExpression(node); } else { @@ -47048,11 +47186,11 @@ var ts; } function emitCatchClause(node) { writeLine(); - var openParenPos = writeToken(72, node.pos); + var openParenPos = writeToken(73, node.pos); write(" "); - writeToken(17, openParenPos); + writeToken(18, openParenPos); emit(node.variableDeclaration); - writeToken(18, node.variableDeclaration ? node.variableDeclaration.end : openParenPos); + writeToken(19, node.variableDeclaration ? node.variableDeclaration.end : openParenPos); write(" "); emit(node.block); } @@ -47159,7 +47297,7 @@ var ts; paramEmitted = true; helpersEmitted = true; } - if (!awaiterEmitted && node.flags & 8192) { + if ((languageVersion < 4) && (!awaiterEmitted && node.flags & 8192)) { writeLines(awaiterHelper); if (languageVersion < 2) { writeLines(generatorHelper); @@ -47468,7 +47606,7 @@ var ts; && !ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 178 && ts.nodeIsSynthesized(node)) { + while (node.kind === 179 && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -47525,21 +47663,21 @@ var ts; } function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name_44 = flags === 268435456 ? "_i" : "_n"; - if (isUniqueName(name_44)) { + var name_41 = flags === 268435456 ? "_i" : "_n"; + if (isUniqueName(name_41)) { tempFlags |= flags; - return name_44; + return name_41; } } while (true) { var count = tempFlags & 268435455; tempFlags++; if (count !== 8 && count !== 13) { - var name_45 = count < 26 + var name_42 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); - if (isUniqueName(name_45)) { - return name_45; + if (isUniqueName(name_42)) { + return name_42; } } } @@ -47575,19 +47713,19 @@ var ts; } function generateNameForNode(node) { switch (node.kind) { - case 69: + case 70: return makeUniqueName(getTextOfNode(node)); + case 226: case 225: - case 224: return generateNameForModuleOrEnum(node); - case 230: - case 236: + case 231: + case 237: return generateNameForImportOrExportDeclaration(node); - case 220: case 221: - case 235: + case 222: + case 236: return generateNameForExportDefault(); - case 192: + case 193: return generateNameForClassExpression(); default: return makeTempVariableName(0); @@ -47657,6 +47795,68 @@ var ts; } } ts.emitFiles = emitFiles; + var ListFormat; + (function (ListFormat) { + ListFormat[ListFormat["None"] = 0] = "None"; + ListFormat[ListFormat["SingleLine"] = 0] = "SingleLine"; + ListFormat[ListFormat["MultiLine"] = 1] = "MultiLine"; + ListFormat[ListFormat["PreserveLines"] = 2] = "PreserveLines"; + ListFormat[ListFormat["LinesMask"] = 3] = "LinesMask"; + ListFormat[ListFormat["NotDelimited"] = 0] = "NotDelimited"; + ListFormat[ListFormat["BarDelimited"] = 4] = "BarDelimited"; + ListFormat[ListFormat["AmpersandDelimited"] = 8] = "AmpersandDelimited"; + ListFormat[ListFormat["CommaDelimited"] = 16] = "CommaDelimited"; + ListFormat[ListFormat["DelimitersMask"] = 28] = "DelimitersMask"; + ListFormat[ListFormat["AllowTrailingComma"] = 32] = "AllowTrailingComma"; + ListFormat[ListFormat["Indented"] = 64] = "Indented"; + ListFormat[ListFormat["SpaceBetweenBraces"] = 128] = "SpaceBetweenBraces"; + ListFormat[ListFormat["SpaceBetweenSiblings"] = 256] = "SpaceBetweenSiblings"; + ListFormat[ListFormat["Braces"] = 512] = "Braces"; + ListFormat[ListFormat["Parenthesis"] = 1024] = "Parenthesis"; + ListFormat[ListFormat["AngleBrackets"] = 2048] = "AngleBrackets"; + ListFormat[ListFormat["SquareBrackets"] = 4096] = "SquareBrackets"; + ListFormat[ListFormat["BracketsMask"] = 7680] = "BracketsMask"; + ListFormat[ListFormat["OptionalIfUndefined"] = 8192] = "OptionalIfUndefined"; + ListFormat[ListFormat["OptionalIfEmpty"] = 16384] = "OptionalIfEmpty"; + ListFormat[ListFormat["Optional"] = 24576] = "Optional"; + ListFormat[ListFormat["PreferNewLine"] = 32768] = "PreferNewLine"; + ListFormat[ListFormat["NoTrailingNewLine"] = 65536] = "NoTrailingNewLine"; + ListFormat[ListFormat["NoInterveningComments"] = 131072] = "NoInterveningComments"; + ListFormat[ListFormat["Modifiers"] = 256] = "Modifiers"; + ListFormat[ListFormat["HeritageClauses"] = 256] = "HeritageClauses"; + ListFormat[ListFormat["TypeLiteralMembers"] = 65] = "TypeLiteralMembers"; + ListFormat[ListFormat["TupleTypeElements"] = 336] = "TupleTypeElements"; + ListFormat[ListFormat["UnionTypeConstituents"] = 260] = "UnionTypeConstituents"; + ListFormat[ListFormat["IntersectionTypeConstituents"] = 264] = "IntersectionTypeConstituents"; + ListFormat[ListFormat["ObjectBindingPatternElements"] = 432] = "ObjectBindingPatternElements"; + ListFormat[ListFormat["ArrayBindingPatternElements"] = 304] = "ArrayBindingPatternElements"; + ListFormat[ListFormat["ObjectLiteralExpressionProperties"] = 978] = "ObjectLiteralExpressionProperties"; + ListFormat[ListFormat["ArrayLiteralExpressionElements"] = 4466] = "ArrayLiteralExpressionElements"; + ListFormat[ListFormat["CallExpressionArguments"] = 1296] = "CallExpressionArguments"; + ListFormat[ListFormat["NewExpressionArguments"] = 9488] = "NewExpressionArguments"; + ListFormat[ListFormat["TemplateExpressionSpans"] = 131072] = "TemplateExpressionSpans"; + ListFormat[ListFormat["SingleLineBlockStatements"] = 384] = "SingleLineBlockStatements"; + ListFormat[ListFormat["MultiLineBlockStatements"] = 65] = "MultiLineBlockStatements"; + ListFormat[ListFormat["VariableDeclarationList"] = 272] = "VariableDeclarationList"; + ListFormat[ListFormat["SingleLineFunctionBodyStatements"] = 384] = "SingleLineFunctionBodyStatements"; + ListFormat[ListFormat["MultiLineFunctionBodyStatements"] = 1] = "MultiLineFunctionBodyStatements"; + ListFormat[ListFormat["ClassHeritageClauses"] = 256] = "ClassHeritageClauses"; + ListFormat[ListFormat["ClassMembers"] = 65] = "ClassMembers"; + ListFormat[ListFormat["InterfaceMembers"] = 65] = "InterfaceMembers"; + ListFormat[ListFormat["EnumMembers"] = 81] = "EnumMembers"; + ListFormat[ListFormat["CaseBlockClauses"] = 65] = "CaseBlockClauses"; + ListFormat[ListFormat["NamedImportsOrExportsElements"] = 432] = "NamedImportsOrExportsElements"; + ListFormat[ListFormat["JsxElementChildren"] = 131072] = "JsxElementChildren"; + ListFormat[ListFormat["JsxElementAttributes"] = 131328] = "JsxElementAttributes"; + ListFormat[ListFormat["CaseOrDefaultClauseStatements"] = 81985] = "CaseOrDefaultClauseStatements"; + ListFormat[ListFormat["HeritageClauseTypes"] = 272] = "HeritageClauseTypes"; + ListFormat[ListFormat["SourceFileStatements"] = 65537] = "SourceFileStatements"; + ListFormat[ListFormat["Decorators"] = 24577] = "Decorators"; + ListFormat[ListFormat["TypeArguments"] = 26960] = "TypeArguments"; + ListFormat[ListFormat["TypeParameters"] = 26960] = "TypeParameters"; + ListFormat[ListFormat["Parameters"] = 1360] = "Parameters"; + ListFormat[ListFormat["IndexSignatureParameters"] = 4432] = "IndexSignatureParameters"; + })(ListFormat || (ListFormat = {})); })(ts || (ts = {})); var ts; (function (ts) { @@ -47876,10 +48076,10 @@ var ts; var resolutions = []; var cache = ts.createMap(); for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { - var name_46 = names_2[_i]; - var result = name_46 in cache - ? cache[name_46] - : cache[name_46] = loader(name_46, containingFile); + var name_43 = names_2[_i]; + var result = name_43 in cache + ? cache[name_43] + : cache[name_43] = loader(name_43, containingFile); resolutions.push(result); } return resolutions; @@ -48110,7 +48310,7 @@ var ts; getSourceFiles: program.getSourceFiles, isSourceFileFromExternalLibrary: function (file) { return !!sourceFilesFoundSearchingNodeModules[file.path]; }, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), - isEmitBlocked: isEmitBlocked + isEmitBlocked: isEmitBlocked, }; } function getDiagnosticsProducingTypeChecker() { @@ -48188,7 +48388,7 @@ var ts; return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile, cancellationToken); } } - function getSyntacticDiagnosticsForFile(sourceFile, cancellationToken) { + function getSyntacticDiagnosticsForFile(sourceFile) { return sourceFile.parseDiagnostics; } function runWithCancellationToken(func) { @@ -48209,14 +48409,14 @@ var ts; ts.Debug.assert(!!sourceFile.bindDiagnostics); var bindDiagnostics = sourceFile.bindDiagnostics; var checkDiagnostics = ts.isSourceFileJavaScript(sourceFile) ? - getJavaScriptSemanticDiagnosticsForFile(sourceFile, cancellationToken) : + getJavaScriptSemanticDiagnosticsForFile(sourceFile) : typeChecker.getDiagnostics(sourceFile, cancellationToken); var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); - return bindDiagnostics.concat(checkDiagnostics).concat(fileProcessingDiagnosticsInFile).concat(programDiagnosticsInFile); + return bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); }); } - function getJavaScriptSemanticDiagnosticsForFile(sourceFile, cancellationToken) { + function getJavaScriptSemanticDiagnosticsForFile(sourceFile) { return runWithCancellationToken(function () { var diagnostics = []; walk(sourceFile); @@ -48226,16 +48426,16 @@ var ts; return false; } switch (node.kind) { - case 229: + case 230: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return true; - case 235: + case 236: if (node.isExportEquals) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return true; } break; - case 221: + case 222: var classDeclaration = node; if (checkModifiers(classDeclaration.modifiers) || checkTypeParameters(classDeclaration.typeParameters)) { @@ -48244,29 +48444,29 @@ var ts; break; case 251: var heritageClause = node; - if (heritageClause.token === 106) { + if (heritageClause.token === 107) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return true; } break; - case 222: + case 223: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return true; - case 225: + case 226: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return true; - case 223: + case 224: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return true; - case 147: - case 146: case 148: + case 147: case 149: case 150: - case 179: - case 220: + case 151: case 180: - case 220: + case 221: + case 181: + case 221: var functionDeclaration = node; if (checkModifiers(functionDeclaration.modifiers) || checkTypeParameters(functionDeclaration.typeParameters) || @@ -48274,20 +48474,20 @@ var ts; return true; } break; - case 200: + case 201: var variableStatement = node; if (checkModifiers(variableStatement.modifiers)) { return true; } break; - case 218: + case 219: var variableDeclaration = node; if (checkTypeAnnotation(variableDeclaration.type)) { return true; } break; - case 174: case 175: + case 176: var expression = node; if (expression.typeArguments && expression.typeArguments.length > 0) { var start = expression.typeArguments.pos; @@ -48295,7 +48495,7 @@ var ts; return true; } break; - case 142: + case 143: var parameter = node; if (parameter.modifiers) { var start = parameter.modifiers.pos; @@ -48311,12 +48511,12 @@ var ts; return true; } break; - case 145: + case 146: var propertyDeclaration = node; if (propertyDeclaration.modifiers) { for (var _i = 0, _a = propertyDeclaration.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 113) { + if (modifier.kind !== 114) { diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); return true; } @@ -48326,14 +48526,14 @@ var ts; return true; } break; - case 224: + case 225: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return true; - case 177: + case 178: 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 143: + case 144: if (!options.experimentalDecorators) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning)); } @@ -48361,18 +48561,18 @@ var ts; for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { var modifier = modifiers_1[_i]; switch (modifier.kind) { - case 112: - case 110: + case 113: case 111: - case 128: - case 122: + case 112: + case 129: + case 123: diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); return true; - case 113: - case 82: - case 74: - case 77: - case 115: + case 114: + case 83: + case 75: + case 78: + case 116: } } } @@ -48405,7 +48605,7 @@ var ts; return ts.getBaseFileName(fileName).indexOf(".") >= 0; } function processRootFile(fileName, isDefaultLib) { - processSourceFile(ts.normalizePath(fileName), isDefaultLib, true); + processSourceFile(ts.normalizePath(fileName), isDefaultLib); } function fileReferenceIsEqualTo(a, b) { return a.fileName === b.fileName; @@ -48444,9 +48644,9 @@ var ts; return; function collectModuleReferences(node, inAmbientModule) { switch (node.kind) { + case 231: case 230: - case 229: - case 236: + case 237: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9) { break; @@ -48458,7 +48658,7 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 225: + case 226: if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasModifier(node, 2) || ts.isDeclarationFile(file))) { var moduleName = node.name; if (isExternalModuleFile || (inAmbientModule && !ts.isExternalModuleNameRelative(moduleName.text))) { @@ -48485,7 +48685,7 @@ var ts; } } } - function processSourceFile(fileName, isDefaultLib, isReference, refFile, refPos, refEnd) { + function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { var diagnosticArgument; var diagnostic; if (hasExtension(fileName)) { @@ -48493,7 +48693,7 @@ var ts; diagnostic = ts.Diagnostics.File_0_has_unsupported_extension_The_only_supported_extensions_are_1; diagnosticArgument = [fileName, "'" + supportedExtensions.join("', '") + "'"]; } - else if (!findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, isReference, refFile, refPos, refEnd)) { + else if (!findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd)) { diagnostic = ts.Diagnostics.File_0_not_found; diagnosticArgument = [fileName]; } @@ -48503,13 +48703,13 @@ var ts; } } else { - var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, isReference, refFile, refPos, refEnd); + var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd); if (!nonTsFile) { if (options.allowNonTsExtensions) { diagnostic = ts.Diagnostics.File_0_not_found; diagnosticArgument = [fileName]; } - else if (!ts.forEach(supportedExtensions, function (extension) { return findSourceFile(fileName + extension, ts.toPath(fileName + extension, currentDirectory, getCanonicalFileName), isDefaultLib, isReference, refFile, refPos, refEnd); })) { + else if (!ts.forEach(supportedExtensions, function (extension) { return findSourceFile(fileName + extension, ts.toPath(fileName + extension, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd); })) { diagnostic = ts.Diagnostics.File_0_not_found; fileName += ".ts"; diagnosticArgument = [fileName]; @@ -48533,7 +48733,7 @@ var ts; fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); } } - function findSourceFile(fileName, path, isDefaultLib, isReference, refFile, refPos, refEnd) { + function findSourceFile(fileName, path, isDefaultLib, refFile, refPos, refEnd) { if (filesByName.contains(path)) { var file_1 = filesByName.get(path); if (file_1 && options.forceConsistentCasingInFileNames && ts.getNormalizedAbsolutePath(file_1.fileName, currentDirectory) !== ts.getNormalizedAbsolutePath(fileName, currentDirectory)) { @@ -48542,16 +48742,16 @@ var ts; if (file_1 && sourceFilesFoundSearchingNodeModules[file_1.path] && currentNodeModulesDepth == 0) { sourceFilesFoundSearchingNodeModules[file_1.path] = false; if (!options.noResolve) { - processReferencedFiles(file_1, ts.getDirectoryPath(fileName), isDefaultLib); + processReferencedFiles(file_1, isDefaultLib); processTypeReferenceDirectives(file_1); } modulesWithElidedImports[file_1.path] = false; - processImportedModules(file_1, ts.getDirectoryPath(fileName)); + processImportedModules(file_1); } else if (file_1 && modulesWithElidedImports[file_1.path]) { if (currentNodeModulesDepth < maxNodeModulesJsDepth) { modulesWithElidedImports[file_1.path] = false; - processImportedModules(file_1, ts.getDirectoryPath(fileName)); + processImportedModules(file_1); } } return file_1; @@ -48578,12 +48778,11 @@ var ts; } } skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; - var basePath = ts.getDirectoryPath(fileName); if (!options.noResolve) { - processReferencedFiles(file, basePath, isDefaultLib); + processReferencedFiles(file, isDefaultLib); processTypeReferenceDirectives(file); } - processImportedModules(file, basePath); + processImportedModules(file); if (isDefaultLib) { files.unshift(file); } @@ -48593,10 +48792,10 @@ var ts; } return file; } - function processReferencedFiles(file, basePath, isDefaultLib) { + function processReferencedFiles(file, isDefaultLib) { ts.forEach(file.referencedFiles, function (ref) { var referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName); - processSourceFile(referencedFileName, isDefaultLib, true, file, ref.pos, ref.end); + processSourceFile(referencedFileName, isDefaultLib, file, ref.pos, ref.end); }); } function processTypeReferenceDirectives(file) { @@ -48618,7 +48817,7 @@ var ts; var saveResolution = true; if (resolvedTypeReferenceDirective) { if (resolvedTypeReferenceDirective.primary) { - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, true, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, refFile, refPos, refEnd); } else { if (previousResolution) { @@ -48629,7 +48828,7 @@ var ts; saveResolution = false; } else { - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, true, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, refFile, refPos, refEnd); } } } @@ -48655,7 +48854,7 @@ var ts; function getCanonicalFileName(fileName) { return host.getCanonicalFileName(fileName); } - function processImportedModules(file, basePath) { + function processImportedModules(file) { collectExternalModuleReferences(file); if (file.imports.length || file.moduleAugmentations.length) { file.resolvedModules = ts.createMap(); @@ -48675,7 +48874,7 @@ var ts; modulesWithElidedImports[file.path] = true; } else if (shouldAddFile) { - findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), false, false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); + findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); } if (isFromNodeModulesSearch) { currentNodeModulesDepth--; @@ -48845,7 +49044,7 @@ var ts; if (!options.noEmit && !options.suppressOutputPathCheck) { var emitHost = getEmitHost(); var emitFilesSeen_1 = ts.createFileMap(!host.useCaseSensitiveFileNames() ? function (key) { return key.toLocaleLowerCase(); } : undefined); - ts.forEachExpectedEmitFile(emitHost, function (emitFileNames, sourceFiles, isBundledEmit) { + ts.forEachExpectedEmitFile(emitHost, function (emitFileNames) { verifyEmitFilePath(emitFileNames.jsFilePath, emitFilesSeen_1); verifyEmitFilePath(emitFileNames.declarationFilePath, emitFilesSeen_1); }); @@ -48854,10 +49053,10 @@ var ts; if (emitFileName) { var emitFilePath = ts.toPath(emitFileName, currentDirectory, getCanonicalFileName); if (filesByName.contains(emitFilePath)) { - createEmitBlockingDiagnostics(emitFileName, emitFilePath, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file); + createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file); } if (emitFilesSeen.contains(emitFilePath)) { - createEmitBlockingDiagnostics(emitFileName, emitFilePath, ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files); + createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files); } else { emitFilesSeen.set(emitFilePath, true); @@ -48865,7 +49064,7 @@ var ts; } } } - function createEmitBlockingDiagnostics(emitFileName, emitFilePath, message) { + function createEmitBlockingDiagnostics(emitFileName, message) { hasEmitBlockingDiagnostics.set(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName), true); programDiagnostics.add(ts.createCompilerDiagnostic(message, emitFileName)); } @@ -48873,6 +49072,1090 @@ var ts; ts.createProgram = createProgram; })(ts || (ts = {})); var ts; +(function (ts) { + ts.compileOnSaveCommandLineOption = { name: "compileOnSave", type: "boolean" }; + ts.optionDeclarations = [ + { + name: "charset", + type: "string", + }, + ts.compileOnSaveCommandLineOption, + { + name: "declaration", + shortName: "d", + type: "boolean", + description: ts.Diagnostics.Generates_corresponding_d_ts_file, + }, + { + name: "declarationDir", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.DIRECTORY, + }, + { + name: "diagnostics", + type: "boolean", + }, + { + name: "extendedDiagnostics", + type: "boolean", + experimental: true + }, + { + name: "emitBOM", + type: "boolean" + }, + { + name: "help", + shortName: "h", + type: "boolean", + description: ts.Diagnostics.Print_this_message, + }, + { + name: "help", + shortName: "?", + type: "boolean" + }, + { + name: "init", + type: "boolean", + description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file, + }, + { + name: "inlineSourceMap", + type: "boolean", + }, + { + name: "inlineSources", + type: "boolean", + }, + { + name: "jsx", + type: ts.createMap({ + "preserve": 1, + "react": 2 + }), + paramType: ts.Diagnostics.KIND, + description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, + }, + { + name: "reactNamespace", + type: "string", + description: ts.Diagnostics.Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit + }, + { + name: "listFiles", + type: "boolean", + }, + { + name: "locale", + type: "string", + }, + { + name: "mapRoot", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, + paramType: ts.Diagnostics.LOCATION, + }, + { + name: "module", + shortName: "m", + type: ts.createMap({ + "none": ts.ModuleKind.None, + "commonjs": ts.ModuleKind.CommonJS, + "amd": ts.ModuleKind.AMD, + "system": ts.ModuleKind.System, + "umd": ts.ModuleKind.UMD, + "es6": ts.ModuleKind.ES2015, + "es2015": ts.ModuleKind.ES2015, + }), + description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, + paramType: ts.Diagnostics.KIND, + }, + { + name: "newLine", + type: ts.createMap({ + "crlf": 0, + "lf": 1 + }), + description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, + paramType: ts.Diagnostics.NEWLINE, + }, + { + name: "noEmit", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_outputs, + }, + { + name: "noEmitHelpers", + type: "boolean" + }, + { + name: "noEmitOnError", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, + }, + { + name: "noErrorTruncation", + type: "boolean" + }, + { + name: "noImplicitAny", + type: "boolean", + description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type, + }, + { + name: "noImplicitThis", + type: "boolean", + description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, + }, + { + name: "noUnusedLocals", + type: "boolean", + description: ts.Diagnostics.Report_errors_on_unused_locals, + }, + { + name: "noUnusedParameters", + type: "boolean", + description: ts.Diagnostics.Report_errors_on_unused_parameters, + }, + { + name: "noLib", + type: "boolean", + }, + { + name: "noResolve", + type: "boolean", + }, + { + name: "skipDefaultLibCheck", + type: "boolean", + }, + { + name: "skipLibCheck", + type: "boolean", + description: ts.Diagnostics.Skip_type_checking_of_declaration_files, + }, + { + name: "out", + type: "string", + isFilePath: false, + paramType: ts.Diagnostics.FILE, + }, + { + name: "outFile", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, + paramType: ts.Diagnostics.FILE, + }, + { + name: "outDir", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Redirect_output_structure_to_the_directory, + paramType: ts.Diagnostics.DIRECTORY, + }, + { + name: "preserveConstEnums", + type: "boolean", + description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code + }, + { + name: "pretty", + description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental, + type: "boolean" + }, + { + name: "project", + shortName: "p", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Compile_the_project_in_the_given_directory, + paramType: ts.Diagnostics.DIRECTORY + }, + { + name: "removeComments", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_comments_to_output, + }, + { + name: "rootDir", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.LOCATION, + description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, + }, + { + name: "isolatedModules", + type: "boolean", + }, + { + name: "sourceMap", + type: "boolean", + description: ts.Diagnostics.Generates_corresponding_map_file, + }, + { + name: "sourceRoot", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, + paramType: ts.Diagnostics.LOCATION, + }, + { + name: "suppressExcessPropertyErrors", + type: "boolean", + description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals, + experimental: true + }, + { + name: "suppressImplicitAnyIndexErrors", + type: "boolean", + description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, + }, + { + name: "stripInternal", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation, + experimental: true + }, + { + name: "target", + shortName: "t", + type: ts.createMap({ + "es3": 0, + "es5": 1, + "es6": 2, + "es2015": 2, + "es2016": 3, + "es2017": 4, + }), + description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015, + paramType: ts.Diagnostics.VERSION, + }, + { + name: "version", + shortName: "v", + type: "boolean", + description: ts.Diagnostics.Print_the_compiler_s_version, + }, + { + name: "watch", + shortName: "w", + type: "boolean", + description: ts.Diagnostics.Watch_input_files, + }, + { + name: "experimentalDecorators", + type: "boolean", + description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators + }, + { + name: "emitDecoratorMetadata", + type: "boolean", + experimental: true, + description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators + }, + { + name: "moduleResolution", + type: ts.createMap({ + "node": ts.ModuleResolutionKind.NodeJs, + "classic": ts.ModuleResolutionKind.Classic, + }), + description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, + paramType: ts.Diagnostics.STRATEGY, + }, + { + name: "allowUnusedLabels", + type: "boolean", + description: ts.Diagnostics.Do_not_report_errors_on_unused_labels + }, + { + name: "noImplicitReturns", + type: "boolean", + description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value + }, + { + name: "noFallthroughCasesInSwitch", + type: "boolean", + description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement + }, + { + name: "allowUnreachableCode", + type: "boolean", + description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code + }, + { + name: "forceConsistentCasingInFileNames", + type: "boolean", + description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file + }, + { + name: "baseUrl", + type: "string", + isFilePath: true, + description: ts.Diagnostics.Base_directory_to_resolve_non_absolute_module_names + }, + { + name: "paths", + type: "object", + isTSConfigOnly: true + }, + { + name: "rootDirs", + type: "list", + isTSConfigOnly: true, + element: { + name: "rootDirs", + type: "string", + isFilePath: true + } + }, + { + name: "typeRoots", + type: "list", + element: { + name: "typeRoots", + type: "string", + isFilePath: true + } + }, + { + name: "types", + type: "list", + element: { + name: "types", + type: "string" + }, + description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation + }, + { + name: "traceResolution", + type: "boolean", + description: ts.Diagnostics.Enable_tracing_of_the_name_resolution_process + }, + { + name: "allowJs", + type: "boolean", + description: ts.Diagnostics.Allow_javascript_files_to_be_compiled + }, + { + name: "allowSyntheticDefaultImports", + type: "boolean", + description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking + }, + { + name: "noImplicitUseStrict", + type: "boolean", + description: ts.Diagnostics.Do_not_emit_use_strict_directives_in_module_output + }, + { + name: "maxNodeModuleJsDepth", + type: "number", + description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files + }, + { + name: "listEmittedFiles", + type: "boolean" + }, + { + name: "lib", + type: "list", + element: { + name: "lib", + type: ts.createMap({ + "es5": "lib.es5.d.ts", + "es6": "lib.es2015.d.ts", + "es2015": "lib.es2015.d.ts", + "es7": "lib.es2016.d.ts", + "es2016": "lib.es2016.d.ts", + "es2017": "lib.es2017.d.ts", + "dom": "lib.dom.d.ts", + "dom.iterable": "lib.dom.iterable.d.ts", + "webworker": "lib.webworker.d.ts", + "scripthost": "lib.scripthost.d.ts", + "es2015.core": "lib.es2015.core.d.ts", + "es2015.collection": "lib.es2015.collection.d.ts", + "es2015.generator": "lib.es2015.generator.d.ts", + "es2015.iterable": "lib.es2015.iterable.d.ts", + "es2015.promise": "lib.es2015.promise.d.ts", + "es2015.proxy": "lib.es2015.proxy.d.ts", + "es2015.reflect": "lib.es2015.reflect.d.ts", + "es2015.symbol": "lib.es2015.symbol.d.ts", + "es2015.symbol.wellknown": "lib.es2015.symbol.wellknown.d.ts", + "es2016.array.include": "lib.es2016.array.include.d.ts", + "es2017.object": "lib.es2017.object.d.ts", + "es2017.sharedmemory": "lib.es2017.sharedmemory.d.ts" + }), + }, + description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon + }, + { + name: "disableSizeLimit", + type: "boolean" + }, + { + name: "strictNullChecks", + type: "boolean", + description: ts.Diagnostics.Enable_strict_null_checks + }, + { + name: "importHelpers", + type: "boolean", + description: ts.Diagnostics.Import_emit_helpers_from_tslib + }, + { + name: "alwaysStrict", + type: "boolean", + description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file + } + ]; + ts.typingOptionDeclarations = [ + { + name: "enableAutoDiscovery", + type: "boolean", + }, + { + name: "include", + type: "list", + element: { + name: "include", + type: "string" + } + }, + { + name: "exclude", + type: "list", + element: { + name: "exclude", + type: "string" + } + } + ]; + ts.defaultInitCompilerOptions = { + module: ts.ModuleKind.CommonJS, + target: 1, + noImplicitAny: false, + sourceMap: false, + }; + var optionNameMapCache; + function getOptionNameMap() { + if (optionNameMapCache) { + return optionNameMapCache; + } + var optionNameMap = ts.createMap(); + var shortOptionNames = ts.createMap(); + ts.forEach(ts.optionDeclarations, function (option) { + optionNameMap[option.name.toLowerCase()] = option; + if (option.shortName) { + shortOptionNames[option.shortName] = option.name; + } + }); + optionNameMapCache = { optionNameMap: optionNameMap, shortOptionNames: shortOptionNames }; + return optionNameMapCache; + } + ts.getOptionNameMap = getOptionNameMap; + function createCompilerDiagnosticForInvalidCustomType(opt) { + var namesOfType = Object.keys(opt.type).map(function (key) { return "'" + key + "'"; }).join(", "); + return ts.createCompilerDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); + } + ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; + function parseCustomTypeOption(opt, value, errors) { + var key = trimString((value || "")).toLowerCase(); + var map = opt.type; + if (key in map) { + return map[key]; + } + else { + errors.push(createCompilerDiagnosticForInvalidCustomType(opt)); + } + } + ts.parseCustomTypeOption = parseCustomTypeOption; + function parseListTypeOption(opt, value, errors) { + if (value === void 0) { value = ""; } + value = trimString(value); + if (ts.startsWith(value, "-")) { + return undefined; + } + if (value === "") { + return []; + } + var values = value.split(","); + switch (opt.element.type) { + case "number": + return ts.map(values, parseInt); + case "string": + return ts.map(values, function (v) { return v || ""; }); + default: + return ts.filter(ts.map(values, function (v) { return parseCustomTypeOption(opt.element, v, errors); }), function (v) { return !!v; }); + } + } + ts.parseListTypeOption = parseListTypeOption; + function parseCommandLine(commandLine, readFile) { + var options = {}; + var fileNames = []; + var errors = []; + var _a = getOptionNameMap(), optionNameMap = _a.optionNameMap, shortOptionNames = _a.shortOptionNames; + parseStrings(commandLine); + return { + options: options, + fileNames: fileNames, + errors: errors + }; + function parseStrings(args) { + var i = 0; + while (i < args.length) { + var s = args[i]; + i++; + if (s.charCodeAt(0) === 64) { + parseResponseFile(s.slice(1)); + } + else if (s.charCodeAt(0) === 45) { + s = s.slice(s.charCodeAt(1) === 45 ? 2 : 1).toLowerCase(); + if (s in shortOptionNames) { + s = shortOptionNames[s]; + } + if (s in optionNameMap) { + var opt = optionNameMap[s]; + if (opt.isTSConfigOnly) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file, opt.name)); + } + else { + if (!args[i] && opt.type !== "boolean") { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_expects_an_argument, opt.name)); + } + switch (opt.type) { + case "number": + options[opt.name] = parseInt(args[i]); + i++; + break; + case "boolean": + options[opt.name] = true; + break; + case "string": + options[opt.name] = args[i] || ""; + i++; + break; + case "list": + var result = parseListTypeOption(opt, args[i], errors); + options[opt.name] = result || []; + if (result) { + i++; + } + break; + default: + options[opt.name] = parseCustomTypeOption(opt, args[i], errors); + i++; + break; + } + } + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_compiler_option_0, s)); + } + } + else { + fileNames.push(s); + } + } + } + function parseResponseFile(fileName) { + var text = readFile ? readFile(fileName) : ts.sys.readFile(fileName); + if (!text) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, fileName)); + return; + } + var args = []; + var pos = 0; + while (true) { + while (pos < text.length && text.charCodeAt(pos) <= 32) + pos++; + if (pos >= text.length) + break; + var start = pos; + if (text.charCodeAt(start) === 34) { + pos++; + while (pos < text.length && text.charCodeAt(pos) !== 34) + pos++; + if (pos < text.length) { + args.push(text.substring(start + 1, pos)); + pos++; + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unterminated_quoted_string_in_response_file_0, fileName)); + } + } + else { + while (text.charCodeAt(pos) > 32) + pos++; + args.push(text.substring(start, pos)); + } + } + parseStrings(args); + } + } + ts.parseCommandLine = parseCommandLine; + function readConfigFile(fileName, readFile) { + var text = ""; + try { + text = readFile(fileName); + } + catch (e) { + return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) }; + } + return parseConfigFileTextToJson(fileName, text); + } + ts.readConfigFile = readConfigFile; + function parseConfigFileTextToJson(fileName, jsonText, stripComments) { + if (stripComments === void 0) { stripComments = true; } + try { + var jsonTextToParse = stripComments ? removeComments(jsonText) : jsonText; + return { config: /\S/.test(jsonTextToParse) ? JSON.parse(jsonTextToParse) : {} }; + } + catch (e) { + return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) }; + } + } + ts.parseConfigFileTextToJson = parseConfigFileTextToJson; + function generateTSConfig(options, fileNames) { + var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions); + var configurations = { + compilerOptions: serializeCompilerOptions(compilerOptions) + }; + if (fileNames && fileNames.length) { + configurations.files = fileNames; + } + return configurations; + function getCustomTypeMapOfCommandLineOption(optionDefinition) { + if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean") { + return undefined; + } + else if (optionDefinition.type === "list") { + return getCustomTypeMapOfCommandLineOption(optionDefinition.element); + } + else { + return optionDefinition.type; + } + } + function getNameOfCompilerOptionValue(value, customTypeMap) { + for (var key in customTypeMap) { + if (customTypeMap[key] === value) { + return key; + } + } + return undefined; + } + function serializeCompilerOptions(options) { + var result = ts.createMap(); + var optionsNameMap = getOptionNameMap().optionNameMap; + for (var name_44 in options) { + if (ts.hasProperty(options, name_44)) { + switch (name_44) { + case "init": + case "watch": + case "version": + case "help": + case "project": + break; + default: + var value = options[name_44]; + var optionDefinition = optionsNameMap[name_44.toLowerCase()]; + if (optionDefinition) { + var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); + if (!customTypeMap) { + result[name_44] = value; + } + else { + if (optionDefinition.type === "list") { + var convertedValue = []; + for (var _i = 0, _a = value; _i < _a.length; _i++) { + var element = _a[_i]; + convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); + } + result[name_44] = convertedValue; + } + else { + result[name_44] = getNameOfCompilerOptionValue(value, customTypeMap); + } + } + } + break; + } + } + } + return result; + } + } + ts.generateTSConfig = generateTSConfig; + function removeComments(jsonText) { + var output = ""; + var scanner = ts.createScanner(1, false, 0, jsonText); + var token; + while ((token = scanner.scan()) !== 1) { + switch (token) { + case 2: + case 3: + output += scanner.getTokenText().replace(/\S/g, " "); + break; + default: + output += scanner.getTokenText(); + break; + } + } + return output; + } + function parseJsonConfigFileContent(json, host, basePath, existingOptions, configFileName, resolutionStack) { + if (existingOptions === void 0) { existingOptions = {}; } + if (resolutionStack === void 0) { resolutionStack = []; } + var errors = []; + var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); + var resolvedPath = ts.toPath(configFileName || "", basePath, getCanonicalFileName); + if (resolutionStack.indexOf(resolvedPath) >= 0) { + return { + options: {}, + fileNames: [], + typingOptions: {}, + raw: json, + errors: [ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, resolutionStack.concat([resolvedPath]).join(" -> "))], + wildcardDirectories: {} + }; + } + var options = convertCompilerOptionsFromJsonWorker(json["compilerOptions"], basePath, errors, configFileName); + var typingOptions = convertTypingOptionsFromJsonWorker(json["typingOptions"], basePath, errors, configFileName); + if (json["extends"]) { + var _a = [undefined, undefined, undefined, {}], include = _a[0], exclude = _a[1], files = _a[2], baseOptions = _a[3]; + if (typeof json["extends"] === "string") { + _b = (tryExtendsName(json["extends"]) || [include, exclude, files, baseOptions]), include = _b[0], exclude = _b[1], files = _b[2], baseOptions = _b[3]; + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string")); + } + if (include && !json["include"]) { + json["include"] = include; + } + if (exclude && !json["exclude"]) { + json["exclude"] = exclude; + } + if (files && !json["files"]) { + json["files"] = files; + } + options = ts.assign({}, baseOptions, options); + } + options = ts.extend(existingOptions, options); + options.configFilePath = configFileName; + var _c = getFileNames(errors), fileNames = _c.fileNames, wildcardDirectories = _c.wildcardDirectories; + var compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors); + return { + options: options, + fileNames: fileNames, + typingOptions: typingOptions, + raw: json, + errors: errors, + wildcardDirectories: wildcardDirectories, + compileOnSave: compileOnSave + }; + function tryExtendsName(extendedConfig) { + if (!(ts.isRootedDiskPath(extendedConfig) || ts.startsWith(ts.normalizeSlashes(extendedConfig), "./") || ts.startsWith(ts.normalizeSlashes(extendedConfig), "../"))) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.The_path_in_an_extends_options_must_be_relative_or_rooted)); + return; + } + var extendedConfigPath = ts.toPath(extendedConfig, basePath, getCanonicalFileName); + if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json")) { + extendedConfigPath = extendedConfigPath + ".json"; + if (!host.fileExists(extendedConfigPath)) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_does_not_exist, extendedConfig)); + return; + } + } + var extendedResult = readConfigFile(extendedConfigPath, function (path) { return host.readFile(path); }); + if (extendedResult.error) { + errors.push(extendedResult.error); + return; + } + var extendedDirname = ts.getDirectoryPath(extendedConfigPath); + var relativeDifference = ts.convertToRelativePath(extendedDirname, basePath, getCanonicalFileName); + var updatePath = function (path) { return ts.isRootedDiskPath(path) ? path : ts.combinePaths(relativeDifference, path); }; + var result = parseJsonConfigFileContent(extendedResult.config, host, extendedDirname, undefined, ts.getBaseFileName(extendedConfigPath), resolutionStack.concat([resolvedPath])); + errors.push.apply(errors, result.errors); + var _a = ts.map(["include", "exclude", "files"], function (key) { + if (!json[key] && extendedResult.config[key]) { + return ts.map(extendedResult.config[key], updatePath); + } + }), include = _a[0], exclude = _a[1], files = _a[2]; + return [include, exclude, files, result.options]; + } + function getFileNames(errors) { + var fileNames; + if (ts.hasProperty(json, "files")) { + if (ts.isArray(json["files"])) { + fileNames = json["files"]; + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array")); + } + } + var includeSpecs; + if (ts.hasProperty(json, "include")) { + if (ts.isArray(json["include"])) { + includeSpecs = json["include"]; + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "include", "Array")); + } + } + var excludeSpecs; + if (ts.hasProperty(json, "exclude")) { + if (ts.isArray(json["exclude"])) { + excludeSpecs = json["exclude"]; + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "exclude", "Array")); + } + } + else if (ts.hasProperty(json, "excludes")) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_option_excludes_Did_you_mean_exclude)); + } + else { + excludeSpecs = ["node_modules", "bower_components", "jspm_packages"]; + var outDir = json["compilerOptions"] && json["compilerOptions"]["outDir"]; + if (outDir) { + excludeSpecs.push(outDir); + } + } + if (fileNames === undefined && includeSpecs === undefined) { + includeSpecs = ["**/*"]; + } + return matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors); + } + var _b; + } + ts.parseJsonConfigFileContent = parseJsonConfigFileContent; + function convertCompileOnSaveOptionFromJson(jsonOption, basePath, errors) { + if (!ts.hasProperty(jsonOption, ts.compileOnSaveCommandLineOption.name)) { + return false; + } + var result = convertJsonOption(ts.compileOnSaveCommandLineOption, jsonOption["compileOnSave"], basePath, errors); + if (typeof result === "boolean" && result) { + return result; + } + return false; + } + ts.convertCompileOnSaveOptionFromJson = convertCompileOnSaveOptionFromJson; + function convertCompilerOptionsFromJson(jsonOptions, basePath, configFileName) { + var errors = []; + var options = convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName); + return { options: options, errors: errors }; + } + ts.convertCompilerOptionsFromJson = convertCompilerOptionsFromJson; + function convertTypingOptionsFromJson(jsonOptions, basePath, configFileName) { + var errors = []; + var options = convertTypingOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName); + return { options: options, errors: errors }; + } + ts.convertTypingOptionsFromJson = convertTypingOptionsFromJson; + function convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { + var options = ts.getBaseFileName(configFileName) === "jsconfig.json" + ? { allowJs: true, maxNodeModuleJsDepth: 2, allowSyntheticDefaultImports: true, skipLibCheck: true } + : {}; + convertOptionsFromJson(ts.optionDeclarations, jsonOptions, basePath, options, ts.Diagnostics.Unknown_compiler_option_0, errors); + return options; + } + function convertTypingOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { + var options = ts.getBaseFileName(configFileName) === "jsconfig.json" + ? { enableAutoDiscovery: true, include: [], exclude: [] } + : { enableAutoDiscovery: false, include: [], exclude: [] }; + convertOptionsFromJson(ts.typingOptionDeclarations, jsonOptions, basePath, options, ts.Diagnostics.Unknown_typing_option_0, errors); + return options; + } + function convertOptionsFromJson(optionDeclarations, jsonOptions, basePath, defaultOptions, diagnosticMessage, errors) { + if (!jsonOptions) { + return; + } + var optionNameMap = ts.arrayToMap(optionDeclarations, function (opt) { return opt.name; }); + for (var id in jsonOptions) { + if (id in optionNameMap) { + var opt = optionNameMap[id]; + defaultOptions[opt.name] = convertJsonOption(opt, jsonOptions[id], basePath, errors); + } + else { + errors.push(ts.createCompilerDiagnostic(diagnosticMessage, id)); + } + } + } + function convertJsonOption(opt, value, basePath, errors) { + var optType = opt.type; + var expectedType = typeof optType === "string" ? optType : "string"; + if (optType === "list" && ts.isArray(value)) { + return convertJsonOptionOfListType(opt, value, basePath, errors); + } + else if (typeof value === expectedType) { + if (typeof optType !== "string") { + return convertJsonOptionOfCustomType(opt, value, errors); + } + else { + if (opt.isFilePath) { + value = ts.normalizePath(ts.combinePaths(basePath, value)); + if (value === "") { + value = "."; + } + } + } + return value; + } + else { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, opt.name, expectedType)); + } + } + function convertJsonOptionOfCustomType(opt, value, errors) { + var key = value.toLowerCase(); + if (key in opt.type) { + return opt.type[key]; + } + else { + errors.push(createCompilerDiagnosticForInvalidCustomType(opt)); + } + } + function convertJsonOptionOfListType(option, values, basePath, errors) { + return ts.filter(ts.map(values, function (v) { return convertJsonOption(option.element, v, basePath, errors); }), function (v) { return !!v; }); + } + function trimString(s) { + return typeof s.trim === "function" ? s.trim() : s.replace(/^[\s]+|[\s]+$/g, ""); + } + var invalidTrailingRecursionPattern = /(^|\/)\*\*\/?$/; + var invalidMultipleRecursionPatterns = /(^|\/)\*\*\/(.*\/)?\*\*($|\/)/; + var invalidDotDotAfterRecursiveWildcardPattern = /(^|\/)\*\*\/(.*\/)?\.\.($|\/)/; + var watchRecursivePattern = /\/[^/]*?[*?][^/]*\//; + var wildcardDirectoryPattern = /^[^*?]*(?=\/[^/]*[*?])/; + function matchFileNames(fileNames, include, exclude, basePath, options, host, errors) { + basePath = ts.normalizePath(basePath); + var keyMapper = host.useCaseSensitiveFileNames ? caseSensitiveKeyMapper : caseInsensitiveKeyMapper; + var literalFileMap = ts.createMap(); + var wildcardFileMap = ts.createMap(); + if (include) { + include = validateSpecs(include, errors, false); + } + if (exclude) { + exclude = validateSpecs(exclude, errors, true); + } + var wildcardDirectories = getWildcardDirectories(include, exclude, basePath, host.useCaseSensitiveFileNames); + var supportedExtensions = ts.getSupportedExtensions(options); + if (fileNames) { + for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) { + var fileName = fileNames_1[_i]; + var file = ts.combinePaths(basePath, fileName); + literalFileMap[keyMapper(file)] = file; + } + } + if (include && include.length > 0) { + for (var _a = 0, _b = host.readDirectory(basePath, supportedExtensions, exclude, include); _a < _b.length; _a++) { + var file = _b[_a]; + if (hasFileWithHigherPriorityExtension(file, literalFileMap, wildcardFileMap, supportedExtensions, keyMapper)) { + continue; + } + removeWildcardFilesWithLowerPriorityExtension(file, wildcardFileMap, supportedExtensions, keyMapper); + var key = keyMapper(file); + if (!(key in literalFileMap) && !(key in wildcardFileMap)) { + wildcardFileMap[key] = file; + } + } + } + var literalFiles = ts.reduceProperties(literalFileMap, addFileToOutput, []); + var wildcardFiles = ts.reduceProperties(wildcardFileMap, addFileToOutput, []); + wildcardFiles.sort(host.useCaseSensitiveFileNames ? ts.compareStrings : ts.compareStringsCaseInsensitive); + return { + fileNames: literalFiles.concat(wildcardFiles), + wildcardDirectories: wildcardDirectories + }; + } + function validateSpecs(specs, errors, allowTrailingRecursion) { + var validSpecs = []; + for (var _i = 0, specs_2 = specs; _i < specs_2.length; _i++) { + var spec = specs_2[_i]; + if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); + } + else if (invalidMultipleRecursionPatterns.test(spec)) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0, spec)); + } + else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec)); + } + else { + validSpecs.push(spec); + } + } + return validSpecs; + } + function getWildcardDirectories(include, exclude, path, useCaseSensitiveFileNames) { + var rawExcludeRegex = ts.getRegularExpressionForWildcard(exclude, path, "exclude"); + var excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames ? "" : "i"); + var wildcardDirectories = ts.createMap(); + if (include !== undefined) { + var recursiveKeys = []; + for (var _i = 0, include_1 = include; _i < include_1.length; _i++) { + var file = include_1[_i]; + var name_45 = ts.normalizePath(ts.combinePaths(path, file)); + if (excludeRegex && excludeRegex.test(name_45)) { + continue; + } + var match = wildcardDirectoryPattern.exec(name_45); + if (match) { + var key = useCaseSensitiveFileNames ? match[0] : match[0].toLowerCase(); + var flags = watchRecursivePattern.test(name_45) ? 1 : 0; + var existingFlags = wildcardDirectories[key]; + if (existingFlags === undefined || existingFlags < flags) { + wildcardDirectories[key] = flags; + if (flags === 1) { + recursiveKeys.push(key); + } + } + } + } + for (var key in wildcardDirectories) { + for (var _a = 0, recursiveKeys_1 = recursiveKeys; _a < recursiveKeys_1.length; _a++) { + var recursiveKey = recursiveKeys_1[_a]; + if (key !== recursiveKey && ts.containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) { + delete wildcardDirectories[key]; + } + } + } + } + return wildcardDirectories; + } + function hasFileWithHigherPriorityExtension(file, literalFiles, wildcardFiles, extensions, keyMapper) { + var extensionPriority = ts.getExtensionPriority(file, extensions); + var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority); + for (var i = 0; i < adjustedExtensionPriority; i++) { + var higherPriorityExtension = extensions[i]; + var higherPriorityPath = keyMapper(ts.changeExtension(file, higherPriorityExtension)); + if (higherPriorityPath in literalFiles || higherPriorityPath in wildcardFiles) { + return true; + } + } + return false; + } + function removeWildcardFilesWithLowerPriorityExtension(file, wildcardFiles, extensions, keyMapper) { + var extensionPriority = ts.getExtensionPriority(file, extensions); + var nextExtensionPriority = ts.getNextLowestExtensionPriority(extensionPriority); + for (var i = nextExtensionPriority; i < extensions.length; i++) { + var lowerPriorityExtension = extensions[i]; + var lowerPriorityPath = keyMapper(ts.changeExtension(file, lowerPriorityExtension)); + delete wildcardFiles[lowerPriorityPath]; + } + } + function addFileToOutput(output, file) { + output.push(file); + return output; + } + function caseSensitiveKeyMapper(key) { + return key; + } + function caseInsensitiveKeyMapper(key) { + return key.toLowerCase(); + } +})(ts || (ts = {})); +var ts; (function (ts) { var ScriptSnapshot; (function (ScriptSnapshot) { @@ -48886,7 +50169,7 @@ var ts; StringScriptSnapshot.prototype.getLength = function () { return this.text.length; }; - StringScriptSnapshot.prototype.getChangeRange = function (oldSnapshot) { + StringScriptSnapshot.prototype.getChangeRange = function () { return undefined; }; return StringScriptSnapshot; @@ -48940,6 +50223,22 @@ var ts; SymbolDisplayPartKind[SymbolDisplayPartKind["regularExpressionLiteral"] = 21] = "regularExpressionLiteral"; })(ts.SymbolDisplayPartKind || (ts.SymbolDisplayPartKind = {})); var SymbolDisplayPartKind = ts.SymbolDisplayPartKind; + (function (OutputFileType) { + OutputFileType[OutputFileType["JavaScript"] = 0] = "JavaScript"; + OutputFileType[OutputFileType["SourceMap"] = 1] = "SourceMap"; + OutputFileType[OutputFileType["Declaration"] = 2] = "Declaration"; + })(ts.OutputFileType || (ts.OutputFileType = {})); + var OutputFileType = ts.OutputFileType; + (function (EndOfLineState) { + EndOfLineState[EndOfLineState["None"] = 0] = "None"; + EndOfLineState[EndOfLineState["InMultiLineCommentTrivia"] = 1] = "InMultiLineCommentTrivia"; + EndOfLineState[EndOfLineState["InSingleQuoteStringLiteral"] = 2] = "InSingleQuoteStringLiteral"; + EndOfLineState[EndOfLineState["InDoubleQuoteStringLiteral"] = 3] = "InDoubleQuoteStringLiteral"; + EndOfLineState[EndOfLineState["InTemplateHeadOrNoSubstitutionTemplate"] = 4] = "InTemplateHeadOrNoSubstitutionTemplate"; + EndOfLineState[EndOfLineState["InTemplateMiddleOrTail"] = 5] = "InTemplateMiddleOrTail"; + EndOfLineState[EndOfLineState["InTemplateSubstitutionPosition"] = 6] = "InTemplateSubstitutionPosition"; + })(ts.EndOfLineState || (ts.EndOfLineState = {})); + var EndOfLineState = ts.EndOfLineState; (function (TokenClass) { TokenClass[TokenClass["Punctuation"] = 0] = "Punctuation"; TokenClass[TokenClass["Keyword"] = 1] = "Keyword"; @@ -49027,40 +50326,75 @@ var ts; ClassificationTypeNames.jsxText = "jsx text"; ClassificationTypeNames.jsxAttributeStringLiteralValue = "jsx attribute string literal value"; ts.ClassificationTypeNames = ClassificationTypeNames; + (function (ClassificationType) { + ClassificationType[ClassificationType["comment"] = 1] = "comment"; + ClassificationType[ClassificationType["identifier"] = 2] = "identifier"; + ClassificationType[ClassificationType["keyword"] = 3] = "keyword"; + ClassificationType[ClassificationType["numericLiteral"] = 4] = "numericLiteral"; + ClassificationType[ClassificationType["operator"] = 5] = "operator"; + ClassificationType[ClassificationType["stringLiteral"] = 6] = "stringLiteral"; + ClassificationType[ClassificationType["regularExpressionLiteral"] = 7] = "regularExpressionLiteral"; + ClassificationType[ClassificationType["whiteSpace"] = 8] = "whiteSpace"; + ClassificationType[ClassificationType["text"] = 9] = "text"; + ClassificationType[ClassificationType["punctuation"] = 10] = "punctuation"; + ClassificationType[ClassificationType["className"] = 11] = "className"; + ClassificationType[ClassificationType["enumName"] = 12] = "enumName"; + ClassificationType[ClassificationType["interfaceName"] = 13] = "interfaceName"; + ClassificationType[ClassificationType["moduleName"] = 14] = "moduleName"; + ClassificationType[ClassificationType["typeParameterName"] = 15] = "typeParameterName"; + ClassificationType[ClassificationType["typeAliasName"] = 16] = "typeAliasName"; + ClassificationType[ClassificationType["parameterName"] = 17] = "parameterName"; + ClassificationType[ClassificationType["docCommentTagName"] = 18] = "docCommentTagName"; + ClassificationType[ClassificationType["jsxOpenTagName"] = 19] = "jsxOpenTagName"; + ClassificationType[ClassificationType["jsxCloseTagName"] = 20] = "jsxCloseTagName"; + ClassificationType[ClassificationType["jsxSelfClosingTagName"] = 21] = "jsxSelfClosingTagName"; + ClassificationType[ClassificationType["jsxAttribute"] = 22] = "jsxAttribute"; + ClassificationType[ClassificationType["jsxText"] = 23] = "jsxText"; + ClassificationType[ClassificationType["jsxAttributeStringLiteralValue"] = 24] = "jsxAttributeStringLiteralValue"; + })(ts.ClassificationType || (ts.ClassificationType = {})); + var ClassificationType = ts.ClassificationType; })(ts || (ts = {})); var ts; (function (ts) { - ts.scanner = ts.createScanner(2, true); + ts.scanner = ts.createScanner(4, true); ts.emptyArray = []; + (function (SemanticMeaning) { + SemanticMeaning[SemanticMeaning["None"] = 0] = "None"; + SemanticMeaning[SemanticMeaning["Value"] = 1] = "Value"; + SemanticMeaning[SemanticMeaning["Type"] = 2] = "Type"; + SemanticMeaning[SemanticMeaning["Namespace"] = 4] = "Namespace"; + SemanticMeaning[SemanticMeaning["All"] = 7] = "All"; + })(ts.SemanticMeaning || (ts.SemanticMeaning = {})); + var SemanticMeaning = ts.SemanticMeaning; function getMeaningFromDeclaration(node) { switch (node.kind) { - case 142: - case 218: - case 169: + case 143: + case 219: + case 170: + case 146: case 145: - case 144: case 253: case 254: case 255: - case 147: - case 146: case 148: + case 147: case 149: case 150: - case 220: - case 179: + case 151: + case 221: case 180: + case 181: case 252: return 1; - case 141: - case 222: + case 142: case 223: - case 159: - return 2; - case 221: case 224: - return 1 | 2; + case 160: + return 2; + case 222: case 225: + return 1 | 2; + case 226: if (ts.isAmbientModule(node)) { return 4 | 1; } @@ -49070,12 +50404,12 @@ var ts; else { return 4; } - case 233: case 234: - case 229: - case 230: case 235: + case 230: + case 231: case 236: + case 237: return 1 | 2 | 4; case 256: return 4 | 1; @@ -49084,7 +50418,7 @@ var ts; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.parent.kind === 235) { + if (node.parent.kind === 236) { return 1 | 2 | 4; } else if (isInRightSideOfImport(node)) { @@ -49105,16 +50439,16 @@ var ts; } ts.getMeaningFromLocation = getMeaningFromLocation; function getMeaningFromRightHandSideOfImportEquals(node) { - ts.Debug.assert(node.kind === 69); - if (node.parent.kind === 139 && + ts.Debug.assert(node.kind === 70); + if (node.parent.kind === 140 && node.parent.right === node && - node.parent.parent.kind === 229) { + node.parent.parent.kind === 230) { return 1 | 2 | 4; } return 4; } function isInRightSideOfImport(node) { - while (node.parent.kind === 139) { + while (node.parent.kind === 140) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -49125,27 +50459,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 139) { - while (root.parent && root.parent.kind === 139) { + if (root.parent.kind === 140) { + while (root.parent && root.parent.kind === 140) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 155 && !isLastClause; + return root.parent.kind === 156 && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 172) { - while (root.parent && root.parent.kind === 172) { + if (root.parent.kind === 173) { + while (root.parent && root.parent.kind === 173) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 194 && root.parent.parent.kind === 251) { + if (!isLastClause && root.parent.kind === 195 && root.parent.parent.kind === 251) { var decl = root.parent.parent.parent; - return (decl.kind === 221 && root.parent.parent.token === 106) || - (decl.kind === 222 && root.parent.parent.token === 83); + return (decl.kind === 222 && root.parent.parent.token === 107) || + (decl.kind === 223 && root.parent.parent.token === 84); } return false; } @@ -49153,17 +50487,17 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 155 || - (node.parent.kind === 194 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || - (node.kind === 97 && !ts.isPartOfExpression(node)) || - node.kind === 165; + return node.parent.kind === 156 || + (node.parent.kind === 195 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || + (node.kind === 98 && !ts.isPartOfExpression(node)) || + node.kind === 166; } function isCallExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 174); + return isCallOrNewExpressionTarget(node, 175); } ts.isCallExpressionTarget = isCallExpressionTarget; function isNewExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 175); + return isCallOrNewExpressionTarget(node, 176); } ts.isNewExpressionTarget = isNewExpressionTarget; function isCallOrNewExpressionTarget(node, kind) { @@ -49176,7 +50510,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 214 && referenceNode.label.text === labelName) { + if (referenceNode.kind === 215 && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -49185,14 +50519,14 @@ var ts; } ts.getTargetLabel = getTargetLabel; function isJumpStatementTarget(node) { - return node.kind === 69 && - (node.parent.kind === 210 || node.parent.kind === 209) && + return node.kind === 70 && + (node.parent.kind === 211 || node.parent.kind === 210) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { - return node.kind === 69 && - node.parent.kind === 214 && + return node.kind === 70 && + node.parent.kind === 215 && node.parent.label === node; } function isLabelName(node) { @@ -49200,38 +50534,38 @@ var ts; } ts.isLabelName = isLabelName; function isRightSideOfQualifiedName(node) { - return node.parent.kind === 139 && node.parent.right === node; + return node.parent.kind === 140 && node.parent.right === node; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 172 && node.parent.name === node; + return node && node.parent && node.parent.kind === 173 && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 225 && node.parent.name === node; + return node.parent.kind === 226 && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { - return node.kind === 69 && + return node.kind === 70 && ts.isFunctionLike(node.parent) && node.parent.name === node; } ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 9 || node.kind === 8) { switch (node.parent.kind) { + case 146: case 145: - case 144: case 253: case 255: + case 148: case 147: - case 146: - case 149: case 150: - case 225: + case 151: + case 226: return node.parent.name === node; - case 173: + case 174: return node.parent.argumentExpression === node; - case 140: + case 141: return true; } } @@ -49276,16 +50610,16 @@ var ts; } switch (node.kind) { case 256: + case 148: case 147: - case 146: - case 220: - case 179: - case 149: - case 150: case 221: + case 180: + case 150: + case 151: case 222: - case 224: + case 223: case 225: + case 226: return node; } } @@ -49295,42 +50629,42 @@ var ts; switch (node.kind) { case 256: return ts.isExternalModule(node) ? ts.ScriptElementKind.moduleElement : ts.ScriptElementKind.scriptElement; - case 225: + case 226: return ts.ScriptElementKind.moduleElement; - case 221: - case 192: + case 222: + case 193: return ts.ScriptElementKind.classElement; - case 222: return ts.ScriptElementKind.interfaceElement; - case 223: return ts.ScriptElementKind.typeElement; - case 224: return ts.ScriptElementKind.enumElement; - case 218: + case 223: return ts.ScriptElementKind.interfaceElement; + case 224: return ts.ScriptElementKind.typeElement; + case 225: return ts.ScriptElementKind.enumElement; + case 219: return getKindOfVariableDeclaration(node); - case 169: + case 170: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); + case 181: + case 221: case 180: - case 220: - case 179: return ts.ScriptElementKind.functionElement; - case 149: return ts.ScriptElementKind.memberGetAccessorElement; - case 150: return ts.ScriptElementKind.memberSetAccessorElement; + case 150: return ts.ScriptElementKind.memberGetAccessorElement; + case 151: return ts.ScriptElementKind.memberSetAccessorElement; + case 148: case 147: - case 146: return ts.ScriptElementKind.memberFunctionElement; + case 146: case 145: - case 144: return ts.ScriptElementKind.memberVariableElement; - case 153: return ts.ScriptElementKind.indexSignatureElement; - case 152: return ts.ScriptElementKind.constructSignatureElement; - case 151: return ts.ScriptElementKind.callSignatureElement; - case 148: return ts.ScriptElementKind.constructorImplementationElement; - case 141: return ts.ScriptElementKind.typeParameterElement; + case 154: return ts.ScriptElementKind.indexSignatureElement; + case 153: return ts.ScriptElementKind.constructSignatureElement; + case 152: return ts.ScriptElementKind.callSignatureElement; + case 149: return ts.ScriptElementKind.constructorImplementationElement; + case 142: return ts.ScriptElementKind.typeParameterElement; case 255: return ts.ScriptElementKind.enumMemberElement; - case 142: return ts.hasModifier(node, 92) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; - case 229: - case 234: - case 231: - case 238: + case 143: return ts.hasModifier(node, 92) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; + case 230: + case 235: case 232: + case 239: + case 233: return ts.ScriptElementKind.alias; case 279: return ts.ScriptElementKind.typeElement; @@ -49347,7 +50681,7 @@ var ts; } ts.getNodeKind = getNodeKind; function getStringLiteralTypeForNode(node, typeChecker) { - var searchNode = node.parent.kind === 166 ? node.parent : node; + var searchNode = node.parent.kind === 167 ? node.parent : node; var type = typeChecker.getTypeAtLocation(searchNode); if (type && type.flags & 32) { return type; @@ -49357,10 +50691,10 @@ var ts; ts.getStringLiteralTypeForNode = getStringLiteralTypeForNode; function isThis(node) { switch (node.kind) { - case 97: + case 98: return true; - case 69: - return ts.identifierIsThisKeyword(node) && node.parent.kind === 142; + case 70: + return ts.identifierIsThisKeyword(node) && node.parent.kind === 143; default: return false; } @@ -49404,107 +50738,107 @@ var ts; return false; } switch (n.kind) { - case 221: case 222: - case 224: - case 171: - case 167: - case 159: - case 199: - case 226: + case 223: + case 225: + case 172: + case 168: + case 160: + case 200: case 227: - case 233: - case 237: - return nodeEndsWith(n, 16, sourceFile); + case 228: + case 234: + case 238: + return nodeEndsWith(n, 17, sourceFile); case 252: return isCompletedNode(n.block, sourceFile); - case 175: + case 176: if (!n.arguments) { return true; } - case 174: - case 178: - case 164: - return nodeEndsWith(n, 18, sourceFile); - case 156: + case 175: + case 179: + case 165: + return nodeEndsWith(n, 19, sourceFile); case 157: + case 158: return isCompletedNode(n.type, sourceFile); - case 148: case 149: case 150: - case 220: - case 179: - case 147: - case 146: - case 152: case 151: + case 221: case 180: + case 148: + case 147: + case 153: + case 152: + case 181: if (n.body) { return isCompletedNode(n.body, sourceFile); } if (n.type) { return isCompletedNode(n.type, sourceFile); } - return hasChildOfKind(n, 18, sourceFile); - case 225: + return hasChildOfKind(n, 19, sourceFile); + case 226: return n.body && isCompletedNode(n.body, sourceFile); - case 203: + case 204: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 202: + case 203: return isCompletedNode(n.expression, sourceFile) || - hasChildOfKind(n, 23); - case 170: - case 168: - case 173: - case 140: - case 161: - return nodeEndsWith(n, 20, sourceFile); - case 153: + hasChildOfKind(n, 24); + case 171: + case 169: + case 174: + case 141: + case 162: + return nodeEndsWith(n, 21, sourceFile); + case 154: if (n.type) { return isCompletedNode(n.type, sourceFile); } - return hasChildOfKind(n, 20, sourceFile); + return hasChildOfKind(n, 21, sourceFile); case 249: case 250: return false; - case 206: case 207: case 208: - case 205: + case 209: + case 206: return isCompletedNode(n.statement, sourceFile); - case 204: - var hasWhileKeyword = findChildOfKind(n, 104, sourceFile); + case 205: + var hasWhileKeyword = findChildOfKind(n, 105, sourceFile); if (hasWhileKeyword) { - return nodeEndsWith(n, 18, sourceFile); + return nodeEndsWith(n, 19, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 158: + case 159: return isCompletedNode(n.exprName, sourceFile); - case 182: - case 181: case 183: - case 190: + case 182: + case 184: case 191: + case 192: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 176: + case 177: return isCompletedNode(n.template, sourceFile); - case 189: + case 190: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 197: + case 198: return ts.nodeIsPresent(n.literal); - case 236: - case 230: + case 237: + case 231: return ts.nodeIsPresent(n.moduleSpecifier); - case 185: + case 186: return isCompletedNode(n.operand, sourceFile); - case 187: - return isCompletedNode(n.right, sourceFile); case 188: + return isCompletedNode(n.right, sourceFile); + case 189: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -49518,7 +50852,7 @@ var ts; if (last.kind === expectedLastToken) { return true; } - else if (last.kind === 23 && children.length !== 1) { + else if (last.kind === 24 && children.length !== 1) { return children[children.length - 2].kind === expectedLastToken; } } @@ -49655,7 +50989,7 @@ var ts; function findPrecedingToken(position, sourceFile, startNode) { return find(startNode || sourceFile); function findRightmostToken(n) { - if (isToken(n) || n.kind === 244) { + if (isToken(n)) { return n; } var children = n.getChildren(); @@ -49663,16 +50997,16 @@ var ts; return candidate && findRightmostToken(candidate); } function find(n) { - if (isToken(n) || n.kind === 244) { + if (isToken(n)) { 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 === 244)) { + if (position < child.end && (nodeHasTokens(child) || child.kind === 10)) { var start = child.getStart(sourceFile); var lookInPreviousChild = (start >= position) || - (child.kind === 244 && start === child.end); + (child.kind === 10 && start === child.end); if (lookInPreviousChild) { var candidate = findRightmostChildNodeWithTokens(children, i); return candidate && findRightmostToken(candidate); @@ -49721,19 +51055,19 @@ var ts; if (!token) { return false; } - if (token.kind === 244) { + if (token.kind === 10) { return true; } - if (token.kind === 25 && token.parent.kind === 244) { + if (token.kind === 26 && token.parent.kind === 10) { return true; } - if (token.kind === 25 && token.parent.kind === 248) { + if (token.kind === 26 && token.parent.kind === 248) { return true; } - if (token && token.kind === 16 && token.parent.kind === 248) { + if (token && token.kind === 17 && token.parent.kind === 248) { return true; } - if (token.kind === 25 && token.parent.kind === 245) { + if (token.kind === 26 && token.parent.kind === 245) { return true; } return false; @@ -49772,9 +51106,9 @@ var ts; var node = ts.getTokenAtPosition(sourceFile, position); if (isToken(node)) { switch (node.kind) { - case 102: - case 108: - case 74: + case 103: + case 109: + case 75: node = node.parent === undefined ? undefined : node.parent.parent; break; default: @@ -49824,21 +51158,21 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 155 || node.kind === 174) { + if (node.kind === 156 || node.kind === 175) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 221 || node.kind === 222) { + if (ts.isFunctionLike(node) || node.kind === 222 || node.kind === 223) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 && n.kind <= 138; + return n.kind >= 0 && n.kind <= 139; } ts.isToken = isToken; function isWord(kind) { - return kind === 69 || ts.isKeyword(kind); + return kind === 70 || ts.isKeyword(kind); } ts.isWord = isWord; function isPropertyName(kind) { @@ -49850,7 +51184,7 @@ var ts; ts.isComment = isComment; function isStringOrRegularExpressionOrTemplateLiteral(kind) { if (kind === 9 - || kind === 10 + || kind === 11 || ts.isTemplateLiteralKind(kind)) { return true; } @@ -49858,7 +51192,7 @@ var ts; } ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; function isPunctuation(kind) { - return 15 <= kind && kind <= 68; + return 16 <= kind && kind <= 69; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position) { @@ -49868,9 +51202,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 112: - case 110: + case 113: case 111: + case 112: return true; } return false; @@ -49893,14 +51227,14 @@ var ts; } ts.compareDataObjects = compareDataObjects; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 170 || - node.kind === 171) { - if (node.parent.kind === 187 && + if (node.kind === 171 || + node.kind === 172) { + if (node.parent.kind === 188 && node.parent.left === node && - node.parent.operatorToken.kind === 56) { + node.parent.operatorToken.kind === 57) { return true; } - if (node.parent.kind === 208 && + if (node.parent.kind === 209 && node.parent.initializer === node) { return true; } @@ -49935,7 +51269,7 @@ var ts; })(ts || (ts = {})); (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 142; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 143; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -49988,7 +51322,7 @@ var ts; } } function symbolPart(text, symbol) { - return displayPart(text, displayPartKind(symbol), symbol); + return displayPart(text, displayPartKind(symbol)); function displayPartKind(symbol) { var flags = symbol.flags; if (flags & 3) { @@ -50037,7 +51371,7 @@ var ts; } } ts.symbolPart = symbolPart; - function displayPart(text, kind, symbol) { + function displayPart(text, kind) { return { text: text, kind: ts.SymbolDisplayPartKind[kind] @@ -50110,7 +51444,7 @@ var ts; return location.getText(); } else if (ts.isStringOrNumericLiteral(location.kind) && - location.parent.kind === 140) { + location.parent.kind === 141) { return location.text; } var localExportDefaultSymbol = ts.getLocalSymbolForExportDefault(symbol); @@ -50120,7 +51454,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 234 || location.parent.kind === 238) && + (location.parent.kind === 235 || location.parent.kind === 239) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -50225,157 +51559,157 @@ var ts; function spanInNode(node) { if (node) { switch (node.kind) { - case 200: + case 201: return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 218: - case 145: - case 144: - return spanInVariableDeclaration(node); - case 142: - return spanInParameterDeclaration(node); - case 220: - case 147: + case 219: case 146: - case 149: - case 150: + case 145: + return spanInVariableDeclaration(node); + case 143: + return spanInParameterDeclaration(node); + case 221: case 148: - case 179: + case 147: + case 150: + case 151: + case 149: case 180: + case 181: return spanInFunctionDeclaration(node); - case 199: + case 200: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } - case 226: + case 227: return spanInBlock(node); case 252: return spanInBlock(node.block); - case 202: - return textSpan(node.expression); - case 211: - return textSpan(node.getChildAt(0), node.expression); - case 205: - return textSpanEndingAtNextToken(node, node.expression); - case 204: - return spanInNode(node.statement); - case 217: - return textSpan(node.getChildAt(0)); case 203: - return textSpanEndingAtNextToken(node, node.expression); - case 214: - return spanInNode(node.statement); - case 210: - case 209: - return textSpan(node.getChildAt(0), node.label); + return textSpan(node.expression); + case 212: + return textSpan(node.getChildAt(0), node.expression); case 206: - return spanInForStatement(node); - case 207: return textSpanEndingAtNextToken(node, node.expression); + case 205: + return spanInNode(node.statement); + case 218: + return textSpan(node.getChildAt(0)); + case 204: + return textSpanEndingAtNextToken(node, node.expression); + case 215: + return spanInNode(node.statement); + case 211: + case 210: + return textSpan(node.getChildAt(0), node.label); + case 207: + return spanInForStatement(node); case 208: + return textSpanEndingAtNextToken(node, node.expression); + case 209: return spanInInitializerOfForLike(node); - case 213: + case 214: return textSpanEndingAtNextToken(node, node.expression); case 249: case 250: return spanInNode(node.statements[0]); - case 216: + case 217: return spanInBlock(node.tryBlock); - case 215: + case 216: return textSpan(node, node.expression); - case 235: - return textSpan(node, node.expression); - case 229: - return textSpan(node, node.moduleReference); - case 230: - return textSpan(node, node.moduleSpecifier); case 236: + return textSpan(node, node.expression); + case 230: + return textSpan(node, node.moduleReference); + case 231: return textSpan(node, node.moduleSpecifier); - case 225: + case 237: + return textSpan(node, node.moduleSpecifier); + case 226: if (ts.getModuleInstanceState(node) !== 1) { return undefined; } - case 221: - case 224: - case 255: - case 169: - return textSpan(node); - case 212: - return spanInNode(node.statement); - case 143: - return spanInNodeArray(node.parent.decorators); - case 167: - case 168: - return spanInBindingPattern(node); case 222: + case 225: + case 255: + case 170: + return textSpan(node); + case 213: + return spanInNode(node.statement); + case 144: + return spanInNodeArray(node.parent.decorators); + case 168: + case 169: + return spanInBindingPattern(node); case 223: + case 224: return undefined; - case 23: + case 24: case 1: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile)); - case 24: - return spanInPreviousNode(node); - case 15: - return spanInOpenBraceToken(node); - case 16: - return spanInCloseBraceToken(node); - case 20: - return spanInCloseBracketToken(node); - case 17: - return spanInOpenParenToken(node); - case 18: - return spanInCloseParenToken(node); - case 54: - return spanInColonToken(node); - case 27: case 25: + return spanInPreviousNode(node); + case 16: + return spanInOpenBraceToken(node); + case 17: + return spanInCloseBraceToken(node); + case 21: + return spanInCloseBracketToken(node); + case 18: + return spanInOpenParenToken(node); + case 19: + return spanInCloseParenToken(node); + case 55: + return spanInColonToken(node); + case 28: + case 26: return spanInGreaterThanOrLessThanToken(node); - case 104: + case 105: return spanInWhileKeyword(node); - case 80: - case 72: - case 85: + case 81: + case 73: + case 86: return spanInNextNode(node); - case 138: + case 139: return spanInOfKeyword(node); default: if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(node); } - if ((node.kind === 69 || - node.kind == 191 || + if ((node.kind === 70 || + node.kind == 192 || node.kind === 253 || node.kind === 254) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { return textSpan(node); } - if (node.kind === 187) { + if (node.kind === 188) { var binaryExpression = node; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left); } - if (binaryExpression.operatorToken.kind === 56 && + if (binaryExpression.operatorToken.kind === 57 && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.parent)) { return textSpan(node); } - if (binaryExpression.operatorToken.kind === 24) { + if (binaryExpression.operatorToken.kind === 25) { return spanInNode(binaryExpression.left); } } if (ts.isPartOfExpression(node)) { switch (node.parent.kind) { - case 204: + case 205: return spanInPreviousNode(node); - case 143: + case 144: return spanInNode(node.parent); - case 206: - case 208: + case 207: + case 209: return textSpan(node); - case 187: - if (node.parent.operatorToken.kind === 24) { + case 188: + if (node.parent.operatorToken.kind === 25) { return textSpan(node); } break; - case 180: + case 181: if (node.parent.body === node) { return textSpan(node); } @@ -50387,14 +51721,14 @@ var ts; !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); } - if (node.parent.kind === 177 && node.parent.type === node) { + if (node.parent.kind === 178 && node.parent.type === node) { return spanInNextNode(node.parent.type); } if (ts.isFunctionLike(node.parent) && node.parent.type === node) { return spanInPreviousNode(node); } - if ((node.parent.kind === 218 || - node.parent.kind === 142)) { + if ((node.parent.kind === 219 || + node.parent.kind === 143)) { var paramOrVarDecl = node.parent; if (paramOrVarDecl.initializer === node || paramOrVarDecl.type === node || @@ -50402,7 +51736,7 @@ var ts; return spanInPreviousNode(node); } } - if (node.parent.kind === 187) { + if (node.parent.kind === 188) { var binaryExpression = node.parent; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left) && (binaryExpression.right === node || @@ -50423,7 +51757,7 @@ var ts; } } function spanInVariableDeclaration(variableDeclaration) { - if (variableDeclaration.parent.parent.kind === 207) { + if (variableDeclaration.parent.parent.kind === 208) { return spanInNode(variableDeclaration.parent.parent); } if (ts.isBindingPattern(variableDeclaration.name)) { @@ -50431,7 +51765,7 @@ var ts; } if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1) || - variableDeclaration.parent.parent.kind === 208) { + variableDeclaration.parent.parent.kind === 209) { return textSpanFromVariableDeclaration(variableDeclaration); } var declarations = variableDeclaration.parent.declarations; @@ -50463,7 +51797,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1) || - (functionDeclaration.parent.kind === 221 && functionDeclaration.kind !== 148); + (functionDeclaration.parent.kind === 222 && functionDeclaration.kind !== 149); } function spanInFunctionDeclaration(functionDeclaration) { if (!functionDeclaration.body) { @@ -50483,22 +51817,22 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 225: + case 226: if (ts.getModuleInstanceState(block.parent) !== 1) { return undefined; } - case 205: - case 203: - case 207: - return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); case 206: + case 204: case 208: + return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); + case 207: + case 209: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } return spanInNode(block.statements[0]); } function spanInInitializerOfForLike(forLikeStatement) { - if (forLikeStatement.initializer.kind === 219) { + if (forLikeStatement.initializer.kind === 220) { var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -50520,62 +51854,62 @@ var ts; } } function spanInBindingPattern(bindingPattern) { - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 193 ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 194 ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } - if (bindingPattern.parent.kind === 169) { + if (bindingPattern.parent.kind === 170) { return textSpan(bindingPattern.parent); } return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 168 && node.kind !== 167); - var elements = node.kind === 170 ? + ts.Debug.assert(node.kind !== 169 && node.kind !== 168); + var elements = node.kind === 171 ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 193 ? element : undefined; }); + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 194 ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } - return textSpan(node.parent.kind === 187 ? node.parent : node); + return textSpan(node.parent.kind === 188 ? node.parent : node); } function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 224: + case 225: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 221: + case 222: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 227: + case 228: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } return spanInNode(node.parent); } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 226: + case 227: if (ts.getModuleInstanceState(node.parent.parent) !== 1) { return undefined; } - case 224: - case 221: + case 225: + case 222: return textSpan(node); - case 199: + case 200: if (ts.isFunctionBlock(node.parent)) { return textSpan(node); } case 252: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 227: + case 228: var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); if (lastClause) { return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 167: + case 168: var bindingPattern = node.parent; return spanInNode(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); default: @@ -50588,7 +51922,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 168: + case 169: var bindingPattern = node.parent; return textSpan(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); default: @@ -50600,33 +51934,33 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 204 || - node.parent.kind === 174 || - node.parent.kind === 175) { + if (node.parent.kind === 205 || + node.parent.kind === 175 || + node.parent.kind === 176) { return spanInPreviousNode(node); } - if (node.parent.kind === 178) { + if (node.parent.kind === 179) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInCloseParenToken(node) { switch (node.parent.kind) { - case 179: - case 220: case 180: - case 147: - case 146: - case 149: - case 150: + case 221: + case 181: case 148: - case 205: - case 204: + case 147: + case 150: + case 151: + case 149: case 206: - case 208: - case 174: + case 205: + case 207: + case 209: case 175: - case 178: + case 176: + case 179: return spanInPreviousNode(node); default: return spanInNode(node.parent); @@ -50635,25 +51969,25 @@ var ts; function spanInColonToken(node) { if (ts.isFunctionLike(node.parent) || node.parent.kind === 253 || - node.parent.kind === 142) { + node.parent.kind === 143) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 177) { + if (node.parent.kind === 178) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 204) { + if (node.parent.kind === 205) { return textSpanEndingAtNextToken(node, node.parent.expression); } return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 208) { + if (node.parent.kind === 209) { return spanInNextNode(node); } return spanInNode(node.parent); @@ -50666,27 +52000,27 @@ var ts; var ts; (function (ts) { function createClassifier() { - var scanner = ts.createScanner(2, false); + var scanner = ts.createScanner(4, false); var noRegexTable = []; - noRegexTable[69] = true; + noRegexTable[70] = true; noRegexTable[9] = true; noRegexTable[8] = true; - noRegexTable[10] = true; - noRegexTable[97] = true; - noRegexTable[41] = true; + noRegexTable[11] = true; + noRegexTable[98] = true; noRegexTable[42] = true; - noRegexTable[18] = true; - noRegexTable[20] = true; - noRegexTable[16] = true; - noRegexTable[99] = true; - noRegexTable[84] = true; + noRegexTable[43] = true; + noRegexTable[19] = true; + noRegexTable[21] = true; + noRegexTable[17] = true; + noRegexTable[100] = true; + noRegexTable[85] = true; var templateStack = []; function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { - if (keyword2 === 123 || - keyword2 === 131 || - keyword2 === 121 || - keyword2 === 113) { + if (keyword2 === 124 || + keyword2 === 132 || + keyword2 === 122 || + keyword2 === 114) { return true; } return false; @@ -50769,7 +52103,7 @@ var ts; text = "}\n" + text; offset = 2; case 6: - templateStack.push(12); + templateStack.push(13); break; } scanner.setText(text); @@ -50781,55 +52115,55 @@ var ts; do { token = scanner.scan(); if (!ts.isTrivia(token)) { - if ((token === 39 || token === 61) && !noRegexTable[lastNonTriviaToken]) { - if (scanner.reScanSlashToken() === 10) { - token = 10; + if ((token === 40 || token === 62) && !noRegexTable[lastNonTriviaToken]) { + if (scanner.reScanSlashToken() === 11) { + token = 11; } } - else if (lastNonTriviaToken === 21 && isKeyword(token)) { - token = 69; + else if (lastNonTriviaToken === 22 && isKeyword(token)) { + token = 70; } else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { - token = 69; + token = 70; } - else if (lastNonTriviaToken === 69 && - token === 25) { + else if (lastNonTriviaToken === 70 && + token === 26) { angleBracketStack++; } - else if (token === 27 && angleBracketStack > 0) { + else if (token === 28 && angleBracketStack > 0) { angleBracketStack--; } - else if (token === 117 || - token === 132 || - token === 130 || - token === 120 || - token === 133) { + else if (token === 118 || + token === 133 || + token === 131 || + token === 121 || + token === 134) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { - token = 69; + token = 70; } } - else if (token === 12) { + else if (token === 13) { templateStack.push(token); } - else if (token === 15) { + else if (token === 16) { if (templateStack.length > 0) { templateStack.push(token); } } - else if (token === 16) { + else if (token === 17) { if (templateStack.length > 0) { var lastTemplateStackToken = ts.lastOrUndefined(templateStack); - if (lastTemplateStackToken === 12) { + if (lastTemplateStackToken === 13) { token = scanner.reScanTemplateToken(); - if (token === 14) { + if (token === 15) { templateStack.pop(); } else { - ts.Debug.assert(token === 13, "Should have been a template middle. Was " + token); + ts.Debug.assert(token === 14, "Should have been a template middle. Was " + token); } } else { - ts.Debug.assert(lastTemplateStackToken === 15, "Should have been an open brace. Was: " + token); + ts.Debug.assert(lastTemplateStackToken === 16, "Should have been an open brace. Was: " + token); templateStack.pop(); } } @@ -50867,10 +52201,10 @@ var ts; } else if (ts.isTemplateLiteralKind(token)) { if (scanner.isUnterminated()) { - if (token === 14) { + if (token === 15) { result.endOfLineState = 5; } - else if (token === 11) { + else if (token === 12) { result.endOfLineState = 4; } else { @@ -50878,7 +52212,7 @@ var ts; } } } - else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 12) { + else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 13) { result.endOfLineState = 6; } } @@ -50902,43 +52236,43 @@ var ts; } function isBinaryExpressionOperatorToken(token) { switch (token) { - case 37: - case 39: + case 38: case 40: - case 35: + case 41: case 36: - case 43: + case 37: case 44: case 45: - case 25: - case 27: + case 46: + case 26: case 28: case 29: - case 91: - case 90: - case 116: case 30: + case 92: + case 91: + case 117: case 31: case 32: case 33: - case 46: - case 48: + case 34: case 47: - case 51: + case 49: + case 48: case 52: - case 67: - case 66: + case 53: case 68: - case 63: + case 67: + case 69: case 64: case 65: - case 57: + case 66: case 58: case 59: - case 61: + case 60: case 62: - case 56: - case 24: + case 63: + case 57: + case 25: return true; default: return false; @@ -50946,19 +52280,19 @@ var ts; } function isPrefixUnaryExpressionOperatorToken(token) { switch (token) { - case 35: case 36: + case 37: + case 51: case 50: - case 49: - case 41: case 42: + case 43: return true; default: return false; } } function isKeyword(token) { - return token >= 70 && token <= 138; + return token >= 71 && token <= 139; } function classFromKind(token) { if (isKeyword(token)) { @@ -50967,7 +52301,7 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5; } - else if (token >= 15 && token <= 68) { + else if (token >= 16 && token <= 69) { return 10; } switch (token) { @@ -50975,7 +52309,7 @@ var ts; return 4; case 9: return 6; - case 10: + case 11: return 7; case 7: case 3: @@ -50984,7 +52318,7 @@ var ts; case 5: case 4: return 8; - case 69: + case 70: default: if (ts.isTemplateLiteralKind(token)) { return 6; @@ -51004,10 +52338,10 @@ var ts; ts.getSemanticClassifications = getSemanticClassifications; function checkForClassificationCancellation(cancellationToken, kind) { switch (kind) { - case 225: - case 221: + case 226: case 222: - case 220: + case 223: + case 221: cancellationToken.throwIfCancellationRequested(); } } @@ -51051,7 +52385,7 @@ var ts; return undefined; function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 225 && + return declaration.kind === 226 && ts.getModuleInstanceState(declaration) === 1; }); } @@ -51060,7 +52394,7 @@ var ts; if (node && ts.textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { var kind = node.kind; checkForClassificationCancellation(cancellationToken, kind); - if (kind === 69 && !ts.nodeIsMissing(node)) { + if (kind === 70 && !ts.nodeIsMissing(node)) { var identifier = node; if (classifiableNames[identifier.text]) { var symbol = typeChecker.getSymbolAtLocation(node); @@ -51123,8 +52457,8 @@ var ts; function getEncodedSyntacticClassifications(cancellationToken, sourceFile, span) { var spanStart = span.start; var spanLength = span.length; - var triviaScanner = ts.createScanner(2, false, sourceFile.languageVariant, sourceFile.text); - var mergeConflictScanner = ts.createScanner(2, false, sourceFile.languageVariant, sourceFile.text); + var triviaScanner = ts.createScanner(4, false, sourceFile.languageVariant, sourceFile.text); + var mergeConflictScanner = ts.createScanner(4, false, sourceFile.languageVariant, sourceFile.text); var result = []; processElement(sourceFile); return { spans: result, endOfLineState: 0 }; @@ -51266,10 +52600,10 @@ var ts; return true; } var classifiedElementName = tryClassifyJsxElementName(node); - if (!ts.isToken(node) && node.kind !== 244 && classifiedElementName === undefined) { + if (!ts.isToken(node) && node.kind !== 10 && classifiedElementName === undefined) { return false; } - var tokenStart = node.kind === 244 ? node.pos : classifyLeadingTriviaAndGetTokenStart(node); + var tokenStart = node.kind === 10 ? node.pos : classifyLeadingTriviaAndGetTokenStart(node); var tokenWidth = node.end - tokenStart; ts.Debug.assert(tokenWidth >= 0); if (tokenWidth > 0) { @@ -51282,7 +52616,7 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 243: + case 244: if (token.parent.tagName === token) { return 19; } @@ -51292,7 +52626,7 @@ var ts; return 20; } break; - case 242: + case 243: if (token.parent.tagName === token) { return 21; } @@ -51309,25 +52643,25 @@ var ts; if (ts.isKeyword(tokenKind)) { return 3; } - if (tokenKind === 25 || tokenKind === 27) { + if (tokenKind === 26 || tokenKind === 28) { if (token && ts.getTypeArgumentOrTypeParameterList(token.parent)) { return 10; } } if (ts.isPunctuation(tokenKind)) { if (token) { - if (tokenKind === 56) { - if (token.parent.kind === 218 || - token.parent.kind === 145 || - token.parent.kind === 142 || + if (tokenKind === 57) { + if (token.parent.kind === 219 || + token.parent.kind === 146 || + token.parent.kind === 143 || token.parent.kind === 246) { return 5; } } - if (token.parent.kind === 187 || - token.parent.kind === 185 || + if (token.parent.kind === 188 || token.parent.kind === 186 || - token.parent.kind === 188) { + token.parent.kind === 187 || + token.parent.kind === 189) { return 5; } } @@ -51339,44 +52673,44 @@ var ts; else if (tokenKind === 9) { return token.parent.kind === 246 ? 24 : 6; } - else if (tokenKind === 10) { + else if (tokenKind === 11) { return 6; } else if (ts.isTemplateLiteralKind(tokenKind)) { return 6; } - else if (tokenKind === 244) { + else if (tokenKind === 10) { return 23; } - else if (tokenKind === 69) { + else if (tokenKind === 70) { if (token) { switch (token.parent.kind) { - case 221: + case 222: if (token.parent.name === token) { return 11; } return; - case 141: + case 142: if (token.parent.name === token) { return 15; } return; - case 222: + case 223: if (token.parent.name === token) { return 13; } return; - case 224: + case 225: if (token.parent.name === token) { return 12; } return; - case 225: + case 226: if (token.parent.name === token) { return 14; } return; - case 142: + case 143: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 : 17; } @@ -51437,7 +52771,7 @@ var ts; name: tagName.text, kind: undefined, kindModifiers: undefined, - sortText: "0" + sortText: "0", }); } else { @@ -51453,13 +52787,13 @@ var ts; function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames) { var entries = []; var nameTable = ts.getNameTable(sourceFile); - for (var name_47 in nameTable) { - if (nameTable[name_47] === position) { + for (var name_46 in nameTable) { + if (nameTable[name_46] === position) { continue; } - if (!uniqueNames[name_47]) { - uniqueNames[name_47] = name_47; - var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_47), compilerOptions.target, true); + if (!uniqueNames[name_46]) { + uniqueNames[name_46] = name_46; + var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_46), compilerOptions.target, true); if (displayName) { var entry = { name: displayName, @@ -51482,7 +52816,7 @@ var ts; name: displayName, kind: ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location), kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), - sortText: "0" + sortText: "0", }; } function getCompletionEntriesFromSymbols(symbols, entries, location, performCharacterChecks) { @@ -51510,20 +52844,20 @@ var ts; return undefined; } if (node.parent.kind === 253 && - node.parent.parent.kind === 171 && + node.parent.parent.kind === 172 && node.parent.name === node) { return getStringLiteralCompletionEntriesFromPropertyAssignment(node.parent); } else if (ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node) { return getStringLiteralCompletionEntriesFromElementAccess(node.parent); } - else if (node.parent.kind === 230 || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { + else if (node.parent.kind === 231 || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { return getStringLiteralCompletionEntriesFromModuleNames(node); } else { var argumentInfo = ts.SignatureHelp.getContainingArgumentInfo(node, position, sourceFile); if (argumentInfo) { - return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo, node); + return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo); } return getStringLiteralCompletionEntriesFromContextualType(node); } @@ -51538,7 +52872,7 @@ var ts; } } } - function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo, location) { + function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo) { var candidates = []; var entries = []; typeChecker.getResolvedSignature(argumentInfo.invocation, candidates); @@ -51848,7 +53182,7 @@ var ts; if (typeRoots) { for (var _b = 0, typeRoots_2 = typeRoots; _b < typeRoots_2.length; _b++) { var root = typeRoots_2[_b]; - getCompletionEntriesFromDirectories(host, options, root, span, result); + getCompletionEntriesFromDirectories(host, root, span, result); } } } @@ -51856,12 +53190,12 @@ var ts; for (var _c = 0, _d = findPackageJsons(scriptPath); _c < _d.length; _c++) { var packageJson = _d[_c]; var typesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules/@types"); - getCompletionEntriesFromDirectories(host, options, typesDir, span, result); + getCompletionEntriesFromDirectories(host, typesDir, span, result); } } return result; } - function getCompletionEntriesFromDirectories(host, options, directory, span, result) { + function getCompletionEntriesFromDirectories(host, directory, span, result) { if (host.getDirectories && tryDirectoryExists(host, directory)) { var directories = tryGetDirectories(host, directory); if (directories) { @@ -52055,12 +53389,12 @@ var ts; return undefined; } var parent_17 = contextToken.parent, kind = contextToken.kind; - if (kind === 21) { - if (parent_17.kind === 172) { + if (kind === 22) { + if (parent_17.kind === 173) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_17.kind === 139) { + else if (parent_17.kind === 140) { node = contextToken.parent.left; isRightOfDot = true; } @@ -52069,11 +53403,11 @@ var ts; } } else if (sourceFile.languageVariant === 1) { - if (kind === 25) { + if (kind === 26) { isRightOfOpenTag = true; location = contextToken; } - else if (kind === 39 && contextToken.parent.kind === 245) { + else if (kind === 40 && contextToken.parent.kind === 245) { isStartingCloseTag = true; location = contextToken; } @@ -52111,7 +53445,6 @@ var ts; if (!tryGetGlobalSymbols()) { return undefined; } - isGlobalCompletion = true; } log("getCompletionData: Semantic work: " + (ts.timestamp() - semanticStart)); return { symbols: symbols, isGlobalCompletion: isGlobalCompletion, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName: isJsDocTagName }; @@ -52119,7 +53452,7 @@ var ts; isGlobalCompletion = false; isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 69 || node.kind === 139 || node.kind === 172) { + if (node.kind === 70 || node.kind === 140 || node.kind === 173) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol && symbol.flags & 8388608) { symbol = typeChecker.getAliasedSymbol(symbol); @@ -52165,9 +53498,8 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType = void 0; - if ((jsxContainer.kind === 242) || (jsxContainer.kind === 243)) { + if ((jsxContainer.kind === 243) || (jsxContainer.kind === 244)) { attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); - isGlobalCompletion = false; if (attrsType) { symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); isMemberCompletion = true; @@ -52185,6 +53517,13 @@ var ts; previousToken.getStart() : position; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; + if (scopeNode) { + isGlobalCompletion = + scopeNode.kind === 256 || + scopeNode.kind === 190 || + scopeNode.kind === 248 || + ts.isStatement(scopeNode); + } var symbolMeanings = 793064 | 107455 | 1920 | 8388608; symbols = typeChecker.getSymbolsInScope(scopeNode, symbolMeanings); return true; @@ -52206,15 +53545,15 @@ var ts; return result; } function isInJsxText(contextToken) { - if (contextToken.kind === 244) { + if (contextToken.kind === 10) { return true; } - if (contextToken.kind === 27 && contextToken.parent) { - if (contextToken.parent.kind === 243) { + if (contextToken.kind === 28 && contextToken.parent) { + if (contextToken.parent.kind === 244) { return true; } - if (contextToken.parent.kind === 245 || contextToken.parent.kind === 242) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 241; + if (contextToken.parent.kind === 245 || contextToken.parent.kind === 243) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 242; } } return false; @@ -52223,41 +53562,41 @@ var ts; if (previousToken) { var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { - case 24: - return containingNodeKind === 174 - || containingNodeKind === 148 - || containingNodeKind === 175 - || containingNodeKind === 170 - || containingNodeKind === 187 - || containingNodeKind === 156; - case 17: - return containingNodeKind === 174 - || containingNodeKind === 148 - || containingNodeKind === 175 - || containingNodeKind === 178 - || containingNodeKind === 164; - case 19: - return containingNodeKind === 170 - || containingNodeKind === 153 - || containingNodeKind === 140; - case 125: + case 25: + return containingNodeKind === 175 + || containingNodeKind === 149 + || containingNodeKind === 176 + || containingNodeKind === 171 + || containingNodeKind === 188 + || containingNodeKind === 157; + case 18: + return containingNodeKind === 175 + || containingNodeKind === 149 + || containingNodeKind === 176 + || containingNodeKind === 179 + || containingNodeKind === 165; + case 20: + return containingNodeKind === 171 + || containingNodeKind === 154 + || containingNodeKind === 141; case 126: + case 127: return true; - case 21: - return containingNodeKind === 225; - case 15: - return containingNodeKind === 221; - case 56: - return containingNodeKind === 218 - || containingNodeKind === 187; - case 12: - return containingNodeKind === 189; + case 22: + return containingNodeKind === 226; + case 16: + return containingNodeKind === 222; + case 57: + return containingNodeKind === 219 + || containingNodeKind === 188; case 13: - return containingNodeKind === 197; - case 112: - case 110: + return containingNodeKind === 190; + case 14: + return containingNodeKind === 198; + case 113: case 111: - return containingNodeKind === 145; + case 112: + return containingNodeKind === 146; } switch (previousToken.getText()) { case "public": @@ -52270,7 +53609,7 @@ var ts; } function isInStringOrRegularExpressionOrTemplateLiteral(contextToken) { if (contextToken.kind === 9 - || contextToken.kind === 10 + || contextToken.kind === 11 || ts.isTemplateLiteralKind(contextToken.kind)) { var start_3 = contextToken.getStart(); var end = contextToken.getEnd(); @@ -52279,7 +53618,7 @@ var ts; } if (position === end) { return !!contextToken.isUnterminated - || contextToken.kind === 10; + || contextToken.kind === 11; } } return false; @@ -52288,22 +53627,22 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 171) { + if (objectLikeContainer.kind === 172) { isNewIdentifierLocation = true; typeForObject = typeChecker.getContextualType(objectLikeContainer); typeForObject = typeForObject && typeForObject.getNonNullableType(); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 167) { + else if (objectLikeContainer.kind === 168) { isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); if (ts.isVariableLike(rootDeclaration)) { var canGetType = !!(rootDeclaration.initializer || rootDeclaration.type); - if (!canGetType && rootDeclaration.kind === 142) { + if (!canGetType && rootDeclaration.kind === 143) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 147 || rootDeclaration.parent.kind === 150) { + else if (rootDeclaration.parent.kind === 148 || rootDeclaration.parent.kind === 151) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -52329,9 +53668,9 @@ var ts; return true; } function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 233 ? - 230 : - 236; + var declarationKind = namedImportsOrExports.kind === 234 ? + 231 : + 237; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -52350,10 +53689,10 @@ var ts; function tryGetObjectLikeCompletionContainer(contextToken) { if (contextToken) { switch (contextToken.kind) { - case 15: - case 24: + case 16: + case 25: var parent_18 = contextToken.parent; - if (parent_18 && (parent_18.kind === 171 || parent_18.kind === 167)) { + if (parent_18 && (parent_18.kind === 172 || parent_18.kind === 168)) { return parent_18; } break; @@ -52364,11 +53703,11 @@ var ts; function tryGetNamedImportsOrExportsForCompletion(contextToken) { if (contextToken) { switch (contextToken.kind) { - case 15: - case 24: + case 16: + case 25: switch (contextToken.parent.kind) { - case 233: - case 237: + case 234: + case 238: return contextToken.parent; } } @@ -52379,12 +53718,12 @@ var ts; if (contextToken) { var parent_19 = contextToken.parent; switch (contextToken.kind) { - case 26: - case 39: - case 69: + case 27: + case 40: + case 70: case 246: case 247: - if (parent_19 && (parent_19.kind === 242 || parent_19.kind === 243)) { + if (parent_19 && (parent_19.kind === 243 || parent_19.kind === 244)) { return parent_19; } else if (parent_19.kind === 246) { @@ -52396,7 +53735,7 @@ var ts; return parent_19.parent; } break; - case 16: + case 17: if (parent_19 && parent_19.kind === 248 && parent_19.parent && @@ -52413,16 +53752,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 179: case 180: - case 220: + case 181: + case 221: + case 148: case 147: - case 146: - case 149: case 150: case 151: case 152: case 153: + case 154: return true; } return false; @@ -52430,67 +53769,67 @@ var ts; function isSolelyIdentifierDefinitionLocation(contextToken) { var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { - case 24: - return containingNodeKind === 218 || - containingNodeKind === 219 || - containingNodeKind === 200 || - containingNodeKind === 224 || + case 25: + return containingNodeKind === 219 || + containingNodeKind === 220 || + containingNodeKind === 201 || + containingNodeKind === 225 || isFunction(containingNodeKind) || - containingNodeKind === 221 || - containingNodeKind === 192 || containingNodeKind === 222 || - containingNodeKind === 168 || - containingNodeKind === 223; - case 21: - return containingNodeKind === 168; - case 54: + containingNodeKind === 193 || + containingNodeKind === 223 || + containingNodeKind === 169 || + containingNodeKind === 224; + case 22: return containingNodeKind === 169; - case 19: - return containingNodeKind === 168; - case 17: + case 55: + return containingNodeKind === 170; + case 20: + return containingNodeKind === 169; + case 18: return containingNodeKind === 252 || isFunction(containingNodeKind); - case 15: - return containingNodeKind === 224 || - containingNodeKind === 222 || - containingNodeKind === 159; - case 23: - return containingNodeKind === 144 && - contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 222 || - contextToken.parent.parent.kind === 159); - case 25: - return containingNodeKind === 221 || - containingNodeKind === 192 || - containingNodeKind === 222 || + case 16: + return containingNodeKind === 225 || containingNodeKind === 223 || + containingNodeKind === 160; + case 24: + return containingNodeKind === 145 && + contextToken.parent && contextToken.parent.parent && + (contextToken.parent.parent.kind === 223 || + contextToken.parent.parent.kind === 160); + case 26: + return containingNodeKind === 222 || + containingNodeKind === 193 || + containingNodeKind === 223 || + containingNodeKind === 224 || isFunction(containingNodeKind); - case 113: - return containingNodeKind === 145; - case 22: - return containingNodeKind === 142 || - (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 168); - case 112: - case 110: - case 111: - return containingNodeKind === 142; - case 116: - return containingNodeKind === 234 || - containingNodeKind === 238 || - containingNodeKind === 232; - case 73: - case 81: - case 107: - case 87: - case 102: - case 123: - case 131: - case 89: - case 108: - case 74: case 114: - case 134: + return containingNodeKind === 146; + case 23: + return containingNodeKind === 143 || + (contextToken.parent && contextToken.parent.parent && + contextToken.parent.parent.kind === 169); + case 113: + case 111: + case 112: + return containingNodeKind === 143; + case 117: + return containingNodeKind === 235 || + containingNodeKind === 239 || + containingNodeKind === 233; + case 74: + case 82: + case 108: + case 88: + case 103: + case 124: + case 132: + case 90: + case 109: + case 75: + case 115: + case 135: return true; } switch (contextToken.getText()) { @@ -52527,8 +53866,8 @@ var ts; if (element.getStart() <= position && position <= element.getEnd()) { continue; } - var name_48 = element.propertyName || element.name; - existingImportsOrExports[name_48.text] = true; + var name_47 = element.propertyName || element.name; + existingImportsOrExports[name_47.text] = true; } if (!ts.someProperties(existingImportsOrExports)) { return ts.filter(exportsOfModule, function (e) { return e.name !== "default"; }); @@ -52544,16 +53883,16 @@ var ts; var m = existingMembers_1[_i]; if (m.kind !== 253 && m.kind !== 254 && - m.kind !== 169 && - m.kind !== 147) { + m.kind !== 170 && + m.kind !== 148) { continue; } if (m.getStart() <= position && position <= m.getEnd()) { continue; } var existingName = void 0; - if (m.kind === 169 && m.propertyName) { - if (m.propertyName.kind === 69) { + if (m.kind === 170 && m.propertyName) { + if (m.propertyName.kind === 70) { existingName = m.propertyName.text; } } @@ -52604,7 +53943,7 @@ var ts; return name; } var keywordCompletions = []; - for (var i = 70; i <= 138; i++) { + for (var i = 71; i <= 139; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ts.ScriptElementKind.keyword, @@ -52666,10 +54005,10 @@ var ts; }; } function getSemanticDocumentHighlights(node) { - if (node.kind === 69 || - node.kind === 97 || - node.kind === 165 || - node.kind === 95 || + if (node.kind === 70 || + node.kind === 98 || + node.kind === 166 || + node.kind === 96 || node.kind === 9 || ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { var referencedSymbols = ts.FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFilesToSearch, false, false, false); @@ -52718,77 +54057,77 @@ var ts; function getHighlightSpans(node) { if (node) { switch (node.kind) { - case 88: - case 80: - if (hasKind(node.parent, 203)) { + case 89: + case 81: + if (hasKind(node.parent, 204)) { return getIfElseOccurrences(node.parent); } break; - case 94: - if (hasKind(node.parent, 211)) { + case 95: + if (hasKind(node.parent, 212)) { return getReturnOccurrences(node.parent); } break; - case 98: - if (hasKind(node.parent, 215)) { + case 99: + if (hasKind(node.parent, 216)) { return getThrowOccurrences(node.parent); } break; - case 72: - if (hasKind(parent(parent(node)), 216)) { + case 73: + if (hasKind(parent(parent(node)), 217)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; - case 100: - case 85: - if (hasKind(parent(node), 216)) { + case 101: + case 86: + if (hasKind(parent(node), 217)) { return getTryCatchFinallyOccurrences(node.parent); } break; - case 96: - if (hasKind(node.parent, 213)) { + case 97: + if (hasKind(node.parent, 214)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; - case 71: - case 77: - if (hasKind(parent(parent(parent(node))), 213)) { + case 72: + case 78: + if (hasKind(parent(parent(parent(node))), 214)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; - case 70: - case 75: - if (hasKind(node.parent, 210) || hasKind(node.parent, 209)) { + case 71: + case 76: + if (hasKind(node.parent, 211) || hasKind(node.parent, 210)) { return getBreakOrContinueStatementOccurrences(node.parent); } break; - case 86: - if (hasKind(node.parent, 206) || - hasKind(node.parent, 207) || - hasKind(node.parent, 208)) { + case 87: + if (hasKind(node.parent, 207) || + hasKind(node.parent, 208) || + hasKind(node.parent, 209)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 104: - case 79: - if (hasKind(node.parent, 205) || hasKind(node.parent, 204)) { + case 105: + case 80: + if (hasKind(node.parent, 206) || hasKind(node.parent, 205)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 121: - if (hasKind(node.parent, 148)) { + case 122: + if (hasKind(node.parent, 149)) { return getConstructorOccurrences(node.parent); } break; - case 123: - case 131: - if (hasKind(node.parent, 149) || hasKind(node.parent, 150)) { + case 124: + case 132: + if (hasKind(node.parent, 150) || hasKind(node.parent, 151)) { return getGetAndSetOccurrences(node.parent); } break; default: if (ts.isModifierKind(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 200)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 201)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -52800,10 +54139,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 215) { + if (node.kind === 216) { statementAccumulator.push(node); } - else if (node.kind === 216) { + else if (node.kind === 217) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -52827,7 +54166,7 @@ var ts; if (ts.isFunctionBlock(parent_20) || parent_20.kind === 256) { return parent_20; } - if (parent_20.kind === 216) { + if (parent_20.kind === 217) { var tryStatement = parent_20; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; @@ -52842,7 +54181,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 210 || node.kind === 209) { + if (node.kind === 211 || node.kind === 210) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -52857,15 +54196,15 @@ var ts; function getBreakOrContinueOwner(statement) { for (var node_1 = statement.parent; node_1; node_1 = node_1.parent) { switch (node_1.kind) { - case 213: - if (statement.kind === 209) { + case 214: + if (statement.kind === 210) { continue; } - case 206: case 207: case 208: + case 209: + case 206: case 205: - case 204: if (!statement.label || isLabeledBy(node_1, statement.label.text)) { return node_1; } @@ -52882,24 +54221,24 @@ var ts; function getModifierOccurrences(modifier, declaration) { var container = declaration.parent; if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 221 || - container.kind === 192 || - (declaration.kind === 142 && hasKind(container, 148)))) { + if (!(container.kind === 222 || + container.kind === 193 || + (declaration.kind === 143 && hasKind(container, 149)))) { return undefined; } } - else if (modifier === 113) { - if (!(container.kind === 221 || container.kind === 192)) { + else if (modifier === 114) { + if (!(container.kind === 222 || container.kind === 193)) { return undefined; } } - else if (modifier === 82 || modifier === 122) { - if (!(container.kind === 226 || container.kind === 256)) { + else if (modifier === 83 || modifier === 123) { + if (!(container.kind === 227 || container.kind === 256)) { return undefined; } } - else if (modifier === 115) { - if (!(container.kind === 221 || declaration.kind === 221)) { + else if (modifier === 116) { + if (!(container.kind === 222 || declaration.kind === 222)) { return undefined; } } @@ -52910,7 +54249,7 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 226: + case 227: case 256: if (modifierFlag & 128) { nodes = declaration.members.concat(declaration); @@ -52919,15 +54258,15 @@ var ts; nodes = container.statements; } break; - case 148: + case 149: nodes = container.parameters.concat(container.parent.members); break; - case 221: - case 192: + case 222: + case 193: nodes = container.members; if (modifierFlag & 28) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 148 && member; + return member.kind === 149 && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -52948,19 +54287,19 @@ var ts; return ts.map(keywords, getHighlightSpanForNode); function getFlagFromModifier(modifier) { switch (modifier) { - case 112: - return 4; - case 110: - return 8; - case 111: - return 16; case 113: + return 4; + case 111: + return 8; + case 112: + return 16; + case 114: return 32; - case 82: + case 83: return 1; - case 122: + case 123: return 2; - case 115: + case 116: return 128; default: ts.Debug.fail(); @@ -52980,13 +54319,13 @@ var ts; } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 149); tryPushAccessorKeyword(accessorDeclaration.symbol, 150); + tryPushAccessorKeyword(accessorDeclaration.symbol, 151); 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, 123, 131); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 124, 132); }); } } } @@ -52995,18 +54334,18 @@ var ts; var keywords = []; ts.forEach(declarations, function (declaration) { ts.forEach(declaration.getChildren(), function (token) { - return pushKeywordIf(keywords, token, 121); + return pushKeywordIf(keywords, token, 122); }); }); return ts.map(keywords, getHighlightSpanForNode); } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 86, 104, 79)) { - if (loopNode.kind === 204) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 87, 105, 80)) { + if (loopNode.kind === 205) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 104)) { + if (pushKeywordIf(keywords, loopTokens[i], 105)) { break; } } @@ -53015,7 +54354,7 @@ var ts; var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 70, 75); + pushKeywordIf(keywords, statement.getFirstToken(), 71, 76); } }); return ts.map(keywords, getHighlightSpanForNode); @@ -53024,13 +54363,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 206: case 207: case 208: - case 204: + case 209: case 205: + case 206: return getLoopBreakContinueOccurrences(owner); - case 213: + case 214: return getSwitchCaseDefaultOccurrences(owner); } } @@ -53038,13 +54377,13 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 96); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 97); ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 71, 77); + pushKeywordIf(keywords, clause.getFirstToken(), 72, 78); var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 70); + pushKeywordIf(keywords, statement.getFirstToken(), 71); } }); }); @@ -53052,13 +54391,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 100); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 101); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 72); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 73); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 85, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 85); + var finallyKeyword = ts.findChildOfKind(tryStatement, 86, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 86); } return ts.map(keywords, getHighlightSpanForNode); } @@ -53069,50 +54408,50 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 98); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 99); }); if (ts.isFunctionBlock(owner)) { ts.forEachReturnStatement(owner, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 94); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 95); }); } return ts.map(keywords, getHighlightSpanForNode); } function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); - if (!(func && hasKind(func.body, 199))) { + if (!(func && hasKind(func.body, 200))) { return undefined; } var keywords = []; ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 94); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 95); }); ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 98); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 99); }); return ts.map(keywords, getHighlightSpanForNode); } function getIfElseOccurrences(ifStatement) { var keywords = []; - while (hasKind(ifStatement.parent, 203) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 204) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } while (ifStatement) { var children = ifStatement.getChildren(); - pushKeywordIf(keywords, children[0], 88); + pushKeywordIf(keywords, children[0], 89); for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 80)) { + if (pushKeywordIf(keywords, children[i], 81)) { break; } } - if (!hasKind(ifStatement.elseStatement, 203)) { + if (!hasKind(ifStatement.elseStatement, 204)) { break; } ifStatement = ifStatement.elseStatement; } var result = []; for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 80 && i < keywords.length - 1) { + if (keywords[i].kind === 81 && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; var shouldCombindElseAndIf = true; @@ -53140,7 +54479,7 @@ var ts; } DocumentHighlights.getDocumentHighlights = getDocumentHighlights; function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 214; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 215; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -53265,9 +54604,9 @@ var ts; if (!ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { break; } - case 69: - case 97: - case 121: + case 70: + case 98: + case 122: case 9: return getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, false); } @@ -53288,7 +54627,7 @@ var ts; if (ts.isThis(node)) { return getReferencesForThisKeyword(node, sourceFiles); } - if (node.kind === 95) { + if (node.kind === 96) { return getReferencesForSuperKeyword(node); } } @@ -53313,7 +54652,7 @@ var ts; getReferencesInNode(scope, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); } else { - var internedName = getInternedName(symbol, node, declarations); + var internedName = getInternedName(symbol, node); for (var _i = 0, sourceFiles_8 = sourceFiles; _i < sourceFiles_8.length; _i++) { var sourceFile = sourceFiles_8[_i]; cancellationToken.throwIfCancellationRequested(); @@ -53344,16 +54683,16 @@ var ts; } function getAliasSymbolForPropertyNameSymbol(symbol, location) { if (symbol.flags & 8388608) { - var defaultImport = ts.getDeclarationOfKind(symbol, 231); + var defaultImport = ts.getDeclarationOfKind(symbol, 232); if (defaultImport) { return typeChecker.getAliasedSymbol(symbol); } - var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 234 || - declaration.kind === 238) ? declaration : undefined; }); + var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 235 || + declaration.kind === 239) ? declaration : undefined; }); if (importOrExportSpecifier && (!importOrExportSpecifier.propertyName || importOrExportSpecifier.propertyName === location)) { - return importOrExportSpecifier.kind === 234 ? + return importOrExportSpecifier.kind === 235 ? typeChecker.getAliasedSymbol(symbol) : typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); } @@ -53368,20 +54707,20 @@ var ts; typeChecker.getPropertySymbolOfDestructuringAssignment(location); } function isObjectBindingPatternElementWithoutPropertyName(symbol) { - var bindingElement = ts.getDeclarationOfKind(symbol, 169); + var bindingElement = ts.getDeclarationOfKind(symbol, 170); return bindingElement && - bindingElement.parent.kind === 167 && + bindingElement.parent.kind === 168 && !bindingElement.propertyName; } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol) { if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { - var bindingElement = ts.getDeclarationOfKind(symbol, 169); + var bindingElement = ts.getDeclarationOfKind(symbol, 170); var typeOfPattern = typeChecker.getTypeAtLocation(bindingElement.parent); return typeOfPattern && typeChecker.getPropertyOfType(typeOfPattern, bindingElement.name.text); } return undefined; } - function getInternedName(symbol, location, declarations) { + function getInternedName(symbol, location) { if (ts.isImportOrExportSpecifierName(location)) { return location.getText(); } @@ -53391,13 +54730,13 @@ var ts; } function getSymbolScope(symbol) { var valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 179 || valueDeclaration.kind === 192)) { + if (valueDeclaration && (valueDeclaration.kind === 180 || valueDeclaration.kind === 193)) { return valueDeclaration; } if (symbol.flags & (4 | 8192)) { var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (ts.getModifierFlags(d) & 8) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 221); + return ts.getAncestor(privateDeclaration, 222); } } if (symbol.flags & 8388608) { @@ -53443,8 +54782,8 @@ var ts; if (position > end) break; var endPosition = position + symbolNameLength; - if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 2)) && - (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 2))) { + if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 4)) && + (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 4))) { positions.push(position); } position = text.indexOf(symbolName, position + symbolNameLength + 1); @@ -53481,7 +54820,7 @@ var ts; function isValidReferencePosition(node, searchSymbolName) { if (node) { switch (node.kind) { - case 69: + case 70: return node.getWidth() === searchSymbolName.length; case 9: if (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || @@ -53531,14 +54870,14 @@ var ts; if (referenceSymbol) { var referenceSymbolDeclaration = referenceSymbol.valueDeclaration; var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); - var relatedSymbol = getRelatedSymbol(searchSymbols_1, referenceSymbol, referenceLocation, searchLocation.kind === 121, parents, inheritsFromCache); + var relatedSymbol = getRelatedSymbol(searchSymbols_1, referenceSymbol, referenceLocation, searchLocation.kind === 122, parents, inheritsFromCache); if (relatedSymbol) { addReferenceToRelatedSymbol(referenceLocation, relatedSymbol); } else if (!(referenceSymbol.flags & 67108864) && searchSymbols_1.indexOf(shorthandValueSymbol) >= 0) { addReferenceToRelatedSymbol(referenceSymbolDeclaration.name, shorthandValueSymbol); } - else if (searchLocation.kind === 121) { + else if (searchLocation.kind === 122) { findAdditionalConstructorReferences(referenceSymbol, referenceLocation); } } @@ -53588,17 +54927,17 @@ var ts; var result = []; for (var _i = 0, _a = classSymbol.members["__constructor"].declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 148); + ts.Debug.assert(decl.kind === 149); var ctrKeyword = decl.getChildAt(0); - ts.Debug.assert(ctrKeyword.kind === 121); + ts.Debug.assert(ctrKeyword.kind === 122); result.push(ctrKeyword); } ts.forEachProperty(classSymbol.exports, function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 147) { + if (decl && decl.kind === 148) { var body = decl.body; if (body) { - forEachDescendantOfKind(body, 97, function (thisKeyword) { + forEachDescendantOfKind(body, 98, function (thisKeyword) { if (ts.isNewExpressionTarget(thisKeyword)) { result.push(thisKeyword); } @@ -53617,10 +54956,10 @@ var ts; var result = []; for (var _i = 0, _a = ctr.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 148); + ts.Debug.assert(decl.kind === 149); var body = decl.body; if (body) { - forEachDescendantOfKind(body, 95, function (node) { + forEachDescendantOfKind(body, 96, function (node) { if (ts.isCallExpressionTarget(node)) { result.push(node); } @@ -53657,7 +54996,7 @@ var ts; if (ts.isDeclarationName(refNode) && isImplementation(refNode.parent)) { result.push(getReferenceEntryFromNode(refNode.parent)); } - else if (refNode.kind === 69) { + else if (refNode.kind === 70) { if (refNode.parent.kind === 254) { getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); } @@ -53673,7 +55012,7 @@ var ts; maybeAdd(getReferenceEntryFromNode(parent_21.initializer)); } else if (ts.isFunctionLike(parent_21) && parent_21.type === containingTypeReference && parent_21.body) { - if (parent_21.body.kind === 199) { + if (parent_21.body.kind === 200) { ts.forEachReturnStatement(parent_21.body, function (returnStatement) { if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); @@ -53720,26 +55059,26 @@ var ts; } function getContainingClassIfInHeritageClause(node) { if (node && node.parent) { - if (node.kind === 194 + if (node.kind === 195 && node.parent.kind === 251 && ts.isClassLike(node.parent.parent)) { return node.parent.parent; } - else if (node.kind === 69 || node.kind === 172) { + else if (node.kind === 70 || node.kind === 173) { return getContainingClassIfInHeritageClause(node.parent); } } return undefined; } function isImplementationExpression(node) { - if (node.kind === 178) { + if (node.kind === 179) { return isImplementationExpression(node.expression); } - return node.kind === 180 || - node.kind === 179 || - node.kind === 171 || - node.kind === 192 || - node.kind === 170; + return node.kind === 181 || + node.kind === 180 || + node.kind === 172 || + node.kind === 193 || + node.kind === 171; } function explicitlyInheritsFrom(child, parent, cachedResults) { var parentIsInterface = parent.getFlags() & 64; @@ -53768,7 +55107,7 @@ var ts; } return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); } - else if (declaration.kind === 222) { + else if (declaration.kind === 223) { if (parentIsInterface) { return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); } @@ -53795,13 +55134,13 @@ var ts; } var staticFlag = 32; switch (searchSpaceNode.kind) { - case 145: - case 144: - case 147: case 146: + case 145: case 148: + case 147: case 149: case 150: + case 151: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; break; @@ -53814,7 +55153,7 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 95) { + if (!node || node.kind !== 96) { return; } var container = ts.getSuperContainer(node, false); @@ -53829,16 +55168,16 @@ var ts; var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); var staticFlag = 32; switch (searchSpaceNode.kind) { + case 148: case 147: - case 146: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } + case 146: case 145: - case 144: - case 148: case 149: case 150: + case 151: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; break; @@ -53846,8 +55185,8 @@ var ts; if (ts.isExternalModule(searchSpaceNode)) { return undefined; } - case 220: - case 179: + case 221: + case 180: break; default: return undefined; @@ -53888,20 +55227,20 @@ var ts; } var container = ts.getThisContainer(node, false); switch (searchSpaceNode.kind) { - case 179: - case 220: + case 180: + case 221: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; + case 148: case 147: - case 146: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 192: - case 221: + case 193: + case 222: if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } @@ -53975,7 +55314,7 @@ var ts; result.push(shorthandValueSymbol); } } - if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 142 && + if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 143 && ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { result = result.concat(typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); } @@ -54006,7 +55345,7 @@ var ts; getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 222) { + else if (declaration.kind === 223) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -54069,7 +55408,7 @@ var ts; }); } function getNameFromObjectLiteralElement(node) { - if (node.name.kind === 140) { + if (node.name.kind === 141) { var nameExpression = node.name.expression; if (ts.isStringOrNumericLiteral(nameExpression.kind)) { return nameExpression.text; @@ -54138,7 +55477,7 @@ var ts; if (node.initializer) { return true; } - else if (node.kind === 218) { + else if (node.kind === 219) { var parentStatement = getParentStatementOfVariableDeclaration(node); return parentStatement && ts.hasModifier(parentStatement, 2); } @@ -54148,18 +55487,18 @@ var ts; } else { switch (node.kind) { - case 221: - case 192: - case 224: + case 222: + case 193: case 225: + case 226: return true; } } return false; } function getParentStatementOfVariableDeclaration(node) { - if (node.parent && node.parent.parent && node.parent.parent.kind === 200) { - ts.Debug.assert(node.parent.kind === 219); + if (node.parent && node.parent.parent && node.parent.parent.kind === 201) { + ts.Debug.assert(node.parent.kind === 220); return node.parent.parent; } } @@ -54192,17 +55531,17 @@ var ts; } FindAllReferences.getReferenceEntryFromNode = getReferenceEntryFromNode; function isWriteAccess(node) { - if (node.kind === 69 && ts.isDeclarationName(node)) { + if (node.kind === 70 && ts.isDeclarationName(node)) { return true; } var parent = node.parent; if (parent) { - if (parent.kind === 186 || parent.kind === 185) { + if (parent.kind === 187 || parent.kind === 186) { return true; } - else if (parent.kind === 187 && parent.left === node) { + else if (parent.kind === 188 && parent.left === node) { var operator = parent.operatorToken.kind; - return 56 <= operator && operator <= 68; + return 57 <= operator && operator <= 69; } } return false; @@ -54219,10 +55558,10 @@ var ts; switch (node.kind) { case 9: case 8: - if (node.parent.kind === 140) { + if (node.parent.kind === 141) { return isObjectLiteralPropertyDeclaration(node.parent.parent) ? node.parent.parent : undefined; } - case 69: + case 70: return isObjectLiteralPropertyDeclaration(node.parent) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -54231,9 +55570,9 @@ var ts; switch (node.kind) { case 253: case 254: - case 147: - case 149: + case 148: case 150: + case 151: return true; } return false; @@ -54290,9 +55629,9 @@ var ts; } if (symbol.flags & 8388608) { var declaration = symbol.declarations[0]; - if (node.kind === 69 && + if (node.kind === 70 && (node.parent === declaration || - (declaration.kind === 234 && declaration.parent && declaration.parent.kind === 233))) { + (declaration.kind === 235 && declaration.parent && declaration.parent.kind === 234))) { symbol = typeChecker.getAliasedSymbol(symbol); } } @@ -54350,7 +55689,7 @@ var ts; } return result; function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) { - if (ts.isNewExpressionTarget(location) || location.kind === 121) { + if (ts.isNewExpressionTarget(location) || location.kind === 122) { if (symbol.flags & 32) { for (var _i = 0, _a = symbol.getDeclarations(); _i < _a.length; _i++) { var declaration = _a[_i]; @@ -54373,8 +55712,8 @@ var ts; var declarations = []; var definition; ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 148) || - (!selectConstructors && (d.kind === 220 || d.kind === 147 || d.kind === 146))) { + if ((selectConstructors && d.kind === 149) || + (!selectConstructors && (d.kind === 221 || d.kind === 148 || d.kind === 147))) { declarations.push(d); if (d.body) definition = d; @@ -54455,7 +55794,7 @@ var ts; ts.FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result); return result.length > 0 ? result : undefined; } - else if (node.kind === 95 || ts.isSuperProperty(node.parent)) { + else if (node.kind === 96 || ts.isSuperProperty(node.parent)) { var symbol = typeChecker.getSymbolAtLocation(node); return symbol.valueDeclaration && [ts.FindAllReferences.getReferenceEntryFromNode(symbol.valueDeclaration)]; } @@ -54519,7 +55858,7 @@ var ts; "version" ]; var jsDocCompletionEntries; - function getJsDocCommentsFromDeclarations(declarations, name, canUseParsedParamTagComments) { + function getJsDocCommentsFromDeclarations(declarations) { var documentationComment = []; forEachUnique(declarations, function (declaration) { var comments = ts.getJSDocComments(declaration, true); @@ -54558,7 +55897,7 @@ var ts; name: tagName, kind: ts.ScriptElementKind.keyword, kindModifiers: "", - sortText: "0" + sortText: "0", }; })); } @@ -54575,16 +55914,16 @@ var ts; var commentOwner; findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 220: - case 147: - case 148: case 221: - case 200: + case 148: + case 149: + case 222: + case 201: break findOwner; case 256: return undefined; - case 225: - if (commentOwner.parent.kind === 225) { + case 226: + if (commentOwner.parent.kind === 226) { return undefined; } break findOwner; @@ -54600,7 +55939,7 @@ var ts; var docParams = ""; for (var i = 0, numParams = parameters.length; i < numParams; i++) { var currentName = parameters[i].name; - var paramName = currentName.kind === 69 ? + var paramName = currentName.kind === 70 ? currentName.text : "param" + i; docParams += indentationStr + " * @param " + paramName + newLine; @@ -54618,7 +55957,7 @@ var ts; if (ts.isFunctionLike(commentOwner)) { return commentOwner.parameters; } - if (commentOwner.kind === 200) { + if (commentOwner.kind === 201) { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; if (varDeclarations.length === 1 && varDeclarations[0].initializer) { @@ -54628,17 +55967,17 @@ var ts; return ts.emptyArray; } function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 178) { + while (rightHandSide.kind === 179) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 179: case 180: + case 181: return rightHandSide.parameters; - case 192: + case 193: for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 148) { + if (member.kind === 149) { return member.parameters; } } @@ -54649,13 +55988,153 @@ var ts; })(JsDoc = ts.JsDoc || (ts.JsDoc = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var JsTyping; + (function (JsTyping) { + ; + ; + var safeList; + var EmptySafeList = ts.createMap(); + function discoverTypings(host, fileNames, projectRootPath, safeListPath, packageNameToTypingLocation, typingOptions) { + var inferredTypings = ts.createMap(); + if (!typingOptions || !typingOptions.enableAutoDiscovery) { + return { cachedTypingPaths: [], newTypingNames: [], filesToWatch: [] }; + } + fileNames = ts.filter(ts.map(fileNames, ts.normalizePath), function (f) { + var kind = ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)); + return kind === 1 || kind === 2; + }); + if (!safeList) { + var result = ts.readConfigFile(safeListPath, function (path) { return host.readFile(path); }); + safeList = result.config ? ts.createMap(result.config) : EmptySafeList; + } + var filesToWatch = []; + var searchDirs = []; + var exclude = []; + mergeTypings(typingOptions.include); + exclude = typingOptions.exclude || []; + var possibleSearchDirs = ts.map(fileNames, ts.getDirectoryPath); + if (projectRootPath !== undefined) { + possibleSearchDirs.push(projectRootPath); + } + searchDirs = ts.deduplicate(possibleSearchDirs); + for (var _i = 0, searchDirs_1 = searchDirs; _i < searchDirs_1.length; _i++) { + var searchDir = searchDirs_1[_i]; + var packageJsonPath = ts.combinePaths(searchDir, "package.json"); + getTypingNamesFromJson(packageJsonPath, filesToWatch); + var bowerJsonPath = ts.combinePaths(searchDir, "bower.json"); + getTypingNamesFromJson(bowerJsonPath, filesToWatch); + var nodeModulesPath = ts.combinePaths(searchDir, "node_modules"); + getTypingNamesFromNodeModuleFolder(nodeModulesPath); + } + getTypingNamesFromSourceFileNames(fileNames); + for (var name_48 in packageNameToTypingLocation) { + if (name_48 in inferredTypings && !inferredTypings[name_48]) { + inferredTypings[name_48] = packageNameToTypingLocation[name_48]; + } + } + for (var _a = 0, exclude_1 = exclude; _a < exclude_1.length; _a++) { + var excludeTypingName = exclude_1[_a]; + delete inferredTypings[excludeTypingName]; + } + var newTypingNames = []; + var cachedTypingPaths = []; + for (var typing in inferredTypings) { + if (inferredTypings[typing] !== undefined) { + cachedTypingPaths.push(inferredTypings[typing]); + } + else { + newTypingNames.push(typing); + } + } + return { cachedTypingPaths: cachedTypingPaths, newTypingNames: newTypingNames, filesToWatch: filesToWatch }; + function mergeTypings(typingNames) { + if (!typingNames) { + return; + } + for (var _i = 0, typingNames_1 = typingNames; _i < typingNames_1.length; _i++) { + var typing = typingNames_1[_i]; + if (!(typing in inferredTypings)) { + inferredTypings[typing] = undefined; + } + } + } + function getTypingNamesFromJson(jsonPath, filesToWatch) { + var result = ts.readConfigFile(jsonPath, function (path) { return host.readFile(path); }); + if (result.config) { + var jsonConfig = result.config; + filesToWatch.push(jsonPath); + if (jsonConfig.dependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.dependencies)); + } + if (jsonConfig.devDependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.devDependencies)); + } + if (jsonConfig.optionalDependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.optionalDependencies)); + } + if (jsonConfig.peerDependencies) { + mergeTypings(ts.getOwnKeys(jsonConfig.peerDependencies)); + } + } + } + function getTypingNamesFromSourceFileNames(fileNames) { + var jsFileNames = ts.filter(fileNames, ts.hasJavaScriptFileExtension); + var inferredTypingNames = ts.map(jsFileNames, function (f) { return ts.removeFileExtension(ts.getBaseFileName(f.toLowerCase())); }); + var cleanedTypingNames = ts.map(inferredTypingNames, function (f) { return f.replace(/((?:\.|-)min(?=\.|$))|((?:-|\.)\d+)/g, ""); }); + if (safeList !== EmptySafeList) { + mergeTypings(ts.filter(cleanedTypingNames, function (f) { return f in safeList; })); + } + var hasJsxFile = ts.forEach(fileNames, function (f) { return ts.ensureScriptKind(f, ts.getScriptKindFromFileName(f)) === 2; }); + if (hasJsxFile) { + mergeTypings(["react"]); + } + } + function getTypingNamesFromNodeModuleFolder(nodeModulesPath) { + if (!host.directoryExists(nodeModulesPath)) { + return; + } + var typingNames = []; + var fileNames = host.readDirectory(nodeModulesPath, [".json"], undefined, undefined, 2); + for (var _i = 0, fileNames_2 = fileNames; _i < fileNames_2.length; _i++) { + var fileName = fileNames_2[_i]; + var normalizedFileName = ts.normalizePath(fileName); + if (ts.getBaseFileName(normalizedFileName) !== "package.json") { + continue; + } + var result = ts.readConfigFile(normalizedFileName, function (path) { return host.readFile(path); }); + if (!result.config) { + continue; + } + var packageJson = result.config; + if (packageJson._requiredBy && + ts.filter(packageJson._requiredBy, function (r) { return r[0] === "#" || r === "/"; }).length === 0) { + continue; + } + if (!packageJson.name) { + continue; + } + if (packageJson.typings) { + var absolutePath = ts.getNormalizedAbsolutePath(packageJson.typings, ts.getDirectoryPath(normalizedFileName)); + inferredTypings[packageJson.name] = absolutePath; + } + else { + typingNames.push(packageJson.name); + } + } + mergeTypings(typingNames); + } + } + JsTyping.discoverTypings = discoverTypings; + })(JsTyping = ts.JsTyping || (ts.JsTyping = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var NavigateTo; (function (NavigateTo) { function getNavigateToItems(sourceFiles, checker, cancellationToken, searchValue, maxResultCount, excludeDtsFiles) { var patternMatcher = ts.createPatternMatcher(searchValue); var rawItems = []; - var baseSensitivity = { sensitivity: "base" }; ts.forEach(sourceFiles, function (sourceFile) { cancellationToken.throwIfCancellationRequested(); if (excludeDtsFiles && ts.fileExtensionIs(sourceFile.fileName, ".d.ts")) { @@ -54690,7 +56169,7 @@ var ts; }); rawItems = ts.filter(rawItems, function (item) { var decl = item.declaration; - if (decl.kind === 231 || decl.kind === 234 || decl.kind === 229) { + if (decl.kind === 232 || decl.kind === 235 || decl.kind === 230) { var importer = checker.getSymbolAtLocation(decl.name); var imported = checker.getAliasedSymbol(importer); return importer.name !== imported.name; @@ -54717,7 +56196,7 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 69 || + if (node.kind === 70 || node.kind === 9 || node.kind === 8) { return node.text; @@ -54731,7 +56210,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 140) { + else if (declaration.name.kind === 141) { return tryAddComputedPropertyName(declaration.name.expression, containers, true); } else { @@ -54748,7 +56227,7 @@ var ts; } return true; } - if (expression.kind === 172) { + if (expression.kind === 173) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -54759,7 +56238,7 @@ var ts; } function getContainers(declaration) { var containers = []; - if (declaration.name.kind === 140) { + if (declaration.name.kind === 141) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, false)) { return undefined; } @@ -54787,8 +56266,8 @@ var ts; } function compareNavigateToItems(i1, i2) { return i1.matchKind - i2.matchKind || - i1.name.localeCompare(i2.name, undefined, baseSensitivity) || - i1.name.localeCompare(i2.name); + ts.compareStringsCaseInsensitive(i1.name, i2.name) || + ts.compareStrings(i1.name, i2.name); } function createNavigateToItem(rawItem) { var declaration = rawItem.declaration; @@ -54891,7 +56370,7 @@ var ts; return; } switch (node.kind) { - case 148: + case 149: var ctr = node; addNodeWithRecursiveChild(ctr, ctr.body); for (var _i = 0, _a = ctr.parameters; _i < _a.length; _i++) { @@ -54901,28 +56380,28 @@ var ts; } } break; - case 147: - case 149: + case 148: case 150: - case 146: + case 151: + case 147: if (!ts.hasDynamicName(node)) { addNodeWithRecursiveChild(node, node.body); } break; + case 146: case 145: - case 144: if (!ts.hasDynamicName(node)) { addLeafNode(node); } break; - case 231: + case 232: var importClause = node; if (importClause.name) { addLeafNode(importClause); } var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 232) { + if (namedBindings.kind === 233) { addLeafNode(namedBindings); } else { @@ -54933,8 +56412,8 @@ var ts; } } break; - case 169: - case 218: + case 170: + case 219: var decl = node; var name_50 = decl.name; if (ts.isBindingPattern(name_50)) { @@ -54947,12 +56426,12 @@ var ts; addNodeWithRecursiveChild(decl, decl.initializer); } break; + case 181: + case 221: case 180: - case 220: - case 179: addNodeWithRecursiveChild(node, node.body); break; - case 224: + case 225: startNode(node); for (var _d = 0, _e = node.members; _d < _e.length; _d++) { var member = _e[_d]; @@ -54962,9 +56441,9 @@ var ts; } endNode(); break; - case 221: - case 192: case 222: + case 193: + case 223: startNode(node); for (var _f = 0, _g = node.members; _f < _g.length; _f++) { var member = _g[_f]; @@ -54972,15 +56451,15 @@ var ts; } endNode(); break; - case 225: + case 226: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 238: - case 229: - case 153: - case 151: + case 239: + case 230: + case 154: case 152: - case 223: + case 153: + case 224: addLeafNode(node); break; default: @@ -55034,12 +56513,12 @@ var ts; } }); function shouldReallyMerge(a, b) { - return a.kind === b.kind && (a.kind !== 225 || areSameModule(a, b)); + return a.kind === b.kind && (a.kind !== 226 || areSameModule(a, b)); function areSameModule(a, b) { if (a.body.kind !== b.body.kind) { return false; } - if (a.body.kind !== 225) { + if (a.body.kind !== 226) { return true; } return areSameModule(a.body, b.body); @@ -55072,9 +56551,8 @@ var ts; return name1 ? 1 : name2 ? -1 : navigationBarNodeKind(child1) - navigationBarNodeKind(child2); } } - var collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; - var localeCompareIsCorrect = collator && collator.compare("a", "B") < 0; - var localeCompareFix = localeCompareIsCorrect ? collator.compare : function (a, b) { + var localeCompareIsCorrect = ts.collator && ts.collator.compare("a", "B") < 0; + var localeCompareFix = localeCompareIsCorrect ? ts.collator.compare : function (a, b) { for (var i = 0; i < Math.min(a.length, b.length); i++) { var chA = a.charAt(i), chB = b.charAt(i); if (chA === "\"" && chB === "'") { @@ -55083,7 +56561,7 @@ var ts; if (chA === "'" && chB === "\"") { return -1; } - var cmp = chA.toLocaleLowerCase().localeCompare(chB.toLocaleLowerCase()); + var cmp = ts.compareStrings(chA.toLocaleLowerCase(), chB.toLocaleLowerCase()); if (cmp !== 0) { return cmp; } @@ -55091,7 +56569,7 @@ var ts; return a.length - b.length; }; function tryGetName(node) { - if (node.kind === 225) { + if (node.kind === 226) { return getModuleName(node); } var decl = node; @@ -55099,9 +56577,9 @@ var ts; return ts.getPropertyNameForPropertyNameNode(decl.name); } switch (node.kind) { - case 179: case 180: - case 192: + case 181: + case 193: return getFunctionOrClassName(node); case 279: return getJSDocTypedefTagName(node); @@ -55110,7 +56588,7 @@ var ts; } } function getItemName(node) { - if (node.kind === 225) { + if (node.kind === 226) { return getModuleName(node); } var name = node.name; @@ -55126,22 +56604,22 @@ var ts; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 180: - case 220: - case 179: + case 181: case 221: - case 192: + case 180: + case 222: + case 193: if (ts.getModifierFlags(node) & 512) { return "default"; } return getFunctionOrClassName(node); - case 148: + case 149: return "constructor"; - case 152: - return "new()"; - case 151: - return "()"; case 153: + return "new()"; + case 152: + return "()"; + case 154: return "[]"; case 279: return getJSDocTypedefTagName(node); @@ -55155,10 +56633,10 @@ var ts; } else { var parentNode = node.parent && node.parent.parent; - if (parentNode && parentNode.kind === 200) { + if (parentNode && parentNode.kind === 201) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; - if (nameIdentifier.kind === 69) { + if (nameIdentifier.kind === 70) { return nameIdentifier.text; } } @@ -55183,24 +56661,24 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 221: - case 192: - case 224: case 222: + case 193: case 225: - case 256: case 223: + case 226: + case 256: + case 224: case 279: return true; - case 148: - case 147: case 149: + case 148: case 150: - case 218: + case 151: + case 219: return hasSomeImportantChild(item); + case 181: + case 221: case 180: - case 220: - case 179: return isTopLevelFunctionDeclaration(item); default: return false; @@ -55210,10 +56688,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 226: + case 227: case 256: - case 147: case 148: + case 149: return true; default: return hasSomeImportantChild(item); @@ -55222,7 +56700,7 @@ var ts; function hasSomeImportantChild(item) { return ts.forEach(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 218 && childKind !== 169; + return childKind !== 219 && childKind !== 170; }); } } @@ -55277,17 +56755,17 @@ var ts; } var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 225) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 226) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } return result.join("."); } function getInteriorModule(decl) { - return decl.body.kind === 225 ? getInteriorModule(decl.body) : decl; + return decl.body.kind === 226 ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 140; + return !member.name || member.name.kind === 141; } function getNodeSpan(node) { return node.kind === 256 @@ -55298,11 +56776,11 @@ var ts; if (node.name && ts.getFullWidth(node.name) > 0) { return ts.declarationNameToString(node.name); } - else if (node.parent.kind === 218) { + else if (node.parent.kind === 219) { return ts.declarationNameToString(node.parent.name); } - else if (node.parent.kind === 187 && - node.parent.operatorToken.kind === 56) { + else if (node.parent.kind === 188 && + node.parent.operatorToken.kind === 57) { return nodeText(node.parent.left); } else if (node.parent.kind === 253 && node.parent.name) { @@ -55316,7 +56794,7 @@ var ts; } } function isFunctionOrClassExpression(node) { - return node.kind === 179 || node.kind === 180 || node.kind === 192; + return node.kind === 180 || node.kind === 181 || node.kind === 193; } })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); })(ts || (ts = {})); @@ -55388,7 +56866,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 180; + return ts.isFunctionBlock(node) && node.parent.kind !== 181; } var depth = 0; var maxDepth = 20; @@ -55400,30 +56878,30 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 199: + case 200: if (!ts.isFunctionBlock(n)) { var parent_22 = n.parent; - var openBrace = ts.findChildOfKind(n, 15, sourceFile); - var closeBrace = ts.findChildOfKind(n, 16, sourceFile); - if (parent_22.kind === 204 || - parent_22.kind === 207 || + var openBrace = ts.findChildOfKind(n, 16, sourceFile); + var closeBrace = ts.findChildOfKind(n, 17, sourceFile); + if (parent_22.kind === 205 || parent_22.kind === 208 || + parent_22.kind === 209 || + parent_22.kind === 207 || + parent_22.kind === 204 || parent_22.kind === 206 || - parent_22.kind === 203 || - parent_22.kind === 205 || - parent_22.kind === 212 || + parent_22.kind === 213 || parent_22.kind === 252) { addOutliningSpan(parent_22, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_22.kind === 216) { + if (parent_22.kind === 217) { var tryStatement = parent_22; if (tryStatement.tryBlock === n) { addOutliningSpan(parent_22, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 85, sourceFile); + var finallyKeyword = ts.findChildOfKind(tryStatement, 86, sourceFile); if (finallyKeyword) { addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); break; @@ -55439,25 +56917,25 @@ var ts; }); break; } - case 226: { - var openBrace = ts.findChildOfKind(n, 15, sourceFile); - var closeBrace = ts.findChildOfKind(n, 16, sourceFile); + case 227: { + var openBrace = ts.findChildOfKind(n, 16, sourceFile); + var closeBrace = ts.findChildOfKind(n, 17, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 221: case 222: - case 224: - case 171: - case 227: { - var openBrace = ts.findChildOfKind(n, 15, sourceFile); - var closeBrace = ts.findChildOfKind(n, 16, sourceFile); + case 223: + case 225: + case 172: + case 228: { + var openBrace = ts.findChildOfKind(n, 16, sourceFile); + var closeBrace = ts.findChildOfKind(n, 17, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 170: - var openBracket = ts.findChildOfKind(n, 19, sourceFile); - var closeBracket = ts.findChildOfKind(n, 20, sourceFile); + case 171: + var openBracket = ts.findChildOfKind(n, 20, sourceFile); + var closeBracket = ts.findChildOfKind(n, 21, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); break; } @@ -55700,7 +57178,7 @@ var ts; if (ch >= 65 && ch <= 90) { return true; } - if (ch < 127 || !ts.isUnicodeIdentifierStart(ch, 2)) { + if (ch < 127 || !ts.isUnicodeIdentifierStart(ch, 4)) { return false; } var str = String.fromCharCode(ch); @@ -55710,7 +57188,7 @@ var ts; if (ch >= 97 && ch <= 122) { return true; } - if (ch < 127 || !ts.isUnicodeIdentifierStart(ch, 2)) { + if (ch < 127 || !ts.isUnicodeIdentifierStart(ch, 4)) { return false; } var str = String.fromCharCode(ch); @@ -55893,10 +57371,10 @@ var ts; var externalModule = false; function nextToken() { var token = ts.scanner.scan(); - if (token === 15) { + if (token === 16) { braceNesting++; } - else if (token === 16) { + else if (token === 17) { braceNesting--; } return token; @@ -55944,9 +57422,9 @@ var ts; } function tryConsumeDeclare() { var token = ts.scanner.getToken(); - if (token === 122) { + if (token === 123) { token = nextToken(); - if (token === 125) { + if (token === 126) { token = nextToken(); if (token === 9) { recordAmbientExternalModule(); @@ -55958,42 +57436,42 @@ var ts; } function tryConsumeImport() { var token = ts.scanner.getToken(); - if (token === 89) { + if (token === 90) { token = nextToken(); if (token === 9) { recordModuleName(); return true; } else { - if (token === 69 || ts.isKeyword(token)) { + if (token === 70 || ts.isKeyword(token)) { token = nextToken(); - if (token === 136) { + if (token === 137) { token = nextToken(); if (token === 9) { recordModuleName(); return true; } } - else if (token === 56) { + else if (token === 57) { if (tryConsumeRequireCall(true)) { return true; } } - else if (token === 24) { + else if (token === 25) { token = nextToken(); } else { return true; } } - if (token === 15) { + if (token === 16) { token = nextToken(); - while (token !== 16 && token !== 1) { + while (token !== 17 && token !== 1) { token = nextToken(); } - if (token === 16) { + if (token === 17) { token = nextToken(); - if (token === 136) { + if (token === 137) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -56001,13 +57479,13 @@ var ts; } } } - else if (token === 37) { + else if (token === 38) { token = nextToken(); - if (token === 116) { + if (token === 117) { token = nextToken(); - if (token === 69 || ts.isKeyword(token)) { + if (token === 70 || ts.isKeyword(token)) { token = nextToken(); - if (token === 136) { + if (token === 137) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -56023,17 +57501,17 @@ var ts; } function tryConsumeExport() { var token = ts.scanner.getToken(); - if (token === 82) { + if (token === 83) { markAsExternalModuleIfTopLevel(); token = nextToken(); - if (token === 15) { + if (token === 16) { token = nextToken(); - while (token !== 16 && token !== 1) { + while (token !== 17 && token !== 1) { token = nextToken(); } - if (token === 16) { + if (token === 17) { token = nextToken(); - if (token === 136) { + if (token === 137) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -56041,20 +57519,20 @@ var ts; } } } - else if (token === 37) { + else if (token === 38) { token = nextToken(); - if (token === 136) { + if (token === 137) { token = nextToken(); if (token === 9) { recordModuleName(); } } } - else if (token === 89) { + else if (token === 90) { token = nextToken(); - if (token === 69 || ts.isKeyword(token)) { + if (token === 70 || ts.isKeyword(token)) { token = nextToken(); - if (token === 56) { + if (token === 57) { if (tryConsumeRequireCall(true)) { return true; } @@ -56067,9 +57545,9 @@ var ts; } function tryConsumeRequireCall(skipCurrentToken) { var token = skipCurrentToken ? nextToken() : ts.scanner.getToken(); - if (token === 129) { + if (token === 130) { token = nextToken(); - if (token === 17) { + if (token === 18) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -56081,27 +57559,27 @@ var ts; } function tryConsumeDefine() { var token = ts.scanner.getToken(); - if (token === 69 && ts.scanner.getTokenValue() === "define") { + if (token === 70 && ts.scanner.getTokenValue() === "define") { token = nextToken(); - if (token !== 17) { + if (token !== 18) { return true; } token = nextToken(); if (token === 9) { token = nextToken(); - if (token === 24) { + if (token === 25) { token = nextToken(); } else { return true; } } - if (token !== 19) { + if (token !== 20) { return true; } token = nextToken(); var i = 0; - while (token !== 20 && token !== 1) { + while (token !== 21 && token !== 1) { if (token === 9) { recordModuleName(); i++; @@ -56173,7 +57651,7 @@ var ts; var canonicalDefaultLibName = getCanonicalFileName(ts.normalizePath(defaultLibFileName)); var node = ts.getTouchingWord(sourceFile, position, true); if (node) { - if (node.kind === 69 || + if (node.kind === 70 || node.kind === 9 || ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || ts.isThis(node)) { @@ -56261,6 +57739,12 @@ var ts; var SignatureHelp; (function (SignatureHelp) { var emptyArray = []; + (function (ArgumentListKind) { + ArgumentListKind[ArgumentListKind["TypeArguments"] = 0] = "TypeArguments"; + ArgumentListKind[ArgumentListKind["CallArguments"] = 1] = "CallArguments"; + ArgumentListKind[ArgumentListKind["TaggedTemplateArguments"] = 2] = "TaggedTemplateArguments"; + })(SignatureHelp.ArgumentListKind || (SignatureHelp.ArgumentListKind = {})); + var ArgumentListKind = SignatureHelp.ArgumentListKind; function getSignatureHelpItems(program, sourceFile, position, cancellationToken) { var typeChecker = program.getTypeChecker(); var startingToken = ts.findTokenOnLeftOfPosition(sourceFile, position); @@ -56286,14 +57770,14 @@ var ts; } SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; function createJavaScriptSignatureHelpItems(argumentInfo, program) { - if (argumentInfo.invocation.kind !== 174) { + if (argumentInfo.invocation.kind !== 175) { return undefined; } var callExpression = argumentInfo.invocation; var expression = callExpression.expression; - var name = expression.kind === 69 + var name = expression.kind === 70 ? expression - : expression.kind === 172 + : expression.kind === 173 ? expression.name : undefined; if (!name || !name.text) { @@ -56322,10 +57806,10 @@ var ts; } } function getImmediatelyContainingArgumentInfo(node, position, sourceFile) { - if (node.parent.kind === 174 || node.parent.kind === 175) { + if (node.parent.kind === 175 || node.parent.kind === 176) { var callExpression = node.parent; - if (node.kind === 25 || - node.kind === 17) { + if (node.kind === 26 || + node.kind === 18) { var list = getChildListThatStartsWithOpenerToken(callExpression, node, sourceFile); var isTypeArgList = callExpression.typeArguments && callExpression.typeArguments.pos === list.pos; ts.Debug.assert(list !== undefined); @@ -56354,24 +57838,24 @@ var ts; } return undefined; } - else if (node.kind === 11 && node.parent.kind === 176) { + else if (node.kind === 12 && node.parent.kind === 177) { if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, 0, sourceFile); } } - else if (node.kind === 12 && node.parent.parent.kind === 176) { + else if (node.kind === 13 && node.parent.parent.kind === 177) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 189); + ts.Debug.assert(templateExpression.kind === 190); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } - else if (node.parent.kind === 197 && node.parent.parent.parent.kind === 176) { + else if (node.parent.kind === 198 && node.parent.parent.parent.kind === 177) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 189); - if (node.kind === 14 && !ts.isInsideTemplateLiteral(node, position)) { + ts.Debug.assert(templateExpression.kind === 190); + if (node.kind === 15 && !ts.isInsideTemplateLiteral(node, position)) { return undefined; } var spanIndex = templateExpression.templateSpans.indexOf(templateSpan); @@ -56388,7 +57872,7 @@ var ts; if (child === node) { break; } - if (child.kind !== 24) { + if (child.kind !== 25) { argumentIndex++; } } @@ -56396,8 +57880,8 @@ var ts; } function getArgumentCount(argumentsList) { var listChildren = argumentsList.getChildren(); - var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 24; }); - if (listChildren.length > 0 && ts.lastOrUndefined(listChildren).kind === 24) { + var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 25; }); + if (listChildren.length > 0 && ts.lastOrUndefined(listChildren).kind === 25) { argumentCount++; } return argumentCount; @@ -56413,7 +57897,7 @@ var ts; return spanIndex + 1; } function getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile) { - var argumentCount = tagExpression.template.kind === 11 + var argumentCount = tagExpression.template.kind === 12 ? 1 : tagExpression.template.templateSpans.length + 1; ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); @@ -56434,7 +57918,7 @@ var ts; var template = taggedTemplate.template; var applicableSpanStart = template.getStart(); var applicableSpanEnd = template.getEnd(); - if (template.kind === 189) { + if (template.kind === 190) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); @@ -56494,10 +57978,10 @@ var ts; ts.addRange(prefixDisplayParts, callTargetDisplayParts); } if (isTypeParameterList) { - prefixDisplayParts.push(ts.punctuationPart(25)); + prefixDisplayParts.push(ts.punctuationPart(26)); var typeParameters = candidateSignature.typeParameters; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(27)); + suffixDisplayParts.push(ts.punctuationPart(28)); var parameterParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.thisParameter, candidateSignature.parameters, writer, invocation); }); @@ -56508,10 +57992,10 @@ var ts; return typeChecker.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation); }); ts.addRange(prefixDisplayParts, typeParameterParts); - prefixDisplayParts.push(ts.punctuationPart(17)); + prefixDisplayParts.push(ts.punctuationPart(18)); var parameters = candidateSignature.parameters; signatureHelpParameters = parameters.length > 0 ? ts.map(parameters, createSignatureHelpParameterForParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(18)); + suffixDisplayParts.push(ts.punctuationPart(19)); } var returnTypeParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation); @@ -56521,7 +58005,7 @@ var ts; isVariadic: candidateSignature.hasRestParameter, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: suffixDisplayParts, - separatorDisplayParts: [ts.punctuationPart(24), ts.spacePart()], + separatorDisplayParts: [ts.punctuationPart(25), ts.spacePart()], parameters: signatureHelpParameters, documentation: candidateSignature.getDocumentationComment() }; @@ -56572,7 +58056,7 @@ var ts; function getSymbolKind(typeChecker, symbol, location) { var flags = symbol.getFlags(); if (flags & 32) - return ts.getDeclarationOfKind(symbol, 192) ? + return ts.getDeclarationOfKind(symbol, 193) ? ts.ScriptElementKind.localClassElement : ts.ScriptElementKind.classElement; if (flags & 384) return ts.ScriptElementKind.enumElement; @@ -56603,7 +58087,7 @@ var ts; if (typeChecker.isArgumentsSymbol(symbol)) { return ts.ScriptElementKind.localVariableElement; } - if (location.kind === 97 && ts.isExpression(location)) { + if (location.kind === 98 && ts.isExpression(location)) { return ts.ScriptElementKind.parameterElement; } if (flags & 3) { @@ -56663,7 +58147,7 @@ var ts; var symbolFlags = symbol.flags; var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, symbolFlags, location); var hasAddedSymbolInfo; - var isThisExpression = location.kind === 97 && ts.isExpression(location); + var isThisExpression = location.kind === 98 && ts.isExpression(location); var type; if (symbolKind !== ts.ScriptElementKind.unknown || symbolFlags & 32 || symbolFlags & 8388608) { if (symbolKind === ts.ScriptElementKind.memberGetAccessorElement || symbolKind === ts.ScriptElementKind.memberSetAccessorElement) { @@ -56672,14 +58156,14 @@ var ts; var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 172) { + if (location.parent && location.parent.kind === 173) { var right = location.parent.name; if (right === location || (right && right.getFullWidth() === 0)) { location = location.parent; } } var callExpression = void 0; - if (location.kind === 174 || location.kind === 175) { + if (location.kind === 175 || location.kind === 176) { callExpression = location; } else if (ts.isCallExpressionTarget(location) || ts.isNewExpressionTarget(location)) { @@ -56691,7 +58175,7 @@ var ts; if (!signature && candidateSignatures.length) { signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 175 || callExpression.expression.kind === 95; + var useConstructSignatures = callExpression.kind === 176 || callExpression.expression.kind === 96; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { signature = allSignatures.length ? allSignatures[0] : undefined; @@ -56706,7 +58190,7 @@ var ts; pushTypePart(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(92)); + displayParts.push(ts.keywordPart(93)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -56721,10 +58205,10 @@ var ts; case ts.ScriptElementKind.letElement: case ts.ScriptElementKind.parameterElement: case ts.ScriptElementKind.localVariableElement: - displayParts.push(ts.punctuationPart(54)); + displayParts.push(ts.punctuationPart(55)); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(92)); + displayParts.push(ts.keywordPart(93)); displayParts.push(ts.spacePart()); } if (!(type.flags & 2097152) && type.symbol) { @@ -56739,21 +58223,21 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304)) || - (location.kind === 121 && location.parent.kind === 148)) { + (location.kind === 122 && location.parent.kind === 149)) { var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 148 ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration.kind === 149 ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 148) { + if (functionDeclaration.kind === 149) { symbolKind = ts.ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 151 && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 152 && !(type.symbol.flags & 2048 || type.symbol.flags & 4096) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -56762,11 +58246,11 @@ var ts; } } if (symbolFlags & 32 && !hasAddedSymbolInfo && !isThisExpression) { - if (ts.getDeclarationOfKind(symbol, 192)) { + if (ts.getDeclarationOfKind(symbol, 193)) { pushTypePart(ts.ScriptElementKind.localClassElement); } else { - displayParts.push(ts.keywordPart(73)); + displayParts.push(ts.keywordPart(74)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); @@ -56774,72 +58258,72 @@ var ts; } if ((symbolFlags & 64) && (semanticMeaning & 2)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(107)); + displayParts.push(ts.keywordPart(108)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if (symbolFlags & 524288) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(134)); + displayParts.push(ts.keywordPart(135)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(56)); + displayParts.push(ts.operatorPart(57)); displayParts.push(ts.spacePart()); ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 512)); } if (symbolFlags & 384) { addNewLineIfDisplayPartsExist(); if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { - displayParts.push(ts.keywordPart(74)); + displayParts.push(ts.keywordPart(75)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(81)); + displayParts.push(ts.keywordPart(82)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 225); - var isNamespace = declaration && declaration.name && declaration.name.kind === 69; - displayParts.push(ts.keywordPart(isNamespace ? 126 : 125)); + var declaration = ts.getDeclarationOfKind(symbol, 226); + var isNamespace = declaration && declaration.name && declaration.name.kind === 70; + displayParts.push(ts.keywordPart(isNamespace ? 127 : 126)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if ((symbolFlags & 262144) && (semanticMeaning & 2)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.punctuationPart(17)); - displayParts.push(ts.textPart("type parameter")); displayParts.push(ts.punctuationPart(18)); + displayParts.push(ts.textPart("type parameter")); + displayParts.push(ts.punctuationPart(19)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(90)); + displayParts.push(ts.keywordPart(91)); displayParts.push(ts.spacePart()); if (symbol.parent) { addFullSymbolName(symbol.parent, enclosingDeclaration); writeTypeParametersOfSymbol(symbol.parent, enclosingDeclaration); } else { - var declaration = ts.getDeclarationOfKind(symbol, 141); + var declaration = ts.getDeclarationOfKind(symbol, 142); ts.Debug.assert(declaration !== undefined); declaration = declaration.parent; if (declaration) { if (ts.isFunctionLikeKind(declaration.kind)) { var signature = typeChecker.getSignatureFromDeclaration(declaration); - if (declaration.kind === 152) { - displayParts.push(ts.keywordPart(92)); + if (declaration.kind === 153) { + displayParts.push(ts.keywordPart(93)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 151 && declaration.name) { + else if (declaration.kind !== 152 && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32)); } else { - displayParts.push(ts.keywordPart(134)); + displayParts.push(ts.keywordPart(135)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -56854,7 +58338,7 @@ var ts; var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(56)); + displayParts.push(ts.operatorPart(57)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(constantValue.toString(), ts.SymbolDisplayPartKind.numericLiteral)); } @@ -56862,33 +58346,33 @@ var ts; } if (symbolFlags & 8388608) { addNewLineIfDisplayPartsExist(); - if (symbol.declarations[0].kind === 228) { - displayParts.push(ts.keywordPart(82)); + if (symbol.declarations[0].kind === 229) { + displayParts.push(ts.keywordPart(83)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(126)); + displayParts.push(ts.keywordPart(127)); } else { - displayParts.push(ts.keywordPart(89)); + displayParts.push(ts.keywordPart(90)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 229) { + if (declaration.kind === 230) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(56)); + displayParts.push(ts.operatorPart(57)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(129)); - displayParts.push(ts.punctuationPart(17)); - displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); + displayParts.push(ts.keywordPart(130)); displayParts.push(ts.punctuationPart(18)); + displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); + displayParts.push(ts.punctuationPart(19)); } else { var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(56)); + displayParts.push(ts.operatorPart(57)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -56902,7 +58386,7 @@ var ts; if (type) { if (isThisExpression) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(97)); + displayParts.push(ts.keywordPart(98)); } else { addPrefixForAnyFunctionOrVar(symbol, symbolKind); @@ -56911,7 +58395,7 @@ var ts; symbolFlags & 3 || symbolKind === ts.ScriptElementKind.localVariableElement || isThisExpression) { - displayParts.push(ts.punctuationPart(54)); + displayParts.push(ts.punctuationPart(55)); displayParts.push(ts.spacePart()); if (type.symbol && type.symbol.flags & 262144) { var typeParameterParts = ts.mapToDisplayParts(function (writer) { @@ -56944,7 +58428,7 @@ var ts; if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 256; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 187) { + if (!declaration.parent || declaration.parent.kind !== 188) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -56987,9 +58471,9 @@ var ts; displayParts.push(ts.textOrKeywordPart(symbolKind)); return; default: - displayParts.push(ts.punctuationPart(17)); - displayParts.push(ts.textOrKeywordPart(symbolKind)); displayParts.push(ts.punctuationPart(18)); + displayParts.push(ts.textOrKeywordPart(symbolKind)); + displayParts.push(ts.punctuationPart(19)); return; } } @@ -56997,12 +58481,12 @@ var ts; ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32)); if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); - displayParts.push(ts.punctuationPart(17)); - displayParts.push(ts.operatorPart(35)); + displayParts.push(ts.punctuationPart(18)); + displayParts.push(ts.operatorPart(36)); displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), ts.SymbolDisplayPartKind.numericLiteral)); displayParts.push(ts.spacePart()); displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); - displayParts.push(ts.punctuationPart(18)); + displayParts.push(ts.punctuationPart(19)); } documentation = signature.getDocumentationComment(); } @@ -57019,14 +58503,14 @@ var ts; return false; } return ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 179) { + if (declaration.kind === 180) { return true; } - if (declaration.kind !== 218 && declaration.kind !== 220) { + if (declaration.kind !== 219 && declaration.kind !== 221) { return false; } for (var parent_23 = declaration.parent; !ts.isFunctionBlock(parent_23); parent_23 = parent_23.parent) { - if (parent_23.kind === 256 || parent_23.kind === 226) { + if (parent_23.kind === 256 || parent_23.kind === 227) { return false; } } @@ -57067,8 +58551,8 @@ var ts; var outputText; var sourceMapText; var compilerHost = { - getSourceFile: function (fileName, target) { return fileName === ts.normalizePath(inputFileName) ? sourceFile : undefined; }, - writeFile: function (name, text, writeByteOrderMark) { + getSourceFile: function (fileName) { return fileName === ts.normalizePath(inputFileName) ? sourceFile : undefined; }, + writeFile: function (name, text) { if (ts.fileExtensionIs(name, ".map")) { ts.Debug.assert(sourceMapText === undefined, "Unexpected multiple source map outputs for the file '" + name + "'"); sourceMapText = text; @@ -57084,9 +58568,9 @@ var ts; getCurrentDirectory: function () { return ""; }, getNewLine: function () { return newLine; }, fileExists: function (fileName) { return fileName === inputFileName; }, - readFile: function (fileName) { return ""; }, - directoryExists: function (directoryExists) { return true; }, - getDirectories: function (path) { return []; } + readFile: function () { return ""; }, + directoryExists: function () { return true; }, + getDirectories: function () { return []; } }; var program = ts.createProgram([inputFileName], options, compilerHost); if (transpileOptions.reportDiagnostics) { @@ -57135,11 +58619,20 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var standardScanner = ts.createScanner(2, false, 0); - var jsxScanner = ts.createScanner(2, false, 1); + var standardScanner = ts.createScanner(4, false, 0); + var jsxScanner = ts.createScanner(4, false, 1); var scanner; + var ScanAction; + (function (ScanAction) { + ScanAction[ScanAction["Scan"] = 0] = "Scan"; + ScanAction[ScanAction["RescanGreaterThanToken"] = 1] = "RescanGreaterThanToken"; + ScanAction[ScanAction["RescanSlashToken"] = 2] = "RescanSlashToken"; + ScanAction[ScanAction["RescanTemplateToken"] = 3] = "RescanTemplateToken"; + ScanAction[ScanAction["RescanJsxIdentifier"] = 4] = "RescanJsxIdentifier"; + ScanAction[ScanAction["RescanJsxText"] = 5] = "RescanJsxText"; + })(ScanAction || (ScanAction = {})); function getFormattingScanner(sourceFile, startPos, endPos) { - ts.Debug.assert(scanner === undefined); + ts.Debug.assert(scanner === undefined, "Scanner should be undefined"); scanner = sourceFile.languageVariant === 1 ? jsxScanner : standardScanner; scanner.setText(sourceFile.text); scanner.setTextPos(startPos); @@ -57164,7 +58657,7 @@ var ts; } }; function advance() { - ts.Debug.assert(scanner !== undefined); + ts.Debug.assert(scanner !== undefined, "Scanner should be present"); lastTokenInfo = undefined; var isStarted = scanner.getStartPos() !== startPos; if (isStarted) { @@ -57204,11 +58697,11 @@ var ts; function shouldRescanGreaterThanToken(node) { if (node) { switch (node.kind) { - case 29: - case 64: + case 30: case 65: + case 66: + case 46: case 45: - case 44: return true; } } @@ -57218,26 +58711,26 @@ var ts; if (node.parent) { switch (node.parent.kind) { case 246: - case 243: + case 244: case 245: - case 242: - return node.kind === 69; + case 243: + return node.kind === 70; } } return false; } function shouldRescanJsxText(node) { - return node && node.kind === 244; + return node && node.kind === 10; } function shouldRescanSlashToken(container) { - return container.kind === 10; + return container.kind === 11; } function shouldRescanTemplateToken(container) { - return container.kind === 13 || - container.kind === 14; + return container.kind === 14 || + container.kind === 15; } function startsWithSlashToken(t) { - return t === 39 || t === 61; + return t === 40 || t === 62; } function readTokenInfo(n) { ts.Debug.assert(scanner !== undefined); @@ -57268,7 +58761,7 @@ var ts; scanner.scan(); } var currentToken = scanner.getToken(); - if (expectedScanAction === 1 && currentToken === 27) { + if (expectedScanAction === 1 && currentToken === 28) { currentToken = scanner.reScanGreaterToken(); ts.Debug.assert(n.kind === currentToken); lastScanAction = 1; @@ -57278,11 +58771,11 @@ var ts; ts.Debug.assert(n.kind === currentToken); lastScanAction = 2; } - else if (expectedScanAction === 3 && currentToken === 16) { + else if (expectedScanAction === 3 && currentToken === 17) { currentToken = scanner.reScanTemplateToken(); lastScanAction = 3; } - else if (expectedScanAction === 4 && currentToken === 69) { + else if (expectedScanAction === 4 && currentToken === 70) { currentToken = scanner.scanJsxIdentifier(); lastScanAction = 4; } @@ -57416,8 +58909,8 @@ var ts; return startLine === endLine; }; FormattingContext.prototype.BlockIsOnOneLine = function (node) { - var openBrace = ts.findChildOfKind(node, 15, this.sourceFile); - var closeBrace = ts.findChildOfKind(node, 16, this.sourceFile); + var openBrace = ts.findChildOfKind(node, 16, this.sourceFile); + var closeBrace = ts.findChildOfKind(node, 17, this.sourceFile); if (openBrace && closeBrace) { var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line; var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line; @@ -57431,6 +58924,20 @@ var ts; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var formatting; + (function (formatting) { + (function (FormattingRequestKind) { + FormattingRequestKind[FormattingRequestKind["FormatDocument"] = 0] = "FormatDocument"; + FormattingRequestKind[FormattingRequestKind["FormatSelection"] = 1] = "FormatSelection"; + FormattingRequestKind[FormattingRequestKind["FormatOnEnter"] = 2] = "FormatOnEnter"; + FormattingRequestKind[FormattingRequestKind["FormatOnSemicolon"] = 3] = "FormatOnSemicolon"; + FormattingRequestKind[FormattingRequestKind["FormatOnClosingCurlyBrace"] = 4] = "FormatOnClosingCurlyBrace"; + })(formatting.FormattingRequestKind || (formatting.FormattingRequestKind = {})); + var FormattingRequestKind = formatting.FormattingRequestKind; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var formatting; (function (formatting) { @@ -57452,6 +58959,19 @@ var ts; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var formatting; + (function (formatting) { + (function (RuleAction) { + RuleAction[RuleAction["Ignore"] = 1] = "Ignore"; + RuleAction[RuleAction["Space"] = 2] = "Space"; + RuleAction[RuleAction["NewLine"] = 4] = "NewLine"; + RuleAction[RuleAction["Delete"] = 8] = "Delete"; + })(formatting.RuleAction || (formatting.RuleAction = {})); + var RuleAction = formatting.RuleAction; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var formatting; (function (formatting) { @@ -57482,6 +59002,17 @@ var ts; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var formatting; + (function (formatting) { + (function (RuleFlags) { + RuleFlags[RuleFlags["None"] = 0] = "None"; + RuleFlags[RuleFlags["CanDeleteNewLines"] = 1] = "CanDeleteNewLines"; + })(formatting.RuleFlags || (formatting.RuleFlags = {})); + var RuleFlags = formatting.RuleFlags; + })(formatting = ts.formatting || (ts.formatting = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var formatting; (function (formatting) { @@ -57546,88 +59077,88 @@ var ts; function Rules() { this.IgnoreBeforeComment = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.Comments), formatting.RuleOperation.create1(1)); this.IgnoreAfterLineComment = new formatting.Rule(formatting.RuleDescriptor.create3(2, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create1(1)); - this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(54, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 2)); - this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(53, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsConditionalOperatorContext), 2)); - this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(53, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(23, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2)); - this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(16, 80), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(16, 104), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 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.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(21, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceBeforeOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), 8)); + this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 55), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(55, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 2)); + this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(54, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsConditionalOperatorContext), 2)); + this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(54, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2)); + this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(17, 81), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(17, 105), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.FromTokens([19, 21, 25, 24])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 22), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(22, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(21, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, 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([69, 3, 73, 82, 89]); - 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, 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)); - this.NoSpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 8)); - this.NoSpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 8)); - this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectContext), 8)); - 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.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); + this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([70, 3, 74, 83, 90]); + this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); + this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([19, 3, 80, 101, 86, 81]); + this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); + this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, 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, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2)); + this.NoSpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 8)); + this.NoSpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 8)); + this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(16, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectContext), 8)); + this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(16, 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, 17), 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.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(41, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(42, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 41), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 42), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(41, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(35, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(35, 41), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(42, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(36, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36, 42), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - 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.IsNonJsxSameLineTokenContext), 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.IsNonJsxSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2)); - this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8)); - 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.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 8)); - this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(103, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsVoidOpContext), 2)); - this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(94, 23), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 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.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, 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.IsNonJsxSameLineTokenContext), 2)); - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123, 131]), 69), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(42, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(43, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 42), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 43), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(42, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(36, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(36, 42), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(43, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(37, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(37, 43), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 25), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([103, 99, 93, 79, 95, 102, 120]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([109, 75]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2)); + this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8)); + this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(88, 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, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 8)); + this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(104, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsVoidOpContext), 2)); + this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(95, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([19, 80, 81, 72]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNotForContext), 2)); + this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([101, 86]), 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([124, 132]), 70), 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.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(121, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([125, 129]), 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 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, 131, 113, 134, 136]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([83, 106, 136])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2)); - this.SpaceBeforeArrow = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 34), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(34, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(22, 69), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(53, formatting.Shared.TokenRange.FromTokens([18, 24])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 25), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); - this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(18, 25), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); - this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(25, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); - this.NoSpaceBeforeCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 27), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); - this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(27, formatting.Shared.TokenRange.FromTokens([17, 19, 27, 24])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); - this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectTypeContext), 8)); - this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 55), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(55, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 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, 131, 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.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2)); - this.SpaceBetweenAsyncAndOpenParen = new formatting.Rule(formatting.RuleDescriptor.create1(118, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(118, 87), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(69, formatting.Shared.TokenRange.FromTokens([11, 12])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceBeforeJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 69), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNextTokenParentJsxAttribute, Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceBeforeSlashInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 39), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create1(39, 27), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceBeforeEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 56), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create3(56, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(122, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([126, 130]), 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116, 74, 123, 78, 82, 83, 84, 124, 107, 90, 108, 126, 127, 111, 113, 112, 132, 114, 135, 137]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([84, 107, 137])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2)); + this.SpaceBeforeArrow = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(35, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(23, 70), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(54, formatting.Shared.TokenRange.FromTokens([19, 25])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 26), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(19, 26), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(26, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceBeforeCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 28), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(28, formatting.Shared.TokenRange.FromTokens([18, 20, 28, 25])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(16, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectTypeContext), 8)); + this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 56), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(56, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([116, 70, 83, 78, 74, 114, 113, 111, 112, 124, 132, 20, 38])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); + this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(88, 38), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8)); + this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(38, formatting.Shared.TokenRange.FromTokens([70, 18])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2)); + this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(115, 38), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8)); + this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([115, 38]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2)); + this.SpaceBetweenAsyncAndOpenParen = new formatting.Rule(formatting.RuleDescriptor.create1(119, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(119, 88), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(70, formatting.Shared.TokenRange.FromTokens([12, 13])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceBeforeJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 70), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNextTokenParentJsxAttribute, Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceBeforeSlashInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 40), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create1(40, 28), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 57), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create3(57, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8)); this.HighPriorityCommonRules = [ this.IgnoreBeforeComment, this.IgnoreAfterLineComment, this.NoSpaceBeforeColon, this.SpaceAfterColon, this.NoSpaceBeforeQuestionMark, this.SpaceAfterQuestionMarkInConditionalOperator, @@ -57682,41 +59213,41 @@ var ts; this.NoSpaceBeforeOpenParenInFuncDecl, this.SpaceBetweenStatements, this.SpaceAfterTryFinally ]; - this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNextTokenNotCloseBracket), 2)); - this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext), 8)); + this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(25, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNextTokenNotCloseBracket), 2)); + this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(25, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext), 8)); this.SpaceBeforeBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.SpaceAfterBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.NoSpaceBeforeBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 8)); this.NoSpaceAfterBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 8)); - this.SpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 2)); - this.NoSpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 8)); - this.NewLineBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 4), 1); - this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 4), 1); - this.NewLineBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), 4), 1); - this.SpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(23, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 2)); - this.NoSpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(23, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 8)); - this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(17, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceBetweenBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(19, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - 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.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([12, 13]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - 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.IsNonJsxSameLineTokenContext), 8)); - this.SpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([13, 14])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(15, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8)); - this.SpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(15, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2)); - this.NoSpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8)); - this.SpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2)); - 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)); - this.NoSpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(27, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 8)); - this.SpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(27, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 2)); + this.SpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 2)); + this.NoSpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 8)); + this.NewLineBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 4), 1); + this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 4), 1); + this.NewLineBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), 4), 1); + this.SpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 2)); + this.NoSpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 8)); + this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(18, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(18, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(18, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceBetweenBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(20, 21), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([13, 14]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([13, 14]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([14, 15])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([14, 15])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8)); + this.SpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2)); + this.NoSpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8)); + this.SpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2)); + this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(88, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(88, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8)); + this.NoSpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(28, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 8)); + this.SpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(28, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 2)); } Rules.prototype.getRuleName = function (rule) { var o = this; @@ -57728,35 +59259,35 @@ var ts; throw new Error("Unknown rule"); }; Rules.IsForContext = function (context) { - return context.contextNode.kind === 206; + return context.contextNode.kind === 207; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 187: case 188: - case 195: - case 238: - case 234: - case 154: - case 162: + case 189: + case 196: + case 239: + case 235: + case 155: case 163: + case 164: return true; - case 169: - case 223: - case 229: - case 218: - case 142: + case 170: + case 224: + case 230: + case 219: + case 143: case 255: + case 146: case 145: - case 144: - return context.currentTokenSpan.kind === 56 || context.nextTokenSpan.kind === 56; - case 207: - return context.currentTokenSpan.kind === 90 || context.nextTokenSpan.kind === 90; + return context.currentTokenSpan.kind === 57 || context.nextTokenSpan.kind === 57; case 208: - return context.currentTokenSpan.kind === 138 || context.nextTokenSpan.kind === 138; + return context.currentTokenSpan.kind === 91 || context.nextTokenSpan.kind === 91; + case 209: + return context.currentTokenSpan.kind === 139 || context.nextTokenSpan.kind === 139; } return false; }; @@ -57764,7 +59295,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 188; + return context.contextNode.kind === 189; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); @@ -57789,76 +59320,76 @@ var ts; return true; } switch (node.kind) { - case 199: + case 200: + case 228: + case 172: case 227: - case 171: - case 226: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 220: + case 221: + case 148: case 147: - case 146: - case 149: case 150: case 151: - case 179: - case 148: + case 152: case 180: - case 222: + case 149: + case 181: + case 223: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 220 || context.contextNode.kind === 179; + return context.contextNode.kind === 221 || context.contextNode.kind === 180; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 221: - case 192: case 222: - case 224: - case 159: + case 193: + case 223: case 225: - case 236: + case 160: + case 226: case 237: - case 230: - case 233: + case 238: + case 231: + case 234: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 221: - case 225: - case 224: - case 199: - case 252: + case 222: case 226: - case 213: + case 225: + case 200: + case 252: + case 227: + case 214: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 203: - case 213: - case 206: + case 204: + case 214: case 207: case 208: + case 209: + case 206: + case 217: case 205: - case 216: - case 204: - case 212: + case 213: case 252: return true; default: @@ -57866,31 +59397,31 @@ var ts; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 171; + return context.contextNode.kind === 172; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 174; + return context.contextNode.kind === 175; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 175; + return context.contextNode.kind === 176; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); }; Rules.IsPreviousTokenNotComma = function (context) { - return context.currentTokenSpan.kind !== 24; + return context.currentTokenSpan.kind !== 25; }; Rules.IsNextTokenNotCloseBracket = function (context) { - return context.nextTokenSpan.kind !== 20; + return context.nextTokenSpan.kind !== 21; }; Rules.IsArrowFunctionContext = function (context) { - return context.contextNode.kind === 180; + return context.contextNode.kind === 181; }; Rules.IsNonJsxSameLineTokenContext = function (context) { - return context.TokensAreOnSameLine() && context.contextNode.kind !== 244; + return context.TokensAreOnSameLine() && context.contextNode.kind !== 10; }; Rules.IsNonJsxElementContext = function (context) { - return context.contextNode.kind !== 241; + return context.contextNode.kind !== 242; }; Rules.IsJsxExpressionContext = function (context) { return context.contextNode.kind === 248; @@ -57902,7 +59433,7 @@ var ts; return context.contextNode.kind === 246; }; Rules.IsJsxSelfClosingElementContext = function (context) { - return context.contextNode.kind === 242; + return context.contextNode.kind === 243; }; Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); @@ -57917,41 +59448,41 @@ var ts; while (ts.isPartOfExpression(node)) { node = node.parent; } - return node.kind === 143; + return node.kind === 144; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 219 && + return context.currentTokenParent.kind === 220 && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { return context.formattingRequestKind !== 2; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 225; + return context.contextNode.kind === 226; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 159; + return context.contextNode.kind === 160; }; Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { - if (token.kind !== 25 && token.kind !== 27) { + if (token.kind !== 26 && token.kind !== 28) { return false; } switch (parent.kind) { - case 155: - case 177: - case 221: - case 192: + case 156: + case 178: case 222: - case 220: - case 179: + case 193: + case 223: + case 221: case 180: + case 181: + case 148: case 147: - case 146: - case 151: case 152: - case 174: + case 153: case 175: - case 194: + case 176: + case 195: return true; default: return false; @@ -57962,13 +59493,13 @@ var ts; Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsTypeAssertionContext = function (context) { - return context.contextNode.kind === 177; + return context.contextNode.kind === 178; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 103 && context.currentTokenParent.kind === 183; + return context.currentTokenSpan.kind === 104 && context.currentTokenParent.kind === 184; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 190 && context.contextNode.expression !== undefined; + return context.contextNode.kind === 191 && context.contextNode.expression !== undefined; }; return Rules; }()); @@ -57990,7 +59521,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 138 + 1; + this.mapRowLength = 139 + 1; this.map = new Array(this.mapRowLength * this.mapRowLength); var rulesBucketConstructionStateList = new Array(this.map.length); this.FillRules(rules, rulesBucketConstructionStateList); @@ -58003,6 +59534,7 @@ var ts; }); }; RulesMap.prototype.GetRuleBucketIndex = function (row, column) { + ts.Debug.assert(row <= 139 && column <= 139, "Must compute formatting context from tokens"); var rulesBucketIndex = (row * this.mapRowLength) + column; return rulesBucketIndex; }; @@ -58166,12 +59698,12 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0; token <= 138; token++) { + for (var token = 0; token <= 139; token++) { result.push(token); } return result; }; - TokenAllAccess.prototype.Contains = function (tokenValue) { + TokenAllAccess.prototype.Contains = function () { return true; }; TokenAllAccess.prototype.toString = function () { @@ -58210,17 +59742,17 @@ var ts; }()); TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3])); - TokenRange.Keywords = TokenRange.FromRange(70, 138); - TokenRange.BinaryOperators = TokenRange.FromRange(25, 68); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([90, 91, 138, 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.Keywords = TokenRange.FromRange(71, 139); + TokenRange.BinaryOperators = TokenRange.FromRange(26, 69); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([91, 92, 139, 117, 125]); + TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([42, 43, 51, 50]); + TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8, 70, 18, 20, 16, 98, 93]); + TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([70, 18, 98, 93]); + TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([70, 19, 21, 93]); + TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([70, 18, 98, 93]); + TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([70, 19, 21, 93]); TokenRange.Comments = TokenRange.FromTokens([2, 3]); - TokenRange.TypeNames = TokenRange.FromTokens([69, 130, 132, 120, 133, 103, 117]); + TokenRange.TypeNames = TokenRange.FromTokens([70, 131, 133, 121, 134, 104, 118]); Shared.TokenRange = TokenRange; })(Shared = formatting.Shared || (formatting.Shared = {})); })(formatting = ts.formatting || (ts.formatting = {})); @@ -58356,6 +59888,10 @@ var ts; (function (ts) { var formatting; (function (formatting) { + var Constants; + (function (Constants) { + Constants[Constants["Unknown"] = -1] = "Unknown"; + })(Constants || (Constants = {})); function formatOnEnter(position, sourceFile, rulesProvider, options) { var line = sourceFile.getLineAndCharacterOfPosition(position).line; if (line === 0) { @@ -58376,11 +59912,11 @@ var ts; } formatting.formatOnEnter = formatOnEnter; function formatOnSemicolon(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 23, sourceFile, options, rulesProvider, 3); + return formatOutermostParent(position, 24, sourceFile, options, rulesProvider, 3); } formatting.formatOnSemicolon = formatOnSemicolon; function formatOnClosingCurly(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 16, sourceFile, options, rulesProvider, 4); + return formatOutermostParent(position, 17, sourceFile, options, rulesProvider, 4); } formatting.formatOnClosingCurly = formatOnClosingCurly; function formatDocument(sourceFile, rulesProvider, options) { @@ -58428,15 +59964,15 @@ var ts; } function isListElement(parent, node) { switch (parent.kind) { - case 221: case 222: + case 223: return ts.rangeContainsRange(parent.members, node); - case 225: - var body = parent.body; - return body && body.kind === 226 && ts.rangeContainsRange(body.statements, node); - case 256: - case 199: case 226: + var body = parent.body; + return body && body.kind === 227 && ts.rangeContainsRange(body.statements, node); + case 256: + case 200: + case 227: return ts.rangeContainsRange(parent.statements, node); case 252: return ts.rangeContainsRange(parent.block.statements, node); @@ -58482,7 +60018,7 @@ var ts; index++; } }; - function rangeHasNoErrors(r) { + function rangeHasNoErrors() { return false; } } @@ -58594,18 +60130,18 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 221: return 73; - case 222: return 107; - case 220: return 87; - case 224: return 224; - case 149: return 123; - case 150: return 131; - case 147: + case 222: return 74; + case 223: return 108; + case 221: return 88; + case 225: return 225; + case 150: return 124; + case 151: return 132; + case 148: if (node.asteriskToken) { - return 37; + return 38; } - case 145: - case 142: + case 146: + case 143: return node.name.kind; } } @@ -58613,9 +60149,9 @@ var ts; return { getIndentationForComment: function (kind, tokenIndentation, container) { switch (kind) { - case 16: - case 20: - case 18: + case 17: + case 21: + case 19: return indentation + getEffectiveDelta(delta, container); } return tokenIndentation !== -1 ? tokenIndentation : indentation; @@ -58627,15 +60163,15 @@ var ts; } } switch (kind) { - case 15: case 16: - case 19: - case 20: case 17: + case 20: + case 21: case 18: - case 80: - case 104: - case 55: + case 19: + case 81: + case 105: + case 56: return indentation; default: return nodeStartLine !== line ? indentation + getEffectiveDelta(delta, container) : indentation; @@ -58715,17 +60251,17 @@ var ts; if (!formattingScanner.isOnToken()) { return inheritedIndentation; } - if (ts.isToken(child)) { + if (ts.isToken(child) && child.kind !== 10) { var tokenInfo = formattingScanner.readTokenInfo(child); - ts.Debug.assert(tokenInfo.token.end === child.end); + ts.Debug.assert(tokenInfo.token.end === child.end, "Token end is child end"); consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 143 ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 144 ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; - if (isFirstListItem && parent.kind === 170 && inheritedIndentation === -1) { + if (isFirstListItem && parent.kind === 171 && inheritedIndentation === -1) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -59029,41 +60565,41 @@ var ts; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 148: - case 220: - case 179: - case 147: - case 146: + case 149: + case 221: case 180: + case 148: + case 147: + case 181: if (node.typeParameters === list) { - return 25; + return 26; } else if (node.parameters === list) { - return 17; + return 18; } break; - case 174: case 175: + case 176: if (node.typeArguments === list) { - return 25; + return 26; } else if (node.arguments === list) { - return 17; + return 18; } break; - case 155: + case 156: if (node.typeArguments === list) { - return 25; + return 26; } } return 0; } function getCloseTokenForOpenToken(kind) { switch (kind) { - case 17: - return 18; - case 25: - return 27; + case 18: + return 19; + case 26: + return 28; } return 0; } @@ -59124,6 +60660,10 @@ var ts; (function (formatting) { var SmartIndenter; (function (SmartIndenter) { + var Value; + (function (Value) { + Value[Value["Unknown"] = -1] = "Unknown"; + })(Value || (Value = {})); function getIndentation(position, sourceFile, options) { if (position > sourceFile.text.length) { return getBaseIndentation(options); @@ -59152,7 +60692,7 @@ var ts; var lineStart = ts.getLineStartPositionForPosition(current_1, sourceFile); return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current_1, sourceFile, options); } - if (precedingToken.kind === 24 && precedingToken.parent.kind !== 187) { + if (precedingToken.kind === 25 && precedingToken.parent.kind !== 188) { var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1) { return actualIndentation; @@ -59265,10 +60805,10 @@ var ts; if (!nextToken) { return false; } - if (nextToken.kind === 15) { + if (nextToken.kind === 16) { return true; } - else if (nextToken.kind === 16) { + else if (nextToken.kind === 17) { var nextTokenStartLine = getStartLineAndCharacterForNode(nextToken, sourceFile).line; return lineAtPosition === nextTokenStartLine; } @@ -59278,8 +60818,8 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 203 && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 80, sourceFile); + if (parent.kind === 204 && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 81, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -59290,23 +60830,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 155: + case 156: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 171: + case 172: return node.parent.properties; - case 170: + case 171: return node.parent.elements; - case 220: - case 179: + case 221: case 180: + case 181: + case 148: case 147: - case 146: - case 151: - case 152: { + case 152: + case 153: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -59317,8 +60857,8 @@ var ts; } break; } - case 175: - case 174: { + case 176: + case 175: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -59343,11 +60883,11 @@ var ts; } } function getLineIndentationWhenExpressionIsInMultiLine(node, sourceFile, options) { - if (node.kind === 18) { + if (node.kind === 19) { return -1; } - if (node.parent && (node.parent.kind === 174 || - node.parent.kind === 175) && + if (node.parent && (node.parent.kind === 175 || + node.parent.kind === 176) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -59365,10 +60905,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 174: case 175: - case 172: + case 176: case 173: + case 174: node = node.expression; break; default: @@ -59382,7 +60922,7 @@ var ts; var node = list[index]; var lineAndCharacter = getStartLineAndCharacterForNode(node, sourceFile); for (var i = index - 1; i >= 0; i--) { - if (list[i].kind === 24) { + if (list[i].kind === 25) { continue; } var prevEndLine = sourceFile.getLineAndCharacterOfPosition(list[i].end).line; @@ -59422,48 +60962,48 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 202: - case 221: - case 192: + case 203: case 222: - case 224: + case 193: case 223: - case 170: - case 199: - case 226: + case 225: + case 224: case 171: - case 159: - case 161: + case 200: case 227: + case 172: + case 160: + case 162: + case 228: case 250: case 249: - case 178: - case 172: - case 174: + case 179: + case 173: case 175: - case 200: - case 218: - case 235: - case 211: - case 188: - case 168: - case 167: - case 243: - case 242: - case 248: - case 146: - case 151: - case 152: - case 142: - case 156: - case 157: - case 164: case 176: - case 184: - case 237: - case 233: + case 201: + case 219: + case 236: + case 212: + case 189: + case 169: + case 168: + case 244: + case 243: + case 248: + case 147: + case 152: + case 153: + case 143: + case 157: + case 158: + case 165: + case 177: + case 185: case 238: case 234: + case 239: + case 235: return true; } return false; @@ -59471,26 +61011,26 @@ var ts; function nodeWillIndentChild(parent, child, indentByDefault) { var childKind = child ? child.kind : 0; switch (parent.kind) { - case 204: case 205: - case 207: - case 208: case 206: - case 203: - case 220: - case 179: - case 147: + case 208: + case 209: + case 207: + case 204: + case 221: case 180: case 148: + case 181: case 149: case 150: - return childKind !== 199; - case 236: - return childKind !== 237; - case 230: - return childKind !== 231 || - (child.namedBindings && child.namedBindings.kind !== 233); - case 241: + case 151: + return childKind !== 200; + case 237: + return childKind !== 238; + case 231: + return childKind !== 232 || + (child.namedBindings && child.namedBindings.kind !== 234); + case 242: return childKind !== 245; } return indentByDefault; @@ -59549,7 +61089,7 @@ var ts; getCodeActions: function (context) { var sourceFile = context.sourceFile; var token = ts.getTokenAtPosition(sourceFile, context.span.start); - if (token.kind !== 121) { + if (token.kind !== 122) { return undefined; } var newPosition = getOpenBraceEnd(token.parent, sourceFile); @@ -59564,7 +61104,7 @@ var ts; getCodeActions: function (context) { var sourceFile = context.sourceFile; var token = ts.getTokenAtPosition(sourceFile, context.span.start); - if (token.kind !== 97) { + if (token.kind !== 98) { return undefined; } var constructor = ts.getContainingFunction(token); @@ -59572,7 +61112,7 @@ var ts; if (!superCall) { return undefined; } - if (superCall.expression && superCall.expression.kind == 174) { + if (superCall.expression && superCall.expression.kind == 175) { var arguments_1 = superCall.expression.arguments; for (var i = 0; i < arguments_1.length; i++) { if (arguments_1[i].expression === token) { @@ -59596,7 +61136,7 @@ var ts; changes: changes }]; function findSuperCall(n) { - if (n.kind === 202 && ts.isSuperCall(n.expression)) { + if (n.kind === 203 && ts.isSuperCall(n.expression)) { return n; } if (ts.isFunctionLike(n)) { @@ -59612,8 +61152,8 @@ var ts; (function (ts) { ts.servicesVersion = "0.5"; function createNode(kind, pos, end, parent) { - var node = kind >= 139 ? new NodeObject(kind, pos, end) : - kind === 69 ? new IdentifierObject(69, pos, end) : + var node = kind >= 140 ? new NodeObject(kind, pos, end) : + kind === 70 ? new IdentifierObject(70, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; return node; @@ -59690,7 +61230,7 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 139) { + if (this.kind >= 140) { ts.scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos_3 = this.pos; @@ -59748,7 +61288,7 @@ var ts; return undefined; } var child = children[0]; - return child.kind < 139 ? child : child.getFirstToken(sourceFile); + return child.kind < 140 ? child : child.getFirstToken(sourceFile); }; NodeObject.prototype.getLastToken = function (sourceFile) { var children = this.getChildren(sourceFile); @@ -59756,7 +61296,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 139 ? child : child.getLastToken(sourceFile); + return child.kind < 140 ? child : child.getLastToken(sourceFile); }; return NodeObject; }()); @@ -59794,19 +61334,19 @@ var ts; TokenOrIdentifierObject.prototype.getText = function (sourceFile) { return (sourceFile || this.getSourceFile()).text.substring(this.getStart(), this.getEnd()); }; - TokenOrIdentifierObject.prototype.getChildCount = function (sourceFile) { + TokenOrIdentifierObject.prototype.getChildCount = function () { return 0; }; - TokenOrIdentifierObject.prototype.getChildAt = function (index, sourceFile) { + TokenOrIdentifierObject.prototype.getChildAt = function () { return undefined; }; - TokenOrIdentifierObject.prototype.getChildren = function (sourceFile) { + TokenOrIdentifierObject.prototype.getChildren = function () { return ts.emptyArray; }; - TokenOrIdentifierObject.prototype.getFirstToken = function (sourceFile) { + TokenOrIdentifierObject.prototype.getFirstToken = function () { return undefined; }; - TokenOrIdentifierObject.prototype.getLastToken = function (sourceFile) { + TokenOrIdentifierObject.prototype.getLastToken = function () { return undefined; }; return TokenOrIdentifierObject; @@ -59827,7 +61367,7 @@ var ts; }; SymbolObject.prototype.getDocumentationComment = function () { if (this.documentationComment === undefined) { - this.documentationComment = ts.JsDoc.getJsDocCommentsFromDeclarations(this.declarations, this.name, !(this.flags & 4)); + this.documentationComment = ts.JsDoc.getJsDocCommentsFromDeclarations(this.declarations); } return this.documentationComment; }; @@ -59844,12 +61384,12 @@ var ts; }(TokenOrIdentifierObject)); var IdentifierObject = (function (_super) { __extends(IdentifierObject, _super); - function IdentifierObject(kind, pos, end) { + function IdentifierObject(_kind, pos, end) { return _super.call(this, pos, end) || this; } return IdentifierObject; }(TokenOrIdentifierObject)); - IdentifierObject.prototype.kind = 69; + IdentifierObject.prototype.kind = 70; var TypeObject = (function () { function TypeObject(checker, flags) { this.checker = checker; @@ -59910,7 +61450,7 @@ var ts; }; SignatureObject.prototype.getDocumentationComment = function () { if (this.documentationComment === undefined) { - this.documentationComment = this.declaration ? ts.JsDoc.getJsDocCommentsFromDeclarations([this.declaration], undefined, false) : []; + this.documentationComment = this.declaration ? ts.JsDoc.getJsDocCommentsFromDeclarations([this.declaration]) : []; } return this.documentationComment; }; @@ -59958,9 +61498,9 @@ var ts; if (result_6 !== undefined) { return result_6; } - if (declaration.name.kind === 140) { + if (declaration.name.kind === 141) { var expr = declaration.name.expression; - if (expr.kind === 172) { + if (expr.kind === 173) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -59970,7 +61510,7 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 69 || + if (node.kind === 70 || node.kind === 9 || node.kind === 8) { return node.text; @@ -59980,10 +61520,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 220: - case 179: + case 221: + case 180: + case 148: case 147: - case 146: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -60000,30 +61540,30 @@ var ts; ts.forEachChild(node, visit); } break; - case 221: - case 192: case 222: + case 193: case 223: case 224: case 225: - case 229: - case 238: - case 234: - case 229: - case 231: + case 226: + case 230: + case 239: + case 235: + case 230: case 232: - case 149: + case 233: case 150: - case 159: + case 151: + case 160: addDeclaration(node); ts.forEachChild(node, visit); break; - case 142: + case 143: if (!ts.hasModifier(node, 92)) { break; } - case 218: - case 169: { + case 219: + case 170: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -60033,23 +61573,23 @@ var ts; visit(decl.initializer); } case 255: + case 146: case 145: - case 144: addDeclaration(node); break; - case 236: + case 237: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 230: + case 231: var importClause = node.importClause; if (importClause) { if (importClause.name) { addDeclaration(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 232) { + if (importClause.namedBindings.kind === 233) { addDeclaration(importClause.namedBindings); } else { @@ -60073,7 +61613,7 @@ var ts; getSourceFileConstructor: function () { return SourceFileObject; }, getSymbolConstructor: function () { return SymbolObject; }, getTypeConstructor: function () { return TypeObject; }, - getSignatureConstructor: function () { return SignatureObject; } + getSignatureConstructor: function () { return SignatureObject; }, }; } function toEditorSettings(optionsAsMap) { @@ -60165,7 +61705,7 @@ var ts; }; HostCache.prototype.getRootFileNames = function () { var fileNames = []; - this.fileNameToEntry.forEachValue(function (path, value) { + this.fileNameToEntry.forEachValue(function (_path, value) { if (value) { fileNames.push(value.hostFileName); } @@ -60195,7 +61735,7 @@ var ts; var version = this.host.getScriptVersion(fileName); var sourceFile; if (this.currentFileName !== fileName) { - sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 2, version, true, scriptKind); + sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 4, version, true, scriptKind); } else if (this.currentFileVersion !== version) { var editRange = scriptSnapshot.getChangeRange(this.currentFileScriptSnapshot); @@ -60348,7 +61888,7 @@ var ts; useCaseSensitiveFileNames: function () { return useCaseSensitivefileNames; }, getNewLine: function () { return ts.getNewLineOrDefaultFromHost(host); }, getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); }, - writeFile: function (fileName, data, writeByteOrderMark) { }, + writeFile: function () { }, getCurrentDirectory: function () { return currentDirectory; }, fileExists: function (fileName) { return hostCache.getOrCreateEntry(fileName) !== undefined; @@ -60490,12 +62030,12 @@ var ts; var symbol = typeChecker.getSymbolAtLocation(node); if (!symbol || typeChecker.isUnknownSymbol(symbol)) { switch (node.kind) { - case 69: - case 172: - case 139: - case 97: - case 165: - case 95: + case 70: + case 173: + case 140: + case 98: + case 166: + case 96: var type = typeChecker.getTypeAtLocation(node); if (type) { return { @@ -60616,23 +62156,23 @@ var ts; function getSourceFile(fileName) { return getNonBoundSourceFile(fileName); } - function getNameOrDottedNameSpan(fileName, startPos, endPos) { + function getNameOrDottedNameSpan(fileName, startPos, _endPos) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); var node = ts.getTouchingPropertyName(sourceFile, startPos); if (node === sourceFile) { return; } switch (node.kind) { - case 172: - case 139: + case 173: + case 140: case 9: - case 84: - case 99: - case 93: - case 95: - case 97: - case 165: - case 69: + case 85: + case 100: + case 94: + case 96: + case 98: + case 166: + case 70: break; default: return; @@ -60643,7 +62183,7 @@ var ts; nodeForStartPos = nodeForStartPos.parent; } else if (ts.isNameOfModuleDeclaration(nodeForStartPos)) { - if (nodeForStartPos.parent.parent.kind === 225 && + if (nodeForStartPos.parent.parent.kind === 226 && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { nodeForStartPos = nodeForStartPos.parent.parent.name; } @@ -60723,14 +62263,14 @@ var ts; return result; function getMatchingTokenKind(token) { switch (token.kind) { - case 15: return 16; - case 17: return 18; - case 19: return 20; - case 25: return 27; - case 16: return 15; - case 18: return 17; - case 20: return 19; - case 27: return 25; + case 16: return 17; + case 18: return 19; + case 20: return 21; + case 26: return 28; + case 17: return 16; + case 19: return 18; + case 21: return 20; + case 28: return 26; } return undefined; } @@ -60933,13 +62473,13 @@ var ts; sourceFile.nameTable = nameTable; function walk(node) { switch (node.kind) { - case 69: + case 70: nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; break; case 9: case 8: if (ts.isDeclarationName(node) || - node.parent.kind === 240 || + node.parent.kind === 241 || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node)) { nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; @@ -60959,7 +62499,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 173 && + node.parent.kind === 174 && node.parent.argumentExpression === node; } function getDefaultLibFilePath(options) { @@ -60974,6 +62514,933 @@ var ts; } initializeServices(); })(ts || (ts = {})); +var debugObjectHost = (function () { return this; })(); +var ts; +(function (ts) { + function logInternalError(logger, err) { + if (logger) { + logger.log("*INTERNAL ERROR* - Exception in typescript services: " + err.message); + } + } + var ScriptSnapshotShimAdapter = (function () { + function ScriptSnapshotShimAdapter(scriptSnapshotShim) { + this.scriptSnapshotShim = scriptSnapshotShim; + } + ScriptSnapshotShimAdapter.prototype.getText = function (start, end) { + return this.scriptSnapshotShim.getText(start, end); + }; + ScriptSnapshotShimAdapter.prototype.getLength = function () { + return this.scriptSnapshotShim.getLength(); + }; + ScriptSnapshotShimAdapter.prototype.getChangeRange = function (oldSnapshot) { + var oldSnapshotShim = oldSnapshot; + var encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim); + if (encoded == null) { + return null; + } + var decoded = JSON.parse(encoded); + return ts.createTextChangeRange(ts.createTextSpan(decoded.span.start, decoded.span.length), decoded.newLength); + }; + ScriptSnapshotShimAdapter.prototype.dispose = function () { + if ("dispose" in this.scriptSnapshotShim) { + this.scriptSnapshotShim.dispose(); + } + }; + return ScriptSnapshotShimAdapter; + }()); + var LanguageServiceShimHostAdapter = (function () { + function LanguageServiceShimHostAdapter(shimHost) { + var _this = this; + this.shimHost = shimHost; + this.loggingEnabled = false; + this.tracingEnabled = false; + if ("getModuleResolutionsForFile" in this.shimHost) { + this.resolveModuleNames = function (moduleNames, containingFile) { + var resolutionsInFile = JSON.parse(_this.shimHost.getModuleResolutionsForFile(containingFile)); + return ts.map(moduleNames, function (name) { + var result = ts.getProperty(resolutionsInFile, name); + return result ? { resolvedFileName: result } : undefined; + }); + }; + } + if ("directoryExists" in this.shimHost) { + this.directoryExists = function (directoryName) { return _this.shimHost.directoryExists(directoryName); }; + } + if ("getTypeReferenceDirectiveResolutionsForFile" in this.shimHost) { + this.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile) { + var typeDirectivesForFile = JSON.parse(_this.shimHost.getTypeReferenceDirectiveResolutionsForFile(containingFile)); + return ts.map(typeDirectiveNames, function (name) { return ts.getProperty(typeDirectivesForFile, name); }); + }; + } + } + LanguageServiceShimHostAdapter.prototype.log = function (s) { + if (this.loggingEnabled) { + this.shimHost.log(s); + } + }; + LanguageServiceShimHostAdapter.prototype.trace = function (s) { + if (this.tracingEnabled) { + this.shimHost.trace(s); + } + }; + LanguageServiceShimHostAdapter.prototype.error = function (s) { + this.shimHost.error(s); + }; + LanguageServiceShimHostAdapter.prototype.getProjectVersion = function () { + if (!this.shimHost.getProjectVersion) { + return undefined; + } + return this.shimHost.getProjectVersion(); + }; + LanguageServiceShimHostAdapter.prototype.getTypeRootsVersion = function () { + if (!this.shimHost.getTypeRootsVersion) { + return 0; + } + return this.shimHost.getTypeRootsVersion(); + }; + LanguageServiceShimHostAdapter.prototype.useCaseSensitiveFileNames = function () { + return this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false; + }; + LanguageServiceShimHostAdapter.prototype.getCompilationSettings = function () { + var settingsJson = this.shimHost.getCompilationSettings(); + if (settingsJson == null || settingsJson == "") { + throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); + } + return JSON.parse(settingsJson); + }; + LanguageServiceShimHostAdapter.prototype.getScriptFileNames = function () { + var encoded = this.shimHost.getScriptFileNames(); + return this.files = JSON.parse(encoded); + }; + LanguageServiceShimHostAdapter.prototype.getScriptSnapshot = function (fileName) { + var scriptSnapshot = this.shimHost.getScriptSnapshot(fileName); + return scriptSnapshot && new ScriptSnapshotShimAdapter(scriptSnapshot); + }; + LanguageServiceShimHostAdapter.prototype.getScriptKind = function (fileName) { + if ("getScriptKind" in this.shimHost) { + return this.shimHost.getScriptKind(fileName); + } + else { + return 0; + } + }; + LanguageServiceShimHostAdapter.prototype.getScriptVersion = function (fileName) { + return this.shimHost.getScriptVersion(fileName); + }; + LanguageServiceShimHostAdapter.prototype.getLocalizedDiagnosticMessages = function () { + var diagnosticMessagesJson = this.shimHost.getLocalizedDiagnosticMessages(); + if (diagnosticMessagesJson == null || diagnosticMessagesJson == "") { + return null; + } + try { + return JSON.parse(diagnosticMessagesJson); + } + catch (e) { + this.log(e.description || "diagnosticMessages.generated.json has invalid JSON format"); + return null; + } + }; + LanguageServiceShimHostAdapter.prototype.getCancellationToken = function () { + var hostCancellationToken = this.shimHost.getCancellationToken(); + return new ThrottledCancellationToken(hostCancellationToken); + }; + LanguageServiceShimHostAdapter.prototype.getCurrentDirectory = function () { + return this.shimHost.getCurrentDirectory(); + }; + LanguageServiceShimHostAdapter.prototype.getDirectories = function (path) { + return JSON.parse(this.shimHost.getDirectories(path)); + }; + LanguageServiceShimHostAdapter.prototype.getDefaultLibFileName = function (options) { + return this.shimHost.getDefaultLibFileName(JSON.stringify(options)); + }; + LanguageServiceShimHostAdapter.prototype.readDirectory = function (path, extensions, exclude, include, depth) { + var pattern = ts.getFileMatcherPatterns(path, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); + return JSON.parse(this.shimHost.readDirectory(path, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); + }; + LanguageServiceShimHostAdapter.prototype.readFile = function (path, encoding) { + return this.shimHost.readFile(path, encoding); + }; + LanguageServiceShimHostAdapter.prototype.fileExists = function (path) { + return this.shimHost.fileExists(path); + }; + return LanguageServiceShimHostAdapter; + }()); + ts.LanguageServiceShimHostAdapter = LanguageServiceShimHostAdapter; + var ThrottledCancellationToken = (function () { + function ThrottledCancellationToken(hostCancellationToken) { + this.hostCancellationToken = hostCancellationToken; + this.lastCancellationCheckTime = 0; + } + ThrottledCancellationToken.prototype.isCancellationRequested = function () { + var time = ts.timestamp(); + var duration = Math.abs(time - this.lastCancellationCheckTime); + if (duration > 10) { + this.lastCancellationCheckTime = time; + return this.hostCancellationToken.isCancellationRequested(); + } + return false; + }; + return ThrottledCancellationToken; + }()); + var CoreServicesShimHostAdapter = (function () { + function CoreServicesShimHostAdapter(shimHost) { + var _this = this; + this.shimHost = shimHost; + this.useCaseSensitiveFileNames = this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false; + if ("directoryExists" in this.shimHost) { + this.directoryExists = function (directoryName) { return _this.shimHost.directoryExists(directoryName); }; + } + if ("realpath" in this.shimHost) { + this.realpath = function (path) { return _this.shimHost.realpath(path); }; + } + } + CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extensions, exclude, include, depth) { + try { + var pattern = ts.getFileMatcherPatterns(rootDir, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); + return JSON.parse(this.shimHost.readDirectory(rootDir, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); + } + catch (e) { + var results = []; + for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) { + var extension = extensions_2[_i]; + for (var _a = 0, _b = this.readDirectoryFallback(rootDir, extension, exclude); _a < _b.length; _a++) { + var file = _b[_a]; + if (!ts.contains(results, file)) { + results.push(file); + } + } + } + return results; + } + }; + CoreServicesShimHostAdapter.prototype.fileExists = function (fileName) { + return this.shimHost.fileExists(fileName); + }; + CoreServicesShimHostAdapter.prototype.readFile = function (fileName) { + return this.shimHost.readFile(fileName); + }; + CoreServicesShimHostAdapter.prototype.readDirectoryFallback = function (rootDir, extension, exclude) { + return JSON.parse(this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude))); + }; + CoreServicesShimHostAdapter.prototype.getDirectories = function (path) { + return JSON.parse(this.shimHost.getDirectories(path)); + }; + return CoreServicesShimHostAdapter; + }()); + ts.CoreServicesShimHostAdapter = CoreServicesShimHostAdapter; + function simpleForwardCall(logger, actionDescription, action, logPerformance) { + var start; + if (logPerformance) { + logger.log(actionDescription); + start = ts.timestamp(); + } + var result = action(); + if (logPerformance) { + var end = ts.timestamp(); + logger.log(actionDescription + " completed in " + (end - start) + " msec"); + if (typeof result === "string") { + var str = result; + if (str.length > 128) { + str = str.substring(0, 128) + "..."; + } + logger.log(" result.length=" + str.length + ", result='" + JSON.stringify(str) + "'"); + } + } + return result; + } + function forwardJSONCall(logger, actionDescription, action, logPerformance) { + return forwardCall(logger, actionDescription, true, action, logPerformance); + } + function forwardCall(logger, actionDescription, returnJson, action, logPerformance) { + try { + var result = simpleForwardCall(logger, actionDescription, action, logPerformance); + return returnJson ? JSON.stringify({ result: result }) : result; + } + catch (err) { + if (err instanceof ts.OperationCanceledException) { + return JSON.stringify({ canceled: true }); + } + logInternalError(logger, err); + err.description = actionDescription; + return JSON.stringify({ error: err }); + } + } + var ShimBase = (function () { + function ShimBase(factory) { + this.factory = factory; + factory.registerShim(this); + } + ShimBase.prototype.dispose = function (_dummy) { + this.factory.unregisterShim(this); + }; + return ShimBase; + }()); + function realizeDiagnostics(diagnostics, newLine) { + return diagnostics.map(function (d) { return realizeDiagnostic(d, newLine); }); + } + ts.realizeDiagnostics = realizeDiagnostics; + function realizeDiagnostic(diagnostic, newLine) { + return { + message: ts.flattenDiagnosticMessageText(diagnostic.messageText, newLine), + start: diagnostic.start, + length: diagnostic.length, + category: ts.DiagnosticCategory[diagnostic.category].toLowerCase(), + code: diagnostic.code + }; + } + var LanguageServiceShimObject = (function (_super) { + __extends(LanguageServiceShimObject, _super); + function LanguageServiceShimObject(factory, host, languageService) { + var _this = _super.call(this, factory) || this; + _this.host = host; + _this.languageService = languageService; + _this.logPerformance = false; + _this.logger = _this.host; + return _this; + } + LanguageServiceShimObject.prototype.forwardJSONCall = function (actionDescription, action) { + return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); + }; + LanguageServiceShimObject.prototype.dispose = function (dummy) { + this.logger.log("dispose()"); + this.languageService.dispose(); + this.languageService = null; + if (debugObjectHost && debugObjectHost.CollectGarbage) { + debugObjectHost.CollectGarbage(); + this.logger.log("CollectGarbage()"); + } + this.logger = null; + _super.prototype.dispose.call(this, dummy); + }; + LanguageServiceShimObject.prototype.refresh = function (throwOnError) { + this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; }); + }; + LanguageServiceShimObject.prototype.cleanupSemanticCache = function () { + var _this = this; + this.forwardJSONCall("cleanupSemanticCache()", function () { + _this.languageService.cleanupSemanticCache(); + return null; + }); + }; + LanguageServiceShimObject.prototype.realizeDiagnostics = function (diagnostics) { + var newLine = ts.getNewLineOrDefaultFromHost(this.host); + return ts.realizeDiagnostics(diagnostics, newLine); + }; + LanguageServiceShimObject.prototype.getSyntacticClassifications = function (fileName, start, length) { + var _this = this; + return this.forwardJSONCall("getSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSyntacticClassifications(fileName, ts.createTextSpan(start, length)); }); + }; + LanguageServiceShimObject.prototype.getSemanticClassifications = function (fileName, start, length) { + var _this = this; + return this.forwardJSONCall("getSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSemanticClassifications(fileName, ts.createTextSpan(start, length)); }); + }; + LanguageServiceShimObject.prototype.getEncodedSyntacticClassifications = function (fileName, start, length) { + var _this = this; + return this.forwardJSONCall("getEncodedSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return convertClassifications(_this.languageService.getEncodedSyntacticClassifications(fileName, ts.createTextSpan(start, length))); }); + }; + LanguageServiceShimObject.prototype.getEncodedSemanticClassifications = function (fileName, start, length) { + var _this = this; + return this.forwardJSONCall("getEncodedSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return convertClassifications(_this.languageService.getEncodedSemanticClassifications(fileName, ts.createTextSpan(start, length))); }); + }; + LanguageServiceShimObject.prototype.getSyntacticDiagnostics = function (fileName) { + var _this = this; + return this.forwardJSONCall("getSyntacticDiagnostics('" + fileName + "')", function () { + var diagnostics = _this.languageService.getSyntacticDiagnostics(fileName); + return _this.realizeDiagnostics(diagnostics); + }); + }; + LanguageServiceShimObject.prototype.getSemanticDiagnostics = function (fileName) { + var _this = this; + return this.forwardJSONCall("getSemanticDiagnostics('" + fileName + "')", function () { + var diagnostics = _this.languageService.getSemanticDiagnostics(fileName); + return _this.realizeDiagnostics(diagnostics); + }); + }; + LanguageServiceShimObject.prototype.getCompilerOptionsDiagnostics = function () { + var _this = this; + return this.forwardJSONCall("getCompilerOptionsDiagnostics()", function () { + var diagnostics = _this.languageService.getCompilerOptionsDiagnostics(); + return _this.realizeDiagnostics(diagnostics); + }); + }; + LanguageServiceShimObject.prototype.getQuickInfoAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getQuickInfoAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getQuickInfoAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getNameOrDottedNameSpan = function (fileName, startPos, endPos) { + var _this = this; + return this.forwardJSONCall("getNameOrDottedNameSpan('" + fileName + "', " + startPos + ", " + endPos + ")", function () { return _this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos); }); + }; + LanguageServiceShimObject.prototype.getBreakpointStatementAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getBreakpointStatementAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBreakpointStatementAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getSignatureHelpItems = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getSignatureHelpItems('" + fileName + "', " + position + ")", function () { return _this.languageService.getSignatureHelpItems(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getDefinitionAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDefinitionAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getTypeDefinitionAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getTypeDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getTypeDefinitionAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getImplementationAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getImplementationAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getImplementationAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position); }); + }; + LanguageServiceShimObject.prototype.findRenameLocations = function (fileName, position, findInStrings, findInComments) { + var _this = this; + return this.forwardJSONCall("findRenameLocations('" + fileName + "', " + position + ", " + findInStrings + ", " + findInComments + ")", function () { return _this.languageService.findRenameLocations(fileName, position, findInStrings, findInComments); }); + }; + LanguageServiceShimObject.prototype.getBraceMatchingAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getBraceMatchingAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBraceMatchingAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.isValidBraceCompletionAtPosition = function (fileName, position, openingBrace) { + var _this = this; + return this.forwardJSONCall("isValidBraceCompletionAtPosition('" + fileName + "', " + position + ", " + openingBrace + ")", function () { return _this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace); }); + }; + LanguageServiceShimObject.prototype.getIndentationAtPosition = function (fileName, position, options) { + var _this = this; + return this.forwardJSONCall("getIndentationAtPosition('" + fileName + "', " + position + ")", function () { + var localOptions = JSON.parse(options); + return _this.languageService.getIndentationAtPosition(fileName, position, localOptions); + }); + }; + LanguageServiceShimObject.prototype.getReferencesAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getReferencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getReferencesAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.findReferences = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("findReferences('" + fileName + "', " + position + ")", function () { return _this.languageService.findReferences(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getOccurrencesAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getOccurrencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getOccurrencesAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getDocumentHighlights = function (fileName, position, filesToSearch) { + var _this = this; + return this.forwardJSONCall("getDocumentHighlights('" + fileName + "', " + position + ")", function () { + var results = _this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); + var normalizedName = ts.normalizeSlashes(fileName).toLowerCase(); + return ts.filter(results, function (r) { return ts.normalizeSlashes(r.fileName).toLowerCase() === normalizedName; }); + }); + }; + LanguageServiceShimObject.prototype.getCompletionsAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getCompletionsAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName) { + var _this = this; + return this.forwardJSONCall("getCompletionEntryDetails('" + fileName + "', " + position + ", '" + entryName + "')", function () { return _this.languageService.getCompletionEntryDetails(fileName, position, entryName); }); + }; + LanguageServiceShimObject.prototype.getFormattingEditsForRange = function (fileName, start, end, options) { + var _this = this; + return this.forwardJSONCall("getFormattingEditsForRange('" + fileName + "', " + start + ", " + end + ")", function () { + var localOptions = JSON.parse(options); + return _this.languageService.getFormattingEditsForRange(fileName, start, end, localOptions); + }); + }; + LanguageServiceShimObject.prototype.getFormattingEditsForDocument = function (fileName, options) { + var _this = this; + return this.forwardJSONCall("getFormattingEditsForDocument('" + fileName + "')", function () { + var localOptions = JSON.parse(options); + return _this.languageService.getFormattingEditsForDocument(fileName, localOptions); + }); + }; + LanguageServiceShimObject.prototype.getFormattingEditsAfterKeystroke = function (fileName, position, key, options) { + var _this = this; + return this.forwardJSONCall("getFormattingEditsAfterKeystroke('" + fileName + "', " + position + ", '" + key + "')", function () { + var localOptions = JSON.parse(options); + return _this.languageService.getFormattingEditsAfterKeystroke(fileName, position, key, localOptions); + }); + }; + LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position); }); + }; + LanguageServiceShimObject.prototype.getNavigateToItems = function (searchValue, maxResultCount, fileName) { + var _this = this; + return this.forwardJSONCall("getNavigateToItems('" + searchValue + "', " + maxResultCount + ", " + fileName + ")", function () { return _this.languageService.getNavigateToItems(searchValue, maxResultCount, fileName); }); + }; + LanguageServiceShimObject.prototype.getNavigationBarItems = function (fileName) { + var _this = this; + return this.forwardJSONCall("getNavigationBarItems('" + fileName + "')", function () { return _this.languageService.getNavigationBarItems(fileName); }); + }; + LanguageServiceShimObject.prototype.getNavigationTree = function (fileName) { + var _this = this; + return this.forwardJSONCall("getNavigationTree('" + fileName + "')", function () { return _this.languageService.getNavigationTree(fileName); }); + }; + LanguageServiceShimObject.prototype.getOutliningSpans = function (fileName) { + var _this = this; + return this.forwardJSONCall("getOutliningSpans('" + fileName + "')", function () { return _this.languageService.getOutliningSpans(fileName); }); + }; + LanguageServiceShimObject.prototype.getTodoComments = function (fileName, descriptors) { + var _this = this; + return this.forwardJSONCall("getTodoComments('" + fileName + "')", function () { return _this.languageService.getTodoComments(fileName, JSON.parse(descriptors)); }); + }; + LanguageServiceShimObject.prototype.getEmitOutput = function (fileName) { + var _this = this; + return this.forwardJSONCall("getEmitOutput('" + fileName + "')", function () { return _this.languageService.getEmitOutput(fileName); }); + }; + LanguageServiceShimObject.prototype.getEmitOutputObject = function (fileName) { + var _this = this; + return forwardCall(this.logger, "getEmitOutput('" + fileName + "')", false, function () { return _this.languageService.getEmitOutput(fileName); }, this.logPerformance); + }; + return LanguageServiceShimObject; + }(ShimBase)); + function convertClassifications(classifications) { + return { spans: classifications.spans.join(","), endOfLineState: classifications.endOfLineState }; + } + var ClassifierShimObject = (function (_super) { + __extends(ClassifierShimObject, _super); + function ClassifierShimObject(factory, logger) { + var _this = _super.call(this, factory) || this; + _this.logger = logger; + _this.logPerformance = false; + _this.classifier = ts.createClassifier(); + return _this; + } + ClassifierShimObject.prototype.getEncodedLexicalClassifications = function (text, lexState, syntacticClassifierAbsent) { + var _this = this; + return forwardJSONCall(this.logger, "getEncodedLexicalClassifications", function () { return convertClassifications(_this.classifier.getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent)); }, this.logPerformance); + }; + ClassifierShimObject.prototype.getClassificationsForLine = function (text, lexState, classifyKeywordsInGenerics) { + var classification = this.classifier.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics); + var result = ""; + for (var _i = 0, _a = classification.entries; _i < _a.length; _i++) { + var item = _a[_i]; + result += item.length + "\n"; + result += item.classification + "\n"; + } + result += classification.finalLexState; + return result; + }; + return ClassifierShimObject; + }(ShimBase)); + var CoreServicesShimObject = (function (_super) { + __extends(CoreServicesShimObject, _super); + function CoreServicesShimObject(factory, logger, host) { + var _this = _super.call(this, factory) || this; + _this.logger = logger; + _this.host = host; + _this.logPerformance = false; + return _this; + } + CoreServicesShimObject.prototype.forwardJSONCall = function (actionDescription, action) { + return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); + }; + CoreServicesShimObject.prototype.resolveModuleName = function (fileName, moduleName, compilerOptionsJson) { + var _this = this; + return this.forwardJSONCall("resolveModuleName('" + fileName + "')", function () { + var compilerOptions = JSON.parse(compilerOptionsJson); + var result = ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host); + return { + resolvedFileName: result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined, + failedLookupLocations: result.failedLookupLocations + }; + }); + }; + CoreServicesShimObject.prototype.resolveTypeReferenceDirective = function (fileName, typeReferenceDirective, compilerOptionsJson) { + var _this = this; + return this.forwardJSONCall("resolveTypeReferenceDirective(" + fileName + ")", function () { + var compilerOptions = JSON.parse(compilerOptionsJson); + var result = ts.resolveTypeReferenceDirective(typeReferenceDirective, ts.normalizeSlashes(fileName), compilerOptions, _this.host); + return { + resolvedFileName: result.resolvedTypeReferenceDirective ? result.resolvedTypeReferenceDirective.resolvedFileName : undefined, + primary: result.resolvedTypeReferenceDirective ? result.resolvedTypeReferenceDirective.primary : true, + failedLookupLocations: result.failedLookupLocations + }; + }); + }; + CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { + var _this = this; + return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { + var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()), true, true); + return { + referencedFiles: _this.convertFileReferences(result.referencedFiles), + importedFiles: _this.convertFileReferences(result.importedFiles), + ambientExternalModules: result.ambientExternalModules, + isLibFile: result.isLibFile, + typeReferenceDirectives: _this.convertFileReferences(result.typeReferenceDirectives) + }; + }); + }; + CoreServicesShimObject.prototype.getAutomaticTypeDirectiveNames = function (compilerOptionsJson) { + var _this = this; + return this.forwardJSONCall("getAutomaticTypeDirectiveNames('" + compilerOptionsJson + "')", function () { + var compilerOptions = JSON.parse(compilerOptionsJson); + return ts.getAutomaticTypeDirectiveNames(compilerOptions, _this.host); + }); + }; + CoreServicesShimObject.prototype.convertFileReferences = function (refs) { + if (!refs) { + return undefined; + } + var result = []; + for (var _i = 0, refs_2 = refs; _i < refs_2.length; _i++) { + var ref = refs_2[_i]; + result.push({ + path: ts.normalizeSlashes(ref.fileName), + position: ref.pos, + length: ref.end - ref.pos + }); + } + return result; + }; + CoreServicesShimObject.prototype.getTSConfigFileInfo = function (fileName, sourceTextSnapshot) { + var _this = this; + return this.forwardJSONCall("getTSConfigFileInfo('" + fileName + "')", function () { + var text = sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()); + var result = ts.parseConfigFileTextToJson(fileName, text); + if (result.error) { + return { + options: {}, + typingOptions: {}, + files: [], + raw: {}, + errors: [realizeDiagnostic(result.error, "\r\n")] + }; + } + var normalizedFileName = ts.normalizeSlashes(fileName); + var configFile = ts.parseJsonConfigFileContent(result.config, _this.host, ts.getDirectoryPath(normalizedFileName), {}, normalizedFileName); + return { + options: configFile.options, + typingOptions: configFile.typingOptions, + files: configFile.fileNames, + raw: configFile.raw, + errors: realizeDiagnostics(configFile.errors, "\r\n") + }; + }); + }; + CoreServicesShimObject.prototype.getDefaultCompilationSettings = function () { + return this.forwardJSONCall("getDefaultCompilationSettings()", function () { return ts.getDefaultCompilerOptions(); }); + }; + CoreServicesShimObject.prototype.discoverTypings = function (discoverTypingsJson) { + var _this = this; + var getCanonicalFileName = ts.createGetCanonicalFileName(false); + return this.forwardJSONCall("discoverTypings()", function () { + var info = JSON.parse(discoverTypingsJson); + return ts.JsTyping.discoverTypings(_this.host, info.fileNames, ts.toPath(info.projectRootPath, info.projectRootPath, getCanonicalFileName), ts.toPath(info.safeListPath, info.safeListPath, getCanonicalFileName), info.packageNameToTypingLocation, info.typingOptions); + }); + }; + return CoreServicesShimObject; + }(ShimBase)); + var TypeScriptServicesFactory = (function () { + function TypeScriptServicesFactory() { + this._shims = []; + } + TypeScriptServicesFactory.prototype.getServicesVersion = function () { + return ts.servicesVersion; + }; + TypeScriptServicesFactory.prototype.createLanguageServiceShim = function (host) { + try { + if (this.documentRegistry === undefined) { + this.documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory()); + } + var hostAdapter = new LanguageServiceShimHostAdapter(host); + var languageService = ts.createLanguageService(hostAdapter, this.documentRegistry); + return new LanguageServiceShimObject(this, host, languageService); + } + catch (err) { + logInternalError(host, err); + throw err; + } + }; + TypeScriptServicesFactory.prototype.createClassifierShim = function (logger) { + try { + return new ClassifierShimObject(this, logger); + } + catch (err) { + logInternalError(logger, err); + throw err; + } + }; + TypeScriptServicesFactory.prototype.createCoreServicesShim = function (host) { + try { + var adapter = new CoreServicesShimHostAdapter(host); + return new CoreServicesShimObject(this, host, adapter); + } + catch (err) { + logInternalError(host, err); + throw err; + } + }; + TypeScriptServicesFactory.prototype.close = function () { + this._shims = []; + this.documentRegistry = undefined; + }; + TypeScriptServicesFactory.prototype.registerShim = function (shim) { + this._shims.push(shim); + }; + TypeScriptServicesFactory.prototype.unregisterShim = function (shim) { + for (var i = 0, n = this._shims.length; i < n; i++) { + if (this._shims[i] === shim) { + delete this._shims[i]; + return; + } + } + throw new Error("Invalid operation"); + }; + return TypeScriptServicesFactory; + }()); + ts.TypeScriptServicesFactory = TypeScriptServicesFactory; + if (typeof module !== "undefined" && module.exports) { + module.exports = ts; + } +})(ts || (ts = {})); +var TypeScript; +(function (TypeScript) { + var Services; + (function (Services) { + Services.TypeScriptServicesFactory = ts.TypeScriptServicesFactory; + })(Services = TypeScript.Services || (TypeScript.Services = {})); +})(TypeScript || (TypeScript = {})); +var toolsVersion = "2.1"; +var ts; +(function (ts) { + var server; + (function (server) { + (function (LogLevel) { + LogLevel[LogLevel["terse"] = 0] = "terse"; + LogLevel[LogLevel["normal"] = 1] = "normal"; + LogLevel[LogLevel["requestTime"] = 2] = "requestTime"; + LogLevel[LogLevel["verbose"] = 3] = "verbose"; + })(server.LogLevel || (server.LogLevel = {})); + var LogLevel = server.LogLevel; + server.emptyArray = []; + var Msg; + (function (Msg) { + Msg.Err = "Err"; + Msg.Info = "Info"; + Msg.Perf = "Perf"; + })(Msg = server.Msg || (server.Msg = {})); + function getProjectRootPath(project) { + switch (project.projectKind) { + case server.ProjectKind.Configured: + return ts.getDirectoryPath(project.getProjectName()); + case server.ProjectKind.Inferred: + return ""; + case server.ProjectKind.External: + var projectName = ts.normalizeSlashes(project.getProjectName()); + return project.projectService.host.fileExists(projectName) ? ts.getDirectoryPath(projectName) : projectName; + } + } + function createInstallTypingsRequest(project, typingOptions, cachePath) { + return { + projectName: project.getProjectName(), + fileNames: project.getFileNames(), + compilerOptions: project.getCompilerOptions(), + typingOptions: typingOptions, + projectRootPath: getProjectRootPath(project), + cachePath: cachePath, + kind: "discover" + }; + } + server.createInstallTypingsRequest = createInstallTypingsRequest; + var Errors; + (function (Errors) { + function ThrowNoProject() { + throw new Error("No Project."); + } + Errors.ThrowNoProject = ThrowNoProject; + function ThrowProjectLanguageServiceDisabled() { + throw new Error("The project's language service is disabled."); + } + Errors.ThrowProjectLanguageServiceDisabled = ThrowProjectLanguageServiceDisabled; + function ThrowProjectDoesNotContainDocument(fileName, project) { + throw new Error("Project '" + project.getProjectName() + "' does not contain document '" + fileName + "'"); + } + Errors.ThrowProjectDoesNotContainDocument = ThrowProjectDoesNotContainDocument; + })(Errors = server.Errors || (server.Errors = {})); + function getDefaultFormatCodeSettings(host) { + return { + indentSize: 4, + tabSize: 4, + newLineCharacter: host.newLine || "\n", + convertTabsToSpaces: true, + indentStyle: ts.IndentStyle.Smart, + insertSpaceAfterCommaDelimiter: true, + insertSpaceAfterSemicolonInForStatements: true, + insertSpaceBeforeAndAfterBinaryOperators: true, + insertSpaceAfterKeywordsInControlFlowStatements: true, + insertSpaceAfterFunctionKeywordForAnonymousFunctions: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, + insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, + insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, + placeOpenBraceOnNewLineForFunctions: false, + placeOpenBraceOnNewLineForControlBlocks: false, + }; + } + server.getDefaultFormatCodeSettings = getDefaultFormatCodeSettings; + function mergeMaps(target, source) { + for (var key in source) { + if (ts.hasProperty(source, key)) { + target[key] = source[key]; + } + } + } + server.mergeMaps = mergeMaps; + function removeItemFromSet(items, itemToRemove) { + if (items.length === 0) { + return; + } + var index = items.indexOf(itemToRemove); + if (index < 0) { + return; + } + if (index === items.length - 1) { + items.pop(); + } + else { + items[index] = items.pop(); + } + } + server.removeItemFromSet = removeItemFromSet; + function toNormalizedPath(fileName) { + return ts.normalizePath(fileName); + } + server.toNormalizedPath = toNormalizedPath; + function normalizedPathToPath(normalizedPath, currentDirectory, getCanonicalFileName) { + var f = ts.isRootedDiskPath(normalizedPath) ? normalizedPath : ts.getNormalizedAbsolutePath(normalizedPath, currentDirectory); + return getCanonicalFileName(f); + } + server.normalizedPathToPath = normalizedPathToPath; + function asNormalizedPath(fileName) { + return fileName; + } + server.asNormalizedPath = asNormalizedPath; + function createNormalizedPathMap() { + var map = Object.create(null); + return { + get: function (path) { + return map[path]; + }, + set: function (path, value) { + map[path] = value; + }, + contains: function (path) { + return ts.hasProperty(map, path); + }, + remove: function (path) { + delete map[path]; + } + }; + } + server.createNormalizedPathMap = createNormalizedPathMap; + function throwLanguageServiceIsDisabledError() { + throw new Error("LanguageService is disabled"); + } + server.nullLanguageService = { + cleanupSemanticCache: throwLanguageServiceIsDisabledError, + getSyntacticDiagnostics: throwLanguageServiceIsDisabledError, + getSemanticDiagnostics: throwLanguageServiceIsDisabledError, + getCompilerOptionsDiagnostics: throwLanguageServiceIsDisabledError, + getSyntacticClassifications: throwLanguageServiceIsDisabledError, + getEncodedSyntacticClassifications: throwLanguageServiceIsDisabledError, + getSemanticClassifications: throwLanguageServiceIsDisabledError, + getEncodedSemanticClassifications: throwLanguageServiceIsDisabledError, + getCompletionsAtPosition: throwLanguageServiceIsDisabledError, + findReferences: throwLanguageServiceIsDisabledError, + getCompletionEntryDetails: throwLanguageServiceIsDisabledError, + getQuickInfoAtPosition: throwLanguageServiceIsDisabledError, + findRenameLocations: throwLanguageServiceIsDisabledError, + getNameOrDottedNameSpan: throwLanguageServiceIsDisabledError, + getBreakpointStatementAtPosition: throwLanguageServiceIsDisabledError, + getBraceMatchingAtPosition: throwLanguageServiceIsDisabledError, + getSignatureHelpItems: throwLanguageServiceIsDisabledError, + getDefinitionAtPosition: throwLanguageServiceIsDisabledError, + getRenameInfo: throwLanguageServiceIsDisabledError, + getTypeDefinitionAtPosition: throwLanguageServiceIsDisabledError, + getReferencesAtPosition: throwLanguageServiceIsDisabledError, + getDocumentHighlights: throwLanguageServiceIsDisabledError, + getOccurrencesAtPosition: throwLanguageServiceIsDisabledError, + getNavigateToItems: throwLanguageServiceIsDisabledError, + getNavigationBarItems: throwLanguageServiceIsDisabledError, + getNavigationTree: throwLanguageServiceIsDisabledError, + getOutliningSpans: throwLanguageServiceIsDisabledError, + getTodoComments: throwLanguageServiceIsDisabledError, + getIndentationAtPosition: throwLanguageServiceIsDisabledError, + getFormattingEditsForRange: throwLanguageServiceIsDisabledError, + getFormattingEditsForDocument: throwLanguageServiceIsDisabledError, + getFormattingEditsAfterKeystroke: throwLanguageServiceIsDisabledError, + getDocCommentTemplateAtPosition: throwLanguageServiceIsDisabledError, + isValidBraceCompletionAtPosition: throwLanguageServiceIsDisabledError, + getEmitOutput: throwLanguageServiceIsDisabledError, + getProgram: throwLanguageServiceIsDisabledError, + getNonBoundSourceFile: throwLanguageServiceIsDisabledError, + dispose: throwLanguageServiceIsDisabledError, + getCompletionEntrySymbol: throwLanguageServiceIsDisabledError, + getImplementationAtPosition: throwLanguageServiceIsDisabledError, + getSourceFile: throwLanguageServiceIsDisabledError, + getCodeFixesAtPosition: throwLanguageServiceIsDisabledError + }; + server.nullLanguageServiceHost = { + setCompilationSettings: function () { return undefined; }, + notifyFileRemoved: function () { return undefined; } + }; + function isInferredProjectName(name) { + return /dev\/null\/inferredProject\d+\*/.test(name); + } + server.isInferredProjectName = isInferredProjectName; + function makeInferredProjectName(counter) { + return "/dev/null/inferredProject" + counter + "*"; + } + server.makeInferredProjectName = makeInferredProjectName; + var ThrottledOperations = (function () { + function ThrottledOperations(host) { + this.host = host; + this.pendingTimeouts = ts.createMap(); + } + ThrottledOperations.prototype.schedule = function (operationId, delay, cb) { + if (ts.hasProperty(this.pendingTimeouts, operationId)) { + this.host.clearTimeout(this.pendingTimeouts[operationId]); + } + this.pendingTimeouts[operationId] = this.host.setTimeout(ThrottledOperations.run, delay, this, operationId, cb); + }; + ThrottledOperations.run = function (self, operationId, cb) { + delete self.pendingTimeouts[operationId]; + cb(); + }; + return ThrottledOperations; + }()); + server.ThrottledOperations = ThrottledOperations; + var GcTimer = (function () { + function GcTimer(host, delay, logger) { + this.host = host; + this.delay = delay; + this.logger = logger; + } + GcTimer.prototype.scheduleCollect = function () { + if (!this.host.gc || this.timerId != undefined) { + return; + } + this.timerId = this.host.setTimeout(GcTimer.run, this.delay, this); + }; + GcTimer.run = function (self) { + self.timerId = undefined; + var log = self.logger.hasLevel(LogLevel.requestTime); + var before = log && self.host.getMemoryUsage(); + self.host.gc(); + if (log) { + var after = self.host.getMemoryUsage(); + self.logger.perftrc("GC::before " + before + ", after " + after); + } + }; + return GcTimer; + }()); + server.GcTimer = GcTimer; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); var ts; (function (ts) { var server; @@ -61045,7 +63512,6 @@ var ts; if (this.containingProjects.length === 0) { return server.Errors.ThrowNoProject(); } - ts.Debug.assert(this.containingProjects.length !== 0); return this.containingProjects[0]; }; ScriptInfo.prototype.setFormatOptions = function (formatSettings) { @@ -61077,12 +63543,12 @@ var ts; var snap = this.snap(); this.host.writeFile(fileName, snap.getText(0, snap.getLength())); }; - ScriptInfo.prototype.reloadFromFile = function () { + ScriptInfo.prototype.reloadFromFile = function (tempFileName) { if (this.hasMixedContent) { this.reload(""); } else { - this.svc.reloadFromFile(this.fileName); + this.svc.reloadFromFile(tempFileName || this.fileName); this.markContainingProjectsAsDirty(); } }; @@ -61294,8 +63760,8 @@ var ts; (function (server) { server.nullTypingsInstaller = { enqueueInstallTypingsRequest: function () { }, - attach: function (projectService) { }, - onProjectClosed: function (p) { }, + attach: function () { }, + onProjectClosed: function () { }, globalTypingsCacheLocation: undefined }; var TypingsCacheEntry = (function () { @@ -61411,7 +63877,7 @@ var ts; BuilderFileInfo.prototype.containsOnlyAmbientModules = function (sourceFile) { for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var statement = _a[_i]; - if (statement.kind !== 225 || statement.name.kind !== 9) { + if (statement.kind !== 226 || statement.name.kind !== 9) { return false; } } @@ -61473,7 +63939,7 @@ var ts; this.fileInfos.remove(path); }; AbstractBuilder.prototype.forEachFileInfo = function (action) { - this.fileInfos.forEachValue(function (path, value) { return action(value); }); + this.fileInfos.forEachValue(function (_path, value) { return action(value); }); }; AbstractBuilder.prototype.emitFile = function (scriptInfo, writeFile) { var fileInfo = this.getFileInfo(scriptInfo.path); @@ -62037,11 +64503,11 @@ var ts; this.markAsDirty(); } }; - Project.prototype.reloadScript = function (filename) { + Project.prototype.reloadScript = function (filename, tempFileName) { var script = this.projectService.getScriptInfoForNormalizedPath(filename); if (script) { ts.Debug.assert(script.isAttached(this)); - script.reloadFromFile(); + script.reloadFromFile(tempFileName); return true; } return false; @@ -62332,6 +64798,66 @@ var ts; var server; (function (server) { server.maxProgramSizeForNonTsFiles = 20 * 1024 * 1024; + function prepareConvertersForEnumLikeCompilerOptions(commandLineOptions) { + var map = ts.createMap(); + for (var _i = 0, commandLineOptions_1 = commandLineOptions; _i < commandLineOptions_1.length; _i++) { + var option = commandLineOptions_1[_i]; + if (typeof option.type === "object") { + var optionMap = option.type; + for (var id in optionMap) { + ts.Debug.assert(typeof optionMap[id] === "number"); + } + map[option.name] = optionMap; + } + } + return map; + } + var compilerOptionConverters = prepareConvertersForEnumLikeCompilerOptions(ts.optionDeclarations); + var indentStyle = ts.createMap({ + "none": ts.IndentStyle.None, + "block": ts.IndentStyle.Block, + "smart": ts.IndentStyle.Smart + }); + function convertFormatOptions(protocolOptions) { + if (typeof protocolOptions.indentStyle === "string") { + protocolOptions.indentStyle = indentStyle[protocolOptions.indentStyle.toLowerCase()]; + ts.Debug.assert(protocolOptions.indentStyle !== undefined); + } + return protocolOptions; + } + server.convertFormatOptions = convertFormatOptions; + function convertCompilerOptions(protocolOptions) { + for (var id in compilerOptionConverters) { + var propertyValue = protocolOptions[id]; + if (typeof propertyValue === "string") { + var mappedValues = compilerOptionConverters[id]; + protocolOptions[id] = mappedValues[propertyValue.toLowerCase()]; + } + } + return protocolOptions; + } + server.convertCompilerOptions = convertCompilerOptions; + function tryConvertScriptKindName(scriptKindName) { + return typeof scriptKindName === "string" + ? convertScriptKindName(scriptKindName) + : scriptKindName; + } + server.tryConvertScriptKindName = tryConvertScriptKindName; + function convertScriptKindName(scriptKindName) { + switch (scriptKindName) { + case "JS": + return 1; + case "JSX": + return 2; + case "TS": + return 3; + case "TSX": + return 4; + default: + return 0; + } + } + server.convertScriptKindName = convertScriptKindName; function combineProjectOutput(projects, action, comparer, areEqual) { var result = projects.reduce(function (previous, current) { return ts.concatenate(previous, action(current)); }, []).sort(comparer); return projects.length > 1 ? ts.deduplicate(result, areEqual) : result; @@ -62344,7 +64870,7 @@ var ts; }; var externalFilePropertyReader = { getFileName: function (x) { return x.fileName; }, - getScriptKind: function (x) { return x.scriptKind; }, + getScriptKind: function (x) { return tryConvertScriptKindName(x.scriptKind); }, hasMixedContent: function (x) { return x.hasMixedContent; } }; function findProjectByName(projectName, projects) { @@ -62429,6 +64955,9 @@ var ts; ProjectService.prototype.ensureInferredProjectsUpToDate_TestOnly = function () { this.ensureInferredProjectsUpToDate(); }; + ProjectService.prototype.getCompilerOptionsForInferredProjects = function () { + return this.compilerOptionsForInferredProjects; + }; ProjectService.prototype.updateTypingsForProject = function (response) { var project = this.findProject(response.projectName); if (!project) { @@ -62445,11 +64974,11 @@ var ts; } }; ProjectService.prototype.setCompilerOptionsForInferredProjects = function (projectCompilerOptions) { - this.compilerOptionsForInferredProjects = projectCompilerOptions; + this.compilerOptionsForInferredProjects = convertCompilerOptions(projectCompilerOptions); this.compileOnSaveForInferredProjects = projectCompilerOptions.compileOnSave; for (var _i = 0, _a = this.inferredProjects; _i < _a.length; _i++) { var proj = _a[_i]; - proj.setCompilerOptions(projectCompilerOptions); + proj.setCompilerOptions(this.compilerOptionsForInferredProjects); proj.compileOnSaveEnabled = projectCompilerOptions.compileOnSave; } this.updateProjectGraphs(this.inferredProjects); @@ -62573,12 +65102,12 @@ var ts; return; } this.logger.info("Detected source file changes: " + fileName); - this.throttledOperations.schedule(project.configFileName, 250, function () { return _this.handleChangeInSourceFileForConfiguredProject(project); }); + this.throttledOperations.schedule(project.configFileName, 250, function () { return _this.handleChangeInSourceFileForConfiguredProject(project, fileName); }); }; - ProjectService.prototype.handleChangeInSourceFileForConfiguredProject = function (project) { + ProjectService.prototype.handleChangeInSourceFileForConfiguredProject = function (project, triggerFile) { var _this = this; var _a = this.convertConfigFileContentToProjectOptions(project.configFileName), projectOptions = _a.projectOptions, configFileErrors = _a.configFileErrors; - this.reportConfigFileDiagnostics(project.getProjectName(), configFileErrors); + this.reportConfigFileDiagnostics(project.getProjectName(), configFileErrors, triggerFile); var newRootFiles = projectOptions.files.map((function (f) { return _this.getCanonicalFileName(f); })); var currentRootFiles = project.getRootFiles().map((function (f) { return _this.getCanonicalFileName(f); })); if (!ts.arrayIsEqualTo(currentRootFiles.sort(), newRootFiles.sort())) { @@ -62598,7 +65127,7 @@ var ts; return; } var configFileErrors = this.convertConfigFileContentToProjectOptions(fileName).configFileErrors; - this.reportConfigFileDiagnostics(fileName, configFileErrors); + this.reportConfigFileDiagnostics(fileName, configFileErrors, fileName); this.logger.info("Detected newly added tsconfig file: " + fileName); this.reloadProjects(); }; @@ -62829,7 +65358,8 @@ var ts; return false; }; ProjectService.prototype.createAndAddExternalProject = function (projectFileName, files, options, typingOptions) { - var project = new server.ExternalProject(projectFileName, this, this.documentRegistry, options, !this.exceededTotalSizeLimitForNonTsFiles(options, files, externalFilePropertyReader), options.compileOnSave === undefined ? true : options.compileOnSave); + var compilerOptions = convertCompilerOptions(options); + var project = new server.ExternalProject(projectFileName, this, this.documentRegistry, compilerOptions, !this.exceededTotalSizeLimitForNonTsFiles(compilerOptions, files, externalFilePropertyReader), options.compileOnSave === undefined ? true : options.compileOnSave); this.addFilesToProjectAndUpdateGraph(project, files, externalFilePropertyReader, undefined, typingOptions, undefined); this.externalProjects.push(project); return project; @@ -63051,7 +65581,7 @@ var ts; if (args.file) { var info = this.getScriptInfoForNormalizedPath(server.toNormalizedPath(args.file)); if (info) { - info.setFormatOptions(args.formatOptions); + info.setFormatOptions(convertFormatOptions(args.formatOptions)); this.logger.info("Host configuration update for file " + args.file); } } @@ -63061,7 +65591,7 @@ var ts; this.logger.info("Host information " + args.hostInfo); } if (args.formatOptions) { - server.mergeMaps(this.hostConfiguration.formatCodeOptions, args.formatOptions); + server.mergeMaps(this.hostConfiguration.formatCodeOptions, convertFormatOptions(args.formatOptions)); this.logger.info("Format host information updated"); } } @@ -63152,7 +65682,7 @@ var ts; var scriptInfo = this.getScriptInfo(file.fileName); ts.Debug.assert(!scriptInfo || !scriptInfo.isOpen); var normalizedPath = scriptInfo ? scriptInfo.fileName : server.toNormalizedPath(file.fileName); - this.openClientFileWithNormalizedPath(normalizedPath, file.content, file.scriptKind, file.hasMixedContent); + this.openClientFileWithNormalizedPath(normalizedPath, file.content, tryConvertScriptKindName(file.scriptKind), file.hasMixedContent); } } if (changedFiles) { @@ -63237,7 +65767,7 @@ var ts; var exisingConfigFiles; if (externalProject) { if (!tsConfigFiles) { - this.updateNonInferredProject(externalProject, proj.rootFiles, externalFilePropertyReader, proj.options, proj.typingOptions, proj.options.compileOnSave, undefined); + this.updateNonInferredProject(externalProject, proj.rootFiles, externalFilePropertyReader, convertCompilerOptions(proj.options), proj.typingOptions, proj.options.compileOnSave, undefined); return; } this.closeExternalProject(proj.projectFileName, true); @@ -63523,23 +66053,7 @@ var ts; return _this.requiredResponse(_this.getRenameInfo(request.arguments)); }, _a[CommandNames.Open] = function (request) { - var openArgs = request.arguments; - var scriptKind; - switch (openArgs.scriptKindName) { - case "TS": - scriptKind = 3; - break; - case "JS": - scriptKind = 1; - break; - case "TSX": - scriptKind = 4; - break; - case "JSX": - scriptKind = 2; - break; - } - _this.openClientFile(server.toNormalizedPath(openArgs.file), openArgs.fileContent, scriptKind); + _this.openClientFile(server.toNormalizedPath(request.arguments.file), request.arguments.fileContent, server.convertScriptKindName(request.arguments.scriptKindName)); return _this.notRequired(); }, _a[CommandNames.Quickinfo] = function (request) { @@ -63611,7 +66125,7 @@ var ts; _a[CommandNames.EncodedSemanticClassificationsFull] = function (request) { return _this.requiredResponse(_this.getEncodedSemanticClassifications(request.arguments)); }, - _a[CommandNames.Cleanup] = function (request) { + _a[CommandNames.Cleanup] = function () { _this.cleanup(); return _this.requiredResponse(true); }, @@ -63686,12 +66200,13 @@ var ts; return _this.requiredResponse(_this.getDocumentHighlights(request.arguments, false)); }, _a[CommandNames.CompilerOptionsForInferredProjects] = function (request) { - return _this.requiredResponse(_this.setCompilerOptionsForInferredProjects(request.arguments)); + _this.setCompilerOptionsForInferredProjects(request.arguments); + return _this.requiredResponse(true); }, _a[CommandNames.ProjectInfo] = function (request) { return _this.requiredResponse(_this.getProjectInfo(request.arguments)); }, - _a[CommandNames.ReloadProjects] = function (request) { + _a[CommandNames.ReloadProjects] = function () { _this.projectService.reloadProjects(); return _this.notRequired(); }, @@ -63701,7 +66216,7 @@ var ts; _a[CommandNames.GetCodeFixesFull] = function (request) { return _this.requiredResponse(_this.getCodeFixes(request.arguments, false)); }, - _a[CommandNames.GetSupportedCodeFixes] = function (request) { + _a[CommandNames.GetSupportedCodeFixes] = function () { return _this.requiredResponse(_this.getSupportedCodeFixes()); }, _a)); @@ -63763,7 +66278,7 @@ var ts; seq: 0, type: "event", event: eventName, - body: info + body: info, }; this.send(ev); }; @@ -63774,7 +66289,7 @@ var ts; type: "response", command: cmdName, request_seq: reqSeq, - success: !errorMsg + success: !errorMsg, }; if (!errorMsg) { res.body = info; @@ -63899,9 +66414,9 @@ var ts; endLocation: scriptInfo && scriptInfo.positionToLineOffset(d.start + d.length) }); }); }; - Session.prototype.getDiagnosticsWorker = function (args, selector, includeLinePosition) { + Session.prototype.getDiagnosticsWorker = function (args, isSemantic, selector, includeLinePosition) { var _a = this.getFileAndProject(args), project = _a.project, file = _a.file; - if (shouldSkipSematicCheck(project)) { + if (isSemantic && shouldSkipSematicCheck(project)) { return []; } var scriptInfo = project.getScriptInfoForNormalizedPath(file); @@ -63985,15 +66500,15 @@ var ts; start: start, end: end, file: fileName, - isWriteAccess: isWriteAccess + isWriteAccess: isWriteAccess, }; }); }; Session.prototype.getSyntacticDiagnosticsSync = function (args) { - return this.getDiagnosticsWorker(args, function (project, file) { return project.getLanguageService().getSyntacticDiagnostics(file); }, args.includeLinePosition); + return this.getDiagnosticsWorker(args, false, function (project, file) { return project.getLanguageService().getSyntacticDiagnostics(file); }, args.includeLinePosition); }; Session.prototype.getSemanticDiagnosticsSync = function (args) { - return this.getDiagnosticsWorker(args, function (project, file) { return project.getLanguageService().getSemanticDiagnostics(file); }, args.includeLinePosition); + return this.getDiagnosticsWorker(args, true, function (project, file) { return project.getLanguageService().getSemanticDiagnostics(file); }, args.includeLinePosition); }; Session.prototype.getDocumentHighlights = function (args, simplifiedResult) { var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; @@ -64090,7 +66605,7 @@ var ts; return { file: location.fileName, start: locationScriptInfo.positionToLineOffset(location.textSpan.start), - end: locationScriptInfo.positionToLineOffset(ts.textSpanEnd(location.textSpan)) + end: locationScriptInfo.positionToLineOffset(ts.textSpanEnd(location.textSpan)), }; }); }, compareRenameLocation, function (a, b) { return a.file === b.file && a.start.line === b.start.line && a.start.offset === b.start.offset; }); @@ -64204,7 +66719,7 @@ var ts; if (this.eventHander) { this.eventHander({ eventName: "configFileDiag", - data: { fileName: fileName, configFileName: configFileName, diagnostics: configFileErrors || [] } + data: { triggerFile: fileName, configFileName: configFileName, diagnostics: configFileErrors || [] } }); } }; @@ -64244,7 +66759,7 @@ var ts; Session.prototype.getIndentation = function (args) { var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; var position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file)); - var options = args.options || this.projectService.getFormatCodeOptions(file); + var options = args.options ? server.convertFormatOptions(args.options) : this.projectService.getFormatCodeOptions(file); var indentation = project.getLanguageService(false).getIndentationAtPosition(file, position, options); return { position: position, indentation: indentation }; }; @@ -64279,7 +66794,7 @@ var ts; start: scriptInfo.positionToLineOffset(quickInfo.textSpan.start), end: scriptInfo.positionToLineOffset(ts.textSpanEnd(quickInfo.textSpan)), displayString: displayString, - documentation: docString + documentation: docString, }; } else { @@ -64300,17 +66815,17 @@ var ts; }; Session.prototype.getFormattingEditsForRangeFull = function (args) { var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - var options = args.options || this.projectService.getFormatCodeOptions(file); + var options = args.options ? server.convertFormatOptions(args.options) : this.projectService.getFormatCodeOptions(file); return project.getLanguageService(false).getFormattingEditsForRange(file, args.position, args.endPosition, options); }; Session.prototype.getFormattingEditsForDocumentFull = function (args) { var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - var options = args.options || this.projectService.getFormatCodeOptions(file); + var options = args.options ? server.convertFormatOptions(args.options) : this.projectService.getFormatCodeOptions(file); return project.getLanguageService(false).getFormattingEditsForDocument(file, options); }; Session.prototype.getFormattingEditsAfterKeystrokeFull = function (args) { var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; - var options = args.options || this.projectService.getFormatCodeOptions(file); + var options = args.options ? server.convertFormatOptions(args.options) : this.projectService.getFormatCodeOptions(file); return project.getLanguageService(false).getFormattingEditsAfterKeystroke(file, args.position, args.key, options); }; Session.prototype.getFormattingEditsAfterKeystroke = function (args) { @@ -64377,7 +66892,7 @@ var ts; result.push({ name: name_53, kind: kind, kindModifiers: kindModifiers, sortText: sortText, replacementSpan: convertedSpan }); } return result; - }, []).sort(function (a, b) { return a.name.localeCompare(b.name); }); + }, []).sort(function (a, b) { return ts.compareStrings(a.name, b.name); }); } else { return completions; @@ -64440,7 +66955,7 @@ var ts; }, selectedItemIndex: helpItems.selectedItemIndex, argumentIndex: helpItems.argumentIndex, - argumentCount: helpItems.argumentCount + argumentCount: helpItems.argumentCount, }; } else { @@ -64477,10 +66992,11 @@ var ts; }; Session.prototype.reload = function (args, reqSeq) { var file = server.toNormalizedPath(args.file); + var tempFileName = args.tmpfile && server.toNormalizedPath(args.tmpfile); var project = this.projectService.getDefaultProjectForFile(file, true); if (project) { this.changeSeq++; - if (project.reloadScript(file)) { + if (project.reloadScript(file, tempFileName)) { this.output(undefined, CommandNames.Reload, reqSeq); } } @@ -64561,7 +67077,7 @@ var ts; kind: navItem.kind, file: navItem.fileName, start: start, - end: end + end: end, }; if (navItem.kindModifiers && (navItem.kindModifiers !== "")) { bakedItem.kindModifiers = navItem.kindModifiers; @@ -64670,7 +67186,7 @@ var ts; if (languageServiceDisabled) { return; } - var fileNamesInProject = fileNames.filter(function (value, index, array) { return value.indexOf("lib.d.ts") < 0; }); + var fileNamesInProject = fileNames.filter(function (value) { return value.indexOf("lib.d.ts") < 0; }); var highPriorityFiles = []; var mediumPriorityFiles = []; var lowPriorityFiles = []; @@ -64790,7 +67306,7 @@ var ts; this.goSubtree = true; this.done = false; } - BaseLineIndexWalker.prototype.leaf = function (rangeStart, rangeLength, ll) { + BaseLineIndexWalker.prototype.leaf = function (_rangeStart, _rangeLength, _ll) { }; return BaseLineIndexWalker; }()); @@ -64885,14 +67401,14 @@ var ts; } return this.lineIndex; }; - EditWalker.prototype.post = function (relativeStart, relativeLength, lineCollection, parent, nodeType) { + EditWalker.prototype.post = function (_relativeStart, _relativeLength, lineCollection) { if (lineCollection === this.lineCollectionAtBranch) { this.state = CharRangeSection.End; } this.stack.length--; return undefined; }; - EditWalker.prototype.pre = function (relativeStart, relativeLength, lineCollection, parent, nodeType) { + EditWalker.prototype.pre = function (_relativeStart, _relativeLength, lineCollection, _parent, nodeType) { var currentNode = this.stack[this.stack.length - 1]; if ((this.state === CharRangeSection.Entire) && (nodeType === CharRangeSection.Start)) { this.state = CharRangeSection.Start; @@ -65117,7 +67633,7 @@ var ts; var starts = [-1]; var count = 1; var pos = 0; - this.index.every(function (ll, s, len) { + this.index.every(function (ll) { starts[count] = pos; count++; pos += ll.text.length; @@ -65411,7 +67927,7 @@ var ts; if (!childInfo.child) { return { line: lineNumber, - offset: charOffset + offset: charOffset, }; } else if (childInfo.childIndex < this.children.length) { @@ -65617,694 +68133,5 @@ var ts; server.LineLeaf = LineLeaf; })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); -var debugObjectHost = (function () { return this; })(); -var ts; -(function (ts) { - function logInternalError(logger, err) { - if (logger) { - logger.log("*INTERNAL ERROR* - Exception in typescript services: " + err.message); - } - } - var ScriptSnapshotShimAdapter = (function () { - function ScriptSnapshotShimAdapter(scriptSnapshotShim) { - this.scriptSnapshotShim = scriptSnapshotShim; - } - ScriptSnapshotShimAdapter.prototype.getText = function (start, end) { - return this.scriptSnapshotShim.getText(start, end); - }; - ScriptSnapshotShimAdapter.prototype.getLength = function () { - return this.scriptSnapshotShim.getLength(); - }; - ScriptSnapshotShimAdapter.prototype.getChangeRange = function (oldSnapshot) { - var oldSnapshotShim = oldSnapshot; - var encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim); - if (encoded == null) { - return null; - } - var decoded = JSON.parse(encoded); - return ts.createTextChangeRange(ts.createTextSpan(decoded.span.start, decoded.span.length), decoded.newLength); - }; - ScriptSnapshotShimAdapter.prototype.dispose = function () { - if ("dispose" in this.scriptSnapshotShim) { - this.scriptSnapshotShim.dispose(); - } - }; - return ScriptSnapshotShimAdapter; - }()); - var LanguageServiceShimHostAdapter = (function () { - function LanguageServiceShimHostAdapter(shimHost) { - var _this = this; - this.shimHost = shimHost; - this.loggingEnabled = false; - this.tracingEnabled = false; - if ("getModuleResolutionsForFile" in this.shimHost) { - this.resolveModuleNames = function (moduleNames, containingFile) { - var resolutionsInFile = JSON.parse(_this.shimHost.getModuleResolutionsForFile(containingFile)); - return ts.map(moduleNames, function (name) { - var result = ts.getProperty(resolutionsInFile, name); - return result ? { resolvedFileName: result } : undefined; - }); - }; - } - if ("directoryExists" in this.shimHost) { - this.directoryExists = function (directoryName) { return _this.shimHost.directoryExists(directoryName); }; - } - if ("getTypeReferenceDirectiveResolutionsForFile" in this.shimHost) { - this.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile) { - var typeDirectivesForFile = JSON.parse(_this.shimHost.getTypeReferenceDirectiveResolutionsForFile(containingFile)); - return ts.map(typeDirectiveNames, function (name) { return ts.getProperty(typeDirectivesForFile, name); }); - }; - } - } - LanguageServiceShimHostAdapter.prototype.log = function (s) { - if (this.loggingEnabled) { - this.shimHost.log(s); - } - }; - LanguageServiceShimHostAdapter.prototype.trace = function (s) { - if (this.tracingEnabled) { - this.shimHost.trace(s); - } - }; - LanguageServiceShimHostAdapter.prototype.error = function (s) { - this.shimHost.error(s); - }; - LanguageServiceShimHostAdapter.prototype.getProjectVersion = function () { - if (!this.shimHost.getProjectVersion) { - return undefined; - } - return this.shimHost.getProjectVersion(); - }; - LanguageServiceShimHostAdapter.prototype.getTypeRootsVersion = function () { - if (!this.shimHost.getTypeRootsVersion) { - return 0; - } - return this.shimHost.getTypeRootsVersion(); - }; - LanguageServiceShimHostAdapter.prototype.useCaseSensitiveFileNames = function () { - return this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false; - }; - LanguageServiceShimHostAdapter.prototype.getCompilationSettings = function () { - var settingsJson = this.shimHost.getCompilationSettings(); - if (settingsJson == null || settingsJson == "") { - throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); - } - return JSON.parse(settingsJson); - }; - LanguageServiceShimHostAdapter.prototype.getScriptFileNames = function () { - var encoded = this.shimHost.getScriptFileNames(); - return this.files = JSON.parse(encoded); - }; - LanguageServiceShimHostAdapter.prototype.getScriptSnapshot = function (fileName) { - var scriptSnapshot = this.shimHost.getScriptSnapshot(fileName); - return scriptSnapshot && new ScriptSnapshotShimAdapter(scriptSnapshot); - }; - LanguageServiceShimHostAdapter.prototype.getScriptKind = function (fileName) { - if ("getScriptKind" in this.shimHost) { - return this.shimHost.getScriptKind(fileName); - } - else { - return 0; - } - }; - LanguageServiceShimHostAdapter.prototype.getScriptVersion = function (fileName) { - return this.shimHost.getScriptVersion(fileName); - }; - LanguageServiceShimHostAdapter.prototype.getLocalizedDiagnosticMessages = function () { - var diagnosticMessagesJson = this.shimHost.getLocalizedDiagnosticMessages(); - if (diagnosticMessagesJson == null || diagnosticMessagesJson == "") { - return null; - } - try { - return JSON.parse(diagnosticMessagesJson); - } - catch (e) { - this.log(e.description || "diagnosticMessages.generated.json has invalid JSON format"); - return null; - } - }; - LanguageServiceShimHostAdapter.prototype.getCancellationToken = function () { - var hostCancellationToken = this.shimHost.getCancellationToken(); - return new ThrottledCancellationToken(hostCancellationToken); - }; - LanguageServiceShimHostAdapter.prototype.getCurrentDirectory = function () { - return this.shimHost.getCurrentDirectory(); - }; - LanguageServiceShimHostAdapter.prototype.getDirectories = function (path) { - return JSON.parse(this.shimHost.getDirectories(path)); - }; - LanguageServiceShimHostAdapter.prototype.getDefaultLibFileName = function (options) { - return this.shimHost.getDefaultLibFileName(JSON.stringify(options)); - }; - LanguageServiceShimHostAdapter.prototype.readDirectory = function (path, extensions, exclude, include, depth) { - var pattern = ts.getFileMatcherPatterns(path, extensions, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); - return JSON.parse(this.shimHost.readDirectory(path, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); - }; - LanguageServiceShimHostAdapter.prototype.readFile = function (path, encoding) { - return this.shimHost.readFile(path, encoding); - }; - LanguageServiceShimHostAdapter.prototype.fileExists = function (path) { - return this.shimHost.fileExists(path); - }; - return LanguageServiceShimHostAdapter; - }()); - ts.LanguageServiceShimHostAdapter = LanguageServiceShimHostAdapter; - var ThrottledCancellationToken = (function () { - function ThrottledCancellationToken(hostCancellationToken) { - this.hostCancellationToken = hostCancellationToken; - this.lastCancellationCheckTime = 0; - } - ThrottledCancellationToken.prototype.isCancellationRequested = function () { - var time = ts.timestamp(); - var duration = Math.abs(time - this.lastCancellationCheckTime); - if (duration > 10) { - this.lastCancellationCheckTime = time; - return this.hostCancellationToken.isCancellationRequested(); - } - return false; - }; - return ThrottledCancellationToken; - }()); - var CoreServicesShimHostAdapter = (function () { - function CoreServicesShimHostAdapter(shimHost) { - var _this = this; - this.shimHost = shimHost; - this.useCaseSensitiveFileNames = this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false; - if ("directoryExists" in this.shimHost) { - this.directoryExists = function (directoryName) { return _this.shimHost.directoryExists(directoryName); }; - } - if ("realpath" in this.shimHost) { - this.realpath = function (path) { return _this.shimHost.realpath(path); }; - } - } - CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extensions, exclude, include, depth) { - try { - var pattern = ts.getFileMatcherPatterns(rootDir, extensions, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); - return JSON.parse(this.shimHost.readDirectory(rootDir, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); - } - catch (e) { - var results = []; - for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) { - var extension = extensions_2[_i]; - for (var _a = 0, _b = this.readDirectoryFallback(rootDir, extension, exclude); _a < _b.length; _a++) { - var file = _b[_a]; - if (!ts.contains(results, file)) { - results.push(file); - } - } - } - return results; - } - }; - CoreServicesShimHostAdapter.prototype.fileExists = function (fileName) { - return this.shimHost.fileExists(fileName); - }; - CoreServicesShimHostAdapter.prototype.readFile = function (fileName) { - return this.shimHost.readFile(fileName); - }; - CoreServicesShimHostAdapter.prototype.readDirectoryFallback = function (rootDir, extension, exclude) { - return JSON.parse(this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude))); - }; - CoreServicesShimHostAdapter.prototype.getDirectories = function (path) { - return JSON.parse(this.shimHost.getDirectories(path)); - }; - return CoreServicesShimHostAdapter; - }()); - ts.CoreServicesShimHostAdapter = CoreServicesShimHostAdapter; - function simpleForwardCall(logger, actionDescription, action, logPerformance) { - var start; - if (logPerformance) { - logger.log(actionDescription); - start = ts.timestamp(); - } - var result = action(); - if (logPerformance) { - var end = ts.timestamp(); - logger.log(actionDescription + " completed in " + (end - start) + " msec"); - if (typeof result === "string") { - var str = result; - if (str.length > 128) { - str = str.substring(0, 128) + "..."; - } - logger.log(" result.length=" + str.length + ", result='" + JSON.stringify(str) + "'"); - } - } - return result; - } - function forwardJSONCall(logger, actionDescription, action, logPerformance) { - return forwardCall(logger, actionDescription, true, action, logPerformance); - } - function forwardCall(logger, actionDescription, returnJson, action, logPerformance) { - try { - var result = simpleForwardCall(logger, actionDescription, action, logPerformance); - return returnJson ? JSON.stringify({ result: result }) : result; - } - catch (err) { - if (err instanceof ts.OperationCanceledException) { - return JSON.stringify({ canceled: true }); - } - logInternalError(logger, err); - err.description = actionDescription; - return JSON.stringify({ error: err }); - } - } - var ShimBase = (function () { - function ShimBase(factory) { - this.factory = factory; - factory.registerShim(this); - } - ShimBase.prototype.dispose = function (dummy) { - this.factory.unregisterShim(this); - }; - return ShimBase; - }()); - function realizeDiagnostics(diagnostics, newLine) { - return diagnostics.map(function (d) { return realizeDiagnostic(d, newLine); }); - } - ts.realizeDiagnostics = realizeDiagnostics; - function realizeDiagnostic(diagnostic, newLine) { - return { - message: ts.flattenDiagnosticMessageText(diagnostic.messageText, newLine), - start: diagnostic.start, - length: diagnostic.length, - category: ts.DiagnosticCategory[diagnostic.category].toLowerCase(), - code: diagnostic.code - }; - } - var LanguageServiceShimObject = (function (_super) { - __extends(LanguageServiceShimObject, _super); - function LanguageServiceShimObject(factory, host, languageService) { - var _this = _super.call(this, factory) || this; - _this.host = host; - _this.languageService = languageService; - _this.logPerformance = false; - _this.logger = _this.host; - return _this; - } - LanguageServiceShimObject.prototype.forwardJSONCall = function (actionDescription, action) { - return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); - }; - LanguageServiceShimObject.prototype.dispose = function (dummy) { - this.logger.log("dispose()"); - this.languageService.dispose(); - this.languageService = null; - if (debugObjectHost && debugObjectHost.CollectGarbage) { - debugObjectHost.CollectGarbage(); - this.logger.log("CollectGarbage()"); - } - this.logger = null; - _super.prototype.dispose.call(this, dummy); - }; - LanguageServiceShimObject.prototype.refresh = function (throwOnError) { - this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; }); - }; - LanguageServiceShimObject.prototype.cleanupSemanticCache = function () { - var _this = this; - this.forwardJSONCall("cleanupSemanticCache()", function () { - _this.languageService.cleanupSemanticCache(); - return null; - }); - }; - LanguageServiceShimObject.prototype.realizeDiagnostics = function (diagnostics) { - var newLine = ts.getNewLineOrDefaultFromHost(this.host); - return ts.realizeDiagnostics(diagnostics, newLine); - }; - LanguageServiceShimObject.prototype.getSyntacticClassifications = function (fileName, start, length) { - var _this = this; - return this.forwardJSONCall("getSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSyntacticClassifications(fileName, ts.createTextSpan(start, length)); }); - }; - LanguageServiceShimObject.prototype.getSemanticClassifications = function (fileName, start, length) { - var _this = this; - return this.forwardJSONCall("getSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSemanticClassifications(fileName, ts.createTextSpan(start, length)); }); - }; - LanguageServiceShimObject.prototype.getEncodedSyntacticClassifications = function (fileName, start, length) { - var _this = this; - return this.forwardJSONCall("getEncodedSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return convertClassifications(_this.languageService.getEncodedSyntacticClassifications(fileName, ts.createTextSpan(start, length))); }); - }; - LanguageServiceShimObject.prototype.getEncodedSemanticClassifications = function (fileName, start, length) { - var _this = this; - return this.forwardJSONCall("getEncodedSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return convertClassifications(_this.languageService.getEncodedSemanticClassifications(fileName, ts.createTextSpan(start, length))); }); - }; - LanguageServiceShimObject.prototype.getSyntacticDiagnostics = function (fileName) { - var _this = this; - return this.forwardJSONCall("getSyntacticDiagnostics('" + fileName + "')", function () { - var diagnostics = _this.languageService.getSyntacticDiagnostics(fileName); - return _this.realizeDiagnostics(diagnostics); - }); - }; - LanguageServiceShimObject.prototype.getSemanticDiagnostics = function (fileName) { - var _this = this; - return this.forwardJSONCall("getSemanticDiagnostics('" + fileName + "')", function () { - var diagnostics = _this.languageService.getSemanticDiagnostics(fileName); - return _this.realizeDiagnostics(diagnostics); - }); - }; - LanguageServiceShimObject.prototype.getCompilerOptionsDiagnostics = function () { - var _this = this; - return this.forwardJSONCall("getCompilerOptionsDiagnostics()", function () { - var diagnostics = _this.languageService.getCompilerOptionsDiagnostics(); - return _this.realizeDiagnostics(diagnostics); - }); - }; - LanguageServiceShimObject.prototype.getQuickInfoAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getQuickInfoAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getQuickInfoAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getNameOrDottedNameSpan = function (fileName, startPos, endPos) { - var _this = this; - return this.forwardJSONCall("getNameOrDottedNameSpan('" + fileName + "', " + startPos + ", " + endPos + ")", function () { return _this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos); }); - }; - LanguageServiceShimObject.prototype.getBreakpointStatementAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getBreakpointStatementAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBreakpointStatementAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getSignatureHelpItems = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getSignatureHelpItems('" + fileName + "', " + position + ")", function () { return _this.languageService.getSignatureHelpItems(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getDefinitionAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDefinitionAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getTypeDefinitionAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getTypeDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getTypeDefinitionAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getImplementationAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getImplementationAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getImplementationAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position); }); - }; - LanguageServiceShimObject.prototype.findRenameLocations = function (fileName, position, findInStrings, findInComments) { - var _this = this; - return this.forwardJSONCall("findRenameLocations('" + fileName + "', " + position + ", " + findInStrings + ", " + findInComments + ")", function () { return _this.languageService.findRenameLocations(fileName, position, findInStrings, findInComments); }); - }; - LanguageServiceShimObject.prototype.getBraceMatchingAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getBraceMatchingAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBraceMatchingAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.isValidBraceCompletionAtPosition = function (fileName, position, openingBrace) { - var _this = this; - return this.forwardJSONCall("isValidBraceCompletionAtPosition('" + fileName + "', " + position + ", " + openingBrace + ")", function () { return _this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace); }); - }; - LanguageServiceShimObject.prototype.getIndentationAtPosition = function (fileName, position, options) { - var _this = this; - return this.forwardJSONCall("getIndentationAtPosition('" + fileName + "', " + position + ")", function () { - var localOptions = JSON.parse(options); - return _this.languageService.getIndentationAtPosition(fileName, position, localOptions); - }); - }; - LanguageServiceShimObject.prototype.getReferencesAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getReferencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getReferencesAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.findReferences = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("findReferences('" + fileName + "', " + position + ")", function () { return _this.languageService.findReferences(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getOccurrencesAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getOccurrencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getOccurrencesAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getDocumentHighlights = function (fileName, position, filesToSearch) { - var _this = this; - return this.forwardJSONCall("getDocumentHighlights('" + fileName + "', " + position + ")", function () { - var results = _this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); - var normalizedName = ts.normalizeSlashes(fileName).toLowerCase(); - return ts.filter(results, function (r) { return ts.normalizeSlashes(r.fileName).toLowerCase() === normalizedName; }); - }); - }; - LanguageServiceShimObject.prototype.getCompletionsAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getCompletionsAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName) { - var _this = this; - return this.forwardJSONCall("getCompletionEntryDetails('" + fileName + "', " + position + ", '" + entryName + "')", function () { return _this.languageService.getCompletionEntryDetails(fileName, position, entryName); }); - }; - LanguageServiceShimObject.prototype.getFormattingEditsForRange = function (fileName, start, end, options) { - var _this = this; - return this.forwardJSONCall("getFormattingEditsForRange('" + fileName + "', " + start + ", " + end + ")", function () { - var localOptions = JSON.parse(options); - return _this.languageService.getFormattingEditsForRange(fileName, start, end, localOptions); - }); - }; - LanguageServiceShimObject.prototype.getFormattingEditsForDocument = function (fileName, options) { - var _this = this; - return this.forwardJSONCall("getFormattingEditsForDocument('" + fileName + "')", function () { - var localOptions = JSON.parse(options); - return _this.languageService.getFormattingEditsForDocument(fileName, localOptions); - }); - }; - LanguageServiceShimObject.prototype.getFormattingEditsAfterKeystroke = function (fileName, position, key, options) { - var _this = this; - return this.forwardJSONCall("getFormattingEditsAfterKeystroke('" + fileName + "', " + position + ", '" + key + "')", function () { - var localOptions = JSON.parse(options); - return _this.languageService.getFormattingEditsAfterKeystroke(fileName, position, key, localOptions); - }); - }; - LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position) { - var _this = this; - return this.forwardJSONCall("getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position); }); - }; - LanguageServiceShimObject.prototype.getNavigateToItems = function (searchValue, maxResultCount, fileName) { - var _this = this; - return this.forwardJSONCall("getNavigateToItems('" + searchValue + "', " + maxResultCount + ", " + fileName + ")", function () { return _this.languageService.getNavigateToItems(searchValue, maxResultCount, fileName); }); - }; - LanguageServiceShimObject.prototype.getNavigationBarItems = function (fileName) { - var _this = this; - return this.forwardJSONCall("getNavigationBarItems('" + fileName + "')", function () { return _this.languageService.getNavigationBarItems(fileName); }); - }; - LanguageServiceShimObject.prototype.getNavigationTree = function (fileName) { - var _this = this; - return this.forwardJSONCall("getNavigationTree('" + fileName + "')", function () { return _this.languageService.getNavigationTree(fileName); }); - }; - LanguageServiceShimObject.prototype.getOutliningSpans = function (fileName) { - var _this = this; - return this.forwardJSONCall("getOutliningSpans('" + fileName + "')", function () { return _this.languageService.getOutliningSpans(fileName); }); - }; - LanguageServiceShimObject.prototype.getTodoComments = function (fileName, descriptors) { - var _this = this; - return this.forwardJSONCall("getTodoComments('" + fileName + "')", function () { return _this.languageService.getTodoComments(fileName, JSON.parse(descriptors)); }); - }; - LanguageServiceShimObject.prototype.getEmitOutput = function (fileName) { - var _this = this; - return this.forwardJSONCall("getEmitOutput('" + fileName + "')", function () { return _this.languageService.getEmitOutput(fileName); }); - }; - LanguageServiceShimObject.prototype.getEmitOutputObject = function (fileName) { - var _this = this; - return forwardCall(this.logger, "getEmitOutput('" + fileName + "')", false, function () { return _this.languageService.getEmitOutput(fileName); }, this.logPerformance); - }; - return LanguageServiceShimObject; - }(ShimBase)); - function convertClassifications(classifications) { - return { spans: classifications.spans.join(","), endOfLineState: classifications.endOfLineState }; - } - var ClassifierShimObject = (function (_super) { - __extends(ClassifierShimObject, _super); - function ClassifierShimObject(factory, logger) { - var _this = _super.call(this, factory) || this; - _this.logger = logger; - _this.logPerformance = false; - _this.classifier = ts.createClassifier(); - return _this; - } - ClassifierShimObject.prototype.getEncodedLexicalClassifications = function (text, lexState, syntacticClassifierAbsent) { - var _this = this; - return forwardJSONCall(this.logger, "getEncodedLexicalClassifications", function () { return convertClassifications(_this.classifier.getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent)); }, this.logPerformance); - }; - ClassifierShimObject.prototype.getClassificationsForLine = function (text, lexState, classifyKeywordsInGenerics) { - var classification = this.classifier.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics); - var result = ""; - for (var _i = 0, _a = classification.entries; _i < _a.length; _i++) { - var item = _a[_i]; - result += item.length + "\n"; - result += item.classification + "\n"; - } - result += classification.finalLexState; - return result; - }; - return ClassifierShimObject; - }(ShimBase)); - var CoreServicesShimObject = (function (_super) { - __extends(CoreServicesShimObject, _super); - function CoreServicesShimObject(factory, logger, host) { - var _this = _super.call(this, factory) || this; - _this.logger = logger; - _this.host = host; - _this.logPerformance = false; - return _this; - } - CoreServicesShimObject.prototype.forwardJSONCall = function (actionDescription, action) { - return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); - }; - CoreServicesShimObject.prototype.resolveModuleName = function (fileName, moduleName, compilerOptionsJson) { - var _this = this; - return this.forwardJSONCall("resolveModuleName('" + fileName + "')", function () { - var compilerOptions = JSON.parse(compilerOptionsJson); - var result = ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host); - return { - resolvedFileName: result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined, - failedLookupLocations: result.failedLookupLocations - }; - }); - }; - CoreServicesShimObject.prototype.resolveTypeReferenceDirective = function (fileName, typeReferenceDirective, compilerOptionsJson) { - var _this = this; - return this.forwardJSONCall("resolveTypeReferenceDirective(" + fileName + ")", function () { - var compilerOptions = JSON.parse(compilerOptionsJson); - var result = ts.resolveTypeReferenceDirective(typeReferenceDirective, ts.normalizeSlashes(fileName), compilerOptions, _this.host); - return { - resolvedFileName: result.resolvedTypeReferenceDirective ? result.resolvedTypeReferenceDirective.resolvedFileName : undefined, - primary: result.resolvedTypeReferenceDirective ? result.resolvedTypeReferenceDirective.primary : true, - failedLookupLocations: result.failedLookupLocations - }; - }); - }; - CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { - var _this = this; - return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { - var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()), true, true); - return { - referencedFiles: _this.convertFileReferences(result.referencedFiles), - importedFiles: _this.convertFileReferences(result.importedFiles), - ambientExternalModules: result.ambientExternalModules, - isLibFile: result.isLibFile, - typeReferenceDirectives: _this.convertFileReferences(result.typeReferenceDirectives) - }; - }); - }; - CoreServicesShimObject.prototype.getAutomaticTypeDirectiveNames = function (compilerOptionsJson) { - var _this = this; - return this.forwardJSONCall("getAutomaticTypeDirectiveNames('" + compilerOptionsJson + "')", function () { - var compilerOptions = JSON.parse(compilerOptionsJson); - return ts.getAutomaticTypeDirectiveNames(compilerOptions, _this.host); - }); - }; - CoreServicesShimObject.prototype.convertFileReferences = function (refs) { - if (!refs) { - return undefined; - } - var result = []; - for (var _i = 0, refs_2 = refs; _i < refs_2.length; _i++) { - var ref = refs_2[_i]; - result.push({ - path: ts.normalizeSlashes(ref.fileName), - position: ref.pos, - length: ref.end - ref.pos - }); - } - return result; - }; - CoreServicesShimObject.prototype.getTSConfigFileInfo = function (fileName, sourceTextSnapshot) { - var _this = this; - return this.forwardJSONCall("getTSConfigFileInfo('" + fileName + "')", function () { - var text = sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()); - var result = ts.parseConfigFileTextToJson(fileName, text); - if (result.error) { - return { - options: {}, - typingOptions: {}, - files: [], - raw: {}, - errors: [realizeDiagnostic(result.error, "\r\n")] - }; - } - var normalizedFileName = ts.normalizeSlashes(fileName); - var configFile = ts.parseJsonConfigFileContent(result.config, _this.host, ts.getDirectoryPath(normalizedFileName), {}, normalizedFileName); - return { - options: configFile.options, - typingOptions: configFile.typingOptions, - files: configFile.fileNames, - raw: configFile.raw, - errors: realizeDiagnostics(configFile.errors, "\r\n") - }; - }); - }; - CoreServicesShimObject.prototype.getDefaultCompilationSettings = function () { - return this.forwardJSONCall("getDefaultCompilationSettings()", function () { return ts.getDefaultCompilerOptions(); }); - }; - CoreServicesShimObject.prototype.discoverTypings = function (discoverTypingsJson) { - var _this = this; - var getCanonicalFileName = ts.createGetCanonicalFileName(false); - return this.forwardJSONCall("discoverTypings()", function () { - var info = JSON.parse(discoverTypingsJson); - return ts.JsTyping.discoverTypings(_this.host, info.fileNames, ts.toPath(info.projectRootPath, info.projectRootPath, getCanonicalFileName), ts.toPath(info.safeListPath, info.safeListPath, getCanonicalFileName), info.packageNameToTypingLocation, info.typingOptions, info.compilerOptions); - }); - }; - return CoreServicesShimObject; - }(ShimBase)); - var TypeScriptServicesFactory = (function () { - function TypeScriptServicesFactory() { - this._shims = []; - } - TypeScriptServicesFactory.prototype.getServicesVersion = function () { - return ts.servicesVersion; - }; - TypeScriptServicesFactory.prototype.createLanguageServiceShim = function (host) { - try { - if (this.documentRegistry === undefined) { - this.documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory()); - } - var hostAdapter = new LanguageServiceShimHostAdapter(host); - var languageService = ts.createLanguageService(hostAdapter, this.documentRegistry); - return new LanguageServiceShimObject(this, host, languageService); - } - catch (err) { - logInternalError(host, err); - throw err; - } - }; - TypeScriptServicesFactory.prototype.createClassifierShim = function (logger) { - try { - return new ClassifierShimObject(this, logger); - } - catch (err) { - logInternalError(logger, err); - throw err; - } - }; - TypeScriptServicesFactory.prototype.createCoreServicesShim = function (host) { - try { - var adapter = new CoreServicesShimHostAdapter(host); - return new CoreServicesShimObject(this, host, adapter); - } - catch (err) { - logInternalError(host, err); - throw err; - } - }; - TypeScriptServicesFactory.prototype.close = function () { - this._shims = []; - this.documentRegistry = undefined; - }; - TypeScriptServicesFactory.prototype.registerShim = function (shim) { - this._shims.push(shim); - }; - TypeScriptServicesFactory.prototype.unregisterShim = function (shim) { - for (var i = 0, n = this._shims.length; i < n; i++) { - if (this._shims[i] === shim) { - delete this._shims[i]; - return; - } - } - throw new Error("Invalid operation"); - }; - return TypeScriptServicesFactory; - }()); - ts.TypeScriptServicesFactory = TypeScriptServicesFactory; - if (typeof module !== "undefined" && module.exports) { - module.exports = ts; - } -})(ts || (ts = {})); -var TypeScript; -(function (TypeScript) { - var Services; - (function (Services) { - Services.TypeScriptServicesFactory = ts.TypeScriptServicesFactory; - })(Services = TypeScript.Services || (TypeScript.Services = {})); -})(TypeScript || (TypeScript = {})); -var toolsVersion = "2.1"; + +//# sourceMappingURL=tsserverlibrary.js.map diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index c915bd9efc8..ba46bcf1540 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -47,241 +47,241 @@ declare namespace ts { ConflictMarkerTrivia = 7, NumericLiteral = 8, StringLiteral = 9, - RegularExpressionLiteral = 10, - NoSubstitutionTemplateLiteral = 11, - TemplateHead = 12, - TemplateMiddle = 13, - TemplateTail = 14, - OpenBraceToken = 15, - CloseBraceToken = 16, - OpenParenToken = 17, - CloseParenToken = 18, - OpenBracketToken = 19, - CloseBracketToken = 20, - DotToken = 21, - DotDotDotToken = 22, - SemicolonToken = 23, - CommaToken = 24, - LessThanToken = 25, - LessThanSlashToken = 26, - GreaterThanToken = 27, - LessThanEqualsToken = 28, - GreaterThanEqualsToken = 29, - EqualsEqualsToken = 30, - ExclamationEqualsToken = 31, - EqualsEqualsEqualsToken = 32, - ExclamationEqualsEqualsToken = 33, - EqualsGreaterThanToken = 34, - PlusToken = 35, - MinusToken = 36, - AsteriskToken = 37, - 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, - NeverKeyword = 127, - ReadonlyKeyword = 128, - RequireKeyword = 129, - NumberKeyword = 130, - SetKeyword = 131, - StringKeyword = 132, - SymbolKeyword = 133, - TypeKeyword = 134, - UndefinedKeyword = 135, - FromKeyword = 136, - GlobalKeyword = 137, - OfKeyword = 138, - QualifiedName = 139, - ComputedPropertyName = 140, - TypeParameter = 141, - Parameter = 142, - Decorator = 143, - PropertySignature = 144, - PropertyDeclaration = 145, - MethodSignature = 146, - MethodDeclaration = 147, - Constructor = 148, - GetAccessor = 149, - SetAccessor = 150, - CallSignature = 151, - ConstructSignature = 152, - IndexSignature = 153, - TypePredicate = 154, - TypeReference = 155, - FunctionType = 156, - ConstructorType = 157, - TypeQuery = 158, - TypeLiteral = 159, - ArrayType = 160, - TupleType = 161, - UnionType = 162, - IntersectionType = 163, - ParenthesizedType = 164, - ThisType = 165, - LiteralType = 166, - ObjectBindingPattern = 167, - ArrayBindingPattern = 168, - BindingElement = 169, - ArrayLiteralExpression = 170, - ObjectLiteralExpression = 171, - PropertyAccessExpression = 172, - ElementAccessExpression = 173, - CallExpression = 174, - NewExpression = 175, - TaggedTemplateExpression = 176, - TypeAssertionExpression = 177, - ParenthesizedExpression = 178, - FunctionExpression = 179, - ArrowFunction = 180, - DeleteExpression = 181, - TypeOfExpression = 182, - VoidExpression = 183, - AwaitExpression = 184, - PrefixUnaryExpression = 185, - PostfixUnaryExpression = 186, - BinaryExpression = 187, - ConditionalExpression = 188, - TemplateExpression = 189, - YieldExpression = 190, - SpreadElementExpression = 191, - ClassExpression = 192, - OmittedExpression = 193, - ExpressionWithTypeArguments = 194, - AsExpression = 195, - NonNullExpression = 196, - TemplateSpan = 197, - SemicolonClassElement = 198, - Block = 199, - VariableStatement = 200, - EmptyStatement = 201, - ExpressionStatement = 202, - IfStatement = 203, - DoStatement = 204, - WhileStatement = 205, - ForStatement = 206, - ForInStatement = 207, - ForOfStatement = 208, - ContinueStatement = 209, - BreakStatement = 210, - ReturnStatement = 211, - WithStatement = 212, - SwitchStatement = 213, - LabeledStatement = 214, - ThrowStatement = 215, - TryStatement = 216, - DebuggerStatement = 217, - VariableDeclaration = 218, - VariableDeclarationList = 219, - FunctionDeclaration = 220, - ClassDeclaration = 221, - InterfaceDeclaration = 222, - TypeAliasDeclaration = 223, - EnumDeclaration = 224, - ModuleDeclaration = 225, - ModuleBlock = 226, - CaseBlock = 227, - NamespaceExportDeclaration = 228, - ImportEqualsDeclaration = 229, - ImportDeclaration = 230, - ImportClause = 231, - NamespaceImport = 232, - NamedImports = 233, - ImportSpecifier = 234, - ExportAssignment = 235, - ExportDeclaration = 236, - NamedExports = 237, - ExportSpecifier = 238, - MissingDeclaration = 239, - ExternalModuleReference = 240, - JsxElement = 241, - JsxSelfClosingElement = 242, - JsxOpeningElement = 243, - JsxText = 244, + JsxText = 10, + RegularExpressionLiteral = 11, + NoSubstitutionTemplateLiteral = 12, + TemplateHead = 13, + TemplateMiddle = 14, + TemplateTail = 15, + OpenBraceToken = 16, + CloseBraceToken = 17, + OpenParenToken = 18, + CloseParenToken = 19, + OpenBracketToken = 20, + CloseBracketToken = 21, + DotToken = 22, + DotDotDotToken = 23, + SemicolonToken = 24, + CommaToken = 25, + LessThanToken = 26, + LessThanSlashToken = 27, + GreaterThanToken = 28, + LessThanEqualsToken = 29, + GreaterThanEqualsToken = 30, + EqualsEqualsToken = 31, + ExclamationEqualsToken = 32, + EqualsEqualsEqualsToken = 33, + ExclamationEqualsEqualsToken = 34, + EqualsGreaterThanToken = 35, + PlusToken = 36, + MinusToken = 37, + AsteriskToken = 38, + AsteriskAsteriskToken = 39, + SlashToken = 40, + PercentToken = 41, + PlusPlusToken = 42, + MinusMinusToken = 43, + LessThanLessThanToken = 44, + GreaterThanGreaterThanToken = 45, + GreaterThanGreaterThanGreaterThanToken = 46, + AmpersandToken = 47, + BarToken = 48, + CaretToken = 49, + ExclamationToken = 50, + TildeToken = 51, + AmpersandAmpersandToken = 52, + BarBarToken = 53, + QuestionToken = 54, + ColonToken = 55, + AtToken = 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 = 69, + Identifier = 70, + BreakKeyword = 71, + CaseKeyword = 72, + CatchKeyword = 73, + ClassKeyword = 74, + ConstKeyword = 75, + ContinueKeyword = 76, + DebuggerKeyword = 77, + DefaultKeyword = 78, + DeleteKeyword = 79, + DoKeyword = 80, + ElseKeyword = 81, + EnumKeyword = 82, + ExportKeyword = 83, + ExtendsKeyword = 84, + FalseKeyword = 85, + FinallyKeyword = 86, + ForKeyword = 87, + FunctionKeyword = 88, + IfKeyword = 89, + ImportKeyword = 90, + InKeyword = 91, + InstanceOfKeyword = 92, + NewKeyword = 93, + NullKeyword = 94, + ReturnKeyword = 95, + SuperKeyword = 96, + SwitchKeyword = 97, + ThisKeyword = 98, + ThrowKeyword = 99, + TrueKeyword = 100, + TryKeyword = 101, + TypeOfKeyword = 102, + VarKeyword = 103, + VoidKeyword = 104, + WhileKeyword = 105, + WithKeyword = 106, + ImplementsKeyword = 107, + InterfaceKeyword = 108, + LetKeyword = 109, + PackageKeyword = 110, + PrivateKeyword = 111, + ProtectedKeyword = 112, + PublicKeyword = 113, + StaticKeyword = 114, + YieldKeyword = 115, + AbstractKeyword = 116, + AsKeyword = 117, + AnyKeyword = 118, + AsyncKeyword = 119, + AwaitKeyword = 120, + BooleanKeyword = 121, + ConstructorKeyword = 122, + DeclareKeyword = 123, + GetKeyword = 124, + IsKeyword = 125, + ModuleKeyword = 126, + NamespaceKeyword = 127, + NeverKeyword = 128, + ReadonlyKeyword = 129, + RequireKeyword = 130, + NumberKeyword = 131, + SetKeyword = 132, + StringKeyword = 133, + SymbolKeyword = 134, + TypeKeyword = 135, + UndefinedKeyword = 136, + FromKeyword = 137, + GlobalKeyword = 138, + OfKeyword = 139, + QualifiedName = 140, + ComputedPropertyName = 141, + TypeParameter = 142, + Parameter = 143, + Decorator = 144, + PropertySignature = 145, + PropertyDeclaration = 146, + MethodSignature = 147, + MethodDeclaration = 148, + Constructor = 149, + GetAccessor = 150, + SetAccessor = 151, + CallSignature = 152, + ConstructSignature = 153, + IndexSignature = 154, + TypePredicate = 155, + TypeReference = 156, + FunctionType = 157, + ConstructorType = 158, + TypeQuery = 159, + TypeLiteral = 160, + ArrayType = 161, + TupleType = 162, + UnionType = 163, + IntersectionType = 164, + ParenthesizedType = 165, + ThisType = 166, + LiteralType = 167, + ObjectBindingPattern = 168, + ArrayBindingPattern = 169, + BindingElement = 170, + ArrayLiteralExpression = 171, + ObjectLiteralExpression = 172, + PropertyAccessExpression = 173, + ElementAccessExpression = 174, + CallExpression = 175, + NewExpression = 176, + TaggedTemplateExpression = 177, + TypeAssertionExpression = 178, + ParenthesizedExpression = 179, + FunctionExpression = 180, + ArrowFunction = 181, + DeleteExpression = 182, + TypeOfExpression = 183, + VoidExpression = 184, + AwaitExpression = 185, + PrefixUnaryExpression = 186, + PostfixUnaryExpression = 187, + BinaryExpression = 188, + ConditionalExpression = 189, + TemplateExpression = 190, + YieldExpression = 191, + SpreadElementExpression = 192, + ClassExpression = 193, + OmittedExpression = 194, + ExpressionWithTypeArguments = 195, + AsExpression = 196, + NonNullExpression = 197, + TemplateSpan = 198, + SemicolonClassElement = 199, + Block = 200, + VariableStatement = 201, + EmptyStatement = 202, + ExpressionStatement = 203, + IfStatement = 204, + DoStatement = 205, + WhileStatement = 206, + ForStatement = 207, + ForInStatement = 208, + ForOfStatement = 209, + ContinueStatement = 210, + BreakStatement = 211, + ReturnStatement = 212, + WithStatement = 213, + SwitchStatement = 214, + LabeledStatement = 215, + ThrowStatement = 216, + TryStatement = 217, + DebuggerStatement = 218, + VariableDeclaration = 219, + VariableDeclarationList = 220, + FunctionDeclaration = 221, + ClassDeclaration = 222, + InterfaceDeclaration = 223, + TypeAliasDeclaration = 224, + EnumDeclaration = 225, + ModuleDeclaration = 226, + ModuleBlock = 227, + CaseBlock = 228, + NamespaceExportDeclaration = 229, + ImportEqualsDeclaration = 230, + ImportDeclaration = 231, + ImportClause = 232, + NamespaceImport = 233, + NamedImports = 234, + ImportSpecifier = 235, + ExportAssignment = 236, + ExportDeclaration = 237, + NamedExports = 238, + ExportSpecifier = 239, + MissingDeclaration = 240, + ExternalModuleReference = 241, + JsxElement = 242, + JsxSelfClosingElement = 243, + JsxOpeningElement = 244, JsxClosingElement = 245, JsxAttribute = 246, JsxSpreadAttribute = 247, @@ -327,31 +327,31 @@ declare namespace ts { NotEmittedStatement = 287, PartiallyEmittedExpression = 288, Count = 289, - FirstAssignment = 56, - LastAssignment = 68, - FirstCompoundAssignment = 57, - LastCompoundAssignment = 68, - FirstReservedWord = 70, - LastReservedWord = 105, - FirstKeyword = 70, - LastKeyword = 138, - FirstFutureReservedWord = 106, - LastFutureReservedWord = 114, - FirstTypeNode = 154, - LastTypeNode = 166, - FirstPunctuation = 15, - LastPunctuation = 68, + FirstAssignment = 57, + LastAssignment = 69, + FirstCompoundAssignment = 58, + LastCompoundAssignment = 69, + FirstReservedWord = 71, + LastReservedWord = 106, + FirstKeyword = 71, + LastKeyword = 139, + FirstFutureReservedWord = 107, + LastFutureReservedWord = 115, + FirstTypeNode = 155, + LastTypeNode = 167, + FirstPunctuation = 16, + LastPunctuation = 69, FirstToken = 0, - LastToken = 138, + LastToken = 139, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, - LastLiteralToken = 11, - FirstTemplateToken = 11, - LastTemplateToken = 14, - FirstBinaryOperator = 25, - LastBinaryOperator = 68, - FirstNode = 139, + LastLiteralToken = 12, + FirstTemplateToken = 12, + LastTemplateToken = 15, + FirstBinaryOperator = 26, + LastBinaryOperator = 69, + FirstNode = 140, FirstJSDocNode = 257, LastJSDocNode = 282, FirstJSDocTagNode = 273, @@ -406,6 +406,7 @@ declare namespace ts { AccessibilityModifier = 28, ParameterPropertyModifier = 92, NonPublicAccessibilityModifier = 24, + TypeScriptModifier = 2270, } enum JsxFlags { None = 0, @@ -1351,8 +1352,9 @@ declare namespace ts { TrueCondition = 32, FalseCondition = 64, SwitchClause = 128, - Referenced = 256, - Shared = 512, + ArrayMutation = 256, + Referenced = 512, + Shared = 1024, Label = 12, Condition = 96, } @@ -1380,6 +1382,10 @@ declare namespace ts { clauseEnd: number; antecedent: FlowNode; } + interface FlowArrayMutation extends FlowNode { + node: CallExpression | BinaryExpression; + antecedent: FlowNode; + } type FlowType = Type | IncompleteType; interface IncompleteType { flags: TypeFlags; @@ -1913,7 +1919,6 @@ declare namespace ts { AMD = 2, UMD = 3, System = 4, - ES6 = 5, ES2015 = 5, } enum JsxEmit { @@ -1939,9 +1944,10 @@ declare namespace ts { enum ScriptTarget { ES3 = 0, ES5 = 1, - ES6 = 2, ES2015 = 2, - Latest = 2, + ES2016 = 3, + ES2017 = 4, + Latest = 4, } enum LanguageVariant { Standard = 0, diff --git a/lib/typescript.js b/lib/typescript.js index c534a725901..dad603b624a 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -37,259 +37,259 @@ var ts; // Literals SyntaxKind[SyntaxKind["NumericLiteral"] = 8] = "NumericLiteral"; SyntaxKind[SyntaxKind["StringLiteral"] = 9] = "StringLiteral"; - SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 10] = "RegularExpressionLiteral"; - SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 11] = "NoSubstitutionTemplateLiteral"; + SyntaxKind[SyntaxKind["JsxText"] = 10] = "JsxText"; + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 11] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 12] = "NoSubstitutionTemplateLiteral"; // Pseudo-literals - SyntaxKind[SyntaxKind["TemplateHead"] = 12] = "TemplateHead"; - SyntaxKind[SyntaxKind["TemplateMiddle"] = 13] = "TemplateMiddle"; - SyntaxKind[SyntaxKind["TemplateTail"] = 14] = "TemplateTail"; + SyntaxKind[SyntaxKind["TemplateHead"] = 13] = "TemplateHead"; + SyntaxKind[SyntaxKind["TemplateMiddle"] = 14] = "TemplateMiddle"; + SyntaxKind[SyntaxKind["TemplateTail"] = 15] = "TemplateTail"; // Punctuation - SyntaxKind[SyntaxKind["OpenBraceToken"] = 15] = "OpenBraceToken"; - SyntaxKind[SyntaxKind["CloseBraceToken"] = 16] = "CloseBraceToken"; - SyntaxKind[SyntaxKind["OpenParenToken"] = 17] = "OpenParenToken"; - SyntaxKind[SyntaxKind["CloseParenToken"] = 18] = "CloseParenToken"; - SyntaxKind[SyntaxKind["OpenBracketToken"] = 19] = "OpenBracketToken"; - SyntaxKind[SyntaxKind["CloseBracketToken"] = 20] = "CloseBracketToken"; - SyntaxKind[SyntaxKind["DotToken"] = 21] = "DotToken"; - SyntaxKind[SyntaxKind["DotDotDotToken"] = 22] = "DotDotDotToken"; - SyntaxKind[SyntaxKind["SemicolonToken"] = 23] = "SemicolonToken"; - SyntaxKind[SyntaxKind["CommaToken"] = 24] = "CommaToken"; - SyntaxKind[SyntaxKind["LessThanToken"] = 25] = "LessThanToken"; - SyntaxKind[SyntaxKind["LessThanSlashToken"] = 26] = "LessThanSlashToken"; - SyntaxKind[SyntaxKind["GreaterThanToken"] = 27] = "GreaterThanToken"; - SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 28] = "LessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 29] = "GreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 30] = "EqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 31] = "ExclamationEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 32] = "EqualsEqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 33] = "ExclamationEqualsEqualsToken"; - SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 34] = "EqualsGreaterThanToken"; - SyntaxKind[SyntaxKind["PlusToken"] = 35] = "PlusToken"; - SyntaxKind[SyntaxKind["MinusToken"] = 36] = "MinusToken"; - SyntaxKind[SyntaxKind["AsteriskToken"] = 37] = "AsteriskToken"; - 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"; + SyntaxKind[SyntaxKind["OpenBraceToken"] = 16] = "OpenBraceToken"; + SyntaxKind[SyntaxKind["CloseBraceToken"] = 17] = "CloseBraceToken"; + SyntaxKind[SyntaxKind["OpenParenToken"] = 18] = "OpenParenToken"; + SyntaxKind[SyntaxKind["CloseParenToken"] = 19] = "CloseParenToken"; + SyntaxKind[SyntaxKind["OpenBracketToken"] = 20] = "OpenBracketToken"; + SyntaxKind[SyntaxKind["CloseBracketToken"] = 21] = "CloseBracketToken"; + SyntaxKind[SyntaxKind["DotToken"] = 22] = "DotToken"; + SyntaxKind[SyntaxKind["DotDotDotToken"] = 23] = "DotDotDotToken"; + SyntaxKind[SyntaxKind["SemicolonToken"] = 24] = "SemicolonToken"; + SyntaxKind[SyntaxKind["CommaToken"] = 25] = "CommaToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 26] = "LessThanToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 27] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 28] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 29] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 30] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 31] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 32] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 33] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 34] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 35] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 36] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 37] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 38] = "AsteriskToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 39] = "AsteriskAsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 40] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 41] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 42] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 43] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 44] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 45] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 46] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 47] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 48] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 49] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 50] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 51] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 52] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 53] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 54] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 55] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 56] = "AtToken"; // Assignments - 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"; + SyntaxKind[SyntaxKind["EqualsToken"] = 57] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 58] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 59] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 60] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 61] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 62] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 63] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 64] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 65] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 66] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 67] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 68] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 69] = "CaretEqualsToken"; // Identifiers - SyntaxKind[SyntaxKind["Identifier"] = 69] = "Identifier"; + SyntaxKind[SyntaxKind["Identifier"] = 70] = "Identifier"; // Reserved words - 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"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 71] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 72] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 73] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 74] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 75] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 76] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 77] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 78] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 79] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 80] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 81] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 82] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 83] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 84] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 85] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 86] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 87] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 88] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 89] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 90] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 91] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 92] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 93] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 94] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 95] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 96] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 97] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 98] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 99] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 100] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 101] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 102] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 103] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 104] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 105] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 106] = "WithKeyword"; // Strict mode reserved words - 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"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 107] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 108] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 109] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 110] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 111] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 112] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 113] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 114] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 115] = "YieldKeyword"; // Contextual keywords - 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["NeverKeyword"] = 127] = "NeverKeyword"; - SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 128] = "ReadonlyKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 129] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 130] = "NumberKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 131] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 132] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 133] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 134] = "TypeKeyword"; - SyntaxKind[SyntaxKind["UndefinedKeyword"] = 135] = "UndefinedKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 136] = "FromKeyword"; - SyntaxKind[SyntaxKind["GlobalKeyword"] = 137] = "GlobalKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 138] = "OfKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 116] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 117] = "AsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 118] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 119] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 120] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 121] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 122] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 123] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 124] = "GetKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 125] = "IsKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 126] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 127] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 128] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 129] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 130] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 131] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 132] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 133] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 134] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 135] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 136] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 137] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 138] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 139] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 139] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 140] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 140] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 141] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 141] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 142] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 143] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 142] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 143] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 144] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 144] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 145] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 146] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 147] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 148] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 149] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 150] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 151] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 152] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 153] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 145] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 146] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 147] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 148] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 149] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 150] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 151] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 152] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 153] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 154] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 154] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 155] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 156] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 157] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 158] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 159] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 160] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 161] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 162] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 163] = "IntersectionType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 164] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 165] = "ThisType"; - SyntaxKind[SyntaxKind["LiteralType"] = 166] = "LiteralType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 155] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 156] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 157] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 158] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 159] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 160] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 161] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 162] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 163] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 164] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 165] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 166] = "ThisType"; + SyntaxKind[SyntaxKind["LiteralType"] = 167] = "LiteralType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 167] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 168] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 169] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 168] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 169] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 170] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 170] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 171] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 172] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 173] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 174] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 175] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 176] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 177] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 178] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 179] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 180] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 181] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 182] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 183] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 184] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 185] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 186] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 187] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 188] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 189] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 190] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElementExpression"] = 191] = "SpreadElementExpression"; - SyntaxKind[SyntaxKind["ClassExpression"] = 192] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 193] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 194] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 195] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 196] = "NonNullExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 171] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 172] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 173] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 174] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 175] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 176] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 177] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 178] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 179] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 180] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 181] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 182] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 183] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 184] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 185] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 186] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 187] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 188] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 189] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 190] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 191] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElementExpression"] = 192] = "SpreadElementExpression"; + SyntaxKind[SyntaxKind["ClassExpression"] = 193] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 194] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 195] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 196] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 197] = "NonNullExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 197] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 198] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 198] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 199] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 199] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 200] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 201] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 202] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 203] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 204] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 205] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 206] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 207] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 208] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 209] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 210] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 211] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 212] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 213] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 214] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 215] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 216] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 217] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 218] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 219] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 220] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 221] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 222] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 223] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 224] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 225] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 226] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 227] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 228] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 229] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 230] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 231] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 232] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 233] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 234] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 235] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 236] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 237] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 238] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 239] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 200] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 201] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 202] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 203] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 204] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 205] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 206] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 207] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 208] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 209] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 210] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 211] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 212] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 213] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 214] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 215] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 216] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 217] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 218] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 219] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 220] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 221] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 222] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 223] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 224] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 225] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 226] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 227] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 228] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 229] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 230] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 231] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 232] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 233] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 234] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 235] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 236] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 237] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 238] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 239] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 240] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 240] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 241] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 241] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 242] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 243] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxText"] = 244] = "JsxText"; + SyntaxKind[SyntaxKind["JsxElement"] = 242] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 243] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 244] = "JsxOpeningElement"; SyntaxKind[SyntaxKind["JsxClosingElement"] = 245] = "JsxClosingElement"; SyntaxKind[SyntaxKind["JsxAttribute"] = 246] = "JsxAttribute"; SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 247] = "JsxSpreadAttribute"; @@ -346,31 +346,31 @@ var ts; // Enum value count SyntaxKind[SyntaxKind["Count"] = 289] = "Count"; // Markers - SyntaxKind[SyntaxKind["FirstAssignment"] = 56] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 68] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 57] = "FirstCompoundAssignment"; - SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 68] = "LastCompoundAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 70] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 105] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 70] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 138] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 106] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 114] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 154] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 166] = "LastTypeNode"; - SyntaxKind[SyntaxKind["FirstPunctuation"] = 15] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 68] = "LastPunctuation"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 57] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 69] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 58] = "FirstCompoundAssignment"; + SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 69] = "LastCompoundAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 71] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 106] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 71] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 139] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 107] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 115] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 155] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 167] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstPunctuation"] = 16] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 69] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 138] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 139] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; - SyntaxKind[SyntaxKind["LastLiteralToken"] = 11] = "LastLiteralToken"; - SyntaxKind[SyntaxKind["FirstTemplateToken"] = 11] = "FirstTemplateToken"; - SyntaxKind[SyntaxKind["LastTemplateToken"] = 14] = "LastTemplateToken"; - SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 25] = "FirstBinaryOperator"; - SyntaxKind[SyntaxKind["LastBinaryOperator"] = 68] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 139] = "FirstNode"; + SyntaxKind[SyntaxKind["LastLiteralToken"] = 12] = "LastLiteralToken"; + SyntaxKind[SyntaxKind["FirstTemplateToken"] = 12] = "FirstTemplateToken"; + SyntaxKind[SyntaxKind["LastTemplateToken"] = 15] = "LastTemplateToken"; + SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 26] = "FirstBinaryOperator"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 69] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstNode"] = 140] = "FirstNode"; SyntaxKind[SyntaxKind["FirstJSDocNode"] = 257] = "FirstJSDocNode"; SyntaxKind[SyntaxKind["LastJSDocNode"] = 282] = "LastJSDocNode"; SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 273] = "FirstJSDocTagNode"; @@ -430,6 +430,7 @@ var ts; // Accessibility modifiers and 'readonly' can be attached to a parameter in a constructor to make it a property. ModifierFlags[ModifierFlags["ParameterPropertyModifier"] = 92] = "ParameterPropertyModifier"; ModifierFlags[ModifierFlags["NonPublicAccessibilityModifier"] = 24] = "NonPublicAccessibilityModifier"; + ModifierFlags[ModifierFlags["TypeScriptModifier"] = 2270] = "TypeScriptModifier"; })(ts.ModifierFlags || (ts.ModifierFlags = {})); var ModifierFlags = ts.ModifierFlags; (function (JsxFlags) { @@ -466,8 +467,9 @@ var ts; FlowFlags[FlowFlags["TrueCondition"] = 32] = "TrueCondition"; FlowFlags[FlowFlags["FalseCondition"] = 64] = "FalseCondition"; FlowFlags[FlowFlags["SwitchClause"] = 128] = "SwitchClause"; - FlowFlags[FlowFlags["Referenced"] = 256] = "Referenced"; - FlowFlags[FlowFlags["Shared"] = 512] = "Shared"; + FlowFlags[FlowFlags["ArrayMutation"] = 256] = "ArrayMutation"; + FlowFlags[FlowFlags["Referenced"] = 512] = "Referenced"; + FlowFlags[FlowFlags["Shared"] = 1024] = "Shared"; FlowFlags[FlowFlags["Label"] = 12] = "Label"; FlowFlags[FlowFlags["Condition"] = 96] = "Condition"; })(ts.FlowFlags || (ts.FlowFlags = {})); @@ -755,7 +757,6 @@ var ts; ModuleKind[ModuleKind["AMD"] = 2] = "AMD"; ModuleKind[ModuleKind["UMD"] = 3] = "UMD"; ModuleKind[ModuleKind["System"] = 4] = "System"; - ModuleKind[ModuleKind["ES6"] = 5] = "ES6"; ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015"; })(ts.ModuleKind || (ts.ModuleKind = {})); var ModuleKind = ts.ModuleKind; @@ -781,9 +782,10 @@ var ts; (function (ScriptTarget) { ScriptTarget[ScriptTarget["ES3"] = 0] = "ES3"; ScriptTarget[ScriptTarget["ES5"] = 1] = "ES5"; - ScriptTarget[ScriptTarget["ES6"] = 2] = "ES6"; ScriptTarget[ScriptTarget["ES2015"] = 2] = "ES2015"; - ScriptTarget[ScriptTarget["Latest"] = 2] = "Latest"; + ScriptTarget[ScriptTarget["ES2016"] = 3] = "ES2016"; + ScriptTarget[ScriptTarget["ES2017"] = 4] = "ES2017"; + ScriptTarget[ScriptTarget["Latest"] = 4] = "Latest"; })(ts.ScriptTarget || (ts.ScriptTarget = {})); var ScriptTarget = ts.ScriptTarget; (function (LanguageVariant) { @@ -940,55 +942,58 @@ var ts; TransformFlags[TransformFlags["ContainsTypeScript"] = 2] = "ContainsTypeScript"; TransformFlags[TransformFlags["Jsx"] = 4] = "Jsx"; TransformFlags[TransformFlags["ContainsJsx"] = 8] = "ContainsJsx"; - TransformFlags[TransformFlags["ES7"] = 16] = "ES7"; - TransformFlags[TransformFlags["ContainsES7"] = 32] = "ContainsES7"; - TransformFlags[TransformFlags["ES6"] = 64] = "ES6"; - TransformFlags[TransformFlags["ContainsES6"] = 128] = "ContainsES6"; - TransformFlags[TransformFlags["DestructuringAssignment"] = 256] = "DestructuringAssignment"; - TransformFlags[TransformFlags["Generator"] = 512] = "Generator"; - TransformFlags[TransformFlags["ContainsGenerator"] = 1024] = "ContainsGenerator"; + TransformFlags[TransformFlags["ES2017"] = 16] = "ES2017"; + TransformFlags[TransformFlags["ContainsES2017"] = 32] = "ContainsES2017"; + TransformFlags[TransformFlags["ES2016"] = 64] = "ES2016"; + TransformFlags[TransformFlags["ContainsES2016"] = 128] = "ContainsES2016"; + TransformFlags[TransformFlags["ES2015"] = 256] = "ES2015"; + TransformFlags[TransformFlags["ContainsES2015"] = 512] = "ContainsES2015"; + TransformFlags[TransformFlags["DestructuringAssignment"] = 1024] = "DestructuringAssignment"; + TransformFlags[TransformFlags["Generator"] = 2048] = "Generator"; + TransformFlags[TransformFlags["ContainsGenerator"] = 4096] = "ContainsGenerator"; // Markers // - Flags used to indicate that a subtree contains a specific transformation. - TransformFlags[TransformFlags["ContainsDecorators"] = 2048] = "ContainsDecorators"; - TransformFlags[TransformFlags["ContainsPropertyInitializer"] = 4096] = "ContainsPropertyInitializer"; - TransformFlags[TransformFlags["ContainsLexicalThis"] = 8192] = "ContainsLexicalThis"; - TransformFlags[TransformFlags["ContainsCapturedLexicalThis"] = 16384] = "ContainsCapturedLexicalThis"; - TransformFlags[TransformFlags["ContainsLexicalThisInComputedPropertyName"] = 32768] = "ContainsLexicalThisInComputedPropertyName"; - TransformFlags[TransformFlags["ContainsDefaultValueAssignments"] = 65536] = "ContainsDefaultValueAssignments"; - TransformFlags[TransformFlags["ContainsParameterPropertyAssignments"] = 131072] = "ContainsParameterPropertyAssignments"; - TransformFlags[TransformFlags["ContainsSpreadElementExpression"] = 262144] = "ContainsSpreadElementExpression"; - TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 524288] = "ContainsComputedPropertyName"; - TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 1048576] = "ContainsBlockScopedBinding"; - TransformFlags[TransformFlags["ContainsBindingPattern"] = 2097152] = "ContainsBindingPattern"; - TransformFlags[TransformFlags["ContainsYield"] = 4194304] = "ContainsYield"; - TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 8388608] = "ContainsHoistedDeclarationOrCompletion"; + TransformFlags[TransformFlags["ContainsDecorators"] = 8192] = "ContainsDecorators"; + TransformFlags[TransformFlags["ContainsPropertyInitializer"] = 16384] = "ContainsPropertyInitializer"; + TransformFlags[TransformFlags["ContainsLexicalThis"] = 32768] = "ContainsLexicalThis"; + TransformFlags[TransformFlags["ContainsCapturedLexicalThis"] = 65536] = "ContainsCapturedLexicalThis"; + TransformFlags[TransformFlags["ContainsLexicalThisInComputedPropertyName"] = 131072] = "ContainsLexicalThisInComputedPropertyName"; + TransformFlags[TransformFlags["ContainsDefaultValueAssignments"] = 262144] = "ContainsDefaultValueAssignments"; + TransformFlags[TransformFlags["ContainsParameterPropertyAssignments"] = 524288] = "ContainsParameterPropertyAssignments"; + TransformFlags[TransformFlags["ContainsSpreadElementExpression"] = 1048576] = "ContainsSpreadElementExpression"; + TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 2097152] = "ContainsComputedPropertyName"; + TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 4194304] = "ContainsBlockScopedBinding"; + TransformFlags[TransformFlags["ContainsBindingPattern"] = 8388608] = "ContainsBindingPattern"; + TransformFlags[TransformFlags["ContainsYield"] = 16777216] = "ContainsYield"; + TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 33554432] = "ContainsHoistedDeclarationOrCompletion"; TransformFlags[TransformFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; // Assertions // - Bitmasks that are used to assert facts about the syntax of a node and its subtree. TransformFlags[TransformFlags["AssertTypeScript"] = 3] = "AssertTypeScript"; TransformFlags[TransformFlags["AssertJsx"] = 12] = "AssertJsx"; - TransformFlags[TransformFlags["AssertES7"] = 48] = "AssertES7"; - TransformFlags[TransformFlags["AssertES6"] = 192] = "AssertES6"; - TransformFlags[TransformFlags["AssertGenerator"] = 1536] = "AssertGenerator"; + TransformFlags[TransformFlags["AssertES2017"] = 48] = "AssertES2017"; + TransformFlags[TransformFlags["AssertES2016"] = 192] = "AssertES2016"; + TransformFlags[TransformFlags["AssertES2015"] = 768] = "AssertES2015"; + TransformFlags[TransformFlags["AssertGenerator"] = 6144] = "AssertGenerator"; // Scope Exclusions // - Bitmasks that exclude flags from propagating out of a specific context // into the subtree flags of their container. - TransformFlags[TransformFlags["NodeExcludes"] = 536871765] = "NodeExcludes"; - TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 550710101] = "ArrowFunctionExcludes"; - TransformFlags[TransformFlags["FunctionExcludes"] = 550726485] = "FunctionExcludes"; - TransformFlags[TransformFlags["ConstructorExcludes"] = 550593365] = "ConstructorExcludes"; - TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 550593365] = "MethodOrAccessorExcludes"; - TransformFlags[TransformFlags["ClassExcludes"] = 537590613] = "ClassExcludes"; - TransformFlags[TransformFlags["ModuleExcludes"] = 546335573] = "ModuleExcludes"; + TransformFlags[TransformFlags["NodeExcludes"] = 536874325] = "NodeExcludes"; + TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 592227669] = "ArrowFunctionExcludes"; + TransformFlags[TransformFlags["FunctionExcludes"] = 592293205] = "FunctionExcludes"; + TransformFlags[TransformFlags["ConstructorExcludes"] = 591760725] = "ConstructorExcludes"; + TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 591760725] = "MethodOrAccessorExcludes"; + TransformFlags[TransformFlags["ClassExcludes"] = 539749717] = "ClassExcludes"; + TransformFlags[TransformFlags["ModuleExcludes"] = 574729557] = "ModuleExcludes"; TransformFlags[TransformFlags["TypeExcludes"] = -3] = "TypeExcludes"; - TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 537430869] = "ObjectLiteralExcludes"; - TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 537133909] = "ArrayLiteralOrCallOrNewExcludes"; - TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 538968917] = "VariableDeclarationListExcludes"; - TransformFlags[TransformFlags["ParameterExcludes"] = 538968917] = "ParameterExcludes"; + TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 539110741] = "ObjectLiteralExcludes"; + TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 537922901] = "ArrayLiteralOrCallOrNewExcludes"; + TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 545262933] = "VariableDeclarationListExcludes"; + TransformFlags[TransformFlags["ParameterExcludes"] = 545262933] = "ParameterExcludes"; // Masks // - Additional bitmasks - TransformFlags[TransformFlags["TypeScriptClassSyntaxMask"] = 137216] = "TypeScriptClassSyntaxMask"; - TransformFlags[TransformFlags["ES6FunctionSyntaxMask"] = 81920] = "ES6FunctionSyntaxMask"; + TransformFlags[TransformFlags["TypeScriptClassSyntaxMask"] = 548864] = "TypeScriptClassSyntaxMask"; + TransformFlags[TransformFlags["ES2015FunctionSyntaxMask"] = 327680] = "ES2015FunctionSyntaxMask"; })(ts.TransformFlags || (ts.TransformFlags = {})); var TransformFlags = ts.TransformFlags; /* @internal */ @@ -1044,7 +1049,7 @@ var ts; (function (performance) { var profilerEvent = typeof onProfilerEvent === "function" && onProfilerEvent.profiler === true ? onProfilerEvent - : function (markName) { }; + : function (_markName) { }; var enabled = false; var profilerStart = 0; var counts; @@ -1146,6 +1151,8 @@ var ts; })(ts.Ternary || (ts.Ternary = {})); var Ternary = ts.Ternary; var createObject = Object.create; + // More efficient to create a collator once and use its `compare` than to call `a.localeCompare(b)` many times. + ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; function createMap(template) { var map = createObject(null); // tslint:disable-line:no-null-keyword // Using 'delete' on an object causes V8 to put the object in dictionary mode. @@ -1171,7 +1178,7 @@ var ts; remove: remove, forEachValue: forEachValueInMap, getKeys: getKeys, - clear: clear + clear: clear, }; function forEachValueInMap(f) { for (var key in files) { @@ -1378,13 +1385,33 @@ var ts; if (array) { result = []; for (var i = 0; i < array.length; i++) { - var v = array[i]; - result.push(f(v, i)); + result.push(f(array[i], i)); } } return result; } ts.map = map; + // Maps from T to T and avoids allocation if all elements map to themselves + function sameMap(array, f) { + var result; + if (array) { + for (var i = 0; i < array.length; i++) { + if (result) { + result.push(f(array[i], i)); + } + else { + var item = array[i]; + var mapped = f(item, i); + if (item !== mapped) { + result = array.slice(0, i); + result.push(mapped); + } + } + } + } + return result || array; + } + ts.sameMap = sameMap; /** * Flattens an array containing a mix of array or non-array elements. * @@ -1507,6 +1534,18 @@ var ts; return result; } ts.mapObject = mapObject; + function some(array, predicate) { + if (array) { + for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { + var v = array_5[_i]; + if (!predicate || predicate(v)) { + return true; + } + } + } + return false; + } + ts.some = some; function concatenate(array1, array2) { if (!array2 || !array2.length) return array1; @@ -1520,8 +1559,8 @@ var ts; var result; if (array) { result = []; - loop: for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { - var item = array_5[_i]; + loop: for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { + var item = array_6[_i]; for (var _a = 0, result_1 = result; _a < result_1.length; _a++) { var res = result_1[_a]; if (areEqual ? areEqual(res, item) : res === item) { @@ -1557,8 +1596,8 @@ var ts; ts.compact = compact; function sum(array, prop) { var result = 0; - for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { - var v = array_6[_i]; + for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { + var v = array_7[_i]; result += v[prop]; } return result; @@ -1857,8 +1896,8 @@ var ts; ts.equalOwnProperties = equalOwnProperties; function arrayToMap(array, makeKey, makeValue) { var result = createMap(); - for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { - var value = array_7[_i]; + for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { + var value = array_8[_i]; result[makeKey(value)] = makeValue ? makeValue(value) : value; } return result; @@ -1971,7 +2010,7 @@ var ts; return function (t) { return compose(a(t)); }; } else { - return function (t) { return function (u) { return u; }; }; + return function (_) { return function (u) { return u; }; }; } } ts.chain = chain; @@ -2002,7 +2041,7 @@ var ts; ts.compose = compose; function formatStringFromArgs(text, args, baseIndex) { baseIndex = baseIndex || 0; - return text.replace(/{(\d+)}/g, function (match, index) { return args[+index + baseIndex]; }); + return text.replace(/{(\d+)}/g, function (_match, index) { return args[+index + baseIndex]; }); } ts.localizedDiagnosticMessages = undefined; function getLocaleSpecificMessage(message) { @@ -2027,12 +2066,12 @@ var ts; length: length, messageText: text, category: message.category, - code: message.code + code: message.code, }; } ts.createFileDiagnostic = createFileDiagnostic; /* internal */ - function formatMessage(dummy, message) { + function formatMessage(_dummy, message) { var text = getLocaleSpecificMessage(message); if (arguments.length > 2) { text = formatStringFromArgs(text, arguments, 2); @@ -2095,7 +2134,8 @@ var ts; if (b === undefined) return 1 /* GreaterThan */; if (ignoreCase) { - if (String.prototype.localeCompare) { + if (ts.collator && String.prototype.localeCompare) { + // accent means a ≠ b, a ≠ á, a = A var result = a.localeCompare(b, /*locales*/ undefined, { usage: "sort", sensitivity: "accent" }); return result < 0 ? -1 /* LessThan */ : result > 0 ? 1 /* GreaterThan */ : 0 /* EqualTo */; } @@ -2269,7 +2309,7 @@ var ts; function getEmitModuleKind(compilerOptions) { return typeof compilerOptions.module === "number" ? compilerOptions.module : - getEmitScriptTarget(compilerOptions) === 2 /* ES6 */ ? ts.ModuleKind.ES6 : ts.ModuleKind.CommonJS; + getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */ ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS; } ts.getEmitModuleKind = getEmitModuleKind; /* @internal */ @@ -2617,7 +2657,7 @@ var ts; function replaceWildcardCharacter(match, singleAsteriskRegexFragment) { return match === "*" ? singleAsteriskRegexFragment : match === "?" ? "[^/]" : "\\" + match; } - function getFileMatcherPatterns(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory) { + function getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory) { path = normalizePath(path); currentDirectory = normalizePath(currentDirectory); var absolutePath = combinePaths(currentDirectory, path); @@ -2632,7 +2672,7 @@ var ts; function matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, getFileSystemEntries) { path = normalizePath(path); currentDirectory = normalizePath(currentDirectory); - var patterns = getFileMatcherPatterns(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory); + var patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory); var regexFlag = useCaseSensitiveFileNames ? "" : "i"; var includeFileRegex = patterns.includeFilePattern && new RegExp(patterns.includeFilePattern, regexFlag); var includeDirectoryRegex = patterns.includeDirectoryPattern && new RegExp(patterns.includeDirectoryPattern, regexFlag); @@ -2847,10 +2887,10 @@ var ts; this.name = name; this.declarations = undefined; } - function Type(checker, flags) { + function Type(_checker, flags) { this.flags = flags; } - function Signature(checker) { + function Signature() { } function Node(kind, pos, end) { this.id = 0; @@ -3230,7 +3270,7 @@ var ts; } var platform = _os.platform(); var useCaseSensitiveFileNames = isFileSystemCaseSensitive(); - function readFile(fileName, encoding) { + function readFile(fileName, _encoding) { if (!fileExists(fileName)) { return undefined; } @@ -3462,7 +3502,7 @@ var ts; args: ChakraHost.args, useCaseSensitiveFileNames: !!ChakraHost.useCaseSensitiveFileNames, write: ChakraHost.echo, - readFile: function (path, encoding) { + readFile: function (path, _encoding) { // encoding is automatically handled by the implementation in ChakraHost return ChakraHost.readFile(path); }, @@ -3480,9 +3520,9 @@ var ts; getExecutingFilePath: function () { return ChakraHost.executingFile; }, getCurrentDirectory: function () { return ChakraHost.currentDirectory; }, getDirectories: ChakraHost.getDirectories, - getEnvironmentVariable: ChakraHost.getEnvironmentVariable || (function (name) { return ""; }), + getEnvironmentVariable: ChakraHost.getEnvironmentVariable || (function () { return ""; }), readDirectory: function (path, extensions, excludes, includes) { - var pattern = ts.getFileMatcherPatterns(path, extensions, excludes, includes, !!ChakraHost.useCaseSensitiveFileNames, ChakraHost.currentDirectory); + var pattern = ts.getFileMatcherPatterns(path, excludes, includes, !!ChakraHost.useCaseSensitiveFileNames, ChakraHost.currentDirectory); return ChakraHost.readDirectory(path, extensions, pattern.basePaths, pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern); }, exit: ChakraHost.quit, @@ -4276,7 +4316,7 @@ var ts; Binding_element_0_implicitly_has_an_1_type: { code: 7031, category: ts.DiagnosticCategory.Error, key: "Binding_element_0_implicitly_has_an_1_type_7031", message: "Binding element '{0}' implicitly has an '{1}' type." }, Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation: { code: 7032, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation_7032", message: "Property '{0}' implicitly has type 'any', because its set accessor lacks a parameter type annotation." }, Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation: { code: 7033, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation_7033", message: "Property '{0}' implicitly has type 'any', because its get accessor lacks a return type annotation." }, - Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined: { code: 7034, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined_7034", message: "Variable '{0}' implicitly has type 'any' in some locations where its type cannot be determined." }, + Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined: { code: 7034, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined_7034", message: "Variable '{0}' implicitly has type '{1}' in some locations where its type cannot be determined." }, You_cannot_rename_this_element: { code: 8000, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_this_element_8000", message: "You cannot rename this element." }, You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", message: "You cannot rename elements that are defined in the standard TypeScript library." }, import_can_only_be_used_in_a_ts_file: { code: 8002, category: ts.DiagnosticCategory.Error, key: "import_can_only_be_used_in_a_ts_file_8002", message: "'import ... =' can only be used in a .ts file." }, @@ -4313,7 +4353,7 @@ var ts; Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers" }, Implement_interface_on_reference: { code: 90005, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_reference_90005", message: "Implement interface on reference" }, Implement_interface_on_class: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_class_90006", message: "Implement interface on class" }, - Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" } + Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" }, }; })(ts || (ts = {})); /// @@ -4322,133 +4362,133 @@ var ts; (function (ts) { /* @internal */ function tokenIsIdentifierOrKeyword(token) { - return token >= 69 /* Identifier */; + return token >= 70 /* Identifier */; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; var textToToken = ts.createMap({ - "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": 136 /* 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 */, - "never": 127 /* NeverKeyword */, - "new": 92 /* NewKeyword */, - "null": 93 /* NullKeyword */, - "number": 130 /* NumberKeyword */, - "package": 109 /* PackageKeyword */, - "private": 110 /* PrivateKeyword */, - "protected": 111 /* ProtectedKeyword */, - "public": 112 /* PublicKeyword */, - "readonly": 128 /* ReadonlyKeyword */, - "require": 129 /* RequireKeyword */, - "global": 137 /* GlobalKeyword */, - "return": 94 /* ReturnKeyword */, - "set": 131 /* SetKeyword */, - "static": 113 /* StaticKeyword */, - "string": 132 /* StringKeyword */, - "super": 95 /* SuperKeyword */, - "switch": 96 /* SwitchKeyword */, - "symbol": 133 /* SymbolKeyword */, - "this": 97 /* ThisKeyword */, - "throw": 98 /* ThrowKeyword */, - "true": 99 /* TrueKeyword */, - "try": 100 /* TryKeyword */, - "type": 134 /* TypeKeyword */, - "typeof": 101 /* TypeOfKeyword */, - "undefined": 135 /* UndefinedKeyword */, - "var": 102 /* VarKeyword */, - "void": 103 /* VoidKeyword */, - "while": 104 /* WhileKeyword */, - "with": 105 /* WithKeyword */, - "yield": 114 /* YieldKeyword */, - "async": 118 /* AsyncKeyword */, - "await": 119 /* AwaitKeyword */, - "of": 138 /* OfKeyword */, - "{": 15 /* OpenBraceToken */, - "}": 16 /* CloseBraceToken */, - "(": 17 /* OpenParenToken */, - ")": 18 /* CloseParenToken */, - "[": 19 /* OpenBracketToken */, - "]": 20 /* CloseBracketToken */, - ".": 21 /* DotToken */, - "...": 22 /* DotDotDotToken */, - ";": 23 /* SemicolonToken */, - ",": 24 /* CommaToken */, - "<": 25 /* LessThanToken */, - ">": 27 /* GreaterThanToken */, - "<=": 28 /* LessThanEqualsToken */, - ">=": 29 /* GreaterThanEqualsToken */, - "==": 30 /* EqualsEqualsToken */, - "!=": 31 /* ExclamationEqualsToken */, - "===": 32 /* EqualsEqualsEqualsToken */, - "!==": 33 /* ExclamationEqualsEqualsToken */, - "=>": 34 /* EqualsGreaterThanToken */, - "+": 35 /* PlusToken */, - "-": 36 /* MinusToken */, - "**": 38 /* AsteriskAsteriskToken */, - "*": 37 /* AsteriskToken */, - "/": 39 /* SlashToken */, - "%": 40 /* PercentToken */, - "++": 41 /* PlusPlusToken */, - "--": 42 /* MinusMinusToken */, - "<<": 43 /* LessThanLessThanToken */, - ">": 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 */ + "abstract": 116 /* AbstractKeyword */, + "any": 118 /* AnyKeyword */, + "as": 117 /* AsKeyword */, + "boolean": 121 /* BooleanKeyword */, + "break": 71 /* BreakKeyword */, + "case": 72 /* CaseKeyword */, + "catch": 73 /* CatchKeyword */, + "class": 74 /* ClassKeyword */, + "continue": 76 /* ContinueKeyword */, + "const": 75 /* ConstKeyword */, + "constructor": 122 /* ConstructorKeyword */, + "debugger": 77 /* DebuggerKeyword */, + "declare": 123 /* DeclareKeyword */, + "default": 78 /* DefaultKeyword */, + "delete": 79 /* DeleteKeyword */, + "do": 80 /* DoKeyword */, + "else": 81 /* ElseKeyword */, + "enum": 82 /* EnumKeyword */, + "export": 83 /* ExportKeyword */, + "extends": 84 /* ExtendsKeyword */, + "false": 85 /* FalseKeyword */, + "finally": 86 /* FinallyKeyword */, + "for": 87 /* ForKeyword */, + "from": 137 /* FromKeyword */, + "function": 88 /* FunctionKeyword */, + "get": 124 /* GetKeyword */, + "if": 89 /* IfKeyword */, + "implements": 107 /* ImplementsKeyword */, + "import": 90 /* ImportKeyword */, + "in": 91 /* InKeyword */, + "instanceof": 92 /* InstanceOfKeyword */, + "interface": 108 /* InterfaceKeyword */, + "is": 125 /* IsKeyword */, + "let": 109 /* LetKeyword */, + "module": 126 /* ModuleKeyword */, + "namespace": 127 /* NamespaceKeyword */, + "never": 128 /* NeverKeyword */, + "new": 93 /* NewKeyword */, + "null": 94 /* NullKeyword */, + "number": 131 /* NumberKeyword */, + "package": 110 /* PackageKeyword */, + "private": 111 /* PrivateKeyword */, + "protected": 112 /* ProtectedKeyword */, + "public": 113 /* PublicKeyword */, + "readonly": 129 /* ReadonlyKeyword */, + "require": 130 /* RequireKeyword */, + "global": 138 /* GlobalKeyword */, + "return": 95 /* ReturnKeyword */, + "set": 132 /* SetKeyword */, + "static": 114 /* StaticKeyword */, + "string": 133 /* StringKeyword */, + "super": 96 /* SuperKeyword */, + "switch": 97 /* SwitchKeyword */, + "symbol": 134 /* SymbolKeyword */, + "this": 98 /* ThisKeyword */, + "throw": 99 /* ThrowKeyword */, + "true": 100 /* TrueKeyword */, + "try": 101 /* TryKeyword */, + "type": 135 /* TypeKeyword */, + "typeof": 102 /* TypeOfKeyword */, + "undefined": 136 /* UndefinedKeyword */, + "var": 103 /* VarKeyword */, + "void": 104 /* VoidKeyword */, + "while": 105 /* WhileKeyword */, + "with": 106 /* WithKeyword */, + "yield": 115 /* YieldKeyword */, + "async": 119 /* AsyncKeyword */, + "await": 120 /* AwaitKeyword */, + "of": 139 /* OfKeyword */, + "{": 16 /* OpenBraceToken */, + "}": 17 /* CloseBraceToken */, + "(": 18 /* OpenParenToken */, + ")": 19 /* CloseParenToken */, + "[": 20 /* OpenBracketToken */, + "]": 21 /* CloseBracketToken */, + ".": 22 /* DotToken */, + "...": 23 /* DotDotDotToken */, + ";": 24 /* SemicolonToken */, + ",": 25 /* CommaToken */, + "<": 26 /* LessThanToken */, + ">": 28 /* GreaterThanToken */, + "<=": 29 /* LessThanEqualsToken */, + ">=": 30 /* GreaterThanEqualsToken */, + "==": 31 /* EqualsEqualsToken */, + "!=": 32 /* ExclamationEqualsToken */, + "===": 33 /* EqualsEqualsEqualsToken */, + "!==": 34 /* ExclamationEqualsEqualsToken */, + "=>": 35 /* EqualsGreaterThanToken */, + "+": 36 /* PlusToken */, + "-": 37 /* MinusToken */, + "**": 39 /* AsteriskAsteriskToken */, + "*": 38 /* AsteriskToken */, + "/": 40 /* SlashToken */, + "%": 41 /* PercentToken */, + "++": 42 /* PlusPlusToken */, + "--": 43 /* MinusMinusToken */, + "<<": 44 /* LessThanLessThanToken */, + ">": 45 /* GreaterThanGreaterThanToken */, + ">>>": 46 /* GreaterThanGreaterThanGreaterThanToken */, + "&": 47 /* AmpersandToken */, + "|": 48 /* BarToken */, + "^": 49 /* CaretToken */, + "!": 50 /* ExclamationToken */, + "~": 51 /* TildeToken */, + "&&": 52 /* AmpersandAmpersandToken */, + "||": 53 /* BarBarToken */, + "?": 54 /* QuestionToken */, + ":": 55 /* ColonToken */, + "=": 57 /* EqualsToken */, + "+=": 58 /* PlusEqualsToken */, + "-=": 59 /* MinusEqualsToken */, + "*=": 60 /* AsteriskEqualsToken */, + "**=": 61 /* AsteriskAsteriskEqualsToken */, + "/=": 62 /* SlashEqualsToken */, + "%=": 63 /* PercentEqualsToken */, + "<<=": 64 /* LessThanLessThanEqualsToken */, + ">>=": 65 /* GreaterThanGreaterThanEqualsToken */, + ">>>=": 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */, + "&=": 67 /* AmpersandEqualsToken */, + "|=": 68 /* BarEqualsToken */, + "^=": 69 /* CaretEqualsToken */, + "@": 56 /* AtToken */, }); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers @@ -4952,7 +4992,7 @@ var ts; return iterateCommentRanges(/*reduce*/ true, text, pos, /*trailing*/ true, cb, state, initial); } ts.reduceEachTrailingCommentRange = reduceEachTrailingCommentRange; - function appendCommentRange(pos, end, kind, hasTrailingNewLine, state, comments) { + function appendCommentRange(pos, end, kind, hasTrailingNewLine, _state, comments) { if (!comments) { comments = []; } @@ -5025,8 +5065,8 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 69 /* Identifier */ || token > 105 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 70 /* FirstReservedWord */ && token <= 105 /* LastReservedWord */; }, + isIdentifier: function () { return token === 70 /* Identifier */ || token > 106 /* LastReservedWord */; }, + isReservedWord: function () { return token >= 71 /* FirstReservedWord */ && token <= 106 /* LastReservedWord */; }, isUnterminated: function () { return tokenIsUnterminated; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, @@ -5045,7 +5085,7 @@ var ts; setTextPos: setTextPos, tryScan: tryScan, lookAhead: lookAhead, - scanRange: scanRange + scanRange: scanRange, }; function error(message, length) { if (onError) { @@ -5174,7 +5214,7 @@ var ts; contents += text.substring(start, pos); tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 11 /* NoSubstitutionTemplateLiteral */ : 14 /* TemplateTail */; + resultingToken = startedWithBacktick ? 12 /* NoSubstitutionTemplateLiteral */ : 15 /* TemplateTail */; break; } var currChar = text.charCodeAt(pos); @@ -5182,14 +5222,14 @@ var ts; if (currChar === 96 /* backtick */) { contents += text.substring(start, pos); pos++; - resultingToken = startedWithBacktick ? 11 /* NoSubstitutionTemplateLiteral */ : 14 /* TemplateTail */; + resultingToken = startedWithBacktick ? 12 /* NoSubstitutionTemplateLiteral */ : 15 /* TemplateTail */; break; } // '${' if (currChar === 36 /* $ */ && pos + 1 < end && text.charCodeAt(pos + 1) === 123 /* openBrace */) { contents += text.substring(start, pos); pos += 2; - resultingToken = startedWithBacktick ? 12 /* TemplateHead */ : 13 /* TemplateMiddle */; + resultingToken = startedWithBacktick ? 13 /* TemplateHead */ : 14 /* TemplateMiddle */; break; } // Escape character @@ -5367,7 +5407,7 @@ var ts; return token = textToToken[tokenValue]; } } - return token = 69 /* Identifier */; + return token = 70 /* Identifier */; } function scanBinaryOrOctalDigits(base) { ts.Debug.assert(base === 2 || base === 8, "Expected either base 2 or base 8"); @@ -5447,12 +5487,12 @@ var ts; case 33 /* exclamation */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 33 /* ExclamationEqualsEqualsToken */; + return pos += 3, token = 34 /* ExclamationEqualsEqualsToken */; } - return pos += 2, token = 31 /* ExclamationEqualsToken */; + return pos += 2, token = 32 /* ExclamationEqualsToken */; } pos++; - return token = 49 /* ExclamationToken */; + return token = 50 /* ExclamationToken */; case 34 /* doubleQuote */: case 39 /* singleQuote */: tokenValue = scanString(); @@ -5461,68 +5501,68 @@ var ts; return token = scanTemplateAndSetTokenValue(); case 37 /* percent */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 62 /* PercentEqualsToken */; + return pos += 2, token = 63 /* PercentEqualsToken */; } pos++; - return token = 40 /* PercentToken */; + return token = 41 /* PercentToken */; case 38 /* ampersand */: if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - return pos += 2, token = 51 /* AmpersandAmpersandToken */; + return pos += 2, token = 52 /* AmpersandAmpersandToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 66 /* AmpersandEqualsToken */; + return pos += 2, token = 67 /* AmpersandEqualsToken */; } pos++; - return token = 46 /* AmpersandToken */; + return token = 47 /* AmpersandToken */; case 40 /* openParen */: pos++; - return token = 17 /* OpenParenToken */; + return token = 18 /* OpenParenToken */; case 41 /* closeParen */: pos++; - return token = 18 /* CloseParenToken */; + return token = 19 /* CloseParenToken */; case 42 /* asterisk */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 59 /* AsteriskEqualsToken */; + return pos += 2, token = 60 /* AsteriskEqualsToken */; } if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 60 /* AsteriskAsteriskEqualsToken */; + return pos += 3, token = 61 /* AsteriskAsteriskEqualsToken */; } - return pos += 2, token = 38 /* AsteriskAsteriskToken */; + return pos += 2, token = 39 /* AsteriskAsteriskToken */; } pos++; - return token = 37 /* AsteriskToken */; + return token = 38 /* AsteriskToken */; case 43 /* plus */: if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 41 /* PlusPlusToken */; + return pos += 2, token = 42 /* PlusPlusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 57 /* PlusEqualsToken */; + return pos += 2, token = 58 /* PlusEqualsToken */; } pos++; - return token = 35 /* PlusToken */; + return token = 36 /* PlusToken */; case 44 /* comma */: pos++; - return token = 24 /* CommaToken */; + return token = 25 /* CommaToken */; case 45 /* minus */: if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 42 /* MinusMinusToken */; + return pos += 2, token = 43 /* MinusMinusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 58 /* MinusEqualsToken */; + return pos += 2, token = 59 /* MinusEqualsToken */; } pos++; - return token = 36 /* MinusToken */; + return token = 37 /* MinusToken */; case 46 /* dot */: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = scanNumber(); return token = 8 /* NumericLiteral */; } if (text.charCodeAt(pos + 1) === 46 /* dot */ && text.charCodeAt(pos + 2) === 46 /* dot */) { - return pos += 3, token = 22 /* DotDotDotToken */; + return pos += 3, token = 23 /* DotDotDotToken */; } pos++; - return token = 21 /* DotToken */; + return token = 22 /* DotToken */; case 47 /* slash */: // Single-line comment if (text.charCodeAt(pos + 1) === 47 /* slash */) { @@ -5568,10 +5608,10 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 61 /* SlashEqualsToken */; + return pos += 2, token = 62 /* SlashEqualsToken */; } pos++; - return token = 39 /* SlashToken */; + return token = 40 /* SlashToken */; case 48 /* _0 */: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { pos += 2; @@ -5624,10 +5664,10 @@ var ts; return token = 8 /* NumericLiteral */; case 58 /* colon */: pos++; - return token = 54 /* ColonToken */; + return token = 55 /* ColonToken */; case 59 /* semicolon */: pos++; - return token = 23 /* SemicolonToken */; + return token = 24 /* SemicolonToken */; case 60 /* lessThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -5640,20 +5680,20 @@ var ts; } if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 63 /* LessThanLessThanEqualsToken */; + return pos += 3, token = 64 /* LessThanLessThanEqualsToken */; } - return pos += 2, token = 43 /* LessThanLessThanToken */; + return pos += 2, token = 44 /* LessThanLessThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 28 /* LessThanEqualsToken */; + return pos += 2, token = 29 /* LessThanEqualsToken */; } if (languageVariant === 1 /* JSX */ && text.charCodeAt(pos + 1) === 47 /* slash */ && text.charCodeAt(pos + 2) !== 42 /* asterisk */) { - return pos += 2, token = 26 /* LessThanSlashToken */; + return pos += 2, token = 27 /* LessThanSlashToken */; } pos++; - return token = 25 /* LessThanToken */; + return token = 26 /* LessThanToken */; case 61 /* equals */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -5666,15 +5706,15 @@ var ts; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 32 /* EqualsEqualsEqualsToken */; + return pos += 3, token = 33 /* EqualsEqualsEqualsToken */; } - return pos += 2, token = 30 /* EqualsEqualsToken */; + return pos += 2, token = 31 /* EqualsEqualsToken */; } if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 34 /* EqualsGreaterThanToken */; + return pos += 2, token = 35 /* EqualsGreaterThanToken */; } pos++; - return token = 56 /* EqualsToken */; + return token = 57 /* EqualsToken */; case 62 /* greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -5686,43 +5726,43 @@ var ts; } } pos++; - return token = 27 /* GreaterThanToken */; + return token = 28 /* GreaterThanToken */; case 63 /* question */: pos++; - return token = 53 /* QuestionToken */; + return token = 54 /* QuestionToken */; case 91 /* openBracket */: pos++; - return token = 19 /* OpenBracketToken */; + return token = 20 /* OpenBracketToken */; case 93 /* closeBracket */: pos++; - return token = 20 /* CloseBracketToken */; + return token = 21 /* CloseBracketToken */; case 94 /* caret */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 68 /* CaretEqualsToken */; + return pos += 2, token = 69 /* CaretEqualsToken */; } pos++; - return token = 48 /* CaretToken */; + return token = 49 /* CaretToken */; case 123 /* openBrace */: pos++; - return token = 15 /* OpenBraceToken */; + return token = 16 /* OpenBraceToken */; case 124 /* bar */: if (text.charCodeAt(pos + 1) === 124 /* bar */) { - return pos += 2, token = 52 /* BarBarToken */; + return pos += 2, token = 53 /* BarBarToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 67 /* BarEqualsToken */; + return pos += 2, token = 68 /* BarEqualsToken */; } pos++; - return token = 47 /* BarToken */; + return token = 48 /* BarToken */; case 125 /* closeBrace */: pos++; - return token = 16 /* CloseBraceToken */; + return token = 17 /* CloseBraceToken */; case 126 /* tilde */: pos++; - return token = 50 /* TildeToken */; + return token = 51 /* TildeToken */; case 64 /* at */: pos++; - return token = 55 /* AtToken */; + return token = 56 /* AtToken */; case 92 /* backslash */: var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { @@ -5760,29 +5800,29 @@ var ts; } } function reScanGreaterToken() { - if (token === 27 /* GreaterThanToken */) { + if (token === 28 /* GreaterThanToken */) { if (text.charCodeAt(pos) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + return pos += 3, token = 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 45 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 46 /* GreaterThanGreaterThanGreaterThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 64 /* GreaterThanGreaterThanEqualsToken */; + return pos += 2, token = 65 /* GreaterThanGreaterThanEqualsToken */; } pos++; - return token = 44 /* GreaterThanGreaterThanToken */; + return token = 45 /* GreaterThanGreaterThanToken */; } if (text.charCodeAt(pos) === 61 /* equals */) { pos++; - return token = 29 /* GreaterThanEqualsToken */; + return token = 30 /* GreaterThanEqualsToken */; } } return token; } function reScanSlashToken() { - if (token === 39 /* SlashToken */ || token === 61 /* SlashEqualsToken */) { + if (token === 40 /* SlashToken */ || token === 62 /* SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -5827,7 +5867,7 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 10 /* RegularExpressionLiteral */; + token = 11 /* RegularExpressionLiteral */; } return token; } @@ -5835,7 +5875,7 @@ var ts; * Unconditionally back up and scan a template expression portion. */ function reScanTemplateToken() { - ts.Debug.assert(token === 16 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); + ts.Debug.assert(token === 17 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); pos = tokenPos; return token = scanTemplateAndSetTokenValue(); } @@ -5852,14 +5892,14 @@ var ts; if (char === 60 /* lessThan */) { if (text.charCodeAt(pos + 1) === 47 /* slash */) { pos += 2; - return token = 26 /* LessThanSlashToken */; + return token = 27 /* LessThanSlashToken */; } pos++; - return token = 25 /* LessThanToken */; + return token = 26 /* LessThanToken */; } if (char === 123 /* openBrace */) { pos++; - return token = 15 /* OpenBraceToken */; + return token = 16 /* OpenBraceToken */; } while (pos < end) { pos++; @@ -5868,7 +5908,7 @@ var ts; break; } } - return token = 244 /* JsxText */; + return token = 10 /* JsxText */; } // Scans a JSX identifier; these differ from normal identifiers in that // they allow dashes @@ -5918,39 +5958,39 @@ var ts; return token = 5 /* WhitespaceTrivia */; case 64 /* at */: pos++; - return token = 55 /* AtToken */; + return token = 56 /* AtToken */; case 10 /* lineFeed */: case 13 /* carriageReturn */: pos++; return token = 4 /* NewLineTrivia */; case 42 /* asterisk */: pos++; - return token = 37 /* AsteriskToken */; + return token = 38 /* AsteriskToken */; case 123 /* openBrace */: pos++; - return token = 15 /* OpenBraceToken */; + return token = 16 /* OpenBraceToken */; case 125 /* closeBrace */: pos++; - return token = 16 /* CloseBraceToken */; + return token = 17 /* CloseBraceToken */; case 91 /* openBracket */: pos++; - return token = 19 /* OpenBracketToken */; + return token = 20 /* OpenBracketToken */; case 93 /* closeBracket */: pos++; - return token = 20 /* CloseBracketToken */; + return token = 21 /* CloseBracketToken */; case 61 /* equals */: pos++; - return token = 56 /* EqualsToken */; + return token = 57 /* EqualsToken */; case 44 /* comma */: pos++; - return token = 24 /* CommaToken */; + return token = 25 /* CommaToken */; } - if (isIdentifierStart(ch, 2 /* Latest */)) { + if (isIdentifierStart(ch, 4 /* Latest */)) { pos++; - while (isIdentifierPart(text.charCodeAt(pos), 2 /* Latest */) && pos < end) { + while (isIdentifierPart(text.charCodeAt(pos), 4 /* Latest */) && pos < end) { pos++; } - return token = 69 /* Identifier */; + return token = 70 /* Identifier */; } else { return pos += 1, token = 0 /* Unknown */; @@ -6189,11 +6229,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 199 /* Block */: - case 227 /* CaseBlock */: - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: + case 200 /* Block */: + case 228 /* CaseBlock */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: return true; } return false; @@ -6329,14 +6369,14 @@ var ts; function getLiteralText(node, sourceFile, languageVersion) { // Any template literal or string literal with an extended escape // (e.g. "\u{0067}") will need to be downleveled as a escaped string literal. - if (languageVersion < 2 /* ES6 */ && (isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { + if (languageVersion < 2 /* ES2015 */ && (isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { return getQuotedEscapedLiteralText('"', node.text, '"'); } // If we don't need to downlevel and we can reach the original source text using // the node's parent reference, then simply get the text as it was originally written. if (!nodeIsSynthesized(node) && node.parent) { var text = getSourceTextOfNodeFromSourceFile(sourceFile, node); - if (languageVersion < 2 /* ES6 */ && isBinaryOrOctalIntegerLiteral(node, text)) { + if (languageVersion < 2 /* ES2015 */ && isBinaryOrOctalIntegerLiteral(node, text)) { return node.text; } return text; @@ -6346,13 +6386,13 @@ var ts; switch (node.kind) { case 9 /* StringLiteral */: return getQuotedEscapedLiteralText('"', node.text, '"'); - case 11 /* NoSubstitutionTemplateLiteral */: + case 12 /* NoSubstitutionTemplateLiteral */: return getQuotedEscapedLiteralText("`", node.text, "`"); - case 12 /* TemplateHead */: + case 13 /* TemplateHead */: return getQuotedEscapedLiteralText("`", node.text, "${"); - case 13 /* TemplateMiddle */: + case 14 /* TemplateMiddle */: return getQuotedEscapedLiteralText("}", node.text, "${"); - case 14 /* TemplateTail */: + case 15 /* TemplateTail */: return getQuotedEscapedLiteralText("}", node.text, "`"); case 8 /* NumericLiteral */: return node.text; @@ -6398,7 +6438,7 @@ var ts; } ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isAmbientModule(node) { - return node && node.kind === 225 /* ModuleDeclaration */ && + return node && node.kind === 226 /* ModuleDeclaration */ && (node.name.kind === 9 /* StringLiteral */ || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; @@ -6408,11 +6448,11 @@ var ts; ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { // The only kind of module that can be missing a body is a shorthand ambient module. - return node.kind === 225 /* ModuleDeclaration */ && (!node.body); + return node.kind === 226 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { return node.kind === 256 /* SourceFile */ || - node.kind === 225 /* ModuleDeclaration */ || + node.kind === 226 /* ModuleDeclaration */ || isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -6430,7 +6470,7 @@ var ts; switch (node.parent.kind) { case 256 /* SourceFile */: return ts.isExternalModule(node.parent); - case 226 /* ModuleBlock */: + case 227 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -6439,21 +6479,21 @@ var ts; function isBlockScope(node, parentNode) { switch (node.kind) { case 256 /* SourceFile */: - case 227 /* CaseBlock */: + case 228 /* CaseBlock */: case 252 /* CatchClause */: - case 225 /* ModuleDeclaration */: - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: - case 148 /* Constructor */: - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 226 /* ModuleDeclaration */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: + case 149 /* Constructor */: + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: return true; - case 199 /* Block */: + case 200 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return parentNode && !isFunctionLike(parentNode); @@ -6475,7 +6515,7 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 218 /* VariableDeclaration */ && + declaration.kind === 219 /* VariableDeclaration */ && declaration.parent && declaration.parent.kind === 252 /* CatchClause */; } @@ -6515,7 +6555,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 199 /* Block */) { + if (node.body && node.body.kind === 200 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -6538,23 +6578,23 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 218 /* VariableDeclaration */: - case 169 /* BindingElement */: - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - case 222 /* InterfaceDeclaration */: - case 225 /* ModuleDeclaration */: - case 224 /* EnumDeclaration */: + case 219 /* VariableDeclaration */: + case 170 /* BindingElement */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 223 /* InterfaceDeclaration */: + case 226 /* ModuleDeclaration */: + case 225 /* EnumDeclaration */: case 255 /* EnumMember */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 223 /* TypeAliasDeclaration */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 224 /* TypeAliasDeclaration */: errorNode = node.name; break; - case 180 /* ArrowFunction */: + case 181 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -6577,7 +6617,7 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 224 /* EnumDeclaration */ && isConst(node); + return node.kind === 225 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -6590,11 +6630,11 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 174 /* CallExpression */ && n.expression.kind === 95 /* SuperKeyword */; + return n.kind === 175 /* CallExpression */ && n.expression.kind === 96 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isPrologueDirective(node) { - return node.kind === 202 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; + return node.kind === 203 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { @@ -6610,10 +6650,10 @@ var ts; } ts.getJsDocComments = getJsDocComments; function getJsDocCommentsFromText(node, text) { - var commentRanges = (node.kind === 142 /* Parameter */ || - node.kind === 141 /* TypeParameter */ || - node.kind === 179 /* FunctionExpression */ || - node.kind === 180 /* ArrowFunction */) ? + var commentRanges = (node.kind === 143 /* Parameter */ || + node.kind === 142 /* TypeParameter */ || + node.kind === 180 /* FunctionExpression */ || + node.kind === 181 /* ArrowFunction */) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : getLeadingCommentRangesOfNodeFromText(node, text); return ts.filter(commentRanges, isJsDocComment); @@ -6629,39 +6669,39 @@ var ts; ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (154 /* FirstTypeNode */ <= node.kind && node.kind <= 166 /* LastTypeNode */) { + if (155 /* FirstTypeNode */ <= node.kind && node.kind <= 167 /* LastTypeNode */) { return true; } switch (node.kind) { - case 117 /* AnyKeyword */: - case 130 /* NumberKeyword */: - case 132 /* StringKeyword */: - case 120 /* BooleanKeyword */: - case 133 /* SymbolKeyword */: - case 135 /* UndefinedKeyword */: - case 127 /* NeverKeyword */: + case 118 /* AnyKeyword */: + case 131 /* NumberKeyword */: + case 133 /* StringKeyword */: + case 121 /* BooleanKeyword */: + case 134 /* SymbolKeyword */: + case 136 /* UndefinedKeyword */: + case 128 /* NeverKeyword */: return true; - case 103 /* VoidKeyword */: - return node.parent.kind !== 183 /* VoidExpression */; - case 194 /* ExpressionWithTypeArguments */: + case 104 /* VoidKeyword */: + return node.parent.kind !== 184 /* VoidExpression */; + case 195 /* 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 69 /* Identifier */: + case 70 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 139 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 140 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 172 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 173 /* PropertyAccessExpression */ && node.parent.name === node) { node = node.parent; } // At this point, node is either a qualified name or an identifier - ts.Debug.assert(node.kind === 69 /* Identifier */ || node.kind === 139 /* QualifiedName */ || node.kind === 172 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); - case 139 /* QualifiedName */: - case 172 /* PropertyAccessExpression */: - case 97 /* ThisKeyword */: + ts.Debug.assert(node.kind === 70 /* Identifier */ || node.kind === 140 /* QualifiedName */ || node.kind === 173 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + case 140 /* QualifiedName */: + case 173 /* PropertyAccessExpression */: + case 98 /* ThisKeyword */: var parent_1 = node.parent; - if (parent_1.kind === 158 /* TypeQuery */) { + if (parent_1.kind === 159 /* TypeQuery */) { return false; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -6670,38 +6710,38 @@ var ts; // // Calling isPartOfTypeNode would consider the qualified name A.B a type node. Only C or // A.B.C is a type node. - if (154 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 166 /* LastTypeNode */) { + if (155 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 167 /* LastTypeNode */) { return true; } switch (parent_1.kind) { - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 141 /* TypeParameter */: + case 142 /* TypeParameter */: return node === parent_1.constraint; - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: - case 142 /* Parameter */: - case 218 /* VariableDeclaration */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: + case 143 /* Parameter */: + case 219 /* VariableDeclaration */: return node === parent_1.type; - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: - case 148 /* Constructor */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 149 /* Constructor */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: return node === parent_1.type; - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: return node === parent_1.type; - case 177 /* TypeAssertionExpression */: + case 178 /* TypeAssertionExpression */: return node === parent_1.type; - case 174 /* CallExpression */: - case 175 /* NewExpression */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; - case 176 /* TaggedTemplateExpression */: + case 177 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -6715,22 +6755,22 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 211 /* ReturnStatement */: + case 212 /* ReturnStatement */: return visitor(node); - case 227 /* CaseBlock */: - case 199 /* Block */: - case 203 /* IfStatement */: - case 204 /* DoStatement */: - case 205 /* WhileStatement */: - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: - case 212 /* WithStatement */: - case 213 /* SwitchStatement */: + case 228 /* CaseBlock */: + case 200 /* Block */: + case 204 /* IfStatement */: + case 205 /* DoStatement */: + case 206 /* WhileStatement */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: + case 213 /* WithStatement */: + case 214 /* SwitchStatement */: case 249 /* CaseClause */: case 250 /* DefaultClause */: - case 214 /* LabeledStatement */: - case 216 /* TryStatement */: + case 215 /* LabeledStatement */: + case 217 /* TryStatement */: case 252 /* CatchClause */: return ts.forEachChild(node, traverse); } @@ -6741,18 +6781,18 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 190 /* YieldExpression */: + case 191 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 224 /* EnumDeclaration */: - case 222 /* InterfaceDeclaration */: - case 225 /* ModuleDeclaration */: - case 223 /* TypeAliasDeclaration */: - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: + case 225 /* EnumDeclaration */: + case 223 /* InterfaceDeclaration */: + case 226 /* ModuleDeclaration */: + case 224 /* TypeAliasDeclaration */: + case 222 /* ClassDeclaration */: + case 193 /* 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. @@ -6760,7 +6800,7 @@ var ts; default: if (isFunctionLike(node)) { var name_5 = node.name; - if (name_5 && name_5.kind === 140 /* ComputedPropertyName */) { + if (name_5 && name_5.kind === 141 /* 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); @@ -6779,14 +6819,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 169 /* BindingElement */: + case 170 /* BindingElement */: case 255 /* EnumMember */: - case 142 /* Parameter */: + case 143 /* Parameter */: case 253 /* PropertyAssignment */: - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: case 254 /* ShorthandPropertyAssignment */: - case 218 /* VariableDeclaration */: + case 219 /* VariableDeclaration */: return true; } } @@ -6794,11 +6834,11 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 149 /* GetAccessor */ || node.kind === 150 /* SetAccessor */); + return node && (node.kind === 150 /* GetAccessor */ || node.kind === 151 /* SetAccessor */); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 221 /* ClassDeclaration */ || node.kind === 192 /* ClassExpression */); + return node && (node.kind === 222 /* ClassDeclaration */ || node.kind === 193 /* ClassExpression */); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -6807,19 +6847,19 @@ var ts; ts.isFunctionLike = isFunctionLike; function isFunctionLikeKind(kind) { switch (kind) { - case 148 /* Constructor */: - case 179 /* FunctionExpression */: - case 220 /* FunctionDeclaration */: - case 180 /* ArrowFunction */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: - case 156 /* FunctionType */: - case 157 /* ConstructorType */: + case 149 /* Constructor */: + case 180 /* FunctionExpression */: + case 221 /* FunctionDeclaration */: + case 181 /* ArrowFunction */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: return true; } return false; @@ -6827,13 +6867,13 @@ var ts; ts.isFunctionLikeKind = isFunctionLikeKind; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: return true; } return false; @@ -6841,30 +6881,30 @@ var ts; ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: - case 204 /* DoStatement */: - case 205 /* WhileStatement */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: + case 205 /* DoStatement */: + case 206 /* WhileStatement */: return true; - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; function isFunctionBlock(node) { - return node && node.kind === 199 /* Block */ && isFunctionLike(node.parent); + return node && node.kind === 200 /* Block */ && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 147 /* MethodDeclaration */ && node.parent.kind === 171 /* ObjectLiteralExpression */; + return node && node.kind === 148 /* MethodDeclaration */ && node.parent.kind === 172 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 147 /* MethodDeclaration */ && - (node.parent.kind === 171 /* ObjectLiteralExpression */ || - node.parent.kind === 192 /* ClassExpression */); + return node.kind === 148 /* MethodDeclaration */ && + (node.parent.kind === 172 /* ObjectLiteralExpression */ || + node.parent.kind === 193 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -6900,7 +6940,7 @@ var ts; return undefined; } switch (node.kind) { - case 140 /* ComputedPropertyName */: + case 141 /* 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 @@ -6915,9 +6955,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 143 /* Decorator */: + case 144 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 142 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 143 /* 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; @@ -6928,25 +6968,25 @@ var ts; node = node.parent; } break; - case 180 /* ArrowFunction */: + case 181 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // Fall through - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 225 /* ModuleDeclaration */: - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: - case 224 /* EnumDeclaration */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 226 /* ModuleDeclaration */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: + case 225 /* EnumDeclaration */: case 256 /* SourceFile */: return node; } @@ -6968,26 +7008,26 @@ var ts; return node; } switch (node.kind) { - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: node = node.parent; break; - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: if (!stopOnFunctions) { continue; } - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: return node; - case 143 /* Decorator */: + case 144 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 142 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 143 /* 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; @@ -7003,14 +7043,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 179 /* FunctionExpression */ || func.kind === 180 /* ArrowFunction */) { + if (func.kind === 180 /* FunctionExpression */ || func.kind === 181 /* ArrowFunction */) { var prev = func; var parent_2 = func.parent; - while (parent_2.kind === 178 /* ParenthesizedExpression */) { + while (parent_2.kind === 179 /* ParenthesizedExpression */) { prev = parent_2; parent_2 = parent_2.parent; } - if (parent_2.kind === 174 /* CallExpression */ && parent_2.expression === prev) { + if (parent_2.kind === 175 /* CallExpression */ && parent_2.expression === prev) { return parent_2; } } @@ -7021,20 +7061,20 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 172 /* PropertyAccessExpression */ || kind === 173 /* ElementAccessExpression */) - && node.expression.kind === 95 /* SuperKeyword */; + return (kind === 173 /* PropertyAccessExpression */ || kind === 174 /* ElementAccessExpression */) + && node.expression.kind === 96 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; function getEntityNameFromTypeNode(node) { if (node) { switch (node.kind) { - case 155 /* TypeReference */: + case 156 /* TypeReference */: return node.typeName; - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: ts.Debug.assert(isEntityNameExpression(node.expression)); return node.expression; - case 69 /* Identifier */: - case 139 /* QualifiedName */: + case 70 /* Identifier */: + case 140 /* QualifiedName */: return node; } } @@ -7043,10 +7083,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function isCallLikeExpression(node) { switch (node.kind) { - case 174 /* CallExpression */: - case 175 /* NewExpression */: - case 176 /* TaggedTemplateExpression */: - case 143 /* Decorator */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: + case 177 /* TaggedTemplateExpression */: + case 144 /* Decorator */: return true; default: return false; @@ -7054,7 +7094,7 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function getInvokedExpression(node) { - if (node.kind === 176 /* TaggedTemplateExpression */) { + if (node.kind === 177 /* TaggedTemplateExpression */) { return node.tag; } // Will either be a CallExpression, NewExpression, or Decorator. @@ -7063,25 +7103,25 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: // classes are valid targets return true; - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return node.parent.kind === 221 /* ClassDeclaration */; - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 147 /* MethodDeclaration */: + return node.parent.kind === 222 /* ClassDeclaration */; + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 148 /* MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. return node.body !== undefined - && node.parent.kind === 221 /* ClassDeclaration */; - case 142 /* Parameter */: + && node.parent.kind === 222 /* ClassDeclaration */; + case 143 /* 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 !== undefined - && (node.parent.kind === 148 /* Constructor */ - || node.parent.kind === 147 /* MethodDeclaration */ - || node.parent.kind === 150 /* SetAccessor */) - && node.parent.parent.kind === 221 /* ClassDeclaration */; + && (node.parent.kind === 149 /* Constructor */ + || node.parent.kind === 148 /* MethodDeclaration */ + || node.parent.kind === 151 /* SetAccessor */) + && node.parent.parent.kind === 222 /* ClassDeclaration */; } return false; } @@ -7097,18 +7137,18 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 147 /* MethodDeclaration */: - case 150 /* SetAccessor */: + case 148 /* MethodDeclaration */: + case 151 /* SetAccessor */: return ts.forEach(node.parameters, nodeIsDecorated); } } ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 243 /* JsxOpeningElement */ || - parent.kind === 242 /* JsxSelfClosingElement */ || + if (parent.kind === 244 /* JsxOpeningElement */ || + parent.kind === 243 /* JsxSelfClosingElement */ || parent.kind === 245 /* JsxClosingElement */) { return parent.tagName === node; } @@ -7117,98 +7157,98 @@ var ts; ts.isJSXTagName = isJSXTagName; function isPartOfExpression(node) { switch (node.kind) { - case 97 /* ThisKeyword */: - case 95 /* SuperKeyword */: - case 93 /* NullKeyword */: - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: - case 10 /* RegularExpressionLiteral */: - case 170 /* ArrayLiteralExpression */: - case 171 /* ObjectLiteralExpression */: - case 172 /* PropertyAccessExpression */: - case 173 /* ElementAccessExpression */: - case 174 /* CallExpression */: - case 175 /* NewExpression */: - case 176 /* TaggedTemplateExpression */: - case 195 /* AsExpression */: - case 177 /* TypeAssertionExpression */: - case 196 /* NonNullExpression */: - case 178 /* ParenthesizedExpression */: - case 179 /* FunctionExpression */: - case 192 /* ClassExpression */: - case 180 /* ArrowFunction */: - case 183 /* VoidExpression */: - case 181 /* DeleteExpression */: - case 182 /* TypeOfExpression */: - case 185 /* PrefixUnaryExpression */: - case 186 /* PostfixUnaryExpression */: - case 187 /* BinaryExpression */: - case 188 /* ConditionalExpression */: - case 191 /* SpreadElementExpression */: - case 189 /* TemplateExpression */: - case 11 /* NoSubstitutionTemplateLiteral */: - case 193 /* OmittedExpression */: - case 241 /* JsxElement */: - case 242 /* JsxSelfClosingElement */: - case 190 /* YieldExpression */: - case 184 /* AwaitExpression */: + case 98 /* ThisKeyword */: + case 96 /* SuperKeyword */: + case 94 /* NullKeyword */: + case 100 /* TrueKeyword */: + case 85 /* FalseKeyword */: + case 11 /* RegularExpressionLiteral */: + case 171 /* ArrayLiteralExpression */: + case 172 /* ObjectLiteralExpression */: + case 173 /* PropertyAccessExpression */: + case 174 /* ElementAccessExpression */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: + case 177 /* TaggedTemplateExpression */: + case 196 /* AsExpression */: + case 178 /* TypeAssertionExpression */: + case 197 /* NonNullExpression */: + case 179 /* ParenthesizedExpression */: + case 180 /* FunctionExpression */: + case 193 /* ClassExpression */: + case 181 /* ArrowFunction */: + case 184 /* VoidExpression */: + case 182 /* DeleteExpression */: + case 183 /* TypeOfExpression */: + case 186 /* PrefixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: + case 188 /* BinaryExpression */: + case 189 /* ConditionalExpression */: + case 192 /* SpreadElementExpression */: + case 190 /* TemplateExpression */: + case 12 /* NoSubstitutionTemplateLiteral */: + case 194 /* OmittedExpression */: + case 242 /* JsxElement */: + case 243 /* JsxSelfClosingElement */: + case 191 /* YieldExpression */: + case 185 /* AwaitExpression */: return true; - case 139 /* QualifiedName */: - while (node.parent.kind === 139 /* QualifiedName */) { + case 140 /* QualifiedName */: + while (node.parent.kind === 140 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 158 /* TypeQuery */ || isJSXTagName(node); - case 69 /* Identifier */: - if (node.parent.kind === 158 /* TypeQuery */ || isJSXTagName(node)) { + return node.parent.kind === 159 /* TypeQuery */ || isJSXTagName(node); + case 70 /* Identifier */: + if (node.parent.kind === 159 /* TypeQuery */ || isJSXTagName(node)) { return true; } // fall through case 8 /* NumericLiteral */: case 9 /* StringLiteral */: - case 97 /* ThisKeyword */: + case 98 /* ThisKeyword */: var parent_3 = node.parent; switch (parent_3.kind) { - case 218 /* VariableDeclaration */: - case 142 /* Parameter */: - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 219 /* VariableDeclaration */: + case 143 /* Parameter */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: case 255 /* EnumMember */: case 253 /* PropertyAssignment */: - case 169 /* BindingElement */: + case 170 /* BindingElement */: return parent_3.initializer === node; - case 202 /* ExpressionStatement */: - case 203 /* IfStatement */: - case 204 /* DoStatement */: - case 205 /* WhileStatement */: - case 211 /* ReturnStatement */: - case 212 /* WithStatement */: - case 213 /* SwitchStatement */: + case 203 /* ExpressionStatement */: + case 204 /* IfStatement */: + case 205 /* DoStatement */: + case 206 /* WhileStatement */: + case 212 /* ReturnStatement */: + case 213 /* WithStatement */: + case 214 /* SwitchStatement */: case 249 /* CaseClause */: - case 215 /* ThrowStatement */: - case 213 /* SwitchStatement */: + case 216 /* ThrowStatement */: + case 214 /* SwitchStatement */: return parent_3.expression === node; - case 206 /* ForStatement */: + case 207 /* ForStatement */: var forStatement = parent_3; - return (forStatement.initializer === node && forStatement.initializer.kind !== 219 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 220 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: var forInStatement = parent_3; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 219 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 220 /* VariableDeclarationList */) || forInStatement.expression === node; - case 177 /* TypeAssertionExpression */: - case 195 /* AsExpression */: + case 178 /* TypeAssertionExpression */: + case 196 /* AsExpression */: return node === parent_3.expression; - case 197 /* TemplateSpan */: + case 198 /* TemplateSpan */: return node === parent_3.expression; - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: return node === parent_3.expression; - case 143 /* Decorator */: + case 144 /* Decorator */: case 248 /* JsxExpression */: case 247 /* JsxSpreadAttribute */: return true; - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: return parent_3.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_3); default: if (isPartOfExpression(parent_3)) { @@ -7226,7 +7266,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 229 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 240 /* ExternalModuleReference */; + return node.kind === 230 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 241 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -7235,7 +7275,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 229 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 240 /* ExternalModuleReference */; + return node.kind === 230 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 241 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -7253,8 +7293,8 @@ var ts; */ function isRequireCall(expression, checkArgumentIsStringLiteral) { // of the form 'require("name")' - var isRequire = expression.kind === 174 /* CallExpression */ && - expression.expression.kind === 69 /* Identifier */ && + var isRequire = expression.kind === 175 /* CallExpression */ && + expression.expression.kind === 70 /* Identifier */ && expression.expression.text === "require" && expression.arguments.length === 1; return isRequire && (!checkArgumentIsStringLiteral || expression.arguments[0].kind === 9 /* StringLiteral */); @@ -7269,9 +7309,9 @@ var ts; * This function does not test if the node is in a JavaScript file or not. */ function isDeclarationOfFunctionExpression(s) { - if (s.valueDeclaration && s.valueDeclaration.kind === 218 /* VariableDeclaration */) { + if (s.valueDeclaration && s.valueDeclaration.kind === 219 /* VariableDeclaration */) { var declaration = s.valueDeclaration; - return declaration.initializer && declaration.initializer.kind === 179 /* FunctionExpression */; + return declaration.initializer && declaration.initializer.kind === 180 /* FunctionExpression */; } return false; } @@ -7282,15 +7322,15 @@ var ts; if (!isInJavaScriptFile(expression)) { return 0 /* None */; } - if (expression.kind !== 187 /* BinaryExpression */) { + if (expression.kind !== 188 /* BinaryExpression */) { return 0 /* None */; } var expr = expression; - if (expr.operatorToken.kind !== 56 /* EqualsToken */ || expr.left.kind !== 172 /* PropertyAccessExpression */) { + if (expr.operatorToken.kind !== 57 /* EqualsToken */ || expr.left.kind !== 173 /* PropertyAccessExpression */) { return 0 /* None */; } var lhs = expr.left; - if (lhs.expression.kind === 69 /* Identifier */) { + if (lhs.expression.kind === 70 /* Identifier */) { var lhsId = lhs.expression; if (lhsId.text === "exports") { // exports.name = expr @@ -7301,13 +7341,13 @@ var ts; return 2 /* ModuleExports */; } } - else if (lhs.expression.kind === 97 /* ThisKeyword */) { + else if (lhs.expression.kind === 98 /* ThisKeyword */) { return 4 /* ThisProperty */; } - else if (lhs.expression.kind === 172 /* PropertyAccessExpression */) { + else if (lhs.expression.kind === 173 /* PropertyAccessExpression */) { // chained dot, e.g. x.y.z = expr; this var is the 'x.y' part var innerPropertyAccess = lhs.expression; - if (innerPropertyAccess.expression.kind === 69 /* Identifier */) { + if (innerPropertyAccess.expression.kind === 70 /* Identifier */) { // module.exports.name = expr var innerPropertyAccessIdentifier = innerPropertyAccess.expression; if (innerPropertyAccessIdentifier.text === "module" && innerPropertyAccess.name.text === "exports") { @@ -7322,35 +7362,35 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 230 /* ImportDeclaration */) { + if (node.kind === 231 /* ImportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 229 /* ImportEqualsDeclaration */) { + if (node.kind === 230 /* ImportEqualsDeclaration */) { var reference = node.moduleReference; - if (reference.kind === 240 /* ExternalModuleReference */) { + if (reference.kind === 241 /* ExternalModuleReference */) { return reference.expression; } } - if (node.kind === 236 /* ExportDeclaration */) { + if (node.kind === 237 /* ExportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 225 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { + if (node.kind === 226 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { return node.name; } } ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { - if (node.kind === 229 /* ImportEqualsDeclaration */) { + if (node.kind === 230 /* ImportEqualsDeclaration */) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 232 /* NamespaceImport */) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 233 /* NamespaceImport */) { return importClause.namedBindings; } } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 230 /* ImportDeclaration */ + return node.kind === 231 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; } @@ -7358,13 +7398,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 142 /* Parameter */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 143 /* Parameter */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: case 254 /* ShorthandPropertyAssignment */: case 253 /* PropertyAssignment */: - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -7434,25 +7474,25 @@ var ts; // var x = function(name) { return name.length; } var isInitializerOfVariableDeclarationInStatement = isVariableLike(node.parent) && (node.parent).initializer === node && - node.parent.parent.parent.kind === 200 /* VariableStatement */; + node.parent.parent.parent.kind === 201 /* VariableStatement */; var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - node.parent.parent.kind === 200 /* VariableStatement */; + node.parent.parent.kind === 201 /* VariableStatement */; var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? node.parent.parent.parent : isVariableOfVariableDeclarationStatement ? node.parent.parent : undefined; if (variableStatementNode) { result = append(result, getJSDocs(variableStatementNode, checkParentVariableStatement, getDocs, getTags)); } - if (node.kind === 225 /* ModuleDeclaration */ && - node.parent && node.parent.kind === 225 /* ModuleDeclaration */) { + if (node.kind === 226 /* ModuleDeclaration */ && + node.parent && node.parent.kind === 226 /* ModuleDeclaration */) { result = append(result, getJSDocs(node.parent, checkParentVariableStatement, getDocs, getTags)); } // Also recognize when the node is the RHS of an assignment expression var parent_4 = node.parent; var isSourceOfAssignmentExpressionStatement = parent_4 && parent_4.parent && - parent_4.kind === 187 /* BinaryExpression */ && - parent_4.operatorToken.kind === 56 /* EqualsToken */ && - parent_4.parent.kind === 202 /* ExpressionStatement */; + parent_4.kind === 188 /* BinaryExpression */ && + parent_4.operatorToken.kind === 57 /* EqualsToken */ && + parent_4.parent.kind === 203 /* ExpressionStatement */; if (isSourceOfAssignmentExpressionStatement) { result = append(result, getJSDocs(parent_4.parent, checkParentVariableStatement, getDocs, getTags)); } @@ -7461,7 +7501,7 @@ var ts; result = append(result, getJSDocs(parent_4, checkParentVariableStatement, getDocs, getTags)); } // Pull parameter comments from declaring function as well - if (node.kind === 142 /* Parameter */) { + if (node.kind === 143 /* Parameter */) { var paramTags = getJSDocParameterTag(node, checkParentVariableStatement); if (paramTags) { result = append(result, getTags(paramTags)); @@ -7492,7 +7532,7 @@ var ts; return [paramTags[i]]; } } - else if (param.name.kind === 69 /* Identifier */) { + else if (param.name.kind === 70 /* Identifier */) { var name_6 = param.name.text; var paramTags = ts.filter(tags, function (tag) { return tag.kind === 275 /* JSDocParameterTag */ && tag.parameterName.text === name_6; }); if (paramTags) { @@ -7518,7 +7558,7 @@ var ts; } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { - if (parameter.name && parameter.name.kind === 69 /* Identifier */) { + if (parameter.name && parameter.name.kind === 70 /* Identifier */) { // If it's a parameter, see if the parent has a jsdoc comment with an @param // annotation. var parameterName = parameter.name.text; @@ -7568,12 +7608,12 @@ var ts; // assignment in an object literal that is an assignment target, or if it is parented by an array literal that is // an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ p: a}] = xxx'. function isAssignmentTarget(node) { - while (node.parent.kind === 178 /* ParenthesizedExpression */) { + while (node.parent.kind === 179 /* ParenthesizedExpression */) { node = node.parent; } while (true) { var parent_5 = node.parent; - if (parent_5.kind === 170 /* ArrayLiteralExpression */ || parent_5.kind === 191 /* SpreadElementExpression */) { + if (parent_5.kind === 171 /* ArrayLiteralExpression */ || parent_5.kind === 192 /* SpreadElementExpression */) { node = parent_5; continue; } @@ -7581,10 +7621,10 @@ var ts; node = parent_5.parent; continue; } - return parent_5.kind === 187 /* BinaryExpression */ && + return parent_5.kind === 188 /* BinaryExpression */ && isAssignmentOperator(parent_5.operatorToken.kind) && parent_5.left === node || - (parent_5.kind === 207 /* ForInStatement */ || parent_5.kind === 208 /* ForOfStatement */) && + (parent_5.kind === 208 /* ForInStatement */ || parent_5.kind === 209 /* ForOfStatement */) && parent_5.initializer === node; } } @@ -7610,11 +7650,11 @@ var ts; ts.isInAmbientContext = isInAmbientContext; // True if the given identifier, string literal, or number literal is the name of a declaration node function isDeclarationName(name) { - if (name.kind !== 69 /* Identifier */ && name.kind !== 9 /* StringLiteral */ && name.kind !== 8 /* NumericLiteral */) { + if (name.kind !== 70 /* Identifier */ && name.kind !== 9 /* StringLiteral */ && name.kind !== 8 /* NumericLiteral */) { return false; } var parent = name.parent; - if (parent.kind === 234 /* ImportSpecifier */ || parent.kind === 238 /* ExportSpecifier */) { + if (parent.kind === 235 /* ImportSpecifier */ || parent.kind === 239 /* ExportSpecifier */) { if (parent.propertyName) { return true; } @@ -7627,7 +7667,7 @@ var ts; ts.isDeclarationName = isDeclarationName; function isLiteralComputedPropertyDeclarationName(node) { return (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && - node.parent.kind === 140 /* ComputedPropertyName */ && + node.parent.kind === 141 /* ComputedPropertyName */ && isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -7635,31 +7675,31 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: case 255 /* EnumMember */: case 253 /* PropertyAssignment */: - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 139 /* QualifiedName */: + case 140 /* QualifiedName */: // Name on right hand side of dot in a type query if (parent.right === node) { - while (parent.kind === 139 /* QualifiedName */) { + while (parent.kind === 140 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 158 /* TypeQuery */; + return parent.kind === 159 /* TypeQuery */; } return false; - case 169 /* BindingElement */: - case 234 /* ImportSpecifier */: + case 170 /* BindingElement */: + case 235 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 238 /* ExportSpecifier */: + case 239 /* ExportSpecifier */: // Any name in an export specifier return true; } @@ -7675,13 +7715,13 @@ var ts; // export = // export default function isAliasSymbolDeclaration(node) { - return node.kind === 229 /* ImportEqualsDeclaration */ || - node.kind === 228 /* NamespaceExportDeclaration */ || - node.kind === 231 /* ImportClause */ && !!node.name || - node.kind === 232 /* NamespaceImport */ || - node.kind === 234 /* ImportSpecifier */ || - node.kind === 238 /* ExportSpecifier */ || - node.kind === 235 /* ExportAssignment */ && exportAssignmentIsAlias(node); + return node.kind === 230 /* ImportEqualsDeclaration */ || + node.kind === 229 /* NamespaceExportDeclaration */ || + node.kind === 232 /* ImportClause */ && !!node.name || + node.kind === 233 /* NamespaceImport */ || + node.kind === 235 /* ImportSpecifier */ || + node.kind === 239 /* ExportSpecifier */ || + node.kind === 236 /* ExportAssignment */ && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function exportAssignmentIsAlias(node) { @@ -7689,17 +7729,17 @@ var ts; } ts.exportAssignmentIsAlias = exportAssignmentIsAlias; function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 83 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 84 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 106 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 107 /* ImplementsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 83 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 84 /* ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -7767,7 +7807,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 70 /* FirstKeyword */ <= token && token <= 138 /* LastKeyword */; + return 71 /* FirstKeyword */ <= token && token <= 139 /* LastKeyword */; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -7794,7 +7834,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 140 /* ComputedPropertyName */ && + return name.kind === 141 /* ComputedPropertyName */ && !isStringOrNumericLiteral(name.expression.kind) && !isWellKnownSymbolSyntactically(name.expression); } @@ -7809,10 +7849,10 @@ var ts; } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 69 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */ || name.kind === 142 /* Parameter */) { + if (name.kind === 70 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */ || name.kind === 143 /* Parameter */) { return name.text; } - if (name.kind === 140 /* ComputedPropertyName */) { + if (name.kind === 141 /* ComputedPropertyName */) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -7833,22 +7873,26 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 69 /* Identifier */ && node.text === "Symbol"; + return node.kind === 70 /* Identifier */ && node.text === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; + function isPushOrUnshiftIdentifier(node) { + return node.text === "push" || node.text === "unshift"; + } + ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isModifierKind(token) { switch (token) { - 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 128 /* ReadonlyKeyword */: - case 113 /* StaticKeyword */: + case 116 /* AbstractKeyword */: + case 119 /* AsyncKeyword */: + case 75 /* ConstKeyword */: + case 123 /* DeclareKeyword */: + case 78 /* DefaultKeyword */: + case 83 /* ExportKeyword */: + case 113 /* PublicKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + case 129 /* ReadonlyKeyword */: + case 114 /* StaticKeyword */: return true; } return false; @@ -7856,11 +7900,11 @@ var ts; ts.isModifierKind = isModifierKind; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 142 /* Parameter */; + return root.kind === 143 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 169 /* BindingElement */) { + while (node.kind === 170 /* BindingElement */) { node = node.parent.parent; } return node; @@ -7868,14 +7912,14 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 148 /* Constructor */ - || kind === 179 /* FunctionExpression */ - || kind === 220 /* FunctionDeclaration */ - || kind === 180 /* ArrowFunction */ - || kind === 147 /* MethodDeclaration */ - || kind === 149 /* GetAccessor */ - || kind === 150 /* SetAccessor */ - || kind === 225 /* ModuleDeclaration */ + return kind === 149 /* Constructor */ + || kind === 180 /* FunctionExpression */ + || kind === 221 /* FunctionDeclaration */ + || kind === 181 /* ArrowFunction */ + || kind === 148 /* MethodDeclaration */ + || kind === 150 /* GetAccessor */ + || kind === 151 /* SetAccessor */ + || kind === 226 /* ModuleDeclaration */ || kind === 256 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; @@ -7937,38 +7981,38 @@ var ts; var Associativity = ts.Associativity; function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 175 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 176 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 175 /* NewExpression */: + case 176 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 185 /* PrefixUnaryExpression */: - case 182 /* TypeOfExpression */: - case 183 /* VoidExpression */: - case 181 /* DeleteExpression */: - case 184 /* AwaitExpression */: - case 188 /* ConditionalExpression */: - case 190 /* YieldExpression */: + case 186 /* PrefixUnaryExpression */: + case 183 /* TypeOfExpression */: + case 184 /* VoidExpression */: + case 182 /* DeleteExpression */: + case 185 /* AwaitExpression */: + case 189 /* ConditionalExpression */: + case 191 /* YieldExpression */: return 1 /* Right */; - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: switch (operator) { - case 38 /* AsteriskAsteriskToken */: - case 56 /* EqualsToken */: - case 57 /* PlusEqualsToken */: - case 58 /* MinusEqualsToken */: - case 60 /* AsteriskAsteriskEqualsToken */: - case 59 /* AsteriskEqualsToken */: - case 61 /* SlashEqualsToken */: - case 62 /* PercentEqualsToken */: - case 63 /* LessThanLessThanEqualsToken */: - case 64 /* GreaterThanGreaterThanEqualsToken */: - case 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 66 /* AmpersandEqualsToken */: - case 68 /* CaretEqualsToken */: - case 67 /* BarEqualsToken */: + case 39 /* AsteriskAsteriskToken */: + case 57 /* EqualsToken */: + case 58 /* PlusEqualsToken */: + case 59 /* MinusEqualsToken */: + case 61 /* AsteriskAsteriskEqualsToken */: + case 60 /* AsteriskEqualsToken */: + case 62 /* SlashEqualsToken */: + case 63 /* PercentEqualsToken */: + case 64 /* LessThanLessThanEqualsToken */: + case 65 /* GreaterThanGreaterThanEqualsToken */: + case 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 67 /* AmpersandEqualsToken */: + case 69 /* CaretEqualsToken */: + case 68 /* BarEqualsToken */: return 1 /* Right */; } } @@ -7977,15 +8021,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 175 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 176 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 187 /* BinaryExpression */) { + if (expression.kind === 188 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 185 /* PrefixUnaryExpression */ || expression.kind === 186 /* PostfixUnaryExpression */) { + else if (expression.kind === 186 /* PrefixUnaryExpression */ || expression.kind === 187 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -7995,106 +8039,106 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 97 /* ThisKeyword */: - case 95 /* SuperKeyword */: - case 69 /* Identifier */: - case 93 /* NullKeyword */: - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: + case 98 /* ThisKeyword */: + case 96 /* SuperKeyword */: + case 70 /* Identifier */: + case 94 /* NullKeyword */: + case 100 /* TrueKeyword */: + case 85 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: - case 170 /* ArrayLiteralExpression */: - case 171 /* ObjectLiteralExpression */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: - case 192 /* ClassExpression */: - case 241 /* JsxElement */: - case 242 /* JsxSelfClosingElement */: - case 10 /* RegularExpressionLiteral */: - case 11 /* NoSubstitutionTemplateLiteral */: - case 189 /* TemplateExpression */: - case 178 /* ParenthesizedExpression */: - case 193 /* OmittedExpression */: + case 171 /* ArrayLiteralExpression */: + case 172 /* ObjectLiteralExpression */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 193 /* ClassExpression */: + case 242 /* JsxElement */: + case 243 /* JsxSelfClosingElement */: + case 11 /* RegularExpressionLiteral */: + case 12 /* NoSubstitutionTemplateLiteral */: + case 190 /* TemplateExpression */: + case 179 /* ParenthesizedExpression */: + case 194 /* OmittedExpression */: return 19; - case 176 /* TaggedTemplateExpression */: - case 172 /* PropertyAccessExpression */: - case 173 /* ElementAccessExpression */: + case 177 /* TaggedTemplateExpression */: + case 173 /* PropertyAccessExpression */: + case 174 /* ElementAccessExpression */: return 18; - case 175 /* NewExpression */: + case 176 /* NewExpression */: return hasArguments ? 18 : 17; - case 174 /* CallExpression */: + case 175 /* CallExpression */: return 17; - case 186 /* PostfixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: return 16; - case 185 /* PrefixUnaryExpression */: - case 182 /* TypeOfExpression */: - case 183 /* VoidExpression */: - case 181 /* DeleteExpression */: - case 184 /* AwaitExpression */: + case 186 /* PrefixUnaryExpression */: + case 183 /* TypeOfExpression */: + case 184 /* VoidExpression */: + case 182 /* DeleteExpression */: + case 185 /* AwaitExpression */: return 15; - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: switch (operatorKind) { - case 49 /* ExclamationToken */: - case 50 /* TildeToken */: + case 50 /* ExclamationToken */: + case 51 /* TildeToken */: return 15; - case 38 /* AsteriskAsteriskToken */: - case 37 /* AsteriskToken */: - case 39 /* SlashToken */: - case 40 /* PercentToken */: + case 39 /* AsteriskAsteriskToken */: + case 38 /* AsteriskToken */: + case 40 /* SlashToken */: + case 41 /* PercentToken */: return 14; - case 35 /* PlusToken */: - case 36 /* MinusToken */: + case 36 /* PlusToken */: + case 37 /* MinusToken */: return 13; - case 43 /* LessThanLessThanToken */: - case 44 /* GreaterThanGreaterThanToken */: - case 45 /* GreaterThanGreaterThanGreaterThanToken */: + case 44 /* LessThanLessThanToken */: + case 45 /* GreaterThanGreaterThanToken */: + case 46 /* GreaterThanGreaterThanGreaterThanToken */: return 12; - case 25 /* LessThanToken */: - case 28 /* LessThanEqualsToken */: - case 27 /* GreaterThanToken */: - case 29 /* GreaterThanEqualsToken */: - case 90 /* InKeyword */: - case 91 /* InstanceOfKeyword */: + case 26 /* LessThanToken */: + case 29 /* LessThanEqualsToken */: + case 28 /* GreaterThanToken */: + case 30 /* GreaterThanEqualsToken */: + case 91 /* InKeyword */: + case 92 /* InstanceOfKeyword */: return 11; - case 30 /* EqualsEqualsToken */: - case 32 /* EqualsEqualsEqualsToken */: - case 31 /* ExclamationEqualsToken */: - case 33 /* ExclamationEqualsEqualsToken */: + case 31 /* EqualsEqualsToken */: + case 33 /* EqualsEqualsEqualsToken */: + case 32 /* ExclamationEqualsToken */: + case 34 /* ExclamationEqualsEqualsToken */: return 10; - case 46 /* AmpersandToken */: + case 47 /* AmpersandToken */: return 9; - case 48 /* CaretToken */: + case 49 /* CaretToken */: return 8; - case 47 /* BarToken */: + case 48 /* BarToken */: return 7; - case 51 /* AmpersandAmpersandToken */: + case 52 /* AmpersandAmpersandToken */: return 6; - case 52 /* BarBarToken */: + case 53 /* BarBarToken */: return 5; - case 56 /* EqualsToken */: - case 57 /* PlusEqualsToken */: - case 58 /* MinusEqualsToken */: - case 60 /* AsteriskAsteriskEqualsToken */: - case 59 /* AsteriskEqualsToken */: - case 61 /* SlashEqualsToken */: - case 62 /* PercentEqualsToken */: - case 63 /* LessThanLessThanEqualsToken */: - case 64 /* GreaterThanGreaterThanEqualsToken */: - case 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 66 /* AmpersandEqualsToken */: - case 68 /* CaretEqualsToken */: - case 67 /* BarEqualsToken */: + case 57 /* EqualsToken */: + case 58 /* PlusEqualsToken */: + case 59 /* MinusEqualsToken */: + case 61 /* AsteriskAsteriskEqualsToken */: + case 60 /* AsteriskEqualsToken */: + case 62 /* SlashEqualsToken */: + case 63 /* PercentEqualsToken */: + case 64 /* LessThanLessThanEqualsToken */: + case 65 /* GreaterThanGreaterThanEqualsToken */: + case 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 67 /* AmpersandEqualsToken */: + case 69 /* CaretEqualsToken */: + case 68 /* BarEqualsToken */: return 3; - case 24 /* CommaToken */: + case 25 /* CommaToken */: return 0; default: return -1; } - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: return 4; - case 190 /* YieldExpression */: + case 191 /* YieldExpression */: return 2; - case 191 /* SpreadElementExpression */: + case 192 /* SpreadElementExpression */: return 1; default: return -1; @@ -8395,7 +8439,7 @@ var ts; var options = host.getCompilerOptions(); // Emit on each source file if (options.outFile || options.out) { - onBundledEmit(host, sourceFiles); + onBundledEmit(sourceFiles); } else { for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { @@ -8427,7 +8471,7 @@ var ts; var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (options.declaration || emitOnlyDtsFiles) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; action(jsFilePath, sourceMapFilePath, declarationFilePath, [sourceFile], /*isBundledEmit*/ false); } - function onBundledEmit(host, sourceFiles) { + function onBundledEmit(sourceFiles) { if (sourceFiles.length) { var jsFilePath = options.outFile || options.out; var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); @@ -8533,7 +8577,7 @@ var ts; ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 148 /* Constructor */ && nodeIsPresent(member.body)) { + if (member.kind === 149 /* Constructor */ && nodeIsPresent(member.body)) { return member; } }); @@ -8561,11 +8605,11 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return node && node.kind === 69 /* Identifier */ && identifierIsThisKeyword(node); + return node && node.kind === 70 /* Identifier */ && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 97 /* ThisKeyword */; + return id.originalKeywordKind === 98 /* ThisKeyword */; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -8575,10 +8619,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 149 /* GetAccessor */) { + if (accessor.kind === 150 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 150 /* SetAccessor */) { + else if (accessor.kind === 151 /* SetAccessor */) { setAccessor = accessor; } else { @@ -8587,7 +8631,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 149 /* GetAccessor */ || member.kind === 150 /* SetAccessor */) + if ((member.kind === 150 /* GetAccessor */ || member.kind === 151 /* SetAccessor */) && hasModifier(member, 32 /* Static */) === hasModifier(accessor, 32 /* Static */)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -8598,10 +8642,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 149 /* GetAccessor */ && !getAccessor) { + if (member.kind === 150 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 150 /* SetAccessor */ && !setAccessor) { + if (member.kind === 151 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -8837,35 +8881,35 @@ var ts; ts.getModifierFlags = getModifierFlags; function modifierToFlag(token) { switch (token) { - case 113 /* StaticKeyword */: return 32 /* Static */; - case 112 /* PublicKeyword */: return 4 /* Public */; - case 111 /* ProtectedKeyword */: return 16 /* Protected */; - case 110 /* PrivateKeyword */: return 8 /* Private */; - case 115 /* AbstractKeyword */: return 128 /* Abstract */; - case 82 /* ExportKeyword */: return 1 /* Export */; - case 122 /* DeclareKeyword */: return 2 /* Ambient */; - case 74 /* ConstKeyword */: return 2048 /* Const */; - case 77 /* DefaultKeyword */: return 512 /* Default */; - case 118 /* AsyncKeyword */: return 256 /* Async */; - case 128 /* ReadonlyKeyword */: return 64 /* Readonly */; + case 114 /* StaticKeyword */: return 32 /* Static */; + case 113 /* PublicKeyword */: return 4 /* Public */; + case 112 /* ProtectedKeyword */: return 16 /* Protected */; + case 111 /* PrivateKeyword */: return 8 /* Private */; + case 116 /* AbstractKeyword */: return 128 /* Abstract */; + case 83 /* ExportKeyword */: return 1 /* Export */; + case 123 /* DeclareKeyword */: return 2 /* Ambient */; + case 75 /* ConstKeyword */: return 2048 /* Const */; + case 78 /* DefaultKeyword */: return 512 /* Default */; + case 119 /* AsyncKeyword */: return 256 /* Async */; + case 129 /* ReadonlyKeyword */: return 64 /* Readonly */; } return 0 /* None */; } ts.modifierToFlag = modifierToFlag; function isLogicalOperator(token) { - return token === 52 /* BarBarToken */ - || token === 51 /* AmpersandAmpersandToken */ - || token === 49 /* ExclamationToken */; + return token === 53 /* BarBarToken */ + || token === 52 /* AmpersandAmpersandToken */ + || token === 50 /* ExclamationToken */; } ts.isLogicalOperator = isLogicalOperator; function isAssignmentOperator(token) { - return token >= 56 /* FirstAssignment */ && token <= 68 /* LastAssignment */; + return token >= 57 /* FirstAssignment */ && token <= 69 /* LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ function tryGetClassExtendingExpressionWithTypeArguments(node) { - if (node.kind === 194 /* ExpressionWithTypeArguments */ && - node.parent.token === 83 /* ExtendsKeyword */ && + if (node.kind === 195 /* ExpressionWithTypeArguments */ && + node.parent.token === 84 /* ExtendsKeyword */ && isClassLike(node.parent.parent)) { return node.parent.parent; } @@ -8873,10 +8917,10 @@ var ts; ts.tryGetClassExtendingExpressionWithTypeArguments = tryGetClassExtendingExpressionWithTypeArguments; function isDestructuringAssignment(node) { if (isBinaryExpression(node)) { - if (node.operatorToken.kind === 56 /* EqualsToken */) { + if (node.operatorToken.kind === 57 /* EqualsToken */) { var kind = node.left.kind; - return kind === 171 /* ObjectLiteralExpression */ - || kind === 170 /* ArrayLiteralExpression */; + return kind === 172 /* ObjectLiteralExpression */ + || kind === 171 /* ArrayLiteralExpression */; } } return false; @@ -8889,7 +8933,7 @@ var ts; } ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 69 /* Identifier */) { + if (node.kind === 70 /* Identifier */) { return true; } else if (isPropertyAccessExpression(node)) { @@ -8904,21 +8948,21 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { - return node.kind === 69 /* Identifier */ || - node.kind === 172 /* PropertyAccessExpression */ && isEntityNameExpression(node.expression); + return node.kind === 70 /* Identifier */ || + node.kind === 173 /* PropertyAccessExpression */ && isEntityNameExpression(node.expression); } ts.isEntityNameExpression = isEntityNameExpression; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 139 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 172 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 140 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 173 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteralOrArrayLiteral(expression) { var kind = expression.kind; - if (kind === 171 /* ObjectLiteralExpression */) { + if (kind === 172 /* ObjectLiteralExpression */) { return expression.properties.length === 0; } - if (kind === 170 /* ArrayLiteralExpression */) { + if (kind === 171 /* ArrayLiteralExpression */) { return expression.elements.length === 0; } return false; @@ -9070,49 +9114,49 @@ var ts; var kind = node.kind; if (kind === 9 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 10 /* RegularExpressionLiteral */ - || kind === 11 /* NoSubstitutionTemplateLiteral */ - || kind === 69 /* Identifier */ - || kind === 97 /* ThisKeyword */ - || kind === 95 /* SuperKeyword */ - || kind === 99 /* TrueKeyword */ - || kind === 84 /* FalseKeyword */ - || kind === 93 /* NullKeyword */) { + || kind === 11 /* RegularExpressionLiteral */ + || kind === 12 /* NoSubstitutionTemplateLiteral */ + || kind === 70 /* Identifier */ + || kind === 98 /* ThisKeyword */ + || kind === 96 /* SuperKeyword */ + || kind === 100 /* TrueKeyword */ + || kind === 85 /* FalseKeyword */ + || kind === 94 /* NullKeyword */) { return true; } - else if (kind === 172 /* PropertyAccessExpression */) { + else if (kind === 173 /* PropertyAccessExpression */) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 173 /* ElementAccessExpression */) { + else if (kind === 174 /* ElementAccessExpression */) { return isSimpleExpressionWorker(node.expression, depth + 1) && isSimpleExpressionWorker(node.argumentExpression, depth + 1); } - else if (kind === 185 /* PrefixUnaryExpression */ - || kind === 186 /* PostfixUnaryExpression */) { + else if (kind === 186 /* PrefixUnaryExpression */ + || kind === 187 /* PostfixUnaryExpression */) { return isSimpleExpressionWorker(node.operand, depth + 1); } - else if (kind === 187 /* BinaryExpression */) { - return node.operatorToken.kind !== 38 /* AsteriskAsteriskToken */ + else if (kind === 188 /* BinaryExpression */) { + return node.operatorToken.kind !== 39 /* AsteriskAsteriskToken */ && isSimpleExpressionWorker(node.left, depth + 1) && isSimpleExpressionWorker(node.right, depth + 1); } - else if (kind === 188 /* ConditionalExpression */) { + else if (kind === 189 /* ConditionalExpression */) { return isSimpleExpressionWorker(node.condition, depth + 1) && isSimpleExpressionWorker(node.whenTrue, depth + 1) && isSimpleExpressionWorker(node.whenFalse, depth + 1); } - else if (kind === 183 /* VoidExpression */ - || kind === 182 /* TypeOfExpression */ - || kind === 181 /* DeleteExpression */) { + else if (kind === 184 /* VoidExpression */ + || kind === 183 /* TypeOfExpression */ + || kind === 182 /* DeleteExpression */) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 170 /* ArrayLiteralExpression */) { + else if (kind === 171 /* ArrayLiteralExpression */) { return node.elements.length === 0; } - else if (kind === 171 /* ObjectLiteralExpression */) { + else if (kind === 172 /* ObjectLiteralExpression */) { return node.properties.length === 0; } - else if (kind === 174 /* CallExpression */) { + else if (kind === 175 /* CallExpression */) { if (!isSimpleExpressionWorker(node.expression, depth + 1)) { return false; } @@ -9271,7 +9315,7 @@ var ts; return ts.positionIsSynthesized(range.pos) ? -1 : ts.skipTrivia(sourceFile.text, range.pos); } ts.getStartPositionOfRange = getStartPositionOfRange; - function collectExternalModuleInfo(sourceFile, resolver) { + function collectExternalModuleInfo(sourceFile) { var externalImports = []; var exportSpecifiers = ts.createMap(); var exportEquals = undefined; @@ -9279,33 +9323,28 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 230 /* ImportDeclaration */: - if (!node.importClause || - resolver.isReferencedAliasDeclaration(node.importClause, /*checkChildren*/ true)) { - // import "mod" - // import x from "mod" where x is referenced - // import * as x from "mod" where x is referenced - // import { x, y } from "mod" where at least one import is referenced + case 231 /* ImportDeclaration */: + // import "mod" + // import x from "mod" + // import * as x from "mod" + // import { x, y } from "mod" + externalImports.push(node); + break; + case 230 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 241 /* ExternalModuleReference */) { + // import x = require("mod") externalImports.push(node); } break; - case 229 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 240 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { - // import x = require("mod") where x is referenced - externalImports.push(node); - } - break; - case 236 /* ExportDeclaration */: + case 237 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" - if (resolver.moduleExportsSomeValue(node.moduleSpecifier)) { - externalImports.push(node); - hasExportStarsToExportValues = true; - } + externalImports.push(node); + hasExportStarsToExportValues = true; } - else if (resolver.isValueAliasDeclaration(node)) { - // export { x, y } from "mod" where at least one export is a value symbol + else { + // export { x, y } from "mod" externalImports.push(node); } } @@ -9318,7 +9357,7 @@ var ts; } } break; - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; @@ -9343,7 +9382,7 @@ var ts; if (node.symbol) { for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 221 /* ClassDeclaration */ && declaration !== node) { + if (declaration.kind === 222 /* ClassDeclaration */ && declaration !== node) { return true; } } @@ -9373,15 +9412,15 @@ var ts; ts.isNodeArray = isNodeArray; // Literals function isNoSubstitutionTemplateLiteral(node) { - return node.kind === 11 /* NoSubstitutionTemplateLiteral */; + return node.kind === 12 /* NoSubstitutionTemplateLiteral */; } ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral; function isLiteralKind(kind) { - return 8 /* FirstLiteralToken */ <= kind && kind <= 11 /* LastLiteralToken */; + return 8 /* FirstLiteralToken */ <= kind && kind <= 12 /* LastLiteralToken */; } ts.isLiteralKind = isLiteralKind; function isTextualLiteralKind(kind) { - return kind === 9 /* StringLiteral */ || kind === 11 /* NoSubstitutionTemplateLiteral */; + return kind === 9 /* StringLiteral */ || kind === 12 /* NoSubstitutionTemplateLiteral */; } ts.isTextualLiteralKind = isTextualLiteralKind; function isLiteralExpression(node) { @@ -9390,22 +9429,22 @@ var ts; ts.isLiteralExpression = isLiteralExpression; // Pseudo-literals function isTemplateLiteralKind(kind) { - return 11 /* FirstTemplateToken */ <= kind && kind <= 14 /* LastTemplateToken */; + return 12 /* FirstTemplateToken */ <= kind && kind <= 15 /* LastTemplateToken */; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isTemplateHead(node) { - return node.kind === 12 /* TemplateHead */; + return node.kind === 13 /* TemplateHead */; } ts.isTemplateHead = isTemplateHead; function isTemplateMiddleOrTemplateTail(node) { var kind = node.kind; - return kind === 13 /* TemplateMiddle */ - || kind === 14 /* TemplateTail */; + return kind === 14 /* TemplateMiddle */ + || kind === 15 /* TemplateTail */; } ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; // Identifiers function isIdentifier(node) { - return node.kind === 69 /* Identifier */; + return node.kind === 70 /* Identifier */; } ts.isIdentifier = isIdentifier; function isGeneratedIdentifier(node) { @@ -9420,90 +9459,90 @@ var ts; ts.isModifier = isModifier; // Names function isQualifiedName(node) { - return node.kind === 139 /* QualifiedName */; + return node.kind === 140 /* QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 140 /* ComputedPropertyName */; + return node.kind === 141 /* ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; function isEntityName(node) { var kind = node.kind; - return kind === 139 /* QualifiedName */ - || kind === 69 /* Identifier */; + return kind === 140 /* QualifiedName */ + || kind === 70 /* Identifier */; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 69 /* Identifier */ + return kind === 70 /* Identifier */ || kind === 9 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 140 /* ComputedPropertyName */; + || kind === 141 /* ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isModuleName(node) { var kind = node.kind; - return kind === 69 /* Identifier */ + return kind === 70 /* Identifier */ || kind === 9 /* StringLiteral */; } ts.isModuleName = isModuleName; function isBindingName(node) { var kind = node.kind; - return kind === 69 /* Identifier */ - || kind === 167 /* ObjectBindingPattern */ - || kind === 168 /* ArrayBindingPattern */; + return kind === 70 /* Identifier */ + || kind === 168 /* ObjectBindingPattern */ + || kind === 169 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Signature elements function isTypeParameter(node) { - return node.kind === 141 /* TypeParameter */; + return node.kind === 142 /* TypeParameter */; } ts.isTypeParameter = isTypeParameter; function isParameter(node) { - return node.kind === 142 /* Parameter */; + return node.kind === 143 /* Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 143 /* Decorator */; + return node.kind === 144 /* Decorator */; } ts.isDecorator = isDecorator; // Type members function isMethodDeclaration(node) { - return node.kind === 147 /* MethodDeclaration */; + return node.kind === 148 /* MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isClassElement(node) { var kind = node.kind; - return kind === 148 /* Constructor */ - || kind === 145 /* PropertyDeclaration */ - || kind === 147 /* MethodDeclaration */ - || kind === 149 /* GetAccessor */ - || kind === 150 /* SetAccessor */ - || kind === 153 /* IndexSignature */ - || kind === 198 /* SemicolonClassElement */; + return kind === 149 /* Constructor */ + || kind === 146 /* PropertyDeclaration */ + || kind === 148 /* MethodDeclaration */ + || kind === 150 /* GetAccessor */ + || kind === 151 /* SetAccessor */ + || kind === 154 /* IndexSignature */ + || kind === 199 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isObjectLiteralElementLike(node) { var kind = node.kind; return kind === 253 /* PropertyAssignment */ || kind === 254 /* ShorthandPropertyAssignment */ - || kind === 147 /* MethodDeclaration */ - || kind === 149 /* GetAccessor */ - || kind === 150 /* SetAccessor */ - || kind === 239 /* MissingDeclaration */; + || kind === 148 /* MethodDeclaration */ + || kind === 150 /* GetAccessor */ + || kind === 151 /* SetAccessor */ + || kind === 240 /* MissingDeclaration */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type function isTypeNodeKind(kind) { - return (kind >= 154 /* FirstTypeNode */ && kind <= 166 /* LastTypeNode */) - || kind === 117 /* AnyKeyword */ - || kind === 130 /* NumberKeyword */ - || kind === 120 /* BooleanKeyword */ - || kind === 132 /* StringKeyword */ - || kind === 133 /* SymbolKeyword */ - || kind === 103 /* VoidKeyword */ - || kind === 127 /* NeverKeyword */ - || kind === 194 /* ExpressionWithTypeArguments */; + return (kind >= 155 /* FirstTypeNode */ && kind <= 167 /* LastTypeNode */) + || kind === 118 /* AnyKeyword */ + || kind === 131 /* NumberKeyword */ + || kind === 121 /* BooleanKeyword */ + || kind === 133 /* StringKeyword */ + || kind === 134 /* SymbolKeyword */ + || kind === 104 /* VoidKeyword */ + || kind === 128 /* NeverKeyword */ + || kind === 195 /* ExpressionWithTypeArguments */; } /** * Node test that determines whether a node is a valid type node. @@ -9518,95 +9557,95 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 168 /* ArrayBindingPattern */ - || kind === 167 /* ObjectBindingPattern */; + return kind === 169 /* ArrayBindingPattern */ + || kind === 168 /* ObjectBindingPattern */; } return false; } ts.isBindingPattern = isBindingPattern; function isBindingElement(node) { - return node.kind === 169 /* BindingElement */; + return node.kind === 170 /* BindingElement */; } ts.isBindingElement = isBindingElement; function isArrayBindingElement(node) { var kind = node.kind; - return kind === 169 /* BindingElement */ - || kind === 193 /* OmittedExpression */; + return kind === 170 /* BindingElement */ + || kind === 194 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; // Expression function isPropertyAccessExpression(node) { - return node.kind === 172 /* PropertyAccessExpression */; + return node.kind === 173 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 173 /* ElementAccessExpression */; + return node.kind === 174 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isBinaryExpression(node) { - return node.kind === 187 /* BinaryExpression */; + return node.kind === 188 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 188 /* ConditionalExpression */; + return node.kind === 189 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isCallExpression(node) { - return node.kind === 174 /* CallExpression */; + return node.kind === 175 /* CallExpression */; } ts.isCallExpression = isCallExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 189 /* TemplateExpression */ - || kind === 11 /* NoSubstitutionTemplateLiteral */; + return kind === 190 /* TemplateExpression */ + || kind === 12 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; function isSpreadElementExpression(node) { - return node.kind === 191 /* SpreadElementExpression */; + return node.kind === 192 /* SpreadElementExpression */; } ts.isSpreadElementExpression = isSpreadElementExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 194 /* ExpressionWithTypeArguments */; + return node.kind === 195 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isLeftHandSideExpressionKind(kind) { - return kind === 172 /* PropertyAccessExpression */ - || kind === 173 /* ElementAccessExpression */ - || kind === 175 /* NewExpression */ - || kind === 174 /* CallExpression */ - || kind === 241 /* JsxElement */ - || kind === 242 /* JsxSelfClosingElement */ - || kind === 176 /* TaggedTemplateExpression */ - || kind === 170 /* ArrayLiteralExpression */ - || kind === 178 /* ParenthesizedExpression */ - || kind === 171 /* ObjectLiteralExpression */ - || kind === 192 /* ClassExpression */ - || kind === 179 /* FunctionExpression */ - || kind === 69 /* Identifier */ - || kind === 10 /* RegularExpressionLiteral */ + return kind === 173 /* PropertyAccessExpression */ + || kind === 174 /* ElementAccessExpression */ + || kind === 176 /* NewExpression */ + || kind === 175 /* CallExpression */ + || kind === 242 /* JsxElement */ + || kind === 243 /* JsxSelfClosingElement */ + || kind === 177 /* TaggedTemplateExpression */ + || kind === 171 /* ArrayLiteralExpression */ + || kind === 179 /* ParenthesizedExpression */ + || kind === 172 /* ObjectLiteralExpression */ + || kind === 193 /* ClassExpression */ + || kind === 180 /* FunctionExpression */ + || kind === 70 /* Identifier */ + || kind === 11 /* RegularExpressionLiteral */ || kind === 8 /* NumericLiteral */ || kind === 9 /* StringLiteral */ - || kind === 11 /* NoSubstitutionTemplateLiteral */ - || kind === 189 /* TemplateExpression */ - || kind === 84 /* FalseKeyword */ - || kind === 93 /* NullKeyword */ - || kind === 97 /* ThisKeyword */ - || kind === 99 /* TrueKeyword */ - || kind === 95 /* SuperKeyword */ - || kind === 196 /* NonNullExpression */; + || kind === 12 /* NoSubstitutionTemplateLiteral */ + || kind === 190 /* TemplateExpression */ + || kind === 85 /* FalseKeyword */ + || kind === 94 /* NullKeyword */ + || kind === 98 /* ThisKeyword */ + || kind === 100 /* TrueKeyword */ + || kind === 96 /* SuperKeyword */ + || kind === 197 /* NonNullExpression */; } function isLeftHandSideExpression(node) { return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isUnaryExpressionKind(kind) { - return kind === 185 /* PrefixUnaryExpression */ - || kind === 186 /* PostfixUnaryExpression */ - || kind === 181 /* DeleteExpression */ - || kind === 182 /* TypeOfExpression */ - || kind === 183 /* VoidExpression */ - || kind === 184 /* AwaitExpression */ - || kind === 177 /* TypeAssertionExpression */ + return kind === 186 /* PrefixUnaryExpression */ + || kind === 187 /* PostfixUnaryExpression */ + || kind === 182 /* DeleteExpression */ + || kind === 183 /* TypeOfExpression */ + || kind === 184 /* VoidExpression */ + || kind === 185 /* AwaitExpression */ + || kind === 178 /* TypeAssertionExpression */ || isLeftHandSideExpressionKind(kind); } function isUnaryExpression(node) { @@ -9614,13 +9653,13 @@ var ts; } ts.isUnaryExpression = isUnaryExpression; function isExpressionKind(kind) { - return kind === 188 /* ConditionalExpression */ - || kind === 190 /* YieldExpression */ - || kind === 180 /* ArrowFunction */ - || kind === 187 /* BinaryExpression */ - || kind === 191 /* SpreadElementExpression */ - || kind === 195 /* AsExpression */ - || kind === 193 /* OmittedExpression */ + return kind === 189 /* ConditionalExpression */ + || kind === 191 /* YieldExpression */ + || kind === 181 /* ArrowFunction */ + || kind === 188 /* BinaryExpression */ + || kind === 192 /* SpreadElementExpression */ + || kind === 196 /* AsExpression */ + || kind === 194 /* OmittedExpression */ || isUnaryExpressionKind(kind); } function isExpression(node) { @@ -9629,8 +9668,8 @@ var ts; ts.isExpression = isExpression; function isAssertionExpression(node) { var kind = node.kind; - return kind === 177 /* TypeAssertionExpression */ - || kind === 195 /* AsExpression */; + return kind === 178 /* TypeAssertionExpression */ + || kind === 196 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { @@ -9647,17 +9686,17 @@ var ts; } ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isOmittedExpression(node) { - return node.kind === 193 /* OmittedExpression */; + return node.kind === 194 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; // Misc function isTemplateSpan(node) { - return node.kind === 197 /* TemplateSpan */; + return node.kind === 198 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; // Element function isBlock(node) { - return node.kind === 199 /* Block */; + return node.kind === 200 /* Block */; } ts.isBlock = isBlock; function isConciseBody(node) { @@ -9675,118 +9714,118 @@ var ts; } ts.isForInitializer = isForInitializer; function isVariableDeclaration(node) { - return node.kind === 218 /* VariableDeclaration */; + return node.kind === 219 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 219 /* VariableDeclarationList */; + return node.kind === 220 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isCaseBlock(node) { - return node.kind === 227 /* CaseBlock */; + return node.kind === 228 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isModuleBody(node) { var kind = node.kind; - return kind === 226 /* ModuleBlock */ - || kind === 225 /* ModuleDeclaration */; + return kind === 227 /* ModuleBlock */ + || kind === 226 /* ModuleDeclaration */; } ts.isModuleBody = isModuleBody; function isImportEqualsDeclaration(node) { - return node.kind === 229 /* ImportEqualsDeclaration */; + return node.kind === 230 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportClause(node) { - return node.kind === 231 /* ImportClause */; + return node.kind === 232 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 233 /* NamedImports */ - || kind === 232 /* NamespaceImport */; + return kind === 234 /* NamedImports */ + || kind === 233 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; function isImportSpecifier(node) { - return node.kind === 234 /* ImportSpecifier */; + return node.kind === 235 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isNamedExports(node) { - return node.kind === 237 /* NamedExports */; + return node.kind === 238 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 238 /* ExportSpecifier */; + return node.kind === 239 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isModuleOrEnumDeclaration(node) { - return node.kind === 225 /* ModuleDeclaration */ || node.kind === 224 /* EnumDeclaration */; + return node.kind === 226 /* ModuleDeclaration */ || node.kind === 225 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 180 /* ArrowFunction */ - || kind === 169 /* BindingElement */ - || kind === 221 /* ClassDeclaration */ - || kind === 192 /* ClassExpression */ - || kind === 148 /* Constructor */ - || kind === 224 /* EnumDeclaration */ + return kind === 181 /* ArrowFunction */ + || kind === 170 /* BindingElement */ + || kind === 222 /* ClassDeclaration */ + || kind === 193 /* ClassExpression */ + || kind === 149 /* Constructor */ + || kind === 225 /* EnumDeclaration */ || kind === 255 /* EnumMember */ - || kind === 238 /* ExportSpecifier */ - || kind === 220 /* FunctionDeclaration */ - || kind === 179 /* FunctionExpression */ - || kind === 149 /* GetAccessor */ - || kind === 231 /* ImportClause */ - || kind === 229 /* ImportEqualsDeclaration */ - || kind === 234 /* ImportSpecifier */ - || kind === 222 /* InterfaceDeclaration */ - || kind === 147 /* MethodDeclaration */ - || kind === 146 /* MethodSignature */ - || kind === 225 /* ModuleDeclaration */ - || kind === 228 /* NamespaceExportDeclaration */ - || kind === 232 /* NamespaceImport */ - || kind === 142 /* Parameter */ + || kind === 239 /* ExportSpecifier */ + || kind === 221 /* FunctionDeclaration */ + || kind === 180 /* FunctionExpression */ + || kind === 150 /* GetAccessor */ + || kind === 232 /* ImportClause */ + || kind === 230 /* ImportEqualsDeclaration */ + || kind === 235 /* ImportSpecifier */ + || kind === 223 /* InterfaceDeclaration */ + || kind === 148 /* MethodDeclaration */ + || kind === 147 /* MethodSignature */ + || kind === 226 /* ModuleDeclaration */ + || kind === 229 /* NamespaceExportDeclaration */ + || kind === 233 /* NamespaceImport */ + || kind === 143 /* Parameter */ || kind === 253 /* PropertyAssignment */ - || kind === 145 /* PropertyDeclaration */ - || kind === 144 /* PropertySignature */ - || kind === 150 /* SetAccessor */ + || kind === 146 /* PropertyDeclaration */ + || kind === 145 /* PropertySignature */ + || kind === 151 /* SetAccessor */ || kind === 254 /* ShorthandPropertyAssignment */ - || kind === 223 /* TypeAliasDeclaration */ - || kind === 141 /* TypeParameter */ - || kind === 218 /* VariableDeclaration */ + || kind === 224 /* TypeAliasDeclaration */ + || kind === 142 /* TypeParameter */ + || kind === 219 /* VariableDeclaration */ || kind === 279 /* JSDocTypedefTag */; } function isDeclarationStatementKind(kind) { - return kind === 220 /* FunctionDeclaration */ - || kind === 239 /* MissingDeclaration */ - || kind === 221 /* ClassDeclaration */ - || kind === 222 /* InterfaceDeclaration */ - || kind === 223 /* TypeAliasDeclaration */ - || kind === 224 /* EnumDeclaration */ - || kind === 225 /* ModuleDeclaration */ - || kind === 230 /* ImportDeclaration */ - || kind === 229 /* ImportEqualsDeclaration */ - || kind === 236 /* ExportDeclaration */ - || kind === 235 /* ExportAssignment */ - || kind === 228 /* NamespaceExportDeclaration */; + return kind === 221 /* FunctionDeclaration */ + || kind === 240 /* MissingDeclaration */ + || kind === 222 /* ClassDeclaration */ + || kind === 223 /* InterfaceDeclaration */ + || kind === 224 /* TypeAliasDeclaration */ + || kind === 225 /* EnumDeclaration */ + || kind === 226 /* ModuleDeclaration */ + || kind === 231 /* ImportDeclaration */ + || kind === 230 /* ImportEqualsDeclaration */ + || kind === 237 /* ExportDeclaration */ + || kind === 236 /* ExportAssignment */ + || kind === 229 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 210 /* BreakStatement */ - || kind === 209 /* ContinueStatement */ - || kind === 217 /* DebuggerStatement */ - || kind === 204 /* DoStatement */ - || kind === 202 /* ExpressionStatement */ - || kind === 201 /* EmptyStatement */ - || kind === 207 /* ForInStatement */ - || kind === 208 /* ForOfStatement */ - || kind === 206 /* ForStatement */ - || kind === 203 /* IfStatement */ - || kind === 214 /* LabeledStatement */ - || kind === 211 /* ReturnStatement */ - || kind === 213 /* SwitchStatement */ - || kind === 215 /* ThrowStatement */ - || kind === 216 /* TryStatement */ - || kind === 200 /* VariableStatement */ - || kind === 205 /* WhileStatement */ - || kind === 212 /* WithStatement */ + return kind === 211 /* BreakStatement */ + || kind === 210 /* ContinueStatement */ + || kind === 218 /* DebuggerStatement */ + || kind === 205 /* DoStatement */ + || kind === 203 /* ExpressionStatement */ + || kind === 202 /* EmptyStatement */ + || kind === 208 /* ForInStatement */ + || kind === 209 /* ForOfStatement */ + || kind === 207 /* ForStatement */ + || kind === 204 /* IfStatement */ + || kind === 215 /* LabeledStatement */ + || kind === 212 /* ReturnStatement */ + || kind === 214 /* SwitchStatement */ + || kind === 216 /* ThrowStatement */ + || kind === 217 /* TryStatement */ + || kind === 201 /* VariableStatement */ + || kind === 206 /* WhileStatement */ + || kind === 213 /* WithStatement */ || kind === 287 /* NotEmittedStatement */; } function isDeclaration(node) { @@ -9808,20 +9847,20 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 199 /* Block */; + || kind === 200 /* Block */; } ts.isStatement = isStatement; // Module references function isModuleReference(node) { var kind = node.kind; - return kind === 240 /* ExternalModuleReference */ - || kind === 139 /* QualifiedName */ - || kind === 69 /* Identifier */; + return kind === 241 /* ExternalModuleReference */ + || kind === 140 /* QualifiedName */ + || kind === 70 /* Identifier */; } ts.isModuleReference = isModuleReference; // JSX function isJsxOpeningElement(node) { - return node.kind === 243 /* JsxOpeningElement */; + return node.kind === 244 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { @@ -9830,17 +9869,17 @@ var ts; ts.isJsxClosingElement = isJsxClosingElement; function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 97 /* ThisKeyword */ - || kind === 69 /* Identifier */ - || kind === 172 /* PropertyAccessExpression */; + return kind === 98 /* ThisKeyword */ + || kind === 70 /* Identifier */ + || kind === 173 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 241 /* JsxElement */ + return kind === 242 /* JsxElement */ || kind === 248 /* JsxExpression */ - || kind === 242 /* JsxSelfClosingElement */ - || kind === 244 /* JsxText */; + || kind === 243 /* JsxSelfClosingElement */ + || kind === 10 /* JsxText */; } ts.isJsxChild = isJsxChild; function isJsxAttributeLike(node) { @@ -9905,7 +9944,16 @@ var ts; })(ts || (ts = {})); (function (ts) { function getDefaultLibFileName(options) { - return options.target === 2 /* ES6 */ ? "lib.es6.d.ts" : "lib.d.ts"; + switch (options.target) { + case 4 /* ES2017 */: + return "lib.es2017.d.ts"; + case 3 /* ES2016 */: + return "lib.es2016.d.ts"; + case 2 /* ES2015 */: + return "lib.es6.d.ts"; + default: + return "lib.d.ts"; + } } ts.getDefaultLibFileName = getDefaultLibFileName; function textSpanEnd(span) { @@ -10114,9 +10162,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 141 /* TypeParameter */) { + if (d && d.kind === 142 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 222 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 223 /* InterfaceDeclaration */) { return current; } } @@ -10124,11 +10172,11 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 148 /* Constructor */ && ts.isClassLike(node.parent.parent); + return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 149 /* Constructor */ && ts.isClassLike(node.parent.parent); } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 169 /* BindingElement */ || ts.isBindingPattern(node))) { + while (node && (node.kind === 170 /* BindingElement */ || ts.isBindingPattern(node))) { node = node.parent; } return node; @@ -10136,14 +10184,14 @@ var ts; function getCombinedModifierFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = ts.getModifierFlags(node); - if (node.kind === 218 /* VariableDeclaration */) { + if (node.kind === 219 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 219 /* VariableDeclarationList */) { + if (node && node.kind === 220 /* VariableDeclarationList */) { flags |= ts.getModifierFlags(node); node = node.parent; } - if (node && node.kind === 200 /* VariableStatement */) { + if (node && node.kind === 201 /* VariableStatement */) { flags |= ts.getModifierFlags(node); } return flags; @@ -10159,14 +10207,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 218 /* VariableDeclaration */) { + if (node.kind === 219 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 219 /* VariableDeclarationList */) { + if (node && node.kind === 220 /* VariableDeclarationList */) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 200 /* VariableStatement */) { + if (node && node.kind === 201 /* VariableStatement */) { flags |= node.flags; } return flags; @@ -10271,7 +10319,7 @@ var ts; return node; } else if (typeof value === "boolean") { - return createNode(value ? 99 /* TrueKeyword */ : 84 /* FalseKeyword */, location, /*flags*/ undefined); + return createNode(value ? 100 /* TrueKeyword */ : 85 /* FalseKeyword */, location, /*flags*/ undefined); } else if (typeof value === "string") { var node = createNode(9 /* StringLiteral */, location, /*flags*/ undefined); @@ -10289,7 +10337,7 @@ var ts; // Identifiers var nextAutoGenerateId = 0; function createIdentifier(text, location) { - var node = createNode(69 /* Identifier */, location); + var node = createNode(70 /* Identifier */, location); node.text = ts.escapeIdentifier(text); node.originalKeywordKind = ts.stringToToken(text); node.autoGenerateKind = 0 /* None */; @@ -10298,7 +10346,7 @@ var ts; } ts.createIdentifier = createIdentifier; function createTempVariable(recordTempVariable, location) { - var name = createNode(69 /* Identifier */, location); + var name = createNode(70 /* Identifier */, location); name.text = ""; name.originalKeywordKind = 0 /* Unknown */; name.autoGenerateKind = 1 /* Auto */; @@ -10311,7 +10359,7 @@ var ts; } ts.createTempVariable = createTempVariable; function createLoopVariable(location) { - var name = createNode(69 /* Identifier */, location); + var name = createNode(70 /* Identifier */, location); name.text = ""; name.originalKeywordKind = 0 /* Unknown */; name.autoGenerateKind = 2 /* Loop */; @@ -10321,7 +10369,7 @@ var ts; } ts.createLoopVariable = createLoopVariable; function createUniqueName(text, location) { - var name = createNode(69 /* Identifier */, location); + var name = createNode(70 /* Identifier */, location); name.text = text; name.originalKeywordKind = 0 /* Unknown */; name.autoGenerateKind = 3 /* Unique */; @@ -10331,7 +10379,7 @@ var ts; } ts.createUniqueName = createUniqueName; function getGeneratedNameForNode(node, location) { - var name = createNode(69 /* Identifier */, location); + var name = createNode(70 /* Identifier */, location); name.original = node; name.text = ""; name.originalKeywordKind = 0 /* Unknown */; @@ -10348,23 +10396,23 @@ var ts; ts.createToken = createToken; // Reserved words function createSuper() { - var node = createNode(95 /* SuperKeyword */); + var node = createNode(96 /* SuperKeyword */); return node; } ts.createSuper = createSuper; function createThis(location) { - var node = createNode(97 /* ThisKeyword */, location); + var node = createNode(98 /* ThisKeyword */, location); return node; } ts.createThis = createThis; function createNull() { - var node = createNode(93 /* NullKeyword */); + var node = createNode(94 /* NullKeyword */); return node; } ts.createNull = createNull; // Names function createComputedPropertyName(expression, location) { - var node = createNode(140 /* ComputedPropertyName */, location); + var node = createNode(141 /* ComputedPropertyName */, location); node.expression = expression; return node; } @@ -10387,7 +10435,7 @@ var ts; } ts.createParameter = createParameter; function createParameterDeclaration(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer, location, flags) { - var node = createNode(142 /* Parameter */, location, flags); + var node = createNode(143 /* Parameter */, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.dotDotDotToken = dotDotDotToken; @@ -10407,7 +10455,7 @@ var ts; ts.updateParameterDeclaration = updateParameterDeclaration; // Type members function createProperty(decorators, modifiers, name, questionToken, type, initializer, location) { - var node = createNode(145 /* PropertyDeclaration */, location); + var node = createNode(146 /* PropertyDeclaration */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10425,7 +10473,7 @@ var ts; } ts.updateProperty = updateProperty; function createMethod(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(147 /* MethodDeclaration */, location, flags); + var node = createNode(148 /* MethodDeclaration */, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; @@ -10445,7 +10493,7 @@ var ts; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body, location, flags) { - var node = createNode(148 /* Constructor */, location, flags); + var node = createNode(149 /* Constructor */, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.typeParameters = undefined; @@ -10463,7 +10511,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body, location, flags) { - var node = createNode(149 /* GetAccessor */, location, flags); + var node = createNode(150 /* GetAccessor */, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10482,7 +10530,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body, location, flags) { - var node = createNode(150 /* SetAccessor */, location, flags); + var node = createNode(151 /* SetAccessor */, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10501,7 +10549,7 @@ var ts; ts.updateSetAccessor = updateSetAccessor; // Binding Patterns function createObjectBindingPattern(elements, location) { - var node = createNode(167 /* ObjectBindingPattern */, location); + var node = createNode(168 /* ObjectBindingPattern */, location); node.elements = createNodeArray(elements); return node; } @@ -10514,7 +10562,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements, location) { - var node = createNode(168 /* ArrayBindingPattern */, location); + var node = createNode(169 /* ArrayBindingPattern */, location); node.elements = createNodeArray(elements); return node; } @@ -10527,7 +10575,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(propertyName, dotDotDotToken, name, initializer, location) { - var node = createNode(169 /* BindingElement */, location); + var node = createNode(170 /* BindingElement */, location); node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; node.dotDotDotToken = dotDotDotToken; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10544,7 +10592,7 @@ var ts; ts.updateBindingElement = updateBindingElement; // Expression function createArrayLiteral(elements, location, multiLine) { - var node = createNode(170 /* ArrayLiteralExpression */, location); + var node = createNode(171 /* ArrayLiteralExpression */, location); node.elements = parenthesizeListElements(createNodeArray(elements)); if (multiLine) { node.multiLine = true; @@ -10560,7 +10608,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, location, multiLine) { - var node = createNode(171 /* ObjectLiteralExpression */, location); + var node = createNode(172 /* ObjectLiteralExpression */, location); node.properties = createNodeArray(properties); if (multiLine) { node.multiLine = true; @@ -10576,7 +10624,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name, location, flags) { - var node = createNode(172 /* PropertyAccessExpression */, location, flags); + var node = createNode(173 /* PropertyAccessExpression */, location, flags); node.expression = parenthesizeForAccess(expression); (node.emitNode || (node.emitNode = {})).flags |= 1048576 /* NoIndentation */; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10594,7 +10642,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index, location) { - var node = createNode(173 /* ElementAccessExpression */, location); + var node = createNode(174 /* ElementAccessExpression */, location); node.expression = parenthesizeForAccess(expression); node.argumentExpression = typeof index === "number" ? createLiteral(index) : index; return node; @@ -10608,7 +10656,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(174 /* CallExpression */, location, flags); + var node = createNode(175 /* CallExpression */, location, flags); node.expression = parenthesizeForAccess(expression); if (typeArguments) { node.typeArguments = createNodeArray(typeArguments); @@ -10625,7 +10673,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(175 /* NewExpression */, location, flags); + var node = createNode(176 /* NewExpression */, location, flags); node.expression = parenthesizeForNew(expression); node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; node.arguments = argumentsArray ? parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -10640,7 +10688,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, template, location) { - var node = createNode(176 /* TaggedTemplateExpression */, location); + var node = createNode(177 /* TaggedTemplateExpression */, location); node.tag = parenthesizeForAccess(tag); node.template = template; return node; @@ -10654,7 +10702,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createParen(expression, location) { - var node = createNode(178 /* ParenthesizedExpression */, location); + var node = createNode(179 /* ParenthesizedExpression */, location); node.expression = expression; return node; } @@ -10666,9 +10714,9 @@ var ts; return node; } ts.updateParen = updateParen; - function createFunctionExpression(asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(179 /* FunctionExpression */, location, flags); - node.modifiers = undefined; + function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { + var node = createNode(180 /* FunctionExpression */, location, flags); + node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; node.name = typeof name === "string" ? createIdentifier(name) : name; node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; @@ -10678,20 +10726,20 @@ var ts; return node; } ts.createFunctionExpression = createFunctionExpression; - function updateFunctionExpression(node, name, typeParameters, parameters, type, body) { - if (node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createFunctionExpression(node.asteriskToken, name, typeParameters, parameters, type, body, /*location*/ node, node.flags), node); + function updateFunctionExpression(node, modifiers, name, typeParameters, parameters, type, body) { + if (node.name !== name || node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { + return updateNode(createFunctionExpression(modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, /*location*/ node, node.flags), node); } return node; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body, location, flags) { - var node = createNode(180 /* ArrowFunction */, location, flags); + var node = createNode(181 /* ArrowFunction */, location, flags); node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; node.parameters = createNodeArray(parameters); node.type = type; - node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(34 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(35 /* EqualsGreaterThanToken */); node.body = parenthesizeConciseBody(body); return node; } @@ -10704,7 +10752,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression, location) { - var node = createNode(181 /* DeleteExpression */, location); + var node = createNode(182 /* DeleteExpression */, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10717,7 +10765,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression, location) { - var node = createNode(182 /* TypeOfExpression */, location); + var node = createNode(183 /* TypeOfExpression */, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10730,7 +10778,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression, location) { - var node = createNode(183 /* VoidExpression */, location); + var node = createNode(184 /* VoidExpression */, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10743,7 +10791,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression, location) { - var node = createNode(184 /* AwaitExpression */, location); + var node = createNode(185 /* AwaitExpression */, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10756,7 +10804,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand, location) { - var node = createNode(185 /* PrefixUnaryExpression */, location); + var node = createNode(186 /* PrefixUnaryExpression */, location); node.operator = operator; node.operand = parenthesizePrefixOperand(operand); return node; @@ -10770,7 +10818,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator, location) { - var node = createNode(186 /* PostfixUnaryExpression */, location); + var node = createNode(187 /* PostfixUnaryExpression */, location); node.operand = parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -10786,7 +10834,7 @@ var ts; function createBinary(left, operator, right, location) { var operatorToken = typeof operator === "number" ? createToken(operator) : operator; var operatorKind = operatorToken.kind; - var node = createNode(187 /* BinaryExpression */, location); + var node = createNode(188 /* BinaryExpression */, location); node.left = parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); node.operatorToken = operatorToken; node.right = parenthesizeBinaryOperand(operatorKind, right, /*isLeftSideOfBinary*/ false, node.left); @@ -10801,7 +10849,7 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionToken, whenTrue, colonToken, whenFalse, location) { - var node = createNode(188 /* ConditionalExpression */, location); + var node = createNode(189 /* ConditionalExpression */, location); node.condition = condition; node.questionToken = questionToken; node.whenTrue = whenTrue; @@ -10818,7 +10866,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans, location) { - var node = createNode(189 /* TemplateExpression */, location); + var node = createNode(190 /* TemplateExpression */, location); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -10832,7 +10880,7 @@ var ts; } ts.updateTemplateExpression = updateTemplateExpression; function createYield(asteriskToken, expression, location) { - var node = createNode(190 /* YieldExpression */, location); + var node = createNode(191 /* YieldExpression */, location); node.asteriskToken = asteriskToken; node.expression = expression; return node; @@ -10846,7 +10894,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression, location) { - var node = createNode(191 /* SpreadElementExpression */, location); + var node = createNode(192 /* SpreadElementExpression */, location); node.expression = parenthesizeExpressionForList(expression); return node; } @@ -10859,7 +10907,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(192 /* ClassExpression */, location); + var node = createNode(193 /* ClassExpression */, location); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -10877,12 +10925,12 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression(location) { - var node = createNode(193 /* OmittedExpression */, location); + var node = createNode(194 /* OmittedExpression */, location); return node; } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression, location) { - var node = createNode(194 /* ExpressionWithTypeArguments */, location); + var node = createNode(195 /* ExpressionWithTypeArguments */, location); node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; node.expression = parenthesizeForAccess(expression); return node; @@ -10897,7 +10945,7 @@ var ts; ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; // Misc function createTemplateSpan(expression, literal, location) { - var node = createNode(197 /* TemplateSpan */, location); + var node = createNode(198 /* TemplateSpan */, location); node.expression = expression; node.literal = literal; return node; @@ -10912,7 +10960,7 @@ var ts; ts.updateTemplateSpan = updateTemplateSpan; // Element function createBlock(statements, location, multiLine, flags) { - var block = createNode(199 /* Block */, location, flags); + var block = createNode(200 /* Block */, location, flags); block.statements = createNodeArray(statements); if (multiLine) { block.multiLine = true; @@ -10928,7 +10976,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList, location, flags) { - var node = createNode(200 /* VariableStatement */, location, flags); + var node = createNode(201 /* VariableStatement */, location, flags); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -10943,7 +10991,7 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createVariableDeclarationList(declarations, location, flags) { - var node = createNode(219 /* VariableDeclarationList */, location, flags); + var node = createNode(220 /* VariableDeclarationList */, location, flags); node.declarations = createNodeArray(declarations); return node; } @@ -10956,7 +11004,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createVariableDeclaration(name, type, initializer, location, flags) { - var node = createNode(218 /* VariableDeclaration */, location, flags); + var node = createNode(219 /* VariableDeclaration */, location, flags); node.name = typeof name === "string" ? createIdentifier(name) : name; node.type = type; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -10971,11 +11019,11 @@ var ts; } ts.updateVariableDeclaration = updateVariableDeclaration; function createEmptyStatement(location) { - return createNode(201 /* EmptyStatement */, location); + return createNode(202 /* EmptyStatement */, location); } ts.createEmptyStatement = createEmptyStatement; function createStatement(expression, location, flags) { - var node = createNode(202 /* ExpressionStatement */, location, flags); + var node = createNode(203 /* ExpressionStatement */, location, flags); node.expression = parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -10988,7 +11036,7 @@ var ts; } ts.updateStatement = updateStatement; function createIf(expression, thenStatement, elseStatement, location) { - var node = createNode(203 /* IfStatement */, location); + var node = createNode(204 /* IfStatement */, location); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -11003,7 +11051,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression, location) { - var node = createNode(204 /* DoStatement */, location); + var node = createNode(205 /* DoStatement */, location); node.statement = statement; node.expression = expression; return node; @@ -11017,7 +11065,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement, location) { - var node = createNode(205 /* WhileStatement */, location); + var node = createNode(206 /* WhileStatement */, location); node.expression = expression; node.statement = statement; return node; @@ -11031,7 +11079,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement, location) { - var node = createNode(206 /* ForStatement */, location, /*flags*/ undefined); + var node = createNode(207 /* ForStatement */, location, /*flags*/ undefined); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -11047,7 +11095,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement, location) { - var node = createNode(207 /* ForInStatement */, location); + var node = createNode(208 /* ForInStatement */, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11062,7 +11110,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(initializer, expression, statement, location) { - var node = createNode(208 /* ForOfStatement */, location); + var node = createNode(209 /* ForOfStatement */, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11077,7 +11125,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label, location) { - var node = createNode(209 /* ContinueStatement */, location); + var node = createNode(210 /* ContinueStatement */, location); if (label) { node.label = label; } @@ -11092,7 +11140,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label, location) { - var node = createNode(210 /* BreakStatement */, location); + var node = createNode(211 /* BreakStatement */, location); if (label) { node.label = label; } @@ -11107,7 +11155,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression, location) { - var node = createNode(211 /* ReturnStatement */, location); + var node = createNode(212 /* ReturnStatement */, location); node.expression = expression; return node; } @@ -11120,7 +11168,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement, location) { - var node = createNode(212 /* WithStatement */, location); + var node = createNode(213 /* WithStatement */, location); node.expression = expression; node.statement = statement; return node; @@ -11134,7 +11182,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock, location) { - var node = createNode(213 /* SwitchStatement */, location); + var node = createNode(214 /* SwitchStatement */, location); node.expression = parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -11148,7 +11196,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement, location) { - var node = createNode(214 /* LabeledStatement */, location); + var node = createNode(215 /* LabeledStatement */, location); node.label = typeof label === "string" ? createIdentifier(label) : label; node.statement = statement; return node; @@ -11162,7 +11210,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression, location) { - var node = createNode(215 /* ThrowStatement */, location); + var node = createNode(216 /* ThrowStatement */, location); node.expression = expression; return node; } @@ -11175,7 +11223,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock, location) { - var node = createNode(216 /* TryStatement */, location); + var node = createNode(217 /* TryStatement */, location); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -11190,7 +11238,7 @@ var ts; } ts.updateTry = updateTry; function createCaseBlock(clauses, location) { - var node = createNode(227 /* CaseBlock */, location); + var node = createNode(228 /* CaseBlock */, location); node.clauses = createNodeArray(clauses); return node; } @@ -11203,7 +11251,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(220 /* FunctionDeclaration */, location, flags); + var node = createNode(221 /* FunctionDeclaration */, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; @@ -11223,7 +11271,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(221 /* ClassDeclaration */, location); + var node = createNode(222 /* ClassDeclaration */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -11241,7 +11289,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, location) { - var node = createNode(230 /* ImportDeclaration */, location); + var node = createNode(231 /* ImportDeclaration */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.importClause = importClause; @@ -11257,7 +11305,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings, location) { - var node = createNode(231 /* ImportClause */, location); + var node = createNode(232 /* ImportClause */, location); node.name = name; node.namedBindings = namedBindings; return node; @@ -11271,7 +11319,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name, location) { - var node = createNode(232 /* NamespaceImport */, location); + var node = createNode(233 /* NamespaceImport */, location); node.name = name; return node; } @@ -11284,7 +11332,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements, location) { - var node = createNode(233 /* NamedImports */, location); + var node = createNode(234 /* NamedImports */, location); node.elements = createNodeArray(elements); return node; } @@ -11297,7 +11345,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name, location) { - var node = createNode(234 /* ImportSpecifier */, location); + var node = createNode(235 /* ImportSpecifier */, location); node.propertyName = propertyName; node.name = name; return node; @@ -11311,7 +11359,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression, location) { - var node = createNode(235 /* ExportAssignment */, location); + var node = createNode(236 /* ExportAssignment */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.isExportEquals = isExportEquals; @@ -11327,7 +11375,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, location) { - var node = createNode(236 /* ExportDeclaration */, location); + var node = createNode(237 /* ExportDeclaration */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.exportClause = exportClause; @@ -11343,7 +11391,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements, location) { - var node = createNode(237 /* NamedExports */, location); + var node = createNode(238 /* NamedExports */, location); node.elements = createNodeArray(elements); return node; } @@ -11356,7 +11404,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(name, propertyName, location) { - var node = createNode(238 /* ExportSpecifier */, location); + var node = createNode(239 /* ExportSpecifier */, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; return node; @@ -11371,7 +11419,7 @@ var ts; ts.updateExportSpecifier = updateExportSpecifier; // JSX function createJsxElement(openingElement, children, closingElement, location) { - var node = createNode(241 /* JsxElement */, location); + var node = createNode(242 /* JsxElement */, location); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -11386,7 +11434,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, attributes, location) { - var node = createNode(242 /* JsxSelfClosingElement */, location); + var node = createNode(243 /* JsxSelfClosingElement */, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -11400,7 +11448,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, attributes, location) { - var node = createNode(243 /* JsxOpeningElement */, location); + var node = createNode(244 /* JsxOpeningElement */, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -11653,47 +11701,47 @@ var ts; ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; // Compound nodes function createComma(left, right) { - return createBinary(left, 24 /* CommaToken */, right); + return createBinary(left, 25 /* CommaToken */, right); } ts.createComma = createComma; function createLessThan(left, right, location) { - return createBinary(left, 25 /* LessThanToken */, right, location); + return createBinary(left, 26 /* LessThanToken */, right, location); } ts.createLessThan = createLessThan; function createAssignment(left, right, location) { - return createBinary(left, 56 /* EqualsToken */, right, location); + return createBinary(left, 57 /* EqualsToken */, right, location); } ts.createAssignment = createAssignment; function createStrictEquality(left, right) { - return createBinary(left, 32 /* EqualsEqualsEqualsToken */, right); + return createBinary(left, 33 /* EqualsEqualsEqualsToken */, right); } ts.createStrictEquality = createStrictEquality; function createStrictInequality(left, right) { - return createBinary(left, 33 /* ExclamationEqualsEqualsToken */, right); + return createBinary(left, 34 /* ExclamationEqualsEqualsToken */, right); } ts.createStrictInequality = createStrictInequality; function createAdd(left, right) { - return createBinary(left, 35 /* PlusToken */, right); + return createBinary(left, 36 /* PlusToken */, right); } ts.createAdd = createAdd; function createSubtract(left, right) { - return createBinary(left, 36 /* MinusToken */, right); + return createBinary(left, 37 /* MinusToken */, right); } ts.createSubtract = createSubtract; function createPostfixIncrement(operand, location) { - return createPostfix(operand, 41 /* PlusPlusToken */, location); + return createPostfix(operand, 42 /* PlusPlusToken */, location); } ts.createPostfixIncrement = createPostfixIncrement; function createLogicalAnd(left, right) { - return createBinary(left, 51 /* AmpersandAmpersandToken */, right); + return createBinary(left, 52 /* AmpersandAmpersandToken */, right); } ts.createLogicalAnd = createLogicalAnd; function createLogicalOr(left, right) { - return createBinary(left, 52 /* BarBarToken */, right); + return createBinary(left, 53 /* BarBarToken */, right); } ts.createLogicalOr = createLogicalOr; function createLogicalNot(operand) { - return createPrefix(49 /* ExclamationToken */, operand); + return createPrefix(50 /* ExclamationToken */, operand); } ts.createLogicalNot = createLogicalNot; function createVoidZero() { @@ -11714,7 +11762,7 @@ var ts; function createRestParameter(name) { return createParameterDeclaration( /*decorators*/ undefined, - /*modifiers*/ undefined, createToken(22 /* DotDotDotToken */), name, + /*modifiers*/ undefined, createToken(23 /* DotDotDotToken */), name, /*questionToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined); @@ -11844,7 +11892,8 @@ var ts; } ts.createDecorateHelper = createDecorateHelper; function createAwaiterHelper(externalHelpersModuleName, hasLexicalArguments, promiseConstructor, body) { - var generatorFunc = createFunctionExpression(createToken(37 /* AsteriskToken */), + var generatorFunc = createFunctionExpression( + /*modifiers*/ undefined, createToken(38 /* AsteriskToken */), /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ [], @@ -11935,6 +11984,7 @@ var ts; /*modifiers*/ undefined, createConstDeclarationList([ createVariableDeclaration("_super", /*type*/ undefined, createCall(createParen(createFunctionExpression( + /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, [ @@ -11963,19 +12013,19 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = skipParentheses(node); switch (target.kind) { - case 69 /* Identifier */: + case 70 /* Identifier */: return cacheIdentifiers; - case 97 /* ThisKeyword */: + case 98 /* ThisKeyword */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: return false; - case 170 /* ArrayLiteralExpression */: + case 171 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 171 /* ObjectLiteralExpression */: + case 172 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -11989,13 +12039,13 @@ var ts; thisArg = createThis(); target = callee; } - else if (callee.kind === 95 /* SuperKeyword */) { + else if (callee.kind === 96 /* SuperKeyword */) { thisArg = createThis(); - target = languageVersion < 2 /* ES6 */ ? createIdentifier("_super", /*location*/ callee) : callee; + target = languageVersion < 2 /* ES2015 */ ? createIdentifier("_super", /*location*/ callee) : callee; } else { switch (callee.kind) { - case 172 /* PropertyAccessExpression */: { + case 173 /* PropertyAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` thisArg = createTempVariable(recordTempVariable); @@ -12009,7 +12059,7 @@ var ts; } break; } - case 173 /* ElementAccessExpression */: { + case 174 /* ElementAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` thisArg = createTempVariable(recordTempVariable); @@ -12063,14 +12113,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); case 253 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); case 254 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 147 /* MethodDeclaration */: + case 148 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); } } @@ -12080,7 +12130,7 @@ var ts; if (property === firstAccessor) { var properties_1 = []; if (getAccessor) { - var getterFunction = createFunctionExpression( + var getterFunction = createFunctionExpression(getAccessor.modifiers, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, getAccessor.parameters, @@ -12091,7 +12141,7 @@ var ts; properties_1.push(getter); } if (setAccessor) { - var setterFunction = createFunctionExpression( + var setterFunction = createFunctionExpression(setAccessor.modifiers, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, setAccessor.parameters, @@ -12125,7 +12175,7 @@ var ts; /*original*/ property)); } function createExpressionForMethodDeclaration(method, receiver) { - return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, method.name, /*location*/ method.name), setOriginalNode(createFunctionExpression(method.asteriskToken, + return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, method.name, /*location*/ method.name), setOriginalNode(createFunctionExpression(method.modifiers, method.asteriskToken, /*name*/ undefined, /*typeParameters*/ undefined, method.parameters, /*type*/ undefined, method.body, @@ -12150,7 +12200,7 @@ var ts; * @param visitor: Optional callback used to visit any custom prologue directives. */ function addPrologueDirectives(target, source, ensureUseStrict, visitor) { - ts.Debug.assert(target.length === 0, "PrologueDirectives should be at the first statement in the target statements array"); + ts.Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array"); var foundUseStrict = false; var statementOffset = 0; var numStatements = source.length; @@ -12163,16 +12213,20 @@ var ts; target.push(statement); } else { - if (ensureUseStrict && !foundUseStrict) { - target.push(startOnNewLine(createStatement(createLiteral("use strict")))); - foundUseStrict = true; - } - if (getEmitFlags(statement) & 8388608 /* CustomPrologue */) { - target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); - } - else { - break; - } + break; + } + statementOffset++; + } + if (ensureUseStrict && !foundUseStrict) { + target.push(startOnNewLine(createStatement(createLiteral("use strict")))); + } + while (statementOffset < numStatements) { + var statement = source[statementOffset]; + if (getEmitFlags(statement) & 8388608 /* CustomPrologue */) { + target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); + } + else { + break; } statementOffset++; } @@ -12219,7 +12273,7 @@ var ts; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = skipPartiallyEmittedExpressions(operand); // If the resulting expression is already parenthesized, we do not need to do any further processing. - if (skipped.kind === 178 /* ParenthesizedExpression */) { + if (skipped.kind === 179 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -12253,8 +12307,8 @@ var ts; // // If `a ** d` is on the left of operator `**`, we need to parenthesize to preserve // the intended order of operations: `(a ** b) ** c` - var binaryOperatorPrecedence = ts.getOperatorPrecedence(187 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(187 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(188 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(188 /* BinaryExpression */, binaryOperator); var emittedOperand = skipPartiallyEmittedExpressions(operand); var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { @@ -12263,7 +12317,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 190 /* YieldExpression */) { + && operand.kind === 191 /* YieldExpression */) { return false; } return true; @@ -12300,7 +12354,7 @@ var ts; // the same kind (recursively). // "a"+(1+2) => "a"+(1+2) // "a"+("b"+"c") => "a"+"b"+"c" - if (binaryOperator === 35 /* PlusToken */) { + if (binaryOperator === 36 /* PlusToken */) { var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0 /* Unknown */; if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { return false; @@ -12335,10 +12389,10 @@ var ts; // // While addition is associative in mathematics, JavaScript's `+` is not // guaranteed to be associative as it is overloaded with string concatenation. - return binaryOperator === 37 /* AsteriskToken */ - || binaryOperator === 47 /* BarToken */ - || binaryOperator === 46 /* AmpersandToken */ - || binaryOperator === 48 /* CaretToken */; + return binaryOperator === 38 /* AsteriskToken */ + || binaryOperator === 48 /* BarToken */ + || binaryOperator === 47 /* AmpersandToken */ + || binaryOperator === 49 /* CaretToken */; } /** * This function determines whether an expression consists of a homogeneous set of @@ -12351,7 +12405,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 187 /* BinaryExpression */ && node.operatorToken.kind === 35 /* PlusToken */) { + if (node.kind === 188 /* BinaryExpression */ && node.operatorToken.kind === 36 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -12374,9 +12428,9 @@ var ts; function parenthesizeForNew(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); switch (emittedExpression.kind) { - case 174 /* CallExpression */: + case 175 /* CallExpression */: return createParen(expression); - case 175 /* NewExpression */: + case 176 /* NewExpression */: return emittedExpression.arguments ? expression : createParen(expression); @@ -12401,7 +12455,7 @@ var ts; // var emittedExpression = skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 175 /* NewExpression */ || emittedExpression.arguments) + && (emittedExpression.kind !== 176 /* NewExpression */ || emittedExpression.arguments) && emittedExpression.kind !== 8 /* NumericLiteral */) { return expression; } @@ -12439,7 +12493,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(187 /* BinaryExpression */, 24 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(188 /* BinaryExpression */, 25 /* CommaToken */); return expressionPrecedence > commaPrecedence ? expression : createParen(expression, /*location*/ expression); @@ -12450,7 +12504,7 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = skipPartiallyEmittedExpressions(callee).kind; - if (kind === 179 /* FunctionExpression */ || kind === 180 /* ArrowFunction */) { + if (kind === 180 /* FunctionExpression */ || kind === 181 /* ArrowFunction */) { var mutableCall = getMutableClone(emittedExpression); mutableCall.expression = createParen(callee, /*location*/ callee); return recreatePartiallyEmittedExpressions(expression, mutableCall); @@ -12458,7 +12512,7 @@ var ts; } else { var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; - if (leftmostExpressionKind === 171 /* ObjectLiteralExpression */ || leftmostExpressionKind === 179 /* FunctionExpression */) { + if (leftmostExpressionKind === 172 /* ObjectLiteralExpression */ || leftmostExpressionKind === 180 /* FunctionExpression */) { return createParen(expression, /*location*/ expression); } } @@ -12482,18 +12536,18 @@ var ts; function getLeftmostExpression(node) { while (true) { switch (node.kind) { - case 186 /* PostfixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: node = node.operand; continue; - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: node = node.left; continue; - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: node = node.condition; continue; - case 174 /* CallExpression */: - case 173 /* ElementAccessExpression */: - case 172 /* PropertyAccessExpression */: + case 175 /* CallExpression */: + case 174 /* ElementAccessExpression */: + case 173 /* PropertyAccessExpression */: node = node.expression; continue; case 288 /* PartiallyEmittedExpression */: @@ -12505,7 +12559,7 @@ var ts; } function parenthesizeConciseBody(body) { var emittedBody = skipPartiallyEmittedExpressions(body); - if (emittedBody.kind === 171 /* ObjectLiteralExpression */) { + if (emittedBody.kind === 172 /* ObjectLiteralExpression */) { return createParen(body, /*location*/ body); } return body; @@ -12537,7 +12591,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipParentheses(node) { - while (node.kind === 178 /* ParenthesizedExpression */) { + while (node.kind === 179 /* ParenthesizedExpression */) { node = node.expression; } return node; @@ -12771,10 +12825,10 @@ var ts; var name_9 = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name_9) ? name_9 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); } - if (node.kind === 230 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 231 /* ImportDeclaration */ && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 236 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 237 /* ExportDeclaration */ && node.moduleSpecifier) { return getGeneratedNameForNode(node); } return undefined; @@ -12845,10 +12899,10 @@ var ts; if (kind === 256 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } - else if (kind === 69 /* Identifier */) { + else if (kind === 70 /* Identifier */) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } - else if (kind < 139 /* FirstNode */) { + else if (kind < 140 /* FirstNode */) { return new (TokenConstructor || (TokenConstructor = ts.objectAllocator.getTokenConstructor()))(kind, pos, end); } else { @@ -12891,10 +12945,10 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 139 /* QualifiedName */: + case 140 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 141 /* TypeParameter */: + case 142 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); @@ -12905,12 +12959,12 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 142 /* Parameter */: - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 143 /* Parameter */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: case 253 /* PropertyAssignment */: - case 218 /* VariableDeclaration */: - case 169 /* BindingElement */: + case 219 /* VariableDeclaration */: + case 170 /* BindingElement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -12919,24 +12973,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 156 /* FunctionType */: - case 157 /* ConstructorType */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 179 /* FunctionExpression */: - case 220 /* FunctionDeclaration */: - case 180 /* ArrowFunction */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 180 /* FunctionExpression */: + case 221 /* FunctionDeclaration */: + case 181 /* ArrowFunction */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -12947,176 +13001,176 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 155 /* TypeReference */: + case 156 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 154 /* TypePredicate */: + case 155 /* TypePredicate */: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 158 /* TypeQuery */: + case 159 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 159 /* TypeLiteral */: + case 160 /* TypeLiteral */: return visitNodes(cbNodes, node.members); - case 160 /* ArrayType */: + case 161 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 161 /* TupleType */: + case 162 /* TupleType */: return visitNodes(cbNodes, node.elementTypes); - case 162 /* UnionType */: - case 163 /* IntersectionType */: + case 163 /* UnionType */: + case 164 /* IntersectionType */: return visitNodes(cbNodes, node.types); - case 164 /* ParenthesizedType */: + case 165 /* ParenthesizedType */: return visitNode(cbNode, node.type); - case 166 /* LiteralType */: + case 167 /* LiteralType */: return visitNode(cbNode, node.literal); - case 167 /* ObjectBindingPattern */: - case 168 /* ArrayBindingPattern */: + case 168 /* ObjectBindingPattern */: + case 169 /* ArrayBindingPattern */: return visitNodes(cbNodes, node.elements); - case 170 /* ArrayLiteralExpression */: + case 171 /* ArrayLiteralExpression */: return visitNodes(cbNodes, node.elements); - case 171 /* ObjectLiteralExpression */: + case 172 /* ObjectLiteralExpression */: return visitNodes(cbNodes, node.properties); - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 173 /* ElementAccessExpression */: + case 174 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 174 /* CallExpression */: - case 175 /* NewExpression */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 176 /* TaggedTemplateExpression */: + case 177 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 177 /* TypeAssertionExpression */: + case 178 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 181 /* DeleteExpression */: + case 182 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 182 /* TypeOfExpression */: + case 183 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 183 /* VoidExpression */: + case 184 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 185 /* PrefixUnaryExpression */: + case 186 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 190 /* YieldExpression */: + case 191 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 184 /* AwaitExpression */: + case 185 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 186 /* PostfixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 195 /* AsExpression */: + case 196 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 196 /* NonNullExpression */: + case 197 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 191 /* SpreadElementExpression */: + case 192 /* SpreadElementExpression */: return visitNode(cbNode, node.expression); - case 199 /* Block */: - case 226 /* ModuleBlock */: + case 200 /* Block */: + case 227 /* ModuleBlock */: return visitNodes(cbNodes, node.statements); case 256 /* SourceFile */: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 219 /* VariableDeclarationList */: + case 220 /* VariableDeclarationList */: return visitNodes(cbNodes, node.declarations); - case 202 /* ExpressionStatement */: + case 203 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 203 /* IfStatement */: + case 204 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 204 /* DoStatement */: + case 205 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 205 /* WhileStatement */: + case 206 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 206 /* ForStatement */: + case 207 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 207 /* ForInStatement */: + case 208 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 208 /* ForOfStatement */: + case 209 /* ForOfStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 209 /* ContinueStatement */: - case 210 /* BreakStatement */: + case 210 /* ContinueStatement */: + case 211 /* BreakStatement */: return visitNode(cbNode, node.label); - case 211 /* ReturnStatement */: + case 212 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 212 /* WithStatement */: + case 213 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 213 /* SwitchStatement */: + case 214 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 227 /* CaseBlock */: + case 228 /* CaseBlock */: return visitNodes(cbNodes, node.clauses); case 249 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); case 250 /* DefaultClause */: return visitNodes(cbNodes, node.statements); - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 215 /* ThrowStatement */: + case 216 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 216 /* TryStatement */: + case 217 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); case 252 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 143 /* Decorator */: + case 144 /* Decorator */: return visitNode(cbNode, node.expression); - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: + case 222 /* ClassDeclaration */: + case 193 /* 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 222 /* InterfaceDeclaration */: + case 223 /* 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 223 /* TypeAliasDeclaration */: + case 224 /* TypeAliasDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -13124,65 +13178,65 @@ var ts; case 255 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 229 /* ImportEqualsDeclaration */: + case 230 /* ImportEqualsDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 230 /* ImportDeclaration */: + case 231 /* ImportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 231 /* ImportClause */: + case 232 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 228 /* NamespaceExportDeclaration */: + case 229 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 232 /* NamespaceImport */: + case 233 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 233 /* NamedImports */: - case 237 /* NamedExports */: + case 234 /* NamedImports */: + case 238 /* NamedExports */: return visitNodes(cbNodes, node.elements); - case 236 /* ExportDeclaration */: + case 237 /* ExportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 234 /* ImportSpecifier */: - case 238 /* ExportSpecifier */: + case 235 /* ImportSpecifier */: + case 239 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 189 /* TemplateExpression */: + case 190 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 197 /* TemplateSpan */: + case 198 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); case 251 /* HeritageClause */: return visitNodes(cbNodes, node.types); - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 240 /* ExternalModuleReference */: + case 241 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 239 /* MissingDeclaration */: + case 240 /* MissingDeclaration */: return visitNodes(cbNodes, node.decorators); - case 241 /* JsxElement */: + case 242 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 242 /* JsxSelfClosingElement */: - case 243 /* JsxOpeningElement */: + case 243 /* JsxSelfClosingElement */: + case 244 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); case 246 /* JsxAttribute */: @@ -13303,7 +13357,7 @@ var ts; (function (Parser) { // Share a single scanner across all calls to parse a source file. This helps speed things // up by avoiding the cost of creating/compiling scanners over and over again. - var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ true); + var scanner = ts.createScanner(4 /* Latest */, /*skipTrivia*/ true); var disallowInAndDecoratorContext = 32768 /* DisallowInContext */ | 131072 /* DecoratorContext */; // capture constructors in 'initializeState' to avoid null checks var NodeConstructor; @@ -13394,9 +13448,9 @@ var ts; // Note: any errors at the end of the file that do not precede a regular node, should get // attached to the EOF token. var parseErrorBeforeNextFinishedNode = false; - function parseSourceFile(fileName, _sourceText, languageVersion, _syntaxCursor, setParentNodes, scriptKind) { + function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes, scriptKind) { scriptKind = ts.ensureScriptKind(fileName, scriptKind); - initializeState(fileName, _sourceText, languageVersion, _syntaxCursor, scriptKind); + initializeState(sourceText, languageVersion, syntaxCursor, scriptKind); var result = parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind); clearState(); return result; @@ -13406,7 +13460,7 @@ var ts; // .tsx and .jsx files are treated as jsx language variant. return scriptKind === 4 /* TSX */ || scriptKind === 2 /* JSX */ || scriptKind === 1 /* JS */ ? 1 /* JSX */ : 0 /* Standard */; } - function initializeState(fileName, _sourceText, languageVersion, _syntaxCursor, scriptKind) { + function initializeState(_sourceText, languageVersion, _syntaxCursor, scriptKind) { NodeConstructor = ts.objectAllocator.getNodeConstructor(); TokenConstructor = ts.objectAllocator.getTokenConstructor(); IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor(); @@ -13710,20 +13764,20 @@ var ts; } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token() === 69 /* Identifier */) { + if (token() === 70 /* 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() === 114 /* YieldKeyword */ && inYieldContext()) { + if (token() === 115 /* 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() === 119 /* AwaitKeyword */ && inAwaitContext()) { + if (token() === 120 /* AwaitKeyword */ && inAwaitContext()) { return false; } - return token() > 105 /* LastReservedWord */; + return token() > 106 /* LastReservedWord */; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -13766,22 +13820,22 @@ var ts; } function canParseSemicolon() { // If there's a real semicolon, then we can always parse it out. - if (token() === 23 /* SemicolonToken */) { + if (token() === 24 /* SemicolonToken */) { return true; } // We can parse out an optional semicolon in ASI cases in the following cases. - return token() === 16 /* CloseBraceToken */ || token() === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); + return token() === 17 /* CloseBraceToken */ || token() === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); } function parseSemicolon() { if (canParseSemicolon()) { - if (token() === 23 /* SemicolonToken */) { + if (token() === 24 /* SemicolonToken */) { // consume the semicolon if it was explicitly provided. nextToken(); } return true; } else { - return parseExpected(23 /* SemicolonToken */); + return parseExpected(24 /* SemicolonToken */); } } // note: this function creates only node @@ -13790,8 +13844,8 @@ var ts; if (!(pos >= 0)) { pos = scanner.getStartPos(); } - return kind >= 139 /* FirstNode */ ? new NodeConstructor(kind, pos, pos) : - kind === 69 /* Identifier */ ? new IdentifierConstructor(kind, pos, pos) : + return kind >= 140 /* FirstNode */ ? new NodeConstructor(kind, pos, pos) : + kind === 70 /* Identifier */ ? new IdentifierConstructor(kind, pos, pos) : new TokenConstructor(kind, pos, pos); } function createNodeArray(elements, pos) { @@ -13838,16 +13892,16 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(69 /* Identifier */); + var node = createNode(70 /* Identifier */); // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker - if (token() !== 69 /* Identifier */) { + if (token() !== 70 /* Identifier */) { node.originalKeywordKind = token(); } node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - return createMissingNode(69 /* Identifier */, /*reportAtCurrentPosition*/ false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(70 /* Identifier */, /*reportAtCurrentPosition*/ false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -13864,7 +13918,7 @@ var ts; if (token() === 9 /* StringLiteral */ || token() === 8 /* NumericLiteral */) { return parseLiteralNode(/*internName*/ true); } - if (allowComputedPropertyNames && token() === 19 /* OpenBracketToken */) { + if (allowComputedPropertyNames && token() === 20 /* OpenBracketToken */) { return parseComputedPropertyName(); } return parseIdentifierName(); @@ -13882,13 +13936,13 @@ var ts; // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(140 /* ComputedPropertyName */); - parseExpected(19 /* OpenBracketToken */); + var node = createNode(141 /* ComputedPropertyName */); + parseExpected(20 /* OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker // will error if it sees a comma expression. node.expression = allowInAnd(parseExpression); - parseExpected(20 /* CloseBracketToken */); + parseExpected(21 /* CloseBracketToken */); return finishNode(node); } function parseContextualModifier(t) { @@ -13902,21 +13956,21 @@ var ts; return canFollowModifier(); } function nextTokenCanFollowModifier() { - if (token() === 74 /* ConstKeyword */) { + if (token() === 75 /* ConstKeyword */) { // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 81 /* EnumKeyword */; + return nextToken() === 82 /* EnumKeyword */; } - if (token() === 82 /* ExportKeyword */) { + if (token() === 83 /* ExportKeyword */) { nextToken(); - if (token() === 77 /* DefaultKeyword */) { + if (token() === 78 /* DefaultKeyword */) { return lookAhead(nextTokenIsClassOrFunctionOrAsync); } - return token() !== 37 /* AsteriskToken */ && token() !== 116 /* AsKeyword */ && token() !== 15 /* OpenBraceToken */ && canFollowModifier(); + return token() !== 38 /* AsteriskToken */ && token() !== 117 /* AsKeyword */ && token() !== 16 /* OpenBraceToken */ && canFollowModifier(); } - if (token() === 77 /* DefaultKeyword */) { + if (token() === 78 /* DefaultKeyword */) { return nextTokenIsClassOrFunctionOrAsync(); } - if (token() === 113 /* StaticKeyword */) { + if (token() === 114 /* StaticKeyword */) { nextToken(); return canFollowModifier(); } @@ -13926,16 +13980,16 @@ var ts; return ts.isModifierKind(token()) && tryParse(nextTokenCanFollowModifier); } function canFollowModifier() { - return token() === 19 /* OpenBracketToken */ - || token() === 15 /* OpenBraceToken */ - || token() === 37 /* AsteriskToken */ - || token() === 22 /* DotDotDotToken */ + return token() === 20 /* OpenBracketToken */ + || token() === 16 /* OpenBraceToken */ + || token() === 38 /* AsteriskToken */ + || token() === 23 /* DotDotDotToken */ || isLiteralPropertyName(); } function nextTokenIsClassOrFunctionOrAsync() { nextToken(); - return token() === 73 /* ClassKeyword */ || token() === 87 /* FunctionKeyword */ || - (token() === 118 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 74 /* ClassKeyword */ || token() === 88 /* FunctionKeyword */ || + (token() === 119 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -13953,9 +14007,9 @@ var ts; // we're parsing. For example, if we have a semicolon in the middle of a class, then // we really don't want to assume the class is over and we're on a statement in the // outer module. We just want to consume and move on. - return !(token() === 23 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); + return !(token() === 24 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); case 2 /* SwitchClauses */: - return token() === 71 /* CaseKeyword */ || token() === 77 /* DefaultKeyword */; + return token() === 72 /* CaseKeyword */ || token() === 78 /* DefaultKeyword */; case 4 /* TypeMembers */: return lookAhead(isTypeMemberStart); case 5 /* ClassMembers */: @@ -13963,19 +14017,19 @@ var ts; // not in error recovery. If we're in error recovery, we don't want an errant // semicolon to be treated as a class member (since they're almost always used // for statements. - return lookAhead(isClassMemberStart) || (token() === 23 /* SemicolonToken */ && !inErrorRecovery); + return lookAhead(isClassMemberStart) || (token() === 24 /* SemicolonToken */ && !inErrorRecovery); case 6 /* EnumMembers */: // Include open bracket computed properties. This technically also lets in indexers, // which would be a candidate for improved error reporting. - return token() === 19 /* OpenBracketToken */ || isLiteralPropertyName(); + return token() === 20 /* OpenBracketToken */ || isLiteralPropertyName(); case 12 /* ObjectLiteralMembers */: - return token() === 19 /* OpenBracketToken */ || token() === 37 /* AsteriskToken */ || isLiteralPropertyName(); + return token() === 20 /* OpenBracketToken */ || token() === 38 /* AsteriskToken */ || isLiteralPropertyName(); case 9 /* ObjectBindingElements */: - return token() === 19 /* OpenBracketToken */ || isLiteralPropertyName(); + return token() === 20 /* OpenBracketToken */ || isLiteralPropertyName(); case 7 /* HeritageClauseElement */: // If we see { } then only consume it as an expression if it is followed by , or { // That way we won't consume the body of a class in its heritage clause. - if (token() === 15 /* OpenBraceToken */) { + if (token() === 16 /* OpenBraceToken */) { return lookAhead(isValidHeritageClauseObjectLiteral); } if (!inErrorRecovery) { @@ -13990,23 +14044,23 @@ var ts; case 8 /* VariableDeclarations */: return isIdentifierOrPattern(); case 10 /* ArrayBindingElements */: - return token() === 24 /* CommaToken */ || token() === 22 /* DotDotDotToken */ || isIdentifierOrPattern(); + return token() === 25 /* CommaToken */ || token() === 23 /* DotDotDotToken */ || isIdentifierOrPattern(); case 17 /* TypeParameters */: return isIdentifier(); case 11 /* ArgumentExpressions */: case 15 /* ArrayLiteralMembers */: - return token() === 24 /* CommaToken */ || token() === 22 /* DotDotDotToken */ || isStartOfExpression(); + return token() === 25 /* CommaToken */ || token() === 23 /* DotDotDotToken */ || isStartOfExpression(); case 16 /* Parameters */: return isStartOfParameter(); case 18 /* TypeArguments */: case 19 /* TupleElementTypes */: - return token() === 24 /* CommaToken */ || isStartOfType(); + return token() === 25 /* CommaToken */ || isStartOfType(); case 20 /* HeritageClauses */: return isHeritageClause(); case 21 /* ImportOrExportSpecifiers */: return ts.tokenIsIdentifierOrKeyword(token()); case 13 /* JsxAttributes */: - return ts.tokenIsIdentifierOrKeyword(token()) || token() === 15 /* OpenBraceToken */; + return ts.tokenIsIdentifierOrKeyword(token()) || token() === 16 /* OpenBraceToken */; case 14 /* JsxChildren */: return true; case 22 /* JSDocFunctionParameters */: @@ -14019,8 +14073,8 @@ var ts; ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token() === 15 /* OpenBraceToken */); - if (nextToken() === 16 /* CloseBraceToken */) { + ts.Debug.assert(token() === 16 /* OpenBraceToken */); + if (nextToken() === 17 /* CloseBraceToken */) { // if we see "extends {}" then only treat the {} as what we're extending (and not // the class body) if we have: // @@ -14029,7 +14083,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 24 /* CommaToken */ || next === 15 /* OpenBraceToken */ || next === 83 /* ExtendsKeyword */ || next === 106 /* ImplementsKeyword */; + return next === 25 /* CommaToken */ || next === 16 /* OpenBraceToken */ || next === 84 /* ExtendsKeyword */ || next === 107 /* ImplementsKeyword */; } return true; } @@ -14042,8 +14096,8 @@ var ts; return ts.tokenIsIdentifierOrKeyword(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 106 /* ImplementsKeyword */ || - token() === 83 /* ExtendsKeyword */) { + if (token() === 107 /* ImplementsKeyword */ || + token() === 84 /* ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -14067,43 +14121,43 @@ var ts; case 12 /* ObjectLiteralMembers */: case 9 /* ObjectBindingElements */: case 21 /* ImportOrExportSpecifiers */: - return token() === 16 /* CloseBraceToken */; + return token() === 17 /* CloseBraceToken */; case 3 /* SwitchClauseStatements */: - return token() === 16 /* CloseBraceToken */ || token() === 71 /* CaseKeyword */ || token() === 77 /* DefaultKeyword */; + return token() === 17 /* CloseBraceToken */ || token() === 72 /* CaseKeyword */ || token() === 78 /* DefaultKeyword */; case 7 /* HeritageClauseElement */: - return token() === 15 /* OpenBraceToken */ || token() === 83 /* ExtendsKeyword */ || token() === 106 /* ImplementsKeyword */; + return token() === 16 /* OpenBraceToken */ || token() === 84 /* ExtendsKeyword */ || token() === 107 /* 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() === 83 /* ExtendsKeyword */ || token() === 106 /* ImplementsKeyword */; + return token() === 28 /* GreaterThanToken */ || token() === 18 /* OpenParenToken */ || token() === 16 /* OpenBraceToken */ || token() === 84 /* ExtendsKeyword */ || token() === 107 /* ImplementsKeyword */; case 11 /* ArgumentExpressions */: // Tokens other than ')' are here for better error recovery - return token() === 18 /* CloseParenToken */ || token() === 23 /* SemicolonToken */; + return token() === 19 /* CloseParenToken */ || token() === 24 /* SemicolonToken */; case 15 /* ArrayLiteralMembers */: case 19 /* TupleElementTypes */: case 10 /* ArrayBindingElements */: - return token() === 20 /* CloseBracketToken */; + return token() === 21 /* CloseBracketToken */; case 16 /* Parameters */: // Tokens other than ')' and ']' (the latter for index signatures) are here for better error recovery - return token() === 18 /* CloseParenToken */ || token() === 20 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; + return token() === 19 /* CloseParenToken */ || token() === 21 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; case 18 /* TypeArguments */: // All other tokens should cause the type-argument to terminate except comma token - return token() !== 24 /* CommaToken */; + return token() !== 25 /* CommaToken */; case 20 /* HeritageClauses */: - return token() === 15 /* OpenBraceToken */ || token() === 16 /* CloseBraceToken */; + return token() === 16 /* OpenBraceToken */ || token() === 17 /* CloseBraceToken */; case 13 /* JsxAttributes */: - return token() === 27 /* GreaterThanToken */ || token() === 39 /* SlashToken */; + return token() === 28 /* GreaterThanToken */ || token() === 40 /* SlashToken */; case 14 /* JsxChildren */: - return token() === 25 /* LessThanToken */ && lookAhead(nextTokenIsSlash); + return token() === 26 /* LessThanToken */ && lookAhead(nextTokenIsSlash); case 22 /* JSDocFunctionParameters */: - return token() === 18 /* CloseParenToken */ || token() === 54 /* ColonToken */ || token() === 16 /* CloseBraceToken */; + return token() === 19 /* CloseParenToken */ || token() === 55 /* ColonToken */ || token() === 17 /* CloseBraceToken */; case 23 /* JSDocTypeArguments */: - return token() === 27 /* GreaterThanToken */ || token() === 16 /* CloseBraceToken */; + return token() === 28 /* GreaterThanToken */ || token() === 17 /* CloseBraceToken */; case 25 /* JSDocTupleTypes */: - return token() === 20 /* CloseBracketToken */ || token() === 16 /* CloseBraceToken */; + return token() === 21 /* CloseBracketToken */ || token() === 17 /* CloseBraceToken */; case 24 /* JSDocRecordMembers */: - return token() === 16 /* CloseBraceToken */; + return token() === 17 /* CloseBraceToken */; } } function isVariableDeclaratorListTerminator() { @@ -14121,7 +14175,7 @@ var ts; // For better error recovery, if we see an '=>' then we just stop immediately. We've got an // arrow function here and it's going to be very unlikely that we'll resynchronize and get // another variable declaration. - if (token() === 34 /* EqualsGreaterThanToken */) { + if (token() === 35 /* EqualsGreaterThanToken */) { return true; } // Keep trying to parse out variable declarators. @@ -14284,20 +14338,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 148 /* Constructor */: - case 153 /* IndexSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 145 /* PropertyDeclaration */: - case 198 /* SemicolonClassElement */: + case 149 /* Constructor */: + case 154 /* IndexSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 146 /* PropertyDeclaration */: + case 199 /* SemicolonClassElement */: return true; - case 147 /* MethodDeclaration */: + case 148 /* 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 === 69 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 121 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 70 /* Identifier */ && + methodDeclaration.name.originalKeywordKind === 122 /* ConstructorKeyword */; return !nameIsConstructor; } } @@ -14316,35 +14370,35 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 220 /* FunctionDeclaration */: - case 200 /* VariableStatement */: - case 199 /* Block */: - case 203 /* IfStatement */: - case 202 /* ExpressionStatement */: - case 215 /* ThrowStatement */: - case 211 /* ReturnStatement */: - case 213 /* SwitchStatement */: - case 210 /* BreakStatement */: - case 209 /* ContinueStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: - case 206 /* ForStatement */: - case 205 /* WhileStatement */: - case 212 /* WithStatement */: - case 201 /* EmptyStatement */: - case 216 /* TryStatement */: - case 214 /* LabeledStatement */: - case 204 /* DoStatement */: - case 217 /* DebuggerStatement */: - case 230 /* ImportDeclaration */: - case 229 /* ImportEqualsDeclaration */: - case 236 /* ExportDeclaration */: - case 235 /* ExportAssignment */: - case 225 /* ModuleDeclaration */: - case 221 /* ClassDeclaration */: - case 222 /* InterfaceDeclaration */: - case 224 /* EnumDeclaration */: - case 223 /* TypeAliasDeclaration */: + case 221 /* FunctionDeclaration */: + case 201 /* VariableStatement */: + case 200 /* Block */: + case 204 /* IfStatement */: + case 203 /* ExpressionStatement */: + case 216 /* ThrowStatement */: + case 212 /* ReturnStatement */: + case 214 /* SwitchStatement */: + case 211 /* BreakStatement */: + case 210 /* ContinueStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: + case 207 /* ForStatement */: + case 206 /* WhileStatement */: + case 213 /* WithStatement */: + case 202 /* EmptyStatement */: + case 217 /* TryStatement */: + case 215 /* LabeledStatement */: + case 205 /* DoStatement */: + case 218 /* DebuggerStatement */: + case 231 /* ImportDeclaration */: + case 230 /* ImportEqualsDeclaration */: + case 237 /* ExportDeclaration */: + case 236 /* ExportAssignment */: + case 226 /* ModuleDeclaration */: + case 222 /* ClassDeclaration */: + case 223 /* InterfaceDeclaration */: + case 225 /* EnumDeclaration */: + case 224 /* TypeAliasDeclaration */: return true; } } @@ -14356,18 +14410,18 @@ var ts; function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 152 /* ConstructSignature */: - case 146 /* MethodSignature */: - case 153 /* IndexSignature */: - case 144 /* PropertySignature */: - case 151 /* CallSignature */: + case 153 /* ConstructSignature */: + case 147 /* MethodSignature */: + case 154 /* IndexSignature */: + case 145 /* PropertySignature */: + case 152 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 218 /* VariableDeclaration */) { + if (node.kind !== 219 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -14388,7 +14442,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 142 /* Parameter */) { + if (node.kind !== 143 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -14445,7 +14499,7 @@ var ts; if (isListElement(kind, /*inErrorRecovery*/ false)) { result.push(parseListElement(kind, parseElement)); commaStart = scanner.getTokenPos(); - if (parseOptional(24 /* CommaToken */)) { + if (parseOptional(25 /* CommaToken */)) { continue; } commaStart = -1; // Back to the state where the last token was not a comma @@ -14454,13 +14508,13 @@ var ts; } // We didn't get a comma, and the list wasn't terminated, explicitly parse // out a comma so we give a good error message. - parseExpected(24 /* CommaToken */); + parseExpected(25 /* CommaToken */); // If the token was a semicolon, and the caller allows that, then skip it and // continue. This ensures we get back on track and don't result in tons of // parse errors. For example, this can happen when people do things like use // a semicolon to delimit object literal members. Note: we'll have already // reported an error when we called parseExpected above. - if (considerSemicolonAsDelimiter && token() === 23 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { + if (considerSemicolonAsDelimiter && token() === 24 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); } continue; @@ -14499,8 +14553,8 @@ var ts; // The allowReservedWords parameter controls whether reserved words are permitted after the first dot function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); - while (parseOptional(21 /* DotToken */)) { - var node = createNode(139 /* QualifiedName */, entity.pos); // !!! + while (parseOptional(22 /* DotToken */)) { + var node = createNode(140 /* QualifiedName */, entity.pos); // !!! node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -14533,33 +14587,33 @@ 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(69 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return createMissingNode(70 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(189 /* TemplateExpression */); + var template = createNode(190 /* TemplateExpression */); template.head = parseTemplateHead(); - ts.Debug.assert(template.head.kind === 12 /* TemplateHead */, "Template head has wrong token kind"); + ts.Debug.assert(template.head.kind === 13 /* TemplateHead */, "Template head has wrong token kind"); var templateSpans = createNodeArray(); do { templateSpans.push(parseTemplateSpan()); - } while (ts.lastOrUndefined(templateSpans).literal.kind === 13 /* TemplateMiddle */); + } while (ts.lastOrUndefined(templateSpans).literal.kind === 14 /* TemplateMiddle */); templateSpans.end = getNodeEnd(); template.templateSpans = templateSpans; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(197 /* TemplateSpan */); + var span = createNode(198 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; - if (token() === 16 /* CloseBraceToken */) { + if (token() === 17 /* CloseBraceToken */) { reScanTemplateToken(); literal = parseTemplateMiddleOrTemplateTail(); } else { - literal = parseExpectedToken(14 /* TemplateTail */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(16 /* CloseBraceToken */)); + literal = parseExpectedToken(15 /* TemplateTail */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(17 /* CloseBraceToken */)); } span.literal = literal; return finishNode(span); @@ -14569,12 +14623,12 @@ var ts; } function parseTemplateHead() { var fragment = parseLiteralLikeNode(token(), /*internName*/ false); - ts.Debug.assert(fragment.kind === 12 /* TemplateHead */, "Template head has wrong token kind"); + ts.Debug.assert(fragment.kind === 13 /* TemplateHead */, "Template head has wrong token kind"); return fragment; } function parseTemplateMiddleOrTemplateTail() { var fragment = parseLiteralLikeNode(token(), /*internName*/ false); - ts.Debug.assert(fragment.kind === 13 /* TemplateMiddle */ || fragment.kind === 14 /* TemplateTail */, "Template fragment has wrong token kind"); + ts.Debug.assert(fragment.kind === 14 /* TemplateMiddle */ || fragment.kind === 15 /* TemplateTail */, "Template fragment has wrong token kind"); return fragment; } function parseLiteralLikeNode(kind, internName) { @@ -14606,35 +14660,35 @@ var ts; // TYPES function parseTypeReference() { var typeName = parseEntityName(/*allowReservedWords*/ false, ts.Diagnostics.Type_expected); - var node = createNode(155 /* TypeReference */, typeName.pos); + var node = createNode(156 /* TypeReference */, typeName.pos); node.typeName = typeName; - if (!scanner.hasPrecedingLineBreak() && token() === 25 /* LessThanToken */) { - node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); + if (!scanner.hasPrecedingLineBreak() && token() === 26 /* LessThanToken */) { + node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 26 /* LessThanToken */, 28 /* GreaterThanToken */); } return finishNode(node); } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(154 /* TypePredicate */, lhs.pos); + var node = createNode(155 /* TypePredicate */, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(165 /* ThisType */); + var node = createNode(166 /* ThisType */); nextToken(); return finishNode(node); } function parseTypeQuery() { - var node = createNode(158 /* TypeQuery */); - parseExpected(101 /* TypeOfKeyword */); + var node = createNode(159 /* TypeQuery */); + parseExpected(102 /* TypeOfKeyword */); node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(141 /* TypeParameter */); + var node = createNode(142 /* TypeParameter */); node.name = parseIdentifier(); - if (parseOptional(83 /* ExtendsKeyword */)) { + if (parseOptional(84 /* 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 @@ -14656,29 +14710,29 @@ var ts; return finishNode(node); } function parseTypeParameters() { - if (token() === 25 /* LessThanToken */) { - return parseBracketedList(17 /* TypeParameters */, parseTypeParameter, 25 /* LessThanToken */, 27 /* GreaterThanToken */); + if (token() === 26 /* LessThanToken */) { + return parseBracketedList(17 /* TypeParameters */, parseTypeParameter, 26 /* LessThanToken */, 28 /* GreaterThanToken */); } } function parseParameterType() { - if (parseOptional(54 /* ColonToken */)) { + if (parseOptional(55 /* ColonToken */)) { return parseType(); } return undefined; } function isStartOfParameter() { - return token() === 22 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifierKind(token()) || token() === 55 /* AtToken */ || token() === 97 /* ThisKeyword */; + return token() === 23 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifierKind(token()) || token() === 56 /* AtToken */ || token() === 98 /* ThisKeyword */; } function parseParameter() { - var node = createNode(142 /* Parameter */); - if (token() === 97 /* ThisKeyword */) { + var node = createNode(143 /* Parameter */); + if (token() === 98 /* ThisKeyword */) { node.name = createIdentifier(/*isIdentifier*/ true, undefined); node.type = parseParameterType(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); + node.dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); // FormalParameter [Yield,Await]: // BindingElement[?Yield,?Await] node.name = parseIdentifierOrPattern(); @@ -14693,7 +14747,7 @@ var ts; // to avoid this we'll advance cursor to the next token. nextToken(); } - node.questionToken = parseOptionalToken(53 /* QuestionToken */); + node.questionToken = parseOptionalToken(54 /* QuestionToken */); node.type = parseParameterType(); node.initializer = parseBindingElementInitializer(/*inParameter*/ true); // Do not check for initializers in an ambient context for parameters. This is not @@ -14713,7 +14767,7 @@ var ts; return parseInitializer(/*inParameter*/ true); } function fillSignature(returnToken, yieldContext, awaitContext, requireCompleteParameterList, signature) { - var returnTokenRequired = returnToken === 34 /* EqualsGreaterThanToken */; + var returnTokenRequired = returnToken === 35 /* EqualsGreaterThanToken */; signature.typeParameters = parseTypeParameters(); signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); if (returnTokenRequired) { @@ -14738,7 +14792,7 @@ var ts; // // SingleNameBinding [Yield,Await]: // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt - if (parseExpected(17 /* OpenParenToken */)) { + if (parseExpected(18 /* OpenParenToken */)) { var savedYieldContext = inYieldContext(); var savedAwaitContext = inAwaitContext(); setYieldContext(yieldContext); @@ -14746,7 +14800,7 @@ var ts; var result = parseDelimitedList(16 /* Parameters */, parseParameter); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); - if (!parseExpected(18 /* CloseParenToken */) && requireCompleteParameterList) { + if (!parseExpected(19 /* CloseParenToken */) && requireCompleteParameterList) { // Caller insisted that we had to end with a ) We didn't. So just return // undefined here. return undefined; @@ -14761,7 +14815,7 @@ var ts; function parseTypeMemberSemicolon() { // We allow type members to be separated by commas or (possibly ASI) semicolons. // First check if it was a comma. If so, we're done with the member. - if (parseOptional(24 /* CommaToken */)) { + if (parseOptional(25 /* CommaToken */)) { return; } // Didn't have a comma. We must have a (possible ASI) semicolon. @@ -14769,15 +14823,15 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 152 /* ConstructSignature */) { - parseExpected(92 /* NewKeyword */); + if (kind === 153 /* ConstructSignature */) { + parseExpected(93 /* NewKeyword */); } - fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + fillSignature(55 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); parseTypeMemberSemicolon(); return addJSDocComment(finishNode(node)); } function isIndexSignature() { - if (token() !== 19 /* OpenBracketToken */) { + if (token() !== 20 /* OpenBracketToken */) { return false; } return lookAhead(isUnambiguouslyIndexSignature); @@ -14800,7 +14854,7 @@ var ts; // [] // nextToken(); - if (token() === 22 /* DotDotDotToken */ || token() === 20 /* CloseBracketToken */) { + if (token() === 23 /* DotDotDotToken */ || token() === 21 /* CloseBracketToken */) { return true; } if (ts.isModifierKind(token())) { @@ -14819,49 +14873,49 @@ 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() === 54 /* ColonToken */ || token() === 24 /* CommaToken */) { + if (token() === 55 /* ColonToken */ || token() === 25 /* 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() !== 53 /* QuestionToken */) { + if (token() !== 54 /* 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() === 54 /* ColonToken */ || token() === 24 /* CommaToken */ || token() === 20 /* CloseBracketToken */; + return token() === 55 /* ColonToken */ || token() === 25 /* CommaToken */ || token() === 21 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(153 /* IndexSignature */, fullStart); + var node = createNode(154 /* IndexSignature */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); + node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 20 /* OpenBracketToken */, 21 /* CloseBracketToken */); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); return finishNode(node); } function parsePropertyOrMethodSignature(fullStart, modifiers) { var name = parsePropertyName(); - var questionToken = parseOptionalToken(53 /* QuestionToken */); - if (token() === 17 /* OpenParenToken */ || token() === 25 /* LessThanToken */) { - var method = createNode(146 /* MethodSignature */, fullStart); + var questionToken = parseOptionalToken(54 /* QuestionToken */); + if (token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */) { + var method = createNode(147 /* MethodSignature */, fullStart); method.modifiers = modifiers; method.name = name; method.questionToken = questionToken; // Method signatures don't exist in expression contexts. So they have neither // [Yield] nor [Await] - fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, method); + fillSignature(55 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, method); parseTypeMemberSemicolon(); return addJSDocComment(finishNode(method)); } else { - var property = createNode(144 /* PropertySignature */, fullStart); + var property = createNode(145 /* PropertySignature */, fullStart); property.modifiers = modifiers; property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); - if (token() === 56 /* EqualsToken */) { + if (token() === 57 /* EqualsToken */) { // Although type literal properties cannot not have initializers, we attempt // to parse an initializer so we can report in the checker that an interface // property or type literal property cannot have an initializer. @@ -14874,7 +14928,7 @@ var ts; function isTypeMemberStart() { var idToken; // Return true if we have the start of a signature member - if (token() === 17 /* OpenParenToken */ || token() === 25 /* LessThanToken */) { + if (token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier @@ -14883,7 +14937,7 @@ var ts; nextToken(); } // Index signatures and computed property names are type members - if (token() === 19 /* OpenBracketToken */) { + if (token() === 20 /* OpenBracketToken */) { return true; } // Try to get the first property-like token following all modifiers @@ -14894,21 +14948,21 @@ var ts; // If we were able to get any potential identifier, check that it is // the start of a member declaration if (idToken) { - return token() === 17 /* OpenParenToken */ || - token() === 25 /* LessThanToken */ || - token() === 53 /* QuestionToken */ || - token() === 54 /* ColonToken */ || - token() === 24 /* CommaToken */ || + return token() === 18 /* OpenParenToken */ || + token() === 26 /* LessThanToken */ || + token() === 54 /* QuestionToken */ || + token() === 55 /* ColonToken */ || + token() === 25 /* CommaToken */ || canParseSemicolon(); } return false; } function parseTypeMember() { - if (token() === 17 /* OpenParenToken */ || token() === 25 /* LessThanToken */) { - return parseSignatureMember(151 /* CallSignature */); + if (token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */) { + return parseSignatureMember(152 /* CallSignature */); } - if (token() === 92 /* NewKeyword */ && lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(152 /* ConstructSignature */); + if (token() === 93 /* NewKeyword */ && lookAhead(isStartOfConstructSignature)) { + return parseSignatureMember(153 /* ConstructSignature */); } var fullStart = getNodePos(); var modifiers = parseModifiers(); @@ -14919,18 +14973,18 @@ var ts; } function isStartOfConstructSignature() { nextToken(); - return token() === 17 /* OpenParenToken */ || token() === 25 /* LessThanToken */; + return token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */; } function parseTypeLiteral() { - var node = createNode(159 /* TypeLiteral */); + var node = createNode(160 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseObjectTypeMembers() { var members; - if (parseExpected(15 /* OpenBraceToken */)) { + if (parseExpected(16 /* OpenBraceToken */)) { members = parseList(4 /* TypeMembers */, parseTypeMember); - parseExpected(16 /* CloseBraceToken */); + parseExpected(17 /* CloseBraceToken */); } else { members = createMissingList(); @@ -14938,31 +14992,31 @@ var ts; return members; } function parseTupleType() { - var node = createNode(161 /* TupleType */); - node.elementTypes = parseBracketedList(19 /* TupleElementTypes */, parseType, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); + var node = createNode(162 /* TupleType */); + node.elementTypes = parseBracketedList(19 /* TupleElementTypes */, parseType, 20 /* OpenBracketToken */, 21 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(164 /* ParenthesizedType */); - parseExpected(17 /* OpenParenToken */); + var node = createNode(165 /* ParenthesizedType */); + parseExpected(18 /* OpenParenToken */); node.type = parseType(); - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); return finishNode(node); } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 157 /* ConstructorType */) { - parseExpected(92 /* NewKeyword */); + if (kind === 158 /* ConstructorType */) { + parseExpected(93 /* NewKeyword */); } - fillSignature(34 /* EqualsGreaterThanToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + fillSignature(35 /* EqualsGreaterThanToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); return finishNode(node); } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token() === 21 /* DotToken */ ? undefined : node; + return token() === 22 /* DotToken */ ? undefined : node; } function parseLiteralTypeNode() { - var node = createNode(166 /* LiteralType */); + var node = createNode(167 /* LiteralType */); node.literal = parseSimpleUnaryExpression(); finishNode(node); return node; @@ -14972,42 +15026,42 @@ var ts; } function parseNonArrayType() { switch (token()) { - case 117 /* AnyKeyword */: - case 132 /* StringKeyword */: - case 130 /* NumberKeyword */: - case 120 /* BooleanKeyword */: - case 133 /* SymbolKeyword */: - case 135 /* UndefinedKeyword */: - case 127 /* NeverKeyword */: + case 118 /* AnyKeyword */: + case 133 /* StringKeyword */: + case 131 /* NumberKeyword */: + case 121 /* BooleanKeyword */: + case 134 /* SymbolKeyword */: + case 136 /* UndefinedKeyword */: + case 128 /* NeverKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: + case 100 /* TrueKeyword */: + case 85 /* FalseKeyword */: return parseLiteralTypeNode(); - case 36 /* MinusToken */: + case 37 /* MinusToken */: return lookAhead(nextTokenIsNumericLiteral) ? parseLiteralTypeNode() : parseTypeReference(); - case 103 /* VoidKeyword */: - case 93 /* NullKeyword */: + case 104 /* VoidKeyword */: + case 94 /* NullKeyword */: return parseTokenNode(); - case 97 /* ThisKeyword */: { + case 98 /* ThisKeyword */: { var thisKeyword = parseThisTypeNode(); - if (token() === 124 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 125 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 101 /* TypeOfKeyword */: + case 102 /* TypeOfKeyword */: return parseTypeQuery(); - case 15 /* OpenBraceToken */: + case 16 /* OpenBraceToken */: return parseTypeLiteral(); - case 19 /* OpenBracketToken */: + case 20 /* OpenBracketToken */: return parseTupleType(); - case 17 /* OpenParenToken */: + case 18 /* OpenParenToken */: return parseParenthesizedType(); default: return parseTypeReference(); @@ -15015,29 +15069,29 @@ var ts; } function isStartOfType() { switch (token()) { - case 117 /* AnyKeyword */: - case 132 /* StringKeyword */: - case 130 /* NumberKeyword */: - case 120 /* BooleanKeyword */: - case 133 /* SymbolKeyword */: - case 103 /* VoidKeyword */: - case 135 /* UndefinedKeyword */: - case 93 /* NullKeyword */: - case 97 /* ThisKeyword */: - case 101 /* TypeOfKeyword */: - case 127 /* NeverKeyword */: - case 15 /* OpenBraceToken */: - case 19 /* OpenBracketToken */: - case 25 /* LessThanToken */: - case 92 /* NewKeyword */: + case 118 /* AnyKeyword */: + case 133 /* StringKeyword */: + case 131 /* NumberKeyword */: + case 121 /* BooleanKeyword */: + case 134 /* SymbolKeyword */: + case 104 /* VoidKeyword */: + case 136 /* UndefinedKeyword */: + case 94 /* NullKeyword */: + case 98 /* ThisKeyword */: + case 102 /* TypeOfKeyword */: + case 128 /* NeverKeyword */: + case 16 /* OpenBraceToken */: + case 20 /* OpenBracketToken */: + case 26 /* LessThanToken */: + case 93 /* NewKeyword */: case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: + case 100 /* TrueKeyword */: + case 85 /* FalseKeyword */: return true; - case 36 /* MinusToken */: + case 37 /* MinusToken */: return lookAhead(nextTokenIsNumericLiteral); - case 17 /* OpenParenToken */: + case 18 /* OpenParenToken */: // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, // or something that starts a type. We don't want to consider things like '(1)' a type. return lookAhead(isStartOfParenthesizedOrFunctionType); @@ -15047,13 +15101,13 @@ var ts; } function isStartOfParenthesizedOrFunctionType() { nextToken(); - return token() === 18 /* CloseParenToken */ || isStartOfParameter() || isStartOfType(); + return token() === 19 /* CloseParenToken */ || isStartOfParameter() || isStartOfType(); } function parseArrayTypeOrHigher() { var type = parseNonArrayType(); - while (!scanner.hasPrecedingLineBreak() && parseOptional(19 /* OpenBracketToken */)) { - parseExpected(20 /* CloseBracketToken */); - var node = createNode(160 /* ArrayType */, type.pos); + while (!scanner.hasPrecedingLineBreak() && parseOptional(20 /* OpenBracketToken */)) { + parseExpected(21 /* CloseBracketToken */); + var node = createNode(161 /* ArrayType */, type.pos); node.elementType = type; type = finishNode(node); } @@ -15074,27 +15128,27 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(163 /* IntersectionType */, parseArrayTypeOrHigher, 46 /* AmpersandToken */); + return parseUnionOrIntersectionType(164 /* IntersectionType */, parseArrayTypeOrHigher, 47 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(162 /* UnionType */, parseIntersectionTypeOrHigher, 47 /* BarToken */); + return parseUnionOrIntersectionType(163 /* UnionType */, parseIntersectionTypeOrHigher, 48 /* BarToken */); } function isStartOfFunctionType() { - if (token() === 25 /* LessThanToken */) { + if (token() === 26 /* LessThanToken */) { return true; } - return token() === 17 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); + return token() === 18 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); } function skipParameterStart() { if (ts.isModifierKind(token())) { // Skip modifiers parseModifiers(); } - if (isIdentifier() || token() === 97 /* ThisKeyword */) { + if (isIdentifier() || token() === 98 /* ThisKeyword */) { nextToken(); return true; } - if (token() === 19 /* OpenBracketToken */ || token() === 15 /* OpenBraceToken */) { + if (token() === 20 /* OpenBracketToken */ || token() === 16 /* OpenBraceToken */) { // Return true if we can parse an array or object binding pattern with no errors var previousErrorCount = parseDiagnostics.length; parseIdentifierOrPattern(); @@ -15104,7 +15158,7 @@ var ts; } function isUnambiguouslyStartOfFunctionType() { nextToken(); - if (token() === 18 /* CloseParenToken */ || token() === 22 /* DotDotDotToken */) { + if (token() === 19 /* CloseParenToken */ || token() === 23 /* DotDotDotToken */) { // ( ) // ( ... return true; @@ -15112,17 +15166,17 @@ var ts; if (skipParameterStart()) { // We successfully skipped modifiers (if any) and an identifier or binding pattern, // now see if we have something that indicates a parameter declaration - if (token() === 54 /* ColonToken */ || token() === 24 /* CommaToken */ || - token() === 53 /* QuestionToken */ || token() === 56 /* EqualsToken */) { + if (token() === 55 /* ColonToken */ || token() === 25 /* CommaToken */ || + token() === 54 /* QuestionToken */ || token() === 57 /* EqualsToken */) { // ( xxx : // ( xxx , // ( xxx ? // ( xxx = return true; } - if (token() === 18 /* CloseParenToken */) { + if (token() === 19 /* CloseParenToken */) { nextToken(); - if (token() === 34 /* EqualsGreaterThanToken */) { + if (token() === 35 /* EqualsGreaterThanToken */) { // ( xxx ) => return true; } @@ -15134,7 +15188,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(154 /* TypePredicate */, typePredicateVariable.pos); + var node = createNode(155 /* TypePredicate */, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -15145,7 +15199,7 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 124 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 125 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } @@ -15157,37 +15211,37 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(156 /* FunctionType */); + return parseFunctionOrConstructorType(157 /* FunctionType */); } - if (token() === 92 /* NewKeyword */) { - return parseFunctionOrConstructorType(157 /* ConstructorType */); + if (token() === 93 /* NewKeyword */) { + return parseFunctionOrConstructorType(158 /* ConstructorType */); } return parseUnionTypeOrHigher(); } function parseTypeAnnotation() { - return parseOptional(54 /* ColonToken */) ? parseType() : undefined; + return parseOptional(55 /* ColonToken */) ? parseType() : undefined; } // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token()) { - case 97 /* ThisKeyword */: - case 95 /* SuperKeyword */: - case 93 /* NullKeyword */: - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: + case 98 /* ThisKeyword */: + case 96 /* SuperKeyword */: + case 94 /* NullKeyword */: + case 100 /* TrueKeyword */: + case 85 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: - case 11 /* NoSubstitutionTemplateLiteral */: - case 12 /* TemplateHead */: - case 17 /* OpenParenToken */: - case 19 /* OpenBracketToken */: - case 15 /* OpenBraceToken */: - case 87 /* FunctionKeyword */: - case 73 /* ClassKeyword */: - case 92 /* NewKeyword */: - case 39 /* SlashToken */: - case 61 /* SlashEqualsToken */: - case 69 /* Identifier */: + case 12 /* NoSubstitutionTemplateLiteral */: + case 13 /* TemplateHead */: + case 18 /* OpenParenToken */: + case 20 /* OpenBracketToken */: + case 16 /* OpenBraceToken */: + case 88 /* FunctionKeyword */: + case 74 /* ClassKeyword */: + case 93 /* NewKeyword */: + case 40 /* SlashToken */: + case 62 /* SlashEqualsToken */: + case 70 /* Identifier */: return true; default: return isIdentifier(); @@ -15198,18 +15252,18 @@ var ts; return true; } switch (token()) { - case 35 /* PlusToken */: - case 36 /* MinusToken */: - 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 119 /* AwaitKeyword */: - case 114 /* YieldKeyword */: + case 36 /* PlusToken */: + case 37 /* MinusToken */: + case 51 /* TildeToken */: + case 50 /* ExclamationToken */: + case 79 /* DeleteKeyword */: + case 102 /* TypeOfKeyword */: + case 104 /* VoidKeyword */: + case 42 /* PlusPlusToken */: + case 43 /* MinusMinusToken */: + case 26 /* LessThanToken */: + case 120 /* AwaitKeyword */: + case 115 /* 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. @@ -15227,10 +15281,10 @@ var ts; } function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. - return token() !== 15 /* OpenBraceToken */ && - token() !== 87 /* FunctionKeyword */ && - token() !== 73 /* ClassKeyword */ && - token() !== 55 /* AtToken */ && + return token() !== 16 /* OpenBraceToken */ && + token() !== 88 /* FunctionKeyword */ && + token() !== 74 /* ClassKeyword */ && + token() !== 56 /* AtToken */ && isStartOfExpression(); } function parseExpression() { @@ -15244,7 +15298,7 @@ var ts; } var expr = parseAssignmentExpressionOrHigher(); var operatorToken; - while ((operatorToken = parseOptionalToken(24 /* CommaToken */))) { + while ((operatorToken = parseOptionalToken(25 /* CommaToken */))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); } if (saveDecoratorContext) { @@ -15253,7 +15307,7 @@ var ts; return expr; } function parseInitializer(inParameter) { - if (token() !== 56 /* EqualsToken */) { + if (token() !== 57 /* 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. @@ -15262,7 +15316,7 @@ var ts; // it's more likely that a { would be a allowed (as an object literal). While this // is also allowed for parameters, the risk is that we consume the { as an object // literal when it really will be for the block following the parameter. - if (scanner.hasPrecedingLineBreak() || (inParameter && token() === 15 /* OpenBraceToken */) || !isStartOfExpression()) { + if (scanner.hasPrecedingLineBreak() || (inParameter && token() === 16 /* OpenBraceToken */) || !isStartOfExpression()) { // preceding line break, open brace in a parameter (likely a function body) or current token is not an expression - // do not try to parse initializer return undefined; @@ -15270,7 +15324,7 @@ var ts; } // Initializer[In, Yield] : // = AssignmentExpression[?In, ?Yield] - parseExpected(56 /* EqualsToken */); + parseExpected(57 /* EqualsToken */); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { @@ -15316,7 +15370,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 === 69 /* Identifier */ && token() === 34 /* EqualsGreaterThanToken */) { + if (expr.kind === 70 /* Identifier */ && token() === 35 /* EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(expr); } // Now see if we might be in cases '2' or '3'. @@ -15332,7 +15386,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token() === 114 /* YieldKeyword */) { + if (token() === 115 /* YieldKeyword */) { // If we have a 'yield' keyword, and this is a context where yield expressions are // allowed, then definitely parse out a yield expression. if (inYieldContext()) { @@ -15361,15 +15415,15 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(190 /* YieldExpression */); + var node = createNode(191 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] // yield [no LineTerminator here] * [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token() === 37 /* AsteriskToken */ || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); + (token() === 38 /* AsteriskToken */ || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(38 /* AsteriskToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -15380,21 +15434,21 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier, asyncModifier) { - ts.Debug.assert(token() === 34 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + ts.Debug.assert(token() === 35 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(180 /* ArrowFunction */, asyncModifier.pos); + node = createNode(181 /* ArrowFunction */, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(180 /* ArrowFunction */, identifier.pos); + node = createNode(181 /* ArrowFunction */, identifier.pos); } - var parameter = createNode(142 /* Parameter */, identifier.pos); + var parameter = createNode(143 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos); node.parameters.end = parameter.end; - node.equalsGreaterThanToken = parseExpectedToken(34 /* EqualsGreaterThanToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, "=>"); + node.equalsGreaterThanToken = parseExpectedToken(35 /* EqualsGreaterThanToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, "=>"); node.body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier); return addJSDocComment(finishNode(node)); } @@ -15419,8 +15473,8 @@ var ts; // If we have an arrow, then try to parse the body. Even if not, try to parse if we // have an opening brace, just in case we're in an error state. var lastToken = token(); - arrowFunction.equalsGreaterThanToken = parseExpectedToken(34 /* EqualsGreaterThanToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, "=>"); - arrowFunction.body = (lastToken === 34 /* EqualsGreaterThanToken */ || lastToken === 15 /* OpenBraceToken */) + arrowFunction.equalsGreaterThanToken = parseExpectedToken(35 /* EqualsGreaterThanToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, "=>"); + arrowFunction.body = (lastToken === 35 /* EqualsGreaterThanToken */ || lastToken === 16 /* OpenBraceToken */) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return addJSDocComment(finishNode(arrowFunction)); @@ -15430,10 +15484,10 @@ 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() === 118 /* AsyncKeyword */) { + if (token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */ || token() === 119 /* AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token() === 34 /* EqualsGreaterThanToken */) { + if (token() === 35 /* EqualsGreaterThanToken */) { // ERROR RECOVERY TWEAK: // If we see a standalone => try to parse it as an arrow function expression as that's // likely what the user intended to write. @@ -15443,28 +15497,28 @@ var ts; return 0 /* False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 118 /* AsyncKeyword */) { + if (token() === 119 /* AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0 /* False */; } - if (token() !== 17 /* OpenParenToken */ && token() !== 25 /* LessThanToken */) { + if (token() !== 18 /* OpenParenToken */ && token() !== 26 /* LessThanToken */) { return 0 /* False */; } } var first = token(); var second = nextToken(); - if (first === 17 /* OpenParenToken */) { - if (second === 18 /* CloseParenToken */) { + if (first === 18 /* OpenParenToken */) { + if (second === 19 /* CloseParenToken */) { // Simple cases: "() =>", "(): ", and "() {". // This is an arrow function with no parameters. // The last one is not actually an arrow function, // but this is probably what the user intended. var third = nextToken(); switch (third) { - case 34 /* EqualsGreaterThanToken */: - case 54 /* ColonToken */: - case 15 /* OpenBraceToken */: + case 35 /* EqualsGreaterThanToken */: + case 55 /* ColonToken */: + case 16 /* OpenBraceToken */: return 1 /* True */; default: return 0 /* False */; @@ -15476,12 +15530,12 @@ var ts; // ({ x }) => { } // ([ x ]) // ({ x }) - if (second === 19 /* OpenBracketToken */ || second === 15 /* OpenBraceToken */) { + if (second === 20 /* OpenBracketToken */ || second === 16 /* OpenBraceToken */) { return 2 /* Unknown */; } // Simple case: "(..." // This is an arrow function with a rest parameter. - if (second === 22 /* DotDotDotToken */) { + if (second === 23 /* DotDotDotToken */) { return 1 /* True */; } // If we had "(" followed by something that's not an identifier, @@ -15494,7 +15548,7 @@ var ts; } // If we have something like "(a:", then we must have a // type-annotated parameter in an arrow function expression. - if (nextToken() === 54 /* ColonToken */) { + if (nextToken() === 55 /* ColonToken */) { return 1 /* True */; } // This *could* be a parenthesized arrow function. @@ -15502,7 +15556,7 @@ var ts; return 2 /* Unknown */; } else { - ts.Debug.assert(first === 25 /* LessThanToken */); + ts.Debug.assert(first === 26 /* LessThanToken */); // If we have "<" not followed by an identifier, // then this definitely is not an arrow function. if (!isIdentifier()) { @@ -15512,17 +15566,17 @@ var ts; if (sourceFile.languageVariant === 1 /* JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 83 /* ExtendsKeyword */) { + if (third === 84 /* ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 56 /* EqualsToken */: - case 27 /* GreaterThanToken */: + case 57 /* EqualsToken */: + case 28 /* GreaterThanToken */: return false; default: return true; } } - else if (third === 24 /* CommaToken */) { + else if (third === 25 /* CommaToken */) { return true; } return false; @@ -15541,7 +15595,7 @@ var ts; } function tryParseAsyncSimpleArrowFunctionExpression() { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" - if (token() === 118 /* AsyncKeyword */) { + if (token() === 119 /* AsyncKeyword */) { var isUnParenthesizedAsyncArrowFunction = lookAhead(isUnParenthesizedAsyncArrowFunctionWorker); if (isUnParenthesizedAsyncArrowFunction === 1 /* True */) { var asyncModifier = parseModifiersForArrowFunction(); @@ -15555,23 +15609,23 @@ var ts; // AsyncArrowFunctionExpression: // 1) async[no LineTerminator here]AsyncArrowBindingIdentifier[?Yield][no LineTerminator here]=>AsyncConciseBody[?In] // 2) CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await][no LineTerminator here]=>AsyncConciseBody[?In] - if (token() === 118 /* AsyncKeyword */) { + if (token() === 119 /* AsyncKeyword */) { nextToken(); // If the "async" is followed by "=>" token then it is not a begining of an async arrow-function // but instead a simple arrow-function which will be parsed inside "parseAssignmentExpressionOrHigher" - if (scanner.hasPrecedingLineBreak() || token() === 34 /* EqualsGreaterThanToken */) { + if (scanner.hasPrecedingLineBreak() || token() === 35 /* EqualsGreaterThanToken */) { return 0 /* False */; } // Check for un-parenthesized AsyncArrowFunction var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 69 /* Identifier */ && token() === 34 /* EqualsGreaterThanToken */) { + if (!scanner.hasPrecedingLineBreak() && expr.kind === 70 /* Identifier */ && token() === 35 /* EqualsGreaterThanToken */) { return 1 /* True */; } } return 0 /* False */; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(180 /* ArrowFunction */); + var node = createNode(181 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); var isAsync = !!(ts.getModifierFlags(node) & 256 /* Async */); // Arrow functions are never generators. @@ -15581,7 +15635,7 @@ var ts; // a => (b => c) // And think that "(b =>" was actually a parenthesized arrow function with a missing // close paren. - fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ !allowAmbiguity, node); + fillSignature(55 /* 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; @@ -15594,19 +15648,19 @@ var ts; // - "a ? (b): c" will have "(b):" parsed as a signature with a return type annotation. // // So we need just a bit of lookahead to ensure that it can only be a signature. - if (!allowAmbiguity && token() !== 34 /* EqualsGreaterThanToken */ && token() !== 15 /* OpenBraceToken */) { + if (!allowAmbiguity && token() !== 35 /* EqualsGreaterThanToken */ && token() !== 16 /* OpenBraceToken */) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } return node; } function parseArrowFunctionExpressionBody(isAsync) { - if (token() === 15 /* OpenBraceToken */) { + if (token() === 16 /* OpenBraceToken */) { return parseFunctionBlock(/*allowYield*/ false, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); } - if (token() !== 23 /* SemicolonToken */ && - token() !== 87 /* FunctionKeyword */ && - token() !== 73 /* ClassKeyword */ && + if (token() !== 24 /* SemicolonToken */ && + token() !== 88 /* FunctionKeyword */ && + token() !== 74 /* ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -15631,17 +15685,17 @@ var ts; } function parseConditionalExpressionRest(leftOperand) { // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - var questionToken = parseOptionalToken(53 /* QuestionToken */); + var questionToken = parseOptionalToken(54 /* 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(188 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(189 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(54 /* ColonToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(54 /* ColonToken */)); + node.colonToken = parseExpectedToken(55 /* ColonToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(55 /* ColonToken */)); node.whenFalse = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -15650,7 +15704,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 90 /* InKeyword */ || t === 138 /* OfKeyword */; + return t === 91 /* InKeyword */ || t === 139 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -15679,16 +15733,16 @@ var ts; // ^^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 */ ? + var consumeCurrentOperator = token() === 39 /* AsteriskAsteriskToken */ ? newPrecedence >= precedence : newPrecedence > precedence; if (!consumeCurrentOperator) { break; } - if (token() === 90 /* InKeyword */ && inDisallowInContext()) { + if (token() === 91 /* InKeyword */ && inDisallowInContext()) { break; } - if (token() === 116 /* AsKeyword */) { + if (token() === 117 /* AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -15709,48 +15763,48 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 90 /* InKeyword */) { + if (inDisallowInContext() && token() === 91 /* InKeyword */) { return false; } return getBinaryOperatorPrecedence() > 0; } function getBinaryOperatorPrecedence() { switch (token()) { - case 52 /* BarBarToken */: + case 53 /* BarBarToken */: return 1; - case 51 /* AmpersandAmpersandToken */: + case 52 /* AmpersandAmpersandToken */: return 2; - case 47 /* BarToken */: + case 48 /* BarToken */: return 3; - case 48 /* CaretToken */: + case 49 /* CaretToken */: return 4; - case 46 /* AmpersandToken */: + case 47 /* AmpersandToken */: return 5; - case 30 /* EqualsEqualsToken */: - case 31 /* ExclamationEqualsToken */: - case 32 /* EqualsEqualsEqualsToken */: - case 33 /* ExclamationEqualsEqualsToken */: + case 31 /* EqualsEqualsToken */: + case 32 /* ExclamationEqualsToken */: + case 33 /* EqualsEqualsEqualsToken */: + case 34 /* ExclamationEqualsEqualsToken */: return 6; - case 25 /* LessThanToken */: - case 27 /* GreaterThanToken */: - case 28 /* LessThanEqualsToken */: - case 29 /* GreaterThanEqualsToken */: - case 91 /* InstanceOfKeyword */: - case 90 /* InKeyword */: - case 116 /* AsKeyword */: + case 26 /* LessThanToken */: + case 28 /* GreaterThanToken */: + case 29 /* LessThanEqualsToken */: + case 30 /* GreaterThanEqualsToken */: + case 92 /* InstanceOfKeyword */: + case 91 /* InKeyword */: + case 117 /* AsKeyword */: return 7; - case 43 /* LessThanLessThanToken */: - case 44 /* GreaterThanGreaterThanToken */: - case 45 /* GreaterThanGreaterThanGreaterThanToken */: + case 44 /* LessThanLessThanToken */: + case 45 /* GreaterThanGreaterThanToken */: + case 46 /* GreaterThanGreaterThanGreaterThanToken */: return 8; - case 35 /* PlusToken */: - case 36 /* MinusToken */: + case 36 /* PlusToken */: + case 37 /* MinusToken */: return 9; - case 37 /* AsteriskToken */: - case 39 /* SlashToken */: - case 40 /* PercentToken */: + case 38 /* AsteriskToken */: + case 40 /* SlashToken */: + case 41 /* PercentToken */: return 10; - case 38 /* AsteriskAsteriskToken */: + case 39 /* AsteriskAsteriskToken */: return 11; } // -1 is lower than all other precedences. Returning it will cause binary expression @@ -15758,45 +15812,45 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(187 /* BinaryExpression */, left.pos); + var node = createNode(188 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(195 /* AsExpression */, left.pos); + var node = createNode(196 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(185 /* PrefixUnaryExpression */); + var node = createNode(186 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(181 /* DeleteExpression */); + var node = createNode(182 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(182 /* TypeOfExpression */); + var node = createNode(183 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(183 /* VoidExpression */); + var node = createNode(184 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function isAwaitExpression() { - if (token() === 119 /* AwaitKeyword */) { + if (token() === 120 /* AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -15806,7 +15860,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(184 /* AwaitExpression */); + var node = createNode(185 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -15830,7 +15884,7 @@ var ts; */ if (isUpdateExpression()) { var incrementExpression = parseIncrementExpression(); - return token() === 38 /* AsteriskAsteriskToken */ ? + return token() === 39 /* AsteriskAsteriskToken */ ? parseBinaryExpressionRest(getBinaryOperatorPrecedence(), incrementExpression) : incrementExpression; } @@ -15847,9 +15901,9 @@ var ts; */ var unaryOperator = token(); var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token() === 38 /* AsteriskAsteriskToken */) { + if (token() === 39 /* AsteriskAsteriskToken */) { var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); - if (simpleUnaryExpression.kind === 177 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 178 /* 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 { @@ -15874,23 +15928,23 @@ var ts; */ function parseSimpleUnaryExpression() { switch (token()) { - case 35 /* PlusToken */: - case 36 /* MinusToken */: - case 50 /* TildeToken */: - case 49 /* ExclamationToken */: + case 36 /* PlusToken */: + case 37 /* MinusToken */: + case 51 /* TildeToken */: + case 50 /* ExclamationToken */: return parsePrefixUnaryExpression(); - case 78 /* DeleteKeyword */: + case 79 /* DeleteKeyword */: return parseDeleteExpression(); - case 101 /* TypeOfKeyword */: + case 102 /* TypeOfKeyword */: return parseTypeOfExpression(); - case 103 /* VoidKeyword */: + case 104 /* VoidKeyword */: return parseVoidExpression(); - case 25 /* LessThanToken */: + case 26 /* LessThanToken */: // This is modified UnaryExpression grammar in TypeScript // UnaryExpression (modified): // < type > UnaryExpression return parseTypeAssertion(); - case 119 /* AwaitKeyword */: + case 120 /* AwaitKeyword */: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -15912,16 +15966,16 @@ var ts; // This function is called inside parseUnaryExpression to decide // whether to call parseSimpleUnaryExpression or call parseIncrementExpression directly switch (token()) { - case 35 /* PlusToken */: - case 36 /* MinusToken */: - case 50 /* TildeToken */: - case 49 /* ExclamationToken */: - case 78 /* DeleteKeyword */: - case 101 /* TypeOfKeyword */: - case 103 /* VoidKeyword */: - case 119 /* AwaitKeyword */: + case 36 /* PlusToken */: + case 37 /* MinusToken */: + case 51 /* TildeToken */: + case 50 /* ExclamationToken */: + case 79 /* DeleteKeyword */: + case 102 /* TypeOfKeyword */: + case 104 /* VoidKeyword */: + case 120 /* AwaitKeyword */: return false; - case 25 /* LessThanToken */: + case 26 /* LessThanToken */: // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression if (sourceFile.languageVariant !== 1 /* JSX */) { return false; @@ -15944,21 +15998,21 @@ var ts; * 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(185 /* PrefixUnaryExpression */); + if (token() === 42 /* PlusPlusToken */ || token() === 43 /* MinusMinusToken */) { + var node = createNode(186 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); return finishNode(node); } - else if (sourceFile.languageVariant === 1 /* JSX */ && token() === 25 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeyword)) { + else if (sourceFile.languageVariant === 1 /* JSX */ && token() === 26 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeyword)) { // JSXElement is part of primaryExpression return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token() === 41 /* PlusPlusToken */ || token() === 42 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(186 /* PostfixUnaryExpression */, expression.pos); + if ((token() === 42 /* PlusPlusToken */ || token() === 43 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(187 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -15997,7 +16051,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() === 95 /* SuperKeyword */ + var expression = token() === 96 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); // Now, we *may* be complete. However, we might have consumed the start of a @@ -16057,14 +16111,14 @@ var ts; } function parseSuperExpression() { var expression = parseTokenNode(); - if (token() === 17 /* OpenParenToken */ || token() === 21 /* DotToken */ || token() === 19 /* OpenBracketToken */) { + if (token() === 18 /* OpenParenToken */ || token() === 22 /* DotToken */ || token() === 20 /* OpenBracketToken */) { return expression; } // 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(172 /* PropertyAccessExpression */, expression.pos); + var node = createNode(173 /* PropertyAccessExpression */, expression.pos); node.expression = expression; - parseExpectedToken(21 /* DotToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + parseExpectedToken(22 /* DotToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); return finishNode(node); } @@ -16072,10 +16126,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 69 /* Identifier */) { + if (lhs.kind === 70 /* Identifier */) { return lhs.text === rhs.text; } - if (lhs.kind === 97 /* ThisKeyword */) { + if (lhs.kind === 98 /* ThisKeyword */) { return true; } // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only @@ -16087,8 +16141,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 243 /* JsxOpeningElement */) { - var node = createNode(241 /* JsxElement */, opening.pos); + if (opening.kind === 244 /* JsxOpeningElement */) { + var node = createNode(242 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -16098,7 +16152,7 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 242 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 243 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -16109,15 +16163,15 @@ var ts; // does less damage and we can report a better error. // Since JSX elements are invalid < operands anyway, this lookahead parse will only occur in error scenarios // of one sort or another. - if (inExpressionContext && token() === 25 /* LessThanToken */) { + if (inExpressionContext && token() === 26 /* LessThanToken */) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(187 /* BinaryExpression */, result.pos); + var badNode = createNode(188 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; - badNode.operatorToken = createMissingNode(24 /* CommaToken */, /*reportAtCurrentPosition*/ false, /*diagnosticMessage*/ undefined); + badNode.operatorToken = createMissingNode(25 /* CommaToken */, /*reportAtCurrentPosition*/ false, /*diagnosticMessage*/ undefined); badNode.operatorToken.pos = badNode.operatorToken.end = badNode.right.pos; return badNode; } @@ -16125,17 +16179,17 @@ var ts; return result; } function parseJsxText() { - var node = createNode(244 /* JsxText */, scanner.getStartPos()); + var node = createNode(10 /* JsxText */, scanner.getStartPos()); currentToken = scanner.scanJsxToken(); return finishNode(node); } function parseJsxChild() { switch (token()) { - case 244 /* JsxText */: + case 10 /* JsxText */: return parseJsxText(); - case 15 /* OpenBraceToken */: + case 16 /* OpenBraceToken */: return parseJsxExpression(/*inExpressionContext*/ false); - case 25 /* LessThanToken */: + case 26 /* LessThanToken */: return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ false); } ts.Debug.fail("Unknown JSX child kind " + token()); @@ -16146,7 +16200,7 @@ var ts; parsingContext |= 1 << 14 /* JsxChildren */; while (true) { currentToken = scanner.reScanJsxToken(); - if (token() === 26 /* LessThanSlashToken */) { + if (token() === 27 /* LessThanSlashToken */) { // Closing tag break; } @@ -16164,27 +16218,27 @@ var ts; } function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { var fullStart = scanner.getStartPos(); - parseExpected(25 /* LessThanToken */); + parseExpected(26 /* LessThanToken */); var tagName = parseJsxElementName(); var attributes = parseList(13 /* JsxAttributes */, parseJsxAttribute); var node; - if (token() === 27 /* GreaterThanToken */) { + if (token() === 28 /* GreaterThanToken */) { // 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(243 /* JsxOpeningElement */, fullStart); + node = createNode(244 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { - parseExpected(39 /* SlashToken */); + parseExpected(40 /* SlashToken */); if (inExpressionContext) { - parseExpected(27 /* GreaterThanToken */); + parseExpected(28 /* GreaterThanToken */); } else { - parseExpected(27 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(28 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(242 /* JsxSelfClosingElement */, fullStart); + node = createNode(243 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -16197,10 +16251,10 @@ var ts; // primaryExpression in the form of an identifier and "this" keyword // We can't just simply use parseLeftHandSideExpressionOrHigher because then we will start consider class,function etc as a keyword // We only want to consider "this" as a primaryExpression - var expression = token() === 97 /* ThisKeyword */ ? + var expression = token() === 98 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); - while (parseOptional(21 /* DotToken */)) { - var propertyAccess = createNode(172 /* PropertyAccessExpression */, expression.pos); + while (parseOptional(22 /* DotToken */)) { + var propertyAccess = createNode(173 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -16209,27 +16263,27 @@ var ts; } function parseJsxExpression(inExpressionContext) { var node = createNode(248 /* JsxExpression */); - parseExpected(15 /* OpenBraceToken */); - if (token() !== 16 /* CloseBraceToken */) { + parseExpected(16 /* OpenBraceToken */); + if (token() !== 17 /* CloseBraceToken */) { node.expression = parseAssignmentExpressionOrHigher(); } if (inExpressionContext) { - parseExpected(16 /* CloseBraceToken */); + parseExpected(17 /* CloseBraceToken */); } else { - parseExpected(16 /* CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false); + parseExpected(17 /* CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseJsxAttribute() { - if (token() === 15 /* OpenBraceToken */) { + if (token() === 16 /* OpenBraceToken */) { return parseJsxSpreadAttribute(); } scanJsxIdentifier(); var node = createNode(246 /* JsxAttribute */); node.name = parseIdentifierName(); - if (token() === 56 /* EqualsToken */) { + if (token() === 57 /* EqualsToken */) { switch (scanJsxAttributeValue()) { case 9 /* StringLiteral */: node.initializer = parseLiteralNode(); @@ -16243,71 +16297,71 @@ var ts; } function parseJsxSpreadAttribute() { var node = createNode(247 /* JsxSpreadAttribute */); - parseExpected(15 /* OpenBraceToken */); - parseExpected(22 /* DotDotDotToken */); + parseExpected(16 /* OpenBraceToken */); + parseExpected(23 /* DotDotDotToken */); node.expression = parseExpression(); - parseExpected(16 /* CloseBraceToken */); + parseExpected(17 /* CloseBraceToken */); return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { var node = createNode(245 /* JsxClosingElement */); - parseExpected(26 /* LessThanSlashToken */); + parseExpected(27 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { - parseExpected(27 /* GreaterThanToken */); + parseExpected(28 /* GreaterThanToken */); } else { - parseExpected(27 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(28 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseTypeAssertion() { - var node = createNode(177 /* TypeAssertionExpression */); - parseExpected(25 /* LessThanToken */); + var node = createNode(178 /* TypeAssertionExpression */); + parseExpected(26 /* LessThanToken */); node.type = parseType(); - parseExpected(27 /* GreaterThanToken */); + parseExpected(28 /* GreaterThanToken */); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseMemberExpressionRest(expression) { while (true) { - var dotToken = parseOptionalToken(21 /* DotToken */); + var dotToken = parseOptionalToken(22 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(172 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(173 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); continue; } - if (token() === 49 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 50 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(196 /* NonNullExpression */, expression.pos); + var nonNullExpression = createNode(197 /* NonNullExpression */, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } // 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(173 /* ElementAccessExpression */, expression.pos); + if (!inDecoratorContext() && parseOptional(20 /* OpenBracketToken */)) { + var indexedAccess = createNode(174 /* 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. - if (token() !== 20 /* CloseBracketToken */) { + if (token() !== 21 /* CloseBracketToken */) { indexedAccess.argumentExpression = allowInAnd(parseExpression); if (indexedAccess.argumentExpression.kind === 9 /* StringLiteral */ || indexedAccess.argumentExpression.kind === 8 /* NumericLiteral */) { var literal = indexedAccess.argumentExpression; literal.text = internIdentifier(literal.text); } } - parseExpected(20 /* CloseBracketToken */); + parseExpected(21 /* CloseBracketToken */); expression = finishNode(indexedAccess); continue; } - if (token() === 11 /* NoSubstitutionTemplateLiteral */ || token() === 12 /* TemplateHead */) { - var tagExpression = createNode(176 /* TaggedTemplateExpression */, expression.pos); + if (token() === 12 /* NoSubstitutionTemplateLiteral */ || token() === 13 /* TemplateHead */) { + var tagExpression = createNode(177 /* TaggedTemplateExpression */, expression.pos); tagExpression.tag = expression; - tagExpression.template = token() === 11 /* NoSubstitutionTemplateLiteral */ + tagExpression.template = token() === 12 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() : parseTemplateExpression(); expression = finishNode(tagExpression); @@ -16319,7 +16373,7 @@ var ts; function parseCallExpressionRest(expression) { while (true) { expression = parseMemberExpressionRest(expression); - if (token() === 25 /* LessThanToken */) { + if (token() === 26 /* LessThanToken */) { // See if this is the start of a generic invocation. If so, consume it and // keep checking for postfix expressions. Otherwise, it's just a '<' that's // part of an arithmetic expression. Break out so we consume it higher in the @@ -16328,15 +16382,15 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(174 /* CallExpression */, expression.pos); + var callExpr = createNode(175 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); continue; } - else if (token() === 17 /* OpenParenToken */) { - var callExpr = createNode(174 /* CallExpression */, expression.pos); + else if (token() === 18 /* OpenParenToken */) { + var callExpr = createNode(175 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -16346,17 +16400,17 @@ var ts; } } function parseArgumentList() { - parseExpected(17 /* OpenParenToken */); + parseExpected(18 /* OpenParenToken */); var result = parseDelimitedList(11 /* ArgumentExpressions */, parseArgumentExpression); - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); return result; } function parseTypeArgumentsInExpression() { - if (!parseOptional(25 /* LessThanToken */)) { + if (!parseOptional(26 /* LessThanToken */)) { return undefined; } var typeArguments = parseDelimitedList(18 /* TypeArguments */, parseType); - if (!parseExpected(27 /* GreaterThanToken */)) { + if (!parseExpected(28 /* GreaterThanToken */)) { // If it doesn't have the closing > then it's definitely not an type argument list. return undefined; } @@ -16368,32 +16422,32 @@ var ts; } function canFollowTypeArgumentsInExpression() { switch (token()) { - case 17 /* OpenParenToken */: // foo( + case 18 /* OpenParenToken */: // foo( // this case are the only case where this token can legally follow a type argument // list. So we definitely want to treat this as a type arg list. - case 21 /* DotToken */: // foo. - case 18 /* CloseParenToken */: // foo) - case 20 /* CloseBracketToken */: // foo] - case 54 /* ColonToken */: // foo: - case 23 /* SemicolonToken */: // foo; - case 53 /* QuestionToken */: // foo? - case 30 /* EqualsEqualsToken */: // foo == - case 32 /* EqualsEqualsEqualsToken */: // foo === - case 31 /* ExclamationEqualsToken */: // foo != - case 33 /* ExclamationEqualsEqualsToken */: // 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 22 /* DotToken */: // foo. + case 19 /* CloseParenToken */: // foo) + case 21 /* CloseBracketToken */: // foo] + case 55 /* ColonToken */: // foo: + case 24 /* SemicolonToken */: // foo; + case 54 /* QuestionToken */: // foo? + case 31 /* EqualsEqualsToken */: // foo == + case 33 /* EqualsEqualsEqualsToken */: // foo === + case 32 /* ExclamationEqualsToken */: // foo != + case 34 /* ExclamationEqualsEqualsToken */: // foo !== + case 52 /* AmpersandAmpersandToken */: // foo && + case 53 /* BarBarToken */: // foo || + case 49 /* CaretToken */: // foo ^ + case 47 /* AmpersandToken */: // foo & + case 48 /* BarToken */: // foo | + case 17 /* CloseBraceToken */: // foo } case 1 /* EndOfFileToken */: // these cases can't legally follow a type arg list. However, they're not legal // expressions either. The user is probably in the middle of a generic type. So // treat it as such. return true; - case 24 /* CommaToken */: // foo, - case 15 /* OpenBraceToken */: // foo { + case 25 /* CommaToken */: // foo, + case 16 /* OpenBraceToken */: // foo { // We don't want to treat these as type arguments. Otherwise we'll parse this // as an invocation expression. Instead, we want to parse out the expression // in isolation from the type arguments. @@ -16406,21 +16460,21 @@ var ts; switch (token()) { case 8 /* NumericLiteral */: case 9 /* StringLiteral */: - case 11 /* NoSubstitutionTemplateLiteral */: + case 12 /* NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 97 /* ThisKeyword */: - case 95 /* SuperKeyword */: - case 93 /* NullKeyword */: - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: + case 98 /* ThisKeyword */: + case 96 /* SuperKeyword */: + case 94 /* NullKeyword */: + case 100 /* TrueKeyword */: + case 85 /* FalseKeyword */: return parseTokenNode(); - case 17 /* OpenParenToken */: + case 18 /* OpenParenToken */: return parseParenthesizedExpression(); - case 19 /* OpenBracketToken */: + case 20 /* OpenBracketToken */: return parseArrayLiteralExpression(); - case 15 /* OpenBraceToken */: + case 16 /* OpenBraceToken */: return parseObjectLiteralExpression(); - case 118 /* AsyncKeyword */: + case 119 /* 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. @@ -16428,60 +16482,60 @@ var ts; break; } return parseFunctionExpression(); - case 73 /* ClassKeyword */: + case 74 /* ClassKeyword */: return parseClassExpression(); - case 87 /* FunctionKeyword */: + case 88 /* FunctionKeyword */: return parseFunctionExpression(); - case 92 /* NewKeyword */: + case 93 /* NewKeyword */: return parseNewExpression(); - case 39 /* SlashToken */: - case 61 /* SlashEqualsToken */: - if (reScanSlashToken() === 10 /* RegularExpressionLiteral */) { + case 40 /* SlashToken */: + case 62 /* SlashEqualsToken */: + if (reScanSlashToken() === 11 /* RegularExpressionLiteral */) { return parseLiteralNode(); } break; - case 12 /* TemplateHead */: + case 13 /* TemplateHead */: return parseTemplateExpression(); } return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(178 /* ParenthesizedExpression */); - parseExpected(17 /* OpenParenToken */); + var node = createNode(179 /* ParenthesizedExpression */); + parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(191 /* SpreadElementExpression */); - parseExpected(22 /* DotDotDotToken */); + var node = createNode(192 /* SpreadElementExpression */); + parseExpected(23 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { - return token() === 22 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 24 /* CommaToken */ ? createNode(193 /* OmittedExpression */) : + return token() === 23 /* DotDotDotToken */ ? parseSpreadElement() : + token() === 25 /* CommaToken */ ? createNode(194 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(170 /* ArrayLiteralExpression */); - parseExpected(19 /* OpenBracketToken */); + var node = createNode(171 /* ArrayLiteralExpression */); + parseExpected(20 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); - parseExpected(20 /* CloseBracketToken */); + parseExpected(21 /* CloseBracketToken */); return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { - if (parseContextualModifier(123 /* GetKeyword */)) { - return parseAccessorDeclaration(149 /* GetAccessor */, fullStart, decorators, modifiers); + if (parseContextualModifier(124 /* GetKeyword */)) { + return parseAccessorDeclaration(150 /* GetAccessor */, fullStart, decorators, modifiers); } - else if (parseContextualModifier(131 /* SetKeyword */)) { - return parseAccessorDeclaration(150 /* SetAccessor */, fullStart, decorators, modifiers); + else if (parseContextualModifier(132 /* SetKeyword */)) { + return parseAccessorDeclaration(151 /* SetAccessor */, fullStart, decorators, modifiers); } return undefined; } @@ -16493,12 +16547,12 @@ var ts; if (accessor) { return accessor; } - var asteriskToken = parseOptionalToken(37 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(38 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); // Disallowing of optional property assignments happens in the grammar checker. - var questionToken = parseOptionalToken(53 /* QuestionToken */); - if (asteriskToken || token() === 17 /* OpenParenToken */ || token() === 25 /* LessThanToken */) { + var questionToken = parseOptionalToken(54 /* QuestionToken */); + if (asteriskToken || token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } // check if it is short-hand property assignment or normal property assignment @@ -16506,12 +16560,12 @@ var ts; // 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 */); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 25 /* CommaToken */ || token() === 17 /* CloseBraceToken */ || token() === 57 /* EqualsToken */); if (isShorthandPropertyAssignment) { var shorthandDeclaration = createNode(254 /* ShorthandPropertyAssignment */, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; - var equalsToken = parseOptionalToken(56 /* EqualsToken */); + var equalsToken = parseOptionalToken(57 /* EqualsToken */); if (equalsToken) { shorthandDeclaration.equalsToken = equalsToken; shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); @@ -16523,19 +16577,19 @@ var ts; propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; - parseExpected(54 /* ColonToken */); + parseExpected(55 /* ColonToken */); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); return addJSDocComment(finishNode(propertyAssignment)); } } function parseObjectLiteralExpression() { - var node = createNode(171 /* ObjectLiteralExpression */); - parseExpected(15 /* OpenBraceToken */); + var node = createNode(172 /* ObjectLiteralExpression */); + parseExpected(16 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true); - parseExpected(16 /* CloseBraceToken */); + parseExpected(17 /* CloseBraceToken */); return finishNode(node); } function parseFunctionExpression() { @@ -16548,10 +16602,10 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNode(179 /* FunctionExpression */); + var node = createNode(180 /* FunctionExpression */); node.modifiers = parseModifiers(); - parseExpected(87 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); + parseExpected(88 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(38 /* AsteriskToken */); var isGenerator = !!node.asteriskToken; var isAsync = !!(ts.getModifierFlags(node) & 256 /* Async */); node.name = @@ -16559,7 +16613,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); + fillSignature(55 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlock(/*allowYield*/ isGenerator, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); @@ -16570,24 +16624,24 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(175 /* NewExpression */); - parseExpected(92 /* NewKeyword */); + var node = createNode(176 /* NewExpression */); + parseExpected(93 /* NewKeyword */); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); - if (node.typeArguments || token() === 17 /* OpenParenToken */) { + if (node.typeArguments || token() === 18 /* OpenParenToken */) { node.arguments = parseArgumentList(); } return finishNode(node); } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(199 /* Block */); - if (parseExpected(15 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { + var node = createNode(200 /* Block */); + if (parseExpected(16 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(16 /* CloseBraceToken */); + parseExpected(17 /* CloseBraceToken */); } else { node.statements = createMissingList(); @@ -16614,51 +16668,51 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(201 /* EmptyStatement */); - parseExpected(23 /* SemicolonToken */); + var node = createNode(202 /* EmptyStatement */); + parseExpected(24 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(203 /* IfStatement */); - parseExpected(88 /* IfKeyword */); - parseExpected(17 /* OpenParenToken */); + var node = createNode(204 /* IfStatement */); + parseExpected(89 /* IfKeyword */); + parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(80 /* ElseKeyword */) ? parseStatement() : undefined; + node.elseStatement = parseOptional(81 /* ElseKeyword */) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(204 /* DoStatement */); - parseExpected(79 /* DoKeyword */); + var node = createNode(205 /* DoStatement */); + parseExpected(80 /* DoKeyword */); node.statement = parseStatement(); - parseExpected(104 /* WhileKeyword */); - parseExpected(17 /* OpenParenToken */); + parseExpected(105 /* WhileKeyword */); + parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); // From: https://mail.mozilla.org/pipermail/es-discuss/2011-August/016188.html // 157 min --- All allen at wirfs-brock.com CONF --- "do{;}while(false)false" prohibited in // spec but allowed in consensus reality. Approved -- this is the de-facto standard whereby // do;while(0)x will have a semicolon inserted before x. - parseOptional(23 /* SemicolonToken */); + parseOptional(24 /* SemicolonToken */); return finishNode(node); } function parseWhileStatement() { - var node = createNode(205 /* WhileStatement */); - parseExpected(104 /* WhileKeyword */); - parseExpected(17 /* OpenParenToken */); + var node = createNode(206 /* WhileStatement */); + parseExpected(105 /* WhileKeyword */); + parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); node.statement = parseStatement(); return finishNode(node); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(86 /* ForKeyword */); - parseExpected(17 /* OpenParenToken */); + parseExpected(87 /* ForKeyword */); + parseExpected(18 /* OpenParenToken */); var initializer = undefined; - if (token() !== 23 /* SemicolonToken */) { - if (token() === 102 /* VarKeyword */ || token() === 108 /* LetKeyword */ || token() === 74 /* ConstKeyword */) { + if (token() !== 24 /* SemicolonToken */) { + if (token() === 103 /* VarKeyword */ || token() === 109 /* LetKeyword */ || token() === 75 /* ConstKeyword */) { initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { @@ -16666,32 +16720,32 @@ var ts; } } var forOrForInOrForOfStatement; - if (parseOptional(90 /* InKeyword */)) { - var forInStatement = createNode(207 /* ForInStatement */, pos); + if (parseOptional(91 /* InKeyword */)) { + var forInStatement = createNode(208 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(138 /* OfKeyword */)) { - var forOfStatement = createNode(208 /* ForOfStatement */, pos); + else if (parseOptional(139 /* OfKeyword */)) { + var forOfStatement = createNode(209 /* ForOfStatement */, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(206 /* ForStatement */, pos); + var forStatement = createNode(207 /* ForStatement */, pos); forStatement.initializer = initializer; - parseExpected(23 /* SemicolonToken */); - if (token() !== 23 /* SemicolonToken */ && token() !== 18 /* CloseParenToken */) { + parseExpected(24 /* SemicolonToken */); + if (token() !== 24 /* SemicolonToken */ && token() !== 19 /* CloseParenToken */) { forStatement.condition = allowInAnd(parseExpression); } - parseExpected(23 /* SemicolonToken */); - if (token() !== 18 /* CloseParenToken */) { + parseExpected(24 /* SemicolonToken */); + if (token() !== 19 /* CloseParenToken */) { forStatement.incrementor = allowInAnd(parseExpression); } - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); forOrForInOrForOfStatement = forStatement; } forOrForInOrForOfStatement.statement = parseStatement(); @@ -16699,7 +16753,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 210 /* BreakStatement */ ? 70 /* BreakKeyword */ : 75 /* ContinueKeyword */); + parseExpected(kind === 211 /* BreakStatement */ ? 71 /* BreakKeyword */ : 76 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -16707,8 +16761,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(211 /* ReturnStatement */); - parseExpected(94 /* ReturnKeyword */); + var node = createNode(212 /* ReturnStatement */); + parseExpected(95 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -16716,42 +16770,42 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(212 /* WithStatement */); - parseExpected(105 /* WithKeyword */); - parseExpected(17 /* OpenParenToken */); + var node = createNode(213 /* WithStatement */); + parseExpected(106 /* WithKeyword */); + parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); node.statement = parseStatement(); return finishNode(node); } function parseCaseClause() { var node = createNode(249 /* CaseClause */); - parseExpected(71 /* CaseKeyword */); + parseExpected(72 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); - parseExpected(54 /* ColonToken */); + parseExpected(55 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseDefaultClause() { var node = createNode(250 /* DefaultClause */); - parseExpected(77 /* DefaultKeyword */); - parseExpected(54 /* ColonToken */); + parseExpected(78 /* DefaultKeyword */); + parseExpected(55 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token() === 71 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token() === 72 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(213 /* SwitchStatement */); - parseExpected(96 /* SwitchKeyword */); - parseExpected(17 /* OpenParenToken */); + var node = createNode(214 /* SwitchStatement */); + parseExpected(97 /* SwitchKeyword */); + parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(18 /* CloseParenToken */); - var caseBlock = createNode(227 /* CaseBlock */, scanner.getStartPos()); - parseExpected(15 /* OpenBraceToken */); + parseExpected(19 /* CloseParenToken */); + var caseBlock = createNode(228 /* CaseBlock */, scanner.getStartPos()); + parseExpected(16 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); - parseExpected(16 /* CloseBraceToken */); + parseExpected(17 /* CloseBraceToken */); node.caseBlock = finishNode(caseBlock); return finishNode(node); } @@ -16763,39 +16817,39 @@ 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(215 /* ThrowStatement */); - parseExpected(98 /* ThrowKeyword */); + var node = createNode(216 /* ThrowStatement */); + parseExpected(99 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(216 /* TryStatement */); - parseExpected(100 /* TryKeyword */); + var node = createNode(217 /* TryStatement */); + parseExpected(101 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); - node.catchClause = token() === 72 /* CatchKeyword */ ? parseCatchClause() : undefined; + node.catchClause = token() === 73 /* 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() === 85 /* FinallyKeyword */) { - parseExpected(85 /* FinallyKeyword */); + if (!node.catchClause || token() === 86 /* FinallyKeyword */) { + parseExpected(86 /* FinallyKeyword */); node.finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } return finishNode(node); } function parseCatchClause() { var result = createNode(252 /* CatchClause */); - parseExpected(72 /* CatchKeyword */); - if (parseExpected(17 /* OpenParenToken */)) { + parseExpected(73 /* CatchKeyword */); + if (parseExpected(18 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); } - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); result.block = parseBlock(/*ignoreMissingOpenBrace*/ false); return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(217 /* DebuggerStatement */); - parseExpected(76 /* DebuggerKeyword */); + var node = createNode(218 /* DebuggerStatement */); + parseExpected(77 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); } @@ -16805,14 +16859,14 @@ var ts; // a colon. var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); - if (expression.kind === 69 /* Identifier */ && parseOptional(54 /* ColonToken */)) { - var labeledStatement = createNode(214 /* LabeledStatement */, fullStart); + if (expression.kind === 70 /* Identifier */ && parseOptional(55 /* ColonToken */)) { + var labeledStatement = createNode(215 /* LabeledStatement */, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(202 /* ExpressionStatement */, fullStart); + var expressionStatement = createNode(203 /* ExpressionStatement */, fullStart); expressionStatement.expression = expression; parseSemicolon(); return addJSDocComment(finishNode(expressionStatement)); @@ -16824,7 +16878,7 @@ var ts; } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 87 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 88 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { nextToken(); @@ -16833,12 +16887,12 @@ var ts; function isDeclaration() { while (true) { switch (token()) { - case 102 /* VarKeyword */: - case 108 /* LetKeyword */: - case 74 /* ConstKeyword */: - case 87 /* FunctionKeyword */: - case 73 /* ClassKeyword */: - case 81 /* EnumKeyword */: + case 103 /* VarKeyword */: + case 109 /* LetKeyword */: + case 75 /* ConstKeyword */: + case 88 /* FunctionKeyword */: + case 74 /* ClassKeyword */: + case 82 /* 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 @@ -16861,41 +16915,41 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 107 /* InterfaceKeyword */: - case 134 /* TypeKeyword */: + case 108 /* InterfaceKeyword */: + case 135 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 125 /* ModuleKeyword */: - case 126 /* NamespaceKeyword */: + case 126 /* ModuleKeyword */: + case 127 /* NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 115 /* AbstractKeyword */: - case 118 /* AsyncKeyword */: - case 122 /* DeclareKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - case 112 /* PublicKeyword */: - case 128 /* ReadonlyKeyword */: + case 116 /* AbstractKeyword */: + case 119 /* AsyncKeyword */: + case 123 /* DeclareKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + case 113 /* PublicKeyword */: + case 129 /* ReadonlyKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 137 /* GlobalKeyword */: + case 138 /* GlobalKeyword */: nextToken(); - return token() === 15 /* OpenBraceToken */ || token() === 69 /* Identifier */ || token() === 82 /* ExportKeyword */; - case 89 /* ImportKeyword */: + return token() === 16 /* OpenBraceToken */ || token() === 70 /* Identifier */ || token() === 83 /* ExportKeyword */; + case 90 /* ImportKeyword */: nextToken(); - return token() === 9 /* StringLiteral */ || token() === 37 /* AsteriskToken */ || - token() === 15 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); - case 82 /* ExportKeyword */: + return token() === 9 /* StringLiteral */ || token() === 38 /* AsteriskToken */ || + token() === 16 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); + case 83 /* ExportKeyword */: nextToken(); - if (token() === 56 /* EqualsToken */ || token() === 37 /* AsteriskToken */ || - token() === 15 /* OpenBraceToken */ || token() === 77 /* DefaultKeyword */ || - token() === 116 /* AsKeyword */) { + if (token() === 57 /* EqualsToken */ || token() === 38 /* AsteriskToken */ || + token() === 16 /* OpenBraceToken */ || token() === 78 /* DefaultKeyword */ || + token() === 117 /* AsKeyword */) { return true; } continue; - case 113 /* StaticKeyword */: + case 114 /* StaticKeyword */: nextToken(); continue; default: @@ -16908,49 +16962,49 @@ var ts; } function isStartOfStatement() { switch (token()) { - case 55 /* AtToken */: - case 23 /* SemicolonToken */: - case 15 /* OpenBraceToken */: - 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 */: + case 56 /* AtToken */: + case 24 /* SemicolonToken */: + case 16 /* OpenBraceToken */: + case 103 /* VarKeyword */: + case 109 /* LetKeyword */: + case 88 /* FunctionKeyword */: + case 74 /* ClassKeyword */: + case 82 /* EnumKeyword */: + case 89 /* IfKeyword */: + case 80 /* DoKeyword */: + case 105 /* WhileKeyword */: + case 87 /* ForKeyword */: + case 76 /* ContinueKeyword */: + case 71 /* BreakKeyword */: + case 95 /* ReturnKeyword */: + case 106 /* WithKeyword */: + case 97 /* SwitchKeyword */: + case 99 /* ThrowKeyword */: + case 101 /* TryKeyword */: + case 77 /* 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 72 /* CatchKeyword */: - case 85 /* FinallyKeyword */: + case 73 /* CatchKeyword */: + case 86 /* FinallyKeyword */: return true; - case 74 /* ConstKeyword */: - case 82 /* ExportKeyword */: - case 89 /* ImportKeyword */: + case 75 /* ConstKeyword */: + case 83 /* ExportKeyword */: + case 90 /* ImportKeyword */: return isStartOfDeclaration(); - case 118 /* AsyncKeyword */: - case 122 /* DeclareKeyword */: - case 107 /* InterfaceKeyword */: - case 125 /* ModuleKeyword */: - case 126 /* NamespaceKeyword */: - case 134 /* TypeKeyword */: - case 137 /* GlobalKeyword */: + case 119 /* AsyncKeyword */: + case 123 /* DeclareKeyword */: + case 108 /* InterfaceKeyword */: + case 126 /* ModuleKeyword */: + case 127 /* NamespaceKeyword */: + case 135 /* TypeKeyword */: + case 138 /* GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - case 113 /* StaticKeyword */: - case 128 /* ReadonlyKeyword */: + case 113 /* PublicKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + case 114 /* StaticKeyword */: + case 129 /* ReadonlyKeyword */: // 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); @@ -16960,7 +17014,7 @@ var ts; } function nextTokenIsIdentifierOrStartOfDestructuring() { nextToken(); - return isIdentifier() || token() === 15 /* OpenBraceToken */ || token() === 19 /* OpenBracketToken */; + return isIdentifier() || token() === 16 /* OpenBraceToken */ || token() === 20 /* OpenBracketToken */; } function isLetDeclaration() { // In ES6 'let' always starts a lexical declaration if followed by an identifier or { @@ -16969,67 +17023,67 @@ var ts; } function parseStatement() { switch (token()) { - case 23 /* SemicolonToken */: + case 24 /* SemicolonToken */: return parseEmptyStatement(); - case 15 /* OpenBraceToken */: + case 16 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); - case 102 /* VarKeyword */: + case 103 /* VarKeyword */: return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 108 /* LetKeyword */: + case 109 /* LetKeyword */: if (isLetDeclaration()) { return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); } break; - case 87 /* FunctionKeyword */: + case 88 /* FunctionKeyword */: return parseFunctionDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 73 /* ClassKeyword */: + case 74 /* ClassKeyword */: return parseClassDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 88 /* IfKeyword */: + case 89 /* IfKeyword */: return parseIfStatement(); - case 79 /* DoKeyword */: + case 80 /* DoKeyword */: return parseDoStatement(); - case 104 /* WhileKeyword */: + case 105 /* WhileKeyword */: return parseWhileStatement(); - case 86 /* ForKeyword */: + case 87 /* ForKeyword */: return parseForOrForInOrForOfStatement(); - case 75 /* ContinueKeyword */: - return parseBreakOrContinueStatement(209 /* ContinueStatement */); - case 70 /* BreakKeyword */: - return parseBreakOrContinueStatement(210 /* BreakStatement */); - case 94 /* ReturnKeyword */: + case 76 /* ContinueKeyword */: + return parseBreakOrContinueStatement(210 /* ContinueStatement */); + case 71 /* BreakKeyword */: + return parseBreakOrContinueStatement(211 /* BreakStatement */); + case 95 /* ReturnKeyword */: return parseReturnStatement(); - case 105 /* WithKeyword */: + case 106 /* WithKeyword */: return parseWithStatement(); - case 96 /* SwitchKeyword */: + case 97 /* SwitchKeyword */: return parseSwitchStatement(); - case 98 /* ThrowKeyword */: + case 99 /* ThrowKeyword */: return parseThrowStatement(); - case 100 /* TryKeyword */: + case 101 /* TryKeyword */: // Include 'catch' and 'finally' for error recovery. - case 72 /* CatchKeyword */: - case 85 /* FinallyKeyword */: + case 73 /* CatchKeyword */: + case 86 /* FinallyKeyword */: return parseTryStatement(); - case 76 /* DebuggerKeyword */: + case 77 /* DebuggerKeyword */: return parseDebuggerStatement(); - case 55 /* AtToken */: + case 56 /* AtToken */: return parseDeclaration(); - case 118 /* AsyncKeyword */: - case 107 /* InterfaceKeyword */: - case 134 /* 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 */: - case 128 /* ReadonlyKeyword */: - case 137 /* GlobalKeyword */: + case 119 /* AsyncKeyword */: + case 108 /* InterfaceKeyword */: + case 135 /* TypeKeyword */: + case 126 /* ModuleKeyword */: + case 127 /* NamespaceKeyword */: + case 123 /* DeclareKeyword */: + case 75 /* ConstKeyword */: + case 82 /* EnumKeyword */: + case 83 /* ExportKeyword */: + case 90 /* ImportKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + case 113 /* PublicKeyword */: + case 116 /* AbstractKeyword */: + case 114 /* StaticKeyword */: + case 129 /* ReadonlyKeyword */: + case 138 /* GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -17042,33 +17096,33 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(); switch (token()) { - case 102 /* VarKeyword */: - case 108 /* LetKeyword */: - case 74 /* ConstKeyword */: + case 103 /* VarKeyword */: + case 109 /* LetKeyword */: + case 75 /* ConstKeyword */: return parseVariableStatement(fullStart, decorators, modifiers); - case 87 /* FunctionKeyword */: + case 88 /* FunctionKeyword */: return parseFunctionDeclaration(fullStart, decorators, modifiers); - case 73 /* ClassKeyword */: + case 74 /* ClassKeyword */: return parseClassDeclaration(fullStart, decorators, modifiers); - case 107 /* InterfaceKeyword */: + case 108 /* InterfaceKeyword */: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 134 /* TypeKeyword */: + case 135 /* TypeKeyword */: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); - case 81 /* EnumKeyword */: + case 82 /* EnumKeyword */: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 137 /* GlobalKeyword */: - case 125 /* ModuleKeyword */: - case 126 /* NamespaceKeyword */: + case 138 /* GlobalKeyword */: + case 126 /* ModuleKeyword */: + case 127 /* NamespaceKeyword */: return parseModuleDeclaration(fullStart, decorators, modifiers); - case 89 /* ImportKeyword */: + case 90 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); - case 82 /* ExportKeyword */: + case 83 /* ExportKeyword */: nextToken(); switch (token()) { - case 77 /* DefaultKeyword */: - case 56 /* EqualsToken */: + case 78 /* DefaultKeyword */: + case 57 /* EqualsToken */: return parseExportAssignment(fullStart, decorators, modifiers); - case 116 /* AsKeyword */: + case 117 /* AsKeyword */: return parseNamespaceExportDeclaration(fullStart, decorators, modifiers); default: return parseExportDeclaration(fullStart, decorators, modifiers); @@ -17077,7 +17131,7 @@ var ts; 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(239 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(240 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; node.modifiers = modifiers; @@ -17090,7 +17144,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 9 /* StringLiteral */); } function parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage) { - if (token() !== 15 /* OpenBraceToken */ && canParseSemicolon()) { + if (token() !== 16 /* OpenBraceToken */ && canParseSemicolon()) { parseSemicolon(); return; } @@ -17098,24 +17152,24 @@ var ts; } // DECLARATIONS function parseArrayBindingElement() { - if (token() === 24 /* CommaToken */) { - return createNode(193 /* OmittedExpression */); + if (token() === 25 /* CommaToken */) { + return createNode(194 /* OmittedExpression */); } - var node = createNode(169 /* BindingElement */); - node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); + var node = createNode(170 /* BindingElement */); + node.dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(/*inParameter*/ false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(169 /* BindingElement */); + var node = createNode(170 /* BindingElement */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token() !== 54 /* ColonToken */) { + if (tokenIsIdentifier && token() !== 55 /* ColonToken */) { node.name = propertyName; } else { - parseExpected(54 /* ColonToken */); + parseExpected(55 /* ColonToken */); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -17123,33 +17177,33 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(167 /* ObjectBindingPattern */); - parseExpected(15 /* OpenBraceToken */); + var node = createNode(168 /* ObjectBindingPattern */); + parseExpected(16 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); - parseExpected(16 /* CloseBraceToken */); + parseExpected(17 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(168 /* ArrayBindingPattern */); - parseExpected(19 /* OpenBracketToken */); + var node = createNode(169 /* ArrayBindingPattern */); + parseExpected(20 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); - parseExpected(20 /* CloseBracketToken */); + parseExpected(21 /* CloseBracketToken */); return finishNode(node); } function isIdentifierOrPattern() { - return token() === 15 /* OpenBraceToken */ || token() === 19 /* OpenBracketToken */ || isIdentifier(); + return token() === 16 /* OpenBraceToken */ || token() === 20 /* OpenBracketToken */ || isIdentifier(); } function parseIdentifierOrPattern() { - if (token() === 19 /* OpenBracketToken */) { + if (token() === 20 /* OpenBracketToken */) { return parseArrayBindingPattern(); } - if (token() === 15 /* OpenBraceToken */) { + if (token() === 16 /* OpenBraceToken */) { return parseObjectBindingPattern(); } return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(218 /* VariableDeclaration */); + var node = createNode(219 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { @@ -17158,14 +17212,14 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(219 /* VariableDeclarationList */); + var node = createNode(220 /* VariableDeclarationList */); switch (token()) { - case 102 /* VarKeyword */: + case 103 /* VarKeyword */: break; - case 108 /* LetKeyword */: + case 109 /* LetKeyword */: node.flags |= 1 /* Let */; break; - case 74 /* ConstKeyword */: + case 75 /* ConstKeyword */: node.flags |= 2 /* Const */; break; default: @@ -17181,7 +17235,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() === 138 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 139 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -17193,10 +17247,10 @@ var ts; return finishNode(node); } function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 18 /* CloseParenToken */; + return nextTokenIsIdentifier() && nextToken() === 19 /* CloseParenToken */; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(200 /* VariableStatement */, fullStart); + var node = createNode(201 /* VariableStatement */, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); @@ -17204,29 +17258,29 @@ var ts; return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(220 /* FunctionDeclaration */, fullStart); + var node = createNode(221 /* FunctionDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(87 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); + parseExpected(88 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(38 /* AsteriskToken */); node.name = ts.hasModifier(node, 512 /* Default */) ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = !!node.asteriskToken; var isAsync = ts.hasModifier(node, 256 /* Async */); - fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); + fillSignature(55 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return addJSDocComment(finishNode(node)); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(148 /* Constructor */, pos); + var node = createNode(149 /* Constructor */, pos); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(121 /* ConstructorKeyword */); - fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + parseExpected(122 /* ConstructorKeyword */); + fillSignature(55 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false, ts.Diagnostics.or_expected); return addJSDocComment(finishNode(node)); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(147 /* MethodDeclaration */, fullStart); + var method = createNode(148 /* MethodDeclaration */, fullStart); method.decorators = decorators; method.modifiers = modifiers; method.asteriskToken = asteriskToken; @@ -17234,12 +17288,12 @@ var ts; method.questionToken = questionToken; var isGenerator = !!asteriskToken; var isAsync = ts.hasModifier(method, 256 /* Async */); - fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method); + fillSignature(55 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return addJSDocComment(finishNode(method)); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(145 /* PropertyDeclaration */, fullStart); + var property = createNode(146 /* PropertyDeclaration */, fullStart); property.decorators = decorators; property.modifiers = modifiers; property.name = name; @@ -17261,12 +17315,12 @@ var ts; return addJSDocComment(finishNode(property)); } function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { - var asteriskToken = parseOptionalToken(37 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(38 /* AsteriskToken */); 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(53 /* QuestionToken */); - if (asteriskToken || token() === 17 /* OpenParenToken */ || token() === 25 /* LessThanToken */) { + var questionToken = parseOptionalToken(54 /* QuestionToken */); + if (asteriskToken || token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); } else { @@ -17281,17 +17335,17 @@ var ts; node.decorators = decorators; node.modifiers = modifiers; node.name = parsePropertyName(); - fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + fillSignature(55 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false); return addJSDocComment(finishNode(node)); } function isClassMemberModifier(idToken) { switch (idToken) { - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - case 113 /* StaticKeyword */: - case 128 /* ReadonlyKeyword */: + case 113 /* PublicKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + case 114 /* StaticKeyword */: + case 129 /* ReadonlyKeyword */: return true; default: return false; @@ -17299,7 +17353,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token() === 55 /* AtToken */) { + if (token() === 56 /* AtToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. @@ -17316,7 +17370,7 @@ var ts; } nextToken(); } - if (token() === 37 /* AsteriskToken */) { + if (token() === 38 /* AsteriskToken */) { return true; } // Try to get the first property-like token following all modifiers. @@ -17326,23 +17380,23 @@ var ts; nextToken(); } // Index signatures and computed properties are class members; we can parse. - if (token() === 19 /* OpenBracketToken */) { + if (token() === 20 /* OpenBracketToken */) { return true; } // 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 === 131 /* SetKeyword */ || idToken === 123 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 132 /* SetKeyword */ || idToken === 124 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along // to see if it should actually be parsed as a class member. switch (token()) { - case 17 /* OpenParenToken */: // Method declaration - case 25 /* LessThanToken */: // Generic Method declaration - case 54 /* ColonToken */: // Type Annotation for declaration - case 56 /* EqualsToken */: // Initializer for declaration - case 53 /* QuestionToken */: + case 18 /* OpenParenToken */: // Method declaration + case 26 /* LessThanToken */: // Generic Method declaration + case 55 /* ColonToken */: // Type Annotation for declaration + case 57 /* EqualsToken */: // Initializer for declaration + case 54 /* QuestionToken */: return true; default: // Covers @@ -17359,10 +17413,10 @@ var ts; var decorators; while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(55 /* AtToken */)) { + if (!parseOptional(56 /* AtToken */)) { break; } - var decorator = createNode(143 /* Decorator */, decoratorStart); + var decorator = createNode(144 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); if (!decorators) { @@ -17389,7 +17443,7 @@ var ts; while (true) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); - if (token() === 74 /* ConstKeyword */ && permitInvalidConstAsModifier) { + if (token() === 75 /* ConstKeyword */ && permitInvalidConstAsModifier) { // We need to ensure that any subsequent modifiers appear on the same line // so that when 'const' is a standalone declaration, we don't issue an error. if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) { @@ -17416,7 +17470,7 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 118 /* AsyncKeyword */) { + if (token() === 119 /* AsyncKeyword */) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); nextToken(); @@ -17427,8 +17481,8 @@ var ts; return modifiers; } function parseClassElement() { - if (token() === 23 /* SemicolonToken */) { - var result = createNode(198 /* SemicolonClassElement */); + if (token() === 24 /* SemicolonToken */) { + var result = createNode(199 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -17439,7 +17493,7 @@ var ts; if (accessor) { return accessor; } - if (token() === 121 /* ConstructorKeyword */) { + if (token() === 122 /* ConstructorKeyword */) { return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { @@ -17450,13 +17504,13 @@ var ts; if (ts.tokenIsIdentifierOrKeyword(token()) || token() === 9 /* StringLiteral */ || token() === 8 /* NumericLiteral */ || - token() === 37 /* AsteriskToken */ || - token() === 19 /* OpenBracketToken */) { + token() === 38 /* AsteriskToken */ || + token() === 20 /* OpenBracketToken */) { return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { // treat this as a property declaration with a missing name. - var name_10 = createMissingNode(69 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var name_10 = createMissingNode(70 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(fullStart, decorators, modifiers, name_10, /*questionToken*/ undefined); } // 'isClassMemberStart' should have hinted not to attempt parsing. @@ -17466,24 +17520,24 @@ var ts; return parseClassDeclarationOrExpression( /*fullStart*/ scanner.getStartPos(), /*decorators*/ undefined, - /*modifiers*/ undefined, 192 /* ClassExpression */); + /*modifiers*/ undefined, 193 /* ClassExpression */); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 221 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 222 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(73 /* ClassKeyword */); + parseExpected(74 /* ClassKeyword */); node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); - node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ true); - if (parseExpected(15 /* OpenBraceToken */)) { + node.heritageClauses = parseHeritageClauses(); + if (parseExpected(16 /* OpenBraceToken */)) { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } node.members = parseClassMembers(); - parseExpected(16 /* CloseBraceToken */); + parseExpected(17 /* CloseBraceToken */); } else { node.members = createMissingList(); @@ -17501,9 +17555,9 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 106 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 107 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); } - function parseHeritageClauses(isClassHeritageClause) { + function parseHeritageClauses() { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } if (isHeritageClause()) { @@ -17512,7 +17566,7 @@ var ts; return undefined; } function parseHeritageClause() { - if (token() === 83 /* ExtendsKeyword */ || token() === 106 /* ImplementsKeyword */) { + if (token() === 84 /* ExtendsKeyword */ || token() === 107 /* ImplementsKeyword */) { var node = createNode(251 /* HeritageClause */); node.token = token(); nextToken(); @@ -17522,38 +17576,38 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(194 /* ExpressionWithTypeArguments */); + var node = createNode(195 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); - if (token() === 25 /* LessThanToken */) { - node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); + if (token() === 26 /* LessThanToken */) { + node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 26 /* LessThanToken */, 28 /* GreaterThanToken */); } return finishNode(node); } function isHeritageClause() { - return token() === 83 /* ExtendsKeyword */ || token() === 106 /* ImplementsKeyword */; + return token() === 84 /* ExtendsKeyword */ || token() === 107 /* ImplementsKeyword */; } function parseClassMembers() { return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(222 /* InterfaceDeclaration */, fullStart); + var node = createNode(223 /* InterfaceDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(107 /* InterfaceKeyword */); + parseExpected(108 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ false); + node.heritageClauses = parseHeritageClauses(); node.members = parseObjectTypeMembers(); return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(223 /* TypeAliasDeclaration */, fullStart); + var node = createNode(224 /* TypeAliasDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(134 /* TypeKeyword */); + parseExpected(135 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(56 /* EqualsToken */); + parseExpected(57 /* EqualsToken */); node.type = parseType(); parseSemicolon(); return addJSDocComment(finishNode(node)); @@ -17569,14 +17623,14 @@ var ts; return addJSDocComment(finishNode(node)); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(224 /* EnumDeclaration */, fullStart); + var node = createNode(225 /* EnumDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(81 /* EnumKeyword */); + parseExpected(82 /* EnumKeyword */); node.name = parseIdentifier(); - if (parseExpected(15 /* OpenBraceToken */)) { + if (parseExpected(16 /* OpenBraceToken */)) { node.members = parseDelimitedList(6 /* EnumMembers */, parseEnumMember); - parseExpected(16 /* CloseBraceToken */); + parseExpected(17 /* CloseBraceToken */); } else { node.members = createMissingList(); @@ -17584,10 +17638,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseModuleBlock() { - var node = createNode(226 /* ModuleBlock */, scanner.getStartPos()); - if (parseExpected(15 /* OpenBraceToken */)) { + var node = createNode(227 /* ModuleBlock */, scanner.getStartPos()); + if (parseExpected(16 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(16 /* CloseBraceToken */); + parseExpected(17 /* CloseBraceToken */); } else { node.statements = createMissingList(); @@ -17595,7 +17649,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(225 /* ModuleDeclaration */, fullStart); + var node = createNode(226 /* 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 & 16 /* Namespace */; @@ -17603,16 +17657,16 @@ var ts; node.modifiers = modifiers; node.flags |= flags; node.name = parseIdentifier(); - node.body = parseOptional(21 /* DotToken */) + node.body = parseOptional(22 /* DotToken */) ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, 4 /* NestedNamespace */ | namespaceFlag) : parseModuleBlock(); return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(225 /* ModuleDeclaration */, fullStart); + var node = createNode(226 /* ModuleDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (token() === 137 /* GlobalKeyword */) { + if (token() === 138 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); node.flags |= 512 /* GlobalAugmentation */; @@ -17620,7 +17674,7 @@ var ts; else { node.name = parseLiteralNode(/*internName*/ true); } - if (token() === 15 /* OpenBraceToken */) { + if (token() === 16 /* OpenBraceToken */) { node.body = parseModuleBlock(); } else { @@ -17630,15 +17684,15 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = 0; - if (token() === 137 /* GlobalKeyword */) { + if (token() === 138 /* GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } - else if (parseOptional(126 /* NamespaceKeyword */)) { + else if (parseOptional(127 /* NamespaceKeyword */)) { flags |= 16 /* Namespace */; } else { - parseExpected(125 /* ModuleKeyword */); + parseExpected(126 /* ModuleKeyword */); if (token() === 9 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -17646,57 +17700,57 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token() === 129 /* RequireKeyword */ && + return token() === 130 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { - return nextToken() === 17 /* OpenParenToken */; + return nextToken() === 18 /* OpenParenToken */; } function nextTokenIsSlash() { - return nextToken() === 39 /* SlashToken */; + return nextToken() === 40 /* SlashToken */; } function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { - var exportDeclaration = createNode(228 /* NamespaceExportDeclaration */, fullStart); + var exportDeclaration = createNode(229 /* NamespaceExportDeclaration */, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; - parseExpected(116 /* AsKeyword */); - parseExpected(126 /* NamespaceKeyword */); + parseExpected(117 /* AsKeyword */); + parseExpected(127 /* NamespaceKeyword */); exportDeclaration.name = parseIdentifier(); - parseExpected(23 /* SemicolonToken */); + parseExpected(24 /* SemicolonToken */); return finishNode(exportDeclaration); } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { - parseExpected(89 /* ImportKeyword */); + parseExpected(90 /* ImportKeyword */); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 24 /* CommaToken */ && token() !== 136 /* FromKeyword */) { + if (token() !== 25 /* CommaToken */ && token() !== 137 /* FromKeyword */) { // ImportEquals declaration of type: // import x = require("mod"); or // import x = M.x; - var importEqualsDeclaration = createNode(229 /* ImportEqualsDeclaration */, fullStart); + var importEqualsDeclaration = createNode(230 /* ImportEqualsDeclaration */, fullStart); importEqualsDeclaration.decorators = decorators; importEqualsDeclaration.modifiers = modifiers; importEqualsDeclaration.name = identifier; - parseExpected(56 /* EqualsToken */); + parseExpected(57 /* EqualsToken */); importEqualsDeclaration.moduleReference = parseModuleReference(); parseSemicolon(); return addJSDocComment(finishNode(importEqualsDeclaration)); } } // Import statement - var importDeclaration = createNode(230 /* ImportDeclaration */, fullStart); + var importDeclaration = createNode(231 /* ImportDeclaration */, fullStart); importDeclaration.decorators = decorators; importDeclaration.modifiers = modifiers; // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; if (identifier || - token() === 37 /* AsteriskToken */ || - token() === 15 /* OpenBraceToken */) { + token() === 38 /* AsteriskToken */ || + token() === 16 /* OpenBraceToken */) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(136 /* FromKeyword */); + parseExpected(137 /* FromKeyword */); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -17709,7 +17763,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(231 /* ImportClause */, fullStart); + var importClause = createNode(232 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -17718,8 +17772,8 @@ var ts; // If there was no default import or if there is comma token after default import // parse namespace or named imports if (!importClause.name || - parseOptional(24 /* CommaToken */)) { - importClause.namedBindings = token() === 37 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(233 /* NamedImports */); + parseOptional(25 /* CommaToken */)) { + importClause.namedBindings = token() === 38 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(234 /* NamedImports */); } return finishNode(importClause); } @@ -17729,11 +17783,11 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(240 /* ExternalModuleReference */); - parseExpected(129 /* RequireKeyword */); - parseExpected(17 /* OpenParenToken */); + var node = createNode(241 /* ExternalModuleReference */); + parseExpected(130 /* RequireKeyword */); + parseExpected(18 /* OpenParenToken */); node.expression = parseModuleSpecifier(); - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); return finishNode(node); } function parseModuleSpecifier() { @@ -17752,9 +17806,9 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(232 /* NamespaceImport */); - parseExpected(37 /* AsteriskToken */); - parseExpected(116 /* AsKeyword */); + var namespaceImport = createNode(233 /* NamespaceImport */); + parseExpected(38 /* AsteriskToken */); + parseExpected(117 /* AsKeyword */); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } @@ -17767,14 +17821,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 233 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 15 /* OpenBraceToken */, 16 /* CloseBraceToken */); + node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 234 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 16 /* OpenBraceToken */, 17 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(238 /* ExportSpecifier */); + return parseImportOrExportSpecifier(239 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(234 /* ImportSpecifier */); + return parseImportOrExportSpecifier(235 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -17788,9 +17842,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token() === 116 /* AsKeyword */) { + if (token() === 117 /* AsKeyword */) { node.propertyName = identifierName; - parseExpected(116 /* AsKeyword */); + parseExpected(117 /* AsKeyword */); checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -17799,27 +17853,27 @@ var ts; else { node.name = identifierName; } - if (kind === 234 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 235 /* 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(236 /* ExportDeclaration */, fullStart); + var node = createNode(237 /* ExportDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (parseOptional(37 /* AsteriskToken */)) { - parseExpected(136 /* FromKeyword */); + if (parseOptional(38 /* AsteriskToken */)) { + parseExpected(137 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(237 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(238 /* 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() === 136 /* FromKeyword */ || (token() === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(136 /* FromKeyword */); + if (token() === 137 /* FromKeyword */ || (token() === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(137 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -17827,14 +17881,14 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(235 /* ExportAssignment */, fullStart); + var node = createNode(236 /* ExportAssignment */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (parseOptional(56 /* EqualsToken */)) { + if (parseOptional(57 /* EqualsToken */)) { node.isExportEquals = true; } else { - parseExpected(77 /* DefaultKeyword */); + parseExpected(78 /* DefaultKeyword */); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -17909,10 +17963,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 229 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 240 /* ExternalModuleReference */ - || node.kind === 230 /* ImportDeclaration */ - || node.kind === 235 /* ExportAssignment */ - || node.kind === 236 /* ExportDeclaration */ + || node.kind === 230 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 241 /* ExternalModuleReference */ + || node.kind === 231 /* ImportDeclaration */ + || node.kind === 236 /* ExportAssignment */ + || node.kind === 237 /* ExportDeclaration */ ? node : undefined; }); @@ -17957,24 +18011,24 @@ var ts; (function (JSDocParser) { function isJSDocType() { switch (token()) { - case 37 /* AsteriskToken */: - case 53 /* QuestionToken */: - case 17 /* OpenParenToken */: - case 19 /* OpenBracketToken */: - case 49 /* ExclamationToken */: - case 15 /* OpenBraceToken */: - case 87 /* FunctionKeyword */: - case 22 /* DotDotDotToken */: - case 92 /* NewKeyword */: - case 97 /* ThisKeyword */: + case 38 /* AsteriskToken */: + case 54 /* QuestionToken */: + case 18 /* OpenParenToken */: + case 20 /* OpenBracketToken */: + case 50 /* ExclamationToken */: + case 16 /* OpenBraceToken */: + case 88 /* FunctionKeyword */: + case 23 /* DotDotDotToken */: + case 93 /* NewKeyword */: + case 98 /* ThisKeyword */: return true; } return ts.tokenIsIdentifierOrKeyword(token()); } JSDocParser.isJSDocType = isJSDocType; function parseJSDocTypeExpressionForTests(content, start, length) { - initializeState("file.js", content, 2 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); - sourceFile = createSourceFile("file.js", 2 /* Latest */, 1 /* JS */); + initializeState(content, 4 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); + sourceFile = createSourceFile("file.js", 4 /* Latest */, 1 /* JS */); scanner.setText(content, start, length); currentToken = scanner.scan(); var jsDocTypeExpression = parseJSDocTypeExpression(); @@ -17987,21 +18041,21 @@ var ts; /* @internal */ function parseJSDocTypeExpression() { var result = createNode(257 /* JSDocTypeExpression */, scanner.getTokenPos()); - parseExpected(15 /* OpenBraceToken */); + parseExpected(16 /* OpenBraceToken */); result.type = parseJSDocTopLevelType(); - parseExpected(16 /* CloseBraceToken */); + parseExpected(17 /* CloseBraceToken */); fixupParentReferences(result); return finishNode(result); } JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocTopLevelType() { var type = parseJSDocType(); - if (token() === 47 /* BarToken */) { + if (token() === 48 /* BarToken */) { var unionType = createNode(261 /* JSDocUnionType */, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } - if (token() === 56 /* EqualsToken */) { + if (token() === 57 /* EqualsToken */) { var optionalType = createNode(268 /* JSDocOptionalType */, type.pos); nextToken(); optionalType.type = type; @@ -18012,20 +18066,20 @@ var ts; function parseJSDocType() { var type = parseBasicTypeExpression(); while (true) { - if (token() === 19 /* OpenBracketToken */) { + if (token() === 20 /* OpenBracketToken */) { var arrayType = createNode(260 /* JSDocArrayType */, type.pos); arrayType.elementType = type; nextToken(); - parseExpected(20 /* CloseBracketToken */); + parseExpected(21 /* CloseBracketToken */); type = finishNode(arrayType); } - else if (token() === 53 /* QuestionToken */) { + else if (token() === 54 /* QuestionToken */) { var nullableType = createNode(263 /* JSDocNullableType */, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } - else if (token() === 49 /* ExclamationToken */) { + else if (token() === 50 /* ExclamationToken */) { var nonNullableType = createNode(264 /* JSDocNonNullableType */, type.pos); nonNullableType.type = type; nextToken(); @@ -18039,40 +18093,40 @@ var ts; } function parseBasicTypeExpression() { switch (token()) { - case 37 /* AsteriskToken */: + case 38 /* AsteriskToken */: return parseJSDocAllType(); - case 53 /* QuestionToken */: + case 54 /* QuestionToken */: return parseJSDocUnknownOrNullableType(); - case 17 /* OpenParenToken */: + case 18 /* OpenParenToken */: return parseJSDocUnionType(); - case 19 /* OpenBracketToken */: + case 20 /* OpenBracketToken */: return parseJSDocTupleType(); - case 49 /* ExclamationToken */: + case 50 /* ExclamationToken */: return parseJSDocNonNullableType(); - case 15 /* OpenBraceToken */: + case 16 /* OpenBraceToken */: return parseJSDocRecordType(); - case 87 /* FunctionKeyword */: + case 88 /* FunctionKeyword */: return parseJSDocFunctionType(); - case 22 /* DotDotDotToken */: + case 23 /* DotDotDotToken */: return parseJSDocVariadicType(); - case 92 /* NewKeyword */: + case 93 /* NewKeyword */: return parseJSDocConstructorType(); - case 97 /* ThisKeyword */: + case 98 /* ThisKeyword */: return parseJSDocThisType(); - case 117 /* AnyKeyword */: - case 132 /* StringKeyword */: - case 130 /* NumberKeyword */: - case 120 /* BooleanKeyword */: - case 133 /* SymbolKeyword */: - case 103 /* VoidKeyword */: - case 93 /* NullKeyword */: - case 135 /* UndefinedKeyword */: - case 127 /* NeverKeyword */: + case 118 /* AnyKeyword */: + case 133 /* StringKeyword */: + case 131 /* NumberKeyword */: + case 121 /* BooleanKeyword */: + case 134 /* SymbolKeyword */: + case 104 /* VoidKeyword */: + case 94 /* NullKeyword */: + case 136 /* UndefinedKeyword */: + case 128 /* NeverKeyword */: return parseTokenNode(); case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: + case 100 /* TrueKeyword */: + case 85 /* FalseKeyword */: return parseJSDocLiteralType(); } return parseJSDocTypeReference(); @@ -18080,14 +18134,14 @@ var ts; function parseJSDocThisType() { var result = createNode(272 /* JSDocThisType */); nextToken(); - parseExpected(54 /* ColonToken */); + parseExpected(55 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { var result = createNode(271 /* JSDocConstructorType */); nextToken(); - parseExpected(54 /* ColonToken */); + parseExpected(55 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } @@ -18100,34 +18154,34 @@ var ts; function parseJSDocFunctionType() { var result = createNode(269 /* JSDocFunctionType */); nextToken(); - parseExpected(17 /* OpenParenToken */); + parseExpected(18 /* OpenParenToken */); result.parameters = parseDelimitedList(22 /* JSDocFunctionParameters */, parseJSDocParameter); checkForTrailingComma(result.parameters); - parseExpected(18 /* CloseParenToken */); - if (token() === 54 /* ColonToken */) { + parseExpected(19 /* CloseParenToken */); + if (token() === 55 /* ColonToken */) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(142 /* Parameter */); + var parameter = createNode(143 /* Parameter */); parameter.type = parseJSDocType(); - if (parseOptional(56 /* EqualsToken */)) { + if (parseOptional(57 /* EqualsToken */)) { // TODO(rbuckton): Can this be changed to SyntaxKind.QuestionToken? - parameter.questionToken = createNode(56 /* EqualsToken */); + parameter.questionToken = createNode(57 /* EqualsToken */); } return finishNode(parameter); } function parseJSDocTypeReference() { var result = createNode(267 /* JSDocTypeReference */); result.name = parseSimplePropertyName(); - if (token() === 25 /* LessThanToken */) { + if (token() === 26 /* LessThanToken */) { result.typeArguments = parseTypeArguments(); } else { - while (parseOptional(21 /* DotToken */)) { - if (token() === 25 /* LessThanToken */) { + while (parseOptional(22 /* DotToken */)) { + if (token() === 26 /* LessThanToken */) { result.typeArguments = parseTypeArguments(); break; } @@ -18144,7 +18198,7 @@ var ts; var typeArguments = parseDelimitedList(23 /* JSDocTypeArguments */, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); - parseExpected(27 /* GreaterThanToken */); + parseExpected(28 /* GreaterThanToken */); return typeArguments; } function checkForEmptyTypeArgumentList(typeArguments) { @@ -18155,7 +18209,7 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(139 /* QualifiedName */, left.pos); + var result = createNode(140 /* QualifiedName */, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); @@ -18176,7 +18230,7 @@ var ts; nextToken(); result.types = parseDelimitedList(25 /* JSDocTupleTypes */, parseJSDocType); checkForTrailingComma(result.types); - parseExpected(20 /* CloseBracketToken */); + parseExpected(21 /* CloseBracketToken */); return finishNode(result); } function checkForTrailingComma(list) { @@ -18189,13 +18243,13 @@ var ts; var result = createNode(261 /* JSDocUnionType */); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); return finishNode(result); } function parseJSDocTypeList(firstType) { ts.Debug.assert(!!firstType); var types = createNodeArray([firstType], firstType.pos); - while (parseOptional(47 /* BarToken */)) { + while (parseOptional(48 /* BarToken */)) { types.push(parseJSDocType()); } types.end = scanner.getStartPos(); @@ -18224,12 +18278,12 @@ var ts; // Foo // Foo(?= // (?| - if (token() === 24 /* CommaToken */ || - token() === 16 /* CloseBraceToken */ || - token() === 18 /* CloseParenToken */ || - token() === 27 /* GreaterThanToken */ || - token() === 56 /* EqualsToken */ || - token() === 47 /* BarToken */) { + if (token() === 25 /* CommaToken */ || + token() === 17 /* CloseBraceToken */ || + token() === 19 /* CloseParenToken */ || + token() === 28 /* GreaterThanToken */ || + token() === 57 /* EqualsToken */ || + token() === 48 /* BarToken */) { var result = createNode(259 /* JSDocUnknownType */, pos); return finishNode(result); } @@ -18240,7 +18294,7 @@ var ts; } } function parseIsolatedJSDocComment(content, start, length) { - initializeState("file.js", content, 2 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); + initializeState(content, 4 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); sourceFile = { languageVariant: 0 /* Standard */, text: content }; var jsDoc = parseJSDocCommentWorker(start, length); var diagnostics = parseDiagnostics; @@ -18309,7 +18363,7 @@ var ts; } while (token() !== 1 /* EndOfFileToken */) { switch (token()) { - case 55 /* AtToken */: + case 56 /* AtToken */: if (state === 0 /* BeginningOfLine */ || state === 1 /* SawAsterisk */) { removeTrailingNewlines(comments); parseTag(indent); @@ -18330,7 +18384,7 @@ var ts; state = 0 /* BeginningOfLine */; indent = 0; break; - case 37 /* AsteriskToken */: + case 38 /* AsteriskToken */: var asterisk = scanner.getTokenText(); if (state === 1 /* SawAsterisk */) { // If we've already seen an asterisk, then we can no longer parse a tag on this line @@ -18343,7 +18397,7 @@ var ts; indent += asterisk.length; } break; - case 69 /* Identifier */: + case 70 /* Identifier */: // Anything else is doc comment text. We just save it. Because it // wasn't a tag, we can no longer parse a tag on this line until we hit the next // line break. @@ -18404,8 +18458,8 @@ var ts; } } function parseTag(indent) { - ts.Debug.assert(token() === 55 /* AtToken */); - var atToken = createNode(55 /* AtToken */, scanner.getTokenPos()); + ts.Debug.assert(token() === 56 /* AtToken */); + var atToken = createNode(56 /* AtToken */, scanner.getTokenPos()); atToken.end = scanner.getTextPos(); nextJSDocToken(); var tagName = parseJSDocIdentifierName(); @@ -18457,7 +18511,7 @@ var ts; comments.push(text); indent += text.length; } - while (token() !== 55 /* AtToken */ && token() !== 1 /* EndOfFileToken */) { + while (token() !== 56 /* AtToken */ && token() !== 1 /* EndOfFileToken */) { switch (token()) { case 4 /* NewLineTrivia */: if (state >= 1 /* SawAsterisk */) { @@ -18466,7 +18520,7 @@ var ts; } indent = 0; break; - case 55 /* AtToken */: + case 56 /* AtToken */: // Done break; case 5 /* WhitespaceTrivia */: @@ -18482,7 +18536,7 @@ var ts; indent += whitespace.length; } break; - case 37 /* AsteriskToken */: + case 38 /* AsteriskToken */: if (state === 0 /* BeginningOfLine */) { // leading asterisks start recording on the *next* (non-whitespace) token state = 1 /* SawAsterisk */; @@ -18495,7 +18549,7 @@ var ts; pushComment(scanner.getTokenText()); break; } - if (token() === 55 /* AtToken */) { + if (token() === 56 /* AtToken */) { // Done break; } @@ -18524,7 +18578,7 @@ var ts; function tryParseTypeExpression() { return tryParse(function () { skipWhitespace(); - if (token() !== 15 /* OpenBraceToken */) { + if (token() !== 16 /* OpenBraceToken */) { return undefined; } return parseJSDocTypeExpression(); @@ -18536,15 +18590,15 @@ var ts; var name; var isBracketed; // Looking for something like '[foo]' or 'foo' - if (parseOptionalToken(19 /* OpenBracketToken */)) { + if (parseOptionalToken(20 /* OpenBracketToken */)) { name = parseJSDocIdentifierName(); skipWhitespace(); isBracketed = true; // May have an optional default, e.g. '[foo = 42]' - if (parseOptionalToken(56 /* EqualsToken */)) { + if (parseOptionalToken(57 /* EqualsToken */)) { parseExpression(); } - parseExpected(20 /* CloseBracketToken */); + parseExpected(21 /* CloseBracketToken */); } else if (ts.tokenIsIdentifierOrKeyword(token())) { name = parseJSDocIdentifierName(); @@ -18621,7 +18675,7 @@ var ts; if (typeExpression) { if (typeExpression.type.kind === 267 /* JSDocTypeReference */) { var jsDocTypeReference = typeExpression.type; - if (jsDocTypeReference.name.kind === 69 /* Identifier */) { + if (jsDocTypeReference.name.kind === 70 /* Identifier */) { var name_11 = jsDocTypeReference.name; if (name_11.text === "Object") { typedefTag.jsDocTypeLiteral = scanChildTags(); @@ -18645,7 +18699,7 @@ var ts; while (token() !== 1 /* EndOfFileToken */ && !parentTagTerminated) { nextJSDocToken(); switch (token()) { - case 55 /* AtToken */: + case 56 /* AtToken */: if (canParseTag) { parentTagTerminated = !tryParseChildTag(jsDocTypeLiteral); if (!parentTagTerminated) { @@ -18659,13 +18713,13 @@ var ts; canParseTag = true; seenAsterisk = false; break; - case 37 /* AsteriskToken */: + case 38 /* AsteriskToken */: if (seenAsterisk) { canParseTag = false; } seenAsterisk = true; break; - case 69 /* Identifier */: + case 70 /* Identifier */: canParseTag = false; case 1 /* EndOfFileToken */: break; @@ -18676,8 +18730,8 @@ var ts; } } function tryParseChildTag(parentTag) { - ts.Debug.assert(token() === 55 /* AtToken */); - var atToken = createNode(55 /* AtToken */, scanner.getStartPos()); + ts.Debug.assert(token() === 56 /* AtToken */); + var atToken = createNode(56 /* AtToken */, scanner.getStartPos()); atToken.end = scanner.getTextPos(); nextJSDocToken(); var tagName = parseJSDocIdentifierName(); @@ -18717,11 +18771,11 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(141 /* TypeParameter */, name_12.pos); + var typeParameter = createNode(142 /* TypeParameter */, name_12.pos); typeParameter.name = name_12; finishNode(typeParameter); typeParameters.push(typeParameter); - if (token() === 24 /* CommaToken */) { + if (token() === 25 /* CommaToken */) { nextJSDocToken(); skipWhitespace(); } @@ -18750,7 +18804,7 @@ var ts; } var pos = scanner.getTokenPos(); var end = scanner.getTextPos(); - var result = createNode(69 /* Identifier */, pos); + var result = createNode(70 /* Identifier */, pos); result.text = content.substring(pos, end); finishNode(result, end); nextJSDocToken(); @@ -18868,8 +18922,8 @@ var ts; array._children = undefined; array.pos += delta; array.end += delta; - for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { - var node = array_8[_i]; + for (var _i = 0, array_9 = array; _i < array_9.length; _i++) { + var node = array_9[_i]; visitNode(node); } } @@ -18878,7 +18932,7 @@ var ts; switch (node.kind) { case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - case 69 /* Identifier */: + case 70 /* Identifier */: return true; } return false; @@ -19006,8 +19060,8 @@ var ts; array._children = undefined; // Adjust the pos or end (or both) of the intersecting array accordingly. adjustIntersectingElement(array, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta); - for (var _i = 0, array_9 = array; _i < array_9.length; _i++) { - var node = array_9[_i]; + for (var _i = 0, array_10 = array; _i < array_10.length; _i++) { + var node = array_10[_i]; visitNode(node); } return; @@ -19249,16 +19303,16 @@ var ts; function getModuleInstanceState(node) { // A module is uninstantiated if it contains only // 1. interface declarations, type alias declarations - if (node.kind === 222 /* InterfaceDeclaration */ || node.kind === 223 /* TypeAliasDeclaration */) { + if (node.kind === 223 /* InterfaceDeclaration */ || node.kind === 224 /* TypeAliasDeclaration */) { return 0 /* NonInstantiated */; } else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if ((node.kind === 230 /* ImportDeclaration */ || node.kind === 229 /* ImportEqualsDeclaration */) && !(ts.hasModifier(node, 1 /* Export */))) { + else if ((node.kind === 231 /* ImportDeclaration */ || node.kind === 230 /* ImportEqualsDeclaration */) && !(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } - else if (node.kind === 226 /* ModuleBlock */) { + else if (node.kind === 227 /* ModuleBlock */) { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -19277,7 +19331,7 @@ var ts; }); return state_1; } - else if (node.kind === 225 /* ModuleDeclaration */) { + else if (node.kind === 226 /* ModuleDeclaration */) { var body = node.body; return body ? getModuleInstanceState(body) : 1 /* Instantiated */; } @@ -19415,7 +19469,7 @@ var ts; if (symbolFlags & 107455 /* Value */) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 225 /* ModuleDeclaration */)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 226 /* ModuleDeclaration */)) { // other kinds of value declarations take precedence over modules symbol.valueDeclaration = node; } @@ -19428,7 +19482,7 @@ var ts; if (ts.isAmbientModule(node)) { return ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + node.name.text + "\""; } - if (node.name.kind === 140 /* ComputedPropertyName */) { + if (node.name.kind === 141 /* ComputedPropertyName */) { var nameExpression = node.name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteral(nameExpression.kind)) { @@ -19440,21 +19494,21 @@ var ts; return node.name.text; } switch (node.kind) { - case 148 /* Constructor */: + case 149 /* Constructor */: return "__constructor"; - case 156 /* FunctionType */: - case 151 /* CallSignature */: + case 157 /* FunctionType */: + case 152 /* CallSignature */: return "__call"; - case 157 /* ConstructorType */: - case 152 /* ConstructSignature */: + case 158 /* ConstructorType */: + case 153 /* ConstructSignature */: return "__new"; - case 153 /* IndexSignature */: + case 154 /* IndexSignature */: return "__index"; - case 236 /* ExportDeclaration */: + case 237 /* ExportDeclaration */: return "__export"; - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: return node.isExportEquals ? "export=" : "default"; - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: switch (ts.getSpecialPropertyAssignmentKind(node)) { case 2 /* ModuleExports */: // module.exports = ... @@ -19469,12 +19523,12 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 220 /* FunctionDeclaration */: - case 221 /* ClassDeclaration */: + case 221 /* FunctionDeclaration */: + case 222 /* ClassDeclaration */: return ts.hasModifier(node, 512 /* Default */) ? "default" : undefined; case 269 /* JSDocFunctionType */: return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; - case 142 /* Parameter */: + case 143 /* Parameter */: // Parameters with names are handled at the top of this function. Parameters // without names can only come from JSDocFunctionTypes. ts.Debug.assert(node.parent.kind === 269 /* JSDocFunctionType */); @@ -19484,10 +19538,10 @@ var ts; case 279 /* JSDocTypedefTag */: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 200 /* VariableStatement */) { + if (parentNode && parentNode.kind === 201 /* VariableStatement */) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; - if (nameIdentifier.kind === 69 /* Identifier */) { + if (nameIdentifier.kind === 70 /* Identifier */) { nameFromParentNode = nameIdentifier.text; } } @@ -19571,7 +19625,7 @@ var ts; // 1. multiple export default of class declaration or function declaration by checking NodeFlags.Default // 2. multiple export default of export assignment. This one doesn't have NodeFlags.Default on (as export default doesn't considered as modifiers) if (symbol.declarations && symbol.declarations.length && - (isDefaultExport || (node.kind === 235 /* ExportAssignment */ && !node.isExportEquals))) { + (isDefaultExport || (node.kind === 236 /* ExportAssignment */ && !node.isExportEquals))) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -19591,7 +19645,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 8388608 /* Alias */) { - if (node.kind === 238 /* ExportSpecifier */ || (node.kind === 229 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 239 /* ExportSpecifier */ || (node.kind === 230 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -19753,64 +19807,64 @@ var ts; return; } switch (node.kind) { - case 205 /* WhileStatement */: + case 206 /* WhileStatement */: bindWhileStatement(node); break; - case 204 /* DoStatement */: + case 205 /* DoStatement */: bindDoStatement(node); break; - case 206 /* ForStatement */: + case 207 /* ForStatement */: bindForStatement(node); break; - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 203 /* IfStatement */: + case 204 /* IfStatement */: bindIfStatement(node); break; - case 211 /* ReturnStatement */: - case 215 /* ThrowStatement */: + case 212 /* ReturnStatement */: + case 216 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 210 /* BreakStatement */: - case 209 /* ContinueStatement */: + case 211 /* BreakStatement */: + case 210 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 216 /* TryStatement */: + case 217 /* TryStatement */: bindTryStatement(node); break; - case 213 /* SwitchStatement */: + case 214 /* SwitchStatement */: bindSwitchStatement(node); break; - case 227 /* CaseBlock */: + case 228 /* CaseBlock */: bindCaseBlock(node); break; case 249 /* CaseClause */: bindCaseClause(node); break; - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: bindLabeledStatement(node); break; - case 185 /* PrefixUnaryExpression */: + case 186 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 186 /* PostfixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: bindBinaryExpressionFlow(node); break; - case 181 /* DeleteExpression */: + case 182 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 218 /* VariableDeclaration */: + case 219 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 174 /* CallExpression */: + case 175 /* CallExpression */: bindCallExpressionFlow(node); break; default: @@ -19820,25 +19874,25 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 69 /* Identifier */: - case 97 /* ThisKeyword */: - case 172 /* PropertyAccessExpression */: + case 70 /* Identifier */: + case 98 /* ThisKeyword */: + case 173 /* PropertyAccessExpression */: return isNarrowableReference(expr); - case 174 /* CallExpression */: + case 175 /* CallExpression */: return hasNarrowableArgument(expr); - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return isNarrowingExpression(expr.expression); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 185 /* PrefixUnaryExpression */: - return expr.operator === 49 /* ExclamationToken */ && isNarrowingExpression(expr.operand); + case 186 /* PrefixUnaryExpression */: + return expr.operator === 50 /* ExclamationToken */ && isNarrowingExpression(expr.operand); } return false; } function isNarrowableReference(expr) { - return expr.kind === 69 /* Identifier */ || - expr.kind === 97 /* ThisKeyword */ || - expr.kind === 172 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); + return expr.kind === 70 /* Identifier */ || + expr.kind === 98 /* ThisKeyword */ || + expr.kind === 173 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -19849,41 +19903,41 @@ var ts; } } } - if (expr.expression.kind === 172 /* PropertyAccessExpression */ && + if (expr.expression.kind === 173 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression.expression)) { return true; } return false; } function isNarrowingTypeofOperands(expr1, expr2) { - return expr1.kind === 182 /* TypeOfExpression */ && isNarrowableOperand(expr1.expression) && expr2.kind === 9 /* StringLiteral */; + return expr1.kind === 183 /* TypeOfExpression */ && isNarrowableOperand(expr1.expression) && expr2.kind === 9 /* StringLiteral */; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 56 /* EqualsToken */: + case 57 /* EqualsToken */: return isNarrowableReference(expr.left); - case 30 /* EqualsEqualsToken */: - case 31 /* ExclamationEqualsToken */: - case 32 /* EqualsEqualsEqualsToken */: - case 33 /* ExclamationEqualsEqualsToken */: + case 31 /* EqualsEqualsToken */: + case 32 /* ExclamationEqualsToken */: + case 33 /* EqualsEqualsEqualsToken */: + case 34 /* ExclamationEqualsEqualsToken */: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 91 /* InstanceOfKeyword */: + case 92 /* InstanceOfKeyword */: return isNarrowableOperand(expr.left); - case 24 /* CommaToken */: + case 25 /* CommaToken */: return isNarrowingExpression(expr.right); } return false; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: switch (expr.operatorToken.kind) { - case 56 /* EqualsToken */: + case 57 /* EqualsToken */: return isNarrowableOperand(expr.left); - case 24 /* CommaToken */: + case 25 /* CommaToken */: return isNarrowableOperand(expr.right); } } @@ -19903,7 +19957,7 @@ var ts; } function setFlowNodeReferenced(flow) { // On first reference we set the Referenced flag, thereafter we set the Shared flag - flow.flags |= flow.flags & 256 /* Referenced */ ? 512 /* Shared */ : 256 /* Referenced */; + flow.flags |= flow.flags & 512 /* Referenced */ ? 1024 /* Shared */ : 512 /* Referenced */; } function addAntecedent(label, antecedent) { if (!(antecedent.flags & 1 /* Unreachable */) && !ts.contains(label.antecedents, antecedent)) { @@ -19918,8 +19972,8 @@ var ts; if (!expression) { return flags & 32 /* TrueCondition */ ? antecedent : unreachableFlow; } - if (expression.kind === 99 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || - expression.kind === 84 /* FalseKeyword */ && flags & 32 /* TrueCondition */) { + if (expression.kind === 100 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || + expression.kind === 85 /* FalseKeyword */ && flags & 32 /* TrueCondition */) { return unreachableFlow; } if (!isNarrowingExpression(expression)) { @@ -19953,6 +20007,14 @@ var ts; node: node }; } + function createFlowArrayMutation(antecedent, node) { + setFlowNodeReferenced(antecedent); + return { + flags: 256 /* ArrayMutation */, + antecedent: antecedent, + node: node + }; + } function finishFlowLabel(flow) { var antecedents = flow.antecedents; if (!antecedents) { @@ -19966,34 +20028,34 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 203 /* IfStatement */: - case 205 /* WhileStatement */: - case 204 /* DoStatement */: + case 204 /* IfStatement */: + case 206 /* WhileStatement */: + case 205 /* DoStatement */: return parent.expression === node; - case 206 /* ForStatement */: - case 188 /* ConditionalExpression */: + case 207 /* ForStatement */: + case 189 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 178 /* ParenthesizedExpression */) { + if (node.kind === 179 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 185 /* PrefixUnaryExpression */ && node.operator === 49 /* ExclamationToken */) { + else if (node.kind === 186 /* PrefixUnaryExpression */ && node.operator === 50 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 187 /* BinaryExpression */ && (node.operatorToken.kind === 51 /* AmpersandAmpersandToken */ || - node.operatorToken.kind === 52 /* BarBarToken */); + return node.kind === 188 /* BinaryExpression */ && (node.operatorToken.kind === 52 /* AmpersandAmpersandToken */ || + node.operatorToken.kind === 53 /* BarBarToken */); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 178 /* ParenthesizedExpression */ || - node.parent.kind === 185 /* PrefixUnaryExpression */ && - node.parent.operator === 49 /* ExclamationToken */) { + while (node.parent.kind === 179 /* ParenthesizedExpression */ || + node.parent.kind === 186 /* PrefixUnaryExpression */ && + node.parent.operator === 50 /* ExclamationToken */) { node = node.parent; } return !isStatementCondition(node) && !isLogicalExpression(node.parent); @@ -20066,7 +20128,7 @@ var ts; bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 219 /* VariableDeclarationList */) { + if (node.initializer.kind !== 220 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -20088,7 +20150,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 211 /* ReturnStatement */) { + if (node.kind === 212 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -20108,7 +20170,7 @@ var ts; return undefined; } function bindbreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 210 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 211 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -20128,24 +20190,41 @@ var ts; } } function bindTryStatement(node) { - var postFinallyLabel = createBranchLabel(); + var preFinallyLabel = createBranchLabel(); var preTryFlow = currentFlow; // TODO: Every statement in try block is potentially an exit point! bind(node.tryBlock); - addAntecedent(postFinallyLabel, currentFlow); + addAntecedent(preFinallyLabel, currentFlow); + var flowAfterTry = currentFlow; + var flowAfterCatch = unreachableFlow; if (node.catchClause) { currentFlow = preTryFlow; bind(node.catchClause); - addAntecedent(postFinallyLabel, currentFlow); + addAntecedent(preFinallyLabel, currentFlow); + flowAfterCatch = currentFlow; } if (node.finallyBlock) { - currentFlow = preTryFlow; + // in finally flow is combined from pre-try/flow from try/flow from catch + // pre-flow is necessary to make sure that finally is reachable even if finally flows in both try and finally blocks are unreachable + addAntecedent(preFinallyLabel, preTryFlow); + currentFlow = finishFlowLabel(preFinallyLabel); bind(node.finallyBlock); + // if flow after finally is unreachable - keep it + // otherwise check if flows after try and after catch are unreachable + // if yes - convert current flow to unreachable + // i.e. + // try { return "1" } finally { console.log(1); } + // console.log(2); // this line should be unreachable even if flow falls out of finally block + if (!(currentFlow.flags & 1 /* Unreachable */)) { + if ((flowAfterTry.flags & 1 /* Unreachable */) && (flowAfterCatch.flags & 1 /* Unreachable */)) { + currentFlow = flowAfterTry === reportedUnreachableFlow || flowAfterCatch === reportedUnreachableFlow + ? reportedUnreachableFlow + : unreachableFlow; + } + } } - // if try statement has finally block and flow after finally block is unreachable - keep it - // otherwise use whatever flow was accumulated at postFinallyLabel - if (!node.finallyBlock || !(currentFlow.flags & 1 /* Unreachable */)) { - currentFlow = finishFlowLabel(postFinallyLabel); + else { + currentFlow = finishFlowLabel(preFinallyLabel); } } function bindSwitchStatement(node) { @@ -20224,7 +20303,7 @@ var ts; currentFlow = finishFlowLabel(postStatementLabel); } function bindDestructuringTargetFlow(node) { - if (node.kind === 187 /* BinaryExpression */ && node.operatorToken.kind === 56 /* EqualsToken */) { + if (node.kind === 188 /* BinaryExpression */ && node.operatorToken.kind === 57 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -20235,10 +20314,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 170 /* ArrayLiteralExpression */) { + else if (node.kind === 171 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 191 /* SpreadElementExpression */) { + if (e.kind === 192 /* SpreadElementExpression */) { bindAssignmentTargetFlow(e.expression); } else { @@ -20246,7 +20325,7 @@ var ts; } } } - else if (node.kind === 171 /* ObjectLiteralExpression */) { + else if (node.kind === 172 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; if (p.kind === 253 /* PropertyAssignment */) { @@ -20260,7 +20339,7 @@ var ts; } function bindLogicalExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 51 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 52 /* AmpersandAmpersandToken */) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -20271,7 +20350,7 @@ var ts; bindCondition(node.right, trueTarget, falseTarget); } function bindPrefixUnaryExpressionFlow(node) { - if (node.operator === 49 /* ExclamationToken */) { + if (node.operator === 50 /* ExclamationToken */) { var saveTrueTarget = currentTrueTarget; currentTrueTarget = currentFalseTarget; currentFalseTarget = saveTrueTarget; @@ -20281,20 +20360,20 @@ var ts; } else { ts.forEachChild(node, bind); - if (node.operator === 41 /* PlusPlusToken */ || node.operator === 42 /* MinusMinusToken */) { + if (node.operator === 42 /* PlusPlusToken */ || node.operator === 43 /* MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } } function bindPostfixUnaryExpressionFlow(node) { ts.forEachChild(node, bind); - if (node.operator === 41 /* PlusPlusToken */ || node.operator === 42 /* MinusMinusToken */) { + if (node.operator === 42 /* PlusPlusToken */ || node.operator === 43 /* MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } function bindBinaryExpressionFlow(node) { var operator = node.operatorToken.kind; - if (operator === 51 /* AmpersandAmpersandToken */ || operator === 52 /* BarBarToken */) { + if (operator === 52 /* AmpersandAmpersandToken */ || operator === 53 /* BarBarToken */) { if (isTopLevelLogicalExpression(node)) { var postExpressionLabel = createBranchLabel(); bindLogicalExpression(node, postExpressionLabel, postExpressionLabel); @@ -20306,14 +20385,20 @@ var ts; } else { ts.forEachChild(node, bind); - if (operator === 56 /* EqualsToken */ && !ts.isAssignmentTarget(node)) { + if (operator === 57 /* EqualsToken */ && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); + if (node.left.kind === 174 /* ElementAccessExpression */) { + var elementAccess = node.left; + if (isNarrowableOperand(elementAccess.expression)) { + currentFlow = createFlowArrayMutation(currentFlow, node); + } + } } } } function bindDeleteExpressionFlow(node) { ts.forEachChild(node, bind); - if (node.expression.kind === 172 /* PropertyAccessExpression */) { + if (node.expression.kind === 173 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -20344,7 +20429,7 @@ var ts; } function bindVariableDeclarationFlow(node) { ts.forEachChild(node, bind); - if (node.initializer || node.parent.parent.kind === 207 /* ForInStatement */ || node.parent.parent.kind === 208 /* ForOfStatement */) { + if (node.initializer || node.parent.parent.kind === 208 /* ForInStatement */ || node.parent.parent.kind === 209 /* ForOfStatement */) { bindInitializedVariableFlow(node); } } @@ -20353,10 +20438,10 @@ var ts; // an immediately invoked function expression (IIFE). Initialize the flowNode property to // the current control flow (which includes evaluation of the IIFE arguments). var expr = node.expression; - while (expr.kind === 178 /* ParenthesizedExpression */) { + while (expr.kind === 179 /* ParenthesizedExpression */) { expr = expr.expression; } - if (expr.kind === 179 /* FunctionExpression */ || expr.kind === 180 /* ArrowFunction */) { + if (expr.kind === 180 /* FunctionExpression */ || expr.kind === 181 /* ArrowFunction */) { ts.forEach(node.typeArguments, bind); ts.forEach(node.arguments, bind); bind(node.expression); @@ -20364,54 +20449,60 @@ var ts; else { ts.forEachChild(node, bind); } + if (node.expression.kind === 173 /* PropertyAccessExpression */) { + var propertyAccess = node.expression; + if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { + currentFlow = createFlowArrayMutation(currentFlow, node); + } + } } function getContainerFlags(node) { switch (node.kind) { - case 192 /* ClassExpression */: - case 221 /* ClassDeclaration */: - case 224 /* EnumDeclaration */: - case 171 /* ObjectLiteralExpression */: - case 159 /* TypeLiteral */: + case 193 /* ClassExpression */: + case 222 /* ClassDeclaration */: + case 225 /* EnumDeclaration */: + case 172 /* ObjectLiteralExpression */: + case 160 /* TypeLiteral */: case 281 /* JSDocTypeLiteral */: case 265 /* JSDocRecordType */: return 1 /* IsContainer */; - case 222 /* InterfaceDeclaration */: + case 223 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; case 269 /* JSDocFunctionType */: - case 225 /* ModuleDeclaration */: - case 223 /* TypeAliasDeclaration */: + case 226 /* ModuleDeclaration */: + case 224 /* TypeAliasDeclaration */: return 1 /* IsContainer */ | 32 /* HasLocals */; case 256 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 147 /* MethodDeclaration */: + case 148 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } - case 148 /* Constructor */: - case 220 /* FunctionDeclaration */: - case 146 /* MethodSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: - case 156 /* FunctionType */: - case 157 /* ConstructorType */: + case 149 /* Constructor */: + case 221 /* FunctionDeclaration */: + case 147 /* MethodSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 226 /* ModuleBlock */: + case 227 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; case 252 /* CatchClause */: - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: - case 227 /* CaseBlock */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: + case 228 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 199 /* Block */: + case 200 /* 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. Otherwise 'x' // would not appear to be a redeclaration of a block scoped local in the following @@ -20448,18 +20539,18 @@ 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 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); case 256 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 192 /* ClassExpression */: - case 221 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 222 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 159 /* TypeLiteral */: - case 171 /* ObjectLiteralExpression */: - case 222 /* InterfaceDeclaration */: + case 160 /* TypeLiteral */: + case 172 /* ObjectLiteralExpression */: + case 223 /* InterfaceDeclaration */: case 265 /* JSDocRecordType */: case 281 /* JSDocTypeLiteral */: // Interface/Object-types always have their children added to the 'members' of @@ -20468,21 +20559,21 @@ var ts; // 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 156 /* FunctionType */: - case 157 /* ConstructorType */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: case 269 /* JSDocFunctionType */: - case 223 /* TypeAliasDeclaration */: + case 224 /* 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 @@ -20504,10 +20595,10 @@ var ts; } function hasExportDeclarations(node) { var body = node.kind === 256 /* SourceFile */ ? node : node.body; - if (body && (body.kind === 256 /* SourceFile */ || body.kind === 226 /* ModuleBlock */)) { + if (body && (body.kind === 256 /* SourceFile */ || body.kind === 227 /* ModuleBlock */)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 236 /* ExportDeclaration */ || stat.kind === 235 /* ExportAssignment */) { + if (stat.kind === 237 /* ExportDeclaration */ || stat.kind === 236 /* ExportAssignment */) { return true; } } @@ -20600,7 +20691,7 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.name.kind !== 69 /* Identifier */) { + if (prop.name.kind !== 70 /* Identifier */) { continue; } var identifier = prop.name; @@ -20612,7 +20703,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 === 253 /* PropertyAssignment */ || prop.kind === 254 /* ShorthandPropertyAssignment */ || prop.kind === 147 /* MethodDeclaration */ + var currentKind = prop.kind === 253 /* PropertyAssignment */ || prop.kind === 254 /* ShorthandPropertyAssignment */ || prop.kind === 148 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen[identifier.text]; @@ -20634,7 +20725,7 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; case 256 /* SourceFile */: @@ -20658,8 +20749,8 @@ var ts; // check for reserved words used as identifiers in strict mode code. function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 106 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 114 /* LastFutureReservedWord */ && + node.originalKeywordKind >= 107 /* FirstFutureReservedWord */ && + node.originalKeywordKind <= 115 /* LastFutureReservedWord */ && !ts.isIdentifierName(node) && !ts.isInAmbientContext(node)) { // Report error only if there are no parse errors in file @@ -20695,7 +20786,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 69 /* Identifier */) { + if (inStrictMode && node.expression.kind === 70 /* 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_2 = ts.getErrorSpanForNode(file, node.expression); @@ -20703,11 +20794,11 @@ var ts; } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 69 /* Identifier */ && + return node.kind === 70 /* Identifier */ && (node.text === "eval" || node.text === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 69 /* Identifier */) { + if (name && name.kind === 70 /* 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 @@ -20746,10 +20837,10 @@ var ts; return ts.Diagnostics.Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5; } function checkStrictModeFunctionDeclaration(node) { - if (languageVersion < 2 /* ES6 */) { + if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration if (blockScopeContainer.kind !== 256 /* SourceFile */ && - blockScopeContainer.kind !== 225 /* ModuleDeclaration */ && + blockScopeContainer.kind !== 226 /* ModuleDeclaration */ && !ts.isFunctionLike(blockScopeContainer)) { // We check first if the name is inside class declaration or class expression; if so give explicit message // otherwise report generic error message. @@ -20775,7 +20866,7 @@ var ts; function checkStrictModePrefixUnaryExpression(node) { // Grammar checking if (inStrictMode) { - if (node.operator === 41 /* PlusPlusToken */ || node.operator === 42 /* MinusMinusToken */) { + if (node.operator === 42 /* PlusPlusToken */ || node.operator === 43 /* MinusMinusToken */) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -20815,7 +20906,7 @@ var ts; // the current 'container' node when it changes. This helps us know which symbol table // a local should go into for example. Since terminal nodes are known not to have // children, as an optimization we don't process those. - if (node.kind > 138 /* LastToken */) { + if (node.kind > 139 /* LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -20856,18 +20947,18 @@ var ts; function bindWorker(node) { switch (node.kind) { /* Strict mode checks */ - case 69 /* Identifier */: - case 97 /* ThisKeyword */: + case 70 /* Identifier */: + case 98 /* ThisKeyword */: if (currentFlow && (ts.isExpression(node) || parent.kind === 254 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } break; - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: if (ts.isInJavaScriptFile(node)) { var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { @@ -20893,30 +20984,30 @@ var ts; return checkStrictModeBinaryExpression(node); case 252 /* CatchClause */: return checkStrictModeCatchClause(node); - case 181 /* DeleteExpression */: + case 182 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 186 /* PostfixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 185 /* PrefixUnaryExpression */: + case 186 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 212 /* WithStatement */: + case 213 /* WithStatement */: return checkStrictModeWithStatement(node); - case 165 /* ThisType */: + case 166 /* ThisType */: seenThisKeyword = true; return; - case 154 /* TypePredicate */: + case 155 /* TypePredicate */: return checkTypePredicate(node); - case 141 /* TypeParameter */: + case 142 /* TypeParameter */: return declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 530920 /* TypeParameterExcludes */); - case 142 /* Parameter */: + case 143 /* Parameter */: return bindParameter(node); - case 218 /* VariableDeclaration */: - case 169 /* BindingElement */: + case 219 /* VariableDeclaration */: + case 170 /* BindingElement */: return bindVariableDeclarationOrBindingElement(node); - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: case 266 /* JSDocRecordMember */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); case 280 /* JSDocPropertyTag */: @@ -20929,90 +21020,90 @@ var ts; case 247 /* JsxSpreadAttribute */: emitFlags |= 16384 /* HasJsxSpreadAttributes */; return; - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 148 /* MethodDeclaration */: + case 147 /* 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) ? 0 /* PropertyExcludes */ : 99263 /* MethodExcludes */); - case 220 /* FunctionDeclaration */: + case 221 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 148 /* Constructor */: + case 149 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 149 /* GetAccessor */: + case 150 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 41919 /* GetAccessorExcludes */); - case 150 /* SetAccessor */: + case 151 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */); - case 156 /* FunctionType */: - case 157 /* ConstructorType */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: case 269 /* JSDocFunctionType */: return bindFunctionOrConstructorType(node); - case 159 /* TypeLiteral */: + case 160 /* TypeLiteral */: case 281 /* JSDocTypeLiteral */: case 265 /* JSDocRecordType */: return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type"); - case 171 /* ObjectLiteralExpression */: + case 172 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: return bindFunctionExpression(node); - case 174 /* CallExpression */: + case 175 /* CallExpression */: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; // Members of classes, interfaces, and modules - case 192 /* ClassExpression */: - case 221 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 222 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 222 /* InterfaceDeclaration */: + case 223 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 792968 /* InterfaceExcludes */); case 279 /* JSDocTypedefTag */: - case 223 /* TypeAliasDeclaration */: + case 224 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793064 /* TypeAliasExcludes */); - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Imports and exports - case 229 /* ImportEqualsDeclaration */: - case 232 /* NamespaceImport */: - case 234 /* ImportSpecifier */: - case 238 /* ExportSpecifier */: + case 230 /* ImportEqualsDeclaration */: + case 233 /* NamespaceImport */: + case 235 /* ImportSpecifier */: + case 239 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); - case 228 /* NamespaceExportDeclaration */: + case 229 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 231 /* ImportClause */: + case 232 /* ImportClause */: return bindImportClause(node); - case 236 /* ExportDeclaration */: + case 237 /* ExportDeclaration */: return bindExportDeclaration(node); - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: return bindExportAssignment(node); case 256 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 199 /* Block */: + case 200 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // Fall through - case 226 /* ModuleBlock */: + case 227 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); } } function checkTypePredicate(node) { var parameterName = node.parameterName, type = node.type; - if (parameterName && parameterName.kind === 69 /* Identifier */) { + if (parameterName && parameterName.kind === 70 /* Identifier */) { checkStrictModeIdentifier(parameterName); } - if (parameterName && parameterName.kind === 165 /* ThisType */) { + if (parameterName && parameterName.kind === 166 /* ThisType */) { seenThisKeyword = true; } bind(type); @@ -21035,7 +21126,7 @@ var ts; // An export default clause with an expression exports a value // We want to exclude both class and function here, this is necessary to issue an error when there are both // default export-assignment and default export function and class declaration. - var flags = node.kind === 235 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 236 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) ? 8388608 /* Alias */ : 4 /* Property */; declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 /* Property */ | 8388608 /* AliasExcludes */ | 32 /* Class */ | 16 /* Function */); @@ -21081,7 +21172,9 @@ var ts; function setCommonJsModuleIndicator(node) { if (!file.commonJsModuleIndicator) { file.commonJsModuleIndicator = node; - bindSourceFileAsExternalModule(); + if (!file.externalModuleIndicator) { + bindSourceFileAsExternalModule(); + } } } function bindExportsPropertyAssignment(node) { @@ -21098,12 +21191,12 @@ var ts; function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJavaScriptFile(node)); // Declare a 'member' if the container is an ES5 class or ES6 constructor - if (container.kind === 220 /* FunctionDeclaration */ || container.kind === 179 /* FunctionExpression */) { + if (container.kind === 221 /* FunctionDeclaration */ || container.kind === 180 /* FunctionExpression */) { container.symbol.members = container.symbol.members || ts.createMap(); // It's acceptable for multiple 'this' assignments of the same identifier to occur declareSymbol(container.symbol.members, container.symbol, node, 4 /* Property */, 0 /* PropertyExcludes */ & ~4 /* Property */); } - else if (container.kind === 148 /* Constructor */) { + else if (container.kind === 149 /* Constructor */) { // this.foo assignment in a JavaScript class // Bind this property to the containing class var saveContainer = container; @@ -21154,7 +21247,7 @@ var ts; emitFlags |= 2048 /* HasDecorators */; } } - if (node.kind === 221 /* ClassDeclaration */) { + if (node.kind === 222 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899519 /* ClassExcludes */); } else { @@ -21298,13 +21391,13 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 201 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 202 /* EmptyStatement */) || // report error on class declarations - node.kind === 221 /* ClassDeclaration */ || + node.kind === 222 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 225 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 226 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || // report error on regular enums and const enums if preserveConstEnums is set - (node.kind === 224 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + (node.kind === 225 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; // unreachable code is reported if @@ -21318,7 +21411,7 @@ var ts; // On the other side we do want to report errors on non-initialized 'lets' because of TDZ var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 200 /* VariableStatement */ || + (node.kind !== 201 /* VariableStatement */ || ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */ || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -21338,52 +21431,54 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 174 /* CallExpression */: + case 175 /* CallExpression */: return computeCallExpression(node, subtreeFlags); - case 225 /* ModuleDeclaration */: + case 176 /* NewExpression */: + return computeNewExpression(node, subtreeFlags); + case 226 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 202 /* ExpressionStatement */: + case 203 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); - case 142 /* Parameter */: + case 143 /* Parameter */: return computeParameter(node, subtreeFlags); - case 180 /* ArrowFunction */: + case 181 /* ArrowFunction */: return computeArrowFunction(node, subtreeFlags); - case 179 /* FunctionExpression */: + case 180 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 220 /* FunctionDeclaration */: + case 221 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 218 /* VariableDeclaration */: + case 219 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 219 /* VariableDeclarationList */: + case 220 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); - case 192 /* ClassExpression */: + case 193 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); case 251 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 148 /* Constructor */: + case 149 /* Constructor */: return computeConstructor(node, subtreeFlags); - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: return computePropertyDeclaration(node, subtreeFlags); - case 147 /* MethodDeclaration */: + case 148 /* MethodDeclaration */: return computeMethod(node, subtreeFlags); - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 229 /* ImportEqualsDeclaration */: + case 230 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -21394,44 +21489,60 @@ var ts; var transformFlags = subtreeFlags; var expression = node.expression; var expressionKind = expression.kind; - if (subtreeFlags & 262144 /* ContainsSpreadElementExpression */ + if (node.typeArguments) { + transformFlags |= 3 /* AssertTypeScript */; + } + if (subtreeFlags & 1048576 /* ContainsSpreadElementExpression */ || isSuperOrSuperProperty(expression, expressionKind)) { // If the this node contains a SpreadElementExpression, or is a super call, then it is an ES6 // node. - transformFlags |= 192 /* AssertES6 */; + transformFlags |= 768 /* AssertES2015 */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~537133909 /* ArrayLiteralOrCallOrNewExcludes */; + return transformFlags & ~537922901 /* ArrayLiteralOrCallOrNewExcludes */; } function isSuperOrSuperProperty(node, kind) { switch (kind) { - case 95 /* SuperKeyword */: + case 96 /* SuperKeyword */: return true; - case 172 /* PropertyAccessExpression */: - case 173 /* ElementAccessExpression */: + case 173 /* PropertyAccessExpression */: + case 174 /* ElementAccessExpression */: var expression = node.expression; var expressionKind = expression.kind; - return expressionKind === 95 /* SuperKeyword */; + return expressionKind === 96 /* SuperKeyword */; } return false; } + function computeNewExpression(node, subtreeFlags) { + var transformFlags = subtreeFlags; + if (node.typeArguments) { + transformFlags |= 3 /* AssertTypeScript */; + } + if (subtreeFlags & 1048576 /* ContainsSpreadElementExpression */) { + // If the this node contains a SpreadElementExpression then it is an ES6 + // node. + transformFlags |= 768 /* AssertES2015 */; + } + node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; + return transformFlags & ~537922901 /* ArrayLiteralOrCallOrNewExcludes */; + } function computeBinaryExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 56 /* EqualsToken */ - && (leftKind === 171 /* ObjectLiteralExpression */ - || leftKind === 170 /* ArrayLiteralExpression */)) { + if (operatorTokenKind === 57 /* EqualsToken */ + && (leftKind === 172 /* ObjectLiteralExpression */ + || leftKind === 171 /* ArrayLiteralExpression */)) { // Destructuring assignments are ES6 syntax. - transformFlags |= 192 /* AssertES6 */ | 256 /* DestructuringAssignment */; + transformFlags |= 768 /* AssertES2015 */ | 1024 /* DestructuringAssignment */; } - else if (operatorTokenKind === 38 /* AsteriskAsteriskToken */ - || operatorTokenKind === 60 /* AsteriskAsteriskEqualsToken */) { - // Exponentiation is ES7 syntax. - transformFlags |= 48 /* AssertES7 */; + else if (operatorTokenKind === 39 /* AsteriskAsteriskToken */ + || operatorTokenKind === 61 /* AsteriskAsteriskEqualsToken */) { + // Exponentiation is ES2016 syntax. + transformFlags |= 192 /* AssertES2016 */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536871765 /* NodeExcludes */; + return transformFlags & ~536874325 /* NodeExcludes */; } function computeParameter(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -21439,25 +21550,25 @@ var ts; var name = node.name; var initializer = node.initializer; var dotDotDotToken = node.dotDotDotToken; - // If the parameter has a question token, then it is TypeScript syntax. - if (node.questionToken) { - transformFlags |= 3 /* AssertTypeScript */; - } - // If the parameter's name is 'this', then it is TypeScript syntax. - if (subtreeFlags & 2048 /* ContainsDecorators */ || ts.isThisIdentifier(name)) { + // The '?' token, type annotations, decorators, and 'this' parameters are TypeSCript + // syntax. + if (node.questionToken + || node.type + || subtreeFlags & 8192 /* ContainsDecorators */ + || ts.isThisIdentifier(name)) { transformFlags |= 3 /* AssertTypeScript */; } // If a parameter has an accessibility modifier, then it is TypeScript syntax. if (modifierFlags & 92 /* ParameterPropertyModifier */) { - transformFlags |= 3 /* AssertTypeScript */ | 131072 /* ContainsParameterPropertyAssignments */; + transformFlags |= 3 /* AssertTypeScript */ | 524288 /* ContainsParameterPropertyAssignments */; } // If a parameter has an initializer, a binding pattern or a dotDotDot token, then // it is ES6 syntax and its container must emit default value assignments or parameter destructuring downlevel. - if (subtreeFlags & 2097152 /* ContainsBindingPattern */ || initializer || dotDotDotToken) { - transformFlags |= 192 /* AssertES6 */ | 65536 /* ContainsDefaultValueAssignments */; + if (subtreeFlags & 8388608 /* ContainsBindingPattern */ || initializer || dotDotDotToken) { + transformFlags |= 768 /* AssertES2015 */ | 262144 /* ContainsDefaultValueAssignments */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~538968917 /* ParameterExcludes */; + return transformFlags & ~545262933 /* ParameterExcludes */; } function computeParenthesizedExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -21467,17 +21578,17 @@ 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 (expressionKind === 195 /* AsExpression */ - || expressionKind === 177 /* TypeAssertionExpression */) { + if (expressionKind === 196 /* AsExpression */ + || expressionKind === 178 /* TypeAssertionExpression */) { transformFlags |= 3 /* AssertTypeScript */; } // If the expression of a ParenthesizedExpression is a destructuring assignment, // then the ParenthesizedExpression is a destructuring assignment. - if (expressionTransformFlags & 256 /* DestructuringAssignment */) { - transformFlags |= 256 /* DestructuringAssignment */; + if (expressionTransformFlags & 1024 /* DestructuringAssignment */) { + transformFlags |= 1024 /* DestructuringAssignment */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536871765 /* NodeExcludes */; + return transformFlags & ~536874325 /* NodeExcludes */; } function computeClassDeclaration(node, subtreeFlags) { var transformFlags; @@ -21488,47 +21599,49 @@ var ts; } else { // A ClassDeclaration is ES6 syntax. - transformFlags = subtreeFlags | 192 /* AssertES6 */; + transformFlags = subtreeFlags | 768 /* AssertES2015 */; // A class with a parameter property assignment, property initializer, or decorator is // TypeScript syntax. // An exported declaration may be TypeScript syntax. - if ((subtreeFlags & 137216 /* TypeScriptClassSyntaxMask */) - || (modifierFlags & 1 /* Export */)) { + if ((subtreeFlags & 548864 /* TypeScriptClassSyntaxMask */) + || (modifierFlags & 1 /* Export */) + || node.typeParameters) { transformFlags |= 3 /* AssertTypeScript */; } - if (subtreeFlags & 32768 /* ContainsLexicalThisInComputedPropertyName */) { + if (subtreeFlags & 131072 /* ContainsLexicalThisInComputedPropertyName */) { // A computed property name containing `this` might need to be rewritten, // so propagate the ContainsLexicalThis flag upward. - transformFlags |= 8192 /* ContainsLexicalThis */; + transformFlags |= 32768 /* ContainsLexicalThis */; } } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~537590613 /* ClassExcludes */; + return transformFlags & ~539749717 /* ClassExcludes */; } function computeClassExpression(node, subtreeFlags) { // A ClassExpression is ES6 syntax. - var transformFlags = subtreeFlags | 192 /* AssertES6 */; + var transformFlags = subtreeFlags | 768 /* AssertES2015 */; // A class with a parameter property assignment, property initializer, or decorator is // TypeScript syntax. - if (subtreeFlags & 137216 /* TypeScriptClassSyntaxMask */) { + if (subtreeFlags & 548864 /* TypeScriptClassSyntaxMask */ + || node.typeParameters) { transformFlags |= 3 /* AssertTypeScript */; } - if (subtreeFlags & 32768 /* ContainsLexicalThisInComputedPropertyName */) { + if (subtreeFlags & 131072 /* ContainsLexicalThisInComputedPropertyName */) { // A computed property name containing `this` might need to be rewritten, // so propagate the ContainsLexicalThis flag upward. - transformFlags |= 8192 /* ContainsLexicalThis */; + transformFlags |= 32768 /* ContainsLexicalThis */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~537590613 /* ClassExcludes */; + return transformFlags & ~539749717 /* ClassExcludes */; } function computeHeritageClause(node, subtreeFlags) { var transformFlags = subtreeFlags; switch (node.token) { - case 83 /* ExtendsKeyword */: + case 84 /* ExtendsKeyword */: // An `extends` HeritageClause is ES6 syntax. - transformFlags |= 192 /* AssertES6 */; + transformFlags |= 768 /* AssertES2015 */; break; - case 106 /* ImplementsKeyword */: + case 107 /* ImplementsKeyword */: // An `implements` HeritageClause is TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; break; @@ -21537,65 +21650,65 @@ var ts; break; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536871765 /* NodeExcludes */; + return transformFlags & ~536874325 /* NodeExcludes */; } function computeExpressionWithTypeArguments(node, subtreeFlags) { // An ExpressionWithTypeArguments is ES6 syntax, as it is used in the // extends clause of a class. - var transformFlags = subtreeFlags | 192 /* AssertES6 */; + var transformFlags = subtreeFlags | 768 /* AssertES2015 */; // If an ExpressionWithTypeArguments contains type arguments, then it // is TypeScript syntax. if (node.typeArguments) { transformFlags |= 3 /* AssertTypeScript */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536871765 /* NodeExcludes */; + return transformFlags & ~536874325 /* NodeExcludes */; } function computeConstructor(node, subtreeFlags) { var transformFlags = subtreeFlags; - var body = node.body; - if (body === undefined) { - // An overload constructor is TypeScript syntax. + // TypeScript-specific modifiers and overloads are TypeScript syntax + if (ts.hasModifier(node, 2270 /* TypeScriptModifier */) + || !node.body) { transformFlags |= 3 /* AssertTypeScript */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~550593365 /* ConstructorExcludes */; + return transformFlags & ~591760725 /* ConstructorExcludes */; } function computeMethod(node, subtreeFlags) { // A MethodDeclaration is ES6 syntax. - var transformFlags = subtreeFlags | 192 /* AssertES6 */; - var modifierFlags = ts.getModifierFlags(node); - var body = node.body; - var typeParameters = node.typeParameters; - var asteriskToken = node.asteriskToken; - // A MethodDeclaration is TypeScript syntax if it is either async, abstract, overloaded, - // generic, or has a decorator. - if (!body - || typeParameters - || (modifierFlags & (256 /* Async */ | 128 /* Abstract */)) - || (subtreeFlags & 2048 /* ContainsDecorators */)) { + var transformFlags = subtreeFlags | 768 /* AssertES2015 */; + // Decorators, TypeScript-specific modifiers, type parameters, type annotations, and + // overloads are TypeScript syntax. + if (node.decorators + || ts.hasModifier(node, 2270 /* TypeScriptModifier */) + || node.typeParameters + || node.type + || !node.body) { transformFlags |= 3 /* AssertTypeScript */; } + // An async method declaration is ES2017 syntax. + if (ts.hasModifier(node, 256 /* Async */)) { + transformFlags |= 48 /* AssertES2017 */; + } // Currently, we only support generators that were originally async function bodies. - if (asteriskToken && ts.getEmitFlags(node) & 2097152 /* AsyncFunctionBody */) { - transformFlags |= 1536 /* AssertGenerator */; + if (node.asteriskToken && ts.getEmitFlags(node) & 2097152 /* AsyncFunctionBody */) { + transformFlags |= 6144 /* AssertGenerator */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~550593365 /* MethodOrAccessorExcludes */; + return transformFlags & ~591760725 /* MethodOrAccessorExcludes */; } function computeAccessor(node, subtreeFlags) { var transformFlags = subtreeFlags; - var modifierFlags = ts.getModifierFlags(node); - var body = node.body; - // A MethodDeclaration is TypeScript syntax if it is either async, abstract, overloaded, - // generic, or has a decorator. - if (!body - || (modifierFlags & (256 /* Async */ | 128 /* Abstract */)) - || (subtreeFlags & 2048 /* ContainsDecorators */)) { + // Decorators, TypeScript-specific modifiers, type annotations, and overloads are + // TypeScript syntax. + if (node.decorators + || ts.hasModifier(node, 2270 /* TypeScriptModifier */) + || node.type + || !node.body) { transformFlags |= 3 /* AssertTypeScript */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~550593365 /* MethodOrAccessorExcludes */; + return transformFlags & ~591760725 /* MethodOrAccessorExcludes */; } function computePropertyDeclaration(node, subtreeFlags) { // A PropertyDeclaration is TypeScript syntax. @@ -21603,88 +21716,105 @@ var ts; // If the PropertyDeclaration has an initializer, we need to inform its ancestor // so that it handle the transformation. if (node.initializer) { - transformFlags |= 4096 /* ContainsPropertyInitializer */; + transformFlags |= 16384 /* ContainsPropertyInitializer */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536871765 /* NodeExcludes */; + return transformFlags & ~536874325 /* NodeExcludes */; } function computeFunctionDeclaration(node, subtreeFlags) { var transformFlags; var modifierFlags = ts.getModifierFlags(node); var body = node.body; - var asteriskToken = node.asteriskToken; if (!body || (modifierFlags & 2 /* Ambient */)) { // An ambient declaration is TypeScript syntax. // A FunctionDeclaration without a body is an overload and is TypeScript syntax. transformFlags = 3 /* AssertTypeScript */; } else { - transformFlags = subtreeFlags | 8388608 /* ContainsHoistedDeclarationOrCompletion */; + transformFlags = subtreeFlags | 33554432 /* ContainsHoistedDeclarationOrCompletion */; // If a FunctionDeclaration is exported, then it is either ES6 or TypeScript syntax. if (modifierFlags & 1 /* Export */) { - transformFlags |= 3 /* AssertTypeScript */ | 192 /* AssertES6 */; + transformFlags |= 3 /* AssertTypeScript */ | 768 /* AssertES2015 */; } - // If a FunctionDeclaration is async, then it is TypeScript syntax. - if (modifierFlags & 256 /* Async */) { + // TypeScript-specific modifiers, type parameters, and type annotations are TypeScript + // syntax. + if (modifierFlags & 2270 /* TypeScriptModifier */ + || node.typeParameters + || node.type) { transformFlags |= 3 /* AssertTypeScript */; } + // An async function declaration is ES2017 syntax. + if (modifierFlags & 256 /* Async */) { + transformFlags |= 48 /* AssertES2017 */; + } // If a FunctionDeclaration's subtree has marked the container as needing to capture the // lexical this, or the function contains parameters with initializers, then this node is // ES6 syntax. - if (subtreeFlags & 81920 /* ES6FunctionSyntaxMask */) { - transformFlags |= 192 /* AssertES6 */; + if (subtreeFlags & 327680 /* ES2015FunctionSyntaxMask */) { + transformFlags |= 768 /* AssertES2015 */; } // If a FunctionDeclaration is generator function and is the body of a // transformed async function, then this node can be transformed to a // down-level generator. // Currently we do not support transforming any other generator fucntions // down level. - if (asteriskToken && ts.getEmitFlags(node) & 2097152 /* AsyncFunctionBody */) { - transformFlags |= 1536 /* AssertGenerator */; + if (node.asteriskToken && ts.getEmitFlags(node) & 2097152 /* AsyncFunctionBody */) { + transformFlags |= 6144 /* AssertGenerator */; } } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~550726485 /* FunctionExcludes */; + return transformFlags & ~592293205 /* FunctionExcludes */; } function computeFunctionExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; - var modifierFlags = ts.getModifierFlags(node); - var asteriskToken = node.asteriskToken; - // An async function expression is TypeScript syntax. - if (modifierFlags & 256 /* Async */) { + // TypeScript-specific modifiers, type parameters, and type annotations are TypeScript + // syntax. + if (ts.hasModifier(node, 2270 /* TypeScriptModifier */) + || node.typeParameters + || node.type) { transformFlags |= 3 /* AssertTypeScript */; } + // An async function expression is ES2017 syntax. + if (ts.hasModifier(node, 256 /* Async */)) { + transformFlags |= 48 /* AssertES2017 */; + } // If a FunctionExpression's subtree has marked the container as needing to capture the // lexical this, or the function contains parameters with initializers, then this node is // ES6 syntax. - if (subtreeFlags & 81920 /* ES6FunctionSyntaxMask */) { - transformFlags |= 192 /* AssertES6 */; + if (subtreeFlags & 327680 /* ES2015FunctionSyntaxMask */) { + transformFlags |= 768 /* AssertES2015 */; } // If a FunctionExpression is generator function and is the body of a // transformed async function, then this node can be transformed to a // down-level generator. // Currently we do not support transforming any other generator fucntions // down level. - if (asteriskToken && ts.getEmitFlags(node) & 2097152 /* AsyncFunctionBody */) { - transformFlags |= 1536 /* AssertGenerator */; + if (node.asteriskToken && ts.getEmitFlags(node) & 2097152 /* AsyncFunctionBody */) { + transformFlags |= 6144 /* AssertGenerator */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~550726485 /* FunctionExcludes */; + return transformFlags & ~592293205 /* FunctionExcludes */; } function computeArrowFunction(node, subtreeFlags) { // An ArrowFunction is ES6 syntax, and excludes markers that should not escape the scope of an ArrowFunction. - var transformFlags = subtreeFlags | 192 /* AssertES6 */; - var modifierFlags = ts.getModifierFlags(node); - // An async arrow function is TypeScript syntax. - if (modifierFlags & 256 /* Async */) { + var transformFlags = subtreeFlags | 768 /* AssertES2015 */; + // TypeScript-specific modifiers, type parameters, and type annotations are TypeScript + // syntax. + if (ts.hasModifier(node, 2270 /* TypeScriptModifier */) + || node.typeParameters + || node.type) { transformFlags |= 3 /* AssertTypeScript */; } + // An async arrow function is ES2017 syntax. + if (ts.hasModifier(node, 256 /* Async */)) { + transformFlags |= 48 /* AssertES2017 */; + } // If an ArrowFunction contains a lexical this, its container must capture the lexical this. - if (subtreeFlags & 8192 /* ContainsLexicalThis */) { - transformFlags |= 16384 /* ContainsCapturedLexicalThis */; + if (subtreeFlags & 32768 /* ContainsLexicalThis */) { + transformFlags |= 65536 /* ContainsCapturedLexicalThis */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~550710101 /* ArrowFunctionExcludes */; + return transformFlags & ~592227669 /* ArrowFunctionExcludes */; } function computePropertyAccess(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -21692,21 +21822,25 @@ var ts; var expressionKind = expression.kind; // If a PropertyAccessExpression starts with a super keyword, then it is // ES6 syntax, and requires a lexical `this` binding. - if (expressionKind === 95 /* SuperKeyword */) { - transformFlags |= 8192 /* ContainsLexicalThis */; + if (expressionKind === 96 /* SuperKeyword */) { + transformFlags |= 32768 /* ContainsLexicalThis */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536871765 /* NodeExcludes */; + return transformFlags & ~536874325 /* NodeExcludes */; } function computeVariableDeclaration(node, subtreeFlags) { var transformFlags = subtreeFlags; var nameKind = node.name.kind; // A VariableDeclaration with a binding pattern is ES6 syntax. - if (nameKind === 167 /* ObjectBindingPattern */ || nameKind === 168 /* ArrayBindingPattern */) { - transformFlags |= 192 /* AssertES6 */ | 2097152 /* ContainsBindingPattern */; + if (nameKind === 168 /* ObjectBindingPattern */ || nameKind === 169 /* ArrayBindingPattern */) { + transformFlags |= 768 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; + } + // Type annotations are TypeScript syntax. + if (node.type) { + transformFlags |= 3 /* AssertTypeScript */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536871765 /* NodeExcludes */; + return transformFlags & ~536874325 /* NodeExcludes */; } function computeVariableStatement(node, subtreeFlags) { var transformFlags; @@ -21720,24 +21854,24 @@ var ts; transformFlags = subtreeFlags; // If a VariableStatement is exported, then it is either ES6 or TypeScript syntax. if (modifierFlags & 1 /* Export */) { - transformFlags |= 192 /* AssertES6 */ | 3 /* AssertTypeScript */; + transformFlags |= 768 /* AssertES2015 */ | 3 /* AssertTypeScript */; } - if (declarationListTransformFlags & 2097152 /* ContainsBindingPattern */) { - transformFlags |= 192 /* AssertES6 */; + if (declarationListTransformFlags & 8388608 /* ContainsBindingPattern */) { + transformFlags |= 768 /* AssertES2015 */; } } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536871765 /* NodeExcludes */; + return transformFlags & ~536874325 /* NodeExcludes */; } function computeLabeledStatement(node, subtreeFlags) { var transformFlags = subtreeFlags; // A labeled statement containing a block scoped binding *may* need to be transformed from ES6. - if (subtreeFlags & 1048576 /* ContainsBlockScopedBinding */ + if (subtreeFlags & 4194304 /* ContainsBlockScopedBinding */ && ts.isIterationStatement(node, /*lookInLabeledStatements*/ true)) { - transformFlags |= 192 /* AssertES6 */; + transformFlags |= 768 /* AssertES2015 */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536871765 /* NodeExcludes */; + return transformFlags & ~536874325 /* NodeExcludes */; } function computeImportEquals(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -21746,18 +21880,18 @@ var ts; transformFlags |= 3 /* AssertTypeScript */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536871765 /* NodeExcludes */; + return transformFlags & ~536874325 /* NodeExcludes */; } function computeExpressionStatement(node, subtreeFlags) { var transformFlags = subtreeFlags; // If the expression of an expression statement is a destructuring assignment, // then we treat the statement as ES6 so that we can indicate that we do not // need to hold on to the right-hand side. - if (node.expression.transformFlags & 256 /* DestructuringAssignment */) { - transformFlags |= 192 /* AssertES6 */; + if (node.expression.transformFlags & 1024 /* DestructuringAssignment */) { + transformFlags |= 768 /* AssertES2015 */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536871765 /* NodeExcludes */; + return transformFlags & ~536874325 /* NodeExcludes */; } function computeModuleDeclaration(node, subtreeFlags) { var transformFlags = 3 /* AssertTypeScript */; @@ -21766,46 +21900,49 @@ var ts; transformFlags |= subtreeFlags; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~546335573 /* ModuleExcludes */; + return transformFlags & ~574729557 /* ModuleExcludes */; } function computeVariableDeclarationList(node, subtreeFlags) { - var transformFlags = subtreeFlags | 8388608 /* ContainsHoistedDeclarationOrCompletion */; - if (subtreeFlags & 2097152 /* ContainsBindingPattern */) { - transformFlags |= 192 /* AssertES6 */; + var transformFlags = subtreeFlags | 33554432 /* ContainsHoistedDeclarationOrCompletion */; + if (subtreeFlags & 8388608 /* ContainsBindingPattern */) { + transformFlags |= 768 /* AssertES2015 */; } // If a VariableDeclarationList is `let` or `const`, then it is ES6 syntax. if (node.flags & 3 /* BlockScoped */) { - transformFlags |= 192 /* AssertES6 */ | 1048576 /* ContainsBlockScopedBinding */; + transformFlags |= 768 /* AssertES2015 */ | 4194304 /* ContainsBlockScopedBinding */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~538968917 /* VariableDeclarationListExcludes */; + return transformFlags & ~545262933 /* VariableDeclarationListExcludes */; } function computeOther(node, kind, subtreeFlags) { // Mark transformations needed for each node var transformFlags = subtreeFlags; - var excludeFlags = 536871765 /* NodeExcludes */; + var excludeFlags = 536874325 /* NodeExcludes */; switch (kind) { - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - case 115 /* AbstractKeyword */: - case 122 /* DeclareKeyword */: - case 118 /* AsyncKeyword */: - case 74 /* ConstKeyword */: - case 184 /* AwaitExpression */: - case 224 /* EnumDeclaration */: + case 119 /* AsyncKeyword */: + case 185 /* AwaitExpression */: + // async/await is ES2017 syntax + transformFlags |= 48 /* AssertES2017 */; + break; + case 113 /* PublicKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + case 116 /* AbstractKeyword */: + case 123 /* DeclareKeyword */: + case 75 /* ConstKeyword */: + case 225 /* EnumDeclaration */: case 255 /* EnumMember */: - case 177 /* TypeAssertionExpression */: - case 195 /* AsExpression */: - case 196 /* NonNullExpression */: - case 128 /* ReadonlyKeyword */: + case 178 /* TypeAssertionExpression */: + case 196 /* AsExpression */: + case 197 /* NonNullExpression */: + case 129 /* ReadonlyKeyword */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; break; - case 241 /* JsxElement */: - case 242 /* JsxSelfClosingElement */: - case 243 /* JsxOpeningElement */: - case 244 /* JsxText */: + case 242 /* JsxElement */: + case 243 /* JsxSelfClosingElement */: + case 244 /* JsxOpeningElement */: + case 10 /* JsxText */: case 245 /* JsxClosingElement */: case 246 /* JsxAttribute */: case 247 /* JsxSpreadAttribute */: @@ -21813,64 +21950,64 @@ var ts; // These nodes are Jsx syntax. transformFlags |= 12 /* AssertJsx */; break; - case 82 /* ExportKeyword */: + case 83 /* ExportKeyword */: // This node is both ES6 and TypeScript syntax. - transformFlags |= 192 /* AssertES6 */ | 3 /* AssertTypeScript */; + transformFlags |= 768 /* AssertES2015 */ | 3 /* AssertTypeScript */; break; - case 77 /* DefaultKeyword */: - case 11 /* NoSubstitutionTemplateLiteral */: - case 12 /* TemplateHead */: - case 13 /* TemplateMiddle */: - case 14 /* TemplateTail */: - case 189 /* TemplateExpression */: - case 176 /* TaggedTemplateExpression */: + case 78 /* DefaultKeyword */: + case 12 /* NoSubstitutionTemplateLiteral */: + case 13 /* TemplateHead */: + case 14 /* TemplateMiddle */: + case 15 /* TemplateTail */: + case 190 /* TemplateExpression */: + case 177 /* TaggedTemplateExpression */: case 254 /* ShorthandPropertyAssignment */: - case 208 /* ForOfStatement */: + case 209 /* ForOfStatement */: // These nodes are ES6 syntax. - transformFlags |= 192 /* AssertES6 */; + transformFlags |= 768 /* AssertES2015 */; break; - case 190 /* YieldExpression */: + case 191 /* YieldExpression */: // This node is ES6 syntax. - transformFlags |= 192 /* AssertES6 */ | 4194304 /* ContainsYield */; + transformFlags |= 768 /* AssertES2015 */ | 16777216 /* ContainsYield */; break; - case 117 /* AnyKeyword */: - case 130 /* NumberKeyword */: - case 127 /* NeverKeyword */: - case 132 /* StringKeyword */: - case 120 /* BooleanKeyword */: - case 133 /* SymbolKeyword */: - case 103 /* VoidKeyword */: - case 141 /* TypeParameter */: - case 144 /* PropertySignature */: - case 146 /* MethodSignature */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: - case 154 /* TypePredicate */: - case 155 /* TypeReference */: - case 156 /* FunctionType */: - case 157 /* ConstructorType */: - case 158 /* TypeQuery */: - case 159 /* TypeLiteral */: - case 160 /* ArrayType */: - case 161 /* TupleType */: - case 162 /* UnionType */: - case 163 /* IntersectionType */: - case 164 /* ParenthesizedType */: - case 222 /* InterfaceDeclaration */: - case 223 /* TypeAliasDeclaration */: - case 165 /* ThisType */: - case 166 /* LiteralType */: + case 118 /* AnyKeyword */: + case 131 /* NumberKeyword */: + case 128 /* NeverKeyword */: + case 133 /* StringKeyword */: + case 121 /* BooleanKeyword */: + case 134 /* SymbolKeyword */: + case 104 /* VoidKeyword */: + case 142 /* TypeParameter */: + case 145 /* PropertySignature */: + case 147 /* MethodSignature */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: + case 155 /* TypePredicate */: + case 156 /* TypeReference */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: + case 159 /* TypeQuery */: + case 160 /* TypeLiteral */: + case 161 /* ArrayType */: + case 162 /* TupleType */: + case 163 /* UnionType */: + case 164 /* IntersectionType */: + case 165 /* ParenthesizedType */: + case 223 /* InterfaceDeclaration */: + case 224 /* TypeAliasDeclaration */: + case 166 /* ThisType */: + case 167 /* LiteralType */: // Types and signatures are TypeScript syntax, and exclude all other facts. transformFlags = 3 /* AssertTypeScript */; excludeFlags = -3 /* TypeExcludes */; break; - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: // Even though computed property names are ES6, we don't treat them as such. // This is so that they can flow through PropertyName transforms unaffected. // Instead, we mark the container as ES6, so that it can properly handle the transform. - transformFlags |= 524288 /* ContainsComputedPropertyName */; - if (subtreeFlags & 8192 /* ContainsLexicalThis */) { + transformFlags |= 2097152 /* ContainsComputedPropertyName */; + if (subtreeFlags & 32768 /* ContainsLexicalThis */) { // A computed method name like `[this.getName()](x: string) { ... }` needs to // distinguish itself from the normal case of a method body containing `this`: // `this` inside a method doesn't need to be rewritten (the method provides `this`), @@ -21879,70 +22016,70 @@ var ts; // `_this = this; () => class K { [_this.getName()]() { ... } }` // To make this distinction, use ContainsLexicalThisInComputedPropertyName // instead of ContainsLexicalThis for computed property names - transformFlags |= 32768 /* ContainsLexicalThisInComputedPropertyName */; + transformFlags |= 131072 /* ContainsLexicalThisInComputedPropertyName */; } break; - case 191 /* SpreadElementExpression */: + case 192 /* SpreadElementExpression */: // This node is ES6 syntax, but is handled by a containing node. - transformFlags |= 262144 /* ContainsSpreadElementExpression */; + transformFlags |= 1048576 /* ContainsSpreadElementExpression */; break; - case 95 /* SuperKeyword */: + case 96 /* SuperKeyword */: // This node is ES6 syntax. - transformFlags |= 192 /* AssertES6 */; + transformFlags |= 768 /* AssertES2015 */; break; - case 97 /* ThisKeyword */: + case 98 /* ThisKeyword */: // Mark this node and its ancestors as containing a lexical `this` keyword. - transformFlags |= 8192 /* ContainsLexicalThis */; + transformFlags |= 32768 /* ContainsLexicalThis */; break; - case 167 /* ObjectBindingPattern */: - case 168 /* ArrayBindingPattern */: + case 168 /* ObjectBindingPattern */: + case 169 /* ArrayBindingPattern */: // These nodes are ES6 syntax. - transformFlags |= 192 /* AssertES6 */ | 2097152 /* ContainsBindingPattern */; + transformFlags |= 768 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; break; - case 143 /* Decorator */: + case 144 /* Decorator */: // This node is TypeScript syntax, and marks its container as also being TypeScript syntax. - transformFlags |= 3 /* AssertTypeScript */ | 2048 /* ContainsDecorators */; + transformFlags |= 3 /* AssertTypeScript */ | 8192 /* ContainsDecorators */; break; - case 171 /* ObjectLiteralExpression */: - excludeFlags = 537430869 /* ObjectLiteralExcludes */; - if (subtreeFlags & 524288 /* ContainsComputedPropertyName */) { + case 172 /* ObjectLiteralExpression */: + excludeFlags = 539110741 /* ObjectLiteralExcludes */; + if (subtreeFlags & 2097152 /* ContainsComputedPropertyName */) { // If an ObjectLiteralExpression contains a ComputedPropertyName, then it // is an ES6 node. - transformFlags |= 192 /* AssertES6 */; + transformFlags |= 768 /* AssertES2015 */; } - if (subtreeFlags & 32768 /* ContainsLexicalThisInComputedPropertyName */) { + if (subtreeFlags & 131072 /* ContainsLexicalThisInComputedPropertyName */) { // A computed property name containing `this` might need to be rewritten, // so propagate the ContainsLexicalThis flag upward. - transformFlags |= 8192 /* ContainsLexicalThis */; + transformFlags |= 32768 /* ContainsLexicalThis */; } break; - case 170 /* ArrayLiteralExpression */: - case 175 /* NewExpression */: - excludeFlags = 537133909 /* ArrayLiteralOrCallOrNewExcludes */; - if (subtreeFlags & 262144 /* ContainsSpreadElementExpression */) { + case 171 /* ArrayLiteralExpression */: + case 176 /* NewExpression */: + excludeFlags = 537922901 /* ArrayLiteralOrCallOrNewExcludes */; + if (subtreeFlags & 1048576 /* ContainsSpreadElementExpression */) { // If the this node contains a SpreadElementExpression, then it is an ES6 // node. - transformFlags |= 192 /* AssertES6 */; + transformFlags |= 768 /* AssertES2015 */; } break; - case 204 /* DoStatement */: - case 205 /* WhileStatement */: - case 206 /* ForStatement */: - case 207 /* ForInStatement */: + case 205 /* DoStatement */: + case 206 /* WhileStatement */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. - if (subtreeFlags & 1048576 /* ContainsBlockScopedBinding */) { - transformFlags |= 192 /* AssertES6 */; + if (subtreeFlags & 4194304 /* ContainsBlockScopedBinding */) { + transformFlags |= 768 /* AssertES2015 */; } break; case 256 /* SourceFile */: - if (subtreeFlags & 16384 /* ContainsCapturedLexicalThis */) { - transformFlags |= 192 /* AssertES6 */; + if (subtreeFlags & 65536 /* ContainsCapturedLexicalThis */) { + transformFlags |= 768 /* AssertES2015 */; } break; - case 211 /* ReturnStatement */: - case 209 /* ContinueStatement */: - case 210 /* BreakStatement */: - transformFlags |= 8388608 /* ContainsHoistedDeclarationOrCompletion */; + case 212 /* ReturnStatement */: + case 210 /* ContinueStatement */: + case 211 /* BreakStatement */: + transformFlags |= 33554432 /* ContainsHoistedDeclarationOrCompletion */; break; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; @@ -21953,7 +22090,7 @@ var ts; /// var ts; (function (ts) { - function trace(host, message) { + function trace(host) { host.trace(ts.formatMessage.apply(undefined, arguments)); } ts.trace = trace; @@ -22724,6 +22861,7 @@ var ts; var intersectionTypes = ts.createMap(); var stringLiteralTypes = ts.createMap(); var numericLiteralTypes = ts.createMap(); + var evolvingArrayTypes = []; var unknownSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "unknown"); var resolvingSymbol = createSymbol(67108864 /* Transient */, "__resolving__"); var anyType = createIntrinsicType(1 /* Any */, "any"); @@ -22774,6 +22912,7 @@ var ts; var globalBooleanType; var globalRegExpType; var anyArrayType; + var autoArrayType; var anyReadonlyArrayType; // The library files are only loaded when the feature is used. // This allows users to just specify library files they want to used through --lib @@ -23018,7 +23157,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 225 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 225 /* ModuleDeclaration */))) { + (target.valueDeclaration.kind === 226 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 226 /* ModuleDeclaration */))) { // other kinds of value declarations take precedence over modules target.valueDeclaration = source.valueDeclaration; } @@ -23174,7 +23313,7 @@ var ts; 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 !== 218 /* VariableDeclaration */ || + return declaration.kind !== 219 /* VariableDeclaration */ || !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } // declaration is after usage @@ -23183,9 +23322,9 @@ var ts; function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 200 /* VariableStatement */: - case 206 /* ForStatement */: - case 208 /* ForOfStatement */: + case 201 /* VariableStatement */: + case 207 /* ForStatement */: + case 209 /* ForOfStatement */: // variable statement/for/for-of statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) if (isSameScopeDescendentOf(usage, declaration, container)) { @@ -23194,8 +23333,8 @@ var ts; break; } switch (declaration.parent.parent.kind) { - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: // ForIn/ForOf case - use site should not be used in expression part if (isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container)) { return true; @@ -23214,7 +23353,7 @@ var ts; return true; } var initializerOfNonStaticProperty = current.parent && - current.parent.kind === 145 /* PropertyDeclaration */ && + current.parent.kind === 146 /* PropertyDeclaration */ && (ts.getModifierFlags(current.parent) & 32 /* Static */) === 0 && current.parent.initializer === current; if (initializerOfNonStaticProperty) { @@ -23250,8 +23389,8 @@ var ts; if (meaning & result.flags & 793064 /* Type */ && lastLocation.kind !== 273 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ ? lastLocation === location.type || - lastLocation.kind === 142 /* Parameter */ || - lastLocation.kind === 141 /* TypeParameter */ + lastLocation.kind === 143 /* Parameter */ || + lastLocation.kind === 142 /* TypeParameter */ : false; } if (meaning & 107455 /* Value */ && result.flags & 1 /* FunctionScopedVariable */) { @@ -23260,9 +23399,9 @@ var ts; // however it is detected separately when checking initializers of parameters // to make sure that they reference no variables declared after them. useResult = - lastLocation.kind === 142 /* Parameter */ || + lastLocation.kind === 143 /* Parameter */ || (lastLocation === location.type && - result.valueDeclaration.kind === 142 /* Parameter */); + result.valueDeclaration.kind === 143 /* Parameter */); } } if (useResult) { @@ -23278,7 +23417,7 @@ var ts; if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; if (location.kind === 256 /* SourceFile */ || ts.isAmbientModule(location)) { // It's an external module. First see if the module has an export default and if the local @@ -23303,7 +23442,7 @@ var ts; // which is not the desired behavior. if (moduleExports[name] && moduleExports[name].flags === 8388608 /* Alias */ && - ts.getDeclarationOfKind(moduleExports[name], 238 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExports[name], 239 /* ExportSpecifier */)) { break; } } @@ -23311,13 +23450,13 @@ var ts; break loop; } break; - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* 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 @@ -23334,9 +23473,9 @@ var ts; } } break; - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - case 222 /* InterfaceDeclaration */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 223 /* InterfaceDeclaration */: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793064 /* Type */)) { if (lastLocation && ts.getModifierFlags(lastLocation) & 32 /* Static */) { // TypeScript 1.0 spec (April 2014): 3.4.1 @@ -23347,7 +23486,7 @@ var ts; } break loop; } - if (location.kind === 192 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 193 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -23363,9 +23502,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 222 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 223 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793064 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -23373,19 +23512,19 @@ var ts; } } break; - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 220 /* FunctionDeclaration */: - case 180 /* ArrowFunction */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 221 /* FunctionDeclaration */: + case 181 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 179 /* FunctionExpression */: + case 180 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -23398,7 +23537,7 @@ var ts; } } break; - case 143 /* Decorator */: + case 144 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -23407,7 +23546,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 === 142 /* Parameter */) { + if (location.parent && location.parent.kind === 143 /* Parameter */) { location = location.parent; } // @@ -23470,7 +23609,7 @@ var ts; // If we're in an external module, we can't reference value symbols created from UMD export declarations if (result && isInExternalModule && (meaning & 107455 /* Value */) === 107455 /* Value */) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 228 /* NamespaceExportDeclaration */) { + if (decls && decls.length === 1 && decls[0].kind === 229 /* NamespaceExportDeclaration */) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } @@ -23478,7 +23617,7 @@ var ts; return result; } function checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) { - if ((errorLocation.kind === 69 /* Identifier */ && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { + if ((errorLocation.kind === 70 /* Identifier */ && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { return false; } var container = ts.getThisContainer(errorLocation, /* includeArrowFunctions */ true); @@ -23523,10 +23662,10 @@ var ts; */ function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 69 /* Identifier */: - case 172 /* PropertyAccessExpression */: + case 70 /* Identifier */: + case 173 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: ts.Debug.assert(ts.isEntityNameExpression(node.expression)); return node.expression; default: @@ -23548,7 +23687,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"); - if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 218 /* VariableDeclaration */), errorLocation)) { + if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 219 /* VariableDeclaration */), errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -23569,10 +23708,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 229 /* ImportEqualsDeclaration */) { + if (node.kind === 230 /* ImportEqualsDeclaration */) { return node; } - while (node && node.kind !== 230 /* ImportDeclaration */) { + while (node && node.kind !== 231 /* ImportDeclaration */) { node = node.parent; } return node; @@ -23582,10 +23721,10 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 240 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 241 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } - return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); + return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); } function getTargetOfImportClause(node) { var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier); @@ -23707,19 +23846,19 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 229 /* ImportEqualsDeclaration */: + case 230 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node); - case 231 /* ImportClause */: + case 232 /* ImportClause */: return getTargetOfImportClause(node); - case 232 /* NamespaceImport */: + case 233 /* NamespaceImport */: return getTargetOfNamespaceImport(node); - case 234 /* ImportSpecifier */: + case 235 /* ImportSpecifier */: return getTargetOfImportSpecifier(node); - case 238 /* ExportSpecifier */: + case 239 /* ExportSpecifier */: return getTargetOfExportSpecifier(node); - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: return getTargetOfExportAssignment(node); - case 228 /* NamespaceExportDeclaration */: + case 229 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node); } } @@ -23766,11 +23905,11 @@ var ts; links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); ts.Debug.assert(!!node); - if (node.kind === 235 /* ExportAssignment */) { + if (node.kind === 236 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 238 /* ExportSpecifier */) { + else if (node.kind === 239 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -23781,24 +23920,24 @@ var ts; } } // This function is only for imports with entity names - function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration, dontResolveAlias) { + function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, dontResolveAlias) { // There are three things we might try to look for. In the following examples, // the search term is enclosed in |...|: // // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 69 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 70 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 69 /* Identifier */ || entityName.parent.kind === 139 /* QualifiedName */) { + if (entityName.kind === 70 /* Identifier */ || entityName.parent.kind === 140 /* QualifiedName */) { return resolveEntityName(entityName, 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 229 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 230 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } @@ -23811,16 +23950,16 @@ var ts; return undefined; } var symbol; - if (name.kind === 69 /* Identifier */) { + if (name.kind === 70 /* Identifier */) { var message = meaning === 1920 /* Namespace */ ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; symbol = resolveName(location || name, name.text, meaning, ignoreErrors ? undefined : message, name); if (!symbol) { return undefined; } } - else if (name.kind === 139 /* QualifiedName */ || name.kind === 172 /* PropertyAccessExpression */) { - var left = name.kind === 139 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 139 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 140 /* QualifiedName */ || name.kind === 173 /* PropertyAccessExpression */) { + var left = name.kind === 140 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 140 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, 1920 /* Namespace */, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -24027,7 +24166,7 @@ var ts; var members = node.members; for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { var member = members_1[_i]; - if (member.kind === 148 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 149 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -24106,7 +24245,7 @@ var ts; if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } @@ -24147,7 +24286,7 @@ var ts; return ts.forEachProperty(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 /* Alias */ && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 238 /* ExportSpecifier */)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 239 /* ExportSpecifier */)) { if (!useOnlyExternalAliasing || // Is this external alias, then use it to name ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { @@ -24186,7 +24325,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, 238 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 239 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -24201,10 +24340,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 145 /* PropertyDeclaration */: - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 146 /* PropertyDeclaration */: + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: continue; default: return false; @@ -24235,7 +24374,7 @@ var ts; return { accessibility: 1 /* NotAccessible */, errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), - errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, 1920 /* Namespace */) : undefined + errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, 1920 /* Namespace */) : undefined, }; } return hasAccessibleDeclarations; @@ -24272,7 +24411,7 @@ var ts; // Just a local name that is not accessible return { accessibility: 1 /* NotAccessible */, - errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning) + errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), }; } return { accessibility: 0 /* Accessible */ }; @@ -24326,12 +24465,12 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 158 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + if (entityName.parent.kind === 159 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { // Typeof value meaning = 107455 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 139 /* QualifiedName */ || entityName.kind === 172 /* PropertyAccessExpression */ || - entityName.parent.kind === 229 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 140 /* QualifiedName */ || entityName.kind === 173 /* PropertyAccessExpression */ || + entityName.parent.kind === 230 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -24427,10 +24566,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { var node = type.symbol.declarations[0].parent; - while (node.kind === 164 /* ParenthesizedType */) { + while (node.kind === 165 /* ParenthesizedType */) { node = node.parent; } - if (node.kind === 223 /* TypeAliasDeclaration */) { + if (node.kind === 224 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -24438,7 +24577,7 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 226 /* ModuleBlock */ && + node.parent.kind === 227 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { @@ -24452,10 +24591,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 192 /* ClassExpression */: + case 193 /* ClassExpression */: return "(Anonymous class)"; - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: return "(Anonymous function)"; } } @@ -24478,17 +24617,17 @@ var ts; var firstChar = symbolName.charCodeAt(0); var needsElementAccess = !ts.isIdentifierStart(firstChar, languageVersion); if (needsElementAccess) { - writePunctuation(writer, 19 /* OpenBracketToken */); + writePunctuation(writer, 20 /* OpenBracketToken */); if (ts.isSingleOrDoubleQuote(firstChar)) { writer.writeStringLiteral(symbolName); } else { writer.writeSymbol(symbolName, symbol); } - writePunctuation(writer, 20 /* CloseBracketToken */); + writePunctuation(writer, 21 /* CloseBracketToken */); } else { - writePunctuation(writer, 21 /* DotToken */); + writePunctuation(writer, 22 /* DotToken */); writer.writeSymbol(symbolName, symbol); } } @@ -24587,7 +24726,7 @@ var ts; } else if (type.flags & 256 /* EnumLiteral */) { buildSymbolDisplay(getParentOfSymbol(type.symbol), writer, enclosingDeclaration, 793064 /* Type */, 0 /* None */, nextFlags); - writePunctuation(writer, 21 /* DotToken */); + writePunctuation(writer, 22 /* DotToken */); appendSymbolNameOnly(type.symbol, writer); } else if (type.flags & (32768 /* Class */ | 65536 /* Interface */ | 16 /* Enum */ | 16384 /* TypeParameter */)) { @@ -24617,23 +24756,23 @@ var ts; else { // Should never get here // { ... } - writePunctuation(writer, 15 /* OpenBraceToken */); + writePunctuation(writer, 16 /* OpenBraceToken */); writeSpace(writer); - writePunctuation(writer, 22 /* DotDotDotToken */); + writePunctuation(writer, 23 /* DotDotDotToken */); writeSpace(writer); - writePunctuation(writer, 16 /* CloseBraceToken */); + writePunctuation(writer, 17 /* CloseBraceToken */); } } function writeTypeList(types, delimiter) { for (var i = 0; i < types.length; i++) { if (i > 0) { - if (delimiter !== 24 /* CommaToken */) { + if (delimiter !== 25 /* CommaToken */) { writeSpace(writer); } writePunctuation(writer, delimiter); writeSpace(writer); } - writeType(types[i], delimiter === 24 /* CommaToken */ ? 0 /* None */ : 64 /* InElementType */); + writeType(types[i], delimiter === 25 /* CommaToken */ ? 0 /* None */ : 64 /* InElementType */); } } function writeSymbolTypeReference(symbol, typeArguments, pos, end, flags) { @@ -24642,29 +24781,29 @@ var ts; buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793064 /* Type */, 0 /* None */, flags); } if (pos < end) { - writePunctuation(writer, 25 /* LessThanToken */); + writePunctuation(writer, 26 /* LessThanToken */); writeType(typeArguments[pos], 256 /* InFirstTypeArgument */); pos++; while (pos < end) { - writePunctuation(writer, 24 /* CommaToken */); + writePunctuation(writer, 25 /* CommaToken */); writeSpace(writer); writeType(typeArguments[pos], 0 /* None */); pos++; } - writePunctuation(writer, 27 /* GreaterThanToken */); + writePunctuation(writer, 28 /* GreaterThanToken */); } } function writeTypeReference(type, flags) { var typeArguments = type.typeArguments || emptyArray; if (type.target === globalArrayType && !(flags & 1 /* WriteArrayAsGenericType */)) { writeType(typeArguments[0], 64 /* InElementType */); - writePunctuation(writer, 19 /* OpenBracketToken */); - writePunctuation(writer, 20 /* CloseBracketToken */); + writePunctuation(writer, 20 /* OpenBracketToken */); + writePunctuation(writer, 21 /* CloseBracketToken */); } else if (type.target.flags & 262144 /* Tuple */) { - writePunctuation(writer, 19 /* OpenBracketToken */); - writeTypeList(type.typeArguments.slice(0, getTypeReferenceArity(type)), 24 /* CommaToken */); - writePunctuation(writer, 20 /* CloseBracketToken */); + writePunctuation(writer, 20 /* OpenBracketToken */); + writeTypeList(type.typeArguments.slice(0, getTypeReferenceArity(type)), 25 /* CommaToken */); + writePunctuation(writer, 21 /* CloseBracketToken */); } else { // Write the type reference in the format f
.g.C where A and B are type arguments @@ -24685,7 +24824,7 @@ var ts; // the default outer type arguments), we don't show the group. if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { writeSymbolTypeReference(parent_9, typeArguments, start, i, flags); - writePunctuation(writer, 21 /* DotToken */); + writePunctuation(writer, 22 /* DotToken */); } } } @@ -24695,16 +24834,16 @@ var ts; } function writeUnionOrIntersectionType(type, flags) { if (flags & 64 /* InElementType */) { - writePunctuation(writer, 17 /* OpenParenToken */); + writePunctuation(writer, 18 /* OpenParenToken */); } if (type.flags & 524288 /* Union */) { - writeTypeList(formatUnionTypes(type.types), 47 /* BarToken */); + writeTypeList(formatUnionTypes(type.types), 48 /* BarToken */); } else { - writeTypeList(type.types, 46 /* AmpersandToken */); + writeTypeList(type.types, 47 /* AmpersandToken */); } if (flags & 64 /* InElementType */) { - writePunctuation(writer, 18 /* CloseParenToken */); + writePunctuation(writer, 19 /* CloseParenToken */); } } function writeAnonymousType(type, flags) { @@ -24726,7 +24865,7 @@ var ts; } else { // Recursive usage, use any - writeKeyword(writer, 117 /* AnyKeyword */); + writeKeyword(writer, 118 /* AnyKeyword */); } } else { @@ -24750,7 +24889,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 256 /* SourceFile */ || declaration.parent.kind === 226 /* ModuleBlock */; + return declaration.parent.kind === 256 /* SourceFile */ || declaration.parent.kind === 227 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -24760,37 +24899,37 @@ var ts; } } function writeTypeOfSymbol(type, typeFormatFlags) { - writeKeyword(writer, 101 /* TypeOfKeyword */); + writeKeyword(writer, 102 /* TypeOfKeyword */); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455 /* Value */, 0 /* None */, typeFormatFlags); } function writeIndexSignature(info, keyword) { if (info) { if (info.isReadonly) { - writeKeyword(writer, 128 /* ReadonlyKeyword */); + writeKeyword(writer, 129 /* ReadonlyKeyword */); writeSpace(writer); } - writePunctuation(writer, 19 /* OpenBracketToken */); + writePunctuation(writer, 20 /* OpenBracketToken */); writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); - writePunctuation(writer, 54 /* ColonToken */); + writePunctuation(writer, 55 /* ColonToken */); writeSpace(writer); writeKeyword(writer, keyword); - writePunctuation(writer, 20 /* CloseBracketToken */); - writePunctuation(writer, 54 /* ColonToken */); + writePunctuation(writer, 21 /* CloseBracketToken */); + writePunctuation(writer, 55 /* ColonToken */); writeSpace(writer); writeType(info.type, 0 /* None */); - writePunctuation(writer, 23 /* SemicolonToken */); + writePunctuation(writer, 24 /* SemicolonToken */); writer.writeLine(); } } function writePropertyWithModifiers(prop) { if (isReadonlySymbol(prop)) { - writeKeyword(writer, 128 /* ReadonlyKeyword */); + writeKeyword(writer, 129 /* ReadonlyKeyword */); writeSpace(writer); } buildSymbolDisplay(prop, writer); if (prop.flags & 536870912 /* Optional */) { - writePunctuation(writer, 53 /* QuestionToken */); + writePunctuation(writer, 54 /* QuestionToken */); } } function shouldAddParenthesisAroundFunctionType(callSignature, flags) { @@ -24809,53 +24948,53 @@ var ts; var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { - writePunctuation(writer, 15 /* OpenBraceToken */); - writePunctuation(writer, 16 /* CloseBraceToken */); + writePunctuation(writer, 16 /* OpenBraceToken */); + writePunctuation(writer, 17 /* CloseBraceToken */); return; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var parenthesizeSignature = shouldAddParenthesisAroundFunctionType(resolved.callSignatures[0], flags); if (parenthesizeSignature) { - writePunctuation(writer, 17 /* OpenParenToken */); + writePunctuation(writer, 18 /* OpenParenToken */); } buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, /*kind*/ undefined, symbolStack); if (parenthesizeSignature) { - writePunctuation(writer, 18 /* CloseParenToken */); + writePunctuation(writer, 19 /* CloseParenToken */); } return; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { if (flags & 64 /* InElementType */) { - writePunctuation(writer, 17 /* OpenParenToken */); + writePunctuation(writer, 18 /* OpenParenToken */); } - writeKeyword(writer, 92 /* NewKeyword */); + writeKeyword(writer, 93 /* NewKeyword */); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, /*kind*/ undefined, symbolStack); if (flags & 64 /* InElementType */) { - writePunctuation(writer, 18 /* CloseParenToken */); + writePunctuation(writer, 19 /* CloseParenToken */); } return; } } var saveInObjectTypeLiteral = inObjectTypeLiteral; inObjectTypeLiteral = true; - writePunctuation(writer, 15 /* OpenBraceToken */); + writePunctuation(writer, 16 /* OpenBraceToken */); writer.writeLine(); writer.increaseIndent(); for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, /*kind*/ undefined, symbolStack); - writePunctuation(writer, 23 /* SemicolonToken */); + writePunctuation(writer, 24 /* SemicolonToken */); writer.writeLine(); } for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, 1 /* Construct */, symbolStack); - writePunctuation(writer, 23 /* SemicolonToken */); + writePunctuation(writer, 24 /* SemicolonToken */); writer.writeLine(); } - writeIndexSignature(resolved.stringIndexInfo, 132 /* StringKeyword */); - writeIndexSignature(resolved.numberIndexInfo, 130 /* NumberKeyword */); + writeIndexSignature(resolved.stringIndexInfo, 133 /* StringKeyword */); + writeIndexSignature(resolved.numberIndexInfo, 131 /* NumberKeyword */); for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); @@ -24865,21 +25004,21 @@ var ts; var signature = signatures_1[_f]; writePropertyWithModifiers(p); buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, /*kind*/ undefined, symbolStack); - writePunctuation(writer, 23 /* SemicolonToken */); + writePunctuation(writer, 24 /* SemicolonToken */); writer.writeLine(); } } else { writePropertyWithModifiers(p); - writePunctuation(writer, 54 /* ColonToken */); + writePunctuation(writer, 55 /* ColonToken */); writeSpace(writer); writeType(t, 0 /* None */); - writePunctuation(writer, 23 /* SemicolonToken */); + writePunctuation(writer, 24 /* SemicolonToken */); writer.writeLine(); } } writer.decreaseIndent(); - writePunctuation(writer, 16 /* CloseBraceToken */); + writePunctuation(writer, 17 /* CloseBraceToken */); inObjectTypeLiteral = saveInObjectTypeLiteral; } } @@ -24894,7 +25033,7 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 83 /* ExtendsKeyword */); + writeKeyword(writer, 84 /* ExtendsKeyword */); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } @@ -24902,7 +25041,7 @@ var ts; function buildParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack) { var parameterNode = p.valueDeclaration; if (ts.isRestParameter(parameterNode)) { - writePunctuation(writer, 22 /* DotDotDotToken */); + writePunctuation(writer, 23 /* DotDotDotToken */); } if (ts.isBindingPattern(parameterNode.name)) { buildBindingPatternDisplay(parameterNode.name, writer, enclosingDeclaration, flags, symbolStack); @@ -24911,37 +25050,37 @@ var ts; appendSymbolNameOnly(p, writer); } if (isOptionalParameter(parameterNode)) { - writePunctuation(writer, 53 /* QuestionToken */); + writePunctuation(writer, 54 /* QuestionToken */); } - writePunctuation(writer, 54 /* ColonToken */); + writePunctuation(writer, 55 /* ColonToken */); writeSpace(writer); buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); } function buildBindingPatternDisplay(bindingPattern, writer, enclosingDeclaration, flags, symbolStack) { // We have to explicitly emit square bracket and bracket because these tokens are not stored inside the node. - if (bindingPattern.kind === 167 /* ObjectBindingPattern */) { - writePunctuation(writer, 15 /* OpenBraceToken */); + if (bindingPattern.kind === 168 /* ObjectBindingPattern */) { + writePunctuation(writer, 16 /* OpenBraceToken */); buildDisplayForCommaSeparatedList(bindingPattern.elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); - writePunctuation(writer, 16 /* CloseBraceToken */); + writePunctuation(writer, 17 /* CloseBraceToken */); } - else if (bindingPattern.kind === 168 /* ArrayBindingPattern */) { - writePunctuation(writer, 19 /* OpenBracketToken */); + else if (bindingPattern.kind === 169 /* ArrayBindingPattern */) { + writePunctuation(writer, 20 /* OpenBracketToken */); var elements = bindingPattern.elements; buildDisplayForCommaSeparatedList(elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); if (elements && elements.hasTrailingComma) { - writePunctuation(writer, 24 /* CommaToken */); + writePunctuation(writer, 25 /* CommaToken */); } - writePunctuation(writer, 20 /* CloseBracketToken */); + writePunctuation(writer, 21 /* CloseBracketToken */); } } function buildBindingElementDisplay(bindingElement, writer, enclosingDeclaration, flags, symbolStack) { if (ts.isOmittedExpression(bindingElement)) { return; } - ts.Debug.assert(bindingElement.kind === 169 /* BindingElement */); + ts.Debug.assert(bindingElement.kind === 170 /* BindingElement */); if (bindingElement.propertyName) { writer.writeSymbol(ts.getTextOfNode(bindingElement.propertyName), bindingElement.symbol); - writePunctuation(writer, 54 /* ColonToken */); + writePunctuation(writer, 55 /* ColonToken */); writeSpace(writer); } if (ts.isBindingPattern(bindingElement.name)) { @@ -24949,75 +25088,75 @@ var ts; } else { if (bindingElement.dotDotDotToken) { - writePunctuation(writer, 22 /* DotDotDotToken */); + writePunctuation(writer, 23 /* DotDotDotToken */); } appendSymbolNameOnly(bindingElement.symbol, writer); } } function buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, flags, symbolStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 25 /* LessThanToken */); + writePunctuation(writer, 26 /* LessThanToken */); buildDisplayForCommaSeparatedList(typeParameters, writer, function (p) { return buildTypeParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack); }); - writePunctuation(writer, 27 /* GreaterThanToken */); + writePunctuation(writer, 28 /* GreaterThanToken */); } } function buildDisplayForCommaSeparatedList(list, writer, action) { for (var i = 0; i < list.length; i++) { if (i > 0) { - writePunctuation(writer, 24 /* CommaToken */); + writePunctuation(writer, 25 /* CommaToken */); writeSpace(writer); } action(list[i]); } } - function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration, flags, symbolStack) { + function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 25 /* LessThanToken */); - var flags_1 = 256 /* InFirstTypeArgument */; + writePunctuation(writer, 26 /* LessThanToken */); + var flags = 256 /* InFirstTypeArgument */; for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 24 /* CommaToken */); + writePunctuation(writer, 25 /* CommaToken */); writeSpace(writer); - flags_1 = 0 /* None */; + flags = 0 /* None */; } - buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, flags_1); + buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, flags); } - writePunctuation(writer, 27 /* GreaterThanToken */); + writePunctuation(writer, 28 /* GreaterThanToken */); } } function buildDisplayForParametersAndDelimiters(thisParameter, parameters, writer, enclosingDeclaration, flags, symbolStack) { - writePunctuation(writer, 17 /* OpenParenToken */); + writePunctuation(writer, 18 /* OpenParenToken */); if (thisParameter) { buildParameterDisplay(thisParameter, writer, enclosingDeclaration, flags, symbolStack); } for (var i = 0; i < parameters.length; i++) { if (i > 0 || thisParameter) { - writePunctuation(writer, 24 /* CommaToken */); + writePunctuation(writer, 25 /* CommaToken */); writeSpace(writer); } buildParameterDisplay(parameters[i], writer, enclosingDeclaration, flags, symbolStack); } - writePunctuation(writer, 18 /* CloseParenToken */); + writePunctuation(writer, 19 /* CloseParenToken */); } function buildTypePredicateDisplay(predicate, writer, enclosingDeclaration, flags, symbolStack) { if (ts.isIdentifierTypePredicate(predicate)) { writer.writeParameter(predicate.parameterName); } else { - writeKeyword(writer, 97 /* ThisKeyword */); + writeKeyword(writer, 98 /* ThisKeyword */); } writeSpace(writer); - writeKeyword(writer, 124 /* IsKeyword */); + writeKeyword(writer, 125 /* IsKeyword */); writeSpace(writer); buildTypeDisplay(predicate.type, writer, enclosingDeclaration, flags, symbolStack); } function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { if (flags & 8 /* WriteArrowStyleSignature */) { writeSpace(writer); - writePunctuation(writer, 34 /* EqualsGreaterThanToken */); + writePunctuation(writer, 35 /* EqualsGreaterThanToken */); } else { - writePunctuation(writer, 54 /* ColonToken */); + writePunctuation(writer, 55 /* ColonToken */); } writeSpace(writer); if (signature.typePredicate) { @@ -25030,7 +25169,7 @@ var ts; } function buildSignatureDisplay(signature, writer, enclosingDeclaration, flags, kind, symbolStack) { if (kind === 1 /* Construct */) { - writeKeyword(writer, 92 /* NewKeyword */); + writeKeyword(writer, 93 /* NewKeyword */); writeSpace(writer); } if (signature.target && (flags & 32 /* WriteTypeArgumentsOfSignature */)) { @@ -25068,22 +25207,22 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 169 /* BindingElement */: + case 170 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 218 /* VariableDeclaration */: + case 219 /* 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 225 /* ModuleDeclaration */: - case 221 /* ClassDeclaration */: - case 222 /* InterfaceDeclaration */: - case 223 /* TypeAliasDeclaration */: - case 220 /* FunctionDeclaration */: - case 224 /* EnumDeclaration */: - case 229 /* ImportEqualsDeclaration */: + case 226 /* ModuleDeclaration */: + case 222 /* ClassDeclaration */: + case 223 /* InterfaceDeclaration */: + case 224 /* TypeAliasDeclaration */: + case 221 /* FunctionDeclaration */: + case 225 /* EnumDeclaration */: + case 230 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -25091,52 +25230,52 @@ var ts; var parent_10 = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedModifierFlags(node) & 1 /* Export */) && - !(node.kind !== 229 /* ImportEqualsDeclaration */ && parent_10.kind !== 256 /* SourceFile */ && ts.isInAmbientContext(parent_10))) { + !(node.kind !== 230 /* ImportEqualsDeclaration */ && parent_10.kind !== 256 /* SourceFile */ && ts.isInAmbientContext(parent_10))) { return isGlobalSourceFile(parent_10); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent_10); - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: if (ts.getModifierFlags(node) & (8 /* Private */ | 16 /* Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so const it fall into next case statement - case 148 /* Constructor */: - case 152 /* ConstructSignature */: - case 151 /* CallSignature */: - case 153 /* IndexSignature */: - case 142 /* Parameter */: - case 226 /* ModuleBlock */: - case 156 /* FunctionType */: - case 157 /* ConstructorType */: - case 159 /* TypeLiteral */: - case 155 /* TypeReference */: - case 160 /* ArrayType */: - case 161 /* TupleType */: - case 162 /* UnionType */: - case 163 /* IntersectionType */: - case 164 /* ParenthesizedType */: + case 149 /* Constructor */: + case 153 /* ConstructSignature */: + case 152 /* CallSignature */: + case 154 /* IndexSignature */: + case 143 /* Parameter */: + case 227 /* ModuleBlock */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: + case 160 /* TypeLiteral */: + case 156 /* TypeReference */: + case 161 /* ArrayType */: + case 162 /* TupleType */: + case 163 /* UnionType */: + case 164 /* IntersectionType */: + case 165 /* 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 231 /* ImportClause */: - case 232 /* NamespaceImport */: - case 234 /* ImportSpecifier */: + case 232 /* ImportClause */: + case 233 /* NamespaceImport */: + case 235 /* ImportSpecifier */: return false; // Type parameters are always visible - case 141 /* TypeParameter */: + case 142 /* TypeParameter */: // Source file and namespace export are always visible case 256 /* SourceFile */: - case 228 /* NamespaceExportDeclaration */: + case 229 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: return false; default: return false; @@ -25145,10 +25284,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 235 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 236 /* ExportAssignment */) { exportSymbol = resolveName(node.parent, node.text, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */ | 8388608 /* Alias */, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 238 /* ExportSpecifier */) { + else if (node.parent.kind === 239 /* ExportSpecifier */) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -25242,12 +25381,12 @@ var ts; node = ts.getRootDeclaration(node); while (node) { switch (node.kind) { - case 218 /* VariableDeclaration */: - case 219 /* VariableDeclarationList */: - case 234 /* ImportSpecifier */: - case 233 /* NamedImports */: - case 232 /* NamespaceImport */: - case 231 /* ImportClause */: + case 219 /* VariableDeclaration */: + case 220 /* VariableDeclarationList */: + case 235 /* ImportSpecifier */: + case 234 /* NamedImports */: + case 233 /* NamespaceImport */: + case 232 /* ImportClause */: node = node.parent; break; default: @@ -25282,12 +25421,12 @@ var ts; } function getTextOfPropertyName(name) { switch (name.kind) { - case 69 /* Identifier */: + case 70 /* Identifier */: return name.text; case 9 /* StringLiteral */: case 8 /* NumericLiteral */: return name.text; - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: if (ts.isStringOrNumericLiteral(name.expression.kind)) { return name.expression.text; } @@ -25295,7 +25434,7 @@ var ts; return undefined; } function isComputedNonLiteralName(name) { - return name.kind === 140 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteral(name.expression.kind); + return name.kind === 141 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteral(name.expression.kind); } /** Return the inferred type for a binding element */ function getTypeForBindingElement(declaration) { @@ -25315,7 +25454,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 167 /* ObjectBindingPattern */) { + if (pattern.kind === 168 /* ObjectBindingPattern */) { // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) var name_14 = declaration.propertyName || declaration.name; if (isComputedNonLiteralName(name_14)) { @@ -25383,16 +25522,16 @@ var ts; if (typeTag && typeTag.typeExpression) { return typeTag.typeExpression.type; } - if (declaration.kind === 218 /* VariableDeclaration */ && - declaration.parent.kind === 219 /* VariableDeclarationList */ && - declaration.parent.parent.kind === 200 /* VariableStatement */) { + if (declaration.kind === 219 /* VariableDeclaration */ && + declaration.parent.kind === 220 /* VariableDeclarationList */ && + declaration.parent.parent.kind === 201 /* VariableStatement */) { // @type annotation might have been on the variable statement, try that instead. var annotation = ts.getJSDocTypeTag(declaration.parent.parent); if (annotation && annotation.typeExpression) { return annotation.typeExpression.type; } } - else if (declaration.kind === 142 /* Parameter */) { + else if (declaration.kind === 143 /* Parameter */) { // If it's a parameter, see if the parent has a jsdoc comment with an @param // annotation. var paramTag = ts.getCorrespondingJSDocParameterTag(declaration); @@ -25402,9 +25541,13 @@ var ts; } return undefined; } - function isAutoVariableInitializer(initializer) { - var expr = initializer && ts.skipParentheses(initializer); - return !expr || expr.kind === 93 /* NullKeyword */ || expr.kind === 69 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; + function isNullOrUndefined(node) { + var expr = ts.skipParentheses(node); + return expr.kind === 94 /* NullKeyword */ || expr.kind === 70 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; + } + function isEmptyArrayLiteral(node) { + var expr = ts.skipParentheses(node); + return expr.kind === 171 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, optional) { return strictNullChecks && optional ? includeFalsyTypes(type, 2048 /* Undefined */) : type; @@ -25421,10 +25564,10 @@ var ts; } } // A variable declared in a for..in statement is always of type string - if (declaration.parent.parent.kind === 207 /* ForInStatement */) { + if (declaration.parent.parent.kind === 208 /* ForInStatement */) { return stringType; } - if (declaration.parent.parent.kind === 208 /* ForOfStatement */) { + if (declaration.parent.parent.kind === 209 /* 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, @@ -25438,18 +25581,24 @@ var ts; if (declaration.type) { return addOptionality(getTypeFromTypeNode(declaration.type), /*optional*/ declaration.questionToken && includeOptionality); } - // Use control flow type inference for non-ambient, non-exported var or let variables with no initializer - // or a 'null' or 'undefined' initializer. - if (declaration.kind === 218 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && - !(ts.getCombinedNodeFlags(declaration) & 2 /* Const */) && !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && - !ts.isInAmbientContext(declaration) && isAutoVariableInitializer(declaration.initializer)) { - return autoType; + if (declaration.kind === 219 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !ts.isInAmbientContext(declaration)) { + // Use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no + // initializer or a 'null' or 'undefined' initializer. + if (!(ts.getCombinedNodeFlags(declaration) & 2 /* Const */) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { + return autoType; + } + // Use control flow tracked 'any[]' type for non-ambient, non-exported variables with an empty array + // literal initializer. + if (declaration.initializer && isEmptyArrayLiteral(declaration.initializer)) { + return autoArrayType; + } } - if (declaration.kind === 142 /* Parameter */) { + if (declaration.kind === 143 /* 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 === 150 /* SetAccessor */ && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 149 /* GetAccessor */); + if (func.kind === 151 /* SetAccessor */ && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 150 /* GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -25464,8 +25613,7 @@ var ts; // Use contextual parameter type if one is available var type = void 0; if (declaration.symbol.name === "this") { - var thisParameter = getContextualThisParameter(func); - type = thisParameter ? getTypeOfSymbol(thisParameter) : undefined; + type = getContextualThisParameterType(func); } else { type = getContextuallyTypedParameterType(declaration); @@ -25537,7 +25685,7 @@ var ts; var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); if (elements.length === 0 || (!ts.isOmittedExpression(lastElement) && lastElement.dotDotDotToken)) { - return languageVersion >= 2 /* ES6 */ ? createIterableType(anyType) : anyArrayType; + return languageVersion >= 2 /* ES2015 */ ? 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 ts.isOmittedExpression(e) ? anyType : getTypeFromBindingElement(e, includePatternInType, reportErrors); }); @@ -25556,7 +25704,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, reportErrors) { - return pattern.kind === 167 /* ObjectBindingPattern */ + return pattern.kind === 168 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -25595,7 +25743,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 142 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 143 /* Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function getTypeOfVariableOrParameterOrProperty(symbol) { @@ -25611,7 +25759,7 @@ var ts; return links.type = anyType; } // Handle export default expressions - if (declaration.kind === 235 /* ExportAssignment */) { + if (declaration.kind === 236 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } if (declaration.flags & 1048576 /* JavaScriptFile */ && declaration.kind === 280 /* JSDocPropertyTag */ && declaration.typeExpression) { @@ -25627,8 +25775,8 @@ var ts; // * exports.p = expr // * this.p = expr // * className.prototype.method = expr - if (declaration.kind === 187 /* BinaryExpression */ || - declaration.kind === 172 /* PropertyAccessExpression */ && declaration.parent.kind === 187 /* BinaryExpression */) { + if (declaration.kind === 188 /* BinaryExpression */ || + declaration.kind === 173 /* PropertyAccessExpression */ && declaration.parent.kind === 188 /* BinaryExpression */) { // Use JS Doc type if present on parent expression statement if (declaration.flags & 1048576 /* JavaScriptFile */) { var typeTag = ts.getJSDocTypeTag(declaration.parent); @@ -25636,7 +25784,7 @@ var ts; return links.type = getTypeFromTypeNode(typeTag.typeExpression.type); } } - var declaredTypes = ts.map(symbol.declarations, function (decl) { return decl.kind === 187 /* BinaryExpression */ ? + var declaredTypes = ts.map(symbol.declarations, function (decl) { return decl.kind === 188 /* BinaryExpression */ ? checkExpressionCached(decl.right) : checkExpressionCached(decl.parent.right); }); type = getUnionType(declaredTypes, /*subtypeReduction*/ true); @@ -25664,7 +25812,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 149 /* GetAccessor */) { + if (accessor.kind === 150 /* GetAccessor */) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -25684,8 +25832,8 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - var getter = ts.getDeclarationOfKind(symbol, 149 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 150 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 150 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 151 /* SetAccessor */); if (getter && getter.flags & 1048576 /* JavaScriptFile */) { var jsDocType = getTypeForVariableLikeDeclarationFromJSDocComment(getter); if (jsDocType) { @@ -25729,7 +25877,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 149 /* GetAccessor */); + var getter_1 = ts.getDeclarationOfKind(symbol, 150 /* 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)); } } @@ -25740,7 +25888,7 @@ var ts; function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (symbol.valueDeclaration.kind === 225 /* ModuleDeclaration */ && ts.isShorthandAmbientModuleSymbol(symbol)) { + if (symbol.valueDeclaration.kind === 226 /* ModuleDeclaration */ && ts.isShorthandAmbientModuleSymbol(symbol)) { links.type = anyType; } else { @@ -25836,9 +25984,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 221 /* ClassDeclaration */ || node.kind === 192 /* ClassExpression */ || - node.kind === 220 /* FunctionDeclaration */ || node.kind === 179 /* FunctionExpression */ || - node.kind === 147 /* MethodDeclaration */ || node.kind === 180 /* ArrowFunction */) { + if (node.kind === 222 /* ClassDeclaration */ || node.kind === 193 /* ClassExpression */ || + node.kind === 221 /* FunctionDeclaration */ || node.kind === 180 /* FunctionExpression */ || + node.kind === 148 /* MethodDeclaration */ || node.kind === 181 /* ArrowFunction */) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -25848,7 +25996,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, 222 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 223 /* InterfaceDeclaration */); return appendOuterTypeParameters(undefined, declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -25857,8 +26005,8 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 222 /* InterfaceDeclaration */ || node.kind === 221 /* ClassDeclaration */ || - node.kind === 192 /* ClassExpression */ || node.kind === 223 /* TypeAliasDeclaration */) { + if (node.kind === 223 /* InterfaceDeclaration */ || node.kind === 222 /* ClassDeclaration */ || + node.kind === 193 /* ClassExpression */ || node.kind === 224 /* TypeAliasDeclaration */) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -26001,7 +26149,7 @@ var ts; type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 222 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 223 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -26033,7 +26181,7 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 222 /* InterfaceDeclaration */) { + if (declaration.kind === 223 /* InterfaceDeclaration */) { if (declaration.flags & 64 /* ContainsThis */) { return false; } @@ -26102,7 +26250,7 @@ var ts; } } else { - declaration = ts.getDeclarationOfKind(symbol, 223 /* TypeAliasDeclaration */); + declaration = ts.getDeclarationOfKind(symbol, 224 /* TypeAliasDeclaration */); type = getTypeFromTypeNode(declaration.type, symbol, typeParameters); } if (popTypeResolution()) { @@ -26128,14 +26276,14 @@ var ts; return !ts.isInAmbientContext(member); } return expr.kind === 8 /* NumericLiteral */ || - expr.kind === 185 /* PrefixUnaryExpression */ && expr.operator === 36 /* MinusToken */ && + expr.kind === 186 /* PrefixUnaryExpression */ && expr.operator === 37 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */ || - expr.kind === 69 /* Identifier */ && !!symbol.exports[expr.text]; + expr.kind === 70 /* Identifier */ && !!symbol.exports[expr.text]; } function enumHasLiteralMembers(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 224 /* EnumDeclaration */) { + if (declaration.kind === 225 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (!isLiteralEnumMember(symbol, member)) { @@ -26163,7 +26311,7 @@ var ts; var memberTypes = ts.createMap(); for (var _i = 0, _a = enumType.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 224 /* EnumDeclaration */) { + if (declaration.kind === 225 /* EnumDeclaration */) { computeEnumMemberValues(declaration); for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; @@ -26201,7 +26349,7 @@ var ts; if (!links.declaredType) { var type = createType(16384 /* TypeParameter */); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 141 /* TypeParameter */).constraint) { + if (!ts.getDeclarationOfKind(symbol, 142 /* TypeParameter */).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -26254,20 +26402,20 @@ var ts; // considered independent. function isIndependentType(node) { switch (node.kind) { - case 117 /* AnyKeyword */: - case 132 /* StringKeyword */: - case 130 /* NumberKeyword */: - case 120 /* BooleanKeyword */: - case 133 /* SymbolKeyword */: - case 103 /* VoidKeyword */: - case 135 /* UndefinedKeyword */: - case 93 /* NullKeyword */: - case 127 /* NeverKeyword */: - case 166 /* LiteralType */: + case 118 /* AnyKeyword */: + case 133 /* StringKeyword */: + case 131 /* NumberKeyword */: + case 121 /* BooleanKeyword */: + case 134 /* SymbolKeyword */: + case 104 /* VoidKeyword */: + case 136 /* UndefinedKeyword */: + case 94 /* NullKeyword */: + case 128 /* NeverKeyword */: + case 167 /* LiteralType */: return true; - case 160 /* ArrayType */: + case 161 /* ArrayType */: return isIndependentType(node.elementType); - case 155 /* TypeReference */: + case 156 /* TypeReference */: return isIndependentTypeReference(node); } return false; @@ -26280,7 +26428,7 @@ var ts; // 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 !== 148 /* Constructor */ && (!node.type || !isIndependentType(node.type))) { + if (node.kind !== 149 /* Constructor */ && (!node.type || !isIndependentType(node.type))) { return false; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { @@ -26301,12 +26449,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: return isIndependentVariableLikeDeclaration(declaration); - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: return isIndependentFunctionLikeDeclaration(declaration); } } @@ -26933,7 +27081,7 @@ var ts; return false; } function createTypePredicateFromTypePredicateNode(node) { - if (node.parameterName.kind === 69 /* Identifier */) { + if (node.parameterName.kind === 70 /* Identifier */) { var parameterName = node.parameterName; return { kind: 1 /* Identifier */, @@ -26976,7 +27124,7 @@ var ts; else { parameters.push(paramSymbol); } - if (param.type && param.type.kind === 166 /* LiteralType */) { + if (param.type && param.type.kind === 167 /* LiteralType */) { hasLiteralTypes = true; } if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) { @@ -26990,10 +27138,10 @@ var ts; } } // If only one accessor includes a this-type annotation, the other behaves as if it had the same type annotation - if ((declaration.kind === 149 /* GetAccessor */ || declaration.kind === 150 /* SetAccessor */) && + if ((declaration.kind === 150 /* GetAccessor */ || declaration.kind === 151 /* SetAccessor */) && !ts.hasDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 149 /* GetAccessor */ ? 150 /* SetAccessor */ : 149 /* GetAccessor */; + var otherKind = declaration.kind === 150 /* GetAccessor */ ? 151 /* SetAccessor */ : 150 /* GetAccessor */; var other = ts.getDeclarationOfKind(declaration.symbol, otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); @@ -27005,24 +27153,21 @@ var ts; if (isJSConstructSignature) { minArgumentCount--; } - if (!thisParameter && ts.isObjectLiteralMethod(declaration)) { - thisParameter = getContextualThisParameter(declaration); - } - var classType = declaration.kind === 148 /* Constructor */ ? + var classType = declaration.kind === 149 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : getTypeParametersFromJSDocTemplate(declaration); - var returnType = getSignatureReturnTypeFromDeclaration(declaration, minArgumentCount, isJSConstructSignature, classType); - var typePredicate = declaration.type && declaration.type.kind === 154 /* TypePredicate */ ? + var returnType = getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType); + var typePredicate = declaration.type && declaration.type.kind === 155 /* TypePredicate */ ? createTypePredicateFromTypePredicateNode(declaration.type) : undefined; links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasLiteralTypes); } return links.resolvedSignature; } - function getSignatureReturnTypeFromDeclaration(declaration, minArgumentCount, isJSConstructSignature, classType) { + function getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType) { if (isJSConstructSignature) { return getTypeFromTypeNode(declaration.parameters[0].type); } @@ -27040,8 +27185,8 @@ var ts; } // 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 === 149 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 150 /* SetAccessor */); + if (declaration.kind === 150 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 151 /* SetAccessor */); return getAnnotatedAccessorType(setter); } if (ts.nodeIsMissing(declaration.body)) { @@ -27055,19 +27200,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 156 /* FunctionType */: - case 157 /* ConstructorType */: - case 220 /* FunctionDeclaration */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: + case 221 /* FunctionDeclaration */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: case 269 /* JSDocFunctionType */: // 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 @@ -27155,7 +27300,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 === 148 /* Constructor */ || signature.declaration.kind === 152 /* ConstructSignature */; + var isConstructor = signature.declaration.kind === 149 /* Constructor */ || signature.declaration.kind === 153 /* ConstructSignature */; var type = createObjectType(2097152 /* Anonymous */); type.members = emptySymbols; type.properties = emptyArray; @@ -27169,7 +27314,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 130 /* NumberKeyword */ : 132 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 131 /* NumberKeyword */ : 133 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -27196,7 +27341,7 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - return ts.getDeclarationOfKind(type.symbol, 141 /* TypeParameter */).constraint; + return ts.getDeclarationOfKind(type.symbol, 142 /* TypeParameter */).constraint; } function hasConstraintReferenceTo(type, target) { var checked; @@ -27229,7 +27374,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 141 /* TypeParameter */).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 142 /* TypeParameter */).parent); } function getTypeListId(types) { var result = ""; @@ -27341,11 +27486,11 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 155 /* TypeReference */: + case 156 /* TypeReference */: return node.typeName; case 267 /* JSDocTypeReference */: return node.name; - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -27355,7 +27500,7 @@ var ts; } return undefined; } - function resolveTypeReferenceName(node, typeReferenceName) { + function resolveTypeReferenceName(typeReferenceName) { if (!typeReferenceName) { return unknownSymbol; } @@ -27386,12 +27531,12 @@ var ts; var type = void 0; if (node.kind === 267 /* JSDocTypeReference */) { var typeReferenceName = getTypeReferenceName(node); - symbol = resolveTypeReferenceName(node, typeReferenceName); + symbol = resolveTypeReferenceName(typeReferenceName); type = getTypeReferenceType(node, symbol); } else { // We only support expressions that are simple qualified names. For other expressions this produces undefined. - var typeNameOrExpression = node.kind === 155 /* TypeReference */ + var typeNameOrExpression = node.kind === 156 /* TypeReference */ ? node.typeName : ts.isEntityNameExpression(node.expression) ? node.expression @@ -27426,9 +27571,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 221 /* ClassDeclaration */: - case 222 /* InterfaceDeclaration */: - case 224 /* EnumDeclaration */: + case 222 /* ClassDeclaration */: + case 223 /* InterfaceDeclaration */: + case 225 /* EnumDeclaration */: return declaration; } } @@ -27838,9 +27983,9 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 222 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 223 /* InterfaceDeclaration */)) { if (!(ts.getModifierFlags(container) & 32 /* Static */) && - (container.kind !== 148 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { + (container.kind !== 149 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -27859,25 +28004,25 @@ var ts; } function getTypeFromTypeNode(node, aliasSymbol, aliasTypeArguments) { switch (node.kind) { - case 117 /* AnyKeyword */: + case 118 /* AnyKeyword */: case 258 /* JSDocAllType */: case 259 /* JSDocUnknownType */: return anyType; - case 132 /* StringKeyword */: + case 133 /* StringKeyword */: return stringType; - case 130 /* NumberKeyword */: + case 131 /* NumberKeyword */: return numberType; - case 120 /* BooleanKeyword */: + case 121 /* BooleanKeyword */: return booleanType; - case 133 /* SymbolKeyword */: + case 134 /* SymbolKeyword */: return esSymbolType; - case 103 /* VoidKeyword */: + case 104 /* VoidKeyword */: return voidType; - case 135 /* UndefinedKeyword */: + case 136 /* UndefinedKeyword */: return undefinedType; - case 93 /* NullKeyword */: + case 94 /* NullKeyword */: return nullType; - case 127 /* NeverKeyword */: + case 128 /* NeverKeyword */: return neverType; case 283 /* JSDocNullKeyword */: return nullType; @@ -27885,33 +28030,33 @@ var ts; return undefinedType; case 285 /* JSDocNeverKeyword */: return neverType; - case 165 /* ThisType */: - case 97 /* ThisKeyword */: + case 166 /* ThisType */: + case 98 /* ThisKeyword */: return getTypeFromThisTypeNode(node); - case 166 /* LiteralType */: + case 167 /* LiteralType */: return getTypeFromLiteralTypeNode(node); case 282 /* JSDocLiteralType */: return getTypeFromLiteralTypeNode(node.literal); - case 155 /* TypeReference */: + case 156 /* TypeReference */: case 267 /* JSDocTypeReference */: return getTypeFromTypeReference(node); - case 154 /* TypePredicate */: + case 155 /* TypePredicate */: return booleanType; - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 158 /* TypeQuery */: + case 159 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 160 /* ArrayType */: + case 161 /* ArrayType */: case 260 /* JSDocArrayType */: return getTypeFromArrayTypeNode(node); - case 161 /* TupleType */: + case 162 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 162 /* UnionType */: + case 163 /* UnionType */: case 261 /* JSDocUnionType */: return getTypeFromUnionTypeNode(node, aliasSymbol, aliasTypeArguments); - case 163 /* IntersectionType */: + case 164 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node, aliasSymbol, aliasTypeArguments); - case 164 /* ParenthesizedType */: + case 165 /* ParenthesizedType */: case 263 /* JSDocNullableType */: case 264 /* JSDocNonNullableType */: case 271 /* JSDocConstructorType */: @@ -27920,16 +28065,16 @@ var ts; return getTypeFromTypeNode(node.type); case 265 /* JSDocRecordType */: return getTypeFromTypeNode(node.literal); - case 156 /* FunctionType */: - case 157 /* ConstructorType */: - case 159 /* TypeLiteral */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: + case 160 /* TypeLiteral */: case 281 /* JSDocTypeLiteral */: case 269 /* JSDocFunctionType */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node, aliasSymbol, aliasTypeArguments); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode - case 69 /* Identifier */: - case 139 /* QualifiedName */: + case 70 /* Identifier */: + case 140 /* QualifiedName */: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); case 262 /* JSDocTupleType */: @@ -28097,23 +28242,23 @@ var ts; var node = symbol.declarations[0].parent; while (node) { switch (node.kind) { - case 156 /* FunctionType */: - case 157 /* ConstructorType */: - case 220 /* FunctionDeclaration */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - case 222 /* InterfaceDeclaration */: - case 223 /* TypeAliasDeclaration */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: + case 221 /* FunctionDeclaration */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 223 /* InterfaceDeclaration */: + case 224 /* TypeAliasDeclaration */: var declaration = node; if (declaration.typeParameters) { for (var _i = 0, _a = declaration.typeParameters; _i < _a.length; _i++) { @@ -28123,14 +28268,14 @@ var ts; } } } - if (ts.isClassLike(node) || node.kind === 222 /* InterfaceDeclaration */) { + if (ts.isClassLike(node) || node.kind === 223 /* InterfaceDeclaration */) { var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; if (thisType && ts.contains(mappedTypes, thisType)) { return true; } } break; - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: case 256 /* SourceFile */: return false; } @@ -28173,35 +28318,50 @@ 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 !== 147 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 148 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: return isContextSensitiveFunctionLikeDeclaration(node); - case 171 /* ObjectLiteralExpression */: + case 172 /* ObjectLiteralExpression */: return ts.forEach(node.properties, isContextSensitive); - case 170 /* ArrayLiteralExpression */: + case 171 /* ArrayLiteralExpression */: return ts.forEach(node.elements, isContextSensitive); - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 187 /* BinaryExpression */: - return node.operatorToken.kind === 52 /* BarBarToken */ && + case 188 /* BinaryExpression */: + return node.operatorToken.kind === 53 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); case 253 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: return isContextSensitiveFunctionLikeDeclaration(node); - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return isContextSensitive(node.expression); } return false; } function isContextSensitiveFunctionLikeDeclaration(node) { - var areAllParametersUntyped = !ts.forEach(node.parameters, function (p) { return p.type; }); - var isNullaryArrow = node.kind === 180 /* ArrowFunction */ && !node.parameters.length; - return !node.typeParameters && areAllParametersUntyped && !isNullaryArrow; + // Functions with type parameters are not context sensitive. + if (node.typeParameters) { + return false; + } + // Functions with any parameters that lack type annotations are context sensitive. + if (ts.forEach(node.parameters, function (p) { return !p.type; })) { + return true; + } + // For arrow functions we now know we're not context sensitive. + if (node.kind === 181 /* ArrowFunction */) { + return false; + } + // If the first parameter is not an explicit 'this' parameter, then the function has + // an implicit 'this' parameter which is subject to contextual typing. Otherwise we + // know that all parameters (including 'this') have type annotations and nothing is + // subject to contextual typing. + var parameter = ts.firstOrUndefined(node.parameters); + return !(parameter && ts.parameterIsThisKeyword(parameter)); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func); @@ -28691,8 +28851,8 @@ var ts; } if (source.flags & 524288 /* Union */ && target.flags & 524288 /* Union */ || source.flags & 1048576 /* Intersection */ && target.flags & 1048576 /* Intersection */) { - if (result = eachTypeRelatedToSomeType(source, target, /*reportErrors*/ false)) { - if (result &= eachTypeRelatedToSomeType(target, source, /*reportErrors*/ false)) { + if (result = eachTypeRelatedToSomeType(source, target)) { + if (result &= eachTypeRelatedToSomeType(target, source)) { return result; } } @@ -28750,7 +28910,7 @@ var ts; } return false; } - function eachTypeRelatedToSomeType(source, target, reportErrors) { + function eachTypeRelatedToSomeType(source, target) { var result = -1 /* True */; var sourceTypes = source.types; for (var _i = 0, sourceTypes_1 = sourceTypes; _i < sourceTypes_1.length; _i++) { @@ -29414,7 +29574,7 @@ var ts; type.flags & 64 /* NumberLiteral */ ? numberType : type.flags & 128 /* BooleanLiteral */ ? booleanType : type.flags & 256 /* EnumLiteral */ ? type.baseType : - type.flags & 524288 /* Union */ && !(type.flags & 16 /* Enum */) ? getUnionType(ts.map(type.types, getBaseTypeOfLiteralType)) : + type.flags & 524288 /* Union */ && !(type.flags & 16 /* Enum */) ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) : type; } function getWidenedLiteralType(type) { @@ -29422,7 +29582,7 @@ var ts; type.flags & 64 /* NumberLiteral */ && type.flags & 16777216 /* FreshLiteral */ ? numberType : type.flags & 128 /* BooleanLiteral */ ? booleanType : type.flags & 256 /* EnumLiteral */ ? type.baseType : - type.flags & 524288 /* Union */ && !(type.flags & 16 /* Enum */) ? getUnionType(ts.map(type.types, getWidenedLiteralType)) : + type.flags & 524288 /* Union */ && !(type.flags & 16 /* Enum */) ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) : type; } /** @@ -29549,10 +29709,10 @@ var ts; return getWidenedTypeOfObjectLiteral(type); } if (type.flags & 524288 /* Union */) { - return getUnionType(ts.map(type.types, getWidenedConstituentType)); + return getUnionType(ts.sameMap(type.types, getWidenedConstituentType)); } if (isArrayType(type) || isTupleType(type)) { - return createTypeReference(type.target, ts.map(type.typeArguments, getWidenedType)); + return createTypeReference(type.target, ts.sameMap(type.typeArguments, getWidenedType)); } } return type; @@ -29604,25 +29764,25 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 142 /* Parameter */: + case 143 /* 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 169 /* BindingElement */: + case 170 /* BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 220 /* FunctionDeclaration */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 221 /* FunctionDeclaration */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -29668,7 +29828,7 @@ var ts; signature: signature, inferUnionTypes: inferUnionTypes, inferences: inferences, - inferredTypes: new Array(signature.typeParameters.length) + inferredTypes: new Array(signature.typeParameters.length), }; } function createTypeInferencesObject() { @@ -29676,7 +29836,7 @@ var ts; primary: undefined, secondary: undefined, topLevel: true, - isFixed: false + isFixed: false, }; } // Return true if the given type could possibly reference a type parameter for which @@ -29957,7 +30117,7 @@ var ts; var widenLiteralTypes = context.inferences[index].topLevel && !hasPrimitiveConstraint(signature.typeParameters[index]) && (context.inferences[index].isFixed || !isTypeParameterAtTopLevel(getReturnTypeOfSignature(signature), signature.typeParameters[index])); - var baseInferences = widenLiteralTypes ? ts.map(inferences, getWidenedLiteralType) : inferences; + var baseInferences = widenLiteralTypes ? ts.sameMap(inferences, getWidenedLiteralType) : inferences; // Infer widened union or supertype, or the unknown type for no common supertype var unionOrSuperType = context.inferUnionTypes ? getUnionType(baseInferences, /*subtypeReduction*/ true) : getCommonSupertype(baseInferences); inferredType = unionOrSuperType ? getWidenedType(unionOrSuperType) : unknownType; @@ -30011,10 +30171,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 158 /* TypeQuery */: + case 159 /* TypeQuery */: return true; - case 69 /* Identifier */: - case 139 /* QualifiedName */: + case 70 /* Identifier */: + case 140 /* QualifiedName */: node = node.parent; continue; default: @@ -30028,14 +30188,14 @@ var ts; // leftmost identifier followed by zero or more property names separated by dots. // The result is undefined if the reference isn't a dotted name. function getFlowCacheKey(node) { - if (node.kind === 69 /* Identifier */) { + if (node.kind === 70 /* Identifier */) { var symbol = getResolvedSymbol(node); return symbol !== unknownSymbol ? "" + getSymbolId(symbol) : undefined; } - if (node.kind === 97 /* ThisKeyword */) { + if (node.kind === 98 /* ThisKeyword */) { return "0"; } - if (node.kind === 172 /* PropertyAccessExpression */) { + if (node.kind === 173 /* PropertyAccessExpression */) { var key = getFlowCacheKey(node.expression); return key && key + "." + node.name.text; } @@ -30043,31 +30203,31 @@ var ts; } function getLeftmostIdentifierOrThis(node) { switch (node.kind) { - case 69 /* Identifier */: - case 97 /* ThisKeyword */: + case 70 /* Identifier */: + case 98 /* ThisKeyword */: return node; - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: return getLeftmostIdentifierOrThis(node.expression); } return undefined; } function isMatchingReference(source, target) { switch (source.kind) { - case 69 /* Identifier */: - return target.kind === 69 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 218 /* VariableDeclaration */ || target.kind === 169 /* BindingElement */) && + case 70 /* Identifier */: + return target.kind === 70 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 219 /* VariableDeclaration */ || target.kind === 170 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 97 /* ThisKeyword */: - return target.kind === 97 /* ThisKeyword */; - case 172 /* PropertyAccessExpression */: - return target.kind === 172 /* PropertyAccessExpression */ && + case 98 /* ThisKeyword */: + return target.kind === 98 /* ThisKeyword */; + case 173 /* PropertyAccessExpression */: + return target.kind === 173 /* PropertyAccessExpression */ && source.name.text === target.name.text && isMatchingReference(source.expression, target.expression); } return false; } function containsMatchingReference(source, target) { - while (source.kind === 172 /* PropertyAccessExpression */) { + while (source.kind === 173 /* PropertyAccessExpression */) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -30080,15 +30240,15 @@ var ts; // a possible discriminant if its type differs in the constituents of containing union type, and if every // choice is a unit type or a union of unit types. function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 172 /* PropertyAccessExpression */ && + return target.kind === 173 /* PropertyAccessExpression */ && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.text); } function getDeclaredTypeOfReference(expr) { - if (expr.kind === 69 /* Identifier */) { + if (expr.kind === 70 /* Identifier */) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 172 /* PropertyAccessExpression */) { + if (expr.kind === 173 /* PropertyAccessExpression */) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.text); } @@ -30118,7 +30278,7 @@ var ts; } } } - if (callExpression.expression.kind === 172 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 173 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -30249,7 +30409,7 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false) || unknownType); } function getAssignedTypeOfBinaryExpression(node) { - return node.parent.kind === 170 /* ArrayLiteralExpression */ || node.parent.kind === 253 /* PropertyAssignment */ ? + return node.parent.kind === 171 /* ArrayLiteralExpression */ || node.parent.kind === 253 /* PropertyAssignment */ ? getTypeWithDefault(getAssignedType(node), node.right) : checkExpression(node.right); } @@ -30268,17 +30428,17 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 207 /* ForInStatement */: + case 208 /* ForInStatement */: return stringType; - case 208 /* ForOfStatement */: + case 209 /* ForOfStatement */: return checkRightHandSideOfForOf(parent.expression) || unknownType; - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 181 /* DeleteExpression */: + case 182 /* DeleteExpression */: return undefinedType; - case 170 /* ArrayLiteralExpression */: + case 171 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 191 /* SpreadElementExpression */: + case 192 /* SpreadElementExpression */: return getAssignedTypeOfSpreadElement(parent); case 253 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); @@ -30290,7 +30450,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 167 /* ObjectBindingPattern */ ? + var type = pattern.kind === 168 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, ts.indexOf(pattern.elements, node)) : @@ -30308,38 +30468,51 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 207 /* ForInStatement */) { + if (node.parent.parent.kind === 208 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 208 /* ForOfStatement */) { + if (node.parent.parent.kind === 209 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent.expression) || unknownType; } return unknownType; } function getInitialType(node) { - return node.kind === 218 /* VariableDeclaration */ ? + return node.kind === 219 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 218 /* VariableDeclaration */ || node.kind === 169 /* BindingElement */ ? + return node.kind === 219 /* VariableDeclaration */ || node.kind === 170 /* BindingElement */ ? getInitialType(node) : getAssignedType(node); } + function isEmptyArrayAssignment(node) { + return node.kind === 219 /* VariableDeclaration */ && node.initializer && + isEmptyArrayLiteral(node.initializer) || + node.kind !== 170 /* BindingElement */ && node.parent.kind === 188 /* BinaryExpression */ && + isEmptyArrayLiteral(node.parent.right); + } function getReferenceCandidate(node) { switch (node.kind) { - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 56 /* EqualsToken */: + case 57 /* EqualsToken */: return getReferenceCandidate(node.left); - case 24 /* CommaToken */: + case 25 /* CommaToken */: return getReferenceCandidate(node.right); } } return node; } + function getReferenceRoot(node) { + var parent = node.parent; + return parent.kind === 179 /* ParenthesizedExpression */ || + parent.kind === 188 /* BinaryExpression */ && parent.operatorToken.kind === 57 /* EqualsToken */ && parent.left === node || + parent.kind === 188 /* BinaryExpression */ && parent.operatorToken.kind === 25 /* CommaToken */ && parent.right === node ? + getReferenceRoot(parent) : node; + } function getTypeOfSwitchClause(clause) { if (clause.kind === 249 /* CaseClause */) { var caseType = getRegularTypeOfLiteralType(checkExpression(clause.expression)); @@ -30415,24 +30588,105 @@ var ts; function createFlowType(type, incomplete) { return incomplete ? { flags: 0, type: type } : type; } + // An evolving array type tracks the element types that have so far been seen in an + // 'x.push(value)' or 'x[n] = value' operation along the control flow graph. Evolving + // array types are ultimately converted into manifest array types (using getFinalArrayType) + // and never escape the getFlowTypeOfReference function. + function createEvolvingArrayType(elementType) { + var result = createObjectType(2097152 /* Anonymous */); + result.elementType = elementType; + return result; + } + function getEvolvingArrayType(elementType) { + return evolvingArrayTypes[elementType.id] || (evolvingArrayTypes[elementType.id] = createEvolvingArrayType(elementType)); + } + // When adding evolving array element types we do not perform subtype reduction. Instead, + // we defer subtype reduction until the evolving array type is finalized into a manifest + // array type. + function addEvolvingArrayElementType(evolvingArrayType, node) { + var elementType = getBaseTypeOfLiteralType(checkExpression(node)); + return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType])); + } + function isEvolvingArrayType(type) { + return !!(type.flags & 2097152 /* Anonymous */ && type.elementType); + } + function createFinalArrayType(elementType) { + return elementType.flags & 8192 /* Never */ ? + autoArrayType : + createArrayType(elementType.flags & 524288 /* Union */ ? + getUnionType(elementType.types, /*subtypeReduction*/ true) : + elementType); + } + // We perform subtype reduction upon obtaining the final array type from an evolving array type. + function getFinalArrayType(evolvingArrayType) { + return evolvingArrayType.finalArrayType || (evolvingArrayType.finalArrayType = createFinalArrayType(evolvingArrayType.elementType)); + } + function finalizeEvolvingArrayType(type) { + return isEvolvingArrayType(type) ? getFinalArrayType(type) : type; + } + function getElementTypeOfEvolvingArrayType(type) { + return isEvolvingArrayType(type) ? type.elementType : neverType; + } + function isEvolvingArrayTypeList(types) { + var hasEvolvingArrayType = false; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; + if (!(t.flags & 8192 /* Never */)) { + if (!isEvolvingArrayType(t)) { + return false; + } + hasEvolvingArrayType = true; + } + } + return hasEvolvingArrayType; + } + // At flow control branch or loop junctions, if the type along every antecedent code path + // is an evolving array type, we construct a combined evolving array type. Otherwise we + // finalize all evolving array types. + function getUnionOrEvolvingArrayType(types, subtypeReduction) { + return isEvolvingArrayTypeList(types) ? + getEvolvingArrayType(getUnionType(ts.map(types, getElementTypeOfEvolvingArrayType))) : + getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction); + } + // Return true if the given node is 'x' in an 'x.length', x.push(value)', 'x.unshift(value)' or + // 'x[n] = value' operation, where 'n' is an expression of type any, undefined, or a number-like type. + function isEvolvingArrayOperationTarget(node) { + var root = getReferenceRoot(node); + var parent = root.parent; + var isLengthPushOrUnshift = parent.kind === 173 /* PropertyAccessExpression */ && (parent.name.text === "length" || + parent.parent.kind === 175 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 174 /* ElementAccessExpression */ && + parent.expression === root && + parent.parent.kind === 188 /* BinaryExpression */ && + parent.parent.operatorToken.kind === 57 /* EqualsToken */ && + parent.parent.left === parent && + !ts.isAssignmentTarget(parent.parent) && + isTypeAnyOrAllConstituentTypesHaveKind(checkExpression(parent.argumentExpression), 340 /* NumberLike */ | 2048 /* Undefined */); + return isLengthPushOrUnshift || isElementAssignment; + } function getFlowTypeOfReference(reference, declaredType, assumeInitialized, flowContainer) { var key; if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 4178943 /* Narrowable */)) { return declaredType; } var initialType = assumeInitialized ? declaredType : - declaredType === autoType ? undefinedType : + declaredType === autoType || declaredType === autoArrayType ? undefinedType : includeFalsyTypes(declaredType, 2048 /* Undefined */); var visitedFlowStart = visitedFlowCount; - var result = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); + var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); visitedFlowCount = visitedFlowStart; - if (reference.parent.kind === 196 /* NonNullExpression */ && getTypeWithFacts(result, 524288 /* NEUndefinedOrNull */).flags & 8192 /* Never */) { + // When the reference is 'x' in an 'x.length', 'x.push(value)', 'x.unshift(value)' or x[n] = value' operation, + // we give type 'any[]' to 'x' instead of using the type determined by control flow analysis such that operations + // on empty arrays are possible without implicit any errors and new element types can be inferred without + // type mismatch errors. + var resultType = isEvolvingArrayType(evolvedType) && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); + if (reference.parent.kind === 197 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 8192 /* Never */) { return declaredType; } - return result; + return resultType; function getTypeAtFlowNode(flow) { while (true) { - if (flow.flags & 512 /* Shared */) { + if (flow.flags & 1024 /* Shared */) { // We cache results of flow type resolution for shared nodes that were previously visited in // the same getFlowTypeOfReference invocation. A node is considered shared when it is the // antecedent of more than one node. @@ -30465,10 +30719,17 @@ var ts; getTypeAtFlowBranchLabel(flow) : getTypeAtFlowLoopLabel(flow); } + else if (flow.flags & 256 /* ArrayMutation */) { + type = getTypeAtFlowArrayMutation(flow); + if (!type) { + flow = flow.antecedent; + continue; + } + } else if (flow.flags & 2 /* Start */) { // Check if we should continue with the control flow of the containing function. var container = flow.container; - if (container && container !== flowContainer && reference.kind !== 172 /* PropertyAccessExpression */) { + if (container && container !== flowContainer && reference.kind !== 173 /* PropertyAccessExpression */) { flow = container.flowNode; continue; } @@ -30477,10 +30738,10 @@ var ts; } else { // Unreachable code errors are reported in the binding phase. Here we - // simply return the declared type to reduce follow-on errors. - type = declaredType; + // simply return the non-auto declared type to reduce follow-on errors. + type = convertAutoToAny(declaredType); } - if (flow.flags & 512 /* Shared */) { + if (flow.flags & 1024 /* Shared */) { // Record visited node and the associated type in the cache. visitedFlowNodes[visitedFlowCount] = flow; visitedFlowTypes[visitedFlowCount] = type; @@ -30494,13 +30755,21 @@ var ts; // Assignments only narrow the computed type if the declared type is a union type. Thus, we // only need to evaluate the assigned type if the declared type is a union type. if (isMatchingReference(reference, node)) { - if (node.parent.kind === 185 /* PrefixUnaryExpression */ || node.parent.kind === 186 /* PostfixUnaryExpression */) { + if (node.parent.kind === 186 /* PrefixUnaryExpression */ || node.parent.kind === 187 /* PostfixUnaryExpression */) { var flowType = getTypeAtFlowNode(flow.antecedent); return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType)); } - return declaredType === autoType ? getBaseTypeOfLiteralType(getInitialOrAssignedType(node)) : - declaredType.flags & 524288 /* Union */ ? getAssignmentReducedType(declaredType, getInitialOrAssignedType(node)) : - declaredType; + if (declaredType === autoType || declaredType === autoArrayType) { + if (isEmptyArrayAssignment(node)) { + return getEvolvingArrayType(neverType); + } + var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(node)); + return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; + } + if (declaredType.flags & 524288 /* Union */) { + return getAssignmentReducedType(declaredType, getInitialOrAssignedType(node)); + } + return declaredType; } // We didn't have a direct match. However, if the reference is a dotted name, this // may be an assignment to a left hand part of the reference. For example, for a @@ -30512,24 +30781,56 @@ var ts; // Assignment doesn't affect reference return undefined; } + function getTypeAtFlowArrayMutation(flow) { + var node = flow.node; + var expr = node.kind === 175 /* CallExpression */ ? + node.expression.expression : + node.left.expression; + if (isMatchingReference(reference, getReferenceCandidate(expr))) { + var flowType = getTypeAtFlowNode(flow.antecedent); + var type = getTypeFromFlowType(flowType); + if (isEvolvingArrayType(type)) { + var evolvedType_1 = type; + if (node.kind === 175 /* CallExpression */) { + for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { + var arg = _a[_i]; + evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); + } + } + else { + var indexType = checkExpression(node.left.argumentExpression); + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 340 /* NumberLike */ | 2048 /* Undefined */)) { + evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); + } + } + return evolvedType_1 === type ? flowType : createFlowType(evolvedType_1, isIncomplete(flowType)); + } + return flowType; + } + return undefined; + } function getTypeAtFlowCondition(flow) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (!(type.flags & 8192 /* Never */)) { - // If we have an antecedent type (meaning we're reachable in some way), we first - // attempt to narrow the antecedent type. If that produces the never type, and if - // the antecedent type is incomplete (i.e. a transient type in a loop), then we - // take the type guard as an indication that control *could* reach here once we - // have the complete type. We proceed by switching to the silent never type which - // doesn't report errors when operators are applied to it. Note that this is the - // *only* place a silent never type is ever generated. - var assumeTrue = (flow.flags & 32 /* TrueCondition */) !== 0; - type = narrowType(type, flow.expression, assumeTrue); - if (type.flags & 8192 /* Never */ && isIncomplete(flowType)) { - type = silentNeverType; - } + if (type.flags & 8192 /* Never */) { + return flowType; } - return createFlowType(type, isIncomplete(flowType)); + // If we have an antecedent type (meaning we're reachable in some way), we first + // attempt to narrow the antecedent type. If that produces the never type, and if + // the antecedent type is incomplete (i.e. a transient type in a loop), then we + // take the type guard as an indication that control *could* reach here once we + // have the complete type. We proceed by switching to the silent never type which + // doesn't report errors when operators are applied to it. Note that this is the + // *only* place a silent never type is ever generated. + var assumeTrue = (flow.flags & 32 /* TrueCondition */) !== 0; + var nonEvolvingType = finalizeEvolvingArrayType(type); + var narrowedType = narrowType(nonEvolvingType, flow.expression, assumeTrue); + if (narrowedType === nonEvolvingType) { + return flowType; + } + var incomplete = isIncomplete(flowType); + var resultType = incomplete && narrowedType.flags & 8192 /* Never */ ? silentNeverType : narrowedType; + return createFlowType(resultType, incomplete); } function getTypeAtSwitchClause(flow) { var flowType = getTypeAtFlowNode(flow.antecedent); @@ -30571,7 +30872,7 @@ var ts; seenIncomplete = true; } } - return createFlowType(getUnionType(antecedentTypes, subtypeReduction), seenIncomplete); + return createFlowType(getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction), seenIncomplete); } function getTypeAtFlowLoopLabel(flow) { // If we have previously computed the control flow type for the reference at @@ -30586,11 +30887,15 @@ var ts; } // If this flow loop junction and reference are already being processed, return // the union of the types computed for each branch so far, marked as incomplete. - // We should never see an empty array here because the first antecedent of a loop - // junction is always the non-looping control flow path that leads to the top. + // It is possible to see an empty array in cases where loops are nested and the + // back edge of the outer loop reaches an inner loop that is already being analyzed. + // In such cases we restart the analysis of the inner loop, which will then see + // a non-empty in-process array for the outer loop and eventually terminate because + // the first antecedent of a loop junction is always the non-looping control flow + // path that leads to the top. for (var i = flowLoopStart; i < flowLoopCount; i++) { - if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key) { - return createFlowType(getUnionType(flowLoopTypes[i]), /*incomplete*/ true); + if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key && flowLoopTypes[i].length) { + return createFlowType(getUnionOrEvolvingArrayType(flowLoopTypes[i], /*subtypeReduction*/ false), /*incomplete*/ true); } } // Add the flow loop junction and reference to the in-process stack and analyze @@ -30634,14 +30939,14 @@ var ts; } // The result is incomplete if the first antecedent (the non-looping control flow path) // is incomplete. - var result = getUnionType(antecedentTypes, subtypeReduction); + var result = getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction); if (isIncomplete(firstAntecedentType)) { return createFlowType(result, /*incomplete*/ true); } return cache[key] = result; } function isMatchingReferenceDiscriminant(expr) { - return expr.kind === 172 /* PropertyAccessExpression */ && + return expr.kind === 173 /* PropertyAccessExpression */ && declaredType.flags & 524288 /* Union */ && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(declaredType, expr.name.text); @@ -30666,19 +30971,19 @@ var ts; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 56 /* EqualsToken */: + case 57 /* EqualsToken */: return narrowTypeByTruthiness(type, expr.left, assumeTrue); - case 30 /* EqualsEqualsToken */: - case 31 /* ExclamationEqualsToken */: - case 32 /* EqualsEqualsEqualsToken */: - case 33 /* ExclamationEqualsEqualsToken */: + case 31 /* EqualsEqualsToken */: + case 32 /* ExclamationEqualsToken */: + case 33 /* EqualsEqualsEqualsToken */: + case 34 /* ExclamationEqualsEqualsToken */: var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 182 /* TypeOfExpression */ && right_1.kind === 9 /* StringLiteral */) { + if (left_1.kind === 183 /* TypeOfExpression */ && right_1.kind === 9 /* StringLiteral */) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 182 /* TypeOfExpression */ && left_1.kind === 9 /* StringLiteral */) { + if (right_1.kind === 183 /* TypeOfExpression */ && left_1.kind === 9 /* StringLiteral */) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -30697,9 +31002,9 @@ var ts; return declaredType; } break; - case 91 /* InstanceOfKeyword */: + case 92 /* InstanceOfKeyword */: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 24 /* CommaToken */: + case 25 /* CommaToken */: return narrowType(type, expr.right, assumeTrue); } return type; @@ -30708,7 +31013,7 @@ var ts; if (type.flags & 1 /* Any */) { return type; } - if (operator === 31 /* ExclamationEqualsToken */ || operator === 33 /* ExclamationEqualsEqualsToken */) { + if (operator === 32 /* ExclamationEqualsToken */ || operator === 34 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } var valueType = checkExpression(value); @@ -30716,10 +31021,10 @@ var ts; if (!strictNullChecks) { return type; } - var doubleEquals = operator === 30 /* EqualsEqualsToken */ || operator === 31 /* ExclamationEqualsToken */; + var doubleEquals = operator === 31 /* EqualsEqualsToken */ || operator === 32 /* ExclamationEqualsToken */; var facts = doubleEquals ? assumeTrue ? 65536 /* EQUndefinedOrNull */ : 524288 /* NEUndefinedOrNull */ : - value.kind === 93 /* NullKeyword */ ? + value.kind === 94 /* NullKeyword */ ? assumeTrue ? 32768 /* EQNull */ : 262144 /* NENull */ : assumeTrue ? 16384 /* EQUndefined */ : 131072 /* NEUndefined */; return getTypeWithFacts(type, facts); @@ -30748,7 +31053,7 @@ var ts; } return type; } - if (operator === 31 /* ExclamationEqualsToken */ || operator === 33 /* ExclamationEqualsEqualsToken */) { + if (operator === 32 /* ExclamationEqualsToken */ || operator === 34 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } if (assumeTrue && !(type.flags & 524288 /* Union */)) { @@ -30877,7 +31182,7 @@ var ts; } else { var invokedExpression = skipParenthesizedNodes(callExpression.expression); - if (invokedExpression.kind === 173 /* ElementAccessExpression */ || invokedExpression.kind === 172 /* PropertyAccessExpression */) { + if (invokedExpression.kind === 174 /* ElementAccessExpression */ || invokedExpression.kind === 173 /* PropertyAccessExpression */) { var accessExpression = invokedExpression; var possibleReference = skipParenthesizedNodes(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -30894,18 +31199,18 @@ var ts; // will be a subtype or the same type as the argument. function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 69 /* Identifier */: - case 97 /* ThisKeyword */: - case 172 /* PropertyAccessExpression */: + case 70 /* Identifier */: + case 98 /* ThisKeyword */: + case 173 /* PropertyAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 174 /* CallExpression */: + case 175 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 185 /* PrefixUnaryExpression */: - if (expr.operator === 49 /* ExclamationToken */) { + case 186 /* PrefixUnaryExpression */: + if (expr.operator === 50 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -30918,7 +31223,7 @@ var ts; // an dotted name expression, and if the location is not an assignment target, obtain the type // of the expression (which will reflect control flow analysis). If the expression indeed // resolved to the given symbol, return the narrowed type. - if (location.kind === 69 /* Identifier */) { + if (location.kind === 70 /* Identifier */) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } @@ -30937,7 +31242,7 @@ var ts; return getTypeOfSymbol(symbol); } function skipParenthesizedNodes(expression) { - while (expression.kind === 178 /* ParenthesizedExpression */) { + while (expression.kind === 179 /* ParenthesizedExpression */) { expression = expression.expression; } return expression; @@ -30946,9 +31251,9 @@ var ts; while (true) { node = node.parent; if (ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 226 /* ModuleBlock */ || + node.kind === 227 /* ModuleBlock */ || node.kind === 256 /* SourceFile */ || - node.kind === 145 /* PropertyDeclaration */) { + node.kind === 146 /* PropertyDeclaration */) { return node; } } @@ -30977,10 +31282,10 @@ var ts; } } function markParameterAssignments(node) { - if (node.kind === 69 /* Identifier */) { + if (node.kind === 70 /* Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 142 /* Parameter */) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 143 /* Parameter */) { symbol.isAssigned = true; } } @@ -30989,6 +31294,9 @@ var ts; ts.forEachChild(node, markParameterAssignments); } } + function isConstVariable(symbol) { + return symbol.flags & 3 /* Variable */ && (getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* Const */) !== 0 && getTypeOfSymbol(symbol) !== autoArrayType; + } function checkIdentifier(node) { var symbol = getResolvedSymbol(node); // As noted in ECMAScript 6 language spec, arrow functions never have an arguments objects. @@ -30999,8 +31307,8 @@ var ts; // can explicitly bound arguments objects if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); - if (languageVersion < 2 /* ES6 */) { - if (container.kind === 180 /* ArrowFunction */) { + if (languageVersion < 2 /* ES2015 */) { + if (container.kind === 181 /* ArrowFunction */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } else if (ts.hasModifier(container, 256 /* Async */)) { @@ -31020,8 +31328,8 @@ var ts; // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. - if (languageVersion === 2 /* ES6 */ - && declaration_1.kind === 221 /* ClassDeclaration */ + if (languageVersion === 2 /* ES2015 */ + && declaration_1.kind === 222 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration_1)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -31033,14 +31341,14 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration_1.kind === 192 /* ClassExpression */) { + else if (declaration_1.kind === 193 /* ClassExpression */) { // When we emit a class expression with static members that contain a reference // to the constructor in the initializer, we will need to substitute that // binding with an alias as the class name is not in scope. var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); while (container !== undefined) { if (container.parent === declaration_1) { - if (container.kind === 145 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { + if (container.kind === 146 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration_1).flags |= 8388608 /* ClassWithConstructorReference */; getNodeLinks(node).flags |= 16777216 /* ConstructorReferenceInClass */; } @@ -31063,37 +31371,35 @@ var ts; // The declaration container is the innermost function that encloses the declaration of the variable // or parameter. The flow container is the innermost function starting with which we analyze the control // flow graph to determine the control flow based type. - var isParameter = ts.getRootDeclaration(declaration).kind === 142 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 143 /* Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; // When the control flow originates in a function expression or arrow function and we are referencing // a const variable or parameter from an outer function, we extend the origin of the control flow // analysis to include the immediately enclosing function. - while (flowContainer !== declarationContainer && - (flowContainer.kind === 179 /* FunctionExpression */ || - flowContainer.kind === 180 /* ArrowFunction */ || - ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && - (isReadonlySymbol(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { + while (flowContainer !== declarationContainer && (flowContainer.kind === 180 /* FunctionExpression */ || + flowContainer.kind === 181 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } // We only look for uninitialized variables in strict null checking mode, and only when we can analyze // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). var assumeInitialized = isParameter || isOuterVariable || - type !== autoType && (!strictNullChecks || (type.flags & 1 /* Any */) !== 0) || + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1 /* Any */) !== 0) || ts.isInAmbientContext(declaration); var flowType = getFlowTypeOfReference(node, type, assumeInitialized, flowContainer); // A variable is considered uninitialized when it is possible to analyze the entire control flow graph // from declaration to use, and when the variable's declared type doesn't include undefined but the // control flow based type does include undefined. - if (type === autoType) { - if (flowType === autoType) { + if (type === autoType || type === autoArrayType) { + if (flowType === autoType || flowType === autoArrayType) { if (compilerOptions.noImplicitAny) { - error(declaration.name, ts.Diagnostics.Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol)); - error(node, ts.Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(anyType)); + error(declaration.name, ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol), typeToString(flowType)); + error(node, ts.Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(flowType)); } - return anyType; + return convertAutoToAny(flowType); } } else if (!assumeInitialized && !(getFalsyFlags(type) & 2048 /* Undefined */) && getFalsyFlags(flowType) & 2048 /* Undefined */) { @@ -31114,7 +31420,7 @@ var ts; return false; } function checkNestedBlockScopedBinding(node, symbol) { - if (languageVersion >= 2 /* ES6 */ || + if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || symbol.valueDeclaration.parent.kind === 252 /* CatchClause */) { return; @@ -31141,8 +31447,8 @@ var ts; } // mark variables that are declared in loop initializer and reassigned inside the body of ForStatement. // if body of ForStatement will be converted to function then we'll need a extra machinery to propagate reassigned values back. - if (container.kind === 206 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 219 /* VariableDeclarationList */).parent === container && + if (container.kind === 207 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 220 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152 /* NeedsLoopOutParameter */; } @@ -31156,7 +31462,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { var current = node; // skip parenthesized nodes - while (current.parent.kind === 178 /* ParenthesizedExpression */) { + while (current.parent.kind === 179 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -31164,9 +31470,9 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 185 /* PrefixUnaryExpression */ || current.parent.kind === 186 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 186 /* PrefixUnaryExpression */ || current.parent.kind === 187 /* PostfixUnaryExpression */)) { var expr = current.parent; - isAssigned = expr.operator === 41 /* PlusPlusToken */ || expr.operator === 42 /* MinusMinusToken */; + isAssigned = expr.operator === 42 /* PlusPlusToken */ || expr.operator === 43 /* MinusMinusToken */; } if (!isAssigned) { return false; @@ -31185,7 +31491,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 145 /* PropertyDeclaration */ || container.kind === 148 /* Constructor */) { + if (container.kind === 146 /* PropertyDeclaration */ || container.kind === 149 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -31233,7 +31539,7 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var needToCaptureLexicalThis = false; - if (container.kind === 148 /* Constructor */) { + if (container.kind === 149 /* Constructor */) { var containingClassDecl = container.parent; var baseTypeNode = ts.getClassExtendsHeritageClauseElement(containingClassDecl); // If a containing class does not have extends clause or the class extends null @@ -31254,32 +31560,32 @@ var ts; } } // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 180 /* ArrowFunction */) { + if (container.kind === 181 /* 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 */); + needToCaptureLexicalThis = (languageVersion < 2 /* ES2015 */); } switch (container.kind) { - case 225 /* ModuleDeclaration */: + case 226 /* 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 224 /* EnumDeclaration */: + case 225 /* 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 148 /* Constructor */: + case 149 /* Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: if (ts.getModifierFlags(container) & 32 /* Static */) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -31291,7 +31597,7 @@ var ts; // Note: a parameter initializer should refer to class-this unless function-this is explicitly annotated. // If this is a function in a JS file, it might be a class method. Check if it's the RHS // of a x.prototype.y = function [name]() { .... } - if (container.kind === 179 /* FunctionExpression */ && + if (container.kind === 180 /* FunctionExpression */ && ts.isInJavaScriptFile(container.parent) && ts.getSpecialPropertyAssignmentKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = f' (here, 'f' is 'container') @@ -31304,7 +31610,7 @@ var ts; return getInferredClassType(classSymbol); } } - var thisType = getThisTypeOfDeclaration(container); + var thisType = getThisTypeOfDeclaration(container) || getContextualThisParameterType(container); if (thisType) { return thisType; } @@ -31337,21 +31643,21 @@ var ts; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 142 /* Parameter */) { + if (n.kind === 143 /* Parameter */) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 174 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 175 /* CallExpression */ && node.parent.expression === node; var container = ts.getSuperContainer(node, /*stopOnFunctions*/ true); var needToCaptureLexicalThis = false; // adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting if (!isCallExpression) { - while (container && container.kind === 180 /* ArrowFunction */) { + while (container && container.kind === 181 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); - needToCaptureLexicalThis = languageVersion < 2 /* ES6 */; + needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } } var canUseSuperExpression = isLegalUsageOfSuperExpression(container); @@ -31363,16 +31669,16 @@ var ts; // [super.foo()]() {} // } var current = node; - while (current && current !== container && current.kind !== 140 /* ComputedPropertyName */) { + while (current && current !== container && current.kind !== 141 /* ComputedPropertyName */) { current = current.parent; } - if (current && current.kind === 140 /* ComputedPropertyName */) { + if (current && current.kind === 141 /* ComputedPropertyName */) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); } - else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 171 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 172 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -31443,7 +31749,7 @@ var ts; // This helper creates an object with a "value" property that wraps the `super` property or indexed access for both get and set. // This is required for destructuring assignments, as a call expression cannot be used as the target of a destructuring assignment // while a property access can. - if (container.kind === 147 /* MethodDeclaration */ && ts.getModifierFlags(container) & 256 /* Async */) { + if (container.kind === 148 /* MethodDeclaration */ && ts.getModifierFlags(container) & 256 /* Async */) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -31457,8 +31763,8 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 171 /* ObjectLiteralExpression */) { - if (languageVersion < 2 /* ES6 */) { + if (container.parent.kind === 172 /* ObjectLiteralExpression */) { + if (languageVersion < 2 /* ES2015 */) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return unknownType; } @@ -31477,7 +31783,7 @@ var ts; } return unknownType; } - if (container.kind === 148 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 149 /* 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; @@ -31492,7 +31798,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 === 148 /* Constructor */; + return container.kind === 149 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -31500,32 +31806,35 @@ var ts; // - In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance // - In a static member function or static member accessor // topmost container must be something that is directly nested in the class declaration\object literal expression - if (ts.isClassLike(container.parent) || container.parent.kind === 171 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 172 /* ObjectLiteralExpression */) { if (ts.getModifierFlags(container) & 32 /* Static */) { - return container.kind === 147 /* MethodDeclaration */ || - container.kind === 146 /* MethodSignature */ || - container.kind === 149 /* GetAccessor */ || - container.kind === 150 /* SetAccessor */; + return container.kind === 148 /* MethodDeclaration */ || + container.kind === 147 /* MethodSignature */ || + container.kind === 150 /* GetAccessor */ || + container.kind === 151 /* SetAccessor */; } else { - return container.kind === 147 /* MethodDeclaration */ || - container.kind === 146 /* MethodSignature */ || - container.kind === 149 /* GetAccessor */ || - container.kind === 150 /* SetAccessor */ || - container.kind === 145 /* PropertyDeclaration */ || - container.kind === 144 /* PropertySignature */ || - container.kind === 148 /* Constructor */; + return container.kind === 148 /* MethodDeclaration */ || + container.kind === 147 /* MethodSignature */ || + container.kind === 150 /* GetAccessor */ || + container.kind === 151 /* SetAccessor */ || + container.kind === 146 /* PropertyDeclaration */ || + container.kind === 145 /* PropertySignature */ || + container.kind === 149 /* Constructor */; } } } return false; } } - function getContextualThisParameter(func) { - if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 180 /* ArrowFunction */) { + function getContextualThisParameterType(func) { + if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 181 /* ArrowFunction */) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { - return contextualSignature.thisParameter; + var thisParameter = contextualSignature.thisParameter; + if (thisParameter) { + return getTypeOfSymbol(thisParameter); + } } } return undefined; @@ -31585,7 +31894,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 142 /* Parameter */) { + if (declaration.kind === 143 /* Parameter */) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -31637,7 +31946,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 142 /* Parameter */ && node.parent.initializer === node) { + if (node.parent.kind === 143 /* Parameter */ && node.parent.initializer === node) { return true; } node = node.parent; @@ -31648,8 +31957,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 === 148 /* Constructor */ || - functionDecl.kind === 149 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 150 /* SetAccessor */))) { + functionDecl.kind === 149 /* Constructor */ || + functionDecl.kind === 150 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 151 /* SetAccessor */))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } // Otherwise, if the containing function is contextually typed by a function type with exactly one call signature @@ -31671,7 +31980,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 176 /* TaggedTemplateExpression */) { + if (template.parent.kind === 177 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -31679,7 +31988,7 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operatorToken.kind; - if (operator >= 56 /* FirstAssignment */ && operator <= 68 /* LastAssignment */) { + if (operator >= 57 /* FirstAssignment */ && operator <= 69 /* LastAssignment */) { // Don't do this for special property assignments to avoid circularity if (ts.getSpecialPropertyAssignmentKind(binaryExpression) !== 0 /* None */) { return undefined; @@ -31689,7 +31998,7 @@ var ts; return checkExpression(binaryExpression.left); } } - else if (operator === 52 /* BarBarToken */) { + else if (operator === 53 /* 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); @@ -31698,7 +32007,7 @@ var ts; } return type; } - else if (operator === 51 /* AmpersandAmpersandToken */ || operator === 24 /* CommaToken */) { + else if (operator === 52 /* AmpersandAmpersandToken */ || operator === 25 /* CommaToken */) { if (node === binaryExpression.right) { return getContextualType(binaryExpression); } @@ -31715,8 +32024,8 @@ var ts; var types = type.types; var mappedType; var mappedTypes; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var current = types_12[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var current = types_13[_i]; var t = mapper(current); if (t) { if (!mappedType) { @@ -31786,7 +32095,7 @@ var ts; var index = ts.indexOf(arrayLiteral.elements, node); return getTypeOfPropertyOfContextualType(type, "" + index) || getIndexTypeOfContextualType(type, 1 /* Number */) - || (languageVersion >= 2 /* ES6 */ ? getElementTypeOfIterable(type, /*errorNode*/ undefined) : undefined); + || (languageVersion >= 2 /* ES2015 */ ? getElementTypeOfIterable(type, /*errorNode*/ undefined) : undefined); } return undefined; } @@ -31843,36 +32152,36 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 218 /* VariableDeclaration */: - case 142 /* Parameter */: - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: - case 169 /* BindingElement */: + case 219 /* VariableDeclaration */: + case 143 /* Parameter */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: + case 170 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 180 /* ArrowFunction */: - case 211 /* ReturnStatement */: + case 181 /* ArrowFunction */: + case 212 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 190 /* YieldExpression */: + case 191 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 174 /* CallExpression */: - case 175 /* NewExpression */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 177 /* TypeAssertionExpression */: - case 195 /* AsExpression */: + case 178 /* TypeAssertionExpression */: + case 196 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); case 253 /* PropertyAssignment */: case 254 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 170 /* ArrayLiteralExpression */: + case 171 /* ArrayLiteralExpression */: return getContextualTypeForElementExpression(node); - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 197 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 189 /* TemplateExpression */); + case 198 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 190 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return getContextualType(parent); case 248 /* JsxExpression */: return getContextualType(parent); @@ -31894,7 +32203,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 179 /* FunctionExpression */ || node.kind === 180 /* ArrowFunction */; + return node.kind === 180 /* FunctionExpression */ || node.kind === 181 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -31913,7 +32222,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 !== 147 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 148 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var type = getContextualTypeForFunctionLikeDeclaration(node); if (!type) { return undefined; @@ -31923,8 +32232,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var current = types_13[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var current = types_14[_i]; var signature = getNonGenericSignature(current); if (signature) { if (!signatureList) { @@ -31980,8 +32289,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false); } function hasDefaultValue(node) { - return (node.kind === 169 /* BindingElement */ && !!node.initializer) || - (node.kind === 187 /* BinaryExpression */ && node.operatorToken.kind === 56 /* EqualsToken */); + return (node.kind === 170 /* BindingElement */ && !!node.initializer) || + (node.kind === 188 /* BinaryExpression */ && node.operatorToken.kind === 57 /* EqualsToken */); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -31990,7 +32299,7 @@ var ts; var inDestructuringPattern = ts.isAssignmentTarget(node); for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { var e = elements_1[_i]; - if (inDestructuringPattern && e.kind === 191 /* SpreadElementExpression */) { + if (inDestructuringPattern && e.kind === 192 /* SpreadElementExpression */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -32005,7 +32314,7 @@ var ts; // if there is no index type / iterated type. var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1 /* Number */) || - (languageVersion >= 2 /* ES6 */ ? getElementTypeOfIterable(restArrayType, /*errorNode*/ undefined) : undefined); + (languageVersion >= 2 /* ES2015 */ ? getElementTypeOfIterable(restArrayType, /*errorNode*/ undefined) : undefined); if (restElementType) { elementTypes.push(restElementType); } @@ -32014,7 +32323,7 @@ var ts; var type = checkExpressionForMutableLocation(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 191 /* SpreadElementExpression */; + hasSpreadElement = hasSpreadElement || e.kind === 192 /* SpreadElementExpression */; } if (!hasSpreadElement) { // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such @@ -32029,7 +32338,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 === 168 /* ArrayBindingPattern */ || pattern.kind === 170 /* ArrayLiteralExpression */)) { + if (pattern && (pattern.kind === 169 /* ArrayBindingPattern */ || pattern.kind === 171 /* ArrayLiteralExpression */)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -32037,7 +32346,7 @@ var ts; elementTypes.push(contextualType.typeArguments[i]); } else { - if (patternElement.kind !== 193 /* OmittedExpression */) { + if (patternElement.kind !== 194 /* OmittedExpression */) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -32054,7 +32363,7 @@ var ts; strictNullChecks ? neverType : undefinedWideningType); } function isNumericName(name) { - return name.kind === 140 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 141 /* 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, @@ -32124,7 +32433,7 @@ var ts; var propertiesArray = []; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 167 /* ObjectBindingPattern */ || contextualType.pattern.kind === 171 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 168 /* ObjectBindingPattern */ || contextualType.pattern.kind === 172 /* ObjectLiteralExpression */); var typeFlags = 0; var patternWithComputedProperties = false; var hasComputedStringProperty = false; @@ -32139,7 +32448,7 @@ var ts; if (memberDecl.kind === 253 /* PropertyAssignment */) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 147 /* MethodDeclaration */) { + else if (memberDecl.kind === 148 /* MethodDeclaration */) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { @@ -32187,7 +32496,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 === 149 /* GetAccessor */ || memberDecl.kind === 150 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 150 /* GetAccessor */ || memberDecl.kind === 151 /* SetAccessor */); checkAccessorDeclaration(memberDecl); } if (ts.hasDynamicName(memberDecl)) { @@ -32251,10 +32560,10 @@ var ts; case 248 /* JsxExpression */: checkJsxExpression(child); break; - case 241 /* JsxElement */: + case 242 /* JsxElement */: checkJsxElement(child); break; - case 242 /* JsxSelfClosingElement */: + case 243 /* JsxSelfClosingElement */: checkJsxSelfClosingElement(child); break; } @@ -32273,7 +32582,7 @@ var ts; */ function isJsxIntrinsicIdentifier(tagName) { // TODO (yuisu): comment - if (tagName.kind === 172 /* PropertyAccessExpression */ || tagName.kind === 97 /* ThisKeyword */) { + if (tagName.kind === 173 /* PropertyAccessExpression */ || tagName.kind === 98 /* ThisKeyword */) { return false; } else { @@ -32400,7 +32709,7 @@ var ts; return unknownType; } } - return getUnionType(signatures.map(getReturnTypeOfSignature), /*subtypeReduction*/ true); + return getUnionType(ts.map(signatures, getReturnTypeOfSignature), /*subtypeReduction*/ true); } /// e.g. "props" for React.d.ts, /// or 'undefined' if ElementAttributesProperty doesn't exist (which means all @@ -32444,7 +32753,7 @@ var ts; } if (elemType.flags & 524288 /* Union */) { var types = elemType.types; - return getUnionType(types.map(function (type) { + return getUnionType(ts.map(types, function (type) { return getResolvedJsxType(node, type, elemClassType); }), /*subtypeReduction*/ true); } @@ -32654,7 +32963,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 : 145 /* PropertyDeclaration */; + return s.valueDeclaration ? s.valueDeclaration.kind : 146 /* PropertyDeclaration */; } function getDeclarationModifierFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedModifierFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 4 /* Public */ | 32 /* Static */ : 0; @@ -32673,10 +32982,10 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationModifierFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(getParentOfSymbol(prop)); - var errorNode = node.kind === 172 /* PropertyAccessExpression */ || node.kind === 218 /* VariableDeclaration */ ? + var errorNode = node.kind === 173 /* PropertyAccessExpression */ || node.kind === 219 /* VariableDeclaration */ ? node.name : node.right; - if (left.kind === 95 /* SuperKeyword */) { + if (left.kind === 96 /* SuperKeyword */) { // TS 1.0 spec (April 2014): 4.8.2 // - In a constructor, instance member function, instance member accessor, or // instance member variable initializer where this references a derived class instance, @@ -32684,7 +32993,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 (languageVersion < 2 /* ES6 */ && getDeclarationKindFromSymbol(prop) !== 147 /* MethodDeclaration */) { + if (languageVersion < 2 /* ES2015 */ && getDeclarationKindFromSymbol(prop) !== 148 /* 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); @@ -32715,7 +33024,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 === 95 /* SuperKeyword */) { + if (left.kind === 96 /* SuperKeyword */) { return true; } // Get the enclosing class that has the declaring class as its base type @@ -32799,7 +33108,7 @@ var ts; // Only compute control flow type if this is a property access expression that isn't an // assignment target, and the referenced property was declared as a variable, property, // accessor, or optional method. - if (node.kind !== 172 /* PropertyAccessExpression */ || ts.isAssignmentTarget(node) || + if (node.kind !== 173 /* PropertyAccessExpression */ || ts.isAssignmentTarget(node) || !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 524288 /* Union */)) { return propType; @@ -32821,7 +33130,7 @@ var ts; } } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 172 /* PropertyAccessExpression */ + var left = node.kind === 173 /* PropertyAccessExpression */ ? node.expression : node.left; var type = checkExpression(left); @@ -32838,13 +33147,13 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 219 /* VariableDeclarationList */) { + if (initializer.kind === 220 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 69 /* Identifier */) { + else if (initializer.kind === 70 /* Identifier */) { return getResolvedSymbol(initializer); } return undefined; @@ -32861,13 +33170,13 @@ var ts; */ function isForInVariableForNumericPropertyNames(expr) { var e = skipParenthesizedNodes(expr); - if (e.kind === 69 /* Identifier */) { + if (e.kind === 70 /* Identifier */) { var symbol = getResolvedSymbol(e); if (symbol.flags & 3 /* Variable */) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 207 /* ForInStatement */ && + if (node.kind === 208 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(checkExpression(node.expression))) { @@ -32884,7 +33193,7 @@ var ts; // Grammar checking if (!node.argumentExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 175 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 176 /* 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); @@ -32970,7 +33279,7 @@ var ts; if (indexArgumentExpression.kind === 9 /* StringLiteral */ || indexArgumentExpression.kind === 8 /* NumericLiteral */) { return indexArgumentExpression.text; } - if (indexArgumentExpression.kind === 173 /* ElementAccessExpression */ || indexArgumentExpression.kind === 172 /* PropertyAccessExpression */) { + if (indexArgumentExpression.kind === 174 /* ElementAccessExpression */ || indexArgumentExpression.kind === 173 /* PropertyAccessExpression */) { var value = getConstantValue(indexArgumentExpression); if (value !== undefined) { return value.toString(); @@ -33025,10 +33334,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 176 /* TaggedTemplateExpression */) { + if (node.kind === 177 /* TaggedTemplateExpression */) { checkExpression(node.template); } - else if (node.kind !== 143 /* Decorator */) { + else if (node.kind !== 144 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -33094,7 +33403,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 191 /* SpreadElementExpression */) { + if (arg && arg.kind === 192 /* SpreadElementExpression */) { return i; } } @@ -33107,13 +33416,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 === 176 /* TaggedTemplateExpression */) { + if (node.kind === 177 /* 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 argCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 189 /* TemplateExpression */) { + if (tagExpression.template.kind === 190 /* 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; @@ -33126,11 +33435,11 @@ var ts; // then this might actually turn out to be a TemplateHead in the future; // so we consider the call to be incomplete. var templateLiteral = tagExpression.template; - ts.Debug.assert(templateLiteral.kind === 11 /* NoSubstitutionTemplateLiteral */); + ts.Debug.assert(templateLiteral.kind === 12 /* NoSubstitutionTemplateLiteral */); callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 143 /* Decorator */) { + else if (node.kind === 144 /* Decorator */) { isDecorator = true; typeArguments = undefined; argCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature); @@ -33139,7 +33448,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 === 175 /* NewExpression */); + ts.Debug.assert(callExpression.kind === 176 /* NewExpression */); return signature.minArgumentCount === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -33223,9 +33532,9 @@ 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 !== 193 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 194 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); - var argType = getEffectiveArgumentType(node, i, arg); + var argType = getEffectiveArgumentType(node, i); // If the effective argument type is 'undefined', there is no synthetic type // for the argument. In that case, we should check the argument. if (argType === undefined) { @@ -33280,7 +33589,7 @@ var ts; } function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 175 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 176 /* NewExpression */) { // If the called expression is not of the form `x.f` or `x["f"]`, then sourceType = voidType // If the signature's 'this' type is voidType, then the check is skipped -- anything is compatible. // If the expression is a new expression, then the check is skipped. @@ -33297,10 +33606,10 @@ 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 !== 193 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 194 /* 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); + var argType = getEffectiveArgumentType(node, i); // If the effective argument type is 'undefined', there is no synthetic type // for the argument. In that case, we should check the argument. if (argType === undefined) { @@ -33319,12 +33628,12 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 174 /* CallExpression */) { + if (node.kind === 175 /* CallExpression */) { var callee = node.expression; - if (callee.kind === 172 /* PropertyAccessExpression */) { + if (callee.kind === 173 /* PropertyAccessExpression */) { return callee.expression; } - else if (callee.kind === 173 /* ElementAccessExpression */) { + else if (callee.kind === 174 /* ElementAccessExpression */) { return callee.expression; } } @@ -33340,16 +33649,16 @@ var ts; */ function getEffectiveCallArguments(node) { var args; - if (node.kind === 176 /* TaggedTemplateExpression */) { + if (node.kind === 177 /* TaggedTemplateExpression */) { var template = node.template; args = [undefined]; - if (template.kind === 189 /* TemplateExpression */) { + if (template.kind === 190 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 143 /* Decorator */) { + else if (node.kind === 144 /* 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. @@ -33374,19 +33683,19 @@ var ts; * Otherwise, the argument count is the length of the 'args' array. */ function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 143 /* Decorator */) { + if (node.kind === 144 /* Decorator */) { switch (node.parent.kind) { - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) return 1; - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: // A property declaration decorator will have two arguments (see // `PropertyDecorator` in core.d.ts) return 2; - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* 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. @@ -33396,7 +33705,7 @@ var ts; // 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 142 /* Parameter */: + case 143 /* Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts) return 3; @@ -33420,25 +33729,25 @@ var ts; */ function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. - if (node.kind === 221 /* ClassDeclaration */) { + if (node.kind === 222 /* ClassDeclaration */) { // 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); } - if (node.kind === 142 /* Parameter */) { + if (node.kind === 143 /* Parameter */) { // For a parameter decorator, the `target` is the parent type of the // parameter's containing method. node = node.parent; - if (node.kind === 148 /* Constructor */) { + if (node.kind === 149 /* Constructor */) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } } - if (node.kind === 145 /* PropertyDeclaration */ || - node.kind === 147 /* MethodDeclaration */ || - node.kind === 149 /* GetAccessor */ || - node.kind === 150 /* SetAccessor */) { + if (node.kind === 146 /* PropertyDeclaration */ || + node.kind === 148 /* MethodDeclaration */ || + node.kind === 150 /* GetAccessor */ || + node.kind === 151 /* 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 @@ -33465,32 +33774,32 @@ var ts; */ function getEffectiveDecoratorSecondArgumentType(node) { // The second argument to a decorator is its `propertyKey` - if (node.kind === 221 /* ClassDeclaration */) { + if (node.kind === 222 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } - if (node.kind === 142 /* Parameter */) { + if (node.kind === 143 /* Parameter */) { node = node.parent; - if (node.kind === 148 /* Constructor */) { + if (node.kind === 149 /* Constructor */) { // For a constructor parameter decorator, the `propertyKey` will be `undefined`. return anyType; } } - if (node.kind === 145 /* PropertyDeclaration */ || - node.kind === 147 /* MethodDeclaration */ || - node.kind === 149 /* GetAccessor */ || - node.kind === 150 /* SetAccessor */) { + if (node.kind === 146 /* PropertyDeclaration */ || + node.kind === 148 /* MethodDeclaration */ || + node.kind === 150 /* GetAccessor */ || + node.kind === 151 /* 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 69 /* Identifier */: + case 70 /* Identifier */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: return getLiteralTypeForText(32 /* StringLiteral */, element.name.text); - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(element.name); if (isTypeOfKind(nameType, 512 /* ESSymbol */)) { return nameType; @@ -33516,21 +33825,21 @@ var ts; function getEffectiveDecoratorThirdArgumentType(node) { // The third argument to a decorator is either its `descriptor` for a method decorator // or its `parameterIndex` for a parameter decorator - if (node.kind === 221 /* ClassDeclaration */) { + if (node.kind === 222 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 142 /* Parameter */) { + if (node.kind === 143 /* Parameter */) { // The `parameterIndex` for a parameter decorator is always a number return numberType; } - if (node.kind === 145 /* PropertyDeclaration */) { + if (node.kind === 146 /* PropertyDeclaration */) { ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 147 /* MethodDeclaration */ || - node.kind === 149 /* GetAccessor */ || - node.kind === 150 /* SetAccessor */) { + if (node.kind === 148 /* MethodDeclaration */ || + node.kind === 150 /* GetAccessor */ || + node.kind === 151 /* SetAccessor */) { // The `descriptor` for a method decorator will be a `TypedPropertyDescriptor` // for the type of the member. var propertyType = getTypeOfNode(node); @@ -33558,14 +33867,14 @@ var ts; /** * Gets the effective argument type for an argument in a call expression. */ - function getEffectiveArgumentType(node, argIndex, arg) { + function getEffectiveArgumentType(node, argIndex) { // 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 === 143 /* Decorator */) { + if (node.kind === 144 /* Decorator */) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 176 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 177 /* TaggedTemplateExpression */) { return getGlobalTemplateStringsArrayType(); } // This is not a synthetic argument, so we return 'undefined' @@ -33577,8 +33886,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 === 143 /* Decorator */ || - (argIndex === 0 && node.kind === 176 /* TaggedTemplateExpression */)) { + if (node.kind === 144 /* Decorator */ || + (argIndex === 0 && node.kind === 177 /* TaggedTemplateExpression */)) { return undefined; } return args[argIndex]; @@ -33587,11 +33896,11 @@ var ts; * Gets the error node to use when reporting errors for an effective argument. */ function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 143 /* Decorator */) { + if (node.kind === 144 /* Decorator */) { // For a decorator, we use the expression of the decorator for error reporting. return node.expression; } - else if (argIndex === 0 && node.kind === 176 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 177 /* TaggedTemplateExpression */) { // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. return node.template; } @@ -33600,13 +33909,13 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 176 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 143 /* Decorator */; + var isTaggedTemplate = node.kind === 177 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 144 /* 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 !== 95 /* SuperKeyword */) { + if (node.expression.kind !== 96 /* SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } @@ -33672,7 +33981,7 @@ var ts; var result; // If we are in signature help, a trailing comma indicates that we intend to provide another argument, // so we will only accept overloads with arity at least 1 higher than the current number of provided arguments. - var signatureHelpTrailingComma = candidatesOutArray && node.kind === 174 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 175 /* CallExpression */ && node.arguments.hasTrailingComma; // Section 4.12.1: // if the candidate list contains one or more signatures for which the type of each argument // expression is a subtype of each corresponding parameter type, the return type of the first @@ -33818,7 +34127,7 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 95 /* SuperKeyword */) { + if (node.expression.kind === 96 /* 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 @@ -34020,16 +34329,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 142 /* Parameter */: + case 143 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -34059,13 +34368,13 @@ var ts; } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 174 /* CallExpression */: + case 175 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray); - case 175 /* NewExpression */: + case 176 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray); - case 176 /* TaggedTemplateExpression */: + case 177 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray); - case 143 /* Decorator */: + case 144 /* Decorator */: return resolveDecorator(node, candidatesOutArray); } ts.Debug.fail("Branch in 'resolveSignature' should be unreachable."); @@ -34111,22 +34420,22 @@ 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 === 95 /* SuperKeyword */) { + if (node.expression.kind === 96 /* SuperKeyword */) { return voidType; } - if (node.kind === 175 /* NewExpression */) { + if (node.kind === 176 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 148 /* Constructor */ && - declaration.kind !== 152 /* ConstructSignature */ && - declaration.kind !== 157 /* ConstructorType */ && + declaration.kind !== 149 /* Constructor */ && + declaration.kind !== 153 /* ConstructSignature */ && + declaration.kind !== 158 /* ConstructorType */ && !ts.isJSDocConstructSignature(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any, unless // the declaring function had members created through 'x.prototype.y = expr' or 'this.y = expr' psuedodeclarations // in a JS file // Note:JS inferred classes might come from a variable declaration instead of a function declaration. // In this case, using getResolvedSymbol directly is required to avoid losing the members from the declaration. - var funcSymbol = node.expression.kind === 69 /* Identifier */ ? + var funcSymbol = node.expression.kind === 70 /* Identifier */ ? getResolvedSymbol(node.expression) : checkExpression(node.expression).symbol; if (funcSymbol && funcSymbol.members && (funcSymbol.flags & 16 /* Function */ || ts.isDeclarationOfFunctionExpression(funcSymbol))) { @@ -34139,7 +34448,10 @@ var ts; } } // In JavaScript files, calls to any identifier 'require' are treated as external module imports - if (ts.isInJavaScriptFile(node) && ts.isRequireCall(node, /*checkArgumentIsStringLiteral*/ true)) { + if (ts.isInJavaScriptFile(node) && + ts.isRequireCall(node, /*checkArgumentIsStringLiteral*/ true) && + // Make sure require is not a local function + !resolveName(node.expression, node.expression.text, 107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined)) { return resolveExternalModuleTypeByLiteral(node.arguments[0]); } return getReturnTypeOfSignature(signature); @@ -34179,21 +34491,36 @@ var ts; } function assignContextualParameterTypes(signature, context, mapper) { var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + if (isInferentialContext(mapper)) { + for (var i = 0; i < len; i++) { + var declaration = signature.parameters[i].valueDeclaration; + if (declaration.type) { + inferTypes(mapper.context, getTypeFromTypeNode(declaration.type), getTypeAtPosition(context, i)); + } + } + } if (context.thisParameter) { - if (!signature.thisParameter) { - signature.thisParameter = createTransientSymbol(context.thisParameter, undefined); + var parameter = signature.thisParameter; + if (!parameter || parameter.valueDeclaration && !parameter.valueDeclaration.type) { + if (!parameter) { + signature.thisParameter = createTransientSymbol(context.thisParameter, undefined); + } + assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper); } - assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper); } for (var i = 0; i < len; i++) { var parameter = signature.parameters[i]; - var contextualParameterType = getTypeAtPosition(context, i); - assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + if (!parameter.valueDeclaration.type) { + var contextualParameterType = getTypeAtPosition(context, i); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + } } if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) { var parameter = ts.lastOrUndefined(signature.parameters); - var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); - assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + if (!parameter.valueDeclaration.type) { + var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + } } } // When contextual typing assigns a type to a parameter that contains a binding pattern, we also need to push @@ -34203,7 +34530,7 @@ var ts; for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { var element = _a[_i]; if (!ts.isOmittedExpression(element)) { - if (element.name.kind === 69 /* Identifier */) { + if (element.name.kind === 70 /* Identifier */) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } assignBindingElementTypes(element); @@ -34217,8 +34544,8 @@ var ts; links.type = instantiateType(contextualType, mapper); // if inference didn't come up with anything but {}, fall back to the binding pattern if present. if (links.type === emptyObjectType && - (parameter.valueDeclaration.name.kind === 167 /* ObjectBindingPattern */ || - parameter.valueDeclaration.name.kind === 168 /* ArrayBindingPattern */)) { + (parameter.valueDeclaration.name.kind === 168 /* ObjectBindingPattern */ || + parameter.valueDeclaration.name.kind === 169 /* ArrayBindingPattern */)) { links.type = getTypeFromBindingPattern(parameter.valueDeclaration.name); } assignBindingElementTypes(parameter.valueDeclaration); @@ -34288,7 +34615,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 199 /* Block */) { + if (func.body.kind !== 200 /* 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 @@ -34378,7 +34705,7 @@ var ts; return false; } var lastStatement = ts.lastOrUndefined(func.body.statements); - if (lastStatement && lastStatement.kind === 213 /* SwitchStatement */ && isExhaustiveSwitchStatement(lastStatement)) { + if (lastStatement && lastStatement.kind === 214 /* SwitchStatement */ && isExhaustiveSwitchStatement(lastStatement)) { return false; } return true; @@ -34411,7 +34738,7 @@ var ts; } }); if (aggregatedTypes.length === 0 && !hasReturnWithNoExpression && (hasReturnOfTypeNever || - func.kind === 179 /* FunctionExpression */ || func.kind === 180 /* ArrowFunction */)) { + func.kind === 180 /* FunctionExpression */ || func.kind === 181 /* ArrowFunction */)) { return undefined; } if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression) { @@ -34440,7 +34767,7 @@ var ts; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (ts.nodeIsMissing(func.body) || func.body.kind !== 199 /* Block */ || !functionHasImplicitReturn(func)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 200 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; @@ -34473,10 +34800,10 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 147 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 148 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 179 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 180 /* FunctionExpression */) { checkGrammarForGenerator(node); } // The identityMapper object is used to indicate that function expressions are wildcards @@ -34517,14 +34844,14 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 147 /* MethodDeclaration */) { + if (produceDiagnostics && node.kind !== 148 /* MethodDeclaration */) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 147 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 148 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); if (!node.asteriskToken) { @@ -34540,7 +34867,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 199 /* Block */) { + if (node.body.kind === 200 /* Block */) { checkSourceElement(node.body); } else { @@ -34587,11 +34914,11 @@ var ts; if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && - (expr.kind === 172 /* PropertyAccessExpression */ || expr.kind === 173 /* ElementAccessExpression */) && - expr.expression.kind === 97 /* ThisKeyword */) { + (expr.kind === 173 /* PropertyAccessExpression */ || expr.kind === 174 /* ElementAccessExpression */) && + expr.expression.kind === 98 /* ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 148 /* Constructor */)) + if (!(func && func.kind === 149 /* Constructor */)) return true; // If func.parent is a class and symbol is a (readonly) property of that class, or // if func is a constructor and symbol is a (readonly) parameter property declared in it, @@ -34603,13 +34930,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 172 /* PropertyAccessExpression */ || expr.kind === 173 /* ElementAccessExpression */) { + if (expr.kind === 173 /* PropertyAccessExpression */ || expr.kind === 174 /* ElementAccessExpression */) { var node = skipParenthesizedNodes(expr.expression); - if (node.kind === 69 /* Identifier */) { + if (node.kind === 70 /* Identifier */) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 8388608 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol); - return declaration && declaration.kind === 232 /* NamespaceImport */; + return declaration && declaration.kind === 233 /* NamespaceImport */; } } } @@ -34618,7 +34945,7 @@ var ts; function checkReferenceExpression(expr, invalidReferenceMessage, constantVariableMessage) { // References are combinations of identifiers, parentheses, and property accesses. var node = skipParenthesizedNodes(expr); - if (node.kind !== 69 /* Identifier */ && node.kind !== 172 /* PropertyAccessExpression */ && node.kind !== 173 /* ElementAccessExpression */) { + if (node.kind !== 70 /* Identifier */ && node.kind !== 173 /* PropertyAccessExpression */ && node.kind !== 174 /* ElementAccessExpression */) { error(expr, invalidReferenceMessage); return false; } @@ -34631,7 +34958,7 @@ var ts; if (symbol !== unknownSymbol && symbol !== argumentsSymbol) { // Only variables (and not functions, classes, namespaces, enum objects, or enum members) // are considered references when referenced using a simple identifier. - if (node.kind === 69 /* Identifier */ && !(symbol.flags & 3 /* Variable */)) { + if (node.kind === 70 /* Identifier */ && !(symbol.flags & 3 /* Variable */)) { error(expr, invalidReferenceMessage); return false; } @@ -34641,7 +34968,7 @@ var ts; } } } - else if (node.kind === 173 /* ElementAccessExpression */) { + else if (node.kind === 174 /* ElementAccessExpression */) { if (links.resolvedIndexInfo && links.resolvedIndexInfo.isReadonly) { error(expr, constantVariableMessage); return false; @@ -34679,24 +35006,24 @@ var ts; if (operandType === silentNeverType) { return silentNeverType; } - if (node.operator === 36 /* MinusToken */ && node.operand.kind === 8 /* NumericLiteral */) { + if (node.operator === 37 /* MinusToken */ && node.operand.kind === 8 /* NumericLiteral */) { return getFreshTypeOfLiteralType(getLiteralTypeForText(64 /* NumberLiteral */, "" + -node.operand.text)); } switch (node.operator) { - case 35 /* PlusToken */: - case 36 /* MinusToken */: - case 50 /* TildeToken */: + case 36 /* PlusToken */: + case 37 /* MinusToken */: + case 51 /* TildeToken */: if (maybeTypeOfKind(operandType, 512 /* ESSymbol */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; - case 49 /* ExclamationToken */: + case 50 /* ExclamationToken */: var facts = getTypeFacts(operandType) & (1048576 /* Truthy */ | 2097152 /* Falsy */); return facts === 1048576 /* Truthy */ ? falseType : facts === 2097152 /* Falsy */ ? trueType : booleanType; - case 41 /* PlusPlusToken */: - case 42 /* MinusMinusToken */: + case 42 /* PlusPlusToken */: + case 43 /* MinusMinusToken */: var ok = checkArithmeticOperandType(node.operand, getNonNullableType(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 @@ -34726,8 +35053,8 @@ var ts; } if (type.flags & 1572864 /* UnionOrIntersection */) { var types = type.types; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var t = types_14[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var t = types_15[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -34744,8 +35071,8 @@ var ts; } if (type.flags & 524288 /* Union */) { var types = type.types; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var t = types_15[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var t = types_16[_i]; if (!isTypeOfKind(t, kind)) { return false; } @@ -34754,8 +35081,8 @@ var ts; } if (type.flags & 1048576 /* Intersection */) { var types = type.types; - for (var _a = 0, types_16 = types; _a < types_16.length; _a++) { - var t = types_16[_a]; + for (var _a = 0, types_17 = types; _a < types_17.length; _a++) { + var t = types_17[_a]; if (isTypeOfKind(t, kind)) { return true; } @@ -34803,18 +35130,18 @@ var ts; } return booleanType; } - function checkObjectLiteralAssignment(node, sourceType, contextualMapper) { + function checkObjectLiteralAssignment(node, sourceType) { var properties = node.properties; for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { var p = properties_4[_i]; - checkObjectLiteralDestructuringPropertyAssignment(sourceType, p, contextualMapper); + checkObjectLiteralDestructuringPropertyAssignment(sourceType, p); } return sourceType; } - function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, contextualMapper) { + function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property) { if (property.kind === 253 /* PropertyAssignment */ || property.kind === 254 /* ShorthandPropertyAssignment */) { var name_17 = property.name; - if (name_17.kind === 140 /* ComputedPropertyName */) { + if (name_17.kind === 141 /* ComputedPropertyName */) { checkComputedPropertyName(name_17); } if (isComputedNonLiteralName(name_17)) { @@ -34857,8 +35184,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, contextualMapper) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 193 /* OmittedExpression */) { - if (element.kind !== 191 /* SpreadElementExpression */) { + if (element.kind !== 194 /* OmittedExpression */) { + if (element.kind !== 192 /* SpreadElementExpression */) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType @@ -34886,7 +35213,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 187 /* BinaryExpression */ && restExpression.operatorToken.kind === 56 /* EqualsToken */) { + if (restExpression.kind === 188 /* BinaryExpression */ && restExpression.operatorToken.kind === 57 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -34915,14 +35242,14 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 187 /* BinaryExpression */ && target.operatorToken.kind === 56 /* EqualsToken */) { + if (target.kind === 188 /* BinaryExpression */ && target.operatorToken.kind === 57 /* EqualsToken */) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 171 /* ObjectLiteralExpression */) { - return checkObjectLiteralAssignment(target, sourceType, contextualMapper); + if (target.kind === 172 /* ObjectLiteralExpression */) { + return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 170 /* ArrayLiteralExpression */) { + if (target.kind === 171 /* ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -34945,52 +35272,52 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 69 /* Identifier */: + case 70 /* Identifier */: case 9 /* StringLiteral */: - case 10 /* RegularExpressionLiteral */: - case 176 /* TaggedTemplateExpression */: - case 189 /* TemplateExpression */: - case 11 /* NoSubstitutionTemplateLiteral */: + case 11 /* RegularExpressionLiteral */: + case 177 /* TaggedTemplateExpression */: + case 190 /* TemplateExpression */: + case 12 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: - case 93 /* NullKeyword */: - case 135 /* UndefinedKeyword */: - case 179 /* FunctionExpression */: - case 192 /* ClassExpression */: - case 180 /* ArrowFunction */: - case 170 /* ArrayLiteralExpression */: - case 171 /* ObjectLiteralExpression */: - case 182 /* TypeOfExpression */: - case 196 /* NonNullExpression */: - case 242 /* JsxSelfClosingElement */: - case 241 /* JsxElement */: + case 100 /* TrueKeyword */: + case 85 /* FalseKeyword */: + case 94 /* NullKeyword */: + case 136 /* UndefinedKeyword */: + case 180 /* FunctionExpression */: + case 193 /* ClassExpression */: + case 181 /* ArrowFunction */: + case 171 /* ArrayLiteralExpression */: + case 172 /* ObjectLiteralExpression */: + case 183 /* TypeOfExpression */: + case 197 /* NonNullExpression */: + case 243 /* JsxSelfClosingElement */: + case 242 /* JsxElement */: return true; - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 185 /* PrefixUnaryExpression */: - case 186 /* PostfixUnaryExpression */: + case 186 /* PrefixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { - case 49 /* ExclamationToken */: - case 35 /* PlusToken */: - case 36 /* MinusToken */: - case 50 /* TildeToken */: + case 50 /* ExclamationToken */: + case 36 /* PlusToken */: + case 37 /* MinusToken */: + case 51 /* TildeToken */: return true; } return false; // Some forms listed here for clarity - case 183 /* VoidExpression */: // Explicit opt-out - case 177 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 195 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 184 /* VoidExpression */: // Explicit opt-out + case 178 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 196 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -35010,34 +35337,34 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { var operator = operatorToken.kind; - if (operator === 56 /* EqualsToken */ && (left.kind === 171 /* ObjectLiteralExpression */ || left.kind === 170 /* ArrayLiteralExpression */)) { + if (operator === 57 /* EqualsToken */ && (left.kind === 172 /* ObjectLiteralExpression */ || left.kind === 171 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } var leftType = checkExpression(left, contextualMapper); var rightType = checkExpression(right, contextualMapper); switch (operator) { - case 37 /* AsteriskToken */: - 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 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 */: + case 38 /* AsteriskToken */: + case 39 /* AsteriskAsteriskToken */: + case 60 /* AsteriskEqualsToken */: + case 61 /* AsteriskAsteriskEqualsToken */: + case 40 /* SlashToken */: + case 62 /* SlashEqualsToken */: + case 41 /* PercentToken */: + case 63 /* PercentEqualsToken */: + case 37 /* MinusToken */: + case 59 /* MinusEqualsToken */: + case 44 /* LessThanLessThanToken */: + case 64 /* LessThanLessThanEqualsToken */: + case 45 /* GreaterThanGreaterThanToken */: + case 65 /* GreaterThanGreaterThanEqualsToken */: + case 46 /* GreaterThanGreaterThanGreaterThanToken */: + case 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 48 /* BarToken */: + case 68 /* BarEqualsToken */: + case 49 /* CaretToken */: + case 69 /* CaretEqualsToken */: + case 47 /* AmpersandToken */: + case 67 /* AmpersandEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -35070,8 +35397,8 @@ var ts; } } return numberType; - case 35 /* PlusToken */: - case 57 /* PlusEqualsToken */: + case 36 /* PlusToken */: + case 58 /* PlusEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -35110,24 +35437,24 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 57 /* PlusEqualsToken */) { + if (operator === 58 /* PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; - case 25 /* LessThanToken */: - case 27 /* GreaterThanToken */: - case 28 /* LessThanEqualsToken */: - case 29 /* GreaterThanEqualsToken */: + case 26 /* LessThanToken */: + case 28 /* GreaterThanToken */: + case 29 /* LessThanEqualsToken */: + case 30 /* GreaterThanEqualsToken */: if (checkForDisallowedESSymbolOperand(operator)) { if (!isTypeComparableTo(leftType, rightType) && !isTypeComparableTo(rightType, leftType)) { reportOperatorError(); } } return booleanType; - case 30 /* EqualsEqualsToken */: - case 31 /* ExclamationEqualsToken */: - case 32 /* EqualsEqualsEqualsToken */: - case 33 /* ExclamationEqualsEqualsToken */: + case 31 /* EqualsEqualsToken */: + case 32 /* ExclamationEqualsToken */: + case 33 /* EqualsEqualsEqualsToken */: + case 34 /* ExclamationEqualsEqualsToken */: var leftIsLiteral = isLiteralType(leftType); var rightIsLiteral = isLiteralType(rightType); if (!leftIsLiteral || !rightIsLiteral) { @@ -35138,22 +35465,22 @@ var ts; reportOperatorError(); } return booleanType; - case 91 /* InstanceOfKeyword */: + case 92 /* InstanceOfKeyword */: return checkInstanceOfExpression(left, right, leftType, rightType); - case 90 /* InKeyword */: + case 91 /* InKeyword */: return checkInExpression(left, right, leftType, rightType); - case 51 /* AmpersandAmpersandToken */: + case 52 /* AmpersandAmpersandToken */: return getTypeFacts(leftType) & 1048576 /* Truthy */ ? includeFalsyTypes(rightType, getFalsyFlags(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType))) : leftType; - case 52 /* BarBarToken */: + case 53 /* BarBarToken */: return getTypeFacts(leftType) & 2097152 /* Falsy */ ? getBestChoiceType(removeDefinitelyFalsyTypes(leftType), rightType) : leftType; - case 56 /* EqualsToken */: + case 57 /* EqualsToken */: checkAssignmentOperator(rightType); return getRegularTypeOfObjectLiteral(rightType); - case 24 /* CommaToken */: + case 25 /* CommaToken */: if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left)) { error(left, ts.Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects); } @@ -35172,21 +35499,21 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 47 /* BarToken */: - case 67 /* BarEqualsToken */: - return 52 /* BarBarToken */; - case 48 /* CaretToken */: - case 68 /* CaretEqualsToken */: - return 33 /* ExclamationEqualsEqualsToken */; - case 46 /* AmpersandToken */: - case 66 /* AmpersandEqualsToken */: - return 51 /* AmpersandAmpersandToken */; + case 48 /* BarToken */: + case 68 /* BarEqualsToken */: + return 53 /* BarBarToken */; + case 49 /* CaretToken */: + case 69 /* CaretEqualsToken */: + return 34 /* ExclamationEqualsEqualsToken */; + case 47 /* AmpersandToken */: + case 67 /* AmpersandEqualsToken */: + return 52 /* AmpersandAmpersandToken */; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 56 /* FirstAssignment */ && operator <= 68 /* LastAssignment */) { + if (produceDiagnostics && operator >= 57 /* FirstAssignment */ && operator <= 69 /* LastAssignment */) { // TypeScript 1.0 spec (April 2014): 4.17 // An assignment of the form // VarExpr = ValueExpr @@ -35273,9 +35600,9 @@ var ts; return getFreshTypeOfLiteralType(getLiteralTypeForText(32 /* StringLiteral */, node.text)); case 8 /* NumericLiteral */: return getFreshTypeOfLiteralType(getLiteralTypeForText(64 /* NumberLiteral */, node.text)); - case 99 /* TrueKeyword */: + case 100 /* TrueKeyword */: return trueType; - case 84 /* FalseKeyword */: + case 85 /* FalseKeyword */: return falseType; } } @@ -35312,7 +35639,7 @@ var ts; } function isTypeAssertion(node) { node = skipParenthesizedNodes(node); - return node.kind === 177 /* TypeAssertionExpression */ || node.kind === 195 /* AsExpression */; + return node.kind === 178 /* TypeAssertionExpression */ || node.kind === 196 /* AsExpression */; } function checkDeclarationInitializer(declaration) { var type = checkExpressionCached(declaration.initializer); @@ -35344,7 +35671,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 === 140 /* ComputedPropertyName */) { + if (node.name.kind === 141 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, contextualMapper); @@ -35355,7 +35682,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 === 140 /* ComputedPropertyName */) { + if (node.name.kind === 141 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -35385,7 +35712,7 @@ var ts; // contextually typed function and arrow expressions in the initial phase. function checkExpression(node, contextualMapper) { var type; - if (node.kind === 139 /* QualifiedName */) { + if (node.kind === 140 /* QualifiedName */) { type = checkQualifiedName(node); } else { @@ -35397,9 +35724,9 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 172 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 173 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 69 /* Identifier */ || node.kind === 139 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 173 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 174 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 70 /* Identifier */ || node.kind === 140 /* 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); } @@ -35408,79 +35735,79 @@ var ts; } function checkExpressionWorker(node, contextualMapper) { switch (node.kind) { - case 69 /* Identifier */: + case 70 /* Identifier */: return checkIdentifier(node); - case 97 /* ThisKeyword */: + case 98 /* ThisKeyword */: return checkThisExpression(node); - case 95 /* SuperKeyword */: + case 96 /* SuperKeyword */: return checkSuperExpression(node); - case 93 /* NullKeyword */: + case 94 /* NullKeyword */: return nullWideningType; case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: + case 100 /* TrueKeyword */: + case 85 /* FalseKeyword */: return checkLiteralExpression(node); - case 189 /* TemplateExpression */: + case 190 /* TemplateExpression */: return checkTemplateExpression(node); - case 11 /* NoSubstitutionTemplateLiteral */: + case 12 /* NoSubstitutionTemplateLiteral */: return stringType; - case 10 /* RegularExpressionLiteral */: + case 11 /* RegularExpressionLiteral */: return globalRegExpType; - case 170 /* ArrayLiteralExpression */: + case 171 /* ArrayLiteralExpression */: return checkArrayLiteral(node, contextualMapper); - case 171 /* ObjectLiteralExpression */: + case 172 /* ObjectLiteralExpression */: return checkObjectLiteral(node, contextualMapper); - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 173 /* ElementAccessExpression */: + case 174 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 174 /* CallExpression */: - case 175 /* NewExpression */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: return checkCallExpression(node); - case 176 /* TaggedTemplateExpression */: + case 177 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return checkExpression(node.expression, contextualMapper); - case 192 /* ClassExpression */: + case 193 /* ClassExpression */: return checkClassExpression(node); - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 182 /* TypeOfExpression */: + case 183 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 177 /* TypeAssertionExpression */: - case 195 /* AsExpression */: + case 178 /* TypeAssertionExpression */: + case 196 /* AsExpression */: return checkAssertion(node); - case 196 /* NonNullExpression */: + case 197 /* NonNullExpression */: return checkNonNullAssertion(node); - case 181 /* DeleteExpression */: + case 182 /* DeleteExpression */: return checkDeleteExpression(node); - case 183 /* VoidExpression */: + case 184 /* VoidExpression */: return checkVoidExpression(node); - case 184 /* AwaitExpression */: + case 185 /* AwaitExpression */: return checkAwaitExpression(node); - case 185 /* PrefixUnaryExpression */: + case 186 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 186 /* PostfixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return checkBinaryExpression(node, contextualMapper); - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: return checkConditionalExpression(node, contextualMapper); - case 191 /* SpreadElementExpression */: + case 192 /* SpreadElementExpression */: return checkSpreadElementExpression(node, contextualMapper); - case 193 /* OmittedExpression */: + case 194 /* OmittedExpression */: return undefinedWideningType; - case 190 /* YieldExpression */: + case 191 /* YieldExpression */: return checkYieldExpression(node); case 248 /* JsxExpression */: return checkJsxExpression(node); - case 241 /* JsxElement */: + case 242 /* JsxElement */: return checkJsxElement(node); - case 242 /* JsxSelfClosingElement */: + case 243 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node); - case 243 /* JsxOpeningElement */: + case 244 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -35508,7 +35835,7 @@ var ts; var func = ts.getContainingFunction(node); if (ts.getModifierFlags(node) & 92 /* ParameterPropertyModifier */) { func = ts.getContainingFunction(node); - if (!(func.kind === 148 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 149 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -35519,7 +35846,7 @@ var ts; if (ts.indexOf(func.parameters, node) !== 0) { error(node, ts.Diagnostics.A_this_parameter_must_be_the_first_parameter); } - if (func.kind === 148 /* Constructor */ || func.kind === 152 /* ConstructSignature */ || func.kind === 157 /* ConstructorType */) { + if (func.kind === 149 /* Constructor */ || func.kind === 153 /* ConstructSignature */ || func.kind === 158 /* ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } } @@ -35533,15 +35860,15 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 147 /* MethodDeclaration */ || - node.kind === 220 /* FunctionDeclaration */ || - node.kind === 179 /* FunctionExpression */; + return node.kind === 148 /* MethodDeclaration */ || + node.kind === 221 /* FunctionDeclaration */ || + node.kind === 180 /* FunctionExpression */; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 69 /* Identifier */ && + if (param.name.kind === 70 /* Identifier */ && param.name.text === parameter.text) { return i; } @@ -35593,13 +35920,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 180 /* ArrowFunction */: - case 151 /* CallSignature */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 156 /* FunctionType */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 181 /* ArrowFunction */: + case 152 /* CallSignature */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 157 /* FunctionType */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: var parent_12 = node.parent; if (node === parent_12.type) { return parent_12; @@ -35613,13 +35940,13 @@ var ts; continue; } var name_19 = element.name; - if (name_19.kind === 69 /* Identifier */ && + if (name_19.kind === 70 /* Identifier */ && name_19.text === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name_19.kind === 168 /* ArrayBindingPattern */ || - name_19.kind === 167 /* ObjectBindingPattern */) { + else if (name_19.kind === 169 /* ArrayBindingPattern */ || + name_19.kind === 168 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_19, predicateVariableNode, predicateVariableName)) { return true; } @@ -35628,12 +35955,12 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 153 /* IndexSignature */) { + if (node.kind === 154 /* IndexSignature */) { checkGrammarIndexSignature(node); } - else if (node.kind === 156 /* FunctionType */ || node.kind === 220 /* FunctionDeclaration */ || node.kind === 157 /* ConstructorType */ || - node.kind === 151 /* CallSignature */ || node.kind === 148 /* Constructor */ || - node.kind === 152 /* ConstructSignature */) { + else if (node.kind === 157 /* FunctionType */ || node.kind === 221 /* FunctionDeclaration */ || node.kind === 158 /* ConstructorType */ || + node.kind === 152 /* CallSignature */ || node.kind === 149 /* Constructor */ || + node.kind === 153 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); @@ -35645,16 +35972,16 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 152 /* ConstructSignature */: + case 153 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 151 /* CallSignature */: + case 152 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } } if (node.type) { - if (languageVersion >= 2 /* ES6 */ && isSyntacticallyValidGenerator(node)) { + if (languageVersion >= 2 /* ES2015 */ && isSyntacticallyValidGenerator(node)) { var returnType = getTypeFromTypeNode(node.type); if (returnType === voidType) { error(node.type, ts.Diagnostics.A_generator_cannot_have_a_void_type_annotation); @@ -35691,7 +36018,7 @@ var ts; var staticNames = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 148 /* Constructor */) { + if (member.kind === 149 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param)) { @@ -35700,18 +36027,18 @@ var ts; } } else { - var isStatic = ts.forEach(member.modifiers, function (m) { return m.kind === 113 /* StaticKeyword */; }); + var isStatic = ts.forEach(member.modifiers, function (m) { return m.kind === 114 /* StaticKeyword */; }); var names = isStatic ? staticNames : instanceNames; var memberName = member.name && ts.getPropertyNameForPropertyNameNode(member.name); if (memberName) { switch (member.kind) { - case 149 /* GetAccessor */: + case 150 /* GetAccessor */: addName(names, member.name, memberName, 1 /* Getter */); break; - case 150 /* SetAccessor */: + case 151 /* SetAccessor */: addName(names, member.name, memberName, 2 /* Setter */); break; - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: addName(names, member.name, memberName, 3 /* Property */); break; } @@ -35737,12 +36064,12 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind == 144 /* PropertySignature */) { + if (member.kind == 145 /* PropertySignature */) { var memberName = void 0; switch (member.name.kind) { case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - case 69 /* Identifier */: + case 70 /* Identifier */: memberName = member.name.text; break; default: @@ -35759,7 +36086,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 222 /* InterfaceDeclaration */) { + if (node.kind === 223 /* 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 @@ -35779,7 +36106,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 132 /* StringKeyword */: + case 133 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -35787,7 +36114,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 130 /* NumberKeyword */: + case 131 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -35852,15 +36179,15 @@ var ts; return ts.forEachChild(n, containsSuperCall); } function markThisReferencesAsErrors(n) { - if (n.kind === 97 /* ThisKeyword */) { + if (n.kind === 98 /* ThisKeyword */) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 179 /* FunctionExpression */ && n.kind !== 220 /* FunctionDeclaration */) { + else if (n.kind !== 180 /* FunctionExpression */ && n.kind !== 221 /* FunctionDeclaration */) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 145 /* PropertyDeclaration */ && + return n.kind === 146 /* PropertyDeclaration */ && !(ts.getModifierFlags(n) & 32 /* Static */) && !!n.initializer; } @@ -35890,7 +36217,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 202 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 203 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -35914,7 +36241,7 @@ var ts; checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 149 /* GetAccessor */) { + if (node.kind === 150 /* GetAccessor */) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 128 /* HasImplicitReturn */)) { if (!(node.flags & 256 /* HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); @@ -35924,13 +36251,13 @@ 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 === 140 /* ComputedPropertyName */) { + if (node.name.kind === 141 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } 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 === 149 /* GetAccessor */ ? 150 /* SetAccessor */ : 149 /* GetAccessor */; + var otherKind = node.kind === 150 /* GetAccessor */ ? 151 /* SetAccessor */ : 150 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if ((ts.getModifierFlags(node) & 28 /* AccessibilityModifier */) !== (ts.getModifierFlags(otherAccessor) & 28 /* AccessibilityModifier */)) { @@ -35946,11 +36273,11 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 149 /* GetAccessor */) { + if (node.kind === 150 /* GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } - if (node.parent.kind !== 171 /* ObjectLiteralExpression */) { + if (node.parent.kind !== 172 /* ObjectLiteralExpression */) { checkSourceElement(node.body); registerForUnusedIdentifiersCheck(node); } @@ -36040,9 +36367,9 @@ var ts; var flags = ts.getCombinedModifierFlags(n); // children of classes (even ambient classes) should not be marked as ambient or export // because those flags have no useful semantics there. - if (n.parent.kind !== 222 /* InterfaceDeclaration */ && - n.parent.kind !== 221 /* ClassDeclaration */ && - n.parent.kind !== 192 /* ClassExpression */ && + if (n.parent.kind !== 223 /* InterfaceDeclaration */ && + n.parent.kind !== 222 /* ClassDeclaration */ && + n.parent.kind !== 193 /* ClassExpression */ && ts.isInAmbientContext(n)) { if (!(flags & 2 /* Ambient */)) { // It is nested in an ambient context, which means it is automatically exported @@ -36130,7 +36457,7 @@ var ts; var errorNode_1 = subsequentNode.name || subsequentNode; // TODO(jfreeman): These are methods, so handle computed name case if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - var reportError = (node.kind === 147 /* MethodDeclaration */ || node.kind === 146 /* MethodSignature */) && + var reportError = (node.kind === 148 /* MethodDeclaration */ || node.kind === 147 /* MethodSignature */) && (ts.getModifierFlags(node) & 32 /* Static */) !== (ts.getModifierFlags(subsequentNode) & 32 /* Static */); // we can get here in two cases // 1. mixed static and instance class members @@ -36169,7 +36496,7 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 222 /* InterfaceDeclaration */ || node.parent.kind === 159 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 223 /* InterfaceDeclaration */ || node.parent.kind === 160 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -36180,7 +36507,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 === 220 /* FunctionDeclaration */ || node.kind === 147 /* MethodDeclaration */ || node.kind === 146 /* MethodSignature */ || node.kind === 148 /* Constructor */) { + if (node.kind === 221 /* FunctionDeclaration */ || node.kind === 148 /* MethodDeclaration */ || node.kind === 147 /* MethodSignature */ || node.kind === 149 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -36302,16 +36629,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 222 /* InterfaceDeclaration */: + case 223 /* InterfaceDeclaration */: return 2097152 /* ExportType */; - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ : 4194304 /* ExportNamespace */; - case 221 /* ClassDeclaration */: - case 224 /* EnumDeclaration */: + case 222 /* ClassDeclaration */: + case 225 /* EnumDeclaration */: return 2097152 /* ExportType */ | 1048576 /* ExportValue */; - case 229 /* ImportEqualsDeclaration */: + case 230 /* ImportEqualsDeclaration */: var result_2 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_2 |= getDeclarationSpaces(d); }); @@ -36515,7 +36842,7 @@ var ts; * callable `then` signature. */ function checkAsyncFunctionReturnType(node) { - if (languageVersion >= 2 /* ES6 */) { + if (languageVersion >= 2 /* ES2015 */) { var returnType = getTypeFromTypeNode(node.type); return checkCorrectPromiseType(returnType, node.type, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type); } @@ -36594,22 +36921,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 142 /* Parameter */: + case 143 /* 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 145 /* PropertyDeclaration */: + case 146 /* 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 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -36622,9 +36949,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 === 155 /* TypeReference */) { + if (node && node.kind === 156 /* TypeReference */) { var root = getFirstIdentifier(node.typeName); - var meaning = root.parent.kind === 155 /* TypeReference */ ? 793064 /* Type */ : 1920 /* Namespace */; + var meaning = root.parent.kind === 156 /* TypeReference */ ? 793064 /* Type */ : 1920 /* 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 @@ -36671,20 +36998,20 @@ 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 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: checkParameterTypeAnnotationsAsExpressions(node); checkReturnTypeAnnotationAsExpression(node); break; - case 145 /* PropertyDeclaration */: - case 142 /* Parameter */: + case 146 /* PropertyDeclaration */: + case 143 /* Parameter */: checkTypeAnnotationAsExpression(node); break; } @@ -36707,7 +37034,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 && node.name.kind === 140 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 141 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -36768,42 +37095,42 @@ var ts; var node = deferredUnusedIdentifierNodes_1[_i]; switch (node.kind) { case 256 /* SourceFile */: - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: checkUnusedModuleMembers(node); break; - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; - case 222 /* InterfaceDeclaration */: + case 223 /* InterfaceDeclaration */: checkUnusedTypeParameters(node); break; - case 199 /* Block */: - case 227 /* CaseBlock */: - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: + case 200 /* Block */: + case 228 /* CaseBlock */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: checkUnusedLocalsAndParameters(node); break; - case 148 /* Constructor */: - case 179 /* FunctionExpression */: - case 220 /* FunctionDeclaration */: - case 180 /* ArrowFunction */: - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 149 /* Constructor */: + case 180 /* FunctionExpression */: + case 221 /* FunctionDeclaration */: + case 181 /* ArrowFunction */: + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: if (node.body) { checkUnusedLocalsAndParameters(node); } checkUnusedTypeParameters(node); break; - case 146 /* MethodSignature */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: - case 156 /* FunctionType */: - case 157 /* ConstructorType */: + case 147 /* MethodSignature */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: checkUnusedTypeParameters(node); break; } @@ -36812,11 +37139,11 @@ var ts; } } function checkUnusedLocalsAndParameters(node) { - if (node.parent.kind !== 222 /* InterfaceDeclaration */ && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { + if (node.parent.kind !== 223 /* InterfaceDeclaration */ && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { var _loop_1 = function (key) { var local = node.locals[key]; if (!local.isReferenced) { - if (local.valueDeclaration && local.valueDeclaration.kind === 142 /* Parameter */) { + if (local.valueDeclaration && local.valueDeclaration.kind === 143 /* Parameter */) { var parameter = local.valueDeclaration; if (compilerOptions.noUnusedParameters && !ts.isParameterPropertyDeclaration(parameter) && @@ -36836,19 +37163,19 @@ var ts; } } function parameterNameStartsWithUnderscore(parameter) { - return parameter.name && parameter.name.kind === 69 /* Identifier */ && parameter.name.text.charCodeAt(0) === 95 /* _ */; + return parameter.name && parameter.name.kind === 70 /* Identifier */ && parameter.name.text.charCodeAt(0) === 95 /* _ */; } function checkUnusedClassMembers(node) { if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) { if (node.members) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 147 /* MethodDeclaration */ || member.kind === 145 /* PropertyDeclaration */) { + if (member.kind === 148 /* MethodDeclaration */ || member.kind === 146 /* PropertyDeclaration */) { if (!member.symbol.isReferenced && ts.getModifierFlags(member) & 8 /* Private */) { error(member.name, ts.Diagnostics._0_is_declared_but_never_used, member.symbol.name); } } - else if (member.kind === 148 /* Constructor */) { + else if (member.kind === 149 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.getModifierFlags(parameter) & 8 /* Private */) { @@ -36896,7 +37223,7 @@ var ts; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 199 /* Block */) { + if (node.kind === 200 /* Block */) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -36919,12 +37246,12 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 145 /* PropertyDeclaration */ || - node.kind === 144 /* PropertySignature */ || - node.kind === 147 /* MethodDeclaration */ || - node.kind === 146 /* MethodSignature */ || - node.kind === 149 /* GetAccessor */ || - node.kind === 150 /* SetAccessor */) { + if (node.kind === 146 /* PropertyDeclaration */ || + node.kind === 145 /* PropertySignature */ || + node.kind === 148 /* MethodDeclaration */ || + node.kind === 147 /* MethodSignature */ || + node.kind === 150 /* GetAccessor */ || + node.kind === 151 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -36933,7 +37260,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 142 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 143 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -36949,7 +37276,7 @@ var ts; var current = node; while (current) { if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 69 /* Identifier */; + var isDeclaration_1 = node.kind !== 70 /* Identifier */; if (isDeclaration_1) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -36972,7 +37299,7 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 69 /* Identifier */; + var isDeclaration_2 = node.kind !== 70 /* Identifier */; if (isDeclaration_2) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -36983,14 +37310,14 @@ var ts; } function checkCollisionWithRequireExportsInGeneratedCode(node, name) { // No need to check for require or exports for ES6 modules and later - if (modulekind >= ts.ModuleKind.ES6) { + if (modulekind >= ts.ModuleKind.ES2015) { return; } if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 225 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 226 /* 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 @@ -37005,7 +37332,7 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 225 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 226 /* 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 @@ -37045,7 +37372,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 === 218 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 219 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -37055,16 +37382,16 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 219 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 200 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 220 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 201 /* 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 === 199 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 226 /* ModuleBlock */ || - container.kind === 225 /* ModuleDeclaration */ || + (container.kind === 200 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 227 /* ModuleBlock */ || + container.kind === 226 /* ModuleDeclaration */ || container.kind === 256 /* 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 @@ -37080,7 +37407,7 @@ 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 !== 142 /* Parameter */) { + if (ts.getRootDeclaration(node).kind !== 143 /* Parameter */) { return; } var func = ts.getContainingFunction(node); @@ -37091,11 +37418,11 @@ var ts; // skip declaration names (i.e. in object literal expressions) return; } - if (n.kind === 172 /* PropertyAccessExpression */) { + if (n.kind === 173 /* PropertyAccessExpression */) { // skip property names in property access expression return visit(n.expression); } - else if (n.kind === 69 /* Identifier */) { + else if (n.kind === 70 /* Identifier */) { // check FunctionLikeDeclaration.locals (stores parameters\function local variable) // if it contains entry with a specified name var symbol = resolveName(n, n.text, 107455 /* Value */ | 8388608 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); @@ -37110,7 +37437,7 @@ var ts; // so we need to do a bit of extra work to check if reference is legal var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 142 /* Parameter */) { + if (symbol.valueDeclaration.kind === 143 /* Parameter */) { // it is ok to reference parameter in initializer if either // - parameter is located strictly on the left of current parameter declaration if (symbol.valueDeclaration.pos < node.pos) { @@ -37124,7 +37451,7 @@ var ts; } // computed property names/initializers in instance property declaration of class like entities // are executed in constructor and thus deferred - if (current.parent.kind === 145 /* PropertyDeclaration */ && + if (current.parent.kind === 146 /* PropertyDeclaration */ && !(ts.hasModifier(current.parent, 32 /* Static */)) && ts.isClassLike(current.parent.parent)) { return; @@ -37141,7 +37468,7 @@ var ts; } } function convertAutoToAny(type) { - return type === autoType ? anyType : type; + return type === autoType ? anyType : type === autoArrayType ? anyArrayType : type; } // Check variable, parameter, or property declaration function checkVariableLikeDeclaration(node) { @@ -37151,15 +37478,15 @@ 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 === 140 /* ComputedPropertyName */) { + if (node.name.kind === 141 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 169 /* BindingElement */) { + if (node.kind === 170 /* BindingElement */) { // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 140 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 141 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access @@ -37176,14 +37503,14 @@ 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 === 142 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 143 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { // Don't validate for-in initializer as it is already an error - if (node.initializer && node.parent.parent.kind !== 207 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 208 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -37194,7 +37521,7 @@ var ts; if (node === symbol.valueDeclaration) { // Node is the primary declaration of the symbol, just validate the initializer // Don't validate for-in initializer as it is already an error - if (node.initializer && node.parent.parent.kind !== 207 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 208 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -37214,10 +37541,10 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 145 /* PropertyDeclaration */ && node.kind !== 144 /* PropertySignature */) { + if (node.kind !== 146 /* PropertyDeclaration */ && node.kind !== 145 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 218 /* VariableDeclaration */ || node.kind === 169 /* BindingElement */) { + if (node.kind === 219 /* VariableDeclaration */ || node.kind === 170 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -37227,8 +37554,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 142 /* Parameter */ && right.kind === 218 /* VariableDeclaration */) || - (left.kind === 218 /* VariableDeclaration */ && right.kind === 142 /* Parameter */)) { + if ((left.kind === 143 /* Parameter */ && right.kind === 219 /* VariableDeclaration */) || + (left.kind === 219 /* VariableDeclaration */ && right.kind === 143 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -37258,7 +37585,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 === 171 /* ObjectLiteralExpression */) { + if (node.modifiers && node.parent.kind === 172 /* ObjectLiteralExpression */) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -37279,7 +37606,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 201 /* EmptyStatement */) { + if (node.thenStatement.kind === 202 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -37299,12 +37626,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 219 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 220 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 219 /* VariableDeclarationList */) { + if (node.initializer.kind === 220 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -37327,14 +37654,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 === 219 /* VariableDeclarationList */) { + if (node.initializer.kind === 220 /* 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 === 170 /* ArrayLiteralExpression */ || varExpr.kind === 171 /* ObjectLiteralExpression */) { + if (varExpr.kind === 171 /* ArrayLiteralExpression */ || varExpr.kind === 172 /* 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. @@ -37366,7 +37693,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 === 219 /* VariableDeclarationList */) { + if (node.initializer.kind === 220 /* 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); @@ -37380,7 +37707,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 === 170 /* ArrayLiteralExpression */ || varExpr.kind === 171 /* ObjectLiteralExpression */) { + if (varExpr.kind === 171 /* ArrayLiteralExpression */ || varExpr.kind === 172 /* ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 34 /* StringLike */)) { @@ -37418,7 +37745,7 @@ var ts; if (isTypeAny(inputType)) { return inputType; } - if (languageVersion >= 2 /* ES6 */) { + if (languageVersion >= 2 /* ES2015 */) { return checkElementTypeOfIterable(inputType, errorNode); } if (allowStringInput) { @@ -37578,7 +37905,7 @@ var ts; * 2. Some constituent is a string and target is less than ES5 (because in ES3 string is not indexable). */ function checkElementTypeOfArrayOrString(arrayOrStringType, errorNode) { - ts.Debug.assert(languageVersion < 2 /* ES6 */); + ts.Debug.assert(languageVersion < 2 /* ES2015 */); // After we remove all types that are StringLike, we will know if there was a string constituent // based on whether the remaining type is the same as the initial type. var arrayType = arrayOrStringType; @@ -37630,7 +37957,7 @@ var ts; // TODO: Check that target label is valid } function isGetAccessorWithAnnotatedSetAccessor(node) { - return !!(node.kind === 149 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 150 /* SetAccessor */))); + return !!(node.kind === 150 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 151 /* SetAccessor */))); } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { var unwrappedReturnType = ts.isAsyncFunctionLike(func) ? getPromisedType(returnType) : returnType; @@ -37657,12 +37984,12 @@ var ts; // for generators. return; } - if (func.kind === 150 /* SetAccessor */) { + if (func.kind === 151 /* SetAccessor */) { if (node.expression) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 148 /* Constructor */) { + else if (func.kind === 149 /* Constructor */) { if (node.expression && !checkTypeAssignableTo(exprType, returnType, node.expression)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -37683,7 +38010,7 @@ var ts; } } } - else if (func.kind !== 148 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 149 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { // The function has a return type, but the return statement doesn't have an expression. error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } @@ -37749,7 +38076,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 214 /* LabeledStatement */ && current.label.text === node.label.text) { + if (current.kind === 215 /* 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; @@ -37779,7 +38106,7 @@ var ts; if (catchClause) { // Grammar checking if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 69 /* Identifier */) { + if (catchClause.variableDeclaration.name.kind !== 70 /* Identifier */) { grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); } else if (catchClause.variableDeclaration.type) { @@ -37854,7 +38181,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 === 140 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 141 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -37912,7 +38239,7 @@ var ts; var firstDecl; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 221 /* ClassDeclaration */ || declaration.kind === 222 /* InterfaceDeclaration */) { + if (declaration.kind === 222 /* ClassDeclaration */ || declaration.kind === 223 /* InterfaceDeclaration */) { if (!firstDecl) { firstDecl = declaration; } @@ -38076,7 +38403,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 & 128 /* Abstract */ && (!derivedClassDecl || !(ts.getModifierFlags(derivedClassDecl) & 128 /* Abstract */))) { - if (derivedClassDecl.kind === 192 /* ClassExpression */) { + if (derivedClassDecl.kind === 193 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -38124,7 +38451,7 @@ var ts; } } function isAccessor(kind) { - return kind === 149 /* GetAccessor */ || kind === 150 /* SetAccessor */; + return kind === 150 /* GetAccessor */ || kind === 151 /* SetAccessor */; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -38196,7 +38523,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(node, symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 222 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 223 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -38302,18 +38629,18 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 185 /* PrefixUnaryExpression */: + case 186 /* PrefixUnaryExpression */: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; } switch (e.operator) { - case 35 /* PlusToken */: return value_1; - case 36 /* MinusToken */: return -value_1; - case 50 /* TildeToken */: return ~value_1; + case 36 /* PlusToken */: return value_1; + case 37 /* MinusToken */: return -value_1; + case 51 /* TildeToken */: return ~value_1; } return undefined; - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -38323,31 +38650,31 @@ var ts; return undefined; } switch (e.operatorToken.kind) { - 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 39 /* SlashToken */: return left / right; - case 35 /* PlusToken */: return left + right; - case 36 /* MinusToken */: return left - right; - case 40 /* PercentToken */: return left % right; + case 48 /* BarToken */: return left | right; + case 47 /* AmpersandToken */: return left & right; + case 45 /* GreaterThanGreaterThanToken */: return left >> right; + case 46 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 44 /* LessThanLessThanToken */: return left << right; + case 49 /* CaretToken */: return left ^ right; + case 38 /* AsteriskToken */: return left * right; + case 40 /* SlashToken */: return left / right; + case 36 /* PlusToken */: return left + right; + case 37 /* MinusToken */: return left - right; + case 41 /* PercentToken */: return left % right; } return undefined; case 8 /* NumericLiteral */: return +e.text; - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return evalConstant(e.expression); - case 69 /* Identifier */: - case 173 /* ElementAccessExpression */: - case 172 /* PropertyAccessExpression */: + case 70 /* Identifier */: + case 174 /* ElementAccessExpression */: + case 173 /* PropertyAccessExpression */: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; var propertyName = void 0; - if (e.kind === 69 /* Identifier */) { + if (e.kind === 70 /* 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; @@ -38355,7 +38682,7 @@ var ts; } else { var expression = void 0; - if (e.kind === 173 /* ElementAccessExpression */) { + if (e.kind === 174 /* ElementAccessExpression */) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9 /* StringLiteral */) { return undefined; @@ -38370,10 +38697,10 @@ var ts; // expression part in ElementAccess\PropertyAccess should be either identifier or dottedName var current = expression; while (current) { - if (current.kind === 69 /* Identifier */) { + if (current.kind === 70 /* Identifier */) { break; } - else if (current.kind === 172 /* PropertyAccessExpression */) { + else if (current.kind === 173 /* PropertyAccessExpression */) { current = current.expression; } else { @@ -38445,7 +38772,7 @@ var ts; var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 224 /* EnumDeclaration */) { + if (declaration.kind !== 225 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -38468,8 +38795,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { var declaration = declarations_5[_i]; - if ((declaration.kind === 221 /* ClassDeclaration */ || - (declaration.kind === 220 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 222 /* ClassDeclaration */ || + (declaration.kind === 221 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -38533,7 +38860,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, 221 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 222 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -38584,23 +38911,23 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: // error each individual name in variable statement instead of marking the entire variable statement for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 235 /* ExportAssignment */: - case 236 /* ExportDeclaration */: + case 236 /* ExportAssignment */: + case 237 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 229 /* ImportEqualsDeclaration */: - case 230 /* ImportDeclaration */: + case 230 /* ImportEqualsDeclaration */: + case 231 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 169 /* BindingElement */: - case 218 /* VariableDeclaration */: + case 170 /* BindingElement */: + case 219 /* VariableDeclaration */: var name_22 = node.name; if (ts.isBindingPattern(name_22)) { for (var _b = 0, _c = name_22.elements; _b < _c.length; _b++) { @@ -38611,12 +38938,12 @@ var ts; break; } // fallthrough - case 221 /* ClassDeclaration */: - case 224 /* EnumDeclaration */: - case 220 /* FunctionDeclaration */: - case 222 /* InterfaceDeclaration */: - case 225 /* ModuleDeclaration */: - case 223 /* TypeAliasDeclaration */: + case 222 /* ClassDeclaration */: + case 225 /* EnumDeclaration */: + case 221 /* FunctionDeclaration */: + case 223 /* InterfaceDeclaration */: + case 226 /* ModuleDeclaration */: + case 224 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -38637,17 +38964,17 @@ var ts; } function getFirstIdentifier(node) { switch (node.kind) { - case 69 /* Identifier */: + case 70 /* Identifier */: return node; - case 139 /* QualifiedName */: + case 140 /* QualifiedName */: do { node = node.left; - } while (node.kind !== 69 /* Identifier */); + } while (node.kind !== 70 /* Identifier */); return node; - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: do { node = node.expression; - } while (node.kind !== 69 /* Identifier */); + } while (node.kind !== 70 /* Identifier */); return node; } } @@ -38657,9 +38984,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 226 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientExternalModule = node.parent.kind === 227 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); if (node.parent.kind !== 256 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 236 /* ExportDeclaration */ ? + error(moduleName, node.kind === 237 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -38692,7 +39019,7 @@ var ts; (symbol.flags & 793064 /* Type */ ? 793064 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 238 /* ExportSpecifier */ ? + var message = node.kind === 239 /* 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)); @@ -38720,7 +39047,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 232 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 233 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -38757,7 +39084,7 @@ var ts; } } else { - if (modulekind === ts.ModuleKind.ES6 && !ts.isInAmbientContext(node)) { + if (modulekind === ts.ModuleKind.ES2015 && !ts.isInAmbientContext(node)) { // Import equals declaration is deprecated in es6 or above grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } @@ -38777,7 +39104,7 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 226 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientExternalModule = node.parent.kind === 227 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); if (node.parent.kind !== 256 /* SourceFile */ && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } @@ -38792,7 +39119,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 256 /* SourceFile */ || node.parent.kind === 226 /* ModuleBlock */ || node.parent.kind === 225 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 256 /* SourceFile */ || node.parent.kind === 227 /* ModuleBlock */ || node.parent.kind === 226 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -38819,7 +39146,7 @@ var ts; return; } var container = node.parent.kind === 256 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 225 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + if (container.kind === 226 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } @@ -38827,7 +39154,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.getModifierFlags(node) !== 0) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 69 /* Identifier */) { + if (node.expression.kind === 70 /* Identifier */) { markExportAsReferenced(node); } else { @@ -38835,7 +39162,7 @@ var ts; } checkExternalModuleExports(container); if (node.isExportEquals && !ts.isInAmbientContext(node)) { - if (modulekind === ts.ModuleKind.ES6) { + if (modulekind === ts.ModuleKind.ES2015) { // export assignment is not supported in es6 modules grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_export_default_or_another_module_format_instead); } @@ -38894,7 +39221,7 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return (declaration.kind !== 220 /* FunctionDeclaration */ && declaration.kind !== 147 /* MethodDeclaration */) || + return (declaration.kind !== 221 /* FunctionDeclaration */ && declaration.kind !== 148 /* MethodDeclaration */) || !!declaration.body; } } @@ -38907,118 +39234,118 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 225 /* ModuleDeclaration */: - case 221 /* ClassDeclaration */: - case 222 /* InterfaceDeclaration */: - case 220 /* FunctionDeclaration */: + case 226 /* ModuleDeclaration */: + case 222 /* ClassDeclaration */: + case 223 /* InterfaceDeclaration */: + case 221 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 141 /* TypeParameter */: + case 142 /* TypeParameter */: return checkTypeParameter(node); - case 142 /* Parameter */: + case 143 /* Parameter */: return checkParameter(node); - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: return checkPropertyDeclaration(node); - case 156 /* FunctionType */: - case 157 /* ConstructorType */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: return checkSignatureDeclaration(node); - case 153 /* IndexSignature */: + case 154 /* IndexSignature */: return checkSignatureDeclaration(node); - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: return checkMethodDeclaration(node); - case 148 /* Constructor */: + case 149 /* Constructor */: return checkConstructorDeclaration(node); - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: return checkAccessorDeclaration(node); - case 155 /* TypeReference */: + case 156 /* TypeReference */: return checkTypeReferenceNode(node); - case 154 /* TypePredicate */: + case 155 /* TypePredicate */: return checkTypePredicate(node); - case 158 /* TypeQuery */: + case 159 /* TypeQuery */: return checkTypeQuery(node); - case 159 /* TypeLiteral */: + case 160 /* TypeLiteral */: return checkTypeLiteral(node); - case 160 /* ArrayType */: + case 161 /* ArrayType */: return checkArrayType(node); - case 161 /* TupleType */: + case 162 /* TupleType */: return checkTupleType(node); - case 162 /* UnionType */: - case 163 /* IntersectionType */: + case 163 /* UnionType */: + case 164 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 164 /* ParenthesizedType */: + case 165 /* ParenthesizedType */: return checkSourceElement(node.type); - case 220 /* FunctionDeclaration */: + case 221 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 199 /* Block */: - case 226 /* ModuleBlock */: + case 200 /* Block */: + case 227 /* ModuleBlock */: return checkBlock(node); - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: return checkVariableStatement(node); - case 202 /* ExpressionStatement */: + case 203 /* ExpressionStatement */: return checkExpressionStatement(node); - case 203 /* IfStatement */: + case 204 /* IfStatement */: return checkIfStatement(node); - case 204 /* DoStatement */: + case 205 /* DoStatement */: return checkDoStatement(node); - case 205 /* WhileStatement */: + case 206 /* WhileStatement */: return checkWhileStatement(node); - case 206 /* ForStatement */: + case 207 /* ForStatement */: return checkForStatement(node); - case 207 /* ForInStatement */: + case 208 /* ForInStatement */: return checkForInStatement(node); - case 208 /* ForOfStatement */: + case 209 /* ForOfStatement */: return checkForOfStatement(node); - case 209 /* ContinueStatement */: - case 210 /* BreakStatement */: + case 210 /* ContinueStatement */: + case 211 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 211 /* ReturnStatement */: + case 212 /* ReturnStatement */: return checkReturnStatement(node); - case 212 /* WithStatement */: + case 213 /* WithStatement */: return checkWithStatement(node); - case 213 /* SwitchStatement */: + case 214 /* SwitchStatement */: return checkSwitchStatement(node); - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: return checkLabeledStatement(node); - case 215 /* ThrowStatement */: + case 216 /* ThrowStatement */: return checkThrowStatement(node); - case 216 /* TryStatement */: + case 217 /* TryStatement */: return checkTryStatement(node); - case 218 /* VariableDeclaration */: + case 219 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 169 /* BindingElement */: + case 170 /* BindingElement */: return checkBindingElement(node); - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: return checkClassDeclaration(node); - case 222 /* InterfaceDeclaration */: + case 223 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 223 /* TypeAliasDeclaration */: + case 224 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 230 /* ImportDeclaration */: + case 231 /* ImportDeclaration */: return checkImportDeclaration(node); - case 229 /* ImportEqualsDeclaration */: + case 230 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 236 /* ExportDeclaration */: + case 237 /* ExportDeclaration */: return checkExportDeclaration(node); - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: return checkExportAssignment(node); - case 201 /* EmptyStatement */: + case 202 /* EmptyStatement */: checkGrammarStatementInAmbientContext(node); return; - case 217 /* DebuggerStatement */: + case 218 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 239 /* MissingDeclaration */: + case 240 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -39040,17 +39367,17 @@ var ts; for (var _i = 0, deferredNodes_1 = deferredNodes; _i < deferredNodes_1.length; _i++) { var node = deferredNodes_1[_i]; switch (node.kind) { - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: checkAccessorDeferred(node); break; - case 192 /* ClassExpression */: + case 193 /* ClassExpression */: checkClassExpressionDeferred(node); break; } @@ -39131,7 +39458,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 212 /* WithStatement */ && node.parent.statement === node) { + if (node.parent.kind === 213 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -39158,21 +39485,21 @@ var ts; if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 192 /* ClassExpression */: + case 193 /* 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 221 /* ClassDeclaration */: - case 222 /* InterfaceDeclaration */: + case 222 /* ClassDeclaration */: + case 223 /* InterfaceDeclaration */: // If we didn't come from static member of class or interface, // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. @@ -39181,7 +39508,7 @@ var ts; copySymbols(getSymbolOfNode(location).members, meaning & 793064 /* Type */); } break; - case 179 /* FunctionExpression */: + case 180 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -39224,34 +39551,34 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 69 /* Identifier */ && + return name.kind === 70 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 141 /* TypeParameter */: - case 221 /* ClassDeclaration */: - case 222 /* InterfaceDeclaration */: - case 223 /* TypeAliasDeclaration */: - case 224 /* EnumDeclaration */: + case 142 /* TypeParameter */: + case 222 /* ClassDeclaration */: + case 223 /* InterfaceDeclaration */: + case 224 /* TypeAliasDeclaration */: + case 225 /* 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 === 139 /* QualifiedName */) { + while (node.parent && node.parent.kind === 140 /* QualifiedName */) { node = node.parent; } - return node.parent && (node.parent.kind === 155 /* TypeReference */ || node.parent.kind === 267 /* JSDocTypeReference */); + return node.parent && (node.parent.kind === 156 /* TypeReference */ || node.parent.kind === 267 /* JSDocTypeReference */); } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 172 /* PropertyAccessExpression */) { + while (node.parent && node.parent.kind === 173 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent && node.parent.kind === 194 /* ExpressionWithTypeArguments */; + return node.parent && node.parent.kind === 195 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -39268,13 +39595,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 139 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 140 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 229 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 230 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 235 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 236 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -39286,7 +39613,7 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 172 /* PropertyAccessExpression */) { + if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 173 /* PropertyAccessExpression */) { var specialPropertyAssignmentKind = ts.getSpecialPropertyAssignmentKind(entityName.parent.parent); switch (specialPropertyAssignmentKind) { case 1 /* ExportsProperty */: @@ -39298,15 +39625,15 @@ var ts; default: } } - if (entityName.parent.kind === 235 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 236 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { return resolveEntityName(entityName, /*all meanings*/ 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */ | 8388608 /* Alias */); } - if (entityName.kind !== 172 /* PropertyAccessExpression */ && isInRightSideOfImportOrExportAssignment(entityName)) { + if (entityName.kind !== 173 /* PropertyAccessExpression */ && isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(entityName, 229 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 230 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); - return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importEqualsDeclaration, /*dontResolveAlias*/ true); + return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } if (ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; @@ -39314,7 +39641,7 @@ var ts; if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0 /* None */; // In an interface or class, we're definitely interested in a type. - if (entityName.parent.kind === 194 /* ExpressionWithTypeArguments */) { + if (entityName.parent.kind === 195 /* ExpressionWithTypeArguments */) { meaning = 793064 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { @@ -39332,20 +39659,20 @@ var ts; // Missing entity name. return undefined; } - if (entityName.kind === 69 /* Identifier */) { + if (entityName.kind === 70 /* Identifier */) { if (ts.isJSXTagName(entityName) && isJsxIntrinsicIdentifier(entityName)) { return getIntrinsicTagSymbol(entityName.parent); } return resolveEntityName(entityName, 107455 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.kind === 172 /* PropertyAccessExpression */) { + else if (entityName.kind === 173 /* PropertyAccessExpression */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 139 /* QualifiedName */) { + else if (entityName.kind === 140 /* QualifiedName */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -39354,13 +39681,13 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = (entityName.parent.kind === 155 /* TypeReference */ || entityName.parent.kind === 267 /* JSDocTypeReference */) ? 793064 /* Type */ : 1920 /* Namespace */; + var meaning = (entityName.parent.kind === 156 /* TypeReference */ || entityName.parent.kind === 267 /* JSDocTypeReference */) ? 793064 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } else if (entityName.parent.kind === 246 /* JsxAttribute */) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 154 /* TypePredicate */) { + if (entityName.parent.kind === 155 /* TypePredicate */) { return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? @@ -39381,12 +39708,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(node.parent.parent); } - if (node.kind === 69 /* Identifier */) { + if (node.kind === 70 /* Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (node.parent.kind === 169 /* BindingElement */ && - node.parent.parent.kind === 167 /* ObjectBindingPattern */ && + else if (node.parent.kind === 170 /* BindingElement */ && + node.parent.parent.kind === 168 /* ObjectBindingPattern */ && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -39396,11 +39723,11 @@ var ts; } } switch (node.kind) { - case 69 /* Identifier */: - case 172 /* PropertyAccessExpression */: - case 139 /* QualifiedName */: + case 70 /* Identifier */: + case 173 /* PropertyAccessExpression */: + case 140 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 97 /* ThisKeyword */: + case 98 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -39409,15 +39736,15 @@ var ts; } } // fallthrough - case 95 /* SuperKeyword */: + case 96 /* SuperKeyword */: var type = ts.isPartOfExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 165 /* ThisType */: + case 166 /* ThisType */: return getTypeFromTypeNode(node).symbol; - case 121 /* ConstructorKeyword */: + case 122 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 148 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 149 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -39425,7 +39752,7 @@ var ts; // External module name in an import declaration if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 230 /* ImportDeclaration */ || node.parent.kind === 236 /* ExportDeclaration */) && + ((node.parent.kind === 231 /* ImportDeclaration */ || node.parent.kind === 237 /* ExportDeclaration */) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } @@ -39435,7 +39762,7 @@ var ts; // Fall through case 8 /* NumericLiteral */: // index access - if (node.parent.kind === 173 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { + if (node.parent.kind === 174 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -39514,17 +39841,17 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 171 /* ObjectLiteralExpression */ || expr.kind === 170 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 172 /* ObjectLiteralExpression */ || expr.kind === 171 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 208 /* ForOfStatement */) { + if (expr.parent.kind === 209 /* ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression); return checkDestructuringAssignment(expr, iteratedType || unknownType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 187 /* BinaryExpression */) { + if (expr.parent.kind === 188 /* BinaryExpression */) { var iteratedType = checkExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || unknownType); } @@ -39535,7 +39862,7 @@ var ts; return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent); } // Array literal assignment - array destructuring pattern - ts.Debug.assert(expr.parent.kind === 170 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.parent.kind === 171 /* ArrayLiteralExpression */); // [{ property1: p1, property2 }] = elems; var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, /*allowStringInput*/ false) || unknownType; @@ -39724,7 +40051,7 @@ var ts; // they will not collide with anything var isDeclaredInLoop = nodeLinks_1.flags & 262144 /* BlockScopedBindingInLoop */; var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); - var inLoopBodyBlock = container.kind === 199 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 200 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -39770,18 +40097,18 @@ var ts; return true; } switch (node.kind) { - case 229 /* ImportEqualsDeclaration */: - case 231 /* ImportClause */: - case 232 /* NamespaceImport */: - case 234 /* ImportSpecifier */: - case 238 /* ExportSpecifier */: + case 230 /* ImportEqualsDeclaration */: + case 232 /* ImportClause */: + case 233 /* NamespaceImport */: + case 235 /* ImportSpecifier */: + case 239 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 236 /* ExportDeclaration */: + case 237 /* ExportDeclaration */: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: return node.expression - && node.expression.kind === 69 /* Identifier */ + && node.expression.kind === 70 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : true; } @@ -40043,7 +40370,7 @@ var ts; // property access can only be used as values // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries - var meaning = (node.kind === 172 /* PropertyAccessExpression */) || (node.kind === 69 /* Identifier */ && isInTypeQuery(node)) + var meaning = (node.kind === 173 /* PropertyAccessExpression */) || (node.kind === 70 /* Identifier */ && isInTypeQuery(node)) ? 107455 /* Value */ | 1048576 /* ExportValue */ : 793064 /* Type */ | 1920 /* Namespace */; var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); @@ -40192,7 +40519,7 @@ var ts; getGlobalPromiseConstructorLikeType = ts.memoize(function () { return getGlobalType("PromiseConstructorLike"); }); getGlobalThenableType = ts.memoize(createThenableType); getGlobalTemplateStringsArrayType = ts.memoize(function () { return getGlobalType("TemplateStringsArray"); }); - if (languageVersion >= 2 /* ES6 */) { + if (languageVersion >= 2 /* ES2015 */) { getGlobalESSymbolType = ts.memoize(function () { return getGlobalType("Symbol"); }); getGlobalIterableType = ts.memoize(function () { return getGlobalType("Iterable", /*arity*/ 1); }); getGlobalIteratorType = ts.memoize(function () { return getGlobalType("Iterator", /*arity*/ 1); }); @@ -40205,6 +40532,7 @@ var ts; getGlobalIterableIteratorType = ts.memoize(function () { return emptyGenericType; }); } anyArrayType = createArrayType(anyType); + autoArrayType = createArrayType(autoType); var symbol = getGlobalSymbol("ReadonlyArray", 793064 /* Type */, /*diagnostic*/ undefined); globalReadonlyArrayType = symbol && getTypeOfGlobalSymbol(symbol, /*arity*/ 1); anyReadonlyArrayType = globalReadonlyArrayType ? createTypeFromGenericGlobalType(globalReadonlyArrayType, [anyType]) : anyArrayType; @@ -40218,7 +40546,7 @@ var ts; // If we found the module, report errors if it does not have the necessary exports. if (helpersModule) { var exports = helpersModule.exports; - if (requestedExternalEmitHelpers & 1024 /* HasClassExtends */ && languageVersion < 2 /* ES6 */) { + if (requestedExternalEmitHelpers & 1024 /* HasClassExtends */ && languageVersion < 2 /* ES2015 */) { verifyHelperSymbol(exports, "__extends", 107455 /* Value */); } if (requestedExternalEmitHelpers & 16384 /* HasJsxSpreadAttributes */ && compilerOptions.jsx !== 1 /* Preserve */) { @@ -40235,7 +40563,7 @@ var ts; } if (requestedExternalEmitHelpers & 8192 /* HasAsyncFunctions */) { verifyHelperSymbol(exports, "__awaiter", 107455 /* Value */); - if (languageVersion < 2 /* ES6 */) { + if (languageVersion < 2 /* ES2015 */) { verifyHelperSymbol(exports, "__generator", 107455 /* Value */); } } @@ -40272,14 +40600,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node)) { - if (node.kind === 147 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 148 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload); } else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } } - else if (node.kind === 149 /* GetAccessor */ || node.kind === 150 /* SetAccessor */) { + else if (node.kind === 150 /* GetAccessor */ || node.kind === 151 /* 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); @@ -40296,28 +40624,28 @@ var ts; var flags = 0 /* None */; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 128 /* ReadonlyKeyword */) { - if (node.kind === 144 /* PropertySignature */ || node.kind === 146 /* MethodSignature */) { + if (modifier.kind !== 129 /* ReadonlyKeyword */) { + if (node.kind === 145 /* PropertySignature */ || node.kind === 147 /* MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 153 /* IndexSignature */) { + if (node.kind === 154 /* IndexSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 74 /* ConstKeyword */: - if (node.kind !== 224 /* EnumDeclaration */ && node.parent.kind === 221 /* ClassDeclaration */) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(74 /* ConstKeyword */)); + case 75 /* ConstKeyword */: + if (node.kind !== 225 /* EnumDeclaration */ && node.parent.kind === 222 /* ClassDeclaration */) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(75 /* ConstKeyword */)); } break; - case 112 /* PublicKeyword */: - case 111 /* ProtectedKeyword */: - case 110 /* PrivateKeyword */: + case 113 /* PublicKeyword */: + case 112 /* ProtectedKeyword */: + case 111 /* PrivateKeyword */: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); - if (modifier.kind === 111 /* ProtectedKeyword */) { + if (modifier.kind === 112 /* ProtectedKeyword */) { lastProtected = modifier; } - else if (modifier.kind === 110 /* PrivateKeyword */) { + else if (modifier.kind === 111 /* PrivateKeyword */) { lastPrivate = modifier; } if (flags & 28 /* AccessibilityModifier */) { @@ -40332,11 +40660,11 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 226 /* ModuleBlock */ || node.parent.kind === 256 /* SourceFile */) { + else if (node.parent.kind === 227 /* ModuleBlock */ || node.parent.kind === 256 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { - if (modifier.kind === 110 /* PrivateKeyword */) { + if (modifier.kind === 111 /* PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -40345,7 +40673,7 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 113 /* StaticKeyword */: + case 114 /* StaticKeyword */: if (flags & 32 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } @@ -40355,10 +40683,10 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 226 /* ModuleBlock */ || node.parent.kind === 256 /* SourceFile */) { + else if (node.parent.kind === 227 /* ModuleBlock */ || node.parent.kind === 256 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 142 /* Parameter */) { + else if (node.kind === 143 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { @@ -40367,18 +40695,18 @@ var ts; flags |= 32 /* Static */; lastStatic = modifier; break; - case 128 /* ReadonlyKeyword */: + case 129 /* ReadonlyKeyword */: if (flags & 64 /* Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 145 /* PropertyDeclaration */ && node.kind !== 144 /* PropertySignature */ && node.kind !== 153 /* IndexSignature */ && node.kind !== 142 /* Parameter */) { + else if (node.kind !== 146 /* PropertyDeclaration */ && node.kind !== 145 /* PropertySignature */ && node.kind !== 154 /* IndexSignature */ && node.kind !== 143 /* Parameter */) { // If node.kind === SyntaxKind.Parameter, checkParameter report an error if it's not a parameter property. return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } flags |= 64 /* Readonly */; lastReadonly = modifier; break; - case 82 /* ExportKeyword */: + case 83 /* ExportKeyword */: if (flags & 1 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -40391,45 +40719,45 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 221 /* ClassDeclaration */) { + else if (node.parent.kind === 222 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 142 /* Parameter */) { + else if (node.kind === 143 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; - case 122 /* DeclareKeyword */: + case 123 /* DeclareKeyword */: if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 221 /* ClassDeclaration */) { + else if (node.parent.kind === 222 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 142 /* Parameter */) { + else if (node.kind === 143 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 226 /* ModuleBlock */) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 227 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; lastDeclare = modifier; break; - case 115 /* AbstractKeyword */: + case 116 /* AbstractKeyword */: if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 221 /* ClassDeclaration */) { - if (node.kind !== 147 /* MethodDeclaration */ && - node.kind !== 145 /* PropertyDeclaration */ && - node.kind !== 149 /* GetAccessor */ && - node.kind !== 150 /* SetAccessor */) { + if (node.kind !== 222 /* ClassDeclaration */) { + if (node.kind !== 148 /* MethodDeclaration */ && + node.kind !== 146 /* PropertyDeclaration */ && + node.kind !== 150 /* GetAccessor */ && + node.kind !== 151 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 221 /* ClassDeclaration */ && ts.getModifierFlags(node.parent) & 128 /* Abstract */)) { + if (!(node.parent.kind === 222 /* ClassDeclaration */ && ts.getModifierFlags(node.parent) & 128 /* Abstract */)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32 /* Static */) { @@ -40441,14 +40769,14 @@ var ts; } flags |= 128 /* Abstract */; break; - case 118 /* AsyncKeyword */: + case 119 /* AsyncKeyword */: if (flags & 256 /* 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 === 142 /* Parameter */) { + else if (node.kind === 143 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256 /* Async */; @@ -40456,7 +40784,7 @@ var ts; break; } } - if (node.kind === 148 /* Constructor */) { + if (node.kind === 149 /* Constructor */) { if (flags & 32 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -40471,13 +40799,13 @@ var ts; } return; } - else if ((node.kind === 230 /* ImportDeclaration */ || node.kind === 229 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 231 /* ImportDeclaration */ || node.kind === 230 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 142 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 143 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 142 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 143 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256 /* Async */) { @@ -40497,38 +40825,38 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 148 /* Constructor */: - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 153 /* IndexSignature */: - case 225 /* ModuleDeclaration */: - case 230 /* ImportDeclaration */: - case 229 /* ImportEqualsDeclaration */: - case 236 /* ExportDeclaration */: - case 235 /* ExportAssignment */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: - case 142 /* Parameter */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 149 /* Constructor */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 154 /* IndexSignature */: + case 226 /* ModuleDeclaration */: + case 231 /* ImportDeclaration */: + case 230 /* ImportEqualsDeclaration */: + case 237 /* ExportDeclaration */: + case 236 /* ExportAssignment */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 143 /* Parameter */: return false; default: - if (node.parent.kind === 226 /* ModuleBlock */ || node.parent.kind === 256 /* SourceFile */) { + if (node.parent.kind === 227 /* ModuleBlock */ || node.parent.kind === 256 /* SourceFile */) { return false; } switch (node.kind) { - case 220 /* FunctionDeclaration */: - return nodeHasAnyModifiersExcept(node, 118 /* AsyncKeyword */); - case 221 /* ClassDeclaration */: - return nodeHasAnyModifiersExcept(node, 115 /* AbstractKeyword */); - case 222 /* InterfaceDeclaration */: - case 200 /* VariableStatement */: - case 223 /* TypeAliasDeclaration */: + case 221 /* FunctionDeclaration */: + return nodeHasAnyModifiersExcept(node, 119 /* AsyncKeyword */); + case 222 /* ClassDeclaration */: + return nodeHasAnyModifiersExcept(node, 116 /* AbstractKeyword */); + case 223 /* InterfaceDeclaration */: + case 201 /* VariableStatement */: + case 224 /* TypeAliasDeclaration */: return true; - case 224 /* EnumDeclaration */: - return nodeHasAnyModifiersExcept(node, 74 /* ConstKeyword */); + case 225 /* EnumDeclaration */: + return nodeHasAnyModifiersExcept(node, 75 /* ConstKeyword */); default: ts.Debug.fail(); return false; @@ -40540,10 +40868,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 147 /* MethodDeclaration */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 148 /* MethodDeclaration */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: if (!node.asteriskToken) { return false; } @@ -40559,7 +40887,7 @@ var ts; return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Trailing_comma_not_allowed); } } - function checkGrammarTypeParameterList(node, typeParameters, file) { + function checkGrammarTypeParameterList(typeParameters, file) { if (checkGrammarForDisallowedTrailingComma(typeParameters)) { return true; } @@ -40602,11 +40930,11 @@ var ts; function checkGrammarFunctionLikeDeclaration(node) { // Prevent cascading error by short-circuit var file = ts.getSourceFileOfNode(node); - return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node, node.typeParameters, file) || + return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node.typeParameters, file) || checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 180 /* ArrowFunction */) { + if (node.kind === 181 /* ArrowFunction */) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -40641,7 +40969,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 !== 132 /* StringKeyword */ && parameter.type.kind !== 130 /* NumberKeyword */) { + if (parameter.type.kind !== 133 /* StringKeyword */ && parameter.type.kind !== 131 /* NumberKeyword */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -40669,7 +40997,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 193 /* OmittedExpression */) { + if (arg.kind === 194 /* OmittedExpression */) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -40695,7 +41023,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 === 83 /* ExtendsKeyword */) { + if (heritageClause.token === 84 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -40708,7 +41036,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 106 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 107 /* ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -40724,14 +41052,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 83 /* ExtendsKeyword */) { + if (heritageClause.token === 84 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 106 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 107 /* ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -40742,31 +41070,31 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 140 /* ComputedPropertyName */) { + if (node.kind !== 141 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 187 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 24 /* CommaToken */) { + if (computedPropertyName.expression.kind === 188 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 25 /* 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 === 220 /* FunctionDeclaration */ || - node.kind === 179 /* FunctionExpression */ || - node.kind === 147 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 221 /* FunctionDeclaration */ || + node.kind === 180 /* FunctionExpression */ || + node.kind === 148 /* MethodDeclaration */); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } if (!node.body) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.An_overload_signature_cannot_be_declared_as_a_generator); } - if (languageVersion < 2 /* ES6 */) { + if (languageVersion < 2 /* ES2015 */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher); } } } - function checkGrammarForInvalidQuestionMark(node, questionToken, message) { + function checkGrammarForInvalidQuestionMark(questionToken, message) { if (questionToken) { return grammarErrorOnNode(questionToken, message); } @@ -40780,7 +41108,7 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; var name_24 = prop.name; - if (name_24.kind === 140 /* ComputedPropertyName */) { + if (name_24.kind === 141 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name_24); } @@ -40793,7 +41121,7 @@ var ts; if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (mod.kind !== 118 /* AsyncKeyword */ || prop.kind !== 147 /* MethodDeclaration */) { + if (mod.kind !== 119 /* AsyncKeyword */ || prop.kind !== 148 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -40809,19 +41137,19 @@ var ts; var currentKind = void 0; if (prop.kind === 253 /* PropertyAssignment */ || prop.kind === 254 /* ShorthandPropertyAssignment */) { // Grammar checking for computedPropertyName and shorthandPropertyAssignment - checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); + checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name_24.kind === 8 /* NumericLiteral */) { checkGrammarNumericLiteral(name_24); } currentKind = Property; } - else if (prop.kind === 147 /* MethodDeclaration */) { + else if (prop.kind === 148 /* MethodDeclaration */) { currentKind = Property; } - else if (prop.kind === 149 /* GetAccessor */) { + else if (prop.kind === 150 /* GetAccessor */) { currentKind = GetAccessor; } - else if (prop.kind === 150 /* SetAccessor */) { + else if (prop.kind === 151 /* SetAccessor */) { currentKind = SetAccessor; } else { @@ -40878,7 +41206,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 219 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 220 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -40893,20 +41221,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 207 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 208 /* 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 = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 207 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 208 /* 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 === 207 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 208 /* 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); @@ -40930,11 +41258,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 149 /* GetAccessor */ ? + return grammarErrorOnNode(accessor.name, kind === 150 /* GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 150 /* SetAccessor */) { + else if (kind === 151 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -40957,10 +41285,10 @@ var ts; A get accessor has no parameters or a single `this` parameter. A set accessor has one parameter or a `this` parameter and one more parameter */ function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 149 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 150 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 149 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 150 /* GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } @@ -40975,8 +41303,8 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 171 /* ObjectLiteralExpression */) { - if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { + if (node.parent.kind === 172 /* ObjectLiteralExpression */) { + if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { return true; } else if (node.body === undefined) { @@ -40996,10 +41324,10 @@ 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 === 222 /* InterfaceDeclaration */) { + else if (node.parent.kind === 223 /* 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 === 159 /* TypeLiteral */) { + else if (node.parent.kind === 160 /* TypeLiteral */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } @@ -41010,11 +41338,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 214 /* LabeledStatement */: + case 215 /* 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 === 209 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 210 /* ContinueStatement */ && !ts.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); @@ -41022,8 +41350,8 @@ var ts; return false; } break; - case 213 /* SwitchStatement */: - if (node.kind === 210 /* BreakStatement */ && !node.label) { + case 214 /* SwitchStatement */: + if (node.kind === 211 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -41038,13 +41366,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 210 /* BreakStatement */ + var message = node.kind === 211 /* 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 === 210 /* BreakStatement */ + var message = node.kind === 211 /* 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); @@ -41056,7 +41384,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 === 168 /* ArrayBindingPattern */ || node.name.kind === 167 /* ObjectBindingPattern */) { + if (node.name.kind === 169 /* ArrayBindingPattern */ || node.name.kind === 168 /* ObjectBindingPattern */) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -41067,11 +41395,11 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || - expr.kind === 185 /* PrefixUnaryExpression */ && expr.operator === 36 /* MinusToken */ && + expr.kind === 186 /* PrefixUnaryExpression */ && expr.operator === 37 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 207 /* ForInStatement */ && node.parent.parent.kind !== 208 /* ForOfStatement */) { + if (node.parent.parent.kind !== 208 /* ForInStatement */ && node.parent.parent.kind !== 209 /* ForOfStatement */) { if (ts.isInAmbientContext(node)) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -41110,8 +41438,8 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 69 /* Identifier */) { - if (name.originalKeywordKind === 108 /* LetKeyword */) { + if (name.kind === 70 /* Identifier */) { + if (name.originalKeywordKind === 109 /* LetKeyword */) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -41136,15 +41464,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 203 /* IfStatement */: - case 204 /* DoStatement */: - case 205 /* WhileStatement */: - case 212 /* WithStatement */: - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: + case 204 /* IfStatement */: + case 205 /* DoStatement */: + case 206 /* WhileStatement */: + case 213 /* WithStatement */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: return false; - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -41199,7 +41527,7 @@ var ts; return true; } } - else if (node.parent.kind === 222 /* InterfaceDeclaration */) { + else if (node.parent.kind === 223 /* InterfaceDeclaration */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -41207,7 +41535,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 159 /* TypeLiteral */) { + else if (node.parent.kind === 160 /* 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; } @@ -41232,13 +41560,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 222 /* InterfaceDeclaration */ || - node.kind === 223 /* TypeAliasDeclaration */ || - node.kind === 230 /* ImportDeclaration */ || - node.kind === 229 /* ImportEqualsDeclaration */ || - node.kind === 236 /* ExportDeclaration */ || - node.kind === 235 /* ExportAssignment */ || - node.kind === 228 /* NamespaceExportDeclaration */ || + if (node.kind === 223 /* InterfaceDeclaration */ || + node.kind === 224 /* TypeAliasDeclaration */ || + node.kind === 231 /* ImportDeclaration */ || + node.kind === 230 /* ImportEqualsDeclaration */ || + node.kind === 237 /* ExportDeclaration */ || + node.kind === 236 /* ExportAssignment */ || + node.kind === 229 /* NamespaceExportDeclaration */ || ts.getModifierFlags(node) & (2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -41247,7 +41575,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 === 200 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 201 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -41273,7 +41601,7 @@ var ts; // to prevent noisiness. 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 === 199 /* Block */ || node.parent.kind === 226 /* ModuleBlock */ || node.parent.kind === 256 /* SourceFile */) { + if (node.parent.kind === 200 /* Block */ || node.parent.kind === 227 /* ModuleBlock */ || node.parent.kind === 256 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -41333,46 +41661,46 @@ var ts; * significantly impacted. */ var nodeEdgeTraversalMap = ts.createMap((_a = {}, - _a[139 /* QualifiedName */] = [ + _a[140 /* QualifiedName */] = [ { name: "left", test: ts.isEntityName }, { name: "right", test: ts.isIdentifier } ], - _a[143 /* Decorator */] = [ + _a[144 /* Decorator */] = [ { name: "expression", test: ts.isLeftHandSideExpression } ], - _a[177 /* TypeAssertionExpression */] = [ + _a[178 /* TypeAssertionExpression */] = [ { name: "type", test: ts.isTypeNode }, { name: "expression", test: ts.isUnaryExpression } ], - _a[195 /* AsExpression */] = [ + _a[196 /* AsExpression */] = [ { name: "expression", test: ts.isExpression }, { name: "type", test: ts.isTypeNode } ], - _a[196 /* NonNullExpression */] = [ + _a[197 /* NonNullExpression */] = [ { name: "expression", test: ts.isLeftHandSideExpression } ], - _a[224 /* EnumDeclaration */] = [ + _a[225 /* EnumDeclaration */] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "members", test: ts.isEnumMember } ], - _a[225 /* ModuleDeclaration */] = [ + _a[226 /* ModuleDeclaration */] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isModuleName }, { name: "body", test: ts.isModuleBody } ], - _a[226 /* ModuleBlock */] = [ + _a[227 /* ModuleBlock */] = [ { name: "statements", test: ts.isStatement } ], - _a[229 /* ImportEqualsDeclaration */] = [ + _a[230 /* ImportEqualsDeclaration */] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "moduleReference", test: ts.isModuleReference } ], - _a[240 /* ExternalModuleReference */] = [ + _a[241 /* ExternalModuleReference */] = [ { name: "expression", test: ts.isExpression, optional: true } ], _a[255 /* EnumMember */] = [ @@ -41398,47 +41726,47 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 138 /* LastToken */)) { + if ((kind > 0 /* FirstToken */ && kind <= 139 /* LastToken */)) { return initial; } // We do not yet support types. - if ((kind >= 154 /* TypePredicate */ && kind <= 166 /* LiteralType */)) { + if ((kind >= 155 /* TypePredicate */ && kind <= 167 /* LiteralType */)) { return initial; } var result = initial; switch (node.kind) { // Leaf nodes - case 198 /* SemicolonClassElement */: - case 201 /* EmptyStatement */: - case 193 /* OmittedExpression */: - case 217 /* DebuggerStatement */: + case 199 /* SemicolonClassElement */: + case 202 /* EmptyStatement */: + case 194 /* OmittedExpression */: + case 218 /* DebuggerStatement */: case 287 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: result = reduceNode(node.expression, f, result); break; // Signature elements - case 142 /* Parameter */: + case 143 /* Parameter */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.initializer, f, result); break; - case 143 /* Decorator */: + case 144 /* Decorator */: result = reduceNode(node.expression, f, result); break; // Type member - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.initializer, f, result); break; - case 147 /* MethodDeclaration */: + case 148 /* MethodDeclaration */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -41447,12 +41775,12 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 148 /* Constructor */: + case 149 /* Constructor */: result = ts.reduceLeft(node.modifiers, f, result); result = ts.reduceLeft(node.parameters, f, result); result = reduceNode(node.body, f, result); break; - case 149 /* GetAccessor */: + case 150 /* GetAccessor */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -41460,7 +41788,7 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 150 /* SetAccessor */: + case 151 /* SetAccessor */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -41468,45 +41796,45 @@ var ts; result = reduceNode(node.body, f, result); break; // Binding patterns - case 167 /* ObjectBindingPattern */: - case 168 /* ArrayBindingPattern */: + case 168 /* ObjectBindingPattern */: + case 169 /* ArrayBindingPattern */: result = ts.reduceLeft(node.elements, f, result); break; - case 169 /* BindingElement */: + case 170 /* BindingElement */: result = reduceNode(node.propertyName, f, result); result = reduceNode(node.name, f, result); result = reduceNode(node.initializer, f, result); break; // Expression - case 170 /* ArrayLiteralExpression */: + case 171 /* ArrayLiteralExpression */: result = ts.reduceLeft(node.elements, f, result); break; - case 171 /* ObjectLiteralExpression */: + case 172 /* ObjectLiteralExpression */: result = ts.reduceLeft(node.properties, f, result); break; - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: result = reduceNode(node.expression, f, result); result = reduceNode(node.name, f, result); break; - case 173 /* ElementAccessExpression */: + case 174 /* ElementAccessExpression */: result = reduceNode(node.expression, f, result); result = reduceNode(node.argumentExpression, f, result); break; - case 174 /* CallExpression */: + case 175 /* CallExpression */: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); result = ts.reduceLeft(node.arguments, f, result); break; - case 175 /* NewExpression */: + case 176 /* NewExpression */: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); result = ts.reduceLeft(node.arguments, f, result); break; - case 176 /* TaggedTemplateExpression */: + case 177 /* TaggedTemplateExpression */: result = reduceNode(node.tag, f, result); result = reduceNode(node.template, f, result); break; - case 179 /* FunctionExpression */: + case 180 /* FunctionExpression */: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.typeParameters, f, result); @@ -41514,119 +41842,119 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 180 /* ArrowFunction */: + case 181 /* ArrowFunction */: result = ts.reduceLeft(node.modifiers, f, result); result = ts.reduceLeft(node.typeParameters, f, result); result = ts.reduceLeft(node.parameters, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 178 /* ParenthesizedExpression */: - case 181 /* DeleteExpression */: - case 182 /* TypeOfExpression */: - case 183 /* VoidExpression */: - case 184 /* AwaitExpression */: - case 190 /* YieldExpression */: - case 191 /* SpreadElementExpression */: - case 196 /* NonNullExpression */: + case 179 /* ParenthesizedExpression */: + case 182 /* DeleteExpression */: + case 183 /* TypeOfExpression */: + case 184 /* VoidExpression */: + case 185 /* AwaitExpression */: + case 191 /* YieldExpression */: + case 192 /* SpreadElementExpression */: + case 197 /* NonNullExpression */: result = reduceNode(node.expression, f, result); break; - case 185 /* PrefixUnaryExpression */: - case 186 /* PostfixUnaryExpression */: + case 186 /* PrefixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: result = reduceNode(node.operand, f, result); break; - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: result = reduceNode(node.left, f, result); result = reduceNode(node.right, f, result); break; - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: result = reduceNode(node.condition, f, result); result = reduceNode(node.whenTrue, f, result); result = reduceNode(node.whenFalse, f, result); break; - case 189 /* TemplateExpression */: + case 190 /* TemplateExpression */: result = reduceNode(node.head, f, result); result = ts.reduceLeft(node.templateSpans, f, result); break; - case 192 /* ClassExpression */: + case 193 /* ClassExpression */: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.typeParameters, f, result); result = ts.reduceLeft(node.heritageClauses, f, result); result = ts.reduceLeft(node.members, f, result); break; - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); break; // Misc - case 197 /* TemplateSpan */: + case 198 /* TemplateSpan */: result = reduceNode(node.expression, f, result); result = reduceNode(node.literal, f, result); break; // Element - case 199 /* Block */: + case 200 /* Block */: result = ts.reduceLeft(node.statements, f, result); break; - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.declarationList, f, result); break; - case 202 /* ExpressionStatement */: + case 203 /* ExpressionStatement */: result = reduceNode(node.expression, f, result); break; - case 203 /* IfStatement */: + case 204 /* IfStatement */: result = reduceNode(node.expression, f, result); result = reduceNode(node.thenStatement, f, result); result = reduceNode(node.elseStatement, f, result); break; - case 204 /* DoStatement */: + case 205 /* DoStatement */: result = reduceNode(node.statement, f, result); result = reduceNode(node.expression, f, result); break; - case 205 /* WhileStatement */: - case 212 /* WithStatement */: + case 206 /* WhileStatement */: + case 213 /* WithStatement */: result = reduceNode(node.expression, f, result); result = reduceNode(node.statement, f, result); break; - case 206 /* ForStatement */: + case 207 /* ForStatement */: result = reduceNode(node.initializer, f, result); result = reduceNode(node.condition, f, result); result = reduceNode(node.incrementor, f, result); result = reduceNode(node.statement, f, result); break; - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: result = reduceNode(node.initializer, f, result); result = reduceNode(node.expression, f, result); result = reduceNode(node.statement, f, result); break; - case 211 /* ReturnStatement */: - case 215 /* ThrowStatement */: + case 212 /* ReturnStatement */: + case 216 /* ThrowStatement */: result = reduceNode(node.expression, f, result); break; - case 213 /* SwitchStatement */: + case 214 /* SwitchStatement */: result = reduceNode(node.expression, f, result); result = reduceNode(node.caseBlock, f, result); break; - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: result = reduceNode(node.label, f, result); result = reduceNode(node.statement, f, result); break; - case 216 /* TryStatement */: + case 217 /* TryStatement */: result = reduceNode(node.tryBlock, f, result); result = reduceNode(node.catchClause, f, result); result = reduceNode(node.finallyBlock, f, result); break; - case 218 /* VariableDeclaration */: + case 219 /* VariableDeclaration */: result = reduceNode(node.name, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.initializer, f, result); break; - case 219 /* VariableDeclarationList */: + case 220 /* VariableDeclarationList */: result = ts.reduceLeft(node.declarations, f, result); break; - case 220 /* FunctionDeclaration */: + case 221 /* FunctionDeclaration */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -41635,7 +41963,7 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -41643,50 +41971,50 @@ var ts; result = ts.reduceLeft(node.heritageClauses, f, result); result = ts.reduceLeft(node.members, f, result); break; - case 227 /* CaseBlock */: + case 228 /* CaseBlock */: result = ts.reduceLeft(node.clauses, f, result); break; - case 230 /* ImportDeclaration */: + case 231 /* ImportDeclaration */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.importClause, f, result); result = reduceNode(node.moduleSpecifier, f, result); break; - case 231 /* ImportClause */: + case 232 /* ImportClause */: result = reduceNode(node.name, f, result); result = reduceNode(node.namedBindings, f, result); break; - case 232 /* NamespaceImport */: + case 233 /* NamespaceImport */: result = reduceNode(node.name, f, result); break; - case 233 /* NamedImports */: - case 237 /* NamedExports */: + case 234 /* NamedImports */: + case 238 /* NamedExports */: result = ts.reduceLeft(node.elements, f, result); break; - case 234 /* ImportSpecifier */: - case 238 /* ExportSpecifier */: + case 235 /* ImportSpecifier */: + case 239 /* ExportSpecifier */: result = reduceNode(node.propertyName, f, result); result = reduceNode(node.name, f, result); break; - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.expression, f, result); break; - case 236 /* ExportDeclaration */: + case 237 /* ExportDeclaration */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.exportClause, f, result); result = reduceNode(node.moduleSpecifier, f, result); break; // JSX - case 241 /* JsxElement */: + case 242 /* JsxElement */: result = reduceNode(node.openingElement, f, result); result = ts.reduceLeft(node.children, f, result); result = reduceNode(node.closingElement, f, result); break; - case 242 /* JsxSelfClosingElement */: - case 243 /* JsxOpeningElement */: + case 243 /* JsxSelfClosingElement */: + case 244 /* JsxOpeningElement */: result = reduceNode(node.tagName, f, result); result = ts.reduceLeft(node.attributes, f, result); break; @@ -41841,163 +42169,163 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 138 /* LastToken */)) { + if ((kind > 0 /* FirstToken */ && kind <= 139 /* LastToken */)) { return node; } // We do not yet support types. - if ((kind >= 154 /* TypePredicate */ && kind <= 166 /* LiteralType */)) { + if ((kind >= 155 /* TypePredicate */ && kind <= 167 /* LiteralType */)) { return node; } switch (node.kind) { - case 198 /* SemicolonClassElement */: - case 201 /* EmptyStatement */: - case 193 /* OmittedExpression */: - case 217 /* DebuggerStatement */: + case 199 /* SemicolonClassElement */: + case 202 /* EmptyStatement */: + case 194 /* OmittedExpression */: + case 218 /* DebuggerStatement */: // No need to visit nodes with no children. return node; // Names - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); // Signature elements - case 142 /* Parameter */: + case 143 /* Parameter */: return ts.updateParameterDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); // Type member - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: return ts.updateProperty(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); - case 147 /* MethodDeclaration */: + case 148 /* MethodDeclaration */: return ts.updateMethod(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, /*optional*/ true), context.endLexicalEnvironment())); - case 148 /* Constructor */: + case 149 /* Constructor */: return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, /*optional*/ true), context.endLexicalEnvironment())); - case 149 /* GetAccessor */: + case 150 /* GetAccessor */: return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, /*optional*/ true), context.endLexicalEnvironment())); - case 150 /* SetAccessor */: + case 151 /* SetAccessor */: return ts.updateSetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, /*optional*/ true), context.endLexicalEnvironment())); // Binding patterns - case 167 /* ObjectBindingPattern */: + case 168 /* ObjectBindingPattern */: return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); - case 168 /* ArrayBindingPattern */: + case 169 /* ArrayBindingPattern */: return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); - case 169 /* BindingElement */: + case 170 /* BindingElement */: return ts.updateBindingElement(node, visitNode(node.propertyName, visitor, ts.isPropertyName, /*optional*/ true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); // Expression - case 170 /* ArrayLiteralExpression */: + case 171 /* ArrayLiteralExpression */: return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); - case 171 /* ObjectLiteralExpression */: + case 172 /* ObjectLiteralExpression */: return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 173 /* ElementAccessExpression */: + case 174 /* ElementAccessExpression */: return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 174 /* CallExpression */: + case 175 /* CallExpression */: return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); - case 175 /* NewExpression */: + case 176 /* NewExpression */: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); - case 176 /* TaggedTemplateExpression */: + case 177 /* TaggedTemplateExpression */: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 179 /* FunctionExpression */: - return ts.updateFunctionExpression(node, visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, /*optional*/ true), context.endLexicalEnvironment())); - case 180 /* ArrowFunction */: + case 180 /* FunctionExpression */: + return ts.updateFunctionExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, /*optional*/ true), context.endLexicalEnvironment())); + case 181 /* ArrowFunction */: return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isConciseBody, /*optional*/ true), context.endLexicalEnvironment())); - case 181 /* DeleteExpression */: + case 182 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 182 /* TypeOfExpression */: + case 183 /* TypeOfExpression */: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 183 /* VoidExpression */: + case 184 /* VoidExpression */: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 184 /* AwaitExpression */: + case 185 /* AwaitExpression */: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); - case 185 /* PrefixUnaryExpression */: + case 186 /* PrefixUnaryExpression */: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 186 /* PostfixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); - case 189 /* TemplateExpression */: + case 190 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); - case 190 /* YieldExpression */: + case 191 /* YieldExpression */: return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); - case 191 /* SpreadElementExpression */: + case 192 /* SpreadElementExpression */: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 192 /* ClassExpression */: + case 193 /* ClassExpression */: return ts.updateClassExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, /*optional*/ true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); // Misc - case 197 /* TemplateSpan */: + case 198 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 199 /* Block */: + case 200 /* Block */: return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 202 /* ExpressionStatement */: + case 203 /* ExpressionStatement */: return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 203 /* IfStatement */: + case 204 /* IfStatement */: return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, /*optional*/ false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, /*optional*/ true, liftToBlock)); - case 204 /* DoStatement */: + case 205 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 205 /* WhileStatement */: + case 206 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 206 /* ForStatement */: + case 207 /* ForStatement */: return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 207 /* ForInStatement */: + case 208 /* ForInStatement */: return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 208 /* ForOfStatement */: + case 209 /* ForOfStatement */: return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 209 /* ContinueStatement */: + case 210 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, /*optional*/ true)); - case 210 /* BreakStatement */: + case 211 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, /*optional*/ true)); - case 211 /* ReturnStatement */: + case 212 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, /*optional*/ true)); - case 212 /* WithStatement */: + case 213 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 213 /* SwitchStatement */: + case 214 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 215 /* ThrowStatement */: + case 216 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 216 /* TryStatement */: + case 217 /* TryStatement */: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause, /*optional*/ true), visitNode(node.finallyBlock, visitor, ts.isBlock, /*optional*/ true)); - case 218 /* VariableDeclaration */: + case 219 /* VariableDeclaration */: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); - case 219 /* VariableDeclarationList */: + case 220 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); - case 220 /* FunctionDeclaration */: + case 221 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, /*optional*/ true), context.endLexicalEnvironment())); - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: return ts.updateClassDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, /*optional*/ true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 227 /* CaseBlock */: + case 228 /* CaseBlock */: return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 230 /* ImportDeclaration */: + case 231 /* ImportDeclaration */: return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, /*optional*/ true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 231 /* ImportClause */: + case 232 /* ImportClause */: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, /*optional*/ true)); - case 232 /* NamespaceImport */: + case 233 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 233 /* NamedImports */: + case 234 /* NamedImports */: return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); - case 234 /* ImportSpecifier */: + case 235 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.name, visitor, ts.isIdentifier)); - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 236 /* ExportDeclaration */: + case 237 /* ExportDeclaration */: return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, /*optional*/ true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, /*optional*/ true)); - case 237 /* NamedExports */: + case 238 /* NamedExports */: return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); - case 238 /* ExportSpecifier */: + case 239 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.name, visitor, ts.isIdentifier)); // JSX - case 241 /* JsxElement */: + case 242 /* JsxElement */: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 242 /* JsxSelfClosingElement */: + case 243 /* JsxSelfClosingElement */: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); - case 243 /* JsxOpeningElement */: + case 244 /* JsxOpeningElement */: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); case 245 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); @@ -42142,67 +42470,67 @@ var ts; * than calling this function. */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 154 /* FirstTypeNode */ && kind <= 166 /* LastTypeNode */) { + if (kind >= 155 /* FirstTypeNode */ && kind <= 167 /* LastTypeNode */) { return -3 /* TypeExcludes */; } switch (kind) { - case 174 /* CallExpression */: - case 175 /* NewExpression */: - case 170 /* ArrayLiteralExpression */: - return 537133909 /* ArrayLiteralOrCallOrNewExcludes */; - case 225 /* ModuleDeclaration */: - return 546335573 /* ModuleExcludes */; - case 142 /* Parameter */: - return 538968917 /* ParameterExcludes */; - case 180 /* ArrowFunction */: - return 550710101 /* ArrowFunctionExcludes */; - case 179 /* FunctionExpression */: - case 220 /* FunctionDeclaration */: - return 550726485 /* FunctionExcludes */; - case 219 /* VariableDeclarationList */: - return 538968917 /* VariableDeclarationListExcludes */; - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - return 537590613 /* ClassExcludes */; - case 148 /* Constructor */: - return 550593365 /* ConstructorExcludes */; - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - return 550593365 /* MethodOrAccessorExcludes */; - case 117 /* AnyKeyword */: - case 130 /* NumberKeyword */: - case 127 /* NeverKeyword */: - case 132 /* StringKeyword */: - case 120 /* BooleanKeyword */: - case 133 /* SymbolKeyword */: - case 103 /* VoidKeyword */: - case 141 /* TypeParameter */: - case 144 /* PropertySignature */: - case 146 /* MethodSignature */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: - case 222 /* InterfaceDeclaration */: - case 223 /* TypeAliasDeclaration */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: + case 171 /* ArrayLiteralExpression */: + return 537922901 /* ArrayLiteralOrCallOrNewExcludes */; + case 226 /* ModuleDeclaration */: + return 574729557 /* ModuleExcludes */; + case 143 /* Parameter */: + return 545262933 /* ParameterExcludes */; + case 181 /* ArrowFunction */: + return 592227669 /* ArrowFunctionExcludes */; + case 180 /* FunctionExpression */: + case 221 /* FunctionDeclaration */: + return 592293205 /* FunctionExcludes */; + case 220 /* VariableDeclarationList */: + return 545262933 /* VariableDeclarationListExcludes */; + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + return 539749717 /* ClassExcludes */; + case 149 /* Constructor */: + return 591760725 /* ConstructorExcludes */; + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + return 591760725 /* MethodOrAccessorExcludes */; + case 118 /* AnyKeyword */: + case 131 /* NumberKeyword */: + case 128 /* NeverKeyword */: + case 133 /* StringKeyword */: + case 121 /* BooleanKeyword */: + case 134 /* SymbolKeyword */: + case 104 /* VoidKeyword */: + case 142 /* TypeParameter */: + case 145 /* PropertySignature */: + case 147 /* MethodSignature */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: + case 223 /* InterfaceDeclaration */: + case 224 /* TypeAliasDeclaration */: return -3 /* TypeExcludes */; - case 171 /* ObjectLiteralExpression */: - return 537430869 /* ObjectLiteralExcludes */; + case 172 /* ObjectLiteralExpression */: + return 539110741 /* ObjectLiteralExcludes */; default: - return 536871765 /* NodeExcludes */; + return 536874325 /* NodeExcludes */; } } var Debug; (function (Debug) { Debug.failNotOptional = Debug.shouldAssert(1 /* Normal */) ? function (message) { return Debug.assert(false, message || "Node not optional."); } - : function (message) { }; + : function () { }; Debug.failBadSyntaxKind = Debug.shouldAssert(1 /* Normal */) ? function (node, message) { return Debug.assert(false, message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " was unexpected."; }); } - : function (node, message) { }; + : function () { }; Debug.assertNode = Debug.shouldAssert(1 /* Normal */) ? function (node, test, message) { return Debug.assert(test === undefined || test(node), message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }); } - : function (node, test, message) { }; + : function () { }; function getFunctionName(func) { if (typeof func !== "function") { return ""; @@ -42264,7 +42592,7 @@ var ts; // location should point to the right-hand value of the expression. location = value; } - flattenDestructuring(context, node, value, location, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, location, emitAssignment, emitTempVariableAssignment, visitor); if (needsValue) { expressions.push(value); } @@ -42293,9 +42621,9 @@ var ts; * @param value The rhs value for the binding pattern. * @param visitor An optional visitor to use to visit expressions. */ - function flattenParameterDestructuring(context, node, value, visitor) { + function flattenParameterDestructuring(node, value, visitor) { var declarations = []; - flattenDestructuring(context, node, value, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, visitor); return declarations; function emitAssignment(name, value, location) { var declaration = ts.createVariableDeclaration(name, /*type*/ undefined, value, location); @@ -42319,10 +42647,10 @@ var ts; * @param value An optional rhs value for the binding pattern. * @param visitor An optional visitor to use to visit expressions. */ - function flattenVariableDestructuring(context, node, value, visitor, recordTempVariable) { + function flattenVariableDestructuring(node, value, visitor, recordTempVariable) { var declarations = []; var pendingAssignments; - flattenDestructuring(context, node, value, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, visitor); return declarations; function emitAssignment(name, value, location, original) { if (pendingAssignments) { @@ -42364,9 +42692,9 @@ var ts; * @param nameSubstitution An optional callback used to substitute binding names. * @param visitor An optional visitor to use to visit expressions. */ - function flattenVariableDestructuringToExpression(context, node, recordTempVariable, nameSubstitution, visitor) { + function flattenVariableDestructuringToExpression(node, recordTempVariable, nameSubstitution, visitor) { var pendingAssignments = []; - flattenDestructuring(context, node, /*value*/ undefined, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, /*value*/ undefined, node, emitAssignment, emitTempVariableAssignment, visitor); var expression = ts.inlineExpressions(pendingAssignments); ts.aggregateTransformFlags(expression); return expression; @@ -42390,7 +42718,7 @@ var ts; } } ts.flattenVariableDestructuringToExpression = flattenVariableDestructuringToExpression; - function flattenDestructuring(context, root, value, location, emitAssignment, emitTempVariableAssignment, visitor) { + function flattenDestructuring(root, value, location, emitAssignment, emitTempVariableAssignment, visitor) { if (value && visitor) { value = ts.visitNode(value, visitor, ts.isExpression); } @@ -42412,7 +42740,7 @@ var ts; } target = bindingTarget.name; } - else if (ts.isBinaryExpression(bindingTarget) && bindingTarget.operatorToken.kind === 56 /* EqualsToken */) { + else if (ts.isBinaryExpression(bindingTarget) && bindingTarget.operatorToken.kind === 57 /* EqualsToken */) { var initializer = visitor ? ts.visitNode(bindingTarget.right, visitor, ts.isExpression) : bindingTarget.right; @@ -42422,10 +42750,10 @@ var ts; else { target = bindingTarget; } - if (target.kind === 171 /* ObjectLiteralExpression */) { + if (target.kind === 172 /* ObjectLiteralExpression */) { emitObjectLiteralAssignment(target, value, location); } - else if (target.kind === 170 /* ArrayLiteralExpression */) { + else if (target.kind === 171 /* ArrayLiteralExpression */) { emitArrayLiteralAssignment(target, value, location); } else { @@ -42464,9 +42792,9 @@ var ts; } for (var i = 0; i < numElements; i++) { var e = elements[i]; - if (e.kind !== 193 /* OmittedExpression */) { + if (e.kind !== 194 /* OmittedExpression */) { // Assignment for target = value.propName should highligh whole property, hence use e as source map node - if (e.kind !== 191 /* SpreadElementExpression */) { + if (e.kind !== 192 /* SpreadElementExpression */) { emitDestructuringAssignment(e, ts.createElementAccess(value, ts.createLiteral(i)), e); } else if (i === numElements - 1) { @@ -42502,7 +42830,7 @@ var ts; if (ts.isOmittedExpression(element)) { continue; } - else if (name.kind === 167 /* ObjectBindingPattern */) { + else if (name.kind === 168 /* ObjectBindingPattern */) { // Rewrite element to a declaration with an initializer that fetches property var propName = element.propertyName || element.name; emitBindingElement(element, createDestructuringPropertyAccess(value, propName)); @@ -42524,7 +42852,7 @@ var ts; } function createDefaultValueCheck(value, defaultValue, location) { value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true, location, emitTempVariableAssignment); - return ts.createConditional(ts.createStrictEquality(value, ts.createVoidZero()), ts.createToken(53 /* QuestionToken */), defaultValue, ts.createToken(54 /* ColonToken */), value); + return ts.createConditional(ts.createStrictEquality(value, ts.createVoidZero()), ts.createToken(54 /* QuestionToken */), defaultValue, ts.createToken(55 /* ColonToken */), value); } /** * Creates either a PropertyAccessExpression or an ElementAccessExpression for the @@ -42594,8 +42922,6 @@ var ts; TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["ClassAliases"] = 1] = "ClassAliases"; /** Enables substitutions for namespace exports. */ TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["NamespaceExports"] = 2] = "NamespaceExports"; - /** Enables substitutions for async methods with `super` calls. */ - TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["AsyncMethodsWithSuper"] = 4] = "AsyncMethodsWithSuper"; /* Enables substitutions for unqualified enum members */ TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["NonQualifiedEnumMembers"] = 8] = "NonQualifiedEnumMembers"; })(TypeScriptSubstitutionFlags || (TypeScriptSubstitutionFlags = {})); @@ -42612,8 +42938,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(172 /* PropertyAccessExpression */); - context.enableSubstitution(173 /* ElementAccessExpression */); + context.enableSubstitution(173 /* PropertyAccessExpression */); + context.enableSubstitution(174 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -42636,11 +42962,6 @@ var ts; * just-in-time substitution while printing an expression identifier. */ var applicableSubstitutions; - /** - * This keeps track of containers where `super` is valid, for use with - * just-in-time substitution for `super` expressions inside of async methods. - */ - var currentSuperContainer; return transformSourceFile; /** * Transform TypeScript-specific syntax in a SourceFile. @@ -42699,6 +43020,33 @@ var ts; } return node; } + /** + * Specialized visitor that visits the immediate children of a SourceFile. + * + * @param node The node to visit. + */ + function sourceElementVisitor(node) { + return saveStateAndInvoke(node, sourceElementVisitorWorker); + } + /** + * Specialized visitor that visits the immediate children of a SourceFile. + * + * @param node The node to visit. + */ + function sourceElementVisitorWorker(node) { + switch (node.kind) { + case 231 /* ImportDeclaration */: + return visitImportDeclaration(node); + case 230 /* ImportEqualsDeclaration */: + return visitImportEqualsDeclaration(node); + case 236 /* ExportAssignment */: + return visitExportAssignment(node); + case 237 /* ExportDeclaration */: + return visitExportDeclaration(node); + default: + return visitorWorker(node); + } + } /** * Specialized visitor that visits the immediate children of a namespace. * @@ -42713,11 +43061,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 236 /* ExportDeclaration */ || - node.kind === 230 /* ImportDeclaration */ || - node.kind === 231 /* ImportClause */ || - (node.kind === 229 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 240 /* ExternalModuleReference */)) { + if (node.kind === 237 /* ExportDeclaration */ || + node.kind === 231 /* ImportDeclaration */ || + node.kind === 232 /* ImportClause */ || + (node.kind === 230 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 241 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -42747,19 +43095,19 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 148 /* Constructor */: + case 149 /* Constructor */: // TypeScript constructors are transformed in `visitClassDeclaration`. // We elide them here as `visitorWorker` checks transform flags, which could // erronously include an ES6 constructor without TypeScript syntax. return undefined; - case 145 /* PropertyDeclaration */: - case 153 /* IndexSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 147 /* MethodDeclaration */: + case 146 /* PropertyDeclaration */: + case 154 /* IndexSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 148 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 198 /* SemicolonClassElement */: + case 199 /* SemicolonClassElement */: return node; default: ts.Debug.failBadSyntaxKind(node); @@ -42778,57 +43126,55 @@ var ts; return ts.createNotEmittedStatement(node); } switch (node.kind) { - case 82 /* ExportKeyword */: - case 77 /* DefaultKeyword */: + case 83 /* ExportKeyword */: + case 78 /* DefaultKeyword */: // ES6 export and default modifiers are elided when inside a namespace. return currentNamespace ? undefined : node; - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - case 115 /* AbstractKeyword */: - case 118 /* AsyncKeyword */: - case 74 /* ConstKeyword */: - case 122 /* DeclareKeyword */: - case 128 /* ReadonlyKeyword */: + case 113 /* PublicKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + case 116 /* AbstractKeyword */: + case 75 /* ConstKeyword */: + case 123 /* DeclareKeyword */: + case 129 /* ReadonlyKeyword */: // TypeScript accessibility and readonly modifiers are elided. - case 160 /* ArrayType */: - case 161 /* TupleType */: - case 159 /* TypeLiteral */: - case 154 /* TypePredicate */: - case 141 /* TypeParameter */: - case 117 /* AnyKeyword */: - case 120 /* BooleanKeyword */: - case 132 /* StringKeyword */: - case 130 /* NumberKeyword */: - case 127 /* NeverKeyword */: - case 103 /* VoidKeyword */: - case 133 /* SymbolKeyword */: - case 157 /* ConstructorType */: - case 156 /* FunctionType */: - case 158 /* TypeQuery */: - case 155 /* TypeReference */: - case 162 /* UnionType */: - case 163 /* IntersectionType */: - case 164 /* ParenthesizedType */: - case 165 /* ThisType */: - case 166 /* LiteralType */: + case 161 /* ArrayType */: + case 162 /* TupleType */: + case 160 /* TypeLiteral */: + case 155 /* TypePredicate */: + case 142 /* TypeParameter */: + case 118 /* AnyKeyword */: + case 121 /* BooleanKeyword */: + case 133 /* StringKeyword */: + case 131 /* NumberKeyword */: + case 128 /* NeverKeyword */: + case 104 /* VoidKeyword */: + case 134 /* SymbolKeyword */: + case 158 /* ConstructorType */: + case 157 /* FunctionType */: + case 159 /* TypeQuery */: + case 156 /* TypeReference */: + case 163 /* UnionType */: + case 164 /* IntersectionType */: + case 165 /* ParenthesizedType */: + case 166 /* ThisType */: + case 167 /* LiteralType */: // TypeScript type nodes are elided. - case 153 /* IndexSignature */: + case 154 /* IndexSignature */: // TypeScript index signatures are elided. - case 143 /* Decorator */: + case 144 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 223 /* TypeAliasDeclaration */: + case 224 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: // TypeScript property declarations are elided. - case 148 /* Constructor */: - // TypeScript constructors are transformed in `visitClassDeclaration`. - return undefined; - case 222 /* InterfaceDeclaration */: + case 149 /* Constructor */: + return visitConstructor(node); + case 223 /* InterfaceDeclaration */: // TypeScript interfaces are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return ts.createNotEmittedStatement(node); - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: // This is a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -42838,9 +43184,8 @@ var ts; // - property declarations // - index signatures // - method overload signatures - // - async methods return visitClassDeclaration(node); - case 192 /* ClassExpression */: + case 193 /* ClassExpression */: // This is a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -42850,7 +43195,6 @@ var ts; // - property declarations // - index signatures // - method overload signatures - // - async methods return visitClassExpression(node); case 251 /* HeritageClause */: // This is a heritage clause with TypeScript syntax extensions. @@ -42858,29 +43202,29 @@ var ts; // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 147 /* MethodDeclaration */: - // TypeScript method declarations may be 'async', and may have decorators, modifiers + case 148 /* MethodDeclaration */: + // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 149 /* GetAccessor */: + case 150 /* GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 150 /* SetAccessor */: - // Set Accessors can have TypeScript modifiers, decorators, and type annotations. + case 151 /* SetAccessor */: + // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 220 /* FunctionDeclaration */: - // TypeScript function declarations may be 'async' + case 221 /* FunctionDeclaration */: + // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 179 /* FunctionExpression */: - // TypeScript function expressions may be 'async' + case 180 /* FunctionExpression */: + // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 180 /* ArrowFunction */: - // TypeScript arrow functions may be 'async' + case 181 /* ArrowFunction */: + // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 142 /* Parameter */: + case 143 /* Parameter */: // This is a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -42890,30 +43234,33 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 177 /* TypeAssertionExpression */: - case 195 /* AsExpression */: + case 178 /* TypeAssertionExpression */: + case 196 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 196 /* NonNullExpression */: + case 175 /* CallExpression */: + return visitCallExpression(node); + case 176 /* NewExpression */: + return visitNewExpression(node); + case 197 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 184 /* AwaitExpression */: - // TypeScript 'await' expressions must be transformed. - return visitAwaitExpression(node); - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 225 /* ModuleDeclaration */: + case 219 /* VariableDeclaration */: + return visitVariableDeclaration(node); + case 226 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 229 /* ImportEqualsDeclaration */: + case 230 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -42929,14 +43276,14 @@ var ts; function onBeforeVisitNode(node) { switch (node.kind) { case 256 /* SourceFile */: - case 227 /* CaseBlock */: - case 226 /* ModuleBlock */: - case 199 /* Block */: + case 228 /* CaseBlock */: + case 227 /* ModuleBlock */: + case 200 /* Block */: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; - case 221 /* ClassDeclaration */: - case 220 /* FunctionDeclaration */: + case 222 /* ClassDeclaration */: + case 221 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -42967,14 +43314,14 @@ var ts; externalHelpersModuleImport.flags &= ~8 /* Synthesized */; statements.push(externalHelpersModuleImport); currentSourceFileExternalHelpersModuleName = externalHelpersModuleName; - ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); + ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); currentSourceFileExternalHelpersModuleName = undefined; node = ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); node.externalHelpersModuleName = externalHelpersModuleName; } else { - node = ts.visitEachChild(node, visitor, context); + node = ts.visitEachChild(node, sourceElementVisitor, context); } ts.setEmitFlags(node, 1 /* EmitEmitHelpers */ | ts.getEmitFlags(node)); return node; @@ -43048,7 +43395,7 @@ var ts; // HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using // a lexical declaration such as a LexicalDeclaration or a ClassDeclaration. if (staticProperties.length) { - addInitializedPropertyStatements(statements, node, staticProperties, getLocalName(node, /*noSourceMaps*/ true)); + addInitializedPropertyStatements(statements, staticProperties, getLocalName(node, /*noSourceMaps*/ true)); } // Write any decorators of the node. addClassElementDecorationStatements(statements, node, /*isStatic*/ false); @@ -43224,7 +43571,7 @@ var ts; function visitClassExpression(node) { var staticProperties = getInitializedProperties(node, /*isStatic*/ true); var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); - var members = transformClassMembers(node, heritageClauses !== undefined); + var members = transformClassMembers(node, ts.some(heritageClauses, function (c) { return c.token === 84 /* ExtendsKeyword */; })); var classExpression = ts.setOriginalNode(ts.createClassExpression( /*modifiers*/ undefined, node.name, /*typeParameters*/ undefined, heritageClauses, members, @@ -43241,7 +43588,7 @@ var ts; // the body of a class with static initializers. ts.setEmitFlags(classExpression, 524288 /* Indented */ | ts.getEmitFlags(classExpression)); expressions.push(ts.startOnNewLine(ts.createAssignment(temp, classExpression))); - ts.addRange(expressions, generateInitializedPropertyExpressions(node, staticProperties, temp)); + ts.addRange(expressions, generateInitializedPropertyExpressions(staticProperties, temp)); expressions.push(ts.startOnNewLine(temp)); return ts.inlineExpressions(expressions); } @@ -43273,7 +43620,7 @@ var ts; // If there is a property assignment, we need to emit constructor whether users define it or not // If there is no property assignment, we can omit constructor if users do not define it var hasInstancePropertyWithInitializer = ts.forEach(node.members, isInstanceInitializedProperty); - var hasParameterPropertyAssignments = node.transformFlags & 131072 /* ContainsParameterPropertyAssignments */; + var hasParameterPropertyAssignments = node.transformFlags & 524288 /* ContainsParameterPropertyAssignments */; var constructor = ts.getFirstConstructorWithBody(node); // If the class does not contain nodes that require a synthesized constructor, // accept the current constructor if it exists. @@ -43281,7 +43628,7 @@ var ts; return ts.visitEachChild(constructor, visitor, context); } var parameters = transformConstructorParameters(constructor); - var body = transformConstructorBody(node, constructor, hasExtendsClause, parameters); + var body = transformConstructorBody(node, constructor, hasExtendsClause); // constructor(${parameters}) { // ${body} // } @@ -43324,9 +43671,8 @@ var ts; * @param node The current class. * @param constructor The current class constructor. * @param hasExtendsClause A value indicating whether the class has an extends clause. - * @param parameters The transformed parameters for the constructor. */ - function transformConstructorBody(node, constructor, hasExtendsClause, parameters) { + function transformConstructorBody(node, constructor, hasExtendsClause) { var statements = []; var indexOfFirstStatement = 0; // The body of a constructor is a new lexical environment @@ -43367,7 +43713,7 @@ var ts; // } // var properties = getInitializedProperties(node, /*isStatic*/ false); - addInitializedPropertyStatements(statements, node, properties, ts.createThis()); + addInitializedPropertyStatements(statements, properties, ts.createThis()); if (constructor) { // The class already had a constructor, so we should add the existing statements, skipping the initial super call. ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement)); @@ -43394,7 +43740,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 202 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 203 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -43467,21 +43813,20 @@ var ts; * @param isStatic A value indicating whether the member should be a static or instance member. */ function isInitializedProperty(member, isStatic) { - return member.kind === 145 /* PropertyDeclaration */ + return member.kind === 146 /* PropertyDeclaration */ && isStatic === ts.hasModifier(member, 32 /* Static */) && member.initializer !== undefined; } /** * Generates assignment statements for property initializers. * - * @param node The class node. * @param properties An array of property declarations to transform. * @param receiver The receiver on which each property should be assigned. */ - function addInitializedPropertyStatements(statements, node, properties, receiver) { + function addInitializedPropertyStatements(statements, properties, receiver) { for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) { var property = properties_7[_i]; - var statement = ts.createStatement(transformInitializedProperty(node, property, receiver)); + var statement = ts.createStatement(transformInitializedProperty(property, receiver)); ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property)); ts.setCommentRange(statement, property); statements.push(statement); @@ -43490,15 +43835,14 @@ var ts; /** * Generates assignment expressions for property initializers. * - * @param node The class node. * @param properties An array of property declarations to transform. * @param receiver The receiver on which each property should be assigned. */ - function generateInitializedPropertyExpressions(node, properties, receiver) { + function generateInitializedPropertyExpressions(properties, receiver) { var expressions = []; for (var _i = 0, properties_8 = properties; _i < properties_8.length; _i++) { var property = properties_8[_i]; - var expression = transformInitializedProperty(node, property, receiver); + var expression = transformInitializedProperty(property, receiver); expression.startsOnNewLine = true; ts.setSourceMapRange(expression, ts.moveRangePastModifiers(property)); ts.setCommentRange(expression, property); @@ -43509,11 +43853,10 @@ var ts; /** * Transforms a property initializer into an assignment statement. * - * @param node The class containing the property. * @param property The property declaration. * @param receiver The object receiving the property assignment. */ - function transformInitializedProperty(node, property, receiver) { + function transformInitializedProperty(property, receiver) { var propertyName = visitPropertyNameOfClassElement(property); var initializer = ts.visitNode(property.initializer, visitor, ts.isExpression); var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, /*location*/ propertyName); @@ -43605,12 +43948,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 147 /* MethodDeclaration */: + case 148 /* MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -43762,7 +44105,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ true); var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 145 /* PropertyDeclaration */ + ? member.kind === 146 /* PropertyDeclaration */ ? ts.createVoidZero() : ts.createNull() : undefined; @@ -43895,10 +44238,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 147 /* MethodDeclaration */ - || kind === 149 /* GetAccessor */ - || kind === 150 /* SetAccessor */ - || kind === 145 /* PropertyDeclaration */; + return kind === 148 /* MethodDeclaration */ + || kind === 150 /* GetAccessor */ + || kind === 151 /* SetAccessor */ + || kind === 146 /* PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -43908,7 +44251,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 147 /* MethodDeclaration */; + return node.kind === 148 /* MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -43919,11 +44262,11 @@ var ts; */ function shouldAddParamTypesMetadata(node) { var kind = node.kind; - return kind === 221 /* ClassDeclaration */ - || kind === 192 /* ClassExpression */ - || kind === 147 /* MethodDeclaration */ - || kind === 149 /* GetAccessor */ - || kind === 150 /* SetAccessor */; + return kind === 222 /* ClassDeclaration */ + || kind === 193 /* ClassExpression */ + || kind === 148 /* MethodDeclaration */ + || kind === 150 /* GetAccessor */ + || kind === 151 /* SetAccessor */; } /** * Serializes the type of a node for use with decorator type metadata. @@ -43932,15 +44275,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 145 /* PropertyDeclaration */: - case 142 /* Parameter */: - case 149 /* GetAccessor */: + case 146 /* PropertyDeclaration */: + case 143 /* Parameter */: + case 150 /* GetAccessor */: return serializeTypeNode(node.type); - case 150 /* SetAccessor */: + case 151 /* SetAccessor */: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - case 147 /* MethodDeclaration */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 148 /* MethodDeclaration */: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -43953,10 +44296,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 160 /* ArrayType */) { + if (node && node.kind === 161 /* ArrayType */) { return node.elementType; } - else if (node && node.kind === 155 /* TypeReference */) { + else if (node && node.kind === 156 /* TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -44030,45 +44373,45 @@ var ts; return ts.createIdentifier("Object"); } switch (node.kind) { - case 103 /* VoidKeyword */: + case 104 /* VoidKeyword */: return ts.createVoidZero(); - case 164 /* ParenthesizedType */: + case 165 /* ParenthesizedType */: return serializeTypeNode(node.type); - case 156 /* FunctionType */: - case 157 /* ConstructorType */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: return ts.createIdentifier("Function"); - case 160 /* ArrayType */: - case 161 /* TupleType */: + case 161 /* ArrayType */: + case 162 /* TupleType */: return ts.createIdentifier("Array"); - case 154 /* TypePredicate */: - case 120 /* BooleanKeyword */: + case 155 /* TypePredicate */: + case 121 /* BooleanKeyword */: return ts.createIdentifier("Boolean"); - case 132 /* StringKeyword */: + case 133 /* StringKeyword */: return ts.createIdentifier("String"); - case 166 /* LiteralType */: + case 167 /* LiteralType */: switch (node.literal.kind) { case 9 /* StringLiteral */: return ts.createIdentifier("String"); case 8 /* NumericLiteral */: return ts.createIdentifier("Number"); - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: + case 100 /* TrueKeyword */: + case 85 /* FalseKeyword */: return ts.createIdentifier("Boolean"); default: ts.Debug.failBadSyntaxKind(node.literal); break; } break; - case 130 /* NumberKeyword */: + case 131 /* NumberKeyword */: return ts.createIdentifier("Number"); - case 133 /* SymbolKeyword */: - return languageVersion < 2 /* ES6 */ + case 134 /* SymbolKeyword */: + return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 155 /* TypeReference */: + case 156 /* TypeReference */: return serializeTypeReferenceNode(node); - case 163 /* IntersectionType */: - case 162 /* UnionType */: + case 164 /* IntersectionType */: + case 163 /* UnionType */: { var unionOrIntersection = node; var serializedUnion = void 0; @@ -44076,7 +44419,7 @@ var ts; var typeNode = _a[_i]; var serializedIndividual = serializeTypeNode(typeNode); // Non identifier - if (serializedIndividual.kind !== 69 /* Identifier */) { + if (serializedIndividual.kind !== 70 /* Identifier */) { serializedUnion = undefined; break; } @@ -44097,10 +44440,10 @@ var ts; } } // Fallthrough - case 158 /* TypeQuery */: - case 159 /* TypeLiteral */: - case 117 /* AnyKeyword */: - case 165 /* ThisType */: + case 159 /* TypeQuery */: + case 160 /* TypeLiteral */: + case 118 /* AnyKeyword */: + case 166 /* ThisType */: break; default: ts.Debug.failBadSyntaxKind(node); @@ -44133,7 +44476,7 @@ var ts; case ts.TypeReferenceSerializationKind.ArrayLikeType: return ts.createIdentifier("Array"); case ts.TypeReferenceSerializationKind.ESSymbolType: - return languageVersion < 2 /* ES6 */ + return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); case ts.TypeReferenceSerializationKind.TypeWithCallSignature: @@ -44154,7 +44497,7 @@ var ts; */ function serializeEntityNameAsExpression(node, useFallback) { switch (node.kind) { - case 69 /* Identifier */: + case 70 /* Identifier */: // Create a clone of the name with a new parent, and treat it as if it were // a source tree node for the purposes of the checker. var name_27 = ts.getMutableClone(node); @@ -44165,7 +44508,7 @@ var ts; return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_27), ts.createLiteral("undefined")), name_27); } return name_27; - case 139 /* QualifiedName */: + case 140 /* QualifiedName */: return serializeQualifiedNameAsExpression(node, useFallback); } } @@ -44178,7 +44521,7 @@ var ts; */ function serializeQualifiedNameAsExpression(node, useFallback) { var left; - if (node.left.kind === 69 /* Identifier */) { + if (node.left.kind === 70 /* Identifier */) { left = serializeEntityNameAsExpression(node.left, useFallback); } else if (useFallback) { @@ -44195,7 +44538,7 @@ var ts; * available. */ function getGlobalSymbolNameWithFallback() { - return ts.createConditional(ts.createStrictEquality(ts.createTypeOf(ts.createIdentifier("Symbol")), ts.createLiteral("function")), ts.createToken(53 /* QuestionToken */), ts.createIdentifier("Symbol"), ts.createToken(54 /* ColonToken */), ts.createIdentifier("Object")); + return ts.createConditional(ts.createStrictEquality(ts.createTypeOf(ts.createIdentifier("Symbol")), ts.createLiteral("function")), ts.createToken(54 /* QuestionToken */), ts.createIdentifier("Symbol"), ts.createToken(55 /* ColonToken */), ts.createIdentifier("Object")); } /** * Gets an expression that represents a property name. For a computed property, a @@ -44249,9 +44592,9 @@ var ts; * @param node The HeritageClause to transform. */ function visitHeritageClause(node) { - if (node.token === 83 /* ExtendsKeyword */) { + if (node.token === 84 /* ExtendsKeyword */) { var types = ts.visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments, 0, 1); - return ts.createHeritageClause(83 /* ExtendsKeyword */, types, node); + return ts.createHeritageClause(84 /* ExtendsKeyword */, types, node); } return undefined; } @@ -44277,12 +44620,18 @@ var ts; function shouldEmitFunctionLikeDeclaration(node) { return !ts.nodeIsMissing(node.body); } + function visitConstructor(node) { + if (!shouldEmitFunctionLikeDeclaration(node)) { + return undefined; + } + return ts.visitEachChild(node, visitor, context); + } /** * Visits a method declaration of a class. * * This function will be called when one of the following conditions are met: * - The node is an overload - * - The node is marked as abstract, async, public, private, protected, or readonly + * - The node is marked as abstract, public, private, protected, or readonly * - The node has both a decorator and a computed property name * * @param node The method node. @@ -44364,8 +44713,8 @@ var ts; * * This function will be called when one of the following conditions are met: * - The node is an overload - * - The node is marked async * - The node is exported from a TypeScript namespace + * - The node has decorators * * @param node The function node. */ @@ -44390,7 +44739,7 @@ var ts; * Visits a function expression node. * * This function will be called when one of the following conditions are met: - * - The node is marked async + * - The node has type annotations * * @param node The function expression node. */ @@ -44398,7 +44747,7 @@ var ts; if (ts.nodeIsMissing(node.body)) { return ts.createOmittedExpression(); } - var func = ts.createFunctionExpression(node.asteriskToken, node.name, + var func = ts.createFunctionExpression(ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), /*type*/ undefined, transformFunctionBody(node), /*location*/ node); @@ -44408,11 +44757,10 @@ var ts; /** * @remarks * This function will be called when one of the following conditions are met: - * - The node is marked async + * - The node has type annotations */ function visitArrowFunction(node) { - var func = ts.createArrowFunction( - /*modifiers*/ undefined, + var func = ts.createArrowFunction(ts.visitNodes(node.modifiers, visitor, ts.isModifier), /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), /*type*/ undefined, node.equalsGreaterThanToken, transformConciseBody(node), /*location*/ node); @@ -44420,26 +44768,23 @@ var ts; return func; } function transformFunctionBody(node) { - if (ts.isAsyncFunctionLike(node)) { - return transformAsyncFunctionBody(node); - } return transformFunctionBodyWorker(node.body); } function transformFunctionBodyWorker(body, start) { if (start === void 0) { start = 0; } var savedCurrentScope = currentScope; + var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName; currentScope = body; + currentScopeFirstDeclarationsOfName = ts.createMap(); startLexicalEnvironment(); var statements = ts.visitNodes(body.statements, visitor, ts.isStatement, start); var visited = ts.updateBlock(body, statements); var declarations = endLexicalEnvironment(); currentScope = savedCurrentScope; + currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; return ts.mergeFunctionBodyLexicalEnvironment(visited, declarations); } function transformConciseBody(node) { - if (ts.isAsyncFunctionLike(node)) { - return transformAsyncFunctionBody(node); - } return transformConciseBodyWorker(node.body, /*forceBlockFunctionBody*/ false); } function transformConciseBodyWorker(body, forceBlockFunctionBody) { @@ -44461,49 +44806,6 @@ var ts; } } } - function getPromiseConstructor(type) { - var typeName = ts.getEntityNameFromTypeNode(type); - if (typeName && ts.isEntityName(typeName)) { - var serializationKind = resolver.getTypeReferenceSerializationKind(typeName); - if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue - || serializationKind === ts.TypeReferenceSerializationKind.Unknown) { - return typeName; - } - } - return undefined; - } - function transformAsyncFunctionBody(node) { - var promiseConstructor = languageVersion < 2 /* ES6 */ ? getPromiseConstructor(node.type) : undefined; - var isArrowFunction = node.kind === 180 /* ArrowFunction */; - var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* CaptureArguments */) !== 0; - // An async function is emit as an outer function that calls an inner - // generator function. To preserve lexical bindings, we pass the current - // `this` and `arguments` objects to `__awaiter`. The generator function - // passed to `__awaiter` is executed inside of the callback to the - // promise constructor. - if (!isArrowFunction) { - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.body.statements, /*ensureUseStrict*/ false, visitor); - statements.push(ts.createReturn(ts.createAwaiterHelper(currentSourceFileExternalHelpersModuleName, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body, statementOffset)))); - var block = ts.createBlock(statements, /*location*/ node.body, /*multiLine*/ true); - // Minor optimization, emit `_super` helper to capture `super` access in an arrow. - // This step isn't needed if we eventually transform this to ES5. - if (languageVersion >= 2 /* ES6 */) { - if (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) { - enableSubstitutionForAsyncMethodsWithSuper(); - ts.setEmitFlags(block, 8 /* EmitAdvancedSuperHelper */); - } - else if (resolver.getNodeCheckFlags(node) & 2048 /* AsyncMethodWithSuper */) { - enableSubstitutionForAsyncMethodsWithSuper(); - ts.setEmitFlags(block, 4 /* EmitSuperHelper */); - } - } - return block; - } - else { - return ts.createAwaiterHelper(currentSourceFileExternalHelpersModuleName, hasLexicalArguments, promiseConstructor, transformConciseBodyWorker(node.body, /*forceBlockFunctionBody*/ true)); - } - } /** * Visits a parameter declaration node. * @@ -44555,24 +44857,16 @@ var ts; function transformInitializedVariable(node) { var name = node.name; if (ts.isBindingPattern(name)) { - return ts.flattenVariableDestructuringToExpression(context, node, hoistVariableDeclaration, getNamespaceMemberNameWithSourceMapsAndWithoutComments, visitor); + return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, getNamespaceMemberNameWithSourceMapsAndWithoutComments, visitor); } else { return ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(name), ts.visitNode(node.initializer, visitor, ts.isExpression), /*location*/ node); } } - /** - * Visits an await expression. - * - * This function will be called any time a TypeScript await expression is encountered. - * - * @param node The await expression node. - */ - function visitAwaitExpression(node) { - return ts.setOriginalNode(ts.createYield( - /*asteriskToken*/ undefined, ts.visitNode(node.expression, visitor, ts.isExpression), - /*location*/ node), node); + function visitVariableDeclaration(node) { + return ts.updateVariableDeclaration(node, ts.visitNode(node.name, visitor, ts.isBindingName), + /*type*/ undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)); } /** * Visits a parenthesized expression that contains either a type assertion or an `as` @@ -44611,6 +44905,14 @@ var ts; var expression = ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression); return ts.createPartiallyEmittedExpression(expression, node); } + function visitCallExpression(node) { + return ts.updateCall(node, ts.visitNode(node.expression, visitor, ts.isExpression), + /*typeArguments*/ undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression)); + } + function visitNewExpression(node) { + return ts.updateNew(node, ts.visitNode(node.expression, visitor, ts.isExpression), + /*typeArguments*/ undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression)); + } /** * Determines whether to emit an enum declaration. * @@ -44673,6 +44975,7 @@ var ts; // ... // })(x || (x = {})); var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression( + /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, [ts.createParameter(parameterName)], @@ -44748,7 +45051,7 @@ var ts; } function isES6ExportedDeclaration(node) { return isExternalModuleExport(node) - && moduleKind === ts.ModuleKind.ES6; + && moduleKind === ts.ModuleKind.ES2015; } /** * Records that a declaration was emitted in the current scope, if it was the first @@ -44796,7 +45099,7 @@ var ts; ]); ts.setOriginalNode(statement, /*original*/ node); // Adjust the source map emit to match the old emitter. - if (node.kind === 224 /* EnumDeclaration */) { + if (node.kind === 225 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -44871,6 +45174,7 @@ var ts; // x_1.y = ...; // })(x || (x = {})); var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression( + /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, [ts.createParameter(parameterName)], @@ -44899,7 +45203,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 226 /* ModuleBlock */) { + if (body.kind === 227 /* ModuleBlock */) { ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); statementsLocation = body.statements; blockLocation = body; @@ -44945,17 +45249,127 @@ var ts; // })(hi = hello.hi || (hello.hi = {})); // })(hello || (hello = {})); // We only want to emit comment on the namespace which contains block body itself, not the containing namespaces. - if (body.kind !== 226 /* ModuleBlock */) { + if (body.kind !== 227 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 49152 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 225 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 226 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } } + /** + * Visits an import declaration, eliding it if it is not referenced. + * + * @param node The import declaration node. + */ + function visitImportDeclaration(node) { + if (!node.importClause) { + // Do not elide a side-effect only import declaration. + // import "foo"; + return node; + } + // Elide the declaration if the import clause was elided. + var importClause = ts.visitNode(node.importClause, visitImportClause, ts.isImportClause, /*optional*/ true); + return importClause + ? ts.updateImportDeclaration(node, + /*decorators*/ undefined, + /*modifiers*/ undefined, importClause, node.moduleSpecifier) + : undefined; + } + /** + * Visits an import clause, eliding it if it is not referenced. + * + * @param node The import clause node. + */ + function visitImportClause(node) { + // Elide the import clause if we elide both its name and its named bindings. + var name = resolver.isReferencedAliasDeclaration(node) ? node.name : undefined; + var namedBindings = ts.visitNode(node.namedBindings, visitNamedImportBindings, ts.isNamedImportBindings, /*optional*/ true); + return (name || namedBindings) ? ts.updateImportClause(node, name, namedBindings) : undefined; + } + /** + * Visits named import bindings, eliding it if it is not referenced. + * + * @param node The named import bindings node. + */ + function visitNamedImportBindings(node) { + if (node.kind === 233 /* NamespaceImport */) { + // Elide a namespace import if it is not referenced. + return resolver.isReferencedAliasDeclaration(node) ? node : undefined; + } + else { + // Elide named imports if all of its import specifiers are elided. + var elements = ts.visitNodes(node.elements, visitImportSpecifier, ts.isImportSpecifier); + return ts.some(elements) ? ts.updateNamedImports(node, elements) : undefined; + } + } + /** + * Visits an import specifier, eliding it if it is not referenced. + * + * @param node The import specifier node. + */ + function visitImportSpecifier(node) { + // Elide an import specifier if it is not referenced. + return resolver.isReferencedAliasDeclaration(node) ? node : undefined; + } + /** + * Visits an export assignment, eliding it if it does not contain a clause that resolves + * to a value. + * + * @param node The export assignment node. + */ + function visitExportAssignment(node) { + // Elide the export assignment if it does not reference a value. + return resolver.isValueAliasDeclaration(node) + ? ts.visitEachChild(node, visitor, context) + : undefined; + } + /** + * Visits an export declaration, eliding it if it does not contain a clause that resolves + * to a value. + * + * @param node The export declaration node. + */ + function visitExportDeclaration(node) { + if (!node.exportClause) { + // Elide a star export if the module it references does not export a value. + return resolver.moduleExportsSomeValue(node.moduleSpecifier) ? node : undefined; + } + if (!resolver.isValueAliasDeclaration(node)) { + // Elide the export declaration if it does not export a value. + return undefined; + } + // Elide the export declaration if all of its named exports are elided. + var exportClause = ts.visitNode(node.exportClause, visitNamedExports, ts.isNamedExports, /*optional*/ true); + return exportClause + ? ts.updateExportDeclaration(node, + /*decorators*/ undefined, + /*modifiers*/ undefined, exportClause, node.moduleSpecifier) + : undefined; + } + /** + * Visits named exports, eliding it if it does not contain an export specifier that + * resolves to a value. + * + * @param node The named exports node. + */ + function visitNamedExports(node) { + // Elide the named exports if all of its export specifiers were elided. + var elements = ts.visitNodes(node.elements, visitExportSpecifier, ts.isExportSpecifier); + return ts.some(elements) ? ts.updateNamedExports(node, elements) : undefined; + } + /** + * Visits an export specifier, eliding it if it does not resolve to a value. + * + * @param node The export specifier node. + */ + function visitExportSpecifier(node) { + // Elide an export specifier if it does not reference a value. + return resolver.isValueAliasDeclaration(node) ? node : undefined; + } /** * Determines whether to emit an import equals declaration. * @@ -44976,7 +45390,10 @@ var ts; */ function visitImportEqualsDeclaration(node) { if (ts.isExternalModuleImportEqualsDeclaration(node)) { - return ts.visitEachChild(node, visitor, context); + // Elide external module `import=` if it is not referenced. + return resolver.isReferencedAliasDeclaration(node) + ? ts.visitEachChild(node, visitor, context) + : undefined; } if (!shouldEmitImportEqualsDeclaration(node)) { return undefined; @@ -45152,23 +45569,7 @@ var ts; function enableSubstitutionForNonQualifiedEnumMembers() { if ((enabledSubstitutions & 8 /* NonQualifiedEnumMembers */) === 0) { enabledSubstitutions |= 8 /* NonQualifiedEnumMembers */; - context.enableSubstitution(69 /* Identifier */); - } - } - function enableSubstitutionForAsyncMethodsWithSuper() { - if ((enabledSubstitutions & 4 /* AsyncMethodsWithSuper */) === 0) { - enabledSubstitutions |= 4 /* AsyncMethodsWithSuper */; - // We need to enable substitutions for call, property access, and element access - // if we need to rewrite super calls. - context.enableSubstitution(174 /* CallExpression */); - context.enableSubstitution(172 /* PropertyAccessExpression */); - context.enableSubstitution(173 /* ElementAccessExpression */); - // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(221 /* ClassDeclaration */); - context.enableEmitNotification(147 /* MethodDeclaration */); - context.enableEmitNotification(149 /* GetAccessor */); - context.enableEmitNotification(150 /* SetAccessor */); - context.enableEmitNotification(148 /* Constructor */); + context.enableSubstitution(70 /* Identifier */); } } function enableSubstitutionForClassAliases() { @@ -45176,7 +45577,7 @@ var ts; enabledSubstitutions |= 1 /* ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(69 /* Identifier */); + context.enableSubstitution(70 /* Identifier */); // Keep track of class aliases. classAliases = ts.createMap(); } @@ -45186,25 +45587,17 @@ var ts; enabledSubstitutions |= 2 /* NamespaceExports */; // We need to enable substitutions for identifiers and shorthand property assignments. This allows us to // substitute the names of exported members of a namespace. - context.enableSubstitution(69 /* Identifier */); + context.enableSubstitution(70 /* Identifier */); context.enableSubstitution(254 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(225 /* ModuleDeclaration */); + context.enableEmitNotification(226 /* ModuleDeclaration */); } } - function isSuperContainer(node) { - var kind = node.kind; - return kind === 221 /* ClassDeclaration */ - || kind === 148 /* Constructor */ - || kind === 147 /* MethodDeclaration */ - || kind === 149 /* GetAccessor */ - || kind === 150 /* SetAccessor */; - } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 225 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 226 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 224 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 225 /* EnumDeclaration */; } /** * Hook for node emit. @@ -45214,12 +45607,6 @@ var ts; */ function onEmitNode(emitContext, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; - var savedCurrentSuperContainer = currentSuperContainer; - // If we need to support substitutions for `super` in an async method, - // we should track it here. - if (enabledSubstitutions & 4 /* AsyncMethodsWithSuper */ && isSuperContainer(node)) { - currentSuperContainer = node; - } if (enabledSubstitutions & 2 /* NamespaceExports */ && isTransformedModuleDeclaration(node)) { applicableSubstitutions |= 2 /* NamespaceExports */; } @@ -45228,7 +45615,6 @@ var ts; } previousOnEmitNode(emitContext, node, emitCallback); applicableSubstitutions = savedApplicableSubstitutions; - currentSuperContainer = savedCurrentSuperContainer; } /** * Hooks node substitutions. @@ -45265,17 +45651,12 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 69 /* Identifier */: + case 70 /* Identifier */: return substituteExpressionIdentifier(node); - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 173 /* ElementAccessExpression */: + case 174 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 174 /* CallExpression */: - if (enabledSubstitutions & 4 /* AsyncMethodsWithSuper */) { - return substituteCallExpression(node); - } - break; } return node; } @@ -45313,8 +45694,8 @@ var ts; // an identifier that is exported from a merged namespace. var container = resolver.getReferencedExportContainer(node, /*prefixLocals*/ false); if (container) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 225 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 224 /* EnumDeclaration */); + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 226 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 225 /* EnumDeclaration */); if (substitute) { return ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node, /*location*/ node); } @@ -45322,38 +45703,10 @@ var ts; } return undefined; } - function substituteCallExpression(node) { - var expression = node.expression; - if (ts.isSuperProperty(expression)) { - var flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - var argumentExpression = ts.isPropertyAccessExpression(expression) - ? substitutePropertyAccessExpression(expression) - : substituteElementAccessExpression(expression); - return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), - /*typeArguments*/ undefined, [ - ts.createThis() - ].concat(node.arguments)); - } - } - return node; - } function substitutePropertyAccessExpression(node) { - if (enabledSubstitutions & 4 /* AsyncMethodsWithSuper */ && node.expression.kind === 95 /* SuperKeyword */) { - var flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - return createSuperAccessInAsyncMethod(ts.createLiteral(node.name.text), flags, node); - } - } return substituteConstantValue(node); } function substituteElementAccessExpression(node) { - if (enabledSubstitutions & 4 /* AsyncMethodsWithSuper */ && node.expression.kind === 95 /* SuperKeyword */) { - var flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - return createSuperAccessInAsyncMethod(node.argumentExpression, flags, node); - } - } return substituteConstantValue(node); } function substituteConstantValue(node) { @@ -45381,2042 +45734,9 @@ var ts; ? resolver.getConstantValue(node) : undefined; } - function createSuperAccessInAsyncMethod(argumentExpression, flags, location) { - if (flags & 4096 /* AsyncMethodWithSuperBinding */) { - return ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), - /*typeArguments*/ undefined, [argumentExpression]), "value", location); - } - else { - return ts.createCall(ts.createIdentifier("_super"), - /*typeArguments*/ undefined, [argumentExpression], location); - } - } - function getSuperContainerAsyncMethodFlags() { - return currentSuperContainer !== undefined - && resolver.getNodeCheckFlags(currentSuperContainer) & (2048 /* AsyncMethodWithSuper */ | 4096 /* AsyncMethodWithSuperBinding */); - } } ts.transformTypeScript = transformTypeScript; })(ts || (ts = {})); -/// -/// -/*@internal*/ -var ts; -(function (ts) { - function transformES6Module(context) { - var compilerOptions = context.getCompilerOptions(); - var resolver = context.getEmitResolver(); - var currentSourceFile; - return transformSourceFile; - function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { - return node; - } - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - currentSourceFile = node; - return ts.visitEachChild(node, visitor, context); - } - return node; - } - function visitor(node) { - switch (node.kind) { - case 230 /* ImportDeclaration */: - return visitImportDeclaration(node); - case 229 /* ImportEqualsDeclaration */: - return visitImportEqualsDeclaration(node); - case 231 /* ImportClause */: - return visitImportClause(node); - case 233 /* NamedImports */: - case 232 /* NamespaceImport */: - return visitNamedBindings(node); - case 234 /* ImportSpecifier */: - return visitImportSpecifier(node); - case 235 /* ExportAssignment */: - return visitExportAssignment(node); - case 236 /* ExportDeclaration */: - return visitExportDeclaration(node); - case 237 /* NamedExports */: - return visitNamedExports(node); - case 238 /* ExportSpecifier */: - return visitExportSpecifier(node); - } - return node; - } - function visitExportAssignment(node) { - if (node.isExportEquals) { - return undefined; // do not emit export equals for ES6 - } - var original = ts.getOriginalNode(node); - return ts.nodeIsSynthesized(original) || resolver.isValueAliasDeclaration(original) ? node : undefined; - } - function visitExportDeclaration(node) { - if (!node.exportClause) { - return resolver.moduleExportsSomeValue(node.moduleSpecifier) ? node : undefined; - } - if (!resolver.isValueAliasDeclaration(node)) { - return undefined; - } - var newExportClause = ts.visitNode(node.exportClause, visitor, ts.isNamedExports, /*optional*/ true); - if (node.exportClause === newExportClause) { - return node; - } - return newExportClause - ? ts.createExportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, newExportClause, node.moduleSpecifier) - : undefined; - } - function visitNamedExports(node) { - var newExports = ts.visitNodes(node.elements, visitor, ts.isExportSpecifier); - if (node.elements === newExports) { - return node; - } - return newExports.length ? ts.createNamedExports(newExports) : undefined; - } - function visitExportSpecifier(node) { - return resolver.isValueAliasDeclaration(node) ? node : undefined; - } - function visitImportEqualsDeclaration(node) { - return !ts.isExternalModuleImportEqualsDeclaration(node) || resolver.isReferencedAliasDeclaration(node) ? node : undefined; - } - function visitImportDeclaration(node) { - if (node.importClause) { - var newImportClause = ts.visitNode(node.importClause, visitor, ts.isImportClause); - if (!newImportClause.name && !newImportClause.namedBindings) { - return undefined; - } - else if (newImportClause !== node.importClause) { - return ts.createImportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, newImportClause, node.moduleSpecifier); - } - } - return node; - } - function visitImportClause(node) { - var newDefaultImport = node.name; - if (!resolver.isReferencedAliasDeclaration(node)) { - newDefaultImport = undefined; - } - var newNamedBindings = ts.visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, /*optional*/ true); - return newDefaultImport !== node.name || newNamedBindings !== node.namedBindings - ? ts.createImportClause(newDefaultImport, newNamedBindings) - : node; - } - function visitNamedBindings(node) { - if (node.kind === 232 /* NamespaceImport */) { - return resolver.isReferencedAliasDeclaration(node) ? node : undefined; - } - else { - var newNamedImportElements = ts.visitNodes(node.elements, visitor, ts.isImportSpecifier); - if (!newNamedImportElements || newNamedImportElements.length == 0) { - return undefined; - } - if (newNamedImportElements === node.elements) { - return node; - } - return ts.createNamedImports(newNamedImportElements); - } - } - function visitImportSpecifier(node) { - return resolver.isReferencedAliasDeclaration(node) ? node : undefined; - } - } - ts.transformES6Module = transformES6Module; -})(ts || (ts = {})); -/// -/// -/*@internal*/ -var ts; -(function (ts) { - function transformSystemModule(context) { - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration, hoistFunctionDeclaration = context.hoistFunctionDeclaration; - var compilerOptions = context.getCompilerOptions(); - var resolver = context.getEmitResolver(); - var host = context.getEmitHost(); - var languageVersion = ts.getEmitScriptTarget(compilerOptions); - var previousOnSubstituteNode = context.onSubstituteNode; - var previousOnEmitNode = context.onEmitNode; - context.onSubstituteNode = onSubstituteNode; - context.onEmitNode = onEmitNode; - context.enableSubstitution(69 /* Identifier */); - context.enableSubstitution(187 /* BinaryExpression */); - context.enableSubstitution(185 /* PrefixUnaryExpression */); - context.enableSubstitution(186 /* PostfixUnaryExpression */); - context.enableEmitNotification(256 /* SourceFile */); - var exportFunctionForFileMap = []; - var currentSourceFile; - var externalImports; - var exportSpecifiers; - var exportEquals; - var hasExportStarsToExportValues; - var exportFunctionForFile; - var contextObjectForFile; - var exportedLocalNames; - var exportedFunctionDeclarations; - var enclosingBlockScopedContainer; - var currentParent; - var currentNode; - return transformSourceFile; - function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { - return node; - } - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - currentSourceFile = node; - currentNode = node; - // Perform the transformation. - var updated = transformSystemModuleWorker(node); - ts.aggregateTransformFlags(updated); - currentSourceFile = undefined; - externalImports = undefined; - exportSpecifiers = undefined; - exportEquals = undefined; - hasExportStarsToExportValues = false; - exportFunctionForFile = undefined; - contextObjectForFile = undefined; - exportedLocalNames = undefined; - exportedFunctionDeclarations = undefined; - return updated; - } - return node; - } - function transformSystemModuleWorker(node) { - // System modules have the following shape: - // - // System.register(['dep-1', ... 'dep-n'], function(exports) {/* module body function */}) - // - // The parameter 'exports' here is a callback '(name: string, value: T) => T' that - // is used to publish exported values. 'exports' returns its 'value' argument so in - // most cases expressions that mutate exported values can be rewritten as: - // - // expr -> exports('name', expr) - // - // The only exception in this rule is postfix unary operators, - // see comment to 'substitutePostfixUnaryExpression' for more details - ts.Debug.assert(!exportFunctionForFile); - // Collect information about the external module and dependency groups. - (_a = ts.collectExternalModuleInfo(node, resolver), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); - // Make sure that the name of the 'exports' function does not conflict with - // existing identifiers. - exportFunctionForFile = ts.createUniqueName("exports"); - contextObjectForFile = ts.createUniqueName("context"); - exportFunctionForFileMap[ts.getOriginalNodeId(node)] = exportFunctionForFile; - var dependencyGroups = collectDependencyGroups(externalImports); - var statements = []; - // Add the body of the module. - addSystemModuleBody(statements, node, dependencyGroups); - var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); - var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, getNameOfDependencyGroup)); - var body = ts.createFunctionExpression( - /*asteriskToken*/ undefined, - /*name*/ undefined, - /*typeParameters*/ undefined, [ - ts.createParameter(exportFunctionForFile), - ts.createParameter(contextObjectForFile) - ], - /*type*/ undefined, ts.setEmitFlags(ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true), 1 /* EmitEmitHelpers */)); - // Write the call to `System.register` - // Clear the emit-helpers flag for later passes since we'll have already used it in the module body - // So the helper will be emit at the correct position instead of at the top of the source-file - return updateSourceFile(node, [ - ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), - /*typeArguments*/ undefined, moduleName - ? [moduleName, dependencies, body] - : [dependencies, body])) - ], /*nodeEmitFlags*/ ~1 /* EmitEmitHelpers */ & ts.getEmitFlags(node)); - var _a; - } - /** - * Adds the statements for the module body function for the source file. - * - * @param statements The output statements for the module body. - * @param node The source file for the module. - * @param statementOffset The offset at which to begin visiting the statements of the SourceFile. - */ - function addSystemModuleBody(statements, node, dependencyGroups) { - // Shape of the body in system modules: - // - // function (exports) { - // - // - // - // return { - // setters: [ - // - // ], - // execute: function() { - // - // } - // } - // - // } - // - // i.e: - // - // import {x} from 'file1' - // var y = 1; - // export function foo() { return y + x(); } - // console.log(y); - // - // Will be transformed to: - // - // function(exports) { - // var file_1; // local alias - // var y; - // function foo() { return y + file_1.x(); } - // exports("foo", foo); - // return { - // setters: [ - // function(v) { file_1 = v } - // ], - // execute(): function() { - // y = 1; - // console.log(y); - // } - // }; - // } - // We start a new lexical environment in this function body, but *not* in the - // body of the execute function. This allows us to emit temporary declarations - // only in the outer module body and not in the inner one. - startLexicalEnvironment(); - // Add any prologue directives. - var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, visitSourceElement); - // var __moduleName = context_1 && context_1.id; - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration("__moduleName", - /*type*/ undefined, ts.createLogicalAnd(contextObjectForFile, ts.createPropertyAccess(contextObjectForFile, "id"))) - ]))); - // Visit the statements of the source file, emitting any transformations into - // the `executeStatements` array. We do this *before* we fill the `setters` array - // as we both emit transformations as well as aggregate some data used when creating - // setters. This allows us to reduce the number of times we need to loop through the - // statements of the source file. - var executeStatements = ts.visitNodes(node.statements, visitSourceElement, ts.isStatement, statementOffset); - // We emit the lexical environment (hoisted variables and function declarations) - // early to align roughly with our previous emit output. - // Two key differences in this approach are: - // - Temporary variables will appear at the top rather than at the bottom of the file - // - Calls to the exporter for exported function declarations are grouped after - // the declarations. - ts.addRange(statements, endLexicalEnvironment()); - // Emit early exports for function declarations. - ts.addRange(statements, exportedFunctionDeclarations); - var exportStarFunction = addExportStarIfNeeded(statements); - statements.push(ts.createReturn(ts.setMultiLine(ts.createObjectLiteral([ - ts.createPropertyAssignment("setters", generateSetters(exportStarFunction, dependencyGroups)), - ts.createPropertyAssignment("execute", ts.createFunctionExpression( - /*asteriskToken*/ undefined, - /*name*/ undefined, - /*typeParameters*/ undefined, - /*parameters*/ [], - /*type*/ undefined, ts.createBlock(executeStatements, - /*location*/ undefined, - /*multiLine*/ true))) - ]), - /*multiLine*/ true))); - } - function addExportStarIfNeeded(statements) { - if (!hasExportStarsToExportValues) { - return; - } - // when resolving exports local exported entries/indirect exported entries in the module - // should always win over entries with similar names that were added via star exports - // to support this we store names of local/indirect exported entries in a set. - // this set is used to filter names brought by star expors. - // local names set should only be added if we have anything exported - if (!exportedLocalNames && ts.isEmpty(exportSpecifiers)) { - // no exported declarations (export var ...) or export specifiers (export {x}) - // check if we have any non star export declarations. - var hasExportDeclarationWithExportClause = false; - for (var _i = 0, externalImports_1 = externalImports; _i < externalImports_1.length; _i++) { - var externalImport = externalImports_1[_i]; - if (externalImport.kind === 236 /* ExportDeclaration */ && externalImport.exportClause) { - hasExportDeclarationWithExportClause = true; - break; - } - } - if (!hasExportDeclarationWithExportClause) { - // we still need to emit exportStar helper - return addExportStarFunction(statements, /*localNames*/ undefined); - } - } - var exportedNames = []; - if (exportedLocalNames) { - for (var _a = 0, exportedLocalNames_1 = exportedLocalNames; _a < exportedLocalNames_1.length; _a++) { - var exportedLocalName = exportedLocalNames_1[_a]; - // write name of exported declaration, i.e 'export var x...' - exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName.text), ts.createLiteral(true))); - } - } - for (var _b = 0, externalImports_2 = externalImports; _b < externalImports_2.length; _b++) { - var externalImport = externalImports_2[_b]; - if (externalImport.kind !== 236 /* ExportDeclaration */) { - continue; - } - var exportDecl = externalImport; - if (!exportDecl.exportClause) { - // export * from ... - continue; - } - for (var _c = 0, _d = exportDecl.exportClause.elements; _c < _d.length; _c++) { - var element = _d[_c]; - // write name of indirectly exported entry, i.e. 'export {x} from ...' - exportedNames.push(ts.createPropertyAssignment(ts.createLiteral((element.name || element.propertyName).text), ts.createLiteral(true))); - } - } - var exportedNamesStorageRef = ts.createUniqueName("exportedNames"); - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(exportedNamesStorageRef, - /*type*/ undefined, ts.createObjectLiteral(exportedNames, /*location*/ undefined, /*multiline*/ true)) - ]))); - return addExportStarFunction(statements, exportedNamesStorageRef); - } - /** - * Emits a setter callback for each dependency group. - * @param write The callback used to write each callback. - */ - function generateSetters(exportStarFunction, dependencyGroups) { - var setters = []; - for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { - var group = dependencyGroups_1[_i]; - // derive a unique name for parameter from the first named entry in the group - var localName = ts.forEach(group.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); - var parameterName = localName ? ts.getGeneratedNameForNode(localName) : ts.createUniqueName(""); - var statements = []; - for (var _a = 0, _b = group.externalImports; _a < _b.length; _a++) { - var entry = _b[_a]; - var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); - switch (entry.kind) { - case 230 /* ImportDeclaration */: - if (!entry.importClause) { - // 'import "..."' case - // module is imported only for side-effects, no emit required - break; - } - // fall-through - case 229 /* ImportEqualsDeclaration */: - ts.Debug.assert(importVariableName !== undefined); - // save import into the local - statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); - break; - case 236 /* ExportDeclaration */: - ts.Debug.assert(importVariableName !== undefined); - if (entry.exportClause) { - // export {a, b as c} from 'foo' - // - // emit as: - // - // exports_({ - // "a": _["a"], - // "c": _["b"] - // }); - var properties = []; - for (var _c = 0, _d = entry.exportClause.elements; _c < _d.length; _c++) { - var e = _d[_c]; - properties.push(ts.createPropertyAssignment(ts.createLiteral(e.name.text), ts.createElementAccess(parameterName, ts.createLiteral((e.propertyName || e.name).text)))); - } - statements.push(ts.createStatement(ts.createCall(exportFunctionForFile, - /*typeArguments*/ undefined, [ts.createObjectLiteral(properties, /*location*/ undefined, /*multiline*/ true)]))); - } - else { - // export * from 'foo' - // - // emit as: - // - // exportStar(foo_1_1); - statements.push(ts.createStatement(ts.createCall(exportStarFunction, - /*typeArguments*/ undefined, [parameterName]))); - } - break; - } - } - setters.push(ts.createFunctionExpression( - /*asteriskToken*/ undefined, - /*name*/ undefined, - /*typeParameters*/ undefined, [ts.createParameter(parameterName)], - /*type*/ undefined, ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true))); - } - return ts.createArrayLiteral(setters, /*location*/ undefined, /*multiLine*/ true); - } - function visitSourceElement(node) { - switch (node.kind) { - case 230 /* ImportDeclaration */: - return visitImportDeclaration(node); - case 229 /* ImportEqualsDeclaration */: - return visitImportEqualsDeclaration(node); - case 236 /* ExportDeclaration */: - return visitExportDeclaration(node); - case 235 /* ExportAssignment */: - return visitExportAssignment(node); - default: - return visitNestedNode(node); - } - } - function visitNestedNode(node) { - var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; - var savedCurrentParent = currentParent; - var savedCurrentNode = currentNode; - var currentGrandparent = currentParent; - currentParent = currentNode; - currentNode = node; - if (currentParent && ts.isBlockScope(currentParent, currentGrandparent)) { - enclosingBlockScopedContainer = currentParent; - } - var result = visitNestedNodeWorker(node); - enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; - currentParent = savedCurrentParent; - currentNode = savedCurrentNode; - return result; - } - function visitNestedNodeWorker(node) { - switch (node.kind) { - case 200 /* VariableStatement */: - return visitVariableStatement(node); - case 220 /* FunctionDeclaration */: - return visitFunctionDeclaration(node); - case 221 /* ClassDeclaration */: - return visitClassDeclaration(node); - case 206 /* ForStatement */: - return visitForStatement(node); - case 207 /* ForInStatement */: - return visitForInStatement(node); - case 208 /* ForOfStatement */: - return visitForOfStatement(node); - case 204 /* DoStatement */: - return visitDoStatement(node); - case 205 /* WhileStatement */: - return visitWhileStatement(node); - case 214 /* LabeledStatement */: - return visitLabeledStatement(node); - case 212 /* WithStatement */: - return visitWithStatement(node); - case 213 /* SwitchStatement */: - return visitSwitchStatement(node); - case 227 /* CaseBlock */: - return visitCaseBlock(node); - case 249 /* CaseClause */: - return visitCaseClause(node); - case 250 /* DefaultClause */: - return visitDefaultClause(node); - case 216 /* TryStatement */: - return visitTryStatement(node); - case 252 /* CatchClause */: - return visitCatchClause(node); - case 199 /* Block */: - return visitBlock(node); - case 202 /* ExpressionStatement */: - return visitExpressionStatement(node); - default: - return node; - } - } - function visitImportDeclaration(node) { - if (node.importClause && ts.contains(externalImports, node)) { - hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); - } - return undefined; - } - function visitImportEqualsDeclaration(node) { - if (ts.contains(externalImports, node)) { - hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); - } - // NOTE(rbuckton): Do we support export import = require('') in System? - return undefined; - } - function visitExportDeclaration(node) { - if (!node.moduleSpecifier) { - var statements = []; - ts.addRange(statements, ts.map(node.exportClause.elements, visitExportSpecifier)); - return statements; - } - return undefined; - } - function visitExportSpecifier(specifier) { - if (resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) - || resolver.isValueAliasDeclaration(specifier)) { - recordExportName(specifier.name); - return createExportStatement(specifier.name, specifier.propertyName || specifier.name); - } - return undefined; - } - function visitExportAssignment(node) { - if (!node.isExportEquals) { - if (ts.nodeIsSynthesized(node) || resolver.isValueAliasDeclaration(node)) { - return createExportStatement(ts.createLiteral("default"), node.expression); - } - } - return undefined; - } - /** - * Visits a variable statement, hoisting declared names to the top-level module body. - * Each declaration is rewritten into an assignment expression. - * - * @param node The variable statement to visit. - */ - function visitVariableStatement(node) { - // hoist only non-block scoped declarations or block scoped declarations parented by source file - var shouldHoist = ((ts.getCombinedNodeFlags(ts.getOriginalNode(node.declarationList)) & 3 /* BlockScoped */) == 0) || - enclosingBlockScopedContainer.kind === 256 /* SourceFile */; - if (!shouldHoist) { - return node; - } - var isExported = ts.hasModifier(node, 1 /* Export */); - var expressions = []; - for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { - var variable = _a[_i]; - var visited = transformVariable(variable, isExported); - if (visited) { - expressions.push(visited); - } - } - if (expressions.length) { - return ts.createStatement(ts.inlineExpressions(expressions), node); - } - return undefined; - } - /** - * Transforms a VariableDeclaration into one or more assignment expressions. - * - * @param node The VariableDeclaration to transform. - * @param isExported A value used to indicate whether the containing statement was exported. - */ - function transformVariable(node, isExported) { - // Hoist any bound names within the declaration. - hoistBindingElement(node, isExported); - if (!node.initializer) { - // If the variable has no initializer, ignore it. - return; - } - var name = node.name; - if (ts.isIdentifier(name)) { - // If the variable has an IdentifierName, write out an assignment expression in its place. - return ts.createAssignment(name, node.initializer); - } - else { - // If the variable has a BindingPattern, flatten the variable into multiple assignment expressions. - return ts.flattenVariableDestructuringToExpression(context, node, hoistVariableDeclaration); - } - } - /** - * Visits a FunctionDeclaration, hoisting it to the outer module body function. - * - * @param node The function declaration to visit. - */ - function visitFunctionDeclaration(node) { - if (ts.hasModifier(node, 1 /* Export */)) { - // If the function is exported, ensure it has a name and rewrite the function without any export flags. - var name_31 = node.name || ts.getGeneratedNameForNode(node); - var newNode = ts.createFunctionDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, node.asteriskToken, name_31, - /*typeParameters*/ undefined, node.parameters, - /*type*/ undefined, node.body, - /*location*/ node); - // Record a declaration export in the outer module body function. - recordExportedFunctionDeclaration(node); - if (!ts.hasModifier(node, 512 /* Default */)) { - recordExportName(name_31); - } - ts.setOriginalNode(newNode, node); - node = newNode; - } - // Hoist the function declaration to the outer module body function. - hoistFunctionDeclaration(node); - return undefined; - } - function visitExpressionStatement(node) { - var originalNode = ts.getOriginalNode(node); - if ((originalNode.kind === 225 /* ModuleDeclaration */ || originalNode.kind === 224 /* EnumDeclaration */) && ts.hasModifier(originalNode, 1 /* Export */)) { - var name_32 = getDeclarationName(originalNode); - // We only need to hoistVariableDeclaration for EnumDeclaration - // as ModuleDeclaration is already hoisted when the transformer call visitVariableStatement - // which then call transformsVariable for each declaration in declarationList - if (originalNode.kind === 224 /* EnumDeclaration */) { - hoistVariableDeclaration(name_32); - } - return [ - node, - createExportStatement(name_32, name_32) - ]; - } - return node; - } - /** - * Visits a ClassDeclaration, hoisting its name to the outer module body function. - * - * @param node The class declaration to visit. - */ - function visitClassDeclaration(node) { - // Hoist the name of the class declaration to the outer module body function. - var name = getDeclarationName(node); - hoistVariableDeclaration(name); - var statements = []; - // Rewrite the class declaration into an assignment of a class expression. - statements.push(ts.createStatement(ts.createAssignment(name, ts.createClassExpression( - /*modifiers*/ undefined, node.name, - /*typeParameters*/ undefined, node.heritageClauses, node.members, - /*location*/ node)), - /*location*/ node)); - // If the class was exported, write a declaration export to the inner module body function. - if (ts.hasModifier(node, 1 /* Export */)) { - if (!ts.hasModifier(node, 512 /* Default */)) { - recordExportName(name); - } - statements.push(createDeclarationExport(node)); - } - return statements; - } - function shouldHoistLoopInitializer(node) { - return ts.isVariableDeclarationList(node) && (ts.getCombinedNodeFlags(node) & 3 /* BlockScoped */) === 0; - } - /** - * Visits the body of a ForStatement to hoist declarations. - * - * @param node The statement to visit. - */ - function visitForStatement(node) { - var initializer = node.initializer; - if (shouldHoistLoopInitializer(initializer)) { - var expressions = []; - for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) { - var variable = _a[_i]; - var visited = transformVariable(variable, /*isExported*/ false); - if (visited) { - expressions.push(visited); - } - } - ; - return ts.createFor(expressions.length - ? ts.inlineExpressions(expressions) - : ts.createSynthesizedNode(193 /* OmittedExpression */), node.condition, node.incrementor, ts.visitNode(node.statement, visitNestedNode, ts.isStatement), - /*location*/ node); - } - else { - return ts.visitEachChild(node, visitNestedNode, context); - } - } - /** - * Transforms and hoists the declaration list of a ForInStatement or ForOfStatement into an expression. - * - * @param node The decalaration list to transform. - */ - function transformForBinding(node) { - var firstDeclaration = ts.firstOrUndefined(node.declarations); - hoistBindingElement(firstDeclaration, /*isExported*/ false); - var name = firstDeclaration.name; - return ts.isIdentifier(name) - ? name - : ts.flattenVariableDestructuringToExpression(context, firstDeclaration, hoistVariableDeclaration); - } - /** - * Visits the body of a ForInStatement to hoist declarations. - * - * @param node The statement to visit. - */ - function visitForInStatement(node) { - var initializer = node.initializer; - if (shouldHoistLoopInitializer(initializer)) { - var updated = ts.getMutableClone(node); - updated.initializer = transformForBinding(initializer); - updated.statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); - return updated; - } - else { - return ts.visitEachChild(node, visitNestedNode, context); - } - } - /** - * Visits the body of a ForOfStatement to hoist declarations. - * - * @param node The statement to visit. - */ - function visitForOfStatement(node) { - var initializer = node.initializer; - if (shouldHoistLoopInitializer(initializer)) { - var updated = ts.getMutableClone(node); - updated.initializer = transformForBinding(initializer); - updated.statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); - return updated; - } - else { - return ts.visitEachChild(node, visitNestedNode, context); - } - } - /** - * Visits the body of a DoStatement to hoist declarations. - * - * @param node The statement to visit. - */ - function visitDoStatement(node) { - var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); - if (statement !== node.statement) { - var updated = ts.getMutableClone(node); - updated.statement = statement; - return updated; - } - return node; - } - /** - * Visits the body of a WhileStatement to hoist declarations. - * - * @param node The statement to visit. - */ - function visitWhileStatement(node) { - var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); - if (statement !== node.statement) { - var updated = ts.getMutableClone(node); - updated.statement = statement; - return updated; - } - return node; - } - /** - * Visits the body of a LabeledStatement to hoist declarations. - * - * @param node The statement to visit. - */ - function visitLabeledStatement(node) { - var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); - if (statement !== node.statement) { - var updated = ts.getMutableClone(node); - updated.statement = statement; - return updated; - } - return node; - } - /** - * Visits the body of a WithStatement to hoist declarations. - * - * @param node The statement to visit. - */ - function visitWithStatement(node) { - var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); - if (statement !== node.statement) { - var updated = ts.getMutableClone(node); - updated.statement = statement; - return updated; - } - return node; - } - /** - * Visits the body of a SwitchStatement to hoist declarations. - * - * @param node The statement to visit. - */ - function visitSwitchStatement(node) { - var caseBlock = ts.visitNode(node.caseBlock, visitNestedNode, ts.isCaseBlock); - if (caseBlock !== node.caseBlock) { - var updated = ts.getMutableClone(node); - updated.caseBlock = caseBlock; - return updated; - } - return node; - } - /** - * Visits the body of a CaseBlock to hoist declarations. - * - * @param node The node to visit. - */ - function visitCaseBlock(node) { - var clauses = ts.visitNodes(node.clauses, visitNestedNode, ts.isCaseOrDefaultClause); - if (clauses !== node.clauses) { - var updated = ts.getMutableClone(node); - updated.clauses = clauses; - return updated; - } - return node; - } - /** - * Visits the body of a CaseClause to hoist declarations. - * - * @param node The clause to visit. - */ - function visitCaseClause(node) { - var statements = ts.visitNodes(node.statements, visitNestedNode, ts.isStatement); - if (statements !== node.statements) { - var updated = ts.getMutableClone(node); - updated.statements = statements; - return updated; - } - return node; - } - /** - * Visits the body of a DefaultClause to hoist declarations. - * - * @param node The clause to visit. - */ - function visitDefaultClause(node) { - return ts.visitEachChild(node, visitNestedNode, context); - } - /** - * Visits the body of a TryStatement to hoist declarations. - * - * @param node The statement to visit. - */ - function visitTryStatement(node) { - return ts.visitEachChild(node, visitNestedNode, context); - } - /** - * Visits the body of a CatchClause to hoist declarations. - * - * @param node The clause to visit. - */ - function visitCatchClause(node) { - var block = ts.visitNode(node.block, visitNestedNode, ts.isBlock); - if (block !== node.block) { - var updated = ts.getMutableClone(node); - updated.block = block; - return updated; - } - return node; - } - /** - * Visits the body of a Block to hoist declarations. - * - * @param node The block to visit. - */ - function visitBlock(node) { - return ts.visitEachChild(node, visitNestedNode, context); - } - // - // Substitutions - // - function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 256 /* SourceFile */) { - exportFunctionForFile = exportFunctionForFileMap[ts.getOriginalNodeId(node)]; - previousOnEmitNode(emitContext, node, emitCallback); - exportFunctionForFile = undefined; - } - else { - previousOnEmitNode(emitContext, node, emitCallback); - } - } - /** - * Hooks node substitutions. - * - * @param node The node to substitute. - * @param isExpression A value indicating whether the node is to be used in an expression - * position. - */ - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1 /* Expression */) { - return substituteExpression(node); - } - return node; - } - /** - * Substitute the expression, if necessary. - * - * @param node The node to substitute. - */ - function substituteExpression(node) { - switch (node.kind) { - case 69 /* Identifier */: - return substituteExpressionIdentifier(node); - case 187 /* BinaryExpression */: - return substituteBinaryExpression(node); - case 185 /* PrefixUnaryExpression */: - case 186 /* PostfixUnaryExpression */: - return substituteUnaryExpression(node); - } - return node; - } - /** - * Substitution for identifiers exported at the top level of a module. - */ - function substituteExpressionIdentifier(node) { - var importDeclaration = resolver.getReferencedImportDeclaration(node); - if (importDeclaration) { - var importBinding = createImportBinding(importDeclaration); - if (importBinding) { - return importBinding; - } - } - return node; - } - function substituteBinaryExpression(node) { - if (ts.isAssignmentOperator(node.operatorToken.kind)) { - return substituteAssignmentExpression(node); - } - return node; - } - function substituteAssignmentExpression(node) { - ts.setEmitFlags(node, 128 /* NoSubstitution */); - var left = node.left; - switch (left.kind) { - case 69 /* Identifier */: - var exportDeclaration = resolver.getReferencedExportContainer(left); - if (exportDeclaration) { - return createExportExpression(left, node); - } - break; - case 171 /* ObjectLiteralExpression */: - case 170 /* ArrayLiteralExpression */: - if (hasExportedReferenceInDestructuringPattern(left)) { - return substituteDestructuring(node); - } - break; - } - return node; - } - function isExportedBinding(name) { - var container = resolver.getReferencedExportContainer(name); - return container && container.kind === 256 /* SourceFile */; - } - function hasExportedReferenceInDestructuringPattern(node) { - switch (node.kind) { - case 69 /* Identifier */: - return isExportedBinding(node); - case 171 /* ObjectLiteralExpression */: - for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { - var property = _a[_i]; - if (hasExportedReferenceInObjectDestructuringElement(property)) { - return true; - } - } - break; - case 170 /* ArrayLiteralExpression */: - for (var _b = 0, _c = node.elements; _b < _c.length; _b++) { - var element = _c[_b]; - if (hasExportedReferenceInArrayDestructuringElement(element)) { - return true; - } - } - break; - } - return false; - } - function hasExportedReferenceInObjectDestructuringElement(node) { - if (ts.isShorthandPropertyAssignment(node)) { - return isExportedBinding(node.name); - } - else if (ts.isPropertyAssignment(node)) { - return hasExportedReferenceInDestructuringElement(node.initializer); - } - else { - return false; - } - } - function hasExportedReferenceInArrayDestructuringElement(node) { - if (ts.isSpreadElementExpression(node)) { - var expression = node.expression; - return ts.isIdentifier(expression) && isExportedBinding(expression); - } - else { - return hasExportedReferenceInDestructuringElement(node); - } - } - function hasExportedReferenceInDestructuringElement(node) { - if (ts.isBinaryExpression(node)) { - var left = node.left; - return node.operatorToken.kind === 56 /* EqualsToken */ - && isDestructuringPattern(left) - && hasExportedReferenceInDestructuringPattern(left); - } - else if (ts.isIdentifier(node)) { - return isExportedBinding(node); - } - else if (ts.isSpreadElementExpression(node)) { - var expression = node.expression; - return ts.isIdentifier(expression) && isExportedBinding(expression); - } - else if (isDestructuringPattern(node)) { - return hasExportedReferenceInDestructuringPattern(node); - } - else { - return false; - } - } - function isDestructuringPattern(node) { - var kind = node.kind; - return kind === 69 /* Identifier */ - || kind === 171 /* ObjectLiteralExpression */ - || kind === 170 /* ArrayLiteralExpression */; - } - function substituteDestructuring(node) { - return ts.flattenDestructuringAssignment(context, node, /*needsValue*/ true, hoistVariableDeclaration); - } - function substituteUnaryExpression(node) { - var operand = node.operand; - var operator = node.operator; - var substitute = ts.isIdentifier(operand) && - (node.kind === 186 /* PostfixUnaryExpression */ || - (node.kind === 185 /* PrefixUnaryExpression */ && (operator === 41 /* PlusPlusToken */ || operator === 42 /* MinusMinusToken */))); - if (substitute) { - var exportDeclaration = resolver.getReferencedExportContainer(operand); - if (exportDeclaration) { - var expr = ts.createPrefix(node.operator, operand, node); - ts.setEmitFlags(expr, 128 /* NoSubstitution */); - var call = createExportExpression(operand, expr); - if (node.kind === 185 /* PrefixUnaryExpression */) { - return call; - } - else { - // export function returns the value that was passes as the second argument - // however for postfix unary expressions result value should be the value before modification. - // emit 'x++' as '(export('x', ++x) - 1)' and 'x--' as '(export('x', --x) + 1)' - return operator === 41 /* PlusPlusToken */ - ? ts.createSubtract(call, ts.createLiteral(1)) - : ts.createAdd(call, ts.createLiteral(1)); - } - } - } - return node; - } - /** - * Gets a name to use for a DeclarationStatement. - * @param node The declaration statement. - */ - function getDeclarationName(node) { - return node.name ? ts.getSynthesizedClone(node.name) : ts.getGeneratedNameForNode(node); - } - function addExportStarFunction(statements, localNames) { - var exportStarFunction = ts.createUniqueName("exportStar"); - var m = ts.createIdentifier("m"); - var n = ts.createIdentifier("n"); - var exports = ts.createIdentifier("exports"); - var condition = ts.createStrictInequality(n, ts.createLiteral("default")); - if (localNames) { - condition = ts.createLogicalAnd(condition, ts.createLogicalNot(ts.createHasOwnProperty(localNames, n))); - } - statements.push(ts.createFunctionDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, - /*asteriskToken*/ undefined, exportStarFunction, - /*typeParameters*/ undefined, [ts.createParameter(m)], - /*type*/ undefined, ts.createBlock([ - ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(exports, - /*type*/ undefined, ts.createObjectLiteral([])) - ])), - ts.createForIn(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(n, /*type*/ undefined) - ]), m, ts.createBlock([ - ts.setEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 32 /* SingleLine */) - ])), - ts.createStatement(ts.createCall(exportFunctionForFile, - /*typeArguments*/ undefined, [exports])) - ], - /*location*/ undefined, - /*multiline*/ true))); - return exportStarFunction; - } - /** - * Creates a call to the current file's export function to export a value. - * @param name The bound name of the export. - * @param value The exported value. - */ - function createExportExpression(name, value) { - var exportName = ts.isIdentifier(name) ? ts.createLiteral(name.text) : name; - return ts.createCall(exportFunctionForFile, /*typeArguments*/ undefined, [exportName, value]); - } - /** - * Creates a call to the current file's export function to export a value. - * @param name The bound name of the export. - * @param value The exported value. - */ - function createExportStatement(name, value) { - return ts.createStatement(createExportExpression(name, value)); - } - /** - * Creates a call to the current file's export function to export a declaration. - * @param node The declaration to export. - */ - function createDeclarationExport(node) { - var declarationName = getDeclarationName(node); - var exportName = ts.hasModifier(node, 512 /* Default */) ? ts.createLiteral("default") : declarationName; - return createExportStatement(exportName, declarationName); - } - function createImportBinding(importDeclaration) { - var importAlias; - var name; - if (ts.isImportClause(importDeclaration)) { - importAlias = ts.getGeneratedNameForNode(importDeclaration.parent); - name = ts.createIdentifier("default"); - } - else if (ts.isImportSpecifier(importDeclaration)) { - importAlias = ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent); - name = importDeclaration.propertyName || importDeclaration.name; - } - else { - return undefined; - } - if (name.originalKeywordKind && languageVersion === 0 /* ES3 */) { - return ts.createElementAccess(importAlias, ts.createLiteral(name.text)); - } - else { - return ts.createPropertyAccess(importAlias, ts.getSynthesizedClone(name)); - } - } - function collectDependencyGroups(externalImports) { - var groupIndices = ts.createMap(); - var dependencyGroups = []; - for (var i = 0; i < externalImports.length; i++) { - var externalImport = externalImports[i]; - var externalModuleName = ts.getExternalModuleNameLiteral(externalImport, currentSourceFile, host, resolver, compilerOptions); - var text = externalModuleName.text; - if (ts.hasProperty(groupIndices, text)) { - // deduplicate/group entries in dependency list by the dependency name - var groupIndex = groupIndices[text]; - dependencyGroups[groupIndex].externalImports.push(externalImport); - continue; - } - else { - groupIndices[text] = dependencyGroups.length; - dependencyGroups.push({ - name: externalModuleName, - externalImports: [externalImport] - }); - } - } - return dependencyGroups; - } - function getNameOfDependencyGroup(dependencyGroup) { - return dependencyGroup.name; - } - function recordExportName(name) { - if (!exportedLocalNames) { - exportedLocalNames = []; - } - exportedLocalNames.push(name); - } - function recordExportedFunctionDeclaration(node) { - if (!exportedFunctionDeclarations) { - exportedFunctionDeclarations = []; - } - exportedFunctionDeclarations.push(createDeclarationExport(node)); - } - function hoistBindingElement(node, isExported) { - if (ts.isOmittedExpression(node)) { - return; - } - var name = node.name; - if (ts.isIdentifier(name)) { - hoistVariableDeclaration(ts.getSynthesizedClone(name)); - if (isExported) { - recordExportName(name); - } - } - else if (ts.isBindingPattern(name)) { - ts.forEach(name.elements, isExported ? hoistExportedBindingElement : hoistNonExportedBindingElement); - } - } - function hoistExportedBindingElement(node) { - hoistBindingElement(node, /*isExported*/ true); - } - function hoistNonExportedBindingElement(node) { - hoistBindingElement(node, /*isExported*/ false); - } - function updateSourceFile(node, statements, nodeEmitFlags) { - var updated = ts.getMutableClone(node); - updated.statements = ts.createNodeArray(statements, node.statements); - ts.setEmitFlags(updated, nodeEmitFlags); - return updated; - } - } - ts.transformSystemModule = transformSystemModule; -})(ts || (ts = {})); -/// -/// -/*@internal*/ -var ts; -(function (ts) { - function transformModule(context) { - var transformModuleDelegates = ts.createMap((_a = {}, - _a[ts.ModuleKind.None] = transformCommonJSModule, - _a[ts.ModuleKind.CommonJS] = transformCommonJSModule, - _a[ts.ModuleKind.AMD] = transformAMDModule, - _a[ts.ModuleKind.UMD] = transformUMDModule, - _a)); - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; - var compilerOptions = context.getCompilerOptions(); - var resolver = context.getEmitResolver(); - var host = context.getEmitHost(); - var languageVersion = ts.getEmitScriptTarget(compilerOptions); - var moduleKind = ts.getEmitModuleKind(compilerOptions); - var previousOnSubstituteNode = context.onSubstituteNode; - var previousOnEmitNode = context.onEmitNode; - context.onSubstituteNode = onSubstituteNode; - context.onEmitNode = onEmitNode; - context.enableSubstitution(69 /* Identifier */); - context.enableSubstitution(187 /* BinaryExpression */); - context.enableSubstitution(185 /* PrefixUnaryExpression */); - context.enableSubstitution(186 /* PostfixUnaryExpression */); - context.enableSubstitution(254 /* ShorthandPropertyAssignment */); - context.enableEmitNotification(256 /* SourceFile */); - var currentSourceFile; - var externalImports; - var exportSpecifiers; - var exportEquals; - var bindingNameExportSpecifiersMap; - // Subset of exportSpecifiers that is a binding-name. - // This is to reduce amount of memory we have to keep around even after we done with module-transformer - var bindingNameExportSpecifiersForFileMap = ts.createMap(); - var hasExportStarsToExportValues; - return transformSourceFile; - /** - * Transforms the module aspects of a SourceFile. - * - * @param node The SourceFile node. - */ - function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { - return node; - } - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - currentSourceFile = node; - // Collect information about the external module. - (_a = ts.collectExternalModuleInfo(node, resolver), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); - // Perform the transformation. - var transformModule_1 = transformModuleDelegates[moduleKind] || transformModuleDelegates[ts.ModuleKind.None]; - var updated = transformModule_1(node); - ts.aggregateTransformFlags(updated); - currentSourceFile = undefined; - externalImports = undefined; - exportSpecifiers = undefined; - exportEquals = undefined; - hasExportStarsToExportValues = false; - return updated; - } - return node; - var _a; - } - /** - * Transforms a SourceFile into a CommonJS module. - * - * @param node The SourceFile node. - */ - function transformCommonJSModule(node) { - startLexicalEnvironment(); - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, visitor); - ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); - ts.addRange(statements, endLexicalEnvironment()); - addExportEqualsIfNeeded(statements, /*emitAsReturn*/ false); - var updated = updateSourceFile(node, statements); - if (hasExportStarsToExportValues) { - ts.setEmitFlags(updated, 2 /* EmitExportStar */ | ts.getEmitFlags(node)); - } - return updated; - } - /** - * Transforms a SourceFile into an AMD module. - * - * @param node The SourceFile node. - */ - function transformAMDModule(node) { - var define = ts.createIdentifier("define"); - var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); - return transformAsynchronousModule(node, define, moduleName, /*includeNonAmdDependencies*/ true); - } - /** - * Transforms a SourceFile into a UMD module. - * - * @param node The SourceFile node. - */ - function transformUMDModule(node) { - var define = ts.createIdentifier("define"); - ts.setEmitFlags(define, 16 /* UMDDefine */); - return transformAsynchronousModule(node, define, /*moduleName*/ undefined, /*includeNonAmdDependencies*/ false); - } - /** - * Transforms a SourceFile into an AMD or UMD module. - * - * @param node The SourceFile node. - * @param define The expression used to define the module. - * @param moduleName An expression for the module name, if available. - * @param includeNonAmdDependencies A value indicating whether to incldue any non-AMD dependencies. - */ - function transformAsynchronousModule(node, define, moduleName, includeNonAmdDependencies) { - // An AMD define function has the following shape: - // - // define(id?, dependencies?, factory); - // - // This has the shape of the following: - // - // 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 _a = collectAsynchronousDependencies(node, includeNonAmdDependencies), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; - // Create an updated SourceFile: - // - // define(moduleName?, ["module1", "module2"], function ... - return updateSourceFile(node, [ - ts.createStatement(ts.createCall(define, - /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ - // Add the dependency array argument: - // - // ["require", "exports", module1", "module2", ...] - ts.createArrayLiteral([ - ts.createLiteral("require"), - ts.createLiteral("exports") - ].concat(aliasedModuleNames, unaliasedModuleNames)), - // Add the module body function argument: - // - // function (require, exports, module1, module2) ... - ts.createFunctionExpression( - /*asteriskToken*/ undefined, - /*name*/ undefined, - /*typeParameters*/ undefined, [ - ts.createParameter("require"), - ts.createParameter("exports") - ].concat(importAliasNames), - /*type*/ undefined, transformAsynchronousModuleBody(node)) - ]))) - ]); - } - /** - * Transforms a SourceFile into an AMD or UMD module body. - * - * @param node The SourceFile node. - */ - function transformAsynchronousModuleBody(node) { - startLexicalEnvironment(); - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, visitor); - // Visit each statement of the module body. - ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); - // End the lexical environment for the module body - // and merge any new lexical declarations. - ts.addRange(statements, endLexicalEnvironment()); - // Append the 'export =' statement if provided. - addExportEqualsIfNeeded(statements, /*emitAsReturn*/ true); - var body = ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true); - if (hasExportStarsToExportValues) { - // If we have any `export * from ...` declarations - // we need to inform the emitter to add the __export helper. - ts.setEmitFlags(body, 2 /* EmitExportStar */); - } - return body; - } - function addExportEqualsIfNeeded(statements, emitAsReturn) { - if (exportEquals && resolver.isValueAliasDeclaration(exportEquals)) { - if (emitAsReturn) { - var statement = ts.createReturn(exportEquals.expression, - /*location*/ exportEquals); - ts.setEmitFlags(statement, 12288 /* NoTokenSourceMaps */ | 49152 /* NoComments */); - statements.push(statement); - } - else { - var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), exportEquals.expression), - /*location*/ exportEquals); - ts.setEmitFlags(statement, 49152 /* NoComments */); - statements.push(statement); - } - } - } - /** - * Visits a node at the top level of the source file. - * - * @param node The node. - */ - function visitor(node) { - switch (node.kind) { - case 230 /* ImportDeclaration */: - return visitImportDeclaration(node); - case 229 /* ImportEqualsDeclaration */: - return visitImportEqualsDeclaration(node); - case 236 /* ExportDeclaration */: - return visitExportDeclaration(node); - case 235 /* ExportAssignment */: - return visitExportAssignment(node); - case 200 /* VariableStatement */: - return visitVariableStatement(node); - case 220 /* FunctionDeclaration */: - return visitFunctionDeclaration(node); - case 221 /* ClassDeclaration */: - return visitClassDeclaration(node); - case 202 /* ExpressionStatement */: - return visitExpressionStatement(node); - default: - // This visitor does not descend into the tree, as export/import statements - // are only transformed at the top level of a file. - return node; - } - } - /** - * Visits an ImportDeclaration node. - * - * @param node The ImportDeclaration node. - */ - function visitImportDeclaration(node) { - if (!ts.contains(externalImports, node)) { - return undefined; - } - var statements = []; - var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); - if (moduleKind !== ts.ModuleKind.AMD) { - if (!node.importClause) { - // import "mod"; - statements.push(ts.createStatement(createRequireCall(node), - /*location*/ node)); - } - else { - var variables = []; - if (namespaceDeclaration && !ts.isDefaultImport(node)) { - // import * as n from "mod"; - variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), - /*type*/ undefined, createRequireCall(node))); - } - else { - // import d from "mod"; - // import { x, y } from "mod"; - // import d, { x, y } from "mod"; - // import d, * as n from "mod"; - variables.push(ts.createVariableDeclaration(ts.getGeneratedNameForNode(node), - /*type*/ undefined, createRequireCall(node))); - if (namespaceDeclaration && ts.isDefaultImport(node)) { - variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), - /*type*/ undefined, ts.getGeneratedNameForNode(node))); - } - } - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createConstDeclarationList(variables), - /*location*/ node)); - } - } - else if (namespaceDeclaration && ts.isDefaultImport(node)) { - // import d, * as n from "mod"; - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), - /*type*/ undefined, ts.getGeneratedNameForNode(node), - /*location*/ node) - ]))); - } - addExportImportAssignments(statements, node); - return ts.singleOrMany(statements); - } - function visitImportEqualsDeclaration(node) { - if (!ts.contains(externalImports, node)) { - return undefined; - } - // Set emitFlags on the name of the importEqualsDeclaration - // This is so the printer will not substitute the identifier - ts.setEmitFlags(node.name, 128 /* NoSubstitution */); - var statements = []; - if (moduleKind !== ts.ModuleKind.AMD) { - if (ts.hasModifier(node, 1 /* Export */)) { - statements.push(ts.createStatement(createExportAssignment(node.name, createRequireCall(node)), - /*location*/ node)); - } - else { - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(ts.getSynthesizedClone(node.name), - /*type*/ undefined, createRequireCall(node)) - ], - /*location*/ undefined, - /*flags*/ languageVersion >= 2 /* ES6 */ ? 2 /* Const */ : 0 /* None */), - /*location*/ node)); - } - } - else { - if (ts.hasModifier(node, 1 /* Export */)) { - statements.push(ts.createStatement(createExportAssignment(node.name, node.name), - /*location*/ node)); - } - } - addExportImportAssignments(statements, node); - return statements; - } - function visitExportDeclaration(node) { - if (!ts.contains(externalImports, node)) { - return undefined; - } - var generatedName = ts.getGeneratedNameForNode(node); - if (node.exportClause) { - var statements = []; - // export { x, y } from "mod"; - if (moduleKind !== ts.ModuleKind.AMD) { - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(generatedName, - /*type*/ undefined, createRequireCall(node)) - ]), - /*location*/ node)); - } - for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { - var specifier = _a[_i]; - if (resolver.isValueAliasDeclaration(specifier)) { - var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); - statements.push(ts.createStatement(createExportAssignment(specifier.name, exportedValue), - /*location*/ specifier)); - } - } - return ts.singleOrMany(statements); - } - else if (resolver.moduleExportsSomeValue(node.moduleSpecifier)) { - // export * from "mod"; - return ts.createStatement(ts.createCall(ts.createIdentifier("__export"), - /*typeArguments*/ undefined, [ - moduleKind !== ts.ModuleKind.AMD - ? createRequireCall(node) - : generatedName - ]), - /*location*/ node); - } - } - function visitExportAssignment(node) { - if (!node.isExportEquals) { - if (ts.nodeIsSynthesized(node) || resolver.isValueAliasDeclaration(node)) { - var statements = []; - addExportDefault(statements, node.expression, /*location*/ node); - return statements; - } - } - return undefined; - } - function addExportDefault(statements, expression, location) { - tryAddExportDefaultCompat(statements); - statements.push(ts.createStatement(createExportAssignment(ts.createIdentifier("default"), expression), location)); - } - function tryAddExportDefaultCompat(statements) { - var original = ts.getOriginalNode(currentSourceFile); - ts.Debug.assert(original.kind === 256 /* SourceFile */); - if (!original.symbol.exports["___esModule"]) { - if (languageVersion === 0 /* ES3 */) { - statements.push(ts.createStatement(createExportAssignment(ts.createIdentifier("__esModule"), ts.createLiteral(true)))); - } - else { - statements.push(ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), - /*typeArguments*/ undefined, [ - ts.createIdentifier("exports"), - ts.createLiteral("__esModule"), - ts.createObjectLiteral([ - ts.createPropertyAssignment("value", ts.createLiteral(true)) - ]) - ]))); - } - } - } - function addExportImportAssignments(statements, node) { - if (ts.isImportEqualsDeclaration(node)) { - addExportMemberAssignments(statements, node.name); - } - else { - var names = ts.reduceEachChild(node, collectExportMembers, []); - for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_33 = names_1[_i]; - addExportMemberAssignments(statements, name_33); - } - } - } - function collectExportMembers(names, node) { - if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node) && ts.isDeclaration(node)) { - var name_34 = node.name; - if (ts.isIdentifier(name_34)) { - names.push(name_34); - } - } - return ts.reduceEachChild(node, collectExportMembers, names); - } - function addExportMemberAssignments(statements, name) { - if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { - for (var _i = 0, _a = exportSpecifiers[name.text]; _i < _a.length; _i++) { - var specifier = _a[_i]; - statements.push(ts.startOnNewLine(ts.createStatement(createExportAssignment(specifier.name, name), - /*location*/ specifier.name))); - } - } - } - function addExportMemberAssignment(statements, node) { - if (ts.hasModifier(node, 512 /* Default */)) { - addExportDefault(statements, getDeclarationName(node), /*location*/ node); - } - else { - statements.push(createExportStatement(node.name, ts.setEmitFlags(ts.getSynthesizedClone(node.name), 262144 /* LocalName */), /*location*/ node)); - } - } - function visitVariableStatement(node) { - // If the variable is for a generated declaration, - // we should maintain it and just strip off the 'export' modifier if necessary. - var originalKind = ts.getOriginalNode(node).kind; - if (originalKind === 225 /* ModuleDeclaration */ || - originalKind === 224 /* EnumDeclaration */ || - originalKind === 221 /* ClassDeclaration */) { - if (!ts.hasModifier(node, 1 /* Export */)) { - return node; - } - return ts.setOriginalNode(ts.createVariableStatement( - /*modifiers*/ undefined, node.declarationList), node); - } - var resultStatements = []; - // If we're exporting these variables, then these just become assignments to 'exports.blah'. - // We only want to emit assignments for variables with initializers. - if (ts.hasModifier(node, 1 /* Export */)) { - var variables = ts.getInitializedVariables(node.declarationList); - if (variables.length > 0) { - var inlineAssignments = ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable)), node); - resultStatements.push(inlineAssignments); - } - } - else { - resultStatements.push(node); - } - // While we might not have been exported here, each variable might have been exported - // later on in an export specifier (e.g. `export {foo as blah, bar}`). - for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - addExportMemberAssignmentsForBindingName(resultStatements, decl.name); - } - return resultStatements; - } - /** - * Creates appropriate assignments for each binding identifier that is exported in an export specifier, - * and inserts it into 'resultStatements'. - */ - function addExportMemberAssignmentsForBindingName(resultStatements, name) { - if (ts.isBindingPattern(name)) { - for (var _i = 0, _a = name.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (!ts.isOmittedExpression(element)) { - addExportMemberAssignmentsForBindingName(resultStatements, element.name); - } - } - } - else { - if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { - var sourceFileId = ts.getOriginalNodeId(currentSourceFile); - if (!bindingNameExportSpecifiersForFileMap[sourceFileId]) { - bindingNameExportSpecifiersForFileMap[sourceFileId] = ts.createMap(); - } - bindingNameExportSpecifiersForFileMap[sourceFileId][name.text] = exportSpecifiers[name.text]; - addExportMemberAssignments(resultStatements, name); - } - } - } - function transformInitializedVariable(node) { - var name = node.name; - if (ts.isBindingPattern(name)) { - return ts.flattenVariableDestructuringToExpression(context, node, hoistVariableDeclaration, getModuleMemberName, visitor); - } - else { - return ts.createAssignment(getModuleMemberName(name), ts.visitNode(node.initializer, visitor, ts.isExpression)); - } - } - function visitFunctionDeclaration(node) { - var statements = []; - var name = node.name || ts.getGeneratedNameForNode(node); - if (ts.hasModifier(node, 1 /* Export */)) { - statements.push(ts.setOriginalNode(ts.createFunctionDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, node.asteriskToken, name, - /*typeParameters*/ undefined, node.parameters, - /*type*/ undefined, node.body, - /*location*/ node), - /*original*/ node)); - addExportMemberAssignment(statements, node); - } - else { - statements.push(node); - } - if (node.name) { - addExportMemberAssignments(statements, node.name); - } - return ts.singleOrMany(statements); - } - function visitClassDeclaration(node) { - var statements = []; - var name = node.name || ts.getGeneratedNameForNode(node); - if (ts.hasModifier(node, 1 /* Export */)) { - statements.push(ts.setOriginalNode(ts.createClassDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, name, - /*typeParameters*/ undefined, node.heritageClauses, node.members, - /*location*/ node), - /*original*/ node)); - addExportMemberAssignment(statements, node); - } - else { - statements.push(node); - } - // Decorators end up creating a series of assignment expressions which overwrite - // the local binding that we export, so we need to defer from exporting decorated classes - // until the decoration assignments take place. We do this when visiting expression-statements. - if (node.name && !(node.decorators && node.decorators.length)) { - addExportMemberAssignments(statements, node.name); - } - return ts.singleOrMany(statements); - } - function visitExpressionStatement(node) { - var original = ts.getOriginalNode(node); - var origKind = original.kind; - if (origKind === 224 /* EnumDeclaration */ || origKind === 225 /* ModuleDeclaration */) { - return visitExpressionStatementForEnumOrNamespaceDeclaration(node, original); - } - else if (origKind === 221 /* ClassDeclaration */) { - // The decorated assignment for a class name may need to be transformed. - var classDecl = original; - if (classDecl.name) { - var statements = [node]; - addExportMemberAssignments(statements, classDecl.name); - return statements; - } - } - return node; - } - function visitExpressionStatementForEnumOrNamespaceDeclaration(node, original) { - var statements = [node]; - // Preserve old behavior for enums in which a variable statement is emitted after the body itself. - if (ts.hasModifier(original, 1 /* Export */) && - original.kind === 224 /* EnumDeclaration */ && - ts.isFirstDeclarationOfKind(original, 224 /* EnumDeclaration */)) { - addVarForExportedEnumOrNamespaceDeclaration(statements, original); - } - addExportMemberAssignments(statements, original.name); - return statements; - } - /** - * Adds a trailing VariableStatement for an enum or module declaration. - */ - function addVarForExportedEnumOrNamespaceDeclaration(statements, node) { - var transformedStatement = ts.createVariableStatement( - /*modifiers*/ undefined, [ts.createVariableDeclaration(getDeclarationName(node), - /*type*/ undefined, ts.createPropertyAccess(ts.createIdentifier("exports"), getDeclarationName(node)))], - /*location*/ node); - ts.setEmitFlags(transformedStatement, 49152 /* NoComments */); - statements.push(transformedStatement); - } - function getDeclarationName(node) { - return node.name ? ts.getSynthesizedClone(node.name) : ts.getGeneratedNameForNode(node); - } - function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 256 /* SourceFile */) { - bindingNameExportSpecifiersMap = bindingNameExportSpecifiersForFileMap[ts.getOriginalNodeId(node)]; - previousOnEmitNode(emitContext, node, emitCallback); - bindingNameExportSpecifiersMap = undefined; - } - else { - previousOnEmitNode(emitContext, node, emitCallback); - } - } - /** - * Hooks node substitutions. - * - * @param node The node to substitute. - * @param isExpression A value indicating whether the node is to be used in an expression - * position. - */ - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1 /* Expression */) { - return substituteExpression(node); - } - else if (ts.isShorthandPropertyAssignment(node)) { - return substituteShorthandPropertyAssignment(node); - } - return node; - } - function substituteShorthandPropertyAssignment(node) { - var name = node.name; - var exportedOrImportedName = substituteExpressionIdentifier(name); - if (exportedOrImportedName !== name) { - // A shorthand property with an assignment initializer is probably part of a - // destructuring assignment - if (node.objectAssignmentInitializer) { - var initializer = ts.createAssignment(exportedOrImportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name, initializer, /*location*/ node); - } - return ts.createPropertyAssignment(name, exportedOrImportedName, /*location*/ node); - } - return node; - } - function substituteExpression(node) { - switch (node.kind) { - case 69 /* Identifier */: - return substituteExpressionIdentifier(node); - case 187 /* BinaryExpression */: - return substituteBinaryExpression(node); - case 186 /* PostfixUnaryExpression */: - case 185 /* PrefixUnaryExpression */: - return substituteUnaryExpression(node); - } - return node; - } - function substituteExpressionIdentifier(node) { - return trySubstituteExportedName(node) - || trySubstituteImportedName(node) - || node; - } - function substituteBinaryExpression(node) { - var left = node.left; - // If the left-hand-side of the binaryExpression is an identifier and its is export through export Specifier - if (ts.isIdentifier(left) && ts.isAssignmentOperator(node.operatorToken.kind)) { - if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, left.text)) { - ts.setEmitFlags(node, 128 /* NoSubstitution */); - var nestedExportAssignment = void 0; - for (var _i = 0, _a = bindingNameExportSpecifiersMap[left.text]; _i < _a.length; _i++) { - var specifier = _a[_i]; - nestedExportAssignment = nestedExportAssignment ? - createExportAssignment(specifier.name, nestedExportAssignment) : - createExportAssignment(specifier.name, node); - } - return nestedExportAssignment; - } - } - return node; - } - function substituteUnaryExpression(node) { - // Because how the compiler only parse plusplus and minusminus to be either prefixUnaryExpression or postFixUnaryExpression depended on where they are - // We don't need to check that the operator has SyntaxKind.plusplus or SyntaxKind.minusminus - var operator = node.operator; - var operand = node.operand; - if (ts.isIdentifier(operand) && bindingNameExportSpecifiersForFileMap) { - if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, operand.text)) { - ts.setEmitFlags(node, 128 /* NoSubstitution */); - var transformedUnaryExpression = void 0; - if (node.kind === 186 /* PostfixUnaryExpression */) { - transformedUnaryExpression = ts.createBinary(operand, ts.createToken(operator === 41 /* PlusPlusToken */ ? 57 /* PlusEqualsToken */ : 58 /* MinusEqualsToken */), ts.createLiteral(1), - /*location*/ node); - // We have to set no substitution flag here to prevent visit the binary expression and substitute it again as we will preform all necessary substitution in here - ts.setEmitFlags(transformedUnaryExpression, 128 /* NoSubstitution */); - } - var nestedExportAssignment = void 0; - for (var _i = 0, _a = bindingNameExportSpecifiersMap[operand.text]; _i < _a.length; _i++) { - var specifier = _a[_i]; - nestedExportAssignment = nestedExportAssignment ? - createExportAssignment(specifier.name, nestedExportAssignment) : - createExportAssignment(specifier.name, transformedUnaryExpression || node); - } - return nestedExportAssignment; - } - } - return node; - } - function trySubstituteExportedName(node) { - var emitFlags = ts.getEmitFlags(node); - if ((emitFlags & 262144 /* LocalName */) === 0) { - var container = resolver.getReferencedExportContainer(node, (emitFlags & 131072 /* ExportName */) !== 0); - if (container) { - if (container.kind === 256 /* SourceFile */) { - return ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node), - /*location*/ node); - } - } - } - return undefined; - } - function trySubstituteImportedName(node) { - if ((ts.getEmitFlags(node) & 262144 /* LocalName */) === 0) { - var declaration = resolver.getReferencedImportDeclaration(node); - if (declaration) { - if (ts.isImportClause(declaration)) { - if (languageVersion >= 1 /* ES5 */) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent), ts.createIdentifier("default"), - /*location*/ node); - } - else { - // TODO: ES3 transform to handle x.default -> x["default"] - return ts.createElementAccess(ts.getGeneratedNameForNode(declaration.parent), ts.createLiteral("default"), - /*location*/ node); - } - } - else if (ts.isImportSpecifier(declaration)) { - var name_35 = declaration.propertyName || declaration.name; - if (name_35.originalKeywordKind === 77 /* DefaultKeyword */ && languageVersion <= 0 /* ES3 */) { - // TODO: ES3 transform to handle x.default -> x["default"] - return ts.createElementAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.createLiteral(name_35.text), - /*location*/ node); - } - else { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.getSynthesizedClone(name_35), - /*location*/ node); - } - } - } - } - return undefined; - } - function getModuleMemberName(name) { - return ts.createPropertyAccess(ts.createIdentifier("exports"), name, - /*location*/ name); - } - function createRequireCall(importNode) { - var moduleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); - var args = []; - if (ts.isDefined(moduleName)) { - args.push(moduleName); - } - return ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, args); - } - function createExportStatement(name, value, location) { - var statement = ts.createStatement(createExportAssignment(name, value)); - statement.startsOnNewLine = true; - if (location) { - ts.setSourceMapRange(statement, location); - } - return statement; - } - function createExportAssignment(name, value) { - return ts.createAssignment(name.originalKeywordKind === 77 /* DefaultKeyword */ && languageVersion === 0 /* ES3 */ - ? ts.createElementAccess(ts.createIdentifier("exports"), ts.createLiteral(name.text)) - : ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value); - } - function collectAsynchronousDependencies(node, includeNonAmdDependencies) { - // names of modules with corresponding parameter in the factory function - var aliasedModuleNames = []; - // names of modules with no corresponding parameters in factory function - var unaliasedModuleNames = []; - // names of the parameters in the factory function; these - // parameters need to match the indexes of the corresponding - // module names in aliasedModuleNames. - var importAliasNames = []; - // Fill in amd-dependency tags - for (var _i = 0, _a = node.amdDependencies; _i < _a.length; _i++) { - var amdDependency = _a[_i]; - if (amdDependency.name) { - aliasedModuleNames.push(ts.createLiteral(amdDependency.path)); - importAliasNames.push(ts.createParameter(amdDependency.name)); - } - else { - unaliasedModuleNames.push(ts.createLiteral(amdDependency.path)); - } - } - for (var _b = 0, externalImports_3 = externalImports; _b < externalImports_3.length; _b++) { - var importNode = externalImports_3[_b]; - // Find the name of the external module - var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); - // Find the name of the module alias, if there is one - var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile); - if (includeNonAmdDependencies && importAliasName) { - // Set emitFlags on the name of the classDeclaration - // This is so that when printer will not substitute the identifier - ts.setEmitFlags(importAliasName, 128 /* NoSubstitution */); - aliasedModuleNames.push(externalModuleName); - importAliasNames.push(ts.createParameter(importAliasName)); - } - else { - unaliasedModuleNames.push(externalModuleName); - } - } - return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; - } - function updateSourceFile(node, statements) { - var updated = ts.getMutableClone(node); - updated.statements = ts.createNodeArray(statements, node.statements); - return updated; - } - var _a; - } - ts.transformModule = transformModule; -})(ts || (ts = {})); /// /// /*@internal*/ @@ -47454,9 +45774,9 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 241 /* JsxElement */: + case 242 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 242 /* JsxSelfClosingElement */: + case 243 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); case 248 /* JsxExpression */: return visitJsxExpression(node); @@ -47467,13 +45787,13 @@ var ts; } function transformJsxChildToExpression(node) { switch (node.kind) { - case 244 /* JsxText */: + case 10 /* JsxText */: return visitJsxText(node); case 248 /* JsxExpression */: return visitJsxExpression(node); - case 241 /* JsxElement */: + case 242 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 242 /* JsxSelfClosingElement */: + case 243 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); default: ts.Debug.failBadSyntaxKind(node); @@ -47614,16 +45934,16 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 241 /* JsxElement */) { + if (node.kind === 242 /* JsxElement */) { return getTagName(node.openingElement); } else { - var name_36 = node.tagName; - if (ts.isIdentifier(name_36) && ts.isIntrinsicJsxName(name_36.text)) { - return ts.createLiteral(name_36.text); + var name_31 = node.tagName; + if (ts.isIdentifier(name_31) && ts.isIntrinsicJsxName(name_31.text)) { + return ts.createLiteral(name_31.text); } else { - return ts.createExpressionFromEntityName(name_36); + return ts.createExpressionFromEntityName(name_31); } } } @@ -47909,7 +46229,384 @@ var ts; /*@internal*/ var ts; (function (ts) { - function transformES7(context) { + function transformES2017(context) { + var ES2017SubstitutionFlags; + (function (ES2017SubstitutionFlags) { + /** Enables substitutions for async methods with `super` calls. */ + ES2017SubstitutionFlags[ES2017SubstitutionFlags["AsyncMethodsWithSuper"] = 1] = "AsyncMethodsWithSuper"; + })(ES2017SubstitutionFlags || (ES2017SubstitutionFlags = {})); + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; + var resolver = context.getEmitResolver(); + var compilerOptions = context.getCompilerOptions(); + var languageVersion = ts.getEmitScriptTarget(compilerOptions); + // These variables contain state that changes as we descend into the tree. + var currentSourceFileExternalHelpersModuleName; + /** + * Keeps track of whether expression substitution has been enabled for specific edge cases. + * They are persisted between each SourceFile transformation and should not be reset. + */ + var enabledSubstitutions; + /** + * Keeps track of whether we are within any containing namespaces when performing + * just-in-time substitution while printing an expression identifier. + */ + var applicableSubstitutions; + /** + * This keeps track of containers where `super` is valid, for use with + * just-in-time substitution for `super` expressions inside of async methods. + */ + var currentSuperContainer; + // Save the previous transformation hooks. + var previousOnEmitNode = context.onEmitNode; + var previousOnSubstituteNode = context.onSubstituteNode; + // Set new transformation hooks. + context.onEmitNode = onEmitNode; + context.onSubstituteNode = onSubstituteNode; + var currentScope; + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } + currentSourceFileExternalHelpersModuleName = node.externalHelpersModuleName; + return ts.visitEachChild(node, visitor, context); + } + function visitor(node) { + if (node.transformFlags & 16 /* ES2017 */) { + return visitorWorker(node); + } + else if (node.transformFlags & 32 /* ContainsES2017 */) { + return ts.visitEachChild(node, visitor, context); + } + return node; + } + function visitorWorker(node) { + switch (node.kind) { + case 119 /* AsyncKeyword */: + // ES2017 async modifier should be elided for targets < ES2017 + return undefined; + case 185 /* AwaitExpression */: + // ES2017 'await' expressions must be transformed for targets < ES2017. + return visitAwaitExpression(node); + case 148 /* MethodDeclaration */: + // ES2017 method declarations may be 'async' + return visitMethodDeclaration(node); + case 221 /* FunctionDeclaration */: + // ES2017 function declarations may be 'async' + return visitFunctionDeclaration(node); + case 180 /* FunctionExpression */: + // ES2017 function expressions may be 'async' + return visitFunctionExpression(node); + case 181 /* ArrowFunction */: + // ES2017 arrow functions may be 'async' + return visitArrowFunction(node); + default: + ts.Debug.failBadSyntaxKind(node); + return node; + } + } + /** + * Visits an await expression. + * + * This function will be called any time a ES2017 await expression is encountered. + * + * @param node The await expression node. + */ + function visitAwaitExpression(node) { + return ts.setOriginalNode(ts.createYield( + /*asteriskToken*/ undefined, ts.visitNode(node.expression, visitor, ts.isExpression), + /*location*/ node), node); + } + /** + * Visits a method declaration of a class. + * + * This function will be called when one of the following conditions are met: + * - The node is marked as async + * + * @param node The method node. + */ + function visitMethodDeclaration(node) { + if (!ts.isAsyncFunctionLike(node)) { + return node; + } + var method = ts.createMethod( + /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, + /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), + /*type*/ undefined, transformFunctionBody(node), + /*location*/ node); + // While we emit the source map for the node after skipping decorators and modifiers, + // we need to emit the comments for the original range. + ts.setCommentRange(method, node); + ts.setSourceMapRange(method, ts.moveRangePastDecorators(node)); + ts.setOriginalNode(method, node); + return method; + } + /** + * Visits a function declaration. + * + * This function will be called when one of the following conditions are met: + * - The node is marked async + * + * @param node The function node. + */ + function visitFunctionDeclaration(node) { + if (!ts.isAsyncFunctionLike(node)) { + return node; + } + var func = ts.createFunctionDeclaration( + /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, + /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), + /*type*/ undefined, transformFunctionBody(node), + /*location*/ node); + ts.setOriginalNode(func, node); + return func; + } + /** + * Visits a function expression node. + * + * This function will be called when one of the following conditions are met: + * - The node is marked async + * + * @param node The function expression node. + */ + function visitFunctionExpression(node) { + if (!ts.isAsyncFunctionLike(node)) { + return node; + } + if (ts.nodeIsMissing(node.body)) { + return ts.createOmittedExpression(); + } + var func = ts.createFunctionExpression( + /*modifiers*/ undefined, node.asteriskToken, node.name, + /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), + /*type*/ undefined, transformFunctionBody(node), + /*location*/ node); + ts.setOriginalNode(func, node); + return func; + } + /** + * @remarks + * This function will be called when one of the following conditions are met: + * - The node is marked async + */ + function visitArrowFunction(node) { + if (!ts.isAsyncFunctionLike(node)) { + return node; + } + var func = ts.createArrowFunction(ts.visitNodes(node.modifiers, visitor, ts.isModifier), + /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), + /*type*/ undefined, node.equalsGreaterThanToken, transformConciseBody(node), + /*location*/ node); + ts.setOriginalNode(func, node); + return func; + } + function transformFunctionBody(node) { + return transformAsyncFunctionBody(node); + } + function transformConciseBody(node) { + return transformAsyncFunctionBody(node); + } + function transformFunctionBodyWorker(body, start) { + if (start === void 0) { start = 0; } + var savedCurrentScope = currentScope; + currentScope = body; + startLexicalEnvironment(); + var statements = ts.visitNodes(body.statements, visitor, ts.isStatement, start); + var visited = ts.updateBlock(body, statements); + var declarations = endLexicalEnvironment(); + currentScope = savedCurrentScope; + return ts.mergeFunctionBodyLexicalEnvironment(visited, declarations); + } + function transformAsyncFunctionBody(node) { + var nodeType = node.original ? node.original.type : node.type; + var promiseConstructor = languageVersion < 2 /* ES2015 */ ? getPromiseConstructor(nodeType) : undefined; + var isArrowFunction = node.kind === 181 /* ArrowFunction */; + var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* CaptureArguments */) !== 0; + // An async function is emit as an outer function that calls an inner + // generator function. To preserve lexical bindings, we pass the current + // `this` and `arguments` objects to `__awaiter`. The generator function + // passed to `__awaiter` is executed inside of the callback to the + // promise constructor. + if (!isArrowFunction) { + var statements = []; + var statementOffset = ts.addPrologueDirectives(statements, node.body.statements, /*ensureUseStrict*/ false, visitor); + statements.push(ts.createReturn(ts.createAwaiterHelper(currentSourceFileExternalHelpersModuleName, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body, statementOffset)))); + var block = ts.createBlock(statements, /*location*/ node.body, /*multiLine*/ true); + // Minor optimization, emit `_super` helper to capture `super` access in an arrow. + // This step isn't needed if we eventually transform this to ES5. + if (languageVersion >= 2 /* ES2015 */) { + if (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) { + enableSubstitutionForAsyncMethodsWithSuper(); + ts.setEmitFlags(block, 8 /* EmitAdvancedSuperHelper */); + } + else if (resolver.getNodeCheckFlags(node) & 2048 /* AsyncMethodWithSuper */) { + enableSubstitutionForAsyncMethodsWithSuper(); + ts.setEmitFlags(block, 4 /* EmitSuperHelper */); + } + } + return block; + } + else { + return ts.createAwaiterHelper(currentSourceFileExternalHelpersModuleName, hasLexicalArguments, promiseConstructor, transformConciseBodyWorker(node.body, /*forceBlockFunctionBody*/ true)); + } + } + function transformConciseBodyWorker(body, forceBlockFunctionBody) { + if (ts.isBlock(body)) { + return transformFunctionBodyWorker(body); + } + else { + startLexicalEnvironment(); + var visited = ts.visitNode(body, visitor, ts.isConciseBody); + var declarations = endLexicalEnvironment(); + var merged = ts.mergeFunctionBodyLexicalEnvironment(visited, declarations); + if (forceBlockFunctionBody && !ts.isBlock(merged)) { + return ts.createBlock([ + ts.createReturn(merged) + ]); + } + else { + return merged; + } + } + } + function getPromiseConstructor(type) { + var typeName = ts.getEntityNameFromTypeNode(type); + if (typeName && ts.isEntityName(typeName)) { + var serializationKind = resolver.getTypeReferenceSerializationKind(typeName); + if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue + || serializationKind === ts.TypeReferenceSerializationKind.Unknown) { + return typeName; + } + } + return undefined; + } + function enableSubstitutionForAsyncMethodsWithSuper() { + if ((enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) === 0) { + enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; + // We need to enable substitutions for call, property access, and element access + // if we need to rewrite super calls. + context.enableSubstitution(175 /* CallExpression */); + context.enableSubstitution(173 /* PropertyAccessExpression */); + context.enableSubstitution(174 /* ElementAccessExpression */); + // We need to be notified when entering and exiting declarations that bind super. + context.enableEmitNotification(222 /* ClassDeclaration */); + context.enableEmitNotification(148 /* MethodDeclaration */); + context.enableEmitNotification(150 /* GetAccessor */); + context.enableEmitNotification(151 /* SetAccessor */); + context.enableEmitNotification(149 /* Constructor */); + } + } + function substituteExpression(node) { + switch (node.kind) { + case 173 /* PropertyAccessExpression */: + return substitutePropertyAccessExpression(node); + case 174 /* ElementAccessExpression */: + return substituteElementAccessExpression(node); + case 175 /* CallExpression */: + if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) { + return substituteCallExpression(node); + } + break; + } + return node; + } + function substitutePropertyAccessExpression(node) { + if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && node.expression.kind === 96 /* SuperKeyword */) { + var flags = getSuperContainerAsyncMethodFlags(); + if (flags) { + return createSuperAccessInAsyncMethod(ts.createLiteral(node.name.text), flags, node); + } + } + return node; + } + function substituteElementAccessExpression(node) { + if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && node.expression.kind === 96 /* SuperKeyword */) { + var flags = getSuperContainerAsyncMethodFlags(); + if (flags) { + return createSuperAccessInAsyncMethod(node.argumentExpression, flags, node); + } + } + return node; + } + function substituteCallExpression(node) { + var expression = node.expression; + if (ts.isSuperProperty(expression)) { + var flags = getSuperContainerAsyncMethodFlags(); + if (flags) { + var argumentExpression = ts.isPropertyAccessExpression(expression) + ? substitutePropertyAccessExpression(expression) + : substituteElementAccessExpression(expression); + return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), + /*typeArguments*/ undefined, [ + ts.createThis() + ].concat(node.arguments)); + } + } + return node; + } + function isSuperContainer(node) { + var kind = node.kind; + return kind === 222 /* ClassDeclaration */ + || kind === 149 /* Constructor */ + || kind === 148 /* MethodDeclaration */ + || kind === 150 /* GetAccessor */ + || kind === 151 /* SetAccessor */; + } + /** + * Hook for node emit. + * + * @param node The node to emit. + * @param emit A callback used to emit the node in the printer. + */ + function onEmitNode(emitContext, node, emitCallback) { + var savedApplicableSubstitutions = applicableSubstitutions; + var savedCurrentSuperContainer = currentSuperContainer; + // If we need to support substitutions for `super` in an async method, + // we should track it here. + if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && isSuperContainer(node)) { + currentSuperContainer = node; + } + previousOnEmitNode(emitContext, node, emitCallback); + applicableSubstitutions = savedApplicableSubstitutions; + currentSuperContainer = savedCurrentSuperContainer; + } + /** + * Hooks node substitutions. + * + * @param node The node to substitute. + * @param isExpression A value indicating whether the node is to be used in an expression + * position. + */ + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1 /* Expression */) { + return substituteExpression(node); + } + return node; + } + function createSuperAccessInAsyncMethod(argumentExpression, flags, location) { + if (flags & 4096 /* AsyncMethodWithSuperBinding */) { + return ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), + /*typeArguments*/ undefined, [argumentExpression]), "value", location); + } + else { + return ts.createCall(ts.createIdentifier("_super"), + /*typeArguments*/ undefined, [argumentExpression], location); + } + } + function getSuperContainerAsyncMethodFlags() { + return currentSuperContainer !== undefined + && resolver.getNodeCheckFlags(currentSuperContainer) & (2048 /* AsyncMethodWithSuper */ | 4096 /* AsyncMethodWithSuperBinding */); + } + } + ts.transformES2017 = transformES2017; +})(ts || (ts = {})); +/// +/// +/*@internal*/ +var ts; +(function (ts) { + function transformES2016(context) { var hoistVariableDeclaration = context.hoistVariableDeclaration; return transformSourceFile; function transformSourceFile(node) { @@ -47919,10 +46616,10 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if (node.transformFlags & 16 /* ES7 */) { + if (node.transformFlags & 64 /* ES2016 */) { return visitorWorker(node); } - else if (node.transformFlags & 32 /* ContainsES7 */) { + else if (node.transformFlags & 128 /* ContainsES2016 */) { return ts.visitEachChild(node, visitor, context); } else { @@ -47931,7 +46628,7 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return visitBinaryExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -47939,10 +46636,10 @@ var ts; } } function visitBinaryExpression(node) { - // We are here because ES7 adds support for the exponentiation operator. + // We are here because ES2016 adds support for the exponentiation operator. var left = ts.visitNode(node.left, visitor, ts.isExpression); var right = ts.visitNode(node.right, visitor, ts.isExpression); - if (node.operatorToken.kind === 60 /* AsteriskAsteriskEqualsToken */) { + if (node.operatorToken.kind === 61 /* AsteriskAsteriskEqualsToken */) { var target = void 0; var value = void 0; if (ts.isElementAccessExpression(left)) { @@ -47969,7 +46666,7 @@ var ts; } return ts.createAssignment(target, ts.createMathPow(value, right, /*location*/ node), /*location*/ node); } - else if (node.operatorToken.kind === 38 /* AsteriskAsteriskToken */) { + else if (node.operatorToken.kind === 39 /* AsteriskAsteriskToken */) { // Transforms `a ** b` into `Math.pow(a, b)` return ts.createMathPow(left, right, /*location*/ node); } @@ -47979,7 +46676,2474 @@ var ts; } } } - ts.transformES7 = transformES7; + ts.transformES2016 = transformES2016; +})(ts || (ts = {})); +/// +/// +/*@internal*/ +var ts; +(function (ts) { + var ES2015SubstitutionFlags; + (function (ES2015SubstitutionFlags) { + /** Enables substitutions for captured `this` */ + ES2015SubstitutionFlags[ES2015SubstitutionFlags["CapturedThis"] = 1] = "CapturedThis"; + /** Enables substitutions for block-scoped bindings. */ + ES2015SubstitutionFlags[ES2015SubstitutionFlags["BlockScopedBindings"] = 2] = "BlockScopedBindings"; + })(ES2015SubstitutionFlags || (ES2015SubstitutionFlags = {})); + var CopyDirection; + (function (CopyDirection) { + CopyDirection[CopyDirection["ToOriginal"] = 0] = "ToOriginal"; + CopyDirection[CopyDirection["ToOutParameter"] = 1] = "ToOutParameter"; + })(CopyDirection || (CopyDirection = {})); + var Jump; + (function (Jump) { + Jump[Jump["Break"] = 2] = "Break"; + Jump[Jump["Continue"] = 4] = "Continue"; + Jump[Jump["Return"] = 8] = "Return"; + })(Jump || (Jump = {})); + var SuperCaptureResult; + (function (SuperCaptureResult) { + /** + * A capture may have been added for calls to 'super', but + * the caller should emit subsequent statements normally. + */ + SuperCaptureResult[SuperCaptureResult["NoReplacement"] = 0] = "NoReplacement"; + /** + * A call to 'super()' got replaced with a capturing statement like: + * + * var _this = _super.call(...) || this; + * + * Callers should skip the current statement. + */ + SuperCaptureResult[SuperCaptureResult["ReplaceSuperCapture"] = 1] = "ReplaceSuperCapture"; + /** + * A call to 'super()' got replaced with a capturing statement like: + * + * return _super.call(...) || this; + * + * Callers should skip the current statement and avoid any returns of '_this'. + */ + SuperCaptureResult[SuperCaptureResult["ReplaceWithReturn"] = 2] = "ReplaceWithReturn"; + })(SuperCaptureResult || (SuperCaptureResult = {})); + function transformES2015(context) { + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; + var resolver = context.getEmitResolver(); + var previousOnSubstituteNode = context.onSubstituteNode; + var previousOnEmitNode = context.onEmitNode; + context.onEmitNode = onEmitNode; + context.onSubstituteNode = onSubstituteNode; + var currentSourceFile; + var currentText; + var currentParent; + var currentNode; + var enclosingVariableStatement; + var enclosingBlockScopeContainer; + var enclosingBlockScopeContainerParent; + var enclosingFunction; + var enclosingNonArrowFunction; + var enclosingNonAsyncFunctionBody; + /** + * Used to track if we are emitting body of the converted loop + */ + var convertedLoopState; + /** + * Keeps track of whether substitutions have been enabled for specific cases. + * They are persisted between each SourceFile transformation and should not + * be reset. + */ + var enabledSubstitutions; + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } + currentSourceFile = node; + currentText = node.text; + return ts.visitNode(node, visitor, ts.isSourceFile); + } + function visitor(node) { + return saveStateAndInvoke(node, dispatcher); + } + function dispatcher(node) { + return convertedLoopState + ? visitorForConvertedLoopWorker(node) + : visitorWorker(node); + } + function saveStateAndInvoke(node, f) { + var savedEnclosingFunction = enclosingFunction; + var savedEnclosingNonArrowFunction = enclosingNonArrowFunction; + var savedEnclosingNonAsyncFunctionBody = enclosingNonAsyncFunctionBody; + var savedEnclosingBlockScopeContainer = enclosingBlockScopeContainer; + var savedEnclosingBlockScopeContainerParent = enclosingBlockScopeContainerParent; + var savedEnclosingVariableStatement = enclosingVariableStatement; + var savedCurrentParent = currentParent; + var savedCurrentNode = currentNode; + var savedConvertedLoopState = convertedLoopState; + if (ts.nodeStartsNewLexicalEnvironment(node)) { + // don't treat content of nodes that start new lexical environment as part of converted loop copy + convertedLoopState = undefined; + } + onBeforeVisitNode(node); + var visited = f(node); + convertedLoopState = savedConvertedLoopState; + enclosingFunction = savedEnclosingFunction; + enclosingNonArrowFunction = savedEnclosingNonArrowFunction; + enclosingNonAsyncFunctionBody = savedEnclosingNonAsyncFunctionBody; + enclosingBlockScopeContainer = savedEnclosingBlockScopeContainer; + enclosingBlockScopeContainerParent = savedEnclosingBlockScopeContainerParent; + enclosingVariableStatement = savedEnclosingVariableStatement; + currentParent = savedCurrentParent; + currentNode = savedCurrentNode; + return visited; + } + function shouldCheckNode(node) { + return (node.transformFlags & 256 /* ES2015 */) !== 0 || + node.kind === 215 /* LabeledStatement */ || + (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)); + } + function visitorWorker(node) { + if (shouldCheckNode(node)) { + return visitJavaScript(node); + } + else if (node.transformFlags & 512 /* ContainsES2015 */) { + return ts.visitEachChild(node, visitor, context); + } + else { + return node; + } + } + function visitorForConvertedLoopWorker(node) { + var result; + if (shouldCheckNode(node)) { + result = visitJavaScript(node); + } + else { + result = visitNodesInConvertedLoop(node); + } + return result; + } + function visitNodesInConvertedLoop(node) { + switch (node.kind) { + case 212 /* ReturnStatement */: + return visitReturnStatement(node); + case 201 /* VariableStatement */: + return visitVariableStatement(node); + case 214 /* SwitchStatement */: + return visitSwitchStatement(node); + case 211 /* BreakStatement */: + case 210 /* ContinueStatement */: + return visitBreakOrContinueStatement(node); + case 98 /* ThisKeyword */: + return visitThisKeyword(node); + case 70 /* Identifier */: + return visitIdentifier(node); + default: + return ts.visitEachChild(node, visitor, context); + } + } + function visitJavaScript(node) { + switch (node.kind) { + case 83 /* ExportKeyword */: + return node; + case 222 /* ClassDeclaration */: + return visitClassDeclaration(node); + case 193 /* ClassExpression */: + return visitClassExpression(node); + case 143 /* Parameter */: + return visitParameter(node); + case 221 /* FunctionDeclaration */: + return visitFunctionDeclaration(node); + case 181 /* ArrowFunction */: + return visitArrowFunction(node); + case 180 /* FunctionExpression */: + return visitFunctionExpression(node); + case 219 /* VariableDeclaration */: + return visitVariableDeclaration(node); + case 70 /* Identifier */: + return visitIdentifier(node); + case 220 /* VariableDeclarationList */: + return visitVariableDeclarationList(node); + case 215 /* LabeledStatement */: + return visitLabeledStatement(node); + case 205 /* DoStatement */: + return visitDoStatement(node); + case 206 /* WhileStatement */: + return visitWhileStatement(node); + case 207 /* ForStatement */: + return visitForStatement(node); + case 208 /* ForInStatement */: + return visitForInStatement(node); + case 209 /* ForOfStatement */: + return visitForOfStatement(node); + case 203 /* ExpressionStatement */: + return visitExpressionStatement(node); + case 172 /* ObjectLiteralExpression */: + return visitObjectLiteralExpression(node); + case 254 /* ShorthandPropertyAssignment */: + return visitShorthandPropertyAssignment(node); + case 171 /* ArrayLiteralExpression */: + return visitArrayLiteralExpression(node); + case 175 /* CallExpression */: + return visitCallExpression(node); + case 176 /* NewExpression */: + return visitNewExpression(node); + case 179 /* ParenthesizedExpression */: + return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); + case 188 /* BinaryExpression */: + return visitBinaryExpression(node, /*needsDestructuringValue*/ true); + case 12 /* NoSubstitutionTemplateLiteral */: + case 13 /* TemplateHead */: + case 14 /* TemplateMiddle */: + case 15 /* TemplateTail */: + return visitTemplateLiteral(node); + case 177 /* TaggedTemplateExpression */: + return visitTaggedTemplateExpression(node); + case 190 /* TemplateExpression */: + return visitTemplateExpression(node); + case 191 /* YieldExpression */: + return visitYieldExpression(node); + case 96 /* SuperKeyword */: + return visitSuperKeyword(); + case 191 /* YieldExpression */: + // `yield` will be handled by a generators transform. + return ts.visitEachChild(node, visitor, context); + case 148 /* MethodDeclaration */: + return visitMethodDeclaration(node); + case 256 /* SourceFile */: + return visitSourceFileNode(node); + case 201 /* VariableStatement */: + return visitVariableStatement(node); + default: + ts.Debug.failBadSyntaxKind(node); + return ts.visitEachChild(node, visitor, context); + } + } + function onBeforeVisitNode(node) { + if (currentNode) { + if (ts.isBlockScope(currentNode, currentParent)) { + enclosingBlockScopeContainer = currentNode; + enclosingBlockScopeContainerParent = currentParent; + } + if (ts.isFunctionLike(currentNode)) { + enclosingFunction = currentNode; + if (currentNode.kind !== 181 /* ArrowFunction */) { + enclosingNonArrowFunction = currentNode; + if (!(ts.getEmitFlags(currentNode) & 2097152 /* AsyncFunctionBody */)) { + enclosingNonAsyncFunctionBody = currentNode; + } + } + } + // keep track of the enclosing variable statement when in the context of + // variable statements, variable declarations, binding elements, and binding + // patterns. + switch (currentNode.kind) { + case 201 /* VariableStatement */: + enclosingVariableStatement = currentNode; + break; + case 220 /* VariableDeclarationList */: + case 219 /* VariableDeclaration */: + case 170 /* BindingElement */: + case 168 /* ObjectBindingPattern */: + case 169 /* ArrayBindingPattern */: + break; + default: + enclosingVariableStatement = undefined; + } + } + currentParent = currentNode; + currentNode = node; + } + function visitSwitchStatement(node) { + ts.Debug.assert(convertedLoopState !== undefined); + var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; + // for switch statement allow only non-labeled break + convertedLoopState.allowedNonLabeledJumps |= 2 /* Break */; + var result = ts.visitEachChild(node, visitor, context); + convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; + return result; + } + function visitReturnStatement(node) { + ts.Debug.assert(convertedLoopState !== undefined); + convertedLoopState.nonLocalJumps |= 8 /* Return */; + return ts.createReturn(ts.createObjectLiteral([ + ts.createPropertyAssignment(ts.createIdentifier("value"), node.expression + ? ts.visitNode(node.expression, visitor, ts.isExpression) + : ts.createVoidZero()) + ])); + } + function visitThisKeyword(node) { + ts.Debug.assert(convertedLoopState !== undefined); + if (enclosingFunction && enclosingFunction.kind === 181 /* ArrowFunction */) { + // if the enclosing function is an ArrowFunction is then we use the captured 'this' keyword. + convertedLoopState.containsLexicalThis = true; + return node; + } + return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this")); + } + function visitIdentifier(node) { + if (!convertedLoopState) { + return node; + } + if (ts.isGeneratedIdentifier(node)) { + return node; + } + if (node.text !== "arguments" && !resolver.isArgumentsLocalBinding(node)) { + return node; + } + return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = ts.createUniqueName("arguments")); + } + function visitBreakOrContinueStatement(node) { + if (convertedLoopState) { + // check if we can emit break/continue as is + // it is possible if either + // - break/continue is labeled and label is located inside the converted loop + // - break/continue is non-labeled and located in non-converted loop/switch statement + var jump = node.kind === 211 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || + (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); + if (!canUseBreakOrContinue) { + var labelMarker = void 0; + if (!node.label) { + if (node.kind === 211 /* BreakStatement */) { + convertedLoopState.nonLocalJumps |= 2 /* Break */; + labelMarker = "break"; + } + else { + convertedLoopState.nonLocalJumps |= 4 /* Continue */; + // note: return value is emitted only to simplify debugging, call to converted loop body does not do any dispatching on it. + labelMarker = "continue"; + } + } + else { + if (node.kind === 211 /* BreakStatement */) { + labelMarker = "break-" + node.label.text; + setLabeledJump(convertedLoopState, /*isBreak*/ true, node.label.text, labelMarker); + } + else { + labelMarker = "continue-" + node.label.text; + setLabeledJump(convertedLoopState, /*isBreak*/ false, node.label.text, labelMarker); + } + } + var returnExpression = ts.createLiteral(labelMarker); + if (convertedLoopState.loopOutParameters.length) { + var outParams = convertedLoopState.loopOutParameters; + var expr = void 0; + for (var i = 0; i < outParams.length; i++) { + var copyExpr = copyOutParameter(outParams[i], 1 /* ToOutParameter */); + if (i === 0) { + expr = copyExpr; + } + else { + expr = ts.createBinary(expr, 25 /* CommaToken */, copyExpr); + } + } + returnExpression = ts.createBinary(expr, 25 /* CommaToken */, returnExpression); + } + return ts.createReturn(returnExpression); + } + } + return ts.visitEachChild(node, visitor, context); + } + /** + * Visits a ClassDeclaration and transforms it into a variable statement. + * + * @param node A ClassDeclaration node. + */ + function visitClassDeclaration(node) { + // [source] + // class C { } + // + // [output] + // var C = (function () { + // function C() { + // } + // return C; + // }()); + var modifierFlags = ts.getModifierFlags(node); + var isExported = modifierFlags & 1 /* Export */; + var isDefault = modifierFlags & 512 /* Default */; + // Add an `export` modifier to the statement if needed (for `--target es5 --module es6`) + var modifiers = isExported && !isDefault + ? ts.filter(node.modifiers, isExportModifier) + : undefined; + var statement = ts.createVariableStatement(modifiers, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(getDeclarationName(node, /*allowComments*/ true), + /*type*/ undefined, transformClassLikeDeclarationToExpression(node)) + ]), + /*location*/ node); + ts.setOriginalNode(statement, node); + ts.startOnNewLine(statement); + // Add an `export default` statement for default exports (for `--target es5 --module es6`) + if (isExported && isDefault) { + var statements = [statement]; + statements.push(ts.createExportAssignment( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*isExportEquals*/ false, getDeclarationName(node, /*allowComments*/ false))); + return statements; + } + return statement; + } + function isExportModifier(node) { + return node.kind === 83 /* ExportKeyword */; + } + /** + * Visits a ClassExpression and transforms it into an expression. + * + * @param node A ClassExpression node. + */ + function visitClassExpression(node) { + // [source] + // C = class { } + // + // [output] + // C = (function () { + // function class_1() { + // } + // return class_1; + // }()) + return transformClassLikeDeclarationToExpression(node); + } + /** + * Transforms a ClassExpression or ClassDeclaration into an expression. + * + * @param node A ClassExpression or ClassDeclaration node. + */ + function transformClassLikeDeclarationToExpression(node) { + // [source] + // class C extends D { + // constructor() {} + // method() {} + // get prop() {} + // set prop(v) {} + // } + // + // [output] + // (function (_super) { + // __extends(C, _super); + // function C() { + // } + // C.prototype.method = function () {} + // Object.defineProperty(C.prototype, "prop", { + // get: function() {}, + // set: function() {}, + // enumerable: true, + // configurable: true + // }); + // return C; + // }(D)) + if (node.name) { + enableSubstitutionsForBlockScopedBindings(); + } + var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); + var classFunction = ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, extendsClauseElement ? [ts.createParameter("_super")] : [], + /*type*/ undefined, transformClassBody(node, extendsClauseElement)); + // To preserve the behavior of the old emitter, we explicitly indent + // the body of the function here if it was requested in an earlier + // transformation. + if (ts.getEmitFlags(node) & 524288 /* Indented */) { + ts.setEmitFlags(classFunction, 524288 /* Indented */); + } + // "inner" and "outer" below are added purely to preserve source map locations from + // the old emitter + var inner = ts.createPartiallyEmittedExpression(classFunction); + inner.end = node.end; + ts.setEmitFlags(inner, 49152 /* NoComments */); + var outer = ts.createPartiallyEmittedExpression(inner); + outer.end = ts.skipTrivia(currentText, node.pos); + ts.setEmitFlags(outer, 49152 /* NoComments */); + return ts.createParen(ts.createCall(outer, + /*typeArguments*/ undefined, extendsClauseElement + ? [ts.visitNode(extendsClauseElement.expression, visitor, ts.isExpression)] + : [])); + } + /** + * Transforms a ClassExpression or ClassDeclaration into a function body. + * + * @param node A ClassExpression or ClassDeclaration node. + * @param extendsClauseElement The expression for the class `extends` clause. + */ + function transformClassBody(node, extendsClauseElement) { + var statements = []; + startLexicalEnvironment(); + addExtendsHelperIfNeeded(statements, node, extendsClauseElement); + addConstructor(statements, node, extendsClauseElement); + addClassMembers(statements, node); + // Create a synthetic text range for the return statement. + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 17 /* CloseBraceToken */); + var localName = getLocalName(node); + // The following partially-emitted expression exists purely to align our sourcemap + // emit with the original emitter. + var outer = ts.createPartiallyEmittedExpression(localName); + outer.end = closingBraceLocation.end; + ts.setEmitFlags(outer, 49152 /* NoComments */); + var statement = ts.createReturn(outer); + statement.pos = closingBraceLocation.pos; + ts.setEmitFlags(statement, 49152 /* NoComments */ | 12288 /* NoTokenSourceMaps */); + statements.push(statement); + ts.addRange(statements, endLexicalEnvironment()); + var block = ts.createBlock(ts.createNodeArray(statements, /*location*/ node.members), /*location*/ undefined, /*multiLine*/ true); + ts.setEmitFlags(block, 49152 /* NoComments */); + return block; + } + /** + * Adds a call to the `__extends` helper if needed for a class. + * + * @param statements The statements of the class body function. + * @param node The ClassExpression or ClassDeclaration node. + * @param extendsClauseElement The expression for the class `extends` clause. + */ + function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) { + if (extendsClauseElement) { + statements.push(ts.createStatement(ts.createExtendsHelper(currentSourceFile.externalHelpersModuleName, getDeclarationName(node)), + /*location*/ extendsClauseElement)); + } + } + /** + * Adds the constructor of the class to a class body function. + * + * @param statements The statements of the class body function. + * @param node The ClassExpression or ClassDeclaration node. + * @param extendsClauseElement The expression for the class `extends` clause. + */ + function addConstructor(statements, node, extendsClauseElement) { + var constructor = ts.getFirstConstructorWithBody(node); + var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); + var constructorFunction = ts.createFunctionDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, getDeclarationName(node), + /*typeParameters*/ undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), + /*type*/ undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), + /*location*/ constructor || node); + if (extendsClauseElement) { + ts.setEmitFlags(constructorFunction, 256 /* CapturesThis */); + } + statements.push(constructorFunction); + } + /** + * Transforms the parameters of the constructor declaration of a class. + * + * @param constructor The constructor for the class. + * @param hasSynthesizedSuper A value indicating whether the constructor starts with a + * synthesized `super` call. + */ + function transformConstructorParameters(constructor, hasSynthesizedSuper) { + // If the TypeScript transformer needed to synthesize a constructor for property + // initializers, it would have also added a synthetic `...args` parameter and + // `super` call. + // If this is the case, we do not include the synthetic `...args` parameter and + // will instead use the `arguments` object in ES5/3. + if (constructor && !hasSynthesizedSuper) { + return ts.visitNodes(constructor.parameters, visitor, ts.isParameter); + } + return []; + } + /** + * Transforms the body of a constructor declaration of a class. + * + * @param constructor The constructor for the class. + * @param node The node which contains the constructor. + * @param extendsClauseElement The expression for the class `extends` clause. + * @param hasSynthesizedSuper A value indicating whether the constructor starts with a + * synthesized `super` call. + */ + function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { + var statements = []; + startLexicalEnvironment(); + var statementOffset = -1; + if (hasSynthesizedSuper) { + // If a super call has already been synthesized, + // we're going to assume that we should just transform everything after that. + // The assumption is that no prior step in the pipeline has added any prologue directives. + statementOffset = 1; + } + else if (constructor) { + // Otherwise, try to emit all potential prologue directives first. + statementOffset = ts.addPrologueDirectives(statements, constructor.body.statements, /*ensureUseStrict*/ false, visitor); + } + if (constructor) { + addDefaultValueAssignmentsIfNeeded(statements, constructor); + addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); + ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); + } + var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, !!extendsClauseElement, hasSynthesizedSuper, statementOffset); + // The last statement expression was replaced. Skip it. + if (superCaptureStatus === 1 /* ReplaceSuperCapture */ || superCaptureStatus === 2 /* ReplaceWithReturn */) { + statementOffset++; + } + if (constructor) { + var body = saveStateAndInvoke(constructor, function (constructor) { return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, /*start*/ statementOffset); }); + ts.addRange(statements, body); + } + // Return `_this` unless we're sure enough that it would be pointless to add a return statement. + // If there's a constructor that we can tell returns in enough places, then we *do not* want to add a return. + if (extendsClauseElement + && superCaptureStatus !== 2 /* ReplaceWithReturn */ + && !(constructor && isSufficientlyCoveredByReturnStatements(constructor.body))) { + statements.push(ts.createReturn(ts.createIdentifier("_this"))); + } + ts.addRange(statements, endLexicalEnvironment()); + var block = ts.createBlock(ts.createNodeArray(statements, + /*location*/ constructor ? constructor.body.statements : node.members), + /*location*/ constructor ? constructor.body : node, + /*multiLine*/ true); + if (!constructor) { + ts.setEmitFlags(block, 49152 /* NoComments */); + } + return block; + } + /** + * We want to try to avoid emitting a return statement in certain cases if a user already returned something. + * It would generate obviously dead code, so we'll try to make things a little bit prettier + * by doing a minimal check on whether some common patterns always explicitly return. + */ + function isSufficientlyCoveredByReturnStatements(statement) { + // A return statement is considered covered. + if (statement.kind === 212 /* ReturnStatement */) { + return true; + } + else if (statement.kind === 204 /* IfStatement */) { + var ifStatement = statement; + if (ifStatement.elseStatement) { + return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && + isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); + } + } + else if (statement.kind === 200 /* Block */) { + var lastStatement = ts.lastOrUndefined(statement.statements); + if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { + return true; + } + } + return false; + } + /** + * Declares a `_this` variable for derived classes and for when arrow functions capture `this`. + * + * @returns The new statement offset into the `statements` array. + */ + function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, hasExtendsClause, hasSynthesizedSuper, statementOffset) { + // If this isn't a derived class, just capture 'this' for arrow functions if necessary. + if (!hasExtendsClause) { + if (ctor) { + addCaptureThisForNodeIfNeeded(statements, ctor); + } + return 0 /* NoReplacement */; + } + // We must be here because the user didn't write a constructor + // but we needed to call 'super(...args)' anyway as per 14.5.14 of the ES2016 spec. + // If that's the case we can just immediately return the result of a 'super()' call. + if (!ctor) { + statements.push(ts.createReturn(createDefaultSuperCallOrThis())); + return 2 /* ReplaceWithReturn */; + } + // The constructor exists, but it and the 'super()' call it contains were generated + // for something like property initializers. + // Create a captured '_this' variable and assume it will subsequently be used. + if (hasSynthesizedSuper) { + captureThisForNode(statements, ctor, createDefaultSuperCallOrThis()); + enableSubstitutionsForCapturedThis(); + return 1 /* ReplaceSuperCapture */; + } + // Most of the time, a 'super' call will be the first real statement in a constructor body. + // In these cases, we'd like to transform these into a *single* statement instead of a declaration + // followed by an assignment statement for '_this'. For instance, if we emitted without an initializer, + // we'd get: + // + // var _this; + // _this = _super.call(...) || this; + // + // instead of + // + // var _this = _super.call(...) || this; + // + // Additionally, if the 'super()' call is the last statement, we should just avoid capturing + // entirely and immediately return the result like so: + // + // return _super.call(...) || this; + // + var firstStatement; + var superCallExpression; + var ctorStatements = ctor.body.statements; + if (statementOffset < ctorStatements.length) { + firstStatement = ctorStatements[statementOffset]; + if (firstStatement.kind === 203 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { + var superCall = firstStatement.expression; + superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); + } + } + // Return the result if we have an immediate super() call on the last statement. + if (superCallExpression && statementOffset === ctorStatements.length - 1) { + statements.push(ts.createReturn(superCallExpression)); + return 2 /* ReplaceWithReturn */; + } + // Perform the capture. + captureThisForNode(statements, ctor, superCallExpression, firstStatement); + // If we're actually replacing the original statement, we need to signal this to the caller. + if (superCallExpression) { + return 1 /* ReplaceSuperCapture */; + } + return 0 /* NoReplacement */; + } + function createDefaultSuperCallOrThis() { + var actualThis = ts.createThis(); + ts.setEmitFlags(actualThis, 128 /* NoSubstitution */); + var superCall = ts.createFunctionApply(ts.createIdentifier("_super"), actualThis, ts.createIdentifier("arguments")); + return ts.createLogicalOr(superCall, actualThis); + } + /** + * Visits a parameter declaration. + * + * @param node A ParameterDeclaration node. + */ + function visitParameter(node) { + if (node.dotDotDotToken) { + // rest parameters are elided + return undefined; + } + else if (ts.isBindingPattern(node.name)) { + // Binding patterns are converted into a generated name and are + // evaluated inside the function body. + return ts.setOriginalNode(ts.createParameter(ts.getGeneratedNameForNode(node), + /*initializer*/ undefined, + /*location*/ node), + /*original*/ node); + } + else if (node.initializer) { + // Initializers are elided + return ts.setOriginalNode(ts.createParameter(node.name, + /*initializer*/ undefined, + /*location*/ node), + /*original*/ node); + } + else { + return node; + } + } + /** + * Gets a value indicating whether we need to add default value assignments for a + * function-like node. + * + * @param node A function-like node. + */ + function shouldAddDefaultValueAssignments(node) { + return (node.transformFlags & 262144 /* ContainsDefaultValueAssignments */) !== 0; + } + /** + * Adds statements to the body of a function-like node if it contains parameters with + * binding patterns or initializers. + * + * @param statements The statements for the new function body. + * @param node A function-like node. + */ + function addDefaultValueAssignmentsIfNeeded(statements, node) { + if (!shouldAddDefaultValueAssignments(node)) { + return; + } + for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { + var parameter = _a[_i]; + var name_32 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; + // A rest parameter cannot have a binding pattern or an initializer, + // so let's just ignore it. + if (dotDotDotToken) { + continue; + } + if (ts.isBindingPattern(name_32)) { + addDefaultValueAssignmentForBindingPattern(statements, parameter, name_32, initializer); + } + else if (initializer) { + addDefaultValueAssignmentForInitializer(statements, parameter, name_32, initializer); + } + } + } + /** + * Adds statements to the body of a function-like node for parameters with binding patterns + * + * @param statements The statements for the new function body. + * @param parameter The parameter for the function. + * @param name The name of the parameter. + * @param initializer The initializer for the parameter. + */ + function addDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer) { + var temp = ts.getGeneratedNameForNode(parameter); + // In cases where a binding pattern is simply '[]' or '{}', + // we usually don't want to emit a var declaration; however, in the presence + // of an initializer, we must emit that expression to preserve side effects. + if (name.elements.length > 0) { + statements.push(ts.setEmitFlags(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList(ts.flattenParameterDestructuring(parameter, temp, visitor))), 8388608 /* CustomPrologue */)); + } + else if (initializer) { + statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 8388608 /* CustomPrologue */)); + } + } + /** + * Adds statements to the body of a function-like node for parameters with initializers. + * + * @param statements The statements for the new function body. + * @param parameter The parameter for the function. + * @param name The name of the parameter. + * @param initializer The initializer for the parameter. + */ + function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) { + initializer = ts.visitNode(initializer, visitor, ts.isExpression); + var statement = ts.createIf(ts.createStrictEquality(ts.getSynthesizedClone(name), ts.createVoidZero()), ts.setEmitFlags(ts.createBlock([ + ts.createStatement(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 1536 /* NoSourceMap */), ts.setEmitFlags(initializer, 1536 /* NoSourceMap */ | ts.getEmitFlags(initializer)), + /*location*/ parameter)) + ], /*location*/ parameter), 32 /* SingleLine */ | 1024 /* NoTrailingSourceMap */ | 12288 /* NoTokenSourceMaps */), + /*elseStatement*/ undefined, + /*location*/ parameter); + statement.startsOnNewLine = true; + ts.setEmitFlags(statement, 12288 /* NoTokenSourceMaps */ | 1024 /* NoTrailingSourceMap */ | 8388608 /* CustomPrologue */); + statements.push(statement); + } + /** + * Gets a value indicating whether we need to add statements to handle a rest parameter. + * + * @param node A ParameterDeclaration node. + * @param inConstructorWithSynthesizedSuper A value indicating whether the parameter is + * part of a constructor declaration with a + * synthesized call to `super` + */ + function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) { + return node && node.dotDotDotToken && node.name.kind === 70 /* Identifier */ && !inConstructorWithSynthesizedSuper; + } + /** + * Adds statements to the body of a function-like node if it contains a rest parameter. + * + * @param statements The statements for the new function body. + * @param node A function-like node. + * @param inConstructorWithSynthesizedSuper A value indicating whether the parameter is + * part of a constructor declaration with a + * synthesized call to `super` + */ + function addRestParameterIfNeeded(statements, node, inConstructorWithSynthesizedSuper) { + var parameter = ts.lastOrUndefined(node.parameters); + if (!shouldAddRestParameter(parameter, inConstructorWithSynthesizedSuper)) { + return; + } + // `declarationName` is the name of the local declaration for the parameter. + var declarationName = ts.getMutableClone(parameter.name); + ts.setEmitFlags(declarationName, 1536 /* NoSourceMap */); + // `expressionName` is the name of the parameter used in expressions. + var expressionName = ts.getSynthesizedClone(parameter.name); + var restIndex = node.parameters.length - 1; + var temp = ts.createLoopVariable(); + // var param = []; + statements.push(ts.setEmitFlags(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(declarationName, + /*type*/ undefined, ts.createArrayLiteral([])) + ]), + /*location*/ parameter), 8388608 /* CustomPrologue */)); + // for (var _i = restIndex; _i < arguments.length; _i++) { + // param[_i - restIndex] = arguments[_i]; + // } + var forStatement = ts.createFor(ts.createVariableDeclarationList([ + ts.createVariableDeclaration(temp, /*type*/ undefined, ts.createLiteral(restIndex)) + ], /*location*/ parameter), ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length"), + /*location*/ parameter), ts.createPostfixIncrement(temp, /*location*/ parameter), ts.createBlock([ + ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp)), + /*location*/ parameter)) + ])); + ts.setEmitFlags(forStatement, 8388608 /* CustomPrologue */); + ts.startOnNewLine(forStatement); + statements.push(forStatement); + } + /** + * Adds a statement to capture the `this` of a function declaration if it is needed. + * + * @param statements The statements for the new function body. + * @param node A node. + */ + function addCaptureThisForNodeIfNeeded(statements, node) { + if (node.transformFlags & 65536 /* ContainsCapturedLexicalThis */ && node.kind !== 181 /* ArrowFunction */) { + captureThisForNode(statements, node, ts.createThis()); + } + } + function captureThisForNode(statements, node, initializer, originalStatement) { + enableSubstitutionsForCapturedThis(); + var captureThisStatement = ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration("_this", + /*type*/ undefined, initializer) + ]), originalStatement); + ts.setEmitFlags(captureThisStatement, 49152 /* NoComments */ | 8388608 /* CustomPrologue */); + ts.setSourceMapRange(captureThisStatement, node); + statements.push(captureThisStatement); + } + /** + * Adds statements to the class body function for a class to define the members of the + * class. + * + * @param statements The statements for the class body function. + * @param node The ClassExpression or ClassDeclaration node. + */ + function addClassMembers(statements, node) { + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + switch (member.kind) { + case 199 /* SemicolonClassElement */: + statements.push(transformSemicolonClassElementToStatement(member)); + break; + case 148 /* MethodDeclaration */: + statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member)); + break; + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + var accessors = ts.getAllAccessorDeclarations(node.members, member); + if (member === accessors.firstAccessor) { + statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors)); + } + break; + case 149 /* Constructor */: + // Constructors are handled in visitClassExpression/visitClassDeclaration + break; + default: + ts.Debug.failBadSyntaxKind(node); + break; + } + } + } + /** + * Transforms a SemicolonClassElement into a statement for a class body function. + * + * @param member The SemicolonClassElement node. + */ + function transformSemicolonClassElementToStatement(member) { + return ts.createEmptyStatement(/*location*/ member); + } + /** + * Transforms a MethodDeclaration into a statement for a class body function. + * + * @param receiver The receiver for the member. + * @param member The MethodDeclaration node. + */ + function transformClassMethodDeclarationToStatement(receiver, member) { + var commentRange = ts.getCommentRange(member); + var sourceMapRange = ts.getSourceMapRange(member); + var func = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined); + ts.setEmitFlags(func, 49152 /* NoComments */); + ts.setSourceMapRange(func, sourceMapRange); + var statement = ts.createStatement(ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), + /*location*/ member.name), func), + /*location*/ member); + ts.setOriginalNode(statement, member); + ts.setCommentRange(statement, commentRange); + // The location for the statement is used to emit comments only. + // No source map should be emitted for this statement to align with the + // old emitter. + ts.setEmitFlags(statement, 1536 /* NoSourceMap */); + return statement; + } + /** + * Transforms a set of related of get/set accessors into a statement for a class body function. + * + * @param receiver The receiver for the member. + * @param accessors The set of related get/set accessors. + */ + function transformAccessorsToStatement(receiver, accessors) { + var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, /*startsOnNewLine*/ false), + /*location*/ ts.getSourceMapRange(accessors.firstAccessor)); + // The location for the statement is used to emit source maps only. + // No comments should be emitted for this statement to align with the + // old emitter. + ts.setEmitFlags(statement, 49152 /* NoComments */); + return statement; + } + /** + * Transforms a set of related get/set accessors into an expression for either a class + * body function or an ObjectLiteralExpression with computed properties. + * + * @param receiver The receiver for the member. + */ + function transformAccessorsToExpression(receiver, _a, startsOnNewLine) { + var firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; + // To align with source maps in the old emitter, the receiver and property name + // arguments are both mapped contiguously to the accessor name. + var target = ts.getMutableClone(receiver); + ts.setEmitFlags(target, 49152 /* NoComments */ | 1024 /* NoTrailingSourceMap */); + ts.setSourceMapRange(target, firstAccessor.name); + var propertyName = ts.createExpressionForPropertyName(ts.visitNode(firstAccessor.name, visitor, ts.isPropertyName)); + ts.setEmitFlags(propertyName, 49152 /* NoComments */ | 512 /* NoLeadingSourceMap */); + ts.setSourceMapRange(propertyName, firstAccessor.name); + var properties = []; + if (getAccessor) { + var getterFunction = transformFunctionLikeToExpression(getAccessor, /*location*/ undefined, /*name*/ undefined); + ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); + ts.setEmitFlags(getterFunction, 16384 /* NoLeadingComments */); + var getter = ts.createPropertyAssignment("get", getterFunction); + ts.setCommentRange(getter, ts.getCommentRange(getAccessor)); + properties.push(getter); + } + if (setAccessor) { + var setterFunction = transformFunctionLikeToExpression(setAccessor, /*location*/ undefined, /*name*/ undefined); + ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); + ts.setEmitFlags(setterFunction, 16384 /* NoLeadingComments */); + var setter = ts.createPropertyAssignment("set", setterFunction); + ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); + properties.push(setter); + } + properties.push(ts.createPropertyAssignment("enumerable", ts.createLiteral(true)), ts.createPropertyAssignment("configurable", ts.createLiteral(true))); + var call = ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), + /*typeArguments*/ undefined, [ + target, + propertyName, + ts.createObjectLiteral(properties, /*location*/ undefined, /*multiLine*/ true) + ]); + if (startsOnNewLine) { + call.startsOnNewLine = true; + } + return call; + } + /** + * Visits an ArrowFunction and transforms it into a FunctionExpression. + * + * @param node An ArrowFunction node. + */ + function visitArrowFunction(node) { + if (node.transformFlags & 32768 /* ContainsLexicalThis */) { + enableSubstitutionsForCapturedThis(); + } + var func = transformFunctionLikeToExpression(node, /*location*/ node, /*name*/ undefined); + ts.setEmitFlags(func, 256 /* CapturesThis */); + return func; + } + /** + * Visits a FunctionExpression node. + * + * @param node a FunctionExpression node. + */ + function visitFunctionExpression(node) { + return transformFunctionLikeToExpression(node, /*location*/ node, node.name); + } + /** + * Visits a FunctionDeclaration node. + * + * @param node a FunctionDeclaration node. + */ + function visitFunctionDeclaration(node) { + return ts.setOriginalNode(ts.createFunctionDeclaration( + /*decorators*/ undefined, node.modifiers, node.asteriskToken, node.name, + /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), + /*type*/ undefined, transformFunctionBody(node), + /*location*/ node), + /*original*/ node); + } + /** + * Transforms a function-like node into a FunctionExpression. + * + * @param node The function-like node to transform. + * @param location The source-map location for the new FunctionExpression. + * @param name The name of the new FunctionExpression. + */ + function transformFunctionLikeToExpression(node, location, name) { + var savedContainingNonArrowFunction = enclosingNonArrowFunction; + if (node.kind !== 181 /* ArrowFunction */) { + enclosingNonArrowFunction = node; + } + var expression = ts.setOriginalNode(ts.createFunctionExpression( + /*modifiers*/ undefined, node.asteriskToken, name, + /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), + /*type*/ undefined, saveStateAndInvoke(node, transformFunctionBody), location), + /*original*/ node); + enclosingNonArrowFunction = savedContainingNonArrowFunction; + return expression; + } + /** + * Transforms the body of a function-like node. + * + * @param node A function-like node. + */ + function transformFunctionBody(node) { + var multiLine = false; // indicates whether the block *must* be emitted as multiple lines + var singleLine = false; // indicates whether the block *may* be emitted as a single line + var statementsLocation; + var closeBraceLocation; + var statements = []; + var body = node.body; + var statementOffset; + startLexicalEnvironment(); + if (ts.isBlock(body)) { + // ensureUseStrict is false because no new prologue-directive should be added. + // addPrologueDirectives will simply put already-existing directives at the beginning of the target statement-array + statementOffset = ts.addPrologueDirectives(statements, body.statements, /*ensureUseStrict*/ false, visitor); + } + addCaptureThisForNodeIfNeeded(statements, node); + addDefaultValueAssignmentsIfNeeded(statements, node); + addRestParameterIfNeeded(statements, node, /*inConstructorWithSynthesizedSuper*/ false); + // If we added any generated statements, this must be a multi-line block. + if (!multiLine && statements.length > 0) { + multiLine = true; + } + if (ts.isBlock(body)) { + statementsLocation = body.statements; + ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, statementOffset)); + // If the original body was a multi-line block, this must be a multi-line block. + if (!multiLine && body.multiLine) { + multiLine = true; + } + } + else { + ts.Debug.assert(node.kind === 181 /* ArrowFunction */); + // To align with the old emitter, we use a synthetic end position on the location + // for the statement list we synthesize when we down-level an arrow function with + // an expression function body. This prevents both comments and source maps from + // being emitted for the end position only. + statementsLocation = ts.moveRangeEnd(body, -1); + var equalsGreaterThanToken = node.equalsGreaterThanToken; + if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { + if (ts.rangeEndIsOnSameLineAsRangeStart(equalsGreaterThanToken, body, currentSourceFile)) { + singleLine = true; + } + else { + multiLine = true; + } + } + var expression = ts.visitNode(body, visitor, ts.isExpression); + var returnStatement = ts.createReturn(expression, /*location*/ body); + ts.setEmitFlags(returnStatement, 12288 /* NoTokenSourceMaps */ | 1024 /* NoTrailingSourceMap */ | 32768 /* NoTrailingComments */); + statements.push(returnStatement); + // To align with the source map emit for the old emitter, we set a custom + // source map location for the close brace. + closeBraceLocation = body; + } + var lexicalEnvironment = endLexicalEnvironment(); + ts.addRange(statements, lexicalEnvironment); + // If we added any final generated statements, this must be a multi-line block + if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { + multiLine = true; + } + var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), node.body, multiLine); + if (!multiLine && singleLine) { + ts.setEmitFlags(block, 32 /* SingleLine */); + } + if (closeBraceLocation) { + ts.setTokenSourceMapRange(block, 17 /* CloseBraceToken */, closeBraceLocation); + } + ts.setOriginalNode(block, node.body); + return block; + } + /** + * Visits an ExpressionStatement that contains a destructuring assignment. + * + * @param node An ExpressionStatement node. + */ + function visitExpressionStatement(node) { + // If we are here it is most likely because our expression is a destructuring assignment. + switch (node.expression.kind) { + case 179 /* ParenthesizedExpression */: + return ts.updateStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); + case 188 /* BinaryExpression */: + return ts.updateStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); + } + return ts.visitEachChild(node, visitor, context); + } + /** + * Visits a ParenthesizedExpression that may contain a destructuring assignment. + * + * @param node A ParenthesizedExpression node. + * @param needsDestructuringValue A value indicating whether we need to hold onto the rhs + * of a destructuring assignment. + */ + function visitParenthesizedExpression(node, needsDestructuringValue) { + // If we are here it is most likely because our expression is a destructuring assignment. + if (needsDestructuringValue) { + switch (node.expression.kind) { + case 179 /* ParenthesizedExpression */: + return ts.createParen(visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ true), + /*location*/ node); + case 188 /* BinaryExpression */: + return ts.createParen(visitBinaryExpression(node.expression, /*needsDestructuringValue*/ true), + /*location*/ node); + } + } + return ts.visitEachChild(node, visitor, context); + } + /** + * Visits a BinaryExpression that contains a destructuring assignment. + * + * @param node A BinaryExpression node. + * @param needsDestructuringValue A value indicating whether we need to hold onto the rhs + * of a destructuring assignment. + */ + function visitBinaryExpression(node, needsDestructuringValue) { + // If we are here it is because this is a destructuring assignment. + ts.Debug.assert(ts.isDestructuringAssignment(node)); + return ts.flattenDestructuringAssignment(context, node, needsDestructuringValue, hoistVariableDeclaration, visitor); + } + function visitVariableStatement(node) { + if (convertedLoopState && (ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */) == 0) { + // we are inside a converted loop - hoist variable declarations + var assignments = void 0; + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + hoistVariableDeclarationDeclaredInConvertedLoop(convertedLoopState, decl); + if (decl.initializer) { + var assignment = void 0; + if (ts.isBindingPattern(decl.name)) { + assignment = ts.flattenVariableDestructuringToExpression(decl, hoistVariableDeclaration, /*nameSubstitution*/ undefined, visitor); + } + else { + assignment = ts.createBinary(decl.name, 57 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + } + (assignments || (assignments = [])).push(assignment); + } + } + if (assignments) { + return ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25 /* CommaToken */, acc); }), node); + } + else { + // none of declarations has initializer - the entire variable statement can be deleted + return undefined; + } + } + return ts.visitEachChild(node, visitor, context); + } + /** + * Visits a VariableDeclarationList that is block scoped (e.g. `let` or `const`). + * + * @param node A VariableDeclarationList node. + */ + function visitVariableDeclarationList(node) { + if (node.flags & 3 /* BlockScoped */) { + enableSubstitutionsForBlockScopedBindings(); + } + var declarations = ts.flatten(ts.map(node.declarations, node.flags & 1 /* Let */ + ? visitVariableDeclarationInLetDeclarationList + : visitVariableDeclaration)); + var declarationList = ts.createVariableDeclarationList(declarations, /*location*/ node); + ts.setOriginalNode(declarationList, node); + ts.setCommentRange(declarationList, node); + if (node.transformFlags & 8388608 /* ContainsBindingPattern */ + && (ts.isBindingPattern(node.declarations[0].name) + || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { + // If the first or last declaration is a binding pattern, we need to modify + // the source map range for the declaration list. + var firstDeclaration = ts.firstOrUndefined(declarations); + var lastDeclaration = ts.lastOrUndefined(declarations); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + } + return declarationList; + } + /** + * Gets a value indicating whether we should emit an explicit initializer for a variable + * declaration in a `let` declaration list. + * + * @param node A VariableDeclaration node. + */ + function shouldEmitExplicitInitializerForLetDeclaration(node) { + // Nested let bindings might need to be initialized explicitly to preserve + // ES6 semantic: + // + // { let x = 1; } + // { let x; } // x here should be undefined. not 1 + // + // Top level bindings never collide with anything and thus don't require + // explicit initialization. As for nested let bindings there are two cases: + // + // - Nested let bindings that were not renamed definitely should be + // initialized explicitly: + // + // { let x = 1; } + // { let x; if (some-condition) { x = 1}; if (x) { /*1*/ } } + // + // Without explicit initialization code in /*1*/ can be executed even if + // some-condition is evaluated to false. + // + // - Renaming introduces fresh name that should not collide with any + // existing names, however renamed bindings sometimes also should be + // explicitly initialized. One particular case: non-captured binding + // declared inside loop body (but not in loop initializer): + // + // let x; + // for (;;) { + // let x; + // } + // + // In downlevel codegen inner 'x' will be renamed so it won't collide + // with outer 'x' however it will should be reset on every iteration as + // if it was declared anew. + // + // * Why non-captured binding? + // - Because if loop contains block scoped binding captured in some + // function then loop body will be rewritten to have a fresh scope + // on every iteration so everything will just work. + // + // * Why loop initializer is excluded? + // - Since we've introduced a fresh name it already will be undefined. + var flags = resolver.getNodeCheckFlags(node); + var isCapturedInFunction = flags & 131072 /* CapturedBlockScopedBinding */; + var isDeclaredInLoop = flags & 262144 /* BlockScopedBindingInLoop */; + var emittedAsTopLevel = ts.isBlockScopedContainerTopLevel(enclosingBlockScopeContainer) + || (isCapturedInFunction + && isDeclaredInLoop + && ts.isBlock(enclosingBlockScopeContainer) + && ts.isIterationStatement(enclosingBlockScopeContainerParent, /*lookInLabeledStatements*/ false)); + var emitExplicitInitializer = !emittedAsTopLevel + && enclosingBlockScopeContainer.kind !== 208 /* ForInStatement */ + && enclosingBlockScopeContainer.kind !== 209 /* ForOfStatement */ + && (!resolver.isDeclarationWithCollidingName(node) + || (isDeclaredInLoop + && !isCapturedInFunction + && !ts.isIterationStatement(enclosingBlockScopeContainer, /*lookInLabeledStatements*/ false))); + return emitExplicitInitializer; + } + /** + * Visits a VariableDeclaration in a `let` declaration list. + * + * @param node A VariableDeclaration node. + */ + function visitVariableDeclarationInLetDeclarationList(node) { + // For binding pattern names that lack initializers there is no point to emit + // explicit initializer since downlevel codegen for destructuring will fail + // in the absence of initializer so all binding elements will say uninitialized + var name = node.name; + if (ts.isBindingPattern(name)) { + return visitVariableDeclaration(node); + } + if (!node.initializer && shouldEmitExplicitInitializerForLetDeclaration(node)) { + var clone_5 = ts.getMutableClone(node); + clone_5.initializer = ts.createVoidZero(); + return clone_5; + } + return ts.visitEachChild(node, visitor, context); + } + /** + * Visits a VariableDeclaration node with a binding pattern. + * + * @param node A VariableDeclaration node. + */ + function visitVariableDeclaration(node) { + // If we are here it is because the name contains a binding pattern. + if (ts.isBindingPattern(node.name)) { + var recordTempVariablesInLine = !enclosingVariableStatement + || !ts.hasModifier(enclosingVariableStatement, 1 /* Export */); + return ts.flattenVariableDestructuring(node, /*value*/ undefined, visitor, recordTempVariablesInLine ? undefined : hoistVariableDeclaration); + } + return ts.visitEachChild(node, visitor, context); + } + function visitLabeledStatement(node) { + if (convertedLoopState) { + if (!convertedLoopState.labels) { + convertedLoopState.labels = ts.createMap(); + } + convertedLoopState.labels[node.label.text] = node.label.text; + } + var result; + if (ts.isIterationStatement(node.statement, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node.statement)) { + result = ts.visitNodes(ts.createNodeArray([node.statement]), visitor, ts.isStatement); + } + else { + result = ts.visitEachChild(node, visitor, context); + } + if (convertedLoopState) { + convertedLoopState.labels[node.label.text] = undefined; + } + return result; + } + function visitDoStatement(node) { + return convertIterationStatementBodyIfNecessary(node); + } + function visitWhileStatement(node) { + return convertIterationStatementBodyIfNecessary(node); + } + function visitForStatement(node) { + return convertIterationStatementBodyIfNecessary(node); + } + function visitForInStatement(node) { + return convertIterationStatementBodyIfNecessary(node); + } + /** + * Visits a ForOfStatement and converts it into a compatible ForStatement. + * + * @param node A ForOfStatement. + */ + function visitForOfStatement(node) { + return convertIterationStatementBodyIfNecessary(node, convertForOfToFor); + } + function convertForOfToFor(node, convertedLoopBodyStatements) { + // The following ES6 code: + // + // for (let v of expr) { } + // + // should be emitted as + // + // for (var _i = 0, _a = expr; _i < _a.length; _i++) { + // var v = _a[_i]; + // } + // + // where _a and _i are temps emitted to capture the RHS and the counter, + // respectively. + // When the left hand side is an expression instead of a let declaration, + // the "let v" is not emitted. + // When the left hand side is a let/const, the v is renamed if there is + // another v in scope. + // Note that all assignments to the LHS are emitted in the body, including + // all destructuring. + // Note also that because an extra statement is needed to assign to the LHS, + // for-of bodies are always emitted as blocks. + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + var initializer = node.initializer; + var statements = []; + // In the case where the user wrote an identifier as the RHS, like this: + // + // for (let v of arr) { } + // + // we don't want to emit a temporary variable for the RHS, just use it directly. + var counter = ts.createLoopVariable(); + var rhsReference = expression.kind === 70 /* Identifier */ + ? ts.createUniqueName(expression.text) + : ts.createTempVariable(/*recordTempVariable*/ undefined); + // Initialize LHS + // var v = _a[_i]; + if (ts.isVariableDeclarationList(initializer)) { + if (initializer.flags & 3 /* BlockScoped */) { + enableSubstitutionsForBlockScopedBindings(); + } + var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); + if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { + // This works whether the declaration is a var, let, or const. + // It will use rhsIterationValue _a[_i] as the initializer. + var declarations = ts.flattenVariableDestructuring(firstOriginalDeclaration, ts.createElementAccess(rhsReference, counter), visitor); + var declarationList = ts.createVariableDeclarationList(declarations, /*location*/ initializer); + ts.setOriginalNode(declarationList, initializer); + // Adjust the source map range for the first declaration to align with the old + // emitter. + var firstDeclaration = declarations[0]; + var lastDeclaration = ts.lastOrUndefined(declarations); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + statements.push(ts.createVariableStatement( + /*modifiers*/ undefined, declarationList)); + } + else { + // The following call does not include the initializer, so we have + // to emit it separately. + statements.push(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(/*recordTempVariable*/ undefined), + /*type*/ undefined, ts.createElementAccess(rhsReference, counter)) + ], /*location*/ ts.moveRangePos(initializer, -1)), + /*location*/ ts.moveRangeEnd(initializer, -1))); + } + } + else { + // Initializer is an expression. Emit the expression in the body, so that it's + // evaluated on every iteration. + var assignment = ts.createAssignment(initializer, ts.createElementAccess(rhsReference, counter)); + if (ts.isDestructuringAssignment(assignment)) { + // This is a destructuring pattern, so we flatten the destructuring instead. + statements.push(ts.createStatement(ts.flattenDestructuringAssignment(context, assignment, + /*needsValue*/ false, hoistVariableDeclaration, visitor))); + } + else { + // Currently there is not way to check that assignment is binary expression of destructing assignment + // so we have to cast never type to binaryExpression + assignment.end = initializer.end; + statements.push(ts.createStatement(assignment, /*location*/ ts.moveRangeEnd(initializer, -1))); + } + } + var bodyLocation; + var statementsLocation; + if (convertedLoopBodyStatements) { + ts.addRange(statements, convertedLoopBodyStatements); + } + else { + var statement = ts.visitNode(node.statement, visitor, ts.isStatement); + if (ts.isBlock(statement)) { + ts.addRange(statements, statement.statements); + bodyLocation = statement; + statementsLocation = statement.statements; + } + else { + statements.push(statement); + } + } + // The old emitter does not emit source maps for the expression + ts.setEmitFlags(expression, 1536 /* NoSourceMap */ | ts.getEmitFlags(expression)); + // The old emitter does not emit source maps for the block. + // We add the location to preserve comments. + var body = ts.createBlock(ts.createNodeArray(statements, /*location*/ statementsLocation), + /*location*/ bodyLocation); + ts.setEmitFlags(body, 1536 /* NoSourceMap */ | 12288 /* NoTokenSourceMaps */); + var forStatement = ts.createFor(ts.createVariableDeclarationList([ + ts.createVariableDeclaration(counter, /*type*/ undefined, ts.createLiteral(0), /*location*/ ts.moveRangePos(node.expression, -1)), + ts.createVariableDeclaration(rhsReference, /*type*/ undefined, expression, /*location*/ node.expression) + ], /*location*/ node.expression), ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length"), + /*location*/ node.expression), ts.createPostfixIncrement(counter, /*location*/ node.expression), body, + /*location*/ node); + // Disable trailing source maps for the OpenParenToken to align source map emit with the old emitter. + ts.setEmitFlags(forStatement, 8192 /* NoTokenTrailingSourceMaps */); + return forStatement; + } + /** + * Visits an ObjectLiteralExpression with computed propety names. + * + * @param node An ObjectLiteralExpression node. + */ + function visitObjectLiteralExpression(node) { + // We are here because a ComputedPropertyName was used somewhere in the expression. + var properties = node.properties; + var numProperties = properties.length; + // Find the first computed property. + // Everything until that point can be emitted as part of the initial object literal. + var numInitialProperties = numProperties; + for (var i = 0; i < numProperties; i++) { + var property = properties[i]; + if (property.transformFlags & 16777216 /* ContainsYield */ + || property.name.kind === 141 /* ComputedPropertyName */) { + numInitialProperties = i; + break; + } + } + ts.Debug.assert(numInitialProperties !== numProperties); + // For computed properties, we need to create a unique handle to the object + // literal so we can modify it without risking internal assignments tainting the object. + var temp = ts.createTempVariable(hoistVariableDeclaration); + // Write out the first non-computed properties, then emit the rest through indexing on the temp variable. + var expressions = []; + var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), + /*location*/ undefined, node.multiLine), 524288 /* Indented */)); + if (node.multiLine) { + assignment.startsOnNewLine = true; + } + expressions.push(assignment); + addObjectLiteralMembers(expressions, node, temp, numInitialProperties); + // We need to clone the temporary identifier so that we can write it on a + // new line + expressions.push(node.multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); + return ts.inlineExpressions(expressions); + } + function shouldConvertIterationStatementBody(node) { + return (resolver.getNodeCheckFlags(node) & 65536 /* LoopWithCapturedBlockScopedBinding */) !== 0; + } + /** + * Records constituents of name for the given variable to be hoisted in the outer scope. + */ + function hoistVariableDeclarationDeclaredInConvertedLoop(state, node) { + if (!state.hoistedLocalVariables) { + state.hoistedLocalVariables = []; + } + visit(node.name); + function visit(node) { + if (node.kind === 70 /* Identifier */) { + state.hoistedLocalVariables.push(node); + } + else { + for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!ts.isOmittedExpression(element)) { + visit(element.name); + } + } + } + } + } + function convertIterationStatementBodyIfNecessary(node, convert) { + if (!shouldConvertIterationStatementBody(node)) { + var saveAllowedNonLabeledJumps = void 0; + if (convertedLoopState) { + // we get here if we are trying to emit normal loop loop inside converted loop + // set allowedNonLabeledJumps to Break | Continue to mark that break\continue inside the loop should be emitted as is + saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; + convertedLoopState.allowedNonLabeledJumps = 2 /* Break */ | 4 /* Continue */; + } + var result = convert ? convert(node, /*convertedLoopBodyStatements*/ undefined) : ts.visitEachChild(node, visitor, context); + if (convertedLoopState) { + convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps; + } + return result; + } + var functionName = ts.createUniqueName("_loop"); + var loopInitializer; + switch (node.kind) { + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: + var initializer = node.initializer; + if (initializer && initializer.kind === 220 /* VariableDeclarationList */) { + loopInitializer = initializer; + } + break; + } + // variables that will be passed to the loop as parameters + var loopParameters = []; + // variables declared in the loop initializer that will be changed inside the loop + var loopOutParameters = []; + if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3 /* BlockScoped */)) { + for (var _i = 0, _a = loopInitializer.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + processLoopVariableDeclaration(decl, loopParameters, loopOutParameters); + } + } + var outerConvertedLoopState = convertedLoopState; + convertedLoopState = { loopOutParameters: loopOutParameters }; + if (outerConvertedLoopState) { + // convertedOuterLoopState !== undefined means that this converted loop is nested in another converted loop. + // if outer converted loop has already accumulated some state - pass it through + if (outerConvertedLoopState.argumentsName) { + // outer loop has already used 'arguments' so we've already have some name to alias it + // use the same name in all nested loops + convertedLoopState.argumentsName = outerConvertedLoopState.argumentsName; + } + if (outerConvertedLoopState.thisName) { + // outer loop has already used 'this' so we've already have some name to alias it + // use the same name in all nested loops + convertedLoopState.thisName = outerConvertedLoopState.thisName; + } + if (outerConvertedLoopState.hoistedLocalVariables) { + // we've already collected some non-block scoped variable declarations in enclosing loop + // use the same storage in nested loop + convertedLoopState.hoistedLocalVariables = outerConvertedLoopState.hoistedLocalVariables; + } + } + var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement); + var currentState = convertedLoopState; + convertedLoopState = outerConvertedLoopState; + if (loopOutParameters.length) { + var statements_3 = ts.isBlock(loopBody) ? loopBody.statements.slice() : [loopBody]; + copyOutParameters(loopOutParameters, 1 /* ToOutParameter */, statements_3); + loopBody = ts.createBlock(statements_3, /*location*/ undefined, /*multiline*/ true); + } + if (!ts.isBlock(loopBody)) { + loopBody = ts.createBlock([loopBody], /*location*/ undefined, /*multiline*/ true); + } + var isAsyncBlockContainingAwait = enclosingNonArrowFunction + && (ts.getEmitFlags(enclosingNonArrowFunction) & 2097152 /* AsyncFunctionBody */) !== 0 + && (node.statement.transformFlags & 16777216 /* ContainsYield */) !== 0; + var loopBodyFlags = 0; + if (currentState.containsLexicalThis) { + loopBodyFlags |= 256 /* CapturesThis */; + } + if (isAsyncBlockContainingAwait) { + loopBodyFlags |= 2097152 /* AsyncFunctionBody */; + } + var convertedLoopVariable = ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(functionName, + /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression( + /*modifiers*/ undefined, isAsyncBlockContainingAwait ? ts.createToken(38 /* AsteriskToken */) : undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, loopParameters, + /*type*/ undefined, loopBody), loopBodyFlags)) + ])); + var statements = [convertedLoopVariable]; + var extraVariableDeclarations; + // propagate state from the inner loop to the outer loop if necessary + if (currentState.argumentsName) { + // if alias for arguments is set + if (outerConvertedLoopState) { + // pass it to outer converted loop + outerConvertedLoopState.argumentsName = currentState.argumentsName; + } + else { + // this is top level converted loop and we need to create an alias for 'arguments' object + (extraVariableDeclarations || (extraVariableDeclarations = [])).push(ts.createVariableDeclaration(currentState.argumentsName, + /*type*/ undefined, ts.createIdentifier("arguments"))); + } + } + if (currentState.thisName) { + // if alias for this is set + if (outerConvertedLoopState) { + // pass it to outer converted loop + outerConvertedLoopState.thisName = currentState.thisName; + } + else { + // this is top level converted loop so we need to create an alias for 'this' here + // NOTE: + // if converted loops were all nested in arrow function then we'll always emit '_this' so convertedLoopState.thisName will not be set. + // If it is set this means that all nested loops are not nested in arrow function and it is safe to capture 'this'. + (extraVariableDeclarations || (extraVariableDeclarations = [])).push(ts.createVariableDeclaration(currentState.thisName, + /*type*/ undefined, ts.createIdentifier("this"))); + } + } + if (currentState.hoistedLocalVariables) { + // if hoistedLocalVariables !== undefined this means that we've possibly collected some variable declarations to be hoisted later + if (outerConvertedLoopState) { + // pass them to outer converted loop + outerConvertedLoopState.hoistedLocalVariables = currentState.hoistedLocalVariables; + } + else { + if (!extraVariableDeclarations) { + extraVariableDeclarations = []; + } + // hoist collected variable declarations + for (var _b = 0, _c = currentState.hoistedLocalVariables; _b < _c.length; _b++) { + var identifier = _c[_b]; + extraVariableDeclarations.push(ts.createVariableDeclaration(identifier)); + } + } + } + // add extra variables to hold out parameters if necessary + if (loopOutParameters.length) { + if (!extraVariableDeclarations) { + extraVariableDeclarations = []; + } + for (var _d = 0, loopOutParameters_1 = loopOutParameters; _d < loopOutParameters_1.length; _d++) { + var outParam = loopOutParameters_1[_d]; + extraVariableDeclarations.push(ts.createVariableDeclaration(outParam.outParamName)); + } + } + // create variable statement to hold all introduced variable declarations + if (extraVariableDeclarations) { + statements.push(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList(extraVariableDeclarations))); + } + var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, isAsyncBlockContainingAwait); + var loop; + if (convert) { + loop = convert(node, convertedLoopBodyStatements); + } + else { + loop = ts.getMutableClone(node); + // clean statement part + loop.statement = undefined; + // visit childnodes to transform initializer/condition/incrementor parts + loop = ts.visitEachChild(loop, visitor, context); + // set loop statement + loop.statement = ts.createBlock(convertedLoopBodyStatements, + /*location*/ undefined, + /*multiline*/ true); + // reset and re-aggregate the transform flags + loop.transformFlags = 0; + ts.aggregateTransformFlags(loop); + } + statements.push(currentParent.kind === 215 /* LabeledStatement */ + ? ts.createLabel(currentParent.label, loop) + : loop); + return statements; + } + function copyOutParameter(outParam, copyDirection) { + var source = copyDirection === 0 /* ToOriginal */ ? outParam.outParamName : outParam.originalName; + var target = copyDirection === 0 /* ToOriginal */ ? outParam.originalName : outParam.outParamName; + return ts.createBinary(target, 57 /* EqualsToken */, source); + } + function copyOutParameters(outParams, copyDirection, statements) { + for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { + var outParam = outParams_1[_i]; + statements.push(ts.createStatement(copyOutParameter(outParam, copyDirection))); + } + } + function generateCallToConvertedLoop(loopFunctionExpressionName, parameters, state, isAsyncBlockContainingAwait) { + var outerConvertedLoopState = convertedLoopState; + var statements = []; + // loop is considered simple if it does not have any return statements or break\continue that transfer control outside of the loop + // simple loops are emitted as just 'loop()'; + // NOTE: if loop uses only 'continue' it still will be emitted as simple loop + var isSimpleLoop = !(state.nonLocalJumps & ~4 /* Continue */) && + !state.labeledNonLocalBreaks && + !state.labeledNonLocalContinues; + var call = ts.createCall(loopFunctionExpressionName, /*typeArguments*/ undefined, ts.map(parameters, function (p) { return p.name; })); + var callResult = isAsyncBlockContainingAwait ? ts.createYield(ts.createToken(38 /* AsteriskToken */), call) : call; + if (isSimpleLoop) { + statements.push(ts.createStatement(callResult)); + copyOutParameters(state.loopOutParameters, 0 /* ToOriginal */, statements); + } + else { + var loopResultName = ts.createUniqueName("state"); + var stateVariable = ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ts.createVariableDeclaration(loopResultName, /*type*/ undefined, callResult)])); + statements.push(stateVariable); + copyOutParameters(state.loopOutParameters, 0 /* ToOriginal */, statements); + if (state.nonLocalJumps & 8 /* Return */) { + var returnStatement = void 0; + if (outerConvertedLoopState) { + outerConvertedLoopState.nonLocalJumps |= 8 /* Return */; + returnStatement = ts.createReturn(loopResultName); + } + else { + returnStatement = ts.createReturn(ts.createPropertyAccess(loopResultName, "value")); + } + statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 33 /* EqualsEqualsEqualsToken */, ts.createLiteral("object")), returnStatement)); + } + if (state.nonLocalJumps & 2 /* Break */) { + statements.push(ts.createIf(ts.createBinary(loopResultName, 33 /* EqualsEqualsEqualsToken */, ts.createLiteral("break")), ts.createBreak())); + } + if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { + var caseClauses = []; + processLabeledJumps(state.labeledNonLocalBreaks, /*isBreak*/ true, loopResultName, outerConvertedLoopState, caseClauses); + processLabeledJumps(state.labeledNonLocalContinues, /*isBreak*/ false, loopResultName, outerConvertedLoopState, caseClauses); + statements.push(ts.createSwitch(loopResultName, ts.createCaseBlock(caseClauses))); + } + } + return statements; + } + function setLabeledJump(state, isBreak, labelText, labelMarker) { + if (isBreak) { + if (!state.labeledNonLocalBreaks) { + state.labeledNonLocalBreaks = ts.createMap(); + } + state.labeledNonLocalBreaks[labelText] = labelMarker; + } + else { + if (!state.labeledNonLocalContinues) { + state.labeledNonLocalContinues = ts.createMap(); + } + state.labeledNonLocalContinues[labelText] = labelMarker; + } + } + function processLabeledJumps(table, isBreak, loopResultName, outerLoop, caseClauses) { + if (!table) { + return; + } + for (var labelText in table) { + var labelMarker = table[labelText]; + var statements = []; + // if there are no outer converted loop or outer label in question is located inside outer converted loop + // then emit labeled break\continue + // otherwise propagate pair 'label -> marker' to outer converted loop and emit 'return labelMarker' so outer loop can later decide what to do + if (!outerLoop || (outerLoop.labels && outerLoop.labels[labelText])) { + var label = ts.createIdentifier(labelText); + statements.push(isBreak ? ts.createBreak(label) : ts.createContinue(label)); + } + else { + setLabeledJump(outerLoop, isBreak, labelText, labelMarker); + statements.push(ts.createReturn(loopResultName)); + } + caseClauses.push(ts.createCaseClause(ts.createLiteral(labelMarker), statements)); + } + } + function processLoopVariableDeclaration(decl, loopParameters, loopOutParameters) { + var name = decl.name; + if (ts.isBindingPattern(name)) { + for (var _i = 0, _a = name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!ts.isOmittedExpression(element)) { + processLoopVariableDeclaration(element, loopParameters, loopOutParameters); + } + } + } + else { + loopParameters.push(ts.createParameter(name)); + if (resolver.getNodeCheckFlags(decl) & 2097152 /* NeedsLoopOutParameter */) { + var outParamName = ts.createUniqueName("out_" + name.text); + loopOutParameters.push({ originalName: name, outParamName: outParamName }); + } + } + } + /** + * Adds the members of an object literal to an array of expressions. + * + * @param expressions An array of expressions. + * @param node An ObjectLiteralExpression node. + * @param receiver The receiver for members of the ObjectLiteralExpression. + * @param numInitialNonComputedProperties The number of initial properties without + * computed property names. + */ + function addObjectLiteralMembers(expressions, node, receiver, start) { + var properties = node.properties; + var numProperties = properties.length; + for (var i = start; i < numProperties; i++) { + var property = properties[i]; + switch (property.kind) { + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + var accessors = ts.getAllAccessorDeclarations(node.properties, property); + if (property === accessors.firstAccessor) { + expressions.push(transformAccessorsToExpression(receiver, accessors, node.multiLine)); + } + break; + case 253 /* PropertyAssignment */: + expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); + break; + case 254 /* ShorthandPropertyAssignment */: + expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); + break; + case 148 /* MethodDeclaration */: + expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node.multiLine)); + break; + default: + ts.Debug.failBadSyntaxKind(node); + break; + } + } + } + /** + * Transforms a PropertyAssignment node into an expression. + * + * @param node The ObjectLiteralExpression that contains the PropertyAssignment. + * @param property The PropertyAssignment node. + * @param receiver The receiver for the assignment. + */ + function transformPropertyAssignmentToExpression(property, receiver, startsOnNewLine) { + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.visitNode(property.initializer, visitor, ts.isExpression), + /*location*/ property); + if (startsOnNewLine) { + expression.startsOnNewLine = true; + } + return expression; + } + /** + * Transforms a ShorthandPropertyAssignment node into an expression. + * + * @param node The ObjectLiteralExpression that contains the ShorthandPropertyAssignment. + * @param property The ShorthandPropertyAssignment node. + * @param receiver The receiver for the assignment. + */ + function transformShorthandPropertyAssignmentToExpression(property, receiver, startsOnNewLine) { + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.getSynthesizedClone(property.name), + /*location*/ property); + if (startsOnNewLine) { + expression.startsOnNewLine = true; + } + return expression; + } + /** + * Transforms a MethodDeclaration of an ObjectLiteralExpression into an expression. + * + * @param node The ObjectLiteralExpression that contains the MethodDeclaration. + * @param method The MethodDeclaration node. + * @param receiver The receiver for the assignment. + */ + function transformObjectLiteralMethodDeclarationToExpression(method, receiver, startsOnNewLine) { + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, /*location*/ method, /*name*/ undefined), + /*location*/ method); + if (startsOnNewLine) { + expression.startsOnNewLine = true; + } + return expression; + } + /** + * Visits a MethodDeclaration of an ObjectLiteralExpression and transforms it into a + * PropertyAssignment. + * + * @param node A MethodDeclaration node. + */ + function visitMethodDeclaration(node) { + // We should only get here for methods on an object literal with regular identifier names. + // Methods on classes are handled in visitClassDeclaration/visitClassExpression. + // Methods with computed property names are handled in visitObjectLiteralExpression. + ts.Debug.assert(!ts.isComputedPropertyName(node.name)); + var functionExpression = transformFunctionLikeToExpression(node, /*location*/ ts.moveRangePos(node, -1), /*name*/ undefined); + ts.setEmitFlags(functionExpression, 16384 /* NoLeadingComments */ | ts.getEmitFlags(functionExpression)); + return ts.createPropertyAssignment(node.name, functionExpression, + /*location*/ node); + } + /** + * Visits a ShorthandPropertyAssignment and transforms it into a PropertyAssignment. + * + * @param node A ShorthandPropertyAssignment node. + */ + function visitShorthandPropertyAssignment(node) { + return ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name), + /*location*/ node); + } + /** + * Visits a YieldExpression node. + * + * @param node A YieldExpression node. + */ + function visitYieldExpression(node) { + // `yield` expressions are transformed using the generators transformer. + return ts.visitEachChild(node, visitor, context); + } + /** + * Visits an ArrayLiteralExpression that contains a spread element. + * + * @param node An ArrayLiteralExpression node. + */ + function visitArrayLiteralExpression(node) { + // We are here because we contain a SpreadElementExpression. + return transformAndSpreadElements(node.elements, /*needsUniqueCopy*/ true, node.multiLine, /*hasTrailingComma*/ node.elements.hasTrailingComma); + } + /** + * Visits a CallExpression that contains either a spread element or `super`. + * + * @param node a CallExpression. + */ + function visitCallExpression(node) { + return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); + } + function visitImmediateSuperCallInBody(node) { + return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ false); + } + function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) { + // We are here either because SuperKeyword was used somewhere in the expression, or + // because we contain a SpreadElementExpression. + var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; + if (node.expression.kind === 96 /* SuperKeyword */) { + ts.setEmitFlags(thisArg, 128 /* NoSubstitution */); + } + var resultingCall; + if (node.transformFlags & 1048576 /* ContainsSpreadElementExpression */) { + // [source] + // f(...a, b) + // x.m(...a, b) + // super(...a, b) + // super.m(...a, b) // in static + // super.m(...a, b) // in instance + // + // [output] + // f.apply(void 0, a.concat([b])) + // (_a = x).m.apply(_a, a.concat([b])) + // _super.apply(this, a.concat([b])) + // _super.m.apply(this, a.concat([b])) + // _super.prototype.m.apply(this, a.concat([b])) + resultingCall = ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); + } + else { + // [source] + // super(a) + // super.m(a) // in static + // super.m(a) // in instance + // + // [output] + // _super.call(this, a) + // _super.m.call(this, a) + // _super.prototype.m.call(this, a) + resultingCall = ts.createFunctionCall(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), + /*location*/ node); + } + if (node.expression.kind === 96 /* SuperKeyword */) { + var actualThis = ts.createThis(); + ts.setEmitFlags(actualThis, 128 /* NoSubstitution */); + var initializer = ts.createLogicalOr(resultingCall, actualThis); + return assignToCapturedThis + ? ts.createAssignment(ts.createIdentifier("_this"), initializer) + : initializer; + } + return resultingCall; + } + /** + * Visits a NewExpression that contains a spread element. + * + * @param node A NewExpression node. + */ + function visitNewExpression(node) { + // We are here because we contain a SpreadElementExpression. + ts.Debug.assert((node.transformFlags & 1048576 /* ContainsSpreadElementExpression */) !== 0); + // [source] + // new C(...a) + // + // [output] + // new ((_a = C).bind.apply(_a, [void 0].concat(a)))() + var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; + return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)), + /*typeArguments*/ undefined, []); + } + /** + * Transforms an array of Expression nodes that contains a SpreadElementExpression. + * + * @param elements The array of Expression nodes. + * @param needsUniqueCopy A value indicating whether to ensure that the result is a fresh array. + * @param multiLine A value indicating whether the result should be emitted on multiple lines. + */ + function transformAndSpreadElements(elements, needsUniqueCopy, multiLine, hasTrailingComma) { + // [source] + // [a, ...b, c] + // + // [output] + // [a].concat(b, [c]) + // Map spans of spread expressions into their expressions and spans of other + // expressions into an array literal. + var numElements = elements.length; + var segments = ts.flatten(ts.spanMap(elements, partitionSpreadElement, function (partition, visitPartition, _start, end) { + return visitPartition(partition, multiLine, hasTrailingComma && end === numElements); + })); + if (segments.length === 1) { + var firstElement = elements[0]; + return needsUniqueCopy && ts.isSpreadElementExpression(firstElement) && firstElement.expression.kind !== 171 /* ArrayLiteralExpression */ + ? ts.createArraySlice(segments[0]) + : segments[0]; + } + // Rewrite using the pattern .concat(, , ...) + return ts.createArrayConcat(segments.shift(), segments); + } + function partitionSpreadElement(node) { + return ts.isSpreadElementExpression(node) + ? visitSpanOfSpreadElements + : visitSpanOfNonSpreadElements; + } + function visitSpanOfSpreadElements(chunk) { + return ts.map(chunk, visitExpressionOfSpreadElement); + } + function visitSpanOfNonSpreadElements(chunk, multiLine, hasTrailingComma) { + return ts.createArrayLiteral(ts.visitNodes(ts.createNodeArray(chunk, /*location*/ undefined, hasTrailingComma), visitor, ts.isExpression), + /*location*/ undefined, multiLine); + } + /** + * Transforms the expression of a SpreadElementExpression node. + * + * @param node A SpreadElementExpression node. + */ + function visitExpressionOfSpreadElement(node) { + return ts.visitNode(node.expression, visitor, ts.isExpression); + } + /** + * Visits a template literal. + * + * @param node A template literal. + */ + function visitTemplateLiteral(node) { + return ts.createLiteral(node.text, /*location*/ node); + } + /** + * Visits a TaggedTemplateExpression node. + * + * @param node A TaggedTemplateExpression node. + */ + function visitTaggedTemplateExpression(node) { + // Visit the tag expression + var tag = ts.visitNode(node.tag, visitor, ts.isExpression); + // Allocate storage for the template site object + var temp = ts.createTempVariable(hoistVariableDeclaration); + // Build up the template arguments and the raw and cooked strings for the template. + var templateArguments = [temp]; + var cookedStrings = []; + var rawStrings = []; + var template = node.template; + if (ts.isNoSubstitutionTemplateLiteral(template)) { + cookedStrings.push(ts.createLiteral(template.text)); + rawStrings.push(getRawLiteral(template)); + } + else { + cookedStrings.push(ts.createLiteral(template.head.text)); + rawStrings.push(getRawLiteral(template.head)); + for (var _i = 0, _a = template.templateSpans; _i < _a.length; _i++) { + var templateSpan = _a[_i]; + cookedStrings.push(ts.createLiteral(templateSpan.literal.text)); + rawStrings.push(getRawLiteral(templateSpan.literal)); + templateArguments.push(ts.visitNode(templateSpan.expression, visitor, ts.isExpression)); + } + } + // NOTE: The parentheses here is entirely optional as we are now able to auto- + // parenthesize when rebuilding the tree. This should be removed in a + // future version. It is here for now to match our existing emit. + return ts.createParen(ts.inlineExpressions([ + ts.createAssignment(temp, ts.createArrayLiteral(cookedStrings)), + ts.createAssignment(ts.createPropertyAccess(temp, "raw"), ts.createArrayLiteral(rawStrings)), + ts.createCall(tag, /*typeArguments*/ undefined, templateArguments) + ])); + } + /** + * Creates an ES5 compatible literal from an ES6 template literal. + * + * @param node The ES6 template literal. + */ + function getRawLiteral(node) { + // Find original source text, since we need to emit the raw strings of the tagged template. + // The raw strings contain the (escaped) strings of what the user wrote. + // Examples: `\n` is converted to "\\n", a template string with a newline to "\n". + var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); + // text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"), + // thus we need to remove those characters. + // First template piece starts with "`", others with "}" + // Last template piece ends with "`", others with "${" + var isLast = node.kind === 12 /* NoSubstitutionTemplateLiteral */ || node.kind === 15 /* TemplateTail */; + text = text.substring(1, text.length - (isLast ? 1 : 2)); + // Newline normalization: + // ES6 Spec 11.8.6.1 - Static Semantics of TV's and TRV's + // and LineTerminatorSequences are normalized to for both TV and TRV. + text = text.replace(/\r\n?/g, "\n"); + return ts.createLiteral(text, /*location*/ node); + } + /** + * Visits a TemplateExpression node. + * + * @param node A TemplateExpression node. + */ + function visitTemplateExpression(node) { + var expressions = []; + addTemplateHead(expressions, node); + addTemplateSpans(expressions, node); + // createAdd will check if each expression binds less closely than binary '+'. + // If it does, it wraps the expression in parentheses. Otherwise, something like + // `abc${ 1 << 2 }` + // becomes + // "abc" + 1 << 2 + "" + // which is really + // ("abc" + 1) << (2 + "") + // rather than + // "abc" + (1 << 2) + "" + var expression = ts.reduceLeft(expressions, ts.createAdd); + if (ts.nodeIsSynthesized(expression)) { + ts.setTextRange(expression, node); + } + return expression; + } + /** + * Gets a value indicating whether we need to include the head of a TemplateExpression. + * + * @param node A TemplateExpression node. + */ + function shouldAddTemplateHead(node) { + // If this expression has an empty head literal and the first template span has a non-empty + // literal, then emitting the empty head literal is not necessary. + // `${ foo } and ${ bar }` + // can be emitted as + // foo + " and " + bar + // This is because it is only required that one of the first two operands in the emit + // output must be a string literal, so that the other operand and all following operands + // are forced into strings. + // + // If the first template span has an empty literal, then the head must still be emitted. + // `${ foo }${ bar }` + // must still be emitted as + // "" + foo + bar + // There is always atleast one templateSpan in this code path, since + // NoSubstitutionTemplateLiterals are directly emitted via emitLiteral() + ts.Debug.assert(node.templateSpans.length !== 0); + return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0; + } + /** + * Adds the head of a TemplateExpression to an array of expressions. + * + * @param expressions An array of expressions. + * @param node A TemplateExpression node. + */ + function addTemplateHead(expressions, node) { + if (!shouldAddTemplateHead(node)) { + return; + } + expressions.push(ts.createLiteral(node.head.text)); + } + /** + * Visits and adds the template spans of a TemplateExpression to an array of expressions. + * + * @param expressions An array of expressions. + * @param node A TemplateExpression node. + */ + function addTemplateSpans(expressions, node) { + for (var _i = 0, _a = node.templateSpans; _i < _a.length; _i++) { + var span_6 = _a[_i]; + expressions.push(ts.visitNode(span_6.expression, visitor, ts.isExpression)); + // Only emit if the literal is non-empty. + // The binary '+' operator is left-associative, so the first string concatenation + // with the head will force the result up to this point to be a string. + // Emitting a '+ ""' has no semantic effect for middles and tails. + if (span_6.literal.text.length !== 0) { + expressions.push(ts.createLiteral(span_6.literal.text)); + } + } + } + /** + * Visits the `super` keyword + */ + function visitSuperKeyword() { + return enclosingNonAsyncFunctionBody + && ts.isClassElement(enclosingNonAsyncFunctionBody) + && !ts.hasModifier(enclosingNonAsyncFunctionBody, 32 /* Static */) + && currentParent.kind !== 175 /* CallExpression */ + ? ts.createPropertyAccess(ts.createIdentifier("_super"), "prototype") + : ts.createIdentifier("_super"); + } + function visitSourceFileNode(node) { + var _a = ts.span(node.statements, ts.isPrologueDirective), prologue = _a[0], remaining = _a[1]; + var statements = []; + startLexicalEnvironment(); + ts.addRange(statements, prologue); + addCaptureThisForNodeIfNeeded(statements, node); + ts.addRange(statements, ts.visitNodes(ts.createNodeArray(remaining), visitor, ts.isStatement)); + ts.addRange(statements, endLexicalEnvironment()); + var clone = ts.getMutableClone(node); + clone.statements = ts.createNodeArray(statements, /*location*/ node.statements); + return clone; + } + /** + * Called by the printer just before a node is printed. + * + * @param node The node to be printed. + */ + function onEmitNode(emitContext, node, emitCallback) { + var savedEnclosingFunction = enclosingFunction; + if (enabledSubstitutions & 1 /* CapturedThis */ && ts.isFunctionLike(node)) { + // If we are tracking a captured `this`, keep track of the enclosing function. + enclosingFunction = node; + } + previousOnEmitNode(emitContext, node, emitCallback); + enclosingFunction = savedEnclosingFunction; + } + /** + * Enables a more costly code path for substitutions when we determine a source file + * contains block-scoped bindings (e.g. `let` or `const`). + */ + function enableSubstitutionsForBlockScopedBindings() { + if ((enabledSubstitutions & 2 /* BlockScopedBindings */) === 0) { + enabledSubstitutions |= 2 /* BlockScopedBindings */; + context.enableSubstitution(70 /* Identifier */); + } + } + /** + * Enables a more costly code path for substitutions when we determine a source file + * contains a captured `this`. + */ + function enableSubstitutionsForCapturedThis() { + if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { + enabledSubstitutions |= 1 /* CapturedThis */; + context.enableSubstitution(98 /* ThisKeyword */); + context.enableEmitNotification(149 /* Constructor */); + context.enableEmitNotification(148 /* MethodDeclaration */); + context.enableEmitNotification(150 /* GetAccessor */); + context.enableEmitNotification(151 /* SetAccessor */); + context.enableEmitNotification(181 /* ArrowFunction */); + context.enableEmitNotification(180 /* FunctionExpression */); + context.enableEmitNotification(221 /* FunctionDeclaration */); + } + } + /** + * Hooks node substitutions. + * + * @param node The node to substitute. + * @param isExpression A value indicating whether the node is to be used in an expression + * position. + */ + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1 /* Expression */) { + return substituteExpression(node); + } + if (ts.isIdentifier(node)) { + return substituteIdentifier(node); + } + return node; + } + /** + * Hooks substitutions for non-expression identifiers. + */ + function substituteIdentifier(node) { + // Only substitute the identifier if we have enabled substitutions for block-scoped + // bindings. + if (enabledSubstitutions & 2 /* BlockScopedBindings */) { + var original = ts.getParseTreeNode(node, ts.isIdentifier); + if (original && isNameOfDeclarationWithCollidingName(original)) { + return ts.getGeneratedNameForNode(original); + } + } + return node; + } + /** + * Determines whether a name is the name of a declaration with a colliding name. + * NOTE: This function expects to be called with an original source tree node. + * + * @param node An original source tree node. + */ + function isNameOfDeclarationWithCollidingName(node) { + var parent = node.parent; + switch (parent.kind) { + case 170 /* BindingElement */: + case 222 /* ClassDeclaration */: + case 225 /* EnumDeclaration */: + case 219 /* VariableDeclaration */: + return parent.name === node + && resolver.isDeclarationWithCollidingName(parent); + } + return false; + } + /** + * Substitutes an expression. + * + * @param node An Expression node. + */ + function substituteExpression(node) { + switch (node.kind) { + case 70 /* Identifier */: + return substituteExpressionIdentifier(node); + case 98 /* ThisKeyword */: + return substituteThisKeyword(node); + } + return node; + } + /** + * Substitutes an expression identifier. + * + * @param node An Identifier node. + */ + function substituteExpressionIdentifier(node) { + if (enabledSubstitutions & 2 /* BlockScopedBindings */) { + var declaration = resolver.getReferencedDeclarationWithCollidingName(node); + if (declaration) { + return ts.getGeneratedNameForNode(declaration.name); + } + } + return node; + } + /** + * Substitutes `this` when contained within an arrow function. + * + * @param node The ThisKeyword node. + */ + function substituteThisKeyword(node) { + if (enabledSubstitutions & 1 /* CapturedThis */ + && enclosingFunction + && ts.getEmitFlags(enclosingFunction) & 256 /* CapturesThis */) { + return ts.createIdentifier("_this", /*location*/ node); + } + return node; + } + /** + * Gets the local name for a declaration for use in expressions. + * + * A local name will *never* be prefixed with an module or namespace export modifier like + * "exports.". + * + * @param node The declaration. + * @param allowComments A value indicating whether comments may be emitted for the name. + * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. + */ + function getLocalName(node, allowComments, allowSourceMaps) { + return getDeclarationName(node, allowComments, allowSourceMaps, 262144 /* LocalName */); + } + /** + * Gets the name of a declaration, without source map or comments. + * + * @param node The declaration. + * @param allowComments Allow comments for the name. + */ + function getDeclarationName(node, allowComments, allowSourceMaps, emitFlags) { + if (node.name && !ts.isGeneratedIdentifier(node.name)) { + var name_33 = ts.getMutableClone(node.name); + emitFlags |= ts.getEmitFlags(node.name); + if (!allowSourceMaps) { + emitFlags |= 1536 /* NoSourceMap */; + } + if (!allowComments) { + emitFlags |= 49152 /* NoComments */; + } + if (emitFlags) { + ts.setEmitFlags(name_33, emitFlags); + } + return name_33; + } + return ts.getGeneratedNameForNode(node); + } + function getClassMemberPrefix(node, member) { + var expression = getLocalName(node); + return ts.hasModifier(member, 32 /* Static */) ? expression : ts.createPropertyAccess(expression, "prototype"); + } + function hasSynthesizedDefaultSuperCall(constructor, hasExtendsClause) { + if (!constructor || !hasExtendsClause) { + return false; + } + var parameter = ts.singleOrUndefined(constructor.parameters); + if (!parameter || !ts.nodeIsSynthesized(parameter) || !parameter.dotDotDotToken) { + return false; + } + var statement = ts.firstOrUndefined(constructor.body.statements); + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 203 /* ExpressionStatement */) { + return false; + } + var statementExpression = statement.expression; + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 175 /* CallExpression */) { + return false; + } + var callTarget = statementExpression.expression; + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 96 /* SuperKeyword */) { + return false; + } + var callArgument = ts.singleOrUndefined(statementExpression.arguments); + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 192 /* SpreadElementExpression */) { + return false; + } + var expression = callArgument.expression; + return ts.isIdentifier(expression) && expression === parameter.name; + } + } + ts.transformES2015 = transformES2015; })(ts || (ts = {})); /// /// @@ -48214,7 +49378,7 @@ var ts; if (ts.isDeclarationFile(node)) { return node; } - if (node.transformFlags & 1024 /* ContainsGenerator */) { + if (node.transformFlags & 4096 /* ContainsGenerator */) { currentSourceFile = node; node = ts.visitEachChild(node, visitor, context); currentSourceFile = undefined; @@ -48234,10 +49398,10 @@ var ts; else if (inGeneratorFunctionBody) { return visitJavaScriptInGeneratorFunctionBody(node); } - else if (transformFlags & 512 /* Generator */) { + else if (transformFlags & 2048 /* Generator */) { return visitGenerator(node); } - else if (transformFlags & 1024 /* ContainsGenerator */) { + else if (transformFlags & 4096 /* ContainsGenerator */) { return ts.visitEachChild(node, visitor, context); } else { @@ -48251,13 +49415,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 204 /* DoStatement */: + case 205 /* DoStatement */: return visitDoStatement(node); - case 205 /* WhileStatement */: + case 206 /* WhileStatement */: return visitWhileStatement(node); - case 213 /* SwitchStatement */: + case 214 /* SwitchStatement */: return visitSwitchStatement(node); - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -48270,30 +49434,30 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 220 /* FunctionDeclaration */: + case 221 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 179 /* FunctionExpression */: + case 180 /* FunctionExpression */: return visitFunctionExpression(node); - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: return visitAccessorDeclaration(node); - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: return visitVariableStatement(node); - case 206 /* ForStatement */: + case 207 /* ForStatement */: return visitForStatement(node); - case 207 /* ForInStatement */: + case 208 /* ForInStatement */: return visitForInStatement(node); - case 210 /* BreakStatement */: + case 211 /* BreakStatement */: return visitBreakStatement(node); - case 209 /* ContinueStatement */: + case 210 /* ContinueStatement */: return visitContinueStatement(node); - case 211 /* ReturnStatement */: + case 212 /* ReturnStatement */: return visitReturnStatement(node); default: - if (node.transformFlags & 4194304 /* ContainsYield */) { + if (node.transformFlags & 16777216 /* ContainsYield */) { return visitJavaScriptContainingYield(node); } - else if (node.transformFlags & (1024 /* ContainsGenerator */ | 8388608 /* ContainsHoistedDeclarationOrCompletion */)) { + else if (node.transformFlags & (4096 /* ContainsGenerator */ | 33554432 /* ContainsHoistedDeclarationOrCompletion */)) { return ts.visitEachChild(node, visitor, context); } else { @@ -48308,21 +49472,21 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return visitBinaryExpression(node); - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: return visitConditionalExpression(node); - case 190 /* YieldExpression */: + case 191 /* YieldExpression */: return visitYieldExpression(node); - case 170 /* ArrayLiteralExpression */: + case 171 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 171 /* ObjectLiteralExpression */: + case 172 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 173 /* ElementAccessExpression */: + case 174 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 174 /* CallExpression */: + case 175 /* CallExpression */: return visitCallExpression(node); - case 175 /* NewExpression */: + case 176 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -48335,9 +49499,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 220 /* FunctionDeclaration */: + case 221 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 179 /* FunctionExpression */: + case 180 /* FunctionExpression */: return visitFunctionExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -48396,6 +49560,7 @@ var ts; // Currently, we only support generators that were originally async functions. if (node.asteriskToken && ts.getEmitFlags(node) & 2097152 /* AsyncFunctionBody */) { node = ts.setOriginalNode(ts.createFunctionExpression( + /*modifiers*/ undefined, /*asteriskToken*/ undefined, node.name, /*typeParameters*/ undefined, node.parameters, /*type*/ undefined, transformGeneratorFunctionBody(node.body), @@ -48497,7 +49662,7 @@ var ts; * @param node The node to visit. */ function visitVariableStatement(node) { - if (node.transformFlags & 4194304 /* ContainsYield */) { + if (node.transformFlags & 16777216 /* ContainsYield */) { transformAndEmitVariableDeclarationList(node.declarationList); return undefined; } @@ -48536,23 +49701,23 @@ var ts; } } function isCompoundAssignment(kind) { - return kind >= 57 /* FirstCompoundAssignment */ - && kind <= 68 /* LastCompoundAssignment */; + return kind >= 58 /* FirstCompoundAssignment */ + && kind <= 69 /* LastCompoundAssignment */; } function getOperatorForCompoundAssignment(kind) { switch (kind) { - case 57 /* PlusEqualsToken */: return 35 /* PlusToken */; - case 58 /* MinusEqualsToken */: return 36 /* MinusToken */; - case 59 /* AsteriskEqualsToken */: return 37 /* AsteriskToken */; - case 60 /* AsteriskAsteriskEqualsToken */: return 38 /* AsteriskAsteriskToken */; - case 61 /* SlashEqualsToken */: return 39 /* SlashToken */; - case 62 /* PercentEqualsToken */: return 40 /* PercentToken */; - case 63 /* LessThanLessThanEqualsToken */: return 43 /* LessThanLessThanToken */; - case 64 /* GreaterThanGreaterThanEqualsToken */: return 44 /* GreaterThanGreaterThanToken */; - case 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 45 /* GreaterThanGreaterThanGreaterThanToken */; - case 66 /* AmpersandEqualsToken */: return 46 /* AmpersandToken */; - case 67 /* BarEqualsToken */: return 47 /* BarToken */; - case 68 /* CaretEqualsToken */: return 48 /* CaretToken */; + case 58 /* PlusEqualsToken */: return 36 /* PlusToken */; + case 59 /* MinusEqualsToken */: return 37 /* MinusToken */; + case 60 /* AsteriskEqualsToken */: return 38 /* AsteriskToken */; + case 61 /* AsteriskAsteriskEqualsToken */: return 39 /* AsteriskAsteriskToken */; + case 62 /* SlashEqualsToken */: return 40 /* SlashToken */; + case 63 /* PercentEqualsToken */: return 41 /* PercentToken */; + case 64 /* LessThanLessThanEqualsToken */: return 44 /* LessThanLessThanToken */; + case 65 /* GreaterThanGreaterThanEqualsToken */: return 45 /* GreaterThanGreaterThanToken */; + case 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 46 /* GreaterThanGreaterThanGreaterThanToken */; + case 67 /* AmpersandEqualsToken */: return 47 /* AmpersandToken */; + case 68 /* BarEqualsToken */: return 48 /* BarToken */; + case 69 /* CaretEqualsToken */: return 49 /* CaretToken */; } } /** @@ -48565,7 +49730,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -48577,7 +49742,7 @@ var ts; // _a.b = %sent%; target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 173 /* ElementAccessExpression */: + case 174 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -48596,7 +49761,7 @@ var ts; } var operator = node.operatorToken.kind; if (isCompoundAssignment(operator)) { - return ts.createBinary(target, 56 /* EqualsToken */, ts.createBinary(cacheExpression(target), getOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression), node), node); + return ts.createBinary(target, 57 /* EqualsToken */, ts.createBinary(cacheExpression(target), getOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression), node), node); } else { return ts.updateBinary(node, target, ts.visitNode(right, visitor, ts.isExpression)); @@ -48609,7 +49774,7 @@ var ts; if (ts.isLogicalOperator(node.operatorToken.kind)) { return visitLogicalBinaryExpression(node); } - else if (node.operatorToken.kind === 24 /* CommaToken */) { + else if (node.operatorToken.kind === 25 /* CommaToken */) { return visitCommaExpression(node); } // [source] @@ -48620,10 +49785,10 @@ var ts; // _a = a(); // .yield resumeLabel // _a + %sent% + c() - var clone_5 = ts.getMutableClone(node); - clone_5.left = cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression)); - clone_5.right = ts.visitNode(node.right, visitor, ts.isExpression); - return clone_5; + var clone_6 = ts.getMutableClone(node); + clone_6.left = cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression)); + clone_6.right = ts.visitNode(node.right, visitor, ts.isExpression); + return clone_6; } return ts.visitEachChild(node, visitor, context); } @@ -48664,7 +49829,7 @@ var ts; var resultLabel = defineLabel(); var resultLocal = declareLocal(); emitAssignment(resultLocal, ts.visitNode(node.left, visitor, ts.isExpression), /*location*/ node.left); - if (node.operatorToken.kind === 51 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 52 /* AmpersandAmpersandToken */) { // Logical `&&` shortcuts when the left-hand operand is falsey. emitBreakWhenFalse(resultLabel, resultLocal, /*location*/ node.left); } @@ -48695,7 +49860,7 @@ var ts; visit(node.right); return ts.inlineExpressions(pendingExpressions); function visit(node) { - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 24 /* CommaToken */) { + if (ts.isBinaryExpression(node) && node.operatorToken.kind === 25 /* CommaToken */) { visit(node.left); visit(node.right); } @@ -48785,7 +49950,7 @@ var ts; * @param elements The elements to visit. * @param multiLine Whether array literals created should be emitted on multiple lines. */ - function visitElements(elements, multiLine) { + function visitElements(elements, _multiLine) { // [source] // ar = [1, yield, 2]; // @@ -48877,10 +50042,10 @@ var ts; // .yield resumeLabel // .mark resumeLabel // a = _a[%sent%] - var clone_6 = ts.getMutableClone(node); - clone_6.expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); - clone_6.argumentExpression = ts.visitNode(node.argumentExpression, visitor, ts.isExpression); - return clone_6; + var clone_7 = ts.getMutableClone(node); + clone_7.expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); + clone_7.argumentExpression = ts.visitNode(node.argumentExpression, visitor, ts.isExpression); + return clone_7; } return ts.visitEachChild(node, visitor, context); } @@ -48897,7 +50062,7 @@ var ts; // .mark resumeLabel // _b.apply(_a, _c.concat([%sent%, 2])); var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration, languageVersion, /*cacheIdentifiers*/ true), target = _a.target, thisArg = _a.thisArg; - return ts.setOriginalNode(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isLeftHandSideExpression)), thisArg, visitElements(node.arguments, /*multiLine*/ false), + return ts.setOriginalNode(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isLeftHandSideExpression)), thisArg, visitElements(node.arguments), /*location*/ node), node); } return ts.visitEachChild(node, visitor, context); @@ -48915,7 +50080,7 @@ var ts; // .mark resumeLabel // new (_b.apply(_a, _c.concat([%sent%, 2]))); var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.setOriginalNode(ts.createNew(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isExpression)), thisArg, visitElements(node.arguments, /*multiLine*/ false)), + return ts.setOriginalNode(ts.createNew(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isExpression)), thisArg, visitElements(node.arguments)), /*typeArguments*/ undefined, [], /*location*/ node), node); } @@ -48946,35 +50111,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 199 /* Block */: + case 200 /* Block */: return transformAndEmitBlock(node); - case 202 /* ExpressionStatement */: + case 203 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 203 /* IfStatement */: + case 204 /* IfStatement */: return transformAndEmitIfStatement(node); - case 204 /* DoStatement */: + case 205 /* DoStatement */: return transformAndEmitDoStatement(node); - case 205 /* WhileStatement */: + case 206 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 206 /* ForStatement */: + case 207 /* ForStatement */: return transformAndEmitForStatement(node); - case 207 /* ForInStatement */: + case 208 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 209 /* ContinueStatement */: + case 210 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 210 /* BreakStatement */: + case 211 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 211 /* ReturnStatement */: + case 212 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 212 /* WithStatement */: + case 213 /* WithStatement */: return transformAndEmitWithStatement(node); - case 213 /* SwitchStatement */: + case 214 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 215 /* ThrowStatement */: + case 216 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 216 /* TryStatement */: + case 217 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement, /*optional*/ true)); @@ -49538,7 +50703,7 @@ var ts; } } function containsYield(node) { - return node && (node.transformFlags & 4194304 /* ContainsYield */) !== 0; + return node && (node.transformFlags & 16777216 /* ContainsYield */) !== 0; } function countInitialNodesWithoutYield(nodes) { var numNodes = nodes.length; @@ -49568,12 +50733,12 @@ var ts; if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - var name_37 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); - if (name_37) { - var clone_7 = ts.getMutableClone(name_37); - ts.setSourceMapRange(clone_7, node); - ts.setCommentRange(clone_7, node); - return clone_7; + var name_34 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); + if (name_34) { + var clone_8 = ts.getMutableClone(name_34); + ts.setSourceMapRange(clone_8, node); + ts.setCommentRange(clone_8, node); + return clone_8; } } } @@ -49715,7 +50880,7 @@ var ts; if (!renamedCatchVariables) { renamedCatchVariables = ts.createMap(); renamedCatchVariableDeclarations = ts.createMap(); - context.enableSubstitution(69 /* Identifier */); + context.enableSubstitution(70 /* Identifier */); } renamedCatchVariables[text] = true; renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; @@ -49981,7 +51146,7 @@ var ts; } return expression; } - return ts.createNode(193 /* OmittedExpression */); + return ts.createNode(194 /* OmittedExpression */); } /** * Creates a numeric literal for the provided instruction. @@ -50163,6 +51328,7 @@ var ts; /*typeArguments*/ undefined, [ ts.createThis(), ts.setEmitFlags(ts.createFunctionExpression( + /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, [ts.createParameter(state)], @@ -50542,2306 +51708,589 @@ var ts; ts.transformGenerators = transformGenerators; var _a; })(ts || (ts = {})); -/// -/// +/// +/// /*@internal*/ var ts; (function (ts) { - var ES6SubstitutionFlags; - (function (ES6SubstitutionFlags) { - /** Enables substitutions for captured `this` */ - ES6SubstitutionFlags[ES6SubstitutionFlags["CapturedThis"] = 1] = "CapturedThis"; - /** Enables substitutions for block-scoped bindings. */ - ES6SubstitutionFlags[ES6SubstitutionFlags["BlockScopedBindings"] = 2] = "BlockScopedBindings"; - })(ES6SubstitutionFlags || (ES6SubstitutionFlags = {})); - var CopyDirection; - (function (CopyDirection) { - CopyDirection[CopyDirection["ToOriginal"] = 0] = "ToOriginal"; - CopyDirection[CopyDirection["ToOutParameter"] = 1] = "ToOutParameter"; - })(CopyDirection || (CopyDirection = {})); - var Jump; - (function (Jump) { - Jump[Jump["Break"] = 2] = "Break"; - Jump[Jump["Continue"] = 4] = "Continue"; - Jump[Jump["Return"] = 8] = "Return"; - })(Jump || (Jump = {})); - var SuperCaptureResult; - (function (SuperCaptureResult) { - /** - * A capture may have been added for calls to 'super', but - * the caller should emit subsequent statements normally. - */ - SuperCaptureResult[SuperCaptureResult["NoReplacement"] = 0] = "NoReplacement"; - /** - * A call to 'super()' got replaced with a capturing statement like: - * - * var _this = _super.call(...) || this; - * - * Callers should skip the current statement. - */ - SuperCaptureResult[SuperCaptureResult["ReplaceSuperCapture"] = 1] = "ReplaceSuperCapture"; - /** - * A call to 'super()' got replaced with a capturing statement like: - * - * return _super.call(...) || this; - * - * Callers should skip the current statement and avoid any returns of '_this'. - */ - SuperCaptureResult[SuperCaptureResult["ReplaceWithReturn"] = 2] = "ReplaceWithReturn"; - })(SuperCaptureResult || (SuperCaptureResult = {})); - function transformES6(context) { + function transformModule(context) { + var transformModuleDelegates = ts.createMap((_a = {}, + _a[ts.ModuleKind.None] = transformCommonJSModule, + _a[ts.ModuleKind.CommonJS] = transformCommonJSModule, + _a[ts.ModuleKind.AMD] = transformAMDModule, + _a[ts.ModuleKind.UMD] = transformUMDModule, + _a)); var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; + var compilerOptions = context.getCompilerOptions(); var resolver = context.getEmitResolver(); + var host = context.getEmitHost(); + var languageVersion = ts.getEmitScriptTarget(compilerOptions); + var moduleKind = ts.getEmitModuleKind(compilerOptions); var previousOnSubstituteNode = context.onSubstituteNode; var previousOnEmitNode = context.onEmitNode; - context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; + context.onEmitNode = onEmitNode; + context.enableSubstitution(70 /* Identifier */); + context.enableSubstitution(188 /* BinaryExpression */); + context.enableSubstitution(186 /* PrefixUnaryExpression */); + context.enableSubstitution(187 /* PostfixUnaryExpression */); + context.enableSubstitution(254 /* ShorthandPropertyAssignment */); + context.enableEmitNotification(256 /* SourceFile */); var currentSourceFile; - var currentText; - var currentParent; - var currentNode; - var enclosingVariableStatement; - var enclosingBlockScopeContainer; - var enclosingBlockScopeContainerParent; - var enclosingFunction; - var enclosingNonArrowFunction; - var enclosingNonAsyncFunctionBody; - /** - * Used to track if we are emitting body of the converted loop - */ - var convertedLoopState; - /** - * Keeps track of whether substitutions have been enabled for specific cases. - * They are persisted between each SourceFile transformation and should not - * be reset. - */ - var enabledSubstitutions; + var externalImports; + var exportSpecifiers; + var exportEquals; + var bindingNameExportSpecifiersMap; + // Subset of exportSpecifiers that is a binding-name. + // This is to reduce amount of memory we have to keep around even after we done with module-transformer + var bindingNameExportSpecifiersForFileMap = ts.createMap(); + var hasExportStarsToExportValues; return transformSourceFile; + /** + * Transforms the module aspects of a SourceFile. + * + * @param node The SourceFile node. + */ function transformSourceFile(node) { if (ts.isDeclarationFile(node)) { return node; } - currentSourceFile = node; - currentText = node.text; - return ts.visitNode(node, visitor, ts.isSourceFile); - } - function visitor(node) { - return saveStateAndInvoke(node, dispatcher); - } - function dispatcher(node) { - return convertedLoopState - ? visitorForConvertedLoopWorker(node) - : visitorWorker(node); - } - function saveStateAndInvoke(node, f) { - var savedEnclosingFunction = enclosingFunction; - var savedEnclosingNonArrowFunction = enclosingNonArrowFunction; - var savedEnclosingNonAsyncFunctionBody = enclosingNonAsyncFunctionBody; - var savedEnclosingBlockScopeContainer = enclosingBlockScopeContainer; - var savedEnclosingBlockScopeContainerParent = enclosingBlockScopeContainerParent; - var savedEnclosingVariableStatement = enclosingVariableStatement; - var savedCurrentParent = currentParent; - var savedCurrentNode = currentNode; - var savedConvertedLoopState = convertedLoopState; - if (ts.nodeStartsNewLexicalEnvironment(node)) { - // don't treat content of nodes that start new lexical environment as part of converted loop copy - convertedLoopState = undefined; + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + currentSourceFile = node; + // Collect information about the external module. + (_a = ts.collectExternalModuleInfo(node), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); + // Perform the transformation. + var transformModule_1 = transformModuleDelegates[moduleKind] || transformModuleDelegates[ts.ModuleKind.None]; + var updated = transformModule_1(node); + ts.aggregateTransformFlags(updated); + currentSourceFile = undefined; + externalImports = undefined; + exportSpecifiers = undefined; + exportEquals = undefined; + hasExportStarsToExportValues = false; + return updated; } - onBeforeVisitNode(node); - var visited = f(node); - convertedLoopState = savedConvertedLoopState; - enclosingFunction = savedEnclosingFunction; - enclosingNonArrowFunction = savedEnclosingNonArrowFunction; - enclosingNonAsyncFunctionBody = savedEnclosingNonAsyncFunctionBody; - enclosingBlockScopeContainer = savedEnclosingBlockScopeContainer; - enclosingBlockScopeContainerParent = savedEnclosingBlockScopeContainerParent; - enclosingVariableStatement = savedEnclosingVariableStatement; - currentParent = savedCurrentParent; - currentNode = savedCurrentNode; - return visited; - } - function shouldCheckNode(node) { - return (node.transformFlags & 64 /* ES6 */) !== 0 || - node.kind === 214 /* LabeledStatement */ || - (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)); - } - function visitorWorker(node) { - if (shouldCheckNode(node)) { - return visitJavaScript(node); - } - else if (node.transformFlags & 128 /* ContainsES6 */) { - return ts.visitEachChild(node, visitor, context); - } - else { - return node; - } - } - function visitorForConvertedLoopWorker(node) { - var result; - if (shouldCheckNode(node)) { - result = visitJavaScript(node); - } - else { - result = visitNodesInConvertedLoop(node); - } - return result; - } - function visitNodesInConvertedLoop(node) { - switch (node.kind) { - case 211 /* ReturnStatement */: - return visitReturnStatement(node); - case 200 /* VariableStatement */: - return visitVariableStatement(node); - case 213 /* SwitchStatement */: - return visitSwitchStatement(node); - case 210 /* BreakStatement */: - case 209 /* ContinueStatement */: - return visitBreakOrContinueStatement(node); - case 97 /* ThisKeyword */: - return visitThisKeyword(node); - case 69 /* Identifier */: - return visitIdentifier(node); - default: - return ts.visitEachChild(node, visitor, context); - } - } - function visitJavaScript(node) { - switch (node.kind) { - case 82 /* ExportKeyword */: - return node; - case 221 /* ClassDeclaration */: - return visitClassDeclaration(node); - case 192 /* ClassExpression */: - return visitClassExpression(node); - case 142 /* Parameter */: - return visitParameter(node); - case 220 /* FunctionDeclaration */: - return visitFunctionDeclaration(node); - case 180 /* ArrowFunction */: - return visitArrowFunction(node); - case 179 /* FunctionExpression */: - return visitFunctionExpression(node); - case 218 /* VariableDeclaration */: - return visitVariableDeclaration(node); - case 69 /* Identifier */: - return visitIdentifier(node); - case 219 /* VariableDeclarationList */: - return visitVariableDeclarationList(node); - case 214 /* LabeledStatement */: - return visitLabeledStatement(node); - case 204 /* DoStatement */: - return visitDoStatement(node); - case 205 /* WhileStatement */: - return visitWhileStatement(node); - case 206 /* ForStatement */: - return visitForStatement(node); - case 207 /* ForInStatement */: - return visitForInStatement(node); - case 208 /* ForOfStatement */: - return visitForOfStatement(node); - case 202 /* ExpressionStatement */: - return visitExpressionStatement(node); - case 171 /* ObjectLiteralExpression */: - return visitObjectLiteralExpression(node); - case 254 /* ShorthandPropertyAssignment */: - return visitShorthandPropertyAssignment(node); - case 170 /* ArrayLiteralExpression */: - return visitArrayLiteralExpression(node); - case 174 /* CallExpression */: - return visitCallExpression(node); - case 175 /* NewExpression */: - return visitNewExpression(node); - case 178 /* ParenthesizedExpression */: - return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 187 /* BinaryExpression */: - return visitBinaryExpression(node, /*needsDestructuringValue*/ true); - case 11 /* NoSubstitutionTemplateLiteral */: - case 12 /* TemplateHead */: - case 13 /* TemplateMiddle */: - case 14 /* TemplateTail */: - return visitTemplateLiteral(node); - case 176 /* TaggedTemplateExpression */: - return visitTaggedTemplateExpression(node); - case 189 /* TemplateExpression */: - return visitTemplateExpression(node); - case 190 /* YieldExpression */: - return visitYieldExpression(node); - case 95 /* SuperKeyword */: - return visitSuperKeyword(node); - case 190 /* YieldExpression */: - // `yield` will be handled by a generators transform. - return ts.visitEachChild(node, visitor, context); - case 147 /* MethodDeclaration */: - return visitMethodDeclaration(node); - case 256 /* SourceFile */: - return visitSourceFileNode(node); - case 200 /* VariableStatement */: - return visitVariableStatement(node); - default: - ts.Debug.failBadSyntaxKind(node); - return ts.visitEachChild(node, visitor, context); - } - } - function onBeforeVisitNode(node) { - if (currentNode) { - if (ts.isBlockScope(currentNode, currentParent)) { - enclosingBlockScopeContainer = currentNode; - enclosingBlockScopeContainerParent = currentParent; - } - if (ts.isFunctionLike(currentNode)) { - enclosingFunction = currentNode; - if (currentNode.kind !== 180 /* ArrowFunction */) { - enclosingNonArrowFunction = currentNode; - if (!(ts.getEmitFlags(currentNode) & 2097152 /* AsyncFunctionBody */)) { - enclosingNonAsyncFunctionBody = currentNode; - } - } - } - // keep track of the enclosing variable statement when in the context of - // variable statements, variable declarations, binding elements, and binding - // patterns. - switch (currentNode.kind) { - case 200 /* VariableStatement */: - enclosingVariableStatement = currentNode; - break; - case 219 /* VariableDeclarationList */: - case 218 /* VariableDeclaration */: - case 169 /* BindingElement */: - case 167 /* ObjectBindingPattern */: - case 168 /* ArrayBindingPattern */: - break; - default: - enclosingVariableStatement = undefined; - } - } - currentParent = currentNode; - currentNode = node; - } - function visitSwitchStatement(node) { - ts.Debug.assert(convertedLoopState !== undefined); - var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; - // for switch statement allow only non-labeled break - convertedLoopState.allowedNonLabeledJumps |= 2 /* Break */; - var result = ts.visitEachChild(node, visitor, context); - convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; - return result; - } - function visitReturnStatement(node) { - ts.Debug.assert(convertedLoopState !== undefined); - convertedLoopState.nonLocalJumps |= 8 /* Return */; - return ts.createReturn(ts.createObjectLiteral([ - ts.createPropertyAssignment(ts.createIdentifier("value"), node.expression - ? ts.visitNode(node.expression, visitor, ts.isExpression) - : ts.createVoidZero()) - ])); - } - function visitThisKeyword(node) { - ts.Debug.assert(convertedLoopState !== undefined); - if (enclosingFunction && enclosingFunction.kind === 180 /* ArrowFunction */) { - // if the enclosing function is an ArrowFunction is then we use the captured 'this' keyword. - convertedLoopState.containsLexicalThis = true; - return node; - } - return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this")); - } - function visitIdentifier(node) { - if (!convertedLoopState) { - return node; - } - if (ts.isGeneratedIdentifier(node)) { - return node; - } - if (node.text !== "arguments" && !resolver.isArgumentsLocalBinding(node)) { - return node; - } - return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = ts.createUniqueName("arguments")); - } - function visitBreakOrContinueStatement(node) { - if (convertedLoopState) { - // check if we can emit break/continue as is - // it is possible if either - // - break/continue is labeled and label is located inside the converted loop - // - break/continue is non-labeled and located in non-converted loop/switch statement - var jump = node.kind === 210 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; - var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || - (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); - if (!canUseBreakOrContinue) { - var labelMarker = void 0; - if (!node.label) { - if (node.kind === 210 /* BreakStatement */) { - convertedLoopState.nonLocalJumps |= 2 /* Break */; - labelMarker = "break"; - } - else { - convertedLoopState.nonLocalJumps |= 4 /* Continue */; - // note: return value is emitted only to simplify debugging, call to converted loop body does not do any dispatching on it. - labelMarker = "continue"; - } - } - else { - if (node.kind === 210 /* BreakStatement */) { - labelMarker = "break-" + node.label.text; - setLabeledJump(convertedLoopState, /*isBreak*/ true, node.label.text, labelMarker); - } - else { - labelMarker = "continue-" + node.label.text; - setLabeledJump(convertedLoopState, /*isBreak*/ false, node.label.text, labelMarker); - } - } - var returnExpression = ts.createLiteral(labelMarker); - if (convertedLoopState.loopOutParameters.length) { - var outParams = convertedLoopState.loopOutParameters; - var expr = void 0; - for (var i = 0; i < outParams.length; i++) { - var copyExpr = copyOutParameter(outParams[i], 1 /* ToOutParameter */); - if (i === 0) { - expr = copyExpr; - } - else { - expr = ts.createBinary(expr, 24 /* CommaToken */, copyExpr); - } - } - returnExpression = ts.createBinary(expr, 24 /* CommaToken */, returnExpression); - } - return ts.createReturn(returnExpression); - } - } - return ts.visitEachChild(node, visitor, context); + return node; + var _a; } /** - * Visits a ClassDeclaration and transforms it into a variable statement. + * Transforms a SourceFile into a CommonJS module. * - * @param node A ClassDeclaration node. + * @param node The SourceFile node. */ - function visitClassDeclaration(node) { - // [source] - // class C { } - // - // [output] - // var C = (function () { - // function C() { - // } - // return C; - // }()); - var modifierFlags = ts.getModifierFlags(node); - var isExported = modifierFlags & 1 /* Export */; - var isDefault = modifierFlags & 512 /* Default */; - // Add an `export` modifier to the statement if needed (for `--target es5 --module es6`) - var modifiers = isExported && !isDefault - ? ts.filter(node.modifiers, isExportModifier) - : undefined; - var statement = ts.createVariableStatement(modifiers, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(getDeclarationName(node, /*allowComments*/ true), - /*type*/ undefined, transformClassLikeDeclarationToExpression(node)) - ]), - /*location*/ node); - ts.setOriginalNode(statement, node); - ts.startOnNewLine(statement); - // Add an `export default` statement for default exports (for `--target es5 --module es6`) - if (isExported && isDefault) { - var statements = [statement]; - statements.push(ts.createExportAssignment( - /*decorators*/ undefined, - /*modifiers*/ undefined, - /*isExportEquals*/ false, getDeclarationName(node, /*allowComments*/ false))); - return statements; - } - return statement; - } - function isExportModifier(node) { - return node.kind === 82 /* ExportKeyword */; - } - /** - * Visits a ClassExpression and transforms it into an expression. - * - * @param node A ClassExpression node. - */ - function visitClassExpression(node) { - // [source] - // C = class { } - // - // [output] - // C = (function () { - // function class_1() { - // } - // return class_1; - // }()) - return transformClassLikeDeclarationToExpression(node); - } - /** - * Transforms a ClassExpression or ClassDeclaration into an expression. - * - * @param node A ClassExpression or ClassDeclaration node. - */ - function transformClassLikeDeclarationToExpression(node) { - // [source] - // class C extends D { - // constructor() {} - // method() {} - // get prop() {} - // set prop(v) {} - // } - // - // [output] - // (function (_super) { - // __extends(C, _super); - // function C() { - // } - // C.prototype.method = function () {} - // Object.defineProperty(C.prototype, "prop", { - // get: function() {}, - // set: function() {}, - // enumerable: true, - // configurable: true - // }); - // return C; - // }(D)) - if (node.name) { - enableSubstitutionsForBlockScopedBindings(); - } - var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); - var classFunction = ts.createFunctionExpression( - /*asteriskToken*/ undefined, - /*name*/ undefined, - /*typeParameters*/ undefined, extendsClauseElement ? [ts.createParameter("_super")] : [], - /*type*/ undefined, transformClassBody(node, extendsClauseElement)); - // To preserve the behavior of the old emitter, we explicitly indent - // the body of the function here if it was requested in an earlier - // transformation. - if (ts.getEmitFlags(node) & 524288 /* Indented */) { - ts.setEmitFlags(classFunction, 524288 /* Indented */); - } - // "inner" and "outer" below are added purely to preserve source map locations from - // the old emitter - var inner = ts.createPartiallyEmittedExpression(classFunction); - inner.end = node.end; - ts.setEmitFlags(inner, 49152 /* NoComments */); - var outer = ts.createPartiallyEmittedExpression(inner); - outer.end = ts.skipTrivia(currentText, node.pos); - ts.setEmitFlags(outer, 49152 /* NoComments */); - return ts.createParen(ts.createCall(outer, - /*typeArguments*/ undefined, extendsClauseElement - ? [ts.visitNode(extendsClauseElement.expression, visitor, ts.isExpression)] - : [])); - } - /** - * Transforms a ClassExpression or ClassDeclaration into a function body. - * - * @param node A ClassExpression or ClassDeclaration node. - * @param extendsClauseElement The expression for the class `extends` clause. - */ - function transformClassBody(node, extendsClauseElement) { - var statements = []; + function transformCommonJSModule(node) { startLexicalEnvironment(); - addExtendsHelperIfNeeded(statements, node, extendsClauseElement); - addConstructor(statements, node, extendsClauseElement); - addClassMembers(statements, node); - // Create a synthetic text range for the return statement. - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 16 /* CloseBraceToken */); - var localName = getLocalName(node); - // The following partially-emitted expression exists purely to align our sourcemap - // emit with the original emitter. - var outer = ts.createPartiallyEmittedExpression(localName); - outer.end = closingBraceLocation.end; - ts.setEmitFlags(outer, 49152 /* NoComments */); - var statement = ts.createReturn(outer); - statement.pos = closingBraceLocation.pos; - ts.setEmitFlags(statement, 49152 /* NoComments */ | 12288 /* NoTokenSourceMaps */); - statements.push(statement); - ts.addRange(statements, endLexicalEnvironment()); - var block = ts.createBlock(ts.createNodeArray(statements, /*location*/ node.members), /*location*/ undefined, /*multiLine*/ true); - ts.setEmitFlags(block, 49152 /* NoComments */); - return block; - } - /** - * Adds a call to the `__extends` helper if needed for a class. - * - * @param statements The statements of the class body function. - * @param node The ClassExpression or ClassDeclaration node. - * @param extendsClauseElement The expression for the class `extends` clause. - */ - function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) { - if (extendsClauseElement) { - statements.push(ts.createStatement(ts.createExtendsHelper(currentSourceFile.externalHelpersModuleName, getDeclarationName(node)), - /*location*/ extendsClauseElement)); - } - } - /** - * Adds the constructor of the class to a class body function. - * - * @param statements The statements of the class body function. - * @param node The ClassExpression or ClassDeclaration node. - * @param extendsClauseElement The expression for the class `extends` clause. - */ - function addConstructor(statements, node, extendsClauseElement) { - var constructor = ts.getFirstConstructorWithBody(node); - var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); - var constructorFunction = ts.createFunctionDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, - /*asteriskToken*/ undefined, getDeclarationName(node), - /*typeParameters*/ undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), - /*type*/ undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), - /*location*/ constructor || node); - if (extendsClauseElement) { - ts.setEmitFlags(constructorFunction, 256 /* CapturesThis */); - } - statements.push(constructorFunction); - } - /** - * Transforms the parameters of the constructor declaration of a class. - * - * @param constructor The constructor for the class. - * @param hasSynthesizedSuper A value indicating whether the constructor starts with a - * synthesized `super` call. - */ - function transformConstructorParameters(constructor, hasSynthesizedSuper) { - // If the TypeScript transformer needed to synthesize a constructor for property - // initializers, it would have also added a synthetic `...args` parameter and - // `super` call. - // If this is the case, we do not include the synthetic `...args` parameter and - // will instead use the `arguments` object in ES5/3. - if (constructor && !hasSynthesizedSuper) { - return ts.visitNodes(constructor.parameters, visitor, ts.isParameter); - } - return []; - } - /** - * Transforms the body of a constructor declaration of a class. - * - * @param constructor The constructor for the class. - * @param node The node which contains the constructor. - * @param extendsClauseElement The expression for the class `extends` clause. - * @param hasSynthesizedSuper A value indicating whether the constructor starts with a - * synthesized `super` call. - */ - function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { var statements = []; - startLexicalEnvironment(); - var statementOffset = -1; - if (hasSynthesizedSuper) { - // If a super call has already been synthesized, - // we're going to assume that we should just transform everything after that. - // The assumption is that no prior step in the pipeline has added any prologue directives. - statementOffset = 1; - } - else if (constructor) { - // Otherwise, try to emit all potential prologue directives first. - statementOffset = ts.addPrologueDirectives(statements, constructor.body.statements, /*ensureUseStrict*/ false, visitor); - } - if (constructor) { - addDefaultValueAssignmentsIfNeeded(statements, constructor); - addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); - ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); - } - var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, !!extendsClauseElement, hasSynthesizedSuper, statementOffset); - // The last statement expression was replaced. Skip it. - if (superCaptureStatus === 1 /* ReplaceSuperCapture */ || superCaptureStatus === 2 /* ReplaceWithReturn */) { - statementOffset++; - } - if (constructor) { - var body = saveStateAndInvoke(constructor, function (constructor) { return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, /*start*/ statementOffset); }); - ts.addRange(statements, body); - } - // Return `_this` unless we're sure enough that it would be pointless to add a return statement. - // If there's a constructor that we can tell returns in enough places, then we *do not* want to add a return. - if (extendsClauseElement - && superCaptureStatus !== 2 /* ReplaceWithReturn */ - && !(constructor && isSufficientlyCoveredByReturnStatements(constructor.body))) { - statements.push(ts.createReturn(ts.createIdentifier("_this"))); - } + var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, visitor); + ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); - var block = ts.createBlock(ts.createNodeArray(statements, - /*location*/ constructor ? constructor.body.statements : node.members), - /*location*/ constructor ? constructor.body : node, - /*multiLine*/ true); - if (!constructor) { - ts.setEmitFlags(block, 49152 /* NoComments */); + addExportEqualsIfNeeded(statements, /*emitAsReturn*/ false); + var updated = updateSourceFile(node, statements); + if (hasExportStarsToExportValues) { + ts.setEmitFlags(updated, 2 /* EmitExportStar */ | ts.getEmitFlags(node)); } - return block; + return updated; } /** - * We want to try to avoid emitting a return statement in certain cases if a user already returned something. - * It would generate obviously dead code, so we'll try to make things a little bit prettier - * by doing a minimal check on whether some common patterns always explicitly return. - */ - function isSufficientlyCoveredByReturnStatements(statement) { - // A return statement is considered covered. - if (statement.kind === 211 /* ReturnStatement */) { - return true; - } - else if (statement.kind === 203 /* IfStatement */) { - var ifStatement = statement; - if (ifStatement.elseStatement) { - return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && - isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); - } - } - else if (statement.kind === 199 /* Block */) { - var lastStatement = ts.lastOrUndefined(statement.statements); - if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { - return true; - } - } - return false; - } - /** - * Declares a `_this` variable for derived classes and for when arrow functions capture `this`. + * Transforms a SourceFile into an AMD module. * - * @returns The new statement offset into the `statements` array. + * @param node The SourceFile node. */ - function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, hasExtendsClause, hasSynthesizedSuper, statementOffset) { - // If this isn't a derived class, just capture 'this' for arrow functions if necessary. - if (!hasExtendsClause) { - if (ctor) { - addCaptureThisForNodeIfNeeded(statements, ctor); - } - return 0 /* NoReplacement */; - } - // We must be here because the user didn't write a constructor - // but we needed to call 'super(...args)' anyway as per 14.5.14 of the ES2016 spec. - // If that's the case we can just immediately return the result of a 'super()' call. - if (!ctor) { - statements.push(ts.createReturn(createDefaultSuperCallOrThis())); - return 2 /* ReplaceWithReturn */; - } - // The constructor exists, but it and the 'super()' call it contains were generated - // for something like property initializers. - // Create a captured '_this' variable and assume it will subsequently be used. - if (hasSynthesizedSuper) { - captureThisForNode(statements, ctor, createDefaultSuperCallOrThis()); - enableSubstitutionsForCapturedThis(); - return 1 /* ReplaceSuperCapture */; - } - // Most of the time, a 'super' call will be the first real statement in a constructor body. - // In these cases, we'd like to transform these into a *single* statement instead of a declaration - // followed by an assignment statement for '_this'. For instance, if we emitted without an initializer, - // we'd get: + function transformAMDModule(node) { + var define = ts.createIdentifier("define"); + var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); + return transformAsynchronousModule(node, define, moduleName, /*includeNonAmdDependencies*/ true); + } + /** + * Transforms a SourceFile into a UMD module. + * + * @param node The SourceFile node. + */ + function transformUMDModule(node) { + var define = ts.createIdentifier("define"); + ts.setEmitFlags(define, 16 /* UMDDefine */); + return transformAsynchronousModule(node, define, /*moduleName*/ undefined, /*includeNonAmdDependencies*/ false); + } + /** + * Transforms a SourceFile into an AMD or UMD module. + * + * @param node The SourceFile node. + * @param define The expression used to define the module. + * @param moduleName An expression for the module name, if available. + * @param includeNonAmdDependencies A value indicating whether to incldue any non-AMD dependencies. + */ + function transformAsynchronousModule(node, define, moduleName, includeNonAmdDependencies) { + // An AMD define function has the following shape: // - // var _this; - // _this = _super.call(...) || this; + // define(id?, dependencies?, factory); // - // instead of + // This has the shape of the following: // - // var _this = _super.call(...) || this; + // define(name, ["module1", "module2"], function (module1Alias) { ... } // - // Additionally, if the 'super()' call is the last statement, we should just avoid capturing - // entirely and immediately return the result like so: + // 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. // - // return _super.call(...) || this; + // To ensure this is true in cases of modules with no aliases, e.g.: // - var firstStatement; - var superCallExpression; - var ctorStatements = ctor.body.statements; - if (statementOffset < ctorStatements.length) { - firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 202 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { - var superCall = firstStatement.expression; - superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); - } - } - // Return the result if we have an immediate super() call on the last statement. - if (superCallExpression && statementOffset === ctorStatements.length - 1) { - statements.push(ts.createReturn(superCallExpression)); - return 2 /* ReplaceWithReturn */; - } - // Perform the capture. - captureThisForNode(statements, ctor, superCallExpression, firstStatement); - // If we're actually replacing the original statement, we need to signal this to the caller. - if (superCallExpression) { - return 1 /* ReplaceSuperCapture */; - } - return 0 /* NoReplacement */; - } - function createDefaultSuperCallOrThis() { - var actualThis = ts.createThis(); - ts.setEmitFlags(actualThis, 128 /* NoSubstitution */); - var superCall = ts.createFunctionApply(ts.createIdentifier("_super"), actualThis, ts.createIdentifier("arguments")); - return ts.createLogicalOr(superCall, actualThis); - } - /** - * Visits a parameter declaration. - * - * @param node A ParameterDeclaration node. - */ - function visitParameter(node) { - if (node.dotDotDotToken) { - // rest parameters are elided - return undefined; - } - else if (ts.isBindingPattern(node.name)) { - // Binding patterns are converted into a generated name and are - // evaluated inside the function body. - return ts.setOriginalNode(ts.createParameter(ts.getGeneratedNameForNode(node), - /*initializer*/ undefined, - /*location*/ node), - /*original*/ node); - } - else if (node.initializer) { - // Initializers are elided - return ts.setOriginalNode(ts.createParameter(node.name, - /*initializer*/ undefined, - /*location*/ node), - /*original*/ node); - } - else { - return node; - } - } - /** - * Gets a value indicating whether we need to add default value assignments for a - * function-like node. - * - * @param node A function-like node. - */ - function shouldAddDefaultValueAssignments(node) { - return (node.transformFlags & 65536 /* ContainsDefaultValueAssignments */) !== 0; - } - /** - * Adds statements to the body of a function-like node if it contains parameters with - * binding patterns or initializers. - * - * @param statements The statements for the new function body. - * @param node A function-like node. - */ - function addDefaultValueAssignmentsIfNeeded(statements, node) { - if (!shouldAddDefaultValueAssignments(node)) { - return; - } - for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { - var parameter = _a[_i]; - var name_38 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; - // A rest parameter cannot have a binding pattern or an initializer, - // so let's just ignore it. - if (dotDotDotToken) { - continue; - } - if (ts.isBindingPattern(name_38)) { - addDefaultValueAssignmentForBindingPattern(statements, parameter, name_38, initializer); - } - else if (initializer) { - addDefaultValueAssignmentForInitializer(statements, parameter, name_38, initializer); - } - } - } - /** - * Adds statements to the body of a function-like node for parameters with binding patterns - * - * @param statements The statements for the new function body. - * @param parameter The parameter for the function. - * @param name The name of the parameter. - * @param initializer The initializer for the parameter. - */ - function addDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer) { - var temp = ts.getGeneratedNameForNode(parameter); - // In cases where a binding pattern is simply '[]' or '{}', - // we usually don't want to emit a var declaration; however, in the presence - // of an initializer, we must emit that expression to preserve side effects. - if (name.elements.length > 0) { - statements.push(ts.setEmitFlags(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList(ts.flattenParameterDestructuring(context, parameter, temp, visitor))), 8388608 /* CustomPrologue */)); - } - else if (initializer) { - statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 8388608 /* CustomPrologue */)); - } - } - /** - * Adds statements to the body of a function-like node for parameters with initializers. - * - * @param statements The statements for the new function body. - * @param parameter The parameter for the function. - * @param name The name of the parameter. - * @param initializer The initializer for the parameter. - */ - function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) { - initializer = ts.visitNode(initializer, visitor, ts.isExpression); - var statement = ts.createIf(ts.createStrictEquality(ts.getSynthesizedClone(name), ts.createVoidZero()), ts.setEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 1536 /* NoSourceMap */), ts.setEmitFlags(initializer, 1536 /* NoSourceMap */ | ts.getEmitFlags(initializer)), - /*location*/ parameter)) - ], /*location*/ parameter), 32 /* SingleLine */ | 1024 /* NoTrailingSourceMap */ | 12288 /* NoTokenSourceMaps */), - /*elseStatement*/ undefined, - /*location*/ parameter); - statement.startsOnNewLine = true; - ts.setEmitFlags(statement, 12288 /* NoTokenSourceMaps */ | 1024 /* NoTrailingSourceMap */ | 8388608 /* CustomPrologue */); - statements.push(statement); - } - /** - * Gets a value indicating whether we need to add statements to handle a rest parameter. - * - * @param node A ParameterDeclaration node. - * @param inConstructorWithSynthesizedSuper A value indicating whether the parameter is - * part of a constructor declaration with a - * synthesized call to `super` - */ - function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) { - return node && node.dotDotDotToken && node.name.kind === 69 /* Identifier */ && !inConstructorWithSynthesizedSuper; - } - /** - * Adds statements to the body of a function-like node if it contains a rest parameter. - * - * @param statements The statements for the new function body. - * @param node A function-like node. - * @param inConstructorWithSynthesizedSuper A value indicating whether the parameter is - * part of a constructor declaration with a - * synthesized call to `super` - */ - function addRestParameterIfNeeded(statements, node, inConstructorWithSynthesizedSuper) { - var parameter = ts.lastOrUndefined(node.parameters); - if (!shouldAddRestParameter(parameter, inConstructorWithSynthesizedSuper)) { - return; - } - // `declarationName` is the name of the local declaration for the parameter. - var declarationName = ts.getMutableClone(parameter.name); - ts.setEmitFlags(declarationName, 1536 /* NoSourceMap */); - // `expressionName` is the name of the parameter used in expressions. - var expressionName = ts.getSynthesizedClone(parameter.name); - var restIndex = node.parameters.length - 1; - var temp = ts.createLoopVariable(); - // var param = []; - statements.push(ts.setEmitFlags(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(declarationName, - /*type*/ undefined, ts.createArrayLiteral([])) - ]), - /*location*/ parameter), 8388608 /* CustomPrologue */)); - // for (var _i = restIndex; _i < arguments.length; _i++) { - // param[_i - restIndex] = arguments[_i]; - // } - var forStatement = ts.createFor(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(temp, /*type*/ undefined, ts.createLiteral(restIndex)) - ], /*location*/ parameter), ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length"), - /*location*/ parameter), ts.createPostfixIncrement(temp, /*location*/ parameter), ts.createBlock([ - ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp)), - /*location*/ parameter)) - ])); - ts.setEmitFlags(forStatement, 8388608 /* CustomPrologue */); - ts.startOnNewLine(forStatement); - statements.push(forStatement); - } - /** - * Adds a statement to capture the `this` of a function declaration if it is needed. - * - * @param statements The statements for the new function body. - * @param node A node. - */ - function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 16384 /* ContainsCapturedLexicalThis */ && node.kind !== 180 /* ArrowFunction */) { - captureThisForNode(statements, node, ts.createThis()); - } - } - function captureThisForNode(statements, node, initializer, originalStatement) { - enableSubstitutionsForCapturedThis(); - var captureThisStatement = ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration("_this", - /*type*/ undefined, initializer) - ]), originalStatement); - ts.setEmitFlags(captureThisStatement, 49152 /* NoComments */ | 8388608 /* CustomPrologue */); - ts.setSourceMapRange(captureThisStatement, node); - statements.push(captureThisStatement); - } - /** - * Adds statements to the class body function for a class to define the members of the - * class. - * - * @param statements The statements for the class body function. - * @param node The ClassExpression or ClassDeclaration node. - */ - function addClassMembers(statements, node) { - for (var _i = 0, _a = node.members; _i < _a.length; _i++) { - var member = _a[_i]; - switch (member.kind) { - case 198 /* SemicolonClassElement */: - statements.push(transformSemicolonClassElementToStatement(member)); - break; - case 147 /* MethodDeclaration */: - statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member)); - break; - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - var accessors = ts.getAllAccessorDeclarations(node.members, member); - if (member === accessors.firstAccessor) { - statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors)); - } - break; - case 148 /* Constructor */: - // Constructors are handled in visitClassExpression/visitClassDeclaration - break; - default: - ts.Debug.failBadSyntaxKind(node); - break; - } - } - } - /** - * Transforms a SemicolonClassElement into a statement for a class body function. - * - * @param member The SemicolonClassElement node. - */ - function transformSemicolonClassElementToStatement(member) { - return ts.createEmptyStatement(/*location*/ member); - } - /** - * Transforms a MethodDeclaration into a statement for a class body function. - * - * @param receiver The receiver for the member. - * @param member The MethodDeclaration node. - */ - function transformClassMethodDeclarationToStatement(receiver, member) { - var commentRange = ts.getCommentRange(member); - var sourceMapRange = ts.getSourceMapRange(member); - var func = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined); - ts.setEmitFlags(func, 49152 /* NoComments */); - ts.setSourceMapRange(func, sourceMapRange); - var statement = ts.createStatement(ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), - /*location*/ member.name), func), - /*location*/ member); - ts.setOriginalNode(statement, member); - ts.setCommentRange(statement, commentRange); - // The location for the statement is used to emit comments only. - // No source map should be emitted for this statement to align with the - // old emitter. - ts.setEmitFlags(statement, 1536 /* NoSourceMap */); - return statement; - } - /** - * Transforms a set of related of get/set accessors into a statement for a class body function. - * - * @param receiver The receiver for the member. - * @param accessors The set of related get/set accessors. - */ - function transformAccessorsToStatement(receiver, accessors) { - var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, /*startsOnNewLine*/ false), - /*location*/ ts.getSourceMapRange(accessors.firstAccessor)); - // The location for the statement is used to emit source maps only. - // No comments should be emitted for this statement to align with the - // old emitter. - ts.setEmitFlags(statement, 49152 /* NoComments */); - return statement; - } - /** - * Transforms a set of related get/set accessors into an expression for either a class - * body function or an ObjectLiteralExpression with computed properties. - * - * @param receiver The receiver for the member. - */ - function transformAccessorsToExpression(receiver, _a, startsOnNewLine) { - var firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; - // To align with source maps in the old emitter, the receiver and property name - // arguments are both mapped contiguously to the accessor name. - var target = ts.getMutableClone(receiver); - ts.setEmitFlags(target, 49152 /* NoComments */ | 1024 /* NoTrailingSourceMap */); - ts.setSourceMapRange(target, firstAccessor.name); - var propertyName = ts.createExpressionForPropertyName(ts.visitNode(firstAccessor.name, visitor, ts.isPropertyName)); - ts.setEmitFlags(propertyName, 49152 /* NoComments */ | 512 /* NoLeadingSourceMap */); - ts.setSourceMapRange(propertyName, firstAccessor.name); - var properties = []; - if (getAccessor) { - var getterFunction = transformFunctionLikeToExpression(getAccessor, /*location*/ undefined, /*name*/ undefined); - ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); - var getter = ts.createPropertyAssignment("get", getterFunction); - ts.setCommentRange(getter, ts.getCommentRange(getAccessor)); - properties.push(getter); - } - if (setAccessor) { - var setterFunction = transformFunctionLikeToExpression(setAccessor, /*location*/ undefined, /*name*/ undefined); - ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); - var setter = ts.createPropertyAssignment("set", setterFunction); - ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); - properties.push(setter); - } - properties.push(ts.createPropertyAssignment("enumerable", ts.createLiteral(true)), ts.createPropertyAssignment("configurable", ts.createLiteral(true))); - var call = ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), - /*typeArguments*/ undefined, [ - target, - propertyName, - ts.createObjectLiteral(properties, /*location*/ undefined, /*multiLine*/ true) + // import "module" + // + // or + // + // /// + // + // we need to add modules without alias names to the end of the dependencies list + var _a = collectAsynchronousDependencies(node, includeNonAmdDependencies), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + // Create an updated SourceFile: + // + // define(moduleName?, ["module1", "module2"], function ... + return updateSourceFile(node, [ + ts.createStatement(ts.createCall(define, + /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ + // Add the dependency array argument: + // + // ["require", "exports", module1", "module2", ...] + ts.createArrayLiteral([ + ts.createLiteral("require"), + ts.createLiteral("exports") + ].concat(aliasedModuleNames, unaliasedModuleNames)), + // Add the module body function argument: + // + // function (require, exports, module1, module2) ... + ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, [ + ts.createParameter("require"), + ts.createParameter("exports") + ].concat(importAliasNames), + /*type*/ undefined, transformAsynchronousModuleBody(node)) + ]))) ]); - if (startsOnNewLine) { - call.startsOnNewLine = true; - } - return call; } /** - * Visits an ArrowFunction and transforms it into a FunctionExpression. + * Transforms a SourceFile into an AMD or UMD module body. * - * @param node An ArrowFunction node. + * @param node The SourceFile node. */ - function visitArrowFunction(node) { - if (node.transformFlags & 8192 /* ContainsLexicalThis */) { - enableSubstitutionsForCapturedThis(); - } - var func = transformFunctionLikeToExpression(node, /*location*/ node, /*name*/ undefined); - ts.setEmitFlags(func, 256 /* CapturesThis */); - return func; - } - /** - * Visits a FunctionExpression node. - * - * @param node a FunctionExpression node. - */ - function visitFunctionExpression(node) { - return transformFunctionLikeToExpression(node, /*location*/ node, node.name); - } - /** - * Visits a FunctionDeclaration node. - * - * @param node a FunctionDeclaration node. - */ - function visitFunctionDeclaration(node) { - return ts.setOriginalNode(ts.createFunctionDeclaration( - /*decorators*/ undefined, node.modifiers, node.asteriskToken, node.name, - /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), - /*type*/ undefined, transformFunctionBody(node), - /*location*/ node), - /*original*/ node); - } - /** - * Transforms a function-like node into a FunctionExpression. - * - * @param node The function-like node to transform. - * @param location The source-map location for the new FunctionExpression. - * @param name The name of the new FunctionExpression. - */ - function transformFunctionLikeToExpression(node, location, name) { - var savedContainingNonArrowFunction = enclosingNonArrowFunction; - if (node.kind !== 180 /* ArrowFunction */) { - enclosingNonArrowFunction = node; - } - var expression = ts.setOriginalNode(ts.createFunctionExpression(node.asteriskToken, name, - /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), - /*type*/ undefined, saveStateAndInvoke(node, transformFunctionBody), location), - /*original*/ node); - enclosingNonArrowFunction = savedContainingNonArrowFunction; - return expression; - } - /** - * Transforms the body of a function-like node. - * - * @param node A function-like node. - */ - function transformFunctionBody(node) { - var multiLine = false; // indicates whether the block *must* be emitted as multiple lines - var singleLine = false; // indicates whether the block *may* be emitted as a single line - var statementsLocation; - var closeBraceLocation; - var statements = []; - var body = node.body; - var statementOffset; + function transformAsynchronousModuleBody(node) { startLexicalEnvironment(); - if (ts.isBlock(body)) { - // ensureUseStrict is false because no new prologue-directive should be added. - // addPrologueDirectives will simply put already-existing directives at the beginning of the target statement-array - statementOffset = ts.addPrologueDirectives(statements, body.statements, /*ensureUseStrict*/ false, visitor); - } - addCaptureThisForNodeIfNeeded(statements, node); - addDefaultValueAssignmentsIfNeeded(statements, node); - addRestParameterIfNeeded(statements, node, /*inConstructorWithSynthesizedSuper*/ false); - // If we added any generated statements, this must be a multi-line block. - if (!multiLine && statements.length > 0) { - multiLine = true; - } - if (ts.isBlock(body)) { - statementsLocation = body.statements; - ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, statementOffset)); - // If the original body was a multi-line block, this must be a multi-line block. - if (!multiLine && body.multiLine) { - multiLine = true; - } - } - else { - ts.Debug.assert(node.kind === 180 /* ArrowFunction */); - // To align with the old emitter, we use a synthetic end position on the location - // for the statement list we synthesize when we down-level an arrow function with - // an expression function body. This prevents both comments and source maps from - // being emitted for the end position only. - statementsLocation = ts.moveRangeEnd(body, -1); - var equalsGreaterThanToken = node.equalsGreaterThanToken; - if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { - if (ts.rangeEndIsOnSameLineAsRangeStart(equalsGreaterThanToken, body, currentSourceFile)) { - singleLine = true; - } - else { - multiLine = true; - } - } - var expression = ts.visitNode(body, visitor, ts.isExpression); - var returnStatement = ts.createReturn(expression, /*location*/ body); - ts.setEmitFlags(returnStatement, 12288 /* NoTokenSourceMaps */ | 1024 /* NoTrailingSourceMap */ | 32768 /* NoTrailingComments */); - statements.push(returnStatement); - // To align with the source map emit for the old emitter, we set a custom - // source map location for the close brace. - closeBraceLocation = body; - } - var lexicalEnvironment = endLexicalEnvironment(); - ts.addRange(statements, lexicalEnvironment); - // If we added any final generated statements, this must be a multi-line block - if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { - multiLine = true; - } - var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), node.body, multiLine); - if (!multiLine && singleLine) { - ts.setEmitFlags(block, 32 /* SingleLine */); - } - if (closeBraceLocation) { - ts.setTokenSourceMapRange(block, 16 /* CloseBraceToken */, closeBraceLocation); - } - ts.setOriginalNode(block, node.body); - return block; - } - /** - * Visits an ExpressionStatement that contains a destructuring assignment. - * - * @param node An ExpressionStatement node. - */ - function visitExpressionStatement(node) { - // If we are here it is most likely because our expression is a destructuring assignment. - switch (node.expression.kind) { - case 178 /* ParenthesizedExpression */: - return ts.updateStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 187 /* BinaryExpression */: - return ts.updateStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); - } - return ts.visitEachChild(node, visitor, context); - } - /** - * Visits a ParenthesizedExpression that may contain a destructuring assignment. - * - * @param node A ParenthesizedExpression node. - * @param needsDestructuringValue A value indicating whether we need to hold onto the rhs - * of a destructuring assignment. - */ - function visitParenthesizedExpression(node, needsDestructuringValue) { - // If we are here it is most likely because our expression is a destructuring assignment. - if (needsDestructuringValue) { - switch (node.expression.kind) { - case 178 /* ParenthesizedExpression */: - return ts.createParen(visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ true), - /*location*/ node); - case 187 /* BinaryExpression */: - return ts.createParen(visitBinaryExpression(node.expression, /*needsDestructuringValue*/ true), - /*location*/ node); - } - } - return ts.visitEachChild(node, visitor, context); - } - /** - * Visits a BinaryExpression that contains a destructuring assignment. - * - * @param node A BinaryExpression node. - * @param needsDestructuringValue A value indicating whether we need to hold onto the rhs - * of a destructuring assignment. - */ - function visitBinaryExpression(node, needsDestructuringValue) { - // If we are here it is because this is a destructuring assignment. - ts.Debug.assert(ts.isDestructuringAssignment(node)); - return ts.flattenDestructuringAssignment(context, node, needsDestructuringValue, hoistVariableDeclaration, visitor); - } - function visitVariableStatement(node) { - if (convertedLoopState && (ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */) == 0) { - // we are inside a converted loop - hoist variable declarations - var assignments = void 0; - for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - hoistVariableDeclarationDeclaredInConvertedLoop(convertedLoopState, decl); - if (decl.initializer) { - var assignment = void 0; - if (ts.isBindingPattern(decl.name)) { - assignment = ts.flattenVariableDestructuringToExpression(context, decl, hoistVariableDeclaration, /*nameSubstitution*/ undefined, visitor); - } - else { - assignment = ts.createBinary(decl.name, 56 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); - } - (assignments || (assignments = [])).push(assignment); - } - } - if (assignments) { - return ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 24 /* CommaToken */, acc); }), node); - } - else { - // none of declarations has initializer - the entire variable statement can be deleted - return undefined; - } - } - return ts.visitEachChild(node, visitor, context); - } - /** - * Visits a VariableDeclarationList that is block scoped (e.g. `let` or `const`). - * - * @param node A VariableDeclarationList node. - */ - function visitVariableDeclarationList(node) { - if (node.flags & 3 /* BlockScoped */) { - enableSubstitutionsForBlockScopedBindings(); - } - var declarations = ts.flatten(ts.map(node.declarations, node.flags & 1 /* Let */ - ? visitVariableDeclarationInLetDeclarationList - : visitVariableDeclaration)); - var declarationList = ts.createVariableDeclarationList(declarations, /*location*/ node); - ts.setOriginalNode(declarationList, node); - ts.setCommentRange(declarationList, node); - if (node.transformFlags & 2097152 /* ContainsBindingPattern */ - && (ts.isBindingPattern(node.declarations[0].name) - || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { - // If the first or last declaration is a binding pattern, we need to modify - // the source map range for the declaration list. - var firstDeclaration = ts.firstOrUndefined(declarations); - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); - } - return declarationList; - } - /** - * Gets a value indicating whether we should emit an explicit initializer for a variable - * declaration in a `let` declaration list. - * - * @param node A VariableDeclaration node. - */ - function shouldEmitExplicitInitializerForLetDeclaration(node) { - // Nested let bindings might need to be initialized explicitly to preserve - // ES6 semantic: - // - // { let x = 1; } - // { let x; } // x here should be undefined. not 1 - // - // Top level bindings never collide with anything and thus don't require - // explicit initialization. As for nested let bindings there are two cases: - // - // - Nested let bindings that were not renamed definitely should be - // initialized explicitly: - // - // { let x = 1; } - // { let x; if (some-condition) { x = 1}; if (x) { /*1*/ } } - // - // Without explicit initialization code in /*1*/ can be executed even if - // some-condition is evaluated to false. - // - // - Renaming introduces fresh name that should not collide with any - // existing names, however renamed bindings sometimes also should be - // explicitly initialized. One particular case: non-captured binding - // declared inside loop body (but not in loop initializer): - // - // let x; - // for (;;) { - // let x; - // } - // - // In downlevel codegen inner 'x' will be renamed so it won't collide - // with outer 'x' however it will should be reset on every iteration as - // if it was declared anew. - // - // * Why non-captured binding? - // - Because if loop contains block scoped binding captured in some - // function then loop body will be rewritten to have a fresh scope - // on every iteration so everything will just work. - // - // * Why loop initializer is excluded? - // - Since we've introduced a fresh name it already will be undefined. - var flags = resolver.getNodeCheckFlags(node); - var isCapturedInFunction = flags & 131072 /* CapturedBlockScopedBinding */; - var isDeclaredInLoop = flags & 262144 /* BlockScopedBindingInLoop */; - var emittedAsTopLevel = ts.isBlockScopedContainerTopLevel(enclosingBlockScopeContainer) - || (isCapturedInFunction - && isDeclaredInLoop - && ts.isBlock(enclosingBlockScopeContainer) - && ts.isIterationStatement(enclosingBlockScopeContainerParent, /*lookInLabeledStatements*/ false)); - var emitExplicitInitializer = !emittedAsTopLevel - && enclosingBlockScopeContainer.kind !== 207 /* ForInStatement */ - && enclosingBlockScopeContainer.kind !== 208 /* ForOfStatement */ - && (!resolver.isDeclarationWithCollidingName(node) - || (isDeclaredInLoop - && !isCapturedInFunction - && !ts.isIterationStatement(enclosingBlockScopeContainer, /*lookInLabeledStatements*/ false))); - return emitExplicitInitializer; - } - /** - * Visits a VariableDeclaration in a `let` declaration list. - * - * @param node A VariableDeclaration node. - */ - function visitVariableDeclarationInLetDeclarationList(node) { - // For binding pattern names that lack initializers there is no point to emit - // explicit initializer since downlevel codegen for destructuring will fail - // in the absence of initializer so all binding elements will say uninitialized - var name = node.name; - if (ts.isBindingPattern(name)) { - return visitVariableDeclaration(node); - } - if (!node.initializer && shouldEmitExplicitInitializerForLetDeclaration(node)) { - var clone_8 = ts.getMutableClone(node); - clone_8.initializer = ts.createVoidZero(); - return clone_8; - } - return ts.visitEachChild(node, visitor, context); - } - /** - * Visits a VariableDeclaration node with a binding pattern. - * - * @param node A VariableDeclaration node. - */ - function visitVariableDeclaration(node) { - // If we are here it is because the name contains a binding pattern. - if (ts.isBindingPattern(node.name)) { - var recordTempVariablesInLine = !enclosingVariableStatement - || !ts.hasModifier(enclosingVariableStatement, 1 /* Export */); - return ts.flattenVariableDestructuring(context, node, /*value*/ undefined, visitor, recordTempVariablesInLine ? undefined : hoistVariableDeclaration); - } - return ts.visitEachChild(node, visitor, context); - } - function visitLabeledStatement(node) { - if (convertedLoopState) { - if (!convertedLoopState.labels) { - convertedLoopState.labels = ts.createMap(); - } - convertedLoopState.labels[node.label.text] = node.label.text; - } - var result; - if (ts.isIterationStatement(node.statement, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node.statement)) { - result = ts.visitNodes(ts.createNodeArray([node.statement]), visitor, ts.isStatement); - } - else { - result = ts.visitEachChild(node, visitor, context); - } - if (convertedLoopState) { - convertedLoopState.labels[node.label.text] = undefined; - } - return result; - } - function visitDoStatement(node) { - return convertIterationStatementBodyIfNecessary(node); - } - function visitWhileStatement(node) { - return convertIterationStatementBodyIfNecessary(node); - } - function visitForStatement(node) { - return convertIterationStatementBodyIfNecessary(node); - } - function visitForInStatement(node) { - return convertIterationStatementBodyIfNecessary(node); - } - /** - * Visits a ForOfStatement and converts it into a compatible ForStatement. - * - * @param node A ForOfStatement. - */ - function visitForOfStatement(node) { - return convertIterationStatementBodyIfNecessary(node, convertForOfToFor); - } - function convertForOfToFor(node, convertedLoopBodyStatements) { - // The following ES6 code: - // - // for (let v of expr) { } - // - // should be emitted as - // - // for (var _i = 0, _a = expr; _i < _a.length; _i++) { - // var v = _a[_i]; - // } - // - // where _a and _i are temps emitted to capture the RHS and the counter, - // respectively. - // When the left hand side is an expression instead of a let declaration, - // the "let v" is not emitted. - // When the left hand side is a let/const, the v is renamed if there is - // another v in scope. - // Note that all assignments to the LHS are emitted in the body, including - // all destructuring. - // Note also that because an extra statement is needed to assign to the LHS, - // for-of bodies are always emitted as blocks. - var expression = ts.visitNode(node.expression, visitor, ts.isExpression); - var initializer = node.initializer; var statements = []; - // In the case where the user wrote an identifier as the RHS, like this: - // - // for (let v of arr) { } - // - // we don't want to emit a temporary variable for the RHS, just use it directly. - var counter = ts.createLoopVariable(); - var rhsReference = expression.kind === 69 /* Identifier */ - ? ts.createUniqueName(expression.text) - : ts.createTempVariable(/*recordTempVariable*/ undefined); - // Initialize LHS - // var v = _a[_i]; - if (ts.isVariableDeclarationList(initializer)) { - if (initializer.flags & 3 /* BlockScoped */) { - enableSubstitutionsForBlockScopedBindings(); - } - var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); - if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { - // This works whether the declaration is a var, let, or const. - // It will use rhsIterationValue _a[_i] as the initializer. - var declarations = ts.flattenVariableDestructuring(context, firstOriginalDeclaration, ts.createElementAccess(rhsReference, counter), visitor); - var declarationList = ts.createVariableDeclarationList(declarations, /*location*/ initializer); - ts.setOriginalNode(declarationList, initializer); - // Adjust the source map range for the first declaration to align with the old - // emitter. - var firstDeclaration = declarations[0]; - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, declarationList)); - } - else { - // The following call does not include the initializer, so we have - // to emit it separately. - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(/*recordTempVariable*/ undefined), - /*type*/ undefined, ts.createElementAccess(rhsReference, counter)) - ], /*location*/ ts.moveRangePos(initializer, -1)), - /*location*/ ts.moveRangeEnd(initializer, -1))); - } + var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, visitor); + // Visit each statement of the module body. + ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); + // End the lexical environment for the module body + // and merge any new lexical declarations. + ts.addRange(statements, endLexicalEnvironment()); + // Append the 'export =' statement if provided. + addExportEqualsIfNeeded(statements, /*emitAsReturn*/ true); + var body = ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true); + if (hasExportStarsToExportValues) { + // If we have any `export * from ...` declarations + // we need to inform the emitter to add the __export helper. + ts.setEmitFlags(body, 2 /* EmitExportStar */); } - else { - // Initializer is an expression. Emit the expression in the body, so that it's - // evaluated on every iteration. - var assignment = ts.createAssignment(initializer, ts.createElementAccess(rhsReference, counter)); - if (ts.isDestructuringAssignment(assignment)) { - // This is a destructuring pattern, so we flatten the destructuring instead. - statements.push(ts.createStatement(ts.flattenDestructuringAssignment(context, assignment, - /*needsValue*/ false, hoistVariableDeclaration, visitor))); - } - else { - // Currently there is not way to check that assignment is binary expression of destructing assignment - // so we have to cast never type to binaryExpression - assignment.end = initializer.end; - statements.push(ts.createStatement(assignment, /*location*/ ts.moveRangeEnd(initializer, -1))); - } - } - var bodyLocation; - var statementsLocation; - if (convertedLoopBodyStatements) { - ts.addRange(statements, convertedLoopBodyStatements); - } - else { - var statement = ts.visitNode(node.statement, visitor, ts.isStatement); - if (ts.isBlock(statement)) { - ts.addRange(statements, statement.statements); - bodyLocation = statement; - statementsLocation = statement.statements; + return body; + } + function addExportEqualsIfNeeded(statements, emitAsReturn) { + if (exportEquals) { + if (emitAsReturn) { + var statement = ts.createReturn(exportEquals.expression, + /*location*/ exportEquals); + ts.setEmitFlags(statement, 12288 /* NoTokenSourceMaps */ | 49152 /* NoComments */); + statements.push(statement); } else { + var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), exportEquals.expression), + /*location*/ exportEquals); + ts.setEmitFlags(statement, 49152 /* NoComments */); statements.push(statement); } } - // The old emitter does not emit source maps for the expression - ts.setEmitFlags(expression, 1536 /* NoSourceMap */ | ts.getEmitFlags(expression)); - // The old emitter does not emit source maps for the block. - // We add the location to preserve comments. - var body = ts.createBlock(ts.createNodeArray(statements, /*location*/ statementsLocation), - /*location*/ bodyLocation); - ts.setEmitFlags(body, 1536 /* NoSourceMap */ | 12288 /* NoTokenSourceMaps */); - var forStatement = ts.createFor(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(counter, /*type*/ undefined, ts.createLiteral(0), /*location*/ ts.moveRangePos(node.expression, -1)), - ts.createVariableDeclaration(rhsReference, /*type*/ undefined, expression, /*location*/ node.expression) - ], /*location*/ node.expression), ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length"), - /*location*/ node.expression), ts.createPostfixIncrement(counter, /*location*/ node.expression), body, - /*location*/ node); - // Disable trailing source maps for the OpenParenToken to align source map emit with the old emitter. - ts.setEmitFlags(forStatement, 8192 /* NoTokenTrailingSourceMaps */); - return forStatement; } /** - * Visits an ObjectLiteralExpression with computed propety names. + * Visits a node at the top level of the source file. * - * @param node An ObjectLiteralExpression node. + * @param node The node. */ - function visitObjectLiteralExpression(node) { - // We are here because a ComputedPropertyName was used somewhere in the expression. - var properties = node.properties; - var numProperties = properties.length; - // Find the first computed property. - // Everything until that point can be emitted as part of the initial object literal. - var numInitialProperties = numProperties; - for (var i = 0; i < numProperties; i++) { - var property = properties[i]; - if (property.transformFlags & 4194304 /* ContainsYield */ - || property.name.kind === 140 /* ComputedPropertyName */) { - numInitialProperties = i; - break; - } + function visitor(node) { + switch (node.kind) { + case 231 /* ImportDeclaration */: + return visitImportDeclaration(node); + case 230 /* ImportEqualsDeclaration */: + return visitImportEqualsDeclaration(node); + case 237 /* ExportDeclaration */: + return visitExportDeclaration(node); + case 236 /* ExportAssignment */: + return visitExportAssignment(node); + case 201 /* VariableStatement */: + return visitVariableStatement(node); + case 221 /* FunctionDeclaration */: + return visitFunctionDeclaration(node); + case 222 /* ClassDeclaration */: + return visitClassDeclaration(node); + case 203 /* ExpressionStatement */: + return visitExpressionStatement(node); + default: + // This visitor does not descend into the tree, as export/import statements + // are only transformed at the top level of a file. + return node; } - ts.Debug.assert(numInitialProperties !== numProperties); - // For computed properties, we need to create a unique handle to the object - // literal so we can modify it without risking internal assignments tainting the object. - var temp = ts.createTempVariable(hoistVariableDeclaration); - // Write out the first non-computed properties, then emit the rest through indexing on the temp variable. - var expressions = []; - var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), - /*location*/ undefined, node.multiLine), 524288 /* Indented */)); - if (node.multiLine) { - assignment.startsOnNewLine = true; - } - expressions.push(assignment); - addObjectLiteralMembers(expressions, node, temp, numInitialProperties); - // We need to clone the temporary identifier so that we can write it on a - // new line - expressions.push(node.multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); - return ts.inlineExpressions(expressions); - } - function shouldConvertIterationStatementBody(node) { - return (resolver.getNodeCheckFlags(node) & 65536 /* LoopWithCapturedBlockScopedBinding */) !== 0; } /** - * Records constituents of name for the given variable to be hoisted in the outer scope. + * Visits an ImportDeclaration node. + * + * @param node The ImportDeclaration node. */ - function hoistVariableDeclarationDeclaredInConvertedLoop(state, node) { - if (!state.hoistedLocalVariables) { - state.hoistedLocalVariables = []; + function visitImportDeclaration(node) { + if (!ts.contains(externalImports, node)) { + return undefined; } - visit(node.name); - function visit(node) { - if (node.kind === 69 /* Identifier */) { - state.hoistedLocalVariables.push(node); - } - else { - for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (!ts.isOmittedExpression(element)) { - visit(element.name); - } - } - } - } - } - function convertIterationStatementBodyIfNecessary(node, convert) { - if (!shouldConvertIterationStatementBody(node)) { - var saveAllowedNonLabeledJumps = void 0; - if (convertedLoopState) { - // we get here if we are trying to emit normal loop loop inside converted loop - // set allowedNonLabeledJumps to Break | Continue to mark that break\continue inside the loop should be emitted as is - saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; - convertedLoopState.allowedNonLabeledJumps = 2 /* Break */ | 4 /* Continue */; - } - var result = convert ? convert(node, /*convertedLoopBodyStatements*/ undefined) : ts.visitEachChild(node, visitor, context); - if (convertedLoopState) { - convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps; - } - return result; - } - var functionName = ts.createUniqueName("_loop"); - var loopInitializer; - switch (node.kind) { - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: - var initializer = node.initializer; - if (initializer && initializer.kind === 219 /* VariableDeclarationList */) { - loopInitializer = initializer; - } - break; - } - // variables that will be passed to the loop as parameters - var loopParameters = []; - // variables declared in the loop initializer that will be changed inside the loop - var loopOutParameters = []; - if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3 /* BlockScoped */)) { - for (var _i = 0, _a = loopInitializer.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - processLoopVariableDeclaration(decl, loopParameters, loopOutParameters); - } - } - var outerConvertedLoopState = convertedLoopState; - convertedLoopState = { loopOutParameters: loopOutParameters }; - if (outerConvertedLoopState) { - // convertedOuterLoopState !== undefined means that this converted loop is nested in another converted loop. - // if outer converted loop has already accumulated some state - pass it through - if (outerConvertedLoopState.argumentsName) { - // outer loop has already used 'arguments' so we've already have some name to alias it - // use the same name in all nested loops - convertedLoopState.argumentsName = outerConvertedLoopState.argumentsName; - } - if (outerConvertedLoopState.thisName) { - // outer loop has already used 'this' so we've already have some name to alias it - // use the same name in all nested loops - convertedLoopState.thisName = outerConvertedLoopState.thisName; - } - if (outerConvertedLoopState.hoistedLocalVariables) { - // we've already collected some non-block scoped variable declarations in enclosing loop - // use the same storage in nested loop - convertedLoopState.hoistedLocalVariables = outerConvertedLoopState.hoistedLocalVariables; - } - } - var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement); - var currentState = convertedLoopState; - convertedLoopState = outerConvertedLoopState; - if (loopOutParameters.length) { - var statements_3 = ts.isBlock(loopBody) ? loopBody.statements.slice() : [loopBody]; - copyOutParameters(loopOutParameters, 1 /* ToOutParameter */, statements_3); - loopBody = ts.createBlock(statements_3, /*location*/ undefined, /*multiline*/ true); - } - if (!ts.isBlock(loopBody)) { - loopBody = ts.createBlock([loopBody], /*location*/ undefined, /*multiline*/ true); - } - var isAsyncBlockContainingAwait = enclosingNonArrowFunction - && (ts.getEmitFlags(enclosingNonArrowFunction) & 2097152 /* AsyncFunctionBody */) !== 0 - && (node.statement.transformFlags & 4194304 /* ContainsYield */) !== 0; - var loopBodyFlags = 0; - if (currentState.containsLexicalThis) { - loopBodyFlags |= 256 /* CapturesThis */; - } - if (isAsyncBlockContainingAwait) { - loopBodyFlags |= 2097152 /* AsyncFunctionBody */; - } - var convertedLoopVariable = ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(functionName, - /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression(isAsyncBlockContainingAwait ? ts.createToken(37 /* AsteriskToken */) : undefined, - /*name*/ undefined, - /*typeParameters*/ undefined, loopParameters, - /*type*/ undefined, loopBody), loopBodyFlags)) - ])); - var statements = [convertedLoopVariable]; - var extraVariableDeclarations; - // propagate state from the inner loop to the outer loop if necessary - if (currentState.argumentsName) { - // if alias for arguments is set - if (outerConvertedLoopState) { - // pass it to outer converted loop - outerConvertedLoopState.argumentsName = currentState.argumentsName; - } - else { - // this is top level converted loop and we need to create an alias for 'arguments' object - (extraVariableDeclarations || (extraVariableDeclarations = [])).push(ts.createVariableDeclaration(currentState.argumentsName, - /*type*/ undefined, ts.createIdentifier("arguments"))); - } - } - if (currentState.thisName) { - // if alias for this is set - if (outerConvertedLoopState) { - // pass it to outer converted loop - outerConvertedLoopState.thisName = currentState.thisName; - } - else { - // this is top level converted loop so we need to create an alias for 'this' here - // NOTE: - // if converted loops were all nested in arrow function then we'll always emit '_this' so convertedLoopState.thisName will not be set. - // If it is set this means that all nested loops are not nested in arrow function and it is safe to capture 'this'. - (extraVariableDeclarations || (extraVariableDeclarations = [])).push(ts.createVariableDeclaration(currentState.thisName, - /*type*/ undefined, ts.createIdentifier("this"))); - } - } - if (currentState.hoistedLocalVariables) { - // if hoistedLocalVariables !== undefined this means that we've possibly collected some variable declarations to be hoisted later - if (outerConvertedLoopState) { - // pass them to outer converted loop - outerConvertedLoopState.hoistedLocalVariables = currentState.hoistedLocalVariables; - } - else { - if (!extraVariableDeclarations) { - extraVariableDeclarations = []; - } - // hoist collected variable declarations - for (var _b = 0, _c = currentState.hoistedLocalVariables; _b < _c.length; _b++) { - var identifier = _c[_b]; - extraVariableDeclarations.push(ts.createVariableDeclaration(identifier)); - } - } - } - // add extra variables to hold out parameters if necessary - if (loopOutParameters.length) { - if (!extraVariableDeclarations) { - extraVariableDeclarations = []; - } - for (var _d = 0, loopOutParameters_1 = loopOutParameters; _d < loopOutParameters_1.length; _d++) { - var outParam = loopOutParameters_1[_d]; - extraVariableDeclarations.push(ts.createVariableDeclaration(outParam.outParamName)); - } - } - // create variable statement to hold all introduced variable declarations - if (extraVariableDeclarations) { - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList(extraVariableDeclarations))); - } - var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, isAsyncBlockContainingAwait); - var loop; - if (convert) { - loop = convert(node, convertedLoopBodyStatements); - } - else { - loop = ts.getMutableClone(node); - // clean statement part - loop.statement = undefined; - // visit childnodes to transform initializer/condition/incrementor parts - loop = ts.visitEachChild(loop, visitor, context); - // set loop statement - loop.statement = ts.createBlock(convertedLoopBodyStatements, - /*location*/ undefined, - /*multiline*/ true); - // reset and re-aggregate the transform flags - loop.transformFlags = 0; - ts.aggregateTransformFlags(loop); - } - statements.push(currentParent.kind === 214 /* LabeledStatement */ - ? ts.createLabel(currentParent.label, loop) - : loop); - return statements; - } - function copyOutParameter(outParam, copyDirection) { - var source = copyDirection === 0 /* ToOriginal */ ? outParam.outParamName : outParam.originalName; - var target = copyDirection === 0 /* ToOriginal */ ? outParam.originalName : outParam.outParamName; - return ts.createBinary(target, 56 /* EqualsToken */, source); - } - function copyOutParameters(outParams, copyDirection, statements) { - for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { - var outParam = outParams_1[_i]; - statements.push(ts.createStatement(copyOutParameter(outParam, copyDirection))); - } - } - function generateCallToConvertedLoop(loopFunctionExpressionName, parameters, state, isAsyncBlockContainingAwait) { - var outerConvertedLoopState = convertedLoopState; var statements = []; - // loop is considered simple if it does not have any return statements or break\continue that transfer control outside of the loop - // simple loops are emitted as just 'loop()'; - // NOTE: if loop uses only 'continue' it still will be emitted as simple loop - var isSimpleLoop = !(state.nonLocalJumps & ~4 /* Continue */) && - !state.labeledNonLocalBreaks && - !state.labeledNonLocalContinues; - var call = ts.createCall(loopFunctionExpressionName, /*typeArguments*/ undefined, ts.map(parameters, function (p) { return p.name; })); - var callResult = isAsyncBlockContainingAwait ? ts.createYield(ts.createToken(37 /* AsteriskToken */), call) : call; - if (isSimpleLoop) { - statements.push(ts.createStatement(callResult)); - copyOutParameters(state.loopOutParameters, 0 /* ToOriginal */, statements); - } - else { - var loopResultName = ts.createUniqueName("state"); - var stateVariable = ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ts.createVariableDeclaration(loopResultName, /*type*/ undefined, callResult)])); - statements.push(stateVariable); - copyOutParameters(state.loopOutParameters, 0 /* ToOriginal */, statements); - if (state.nonLocalJumps & 8 /* Return */) { - var returnStatement = void 0; - if (outerConvertedLoopState) { - outerConvertedLoopState.nonLocalJumps |= 8 /* Return */; - returnStatement = ts.createReturn(loopResultName); + var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); + if (moduleKind !== ts.ModuleKind.AMD) { + if (!node.importClause) { + // import "mod"; + statements.push(ts.createStatement(createRequireCall(node), + /*location*/ node)); + } + else { + var variables = []; + if (namespaceDeclaration && !ts.isDefaultImport(node)) { + // import * as n from "mod"; + variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), + /*type*/ undefined, createRequireCall(node))); } else { - returnStatement = ts.createReturn(ts.createPropertyAccess(loopResultName, "value")); + // import d from "mod"; + // import { x, y } from "mod"; + // import d, { x, y } from "mod"; + // import d, * as n from "mod"; + variables.push(ts.createVariableDeclaration(ts.getGeneratedNameForNode(node), + /*type*/ undefined, createRequireCall(node))); + if (namespaceDeclaration && ts.isDefaultImport(node)) { + variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), + /*type*/ undefined, ts.getGeneratedNameForNode(node))); + } } - statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 32 /* EqualsEqualsEqualsToken */, ts.createLiteral("object")), returnStatement)); - } - if (state.nonLocalJumps & 2 /* Break */) { - statements.push(ts.createIf(ts.createBinary(loopResultName, 32 /* EqualsEqualsEqualsToken */, ts.createLiteral("break")), ts.createBreak())); - } - if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { - var caseClauses = []; - processLabeledJumps(state.labeledNonLocalBreaks, /*isBreak*/ true, loopResultName, outerConvertedLoopState, caseClauses); - processLabeledJumps(state.labeledNonLocalContinues, /*isBreak*/ false, loopResultName, outerConvertedLoopState, caseClauses); - statements.push(ts.createSwitch(loopResultName, ts.createCaseBlock(caseClauses))); + statements.push(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createConstDeclarationList(variables), + /*location*/ node)); } } - return statements; + else if (namespaceDeclaration && ts.isDefaultImport(node)) { + // import d, * as n from "mod"; + statements.push(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), + /*type*/ undefined, ts.getGeneratedNameForNode(node), + /*location*/ node) + ]))); + } + addExportImportAssignments(statements, node); + return ts.singleOrMany(statements); } - function setLabeledJump(state, isBreak, labelText, labelMarker) { - if (isBreak) { - if (!state.labeledNonLocalBreaks) { - state.labeledNonLocalBreaks = ts.createMap(); - } - state.labeledNonLocalBreaks[labelText] = labelMarker; + function visitImportEqualsDeclaration(node) { + if (!ts.contains(externalImports, node)) { + return undefined; } - else { - if (!state.labeledNonLocalContinues) { - state.labeledNonLocalContinues = ts.createMap(); - } - state.labeledNonLocalContinues[labelText] = labelMarker; - } - } - function processLabeledJumps(table, isBreak, loopResultName, outerLoop, caseClauses) { - if (!table) { - return; - } - for (var labelText in table) { - var labelMarker = table[labelText]; - var statements = []; - // if there are no outer converted loop or outer label in question is located inside outer converted loop - // then emit labeled break\continue - // otherwise propagate pair 'label -> marker' to outer converted loop and emit 'return labelMarker' so outer loop can later decide what to do - if (!outerLoop || (outerLoop.labels && outerLoop.labels[labelText])) { - var label = ts.createIdentifier(labelText); - statements.push(isBreak ? ts.createBreak(label) : ts.createContinue(label)); + // Set emitFlags on the name of the importEqualsDeclaration + // This is so the printer will not substitute the identifier + ts.setEmitFlags(node.name, 128 /* NoSubstitution */); + var statements = []; + if (moduleKind !== ts.ModuleKind.AMD) { + if (ts.hasModifier(node, 1 /* Export */)) { + statements.push(ts.createStatement(createExportAssignment(node.name, createRequireCall(node)), + /*location*/ node)); } else { - setLabeledJump(outerLoop, isBreak, labelText, labelMarker); - statements.push(ts.createReturn(loopResultName)); + statements.push(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(ts.getSynthesizedClone(node.name), + /*type*/ undefined, createRequireCall(node)) + ], + /*location*/ undefined, + /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */), + /*location*/ node)); } - caseClauses.push(ts.createCaseClause(ts.createLiteral(labelMarker), statements)); + } + else { + if (ts.hasModifier(node, 1 /* Export */)) { + statements.push(ts.createStatement(createExportAssignment(node.name, node.name), + /*location*/ node)); + } + } + addExportImportAssignments(statements, node); + return statements; + } + function visitExportDeclaration(node) { + if (!ts.contains(externalImports, node)) { + return undefined; + } + var generatedName = ts.getGeneratedNameForNode(node); + if (node.exportClause) { + var statements = []; + // export { x, y } from "mod"; + if (moduleKind !== ts.ModuleKind.AMD) { + statements.push(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(generatedName, + /*type*/ undefined, createRequireCall(node)) + ]), + /*location*/ node)); + } + for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { + var specifier = _a[_i]; + var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); + statements.push(ts.createStatement(createExportAssignment(specifier.name, exportedValue), + /*location*/ specifier)); + } + return ts.singleOrMany(statements); + } + else { + // export * from "mod"; + return ts.createStatement(ts.createCall(ts.createIdentifier("__export"), + /*typeArguments*/ undefined, [ + moduleKind !== ts.ModuleKind.AMD + ? createRequireCall(node) + : generatedName + ]), + /*location*/ node); } } - function processLoopVariableDeclaration(decl, loopParameters, loopOutParameters) { - var name = decl.name; + function visitExportAssignment(node) { + if (node.isExportEquals) { + // Elide as `export=` is handled in addExportEqualsIfNeeded + return undefined; + } + var statements = []; + addExportDefault(statements, node.expression, /*location*/ node); + return statements; + } + function addExportDefault(statements, expression, location) { + tryAddExportDefaultCompat(statements); + statements.push(ts.createStatement(createExportAssignment(ts.createIdentifier("default"), expression), location)); + } + function tryAddExportDefaultCompat(statements) { + var original = ts.getOriginalNode(currentSourceFile); + ts.Debug.assert(original.kind === 256 /* SourceFile */); + if (!original.symbol.exports["___esModule"]) { + if (languageVersion === 0 /* ES3 */) { + statements.push(ts.createStatement(createExportAssignment(ts.createIdentifier("__esModule"), ts.createLiteral(true)))); + } + else { + statements.push(ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), + /*typeArguments*/ undefined, [ + ts.createIdentifier("exports"), + ts.createLiteral("__esModule"), + ts.createObjectLiteral([ + ts.createPropertyAssignment("value", ts.createLiteral(true)) + ]) + ]))); + } + } + } + function addExportImportAssignments(statements, node) { + if (ts.isImportEqualsDeclaration(node)) { + addExportMemberAssignments(statements, node.name); + } + else { + var names = ts.reduceEachChild(node, collectExportMembers, []); + for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { + var name_35 = names_1[_i]; + addExportMemberAssignments(statements, name_35); + } + } + } + function collectExportMembers(names, node) { + if (ts.isAliasSymbolDeclaration(node) && ts.isDeclaration(node)) { + var name_36 = node.name; + if (ts.isIdentifier(name_36)) { + names.push(name_36); + } + } + return ts.reduceEachChild(node, collectExportMembers, names); + } + function addExportMemberAssignments(statements, name) { + if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { + for (var _i = 0, _a = exportSpecifiers[name.text]; _i < _a.length; _i++) { + var specifier = _a[_i]; + statements.push(ts.startOnNewLine(ts.createStatement(createExportAssignment(specifier.name, name), + /*location*/ specifier.name))); + } + } + } + function addExportMemberAssignment(statements, node) { + if (ts.hasModifier(node, 512 /* Default */)) { + addExportDefault(statements, getDeclarationName(node), /*location*/ node); + } + else { + statements.push(createExportStatement(node.name, ts.setEmitFlags(ts.getSynthesizedClone(node.name), 262144 /* LocalName */), /*location*/ node)); + } + } + function visitVariableStatement(node) { + // If the variable is for a generated declaration, + // we should maintain it and just strip off the 'export' modifier if necessary. + var originalKind = ts.getOriginalNode(node).kind; + if (originalKind === 226 /* ModuleDeclaration */ || + originalKind === 225 /* EnumDeclaration */ || + originalKind === 222 /* ClassDeclaration */) { + if (!ts.hasModifier(node, 1 /* Export */)) { + return node; + } + return ts.setOriginalNode(ts.createVariableStatement( + /*modifiers*/ undefined, node.declarationList), node); + } + var resultStatements = []; + // If we're exporting these variables, then these just become assignments to 'exports.blah'. + // We only want to emit assignments for variables with initializers. + if (ts.hasModifier(node, 1 /* Export */)) { + var variables = ts.getInitializedVariables(node.declarationList); + if (variables.length > 0) { + var inlineAssignments = ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable)), node); + resultStatements.push(inlineAssignments); + } + } + else { + resultStatements.push(node); + } + // While we might not have been exported here, each variable might have been exported + // later on in an export specifier (e.g. `export {foo as blah, bar}`). + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + addExportMemberAssignmentsForBindingName(resultStatements, decl.name); + } + return resultStatements; + } + /** + * Creates appropriate assignments for each binding identifier that is exported in an export specifier, + * and inserts it into 'resultStatements'. + */ + function addExportMemberAssignmentsForBindingName(resultStatements, name) { if (ts.isBindingPattern(name)) { for (var _i = 0, _a = name.elements; _i < _a.length; _i++) { var element = _a[_i]; if (!ts.isOmittedExpression(element)) { - processLoopVariableDeclaration(element, loopParameters, loopOutParameters); + addExportMemberAssignmentsForBindingName(resultStatements, element.name); } } } else { - loopParameters.push(ts.createParameter(name)); - if (resolver.getNodeCheckFlags(decl) & 2097152 /* NeedsLoopOutParameter */) { - var outParamName = ts.createUniqueName("out_" + name.text); - loopOutParameters.push({ originalName: name, outParamName: outParamName }); + if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { + var sourceFileId = ts.getOriginalNodeId(currentSourceFile); + if (!bindingNameExportSpecifiersForFileMap[sourceFileId]) { + bindingNameExportSpecifiersForFileMap[sourceFileId] = ts.createMap(); + } + bindingNameExportSpecifiersForFileMap[sourceFileId][name.text] = exportSpecifiers[name.text]; + addExportMemberAssignments(resultStatements, name); } } } - /** - * Adds the members of an object literal to an array of expressions. - * - * @param expressions An array of expressions. - * @param node An ObjectLiteralExpression node. - * @param receiver The receiver for members of the ObjectLiteralExpression. - * @param numInitialNonComputedProperties The number of initial properties without - * computed property names. - */ - function addObjectLiteralMembers(expressions, node, receiver, start) { - var properties = node.properties; - var numProperties = properties.length; - for (var i = start; i < numProperties; i++) { - var property = properties[i]; - switch (property.kind) { - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - var accessors = ts.getAllAccessorDeclarations(node.properties, property); - if (property === accessors.firstAccessor) { - expressions.push(transformAccessorsToExpression(receiver, accessors, node.multiLine)); - } - break; - case 253 /* PropertyAssignment */: - expressions.push(transformPropertyAssignmentToExpression(node, property, receiver, node.multiLine)); - break; - case 254 /* ShorthandPropertyAssignment */: - expressions.push(transformShorthandPropertyAssignmentToExpression(node, property, receiver, node.multiLine)); - break; - case 147 /* MethodDeclaration */: - expressions.push(transformObjectLiteralMethodDeclarationToExpression(node, property, receiver, node.multiLine)); - break; - default: - ts.Debug.failBadSyntaxKind(node); - break; - } - } - } - /** - * Transforms a PropertyAssignment node into an expression. - * - * @param node The ObjectLiteralExpression that contains the PropertyAssignment. - * @param property The PropertyAssignment node. - * @param receiver The receiver for the assignment. - */ - function transformPropertyAssignmentToExpression(node, property, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.visitNode(property.initializer, visitor, ts.isExpression), - /*location*/ property); - if (startsOnNewLine) { - expression.startsOnNewLine = true; - } - return expression; - } - /** - * Transforms a ShorthandPropertyAssignment node into an expression. - * - * @param node The ObjectLiteralExpression that contains the ShorthandPropertyAssignment. - * @param property The ShorthandPropertyAssignment node. - * @param receiver The receiver for the assignment. - */ - function transformShorthandPropertyAssignmentToExpression(node, property, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.getSynthesizedClone(property.name), - /*location*/ property); - if (startsOnNewLine) { - expression.startsOnNewLine = true; - } - return expression; - } - /** - * Transforms a MethodDeclaration of an ObjectLiteralExpression into an expression. - * - * @param node The ObjectLiteralExpression that contains the MethodDeclaration. - * @param method The MethodDeclaration node. - * @param receiver The receiver for the assignment. - */ - function transformObjectLiteralMethodDeclarationToExpression(node, method, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, /*location*/ method, /*name*/ undefined), - /*location*/ method); - if (startsOnNewLine) { - expression.startsOnNewLine = true; - } - return expression; - } - /** - * Visits a MethodDeclaration of an ObjectLiteralExpression and transforms it into a - * PropertyAssignment. - * - * @param node A MethodDeclaration node. - */ - function visitMethodDeclaration(node) { - // We should only get here for methods on an object literal with regular identifier names. - // Methods on classes are handled in visitClassDeclaration/visitClassExpression. - // Methods with computed property names are handled in visitObjectLiteralExpression. - ts.Debug.assert(!ts.isComputedPropertyName(node.name)); - var functionExpression = transformFunctionLikeToExpression(node, /*location*/ ts.moveRangePos(node, -1), /*name*/ undefined); - ts.setEmitFlags(functionExpression, 16384 /* NoLeadingComments */ | ts.getEmitFlags(functionExpression)); - return ts.createPropertyAssignment(node.name, functionExpression, - /*location*/ node); - } - /** - * Visits a ShorthandPropertyAssignment and transforms it into a PropertyAssignment. - * - * @param node A ShorthandPropertyAssignment node. - */ - function visitShorthandPropertyAssignment(node) { - return ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name), - /*location*/ node); - } - /** - * Visits a YieldExpression node. - * - * @param node A YieldExpression node. - */ - function visitYieldExpression(node) { - // `yield` expressions are transformed using the generators transformer. - return ts.visitEachChild(node, visitor, context); - } - /** - * Visits an ArrayLiteralExpression that contains a spread element. - * - * @param node An ArrayLiteralExpression node. - */ - function visitArrayLiteralExpression(node) { - // We are here because we contain a SpreadElementExpression. - return transformAndSpreadElements(node.elements, /*needsUniqueCopy*/ true, node.multiLine, /*hasTrailingComma*/ node.elements.hasTrailingComma); - } - /** - * Visits a CallExpression that contains either a spread element or `super`. - * - * @param node a CallExpression. - */ - function visitCallExpression(node) { - return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); - } - function visitImmediateSuperCallInBody(node) { - return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ false); - } - function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) { - // We are here either because SuperKeyword was used somewhere in the expression, or - // because we contain a SpreadElementExpression. - var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 95 /* SuperKeyword */) { - ts.setEmitFlags(thisArg, 128 /* NoSubstitution */); - } - var resultingCall; - if (node.transformFlags & 262144 /* ContainsSpreadElementExpression */) { - // [source] - // f(...a, b) - // x.m(...a, b) - // super(...a, b) - // super.m(...a, b) // in static - // super.m(...a, b) // in instance - // - // [output] - // f.apply(void 0, a.concat([b])) - // (_a = x).m.apply(_a, a.concat([b])) - // _super.apply(this, a.concat([b])) - // _super.m.apply(this, a.concat([b])) - // _super.prototype.m.apply(this, a.concat([b])) - resultingCall = ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); + function transformInitializedVariable(node) { + var name = node.name; + if (ts.isBindingPattern(name)) { + return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, getModuleMemberName, visitor); } else { - // [source] - // super(a) - // super.m(a) // in static - // super.m(a) // in instance - // - // [output] - // _super.call(this, a) - // _super.m.call(this, a) - // _super.prototype.m.call(this, a) - resultingCall = ts.createFunctionCall(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), - /*location*/ node); - } - if (node.expression.kind === 95 /* SuperKeyword */) { - var actualThis = ts.createThis(); - ts.setEmitFlags(actualThis, 128 /* NoSubstitution */); - var initializer = ts.createLogicalOr(resultingCall, actualThis); - return assignToCapturedThis - ? ts.createAssignment(ts.createIdentifier("_this"), initializer) - : initializer; - } - return resultingCall; - } - /** - * Visits a NewExpression that contains a spread element. - * - * @param node A NewExpression node. - */ - function visitNewExpression(node) { - // We are here because we contain a SpreadElementExpression. - ts.Debug.assert((node.transformFlags & 262144 /* ContainsSpreadElementExpression */) !== 0); - // [source] - // new C(...a) - // - // [output] - // new ((_a = C).bind.apply(_a, [void 0].concat(a)))() - var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)), - /*typeArguments*/ undefined, []); - } - /** - * Transforms an array of Expression nodes that contains a SpreadElementExpression. - * - * @param elements The array of Expression nodes. - * @param needsUniqueCopy A value indicating whether to ensure that the result is a fresh array. - * @param multiLine A value indicating whether the result should be emitted on multiple lines. - */ - function transformAndSpreadElements(elements, needsUniqueCopy, multiLine, hasTrailingComma) { - // [source] - // [a, ...b, c] - // - // [output] - // [a].concat(b, [c]) - // Map spans of spread expressions into their expressions and spans of other - // expressions into an array literal. - var numElements = elements.length; - var segments = ts.flatten(ts.spanMap(elements, partitionSpreadElement, function (partition, visitPartition, start, end) { - return visitPartition(partition, multiLine, hasTrailingComma && end === numElements); - })); - if (segments.length === 1) { - var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadElementExpression(firstElement) && firstElement.expression.kind !== 170 /* ArrayLiteralExpression */ - ? ts.createArraySlice(segments[0]) - : segments[0]; - } - // Rewrite using the pattern .concat(, , ...) - return ts.createArrayConcat(segments.shift(), segments); - } - function partitionSpreadElement(node) { - return ts.isSpreadElementExpression(node) - ? visitSpanOfSpreadElements - : visitSpanOfNonSpreadElements; - } - function visitSpanOfSpreadElements(chunk, multiLine, hasTrailingComma) { - return ts.map(chunk, visitExpressionOfSpreadElement); - } - function visitSpanOfNonSpreadElements(chunk, multiLine, hasTrailingComma) { - return ts.createArrayLiteral(ts.visitNodes(ts.createNodeArray(chunk, /*location*/ undefined, hasTrailingComma), visitor, ts.isExpression), - /*location*/ undefined, multiLine); - } - /** - * Transforms the expression of a SpreadElementExpression node. - * - * @param node A SpreadElementExpression node. - */ - function visitExpressionOfSpreadElement(node) { - return ts.visitNode(node.expression, visitor, ts.isExpression); - } - /** - * Visits a template literal. - * - * @param node A template literal. - */ - function visitTemplateLiteral(node) { - return ts.createLiteral(node.text, /*location*/ node); - } - /** - * Visits a TaggedTemplateExpression node. - * - * @param node A TaggedTemplateExpression node. - */ - function visitTaggedTemplateExpression(node) { - // Visit the tag expression - var tag = ts.visitNode(node.tag, visitor, ts.isExpression); - // Allocate storage for the template site object - var temp = ts.createTempVariable(hoistVariableDeclaration); - // Build up the template arguments and the raw and cooked strings for the template. - var templateArguments = [temp]; - var cookedStrings = []; - var rawStrings = []; - var template = node.template; - if (ts.isNoSubstitutionTemplateLiteral(template)) { - cookedStrings.push(ts.createLiteral(template.text)); - rawStrings.push(getRawLiteral(template)); - } - else { - cookedStrings.push(ts.createLiteral(template.head.text)); - rawStrings.push(getRawLiteral(template.head)); - for (var _i = 0, _a = template.templateSpans; _i < _a.length; _i++) { - var templateSpan = _a[_i]; - cookedStrings.push(ts.createLiteral(templateSpan.literal.text)); - rawStrings.push(getRawLiteral(templateSpan.literal)); - templateArguments.push(ts.visitNode(templateSpan.expression, visitor, ts.isExpression)); - } - } - // NOTE: The parentheses here is entirely optional as we are now able to auto- - // parenthesize when rebuilding the tree. This should be removed in a - // future version. It is here for now to match our existing emit. - return ts.createParen(ts.inlineExpressions([ - ts.createAssignment(temp, ts.createArrayLiteral(cookedStrings)), - ts.createAssignment(ts.createPropertyAccess(temp, "raw"), ts.createArrayLiteral(rawStrings)), - ts.createCall(tag, /*typeArguments*/ undefined, templateArguments) - ])); - } - /** - * Creates an ES5 compatible literal from an ES6 template literal. - * - * @param node The ES6 template literal. - */ - function getRawLiteral(node) { - // Find original source text, since we need to emit the raw strings of the tagged template. - // The raw strings contain the (escaped) strings of what the user wrote. - // Examples: `\n` is converted to "\\n", a template string with a newline to "\n". - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - // text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"), - // thus we need to remove those characters. - // First template piece starts with "`", others with "}" - // Last template piece ends with "`", others with "${" - var isLast = node.kind === 11 /* NoSubstitutionTemplateLiteral */ || node.kind === 14 /* TemplateTail */; - text = text.substring(1, text.length - (isLast ? 1 : 2)); - // Newline normalization: - // ES6 Spec 11.8.6.1 - Static Semantics of TV's and TRV's - // and LineTerminatorSequences are normalized to for both TV and TRV. - text = text.replace(/\r\n?/g, "\n"); - return ts.createLiteral(text, /*location*/ node); - } - /** - * Visits a TemplateExpression node. - * - * @param node A TemplateExpression node. - */ - function visitTemplateExpression(node) { - var expressions = []; - addTemplateHead(expressions, node); - addTemplateSpans(expressions, node); - // createAdd will check if each expression binds less closely than binary '+'. - // If it does, it wraps the expression in parentheses. Otherwise, something like - // `abc${ 1 << 2 }` - // becomes - // "abc" + 1 << 2 + "" - // which is really - // ("abc" + 1) << (2 + "") - // rather than - // "abc" + (1 << 2) + "" - var expression = ts.reduceLeft(expressions, ts.createAdd); - if (ts.nodeIsSynthesized(expression)) { - ts.setTextRange(expression, node); - } - return expression; - } - /** - * Gets a value indicating whether we need to include the head of a TemplateExpression. - * - * @param node A TemplateExpression node. - */ - function shouldAddTemplateHead(node) { - // If this expression has an empty head literal and the first template span has a non-empty - // literal, then emitting the empty head literal is not necessary. - // `${ foo } and ${ bar }` - // can be emitted as - // foo + " and " + bar - // This is because it is only required that one of the first two operands in the emit - // output must be a string literal, so that the other operand and all following operands - // are forced into strings. - // - // If the first template span has an empty literal, then the head must still be emitted. - // `${ foo }${ bar }` - // must still be emitted as - // "" + foo + bar - // There is always atleast one templateSpan in this code path, since - // NoSubstitutionTemplateLiterals are directly emitted via emitLiteral() - ts.Debug.assert(node.templateSpans.length !== 0); - return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0; - } - /** - * Adds the head of a TemplateExpression to an array of expressions. - * - * @param expressions An array of expressions. - * @param node A TemplateExpression node. - */ - function addTemplateHead(expressions, node) { - if (!shouldAddTemplateHead(node)) { - return; - } - expressions.push(ts.createLiteral(node.head.text)); - } - /** - * Visits and adds the template spans of a TemplateExpression to an array of expressions. - * - * @param expressions An array of expressions. - * @param node A TemplateExpression node. - */ - function addTemplateSpans(expressions, node) { - for (var _i = 0, _a = node.templateSpans; _i < _a.length; _i++) { - var span_6 = _a[_i]; - expressions.push(ts.visitNode(span_6.expression, visitor, ts.isExpression)); - // Only emit if the literal is non-empty. - // The binary '+' operator is left-associative, so the first string concatenation - // with the head will force the result up to this point to be a string. - // Emitting a '+ ""' has no semantic effect for middles and tails. - if (span_6.literal.text.length !== 0) { - expressions.push(ts.createLiteral(span_6.literal.text)); - } + return ts.createAssignment(getModuleMemberName(name), ts.visitNode(node.initializer, visitor, ts.isExpression)); } } - /** - * Visits the `super` keyword - */ - function visitSuperKeyword(node) { - return enclosingNonAsyncFunctionBody - && ts.isClassElement(enclosingNonAsyncFunctionBody) - && !ts.hasModifier(enclosingNonAsyncFunctionBody, 32 /* Static */) - && currentParent.kind !== 174 /* CallExpression */ - ? ts.createPropertyAccess(ts.createIdentifier("_super"), "prototype") - : ts.createIdentifier("_super"); - } - function visitSourceFileNode(node) { - var _a = ts.span(node.statements, ts.isPrologueDirective), prologue = _a[0], remaining = _a[1]; + function visitFunctionDeclaration(node) { var statements = []; - startLexicalEnvironment(); - ts.addRange(statements, prologue); - addCaptureThisForNodeIfNeeded(statements, node); - ts.addRange(statements, ts.visitNodes(ts.createNodeArray(remaining), visitor, ts.isStatement)); - ts.addRange(statements, endLexicalEnvironment()); - var clone = ts.getMutableClone(node); - clone.statements = ts.createNodeArray(statements, /*location*/ node.statements); - return clone; + var name = node.name || ts.getGeneratedNameForNode(node); + if (ts.hasModifier(node, 1 /* Export */)) { + // Keep async modifier for ES2017 transformer + var isAsync = ts.hasModifier(node, 256 /* Async */); + statements.push(ts.setOriginalNode(ts.createFunctionDeclaration( + /*decorators*/ undefined, isAsync ? [ts.createNode(119 /* AsyncKeyword */)] : undefined, node.asteriskToken, name, + /*typeParameters*/ undefined, node.parameters, + /*type*/ undefined, node.body, + /*location*/ node), + /*original*/ node)); + addExportMemberAssignment(statements, node); + } + else { + statements.push(node); + } + if (node.name) { + addExportMemberAssignments(statements, node.name); + } + return ts.singleOrMany(statements); + } + function visitClassDeclaration(node) { + var statements = []; + var name = node.name || ts.getGeneratedNameForNode(node); + if (ts.hasModifier(node, 1 /* Export */)) { + statements.push(ts.setOriginalNode(ts.createClassDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, name, + /*typeParameters*/ undefined, node.heritageClauses, node.members, + /*location*/ node), + /*original*/ node)); + addExportMemberAssignment(statements, node); + } + else { + statements.push(node); + } + // Decorators end up creating a series of assignment expressions which overwrite + // the local binding that we export, so we need to defer from exporting decorated classes + // until the decoration assignments take place. We do this when visiting expression-statements. + if (node.name && !(node.decorators && node.decorators.length)) { + addExportMemberAssignments(statements, node.name); + } + return ts.singleOrMany(statements); + } + function visitExpressionStatement(node) { + var original = ts.getOriginalNode(node); + var origKind = original.kind; + if (origKind === 225 /* EnumDeclaration */ || origKind === 226 /* ModuleDeclaration */) { + return visitExpressionStatementForEnumOrNamespaceDeclaration(node, original); + } + else if (origKind === 222 /* ClassDeclaration */) { + // The decorated assignment for a class name may need to be transformed. + var classDecl = original; + if (classDecl.name) { + var statements = [node]; + addExportMemberAssignments(statements, classDecl.name); + return statements; + } + } + return node; + } + function visitExpressionStatementForEnumOrNamespaceDeclaration(node, original) { + var statements = [node]; + // Preserve old behavior for enums in which a variable statement is emitted after the body itself. + if (ts.hasModifier(original, 1 /* Export */) && + original.kind === 225 /* EnumDeclaration */ && + ts.isFirstDeclarationOfKind(original, 225 /* EnumDeclaration */)) { + addVarForExportedEnumOrNamespaceDeclaration(statements, original); + } + addExportMemberAssignments(statements, original.name); + return statements; } /** - * Called by the printer just before a node is printed. - * - * @param node The node to be printed. + * Adds a trailing VariableStatement for an enum or module declaration. */ + function addVarForExportedEnumOrNamespaceDeclaration(statements, node) { + var transformedStatement = ts.createVariableStatement( + /*modifiers*/ undefined, [ts.createVariableDeclaration(getDeclarationName(node), + /*type*/ undefined, ts.createPropertyAccess(ts.createIdentifier("exports"), getDeclarationName(node)))], + /*location*/ node); + ts.setEmitFlags(transformedStatement, 49152 /* NoComments */); + statements.push(transformedStatement); + } + function getDeclarationName(node) { + return node.name ? ts.getSynthesizedClone(node.name) : ts.getGeneratedNameForNode(node); + } function onEmitNode(emitContext, node, emitCallback) { - var savedEnclosingFunction = enclosingFunction; - if (enabledSubstitutions & 1 /* CapturedThis */ && ts.isFunctionLike(node)) { - // If we are tracking a captured `this`, keep track of the enclosing function. - enclosingFunction = node; + if (node.kind === 256 /* SourceFile */) { + bindingNameExportSpecifiersMap = bindingNameExportSpecifiersForFileMap[ts.getOriginalNodeId(node)]; + previousOnEmitNode(emitContext, node, emitCallback); + bindingNameExportSpecifiersMap = undefined; } - previousOnEmitNode(emitContext, node, emitCallback); - enclosingFunction = savedEnclosingFunction; - } - /** - * Enables a more costly code path for substitutions when we determine a source file - * contains block-scoped bindings (e.g. `let` or `const`). - */ - function enableSubstitutionsForBlockScopedBindings() { - if ((enabledSubstitutions & 2 /* BlockScopedBindings */) === 0) { - enabledSubstitutions |= 2 /* BlockScopedBindings */; - context.enableSubstitution(69 /* Identifier */); - } - } - /** - * Enables a more costly code path for substitutions when we determine a source file - * contains a captured `this`. - */ - function enableSubstitutionsForCapturedThis() { - if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { - enabledSubstitutions |= 1 /* CapturedThis */; - context.enableSubstitution(97 /* ThisKeyword */); - context.enableEmitNotification(148 /* Constructor */); - context.enableEmitNotification(147 /* MethodDeclaration */); - context.enableEmitNotification(149 /* GetAccessor */); - context.enableEmitNotification(150 /* SetAccessor */); - context.enableEmitNotification(180 /* ArrowFunction */); - context.enableEmitNotification(179 /* FunctionExpression */); - context.enableEmitNotification(220 /* FunctionDeclaration */); + else { + previousOnEmitNode(emitContext, node, emitCallback); } } /** @@ -52856,168 +52305,1407 @@ var ts; if (emitContext === 1 /* Expression */) { return substituteExpression(node); } - if (ts.isIdentifier(node)) { - return substituteIdentifier(node); + else if (ts.isShorthandPropertyAssignment(node)) { + return substituteShorthandPropertyAssignment(node); } return node; } - /** - * Hooks substitutions for non-expression identifiers. - */ - function substituteIdentifier(node) { - // Only substitute the identifier if we have enabled substitutions for block-scoped - // bindings. - if (enabledSubstitutions & 2 /* BlockScopedBindings */) { - var original = ts.getParseTreeNode(node, ts.isIdentifier); - if (original && isNameOfDeclarationWithCollidingName(original)) { - return ts.getGeneratedNameForNode(original); + function substituteShorthandPropertyAssignment(node) { + var name = node.name; + var exportedOrImportedName = substituteExpressionIdentifier(name); + if (exportedOrImportedName !== name) { + // A shorthand property with an assignment initializer is probably part of a + // destructuring assignment + if (node.objectAssignmentInitializer) { + var initializer = ts.createAssignment(exportedOrImportedName, node.objectAssignmentInitializer); + return ts.createPropertyAssignment(name, initializer, /*location*/ node); + } + return ts.createPropertyAssignment(name, exportedOrImportedName, /*location*/ node); + } + return node; + } + function substituteExpression(node) { + switch (node.kind) { + case 70 /* Identifier */: + return substituteExpressionIdentifier(node); + case 188 /* BinaryExpression */: + return substituteBinaryExpression(node); + case 187 /* PostfixUnaryExpression */: + case 186 /* PrefixUnaryExpression */: + return substituteUnaryExpression(node); + } + return node; + } + function substituteExpressionIdentifier(node) { + return trySubstituteExportedName(node) + || trySubstituteImportedName(node) + || node; + } + function substituteBinaryExpression(node) { + var left = node.left; + // If the left-hand-side of the binaryExpression is an identifier and its is export through export Specifier + if (ts.isIdentifier(left) && ts.isAssignmentOperator(node.operatorToken.kind)) { + if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, left.text)) { + ts.setEmitFlags(node, 128 /* NoSubstitution */); + var nestedExportAssignment = void 0; + for (var _i = 0, _a = bindingNameExportSpecifiersMap[left.text]; _i < _a.length; _i++) { + var specifier = _a[_i]; + nestedExportAssignment = nestedExportAssignment ? + createExportAssignment(specifier.name, nestedExportAssignment) : + createExportAssignment(specifier.name, node); + } + return nestedExportAssignment; } } return node; } - /** - * Determines whether a name is the name of a declaration with a colliding name. - * NOTE: This function expects to be called with an original source tree node. - * - * @param node An original source tree node. - */ - function isNameOfDeclarationWithCollidingName(node) { - var parent = node.parent; - switch (parent.kind) { - case 169 /* BindingElement */: - case 221 /* ClassDeclaration */: - case 224 /* EnumDeclaration */: - case 218 /* VariableDeclaration */: - return parent.name === node - && resolver.isDeclarationWithCollidingName(parent); + function substituteUnaryExpression(node) { + // Because how the compiler only parse plusplus and minusminus to be either prefixUnaryExpression or postFixUnaryExpression depended on where they are + // We don't need to check that the operator has SyntaxKind.plusplus or SyntaxKind.minusminus + var operator = node.operator; + var operand = node.operand; + if (ts.isIdentifier(operand) && bindingNameExportSpecifiersForFileMap) { + if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, operand.text)) { + ts.setEmitFlags(node, 128 /* NoSubstitution */); + var transformedUnaryExpression = void 0; + if (node.kind === 187 /* PostfixUnaryExpression */) { + transformedUnaryExpression = ts.createBinary(operand, ts.createToken(operator === 42 /* PlusPlusToken */ ? 58 /* PlusEqualsToken */ : 59 /* MinusEqualsToken */), ts.createLiteral(1), + /*location*/ node); + // We have to set no substitution flag here to prevent visit the binary expression and substitute it again as we will preform all necessary substitution in here + ts.setEmitFlags(transformedUnaryExpression, 128 /* NoSubstitution */); + } + var nestedExportAssignment = void 0; + for (var _i = 0, _a = bindingNameExportSpecifiersMap[operand.text]; _i < _a.length; _i++) { + var specifier = _a[_i]; + nestedExportAssignment = nestedExportAssignment ? + createExportAssignment(specifier.name, nestedExportAssignment) : + createExportAssignment(specifier.name, transformedUnaryExpression || node); + } + return nestedExportAssignment; + } } - return false; + return node; + } + function trySubstituteExportedName(node) { + var emitFlags = ts.getEmitFlags(node); + if ((emitFlags & 262144 /* LocalName */) === 0) { + var container = resolver.getReferencedExportContainer(node, (emitFlags & 131072 /* ExportName */) !== 0); + if (container) { + if (container.kind === 256 /* SourceFile */) { + return ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node), + /*location*/ node); + } + } + } + return undefined; + } + function trySubstituteImportedName(node) { + if ((ts.getEmitFlags(node) & 262144 /* LocalName */) === 0) { + var declaration = resolver.getReferencedImportDeclaration(node); + if (declaration) { + if (ts.isImportClause(declaration)) { + return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent), ts.createIdentifier("default"), + /*location*/ node); + } + else if (ts.isImportSpecifier(declaration)) { + var name_37 = declaration.propertyName || declaration.name; + return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.getSynthesizedClone(name_37), + /*location*/ node); + } + } + } + return undefined; + } + function getModuleMemberName(name) { + return ts.createPropertyAccess(ts.createIdentifier("exports"), name, + /*location*/ name); + } + function createRequireCall(importNode) { + var moduleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); + var args = []; + if (ts.isDefined(moduleName)) { + args.push(moduleName); + } + return ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, args); + } + function createExportStatement(name, value, location) { + var statement = ts.createStatement(createExportAssignment(name, value)); + statement.startsOnNewLine = true; + if (location) { + ts.setSourceMapRange(statement, location); + } + return statement; + } + function createExportAssignment(name, value) { + return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value); + } + function collectAsynchronousDependencies(node, includeNonAmdDependencies) { + // names of modules with corresponding parameter in the factory function + var aliasedModuleNames = []; + // names of modules with no corresponding parameters in factory function + var unaliasedModuleNames = []; + // names of the parameters in the factory function; these + // parameters need to match the indexes of the corresponding + // module names in aliasedModuleNames. + var importAliasNames = []; + // Fill in amd-dependency tags + for (var _i = 0, _a = node.amdDependencies; _i < _a.length; _i++) { + var amdDependency = _a[_i]; + if (amdDependency.name) { + aliasedModuleNames.push(ts.createLiteral(amdDependency.path)); + importAliasNames.push(ts.createParameter(amdDependency.name)); + } + else { + unaliasedModuleNames.push(ts.createLiteral(amdDependency.path)); + } + } + for (var _b = 0, externalImports_1 = externalImports; _b < externalImports_1.length; _b++) { + var importNode = externalImports_1[_b]; + // Find the name of the external module + var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); + // Find the name of the module alias, if there is one + var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile); + if (includeNonAmdDependencies && importAliasName) { + // Set emitFlags on the name of the classDeclaration + // This is so that when printer will not substitute the identifier + ts.setEmitFlags(importAliasName, 128 /* NoSubstitution */); + aliasedModuleNames.push(externalModuleName); + importAliasNames.push(ts.createParameter(importAliasName)); + } + else { + unaliasedModuleNames.push(externalModuleName); + } + } + return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; + } + function updateSourceFile(node, statements) { + var updated = ts.getMutableClone(node); + updated.statements = ts.createNodeArray(statements, node.statements); + return updated; + } + var _a; + } + ts.transformModule = transformModule; +})(ts || (ts = {})); +/// +/// +/*@internal*/ +var ts; +(function (ts) { + function transformSystemModule(context) { + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration, hoistFunctionDeclaration = context.hoistFunctionDeclaration; + var compilerOptions = context.getCompilerOptions(); + var resolver = context.getEmitResolver(); + var host = context.getEmitHost(); + var previousOnSubstituteNode = context.onSubstituteNode; + var previousOnEmitNode = context.onEmitNode; + context.onSubstituteNode = onSubstituteNode; + context.onEmitNode = onEmitNode; + context.enableSubstitution(70 /* Identifier */); + context.enableSubstitution(188 /* BinaryExpression */); + context.enableSubstitution(186 /* PrefixUnaryExpression */); + context.enableSubstitution(187 /* PostfixUnaryExpression */); + context.enableEmitNotification(256 /* SourceFile */); + var exportFunctionForFileMap = []; + var currentSourceFile; + var externalImports; + var exportSpecifiers; + var exportEquals; + var hasExportStarsToExportValues; + var exportFunctionForFile; + var contextObjectForFile; + var exportedLocalNames; + var exportedFunctionDeclarations; + var enclosingBlockScopedContainer; + var currentParent; + var currentNode; + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + currentSourceFile = node; + currentNode = node; + // Perform the transformation. + var updated = transformSystemModuleWorker(node); + ts.aggregateTransformFlags(updated); + currentSourceFile = undefined; + externalImports = undefined; + exportSpecifiers = undefined; + exportEquals = undefined; + hasExportStarsToExportValues = false; + exportFunctionForFile = undefined; + contextObjectForFile = undefined; + exportedLocalNames = undefined; + exportedFunctionDeclarations = undefined; + return updated; + } + return node; + } + function transformSystemModuleWorker(node) { + // System modules have the following shape: + // + // System.register(['dep-1', ... 'dep-n'], function(exports) {/* module body function */}) + // + // The parameter 'exports' here is a callback '(name: string, value: T) => T' that + // is used to publish exported values. 'exports' returns its 'value' argument so in + // most cases expressions that mutate exported values can be rewritten as: + // + // expr -> exports('name', expr) + // + // The only exception in this rule is postfix unary operators, + // see comment to 'substitutePostfixUnaryExpression' for more details + ts.Debug.assert(!exportFunctionForFile); + // Collect information about the external module and dependency groups. + (_a = ts.collectExternalModuleInfo(node), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); + // Make sure that the name of the 'exports' function does not conflict with + // existing identifiers. + exportFunctionForFile = ts.createUniqueName("exports"); + contextObjectForFile = ts.createUniqueName("context"); + exportFunctionForFileMap[ts.getOriginalNodeId(node)] = exportFunctionForFile; + var dependencyGroups = collectDependencyGroups(externalImports); + var statements = []; + // Add the body of the module. + addSystemModuleBody(statements, node, dependencyGroups); + var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); + var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, getNameOfDependencyGroup)); + var body = ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, [ + ts.createParameter(exportFunctionForFile), + ts.createParameter(contextObjectForFile) + ], + /*type*/ undefined, ts.setEmitFlags(ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true), 1 /* EmitEmitHelpers */)); + // Write the call to `System.register` + // Clear the emit-helpers flag for later passes since we'll have already used it in the module body + // So the helper will be emit at the correct position instead of at the top of the source-file + return updateSourceFile(node, [ + ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), + /*typeArguments*/ undefined, moduleName + ? [moduleName, dependencies, body] + : [dependencies, body])) + ], /*nodeEmitFlags*/ ~1 /* EmitEmitHelpers */ & ts.getEmitFlags(node)); + var _a; } /** - * Substitutes an expression. + * Adds the statements for the module body function for the source file. * - * @param node An Expression node. + * @param statements The output statements for the module body. + * @param node The source file for the module. + * @param statementOffset The offset at which to begin visiting the statements of the SourceFile. + */ + function addSystemModuleBody(statements, node, dependencyGroups) { + // Shape of the body in system modules: + // + // function (exports) { + // + // + // + // return { + // setters: [ + // + // ], + // execute: function() { + // + // } + // } + // + // } + // + // i.e: + // + // import {x} from 'file1' + // var y = 1; + // export function foo() { return y + x(); } + // console.log(y); + // + // Will be transformed to: + // + // function(exports) { + // var file_1; // local alias + // var y; + // function foo() { return y + file_1.x(); } + // exports("foo", foo); + // return { + // setters: [ + // function(v) { file_1 = v } + // ], + // execute(): function() { + // y = 1; + // console.log(y); + // } + // }; + // } + // We start a new lexical environment in this function body, but *not* in the + // body of the execute function. This allows us to emit temporary declarations + // only in the outer module body and not in the inner one. + startLexicalEnvironment(); + // Add any prologue directives. + var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, visitSourceElement); + // var __moduleName = context_1 && context_1.id; + statements.push(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration("__moduleName", + /*type*/ undefined, ts.createLogicalAnd(contextObjectForFile, ts.createPropertyAccess(contextObjectForFile, "id"))) + ]))); + // Visit the statements of the source file, emitting any transformations into + // the `executeStatements` array. We do this *before* we fill the `setters` array + // as we both emit transformations as well as aggregate some data used when creating + // setters. This allows us to reduce the number of times we need to loop through the + // statements of the source file. + var executeStatements = ts.visitNodes(node.statements, visitSourceElement, ts.isStatement, statementOffset); + // We emit the lexical environment (hoisted variables and function declarations) + // early to align roughly with our previous emit output. + // Two key differences in this approach are: + // - Temporary variables will appear at the top rather than at the bottom of the file + // - Calls to the exporter for exported function declarations are grouped after + // the declarations. + ts.addRange(statements, endLexicalEnvironment()); + // Emit early exports for function declarations. + ts.addRange(statements, exportedFunctionDeclarations); + var exportStarFunction = addExportStarIfNeeded(statements); + statements.push(ts.createReturn(ts.setMultiLine(ts.createObjectLiteral([ + ts.createPropertyAssignment("setters", generateSetters(exportStarFunction, dependencyGroups)), + ts.createPropertyAssignment("execute", ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, + /*parameters*/ [], + /*type*/ undefined, ts.createBlock(executeStatements, + /*location*/ undefined, + /*multiLine*/ true))) + ]), + /*multiLine*/ true))); + } + function addExportStarIfNeeded(statements) { + if (!hasExportStarsToExportValues) { + return; + } + // when resolving exports local exported entries/indirect exported entries in the module + // should always win over entries with similar names that were added via star exports + // to support this we store names of local/indirect exported entries in a set. + // this set is used to filter names brought by star expors. + // local names set should only be added if we have anything exported + if (!exportedLocalNames && ts.isEmpty(exportSpecifiers)) { + // no exported declarations (export var ...) or export specifiers (export {x}) + // check if we have any non star export declarations. + var hasExportDeclarationWithExportClause = false; + for (var _i = 0, externalImports_2 = externalImports; _i < externalImports_2.length; _i++) { + var externalImport = externalImports_2[_i]; + if (externalImport.kind === 237 /* ExportDeclaration */ && externalImport.exportClause) { + hasExportDeclarationWithExportClause = true; + break; + } + } + if (!hasExportDeclarationWithExportClause) { + // we still need to emit exportStar helper + return addExportStarFunction(statements, /*localNames*/ undefined); + } + } + var exportedNames = []; + if (exportedLocalNames) { + for (var _a = 0, exportedLocalNames_1 = exportedLocalNames; _a < exportedLocalNames_1.length; _a++) { + var exportedLocalName = exportedLocalNames_1[_a]; + // write name of exported declaration, i.e 'export var x...' + exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName.text), ts.createLiteral(true))); + } + } + for (var _b = 0, externalImports_3 = externalImports; _b < externalImports_3.length; _b++) { + var externalImport = externalImports_3[_b]; + if (externalImport.kind !== 237 /* ExportDeclaration */) { + continue; + } + var exportDecl = externalImport; + if (!exportDecl.exportClause) { + // export * from ... + continue; + } + for (var _c = 0, _d = exportDecl.exportClause.elements; _c < _d.length; _c++) { + var element = _d[_c]; + // write name of indirectly exported entry, i.e. 'export {x} from ...' + exportedNames.push(ts.createPropertyAssignment(ts.createLiteral((element.name || element.propertyName).text), ts.createLiteral(true))); + } + } + var exportedNamesStorageRef = ts.createUniqueName("exportedNames"); + statements.push(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(exportedNamesStorageRef, + /*type*/ undefined, ts.createObjectLiteral(exportedNames, /*location*/ undefined, /*multiline*/ true)) + ]))); + return addExportStarFunction(statements, exportedNamesStorageRef); + } + /** + * Emits a setter callback for each dependency group. + * @param write The callback used to write each callback. + */ + function generateSetters(exportStarFunction, dependencyGroups) { + var setters = []; + for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { + var group = dependencyGroups_1[_i]; + // derive a unique name for parameter from the first named entry in the group + var localName = ts.forEach(group.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); + var parameterName = localName ? ts.getGeneratedNameForNode(localName) : ts.createUniqueName(""); + var statements = []; + for (var _a = 0, _b = group.externalImports; _a < _b.length; _a++) { + var entry = _b[_a]; + var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); + switch (entry.kind) { + case 231 /* ImportDeclaration */: + if (!entry.importClause) { + // 'import "..."' case + // module is imported only for side-effects, no emit required + break; + } + // fall-through + case 230 /* ImportEqualsDeclaration */: + ts.Debug.assert(importVariableName !== undefined); + // save import into the local + statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); + break; + case 237 /* ExportDeclaration */: + ts.Debug.assert(importVariableName !== undefined); + if (entry.exportClause) { + // export {a, b as c} from 'foo' + // + // emit as: + // + // exports_({ + // "a": _["a"], + // "c": _["b"] + // }); + var properties = []; + for (var _c = 0, _d = entry.exportClause.elements; _c < _d.length; _c++) { + var e = _d[_c]; + properties.push(ts.createPropertyAssignment(ts.createLiteral(e.name.text), ts.createElementAccess(parameterName, ts.createLiteral((e.propertyName || e.name).text)))); + } + statements.push(ts.createStatement(ts.createCall(exportFunctionForFile, + /*typeArguments*/ undefined, [ts.createObjectLiteral(properties, /*location*/ undefined, /*multiline*/ true)]))); + } + else { + // export * from 'foo' + // + // emit as: + // + // exportStar(foo_1_1); + statements.push(ts.createStatement(ts.createCall(exportStarFunction, + /*typeArguments*/ undefined, [parameterName]))); + } + break; + } + } + setters.push(ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, [ts.createParameter(parameterName)], + /*type*/ undefined, ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true))); + } + return ts.createArrayLiteral(setters, /*location*/ undefined, /*multiLine*/ true); + } + function visitSourceElement(node) { + switch (node.kind) { + case 231 /* ImportDeclaration */: + return visitImportDeclaration(node); + case 230 /* ImportEqualsDeclaration */: + return visitImportEqualsDeclaration(node); + case 237 /* ExportDeclaration */: + return visitExportDeclaration(node); + case 236 /* ExportAssignment */: + return visitExportAssignment(node); + default: + return visitNestedNode(node); + } + } + function visitNestedNode(node) { + var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; + var savedCurrentParent = currentParent; + var savedCurrentNode = currentNode; + var currentGrandparent = currentParent; + currentParent = currentNode; + currentNode = node; + if (currentParent && ts.isBlockScope(currentParent, currentGrandparent)) { + enclosingBlockScopedContainer = currentParent; + } + var result = visitNestedNodeWorker(node); + enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; + currentParent = savedCurrentParent; + currentNode = savedCurrentNode; + return result; + } + function visitNestedNodeWorker(node) { + switch (node.kind) { + case 201 /* VariableStatement */: + return visitVariableStatement(node); + case 221 /* FunctionDeclaration */: + return visitFunctionDeclaration(node); + case 222 /* ClassDeclaration */: + return visitClassDeclaration(node); + case 207 /* ForStatement */: + return visitForStatement(node); + case 208 /* ForInStatement */: + return visitForInStatement(node); + case 209 /* ForOfStatement */: + return visitForOfStatement(node); + case 205 /* DoStatement */: + return visitDoStatement(node); + case 206 /* WhileStatement */: + return visitWhileStatement(node); + case 215 /* LabeledStatement */: + return visitLabeledStatement(node); + case 213 /* WithStatement */: + return visitWithStatement(node); + case 214 /* SwitchStatement */: + return visitSwitchStatement(node); + case 228 /* CaseBlock */: + return visitCaseBlock(node); + case 249 /* CaseClause */: + return visitCaseClause(node); + case 250 /* DefaultClause */: + return visitDefaultClause(node); + case 217 /* TryStatement */: + return visitTryStatement(node); + case 252 /* CatchClause */: + return visitCatchClause(node); + case 200 /* Block */: + return visitBlock(node); + case 203 /* ExpressionStatement */: + return visitExpressionStatement(node); + default: + return node; + } + } + function visitImportDeclaration(node) { + if (node.importClause && ts.contains(externalImports, node)) { + hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); + } + return undefined; + } + function visitImportEqualsDeclaration(node) { + if (ts.contains(externalImports, node)) { + hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); + } + // NOTE(rbuckton): Do we support export import = require('') in System? + return undefined; + } + function visitExportDeclaration(node) { + if (!node.moduleSpecifier) { + var statements = []; + ts.addRange(statements, ts.map(node.exportClause.elements, visitExportSpecifier)); + return statements; + } + return undefined; + } + function visitExportSpecifier(specifier) { + recordExportName(specifier.name); + return createExportStatement(specifier.name, specifier.propertyName || specifier.name); + } + function visitExportAssignment(node) { + if (node.isExportEquals) { + // Elide `export=` as it is illegal in a SystemJS module. + return undefined; + } + return createExportStatement(ts.createLiteral("default"), node.expression); + } + /** + * Visits a variable statement, hoisting declared names to the top-level module body. + * Each declaration is rewritten into an assignment expression. + * + * @param node The variable statement to visit. + */ + function visitVariableStatement(node) { + // hoist only non-block scoped declarations or block scoped declarations parented by source file + var shouldHoist = ((ts.getCombinedNodeFlags(ts.getOriginalNode(node.declarationList)) & 3 /* BlockScoped */) == 0) || + enclosingBlockScopedContainer.kind === 256 /* SourceFile */; + if (!shouldHoist) { + return node; + } + var isExported = ts.hasModifier(node, 1 /* Export */); + var expressions = []; + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var variable = _a[_i]; + var visited = transformVariable(variable, isExported); + if (visited) { + expressions.push(visited); + } + } + if (expressions.length) { + return ts.createStatement(ts.inlineExpressions(expressions), node); + } + return undefined; + } + /** + * Transforms a VariableDeclaration into one or more assignment expressions. + * + * @param node The VariableDeclaration to transform. + * @param isExported A value used to indicate whether the containing statement was exported. + */ + function transformVariable(node, isExported) { + // Hoist any bound names within the declaration. + hoistBindingElement(node, isExported); + if (!node.initializer) { + // If the variable has no initializer, ignore it. + return; + } + var name = node.name; + if (ts.isIdentifier(name)) { + // If the variable has an IdentifierName, write out an assignment expression in its place. + return ts.createAssignment(name, node.initializer); + } + else { + // If the variable has a BindingPattern, flatten the variable into multiple assignment expressions. + return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration); + } + } + /** + * Visits a FunctionDeclaration, hoisting it to the outer module body function. + * + * @param node The function declaration to visit. + */ + function visitFunctionDeclaration(node) { + if (ts.hasModifier(node, 1 /* Export */)) { + // If the function is exported, ensure it has a name and rewrite the function without any export flags. + var name_38 = node.name || ts.getGeneratedNameForNode(node); + // Keep async modifier for ES2017 transformer + var isAsync = ts.hasModifier(node, 256 /* Async */); + var newNode = ts.createFunctionDeclaration( + /*decorators*/ undefined, isAsync ? [ts.createNode(119 /* AsyncKeyword */)] : undefined, node.asteriskToken, name_38, + /*typeParameters*/ undefined, node.parameters, + /*type*/ undefined, node.body, + /*location*/ node); + // Record a declaration export in the outer module body function. + recordExportedFunctionDeclaration(node); + if (!ts.hasModifier(node, 512 /* Default */)) { + recordExportName(name_38); + } + ts.setOriginalNode(newNode, node); + node = newNode; + } + // Hoist the function declaration to the outer module body function. + hoistFunctionDeclaration(node); + return undefined; + } + function visitExpressionStatement(node) { + var originalNode = ts.getOriginalNode(node); + if ((originalNode.kind === 226 /* ModuleDeclaration */ || originalNode.kind === 225 /* EnumDeclaration */) && ts.hasModifier(originalNode, 1 /* Export */)) { + var name_39 = getDeclarationName(originalNode); + // We only need to hoistVariableDeclaration for EnumDeclaration + // as ModuleDeclaration is already hoisted when the transformer call visitVariableStatement + // which then call transformsVariable for each declaration in declarationList + if (originalNode.kind === 225 /* EnumDeclaration */) { + hoistVariableDeclaration(name_39); + } + return [ + node, + createExportStatement(name_39, name_39) + ]; + } + return node; + } + /** + * Visits a ClassDeclaration, hoisting its name to the outer module body function. + * + * @param node The class declaration to visit. + */ + function visitClassDeclaration(node) { + // Hoist the name of the class declaration to the outer module body function. + var name = getDeclarationName(node); + hoistVariableDeclaration(name); + var statements = []; + // Rewrite the class declaration into an assignment of a class expression. + statements.push(ts.createStatement(ts.createAssignment(name, ts.createClassExpression( + /*modifiers*/ undefined, node.name, + /*typeParameters*/ undefined, node.heritageClauses, node.members, + /*location*/ node)), + /*location*/ node)); + // If the class was exported, write a declaration export to the inner module body function. + if (ts.hasModifier(node, 1 /* Export */)) { + if (!ts.hasModifier(node, 512 /* Default */)) { + recordExportName(name); + } + statements.push(createDeclarationExport(node)); + } + return statements; + } + function shouldHoistLoopInitializer(node) { + return ts.isVariableDeclarationList(node) && (ts.getCombinedNodeFlags(node) & 3 /* BlockScoped */) === 0; + } + /** + * Visits the body of a ForStatement to hoist declarations. + * + * @param node The statement to visit. + */ + function visitForStatement(node) { + var initializer = node.initializer; + if (shouldHoistLoopInitializer(initializer)) { + var expressions = []; + for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) { + var variable = _a[_i]; + var visited = transformVariable(variable, /*isExported*/ false); + if (visited) { + expressions.push(visited); + } + } + ; + return ts.createFor(expressions.length + ? ts.inlineExpressions(expressions) + : ts.createSynthesizedNode(194 /* OmittedExpression */), node.condition, node.incrementor, ts.visitNode(node.statement, visitNestedNode, ts.isStatement), + /*location*/ node); + } + else { + return ts.visitEachChild(node, visitNestedNode, context); + } + } + /** + * Transforms and hoists the declaration list of a ForInStatement or ForOfStatement into an expression. + * + * @param node The decalaration list to transform. + */ + function transformForBinding(node) { + var firstDeclaration = ts.firstOrUndefined(node.declarations); + hoistBindingElement(firstDeclaration, /*isExported*/ false); + var name = firstDeclaration.name; + return ts.isIdentifier(name) + ? name + : ts.flattenVariableDestructuringToExpression(firstDeclaration, hoistVariableDeclaration); + } + /** + * Visits the body of a ForInStatement to hoist declarations. + * + * @param node The statement to visit. + */ + function visitForInStatement(node) { + var initializer = node.initializer; + if (shouldHoistLoopInitializer(initializer)) { + var updated = ts.getMutableClone(node); + updated.initializer = transformForBinding(initializer); + updated.statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); + return updated; + } + else { + return ts.visitEachChild(node, visitNestedNode, context); + } + } + /** + * Visits the body of a ForOfStatement to hoist declarations. + * + * @param node The statement to visit. + */ + function visitForOfStatement(node) { + var initializer = node.initializer; + if (shouldHoistLoopInitializer(initializer)) { + var updated = ts.getMutableClone(node); + updated.initializer = transformForBinding(initializer); + updated.statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); + return updated; + } + else { + return ts.visitEachChild(node, visitNestedNode, context); + } + } + /** + * Visits the body of a DoStatement to hoist declarations. + * + * @param node The statement to visit. + */ + function visitDoStatement(node) { + var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); + if (statement !== node.statement) { + var updated = ts.getMutableClone(node); + updated.statement = statement; + return updated; + } + return node; + } + /** + * Visits the body of a WhileStatement to hoist declarations. + * + * @param node The statement to visit. + */ + function visitWhileStatement(node) { + var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); + if (statement !== node.statement) { + var updated = ts.getMutableClone(node); + updated.statement = statement; + return updated; + } + return node; + } + /** + * Visits the body of a LabeledStatement to hoist declarations. + * + * @param node The statement to visit. + */ + function visitLabeledStatement(node) { + var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); + if (statement !== node.statement) { + var updated = ts.getMutableClone(node); + updated.statement = statement; + return updated; + } + return node; + } + /** + * Visits the body of a WithStatement to hoist declarations. + * + * @param node The statement to visit. + */ + function visitWithStatement(node) { + var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); + if (statement !== node.statement) { + var updated = ts.getMutableClone(node); + updated.statement = statement; + return updated; + } + return node; + } + /** + * Visits the body of a SwitchStatement to hoist declarations. + * + * @param node The statement to visit. + */ + function visitSwitchStatement(node) { + var caseBlock = ts.visitNode(node.caseBlock, visitNestedNode, ts.isCaseBlock); + if (caseBlock !== node.caseBlock) { + var updated = ts.getMutableClone(node); + updated.caseBlock = caseBlock; + return updated; + } + return node; + } + /** + * Visits the body of a CaseBlock to hoist declarations. + * + * @param node The node to visit. + */ + function visitCaseBlock(node) { + var clauses = ts.visitNodes(node.clauses, visitNestedNode, ts.isCaseOrDefaultClause); + if (clauses !== node.clauses) { + var updated = ts.getMutableClone(node); + updated.clauses = clauses; + return updated; + } + return node; + } + /** + * Visits the body of a CaseClause to hoist declarations. + * + * @param node The clause to visit. + */ + function visitCaseClause(node) { + var statements = ts.visitNodes(node.statements, visitNestedNode, ts.isStatement); + if (statements !== node.statements) { + var updated = ts.getMutableClone(node); + updated.statements = statements; + return updated; + } + return node; + } + /** + * Visits the body of a DefaultClause to hoist declarations. + * + * @param node The clause to visit. + */ + function visitDefaultClause(node) { + return ts.visitEachChild(node, visitNestedNode, context); + } + /** + * Visits the body of a TryStatement to hoist declarations. + * + * @param node The statement to visit. + */ + function visitTryStatement(node) { + return ts.visitEachChild(node, visitNestedNode, context); + } + /** + * Visits the body of a CatchClause to hoist declarations. + * + * @param node The clause to visit. + */ + function visitCatchClause(node) { + var block = ts.visitNode(node.block, visitNestedNode, ts.isBlock); + if (block !== node.block) { + var updated = ts.getMutableClone(node); + updated.block = block; + return updated; + } + return node; + } + /** + * Visits the body of a Block to hoist declarations. + * + * @param node The block to visit. + */ + function visitBlock(node) { + return ts.visitEachChild(node, visitNestedNode, context); + } + // + // Substitutions + // + function onEmitNode(emitContext, node, emitCallback) { + if (node.kind === 256 /* SourceFile */) { + exportFunctionForFile = exportFunctionForFileMap[ts.getOriginalNodeId(node)]; + previousOnEmitNode(emitContext, node, emitCallback); + exportFunctionForFile = undefined; + } + else { + previousOnEmitNode(emitContext, node, emitCallback); + } + } + /** + * Hooks node substitutions. + * + * @param node The node to substitute. + * @param isExpression A value indicating whether the node is to be used in an expression + * position. + */ + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1 /* Expression */) { + return substituteExpression(node); + } + return node; + } + /** + * Substitute the expression, if necessary. + * + * @param node The node to substitute. */ function substituteExpression(node) { switch (node.kind) { - case 69 /* Identifier */: + case 70 /* Identifier */: return substituteExpressionIdentifier(node); - case 97 /* ThisKeyword */: - return substituteThisKeyword(node); + case 188 /* BinaryExpression */: + return substituteBinaryExpression(node); + case 186 /* PrefixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: + return substituteUnaryExpression(node); } return node; } /** - * Substitutes an expression identifier. - * - * @param node An Identifier node. + * Substitution for identifiers exported at the top level of a module. */ function substituteExpressionIdentifier(node) { - if (enabledSubstitutions & 2 /* BlockScopedBindings */) { - var declaration = resolver.getReferencedDeclarationWithCollidingName(node); - if (declaration) { - return ts.getGeneratedNameForNode(declaration.name); + var importDeclaration = resolver.getReferencedImportDeclaration(node); + if (importDeclaration) { + var importBinding = createImportBinding(importDeclaration); + if (importBinding) { + return importBinding; + } + } + return node; + } + function substituteBinaryExpression(node) { + if (ts.isAssignmentOperator(node.operatorToken.kind)) { + return substituteAssignmentExpression(node); + } + return node; + } + function substituteAssignmentExpression(node) { + ts.setEmitFlags(node, 128 /* NoSubstitution */); + var left = node.left; + switch (left.kind) { + case 70 /* Identifier */: + var exportDeclaration = resolver.getReferencedExportContainer(left); + if (exportDeclaration) { + return createExportExpression(left, node); + } + break; + case 172 /* ObjectLiteralExpression */: + case 171 /* ArrayLiteralExpression */: + if (hasExportedReferenceInDestructuringPattern(left)) { + return substituteDestructuring(node); + } + break; + } + return node; + } + function isExportedBinding(name) { + var container = resolver.getReferencedExportContainer(name); + return container && container.kind === 256 /* SourceFile */; + } + function hasExportedReferenceInDestructuringPattern(node) { + switch (node.kind) { + case 70 /* Identifier */: + return isExportedBinding(node); + case 172 /* ObjectLiteralExpression */: + for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { + var property = _a[_i]; + if (hasExportedReferenceInObjectDestructuringElement(property)) { + return true; + } + } + break; + case 171 /* ArrayLiteralExpression */: + for (var _b = 0, _c = node.elements; _b < _c.length; _b++) { + var element = _c[_b]; + if (hasExportedReferenceInArrayDestructuringElement(element)) { + return true; + } + } + break; + } + return false; + } + function hasExportedReferenceInObjectDestructuringElement(node) { + if (ts.isShorthandPropertyAssignment(node)) { + return isExportedBinding(node.name); + } + else if (ts.isPropertyAssignment(node)) { + return hasExportedReferenceInDestructuringElement(node.initializer); + } + else { + return false; + } + } + function hasExportedReferenceInArrayDestructuringElement(node) { + if (ts.isSpreadElementExpression(node)) { + var expression = node.expression; + return ts.isIdentifier(expression) && isExportedBinding(expression); + } + else { + return hasExportedReferenceInDestructuringElement(node); + } + } + function hasExportedReferenceInDestructuringElement(node) { + if (ts.isBinaryExpression(node)) { + var left = node.left; + return node.operatorToken.kind === 57 /* EqualsToken */ + && isDestructuringPattern(left) + && hasExportedReferenceInDestructuringPattern(left); + } + else if (ts.isIdentifier(node)) { + return isExportedBinding(node); + } + else if (ts.isSpreadElementExpression(node)) { + var expression = node.expression; + return ts.isIdentifier(expression) && isExportedBinding(expression); + } + else if (isDestructuringPattern(node)) { + return hasExportedReferenceInDestructuringPattern(node); + } + else { + return false; + } + } + function isDestructuringPattern(node) { + var kind = node.kind; + return kind === 70 /* Identifier */ + || kind === 172 /* ObjectLiteralExpression */ + || kind === 171 /* ArrayLiteralExpression */; + } + function substituteDestructuring(node) { + return ts.flattenDestructuringAssignment(context, node, /*needsValue*/ true, hoistVariableDeclaration); + } + function substituteUnaryExpression(node) { + var operand = node.operand; + var operator = node.operator; + var substitute = ts.isIdentifier(operand) && + (node.kind === 187 /* PostfixUnaryExpression */ || + (node.kind === 186 /* PrefixUnaryExpression */ && (operator === 42 /* PlusPlusToken */ || operator === 43 /* MinusMinusToken */))); + if (substitute) { + var exportDeclaration = resolver.getReferencedExportContainer(operand); + if (exportDeclaration) { + var expr = ts.createPrefix(node.operator, operand, node); + ts.setEmitFlags(expr, 128 /* NoSubstitution */); + var call = createExportExpression(operand, expr); + if (node.kind === 186 /* PrefixUnaryExpression */) { + return call; + } + else { + // export function returns the value that was passes as the second argument + // however for postfix unary expressions result value should be the value before modification. + // emit 'x++' as '(export('x', ++x) - 1)' and 'x--' as '(export('x', --x) + 1)' + return operator === 42 /* PlusPlusToken */ + ? ts.createSubtract(call, ts.createLiteral(1)) + : ts.createAdd(call, ts.createLiteral(1)); + } } } return node; } /** - * Substitutes `this` when contained within an arrow function. - * - * @param node The ThisKeyword node. + * Gets a name to use for a DeclarationStatement. + * @param node The declaration statement. */ - function substituteThisKeyword(node) { - if (enabledSubstitutions & 1 /* CapturedThis */ - && enclosingFunction - && ts.getEmitFlags(enclosingFunction) & 256 /* CapturesThis */) { - return ts.createIdentifier("_this", /*location*/ node); + function getDeclarationName(node) { + return node.name ? ts.getSynthesizedClone(node.name) : ts.getGeneratedNameForNode(node); + } + function addExportStarFunction(statements, localNames) { + var exportStarFunction = ts.createUniqueName("exportStar"); + var m = ts.createIdentifier("m"); + var n = ts.createIdentifier("n"); + var exports = ts.createIdentifier("exports"); + var condition = ts.createStrictInequality(n, ts.createLiteral("default")); + if (localNames) { + condition = ts.createLogicalAnd(condition, ts.createLogicalNot(ts.createHasOwnProperty(localNames, n))); } - return node; + statements.push(ts.createFunctionDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, exportStarFunction, + /*typeParameters*/ undefined, [ts.createParameter(m)], + /*type*/ undefined, ts.createBlock([ + ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(exports, + /*type*/ undefined, ts.createObjectLiteral([])) + ])), + ts.createForIn(ts.createVariableDeclarationList([ + ts.createVariableDeclaration(n, /*type*/ undefined) + ]), m, ts.createBlock([ + ts.setEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 32 /* SingleLine */) + ])), + ts.createStatement(ts.createCall(exportFunctionForFile, + /*typeArguments*/ undefined, [exports])) + ], + /*location*/ undefined, + /*multiline*/ true))); + return exportStarFunction; } /** - * Gets the local name for a declaration for use in expressions. - * - * A local name will *never* be prefixed with an module or namespace export modifier like - * "exports.". - * - * @param node The declaration. - * @param allowComments A value indicating whether comments may be emitted for the name. - * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. + * Creates a call to the current file's export function to export a value. + * @param name The bound name of the export. + * @param value The exported value. */ - function getLocalName(node, allowComments, allowSourceMaps) { - return getDeclarationName(node, allowComments, allowSourceMaps, 262144 /* LocalName */); + function createExportExpression(name, value) { + var exportName = ts.isIdentifier(name) ? ts.createLiteral(name.text) : name; + return ts.createCall(exportFunctionForFile, /*typeArguments*/ undefined, [exportName, value]); } /** - * Gets the name of a declaration, without source map or comments. - * - * @param node The declaration. - * @param allowComments Allow comments for the name. + * Creates a call to the current file's export function to export a value. + * @param name The bound name of the export. + * @param value The exported value. */ - function getDeclarationName(node, allowComments, allowSourceMaps, emitFlags) { - if (node.name && !ts.isGeneratedIdentifier(node.name)) { - var name_39 = ts.getMutableClone(node.name); - emitFlags |= ts.getEmitFlags(node.name); - if (!allowSourceMaps) { - emitFlags |= 1536 /* NoSourceMap */; - } - if (!allowComments) { - emitFlags |= 49152 /* NoComments */; - } - if (emitFlags) { - ts.setEmitFlags(name_39, emitFlags); - } - return name_39; - } - return ts.getGeneratedNameForNode(node); + function createExportStatement(name, value) { + return ts.createStatement(createExportExpression(name, value)); } - function getClassMemberPrefix(node, member) { - var expression = getLocalName(node); - return ts.hasModifier(member, 32 /* Static */) ? expression : ts.createPropertyAccess(expression, "prototype"); + /** + * Creates a call to the current file's export function to export a declaration. + * @param node The declaration to export. + */ + function createDeclarationExport(node) { + var declarationName = getDeclarationName(node); + var exportName = ts.hasModifier(node, 512 /* Default */) ? ts.createLiteral("default") : declarationName; + return createExportStatement(exportName, declarationName); } - function hasSynthesizedDefaultSuperCall(constructor, hasExtendsClause) { - if (!constructor || !hasExtendsClause) { - return false; + function createImportBinding(importDeclaration) { + var importAlias; + var name; + if (ts.isImportClause(importDeclaration)) { + importAlias = ts.getGeneratedNameForNode(importDeclaration.parent); + name = ts.createIdentifier("default"); } - var parameter = ts.singleOrUndefined(constructor.parameters); - if (!parameter || !ts.nodeIsSynthesized(parameter) || !parameter.dotDotDotToken) { - return false; + else if (ts.isImportSpecifier(importDeclaration)) { + importAlias = ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent); + name = importDeclaration.propertyName || importDeclaration.name; } - var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 202 /* ExpressionStatement */) { - return false; + else { + return undefined; } - var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 174 /* CallExpression */) { - return false; + return ts.createPropertyAccess(importAlias, ts.getSynthesizedClone(name)); + } + function collectDependencyGroups(externalImports) { + var groupIndices = ts.createMap(); + var dependencyGroups = []; + for (var i = 0; i < externalImports.length; i++) { + var externalImport = externalImports[i]; + var externalModuleName = ts.getExternalModuleNameLiteral(externalImport, currentSourceFile, host, resolver, compilerOptions); + var text = externalModuleName.text; + if (ts.hasProperty(groupIndices, text)) { + // deduplicate/group entries in dependency list by the dependency name + var groupIndex = groupIndices[text]; + dependencyGroups[groupIndex].externalImports.push(externalImport); + continue; + } + else { + groupIndices[text] = dependencyGroups.length; + dependencyGroups.push({ + name: externalModuleName, + externalImports: [externalImport] + }); + } } - var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 95 /* SuperKeyword */) { - return false; + return dependencyGroups; + } + function getNameOfDependencyGroup(dependencyGroup) { + return dependencyGroup.name; + } + function recordExportName(name) { + if (!exportedLocalNames) { + exportedLocalNames = []; } - var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 191 /* SpreadElementExpression */) { - return false; + exportedLocalNames.push(name); + } + function recordExportedFunctionDeclaration(node) { + if (!exportedFunctionDeclarations) { + exportedFunctionDeclarations = []; } - var expression = callArgument.expression; - return ts.isIdentifier(expression) && expression === parameter.name; + exportedFunctionDeclarations.push(createDeclarationExport(node)); + } + function hoistBindingElement(node, isExported) { + if (ts.isOmittedExpression(node)) { + return; + } + var name = node.name; + if (ts.isIdentifier(name)) { + hoistVariableDeclaration(ts.getSynthesizedClone(name)); + if (isExported) { + recordExportName(name); + } + } + else if (ts.isBindingPattern(name)) { + ts.forEach(name.elements, isExported ? hoistExportedBindingElement : hoistNonExportedBindingElement); + } + } + function hoistExportedBindingElement(node) { + hoistBindingElement(node, /*isExported*/ true); + } + function hoistNonExportedBindingElement(node) { + hoistBindingElement(node, /*isExported*/ false); + } + function updateSourceFile(node, statements, nodeEmitFlags) { + var updated = ts.getMutableClone(node); + updated.statements = ts.createNodeArray(statements, node.statements); + ts.setEmitFlags(updated, nodeEmitFlags); + return updated; } } - ts.transformES6 = transformES6; + ts.transformSystemModule = transformSystemModule; +})(ts || (ts = {})); +/// +/// +/*@internal*/ +var ts; +(function (ts) { + function transformES2015Module(context) { + var compilerOptions = context.getCompilerOptions(); + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + return ts.visitEachChild(node, visitor, context); + } + return node; + } + function visitor(node) { + switch (node.kind) { + case 230 /* ImportEqualsDeclaration */: + // Elide `import=` as it is not legal with --module ES6 + return undefined; + case 236 /* ExportAssignment */: + return visitExportAssignment(node); + } + return node; + } + function visitExportAssignment(node) { + // Elide `export=` as it is not legal with --module ES6 + return node.isExportEquals ? undefined : node; + } + } + ts.transformES2015Module = transformES2015Module; +})(ts || (ts = {})); +/// +/// +/*@internal*/ +var ts; +(function (ts) { + /** + * Transforms ES5 syntax into ES3 syntax. + * + * @param context Context and state information for the transformation. + */ + function transformES5(context) { + var previousOnSubstituteNode = context.onSubstituteNode; + context.onSubstituteNode = onSubstituteNode; + context.enableSubstitution(173 /* PropertyAccessExpression */); + context.enableSubstitution(253 /* PropertyAssignment */); + return transformSourceFile; + /** + * Transforms an ES5 source file to ES3. + * + * @param node A SourceFile + */ + function transformSourceFile(node) { + return node; + } + /** + * Hooks node substitutions. + * + * @param emitContext The context for the emitter. + * @param node The node to substitute. + */ + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (ts.isPropertyAccessExpression(node)) { + return substitutePropertyAccessExpression(node); + } + else if (ts.isPropertyAssignment(node)) { + return substitutePropertyAssignment(node); + } + return node; + } + /** + * Substitutes a PropertyAccessExpression whose name is a reserved word. + * + * @param node A PropertyAccessExpression + */ + function substitutePropertyAccessExpression(node) { + var literalName = trySubstituteReservedName(node.name); + if (literalName) { + return ts.createElementAccess(node.expression, literalName, /*location*/ node); + } + return node; + } + /** + * Substitutes a PropertyAssignment whose name is a reserved word. + * + * @param node A PropertyAssignment + */ + function substitutePropertyAssignment(node) { + var literalName = ts.isIdentifier(node.name) && trySubstituteReservedName(node.name); + if (literalName) { + return ts.updatePropertyAssignment(node, literalName, node.initializer); + } + return node; + } + /** + * If an identifier name is a reserved word, returns a string literal for the name. + * + * @param name An Identifier + */ + function trySubstituteReservedName(name) { + var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(name.text) : undefined); + if (token >= 71 /* FirstReservedWord */ && token <= 106 /* LastReservedWord */) { + return ts.createLiteral(name, /*location*/ name); + } + return undefined; + } + } + ts.transformES5 = transformES5; })(ts || (ts = {})); /// /// /// -/// -/// +/// +/// +/// /// +/// /// /// -/// +/// /* @internal */ var ts; (function (ts) { var moduleTransformerMap = ts.createMap((_a = {}, - _a[ts.ModuleKind.ES6] = ts.transformES6Module, + _a[ts.ModuleKind.ES2015] = ts.transformES2015Module, _a[ts.ModuleKind.System] = ts.transformSystemModule, _a[ts.ModuleKind.AMD] = ts.transformModule, _a[ts.ModuleKind.CommonJS] = ts.transformModule, @@ -53039,11 +53727,19 @@ var ts; if (jsx === 2 /* React */) { transformers.push(ts.transformJsx); } - transformers.push(ts.transformES7); - if (languageVersion < 2 /* ES6 */) { - transformers.push(ts.transformES6); + if (languageVersion < 4 /* ES2017 */) { + transformers.push(ts.transformES2017); + } + if (languageVersion < 3 /* ES2016 */) { + transformers.push(ts.transformES2016); + } + if (languageVersion < 2 /* ES2015 */) { + transformers.push(ts.transformES2015); transformers.push(ts.transformGenerators); } + if (languageVersion < 1 /* ES5 */) { + transformers.push(ts.transformES5); + } return transformers; } ts.getTransformers = getTransformers; @@ -53073,7 +53769,7 @@ var ts; hoistFunctionDeclaration: hoistFunctionDeclaration, startLexicalEnvironment: startLexicalEnvironment, endLexicalEnvironment: endLexicalEnvironment, - onSubstituteNode: function (emitContext, node) { return node; }, + onSubstituteNode: function (_emitContext, node) { return node; }, enableSubstitution: enableSubstitution, isSubstitutionEnabled: isSubstitutionEnabled, onEmitNode: function (node, emitContext, emitCallback) { return emitCallback(node, emitContext); }, @@ -53274,7 +53970,7 @@ var ts; emitNodeWithSourceMap: emitNodeWithSourceMap, emitTokenWithSourceMap: emitTokenWithSourceMap, getText: getText, - getSourceMappingURL: getSourceMappingURL + getSourceMappingURL: getSourceMappingURL, }; /** * Initialize the SourceMapWriter for a new output file. @@ -53548,7 +54244,7 @@ var ts; sources: sourceMapData.sourceMapSources, names: sourceMapData.sourceMapNames, mappings: sourceMapData.sourceMapMappings, - sourcesContent: sourceMapData.sourceMapSourcesContent + sourcesContent: sourceMapData.sourceMapSourcesContent, }); } /** @@ -53625,7 +54321,7 @@ var ts; setSourceFile: setSourceFile, emitNodeWithComments: emitNodeWithComments, emitBodyWithDetachedComments: emitBodyWithDetachedComments, - emitTrailingCommentsOfPosition: emitTrailingCommentsOfPosition + emitTrailingCommentsOfPosition: emitTrailingCommentsOfPosition, }; function emitNodeWithComments(emitContext, node, emitCallback) { if (disabled) { @@ -53669,7 +54365,7 @@ var ts; containerEnd = end; // To avoid invalid comment emit in a down-level binding pattern, we // keep track of the last declaration list container's end - if (node.kind === 219 /* VariableDeclarationList */) { + if (node.kind === 220 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -53756,7 +54452,7 @@ var ts; emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos); } } - function emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) { + function emitLeadingComment(commentPos, commentEnd, _kind, hasTrailingNewLine, rangePos) { if (!hasWrittenComment) { ts.emitNewLineBeforeLeadingCommentOfPosition(currentLineMap, writer, rangePos, commentPos); hasWrittenComment = true; @@ -53775,7 +54471,7 @@ var ts; function emitTrailingComments(pos) { forEachTrailingCommentToEmit(pos, emitTrailingComment); } - function emitTrailingComment(commentPos, commentEnd, kind, hasTrailingNewLine) { + function emitTrailingComment(commentPos, commentEnd, _kind, hasTrailingNewLine) { // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment2*/ if (!writer.isAtStartOfLine()) { writer.write(" "); @@ -53799,7 +54495,7 @@ var ts; ts.performance.measure("commentTime", "beforeEmitTrailingCommentsOfPosition"); } } - function emitTrailingCommentOfPosition(commentPos, commentEnd, kind, hasTrailingNewLine) { + function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) { // trailing comments of a position are emitted at /*trailing comment1 */space/*trailing comment*/space emitPos(commentPos); ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); @@ -53923,7 +54619,7 @@ var ts; var isCurrentFileExternalModule; var reportedDeclarationError = false; var errorNameNode; - var emitJsDocComments = compilerOptions.removeComments ? function (declaration) { } : writeJsDocComments; + var emitJsDocComments = compilerOptions.removeComments ? function () { } : writeJsDocComments; var emit = compilerOptions.stripInternal ? stripInternal : emitNode; var noDeclare; var moduleElementDeclarationEmitInfo = []; @@ -53979,7 +54675,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 230 /* ImportDeclaration */); + ts.Debug.assert(aliasEmitInfo.node.kind === 231 /* ImportDeclaration */); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -54013,7 +54709,7 @@ var ts; reportedDeclarationError: reportedDeclarationError, moduleElementDeclarationEmitInfo: allSourcesModuleElementDeclarationEmitInfo, synchronousDeclarationOutput: writer.getText(), - referencesOutput: referencesOutput + referencesOutput: referencesOutput, }; function hasInternalAnnotation(range) { var comment = currentText.substring(range.pos, range.end); @@ -54053,10 +54749,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 218 /* VariableDeclaration */) { + if (declaration.kind === 219 /* VariableDeclaration */) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 233 /* NamedImports */ || declaration.kind === 234 /* ImportSpecifier */ || declaration.kind === 231 /* ImportClause */) { + else if (declaration.kind === 234 /* NamedImports */ || declaration.kind === 235 /* ImportSpecifier */ || declaration.kind === 232 /* ImportClause */) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -54074,7 +54770,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 === 230 /* ImportDeclaration */) { + if (moduleElementEmitInfo.node.kind === 231 /* 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; @@ -54084,12 +54780,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 225 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 226 /* ModuleDeclaration */) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 225 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 226 /* ModuleDeclaration */) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -54206,53 +54902,53 @@ var ts; } function emitType(type) { switch (type.kind) { - case 117 /* AnyKeyword */: - case 132 /* StringKeyword */: - case 130 /* NumberKeyword */: - case 120 /* BooleanKeyword */: - case 133 /* SymbolKeyword */: - case 103 /* VoidKeyword */: - case 135 /* UndefinedKeyword */: - case 93 /* NullKeyword */: - case 127 /* NeverKeyword */: - case 165 /* ThisType */: - case 166 /* LiteralType */: + case 118 /* AnyKeyword */: + case 133 /* StringKeyword */: + case 131 /* NumberKeyword */: + case 121 /* BooleanKeyword */: + case 134 /* SymbolKeyword */: + case 104 /* VoidKeyword */: + case 136 /* UndefinedKeyword */: + case 94 /* NullKeyword */: + case 128 /* NeverKeyword */: + case 166 /* ThisType */: + case 167 /* LiteralType */: return writeTextOfNode(currentText, type); - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(type); - case 155 /* TypeReference */: + case 156 /* TypeReference */: return emitTypeReference(type); - case 158 /* TypeQuery */: + case 159 /* TypeQuery */: return emitTypeQuery(type); - case 160 /* ArrayType */: + case 161 /* ArrayType */: return emitArrayType(type); - case 161 /* TupleType */: + case 162 /* TupleType */: return emitTupleType(type); - case 162 /* UnionType */: + case 163 /* UnionType */: return emitUnionType(type); - case 163 /* IntersectionType */: + case 164 /* IntersectionType */: return emitIntersectionType(type); - case 164 /* ParenthesizedType */: + case 165 /* ParenthesizedType */: return emitParenType(type); - case 156 /* FunctionType */: - case 157 /* ConstructorType */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: return emitSignatureDeclarationWithJsDocComments(type); - case 159 /* TypeLiteral */: + case 160 /* TypeLiteral */: return emitTypeLiteral(type); - case 69 /* Identifier */: + case 70 /* Identifier */: return emitEntityName(type); - case 139 /* QualifiedName */: + case 140 /* QualifiedName */: return emitEntityName(type); - case 154 /* TypePredicate */: + case 155 /* TypePredicate */: return emitTypePredicate(type); } function writeEntityName(entityName) { - if (entityName.kind === 69 /* Identifier */) { + if (entityName.kind === 70 /* Identifier */) { writeTextOfNode(currentText, entityName); } else { - var left = entityName.kind === 139 /* QualifiedName */ ? entityName.left : entityName.expression; - var right = entityName.kind === 139 /* QualifiedName */ ? entityName.right : entityName.name; + var left = entityName.kind === 140 /* QualifiedName */ ? entityName.left : entityName.expression; + var right = entityName.kind === 140 /* QualifiedName */ ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentText, right); @@ -54261,14 +54957,14 @@ var ts; function emitEntityName(entityName) { var visibilityResult = resolver.isEntityNameVisible(entityName, // Aliases can be written asynchronously so use correct enclosing declaration - entityName.parent.kind === 229 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); + entityName.parent.kind === 230 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isEntityNameExpression(node.expression)) { - ts.Debug.assert(node.expression.kind === 69 /* Identifier */ || node.expression.kind === 172 /* PropertyAccessExpression */); + ts.Debug.assert(node.expression.kind === 70 /* Identifier */ || node.expression.kind === 173 /* PropertyAccessExpression */); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -54354,7 +55050,7 @@ var ts; } } function emitExportAssignment(node) { - if (node.expression.kind === 69 /* Identifier */) { + if (node.expression.kind === 70 /* Identifier */) { write(node.isExportEquals ? "export = " : "export default "); writeTextOfNode(currentText, node.expression); } @@ -54377,12 +55073,12 @@ var ts; write(";"); writeLine(); // Make all the declarations visible for the export name - if (node.expression.kind === 69 /* Identifier */) { + if (node.expression.kind === 70 /* Identifier */) { var nodes = resolver.collectLinkedAliases(node.expression); // write each of these declarations asynchronously writeAsynchronousModuleElements(nodes); } - function getDefaultExportAccessibilityDiagnostic(diagnostic) { + function getDefaultExportAccessibilityDiagnostic() { return { diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, errorNode: node @@ -54396,7 +55092,7 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 229 /* ImportEqualsDeclaration */ || + else if (node.kind === 230 /* ImportEqualsDeclaration */ || (node.parent.kind === 256 /* SourceFile */ && isCurrentFileExternalModule)) { var isVisible = void 0; if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 256 /* SourceFile */) { @@ -54409,7 +55105,7 @@ var ts; }); } else { - if (node.kind === 230 /* ImportDeclaration */) { + if (node.kind === 231 /* ImportDeclaration */) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -54427,23 +55123,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 220 /* FunctionDeclaration */: + case 221 /* FunctionDeclaration */: return writeFunctionDeclaration(node); - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: return writeVariableStatement(node); - case 222 /* InterfaceDeclaration */: + case 223 /* InterfaceDeclaration */: return writeInterfaceDeclaration(node); - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: return writeClassDeclaration(node); - case 223 /* TypeAliasDeclaration */: + case 224 /* TypeAliasDeclaration */: return writeTypeAliasDeclaration(node); - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: return writeEnumDeclaration(node); - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: return writeModuleDeclaration(node); - case 229 /* ImportEqualsDeclaration */: + case 230 /* ImportEqualsDeclaration */: return writeImportEqualsDeclaration(node); - case 230 /* ImportDeclaration */: + case 231 /* ImportDeclaration */: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -54460,7 +55156,7 @@ var ts; if (modifiers & 512 /* Default */) { write("default "); } - else if (node.kind !== 222 /* InterfaceDeclaration */ && !noDeclare) { + else if (node.kind !== 223 /* InterfaceDeclaration */ && !noDeclare) { write("declare "); } } @@ -54502,7 +55198,7 @@ var ts; write(");"); } writer.writeLine(); - function getImportEntityNameVisibilityError(symbolAccessibilityResult) { + function getImportEntityNameVisibilityError() { return { diagnosticMessage: ts.Diagnostics.Import_declaration_0_is_using_private_name_1, errorNode: node, @@ -54512,7 +55208,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 232 /* NamespaceImport */) { + if (namedBindings.kind === 233 /* NamespaceImport */) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -54536,7 +55232,7 @@ var ts; // If the default binding was emitted, write the separated write(", "); } - if (node.importClause.namedBindings.kind === 232 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 233 /* NamespaceImport */) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -54557,13 +55253,13 @@ var ts; // the only case when it is not true is when we call it to emit correct name for module augmentation - d.ts files with just module augmentations are not considered // external modules since they are indistinguishable from script files with ambient modules. To fix this in such d.ts files we'll emit top level 'export {}' // so compiler will treat them as external modules. - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 225 /* ModuleDeclaration */; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 226 /* ModuleDeclaration */; var moduleSpecifier; - if (parent.kind === 229 /* ImportEqualsDeclaration */) { + if (parent.kind === 230 /* ImportEqualsDeclaration */) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 225 /* ModuleDeclaration */) { + else if (parent.kind === 226 /* ModuleDeclaration */) { moduleSpecifier = parent.name; } else { @@ -54633,7 +55329,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body && node.body.kind !== 226 /* ModuleBlock */) { + while (node.body && node.body.kind !== 227 /* ModuleBlock */) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -54667,7 +55363,7 @@ var ts; write(";"); writeLine(); enclosingDeclaration = prevEnclosingDeclaration; - function getTypeAliasDeclarationVisibilityError(symbolAccessibilityResult) { + function getTypeAliasDeclarationVisibilityError() { return { diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, errorNode: node.type, @@ -54703,7 +55399,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 147 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); + return node.parent.kind === 148 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -54714,50 +55410,50 @@ 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 === 156 /* FunctionType */ || - node.parent.kind === 157 /* ConstructorType */ || - (node.parent.parent && node.parent.parent.kind === 159 /* TypeLiteral */)) { - ts.Debug.assert(node.parent.kind === 147 /* MethodDeclaration */ || - node.parent.kind === 146 /* MethodSignature */ || - node.parent.kind === 156 /* FunctionType */ || - node.parent.kind === 157 /* ConstructorType */ || - node.parent.kind === 151 /* CallSignature */ || - node.parent.kind === 152 /* ConstructSignature */); + if (node.parent.kind === 157 /* FunctionType */ || + node.parent.kind === 158 /* ConstructorType */ || + (node.parent.parent && node.parent.parent.kind === 160 /* TypeLiteral */)) { + ts.Debug.assert(node.parent.kind === 148 /* MethodDeclaration */ || + node.parent.kind === 147 /* MethodSignature */ || + node.parent.kind === 157 /* FunctionType */ || + node.parent.kind === 158 /* ConstructorType */ || + node.parent.kind === 152 /* CallSignature */ || + node.parent.kind === 153 /* ConstructSignature */); emitType(node.constraint); } else { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.constraint, getTypeParameterConstraintVisibilityError); } } - function getTypeParameterConstraintVisibilityError(symbolAccessibilityResult) { + function getTypeParameterConstraintVisibilityError() { // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 222 /* InterfaceDeclaration */: + case 223 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 152 /* ConstructSignature */: + case 153 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 151 /* CallSignature */: + case 152 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* 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 === 221 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 222 /* 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 220 /* FunctionDeclaration */: + case 221 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -54785,17 +55481,17 @@ var ts; if (ts.isEntityNameExpression(node.expression)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } - else if (!isImplementsList && node.expression.kind === 93 /* NullKeyword */) { + else if (!isImplementsList && node.expression.kind === 94 /* NullKeyword */) { write("null"); } else { writer.getSymbolAccessibilityDiagnostic = getHeritageClauseVisibilityError; resolver.writeBaseConstructorTypeOfClass(enclosingDeclaration, enclosingDeclaration, 2 /* UseTypeOfFunction */ | 1024 /* UseTypeAliasValue */, writer); } - function getHeritageClauseVisibilityError(symbolAccessibilityResult) { + function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 221 /* ClassDeclaration */) { + if (node.parent.parent.kind === 222 /* 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 : @@ -54879,7 +55575,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 !== 218 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (node.kind !== 219 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -54890,11 +55586,11 @@ var ts; writeTextOfNode(currentText, node.name); // If optional property emit ? but in the case of parameterProperty declaration with "?" indicating optional parameter for the constructor // we don't want to emit property declaration with "?" - if ((node.kind === 145 /* PropertyDeclaration */ || node.kind === 144 /* PropertySignature */ || - (node.kind === 142 /* Parameter */ && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { + if ((node.kind === 146 /* PropertyDeclaration */ || node.kind === 145 /* PropertySignature */ || + (node.kind === 143 /* Parameter */ && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 145 /* PropertyDeclaration */ || node.kind === 144 /* PropertySignature */) && node.parent.kind === 159 /* TypeLiteral */) { + if ((node.kind === 146 /* PropertyDeclaration */ || node.kind === 145 /* PropertySignature */) && node.parent.kind === 160 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (resolver.isLiteralConstDeclaration(node)) { @@ -54907,14 +55603,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 218 /* VariableDeclaration */) { + if (node.kind === 219 /* VariableDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 === 145 /* PropertyDeclaration */ || node.kind === 144 /* PropertySignature */) { + else if (node.kind === 146 /* PropertyDeclaration */ || node.kind === 145 /* PropertySignature */) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.hasModifier(node, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? @@ -54923,7 +55619,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 === 221 /* ClassDeclaration */) { + else if (node.parent.kind === 222 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 : @@ -54955,7 +55651,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 193 /* OmittedExpression */) { + if (element.kind !== 194 /* OmittedExpression */) { elements.push(element); } } @@ -55025,7 +55721,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 === 149 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 150 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -55038,7 +55734,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 149 /* GetAccessor */ + return accessor.kind === 150 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -55047,7 +55743,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 150 /* SetAccessor */) { + if (accessorWithTypeAnnotation.kind === 151 /* SetAccessor */) { // Setters have to have type named and cannot infer it so, the type should always be named if (ts.hasModifier(accessorWithTypeAnnotation.parent, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? @@ -55097,17 +55793,17 @@ var ts; // so no need to verify if the declaration is visible if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 220 /* FunctionDeclaration */) { + if (node.kind === 221 /* FunctionDeclaration */) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 147 /* MethodDeclaration */ || node.kind === 148 /* Constructor */) { + else if (node.kind === 148 /* MethodDeclaration */ || node.kind === 149 /* Constructor */) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); } - if (node.kind === 220 /* FunctionDeclaration */) { + if (node.kind === 221 /* FunctionDeclaration */) { write("function "); writeTextOfNode(currentText, node.name); } - else if (node.kind === 148 /* Constructor */) { + else if (node.kind === 149 /* Constructor */) { write("constructor"); } else { @@ -55127,17 +55823,17 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; var closeParenthesizedFunctionType = false; - if (node.kind === 153 /* IndexSignature */) { + if (node.kind === 154 /* IndexSignature */) { // Index signature can have readonly modifier emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); write("["); } else { // Construct signature or constructor type write new Signature - if (node.kind === 152 /* ConstructSignature */ || node.kind === 157 /* ConstructorType */) { + if (node.kind === 153 /* ConstructSignature */ || node.kind === 158 /* ConstructorType */) { write("new "); } - else if (node.kind === 156 /* FunctionType */) { + else if (node.kind === 157 /* FunctionType */) { var currentOutput = writer.getText(); // Do not generate incorrect type when function type with type parameters is type argument // This could happen if user used space between two '<' making it error free @@ -55152,22 +55848,22 @@ var ts; } // Parameters emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 153 /* IndexSignature */) { + if (node.kind === 154 /* IndexSignature */) { write("]"); } else { write(")"); } // If this is not a constructor and is not private, emit the return type - var isFunctionTypeOrConstructorType = node.kind === 156 /* FunctionType */ || node.kind === 157 /* ConstructorType */; - if (isFunctionTypeOrConstructorType || node.parent.kind === 159 /* TypeLiteral */) { + var isFunctionTypeOrConstructorType = node.kind === 157 /* FunctionType */ || node.kind === 158 /* ConstructorType */; + if (isFunctionTypeOrConstructorType || node.parent.kind === 160 /* TypeLiteral */) { // Emit type literal signature return type only if specified if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 148 /* Constructor */ && !ts.hasModifier(node, 8 /* Private */)) { + else if (node.kind !== 149 /* Constructor */ && !ts.hasModifier(node, 8 /* Private */)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -55181,26 +55877,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 152 /* ConstructSignature */: + case 153 /* ConstructSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.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 151 /* CallSignature */: + case 152 /* CallSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.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 153 /* IndexSignature */: + case 154 /* IndexSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.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 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: if (ts.hasModifier(node, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -55208,7 +55904,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 === 221 /* ClassDeclaration */) { + else if (node.parent.kind === 222 /* ClassDeclaration */) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 : @@ -55222,7 +55918,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 220 /* FunctionDeclaration */: + case 221 /* FunctionDeclaration */: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -55257,9 +55953,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 156 /* FunctionType */ || - node.parent.kind === 157 /* ConstructorType */ || - node.parent.parent.kind === 159 /* TypeLiteral */) { + if (node.parent.kind === 157 /* FunctionType */ || + node.parent.kind === 158 /* ConstructorType */ || + node.parent.parent.kind === 160 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!ts.hasModifier(node.parent, 8 /* Private */)) { @@ -55275,24 +55971,24 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 148 /* Constructor */: + case 149 /* Constructor */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 152 /* ConstructSignature */: + case 153 /* ConstructSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.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 151 /* CallSignature */: + case 152 /* CallSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.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 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -55300,7 +55996,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 === 221 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 222 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 : @@ -55313,7 +56009,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 220 /* FunctionDeclaration */: + case 221 /* FunctionDeclaration */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -55325,12 +56021,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 === 167 /* ObjectBindingPattern */) { + if (bindingPattern.kind === 168 /* ObjectBindingPattern */) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 168 /* ArrayBindingPattern */) { + else if (bindingPattern.kind === 169 /* ArrayBindingPattern */) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -55341,7 +56037,7 @@ var ts; } } function emitBindingElement(bindingElement) { - if (bindingElement.kind === 193 /* OmittedExpression */) { + if (bindingElement.kind === 194 /* 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) @@ -55350,7 +56046,7 @@ var ts; // emit : function foo([ , x, , ]) {} write(" "); } - else if (bindingElement.kind === 169 /* BindingElement */) { + else if (bindingElement.kind === 170 /* 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" @@ -55373,7 +56069,7 @@ var ts; emitBindingPattern(bindingElement.name); } else { - ts.Debug.assert(bindingElement.name.kind === 69 /* Identifier */); + ts.Debug.assert(bindingElement.name.kind === 70 /* 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}) {} @@ -55389,38 +56085,38 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 220 /* FunctionDeclaration */: - case 225 /* ModuleDeclaration */: - case 229 /* ImportEqualsDeclaration */: - case 222 /* InterfaceDeclaration */: - case 221 /* ClassDeclaration */: - case 223 /* TypeAliasDeclaration */: - case 224 /* EnumDeclaration */: + case 221 /* FunctionDeclaration */: + case 226 /* ModuleDeclaration */: + case 230 /* ImportEqualsDeclaration */: + case 223 /* InterfaceDeclaration */: + case 222 /* ClassDeclaration */: + case 224 /* TypeAliasDeclaration */: + case 225 /* EnumDeclaration */: return emitModuleElement(node, isModuleElementVisible(node)); - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: return emitModuleElement(node, isVariableStatementVisible(node)); - case 230 /* ImportDeclaration */: + case 231 /* ImportDeclaration */: // Import declaration without import clause is visible, otherwise it is not visible return emitModuleElement(node, /*isModuleElementVisible*/ !node.importClause); - case 236 /* ExportDeclaration */: + case 237 /* ExportDeclaration */: return emitExportDeclaration(node); - case 148 /* Constructor */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 149 /* Constructor */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: return writeFunctionDeclaration(node); - case 152 /* ConstructSignature */: - case 151 /* CallSignature */: - case 153 /* IndexSignature */: + case 153 /* ConstructSignature */: + case 152 /* CallSignature */: + case 154 /* IndexSignature */: return emitSignatureDeclarationWithJsDocComments(node); - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: return emitAccessorDeclaration(node); - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: return emitPropertyDeclaration(node); case 255 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: return emitExportAssignment(node); case 256 /* SourceFile */: return emitSourceFile(node); @@ -55448,7 +56144,7 @@ var ts; referencesOutput += "/// " + newLine; } return addedBundledEmitReference; - function getDeclFileName(emitFileNames, sourceFiles, isBundledEmit) { + function getDeclFileName(emitFileNames, _sourceFiles, isBundledEmit) { // Dont add reference path to this file if it is a bundled emit and caller asked not emit bundled file path if (isBundledEmit && !addBundledFileReference) { return; @@ -55502,7 +56198,7 @@ var ts; TempFlags[TempFlags["_i"] = 268435456] = "_i"; })(TempFlags || (TempFlags = {})); var id = function (s) { return s; }; - var nullTransformers = [function (ctx) { return id; }]; + var nullTransformers = [function (_) { return id; }]; // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles) { var delimiters = createDelimiterMap(); @@ -55817,7 +56513,7 @@ var ts; var kind = node.kind; switch (kind) { // Identifiers - case 69 /* Identifier */: + case 70 /* Identifier */: return emitIdentifier(node); } } @@ -55831,199 +56527,213 @@ var ts; var kind = node.kind; switch (kind) { // Pseudo-literals - case 12 /* TemplateHead */: - case 13 /* TemplateMiddle */: - case 14 /* TemplateTail */: + case 13 /* TemplateHead */: + case 14 /* TemplateMiddle */: + case 15 /* TemplateTail */: return emitLiteral(node); // Identifiers - case 69 /* Identifier */: + case 70 /* Identifier */: return emitIdentifier(node); // Reserved words - case 74 /* ConstKeyword */: - case 77 /* DefaultKeyword */: - case 82 /* ExportKeyword */: - case 103 /* VoidKeyword */: + case 75 /* ConstKeyword */: + case 78 /* DefaultKeyword */: + case 83 /* ExportKeyword */: + case 104 /* VoidKeyword */: // Strict mode reserved words - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - case 112 /* PublicKeyword */: - case 113 /* StaticKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + case 113 /* PublicKeyword */: + case 114 /* StaticKeyword */: // Contextual keywords - case 115 /* AbstractKeyword */: - case 117 /* AnyKeyword */: - case 118 /* AsyncKeyword */: - case 120 /* BooleanKeyword */: - case 122 /* DeclareKeyword */: - case 130 /* NumberKeyword */: - case 128 /* ReadonlyKeyword */: - case 132 /* StringKeyword */: - case 133 /* SymbolKeyword */: - case 137 /* GlobalKeyword */: + case 116 /* AbstractKeyword */: + case 117 /* AsKeyword */: + case 118 /* AnyKeyword */: + case 119 /* AsyncKeyword */: + case 120 /* AwaitKeyword */: + case 121 /* BooleanKeyword */: + case 122 /* ConstructorKeyword */: + case 123 /* DeclareKeyword */: + case 124 /* GetKeyword */: + case 125 /* IsKeyword */: + case 126 /* ModuleKeyword */: + case 127 /* NamespaceKeyword */: + case 128 /* NeverKeyword */: + case 129 /* ReadonlyKeyword */: + case 130 /* RequireKeyword */: + case 131 /* NumberKeyword */: + case 132 /* SetKeyword */: + case 133 /* StringKeyword */: + case 134 /* SymbolKeyword */: + case 135 /* TypeKeyword */: + case 136 /* UndefinedKeyword */: + case 137 /* FromKeyword */: + case 138 /* GlobalKeyword */: + case 139 /* OfKeyword */: writeTokenText(kind); return; // Parse tree nodes // Names - case 139 /* QualifiedName */: + case 140 /* QualifiedName */: return emitQualifiedName(node); - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 141 /* TypeParameter */: + case 142 /* TypeParameter */: return emitTypeParameter(node); - case 142 /* Parameter */: + case 143 /* Parameter */: return emitParameter(node); - case 143 /* Decorator */: + case 144 /* Decorator */: return emitDecorator(node); // Type members - case 144 /* PropertySignature */: + case 145 /* PropertySignature */: return emitPropertySignature(node); - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: return emitPropertyDeclaration(node); - case 146 /* MethodSignature */: + case 147 /* MethodSignature */: return emitMethodSignature(node); - case 147 /* MethodDeclaration */: + case 148 /* MethodDeclaration */: return emitMethodDeclaration(node); - case 148 /* Constructor */: + case 149 /* Constructor */: return emitConstructor(node); - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: return emitAccessorDeclaration(node); - case 151 /* CallSignature */: + case 152 /* CallSignature */: return emitCallSignature(node); - case 152 /* ConstructSignature */: + case 153 /* ConstructSignature */: return emitConstructSignature(node); - case 153 /* IndexSignature */: + case 154 /* IndexSignature */: return emitIndexSignature(node); // Types - case 154 /* TypePredicate */: + case 155 /* TypePredicate */: return emitTypePredicate(node); - case 155 /* TypeReference */: + case 156 /* TypeReference */: return emitTypeReference(node); - case 156 /* FunctionType */: + case 157 /* FunctionType */: return emitFunctionType(node); - case 157 /* ConstructorType */: + case 158 /* ConstructorType */: return emitConstructorType(node); - case 158 /* TypeQuery */: + case 159 /* TypeQuery */: return emitTypeQuery(node); - case 159 /* TypeLiteral */: + case 160 /* TypeLiteral */: return emitTypeLiteral(node); - case 160 /* ArrayType */: + case 161 /* ArrayType */: return emitArrayType(node); - case 161 /* TupleType */: + case 162 /* TupleType */: return emitTupleType(node); - case 162 /* UnionType */: + case 163 /* UnionType */: return emitUnionType(node); - case 163 /* IntersectionType */: + case 164 /* IntersectionType */: return emitIntersectionType(node); - case 164 /* ParenthesizedType */: + case 165 /* ParenthesizedType */: return emitParenthesizedType(node); - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 165 /* ThisType */: - return emitThisType(node); - case 166 /* LiteralType */: + case 166 /* ThisType */: + return emitThisType(); + case 167 /* LiteralType */: return emitLiteralType(node); // Binding patterns - case 167 /* ObjectBindingPattern */: + case 168 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 168 /* ArrayBindingPattern */: + case 169 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 169 /* BindingElement */: + case 170 /* BindingElement */: return emitBindingElement(node); // Misc - case 197 /* TemplateSpan */: + case 198 /* TemplateSpan */: return emitTemplateSpan(node); - case 198 /* SemicolonClassElement */: - return emitSemicolonClassElement(node); + case 199 /* SemicolonClassElement */: + return emitSemicolonClassElement(); // Statements - case 199 /* Block */: + case 200 /* Block */: return emitBlock(node); - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: return emitVariableStatement(node); - case 201 /* EmptyStatement */: - return emitEmptyStatement(node); - case 202 /* ExpressionStatement */: + case 202 /* EmptyStatement */: + return emitEmptyStatement(); + case 203 /* ExpressionStatement */: return emitExpressionStatement(node); - case 203 /* IfStatement */: + case 204 /* IfStatement */: return emitIfStatement(node); - case 204 /* DoStatement */: + case 205 /* DoStatement */: return emitDoStatement(node); - case 205 /* WhileStatement */: + case 206 /* WhileStatement */: return emitWhileStatement(node); - case 206 /* ForStatement */: + case 207 /* ForStatement */: return emitForStatement(node); - case 207 /* ForInStatement */: + case 208 /* ForInStatement */: return emitForInStatement(node); - case 208 /* ForOfStatement */: + case 209 /* ForOfStatement */: return emitForOfStatement(node); - case 209 /* ContinueStatement */: + case 210 /* ContinueStatement */: return emitContinueStatement(node); - case 210 /* BreakStatement */: + case 211 /* BreakStatement */: return emitBreakStatement(node); - case 211 /* ReturnStatement */: + case 212 /* ReturnStatement */: return emitReturnStatement(node); - case 212 /* WithStatement */: + case 213 /* WithStatement */: return emitWithStatement(node); - case 213 /* SwitchStatement */: + case 214 /* SwitchStatement */: return emitSwitchStatement(node); - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: return emitLabeledStatement(node); - case 215 /* ThrowStatement */: + case 216 /* ThrowStatement */: return emitThrowStatement(node); - case 216 /* TryStatement */: + case 217 /* TryStatement */: return emitTryStatement(node); - case 217 /* DebuggerStatement */: + case 218 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 218 /* VariableDeclaration */: + case 219 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 219 /* VariableDeclarationList */: + case 220 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 220 /* FunctionDeclaration */: + case 221 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: return emitClassDeclaration(node); - case 222 /* InterfaceDeclaration */: + case 223 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 223 /* TypeAliasDeclaration */: + case 224 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 226 /* ModuleBlock */: + case 227 /* ModuleBlock */: return emitModuleBlock(node); - case 227 /* CaseBlock */: + case 228 /* CaseBlock */: return emitCaseBlock(node); - case 229 /* ImportEqualsDeclaration */: + case 230 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 230 /* ImportDeclaration */: + case 231 /* ImportDeclaration */: return emitImportDeclaration(node); - case 231 /* ImportClause */: + case 232 /* ImportClause */: return emitImportClause(node); - case 232 /* NamespaceImport */: + case 233 /* NamespaceImport */: return emitNamespaceImport(node); - case 233 /* NamedImports */: + case 234 /* NamedImports */: return emitNamedImports(node); - case 234 /* ImportSpecifier */: + case 235 /* ImportSpecifier */: return emitImportSpecifier(node); - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: return emitExportAssignment(node); - case 236 /* ExportDeclaration */: + case 237 /* ExportDeclaration */: return emitExportDeclaration(node); - case 237 /* NamedExports */: + case 238 /* NamedExports */: return emitNamedExports(node); - case 238 /* ExportSpecifier */: + case 239 /* ExportSpecifier */: return emitExportSpecifier(node); - case 239 /* MissingDeclaration */: + case 240 /* MissingDeclaration */: return; // Module references - case 240 /* ExternalModuleReference */: + case 241 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) - case 244 /* JsxText */: + case 10 /* JsxText */: return emitJsxText(node); - case 243 /* JsxOpeningElement */: + case 244 /* JsxOpeningElement */: return emitJsxOpeningElement(node); case 245 /* JsxClosingElement */: return emitJsxClosingElement(node); @@ -56070,77 +56780,77 @@ var ts; case 8 /* NumericLiteral */: return emitNumericLiteral(node); case 9 /* StringLiteral */: - case 10 /* RegularExpressionLiteral */: - case 11 /* NoSubstitutionTemplateLiteral */: + case 11 /* RegularExpressionLiteral */: + case 12 /* NoSubstitutionTemplateLiteral */: return emitLiteral(node); // Identifiers - case 69 /* Identifier */: + case 70 /* Identifier */: return emitIdentifier(node); // Reserved words - case 84 /* FalseKeyword */: - case 93 /* NullKeyword */: - case 95 /* SuperKeyword */: - case 99 /* TrueKeyword */: - case 97 /* ThisKeyword */: + case 85 /* FalseKeyword */: + case 94 /* NullKeyword */: + case 96 /* SuperKeyword */: + case 100 /* TrueKeyword */: + case 98 /* ThisKeyword */: writeTokenText(kind); return; // Expressions - case 170 /* ArrayLiteralExpression */: + case 171 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 171 /* ObjectLiteralExpression */: + case 172 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 173 /* ElementAccessExpression */: + case 174 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 174 /* CallExpression */: + case 175 /* CallExpression */: return emitCallExpression(node); - case 175 /* NewExpression */: + case 176 /* NewExpression */: return emitNewExpression(node); - case 176 /* TaggedTemplateExpression */: + case 177 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 177 /* TypeAssertionExpression */: + case 178 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 179 /* FunctionExpression */: + case 180 /* FunctionExpression */: return emitFunctionExpression(node); - case 180 /* ArrowFunction */: + case 181 /* ArrowFunction */: return emitArrowFunction(node); - case 181 /* DeleteExpression */: + case 182 /* DeleteExpression */: return emitDeleteExpression(node); - case 182 /* TypeOfExpression */: + case 183 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 183 /* VoidExpression */: + case 184 /* VoidExpression */: return emitVoidExpression(node); - case 184 /* AwaitExpression */: + case 185 /* AwaitExpression */: return emitAwaitExpression(node); - case 185 /* PrefixUnaryExpression */: + case 186 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 186 /* PostfixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return emitBinaryExpression(node); - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: return emitConditionalExpression(node); - case 189 /* TemplateExpression */: + case 190 /* TemplateExpression */: return emitTemplateExpression(node); - case 190 /* YieldExpression */: + case 191 /* YieldExpression */: return emitYieldExpression(node); - case 191 /* SpreadElementExpression */: + case 192 /* SpreadElementExpression */: return emitSpreadElementExpression(node); - case 192 /* ClassExpression */: + case 193 /* ClassExpression */: return emitClassExpression(node); - case 193 /* OmittedExpression */: + case 194 /* OmittedExpression */: return; - case 195 /* AsExpression */: + case 196 /* AsExpression */: return emitAsExpression(node); - case 196 /* NonNullExpression */: + case 197 /* NonNullExpression */: return emitNonNullExpression(node); // JSX - case 241 /* JsxElement */: + case 242 /* JsxElement */: return emitJsxElement(node); - case 242 /* JsxSelfClosingElement */: + case 243 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); // Transformation nodes case 288 /* PartiallyEmittedExpression */: @@ -56193,7 +56903,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 69 /* Identifier */) { + if (node.kind === 70 /* Identifier */) { emitExpression(node); } else { @@ -56269,7 +56979,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - write(node.kind === 149 /* GetAccessor */ ? "get " : "set "); + write(node.kind === 150 /* GetAccessor */ ? "get " : "set "); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); } @@ -56297,7 +57007,7 @@ var ts; emitWithPrefix(": ", node.type); write(";"); } - function emitSemicolonClassElement(node) { + function emitSemicolonClassElement() { write(";"); } // @@ -56354,7 +57064,7 @@ var ts; emit(node.type); write(")"); } - function emitThisType(node) { + function emitThisType() { write("this"); } function emitLiteralType(node) { @@ -56428,7 +57138,7 @@ var ts; if (!(ts.getEmitFlags(node) & 1048576 /* NoIndentation */)) { var dotRangeStart = node.expression.end; var dotRangeEnd = ts.skipTrivia(currentText, node.expression.end) + 1; - var dotToken = { kind: 21 /* DotToken */, pos: dotRangeStart, end: dotRangeEnd }; + var dotToken = { kind: 22 /* DotToken */, pos: dotRangeStart, end: dotRangeEnd }; indentBeforeDot = needsIndentation(node, node.expression, dotToken); indentAfterDot = needsIndentation(node, dotToken, node.name); } @@ -56446,7 +57156,7 @@ var ts; if (expression.kind === 8 /* NumericLiteral */) { // check if numeric literal was originally written with a dot var text = getLiteralTextOfNode(expression); - return text.indexOf(ts.tokenToString(21 /* DotToken */)) < 0; + return text.indexOf(ts.tokenToString(22 /* DotToken */)) < 0; } else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { // check if constant enum value is integer @@ -56465,11 +57175,13 @@ var ts; } function emitCallExpression(node) { emitExpression(node.expression); + emitTypeArguments(node, node.typeArguments); emitExpressionList(node, node.arguments, 1296 /* CallExpressionArguments */); } function emitNewExpression(node) { write("new "); emitExpression(node.expression); + emitTypeArguments(node, node.typeArguments); emitExpressionList(node, node.arguments, 9488 /* NewExpressionArguments */); } function emitTaggedTemplateExpression(node) { @@ -56541,16 +57253,16 @@ var ts; // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. var operand = node.operand; - return operand.kind === 185 /* PrefixUnaryExpression */ - && ((node.operator === 35 /* PlusToken */ && (operand.operator === 35 /* PlusToken */ || operand.operator === 41 /* PlusPlusToken */)) - || (node.operator === 36 /* MinusToken */ && (operand.operator === 36 /* MinusToken */ || operand.operator === 42 /* MinusMinusToken */))); + return operand.kind === 186 /* PrefixUnaryExpression */ + && ((node.operator === 36 /* PlusToken */ && (operand.operator === 36 /* PlusToken */ || operand.operator === 42 /* PlusPlusToken */)) + || (node.operator === 37 /* MinusToken */ && (operand.operator === 37 /* MinusToken */ || operand.operator === 43 /* MinusMinusToken */))); } function emitPostfixUnaryExpression(node) { emitExpression(node.operand); writeTokenText(node.operator); } function emitBinaryExpression(node) { - var isCommaOperator = node.operatorToken.kind !== 24 /* CommaToken */; + var isCommaOperator = node.operatorToken.kind !== 25 /* CommaToken */; var indentBeforeOperator = needsIndentation(node, node.left, node.operatorToken); var indentAfterOperator = needsIndentation(node, node.operatorToken, node.right); emitExpression(node.left); @@ -56617,16 +57329,16 @@ var ts; // // Statements // - function emitBlock(node, format) { + function emitBlock(node) { if (isSingleLineEmptyBlock(node)) { - writeToken(15 /* OpenBraceToken */, node.pos, /*contextNode*/ node); + writeToken(16 /* OpenBraceToken */, node.pos, /*contextNode*/ node); write(" "); - writeToken(16 /* CloseBraceToken */, node.statements.end, /*contextNode*/ node); + writeToken(17 /* CloseBraceToken */, node.statements.end, /*contextNode*/ node); } else { - writeToken(15 /* OpenBraceToken */, node.pos, /*contextNode*/ node); + writeToken(16 /* OpenBraceToken */, node.pos, /*contextNode*/ node); emitBlockStatements(node); - writeToken(16 /* CloseBraceToken */, node.statements.end, /*contextNode*/ node); + writeToken(17 /* CloseBraceToken */, node.statements.end, /*contextNode*/ node); } } function emitBlockStatements(node) { @@ -56642,7 +57354,7 @@ var ts; emit(node.declarationList); write(";"); } - function emitEmptyStatement(node) { + function emitEmptyStatement() { write(";"); } function emitExpressionStatement(node) { @@ -56650,16 +57362,16 @@ var ts; write(";"); } function emitIfStatement(node) { - var openParenPos = writeToken(88 /* IfKeyword */, node.pos, node); + var openParenPos = writeToken(89 /* IfKeyword */, node.pos, node); write(" "); - writeToken(17 /* OpenParenToken */, openParenPos, node); + writeToken(18 /* OpenParenToken */, openParenPos, node); emitExpression(node.expression); - writeToken(18 /* CloseParenToken */, node.expression.end, node); + writeToken(19 /* CloseParenToken */, node.expression.end, node); emitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { writeLine(); - writeToken(80 /* ElseKeyword */, node.thenStatement.end, node); - if (node.elseStatement.kind === 203 /* IfStatement */) { + writeToken(81 /* ElseKeyword */, node.thenStatement.end, node); + if (node.elseStatement.kind === 204 /* IfStatement */) { write(" "); emit(node.elseStatement); } @@ -56688,9 +57400,9 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForStatement(node) { - var openParenPos = writeToken(86 /* ForKeyword */, node.pos); + var openParenPos = writeToken(87 /* ForKeyword */, node.pos); write(" "); - writeToken(17 /* OpenParenToken */, openParenPos, /*contextNode*/ node); + writeToken(18 /* OpenParenToken */, openParenPos, /*contextNode*/ node); emitForBinding(node.initializer); write(";"); emitExpressionWithPrefix(" ", node.condition); @@ -56700,28 +57412,28 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInStatement(node) { - var openParenPos = writeToken(86 /* ForKeyword */, node.pos); + var openParenPos = writeToken(87 /* ForKeyword */, node.pos); write(" "); - writeToken(17 /* OpenParenToken */, openParenPos); + writeToken(18 /* OpenParenToken */, openParenPos); emitForBinding(node.initializer); write(" in "); emitExpression(node.expression); - writeToken(18 /* CloseParenToken */, node.expression.end); + writeToken(19 /* CloseParenToken */, node.expression.end); emitEmbeddedStatement(node.statement); } function emitForOfStatement(node) { - var openParenPos = writeToken(86 /* ForKeyword */, node.pos); + var openParenPos = writeToken(87 /* ForKeyword */, node.pos); write(" "); - writeToken(17 /* OpenParenToken */, openParenPos); + writeToken(18 /* OpenParenToken */, openParenPos); emitForBinding(node.initializer); write(" of "); emitExpression(node.expression); - writeToken(18 /* CloseParenToken */, node.expression.end); + writeToken(19 /* CloseParenToken */, node.expression.end); emitEmbeddedStatement(node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 219 /* VariableDeclarationList */) { + if (node.kind === 220 /* VariableDeclarationList */) { emit(node); } else { @@ -56730,17 +57442,17 @@ var ts; } } function emitContinueStatement(node) { - writeToken(75 /* ContinueKeyword */, node.pos); + writeToken(76 /* ContinueKeyword */, node.pos); emitWithPrefix(" ", node.label); write(";"); } function emitBreakStatement(node) { - writeToken(70 /* BreakKeyword */, node.pos); + writeToken(71 /* BreakKeyword */, node.pos); emitWithPrefix(" ", node.label); write(";"); } function emitReturnStatement(node) { - writeToken(94 /* ReturnKeyword */, node.pos, /*contextNode*/ node); + writeToken(95 /* ReturnKeyword */, node.pos, /*contextNode*/ node); emitExpressionWithPrefix(" ", node.expression); write(";"); } @@ -56751,11 +57463,11 @@ var ts; emitEmbeddedStatement(node.statement); } function emitSwitchStatement(node) { - var openParenPos = writeToken(96 /* SwitchKeyword */, node.pos); + var openParenPos = writeToken(97 /* SwitchKeyword */, node.pos); write(" "); - writeToken(17 /* OpenParenToken */, openParenPos); + writeToken(18 /* OpenParenToken */, openParenPos); emitExpression(node.expression); - writeToken(18 /* CloseParenToken */, node.expression.end); + writeToken(19 /* CloseParenToken */, node.expression.end); write(" "); emit(node.caseBlock); } @@ -56780,7 +57492,7 @@ var ts; } } function emitDebuggerStatement(node) { - writeToken(76 /* DebuggerKeyword */, node.pos); + writeToken(77 /* DebuggerKeyword */, node.pos); write(";"); } // @@ -56788,6 +57500,7 @@ var ts; // function emitVariableDeclaration(node) { emit(node.name); + emitWithPrefix(": ", node.type); emitExpressionWithPrefix(" = ", node.initializer); } function emitVariableDeclarationList(node) { @@ -56814,13 +57527,13 @@ var ts; } if (ts.getEmitFlags(node) & 4194304 /* ReuseTempVariableScope */) { emitSignatureHead(node); - emitBlockFunctionBody(node, body); + emitBlockFunctionBody(body); } else { var savedTempFlags = tempFlags; tempFlags = 0; emitSignatureHead(node); - emitBlockFunctionBody(node, body); + emitBlockFunctionBody(body); tempFlags = savedTempFlags; } if (indentedFlag) { @@ -56843,7 +57556,7 @@ var ts; emitParameters(node, node.parameters); emitWithPrefix(": ", node.type); } - function shouldEmitBlockFunctionBodyOnSingleLine(parentNode, body) { + function shouldEmitBlockFunctionBodyOnSingleLine(body) { // We must emit a function body as a single-line body in the following case: // * The body has NodeEmitFlags.SingleLine specified. // We must emit a function body as a multi-line body in the following cases: @@ -56873,14 +57586,14 @@ var ts; } return true; } - function emitBlockFunctionBody(parentNode, body) { + function emitBlockFunctionBody(body) { write(" {"); increaseIndent(); - emitBodyWithDetachedComments(body, body.statements, shouldEmitBlockFunctionBodyOnSingleLine(parentNode, body) + emitBodyWithDetachedComments(body, body.statements, shouldEmitBlockFunctionBodyOnSingleLine(body) ? emitBlockFunctionBodyOnSingleLine : emitBlockFunctionBodyWorker); decreaseIndent(); - writeToken(16 /* CloseBraceToken */, body.statements.end, body); + writeToken(17 /* CloseBraceToken */, body.statements.end, body); } function emitBlockFunctionBodyOnSingleLine(body) { emitBlockFunctionBodyWorker(body, /*emitBlockFunctionBodyOnSingleLine*/ true); @@ -56959,7 +57672,7 @@ var ts; write(node.flags & 16 /* Namespace */ ? "namespace " : "module "); emit(node.name); var body = node.body; - while (body.kind === 225 /* ModuleDeclaration */) { + while (body.kind === 226 /* ModuleDeclaration */) { write("."); emit(body.name); body = body.body; @@ -56982,9 +57695,9 @@ var ts; } } function emitCaseBlock(node) { - writeToken(15 /* OpenBraceToken */, node.pos); + writeToken(16 /* OpenBraceToken */, node.pos); emitList(node, node.clauses, 65 /* CaseBlockClauses */); - writeToken(16 /* CloseBraceToken */, node.clauses.end); + writeToken(17 /* CloseBraceToken */, node.clauses.end); } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); @@ -56995,7 +57708,7 @@ var ts; write(";"); } function emitModuleReference(node) { - if (node.kind === 69 /* Identifier */) { + if (node.kind === 70 /* Identifier */) { emitExpression(node); } else { @@ -57121,7 +57834,7 @@ var ts; } } function emitJsxTagName(node) { - if (node.kind === 69 /* Identifier */) { + if (node.kind === 70 /* Identifier */) { emitExpression(node); } else { @@ -57164,11 +57877,11 @@ var ts; } function emitCatchClause(node) { writeLine(); - var openParenPos = writeToken(72 /* CatchKeyword */, node.pos); + var openParenPos = writeToken(73 /* CatchKeyword */, node.pos); write(" "); - writeToken(17 /* OpenParenToken */, openParenPos); + writeToken(18 /* OpenParenToken */, openParenPos); emit(node.variableDeclaration); - writeToken(18 /* CloseParenToken */, node.variableDeclaration ? node.variableDeclaration.end : openParenPos); + writeToken(19 /* CloseParenToken */, node.variableDeclaration ? node.variableDeclaration.end : openParenPos); write(" "); emit(node.block); } @@ -57279,7 +57992,7 @@ var ts; var helpersEmitted = false; // Only Emit __extends function when target ES5. // For target ES6 and above, we can emit classDeclaration as is. - if ((languageVersion < 2 /* ES6 */) && (!extendsEmitted && node.flags & 1024 /* HasClassExtends */)) { + if ((languageVersion < 2 /* ES2015 */) && (!extendsEmitted && node.flags & 1024 /* HasClassExtends */)) { writeLines(extendsHelper); extendsEmitted = true; helpersEmitted = true; @@ -57301,9 +58014,12 @@ var ts; paramEmitted = true; helpersEmitted = true; } - if (!awaiterEmitted && node.flags & 8192 /* HasAsyncFunctions */) { + // Only emit __awaiter function when target ES5/ES6. + // Only emit __generator function when target ES5. + // For target ES2017 and above, we can emit async/await as is. + if ((languageVersion < 4 /* ES2017 */) && (!awaiterEmitted && node.flags & 8192 /* HasAsyncFunctions */)) { writeLines(awaiterHelper); - if (languageVersion < 2 /* ES6 */) { + if (languageVersion < 2 /* ES2015 */) { writeLines(generatorHelper); } awaiterEmitted = true; @@ -57630,7 +58346,7 @@ var ts; && !ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 178 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 179 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -57755,19 +58471,19 @@ var ts; */ function generateNameForNode(node) { switch (node.kind) { - case 69 /* Identifier */: + case 70 /* Identifier */: return makeUniqueName(getTextOfNode(node)); - case 225 /* ModuleDeclaration */: - case 224 /* EnumDeclaration */: + case 226 /* ModuleDeclaration */: + case 225 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 230 /* ImportDeclaration */: - case 236 /* ExportDeclaration */: + case 231 /* ImportDeclaration */: + case 237 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 220 /* FunctionDeclaration */: - case 221 /* ClassDeclaration */: - case 235 /* ExportAssignment */: + case 221 /* FunctionDeclaration */: + case 222 /* ClassDeclaration */: + case 236 /* ExportAssignment */: return generateNameForExportDefault(); - case 192 /* ClassExpression */: + case 193 /* ClassExpression */: return generateNameForClassExpression(); default: return makeTempVariableName(0 /* Auto */); @@ -58440,7 +59156,7 @@ var ts; getSourceFiles: program.getSourceFiles, isSourceFileFromExternalLibrary: function (file) { return !!sourceFilesFoundSearchingNodeModules[file.path]; }, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), - isEmitBlocked: isEmitBlocked + isEmitBlocked: isEmitBlocked, }; } function getDiagnosticsProducingTypeChecker() { @@ -58530,7 +59246,7 @@ var ts; return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile, cancellationToken); } } - function getSyntacticDiagnosticsForFile(sourceFile, cancellationToken) { + function getSyntacticDiagnosticsForFile(sourceFile) { return sourceFile.parseDiagnostics; } function runWithCancellationToken(func) { @@ -58563,14 +59279,14 @@ var ts; // Instead, we just report errors for using TypeScript-only constructs from within a // JavaScript file. var checkDiagnostics = ts.isSourceFileJavaScript(sourceFile) ? - getJavaScriptSemanticDiagnosticsForFile(sourceFile, cancellationToken) : + getJavaScriptSemanticDiagnosticsForFile(sourceFile) : typeChecker.getDiagnostics(sourceFile, cancellationToken); var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); - return bindDiagnostics.concat(checkDiagnostics).concat(fileProcessingDiagnosticsInFile).concat(programDiagnosticsInFile); + return bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); }); } - function getJavaScriptSemanticDiagnosticsForFile(sourceFile, cancellationToken) { + function getJavaScriptSemanticDiagnosticsForFile(sourceFile) { return runWithCancellationToken(function () { var diagnostics = []; walk(sourceFile); @@ -58580,16 +59296,16 @@ var ts; return false; } switch (node.kind) { - case 229 /* ImportEqualsDeclaration */: + case 230 /* ImportEqualsDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return true; - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return true; } break; - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: var classDeclaration = node; if (checkModifiers(classDeclaration.modifiers) || checkTypeParameters(classDeclaration.typeParameters)) { @@ -58598,29 +59314,29 @@ var ts; break; case 251 /* HeritageClause */: var heritageClause = node; - if (heritageClause.token === 106 /* ImplementsKeyword */) { + if (heritageClause.token === 107 /* ImplementsKeyword */) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return true; } break; - case 222 /* InterfaceDeclaration */: + case 223 /* InterfaceDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return true; - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return true; - case 223 /* TypeAliasDeclaration */: + case 224 /* TypeAliasDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return true; - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 179 /* FunctionExpression */: - case 220 /* FunctionDeclaration */: - case 180 /* ArrowFunction */: - case 220 /* FunctionDeclaration */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 180 /* FunctionExpression */: + case 221 /* FunctionDeclaration */: + case 181 /* ArrowFunction */: + case 221 /* FunctionDeclaration */: var functionDeclaration = node; if (checkModifiers(functionDeclaration.modifiers) || checkTypeParameters(functionDeclaration.typeParameters) || @@ -58628,20 +59344,20 @@ var ts; return true; } break; - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: var variableStatement = node; if (checkModifiers(variableStatement.modifiers)) { return true; } break; - case 218 /* VariableDeclaration */: + case 219 /* VariableDeclaration */: var variableDeclaration = node; if (checkTypeAnnotation(variableDeclaration.type)) { return true; } break; - case 174 /* CallExpression */: - case 175 /* NewExpression */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: var expression = node; if (expression.typeArguments && expression.typeArguments.length > 0) { var start = expression.typeArguments.pos; @@ -58649,7 +59365,7 @@ var ts; return true; } break; - case 142 /* Parameter */: + case 143 /* Parameter */: var parameter = node; if (parameter.modifiers) { var start = parameter.modifiers.pos; @@ -58665,12 +59381,12 @@ var ts; return true; } break; - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: var propertyDeclaration = node; if (propertyDeclaration.modifiers) { for (var _i = 0, _a = propertyDeclaration.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 113 /* StaticKeyword */) { + if (modifier.kind !== 114 /* StaticKeyword */) { diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); return true; } @@ -58680,14 +59396,14 @@ var ts; return true; } break; - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return true; - case 177 /* TypeAssertionExpression */: + case 178 /* 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 143 /* Decorator */: + case 144 /* Decorator */: if (!options.experimentalDecorators) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning)); } @@ -58715,19 +59431,19 @@ var ts; for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { var modifier = modifiers_1[_i]; switch (modifier.kind) { - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - case 128 /* ReadonlyKeyword */: - case 122 /* DeclareKeyword */: + case 113 /* PublicKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + case 129 /* ReadonlyKeyword */: + case 123 /* 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 113 /* StaticKeyword */: - case 82 /* ExportKeyword */: - case 74 /* ConstKeyword */: - case 77 /* DefaultKeyword */: - case 115 /* AbstractKeyword */: + case 114 /* StaticKeyword */: + case 83 /* ExportKeyword */: + case 75 /* ConstKeyword */: + case 78 /* DefaultKeyword */: + case 116 /* AbstractKeyword */: } } } @@ -58761,7 +59477,7 @@ var ts; return ts.getBaseFileName(fileName).indexOf(".") >= 0; } function processRootFile(fileName, isDefaultLib) { - processSourceFile(ts.normalizePath(fileName), isDefaultLib, /*isReference*/ true); + processSourceFile(ts.normalizePath(fileName), isDefaultLib); } function fileReferenceIsEqualTo(a, b) { return a.fileName === b.fileName; @@ -58802,9 +59518,9 @@ var ts; return; function collectModuleReferences(node, inAmbientModule) { switch (node.kind) { - case 230 /* ImportDeclaration */: - case 229 /* ImportEqualsDeclaration */: - case 236 /* ExportDeclaration */: + case 231 /* ImportDeclaration */: + case 230 /* ImportEqualsDeclaration */: + case 237 /* ExportDeclaration */: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9 /* StringLiteral */) { break; @@ -58819,7 +59535,7 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasModifier(node, 2 /* Ambient */) || ts.isDeclarationFile(file))) { var moduleName = node.name; // Ambient module declarations can be interpreted as augmentations for some existing external modules. @@ -58859,7 +59575,7 @@ var ts; /** * 'isReference' indicates whether the file was brought in via a reference directive (rather than an import declaration) */ - function processSourceFile(fileName, isDefaultLib, isReference, refFile, refPos, refEnd) { + function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { var diagnosticArgument; var diagnostic; if (hasExtension(fileName)) { @@ -58867,7 +59583,7 @@ var ts; diagnostic = ts.Diagnostics.File_0_has_unsupported_extension_The_only_supported_extensions_are_1; diagnosticArgument = [fileName, "'" + supportedExtensions.join("', '") + "'"]; } - else if (!findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, isReference, refFile, refPos, refEnd)) { + else if (!findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd)) { diagnostic = ts.Diagnostics.File_0_not_found; diagnosticArgument = [fileName]; } @@ -58877,13 +59593,13 @@ var ts; } } else { - var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, isReference, refFile, refPos, refEnd); + var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd); if (!nonTsFile) { if (options.allowNonTsExtensions) { diagnostic = ts.Diagnostics.File_0_not_found; diagnosticArgument = [fileName]; } - else if (!ts.forEach(supportedExtensions, function (extension) { return findSourceFile(fileName + extension, ts.toPath(fileName + extension, currentDirectory, getCanonicalFileName), isDefaultLib, isReference, refFile, refPos, refEnd); })) { + else if (!ts.forEach(supportedExtensions, function (extension) { return findSourceFile(fileName + extension, ts.toPath(fileName + extension, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd); })) { diagnostic = ts.Diagnostics.File_0_not_found; fileName += ".ts"; diagnosticArgument = [fileName]; @@ -58908,7 +59624,7 @@ var ts; } } // Get source file from normalized fileName - function findSourceFile(fileName, path, isDefaultLib, isReference, refFile, refPos, refEnd) { + function findSourceFile(fileName, path, isDefaultLib, refFile, refPos, refEnd) { if (filesByName.contains(path)) { var file_1 = filesByName.get(path); // try to check if we've already seen this file but with a different casing in path @@ -58921,16 +59637,16 @@ var ts; if (file_1 && sourceFilesFoundSearchingNodeModules[file_1.path] && currentNodeModulesDepth == 0) { sourceFilesFoundSearchingNodeModules[file_1.path] = false; if (!options.noResolve) { - processReferencedFiles(file_1, ts.getDirectoryPath(fileName), isDefaultLib); + processReferencedFiles(file_1, isDefaultLib); processTypeReferenceDirectives(file_1); } modulesWithElidedImports[file_1.path] = false; - processImportedModules(file_1, ts.getDirectoryPath(fileName)); + processImportedModules(file_1); } else if (file_1 && modulesWithElidedImports[file_1.path]) { if (currentNodeModulesDepth < maxNodeModulesJsDepth) { modulesWithElidedImports[file_1.path] = false; - processImportedModules(file_1, ts.getDirectoryPath(fileName)); + processImportedModules(file_1); } } return file_1; @@ -58959,13 +59675,12 @@ var ts; } } skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; - var basePath = ts.getDirectoryPath(fileName); if (!options.noResolve) { - processReferencedFiles(file, basePath, isDefaultLib); + processReferencedFiles(file, isDefaultLib); processTypeReferenceDirectives(file); } // always process imported modules to record module name resolutions - processImportedModules(file, basePath); + processImportedModules(file); if (isDefaultLib) { files.unshift(file); } @@ -58975,10 +59690,10 @@ var ts; } return file; } - function processReferencedFiles(file, basePath, isDefaultLib) { + function processReferencedFiles(file, isDefaultLib) { ts.forEach(file.referencedFiles, function (ref) { var referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName); - processSourceFile(referencedFileName, isDefaultLib, /*isReference*/ true, file, ref.pos, ref.end); + processSourceFile(referencedFileName, isDefaultLib, file, ref.pos, ref.end); }); } function processTypeReferenceDirectives(file) { @@ -59004,7 +59719,7 @@ var ts; if (resolvedTypeReferenceDirective) { if (resolvedTypeReferenceDirective.primary) { // resolved from the primary path - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*isReference*/ true, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, refFile, refPos, refEnd); } else { // If we already resolved to this file, it must have been a secondary reference. Check file contents @@ -59019,7 +59734,7 @@ var ts; } else { // First resolution of this library - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*isReference*/ true, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, refFile, refPos, refEnd); } } } @@ -59045,7 +59760,7 @@ var ts; function getCanonicalFileName(fileName) { return host.getCanonicalFileName(fileName); } - function processImportedModules(file, basePath) { + function processImportedModules(file) { collectExternalModuleReferences(file); if (file.imports.length || file.moduleAugmentations.length) { file.resolvedModules = ts.createMap(); @@ -59071,7 +59786,7 @@ var ts; } else if (shouldAddFile) { findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), - /*isDefaultLib*/ false, /*isReference*/ false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); + /*isDefaultLib*/ false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); } if (isFromNodeModulesSearch) { currentNodeModulesDepth--; @@ -59200,7 +59915,7 @@ var ts; var outFile = options.outFile || options.out; var firstNonAmbientExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) && !ts.isDeclarationFile(f) ? f : undefined; }); if (options.isolatedModules) { - if (options.module === ts.ModuleKind.None && languageVersion < 2 /* ES6 */) { + if (options.module === ts.ModuleKind.None && languageVersion < 2 /* ES2015 */) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher)); } var firstNonExternalModuleSourceFile = ts.forEach(files, function (f) { return !ts.isExternalModule(f) && !ts.isDeclarationFile(f) ? f : undefined; }); @@ -59209,7 +59924,7 @@ var ts; programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span_7.start, span_7.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided)); } } - else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 /* ES6 */ && options.module === ts.ModuleKind.None) { + else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 /* ES2015 */ && options.module === ts.ModuleKind.None) { // We cannot use createDiagnosticFromNode because nodes do not have parents yet var span_8 = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, firstNonAmbientExternalModuleSourceFile.externalModuleIndicator); programDiagnostics.add(ts.createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span_8.start, span_8.length, ts.Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none)); @@ -59250,7 +59965,7 @@ var ts; if (!options.noEmit && !options.suppressOutputPathCheck) { var emitHost = getEmitHost(); var emitFilesSeen_1 = ts.createFileMap(!host.useCaseSensitiveFileNames() ? function (key) { return key.toLocaleLowerCase(); } : undefined); - ts.forEachExpectedEmitFile(emitHost, function (emitFileNames, sourceFiles, isBundledEmit) { + ts.forEachExpectedEmitFile(emitHost, function (emitFileNames) { verifyEmitFilePath(emitFileNames.jsFilePath, emitFilesSeen_1); verifyEmitFilePath(emitFileNames.declarationFilePath, emitFilesSeen_1); }); @@ -59261,12 +59976,12 @@ var ts; var emitFilePath = ts.toPath(emitFileName, currentDirectory, getCanonicalFileName); // Report error if the output overwrites input file if (filesByName.contains(emitFilePath)) { - createEmitBlockingDiagnostics(emitFileName, emitFilePath, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file); + createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file); } // Report error if multiple files write into same file if (emitFilesSeen.contains(emitFilePath)) { // Already seen the same emit file - report error - createEmitBlockingDiagnostics(emitFileName, emitFilePath, ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files); + createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files); } else { emitFilesSeen.set(emitFilePath, true); @@ -59274,7 +59989,7 @@ var ts; } } } - function createEmitBlockingDiagnostics(emitFileName, emitFilePath, message) { + function createEmitBlockingDiagnostics(emitFileName, message) { hasEmitBlockingDiagnostics.set(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName), true); programDiagnostics.add(ts.createCompilerDiagnostic(message, emitFileName)); } @@ -59294,24 +60009,24 @@ var ts; ts.optionDeclarations = [ { name: "charset", - type: "string" + type: "string", }, ts.compileOnSaveCommandLineOption, { name: "declaration", shortName: "d", type: "boolean", - description: ts.Diagnostics.Generates_corresponding_d_ts_file + description: ts.Diagnostics.Generates_corresponding_d_ts_file, }, { name: "declarationDir", type: "string", isFilePath: true, - paramType: ts.Diagnostics.DIRECTORY + paramType: ts.Diagnostics.DIRECTORY, }, { name: "diagnostics", - type: "boolean" + type: "boolean", }, { name: "extendedDiagnostics", @@ -59326,7 +60041,7 @@ var ts; name: "help", shortName: "h", type: "boolean", - description: ts.Diagnostics.Print_this_message + description: ts.Diagnostics.Print_this_message, }, { name: "help", @@ -59336,15 +60051,15 @@ var ts; { name: "init", type: "boolean", - description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file + description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file, }, { name: "inlineSourceMap", - type: "boolean" + type: "boolean", }, { name: "inlineSources", - type: "boolean" + type: "boolean", }, { name: "jsx", @@ -59353,7 +60068,7 @@ var ts; "react": 2 /* React */ }), paramType: ts.Diagnostics.KIND, - description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react + description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, }, { name: "reactNamespace", @@ -59362,18 +60077,18 @@ var ts; }, { name: "listFiles", - type: "boolean" + type: "boolean", }, { name: "locale", - type: "string" + type: "string", }, { name: "mapRoot", type: "string", isFilePath: true, description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, - paramType: ts.Diagnostics.LOCATION + paramType: ts.Diagnostics.LOCATION, }, { name: "module", @@ -59384,11 +60099,11 @@ var ts; "amd": ts.ModuleKind.AMD, "system": ts.ModuleKind.System, "umd": ts.ModuleKind.UMD, - "es6": ts.ModuleKind.ES6, - "es2015": ts.ModuleKind.ES2015 + "es6": ts.ModuleKind.ES2015, + "es2015": ts.ModuleKind.ES2015, }), description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, - paramType: ts.Diagnostics.KIND + paramType: ts.Diagnostics.KIND, }, { name: "newLine", @@ -59397,12 +60112,12 @@ var ts; "lf": 1 /* LineFeed */ }), description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, - paramType: ts.Diagnostics.NEWLINE + paramType: ts.Diagnostics.NEWLINE, }, { name: "noEmit", type: "boolean", - description: ts.Diagnostics.Do_not_emit_outputs + description: ts.Diagnostics.Do_not_emit_outputs, }, { name: "noEmitHelpers", @@ -59411,7 +60126,7 @@ var ts; { name: "noEmitOnError", type: "boolean", - description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported + description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, }, { name: "noErrorTruncation", @@ -59420,60 +60135,60 @@ var ts; { name: "noImplicitAny", type: "boolean", - description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type + description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type, }, { name: "noImplicitThis", type: "boolean", - description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type + description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, }, { name: "noUnusedLocals", type: "boolean", - description: ts.Diagnostics.Report_errors_on_unused_locals + description: ts.Diagnostics.Report_errors_on_unused_locals, }, { name: "noUnusedParameters", type: "boolean", - description: ts.Diagnostics.Report_errors_on_unused_parameters + description: ts.Diagnostics.Report_errors_on_unused_parameters, }, { name: "noLib", - type: "boolean" + type: "boolean", }, { name: "noResolve", - type: "boolean" + type: "boolean", }, { name: "skipDefaultLibCheck", - type: "boolean" + type: "boolean", }, { name: "skipLibCheck", type: "boolean", - description: ts.Diagnostics.Skip_type_checking_of_declaration_files + description: ts.Diagnostics.Skip_type_checking_of_declaration_files, }, { name: "out", type: "string", isFilePath: false, // for correct behaviour, please use outFile - paramType: ts.Diagnostics.FILE + paramType: ts.Diagnostics.FILE, }, { name: "outFile", type: "string", isFilePath: true, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, - paramType: ts.Diagnostics.FILE + paramType: ts.Diagnostics.FILE, }, { name: "outDir", type: "string", isFilePath: true, description: ts.Diagnostics.Redirect_output_structure_to_the_directory, - paramType: ts.Diagnostics.DIRECTORY + paramType: ts.Diagnostics.DIRECTORY, }, { name: "preserveConstEnums", @@ -59496,30 +60211,30 @@ var ts; { name: "removeComments", type: "boolean", - description: ts.Diagnostics.Do_not_emit_comments_to_output + description: ts.Diagnostics.Do_not_emit_comments_to_output, }, { name: "rootDir", type: "string", isFilePath: true, paramType: ts.Diagnostics.LOCATION, - description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir + description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, }, { name: "isolatedModules", - type: "boolean" + type: "boolean", }, { name: "sourceMap", type: "boolean", - description: ts.Diagnostics.Generates_corresponding_map_file + description: ts.Diagnostics.Generates_corresponding_map_file, }, { name: "sourceRoot", type: "string", isFilePath: true, description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, - paramType: ts.Diagnostics.LOCATION + paramType: ts.Diagnostics.LOCATION, }, { name: "suppressExcessPropertyErrors", @@ -59530,7 +60245,7 @@ var ts; { name: "suppressImplicitAnyIndexErrors", type: "boolean", - description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures + description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, }, { name: "stripInternal", @@ -59544,23 +60259,25 @@ var ts; type: ts.createMap({ "es3": 0 /* ES3 */, "es5": 1 /* ES5 */, - "es6": 2 /* ES6 */, - "es2015": 2 /* ES2015 */ + "es6": 2 /* ES2015 */, + "es2015": 2 /* ES2015 */, + "es2016": 3 /* ES2016 */, + "es2017": 4 /* ES2017 */, }), description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015, - paramType: ts.Diagnostics.VERSION + paramType: ts.Diagnostics.VERSION, }, { name: "version", shortName: "v", type: "boolean", - description: ts.Diagnostics.Print_the_compiler_s_version + description: ts.Diagnostics.Print_the_compiler_s_version, }, { name: "watch", shortName: "w", type: "boolean", - description: ts.Diagnostics.Watch_input_files + description: ts.Diagnostics.Watch_input_files, }, { name: "experimentalDecorators", @@ -59577,10 +60294,10 @@ var ts; name: "moduleResolution", type: ts.createMap({ "node": ts.ModuleResolutionKind.NodeJs, - "classic": ts.ModuleResolutionKind.Classic + "classic": ts.ModuleResolutionKind.Classic, }), description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, - paramType: ts.Diagnostics.STRATEGY + paramType: ts.Diagnostics.STRATEGY, }, { name: "allowUnusedLabels", @@ -59710,7 +60427,7 @@ var ts; "es2016.array.include": "lib.es2016.array.include.d.ts", "es2017.object": "lib.es2017.object.d.ts", "es2017.sharedmemory": "lib.es2017.sharedmemory.d.ts" - }) + }), }, description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon }, @@ -59738,7 +60455,7 @@ var ts; ts.typingOptionDeclarations = [ { name: "enableAutoDiscovery", - type: "boolean" + type: "boolean", }, { name: "include", @@ -59762,7 +60479,7 @@ var ts; module: ts.ModuleKind.CommonJS, target: 1 /* ES5 */, noImplicitAny: false, - sourceMap: false + sourceMap: false, }; var optionNameMapCache; /* @internal */ @@ -59784,10 +60501,7 @@ var ts; ts.getOptionNameMap = getOptionNameMap; /* @internal */ function createCompilerDiagnosticForInvalidCustomType(opt) { - var namesOfType = []; - for (var key in opt.type) { - namesOfType.push(" '" + key + "'"); - } + var namesOfType = Object.keys(opt.type).map(function (key) { return "'" + key + "'"; }).join(", "); return ts.createCompilerDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); } ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; @@ -60592,7 +61306,7 @@ var ts; StringScriptSnapshot.prototype.getLength = function () { return this.text.length; }; - StringScriptSnapshot.prototype.getChangeRange = function (oldSnapshot) { + StringScriptSnapshot.prototype.getChangeRange = function () { // Text-based snapshots do not support incremental parsing. Return undefined // to signal that to the caller. return undefined; @@ -60814,7 +61528,7 @@ var ts; /* @internal */ var ts; (function (ts) { - ts.scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ true); + ts.scanner = ts.createScanner(4 /* Latest */, /*skipTrivia*/ true); ts.emptyArray = []; (function (SemanticMeaning) { SemanticMeaning[SemanticMeaning["None"] = 0] = "None"; @@ -60826,33 +61540,33 @@ var ts; var SemanticMeaning = ts.SemanticMeaning; function getMeaningFromDeclaration(node) { switch (node.kind) { - case 142 /* Parameter */: - case 218 /* VariableDeclaration */: - case 169 /* BindingElement */: - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 143 /* Parameter */: + case 219 /* VariableDeclaration */: + case 170 /* BindingElement */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: case 253 /* PropertyAssignment */: case 254 /* ShorthandPropertyAssignment */: case 255 /* EnumMember */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: case 252 /* CatchClause */: return 1 /* Value */; - case 141 /* TypeParameter */: - case 222 /* InterfaceDeclaration */: - case 223 /* TypeAliasDeclaration */: - case 159 /* TypeLiteral */: + case 142 /* TypeParameter */: + case 223 /* InterfaceDeclaration */: + case 224 /* TypeAliasDeclaration */: + case 160 /* TypeLiteral */: return 2 /* Type */; - case 221 /* ClassDeclaration */: - case 224 /* EnumDeclaration */: + case 222 /* ClassDeclaration */: + case 225 /* EnumDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -60862,12 +61576,12 @@ var ts; else { return 4 /* Namespace */; } - case 233 /* NamedImports */: - case 234 /* ImportSpecifier */: - case 229 /* ImportEqualsDeclaration */: - case 230 /* ImportDeclaration */: - case 235 /* ExportAssignment */: - case 236 /* ExportDeclaration */: + case 234 /* NamedImports */: + case 235 /* ImportSpecifier */: + case 230 /* ImportEqualsDeclaration */: + case 231 /* ImportDeclaration */: + case 236 /* ExportAssignment */: + case 237 /* ExportDeclaration */: return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; // An external module can be a Value case 256 /* SourceFile */: @@ -60877,7 +61591,7 @@ var ts; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.parent.kind === 235 /* ExportAssignment */) { + if (node.parent.kind === 236 /* ExportAssignment */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } else if (isInRightSideOfImport(node)) { @@ -60898,19 +61612,19 @@ var ts; } ts.getMeaningFromLocation = getMeaningFromLocation; function getMeaningFromRightHandSideOfImportEquals(node) { - ts.Debug.assert(node.kind === 69 /* Identifier */); + ts.Debug.assert(node.kind === 70 /* Identifier */); // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (node.parent.kind === 139 /* QualifiedName */ && + if (node.parent.kind === 140 /* QualifiedName */ && node.parent.right === node && - node.parent.parent.kind === 229 /* ImportEqualsDeclaration */) { + node.parent.parent.kind === 230 /* ImportEqualsDeclaration */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } return 4 /* Namespace */; } function isInRightSideOfImport(node) { - while (node.parent.kind === 139 /* QualifiedName */) { + while (node.parent.kind === 140 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -60921,27 +61635,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 139 /* QualifiedName */) { - while (root.parent && root.parent.kind === 139 /* QualifiedName */) { + if (root.parent.kind === 140 /* QualifiedName */) { + while (root.parent && root.parent.kind === 140 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 155 /* TypeReference */ && !isLastClause; + return root.parent.kind === 156 /* TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 172 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 172 /* PropertyAccessExpression */) { + if (root.parent.kind === 173 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 173 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 194 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 251 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 195 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 251 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 221 /* ClassDeclaration */ && root.parent.parent.token === 106 /* ImplementsKeyword */) || - (decl.kind === 222 /* InterfaceDeclaration */ && root.parent.parent.token === 83 /* ExtendsKeyword */); + return (decl.kind === 222 /* ClassDeclaration */ && root.parent.parent.token === 107 /* ImplementsKeyword */) || + (decl.kind === 223 /* InterfaceDeclaration */ && root.parent.parent.token === 84 /* ExtendsKeyword */); } return false; } @@ -60949,17 +61663,17 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 155 /* TypeReference */ || - (node.parent.kind === 194 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || - (node.kind === 97 /* ThisKeyword */ && !ts.isPartOfExpression(node)) || - node.kind === 165 /* ThisType */; + return node.parent.kind === 156 /* TypeReference */ || + (node.parent.kind === 195 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || + (node.kind === 98 /* ThisKeyword */ && !ts.isPartOfExpression(node)) || + node.kind === 166 /* ThisType */; } function isCallExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 174 /* CallExpression */); + return isCallOrNewExpressionTarget(node, 175 /* CallExpression */); } ts.isCallExpressionTarget = isCallExpressionTarget; function isNewExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 175 /* NewExpression */); + return isCallOrNewExpressionTarget(node, 176 /* NewExpression */); } ts.isNewExpressionTarget = isNewExpressionTarget; function isCallOrNewExpressionTarget(node, kind) { @@ -60972,7 +61686,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 214 /* LabeledStatement */ && referenceNode.label.text === labelName) { + if (referenceNode.kind === 215 /* LabeledStatement */ && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -60981,14 +61695,14 @@ var ts; } ts.getTargetLabel = getTargetLabel; function isJumpStatementTarget(node) { - return node.kind === 69 /* Identifier */ && - (node.parent.kind === 210 /* BreakStatement */ || node.parent.kind === 209 /* ContinueStatement */) && + return node.kind === 70 /* Identifier */ && + (node.parent.kind === 211 /* BreakStatement */ || node.parent.kind === 210 /* ContinueStatement */) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { - return node.kind === 69 /* Identifier */ && - node.parent.kind === 214 /* LabeledStatement */ && + return node.kind === 70 /* Identifier */ && + node.parent.kind === 215 /* LabeledStatement */ && node.parent.label === node; } function isLabelName(node) { @@ -60996,38 +61710,38 @@ var ts; } ts.isLabelName = isLabelName; function isRightSideOfQualifiedName(node) { - return node.parent.kind === 139 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 140 /* QualifiedName */ && node.parent.right === node; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 172 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 173 /* PropertyAccessExpression */ && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 225 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 226 /* ModuleDeclaration */ && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { - return node.kind === 69 /* Identifier */ && + return node.kind === 70 /* Identifier */ && ts.isFunctionLike(node.parent) && node.parent.name === node; } ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { switch (node.parent.kind) { - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: case 253 /* PropertyAssignment */: case 255 /* EnumMember */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 225 /* ModuleDeclaration */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 226 /* ModuleDeclaration */: return node.parent.name === node; - case 173 /* ElementAccessExpression */: + case 174 /* ElementAccessExpression */: return node.parent.argumentExpression === node; - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: return true; } } @@ -61077,16 +61791,16 @@ var ts; } switch (node.kind) { case 256 /* SourceFile */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 221 /* ClassDeclaration */: - case 222 /* InterfaceDeclaration */: - case 224 /* EnumDeclaration */: - case 225 /* ModuleDeclaration */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 222 /* ClassDeclaration */: + case 223 /* InterfaceDeclaration */: + case 225 /* EnumDeclaration */: + case 226 /* ModuleDeclaration */: return node; } } @@ -61096,42 +61810,42 @@ var ts; switch (node.kind) { case 256 /* SourceFile */: return ts.isExternalModule(node) ? ts.ScriptElementKind.moduleElement : ts.ScriptElementKind.scriptElement; - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: return ts.ScriptElementKind.moduleElement; - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: return ts.ScriptElementKind.classElement; - case 222 /* InterfaceDeclaration */: return ts.ScriptElementKind.interfaceElement; - case 223 /* TypeAliasDeclaration */: return ts.ScriptElementKind.typeElement; - case 224 /* EnumDeclaration */: return ts.ScriptElementKind.enumElement; - case 218 /* VariableDeclaration */: + case 223 /* InterfaceDeclaration */: return ts.ScriptElementKind.interfaceElement; + case 224 /* TypeAliasDeclaration */: return ts.ScriptElementKind.typeElement; + case 225 /* EnumDeclaration */: return ts.ScriptElementKind.enumElement; + case 219 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 169 /* BindingElement */: + case 170 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 180 /* ArrowFunction */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: return ts.ScriptElementKind.functionElement; - case 149 /* GetAccessor */: return ts.ScriptElementKind.memberGetAccessorElement; - case 150 /* SetAccessor */: return ts.ScriptElementKind.memberSetAccessorElement; - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 150 /* GetAccessor */: return ts.ScriptElementKind.memberGetAccessorElement; + case 151 /* SetAccessor */: return ts.ScriptElementKind.memberSetAccessorElement; + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: return ts.ScriptElementKind.memberFunctionElement; - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: return ts.ScriptElementKind.memberVariableElement; - case 153 /* IndexSignature */: return ts.ScriptElementKind.indexSignatureElement; - case 152 /* ConstructSignature */: return ts.ScriptElementKind.constructSignatureElement; - case 151 /* CallSignature */: return ts.ScriptElementKind.callSignatureElement; - case 148 /* Constructor */: return ts.ScriptElementKind.constructorImplementationElement; - case 141 /* TypeParameter */: return ts.ScriptElementKind.typeParameterElement; + case 154 /* IndexSignature */: return ts.ScriptElementKind.indexSignatureElement; + case 153 /* ConstructSignature */: return ts.ScriptElementKind.constructSignatureElement; + case 152 /* CallSignature */: return ts.ScriptElementKind.callSignatureElement; + case 149 /* Constructor */: return ts.ScriptElementKind.constructorImplementationElement; + case 142 /* TypeParameter */: return ts.ScriptElementKind.typeParameterElement; case 255 /* EnumMember */: return ts.ScriptElementKind.enumMemberElement; - case 142 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; - case 229 /* ImportEqualsDeclaration */: - case 234 /* ImportSpecifier */: - case 231 /* ImportClause */: - case 238 /* ExportSpecifier */: - case 232 /* NamespaceImport */: + case 143 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; + case 230 /* ImportEqualsDeclaration */: + case 235 /* ImportSpecifier */: + case 232 /* ImportClause */: + case 239 /* ExportSpecifier */: + case 233 /* NamespaceImport */: return ts.ScriptElementKind.alias; case 279 /* JSDocTypedefTag */: return ts.ScriptElementKind.typeElement; @@ -61148,7 +61862,7 @@ var ts; } ts.getNodeKind = getNodeKind; function getStringLiteralTypeForNode(node, typeChecker) { - var searchNode = node.parent.kind === 166 /* LiteralType */ ? node.parent : node; + var searchNode = node.parent.kind === 167 /* LiteralType */ ? node.parent : node; var type = typeChecker.getTypeAtLocation(searchNode); if (type && type.flags & 32 /* StringLiteral */) { return type; @@ -61158,12 +61872,12 @@ var ts; ts.getStringLiteralTypeForNode = getStringLiteralTypeForNode; function isThis(node) { switch (node.kind) { - case 97 /* ThisKeyword */: + case 98 /* ThisKeyword */: // case SyntaxKind.ThisType: TODO: GH#9267 return true; - case 69 /* Identifier */: + case 70 /* Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 142 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 143 /* Parameter */; default: return false; } @@ -61208,42 +61922,42 @@ var ts; return false; } switch (n.kind) { - case 221 /* ClassDeclaration */: - case 222 /* InterfaceDeclaration */: - case 224 /* EnumDeclaration */: - case 171 /* ObjectLiteralExpression */: - case 167 /* ObjectBindingPattern */: - case 159 /* TypeLiteral */: - case 199 /* Block */: - case 226 /* ModuleBlock */: - case 227 /* CaseBlock */: - case 233 /* NamedImports */: - case 237 /* NamedExports */: - return nodeEndsWith(n, 16 /* CloseBraceToken */, sourceFile); + case 222 /* ClassDeclaration */: + case 223 /* InterfaceDeclaration */: + case 225 /* EnumDeclaration */: + case 172 /* ObjectLiteralExpression */: + case 168 /* ObjectBindingPattern */: + case 160 /* TypeLiteral */: + case 200 /* Block */: + case 227 /* ModuleBlock */: + case 228 /* CaseBlock */: + case 234 /* NamedImports */: + case 238 /* NamedExports */: + return nodeEndsWith(n, 17 /* CloseBraceToken */, sourceFile); case 252 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 175 /* NewExpression */: + case 176 /* NewExpression */: if (!n.arguments) { return true; } // fall through - case 174 /* CallExpression */: - case 178 /* ParenthesizedExpression */: - case 164 /* ParenthesizedType */: - return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile); - case 156 /* FunctionType */: - case 157 /* ConstructorType */: + case 175 /* CallExpression */: + case 179 /* ParenthesizedExpression */: + case 165 /* ParenthesizedType */: + return nodeEndsWith(n, 19 /* CloseParenToken */, sourceFile); + case 157 /* FunctionType */: + case 158 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 152 /* ConstructSignature */: - case 151 /* CallSignature */: - case 180 /* ArrowFunction */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 153 /* ConstructSignature */: + case 152 /* CallSignature */: + case 181 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -61252,68 +61966,68 @@ 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 225 /* ModuleDeclaration */: + return hasChildOfKind(n, 19 /* CloseParenToken */, sourceFile); + case 226 /* ModuleDeclaration */: return n.body && isCompletedNode(n.body, sourceFile); - case 203 /* IfStatement */: + case 204 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 202 /* ExpressionStatement */: + case 203 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || - hasChildOfKind(n, 23 /* SemicolonToken */); - case 170 /* ArrayLiteralExpression */: - case 168 /* ArrayBindingPattern */: - case 173 /* ElementAccessExpression */: - case 140 /* ComputedPropertyName */: - case 161 /* TupleType */: - return nodeEndsWith(n, 20 /* CloseBracketToken */, sourceFile); - case 153 /* IndexSignature */: + hasChildOfKind(n, 24 /* SemicolonToken */); + case 171 /* ArrayLiteralExpression */: + case 169 /* ArrayBindingPattern */: + case 174 /* ElementAccessExpression */: + case 141 /* ComputedPropertyName */: + case 162 /* TupleType */: + return nodeEndsWith(n, 21 /* CloseBracketToken */, sourceFile); + case 154 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } - return hasChildOfKind(n, 20 /* CloseBracketToken */, sourceFile); + return hasChildOfKind(n, 21 /* CloseBracketToken */, sourceFile); case 249 /* CaseClause */: case 250 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: - case 205 /* WhileStatement */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: + case 206 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 204 /* DoStatement */: + case 205 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; - var hasWhileKeyword = findChildOfKind(n, 104 /* WhileKeyword */, sourceFile); + var hasWhileKeyword = findChildOfKind(n, 105 /* WhileKeyword */, sourceFile); if (hasWhileKeyword) { - return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile); + return nodeEndsWith(n, 19 /* CloseParenToken */, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 158 /* TypeQuery */: + case 159 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 182 /* TypeOfExpression */: - case 181 /* DeleteExpression */: - case 183 /* VoidExpression */: - case 190 /* YieldExpression */: - case 191 /* SpreadElementExpression */: + case 183 /* TypeOfExpression */: + case 182 /* DeleteExpression */: + case 184 /* VoidExpression */: + case 191 /* YieldExpression */: + case 192 /* SpreadElementExpression */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 176 /* TaggedTemplateExpression */: + case 177 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 189 /* TemplateExpression */: + case 190 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 197 /* TemplateSpan */: + case 198 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 236 /* ExportDeclaration */: - case 230 /* ImportDeclaration */: + case 237 /* ExportDeclaration */: + case 231 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 185 /* PrefixUnaryExpression */: + case 186 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -61331,7 +62045,7 @@ var ts; if (last.kind === expectedLastToken) { return true; } - else if (last.kind === 23 /* SemicolonToken */ && children.length !== 1) { + else if (last.kind === 24 /* SemicolonToken */ && children.length !== 1) { return children[children.length - 2].kind === expectedLastToken; } } @@ -61504,7 +62218,7 @@ var ts; function findPrecedingToken(position, sourceFile, startNode) { return find(startNode || sourceFile); function findRightmostToken(n) { - if (isToken(n) || n.kind === 244 /* JsxText */) { + if (isToken(n)) { return n; } var children = n.getChildren(); @@ -61512,7 +62226,7 @@ var ts; return candidate && findRightmostToken(candidate); } function find(n) { - if (isToken(n) || n.kind === 244 /* JsxText */) { + if (isToken(n)) { return n; } var children = n.getChildren(); @@ -61526,10 +62240,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 === 244 /* JsxText */)) { + if (position < child.end && (nodeHasTokens(child) || child.kind === 10 /* JsxText */)) { var start = child.getStart(sourceFile); var lookInPreviousChild = (start >= position) || - (child.kind === 244 /* JsxText */ && start === child.end); // whitespace only JsxText + (child.kind === 10 /* 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); @@ -61592,25 +62306,25 @@ var ts; if (!token) { return false; } - if (token.kind === 244 /* JsxText */) { + if (token.kind === 10 /* JsxText */) { return true; } //
Hello |
- if (token.kind === 25 /* LessThanToken */ && token.parent.kind === 244 /* JsxText */) { + if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 10 /* JsxText */) { return true; } //
{ |
or
- if (token.kind === 25 /* LessThanToken */ && token.parent.kind === 248 /* JsxExpression */) { + if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 248 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 16 /* CloseBraceToken */ && token.parent.kind === 248 /* JsxExpression */) { + if (token && token.kind === 17 /* CloseBraceToken */ && token.parent.kind === 248 /* JsxExpression */) { return true; } //
|
- if (token.kind === 25 /* LessThanToken */ && token.parent.kind === 245 /* JsxClosingElement */) { + if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 245 /* JsxClosingElement */) { return true; } return false; @@ -61667,9 +62381,9 @@ var ts; var node = ts.getTokenAtPosition(sourceFile, position); if (isToken(node)) { switch (node.kind) { - case 102 /* VarKeyword */: - case 108 /* LetKeyword */: - case 74 /* ConstKeyword */: + case 103 /* VarKeyword */: + case 109 /* LetKeyword */: + case 75 /* ConstKeyword */: // if the current token is var, let or const, skip the VariableDeclarationList node = node.parent === undefined ? undefined : node.parent.parent; break; @@ -61722,21 +62436,21 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 155 /* TypeReference */ || node.kind === 174 /* CallExpression */) { + if (node.kind === 156 /* TypeReference */ || node.kind === 175 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 221 /* ClassDeclaration */ || node.kind === 222 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 222 /* ClassDeclaration */ || node.kind === 223 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 138 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 139 /* LastToken */; } ts.isToken = isToken; function isWord(kind) { - return kind === 69 /* Identifier */ || ts.isKeyword(kind); + return kind === 70 /* Identifier */ || ts.isKeyword(kind); } ts.isWord = isWord; function isPropertyName(kind) { @@ -61748,7 +62462,7 @@ var ts; ts.isComment = isComment; function isStringOrRegularExpressionOrTemplateLiteral(kind) { if (kind === 9 /* StringLiteral */ - || kind === 10 /* RegularExpressionLiteral */ + || kind === 11 /* RegularExpressionLiteral */ || ts.isTemplateLiteralKind(kind)) { return true; } @@ -61756,7 +62470,7 @@ var ts; } ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; function isPunctuation(kind) { - return 15 /* FirstPunctuation */ <= kind && kind <= 68 /* LastPunctuation */; + return 16 /* FirstPunctuation */ <= kind && kind <= 69 /* LastPunctuation */; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position) { @@ -61766,9 +62480,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: + case 113 /* PublicKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: return true; } return false; @@ -61791,18 +62505,18 @@ var ts; } ts.compareDataObjects = compareDataObjects; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 170 /* ArrayLiteralExpression */ || - node.kind === 171 /* ObjectLiteralExpression */) { + if (node.kind === 171 /* ArrayLiteralExpression */ || + node.kind === 172 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 187 /* BinaryExpression */ && + if (node.parent.kind === 188 /* BinaryExpression */ && node.parent.left === node && - node.parent.operatorToken.kind === 56 /* EqualsToken */) { + node.parent.operatorToken.kind === 57 /* EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 208 /* ForOfStatement */ && + if (node.parent.kind === 209 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -61843,7 +62557,7 @@ var ts; /* @internal */ (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 142 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 143 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -61896,7 +62610,7 @@ var ts; } } function symbolPart(text, symbol) { - return displayPart(text, displayPartKind(symbol), symbol); + return displayPart(text, displayPartKind(symbol)); function displayPartKind(symbol) { var flags = symbol.flags; if (flags & 3 /* Variable */) { @@ -61945,7 +62659,7 @@ var ts; } } ts.symbolPart = symbolPart; - function displayPart(text, kind, symbol) { + function displayPart(text, kind) { return { text: text, kind: ts.SymbolDisplayPartKind[kind] @@ -62023,7 +62737,7 @@ var ts; return location.getText(); } else if (ts.isStringOrNumericLiteral(location.kind) && - location.parent.kind === 140 /* ComputedPropertyName */) { + location.parent.kind === 141 /* ComputedPropertyName */) { return location.text; } // Try to get the local symbol if we're dealing with an 'export default' @@ -62035,7 +62749,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 234 /* ImportSpecifier */ || location.parent.kind === 238 /* ExportSpecifier */) && + (location.parent.kind === 235 /* ImportSpecifier */ || location.parent.kind === 239 /* ExportSpecifier */) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -62081,7 +62795,7 @@ var ts; var options = { fileName: "config.js", compilerOptions: { - target: 2 /* ES6 */, + target: 2 /* ES2015 */, removeComments: true }, reportDiagnostics: true @@ -62107,24 +62821,24 @@ var ts; (function (ts) { /// Classifier function createClassifier() { - var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false); + var scanner = ts.createScanner(4 /* Latest */, /*skipTrivia*/ false); /// We do not have a full parser support to know when we should parse a regex or not /// If we consider every slash token to be a regex, we could be missing cases like "1/2/3", where /// 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[69 /* Identifier */] = true; + noRegexTable[70 /* Identifier */] = true; noRegexTable[9 /* StringLiteral */] = true; noRegexTable[8 /* NumericLiteral */] = true; - noRegexTable[10 /* RegularExpressionLiteral */] = 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[99 /* TrueKeyword */] = true; - noRegexTable[84 /* FalseKeyword */] = true; + noRegexTable[11 /* RegularExpressionLiteral */] = true; + noRegexTable[98 /* ThisKeyword */] = true; + noRegexTable[42 /* PlusPlusToken */] = true; + noRegexTable[43 /* MinusMinusToken */] = true; + noRegexTable[19 /* CloseParenToken */] = true; + noRegexTable[21 /* CloseBracketToken */] = true; + noRegexTable[17 /* CloseBraceToken */] = true; + noRegexTable[100 /* TrueKeyword */] = true; + noRegexTable[85 /* 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 @@ -62149,10 +62863,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 === 123 /* GetKeyword */ || - keyword2 === 131 /* SetKeyword */ || - keyword2 === 121 /* ConstructorKeyword */ || - keyword2 === 113 /* StaticKeyword */) { + if (keyword2 === 124 /* GetKeyword */ || + keyword2 === 132 /* SetKeyword */ || + keyword2 === 122 /* ConstructorKeyword */ || + keyword2 === 114 /* StaticKeyword */) { // Allow things like "public get", "public constructor" and "public static". // These are all legal. return true; @@ -62251,7 +62965,7 @@ var ts; offset = 2; // fallthrough case 6 /* InTemplateSubstitutionPosition */: - templateStack.push(12 /* TemplateHead */); + templateStack.push(13 /* TemplateHead */); break; } scanner.setText(text); @@ -62282,71 +62996,71 @@ var ts; do { token = scanner.scan(); if (!ts.isTrivia(token)) { - if ((token === 39 /* SlashToken */ || token === 61 /* SlashEqualsToken */) && !noRegexTable[lastNonTriviaToken]) { - if (scanner.reScanSlashToken() === 10 /* RegularExpressionLiteral */) { - token = 10 /* RegularExpressionLiteral */; + if ((token === 40 /* SlashToken */ || token === 62 /* SlashEqualsToken */) && !noRegexTable[lastNonTriviaToken]) { + if (scanner.reScanSlashToken() === 11 /* RegularExpressionLiteral */) { + token = 11 /* RegularExpressionLiteral */; } } - else if (lastNonTriviaToken === 21 /* DotToken */ && isKeyword(token)) { - token = 69 /* Identifier */; + else if (lastNonTriviaToken === 22 /* DotToken */ && isKeyword(token)) { + token = 70 /* 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 = 69 /* Identifier */; + token = 70 /* Identifier */; } - else if (lastNonTriviaToken === 69 /* Identifier */ && - token === 25 /* LessThanToken */) { + else if (lastNonTriviaToken === 70 /* Identifier */ && + token === 26 /* 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. angleBracketStack++; } - else if (token === 27 /* GreaterThanToken */ && angleBracketStack > 0) { + else if (token === 28 /* GreaterThanToken */ && angleBracketStack > 0) { // If we think we're currently in something generic, then mark that that // generic entity is complete. angleBracketStack--; } - else if (token === 117 /* AnyKeyword */ || - token === 132 /* StringKeyword */ || - token === 130 /* NumberKeyword */ || - token === 120 /* BooleanKeyword */ || - token === 133 /* SymbolKeyword */) { + else if (token === 118 /* AnyKeyword */ || + token === 133 /* StringKeyword */ || + token === 131 /* NumberKeyword */ || + token === 121 /* BooleanKeyword */ || + token === 134 /* 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 = 69 /* Identifier */; + token = 70 /* Identifier */; } } - else if (token === 12 /* TemplateHead */) { + else if (token === 13 /* TemplateHead */) { templateStack.push(token); } - else if (token === 15 /* OpenBraceToken */) { + else if (token === 16 /* OpenBraceToken */) { // If we don't have anything on the template stack, // then we aren't trying to keep track of a previously scanned template head. if (templateStack.length > 0) { templateStack.push(token); } } - else if (token === 16 /* CloseBraceToken */) { + else if (token === 17 /* CloseBraceToken */) { // If we don't have anything on the template stack, // then we aren't trying to keep track of a previously scanned template head. if (templateStack.length > 0) { var lastTemplateStackToken = ts.lastOrUndefined(templateStack); - if (lastTemplateStackToken === 12 /* TemplateHead */) { + if (lastTemplateStackToken === 13 /* TemplateHead */) { token = scanner.reScanTemplateToken(); // Only pop on a TemplateTail; a TemplateMiddle indicates there is more for us. - if (token === 14 /* TemplateTail */) { + if (token === 15 /* TemplateTail */) { templateStack.pop(); } else { - ts.Debug.assert(token === 13 /* TemplateMiddle */, "Should have been a template middle. Was " + token); + ts.Debug.assert(token === 14 /* TemplateMiddle */, "Should have been a template middle. Was " + token); } } else { - ts.Debug.assert(lastTemplateStackToken === 15 /* OpenBraceToken */, "Should have been an open brace. Was: " + token); + ts.Debug.assert(lastTemplateStackToken === 16 /* OpenBraceToken */, "Should have been an open brace. Was: " + token); templateStack.pop(); } } @@ -62387,10 +63101,10 @@ var ts; } else if (ts.isTemplateLiteralKind(token)) { if (scanner.isUnterminated()) { - if (token === 14 /* TemplateTail */) { + if (token === 15 /* TemplateTail */) { result.endOfLineState = 5 /* InTemplateMiddleOrTail */; } - else if (token === 11 /* NoSubstitutionTemplateLiteral */) { + else if (token === 12 /* NoSubstitutionTemplateLiteral */) { result.endOfLineState = 4 /* InTemplateHeadOrNoSubstitutionTemplate */; } else { @@ -62398,7 +63112,7 @@ var ts; } } } - else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 12 /* TemplateHead */) { + else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 13 /* TemplateHead */) { result.endOfLineState = 6 /* InTemplateSubstitutionPosition */; } } @@ -62428,43 +63142,43 @@ var ts; } function isBinaryExpressionOperatorToken(token) { switch (token) { - case 37 /* AsteriskToken */: - case 39 /* SlashToken */: - case 40 /* PercentToken */: - case 35 /* PlusToken */: - case 36 /* MinusToken */: - case 43 /* LessThanLessThanToken */: - case 44 /* GreaterThanGreaterThanToken */: - case 45 /* GreaterThanGreaterThanGreaterThanToken */: - case 25 /* LessThanToken */: - case 27 /* GreaterThanToken */: - case 28 /* LessThanEqualsToken */: - case 29 /* GreaterThanEqualsToken */: - case 91 /* InstanceOfKeyword */: - case 90 /* InKeyword */: - case 116 /* AsKeyword */: - case 30 /* EqualsEqualsToken */: - case 31 /* ExclamationEqualsToken */: - case 32 /* EqualsEqualsEqualsToken */: - case 33 /* ExclamationEqualsEqualsToken */: - 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 */: + case 38 /* AsteriskToken */: + case 40 /* SlashToken */: + case 41 /* PercentToken */: + case 36 /* PlusToken */: + case 37 /* MinusToken */: + case 44 /* LessThanLessThanToken */: + case 45 /* GreaterThanGreaterThanToken */: + case 46 /* GreaterThanGreaterThanGreaterThanToken */: + case 26 /* LessThanToken */: + case 28 /* GreaterThanToken */: + case 29 /* LessThanEqualsToken */: + case 30 /* GreaterThanEqualsToken */: + case 92 /* InstanceOfKeyword */: + case 91 /* InKeyword */: + case 117 /* AsKeyword */: + case 31 /* EqualsEqualsToken */: + case 32 /* ExclamationEqualsToken */: + case 33 /* EqualsEqualsEqualsToken */: + case 34 /* ExclamationEqualsEqualsToken */: + case 47 /* AmpersandToken */: + case 49 /* CaretToken */: + case 48 /* BarToken */: + case 52 /* AmpersandAmpersandToken */: + case 53 /* BarBarToken */: + case 68 /* BarEqualsToken */: + case 67 /* AmpersandEqualsToken */: + case 69 /* CaretEqualsToken */: + case 64 /* LessThanLessThanEqualsToken */: + case 65 /* GreaterThanGreaterThanEqualsToken */: + case 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 58 /* PlusEqualsToken */: + case 59 /* MinusEqualsToken */: + case 60 /* AsteriskEqualsToken */: + case 62 /* SlashEqualsToken */: + case 63 /* PercentEqualsToken */: + case 57 /* EqualsToken */: + case 25 /* CommaToken */: return true; default: return false; @@ -62472,19 +63186,19 @@ var ts; } function isPrefixUnaryExpressionOperatorToken(token) { switch (token) { - case 35 /* PlusToken */: - case 36 /* MinusToken */: - case 50 /* TildeToken */: - case 49 /* ExclamationToken */: - case 41 /* PlusPlusToken */: - case 42 /* MinusMinusToken */: + case 36 /* PlusToken */: + case 37 /* MinusToken */: + case 51 /* TildeToken */: + case 50 /* ExclamationToken */: + case 42 /* PlusPlusToken */: + case 43 /* MinusMinusToken */: return true; default: return false; } } function isKeyword(token) { - return token >= 70 /* FirstKeyword */ && token <= 138 /* LastKeyword */; + return token >= 71 /* FirstKeyword */ && token <= 139 /* LastKeyword */; } function classFromKind(token) { if (isKeyword(token)) { @@ -62493,7 +63207,7 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5 /* operator */; } - else if (token >= 15 /* FirstPunctuation */ && token <= 68 /* LastPunctuation */) { + else if (token >= 16 /* FirstPunctuation */ && token <= 69 /* LastPunctuation */) { return 10 /* punctuation */; } switch (token) { @@ -62501,7 +63215,7 @@ var ts; return 4 /* numericLiteral */; case 9 /* StringLiteral */: return 6 /* stringLiteral */; - case 10 /* RegularExpressionLiteral */: + case 11 /* RegularExpressionLiteral */: return 7 /* regularExpressionLiteral */; case 7 /* ConflictMarkerTrivia */: case 3 /* MultiLineCommentTrivia */: @@ -62510,7 +63224,7 @@ var ts; case 5 /* WhitespaceTrivia */: case 4 /* NewLineTrivia */: return 8 /* whiteSpace */; - case 69 /* Identifier */: + case 70 /* Identifier */: default: if (ts.isTemplateLiteralKind(token)) { return 6 /* stringLiteral */; @@ -62541,10 +63255,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 225 /* ModuleDeclaration */: - case 221 /* ClassDeclaration */: - case 222 /* InterfaceDeclaration */: - case 220 /* FunctionDeclaration */: + case 226 /* ModuleDeclaration */: + case 222 /* ClassDeclaration */: + case 223 /* InterfaceDeclaration */: + case 221 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -62595,7 +63309,7 @@ var ts; */ function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 225 /* ModuleDeclaration */ && + return declaration.kind === 226 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; }); } @@ -62605,7 +63319,7 @@ var ts; if (node && ts.textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { var kind = node.kind; checkForClassificationCancellation(cancellationToken, kind); - if (kind === 69 /* Identifier */ && !ts.nodeIsMissing(node)) { + if (kind === 70 /* 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 @@ -62674,8 +63388,8 @@ var ts; var spanStart = span.start; var spanLength = span.length; // Make a scanner we can get trivia from. - var triviaScanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); - var mergeConflictScanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); + var triviaScanner = ts.createScanner(4 /* Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); + var mergeConflictScanner = ts.createScanner(4 /* Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); var result = []; processElement(sourceFile); return { spans: result, endOfLineState: 0 /* None */ }; @@ -62839,10 +63553,10 @@ var ts; return true; } var classifiedElementName = tryClassifyJsxElementName(node); - if (!ts.isToken(node) && node.kind !== 244 /* JsxText */ && classifiedElementName === undefined) { + if (!ts.isToken(node) && node.kind !== 10 /* JsxText */ && classifiedElementName === undefined) { return false; } - var tokenStart = node.kind === 244 /* JsxText */ ? node.pos : classifyLeadingTriviaAndGetTokenStart(node); + var tokenStart = node.kind === 10 /* JsxText */ ? node.pos : classifyLeadingTriviaAndGetTokenStart(node); var tokenWidth = node.end - tokenStart; ts.Debug.assert(tokenWidth >= 0); if (tokenWidth > 0) { @@ -62855,7 +63569,7 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 243 /* JsxOpeningElement */: + case 244 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } @@ -62865,7 +63579,7 @@ var ts; return 20 /* jsxCloseTagName */; } break; - case 242 /* JsxSelfClosingElement */: + case 243 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } @@ -62887,7 +63601,7 @@ var ts; } // Special case < and > If they appear in a generic context they are punctuation, // not operators. - if (tokenKind === 25 /* LessThanToken */ || tokenKind === 27 /* GreaterThanToken */) { + if (tokenKind === 26 /* LessThanToken */ || tokenKind === 28 /* GreaterThanToken */) { // If the node owning the token has a type argument list or type parameter list, then // we can effectively assume that a '<' and '>' belong to those lists. if (token && ts.getTypeArgumentOrTypeParameterList(token.parent)) { @@ -62896,19 +63610,19 @@ var ts; } if (ts.isPunctuation(tokenKind)) { if (token) { - if (tokenKind === 56 /* EqualsToken */) { + if (tokenKind === 57 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (token.parent.kind === 218 /* VariableDeclaration */ || - token.parent.kind === 145 /* PropertyDeclaration */ || - token.parent.kind === 142 /* Parameter */ || + if (token.parent.kind === 219 /* VariableDeclaration */ || + token.parent.kind === 146 /* PropertyDeclaration */ || + token.parent.kind === 143 /* Parameter */ || token.parent.kind === 246 /* JsxAttribute */) { return 5 /* operator */; } } - if (token.parent.kind === 187 /* BinaryExpression */ || - token.parent.kind === 185 /* PrefixUnaryExpression */ || - token.parent.kind === 186 /* PostfixUnaryExpression */ || - token.parent.kind === 188 /* ConditionalExpression */) { + if (token.parent.kind === 188 /* BinaryExpression */ || + token.parent.kind === 186 /* PrefixUnaryExpression */ || + token.parent.kind === 187 /* PostfixUnaryExpression */ || + token.parent.kind === 189 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -62920,7 +63634,7 @@ var ts; else if (tokenKind === 9 /* StringLiteral */) { return token.parent.kind === 246 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } - else if (tokenKind === 10 /* RegularExpressionLiteral */) { + else if (tokenKind === 11 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. return 6 /* stringLiteral */; } @@ -62928,38 +63642,38 @@ var ts; // TODO (drosen): we should *also* get another classification type for these literals. return 6 /* stringLiteral */; } - else if (tokenKind === 244 /* JsxText */) { + else if (tokenKind === 10 /* JsxText */) { return 23 /* jsxText */; } - else if (tokenKind === 69 /* Identifier */) { + else if (tokenKind === 70 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 141 /* TypeParameter */: + case 142 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 222 /* InterfaceDeclaration */: + case 223 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 142 /* Parameter */: + case 143 /* Parameter */: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; } @@ -62989,6 +63703,7 @@ var ts; } ts.getEncodedSyntacticClassifications = getEncodedSyntacticClassifications; })(ts || (ts = {})); +/// /* @internal */ var ts; (function (ts) { @@ -63028,7 +63743,7 @@ var ts; name: tagName.text, kind: undefined, kindModifiers: undefined, - sortText: "0" + sortText: "0", }); } else { @@ -63085,7 +63800,7 @@ var ts; name: displayName, kind: ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location), kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), - sortText: "0" + sortText: "0", }; } function getCompletionEntriesFromSymbols(symbols, entries, location, performCharacterChecks) { @@ -63113,7 +63828,7 @@ var ts; return undefined; } if (node.parent.kind === 253 /* PropertyAssignment */ && - node.parent.parent.kind === 171 /* ObjectLiteralExpression */ && + node.parent.parent.kind === 172 /* ObjectLiteralExpression */ && node.parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { @@ -63138,7 +63853,7 @@ var ts; // a['/*completion position*/'] return getStringLiteralCompletionEntriesFromElementAccess(node.parent); } - else if (node.parent.kind === 230 /* ImportDeclaration */ || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { + else if (node.parent.kind === 231 /* ImportDeclaration */ || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { // Get all known external module names or complete a path to a module // i.e. import * as ns from "/*completion position*/"; // import x = require("/*completion position*/"); @@ -63151,7 +63866,7 @@ var ts; // Get string literal completions from specialized signatures of the target // i.e. declare function f(a: 'A'); // f("/*completion position*/") - return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo, node); + return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo); } // Get completion for string literal from string literal type // i.e. var x: "hi" | "hello" = "/*completion position*/" @@ -63168,7 +63883,7 @@ var ts; } } } - function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo, location) { + function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo) { var candidates = []; var entries = []; typeChecker.getResolvedSignature(argumentInfo.invocation, candidates); @@ -63531,7 +64246,7 @@ var ts; if (typeRoots) { for (var _b = 0, typeRoots_2 = typeRoots; _b < typeRoots_2.length; _b++) { var root = typeRoots_2[_b]; - getCompletionEntriesFromDirectories(host, options, root, span, result); + getCompletionEntriesFromDirectories(host, root, span, result); } } } @@ -63540,12 +64255,12 @@ var ts; for (var _c = 0, _d = findPackageJsons(scriptPath); _c < _d.length; _c++) { var packageJson = _d[_c]; var typesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules/@types"); - getCompletionEntriesFromDirectories(host, options, typesDir, span, result); + getCompletionEntriesFromDirectories(host, typesDir, span, result); } } return result; } - function getCompletionEntriesFromDirectories(host, options, directory, span, result) { + function getCompletionEntriesFromDirectories(host, directory, span, result) { if (host.getDirectories && tryDirectoryExists(host, directory)) { var directories = tryGetDirectories(host, directory); if (directories) { @@ -63769,12 +64484,12 @@ var ts; return undefined; } var parent_17 = contextToken.parent, kind = contextToken.kind; - if (kind === 21 /* DotToken */) { - if (parent_17.kind === 172 /* PropertyAccessExpression */) { + if (kind === 22 /* DotToken */) { + if (parent_17.kind === 173 /* PropertyAccessExpression */) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_17.kind === 139 /* QualifiedName */) { + else if (parent_17.kind === 140 /* QualifiedName */) { node = contextToken.parent.left; isRightOfDot = true; } @@ -63785,11 +64500,11 @@ var ts; } } else if (sourceFile.languageVariant === 1 /* JSX */) { - if (kind === 25 /* LessThanToken */) { + if (kind === 26 /* LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } - else if (kind === 39 /* SlashToken */ && contextToken.parent.kind === 245 /* JsxClosingElement */) { + else if (kind === 40 /* SlashToken */ && contextToken.parent.kind === 245 /* JsxClosingElement */) { isStartingCloseTag = true; location = contextToken; } @@ -63830,7 +64545,6 @@ var ts; if (!tryGetGlobalSymbols()) { return undefined; } - isGlobalCompletion = true; } log("getCompletionData: Semantic work: " + (ts.timestamp() - semanticStart)); return { symbols: symbols, isGlobalCompletion: isGlobalCompletion, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName: isJsDocTagName }; @@ -63839,7 +64553,7 @@ var ts; isGlobalCompletion = false; isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 69 /* Identifier */ || node.kind === 139 /* QualifiedName */ || node.kind === 172 /* PropertyAccessExpression */) { + if (node.kind === 70 /* Identifier */ || node.kind === 140 /* QualifiedName */ || node.kind === 173 /* PropertyAccessExpression */) { var symbol = typeChecker.getSymbolAtLocation(node); // This is an alias, follow what it aliases if (symbol && symbol.flags & 8388608 /* Alias */) { @@ -63895,10 +64609,9 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType = void 0; - if ((jsxContainer.kind === 242 /* JsxSelfClosingElement */) || (jsxContainer.kind === 243 /* JsxOpeningElement */)) { + if ((jsxContainer.kind === 243 /* JsxSelfClosingElement */) || (jsxContainer.kind === 244 /* JsxOpeningElement */)) { // Cursor is inside a JSX self-closing element or opening element attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); - isGlobalCompletion = false; if (attrsType) { symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); isMemberCompletion = true; @@ -63942,6 +64655,13 @@ var ts; previousToken.getStart() : position; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; + if (scopeNode) { + isGlobalCompletion = + scopeNode.kind === 256 /* SourceFile */ || + scopeNode.kind === 190 /* TemplateExpression */ || + scopeNode.kind === 248 /* JsxExpression */ || + ts.isStatement(scopeNode); + } /// TODO filter meaning based on the current context var symbolMeanings = 793064 /* Type */ | 107455 /* Value */ | 1920 /* Namespace */ | 8388608 /* Alias */; symbols = typeChecker.getSymbolsInScope(scopeNode, symbolMeanings); @@ -63968,15 +64688,15 @@ var ts; return result; } function isInJsxText(contextToken) { - if (contextToken.kind === 244 /* JsxText */) { + if (contextToken.kind === 10 /* JsxText */) { return true; } - if (contextToken.kind === 27 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 243 /* JsxOpeningElement */) { + if (contextToken.kind === 28 /* GreaterThanToken */ && contextToken.parent) { + if (contextToken.parent.kind === 244 /* JsxOpeningElement */) { return true; } - if (contextToken.parent.kind === 245 /* JsxClosingElement */ || contextToken.parent.kind === 242 /* JsxSelfClosingElement */) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 241 /* JsxElement */; + if (contextToken.parent.kind === 245 /* JsxClosingElement */ || contextToken.parent.kind === 243 /* JsxSelfClosingElement */) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 242 /* JsxElement */; } } return false; @@ -63985,41 +64705,41 @@ var ts; if (previousToken) { var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { - case 24 /* CommaToken */: - return containingNodeKind === 174 /* CallExpression */ // func( a, | - || containingNodeKind === 148 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 175 /* NewExpression */ // new C(a, | - || containingNodeKind === 170 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 187 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 156 /* FunctionType */; // var x: (s: string, list| - case 17 /* OpenParenToken */: - return containingNodeKind === 174 /* CallExpression */ // func( | - || containingNodeKind === 148 /* Constructor */ // constructor( | - || containingNodeKind === 175 /* NewExpression */ // new C(a| - || containingNodeKind === 178 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 164 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ - case 19 /* OpenBracketToken */: - return containingNodeKind === 170 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 153 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 140 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 125 /* ModuleKeyword */: // module | - case 126 /* NamespaceKeyword */: + case 25 /* CommaToken */: + return containingNodeKind === 175 /* CallExpression */ // func( a, | + || containingNodeKind === 149 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 176 /* NewExpression */ // new C(a, | + || containingNodeKind === 171 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 188 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 157 /* FunctionType */; // var x: (s: string, list| + case 18 /* OpenParenToken */: + return containingNodeKind === 175 /* CallExpression */ // func( | + || containingNodeKind === 149 /* Constructor */ // constructor( | + || containingNodeKind === 176 /* NewExpression */ // new C(a| + || containingNodeKind === 179 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 165 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + case 20 /* OpenBracketToken */: + return containingNodeKind === 171 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 154 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 141 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + case 126 /* ModuleKeyword */: // module | + case 127 /* NamespaceKeyword */: return true; - case 21 /* DotToken */: - return containingNodeKind === 225 /* ModuleDeclaration */; // module A.| - case 15 /* OpenBraceToken */: - return containingNodeKind === 221 /* ClassDeclaration */; // class A{ | - case 56 /* EqualsToken */: - return containingNodeKind === 218 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 187 /* BinaryExpression */; // x = a| - case 12 /* TemplateHead */: - return containingNodeKind === 189 /* TemplateExpression */; // `aa ${| - case 13 /* TemplateMiddle */: - return containingNodeKind === 197 /* TemplateSpan */; // `aa ${10} dd ${| - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - return containingNodeKind === 145 /* PropertyDeclaration */; // class A{ public | + case 22 /* DotToken */: + return containingNodeKind === 226 /* ModuleDeclaration */; // module A.| + case 16 /* OpenBraceToken */: + return containingNodeKind === 222 /* ClassDeclaration */; // class A{ | + case 57 /* EqualsToken */: + return containingNodeKind === 219 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 188 /* BinaryExpression */; // x = a| + case 13 /* TemplateHead */: + return containingNodeKind === 190 /* TemplateExpression */; // `aa ${| + case 14 /* TemplateMiddle */: + return containingNodeKind === 198 /* TemplateSpan */; // `aa ${10} dd ${| + case 113 /* PublicKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + return containingNodeKind === 146 /* PropertyDeclaration */; // class A{ public | } // Previous token may have been a keyword that was converted to an identifier. switch (previousToken.getText()) { @@ -64033,7 +64753,7 @@ var ts; } function isInStringOrRegularExpressionOrTemplateLiteral(contextToken) { if (contextToken.kind === 9 /* StringLiteral */ - || contextToken.kind === 10 /* RegularExpressionLiteral */ + || contextToken.kind === 11 /* RegularExpressionLiteral */ || ts.isTemplateLiteralKind(contextToken.kind)) { var start_3 = contextToken.getStart(); var end = contextToken.getEnd(); @@ -64046,7 +64766,7 @@ var ts; } if (position === end) { return !!contextToken.isUnterminated - || contextToken.kind === 10 /* RegularExpressionLiteral */; + || contextToken.kind === 11 /* RegularExpressionLiteral */; } } return false; @@ -64062,7 +64782,7 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 171 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 172 /* ObjectLiteralExpression */) { // We are completing on contextual types, but may also include properties // other than those within the declared type. isNewIdentifierLocation = true; @@ -64072,7 +64792,7 @@ var ts; typeForObject = typeForObject && typeForObject.getNonNullableType(); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 167 /* ObjectBindingPattern */) { + else if (objectLikeContainer.kind === 168 /* ObjectBindingPattern */) { // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -64083,11 +64803,11 @@ var ts; // Also proceed if rootDeclaration is a parameter and if its containing function expression/arrow function is contextually typed - // type of parameter will flow in from the contextual type of the function var canGetType = !!(rootDeclaration.initializer || rootDeclaration.type); - if (!canGetType && rootDeclaration.kind === 142 /* Parameter */) { + if (!canGetType && rootDeclaration.kind === 143 /* Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 147 /* MethodDeclaration */ || rootDeclaration.parent.kind === 150 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 148 /* MethodDeclaration */ || rootDeclaration.parent.kind === 151 /* SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -64129,9 +64849,9 @@ var ts; * @returns true if 'symbols' was successfully populated; false otherwise. */ function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 233 /* NamedImports */ ? - 230 /* ImportDeclaration */ : - 236 /* ExportDeclaration */; + var declarationKind = namedImportsOrExports.kind === 234 /* NamedImports */ ? + 231 /* ImportDeclaration */ : + 237 /* ExportDeclaration */; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -64154,10 +64874,10 @@ var ts; function tryGetObjectLikeCompletionContainer(contextToken) { if (contextToken) { switch (contextToken.kind) { - case 15 /* OpenBraceToken */: // const x = { | - case 24 /* CommaToken */: + case 16 /* OpenBraceToken */: // const x = { | + case 25 /* CommaToken */: var parent_18 = contextToken.parent; - if (parent_18 && (parent_18.kind === 171 /* ObjectLiteralExpression */ || parent_18.kind === 167 /* ObjectBindingPattern */)) { + if (parent_18 && (parent_18.kind === 172 /* ObjectLiteralExpression */ || parent_18.kind === 168 /* ObjectBindingPattern */)) { return parent_18; } break; @@ -64172,11 +64892,11 @@ var ts; function tryGetNamedImportsOrExportsForCompletion(contextToken) { if (contextToken) { switch (contextToken.kind) { - case 15 /* OpenBraceToken */: // import { | - case 24 /* CommaToken */: + case 16 /* OpenBraceToken */: // import { | + case 25 /* CommaToken */: switch (contextToken.parent.kind) { - case 233 /* NamedImports */: - case 237 /* NamedExports */: + case 234 /* NamedImports */: + case 238 /* NamedExports */: return contextToken.parent; } } @@ -64187,12 +64907,12 @@ var ts; if (contextToken) { var parent_19 = contextToken.parent; switch (contextToken.kind) { - case 26 /* LessThanSlashToken */: - case 39 /* SlashToken */: - case 69 /* Identifier */: + case 27 /* LessThanSlashToken */: + case 40 /* SlashToken */: + case 70 /* Identifier */: case 246 /* JsxAttribute */: case 247 /* JsxSpreadAttribute */: - if (parent_19 && (parent_19.kind === 242 /* JsxSelfClosingElement */ || parent_19.kind === 243 /* JsxOpeningElement */)) { + if (parent_19 && (parent_19.kind === 243 /* JsxSelfClosingElement */ || parent_19.kind === 244 /* JsxOpeningElement */)) { return parent_19; } else if (parent_19.kind === 246 /* JsxAttribute */) { @@ -64207,7 +64927,7 @@ var ts; return parent_19.parent; } break; - case 16 /* CloseBraceToken */: + case 17 /* CloseBraceToken */: if (parent_19 && parent_19.kind === 248 /* JsxExpression */ && parent_19.parent && @@ -64224,16 +64944,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: - case 220 /* FunctionDeclaration */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 221 /* FunctionDeclaration */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: return true; } return false; @@ -64244,67 +64964,67 @@ var ts; function isSolelyIdentifierDefinitionLocation(contextToken) { var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { - case 24 /* CommaToken */: - return containingNodeKind === 218 /* VariableDeclaration */ || - containingNodeKind === 219 /* VariableDeclarationList */ || - containingNodeKind === 200 /* VariableStatement */ || - containingNodeKind === 224 /* EnumDeclaration */ || + case 25 /* CommaToken */: + return containingNodeKind === 219 /* VariableDeclaration */ || + containingNodeKind === 220 /* VariableDeclarationList */ || + containingNodeKind === 201 /* VariableStatement */ || + containingNodeKind === 225 /* EnumDeclaration */ || isFunction(containingNodeKind) || - containingNodeKind === 221 /* ClassDeclaration */ || - containingNodeKind === 192 /* ClassExpression */ || - containingNodeKind === 222 /* InterfaceDeclaration */ || - containingNodeKind === 168 /* ArrayBindingPattern */ || - containingNodeKind === 223 /* TypeAliasDeclaration */; // type Map, K, | - case 21 /* DotToken */: - return containingNodeKind === 168 /* ArrayBindingPattern */; // var [.| - case 54 /* ColonToken */: - return containingNodeKind === 169 /* BindingElement */; // var {x :html| - case 19 /* OpenBracketToken */: - return containingNodeKind === 168 /* ArrayBindingPattern */; // var [x| - case 17 /* OpenParenToken */: + containingNodeKind === 222 /* ClassDeclaration */ || + containingNodeKind === 193 /* ClassExpression */ || + containingNodeKind === 223 /* InterfaceDeclaration */ || + containingNodeKind === 169 /* ArrayBindingPattern */ || + containingNodeKind === 224 /* TypeAliasDeclaration */; // type Map, K, | + case 22 /* DotToken */: + return containingNodeKind === 169 /* ArrayBindingPattern */; // var [.| + case 55 /* ColonToken */: + return containingNodeKind === 170 /* BindingElement */; // var {x :html| + case 20 /* OpenBracketToken */: + return containingNodeKind === 169 /* ArrayBindingPattern */; // var [x| + case 18 /* OpenParenToken */: return containingNodeKind === 252 /* CatchClause */ || isFunction(containingNodeKind); - case 15 /* OpenBraceToken */: - return containingNodeKind === 224 /* EnumDeclaration */ || - containingNodeKind === 222 /* InterfaceDeclaration */ || - containingNodeKind === 159 /* TypeLiteral */; // const x : { | - case 23 /* SemicolonToken */: - return containingNodeKind === 144 /* PropertySignature */ && + case 16 /* OpenBraceToken */: + return containingNodeKind === 225 /* EnumDeclaration */ || + containingNodeKind === 223 /* InterfaceDeclaration */ || + containingNodeKind === 160 /* TypeLiteral */; // const x : { | + case 24 /* SemicolonToken */: + return containingNodeKind === 145 /* PropertySignature */ && contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 222 /* InterfaceDeclaration */ || - contextToken.parent.parent.kind === 159 /* TypeLiteral */); // const x : { a; | - case 25 /* LessThanToken */: - return containingNodeKind === 221 /* ClassDeclaration */ || - containingNodeKind === 192 /* ClassExpression */ || - containingNodeKind === 222 /* InterfaceDeclaration */ || - containingNodeKind === 223 /* TypeAliasDeclaration */ || + (contextToken.parent.parent.kind === 223 /* InterfaceDeclaration */ || + contextToken.parent.parent.kind === 160 /* TypeLiteral */); // const x : { a; | + case 26 /* LessThanToken */: + return containingNodeKind === 222 /* ClassDeclaration */ || + containingNodeKind === 193 /* ClassExpression */ || + containingNodeKind === 223 /* InterfaceDeclaration */ || + containingNodeKind === 224 /* TypeAliasDeclaration */ || isFunction(containingNodeKind); - case 113 /* StaticKeyword */: - return containingNodeKind === 145 /* PropertyDeclaration */; - case 22 /* DotDotDotToken */: - return containingNodeKind === 142 /* Parameter */ || + case 114 /* StaticKeyword */: + return containingNodeKind === 146 /* PropertyDeclaration */; + case 23 /* DotDotDotToken */: + return containingNodeKind === 143 /* Parameter */ || (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 168 /* ArrayBindingPattern */); // var [...z| - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - return containingNodeKind === 142 /* Parameter */; - case 116 /* AsKeyword */: - return containingNodeKind === 234 /* ImportSpecifier */ || - containingNodeKind === 238 /* ExportSpecifier */ || - containingNodeKind === 232 /* NamespaceImport */; - case 73 /* ClassKeyword */: - case 81 /* EnumKeyword */: - case 107 /* InterfaceKeyword */: - case 87 /* FunctionKeyword */: - case 102 /* VarKeyword */: - case 123 /* GetKeyword */: - case 131 /* SetKeyword */: - case 89 /* ImportKeyword */: - case 108 /* LetKeyword */: - case 74 /* ConstKeyword */: - case 114 /* YieldKeyword */: - case 134 /* TypeKeyword */: + contextToken.parent.parent.kind === 169 /* ArrayBindingPattern */); // var [...z| + case 113 /* PublicKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + return containingNodeKind === 143 /* Parameter */; + case 117 /* AsKeyword */: + return containingNodeKind === 235 /* ImportSpecifier */ || + containingNodeKind === 239 /* ExportSpecifier */ || + containingNodeKind === 233 /* NamespaceImport */; + case 74 /* ClassKeyword */: + case 82 /* EnumKeyword */: + case 108 /* InterfaceKeyword */: + case 88 /* FunctionKeyword */: + case 103 /* VarKeyword */: + case 124 /* GetKeyword */: + case 132 /* SetKeyword */: + case 90 /* ImportKeyword */: + case 109 /* LetKeyword */: + case 75 /* ConstKeyword */: + case 115 /* YieldKeyword */: + case 135 /* TypeKeyword */: return true; } // Previous token may have been a keyword that was converted to an identifier. @@ -64376,8 +65096,8 @@ var ts; // Ignore omitted expressions for missing members if (m.kind !== 253 /* PropertyAssignment */ && m.kind !== 254 /* ShorthandPropertyAssignment */ && - m.kind !== 169 /* BindingElement */ && - m.kind !== 147 /* MethodDeclaration */) { + m.kind !== 170 /* BindingElement */ && + m.kind !== 148 /* MethodDeclaration */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -64385,9 +65105,9 @@ var ts; continue; } var existingName = void 0; - if (m.kind === 169 /* BindingElement */ && m.propertyName) { + if (m.kind === 170 /* BindingElement */ && m.propertyName) { // include only identifiers in completion list - if (m.propertyName.kind === 69 /* Identifier */) { + if (m.propertyName.kind === 70 /* Identifier */) { existingName = m.propertyName.text; } } @@ -64465,7 +65185,7 @@ var ts; } // A cache of completion entries for keywords, these do not change between sessions var keywordCompletions = []; - for (var i = 70 /* FirstKeyword */; i <= 138 /* LastKeyword */; i++) { + for (var i = 71 /* FirstKeyword */; i <= 139 /* LastKeyword */; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ts.ScriptElementKind.keyword, @@ -64540,10 +65260,10 @@ var ts; }; } function getSemanticDocumentHighlights(node) { - if (node.kind === 69 /* Identifier */ || - node.kind === 97 /* ThisKeyword */ || - node.kind === 165 /* ThisType */ || - node.kind === 95 /* SuperKeyword */ || + if (node.kind === 70 /* Identifier */ || + node.kind === 98 /* ThisKeyword */ || + node.kind === 166 /* ThisType */ || + node.kind === 96 /* SuperKeyword */ || node.kind === 9 /* StringLiteral */ || ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { var referencedSymbols = ts.FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFilesToSearch, /*findInStrings*/ false, /*findInComments*/ false, /*implementations*/ false); @@ -64594,77 +65314,77 @@ var ts; function getHighlightSpans(node) { if (node) { switch (node.kind) { - case 88 /* IfKeyword */: - case 80 /* ElseKeyword */: - if (hasKind(node.parent, 203 /* IfStatement */)) { + case 89 /* IfKeyword */: + case 81 /* ElseKeyword */: + if (hasKind(node.parent, 204 /* IfStatement */)) { return getIfElseOccurrences(node.parent); } break; - case 94 /* ReturnKeyword */: - if (hasKind(node.parent, 211 /* ReturnStatement */)) { + case 95 /* ReturnKeyword */: + if (hasKind(node.parent, 212 /* ReturnStatement */)) { return getReturnOccurrences(node.parent); } break; - case 98 /* ThrowKeyword */: - if (hasKind(node.parent, 215 /* ThrowStatement */)) { + case 99 /* ThrowKeyword */: + if (hasKind(node.parent, 216 /* ThrowStatement */)) { return getThrowOccurrences(node.parent); } break; - case 72 /* CatchKeyword */: - if (hasKind(parent(parent(node)), 216 /* TryStatement */)) { + case 73 /* CatchKeyword */: + if (hasKind(parent(parent(node)), 217 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; - case 100 /* TryKeyword */: - case 85 /* FinallyKeyword */: - if (hasKind(parent(node), 216 /* TryStatement */)) { + case 101 /* TryKeyword */: + case 86 /* FinallyKeyword */: + if (hasKind(parent(node), 217 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent); } break; - case 96 /* SwitchKeyword */: - if (hasKind(node.parent, 213 /* SwitchStatement */)) { + case 97 /* SwitchKeyword */: + if (hasKind(node.parent, 214 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; - case 71 /* CaseKeyword */: - case 77 /* DefaultKeyword */: - if (hasKind(parent(parent(parent(node))), 213 /* SwitchStatement */)) { + case 72 /* CaseKeyword */: + case 78 /* DefaultKeyword */: + if (hasKind(parent(parent(parent(node))), 214 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; - case 70 /* BreakKeyword */: - case 75 /* ContinueKeyword */: - if (hasKind(node.parent, 210 /* BreakStatement */) || hasKind(node.parent, 209 /* ContinueStatement */)) { + case 71 /* BreakKeyword */: + case 76 /* ContinueKeyword */: + if (hasKind(node.parent, 211 /* BreakStatement */) || hasKind(node.parent, 210 /* ContinueStatement */)) { return getBreakOrContinueStatementOccurrences(node.parent); } break; - case 86 /* ForKeyword */: - if (hasKind(node.parent, 206 /* ForStatement */) || - hasKind(node.parent, 207 /* ForInStatement */) || - hasKind(node.parent, 208 /* ForOfStatement */)) { + case 87 /* ForKeyword */: + if (hasKind(node.parent, 207 /* ForStatement */) || + hasKind(node.parent, 208 /* ForInStatement */) || + hasKind(node.parent, 209 /* ForOfStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 104 /* WhileKeyword */: - case 79 /* DoKeyword */: - if (hasKind(node.parent, 205 /* WhileStatement */) || hasKind(node.parent, 204 /* DoStatement */)) { + case 105 /* WhileKeyword */: + case 80 /* DoKeyword */: + if (hasKind(node.parent, 206 /* WhileStatement */) || hasKind(node.parent, 205 /* DoStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 121 /* ConstructorKeyword */: - if (hasKind(node.parent, 148 /* Constructor */)) { + case 122 /* ConstructorKeyword */: + if (hasKind(node.parent, 149 /* Constructor */)) { return getConstructorOccurrences(node.parent); } break; - case 123 /* GetKeyword */: - case 131 /* SetKeyword */: - if (hasKind(node.parent, 149 /* GetAccessor */) || hasKind(node.parent, 150 /* SetAccessor */)) { + case 124 /* GetKeyword */: + case 132 /* SetKeyword */: + if (hasKind(node.parent, 150 /* GetAccessor */) || hasKind(node.parent, 151 /* SetAccessor */)) { return getGetAndSetOccurrences(node.parent); } break; default: if (ts.isModifierKind(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 200 /* VariableStatement */)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 201 /* VariableStatement */)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -64680,10 +65400,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 215 /* ThrowStatement */) { + if (node.kind === 216 /* ThrowStatement */) { statementAccumulator.push(node); } - else if (node.kind === 216 /* TryStatement */) { + else if (node.kind === 217 /* TryStatement */) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -64716,7 +65436,7 @@ var ts; } // 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_20.kind === 216 /* TryStatement */) { + if (parent_20.kind === 217 /* TryStatement */) { var tryStatement = parent_20; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; @@ -64731,7 +65451,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 210 /* BreakStatement */ || node.kind === 209 /* ContinueStatement */) { + if (node.kind === 211 /* BreakStatement */ || node.kind === 210 /* ContinueStatement */) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -64746,16 +65466,16 @@ var ts; function getBreakOrContinueOwner(statement) { for (var node_1 = statement.parent; node_1; node_1 = node_1.parent) { switch (node_1.kind) { - case 213 /* SwitchStatement */: - if (statement.kind === 209 /* ContinueStatement */) { + case 214 /* SwitchStatement */: + if (statement.kind === 210 /* ContinueStatement */) { continue; } // Fall through. - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: - case 205 /* WhileStatement */: - case 204 /* DoStatement */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: + case 206 /* WhileStatement */: + case 205 /* DoStatement */: if (!statement.label || isLabeledBy(node_1, statement.label.text)) { return node_1; } @@ -64774,24 +65494,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 === 221 /* ClassDeclaration */ || - container.kind === 192 /* ClassExpression */ || - (declaration.kind === 142 /* Parameter */ && hasKind(container, 148 /* Constructor */)))) { + if (!(container.kind === 222 /* ClassDeclaration */ || + container.kind === 193 /* ClassExpression */ || + (declaration.kind === 143 /* Parameter */ && hasKind(container, 149 /* Constructor */)))) { return undefined; } } - else if (modifier === 113 /* StaticKeyword */) { - if (!(container.kind === 221 /* ClassDeclaration */ || container.kind === 192 /* ClassExpression */)) { + else if (modifier === 114 /* StaticKeyword */) { + if (!(container.kind === 222 /* ClassDeclaration */ || container.kind === 193 /* ClassExpression */)) { return undefined; } } - else if (modifier === 82 /* ExportKeyword */ || modifier === 122 /* DeclareKeyword */) { - if (!(container.kind === 226 /* ModuleBlock */ || container.kind === 256 /* SourceFile */)) { + else if (modifier === 83 /* ExportKeyword */ || modifier === 123 /* DeclareKeyword */) { + if (!(container.kind === 227 /* ModuleBlock */ || container.kind === 256 /* SourceFile */)) { return undefined; } } - else if (modifier === 115 /* AbstractKeyword */) { - if (!(container.kind === 221 /* ClassDeclaration */ || declaration.kind === 221 /* ClassDeclaration */)) { + else if (modifier === 116 /* AbstractKeyword */) { + if (!(container.kind === 222 /* ClassDeclaration */ || declaration.kind === 222 /* ClassDeclaration */)) { return undefined; } } @@ -64803,7 +65523,7 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 226 /* ModuleBlock */: + case 227 /* ModuleBlock */: case 256 /* SourceFile */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 128 /* Abstract */) { @@ -64813,17 +65533,17 @@ var ts; nodes = container.statements; } break; - case 148 /* Constructor */: + case 149 /* Constructor */: nodes = container.parameters.concat(container.parent.members); break; - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: + case 222 /* ClassDeclaration */: + case 193 /* 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 & 28 /* AccessibilityModifier */) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 148 /* Constructor */ && member; + return member.kind === 149 /* Constructor */ && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -64844,19 +65564,19 @@ var ts; return ts.map(keywords, getHighlightSpanForNode); function getFlagFromModifier(modifier) { switch (modifier) { - case 112 /* PublicKeyword */: + case 113 /* PublicKeyword */: return 4 /* Public */; - case 110 /* PrivateKeyword */: + case 111 /* PrivateKeyword */: return 8 /* Private */; - case 111 /* ProtectedKeyword */: + case 112 /* ProtectedKeyword */: return 16 /* Protected */; - case 113 /* StaticKeyword */: + case 114 /* StaticKeyword */: return 32 /* Static */; - case 82 /* ExportKeyword */: + case 83 /* ExportKeyword */: return 1 /* Export */; - case 122 /* DeclareKeyword */: + case 123 /* DeclareKeyword */: return 2 /* Ambient */; - case 115 /* AbstractKeyword */: + case 116 /* AbstractKeyword */: return 128 /* Abstract */; default: ts.Debug.fail(); @@ -64876,13 +65596,13 @@ var ts; } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 149 /* GetAccessor */); - tryPushAccessorKeyword(accessorDeclaration.symbol, 150 /* SetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 150 /* GetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 151 /* 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, 123 /* GetKeyword */, 131 /* SetKeyword */); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 124 /* GetKeyword */, 132 /* SetKeyword */); }); } } } @@ -64891,19 +65611,19 @@ var ts; var keywords = []; ts.forEach(declarations, function (declaration) { ts.forEach(declaration.getChildren(), function (token) { - return pushKeywordIf(keywords, token, 121 /* ConstructorKeyword */); + return pushKeywordIf(keywords, token, 122 /* ConstructorKeyword */); }); }); return ts.map(keywords, getHighlightSpanForNode); } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 86 /* ForKeyword */, 104 /* WhileKeyword */, 79 /* DoKeyword */)) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 87 /* ForKeyword */, 105 /* WhileKeyword */, 80 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 204 /* DoStatement */) { + if (loopNode.kind === 205 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 104 /* WhileKeyword */)) { + if (pushKeywordIf(keywords, loopTokens[i], 105 /* WhileKeyword */)) { break; } } @@ -64912,7 +65632,7 @@ var ts; var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 70 /* BreakKeyword */, 75 /* ContinueKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 71 /* BreakKeyword */, 76 /* ContinueKeyword */); } }); return ts.map(keywords, getHighlightSpanForNode); @@ -64921,13 +65641,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: - case 204 /* DoStatement */: - case 205 /* WhileStatement */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: + case 205 /* DoStatement */: + case 206 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 213 /* SwitchStatement */: + case 214 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -64935,14 +65655,14 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 96 /* SwitchKeyword */); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 97 /* 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(), 71 /* CaseKeyword */, 77 /* DefaultKeyword */); + pushKeywordIf(keywords, clause.getFirstToken(), 72 /* CaseKeyword */, 78 /* DefaultKeyword */); var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 70 /* BreakKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 71 /* BreakKeyword */); } }); }); @@ -64950,13 +65670,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 100 /* TryKeyword */); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 101 /* TryKeyword */); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 72 /* CatchKeyword */); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 73 /* CatchKeyword */); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 85 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 85 /* FinallyKeyword */); + var finallyKeyword = ts.findChildOfKind(tryStatement, 86 /* FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 86 /* FinallyKeyword */); } return ts.map(keywords, getHighlightSpanForNode); } @@ -64967,13 +65687,13 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 98 /* ThrowKeyword */); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 99 /* 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(), 94 /* ReturnKeyword */); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 95 /* ReturnKeyword */); }); } return ts.map(keywords, getHighlightSpanForNode); @@ -64981,36 +65701,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, 199 /* Block */))) { + if (!(func && hasKind(func.body, 200 /* Block */))) { return undefined; } var keywords = []; ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 94 /* ReturnKeyword */); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 95 /* ReturnKeyword */); }); // Include 'throw' statements that do not occur within a try block. ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 98 /* ThrowKeyword */); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 99 /* 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, 203 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 204 /* 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], 88 /* IfKeyword */); + pushKeywordIf(keywords, children[0], 89 /* 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], 80 /* ElseKeyword */)) { + if (pushKeywordIf(keywords, children[i], 81 /* ElseKeyword */)) { break; } } - if (!hasKind(ifStatement.elseStatement, 203 /* IfStatement */)) { + if (!hasKind(ifStatement.elseStatement, 204 /* IfStatement */)) { break; } ifStatement = ifStatement.elseStatement; @@ -65019,7 +65739,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 === 80 /* ElseKeyword */ && i < keywords.length - 1) { + if (keywords[i].kind === 81 /* ElseKeyword */ && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. var shouldCombindElseAndIf = true; @@ -65053,7 +65773,7 @@ var ts; * Note: 'node' cannot be a SourceFile. */ function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 214 /* LabeledStatement */; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 215 /* LabeledStatement */; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -65191,10 +65911,10 @@ var ts; break; } // Fallthrough - case 69 /* Identifier */: - case 97 /* ThisKeyword */: + case 70 /* Identifier */: + case 98 /* ThisKeyword */: // case SyntaxKind.SuperKeyword: TODO:GH#9268 - case 121 /* ConstructorKeyword */: + case 122 /* ConstructorKeyword */: case 9 /* StringLiteral */: return getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, /*implementations*/ false); } @@ -65219,7 +65939,7 @@ var ts; if (ts.isThis(node)) { return getReferencesForThisKeyword(node, sourceFiles); } - if (node.kind === 95 /* SuperKeyword */) { + if (node.kind === 96 /* SuperKeyword */) { return getReferencesForSuperKeyword(node); } } @@ -65255,7 +65975,7 @@ var ts; getReferencesInNode(scope, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); } else { - var internedName = getInternedName(symbol, node, declarations); + var internedName = getInternedName(symbol, node); for (var _i = 0, sourceFiles_8 = sourceFiles; _i < sourceFiles_8.length; _i++) { var sourceFile = sourceFiles_8[_i]; cancellationToken.throwIfCancellationRequested(); @@ -65287,12 +66007,12 @@ var ts; function getAliasSymbolForPropertyNameSymbol(symbol, location) { if (symbol.flags & 8388608 /* Alias */) { // Default import get alias - var defaultImport = ts.getDeclarationOfKind(symbol, 231 /* ImportClause */); + var defaultImport = ts.getDeclarationOfKind(symbol, 232 /* ImportClause */); if (defaultImport) { return typeChecker.getAliasedSymbol(symbol); } - var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 234 /* ImportSpecifier */ || - declaration.kind === 238 /* ExportSpecifier */) ? declaration : undefined; }); + var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 235 /* ImportSpecifier */ || + declaration.kind === 239 /* ExportSpecifier */) ? declaration : undefined; }); if (importOrExportSpecifier && // export { a } (!importOrExportSpecifier.propertyName || @@ -65300,7 +66020,7 @@ var ts; importOrExportSpecifier.propertyName === location)) { // If Import specifier -> get alias // else Export specifier -> get local target - return importOrExportSpecifier.kind === 234 /* ImportSpecifier */ ? + return importOrExportSpecifier.kind === 235 /* ImportSpecifier */ ? typeChecker.getAliasedSymbol(symbol) : typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); } @@ -65315,20 +66035,20 @@ var ts; typeChecker.getPropertySymbolOfDestructuringAssignment(location); } function isObjectBindingPatternElementWithoutPropertyName(symbol) { - var bindingElement = ts.getDeclarationOfKind(symbol, 169 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 170 /* BindingElement */); return bindingElement && - bindingElement.parent.kind === 167 /* ObjectBindingPattern */ && + bindingElement.parent.kind === 168 /* ObjectBindingPattern */ && !bindingElement.propertyName; } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol) { if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { - var bindingElement = ts.getDeclarationOfKind(symbol, 169 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 170 /* BindingElement */); var typeOfPattern = typeChecker.getTypeAtLocation(bindingElement.parent); return typeOfPattern && typeChecker.getPropertyOfType(typeOfPattern, bindingElement.name.text); } return undefined; } - function getInternedName(symbol, location, declarations) { + function getInternedName(symbol, location) { // If this is an export or import specifier it could have been renamed using the 'as' syntax. // If so we want to search for whatever under the cursor. if (ts.isImportOrExportSpecifierName(location)) { @@ -65352,14 +66072,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 === 179 /* FunctionExpression */ || valueDeclaration.kind === 192 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 180 /* FunctionExpression */ || valueDeclaration.kind === 193 /* 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 (ts.getModifierFlags(d) & 8 /* Private */) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 221 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 222 /* ClassDeclaration */); } } // If the symbol is an import we would like to find it if we are looking for what it imports. @@ -65421,8 +66141,8 @@ var ts; // We found a match. Make sure it's not part of a larger word (i.e. the char // before and after it have to be a non-identifier char). var endPosition = position + symbolNameLength; - if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 2 /* Latest */)) && - (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 2 /* Latest */))) { + if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 4 /* Latest */)) && + (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 4 /* Latest */))) { // Found a real match. Keep searching. positions.push(position); } @@ -65462,7 +66182,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 69 /* Identifier */: + case 70 /* Identifier */: return node.getWidth() === searchSymbolName.length; case 9 /* StringLiteral */: if (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || @@ -65526,14 +66246,14 @@ var ts; var referenceSymbolDeclaration = referenceSymbol.valueDeclaration; var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); var relatedSymbol = getRelatedSymbol(searchSymbols_1, referenceSymbol, referenceLocation, - /*searchLocationIsConstructor*/ searchLocation.kind === 121 /* ConstructorKeyword */, parents, inheritsFromCache); + /*searchLocationIsConstructor*/ searchLocation.kind === 122 /* ConstructorKeyword */, parents, inheritsFromCache); if (relatedSymbol) { addReferenceToRelatedSymbol(referenceLocation, relatedSymbol); } else if (!(referenceSymbol.flags & 67108864 /* Transient */) && searchSymbols_1.indexOf(shorthandValueSymbol) >= 0) { addReferenceToRelatedSymbol(referenceSymbolDeclaration.name, shorthandValueSymbol); } - else if (searchLocation.kind === 121 /* ConstructorKeyword */) { + else if (searchLocation.kind === 122 /* ConstructorKeyword */) { findAdditionalConstructorReferences(referenceSymbol, referenceLocation); } } @@ -65594,17 +66314,17 @@ var ts; var result = []; for (var _i = 0, _a = classSymbol.members["__constructor"].declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 148 /* Constructor */); + ts.Debug.assert(decl.kind === 149 /* Constructor */); var ctrKeyword = decl.getChildAt(0); - ts.Debug.assert(ctrKeyword.kind === 121 /* ConstructorKeyword */); + ts.Debug.assert(ctrKeyword.kind === 122 /* ConstructorKeyword */); result.push(ctrKeyword); } ts.forEachProperty(classSymbol.exports, function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 147 /* MethodDeclaration */) { + if (decl && decl.kind === 148 /* MethodDeclaration */) { var body = decl.body; if (body) { - forEachDescendantOfKind(body, 97 /* ThisKeyword */, function (thisKeyword) { + forEachDescendantOfKind(body, 98 /* ThisKeyword */, function (thisKeyword) { if (ts.isNewExpressionTarget(thisKeyword)) { result.push(thisKeyword); } @@ -65624,10 +66344,10 @@ var ts; var result = []; for (var _i = 0, _a = ctr.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 148 /* Constructor */); + ts.Debug.assert(decl.kind === 149 /* Constructor */); var body = decl.body; if (body) { - forEachDescendantOfKind(body, 95 /* SuperKeyword */, function (node) { + forEachDescendantOfKind(body, 96 /* SuperKeyword */, function (node) { if (ts.isCallExpressionTarget(node)) { result.push(node); } @@ -65665,7 +66385,7 @@ var ts; if (ts.isDeclarationName(refNode) && isImplementation(refNode.parent)) { result.push(getReferenceEntryFromNode(refNode.parent)); } - else if (refNode.kind === 69 /* Identifier */) { + else if (refNode.kind === 70 /* Identifier */) { if (refNode.parent.kind === 254 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); @@ -65684,7 +66404,7 @@ var ts; maybeAdd(getReferenceEntryFromNode(parent_21.initializer)); } else if (ts.isFunctionLike(parent_21) && parent_21.type === containingTypeReference && parent_21.body) { - if (parent_21.body.kind === 199 /* Block */) { + if (parent_21.body.kind === 200 /* Block */) { ts.forEachReturnStatement(parent_21.body, function (returnStatement) { if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); @@ -65736,12 +66456,12 @@ var ts; } function getContainingClassIfInHeritageClause(node) { if (node && node.parent) { - if (node.kind === 194 /* ExpressionWithTypeArguments */ + if (node.kind === 195 /* ExpressionWithTypeArguments */ && node.parent.kind === 251 /* HeritageClause */ && ts.isClassLike(node.parent.parent)) { return node.parent.parent; } - else if (node.kind === 69 /* Identifier */ || node.kind === 172 /* PropertyAccessExpression */) { + else if (node.kind === 70 /* Identifier */ || node.kind === 173 /* PropertyAccessExpression */) { return getContainingClassIfInHeritageClause(node.parent); } } @@ -65752,14 +66472,14 @@ var ts; */ function isImplementationExpression(node) { // Unwrap parentheses - if (node.kind === 178 /* ParenthesizedExpression */) { + if (node.kind === 179 /* ParenthesizedExpression */) { return isImplementationExpression(node.expression); } - return node.kind === 180 /* ArrowFunction */ || - node.kind === 179 /* FunctionExpression */ || - node.kind === 171 /* ObjectLiteralExpression */ || - node.kind === 192 /* ClassExpression */ || - node.kind === 170 /* ArrayLiteralExpression */; + return node.kind === 181 /* ArrowFunction */ || + node.kind === 180 /* FunctionExpression */ || + node.kind === 172 /* ObjectLiteralExpression */ || + node.kind === 193 /* ClassExpression */ || + node.kind === 171 /* ArrayLiteralExpression */; } /** * Determines if the parent symbol occurs somewhere in the child's ancestry. If the parent symbol @@ -65808,7 +66528,7 @@ var ts; } return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); } - else if (declaration.kind === 222 /* InterfaceDeclaration */) { + else if (declaration.kind === 223 /* InterfaceDeclaration */) { if (parentIsInterface) { return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); } @@ -65836,13 +66556,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -65855,7 +66575,7 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 95 /* SuperKeyword */) { + if (!node || node.kind !== 96 /* SuperKeyword */) { return; } var container = ts.getSuperContainer(node, /*stopOnFunctions*/ false); @@ -65874,17 +66594,17 @@ var ts; // Whether 'this' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // fall through - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -65893,8 +66613,8 @@ var ts; return undefined; } // Fall through - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: + case 221 /* FunctionDeclaration */: + case 180 /* 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. @@ -65937,20 +66657,20 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 179 /* FunctionExpression */: - case 220 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 221 /* FunctionDeclaration */: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 192 /* ClassExpression */: - case 221 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 222 /* 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 && (ts.getModifierFlags(container) & 32 /* Static */) === staticFlag) { @@ -66060,7 +66780,7 @@ var ts; // we should include both parameter declaration symbol and property declaration symbol // Parameter Declaration symbol is only visible within function scope, so the symbol is stored in constructor.locals. // Property Declaration symbol is a member of the class, so the symbol is stored in its class Declaration.symbol.members - if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 142 /* Parameter */ && + if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 143 /* Parameter */ && ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { result = result.concat(typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); } @@ -66115,7 +66835,7 @@ var ts; getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 222 /* InterfaceDeclaration */) { + else if (declaration.kind === 223 /* InterfaceDeclaration */) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -66199,7 +66919,7 @@ var ts; }); } function getNameFromObjectLiteralElement(node) { - if (node.name.kind === 140 /* ComputedPropertyName */) { + if (node.name.kind === 141 /* ComputedPropertyName */) { var nameExpression = node.name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteral(nameExpression.kind)) { @@ -66281,7 +67001,7 @@ var ts; if (node.initializer) { return true; } - else if (node.kind === 218 /* VariableDeclaration */) { + else if (node.kind === 219 /* VariableDeclaration */) { var parentStatement = getParentStatementOfVariableDeclaration(node); return parentStatement && ts.hasModifier(parentStatement, 2 /* Ambient */); } @@ -66291,18 +67011,18 @@ var ts; } else { switch (node.kind) { - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - case 224 /* EnumDeclaration */: - case 225 /* ModuleDeclaration */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 225 /* EnumDeclaration */: + case 226 /* ModuleDeclaration */: return true; } } return false; } function getParentStatementOfVariableDeclaration(node) { - if (node.parent && node.parent.parent && node.parent.parent.kind === 200 /* VariableStatement */) { - ts.Debug.assert(node.parent.kind === 219 /* VariableDeclarationList */); + if (node.parent && node.parent.parent && node.parent.parent.kind === 201 /* VariableStatement */) { + ts.Debug.assert(node.parent.kind === 220 /* VariableDeclarationList */); return node.parent.parent; } } @@ -66336,17 +67056,17 @@ var ts; FindAllReferences.getReferenceEntryFromNode = getReferenceEntryFromNode; /** 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 === 69 /* Identifier */ && ts.isDeclarationName(node)) { + if (node.kind === 70 /* Identifier */ && ts.isDeclarationName(node)) { return true; } var parent = node.parent; if (parent) { - if (parent.kind === 186 /* PostfixUnaryExpression */ || parent.kind === 185 /* PrefixUnaryExpression */) { + if (parent.kind === 187 /* PostfixUnaryExpression */ || parent.kind === 186 /* PrefixUnaryExpression */) { return true; } - else if (parent.kind === 187 /* BinaryExpression */ && parent.left === node) { + else if (parent.kind === 188 /* BinaryExpression */ && parent.left === node) { var operator = parent.operatorToken.kind; - return 56 /* FirstAssignment */ <= operator && operator <= 68 /* LastAssignment */; + return 57 /* FirstAssignment */ <= operator && operator <= 69 /* LastAssignment */; } } return false; @@ -66366,11 +67086,11 @@ var ts; switch (node.kind) { case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - if (node.parent.kind === 140 /* ComputedPropertyName */) { + if (node.parent.kind === 141 /* ComputedPropertyName */) { return isObjectLiteralPropertyDeclaration(node.parent.parent) ? node.parent.parent : undefined; } // intential fall through - case 69 /* Identifier */: + case 70 /* Identifier */: return isObjectLiteralPropertyDeclaration(node.parent) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -66379,9 +67099,9 @@ var ts; switch (node.kind) { case 253 /* PropertyAssignment */: case 254 /* ShorthandPropertyAssignment */: - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: return true; } return false; @@ -66454,9 +67174,9 @@ var ts; // (1) when the aliased symbol was declared in the location(parent). // (2) when the aliased symbol is originating from a named import. // - if (node.kind === 69 /* Identifier */ && + if (node.kind === 70 /* Identifier */ && (node.parent === declaration || - (declaration.kind === 234 /* ImportSpecifier */ && declaration.parent && declaration.parent.kind === 233 /* NamedImports */))) { + (declaration.kind === 235 /* ImportSpecifier */ && declaration.parent && declaration.parent.kind === 234 /* NamedImports */))) { symbol = typeChecker.getAliasedSymbol(symbol); } } @@ -66523,7 +67243,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 (ts.isNewExpressionTarget(location) || location.kind === 121 /* ConstructorKeyword */) { + if (ts.isNewExpressionTarget(location) || location.kind === 122 /* 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++) { @@ -66548,8 +67268,8 @@ var ts; var declarations = []; var definition; ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 148 /* Constructor */) || - (!selectConstructors && (d.kind === 220 /* FunctionDeclaration */ || d.kind === 147 /* MethodDeclaration */ || d.kind === 146 /* MethodSignature */))) { + if ((selectConstructors && d.kind === 149 /* Constructor */) || + (!selectConstructors && (d.kind === 221 /* FunctionDeclaration */ || d.kind === 148 /* MethodDeclaration */ || d.kind === 147 /* MethodSignature */))) { declarations.push(d); if (d.body) definition = d; @@ -66634,7 +67354,7 @@ var ts; ts.FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result); return result.length > 0 ? result : undefined; } - else if (node.kind === 95 /* SuperKeyword */ || ts.isSuperProperty(node.parent)) { + else if (node.kind === 96 /* SuperKeyword */ || ts.isSuperProperty(node.parent)) { // References to and accesses on the super keyword only have one possible implementation, so no // need to "Find all References" var symbol = typeChecker.getSymbolAtLocation(node); @@ -66702,7 +67422,7 @@ var ts; "version" ]; var jsDocCompletionEntries; - function getJsDocCommentsFromDeclarations(declarations, name, canUseParsedParamTagComments) { + function getJsDocCommentsFromDeclarations(declarations) { // Only collect doc comments from duplicate declarations once: // In case of a union property there might be same declaration multiple times // which only varies in type parameter @@ -66752,7 +67472,7 @@ var ts; name: tagName, kind: ts.ScriptElementKind.keyword, kindModifiers: "", - sortText: "0" + sortText: "0", }; })); } @@ -66795,19 +67515,19 @@ var ts; var commentOwner; findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 220 /* FunctionDeclaration */: - case 147 /* MethodDeclaration */: - case 148 /* Constructor */: - case 221 /* ClassDeclaration */: - case 200 /* VariableStatement */: + case 221 /* FunctionDeclaration */: + case 148 /* MethodDeclaration */: + case 149 /* Constructor */: + case 222 /* ClassDeclaration */: + case 201 /* VariableStatement */: break findOwner; case 256 /* SourceFile */: return undefined; - case 225 /* ModuleDeclaration */: + case 226 /* 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 === 225 /* ModuleDeclaration */) { + if (commentOwner.parent.kind === 226 /* ModuleDeclaration */) { return undefined; } break findOwner; @@ -66823,7 +67543,7 @@ var ts; var docParams = ""; for (var i = 0, numParams = parameters.length; i < numParams; i++) { var currentName = parameters[i].name; - var paramName = currentName.kind === 69 /* Identifier */ ? + var paramName = currentName.kind === 70 /* Identifier */ ? currentName.text : "param" + i; docParams += indentationStr + " * @param " + paramName + newLine; @@ -66848,7 +67568,7 @@ var ts; if (ts.isFunctionLike(commentOwner)) { return commentOwner.parameters; } - if (commentOwner.kind === 200 /* VariableStatement */) { + if (commentOwner.kind === 201 /* VariableStatement */) { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; if (varDeclarations.length === 1 && varDeclarations[0].initializer) { @@ -66866,17 +67586,17 @@ var ts; * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. */ function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 178 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 179 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: return rightHandSide.parameters; - case 192 /* ClassExpression */: + case 193 /* ClassExpression */: for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 148 /* Constructor */) { + if (member.kind === 149 /* Constructor */) { return member.parameters; } } @@ -66911,7 +67631,7 @@ var ts; * @param typingOptions are used to customize the typing inference process * @param compilerOptions are used as a source for typing inference */ - function discoverTypings(host, fileNames, projectRootPath, safeListPath, packageNameToTypingLocation, typingOptions, compilerOptions) { + function discoverTypings(host, fileNames, projectRootPath, safeListPath, packageNameToTypingLocation, typingOptions) { // A typing name to typing file path mapping var inferredTypings = ts.createMap(); if (!typingOptions || !typingOptions.enableAutoDiscovery) { @@ -67079,8 +67799,6 @@ var ts; function getNavigateToItems(sourceFiles, checker, cancellationToken, searchValue, maxResultCount, excludeDtsFiles) { var patternMatcher = ts.createPatternMatcher(searchValue); var rawItems = []; - // This means "compare in a case insensitive manner." - var baseSensitivity = { sensitivity: "base" }; // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] ts.forEach(sourceFiles, function (sourceFile) { cancellationToken.throwIfCancellationRequested(); @@ -67121,7 +67839,7 @@ var ts; // Remove imports when the imported declaration is already in the list and has the same name. rawItems = ts.filter(rawItems, function (item) { var decl = item.declaration; - if (decl.kind === 231 /* ImportClause */ || decl.kind === 234 /* ImportSpecifier */ || decl.kind === 229 /* ImportEqualsDeclaration */) { + if (decl.kind === 232 /* ImportClause */ || decl.kind === 235 /* ImportSpecifier */ || decl.kind === 230 /* ImportEqualsDeclaration */) { var importer = checker.getSymbolAtLocation(decl.name); var imported = checker.getAliasedSymbol(importer); return importer.name !== imported.name; @@ -67149,7 +67867,7 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 69 /* Identifier */ || + if (node.kind === 70 /* Identifier */ || node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { return node.text; @@ -67163,7 +67881,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 140 /* ComputedPropertyName */) { + else if (declaration.name.kind === 141 /* ComputedPropertyName */) { return tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion*/ true); } else { @@ -67184,7 +67902,7 @@ var ts; } return true; } - if (expression.kind === 172 /* PropertyAccessExpression */) { + if (expression.kind === 173 /* PropertyAccessExpression */) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -67197,7 +67915,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 === 140 /* ComputedPropertyName */) { + if (declaration.name.kind === 141 /* ComputedPropertyName */) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion*/ false)) { return undefined; } @@ -67230,8 +67948,8 @@ var ts; // We first sort case insensitively. So "Aaa" will come before "bar". // Then we sort case sensitively, so "aaa" will come before "Aaa". return i1.matchKind - i2.matchKind || - i1.name.localeCompare(i2.name, undefined, baseSensitivity) || - i1.name.localeCompare(i2.name); + ts.compareStringsCaseInsensitive(i1.name, i2.name) || + ts.compareStrings(i1.name, i2.name); } function createNavigateToItem(rawItem) { var declaration = rawItem.declaration; @@ -67350,7 +68068,7 @@ var ts; return; } switch (node.kind) { - case 148 /* Constructor */: + case 149 /* Constructor */: // Get parameter properties, and treat them as being on the *same* level as the constructor, not under it. var ctr = node; addNodeWithRecursiveChild(ctr, ctr.body); @@ -67362,21 +68080,21 @@ var ts; } } break; - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 146 /* MethodSignature */: + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 147 /* MethodSignature */: if (!ts.hasDynamicName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: if (!ts.hasDynamicName(node)) { addLeafNode(node); } break; - case 231 /* ImportClause */: + case 232 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -67388,7 +68106,7 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 232 /* NamespaceImport */) { + if (namedBindings.kind === 233 /* NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -67399,8 +68117,8 @@ var ts; } } break; - case 169 /* BindingElement */: - case 218 /* VariableDeclaration */: + case 170 /* BindingElement */: + case 219 /* VariableDeclaration */: var decl = node; var name_50 = decl.name; if (ts.isBindingPattern(name_50)) { @@ -67414,12 +68132,12 @@ var ts; addNodeWithRecursiveChild(decl, decl.initializer); } break; - case 180 /* ArrowFunction */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: startNode(node); for (var _d = 0, _e = node.members; _d < _e.length; _d++) { var member = _e[_d]; @@ -67429,9 +68147,9 @@ var ts; } endNode(); break; - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - case 222 /* InterfaceDeclaration */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 223 /* InterfaceDeclaration */: startNode(node); for (var _f = 0, _g = node.members; _f < _g.length; _f++) { var member = _g[_f]; @@ -67439,15 +68157,15 @@ var ts; } endNode(); break; - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 238 /* ExportSpecifier */: - case 229 /* ImportEqualsDeclaration */: - case 153 /* IndexSignature */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 223 /* TypeAliasDeclaration */: + case 239 /* ExportSpecifier */: + case 230 /* ImportEqualsDeclaration */: + case 154 /* IndexSignature */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 224 /* TypeAliasDeclaration */: addLeafNode(node); break; default: @@ -67504,14 +68222,14 @@ var ts; }); /** a and b have the same name, but they may not be mergeable. */ function shouldReallyMerge(a, b) { - return a.kind === b.kind && (a.kind !== 225 /* ModuleDeclaration */ || areSameModule(a, b)); + return a.kind === b.kind && (a.kind !== 226 /* ModuleDeclaration */ || areSameModule(a, b)); // We use 1 NavNode to represent 'A.B.C', but there are multiple source nodes. // Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'! function areSameModule(a, b) { if (a.body.kind !== b.body.kind) { return false; } - if (a.body.kind !== 225 /* ModuleDeclaration */) { + if (a.body.kind !== 226 /* ModuleDeclaration */) { return true; } return areSameModule(a.body, b.body); @@ -67546,11 +68264,9 @@ var ts; return name1 ? 1 : name2 ? -1 : navigationBarNodeKind(child1) - navigationBarNodeKind(child2); } } - // More efficient to create a collator once and use its `compare` than to call `a.localeCompare(b)` many times. - var collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; // Intl is missing in Safari, and node 0.10 treats "a" as greater than "B". - var localeCompareIsCorrect = collator && collator.compare("a", "B") < 0; - var localeCompareFix = localeCompareIsCorrect ? collator.compare : function (a, b) { + var localeCompareIsCorrect = ts.collator && ts.collator.compare("a", "B") < 0; + var localeCompareFix = localeCompareIsCorrect ? ts.collator.compare : function (a, b) { // This isn't perfect, but it passes all of our tests. for (var i = 0; i < Math.min(a.length, b.length); i++) { var chA = a.charAt(i), chB = b.charAt(i); @@ -67560,7 +68276,7 @@ var ts; if (chA === "'" && chB === "\"") { return -1; } - var cmp = chA.toLocaleLowerCase().localeCompare(chB.toLocaleLowerCase()); + var cmp = ts.compareStrings(chA.toLocaleLowerCase(), chB.toLocaleLowerCase()); if (cmp !== 0) { return cmp; } @@ -67573,7 +68289,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 225 /* ModuleDeclaration */) { + if (node.kind === 226 /* ModuleDeclaration */) { return getModuleName(node); } var decl = node; @@ -67581,9 +68297,9 @@ var ts; return ts.getPropertyNameForPropertyNameNode(decl.name); } switch (node.kind) { - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: - case 192 /* ClassExpression */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 193 /* ClassExpression */: return getFunctionOrClassName(node); case 279 /* JSDocTypedefTag */: return getJSDocTypedefTagName(node); @@ -67592,7 +68308,7 @@ var ts; } } function getItemName(node) { - if (node.kind === 225 /* ModuleDeclaration */) { + if (node.kind === 226 /* ModuleDeclaration */) { return getModuleName(node); } var name = node.name; @@ -67608,22 +68324,22 @@ var ts; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 180 /* ArrowFunction */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: + case 181 /* ArrowFunction */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: if (ts.getModifierFlags(node) & 512 /* Default */) { return "default"; } return getFunctionOrClassName(node); - case 148 /* Constructor */: + case 149 /* Constructor */: return "constructor"; - case 152 /* ConstructSignature */: + case 153 /* ConstructSignature */: return "new()"; - case 151 /* CallSignature */: + case 152 /* CallSignature */: return "()"; - case 153 /* IndexSignature */: + case 154 /* IndexSignature */: return "[]"; case 279 /* JSDocTypedefTag */: return getJSDocTypedefTagName(node); @@ -67637,10 +68353,10 @@ var ts; } else { var parentNode = node.parent && node.parent.parent; - if (parentNode && parentNode.kind === 200 /* VariableStatement */) { + if (parentNode && parentNode.kind === 201 /* VariableStatement */) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; - if (nameIdentifier.kind === 69 /* Identifier */) { + if (nameIdentifier.kind === 70 /* Identifier */) { return nameIdentifier.text; } } @@ -67666,24 +68382,24 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - case 224 /* EnumDeclaration */: - case 222 /* InterfaceDeclaration */: - case 225 /* ModuleDeclaration */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 225 /* EnumDeclaration */: + case 223 /* InterfaceDeclaration */: + case 226 /* ModuleDeclaration */: case 256 /* SourceFile */: - case 223 /* TypeAliasDeclaration */: + case 224 /* TypeAliasDeclaration */: case 279 /* JSDocTypedefTag */: return true; - case 148 /* Constructor */: - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 218 /* VariableDeclaration */: + case 149 /* Constructor */: + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 219 /* VariableDeclaration */: return hasSomeImportantChild(item); - case 180 /* ArrowFunction */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -67693,10 +68409,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 226 /* ModuleBlock */: + case 227 /* ModuleBlock */: case 256 /* SourceFile */: - case 147 /* MethodDeclaration */: - case 148 /* Constructor */: + case 148 /* MethodDeclaration */: + case 149 /* Constructor */: return true; default: return hasSomeImportantChild(item); @@ -67705,7 +68421,7 @@ var ts; function hasSomeImportantChild(item) { return ts.forEach(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 218 /* VariableDeclaration */ && childKind !== 169 /* BindingElement */; + return childKind !== 219 /* VariableDeclaration */ && childKind !== 170 /* BindingElement */; }); } } @@ -67763,7 +68479,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 === 225 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 226 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -67774,10 +68490,10 @@ var ts; * We store 'A' as associated with a NavNode, and use getModuleName to traverse down again. */ function getInteriorModule(decl) { - return decl.body.kind === 225 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; + return decl.body.kind === 226 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 140 /* ComputedPropertyName */; + return !member.name || member.name.kind === 141 /* ComputedPropertyName */; } function getNodeSpan(node) { return node.kind === 256 /* SourceFile */ @@ -67788,11 +68504,11 @@ var ts; if (node.name && ts.getFullWidth(node.name) > 0) { return ts.declarationNameToString(node.name); } - else if (node.parent.kind === 218 /* VariableDeclaration */) { + else if (node.parent.kind === 219 /* VariableDeclaration */) { return ts.declarationNameToString(node.parent.name); } - else if (node.parent.kind === 187 /* BinaryExpression */ && - node.parent.operatorToken.kind === 56 /* EqualsToken */) { + else if (node.parent.kind === 188 /* BinaryExpression */ && + node.parent.operatorToken.kind === 57 /* EqualsToken */) { return nodeText(node.parent.left); } else if (node.parent.kind === 253 /* PropertyAssignment */ && node.parent.name) { @@ -67806,7 +68522,7 @@ var ts; } } function isFunctionOrClassExpression(node) { - return node.kind === 179 /* FunctionExpression */ || node.kind === 180 /* ArrowFunction */ || node.kind === 192 /* ClassExpression */; + return node.kind === 180 /* FunctionExpression */ || node.kind === 181 /* ArrowFunction */ || node.kind === 193 /* ClassExpression */; } })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); })(ts || (ts = {})); @@ -67882,7 +68598,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 180 /* ArrowFunction */; + return ts.isFunctionBlock(node) && node.parent.kind !== 181 /* ArrowFunction */; } var depth = 0; var maxDepth = 20; @@ -67894,26 +68610,26 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 199 /* Block */: + case 200 /* Block */: if (!ts.isFunctionBlock(n)) { var parent_22 = n.parent; - var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); + var openBrace = ts.findChildOfKind(n, 16 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 17 /* CloseBraceToken */, sourceFile); // Check if the block is standalone, or 'attached' to some parent statement. // If the latter, we want to collapse the block, but consider its hint span // to be the entire span of the parent. - if (parent_22.kind === 204 /* DoStatement */ || - parent_22.kind === 207 /* ForInStatement */ || - parent_22.kind === 208 /* ForOfStatement */ || - parent_22.kind === 206 /* ForStatement */ || - parent_22.kind === 203 /* IfStatement */ || - parent_22.kind === 205 /* WhileStatement */ || - parent_22.kind === 212 /* WithStatement */ || + if (parent_22.kind === 205 /* DoStatement */ || + parent_22.kind === 208 /* ForInStatement */ || + parent_22.kind === 209 /* ForOfStatement */ || + parent_22.kind === 207 /* ForStatement */ || + parent_22.kind === 204 /* IfStatement */ || + parent_22.kind === 206 /* WhileStatement */ || + parent_22.kind === 213 /* WithStatement */ || parent_22.kind === 252 /* CatchClause */) { addOutliningSpan(parent_22, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_22.kind === 216 /* TryStatement */) { + if (parent_22.kind === 217 /* TryStatement */) { // Could be the try-block, or the finally-block. var tryStatement = parent_22; if (tryStatement.tryBlock === n) { @@ -67921,7 +68637,7 @@ var ts; break; } else if (tryStatement.finallyBlock === n) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 85 /* FinallyKeyword */, sourceFile); + var finallyKeyword = ts.findChildOfKind(tryStatement, 86 /* FinallyKeyword */, sourceFile); if (finallyKeyword) { addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); break; @@ -67940,25 +68656,25 @@ var ts; break; } // Fallthrough. - case 226 /* ModuleBlock */: { - var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); + case 227 /* ModuleBlock */: { + var openBrace = ts.findChildOfKind(n, 16 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 17 /* CloseBraceToken */, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 221 /* ClassDeclaration */: - case 222 /* InterfaceDeclaration */: - case 224 /* EnumDeclaration */: - case 171 /* ObjectLiteralExpression */: - case 227 /* CaseBlock */: { - var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); + case 222 /* ClassDeclaration */: + case 223 /* InterfaceDeclaration */: + case 225 /* EnumDeclaration */: + case 172 /* ObjectLiteralExpression */: + case 228 /* CaseBlock */: { + var openBrace = ts.findChildOfKind(n, 16 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 17 /* CloseBraceToken */, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 170 /* ArrayLiteralExpression */: - var openBracket = ts.findChildOfKind(n, 19 /* OpenBracketToken */, sourceFile); - var closeBracket = ts.findChildOfKind(n, 20 /* CloseBracketToken */, sourceFile); + case 171 /* ArrayLiteralExpression */: + var openBracket = ts.findChildOfKind(n, 20 /* OpenBracketToken */, sourceFile); + var closeBracket = ts.findChildOfKind(n, 21 /* CloseBracketToken */, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); break; } @@ -68313,7 +69029,7 @@ var ts; if (ch >= 65 /* A */ && ch <= 90 /* Z */) { return true; } - if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 2 /* Latest */)) { + if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 4 /* Latest */)) { return false; } // TODO: find a way to determine this for any unicode characters in a @@ -68326,7 +69042,7 @@ var ts; if (ch >= 97 /* a */ && ch <= 122 /* z */) { return true; } - if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 2 /* Latest */)) { + if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 4 /* Latest */)) { return false; } // TODO: find a way to determine this for any unicode characters in a @@ -68547,10 +69263,10 @@ var ts; var externalModule = false; function nextToken() { var token = ts.scanner.scan(); - if (token === 15 /* OpenBraceToken */) { + if (token === 16 /* OpenBraceToken */) { braceNesting++; } - else if (token === 16 /* CloseBraceToken */) { + else if (token === 17 /* CloseBraceToken */) { braceNesting--; } return token; @@ -68601,10 +69317,10 @@ var ts; */ function tryConsumeDeclare() { var token = ts.scanner.getToken(); - if (token === 122 /* DeclareKeyword */) { + if (token === 123 /* DeclareKeyword */) { // declare module "mod" token = nextToken(); - if (token === 125 /* ModuleKeyword */) { + if (token === 126 /* ModuleKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { recordAmbientExternalModule(); @@ -68619,7 +69335,7 @@ var ts; */ function tryConsumeImport() { var token = ts.scanner.getToken(); - if (token === 89 /* ImportKeyword */) { + if (token === 90 /* ImportKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import "mod"; @@ -68627,9 +69343,9 @@ var ts; return true; } else { - if (token === 69 /* Identifier */ || ts.isKeyword(token)) { + if (token === 70 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 136 /* FromKeyword */) { + if (token === 137 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import d from "mod"; @@ -68637,12 +69353,12 @@ var ts; return true; } } - else if (token === 56 /* EqualsToken */) { + else if (token === 57 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } } - else if (token === 24 /* CommaToken */) { + else if (token === 25 /* CommaToken */) { // consume comma and keep going token = nextToken(); } @@ -68651,16 +69367,16 @@ var ts; return true; } } - if (token === 15 /* OpenBraceToken */) { + if (token === 16 /* OpenBraceToken */) { token = nextToken(); // consume "{ a as B, c, d as D}" clauses // make sure that it stops on EOF - while (token !== 16 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 17 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { token = nextToken(); } - if (token === 16 /* CloseBraceToken */) { + if (token === 17 /* CloseBraceToken */) { token = nextToken(); - if (token === 136 /* FromKeyword */) { + if (token === 137 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import {a as A} from "mod"; @@ -68670,13 +69386,13 @@ var ts; } } } - else if (token === 37 /* AsteriskToken */) { + else if (token === 38 /* AsteriskToken */) { token = nextToken(); - if (token === 116 /* AsKeyword */) { + if (token === 117 /* AsKeyword */) { token = nextToken(); - if (token === 69 /* Identifier */ || ts.isKeyword(token)) { + if (token === 70 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 136 /* FromKeyword */) { + if (token === 137 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import * as NS from "mod" @@ -68694,19 +69410,19 @@ var ts; } function tryConsumeExport() { var token = ts.scanner.getToken(); - if (token === 82 /* ExportKeyword */) { + if (token === 83 /* ExportKeyword */) { markAsExternalModuleIfTopLevel(); token = nextToken(); - if (token === 15 /* OpenBraceToken */) { + if (token === 16 /* OpenBraceToken */) { token = nextToken(); // consume "{ a as B, c, d as D}" clauses // make sure it stops on EOF - while (token !== 16 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 17 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { token = nextToken(); } - if (token === 16 /* CloseBraceToken */) { + if (token === 17 /* CloseBraceToken */) { token = nextToken(); - if (token === 136 /* FromKeyword */) { + if (token === 137 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // export {a as A} from "mod"; @@ -68716,9 +69432,9 @@ var ts; } } } - else if (token === 37 /* AsteriskToken */) { + else if (token === 38 /* AsteriskToken */) { token = nextToken(); - if (token === 136 /* FromKeyword */) { + if (token === 137 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // export * from "mod" @@ -68726,11 +69442,11 @@ var ts; } } } - else if (token === 89 /* ImportKeyword */) { + else if (token === 90 /* ImportKeyword */) { token = nextToken(); - if (token === 69 /* Identifier */ || ts.isKeyword(token)) { + if (token === 70 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 56 /* EqualsToken */) { + if (token === 57 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } @@ -68743,9 +69459,9 @@ var ts; } function tryConsumeRequireCall(skipCurrentToken) { var token = skipCurrentToken ? nextToken() : ts.scanner.getToken(); - if (token === 129 /* RequireKeyword */) { + if (token === 130 /* RequireKeyword */) { token = nextToken(); - if (token === 17 /* OpenParenToken */) { + if (token === 18 /* OpenParenToken */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // require("mod"); @@ -68758,16 +69474,16 @@ var ts; } function tryConsumeDefine() { var token = ts.scanner.getToken(); - if (token === 69 /* Identifier */ && ts.scanner.getTokenValue() === "define") { + if (token === 70 /* Identifier */ && ts.scanner.getTokenValue() === "define") { token = nextToken(); - if (token !== 17 /* OpenParenToken */) { + if (token !== 18 /* OpenParenToken */) { return true; } token = nextToken(); if (token === 9 /* StringLiteral */) { // looks like define ("modname", ... - skip string literal and comma token = nextToken(); - if (token === 24 /* CommaToken */) { + if (token === 25 /* CommaToken */) { token = nextToken(); } else { @@ -68776,14 +69492,14 @@ var ts; } } // should be start of dependency list - if (token !== 19 /* OpenBracketToken */) { + if (token !== 20 /* OpenBracketToken */) { return true; } // skip open bracket token = nextToken(); var i = 0; // scan until ']' or EOF - while (token !== 20 /* CloseBracketToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 21 /* CloseBracketToken */ && token !== 1 /* EndOfFileToken */) { // record string literals as module names if (token === 9 /* StringLiteral */) { recordModuleName(); @@ -68873,7 +69589,7 @@ var ts; var canonicalDefaultLibName = getCanonicalFileName(ts.normalizePath(defaultLibFileName)); var node = ts.getTouchingWord(sourceFile, position, /*includeJsDocComment*/ true); if (node) { - if (node.kind === 69 /* Identifier */ || + if (node.kind === 70 /* Identifier */ || node.kind === 9 /* StringLiteral */ || ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || ts.isThis(node)) { @@ -69134,15 +69850,15 @@ var ts; } SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; function createJavaScriptSignatureHelpItems(argumentInfo, program) { - if (argumentInfo.invocation.kind !== 174 /* CallExpression */) { + if (argumentInfo.invocation.kind !== 175 /* 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 === 69 /* Identifier */ + var name = expression.kind === 70 /* Identifier */ ? expression - : expression.kind === 172 /* PropertyAccessExpression */ + : expression.kind === 173 /* PropertyAccessExpression */ ? expression.name : undefined; if (!name || !name.text) { @@ -69175,7 +69891,7 @@ var ts; * in the argument of an invocation; returns undefined otherwise. */ function getImmediatelyContainingArgumentInfo(node, position, sourceFile) { - if (node.parent.kind === 174 /* CallExpression */ || node.parent.kind === 175 /* NewExpression */) { + if (node.parent.kind === 175 /* CallExpression */ || node.parent.kind === 176 /* NewExpression */) { var callExpression = node.parent; // There are 3 cases to handle: // 1. The token introduces a list, and should begin a sig help session @@ -69191,8 +69907,8 @@ var ts; // Case 3: // foo(a#, #b#) -> The token is buried inside a list, and should give sig help // Find out if 'node' is an argument, a type argument, or neither - if (node.kind === 25 /* LessThanToken */ || - node.kind === 17 /* OpenParenToken */) { + if (node.kind === 26 /* LessThanToken */ || + node.kind === 18 /* OpenParenToken */) { // Find the list that starts right *after* the < or ( token. // If the user has just opened a list, consider this item 0. var list = getChildListThatStartsWithOpenerToken(callExpression, node, sourceFile); @@ -69229,27 +69945,27 @@ var ts; } return undefined; } - else if (node.kind === 11 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 176 /* TaggedTemplateExpression */) { + else if (node.kind === 12 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 177 /* 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, sourceFile); } } - else if (node.kind === 12 /* TemplateHead */ && node.parent.parent.kind === 176 /* TaggedTemplateExpression */) { + else if (node.kind === 13 /* TemplateHead */ && node.parent.parent.kind === 177 /* TaggedTemplateExpression */) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 189 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 190 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } - else if (node.parent.kind === 197 /* TemplateSpan */ && node.parent.parent.parent.kind === 176 /* TaggedTemplateExpression */) { + else if (node.parent.kind === 198 /* TemplateSpan */ && node.parent.parent.parent.kind === 177 /* TaggedTemplateExpression */) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 189 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 190 /* TemplateExpression */); // If we're just after a template tail, don't show signature help. - if (node.kind === 14 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { + if (node.kind === 15 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { return undefined; } var spanIndex = templateExpression.templateSpans.indexOf(templateSpan); @@ -69277,7 +69993,7 @@ var ts; if (child === node) { break; } - if (child.kind !== 24 /* CommaToken */) { + if (child.kind !== 25 /* CommaToken */) { argumentIndex++; } } @@ -69296,8 +70012,8 @@ var ts; // That will give us 2 non-commas. We then add one for the last comma, givin us an // arg count of 3. var listChildren = argumentsList.getChildren(); - var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 24 /* CommaToken */; }); - if (listChildren.length > 0 && ts.lastOrUndefined(listChildren).kind === 24 /* CommaToken */) { + var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 25 /* CommaToken */; }); + if (listChildren.length > 0 && ts.lastOrUndefined(listChildren).kind === 25 /* CommaToken */) { argumentCount++; } return argumentCount; @@ -69327,7 +70043,7 @@ var ts; } function getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile) { // argumentCount is either 1 or (numSpans + 1) to account for the template strings array argument. - var argumentCount = tagExpression.template.kind === 11 /* NoSubstitutionTemplateLiteral */ + var argumentCount = tagExpression.template.kind === 12 /* NoSubstitutionTemplateLiteral */ ? 1 : tagExpression.template.templateSpans.length + 1; ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); @@ -69365,7 +70081,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 === 189 /* TemplateExpression */) { + if (template.kind === 190 /* TemplateExpression */) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -69435,10 +70151,10 @@ var ts; ts.addRange(prefixDisplayParts, callTargetDisplayParts); } if (isTypeParameterList) { - prefixDisplayParts.push(ts.punctuationPart(25 /* LessThanToken */)); + prefixDisplayParts.push(ts.punctuationPart(26 /* LessThanToken */)); var typeParameters = candidateSignature.typeParameters; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(27 /* GreaterThanToken */)); + suffixDisplayParts.push(ts.punctuationPart(28 /* GreaterThanToken */)); var parameterParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.thisParameter, candidateSignature.parameters, writer, invocation); }); @@ -69449,10 +70165,10 @@ var ts; return typeChecker.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation); }); ts.addRange(prefixDisplayParts, typeParameterParts); - prefixDisplayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); + prefixDisplayParts.push(ts.punctuationPart(18 /* OpenParenToken */)); var parameters = candidateSignature.parameters; signatureHelpParameters = parameters.length > 0 ? ts.map(parameters, createSignatureHelpParameterForParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); + suffixDisplayParts.push(ts.punctuationPart(19 /* CloseParenToken */)); } var returnTypeParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation); @@ -69462,7 +70178,7 @@ var ts; isVariadic: candidateSignature.hasRestParameter, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: suffixDisplayParts, - separatorDisplayParts: [ts.punctuationPart(24 /* CommaToken */), ts.spacePart()], + separatorDisplayParts: [ts.punctuationPart(25 /* CommaToken */), ts.spacePart()], parameters: signatureHelpParameters, documentation: candidateSignature.getDocumentationComment() }; @@ -69516,7 +70232,7 @@ var ts; function getSymbolKind(typeChecker, symbol, location) { var flags = symbol.getFlags(); if (flags & 32 /* Class */) - return ts.getDeclarationOfKind(symbol, 192 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 193 /* ClassExpression */) ? ts.ScriptElementKind.localClassElement : ts.ScriptElementKind.classElement; if (flags & 384 /* Enum */) return ts.ScriptElementKind.enumElement; @@ -69547,7 +70263,7 @@ var ts; if (typeChecker.isArgumentsSymbol(symbol)) { return ts.ScriptElementKind.localVariableElement; } - if (location.kind === 97 /* ThisKeyword */ && ts.isExpression(location)) { + if (location.kind === 98 /* ThisKeyword */ && ts.isExpression(location)) { return ts.ScriptElementKind.parameterElement; } if (flags & 3 /* Variable */) { @@ -69611,7 +70327,7 @@ var ts; var symbolFlags = symbol.flags; var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, symbolFlags, location); var hasAddedSymbolInfo; - var isThisExpression = location.kind === 97 /* ThisKeyword */ && ts.isExpression(location); + var isThisExpression = location.kind === 98 /* ThisKeyword */ && ts.isExpression(location); var type; // Class at constructor site need to be shown as constructor apart from property,method, vars if (symbolKind !== ts.ScriptElementKind.unknown || symbolFlags & 32 /* Class */ || symbolFlags & 8388608 /* Alias */) { @@ -69622,7 +70338,7 @@ var ts; var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 172 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 173 /* 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)) { @@ -69631,7 +70347,7 @@ var ts; } // try get the call/construct signature from the type if it matches var callExpression = void 0; - if (location.kind === 174 /* CallExpression */ || location.kind === 175 /* NewExpression */) { + if (location.kind === 175 /* CallExpression */ || location.kind === 176 /* NewExpression */) { callExpression = location; } else if (ts.isCallExpressionTarget(location) || ts.isNewExpressionTarget(location)) { @@ -69644,7 +70360,7 @@ var ts; // Use the first candidate: signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 175 /* NewExpression */ || callExpression.expression.kind === 95 /* SuperKeyword */; + var useConstructSignatures = callExpression.kind === 176 /* NewExpression */ || callExpression.expression.kind === 96 /* SuperKeyword */; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { // Get the first signature if there is one -- allSignatures may contain @@ -69662,7 +70378,7 @@ var ts; pushTypePart(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(92 /* NewKeyword */)); + displayParts.push(ts.keywordPart(93 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -69678,10 +70394,10 @@ var ts; case ts.ScriptElementKind.parameterElement: case ts.ScriptElementKind.localVariableElement: // If it is call or construct signature of lambda's write type name - displayParts.push(ts.punctuationPart(54 /* ColonToken */)); + displayParts.push(ts.punctuationPart(55 /* ColonToken */)); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(92 /* NewKeyword */)); + displayParts.push(ts.keywordPart(93 /* NewKeyword */)); displayParts.push(ts.spacePart()); } if (!(type.flags & 2097152 /* Anonymous */) && type.symbol) { @@ -69697,24 +70413,24 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304 /* Accessor */)) || - (location.kind === 121 /* ConstructorKeyword */ && location.parent.kind === 148 /* Constructor */)) { + (location.kind === 122 /* ConstructorKeyword */ && location.parent.kind === 149 /* Constructor */)) { // get the signature from the declaration and write it var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 148 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration.kind === 149 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 148 /* Constructor */) { + if (functionDeclaration.kind === 149 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = ts.ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 151 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 152 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -69723,7 +70439,7 @@ var ts; } } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { - if (ts.getDeclarationOfKind(symbol, 192 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 193 /* 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 @@ -69731,7 +70447,7 @@ var ts; } else { // Class declaration has name which is not local. - displayParts.push(ts.keywordPart(73 /* ClassKeyword */)); + displayParts.push(ts.keywordPart(74 /* ClassKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); @@ -69739,49 +70455,49 @@ var ts; } if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(107 /* InterfaceKeyword */)); + displayParts.push(ts.keywordPart(108 /* InterfaceKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if (symbolFlags & 524288 /* TypeAlias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(134 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(135 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(56 /* EqualsToken */)); + displayParts.push(ts.operatorPart(57 /* EqualsToken */)); displayParts.push(ts.spacePart()); ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 512 /* InTypeAlias */)); } if (symbolFlags & 384 /* Enum */) { addNewLineIfDisplayPartsExist(); if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { - displayParts.push(ts.keywordPart(74 /* ConstKeyword */)); + displayParts.push(ts.keywordPart(75 /* ConstKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(81 /* EnumKeyword */)); + displayParts.push(ts.keywordPart(82 /* EnumKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536 /* Module */) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 225 /* ModuleDeclaration */); - var isNamespace = declaration && declaration.name && declaration.name.kind === 69 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 126 /* NamespaceKeyword */ : 125 /* ModuleKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 226 /* ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 70 /* Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 127 /* NamespaceKeyword */ : 126 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if ((symbolFlags & 262144 /* TypeParameter */) && (semanticMeaning & 2 /* Type */)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(18 /* OpenParenToken */)); displayParts.push(ts.textPart("type parameter")); - displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(19 /* CloseParenToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(90 /* InKeyword */)); + displayParts.push(ts.keywordPart(91 /* InKeyword */)); displayParts.push(ts.spacePart()); if (symbol.parent) { // Class/Interface type parameter @@ -69790,17 +70506,17 @@ var ts; } else { // Method/function type parameter - var declaration = ts.getDeclarationOfKind(symbol, 141 /* TypeParameter */); + var declaration = ts.getDeclarationOfKind(symbol, 142 /* TypeParameter */); ts.Debug.assert(declaration !== undefined); declaration = declaration.parent; if (declaration) { if (ts.isFunctionLikeKind(declaration.kind)) { var signature = typeChecker.getSignatureFromDeclaration(declaration); - if (declaration.kind === 152 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(92 /* NewKeyword */)); + if (declaration.kind === 153 /* ConstructSignature */) { + displayParts.push(ts.keywordPart(93 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 151 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 152 /* CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); @@ -69809,7 +70525,7 @@ var ts; // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path - displayParts.push(ts.keywordPart(134 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(135 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -69824,7 +70540,7 @@ var ts; var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(56 /* EqualsToken */)); + displayParts.push(ts.operatorPart(57 /* EqualsToken */)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(constantValue.toString(), ts.SymbolDisplayPartKind.numericLiteral)); } @@ -69832,33 +70548,33 @@ var ts; } if (symbolFlags & 8388608 /* Alias */) { addNewLineIfDisplayPartsExist(); - if (symbol.declarations[0].kind === 228 /* NamespaceExportDeclaration */) { - displayParts.push(ts.keywordPart(82 /* ExportKeyword */)); + if (symbol.declarations[0].kind === 229 /* NamespaceExportDeclaration */) { + displayParts.push(ts.keywordPart(83 /* ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(126 /* NamespaceKeyword */)); + displayParts.push(ts.keywordPart(127 /* NamespaceKeyword */)); } else { - displayParts.push(ts.keywordPart(89 /* ImportKeyword */)); + displayParts.push(ts.keywordPart(90 /* ImportKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 229 /* ImportEqualsDeclaration */) { + if (declaration.kind === 230 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(56 /* EqualsToken */)); + displayParts.push(ts.operatorPart(57 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(129 /* RequireKeyword */)); - displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); + displayParts.push(ts.keywordPart(130 /* RequireKeyword */)); + displayParts.push(ts.punctuationPart(18 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); - displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(19 /* CloseParenToken */)); } else { var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(56 /* EqualsToken */)); + displayParts.push(ts.operatorPart(57 /* EqualsToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -69872,7 +70588,7 @@ var ts; if (type) { if (isThisExpression) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(97 /* ThisKeyword */)); + displayParts.push(ts.keywordPart(98 /* ThisKeyword */)); } else { addPrefixForAnyFunctionOrVar(symbol, symbolKind); @@ -69882,7 +70598,7 @@ var ts; symbolFlags & 3 /* Variable */ || symbolKind === ts.ScriptElementKind.localVariableElement || isThisExpression) { - displayParts.push(ts.punctuationPart(54 /* ColonToken */)); + displayParts.push(ts.punctuationPart(55 /* ColonToken */)); displayParts.push(ts.spacePart()); // If the type is type parameter, format it specially if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) { @@ -69919,7 +70635,7 @@ var ts; if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 256 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 187 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 188 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -69962,9 +70678,9 @@ var ts; displayParts.push(ts.textOrKeywordPart(symbolKind)); return; default: - displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(18 /* OpenParenToken */)); displayParts.push(ts.textOrKeywordPart(symbolKind)); - displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(19 /* CloseParenToken */)); return; } } @@ -69972,12 +70688,12 @@ var ts; ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32 /* WriteTypeArgumentsOfSignature */)); if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); - displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); - displayParts.push(ts.operatorPart(35 /* PlusToken */)); + displayParts.push(ts.punctuationPart(18 /* OpenParenToken */)); + displayParts.push(ts.operatorPart(36 /* PlusToken */)); displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), ts.SymbolDisplayPartKind.numericLiteral)); displayParts.push(ts.spacePart()); displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); - displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(19 /* CloseParenToken */)); } documentation = signature.getDocumentationComment(); } @@ -69995,16 +70711,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 179 /* FunctionExpression */) { + if (declaration.kind === 180 /* FunctionExpression */) { return true; } - if (declaration.kind !== 218 /* VariableDeclaration */ && declaration.kind !== 220 /* FunctionDeclaration */) { + if (declaration.kind !== 219 /* VariableDeclaration */ && declaration.kind !== 221 /* FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable for (var parent_23 = declaration.parent; !ts.isFunctionBlock(parent_23); parent_23 = parent_23.parent) { // Reached source file or module block - if (parent_23.kind === 256 /* SourceFile */ || parent_23.kind === 226 /* ModuleBlock */) { + if (parent_23.kind === 256 /* SourceFile */ || parent_23.kind === 227 /* ModuleBlock */) { return false; } } @@ -70065,8 +70781,8 @@ var ts; var sourceMapText; // Create a compilerHost object to allow the compiler to read and write files var compilerHost = { - getSourceFile: function (fileName, target) { return fileName === ts.normalizePath(inputFileName) ? sourceFile : undefined; }, - writeFile: function (name, text, writeByteOrderMark) { + getSourceFile: function (fileName) { return fileName === ts.normalizePath(inputFileName) ? sourceFile : undefined; }, + writeFile: function (name, text) { if (ts.fileExtensionIs(name, ".map")) { ts.Debug.assert(sourceMapText === undefined, "Unexpected multiple source map outputs for the file '" + name + "'"); sourceMapText = text; @@ -70082,9 +70798,9 @@ var ts; getCurrentDirectory: function () { return ""; }, getNewLine: function () { return newLine; }, fileExists: function (fileName) { return fileName === inputFileName; }, - readFile: function (fileName) { return ""; }, - directoryExists: function (directoryExists) { return true; }, - getDirectories: function (path) { return []; } + readFile: function () { return ""; }, + directoryExists: function () { return true; }, + getDirectories: function () { return []; } }; var program = ts.createProgram([inputFileName], options, compilerHost); if (transpileOptions.reportDiagnostics) { @@ -70146,8 +70862,8 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var standardScanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); - var jsxScanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false, 1 /* JSX */); + var standardScanner = ts.createScanner(4 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); + var jsxScanner = ts.createScanner(4 /* Latest */, /*skipTrivia*/ false, 1 /* JSX */); /** * Scanner that is currently used for formatting */ @@ -70162,7 +70878,7 @@ var ts; ScanAction[ScanAction["RescanJsxText"] = 5] = "RescanJsxText"; })(ScanAction || (ScanAction = {})); function getFormattingScanner(sourceFile, startPos, endPos) { - ts.Debug.assert(scanner === undefined); + ts.Debug.assert(scanner === undefined, "Scanner should be undefined"); scanner = sourceFile.languageVariant === 1 /* JSX */ ? jsxScanner : standardScanner; scanner.setText(sourceFile.text); scanner.setTextPos(startPos); @@ -70187,7 +70903,7 @@ var ts; } }; function advance() { - ts.Debug.assert(scanner !== undefined); + ts.Debug.assert(scanner !== undefined, "Scanner should be present"); lastTokenInfo = undefined; var isStarted = scanner.getStartPos() !== startPos; if (isStarted) { @@ -70229,11 +70945,11 @@ var ts; function shouldRescanGreaterThanToken(node) { if (node) { switch (node.kind) { - case 29 /* GreaterThanEqualsToken */: - case 64 /* GreaterThanGreaterThanEqualsToken */: - case 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 45 /* GreaterThanGreaterThanGreaterThanToken */: - case 44 /* GreaterThanGreaterThanToken */: + case 30 /* GreaterThanEqualsToken */: + case 65 /* GreaterThanGreaterThanEqualsToken */: + case 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 46 /* GreaterThanGreaterThanGreaterThanToken */: + case 45 /* GreaterThanGreaterThanToken */: return true; } } @@ -70243,26 +70959,26 @@ var ts; if (node.parent) { switch (node.parent.kind) { case 246 /* JsxAttribute */: - case 243 /* JsxOpeningElement */: + case 244 /* JsxOpeningElement */: case 245 /* JsxClosingElement */: - case 242 /* JsxSelfClosingElement */: - return node.kind === 69 /* Identifier */; + case 243 /* JsxSelfClosingElement */: + return node.kind === 70 /* Identifier */; } } return false; } function shouldRescanJsxText(node) { - return node && node.kind === 244 /* JsxText */; + return node && node.kind === 10 /* JsxText */; } function shouldRescanSlashToken(container) { - return container.kind === 10 /* RegularExpressionLiteral */; + return container.kind === 11 /* RegularExpressionLiteral */; } function shouldRescanTemplateToken(container) { - return container.kind === 13 /* TemplateMiddle */ || - container.kind === 14 /* TemplateTail */; + return container.kind === 14 /* TemplateMiddle */ || + container.kind === 15 /* TemplateTail */; } function startsWithSlashToken(t) { - return t === 39 /* SlashToken */ || t === 61 /* SlashEqualsToken */; + return t === 40 /* SlashToken */ || t === 62 /* SlashEqualsToken */; } function readTokenInfo(n) { ts.Debug.assert(scanner !== undefined); @@ -70303,7 +71019,7 @@ var ts; scanner.scan(); } var currentToken = scanner.getToken(); - if (expectedScanAction === 1 /* RescanGreaterThanToken */ && currentToken === 27 /* GreaterThanToken */) { + if (expectedScanAction === 1 /* RescanGreaterThanToken */ && currentToken === 28 /* GreaterThanToken */) { currentToken = scanner.reScanGreaterToken(); ts.Debug.assert(n.kind === currentToken); lastScanAction = 1 /* RescanGreaterThanToken */; @@ -70313,11 +71029,11 @@ var ts; ts.Debug.assert(n.kind === currentToken); lastScanAction = 2 /* RescanSlashToken */; } - else if (expectedScanAction === 3 /* RescanTemplateToken */ && currentToken === 16 /* CloseBraceToken */) { + else if (expectedScanAction === 3 /* RescanTemplateToken */ && currentToken === 17 /* CloseBraceToken */) { currentToken = scanner.reScanTemplateToken(); lastScanAction = 3 /* RescanTemplateToken */; } - else if (expectedScanAction === 4 /* RescanJsxIdentifier */ && currentToken === 69 /* Identifier */) { + else if (expectedScanAction === 4 /* RescanJsxIdentifier */ && currentToken === 70 /* Identifier */) { currentToken = scanner.scanJsxIdentifier(); lastScanAction = 4 /* RescanJsxIdentifier */; } @@ -70460,8 +71176,8 @@ var ts; return startLine === endLine; }; FormattingContext.prototype.BlockIsOnOneLine = function (node) { - var openBrace = ts.findChildOfKind(node, 15 /* OpenBraceToken */, this.sourceFile); - var closeBrace = ts.findChildOfKind(node, 16 /* CloseBraceToken */, this.sourceFile); + var openBrace = ts.findChildOfKind(node, 16 /* OpenBraceToken */, this.sourceFile); + var closeBrace = ts.findChildOfKind(node, 17 /* CloseBraceToken */, this.sourceFile); if (openBrace && closeBrace) { var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line; var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line; @@ -70649,125 +71365,125 @@ var ts; this.IgnoreBeforeComment = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.Comments), formatting.RuleOperation.create1(1 /* Ignore */)); 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.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54 /* ColonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 24 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 55 /* ColonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(55 /* ColonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 2 /* Space */)); + this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsConditionalOperatorContext), 2 /* Space */)); + this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 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.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2 /* Space */)); + this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* CloseBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, 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 */, 80 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 104 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 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.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* CloseBraceToken */, 81 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* CloseBraceToken */, 105 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* CloseBraceToken */, formatting.Shared.TokenRange.FromTokens([19 /* CloseParenToken */, 21 /* CloseBracketToken */, 25 /* CommaToken */, 24 /* SemicolonToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 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.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(21 /* DotToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 22 /* DotToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(22 /* DotToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // No space before and after indexer - this.NoSpaceBeforeOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19 /* OpenBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20 /* CloseBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), 8 /* Delete */)); + this.NoSpaceBeforeOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* OpenBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(21 /* CloseBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), 8 /* Delete */)); // Place a space before open brace in a function declaration 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 */); + this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 16 /* 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([69 /* Identifier */, 3 /* MultiLineCommentTrivia */, 73 /* ClassKeyword */, 82 /* ExportKeyword */, 89 /* ImportKeyword */]); - 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 */); + this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([70 /* Identifier */, 3 /* MultiLineCommentTrivia */, 74 /* ClassKeyword */, 83 /* ExportKeyword */, 90 /* ImportKeyword */]); + this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 16 /* 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 */, 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 */); + this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([19 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 80 /* DoKeyword */, 101 /* TryKeyword */, 86 /* FinallyKeyword */, 81 /* ElseKeyword */]); + this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 16 /* 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 */)); - this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); - this.NoSpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 8 /* Delete */)); - this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* OpenBraceToken */, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectContext), 8 /* Delete */)); + this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); + this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); + this.NoSpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 8 /* Delete */)); + this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* OpenBraceToken */, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectContext), 8 /* Delete */)); // Insert new line after { and before } in multi-line contexts. - this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); + this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); // For functions and control block place } on a new line [multi-line rule] - this.NewLineBeforeCloseBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.AnyIncludingMultilineComments, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); + this.NewLineBeforeCloseBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.AnyIncludingMultilineComments, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); // Special handling of unary operators. // 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.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(41 /* PlusPlusToken */, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(42 /* MinusMinusToken */, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 41 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 42 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(42 /* PlusPlusToken */, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(43 /* MinusMinusToken */, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 42 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 43 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 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(41 /* PlusPlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 41 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(42 /* MinusMinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 42 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - 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.IsNonJsxSameLineTokenContext), 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.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */)); - 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.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 8 /* Delete */)); - this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(103 /* VoidKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsVoidOpContext), 2 /* Space */)); - this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(94 /* ReturnKeyword */, 23 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(42 /* PlusPlusToken */, 36 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* PlusToken */, 36 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* PlusToken */, 42 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(43 /* MinusMinusToken */, 37 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(37 /* MinusToken */, 37 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(37 /* MinusToken */, 43 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 25 /* CommaToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([103 /* VarKeyword */, 99 /* ThrowKeyword */, 93 /* NewKeyword */, 79 /* DeleteKeyword */, 95 /* ReturnKeyword */, 102 /* TypeOfKeyword */, 120 /* AwaitKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([109 /* LetKeyword */, 75 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */)); + this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */)); + this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(88 /* 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, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 8 /* Delete */)); + this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(104 /* VoidKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsVoidOpContext), 2 /* Space */)); + this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(95 /* ReturnKeyword */, 24 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 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 */, 79 /* DoKeyword */, 80 /* ElseKeyword */, 71 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNotForContext), 2 /* Space */)); + this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([19 /* CloseParenToken */, 80 /* DoKeyword */, 81 /* ElseKeyword */, 72 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, 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([100 /* TryKeyword */, 85 /* FinallyKeyword */]), 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([101 /* TryKeyword */, 86 /* FinallyKeyword */]), 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // get x() {} // set x(val) {} - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123 /* GetKeyword */, 131 /* SetKeyword */]), 69 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([124 /* GetKeyword */, 132 /* SetKeyword */]), 70 /* 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.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, 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(121 /* ConstructorKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(122 /* ConstructorKeyword */, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 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([125 /* ModuleKeyword */, 129 /* RequireKeyword */]), 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([126 /* ModuleKeyword */, 130 /* RequireKeyword */]), 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // Add a space around certain TypeScript keywords - 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 */, 131 /* SetKeyword */, 113 /* StaticKeyword */, 134 /* TypeKeyword */, 136 /* FromKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([83 /* ExtendsKeyword */, 106 /* ImplementsKeyword */, 136 /* FromKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116 /* AbstractKeyword */, 74 /* ClassKeyword */, 123 /* DeclareKeyword */, 78 /* DefaultKeyword */, 82 /* EnumKeyword */, 83 /* ExportKeyword */, 84 /* ExtendsKeyword */, 124 /* GetKeyword */, 107 /* ImplementsKeyword */, 90 /* ImportKeyword */, 108 /* InterfaceKeyword */, 126 /* ModuleKeyword */, 127 /* NamespaceKeyword */, 111 /* PrivateKeyword */, 113 /* PublicKeyword */, 112 /* ProtectedKeyword */, 132 /* SetKeyword */, 114 /* StaticKeyword */, 135 /* TypeKeyword */, 137 /* FromKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([84 /* ExtendsKeyword */, 107 /* ImplementsKeyword */, 137 /* FromKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 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 */)); + this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9 /* StringLiteral */, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); // Lambda expressions - this.SpaceBeforeArrow = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 34 /* EqualsGreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(34 /* EqualsGreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeArrow = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 35 /* EqualsGreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(35 /* EqualsGreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // Optional parameters and let args - this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(22 /* DotDotDotToken */, 69 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 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.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(23 /* DotDotDotToken */, 70 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([19 /* CloseParenToken */, 25 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); - this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(18 /* CloseParenToken */, 25 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); - this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(25 /* LessThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 27 /* GreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); - this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(27 /* GreaterThanToken */, formatting.Shared.TokenRange.FromTokens([17 /* OpenParenToken */, 19 /* OpenBracketToken */, 27 /* GreaterThanToken */, 24 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 26 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(19 /* CloseParenToken */, 26 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(26 /* LessThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 28 /* GreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(28 /* GreaterThanToken */, formatting.Shared.TokenRange.FromTokens([18 /* OpenParenToken */, 20 /* OpenBracketToken */, 28 /* GreaterThanToken */, 25 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); // 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.IsNonJsxSameLineTokenContext, Rules.IsObjectTypeContext), 8 /* Delete */)); + this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* OpenBraceToken */, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectTypeContext), 8 /* Delete */)); // decorators - this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 55 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(55 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 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 */, 131 /* 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.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */)); + this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 56 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(56 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([116 /* AbstractKeyword */, 70 /* Identifier */, 83 /* ExportKeyword */, 78 /* DefaultKeyword */, 74 /* ClassKeyword */, 114 /* StaticKeyword */, 113 /* PublicKeyword */, 111 /* PrivateKeyword */, 112 /* ProtectedKeyword */, 124 /* GetKeyword */, 132 /* SetKeyword */, 20 /* OpenBracketToken */, 38 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); + this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(88 /* FunctionKeyword */, 38 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); + this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(38 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([70 /* Identifier */, 18 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); + this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(115 /* YieldKeyword */, 38 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); + this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([115 /* YieldKeyword */, 38 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */)); // Async-await - this.SpaceBetweenAsyncAndOpenParen = new formatting.Rule(formatting.RuleDescriptor.create1(118 /* AsyncKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(118 /* AsyncKeyword */, 87 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenAsyncAndOpenParen = new formatting.Rule(formatting.RuleDescriptor.create1(119 /* AsyncKeyword */, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(119 /* AsyncKeyword */, 88 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // template string - this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(69 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(70 /* Identifier */, formatting.Shared.TokenRange.FromTokens([12 /* NoSubstitutionTemplateLiteral */, 13 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // jsx opening element - this.SpaceBeforeJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 69 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNextTokenParentJsxAttribute, Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeSlashInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 39 /* SlashToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create1(39 /* SlashToken */, 27 /* GreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 56 /* EqualsToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create3(56 /* EqualsToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceBeforeJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 70 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNextTokenParentJsxAttribute, Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeSlashInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 40 /* SlashToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create1(40 /* SlashToken */, 28 /* GreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 57 /* EqualsToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create3(57 /* EqualsToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // These rules are higher in priority than user-configurable rules. this.HighPriorityCommonRules = [ this.IgnoreBeforeComment, this.IgnoreAfterLineComment, @@ -70829,54 +71545,54 @@ var ts; /// Rules controlled by user options /// // Insert space after comma delimiter - this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNextTokenNotCloseBracket), 2 /* Space */)); - this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext), 8 /* Delete */)); + this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(25 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNextTokenNotCloseBracket), 2 /* Space */)); + this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(25 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext), 8 /* Delete */)); // Insert space before and after binary operators this.SpaceBeforeBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.SpaceAfterBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.NoSpaceBeforeBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 8 /* Delete */)); this.NoSpaceAfterBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 8 /* Delete */)); // Insert space after keywords in control flow statements - this.SpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 2 /* Space */)); - this.NoSpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 8 /* Delete */)); + this.SpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 2 /* Space */)); + this.NoSpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 8 /* Delete */)); // Open Brace braces after function // TypeScript: Function can have return types, which can be made of tons of different token kinds - this.NewLineBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); + this.NewLineBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); // Open Brace braces after TypeScript module/class/interface - this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); + this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); // Open Brace braces after control block - this.NewLineBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); + this.NewLineBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); // Insert space after semicolon in for statement - this.SpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 2 /* Space */)); - this.NoSpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 8 /* Delete */)); + this.SpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 2 /* Space */)); + this.NoSpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 8 /* Delete */)); // Insert space after opening and before closing nonempty parenthesis - this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* OpenParenToken */, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(18 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(18 /* OpenParenToken */, 19 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(18 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // Insert space after opening and before closing nonempty brackets - this.SpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.NoSpaceBetweenBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(19 /* OpenBracketToken */, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBetweenBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(20 /* OpenBracketToken */, 21 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // Insert space after opening and before closing template string braces - 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.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterTemplateHeadAndMiddle = 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.IsNonJsxSameLineTokenContext), 2 /* Space */)); - 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.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.SpaceBeforeTemplateMiddleAndTail = 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.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([13 /* TemplateHead */, 14 /* TemplateMiddle */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([13 /* TemplateHead */, 14 /* TemplateMiddle */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([14 /* TemplateMiddle */, 15 /* TemplateTail */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([14 /* TemplateMiddle */, 15 /* TemplateTail */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // No space after { and before } in JSX expression - this.NoSpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8 /* Delete */)); - this.SpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2 /* Space */)); - this.NoSpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8 /* Delete */)); - this.SpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2 /* Space */)); + this.NoSpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8 /* Delete */)); + this.SpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2 /* Space */)); + this.NoSpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8 /* Delete */)); + this.SpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2 /* Space */)); // Insert space after function keyword for anonymous functions - 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 */)); + this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(88 /* FunctionKeyword */, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(88 /* FunctionKeyword */, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8 /* Delete */)); // No space after type assertion - this.NoSpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(27 /* GreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 8 /* Delete */)); - this.SpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(27 /* GreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 2 /* Space */)); + this.NoSpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(28 /* GreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 8 /* Delete */)); + this.SpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(28 /* GreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 2 /* Space */)); } Rules.prototype.getRuleName = function (rule) { var o = this; @@ -70891,42 +71607,42 @@ var ts; /// Contexts /// Rules.IsForContext = function (context) { - return context.contextNode.kind === 206 /* ForStatement */; + return context.contextNode.kind === 207 /* ForStatement */; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 187 /* BinaryExpression */: - case 188 /* ConditionalExpression */: - case 195 /* AsExpression */: - case 238 /* ExportSpecifier */: - case 234 /* ImportSpecifier */: - case 154 /* TypePredicate */: - case 162 /* UnionType */: - case 163 /* IntersectionType */: + case 188 /* BinaryExpression */: + case 189 /* ConditionalExpression */: + case 196 /* AsExpression */: + case 239 /* ExportSpecifier */: + case 235 /* ImportSpecifier */: + case 155 /* TypePredicate */: + case 163 /* UnionType */: + case 164 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 169 /* BindingElement */: + case 170 /* BindingElement */: // equals in type X = ... - case 223 /* TypeAliasDeclaration */: + case 224 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 229 /* ImportEqualsDeclaration */: + case 230 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 218 /* VariableDeclaration */: + case 219 /* VariableDeclaration */: // equal in p = 0; - case 142 /* Parameter */: + case 143 /* Parameter */: case 255 /* EnumMember */: - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: - return context.currentTokenSpan.kind === 56 /* EqualsToken */ || context.nextTokenSpan.kind === 56 /* EqualsToken */; + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: + return context.currentTokenSpan.kind === 57 /* EqualsToken */ || context.nextTokenSpan.kind === 57 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 207 /* ForInStatement */: - return context.currentTokenSpan.kind === 90 /* InKeyword */ || context.nextTokenSpan.kind === 90 /* InKeyword */; + case 208 /* ForInStatement */: + return context.currentTokenSpan.kind === 91 /* InKeyword */ || context.nextTokenSpan.kind === 91 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 208 /* ForOfStatement */: - return context.currentTokenSpan.kind === 138 /* OfKeyword */ || context.nextTokenSpan.kind === 138 /* OfKeyword */; + case 209 /* ForOfStatement */: + return context.currentTokenSpan.kind === 139 /* OfKeyword */ || context.nextTokenSpan.kind === 139 /* OfKeyword */; } return false; }; @@ -70934,7 +71650,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 188 /* ConditionalExpression */; + return context.contextNode.kind === 189 /* ConditionalExpression */; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. @@ -70978,81 +71694,81 @@ var ts; return true; } switch (node.kind) { - case 199 /* Block */: - case 227 /* CaseBlock */: - case 171 /* ObjectLiteralExpression */: - case 226 /* ModuleBlock */: + case 200 /* Block */: + case 228 /* CaseBlock */: + case 172 /* ObjectLiteralExpression */: + case 227 /* ModuleBlock */: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 220 /* FunctionDeclaration */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 221 /* FunctionDeclaration */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: // case SyntaxKind.MethodSignature: - case 151 /* CallSignature */: - case 179 /* FunctionExpression */: - case 148 /* Constructor */: - case 180 /* ArrowFunction */: + case 152 /* CallSignature */: + case 180 /* FunctionExpression */: + case 149 /* Constructor */: + case 181 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 222 /* InterfaceDeclaration */: + case 223 /* InterfaceDeclaration */: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 220 /* FunctionDeclaration */ || context.contextNode.kind === 179 /* FunctionExpression */; + return context.contextNode.kind === 221 /* FunctionDeclaration */ || context.contextNode.kind === 180 /* FunctionExpression */; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - case 222 /* InterfaceDeclaration */: - case 224 /* EnumDeclaration */: - case 159 /* TypeLiteral */: - case 225 /* ModuleDeclaration */: - case 236 /* ExportDeclaration */: - case 237 /* NamedExports */: - case 230 /* ImportDeclaration */: - case 233 /* NamedImports */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 223 /* InterfaceDeclaration */: + case 225 /* EnumDeclaration */: + case 160 /* TypeLiteral */: + case 226 /* ModuleDeclaration */: + case 237 /* ExportDeclaration */: + case 238 /* NamedExports */: + case 231 /* ImportDeclaration */: + case 234 /* NamedImports */: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 221 /* ClassDeclaration */: - case 225 /* ModuleDeclaration */: - case 224 /* EnumDeclaration */: - case 199 /* Block */: + case 222 /* ClassDeclaration */: + case 226 /* ModuleDeclaration */: + case 225 /* EnumDeclaration */: + case 200 /* Block */: case 252 /* CatchClause */: - case 226 /* ModuleBlock */: - case 213 /* SwitchStatement */: + case 227 /* ModuleBlock */: + case 214 /* SwitchStatement */: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 203 /* IfStatement */: - case 213 /* SwitchStatement */: - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: - case 205 /* WhileStatement */: - case 216 /* TryStatement */: - case 204 /* DoStatement */: - case 212 /* WithStatement */: + case 204 /* IfStatement */: + case 214 /* SwitchStatement */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: + case 206 /* WhileStatement */: + case 217 /* TryStatement */: + case 205 /* DoStatement */: + case 213 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: case 252 /* CatchClause */: @@ -71062,31 +71778,31 @@ var ts; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 171 /* ObjectLiteralExpression */; + return context.contextNode.kind === 172 /* ObjectLiteralExpression */; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 174 /* CallExpression */; + return context.contextNode.kind === 175 /* CallExpression */; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 175 /* NewExpression */; + return context.contextNode.kind === 176 /* NewExpression */; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); }; Rules.IsPreviousTokenNotComma = function (context) { - return context.currentTokenSpan.kind !== 24 /* CommaToken */; + return context.currentTokenSpan.kind !== 25 /* CommaToken */; }; Rules.IsNextTokenNotCloseBracket = function (context) { - return context.nextTokenSpan.kind !== 20 /* CloseBracketToken */; + return context.nextTokenSpan.kind !== 21 /* CloseBracketToken */; }; Rules.IsArrowFunctionContext = function (context) { - return context.contextNode.kind === 180 /* ArrowFunction */; + return context.contextNode.kind === 181 /* ArrowFunction */; }; Rules.IsNonJsxSameLineTokenContext = function (context) { - return context.TokensAreOnSameLine() && context.contextNode.kind !== 244 /* JsxText */; + return context.TokensAreOnSameLine() && context.contextNode.kind !== 10 /* JsxText */; }; Rules.IsNonJsxElementContext = function (context) { - return context.contextNode.kind !== 241 /* JsxElement */; + return context.contextNode.kind !== 242 /* JsxElement */; }; Rules.IsJsxExpressionContext = function (context) { return context.contextNode.kind === 248 /* JsxExpression */; @@ -71098,7 +71814,7 @@ var ts; return context.contextNode.kind === 246 /* JsxAttribute */; }; Rules.IsJsxSelfClosingElementContext = function (context) { - return context.contextNode.kind === 242 /* JsxSelfClosingElement */; + return context.contextNode.kind === 243 /* JsxSelfClosingElement */; }; Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); @@ -71113,41 +71829,41 @@ var ts; while (ts.isPartOfExpression(node)) { node = node.parent; } - return node.kind === 143 /* Decorator */; + return node.kind === 144 /* Decorator */; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 219 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 220 /* 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 === 225 /* ModuleDeclaration */; + return context.contextNode.kind === 226 /* ModuleDeclaration */; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 159 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 160 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; }; Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { - if (token.kind !== 25 /* LessThanToken */ && token.kind !== 27 /* GreaterThanToken */) { + if (token.kind !== 26 /* LessThanToken */ && token.kind !== 28 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 155 /* TypeReference */: - case 177 /* TypeAssertionExpression */: - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - case 222 /* InterfaceDeclaration */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 174 /* CallExpression */: - case 175 /* NewExpression */: - case 194 /* ExpressionWithTypeArguments */: + case 156 /* TypeReference */: + case 178 /* TypeAssertionExpression */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 223 /* InterfaceDeclaration */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: + case 195 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -71158,13 +71874,13 @@ var ts; Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsTypeAssertionContext = function (context) { - return context.contextNode.kind === 177 /* TypeAssertionExpression */; + return context.contextNode.kind === 178 /* TypeAssertionExpression */; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 103 /* VoidKeyword */ && context.currentTokenParent.kind === 183 /* VoidExpression */; + return context.currentTokenSpan.kind === 104 /* VoidKeyword */ && context.currentTokenParent.kind === 184 /* VoidExpression */; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 190 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 191 /* YieldExpression */ && context.contextNode.expression !== undefined; }; return Rules; }()); @@ -71188,7 +71904,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 138 /* LastToken */ + 1; + this.mapRowLength = 139 /* 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); @@ -71202,8 +71918,8 @@ var ts; }); }; RulesMap.prototype.GetRuleBucketIndex = function (row, column) { + ts.Debug.assert(row <= 139 /* LastKeyword */ && column <= 139 /* LastKeyword */, "Must compute formatting context from tokens"); var rulesBucketIndex = (row * this.mapRowLength) + column; - // Debug.Assert(rulesBucketIndex < this.map.Length, "Trying to access an index outside the array."); return rulesBucketIndex; }; RulesMap.prototype.FillRule = function (rule, rulesBucketConstructionStateList) { @@ -71383,12 +72099,12 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0 /* FirstToken */; token <= 138 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 139 /* LastToken */; token++) { result.push(token); } return result; }; - TokenAllAccess.prototype.Contains = function (tokenValue) { + TokenAllAccess.prototype.Contains = function () { return true; }; TokenAllAccess.prototype.toString = function () { @@ -71427,17 +72143,17 @@ var ts; }()); TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3 /* MultiLineCommentTrivia */])); - TokenRange.Keywords = TokenRange.FromRange(70 /* FirstKeyword */, 138 /* LastKeyword */); - TokenRange.BinaryOperators = TokenRange.FromRange(25 /* FirstBinaryOperator */, 68 /* LastBinaryOperator */); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([90 /* InKeyword */, 91 /* InstanceOfKeyword */, 138 /* 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.Keywords = TokenRange.FromRange(71 /* FirstKeyword */, 139 /* LastKeyword */); + TokenRange.BinaryOperators = TokenRange.FromRange(26 /* FirstBinaryOperator */, 69 /* LastBinaryOperator */); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([91 /* InKeyword */, 92 /* InstanceOfKeyword */, 139 /* OfKeyword */, 117 /* AsKeyword */, 125 /* IsKeyword */]); + TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([42 /* PlusPlusToken */, 43 /* MinusMinusToken */, 51 /* TildeToken */, 50 /* ExclamationToken */]); + TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8 /* NumericLiteral */, 70 /* Identifier */, 18 /* OpenParenToken */, 20 /* OpenBracketToken */, 16 /* OpenBraceToken */, 98 /* ThisKeyword */, 93 /* NewKeyword */]); + TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([70 /* Identifier */, 18 /* OpenParenToken */, 98 /* ThisKeyword */, 93 /* NewKeyword */]); + TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([70 /* Identifier */, 19 /* CloseParenToken */, 21 /* CloseBracketToken */, 93 /* NewKeyword */]); + TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([70 /* Identifier */, 18 /* OpenParenToken */, 98 /* ThisKeyword */, 93 /* NewKeyword */]); + TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([70 /* Identifier */, 19 /* CloseParenToken */, 21 /* CloseBracketToken */, 93 /* NewKeyword */]); TokenRange.Comments = TokenRange.FromTokens([2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]); - TokenRange.TypeNames = TokenRange.FromTokens([69 /* Identifier */, 130 /* NumberKeyword */, 132 /* StringKeyword */, 120 /* BooleanKeyword */, 133 /* SymbolKeyword */, 103 /* VoidKeyword */, 117 /* AnyKeyword */]); + TokenRange.TypeNames = TokenRange.FromTokens([70 /* Identifier */, 131 /* NumberKeyword */, 133 /* StringKeyword */, 121 /* BooleanKeyword */, 134 /* SymbolKeyword */, 104 /* VoidKeyword */, 118 /* AnyKeyword */]); Shared.TokenRange = TokenRange; })(Shared = formatting.Shared || (formatting.Shared = {})); })(formatting = ts.formatting || (ts.formatting = {})); @@ -71628,11 +72344,11 @@ var ts; } formatting.formatOnEnter = formatOnEnter; function formatOnSemicolon(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 23 /* SemicolonToken */, sourceFile, options, rulesProvider, 3 /* FormatOnSemicolon */); + return formatOutermostParent(position, 24 /* SemicolonToken */, sourceFile, options, rulesProvider, 3 /* FormatOnSemicolon */); } formatting.formatOnSemicolon = formatOnSemicolon; function formatOnClosingCurly(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 16 /* CloseBraceToken */, sourceFile, options, rulesProvider, 4 /* FormatOnClosingCurlyBrace */); + return formatOutermostParent(position, 17 /* CloseBraceToken */, sourceFile, options, rulesProvider, 4 /* FormatOnClosingCurlyBrace */); } formatting.formatOnClosingCurly = formatOnClosingCurly; function formatDocument(sourceFile, rulesProvider, options) { @@ -71696,15 +72412,15 @@ 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 221 /* ClassDeclaration */: - case 222 /* InterfaceDeclaration */: + case 222 /* ClassDeclaration */: + case 223 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: var body = parent.body; - return body && body.kind === 226 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + return body && body.kind === 227 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); case 256 /* SourceFile */: - case 199 /* Block */: - case 226 /* ModuleBlock */: + case 200 /* Block */: + case 227 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); case 252 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); @@ -71761,7 +72477,7 @@ var ts; index++; } }; - function rangeHasNoErrors(r) { + function rangeHasNoErrors() { return false; } } @@ -71911,20 +72627,20 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 221 /* ClassDeclaration */: return 73 /* ClassKeyword */; - case 222 /* InterfaceDeclaration */: return 107 /* InterfaceKeyword */; - case 220 /* FunctionDeclaration */: return 87 /* FunctionKeyword */; - case 224 /* EnumDeclaration */: return 224 /* EnumDeclaration */; - case 149 /* GetAccessor */: return 123 /* GetKeyword */; - case 150 /* SetAccessor */: return 131 /* SetKeyword */; - case 147 /* MethodDeclaration */: + case 222 /* ClassDeclaration */: return 74 /* ClassKeyword */; + case 223 /* InterfaceDeclaration */: return 108 /* InterfaceKeyword */; + case 221 /* FunctionDeclaration */: return 88 /* FunctionKeyword */; + case 225 /* EnumDeclaration */: return 225 /* EnumDeclaration */; + case 150 /* GetAccessor */: return 124 /* GetKeyword */; + case 151 /* SetAccessor */: return 132 /* SetKeyword */; + case 148 /* MethodDeclaration */: if (node.asteriskToken) { - return 37 /* AsteriskToken */; + return 38 /* AsteriskToken */; } /* fall-through */ - case 145 /* PropertyDeclaration */: - case 142 /* Parameter */: + case 146 /* PropertyDeclaration */: + case 143 /* Parameter */: return node.name.kind; } } @@ -71936,9 +72652,9 @@ var ts; // .. { // // comment // } - case 16 /* CloseBraceToken */: - case 20 /* CloseBracketToken */: - case 18 /* CloseParenToken */: + case 17 /* CloseBraceToken */: + case 21 /* CloseBracketToken */: + case 19 /* CloseParenToken */: return indentation + getEffectiveDelta(delta, container); } return tokenIndentation !== -1 /* Unknown */ ? tokenIndentation : indentation; @@ -71952,15 +72668,15 @@ var ts; } switch (kind) { // open and close brace, 'else' and 'while' (in do statement) tokens has indentation of the parent - case 15 /* OpenBraceToken */: - case 16 /* CloseBraceToken */: - case 19 /* OpenBracketToken */: - case 20 /* CloseBracketToken */: - case 17 /* OpenParenToken */: - case 18 /* CloseParenToken */: - case 80 /* ElseKeyword */: - case 104 /* WhileKeyword */: - case 55 /* AtToken */: + case 16 /* OpenBraceToken */: + case 17 /* CloseBraceToken */: + case 20 /* OpenBracketToken */: + case 21 /* CloseBracketToken */: + case 18 /* OpenParenToken */: + case 19 /* CloseParenToken */: + case 81 /* ElseKeyword */: + case 105 /* WhileKeyword */: + case 56 /* 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 @@ -72060,18 +72776,19 @@ var ts; if (!formattingScanner.isOnToken()) { return inheritedIndentation; } - if (ts.isToken(child)) { + // JSX text shouldn't affect indenting + if (ts.isToken(child) && child.kind !== 10 /* JsxText */) { // if child node is a token, it does not impact indentation, proceed it using parent indentation scope rules var tokenInfo = formattingScanner.readTokenInfo(child); - ts.Debug.assert(tokenInfo.token.end === child.end); + ts.Debug.assert(tokenInfo.token.end === child.end, "Token end is child end"); consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 143 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 144 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; - if (isFirstListItem && parent.kind === 170 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 171 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -72416,41 +73133,41 @@ var ts; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 148 /* Constructor */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 180 /* ArrowFunction */: + case 149 /* Constructor */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 181 /* ArrowFunction */: if (node.typeParameters === list) { - return 25 /* LessThanToken */; + return 26 /* LessThanToken */; } else if (node.parameters === list) { - return 17 /* OpenParenToken */; + return 18 /* OpenParenToken */; } break; - case 174 /* CallExpression */: - case 175 /* NewExpression */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: if (node.typeArguments === list) { - return 25 /* LessThanToken */; + return 26 /* LessThanToken */; } else if (node.arguments === list) { - return 17 /* OpenParenToken */; + return 18 /* OpenParenToken */; } break; - case 155 /* TypeReference */: + case 156 /* TypeReference */: if (node.typeArguments === list) { - return 25 /* LessThanToken */; + return 26 /* LessThanToken */; } } return 0 /* Unknown */; } function getCloseTokenForOpenToken(kind) { switch (kind) { - case 17 /* OpenParenToken */: - return 18 /* CloseParenToken */; - case 25 /* LessThanToken */: - return 27 /* GreaterThanToken */; + case 18 /* OpenParenToken */: + return 19 /* CloseParenToken */; + case 26 /* LessThanToken */: + return 28 /* GreaterThanToken */; } return 0 /* Unknown */; } @@ -72554,7 +73271,7 @@ var ts; var lineStart = ts.getLineStartPositionForPosition(current_1, sourceFile); return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current_1, sourceFile, options); } - if (precedingToken.kind === 24 /* CommaToken */ && precedingToken.parent.kind !== 187 /* BinaryExpression */) { + if (precedingToken.kind === 25 /* CommaToken */ && precedingToken.parent.kind !== 188 /* 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 */) { @@ -72688,11 +73405,11 @@ var ts; if (!nextToken) { return false; } - if (nextToken.kind === 15 /* OpenBraceToken */) { + if (nextToken.kind === 16 /* OpenBraceToken */) { // open braces are always indented at the parent level return true; } - else if (nextToken.kind === 16 /* CloseBraceToken */) { + else if (nextToken.kind === 17 /* CloseBraceToken */) { // close braces are indented at the parent level if they are located on the same line with cursor // this means that if new line will be added at $ position, this case will be indented // class A { @@ -72710,8 +73427,8 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 203 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 80 /* ElseKeyword */, sourceFile); + if (parent.kind === 204 /* IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 81 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -72722,23 +73439,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 155 /* TypeReference */: + case 156 /* TypeReference */: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 171 /* ObjectLiteralExpression */: + case 172 /* ObjectLiteralExpression */: return node.parent.properties; - case 170 /* ArrayLiteralExpression */: + case 171 /* ArrayLiteralExpression */: return node.parent.elements; - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: { + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -72749,8 +73466,8 @@ var ts; } break; } - case 175 /* NewExpression */: - case 174 /* CallExpression */: { + case 176 /* NewExpression */: + case 175 /* CallExpression */: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -72777,11 +73494,11 @@ var ts; function getLineIndentationWhenExpressionIsInMultiLine(node, sourceFile, options) { // actual indentation should not be used when: // - node is close parenthesis - this is the end of the expression - if (node.kind === 18 /* CloseParenToken */) { + if (node.kind === 19 /* CloseParenToken */) { return -1 /* Unknown */; } - if (node.parent && (node.parent.kind === 174 /* CallExpression */ || - node.parent.kind === 175 /* NewExpression */) && + if (node.parent && (node.parent.kind === 175 /* CallExpression */ || + node.parent.kind === 176 /* NewExpression */) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -72799,10 +73516,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 174 /* CallExpression */: - case 175 /* NewExpression */: - case 172 /* PropertyAccessExpression */: - case 173 /* ElementAccessExpression */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: + case 173 /* PropertyAccessExpression */: + case 174 /* ElementAccessExpression */: node = node.expression; break; default: @@ -72818,7 +73535,7 @@ var ts; // if end line for item [i - 1] differs from the start line for item [i] - find column of the first non-whitespace character on the line of item [i] var lineAndCharacter = getStartLineAndCharacterForNode(node, sourceFile); for (var i = index - 1; i >= 0; i--) { - if (list[i].kind === 24 /* CommaToken */) { + if (list[i].kind === 25 /* CommaToken */) { continue; } // skip list items that ends on the same line with the current list element @@ -72866,48 +73583,48 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 202 /* ExpressionStatement */: - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - case 222 /* InterfaceDeclaration */: - case 224 /* EnumDeclaration */: - case 223 /* TypeAliasDeclaration */: - case 170 /* ArrayLiteralExpression */: - case 199 /* Block */: - case 226 /* ModuleBlock */: - case 171 /* ObjectLiteralExpression */: - case 159 /* TypeLiteral */: - case 161 /* TupleType */: - case 227 /* CaseBlock */: + case 203 /* ExpressionStatement */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 223 /* InterfaceDeclaration */: + case 225 /* EnumDeclaration */: + case 224 /* TypeAliasDeclaration */: + case 171 /* ArrayLiteralExpression */: + case 200 /* Block */: + case 227 /* ModuleBlock */: + case 172 /* ObjectLiteralExpression */: + case 160 /* TypeLiteral */: + case 162 /* TupleType */: + case 228 /* CaseBlock */: case 250 /* DefaultClause */: case 249 /* CaseClause */: - case 178 /* ParenthesizedExpression */: - case 172 /* PropertyAccessExpression */: - case 174 /* CallExpression */: - case 175 /* NewExpression */: - case 200 /* VariableStatement */: - case 218 /* VariableDeclaration */: - case 235 /* ExportAssignment */: - case 211 /* ReturnStatement */: - case 188 /* ConditionalExpression */: - case 168 /* ArrayBindingPattern */: - case 167 /* ObjectBindingPattern */: - case 243 /* JsxOpeningElement */: - case 242 /* JsxSelfClosingElement */: + case 179 /* ParenthesizedExpression */: + case 173 /* PropertyAccessExpression */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: + case 201 /* VariableStatement */: + case 219 /* VariableDeclaration */: + case 236 /* ExportAssignment */: + case 212 /* ReturnStatement */: + case 189 /* ConditionalExpression */: + case 169 /* ArrayBindingPattern */: + case 168 /* ObjectBindingPattern */: + case 244 /* JsxOpeningElement */: + case 243 /* JsxSelfClosingElement */: case 248 /* JsxExpression */: - case 146 /* MethodSignature */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 142 /* Parameter */: - case 156 /* FunctionType */: - case 157 /* ConstructorType */: - case 164 /* ParenthesizedType */: - case 176 /* TaggedTemplateExpression */: - case 184 /* AwaitExpression */: - case 237 /* NamedExports */: - case 233 /* NamedImports */: - case 238 /* ExportSpecifier */: - case 234 /* ImportSpecifier */: + case 147 /* MethodSignature */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 143 /* Parameter */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: + case 165 /* ParenthesizedType */: + case 177 /* TaggedTemplateExpression */: + case 185 /* AwaitExpression */: + case 238 /* NamedExports */: + case 234 /* NamedImports */: + case 239 /* ExportSpecifier */: + case 235 /* ImportSpecifier */: return true; } return false; @@ -72916,26 +73633,26 @@ var ts; function nodeWillIndentChild(parent, child, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 204 /* DoStatement */: - case 205 /* WhileStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: - case 206 /* ForStatement */: - case 203 /* IfStatement */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 147 /* MethodDeclaration */: - case 180 /* ArrowFunction */: - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - return childKind !== 199 /* Block */; - case 236 /* ExportDeclaration */: - return childKind !== 237 /* NamedExports */; - case 230 /* ImportDeclaration */: - return childKind !== 231 /* ImportClause */ || - (child.namedBindings && child.namedBindings.kind !== 233 /* NamedImports */); - case 241 /* JsxElement */: + case 205 /* DoStatement */: + case 206 /* WhileStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: + case 207 /* ForStatement */: + case 204 /* IfStatement */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 148 /* MethodDeclaration */: + case 181 /* ArrowFunction */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + return childKind !== 200 /* Block */; + case 237 /* ExportDeclaration */: + return childKind !== 238 /* NamedExports */; + case 231 /* ImportDeclaration */: + return childKind !== 232 /* ImportClause */ || + (child.namedBindings && child.namedBindings.kind !== 234 /* NamedImports */); + case 242 /* JsxElement */: return childKind !== 245 /* JsxClosingElement */; } // No explicit rule for given nodes so the result will follow the default value argument @@ -73001,7 +73718,7 @@ var ts; getCodeActions: function (context) { var sourceFile = context.sourceFile; var token = ts.getTokenAtPosition(sourceFile, context.span.start); - if (token.kind !== 121 /* ConstructorKeyword */) { + if (token.kind !== 122 /* ConstructorKeyword */) { return undefined; } var newPosition = getOpenBraceEnd(token.parent, sourceFile); @@ -73016,7 +73733,7 @@ var ts; getCodeActions: function (context) { var sourceFile = context.sourceFile; var token = ts.getTokenAtPosition(sourceFile, context.span.start); - if (token.kind !== 97 /* ThisKeyword */) { + if (token.kind !== 98 /* ThisKeyword */) { return undefined; } var constructor = ts.getContainingFunction(token); @@ -73026,7 +73743,7 @@ var ts; } // figure out if the this access is actuall inside the supercall // i.e. super(this.a), since in that case we won't suggest a fix - if (superCall.expression && superCall.expression.kind == 174 /* CallExpression */) { + if (superCall.expression && superCall.expression.kind == 175 /* CallExpression */) { var arguments_1 = superCall.expression.arguments; for (var i = 0; i < arguments_1.length; i++) { if (arguments_1[i].expression === token) { @@ -73050,7 +73767,7 @@ var ts; changes: changes }]; function findSuperCall(n) { - if (n.kind === 202 /* ExpressionStatement */ && ts.isSuperCall(n.expression)) { + if (n.kind === 203 /* ExpressionStatement */ && ts.isSuperCall(n.expression)) { return n; } if (ts.isFunctionLike(n)) { @@ -73095,8 +73812,8 @@ var ts; /** The version of the language service API */ ts.servicesVersion = "0.5"; function createNode(kind, pos, end, parent) { - var node = kind >= 139 /* FirstNode */ ? new NodeObject(kind, pos, end) : - kind === 69 /* Identifier */ ? new IdentifierObject(69 /* Identifier */, pos, end) : + var node = kind >= 140 /* FirstNode */ ? new NodeObject(kind, pos, end) : + kind === 70 /* Identifier */ ? new IdentifierObject(70 /* Identifier */, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; return node; @@ -73173,7 +73890,7 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 139 /* FirstNode */) { + if (this.kind >= 140 /* FirstNode */) { ts.scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos_3 = this.pos; @@ -73235,7 +73952,7 @@ var ts; return undefined; } var child = children[0]; - return child.kind < 139 /* FirstNode */ ? child : child.getFirstToken(sourceFile); + return child.kind < 140 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; NodeObject.prototype.getLastToken = function (sourceFile) { var children = this.getChildren(sourceFile); @@ -73243,7 +73960,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 139 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 140 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; return NodeObject; }()); @@ -73282,19 +73999,19 @@ var ts; TokenOrIdentifierObject.prototype.getText = function (sourceFile) { return (sourceFile || this.getSourceFile()).text.substring(this.getStart(), this.getEnd()); }; - TokenOrIdentifierObject.prototype.getChildCount = function (sourceFile) { + TokenOrIdentifierObject.prototype.getChildCount = function () { return 0; }; - TokenOrIdentifierObject.prototype.getChildAt = function (index, sourceFile) { + TokenOrIdentifierObject.prototype.getChildAt = function () { return undefined; }; - TokenOrIdentifierObject.prototype.getChildren = function (sourceFile) { + TokenOrIdentifierObject.prototype.getChildren = function () { return ts.emptyArray; }; - TokenOrIdentifierObject.prototype.getFirstToken = function (sourceFile) { + TokenOrIdentifierObject.prototype.getFirstToken = function () { return undefined; }; - TokenOrIdentifierObject.prototype.getLastToken = function (sourceFile) { + TokenOrIdentifierObject.prototype.getLastToken = function () { return undefined; }; return TokenOrIdentifierObject; @@ -73315,7 +74032,7 @@ var ts; }; SymbolObject.prototype.getDocumentationComment = function () { if (this.documentationComment === undefined) { - this.documentationComment = ts.JsDoc.getJsDocCommentsFromDeclarations(this.declarations, this.name, !(this.flags & 4 /* Property */)); + this.documentationComment = ts.JsDoc.getJsDocCommentsFromDeclarations(this.declarations); } return this.documentationComment; }; @@ -73332,12 +74049,12 @@ var ts; }(TokenOrIdentifierObject)); var IdentifierObject = (function (_super) { __extends(IdentifierObject, _super); - function IdentifierObject(kind, pos, end) { + function IdentifierObject(_kind, pos, end) { return _super.call(this, pos, end) || this; } return IdentifierObject; }(TokenOrIdentifierObject)); - IdentifierObject.prototype.kind = 69 /* Identifier */; + IdentifierObject.prototype.kind = 70 /* Identifier */; var TypeObject = (function () { function TypeObject(checker, flags) { this.checker = checker; @@ -73398,9 +74115,7 @@ var ts; }; SignatureObject.prototype.getDocumentationComment = function () { if (this.documentationComment === undefined) { - this.documentationComment = this.declaration ? ts.JsDoc.getJsDocCommentsFromDeclarations([this.declaration], - /*name*/ undefined, - /*canUseParsedParamTagComments*/ false) : []; + this.documentationComment = this.declaration ? ts.JsDoc.getJsDocCommentsFromDeclarations([this.declaration]) : []; } return this.documentationComment; }; @@ -73448,9 +74163,9 @@ var ts; if (result_6 !== undefined) { return result_6; } - if (declaration.name.kind === 140 /* ComputedPropertyName */) { + if (declaration.name.kind === 141 /* ComputedPropertyName */) { var expr = declaration.name.expression; - if (expr.kind === 172 /* PropertyAccessExpression */) { + if (expr.kind === 173 /* PropertyAccessExpression */) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -73460,7 +74175,7 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 69 /* Identifier */ || + if (node.kind === 70 /* Identifier */ || node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { return node.text; @@ -73470,10 +74185,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -73493,32 +74208,32 @@ var ts; ts.forEachChild(node, visit); } break; - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - case 222 /* InterfaceDeclaration */: - case 223 /* TypeAliasDeclaration */: - case 224 /* EnumDeclaration */: - case 225 /* ModuleDeclaration */: - case 229 /* ImportEqualsDeclaration */: - case 238 /* ExportSpecifier */: - case 234 /* ImportSpecifier */: - case 229 /* ImportEqualsDeclaration */: - case 231 /* ImportClause */: - case 232 /* NamespaceImport */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 159 /* TypeLiteral */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 223 /* InterfaceDeclaration */: + case 224 /* TypeAliasDeclaration */: + case 225 /* EnumDeclaration */: + case 226 /* ModuleDeclaration */: + case 230 /* ImportEqualsDeclaration */: + case 239 /* ExportSpecifier */: + case 235 /* ImportSpecifier */: + case 230 /* ImportEqualsDeclaration */: + case 232 /* ImportClause */: + case 233 /* NamespaceImport */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 160 /* TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 142 /* Parameter */: + case 143 /* Parameter */: // Only consider parameter properties if (!ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { break; } // fall through - case 218 /* VariableDeclaration */: - case 169 /* BindingElement */: { + case 219 /* VariableDeclaration */: + case 170 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -73528,18 +74243,18 @@ var ts; visit(decl.initializer); } case 255 /* EnumMember */: - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: addDeclaration(node); break; - case 236 /* ExportDeclaration */: + case 237 /* 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 230 /* ImportDeclaration */: + case 231 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -73551,7 +74266,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 232 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 233 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -73575,7 +74290,7 @@ var ts; getSourceFileConstructor: function () { return SourceFileObject; }, getSymbolConstructor: function () { return SymbolObject; }, getTypeConstructor: function () { return TypeObject; }, - getSignatureConstructor: function () { return SignatureObject; } + getSignatureConstructor: function () { return SignatureObject; }, }; } function toEditorSettings(optionsAsMap) { @@ -73674,7 +74389,7 @@ var ts; }; HostCache.prototype.getRootFileNames = function () { var fileNames = []; - this.fileNameToEntry.forEachValue(function (path, value) { + this.fileNameToEntry.forEachValue(function (_path, value) { if (value) { fileNames.push(value.hostFileName); } @@ -73706,7 +74421,7 @@ var ts; var sourceFile; if (this.currentFileName !== fileName) { // This is a new file, just parse it - sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 2 /* Latest */, version, /*setNodeParents*/ true, scriptKind); + sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 4 /* Latest */, version, /*setNodeParents*/ true, scriptKind); } else if (this.currentFileVersion !== version) { // This is the same file, just a newer version. Incrementally parse the file. @@ -73884,7 +74599,7 @@ var ts; useCaseSensitiveFileNames: function () { return useCaseSensitivefileNames; }, getNewLine: function () { return ts.getNewLineOrDefaultFromHost(host); }, getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); }, - writeFile: function (fileName, data, writeByteOrderMark) { }, + writeFile: function () { }, getCurrentDirectory: function () { return currentDirectory; }, fileExists: function (fileName) { // stub missing host functionality @@ -74080,12 +74795,12 @@ var ts; if (!symbol || typeChecker.isUnknownSymbol(symbol)) { // Try getting just type at this position and show switch (node.kind) { - case 69 /* Identifier */: - case 172 /* PropertyAccessExpression */: - case 139 /* QualifiedName */: - case 97 /* ThisKeyword */: - case 165 /* ThisType */: - case 95 /* SuperKeyword */: + case 70 /* Identifier */: + case 173 /* PropertyAccessExpression */: + case 140 /* QualifiedName */: + case 98 /* ThisKeyword */: + case 166 /* ThisType */: + case 96 /* SuperKeyword */: // For the identifiers/this/super etc get the type at position var type = typeChecker.getTypeAtLocation(node); if (type) { @@ -74219,7 +74934,7 @@ var ts; function getSourceFile(fileName) { return getNonBoundSourceFile(fileName); } - function getNameOrDottedNameSpan(fileName, startPos, endPos) { + function getNameOrDottedNameSpan(fileName, startPos, _endPos) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); // Get node at the location var node = ts.getTouchingPropertyName(sourceFile, startPos); @@ -74227,16 +74942,16 @@ var ts; return; } switch (node.kind) { - case 172 /* PropertyAccessExpression */: - case 139 /* QualifiedName */: + case 173 /* PropertyAccessExpression */: + case 140 /* QualifiedName */: case 9 /* StringLiteral */: - case 84 /* FalseKeyword */: - case 99 /* TrueKeyword */: - case 93 /* NullKeyword */: - case 95 /* SuperKeyword */: - case 97 /* ThisKeyword */: - case 165 /* ThisType */: - case 69 /* Identifier */: + case 85 /* FalseKeyword */: + case 100 /* TrueKeyword */: + case 94 /* NullKeyword */: + case 96 /* SuperKeyword */: + case 98 /* ThisKeyword */: + case 166 /* ThisType */: + case 70 /* Identifier */: break; // Cant create the text span default: @@ -74252,7 +74967,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 === 225 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 226 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -74343,14 +75058,14 @@ var ts; return result; function getMatchingTokenKind(token) { switch (token.kind) { - case 15 /* OpenBraceToken */: return 16 /* CloseBraceToken */; - case 17 /* OpenParenToken */: return 18 /* CloseParenToken */; - case 19 /* OpenBracketToken */: return 20 /* CloseBracketToken */; - case 25 /* LessThanToken */: return 27 /* GreaterThanToken */; - case 16 /* CloseBraceToken */: return 15 /* OpenBraceToken */; - case 18 /* CloseParenToken */: return 17 /* OpenParenToken */; - case 20 /* CloseBracketToken */: return 19 /* OpenBracketToken */; - case 27 /* GreaterThanToken */: return 25 /* LessThanToken */; + case 16 /* OpenBraceToken */: return 17 /* CloseBraceToken */; + case 18 /* OpenParenToken */: return 19 /* CloseParenToken */; + case 20 /* OpenBracketToken */: return 21 /* CloseBracketToken */; + case 26 /* LessThanToken */: return 28 /* GreaterThanToken */; + case 17 /* CloseBraceToken */: return 16 /* OpenBraceToken */; + case 19 /* CloseParenToken */: return 18 /* OpenParenToken */; + case 21 /* CloseBracketToken */: return 20 /* OpenBracketToken */; + case 28 /* GreaterThanToken */: return 26 /* LessThanToken */; } return undefined; } @@ -74626,7 +75341,7 @@ var ts; sourceFile.nameTable = nameTable; function walk(node) { switch (node.kind) { - case 69 /* Identifier */: + case 70 /* Identifier */: nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; break; case 9 /* StringLiteral */: @@ -74636,7 +75351,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 === 240 /* ExternalModuleReference */ || + node.parent.kind === 241 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node)) { nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; @@ -74656,7 +75371,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 173 /* ElementAccessExpression */ && + node.parent.kind === 174 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -74740,143 +75455,143 @@ var ts; function spanInNode(node) { if (node) { switch (node.kind) { - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 218 /* VariableDeclaration */: - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 219 /* VariableDeclaration */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: return spanInVariableDeclaration(node); - case 142 /* Parameter */: + case 143 /* Parameter */: return spanInParameterDeclaration(node); - case 220 /* FunctionDeclaration */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 148 /* Constructor */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 221 /* FunctionDeclaration */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 149 /* Constructor */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 199 /* Block */: + case 200 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // Fall through - case 226 /* ModuleBlock */: + case 227 /* ModuleBlock */: return spanInBlock(node); case 252 /* CatchClause */: return spanInBlock(node.block); - case 202 /* ExpressionStatement */: + case 203 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 211 /* ReturnStatement */: + case 212 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 205 /* WhileStatement */: + case 206 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 204 /* DoStatement */: + case 205 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 217 /* DebuggerStatement */: + case 218 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 203 /* IfStatement */: + case 204 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 210 /* BreakStatement */: - case 209 /* ContinueStatement */: + case 211 /* BreakStatement */: + case 210 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 206 /* ForStatement */: + case 207 /* ForStatement */: return spanInForStatement(node); - case 207 /* ForInStatement */: + case 208 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 208 /* ForOfStatement */: + case 209 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 213 /* SwitchStatement */: + case 214 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); case 249 /* CaseClause */: case 250 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 216 /* TryStatement */: + case 217 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 215 /* ThrowStatement */: + case 216 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 229 /* ImportEqualsDeclaration */: + case 230 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 230 /* ImportDeclaration */: + case 231 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 236 /* ExportDeclaration */: + case 237 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } - case 221 /* ClassDeclaration */: - case 224 /* EnumDeclaration */: + case 222 /* ClassDeclaration */: + case 225 /* EnumDeclaration */: case 255 /* EnumMember */: - case 169 /* BindingElement */: + case 170 /* BindingElement */: // span on complete node return textSpan(node); - case 212 /* WithStatement */: + case 213 /* WithStatement */: // span in statement return spanInNode(node.statement); - case 143 /* Decorator */: + case 144 /* Decorator */: return spanInNodeArray(node.parent.decorators); - case 167 /* ObjectBindingPattern */: - case 168 /* ArrayBindingPattern */: + case 168 /* ObjectBindingPattern */: + case 169 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 222 /* InterfaceDeclaration */: - case 223 /* TypeAliasDeclaration */: + case 223 /* InterfaceDeclaration */: + case 224 /* TypeAliasDeclaration */: return undefined; // Tokens: - case 23 /* SemicolonToken */: + case 24 /* SemicolonToken */: case 1 /* EndOfFileToken */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile)); - case 24 /* CommaToken */: + case 25 /* CommaToken */: return spanInPreviousNode(node); - case 15 /* OpenBraceToken */: + case 16 /* OpenBraceToken */: return spanInOpenBraceToken(node); - case 16 /* CloseBraceToken */: + case 17 /* CloseBraceToken */: return spanInCloseBraceToken(node); - case 20 /* CloseBracketToken */: + case 21 /* CloseBracketToken */: return spanInCloseBracketToken(node); - case 17 /* OpenParenToken */: + case 18 /* OpenParenToken */: return spanInOpenParenToken(node); - case 18 /* CloseParenToken */: + case 19 /* CloseParenToken */: return spanInCloseParenToken(node); - case 54 /* ColonToken */: + case 55 /* ColonToken */: return spanInColonToken(node); - case 27 /* GreaterThanToken */: - case 25 /* LessThanToken */: + case 28 /* GreaterThanToken */: + case 26 /* LessThanToken */: return spanInGreaterThanOrLessThanToken(node); // Keywords: - case 104 /* WhileKeyword */: + case 105 /* WhileKeyword */: return spanInWhileKeyword(node); - case 80 /* ElseKeyword */: - case 72 /* CatchKeyword */: - case 85 /* FinallyKeyword */: + case 81 /* ElseKeyword */: + case 73 /* CatchKeyword */: + case 86 /* FinallyKeyword */: return spanInNextNode(node); - case 138 /* OfKeyword */: + case 139 /* OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -74888,14 +75603,14 @@ var ts; // Set breakpoint on identifier element of destructuring pattern // a or ...c or d: x from // [a, b, ...c] or { a, b } or { d: x } from destructuring pattern - if ((node.kind === 69 /* Identifier */ || - node.kind == 191 /* SpreadElementExpression */ || + if ((node.kind === 70 /* Identifier */ || + node.kind == 192 /* SpreadElementExpression */ || node.kind === 253 /* PropertyAssignment */ || node.kind === 254 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { return textSpan(node); } - if (node.kind === 187 /* BinaryExpression */) { + if (node.kind === 188 /* BinaryExpression */) { var binaryExpression = node; // Set breakpoint in destructuring pattern if its destructuring assignment // [a, b, c] or {a, b, c} of @@ -74904,7 +75619,7 @@ var ts; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left); } - if (binaryExpression.operatorToken.kind === 56 /* EqualsToken */ && + if (binaryExpression.operatorToken.kind === 57 /* EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.parent)) { // Set breakpoint on assignment expression element of destructuring pattern // a = expression of @@ -74912,28 +75627,28 @@ var ts; // { a = expression, b, c } = someExpression return textSpan(node); } - if (binaryExpression.operatorToken.kind === 24 /* CommaToken */) { + if (binaryExpression.operatorToken.kind === 25 /* CommaToken */) { return spanInNode(binaryExpression.left); } } if (ts.isPartOfExpression(node)) { switch (node.parent.kind) { - case 204 /* DoStatement */: + case 205 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 143 /* Decorator */: + case 144 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 206 /* ForStatement */: - case 208 /* ForOfStatement */: + case 207 /* ForStatement */: + case 209 /* ForOfStatement */: return textSpan(node); - case 187 /* BinaryExpression */: - if (node.parent.operatorToken.kind === 24 /* CommaToken */) { + case 188 /* BinaryExpression */: + if (node.parent.operatorToken.kind === 25 /* CommaToken */) { // If this is a comma expression, the breakpoint is possible in this expression return textSpan(node); } break; - case 180 /* ArrowFunction */: + case 181 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -74948,7 +75663,7 @@ var ts; return spanInNode(node.parent.initializer); } // Breakpoint in type assertion goes to its operand - if (node.parent.kind === 177 /* TypeAssertionExpression */ && node.parent.type === node) { + if (node.parent.kind === 178 /* TypeAssertionExpression */ && node.parent.type === node) { return spanInNextNode(node.parent.type); } // return type of function go to previous token @@ -74956,8 +75671,8 @@ var ts; return spanInPreviousNode(node); } // initializer of variable/parameter declaration go to previous node - if ((node.parent.kind === 218 /* VariableDeclaration */ || - node.parent.kind === 142 /* Parameter */)) { + if ((node.parent.kind === 219 /* VariableDeclaration */ || + node.parent.kind === 143 /* Parameter */)) { var paramOrVarDecl = node.parent; if (paramOrVarDecl.initializer === node || paramOrVarDecl.type === node || @@ -74965,7 +75680,7 @@ var ts; return spanInPreviousNode(node); } } - if (node.parent.kind === 187 /* BinaryExpression */) { + if (node.parent.kind === 188 /* BinaryExpression */) { var binaryExpression = node.parent; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left) && (binaryExpression.right === node || @@ -74991,7 +75706,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 207 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 208 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } // If this is a destructuring pattern, set breakpoint in binding pattern @@ -75002,7 +75717,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1 /* Export */) || - variableDeclaration.parent.parent.kind === 208 /* ForOfStatement */) { + variableDeclaration.parent.parent.kind === 209 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } var declarations = variableDeclaration.parent.declarations; @@ -75042,7 +75757,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 221 /* ClassDeclaration */ && functionDeclaration.kind !== 148 /* Constructor */); + (functionDeclaration.parent.kind === 222 /* ClassDeclaration */ && functionDeclaration.kind !== 149 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -75065,25 +75780,25 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement - case 205 /* WhileStatement */: - case 203 /* IfStatement */: - case 207 /* ForInStatement */: + case 206 /* WhileStatement */: + case 204 /* IfStatement */: + case 208 /* ForInStatement */: 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 206 /* ForStatement */: - case 208 /* ForOfStatement */: + case 207 /* ForStatement */: + case 209 /* ForOfStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } // Default action is to set on first statement return spanInNode(block.statements[0]); } function spanInInitializerOfForLike(forLikeStatement) { - if (forLikeStatement.initializer.kind === 219 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 220 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -75108,23 +75823,23 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 193 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 194 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 169 /* BindingElement */) { + if (bindingPattern.parent.kind === 170 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 168 /* ArrayBindingPattern */ && node.kind !== 167 /* ObjectBindingPattern */); - var elements = node.kind === 170 /* ArrayLiteralExpression */ ? + ts.Debug.assert(node.kind !== 169 /* ArrayBindingPattern */ && node.kind !== 168 /* ObjectBindingPattern */); + var elements = node.kind === 171 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 193 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 194 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -75132,18 +75847,18 @@ var ts; // just nested element in another destructuring assignment // set breakpoint on assignment when parent is destructuring assignment // Otherwise set breakpoint for this element - return textSpan(node.parent.kind === 187 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 188 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 227 /* CaseBlock */: + case 228 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -75151,16 +75866,16 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 226 /* ModuleBlock */: + case 227 /* ModuleBlock */: // If this is not an instantiated module block, no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } - case 224 /* EnumDeclaration */: - case 221 /* ClassDeclaration */: + case 225 /* EnumDeclaration */: + case 222 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 199 /* Block */: + case 200 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); @@ -75168,7 +75883,7 @@ var ts; // fall through case 252 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 227 /* CaseBlock */: + case 228 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -75176,7 +75891,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 167 /* ObjectBindingPattern */: + case 168 /* ObjectBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return spanInNode(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -75192,7 +75907,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 168 /* ArrayBindingPattern */: + case 169 /* ArrayBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return textSpan(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -75207,12 +75922,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 204 /* DoStatement */ || - node.parent.kind === 174 /* CallExpression */ || - node.parent.kind === 175 /* NewExpression */) { + if (node.parent.kind === 205 /* DoStatement */ || + node.parent.kind === 175 /* CallExpression */ || + node.parent.kind === 176 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 178 /* ParenthesizedExpression */) { + if (node.parent.kind === 179 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -75221,21 +75936,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 179 /* FunctionExpression */: - case 220 /* FunctionDeclaration */: - case 180 /* ArrowFunction */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 148 /* Constructor */: - case 205 /* WhileStatement */: - case 204 /* DoStatement */: - case 206 /* ForStatement */: - case 208 /* ForOfStatement */: - case 174 /* CallExpression */: - case 175 /* NewExpression */: - case 178 /* ParenthesizedExpression */: + case 180 /* FunctionExpression */: + case 221 /* FunctionDeclaration */: + case 181 /* ArrowFunction */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 149 /* Constructor */: + case 206 /* WhileStatement */: + case 205 /* DoStatement */: + case 207 /* ForStatement */: + case 209 /* ForOfStatement */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: + case 179 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -75246,19 +75961,19 @@ var ts; // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || node.parent.kind === 253 /* PropertyAssignment */ || - node.parent.kind === 142 /* Parameter */) { + node.parent.kind === 143 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 177 /* TypeAssertionExpression */) { + if (node.parent.kind === 178 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 204 /* DoStatement */) { + if (node.parent.kind === 205 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -75266,7 +75981,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 208 /* ForOfStatement */) { + if (node.parent.kind === 209 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -75445,7 +76160,7 @@ var ts; return this.shimHost.getDefaultLibFileName(JSON.stringify(options)); }; LanguageServiceShimHostAdapter.prototype.readDirectory = function (path, extensions, exclude, include, depth) { - var pattern = ts.getFileMatcherPatterns(path, extensions, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); + var pattern = ts.getFileMatcherPatterns(path, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); return JSON.parse(this.shimHost.readDirectory(path, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); }; LanguageServiceShimHostAdapter.prototype.readFile = function (path, encoding) { @@ -75494,7 +76209,7 @@ var ts; // Wrap the API changes for 2.0 release. This try/catch // should be removed once TypeScript 2.0 has shipped. try { - var pattern = ts.getFileMatcherPatterns(rootDir, extensions, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); + var pattern = ts.getFileMatcherPatterns(rootDir, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); return JSON.parse(this.shimHost.readDirectory(rootDir, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); } catch (e) { @@ -75568,7 +76283,7 @@ var ts; this.factory = factory; factory.registerShim(this); } - ShimBase.prototype.dispose = function (dummy) { + ShimBase.prototype.dispose = function (_dummy) { this.factory.unregisterShim(this); }; return ShimBase; @@ -75991,7 +76706,7 @@ var ts; var getCanonicalFileName = ts.createGetCanonicalFileName(/*useCaseSensitivefileNames:*/ false); return this.forwardJSONCall("discoverTypings()", function () { var info = JSON.parse(discoverTypingsJson); - return ts.JsTyping.discoverTypings(_this.host, info.fileNames, ts.toPath(info.projectRootPath, info.projectRootPath, getCanonicalFileName), ts.toPath(info.safeListPath, info.safeListPath, getCanonicalFileName), info.packageNameToTypingLocation, info.typingOptions, info.compilerOptions); + return ts.JsTyping.discoverTypings(_this.host, info.fileNames, ts.toPath(info.projectRootPath, info.projectRootPath, getCanonicalFileName), ts.toPath(info.safeListPath, info.safeListPath, getCanonicalFileName), info.packageNameToTypingLocation, info.typingOptions); }); }; return CoreServicesShimObject; @@ -76080,3 +76795,5 @@ var TypeScript; /* @internal */ var toolsVersion = "2.1"; /* tslint:enable:no-unused-variable */ + +//# sourceMappingURL=typescriptServices.js.map diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index 5f319ffb74c..2558f2a3f99 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -47,241 +47,241 @@ declare namespace ts { ConflictMarkerTrivia = 7, NumericLiteral = 8, StringLiteral = 9, - RegularExpressionLiteral = 10, - NoSubstitutionTemplateLiteral = 11, - TemplateHead = 12, - TemplateMiddle = 13, - TemplateTail = 14, - OpenBraceToken = 15, - CloseBraceToken = 16, - OpenParenToken = 17, - CloseParenToken = 18, - OpenBracketToken = 19, - CloseBracketToken = 20, - DotToken = 21, - DotDotDotToken = 22, - SemicolonToken = 23, - CommaToken = 24, - LessThanToken = 25, - LessThanSlashToken = 26, - GreaterThanToken = 27, - LessThanEqualsToken = 28, - GreaterThanEqualsToken = 29, - EqualsEqualsToken = 30, - ExclamationEqualsToken = 31, - EqualsEqualsEqualsToken = 32, - ExclamationEqualsEqualsToken = 33, - EqualsGreaterThanToken = 34, - PlusToken = 35, - MinusToken = 36, - AsteriskToken = 37, - 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, - NeverKeyword = 127, - ReadonlyKeyword = 128, - RequireKeyword = 129, - NumberKeyword = 130, - SetKeyword = 131, - StringKeyword = 132, - SymbolKeyword = 133, - TypeKeyword = 134, - UndefinedKeyword = 135, - FromKeyword = 136, - GlobalKeyword = 137, - OfKeyword = 138, - QualifiedName = 139, - ComputedPropertyName = 140, - TypeParameter = 141, - Parameter = 142, - Decorator = 143, - PropertySignature = 144, - PropertyDeclaration = 145, - MethodSignature = 146, - MethodDeclaration = 147, - Constructor = 148, - GetAccessor = 149, - SetAccessor = 150, - CallSignature = 151, - ConstructSignature = 152, - IndexSignature = 153, - TypePredicate = 154, - TypeReference = 155, - FunctionType = 156, - ConstructorType = 157, - TypeQuery = 158, - TypeLiteral = 159, - ArrayType = 160, - TupleType = 161, - UnionType = 162, - IntersectionType = 163, - ParenthesizedType = 164, - ThisType = 165, - LiteralType = 166, - ObjectBindingPattern = 167, - ArrayBindingPattern = 168, - BindingElement = 169, - ArrayLiteralExpression = 170, - ObjectLiteralExpression = 171, - PropertyAccessExpression = 172, - ElementAccessExpression = 173, - CallExpression = 174, - NewExpression = 175, - TaggedTemplateExpression = 176, - TypeAssertionExpression = 177, - ParenthesizedExpression = 178, - FunctionExpression = 179, - ArrowFunction = 180, - DeleteExpression = 181, - TypeOfExpression = 182, - VoidExpression = 183, - AwaitExpression = 184, - PrefixUnaryExpression = 185, - PostfixUnaryExpression = 186, - BinaryExpression = 187, - ConditionalExpression = 188, - TemplateExpression = 189, - YieldExpression = 190, - SpreadElementExpression = 191, - ClassExpression = 192, - OmittedExpression = 193, - ExpressionWithTypeArguments = 194, - AsExpression = 195, - NonNullExpression = 196, - TemplateSpan = 197, - SemicolonClassElement = 198, - Block = 199, - VariableStatement = 200, - EmptyStatement = 201, - ExpressionStatement = 202, - IfStatement = 203, - DoStatement = 204, - WhileStatement = 205, - ForStatement = 206, - ForInStatement = 207, - ForOfStatement = 208, - ContinueStatement = 209, - BreakStatement = 210, - ReturnStatement = 211, - WithStatement = 212, - SwitchStatement = 213, - LabeledStatement = 214, - ThrowStatement = 215, - TryStatement = 216, - DebuggerStatement = 217, - VariableDeclaration = 218, - VariableDeclarationList = 219, - FunctionDeclaration = 220, - ClassDeclaration = 221, - InterfaceDeclaration = 222, - TypeAliasDeclaration = 223, - EnumDeclaration = 224, - ModuleDeclaration = 225, - ModuleBlock = 226, - CaseBlock = 227, - NamespaceExportDeclaration = 228, - ImportEqualsDeclaration = 229, - ImportDeclaration = 230, - ImportClause = 231, - NamespaceImport = 232, - NamedImports = 233, - ImportSpecifier = 234, - ExportAssignment = 235, - ExportDeclaration = 236, - NamedExports = 237, - ExportSpecifier = 238, - MissingDeclaration = 239, - ExternalModuleReference = 240, - JsxElement = 241, - JsxSelfClosingElement = 242, - JsxOpeningElement = 243, - JsxText = 244, + JsxText = 10, + RegularExpressionLiteral = 11, + NoSubstitutionTemplateLiteral = 12, + TemplateHead = 13, + TemplateMiddle = 14, + TemplateTail = 15, + OpenBraceToken = 16, + CloseBraceToken = 17, + OpenParenToken = 18, + CloseParenToken = 19, + OpenBracketToken = 20, + CloseBracketToken = 21, + DotToken = 22, + DotDotDotToken = 23, + SemicolonToken = 24, + CommaToken = 25, + LessThanToken = 26, + LessThanSlashToken = 27, + GreaterThanToken = 28, + LessThanEqualsToken = 29, + GreaterThanEqualsToken = 30, + EqualsEqualsToken = 31, + ExclamationEqualsToken = 32, + EqualsEqualsEqualsToken = 33, + ExclamationEqualsEqualsToken = 34, + EqualsGreaterThanToken = 35, + PlusToken = 36, + MinusToken = 37, + AsteriskToken = 38, + AsteriskAsteriskToken = 39, + SlashToken = 40, + PercentToken = 41, + PlusPlusToken = 42, + MinusMinusToken = 43, + LessThanLessThanToken = 44, + GreaterThanGreaterThanToken = 45, + GreaterThanGreaterThanGreaterThanToken = 46, + AmpersandToken = 47, + BarToken = 48, + CaretToken = 49, + ExclamationToken = 50, + TildeToken = 51, + AmpersandAmpersandToken = 52, + BarBarToken = 53, + QuestionToken = 54, + ColonToken = 55, + AtToken = 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 = 69, + Identifier = 70, + BreakKeyword = 71, + CaseKeyword = 72, + CatchKeyword = 73, + ClassKeyword = 74, + ConstKeyword = 75, + ContinueKeyword = 76, + DebuggerKeyword = 77, + DefaultKeyword = 78, + DeleteKeyword = 79, + DoKeyword = 80, + ElseKeyword = 81, + EnumKeyword = 82, + ExportKeyword = 83, + ExtendsKeyword = 84, + FalseKeyword = 85, + FinallyKeyword = 86, + ForKeyword = 87, + FunctionKeyword = 88, + IfKeyword = 89, + ImportKeyword = 90, + InKeyword = 91, + InstanceOfKeyword = 92, + NewKeyword = 93, + NullKeyword = 94, + ReturnKeyword = 95, + SuperKeyword = 96, + SwitchKeyword = 97, + ThisKeyword = 98, + ThrowKeyword = 99, + TrueKeyword = 100, + TryKeyword = 101, + TypeOfKeyword = 102, + VarKeyword = 103, + VoidKeyword = 104, + WhileKeyword = 105, + WithKeyword = 106, + ImplementsKeyword = 107, + InterfaceKeyword = 108, + LetKeyword = 109, + PackageKeyword = 110, + PrivateKeyword = 111, + ProtectedKeyword = 112, + PublicKeyword = 113, + StaticKeyword = 114, + YieldKeyword = 115, + AbstractKeyword = 116, + AsKeyword = 117, + AnyKeyword = 118, + AsyncKeyword = 119, + AwaitKeyword = 120, + BooleanKeyword = 121, + ConstructorKeyword = 122, + DeclareKeyword = 123, + GetKeyword = 124, + IsKeyword = 125, + ModuleKeyword = 126, + NamespaceKeyword = 127, + NeverKeyword = 128, + ReadonlyKeyword = 129, + RequireKeyword = 130, + NumberKeyword = 131, + SetKeyword = 132, + StringKeyword = 133, + SymbolKeyword = 134, + TypeKeyword = 135, + UndefinedKeyword = 136, + FromKeyword = 137, + GlobalKeyword = 138, + OfKeyword = 139, + QualifiedName = 140, + ComputedPropertyName = 141, + TypeParameter = 142, + Parameter = 143, + Decorator = 144, + PropertySignature = 145, + PropertyDeclaration = 146, + MethodSignature = 147, + MethodDeclaration = 148, + Constructor = 149, + GetAccessor = 150, + SetAccessor = 151, + CallSignature = 152, + ConstructSignature = 153, + IndexSignature = 154, + TypePredicate = 155, + TypeReference = 156, + FunctionType = 157, + ConstructorType = 158, + TypeQuery = 159, + TypeLiteral = 160, + ArrayType = 161, + TupleType = 162, + UnionType = 163, + IntersectionType = 164, + ParenthesizedType = 165, + ThisType = 166, + LiteralType = 167, + ObjectBindingPattern = 168, + ArrayBindingPattern = 169, + BindingElement = 170, + ArrayLiteralExpression = 171, + ObjectLiteralExpression = 172, + PropertyAccessExpression = 173, + ElementAccessExpression = 174, + CallExpression = 175, + NewExpression = 176, + TaggedTemplateExpression = 177, + TypeAssertionExpression = 178, + ParenthesizedExpression = 179, + FunctionExpression = 180, + ArrowFunction = 181, + DeleteExpression = 182, + TypeOfExpression = 183, + VoidExpression = 184, + AwaitExpression = 185, + PrefixUnaryExpression = 186, + PostfixUnaryExpression = 187, + BinaryExpression = 188, + ConditionalExpression = 189, + TemplateExpression = 190, + YieldExpression = 191, + SpreadElementExpression = 192, + ClassExpression = 193, + OmittedExpression = 194, + ExpressionWithTypeArguments = 195, + AsExpression = 196, + NonNullExpression = 197, + TemplateSpan = 198, + SemicolonClassElement = 199, + Block = 200, + VariableStatement = 201, + EmptyStatement = 202, + ExpressionStatement = 203, + IfStatement = 204, + DoStatement = 205, + WhileStatement = 206, + ForStatement = 207, + ForInStatement = 208, + ForOfStatement = 209, + ContinueStatement = 210, + BreakStatement = 211, + ReturnStatement = 212, + WithStatement = 213, + SwitchStatement = 214, + LabeledStatement = 215, + ThrowStatement = 216, + TryStatement = 217, + DebuggerStatement = 218, + VariableDeclaration = 219, + VariableDeclarationList = 220, + FunctionDeclaration = 221, + ClassDeclaration = 222, + InterfaceDeclaration = 223, + TypeAliasDeclaration = 224, + EnumDeclaration = 225, + ModuleDeclaration = 226, + ModuleBlock = 227, + CaseBlock = 228, + NamespaceExportDeclaration = 229, + ImportEqualsDeclaration = 230, + ImportDeclaration = 231, + ImportClause = 232, + NamespaceImport = 233, + NamedImports = 234, + ImportSpecifier = 235, + ExportAssignment = 236, + ExportDeclaration = 237, + NamedExports = 238, + ExportSpecifier = 239, + MissingDeclaration = 240, + ExternalModuleReference = 241, + JsxElement = 242, + JsxSelfClosingElement = 243, + JsxOpeningElement = 244, JsxClosingElement = 245, JsxAttribute = 246, JsxSpreadAttribute = 247, @@ -327,31 +327,31 @@ declare namespace ts { NotEmittedStatement = 287, PartiallyEmittedExpression = 288, Count = 289, - FirstAssignment = 56, - LastAssignment = 68, - FirstCompoundAssignment = 57, - LastCompoundAssignment = 68, - FirstReservedWord = 70, - LastReservedWord = 105, - FirstKeyword = 70, - LastKeyword = 138, - FirstFutureReservedWord = 106, - LastFutureReservedWord = 114, - FirstTypeNode = 154, - LastTypeNode = 166, - FirstPunctuation = 15, - LastPunctuation = 68, + FirstAssignment = 57, + LastAssignment = 69, + FirstCompoundAssignment = 58, + LastCompoundAssignment = 69, + FirstReservedWord = 71, + LastReservedWord = 106, + FirstKeyword = 71, + LastKeyword = 139, + FirstFutureReservedWord = 107, + LastFutureReservedWord = 115, + FirstTypeNode = 155, + LastTypeNode = 167, + FirstPunctuation = 16, + LastPunctuation = 69, FirstToken = 0, - LastToken = 138, + LastToken = 139, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, - LastLiteralToken = 11, - FirstTemplateToken = 11, - LastTemplateToken = 14, - FirstBinaryOperator = 25, - LastBinaryOperator = 68, - FirstNode = 139, + LastLiteralToken = 12, + FirstTemplateToken = 12, + LastTemplateToken = 15, + FirstBinaryOperator = 26, + LastBinaryOperator = 69, + FirstNode = 140, FirstJSDocNode = 257, LastJSDocNode = 282, FirstJSDocTagNode = 273, @@ -406,6 +406,7 @@ declare namespace ts { AccessibilityModifier = 28, ParameterPropertyModifier = 92, NonPublicAccessibilityModifier = 24, + TypeScriptModifier = 2270, } enum JsxFlags { None = 0, @@ -1351,8 +1352,9 @@ declare namespace ts { TrueCondition = 32, FalseCondition = 64, SwitchClause = 128, - Referenced = 256, - Shared = 512, + ArrayMutation = 256, + Referenced = 512, + Shared = 1024, Label = 12, Condition = 96, } @@ -1380,6 +1382,10 @@ declare namespace ts { clauseEnd: number; antecedent: FlowNode; } + interface FlowArrayMutation extends FlowNode { + node: CallExpression | BinaryExpression; + antecedent: FlowNode; + } type FlowType = Type | IncompleteType; interface IncompleteType { flags: TypeFlags; @@ -1913,7 +1919,6 @@ declare namespace ts { AMD = 2, UMD = 3, System = 4, - ES6 = 5, ES2015 = 5, } enum JsxEmit { @@ -1939,9 +1944,10 @@ declare namespace ts { enum ScriptTarget { ES3 = 0, ES5 = 1, - ES6 = 2, ES2015 = 2, - Latest = 2, + ES2016 = 3, + ES2017 = 4, + Latest = 4, } enum LanguageVariant { Standard = 0, diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index c534a725901..dad603b624a 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -37,259 +37,259 @@ var ts; // Literals SyntaxKind[SyntaxKind["NumericLiteral"] = 8] = "NumericLiteral"; SyntaxKind[SyntaxKind["StringLiteral"] = 9] = "StringLiteral"; - SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 10] = "RegularExpressionLiteral"; - SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 11] = "NoSubstitutionTemplateLiteral"; + SyntaxKind[SyntaxKind["JsxText"] = 10] = "JsxText"; + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 11] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 12] = "NoSubstitutionTemplateLiteral"; // Pseudo-literals - SyntaxKind[SyntaxKind["TemplateHead"] = 12] = "TemplateHead"; - SyntaxKind[SyntaxKind["TemplateMiddle"] = 13] = "TemplateMiddle"; - SyntaxKind[SyntaxKind["TemplateTail"] = 14] = "TemplateTail"; + SyntaxKind[SyntaxKind["TemplateHead"] = 13] = "TemplateHead"; + SyntaxKind[SyntaxKind["TemplateMiddle"] = 14] = "TemplateMiddle"; + SyntaxKind[SyntaxKind["TemplateTail"] = 15] = "TemplateTail"; // Punctuation - SyntaxKind[SyntaxKind["OpenBraceToken"] = 15] = "OpenBraceToken"; - SyntaxKind[SyntaxKind["CloseBraceToken"] = 16] = "CloseBraceToken"; - SyntaxKind[SyntaxKind["OpenParenToken"] = 17] = "OpenParenToken"; - SyntaxKind[SyntaxKind["CloseParenToken"] = 18] = "CloseParenToken"; - SyntaxKind[SyntaxKind["OpenBracketToken"] = 19] = "OpenBracketToken"; - SyntaxKind[SyntaxKind["CloseBracketToken"] = 20] = "CloseBracketToken"; - SyntaxKind[SyntaxKind["DotToken"] = 21] = "DotToken"; - SyntaxKind[SyntaxKind["DotDotDotToken"] = 22] = "DotDotDotToken"; - SyntaxKind[SyntaxKind["SemicolonToken"] = 23] = "SemicolonToken"; - SyntaxKind[SyntaxKind["CommaToken"] = 24] = "CommaToken"; - SyntaxKind[SyntaxKind["LessThanToken"] = 25] = "LessThanToken"; - SyntaxKind[SyntaxKind["LessThanSlashToken"] = 26] = "LessThanSlashToken"; - SyntaxKind[SyntaxKind["GreaterThanToken"] = 27] = "GreaterThanToken"; - SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 28] = "LessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 29] = "GreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 30] = "EqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 31] = "ExclamationEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 32] = "EqualsEqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 33] = "ExclamationEqualsEqualsToken"; - SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 34] = "EqualsGreaterThanToken"; - SyntaxKind[SyntaxKind["PlusToken"] = 35] = "PlusToken"; - SyntaxKind[SyntaxKind["MinusToken"] = 36] = "MinusToken"; - SyntaxKind[SyntaxKind["AsteriskToken"] = 37] = "AsteriskToken"; - 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"; + SyntaxKind[SyntaxKind["OpenBraceToken"] = 16] = "OpenBraceToken"; + SyntaxKind[SyntaxKind["CloseBraceToken"] = 17] = "CloseBraceToken"; + SyntaxKind[SyntaxKind["OpenParenToken"] = 18] = "OpenParenToken"; + SyntaxKind[SyntaxKind["CloseParenToken"] = 19] = "CloseParenToken"; + SyntaxKind[SyntaxKind["OpenBracketToken"] = 20] = "OpenBracketToken"; + SyntaxKind[SyntaxKind["CloseBracketToken"] = 21] = "CloseBracketToken"; + SyntaxKind[SyntaxKind["DotToken"] = 22] = "DotToken"; + SyntaxKind[SyntaxKind["DotDotDotToken"] = 23] = "DotDotDotToken"; + SyntaxKind[SyntaxKind["SemicolonToken"] = 24] = "SemicolonToken"; + SyntaxKind[SyntaxKind["CommaToken"] = 25] = "CommaToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 26] = "LessThanToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 27] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 28] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 29] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 30] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 31] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 32] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 33] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 34] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 35] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 36] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 37] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 38] = "AsteriskToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 39] = "AsteriskAsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 40] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 41] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 42] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 43] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 44] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 45] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 46] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 47] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 48] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 49] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 50] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 51] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 52] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 53] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 54] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 55] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 56] = "AtToken"; // Assignments - 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"; + SyntaxKind[SyntaxKind["EqualsToken"] = 57] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 58] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 59] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 60] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 61] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 62] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 63] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 64] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 65] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 66] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 67] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 68] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 69] = "CaretEqualsToken"; // Identifiers - SyntaxKind[SyntaxKind["Identifier"] = 69] = "Identifier"; + SyntaxKind[SyntaxKind["Identifier"] = 70] = "Identifier"; // Reserved words - 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"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 71] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 72] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 73] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 74] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 75] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 76] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 77] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 78] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 79] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 80] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 81] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 82] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 83] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 84] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 85] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 86] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 87] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 88] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 89] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 90] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 91] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 92] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 93] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 94] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 95] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 96] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 97] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 98] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 99] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 100] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 101] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 102] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 103] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 104] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 105] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 106] = "WithKeyword"; // Strict mode reserved words - 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"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 107] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 108] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 109] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 110] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 111] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 112] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 113] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 114] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 115] = "YieldKeyword"; // Contextual keywords - 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["NeverKeyword"] = 127] = "NeverKeyword"; - SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 128] = "ReadonlyKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 129] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 130] = "NumberKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 131] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 132] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 133] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 134] = "TypeKeyword"; - SyntaxKind[SyntaxKind["UndefinedKeyword"] = 135] = "UndefinedKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 136] = "FromKeyword"; - SyntaxKind[SyntaxKind["GlobalKeyword"] = 137] = "GlobalKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 138] = "OfKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 116] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 117] = "AsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 118] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 119] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 120] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 121] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 122] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 123] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 124] = "GetKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 125] = "IsKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 126] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 127] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 128] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 129] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 130] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 131] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 132] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 133] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 134] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 135] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 136] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 137] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 138] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 139] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 139] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 140] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 140] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 141] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 141] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 142] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 143] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 142] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 143] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 144] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 144] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 145] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 146] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 147] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 148] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 149] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 150] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 151] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 152] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 153] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 145] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 146] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 147] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 148] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 149] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 150] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 151] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 152] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 153] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 154] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 154] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 155] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 156] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 157] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 158] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 159] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 160] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 161] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 162] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 163] = "IntersectionType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 164] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 165] = "ThisType"; - SyntaxKind[SyntaxKind["LiteralType"] = 166] = "LiteralType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 155] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 156] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 157] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 158] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 159] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 160] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 161] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 162] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 163] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 164] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 165] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 166] = "ThisType"; + SyntaxKind[SyntaxKind["LiteralType"] = 167] = "LiteralType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 167] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 168] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 169] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 168] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 169] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 170] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 170] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 171] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 172] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 173] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 174] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 175] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 176] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 177] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 178] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 179] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 180] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 181] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 182] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 183] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 184] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 185] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 186] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 187] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 188] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 189] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 190] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElementExpression"] = 191] = "SpreadElementExpression"; - SyntaxKind[SyntaxKind["ClassExpression"] = 192] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 193] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 194] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 195] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 196] = "NonNullExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 171] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 172] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 173] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 174] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 175] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 176] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 177] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 178] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 179] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 180] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 181] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 182] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 183] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 184] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 185] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 186] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 187] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 188] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 189] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 190] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 191] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElementExpression"] = 192] = "SpreadElementExpression"; + SyntaxKind[SyntaxKind["ClassExpression"] = 193] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 194] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 195] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 196] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 197] = "NonNullExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 197] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 198] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 198] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 199] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 199] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 200] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 201] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 202] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 203] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 204] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 205] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 206] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 207] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 208] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 209] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 210] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 211] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 212] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 213] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 214] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 215] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 216] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 217] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 218] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 219] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 220] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 221] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 222] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 223] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 224] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 225] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 226] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 227] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 228] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 229] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 230] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 231] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 232] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 233] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 234] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 235] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 236] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 237] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 238] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 239] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 200] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 201] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 202] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 203] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 204] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 205] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 206] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 207] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 208] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 209] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 210] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 211] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 212] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 213] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 214] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 215] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 216] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 217] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 218] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 219] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 220] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 221] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 222] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 223] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 224] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 225] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 226] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 227] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 228] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 229] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 230] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 231] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 232] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 233] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 234] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 235] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 236] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 237] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 238] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 239] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 240] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 240] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 241] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 241] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 242] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 243] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxText"] = 244] = "JsxText"; + SyntaxKind[SyntaxKind["JsxElement"] = 242] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 243] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 244] = "JsxOpeningElement"; SyntaxKind[SyntaxKind["JsxClosingElement"] = 245] = "JsxClosingElement"; SyntaxKind[SyntaxKind["JsxAttribute"] = 246] = "JsxAttribute"; SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 247] = "JsxSpreadAttribute"; @@ -346,31 +346,31 @@ var ts; // Enum value count SyntaxKind[SyntaxKind["Count"] = 289] = "Count"; // Markers - SyntaxKind[SyntaxKind["FirstAssignment"] = 56] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 68] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 57] = "FirstCompoundAssignment"; - SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 68] = "LastCompoundAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 70] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 105] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 70] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 138] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 106] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 114] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 154] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 166] = "LastTypeNode"; - SyntaxKind[SyntaxKind["FirstPunctuation"] = 15] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 68] = "LastPunctuation"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 57] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 69] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 58] = "FirstCompoundAssignment"; + SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 69] = "LastCompoundAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 71] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 106] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 71] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 139] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 107] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 115] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 155] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 167] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstPunctuation"] = 16] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 69] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 138] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 139] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; - SyntaxKind[SyntaxKind["LastLiteralToken"] = 11] = "LastLiteralToken"; - SyntaxKind[SyntaxKind["FirstTemplateToken"] = 11] = "FirstTemplateToken"; - SyntaxKind[SyntaxKind["LastTemplateToken"] = 14] = "LastTemplateToken"; - SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 25] = "FirstBinaryOperator"; - SyntaxKind[SyntaxKind["LastBinaryOperator"] = 68] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 139] = "FirstNode"; + SyntaxKind[SyntaxKind["LastLiteralToken"] = 12] = "LastLiteralToken"; + SyntaxKind[SyntaxKind["FirstTemplateToken"] = 12] = "FirstTemplateToken"; + SyntaxKind[SyntaxKind["LastTemplateToken"] = 15] = "LastTemplateToken"; + SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 26] = "FirstBinaryOperator"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 69] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstNode"] = 140] = "FirstNode"; SyntaxKind[SyntaxKind["FirstJSDocNode"] = 257] = "FirstJSDocNode"; SyntaxKind[SyntaxKind["LastJSDocNode"] = 282] = "LastJSDocNode"; SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 273] = "FirstJSDocTagNode"; @@ -430,6 +430,7 @@ var ts; // Accessibility modifiers and 'readonly' can be attached to a parameter in a constructor to make it a property. ModifierFlags[ModifierFlags["ParameterPropertyModifier"] = 92] = "ParameterPropertyModifier"; ModifierFlags[ModifierFlags["NonPublicAccessibilityModifier"] = 24] = "NonPublicAccessibilityModifier"; + ModifierFlags[ModifierFlags["TypeScriptModifier"] = 2270] = "TypeScriptModifier"; })(ts.ModifierFlags || (ts.ModifierFlags = {})); var ModifierFlags = ts.ModifierFlags; (function (JsxFlags) { @@ -466,8 +467,9 @@ var ts; FlowFlags[FlowFlags["TrueCondition"] = 32] = "TrueCondition"; FlowFlags[FlowFlags["FalseCondition"] = 64] = "FalseCondition"; FlowFlags[FlowFlags["SwitchClause"] = 128] = "SwitchClause"; - FlowFlags[FlowFlags["Referenced"] = 256] = "Referenced"; - FlowFlags[FlowFlags["Shared"] = 512] = "Shared"; + FlowFlags[FlowFlags["ArrayMutation"] = 256] = "ArrayMutation"; + FlowFlags[FlowFlags["Referenced"] = 512] = "Referenced"; + FlowFlags[FlowFlags["Shared"] = 1024] = "Shared"; FlowFlags[FlowFlags["Label"] = 12] = "Label"; FlowFlags[FlowFlags["Condition"] = 96] = "Condition"; })(ts.FlowFlags || (ts.FlowFlags = {})); @@ -755,7 +757,6 @@ var ts; ModuleKind[ModuleKind["AMD"] = 2] = "AMD"; ModuleKind[ModuleKind["UMD"] = 3] = "UMD"; ModuleKind[ModuleKind["System"] = 4] = "System"; - ModuleKind[ModuleKind["ES6"] = 5] = "ES6"; ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015"; })(ts.ModuleKind || (ts.ModuleKind = {})); var ModuleKind = ts.ModuleKind; @@ -781,9 +782,10 @@ var ts; (function (ScriptTarget) { ScriptTarget[ScriptTarget["ES3"] = 0] = "ES3"; ScriptTarget[ScriptTarget["ES5"] = 1] = "ES5"; - ScriptTarget[ScriptTarget["ES6"] = 2] = "ES6"; ScriptTarget[ScriptTarget["ES2015"] = 2] = "ES2015"; - ScriptTarget[ScriptTarget["Latest"] = 2] = "Latest"; + ScriptTarget[ScriptTarget["ES2016"] = 3] = "ES2016"; + ScriptTarget[ScriptTarget["ES2017"] = 4] = "ES2017"; + ScriptTarget[ScriptTarget["Latest"] = 4] = "Latest"; })(ts.ScriptTarget || (ts.ScriptTarget = {})); var ScriptTarget = ts.ScriptTarget; (function (LanguageVariant) { @@ -940,55 +942,58 @@ var ts; TransformFlags[TransformFlags["ContainsTypeScript"] = 2] = "ContainsTypeScript"; TransformFlags[TransformFlags["Jsx"] = 4] = "Jsx"; TransformFlags[TransformFlags["ContainsJsx"] = 8] = "ContainsJsx"; - TransformFlags[TransformFlags["ES7"] = 16] = "ES7"; - TransformFlags[TransformFlags["ContainsES7"] = 32] = "ContainsES7"; - TransformFlags[TransformFlags["ES6"] = 64] = "ES6"; - TransformFlags[TransformFlags["ContainsES6"] = 128] = "ContainsES6"; - TransformFlags[TransformFlags["DestructuringAssignment"] = 256] = "DestructuringAssignment"; - TransformFlags[TransformFlags["Generator"] = 512] = "Generator"; - TransformFlags[TransformFlags["ContainsGenerator"] = 1024] = "ContainsGenerator"; + TransformFlags[TransformFlags["ES2017"] = 16] = "ES2017"; + TransformFlags[TransformFlags["ContainsES2017"] = 32] = "ContainsES2017"; + TransformFlags[TransformFlags["ES2016"] = 64] = "ES2016"; + TransformFlags[TransformFlags["ContainsES2016"] = 128] = "ContainsES2016"; + TransformFlags[TransformFlags["ES2015"] = 256] = "ES2015"; + TransformFlags[TransformFlags["ContainsES2015"] = 512] = "ContainsES2015"; + TransformFlags[TransformFlags["DestructuringAssignment"] = 1024] = "DestructuringAssignment"; + TransformFlags[TransformFlags["Generator"] = 2048] = "Generator"; + TransformFlags[TransformFlags["ContainsGenerator"] = 4096] = "ContainsGenerator"; // Markers // - Flags used to indicate that a subtree contains a specific transformation. - TransformFlags[TransformFlags["ContainsDecorators"] = 2048] = "ContainsDecorators"; - TransformFlags[TransformFlags["ContainsPropertyInitializer"] = 4096] = "ContainsPropertyInitializer"; - TransformFlags[TransformFlags["ContainsLexicalThis"] = 8192] = "ContainsLexicalThis"; - TransformFlags[TransformFlags["ContainsCapturedLexicalThis"] = 16384] = "ContainsCapturedLexicalThis"; - TransformFlags[TransformFlags["ContainsLexicalThisInComputedPropertyName"] = 32768] = "ContainsLexicalThisInComputedPropertyName"; - TransformFlags[TransformFlags["ContainsDefaultValueAssignments"] = 65536] = "ContainsDefaultValueAssignments"; - TransformFlags[TransformFlags["ContainsParameterPropertyAssignments"] = 131072] = "ContainsParameterPropertyAssignments"; - TransformFlags[TransformFlags["ContainsSpreadElementExpression"] = 262144] = "ContainsSpreadElementExpression"; - TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 524288] = "ContainsComputedPropertyName"; - TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 1048576] = "ContainsBlockScopedBinding"; - TransformFlags[TransformFlags["ContainsBindingPattern"] = 2097152] = "ContainsBindingPattern"; - TransformFlags[TransformFlags["ContainsYield"] = 4194304] = "ContainsYield"; - TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 8388608] = "ContainsHoistedDeclarationOrCompletion"; + TransformFlags[TransformFlags["ContainsDecorators"] = 8192] = "ContainsDecorators"; + TransformFlags[TransformFlags["ContainsPropertyInitializer"] = 16384] = "ContainsPropertyInitializer"; + TransformFlags[TransformFlags["ContainsLexicalThis"] = 32768] = "ContainsLexicalThis"; + TransformFlags[TransformFlags["ContainsCapturedLexicalThis"] = 65536] = "ContainsCapturedLexicalThis"; + TransformFlags[TransformFlags["ContainsLexicalThisInComputedPropertyName"] = 131072] = "ContainsLexicalThisInComputedPropertyName"; + TransformFlags[TransformFlags["ContainsDefaultValueAssignments"] = 262144] = "ContainsDefaultValueAssignments"; + TransformFlags[TransformFlags["ContainsParameterPropertyAssignments"] = 524288] = "ContainsParameterPropertyAssignments"; + TransformFlags[TransformFlags["ContainsSpreadElementExpression"] = 1048576] = "ContainsSpreadElementExpression"; + TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 2097152] = "ContainsComputedPropertyName"; + TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 4194304] = "ContainsBlockScopedBinding"; + TransformFlags[TransformFlags["ContainsBindingPattern"] = 8388608] = "ContainsBindingPattern"; + TransformFlags[TransformFlags["ContainsYield"] = 16777216] = "ContainsYield"; + TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 33554432] = "ContainsHoistedDeclarationOrCompletion"; TransformFlags[TransformFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; // Assertions // - Bitmasks that are used to assert facts about the syntax of a node and its subtree. TransformFlags[TransformFlags["AssertTypeScript"] = 3] = "AssertTypeScript"; TransformFlags[TransformFlags["AssertJsx"] = 12] = "AssertJsx"; - TransformFlags[TransformFlags["AssertES7"] = 48] = "AssertES7"; - TransformFlags[TransformFlags["AssertES6"] = 192] = "AssertES6"; - TransformFlags[TransformFlags["AssertGenerator"] = 1536] = "AssertGenerator"; + TransformFlags[TransformFlags["AssertES2017"] = 48] = "AssertES2017"; + TransformFlags[TransformFlags["AssertES2016"] = 192] = "AssertES2016"; + TransformFlags[TransformFlags["AssertES2015"] = 768] = "AssertES2015"; + TransformFlags[TransformFlags["AssertGenerator"] = 6144] = "AssertGenerator"; // Scope Exclusions // - Bitmasks that exclude flags from propagating out of a specific context // into the subtree flags of their container. - TransformFlags[TransformFlags["NodeExcludes"] = 536871765] = "NodeExcludes"; - TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 550710101] = "ArrowFunctionExcludes"; - TransformFlags[TransformFlags["FunctionExcludes"] = 550726485] = "FunctionExcludes"; - TransformFlags[TransformFlags["ConstructorExcludes"] = 550593365] = "ConstructorExcludes"; - TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 550593365] = "MethodOrAccessorExcludes"; - TransformFlags[TransformFlags["ClassExcludes"] = 537590613] = "ClassExcludes"; - TransformFlags[TransformFlags["ModuleExcludes"] = 546335573] = "ModuleExcludes"; + TransformFlags[TransformFlags["NodeExcludes"] = 536874325] = "NodeExcludes"; + TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 592227669] = "ArrowFunctionExcludes"; + TransformFlags[TransformFlags["FunctionExcludes"] = 592293205] = "FunctionExcludes"; + TransformFlags[TransformFlags["ConstructorExcludes"] = 591760725] = "ConstructorExcludes"; + TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 591760725] = "MethodOrAccessorExcludes"; + TransformFlags[TransformFlags["ClassExcludes"] = 539749717] = "ClassExcludes"; + TransformFlags[TransformFlags["ModuleExcludes"] = 574729557] = "ModuleExcludes"; TransformFlags[TransformFlags["TypeExcludes"] = -3] = "TypeExcludes"; - TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 537430869] = "ObjectLiteralExcludes"; - TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 537133909] = "ArrayLiteralOrCallOrNewExcludes"; - TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 538968917] = "VariableDeclarationListExcludes"; - TransformFlags[TransformFlags["ParameterExcludes"] = 538968917] = "ParameterExcludes"; + TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 539110741] = "ObjectLiteralExcludes"; + TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 537922901] = "ArrayLiteralOrCallOrNewExcludes"; + TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 545262933] = "VariableDeclarationListExcludes"; + TransformFlags[TransformFlags["ParameterExcludes"] = 545262933] = "ParameterExcludes"; // Masks // - Additional bitmasks - TransformFlags[TransformFlags["TypeScriptClassSyntaxMask"] = 137216] = "TypeScriptClassSyntaxMask"; - TransformFlags[TransformFlags["ES6FunctionSyntaxMask"] = 81920] = "ES6FunctionSyntaxMask"; + TransformFlags[TransformFlags["TypeScriptClassSyntaxMask"] = 548864] = "TypeScriptClassSyntaxMask"; + TransformFlags[TransformFlags["ES2015FunctionSyntaxMask"] = 327680] = "ES2015FunctionSyntaxMask"; })(ts.TransformFlags || (ts.TransformFlags = {})); var TransformFlags = ts.TransformFlags; /* @internal */ @@ -1044,7 +1049,7 @@ var ts; (function (performance) { var profilerEvent = typeof onProfilerEvent === "function" && onProfilerEvent.profiler === true ? onProfilerEvent - : function (markName) { }; + : function (_markName) { }; var enabled = false; var profilerStart = 0; var counts; @@ -1146,6 +1151,8 @@ var ts; })(ts.Ternary || (ts.Ternary = {})); var Ternary = ts.Ternary; var createObject = Object.create; + // More efficient to create a collator once and use its `compare` than to call `a.localeCompare(b)` many times. + ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; function createMap(template) { var map = createObject(null); // tslint:disable-line:no-null-keyword // Using 'delete' on an object causes V8 to put the object in dictionary mode. @@ -1171,7 +1178,7 @@ var ts; remove: remove, forEachValue: forEachValueInMap, getKeys: getKeys, - clear: clear + clear: clear, }; function forEachValueInMap(f) { for (var key in files) { @@ -1378,13 +1385,33 @@ var ts; if (array) { result = []; for (var i = 0; i < array.length; i++) { - var v = array[i]; - result.push(f(v, i)); + result.push(f(array[i], i)); } } return result; } ts.map = map; + // Maps from T to T and avoids allocation if all elements map to themselves + function sameMap(array, f) { + var result; + if (array) { + for (var i = 0; i < array.length; i++) { + if (result) { + result.push(f(array[i], i)); + } + else { + var item = array[i]; + var mapped = f(item, i); + if (item !== mapped) { + result = array.slice(0, i); + result.push(mapped); + } + } + } + } + return result || array; + } + ts.sameMap = sameMap; /** * Flattens an array containing a mix of array or non-array elements. * @@ -1507,6 +1534,18 @@ var ts; return result; } ts.mapObject = mapObject; + function some(array, predicate) { + if (array) { + for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { + var v = array_5[_i]; + if (!predicate || predicate(v)) { + return true; + } + } + } + return false; + } + ts.some = some; function concatenate(array1, array2) { if (!array2 || !array2.length) return array1; @@ -1520,8 +1559,8 @@ var ts; var result; if (array) { result = []; - loop: for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { - var item = array_5[_i]; + loop: for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { + var item = array_6[_i]; for (var _a = 0, result_1 = result; _a < result_1.length; _a++) { var res = result_1[_a]; if (areEqual ? areEqual(res, item) : res === item) { @@ -1557,8 +1596,8 @@ var ts; ts.compact = compact; function sum(array, prop) { var result = 0; - for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { - var v = array_6[_i]; + for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { + var v = array_7[_i]; result += v[prop]; } return result; @@ -1857,8 +1896,8 @@ var ts; ts.equalOwnProperties = equalOwnProperties; function arrayToMap(array, makeKey, makeValue) { var result = createMap(); - for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { - var value = array_7[_i]; + for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { + var value = array_8[_i]; result[makeKey(value)] = makeValue ? makeValue(value) : value; } return result; @@ -1971,7 +2010,7 @@ var ts; return function (t) { return compose(a(t)); }; } else { - return function (t) { return function (u) { return u; }; }; + return function (_) { return function (u) { return u; }; }; } } ts.chain = chain; @@ -2002,7 +2041,7 @@ var ts; ts.compose = compose; function formatStringFromArgs(text, args, baseIndex) { baseIndex = baseIndex || 0; - return text.replace(/{(\d+)}/g, function (match, index) { return args[+index + baseIndex]; }); + return text.replace(/{(\d+)}/g, function (_match, index) { return args[+index + baseIndex]; }); } ts.localizedDiagnosticMessages = undefined; function getLocaleSpecificMessage(message) { @@ -2027,12 +2066,12 @@ var ts; length: length, messageText: text, category: message.category, - code: message.code + code: message.code, }; } ts.createFileDiagnostic = createFileDiagnostic; /* internal */ - function formatMessage(dummy, message) { + function formatMessage(_dummy, message) { var text = getLocaleSpecificMessage(message); if (arguments.length > 2) { text = formatStringFromArgs(text, arguments, 2); @@ -2095,7 +2134,8 @@ var ts; if (b === undefined) return 1 /* GreaterThan */; if (ignoreCase) { - if (String.prototype.localeCompare) { + if (ts.collator && String.prototype.localeCompare) { + // accent means a ≠ b, a ≠ á, a = A var result = a.localeCompare(b, /*locales*/ undefined, { usage: "sort", sensitivity: "accent" }); return result < 0 ? -1 /* LessThan */ : result > 0 ? 1 /* GreaterThan */ : 0 /* EqualTo */; } @@ -2269,7 +2309,7 @@ var ts; function getEmitModuleKind(compilerOptions) { return typeof compilerOptions.module === "number" ? compilerOptions.module : - getEmitScriptTarget(compilerOptions) === 2 /* ES6 */ ? ts.ModuleKind.ES6 : ts.ModuleKind.CommonJS; + getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */ ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS; } ts.getEmitModuleKind = getEmitModuleKind; /* @internal */ @@ -2617,7 +2657,7 @@ var ts; function replaceWildcardCharacter(match, singleAsteriskRegexFragment) { return match === "*" ? singleAsteriskRegexFragment : match === "?" ? "[^/]" : "\\" + match; } - function getFileMatcherPatterns(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory) { + function getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory) { path = normalizePath(path); currentDirectory = normalizePath(currentDirectory); var absolutePath = combinePaths(currentDirectory, path); @@ -2632,7 +2672,7 @@ var ts; function matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, getFileSystemEntries) { path = normalizePath(path); currentDirectory = normalizePath(currentDirectory); - var patterns = getFileMatcherPatterns(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory); + var patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory); var regexFlag = useCaseSensitiveFileNames ? "" : "i"; var includeFileRegex = patterns.includeFilePattern && new RegExp(patterns.includeFilePattern, regexFlag); var includeDirectoryRegex = patterns.includeDirectoryPattern && new RegExp(patterns.includeDirectoryPattern, regexFlag); @@ -2847,10 +2887,10 @@ var ts; this.name = name; this.declarations = undefined; } - function Type(checker, flags) { + function Type(_checker, flags) { this.flags = flags; } - function Signature(checker) { + function Signature() { } function Node(kind, pos, end) { this.id = 0; @@ -3230,7 +3270,7 @@ var ts; } var platform = _os.platform(); var useCaseSensitiveFileNames = isFileSystemCaseSensitive(); - function readFile(fileName, encoding) { + function readFile(fileName, _encoding) { if (!fileExists(fileName)) { return undefined; } @@ -3462,7 +3502,7 @@ var ts; args: ChakraHost.args, useCaseSensitiveFileNames: !!ChakraHost.useCaseSensitiveFileNames, write: ChakraHost.echo, - readFile: function (path, encoding) { + readFile: function (path, _encoding) { // encoding is automatically handled by the implementation in ChakraHost return ChakraHost.readFile(path); }, @@ -3480,9 +3520,9 @@ var ts; getExecutingFilePath: function () { return ChakraHost.executingFile; }, getCurrentDirectory: function () { return ChakraHost.currentDirectory; }, getDirectories: ChakraHost.getDirectories, - getEnvironmentVariable: ChakraHost.getEnvironmentVariable || (function (name) { return ""; }), + getEnvironmentVariable: ChakraHost.getEnvironmentVariable || (function () { return ""; }), readDirectory: function (path, extensions, excludes, includes) { - var pattern = ts.getFileMatcherPatterns(path, extensions, excludes, includes, !!ChakraHost.useCaseSensitiveFileNames, ChakraHost.currentDirectory); + var pattern = ts.getFileMatcherPatterns(path, excludes, includes, !!ChakraHost.useCaseSensitiveFileNames, ChakraHost.currentDirectory); return ChakraHost.readDirectory(path, extensions, pattern.basePaths, pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern); }, exit: ChakraHost.quit, @@ -4276,7 +4316,7 @@ var ts; Binding_element_0_implicitly_has_an_1_type: { code: 7031, category: ts.DiagnosticCategory.Error, key: "Binding_element_0_implicitly_has_an_1_type_7031", message: "Binding element '{0}' implicitly has an '{1}' type." }, Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation: { code: 7032, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation_7032", message: "Property '{0}' implicitly has type 'any', because its set accessor lacks a parameter type annotation." }, Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation: { code: 7033, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation_7033", message: "Property '{0}' implicitly has type 'any', because its get accessor lacks a return type annotation." }, - Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined: { code: 7034, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined_7034", message: "Variable '{0}' implicitly has type 'any' in some locations where its type cannot be determined." }, + Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined: { code: 7034, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined_7034", message: "Variable '{0}' implicitly has type '{1}' in some locations where its type cannot be determined." }, You_cannot_rename_this_element: { code: 8000, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_this_element_8000", message: "You cannot rename this element." }, You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", message: "You cannot rename elements that are defined in the standard TypeScript library." }, import_can_only_be_used_in_a_ts_file: { code: 8002, category: ts.DiagnosticCategory.Error, key: "import_can_only_be_used_in_a_ts_file_8002", message: "'import ... =' can only be used in a .ts file." }, @@ -4313,7 +4353,7 @@ var ts; Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers" }, Implement_interface_on_reference: { code: 90005, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_reference_90005", message: "Implement interface on reference" }, Implement_interface_on_class: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_class_90006", message: "Implement interface on class" }, - Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" } + Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" }, }; })(ts || (ts = {})); /// @@ -4322,133 +4362,133 @@ var ts; (function (ts) { /* @internal */ function tokenIsIdentifierOrKeyword(token) { - return token >= 69 /* Identifier */; + return token >= 70 /* Identifier */; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; var textToToken = ts.createMap({ - "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": 136 /* 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 */, - "never": 127 /* NeverKeyword */, - "new": 92 /* NewKeyword */, - "null": 93 /* NullKeyword */, - "number": 130 /* NumberKeyword */, - "package": 109 /* PackageKeyword */, - "private": 110 /* PrivateKeyword */, - "protected": 111 /* ProtectedKeyword */, - "public": 112 /* PublicKeyword */, - "readonly": 128 /* ReadonlyKeyword */, - "require": 129 /* RequireKeyword */, - "global": 137 /* GlobalKeyword */, - "return": 94 /* ReturnKeyword */, - "set": 131 /* SetKeyword */, - "static": 113 /* StaticKeyword */, - "string": 132 /* StringKeyword */, - "super": 95 /* SuperKeyword */, - "switch": 96 /* SwitchKeyword */, - "symbol": 133 /* SymbolKeyword */, - "this": 97 /* ThisKeyword */, - "throw": 98 /* ThrowKeyword */, - "true": 99 /* TrueKeyword */, - "try": 100 /* TryKeyword */, - "type": 134 /* TypeKeyword */, - "typeof": 101 /* TypeOfKeyword */, - "undefined": 135 /* UndefinedKeyword */, - "var": 102 /* VarKeyword */, - "void": 103 /* VoidKeyword */, - "while": 104 /* WhileKeyword */, - "with": 105 /* WithKeyword */, - "yield": 114 /* YieldKeyword */, - "async": 118 /* AsyncKeyword */, - "await": 119 /* AwaitKeyword */, - "of": 138 /* OfKeyword */, - "{": 15 /* OpenBraceToken */, - "}": 16 /* CloseBraceToken */, - "(": 17 /* OpenParenToken */, - ")": 18 /* CloseParenToken */, - "[": 19 /* OpenBracketToken */, - "]": 20 /* CloseBracketToken */, - ".": 21 /* DotToken */, - "...": 22 /* DotDotDotToken */, - ";": 23 /* SemicolonToken */, - ",": 24 /* CommaToken */, - "<": 25 /* LessThanToken */, - ">": 27 /* GreaterThanToken */, - "<=": 28 /* LessThanEqualsToken */, - ">=": 29 /* GreaterThanEqualsToken */, - "==": 30 /* EqualsEqualsToken */, - "!=": 31 /* ExclamationEqualsToken */, - "===": 32 /* EqualsEqualsEqualsToken */, - "!==": 33 /* ExclamationEqualsEqualsToken */, - "=>": 34 /* EqualsGreaterThanToken */, - "+": 35 /* PlusToken */, - "-": 36 /* MinusToken */, - "**": 38 /* AsteriskAsteriskToken */, - "*": 37 /* AsteriskToken */, - "/": 39 /* SlashToken */, - "%": 40 /* PercentToken */, - "++": 41 /* PlusPlusToken */, - "--": 42 /* MinusMinusToken */, - "<<": 43 /* LessThanLessThanToken */, - ">": 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 */ + "abstract": 116 /* AbstractKeyword */, + "any": 118 /* AnyKeyword */, + "as": 117 /* AsKeyword */, + "boolean": 121 /* BooleanKeyword */, + "break": 71 /* BreakKeyword */, + "case": 72 /* CaseKeyword */, + "catch": 73 /* CatchKeyword */, + "class": 74 /* ClassKeyword */, + "continue": 76 /* ContinueKeyword */, + "const": 75 /* ConstKeyword */, + "constructor": 122 /* ConstructorKeyword */, + "debugger": 77 /* DebuggerKeyword */, + "declare": 123 /* DeclareKeyword */, + "default": 78 /* DefaultKeyword */, + "delete": 79 /* DeleteKeyword */, + "do": 80 /* DoKeyword */, + "else": 81 /* ElseKeyword */, + "enum": 82 /* EnumKeyword */, + "export": 83 /* ExportKeyword */, + "extends": 84 /* ExtendsKeyword */, + "false": 85 /* FalseKeyword */, + "finally": 86 /* FinallyKeyword */, + "for": 87 /* ForKeyword */, + "from": 137 /* FromKeyword */, + "function": 88 /* FunctionKeyword */, + "get": 124 /* GetKeyword */, + "if": 89 /* IfKeyword */, + "implements": 107 /* ImplementsKeyword */, + "import": 90 /* ImportKeyword */, + "in": 91 /* InKeyword */, + "instanceof": 92 /* InstanceOfKeyword */, + "interface": 108 /* InterfaceKeyword */, + "is": 125 /* IsKeyword */, + "let": 109 /* LetKeyword */, + "module": 126 /* ModuleKeyword */, + "namespace": 127 /* NamespaceKeyword */, + "never": 128 /* NeverKeyword */, + "new": 93 /* NewKeyword */, + "null": 94 /* NullKeyword */, + "number": 131 /* NumberKeyword */, + "package": 110 /* PackageKeyword */, + "private": 111 /* PrivateKeyword */, + "protected": 112 /* ProtectedKeyword */, + "public": 113 /* PublicKeyword */, + "readonly": 129 /* ReadonlyKeyword */, + "require": 130 /* RequireKeyword */, + "global": 138 /* GlobalKeyword */, + "return": 95 /* ReturnKeyword */, + "set": 132 /* SetKeyword */, + "static": 114 /* StaticKeyword */, + "string": 133 /* StringKeyword */, + "super": 96 /* SuperKeyword */, + "switch": 97 /* SwitchKeyword */, + "symbol": 134 /* SymbolKeyword */, + "this": 98 /* ThisKeyword */, + "throw": 99 /* ThrowKeyword */, + "true": 100 /* TrueKeyword */, + "try": 101 /* TryKeyword */, + "type": 135 /* TypeKeyword */, + "typeof": 102 /* TypeOfKeyword */, + "undefined": 136 /* UndefinedKeyword */, + "var": 103 /* VarKeyword */, + "void": 104 /* VoidKeyword */, + "while": 105 /* WhileKeyword */, + "with": 106 /* WithKeyword */, + "yield": 115 /* YieldKeyword */, + "async": 119 /* AsyncKeyword */, + "await": 120 /* AwaitKeyword */, + "of": 139 /* OfKeyword */, + "{": 16 /* OpenBraceToken */, + "}": 17 /* CloseBraceToken */, + "(": 18 /* OpenParenToken */, + ")": 19 /* CloseParenToken */, + "[": 20 /* OpenBracketToken */, + "]": 21 /* CloseBracketToken */, + ".": 22 /* DotToken */, + "...": 23 /* DotDotDotToken */, + ";": 24 /* SemicolonToken */, + ",": 25 /* CommaToken */, + "<": 26 /* LessThanToken */, + ">": 28 /* GreaterThanToken */, + "<=": 29 /* LessThanEqualsToken */, + ">=": 30 /* GreaterThanEqualsToken */, + "==": 31 /* EqualsEqualsToken */, + "!=": 32 /* ExclamationEqualsToken */, + "===": 33 /* EqualsEqualsEqualsToken */, + "!==": 34 /* ExclamationEqualsEqualsToken */, + "=>": 35 /* EqualsGreaterThanToken */, + "+": 36 /* PlusToken */, + "-": 37 /* MinusToken */, + "**": 39 /* AsteriskAsteriskToken */, + "*": 38 /* AsteriskToken */, + "/": 40 /* SlashToken */, + "%": 41 /* PercentToken */, + "++": 42 /* PlusPlusToken */, + "--": 43 /* MinusMinusToken */, + "<<": 44 /* LessThanLessThanToken */, + ">": 45 /* GreaterThanGreaterThanToken */, + ">>>": 46 /* GreaterThanGreaterThanGreaterThanToken */, + "&": 47 /* AmpersandToken */, + "|": 48 /* BarToken */, + "^": 49 /* CaretToken */, + "!": 50 /* ExclamationToken */, + "~": 51 /* TildeToken */, + "&&": 52 /* AmpersandAmpersandToken */, + "||": 53 /* BarBarToken */, + "?": 54 /* QuestionToken */, + ":": 55 /* ColonToken */, + "=": 57 /* EqualsToken */, + "+=": 58 /* PlusEqualsToken */, + "-=": 59 /* MinusEqualsToken */, + "*=": 60 /* AsteriskEqualsToken */, + "**=": 61 /* AsteriskAsteriskEqualsToken */, + "/=": 62 /* SlashEqualsToken */, + "%=": 63 /* PercentEqualsToken */, + "<<=": 64 /* LessThanLessThanEqualsToken */, + ">>=": 65 /* GreaterThanGreaterThanEqualsToken */, + ">>>=": 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */, + "&=": 67 /* AmpersandEqualsToken */, + "|=": 68 /* BarEqualsToken */, + "^=": 69 /* CaretEqualsToken */, + "@": 56 /* AtToken */, }); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers @@ -4952,7 +4992,7 @@ var ts; return iterateCommentRanges(/*reduce*/ true, text, pos, /*trailing*/ true, cb, state, initial); } ts.reduceEachTrailingCommentRange = reduceEachTrailingCommentRange; - function appendCommentRange(pos, end, kind, hasTrailingNewLine, state, comments) { + function appendCommentRange(pos, end, kind, hasTrailingNewLine, _state, comments) { if (!comments) { comments = []; } @@ -5025,8 +5065,8 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 69 /* Identifier */ || token > 105 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 70 /* FirstReservedWord */ && token <= 105 /* LastReservedWord */; }, + isIdentifier: function () { return token === 70 /* Identifier */ || token > 106 /* LastReservedWord */; }, + isReservedWord: function () { return token >= 71 /* FirstReservedWord */ && token <= 106 /* LastReservedWord */; }, isUnterminated: function () { return tokenIsUnterminated; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, @@ -5045,7 +5085,7 @@ var ts; setTextPos: setTextPos, tryScan: tryScan, lookAhead: lookAhead, - scanRange: scanRange + scanRange: scanRange, }; function error(message, length) { if (onError) { @@ -5174,7 +5214,7 @@ var ts; contents += text.substring(start, pos); tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 11 /* NoSubstitutionTemplateLiteral */ : 14 /* TemplateTail */; + resultingToken = startedWithBacktick ? 12 /* NoSubstitutionTemplateLiteral */ : 15 /* TemplateTail */; break; } var currChar = text.charCodeAt(pos); @@ -5182,14 +5222,14 @@ var ts; if (currChar === 96 /* backtick */) { contents += text.substring(start, pos); pos++; - resultingToken = startedWithBacktick ? 11 /* NoSubstitutionTemplateLiteral */ : 14 /* TemplateTail */; + resultingToken = startedWithBacktick ? 12 /* NoSubstitutionTemplateLiteral */ : 15 /* TemplateTail */; break; } // '${' if (currChar === 36 /* $ */ && pos + 1 < end && text.charCodeAt(pos + 1) === 123 /* openBrace */) { contents += text.substring(start, pos); pos += 2; - resultingToken = startedWithBacktick ? 12 /* TemplateHead */ : 13 /* TemplateMiddle */; + resultingToken = startedWithBacktick ? 13 /* TemplateHead */ : 14 /* TemplateMiddle */; break; } // Escape character @@ -5367,7 +5407,7 @@ var ts; return token = textToToken[tokenValue]; } } - return token = 69 /* Identifier */; + return token = 70 /* Identifier */; } function scanBinaryOrOctalDigits(base) { ts.Debug.assert(base === 2 || base === 8, "Expected either base 2 or base 8"); @@ -5447,12 +5487,12 @@ var ts; case 33 /* exclamation */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 33 /* ExclamationEqualsEqualsToken */; + return pos += 3, token = 34 /* ExclamationEqualsEqualsToken */; } - return pos += 2, token = 31 /* ExclamationEqualsToken */; + return pos += 2, token = 32 /* ExclamationEqualsToken */; } pos++; - return token = 49 /* ExclamationToken */; + return token = 50 /* ExclamationToken */; case 34 /* doubleQuote */: case 39 /* singleQuote */: tokenValue = scanString(); @@ -5461,68 +5501,68 @@ var ts; return token = scanTemplateAndSetTokenValue(); case 37 /* percent */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 62 /* PercentEqualsToken */; + return pos += 2, token = 63 /* PercentEqualsToken */; } pos++; - return token = 40 /* PercentToken */; + return token = 41 /* PercentToken */; case 38 /* ampersand */: if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - return pos += 2, token = 51 /* AmpersandAmpersandToken */; + return pos += 2, token = 52 /* AmpersandAmpersandToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 66 /* AmpersandEqualsToken */; + return pos += 2, token = 67 /* AmpersandEqualsToken */; } pos++; - return token = 46 /* AmpersandToken */; + return token = 47 /* AmpersandToken */; case 40 /* openParen */: pos++; - return token = 17 /* OpenParenToken */; + return token = 18 /* OpenParenToken */; case 41 /* closeParen */: pos++; - return token = 18 /* CloseParenToken */; + return token = 19 /* CloseParenToken */; case 42 /* asterisk */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 59 /* AsteriskEqualsToken */; + return pos += 2, token = 60 /* AsteriskEqualsToken */; } if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 60 /* AsteriskAsteriskEqualsToken */; + return pos += 3, token = 61 /* AsteriskAsteriskEqualsToken */; } - return pos += 2, token = 38 /* AsteriskAsteriskToken */; + return pos += 2, token = 39 /* AsteriskAsteriskToken */; } pos++; - return token = 37 /* AsteriskToken */; + return token = 38 /* AsteriskToken */; case 43 /* plus */: if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 41 /* PlusPlusToken */; + return pos += 2, token = 42 /* PlusPlusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 57 /* PlusEqualsToken */; + return pos += 2, token = 58 /* PlusEqualsToken */; } pos++; - return token = 35 /* PlusToken */; + return token = 36 /* PlusToken */; case 44 /* comma */: pos++; - return token = 24 /* CommaToken */; + return token = 25 /* CommaToken */; case 45 /* minus */: if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 42 /* MinusMinusToken */; + return pos += 2, token = 43 /* MinusMinusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 58 /* MinusEqualsToken */; + return pos += 2, token = 59 /* MinusEqualsToken */; } pos++; - return token = 36 /* MinusToken */; + return token = 37 /* MinusToken */; case 46 /* dot */: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = scanNumber(); return token = 8 /* NumericLiteral */; } if (text.charCodeAt(pos + 1) === 46 /* dot */ && text.charCodeAt(pos + 2) === 46 /* dot */) { - return pos += 3, token = 22 /* DotDotDotToken */; + return pos += 3, token = 23 /* DotDotDotToken */; } pos++; - return token = 21 /* DotToken */; + return token = 22 /* DotToken */; case 47 /* slash */: // Single-line comment if (text.charCodeAt(pos + 1) === 47 /* slash */) { @@ -5568,10 +5608,10 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 61 /* SlashEqualsToken */; + return pos += 2, token = 62 /* SlashEqualsToken */; } pos++; - return token = 39 /* SlashToken */; + return token = 40 /* SlashToken */; case 48 /* _0 */: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { pos += 2; @@ -5624,10 +5664,10 @@ var ts; return token = 8 /* NumericLiteral */; case 58 /* colon */: pos++; - return token = 54 /* ColonToken */; + return token = 55 /* ColonToken */; case 59 /* semicolon */: pos++; - return token = 23 /* SemicolonToken */; + return token = 24 /* SemicolonToken */; case 60 /* lessThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -5640,20 +5680,20 @@ var ts; } if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 63 /* LessThanLessThanEqualsToken */; + return pos += 3, token = 64 /* LessThanLessThanEqualsToken */; } - return pos += 2, token = 43 /* LessThanLessThanToken */; + return pos += 2, token = 44 /* LessThanLessThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 28 /* LessThanEqualsToken */; + return pos += 2, token = 29 /* LessThanEqualsToken */; } if (languageVariant === 1 /* JSX */ && text.charCodeAt(pos + 1) === 47 /* slash */ && text.charCodeAt(pos + 2) !== 42 /* asterisk */) { - return pos += 2, token = 26 /* LessThanSlashToken */; + return pos += 2, token = 27 /* LessThanSlashToken */; } pos++; - return token = 25 /* LessThanToken */; + return token = 26 /* LessThanToken */; case 61 /* equals */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -5666,15 +5706,15 @@ var ts; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 32 /* EqualsEqualsEqualsToken */; + return pos += 3, token = 33 /* EqualsEqualsEqualsToken */; } - return pos += 2, token = 30 /* EqualsEqualsToken */; + return pos += 2, token = 31 /* EqualsEqualsToken */; } if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 34 /* EqualsGreaterThanToken */; + return pos += 2, token = 35 /* EqualsGreaterThanToken */; } pos++; - return token = 56 /* EqualsToken */; + return token = 57 /* EqualsToken */; case 62 /* greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -5686,43 +5726,43 @@ var ts; } } pos++; - return token = 27 /* GreaterThanToken */; + return token = 28 /* GreaterThanToken */; case 63 /* question */: pos++; - return token = 53 /* QuestionToken */; + return token = 54 /* QuestionToken */; case 91 /* openBracket */: pos++; - return token = 19 /* OpenBracketToken */; + return token = 20 /* OpenBracketToken */; case 93 /* closeBracket */: pos++; - return token = 20 /* CloseBracketToken */; + return token = 21 /* CloseBracketToken */; case 94 /* caret */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 68 /* CaretEqualsToken */; + return pos += 2, token = 69 /* CaretEqualsToken */; } pos++; - return token = 48 /* CaretToken */; + return token = 49 /* CaretToken */; case 123 /* openBrace */: pos++; - return token = 15 /* OpenBraceToken */; + return token = 16 /* OpenBraceToken */; case 124 /* bar */: if (text.charCodeAt(pos + 1) === 124 /* bar */) { - return pos += 2, token = 52 /* BarBarToken */; + return pos += 2, token = 53 /* BarBarToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 67 /* BarEqualsToken */; + return pos += 2, token = 68 /* BarEqualsToken */; } pos++; - return token = 47 /* BarToken */; + return token = 48 /* BarToken */; case 125 /* closeBrace */: pos++; - return token = 16 /* CloseBraceToken */; + return token = 17 /* CloseBraceToken */; case 126 /* tilde */: pos++; - return token = 50 /* TildeToken */; + return token = 51 /* TildeToken */; case 64 /* at */: pos++; - return token = 55 /* AtToken */; + return token = 56 /* AtToken */; case 92 /* backslash */: var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { @@ -5760,29 +5800,29 @@ var ts; } } function reScanGreaterToken() { - if (token === 27 /* GreaterThanToken */) { + if (token === 28 /* GreaterThanToken */) { if (text.charCodeAt(pos) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + return pos += 3, token = 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 45 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 46 /* GreaterThanGreaterThanGreaterThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 64 /* GreaterThanGreaterThanEqualsToken */; + return pos += 2, token = 65 /* GreaterThanGreaterThanEqualsToken */; } pos++; - return token = 44 /* GreaterThanGreaterThanToken */; + return token = 45 /* GreaterThanGreaterThanToken */; } if (text.charCodeAt(pos) === 61 /* equals */) { pos++; - return token = 29 /* GreaterThanEqualsToken */; + return token = 30 /* GreaterThanEqualsToken */; } } return token; } function reScanSlashToken() { - if (token === 39 /* SlashToken */ || token === 61 /* SlashEqualsToken */) { + if (token === 40 /* SlashToken */ || token === 62 /* SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -5827,7 +5867,7 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 10 /* RegularExpressionLiteral */; + token = 11 /* RegularExpressionLiteral */; } return token; } @@ -5835,7 +5875,7 @@ var ts; * Unconditionally back up and scan a template expression portion. */ function reScanTemplateToken() { - ts.Debug.assert(token === 16 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); + ts.Debug.assert(token === 17 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); pos = tokenPos; return token = scanTemplateAndSetTokenValue(); } @@ -5852,14 +5892,14 @@ var ts; if (char === 60 /* lessThan */) { if (text.charCodeAt(pos + 1) === 47 /* slash */) { pos += 2; - return token = 26 /* LessThanSlashToken */; + return token = 27 /* LessThanSlashToken */; } pos++; - return token = 25 /* LessThanToken */; + return token = 26 /* LessThanToken */; } if (char === 123 /* openBrace */) { pos++; - return token = 15 /* OpenBraceToken */; + return token = 16 /* OpenBraceToken */; } while (pos < end) { pos++; @@ -5868,7 +5908,7 @@ var ts; break; } } - return token = 244 /* JsxText */; + return token = 10 /* JsxText */; } // Scans a JSX identifier; these differ from normal identifiers in that // they allow dashes @@ -5918,39 +5958,39 @@ var ts; return token = 5 /* WhitespaceTrivia */; case 64 /* at */: pos++; - return token = 55 /* AtToken */; + return token = 56 /* AtToken */; case 10 /* lineFeed */: case 13 /* carriageReturn */: pos++; return token = 4 /* NewLineTrivia */; case 42 /* asterisk */: pos++; - return token = 37 /* AsteriskToken */; + return token = 38 /* AsteriskToken */; case 123 /* openBrace */: pos++; - return token = 15 /* OpenBraceToken */; + return token = 16 /* OpenBraceToken */; case 125 /* closeBrace */: pos++; - return token = 16 /* CloseBraceToken */; + return token = 17 /* CloseBraceToken */; case 91 /* openBracket */: pos++; - return token = 19 /* OpenBracketToken */; + return token = 20 /* OpenBracketToken */; case 93 /* closeBracket */: pos++; - return token = 20 /* CloseBracketToken */; + return token = 21 /* CloseBracketToken */; case 61 /* equals */: pos++; - return token = 56 /* EqualsToken */; + return token = 57 /* EqualsToken */; case 44 /* comma */: pos++; - return token = 24 /* CommaToken */; + return token = 25 /* CommaToken */; } - if (isIdentifierStart(ch, 2 /* Latest */)) { + if (isIdentifierStart(ch, 4 /* Latest */)) { pos++; - while (isIdentifierPart(text.charCodeAt(pos), 2 /* Latest */) && pos < end) { + while (isIdentifierPart(text.charCodeAt(pos), 4 /* Latest */) && pos < end) { pos++; } - return token = 69 /* Identifier */; + return token = 70 /* Identifier */; } else { return pos += 1, token = 0 /* Unknown */; @@ -6189,11 +6229,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 199 /* Block */: - case 227 /* CaseBlock */: - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: + case 200 /* Block */: + case 228 /* CaseBlock */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: return true; } return false; @@ -6329,14 +6369,14 @@ var ts; function getLiteralText(node, sourceFile, languageVersion) { // Any template literal or string literal with an extended escape // (e.g. "\u{0067}") will need to be downleveled as a escaped string literal. - if (languageVersion < 2 /* ES6 */ && (isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { + if (languageVersion < 2 /* ES2015 */ && (isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { return getQuotedEscapedLiteralText('"', node.text, '"'); } // If we don't need to downlevel and we can reach the original source text using // the node's parent reference, then simply get the text as it was originally written. if (!nodeIsSynthesized(node) && node.parent) { var text = getSourceTextOfNodeFromSourceFile(sourceFile, node); - if (languageVersion < 2 /* ES6 */ && isBinaryOrOctalIntegerLiteral(node, text)) { + if (languageVersion < 2 /* ES2015 */ && isBinaryOrOctalIntegerLiteral(node, text)) { return node.text; } return text; @@ -6346,13 +6386,13 @@ var ts; switch (node.kind) { case 9 /* StringLiteral */: return getQuotedEscapedLiteralText('"', node.text, '"'); - case 11 /* NoSubstitutionTemplateLiteral */: + case 12 /* NoSubstitutionTemplateLiteral */: return getQuotedEscapedLiteralText("`", node.text, "`"); - case 12 /* TemplateHead */: + case 13 /* TemplateHead */: return getQuotedEscapedLiteralText("`", node.text, "${"); - case 13 /* TemplateMiddle */: + case 14 /* TemplateMiddle */: return getQuotedEscapedLiteralText("}", node.text, "${"); - case 14 /* TemplateTail */: + case 15 /* TemplateTail */: return getQuotedEscapedLiteralText("}", node.text, "`"); case 8 /* NumericLiteral */: return node.text; @@ -6398,7 +6438,7 @@ var ts; } ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isAmbientModule(node) { - return node && node.kind === 225 /* ModuleDeclaration */ && + return node && node.kind === 226 /* ModuleDeclaration */ && (node.name.kind === 9 /* StringLiteral */ || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; @@ -6408,11 +6448,11 @@ var ts; ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { // The only kind of module that can be missing a body is a shorthand ambient module. - return node.kind === 225 /* ModuleDeclaration */ && (!node.body); + return node.kind === 226 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { return node.kind === 256 /* SourceFile */ || - node.kind === 225 /* ModuleDeclaration */ || + node.kind === 226 /* ModuleDeclaration */ || isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -6430,7 +6470,7 @@ var ts; switch (node.parent.kind) { case 256 /* SourceFile */: return ts.isExternalModule(node.parent); - case 226 /* ModuleBlock */: + case 227 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -6439,21 +6479,21 @@ var ts; function isBlockScope(node, parentNode) { switch (node.kind) { case 256 /* SourceFile */: - case 227 /* CaseBlock */: + case 228 /* CaseBlock */: case 252 /* CatchClause */: - case 225 /* ModuleDeclaration */: - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: - case 148 /* Constructor */: - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 226 /* ModuleDeclaration */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: + case 149 /* Constructor */: + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: return true; - case 199 /* Block */: + case 200 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return parentNode && !isFunctionLike(parentNode); @@ -6475,7 +6515,7 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 218 /* VariableDeclaration */ && + declaration.kind === 219 /* VariableDeclaration */ && declaration.parent && declaration.parent.kind === 252 /* CatchClause */; } @@ -6515,7 +6555,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 199 /* Block */) { + if (node.body && node.body.kind === 200 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -6538,23 +6578,23 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 218 /* VariableDeclaration */: - case 169 /* BindingElement */: - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - case 222 /* InterfaceDeclaration */: - case 225 /* ModuleDeclaration */: - case 224 /* EnumDeclaration */: + case 219 /* VariableDeclaration */: + case 170 /* BindingElement */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 223 /* InterfaceDeclaration */: + case 226 /* ModuleDeclaration */: + case 225 /* EnumDeclaration */: case 255 /* EnumMember */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 223 /* TypeAliasDeclaration */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 224 /* TypeAliasDeclaration */: errorNode = node.name; break; - case 180 /* ArrowFunction */: + case 181 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -6577,7 +6617,7 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 224 /* EnumDeclaration */ && isConst(node); + return node.kind === 225 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -6590,11 +6630,11 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 174 /* CallExpression */ && n.expression.kind === 95 /* SuperKeyword */; + return n.kind === 175 /* CallExpression */ && n.expression.kind === 96 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isPrologueDirective(node) { - return node.kind === 202 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; + return node.kind === 203 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { @@ -6610,10 +6650,10 @@ var ts; } ts.getJsDocComments = getJsDocComments; function getJsDocCommentsFromText(node, text) { - var commentRanges = (node.kind === 142 /* Parameter */ || - node.kind === 141 /* TypeParameter */ || - node.kind === 179 /* FunctionExpression */ || - node.kind === 180 /* ArrowFunction */) ? + var commentRanges = (node.kind === 143 /* Parameter */ || + node.kind === 142 /* TypeParameter */ || + node.kind === 180 /* FunctionExpression */ || + node.kind === 181 /* ArrowFunction */) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : getLeadingCommentRangesOfNodeFromText(node, text); return ts.filter(commentRanges, isJsDocComment); @@ -6629,39 +6669,39 @@ var ts; ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (154 /* FirstTypeNode */ <= node.kind && node.kind <= 166 /* LastTypeNode */) { + if (155 /* FirstTypeNode */ <= node.kind && node.kind <= 167 /* LastTypeNode */) { return true; } switch (node.kind) { - case 117 /* AnyKeyword */: - case 130 /* NumberKeyword */: - case 132 /* StringKeyword */: - case 120 /* BooleanKeyword */: - case 133 /* SymbolKeyword */: - case 135 /* UndefinedKeyword */: - case 127 /* NeverKeyword */: + case 118 /* AnyKeyword */: + case 131 /* NumberKeyword */: + case 133 /* StringKeyword */: + case 121 /* BooleanKeyword */: + case 134 /* SymbolKeyword */: + case 136 /* UndefinedKeyword */: + case 128 /* NeverKeyword */: return true; - case 103 /* VoidKeyword */: - return node.parent.kind !== 183 /* VoidExpression */; - case 194 /* ExpressionWithTypeArguments */: + case 104 /* VoidKeyword */: + return node.parent.kind !== 184 /* VoidExpression */; + case 195 /* 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 69 /* Identifier */: + case 70 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 139 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 140 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 172 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 173 /* PropertyAccessExpression */ && node.parent.name === node) { node = node.parent; } // At this point, node is either a qualified name or an identifier - ts.Debug.assert(node.kind === 69 /* Identifier */ || node.kind === 139 /* QualifiedName */ || node.kind === 172 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); - case 139 /* QualifiedName */: - case 172 /* PropertyAccessExpression */: - case 97 /* ThisKeyword */: + ts.Debug.assert(node.kind === 70 /* Identifier */ || node.kind === 140 /* QualifiedName */ || node.kind === 173 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + case 140 /* QualifiedName */: + case 173 /* PropertyAccessExpression */: + case 98 /* ThisKeyword */: var parent_1 = node.parent; - if (parent_1.kind === 158 /* TypeQuery */) { + if (parent_1.kind === 159 /* TypeQuery */) { return false; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -6670,38 +6710,38 @@ var ts; // // Calling isPartOfTypeNode would consider the qualified name A.B a type node. Only C or // A.B.C is a type node. - if (154 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 166 /* LastTypeNode */) { + if (155 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 167 /* LastTypeNode */) { return true; } switch (parent_1.kind) { - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 141 /* TypeParameter */: + case 142 /* TypeParameter */: return node === parent_1.constraint; - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: - case 142 /* Parameter */: - case 218 /* VariableDeclaration */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: + case 143 /* Parameter */: + case 219 /* VariableDeclaration */: return node === parent_1.type; - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: - case 148 /* Constructor */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 149 /* Constructor */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: return node === parent_1.type; - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: return node === parent_1.type; - case 177 /* TypeAssertionExpression */: + case 178 /* TypeAssertionExpression */: return node === parent_1.type; - case 174 /* CallExpression */: - case 175 /* NewExpression */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; - case 176 /* TaggedTemplateExpression */: + case 177 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -6715,22 +6755,22 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 211 /* ReturnStatement */: + case 212 /* ReturnStatement */: return visitor(node); - case 227 /* CaseBlock */: - case 199 /* Block */: - case 203 /* IfStatement */: - case 204 /* DoStatement */: - case 205 /* WhileStatement */: - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: - case 212 /* WithStatement */: - case 213 /* SwitchStatement */: + case 228 /* CaseBlock */: + case 200 /* Block */: + case 204 /* IfStatement */: + case 205 /* DoStatement */: + case 206 /* WhileStatement */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: + case 213 /* WithStatement */: + case 214 /* SwitchStatement */: case 249 /* CaseClause */: case 250 /* DefaultClause */: - case 214 /* LabeledStatement */: - case 216 /* TryStatement */: + case 215 /* LabeledStatement */: + case 217 /* TryStatement */: case 252 /* CatchClause */: return ts.forEachChild(node, traverse); } @@ -6741,18 +6781,18 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 190 /* YieldExpression */: + case 191 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 224 /* EnumDeclaration */: - case 222 /* InterfaceDeclaration */: - case 225 /* ModuleDeclaration */: - case 223 /* TypeAliasDeclaration */: - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: + case 225 /* EnumDeclaration */: + case 223 /* InterfaceDeclaration */: + case 226 /* ModuleDeclaration */: + case 224 /* TypeAliasDeclaration */: + case 222 /* ClassDeclaration */: + case 193 /* 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. @@ -6760,7 +6800,7 @@ var ts; default: if (isFunctionLike(node)) { var name_5 = node.name; - if (name_5 && name_5.kind === 140 /* ComputedPropertyName */) { + if (name_5 && name_5.kind === 141 /* 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); @@ -6779,14 +6819,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 169 /* BindingElement */: + case 170 /* BindingElement */: case 255 /* EnumMember */: - case 142 /* Parameter */: + case 143 /* Parameter */: case 253 /* PropertyAssignment */: - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: case 254 /* ShorthandPropertyAssignment */: - case 218 /* VariableDeclaration */: + case 219 /* VariableDeclaration */: return true; } } @@ -6794,11 +6834,11 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 149 /* GetAccessor */ || node.kind === 150 /* SetAccessor */); + return node && (node.kind === 150 /* GetAccessor */ || node.kind === 151 /* SetAccessor */); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 221 /* ClassDeclaration */ || node.kind === 192 /* ClassExpression */); + return node && (node.kind === 222 /* ClassDeclaration */ || node.kind === 193 /* ClassExpression */); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -6807,19 +6847,19 @@ var ts; ts.isFunctionLike = isFunctionLike; function isFunctionLikeKind(kind) { switch (kind) { - case 148 /* Constructor */: - case 179 /* FunctionExpression */: - case 220 /* FunctionDeclaration */: - case 180 /* ArrowFunction */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: - case 156 /* FunctionType */: - case 157 /* ConstructorType */: + case 149 /* Constructor */: + case 180 /* FunctionExpression */: + case 221 /* FunctionDeclaration */: + case 181 /* ArrowFunction */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: return true; } return false; @@ -6827,13 +6867,13 @@ var ts; ts.isFunctionLikeKind = isFunctionLikeKind; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: return true; } return false; @@ -6841,30 +6881,30 @@ var ts; ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: - case 204 /* DoStatement */: - case 205 /* WhileStatement */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: + case 205 /* DoStatement */: + case 206 /* WhileStatement */: return true; - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; function isFunctionBlock(node) { - return node && node.kind === 199 /* Block */ && isFunctionLike(node.parent); + return node && node.kind === 200 /* Block */ && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 147 /* MethodDeclaration */ && node.parent.kind === 171 /* ObjectLiteralExpression */; + return node && node.kind === 148 /* MethodDeclaration */ && node.parent.kind === 172 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 147 /* MethodDeclaration */ && - (node.parent.kind === 171 /* ObjectLiteralExpression */ || - node.parent.kind === 192 /* ClassExpression */); + return node.kind === 148 /* MethodDeclaration */ && + (node.parent.kind === 172 /* ObjectLiteralExpression */ || + node.parent.kind === 193 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -6900,7 +6940,7 @@ var ts; return undefined; } switch (node.kind) { - case 140 /* ComputedPropertyName */: + case 141 /* 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 @@ -6915,9 +6955,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 143 /* Decorator */: + case 144 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 142 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 143 /* 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; @@ -6928,25 +6968,25 @@ var ts; node = node.parent; } break; - case 180 /* ArrowFunction */: + case 181 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // Fall through - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 225 /* ModuleDeclaration */: - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: - case 224 /* EnumDeclaration */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 226 /* ModuleDeclaration */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: + case 225 /* EnumDeclaration */: case 256 /* SourceFile */: return node; } @@ -6968,26 +7008,26 @@ var ts; return node; } switch (node.kind) { - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: node = node.parent; break; - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: if (!stopOnFunctions) { continue; } - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: return node; - case 143 /* Decorator */: + case 144 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 142 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 143 /* 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; @@ -7003,14 +7043,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 179 /* FunctionExpression */ || func.kind === 180 /* ArrowFunction */) { + if (func.kind === 180 /* FunctionExpression */ || func.kind === 181 /* ArrowFunction */) { var prev = func; var parent_2 = func.parent; - while (parent_2.kind === 178 /* ParenthesizedExpression */) { + while (parent_2.kind === 179 /* ParenthesizedExpression */) { prev = parent_2; parent_2 = parent_2.parent; } - if (parent_2.kind === 174 /* CallExpression */ && parent_2.expression === prev) { + if (parent_2.kind === 175 /* CallExpression */ && parent_2.expression === prev) { return parent_2; } } @@ -7021,20 +7061,20 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 172 /* PropertyAccessExpression */ || kind === 173 /* ElementAccessExpression */) - && node.expression.kind === 95 /* SuperKeyword */; + return (kind === 173 /* PropertyAccessExpression */ || kind === 174 /* ElementAccessExpression */) + && node.expression.kind === 96 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; function getEntityNameFromTypeNode(node) { if (node) { switch (node.kind) { - case 155 /* TypeReference */: + case 156 /* TypeReference */: return node.typeName; - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: ts.Debug.assert(isEntityNameExpression(node.expression)); return node.expression; - case 69 /* Identifier */: - case 139 /* QualifiedName */: + case 70 /* Identifier */: + case 140 /* QualifiedName */: return node; } } @@ -7043,10 +7083,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function isCallLikeExpression(node) { switch (node.kind) { - case 174 /* CallExpression */: - case 175 /* NewExpression */: - case 176 /* TaggedTemplateExpression */: - case 143 /* Decorator */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: + case 177 /* TaggedTemplateExpression */: + case 144 /* Decorator */: return true; default: return false; @@ -7054,7 +7094,7 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function getInvokedExpression(node) { - if (node.kind === 176 /* TaggedTemplateExpression */) { + if (node.kind === 177 /* TaggedTemplateExpression */) { return node.tag; } // Will either be a CallExpression, NewExpression, or Decorator. @@ -7063,25 +7103,25 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: // classes are valid targets return true; - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return node.parent.kind === 221 /* ClassDeclaration */; - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 147 /* MethodDeclaration */: + return node.parent.kind === 222 /* ClassDeclaration */; + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 148 /* MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. return node.body !== undefined - && node.parent.kind === 221 /* ClassDeclaration */; - case 142 /* Parameter */: + && node.parent.kind === 222 /* ClassDeclaration */; + case 143 /* 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 !== undefined - && (node.parent.kind === 148 /* Constructor */ - || node.parent.kind === 147 /* MethodDeclaration */ - || node.parent.kind === 150 /* SetAccessor */) - && node.parent.parent.kind === 221 /* ClassDeclaration */; + && (node.parent.kind === 149 /* Constructor */ + || node.parent.kind === 148 /* MethodDeclaration */ + || node.parent.kind === 151 /* SetAccessor */) + && node.parent.parent.kind === 222 /* ClassDeclaration */; } return false; } @@ -7097,18 +7137,18 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 147 /* MethodDeclaration */: - case 150 /* SetAccessor */: + case 148 /* MethodDeclaration */: + case 151 /* SetAccessor */: return ts.forEach(node.parameters, nodeIsDecorated); } } ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 243 /* JsxOpeningElement */ || - parent.kind === 242 /* JsxSelfClosingElement */ || + if (parent.kind === 244 /* JsxOpeningElement */ || + parent.kind === 243 /* JsxSelfClosingElement */ || parent.kind === 245 /* JsxClosingElement */) { return parent.tagName === node; } @@ -7117,98 +7157,98 @@ var ts; ts.isJSXTagName = isJSXTagName; function isPartOfExpression(node) { switch (node.kind) { - case 97 /* ThisKeyword */: - case 95 /* SuperKeyword */: - case 93 /* NullKeyword */: - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: - case 10 /* RegularExpressionLiteral */: - case 170 /* ArrayLiteralExpression */: - case 171 /* ObjectLiteralExpression */: - case 172 /* PropertyAccessExpression */: - case 173 /* ElementAccessExpression */: - case 174 /* CallExpression */: - case 175 /* NewExpression */: - case 176 /* TaggedTemplateExpression */: - case 195 /* AsExpression */: - case 177 /* TypeAssertionExpression */: - case 196 /* NonNullExpression */: - case 178 /* ParenthesizedExpression */: - case 179 /* FunctionExpression */: - case 192 /* ClassExpression */: - case 180 /* ArrowFunction */: - case 183 /* VoidExpression */: - case 181 /* DeleteExpression */: - case 182 /* TypeOfExpression */: - case 185 /* PrefixUnaryExpression */: - case 186 /* PostfixUnaryExpression */: - case 187 /* BinaryExpression */: - case 188 /* ConditionalExpression */: - case 191 /* SpreadElementExpression */: - case 189 /* TemplateExpression */: - case 11 /* NoSubstitutionTemplateLiteral */: - case 193 /* OmittedExpression */: - case 241 /* JsxElement */: - case 242 /* JsxSelfClosingElement */: - case 190 /* YieldExpression */: - case 184 /* AwaitExpression */: + case 98 /* ThisKeyword */: + case 96 /* SuperKeyword */: + case 94 /* NullKeyword */: + case 100 /* TrueKeyword */: + case 85 /* FalseKeyword */: + case 11 /* RegularExpressionLiteral */: + case 171 /* ArrayLiteralExpression */: + case 172 /* ObjectLiteralExpression */: + case 173 /* PropertyAccessExpression */: + case 174 /* ElementAccessExpression */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: + case 177 /* TaggedTemplateExpression */: + case 196 /* AsExpression */: + case 178 /* TypeAssertionExpression */: + case 197 /* NonNullExpression */: + case 179 /* ParenthesizedExpression */: + case 180 /* FunctionExpression */: + case 193 /* ClassExpression */: + case 181 /* ArrowFunction */: + case 184 /* VoidExpression */: + case 182 /* DeleteExpression */: + case 183 /* TypeOfExpression */: + case 186 /* PrefixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: + case 188 /* BinaryExpression */: + case 189 /* ConditionalExpression */: + case 192 /* SpreadElementExpression */: + case 190 /* TemplateExpression */: + case 12 /* NoSubstitutionTemplateLiteral */: + case 194 /* OmittedExpression */: + case 242 /* JsxElement */: + case 243 /* JsxSelfClosingElement */: + case 191 /* YieldExpression */: + case 185 /* AwaitExpression */: return true; - case 139 /* QualifiedName */: - while (node.parent.kind === 139 /* QualifiedName */) { + case 140 /* QualifiedName */: + while (node.parent.kind === 140 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 158 /* TypeQuery */ || isJSXTagName(node); - case 69 /* Identifier */: - if (node.parent.kind === 158 /* TypeQuery */ || isJSXTagName(node)) { + return node.parent.kind === 159 /* TypeQuery */ || isJSXTagName(node); + case 70 /* Identifier */: + if (node.parent.kind === 159 /* TypeQuery */ || isJSXTagName(node)) { return true; } // fall through case 8 /* NumericLiteral */: case 9 /* StringLiteral */: - case 97 /* ThisKeyword */: + case 98 /* ThisKeyword */: var parent_3 = node.parent; switch (parent_3.kind) { - case 218 /* VariableDeclaration */: - case 142 /* Parameter */: - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 219 /* VariableDeclaration */: + case 143 /* Parameter */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: case 255 /* EnumMember */: case 253 /* PropertyAssignment */: - case 169 /* BindingElement */: + case 170 /* BindingElement */: return parent_3.initializer === node; - case 202 /* ExpressionStatement */: - case 203 /* IfStatement */: - case 204 /* DoStatement */: - case 205 /* WhileStatement */: - case 211 /* ReturnStatement */: - case 212 /* WithStatement */: - case 213 /* SwitchStatement */: + case 203 /* ExpressionStatement */: + case 204 /* IfStatement */: + case 205 /* DoStatement */: + case 206 /* WhileStatement */: + case 212 /* ReturnStatement */: + case 213 /* WithStatement */: + case 214 /* SwitchStatement */: case 249 /* CaseClause */: - case 215 /* ThrowStatement */: - case 213 /* SwitchStatement */: + case 216 /* ThrowStatement */: + case 214 /* SwitchStatement */: return parent_3.expression === node; - case 206 /* ForStatement */: + case 207 /* ForStatement */: var forStatement = parent_3; - return (forStatement.initializer === node && forStatement.initializer.kind !== 219 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 220 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: var forInStatement = parent_3; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 219 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 220 /* VariableDeclarationList */) || forInStatement.expression === node; - case 177 /* TypeAssertionExpression */: - case 195 /* AsExpression */: + case 178 /* TypeAssertionExpression */: + case 196 /* AsExpression */: return node === parent_3.expression; - case 197 /* TemplateSpan */: + case 198 /* TemplateSpan */: return node === parent_3.expression; - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: return node === parent_3.expression; - case 143 /* Decorator */: + case 144 /* Decorator */: case 248 /* JsxExpression */: case 247 /* JsxSpreadAttribute */: return true; - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: return parent_3.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_3); default: if (isPartOfExpression(parent_3)) { @@ -7226,7 +7266,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 229 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 240 /* ExternalModuleReference */; + return node.kind === 230 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 241 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -7235,7 +7275,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 229 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 240 /* ExternalModuleReference */; + return node.kind === 230 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 241 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -7253,8 +7293,8 @@ var ts; */ function isRequireCall(expression, checkArgumentIsStringLiteral) { // of the form 'require("name")' - var isRequire = expression.kind === 174 /* CallExpression */ && - expression.expression.kind === 69 /* Identifier */ && + var isRequire = expression.kind === 175 /* CallExpression */ && + expression.expression.kind === 70 /* Identifier */ && expression.expression.text === "require" && expression.arguments.length === 1; return isRequire && (!checkArgumentIsStringLiteral || expression.arguments[0].kind === 9 /* StringLiteral */); @@ -7269,9 +7309,9 @@ var ts; * This function does not test if the node is in a JavaScript file or not. */ function isDeclarationOfFunctionExpression(s) { - if (s.valueDeclaration && s.valueDeclaration.kind === 218 /* VariableDeclaration */) { + if (s.valueDeclaration && s.valueDeclaration.kind === 219 /* VariableDeclaration */) { var declaration = s.valueDeclaration; - return declaration.initializer && declaration.initializer.kind === 179 /* FunctionExpression */; + return declaration.initializer && declaration.initializer.kind === 180 /* FunctionExpression */; } return false; } @@ -7282,15 +7322,15 @@ var ts; if (!isInJavaScriptFile(expression)) { return 0 /* None */; } - if (expression.kind !== 187 /* BinaryExpression */) { + if (expression.kind !== 188 /* BinaryExpression */) { return 0 /* None */; } var expr = expression; - if (expr.operatorToken.kind !== 56 /* EqualsToken */ || expr.left.kind !== 172 /* PropertyAccessExpression */) { + if (expr.operatorToken.kind !== 57 /* EqualsToken */ || expr.left.kind !== 173 /* PropertyAccessExpression */) { return 0 /* None */; } var lhs = expr.left; - if (lhs.expression.kind === 69 /* Identifier */) { + if (lhs.expression.kind === 70 /* Identifier */) { var lhsId = lhs.expression; if (lhsId.text === "exports") { // exports.name = expr @@ -7301,13 +7341,13 @@ var ts; return 2 /* ModuleExports */; } } - else if (lhs.expression.kind === 97 /* ThisKeyword */) { + else if (lhs.expression.kind === 98 /* ThisKeyword */) { return 4 /* ThisProperty */; } - else if (lhs.expression.kind === 172 /* PropertyAccessExpression */) { + else if (lhs.expression.kind === 173 /* PropertyAccessExpression */) { // chained dot, e.g. x.y.z = expr; this var is the 'x.y' part var innerPropertyAccess = lhs.expression; - if (innerPropertyAccess.expression.kind === 69 /* Identifier */) { + if (innerPropertyAccess.expression.kind === 70 /* Identifier */) { // module.exports.name = expr var innerPropertyAccessIdentifier = innerPropertyAccess.expression; if (innerPropertyAccessIdentifier.text === "module" && innerPropertyAccess.name.text === "exports") { @@ -7322,35 +7362,35 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 230 /* ImportDeclaration */) { + if (node.kind === 231 /* ImportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 229 /* ImportEqualsDeclaration */) { + if (node.kind === 230 /* ImportEqualsDeclaration */) { var reference = node.moduleReference; - if (reference.kind === 240 /* ExternalModuleReference */) { + if (reference.kind === 241 /* ExternalModuleReference */) { return reference.expression; } } - if (node.kind === 236 /* ExportDeclaration */) { + if (node.kind === 237 /* ExportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 225 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { + if (node.kind === 226 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { return node.name; } } ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { - if (node.kind === 229 /* ImportEqualsDeclaration */) { + if (node.kind === 230 /* ImportEqualsDeclaration */) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 232 /* NamespaceImport */) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 233 /* NamespaceImport */) { return importClause.namedBindings; } } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 230 /* ImportDeclaration */ + return node.kind === 231 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; } @@ -7358,13 +7398,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 142 /* Parameter */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 143 /* Parameter */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: case 254 /* ShorthandPropertyAssignment */: case 253 /* PropertyAssignment */: - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -7434,25 +7474,25 @@ var ts; // var x = function(name) { return name.length; } var isInitializerOfVariableDeclarationInStatement = isVariableLike(node.parent) && (node.parent).initializer === node && - node.parent.parent.parent.kind === 200 /* VariableStatement */; + node.parent.parent.parent.kind === 201 /* VariableStatement */; var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - node.parent.parent.kind === 200 /* VariableStatement */; + node.parent.parent.kind === 201 /* VariableStatement */; var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? node.parent.parent.parent : isVariableOfVariableDeclarationStatement ? node.parent.parent : undefined; if (variableStatementNode) { result = append(result, getJSDocs(variableStatementNode, checkParentVariableStatement, getDocs, getTags)); } - if (node.kind === 225 /* ModuleDeclaration */ && - node.parent && node.parent.kind === 225 /* ModuleDeclaration */) { + if (node.kind === 226 /* ModuleDeclaration */ && + node.parent && node.parent.kind === 226 /* ModuleDeclaration */) { result = append(result, getJSDocs(node.parent, checkParentVariableStatement, getDocs, getTags)); } // Also recognize when the node is the RHS of an assignment expression var parent_4 = node.parent; var isSourceOfAssignmentExpressionStatement = parent_4 && parent_4.parent && - parent_4.kind === 187 /* BinaryExpression */ && - parent_4.operatorToken.kind === 56 /* EqualsToken */ && - parent_4.parent.kind === 202 /* ExpressionStatement */; + parent_4.kind === 188 /* BinaryExpression */ && + parent_4.operatorToken.kind === 57 /* EqualsToken */ && + parent_4.parent.kind === 203 /* ExpressionStatement */; if (isSourceOfAssignmentExpressionStatement) { result = append(result, getJSDocs(parent_4.parent, checkParentVariableStatement, getDocs, getTags)); } @@ -7461,7 +7501,7 @@ var ts; result = append(result, getJSDocs(parent_4, checkParentVariableStatement, getDocs, getTags)); } // Pull parameter comments from declaring function as well - if (node.kind === 142 /* Parameter */) { + if (node.kind === 143 /* Parameter */) { var paramTags = getJSDocParameterTag(node, checkParentVariableStatement); if (paramTags) { result = append(result, getTags(paramTags)); @@ -7492,7 +7532,7 @@ var ts; return [paramTags[i]]; } } - else if (param.name.kind === 69 /* Identifier */) { + else if (param.name.kind === 70 /* Identifier */) { var name_6 = param.name.text; var paramTags = ts.filter(tags, function (tag) { return tag.kind === 275 /* JSDocParameterTag */ && tag.parameterName.text === name_6; }); if (paramTags) { @@ -7518,7 +7558,7 @@ var ts; } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { - if (parameter.name && parameter.name.kind === 69 /* Identifier */) { + if (parameter.name && parameter.name.kind === 70 /* Identifier */) { // If it's a parameter, see if the parent has a jsdoc comment with an @param // annotation. var parameterName = parameter.name.text; @@ -7568,12 +7608,12 @@ var ts; // assignment in an object literal that is an assignment target, or if it is parented by an array literal that is // an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ p: a}] = xxx'. function isAssignmentTarget(node) { - while (node.parent.kind === 178 /* ParenthesizedExpression */) { + while (node.parent.kind === 179 /* ParenthesizedExpression */) { node = node.parent; } while (true) { var parent_5 = node.parent; - if (parent_5.kind === 170 /* ArrayLiteralExpression */ || parent_5.kind === 191 /* SpreadElementExpression */) { + if (parent_5.kind === 171 /* ArrayLiteralExpression */ || parent_5.kind === 192 /* SpreadElementExpression */) { node = parent_5; continue; } @@ -7581,10 +7621,10 @@ var ts; node = parent_5.parent; continue; } - return parent_5.kind === 187 /* BinaryExpression */ && + return parent_5.kind === 188 /* BinaryExpression */ && isAssignmentOperator(parent_5.operatorToken.kind) && parent_5.left === node || - (parent_5.kind === 207 /* ForInStatement */ || parent_5.kind === 208 /* ForOfStatement */) && + (parent_5.kind === 208 /* ForInStatement */ || parent_5.kind === 209 /* ForOfStatement */) && parent_5.initializer === node; } } @@ -7610,11 +7650,11 @@ var ts; ts.isInAmbientContext = isInAmbientContext; // True if the given identifier, string literal, or number literal is the name of a declaration node function isDeclarationName(name) { - if (name.kind !== 69 /* Identifier */ && name.kind !== 9 /* StringLiteral */ && name.kind !== 8 /* NumericLiteral */) { + if (name.kind !== 70 /* Identifier */ && name.kind !== 9 /* StringLiteral */ && name.kind !== 8 /* NumericLiteral */) { return false; } var parent = name.parent; - if (parent.kind === 234 /* ImportSpecifier */ || parent.kind === 238 /* ExportSpecifier */) { + if (parent.kind === 235 /* ImportSpecifier */ || parent.kind === 239 /* ExportSpecifier */) { if (parent.propertyName) { return true; } @@ -7627,7 +7667,7 @@ var ts; ts.isDeclarationName = isDeclarationName; function isLiteralComputedPropertyDeclarationName(node) { return (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && - node.parent.kind === 140 /* ComputedPropertyName */ && + node.parent.kind === 141 /* ComputedPropertyName */ && isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -7635,31 +7675,31 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: case 255 /* EnumMember */: case 253 /* PropertyAssignment */: - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 139 /* QualifiedName */: + case 140 /* QualifiedName */: // Name on right hand side of dot in a type query if (parent.right === node) { - while (parent.kind === 139 /* QualifiedName */) { + while (parent.kind === 140 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 158 /* TypeQuery */; + return parent.kind === 159 /* TypeQuery */; } return false; - case 169 /* BindingElement */: - case 234 /* ImportSpecifier */: + case 170 /* BindingElement */: + case 235 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 238 /* ExportSpecifier */: + case 239 /* ExportSpecifier */: // Any name in an export specifier return true; } @@ -7675,13 +7715,13 @@ var ts; // export = // export default function isAliasSymbolDeclaration(node) { - return node.kind === 229 /* ImportEqualsDeclaration */ || - node.kind === 228 /* NamespaceExportDeclaration */ || - node.kind === 231 /* ImportClause */ && !!node.name || - node.kind === 232 /* NamespaceImport */ || - node.kind === 234 /* ImportSpecifier */ || - node.kind === 238 /* ExportSpecifier */ || - node.kind === 235 /* ExportAssignment */ && exportAssignmentIsAlias(node); + return node.kind === 230 /* ImportEqualsDeclaration */ || + node.kind === 229 /* NamespaceExportDeclaration */ || + node.kind === 232 /* ImportClause */ && !!node.name || + node.kind === 233 /* NamespaceImport */ || + node.kind === 235 /* ImportSpecifier */ || + node.kind === 239 /* ExportSpecifier */ || + node.kind === 236 /* ExportAssignment */ && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function exportAssignmentIsAlias(node) { @@ -7689,17 +7729,17 @@ var ts; } ts.exportAssignmentIsAlias = exportAssignmentIsAlias; function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 83 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 84 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 106 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 107 /* ImplementsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 83 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 84 /* ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -7767,7 +7807,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 70 /* FirstKeyword */ <= token && token <= 138 /* LastKeyword */; + return 71 /* FirstKeyword */ <= token && token <= 139 /* LastKeyword */; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -7794,7 +7834,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 140 /* ComputedPropertyName */ && + return name.kind === 141 /* ComputedPropertyName */ && !isStringOrNumericLiteral(name.expression.kind) && !isWellKnownSymbolSyntactically(name.expression); } @@ -7809,10 +7849,10 @@ var ts; } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 69 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */ || name.kind === 142 /* Parameter */) { + if (name.kind === 70 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */ || name.kind === 143 /* Parameter */) { return name.text; } - if (name.kind === 140 /* ComputedPropertyName */) { + if (name.kind === 141 /* ComputedPropertyName */) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -7833,22 +7873,26 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 69 /* Identifier */ && node.text === "Symbol"; + return node.kind === 70 /* Identifier */ && node.text === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; + function isPushOrUnshiftIdentifier(node) { + return node.text === "push" || node.text === "unshift"; + } + ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isModifierKind(token) { switch (token) { - 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 128 /* ReadonlyKeyword */: - case 113 /* StaticKeyword */: + case 116 /* AbstractKeyword */: + case 119 /* AsyncKeyword */: + case 75 /* ConstKeyword */: + case 123 /* DeclareKeyword */: + case 78 /* DefaultKeyword */: + case 83 /* ExportKeyword */: + case 113 /* PublicKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + case 129 /* ReadonlyKeyword */: + case 114 /* StaticKeyword */: return true; } return false; @@ -7856,11 +7900,11 @@ var ts; ts.isModifierKind = isModifierKind; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 142 /* Parameter */; + return root.kind === 143 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 169 /* BindingElement */) { + while (node.kind === 170 /* BindingElement */) { node = node.parent.parent; } return node; @@ -7868,14 +7912,14 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 148 /* Constructor */ - || kind === 179 /* FunctionExpression */ - || kind === 220 /* FunctionDeclaration */ - || kind === 180 /* ArrowFunction */ - || kind === 147 /* MethodDeclaration */ - || kind === 149 /* GetAccessor */ - || kind === 150 /* SetAccessor */ - || kind === 225 /* ModuleDeclaration */ + return kind === 149 /* Constructor */ + || kind === 180 /* FunctionExpression */ + || kind === 221 /* FunctionDeclaration */ + || kind === 181 /* ArrowFunction */ + || kind === 148 /* MethodDeclaration */ + || kind === 150 /* GetAccessor */ + || kind === 151 /* SetAccessor */ + || kind === 226 /* ModuleDeclaration */ || kind === 256 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; @@ -7937,38 +7981,38 @@ var ts; var Associativity = ts.Associativity; function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 175 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 176 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 175 /* NewExpression */: + case 176 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 185 /* PrefixUnaryExpression */: - case 182 /* TypeOfExpression */: - case 183 /* VoidExpression */: - case 181 /* DeleteExpression */: - case 184 /* AwaitExpression */: - case 188 /* ConditionalExpression */: - case 190 /* YieldExpression */: + case 186 /* PrefixUnaryExpression */: + case 183 /* TypeOfExpression */: + case 184 /* VoidExpression */: + case 182 /* DeleteExpression */: + case 185 /* AwaitExpression */: + case 189 /* ConditionalExpression */: + case 191 /* YieldExpression */: return 1 /* Right */; - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: switch (operator) { - case 38 /* AsteriskAsteriskToken */: - case 56 /* EqualsToken */: - case 57 /* PlusEqualsToken */: - case 58 /* MinusEqualsToken */: - case 60 /* AsteriskAsteriskEqualsToken */: - case 59 /* AsteriskEqualsToken */: - case 61 /* SlashEqualsToken */: - case 62 /* PercentEqualsToken */: - case 63 /* LessThanLessThanEqualsToken */: - case 64 /* GreaterThanGreaterThanEqualsToken */: - case 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 66 /* AmpersandEqualsToken */: - case 68 /* CaretEqualsToken */: - case 67 /* BarEqualsToken */: + case 39 /* AsteriskAsteriskToken */: + case 57 /* EqualsToken */: + case 58 /* PlusEqualsToken */: + case 59 /* MinusEqualsToken */: + case 61 /* AsteriskAsteriskEqualsToken */: + case 60 /* AsteriskEqualsToken */: + case 62 /* SlashEqualsToken */: + case 63 /* PercentEqualsToken */: + case 64 /* LessThanLessThanEqualsToken */: + case 65 /* GreaterThanGreaterThanEqualsToken */: + case 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 67 /* AmpersandEqualsToken */: + case 69 /* CaretEqualsToken */: + case 68 /* BarEqualsToken */: return 1 /* Right */; } } @@ -7977,15 +8021,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 175 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 176 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 187 /* BinaryExpression */) { + if (expression.kind === 188 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 185 /* PrefixUnaryExpression */ || expression.kind === 186 /* PostfixUnaryExpression */) { + else if (expression.kind === 186 /* PrefixUnaryExpression */ || expression.kind === 187 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -7995,106 +8039,106 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 97 /* ThisKeyword */: - case 95 /* SuperKeyword */: - case 69 /* Identifier */: - case 93 /* NullKeyword */: - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: + case 98 /* ThisKeyword */: + case 96 /* SuperKeyword */: + case 70 /* Identifier */: + case 94 /* NullKeyword */: + case 100 /* TrueKeyword */: + case 85 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: - case 170 /* ArrayLiteralExpression */: - case 171 /* ObjectLiteralExpression */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: - case 192 /* ClassExpression */: - case 241 /* JsxElement */: - case 242 /* JsxSelfClosingElement */: - case 10 /* RegularExpressionLiteral */: - case 11 /* NoSubstitutionTemplateLiteral */: - case 189 /* TemplateExpression */: - case 178 /* ParenthesizedExpression */: - case 193 /* OmittedExpression */: + case 171 /* ArrayLiteralExpression */: + case 172 /* ObjectLiteralExpression */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 193 /* ClassExpression */: + case 242 /* JsxElement */: + case 243 /* JsxSelfClosingElement */: + case 11 /* RegularExpressionLiteral */: + case 12 /* NoSubstitutionTemplateLiteral */: + case 190 /* TemplateExpression */: + case 179 /* ParenthesizedExpression */: + case 194 /* OmittedExpression */: return 19; - case 176 /* TaggedTemplateExpression */: - case 172 /* PropertyAccessExpression */: - case 173 /* ElementAccessExpression */: + case 177 /* TaggedTemplateExpression */: + case 173 /* PropertyAccessExpression */: + case 174 /* ElementAccessExpression */: return 18; - case 175 /* NewExpression */: + case 176 /* NewExpression */: return hasArguments ? 18 : 17; - case 174 /* CallExpression */: + case 175 /* CallExpression */: return 17; - case 186 /* PostfixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: return 16; - case 185 /* PrefixUnaryExpression */: - case 182 /* TypeOfExpression */: - case 183 /* VoidExpression */: - case 181 /* DeleteExpression */: - case 184 /* AwaitExpression */: + case 186 /* PrefixUnaryExpression */: + case 183 /* TypeOfExpression */: + case 184 /* VoidExpression */: + case 182 /* DeleteExpression */: + case 185 /* AwaitExpression */: return 15; - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: switch (operatorKind) { - case 49 /* ExclamationToken */: - case 50 /* TildeToken */: + case 50 /* ExclamationToken */: + case 51 /* TildeToken */: return 15; - case 38 /* AsteriskAsteriskToken */: - case 37 /* AsteriskToken */: - case 39 /* SlashToken */: - case 40 /* PercentToken */: + case 39 /* AsteriskAsteriskToken */: + case 38 /* AsteriskToken */: + case 40 /* SlashToken */: + case 41 /* PercentToken */: return 14; - case 35 /* PlusToken */: - case 36 /* MinusToken */: + case 36 /* PlusToken */: + case 37 /* MinusToken */: return 13; - case 43 /* LessThanLessThanToken */: - case 44 /* GreaterThanGreaterThanToken */: - case 45 /* GreaterThanGreaterThanGreaterThanToken */: + case 44 /* LessThanLessThanToken */: + case 45 /* GreaterThanGreaterThanToken */: + case 46 /* GreaterThanGreaterThanGreaterThanToken */: return 12; - case 25 /* LessThanToken */: - case 28 /* LessThanEqualsToken */: - case 27 /* GreaterThanToken */: - case 29 /* GreaterThanEqualsToken */: - case 90 /* InKeyword */: - case 91 /* InstanceOfKeyword */: + case 26 /* LessThanToken */: + case 29 /* LessThanEqualsToken */: + case 28 /* GreaterThanToken */: + case 30 /* GreaterThanEqualsToken */: + case 91 /* InKeyword */: + case 92 /* InstanceOfKeyword */: return 11; - case 30 /* EqualsEqualsToken */: - case 32 /* EqualsEqualsEqualsToken */: - case 31 /* ExclamationEqualsToken */: - case 33 /* ExclamationEqualsEqualsToken */: + case 31 /* EqualsEqualsToken */: + case 33 /* EqualsEqualsEqualsToken */: + case 32 /* ExclamationEqualsToken */: + case 34 /* ExclamationEqualsEqualsToken */: return 10; - case 46 /* AmpersandToken */: + case 47 /* AmpersandToken */: return 9; - case 48 /* CaretToken */: + case 49 /* CaretToken */: return 8; - case 47 /* BarToken */: + case 48 /* BarToken */: return 7; - case 51 /* AmpersandAmpersandToken */: + case 52 /* AmpersandAmpersandToken */: return 6; - case 52 /* BarBarToken */: + case 53 /* BarBarToken */: return 5; - case 56 /* EqualsToken */: - case 57 /* PlusEqualsToken */: - case 58 /* MinusEqualsToken */: - case 60 /* AsteriskAsteriskEqualsToken */: - case 59 /* AsteriskEqualsToken */: - case 61 /* SlashEqualsToken */: - case 62 /* PercentEqualsToken */: - case 63 /* LessThanLessThanEqualsToken */: - case 64 /* GreaterThanGreaterThanEqualsToken */: - case 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 66 /* AmpersandEqualsToken */: - case 68 /* CaretEqualsToken */: - case 67 /* BarEqualsToken */: + case 57 /* EqualsToken */: + case 58 /* PlusEqualsToken */: + case 59 /* MinusEqualsToken */: + case 61 /* AsteriskAsteriskEqualsToken */: + case 60 /* AsteriskEqualsToken */: + case 62 /* SlashEqualsToken */: + case 63 /* PercentEqualsToken */: + case 64 /* LessThanLessThanEqualsToken */: + case 65 /* GreaterThanGreaterThanEqualsToken */: + case 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 67 /* AmpersandEqualsToken */: + case 69 /* CaretEqualsToken */: + case 68 /* BarEqualsToken */: return 3; - case 24 /* CommaToken */: + case 25 /* CommaToken */: return 0; default: return -1; } - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: return 4; - case 190 /* YieldExpression */: + case 191 /* YieldExpression */: return 2; - case 191 /* SpreadElementExpression */: + case 192 /* SpreadElementExpression */: return 1; default: return -1; @@ -8395,7 +8439,7 @@ var ts; var options = host.getCompilerOptions(); // Emit on each source file if (options.outFile || options.out) { - onBundledEmit(host, sourceFiles); + onBundledEmit(sourceFiles); } else { for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { @@ -8427,7 +8471,7 @@ var ts; var declarationFilePath = !isSourceFileJavaScript(sourceFile) && (options.declaration || emitOnlyDtsFiles) ? getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; action(jsFilePath, sourceMapFilePath, declarationFilePath, [sourceFile], /*isBundledEmit*/ false); } - function onBundledEmit(host, sourceFiles) { + function onBundledEmit(sourceFiles) { if (sourceFiles.length) { var jsFilePath = options.outFile || options.out; var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); @@ -8533,7 +8577,7 @@ var ts; ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 148 /* Constructor */ && nodeIsPresent(member.body)) { + if (member.kind === 149 /* Constructor */ && nodeIsPresent(member.body)) { return member; } }); @@ -8561,11 +8605,11 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return node && node.kind === 69 /* Identifier */ && identifierIsThisKeyword(node); + return node && node.kind === 70 /* Identifier */ && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 97 /* ThisKeyword */; + return id.originalKeywordKind === 98 /* ThisKeyword */; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -8575,10 +8619,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 149 /* GetAccessor */) { + if (accessor.kind === 150 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 150 /* SetAccessor */) { + else if (accessor.kind === 151 /* SetAccessor */) { setAccessor = accessor; } else { @@ -8587,7 +8631,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 149 /* GetAccessor */ || member.kind === 150 /* SetAccessor */) + if ((member.kind === 150 /* GetAccessor */ || member.kind === 151 /* SetAccessor */) && hasModifier(member, 32 /* Static */) === hasModifier(accessor, 32 /* Static */)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -8598,10 +8642,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 149 /* GetAccessor */ && !getAccessor) { + if (member.kind === 150 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 150 /* SetAccessor */ && !setAccessor) { + if (member.kind === 151 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -8837,35 +8881,35 @@ var ts; ts.getModifierFlags = getModifierFlags; function modifierToFlag(token) { switch (token) { - case 113 /* StaticKeyword */: return 32 /* Static */; - case 112 /* PublicKeyword */: return 4 /* Public */; - case 111 /* ProtectedKeyword */: return 16 /* Protected */; - case 110 /* PrivateKeyword */: return 8 /* Private */; - case 115 /* AbstractKeyword */: return 128 /* Abstract */; - case 82 /* ExportKeyword */: return 1 /* Export */; - case 122 /* DeclareKeyword */: return 2 /* Ambient */; - case 74 /* ConstKeyword */: return 2048 /* Const */; - case 77 /* DefaultKeyword */: return 512 /* Default */; - case 118 /* AsyncKeyword */: return 256 /* Async */; - case 128 /* ReadonlyKeyword */: return 64 /* Readonly */; + case 114 /* StaticKeyword */: return 32 /* Static */; + case 113 /* PublicKeyword */: return 4 /* Public */; + case 112 /* ProtectedKeyword */: return 16 /* Protected */; + case 111 /* PrivateKeyword */: return 8 /* Private */; + case 116 /* AbstractKeyword */: return 128 /* Abstract */; + case 83 /* ExportKeyword */: return 1 /* Export */; + case 123 /* DeclareKeyword */: return 2 /* Ambient */; + case 75 /* ConstKeyword */: return 2048 /* Const */; + case 78 /* DefaultKeyword */: return 512 /* Default */; + case 119 /* AsyncKeyword */: return 256 /* Async */; + case 129 /* ReadonlyKeyword */: return 64 /* Readonly */; } return 0 /* None */; } ts.modifierToFlag = modifierToFlag; function isLogicalOperator(token) { - return token === 52 /* BarBarToken */ - || token === 51 /* AmpersandAmpersandToken */ - || token === 49 /* ExclamationToken */; + return token === 53 /* BarBarToken */ + || token === 52 /* AmpersandAmpersandToken */ + || token === 50 /* ExclamationToken */; } ts.isLogicalOperator = isLogicalOperator; function isAssignmentOperator(token) { - return token >= 56 /* FirstAssignment */ && token <= 68 /* LastAssignment */; + return token >= 57 /* FirstAssignment */ && token <= 69 /* LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ function tryGetClassExtendingExpressionWithTypeArguments(node) { - if (node.kind === 194 /* ExpressionWithTypeArguments */ && - node.parent.token === 83 /* ExtendsKeyword */ && + if (node.kind === 195 /* ExpressionWithTypeArguments */ && + node.parent.token === 84 /* ExtendsKeyword */ && isClassLike(node.parent.parent)) { return node.parent.parent; } @@ -8873,10 +8917,10 @@ var ts; ts.tryGetClassExtendingExpressionWithTypeArguments = tryGetClassExtendingExpressionWithTypeArguments; function isDestructuringAssignment(node) { if (isBinaryExpression(node)) { - if (node.operatorToken.kind === 56 /* EqualsToken */) { + if (node.operatorToken.kind === 57 /* EqualsToken */) { var kind = node.left.kind; - return kind === 171 /* ObjectLiteralExpression */ - || kind === 170 /* ArrayLiteralExpression */; + return kind === 172 /* ObjectLiteralExpression */ + || kind === 171 /* ArrayLiteralExpression */; } } return false; @@ -8889,7 +8933,7 @@ var ts; } ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 69 /* Identifier */) { + if (node.kind === 70 /* Identifier */) { return true; } else if (isPropertyAccessExpression(node)) { @@ -8904,21 +8948,21 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { - return node.kind === 69 /* Identifier */ || - node.kind === 172 /* PropertyAccessExpression */ && isEntityNameExpression(node.expression); + return node.kind === 70 /* Identifier */ || + node.kind === 173 /* PropertyAccessExpression */ && isEntityNameExpression(node.expression); } ts.isEntityNameExpression = isEntityNameExpression; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 139 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 172 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 140 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 173 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteralOrArrayLiteral(expression) { var kind = expression.kind; - if (kind === 171 /* ObjectLiteralExpression */) { + if (kind === 172 /* ObjectLiteralExpression */) { return expression.properties.length === 0; } - if (kind === 170 /* ArrayLiteralExpression */) { + if (kind === 171 /* ArrayLiteralExpression */) { return expression.elements.length === 0; } return false; @@ -9070,49 +9114,49 @@ var ts; var kind = node.kind; if (kind === 9 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 10 /* RegularExpressionLiteral */ - || kind === 11 /* NoSubstitutionTemplateLiteral */ - || kind === 69 /* Identifier */ - || kind === 97 /* ThisKeyword */ - || kind === 95 /* SuperKeyword */ - || kind === 99 /* TrueKeyword */ - || kind === 84 /* FalseKeyword */ - || kind === 93 /* NullKeyword */) { + || kind === 11 /* RegularExpressionLiteral */ + || kind === 12 /* NoSubstitutionTemplateLiteral */ + || kind === 70 /* Identifier */ + || kind === 98 /* ThisKeyword */ + || kind === 96 /* SuperKeyword */ + || kind === 100 /* TrueKeyword */ + || kind === 85 /* FalseKeyword */ + || kind === 94 /* NullKeyword */) { return true; } - else if (kind === 172 /* PropertyAccessExpression */) { + else if (kind === 173 /* PropertyAccessExpression */) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 173 /* ElementAccessExpression */) { + else if (kind === 174 /* ElementAccessExpression */) { return isSimpleExpressionWorker(node.expression, depth + 1) && isSimpleExpressionWorker(node.argumentExpression, depth + 1); } - else if (kind === 185 /* PrefixUnaryExpression */ - || kind === 186 /* PostfixUnaryExpression */) { + else if (kind === 186 /* PrefixUnaryExpression */ + || kind === 187 /* PostfixUnaryExpression */) { return isSimpleExpressionWorker(node.operand, depth + 1); } - else if (kind === 187 /* BinaryExpression */) { - return node.operatorToken.kind !== 38 /* AsteriskAsteriskToken */ + else if (kind === 188 /* BinaryExpression */) { + return node.operatorToken.kind !== 39 /* AsteriskAsteriskToken */ && isSimpleExpressionWorker(node.left, depth + 1) && isSimpleExpressionWorker(node.right, depth + 1); } - else if (kind === 188 /* ConditionalExpression */) { + else if (kind === 189 /* ConditionalExpression */) { return isSimpleExpressionWorker(node.condition, depth + 1) && isSimpleExpressionWorker(node.whenTrue, depth + 1) && isSimpleExpressionWorker(node.whenFalse, depth + 1); } - else if (kind === 183 /* VoidExpression */ - || kind === 182 /* TypeOfExpression */ - || kind === 181 /* DeleteExpression */) { + else if (kind === 184 /* VoidExpression */ + || kind === 183 /* TypeOfExpression */ + || kind === 182 /* DeleteExpression */) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 170 /* ArrayLiteralExpression */) { + else if (kind === 171 /* ArrayLiteralExpression */) { return node.elements.length === 0; } - else if (kind === 171 /* ObjectLiteralExpression */) { + else if (kind === 172 /* ObjectLiteralExpression */) { return node.properties.length === 0; } - else if (kind === 174 /* CallExpression */) { + else if (kind === 175 /* CallExpression */) { if (!isSimpleExpressionWorker(node.expression, depth + 1)) { return false; } @@ -9271,7 +9315,7 @@ var ts; return ts.positionIsSynthesized(range.pos) ? -1 : ts.skipTrivia(sourceFile.text, range.pos); } ts.getStartPositionOfRange = getStartPositionOfRange; - function collectExternalModuleInfo(sourceFile, resolver) { + function collectExternalModuleInfo(sourceFile) { var externalImports = []; var exportSpecifiers = ts.createMap(); var exportEquals = undefined; @@ -9279,33 +9323,28 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 230 /* ImportDeclaration */: - if (!node.importClause || - resolver.isReferencedAliasDeclaration(node.importClause, /*checkChildren*/ true)) { - // import "mod" - // import x from "mod" where x is referenced - // import * as x from "mod" where x is referenced - // import { x, y } from "mod" where at least one import is referenced + case 231 /* ImportDeclaration */: + // import "mod" + // import x from "mod" + // import * as x from "mod" + // import { x, y } from "mod" + externalImports.push(node); + break; + case 230 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 241 /* ExternalModuleReference */) { + // import x = require("mod") externalImports.push(node); } break; - case 229 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 240 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { - // import x = require("mod") where x is referenced - externalImports.push(node); - } - break; - case 236 /* ExportDeclaration */: + case 237 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" - if (resolver.moduleExportsSomeValue(node.moduleSpecifier)) { - externalImports.push(node); - hasExportStarsToExportValues = true; - } + externalImports.push(node); + hasExportStarsToExportValues = true; } - else if (resolver.isValueAliasDeclaration(node)) { - // export { x, y } from "mod" where at least one export is a value symbol + else { + // export { x, y } from "mod" externalImports.push(node); } } @@ -9318,7 +9357,7 @@ var ts; } } break; - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; @@ -9343,7 +9382,7 @@ var ts; if (node.symbol) { for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 221 /* ClassDeclaration */ && declaration !== node) { + if (declaration.kind === 222 /* ClassDeclaration */ && declaration !== node) { return true; } } @@ -9373,15 +9412,15 @@ var ts; ts.isNodeArray = isNodeArray; // Literals function isNoSubstitutionTemplateLiteral(node) { - return node.kind === 11 /* NoSubstitutionTemplateLiteral */; + return node.kind === 12 /* NoSubstitutionTemplateLiteral */; } ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral; function isLiteralKind(kind) { - return 8 /* FirstLiteralToken */ <= kind && kind <= 11 /* LastLiteralToken */; + return 8 /* FirstLiteralToken */ <= kind && kind <= 12 /* LastLiteralToken */; } ts.isLiteralKind = isLiteralKind; function isTextualLiteralKind(kind) { - return kind === 9 /* StringLiteral */ || kind === 11 /* NoSubstitutionTemplateLiteral */; + return kind === 9 /* StringLiteral */ || kind === 12 /* NoSubstitutionTemplateLiteral */; } ts.isTextualLiteralKind = isTextualLiteralKind; function isLiteralExpression(node) { @@ -9390,22 +9429,22 @@ var ts; ts.isLiteralExpression = isLiteralExpression; // Pseudo-literals function isTemplateLiteralKind(kind) { - return 11 /* FirstTemplateToken */ <= kind && kind <= 14 /* LastTemplateToken */; + return 12 /* FirstTemplateToken */ <= kind && kind <= 15 /* LastTemplateToken */; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isTemplateHead(node) { - return node.kind === 12 /* TemplateHead */; + return node.kind === 13 /* TemplateHead */; } ts.isTemplateHead = isTemplateHead; function isTemplateMiddleOrTemplateTail(node) { var kind = node.kind; - return kind === 13 /* TemplateMiddle */ - || kind === 14 /* TemplateTail */; + return kind === 14 /* TemplateMiddle */ + || kind === 15 /* TemplateTail */; } ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; // Identifiers function isIdentifier(node) { - return node.kind === 69 /* Identifier */; + return node.kind === 70 /* Identifier */; } ts.isIdentifier = isIdentifier; function isGeneratedIdentifier(node) { @@ -9420,90 +9459,90 @@ var ts; ts.isModifier = isModifier; // Names function isQualifiedName(node) { - return node.kind === 139 /* QualifiedName */; + return node.kind === 140 /* QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 140 /* ComputedPropertyName */; + return node.kind === 141 /* ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; function isEntityName(node) { var kind = node.kind; - return kind === 139 /* QualifiedName */ - || kind === 69 /* Identifier */; + return kind === 140 /* QualifiedName */ + || kind === 70 /* Identifier */; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 69 /* Identifier */ + return kind === 70 /* Identifier */ || kind === 9 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 140 /* ComputedPropertyName */; + || kind === 141 /* ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isModuleName(node) { var kind = node.kind; - return kind === 69 /* Identifier */ + return kind === 70 /* Identifier */ || kind === 9 /* StringLiteral */; } ts.isModuleName = isModuleName; function isBindingName(node) { var kind = node.kind; - return kind === 69 /* Identifier */ - || kind === 167 /* ObjectBindingPattern */ - || kind === 168 /* ArrayBindingPattern */; + return kind === 70 /* Identifier */ + || kind === 168 /* ObjectBindingPattern */ + || kind === 169 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Signature elements function isTypeParameter(node) { - return node.kind === 141 /* TypeParameter */; + return node.kind === 142 /* TypeParameter */; } ts.isTypeParameter = isTypeParameter; function isParameter(node) { - return node.kind === 142 /* Parameter */; + return node.kind === 143 /* Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 143 /* Decorator */; + return node.kind === 144 /* Decorator */; } ts.isDecorator = isDecorator; // Type members function isMethodDeclaration(node) { - return node.kind === 147 /* MethodDeclaration */; + return node.kind === 148 /* MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isClassElement(node) { var kind = node.kind; - return kind === 148 /* Constructor */ - || kind === 145 /* PropertyDeclaration */ - || kind === 147 /* MethodDeclaration */ - || kind === 149 /* GetAccessor */ - || kind === 150 /* SetAccessor */ - || kind === 153 /* IndexSignature */ - || kind === 198 /* SemicolonClassElement */; + return kind === 149 /* Constructor */ + || kind === 146 /* PropertyDeclaration */ + || kind === 148 /* MethodDeclaration */ + || kind === 150 /* GetAccessor */ + || kind === 151 /* SetAccessor */ + || kind === 154 /* IndexSignature */ + || kind === 199 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isObjectLiteralElementLike(node) { var kind = node.kind; return kind === 253 /* PropertyAssignment */ || kind === 254 /* ShorthandPropertyAssignment */ - || kind === 147 /* MethodDeclaration */ - || kind === 149 /* GetAccessor */ - || kind === 150 /* SetAccessor */ - || kind === 239 /* MissingDeclaration */; + || kind === 148 /* MethodDeclaration */ + || kind === 150 /* GetAccessor */ + || kind === 151 /* SetAccessor */ + || kind === 240 /* MissingDeclaration */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type function isTypeNodeKind(kind) { - return (kind >= 154 /* FirstTypeNode */ && kind <= 166 /* LastTypeNode */) - || kind === 117 /* AnyKeyword */ - || kind === 130 /* NumberKeyword */ - || kind === 120 /* BooleanKeyword */ - || kind === 132 /* StringKeyword */ - || kind === 133 /* SymbolKeyword */ - || kind === 103 /* VoidKeyword */ - || kind === 127 /* NeverKeyword */ - || kind === 194 /* ExpressionWithTypeArguments */; + return (kind >= 155 /* FirstTypeNode */ && kind <= 167 /* LastTypeNode */) + || kind === 118 /* AnyKeyword */ + || kind === 131 /* NumberKeyword */ + || kind === 121 /* BooleanKeyword */ + || kind === 133 /* StringKeyword */ + || kind === 134 /* SymbolKeyword */ + || kind === 104 /* VoidKeyword */ + || kind === 128 /* NeverKeyword */ + || kind === 195 /* ExpressionWithTypeArguments */; } /** * Node test that determines whether a node is a valid type node. @@ -9518,95 +9557,95 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 168 /* ArrayBindingPattern */ - || kind === 167 /* ObjectBindingPattern */; + return kind === 169 /* ArrayBindingPattern */ + || kind === 168 /* ObjectBindingPattern */; } return false; } ts.isBindingPattern = isBindingPattern; function isBindingElement(node) { - return node.kind === 169 /* BindingElement */; + return node.kind === 170 /* BindingElement */; } ts.isBindingElement = isBindingElement; function isArrayBindingElement(node) { var kind = node.kind; - return kind === 169 /* BindingElement */ - || kind === 193 /* OmittedExpression */; + return kind === 170 /* BindingElement */ + || kind === 194 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; // Expression function isPropertyAccessExpression(node) { - return node.kind === 172 /* PropertyAccessExpression */; + return node.kind === 173 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 173 /* ElementAccessExpression */; + return node.kind === 174 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isBinaryExpression(node) { - return node.kind === 187 /* BinaryExpression */; + return node.kind === 188 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 188 /* ConditionalExpression */; + return node.kind === 189 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isCallExpression(node) { - return node.kind === 174 /* CallExpression */; + return node.kind === 175 /* CallExpression */; } ts.isCallExpression = isCallExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 189 /* TemplateExpression */ - || kind === 11 /* NoSubstitutionTemplateLiteral */; + return kind === 190 /* TemplateExpression */ + || kind === 12 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; function isSpreadElementExpression(node) { - return node.kind === 191 /* SpreadElementExpression */; + return node.kind === 192 /* SpreadElementExpression */; } ts.isSpreadElementExpression = isSpreadElementExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 194 /* ExpressionWithTypeArguments */; + return node.kind === 195 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isLeftHandSideExpressionKind(kind) { - return kind === 172 /* PropertyAccessExpression */ - || kind === 173 /* ElementAccessExpression */ - || kind === 175 /* NewExpression */ - || kind === 174 /* CallExpression */ - || kind === 241 /* JsxElement */ - || kind === 242 /* JsxSelfClosingElement */ - || kind === 176 /* TaggedTemplateExpression */ - || kind === 170 /* ArrayLiteralExpression */ - || kind === 178 /* ParenthesizedExpression */ - || kind === 171 /* ObjectLiteralExpression */ - || kind === 192 /* ClassExpression */ - || kind === 179 /* FunctionExpression */ - || kind === 69 /* Identifier */ - || kind === 10 /* RegularExpressionLiteral */ + return kind === 173 /* PropertyAccessExpression */ + || kind === 174 /* ElementAccessExpression */ + || kind === 176 /* NewExpression */ + || kind === 175 /* CallExpression */ + || kind === 242 /* JsxElement */ + || kind === 243 /* JsxSelfClosingElement */ + || kind === 177 /* TaggedTemplateExpression */ + || kind === 171 /* ArrayLiteralExpression */ + || kind === 179 /* ParenthesizedExpression */ + || kind === 172 /* ObjectLiteralExpression */ + || kind === 193 /* ClassExpression */ + || kind === 180 /* FunctionExpression */ + || kind === 70 /* Identifier */ + || kind === 11 /* RegularExpressionLiteral */ || kind === 8 /* NumericLiteral */ || kind === 9 /* StringLiteral */ - || kind === 11 /* NoSubstitutionTemplateLiteral */ - || kind === 189 /* TemplateExpression */ - || kind === 84 /* FalseKeyword */ - || kind === 93 /* NullKeyword */ - || kind === 97 /* ThisKeyword */ - || kind === 99 /* TrueKeyword */ - || kind === 95 /* SuperKeyword */ - || kind === 196 /* NonNullExpression */; + || kind === 12 /* NoSubstitutionTemplateLiteral */ + || kind === 190 /* TemplateExpression */ + || kind === 85 /* FalseKeyword */ + || kind === 94 /* NullKeyword */ + || kind === 98 /* ThisKeyword */ + || kind === 100 /* TrueKeyword */ + || kind === 96 /* SuperKeyword */ + || kind === 197 /* NonNullExpression */; } function isLeftHandSideExpression(node) { return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isUnaryExpressionKind(kind) { - return kind === 185 /* PrefixUnaryExpression */ - || kind === 186 /* PostfixUnaryExpression */ - || kind === 181 /* DeleteExpression */ - || kind === 182 /* TypeOfExpression */ - || kind === 183 /* VoidExpression */ - || kind === 184 /* AwaitExpression */ - || kind === 177 /* TypeAssertionExpression */ + return kind === 186 /* PrefixUnaryExpression */ + || kind === 187 /* PostfixUnaryExpression */ + || kind === 182 /* DeleteExpression */ + || kind === 183 /* TypeOfExpression */ + || kind === 184 /* VoidExpression */ + || kind === 185 /* AwaitExpression */ + || kind === 178 /* TypeAssertionExpression */ || isLeftHandSideExpressionKind(kind); } function isUnaryExpression(node) { @@ -9614,13 +9653,13 @@ var ts; } ts.isUnaryExpression = isUnaryExpression; function isExpressionKind(kind) { - return kind === 188 /* ConditionalExpression */ - || kind === 190 /* YieldExpression */ - || kind === 180 /* ArrowFunction */ - || kind === 187 /* BinaryExpression */ - || kind === 191 /* SpreadElementExpression */ - || kind === 195 /* AsExpression */ - || kind === 193 /* OmittedExpression */ + return kind === 189 /* ConditionalExpression */ + || kind === 191 /* YieldExpression */ + || kind === 181 /* ArrowFunction */ + || kind === 188 /* BinaryExpression */ + || kind === 192 /* SpreadElementExpression */ + || kind === 196 /* AsExpression */ + || kind === 194 /* OmittedExpression */ || isUnaryExpressionKind(kind); } function isExpression(node) { @@ -9629,8 +9668,8 @@ var ts; ts.isExpression = isExpression; function isAssertionExpression(node) { var kind = node.kind; - return kind === 177 /* TypeAssertionExpression */ - || kind === 195 /* AsExpression */; + return kind === 178 /* TypeAssertionExpression */ + || kind === 196 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { @@ -9647,17 +9686,17 @@ var ts; } ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isOmittedExpression(node) { - return node.kind === 193 /* OmittedExpression */; + return node.kind === 194 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; // Misc function isTemplateSpan(node) { - return node.kind === 197 /* TemplateSpan */; + return node.kind === 198 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; // Element function isBlock(node) { - return node.kind === 199 /* Block */; + return node.kind === 200 /* Block */; } ts.isBlock = isBlock; function isConciseBody(node) { @@ -9675,118 +9714,118 @@ var ts; } ts.isForInitializer = isForInitializer; function isVariableDeclaration(node) { - return node.kind === 218 /* VariableDeclaration */; + return node.kind === 219 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 219 /* VariableDeclarationList */; + return node.kind === 220 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isCaseBlock(node) { - return node.kind === 227 /* CaseBlock */; + return node.kind === 228 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isModuleBody(node) { var kind = node.kind; - return kind === 226 /* ModuleBlock */ - || kind === 225 /* ModuleDeclaration */; + return kind === 227 /* ModuleBlock */ + || kind === 226 /* ModuleDeclaration */; } ts.isModuleBody = isModuleBody; function isImportEqualsDeclaration(node) { - return node.kind === 229 /* ImportEqualsDeclaration */; + return node.kind === 230 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportClause(node) { - return node.kind === 231 /* ImportClause */; + return node.kind === 232 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 233 /* NamedImports */ - || kind === 232 /* NamespaceImport */; + return kind === 234 /* NamedImports */ + || kind === 233 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; function isImportSpecifier(node) { - return node.kind === 234 /* ImportSpecifier */; + return node.kind === 235 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isNamedExports(node) { - return node.kind === 237 /* NamedExports */; + return node.kind === 238 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 238 /* ExportSpecifier */; + return node.kind === 239 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isModuleOrEnumDeclaration(node) { - return node.kind === 225 /* ModuleDeclaration */ || node.kind === 224 /* EnumDeclaration */; + return node.kind === 226 /* ModuleDeclaration */ || node.kind === 225 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 180 /* ArrowFunction */ - || kind === 169 /* BindingElement */ - || kind === 221 /* ClassDeclaration */ - || kind === 192 /* ClassExpression */ - || kind === 148 /* Constructor */ - || kind === 224 /* EnumDeclaration */ + return kind === 181 /* ArrowFunction */ + || kind === 170 /* BindingElement */ + || kind === 222 /* ClassDeclaration */ + || kind === 193 /* ClassExpression */ + || kind === 149 /* Constructor */ + || kind === 225 /* EnumDeclaration */ || kind === 255 /* EnumMember */ - || kind === 238 /* ExportSpecifier */ - || kind === 220 /* FunctionDeclaration */ - || kind === 179 /* FunctionExpression */ - || kind === 149 /* GetAccessor */ - || kind === 231 /* ImportClause */ - || kind === 229 /* ImportEqualsDeclaration */ - || kind === 234 /* ImportSpecifier */ - || kind === 222 /* InterfaceDeclaration */ - || kind === 147 /* MethodDeclaration */ - || kind === 146 /* MethodSignature */ - || kind === 225 /* ModuleDeclaration */ - || kind === 228 /* NamespaceExportDeclaration */ - || kind === 232 /* NamespaceImport */ - || kind === 142 /* Parameter */ + || kind === 239 /* ExportSpecifier */ + || kind === 221 /* FunctionDeclaration */ + || kind === 180 /* FunctionExpression */ + || kind === 150 /* GetAccessor */ + || kind === 232 /* ImportClause */ + || kind === 230 /* ImportEqualsDeclaration */ + || kind === 235 /* ImportSpecifier */ + || kind === 223 /* InterfaceDeclaration */ + || kind === 148 /* MethodDeclaration */ + || kind === 147 /* MethodSignature */ + || kind === 226 /* ModuleDeclaration */ + || kind === 229 /* NamespaceExportDeclaration */ + || kind === 233 /* NamespaceImport */ + || kind === 143 /* Parameter */ || kind === 253 /* PropertyAssignment */ - || kind === 145 /* PropertyDeclaration */ - || kind === 144 /* PropertySignature */ - || kind === 150 /* SetAccessor */ + || kind === 146 /* PropertyDeclaration */ + || kind === 145 /* PropertySignature */ + || kind === 151 /* SetAccessor */ || kind === 254 /* ShorthandPropertyAssignment */ - || kind === 223 /* TypeAliasDeclaration */ - || kind === 141 /* TypeParameter */ - || kind === 218 /* VariableDeclaration */ + || kind === 224 /* TypeAliasDeclaration */ + || kind === 142 /* TypeParameter */ + || kind === 219 /* VariableDeclaration */ || kind === 279 /* JSDocTypedefTag */; } function isDeclarationStatementKind(kind) { - return kind === 220 /* FunctionDeclaration */ - || kind === 239 /* MissingDeclaration */ - || kind === 221 /* ClassDeclaration */ - || kind === 222 /* InterfaceDeclaration */ - || kind === 223 /* TypeAliasDeclaration */ - || kind === 224 /* EnumDeclaration */ - || kind === 225 /* ModuleDeclaration */ - || kind === 230 /* ImportDeclaration */ - || kind === 229 /* ImportEqualsDeclaration */ - || kind === 236 /* ExportDeclaration */ - || kind === 235 /* ExportAssignment */ - || kind === 228 /* NamespaceExportDeclaration */; + return kind === 221 /* FunctionDeclaration */ + || kind === 240 /* MissingDeclaration */ + || kind === 222 /* ClassDeclaration */ + || kind === 223 /* InterfaceDeclaration */ + || kind === 224 /* TypeAliasDeclaration */ + || kind === 225 /* EnumDeclaration */ + || kind === 226 /* ModuleDeclaration */ + || kind === 231 /* ImportDeclaration */ + || kind === 230 /* ImportEqualsDeclaration */ + || kind === 237 /* ExportDeclaration */ + || kind === 236 /* ExportAssignment */ + || kind === 229 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 210 /* BreakStatement */ - || kind === 209 /* ContinueStatement */ - || kind === 217 /* DebuggerStatement */ - || kind === 204 /* DoStatement */ - || kind === 202 /* ExpressionStatement */ - || kind === 201 /* EmptyStatement */ - || kind === 207 /* ForInStatement */ - || kind === 208 /* ForOfStatement */ - || kind === 206 /* ForStatement */ - || kind === 203 /* IfStatement */ - || kind === 214 /* LabeledStatement */ - || kind === 211 /* ReturnStatement */ - || kind === 213 /* SwitchStatement */ - || kind === 215 /* ThrowStatement */ - || kind === 216 /* TryStatement */ - || kind === 200 /* VariableStatement */ - || kind === 205 /* WhileStatement */ - || kind === 212 /* WithStatement */ + return kind === 211 /* BreakStatement */ + || kind === 210 /* ContinueStatement */ + || kind === 218 /* DebuggerStatement */ + || kind === 205 /* DoStatement */ + || kind === 203 /* ExpressionStatement */ + || kind === 202 /* EmptyStatement */ + || kind === 208 /* ForInStatement */ + || kind === 209 /* ForOfStatement */ + || kind === 207 /* ForStatement */ + || kind === 204 /* IfStatement */ + || kind === 215 /* LabeledStatement */ + || kind === 212 /* ReturnStatement */ + || kind === 214 /* SwitchStatement */ + || kind === 216 /* ThrowStatement */ + || kind === 217 /* TryStatement */ + || kind === 201 /* VariableStatement */ + || kind === 206 /* WhileStatement */ + || kind === 213 /* WithStatement */ || kind === 287 /* NotEmittedStatement */; } function isDeclaration(node) { @@ -9808,20 +9847,20 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 199 /* Block */; + || kind === 200 /* Block */; } ts.isStatement = isStatement; // Module references function isModuleReference(node) { var kind = node.kind; - return kind === 240 /* ExternalModuleReference */ - || kind === 139 /* QualifiedName */ - || kind === 69 /* Identifier */; + return kind === 241 /* ExternalModuleReference */ + || kind === 140 /* QualifiedName */ + || kind === 70 /* Identifier */; } ts.isModuleReference = isModuleReference; // JSX function isJsxOpeningElement(node) { - return node.kind === 243 /* JsxOpeningElement */; + return node.kind === 244 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { @@ -9830,17 +9869,17 @@ var ts; ts.isJsxClosingElement = isJsxClosingElement; function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 97 /* ThisKeyword */ - || kind === 69 /* Identifier */ - || kind === 172 /* PropertyAccessExpression */; + return kind === 98 /* ThisKeyword */ + || kind === 70 /* Identifier */ + || kind === 173 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 241 /* JsxElement */ + return kind === 242 /* JsxElement */ || kind === 248 /* JsxExpression */ - || kind === 242 /* JsxSelfClosingElement */ - || kind === 244 /* JsxText */; + || kind === 243 /* JsxSelfClosingElement */ + || kind === 10 /* JsxText */; } ts.isJsxChild = isJsxChild; function isJsxAttributeLike(node) { @@ -9905,7 +9944,16 @@ var ts; })(ts || (ts = {})); (function (ts) { function getDefaultLibFileName(options) { - return options.target === 2 /* ES6 */ ? "lib.es6.d.ts" : "lib.d.ts"; + switch (options.target) { + case 4 /* ES2017 */: + return "lib.es2017.d.ts"; + case 3 /* ES2016 */: + return "lib.es2016.d.ts"; + case 2 /* ES2015 */: + return "lib.es6.d.ts"; + default: + return "lib.d.ts"; + } } ts.getDefaultLibFileName = getDefaultLibFileName; function textSpanEnd(span) { @@ -10114,9 +10162,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 141 /* TypeParameter */) { + if (d && d.kind === 142 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 222 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 223 /* InterfaceDeclaration */) { return current; } } @@ -10124,11 +10172,11 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 148 /* Constructor */ && ts.isClassLike(node.parent.parent); + return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 149 /* Constructor */ && ts.isClassLike(node.parent.parent); } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 169 /* BindingElement */ || ts.isBindingPattern(node))) { + while (node && (node.kind === 170 /* BindingElement */ || ts.isBindingPattern(node))) { node = node.parent; } return node; @@ -10136,14 +10184,14 @@ var ts; function getCombinedModifierFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = ts.getModifierFlags(node); - if (node.kind === 218 /* VariableDeclaration */) { + if (node.kind === 219 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 219 /* VariableDeclarationList */) { + if (node && node.kind === 220 /* VariableDeclarationList */) { flags |= ts.getModifierFlags(node); node = node.parent; } - if (node && node.kind === 200 /* VariableStatement */) { + if (node && node.kind === 201 /* VariableStatement */) { flags |= ts.getModifierFlags(node); } return flags; @@ -10159,14 +10207,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 218 /* VariableDeclaration */) { + if (node.kind === 219 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 219 /* VariableDeclarationList */) { + if (node && node.kind === 220 /* VariableDeclarationList */) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 200 /* VariableStatement */) { + if (node && node.kind === 201 /* VariableStatement */) { flags |= node.flags; } return flags; @@ -10271,7 +10319,7 @@ var ts; return node; } else if (typeof value === "boolean") { - return createNode(value ? 99 /* TrueKeyword */ : 84 /* FalseKeyword */, location, /*flags*/ undefined); + return createNode(value ? 100 /* TrueKeyword */ : 85 /* FalseKeyword */, location, /*flags*/ undefined); } else if (typeof value === "string") { var node = createNode(9 /* StringLiteral */, location, /*flags*/ undefined); @@ -10289,7 +10337,7 @@ var ts; // Identifiers var nextAutoGenerateId = 0; function createIdentifier(text, location) { - var node = createNode(69 /* Identifier */, location); + var node = createNode(70 /* Identifier */, location); node.text = ts.escapeIdentifier(text); node.originalKeywordKind = ts.stringToToken(text); node.autoGenerateKind = 0 /* None */; @@ -10298,7 +10346,7 @@ var ts; } ts.createIdentifier = createIdentifier; function createTempVariable(recordTempVariable, location) { - var name = createNode(69 /* Identifier */, location); + var name = createNode(70 /* Identifier */, location); name.text = ""; name.originalKeywordKind = 0 /* Unknown */; name.autoGenerateKind = 1 /* Auto */; @@ -10311,7 +10359,7 @@ var ts; } ts.createTempVariable = createTempVariable; function createLoopVariable(location) { - var name = createNode(69 /* Identifier */, location); + var name = createNode(70 /* Identifier */, location); name.text = ""; name.originalKeywordKind = 0 /* Unknown */; name.autoGenerateKind = 2 /* Loop */; @@ -10321,7 +10369,7 @@ var ts; } ts.createLoopVariable = createLoopVariable; function createUniqueName(text, location) { - var name = createNode(69 /* Identifier */, location); + var name = createNode(70 /* Identifier */, location); name.text = text; name.originalKeywordKind = 0 /* Unknown */; name.autoGenerateKind = 3 /* Unique */; @@ -10331,7 +10379,7 @@ var ts; } ts.createUniqueName = createUniqueName; function getGeneratedNameForNode(node, location) { - var name = createNode(69 /* Identifier */, location); + var name = createNode(70 /* Identifier */, location); name.original = node; name.text = ""; name.originalKeywordKind = 0 /* Unknown */; @@ -10348,23 +10396,23 @@ var ts; ts.createToken = createToken; // Reserved words function createSuper() { - var node = createNode(95 /* SuperKeyword */); + var node = createNode(96 /* SuperKeyword */); return node; } ts.createSuper = createSuper; function createThis(location) { - var node = createNode(97 /* ThisKeyword */, location); + var node = createNode(98 /* ThisKeyword */, location); return node; } ts.createThis = createThis; function createNull() { - var node = createNode(93 /* NullKeyword */); + var node = createNode(94 /* NullKeyword */); return node; } ts.createNull = createNull; // Names function createComputedPropertyName(expression, location) { - var node = createNode(140 /* ComputedPropertyName */, location); + var node = createNode(141 /* ComputedPropertyName */, location); node.expression = expression; return node; } @@ -10387,7 +10435,7 @@ var ts; } ts.createParameter = createParameter; function createParameterDeclaration(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer, location, flags) { - var node = createNode(142 /* Parameter */, location, flags); + var node = createNode(143 /* Parameter */, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.dotDotDotToken = dotDotDotToken; @@ -10407,7 +10455,7 @@ var ts; ts.updateParameterDeclaration = updateParameterDeclaration; // Type members function createProperty(decorators, modifiers, name, questionToken, type, initializer, location) { - var node = createNode(145 /* PropertyDeclaration */, location); + var node = createNode(146 /* PropertyDeclaration */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10425,7 +10473,7 @@ var ts; } ts.updateProperty = updateProperty; function createMethod(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(147 /* MethodDeclaration */, location, flags); + var node = createNode(148 /* MethodDeclaration */, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; @@ -10445,7 +10493,7 @@ var ts; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body, location, flags) { - var node = createNode(148 /* Constructor */, location, flags); + var node = createNode(149 /* Constructor */, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.typeParameters = undefined; @@ -10463,7 +10511,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body, location, flags) { - var node = createNode(149 /* GetAccessor */, location, flags); + var node = createNode(150 /* GetAccessor */, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10482,7 +10530,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body, location, flags) { - var node = createNode(150 /* SetAccessor */, location, flags); + var node = createNode(151 /* SetAccessor */, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10501,7 +10549,7 @@ var ts; ts.updateSetAccessor = updateSetAccessor; // Binding Patterns function createObjectBindingPattern(elements, location) { - var node = createNode(167 /* ObjectBindingPattern */, location); + var node = createNode(168 /* ObjectBindingPattern */, location); node.elements = createNodeArray(elements); return node; } @@ -10514,7 +10562,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements, location) { - var node = createNode(168 /* ArrayBindingPattern */, location); + var node = createNode(169 /* ArrayBindingPattern */, location); node.elements = createNodeArray(elements); return node; } @@ -10527,7 +10575,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(propertyName, dotDotDotToken, name, initializer, location) { - var node = createNode(169 /* BindingElement */, location); + var node = createNode(170 /* BindingElement */, location); node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; node.dotDotDotToken = dotDotDotToken; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10544,7 +10592,7 @@ var ts; ts.updateBindingElement = updateBindingElement; // Expression function createArrayLiteral(elements, location, multiLine) { - var node = createNode(170 /* ArrayLiteralExpression */, location); + var node = createNode(171 /* ArrayLiteralExpression */, location); node.elements = parenthesizeListElements(createNodeArray(elements)); if (multiLine) { node.multiLine = true; @@ -10560,7 +10608,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, location, multiLine) { - var node = createNode(171 /* ObjectLiteralExpression */, location); + var node = createNode(172 /* ObjectLiteralExpression */, location); node.properties = createNodeArray(properties); if (multiLine) { node.multiLine = true; @@ -10576,7 +10624,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name, location, flags) { - var node = createNode(172 /* PropertyAccessExpression */, location, flags); + var node = createNode(173 /* PropertyAccessExpression */, location, flags); node.expression = parenthesizeForAccess(expression); (node.emitNode || (node.emitNode = {})).flags |= 1048576 /* NoIndentation */; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10594,7 +10642,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index, location) { - var node = createNode(173 /* ElementAccessExpression */, location); + var node = createNode(174 /* ElementAccessExpression */, location); node.expression = parenthesizeForAccess(expression); node.argumentExpression = typeof index === "number" ? createLiteral(index) : index; return node; @@ -10608,7 +10656,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(174 /* CallExpression */, location, flags); + var node = createNode(175 /* CallExpression */, location, flags); node.expression = parenthesizeForAccess(expression); if (typeArguments) { node.typeArguments = createNodeArray(typeArguments); @@ -10625,7 +10673,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(175 /* NewExpression */, location, flags); + var node = createNode(176 /* NewExpression */, location, flags); node.expression = parenthesizeForNew(expression); node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; node.arguments = argumentsArray ? parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -10640,7 +10688,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, template, location) { - var node = createNode(176 /* TaggedTemplateExpression */, location); + var node = createNode(177 /* TaggedTemplateExpression */, location); node.tag = parenthesizeForAccess(tag); node.template = template; return node; @@ -10654,7 +10702,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createParen(expression, location) { - var node = createNode(178 /* ParenthesizedExpression */, location); + var node = createNode(179 /* ParenthesizedExpression */, location); node.expression = expression; return node; } @@ -10666,9 +10714,9 @@ var ts; return node; } ts.updateParen = updateParen; - function createFunctionExpression(asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(179 /* FunctionExpression */, location, flags); - node.modifiers = undefined; + function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { + var node = createNode(180 /* FunctionExpression */, location, flags); + node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; node.name = typeof name === "string" ? createIdentifier(name) : name; node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; @@ -10678,20 +10726,20 @@ var ts; return node; } ts.createFunctionExpression = createFunctionExpression; - function updateFunctionExpression(node, name, typeParameters, parameters, type, body) { - if (node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { - return updateNode(createFunctionExpression(node.asteriskToken, name, typeParameters, parameters, type, body, /*location*/ node, node.flags), node); + function updateFunctionExpression(node, modifiers, name, typeParameters, parameters, type, body) { + if (node.name !== name || node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) { + return updateNode(createFunctionExpression(modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, /*location*/ node, node.flags), node); } return node; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body, location, flags) { - var node = createNode(180 /* ArrowFunction */, location, flags); + var node = createNode(181 /* ArrowFunction */, location, flags); node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; node.parameters = createNodeArray(parameters); node.type = type; - node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(34 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(35 /* EqualsGreaterThanToken */); node.body = parenthesizeConciseBody(body); return node; } @@ -10704,7 +10752,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression, location) { - var node = createNode(181 /* DeleteExpression */, location); + var node = createNode(182 /* DeleteExpression */, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10717,7 +10765,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression, location) { - var node = createNode(182 /* TypeOfExpression */, location); + var node = createNode(183 /* TypeOfExpression */, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10730,7 +10778,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression, location) { - var node = createNode(183 /* VoidExpression */, location); + var node = createNode(184 /* VoidExpression */, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10743,7 +10791,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression, location) { - var node = createNode(184 /* AwaitExpression */, location); + var node = createNode(185 /* AwaitExpression */, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10756,7 +10804,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand, location) { - var node = createNode(185 /* PrefixUnaryExpression */, location); + var node = createNode(186 /* PrefixUnaryExpression */, location); node.operator = operator; node.operand = parenthesizePrefixOperand(operand); return node; @@ -10770,7 +10818,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator, location) { - var node = createNode(186 /* PostfixUnaryExpression */, location); + var node = createNode(187 /* PostfixUnaryExpression */, location); node.operand = parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -10786,7 +10834,7 @@ var ts; function createBinary(left, operator, right, location) { var operatorToken = typeof operator === "number" ? createToken(operator) : operator; var operatorKind = operatorToken.kind; - var node = createNode(187 /* BinaryExpression */, location); + var node = createNode(188 /* BinaryExpression */, location); node.left = parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); node.operatorToken = operatorToken; node.right = parenthesizeBinaryOperand(operatorKind, right, /*isLeftSideOfBinary*/ false, node.left); @@ -10801,7 +10849,7 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionToken, whenTrue, colonToken, whenFalse, location) { - var node = createNode(188 /* ConditionalExpression */, location); + var node = createNode(189 /* ConditionalExpression */, location); node.condition = condition; node.questionToken = questionToken; node.whenTrue = whenTrue; @@ -10818,7 +10866,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans, location) { - var node = createNode(189 /* TemplateExpression */, location); + var node = createNode(190 /* TemplateExpression */, location); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -10832,7 +10880,7 @@ var ts; } ts.updateTemplateExpression = updateTemplateExpression; function createYield(asteriskToken, expression, location) { - var node = createNode(190 /* YieldExpression */, location); + var node = createNode(191 /* YieldExpression */, location); node.asteriskToken = asteriskToken; node.expression = expression; return node; @@ -10846,7 +10894,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression, location) { - var node = createNode(191 /* SpreadElementExpression */, location); + var node = createNode(192 /* SpreadElementExpression */, location); node.expression = parenthesizeExpressionForList(expression); return node; } @@ -10859,7 +10907,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(192 /* ClassExpression */, location); + var node = createNode(193 /* ClassExpression */, location); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -10877,12 +10925,12 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression(location) { - var node = createNode(193 /* OmittedExpression */, location); + var node = createNode(194 /* OmittedExpression */, location); return node; } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression, location) { - var node = createNode(194 /* ExpressionWithTypeArguments */, location); + var node = createNode(195 /* ExpressionWithTypeArguments */, location); node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; node.expression = parenthesizeForAccess(expression); return node; @@ -10897,7 +10945,7 @@ var ts; ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; // Misc function createTemplateSpan(expression, literal, location) { - var node = createNode(197 /* TemplateSpan */, location); + var node = createNode(198 /* TemplateSpan */, location); node.expression = expression; node.literal = literal; return node; @@ -10912,7 +10960,7 @@ var ts; ts.updateTemplateSpan = updateTemplateSpan; // Element function createBlock(statements, location, multiLine, flags) { - var block = createNode(199 /* Block */, location, flags); + var block = createNode(200 /* Block */, location, flags); block.statements = createNodeArray(statements); if (multiLine) { block.multiLine = true; @@ -10928,7 +10976,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList, location, flags) { - var node = createNode(200 /* VariableStatement */, location, flags); + var node = createNode(201 /* VariableStatement */, location, flags); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -10943,7 +10991,7 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createVariableDeclarationList(declarations, location, flags) { - var node = createNode(219 /* VariableDeclarationList */, location, flags); + var node = createNode(220 /* VariableDeclarationList */, location, flags); node.declarations = createNodeArray(declarations); return node; } @@ -10956,7 +11004,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createVariableDeclaration(name, type, initializer, location, flags) { - var node = createNode(218 /* VariableDeclaration */, location, flags); + var node = createNode(219 /* VariableDeclaration */, location, flags); node.name = typeof name === "string" ? createIdentifier(name) : name; node.type = type; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -10971,11 +11019,11 @@ var ts; } ts.updateVariableDeclaration = updateVariableDeclaration; function createEmptyStatement(location) { - return createNode(201 /* EmptyStatement */, location); + return createNode(202 /* EmptyStatement */, location); } ts.createEmptyStatement = createEmptyStatement; function createStatement(expression, location, flags) { - var node = createNode(202 /* ExpressionStatement */, location, flags); + var node = createNode(203 /* ExpressionStatement */, location, flags); node.expression = parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -10988,7 +11036,7 @@ var ts; } ts.updateStatement = updateStatement; function createIf(expression, thenStatement, elseStatement, location) { - var node = createNode(203 /* IfStatement */, location); + var node = createNode(204 /* IfStatement */, location); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -11003,7 +11051,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression, location) { - var node = createNode(204 /* DoStatement */, location); + var node = createNode(205 /* DoStatement */, location); node.statement = statement; node.expression = expression; return node; @@ -11017,7 +11065,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement, location) { - var node = createNode(205 /* WhileStatement */, location); + var node = createNode(206 /* WhileStatement */, location); node.expression = expression; node.statement = statement; return node; @@ -11031,7 +11079,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement, location) { - var node = createNode(206 /* ForStatement */, location, /*flags*/ undefined); + var node = createNode(207 /* ForStatement */, location, /*flags*/ undefined); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -11047,7 +11095,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement, location) { - var node = createNode(207 /* ForInStatement */, location); + var node = createNode(208 /* ForInStatement */, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11062,7 +11110,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(initializer, expression, statement, location) { - var node = createNode(208 /* ForOfStatement */, location); + var node = createNode(209 /* ForOfStatement */, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11077,7 +11125,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label, location) { - var node = createNode(209 /* ContinueStatement */, location); + var node = createNode(210 /* ContinueStatement */, location); if (label) { node.label = label; } @@ -11092,7 +11140,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label, location) { - var node = createNode(210 /* BreakStatement */, location); + var node = createNode(211 /* BreakStatement */, location); if (label) { node.label = label; } @@ -11107,7 +11155,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression, location) { - var node = createNode(211 /* ReturnStatement */, location); + var node = createNode(212 /* ReturnStatement */, location); node.expression = expression; return node; } @@ -11120,7 +11168,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement, location) { - var node = createNode(212 /* WithStatement */, location); + var node = createNode(213 /* WithStatement */, location); node.expression = expression; node.statement = statement; return node; @@ -11134,7 +11182,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock, location) { - var node = createNode(213 /* SwitchStatement */, location); + var node = createNode(214 /* SwitchStatement */, location); node.expression = parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -11148,7 +11196,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement, location) { - var node = createNode(214 /* LabeledStatement */, location); + var node = createNode(215 /* LabeledStatement */, location); node.label = typeof label === "string" ? createIdentifier(label) : label; node.statement = statement; return node; @@ -11162,7 +11210,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression, location) { - var node = createNode(215 /* ThrowStatement */, location); + var node = createNode(216 /* ThrowStatement */, location); node.expression = expression; return node; } @@ -11175,7 +11223,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock, location) { - var node = createNode(216 /* TryStatement */, location); + var node = createNode(217 /* TryStatement */, location); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -11190,7 +11238,7 @@ var ts; } ts.updateTry = updateTry; function createCaseBlock(clauses, location) { - var node = createNode(227 /* CaseBlock */, location); + var node = createNode(228 /* CaseBlock */, location); node.clauses = createNodeArray(clauses); return node; } @@ -11203,7 +11251,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(220 /* FunctionDeclaration */, location, flags); + var node = createNode(221 /* FunctionDeclaration */, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; @@ -11223,7 +11271,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(221 /* ClassDeclaration */, location); + var node = createNode(222 /* ClassDeclaration */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -11241,7 +11289,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, location) { - var node = createNode(230 /* ImportDeclaration */, location); + var node = createNode(231 /* ImportDeclaration */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.importClause = importClause; @@ -11257,7 +11305,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings, location) { - var node = createNode(231 /* ImportClause */, location); + var node = createNode(232 /* ImportClause */, location); node.name = name; node.namedBindings = namedBindings; return node; @@ -11271,7 +11319,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name, location) { - var node = createNode(232 /* NamespaceImport */, location); + var node = createNode(233 /* NamespaceImport */, location); node.name = name; return node; } @@ -11284,7 +11332,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements, location) { - var node = createNode(233 /* NamedImports */, location); + var node = createNode(234 /* NamedImports */, location); node.elements = createNodeArray(elements); return node; } @@ -11297,7 +11345,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name, location) { - var node = createNode(234 /* ImportSpecifier */, location); + var node = createNode(235 /* ImportSpecifier */, location); node.propertyName = propertyName; node.name = name; return node; @@ -11311,7 +11359,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression, location) { - var node = createNode(235 /* ExportAssignment */, location); + var node = createNode(236 /* ExportAssignment */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.isExportEquals = isExportEquals; @@ -11327,7 +11375,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, location) { - var node = createNode(236 /* ExportDeclaration */, location); + var node = createNode(237 /* ExportDeclaration */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.exportClause = exportClause; @@ -11343,7 +11391,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements, location) { - var node = createNode(237 /* NamedExports */, location); + var node = createNode(238 /* NamedExports */, location); node.elements = createNodeArray(elements); return node; } @@ -11356,7 +11404,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(name, propertyName, location) { - var node = createNode(238 /* ExportSpecifier */, location); + var node = createNode(239 /* ExportSpecifier */, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; return node; @@ -11371,7 +11419,7 @@ var ts; ts.updateExportSpecifier = updateExportSpecifier; // JSX function createJsxElement(openingElement, children, closingElement, location) { - var node = createNode(241 /* JsxElement */, location); + var node = createNode(242 /* JsxElement */, location); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -11386,7 +11434,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, attributes, location) { - var node = createNode(242 /* JsxSelfClosingElement */, location); + var node = createNode(243 /* JsxSelfClosingElement */, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -11400,7 +11448,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, attributes, location) { - var node = createNode(243 /* JsxOpeningElement */, location); + var node = createNode(244 /* JsxOpeningElement */, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -11653,47 +11701,47 @@ var ts; ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; // Compound nodes function createComma(left, right) { - return createBinary(left, 24 /* CommaToken */, right); + return createBinary(left, 25 /* CommaToken */, right); } ts.createComma = createComma; function createLessThan(left, right, location) { - return createBinary(left, 25 /* LessThanToken */, right, location); + return createBinary(left, 26 /* LessThanToken */, right, location); } ts.createLessThan = createLessThan; function createAssignment(left, right, location) { - return createBinary(left, 56 /* EqualsToken */, right, location); + return createBinary(left, 57 /* EqualsToken */, right, location); } ts.createAssignment = createAssignment; function createStrictEquality(left, right) { - return createBinary(left, 32 /* EqualsEqualsEqualsToken */, right); + return createBinary(left, 33 /* EqualsEqualsEqualsToken */, right); } ts.createStrictEquality = createStrictEquality; function createStrictInequality(left, right) { - return createBinary(left, 33 /* ExclamationEqualsEqualsToken */, right); + return createBinary(left, 34 /* ExclamationEqualsEqualsToken */, right); } ts.createStrictInequality = createStrictInequality; function createAdd(left, right) { - return createBinary(left, 35 /* PlusToken */, right); + return createBinary(left, 36 /* PlusToken */, right); } ts.createAdd = createAdd; function createSubtract(left, right) { - return createBinary(left, 36 /* MinusToken */, right); + return createBinary(left, 37 /* MinusToken */, right); } ts.createSubtract = createSubtract; function createPostfixIncrement(operand, location) { - return createPostfix(operand, 41 /* PlusPlusToken */, location); + return createPostfix(operand, 42 /* PlusPlusToken */, location); } ts.createPostfixIncrement = createPostfixIncrement; function createLogicalAnd(left, right) { - return createBinary(left, 51 /* AmpersandAmpersandToken */, right); + return createBinary(left, 52 /* AmpersandAmpersandToken */, right); } ts.createLogicalAnd = createLogicalAnd; function createLogicalOr(left, right) { - return createBinary(left, 52 /* BarBarToken */, right); + return createBinary(left, 53 /* BarBarToken */, right); } ts.createLogicalOr = createLogicalOr; function createLogicalNot(operand) { - return createPrefix(49 /* ExclamationToken */, operand); + return createPrefix(50 /* ExclamationToken */, operand); } ts.createLogicalNot = createLogicalNot; function createVoidZero() { @@ -11714,7 +11762,7 @@ var ts; function createRestParameter(name) { return createParameterDeclaration( /*decorators*/ undefined, - /*modifiers*/ undefined, createToken(22 /* DotDotDotToken */), name, + /*modifiers*/ undefined, createToken(23 /* DotDotDotToken */), name, /*questionToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined); @@ -11844,7 +11892,8 @@ var ts; } ts.createDecorateHelper = createDecorateHelper; function createAwaiterHelper(externalHelpersModuleName, hasLexicalArguments, promiseConstructor, body) { - var generatorFunc = createFunctionExpression(createToken(37 /* AsteriskToken */), + var generatorFunc = createFunctionExpression( + /*modifiers*/ undefined, createToken(38 /* AsteriskToken */), /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ [], @@ -11935,6 +11984,7 @@ var ts; /*modifiers*/ undefined, createConstDeclarationList([ createVariableDeclaration("_super", /*type*/ undefined, createCall(createParen(createFunctionExpression( + /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, [ @@ -11963,19 +12013,19 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = skipParentheses(node); switch (target.kind) { - case 69 /* Identifier */: + case 70 /* Identifier */: return cacheIdentifiers; - case 97 /* ThisKeyword */: + case 98 /* ThisKeyword */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: return false; - case 170 /* ArrayLiteralExpression */: + case 171 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 171 /* ObjectLiteralExpression */: + case 172 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -11989,13 +12039,13 @@ var ts; thisArg = createThis(); target = callee; } - else if (callee.kind === 95 /* SuperKeyword */) { + else if (callee.kind === 96 /* SuperKeyword */) { thisArg = createThis(); - target = languageVersion < 2 /* ES6 */ ? createIdentifier("_super", /*location*/ callee) : callee; + target = languageVersion < 2 /* ES2015 */ ? createIdentifier("_super", /*location*/ callee) : callee; } else { switch (callee.kind) { - case 172 /* PropertyAccessExpression */: { + case 173 /* PropertyAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` thisArg = createTempVariable(recordTempVariable); @@ -12009,7 +12059,7 @@ var ts; } break; } - case 173 /* ElementAccessExpression */: { + case 174 /* ElementAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` thisArg = createTempVariable(recordTempVariable); @@ -12063,14 +12113,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); case 253 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); case 254 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 147 /* MethodDeclaration */: + case 148 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); } } @@ -12080,7 +12130,7 @@ var ts; if (property === firstAccessor) { var properties_1 = []; if (getAccessor) { - var getterFunction = createFunctionExpression( + var getterFunction = createFunctionExpression(getAccessor.modifiers, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, getAccessor.parameters, @@ -12091,7 +12141,7 @@ var ts; properties_1.push(getter); } if (setAccessor) { - var setterFunction = createFunctionExpression( + var setterFunction = createFunctionExpression(setAccessor.modifiers, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, setAccessor.parameters, @@ -12125,7 +12175,7 @@ var ts; /*original*/ property)); } function createExpressionForMethodDeclaration(method, receiver) { - return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, method.name, /*location*/ method.name), setOriginalNode(createFunctionExpression(method.asteriskToken, + return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, method.name, /*location*/ method.name), setOriginalNode(createFunctionExpression(method.modifiers, method.asteriskToken, /*name*/ undefined, /*typeParameters*/ undefined, method.parameters, /*type*/ undefined, method.body, @@ -12150,7 +12200,7 @@ var ts; * @param visitor: Optional callback used to visit any custom prologue directives. */ function addPrologueDirectives(target, source, ensureUseStrict, visitor) { - ts.Debug.assert(target.length === 0, "PrologueDirectives should be at the first statement in the target statements array"); + ts.Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array"); var foundUseStrict = false; var statementOffset = 0; var numStatements = source.length; @@ -12163,16 +12213,20 @@ var ts; target.push(statement); } else { - if (ensureUseStrict && !foundUseStrict) { - target.push(startOnNewLine(createStatement(createLiteral("use strict")))); - foundUseStrict = true; - } - if (getEmitFlags(statement) & 8388608 /* CustomPrologue */) { - target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); - } - else { - break; - } + break; + } + statementOffset++; + } + if (ensureUseStrict && !foundUseStrict) { + target.push(startOnNewLine(createStatement(createLiteral("use strict")))); + } + while (statementOffset < numStatements) { + var statement = source[statementOffset]; + if (getEmitFlags(statement) & 8388608 /* CustomPrologue */) { + target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); + } + else { + break; } statementOffset++; } @@ -12219,7 +12273,7 @@ var ts; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = skipPartiallyEmittedExpressions(operand); // If the resulting expression is already parenthesized, we do not need to do any further processing. - if (skipped.kind === 178 /* ParenthesizedExpression */) { + if (skipped.kind === 179 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -12253,8 +12307,8 @@ var ts; // // If `a ** d` is on the left of operator `**`, we need to parenthesize to preserve // the intended order of operations: `(a ** b) ** c` - var binaryOperatorPrecedence = ts.getOperatorPrecedence(187 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(187 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(188 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(188 /* BinaryExpression */, binaryOperator); var emittedOperand = skipPartiallyEmittedExpressions(operand); var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { @@ -12263,7 +12317,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 190 /* YieldExpression */) { + && operand.kind === 191 /* YieldExpression */) { return false; } return true; @@ -12300,7 +12354,7 @@ var ts; // the same kind (recursively). // "a"+(1+2) => "a"+(1+2) // "a"+("b"+"c") => "a"+"b"+"c" - if (binaryOperator === 35 /* PlusToken */) { + if (binaryOperator === 36 /* PlusToken */) { var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0 /* Unknown */; if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { return false; @@ -12335,10 +12389,10 @@ var ts; // // While addition is associative in mathematics, JavaScript's `+` is not // guaranteed to be associative as it is overloaded with string concatenation. - return binaryOperator === 37 /* AsteriskToken */ - || binaryOperator === 47 /* BarToken */ - || binaryOperator === 46 /* AmpersandToken */ - || binaryOperator === 48 /* CaretToken */; + return binaryOperator === 38 /* AsteriskToken */ + || binaryOperator === 48 /* BarToken */ + || binaryOperator === 47 /* AmpersandToken */ + || binaryOperator === 49 /* CaretToken */; } /** * This function determines whether an expression consists of a homogeneous set of @@ -12351,7 +12405,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 187 /* BinaryExpression */ && node.operatorToken.kind === 35 /* PlusToken */) { + if (node.kind === 188 /* BinaryExpression */ && node.operatorToken.kind === 36 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -12374,9 +12428,9 @@ var ts; function parenthesizeForNew(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); switch (emittedExpression.kind) { - case 174 /* CallExpression */: + case 175 /* CallExpression */: return createParen(expression); - case 175 /* NewExpression */: + case 176 /* NewExpression */: return emittedExpression.arguments ? expression : createParen(expression); @@ -12401,7 +12455,7 @@ var ts; // var emittedExpression = skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 175 /* NewExpression */ || emittedExpression.arguments) + && (emittedExpression.kind !== 176 /* NewExpression */ || emittedExpression.arguments) && emittedExpression.kind !== 8 /* NumericLiteral */) { return expression; } @@ -12439,7 +12493,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(187 /* BinaryExpression */, 24 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(188 /* BinaryExpression */, 25 /* CommaToken */); return expressionPrecedence > commaPrecedence ? expression : createParen(expression, /*location*/ expression); @@ -12450,7 +12504,7 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = skipPartiallyEmittedExpressions(callee).kind; - if (kind === 179 /* FunctionExpression */ || kind === 180 /* ArrowFunction */) { + if (kind === 180 /* FunctionExpression */ || kind === 181 /* ArrowFunction */) { var mutableCall = getMutableClone(emittedExpression); mutableCall.expression = createParen(callee, /*location*/ callee); return recreatePartiallyEmittedExpressions(expression, mutableCall); @@ -12458,7 +12512,7 @@ var ts; } else { var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; - if (leftmostExpressionKind === 171 /* ObjectLiteralExpression */ || leftmostExpressionKind === 179 /* FunctionExpression */) { + if (leftmostExpressionKind === 172 /* ObjectLiteralExpression */ || leftmostExpressionKind === 180 /* FunctionExpression */) { return createParen(expression, /*location*/ expression); } } @@ -12482,18 +12536,18 @@ var ts; function getLeftmostExpression(node) { while (true) { switch (node.kind) { - case 186 /* PostfixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: node = node.operand; continue; - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: node = node.left; continue; - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: node = node.condition; continue; - case 174 /* CallExpression */: - case 173 /* ElementAccessExpression */: - case 172 /* PropertyAccessExpression */: + case 175 /* CallExpression */: + case 174 /* ElementAccessExpression */: + case 173 /* PropertyAccessExpression */: node = node.expression; continue; case 288 /* PartiallyEmittedExpression */: @@ -12505,7 +12559,7 @@ var ts; } function parenthesizeConciseBody(body) { var emittedBody = skipPartiallyEmittedExpressions(body); - if (emittedBody.kind === 171 /* ObjectLiteralExpression */) { + if (emittedBody.kind === 172 /* ObjectLiteralExpression */) { return createParen(body, /*location*/ body); } return body; @@ -12537,7 +12591,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipParentheses(node) { - while (node.kind === 178 /* ParenthesizedExpression */) { + while (node.kind === 179 /* ParenthesizedExpression */) { node = node.expression; } return node; @@ -12771,10 +12825,10 @@ var ts; var name_9 = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name_9) ? name_9 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); } - if (node.kind === 230 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 231 /* ImportDeclaration */ && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 236 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 237 /* ExportDeclaration */ && node.moduleSpecifier) { return getGeneratedNameForNode(node); } return undefined; @@ -12845,10 +12899,10 @@ var ts; if (kind === 256 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } - else if (kind === 69 /* Identifier */) { + else if (kind === 70 /* Identifier */) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } - else if (kind < 139 /* FirstNode */) { + else if (kind < 140 /* FirstNode */) { return new (TokenConstructor || (TokenConstructor = ts.objectAllocator.getTokenConstructor()))(kind, pos, end); } else { @@ -12891,10 +12945,10 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 139 /* QualifiedName */: + case 140 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 141 /* TypeParameter */: + case 142 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); @@ -12905,12 +12959,12 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 142 /* Parameter */: - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 143 /* Parameter */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: case 253 /* PropertyAssignment */: - case 218 /* VariableDeclaration */: - case 169 /* BindingElement */: + case 219 /* VariableDeclaration */: + case 170 /* BindingElement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -12919,24 +12973,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 156 /* FunctionType */: - case 157 /* ConstructorType */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 179 /* FunctionExpression */: - case 220 /* FunctionDeclaration */: - case 180 /* ArrowFunction */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 180 /* FunctionExpression */: + case 221 /* FunctionDeclaration */: + case 181 /* ArrowFunction */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -12947,176 +13001,176 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 155 /* TypeReference */: + case 156 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 154 /* TypePredicate */: + case 155 /* TypePredicate */: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 158 /* TypeQuery */: + case 159 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 159 /* TypeLiteral */: + case 160 /* TypeLiteral */: return visitNodes(cbNodes, node.members); - case 160 /* ArrayType */: + case 161 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 161 /* TupleType */: + case 162 /* TupleType */: return visitNodes(cbNodes, node.elementTypes); - case 162 /* UnionType */: - case 163 /* IntersectionType */: + case 163 /* UnionType */: + case 164 /* IntersectionType */: return visitNodes(cbNodes, node.types); - case 164 /* ParenthesizedType */: + case 165 /* ParenthesizedType */: return visitNode(cbNode, node.type); - case 166 /* LiteralType */: + case 167 /* LiteralType */: return visitNode(cbNode, node.literal); - case 167 /* ObjectBindingPattern */: - case 168 /* ArrayBindingPattern */: + case 168 /* ObjectBindingPattern */: + case 169 /* ArrayBindingPattern */: return visitNodes(cbNodes, node.elements); - case 170 /* ArrayLiteralExpression */: + case 171 /* ArrayLiteralExpression */: return visitNodes(cbNodes, node.elements); - case 171 /* ObjectLiteralExpression */: + case 172 /* ObjectLiteralExpression */: return visitNodes(cbNodes, node.properties); - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 173 /* ElementAccessExpression */: + case 174 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 174 /* CallExpression */: - case 175 /* NewExpression */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 176 /* TaggedTemplateExpression */: + case 177 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 177 /* TypeAssertionExpression */: + case 178 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 181 /* DeleteExpression */: + case 182 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 182 /* TypeOfExpression */: + case 183 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 183 /* VoidExpression */: + case 184 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 185 /* PrefixUnaryExpression */: + case 186 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 190 /* YieldExpression */: + case 191 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 184 /* AwaitExpression */: + case 185 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 186 /* PostfixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 195 /* AsExpression */: + case 196 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 196 /* NonNullExpression */: + case 197 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 191 /* SpreadElementExpression */: + case 192 /* SpreadElementExpression */: return visitNode(cbNode, node.expression); - case 199 /* Block */: - case 226 /* ModuleBlock */: + case 200 /* Block */: + case 227 /* ModuleBlock */: return visitNodes(cbNodes, node.statements); case 256 /* SourceFile */: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 219 /* VariableDeclarationList */: + case 220 /* VariableDeclarationList */: return visitNodes(cbNodes, node.declarations); - case 202 /* ExpressionStatement */: + case 203 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 203 /* IfStatement */: + case 204 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 204 /* DoStatement */: + case 205 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 205 /* WhileStatement */: + case 206 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 206 /* ForStatement */: + case 207 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 207 /* ForInStatement */: + case 208 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 208 /* ForOfStatement */: + case 209 /* ForOfStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 209 /* ContinueStatement */: - case 210 /* BreakStatement */: + case 210 /* ContinueStatement */: + case 211 /* BreakStatement */: return visitNode(cbNode, node.label); - case 211 /* ReturnStatement */: + case 212 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 212 /* WithStatement */: + case 213 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 213 /* SwitchStatement */: + case 214 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 227 /* CaseBlock */: + case 228 /* CaseBlock */: return visitNodes(cbNodes, node.clauses); case 249 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); case 250 /* DefaultClause */: return visitNodes(cbNodes, node.statements); - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 215 /* ThrowStatement */: + case 216 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 216 /* TryStatement */: + case 217 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); case 252 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 143 /* Decorator */: + case 144 /* Decorator */: return visitNode(cbNode, node.expression); - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: + case 222 /* ClassDeclaration */: + case 193 /* 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 222 /* InterfaceDeclaration */: + case 223 /* 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 223 /* TypeAliasDeclaration */: + case 224 /* TypeAliasDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -13124,65 +13178,65 @@ var ts; case 255 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 229 /* ImportEqualsDeclaration */: + case 230 /* ImportEqualsDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 230 /* ImportDeclaration */: + case 231 /* ImportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 231 /* ImportClause */: + case 232 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 228 /* NamespaceExportDeclaration */: + case 229 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 232 /* NamespaceImport */: + case 233 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 233 /* NamedImports */: - case 237 /* NamedExports */: + case 234 /* NamedImports */: + case 238 /* NamedExports */: return visitNodes(cbNodes, node.elements); - case 236 /* ExportDeclaration */: + case 237 /* ExportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 234 /* ImportSpecifier */: - case 238 /* ExportSpecifier */: + case 235 /* ImportSpecifier */: + case 239 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 189 /* TemplateExpression */: + case 190 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 197 /* TemplateSpan */: + case 198 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); case 251 /* HeritageClause */: return visitNodes(cbNodes, node.types); - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 240 /* ExternalModuleReference */: + case 241 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 239 /* MissingDeclaration */: + case 240 /* MissingDeclaration */: return visitNodes(cbNodes, node.decorators); - case 241 /* JsxElement */: + case 242 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 242 /* JsxSelfClosingElement */: - case 243 /* JsxOpeningElement */: + case 243 /* JsxSelfClosingElement */: + case 244 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); case 246 /* JsxAttribute */: @@ -13303,7 +13357,7 @@ var ts; (function (Parser) { // Share a single scanner across all calls to parse a source file. This helps speed things // up by avoiding the cost of creating/compiling scanners over and over again. - var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ true); + var scanner = ts.createScanner(4 /* Latest */, /*skipTrivia*/ true); var disallowInAndDecoratorContext = 32768 /* DisallowInContext */ | 131072 /* DecoratorContext */; // capture constructors in 'initializeState' to avoid null checks var NodeConstructor; @@ -13394,9 +13448,9 @@ var ts; // Note: any errors at the end of the file that do not precede a regular node, should get // attached to the EOF token. var parseErrorBeforeNextFinishedNode = false; - function parseSourceFile(fileName, _sourceText, languageVersion, _syntaxCursor, setParentNodes, scriptKind) { + function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes, scriptKind) { scriptKind = ts.ensureScriptKind(fileName, scriptKind); - initializeState(fileName, _sourceText, languageVersion, _syntaxCursor, scriptKind); + initializeState(sourceText, languageVersion, syntaxCursor, scriptKind); var result = parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind); clearState(); return result; @@ -13406,7 +13460,7 @@ var ts; // .tsx and .jsx files are treated as jsx language variant. return scriptKind === 4 /* TSX */ || scriptKind === 2 /* JSX */ || scriptKind === 1 /* JS */ ? 1 /* JSX */ : 0 /* Standard */; } - function initializeState(fileName, _sourceText, languageVersion, _syntaxCursor, scriptKind) { + function initializeState(_sourceText, languageVersion, _syntaxCursor, scriptKind) { NodeConstructor = ts.objectAllocator.getNodeConstructor(); TokenConstructor = ts.objectAllocator.getTokenConstructor(); IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor(); @@ -13710,20 +13764,20 @@ var ts; } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token() === 69 /* Identifier */) { + if (token() === 70 /* 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() === 114 /* YieldKeyword */ && inYieldContext()) { + if (token() === 115 /* 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() === 119 /* AwaitKeyword */ && inAwaitContext()) { + if (token() === 120 /* AwaitKeyword */ && inAwaitContext()) { return false; } - return token() > 105 /* LastReservedWord */; + return token() > 106 /* LastReservedWord */; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -13766,22 +13820,22 @@ var ts; } function canParseSemicolon() { // If there's a real semicolon, then we can always parse it out. - if (token() === 23 /* SemicolonToken */) { + if (token() === 24 /* SemicolonToken */) { return true; } // We can parse out an optional semicolon in ASI cases in the following cases. - return token() === 16 /* CloseBraceToken */ || token() === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); + return token() === 17 /* CloseBraceToken */ || token() === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); } function parseSemicolon() { if (canParseSemicolon()) { - if (token() === 23 /* SemicolonToken */) { + if (token() === 24 /* SemicolonToken */) { // consume the semicolon if it was explicitly provided. nextToken(); } return true; } else { - return parseExpected(23 /* SemicolonToken */); + return parseExpected(24 /* SemicolonToken */); } } // note: this function creates only node @@ -13790,8 +13844,8 @@ var ts; if (!(pos >= 0)) { pos = scanner.getStartPos(); } - return kind >= 139 /* FirstNode */ ? new NodeConstructor(kind, pos, pos) : - kind === 69 /* Identifier */ ? new IdentifierConstructor(kind, pos, pos) : + return kind >= 140 /* FirstNode */ ? new NodeConstructor(kind, pos, pos) : + kind === 70 /* Identifier */ ? new IdentifierConstructor(kind, pos, pos) : new TokenConstructor(kind, pos, pos); } function createNodeArray(elements, pos) { @@ -13838,16 +13892,16 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(69 /* Identifier */); + var node = createNode(70 /* Identifier */); // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker - if (token() !== 69 /* Identifier */) { + if (token() !== 70 /* Identifier */) { node.originalKeywordKind = token(); } node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - return createMissingNode(69 /* Identifier */, /*reportAtCurrentPosition*/ false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(70 /* Identifier */, /*reportAtCurrentPosition*/ false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -13864,7 +13918,7 @@ var ts; if (token() === 9 /* StringLiteral */ || token() === 8 /* NumericLiteral */) { return parseLiteralNode(/*internName*/ true); } - if (allowComputedPropertyNames && token() === 19 /* OpenBracketToken */) { + if (allowComputedPropertyNames && token() === 20 /* OpenBracketToken */) { return parseComputedPropertyName(); } return parseIdentifierName(); @@ -13882,13 +13936,13 @@ var ts; // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(140 /* ComputedPropertyName */); - parseExpected(19 /* OpenBracketToken */); + var node = createNode(141 /* ComputedPropertyName */); + parseExpected(20 /* OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker // will error if it sees a comma expression. node.expression = allowInAnd(parseExpression); - parseExpected(20 /* CloseBracketToken */); + parseExpected(21 /* CloseBracketToken */); return finishNode(node); } function parseContextualModifier(t) { @@ -13902,21 +13956,21 @@ var ts; return canFollowModifier(); } function nextTokenCanFollowModifier() { - if (token() === 74 /* ConstKeyword */) { + if (token() === 75 /* ConstKeyword */) { // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 81 /* EnumKeyword */; + return nextToken() === 82 /* EnumKeyword */; } - if (token() === 82 /* ExportKeyword */) { + if (token() === 83 /* ExportKeyword */) { nextToken(); - if (token() === 77 /* DefaultKeyword */) { + if (token() === 78 /* DefaultKeyword */) { return lookAhead(nextTokenIsClassOrFunctionOrAsync); } - return token() !== 37 /* AsteriskToken */ && token() !== 116 /* AsKeyword */ && token() !== 15 /* OpenBraceToken */ && canFollowModifier(); + return token() !== 38 /* AsteriskToken */ && token() !== 117 /* AsKeyword */ && token() !== 16 /* OpenBraceToken */ && canFollowModifier(); } - if (token() === 77 /* DefaultKeyword */) { + if (token() === 78 /* DefaultKeyword */) { return nextTokenIsClassOrFunctionOrAsync(); } - if (token() === 113 /* StaticKeyword */) { + if (token() === 114 /* StaticKeyword */) { nextToken(); return canFollowModifier(); } @@ -13926,16 +13980,16 @@ var ts; return ts.isModifierKind(token()) && tryParse(nextTokenCanFollowModifier); } function canFollowModifier() { - return token() === 19 /* OpenBracketToken */ - || token() === 15 /* OpenBraceToken */ - || token() === 37 /* AsteriskToken */ - || token() === 22 /* DotDotDotToken */ + return token() === 20 /* OpenBracketToken */ + || token() === 16 /* OpenBraceToken */ + || token() === 38 /* AsteriskToken */ + || token() === 23 /* DotDotDotToken */ || isLiteralPropertyName(); } function nextTokenIsClassOrFunctionOrAsync() { nextToken(); - return token() === 73 /* ClassKeyword */ || token() === 87 /* FunctionKeyword */ || - (token() === 118 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 74 /* ClassKeyword */ || token() === 88 /* FunctionKeyword */ || + (token() === 119 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -13953,9 +14007,9 @@ var ts; // we're parsing. For example, if we have a semicolon in the middle of a class, then // we really don't want to assume the class is over and we're on a statement in the // outer module. We just want to consume and move on. - return !(token() === 23 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); + return !(token() === 24 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); case 2 /* SwitchClauses */: - return token() === 71 /* CaseKeyword */ || token() === 77 /* DefaultKeyword */; + return token() === 72 /* CaseKeyword */ || token() === 78 /* DefaultKeyword */; case 4 /* TypeMembers */: return lookAhead(isTypeMemberStart); case 5 /* ClassMembers */: @@ -13963,19 +14017,19 @@ var ts; // not in error recovery. If we're in error recovery, we don't want an errant // semicolon to be treated as a class member (since they're almost always used // for statements. - return lookAhead(isClassMemberStart) || (token() === 23 /* SemicolonToken */ && !inErrorRecovery); + return lookAhead(isClassMemberStart) || (token() === 24 /* SemicolonToken */ && !inErrorRecovery); case 6 /* EnumMembers */: // Include open bracket computed properties. This technically also lets in indexers, // which would be a candidate for improved error reporting. - return token() === 19 /* OpenBracketToken */ || isLiteralPropertyName(); + return token() === 20 /* OpenBracketToken */ || isLiteralPropertyName(); case 12 /* ObjectLiteralMembers */: - return token() === 19 /* OpenBracketToken */ || token() === 37 /* AsteriskToken */ || isLiteralPropertyName(); + return token() === 20 /* OpenBracketToken */ || token() === 38 /* AsteriskToken */ || isLiteralPropertyName(); case 9 /* ObjectBindingElements */: - return token() === 19 /* OpenBracketToken */ || isLiteralPropertyName(); + return token() === 20 /* OpenBracketToken */ || isLiteralPropertyName(); case 7 /* HeritageClauseElement */: // If we see { } then only consume it as an expression if it is followed by , or { // That way we won't consume the body of a class in its heritage clause. - if (token() === 15 /* OpenBraceToken */) { + if (token() === 16 /* OpenBraceToken */) { return lookAhead(isValidHeritageClauseObjectLiteral); } if (!inErrorRecovery) { @@ -13990,23 +14044,23 @@ var ts; case 8 /* VariableDeclarations */: return isIdentifierOrPattern(); case 10 /* ArrayBindingElements */: - return token() === 24 /* CommaToken */ || token() === 22 /* DotDotDotToken */ || isIdentifierOrPattern(); + return token() === 25 /* CommaToken */ || token() === 23 /* DotDotDotToken */ || isIdentifierOrPattern(); case 17 /* TypeParameters */: return isIdentifier(); case 11 /* ArgumentExpressions */: case 15 /* ArrayLiteralMembers */: - return token() === 24 /* CommaToken */ || token() === 22 /* DotDotDotToken */ || isStartOfExpression(); + return token() === 25 /* CommaToken */ || token() === 23 /* DotDotDotToken */ || isStartOfExpression(); case 16 /* Parameters */: return isStartOfParameter(); case 18 /* TypeArguments */: case 19 /* TupleElementTypes */: - return token() === 24 /* CommaToken */ || isStartOfType(); + return token() === 25 /* CommaToken */ || isStartOfType(); case 20 /* HeritageClauses */: return isHeritageClause(); case 21 /* ImportOrExportSpecifiers */: return ts.tokenIsIdentifierOrKeyword(token()); case 13 /* JsxAttributes */: - return ts.tokenIsIdentifierOrKeyword(token()) || token() === 15 /* OpenBraceToken */; + return ts.tokenIsIdentifierOrKeyword(token()) || token() === 16 /* OpenBraceToken */; case 14 /* JsxChildren */: return true; case 22 /* JSDocFunctionParameters */: @@ -14019,8 +14073,8 @@ var ts; ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token() === 15 /* OpenBraceToken */); - if (nextToken() === 16 /* CloseBraceToken */) { + ts.Debug.assert(token() === 16 /* OpenBraceToken */); + if (nextToken() === 17 /* CloseBraceToken */) { // if we see "extends {}" then only treat the {} as what we're extending (and not // the class body) if we have: // @@ -14029,7 +14083,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 24 /* CommaToken */ || next === 15 /* OpenBraceToken */ || next === 83 /* ExtendsKeyword */ || next === 106 /* ImplementsKeyword */; + return next === 25 /* CommaToken */ || next === 16 /* OpenBraceToken */ || next === 84 /* ExtendsKeyword */ || next === 107 /* ImplementsKeyword */; } return true; } @@ -14042,8 +14096,8 @@ var ts; return ts.tokenIsIdentifierOrKeyword(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 106 /* ImplementsKeyword */ || - token() === 83 /* ExtendsKeyword */) { + if (token() === 107 /* ImplementsKeyword */ || + token() === 84 /* ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -14067,43 +14121,43 @@ var ts; case 12 /* ObjectLiteralMembers */: case 9 /* ObjectBindingElements */: case 21 /* ImportOrExportSpecifiers */: - return token() === 16 /* CloseBraceToken */; + return token() === 17 /* CloseBraceToken */; case 3 /* SwitchClauseStatements */: - return token() === 16 /* CloseBraceToken */ || token() === 71 /* CaseKeyword */ || token() === 77 /* DefaultKeyword */; + return token() === 17 /* CloseBraceToken */ || token() === 72 /* CaseKeyword */ || token() === 78 /* DefaultKeyword */; case 7 /* HeritageClauseElement */: - return token() === 15 /* OpenBraceToken */ || token() === 83 /* ExtendsKeyword */ || token() === 106 /* ImplementsKeyword */; + return token() === 16 /* OpenBraceToken */ || token() === 84 /* ExtendsKeyword */ || token() === 107 /* 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() === 83 /* ExtendsKeyword */ || token() === 106 /* ImplementsKeyword */; + return token() === 28 /* GreaterThanToken */ || token() === 18 /* OpenParenToken */ || token() === 16 /* OpenBraceToken */ || token() === 84 /* ExtendsKeyword */ || token() === 107 /* ImplementsKeyword */; case 11 /* ArgumentExpressions */: // Tokens other than ')' are here for better error recovery - return token() === 18 /* CloseParenToken */ || token() === 23 /* SemicolonToken */; + return token() === 19 /* CloseParenToken */ || token() === 24 /* SemicolonToken */; case 15 /* ArrayLiteralMembers */: case 19 /* TupleElementTypes */: case 10 /* ArrayBindingElements */: - return token() === 20 /* CloseBracketToken */; + return token() === 21 /* CloseBracketToken */; case 16 /* Parameters */: // Tokens other than ')' and ']' (the latter for index signatures) are here for better error recovery - return token() === 18 /* CloseParenToken */ || token() === 20 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; + return token() === 19 /* CloseParenToken */ || token() === 21 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; case 18 /* TypeArguments */: // All other tokens should cause the type-argument to terminate except comma token - return token() !== 24 /* CommaToken */; + return token() !== 25 /* CommaToken */; case 20 /* HeritageClauses */: - return token() === 15 /* OpenBraceToken */ || token() === 16 /* CloseBraceToken */; + return token() === 16 /* OpenBraceToken */ || token() === 17 /* CloseBraceToken */; case 13 /* JsxAttributes */: - return token() === 27 /* GreaterThanToken */ || token() === 39 /* SlashToken */; + return token() === 28 /* GreaterThanToken */ || token() === 40 /* SlashToken */; case 14 /* JsxChildren */: - return token() === 25 /* LessThanToken */ && lookAhead(nextTokenIsSlash); + return token() === 26 /* LessThanToken */ && lookAhead(nextTokenIsSlash); case 22 /* JSDocFunctionParameters */: - return token() === 18 /* CloseParenToken */ || token() === 54 /* ColonToken */ || token() === 16 /* CloseBraceToken */; + return token() === 19 /* CloseParenToken */ || token() === 55 /* ColonToken */ || token() === 17 /* CloseBraceToken */; case 23 /* JSDocTypeArguments */: - return token() === 27 /* GreaterThanToken */ || token() === 16 /* CloseBraceToken */; + return token() === 28 /* GreaterThanToken */ || token() === 17 /* CloseBraceToken */; case 25 /* JSDocTupleTypes */: - return token() === 20 /* CloseBracketToken */ || token() === 16 /* CloseBraceToken */; + return token() === 21 /* CloseBracketToken */ || token() === 17 /* CloseBraceToken */; case 24 /* JSDocRecordMembers */: - return token() === 16 /* CloseBraceToken */; + return token() === 17 /* CloseBraceToken */; } } function isVariableDeclaratorListTerminator() { @@ -14121,7 +14175,7 @@ var ts; // For better error recovery, if we see an '=>' then we just stop immediately. We've got an // arrow function here and it's going to be very unlikely that we'll resynchronize and get // another variable declaration. - if (token() === 34 /* EqualsGreaterThanToken */) { + if (token() === 35 /* EqualsGreaterThanToken */) { return true; } // Keep trying to parse out variable declarators. @@ -14284,20 +14338,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 148 /* Constructor */: - case 153 /* IndexSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 145 /* PropertyDeclaration */: - case 198 /* SemicolonClassElement */: + case 149 /* Constructor */: + case 154 /* IndexSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 146 /* PropertyDeclaration */: + case 199 /* SemicolonClassElement */: return true; - case 147 /* MethodDeclaration */: + case 148 /* 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 === 69 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 121 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 70 /* Identifier */ && + methodDeclaration.name.originalKeywordKind === 122 /* ConstructorKeyword */; return !nameIsConstructor; } } @@ -14316,35 +14370,35 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 220 /* FunctionDeclaration */: - case 200 /* VariableStatement */: - case 199 /* Block */: - case 203 /* IfStatement */: - case 202 /* ExpressionStatement */: - case 215 /* ThrowStatement */: - case 211 /* ReturnStatement */: - case 213 /* SwitchStatement */: - case 210 /* BreakStatement */: - case 209 /* ContinueStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: - case 206 /* ForStatement */: - case 205 /* WhileStatement */: - case 212 /* WithStatement */: - case 201 /* EmptyStatement */: - case 216 /* TryStatement */: - case 214 /* LabeledStatement */: - case 204 /* DoStatement */: - case 217 /* DebuggerStatement */: - case 230 /* ImportDeclaration */: - case 229 /* ImportEqualsDeclaration */: - case 236 /* ExportDeclaration */: - case 235 /* ExportAssignment */: - case 225 /* ModuleDeclaration */: - case 221 /* ClassDeclaration */: - case 222 /* InterfaceDeclaration */: - case 224 /* EnumDeclaration */: - case 223 /* TypeAliasDeclaration */: + case 221 /* FunctionDeclaration */: + case 201 /* VariableStatement */: + case 200 /* Block */: + case 204 /* IfStatement */: + case 203 /* ExpressionStatement */: + case 216 /* ThrowStatement */: + case 212 /* ReturnStatement */: + case 214 /* SwitchStatement */: + case 211 /* BreakStatement */: + case 210 /* ContinueStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: + case 207 /* ForStatement */: + case 206 /* WhileStatement */: + case 213 /* WithStatement */: + case 202 /* EmptyStatement */: + case 217 /* TryStatement */: + case 215 /* LabeledStatement */: + case 205 /* DoStatement */: + case 218 /* DebuggerStatement */: + case 231 /* ImportDeclaration */: + case 230 /* ImportEqualsDeclaration */: + case 237 /* ExportDeclaration */: + case 236 /* ExportAssignment */: + case 226 /* ModuleDeclaration */: + case 222 /* ClassDeclaration */: + case 223 /* InterfaceDeclaration */: + case 225 /* EnumDeclaration */: + case 224 /* TypeAliasDeclaration */: return true; } } @@ -14356,18 +14410,18 @@ var ts; function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 152 /* ConstructSignature */: - case 146 /* MethodSignature */: - case 153 /* IndexSignature */: - case 144 /* PropertySignature */: - case 151 /* CallSignature */: + case 153 /* ConstructSignature */: + case 147 /* MethodSignature */: + case 154 /* IndexSignature */: + case 145 /* PropertySignature */: + case 152 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 218 /* VariableDeclaration */) { + if (node.kind !== 219 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -14388,7 +14442,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 142 /* Parameter */) { + if (node.kind !== 143 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -14445,7 +14499,7 @@ var ts; if (isListElement(kind, /*inErrorRecovery*/ false)) { result.push(parseListElement(kind, parseElement)); commaStart = scanner.getTokenPos(); - if (parseOptional(24 /* CommaToken */)) { + if (parseOptional(25 /* CommaToken */)) { continue; } commaStart = -1; // Back to the state where the last token was not a comma @@ -14454,13 +14508,13 @@ var ts; } // We didn't get a comma, and the list wasn't terminated, explicitly parse // out a comma so we give a good error message. - parseExpected(24 /* CommaToken */); + parseExpected(25 /* CommaToken */); // If the token was a semicolon, and the caller allows that, then skip it and // continue. This ensures we get back on track and don't result in tons of // parse errors. For example, this can happen when people do things like use // a semicolon to delimit object literal members. Note: we'll have already // reported an error when we called parseExpected above. - if (considerSemicolonAsDelimiter && token() === 23 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { + if (considerSemicolonAsDelimiter && token() === 24 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); } continue; @@ -14499,8 +14553,8 @@ var ts; // The allowReservedWords parameter controls whether reserved words are permitted after the first dot function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); - while (parseOptional(21 /* DotToken */)) { - var node = createNode(139 /* QualifiedName */, entity.pos); // !!! + while (parseOptional(22 /* DotToken */)) { + var node = createNode(140 /* QualifiedName */, entity.pos); // !!! node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -14533,33 +14587,33 @@ 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(69 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return createMissingNode(70 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(189 /* TemplateExpression */); + var template = createNode(190 /* TemplateExpression */); template.head = parseTemplateHead(); - ts.Debug.assert(template.head.kind === 12 /* TemplateHead */, "Template head has wrong token kind"); + ts.Debug.assert(template.head.kind === 13 /* TemplateHead */, "Template head has wrong token kind"); var templateSpans = createNodeArray(); do { templateSpans.push(parseTemplateSpan()); - } while (ts.lastOrUndefined(templateSpans).literal.kind === 13 /* TemplateMiddle */); + } while (ts.lastOrUndefined(templateSpans).literal.kind === 14 /* TemplateMiddle */); templateSpans.end = getNodeEnd(); template.templateSpans = templateSpans; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(197 /* TemplateSpan */); + var span = createNode(198 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; - if (token() === 16 /* CloseBraceToken */) { + if (token() === 17 /* CloseBraceToken */) { reScanTemplateToken(); literal = parseTemplateMiddleOrTemplateTail(); } else { - literal = parseExpectedToken(14 /* TemplateTail */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(16 /* CloseBraceToken */)); + literal = parseExpectedToken(15 /* TemplateTail */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(17 /* CloseBraceToken */)); } span.literal = literal; return finishNode(span); @@ -14569,12 +14623,12 @@ var ts; } function parseTemplateHead() { var fragment = parseLiteralLikeNode(token(), /*internName*/ false); - ts.Debug.assert(fragment.kind === 12 /* TemplateHead */, "Template head has wrong token kind"); + ts.Debug.assert(fragment.kind === 13 /* TemplateHead */, "Template head has wrong token kind"); return fragment; } function parseTemplateMiddleOrTemplateTail() { var fragment = parseLiteralLikeNode(token(), /*internName*/ false); - ts.Debug.assert(fragment.kind === 13 /* TemplateMiddle */ || fragment.kind === 14 /* TemplateTail */, "Template fragment has wrong token kind"); + ts.Debug.assert(fragment.kind === 14 /* TemplateMiddle */ || fragment.kind === 15 /* TemplateTail */, "Template fragment has wrong token kind"); return fragment; } function parseLiteralLikeNode(kind, internName) { @@ -14606,35 +14660,35 @@ var ts; // TYPES function parseTypeReference() { var typeName = parseEntityName(/*allowReservedWords*/ false, ts.Diagnostics.Type_expected); - var node = createNode(155 /* TypeReference */, typeName.pos); + var node = createNode(156 /* TypeReference */, typeName.pos); node.typeName = typeName; - if (!scanner.hasPrecedingLineBreak() && token() === 25 /* LessThanToken */) { - node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); + if (!scanner.hasPrecedingLineBreak() && token() === 26 /* LessThanToken */) { + node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 26 /* LessThanToken */, 28 /* GreaterThanToken */); } return finishNode(node); } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(154 /* TypePredicate */, lhs.pos); + var node = createNode(155 /* TypePredicate */, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(165 /* ThisType */); + var node = createNode(166 /* ThisType */); nextToken(); return finishNode(node); } function parseTypeQuery() { - var node = createNode(158 /* TypeQuery */); - parseExpected(101 /* TypeOfKeyword */); + var node = createNode(159 /* TypeQuery */); + parseExpected(102 /* TypeOfKeyword */); node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(141 /* TypeParameter */); + var node = createNode(142 /* TypeParameter */); node.name = parseIdentifier(); - if (parseOptional(83 /* ExtendsKeyword */)) { + if (parseOptional(84 /* 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 @@ -14656,29 +14710,29 @@ var ts; return finishNode(node); } function parseTypeParameters() { - if (token() === 25 /* LessThanToken */) { - return parseBracketedList(17 /* TypeParameters */, parseTypeParameter, 25 /* LessThanToken */, 27 /* GreaterThanToken */); + if (token() === 26 /* LessThanToken */) { + return parseBracketedList(17 /* TypeParameters */, parseTypeParameter, 26 /* LessThanToken */, 28 /* GreaterThanToken */); } } function parseParameterType() { - if (parseOptional(54 /* ColonToken */)) { + if (parseOptional(55 /* ColonToken */)) { return parseType(); } return undefined; } function isStartOfParameter() { - return token() === 22 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifierKind(token()) || token() === 55 /* AtToken */ || token() === 97 /* ThisKeyword */; + return token() === 23 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifierKind(token()) || token() === 56 /* AtToken */ || token() === 98 /* ThisKeyword */; } function parseParameter() { - var node = createNode(142 /* Parameter */); - if (token() === 97 /* ThisKeyword */) { + var node = createNode(143 /* Parameter */); + if (token() === 98 /* ThisKeyword */) { node.name = createIdentifier(/*isIdentifier*/ true, undefined); node.type = parseParameterType(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); + node.dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); // FormalParameter [Yield,Await]: // BindingElement[?Yield,?Await] node.name = parseIdentifierOrPattern(); @@ -14693,7 +14747,7 @@ var ts; // to avoid this we'll advance cursor to the next token. nextToken(); } - node.questionToken = parseOptionalToken(53 /* QuestionToken */); + node.questionToken = parseOptionalToken(54 /* QuestionToken */); node.type = parseParameterType(); node.initializer = parseBindingElementInitializer(/*inParameter*/ true); // Do not check for initializers in an ambient context for parameters. This is not @@ -14713,7 +14767,7 @@ var ts; return parseInitializer(/*inParameter*/ true); } function fillSignature(returnToken, yieldContext, awaitContext, requireCompleteParameterList, signature) { - var returnTokenRequired = returnToken === 34 /* EqualsGreaterThanToken */; + var returnTokenRequired = returnToken === 35 /* EqualsGreaterThanToken */; signature.typeParameters = parseTypeParameters(); signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); if (returnTokenRequired) { @@ -14738,7 +14792,7 @@ var ts; // // SingleNameBinding [Yield,Await]: // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt - if (parseExpected(17 /* OpenParenToken */)) { + if (parseExpected(18 /* OpenParenToken */)) { var savedYieldContext = inYieldContext(); var savedAwaitContext = inAwaitContext(); setYieldContext(yieldContext); @@ -14746,7 +14800,7 @@ var ts; var result = parseDelimitedList(16 /* Parameters */, parseParameter); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); - if (!parseExpected(18 /* CloseParenToken */) && requireCompleteParameterList) { + if (!parseExpected(19 /* CloseParenToken */) && requireCompleteParameterList) { // Caller insisted that we had to end with a ) We didn't. So just return // undefined here. return undefined; @@ -14761,7 +14815,7 @@ var ts; function parseTypeMemberSemicolon() { // We allow type members to be separated by commas or (possibly ASI) semicolons. // First check if it was a comma. If so, we're done with the member. - if (parseOptional(24 /* CommaToken */)) { + if (parseOptional(25 /* CommaToken */)) { return; } // Didn't have a comma. We must have a (possible ASI) semicolon. @@ -14769,15 +14823,15 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 152 /* ConstructSignature */) { - parseExpected(92 /* NewKeyword */); + if (kind === 153 /* ConstructSignature */) { + parseExpected(93 /* NewKeyword */); } - fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + fillSignature(55 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); parseTypeMemberSemicolon(); return addJSDocComment(finishNode(node)); } function isIndexSignature() { - if (token() !== 19 /* OpenBracketToken */) { + if (token() !== 20 /* OpenBracketToken */) { return false; } return lookAhead(isUnambiguouslyIndexSignature); @@ -14800,7 +14854,7 @@ var ts; // [] // nextToken(); - if (token() === 22 /* DotDotDotToken */ || token() === 20 /* CloseBracketToken */) { + if (token() === 23 /* DotDotDotToken */ || token() === 21 /* CloseBracketToken */) { return true; } if (ts.isModifierKind(token())) { @@ -14819,49 +14873,49 @@ 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() === 54 /* ColonToken */ || token() === 24 /* CommaToken */) { + if (token() === 55 /* ColonToken */ || token() === 25 /* 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() !== 53 /* QuestionToken */) { + if (token() !== 54 /* 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() === 54 /* ColonToken */ || token() === 24 /* CommaToken */ || token() === 20 /* CloseBracketToken */; + return token() === 55 /* ColonToken */ || token() === 25 /* CommaToken */ || token() === 21 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(153 /* IndexSignature */, fullStart); + var node = createNode(154 /* IndexSignature */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); + node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 20 /* OpenBracketToken */, 21 /* CloseBracketToken */); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); return finishNode(node); } function parsePropertyOrMethodSignature(fullStart, modifiers) { var name = parsePropertyName(); - var questionToken = parseOptionalToken(53 /* QuestionToken */); - if (token() === 17 /* OpenParenToken */ || token() === 25 /* LessThanToken */) { - var method = createNode(146 /* MethodSignature */, fullStart); + var questionToken = parseOptionalToken(54 /* QuestionToken */); + if (token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */) { + var method = createNode(147 /* MethodSignature */, fullStart); method.modifiers = modifiers; method.name = name; method.questionToken = questionToken; // Method signatures don't exist in expression contexts. So they have neither // [Yield] nor [Await] - fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, method); + fillSignature(55 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, method); parseTypeMemberSemicolon(); return addJSDocComment(finishNode(method)); } else { - var property = createNode(144 /* PropertySignature */, fullStart); + var property = createNode(145 /* PropertySignature */, fullStart); property.modifiers = modifiers; property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); - if (token() === 56 /* EqualsToken */) { + if (token() === 57 /* EqualsToken */) { // Although type literal properties cannot not have initializers, we attempt // to parse an initializer so we can report in the checker that an interface // property or type literal property cannot have an initializer. @@ -14874,7 +14928,7 @@ var ts; function isTypeMemberStart() { var idToken; // Return true if we have the start of a signature member - if (token() === 17 /* OpenParenToken */ || token() === 25 /* LessThanToken */) { + if (token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier @@ -14883,7 +14937,7 @@ var ts; nextToken(); } // Index signatures and computed property names are type members - if (token() === 19 /* OpenBracketToken */) { + if (token() === 20 /* OpenBracketToken */) { return true; } // Try to get the first property-like token following all modifiers @@ -14894,21 +14948,21 @@ var ts; // If we were able to get any potential identifier, check that it is // the start of a member declaration if (idToken) { - return token() === 17 /* OpenParenToken */ || - token() === 25 /* LessThanToken */ || - token() === 53 /* QuestionToken */ || - token() === 54 /* ColonToken */ || - token() === 24 /* CommaToken */ || + return token() === 18 /* OpenParenToken */ || + token() === 26 /* LessThanToken */ || + token() === 54 /* QuestionToken */ || + token() === 55 /* ColonToken */ || + token() === 25 /* CommaToken */ || canParseSemicolon(); } return false; } function parseTypeMember() { - if (token() === 17 /* OpenParenToken */ || token() === 25 /* LessThanToken */) { - return parseSignatureMember(151 /* CallSignature */); + if (token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */) { + return parseSignatureMember(152 /* CallSignature */); } - if (token() === 92 /* NewKeyword */ && lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(152 /* ConstructSignature */); + if (token() === 93 /* NewKeyword */ && lookAhead(isStartOfConstructSignature)) { + return parseSignatureMember(153 /* ConstructSignature */); } var fullStart = getNodePos(); var modifiers = parseModifiers(); @@ -14919,18 +14973,18 @@ var ts; } function isStartOfConstructSignature() { nextToken(); - return token() === 17 /* OpenParenToken */ || token() === 25 /* LessThanToken */; + return token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */; } function parseTypeLiteral() { - var node = createNode(159 /* TypeLiteral */); + var node = createNode(160 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseObjectTypeMembers() { var members; - if (parseExpected(15 /* OpenBraceToken */)) { + if (parseExpected(16 /* OpenBraceToken */)) { members = parseList(4 /* TypeMembers */, parseTypeMember); - parseExpected(16 /* CloseBraceToken */); + parseExpected(17 /* CloseBraceToken */); } else { members = createMissingList(); @@ -14938,31 +14992,31 @@ var ts; return members; } function parseTupleType() { - var node = createNode(161 /* TupleType */); - node.elementTypes = parseBracketedList(19 /* TupleElementTypes */, parseType, 19 /* OpenBracketToken */, 20 /* CloseBracketToken */); + var node = createNode(162 /* TupleType */); + node.elementTypes = parseBracketedList(19 /* TupleElementTypes */, parseType, 20 /* OpenBracketToken */, 21 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(164 /* ParenthesizedType */); - parseExpected(17 /* OpenParenToken */); + var node = createNode(165 /* ParenthesizedType */); + parseExpected(18 /* OpenParenToken */); node.type = parseType(); - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); return finishNode(node); } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 157 /* ConstructorType */) { - parseExpected(92 /* NewKeyword */); + if (kind === 158 /* ConstructorType */) { + parseExpected(93 /* NewKeyword */); } - fillSignature(34 /* EqualsGreaterThanToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + fillSignature(35 /* EqualsGreaterThanToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); return finishNode(node); } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token() === 21 /* DotToken */ ? undefined : node; + return token() === 22 /* DotToken */ ? undefined : node; } function parseLiteralTypeNode() { - var node = createNode(166 /* LiteralType */); + var node = createNode(167 /* LiteralType */); node.literal = parseSimpleUnaryExpression(); finishNode(node); return node; @@ -14972,42 +15026,42 @@ var ts; } function parseNonArrayType() { switch (token()) { - case 117 /* AnyKeyword */: - case 132 /* StringKeyword */: - case 130 /* NumberKeyword */: - case 120 /* BooleanKeyword */: - case 133 /* SymbolKeyword */: - case 135 /* UndefinedKeyword */: - case 127 /* NeverKeyword */: + case 118 /* AnyKeyword */: + case 133 /* StringKeyword */: + case 131 /* NumberKeyword */: + case 121 /* BooleanKeyword */: + case 134 /* SymbolKeyword */: + case 136 /* UndefinedKeyword */: + case 128 /* NeverKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: + case 100 /* TrueKeyword */: + case 85 /* FalseKeyword */: return parseLiteralTypeNode(); - case 36 /* MinusToken */: + case 37 /* MinusToken */: return lookAhead(nextTokenIsNumericLiteral) ? parseLiteralTypeNode() : parseTypeReference(); - case 103 /* VoidKeyword */: - case 93 /* NullKeyword */: + case 104 /* VoidKeyword */: + case 94 /* NullKeyword */: return parseTokenNode(); - case 97 /* ThisKeyword */: { + case 98 /* ThisKeyword */: { var thisKeyword = parseThisTypeNode(); - if (token() === 124 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 125 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 101 /* TypeOfKeyword */: + case 102 /* TypeOfKeyword */: return parseTypeQuery(); - case 15 /* OpenBraceToken */: + case 16 /* OpenBraceToken */: return parseTypeLiteral(); - case 19 /* OpenBracketToken */: + case 20 /* OpenBracketToken */: return parseTupleType(); - case 17 /* OpenParenToken */: + case 18 /* OpenParenToken */: return parseParenthesizedType(); default: return parseTypeReference(); @@ -15015,29 +15069,29 @@ var ts; } function isStartOfType() { switch (token()) { - case 117 /* AnyKeyword */: - case 132 /* StringKeyword */: - case 130 /* NumberKeyword */: - case 120 /* BooleanKeyword */: - case 133 /* SymbolKeyword */: - case 103 /* VoidKeyword */: - case 135 /* UndefinedKeyword */: - case 93 /* NullKeyword */: - case 97 /* ThisKeyword */: - case 101 /* TypeOfKeyword */: - case 127 /* NeverKeyword */: - case 15 /* OpenBraceToken */: - case 19 /* OpenBracketToken */: - case 25 /* LessThanToken */: - case 92 /* NewKeyword */: + case 118 /* AnyKeyword */: + case 133 /* StringKeyword */: + case 131 /* NumberKeyword */: + case 121 /* BooleanKeyword */: + case 134 /* SymbolKeyword */: + case 104 /* VoidKeyword */: + case 136 /* UndefinedKeyword */: + case 94 /* NullKeyword */: + case 98 /* ThisKeyword */: + case 102 /* TypeOfKeyword */: + case 128 /* NeverKeyword */: + case 16 /* OpenBraceToken */: + case 20 /* OpenBracketToken */: + case 26 /* LessThanToken */: + case 93 /* NewKeyword */: case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: + case 100 /* TrueKeyword */: + case 85 /* FalseKeyword */: return true; - case 36 /* MinusToken */: + case 37 /* MinusToken */: return lookAhead(nextTokenIsNumericLiteral); - case 17 /* OpenParenToken */: + case 18 /* OpenParenToken */: // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, // or something that starts a type. We don't want to consider things like '(1)' a type. return lookAhead(isStartOfParenthesizedOrFunctionType); @@ -15047,13 +15101,13 @@ var ts; } function isStartOfParenthesizedOrFunctionType() { nextToken(); - return token() === 18 /* CloseParenToken */ || isStartOfParameter() || isStartOfType(); + return token() === 19 /* CloseParenToken */ || isStartOfParameter() || isStartOfType(); } function parseArrayTypeOrHigher() { var type = parseNonArrayType(); - while (!scanner.hasPrecedingLineBreak() && parseOptional(19 /* OpenBracketToken */)) { - parseExpected(20 /* CloseBracketToken */); - var node = createNode(160 /* ArrayType */, type.pos); + while (!scanner.hasPrecedingLineBreak() && parseOptional(20 /* OpenBracketToken */)) { + parseExpected(21 /* CloseBracketToken */); + var node = createNode(161 /* ArrayType */, type.pos); node.elementType = type; type = finishNode(node); } @@ -15074,27 +15128,27 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(163 /* IntersectionType */, parseArrayTypeOrHigher, 46 /* AmpersandToken */); + return parseUnionOrIntersectionType(164 /* IntersectionType */, parseArrayTypeOrHigher, 47 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(162 /* UnionType */, parseIntersectionTypeOrHigher, 47 /* BarToken */); + return parseUnionOrIntersectionType(163 /* UnionType */, parseIntersectionTypeOrHigher, 48 /* BarToken */); } function isStartOfFunctionType() { - if (token() === 25 /* LessThanToken */) { + if (token() === 26 /* LessThanToken */) { return true; } - return token() === 17 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); + return token() === 18 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); } function skipParameterStart() { if (ts.isModifierKind(token())) { // Skip modifiers parseModifiers(); } - if (isIdentifier() || token() === 97 /* ThisKeyword */) { + if (isIdentifier() || token() === 98 /* ThisKeyword */) { nextToken(); return true; } - if (token() === 19 /* OpenBracketToken */ || token() === 15 /* OpenBraceToken */) { + if (token() === 20 /* OpenBracketToken */ || token() === 16 /* OpenBraceToken */) { // Return true if we can parse an array or object binding pattern with no errors var previousErrorCount = parseDiagnostics.length; parseIdentifierOrPattern(); @@ -15104,7 +15158,7 @@ var ts; } function isUnambiguouslyStartOfFunctionType() { nextToken(); - if (token() === 18 /* CloseParenToken */ || token() === 22 /* DotDotDotToken */) { + if (token() === 19 /* CloseParenToken */ || token() === 23 /* DotDotDotToken */) { // ( ) // ( ... return true; @@ -15112,17 +15166,17 @@ var ts; if (skipParameterStart()) { // We successfully skipped modifiers (if any) and an identifier or binding pattern, // now see if we have something that indicates a parameter declaration - if (token() === 54 /* ColonToken */ || token() === 24 /* CommaToken */ || - token() === 53 /* QuestionToken */ || token() === 56 /* EqualsToken */) { + if (token() === 55 /* ColonToken */ || token() === 25 /* CommaToken */ || + token() === 54 /* QuestionToken */ || token() === 57 /* EqualsToken */) { // ( xxx : // ( xxx , // ( xxx ? // ( xxx = return true; } - if (token() === 18 /* CloseParenToken */) { + if (token() === 19 /* CloseParenToken */) { nextToken(); - if (token() === 34 /* EqualsGreaterThanToken */) { + if (token() === 35 /* EqualsGreaterThanToken */) { // ( xxx ) => return true; } @@ -15134,7 +15188,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(154 /* TypePredicate */, typePredicateVariable.pos); + var node = createNode(155 /* TypePredicate */, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -15145,7 +15199,7 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 124 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 125 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } @@ -15157,37 +15211,37 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(156 /* FunctionType */); + return parseFunctionOrConstructorType(157 /* FunctionType */); } - if (token() === 92 /* NewKeyword */) { - return parseFunctionOrConstructorType(157 /* ConstructorType */); + if (token() === 93 /* NewKeyword */) { + return parseFunctionOrConstructorType(158 /* ConstructorType */); } return parseUnionTypeOrHigher(); } function parseTypeAnnotation() { - return parseOptional(54 /* ColonToken */) ? parseType() : undefined; + return parseOptional(55 /* ColonToken */) ? parseType() : undefined; } // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token()) { - case 97 /* ThisKeyword */: - case 95 /* SuperKeyword */: - case 93 /* NullKeyword */: - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: + case 98 /* ThisKeyword */: + case 96 /* SuperKeyword */: + case 94 /* NullKeyword */: + case 100 /* TrueKeyword */: + case 85 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: - case 11 /* NoSubstitutionTemplateLiteral */: - case 12 /* TemplateHead */: - case 17 /* OpenParenToken */: - case 19 /* OpenBracketToken */: - case 15 /* OpenBraceToken */: - case 87 /* FunctionKeyword */: - case 73 /* ClassKeyword */: - case 92 /* NewKeyword */: - case 39 /* SlashToken */: - case 61 /* SlashEqualsToken */: - case 69 /* Identifier */: + case 12 /* NoSubstitutionTemplateLiteral */: + case 13 /* TemplateHead */: + case 18 /* OpenParenToken */: + case 20 /* OpenBracketToken */: + case 16 /* OpenBraceToken */: + case 88 /* FunctionKeyword */: + case 74 /* ClassKeyword */: + case 93 /* NewKeyword */: + case 40 /* SlashToken */: + case 62 /* SlashEqualsToken */: + case 70 /* Identifier */: return true; default: return isIdentifier(); @@ -15198,18 +15252,18 @@ var ts; return true; } switch (token()) { - case 35 /* PlusToken */: - case 36 /* MinusToken */: - 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 119 /* AwaitKeyword */: - case 114 /* YieldKeyword */: + case 36 /* PlusToken */: + case 37 /* MinusToken */: + case 51 /* TildeToken */: + case 50 /* ExclamationToken */: + case 79 /* DeleteKeyword */: + case 102 /* TypeOfKeyword */: + case 104 /* VoidKeyword */: + case 42 /* PlusPlusToken */: + case 43 /* MinusMinusToken */: + case 26 /* LessThanToken */: + case 120 /* AwaitKeyword */: + case 115 /* 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. @@ -15227,10 +15281,10 @@ var ts; } function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. - return token() !== 15 /* OpenBraceToken */ && - token() !== 87 /* FunctionKeyword */ && - token() !== 73 /* ClassKeyword */ && - token() !== 55 /* AtToken */ && + return token() !== 16 /* OpenBraceToken */ && + token() !== 88 /* FunctionKeyword */ && + token() !== 74 /* ClassKeyword */ && + token() !== 56 /* AtToken */ && isStartOfExpression(); } function parseExpression() { @@ -15244,7 +15298,7 @@ var ts; } var expr = parseAssignmentExpressionOrHigher(); var operatorToken; - while ((operatorToken = parseOptionalToken(24 /* CommaToken */))) { + while ((operatorToken = parseOptionalToken(25 /* CommaToken */))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); } if (saveDecoratorContext) { @@ -15253,7 +15307,7 @@ var ts; return expr; } function parseInitializer(inParameter) { - if (token() !== 56 /* EqualsToken */) { + if (token() !== 57 /* 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. @@ -15262,7 +15316,7 @@ var ts; // it's more likely that a { would be a allowed (as an object literal). While this // is also allowed for parameters, the risk is that we consume the { as an object // literal when it really will be for the block following the parameter. - if (scanner.hasPrecedingLineBreak() || (inParameter && token() === 15 /* OpenBraceToken */) || !isStartOfExpression()) { + if (scanner.hasPrecedingLineBreak() || (inParameter && token() === 16 /* OpenBraceToken */) || !isStartOfExpression()) { // preceding line break, open brace in a parameter (likely a function body) or current token is not an expression - // do not try to parse initializer return undefined; @@ -15270,7 +15324,7 @@ var ts; } // Initializer[In, Yield] : // = AssignmentExpression[?In, ?Yield] - parseExpected(56 /* EqualsToken */); + parseExpected(57 /* EqualsToken */); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { @@ -15316,7 +15370,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 === 69 /* Identifier */ && token() === 34 /* EqualsGreaterThanToken */) { + if (expr.kind === 70 /* Identifier */ && token() === 35 /* EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(expr); } // Now see if we might be in cases '2' or '3'. @@ -15332,7 +15386,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token() === 114 /* YieldKeyword */) { + if (token() === 115 /* YieldKeyword */) { // If we have a 'yield' keyword, and this is a context where yield expressions are // allowed, then definitely parse out a yield expression. if (inYieldContext()) { @@ -15361,15 +15415,15 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(190 /* YieldExpression */); + var node = createNode(191 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] // yield [no LineTerminator here] * [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token() === 37 /* AsteriskToken */ || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); + (token() === 38 /* AsteriskToken */ || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(38 /* AsteriskToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -15380,21 +15434,21 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier, asyncModifier) { - ts.Debug.assert(token() === 34 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + ts.Debug.assert(token() === 35 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(180 /* ArrowFunction */, asyncModifier.pos); + node = createNode(181 /* ArrowFunction */, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(180 /* ArrowFunction */, identifier.pos); + node = createNode(181 /* ArrowFunction */, identifier.pos); } - var parameter = createNode(142 /* Parameter */, identifier.pos); + var parameter = createNode(143 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos); node.parameters.end = parameter.end; - node.equalsGreaterThanToken = parseExpectedToken(34 /* EqualsGreaterThanToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, "=>"); + node.equalsGreaterThanToken = parseExpectedToken(35 /* EqualsGreaterThanToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, "=>"); node.body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier); return addJSDocComment(finishNode(node)); } @@ -15419,8 +15473,8 @@ var ts; // If we have an arrow, then try to parse the body. Even if not, try to parse if we // have an opening brace, just in case we're in an error state. var lastToken = token(); - arrowFunction.equalsGreaterThanToken = parseExpectedToken(34 /* EqualsGreaterThanToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, "=>"); - arrowFunction.body = (lastToken === 34 /* EqualsGreaterThanToken */ || lastToken === 15 /* OpenBraceToken */) + arrowFunction.equalsGreaterThanToken = parseExpectedToken(35 /* EqualsGreaterThanToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, "=>"); + arrowFunction.body = (lastToken === 35 /* EqualsGreaterThanToken */ || lastToken === 16 /* OpenBraceToken */) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return addJSDocComment(finishNode(arrowFunction)); @@ -15430,10 +15484,10 @@ 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() === 118 /* AsyncKeyword */) { + if (token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */ || token() === 119 /* AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token() === 34 /* EqualsGreaterThanToken */) { + if (token() === 35 /* EqualsGreaterThanToken */) { // ERROR RECOVERY TWEAK: // If we see a standalone => try to parse it as an arrow function expression as that's // likely what the user intended to write. @@ -15443,28 +15497,28 @@ var ts; return 0 /* False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 118 /* AsyncKeyword */) { + if (token() === 119 /* AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0 /* False */; } - if (token() !== 17 /* OpenParenToken */ && token() !== 25 /* LessThanToken */) { + if (token() !== 18 /* OpenParenToken */ && token() !== 26 /* LessThanToken */) { return 0 /* False */; } } var first = token(); var second = nextToken(); - if (first === 17 /* OpenParenToken */) { - if (second === 18 /* CloseParenToken */) { + if (first === 18 /* OpenParenToken */) { + if (second === 19 /* CloseParenToken */) { // Simple cases: "() =>", "(): ", and "() {". // This is an arrow function with no parameters. // The last one is not actually an arrow function, // but this is probably what the user intended. var third = nextToken(); switch (third) { - case 34 /* EqualsGreaterThanToken */: - case 54 /* ColonToken */: - case 15 /* OpenBraceToken */: + case 35 /* EqualsGreaterThanToken */: + case 55 /* ColonToken */: + case 16 /* OpenBraceToken */: return 1 /* True */; default: return 0 /* False */; @@ -15476,12 +15530,12 @@ var ts; // ({ x }) => { } // ([ x ]) // ({ x }) - if (second === 19 /* OpenBracketToken */ || second === 15 /* OpenBraceToken */) { + if (second === 20 /* OpenBracketToken */ || second === 16 /* OpenBraceToken */) { return 2 /* Unknown */; } // Simple case: "(..." // This is an arrow function with a rest parameter. - if (second === 22 /* DotDotDotToken */) { + if (second === 23 /* DotDotDotToken */) { return 1 /* True */; } // If we had "(" followed by something that's not an identifier, @@ -15494,7 +15548,7 @@ var ts; } // If we have something like "(a:", then we must have a // type-annotated parameter in an arrow function expression. - if (nextToken() === 54 /* ColonToken */) { + if (nextToken() === 55 /* ColonToken */) { return 1 /* True */; } // This *could* be a parenthesized arrow function. @@ -15502,7 +15556,7 @@ var ts; return 2 /* Unknown */; } else { - ts.Debug.assert(first === 25 /* LessThanToken */); + ts.Debug.assert(first === 26 /* LessThanToken */); // If we have "<" not followed by an identifier, // then this definitely is not an arrow function. if (!isIdentifier()) { @@ -15512,17 +15566,17 @@ var ts; if (sourceFile.languageVariant === 1 /* JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 83 /* ExtendsKeyword */) { + if (third === 84 /* ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 56 /* EqualsToken */: - case 27 /* GreaterThanToken */: + case 57 /* EqualsToken */: + case 28 /* GreaterThanToken */: return false; default: return true; } } - else if (third === 24 /* CommaToken */) { + else if (third === 25 /* CommaToken */) { return true; } return false; @@ -15541,7 +15595,7 @@ var ts; } function tryParseAsyncSimpleArrowFunctionExpression() { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" - if (token() === 118 /* AsyncKeyword */) { + if (token() === 119 /* AsyncKeyword */) { var isUnParenthesizedAsyncArrowFunction = lookAhead(isUnParenthesizedAsyncArrowFunctionWorker); if (isUnParenthesizedAsyncArrowFunction === 1 /* True */) { var asyncModifier = parseModifiersForArrowFunction(); @@ -15555,23 +15609,23 @@ var ts; // AsyncArrowFunctionExpression: // 1) async[no LineTerminator here]AsyncArrowBindingIdentifier[?Yield][no LineTerminator here]=>AsyncConciseBody[?In] // 2) CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await][no LineTerminator here]=>AsyncConciseBody[?In] - if (token() === 118 /* AsyncKeyword */) { + if (token() === 119 /* AsyncKeyword */) { nextToken(); // If the "async" is followed by "=>" token then it is not a begining of an async arrow-function // but instead a simple arrow-function which will be parsed inside "parseAssignmentExpressionOrHigher" - if (scanner.hasPrecedingLineBreak() || token() === 34 /* EqualsGreaterThanToken */) { + if (scanner.hasPrecedingLineBreak() || token() === 35 /* EqualsGreaterThanToken */) { return 0 /* False */; } // Check for un-parenthesized AsyncArrowFunction var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 69 /* Identifier */ && token() === 34 /* EqualsGreaterThanToken */) { + if (!scanner.hasPrecedingLineBreak() && expr.kind === 70 /* Identifier */ && token() === 35 /* EqualsGreaterThanToken */) { return 1 /* True */; } } return 0 /* False */; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(180 /* ArrowFunction */); + var node = createNode(181 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); var isAsync = !!(ts.getModifierFlags(node) & 256 /* Async */); // Arrow functions are never generators. @@ -15581,7 +15635,7 @@ var ts; // a => (b => c) // And think that "(b =>" was actually a parenthesized arrow function with a missing // close paren. - fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ !allowAmbiguity, node); + fillSignature(55 /* 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; @@ -15594,19 +15648,19 @@ var ts; // - "a ? (b): c" will have "(b):" parsed as a signature with a return type annotation. // // So we need just a bit of lookahead to ensure that it can only be a signature. - if (!allowAmbiguity && token() !== 34 /* EqualsGreaterThanToken */ && token() !== 15 /* OpenBraceToken */) { + if (!allowAmbiguity && token() !== 35 /* EqualsGreaterThanToken */ && token() !== 16 /* OpenBraceToken */) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } return node; } function parseArrowFunctionExpressionBody(isAsync) { - if (token() === 15 /* OpenBraceToken */) { + if (token() === 16 /* OpenBraceToken */) { return parseFunctionBlock(/*allowYield*/ false, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); } - if (token() !== 23 /* SemicolonToken */ && - token() !== 87 /* FunctionKeyword */ && - token() !== 73 /* ClassKeyword */ && + if (token() !== 24 /* SemicolonToken */ && + token() !== 88 /* FunctionKeyword */ && + token() !== 74 /* ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -15631,17 +15685,17 @@ var ts; } function parseConditionalExpressionRest(leftOperand) { // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - var questionToken = parseOptionalToken(53 /* QuestionToken */); + var questionToken = parseOptionalToken(54 /* 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(188 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(189 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(54 /* ColonToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(54 /* ColonToken */)); + node.colonToken = parseExpectedToken(55 /* ColonToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(55 /* ColonToken */)); node.whenFalse = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -15650,7 +15704,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 90 /* InKeyword */ || t === 138 /* OfKeyword */; + return t === 91 /* InKeyword */ || t === 139 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -15679,16 +15733,16 @@ var ts; // ^^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 */ ? + var consumeCurrentOperator = token() === 39 /* AsteriskAsteriskToken */ ? newPrecedence >= precedence : newPrecedence > precedence; if (!consumeCurrentOperator) { break; } - if (token() === 90 /* InKeyword */ && inDisallowInContext()) { + if (token() === 91 /* InKeyword */ && inDisallowInContext()) { break; } - if (token() === 116 /* AsKeyword */) { + if (token() === 117 /* AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -15709,48 +15763,48 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 90 /* InKeyword */) { + if (inDisallowInContext() && token() === 91 /* InKeyword */) { return false; } return getBinaryOperatorPrecedence() > 0; } function getBinaryOperatorPrecedence() { switch (token()) { - case 52 /* BarBarToken */: + case 53 /* BarBarToken */: return 1; - case 51 /* AmpersandAmpersandToken */: + case 52 /* AmpersandAmpersandToken */: return 2; - case 47 /* BarToken */: + case 48 /* BarToken */: return 3; - case 48 /* CaretToken */: + case 49 /* CaretToken */: return 4; - case 46 /* AmpersandToken */: + case 47 /* AmpersandToken */: return 5; - case 30 /* EqualsEqualsToken */: - case 31 /* ExclamationEqualsToken */: - case 32 /* EqualsEqualsEqualsToken */: - case 33 /* ExclamationEqualsEqualsToken */: + case 31 /* EqualsEqualsToken */: + case 32 /* ExclamationEqualsToken */: + case 33 /* EqualsEqualsEqualsToken */: + case 34 /* ExclamationEqualsEqualsToken */: return 6; - case 25 /* LessThanToken */: - case 27 /* GreaterThanToken */: - case 28 /* LessThanEqualsToken */: - case 29 /* GreaterThanEqualsToken */: - case 91 /* InstanceOfKeyword */: - case 90 /* InKeyword */: - case 116 /* AsKeyword */: + case 26 /* LessThanToken */: + case 28 /* GreaterThanToken */: + case 29 /* LessThanEqualsToken */: + case 30 /* GreaterThanEqualsToken */: + case 92 /* InstanceOfKeyword */: + case 91 /* InKeyword */: + case 117 /* AsKeyword */: return 7; - case 43 /* LessThanLessThanToken */: - case 44 /* GreaterThanGreaterThanToken */: - case 45 /* GreaterThanGreaterThanGreaterThanToken */: + case 44 /* LessThanLessThanToken */: + case 45 /* GreaterThanGreaterThanToken */: + case 46 /* GreaterThanGreaterThanGreaterThanToken */: return 8; - case 35 /* PlusToken */: - case 36 /* MinusToken */: + case 36 /* PlusToken */: + case 37 /* MinusToken */: return 9; - case 37 /* AsteriskToken */: - case 39 /* SlashToken */: - case 40 /* PercentToken */: + case 38 /* AsteriskToken */: + case 40 /* SlashToken */: + case 41 /* PercentToken */: return 10; - case 38 /* AsteriskAsteriskToken */: + case 39 /* AsteriskAsteriskToken */: return 11; } // -1 is lower than all other precedences. Returning it will cause binary expression @@ -15758,45 +15812,45 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(187 /* BinaryExpression */, left.pos); + var node = createNode(188 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(195 /* AsExpression */, left.pos); + var node = createNode(196 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(185 /* PrefixUnaryExpression */); + var node = createNode(186 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(181 /* DeleteExpression */); + var node = createNode(182 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(182 /* TypeOfExpression */); + var node = createNode(183 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(183 /* VoidExpression */); + var node = createNode(184 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function isAwaitExpression() { - if (token() === 119 /* AwaitKeyword */) { + if (token() === 120 /* AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -15806,7 +15860,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(184 /* AwaitExpression */); + var node = createNode(185 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -15830,7 +15884,7 @@ var ts; */ if (isUpdateExpression()) { var incrementExpression = parseIncrementExpression(); - return token() === 38 /* AsteriskAsteriskToken */ ? + return token() === 39 /* AsteriskAsteriskToken */ ? parseBinaryExpressionRest(getBinaryOperatorPrecedence(), incrementExpression) : incrementExpression; } @@ -15847,9 +15901,9 @@ var ts; */ var unaryOperator = token(); var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token() === 38 /* AsteriskAsteriskToken */) { + if (token() === 39 /* AsteriskAsteriskToken */) { var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); - if (simpleUnaryExpression.kind === 177 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 178 /* 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 { @@ -15874,23 +15928,23 @@ var ts; */ function parseSimpleUnaryExpression() { switch (token()) { - case 35 /* PlusToken */: - case 36 /* MinusToken */: - case 50 /* TildeToken */: - case 49 /* ExclamationToken */: + case 36 /* PlusToken */: + case 37 /* MinusToken */: + case 51 /* TildeToken */: + case 50 /* ExclamationToken */: return parsePrefixUnaryExpression(); - case 78 /* DeleteKeyword */: + case 79 /* DeleteKeyword */: return parseDeleteExpression(); - case 101 /* TypeOfKeyword */: + case 102 /* TypeOfKeyword */: return parseTypeOfExpression(); - case 103 /* VoidKeyword */: + case 104 /* VoidKeyword */: return parseVoidExpression(); - case 25 /* LessThanToken */: + case 26 /* LessThanToken */: // This is modified UnaryExpression grammar in TypeScript // UnaryExpression (modified): // < type > UnaryExpression return parseTypeAssertion(); - case 119 /* AwaitKeyword */: + case 120 /* AwaitKeyword */: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -15912,16 +15966,16 @@ var ts; // This function is called inside parseUnaryExpression to decide // whether to call parseSimpleUnaryExpression or call parseIncrementExpression directly switch (token()) { - case 35 /* PlusToken */: - case 36 /* MinusToken */: - case 50 /* TildeToken */: - case 49 /* ExclamationToken */: - case 78 /* DeleteKeyword */: - case 101 /* TypeOfKeyword */: - case 103 /* VoidKeyword */: - case 119 /* AwaitKeyword */: + case 36 /* PlusToken */: + case 37 /* MinusToken */: + case 51 /* TildeToken */: + case 50 /* ExclamationToken */: + case 79 /* DeleteKeyword */: + case 102 /* TypeOfKeyword */: + case 104 /* VoidKeyword */: + case 120 /* AwaitKeyword */: return false; - case 25 /* LessThanToken */: + case 26 /* LessThanToken */: // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression if (sourceFile.languageVariant !== 1 /* JSX */) { return false; @@ -15944,21 +15998,21 @@ var ts; * 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(185 /* PrefixUnaryExpression */); + if (token() === 42 /* PlusPlusToken */ || token() === 43 /* MinusMinusToken */) { + var node = createNode(186 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); return finishNode(node); } - else if (sourceFile.languageVariant === 1 /* JSX */ && token() === 25 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeyword)) { + else if (sourceFile.languageVariant === 1 /* JSX */ && token() === 26 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeyword)) { // JSXElement is part of primaryExpression return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token() === 41 /* PlusPlusToken */ || token() === 42 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(186 /* PostfixUnaryExpression */, expression.pos); + if ((token() === 42 /* PlusPlusToken */ || token() === 43 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(187 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -15997,7 +16051,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() === 95 /* SuperKeyword */ + var expression = token() === 96 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); // Now, we *may* be complete. However, we might have consumed the start of a @@ -16057,14 +16111,14 @@ var ts; } function parseSuperExpression() { var expression = parseTokenNode(); - if (token() === 17 /* OpenParenToken */ || token() === 21 /* DotToken */ || token() === 19 /* OpenBracketToken */) { + if (token() === 18 /* OpenParenToken */ || token() === 22 /* DotToken */ || token() === 20 /* OpenBracketToken */) { return expression; } // 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(172 /* PropertyAccessExpression */, expression.pos); + var node = createNode(173 /* PropertyAccessExpression */, expression.pos); node.expression = expression; - parseExpectedToken(21 /* DotToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + parseExpectedToken(22 /* DotToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); return finishNode(node); } @@ -16072,10 +16126,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 69 /* Identifier */) { + if (lhs.kind === 70 /* Identifier */) { return lhs.text === rhs.text; } - if (lhs.kind === 97 /* ThisKeyword */) { + if (lhs.kind === 98 /* ThisKeyword */) { return true; } // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only @@ -16087,8 +16141,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 243 /* JsxOpeningElement */) { - var node = createNode(241 /* JsxElement */, opening.pos); + if (opening.kind === 244 /* JsxOpeningElement */) { + var node = createNode(242 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -16098,7 +16152,7 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 242 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 243 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -16109,15 +16163,15 @@ var ts; // does less damage and we can report a better error. // Since JSX elements are invalid < operands anyway, this lookahead parse will only occur in error scenarios // of one sort or another. - if (inExpressionContext && token() === 25 /* LessThanToken */) { + if (inExpressionContext && token() === 26 /* LessThanToken */) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(187 /* BinaryExpression */, result.pos); + var badNode = createNode(188 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; - badNode.operatorToken = createMissingNode(24 /* CommaToken */, /*reportAtCurrentPosition*/ false, /*diagnosticMessage*/ undefined); + badNode.operatorToken = createMissingNode(25 /* CommaToken */, /*reportAtCurrentPosition*/ false, /*diagnosticMessage*/ undefined); badNode.operatorToken.pos = badNode.operatorToken.end = badNode.right.pos; return badNode; } @@ -16125,17 +16179,17 @@ var ts; return result; } function parseJsxText() { - var node = createNode(244 /* JsxText */, scanner.getStartPos()); + var node = createNode(10 /* JsxText */, scanner.getStartPos()); currentToken = scanner.scanJsxToken(); return finishNode(node); } function parseJsxChild() { switch (token()) { - case 244 /* JsxText */: + case 10 /* JsxText */: return parseJsxText(); - case 15 /* OpenBraceToken */: + case 16 /* OpenBraceToken */: return parseJsxExpression(/*inExpressionContext*/ false); - case 25 /* LessThanToken */: + case 26 /* LessThanToken */: return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ false); } ts.Debug.fail("Unknown JSX child kind " + token()); @@ -16146,7 +16200,7 @@ var ts; parsingContext |= 1 << 14 /* JsxChildren */; while (true) { currentToken = scanner.reScanJsxToken(); - if (token() === 26 /* LessThanSlashToken */) { + if (token() === 27 /* LessThanSlashToken */) { // Closing tag break; } @@ -16164,27 +16218,27 @@ var ts; } function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { var fullStart = scanner.getStartPos(); - parseExpected(25 /* LessThanToken */); + parseExpected(26 /* LessThanToken */); var tagName = parseJsxElementName(); var attributes = parseList(13 /* JsxAttributes */, parseJsxAttribute); var node; - if (token() === 27 /* GreaterThanToken */) { + if (token() === 28 /* GreaterThanToken */) { // 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(243 /* JsxOpeningElement */, fullStart); + node = createNode(244 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { - parseExpected(39 /* SlashToken */); + parseExpected(40 /* SlashToken */); if (inExpressionContext) { - parseExpected(27 /* GreaterThanToken */); + parseExpected(28 /* GreaterThanToken */); } else { - parseExpected(27 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(28 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(242 /* JsxSelfClosingElement */, fullStart); + node = createNode(243 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -16197,10 +16251,10 @@ var ts; // primaryExpression in the form of an identifier and "this" keyword // We can't just simply use parseLeftHandSideExpressionOrHigher because then we will start consider class,function etc as a keyword // We only want to consider "this" as a primaryExpression - var expression = token() === 97 /* ThisKeyword */ ? + var expression = token() === 98 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); - while (parseOptional(21 /* DotToken */)) { - var propertyAccess = createNode(172 /* PropertyAccessExpression */, expression.pos); + while (parseOptional(22 /* DotToken */)) { + var propertyAccess = createNode(173 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -16209,27 +16263,27 @@ var ts; } function parseJsxExpression(inExpressionContext) { var node = createNode(248 /* JsxExpression */); - parseExpected(15 /* OpenBraceToken */); - if (token() !== 16 /* CloseBraceToken */) { + parseExpected(16 /* OpenBraceToken */); + if (token() !== 17 /* CloseBraceToken */) { node.expression = parseAssignmentExpressionOrHigher(); } if (inExpressionContext) { - parseExpected(16 /* CloseBraceToken */); + parseExpected(17 /* CloseBraceToken */); } else { - parseExpected(16 /* CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false); + parseExpected(17 /* CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseJsxAttribute() { - if (token() === 15 /* OpenBraceToken */) { + if (token() === 16 /* OpenBraceToken */) { return parseJsxSpreadAttribute(); } scanJsxIdentifier(); var node = createNode(246 /* JsxAttribute */); node.name = parseIdentifierName(); - if (token() === 56 /* EqualsToken */) { + if (token() === 57 /* EqualsToken */) { switch (scanJsxAttributeValue()) { case 9 /* StringLiteral */: node.initializer = parseLiteralNode(); @@ -16243,71 +16297,71 @@ var ts; } function parseJsxSpreadAttribute() { var node = createNode(247 /* JsxSpreadAttribute */); - parseExpected(15 /* OpenBraceToken */); - parseExpected(22 /* DotDotDotToken */); + parseExpected(16 /* OpenBraceToken */); + parseExpected(23 /* DotDotDotToken */); node.expression = parseExpression(); - parseExpected(16 /* CloseBraceToken */); + parseExpected(17 /* CloseBraceToken */); return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { var node = createNode(245 /* JsxClosingElement */); - parseExpected(26 /* LessThanSlashToken */); + parseExpected(27 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { - parseExpected(27 /* GreaterThanToken */); + parseExpected(28 /* GreaterThanToken */); } else { - parseExpected(27 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(28 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseTypeAssertion() { - var node = createNode(177 /* TypeAssertionExpression */); - parseExpected(25 /* LessThanToken */); + var node = createNode(178 /* TypeAssertionExpression */); + parseExpected(26 /* LessThanToken */); node.type = parseType(); - parseExpected(27 /* GreaterThanToken */); + parseExpected(28 /* GreaterThanToken */); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseMemberExpressionRest(expression) { while (true) { - var dotToken = parseOptionalToken(21 /* DotToken */); + var dotToken = parseOptionalToken(22 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(172 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(173 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); continue; } - if (token() === 49 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 50 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(196 /* NonNullExpression */, expression.pos); + var nonNullExpression = createNode(197 /* NonNullExpression */, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } // 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(173 /* ElementAccessExpression */, expression.pos); + if (!inDecoratorContext() && parseOptional(20 /* OpenBracketToken */)) { + var indexedAccess = createNode(174 /* 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. - if (token() !== 20 /* CloseBracketToken */) { + if (token() !== 21 /* CloseBracketToken */) { indexedAccess.argumentExpression = allowInAnd(parseExpression); if (indexedAccess.argumentExpression.kind === 9 /* StringLiteral */ || indexedAccess.argumentExpression.kind === 8 /* NumericLiteral */) { var literal = indexedAccess.argumentExpression; literal.text = internIdentifier(literal.text); } } - parseExpected(20 /* CloseBracketToken */); + parseExpected(21 /* CloseBracketToken */); expression = finishNode(indexedAccess); continue; } - if (token() === 11 /* NoSubstitutionTemplateLiteral */ || token() === 12 /* TemplateHead */) { - var tagExpression = createNode(176 /* TaggedTemplateExpression */, expression.pos); + if (token() === 12 /* NoSubstitutionTemplateLiteral */ || token() === 13 /* TemplateHead */) { + var tagExpression = createNode(177 /* TaggedTemplateExpression */, expression.pos); tagExpression.tag = expression; - tagExpression.template = token() === 11 /* NoSubstitutionTemplateLiteral */ + tagExpression.template = token() === 12 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() : parseTemplateExpression(); expression = finishNode(tagExpression); @@ -16319,7 +16373,7 @@ var ts; function parseCallExpressionRest(expression) { while (true) { expression = parseMemberExpressionRest(expression); - if (token() === 25 /* LessThanToken */) { + if (token() === 26 /* LessThanToken */) { // See if this is the start of a generic invocation. If so, consume it and // keep checking for postfix expressions. Otherwise, it's just a '<' that's // part of an arithmetic expression. Break out so we consume it higher in the @@ -16328,15 +16382,15 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(174 /* CallExpression */, expression.pos); + var callExpr = createNode(175 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); continue; } - else if (token() === 17 /* OpenParenToken */) { - var callExpr = createNode(174 /* CallExpression */, expression.pos); + else if (token() === 18 /* OpenParenToken */) { + var callExpr = createNode(175 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -16346,17 +16400,17 @@ var ts; } } function parseArgumentList() { - parseExpected(17 /* OpenParenToken */); + parseExpected(18 /* OpenParenToken */); var result = parseDelimitedList(11 /* ArgumentExpressions */, parseArgumentExpression); - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); return result; } function parseTypeArgumentsInExpression() { - if (!parseOptional(25 /* LessThanToken */)) { + if (!parseOptional(26 /* LessThanToken */)) { return undefined; } var typeArguments = parseDelimitedList(18 /* TypeArguments */, parseType); - if (!parseExpected(27 /* GreaterThanToken */)) { + if (!parseExpected(28 /* GreaterThanToken */)) { // If it doesn't have the closing > then it's definitely not an type argument list. return undefined; } @@ -16368,32 +16422,32 @@ var ts; } function canFollowTypeArgumentsInExpression() { switch (token()) { - case 17 /* OpenParenToken */: // foo( + case 18 /* OpenParenToken */: // foo( // this case are the only case where this token can legally follow a type argument // list. So we definitely want to treat this as a type arg list. - case 21 /* DotToken */: // foo. - case 18 /* CloseParenToken */: // foo) - case 20 /* CloseBracketToken */: // foo] - case 54 /* ColonToken */: // foo: - case 23 /* SemicolonToken */: // foo; - case 53 /* QuestionToken */: // foo? - case 30 /* EqualsEqualsToken */: // foo == - case 32 /* EqualsEqualsEqualsToken */: // foo === - case 31 /* ExclamationEqualsToken */: // foo != - case 33 /* ExclamationEqualsEqualsToken */: // 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 22 /* DotToken */: // foo. + case 19 /* CloseParenToken */: // foo) + case 21 /* CloseBracketToken */: // foo] + case 55 /* ColonToken */: // foo: + case 24 /* SemicolonToken */: // foo; + case 54 /* QuestionToken */: // foo? + case 31 /* EqualsEqualsToken */: // foo == + case 33 /* EqualsEqualsEqualsToken */: // foo === + case 32 /* ExclamationEqualsToken */: // foo != + case 34 /* ExclamationEqualsEqualsToken */: // foo !== + case 52 /* AmpersandAmpersandToken */: // foo && + case 53 /* BarBarToken */: // foo || + case 49 /* CaretToken */: // foo ^ + case 47 /* AmpersandToken */: // foo & + case 48 /* BarToken */: // foo | + case 17 /* CloseBraceToken */: // foo } case 1 /* EndOfFileToken */: // these cases can't legally follow a type arg list. However, they're not legal // expressions either. The user is probably in the middle of a generic type. So // treat it as such. return true; - case 24 /* CommaToken */: // foo, - case 15 /* OpenBraceToken */: // foo { + case 25 /* CommaToken */: // foo, + case 16 /* OpenBraceToken */: // foo { // We don't want to treat these as type arguments. Otherwise we'll parse this // as an invocation expression. Instead, we want to parse out the expression // in isolation from the type arguments. @@ -16406,21 +16460,21 @@ var ts; switch (token()) { case 8 /* NumericLiteral */: case 9 /* StringLiteral */: - case 11 /* NoSubstitutionTemplateLiteral */: + case 12 /* NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 97 /* ThisKeyword */: - case 95 /* SuperKeyword */: - case 93 /* NullKeyword */: - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: + case 98 /* ThisKeyword */: + case 96 /* SuperKeyword */: + case 94 /* NullKeyword */: + case 100 /* TrueKeyword */: + case 85 /* FalseKeyword */: return parseTokenNode(); - case 17 /* OpenParenToken */: + case 18 /* OpenParenToken */: return parseParenthesizedExpression(); - case 19 /* OpenBracketToken */: + case 20 /* OpenBracketToken */: return parseArrayLiteralExpression(); - case 15 /* OpenBraceToken */: + case 16 /* OpenBraceToken */: return parseObjectLiteralExpression(); - case 118 /* AsyncKeyword */: + case 119 /* 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. @@ -16428,60 +16482,60 @@ var ts; break; } return parseFunctionExpression(); - case 73 /* ClassKeyword */: + case 74 /* ClassKeyword */: return parseClassExpression(); - case 87 /* FunctionKeyword */: + case 88 /* FunctionKeyword */: return parseFunctionExpression(); - case 92 /* NewKeyword */: + case 93 /* NewKeyword */: return parseNewExpression(); - case 39 /* SlashToken */: - case 61 /* SlashEqualsToken */: - if (reScanSlashToken() === 10 /* RegularExpressionLiteral */) { + case 40 /* SlashToken */: + case 62 /* SlashEqualsToken */: + if (reScanSlashToken() === 11 /* RegularExpressionLiteral */) { return parseLiteralNode(); } break; - case 12 /* TemplateHead */: + case 13 /* TemplateHead */: return parseTemplateExpression(); } return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(178 /* ParenthesizedExpression */); - parseExpected(17 /* OpenParenToken */); + var node = createNode(179 /* ParenthesizedExpression */); + parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(191 /* SpreadElementExpression */); - parseExpected(22 /* DotDotDotToken */); + var node = createNode(192 /* SpreadElementExpression */); + parseExpected(23 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { - return token() === 22 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 24 /* CommaToken */ ? createNode(193 /* OmittedExpression */) : + return token() === 23 /* DotDotDotToken */ ? parseSpreadElement() : + token() === 25 /* CommaToken */ ? createNode(194 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(170 /* ArrayLiteralExpression */); - parseExpected(19 /* OpenBracketToken */); + var node = createNode(171 /* ArrayLiteralExpression */); + parseExpected(20 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); - parseExpected(20 /* CloseBracketToken */); + parseExpected(21 /* CloseBracketToken */); return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { - if (parseContextualModifier(123 /* GetKeyword */)) { - return parseAccessorDeclaration(149 /* GetAccessor */, fullStart, decorators, modifiers); + if (parseContextualModifier(124 /* GetKeyword */)) { + return parseAccessorDeclaration(150 /* GetAccessor */, fullStart, decorators, modifiers); } - else if (parseContextualModifier(131 /* SetKeyword */)) { - return parseAccessorDeclaration(150 /* SetAccessor */, fullStart, decorators, modifiers); + else if (parseContextualModifier(132 /* SetKeyword */)) { + return parseAccessorDeclaration(151 /* SetAccessor */, fullStart, decorators, modifiers); } return undefined; } @@ -16493,12 +16547,12 @@ var ts; if (accessor) { return accessor; } - var asteriskToken = parseOptionalToken(37 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(38 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); // Disallowing of optional property assignments happens in the grammar checker. - var questionToken = parseOptionalToken(53 /* QuestionToken */); - if (asteriskToken || token() === 17 /* OpenParenToken */ || token() === 25 /* LessThanToken */) { + var questionToken = parseOptionalToken(54 /* QuestionToken */); + if (asteriskToken || token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } // check if it is short-hand property assignment or normal property assignment @@ -16506,12 +16560,12 @@ var ts; // 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 */); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 25 /* CommaToken */ || token() === 17 /* CloseBraceToken */ || token() === 57 /* EqualsToken */); if (isShorthandPropertyAssignment) { var shorthandDeclaration = createNode(254 /* ShorthandPropertyAssignment */, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; - var equalsToken = parseOptionalToken(56 /* EqualsToken */); + var equalsToken = parseOptionalToken(57 /* EqualsToken */); if (equalsToken) { shorthandDeclaration.equalsToken = equalsToken; shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); @@ -16523,19 +16577,19 @@ var ts; propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; - parseExpected(54 /* ColonToken */); + parseExpected(55 /* ColonToken */); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); return addJSDocComment(finishNode(propertyAssignment)); } } function parseObjectLiteralExpression() { - var node = createNode(171 /* ObjectLiteralExpression */); - parseExpected(15 /* OpenBraceToken */); + var node = createNode(172 /* ObjectLiteralExpression */); + parseExpected(16 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true); - parseExpected(16 /* CloseBraceToken */); + parseExpected(17 /* CloseBraceToken */); return finishNode(node); } function parseFunctionExpression() { @@ -16548,10 +16602,10 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNode(179 /* FunctionExpression */); + var node = createNode(180 /* FunctionExpression */); node.modifiers = parseModifiers(); - parseExpected(87 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); + parseExpected(88 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(38 /* AsteriskToken */); var isGenerator = !!node.asteriskToken; var isAsync = !!(ts.getModifierFlags(node) & 256 /* Async */); node.name = @@ -16559,7 +16613,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); + fillSignature(55 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlock(/*allowYield*/ isGenerator, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); @@ -16570,24 +16624,24 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(175 /* NewExpression */); - parseExpected(92 /* NewKeyword */); + var node = createNode(176 /* NewExpression */); + parseExpected(93 /* NewKeyword */); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); - if (node.typeArguments || token() === 17 /* OpenParenToken */) { + if (node.typeArguments || token() === 18 /* OpenParenToken */) { node.arguments = parseArgumentList(); } return finishNode(node); } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(199 /* Block */); - if (parseExpected(15 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { + var node = createNode(200 /* Block */); + if (parseExpected(16 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(16 /* CloseBraceToken */); + parseExpected(17 /* CloseBraceToken */); } else { node.statements = createMissingList(); @@ -16614,51 +16668,51 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(201 /* EmptyStatement */); - parseExpected(23 /* SemicolonToken */); + var node = createNode(202 /* EmptyStatement */); + parseExpected(24 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(203 /* IfStatement */); - parseExpected(88 /* IfKeyword */); - parseExpected(17 /* OpenParenToken */); + var node = createNode(204 /* IfStatement */); + parseExpected(89 /* IfKeyword */); + parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(80 /* ElseKeyword */) ? parseStatement() : undefined; + node.elseStatement = parseOptional(81 /* ElseKeyword */) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(204 /* DoStatement */); - parseExpected(79 /* DoKeyword */); + var node = createNode(205 /* DoStatement */); + parseExpected(80 /* DoKeyword */); node.statement = parseStatement(); - parseExpected(104 /* WhileKeyword */); - parseExpected(17 /* OpenParenToken */); + parseExpected(105 /* WhileKeyword */); + parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); // From: https://mail.mozilla.org/pipermail/es-discuss/2011-August/016188.html // 157 min --- All allen at wirfs-brock.com CONF --- "do{;}while(false)false" prohibited in // spec but allowed in consensus reality. Approved -- this is the de-facto standard whereby // do;while(0)x will have a semicolon inserted before x. - parseOptional(23 /* SemicolonToken */); + parseOptional(24 /* SemicolonToken */); return finishNode(node); } function parseWhileStatement() { - var node = createNode(205 /* WhileStatement */); - parseExpected(104 /* WhileKeyword */); - parseExpected(17 /* OpenParenToken */); + var node = createNode(206 /* WhileStatement */); + parseExpected(105 /* WhileKeyword */); + parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); node.statement = parseStatement(); return finishNode(node); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(86 /* ForKeyword */); - parseExpected(17 /* OpenParenToken */); + parseExpected(87 /* ForKeyword */); + parseExpected(18 /* OpenParenToken */); var initializer = undefined; - if (token() !== 23 /* SemicolonToken */) { - if (token() === 102 /* VarKeyword */ || token() === 108 /* LetKeyword */ || token() === 74 /* ConstKeyword */) { + if (token() !== 24 /* SemicolonToken */) { + if (token() === 103 /* VarKeyword */ || token() === 109 /* LetKeyword */ || token() === 75 /* ConstKeyword */) { initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { @@ -16666,32 +16720,32 @@ var ts; } } var forOrForInOrForOfStatement; - if (parseOptional(90 /* InKeyword */)) { - var forInStatement = createNode(207 /* ForInStatement */, pos); + if (parseOptional(91 /* InKeyword */)) { + var forInStatement = createNode(208 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(138 /* OfKeyword */)) { - var forOfStatement = createNode(208 /* ForOfStatement */, pos); + else if (parseOptional(139 /* OfKeyword */)) { + var forOfStatement = createNode(209 /* ForOfStatement */, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(206 /* ForStatement */, pos); + var forStatement = createNode(207 /* ForStatement */, pos); forStatement.initializer = initializer; - parseExpected(23 /* SemicolonToken */); - if (token() !== 23 /* SemicolonToken */ && token() !== 18 /* CloseParenToken */) { + parseExpected(24 /* SemicolonToken */); + if (token() !== 24 /* SemicolonToken */ && token() !== 19 /* CloseParenToken */) { forStatement.condition = allowInAnd(parseExpression); } - parseExpected(23 /* SemicolonToken */); - if (token() !== 18 /* CloseParenToken */) { + parseExpected(24 /* SemicolonToken */); + if (token() !== 19 /* CloseParenToken */) { forStatement.incrementor = allowInAnd(parseExpression); } - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); forOrForInOrForOfStatement = forStatement; } forOrForInOrForOfStatement.statement = parseStatement(); @@ -16699,7 +16753,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 210 /* BreakStatement */ ? 70 /* BreakKeyword */ : 75 /* ContinueKeyword */); + parseExpected(kind === 211 /* BreakStatement */ ? 71 /* BreakKeyword */ : 76 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -16707,8 +16761,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(211 /* ReturnStatement */); - parseExpected(94 /* ReturnKeyword */); + var node = createNode(212 /* ReturnStatement */); + parseExpected(95 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -16716,42 +16770,42 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(212 /* WithStatement */); - parseExpected(105 /* WithKeyword */); - parseExpected(17 /* OpenParenToken */); + var node = createNode(213 /* WithStatement */); + parseExpected(106 /* WithKeyword */); + parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); node.statement = parseStatement(); return finishNode(node); } function parseCaseClause() { var node = createNode(249 /* CaseClause */); - parseExpected(71 /* CaseKeyword */); + parseExpected(72 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); - parseExpected(54 /* ColonToken */); + parseExpected(55 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseDefaultClause() { var node = createNode(250 /* DefaultClause */); - parseExpected(77 /* DefaultKeyword */); - parseExpected(54 /* ColonToken */); + parseExpected(78 /* DefaultKeyword */); + parseExpected(55 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token() === 71 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token() === 72 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(213 /* SwitchStatement */); - parseExpected(96 /* SwitchKeyword */); - parseExpected(17 /* OpenParenToken */); + var node = createNode(214 /* SwitchStatement */); + parseExpected(97 /* SwitchKeyword */); + parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(18 /* CloseParenToken */); - var caseBlock = createNode(227 /* CaseBlock */, scanner.getStartPos()); - parseExpected(15 /* OpenBraceToken */); + parseExpected(19 /* CloseParenToken */); + var caseBlock = createNode(228 /* CaseBlock */, scanner.getStartPos()); + parseExpected(16 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); - parseExpected(16 /* CloseBraceToken */); + parseExpected(17 /* CloseBraceToken */); node.caseBlock = finishNode(caseBlock); return finishNode(node); } @@ -16763,39 +16817,39 @@ 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(215 /* ThrowStatement */); - parseExpected(98 /* ThrowKeyword */); + var node = createNode(216 /* ThrowStatement */); + parseExpected(99 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(216 /* TryStatement */); - parseExpected(100 /* TryKeyword */); + var node = createNode(217 /* TryStatement */); + parseExpected(101 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); - node.catchClause = token() === 72 /* CatchKeyword */ ? parseCatchClause() : undefined; + node.catchClause = token() === 73 /* 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() === 85 /* FinallyKeyword */) { - parseExpected(85 /* FinallyKeyword */); + if (!node.catchClause || token() === 86 /* FinallyKeyword */) { + parseExpected(86 /* FinallyKeyword */); node.finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } return finishNode(node); } function parseCatchClause() { var result = createNode(252 /* CatchClause */); - parseExpected(72 /* CatchKeyword */); - if (parseExpected(17 /* OpenParenToken */)) { + parseExpected(73 /* CatchKeyword */); + if (parseExpected(18 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); } - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); result.block = parseBlock(/*ignoreMissingOpenBrace*/ false); return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(217 /* DebuggerStatement */); - parseExpected(76 /* DebuggerKeyword */); + var node = createNode(218 /* DebuggerStatement */); + parseExpected(77 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); } @@ -16805,14 +16859,14 @@ var ts; // a colon. var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); - if (expression.kind === 69 /* Identifier */ && parseOptional(54 /* ColonToken */)) { - var labeledStatement = createNode(214 /* LabeledStatement */, fullStart); + if (expression.kind === 70 /* Identifier */ && parseOptional(55 /* ColonToken */)) { + var labeledStatement = createNode(215 /* LabeledStatement */, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(202 /* ExpressionStatement */, fullStart); + var expressionStatement = createNode(203 /* ExpressionStatement */, fullStart); expressionStatement.expression = expression; parseSemicolon(); return addJSDocComment(finishNode(expressionStatement)); @@ -16824,7 +16878,7 @@ var ts; } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 87 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 88 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { nextToken(); @@ -16833,12 +16887,12 @@ var ts; function isDeclaration() { while (true) { switch (token()) { - case 102 /* VarKeyword */: - case 108 /* LetKeyword */: - case 74 /* ConstKeyword */: - case 87 /* FunctionKeyword */: - case 73 /* ClassKeyword */: - case 81 /* EnumKeyword */: + case 103 /* VarKeyword */: + case 109 /* LetKeyword */: + case 75 /* ConstKeyword */: + case 88 /* FunctionKeyword */: + case 74 /* ClassKeyword */: + case 82 /* 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 @@ -16861,41 +16915,41 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 107 /* InterfaceKeyword */: - case 134 /* TypeKeyword */: + case 108 /* InterfaceKeyword */: + case 135 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 125 /* ModuleKeyword */: - case 126 /* NamespaceKeyword */: + case 126 /* ModuleKeyword */: + case 127 /* NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 115 /* AbstractKeyword */: - case 118 /* AsyncKeyword */: - case 122 /* DeclareKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - case 112 /* PublicKeyword */: - case 128 /* ReadonlyKeyword */: + case 116 /* AbstractKeyword */: + case 119 /* AsyncKeyword */: + case 123 /* DeclareKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + case 113 /* PublicKeyword */: + case 129 /* ReadonlyKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 137 /* GlobalKeyword */: + case 138 /* GlobalKeyword */: nextToken(); - return token() === 15 /* OpenBraceToken */ || token() === 69 /* Identifier */ || token() === 82 /* ExportKeyword */; - case 89 /* ImportKeyword */: + return token() === 16 /* OpenBraceToken */ || token() === 70 /* Identifier */ || token() === 83 /* ExportKeyword */; + case 90 /* ImportKeyword */: nextToken(); - return token() === 9 /* StringLiteral */ || token() === 37 /* AsteriskToken */ || - token() === 15 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); - case 82 /* ExportKeyword */: + return token() === 9 /* StringLiteral */ || token() === 38 /* AsteriskToken */ || + token() === 16 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); + case 83 /* ExportKeyword */: nextToken(); - if (token() === 56 /* EqualsToken */ || token() === 37 /* AsteriskToken */ || - token() === 15 /* OpenBraceToken */ || token() === 77 /* DefaultKeyword */ || - token() === 116 /* AsKeyword */) { + if (token() === 57 /* EqualsToken */ || token() === 38 /* AsteriskToken */ || + token() === 16 /* OpenBraceToken */ || token() === 78 /* DefaultKeyword */ || + token() === 117 /* AsKeyword */) { return true; } continue; - case 113 /* StaticKeyword */: + case 114 /* StaticKeyword */: nextToken(); continue; default: @@ -16908,49 +16962,49 @@ var ts; } function isStartOfStatement() { switch (token()) { - case 55 /* AtToken */: - case 23 /* SemicolonToken */: - case 15 /* OpenBraceToken */: - 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 */: + case 56 /* AtToken */: + case 24 /* SemicolonToken */: + case 16 /* OpenBraceToken */: + case 103 /* VarKeyword */: + case 109 /* LetKeyword */: + case 88 /* FunctionKeyword */: + case 74 /* ClassKeyword */: + case 82 /* EnumKeyword */: + case 89 /* IfKeyword */: + case 80 /* DoKeyword */: + case 105 /* WhileKeyword */: + case 87 /* ForKeyword */: + case 76 /* ContinueKeyword */: + case 71 /* BreakKeyword */: + case 95 /* ReturnKeyword */: + case 106 /* WithKeyword */: + case 97 /* SwitchKeyword */: + case 99 /* ThrowKeyword */: + case 101 /* TryKeyword */: + case 77 /* 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 72 /* CatchKeyword */: - case 85 /* FinallyKeyword */: + case 73 /* CatchKeyword */: + case 86 /* FinallyKeyword */: return true; - case 74 /* ConstKeyword */: - case 82 /* ExportKeyword */: - case 89 /* ImportKeyword */: + case 75 /* ConstKeyword */: + case 83 /* ExportKeyword */: + case 90 /* ImportKeyword */: return isStartOfDeclaration(); - case 118 /* AsyncKeyword */: - case 122 /* DeclareKeyword */: - case 107 /* InterfaceKeyword */: - case 125 /* ModuleKeyword */: - case 126 /* NamespaceKeyword */: - case 134 /* TypeKeyword */: - case 137 /* GlobalKeyword */: + case 119 /* AsyncKeyword */: + case 123 /* DeclareKeyword */: + case 108 /* InterfaceKeyword */: + case 126 /* ModuleKeyword */: + case 127 /* NamespaceKeyword */: + case 135 /* TypeKeyword */: + case 138 /* GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - case 113 /* StaticKeyword */: - case 128 /* ReadonlyKeyword */: + case 113 /* PublicKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + case 114 /* StaticKeyword */: + case 129 /* ReadonlyKeyword */: // 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); @@ -16960,7 +17014,7 @@ var ts; } function nextTokenIsIdentifierOrStartOfDestructuring() { nextToken(); - return isIdentifier() || token() === 15 /* OpenBraceToken */ || token() === 19 /* OpenBracketToken */; + return isIdentifier() || token() === 16 /* OpenBraceToken */ || token() === 20 /* OpenBracketToken */; } function isLetDeclaration() { // In ES6 'let' always starts a lexical declaration if followed by an identifier or { @@ -16969,67 +17023,67 @@ var ts; } function parseStatement() { switch (token()) { - case 23 /* SemicolonToken */: + case 24 /* SemicolonToken */: return parseEmptyStatement(); - case 15 /* OpenBraceToken */: + case 16 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); - case 102 /* VarKeyword */: + case 103 /* VarKeyword */: return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 108 /* LetKeyword */: + case 109 /* LetKeyword */: if (isLetDeclaration()) { return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); } break; - case 87 /* FunctionKeyword */: + case 88 /* FunctionKeyword */: return parseFunctionDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 73 /* ClassKeyword */: + case 74 /* ClassKeyword */: return parseClassDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 88 /* IfKeyword */: + case 89 /* IfKeyword */: return parseIfStatement(); - case 79 /* DoKeyword */: + case 80 /* DoKeyword */: return parseDoStatement(); - case 104 /* WhileKeyword */: + case 105 /* WhileKeyword */: return parseWhileStatement(); - case 86 /* ForKeyword */: + case 87 /* ForKeyword */: return parseForOrForInOrForOfStatement(); - case 75 /* ContinueKeyword */: - return parseBreakOrContinueStatement(209 /* ContinueStatement */); - case 70 /* BreakKeyword */: - return parseBreakOrContinueStatement(210 /* BreakStatement */); - case 94 /* ReturnKeyword */: + case 76 /* ContinueKeyword */: + return parseBreakOrContinueStatement(210 /* ContinueStatement */); + case 71 /* BreakKeyword */: + return parseBreakOrContinueStatement(211 /* BreakStatement */); + case 95 /* ReturnKeyword */: return parseReturnStatement(); - case 105 /* WithKeyword */: + case 106 /* WithKeyword */: return parseWithStatement(); - case 96 /* SwitchKeyword */: + case 97 /* SwitchKeyword */: return parseSwitchStatement(); - case 98 /* ThrowKeyword */: + case 99 /* ThrowKeyword */: return parseThrowStatement(); - case 100 /* TryKeyword */: + case 101 /* TryKeyword */: // Include 'catch' and 'finally' for error recovery. - case 72 /* CatchKeyword */: - case 85 /* FinallyKeyword */: + case 73 /* CatchKeyword */: + case 86 /* FinallyKeyword */: return parseTryStatement(); - case 76 /* DebuggerKeyword */: + case 77 /* DebuggerKeyword */: return parseDebuggerStatement(); - case 55 /* AtToken */: + case 56 /* AtToken */: return parseDeclaration(); - case 118 /* AsyncKeyword */: - case 107 /* InterfaceKeyword */: - case 134 /* 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 */: - case 128 /* ReadonlyKeyword */: - case 137 /* GlobalKeyword */: + case 119 /* AsyncKeyword */: + case 108 /* InterfaceKeyword */: + case 135 /* TypeKeyword */: + case 126 /* ModuleKeyword */: + case 127 /* NamespaceKeyword */: + case 123 /* DeclareKeyword */: + case 75 /* ConstKeyword */: + case 82 /* EnumKeyword */: + case 83 /* ExportKeyword */: + case 90 /* ImportKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + case 113 /* PublicKeyword */: + case 116 /* AbstractKeyword */: + case 114 /* StaticKeyword */: + case 129 /* ReadonlyKeyword */: + case 138 /* GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -17042,33 +17096,33 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(); switch (token()) { - case 102 /* VarKeyword */: - case 108 /* LetKeyword */: - case 74 /* ConstKeyword */: + case 103 /* VarKeyword */: + case 109 /* LetKeyword */: + case 75 /* ConstKeyword */: return parseVariableStatement(fullStart, decorators, modifiers); - case 87 /* FunctionKeyword */: + case 88 /* FunctionKeyword */: return parseFunctionDeclaration(fullStart, decorators, modifiers); - case 73 /* ClassKeyword */: + case 74 /* ClassKeyword */: return parseClassDeclaration(fullStart, decorators, modifiers); - case 107 /* InterfaceKeyword */: + case 108 /* InterfaceKeyword */: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 134 /* TypeKeyword */: + case 135 /* TypeKeyword */: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); - case 81 /* EnumKeyword */: + case 82 /* EnumKeyword */: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 137 /* GlobalKeyword */: - case 125 /* ModuleKeyword */: - case 126 /* NamespaceKeyword */: + case 138 /* GlobalKeyword */: + case 126 /* ModuleKeyword */: + case 127 /* NamespaceKeyword */: return parseModuleDeclaration(fullStart, decorators, modifiers); - case 89 /* ImportKeyword */: + case 90 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); - case 82 /* ExportKeyword */: + case 83 /* ExportKeyword */: nextToken(); switch (token()) { - case 77 /* DefaultKeyword */: - case 56 /* EqualsToken */: + case 78 /* DefaultKeyword */: + case 57 /* EqualsToken */: return parseExportAssignment(fullStart, decorators, modifiers); - case 116 /* AsKeyword */: + case 117 /* AsKeyword */: return parseNamespaceExportDeclaration(fullStart, decorators, modifiers); default: return parseExportDeclaration(fullStart, decorators, modifiers); @@ -17077,7 +17131,7 @@ var ts; 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(239 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(240 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; node.modifiers = modifiers; @@ -17090,7 +17144,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 9 /* StringLiteral */); } function parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage) { - if (token() !== 15 /* OpenBraceToken */ && canParseSemicolon()) { + if (token() !== 16 /* OpenBraceToken */ && canParseSemicolon()) { parseSemicolon(); return; } @@ -17098,24 +17152,24 @@ var ts; } // DECLARATIONS function parseArrayBindingElement() { - if (token() === 24 /* CommaToken */) { - return createNode(193 /* OmittedExpression */); + if (token() === 25 /* CommaToken */) { + return createNode(194 /* OmittedExpression */); } - var node = createNode(169 /* BindingElement */); - node.dotDotDotToken = parseOptionalToken(22 /* DotDotDotToken */); + var node = createNode(170 /* BindingElement */); + node.dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(/*inParameter*/ false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(169 /* BindingElement */); + var node = createNode(170 /* BindingElement */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token() !== 54 /* ColonToken */) { + if (tokenIsIdentifier && token() !== 55 /* ColonToken */) { node.name = propertyName; } else { - parseExpected(54 /* ColonToken */); + parseExpected(55 /* ColonToken */); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -17123,33 +17177,33 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(167 /* ObjectBindingPattern */); - parseExpected(15 /* OpenBraceToken */); + var node = createNode(168 /* ObjectBindingPattern */); + parseExpected(16 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); - parseExpected(16 /* CloseBraceToken */); + parseExpected(17 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(168 /* ArrayBindingPattern */); - parseExpected(19 /* OpenBracketToken */); + var node = createNode(169 /* ArrayBindingPattern */); + parseExpected(20 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); - parseExpected(20 /* CloseBracketToken */); + parseExpected(21 /* CloseBracketToken */); return finishNode(node); } function isIdentifierOrPattern() { - return token() === 15 /* OpenBraceToken */ || token() === 19 /* OpenBracketToken */ || isIdentifier(); + return token() === 16 /* OpenBraceToken */ || token() === 20 /* OpenBracketToken */ || isIdentifier(); } function parseIdentifierOrPattern() { - if (token() === 19 /* OpenBracketToken */) { + if (token() === 20 /* OpenBracketToken */) { return parseArrayBindingPattern(); } - if (token() === 15 /* OpenBraceToken */) { + if (token() === 16 /* OpenBraceToken */) { return parseObjectBindingPattern(); } return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(218 /* VariableDeclaration */); + var node = createNode(219 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { @@ -17158,14 +17212,14 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(219 /* VariableDeclarationList */); + var node = createNode(220 /* VariableDeclarationList */); switch (token()) { - case 102 /* VarKeyword */: + case 103 /* VarKeyword */: break; - case 108 /* LetKeyword */: + case 109 /* LetKeyword */: node.flags |= 1 /* Let */; break; - case 74 /* ConstKeyword */: + case 75 /* ConstKeyword */: node.flags |= 2 /* Const */; break; default: @@ -17181,7 +17235,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() === 138 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 139 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -17193,10 +17247,10 @@ var ts; return finishNode(node); } function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 18 /* CloseParenToken */; + return nextTokenIsIdentifier() && nextToken() === 19 /* CloseParenToken */; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(200 /* VariableStatement */, fullStart); + var node = createNode(201 /* VariableStatement */, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); @@ -17204,29 +17258,29 @@ var ts; return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(220 /* FunctionDeclaration */, fullStart); + var node = createNode(221 /* FunctionDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(87 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); + parseExpected(88 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(38 /* AsteriskToken */); node.name = ts.hasModifier(node, 512 /* Default */) ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = !!node.asteriskToken; var isAsync = ts.hasModifier(node, 256 /* Async */); - fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); + fillSignature(55 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return addJSDocComment(finishNode(node)); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(148 /* Constructor */, pos); + var node = createNode(149 /* Constructor */, pos); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(121 /* ConstructorKeyword */); - fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + parseExpected(122 /* ConstructorKeyword */); + fillSignature(55 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false, ts.Diagnostics.or_expected); return addJSDocComment(finishNode(node)); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(147 /* MethodDeclaration */, fullStart); + var method = createNode(148 /* MethodDeclaration */, fullStart); method.decorators = decorators; method.modifiers = modifiers; method.asteriskToken = asteriskToken; @@ -17234,12 +17288,12 @@ var ts; method.questionToken = questionToken; var isGenerator = !!asteriskToken; var isAsync = ts.hasModifier(method, 256 /* Async */); - fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method); + fillSignature(55 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return addJSDocComment(finishNode(method)); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(145 /* PropertyDeclaration */, fullStart); + var property = createNode(146 /* PropertyDeclaration */, fullStart); property.decorators = decorators; property.modifiers = modifiers; property.name = name; @@ -17261,12 +17315,12 @@ var ts; return addJSDocComment(finishNode(property)); } function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { - var asteriskToken = parseOptionalToken(37 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(38 /* AsteriskToken */); 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(53 /* QuestionToken */); - if (asteriskToken || token() === 17 /* OpenParenToken */ || token() === 25 /* LessThanToken */) { + var questionToken = parseOptionalToken(54 /* QuestionToken */); + if (asteriskToken || token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); } else { @@ -17281,17 +17335,17 @@ var ts; node.decorators = decorators; node.modifiers = modifiers; node.name = parsePropertyName(); - fillSignature(54 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + fillSignature(55 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false); return addJSDocComment(finishNode(node)); } function isClassMemberModifier(idToken) { switch (idToken) { - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - case 113 /* StaticKeyword */: - case 128 /* ReadonlyKeyword */: + case 113 /* PublicKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + case 114 /* StaticKeyword */: + case 129 /* ReadonlyKeyword */: return true; default: return false; @@ -17299,7 +17353,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token() === 55 /* AtToken */) { + if (token() === 56 /* AtToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. @@ -17316,7 +17370,7 @@ var ts; } nextToken(); } - if (token() === 37 /* AsteriskToken */) { + if (token() === 38 /* AsteriskToken */) { return true; } // Try to get the first property-like token following all modifiers. @@ -17326,23 +17380,23 @@ var ts; nextToken(); } // Index signatures and computed properties are class members; we can parse. - if (token() === 19 /* OpenBracketToken */) { + if (token() === 20 /* OpenBracketToken */) { return true; } // 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 === 131 /* SetKeyword */ || idToken === 123 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 132 /* SetKeyword */ || idToken === 124 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along // to see if it should actually be parsed as a class member. switch (token()) { - case 17 /* OpenParenToken */: // Method declaration - case 25 /* LessThanToken */: // Generic Method declaration - case 54 /* ColonToken */: // Type Annotation for declaration - case 56 /* EqualsToken */: // Initializer for declaration - case 53 /* QuestionToken */: + case 18 /* OpenParenToken */: // Method declaration + case 26 /* LessThanToken */: // Generic Method declaration + case 55 /* ColonToken */: // Type Annotation for declaration + case 57 /* EqualsToken */: // Initializer for declaration + case 54 /* QuestionToken */: return true; default: // Covers @@ -17359,10 +17413,10 @@ var ts; var decorators; while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(55 /* AtToken */)) { + if (!parseOptional(56 /* AtToken */)) { break; } - var decorator = createNode(143 /* Decorator */, decoratorStart); + var decorator = createNode(144 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); if (!decorators) { @@ -17389,7 +17443,7 @@ var ts; while (true) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); - if (token() === 74 /* ConstKeyword */ && permitInvalidConstAsModifier) { + if (token() === 75 /* ConstKeyword */ && permitInvalidConstAsModifier) { // We need to ensure that any subsequent modifiers appear on the same line // so that when 'const' is a standalone declaration, we don't issue an error. if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) { @@ -17416,7 +17470,7 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 118 /* AsyncKeyword */) { + if (token() === 119 /* AsyncKeyword */) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); nextToken(); @@ -17427,8 +17481,8 @@ var ts; return modifiers; } function parseClassElement() { - if (token() === 23 /* SemicolonToken */) { - var result = createNode(198 /* SemicolonClassElement */); + if (token() === 24 /* SemicolonToken */) { + var result = createNode(199 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -17439,7 +17493,7 @@ var ts; if (accessor) { return accessor; } - if (token() === 121 /* ConstructorKeyword */) { + if (token() === 122 /* ConstructorKeyword */) { return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { @@ -17450,13 +17504,13 @@ var ts; if (ts.tokenIsIdentifierOrKeyword(token()) || token() === 9 /* StringLiteral */ || token() === 8 /* NumericLiteral */ || - token() === 37 /* AsteriskToken */ || - token() === 19 /* OpenBracketToken */) { + token() === 38 /* AsteriskToken */ || + token() === 20 /* OpenBracketToken */) { return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { // treat this as a property declaration with a missing name. - var name_10 = createMissingNode(69 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var name_10 = createMissingNode(70 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(fullStart, decorators, modifiers, name_10, /*questionToken*/ undefined); } // 'isClassMemberStart' should have hinted not to attempt parsing. @@ -17466,24 +17520,24 @@ var ts; return parseClassDeclarationOrExpression( /*fullStart*/ scanner.getStartPos(), /*decorators*/ undefined, - /*modifiers*/ undefined, 192 /* ClassExpression */); + /*modifiers*/ undefined, 193 /* ClassExpression */); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 221 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 222 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(73 /* ClassKeyword */); + parseExpected(74 /* ClassKeyword */); node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); - node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ true); - if (parseExpected(15 /* OpenBraceToken */)) { + node.heritageClauses = parseHeritageClauses(); + if (parseExpected(16 /* OpenBraceToken */)) { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } node.members = parseClassMembers(); - parseExpected(16 /* CloseBraceToken */); + parseExpected(17 /* CloseBraceToken */); } else { node.members = createMissingList(); @@ -17501,9 +17555,9 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 106 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 107 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); } - function parseHeritageClauses(isClassHeritageClause) { + function parseHeritageClauses() { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } if (isHeritageClause()) { @@ -17512,7 +17566,7 @@ var ts; return undefined; } function parseHeritageClause() { - if (token() === 83 /* ExtendsKeyword */ || token() === 106 /* ImplementsKeyword */) { + if (token() === 84 /* ExtendsKeyword */ || token() === 107 /* ImplementsKeyword */) { var node = createNode(251 /* HeritageClause */); node.token = token(); nextToken(); @@ -17522,38 +17576,38 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(194 /* ExpressionWithTypeArguments */); + var node = createNode(195 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); - if (token() === 25 /* LessThanToken */) { - node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 25 /* LessThanToken */, 27 /* GreaterThanToken */); + if (token() === 26 /* LessThanToken */) { + node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 26 /* LessThanToken */, 28 /* GreaterThanToken */); } return finishNode(node); } function isHeritageClause() { - return token() === 83 /* ExtendsKeyword */ || token() === 106 /* ImplementsKeyword */; + return token() === 84 /* ExtendsKeyword */ || token() === 107 /* ImplementsKeyword */; } function parseClassMembers() { return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(222 /* InterfaceDeclaration */, fullStart); + var node = createNode(223 /* InterfaceDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(107 /* InterfaceKeyword */); + parseExpected(108 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ false); + node.heritageClauses = parseHeritageClauses(); node.members = parseObjectTypeMembers(); return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(223 /* TypeAliasDeclaration */, fullStart); + var node = createNode(224 /* TypeAliasDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(134 /* TypeKeyword */); + parseExpected(135 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(56 /* EqualsToken */); + parseExpected(57 /* EqualsToken */); node.type = parseType(); parseSemicolon(); return addJSDocComment(finishNode(node)); @@ -17569,14 +17623,14 @@ var ts; return addJSDocComment(finishNode(node)); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(224 /* EnumDeclaration */, fullStart); + var node = createNode(225 /* EnumDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(81 /* EnumKeyword */); + parseExpected(82 /* EnumKeyword */); node.name = parseIdentifier(); - if (parseExpected(15 /* OpenBraceToken */)) { + if (parseExpected(16 /* OpenBraceToken */)) { node.members = parseDelimitedList(6 /* EnumMembers */, parseEnumMember); - parseExpected(16 /* CloseBraceToken */); + parseExpected(17 /* CloseBraceToken */); } else { node.members = createMissingList(); @@ -17584,10 +17638,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseModuleBlock() { - var node = createNode(226 /* ModuleBlock */, scanner.getStartPos()); - if (parseExpected(15 /* OpenBraceToken */)) { + var node = createNode(227 /* ModuleBlock */, scanner.getStartPos()); + if (parseExpected(16 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(16 /* CloseBraceToken */); + parseExpected(17 /* CloseBraceToken */); } else { node.statements = createMissingList(); @@ -17595,7 +17649,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(225 /* ModuleDeclaration */, fullStart); + var node = createNode(226 /* 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 & 16 /* Namespace */; @@ -17603,16 +17657,16 @@ var ts; node.modifiers = modifiers; node.flags |= flags; node.name = parseIdentifier(); - node.body = parseOptional(21 /* DotToken */) + node.body = parseOptional(22 /* DotToken */) ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, 4 /* NestedNamespace */ | namespaceFlag) : parseModuleBlock(); return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(225 /* ModuleDeclaration */, fullStart); + var node = createNode(226 /* ModuleDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (token() === 137 /* GlobalKeyword */) { + if (token() === 138 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); node.flags |= 512 /* GlobalAugmentation */; @@ -17620,7 +17674,7 @@ var ts; else { node.name = parseLiteralNode(/*internName*/ true); } - if (token() === 15 /* OpenBraceToken */) { + if (token() === 16 /* OpenBraceToken */) { node.body = parseModuleBlock(); } else { @@ -17630,15 +17684,15 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = 0; - if (token() === 137 /* GlobalKeyword */) { + if (token() === 138 /* GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } - else if (parseOptional(126 /* NamespaceKeyword */)) { + else if (parseOptional(127 /* NamespaceKeyword */)) { flags |= 16 /* Namespace */; } else { - parseExpected(125 /* ModuleKeyword */); + parseExpected(126 /* ModuleKeyword */); if (token() === 9 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -17646,57 +17700,57 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token() === 129 /* RequireKeyword */ && + return token() === 130 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { - return nextToken() === 17 /* OpenParenToken */; + return nextToken() === 18 /* OpenParenToken */; } function nextTokenIsSlash() { - return nextToken() === 39 /* SlashToken */; + return nextToken() === 40 /* SlashToken */; } function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { - var exportDeclaration = createNode(228 /* NamespaceExportDeclaration */, fullStart); + var exportDeclaration = createNode(229 /* NamespaceExportDeclaration */, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; - parseExpected(116 /* AsKeyword */); - parseExpected(126 /* NamespaceKeyword */); + parseExpected(117 /* AsKeyword */); + parseExpected(127 /* NamespaceKeyword */); exportDeclaration.name = parseIdentifier(); - parseExpected(23 /* SemicolonToken */); + parseExpected(24 /* SemicolonToken */); return finishNode(exportDeclaration); } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { - parseExpected(89 /* ImportKeyword */); + parseExpected(90 /* ImportKeyword */); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 24 /* CommaToken */ && token() !== 136 /* FromKeyword */) { + if (token() !== 25 /* CommaToken */ && token() !== 137 /* FromKeyword */) { // ImportEquals declaration of type: // import x = require("mod"); or // import x = M.x; - var importEqualsDeclaration = createNode(229 /* ImportEqualsDeclaration */, fullStart); + var importEqualsDeclaration = createNode(230 /* ImportEqualsDeclaration */, fullStart); importEqualsDeclaration.decorators = decorators; importEqualsDeclaration.modifiers = modifiers; importEqualsDeclaration.name = identifier; - parseExpected(56 /* EqualsToken */); + parseExpected(57 /* EqualsToken */); importEqualsDeclaration.moduleReference = parseModuleReference(); parseSemicolon(); return addJSDocComment(finishNode(importEqualsDeclaration)); } } // Import statement - var importDeclaration = createNode(230 /* ImportDeclaration */, fullStart); + var importDeclaration = createNode(231 /* ImportDeclaration */, fullStart); importDeclaration.decorators = decorators; importDeclaration.modifiers = modifiers; // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; if (identifier || - token() === 37 /* AsteriskToken */ || - token() === 15 /* OpenBraceToken */) { + token() === 38 /* AsteriskToken */ || + token() === 16 /* OpenBraceToken */) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(136 /* FromKeyword */); + parseExpected(137 /* FromKeyword */); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -17709,7 +17763,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(231 /* ImportClause */, fullStart); + var importClause = createNode(232 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -17718,8 +17772,8 @@ var ts; // If there was no default import or if there is comma token after default import // parse namespace or named imports if (!importClause.name || - parseOptional(24 /* CommaToken */)) { - importClause.namedBindings = token() === 37 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(233 /* NamedImports */); + parseOptional(25 /* CommaToken */)) { + importClause.namedBindings = token() === 38 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(234 /* NamedImports */); } return finishNode(importClause); } @@ -17729,11 +17783,11 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(240 /* ExternalModuleReference */); - parseExpected(129 /* RequireKeyword */); - parseExpected(17 /* OpenParenToken */); + var node = createNode(241 /* ExternalModuleReference */); + parseExpected(130 /* RequireKeyword */); + parseExpected(18 /* OpenParenToken */); node.expression = parseModuleSpecifier(); - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); return finishNode(node); } function parseModuleSpecifier() { @@ -17752,9 +17806,9 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(232 /* NamespaceImport */); - parseExpected(37 /* AsteriskToken */); - parseExpected(116 /* AsKeyword */); + var namespaceImport = createNode(233 /* NamespaceImport */); + parseExpected(38 /* AsteriskToken */); + parseExpected(117 /* AsKeyword */); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } @@ -17767,14 +17821,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 233 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 15 /* OpenBraceToken */, 16 /* CloseBraceToken */); + node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 234 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 16 /* OpenBraceToken */, 17 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(238 /* ExportSpecifier */); + return parseImportOrExportSpecifier(239 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(234 /* ImportSpecifier */); + return parseImportOrExportSpecifier(235 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -17788,9 +17842,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token() === 116 /* AsKeyword */) { + if (token() === 117 /* AsKeyword */) { node.propertyName = identifierName; - parseExpected(116 /* AsKeyword */); + parseExpected(117 /* AsKeyword */); checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -17799,27 +17853,27 @@ var ts; else { node.name = identifierName; } - if (kind === 234 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 235 /* 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(236 /* ExportDeclaration */, fullStart); + var node = createNode(237 /* ExportDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (parseOptional(37 /* AsteriskToken */)) { - parseExpected(136 /* FromKeyword */); + if (parseOptional(38 /* AsteriskToken */)) { + parseExpected(137 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(237 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(238 /* 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() === 136 /* FromKeyword */ || (token() === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(136 /* FromKeyword */); + if (token() === 137 /* FromKeyword */ || (token() === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(137 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -17827,14 +17881,14 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(235 /* ExportAssignment */, fullStart); + var node = createNode(236 /* ExportAssignment */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (parseOptional(56 /* EqualsToken */)) { + if (parseOptional(57 /* EqualsToken */)) { node.isExportEquals = true; } else { - parseExpected(77 /* DefaultKeyword */); + parseExpected(78 /* DefaultKeyword */); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -17909,10 +17963,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 229 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 240 /* ExternalModuleReference */ - || node.kind === 230 /* ImportDeclaration */ - || node.kind === 235 /* ExportAssignment */ - || node.kind === 236 /* ExportDeclaration */ + || node.kind === 230 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 241 /* ExternalModuleReference */ + || node.kind === 231 /* ImportDeclaration */ + || node.kind === 236 /* ExportAssignment */ + || node.kind === 237 /* ExportDeclaration */ ? node : undefined; }); @@ -17957,24 +18011,24 @@ var ts; (function (JSDocParser) { function isJSDocType() { switch (token()) { - case 37 /* AsteriskToken */: - case 53 /* QuestionToken */: - case 17 /* OpenParenToken */: - case 19 /* OpenBracketToken */: - case 49 /* ExclamationToken */: - case 15 /* OpenBraceToken */: - case 87 /* FunctionKeyword */: - case 22 /* DotDotDotToken */: - case 92 /* NewKeyword */: - case 97 /* ThisKeyword */: + case 38 /* AsteriskToken */: + case 54 /* QuestionToken */: + case 18 /* OpenParenToken */: + case 20 /* OpenBracketToken */: + case 50 /* ExclamationToken */: + case 16 /* OpenBraceToken */: + case 88 /* FunctionKeyword */: + case 23 /* DotDotDotToken */: + case 93 /* NewKeyword */: + case 98 /* ThisKeyword */: return true; } return ts.tokenIsIdentifierOrKeyword(token()); } JSDocParser.isJSDocType = isJSDocType; function parseJSDocTypeExpressionForTests(content, start, length) { - initializeState("file.js", content, 2 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); - sourceFile = createSourceFile("file.js", 2 /* Latest */, 1 /* JS */); + initializeState(content, 4 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); + sourceFile = createSourceFile("file.js", 4 /* Latest */, 1 /* JS */); scanner.setText(content, start, length); currentToken = scanner.scan(); var jsDocTypeExpression = parseJSDocTypeExpression(); @@ -17987,21 +18041,21 @@ var ts; /* @internal */ function parseJSDocTypeExpression() { var result = createNode(257 /* JSDocTypeExpression */, scanner.getTokenPos()); - parseExpected(15 /* OpenBraceToken */); + parseExpected(16 /* OpenBraceToken */); result.type = parseJSDocTopLevelType(); - parseExpected(16 /* CloseBraceToken */); + parseExpected(17 /* CloseBraceToken */); fixupParentReferences(result); return finishNode(result); } JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocTopLevelType() { var type = parseJSDocType(); - if (token() === 47 /* BarToken */) { + if (token() === 48 /* BarToken */) { var unionType = createNode(261 /* JSDocUnionType */, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } - if (token() === 56 /* EqualsToken */) { + if (token() === 57 /* EqualsToken */) { var optionalType = createNode(268 /* JSDocOptionalType */, type.pos); nextToken(); optionalType.type = type; @@ -18012,20 +18066,20 @@ var ts; function parseJSDocType() { var type = parseBasicTypeExpression(); while (true) { - if (token() === 19 /* OpenBracketToken */) { + if (token() === 20 /* OpenBracketToken */) { var arrayType = createNode(260 /* JSDocArrayType */, type.pos); arrayType.elementType = type; nextToken(); - parseExpected(20 /* CloseBracketToken */); + parseExpected(21 /* CloseBracketToken */); type = finishNode(arrayType); } - else if (token() === 53 /* QuestionToken */) { + else if (token() === 54 /* QuestionToken */) { var nullableType = createNode(263 /* JSDocNullableType */, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } - else if (token() === 49 /* ExclamationToken */) { + else if (token() === 50 /* ExclamationToken */) { var nonNullableType = createNode(264 /* JSDocNonNullableType */, type.pos); nonNullableType.type = type; nextToken(); @@ -18039,40 +18093,40 @@ var ts; } function parseBasicTypeExpression() { switch (token()) { - case 37 /* AsteriskToken */: + case 38 /* AsteriskToken */: return parseJSDocAllType(); - case 53 /* QuestionToken */: + case 54 /* QuestionToken */: return parseJSDocUnknownOrNullableType(); - case 17 /* OpenParenToken */: + case 18 /* OpenParenToken */: return parseJSDocUnionType(); - case 19 /* OpenBracketToken */: + case 20 /* OpenBracketToken */: return parseJSDocTupleType(); - case 49 /* ExclamationToken */: + case 50 /* ExclamationToken */: return parseJSDocNonNullableType(); - case 15 /* OpenBraceToken */: + case 16 /* OpenBraceToken */: return parseJSDocRecordType(); - case 87 /* FunctionKeyword */: + case 88 /* FunctionKeyword */: return parseJSDocFunctionType(); - case 22 /* DotDotDotToken */: + case 23 /* DotDotDotToken */: return parseJSDocVariadicType(); - case 92 /* NewKeyword */: + case 93 /* NewKeyword */: return parseJSDocConstructorType(); - case 97 /* ThisKeyword */: + case 98 /* ThisKeyword */: return parseJSDocThisType(); - case 117 /* AnyKeyword */: - case 132 /* StringKeyword */: - case 130 /* NumberKeyword */: - case 120 /* BooleanKeyword */: - case 133 /* SymbolKeyword */: - case 103 /* VoidKeyword */: - case 93 /* NullKeyword */: - case 135 /* UndefinedKeyword */: - case 127 /* NeverKeyword */: + case 118 /* AnyKeyword */: + case 133 /* StringKeyword */: + case 131 /* NumberKeyword */: + case 121 /* BooleanKeyword */: + case 134 /* SymbolKeyword */: + case 104 /* VoidKeyword */: + case 94 /* NullKeyword */: + case 136 /* UndefinedKeyword */: + case 128 /* NeverKeyword */: return parseTokenNode(); case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: + case 100 /* TrueKeyword */: + case 85 /* FalseKeyword */: return parseJSDocLiteralType(); } return parseJSDocTypeReference(); @@ -18080,14 +18134,14 @@ var ts; function parseJSDocThisType() { var result = createNode(272 /* JSDocThisType */); nextToken(); - parseExpected(54 /* ColonToken */); + parseExpected(55 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { var result = createNode(271 /* JSDocConstructorType */); nextToken(); - parseExpected(54 /* ColonToken */); + parseExpected(55 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } @@ -18100,34 +18154,34 @@ var ts; function parseJSDocFunctionType() { var result = createNode(269 /* JSDocFunctionType */); nextToken(); - parseExpected(17 /* OpenParenToken */); + parseExpected(18 /* OpenParenToken */); result.parameters = parseDelimitedList(22 /* JSDocFunctionParameters */, parseJSDocParameter); checkForTrailingComma(result.parameters); - parseExpected(18 /* CloseParenToken */); - if (token() === 54 /* ColonToken */) { + parseExpected(19 /* CloseParenToken */); + if (token() === 55 /* ColonToken */) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(142 /* Parameter */); + var parameter = createNode(143 /* Parameter */); parameter.type = parseJSDocType(); - if (parseOptional(56 /* EqualsToken */)) { + if (parseOptional(57 /* EqualsToken */)) { // TODO(rbuckton): Can this be changed to SyntaxKind.QuestionToken? - parameter.questionToken = createNode(56 /* EqualsToken */); + parameter.questionToken = createNode(57 /* EqualsToken */); } return finishNode(parameter); } function parseJSDocTypeReference() { var result = createNode(267 /* JSDocTypeReference */); result.name = parseSimplePropertyName(); - if (token() === 25 /* LessThanToken */) { + if (token() === 26 /* LessThanToken */) { result.typeArguments = parseTypeArguments(); } else { - while (parseOptional(21 /* DotToken */)) { - if (token() === 25 /* LessThanToken */) { + while (parseOptional(22 /* DotToken */)) { + if (token() === 26 /* LessThanToken */) { result.typeArguments = parseTypeArguments(); break; } @@ -18144,7 +18198,7 @@ var ts; var typeArguments = parseDelimitedList(23 /* JSDocTypeArguments */, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); - parseExpected(27 /* GreaterThanToken */); + parseExpected(28 /* GreaterThanToken */); return typeArguments; } function checkForEmptyTypeArgumentList(typeArguments) { @@ -18155,7 +18209,7 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(139 /* QualifiedName */, left.pos); + var result = createNode(140 /* QualifiedName */, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); @@ -18176,7 +18230,7 @@ var ts; nextToken(); result.types = parseDelimitedList(25 /* JSDocTupleTypes */, parseJSDocType); checkForTrailingComma(result.types); - parseExpected(20 /* CloseBracketToken */); + parseExpected(21 /* CloseBracketToken */); return finishNode(result); } function checkForTrailingComma(list) { @@ -18189,13 +18243,13 @@ var ts; var result = createNode(261 /* JSDocUnionType */); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); - parseExpected(18 /* CloseParenToken */); + parseExpected(19 /* CloseParenToken */); return finishNode(result); } function parseJSDocTypeList(firstType) { ts.Debug.assert(!!firstType); var types = createNodeArray([firstType], firstType.pos); - while (parseOptional(47 /* BarToken */)) { + while (parseOptional(48 /* BarToken */)) { types.push(parseJSDocType()); } types.end = scanner.getStartPos(); @@ -18224,12 +18278,12 @@ var ts; // Foo // Foo(?= // (?| - if (token() === 24 /* CommaToken */ || - token() === 16 /* CloseBraceToken */ || - token() === 18 /* CloseParenToken */ || - token() === 27 /* GreaterThanToken */ || - token() === 56 /* EqualsToken */ || - token() === 47 /* BarToken */) { + if (token() === 25 /* CommaToken */ || + token() === 17 /* CloseBraceToken */ || + token() === 19 /* CloseParenToken */ || + token() === 28 /* GreaterThanToken */ || + token() === 57 /* EqualsToken */ || + token() === 48 /* BarToken */) { var result = createNode(259 /* JSDocUnknownType */, pos); return finishNode(result); } @@ -18240,7 +18294,7 @@ var ts; } } function parseIsolatedJSDocComment(content, start, length) { - initializeState("file.js", content, 2 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); + initializeState(content, 4 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); sourceFile = { languageVariant: 0 /* Standard */, text: content }; var jsDoc = parseJSDocCommentWorker(start, length); var diagnostics = parseDiagnostics; @@ -18309,7 +18363,7 @@ var ts; } while (token() !== 1 /* EndOfFileToken */) { switch (token()) { - case 55 /* AtToken */: + case 56 /* AtToken */: if (state === 0 /* BeginningOfLine */ || state === 1 /* SawAsterisk */) { removeTrailingNewlines(comments); parseTag(indent); @@ -18330,7 +18384,7 @@ var ts; state = 0 /* BeginningOfLine */; indent = 0; break; - case 37 /* AsteriskToken */: + case 38 /* AsteriskToken */: var asterisk = scanner.getTokenText(); if (state === 1 /* SawAsterisk */) { // If we've already seen an asterisk, then we can no longer parse a tag on this line @@ -18343,7 +18397,7 @@ var ts; indent += asterisk.length; } break; - case 69 /* Identifier */: + case 70 /* Identifier */: // Anything else is doc comment text. We just save it. Because it // wasn't a tag, we can no longer parse a tag on this line until we hit the next // line break. @@ -18404,8 +18458,8 @@ var ts; } } function parseTag(indent) { - ts.Debug.assert(token() === 55 /* AtToken */); - var atToken = createNode(55 /* AtToken */, scanner.getTokenPos()); + ts.Debug.assert(token() === 56 /* AtToken */); + var atToken = createNode(56 /* AtToken */, scanner.getTokenPos()); atToken.end = scanner.getTextPos(); nextJSDocToken(); var tagName = parseJSDocIdentifierName(); @@ -18457,7 +18511,7 @@ var ts; comments.push(text); indent += text.length; } - while (token() !== 55 /* AtToken */ && token() !== 1 /* EndOfFileToken */) { + while (token() !== 56 /* AtToken */ && token() !== 1 /* EndOfFileToken */) { switch (token()) { case 4 /* NewLineTrivia */: if (state >= 1 /* SawAsterisk */) { @@ -18466,7 +18520,7 @@ var ts; } indent = 0; break; - case 55 /* AtToken */: + case 56 /* AtToken */: // Done break; case 5 /* WhitespaceTrivia */: @@ -18482,7 +18536,7 @@ var ts; indent += whitespace.length; } break; - case 37 /* AsteriskToken */: + case 38 /* AsteriskToken */: if (state === 0 /* BeginningOfLine */) { // leading asterisks start recording on the *next* (non-whitespace) token state = 1 /* SawAsterisk */; @@ -18495,7 +18549,7 @@ var ts; pushComment(scanner.getTokenText()); break; } - if (token() === 55 /* AtToken */) { + if (token() === 56 /* AtToken */) { // Done break; } @@ -18524,7 +18578,7 @@ var ts; function tryParseTypeExpression() { return tryParse(function () { skipWhitespace(); - if (token() !== 15 /* OpenBraceToken */) { + if (token() !== 16 /* OpenBraceToken */) { return undefined; } return parseJSDocTypeExpression(); @@ -18536,15 +18590,15 @@ var ts; var name; var isBracketed; // Looking for something like '[foo]' or 'foo' - if (parseOptionalToken(19 /* OpenBracketToken */)) { + if (parseOptionalToken(20 /* OpenBracketToken */)) { name = parseJSDocIdentifierName(); skipWhitespace(); isBracketed = true; // May have an optional default, e.g. '[foo = 42]' - if (parseOptionalToken(56 /* EqualsToken */)) { + if (parseOptionalToken(57 /* EqualsToken */)) { parseExpression(); } - parseExpected(20 /* CloseBracketToken */); + parseExpected(21 /* CloseBracketToken */); } else if (ts.tokenIsIdentifierOrKeyword(token())) { name = parseJSDocIdentifierName(); @@ -18621,7 +18675,7 @@ var ts; if (typeExpression) { if (typeExpression.type.kind === 267 /* JSDocTypeReference */) { var jsDocTypeReference = typeExpression.type; - if (jsDocTypeReference.name.kind === 69 /* Identifier */) { + if (jsDocTypeReference.name.kind === 70 /* Identifier */) { var name_11 = jsDocTypeReference.name; if (name_11.text === "Object") { typedefTag.jsDocTypeLiteral = scanChildTags(); @@ -18645,7 +18699,7 @@ var ts; while (token() !== 1 /* EndOfFileToken */ && !parentTagTerminated) { nextJSDocToken(); switch (token()) { - case 55 /* AtToken */: + case 56 /* AtToken */: if (canParseTag) { parentTagTerminated = !tryParseChildTag(jsDocTypeLiteral); if (!parentTagTerminated) { @@ -18659,13 +18713,13 @@ var ts; canParseTag = true; seenAsterisk = false; break; - case 37 /* AsteriskToken */: + case 38 /* AsteriskToken */: if (seenAsterisk) { canParseTag = false; } seenAsterisk = true; break; - case 69 /* Identifier */: + case 70 /* Identifier */: canParseTag = false; case 1 /* EndOfFileToken */: break; @@ -18676,8 +18730,8 @@ var ts; } } function tryParseChildTag(parentTag) { - ts.Debug.assert(token() === 55 /* AtToken */); - var atToken = createNode(55 /* AtToken */, scanner.getStartPos()); + ts.Debug.assert(token() === 56 /* AtToken */); + var atToken = createNode(56 /* AtToken */, scanner.getStartPos()); atToken.end = scanner.getTextPos(); nextJSDocToken(); var tagName = parseJSDocIdentifierName(); @@ -18717,11 +18771,11 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(141 /* TypeParameter */, name_12.pos); + var typeParameter = createNode(142 /* TypeParameter */, name_12.pos); typeParameter.name = name_12; finishNode(typeParameter); typeParameters.push(typeParameter); - if (token() === 24 /* CommaToken */) { + if (token() === 25 /* CommaToken */) { nextJSDocToken(); skipWhitespace(); } @@ -18750,7 +18804,7 @@ var ts; } var pos = scanner.getTokenPos(); var end = scanner.getTextPos(); - var result = createNode(69 /* Identifier */, pos); + var result = createNode(70 /* Identifier */, pos); result.text = content.substring(pos, end); finishNode(result, end); nextJSDocToken(); @@ -18868,8 +18922,8 @@ var ts; array._children = undefined; array.pos += delta; array.end += delta; - for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { - var node = array_8[_i]; + for (var _i = 0, array_9 = array; _i < array_9.length; _i++) { + var node = array_9[_i]; visitNode(node); } } @@ -18878,7 +18932,7 @@ var ts; switch (node.kind) { case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - case 69 /* Identifier */: + case 70 /* Identifier */: return true; } return false; @@ -19006,8 +19060,8 @@ var ts; array._children = undefined; // Adjust the pos or end (or both) of the intersecting array accordingly. adjustIntersectingElement(array, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta); - for (var _i = 0, array_9 = array; _i < array_9.length; _i++) { - var node = array_9[_i]; + for (var _i = 0, array_10 = array; _i < array_10.length; _i++) { + var node = array_10[_i]; visitNode(node); } return; @@ -19249,16 +19303,16 @@ var ts; function getModuleInstanceState(node) { // A module is uninstantiated if it contains only // 1. interface declarations, type alias declarations - if (node.kind === 222 /* InterfaceDeclaration */ || node.kind === 223 /* TypeAliasDeclaration */) { + if (node.kind === 223 /* InterfaceDeclaration */ || node.kind === 224 /* TypeAliasDeclaration */) { return 0 /* NonInstantiated */; } else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if ((node.kind === 230 /* ImportDeclaration */ || node.kind === 229 /* ImportEqualsDeclaration */) && !(ts.hasModifier(node, 1 /* Export */))) { + else if ((node.kind === 231 /* ImportDeclaration */ || node.kind === 230 /* ImportEqualsDeclaration */) && !(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } - else if (node.kind === 226 /* ModuleBlock */) { + else if (node.kind === 227 /* ModuleBlock */) { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -19277,7 +19331,7 @@ var ts; }); return state_1; } - else if (node.kind === 225 /* ModuleDeclaration */) { + else if (node.kind === 226 /* ModuleDeclaration */) { var body = node.body; return body ? getModuleInstanceState(body) : 1 /* Instantiated */; } @@ -19415,7 +19469,7 @@ var ts; if (symbolFlags & 107455 /* Value */) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 225 /* ModuleDeclaration */)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 226 /* ModuleDeclaration */)) { // other kinds of value declarations take precedence over modules symbol.valueDeclaration = node; } @@ -19428,7 +19482,7 @@ var ts; if (ts.isAmbientModule(node)) { return ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + node.name.text + "\""; } - if (node.name.kind === 140 /* ComputedPropertyName */) { + if (node.name.kind === 141 /* ComputedPropertyName */) { var nameExpression = node.name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteral(nameExpression.kind)) { @@ -19440,21 +19494,21 @@ var ts; return node.name.text; } switch (node.kind) { - case 148 /* Constructor */: + case 149 /* Constructor */: return "__constructor"; - case 156 /* FunctionType */: - case 151 /* CallSignature */: + case 157 /* FunctionType */: + case 152 /* CallSignature */: return "__call"; - case 157 /* ConstructorType */: - case 152 /* ConstructSignature */: + case 158 /* ConstructorType */: + case 153 /* ConstructSignature */: return "__new"; - case 153 /* IndexSignature */: + case 154 /* IndexSignature */: return "__index"; - case 236 /* ExportDeclaration */: + case 237 /* ExportDeclaration */: return "__export"; - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: return node.isExportEquals ? "export=" : "default"; - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: switch (ts.getSpecialPropertyAssignmentKind(node)) { case 2 /* ModuleExports */: // module.exports = ... @@ -19469,12 +19523,12 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 220 /* FunctionDeclaration */: - case 221 /* ClassDeclaration */: + case 221 /* FunctionDeclaration */: + case 222 /* ClassDeclaration */: return ts.hasModifier(node, 512 /* Default */) ? "default" : undefined; case 269 /* JSDocFunctionType */: return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; - case 142 /* Parameter */: + case 143 /* Parameter */: // Parameters with names are handled at the top of this function. Parameters // without names can only come from JSDocFunctionTypes. ts.Debug.assert(node.parent.kind === 269 /* JSDocFunctionType */); @@ -19484,10 +19538,10 @@ var ts; case 279 /* JSDocTypedefTag */: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 200 /* VariableStatement */) { + if (parentNode && parentNode.kind === 201 /* VariableStatement */) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; - if (nameIdentifier.kind === 69 /* Identifier */) { + if (nameIdentifier.kind === 70 /* Identifier */) { nameFromParentNode = nameIdentifier.text; } } @@ -19571,7 +19625,7 @@ var ts; // 1. multiple export default of class declaration or function declaration by checking NodeFlags.Default // 2. multiple export default of export assignment. This one doesn't have NodeFlags.Default on (as export default doesn't considered as modifiers) if (symbol.declarations && symbol.declarations.length && - (isDefaultExport || (node.kind === 235 /* ExportAssignment */ && !node.isExportEquals))) { + (isDefaultExport || (node.kind === 236 /* ExportAssignment */ && !node.isExportEquals))) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -19591,7 +19645,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 8388608 /* Alias */) { - if (node.kind === 238 /* ExportSpecifier */ || (node.kind === 229 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 239 /* ExportSpecifier */ || (node.kind === 230 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -19753,64 +19807,64 @@ var ts; return; } switch (node.kind) { - case 205 /* WhileStatement */: + case 206 /* WhileStatement */: bindWhileStatement(node); break; - case 204 /* DoStatement */: + case 205 /* DoStatement */: bindDoStatement(node); break; - case 206 /* ForStatement */: + case 207 /* ForStatement */: bindForStatement(node); break; - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 203 /* IfStatement */: + case 204 /* IfStatement */: bindIfStatement(node); break; - case 211 /* ReturnStatement */: - case 215 /* ThrowStatement */: + case 212 /* ReturnStatement */: + case 216 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 210 /* BreakStatement */: - case 209 /* ContinueStatement */: + case 211 /* BreakStatement */: + case 210 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 216 /* TryStatement */: + case 217 /* TryStatement */: bindTryStatement(node); break; - case 213 /* SwitchStatement */: + case 214 /* SwitchStatement */: bindSwitchStatement(node); break; - case 227 /* CaseBlock */: + case 228 /* CaseBlock */: bindCaseBlock(node); break; case 249 /* CaseClause */: bindCaseClause(node); break; - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: bindLabeledStatement(node); break; - case 185 /* PrefixUnaryExpression */: + case 186 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 186 /* PostfixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: bindBinaryExpressionFlow(node); break; - case 181 /* DeleteExpression */: + case 182 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 218 /* VariableDeclaration */: + case 219 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 174 /* CallExpression */: + case 175 /* CallExpression */: bindCallExpressionFlow(node); break; default: @@ -19820,25 +19874,25 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 69 /* Identifier */: - case 97 /* ThisKeyword */: - case 172 /* PropertyAccessExpression */: + case 70 /* Identifier */: + case 98 /* ThisKeyword */: + case 173 /* PropertyAccessExpression */: return isNarrowableReference(expr); - case 174 /* CallExpression */: + case 175 /* CallExpression */: return hasNarrowableArgument(expr); - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return isNarrowingExpression(expr.expression); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 185 /* PrefixUnaryExpression */: - return expr.operator === 49 /* ExclamationToken */ && isNarrowingExpression(expr.operand); + case 186 /* PrefixUnaryExpression */: + return expr.operator === 50 /* ExclamationToken */ && isNarrowingExpression(expr.operand); } return false; } function isNarrowableReference(expr) { - return expr.kind === 69 /* Identifier */ || - expr.kind === 97 /* ThisKeyword */ || - expr.kind === 172 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); + return expr.kind === 70 /* Identifier */ || + expr.kind === 98 /* ThisKeyword */ || + expr.kind === 173 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -19849,41 +19903,41 @@ var ts; } } } - if (expr.expression.kind === 172 /* PropertyAccessExpression */ && + if (expr.expression.kind === 173 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression.expression)) { return true; } return false; } function isNarrowingTypeofOperands(expr1, expr2) { - return expr1.kind === 182 /* TypeOfExpression */ && isNarrowableOperand(expr1.expression) && expr2.kind === 9 /* StringLiteral */; + return expr1.kind === 183 /* TypeOfExpression */ && isNarrowableOperand(expr1.expression) && expr2.kind === 9 /* StringLiteral */; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 56 /* EqualsToken */: + case 57 /* EqualsToken */: return isNarrowableReference(expr.left); - case 30 /* EqualsEqualsToken */: - case 31 /* ExclamationEqualsToken */: - case 32 /* EqualsEqualsEqualsToken */: - case 33 /* ExclamationEqualsEqualsToken */: + case 31 /* EqualsEqualsToken */: + case 32 /* ExclamationEqualsToken */: + case 33 /* EqualsEqualsEqualsToken */: + case 34 /* ExclamationEqualsEqualsToken */: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 91 /* InstanceOfKeyword */: + case 92 /* InstanceOfKeyword */: return isNarrowableOperand(expr.left); - case 24 /* CommaToken */: + case 25 /* CommaToken */: return isNarrowingExpression(expr.right); } return false; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: switch (expr.operatorToken.kind) { - case 56 /* EqualsToken */: + case 57 /* EqualsToken */: return isNarrowableOperand(expr.left); - case 24 /* CommaToken */: + case 25 /* CommaToken */: return isNarrowableOperand(expr.right); } } @@ -19903,7 +19957,7 @@ var ts; } function setFlowNodeReferenced(flow) { // On first reference we set the Referenced flag, thereafter we set the Shared flag - flow.flags |= flow.flags & 256 /* Referenced */ ? 512 /* Shared */ : 256 /* Referenced */; + flow.flags |= flow.flags & 512 /* Referenced */ ? 1024 /* Shared */ : 512 /* Referenced */; } function addAntecedent(label, antecedent) { if (!(antecedent.flags & 1 /* Unreachable */) && !ts.contains(label.antecedents, antecedent)) { @@ -19918,8 +19972,8 @@ var ts; if (!expression) { return flags & 32 /* TrueCondition */ ? antecedent : unreachableFlow; } - if (expression.kind === 99 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || - expression.kind === 84 /* FalseKeyword */ && flags & 32 /* TrueCondition */) { + if (expression.kind === 100 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || + expression.kind === 85 /* FalseKeyword */ && flags & 32 /* TrueCondition */) { return unreachableFlow; } if (!isNarrowingExpression(expression)) { @@ -19953,6 +20007,14 @@ var ts; node: node }; } + function createFlowArrayMutation(antecedent, node) { + setFlowNodeReferenced(antecedent); + return { + flags: 256 /* ArrayMutation */, + antecedent: antecedent, + node: node + }; + } function finishFlowLabel(flow) { var antecedents = flow.antecedents; if (!antecedents) { @@ -19966,34 +20028,34 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 203 /* IfStatement */: - case 205 /* WhileStatement */: - case 204 /* DoStatement */: + case 204 /* IfStatement */: + case 206 /* WhileStatement */: + case 205 /* DoStatement */: return parent.expression === node; - case 206 /* ForStatement */: - case 188 /* ConditionalExpression */: + case 207 /* ForStatement */: + case 189 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 178 /* ParenthesizedExpression */) { + if (node.kind === 179 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 185 /* PrefixUnaryExpression */ && node.operator === 49 /* ExclamationToken */) { + else if (node.kind === 186 /* PrefixUnaryExpression */ && node.operator === 50 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 187 /* BinaryExpression */ && (node.operatorToken.kind === 51 /* AmpersandAmpersandToken */ || - node.operatorToken.kind === 52 /* BarBarToken */); + return node.kind === 188 /* BinaryExpression */ && (node.operatorToken.kind === 52 /* AmpersandAmpersandToken */ || + node.operatorToken.kind === 53 /* BarBarToken */); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 178 /* ParenthesizedExpression */ || - node.parent.kind === 185 /* PrefixUnaryExpression */ && - node.parent.operator === 49 /* ExclamationToken */) { + while (node.parent.kind === 179 /* ParenthesizedExpression */ || + node.parent.kind === 186 /* PrefixUnaryExpression */ && + node.parent.operator === 50 /* ExclamationToken */) { node = node.parent; } return !isStatementCondition(node) && !isLogicalExpression(node.parent); @@ -20066,7 +20128,7 @@ var ts; bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 219 /* VariableDeclarationList */) { + if (node.initializer.kind !== 220 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -20088,7 +20150,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 211 /* ReturnStatement */) { + if (node.kind === 212 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -20108,7 +20170,7 @@ var ts; return undefined; } function bindbreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 210 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 211 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -20128,24 +20190,41 @@ var ts; } } function bindTryStatement(node) { - var postFinallyLabel = createBranchLabel(); + var preFinallyLabel = createBranchLabel(); var preTryFlow = currentFlow; // TODO: Every statement in try block is potentially an exit point! bind(node.tryBlock); - addAntecedent(postFinallyLabel, currentFlow); + addAntecedent(preFinallyLabel, currentFlow); + var flowAfterTry = currentFlow; + var flowAfterCatch = unreachableFlow; if (node.catchClause) { currentFlow = preTryFlow; bind(node.catchClause); - addAntecedent(postFinallyLabel, currentFlow); + addAntecedent(preFinallyLabel, currentFlow); + flowAfterCatch = currentFlow; } if (node.finallyBlock) { - currentFlow = preTryFlow; + // in finally flow is combined from pre-try/flow from try/flow from catch + // pre-flow is necessary to make sure that finally is reachable even if finally flows in both try and finally blocks are unreachable + addAntecedent(preFinallyLabel, preTryFlow); + currentFlow = finishFlowLabel(preFinallyLabel); bind(node.finallyBlock); + // if flow after finally is unreachable - keep it + // otherwise check if flows after try and after catch are unreachable + // if yes - convert current flow to unreachable + // i.e. + // try { return "1" } finally { console.log(1); } + // console.log(2); // this line should be unreachable even if flow falls out of finally block + if (!(currentFlow.flags & 1 /* Unreachable */)) { + if ((flowAfterTry.flags & 1 /* Unreachable */) && (flowAfterCatch.flags & 1 /* Unreachable */)) { + currentFlow = flowAfterTry === reportedUnreachableFlow || flowAfterCatch === reportedUnreachableFlow + ? reportedUnreachableFlow + : unreachableFlow; + } + } } - // if try statement has finally block and flow after finally block is unreachable - keep it - // otherwise use whatever flow was accumulated at postFinallyLabel - if (!node.finallyBlock || !(currentFlow.flags & 1 /* Unreachable */)) { - currentFlow = finishFlowLabel(postFinallyLabel); + else { + currentFlow = finishFlowLabel(preFinallyLabel); } } function bindSwitchStatement(node) { @@ -20224,7 +20303,7 @@ var ts; currentFlow = finishFlowLabel(postStatementLabel); } function bindDestructuringTargetFlow(node) { - if (node.kind === 187 /* BinaryExpression */ && node.operatorToken.kind === 56 /* EqualsToken */) { + if (node.kind === 188 /* BinaryExpression */ && node.operatorToken.kind === 57 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -20235,10 +20314,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 170 /* ArrayLiteralExpression */) { + else if (node.kind === 171 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 191 /* SpreadElementExpression */) { + if (e.kind === 192 /* SpreadElementExpression */) { bindAssignmentTargetFlow(e.expression); } else { @@ -20246,7 +20325,7 @@ var ts; } } } - else if (node.kind === 171 /* ObjectLiteralExpression */) { + else if (node.kind === 172 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; if (p.kind === 253 /* PropertyAssignment */) { @@ -20260,7 +20339,7 @@ var ts; } function bindLogicalExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 51 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 52 /* AmpersandAmpersandToken */) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -20271,7 +20350,7 @@ var ts; bindCondition(node.right, trueTarget, falseTarget); } function bindPrefixUnaryExpressionFlow(node) { - if (node.operator === 49 /* ExclamationToken */) { + if (node.operator === 50 /* ExclamationToken */) { var saveTrueTarget = currentTrueTarget; currentTrueTarget = currentFalseTarget; currentFalseTarget = saveTrueTarget; @@ -20281,20 +20360,20 @@ var ts; } else { ts.forEachChild(node, bind); - if (node.operator === 41 /* PlusPlusToken */ || node.operator === 42 /* MinusMinusToken */) { + if (node.operator === 42 /* PlusPlusToken */ || node.operator === 43 /* MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } } function bindPostfixUnaryExpressionFlow(node) { ts.forEachChild(node, bind); - if (node.operator === 41 /* PlusPlusToken */ || node.operator === 42 /* MinusMinusToken */) { + if (node.operator === 42 /* PlusPlusToken */ || node.operator === 43 /* MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } function bindBinaryExpressionFlow(node) { var operator = node.operatorToken.kind; - if (operator === 51 /* AmpersandAmpersandToken */ || operator === 52 /* BarBarToken */) { + if (operator === 52 /* AmpersandAmpersandToken */ || operator === 53 /* BarBarToken */) { if (isTopLevelLogicalExpression(node)) { var postExpressionLabel = createBranchLabel(); bindLogicalExpression(node, postExpressionLabel, postExpressionLabel); @@ -20306,14 +20385,20 @@ var ts; } else { ts.forEachChild(node, bind); - if (operator === 56 /* EqualsToken */ && !ts.isAssignmentTarget(node)) { + if (operator === 57 /* EqualsToken */ && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); + if (node.left.kind === 174 /* ElementAccessExpression */) { + var elementAccess = node.left; + if (isNarrowableOperand(elementAccess.expression)) { + currentFlow = createFlowArrayMutation(currentFlow, node); + } + } } } } function bindDeleteExpressionFlow(node) { ts.forEachChild(node, bind); - if (node.expression.kind === 172 /* PropertyAccessExpression */) { + if (node.expression.kind === 173 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -20344,7 +20429,7 @@ var ts; } function bindVariableDeclarationFlow(node) { ts.forEachChild(node, bind); - if (node.initializer || node.parent.parent.kind === 207 /* ForInStatement */ || node.parent.parent.kind === 208 /* ForOfStatement */) { + if (node.initializer || node.parent.parent.kind === 208 /* ForInStatement */ || node.parent.parent.kind === 209 /* ForOfStatement */) { bindInitializedVariableFlow(node); } } @@ -20353,10 +20438,10 @@ var ts; // an immediately invoked function expression (IIFE). Initialize the flowNode property to // the current control flow (which includes evaluation of the IIFE arguments). var expr = node.expression; - while (expr.kind === 178 /* ParenthesizedExpression */) { + while (expr.kind === 179 /* ParenthesizedExpression */) { expr = expr.expression; } - if (expr.kind === 179 /* FunctionExpression */ || expr.kind === 180 /* ArrowFunction */) { + if (expr.kind === 180 /* FunctionExpression */ || expr.kind === 181 /* ArrowFunction */) { ts.forEach(node.typeArguments, bind); ts.forEach(node.arguments, bind); bind(node.expression); @@ -20364,54 +20449,60 @@ var ts; else { ts.forEachChild(node, bind); } + if (node.expression.kind === 173 /* PropertyAccessExpression */) { + var propertyAccess = node.expression; + if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { + currentFlow = createFlowArrayMutation(currentFlow, node); + } + } } function getContainerFlags(node) { switch (node.kind) { - case 192 /* ClassExpression */: - case 221 /* ClassDeclaration */: - case 224 /* EnumDeclaration */: - case 171 /* ObjectLiteralExpression */: - case 159 /* TypeLiteral */: + case 193 /* ClassExpression */: + case 222 /* ClassDeclaration */: + case 225 /* EnumDeclaration */: + case 172 /* ObjectLiteralExpression */: + case 160 /* TypeLiteral */: case 281 /* JSDocTypeLiteral */: case 265 /* JSDocRecordType */: return 1 /* IsContainer */; - case 222 /* InterfaceDeclaration */: + case 223 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; case 269 /* JSDocFunctionType */: - case 225 /* ModuleDeclaration */: - case 223 /* TypeAliasDeclaration */: + case 226 /* ModuleDeclaration */: + case 224 /* TypeAliasDeclaration */: return 1 /* IsContainer */ | 32 /* HasLocals */; case 256 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 147 /* MethodDeclaration */: + case 148 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } - case 148 /* Constructor */: - case 220 /* FunctionDeclaration */: - case 146 /* MethodSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: - case 156 /* FunctionType */: - case 157 /* ConstructorType */: + case 149 /* Constructor */: + case 221 /* FunctionDeclaration */: + case 147 /* MethodSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 226 /* ModuleBlock */: + case 227 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; case 252 /* CatchClause */: - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: - case 227 /* CaseBlock */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: + case 228 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 199 /* Block */: + case 200 /* 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. Otherwise 'x' // would not appear to be a redeclaration of a block scoped local in the following @@ -20448,18 +20539,18 @@ 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 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); case 256 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 192 /* ClassExpression */: - case 221 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 222 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 159 /* TypeLiteral */: - case 171 /* ObjectLiteralExpression */: - case 222 /* InterfaceDeclaration */: + case 160 /* TypeLiteral */: + case 172 /* ObjectLiteralExpression */: + case 223 /* InterfaceDeclaration */: case 265 /* JSDocRecordType */: case 281 /* JSDocTypeLiteral */: // Interface/Object-types always have their children added to the 'members' of @@ -20468,21 +20559,21 @@ var ts; // 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 156 /* FunctionType */: - case 157 /* ConstructorType */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: case 269 /* JSDocFunctionType */: - case 223 /* TypeAliasDeclaration */: + case 224 /* 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 @@ -20504,10 +20595,10 @@ var ts; } function hasExportDeclarations(node) { var body = node.kind === 256 /* SourceFile */ ? node : node.body; - if (body && (body.kind === 256 /* SourceFile */ || body.kind === 226 /* ModuleBlock */)) { + if (body && (body.kind === 256 /* SourceFile */ || body.kind === 227 /* ModuleBlock */)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 236 /* ExportDeclaration */ || stat.kind === 235 /* ExportAssignment */) { + if (stat.kind === 237 /* ExportDeclaration */ || stat.kind === 236 /* ExportAssignment */) { return true; } } @@ -20600,7 +20691,7 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.name.kind !== 69 /* Identifier */) { + if (prop.name.kind !== 70 /* Identifier */) { continue; } var identifier = prop.name; @@ -20612,7 +20703,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 === 253 /* PropertyAssignment */ || prop.kind === 254 /* ShorthandPropertyAssignment */ || prop.kind === 147 /* MethodDeclaration */ + var currentKind = prop.kind === 253 /* PropertyAssignment */ || prop.kind === 254 /* ShorthandPropertyAssignment */ || prop.kind === 148 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen[identifier.text]; @@ -20634,7 +20725,7 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; case 256 /* SourceFile */: @@ -20658,8 +20749,8 @@ var ts; // check for reserved words used as identifiers in strict mode code. function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 106 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 114 /* LastFutureReservedWord */ && + node.originalKeywordKind >= 107 /* FirstFutureReservedWord */ && + node.originalKeywordKind <= 115 /* LastFutureReservedWord */ && !ts.isIdentifierName(node) && !ts.isInAmbientContext(node)) { // Report error only if there are no parse errors in file @@ -20695,7 +20786,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 69 /* Identifier */) { + if (inStrictMode && node.expression.kind === 70 /* 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_2 = ts.getErrorSpanForNode(file, node.expression); @@ -20703,11 +20794,11 @@ var ts; } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 69 /* Identifier */ && + return node.kind === 70 /* Identifier */ && (node.text === "eval" || node.text === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 69 /* Identifier */) { + if (name && name.kind === 70 /* 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 @@ -20746,10 +20837,10 @@ var ts; return ts.Diagnostics.Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5; } function checkStrictModeFunctionDeclaration(node) { - if (languageVersion < 2 /* ES6 */) { + if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration if (blockScopeContainer.kind !== 256 /* SourceFile */ && - blockScopeContainer.kind !== 225 /* ModuleDeclaration */ && + blockScopeContainer.kind !== 226 /* ModuleDeclaration */ && !ts.isFunctionLike(blockScopeContainer)) { // We check first if the name is inside class declaration or class expression; if so give explicit message // otherwise report generic error message. @@ -20775,7 +20866,7 @@ var ts; function checkStrictModePrefixUnaryExpression(node) { // Grammar checking if (inStrictMode) { - if (node.operator === 41 /* PlusPlusToken */ || node.operator === 42 /* MinusMinusToken */) { + if (node.operator === 42 /* PlusPlusToken */ || node.operator === 43 /* MinusMinusToken */) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -20815,7 +20906,7 @@ var ts; // the current 'container' node when it changes. This helps us know which symbol table // a local should go into for example. Since terminal nodes are known not to have // children, as an optimization we don't process those. - if (node.kind > 138 /* LastToken */) { + if (node.kind > 139 /* LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -20856,18 +20947,18 @@ var ts; function bindWorker(node) { switch (node.kind) { /* Strict mode checks */ - case 69 /* Identifier */: - case 97 /* ThisKeyword */: + case 70 /* Identifier */: + case 98 /* ThisKeyword */: if (currentFlow && (ts.isExpression(node) || parent.kind === 254 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } break; - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: if (ts.isInJavaScriptFile(node)) { var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { @@ -20893,30 +20984,30 @@ var ts; return checkStrictModeBinaryExpression(node); case 252 /* CatchClause */: return checkStrictModeCatchClause(node); - case 181 /* DeleteExpression */: + case 182 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 186 /* PostfixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 185 /* PrefixUnaryExpression */: + case 186 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 212 /* WithStatement */: + case 213 /* WithStatement */: return checkStrictModeWithStatement(node); - case 165 /* ThisType */: + case 166 /* ThisType */: seenThisKeyword = true; return; - case 154 /* TypePredicate */: + case 155 /* TypePredicate */: return checkTypePredicate(node); - case 141 /* TypeParameter */: + case 142 /* TypeParameter */: return declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 530920 /* TypeParameterExcludes */); - case 142 /* Parameter */: + case 143 /* Parameter */: return bindParameter(node); - case 218 /* VariableDeclaration */: - case 169 /* BindingElement */: + case 219 /* VariableDeclaration */: + case 170 /* BindingElement */: return bindVariableDeclarationOrBindingElement(node); - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: case 266 /* JSDocRecordMember */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); case 280 /* JSDocPropertyTag */: @@ -20929,90 +21020,90 @@ var ts; case 247 /* JsxSpreadAttribute */: emitFlags |= 16384 /* HasJsxSpreadAttributes */; return; - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 148 /* MethodDeclaration */: + case 147 /* 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) ? 0 /* PropertyExcludes */ : 99263 /* MethodExcludes */); - case 220 /* FunctionDeclaration */: + case 221 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 148 /* Constructor */: + case 149 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 149 /* GetAccessor */: + case 150 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 41919 /* GetAccessorExcludes */); - case 150 /* SetAccessor */: + case 151 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */); - case 156 /* FunctionType */: - case 157 /* ConstructorType */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: case 269 /* JSDocFunctionType */: return bindFunctionOrConstructorType(node); - case 159 /* TypeLiteral */: + case 160 /* TypeLiteral */: case 281 /* JSDocTypeLiteral */: case 265 /* JSDocRecordType */: return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type"); - case 171 /* ObjectLiteralExpression */: + case 172 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: return bindFunctionExpression(node); - case 174 /* CallExpression */: + case 175 /* CallExpression */: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; // Members of classes, interfaces, and modules - case 192 /* ClassExpression */: - case 221 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 222 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 222 /* InterfaceDeclaration */: + case 223 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 792968 /* InterfaceExcludes */); case 279 /* JSDocTypedefTag */: - case 223 /* TypeAliasDeclaration */: + case 224 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793064 /* TypeAliasExcludes */); - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Imports and exports - case 229 /* ImportEqualsDeclaration */: - case 232 /* NamespaceImport */: - case 234 /* ImportSpecifier */: - case 238 /* ExportSpecifier */: + case 230 /* ImportEqualsDeclaration */: + case 233 /* NamespaceImport */: + case 235 /* ImportSpecifier */: + case 239 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); - case 228 /* NamespaceExportDeclaration */: + case 229 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 231 /* ImportClause */: + case 232 /* ImportClause */: return bindImportClause(node); - case 236 /* ExportDeclaration */: + case 237 /* ExportDeclaration */: return bindExportDeclaration(node); - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: return bindExportAssignment(node); case 256 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 199 /* Block */: + case 200 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // Fall through - case 226 /* ModuleBlock */: + case 227 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); } } function checkTypePredicate(node) { var parameterName = node.parameterName, type = node.type; - if (parameterName && parameterName.kind === 69 /* Identifier */) { + if (parameterName && parameterName.kind === 70 /* Identifier */) { checkStrictModeIdentifier(parameterName); } - if (parameterName && parameterName.kind === 165 /* ThisType */) { + if (parameterName && parameterName.kind === 166 /* ThisType */) { seenThisKeyword = true; } bind(type); @@ -21035,7 +21126,7 @@ var ts; // An export default clause with an expression exports a value // We want to exclude both class and function here, this is necessary to issue an error when there are both // default export-assignment and default export function and class declaration. - var flags = node.kind === 235 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 236 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) ? 8388608 /* Alias */ : 4 /* Property */; declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 /* Property */ | 8388608 /* AliasExcludes */ | 32 /* Class */ | 16 /* Function */); @@ -21081,7 +21172,9 @@ var ts; function setCommonJsModuleIndicator(node) { if (!file.commonJsModuleIndicator) { file.commonJsModuleIndicator = node; - bindSourceFileAsExternalModule(); + if (!file.externalModuleIndicator) { + bindSourceFileAsExternalModule(); + } } } function bindExportsPropertyAssignment(node) { @@ -21098,12 +21191,12 @@ var ts; function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJavaScriptFile(node)); // Declare a 'member' if the container is an ES5 class or ES6 constructor - if (container.kind === 220 /* FunctionDeclaration */ || container.kind === 179 /* FunctionExpression */) { + if (container.kind === 221 /* FunctionDeclaration */ || container.kind === 180 /* FunctionExpression */) { container.symbol.members = container.symbol.members || ts.createMap(); // It's acceptable for multiple 'this' assignments of the same identifier to occur declareSymbol(container.symbol.members, container.symbol, node, 4 /* Property */, 0 /* PropertyExcludes */ & ~4 /* Property */); } - else if (container.kind === 148 /* Constructor */) { + else if (container.kind === 149 /* Constructor */) { // this.foo assignment in a JavaScript class // Bind this property to the containing class var saveContainer = container; @@ -21154,7 +21247,7 @@ var ts; emitFlags |= 2048 /* HasDecorators */; } } - if (node.kind === 221 /* ClassDeclaration */) { + if (node.kind === 222 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899519 /* ClassExcludes */); } else { @@ -21298,13 +21391,13 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 201 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 202 /* EmptyStatement */) || // report error on class declarations - node.kind === 221 /* ClassDeclaration */ || + node.kind === 222 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 225 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 226 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || // report error on regular enums and const enums if preserveConstEnums is set - (node.kind === 224 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + (node.kind === 225 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; // unreachable code is reported if @@ -21318,7 +21411,7 @@ var ts; // On the other side we do want to report errors on non-initialized 'lets' because of TDZ var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 200 /* VariableStatement */ || + (node.kind !== 201 /* VariableStatement */ || ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */ || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -21338,52 +21431,54 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 174 /* CallExpression */: + case 175 /* CallExpression */: return computeCallExpression(node, subtreeFlags); - case 225 /* ModuleDeclaration */: + case 176 /* NewExpression */: + return computeNewExpression(node, subtreeFlags); + case 226 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 202 /* ExpressionStatement */: + case 203 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); - case 142 /* Parameter */: + case 143 /* Parameter */: return computeParameter(node, subtreeFlags); - case 180 /* ArrowFunction */: + case 181 /* ArrowFunction */: return computeArrowFunction(node, subtreeFlags); - case 179 /* FunctionExpression */: + case 180 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 220 /* FunctionDeclaration */: + case 221 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 218 /* VariableDeclaration */: + case 219 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 219 /* VariableDeclarationList */: + case 220 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); - case 192 /* ClassExpression */: + case 193 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); case 251 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 148 /* Constructor */: + case 149 /* Constructor */: return computeConstructor(node, subtreeFlags); - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: return computePropertyDeclaration(node, subtreeFlags); - case 147 /* MethodDeclaration */: + case 148 /* MethodDeclaration */: return computeMethod(node, subtreeFlags); - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 229 /* ImportEqualsDeclaration */: + case 230 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -21394,44 +21489,60 @@ var ts; var transformFlags = subtreeFlags; var expression = node.expression; var expressionKind = expression.kind; - if (subtreeFlags & 262144 /* ContainsSpreadElementExpression */ + if (node.typeArguments) { + transformFlags |= 3 /* AssertTypeScript */; + } + if (subtreeFlags & 1048576 /* ContainsSpreadElementExpression */ || isSuperOrSuperProperty(expression, expressionKind)) { // If the this node contains a SpreadElementExpression, or is a super call, then it is an ES6 // node. - transformFlags |= 192 /* AssertES6 */; + transformFlags |= 768 /* AssertES2015 */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~537133909 /* ArrayLiteralOrCallOrNewExcludes */; + return transformFlags & ~537922901 /* ArrayLiteralOrCallOrNewExcludes */; } function isSuperOrSuperProperty(node, kind) { switch (kind) { - case 95 /* SuperKeyword */: + case 96 /* SuperKeyword */: return true; - case 172 /* PropertyAccessExpression */: - case 173 /* ElementAccessExpression */: + case 173 /* PropertyAccessExpression */: + case 174 /* ElementAccessExpression */: var expression = node.expression; var expressionKind = expression.kind; - return expressionKind === 95 /* SuperKeyword */; + return expressionKind === 96 /* SuperKeyword */; } return false; } + function computeNewExpression(node, subtreeFlags) { + var transformFlags = subtreeFlags; + if (node.typeArguments) { + transformFlags |= 3 /* AssertTypeScript */; + } + if (subtreeFlags & 1048576 /* ContainsSpreadElementExpression */) { + // If the this node contains a SpreadElementExpression then it is an ES6 + // node. + transformFlags |= 768 /* AssertES2015 */; + } + node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; + return transformFlags & ~537922901 /* ArrayLiteralOrCallOrNewExcludes */; + } function computeBinaryExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 56 /* EqualsToken */ - && (leftKind === 171 /* ObjectLiteralExpression */ - || leftKind === 170 /* ArrayLiteralExpression */)) { + if (operatorTokenKind === 57 /* EqualsToken */ + && (leftKind === 172 /* ObjectLiteralExpression */ + || leftKind === 171 /* ArrayLiteralExpression */)) { // Destructuring assignments are ES6 syntax. - transformFlags |= 192 /* AssertES6 */ | 256 /* DestructuringAssignment */; + transformFlags |= 768 /* AssertES2015 */ | 1024 /* DestructuringAssignment */; } - else if (operatorTokenKind === 38 /* AsteriskAsteriskToken */ - || operatorTokenKind === 60 /* AsteriskAsteriskEqualsToken */) { - // Exponentiation is ES7 syntax. - transformFlags |= 48 /* AssertES7 */; + else if (operatorTokenKind === 39 /* AsteriskAsteriskToken */ + || operatorTokenKind === 61 /* AsteriskAsteriskEqualsToken */) { + // Exponentiation is ES2016 syntax. + transformFlags |= 192 /* AssertES2016 */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536871765 /* NodeExcludes */; + return transformFlags & ~536874325 /* NodeExcludes */; } function computeParameter(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -21439,25 +21550,25 @@ var ts; var name = node.name; var initializer = node.initializer; var dotDotDotToken = node.dotDotDotToken; - // If the parameter has a question token, then it is TypeScript syntax. - if (node.questionToken) { - transformFlags |= 3 /* AssertTypeScript */; - } - // If the parameter's name is 'this', then it is TypeScript syntax. - if (subtreeFlags & 2048 /* ContainsDecorators */ || ts.isThisIdentifier(name)) { + // The '?' token, type annotations, decorators, and 'this' parameters are TypeSCript + // syntax. + if (node.questionToken + || node.type + || subtreeFlags & 8192 /* ContainsDecorators */ + || ts.isThisIdentifier(name)) { transformFlags |= 3 /* AssertTypeScript */; } // If a parameter has an accessibility modifier, then it is TypeScript syntax. if (modifierFlags & 92 /* ParameterPropertyModifier */) { - transformFlags |= 3 /* AssertTypeScript */ | 131072 /* ContainsParameterPropertyAssignments */; + transformFlags |= 3 /* AssertTypeScript */ | 524288 /* ContainsParameterPropertyAssignments */; } // If a parameter has an initializer, a binding pattern or a dotDotDot token, then // it is ES6 syntax and its container must emit default value assignments or parameter destructuring downlevel. - if (subtreeFlags & 2097152 /* ContainsBindingPattern */ || initializer || dotDotDotToken) { - transformFlags |= 192 /* AssertES6 */ | 65536 /* ContainsDefaultValueAssignments */; + if (subtreeFlags & 8388608 /* ContainsBindingPattern */ || initializer || dotDotDotToken) { + transformFlags |= 768 /* AssertES2015 */ | 262144 /* ContainsDefaultValueAssignments */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~538968917 /* ParameterExcludes */; + return transformFlags & ~545262933 /* ParameterExcludes */; } function computeParenthesizedExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -21467,17 +21578,17 @@ 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 (expressionKind === 195 /* AsExpression */ - || expressionKind === 177 /* TypeAssertionExpression */) { + if (expressionKind === 196 /* AsExpression */ + || expressionKind === 178 /* TypeAssertionExpression */) { transformFlags |= 3 /* AssertTypeScript */; } // If the expression of a ParenthesizedExpression is a destructuring assignment, // then the ParenthesizedExpression is a destructuring assignment. - if (expressionTransformFlags & 256 /* DestructuringAssignment */) { - transformFlags |= 256 /* DestructuringAssignment */; + if (expressionTransformFlags & 1024 /* DestructuringAssignment */) { + transformFlags |= 1024 /* DestructuringAssignment */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536871765 /* NodeExcludes */; + return transformFlags & ~536874325 /* NodeExcludes */; } function computeClassDeclaration(node, subtreeFlags) { var transformFlags; @@ -21488,47 +21599,49 @@ var ts; } else { // A ClassDeclaration is ES6 syntax. - transformFlags = subtreeFlags | 192 /* AssertES6 */; + transformFlags = subtreeFlags | 768 /* AssertES2015 */; // A class with a parameter property assignment, property initializer, or decorator is // TypeScript syntax. // An exported declaration may be TypeScript syntax. - if ((subtreeFlags & 137216 /* TypeScriptClassSyntaxMask */) - || (modifierFlags & 1 /* Export */)) { + if ((subtreeFlags & 548864 /* TypeScriptClassSyntaxMask */) + || (modifierFlags & 1 /* Export */) + || node.typeParameters) { transformFlags |= 3 /* AssertTypeScript */; } - if (subtreeFlags & 32768 /* ContainsLexicalThisInComputedPropertyName */) { + if (subtreeFlags & 131072 /* ContainsLexicalThisInComputedPropertyName */) { // A computed property name containing `this` might need to be rewritten, // so propagate the ContainsLexicalThis flag upward. - transformFlags |= 8192 /* ContainsLexicalThis */; + transformFlags |= 32768 /* ContainsLexicalThis */; } } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~537590613 /* ClassExcludes */; + return transformFlags & ~539749717 /* ClassExcludes */; } function computeClassExpression(node, subtreeFlags) { // A ClassExpression is ES6 syntax. - var transformFlags = subtreeFlags | 192 /* AssertES6 */; + var transformFlags = subtreeFlags | 768 /* AssertES2015 */; // A class with a parameter property assignment, property initializer, or decorator is // TypeScript syntax. - if (subtreeFlags & 137216 /* TypeScriptClassSyntaxMask */) { + if (subtreeFlags & 548864 /* TypeScriptClassSyntaxMask */ + || node.typeParameters) { transformFlags |= 3 /* AssertTypeScript */; } - if (subtreeFlags & 32768 /* ContainsLexicalThisInComputedPropertyName */) { + if (subtreeFlags & 131072 /* ContainsLexicalThisInComputedPropertyName */) { // A computed property name containing `this` might need to be rewritten, // so propagate the ContainsLexicalThis flag upward. - transformFlags |= 8192 /* ContainsLexicalThis */; + transformFlags |= 32768 /* ContainsLexicalThis */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~537590613 /* ClassExcludes */; + return transformFlags & ~539749717 /* ClassExcludes */; } function computeHeritageClause(node, subtreeFlags) { var transformFlags = subtreeFlags; switch (node.token) { - case 83 /* ExtendsKeyword */: + case 84 /* ExtendsKeyword */: // An `extends` HeritageClause is ES6 syntax. - transformFlags |= 192 /* AssertES6 */; + transformFlags |= 768 /* AssertES2015 */; break; - case 106 /* ImplementsKeyword */: + case 107 /* ImplementsKeyword */: // An `implements` HeritageClause is TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; break; @@ -21537,65 +21650,65 @@ var ts; break; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536871765 /* NodeExcludes */; + return transformFlags & ~536874325 /* NodeExcludes */; } function computeExpressionWithTypeArguments(node, subtreeFlags) { // An ExpressionWithTypeArguments is ES6 syntax, as it is used in the // extends clause of a class. - var transformFlags = subtreeFlags | 192 /* AssertES6 */; + var transformFlags = subtreeFlags | 768 /* AssertES2015 */; // If an ExpressionWithTypeArguments contains type arguments, then it // is TypeScript syntax. if (node.typeArguments) { transformFlags |= 3 /* AssertTypeScript */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536871765 /* NodeExcludes */; + return transformFlags & ~536874325 /* NodeExcludes */; } function computeConstructor(node, subtreeFlags) { var transformFlags = subtreeFlags; - var body = node.body; - if (body === undefined) { - // An overload constructor is TypeScript syntax. + // TypeScript-specific modifiers and overloads are TypeScript syntax + if (ts.hasModifier(node, 2270 /* TypeScriptModifier */) + || !node.body) { transformFlags |= 3 /* AssertTypeScript */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~550593365 /* ConstructorExcludes */; + return transformFlags & ~591760725 /* ConstructorExcludes */; } function computeMethod(node, subtreeFlags) { // A MethodDeclaration is ES6 syntax. - var transformFlags = subtreeFlags | 192 /* AssertES6 */; - var modifierFlags = ts.getModifierFlags(node); - var body = node.body; - var typeParameters = node.typeParameters; - var asteriskToken = node.asteriskToken; - // A MethodDeclaration is TypeScript syntax if it is either async, abstract, overloaded, - // generic, or has a decorator. - if (!body - || typeParameters - || (modifierFlags & (256 /* Async */ | 128 /* Abstract */)) - || (subtreeFlags & 2048 /* ContainsDecorators */)) { + var transformFlags = subtreeFlags | 768 /* AssertES2015 */; + // Decorators, TypeScript-specific modifiers, type parameters, type annotations, and + // overloads are TypeScript syntax. + if (node.decorators + || ts.hasModifier(node, 2270 /* TypeScriptModifier */) + || node.typeParameters + || node.type + || !node.body) { transformFlags |= 3 /* AssertTypeScript */; } + // An async method declaration is ES2017 syntax. + if (ts.hasModifier(node, 256 /* Async */)) { + transformFlags |= 48 /* AssertES2017 */; + } // Currently, we only support generators that were originally async function bodies. - if (asteriskToken && ts.getEmitFlags(node) & 2097152 /* AsyncFunctionBody */) { - transformFlags |= 1536 /* AssertGenerator */; + if (node.asteriskToken && ts.getEmitFlags(node) & 2097152 /* AsyncFunctionBody */) { + transformFlags |= 6144 /* AssertGenerator */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~550593365 /* MethodOrAccessorExcludes */; + return transformFlags & ~591760725 /* MethodOrAccessorExcludes */; } function computeAccessor(node, subtreeFlags) { var transformFlags = subtreeFlags; - var modifierFlags = ts.getModifierFlags(node); - var body = node.body; - // A MethodDeclaration is TypeScript syntax if it is either async, abstract, overloaded, - // generic, or has a decorator. - if (!body - || (modifierFlags & (256 /* Async */ | 128 /* Abstract */)) - || (subtreeFlags & 2048 /* ContainsDecorators */)) { + // Decorators, TypeScript-specific modifiers, type annotations, and overloads are + // TypeScript syntax. + if (node.decorators + || ts.hasModifier(node, 2270 /* TypeScriptModifier */) + || node.type + || !node.body) { transformFlags |= 3 /* AssertTypeScript */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~550593365 /* MethodOrAccessorExcludes */; + return transformFlags & ~591760725 /* MethodOrAccessorExcludes */; } function computePropertyDeclaration(node, subtreeFlags) { // A PropertyDeclaration is TypeScript syntax. @@ -21603,88 +21716,105 @@ var ts; // If the PropertyDeclaration has an initializer, we need to inform its ancestor // so that it handle the transformation. if (node.initializer) { - transformFlags |= 4096 /* ContainsPropertyInitializer */; + transformFlags |= 16384 /* ContainsPropertyInitializer */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536871765 /* NodeExcludes */; + return transformFlags & ~536874325 /* NodeExcludes */; } function computeFunctionDeclaration(node, subtreeFlags) { var transformFlags; var modifierFlags = ts.getModifierFlags(node); var body = node.body; - var asteriskToken = node.asteriskToken; if (!body || (modifierFlags & 2 /* Ambient */)) { // An ambient declaration is TypeScript syntax. // A FunctionDeclaration without a body is an overload and is TypeScript syntax. transformFlags = 3 /* AssertTypeScript */; } else { - transformFlags = subtreeFlags | 8388608 /* ContainsHoistedDeclarationOrCompletion */; + transformFlags = subtreeFlags | 33554432 /* ContainsHoistedDeclarationOrCompletion */; // If a FunctionDeclaration is exported, then it is either ES6 or TypeScript syntax. if (modifierFlags & 1 /* Export */) { - transformFlags |= 3 /* AssertTypeScript */ | 192 /* AssertES6 */; + transformFlags |= 3 /* AssertTypeScript */ | 768 /* AssertES2015 */; } - // If a FunctionDeclaration is async, then it is TypeScript syntax. - if (modifierFlags & 256 /* Async */) { + // TypeScript-specific modifiers, type parameters, and type annotations are TypeScript + // syntax. + if (modifierFlags & 2270 /* TypeScriptModifier */ + || node.typeParameters + || node.type) { transformFlags |= 3 /* AssertTypeScript */; } + // An async function declaration is ES2017 syntax. + if (modifierFlags & 256 /* Async */) { + transformFlags |= 48 /* AssertES2017 */; + } // If a FunctionDeclaration's subtree has marked the container as needing to capture the // lexical this, or the function contains parameters with initializers, then this node is // ES6 syntax. - if (subtreeFlags & 81920 /* ES6FunctionSyntaxMask */) { - transformFlags |= 192 /* AssertES6 */; + if (subtreeFlags & 327680 /* ES2015FunctionSyntaxMask */) { + transformFlags |= 768 /* AssertES2015 */; } // If a FunctionDeclaration is generator function and is the body of a // transformed async function, then this node can be transformed to a // down-level generator. // Currently we do not support transforming any other generator fucntions // down level. - if (asteriskToken && ts.getEmitFlags(node) & 2097152 /* AsyncFunctionBody */) { - transformFlags |= 1536 /* AssertGenerator */; + if (node.asteriskToken && ts.getEmitFlags(node) & 2097152 /* AsyncFunctionBody */) { + transformFlags |= 6144 /* AssertGenerator */; } } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~550726485 /* FunctionExcludes */; + return transformFlags & ~592293205 /* FunctionExcludes */; } function computeFunctionExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; - var modifierFlags = ts.getModifierFlags(node); - var asteriskToken = node.asteriskToken; - // An async function expression is TypeScript syntax. - if (modifierFlags & 256 /* Async */) { + // TypeScript-specific modifiers, type parameters, and type annotations are TypeScript + // syntax. + if (ts.hasModifier(node, 2270 /* TypeScriptModifier */) + || node.typeParameters + || node.type) { transformFlags |= 3 /* AssertTypeScript */; } + // An async function expression is ES2017 syntax. + if (ts.hasModifier(node, 256 /* Async */)) { + transformFlags |= 48 /* AssertES2017 */; + } // If a FunctionExpression's subtree has marked the container as needing to capture the // lexical this, or the function contains parameters with initializers, then this node is // ES6 syntax. - if (subtreeFlags & 81920 /* ES6FunctionSyntaxMask */) { - transformFlags |= 192 /* AssertES6 */; + if (subtreeFlags & 327680 /* ES2015FunctionSyntaxMask */) { + transformFlags |= 768 /* AssertES2015 */; } // If a FunctionExpression is generator function and is the body of a // transformed async function, then this node can be transformed to a // down-level generator. // Currently we do not support transforming any other generator fucntions // down level. - if (asteriskToken && ts.getEmitFlags(node) & 2097152 /* AsyncFunctionBody */) { - transformFlags |= 1536 /* AssertGenerator */; + if (node.asteriskToken && ts.getEmitFlags(node) & 2097152 /* AsyncFunctionBody */) { + transformFlags |= 6144 /* AssertGenerator */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~550726485 /* FunctionExcludes */; + return transformFlags & ~592293205 /* FunctionExcludes */; } function computeArrowFunction(node, subtreeFlags) { // An ArrowFunction is ES6 syntax, and excludes markers that should not escape the scope of an ArrowFunction. - var transformFlags = subtreeFlags | 192 /* AssertES6 */; - var modifierFlags = ts.getModifierFlags(node); - // An async arrow function is TypeScript syntax. - if (modifierFlags & 256 /* Async */) { + var transformFlags = subtreeFlags | 768 /* AssertES2015 */; + // TypeScript-specific modifiers, type parameters, and type annotations are TypeScript + // syntax. + if (ts.hasModifier(node, 2270 /* TypeScriptModifier */) + || node.typeParameters + || node.type) { transformFlags |= 3 /* AssertTypeScript */; } + // An async arrow function is ES2017 syntax. + if (ts.hasModifier(node, 256 /* Async */)) { + transformFlags |= 48 /* AssertES2017 */; + } // If an ArrowFunction contains a lexical this, its container must capture the lexical this. - if (subtreeFlags & 8192 /* ContainsLexicalThis */) { - transformFlags |= 16384 /* ContainsCapturedLexicalThis */; + if (subtreeFlags & 32768 /* ContainsLexicalThis */) { + transformFlags |= 65536 /* ContainsCapturedLexicalThis */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~550710101 /* ArrowFunctionExcludes */; + return transformFlags & ~592227669 /* ArrowFunctionExcludes */; } function computePropertyAccess(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -21692,21 +21822,25 @@ var ts; var expressionKind = expression.kind; // If a PropertyAccessExpression starts with a super keyword, then it is // ES6 syntax, and requires a lexical `this` binding. - if (expressionKind === 95 /* SuperKeyword */) { - transformFlags |= 8192 /* ContainsLexicalThis */; + if (expressionKind === 96 /* SuperKeyword */) { + transformFlags |= 32768 /* ContainsLexicalThis */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536871765 /* NodeExcludes */; + return transformFlags & ~536874325 /* NodeExcludes */; } function computeVariableDeclaration(node, subtreeFlags) { var transformFlags = subtreeFlags; var nameKind = node.name.kind; // A VariableDeclaration with a binding pattern is ES6 syntax. - if (nameKind === 167 /* ObjectBindingPattern */ || nameKind === 168 /* ArrayBindingPattern */) { - transformFlags |= 192 /* AssertES6 */ | 2097152 /* ContainsBindingPattern */; + if (nameKind === 168 /* ObjectBindingPattern */ || nameKind === 169 /* ArrayBindingPattern */) { + transformFlags |= 768 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; + } + // Type annotations are TypeScript syntax. + if (node.type) { + transformFlags |= 3 /* AssertTypeScript */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536871765 /* NodeExcludes */; + return transformFlags & ~536874325 /* NodeExcludes */; } function computeVariableStatement(node, subtreeFlags) { var transformFlags; @@ -21720,24 +21854,24 @@ var ts; transformFlags = subtreeFlags; // If a VariableStatement is exported, then it is either ES6 or TypeScript syntax. if (modifierFlags & 1 /* Export */) { - transformFlags |= 192 /* AssertES6 */ | 3 /* AssertTypeScript */; + transformFlags |= 768 /* AssertES2015 */ | 3 /* AssertTypeScript */; } - if (declarationListTransformFlags & 2097152 /* ContainsBindingPattern */) { - transformFlags |= 192 /* AssertES6 */; + if (declarationListTransformFlags & 8388608 /* ContainsBindingPattern */) { + transformFlags |= 768 /* AssertES2015 */; } } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536871765 /* NodeExcludes */; + return transformFlags & ~536874325 /* NodeExcludes */; } function computeLabeledStatement(node, subtreeFlags) { var transformFlags = subtreeFlags; // A labeled statement containing a block scoped binding *may* need to be transformed from ES6. - if (subtreeFlags & 1048576 /* ContainsBlockScopedBinding */ + if (subtreeFlags & 4194304 /* ContainsBlockScopedBinding */ && ts.isIterationStatement(node, /*lookInLabeledStatements*/ true)) { - transformFlags |= 192 /* AssertES6 */; + transformFlags |= 768 /* AssertES2015 */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536871765 /* NodeExcludes */; + return transformFlags & ~536874325 /* NodeExcludes */; } function computeImportEquals(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -21746,18 +21880,18 @@ var ts; transformFlags |= 3 /* AssertTypeScript */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536871765 /* NodeExcludes */; + return transformFlags & ~536874325 /* NodeExcludes */; } function computeExpressionStatement(node, subtreeFlags) { var transformFlags = subtreeFlags; // If the expression of an expression statement is a destructuring assignment, // then we treat the statement as ES6 so that we can indicate that we do not // need to hold on to the right-hand side. - if (node.expression.transformFlags & 256 /* DestructuringAssignment */) { - transformFlags |= 192 /* AssertES6 */; + if (node.expression.transformFlags & 1024 /* DestructuringAssignment */) { + transformFlags |= 768 /* AssertES2015 */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536871765 /* NodeExcludes */; + return transformFlags & ~536874325 /* NodeExcludes */; } function computeModuleDeclaration(node, subtreeFlags) { var transformFlags = 3 /* AssertTypeScript */; @@ -21766,46 +21900,49 @@ var ts; transformFlags |= subtreeFlags; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~546335573 /* ModuleExcludes */; + return transformFlags & ~574729557 /* ModuleExcludes */; } function computeVariableDeclarationList(node, subtreeFlags) { - var transformFlags = subtreeFlags | 8388608 /* ContainsHoistedDeclarationOrCompletion */; - if (subtreeFlags & 2097152 /* ContainsBindingPattern */) { - transformFlags |= 192 /* AssertES6 */; + var transformFlags = subtreeFlags | 33554432 /* ContainsHoistedDeclarationOrCompletion */; + if (subtreeFlags & 8388608 /* ContainsBindingPattern */) { + transformFlags |= 768 /* AssertES2015 */; } // If a VariableDeclarationList is `let` or `const`, then it is ES6 syntax. if (node.flags & 3 /* BlockScoped */) { - transformFlags |= 192 /* AssertES6 */ | 1048576 /* ContainsBlockScopedBinding */; + transformFlags |= 768 /* AssertES2015 */ | 4194304 /* ContainsBlockScopedBinding */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~538968917 /* VariableDeclarationListExcludes */; + return transformFlags & ~545262933 /* VariableDeclarationListExcludes */; } function computeOther(node, kind, subtreeFlags) { // Mark transformations needed for each node var transformFlags = subtreeFlags; - var excludeFlags = 536871765 /* NodeExcludes */; + var excludeFlags = 536874325 /* NodeExcludes */; switch (kind) { - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - case 115 /* AbstractKeyword */: - case 122 /* DeclareKeyword */: - case 118 /* AsyncKeyword */: - case 74 /* ConstKeyword */: - case 184 /* AwaitExpression */: - case 224 /* EnumDeclaration */: + case 119 /* AsyncKeyword */: + case 185 /* AwaitExpression */: + // async/await is ES2017 syntax + transformFlags |= 48 /* AssertES2017 */; + break; + case 113 /* PublicKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + case 116 /* AbstractKeyword */: + case 123 /* DeclareKeyword */: + case 75 /* ConstKeyword */: + case 225 /* EnumDeclaration */: case 255 /* EnumMember */: - case 177 /* TypeAssertionExpression */: - case 195 /* AsExpression */: - case 196 /* NonNullExpression */: - case 128 /* ReadonlyKeyword */: + case 178 /* TypeAssertionExpression */: + case 196 /* AsExpression */: + case 197 /* NonNullExpression */: + case 129 /* ReadonlyKeyword */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; break; - case 241 /* JsxElement */: - case 242 /* JsxSelfClosingElement */: - case 243 /* JsxOpeningElement */: - case 244 /* JsxText */: + case 242 /* JsxElement */: + case 243 /* JsxSelfClosingElement */: + case 244 /* JsxOpeningElement */: + case 10 /* JsxText */: case 245 /* JsxClosingElement */: case 246 /* JsxAttribute */: case 247 /* JsxSpreadAttribute */: @@ -21813,64 +21950,64 @@ var ts; // These nodes are Jsx syntax. transformFlags |= 12 /* AssertJsx */; break; - case 82 /* ExportKeyword */: + case 83 /* ExportKeyword */: // This node is both ES6 and TypeScript syntax. - transformFlags |= 192 /* AssertES6 */ | 3 /* AssertTypeScript */; + transformFlags |= 768 /* AssertES2015 */ | 3 /* AssertTypeScript */; break; - case 77 /* DefaultKeyword */: - case 11 /* NoSubstitutionTemplateLiteral */: - case 12 /* TemplateHead */: - case 13 /* TemplateMiddle */: - case 14 /* TemplateTail */: - case 189 /* TemplateExpression */: - case 176 /* TaggedTemplateExpression */: + case 78 /* DefaultKeyword */: + case 12 /* NoSubstitutionTemplateLiteral */: + case 13 /* TemplateHead */: + case 14 /* TemplateMiddle */: + case 15 /* TemplateTail */: + case 190 /* TemplateExpression */: + case 177 /* TaggedTemplateExpression */: case 254 /* ShorthandPropertyAssignment */: - case 208 /* ForOfStatement */: + case 209 /* ForOfStatement */: // These nodes are ES6 syntax. - transformFlags |= 192 /* AssertES6 */; + transformFlags |= 768 /* AssertES2015 */; break; - case 190 /* YieldExpression */: + case 191 /* YieldExpression */: // This node is ES6 syntax. - transformFlags |= 192 /* AssertES6 */ | 4194304 /* ContainsYield */; + transformFlags |= 768 /* AssertES2015 */ | 16777216 /* ContainsYield */; break; - case 117 /* AnyKeyword */: - case 130 /* NumberKeyword */: - case 127 /* NeverKeyword */: - case 132 /* StringKeyword */: - case 120 /* BooleanKeyword */: - case 133 /* SymbolKeyword */: - case 103 /* VoidKeyword */: - case 141 /* TypeParameter */: - case 144 /* PropertySignature */: - case 146 /* MethodSignature */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: - case 154 /* TypePredicate */: - case 155 /* TypeReference */: - case 156 /* FunctionType */: - case 157 /* ConstructorType */: - case 158 /* TypeQuery */: - case 159 /* TypeLiteral */: - case 160 /* ArrayType */: - case 161 /* TupleType */: - case 162 /* UnionType */: - case 163 /* IntersectionType */: - case 164 /* ParenthesizedType */: - case 222 /* InterfaceDeclaration */: - case 223 /* TypeAliasDeclaration */: - case 165 /* ThisType */: - case 166 /* LiteralType */: + case 118 /* AnyKeyword */: + case 131 /* NumberKeyword */: + case 128 /* NeverKeyword */: + case 133 /* StringKeyword */: + case 121 /* BooleanKeyword */: + case 134 /* SymbolKeyword */: + case 104 /* VoidKeyword */: + case 142 /* TypeParameter */: + case 145 /* PropertySignature */: + case 147 /* MethodSignature */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: + case 155 /* TypePredicate */: + case 156 /* TypeReference */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: + case 159 /* TypeQuery */: + case 160 /* TypeLiteral */: + case 161 /* ArrayType */: + case 162 /* TupleType */: + case 163 /* UnionType */: + case 164 /* IntersectionType */: + case 165 /* ParenthesizedType */: + case 223 /* InterfaceDeclaration */: + case 224 /* TypeAliasDeclaration */: + case 166 /* ThisType */: + case 167 /* LiteralType */: // Types and signatures are TypeScript syntax, and exclude all other facts. transformFlags = 3 /* AssertTypeScript */; excludeFlags = -3 /* TypeExcludes */; break; - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: // Even though computed property names are ES6, we don't treat them as such. // This is so that they can flow through PropertyName transforms unaffected. // Instead, we mark the container as ES6, so that it can properly handle the transform. - transformFlags |= 524288 /* ContainsComputedPropertyName */; - if (subtreeFlags & 8192 /* ContainsLexicalThis */) { + transformFlags |= 2097152 /* ContainsComputedPropertyName */; + if (subtreeFlags & 32768 /* ContainsLexicalThis */) { // A computed method name like `[this.getName()](x: string) { ... }` needs to // distinguish itself from the normal case of a method body containing `this`: // `this` inside a method doesn't need to be rewritten (the method provides `this`), @@ -21879,70 +22016,70 @@ var ts; // `_this = this; () => class K { [_this.getName()]() { ... } }` // To make this distinction, use ContainsLexicalThisInComputedPropertyName // instead of ContainsLexicalThis for computed property names - transformFlags |= 32768 /* ContainsLexicalThisInComputedPropertyName */; + transformFlags |= 131072 /* ContainsLexicalThisInComputedPropertyName */; } break; - case 191 /* SpreadElementExpression */: + case 192 /* SpreadElementExpression */: // This node is ES6 syntax, but is handled by a containing node. - transformFlags |= 262144 /* ContainsSpreadElementExpression */; + transformFlags |= 1048576 /* ContainsSpreadElementExpression */; break; - case 95 /* SuperKeyword */: + case 96 /* SuperKeyword */: // This node is ES6 syntax. - transformFlags |= 192 /* AssertES6 */; + transformFlags |= 768 /* AssertES2015 */; break; - case 97 /* ThisKeyword */: + case 98 /* ThisKeyword */: // Mark this node and its ancestors as containing a lexical `this` keyword. - transformFlags |= 8192 /* ContainsLexicalThis */; + transformFlags |= 32768 /* ContainsLexicalThis */; break; - case 167 /* ObjectBindingPattern */: - case 168 /* ArrayBindingPattern */: + case 168 /* ObjectBindingPattern */: + case 169 /* ArrayBindingPattern */: // These nodes are ES6 syntax. - transformFlags |= 192 /* AssertES6 */ | 2097152 /* ContainsBindingPattern */; + transformFlags |= 768 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; break; - case 143 /* Decorator */: + case 144 /* Decorator */: // This node is TypeScript syntax, and marks its container as also being TypeScript syntax. - transformFlags |= 3 /* AssertTypeScript */ | 2048 /* ContainsDecorators */; + transformFlags |= 3 /* AssertTypeScript */ | 8192 /* ContainsDecorators */; break; - case 171 /* ObjectLiteralExpression */: - excludeFlags = 537430869 /* ObjectLiteralExcludes */; - if (subtreeFlags & 524288 /* ContainsComputedPropertyName */) { + case 172 /* ObjectLiteralExpression */: + excludeFlags = 539110741 /* ObjectLiteralExcludes */; + if (subtreeFlags & 2097152 /* ContainsComputedPropertyName */) { // If an ObjectLiteralExpression contains a ComputedPropertyName, then it // is an ES6 node. - transformFlags |= 192 /* AssertES6 */; + transformFlags |= 768 /* AssertES2015 */; } - if (subtreeFlags & 32768 /* ContainsLexicalThisInComputedPropertyName */) { + if (subtreeFlags & 131072 /* ContainsLexicalThisInComputedPropertyName */) { // A computed property name containing `this` might need to be rewritten, // so propagate the ContainsLexicalThis flag upward. - transformFlags |= 8192 /* ContainsLexicalThis */; + transformFlags |= 32768 /* ContainsLexicalThis */; } break; - case 170 /* ArrayLiteralExpression */: - case 175 /* NewExpression */: - excludeFlags = 537133909 /* ArrayLiteralOrCallOrNewExcludes */; - if (subtreeFlags & 262144 /* ContainsSpreadElementExpression */) { + case 171 /* ArrayLiteralExpression */: + case 176 /* NewExpression */: + excludeFlags = 537922901 /* ArrayLiteralOrCallOrNewExcludes */; + if (subtreeFlags & 1048576 /* ContainsSpreadElementExpression */) { // If the this node contains a SpreadElementExpression, then it is an ES6 // node. - transformFlags |= 192 /* AssertES6 */; + transformFlags |= 768 /* AssertES2015 */; } break; - case 204 /* DoStatement */: - case 205 /* WhileStatement */: - case 206 /* ForStatement */: - case 207 /* ForInStatement */: + case 205 /* DoStatement */: + case 206 /* WhileStatement */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. - if (subtreeFlags & 1048576 /* ContainsBlockScopedBinding */) { - transformFlags |= 192 /* AssertES6 */; + if (subtreeFlags & 4194304 /* ContainsBlockScopedBinding */) { + transformFlags |= 768 /* AssertES2015 */; } break; case 256 /* SourceFile */: - if (subtreeFlags & 16384 /* ContainsCapturedLexicalThis */) { - transformFlags |= 192 /* AssertES6 */; + if (subtreeFlags & 65536 /* ContainsCapturedLexicalThis */) { + transformFlags |= 768 /* AssertES2015 */; } break; - case 211 /* ReturnStatement */: - case 209 /* ContinueStatement */: - case 210 /* BreakStatement */: - transformFlags |= 8388608 /* ContainsHoistedDeclarationOrCompletion */; + case 212 /* ReturnStatement */: + case 210 /* ContinueStatement */: + case 211 /* BreakStatement */: + transformFlags |= 33554432 /* ContainsHoistedDeclarationOrCompletion */; break; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; @@ -21953,7 +22090,7 @@ var ts; /// var ts; (function (ts) { - function trace(host, message) { + function trace(host) { host.trace(ts.formatMessage.apply(undefined, arguments)); } ts.trace = trace; @@ -22724,6 +22861,7 @@ var ts; var intersectionTypes = ts.createMap(); var stringLiteralTypes = ts.createMap(); var numericLiteralTypes = ts.createMap(); + var evolvingArrayTypes = []; var unknownSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "unknown"); var resolvingSymbol = createSymbol(67108864 /* Transient */, "__resolving__"); var anyType = createIntrinsicType(1 /* Any */, "any"); @@ -22774,6 +22912,7 @@ var ts; var globalBooleanType; var globalRegExpType; var anyArrayType; + var autoArrayType; var anyReadonlyArrayType; // The library files are only loaded when the feature is used. // This allows users to just specify library files they want to used through --lib @@ -23018,7 +23157,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 225 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 225 /* ModuleDeclaration */))) { + (target.valueDeclaration.kind === 226 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 226 /* ModuleDeclaration */))) { // other kinds of value declarations take precedence over modules target.valueDeclaration = source.valueDeclaration; } @@ -23174,7 +23313,7 @@ var ts; 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 !== 218 /* VariableDeclaration */ || + return declaration.kind !== 219 /* VariableDeclaration */ || !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } // declaration is after usage @@ -23183,9 +23322,9 @@ var ts; function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 200 /* VariableStatement */: - case 206 /* ForStatement */: - case 208 /* ForOfStatement */: + case 201 /* VariableStatement */: + case 207 /* ForStatement */: + case 209 /* ForOfStatement */: // variable statement/for/for-of statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) if (isSameScopeDescendentOf(usage, declaration, container)) { @@ -23194,8 +23333,8 @@ var ts; break; } switch (declaration.parent.parent.kind) { - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: // ForIn/ForOf case - use site should not be used in expression part if (isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container)) { return true; @@ -23214,7 +23353,7 @@ var ts; return true; } var initializerOfNonStaticProperty = current.parent && - current.parent.kind === 145 /* PropertyDeclaration */ && + current.parent.kind === 146 /* PropertyDeclaration */ && (ts.getModifierFlags(current.parent) & 32 /* Static */) === 0 && current.parent.initializer === current; if (initializerOfNonStaticProperty) { @@ -23250,8 +23389,8 @@ var ts; if (meaning & result.flags & 793064 /* Type */ && lastLocation.kind !== 273 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ ? lastLocation === location.type || - lastLocation.kind === 142 /* Parameter */ || - lastLocation.kind === 141 /* TypeParameter */ + lastLocation.kind === 143 /* Parameter */ || + lastLocation.kind === 142 /* TypeParameter */ : false; } if (meaning & 107455 /* Value */ && result.flags & 1 /* FunctionScopedVariable */) { @@ -23260,9 +23399,9 @@ var ts; // however it is detected separately when checking initializers of parameters // to make sure that they reference no variables declared after them. useResult = - lastLocation.kind === 142 /* Parameter */ || + lastLocation.kind === 143 /* Parameter */ || (lastLocation === location.type && - result.valueDeclaration.kind === 142 /* Parameter */); + result.valueDeclaration.kind === 143 /* Parameter */); } } if (useResult) { @@ -23278,7 +23417,7 @@ var ts; if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; if (location.kind === 256 /* SourceFile */ || ts.isAmbientModule(location)) { // It's an external module. First see if the module has an export default and if the local @@ -23303,7 +23442,7 @@ var ts; // which is not the desired behavior. if (moduleExports[name] && moduleExports[name].flags === 8388608 /* Alias */ && - ts.getDeclarationOfKind(moduleExports[name], 238 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExports[name], 239 /* ExportSpecifier */)) { break; } } @@ -23311,13 +23450,13 @@ var ts; break loop; } break; - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* 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 @@ -23334,9 +23473,9 @@ var ts; } } break; - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - case 222 /* InterfaceDeclaration */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 223 /* InterfaceDeclaration */: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793064 /* Type */)) { if (lastLocation && ts.getModifierFlags(lastLocation) & 32 /* Static */) { // TypeScript 1.0 spec (April 2014): 3.4.1 @@ -23347,7 +23486,7 @@ var ts; } break loop; } - if (location.kind === 192 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 193 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -23363,9 +23502,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 222 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 223 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793064 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -23373,19 +23512,19 @@ var ts; } } break; - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 220 /* FunctionDeclaration */: - case 180 /* ArrowFunction */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 221 /* FunctionDeclaration */: + case 181 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 179 /* FunctionExpression */: + case 180 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -23398,7 +23537,7 @@ var ts; } } break; - case 143 /* Decorator */: + case 144 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -23407,7 +23546,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 === 142 /* Parameter */) { + if (location.parent && location.parent.kind === 143 /* Parameter */) { location = location.parent; } // @@ -23470,7 +23609,7 @@ var ts; // If we're in an external module, we can't reference value symbols created from UMD export declarations if (result && isInExternalModule && (meaning & 107455 /* Value */) === 107455 /* Value */) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 228 /* NamespaceExportDeclaration */) { + if (decls && decls.length === 1 && decls[0].kind === 229 /* NamespaceExportDeclaration */) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } @@ -23478,7 +23617,7 @@ var ts; return result; } function checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) { - if ((errorLocation.kind === 69 /* Identifier */ && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { + if ((errorLocation.kind === 70 /* Identifier */ && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { return false; } var container = ts.getThisContainer(errorLocation, /* includeArrowFunctions */ true); @@ -23523,10 +23662,10 @@ var ts; */ function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 69 /* Identifier */: - case 172 /* PropertyAccessExpression */: + case 70 /* Identifier */: + case 173 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: ts.Debug.assert(ts.isEntityNameExpression(node.expression)); return node.expression; default: @@ -23548,7 +23687,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"); - if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 218 /* VariableDeclaration */), errorLocation)) { + if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 219 /* VariableDeclaration */), errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -23569,10 +23708,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 229 /* ImportEqualsDeclaration */) { + if (node.kind === 230 /* ImportEqualsDeclaration */) { return node; } - while (node && node.kind !== 230 /* ImportDeclaration */) { + while (node && node.kind !== 231 /* ImportDeclaration */) { node = node.parent; } return node; @@ -23582,10 +23721,10 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 240 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 241 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } - return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); + return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); } function getTargetOfImportClause(node) { var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier); @@ -23707,19 +23846,19 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 229 /* ImportEqualsDeclaration */: + case 230 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node); - case 231 /* ImportClause */: + case 232 /* ImportClause */: return getTargetOfImportClause(node); - case 232 /* NamespaceImport */: + case 233 /* NamespaceImport */: return getTargetOfNamespaceImport(node); - case 234 /* ImportSpecifier */: + case 235 /* ImportSpecifier */: return getTargetOfImportSpecifier(node); - case 238 /* ExportSpecifier */: + case 239 /* ExportSpecifier */: return getTargetOfExportSpecifier(node); - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: return getTargetOfExportAssignment(node); - case 228 /* NamespaceExportDeclaration */: + case 229 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node); } } @@ -23766,11 +23905,11 @@ var ts; links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); ts.Debug.assert(!!node); - if (node.kind === 235 /* ExportAssignment */) { + if (node.kind === 236 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 238 /* ExportSpecifier */) { + else if (node.kind === 239 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -23781,24 +23920,24 @@ var ts; } } // This function is only for imports with entity names - function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration, dontResolveAlias) { + function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, dontResolveAlias) { // There are three things we might try to look for. In the following examples, // the search term is enclosed in |...|: // // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 69 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 70 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 69 /* Identifier */ || entityName.parent.kind === 139 /* QualifiedName */) { + if (entityName.kind === 70 /* Identifier */ || entityName.parent.kind === 140 /* QualifiedName */) { return resolveEntityName(entityName, 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 229 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 230 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } @@ -23811,16 +23950,16 @@ var ts; return undefined; } var symbol; - if (name.kind === 69 /* Identifier */) { + if (name.kind === 70 /* Identifier */) { var message = meaning === 1920 /* Namespace */ ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; symbol = resolveName(location || name, name.text, meaning, ignoreErrors ? undefined : message, name); if (!symbol) { return undefined; } } - else if (name.kind === 139 /* QualifiedName */ || name.kind === 172 /* PropertyAccessExpression */) { - var left = name.kind === 139 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 139 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 140 /* QualifiedName */ || name.kind === 173 /* PropertyAccessExpression */) { + var left = name.kind === 140 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 140 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, 1920 /* Namespace */, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -24027,7 +24166,7 @@ var ts; var members = node.members; for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { var member = members_1[_i]; - if (member.kind === 148 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 149 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -24106,7 +24245,7 @@ var ts; if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } @@ -24147,7 +24286,7 @@ var ts; return ts.forEachProperty(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 /* Alias */ && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 238 /* ExportSpecifier */)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 239 /* ExportSpecifier */)) { if (!useOnlyExternalAliasing || // Is this external alias, then use it to name ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { @@ -24186,7 +24325,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, 238 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 239 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -24201,10 +24340,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 145 /* PropertyDeclaration */: - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 146 /* PropertyDeclaration */: + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: continue; default: return false; @@ -24235,7 +24374,7 @@ var ts; return { accessibility: 1 /* NotAccessible */, errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), - errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, 1920 /* Namespace */) : undefined + errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, 1920 /* Namespace */) : undefined, }; } return hasAccessibleDeclarations; @@ -24272,7 +24411,7 @@ var ts; // Just a local name that is not accessible return { accessibility: 1 /* NotAccessible */, - errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning) + errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), }; } return { accessibility: 0 /* Accessible */ }; @@ -24326,12 +24465,12 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 158 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + if (entityName.parent.kind === 159 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { // Typeof value meaning = 107455 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 139 /* QualifiedName */ || entityName.kind === 172 /* PropertyAccessExpression */ || - entityName.parent.kind === 229 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 140 /* QualifiedName */ || entityName.kind === 173 /* PropertyAccessExpression */ || + entityName.parent.kind === 230 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -24427,10 +24566,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { var node = type.symbol.declarations[0].parent; - while (node.kind === 164 /* ParenthesizedType */) { + while (node.kind === 165 /* ParenthesizedType */) { node = node.parent; } - if (node.kind === 223 /* TypeAliasDeclaration */) { + if (node.kind === 224 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -24438,7 +24577,7 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 226 /* ModuleBlock */ && + node.parent.kind === 227 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { @@ -24452,10 +24591,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 192 /* ClassExpression */: + case 193 /* ClassExpression */: return "(Anonymous class)"; - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: return "(Anonymous function)"; } } @@ -24478,17 +24617,17 @@ var ts; var firstChar = symbolName.charCodeAt(0); var needsElementAccess = !ts.isIdentifierStart(firstChar, languageVersion); if (needsElementAccess) { - writePunctuation(writer, 19 /* OpenBracketToken */); + writePunctuation(writer, 20 /* OpenBracketToken */); if (ts.isSingleOrDoubleQuote(firstChar)) { writer.writeStringLiteral(symbolName); } else { writer.writeSymbol(symbolName, symbol); } - writePunctuation(writer, 20 /* CloseBracketToken */); + writePunctuation(writer, 21 /* CloseBracketToken */); } else { - writePunctuation(writer, 21 /* DotToken */); + writePunctuation(writer, 22 /* DotToken */); writer.writeSymbol(symbolName, symbol); } } @@ -24587,7 +24726,7 @@ var ts; } else if (type.flags & 256 /* EnumLiteral */) { buildSymbolDisplay(getParentOfSymbol(type.symbol), writer, enclosingDeclaration, 793064 /* Type */, 0 /* None */, nextFlags); - writePunctuation(writer, 21 /* DotToken */); + writePunctuation(writer, 22 /* DotToken */); appendSymbolNameOnly(type.symbol, writer); } else if (type.flags & (32768 /* Class */ | 65536 /* Interface */ | 16 /* Enum */ | 16384 /* TypeParameter */)) { @@ -24617,23 +24756,23 @@ var ts; else { // Should never get here // { ... } - writePunctuation(writer, 15 /* OpenBraceToken */); + writePunctuation(writer, 16 /* OpenBraceToken */); writeSpace(writer); - writePunctuation(writer, 22 /* DotDotDotToken */); + writePunctuation(writer, 23 /* DotDotDotToken */); writeSpace(writer); - writePunctuation(writer, 16 /* CloseBraceToken */); + writePunctuation(writer, 17 /* CloseBraceToken */); } } function writeTypeList(types, delimiter) { for (var i = 0; i < types.length; i++) { if (i > 0) { - if (delimiter !== 24 /* CommaToken */) { + if (delimiter !== 25 /* CommaToken */) { writeSpace(writer); } writePunctuation(writer, delimiter); writeSpace(writer); } - writeType(types[i], delimiter === 24 /* CommaToken */ ? 0 /* None */ : 64 /* InElementType */); + writeType(types[i], delimiter === 25 /* CommaToken */ ? 0 /* None */ : 64 /* InElementType */); } } function writeSymbolTypeReference(symbol, typeArguments, pos, end, flags) { @@ -24642,29 +24781,29 @@ var ts; buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793064 /* Type */, 0 /* None */, flags); } if (pos < end) { - writePunctuation(writer, 25 /* LessThanToken */); + writePunctuation(writer, 26 /* LessThanToken */); writeType(typeArguments[pos], 256 /* InFirstTypeArgument */); pos++; while (pos < end) { - writePunctuation(writer, 24 /* CommaToken */); + writePunctuation(writer, 25 /* CommaToken */); writeSpace(writer); writeType(typeArguments[pos], 0 /* None */); pos++; } - writePunctuation(writer, 27 /* GreaterThanToken */); + writePunctuation(writer, 28 /* GreaterThanToken */); } } function writeTypeReference(type, flags) { var typeArguments = type.typeArguments || emptyArray; if (type.target === globalArrayType && !(flags & 1 /* WriteArrayAsGenericType */)) { writeType(typeArguments[0], 64 /* InElementType */); - writePunctuation(writer, 19 /* OpenBracketToken */); - writePunctuation(writer, 20 /* CloseBracketToken */); + writePunctuation(writer, 20 /* OpenBracketToken */); + writePunctuation(writer, 21 /* CloseBracketToken */); } else if (type.target.flags & 262144 /* Tuple */) { - writePunctuation(writer, 19 /* OpenBracketToken */); - writeTypeList(type.typeArguments.slice(0, getTypeReferenceArity(type)), 24 /* CommaToken */); - writePunctuation(writer, 20 /* CloseBracketToken */); + writePunctuation(writer, 20 /* OpenBracketToken */); + writeTypeList(type.typeArguments.slice(0, getTypeReferenceArity(type)), 25 /* CommaToken */); + writePunctuation(writer, 21 /* CloseBracketToken */); } else { // Write the type reference in the format f
.g.C where A and B are type arguments @@ -24685,7 +24824,7 @@ var ts; // the default outer type arguments), we don't show the group. if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { writeSymbolTypeReference(parent_9, typeArguments, start, i, flags); - writePunctuation(writer, 21 /* DotToken */); + writePunctuation(writer, 22 /* DotToken */); } } } @@ -24695,16 +24834,16 @@ var ts; } function writeUnionOrIntersectionType(type, flags) { if (flags & 64 /* InElementType */) { - writePunctuation(writer, 17 /* OpenParenToken */); + writePunctuation(writer, 18 /* OpenParenToken */); } if (type.flags & 524288 /* Union */) { - writeTypeList(formatUnionTypes(type.types), 47 /* BarToken */); + writeTypeList(formatUnionTypes(type.types), 48 /* BarToken */); } else { - writeTypeList(type.types, 46 /* AmpersandToken */); + writeTypeList(type.types, 47 /* AmpersandToken */); } if (flags & 64 /* InElementType */) { - writePunctuation(writer, 18 /* CloseParenToken */); + writePunctuation(writer, 19 /* CloseParenToken */); } } function writeAnonymousType(type, flags) { @@ -24726,7 +24865,7 @@ var ts; } else { // Recursive usage, use any - writeKeyword(writer, 117 /* AnyKeyword */); + writeKeyword(writer, 118 /* AnyKeyword */); } } else { @@ -24750,7 +24889,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 256 /* SourceFile */ || declaration.parent.kind === 226 /* ModuleBlock */; + return declaration.parent.kind === 256 /* SourceFile */ || declaration.parent.kind === 227 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -24760,37 +24899,37 @@ var ts; } } function writeTypeOfSymbol(type, typeFormatFlags) { - writeKeyword(writer, 101 /* TypeOfKeyword */); + writeKeyword(writer, 102 /* TypeOfKeyword */); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455 /* Value */, 0 /* None */, typeFormatFlags); } function writeIndexSignature(info, keyword) { if (info) { if (info.isReadonly) { - writeKeyword(writer, 128 /* ReadonlyKeyword */); + writeKeyword(writer, 129 /* ReadonlyKeyword */); writeSpace(writer); } - writePunctuation(writer, 19 /* OpenBracketToken */); + writePunctuation(writer, 20 /* OpenBracketToken */); writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); - writePunctuation(writer, 54 /* ColonToken */); + writePunctuation(writer, 55 /* ColonToken */); writeSpace(writer); writeKeyword(writer, keyword); - writePunctuation(writer, 20 /* CloseBracketToken */); - writePunctuation(writer, 54 /* ColonToken */); + writePunctuation(writer, 21 /* CloseBracketToken */); + writePunctuation(writer, 55 /* ColonToken */); writeSpace(writer); writeType(info.type, 0 /* None */); - writePunctuation(writer, 23 /* SemicolonToken */); + writePunctuation(writer, 24 /* SemicolonToken */); writer.writeLine(); } } function writePropertyWithModifiers(prop) { if (isReadonlySymbol(prop)) { - writeKeyword(writer, 128 /* ReadonlyKeyword */); + writeKeyword(writer, 129 /* ReadonlyKeyword */); writeSpace(writer); } buildSymbolDisplay(prop, writer); if (prop.flags & 536870912 /* Optional */) { - writePunctuation(writer, 53 /* QuestionToken */); + writePunctuation(writer, 54 /* QuestionToken */); } } function shouldAddParenthesisAroundFunctionType(callSignature, flags) { @@ -24809,53 +24948,53 @@ var ts; var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { - writePunctuation(writer, 15 /* OpenBraceToken */); - writePunctuation(writer, 16 /* CloseBraceToken */); + writePunctuation(writer, 16 /* OpenBraceToken */); + writePunctuation(writer, 17 /* CloseBraceToken */); return; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var parenthesizeSignature = shouldAddParenthesisAroundFunctionType(resolved.callSignatures[0], flags); if (parenthesizeSignature) { - writePunctuation(writer, 17 /* OpenParenToken */); + writePunctuation(writer, 18 /* OpenParenToken */); } buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, /*kind*/ undefined, symbolStack); if (parenthesizeSignature) { - writePunctuation(writer, 18 /* CloseParenToken */); + writePunctuation(writer, 19 /* CloseParenToken */); } return; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { if (flags & 64 /* InElementType */) { - writePunctuation(writer, 17 /* OpenParenToken */); + writePunctuation(writer, 18 /* OpenParenToken */); } - writeKeyword(writer, 92 /* NewKeyword */); + writeKeyword(writer, 93 /* NewKeyword */); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, /*kind*/ undefined, symbolStack); if (flags & 64 /* InElementType */) { - writePunctuation(writer, 18 /* CloseParenToken */); + writePunctuation(writer, 19 /* CloseParenToken */); } return; } } var saveInObjectTypeLiteral = inObjectTypeLiteral; inObjectTypeLiteral = true; - writePunctuation(writer, 15 /* OpenBraceToken */); + writePunctuation(writer, 16 /* OpenBraceToken */); writer.writeLine(); writer.increaseIndent(); for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, /*kind*/ undefined, symbolStack); - writePunctuation(writer, 23 /* SemicolonToken */); + writePunctuation(writer, 24 /* SemicolonToken */); writer.writeLine(); } for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, 1 /* Construct */, symbolStack); - writePunctuation(writer, 23 /* SemicolonToken */); + writePunctuation(writer, 24 /* SemicolonToken */); writer.writeLine(); } - writeIndexSignature(resolved.stringIndexInfo, 132 /* StringKeyword */); - writeIndexSignature(resolved.numberIndexInfo, 130 /* NumberKeyword */); + writeIndexSignature(resolved.stringIndexInfo, 133 /* StringKeyword */); + writeIndexSignature(resolved.numberIndexInfo, 131 /* NumberKeyword */); for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); @@ -24865,21 +25004,21 @@ var ts; var signature = signatures_1[_f]; writePropertyWithModifiers(p); buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, /*kind*/ undefined, symbolStack); - writePunctuation(writer, 23 /* SemicolonToken */); + writePunctuation(writer, 24 /* SemicolonToken */); writer.writeLine(); } } else { writePropertyWithModifiers(p); - writePunctuation(writer, 54 /* ColonToken */); + writePunctuation(writer, 55 /* ColonToken */); writeSpace(writer); writeType(t, 0 /* None */); - writePunctuation(writer, 23 /* SemicolonToken */); + writePunctuation(writer, 24 /* SemicolonToken */); writer.writeLine(); } } writer.decreaseIndent(); - writePunctuation(writer, 16 /* CloseBraceToken */); + writePunctuation(writer, 17 /* CloseBraceToken */); inObjectTypeLiteral = saveInObjectTypeLiteral; } } @@ -24894,7 +25033,7 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 83 /* ExtendsKeyword */); + writeKeyword(writer, 84 /* ExtendsKeyword */); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } @@ -24902,7 +25041,7 @@ var ts; function buildParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack) { var parameterNode = p.valueDeclaration; if (ts.isRestParameter(parameterNode)) { - writePunctuation(writer, 22 /* DotDotDotToken */); + writePunctuation(writer, 23 /* DotDotDotToken */); } if (ts.isBindingPattern(parameterNode.name)) { buildBindingPatternDisplay(parameterNode.name, writer, enclosingDeclaration, flags, symbolStack); @@ -24911,37 +25050,37 @@ var ts; appendSymbolNameOnly(p, writer); } if (isOptionalParameter(parameterNode)) { - writePunctuation(writer, 53 /* QuestionToken */); + writePunctuation(writer, 54 /* QuestionToken */); } - writePunctuation(writer, 54 /* ColonToken */); + writePunctuation(writer, 55 /* ColonToken */); writeSpace(writer); buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); } function buildBindingPatternDisplay(bindingPattern, writer, enclosingDeclaration, flags, symbolStack) { // We have to explicitly emit square bracket and bracket because these tokens are not stored inside the node. - if (bindingPattern.kind === 167 /* ObjectBindingPattern */) { - writePunctuation(writer, 15 /* OpenBraceToken */); + if (bindingPattern.kind === 168 /* ObjectBindingPattern */) { + writePunctuation(writer, 16 /* OpenBraceToken */); buildDisplayForCommaSeparatedList(bindingPattern.elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); - writePunctuation(writer, 16 /* CloseBraceToken */); + writePunctuation(writer, 17 /* CloseBraceToken */); } - else if (bindingPattern.kind === 168 /* ArrayBindingPattern */) { - writePunctuation(writer, 19 /* OpenBracketToken */); + else if (bindingPattern.kind === 169 /* ArrayBindingPattern */) { + writePunctuation(writer, 20 /* OpenBracketToken */); var elements = bindingPattern.elements; buildDisplayForCommaSeparatedList(elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); if (elements && elements.hasTrailingComma) { - writePunctuation(writer, 24 /* CommaToken */); + writePunctuation(writer, 25 /* CommaToken */); } - writePunctuation(writer, 20 /* CloseBracketToken */); + writePunctuation(writer, 21 /* CloseBracketToken */); } } function buildBindingElementDisplay(bindingElement, writer, enclosingDeclaration, flags, symbolStack) { if (ts.isOmittedExpression(bindingElement)) { return; } - ts.Debug.assert(bindingElement.kind === 169 /* BindingElement */); + ts.Debug.assert(bindingElement.kind === 170 /* BindingElement */); if (bindingElement.propertyName) { writer.writeSymbol(ts.getTextOfNode(bindingElement.propertyName), bindingElement.symbol); - writePunctuation(writer, 54 /* ColonToken */); + writePunctuation(writer, 55 /* ColonToken */); writeSpace(writer); } if (ts.isBindingPattern(bindingElement.name)) { @@ -24949,75 +25088,75 @@ var ts; } else { if (bindingElement.dotDotDotToken) { - writePunctuation(writer, 22 /* DotDotDotToken */); + writePunctuation(writer, 23 /* DotDotDotToken */); } appendSymbolNameOnly(bindingElement.symbol, writer); } } function buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, flags, symbolStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 25 /* LessThanToken */); + writePunctuation(writer, 26 /* LessThanToken */); buildDisplayForCommaSeparatedList(typeParameters, writer, function (p) { return buildTypeParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack); }); - writePunctuation(writer, 27 /* GreaterThanToken */); + writePunctuation(writer, 28 /* GreaterThanToken */); } } function buildDisplayForCommaSeparatedList(list, writer, action) { for (var i = 0; i < list.length; i++) { if (i > 0) { - writePunctuation(writer, 24 /* CommaToken */); + writePunctuation(writer, 25 /* CommaToken */); writeSpace(writer); } action(list[i]); } } - function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration, flags, symbolStack) { + function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 25 /* LessThanToken */); - var flags_1 = 256 /* InFirstTypeArgument */; + writePunctuation(writer, 26 /* LessThanToken */); + var flags = 256 /* InFirstTypeArgument */; for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 24 /* CommaToken */); + writePunctuation(writer, 25 /* CommaToken */); writeSpace(writer); - flags_1 = 0 /* None */; + flags = 0 /* None */; } - buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, flags_1); + buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, flags); } - writePunctuation(writer, 27 /* GreaterThanToken */); + writePunctuation(writer, 28 /* GreaterThanToken */); } } function buildDisplayForParametersAndDelimiters(thisParameter, parameters, writer, enclosingDeclaration, flags, symbolStack) { - writePunctuation(writer, 17 /* OpenParenToken */); + writePunctuation(writer, 18 /* OpenParenToken */); if (thisParameter) { buildParameterDisplay(thisParameter, writer, enclosingDeclaration, flags, symbolStack); } for (var i = 0; i < parameters.length; i++) { if (i > 0 || thisParameter) { - writePunctuation(writer, 24 /* CommaToken */); + writePunctuation(writer, 25 /* CommaToken */); writeSpace(writer); } buildParameterDisplay(parameters[i], writer, enclosingDeclaration, flags, symbolStack); } - writePunctuation(writer, 18 /* CloseParenToken */); + writePunctuation(writer, 19 /* CloseParenToken */); } function buildTypePredicateDisplay(predicate, writer, enclosingDeclaration, flags, symbolStack) { if (ts.isIdentifierTypePredicate(predicate)) { writer.writeParameter(predicate.parameterName); } else { - writeKeyword(writer, 97 /* ThisKeyword */); + writeKeyword(writer, 98 /* ThisKeyword */); } writeSpace(writer); - writeKeyword(writer, 124 /* IsKeyword */); + writeKeyword(writer, 125 /* IsKeyword */); writeSpace(writer); buildTypeDisplay(predicate.type, writer, enclosingDeclaration, flags, symbolStack); } function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { if (flags & 8 /* WriteArrowStyleSignature */) { writeSpace(writer); - writePunctuation(writer, 34 /* EqualsGreaterThanToken */); + writePunctuation(writer, 35 /* EqualsGreaterThanToken */); } else { - writePunctuation(writer, 54 /* ColonToken */); + writePunctuation(writer, 55 /* ColonToken */); } writeSpace(writer); if (signature.typePredicate) { @@ -25030,7 +25169,7 @@ var ts; } function buildSignatureDisplay(signature, writer, enclosingDeclaration, flags, kind, symbolStack) { if (kind === 1 /* Construct */) { - writeKeyword(writer, 92 /* NewKeyword */); + writeKeyword(writer, 93 /* NewKeyword */); writeSpace(writer); } if (signature.target && (flags & 32 /* WriteTypeArgumentsOfSignature */)) { @@ -25068,22 +25207,22 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 169 /* BindingElement */: + case 170 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 218 /* VariableDeclaration */: + case 219 /* 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 225 /* ModuleDeclaration */: - case 221 /* ClassDeclaration */: - case 222 /* InterfaceDeclaration */: - case 223 /* TypeAliasDeclaration */: - case 220 /* FunctionDeclaration */: - case 224 /* EnumDeclaration */: - case 229 /* ImportEqualsDeclaration */: + case 226 /* ModuleDeclaration */: + case 222 /* ClassDeclaration */: + case 223 /* InterfaceDeclaration */: + case 224 /* TypeAliasDeclaration */: + case 221 /* FunctionDeclaration */: + case 225 /* EnumDeclaration */: + case 230 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -25091,52 +25230,52 @@ var ts; var parent_10 = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedModifierFlags(node) & 1 /* Export */) && - !(node.kind !== 229 /* ImportEqualsDeclaration */ && parent_10.kind !== 256 /* SourceFile */ && ts.isInAmbientContext(parent_10))) { + !(node.kind !== 230 /* ImportEqualsDeclaration */ && parent_10.kind !== 256 /* SourceFile */ && ts.isInAmbientContext(parent_10))) { return isGlobalSourceFile(parent_10); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent_10); - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: if (ts.getModifierFlags(node) & (8 /* Private */ | 16 /* Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so const it fall into next case statement - case 148 /* Constructor */: - case 152 /* ConstructSignature */: - case 151 /* CallSignature */: - case 153 /* IndexSignature */: - case 142 /* Parameter */: - case 226 /* ModuleBlock */: - case 156 /* FunctionType */: - case 157 /* ConstructorType */: - case 159 /* TypeLiteral */: - case 155 /* TypeReference */: - case 160 /* ArrayType */: - case 161 /* TupleType */: - case 162 /* UnionType */: - case 163 /* IntersectionType */: - case 164 /* ParenthesizedType */: + case 149 /* Constructor */: + case 153 /* ConstructSignature */: + case 152 /* CallSignature */: + case 154 /* IndexSignature */: + case 143 /* Parameter */: + case 227 /* ModuleBlock */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: + case 160 /* TypeLiteral */: + case 156 /* TypeReference */: + case 161 /* ArrayType */: + case 162 /* TupleType */: + case 163 /* UnionType */: + case 164 /* IntersectionType */: + case 165 /* 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 231 /* ImportClause */: - case 232 /* NamespaceImport */: - case 234 /* ImportSpecifier */: + case 232 /* ImportClause */: + case 233 /* NamespaceImport */: + case 235 /* ImportSpecifier */: return false; // Type parameters are always visible - case 141 /* TypeParameter */: + case 142 /* TypeParameter */: // Source file and namespace export are always visible case 256 /* SourceFile */: - case 228 /* NamespaceExportDeclaration */: + case 229 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: return false; default: return false; @@ -25145,10 +25284,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 235 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 236 /* ExportAssignment */) { exportSymbol = resolveName(node.parent, node.text, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */ | 8388608 /* Alias */, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 238 /* ExportSpecifier */) { + else if (node.parent.kind === 239 /* ExportSpecifier */) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -25242,12 +25381,12 @@ var ts; node = ts.getRootDeclaration(node); while (node) { switch (node.kind) { - case 218 /* VariableDeclaration */: - case 219 /* VariableDeclarationList */: - case 234 /* ImportSpecifier */: - case 233 /* NamedImports */: - case 232 /* NamespaceImport */: - case 231 /* ImportClause */: + case 219 /* VariableDeclaration */: + case 220 /* VariableDeclarationList */: + case 235 /* ImportSpecifier */: + case 234 /* NamedImports */: + case 233 /* NamespaceImport */: + case 232 /* ImportClause */: node = node.parent; break; default: @@ -25282,12 +25421,12 @@ var ts; } function getTextOfPropertyName(name) { switch (name.kind) { - case 69 /* Identifier */: + case 70 /* Identifier */: return name.text; case 9 /* StringLiteral */: case 8 /* NumericLiteral */: return name.text; - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: if (ts.isStringOrNumericLiteral(name.expression.kind)) { return name.expression.text; } @@ -25295,7 +25434,7 @@ var ts; return undefined; } function isComputedNonLiteralName(name) { - return name.kind === 140 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteral(name.expression.kind); + return name.kind === 141 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteral(name.expression.kind); } /** Return the inferred type for a binding element */ function getTypeForBindingElement(declaration) { @@ -25315,7 +25454,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 167 /* ObjectBindingPattern */) { + if (pattern.kind === 168 /* ObjectBindingPattern */) { // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) var name_14 = declaration.propertyName || declaration.name; if (isComputedNonLiteralName(name_14)) { @@ -25383,16 +25522,16 @@ var ts; if (typeTag && typeTag.typeExpression) { return typeTag.typeExpression.type; } - if (declaration.kind === 218 /* VariableDeclaration */ && - declaration.parent.kind === 219 /* VariableDeclarationList */ && - declaration.parent.parent.kind === 200 /* VariableStatement */) { + if (declaration.kind === 219 /* VariableDeclaration */ && + declaration.parent.kind === 220 /* VariableDeclarationList */ && + declaration.parent.parent.kind === 201 /* VariableStatement */) { // @type annotation might have been on the variable statement, try that instead. var annotation = ts.getJSDocTypeTag(declaration.parent.parent); if (annotation && annotation.typeExpression) { return annotation.typeExpression.type; } } - else if (declaration.kind === 142 /* Parameter */) { + else if (declaration.kind === 143 /* Parameter */) { // If it's a parameter, see if the parent has a jsdoc comment with an @param // annotation. var paramTag = ts.getCorrespondingJSDocParameterTag(declaration); @@ -25402,9 +25541,13 @@ var ts; } return undefined; } - function isAutoVariableInitializer(initializer) { - var expr = initializer && ts.skipParentheses(initializer); - return !expr || expr.kind === 93 /* NullKeyword */ || expr.kind === 69 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; + function isNullOrUndefined(node) { + var expr = ts.skipParentheses(node); + return expr.kind === 94 /* NullKeyword */ || expr.kind === 70 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; + } + function isEmptyArrayLiteral(node) { + var expr = ts.skipParentheses(node); + return expr.kind === 171 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, optional) { return strictNullChecks && optional ? includeFalsyTypes(type, 2048 /* Undefined */) : type; @@ -25421,10 +25564,10 @@ var ts; } } // A variable declared in a for..in statement is always of type string - if (declaration.parent.parent.kind === 207 /* ForInStatement */) { + if (declaration.parent.parent.kind === 208 /* ForInStatement */) { return stringType; } - if (declaration.parent.parent.kind === 208 /* ForOfStatement */) { + if (declaration.parent.parent.kind === 209 /* 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, @@ -25438,18 +25581,24 @@ var ts; if (declaration.type) { return addOptionality(getTypeFromTypeNode(declaration.type), /*optional*/ declaration.questionToken && includeOptionality); } - // Use control flow type inference for non-ambient, non-exported var or let variables with no initializer - // or a 'null' or 'undefined' initializer. - if (declaration.kind === 218 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && - !(ts.getCombinedNodeFlags(declaration) & 2 /* Const */) && !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && - !ts.isInAmbientContext(declaration) && isAutoVariableInitializer(declaration.initializer)) { - return autoType; + if (declaration.kind === 219 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !ts.isInAmbientContext(declaration)) { + // Use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no + // initializer or a 'null' or 'undefined' initializer. + if (!(ts.getCombinedNodeFlags(declaration) & 2 /* Const */) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { + return autoType; + } + // Use control flow tracked 'any[]' type for non-ambient, non-exported variables with an empty array + // literal initializer. + if (declaration.initializer && isEmptyArrayLiteral(declaration.initializer)) { + return autoArrayType; + } } - if (declaration.kind === 142 /* Parameter */) { + if (declaration.kind === 143 /* 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 === 150 /* SetAccessor */ && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 149 /* GetAccessor */); + if (func.kind === 151 /* SetAccessor */ && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 150 /* GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -25464,8 +25613,7 @@ var ts; // Use contextual parameter type if one is available var type = void 0; if (declaration.symbol.name === "this") { - var thisParameter = getContextualThisParameter(func); - type = thisParameter ? getTypeOfSymbol(thisParameter) : undefined; + type = getContextualThisParameterType(func); } else { type = getContextuallyTypedParameterType(declaration); @@ -25537,7 +25685,7 @@ var ts; var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); if (elements.length === 0 || (!ts.isOmittedExpression(lastElement) && lastElement.dotDotDotToken)) { - return languageVersion >= 2 /* ES6 */ ? createIterableType(anyType) : anyArrayType; + return languageVersion >= 2 /* ES2015 */ ? 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 ts.isOmittedExpression(e) ? anyType : getTypeFromBindingElement(e, includePatternInType, reportErrors); }); @@ -25556,7 +25704,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, reportErrors) { - return pattern.kind === 167 /* ObjectBindingPattern */ + return pattern.kind === 168 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -25595,7 +25743,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 142 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 143 /* Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function getTypeOfVariableOrParameterOrProperty(symbol) { @@ -25611,7 +25759,7 @@ var ts; return links.type = anyType; } // Handle export default expressions - if (declaration.kind === 235 /* ExportAssignment */) { + if (declaration.kind === 236 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } if (declaration.flags & 1048576 /* JavaScriptFile */ && declaration.kind === 280 /* JSDocPropertyTag */ && declaration.typeExpression) { @@ -25627,8 +25775,8 @@ var ts; // * exports.p = expr // * this.p = expr // * className.prototype.method = expr - if (declaration.kind === 187 /* BinaryExpression */ || - declaration.kind === 172 /* PropertyAccessExpression */ && declaration.parent.kind === 187 /* BinaryExpression */) { + if (declaration.kind === 188 /* BinaryExpression */ || + declaration.kind === 173 /* PropertyAccessExpression */ && declaration.parent.kind === 188 /* BinaryExpression */) { // Use JS Doc type if present on parent expression statement if (declaration.flags & 1048576 /* JavaScriptFile */) { var typeTag = ts.getJSDocTypeTag(declaration.parent); @@ -25636,7 +25784,7 @@ var ts; return links.type = getTypeFromTypeNode(typeTag.typeExpression.type); } } - var declaredTypes = ts.map(symbol.declarations, function (decl) { return decl.kind === 187 /* BinaryExpression */ ? + var declaredTypes = ts.map(symbol.declarations, function (decl) { return decl.kind === 188 /* BinaryExpression */ ? checkExpressionCached(decl.right) : checkExpressionCached(decl.parent.right); }); type = getUnionType(declaredTypes, /*subtypeReduction*/ true); @@ -25664,7 +25812,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 149 /* GetAccessor */) { + if (accessor.kind === 150 /* GetAccessor */) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -25684,8 +25832,8 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - var getter = ts.getDeclarationOfKind(symbol, 149 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 150 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 150 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 151 /* SetAccessor */); if (getter && getter.flags & 1048576 /* JavaScriptFile */) { var jsDocType = getTypeForVariableLikeDeclarationFromJSDocComment(getter); if (jsDocType) { @@ -25729,7 +25877,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 149 /* GetAccessor */); + var getter_1 = ts.getDeclarationOfKind(symbol, 150 /* 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)); } } @@ -25740,7 +25888,7 @@ var ts; function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (symbol.valueDeclaration.kind === 225 /* ModuleDeclaration */ && ts.isShorthandAmbientModuleSymbol(symbol)) { + if (symbol.valueDeclaration.kind === 226 /* ModuleDeclaration */ && ts.isShorthandAmbientModuleSymbol(symbol)) { links.type = anyType; } else { @@ -25836,9 +25984,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 221 /* ClassDeclaration */ || node.kind === 192 /* ClassExpression */ || - node.kind === 220 /* FunctionDeclaration */ || node.kind === 179 /* FunctionExpression */ || - node.kind === 147 /* MethodDeclaration */ || node.kind === 180 /* ArrowFunction */) { + if (node.kind === 222 /* ClassDeclaration */ || node.kind === 193 /* ClassExpression */ || + node.kind === 221 /* FunctionDeclaration */ || node.kind === 180 /* FunctionExpression */ || + node.kind === 148 /* MethodDeclaration */ || node.kind === 181 /* ArrowFunction */) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -25848,7 +25996,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, 222 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 223 /* InterfaceDeclaration */); return appendOuterTypeParameters(undefined, declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -25857,8 +26005,8 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 222 /* InterfaceDeclaration */ || node.kind === 221 /* ClassDeclaration */ || - node.kind === 192 /* ClassExpression */ || node.kind === 223 /* TypeAliasDeclaration */) { + if (node.kind === 223 /* InterfaceDeclaration */ || node.kind === 222 /* ClassDeclaration */ || + node.kind === 193 /* ClassExpression */ || node.kind === 224 /* TypeAliasDeclaration */) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -26001,7 +26149,7 @@ var ts; type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 222 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 223 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -26033,7 +26181,7 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 222 /* InterfaceDeclaration */) { + if (declaration.kind === 223 /* InterfaceDeclaration */) { if (declaration.flags & 64 /* ContainsThis */) { return false; } @@ -26102,7 +26250,7 @@ var ts; } } else { - declaration = ts.getDeclarationOfKind(symbol, 223 /* TypeAliasDeclaration */); + declaration = ts.getDeclarationOfKind(symbol, 224 /* TypeAliasDeclaration */); type = getTypeFromTypeNode(declaration.type, symbol, typeParameters); } if (popTypeResolution()) { @@ -26128,14 +26276,14 @@ var ts; return !ts.isInAmbientContext(member); } return expr.kind === 8 /* NumericLiteral */ || - expr.kind === 185 /* PrefixUnaryExpression */ && expr.operator === 36 /* MinusToken */ && + expr.kind === 186 /* PrefixUnaryExpression */ && expr.operator === 37 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */ || - expr.kind === 69 /* Identifier */ && !!symbol.exports[expr.text]; + expr.kind === 70 /* Identifier */ && !!symbol.exports[expr.text]; } function enumHasLiteralMembers(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 224 /* EnumDeclaration */) { + if (declaration.kind === 225 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (!isLiteralEnumMember(symbol, member)) { @@ -26163,7 +26311,7 @@ var ts; var memberTypes = ts.createMap(); for (var _i = 0, _a = enumType.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 224 /* EnumDeclaration */) { + if (declaration.kind === 225 /* EnumDeclaration */) { computeEnumMemberValues(declaration); for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; @@ -26201,7 +26349,7 @@ var ts; if (!links.declaredType) { var type = createType(16384 /* TypeParameter */); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 141 /* TypeParameter */).constraint) { + if (!ts.getDeclarationOfKind(symbol, 142 /* TypeParameter */).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -26254,20 +26402,20 @@ var ts; // considered independent. function isIndependentType(node) { switch (node.kind) { - case 117 /* AnyKeyword */: - case 132 /* StringKeyword */: - case 130 /* NumberKeyword */: - case 120 /* BooleanKeyword */: - case 133 /* SymbolKeyword */: - case 103 /* VoidKeyword */: - case 135 /* UndefinedKeyword */: - case 93 /* NullKeyword */: - case 127 /* NeverKeyword */: - case 166 /* LiteralType */: + case 118 /* AnyKeyword */: + case 133 /* StringKeyword */: + case 131 /* NumberKeyword */: + case 121 /* BooleanKeyword */: + case 134 /* SymbolKeyword */: + case 104 /* VoidKeyword */: + case 136 /* UndefinedKeyword */: + case 94 /* NullKeyword */: + case 128 /* NeverKeyword */: + case 167 /* LiteralType */: return true; - case 160 /* ArrayType */: + case 161 /* ArrayType */: return isIndependentType(node.elementType); - case 155 /* TypeReference */: + case 156 /* TypeReference */: return isIndependentTypeReference(node); } return false; @@ -26280,7 +26428,7 @@ var ts; // 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 !== 148 /* Constructor */ && (!node.type || !isIndependentType(node.type))) { + if (node.kind !== 149 /* Constructor */ && (!node.type || !isIndependentType(node.type))) { return false; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { @@ -26301,12 +26449,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: return isIndependentVariableLikeDeclaration(declaration); - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: return isIndependentFunctionLikeDeclaration(declaration); } } @@ -26933,7 +27081,7 @@ var ts; return false; } function createTypePredicateFromTypePredicateNode(node) { - if (node.parameterName.kind === 69 /* Identifier */) { + if (node.parameterName.kind === 70 /* Identifier */) { var parameterName = node.parameterName; return { kind: 1 /* Identifier */, @@ -26976,7 +27124,7 @@ var ts; else { parameters.push(paramSymbol); } - if (param.type && param.type.kind === 166 /* LiteralType */) { + if (param.type && param.type.kind === 167 /* LiteralType */) { hasLiteralTypes = true; } if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) { @@ -26990,10 +27138,10 @@ var ts; } } // If only one accessor includes a this-type annotation, the other behaves as if it had the same type annotation - if ((declaration.kind === 149 /* GetAccessor */ || declaration.kind === 150 /* SetAccessor */) && + if ((declaration.kind === 150 /* GetAccessor */ || declaration.kind === 151 /* SetAccessor */) && !ts.hasDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 149 /* GetAccessor */ ? 150 /* SetAccessor */ : 149 /* GetAccessor */; + var otherKind = declaration.kind === 150 /* GetAccessor */ ? 151 /* SetAccessor */ : 150 /* GetAccessor */; var other = ts.getDeclarationOfKind(declaration.symbol, otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); @@ -27005,24 +27153,21 @@ var ts; if (isJSConstructSignature) { minArgumentCount--; } - if (!thisParameter && ts.isObjectLiteralMethod(declaration)) { - thisParameter = getContextualThisParameter(declaration); - } - var classType = declaration.kind === 148 /* Constructor */ ? + var classType = declaration.kind === 149 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : getTypeParametersFromJSDocTemplate(declaration); - var returnType = getSignatureReturnTypeFromDeclaration(declaration, minArgumentCount, isJSConstructSignature, classType); - var typePredicate = declaration.type && declaration.type.kind === 154 /* TypePredicate */ ? + var returnType = getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType); + var typePredicate = declaration.type && declaration.type.kind === 155 /* TypePredicate */ ? createTypePredicateFromTypePredicateNode(declaration.type) : undefined; links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasLiteralTypes); } return links.resolvedSignature; } - function getSignatureReturnTypeFromDeclaration(declaration, minArgumentCount, isJSConstructSignature, classType) { + function getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType) { if (isJSConstructSignature) { return getTypeFromTypeNode(declaration.parameters[0].type); } @@ -27040,8 +27185,8 @@ var ts; } // 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 === 149 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 150 /* SetAccessor */); + if (declaration.kind === 150 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 151 /* SetAccessor */); return getAnnotatedAccessorType(setter); } if (ts.nodeIsMissing(declaration.body)) { @@ -27055,19 +27200,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 156 /* FunctionType */: - case 157 /* ConstructorType */: - case 220 /* FunctionDeclaration */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: + case 221 /* FunctionDeclaration */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: case 269 /* JSDocFunctionType */: // 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 @@ -27155,7 +27300,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 === 148 /* Constructor */ || signature.declaration.kind === 152 /* ConstructSignature */; + var isConstructor = signature.declaration.kind === 149 /* Constructor */ || signature.declaration.kind === 153 /* ConstructSignature */; var type = createObjectType(2097152 /* Anonymous */); type.members = emptySymbols; type.properties = emptyArray; @@ -27169,7 +27314,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 130 /* NumberKeyword */ : 132 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 131 /* NumberKeyword */ : 133 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -27196,7 +27341,7 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - return ts.getDeclarationOfKind(type.symbol, 141 /* TypeParameter */).constraint; + return ts.getDeclarationOfKind(type.symbol, 142 /* TypeParameter */).constraint; } function hasConstraintReferenceTo(type, target) { var checked; @@ -27229,7 +27374,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 141 /* TypeParameter */).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 142 /* TypeParameter */).parent); } function getTypeListId(types) { var result = ""; @@ -27341,11 +27486,11 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 155 /* TypeReference */: + case 156 /* TypeReference */: return node.typeName; case 267 /* JSDocTypeReference */: return node.name; - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -27355,7 +27500,7 @@ var ts; } return undefined; } - function resolveTypeReferenceName(node, typeReferenceName) { + function resolveTypeReferenceName(typeReferenceName) { if (!typeReferenceName) { return unknownSymbol; } @@ -27386,12 +27531,12 @@ var ts; var type = void 0; if (node.kind === 267 /* JSDocTypeReference */) { var typeReferenceName = getTypeReferenceName(node); - symbol = resolveTypeReferenceName(node, typeReferenceName); + symbol = resolveTypeReferenceName(typeReferenceName); type = getTypeReferenceType(node, symbol); } else { // We only support expressions that are simple qualified names. For other expressions this produces undefined. - var typeNameOrExpression = node.kind === 155 /* TypeReference */ + var typeNameOrExpression = node.kind === 156 /* TypeReference */ ? node.typeName : ts.isEntityNameExpression(node.expression) ? node.expression @@ -27426,9 +27571,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 221 /* ClassDeclaration */: - case 222 /* InterfaceDeclaration */: - case 224 /* EnumDeclaration */: + case 222 /* ClassDeclaration */: + case 223 /* InterfaceDeclaration */: + case 225 /* EnumDeclaration */: return declaration; } } @@ -27838,9 +27983,9 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 222 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 223 /* InterfaceDeclaration */)) { if (!(ts.getModifierFlags(container) & 32 /* Static */) && - (container.kind !== 148 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { + (container.kind !== 149 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -27859,25 +28004,25 @@ var ts; } function getTypeFromTypeNode(node, aliasSymbol, aliasTypeArguments) { switch (node.kind) { - case 117 /* AnyKeyword */: + case 118 /* AnyKeyword */: case 258 /* JSDocAllType */: case 259 /* JSDocUnknownType */: return anyType; - case 132 /* StringKeyword */: + case 133 /* StringKeyword */: return stringType; - case 130 /* NumberKeyword */: + case 131 /* NumberKeyword */: return numberType; - case 120 /* BooleanKeyword */: + case 121 /* BooleanKeyword */: return booleanType; - case 133 /* SymbolKeyword */: + case 134 /* SymbolKeyword */: return esSymbolType; - case 103 /* VoidKeyword */: + case 104 /* VoidKeyword */: return voidType; - case 135 /* UndefinedKeyword */: + case 136 /* UndefinedKeyword */: return undefinedType; - case 93 /* NullKeyword */: + case 94 /* NullKeyword */: return nullType; - case 127 /* NeverKeyword */: + case 128 /* NeverKeyword */: return neverType; case 283 /* JSDocNullKeyword */: return nullType; @@ -27885,33 +28030,33 @@ var ts; return undefinedType; case 285 /* JSDocNeverKeyword */: return neverType; - case 165 /* ThisType */: - case 97 /* ThisKeyword */: + case 166 /* ThisType */: + case 98 /* ThisKeyword */: return getTypeFromThisTypeNode(node); - case 166 /* LiteralType */: + case 167 /* LiteralType */: return getTypeFromLiteralTypeNode(node); case 282 /* JSDocLiteralType */: return getTypeFromLiteralTypeNode(node.literal); - case 155 /* TypeReference */: + case 156 /* TypeReference */: case 267 /* JSDocTypeReference */: return getTypeFromTypeReference(node); - case 154 /* TypePredicate */: + case 155 /* TypePredicate */: return booleanType; - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 158 /* TypeQuery */: + case 159 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 160 /* ArrayType */: + case 161 /* ArrayType */: case 260 /* JSDocArrayType */: return getTypeFromArrayTypeNode(node); - case 161 /* TupleType */: + case 162 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 162 /* UnionType */: + case 163 /* UnionType */: case 261 /* JSDocUnionType */: return getTypeFromUnionTypeNode(node, aliasSymbol, aliasTypeArguments); - case 163 /* IntersectionType */: + case 164 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node, aliasSymbol, aliasTypeArguments); - case 164 /* ParenthesizedType */: + case 165 /* ParenthesizedType */: case 263 /* JSDocNullableType */: case 264 /* JSDocNonNullableType */: case 271 /* JSDocConstructorType */: @@ -27920,16 +28065,16 @@ var ts; return getTypeFromTypeNode(node.type); case 265 /* JSDocRecordType */: return getTypeFromTypeNode(node.literal); - case 156 /* FunctionType */: - case 157 /* ConstructorType */: - case 159 /* TypeLiteral */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: + case 160 /* TypeLiteral */: case 281 /* JSDocTypeLiteral */: case 269 /* JSDocFunctionType */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node, aliasSymbol, aliasTypeArguments); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode - case 69 /* Identifier */: - case 139 /* QualifiedName */: + case 70 /* Identifier */: + case 140 /* QualifiedName */: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); case 262 /* JSDocTupleType */: @@ -28097,23 +28242,23 @@ var ts; var node = symbol.declarations[0].parent; while (node) { switch (node.kind) { - case 156 /* FunctionType */: - case 157 /* ConstructorType */: - case 220 /* FunctionDeclaration */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - case 222 /* InterfaceDeclaration */: - case 223 /* TypeAliasDeclaration */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: + case 221 /* FunctionDeclaration */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 223 /* InterfaceDeclaration */: + case 224 /* TypeAliasDeclaration */: var declaration = node; if (declaration.typeParameters) { for (var _i = 0, _a = declaration.typeParameters; _i < _a.length; _i++) { @@ -28123,14 +28268,14 @@ var ts; } } } - if (ts.isClassLike(node) || node.kind === 222 /* InterfaceDeclaration */) { + if (ts.isClassLike(node) || node.kind === 223 /* InterfaceDeclaration */) { var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; if (thisType && ts.contains(mappedTypes, thisType)) { return true; } } break; - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: case 256 /* SourceFile */: return false; } @@ -28173,35 +28318,50 @@ 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 !== 147 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 148 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: return isContextSensitiveFunctionLikeDeclaration(node); - case 171 /* ObjectLiteralExpression */: + case 172 /* ObjectLiteralExpression */: return ts.forEach(node.properties, isContextSensitive); - case 170 /* ArrayLiteralExpression */: + case 171 /* ArrayLiteralExpression */: return ts.forEach(node.elements, isContextSensitive); - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 187 /* BinaryExpression */: - return node.operatorToken.kind === 52 /* BarBarToken */ && + case 188 /* BinaryExpression */: + return node.operatorToken.kind === 53 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); case 253 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: return isContextSensitiveFunctionLikeDeclaration(node); - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return isContextSensitive(node.expression); } return false; } function isContextSensitiveFunctionLikeDeclaration(node) { - var areAllParametersUntyped = !ts.forEach(node.parameters, function (p) { return p.type; }); - var isNullaryArrow = node.kind === 180 /* ArrowFunction */ && !node.parameters.length; - return !node.typeParameters && areAllParametersUntyped && !isNullaryArrow; + // Functions with type parameters are not context sensitive. + if (node.typeParameters) { + return false; + } + // Functions with any parameters that lack type annotations are context sensitive. + if (ts.forEach(node.parameters, function (p) { return !p.type; })) { + return true; + } + // For arrow functions we now know we're not context sensitive. + if (node.kind === 181 /* ArrowFunction */) { + return false; + } + // If the first parameter is not an explicit 'this' parameter, then the function has + // an implicit 'this' parameter which is subject to contextual typing. Otherwise we + // know that all parameters (including 'this') have type annotations and nothing is + // subject to contextual typing. + var parameter = ts.firstOrUndefined(node.parameters); + return !(parameter && ts.parameterIsThisKeyword(parameter)); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func); @@ -28691,8 +28851,8 @@ var ts; } if (source.flags & 524288 /* Union */ && target.flags & 524288 /* Union */ || source.flags & 1048576 /* Intersection */ && target.flags & 1048576 /* Intersection */) { - if (result = eachTypeRelatedToSomeType(source, target, /*reportErrors*/ false)) { - if (result &= eachTypeRelatedToSomeType(target, source, /*reportErrors*/ false)) { + if (result = eachTypeRelatedToSomeType(source, target)) { + if (result &= eachTypeRelatedToSomeType(target, source)) { return result; } } @@ -28750,7 +28910,7 @@ var ts; } return false; } - function eachTypeRelatedToSomeType(source, target, reportErrors) { + function eachTypeRelatedToSomeType(source, target) { var result = -1 /* True */; var sourceTypes = source.types; for (var _i = 0, sourceTypes_1 = sourceTypes; _i < sourceTypes_1.length; _i++) { @@ -29414,7 +29574,7 @@ var ts; type.flags & 64 /* NumberLiteral */ ? numberType : type.flags & 128 /* BooleanLiteral */ ? booleanType : type.flags & 256 /* EnumLiteral */ ? type.baseType : - type.flags & 524288 /* Union */ && !(type.flags & 16 /* Enum */) ? getUnionType(ts.map(type.types, getBaseTypeOfLiteralType)) : + type.flags & 524288 /* Union */ && !(type.flags & 16 /* Enum */) ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) : type; } function getWidenedLiteralType(type) { @@ -29422,7 +29582,7 @@ var ts; type.flags & 64 /* NumberLiteral */ && type.flags & 16777216 /* FreshLiteral */ ? numberType : type.flags & 128 /* BooleanLiteral */ ? booleanType : type.flags & 256 /* EnumLiteral */ ? type.baseType : - type.flags & 524288 /* Union */ && !(type.flags & 16 /* Enum */) ? getUnionType(ts.map(type.types, getWidenedLiteralType)) : + type.flags & 524288 /* Union */ && !(type.flags & 16 /* Enum */) ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) : type; } /** @@ -29549,10 +29709,10 @@ var ts; return getWidenedTypeOfObjectLiteral(type); } if (type.flags & 524288 /* Union */) { - return getUnionType(ts.map(type.types, getWidenedConstituentType)); + return getUnionType(ts.sameMap(type.types, getWidenedConstituentType)); } if (isArrayType(type) || isTupleType(type)) { - return createTypeReference(type.target, ts.map(type.typeArguments, getWidenedType)); + return createTypeReference(type.target, ts.sameMap(type.typeArguments, getWidenedType)); } } return type; @@ -29604,25 +29764,25 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 142 /* Parameter */: + case 143 /* 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 169 /* BindingElement */: + case 170 /* BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 220 /* FunctionDeclaration */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 221 /* FunctionDeclaration */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -29668,7 +29828,7 @@ var ts; signature: signature, inferUnionTypes: inferUnionTypes, inferences: inferences, - inferredTypes: new Array(signature.typeParameters.length) + inferredTypes: new Array(signature.typeParameters.length), }; } function createTypeInferencesObject() { @@ -29676,7 +29836,7 @@ var ts; primary: undefined, secondary: undefined, topLevel: true, - isFixed: false + isFixed: false, }; } // Return true if the given type could possibly reference a type parameter for which @@ -29957,7 +30117,7 @@ var ts; var widenLiteralTypes = context.inferences[index].topLevel && !hasPrimitiveConstraint(signature.typeParameters[index]) && (context.inferences[index].isFixed || !isTypeParameterAtTopLevel(getReturnTypeOfSignature(signature), signature.typeParameters[index])); - var baseInferences = widenLiteralTypes ? ts.map(inferences, getWidenedLiteralType) : inferences; + var baseInferences = widenLiteralTypes ? ts.sameMap(inferences, getWidenedLiteralType) : inferences; // Infer widened union or supertype, or the unknown type for no common supertype var unionOrSuperType = context.inferUnionTypes ? getUnionType(baseInferences, /*subtypeReduction*/ true) : getCommonSupertype(baseInferences); inferredType = unionOrSuperType ? getWidenedType(unionOrSuperType) : unknownType; @@ -30011,10 +30171,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 158 /* TypeQuery */: + case 159 /* TypeQuery */: return true; - case 69 /* Identifier */: - case 139 /* QualifiedName */: + case 70 /* Identifier */: + case 140 /* QualifiedName */: node = node.parent; continue; default: @@ -30028,14 +30188,14 @@ var ts; // leftmost identifier followed by zero or more property names separated by dots. // The result is undefined if the reference isn't a dotted name. function getFlowCacheKey(node) { - if (node.kind === 69 /* Identifier */) { + if (node.kind === 70 /* Identifier */) { var symbol = getResolvedSymbol(node); return symbol !== unknownSymbol ? "" + getSymbolId(symbol) : undefined; } - if (node.kind === 97 /* ThisKeyword */) { + if (node.kind === 98 /* ThisKeyword */) { return "0"; } - if (node.kind === 172 /* PropertyAccessExpression */) { + if (node.kind === 173 /* PropertyAccessExpression */) { var key = getFlowCacheKey(node.expression); return key && key + "." + node.name.text; } @@ -30043,31 +30203,31 @@ var ts; } function getLeftmostIdentifierOrThis(node) { switch (node.kind) { - case 69 /* Identifier */: - case 97 /* ThisKeyword */: + case 70 /* Identifier */: + case 98 /* ThisKeyword */: return node; - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: return getLeftmostIdentifierOrThis(node.expression); } return undefined; } function isMatchingReference(source, target) { switch (source.kind) { - case 69 /* Identifier */: - return target.kind === 69 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 218 /* VariableDeclaration */ || target.kind === 169 /* BindingElement */) && + case 70 /* Identifier */: + return target.kind === 70 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 219 /* VariableDeclaration */ || target.kind === 170 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 97 /* ThisKeyword */: - return target.kind === 97 /* ThisKeyword */; - case 172 /* PropertyAccessExpression */: - return target.kind === 172 /* PropertyAccessExpression */ && + case 98 /* ThisKeyword */: + return target.kind === 98 /* ThisKeyword */; + case 173 /* PropertyAccessExpression */: + return target.kind === 173 /* PropertyAccessExpression */ && source.name.text === target.name.text && isMatchingReference(source.expression, target.expression); } return false; } function containsMatchingReference(source, target) { - while (source.kind === 172 /* PropertyAccessExpression */) { + while (source.kind === 173 /* PropertyAccessExpression */) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -30080,15 +30240,15 @@ var ts; // a possible discriminant if its type differs in the constituents of containing union type, and if every // choice is a unit type or a union of unit types. function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 172 /* PropertyAccessExpression */ && + return target.kind === 173 /* PropertyAccessExpression */ && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.text); } function getDeclaredTypeOfReference(expr) { - if (expr.kind === 69 /* Identifier */) { + if (expr.kind === 70 /* Identifier */) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 172 /* PropertyAccessExpression */) { + if (expr.kind === 173 /* PropertyAccessExpression */) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.text); } @@ -30118,7 +30278,7 @@ var ts; } } } - if (callExpression.expression.kind === 172 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 173 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -30249,7 +30409,7 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false) || unknownType); } function getAssignedTypeOfBinaryExpression(node) { - return node.parent.kind === 170 /* ArrayLiteralExpression */ || node.parent.kind === 253 /* PropertyAssignment */ ? + return node.parent.kind === 171 /* ArrayLiteralExpression */ || node.parent.kind === 253 /* PropertyAssignment */ ? getTypeWithDefault(getAssignedType(node), node.right) : checkExpression(node.right); } @@ -30268,17 +30428,17 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 207 /* ForInStatement */: + case 208 /* ForInStatement */: return stringType; - case 208 /* ForOfStatement */: + case 209 /* ForOfStatement */: return checkRightHandSideOfForOf(parent.expression) || unknownType; - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 181 /* DeleteExpression */: + case 182 /* DeleteExpression */: return undefinedType; - case 170 /* ArrayLiteralExpression */: + case 171 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 191 /* SpreadElementExpression */: + case 192 /* SpreadElementExpression */: return getAssignedTypeOfSpreadElement(parent); case 253 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); @@ -30290,7 +30450,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 167 /* ObjectBindingPattern */ ? + var type = pattern.kind === 168 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, ts.indexOf(pattern.elements, node)) : @@ -30308,38 +30468,51 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 207 /* ForInStatement */) { + if (node.parent.parent.kind === 208 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 208 /* ForOfStatement */) { + if (node.parent.parent.kind === 209 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent.expression) || unknownType; } return unknownType; } function getInitialType(node) { - return node.kind === 218 /* VariableDeclaration */ ? + return node.kind === 219 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 218 /* VariableDeclaration */ || node.kind === 169 /* BindingElement */ ? + return node.kind === 219 /* VariableDeclaration */ || node.kind === 170 /* BindingElement */ ? getInitialType(node) : getAssignedType(node); } + function isEmptyArrayAssignment(node) { + return node.kind === 219 /* VariableDeclaration */ && node.initializer && + isEmptyArrayLiteral(node.initializer) || + node.kind !== 170 /* BindingElement */ && node.parent.kind === 188 /* BinaryExpression */ && + isEmptyArrayLiteral(node.parent.right); + } function getReferenceCandidate(node) { switch (node.kind) { - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 56 /* EqualsToken */: + case 57 /* EqualsToken */: return getReferenceCandidate(node.left); - case 24 /* CommaToken */: + case 25 /* CommaToken */: return getReferenceCandidate(node.right); } } return node; } + function getReferenceRoot(node) { + var parent = node.parent; + return parent.kind === 179 /* ParenthesizedExpression */ || + parent.kind === 188 /* BinaryExpression */ && parent.operatorToken.kind === 57 /* EqualsToken */ && parent.left === node || + parent.kind === 188 /* BinaryExpression */ && parent.operatorToken.kind === 25 /* CommaToken */ && parent.right === node ? + getReferenceRoot(parent) : node; + } function getTypeOfSwitchClause(clause) { if (clause.kind === 249 /* CaseClause */) { var caseType = getRegularTypeOfLiteralType(checkExpression(clause.expression)); @@ -30415,24 +30588,105 @@ var ts; function createFlowType(type, incomplete) { return incomplete ? { flags: 0, type: type } : type; } + // An evolving array type tracks the element types that have so far been seen in an + // 'x.push(value)' or 'x[n] = value' operation along the control flow graph. Evolving + // array types are ultimately converted into manifest array types (using getFinalArrayType) + // and never escape the getFlowTypeOfReference function. + function createEvolvingArrayType(elementType) { + var result = createObjectType(2097152 /* Anonymous */); + result.elementType = elementType; + return result; + } + function getEvolvingArrayType(elementType) { + return evolvingArrayTypes[elementType.id] || (evolvingArrayTypes[elementType.id] = createEvolvingArrayType(elementType)); + } + // When adding evolving array element types we do not perform subtype reduction. Instead, + // we defer subtype reduction until the evolving array type is finalized into a manifest + // array type. + function addEvolvingArrayElementType(evolvingArrayType, node) { + var elementType = getBaseTypeOfLiteralType(checkExpression(node)); + return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType])); + } + function isEvolvingArrayType(type) { + return !!(type.flags & 2097152 /* Anonymous */ && type.elementType); + } + function createFinalArrayType(elementType) { + return elementType.flags & 8192 /* Never */ ? + autoArrayType : + createArrayType(elementType.flags & 524288 /* Union */ ? + getUnionType(elementType.types, /*subtypeReduction*/ true) : + elementType); + } + // We perform subtype reduction upon obtaining the final array type from an evolving array type. + function getFinalArrayType(evolvingArrayType) { + return evolvingArrayType.finalArrayType || (evolvingArrayType.finalArrayType = createFinalArrayType(evolvingArrayType.elementType)); + } + function finalizeEvolvingArrayType(type) { + return isEvolvingArrayType(type) ? getFinalArrayType(type) : type; + } + function getElementTypeOfEvolvingArrayType(type) { + return isEvolvingArrayType(type) ? type.elementType : neverType; + } + function isEvolvingArrayTypeList(types) { + var hasEvolvingArrayType = false; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; + if (!(t.flags & 8192 /* Never */)) { + if (!isEvolvingArrayType(t)) { + return false; + } + hasEvolvingArrayType = true; + } + } + return hasEvolvingArrayType; + } + // At flow control branch or loop junctions, if the type along every antecedent code path + // is an evolving array type, we construct a combined evolving array type. Otherwise we + // finalize all evolving array types. + function getUnionOrEvolvingArrayType(types, subtypeReduction) { + return isEvolvingArrayTypeList(types) ? + getEvolvingArrayType(getUnionType(ts.map(types, getElementTypeOfEvolvingArrayType))) : + getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction); + } + // Return true if the given node is 'x' in an 'x.length', x.push(value)', 'x.unshift(value)' or + // 'x[n] = value' operation, where 'n' is an expression of type any, undefined, or a number-like type. + function isEvolvingArrayOperationTarget(node) { + var root = getReferenceRoot(node); + var parent = root.parent; + var isLengthPushOrUnshift = parent.kind === 173 /* PropertyAccessExpression */ && (parent.name.text === "length" || + parent.parent.kind === 175 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 174 /* ElementAccessExpression */ && + parent.expression === root && + parent.parent.kind === 188 /* BinaryExpression */ && + parent.parent.operatorToken.kind === 57 /* EqualsToken */ && + parent.parent.left === parent && + !ts.isAssignmentTarget(parent.parent) && + isTypeAnyOrAllConstituentTypesHaveKind(checkExpression(parent.argumentExpression), 340 /* NumberLike */ | 2048 /* Undefined */); + return isLengthPushOrUnshift || isElementAssignment; + } function getFlowTypeOfReference(reference, declaredType, assumeInitialized, flowContainer) { var key; if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 4178943 /* Narrowable */)) { return declaredType; } var initialType = assumeInitialized ? declaredType : - declaredType === autoType ? undefinedType : + declaredType === autoType || declaredType === autoArrayType ? undefinedType : includeFalsyTypes(declaredType, 2048 /* Undefined */); var visitedFlowStart = visitedFlowCount; - var result = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); + var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); visitedFlowCount = visitedFlowStart; - if (reference.parent.kind === 196 /* NonNullExpression */ && getTypeWithFacts(result, 524288 /* NEUndefinedOrNull */).flags & 8192 /* Never */) { + // When the reference is 'x' in an 'x.length', 'x.push(value)', 'x.unshift(value)' or x[n] = value' operation, + // we give type 'any[]' to 'x' instead of using the type determined by control flow analysis such that operations + // on empty arrays are possible without implicit any errors and new element types can be inferred without + // type mismatch errors. + var resultType = isEvolvingArrayType(evolvedType) && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); + if (reference.parent.kind === 197 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 8192 /* Never */) { return declaredType; } - return result; + return resultType; function getTypeAtFlowNode(flow) { while (true) { - if (flow.flags & 512 /* Shared */) { + if (flow.flags & 1024 /* Shared */) { // We cache results of flow type resolution for shared nodes that were previously visited in // the same getFlowTypeOfReference invocation. A node is considered shared when it is the // antecedent of more than one node. @@ -30465,10 +30719,17 @@ var ts; getTypeAtFlowBranchLabel(flow) : getTypeAtFlowLoopLabel(flow); } + else if (flow.flags & 256 /* ArrayMutation */) { + type = getTypeAtFlowArrayMutation(flow); + if (!type) { + flow = flow.antecedent; + continue; + } + } else if (flow.flags & 2 /* Start */) { // Check if we should continue with the control flow of the containing function. var container = flow.container; - if (container && container !== flowContainer && reference.kind !== 172 /* PropertyAccessExpression */) { + if (container && container !== flowContainer && reference.kind !== 173 /* PropertyAccessExpression */) { flow = container.flowNode; continue; } @@ -30477,10 +30738,10 @@ var ts; } else { // Unreachable code errors are reported in the binding phase. Here we - // simply return the declared type to reduce follow-on errors. - type = declaredType; + // simply return the non-auto declared type to reduce follow-on errors. + type = convertAutoToAny(declaredType); } - if (flow.flags & 512 /* Shared */) { + if (flow.flags & 1024 /* Shared */) { // Record visited node and the associated type in the cache. visitedFlowNodes[visitedFlowCount] = flow; visitedFlowTypes[visitedFlowCount] = type; @@ -30494,13 +30755,21 @@ var ts; // Assignments only narrow the computed type if the declared type is a union type. Thus, we // only need to evaluate the assigned type if the declared type is a union type. if (isMatchingReference(reference, node)) { - if (node.parent.kind === 185 /* PrefixUnaryExpression */ || node.parent.kind === 186 /* PostfixUnaryExpression */) { + if (node.parent.kind === 186 /* PrefixUnaryExpression */ || node.parent.kind === 187 /* PostfixUnaryExpression */) { var flowType = getTypeAtFlowNode(flow.antecedent); return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType)); } - return declaredType === autoType ? getBaseTypeOfLiteralType(getInitialOrAssignedType(node)) : - declaredType.flags & 524288 /* Union */ ? getAssignmentReducedType(declaredType, getInitialOrAssignedType(node)) : - declaredType; + if (declaredType === autoType || declaredType === autoArrayType) { + if (isEmptyArrayAssignment(node)) { + return getEvolvingArrayType(neverType); + } + var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(node)); + return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; + } + if (declaredType.flags & 524288 /* Union */) { + return getAssignmentReducedType(declaredType, getInitialOrAssignedType(node)); + } + return declaredType; } // We didn't have a direct match. However, if the reference is a dotted name, this // may be an assignment to a left hand part of the reference. For example, for a @@ -30512,24 +30781,56 @@ var ts; // Assignment doesn't affect reference return undefined; } + function getTypeAtFlowArrayMutation(flow) { + var node = flow.node; + var expr = node.kind === 175 /* CallExpression */ ? + node.expression.expression : + node.left.expression; + if (isMatchingReference(reference, getReferenceCandidate(expr))) { + var flowType = getTypeAtFlowNode(flow.antecedent); + var type = getTypeFromFlowType(flowType); + if (isEvolvingArrayType(type)) { + var evolvedType_1 = type; + if (node.kind === 175 /* CallExpression */) { + for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { + var arg = _a[_i]; + evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); + } + } + else { + var indexType = checkExpression(node.left.argumentExpression); + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 340 /* NumberLike */ | 2048 /* Undefined */)) { + evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); + } + } + return evolvedType_1 === type ? flowType : createFlowType(evolvedType_1, isIncomplete(flowType)); + } + return flowType; + } + return undefined; + } function getTypeAtFlowCondition(flow) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (!(type.flags & 8192 /* Never */)) { - // If we have an antecedent type (meaning we're reachable in some way), we first - // attempt to narrow the antecedent type. If that produces the never type, and if - // the antecedent type is incomplete (i.e. a transient type in a loop), then we - // take the type guard as an indication that control *could* reach here once we - // have the complete type. We proceed by switching to the silent never type which - // doesn't report errors when operators are applied to it. Note that this is the - // *only* place a silent never type is ever generated. - var assumeTrue = (flow.flags & 32 /* TrueCondition */) !== 0; - type = narrowType(type, flow.expression, assumeTrue); - if (type.flags & 8192 /* Never */ && isIncomplete(flowType)) { - type = silentNeverType; - } + if (type.flags & 8192 /* Never */) { + return flowType; } - return createFlowType(type, isIncomplete(flowType)); + // If we have an antecedent type (meaning we're reachable in some way), we first + // attempt to narrow the antecedent type. If that produces the never type, and if + // the antecedent type is incomplete (i.e. a transient type in a loop), then we + // take the type guard as an indication that control *could* reach here once we + // have the complete type. We proceed by switching to the silent never type which + // doesn't report errors when operators are applied to it. Note that this is the + // *only* place a silent never type is ever generated. + var assumeTrue = (flow.flags & 32 /* TrueCondition */) !== 0; + var nonEvolvingType = finalizeEvolvingArrayType(type); + var narrowedType = narrowType(nonEvolvingType, flow.expression, assumeTrue); + if (narrowedType === nonEvolvingType) { + return flowType; + } + var incomplete = isIncomplete(flowType); + var resultType = incomplete && narrowedType.flags & 8192 /* Never */ ? silentNeverType : narrowedType; + return createFlowType(resultType, incomplete); } function getTypeAtSwitchClause(flow) { var flowType = getTypeAtFlowNode(flow.antecedent); @@ -30571,7 +30872,7 @@ var ts; seenIncomplete = true; } } - return createFlowType(getUnionType(antecedentTypes, subtypeReduction), seenIncomplete); + return createFlowType(getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction), seenIncomplete); } function getTypeAtFlowLoopLabel(flow) { // If we have previously computed the control flow type for the reference at @@ -30586,11 +30887,15 @@ var ts; } // If this flow loop junction and reference are already being processed, return // the union of the types computed for each branch so far, marked as incomplete. - // We should never see an empty array here because the first antecedent of a loop - // junction is always the non-looping control flow path that leads to the top. + // It is possible to see an empty array in cases where loops are nested and the + // back edge of the outer loop reaches an inner loop that is already being analyzed. + // In such cases we restart the analysis of the inner loop, which will then see + // a non-empty in-process array for the outer loop and eventually terminate because + // the first antecedent of a loop junction is always the non-looping control flow + // path that leads to the top. for (var i = flowLoopStart; i < flowLoopCount; i++) { - if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key) { - return createFlowType(getUnionType(flowLoopTypes[i]), /*incomplete*/ true); + if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key && flowLoopTypes[i].length) { + return createFlowType(getUnionOrEvolvingArrayType(flowLoopTypes[i], /*subtypeReduction*/ false), /*incomplete*/ true); } } // Add the flow loop junction and reference to the in-process stack and analyze @@ -30634,14 +30939,14 @@ var ts; } // The result is incomplete if the first antecedent (the non-looping control flow path) // is incomplete. - var result = getUnionType(antecedentTypes, subtypeReduction); + var result = getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction); if (isIncomplete(firstAntecedentType)) { return createFlowType(result, /*incomplete*/ true); } return cache[key] = result; } function isMatchingReferenceDiscriminant(expr) { - return expr.kind === 172 /* PropertyAccessExpression */ && + return expr.kind === 173 /* PropertyAccessExpression */ && declaredType.flags & 524288 /* Union */ && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(declaredType, expr.name.text); @@ -30666,19 +30971,19 @@ var ts; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 56 /* EqualsToken */: + case 57 /* EqualsToken */: return narrowTypeByTruthiness(type, expr.left, assumeTrue); - case 30 /* EqualsEqualsToken */: - case 31 /* ExclamationEqualsToken */: - case 32 /* EqualsEqualsEqualsToken */: - case 33 /* ExclamationEqualsEqualsToken */: + case 31 /* EqualsEqualsToken */: + case 32 /* ExclamationEqualsToken */: + case 33 /* EqualsEqualsEqualsToken */: + case 34 /* ExclamationEqualsEqualsToken */: var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 182 /* TypeOfExpression */ && right_1.kind === 9 /* StringLiteral */) { + if (left_1.kind === 183 /* TypeOfExpression */ && right_1.kind === 9 /* StringLiteral */) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 182 /* TypeOfExpression */ && left_1.kind === 9 /* StringLiteral */) { + if (right_1.kind === 183 /* TypeOfExpression */ && left_1.kind === 9 /* StringLiteral */) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -30697,9 +31002,9 @@ var ts; return declaredType; } break; - case 91 /* InstanceOfKeyword */: + case 92 /* InstanceOfKeyword */: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 24 /* CommaToken */: + case 25 /* CommaToken */: return narrowType(type, expr.right, assumeTrue); } return type; @@ -30708,7 +31013,7 @@ var ts; if (type.flags & 1 /* Any */) { return type; } - if (operator === 31 /* ExclamationEqualsToken */ || operator === 33 /* ExclamationEqualsEqualsToken */) { + if (operator === 32 /* ExclamationEqualsToken */ || operator === 34 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } var valueType = checkExpression(value); @@ -30716,10 +31021,10 @@ var ts; if (!strictNullChecks) { return type; } - var doubleEquals = operator === 30 /* EqualsEqualsToken */ || operator === 31 /* ExclamationEqualsToken */; + var doubleEquals = operator === 31 /* EqualsEqualsToken */ || operator === 32 /* ExclamationEqualsToken */; var facts = doubleEquals ? assumeTrue ? 65536 /* EQUndefinedOrNull */ : 524288 /* NEUndefinedOrNull */ : - value.kind === 93 /* NullKeyword */ ? + value.kind === 94 /* NullKeyword */ ? assumeTrue ? 32768 /* EQNull */ : 262144 /* NENull */ : assumeTrue ? 16384 /* EQUndefined */ : 131072 /* NEUndefined */; return getTypeWithFacts(type, facts); @@ -30748,7 +31053,7 @@ var ts; } return type; } - if (operator === 31 /* ExclamationEqualsToken */ || operator === 33 /* ExclamationEqualsEqualsToken */) { + if (operator === 32 /* ExclamationEqualsToken */ || operator === 34 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } if (assumeTrue && !(type.flags & 524288 /* Union */)) { @@ -30877,7 +31182,7 @@ var ts; } else { var invokedExpression = skipParenthesizedNodes(callExpression.expression); - if (invokedExpression.kind === 173 /* ElementAccessExpression */ || invokedExpression.kind === 172 /* PropertyAccessExpression */) { + if (invokedExpression.kind === 174 /* ElementAccessExpression */ || invokedExpression.kind === 173 /* PropertyAccessExpression */) { var accessExpression = invokedExpression; var possibleReference = skipParenthesizedNodes(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -30894,18 +31199,18 @@ var ts; // will be a subtype or the same type as the argument. function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 69 /* Identifier */: - case 97 /* ThisKeyword */: - case 172 /* PropertyAccessExpression */: + case 70 /* Identifier */: + case 98 /* ThisKeyword */: + case 173 /* PropertyAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 174 /* CallExpression */: + case 175 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 185 /* PrefixUnaryExpression */: - if (expr.operator === 49 /* ExclamationToken */) { + case 186 /* PrefixUnaryExpression */: + if (expr.operator === 50 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -30918,7 +31223,7 @@ var ts; // an dotted name expression, and if the location is not an assignment target, obtain the type // of the expression (which will reflect control flow analysis). If the expression indeed // resolved to the given symbol, return the narrowed type. - if (location.kind === 69 /* Identifier */) { + if (location.kind === 70 /* Identifier */) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } @@ -30937,7 +31242,7 @@ var ts; return getTypeOfSymbol(symbol); } function skipParenthesizedNodes(expression) { - while (expression.kind === 178 /* ParenthesizedExpression */) { + while (expression.kind === 179 /* ParenthesizedExpression */) { expression = expression.expression; } return expression; @@ -30946,9 +31251,9 @@ var ts; while (true) { node = node.parent; if (ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 226 /* ModuleBlock */ || + node.kind === 227 /* ModuleBlock */ || node.kind === 256 /* SourceFile */ || - node.kind === 145 /* PropertyDeclaration */) { + node.kind === 146 /* PropertyDeclaration */) { return node; } } @@ -30977,10 +31282,10 @@ var ts; } } function markParameterAssignments(node) { - if (node.kind === 69 /* Identifier */) { + if (node.kind === 70 /* Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 142 /* Parameter */) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 143 /* Parameter */) { symbol.isAssigned = true; } } @@ -30989,6 +31294,9 @@ var ts; ts.forEachChild(node, markParameterAssignments); } } + function isConstVariable(symbol) { + return symbol.flags & 3 /* Variable */ && (getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* Const */) !== 0 && getTypeOfSymbol(symbol) !== autoArrayType; + } function checkIdentifier(node) { var symbol = getResolvedSymbol(node); // As noted in ECMAScript 6 language spec, arrow functions never have an arguments objects. @@ -30999,8 +31307,8 @@ var ts; // can explicitly bound arguments objects if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); - if (languageVersion < 2 /* ES6 */) { - if (container.kind === 180 /* ArrowFunction */) { + if (languageVersion < 2 /* ES2015 */) { + if (container.kind === 181 /* ArrowFunction */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } else if (ts.hasModifier(container, 256 /* Async */)) { @@ -31020,8 +31328,8 @@ var ts; // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. - if (languageVersion === 2 /* ES6 */ - && declaration_1.kind === 221 /* ClassDeclaration */ + if (languageVersion === 2 /* ES2015 */ + && declaration_1.kind === 222 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration_1)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -31033,14 +31341,14 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration_1.kind === 192 /* ClassExpression */) { + else if (declaration_1.kind === 193 /* ClassExpression */) { // When we emit a class expression with static members that contain a reference // to the constructor in the initializer, we will need to substitute that // binding with an alias as the class name is not in scope. var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); while (container !== undefined) { if (container.parent === declaration_1) { - if (container.kind === 145 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { + if (container.kind === 146 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration_1).flags |= 8388608 /* ClassWithConstructorReference */; getNodeLinks(node).flags |= 16777216 /* ConstructorReferenceInClass */; } @@ -31063,37 +31371,35 @@ var ts; // The declaration container is the innermost function that encloses the declaration of the variable // or parameter. The flow container is the innermost function starting with which we analyze the control // flow graph to determine the control flow based type. - var isParameter = ts.getRootDeclaration(declaration).kind === 142 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 143 /* Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; // When the control flow originates in a function expression or arrow function and we are referencing // a const variable or parameter from an outer function, we extend the origin of the control flow // analysis to include the immediately enclosing function. - while (flowContainer !== declarationContainer && - (flowContainer.kind === 179 /* FunctionExpression */ || - flowContainer.kind === 180 /* ArrowFunction */ || - ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && - (isReadonlySymbol(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { + while (flowContainer !== declarationContainer && (flowContainer.kind === 180 /* FunctionExpression */ || + flowContainer.kind === 181 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } // We only look for uninitialized variables in strict null checking mode, and only when we can analyze // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). var assumeInitialized = isParameter || isOuterVariable || - type !== autoType && (!strictNullChecks || (type.flags & 1 /* Any */) !== 0) || + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1 /* Any */) !== 0) || ts.isInAmbientContext(declaration); var flowType = getFlowTypeOfReference(node, type, assumeInitialized, flowContainer); // A variable is considered uninitialized when it is possible to analyze the entire control flow graph // from declaration to use, and when the variable's declared type doesn't include undefined but the // control flow based type does include undefined. - if (type === autoType) { - if (flowType === autoType) { + if (type === autoType || type === autoArrayType) { + if (flowType === autoType || flowType === autoArrayType) { if (compilerOptions.noImplicitAny) { - error(declaration.name, ts.Diagnostics.Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol)); - error(node, ts.Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(anyType)); + error(declaration.name, ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol), typeToString(flowType)); + error(node, ts.Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(flowType)); } - return anyType; + return convertAutoToAny(flowType); } } else if (!assumeInitialized && !(getFalsyFlags(type) & 2048 /* Undefined */) && getFalsyFlags(flowType) & 2048 /* Undefined */) { @@ -31114,7 +31420,7 @@ var ts; return false; } function checkNestedBlockScopedBinding(node, symbol) { - if (languageVersion >= 2 /* ES6 */ || + if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || symbol.valueDeclaration.parent.kind === 252 /* CatchClause */) { return; @@ -31141,8 +31447,8 @@ var ts; } // mark variables that are declared in loop initializer and reassigned inside the body of ForStatement. // if body of ForStatement will be converted to function then we'll need a extra machinery to propagate reassigned values back. - if (container.kind === 206 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 219 /* VariableDeclarationList */).parent === container && + if (container.kind === 207 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 220 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152 /* NeedsLoopOutParameter */; } @@ -31156,7 +31462,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { var current = node; // skip parenthesized nodes - while (current.parent.kind === 178 /* ParenthesizedExpression */) { + while (current.parent.kind === 179 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -31164,9 +31470,9 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 185 /* PrefixUnaryExpression */ || current.parent.kind === 186 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 186 /* PrefixUnaryExpression */ || current.parent.kind === 187 /* PostfixUnaryExpression */)) { var expr = current.parent; - isAssigned = expr.operator === 41 /* PlusPlusToken */ || expr.operator === 42 /* MinusMinusToken */; + isAssigned = expr.operator === 42 /* PlusPlusToken */ || expr.operator === 43 /* MinusMinusToken */; } if (!isAssigned) { return false; @@ -31185,7 +31491,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 145 /* PropertyDeclaration */ || container.kind === 148 /* Constructor */) { + if (container.kind === 146 /* PropertyDeclaration */ || container.kind === 149 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -31233,7 +31539,7 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var needToCaptureLexicalThis = false; - if (container.kind === 148 /* Constructor */) { + if (container.kind === 149 /* Constructor */) { var containingClassDecl = container.parent; var baseTypeNode = ts.getClassExtendsHeritageClauseElement(containingClassDecl); // If a containing class does not have extends clause or the class extends null @@ -31254,32 +31560,32 @@ var ts; } } // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 180 /* ArrowFunction */) { + if (container.kind === 181 /* 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 */); + needToCaptureLexicalThis = (languageVersion < 2 /* ES2015 */); } switch (container.kind) { - case 225 /* ModuleDeclaration */: + case 226 /* 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 224 /* EnumDeclaration */: + case 225 /* 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 148 /* Constructor */: + case 149 /* Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: if (ts.getModifierFlags(container) & 32 /* Static */) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -31291,7 +31597,7 @@ var ts; // Note: a parameter initializer should refer to class-this unless function-this is explicitly annotated. // If this is a function in a JS file, it might be a class method. Check if it's the RHS // of a x.prototype.y = function [name]() { .... } - if (container.kind === 179 /* FunctionExpression */ && + if (container.kind === 180 /* FunctionExpression */ && ts.isInJavaScriptFile(container.parent) && ts.getSpecialPropertyAssignmentKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = f' (here, 'f' is 'container') @@ -31304,7 +31610,7 @@ var ts; return getInferredClassType(classSymbol); } } - var thisType = getThisTypeOfDeclaration(container); + var thisType = getThisTypeOfDeclaration(container) || getContextualThisParameterType(container); if (thisType) { return thisType; } @@ -31337,21 +31643,21 @@ var ts; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 142 /* Parameter */) { + if (n.kind === 143 /* Parameter */) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 174 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 175 /* CallExpression */ && node.parent.expression === node; var container = ts.getSuperContainer(node, /*stopOnFunctions*/ true); var needToCaptureLexicalThis = false; // adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting if (!isCallExpression) { - while (container && container.kind === 180 /* ArrowFunction */) { + while (container && container.kind === 181 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); - needToCaptureLexicalThis = languageVersion < 2 /* ES6 */; + needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } } var canUseSuperExpression = isLegalUsageOfSuperExpression(container); @@ -31363,16 +31669,16 @@ var ts; // [super.foo()]() {} // } var current = node; - while (current && current !== container && current.kind !== 140 /* ComputedPropertyName */) { + while (current && current !== container && current.kind !== 141 /* ComputedPropertyName */) { current = current.parent; } - if (current && current.kind === 140 /* ComputedPropertyName */) { + if (current && current.kind === 141 /* ComputedPropertyName */) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); } - else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 171 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 172 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -31443,7 +31749,7 @@ var ts; // This helper creates an object with a "value" property that wraps the `super` property or indexed access for both get and set. // This is required for destructuring assignments, as a call expression cannot be used as the target of a destructuring assignment // while a property access can. - if (container.kind === 147 /* MethodDeclaration */ && ts.getModifierFlags(container) & 256 /* Async */) { + if (container.kind === 148 /* MethodDeclaration */ && ts.getModifierFlags(container) & 256 /* Async */) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -31457,8 +31763,8 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 171 /* ObjectLiteralExpression */) { - if (languageVersion < 2 /* ES6 */) { + if (container.parent.kind === 172 /* ObjectLiteralExpression */) { + if (languageVersion < 2 /* ES2015 */) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return unknownType; } @@ -31477,7 +31783,7 @@ var ts; } return unknownType; } - if (container.kind === 148 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 149 /* 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; @@ -31492,7 +31798,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 === 148 /* Constructor */; + return container.kind === 149 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -31500,32 +31806,35 @@ var ts; // - In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance // - In a static member function or static member accessor // topmost container must be something that is directly nested in the class declaration\object literal expression - if (ts.isClassLike(container.parent) || container.parent.kind === 171 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 172 /* ObjectLiteralExpression */) { if (ts.getModifierFlags(container) & 32 /* Static */) { - return container.kind === 147 /* MethodDeclaration */ || - container.kind === 146 /* MethodSignature */ || - container.kind === 149 /* GetAccessor */ || - container.kind === 150 /* SetAccessor */; + return container.kind === 148 /* MethodDeclaration */ || + container.kind === 147 /* MethodSignature */ || + container.kind === 150 /* GetAccessor */ || + container.kind === 151 /* SetAccessor */; } else { - return container.kind === 147 /* MethodDeclaration */ || - container.kind === 146 /* MethodSignature */ || - container.kind === 149 /* GetAccessor */ || - container.kind === 150 /* SetAccessor */ || - container.kind === 145 /* PropertyDeclaration */ || - container.kind === 144 /* PropertySignature */ || - container.kind === 148 /* Constructor */; + return container.kind === 148 /* MethodDeclaration */ || + container.kind === 147 /* MethodSignature */ || + container.kind === 150 /* GetAccessor */ || + container.kind === 151 /* SetAccessor */ || + container.kind === 146 /* PropertyDeclaration */ || + container.kind === 145 /* PropertySignature */ || + container.kind === 149 /* Constructor */; } } } return false; } } - function getContextualThisParameter(func) { - if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 180 /* ArrowFunction */) { + function getContextualThisParameterType(func) { + if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 181 /* ArrowFunction */) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { - return contextualSignature.thisParameter; + var thisParameter = contextualSignature.thisParameter; + if (thisParameter) { + return getTypeOfSymbol(thisParameter); + } } } return undefined; @@ -31585,7 +31894,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 142 /* Parameter */) { + if (declaration.kind === 143 /* Parameter */) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -31637,7 +31946,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 142 /* Parameter */ && node.parent.initializer === node) { + if (node.parent.kind === 143 /* Parameter */ && node.parent.initializer === node) { return true; } node = node.parent; @@ -31648,8 +31957,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 === 148 /* Constructor */ || - functionDecl.kind === 149 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 150 /* SetAccessor */))) { + functionDecl.kind === 149 /* Constructor */ || + functionDecl.kind === 150 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 151 /* SetAccessor */))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } // Otherwise, if the containing function is contextually typed by a function type with exactly one call signature @@ -31671,7 +31980,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 176 /* TaggedTemplateExpression */) { + if (template.parent.kind === 177 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -31679,7 +31988,7 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operatorToken.kind; - if (operator >= 56 /* FirstAssignment */ && operator <= 68 /* LastAssignment */) { + if (operator >= 57 /* FirstAssignment */ && operator <= 69 /* LastAssignment */) { // Don't do this for special property assignments to avoid circularity if (ts.getSpecialPropertyAssignmentKind(binaryExpression) !== 0 /* None */) { return undefined; @@ -31689,7 +31998,7 @@ var ts; return checkExpression(binaryExpression.left); } } - else if (operator === 52 /* BarBarToken */) { + else if (operator === 53 /* 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); @@ -31698,7 +32007,7 @@ var ts; } return type; } - else if (operator === 51 /* AmpersandAmpersandToken */ || operator === 24 /* CommaToken */) { + else if (operator === 52 /* AmpersandAmpersandToken */ || operator === 25 /* CommaToken */) { if (node === binaryExpression.right) { return getContextualType(binaryExpression); } @@ -31715,8 +32024,8 @@ var ts; var types = type.types; var mappedType; var mappedTypes; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var current = types_12[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var current = types_13[_i]; var t = mapper(current); if (t) { if (!mappedType) { @@ -31786,7 +32095,7 @@ var ts; var index = ts.indexOf(arrayLiteral.elements, node); return getTypeOfPropertyOfContextualType(type, "" + index) || getIndexTypeOfContextualType(type, 1 /* Number */) - || (languageVersion >= 2 /* ES6 */ ? getElementTypeOfIterable(type, /*errorNode*/ undefined) : undefined); + || (languageVersion >= 2 /* ES2015 */ ? getElementTypeOfIterable(type, /*errorNode*/ undefined) : undefined); } return undefined; } @@ -31843,36 +32152,36 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 218 /* VariableDeclaration */: - case 142 /* Parameter */: - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: - case 169 /* BindingElement */: + case 219 /* VariableDeclaration */: + case 143 /* Parameter */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: + case 170 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 180 /* ArrowFunction */: - case 211 /* ReturnStatement */: + case 181 /* ArrowFunction */: + case 212 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 190 /* YieldExpression */: + case 191 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 174 /* CallExpression */: - case 175 /* NewExpression */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 177 /* TypeAssertionExpression */: - case 195 /* AsExpression */: + case 178 /* TypeAssertionExpression */: + case 196 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); case 253 /* PropertyAssignment */: case 254 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 170 /* ArrayLiteralExpression */: + case 171 /* ArrayLiteralExpression */: return getContextualTypeForElementExpression(node); - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 197 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 189 /* TemplateExpression */); + case 198 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 190 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return getContextualType(parent); case 248 /* JsxExpression */: return getContextualType(parent); @@ -31894,7 +32203,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 179 /* FunctionExpression */ || node.kind === 180 /* ArrowFunction */; + return node.kind === 180 /* FunctionExpression */ || node.kind === 181 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -31913,7 +32222,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 !== 147 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 148 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var type = getContextualTypeForFunctionLikeDeclaration(node); if (!type) { return undefined; @@ -31923,8 +32232,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var current = types_13[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var current = types_14[_i]; var signature = getNonGenericSignature(current); if (signature) { if (!signatureList) { @@ -31980,8 +32289,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false); } function hasDefaultValue(node) { - return (node.kind === 169 /* BindingElement */ && !!node.initializer) || - (node.kind === 187 /* BinaryExpression */ && node.operatorToken.kind === 56 /* EqualsToken */); + return (node.kind === 170 /* BindingElement */ && !!node.initializer) || + (node.kind === 188 /* BinaryExpression */ && node.operatorToken.kind === 57 /* EqualsToken */); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -31990,7 +32299,7 @@ var ts; var inDestructuringPattern = ts.isAssignmentTarget(node); for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { var e = elements_1[_i]; - if (inDestructuringPattern && e.kind === 191 /* SpreadElementExpression */) { + if (inDestructuringPattern && e.kind === 192 /* SpreadElementExpression */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -32005,7 +32314,7 @@ var ts; // if there is no index type / iterated type. var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1 /* Number */) || - (languageVersion >= 2 /* ES6 */ ? getElementTypeOfIterable(restArrayType, /*errorNode*/ undefined) : undefined); + (languageVersion >= 2 /* ES2015 */ ? getElementTypeOfIterable(restArrayType, /*errorNode*/ undefined) : undefined); if (restElementType) { elementTypes.push(restElementType); } @@ -32014,7 +32323,7 @@ var ts; var type = checkExpressionForMutableLocation(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 191 /* SpreadElementExpression */; + hasSpreadElement = hasSpreadElement || e.kind === 192 /* SpreadElementExpression */; } if (!hasSpreadElement) { // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such @@ -32029,7 +32338,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 === 168 /* ArrayBindingPattern */ || pattern.kind === 170 /* ArrayLiteralExpression */)) { + if (pattern && (pattern.kind === 169 /* ArrayBindingPattern */ || pattern.kind === 171 /* ArrayLiteralExpression */)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -32037,7 +32346,7 @@ var ts; elementTypes.push(contextualType.typeArguments[i]); } else { - if (patternElement.kind !== 193 /* OmittedExpression */) { + if (patternElement.kind !== 194 /* OmittedExpression */) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -32054,7 +32363,7 @@ var ts; strictNullChecks ? neverType : undefinedWideningType); } function isNumericName(name) { - return name.kind === 140 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 141 /* 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, @@ -32124,7 +32433,7 @@ var ts; var propertiesArray = []; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 167 /* ObjectBindingPattern */ || contextualType.pattern.kind === 171 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 168 /* ObjectBindingPattern */ || contextualType.pattern.kind === 172 /* ObjectLiteralExpression */); var typeFlags = 0; var patternWithComputedProperties = false; var hasComputedStringProperty = false; @@ -32139,7 +32448,7 @@ var ts; if (memberDecl.kind === 253 /* PropertyAssignment */) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 147 /* MethodDeclaration */) { + else if (memberDecl.kind === 148 /* MethodDeclaration */) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { @@ -32187,7 +32496,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 === 149 /* GetAccessor */ || memberDecl.kind === 150 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 150 /* GetAccessor */ || memberDecl.kind === 151 /* SetAccessor */); checkAccessorDeclaration(memberDecl); } if (ts.hasDynamicName(memberDecl)) { @@ -32251,10 +32560,10 @@ var ts; case 248 /* JsxExpression */: checkJsxExpression(child); break; - case 241 /* JsxElement */: + case 242 /* JsxElement */: checkJsxElement(child); break; - case 242 /* JsxSelfClosingElement */: + case 243 /* JsxSelfClosingElement */: checkJsxSelfClosingElement(child); break; } @@ -32273,7 +32582,7 @@ var ts; */ function isJsxIntrinsicIdentifier(tagName) { // TODO (yuisu): comment - if (tagName.kind === 172 /* PropertyAccessExpression */ || tagName.kind === 97 /* ThisKeyword */) { + if (tagName.kind === 173 /* PropertyAccessExpression */ || tagName.kind === 98 /* ThisKeyword */) { return false; } else { @@ -32400,7 +32709,7 @@ var ts; return unknownType; } } - return getUnionType(signatures.map(getReturnTypeOfSignature), /*subtypeReduction*/ true); + return getUnionType(ts.map(signatures, getReturnTypeOfSignature), /*subtypeReduction*/ true); } /// e.g. "props" for React.d.ts, /// or 'undefined' if ElementAttributesProperty doesn't exist (which means all @@ -32444,7 +32753,7 @@ var ts; } if (elemType.flags & 524288 /* Union */) { var types = elemType.types; - return getUnionType(types.map(function (type) { + return getUnionType(ts.map(types, function (type) { return getResolvedJsxType(node, type, elemClassType); }), /*subtypeReduction*/ true); } @@ -32654,7 +32963,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 : 145 /* PropertyDeclaration */; + return s.valueDeclaration ? s.valueDeclaration.kind : 146 /* PropertyDeclaration */; } function getDeclarationModifierFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedModifierFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 4 /* Public */ | 32 /* Static */ : 0; @@ -32673,10 +32982,10 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationModifierFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(getParentOfSymbol(prop)); - var errorNode = node.kind === 172 /* PropertyAccessExpression */ || node.kind === 218 /* VariableDeclaration */ ? + var errorNode = node.kind === 173 /* PropertyAccessExpression */ || node.kind === 219 /* VariableDeclaration */ ? node.name : node.right; - if (left.kind === 95 /* SuperKeyword */) { + if (left.kind === 96 /* SuperKeyword */) { // TS 1.0 spec (April 2014): 4.8.2 // - In a constructor, instance member function, instance member accessor, or // instance member variable initializer where this references a derived class instance, @@ -32684,7 +32993,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 (languageVersion < 2 /* ES6 */ && getDeclarationKindFromSymbol(prop) !== 147 /* MethodDeclaration */) { + if (languageVersion < 2 /* ES2015 */ && getDeclarationKindFromSymbol(prop) !== 148 /* 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); @@ -32715,7 +33024,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 === 95 /* SuperKeyword */) { + if (left.kind === 96 /* SuperKeyword */) { return true; } // Get the enclosing class that has the declaring class as its base type @@ -32799,7 +33108,7 @@ var ts; // Only compute control flow type if this is a property access expression that isn't an // assignment target, and the referenced property was declared as a variable, property, // accessor, or optional method. - if (node.kind !== 172 /* PropertyAccessExpression */ || ts.isAssignmentTarget(node) || + if (node.kind !== 173 /* PropertyAccessExpression */ || ts.isAssignmentTarget(node) || !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 524288 /* Union */)) { return propType; @@ -32821,7 +33130,7 @@ var ts; } } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 172 /* PropertyAccessExpression */ + var left = node.kind === 173 /* PropertyAccessExpression */ ? node.expression : node.left; var type = checkExpression(left); @@ -32838,13 +33147,13 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 219 /* VariableDeclarationList */) { + if (initializer.kind === 220 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 69 /* Identifier */) { + else if (initializer.kind === 70 /* Identifier */) { return getResolvedSymbol(initializer); } return undefined; @@ -32861,13 +33170,13 @@ var ts; */ function isForInVariableForNumericPropertyNames(expr) { var e = skipParenthesizedNodes(expr); - if (e.kind === 69 /* Identifier */) { + if (e.kind === 70 /* Identifier */) { var symbol = getResolvedSymbol(e); if (symbol.flags & 3 /* Variable */) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 207 /* ForInStatement */ && + if (node.kind === 208 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(checkExpression(node.expression))) { @@ -32884,7 +33193,7 @@ var ts; // Grammar checking if (!node.argumentExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 175 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 176 /* 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); @@ -32970,7 +33279,7 @@ var ts; if (indexArgumentExpression.kind === 9 /* StringLiteral */ || indexArgumentExpression.kind === 8 /* NumericLiteral */) { return indexArgumentExpression.text; } - if (indexArgumentExpression.kind === 173 /* ElementAccessExpression */ || indexArgumentExpression.kind === 172 /* PropertyAccessExpression */) { + if (indexArgumentExpression.kind === 174 /* ElementAccessExpression */ || indexArgumentExpression.kind === 173 /* PropertyAccessExpression */) { var value = getConstantValue(indexArgumentExpression); if (value !== undefined) { return value.toString(); @@ -33025,10 +33334,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 176 /* TaggedTemplateExpression */) { + if (node.kind === 177 /* TaggedTemplateExpression */) { checkExpression(node.template); } - else if (node.kind !== 143 /* Decorator */) { + else if (node.kind !== 144 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -33094,7 +33403,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 191 /* SpreadElementExpression */) { + if (arg && arg.kind === 192 /* SpreadElementExpression */) { return i; } } @@ -33107,13 +33416,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 === 176 /* TaggedTemplateExpression */) { + if (node.kind === 177 /* 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 argCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 189 /* TemplateExpression */) { + if (tagExpression.template.kind === 190 /* 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; @@ -33126,11 +33435,11 @@ var ts; // then this might actually turn out to be a TemplateHead in the future; // so we consider the call to be incomplete. var templateLiteral = tagExpression.template; - ts.Debug.assert(templateLiteral.kind === 11 /* NoSubstitutionTemplateLiteral */); + ts.Debug.assert(templateLiteral.kind === 12 /* NoSubstitutionTemplateLiteral */); callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 143 /* Decorator */) { + else if (node.kind === 144 /* Decorator */) { isDecorator = true; typeArguments = undefined; argCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature); @@ -33139,7 +33448,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 === 175 /* NewExpression */); + ts.Debug.assert(callExpression.kind === 176 /* NewExpression */); return signature.minArgumentCount === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -33223,9 +33532,9 @@ 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 !== 193 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 194 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); - var argType = getEffectiveArgumentType(node, i, arg); + var argType = getEffectiveArgumentType(node, i); // If the effective argument type is 'undefined', there is no synthetic type // for the argument. In that case, we should check the argument. if (argType === undefined) { @@ -33280,7 +33589,7 @@ var ts; } function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 175 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 176 /* NewExpression */) { // If the called expression is not of the form `x.f` or `x["f"]`, then sourceType = voidType // If the signature's 'this' type is voidType, then the check is skipped -- anything is compatible. // If the expression is a new expression, then the check is skipped. @@ -33297,10 +33606,10 @@ 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 !== 193 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 194 /* 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); + var argType = getEffectiveArgumentType(node, i); // If the effective argument type is 'undefined', there is no synthetic type // for the argument. In that case, we should check the argument. if (argType === undefined) { @@ -33319,12 +33628,12 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 174 /* CallExpression */) { + if (node.kind === 175 /* CallExpression */) { var callee = node.expression; - if (callee.kind === 172 /* PropertyAccessExpression */) { + if (callee.kind === 173 /* PropertyAccessExpression */) { return callee.expression; } - else if (callee.kind === 173 /* ElementAccessExpression */) { + else if (callee.kind === 174 /* ElementAccessExpression */) { return callee.expression; } } @@ -33340,16 +33649,16 @@ var ts; */ function getEffectiveCallArguments(node) { var args; - if (node.kind === 176 /* TaggedTemplateExpression */) { + if (node.kind === 177 /* TaggedTemplateExpression */) { var template = node.template; args = [undefined]; - if (template.kind === 189 /* TemplateExpression */) { + if (template.kind === 190 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 143 /* Decorator */) { + else if (node.kind === 144 /* 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. @@ -33374,19 +33683,19 @@ var ts; * Otherwise, the argument count is the length of the 'args' array. */ function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 143 /* Decorator */) { + if (node.kind === 144 /* Decorator */) { switch (node.parent.kind) { - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) return 1; - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: // A property declaration decorator will have two arguments (see // `PropertyDecorator` in core.d.ts) return 2; - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* 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. @@ -33396,7 +33705,7 @@ var ts; // 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 142 /* Parameter */: + case 143 /* Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts) return 3; @@ -33420,25 +33729,25 @@ var ts; */ function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. - if (node.kind === 221 /* ClassDeclaration */) { + if (node.kind === 222 /* ClassDeclaration */) { // 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); } - if (node.kind === 142 /* Parameter */) { + if (node.kind === 143 /* Parameter */) { // For a parameter decorator, the `target` is the parent type of the // parameter's containing method. node = node.parent; - if (node.kind === 148 /* Constructor */) { + if (node.kind === 149 /* Constructor */) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } } - if (node.kind === 145 /* PropertyDeclaration */ || - node.kind === 147 /* MethodDeclaration */ || - node.kind === 149 /* GetAccessor */ || - node.kind === 150 /* SetAccessor */) { + if (node.kind === 146 /* PropertyDeclaration */ || + node.kind === 148 /* MethodDeclaration */ || + node.kind === 150 /* GetAccessor */ || + node.kind === 151 /* 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 @@ -33465,32 +33774,32 @@ var ts; */ function getEffectiveDecoratorSecondArgumentType(node) { // The second argument to a decorator is its `propertyKey` - if (node.kind === 221 /* ClassDeclaration */) { + if (node.kind === 222 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } - if (node.kind === 142 /* Parameter */) { + if (node.kind === 143 /* Parameter */) { node = node.parent; - if (node.kind === 148 /* Constructor */) { + if (node.kind === 149 /* Constructor */) { // For a constructor parameter decorator, the `propertyKey` will be `undefined`. return anyType; } } - if (node.kind === 145 /* PropertyDeclaration */ || - node.kind === 147 /* MethodDeclaration */ || - node.kind === 149 /* GetAccessor */ || - node.kind === 150 /* SetAccessor */) { + if (node.kind === 146 /* PropertyDeclaration */ || + node.kind === 148 /* MethodDeclaration */ || + node.kind === 150 /* GetAccessor */ || + node.kind === 151 /* 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 69 /* Identifier */: + case 70 /* Identifier */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: return getLiteralTypeForText(32 /* StringLiteral */, element.name.text); - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(element.name); if (isTypeOfKind(nameType, 512 /* ESSymbol */)) { return nameType; @@ -33516,21 +33825,21 @@ var ts; function getEffectiveDecoratorThirdArgumentType(node) { // The third argument to a decorator is either its `descriptor` for a method decorator // or its `parameterIndex` for a parameter decorator - if (node.kind === 221 /* ClassDeclaration */) { + if (node.kind === 222 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 142 /* Parameter */) { + if (node.kind === 143 /* Parameter */) { // The `parameterIndex` for a parameter decorator is always a number return numberType; } - if (node.kind === 145 /* PropertyDeclaration */) { + if (node.kind === 146 /* PropertyDeclaration */) { ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 147 /* MethodDeclaration */ || - node.kind === 149 /* GetAccessor */ || - node.kind === 150 /* SetAccessor */) { + if (node.kind === 148 /* MethodDeclaration */ || + node.kind === 150 /* GetAccessor */ || + node.kind === 151 /* SetAccessor */) { // The `descriptor` for a method decorator will be a `TypedPropertyDescriptor` // for the type of the member. var propertyType = getTypeOfNode(node); @@ -33558,14 +33867,14 @@ var ts; /** * Gets the effective argument type for an argument in a call expression. */ - function getEffectiveArgumentType(node, argIndex, arg) { + function getEffectiveArgumentType(node, argIndex) { // 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 === 143 /* Decorator */) { + if (node.kind === 144 /* Decorator */) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 176 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 177 /* TaggedTemplateExpression */) { return getGlobalTemplateStringsArrayType(); } // This is not a synthetic argument, so we return 'undefined' @@ -33577,8 +33886,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 === 143 /* Decorator */ || - (argIndex === 0 && node.kind === 176 /* TaggedTemplateExpression */)) { + if (node.kind === 144 /* Decorator */ || + (argIndex === 0 && node.kind === 177 /* TaggedTemplateExpression */)) { return undefined; } return args[argIndex]; @@ -33587,11 +33896,11 @@ var ts; * Gets the error node to use when reporting errors for an effective argument. */ function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 143 /* Decorator */) { + if (node.kind === 144 /* Decorator */) { // For a decorator, we use the expression of the decorator for error reporting. return node.expression; } - else if (argIndex === 0 && node.kind === 176 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 177 /* TaggedTemplateExpression */) { // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. return node.template; } @@ -33600,13 +33909,13 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 176 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 143 /* Decorator */; + var isTaggedTemplate = node.kind === 177 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 144 /* 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 !== 95 /* SuperKeyword */) { + if (node.expression.kind !== 96 /* SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } @@ -33672,7 +33981,7 @@ var ts; var result; // If we are in signature help, a trailing comma indicates that we intend to provide another argument, // so we will only accept overloads with arity at least 1 higher than the current number of provided arguments. - var signatureHelpTrailingComma = candidatesOutArray && node.kind === 174 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 175 /* CallExpression */ && node.arguments.hasTrailingComma; // Section 4.12.1: // if the candidate list contains one or more signatures for which the type of each argument // expression is a subtype of each corresponding parameter type, the return type of the first @@ -33818,7 +34127,7 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 95 /* SuperKeyword */) { + if (node.expression.kind === 96 /* 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 @@ -34020,16 +34329,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 142 /* Parameter */: + case 143 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -34059,13 +34368,13 @@ var ts; } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 174 /* CallExpression */: + case 175 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray); - case 175 /* NewExpression */: + case 176 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray); - case 176 /* TaggedTemplateExpression */: + case 177 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray); - case 143 /* Decorator */: + case 144 /* Decorator */: return resolveDecorator(node, candidatesOutArray); } ts.Debug.fail("Branch in 'resolveSignature' should be unreachable."); @@ -34111,22 +34420,22 @@ 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 === 95 /* SuperKeyword */) { + if (node.expression.kind === 96 /* SuperKeyword */) { return voidType; } - if (node.kind === 175 /* NewExpression */) { + if (node.kind === 176 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 148 /* Constructor */ && - declaration.kind !== 152 /* ConstructSignature */ && - declaration.kind !== 157 /* ConstructorType */ && + declaration.kind !== 149 /* Constructor */ && + declaration.kind !== 153 /* ConstructSignature */ && + declaration.kind !== 158 /* ConstructorType */ && !ts.isJSDocConstructSignature(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any, unless // the declaring function had members created through 'x.prototype.y = expr' or 'this.y = expr' psuedodeclarations // in a JS file // Note:JS inferred classes might come from a variable declaration instead of a function declaration. // In this case, using getResolvedSymbol directly is required to avoid losing the members from the declaration. - var funcSymbol = node.expression.kind === 69 /* Identifier */ ? + var funcSymbol = node.expression.kind === 70 /* Identifier */ ? getResolvedSymbol(node.expression) : checkExpression(node.expression).symbol; if (funcSymbol && funcSymbol.members && (funcSymbol.flags & 16 /* Function */ || ts.isDeclarationOfFunctionExpression(funcSymbol))) { @@ -34139,7 +34448,10 @@ var ts; } } // In JavaScript files, calls to any identifier 'require' are treated as external module imports - if (ts.isInJavaScriptFile(node) && ts.isRequireCall(node, /*checkArgumentIsStringLiteral*/ true)) { + if (ts.isInJavaScriptFile(node) && + ts.isRequireCall(node, /*checkArgumentIsStringLiteral*/ true) && + // Make sure require is not a local function + !resolveName(node.expression, node.expression.text, 107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined)) { return resolveExternalModuleTypeByLiteral(node.arguments[0]); } return getReturnTypeOfSignature(signature); @@ -34179,21 +34491,36 @@ var ts; } function assignContextualParameterTypes(signature, context, mapper) { var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + if (isInferentialContext(mapper)) { + for (var i = 0; i < len; i++) { + var declaration = signature.parameters[i].valueDeclaration; + if (declaration.type) { + inferTypes(mapper.context, getTypeFromTypeNode(declaration.type), getTypeAtPosition(context, i)); + } + } + } if (context.thisParameter) { - if (!signature.thisParameter) { - signature.thisParameter = createTransientSymbol(context.thisParameter, undefined); + var parameter = signature.thisParameter; + if (!parameter || parameter.valueDeclaration && !parameter.valueDeclaration.type) { + if (!parameter) { + signature.thisParameter = createTransientSymbol(context.thisParameter, undefined); + } + assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper); } - assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper); } for (var i = 0; i < len; i++) { var parameter = signature.parameters[i]; - var contextualParameterType = getTypeAtPosition(context, i); - assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + if (!parameter.valueDeclaration.type) { + var contextualParameterType = getTypeAtPosition(context, i); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + } } if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) { var parameter = ts.lastOrUndefined(signature.parameters); - var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); - assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + if (!parameter.valueDeclaration.type) { + var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + } } } // When contextual typing assigns a type to a parameter that contains a binding pattern, we also need to push @@ -34203,7 +34530,7 @@ var ts; for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { var element = _a[_i]; if (!ts.isOmittedExpression(element)) { - if (element.name.kind === 69 /* Identifier */) { + if (element.name.kind === 70 /* Identifier */) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } assignBindingElementTypes(element); @@ -34217,8 +34544,8 @@ var ts; links.type = instantiateType(contextualType, mapper); // if inference didn't come up with anything but {}, fall back to the binding pattern if present. if (links.type === emptyObjectType && - (parameter.valueDeclaration.name.kind === 167 /* ObjectBindingPattern */ || - parameter.valueDeclaration.name.kind === 168 /* ArrayBindingPattern */)) { + (parameter.valueDeclaration.name.kind === 168 /* ObjectBindingPattern */ || + parameter.valueDeclaration.name.kind === 169 /* ArrayBindingPattern */)) { links.type = getTypeFromBindingPattern(parameter.valueDeclaration.name); } assignBindingElementTypes(parameter.valueDeclaration); @@ -34288,7 +34615,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 199 /* Block */) { + if (func.body.kind !== 200 /* 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 @@ -34378,7 +34705,7 @@ var ts; return false; } var lastStatement = ts.lastOrUndefined(func.body.statements); - if (lastStatement && lastStatement.kind === 213 /* SwitchStatement */ && isExhaustiveSwitchStatement(lastStatement)) { + if (lastStatement && lastStatement.kind === 214 /* SwitchStatement */ && isExhaustiveSwitchStatement(lastStatement)) { return false; } return true; @@ -34411,7 +34738,7 @@ var ts; } }); if (aggregatedTypes.length === 0 && !hasReturnWithNoExpression && (hasReturnOfTypeNever || - func.kind === 179 /* FunctionExpression */ || func.kind === 180 /* ArrowFunction */)) { + func.kind === 180 /* FunctionExpression */ || func.kind === 181 /* ArrowFunction */)) { return undefined; } if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression) { @@ -34440,7 +34767,7 @@ var ts; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (ts.nodeIsMissing(func.body) || func.body.kind !== 199 /* Block */ || !functionHasImplicitReturn(func)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 200 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; @@ -34473,10 +34800,10 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 147 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 148 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 179 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 180 /* FunctionExpression */) { checkGrammarForGenerator(node); } // The identityMapper object is used to indicate that function expressions are wildcards @@ -34517,14 +34844,14 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 147 /* MethodDeclaration */) { + if (produceDiagnostics && node.kind !== 148 /* MethodDeclaration */) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 147 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 148 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); if (!node.asteriskToken) { @@ -34540,7 +34867,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 199 /* Block */) { + if (node.body.kind === 200 /* Block */) { checkSourceElement(node.body); } else { @@ -34587,11 +34914,11 @@ var ts; if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && - (expr.kind === 172 /* PropertyAccessExpression */ || expr.kind === 173 /* ElementAccessExpression */) && - expr.expression.kind === 97 /* ThisKeyword */) { + (expr.kind === 173 /* PropertyAccessExpression */ || expr.kind === 174 /* ElementAccessExpression */) && + expr.expression.kind === 98 /* ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 148 /* Constructor */)) + if (!(func && func.kind === 149 /* Constructor */)) return true; // If func.parent is a class and symbol is a (readonly) property of that class, or // if func is a constructor and symbol is a (readonly) parameter property declared in it, @@ -34603,13 +34930,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 172 /* PropertyAccessExpression */ || expr.kind === 173 /* ElementAccessExpression */) { + if (expr.kind === 173 /* PropertyAccessExpression */ || expr.kind === 174 /* ElementAccessExpression */) { var node = skipParenthesizedNodes(expr.expression); - if (node.kind === 69 /* Identifier */) { + if (node.kind === 70 /* Identifier */) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 8388608 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol); - return declaration && declaration.kind === 232 /* NamespaceImport */; + return declaration && declaration.kind === 233 /* NamespaceImport */; } } } @@ -34618,7 +34945,7 @@ var ts; function checkReferenceExpression(expr, invalidReferenceMessage, constantVariableMessage) { // References are combinations of identifiers, parentheses, and property accesses. var node = skipParenthesizedNodes(expr); - if (node.kind !== 69 /* Identifier */ && node.kind !== 172 /* PropertyAccessExpression */ && node.kind !== 173 /* ElementAccessExpression */) { + if (node.kind !== 70 /* Identifier */ && node.kind !== 173 /* PropertyAccessExpression */ && node.kind !== 174 /* ElementAccessExpression */) { error(expr, invalidReferenceMessage); return false; } @@ -34631,7 +34958,7 @@ var ts; if (symbol !== unknownSymbol && symbol !== argumentsSymbol) { // Only variables (and not functions, classes, namespaces, enum objects, or enum members) // are considered references when referenced using a simple identifier. - if (node.kind === 69 /* Identifier */ && !(symbol.flags & 3 /* Variable */)) { + if (node.kind === 70 /* Identifier */ && !(symbol.flags & 3 /* Variable */)) { error(expr, invalidReferenceMessage); return false; } @@ -34641,7 +34968,7 @@ var ts; } } } - else if (node.kind === 173 /* ElementAccessExpression */) { + else if (node.kind === 174 /* ElementAccessExpression */) { if (links.resolvedIndexInfo && links.resolvedIndexInfo.isReadonly) { error(expr, constantVariableMessage); return false; @@ -34679,24 +35006,24 @@ var ts; if (operandType === silentNeverType) { return silentNeverType; } - if (node.operator === 36 /* MinusToken */ && node.operand.kind === 8 /* NumericLiteral */) { + if (node.operator === 37 /* MinusToken */ && node.operand.kind === 8 /* NumericLiteral */) { return getFreshTypeOfLiteralType(getLiteralTypeForText(64 /* NumberLiteral */, "" + -node.operand.text)); } switch (node.operator) { - case 35 /* PlusToken */: - case 36 /* MinusToken */: - case 50 /* TildeToken */: + case 36 /* PlusToken */: + case 37 /* MinusToken */: + case 51 /* TildeToken */: if (maybeTypeOfKind(operandType, 512 /* ESSymbol */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; - case 49 /* ExclamationToken */: + case 50 /* ExclamationToken */: var facts = getTypeFacts(operandType) & (1048576 /* Truthy */ | 2097152 /* Falsy */); return facts === 1048576 /* Truthy */ ? falseType : facts === 2097152 /* Falsy */ ? trueType : booleanType; - case 41 /* PlusPlusToken */: - case 42 /* MinusMinusToken */: + case 42 /* PlusPlusToken */: + case 43 /* MinusMinusToken */: var ok = checkArithmeticOperandType(node.operand, getNonNullableType(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 @@ -34726,8 +35053,8 @@ var ts; } if (type.flags & 1572864 /* UnionOrIntersection */) { var types = type.types; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var t = types_14[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var t = types_15[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -34744,8 +35071,8 @@ var ts; } if (type.flags & 524288 /* Union */) { var types = type.types; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var t = types_15[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var t = types_16[_i]; if (!isTypeOfKind(t, kind)) { return false; } @@ -34754,8 +35081,8 @@ var ts; } if (type.flags & 1048576 /* Intersection */) { var types = type.types; - for (var _a = 0, types_16 = types; _a < types_16.length; _a++) { - var t = types_16[_a]; + for (var _a = 0, types_17 = types; _a < types_17.length; _a++) { + var t = types_17[_a]; if (isTypeOfKind(t, kind)) { return true; } @@ -34803,18 +35130,18 @@ var ts; } return booleanType; } - function checkObjectLiteralAssignment(node, sourceType, contextualMapper) { + function checkObjectLiteralAssignment(node, sourceType) { var properties = node.properties; for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { var p = properties_4[_i]; - checkObjectLiteralDestructuringPropertyAssignment(sourceType, p, contextualMapper); + checkObjectLiteralDestructuringPropertyAssignment(sourceType, p); } return sourceType; } - function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, contextualMapper) { + function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property) { if (property.kind === 253 /* PropertyAssignment */ || property.kind === 254 /* ShorthandPropertyAssignment */) { var name_17 = property.name; - if (name_17.kind === 140 /* ComputedPropertyName */) { + if (name_17.kind === 141 /* ComputedPropertyName */) { checkComputedPropertyName(name_17); } if (isComputedNonLiteralName(name_17)) { @@ -34857,8 +35184,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, contextualMapper) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 193 /* OmittedExpression */) { - if (element.kind !== 191 /* SpreadElementExpression */) { + if (element.kind !== 194 /* OmittedExpression */) { + if (element.kind !== 192 /* SpreadElementExpression */) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType @@ -34886,7 +35213,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 187 /* BinaryExpression */ && restExpression.operatorToken.kind === 56 /* EqualsToken */) { + if (restExpression.kind === 188 /* BinaryExpression */ && restExpression.operatorToken.kind === 57 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -34915,14 +35242,14 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 187 /* BinaryExpression */ && target.operatorToken.kind === 56 /* EqualsToken */) { + if (target.kind === 188 /* BinaryExpression */ && target.operatorToken.kind === 57 /* EqualsToken */) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 171 /* ObjectLiteralExpression */) { - return checkObjectLiteralAssignment(target, sourceType, contextualMapper); + if (target.kind === 172 /* ObjectLiteralExpression */) { + return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 170 /* ArrayLiteralExpression */) { + if (target.kind === 171 /* ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -34945,52 +35272,52 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 69 /* Identifier */: + case 70 /* Identifier */: case 9 /* StringLiteral */: - case 10 /* RegularExpressionLiteral */: - case 176 /* TaggedTemplateExpression */: - case 189 /* TemplateExpression */: - case 11 /* NoSubstitutionTemplateLiteral */: + case 11 /* RegularExpressionLiteral */: + case 177 /* TaggedTemplateExpression */: + case 190 /* TemplateExpression */: + case 12 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: - case 93 /* NullKeyword */: - case 135 /* UndefinedKeyword */: - case 179 /* FunctionExpression */: - case 192 /* ClassExpression */: - case 180 /* ArrowFunction */: - case 170 /* ArrayLiteralExpression */: - case 171 /* ObjectLiteralExpression */: - case 182 /* TypeOfExpression */: - case 196 /* NonNullExpression */: - case 242 /* JsxSelfClosingElement */: - case 241 /* JsxElement */: + case 100 /* TrueKeyword */: + case 85 /* FalseKeyword */: + case 94 /* NullKeyword */: + case 136 /* UndefinedKeyword */: + case 180 /* FunctionExpression */: + case 193 /* ClassExpression */: + case 181 /* ArrowFunction */: + case 171 /* ArrayLiteralExpression */: + case 172 /* ObjectLiteralExpression */: + case 183 /* TypeOfExpression */: + case 197 /* NonNullExpression */: + case 243 /* JsxSelfClosingElement */: + case 242 /* JsxElement */: return true; - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 185 /* PrefixUnaryExpression */: - case 186 /* PostfixUnaryExpression */: + case 186 /* PrefixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { - case 49 /* ExclamationToken */: - case 35 /* PlusToken */: - case 36 /* MinusToken */: - case 50 /* TildeToken */: + case 50 /* ExclamationToken */: + case 36 /* PlusToken */: + case 37 /* MinusToken */: + case 51 /* TildeToken */: return true; } return false; // Some forms listed here for clarity - case 183 /* VoidExpression */: // Explicit opt-out - case 177 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 195 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 184 /* VoidExpression */: // Explicit opt-out + case 178 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 196 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -35010,34 +35337,34 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { var operator = operatorToken.kind; - if (operator === 56 /* EqualsToken */ && (left.kind === 171 /* ObjectLiteralExpression */ || left.kind === 170 /* ArrayLiteralExpression */)) { + if (operator === 57 /* EqualsToken */ && (left.kind === 172 /* ObjectLiteralExpression */ || left.kind === 171 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } var leftType = checkExpression(left, contextualMapper); var rightType = checkExpression(right, contextualMapper); switch (operator) { - case 37 /* AsteriskToken */: - 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 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 */: + case 38 /* AsteriskToken */: + case 39 /* AsteriskAsteriskToken */: + case 60 /* AsteriskEqualsToken */: + case 61 /* AsteriskAsteriskEqualsToken */: + case 40 /* SlashToken */: + case 62 /* SlashEqualsToken */: + case 41 /* PercentToken */: + case 63 /* PercentEqualsToken */: + case 37 /* MinusToken */: + case 59 /* MinusEqualsToken */: + case 44 /* LessThanLessThanToken */: + case 64 /* LessThanLessThanEqualsToken */: + case 45 /* GreaterThanGreaterThanToken */: + case 65 /* GreaterThanGreaterThanEqualsToken */: + case 46 /* GreaterThanGreaterThanGreaterThanToken */: + case 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 48 /* BarToken */: + case 68 /* BarEqualsToken */: + case 49 /* CaretToken */: + case 69 /* CaretEqualsToken */: + case 47 /* AmpersandToken */: + case 67 /* AmpersandEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -35070,8 +35397,8 @@ var ts; } } return numberType; - case 35 /* PlusToken */: - case 57 /* PlusEqualsToken */: + case 36 /* PlusToken */: + case 58 /* PlusEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -35110,24 +35437,24 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 57 /* PlusEqualsToken */) { + if (operator === 58 /* PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; - case 25 /* LessThanToken */: - case 27 /* GreaterThanToken */: - case 28 /* LessThanEqualsToken */: - case 29 /* GreaterThanEqualsToken */: + case 26 /* LessThanToken */: + case 28 /* GreaterThanToken */: + case 29 /* LessThanEqualsToken */: + case 30 /* GreaterThanEqualsToken */: if (checkForDisallowedESSymbolOperand(operator)) { if (!isTypeComparableTo(leftType, rightType) && !isTypeComparableTo(rightType, leftType)) { reportOperatorError(); } } return booleanType; - case 30 /* EqualsEqualsToken */: - case 31 /* ExclamationEqualsToken */: - case 32 /* EqualsEqualsEqualsToken */: - case 33 /* ExclamationEqualsEqualsToken */: + case 31 /* EqualsEqualsToken */: + case 32 /* ExclamationEqualsToken */: + case 33 /* EqualsEqualsEqualsToken */: + case 34 /* ExclamationEqualsEqualsToken */: var leftIsLiteral = isLiteralType(leftType); var rightIsLiteral = isLiteralType(rightType); if (!leftIsLiteral || !rightIsLiteral) { @@ -35138,22 +35465,22 @@ var ts; reportOperatorError(); } return booleanType; - case 91 /* InstanceOfKeyword */: + case 92 /* InstanceOfKeyword */: return checkInstanceOfExpression(left, right, leftType, rightType); - case 90 /* InKeyword */: + case 91 /* InKeyword */: return checkInExpression(left, right, leftType, rightType); - case 51 /* AmpersandAmpersandToken */: + case 52 /* AmpersandAmpersandToken */: return getTypeFacts(leftType) & 1048576 /* Truthy */ ? includeFalsyTypes(rightType, getFalsyFlags(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType))) : leftType; - case 52 /* BarBarToken */: + case 53 /* BarBarToken */: return getTypeFacts(leftType) & 2097152 /* Falsy */ ? getBestChoiceType(removeDefinitelyFalsyTypes(leftType), rightType) : leftType; - case 56 /* EqualsToken */: + case 57 /* EqualsToken */: checkAssignmentOperator(rightType); return getRegularTypeOfObjectLiteral(rightType); - case 24 /* CommaToken */: + case 25 /* CommaToken */: if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left)) { error(left, ts.Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects); } @@ -35172,21 +35499,21 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 47 /* BarToken */: - case 67 /* BarEqualsToken */: - return 52 /* BarBarToken */; - case 48 /* CaretToken */: - case 68 /* CaretEqualsToken */: - return 33 /* ExclamationEqualsEqualsToken */; - case 46 /* AmpersandToken */: - case 66 /* AmpersandEqualsToken */: - return 51 /* AmpersandAmpersandToken */; + case 48 /* BarToken */: + case 68 /* BarEqualsToken */: + return 53 /* BarBarToken */; + case 49 /* CaretToken */: + case 69 /* CaretEqualsToken */: + return 34 /* ExclamationEqualsEqualsToken */; + case 47 /* AmpersandToken */: + case 67 /* AmpersandEqualsToken */: + return 52 /* AmpersandAmpersandToken */; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 56 /* FirstAssignment */ && operator <= 68 /* LastAssignment */) { + if (produceDiagnostics && operator >= 57 /* FirstAssignment */ && operator <= 69 /* LastAssignment */) { // TypeScript 1.0 spec (April 2014): 4.17 // An assignment of the form // VarExpr = ValueExpr @@ -35273,9 +35600,9 @@ var ts; return getFreshTypeOfLiteralType(getLiteralTypeForText(32 /* StringLiteral */, node.text)); case 8 /* NumericLiteral */: return getFreshTypeOfLiteralType(getLiteralTypeForText(64 /* NumberLiteral */, node.text)); - case 99 /* TrueKeyword */: + case 100 /* TrueKeyword */: return trueType; - case 84 /* FalseKeyword */: + case 85 /* FalseKeyword */: return falseType; } } @@ -35312,7 +35639,7 @@ var ts; } function isTypeAssertion(node) { node = skipParenthesizedNodes(node); - return node.kind === 177 /* TypeAssertionExpression */ || node.kind === 195 /* AsExpression */; + return node.kind === 178 /* TypeAssertionExpression */ || node.kind === 196 /* AsExpression */; } function checkDeclarationInitializer(declaration) { var type = checkExpressionCached(declaration.initializer); @@ -35344,7 +35671,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 === 140 /* ComputedPropertyName */) { + if (node.name.kind === 141 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, contextualMapper); @@ -35355,7 +35682,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 === 140 /* ComputedPropertyName */) { + if (node.name.kind === 141 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -35385,7 +35712,7 @@ var ts; // contextually typed function and arrow expressions in the initial phase. function checkExpression(node, contextualMapper) { var type; - if (node.kind === 139 /* QualifiedName */) { + if (node.kind === 140 /* QualifiedName */) { type = checkQualifiedName(node); } else { @@ -35397,9 +35724,9 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 172 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 173 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 69 /* Identifier */ || node.kind === 139 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 173 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 174 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 70 /* Identifier */ || node.kind === 140 /* 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); } @@ -35408,79 +35735,79 @@ var ts; } function checkExpressionWorker(node, contextualMapper) { switch (node.kind) { - case 69 /* Identifier */: + case 70 /* Identifier */: return checkIdentifier(node); - case 97 /* ThisKeyword */: + case 98 /* ThisKeyword */: return checkThisExpression(node); - case 95 /* SuperKeyword */: + case 96 /* SuperKeyword */: return checkSuperExpression(node); - case 93 /* NullKeyword */: + case 94 /* NullKeyword */: return nullWideningType; case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: + case 100 /* TrueKeyword */: + case 85 /* FalseKeyword */: return checkLiteralExpression(node); - case 189 /* TemplateExpression */: + case 190 /* TemplateExpression */: return checkTemplateExpression(node); - case 11 /* NoSubstitutionTemplateLiteral */: + case 12 /* NoSubstitutionTemplateLiteral */: return stringType; - case 10 /* RegularExpressionLiteral */: + case 11 /* RegularExpressionLiteral */: return globalRegExpType; - case 170 /* ArrayLiteralExpression */: + case 171 /* ArrayLiteralExpression */: return checkArrayLiteral(node, contextualMapper); - case 171 /* ObjectLiteralExpression */: + case 172 /* ObjectLiteralExpression */: return checkObjectLiteral(node, contextualMapper); - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 173 /* ElementAccessExpression */: + case 174 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 174 /* CallExpression */: - case 175 /* NewExpression */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: return checkCallExpression(node); - case 176 /* TaggedTemplateExpression */: + case 177 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return checkExpression(node.expression, contextualMapper); - case 192 /* ClassExpression */: + case 193 /* ClassExpression */: return checkClassExpression(node); - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 182 /* TypeOfExpression */: + case 183 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 177 /* TypeAssertionExpression */: - case 195 /* AsExpression */: + case 178 /* TypeAssertionExpression */: + case 196 /* AsExpression */: return checkAssertion(node); - case 196 /* NonNullExpression */: + case 197 /* NonNullExpression */: return checkNonNullAssertion(node); - case 181 /* DeleteExpression */: + case 182 /* DeleteExpression */: return checkDeleteExpression(node); - case 183 /* VoidExpression */: + case 184 /* VoidExpression */: return checkVoidExpression(node); - case 184 /* AwaitExpression */: + case 185 /* AwaitExpression */: return checkAwaitExpression(node); - case 185 /* PrefixUnaryExpression */: + case 186 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 186 /* PostfixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return checkBinaryExpression(node, contextualMapper); - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: return checkConditionalExpression(node, contextualMapper); - case 191 /* SpreadElementExpression */: + case 192 /* SpreadElementExpression */: return checkSpreadElementExpression(node, contextualMapper); - case 193 /* OmittedExpression */: + case 194 /* OmittedExpression */: return undefinedWideningType; - case 190 /* YieldExpression */: + case 191 /* YieldExpression */: return checkYieldExpression(node); case 248 /* JsxExpression */: return checkJsxExpression(node); - case 241 /* JsxElement */: + case 242 /* JsxElement */: return checkJsxElement(node); - case 242 /* JsxSelfClosingElement */: + case 243 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node); - case 243 /* JsxOpeningElement */: + case 244 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -35508,7 +35835,7 @@ var ts; var func = ts.getContainingFunction(node); if (ts.getModifierFlags(node) & 92 /* ParameterPropertyModifier */) { func = ts.getContainingFunction(node); - if (!(func.kind === 148 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 149 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -35519,7 +35846,7 @@ var ts; if (ts.indexOf(func.parameters, node) !== 0) { error(node, ts.Diagnostics.A_this_parameter_must_be_the_first_parameter); } - if (func.kind === 148 /* Constructor */ || func.kind === 152 /* ConstructSignature */ || func.kind === 157 /* ConstructorType */) { + if (func.kind === 149 /* Constructor */ || func.kind === 153 /* ConstructSignature */ || func.kind === 158 /* ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } } @@ -35533,15 +35860,15 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 147 /* MethodDeclaration */ || - node.kind === 220 /* FunctionDeclaration */ || - node.kind === 179 /* FunctionExpression */; + return node.kind === 148 /* MethodDeclaration */ || + node.kind === 221 /* FunctionDeclaration */ || + node.kind === 180 /* FunctionExpression */; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 69 /* Identifier */ && + if (param.name.kind === 70 /* Identifier */ && param.name.text === parameter.text) { return i; } @@ -35593,13 +35920,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 180 /* ArrowFunction */: - case 151 /* CallSignature */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 156 /* FunctionType */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 181 /* ArrowFunction */: + case 152 /* CallSignature */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 157 /* FunctionType */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: var parent_12 = node.parent; if (node === parent_12.type) { return parent_12; @@ -35613,13 +35940,13 @@ var ts; continue; } var name_19 = element.name; - if (name_19.kind === 69 /* Identifier */ && + if (name_19.kind === 70 /* Identifier */ && name_19.text === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name_19.kind === 168 /* ArrayBindingPattern */ || - name_19.kind === 167 /* ObjectBindingPattern */) { + else if (name_19.kind === 169 /* ArrayBindingPattern */ || + name_19.kind === 168 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_19, predicateVariableNode, predicateVariableName)) { return true; } @@ -35628,12 +35955,12 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 153 /* IndexSignature */) { + if (node.kind === 154 /* IndexSignature */) { checkGrammarIndexSignature(node); } - else if (node.kind === 156 /* FunctionType */ || node.kind === 220 /* FunctionDeclaration */ || node.kind === 157 /* ConstructorType */ || - node.kind === 151 /* CallSignature */ || node.kind === 148 /* Constructor */ || - node.kind === 152 /* ConstructSignature */) { + else if (node.kind === 157 /* FunctionType */ || node.kind === 221 /* FunctionDeclaration */ || node.kind === 158 /* ConstructorType */ || + node.kind === 152 /* CallSignature */ || node.kind === 149 /* Constructor */ || + node.kind === 153 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); @@ -35645,16 +35972,16 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 152 /* ConstructSignature */: + case 153 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 151 /* CallSignature */: + case 152 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } } if (node.type) { - if (languageVersion >= 2 /* ES6 */ && isSyntacticallyValidGenerator(node)) { + if (languageVersion >= 2 /* ES2015 */ && isSyntacticallyValidGenerator(node)) { var returnType = getTypeFromTypeNode(node.type); if (returnType === voidType) { error(node.type, ts.Diagnostics.A_generator_cannot_have_a_void_type_annotation); @@ -35691,7 +36018,7 @@ var ts; var staticNames = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 148 /* Constructor */) { + if (member.kind === 149 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param)) { @@ -35700,18 +36027,18 @@ var ts; } } else { - var isStatic = ts.forEach(member.modifiers, function (m) { return m.kind === 113 /* StaticKeyword */; }); + var isStatic = ts.forEach(member.modifiers, function (m) { return m.kind === 114 /* StaticKeyword */; }); var names = isStatic ? staticNames : instanceNames; var memberName = member.name && ts.getPropertyNameForPropertyNameNode(member.name); if (memberName) { switch (member.kind) { - case 149 /* GetAccessor */: + case 150 /* GetAccessor */: addName(names, member.name, memberName, 1 /* Getter */); break; - case 150 /* SetAccessor */: + case 151 /* SetAccessor */: addName(names, member.name, memberName, 2 /* Setter */); break; - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: addName(names, member.name, memberName, 3 /* Property */); break; } @@ -35737,12 +36064,12 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind == 144 /* PropertySignature */) { + if (member.kind == 145 /* PropertySignature */) { var memberName = void 0; switch (member.name.kind) { case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - case 69 /* Identifier */: + case 70 /* Identifier */: memberName = member.name.text; break; default: @@ -35759,7 +36086,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 222 /* InterfaceDeclaration */) { + if (node.kind === 223 /* 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 @@ -35779,7 +36106,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 132 /* StringKeyword */: + case 133 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -35787,7 +36114,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 130 /* NumberKeyword */: + case 131 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -35852,15 +36179,15 @@ var ts; return ts.forEachChild(n, containsSuperCall); } function markThisReferencesAsErrors(n) { - if (n.kind === 97 /* ThisKeyword */) { + if (n.kind === 98 /* ThisKeyword */) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 179 /* FunctionExpression */ && n.kind !== 220 /* FunctionDeclaration */) { + else if (n.kind !== 180 /* FunctionExpression */ && n.kind !== 221 /* FunctionDeclaration */) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 145 /* PropertyDeclaration */ && + return n.kind === 146 /* PropertyDeclaration */ && !(ts.getModifierFlags(n) & 32 /* Static */) && !!n.initializer; } @@ -35890,7 +36217,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 202 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 203 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -35914,7 +36241,7 @@ var ts; checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 149 /* GetAccessor */) { + if (node.kind === 150 /* GetAccessor */) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 128 /* HasImplicitReturn */)) { if (!(node.flags & 256 /* HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); @@ -35924,13 +36251,13 @@ 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 === 140 /* ComputedPropertyName */) { + if (node.name.kind === 141 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } 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 === 149 /* GetAccessor */ ? 150 /* SetAccessor */ : 149 /* GetAccessor */; + var otherKind = node.kind === 150 /* GetAccessor */ ? 151 /* SetAccessor */ : 150 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if ((ts.getModifierFlags(node) & 28 /* AccessibilityModifier */) !== (ts.getModifierFlags(otherAccessor) & 28 /* AccessibilityModifier */)) { @@ -35946,11 +36273,11 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 149 /* GetAccessor */) { + if (node.kind === 150 /* GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } - if (node.parent.kind !== 171 /* ObjectLiteralExpression */) { + if (node.parent.kind !== 172 /* ObjectLiteralExpression */) { checkSourceElement(node.body); registerForUnusedIdentifiersCheck(node); } @@ -36040,9 +36367,9 @@ var ts; var flags = ts.getCombinedModifierFlags(n); // children of classes (even ambient classes) should not be marked as ambient or export // because those flags have no useful semantics there. - if (n.parent.kind !== 222 /* InterfaceDeclaration */ && - n.parent.kind !== 221 /* ClassDeclaration */ && - n.parent.kind !== 192 /* ClassExpression */ && + if (n.parent.kind !== 223 /* InterfaceDeclaration */ && + n.parent.kind !== 222 /* ClassDeclaration */ && + n.parent.kind !== 193 /* ClassExpression */ && ts.isInAmbientContext(n)) { if (!(flags & 2 /* Ambient */)) { // It is nested in an ambient context, which means it is automatically exported @@ -36130,7 +36457,7 @@ var ts; var errorNode_1 = subsequentNode.name || subsequentNode; // TODO(jfreeman): These are methods, so handle computed name case if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - var reportError = (node.kind === 147 /* MethodDeclaration */ || node.kind === 146 /* MethodSignature */) && + var reportError = (node.kind === 148 /* MethodDeclaration */ || node.kind === 147 /* MethodSignature */) && (ts.getModifierFlags(node) & 32 /* Static */) !== (ts.getModifierFlags(subsequentNode) & 32 /* Static */); // we can get here in two cases // 1. mixed static and instance class members @@ -36169,7 +36496,7 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 222 /* InterfaceDeclaration */ || node.parent.kind === 159 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 223 /* InterfaceDeclaration */ || node.parent.kind === 160 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -36180,7 +36507,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 === 220 /* FunctionDeclaration */ || node.kind === 147 /* MethodDeclaration */ || node.kind === 146 /* MethodSignature */ || node.kind === 148 /* Constructor */) { + if (node.kind === 221 /* FunctionDeclaration */ || node.kind === 148 /* MethodDeclaration */ || node.kind === 147 /* MethodSignature */ || node.kind === 149 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -36302,16 +36629,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 222 /* InterfaceDeclaration */: + case 223 /* InterfaceDeclaration */: return 2097152 /* ExportType */; - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ : 4194304 /* ExportNamespace */; - case 221 /* ClassDeclaration */: - case 224 /* EnumDeclaration */: + case 222 /* ClassDeclaration */: + case 225 /* EnumDeclaration */: return 2097152 /* ExportType */ | 1048576 /* ExportValue */; - case 229 /* ImportEqualsDeclaration */: + case 230 /* ImportEqualsDeclaration */: var result_2 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_2 |= getDeclarationSpaces(d); }); @@ -36515,7 +36842,7 @@ var ts; * callable `then` signature. */ function checkAsyncFunctionReturnType(node) { - if (languageVersion >= 2 /* ES6 */) { + if (languageVersion >= 2 /* ES2015 */) { var returnType = getTypeFromTypeNode(node.type); return checkCorrectPromiseType(returnType, node.type, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type); } @@ -36594,22 +36921,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 142 /* Parameter */: + case 143 /* 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 145 /* PropertyDeclaration */: + case 146 /* 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 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -36622,9 +36949,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 === 155 /* TypeReference */) { + if (node && node.kind === 156 /* TypeReference */) { var root = getFirstIdentifier(node.typeName); - var meaning = root.parent.kind === 155 /* TypeReference */ ? 793064 /* Type */ : 1920 /* Namespace */; + var meaning = root.parent.kind === 156 /* TypeReference */ ? 793064 /* Type */ : 1920 /* 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 @@ -36671,20 +36998,20 @@ 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 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: checkParameterTypeAnnotationsAsExpressions(node); checkReturnTypeAnnotationAsExpression(node); break; - case 145 /* PropertyDeclaration */: - case 142 /* Parameter */: + case 146 /* PropertyDeclaration */: + case 143 /* Parameter */: checkTypeAnnotationAsExpression(node); break; } @@ -36707,7 +37034,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 && node.name.kind === 140 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 141 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -36768,42 +37095,42 @@ var ts; var node = deferredUnusedIdentifierNodes_1[_i]; switch (node.kind) { case 256 /* SourceFile */: - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: checkUnusedModuleMembers(node); break; - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; - case 222 /* InterfaceDeclaration */: + case 223 /* InterfaceDeclaration */: checkUnusedTypeParameters(node); break; - case 199 /* Block */: - case 227 /* CaseBlock */: - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: + case 200 /* Block */: + case 228 /* CaseBlock */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: checkUnusedLocalsAndParameters(node); break; - case 148 /* Constructor */: - case 179 /* FunctionExpression */: - case 220 /* FunctionDeclaration */: - case 180 /* ArrowFunction */: - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 149 /* Constructor */: + case 180 /* FunctionExpression */: + case 221 /* FunctionDeclaration */: + case 181 /* ArrowFunction */: + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: if (node.body) { checkUnusedLocalsAndParameters(node); } checkUnusedTypeParameters(node); break; - case 146 /* MethodSignature */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: - case 156 /* FunctionType */: - case 157 /* ConstructorType */: + case 147 /* MethodSignature */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: checkUnusedTypeParameters(node); break; } @@ -36812,11 +37139,11 @@ var ts; } } function checkUnusedLocalsAndParameters(node) { - if (node.parent.kind !== 222 /* InterfaceDeclaration */ && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { + if (node.parent.kind !== 223 /* InterfaceDeclaration */ && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { var _loop_1 = function (key) { var local = node.locals[key]; if (!local.isReferenced) { - if (local.valueDeclaration && local.valueDeclaration.kind === 142 /* Parameter */) { + if (local.valueDeclaration && local.valueDeclaration.kind === 143 /* Parameter */) { var parameter = local.valueDeclaration; if (compilerOptions.noUnusedParameters && !ts.isParameterPropertyDeclaration(parameter) && @@ -36836,19 +37163,19 @@ var ts; } } function parameterNameStartsWithUnderscore(parameter) { - return parameter.name && parameter.name.kind === 69 /* Identifier */ && parameter.name.text.charCodeAt(0) === 95 /* _ */; + return parameter.name && parameter.name.kind === 70 /* Identifier */ && parameter.name.text.charCodeAt(0) === 95 /* _ */; } function checkUnusedClassMembers(node) { if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) { if (node.members) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 147 /* MethodDeclaration */ || member.kind === 145 /* PropertyDeclaration */) { + if (member.kind === 148 /* MethodDeclaration */ || member.kind === 146 /* PropertyDeclaration */) { if (!member.symbol.isReferenced && ts.getModifierFlags(member) & 8 /* Private */) { error(member.name, ts.Diagnostics._0_is_declared_but_never_used, member.symbol.name); } } - else if (member.kind === 148 /* Constructor */) { + else if (member.kind === 149 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.getModifierFlags(parameter) & 8 /* Private */) { @@ -36896,7 +37223,7 @@ var ts; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 199 /* Block */) { + if (node.kind === 200 /* Block */) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -36919,12 +37246,12 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 145 /* PropertyDeclaration */ || - node.kind === 144 /* PropertySignature */ || - node.kind === 147 /* MethodDeclaration */ || - node.kind === 146 /* MethodSignature */ || - node.kind === 149 /* GetAccessor */ || - node.kind === 150 /* SetAccessor */) { + if (node.kind === 146 /* PropertyDeclaration */ || + node.kind === 145 /* PropertySignature */ || + node.kind === 148 /* MethodDeclaration */ || + node.kind === 147 /* MethodSignature */ || + node.kind === 150 /* GetAccessor */ || + node.kind === 151 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -36933,7 +37260,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 142 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 143 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -36949,7 +37276,7 @@ var ts; var current = node; while (current) { if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 69 /* Identifier */; + var isDeclaration_1 = node.kind !== 70 /* Identifier */; if (isDeclaration_1) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -36972,7 +37299,7 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 69 /* Identifier */; + var isDeclaration_2 = node.kind !== 70 /* Identifier */; if (isDeclaration_2) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -36983,14 +37310,14 @@ var ts; } function checkCollisionWithRequireExportsInGeneratedCode(node, name) { // No need to check for require or exports for ES6 modules and later - if (modulekind >= ts.ModuleKind.ES6) { + if (modulekind >= ts.ModuleKind.ES2015) { return; } if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 225 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 226 /* 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 @@ -37005,7 +37332,7 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 225 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 226 /* 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 @@ -37045,7 +37372,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 === 218 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 219 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -37055,16 +37382,16 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 219 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 200 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 220 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 201 /* 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 === 199 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 226 /* ModuleBlock */ || - container.kind === 225 /* ModuleDeclaration */ || + (container.kind === 200 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 227 /* ModuleBlock */ || + container.kind === 226 /* ModuleDeclaration */ || container.kind === 256 /* 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 @@ -37080,7 +37407,7 @@ 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 !== 142 /* Parameter */) { + if (ts.getRootDeclaration(node).kind !== 143 /* Parameter */) { return; } var func = ts.getContainingFunction(node); @@ -37091,11 +37418,11 @@ var ts; // skip declaration names (i.e. in object literal expressions) return; } - if (n.kind === 172 /* PropertyAccessExpression */) { + if (n.kind === 173 /* PropertyAccessExpression */) { // skip property names in property access expression return visit(n.expression); } - else if (n.kind === 69 /* Identifier */) { + else if (n.kind === 70 /* Identifier */) { // check FunctionLikeDeclaration.locals (stores parameters\function local variable) // if it contains entry with a specified name var symbol = resolveName(n, n.text, 107455 /* Value */ | 8388608 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); @@ -37110,7 +37437,7 @@ var ts; // so we need to do a bit of extra work to check if reference is legal var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 142 /* Parameter */) { + if (symbol.valueDeclaration.kind === 143 /* Parameter */) { // it is ok to reference parameter in initializer if either // - parameter is located strictly on the left of current parameter declaration if (symbol.valueDeclaration.pos < node.pos) { @@ -37124,7 +37451,7 @@ var ts; } // computed property names/initializers in instance property declaration of class like entities // are executed in constructor and thus deferred - if (current.parent.kind === 145 /* PropertyDeclaration */ && + if (current.parent.kind === 146 /* PropertyDeclaration */ && !(ts.hasModifier(current.parent, 32 /* Static */)) && ts.isClassLike(current.parent.parent)) { return; @@ -37141,7 +37468,7 @@ var ts; } } function convertAutoToAny(type) { - return type === autoType ? anyType : type; + return type === autoType ? anyType : type === autoArrayType ? anyArrayType : type; } // Check variable, parameter, or property declaration function checkVariableLikeDeclaration(node) { @@ -37151,15 +37478,15 @@ 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 === 140 /* ComputedPropertyName */) { + if (node.name.kind === 141 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 169 /* BindingElement */) { + if (node.kind === 170 /* BindingElement */) { // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 140 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 141 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access @@ -37176,14 +37503,14 @@ 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 === 142 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 143 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { // Don't validate for-in initializer as it is already an error - if (node.initializer && node.parent.parent.kind !== 207 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 208 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -37194,7 +37521,7 @@ var ts; if (node === symbol.valueDeclaration) { // Node is the primary declaration of the symbol, just validate the initializer // Don't validate for-in initializer as it is already an error - if (node.initializer && node.parent.parent.kind !== 207 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 208 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -37214,10 +37541,10 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 145 /* PropertyDeclaration */ && node.kind !== 144 /* PropertySignature */) { + if (node.kind !== 146 /* PropertyDeclaration */ && node.kind !== 145 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 218 /* VariableDeclaration */ || node.kind === 169 /* BindingElement */) { + if (node.kind === 219 /* VariableDeclaration */ || node.kind === 170 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -37227,8 +37554,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 142 /* Parameter */ && right.kind === 218 /* VariableDeclaration */) || - (left.kind === 218 /* VariableDeclaration */ && right.kind === 142 /* Parameter */)) { + if ((left.kind === 143 /* Parameter */ && right.kind === 219 /* VariableDeclaration */) || + (left.kind === 219 /* VariableDeclaration */ && right.kind === 143 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -37258,7 +37585,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 === 171 /* ObjectLiteralExpression */) { + if (node.modifiers && node.parent.kind === 172 /* ObjectLiteralExpression */) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -37279,7 +37606,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 201 /* EmptyStatement */) { + if (node.thenStatement.kind === 202 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -37299,12 +37626,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 219 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 220 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 219 /* VariableDeclarationList */) { + if (node.initializer.kind === 220 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -37327,14 +37654,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 === 219 /* VariableDeclarationList */) { + if (node.initializer.kind === 220 /* 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 === 170 /* ArrayLiteralExpression */ || varExpr.kind === 171 /* ObjectLiteralExpression */) { + if (varExpr.kind === 171 /* ArrayLiteralExpression */ || varExpr.kind === 172 /* 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. @@ -37366,7 +37693,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 === 219 /* VariableDeclarationList */) { + if (node.initializer.kind === 220 /* 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); @@ -37380,7 +37707,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 === 170 /* ArrayLiteralExpression */ || varExpr.kind === 171 /* ObjectLiteralExpression */) { + if (varExpr.kind === 171 /* ArrayLiteralExpression */ || varExpr.kind === 172 /* ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 34 /* StringLike */)) { @@ -37418,7 +37745,7 @@ var ts; if (isTypeAny(inputType)) { return inputType; } - if (languageVersion >= 2 /* ES6 */) { + if (languageVersion >= 2 /* ES2015 */) { return checkElementTypeOfIterable(inputType, errorNode); } if (allowStringInput) { @@ -37578,7 +37905,7 @@ var ts; * 2. Some constituent is a string and target is less than ES5 (because in ES3 string is not indexable). */ function checkElementTypeOfArrayOrString(arrayOrStringType, errorNode) { - ts.Debug.assert(languageVersion < 2 /* ES6 */); + ts.Debug.assert(languageVersion < 2 /* ES2015 */); // After we remove all types that are StringLike, we will know if there was a string constituent // based on whether the remaining type is the same as the initial type. var arrayType = arrayOrStringType; @@ -37630,7 +37957,7 @@ var ts; // TODO: Check that target label is valid } function isGetAccessorWithAnnotatedSetAccessor(node) { - return !!(node.kind === 149 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 150 /* SetAccessor */))); + return !!(node.kind === 150 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 151 /* SetAccessor */))); } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { var unwrappedReturnType = ts.isAsyncFunctionLike(func) ? getPromisedType(returnType) : returnType; @@ -37657,12 +37984,12 @@ var ts; // for generators. return; } - if (func.kind === 150 /* SetAccessor */) { + if (func.kind === 151 /* SetAccessor */) { if (node.expression) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 148 /* Constructor */) { + else if (func.kind === 149 /* Constructor */) { if (node.expression && !checkTypeAssignableTo(exprType, returnType, node.expression)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -37683,7 +38010,7 @@ var ts; } } } - else if (func.kind !== 148 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 149 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { // The function has a return type, but the return statement doesn't have an expression. error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } @@ -37749,7 +38076,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 214 /* LabeledStatement */ && current.label.text === node.label.text) { + if (current.kind === 215 /* 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; @@ -37779,7 +38106,7 @@ var ts; if (catchClause) { // Grammar checking if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 69 /* Identifier */) { + if (catchClause.variableDeclaration.name.kind !== 70 /* Identifier */) { grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); } else if (catchClause.variableDeclaration.type) { @@ -37854,7 +38181,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 === 140 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 141 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -37912,7 +38239,7 @@ var ts; var firstDecl; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 221 /* ClassDeclaration */ || declaration.kind === 222 /* InterfaceDeclaration */) { + if (declaration.kind === 222 /* ClassDeclaration */ || declaration.kind === 223 /* InterfaceDeclaration */) { if (!firstDecl) { firstDecl = declaration; } @@ -38076,7 +38403,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 & 128 /* Abstract */ && (!derivedClassDecl || !(ts.getModifierFlags(derivedClassDecl) & 128 /* Abstract */))) { - if (derivedClassDecl.kind === 192 /* ClassExpression */) { + if (derivedClassDecl.kind === 193 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -38124,7 +38451,7 @@ var ts; } } function isAccessor(kind) { - return kind === 149 /* GetAccessor */ || kind === 150 /* SetAccessor */; + return kind === 150 /* GetAccessor */ || kind === 151 /* SetAccessor */; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -38196,7 +38523,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(node, symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 222 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 223 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -38302,18 +38629,18 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 185 /* PrefixUnaryExpression */: + case 186 /* PrefixUnaryExpression */: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; } switch (e.operator) { - case 35 /* PlusToken */: return value_1; - case 36 /* MinusToken */: return -value_1; - case 50 /* TildeToken */: return ~value_1; + case 36 /* PlusToken */: return value_1; + case 37 /* MinusToken */: return -value_1; + case 51 /* TildeToken */: return ~value_1; } return undefined; - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -38323,31 +38650,31 @@ var ts; return undefined; } switch (e.operatorToken.kind) { - 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 39 /* SlashToken */: return left / right; - case 35 /* PlusToken */: return left + right; - case 36 /* MinusToken */: return left - right; - case 40 /* PercentToken */: return left % right; + case 48 /* BarToken */: return left | right; + case 47 /* AmpersandToken */: return left & right; + case 45 /* GreaterThanGreaterThanToken */: return left >> right; + case 46 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 44 /* LessThanLessThanToken */: return left << right; + case 49 /* CaretToken */: return left ^ right; + case 38 /* AsteriskToken */: return left * right; + case 40 /* SlashToken */: return left / right; + case 36 /* PlusToken */: return left + right; + case 37 /* MinusToken */: return left - right; + case 41 /* PercentToken */: return left % right; } return undefined; case 8 /* NumericLiteral */: return +e.text; - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return evalConstant(e.expression); - case 69 /* Identifier */: - case 173 /* ElementAccessExpression */: - case 172 /* PropertyAccessExpression */: + case 70 /* Identifier */: + case 174 /* ElementAccessExpression */: + case 173 /* PropertyAccessExpression */: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; var propertyName = void 0; - if (e.kind === 69 /* Identifier */) { + if (e.kind === 70 /* 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; @@ -38355,7 +38682,7 @@ var ts; } else { var expression = void 0; - if (e.kind === 173 /* ElementAccessExpression */) { + if (e.kind === 174 /* ElementAccessExpression */) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9 /* StringLiteral */) { return undefined; @@ -38370,10 +38697,10 @@ var ts; // expression part in ElementAccess\PropertyAccess should be either identifier or dottedName var current = expression; while (current) { - if (current.kind === 69 /* Identifier */) { + if (current.kind === 70 /* Identifier */) { break; } - else if (current.kind === 172 /* PropertyAccessExpression */) { + else if (current.kind === 173 /* PropertyAccessExpression */) { current = current.expression; } else { @@ -38445,7 +38772,7 @@ var ts; var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 224 /* EnumDeclaration */) { + if (declaration.kind !== 225 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -38468,8 +38795,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { var declaration = declarations_5[_i]; - if ((declaration.kind === 221 /* ClassDeclaration */ || - (declaration.kind === 220 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 222 /* ClassDeclaration */ || + (declaration.kind === 221 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -38533,7 +38860,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, 221 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 222 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -38584,23 +38911,23 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: // error each individual name in variable statement instead of marking the entire variable statement for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 235 /* ExportAssignment */: - case 236 /* ExportDeclaration */: + case 236 /* ExportAssignment */: + case 237 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 229 /* ImportEqualsDeclaration */: - case 230 /* ImportDeclaration */: + case 230 /* ImportEqualsDeclaration */: + case 231 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 169 /* BindingElement */: - case 218 /* VariableDeclaration */: + case 170 /* BindingElement */: + case 219 /* VariableDeclaration */: var name_22 = node.name; if (ts.isBindingPattern(name_22)) { for (var _b = 0, _c = name_22.elements; _b < _c.length; _b++) { @@ -38611,12 +38938,12 @@ var ts; break; } // fallthrough - case 221 /* ClassDeclaration */: - case 224 /* EnumDeclaration */: - case 220 /* FunctionDeclaration */: - case 222 /* InterfaceDeclaration */: - case 225 /* ModuleDeclaration */: - case 223 /* TypeAliasDeclaration */: + case 222 /* ClassDeclaration */: + case 225 /* EnumDeclaration */: + case 221 /* FunctionDeclaration */: + case 223 /* InterfaceDeclaration */: + case 226 /* ModuleDeclaration */: + case 224 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -38637,17 +38964,17 @@ var ts; } function getFirstIdentifier(node) { switch (node.kind) { - case 69 /* Identifier */: + case 70 /* Identifier */: return node; - case 139 /* QualifiedName */: + case 140 /* QualifiedName */: do { node = node.left; - } while (node.kind !== 69 /* Identifier */); + } while (node.kind !== 70 /* Identifier */); return node; - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: do { node = node.expression; - } while (node.kind !== 69 /* Identifier */); + } while (node.kind !== 70 /* Identifier */); return node; } } @@ -38657,9 +38984,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 226 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientExternalModule = node.parent.kind === 227 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); if (node.parent.kind !== 256 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 236 /* ExportDeclaration */ ? + error(moduleName, node.kind === 237 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -38692,7 +39019,7 @@ var ts; (symbol.flags & 793064 /* Type */ ? 793064 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 238 /* ExportSpecifier */ ? + var message = node.kind === 239 /* 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)); @@ -38720,7 +39047,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 232 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 233 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -38757,7 +39084,7 @@ var ts; } } else { - if (modulekind === ts.ModuleKind.ES6 && !ts.isInAmbientContext(node)) { + if (modulekind === ts.ModuleKind.ES2015 && !ts.isInAmbientContext(node)) { // Import equals declaration is deprecated in es6 or above grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } @@ -38777,7 +39104,7 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 226 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientExternalModule = node.parent.kind === 227 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); if (node.parent.kind !== 256 /* SourceFile */ && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } @@ -38792,7 +39119,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 256 /* SourceFile */ || node.parent.kind === 226 /* ModuleBlock */ || node.parent.kind === 225 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 256 /* SourceFile */ || node.parent.kind === 227 /* ModuleBlock */ || node.parent.kind === 226 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -38819,7 +39146,7 @@ var ts; return; } var container = node.parent.kind === 256 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 225 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + if (container.kind === 226 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } @@ -38827,7 +39154,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.getModifierFlags(node) !== 0) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 69 /* Identifier */) { + if (node.expression.kind === 70 /* Identifier */) { markExportAsReferenced(node); } else { @@ -38835,7 +39162,7 @@ var ts; } checkExternalModuleExports(container); if (node.isExportEquals && !ts.isInAmbientContext(node)) { - if (modulekind === ts.ModuleKind.ES6) { + if (modulekind === ts.ModuleKind.ES2015) { // export assignment is not supported in es6 modules grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_export_default_or_another_module_format_instead); } @@ -38894,7 +39221,7 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return (declaration.kind !== 220 /* FunctionDeclaration */ && declaration.kind !== 147 /* MethodDeclaration */) || + return (declaration.kind !== 221 /* FunctionDeclaration */ && declaration.kind !== 148 /* MethodDeclaration */) || !!declaration.body; } } @@ -38907,118 +39234,118 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 225 /* ModuleDeclaration */: - case 221 /* ClassDeclaration */: - case 222 /* InterfaceDeclaration */: - case 220 /* FunctionDeclaration */: + case 226 /* ModuleDeclaration */: + case 222 /* ClassDeclaration */: + case 223 /* InterfaceDeclaration */: + case 221 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 141 /* TypeParameter */: + case 142 /* TypeParameter */: return checkTypeParameter(node); - case 142 /* Parameter */: + case 143 /* Parameter */: return checkParameter(node); - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: return checkPropertyDeclaration(node); - case 156 /* FunctionType */: - case 157 /* ConstructorType */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: return checkSignatureDeclaration(node); - case 153 /* IndexSignature */: + case 154 /* IndexSignature */: return checkSignatureDeclaration(node); - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: return checkMethodDeclaration(node); - case 148 /* Constructor */: + case 149 /* Constructor */: return checkConstructorDeclaration(node); - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: return checkAccessorDeclaration(node); - case 155 /* TypeReference */: + case 156 /* TypeReference */: return checkTypeReferenceNode(node); - case 154 /* TypePredicate */: + case 155 /* TypePredicate */: return checkTypePredicate(node); - case 158 /* TypeQuery */: + case 159 /* TypeQuery */: return checkTypeQuery(node); - case 159 /* TypeLiteral */: + case 160 /* TypeLiteral */: return checkTypeLiteral(node); - case 160 /* ArrayType */: + case 161 /* ArrayType */: return checkArrayType(node); - case 161 /* TupleType */: + case 162 /* TupleType */: return checkTupleType(node); - case 162 /* UnionType */: - case 163 /* IntersectionType */: + case 163 /* UnionType */: + case 164 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 164 /* ParenthesizedType */: + case 165 /* ParenthesizedType */: return checkSourceElement(node.type); - case 220 /* FunctionDeclaration */: + case 221 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 199 /* Block */: - case 226 /* ModuleBlock */: + case 200 /* Block */: + case 227 /* ModuleBlock */: return checkBlock(node); - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: return checkVariableStatement(node); - case 202 /* ExpressionStatement */: + case 203 /* ExpressionStatement */: return checkExpressionStatement(node); - case 203 /* IfStatement */: + case 204 /* IfStatement */: return checkIfStatement(node); - case 204 /* DoStatement */: + case 205 /* DoStatement */: return checkDoStatement(node); - case 205 /* WhileStatement */: + case 206 /* WhileStatement */: return checkWhileStatement(node); - case 206 /* ForStatement */: + case 207 /* ForStatement */: return checkForStatement(node); - case 207 /* ForInStatement */: + case 208 /* ForInStatement */: return checkForInStatement(node); - case 208 /* ForOfStatement */: + case 209 /* ForOfStatement */: return checkForOfStatement(node); - case 209 /* ContinueStatement */: - case 210 /* BreakStatement */: + case 210 /* ContinueStatement */: + case 211 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 211 /* ReturnStatement */: + case 212 /* ReturnStatement */: return checkReturnStatement(node); - case 212 /* WithStatement */: + case 213 /* WithStatement */: return checkWithStatement(node); - case 213 /* SwitchStatement */: + case 214 /* SwitchStatement */: return checkSwitchStatement(node); - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: return checkLabeledStatement(node); - case 215 /* ThrowStatement */: + case 216 /* ThrowStatement */: return checkThrowStatement(node); - case 216 /* TryStatement */: + case 217 /* TryStatement */: return checkTryStatement(node); - case 218 /* VariableDeclaration */: + case 219 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 169 /* BindingElement */: + case 170 /* BindingElement */: return checkBindingElement(node); - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: return checkClassDeclaration(node); - case 222 /* InterfaceDeclaration */: + case 223 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 223 /* TypeAliasDeclaration */: + case 224 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 230 /* ImportDeclaration */: + case 231 /* ImportDeclaration */: return checkImportDeclaration(node); - case 229 /* ImportEqualsDeclaration */: + case 230 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 236 /* ExportDeclaration */: + case 237 /* ExportDeclaration */: return checkExportDeclaration(node); - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: return checkExportAssignment(node); - case 201 /* EmptyStatement */: + case 202 /* EmptyStatement */: checkGrammarStatementInAmbientContext(node); return; - case 217 /* DebuggerStatement */: + case 218 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 239 /* MissingDeclaration */: + case 240 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -39040,17 +39367,17 @@ var ts; for (var _i = 0, deferredNodes_1 = deferredNodes; _i < deferredNodes_1.length; _i++) { var node = deferredNodes_1[_i]; switch (node.kind) { - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: checkAccessorDeferred(node); break; - case 192 /* ClassExpression */: + case 193 /* ClassExpression */: checkClassExpressionDeferred(node); break; } @@ -39131,7 +39458,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 212 /* WithStatement */ && node.parent.statement === node) { + if (node.parent.kind === 213 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -39158,21 +39485,21 @@ var ts; if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 192 /* ClassExpression */: + case 193 /* 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 221 /* ClassDeclaration */: - case 222 /* InterfaceDeclaration */: + case 222 /* ClassDeclaration */: + case 223 /* InterfaceDeclaration */: // If we didn't come from static member of class or interface, // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. @@ -39181,7 +39508,7 @@ var ts; copySymbols(getSymbolOfNode(location).members, meaning & 793064 /* Type */); } break; - case 179 /* FunctionExpression */: + case 180 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -39224,34 +39551,34 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 69 /* Identifier */ && + return name.kind === 70 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 141 /* TypeParameter */: - case 221 /* ClassDeclaration */: - case 222 /* InterfaceDeclaration */: - case 223 /* TypeAliasDeclaration */: - case 224 /* EnumDeclaration */: + case 142 /* TypeParameter */: + case 222 /* ClassDeclaration */: + case 223 /* InterfaceDeclaration */: + case 224 /* TypeAliasDeclaration */: + case 225 /* 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 === 139 /* QualifiedName */) { + while (node.parent && node.parent.kind === 140 /* QualifiedName */) { node = node.parent; } - return node.parent && (node.parent.kind === 155 /* TypeReference */ || node.parent.kind === 267 /* JSDocTypeReference */); + return node.parent && (node.parent.kind === 156 /* TypeReference */ || node.parent.kind === 267 /* JSDocTypeReference */); } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 172 /* PropertyAccessExpression */) { + while (node.parent && node.parent.kind === 173 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent && node.parent.kind === 194 /* ExpressionWithTypeArguments */; + return node.parent && node.parent.kind === 195 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -39268,13 +39595,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 139 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 140 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 229 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 230 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 235 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 236 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -39286,7 +39613,7 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 172 /* PropertyAccessExpression */) { + if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 173 /* PropertyAccessExpression */) { var specialPropertyAssignmentKind = ts.getSpecialPropertyAssignmentKind(entityName.parent.parent); switch (specialPropertyAssignmentKind) { case 1 /* ExportsProperty */: @@ -39298,15 +39625,15 @@ var ts; default: } } - if (entityName.parent.kind === 235 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 236 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { return resolveEntityName(entityName, /*all meanings*/ 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */ | 8388608 /* Alias */); } - if (entityName.kind !== 172 /* PropertyAccessExpression */ && isInRightSideOfImportOrExportAssignment(entityName)) { + if (entityName.kind !== 173 /* PropertyAccessExpression */ && isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(entityName, 229 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 230 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); - return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importEqualsDeclaration, /*dontResolveAlias*/ true); + return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } if (ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; @@ -39314,7 +39641,7 @@ var ts; if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0 /* None */; // In an interface or class, we're definitely interested in a type. - if (entityName.parent.kind === 194 /* ExpressionWithTypeArguments */) { + if (entityName.parent.kind === 195 /* ExpressionWithTypeArguments */) { meaning = 793064 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { @@ -39332,20 +39659,20 @@ var ts; // Missing entity name. return undefined; } - if (entityName.kind === 69 /* Identifier */) { + if (entityName.kind === 70 /* Identifier */) { if (ts.isJSXTagName(entityName) && isJsxIntrinsicIdentifier(entityName)) { return getIntrinsicTagSymbol(entityName.parent); } return resolveEntityName(entityName, 107455 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.kind === 172 /* PropertyAccessExpression */) { + else if (entityName.kind === 173 /* PropertyAccessExpression */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 139 /* QualifiedName */) { + else if (entityName.kind === 140 /* QualifiedName */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -39354,13 +39681,13 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = (entityName.parent.kind === 155 /* TypeReference */ || entityName.parent.kind === 267 /* JSDocTypeReference */) ? 793064 /* Type */ : 1920 /* Namespace */; + var meaning = (entityName.parent.kind === 156 /* TypeReference */ || entityName.parent.kind === 267 /* JSDocTypeReference */) ? 793064 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } else if (entityName.parent.kind === 246 /* JsxAttribute */) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 154 /* TypePredicate */) { + if (entityName.parent.kind === 155 /* TypePredicate */) { return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? @@ -39381,12 +39708,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(node.parent.parent); } - if (node.kind === 69 /* Identifier */) { + if (node.kind === 70 /* Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (node.parent.kind === 169 /* BindingElement */ && - node.parent.parent.kind === 167 /* ObjectBindingPattern */ && + else if (node.parent.kind === 170 /* BindingElement */ && + node.parent.parent.kind === 168 /* ObjectBindingPattern */ && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -39396,11 +39723,11 @@ var ts; } } switch (node.kind) { - case 69 /* Identifier */: - case 172 /* PropertyAccessExpression */: - case 139 /* QualifiedName */: + case 70 /* Identifier */: + case 173 /* PropertyAccessExpression */: + case 140 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 97 /* ThisKeyword */: + case 98 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -39409,15 +39736,15 @@ var ts; } } // fallthrough - case 95 /* SuperKeyword */: + case 96 /* SuperKeyword */: var type = ts.isPartOfExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 165 /* ThisType */: + case 166 /* ThisType */: return getTypeFromTypeNode(node).symbol; - case 121 /* ConstructorKeyword */: + case 122 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 148 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 149 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -39425,7 +39752,7 @@ var ts; // External module name in an import declaration if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 230 /* ImportDeclaration */ || node.parent.kind === 236 /* ExportDeclaration */) && + ((node.parent.kind === 231 /* ImportDeclaration */ || node.parent.kind === 237 /* ExportDeclaration */) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } @@ -39435,7 +39762,7 @@ var ts; // Fall through case 8 /* NumericLiteral */: // index access - if (node.parent.kind === 173 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { + if (node.parent.kind === 174 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -39514,17 +39841,17 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 171 /* ObjectLiteralExpression */ || expr.kind === 170 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 172 /* ObjectLiteralExpression */ || expr.kind === 171 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 208 /* ForOfStatement */) { + if (expr.parent.kind === 209 /* ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression); return checkDestructuringAssignment(expr, iteratedType || unknownType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 187 /* BinaryExpression */) { + if (expr.parent.kind === 188 /* BinaryExpression */) { var iteratedType = checkExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || unknownType); } @@ -39535,7 +39862,7 @@ var ts; return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent); } // Array literal assignment - array destructuring pattern - ts.Debug.assert(expr.parent.kind === 170 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.parent.kind === 171 /* ArrayLiteralExpression */); // [{ property1: p1, property2 }] = elems; var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, /*allowStringInput*/ false) || unknownType; @@ -39724,7 +40051,7 @@ var ts; // they will not collide with anything var isDeclaredInLoop = nodeLinks_1.flags & 262144 /* BlockScopedBindingInLoop */; var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); - var inLoopBodyBlock = container.kind === 199 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 200 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -39770,18 +40097,18 @@ var ts; return true; } switch (node.kind) { - case 229 /* ImportEqualsDeclaration */: - case 231 /* ImportClause */: - case 232 /* NamespaceImport */: - case 234 /* ImportSpecifier */: - case 238 /* ExportSpecifier */: + case 230 /* ImportEqualsDeclaration */: + case 232 /* ImportClause */: + case 233 /* NamespaceImport */: + case 235 /* ImportSpecifier */: + case 239 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 236 /* ExportDeclaration */: + case 237 /* ExportDeclaration */: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: return node.expression - && node.expression.kind === 69 /* Identifier */ + && node.expression.kind === 70 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : true; } @@ -40043,7 +40370,7 @@ var ts; // property access can only be used as values // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries - var meaning = (node.kind === 172 /* PropertyAccessExpression */) || (node.kind === 69 /* Identifier */ && isInTypeQuery(node)) + var meaning = (node.kind === 173 /* PropertyAccessExpression */) || (node.kind === 70 /* Identifier */ && isInTypeQuery(node)) ? 107455 /* Value */ | 1048576 /* ExportValue */ : 793064 /* Type */ | 1920 /* Namespace */; var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); @@ -40192,7 +40519,7 @@ var ts; getGlobalPromiseConstructorLikeType = ts.memoize(function () { return getGlobalType("PromiseConstructorLike"); }); getGlobalThenableType = ts.memoize(createThenableType); getGlobalTemplateStringsArrayType = ts.memoize(function () { return getGlobalType("TemplateStringsArray"); }); - if (languageVersion >= 2 /* ES6 */) { + if (languageVersion >= 2 /* ES2015 */) { getGlobalESSymbolType = ts.memoize(function () { return getGlobalType("Symbol"); }); getGlobalIterableType = ts.memoize(function () { return getGlobalType("Iterable", /*arity*/ 1); }); getGlobalIteratorType = ts.memoize(function () { return getGlobalType("Iterator", /*arity*/ 1); }); @@ -40205,6 +40532,7 @@ var ts; getGlobalIterableIteratorType = ts.memoize(function () { return emptyGenericType; }); } anyArrayType = createArrayType(anyType); + autoArrayType = createArrayType(autoType); var symbol = getGlobalSymbol("ReadonlyArray", 793064 /* Type */, /*diagnostic*/ undefined); globalReadonlyArrayType = symbol && getTypeOfGlobalSymbol(symbol, /*arity*/ 1); anyReadonlyArrayType = globalReadonlyArrayType ? createTypeFromGenericGlobalType(globalReadonlyArrayType, [anyType]) : anyArrayType; @@ -40218,7 +40546,7 @@ var ts; // If we found the module, report errors if it does not have the necessary exports. if (helpersModule) { var exports = helpersModule.exports; - if (requestedExternalEmitHelpers & 1024 /* HasClassExtends */ && languageVersion < 2 /* ES6 */) { + if (requestedExternalEmitHelpers & 1024 /* HasClassExtends */ && languageVersion < 2 /* ES2015 */) { verifyHelperSymbol(exports, "__extends", 107455 /* Value */); } if (requestedExternalEmitHelpers & 16384 /* HasJsxSpreadAttributes */ && compilerOptions.jsx !== 1 /* Preserve */) { @@ -40235,7 +40563,7 @@ var ts; } if (requestedExternalEmitHelpers & 8192 /* HasAsyncFunctions */) { verifyHelperSymbol(exports, "__awaiter", 107455 /* Value */); - if (languageVersion < 2 /* ES6 */) { + if (languageVersion < 2 /* ES2015 */) { verifyHelperSymbol(exports, "__generator", 107455 /* Value */); } } @@ -40272,14 +40600,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node)) { - if (node.kind === 147 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 148 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload); } else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } } - else if (node.kind === 149 /* GetAccessor */ || node.kind === 150 /* SetAccessor */) { + else if (node.kind === 150 /* GetAccessor */ || node.kind === 151 /* 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); @@ -40296,28 +40624,28 @@ var ts; var flags = 0 /* None */; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 128 /* ReadonlyKeyword */) { - if (node.kind === 144 /* PropertySignature */ || node.kind === 146 /* MethodSignature */) { + if (modifier.kind !== 129 /* ReadonlyKeyword */) { + if (node.kind === 145 /* PropertySignature */ || node.kind === 147 /* MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 153 /* IndexSignature */) { + if (node.kind === 154 /* IndexSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 74 /* ConstKeyword */: - if (node.kind !== 224 /* EnumDeclaration */ && node.parent.kind === 221 /* ClassDeclaration */) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(74 /* ConstKeyword */)); + case 75 /* ConstKeyword */: + if (node.kind !== 225 /* EnumDeclaration */ && node.parent.kind === 222 /* ClassDeclaration */) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(75 /* ConstKeyword */)); } break; - case 112 /* PublicKeyword */: - case 111 /* ProtectedKeyword */: - case 110 /* PrivateKeyword */: + case 113 /* PublicKeyword */: + case 112 /* ProtectedKeyword */: + case 111 /* PrivateKeyword */: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); - if (modifier.kind === 111 /* ProtectedKeyword */) { + if (modifier.kind === 112 /* ProtectedKeyword */) { lastProtected = modifier; } - else if (modifier.kind === 110 /* PrivateKeyword */) { + else if (modifier.kind === 111 /* PrivateKeyword */) { lastPrivate = modifier; } if (flags & 28 /* AccessibilityModifier */) { @@ -40332,11 +40660,11 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 226 /* ModuleBlock */ || node.parent.kind === 256 /* SourceFile */) { + else if (node.parent.kind === 227 /* ModuleBlock */ || node.parent.kind === 256 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { - if (modifier.kind === 110 /* PrivateKeyword */) { + if (modifier.kind === 111 /* PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -40345,7 +40673,7 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 113 /* StaticKeyword */: + case 114 /* StaticKeyword */: if (flags & 32 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } @@ -40355,10 +40683,10 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 226 /* ModuleBlock */ || node.parent.kind === 256 /* SourceFile */) { + else if (node.parent.kind === 227 /* ModuleBlock */ || node.parent.kind === 256 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 142 /* Parameter */) { + else if (node.kind === 143 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { @@ -40367,18 +40695,18 @@ var ts; flags |= 32 /* Static */; lastStatic = modifier; break; - case 128 /* ReadonlyKeyword */: + case 129 /* ReadonlyKeyword */: if (flags & 64 /* Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 145 /* PropertyDeclaration */ && node.kind !== 144 /* PropertySignature */ && node.kind !== 153 /* IndexSignature */ && node.kind !== 142 /* Parameter */) { + else if (node.kind !== 146 /* PropertyDeclaration */ && node.kind !== 145 /* PropertySignature */ && node.kind !== 154 /* IndexSignature */ && node.kind !== 143 /* Parameter */) { // If node.kind === SyntaxKind.Parameter, checkParameter report an error if it's not a parameter property. return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } flags |= 64 /* Readonly */; lastReadonly = modifier; break; - case 82 /* ExportKeyword */: + case 83 /* ExportKeyword */: if (flags & 1 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -40391,45 +40719,45 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 221 /* ClassDeclaration */) { + else if (node.parent.kind === 222 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 142 /* Parameter */) { + else if (node.kind === 143 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; - case 122 /* DeclareKeyword */: + case 123 /* DeclareKeyword */: if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 221 /* ClassDeclaration */) { + else if (node.parent.kind === 222 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 142 /* Parameter */) { + else if (node.kind === 143 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 226 /* ModuleBlock */) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 227 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; lastDeclare = modifier; break; - case 115 /* AbstractKeyword */: + case 116 /* AbstractKeyword */: if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 221 /* ClassDeclaration */) { - if (node.kind !== 147 /* MethodDeclaration */ && - node.kind !== 145 /* PropertyDeclaration */ && - node.kind !== 149 /* GetAccessor */ && - node.kind !== 150 /* SetAccessor */) { + if (node.kind !== 222 /* ClassDeclaration */) { + if (node.kind !== 148 /* MethodDeclaration */ && + node.kind !== 146 /* PropertyDeclaration */ && + node.kind !== 150 /* GetAccessor */ && + node.kind !== 151 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 221 /* ClassDeclaration */ && ts.getModifierFlags(node.parent) & 128 /* Abstract */)) { + if (!(node.parent.kind === 222 /* ClassDeclaration */ && ts.getModifierFlags(node.parent) & 128 /* Abstract */)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32 /* Static */) { @@ -40441,14 +40769,14 @@ var ts; } flags |= 128 /* Abstract */; break; - case 118 /* AsyncKeyword */: + case 119 /* AsyncKeyword */: if (flags & 256 /* 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 === 142 /* Parameter */) { + else if (node.kind === 143 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256 /* Async */; @@ -40456,7 +40784,7 @@ var ts; break; } } - if (node.kind === 148 /* Constructor */) { + if (node.kind === 149 /* Constructor */) { if (flags & 32 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -40471,13 +40799,13 @@ var ts; } return; } - else if ((node.kind === 230 /* ImportDeclaration */ || node.kind === 229 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 231 /* ImportDeclaration */ || node.kind === 230 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 142 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 143 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 142 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 143 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256 /* Async */) { @@ -40497,38 +40825,38 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 148 /* Constructor */: - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 153 /* IndexSignature */: - case 225 /* ModuleDeclaration */: - case 230 /* ImportDeclaration */: - case 229 /* ImportEqualsDeclaration */: - case 236 /* ExportDeclaration */: - case 235 /* ExportAssignment */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: - case 142 /* Parameter */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 149 /* Constructor */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 154 /* IndexSignature */: + case 226 /* ModuleDeclaration */: + case 231 /* ImportDeclaration */: + case 230 /* ImportEqualsDeclaration */: + case 237 /* ExportDeclaration */: + case 236 /* ExportAssignment */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 143 /* Parameter */: return false; default: - if (node.parent.kind === 226 /* ModuleBlock */ || node.parent.kind === 256 /* SourceFile */) { + if (node.parent.kind === 227 /* ModuleBlock */ || node.parent.kind === 256 /* SourceFile */) { return false; } switch (node.kind) { - case 220 /* FunctionDeclaration */: - return nodeHasAnyModifiersExcept(node, 118 /* AsyncKeyword */); - case 221 /* ClassDeclaration */: - return nodeHasAnyModifiersExcept(node, 115 /* AbstractKeyword */); - case 222 /* InterfaceDeclaration */: - case 200 /* VariableStatement */: - case 223 /* TypeAliasDeclaration */: + case 221 /* FunctionDeclaration */: + return nodeHasAnyModifiersExcept(node, 119 /* AsyncKeyword */); + case 222 /* ClassDeclaration */: + return nodeHasAnyModifiersExcept(node, 116 /* AbstractKeyword */); + case 223 /* InterfaceDeclaration */: + case 201 /* VariableStatement */: + case 224 /* TypeAliasDeclaration */: return true; - case 224 /* EnumDeclaration */: - return nodeHasAnyModifiersExcept(node, 74 /* ConstKeyword */); + case 225 /* EnumDeclaration */: + return nodeHasAnyModifiersExcept(node, 75 /* ConstKeyword */); default: ts.Debug.fail(); return false; @@ -40540,10 +40868,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 147 /* MethodDeclaration */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 148 /* MethodDeclaration */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: if (!node.asteriskToken) { return false; } @@ -40559,7 +40887,7 @@ var ts; return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Trailing_comma_not_allowed); } } - function checkGrammarTypeParameterList(node, typeParameters, file) { + function checkGrammarTypeParameterList(typeParameters, file) { if (checkGrammarForDisallowedTrailingComma(typeParameters)) { return true; } @@ -40602,11 +40930,11 @@ var ts; function checkGrammarFunctionLikeDeclaration(node) { // Prevent cascading error by short-circuit var file = ts.getSourceFileOfNode(node); - return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node, node.typeParameters, file) || + return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node.typeParameters, file) || checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 180 /* ArrowFunction */) { + if (node.kind === 181 /* ArrowFunction */) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -40641,7 +40969,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 !== 132 /* StringKeyword */ && parameter.type.kind !== 130 /* NumberKeyword */) { + if (parameter.type.kind !== 133 /* StringKeyword */ && parameter.type.kind !== 131 /* NumberKeyword */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -40669,7 +40997,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 193 /* OmittedExpression */) { + if (arg.kind === 194 /* OmittedExpression */) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -40695,7 +41023,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 === 83 /* ExtendsKeyword */) { + if (heritageClause.token === 84 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -40708,7 +41036,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 106 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 107 /* ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -40724,14 +41052,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 83 /* ExtendsKeyword */) { + if (heritageClause.token === 84 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 106 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 107 /* ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -40742,31 +41070,31 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 140 /* ComputedPropertyName */) { + if (node.kind !== 141 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 187 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 24 /* CommaToken */) { + if (computedPropertyName.expression.kind === 188 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 25 /* 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 === 220 /* FunctionDeclaration */ || - node.kind === 179 /* FunctionExpression */ || - node.kind === 147 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 221 /* FunctionDeclaration */ || + node.kind === 180 /* FunctionExpression */ || + node.kind === 148 /* MethodDeclaration */); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } if (!node.body) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.An_overload_signature_cannot_be_declared_as_a_generator); } - if (languageVersion < 2 /* ES6 */) { + if (languageVersion < 2 /* ES2015 */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher); } } } - function checkGrammarForInvalidQuestionMark(node, questionToken, message) { + function checkGrammarForInvalidQuestionMark(questionToken, message) { if (questionToken) { return grammarErrorOnNode(questionToken, message); } @@ -40780,7 +41108,7 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; var name_24 = prop.name; - if (name_24.kind === 140 /* ComputedPropertyName */) { + if (name_24.kind === 141 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name_24); } @@ -40793,7 +41121,7 @@ var ts; if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (mod.kind !== 118 /* AsyncKeyword */ || prop.kind !== 147 /* MethodDeclaration */) { + if (mod.kind !== 119 /* AsyncKeyword */ || prop.kind !== 148 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -40809,19 +41137,19 @@ var ts; var currentKind = void 0; if (prop.kind === 253 /* PropertyAssignment */ || prop.kind === 254 /* ShorthandPropertyAssignment */) { // Grammar checking for computedPropertyName and shorthandPropertyAssignment - checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); + checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name_24.kind === 8 /* NumericLiteral */) { checkGrammarNumericLiteral(name_24); } currentKind = Property; } - else if (prop.kind === 147 /* MethodDeclaration */) { + else if (prop.kind === 148 /* MethodDeclaration */) { currentKind = Property; } - else if (prop.kind === 149 /* GetAccessor */) { + else if (prop.kind === 150 /* GetAccessor */) { currentKind = GetAccessor; } - else if (prop.kind === 150 /* SetAccessor */) { + else if (prop.kind === 151 /* SetAccessor */) { currentKind = SetAccessor; } else { @@ -40878,7 +41206,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 219 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 220 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -40893,20 +41221,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 207 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 208 /* 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 = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 207 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 208 /* 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 === 207 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 208 /* 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); @@ -40930,11 +41258,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 149 /* GetAccessor */ ? + return grammarErrorOnNode(accessor.name, kind === 150 /* GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 150 /* SetAccessor */) { + else if (kind === 151 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -40957,10 +41285,10 @@ var ts; A get accessor has no parameters or a single `this` parameter. A set accessor has one parameter or a `this` parameter and one more parameter */ function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 149 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 150 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 149 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 150 /* GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } @@ -40975,8 +41303,8 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 171 /* ObjectLiteralExpression */) { - if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { + if (node.parent.kind === 172 /* ObjectLiteralExpression */) { + if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { return true; } else if (node.body === undefined) { @@ -40996,10 +41324,10 @@ 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 === 222 /* InterfaceDeclaration */) { + else if (node.parent.kind === 223 /* 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 === 159 /* TypeLiteral */) { + else if (node.parent.kind === 160 /* TypeLiteral */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } @@ -41010,11 +41338,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 214 /* LabeledStatement */: + case 215 /* 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 === 209 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 210 /* ContinueStatement */ && !ts.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); @@ -41022,8 +41350,8 @@ var ts; return false; } break; - case 213 /* SwitchStatement */: - if (node.kind === 210 /* BreakStatement */ && !node.label) { + case 214 /* SwitchStatement */: + if (node.kind === 211 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -41038,13 +41366,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 210 /* BreakStatement */ + var message = node.kind === 211 /* 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 === 210 /* BreakStatement */ + var message = node.kind === 211 /* 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); @@ -41056,7 +41384,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 === 168 /* ArrayBindingPattern */ || node.name.kind === 167 /* ObjectBindingPattern */) { + if (node.name.kind === 169 /* ArrayBindingPattern */ || node.name.kind === 168 /* ObjectBindingPattern */) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -41067,11 +41395,11 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || - expr.kind === 185 /* PrefixUnaryExpression */ && expr.operator === 36 /* MinusToken */ && + expr.kind === 186 /* PrefixUnaryExpression */ && expr.operator === 37 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 207 /* ForInStatement */ && node.parent.parent.kind !== 208 /* ForOfStatement */) { + if (node.parent.parent.kind !== 208 /* ForInStatement */ && node.parent.parent.kind !== 209 /* ForOfStatement */) { if (ts.isInAmbientContext(node)) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -41110,8 +41438,8 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 69 /* Identifier */) { - if (name.originalKeywordKind === 108 /* LetKeyword */) { + if (name.kind === 70 /* Identifier */) { + if (name.originalKeywordKind === 109 /* LetKeyword */) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -41136,15 +41464,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 203 /* IfStatement */: - case 204 /* DoStatement */: - case 205 /* WhileStatement */: - case 212 /* WithStatement */: - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: + case 204 /* IfStatement */: + case 205 /* DoStatement */: + case 206 /* WhileStatement */: + case 213 /* WithStatement */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: return false; - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -41199,7 +41527,7 @@ var ts; return true; } } - else if (node.parent.kind === 222 /* InterfaceDeclaration */) { + else if (node.parent.kind === 223 /* InterfaceDeclaration */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -41207,7 +41535,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 159 /* TypeLiteral */) { + else if (node.parent.kind === 160 /* 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; } @@ -41232,13 +41560,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 222 /* InterfaceDeclaration */ || - node.kind === 223 /* TypeAliasDeclaration */ || - node.kind === 230 /* ImportDeclaration */ || - node.kind === 229 /* ImportEqualsDeclaration */ || - node.kind === 236 /* ExportDeclaration */ || - node.kind === 235 /* ExportAssignment */ || - node.kind === 228 /* NamespaceExportDeclaration */ || + if (node.kind === 223 /* InterfaceDeclaration */ || + node.kind === 224 /* TypeAliasDeclaration */ || + node.kind === 231 /* ImportDeclaration */ || + node.kind === 230 /* ImportEqualsDeclaration */ || + node.kind === 237 /* ExportDeclaration */ || + node.kind === 236 /* ExportAssignment */ || + node.kind === 229 /* NamespaceExportDeclaration */ || ts.getModifierFlags(node) & (2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -41247,7 +41575,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 === 200 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 201 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -41273,7 +41601,7 @@ var ts; // to prevent noisiness. 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 === 199 /* Block */ || node.parent.kind === 226 /* ModuleBlock */ || node.parent.kind === 256 /* SourceFile */) { + if (node.parent.kind === 200 /* Block */ || node.parent.kind === 227 /* ModuleBlock */ || node.parent.kind === 256 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -41333,46 +41661,46 @@ var ts; * significantly impacted. */ var nodeEdgeTraversalMap = ts.createMap((_a = {}, - _a[139 /* QualifiedName */] = [ + _a[140 /* QualifiedName */] = [ { name: "left", test: ts.isEntityName }, { name: "right", test: ts.isIdentifier } ], - _a[143 /* Decorator */] = [ + _a[144 /* Decorator */] = [ { name: "expression", test: ts.isLeftHandSideExpression } ], - _a[177 /* TypeAssertionExpression */] = [ + _a[178 /* TypeAssertionExpression */] = [ { name: "type", test: ts.isTypeNode }, { name: "expression", test: ts.isUnaryExpression } ], - _a[195 /* AsExpression */] = [ + _a[196 /* AsExpression */] = [ { name: "expression", test: ts.isExpression }, { name: "type", test: ts.isTypeNode } ], - _a[196 /* NonNullExpression */] = [ + _a[197 /* NonNullExpression */] = [ { name: "expression", test: ts.isLeftHandSideExpression } ], - _a[224 /* EnumDeclaration */] = [ + _a[225 /* EnumDeclaration */] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "members", test: ts.isEnumMember } ], - _a[225 /* ModuleDeclaration */] = [ + _a[226 /* ModuleDeclaration */] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isModuleName }, { name: "body", test: ts.isModuleBody } ], - _a[226 /* ModuleBlock */] = [ + _a[227 /* ModuleBlock */] = [ { name: "statements", test: ts.isStatement } ], - _a[229 /* ImportEqualsDeclaration */] = [ + _a[230 /* ImportEqualsDeclaration */] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "moduleReference", test: ts.isModuleReference } ], - _a[240 /* ExternalModuleReference */] = [ + _a[241 /* ExternalModuleReference */] = [ { name: "expression", test: ts.isExpression, optional: true } ], _a[255 /* EnumMember */] = [ @@ -41398,47 +41726,47 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 138 /* LastToken */)) { + if ((kind > 0 /* FirstToken */ && kind <= 139 /* LastToken */)) { return initial; } // We do not yet support types. - if ((kind >= 154 /* TypePredicate */ && kind <= 166 /* LiteralType */)) { + if ((kind >= 155 /* TypePredicate */ && kind <= 167 /* LiteralType */)) { return initial; } var result = initial; switch (node.kind) { // Leaf nodes - case 198 /* SemicolonClassElement */: - case 201 /* EmptyStatement */: - case 193 /* OmittedExpression */: - case 217 /* DebuggerStatement */: + case 199 /* SemicolonClassElement */: + case 202 /* EmptyStatement */: + case 194 /* OmittedExpression */: + case 218 /* DebuggerStatement */: case 287 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: result = reduceNode(node.expression, f, result); break; // Signature elements - case 142 /* Parameter */: + case 143 /* Parameter */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.initializer, f, result); break; - case 143 /* Decorator */: + case 144 /* Decorator */: result = reduceNode(node.expression, f, result); break; // Type member - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.initializer, f, result); break; - case 147 /* MethodDeclaration */: + case 148 /* MethodDeclaration */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -41447,12 +41775,12 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 148 /* Constructor */: + case 149 /* Constructor */: result = ts.reduceLeft(node.modifiers, f, result); result = ts.reduceLeft(node.parameters, f, result); result = reduceNode(node.body, f, result); break; - case 149 /* GetAccessor */: + case 150 /* GetAccessor */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -41460,7 +41788,7 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 150 /* SetAccessor */: + case 151 /* SetAccessor */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -41468,45 +41796,45 @@ var ts; result = reduceNode(node.body, f, result); break; // Binding patterns - case 167 /* ObjectBindingPattern */: - case 168 /* ArrayBindingPattern */: + case 168 /* ObjectBindingPattern */: + case 169 /* ArrayBindingPattern */: result = ts.reduceLeft(node.elements, f, result); break; - case 169 /* BindingElement */: + case 170 /* BindingElement */: result = reduceNode(node.propertyName, f, result); result = reduceNode(node.name, f, result); result = reduceNode(node.initializer, f, result); break; // Expression - case 170 /* ArrayLiteralExpression */: + case 171 /* ArrayLiteralExpression */: result = ts.reduceLeft(node.elements, f, result); break; - case 171 /* ObjectLiteralExpression */: + case 172 /* ObjectLiteralExpression */: result = ts.reduceLeft(node.properties, f, result); break; - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: result = reduceNode(node.expression, f, result); result = reduceNode(node.name, f, result); break; - case 173 /* ElementAccessExpression */: + case 174 /* ElementAccessExpression */: result = reduceNode(node.expression, f, result); result = reduceNode(node.argumentExpression, f, result); break; - case 174 /* CallExpression */: + case 175 /* CallExpression */: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); result = ts.reduceLeft(node.arguments, f, result); break; - case 175 /* NewExpression */: + case 176 /* NewExpression */: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); result = ts.reduceLeft(node.arguments, f, result); break; - case 176 /* TaggedTemplateExpression */: + case 177 /* TaggedTemplateExpression */: result = reduceNode(node.tag, f, result); result = reduceNode(node.template, f, result); break; - case 179 /* FunctionExpression */: + case 180 /* FunctionExpression */: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.typeParameters, f, result); @@ -41514,119 +41842,119 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 180 /* ArrowFunction */: + case 181 /* ArrowFunction */: result = ts.reduceLeft(node.modifiers, f, result); result = ts.reduceLeft(node.typeParameters, f, result); result = ts.reduceLeft(node.parameters, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 178 /* ParenthesizedExpression */: - case 181 /* DeleteExpression */: - case 182 /* TypeOfExpression */: - case 183 /* VoidExpression */: - case 184 /* AwaitExpression */: - case 190 /* YieldExpression */: - case 191 /* SpreadElementExpression */: - case 196 /* NonNullExpression */: + case 179 /* ParenthesizedExpression */: + case 182 /* DeleteExpression */: + case 183 /* TypeOfExpression */: + case 184 /* VoidExpression */: + case 185 /* AwaitExpression */: + case 191 /* YieldExpression */: + case 192 /* SpreadElementExpression */: + case 197 /* NonNullExpression */: result = reduceNode(node.expression, f, result); break; - case 185 /* PrefixUnaryExpression */: - case 186 /* PostfixUnaryExpression */: + case 186 /* PrefixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: result = reduceNode(node.operand, f, result); break; - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: result = reduceNode(node.left, f, result); result = reduceNode(node.right, f, result); break; - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: result = reduceNode(node.condition, f, result); result = reduceNode(node.whenTrue, f, result); result = reduceNode(node.whenFalse, f, result); break; - case 189 /* TemplateExpression */: + case 190 /* TemplateExpression */: result = reduceNode(node.head, f, result); result = ts.reduceLeft(node.templateSpans, f, result); break; - case 192 /* ClassExpression */: + case 193 /* ClassExpression */: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.typeParameters, f, result); result = ts.reduceLeft(node.heritageClauses, f, result); result = ts.reduceLeft(node.members, f, result); break; - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); break; // Misc - case 197 /* TemplateSpan */: + case 198 /* TemplateSpan */: result = reduceNode(node.expression, f, result); result = reduceNode(node.literal, f, result); break; // Element - case 199 /* Block */: + case 200 /* Block */: result = ts.reduceLeft(node.statements, f, result); break; - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.declarationList, f, result); break; - case 202 /* ExpressionStatement */: + case 203 /* ExpressionStatement */: result = reduceNode(node.expression, f, result); break; - case 203 /* IfStatement */: + case 204 /* IfStatement */: result = reduceNode(node.expression, f, result); result = reduceNode(node.thenStatement, f, result); result = reduceNode(node.elseStatement, f, result); break; - case 204 /* DoStatement */: + case 205 /* DoStatement */: result = reduceNode(node.statement, f, result); result = reduceNode(node.expression, f, result); break; - case 205 /* WhileStatement */: - case 212 /* WithStatement */: + case 206 /* WhileStatement */: + case 213 /* WithStatement */: result = reduceNode(node.expression, f, result); result = reduceNode(node.statement, f, result); break; - case 206 /* ForStatement */: + case 207 /* ForStatement */: result = reduceNode(node.initializer, f, result); result = reduceNode(node.condition, f, result); result = reduceNode(node.incrementor, f, result); result = reduceNode(node.statement, f, result); break; - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: result = reduceNode(node.initializer, f, result); result = reduceNode(node.expression, f, result); result = reduceNode(node.statement, f, result); break; - case 211 /* ReturnStatement */: - case 215 /* ThrowStatement */: + case 212 /* ReturnStatement */: + case 216 /* ThrowStatement */: result = reduceNode(node.expression, f, result); break; - case 213 /* SwitchStatement */: + case 214 /* SwitchStatement */: result = reduceNode(node.expression, f, result); result = reduceNode(node.caseBlock, f, result); break; - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: result = reduceNode(node.label, f, result); result = reduceNode(node.statement, f, result); break; - case 216 /* TryStatement */: + case 217 /* TryStatement */: result = reduceNode(node.tryBlock, f, result); result = reduceNode(node.catchClause, f, result); result = reduceNode(node.finallyBlock, f, result); break; - case 218 /* VariableDeclaration */: + case 219 /* VariableDeclaration */: result = reduceNode(node.name, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.initializer, f, result); break; - case 219 /* VariableDeclarationList */: + case 220 /* VariableDeclarationList */: result = ts.reduceLeft(node.declarations, f, result); break; - case 220 /* FunctionDeclaration */: + case 221 /* FunctionDeclaration */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -41635,7 +41963,7 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -41643,50 +41971,50 @@ var ts; result = ts.reduceLeft(node.heritageClauses, f, result); result = ts.reduceLeft(node.members, f, result); break; - case 227 /* CaseBlock */: + case 228 /* CaseBlock */: result = ts.reduceLeft(node.clauses, f, result); break; - case 230 /* ImportDeclaration */: + case 231 /* ImportDeclaration */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.importClause, f, result); result = reduceNode(node.moduleSpecifier, f, result); break; - case 231 /* ImportClause */: + case 232 /* ImportClause */: result = reduceNode(node.name, f, result); result = reduceNode(node.namedBindings, f, result); break; - case 232 /* NamespaceImport */: + case 233 /* NamespaceImport */: result = reduceNode(node.name, f, result); break; - case 233 /* NamedImports */: - case 237 /* NamedExports */: + case 234 /* NamedImports */: + case 238 /* NamedExports */: result = ts.reduceLeft(node.elements, f, result); break; - case 234 /* ImportSpecifier */: - case 238 /* ExportSpecifier */: + case 235 /* ImportSpecifier */: + case 239 /* ExportSpecifier */: result = reduceNode(node.propertyName, f, result); result = reduceNode(node.name, f, result); break; - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.expression, f, result); break; - case 236 /* ExportDeclaration */: + case 237 /* ExportDeclaration */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.exportClause, f, result); result = reduceNode(node.moduleSpecifier, f, result); break; // JSX - case 241 /* JsxElement */: + case 242 /* JsxElement */: result = reduceNode(node.openingElement, f, result); result = ts.reduceLeft(node.children, f, result); result = reduceNode(node.closingElement, f, result); break; - case 242 /* JsxSelfClosingElement */: - case 243 /* JsxOpeningElement */: + case 243 /* JsxSelfClosingElement */: + case 244 /* JsxOpeningElement */: result = reduceNode(node.tagName, f, result); result = ts.reduceLeft(node.attributes, f, result); break; @@ -41841,163 +42169,163 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 138 /* LastToken */)) { + if ((kind > 0 /* FirstToken */ && kind <= 139 /* LastToken */)) { return node; } // We do not yet support types. - if ((kind >= 154 /* TypePredicate */ && kind <= 166 /* LiteralType */)) { + if ((kind >= 155 /* TypePredicate */ && kind <= 167 /* LiteralType */)) { return node; } switch (node.kind) { - case 198 /* SemicolonClassElement */: - case 201 /* EmptyStatement */: - case 193 /* OmittedExpression */: - case 217 /* DebuggerStatement */: + case 199 /* SemicolonClassElement */: + case 202 /* EmptyStatement */: + case 194 /* OmittedExpression */: + case 218 /* DebuggerStatement */: // No need to visit nodes with no children. return node; // Names - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); // Signature elements - case 142 /* Parameter */: + case 143 /* Parameter */: return ts.updateParameterDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); // Type member - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: return ts.updateProperty(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); - case 147 /* MethodDeclaration */: + case 148 /* MethodDeclaration */: return ts.updateMethod(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, /*optional*/ true), context.endLexicalEnvironment())); - case 148 /* Constructor */: + case 149 /* Constructor */: return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, /*optional*/ true), context.endLexicalEnvironment())); - case 149 /* GetAccessor */: + case 150 /* GetAccessor */: return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, /*optional*/ true), context.endLexicalEnvironment())); - case 150 /* SetAccessor */: + case 151 /* SetAccessor */: return ts.updateSetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, /*optional*/ true), context.endLexicalEnvironment())); // Binding patterns - case 167 /* ObjectBindingPattern */: + case 168 /* ObjectBindingPattern */: return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); - case 168 /* ArrayBindingPattern */: + case 169 /* ArrayBindingPattern */: return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); - case 169 /* BindingElement */: + case 170 /* BindingElement */: return ts.updateBindingElement(node, visitNode(node.propertyName, visitor, ts.isPropertyName, /*optional*/ true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); // Expression - case 170 /* ArrayLiteralExpression */: + case 171 /* ArrayLiteralExpression */: return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); - case 171 /* ObjectLiteralExpression */: + case 172 /* ObjectLiteralExpression */: return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 173 /* ElementAccessExpression */: + case 174 /* ElementAccessExpression */: return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 174 /* CallExpression */: + case 175 /* CallExpression */: return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); - case 175 /* NewExpression */: + case 176 /* NewExpression */: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); - case 176 /* TaggedTemplateExpression */: + case 177 /* TaggedTemplateExpression */: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 179 /* FunctionExpression */: - return ts.updateFunctionExpression(node, visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, /*optional*/ true), context.endLexicalEnvironment())); - case 180 /* ArrowFunction */: + case 180 /* FunctionExpression */: + return ts.updateFunctionExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, /*optional*/ true), context.endLexicalEnvironment())); + case 181 /* ArrowFunction */: return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isConciseBody, /*optional*/ true), context.endLexicalEnvironment())); - case 181 /* DeleteExpression */: + case 182 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 182 /* TypeOfExpression */: + case 183 /* TypeOfExpression */: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 183 /* VoidExpression */: + case 184 /* VoidExpression */: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 184 /* AwaitExpression */: + case 185 /* AwaitExpression */: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); - case 185 /* PrefixUnaryExpression */: + case 186 /* PrefixUnaryExpression */: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 186 /* PostfixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); - case 189 /* TemplateExpression */: + case 190 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); - case 190 /* YieldExpression */: + case 191 /* YieldExpression */: return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); - case 191 /* SpreadElementExpression */: + case 192 /* SpreadElementExpression */: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 192 /* ClassExpression */: + case 193 /* ClassExpression */: return ts.updateClassExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, /*optional*/ true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); // Misc - case 197 /* TemplateSpan */: + case 198 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 199 /* Block */: + case 200 /* Block */: return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 202 /* ExpressionStatement */: + case 203 /* ExpressionStatement */: return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 203 /* IfStatement */: + case 204 /* IfStatement */: return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, /*optional*/ false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, /*optional*/ true, liftToBlock)); - case 204 /* DoStatement */: + case 205 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 205 /* WhileStatement */: + case 206 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 206 /* ForStatement */: + case 207 /* ForStatement */: return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 207 /* ForInStatement */: + case 208 /* ForInStatement */: return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 208 /* ForOfStatement */: + case 209 /* ForOfStatement */: return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 209 /* ContinueStatement */: + case 210 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, /*optional*/ true)); - case 210 /* BreakStatement */: + case 211 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, /*optional*/ true)); - case 211 /* ReturnStatement */: + case 212 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, /*optional*/ true)); - case 212 /* WithStatement */: + case 213 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 213 /* SwitchStatement */: + case 214 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 215 /* ThrowStatement */: + case 216 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 216 /* TryStatement */: + case 217 /* TryStatement */: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause, /*optional*/ true), visitNode(node.finallyBlock, visitor, ts.isBlock, /*optional*/ true)); - case 218 /* VariableDeclaration */: + case 219 /* VariableDeclaration */: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); - case 219 /* VariableDeclarationList */: + case 220 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); - case 220 /* FunctionDeclaration */: + case 221 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, /*optional*/ true), context.endLexicalEnvironment())); - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: return ts.updateClassDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, /*optional*/ true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 227 /* CaseBlock */: + case 228 /* CaseBlock */: return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 230 /* ImportDeclaration */: + case 231 /* ImportDeclaration */: return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, /*optional*/ true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 231 /* ImportClause */: + case 232 /* ImportClause */: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, /*optional*/ true)); - case 232 /* NamespaceImport */: + case 233 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 233 /* NamedImports */: + case 234 /* NamedImports */: return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); - case 234 /* ImportSpecifier */: + case 235 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.name, visitor, ts.isIdentifier)); - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 236 /* ExportDeclaration */: + case 237 /* ExportDeclaration */: return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, /*optional*/ true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, /*optional*/ true)); - case 237 /* NamedExports */: + case 238 /* NamedExports */: return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); - case 238 /* ExportSpecifier */: + case 239 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.name, visitor, ts.isIdentifier)); // JSX - case 241 /* JsxElement */: + case 242 /* JsxElement */: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 242 /* JsxSelfClosingElement */: + case 243 /* JsxSelfClosingElement */: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); - case 243 /* JsxOpeningElement */: + case 244 /* JsxOpeningElement */: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); case 245 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); @@ -42142,67 +42470,67 @@ var ts; * than calling this function. */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 154 /* FirstTypeNode */ && kind <= 166 /* LastTypeNode */) { + if (kind >= 155 /* FirstTypeNode */ && kind <= 167 /* LastTypeNode */) { return -3 /* TypeExcludes */; } switch (kind) { - case 174 /* CallExpression */: - case 175 /* NewExpression */: - case 170 /* ArrayLiteralExpression */: - return 537133909 /* ArrayLiteralOrCallOrNewExcludes */; - case 225 /* ModuleDeclaration */: - return 546335573 /* ModuleExcludes */; - case 142 /* Parameter */: - return 538968917 /* ParameterExcludes */; - case 180 /* ArrowFunction */: - return 550710101 /* ArrowFunctionExcludes */; - case 179 /* FunctionExpression */: - case 220 /* FunctionDeclaration */: - return 550726485 /* FunctionExcludes */; - case 219 /* VariableDeclarationList */: - return 538968917 /* VariableDeclarationListExcludes */; - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - return 537590613 /* ClassExcludes */; - case 148 /* Constructor */: - return 550593365 /* ConstructorExcludes */; - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - return 550593365 /* MethodOrAccessorExcludes */; - case 117 /* AnyKeyword */: - case 130 /* NumberKeyword */: - case 127 /* NeverKeyword */: - case 132 /* StringKeyword */: - case 120 /* BooleanKeyword */: - case 133 /* SymbolKeyword */: - case 103 /* VoidKeyword */: - case 141 /* TypeParameter */: - case 144 /* PropertySignature */: - case 146 /* MethodSignature */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: - case 222 /* InterfaceDeclaration */: - case 223 /* TypeAliasDeclaration */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: + case 171 /* ArrayLiteralExpression */: + return 537922901 /* ArrayLiteralOrCallOrNewExcludes */; + case 226 /* ModuleDeclaration */: + return 574729557 /* ModuleExcludes */; + case 143 /* Parameter */: + return 545262933 /* ParameterExcludes */; + case 181 /* ArrowFunction */: + return 592227669 /* ArrowFunctionExcludes */; + case 180 /* FunctionExpression */: + case 221 /* FunctionDeclaration */: + return 592293205 /* FunctionExcludes */; + case 220 /* VariableDeclarationList */: + return 545262933 /* VariableDeclarationListExcludes */; + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + return 539749717 /* ClassExcludes */; + case 149 /* Constructor */: + return 591760725 /* ConstructorExcludes */; + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + return 591760725 /* MethodOrAccessorExcludes */; + case 118 /* AnyKeyword */: + case 131 /* NumberKeyword */: + case 128 /* NeverKeyword */: + case 133 /* StringKeyword */: + case 121 /* BooleanKeyword */: + case 134 /* SymbolKeyword */: + case 104 /* VoidKeyword */: + case 142 /* TypeParameter */: + case 145 /* PropertySignature */: + case 147 /* MethodSignature */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: + case 223 /* InterfaceDeclaration */: + case 224 /* TypeAliasDeclaration */: return -3 /* TypeExcludes */; - case 171 /* ObjectLiteralExpression */: - return 537430869 /* ObjectLiteralExcludes */; + case 172 /* ObjectLiteralExpression */: + return 539110741 /* ObjectLiteralExcludes */; default: - return 536871765 /* NodeExcludes */; + return 536874325 /* NodeExcludes */; } } var Debug; (function (Debug) { Debug.failNotOptional = Debug.shouldAssert(1 /* Normal */) ? function (message) { return Debug.assert(false, message || "Node not optional."); } - : function (message) { }; + : function () { }; Debug.failBadSyntaxKind = Debug.shouldAssert(1 /* Normal */) ? function (node, message) { return Debug.assert(false, message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " was unexpected."; }); } - : function (node, message) { }; + : function () { }; Debug.assertNode = Debug.shouldAssert(1 /* Normal */) ? function (node, test, message) { return Debug.assert(test === undefined || test(node), message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }); } - : function (node, test, message) { }; + : function () { }; function getFunctionName(func) { if (typeof func !== "function") { return ""; @@ -42264,7 +42592,7 @@ var ts; // location should point to the right-hand value of the expression. location = value; } - flattenDestructuring(context, node, value, location, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, location, emitAssignment, emitTempVariableAssignment, visitor); if (needsValue) { expressions.push(value); } @@ -42293,9 +42621,9 @@ var ts; * @param value The rhs value for the binding pattern. * @param visitor An optional visitor to use to visit expressions. */ - function flattenParameterDestructuring(context, node, value, visitor) { + function flattenParameterDestructuring(node, value, visitor) { var declarations = []; - flattenDestructuring(context, node, value, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, visitor); return declarations; function emitAssignment(name, value, location) { var declaration = ts.createVariableDeclaration(name, /*type*/ undefined, value, location); @@ -42319,10 +42647,10 @@ var ts; * @param value An optional rhs value for the binding pattern. * @param visitor An optional visitor to use to visit expressions. */ - function flattenVariableDestructuring(context, node, value, visitor, recordTempVariable) { + function flattenVariableDestructuring(node, value, visitor, recordTempVariable) { var declarations = []; var pendingAssignments; - flattenDestructuring(context, node, value, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, visitor); return declarations; function emitAssignment(name, value, location, original) { if (pendingAssignments) { @@ -42364,9 +42692,9 @@ var ts; * @param nameSubstitution An optional callback used to substitute binding names. * @param visitor An optional visitor to use to visit expressions. */ - function flattenVariableDestructuringToExpression(context, node, recordTempVariable, nameSubstitution, visitor) { + function flattenVariableDestructuringToExpression(node, recordTempVariable, nameSubstitution, visitor) { var pendingAssignments = []; - flattenDestructuring(context, node, /*value*/ undefined, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, /*value*/ undefined, node, emitAssignment, emitTempVariableAssignment, visitor); var expression = ts.inlineExpressions(pendingAssignments); ts.aggregateTransformFlags(expression); return expression; @@ -42390,7 +42718,7 @@ var ts; } } ts.flattenVariableDestructuringToExpression = flattenVariableDestructuringToExpression; - function flattenDestructuring(context, root, value, location, emitAssignment, emitTempVariableAssignment, visitor) { + function flattenDestructuring(root, value, location, emitAssignment, emitTempVariableAssignment, visitor) { if (value && visitor) { value = ts.visitNode(value, visitor, ts.isExpression); } @@ -42412,7 +42740,7 @@ var ts; } target = bindingTarget.name; } - else if (ts.isBinaryExpression(bindingTarget) && bindingTarget.operatorToken.kind === 56 /* EqualsToken */) { + else if (ts.isBinaryExpression(bindingTarget) && bindingTarget.operatorToken.kind === 57 /* EqualsToken */) { var initializer = visitor ? ts.visitNode(bindingTarget.right, visitor, ts.isExpression) : bindingTarget.right; @@ -42422,10 +42750,10 @@ var ts; else { target = bindingTarget; } - if (target.kind === 171 /* ObjectLiteralExpression */) { + if (target.kind === 172 /* ObjectLiteralExpression */) { emitObjectLiteralAssignment(target, value, location); } - else if (target.kind === 170 /* ArrayLiteralExpression */) { + else if (target.kind === 171 /* ArrayLiteralExpression */) { emitArrayLiteralAssignment(target, value, location); } else { @@ -42464,9 +42792,9 @@ var ts; } for (var i = 0; i < numElements; i++) { var e = elements[i]; - if (e.kind !== 193 /* OmittedExpression */) { + if (e.kind !== 194 /* OmittedExpression */) { // Assignment for target = value.propName should highligh whole property, hence use e as source map node - if (e.kind !== 191 /* SpreadElementExpression */) { + if (e.kind !== 192 /* SpreadElementExpression */) { emitDestructuringAssignment(e, ts.createElementAccess(value, ts.createLiteral(i)), e); } else if (i === numElements - 1) { @@ -42502,7 +42830,7 @@ var ts; if (ts.isOmittedExpression(element)) { continue; } - else if (name.kind === 167 /* ObjectBindingPattern */) { + else if (name.kind === 168 /* ObjectBindingPattern */) { // Rewrite element to a declaration with an initializer that fetches property var propName = element.propertyName || element.name; emitBindingElement(element, createDestructuringPropertyAccess(value, propName)); @@ -42524,7 +42852,7 @@ var ts; } function createDefaultValueCheck(value, defaultValue, location) { value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true, location, emitTempVariableAssignment); - return ts.createConditional(ts.createStrictEquality(value, ts.createVoidZero()), ts.createToken(53 /* QuestionToken */), defaultValue, ts.createToken(54 /* ColonToken */), value); + return ts.createConditional(ts.createStrictEquality(value, ts.createVoidZero()), ts.createToken(54 /* QuestionToken */), defaultValue, ts.createToken(55 /* ColonToken */), value); } /** * Creates either a PropertyAccessExpression or an ElementAccessExpression for the @@ -42594,8 +42922,6 @@ var ts; TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["ClassAliases"] = 1] = "ClassAliases"; /** Enables substitutions for namespace exports. */ TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["NamespaceExports"] = 2] = "NamespaceExports"; - /** Enables substitutions for async methods with `super` calls. */ - TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["AsyncMethodsWithSuper"] = 4] = "AsyncMethodsWithSuper"; /* Enables substitutions for unqualified enum members */ TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["NonQualifiedEnumMembers"] = 8] = "NonQualifiedEnumMembers"; })(TypeScriptSubstitutionFlags || (TypeScriptSubstitutionFlags = {})); @@ -42612,8 +42938,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(172 /* PropertyAccessExpression */); - context.enableSubstitution(173 /* ElementAccessExpression */); + context.enableSubstitution(173 /* PropertyAccessExpression */); + context.enableSubstitution(174 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -42636,11 +42962,6 @@ var ts; * just-in-time substitution while printing an expression identifier. */ var applicableSubstitutions; - /** - * This keeps track of containers where `super` is valid, for use with - * just-in-time substitution for `super` expressions inside of async methods. - */ - var currentSuperContainer; return transformSourceFile; /** * Transform TypeScript-specific syntax in a SourceFile. @@ -42699,6 +43020,33 @@ var ts; } return node; } + /** + * Specialized visitor that visits the immediate children of a SourceFile. + * + * @param node The node to visit. + */ + function sourceElementVisitor(node) { + return saveStateAndInvoke(node, sourceElementVisitorWorker); + } + /** + * Specialized visitor that visits the immediate children of a SourceFile. + * + * @param node The node to visit. + */ + function sourceElementVisitorWorker(node) { + switch (node.kind) { + case 231 /* ImportDeclaration */: + return visitImportDeclaration(node); + case 230 /* ImportEqualsDeclaration */: + return visitImportEqualsDeclaration(node); + case 236 /* ExportAssignment */: + return visitExportAssignment(node); + case 237 /* ExportDeclaration */: + return visitExportDeclaration(node); + default: + return visitorWorker(node); + } + } /** * Specialized visitor that visits the immediate children of a namespace. * @@ -42713,11 +43061,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 236 /* ExportDeclaration */ || - node.kind === 230 /* ImportDeclaration */ || - node.kind === 231 /* ImportClause */ || - (node.kind === 229 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 240 /* ExternalModuleReference */)) { + if (node.kind === 237 /* ExportDeclaration */ || + node.kind === 231 /* ImportDeclaration */ || + node.kind === 232 /* ImportClause */ || + (node.kind === 230 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 241 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -42747,19 +43095,19 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 148 /* Constructor */: + case 149 /* Constructor */: // TypeScript constructors are transformed in `visitClassDeclaration`. // We elide them here as `visitorWorker` checks transform flags, which could // erronously include an ES6 constructor without TypeScript syntax. return undefined; - case 145 /* PropertyDeclaration */: - case 153 /* IndexSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 147 /* MethodDeclaration */: + case 146 /* PropertyDeclaration */: + case 154 /* IndexSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 148 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 198 /* SemicolonClassElement */: + case 199 /* SemicolonClassElement */: return node; default: ts.Debug.failBadSyntaxKind(node); @@ -42778,57 +43126,55 @@ var ts; return ts.createNotEmittedStatement(node); } switch (node.kind) { - case 82 /* ExportKeyword */: - case 77 /* DefaultKeyword */: + case 83 /* ExportKeyword */: + case 78 /* DefaultKeyword */: // ES6 export and default modifiers are elided when inside a namespace. return currentNamespace ? undefined : node; - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - case 115 /* AbstractKeyword */: - case 118 /* AsyncKeyword */: - case 74 /* ConstKeyword */: - case 122 /* DeclareKeyword */: - case 128 /* ReadonlyKeyword */: + case 113 /* PublicKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + case 116 /* AbstractKeyword */: + case 75 /* ConstKeyword */: + case 123 /* DeclareKeyword */: + case 129 /* ReadonlyKeyword */: // TypeScript accessibility and readonly modifiers are elided. - case 160 /* ArrayType */: - case 161 /* TupleType */: - case 159 /* TypeLiteral */: - case 154 /* TypePredicate */: - case 141 /* TypeParameter */: - case 117 /* AnyKeyword */: - case 120 /* BooleanKeyword */: - case 132 /* StringKeyword */: - case 130 /* NumberKeyword */: - case 127 /* NeverKeyword */: - case 103 /* VoidKeyword */: - case 133 /* SymbolKeyword */: - case 157 /* ConstructorType */: - case 156 /* FunctionType */: - case 158 /* TypeQuery */: - case 155 /* TypeReference */: - case 162 /* UnionType */: - case 163 /* IntersectionType */: - case 164 /* ParenthesizedType */: - case 165 /* ThisType */: - case 166 /* LiteralType */: + case 161 /* ArrayType */: + case 162 /* TupleType */: + case 160 /* TypeLiteral */: + case 155 /* TypePredicate */: + case 142 /* TypeParameter */: + case 118 /* AnyKeyword */: + case 121 /* BooleanKeyword */: + case 133 /* StringKeyword */: + case 131 /* NumberKeyword */: + case 128 /* NeverKeyword */: + case 104 /* VoidKeyword */: + case 134 /* SymbolKeyword */: + case 158 /* ConstructorType */: + case 157 /* FunctionType */: + case 159 /* TypeQuery */: + case 156 /* TypeReference */: + case 163 /* UnionType */: + case 164 /* IntersectionType */: + case 165 /* ParenthesizedType */: + case 166 /* ThisType */: + case 167 /* LiteralType */: // TypeScript type nodes are elided. - case 153 /* IndexSignature */: + case 154 /* IndexSignature */: // TypeScript index signatures are elided. - case 143 /* Decorator */: + case 144 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 223 /* TypeAliasDeclaration */: + case 224 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: // TypeScript property declarations are elided. - case 148 /* Constructor */: - // TypeScript constructors are transformed in `visitClassDeclaration`. - return undefined; - case 222 /* InterfaceDeclaration */: + case 149 /* Constructor */: + return visitConstructor(node); + case 223 /* InterfaceDeclaration */: // TypeScript interfaces are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return ts.createNotEmittedStatement(node); - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: // This is a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -42838,9 +43184,8 @@ var ts; // - property declarations // - index signatures // - method overload signatures - // - async methods return visitClassDeclaration(node); - case 192 /* ClassExpression */: + case 193 /* ClassExpression */: // This is a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -42850,7 +43195,6 @@ var ts; // - property declarations // - index signatures // - method overload signatures - // - async methods return visitClassExpression(node); case 251 /* HeritageClause */: // This is a heritage clause with TypeScript syntax extensions. @@ -42858,29 +43202,29 @@ var ts; // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 147 /* MethodDeclaration */: - // TypeScript method declarations may be 'async', and may have decorators, modifiers + case 148 /* MethodDeclaration */: + // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 149 /* GetAccessor */: + case 150 /* GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 150 /* SetAccessor */: - // Set Accessors can have TypeScript modifiers, decorators, and type annotations. + case 151 /* SetAccessor */: + // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 220 /* FunctionDeclaration */: - // TypeScript function declarations may be 'async' + case 221 /* FunctionDeclaration */: + // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 179 /* FunctionExpression */: - // TypeScript function expressions may be 'async' + case 180 /* FunctionExpression */: + // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 180 /* ArrowFunction */: - // TypeScript arrow functions may be 'async' + case 181 /* ArrowFunction */: + // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 142 /* Parameter */: + case 143 /* Parameter */: // This is a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -42890,30 +43234,33 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 177 /* TypeAssertionExpression */: - case 195 /* AsExpression */: + case 178 /* TypeAssertionExpression */: + case 196 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 196 /* NonNullExpression */: + case 175 /* CallExpression */: + return visitCallExpression(node); + case 176 /* NewExpression */: + return visitNewExpression(node); + case 197 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 184 /* AwaitExpression */: - // TypeScript 'await' expressions must be transformed. - return visitAwaitExpression(node); - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 225 /* ModuleDeclaration */: + case 219 /* VariableDeclaration */: + return visitVariableDeclaration(node); + case 226 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 229 /* ImportEqualsDeclaration */: + case 230 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -42929,14 +43276,14 @@ var ts; function onBeforeVisitNode(node) { switch (node.kind) { case 256 /* SourceFile */: - case 227 /* CaseBlock */: - case 226 /* ModuleBlock */: - case 199 /* Block */: + case 228 /* CaseBlock */: + case 227 /* ModuleBlock */: + case 200 /* Block */: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; - case 221 /* ClassDeclaration */: - case 220 /* FunctionDeclaration */: + case 222 /* ClassDeclaration */: + case 221 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -42967,14 +43314,14 @@ var ts; externalHelpersModuleImport.flags &= ~8 /* Synthesized */; statements.push(externalHelpersModuleImport); currentSourceFileExternalHelpersModuleName = externalHelpersModuleName; - ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); + ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); currentSourceFileExternalHelpersModuleName = undefined; node = ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); node.externalHelpersModuleName = externalHelpersModuleName; } else { - node = ts.visitEachChild(node, visitor, context); + node = ts.visitEachChild(node, sourceElementVisitor, context); } ts.setEmitFlags(node, 1 /* EmitEmitHelpers */ | ts.getEmitFlags(node)); return node; @@ -43048,7 +43395,7 @@ var ts; // HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using // a lexical declaration such as a LexicalDeclaration or a ClassDeclaration. if (staticProperties.length) { - addInitializedPropertyStatements(statements, node, staticProperties, getLocalName(node, /*noSourceMaps*/ true)); + addInitializedPropertyStatements(statements, staticProperties, getLocalName(node, /*noSourceMaps*/ true)); } // Write any decorators of the node. addClassElementDecorationStatements(statements, node, /*isStatic*/ false); @@ -43224,7 +43571,7 @@ var ts; function visitClassExpression(node) { var staticProperties = getInitializedProperties(node, /*isStatic*/ true); var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); - var members = transformClassMembers(node, heritageClauses !== undefined); + var members = transformClassMembers(node, ts.some(heritageClauses, function (c) { return c.token === 84 /* ExtendsKeyword */; })); var classExpression = ts.setOriginalNode(ts.createClassExpression( /*modifiers*/ undefined, node.name, /*typeParameters*/ undefined, heritageClauses, members, @@ -43241,7 +43588,7 @@ var ts; // the body of a class with static initializers. ts.setEmitFlags(classExpression, 524288 /* Indented */ | ts.getEmitFlags(classExpression)); expressions.push(ts.startOnNewLine(ts.createAssignment(temp, classExpression))); - ts.addRange(expressions, generateInitializedPropertyExpressions(node, staticProperties, temp)); + ts.addRange(expressions, generateInitializedPropertyExpressions(staticProperties, temp)); expressions.push(ts.startOnNewLine(temp)); return ts.inlineExpressions(expressions); } @@ -43273,7 +43620,7 @@ var ts; // If there is a property assignment, we need to emit constructor whether users define it or not // If there is no property assignment, we can omit constructor if users do not define it var hasInstancePropertyWithInitializer = ts.forEach(node.members, isInstanceInitializedProperty); - var hasParameterPropertyAssignments = node.transformFlags & 131072 /* ContainsParameterPropertyAssignments */; + var hasParameterPropertyAssignments = node.transformFlags & 524288 /* ContainsParameterPropertyAssignments */; var constructor = ts.getFirstConstructorWithBody(node); // If the class does not contain nodes that require a synthesized constructor, // accept the current constructor if it exists. @@ -43281,7 +43628,7 @@ var ts; return ts.visitEachChild(constructor, visitor, context); } var parameters = transformConstructorParameters(constructor); - var body = transformConstructorBody(node, constructor, hasExtendsClause, parameters); + var body = transformConstructorBody(node, constructor, hasExtendsClause); // constructor(${parameters}) { // ${body} // } @@ -43324,9 +43671,8 @@ var ts; * @param node The current class. * @param constructor The current class constructor. * @param hasExtendsClause A value indicating whether the class has an extends clause. - * @param parameters The transformed parameters for the constructor. */ - function transformConstructorBody(node, constructor, hasExtendsClause, parameters) { + function transformConstructorBody(node, constructor, hasExtendsClause) { var statements = []; var indexOfFirstStatement = 0; // The body of a constructor is a new lexical environment @@ -43367,7 +43713,7 @@ var ts; // } // var properties = getInitializedProperties(node, /*isStatic*/ false); - addInitializedPropertyStatements(statements, node, properties, ts.createThis()); + addInitializedPropertyStatements(statements, properties, ts.createThis()); if (constructor) { // The class already had a constructor, so we should add the existing statements, skipping the initial super call. ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement)); @@ -43394,7 +43740,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 202 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 203 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -43467,21 +43813,20 @@ var ts; * @param isStatic A value indicating whether the member should be a static or instance member. */ function isInitializedProperty(member, isStatic) { - return member.kind === 145 /* PropertyDeclaration */ + return member.kind === 146 /* PropertyDeclaration */ && isStatic === ts.hasModifier(member, 32 /* Static */) && member.initializer !== undefined; } /** * Generates assignment statements for property initializers. * - * @param node The class node. * @param properties An array of property declarations to transform. * @param receiver The receiver on which each property should be assigned. */ - function addInitializedPropertyStatements(statements, node, properties, receiver) { + function addInitializedPropertyStatements(statements, properties, receiver) { for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) { var property = properties_7[_i]; - var statement = ts.createStatement(transformInitializedProperty(node, property, receiver)); + var statement = ts.createStatement(transformInitializedProperty(property, receiver)); ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property)); ts.setCommentRange(statement, property); statements.push(statement); @@ -43490,15 +43835,14 @@ var ts; /** * Generates assignment expressions for property initializers. * - * @param node The class node. * @param properties An array of property declarations to transform. * @param receiver The receiver on which each property should be assigned. */ - function generateInitializedPropertyExpressions(node, properties, receiver) { + function generateInitializedPropertyExpressions(properties, receiver) { var expressions = []; for (var _i = 0, properties_8 = properties; _i < properties_8.length; _i++) { var property = properties_8[_i]; - var expression = transformInitializedProperty(node, property, receiver); + var expression = transformInitializedProperty(property, receiver); expression.startsOnNewLine = true; ts.setSourceMapRange(expression, ts.moveRangePastModifiers(property)); ts.setCommentRange(expression, property); @@ -43509,11 +43853,10 @@ var ts; /** * Transforms a property initializer into an assignment statement. * - * @param node The class containing the property. * @param property The property declaration. * @param receiver The object receiving the property assignment. */ - function transformInitializedProperty(node, property, receiver) { + function transformInitializedProperty(property, receiver) { var propertyName = visitPropertyNameOfClassElement(property); var initializer = ts.visitNode(property.initializer, visitor, ts.isExpression); var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, /*location*/ propertyName); @@ -43605,12 +43948,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 147 /* MethodDeclaration */: + case 148 /* MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -43762,7 +44105,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ true); var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 145 /* PropertyDeclaration */ + ? member.kind === 146 /* PropertyDeclaration */ ? ts.createVoidZero() : ts.createNull() : undefined; @@ -43895,10 +44238,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 147 /* MethodDeclaration */ - || kind === 149 /* GetAccessor */ - || kind === 150 /* SetAccessor */ - || kind === 145 /* PropertyDeclaration */; + return kind === 148 /* MethodDeclaration */ + || kind === 150 /* GetAccessor */ + || kind === 151 /* SetAccessor */ + || kind === 146 /* PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -43908,7 +44251,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 147 /* MethodDeclaration */; + return node.kind === 148 /* MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -43919,11 +44262,11 @@ var ts; */ function shouldAddParamTypesMetadata(node) { var kind = node.kind; - return kind === 221 /* ClassDeclaration */ - || kind === 192 /* ClassExpression */ - || kind === 147 /* MethodDeclaration */ - || kind === 149 /* GetAccessor */ - || kind === 150 /* SetAccessor */; + return kind === 222 /* ClassDeclaration */ + || kind === 193 /* ClassExpression */ + || kind === 148 /* MethodDeclaration */ + || kind === 150 /* GetAccessor */ + || kind === 151 /* SetAccessor */; } /** * Serializes the type of a node for use with decorator type metadata. @@ -43932,15 +44275,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 145 /* PropertyDeclaration */: - case 142 /* Parameter */: - case 149 /* GetAccessor */: + case 146 /* PropertyDeclaration */: + case 143 /* Parameter */: + case 150 /* GetAccessor */: return serializeTypeNode(node.type); - case 150 /* SetAccessor */: + case 151 /* SetAccessor */: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - case 147 /* MethodDeclaration */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 148 /* MethodDeclaration */: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -43953,10 +44296,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 160 /* ArrayType */) { + if (node && node.kind === 161 /* ArrayType */) { return node.elementType; } - else if (node && node.kind === 155 /* TypeReference */) { + else if (node && node.kind === 156 /* TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -44030,45 +44373,45 @@ var ts; return ts.createIdentifier("Object"); } switch (node.kind) { - case 103 /* VoidKeyword */: + case 104 /* VoidKeyword */: return ts.createVoidZero(); - case 164 /* ParenthesizedType */: + case 165 /* ParenthesizedType */: return serializeTypeNode(node.type); - case 156 /* FunctionType */: - case 157 /* ConstructorType */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: return ts.createIdentifier("Function"); - case 160 /* ArrayType */: - case 161 /* TupleType */: + case 161 /* ArrayType */: + case 162 /* TupleType */: return ts.createIdentifier("Array"); - case 154 /* TypePredicate */: - case 120 /* BooleanKeyword */: + case 155 /* TypePredicate */: + case 121 /* BooleanKeyword */: return ts.createIdentifier("Boolean"); - case 132 /* StringKeyword */: + case 133 /* StringKeyword */: return ts.createIdentifier("String"); - case 166 /* LiteralType */: + case 167 /* LiteralType */: switch (node.literal.kind) { case 9 /* StringLiteral */: return ts.createIdentifier("String"); case 8 /* NumericLiteral */: return ts.createIdentifier("Number"); - case 99 /* TrueKeyword */: - case 84 /* FalseKeyword */: + case 100 /* TrueKeyword */: + case 85 /* FalseKeyword */: return ts.createIdentifier("Boolean"); default: ts.Debug.failBadSyntaxKind(node.literal); break; } break; - case 130 /* NumberKeyword */: + case 131 /* NumberKeyword */: return ts.createIdentifier("Number"); - case 133 /* SymbolKeyword */: - return languageVersion < 2 /* ES6 */ + case 134 /* SymbolKeyword */: + return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 155 /* TypeReference */: + case 156 /* TypeReference */: return serializeTypeReferenceNode(node); - case 163 /* IntersectionType */: - case 162 /* UnionType */: + case 164 /* IntersectionType */: + case 163 /* UnionType */: { var unionOrIntersection = node; var serializedUnion = void 0; @@ -44076,7 +44419,7 @@ var ts; var typeNode = _a[_i]; var serializedIndividual = serializeTypeNode(typeNode); // Non identifier - if (serializedIndividual.kind !== 69 /* Identifier */) { + if (serializedIndividual.kind !== 70 /* Identifier */) { serializedUnion = undefined; break; } @@ -44097,10 +44440,10 @@ var ts; } } // Fallthrough - case 158 /* TypeQuery */: - case 159 /* TypeLiteral */: - case 117 /* AnyKeyword */: - case 165 /* ThisType */: + case 159 /* TypeQuery */: + case 160 /* TypeLiteral */: + case 118 /* AnyKeyword */: + case 166 /* ThisType */: break; default: ts.Debug.failBadSyntaxKind(node); @@ -44133,7 +44476,7 @@ var ts; case ts.TypeReferenceSerializationKind.ArrayLikeType: return ts.createIdentifier("Array"); case ts.TypeReferenceSerializationKind.ESSymbolType: - return languageVersion < 2 /* ES6 */ + return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); case ts.TypeReferenceSerializationKind.TypeWithCallSignature: @@ -44154,7 +44497,7 @@ var ts; */ function serializeEntityNameAsExpression(node, useFallback) { switch (node.kind) { - case 69 /* Identifier */: + case 70 /* Identifier */: // Create a clone of the name with a new parent, and treat it as if it were // a source tree node for the purposes of the checker. var name_27 = ts.getMutableClone(node); @@ -44165,7 +44508,7 @@ var ts; return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_27), ts.createLiteral("undefined")), name_27); } return name_27; - case 139 /* QualifiedName */: + case 140 /* QualifiedName */: return serializeQualifiedNameAsExpression(node, useFallback); } } @@ -44178,7 +44521,7 @@ var ts; */ function serializeQualifiedNameAsExpression(node, useFallback) { var left; - if (node.left.kind === 69 /* Identifier */) { + if (node.left.kind === 70 /* Identifier */) { left = serializeEntityNameAsExpression(node.left, useFallback); } else if (useFallback) { @@ -44195,7 +44538,7 @@ var ts; * available. */ function getGlobalSymbolNameWithFallback() { - return ts.createConditional(ts.createStrictEquality(ts.createTypeOf(ts.createIdentifier("Symbol")), ts.createLiteral("function")), ts.createToken(53 /* QuestionToken */), ts.createIdentifier("Symbol"), ts.createToken(54 /* ColonToken */), ts.createIdentifier("Object")); + return ts.createConditional(ts.createStrictEquality(ts.createTypeOf(ts.createIdentifier("Symbol")), ts.createLiteral("function")), ts.createToken(54 /* QuestionToken */), ts.createIdentifier("Symbol"), ts.createToken(55 /* ColonToken */), ts.createIdentifier("Object")); } /** * Gets an expression that represents a property name. For a computed property, a @@ -44249,9 +44592,9 @@ var ts; * @param node The HeritageClause to transform. */ function visitHeritageClause(node) { - if (node.token === 83 /* ExtendsKeyword */) { + if (node.token === 84 /* ExtendsKeyword */) { var types = ts.visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments, 0, 1); - return ts.createHeritageClause(83 /* ExtendsKeyword */, types, node); + return ts.createHeritageClause(84 /* ExtendsKeyword */, types, node); } return undefined; } @@ -44277,12 +44620,18 @@ var ts; function shouldEmitFunctionLikeDeclaration(node) { return !ts.nodeIsMissing(node.body); } + function visitConstructor(node) { + if (!shouldEmitFunctionLikeDeclaration(node)) { + return undefined; + } + return ts.visitEachChild(node, visitor, context); + } /** * Visits a method declaration of a class. * * This function will be called when one of the following conditions are met: * - The node is an overload - * - The node is marked as abstract, async, public, private, protected, or readonly + * - The node is marked as abstract, public, private, protected, or readonly * - The node has both a decorator and a computed property name * * @param node The method node. @@ -44364,8 +44713,8 @@ var ts; * * This function will be called when one of the following conditions are met: * - The node is an overload - * - The node is marked async * - The node is exported from a TypeScript namespace + * - The node has decorators * * @param node The function node. */ @@ -44390,7 +44739,7 @@ var ts; * Visits a function expression node. * * This function will be called when one of the following conditions are met: - * - The node is marked async + * - The node has type annotations * * @param node The function expression node. */ @@ -44398,7 +44747,7 @@ var ts; if (ts.nodeIsMissing(node.body)) { return ts.createOmittedExpression(); } - var func = ts.createFunctionExpression(node.asteriskToken, node.name, + var func = ts.createFunctionExpression(ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), /*type*/ undefined, transformFunctionBody(node), /*location*/ node); @@ -44408,11 +44757,10 @@ var ts; /** * @remarks * This function will be called when one of the following conditions are met: - * - The node is marked async + * - The node has type annotations */ function visitArrowFunction(node) { - var func = ts.createArrowFunction( - /*modifiers*/ undefined, + var func = ts.createArrowFunction(ts.visitNodes(node.modifiers, visitor, ts.isModifier), /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), /*type*/ undefined, node.equalsGreaterThanToken, transformConciseBody(node), /*location*/ node); @@ -44420,26 +44768,23 @@ var ts; return func; } function transformFunctionBody(node) { - if (ts.isAsyncFunctionLike(node)) { - return transformAsyncFunctionBody(node); - } return transformFunctionBodyWorker(node.body); } function transformFunctionBodyWorker(body, start) { if (start === void 0) { start = 0; } var savedCurrentScope = currentScope; + var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName; currentScope = body; + currentScopeFirstDeclarationsOfName = ts.createMap(); startLexicalEnvironment(); var statements = ts.visitNodes(body.statements, visitor, ts.isStatement, start); var visited = ts.updateBlock(body, statements); var declarations = endLexicalEnvironment(); currentScope = savedCurrentScope; + currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; return ts.mergeFunctionBodyLexicalEnvironment(visited, declarations); } function transformConciseBody(node) { - if (ts.isAsyncFunctionLike(node)) { - return transformAsyncFunctionBody(node); - } return transformConciseBodyWorker(node.body, /*forceBlockFunctionBody*/ false); } function transformConciseBodyWorker(body, forceBlockFunctionBody) { @@ -44461,49 +44806,6 @@ var ts; } } } - function getPromiseConstructor(type) { - var typeName = ts.getEntityNameFromTypeNode(type); - if (typeName && ts.isEntityName(typeName)) { - var serializationKind = resolver.getTypeReferenceSerializationKind(typeName); - if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue - || serializationKind === ts.TypeReferenceSerializationKind.Unknown) { - return typeName; - } - } - return undefined; - } - function transformAsyncFunctionBody(node) { - var promiseConstructor = languageVersion < 2 /* ES6 */ ? getPromiseConstructor(node.type) : undefined; - var isArrowFunction = node.kind === 180 /* ArrowFunction */; - var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* CaptureArguments */) !== 0; - // An async function is emit as an outer function that calls an inner - // generator function. To preserve lexical bindings, we pass the current - // `this` and `arguments` objects to `__awaiter`. The generator function - // passed to `__awaiter` is executed inside of the callback to the - // promise constructor. - if (!isArrowFunction) { - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.body.statements, /*ensureUseStrict*/ false, visitor); - statements.push(ts.createReturn(ts.createAwaiterHelper(currentSourceFileExternalHelpersModuleName, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body, statementOffset)))); - var block = ts.createBlock(statements, /*location*/ node.body, /*multiLine*/ true); - // Minor optimization, emit `_super` helper to capture `super` access in an arrow. - // This step isn't needed if we eventually transform this to ES5. - if (languageVersion >= 2 /* ES6 */) { - if (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) { - enableSubstitutionForAsyncMethodsWithSuper(); - ts.setEmitFlags(block, 8 /* EmitAdvancedSuperHelper */); - } - else if (resolver.getNodeCheckFlags(node) & 2048 /* AsyncMethodWithSuper */) { - enableSubstitutionForAsyncMethodsWithSuper(); - ts.setEmitFlags(block, 4 /* EmitSuperHelper */); - } - } - return block; - } - else { - return ts.createAwaiterHelper(currentSourceFileExternalHelpersModuleName, hasLexicalArguments, promiseConstructor, transformConciseBodyWorker(node.body, /*forceBlockFunctionBody*/ true)); - } - } /** * Visits a parameter declaration node. * @@ -44555,24 +44857,16 @@ var ts; function transformInitializedVariable(node) { var name = node.name; if (ts.isBindingPattern(name)) { - return ts.flattenVariableDestructuringToExpression(context, node, hoistVariableDeclaration, getNamespaceMemberNameWithSourceMapsAndWithoutComments, visitor); + return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, getNamespaceMemberNameWithSourceMapsAndWithoutComments, visitor); } else { return ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(name), ts.visitNode(node.initializer, visitor, ts.isExpression), /*location*/ node); } } - /** - * Visits an await expression. - * - * This function will be called any time a TypeScript await expression is encountered. - * - * @param node The await expression node. - */ - function visitAwaitExpression(node) { - return ts.setOriginalNode(ts.createYield( - /*asteriskToken*/ undefined, ts.visitNode(node.expression, visitor, ts.isExpression), - /*location*/ node), node); + function visitVariableDeclaration(node) { + return ts.updateVariableDeclaration(node, ts.visitNode(node.name, visitor, ts.isBindingName), + /*type*/ undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)); } /** * Visits a parenthesized expression that contains either a type assertion or an `as` @@ -44611,6 +44905,14 @@ var ts; var expression = ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression); return ts.createPartiallyEmittedExpression(expression, node); } + function visitCallExpression(node) { + return ts.updateCall(node, ts.visitNode(node.expression, visitor, ts.isExpression), + /*typeArguments*/ undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression)); + } + function visitNewExpression(node) { + return ts.updateNew(node, ts.visitNode(node.expression, visitor, ts.isExpression), + /*typeArguments*/ undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression)); + } /** * Determines whether to emit an enum declaration. * @@ -44673,6 +44975,7 @@ var ts; // ... // })(x || (x = {})); var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression( + /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, [ts.createParameter(parameterName)], @@ -44748,7 +45051,7 @@ var ts; } function isES6ExportedDeclaration(node) { return isExternalModuleExport(node) - && moduleKind === ts.ModuleKind.ES6; + && moduleKind === ts.ModuleKind.ES2015; } /** * Records that a declaration was emitted in the current scope, if it was the first @@ -44796,7 +45099,7 @@ var ts; ]); ts.setOriginalNode(statement, /*original*/ node); // Adjust the source map emit to match the old emitter. - if (node.kind === 224 /* EnumDeclaration */) { + if (node.kind === 225 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -44871,6 +45174,7 @@ var ts; // x_1.y = ...; // })(x || (x = {})); var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression( + /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, [ts.createParameter(parameterName)], @@ -44899,7 +45203,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 226 /* ModuleBlock */) { + if (body.kind === 227 /* ModuleBlock */) { ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); statementsLocation = body.statements; blockLocation = body; @@ -44945,17 +45249,127 @@ var ts; // })(hi = hello.hi || (hello.hi = {})); // })(hello || (hello = {})); // We only want to emit comment on the namespace which contains block body itself, not the containing namespaces. - if (body.kind !== 226 /* ModuleBlock */) { + if (body.kind !== 227 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 49152 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 225 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 226 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } } + /** + * Visits an import declaration, eliding it if it is not referenced. + * + * @param node The import declaration node. + */ + function visitImportDeclaration(node) { + if (!node.importClause) { + // Do not elide a side-effect only import declaration. + // import "foo"; + return node; + } + // Elide the declaration if the import clause was elided. + var importClause = ts.visitNode(node.importClause, visitImportClause, ts.isImportClause, /*optional*/ true); + return importClause + ? ts.updateImportDeclaration(node, + /*decorators*/ undefined, + /*modifiers*/ undefined, importClause, node.moduleSpecifier) + : undefined; + } + /** + * Visits an import clause, eliding it if it is not referenced. + * + * @param node The import clause node. + */ + function visitImportClause(node) { + // Elide the import clause if we elide both its name and its named bindings. + var name = resolver.isReferencedAliasDeclaration(node) ? node.name : undefined; + var namedBindings = ts.visitNode(node.namedBindings, visitNamedImportBindings, ts.isNamedImportBindings, /*optional*/ true); + return (name || namedBindings) ? ts.updateImportClause(node, name, namedBindings) : undefined; + } + /** + * Visits named import bindings, eliding it if it is not referenced. + * + * @param node The named import bindings node. + */ + function visitNamedImportBindings(node) { + if (node.kind === 233 /* NamespaceImport */) { + // Elide a namespace import if it is not referenced. + return resolver.isReferencedAliasDeclaration(node) ? node : undefined; + } + else { + // Elide named imports if all of its import specifiers are elided. + var elements = ts.visitNodes(node.elements, visitImportSpecifier, ts.isImportSpecifier); + return ts.some(elements) ? ts.updateNamedImports(node, elements) : undefined; + } + } + /** + * Visits an import specifier, eliding it if it is not referenced. + * + * @param node The import specifier node. + */ + function visitImportSpecifier(node) { + // Elide an import specifier if it is not referenced. + return resolver.isReferencedAliasDeclaration(node) ? node : undefined; + } + /** + * Visits an export assignment, eliding it if it does not contain a clause that resolves + * to a value. + * + * @param node The export assignment node. + */ + function visitExportAssignment(node) { + // Elide the export assignment if it does not reference a value. + return resolver.isValueAliasDeclaration(node) + ? ts.visitEachChild(node, visitor, context) + : undefined; + } + /** + * Visits an export declaration, eliding it if it does not contain a clause that resolves + * to a value. + * + * @param node The export declaration node. + */ + function visitExportDeclaration(node) { + if (!node.exportClause) { + // Elide a star export if the module it references does not export a value. + return resolver.moduleExportsSomeValue(node.moduleSpecifier) ? node : undefined; + } + if (!resolver.isValueAliasDeclaration(node)) { + // Elide the export declaration if it does not export a value. + return undefined; + } + // Elide the export declaration if all of its named exports are elided. + var exportClause = ts.visitNode(node.exportClause, visitNamedExports, ts.isNamedExports, /*optional*/ true); + return exportClause + ? ts.updateExportDeclaration(node, + /*decorators*/ undefined, + /*modifiers*/ undefined, exportClause, node.moduleSpecifier) + : undefined; + } + /** + * Visits named exports, eliding it if it does not contain an export specifier that + * resolves to a value. + * + * @param node The named exports node. + */ + function visitNamedExports(node) { + // Elide the named exports if all of its export specifiers were elided. + var elements = ts.visitNodes(node.elements, visitExportSpecifier, ts.isExportSpecifier); + return ts.some(elements) ? ts.updateNamedExports(node, elements) : undefined; + } + /** + * Visits an export specifier, eliding it if it does not resolve to a value. + * + * @param node The export specifier node. + */ + function visitExportSpecifier(node) { + // Elide an export specifier if it does not reference a value. + return resolver.isValueAliasDeclaration(node) ? node : undefined; + } /** * Determines whether to emit an import equals declaration. * @@ -44976,7 +45390,10 @@ var ts; */ function visitImportEqualsDeclaration(node) { if (ts.isExternalModuleImportEqualsDeclaration(node)) { - return ts.visitEachChild(node, visitor, context); + // Elide external module `import=` if it is not referenced. + return resolver.isReferencedAliasDeclaration(node) + ? ts.visitEachChild(node, visitor, context) + : undefined; } if (!shouldEmitImportEqualsDeclaration(node)) { return undefined; @@ -45152,23 +45569,7 @@ var ts; function enableSubstitutionForNonQualifiedEnumMembers() { if ((enabledSubstitutions & 8 /* NonQualifiedEnumMembers */) === 0) { enabledSubstitutions |= 8 /* NonQualifiedEnumMembers */; - context.enableSubstitution(69 /* Identifier */); - } - } - function enableSubstitutionForAsyncMethodsWithSuper() { - if ((enabledSubstitutions & 4 /* AsyncMethodsWithSuper */) === 0) { - enabledSubstitutions |= 4 /* AsyncMethodsWithSuper */; - // We need to enable substitutions for call, property access, and element access - // if we need to rewrite super calls. - context.enableSubstitution(174 /* CallExpression */); - context.enableSubstitution(172 /* PropertyAccessExpression */); - context.enableSubstitution(173 /* ElementAccessExpression */); - // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(221 /* ClassDeclaration */); - context.enableEmitNotification(147 /* MethodDeclaration */); - context.enableEmitNotification(149 /* GetAccessor */); - context.enableEmitNotification(150 /* SetAccessor */); - context.enableEmitNotification(148 /* Constructor */); + context.enableSubstitution(70 /* Identifier */); } } function enableSubstitutionForClassAliases() { @@ -45176,7 +45577,7 @@ var ts; enabledSubstitutions |= 1 /* ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(69 /* Identifier */); + context.enableSubstitution(70 /* Identifier */); // Keep track of class aliases. classAliases = ts.createMap(); } @@ -45186,25 +45587,17 @@ var ts; enabledSubstitutions |= 2 /* NamespaceExports */; // We need to enable substitutions for identifiers and shorthand property assignments. This allows us to // substitute the names of exported members of a namespace. - context.enableSubstitution(69 /* Identifier */); + context.enableSubstitution(70 /* Identifier */); context.enableSubstitution(254 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(225 /* ModuleDeclaration */); + context.enableEmitNotification(226 /* ModuleDeclaration */); } } - function isSuperContainer(node) { - var kind = node.kind; - return kind === 221 /* ClassDeclaration */ - || kind === 148 /* Constructor */ - || kind === 147 /* MethodDeclaration */ - || kind === 149 /* GetAccessor */ - || kind === 150 /* SetAccessor */; - } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 225 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 226 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 224 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 225 /* EnumDeclaration */; } /** * Hook for node emit. @@ -45214,12 +45607,6 @@ var ts; */ function onEmitNode(emitContext, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; - var savedCurrentSuperContainer = currentSuperContainer; - // If we need to support substitutions for `super` in an async method, - // we should track it here. - if (enabledSubstitutions & 4 /* AsyncMethodsWithSuper */ && isSuperContainer(node)) { - currentSuperContainer = node; - } if (enabledSubstitutions & 2 /* NamespaceExports */ && isTransformedModuleDeclaration(node)) { applicableSubstitutions |= 2 /* NamespaceExports */; } @@ -45228,7 +45615,6 @@ var ts; } previousOnEmitNode(emitContext, node, emitCallback); applicableSubstitutions = savedApplicableSubstitutions; - currentSuperContainer = savedCurrentSuperContainer; } /** * Hooks node substitutions. @@ -45265,17 +45651,12 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 69 /* Identifier */: + case 70 /* Identifier */: return substituteExpressionIdentifier(node); - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 173 /* ElementAccessExpression */: + case 174 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 174 /* CallExpression */: - if (enabledSubstitutions & 4 /* AsyncMethodsWithSuper */) { - return substituteCallExpression(node); - } - break; } return node; } @@ -45313,8 +45694,8 @@ var ts; // an identifier that is exported from a merged namespace. var container = resolver.getReferencedExportContainer(node, /*prefixLocals*/ false); if (container) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 225 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 224 /* EnumDeclaration */); + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 226 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 225 /* EnumDeclaration */); if (substitute) { return ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node, /*location*/ node); } @@ -45322,38 +45703,10 @@ var ts; } return undefined; } - function substituteCallExpression(node) { - var expression = node.expression; - if (ts.isSuperProperty(expression)) { - var flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - var argumentExpression = ts.isPropertyAccessExpression(expression) - ? substitutePropertyAccessExpression(expression) - : substituteElementAccessExpression(expression); - return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), - /*typeArguments*/ undefined, [ - ts.createThis() - ].concat(node.arguments)); - } - } - return node; - } function substitutePropertyAccessExpression(node) { - if (enabledSubstitutions & 4 /* AsyncMethodsWithSuper */ && node.expression.kind === 95 /* SuperKeyword */) { - var flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - return createSuperAccessInAsyncMethod(ts.createLiteral(node.name.text), flags, node); - } - } return substituteConstantValue(node); } function substituteElementAccessExpression(node) { - if (enabledSubstitutions & 4 /* AsyncMethodsWithSuper */ && node.expression.kind === 95 /* SuperKeyword */) { - var flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - return createSuperAccessInAsyncMethod(node.argumentExpression, flags, node); - } - } return substituteConstantValue(node); } function substituteConstantValue(node) { @@ -45381,2042 +45734,9 @@ var ts; ? resolver.getConstantValue(node) : undefined; } - function createSuperAccessInAsyncMethod(argumentExpression, flags, location) { - if (flags & 4096 /* AsyncMethodWithSuperBinding */) { - return ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), - /*typeArguments*/ undefined, [argumentExpression]), "value", location); - } - else { - return ts.createCall(ts.createIdentifier("_super"), - /*typeArguments*/ undefined, [argumentExpression], location); - } - } - function getSuperContainerAsyncMethodFlags() { - return currentSuperContainer !== undefined - && resolver.getNodeCheckFlags(currentSuperContainer) & (2048 /* AsyncMethodWithSuper */ | 4096 /* AsyncMethodWithSuperBinding */); - } } ts.transformTypeScript = transformTypeScript; })(ts || (ts = {})); -/// -/// -/*@internal*/ -var ts; -(function (ts) { - function transformES6Module(context) { - var compilerOptions = context.getCompilerOptions(); - var resolver = context.getEmitResolver(); - var currentSourceFile; - return transformSourceFile; - function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { - return node; - } - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - currentSourceFile = node; - return ts.visitEachChild(node, visitor, context); - } - return node; - } - function visitor(node) { - switch (node.kind) { - case 230 /* ImportDeclaration */: - return visitImportDeclaration(node); - case 229 /* ImportEqualsDeclaration */: - return visitImportEqualsDeclaration(node); - case 231 /* ImportClause */: - return visitImportClause(node); - case 233 /* NamedImports */: - case 232 /* NamespaceImport */: - return visitNamedBindings(node); - case 234 /* ImportSpecifier */: - return visitImportSpecifier(node); - case 235 /* ExportAssignment */: - return visitExportAssignment(node); - case 236 /* ExportDeclaration */: - return visitExportDeclaration(node); - case 237 /* NamedExports */: - return visitNamedExports(node); - case 238 /* ExportSpecifier */: - return visitExportSpecifier(node); - } - return node; - } - function visitExportAssignment(node) { - if (node.isExportEquals) { - return undefined; // do not emit export equals for ES6 - } - var original = ts.getOriginalNode(node); - return ts.nodeIsSynthesized(original) || resolver.isValueAliasDeclaration(original) ? node : undefined; - } - function visitExportDeclaration(node) { - if (!node.exportClause) { - return resolver.moduleExportsSomeValue(node.moduleSpecifier) ? node : undefined; - } - if (!resolver.isValueAliasDeclaration(node)) { - return undefined; - } - var newExportClause = ts.visitNode(node.exportClause, visitor, ts.isNamedExports, /*optional*/ true); - if (node.exportClause === newExportClause) { - return node; - } - return newExportClause - ? ts.createExportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, newExportClause, node.moduleSpecifier) - : undefined; - } - function visitNamedExports(node) { - var newExports = ts.visitNodes(node.elements, visitor, ts.isExportSpecifier); - if (node.elements === newExports) { - return node; - } - return newExports.length ? ts.createNamedExports(newExports) : undefined; - } - function visitExportSpecifier(node) { - return resolver.isValueAliasDeclaration(node) ? node : undefined; - } - function visitImportEqualsDeclaration(node) { - return !ts.isExternalModuleImportEqualsDeclaration(node) || resolver.isReferencedAliasDeclaration(node) ? node : undefined; - } - function visitImportDeclaration(node) { - if (node.importClause) { - var newImportClause = ts.visitNode(node.importClause, visitor, ts.isImportClause); - if (!newImportClause.name && !newImportClause.namedBindings) { - return undefined; - } - else if (newImportClause !== node.importClause) { - return ts.createImportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, newImportClause, node.moduleSpecifier); - } - } - return node; - } - function visitImportClause(node) { - var newDefaultImport = node.name; - if (!resolver.isReferencedAliasDeclaration(node)) { - newDefaultImport = undefined; - } - var newNamedBindings = ts.visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, /*optional*/ true); - return newDefaultImport !== node.name || newNamedBindings !== node.namedBindings - ? ts.createImportClause(newDefaultImport, newNamedBindings) - : node; - } - function visitNamedBindings(node) { - if (node.kind === 232 /* NamespaceImport */) { - return resolver.isReferencedAliasDeclaration(node) ? node : undefined; - } - else { - var newNamedImportElements = ts.visitNodes(node.elements, visitor, ts.isImportSpecifier); - if (!newNamedImportElements || newNamedImportElements.length == 0) { - return undefined; - } - if (newNamedImportElements === node.elements) { - return node; - } - return ts.createNamedImports(newNamedImportElements); - } - } - function visitImportSpecifier(node) { - return resolver.isReferencedAliasDeclaration(node) ? node : undefined; - } - } - ts.transformES6Module = transformES6Module; -})(ts || (ts = {})); -/// -/// -/*@internal*/ -var ts; -(function (ts) { - function transformSystemModule(context) { - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration, hoistFunctionDeclaration = context.hoistFunctionDeclaration; - var compilerOptions = context.getCompilerOptions(); - var resolver = context.getEmitResolver(); - var host = context.getEmitHost(); - var languageVersion = ts.getEmitScriptTarget(compilerOptions); - var previousOnSubstituteNode = context.onSubstituteNode; - var previousOnEmitNode = context.onEmitNode; - context.onSubstituteNode = onSubstituteNode; - context.onEmitNode = onEmitNode; - context.enableSubstitution(69 /* Identifier */); - context.enableSubstitution(187 /* BinaryExpression */); - context.enableSubstitution(185 /* PrefixUnaryExpression */); - context.enableSubstitution(186 /* PostfixUnaryExpression */); - context.enableEmitNotification(256 /* SourceFile */); - var exportFunctionForFileMap = []; - var currentSourceFile; - var externalImports; - var exportSpecifiers; - var exportEquals; - var hasExportStarsToExportValues; - var exportFunctionForFile; - var contextObjectForFile; - var exportedLocalNames; - var exportedFunctionDeclarations; - var enclosingBlockScopedContainer; - var currentParent; - var currentNode; - return transformSourceFile; - function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { - return node; - } - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - currentSourceFile = node; - currentNode = node; - // Perform the transformation. - var updated = transformSystemModuleWorker(node); - ts.aggregateTransformFlags(updated); - currentSourceFile = undefined; - externalImports = undefined; - exportSpecifiers = undefined; - exportEquals = undefined; - hasExportStarsToExportValues = false; - exportFunctionForFile = undefined; - contextObjectForFile = undefined; - exportedLocalNames = undefined; - exportedFunctionDeclarations = undefined; - return updated; - } - return node; - } - function transformSystemModuleWorker(node) { - // System modules have the following shape: - // - // System.register(['dep-1', ... 'dep-n'], function(exports) {/* module body function */}) - // - // The parameter 'exports' here is a callback '(name: string, value: T) => T' that - // is used to publish exported values. 'exports' returns its 'value' argument so in - // most cases expressions that mutate exported values can be rewritten as: - // - // expr -> exports('name', expr) - // - // The only exception in this rule is postfix unary operators, - // see comment to 'substitutePostfixUnaryExpression' for more details - ts.Debug.assert(!exportFunctionForFile); - // Collect information about the external module and dependency groups. - (_a = ts.collectExternalModuleInfo(node, resolver), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); - // Make sure that the name of the 'exports' function does not conflict with - // existing identifiers. - exportFunctionForFile = ts.createUniqueName("exports"); - contextObjectForFile = ts.createUniqueName("context"); - exportFunctionForFileMap[ts.getOriginalNodeId(node)] = exportFunctionForFile; - var dependencyGroups = collectDependencyGroups(externalImports); - var statements = []; - // Add the body of the module. - addSystemModuleBody(statements, node, dependencyGroups); - var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); - var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, getNameOfDependencyGroup)); - var body = ts.createFunctionExpression( - /*asteriskToken*/ undefined, - /*name*/ undefined, - /*typeParameters*/ undefined, [ - ts.createParameter(exportFunctionForFile), - ts.createParameter(contextObjectForFile) - ], - /*type*/ undefined, ts.setEmitFlags(ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true), 1 /* EmitEmitHelpers */)); - // Write the call to `System.register` - // Clear the emit-helpers flag for later passes since we'll have already used it in the module body - // So the helper will be emit at the correct position instead of at the top of the source-file - return updateSourceFile(node, [ - ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), - /*typeArguments*/ undefined, moduleName - ? [moduleName, dependencies, body] - : [dependencies, body])) - ], /*nodeEmitFlags*/ ~1 /* EmitEmitHelpers */ & ts.getEmitFlags(node)); - var _a; - } - /** - * Adds the statements for the module body function for the source file. - * - * @param statements The output statements for the module body. - * @param node The source file for the module. - * @param statementOffset The offset at which to begin visiting the statements of the SourceFile. - */ - function addSystemModuleBody(statements, node, dependencyGroups) { - // Shape of the body in system modules: - // - // function (exports) { - // - // - // - // return { - // setters: [ - // - // ], - // execute: function() { - // - // } - // } - // - // } - // - // i.e: - // - // import {x} from 'file1' - // var y = 1; - // export function foo() { return y + x(); } - // console.log(y); - // - // Will be transformed to: - // - // function(exports) { - // var file_1; // local alias - // var y; - // function foo() { return y + file_1.x(); } - // exports("foo", foo); - // return { - // setters: [ - // function(v) { file_1 = v } - // ], - // execute(): function() { - // y = 1; - // console.log(y); - // } - // }; - // } - // We start a new lexical environment in this function body, but *not* in the - // body of the execute function. This allows us to emit temporary declarations - // only in the outer module body and not in the inner one. - startLexicalEnvironment(); - // Add any prologue directives. - var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, visitSourceElement); - // var __moduleName = context_1 && context_1.id; - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration("__moduleName", - /*type*/ undefined, ts.createLogicalAnd(contextObjectForFile, ts.createPropertyAccess(contextObjectForFile, "id"))) - ]))); - // Visit the statements of the source file, emitting any transformations into - // the `executeStatements` array. We do this *before* we fill the `setters` array - // as we both emit transformations as well as aggregate some data used when creating - // setters. This allows us to reduce the number of times we need to loop through the - // statements of the source file. - var executeStatements = ts.visitNodes(node.statements, visitSourceElement, ts.isStatement, statementOffset); - // We emit the lexical environment (hoisted variables and function declarations) - // early to align roughly with our previous emit output. - // Two key differences in this approach are: - // - Temporary variables will appear at the top rather than at the bottom of the file - // - Calls to the exporter for exported function declarations are grouped after - // the declarations. - ts.addRange(statements, endLexicalEnvironment()); - // Emit early exports for function declarations. - ts.addRange(statements, exportedFunctionDeclarations); - var exportStarFunction = addExportStarIfNeeded(statements); - statements.push(ts.createReturn(ts.setMultiLine(ts.createObjectLiteral([ - ts.createPropertyAssignment("setters", generateSetters(exportStarFunction, dependencyGroups)), - ts.createPropertyAssignment("execute", ts.createFunctionExpression( - /*asteriskToken*/ undefined, - /*name*/ undefined, - /*typeParameters*/ undefined, - /*parameters*/ [], - /*type*/ undefined, ts.createBlock(executeStatements, - /*location*/ undefined, - /*multiLine*/ true))) - ]), - /*multiLine*/ true))); - } - function addExportStarIfNeeded(statements) { - if (!hasExportStarsToExportValues) { - return; - } - // when resolving exports local exported entries/indirect exported entries in the module - // should always win over entries with similar names that were added via star exports - // to support this we store names of local/indirect exported entries in a set. - // this set is used to filter names brought by star expors. - // local names set should only be added if we have anything exported - if (!exportedLocalNames && ts.isEmpty(exportSpecifiers)) { - // no exported declarations (export var ...) or export specifiers (export {x}) - // check if we have any non star export declarations. - var hasExportDeclarationWithExportClause = false; - for (var _i = 0, externalImports_1 = externalImports; _i < externalImports_1.length; _i++) { - var externalImport = externalImports_1[_i]; - if (externalImport.kind === 236 /* ExportDeclaration */ && externalImport.exportClause) { - hasExportDeclarationWithExportClause = true; - break; - } - } - if (!hasExportDeclarationWithExportClause) { - // we still need to emit exportStar helper - return addExportStarFunction(statements, /*localNames*/ undefined); - } - } - var exportedNames = []; - if (exportedLocalNames) { - for (var _a = 0, exportedLocalNames_1 = exportedLocalNames; _a < exportedLocalNames_1.length; _a++) { - var exportedLocalName = exportedLocalNames_1[_a]; - // write name of exported declaration, i.e 'export var x...' - exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName.text), ts.createLiteral(true))); - } - } - for (var _b = 0, externalImports_2 = externalImports; _b < externalImports_2.length; _b++) { - var externalImport = externalImports_2[_b]; - if (externalImport.kind !== 236 /* ExportDeclaration */) { - continue; - } - var exportDecl = externalImport; - if (!exportDecl.exportClause) { - // export * from ... - continue; - } - for (var _c = 0, _d = exportDecl.exportClause.elements; _c < _d.length; _c++) { - var element = _d[_c]; - // write name of indirectly exported entry, i.e. 'export {x} from ...' - exportedNames.push(ts.createPropertyAssignment(ts.createLiteral((element.name || element.propertyName).text), ts.createLiteral(true))); - } - } - var exportedNamesStorageRef = ts.createUniqueName("exportedNames"); - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(exportedNamesStorageRef, - /*type*/ undefined, ts.createObjectLiteral(exportedNames, /*location*/ undefined, /*multiline*/ true)) - ]))); - return addExportStarFunction(statements, exportedNamesStorageRef); - } - /** - * Emits a setter callback for each dependency group. - * @param write The callback used to write each callback. - */ - function generateSetters(exportStarFunction, dependencyGroups) { - var setters = []; - for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { - var group = dependencyGroups_1[_i]; - // derive a unique name for parameter from the first named entry in the group - var localName = ts.forEach(group.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); - var parameterName = localName ? ts.getGeneratedNameForNode(localName) : ts.createUniqueName(""); - var statements = []; - for (var _a = 0, _b = group.externalImports; _a < _b.length; _a++) { - var entry = _b[_a]; - var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); - switch (entry.kind) { - case 230 /* ImportDeclaration */: - if (!entry.importClause) { - // 'import "..."' case - // module is imported only for side-effects, no emit required - break; - } - // fall-through - case 229 /* ImportEqualsDeclaration */: - ts.Debug.assert(importVariableName !== undefined); - // save import into the local - statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); - break; - case 236 /* ExportDeclaration */: - ts.Debug.assert(importVariableName !== undefined); - if (entry.exportClause) { - // export {a, b as c} from 'foo' - // - // emit as: - // - // exports_({ - // "a": _["a"], - // "c": _["b"] - // }); - var properties = []; - for (var _c = 0, _d = entry.exportClause.elements; _c < _d.length; _c++) { - var e = _d[_c]; - properties.push(ts.createPropertyAssignment(ts.createLiteral(e.name.text), ts.createElementAccess(parameterName, ts.createLiteral((e.propertyName || e.name).text)))); - } - statements.push(ts.createStatement(ts.createCall(exportFunctionForFile, - /*typeArguments*/ undefined, [ts.createObjectLiteral(properties, /*location*/ undefined, /*multiline*/ true)]))); - } - else { - // export * from 'foo' - // - // emit as: - // - // exportStar(foo_1_1); - statements.push(ts.createStatement(ts.createCall(exportStarFunction, - /*typeArguments*/ undefined, [parameterName]))); - } - break; - } - } - setters.push(ts.createFunctionExpression( - /*asteriskToken*/ undefined, - /*name*/ undefined, - /*typeParameters*/ undefined, [ts.createParameter(parameterName)], - /*type*/ undefined, ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true))); - } - return ts.createArrayLiteral(setters, /*location*/ undefined, /*multiLine*/ true); - } - function visitSourceElement(node) { - switch (node.kind) { - case 230 /* ImportDeclaration */: - return visitImportDeclaration(node); - case 229 /* ImportEqualsDeclaration */: - return visitImportEqualsDeclaration(node); - case 236 /* ExportDeclaration */: - return visitExportDeclaration(node); - case 235 /* ExportAssignment */: - return visitExportAssignment(node); - default: - return visitNestedNode(node); - } - } - function visitNestedNode(node) { - var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; - var savedCurrentParent = currentParent; - var savedCurrentNode = currentNode; - var currentGrandparent = currentParent; - currentParent = currentNode; - currentNode = node; - if (currentParent && ts.isBlockScope(currentParent, currentGrandparent)) { - enclosingBlockScopedContainer = currentParent; - } - var result = visitNestedNodeWorker(node); - enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; - currentParent = savedCurrentParent; - currentNode = savedCurrentNode; - return result; - } - function visitNestedNodeWorker(node) { - switch (node.kind) { - case 200 /* VariableStatement */: - return visitVariableStatement(node); - case 220 /* FunctionDeclaration */: - return visitFunctionDeclaration(node); - case 221 /* ClassDeclaration */: - return visitClassDeclaration(node); - case 206 /* ForStatement */: - return visitForStatement(node); - case 207 /* ForInStatement */: - return visitForInStatement(node); - case 208 /* ForOfStatement */: - return visitForOfStatement(node); - case 204 /* DoStatement */: - return visitDoStatement(node); - case 205 /* WhileStatement */: - return visitWhileStatement(node); - case 214 /* LabeledStatement */: - return visitLabeledStatement(node); - case 212 /* WithStatement */: - return visitWithStatement(node); - case 213 /* SwitchStatement */: - return visitSwitchStatement(node); - case 227 /* CaseBlock */: - return visitCaseBlock(node); - case 249 /* CaseClause */: - return visitCaseClause(node); - case 250 /* DefaultClause */: - return visitDefaultClause(node); - case 216 /* TryStatement */: - return visitTryStatement(node); - case 252 /* CatchClause */: - return visitCatchClause(node); - case 199 /* Block */: - return visitBlock(node); - case 202 /* ExpressionStatement */: - return visitExpressionStatement(node); - default: - return node; - } - } - function visitImportDeclaration(node) { - if (node.importClause && ts.contains(externalImports, node)) { - hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); - } - return undefined; - } - function visitImportEqualsDeclaration(node) { - if (ts.contains(externalImports, node)) { - hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); - } - // NOTE(rbuckton): Do we support export import = require('') in System? - return undefined; - } - function visitExportDeclaration(node) { - if (!node.moduleSpecifier) { - var statements = []; - ts.addRange(statements, ts.map(node.exportClause.elements, visitExportSpecifier)); - return statements; - } - return undefined; - } - function visitExportSpecifier(specifier) { - if (resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) - || resolver.isValueAliasDeclaration(specifier)) { - recordExportName(specifier.name); - return createExportStatement(specifier.name, specifier.propertyName || specifier.name); - } - return undefined; - } - function visitExportAssignment(node) { - if (!node.isExportEquals) { - if (ts.nodeIsSynthesized(node) || resolver.isValueAliasDeclaration(node)) { - return createExportStatement(ts.createLiteral("default"), node.expression); - } - } - return undefined; - } - /** - * Visits a variable statement, hoisting declared names to the top-level module body. - * Each declaration is rewritten into an assignment expression. - * - * @param node The variable statement to visit. - */ - function visitVariableStatement(node) { - // hoist only non-block scoped declarations or block scoped declarations parented by source file - var shouldHoist = ((ts.getCombinedNodeFlags(ts.getOriginalNode(node.declarationList)) & 3 /* BlockScoped */) == 0) || - enclosingBlockScopedContainer.kind === 256 /* SourceFile */; - if (!shouldHoist) { - return node; - } - var isExported = ts.hasModifier(node, 1 /* Export */); - var expressions = []; - for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { - var variable = _a[_i]; - var visited = transformVariable(variable, isExported); - if (visited) { - expressions.push(visited); - } - } - if (expressions.length) { - return ts.createStatement(ts.inlineExpressions(expressions), node); - } - return undefined; - } - /** - * Transforms a VariableDeclaration into one or more assignment expressions. - * - * @param node The VariableDeclaration to transform. - * @param isExported A value used to indicate whether the containing statement was exported. - */ - function transformVariable(node, isExported) { - // Hoist any bound names within the declaration. - hoistBindingElement(node, isExported); - if (!node.initializer) { - // If the variable has no initializer, ignore it. - return; - } - var name = node.name; - if (ts.isIdentifier(name)) { - // If the variable has an IdentifierName, write out an assignment expression in its place. - return ts.createAssignment(name, node.initializer); - } - else { - // If the variable has a BindingPattern, flatten the variable into multiple assignment expressions. - return ts.flattenVariableDestructuringToExpression(context, node, hoistVariableDeclaration); - } - } - /** - * Visits a FunctionDeclaration, hoisting it to the outer module body function. - * - * @param node The function declaration to visit. - */ - function visitFunctionDeclaration(node) { - if (ts.hasModifier(node, 1 /* Export */)) { - // If the function is exported, ensure it has a name and rewrite the function without any export flags. - var name_31 = node.name || ts.getGeneratedNameForNode(node); - var newNode = ts.createFunctionDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, node.asteriskToken, name_31, - /*typeParameters*/ undefined, node.parameters, - /*type*/ undefined, node.body, - /*location*/ node); - // Record a declaration export in the outer module body function. - recordExportedFunctionDeclaration(node); - if (!ts.hasModifier(node, 512 /* Default */)) { - recordExportName(name_31); - } - ts.setOriginalNode(newNode, node); - node = newNode; - } - // Hoist the function declaration to the outer module body function. - hoistFunctionDeclaration(node); - return undefined; - } - function visitExpressionStatement(node) { - var originalNode = ts.getOriginalNode(node); - if ((originalNode.kind === 225 /* ModuleDeclaration */ || originalNode.kind === 224 /* EnumDeclaration */) && ts.hasModifier(originalNode, 1 /* Export */)) { - var name_32 = getDeclarationName(originalNode); - // We only need to hoistVariableDeclaration for EnumDeclaration - // as ModuleDeclaration is already hoisted when the transformer call visitVariableStatement - // which then call transformsVariable for each declaration in declarationList - if (originalNode.kind === 224 /* EnumDeclaration */) { - hoistVariableDeclaration(name_32); - } - return [ - node, - createExportStatement(name_32, name_32) - ]; - } - return node; - } - /** - * Visits a ClassDeclaration, hoisting its name to the outer module body function. - * - * @param node The class declaration to visit. - */ - function visitClassDeclaration(node) { - // Hoist the name of the class declaration to the outer module body function. - var name = getDeclarationName(node); - hoistVariableDeclaration(name); - var statements = []; - // Rewrite the class declaration into an assignment of a class expression. - statements.push(ts.createStatement(ts.createAssignment(name, ts.createClassExpression( - /*modifiers*/ undefined, node.name, - /*typeParameters*/ undefined, node.heritageClauses, node.members, - /*location*/ node)), - /*location*/ node)); - // If the class was exported, write a declaration export to the inner module body function. - if (ts.hasModifier(node, 1 /* Export */)) { - if (!ts.hasModifier(node, 512 /* Default */)) { - recordExportName(name); - } - statements.push(createDeclarationExport(node)); - } - return statements; - } - function shouldHoistLoopInitializer(node) { - return ts.isVariableDeclarationList(node) && (ts.getCombinedNodeFlags(node) & 3 /* BlockScoped */) === 0; - } - /** - * Visits the body of a ForStatement to hoist declarations. - * - * @param node The statement to visit. - */ - function visitForStatement(node) { - var initializer = node.initializer; - if (shouldHoistLoopInitializer(initializer)) { - var expressions = []; - for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) { - var variable = _a[_i]; - var visited = transformVariable(variable, /*isExported*/ false); - if (visited) { - expressions.push(visited); - } - } - ; - return ts.createFor(expressions.length - ? ts.inlineExpressions(expressions) - : ts.createSynthesizedNode(193 /* OmittedExpression */), node.condition, node.incrementor, ts.visitNode(node.statement, visitNestedNode, ts.isStatement), - /*location*/ node); - } - else { - return ts.visitEachChild(node, visitNestedNode, context); - } - } - /** - * Transforms and hoists the declaration list of a ForInStatement or ForOfStatement into an expression. - * - * @param node The decalaration list to transform. - */ - function transformForBinding(node) { - var firstDeclaration = ts.firstOrUndefined(node.declarations); - hoistBindingElement(firstDeclaration, /*isExported*/ false); - var name = firstDeclaration.name; - return ts.isIdentifier(name) - ? name - : ts.flattenVariableDestructuringToExpression(context, firstDeclaration, hoistVariableDeclaration); - } - /** - * Visits the body of a ForInStatement to hoist declarations. - * - * @param node The statement to visit. - */ - function visitForInStatement(node) { - var initializer = node.initializer; - if (shouldHoistLoopInitializer(initializer)) { - var updated = ts.getMutableClone(node); - updated.initializer = transformForBinding(initializer); - updated.statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); - return updated; - } - else { - return ts.visitEachChild(node, visitNestedNode, context); - } - } - /** - * Visits the body of a ForOfStatement to hoist declarations. - * - * @param node The statement to visit. - */ - function visitForOfStatement(node) { - var initializer = node.initializer; - if (shouldHoistLoopInitializer(initializer)) { - var updated = ts.getMutableClone(node); - updated.initializer = transformForBinding(initializer); - updated.statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); - return updated; - } - else { - return ts.visitEachChild(node, visitNestedNode, context); - } - } - /** - * Visits the body of a DoStatement to hoist declarations. - * - * @param node The statement to visit. - */ - function visitDoStatement(node) { - var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); - if (statement !== node.statement) { - var updated = ts.getMutableClone(node); - updated.statement = statement; - return updated; - } - return node; - } - /** - * Visits the body of a WhileStatement to hoist declarations. - * - * @param node The statement to visit. - */ - function visitWhileStatement(node) { - var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); - if (statement !== node.statement) { - var updated = ts.getMutableClone(node); - updated.statement = statement; - return updated; - } - return node; - } - /** - * Visits the body of a LabeledStatement to hoist declarations. - * - * @param node The statement to visit. - */ - function visitLabeledStatement(node) { - var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); - if (statement !== node.statement) { - var updated = ts.getMutableClone(node); - updated.statement = statement; - return updated; - } - return node; - } - /** - * Visits the body of a WithStatement to hoist declarations. - * - * @param node The statement to visit. - */ - function visitWithStatement(node) { - var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); - if (statement !== node.statement) { - var updated = ts.getMutableClone(node); - updated.statement = statement; - return updated; - } - return node; - } - /** - * Visits the body of a SwitchStatement to hoist declarations. - * - * @param node The statement to visit. - */ - function visitSwitchStatement(node) { - var caseBlock = ts.visitNode(node.caseBlock, visitNestedNode, ts.isCaseBlock); - if (caseBlock !== node.caseBlock) { - var updated = ts.getMutableClone(node); - updated.caseBlock = caseBlock; - return updated; - } - return node; - } - /** - * Visits the body of a CaseBlock to hoist declarations. - * - * @param node The node to visit. - */ - function visitCaseBlock(node) { - var clauses = ts.visitNodes(node.clauses, visitNestedNode, ts.isCaseOrDefaultClause); - if (clauses !== node.clauses) { - var updated = ts.getMutableClone(node); - updated.clauses = clauses; - return updated; - } - return node; - } - /** - * Visits the body of a CaseClause to hoist declarations. - * - * @param node The clause to visit. - */ - function visitCaseClause(node) { - var statements = ts.visitNodes(node.statements, visitNestedNode, ts.isStatement); - if (statements !== node.statements) { - var updated = ts.getMutableClone(node); - updated.statements = statements; - return updated; - } - return node; - } - /** - * Visits the body of a DefaultClause to hoist declarations. - * - * @param node The clause to visit. - */ - function visitDefaultClause(node) { - return ts.visitEachChild(node, visitNestedNode, context); - } - /** - * Visits the body of a TryStatement to hoist declarations. - * - * @param node The statement to visit. - */ - function visitTryStatement(node) { - return ts.visitEachChild(node, visitNestedNode, context); - } - /** - * Visits the body of a CatchClause to hoist declarations. - * - * @param node The clause to visit. - */ - function visitCatchClause(node) { - var block = ts.visitNode(node.block, visitNestedNode, ts.isBlock); - if (block !== node.block) { - var updated = ts.getMutableClone(node); - updated.block = block; - return updated; - } - return node; - } - /** - * Visits the body of a Block to hoist declarations. - * - * @param node The block to visit. - */ - function visitBlock(node) { - return ts.visitEachChild(node, visitNestedNode, context); - } - // - // Substitutions - // - function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 256 /* SourceFile */) { - exportFunctionForFile = exportFunctionForFileMap[ts.getOriginalNodeId(node)]; - previousOnEmitNode(emitContext, node, emitCallback); - exportFunctionForFile = undefined; - } - else { - previousOnEmitNode(emitContext, node, emitCallback); - } - } - /** - * Hooks node substitutions. - * - * @param node The node to substitute. - * @param isExpression A value indicating whether the node is to be used in an expression - * position. - */ - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1 /* Expression */) { - return substituteExpression(node); - } - return node; - } - /** - * Substitute the expression, if necessary. - * - * @param node The node to substitute. - */ - function substituteExpression(node) { - switch (node.kind) { - case 69 /* Identifier */: - return substituteExpressionIdentifier(node); - case 187 /* BinaryExpression */: - return substituteBinaryExpression(node); - case 185 /* PrefixUnaryExpression */: - case 186 /* PostfixUnaryExpression */: - return substituteUnaryExpression(node); - } - return node; - } - /** - * Substitution for identifiers exported at the top level of a module. - */ - function substituteExpressionIdentifier(node) { - var importDeclaration = resolver.getReferencedImportDeclaration(node); - if (importDeclaration) { - var importBinding = createImportBinding(importDeclaration); - if (importBinding) { - return importBinding; - } - } - return node; - } - function substituteBinaryExpression(node) { - if (ts.isAssignmentOperator(node.operatorToken.kind)) { - return substituteAssignmentExpression(node); - } - return node; - } - function substituteAssignmentExpression(node) { - ts.setEmitFlags(node, 128 /* NoSubstitution */); - var left = node.left; - switch (left.kind) { - case 69 /* Identifier */: - var exportDeclaration = resolver.getReferencedExportContainer(left); - if (exportDeclaration) { - return createExportExpression(left, node); - } - break; - case 171 /* ObjectLiteralExpression */: - case 170 /* ArrayLiteralExpression */: - if (hasExportedReferenceInDestructuringPattern(left)) { - return substituteDestructuring(node); - } - break; - } - return node; - } - function isExportedBinding(name) { - var container = resolver.getReferencedExportContainer(name); - return container && container.kind === 256 /* SourceFile */; - } - function hasExportedReferenceInDestructuringPattern(node) { - switch (node.kind) { - case 69 /* Identifier */: - return isExportedBinding(node); - case 171 /* ObjectLiteralExpression */: - for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { - var property = _a[_i]; - if (hasExportedReferenceInObjectDestructuringElement(property)) { - return true; - } - } - break; - case 170 /* ArrayLiteralExpression */: - for (var _b = 0, _c = node.elements; _b < _c.length; _b++) { - var element = _c[_b]; - if (hasExportedReferenceInArrayDestructuringElement(element)) { - return true; - } - } - break; - } - return false; - } - function hasExportedReferenceInObjectDestructuringElement(node) { - if (ts.isShorthandPropertyAssignment(node)) { - return isExportedBinding(node.name); - } - else if (ts.isPropertyAssignment(node)) { - return hasExportedReferenceInDestructuringElement(node.initializer); - } - else { - return false; - } - } - function hasExportedReferenceInArrayDestructuringElement(node) { - if (ts.isSpreadElementExpression(node)) { - var expression = node.expression; - return ts.isIdentifier(expression) && isExportedBinding(expression); - } - else { - return hasExportedReferenceInDestructuringElement(node); - } - } - function hasExportedReferenceInDestructuringElement(node) { - if (ts.isBinaryExpression(node)) { - var left = node.left; - return node.operatorToken.kind === 56 /* EqualsToken */ - && isDestructuringPattern(left) - && hasExportedReferenceInDestructuringPattern(left); - } - else if (ts.isIdentifier(node)) { - return isExportedBinding(node); - } - else if (ts.isSpreadElementExpression(node)) { - var expression = node.expression; - return ts.isIdentifier(expression) && isExportedBinding(expression); - } - else if (isDestructuringPattern(node)) { - return hasExportedReferenceInDestructuringPattern(node); - } - else { - return false; - } - } - function isDestructuringPattern(node) { - var kind = node.kind; - return kind === 69 /* Identifier */ - || kind === 171 /* ObjectLiteralExpression */ - || kind === 170 /* ArrayLiteralExpression */; - } - function substituteDestructuring(node) { - return ts.flattenDestructuringAssignment(context, node, /*needsValue*/ true, hoistVariableDeclaration); - } - function substituteUnaryExpression(node) { - var operand = node.operand; - var operator = node.operator; - var substitute = ts.isIdentifier(operand) && - (node.kind === 186 /* PostfixUnaryExpression */ || - (node.kind === 185 /* PrefixUnaryExpression */ && (operator === 41 /* PlusPlusToken */ || operator === 42 /* MinusMinusToken */))); - if (substitute) { - var exportDeclaration = resolver.getReferencedExportContainer(operand); - if (exportDeclaration) { - var expr = ts.createPrefix(node.operator, operand, node); - ts.setEmitFlags(expr, 128 /* NoSubstitution */); - var call = createExportExpression(operand, expr); - if (node.kind === 185 /* PrefixUnaryExpression */) { - return call; - } - else { - // export function returns the value that was passes as the second argument - // however for postfix unary expressions result value should be the value before modification. - // emit 'x++' as '(export('x', ++x) - 1)' and 'x--' as '(export('x', --x) + 1)' - return operator === 41 /* PlusPlusToken */ - ? ts.createSubtract(call, ts.createLiteral(1)) - : ts.createAdd(call, ts.createLiteral(1)); - } - } - } - return node; - } - /** - * Gets a name to use for a DeclarationStatement. - * @param node The declaration statement. - */ - function getDeclarationName(node) { - return node.name ? ts.getSynthesizedClone(node.name) : ts.getGeneratedNameForNode(node); - } - function addExportStarFunction(statements, localNames) { - var exportStarFunction = ts.createUniqueName("exportStar"); - var m = ts.createIdentifier("m"); - var n = ts.createIdentifier("n"); - var exports = ts.createIdentifier("exports"); - var condition = ts.createStrictInequality(n, ts.createLiteral("default")); - if (localNames) { - condition = ts.createLogicalAnd(condition, ts.createLogicalNot(ts.createHasOwnProperty(localNames, n))); - } - statements.push(ts.createFunctionDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, - /*asteriskToken*/ undefined, exportStarFunction, - /*typeParameters*/ undefined, [ts.createParameter(m)], - /*type*/ undefined, ts.createBlock([ - ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(exports, - /*type*/ undefined, ts.createObjectLiteral([])) - ])), - ts.createForIn(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(n, /*type*/ undefined) - ]), m, ts.createBlock([ - ts.setEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 32 /* SingleLine */) - ])), - ts.createStatement(ts.createCall(exportFunctionForFile, - /*typeArguments*/ undefined, [exports])) - ], - /*location*/ undefined, - /*multiline*/ true))); - return exportStarFunction; - } - /** - * Creates a call to the current file's export function to export a value. - * @param name The bound name of the export. - * @param value The exported value. - */ - function createExportExpression(name, value) { - var exportName = ts.isIdentifier(name) ? ts.createLiteral(name.text) : name; - return ts.createCall(exportFunctionForFile, /*typeArguments*/ undefined, [exportName, value]); - } - /** - * Creates a call to the current file's export function to export a value. - * @param name The bound name of the export. - * @param value The exported value. - */ - function createExportStatement(name, value) { - return ts.createStatement(createExportExpression(name, value)); - } - /** - * Creates a call to the current file's export function to export a declaration. - * @param node The declaration to export. - */ - function createDeclarationExport(node) { - var declarationName = getDeclarationName(node); - var exportName = ts.hasModifier(node, 512 /* Default */) ? ts.createLiteral("default") : declarationName; - return createExportStatement(exportName, declarationName); - } - function createImportBinding(importDeclaration) { - var importAlias; - var name; - if (ts.isImportClause(importDeclaration)) { - importAlias = ts.getGeneratedNameForNode(importDeclaration.parent); - name = ts.createIdentifier("default"); - } - else if (ts.isImportSpecifier(importDeclaration)) { - importAlias = ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent); - name = importDeclaration.propertyName || importDeclaration.name; - } - else { - return undefined; - } - if (name.originalKeywordKind && languageVersion === 0 /* ES3 */) { - return ts.createElementAccess(importAlias, ts.createLiteral(name.text)); - } - else { - return ts.createPropertyAccess(importAlias, ts.getSynthesizedClone(name)); - } - } - function collectDependencyGroups(externalImports) { - var groupIndices = ts.createMap(); - var dependencyGroups = []; - for (var i = 0; i < externalImports.length; i++) { - var externalImport = externalImports[i]; - var externalModuleName = ts.getExternalModuleNameLiteral(externalImport, currentSourceFile, host, resolver, compilerOptions); - var text = externalModuleName.text; - if (ts.hasProperty(groupIndices, text)) { - // deduplicate/group entries in dependency list by the dependency name - var groupIndex = groupIndices[text]; - dependencyGroups[groupIndex].externalImports.push(externalImport); - continue; - } - else { - groupIndices[text] = dependencyGroups.length; - dependencyGroups.push({ - name: externalModuleName, - externalImports: [externalImport] - }); - } - } - return dependencyGroups; - } - function getNameOfDependencyGroup(dependencyGroup) { - return dependencyGroup.name; - } - function recordExportName(name) { - if (!exportedLocalNames) { - exportedLocalNames = []; - } - exportedLocalNames.push(name); - } - function recordExportedFunctionDeclaration(node) { - if (!exportedFunctionDeclarations) { - exportedFunctionDeclarations = []; - } - exportedFunctionDeclarations.push(createDeclarationExport(node)); - } - function hoistBindingElement(node, isExported) { - if (ts.isOmittedExpression(node)) { - return; - } - var name = node.name; - if (ts.isIdentifier(name)) { - hoistVariableDeclaration(ts.getSynthesizedClone(name)); - if (isExported) { - recordExportName(name); - } - } - else if (ts.isBindingPattern(name)) { - ts.forEach(name.elements, isExported ? hoistExportedBindingElement : hoistNonExportedBindingElement); - } - } - function hoistExportedBindingElement(node) { - hoistBindingElement(node, /*isExported*/ true); - } - function hoistNonExportedBindingElement(node) { - hoistBindingElement(node, /*isExported*/ false); - } - function updateSourceFile(node, statements, nodeEmitFlags) { - var updated = ts.getMutableClone(node); - updated.statements = ts.createNodeArray(statements, node.statements); - ts.setEmitFlags(updated, nodeEmitFlags); - return updated; - } - } - ts.transformSystemModule = transformSystemModule; -})(ts || (ts = {})); -/// -/// -/*@internal*/ -var ts; -(function (ts) { - function transformModule(context) { - var transformModuleDelegates = ts.createMap((_a = {}, - _a[ts.ModuleKind.None] = transformCommonJSModule, - _a[ts.ModuleKind.CommonJS] = transformCommonJSModule, - _a[ts.ModuleKind.AMD] = transformAMDModule, - _a[ts.ModuleKind.UMD] = transformUMDModule, - _a)); - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; - var compilerOptions = context.getCompilerOptions(); - var resolver = context.getEmitResolver(); - var host = context.getEmitHost(); - var languageVersion = ts.getEmitScriptTarget(compilerOptions); - var moduleKind = ts.getEmitModuleKind(compilerOptions); - var previousOnSubstituteNode = context.onSubstituteNode; - var previousOnEmitNode = context.onEmitNode; - context.onSubstituteNode = onSubstituteNode; - context.onEmitNode = onEmitNode; - context.enableSubstitution(69 /* Identifier */); - context.enableSubstitution(187 /* BinaryExpression */); - context.enableSubstitution(185 /* PrefixUnaryExpression */); - context.enableSubstitution(186 /* PostfixUnaryExpression */); - context.enableSubstitution(254 /* ShorthandPropertyAssignment */); - context.enableEmitNotification(256 /* SourceFile */); - var currentSourceFile; - var externalImports; - var exportSpecifiers; - var exportEquals; - var bindingNameExportSpecifiersMap; - // Subset of exportSpecifiers that is a binding-name. - // This is to reduce amount of memory we have to keep around even after we done with module-transformer - var bindingNameExportSpecifiersForFileMap = ts.createMap(); - var hasExportStarsToExportValues; - return transformSourceFile; - /** - * Transforms the module aspects of a SourceFile. - * - * @param node The SourceFile node. - */ - function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { - return node; - } - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - currentSourceFile = node; - // Collect information about the external module. - (_a = ts.collectExternalModuleInfo(node, resolver), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); - // Perform the transformation. - var transformModule_1 = transformModuleDelegates[moduleKind] || transformModuleDelegates[ts.ModuleKind.None]; - var updated = transformModule_1(node); - ts.aggregateTransformFlags(updated); - currentSourceFile = undefined; - externalImports = undefined; - exportSpecifiers = undefined; - exportEquals = undefined; - hasExportStarsToExportValues = false; - return updated; - } - return node; - var _a; - } - /** - * Transforms a SourceFile into a CommonJS module. - * - * @param node The SourceFile node. - */ - function transformCommonJSModule(node) { - startLexicalEnvironment(); - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, visitor); - ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); - ts.addRange(statements, endLexicalEnvironment()); - addExportEqualsIfNeeded(statements, /*emitAsReturn*/ false); - var updated = updateSourceFile(node, statements); - if (hasExportStarsToExportValues) { - ts.setEmitFlags(updated, 2 /* EmitExportStar */ | ts.getEmitFlags(node)); - } - return updated; - } - /** - * Transforms a SourceFile into an AMD module. - * - * @param node The SourceFile node. - */ - function transformAMDModule(node) { - var define = ts.createIdentifier("define"); - var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); - return transformAsynchronousModule(node, define, moduleName, /*includeNonAmdDependencies*/ true); - } - /** - * Transforms a SourceFile into a UMD module. - * - * @param node The SourceFile node. - */ - function transformUMDModule(node) { - var define = ts.createIdentifier("define"); - ts.setEmitFlags(define, 16 /* UMDDefine */); - return transformAsynchronousModule(node, define, /*moduleName*/ undefined, /*includeNonAmdDependencies*/ false); - } - /** - * Transforms a SourceFile into an AMD or UMD module. - * - * @param node The SourceFile node. - * @param define The expression used to define the module. - * @param moduleName An expression for the module name, if available. - * @param includeNonAmdDependencies A value indicating whether to incldue any non-AMD dependencies. - */ - function transformAsynchronousModule(node, define, moduleName, includeNonAmdDependencies) { - // An AMD define function has the following shape: - // - // define(id?, dependencies?, factory); - // - // This has the shape of the following: - // - // 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 _a = collectAsynchronousDependencies(node, includeNonAmdDependencies), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; - // Create an updated SourceFile: - // - // define(moduleName?, ["module1", "module2"], function ... - return updateSourceFile(node, [ - ts.createStatement(ts.createCall(define, - /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ - // Add the dependency array argument: - // - // ["require", "exports", module1", "module2", ...] - ts.createArrayLiteral([ - ts.createLiteral("require"), - ts.createLiteral("exports") - ].concat(aliasedModuleNames, unaliasedModuleNames)), - // Add the module body function argument: - // - // function (require, exports, module1, module2) ... - ts.createFunctionExpression( - /*asteriskToken*/ undefined, - /*name*/ undefined, - /*typeParameters*/ undefined, [ - ts.createParameter("require"), - ts.createParameter("exports") - ].concat(importAliasNames), - /*type*/ undefined, transformAsynchronousModuleBody(node)) - ]))) - ]); - } - /** - * Transforms a SourceFile into an AMD or UMD module body. - * - * @param node The SourceFile node. - */ - function transformAsynchronousModuleBody(node) { - startLexicalEnvironment(); - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, visitor); - // Visit each statement of the module body. - ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); - // End the lexical environment for the module body - // and merge any new lexical declarations. - ts.addRange(statements, endLexicalEnvironment()); - // Append the 'export =' statement if provided. - addExportEqualsIfNeeded(statements, /*emitAsReturn*/ true); - var body = ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true); - if (hasExportStarsToExportValues) { - // If we have any `export * from ...` declarations - // we need to inform the emitter to add the __export helper. - ts.setEmitFlags(body, 2 /* EmitExportStar */); - } - return body; - } - function addExportEqualsIfNeeded(statements, emitAsReturn) { - if (exportEquals && resolver.isValueAliasDeclaration(exportEquals)) { - if (emitAsReturn) { - var statement = ts.createReturn(exportEquals.expression, - /*location*/ exportEquals); - ts.setEmitFlags(statement, 12288 /* NoTokenSourceMaps */ | 49152 /* NoComments */); - statements.push(statement); - } - else { - var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), exportEquals.expression), - /*location*/ exportEquals); - ts.setEmitFlags(statement, 49152 /* NoComments */); - statements.push(statement); - } - } - } - /** - * Visits a node at the top level of the source file. - * - * @param node The node. - */ - function visitor(node) { - switch (node.kind) { - case 230 /* ImportDeclaration */: - return visitImportDeclaration(node); - case 229 /* ImportEqualsDeclaration */: - return visitImportEqualsDeclaration(node); - case 236 /* ExportDeclaration */: - return visitExportDeclaration(node); - case 235 /* ExportAssignment */: - return visitExportAssignment(node); - case 200 /* VariableStatement */: - return visitVariableStatement(node); - case 220 /* FunctionDeclaration */: - return visitFunctionDeclaration(node); - case 221 /* ClassDeclaration */: - return visitClassDeclaration(node); - case 202 /* ExpressionStatement */: - return visitExpressionStatement(node); - default: - // This visitor does not descend into the tree, as export/import statements - // are only transformed at the top level of a file. - return node; - } - } - /** - * Visits an ImportDeclaration node. - * - * @param node The ImportDeclaration node. - */ - function visitImportDeclaration(node) { - if (!ts.contains(externalImports, node)) { - return undefined; - } - var statements = []; - var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); - if (moduleKind !== ts.ModuleKind.AMD) { - if (!node.importClause) { - // import "mod"; - statements.push(ts.createStatement(createRequireCall(node), - /*location*/ node)); - } - else { - var variables = []; - if (namespaceDeclaration && !ts.isDefaultImport(node)) { - // import * as n from "mod"; - variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), - /*type*/ undefined, createRequireCall(node))); - } - else { - // import d from "mod"; - // import { x, y } from "mod"; - // import d, { x, y } from "mod"; - // import d, * as n from "mod"; - variables.push(ts.createVariableDeclaration(ts.getGeneratedNameForNode(node), - /*type*/ undefined, createRequireCall(node))); - if (namespaceDeclaration && ts.isDefaultImport(node)) { - variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), - /*type*/ undefined, ts.getGeneratedNameForNode(node))); - } - } - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createConstDeclarationList(variables), - /*location*/ node)); - } - } - else if (namespaceDeclaration && ts.isDefaultImport(node)) { - // import d, * as n from "mod"; - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), - /*type*/ undefined, ts.getGeneratedNameForNode(node), - /*location*/ node) - ]))); - } - addExportImportAssignments(statements, node); - return ts.singleOrMany(statements); - } - function visitImportEqualsDeclaration(node) { - if (!ts.contains(externalImports, node)) { - return undefined; - } - // Set emitFlags on the name of the importEqualsDeclaration - // This is so the printer will not substitute the identifier - ts.setEmitFlags(node.name, 128 /* NoSubstitution */); - var statements = []; - if (moduleKind !== ts.ModuleKind.AMD) { - if (ts.hasModifier(node, 1 /* Export */)) { - statements.push(ts.createStatement(createExportAssignment(node.name, createRequireCall(node)), - /*location*/ node)); - } - else { - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(ts.getSynthesizedClone(node.name), - /*type*/ undefined, createRequireCall(node)) - ], - /*location*/ undefined, - /*flags*/ languageVersion >= 2 /* ES6 */ ? 2 /* Const */ : 0 /* None */), - /*location*/ node)); - } - } - else { - if (ts.hasModifier(node, 1 /* Export */)) { - statements.push(ts.createStatement(createExportAssignment(node.name, node.name), - /*location*/ node)); - } - } - addExportImportAssignments(statements, node); - return statements; - } - function visitExportDeclaration(node) { - if (!ts.contains(externalImports, node)) { - return undefined; - } - var generatedName = ts.getGeneratedNameForNode(node); - if (node.exportClause) { - var statements = []; - // export { x, y } from "mod"; - if (moduleKind !== ts.ModuleKind.AMD) { - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(generatedName, - /*type*/ undefined, createRequireCall(node)) - ]), - /*location*/ node)); - } - for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { - var specifier = _a[_i]; - if (resolver.isValueAliasDeclaration(specifier)) { - var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); - statements.push(ts.createStatement(createExportAssignment(specifier.name, exportedValue), - /*location*/ specifier)); - } - } - return ts.singleOrMany(statements); - } - else if (resolver.moduleExportsSomeValue(node.moduleSpecifier)) { - // export * from "mod"; - return ts.createStatement(ts.createCall(ts.createIdentifier("__export"), - /*typeArguments*/ undefined, [ - moduleKind !== ts.ModuleKind.AMD - ? createRequireCall(node) - : generatedName - ]), - /*location*/ node); - } - } - function visitExportAssignment(node) { - if (!node.isExportEquals) { - if (ts.nodeIsSynthesized(node) || resolver.isValueAliasDeclaration(node)) { - var statements = []; - addExportDefault(statements, node.expression, /*location*/ node); - return statements; - } - } - return undefined; - } - function addExportDefault(statements, expression, location) { - tryAddExportDefaultCompat(statements); - statements.push(ts.createStatement(createExportAssignment(ts.createIdentifier("default"), expression), location)); - } - function tryAddExportDefaultCompat(statements) { - var original = ts.getOriginalNode(currentSourceFile); - ts.Debug.assert(original.kind === 256 /* SourceFile */); - if (!original.symbol.exports["___esModule"]) { - if (languageVersion === 0 /* ES3 */) { - statements.push(ts.createStatement(createExportAssignment(ts.createIdentifier("__esModule"), ts.createLiteral(true)))); - } - else { - statements.push(ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), - /*typeArguments*/ undefined, [ - ts.createIdentifier("exports"), - ts.createLiteral("__esModule"), - ts.createObjectLiteral([ - ts.createPropertyAssignment("value", ts.createLiteral(true)) - ]) - ]))); - } - } - } - function addExportImportAssignments(statements, node) { - if (ts.isImportEqualsDeclaration(node)) { - addExportMemberAssignments(statements, node.name); - } - else { - var names = ts.reduceEachChild(node, collectExportMembers, []); - for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_33 = names_1[_i]; - addExportMemberAssignments(statements, name_33); - } - } - } - function collectExportMembers(names, node) { - if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node) && ts.isDeclaration(node)) { - var name_34 = node.name; - if (ts.isIdentifier(name_34)) { - names.push(name_34); - } - } - return ts.reduceEachChild(node, collectExportMembers, names); - } - function addExportMemberAssignments(statements, name) { - if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { - for (var _i = 0, _a = exportSpecifiers[name.text]; _i < _a.length; _i++) { - var specifier = _a[_i]; - statements.push(ts.startOnNewLine(ts.createStatement(createExportAssignment(specifier.name, name), - /*location*/ specifier.name))); - } - } - } - function addExportMemberAssignment(statements, node) { - if (ts.hasModifier(node, 512 /* Default */)) { - addExportDefault(statements, getDeclarationName(node), /*location*/ node); - } - else { - statements.push(createExportStatement(node.name, ts.setEmitFlags(ts.getSynthesizedClone(node.name), 262144 /* LocalName */), /*location*/ node)); - } - } - function visitVariableStatement(node) { - // If the variable is for a generated declaration, - // we should maintain it and just strip off the 'export' modifier if necessary. - var originalKind = ts.getOriginalNode(node).kind; - if (originalKind === 225 /* ModuleDeclaration */ || - originalKind === 224 /* EnumDeclaration */ || - originalKind === 221 /* ClassDeclaration */) { - if (!ts.hasModifier(node, 1 /* Export */)) { - return node; - } - return ts.setOriginalNode(ts.createVariableStatement( - /*modifiers*/ undefined, node.declarationList), node); - } - var resultStatements = []; - // If we're exporting these variables, then these just become assignments to 'exports.blah'. - // We only want to emit assignments for variables with initializers. - if (ts.hasModifier(node, 1 /* Export */)) { - var variables = ts.getInitializedVariables(node.declarationList); - if (variables.length > 0) { - var inlineAssignments = ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable)), node); - resultStatements.push(inlineAssignments); - } - } - else { - resultStatements.push(node); - } - // While we might not have been exported here, each variable might have been exported - // later on in an export specifier (e.g. `export {foo as blah, bar}`). - for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - addExportMemberAssignmentsForBindingName(resultStatements, decl.name); - } - return resultStatements; - } - /** - * Creates appropriate assignments for each binding identifier that is exported in an export specifier, - * and inserts it into 'resultStatements'. - */ - function addExportMemberAssignmentsForBindingName(resultStatements, name) { - if (ts.isBindingPattern(name)) { - for (var _i = 0, _a = name.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (!ts.isOmittedExpression(element)) { - addExportMemberAssignmentsForBindingName(resultStatements, element.name); - } - } - } - else { - if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { - var sourceFileId = ts.getOriginalNodeId(currentSourceFile); - if (!bindingNameExportSpecifiersForFileMap[sourceFileId]) { - bindingNameExportSpecifiersForFileMap[sourceFileId] = ts.createMap(); - } - bindingNameExportSpecifiersForFileMap[sourceFileId][name.text] = exportSpecifiers[name.text]; - addExportMemberAssignments(resultStatements, name); - } - } - } - function transformInitializedVariable(node) { - var name = node.name; - if (ts.isBindingPattern(name)) { - return ts.flattenVariableDestructuringToExpression(context, node, hoistVariableDeclaration, getModuleMemberName, visitor); - } - else { - return ts.createAssignment(getModuleMemberName(name), ts.visitNode(node.initializer, visitor, ts.isExpression)); - } - } - function visitFunctionDeclaration(node) { - var statements = []; - var name = node.name || ts.getGeneratedNameForNode(node); - if (ts.hasModifier(node, 1 /* Export */)) { - statements.push(ts.setOriginalNode(ts.createFunctionDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, node.asteriskToken, name, - /*typeParameters*/ undefined, node.parameters, - /*type*/ undefined, node.body, - /*location*/ node), - /*original*/ node)); - addExportMemberAssignment(statements, node); - } - else { - statements.push(node); - } - if (node.name) { - addExportMemberAssignments(statements, node.name); - } - return ts.singleOrMany(statements); - } - function visitClassDeclaration(node) { - var statements = []; - var name = node.name || ts.getGeneratedNameForNode(node); - if (ts.hasModifier(node, 1 /* Export */)) { - statements.push(ts.setOriginalNode(ts.createClassDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, name, - /*typeParameters*/ undefined, node.heritageClauses, node.members, - /*location*/ node), - /*original*/ node)); - addExportMemberAssignment(statements, node); - } - else { - statements.push(node); - } - // Decorators end up creating a series of assignment expressions which overwrite - // the local binding that we export, so we need to defer from exporting decorated classes - // until the decoration assignments take place. We do this when visiting expression-statements. - if (node.name && !(node.decorators && node.decorators.length)) { - addExportMemberAssignments(statements, node.name); - } - return ts.singleOrMany(statements); - } - function visitExpressionStatement(node) { - var original = ts.getOriginalNode(node); - var origKind = original.kind; - if (origKind === 224 /* EnumDeclaration */ || origKind === 225 /* ModuleDeclaration */) { - return visitExpressionStatementForEnumOrNamespaceDeclaration(node, original); - } - else if (origKind === 221 /* ClassDeclaration */) { - // The decorated assignment for a class name may need to be transformed. - var classDecl = original; - if (classDecl.name) { - var statements = [node]; - addExportMemberAssignments(statements, classDecl.name); - return statements; - } - } - return node; - } - function visitExpressionStatementForEnumOrNamespaceDeclaration(node, original) { - var statements = [node]; - // Preserve old behavior for enums in which a variable statement is emitted after the body itself. - if (ts.hasModifier(original, 1 /* Export */) && - original.kind === 224 /* EnumDeclaration */ && - ts.isFirstDeclarationOfKind(original, 224 /* EnumDeclaration */)) { - addVarForExportedEnumOrNamespaceDeclaration(statements, original); - } - addExportMemberAssignments(statements, original.name); - return statements; - } - /** - * Adds a trailing VariableStatement for an enum or module declaration. - */ - function addVarForExportedEnumOrNamespaceDeclaration(statements, node) { - var transformedStatement = ts.createVariableStatement( - /*modifiers*/ undefined, [ts.createVariableDeclaration(getDeclarationName(node), - /*type*/ undefined, ts.createPropertyAccess(ts.createIdentifier("exports"), getDeclarationName(node)))], - /*location*/ node); - ts.setEmitFlags(transformedStatement, 49152 /* NoComments */); - statements.push(transformedStatement); - } - function getDeclarationName(node) { - return node.name ? ts.getSynthesizedClone(node.name) : ts.getGeneratedNameForNode(node); - } - function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 256 /* SourceFile */) { - bindingNameExportSpecifiersMap = bindingNameExportSpecifiersForFileMap[ts.getOriginalNodeId(node)]; - previousOnEmitNode(emitContext, node, emitCallback); - bindingNameExportSpecifiersMap = undefined; - } - else { - previousOnEmitNode(emitContext, node, emitCallback); - } - } - /** - * Hooks node substitutions. - * - * @param node The node to substitute. - * @param isExpression A value indicating whether the node is to be used in an expression - * position. - */ - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1 /* Expression */) { - return substituteExpression(node); - } - else if (ts.isShorthandPropertyAssignment(node)) { - return substituteShorthandPropertyAssignment(node); - } - return node; - } - function substituteShorthandPropertyAssignment(node) { - var name = node.name; - var exportedOrImportedName = substituteExpressionIdentifier(name); - if (exportedOrImportedName !== name) { - // A shorthand property with an assignment initializer is probably part of a - // destructuring assignment - if (node.objectAssignmentInitializer) { - var initializer = ts.createAssignment(exportedOrImportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name, initializer, /*location*/ node); - } - return ts.createPropertyAssignment(name, exportedOrImportedName, /*location*/ node); - } - return node; - } - function substituteExpression(node) { - switch (node.kind) { - case 69 /* Identifier */: - return substituteExpressionIdentifier(node); - case 187 /* BinaryExpression */: - return substituteBinaryExpression(node); - case 186 /* PostfixUnaryExpression */: - case 185 /* PrefixUnaryExpression */: - return substituteUnaryExpression(node); - } - return node; - } - function substituteExpressionIdentifier(node) { - return trySubstituteExportedName(node) - || trySubstituteImportedName(node) - || node; - } - function substituteBinaryExpression(node) { - var left = node.left; - // If the left-hand-side of the binaryExpression is an identifier and its is export through export Specifier - if (ts.isIdentifier(left) && ts.isAssignmentOperator(node.operatorToken.kind)) { - if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, left.text)) { - ts.setEmitFlags(node, 128 /* NoSubstitution */); - var nestedExportAssignment = void 0; - for (var _i = 0, _a = bindingNameExportSpecifiersMap[left.text]; _i < _a.length; _i++) { - var specifier = _a[_i]; - nestedExportAssignment = nestedExportAssignment ? - createExportAssignment(specifier.name, nestedExportAssignment) : - createExportAssignment(specifier.name, node); - } - return nestedExportAssignment; - } - } - return node; - } - function substituteUnaryExpression(node) { - // Because how the compiler only parse plusplus and minusminus to be either prefixUnaryExpression or postFixUnaryExpression depended on where they are - // We don't need to check that the operator has SyntaxKind.plusplus or SyntaxKind.minusminus - var operator = node.operator; - var operand = node.operand; - if (ts.isIdentifier(operand) && bindingNameExportSpecifiersForFileMap) { - if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, operand.text)) { - ts.setEmitFlags(node, 128 /* NoSubstitution */); - var transformedUnaryExpression = void 0; - if (node.kind === 186 /* PostfixUnaryExpression */) { - transformedUnaryExpression = ts.createBinary(operand, ts.createToken(operator === 41 /* PlusPlusToken */ ? 57 /* PlusEqualsToken */ : 58 /* MinusEqualsToken */), ts.createLiteral(1), - /*location*/ node); - // We have to set no substitution flag here to prevent visit the binary expression and substitute it again as we will preform all necessary substitution in here - ts.setEmitFlags(transformedUnaryExpression, 128 /* NoSubstitution */); - } - var nestedExportAssignment = void 0; - for (var _i = 0, _a = bindingNameExportSpecifiersMap[operand.text]; _i < _a.length; _i++) { - var specifier = _a[_i]; - nestedExportAssignment = nestedExportAssignment ? - createExportAssignment(specifier.name, nestedExportAssignment) : - createExportAssignment(specifier.name, transformedUnaryExpression || node); - } - return nestedExportAssignment; - } - } - return node; - } - function trySubstituteExportedName(node) { - var emitFlags = ts.getEmitFlags(node); - if ((emitFlags & 262144 /* LocalName */) === 0) { - var container = resolver.getReferencedExportContainer(node, (emitFlags & 131072 /* ExportName */) !== 0); - if (container) { - if (container.kind === 256 /* SourceFile */) { - return ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node), - /*location*/ node); - } - } - } - return undefined; - } - function trySubstituteImportedName(node) { - if ((ts.getEmitFlags(node) & 262144 /* LocalName */) === 0) { - var declaration = resolver.getReferencedImportDeclaration(node); - if (declaration) { - if (ts.isImportClause(declaration)) { - if (languageVersion >= 1 /* ES5 */) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent), ts.createIdentifier("default"), - /*location*/ node); - } - else { - // TODO: ES3 transform to handle x.default -> x["default"] - return ts.createElementAccess(ts.getGeneratedNameForNode(declaration.parent), ts.createLiteral("default"), - /*location*/ node); - } - } - else if (ts.isImportSpecifier(declaration)) { - var name_35 = declaration.propertyName || declaration.name; - if (name_35.originalKeywordKind === 77 /* DefaultKeyword */ && languageVersion <= 0 /* ES3 */) { - // TODO: ES3 transform to handle x.default -> x["default"] - return ts.createElementAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.createLiteral(name_35.text), - /*location*/ node); - } - else { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.getSynthesizedClone(name_35), - /*location*/ node); - } - } - } - } - return undefined; - } - function getModuleMemberName(name) { - return ts.createPropertyAccess(ts.createIdentifier("exports"), name, - /*location*/ name); - } - function createRequireCall(importNode) { - var moduleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); - var args = []; - if (ts.isDefined(moduleName)) { - args.push(moduleName); - } - return ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, args); - } - function createExportStatement(name, value, location) { - var statement = ts.createStatement(createExportAssignment(name, value)); - statement.startsOnNewLine = true; - if (location) { - ts.setSourceMapRange(statement, location); - } - return statement; - } - function createExportAssignment(name, value) { - return ts.createAssignment(name.originalKeywordKind === 77 /* DefaultKeyword */ && languageVersion === 0 /* ES3 */ - ? ts.createElementAccess(ts.createIdentifier("exports"), ts.createLiteral(name.text)) - : ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value); - } - function collectAsynchronousDependencies(node, includeNonAmdDependencies) { - // names of modules with corresponding parameter in the factory function - var aliasedModuleNames = []; - // names of modules with no corresponding parameters in factory function - var unaliasedModuleNames = []; - // names of the parameters in the factory function; these - // parameters need to match the indexes of the corresponding - // module names in aliasedModuleNames. - var importAliasNames = []; - // Fill in amd-dependency tags - for (var _i = 0, _a = node.amdDependencies; _i < _a.length; _i++) { - var amdDependency = _a[_i]; - if (amdDependency.name) { - aliasedModuleNames.push(ts.createLiteral(amdDependency.path)); - importAliasNames.push(ts.createParameter(amdDependency.name)); - } - else { - unaliasedModuleNames.push(ts.createLiteral(amdDependency.path)); - } - } - for (var _b = 0, externalImports_3 = externalImports; _b < externalImports_3.length; _b++) { - var importNode = externalImports_3[_b]; - // Find the name of the external module - var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); - // Find the name of the module alias, if there is one - var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile); - if (includeNonAmdDependencies && importAliasName) { - // Set emitFlags on the name of the classDeclaration - // This is so that when printer will not substitute the identifier - ts.setEmitFlags(importAliasName, 128 /* NoSubstitution */); - aliasedModuleNames.push(externalModuleName); - importAliasNames.push(ts.createParameter(importAliasName)); - } - else { - unaliasedModuleNames.push(externalModuleName); - } - } - return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; - } - function updateSourceFile(node, statements) { - var updated = ts.getMutableClone(node); - updated.statements = ts.createNodeArray(statements, node.statements); - return updated; - } - var _a; - } - ts.transformModule = transformModule; -})(ts || (ts = {})); /// /// /*@internal*/ @@ -47454,9 +45774,9 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 241 /* JsxElement */: + case 242 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 242 /* JsxSelfClosingElement */: + case 243 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); case 248 /* JsxExpression */: return visitJsxExpression(node); @@ -47467,13 +45787,13 @@ var ts; } function transformJsxChildToExpression(node) { switch (node.kind) { - case 244 /* JsxText */: + case 10 /* JsxText */: return visitJsxText(node); case 248 /* JsxExpression */: return visitJsxExpression(node); - case 241 /* JsxElement */: + case 242 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 242 /* JsxSelfClosingElement */: + case 243 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); default: ts.Debug.failBadSyntaxKind(node); @@ -47614,16 +45934,16 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 241 /* JsxElement */) { + if (node.kind === 242 /* JsxElement */) { return getTagName(node.openingElement); } else { - var name_36 = node.tagName; - if (ts.isIdentifier(name_36) && ts.isIntrinsicJsxName(name_36.text)) { - return ts.createLiteral(name_36.text); + var name_31 = node.tagName; + if (ts.isIdentifier(name_31) && ts.isIntrinsicJsxName(name_31.text)) { + return ts.createLiteral(name_31.text); } else { - return ts.createExpressionFromEntityName(name_36); + return ts.createExpressionFromEntityName(name_31); } } } @@ -47909,7 +46229,384 @@ var ts; /*@internal*/ var ts; (function (ts) { - function transformES7(context) { + function transformES2017(context) { + var ES2017SubstitutionFlags; + (function (ES2017SubstitutionFlags) { + /** Enables substitutions for async methods with `super` calls. */ + ES2017SubstitutionFlags[ES2017SubstitutionFlags["AsyncMethodsWithSuper"] = 1] = "AsyncMethodsWithSuper"; + })(ES2017SubstitutionFlags || (ES2017SubstitutionFlags = {})); + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; + var resolver = context.getEmitResolver(); + var compilerOptions = context.getCompilerOptions(); + var languageVersion = ts.getEmitScriptTarget(compilerOptions); + // These variables contain state that changes as we descend into the tree. + var currentSourceFileExternalHelpersModuleName; + /** + * Keeps track of whether expression substitution has been enabled for specific edge cases. + * They are persisted between each SourceFile transformation and should not be reset. + */ + var enabledSubstitutions; + /** + * Keeps track of whether we are within any containing namespaces when performing + * just-in-time substitution while printing an expression identifier. + */ + var applicableSubstitutions; + /** + * This keeps track of containers where `super` is valid, for use with + * just-in-time substitution for `super` expressions inside of async methods. + */ + var currentSuperContainer; + // Save the previous transformation hooks. + var previousOnEmitNode = context.onEmitNode; + var previousOnSubstituteNode = context.onSubstituteNode; + // Set new transformation hooks. + context.onEmitNode = onEmitNode; + context.onSubstituteNode = onSubstituteNode; + var currentScope; + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } + currentSourceFileExternalHelpersModuleName = node.externalHelpersModuleName; + return ts.visitEachChild(node, visitor, context); + } + function visitor(node) { + if (node.transformFlags & 16 /* ES2017 */) { + return visitorWorker(node); + } + else if (node.transformFlags & 32 /* ContainsES2017 */) { + return ts.visitEachChild(node, visitor, context); + } + return node; + } + function visitorWorker(node) { + switch (node.kind) { + case 119 /* AsyncKeyword */: + // ES2017 async modifier should be elided for targets < ES2017 + return undefined; + case 185 /* AwaitExpression */: + // ES2017 'await' expressions must be transformed for targets < ES2017. + return visitAwaitExpression(node); + case 148 /* MethodDeclaration */: + // ES2017 method declarations may be 'async' + return visitMethodDeclaration(node); + case 221 /* FunctionDeclaration */: + // ES2017 function declarations may be 'async' + return visitFunctionDeclaration(node); + case 180 /* FunctionExpression */: + // ES2017 function expressions may be 'async' + return visitFunctionExpression(node); + case 181 /* ArrowFunction */: + // ES2017 arrow functions may be 'async' + return visitArrowFunction(node); + default: + ts.Debug.failBadSyntaxKind(node); + return node; + } + } + /** + * Visits an await expression. + * + * This function will be called any time a ES2017 await expression is encountered. + * + * @param node The await expression node. + */ + function visitAwaitExpression(node) { + return ts.setOriginalNode(ts.createYield( + /*asteriskToken*/ undefined, ts.visitNode(node.expression, visitor, ts.isExpression), + /*location*/ node), node); + } + /** + * Visits a method declaration of a class. + * + * This function will be called when one of the following conditions are met: + * - The node is marked as async + * + * @param node The method node. + */ + function visitMethodDeclaration(node) { + if (!ts.isAsyncFunctionLike(node)) { + return node; + } + var method = ts.createMethod( + /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, + /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), + /*type*/ undefined, transformFunctionBody(node), + /*location*/ node); + // While we emit the source map for the node after skipping decorators and modifiers, + // we need to emit the comments for the original range. + ts.setCommentRange(method, node); + ts.setSourceMapRange(method, ts.moveRangePastDecorators(node)); + ts.setOriginalNode(method, node); + return method; + } + /** + * Visits a function declaration. + * + * This function will be called when one of the following conditions are met: + * - The node is marked async + * + * @param node The function node. + */ + function visitFunctionDeclaration(node) { + if (!ts.isAsyncFunctionLike(node)) { + return node; + } + var func = ts.createFunctionDeclaration( + /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, + /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), + /*type*/ undefined, transformFunctionBody(node), + /*location*/ node); + ts.setOriginalNode(func, node); + return func; + } + /** + * Visits a function expression node. + * + * This function will be called when one of the following conditions are met: + * - The node is marked async + * + * @param node The function expression node. + */ + function visitFunctionExpression(node) { + if (!ts.isAsyncFunctionLike(node)) { + return node; + } + if (ts.nodeIsMissing(node.body)) { + return ts.createOmittedExpression(); + } + var func = ts.createFunctionExpression( + /*modifiers*/ undefined, node.asteriskToken, node.name, + /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), + /*type*/ undefined, transformFunctionBody(node), + /*location*/ node); + ts.setOriginalNode(func, node); + return func; + } + /** + * @remarks + * This function will be called when one of the following conditions are met: + * - The node is marked async + */ + function visitArrowFunction(node) { + if (!ts.isAsyncFunctionLike(node)) { + return node; + } + var func = ts.createArrowFunction(ts.visitNodes(node.modifiers, visitor, ts.isModifier), + /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), + /*type*/ undefined, node.equalsGreaterThanToken, transformConciseBody(node), + /*location*/ node); + ts.setOriginalNode(func, node); + return func; + } + function transformFunctionBody(node) { + return transformAsyncFunctionBody(node); + } + function transformConciseBody(node) { + return transformAsyncFunctionBody(node); + } + function transformFunctionBodyWorker(body, start) { + if (start === void 0) { start = 0; } + var savedCurrentScope = currentScope; + currentScope = body; + startLexicalEnvironment(); + var statements = ts.visitNodes(body.statements, visitor, ts.isStatement, start); + var visited = ts.updateBlock(body, statements); + var declarations = endLexicalEnvironment(); + currentScope = savedCurrentScope; + return ts.mergeFunctionBodyLexicalEnvironment(visited, declarations); + } + function transformAsyncFunctionBody(node) { + var nodeType = node.original ? node.original.type : node.type; + var promiseConstructor = languageVersion < 2 /* ES2015 */ ? getPromiseConstructor(nodeType) : undefined; + var isArrowFunction = node.kind === 181 /* ArrowFunction */; + var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* CaptureArguments */) !== 0; + // An async function is emit as an outer function that calls an inner + // generator function. To preserve lexical bindings, we pass the current + // `this` and `arguments` objects to `__awaiter`. The generator function + // passed to `__awaiter` is executed inside of the callback to the + // promise constructor. + if (!isArrowFunction) { + var statements = []; + var statementOffset = ts.addPrologueDirectives(statements, node.body.statements, /*ensureUseStrict*/ false, visitor); + statements.push(ts.createReturn(ts.createAwaiterHelper(currentSourceFileExternalHelpersModuleName, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body, statementOffset)))); + var block = ts.createBlock(statements, /*location*/ node.body, /*multiLine*/ true); + // Minor optimization, emit `_super` helper to capture `super` access in an arrow. + // This step isn't needed if we eventually transform this to ES5. + if (languageVersion >= 2 /* ES2015 */) { + if (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) { + enableSubstitutionForAsyncMethodsWithSuper(); + ts.setEmitFlags(block, 8 /* EmitAdvancedSuperHelper */); + } + else if (resolver.getNodeCheckFlags(node) & 2048 /* AsyncMethodWithSuper */) { + enableSubstitutionForAsyncMethodsWithSuper(); + ts.setEmitFlags(block, 4 /* EmitSuperHelper */); + } + } + return block; + } + else { + return ts.createAwaiterHelper(currentSourceFileExternalHelpersModuleName, hasLexicalArguments, promiseConstructor, transformConciseBodyWorker(node.body, /*forceBlockFunctionBody*/ true)); + } + } + function transformConciseBodyWorker(body, forceBlockFunctionBody) { + if (ts.isBlock(body)) { + return transformFunctionBodyWorker(body); + } + else { + startLexicalEnvironment(); + var visited = ts.visitNode(body, visitor, ts.isConciseBody); + var declarations = endLexicalEnvironment(); + var merged = ts.mergeFunctionBodyLexicalEnvironment(visited, declarations); + if (forceBlockFunctionBody && !ts.isBlock(merged)) { + return ts.createBlock([ + ts.createReturn(merged) + ]); + } + else { + return merged; + } + } + } + function getPromiseConstructor(type) { + var typeName = ts.getEntityNameFromTypeNode(type); + if (typeName && ts.isEntityName(typeName)) { + var serializationKind = resolver.getTypeReferenceSerializationKind(typeName); + if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue + || serializationKind === ts.TypeReferenceSerializationKind.Unknown) { + return typeName; + } + } + return undefined; + } + function enableSubstitutionForAsyncMethodsWithSuper() { + if ((enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) === 0) { + enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; + // We need to enable substitutions for call, property access, and element access + // if we need to rewrite super calls. + context.enableSubstitution(175 /* CallExpression */); + context.enableSubstitution(173 /* PropertyAccessExpression */); + context.enableSubstitution(174 /* ElementAccessExpression */); + // We need to be notified when entering and exiting declarations that bind super. + context.enableEmitNotification(222 /* ClassDeclaration */); + context.enableEmitNotification(148 /* MethodDeclaration */); + context.enableEmitNotification(150 /* GetAccessor */); + context.enableEmitNotification(151 /* SetAccessor */); + context.enableEmitNotification(149 /* Constructor */); + } + } + function substituteExpression(node) { + switch (node.kind) { + case 173 /* PropertyAccessExpression */: + return substitutePropertyAccessExpression(node); + case 174 /* ElementAccessExpression */: + return substituteElementAccessExpression(node); + case 175 /* CallExpression */: + if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) { + return substituteCallExpression(node); + } + break; + } + return node; + } + function substitutePropertyAccessExpression(node) { + if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && node.expression.kind === 96 /* SuperKeyword */) { + var flags = getSuperContainerAsyncMethodFlags(); + if (flags) { + return createSuperAccessInAsyncMethod(ts.createLiteral(node.name.text), flags, node); + } + } + return node; + } + function substituteElementAccessExpression(node) { + if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && node.expression.kind === 96 /* SuperKeyword */) { + var flags = getSuperContainerAsyncMethodFlags(); + if (flags) { + return createSuperAccessInAsyncMethod(node.argumentExpression, flags, node); + } + } + return node; + } + function substituteCallExpression(node) { + var expression = node.expression; + if (ts.isSuperProperty(expression)) { + var flags = getSuperContainerAsyncMethodFlags(); + if (flags) { + var argumentExpression = ts.isPropertyAccessExpression(expression) + ? substitutePropertyAccessExpression(expression) + : substituteElementAccessExpression(expression); + return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), + /*typeArguments*/ undefined, [ + ts.createThis() + ].concat(node.arguments)); + } + } + return node; + } + function isSuperContainer(node) { + var kind = node.kind; + return kind === 222 /* ClassDeclaration */ + || kind === 149 /* Constructor */ + || kind === 148 /* MethodDeclaration */ + || kind === 150 /* GetAccessor */ + || kind === 151 /* SetAccessor */; + } + /** + * Hook for node emit. + * + * @param node The node to emit. + * @param emit A callback used to emit the node in the printer. + */ + function onEmitNode(emitContext, node, emitCallback) { + var savedApplicableSubstitutions = applicableSubstitutions; + var savedCurrentSuperContainer = currentSuperContainer; + // If we need to support substitutions for `super` in an async method, + // we should track it here. + if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && isSuperContainer(node)) { + currentSuperContainer = node; + } + previousOnEmitNode(emitContext, node, emitCallback); + applicableSubstitutions = savedApplicableSubstitutions; + currentSuperContainer = savedCurrentSuperContainer; + } + /** + * Hooks node substitutions. + * + * @param node The node to substitute. + * @param isExpression A value indicating whether the node is to be used in an expression + * position. + */ + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1 /* Expression */) { + return substituteExpression(node); + } + return node; + } + function createSuperAccessInAsyncMethod(argumentExpression, flags, location) { + if (flags & 4096 /* AsyncMethodWithSuperBinding */) { + return ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), + /*typeArguments*/ undefined, [argumentExpression]), "value", location); + } + else { + return ts.createCall(ts.createIdentifier("_super"), + /*typeArguments*/ undefined, [argumentExpression], location); + } + } + function getSuperContainerAsyncMethodFlags() { + return currentSuperContainer !== undefined + && resolver.getNodeCheckFlags(currentSuperContainer) & (2048 /* AsyncMethodWithSuper */ | 4096 /* AsyncMethodWithSuperBinding */); + } + } + ts.transformES2017 = transformES2017; +})(ts || (ts = {})); +/// +/// +/*@internal*/ +var ts; +(function (ts) { + function transformES2016(context) { var hoistVariableDeclaration = context.hoistVariableDeclaration; return transformSourceFile; function transformSourceFile(node) { @@ -47919,10 +46616,10 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if (node.transformFlags & 16 /* ES7 */) { + if (node.transformFlags & 64 /* ES2016 */) { return visitorWorker(node); } - else if (node.transformFlags & 32 /* ContainsES7 */) { + else if (node.transformFlags & 128 /* ContainsES2016 */) { return ts.visitEachChild(node, visitor, context); } else { @@ -47931,7 +46628,7 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return visitBinaryExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -47939,10 +46636,10 @@ var ts; } } function visitBinaryExpression(node) { - // We are here because ES7 adds support for the exponentiation operator. + // We are here because ES2016 adds support for the exponentiation operator. var left = ts.visitNode(node.left, visitor, ts.isExpression); var right = ts.visitNode(node.right, visitor, ts.isExpression); - if (node.operatorToken.kind === 60 /* AsteriskAsteriskEqualsToken */) { + if (node.operatorToken.kind === 61 /* AsteriskAsteriskEqualsToken */) { var target = void 0; var value = void 0; if (ts.isElementAccessExpression(left)) { @@ -47969,7 +46666,7 @@ var ts; } return ts.createAssignment(target, ts.createMathPow(value, right, /*location*/ node), /*location*/ node); } - else if (node.operatorToken.kind === 38 /* AsteriskAsteriskToken */) { + else if (node.operatorToken.kind === 39 /* AsteriskAsteriskToken */) { // Transforms `a ** b` into `Math.pow(a, b)` return ts.createMathPow(left, right, /*location*/ node); } @@ -47979,7 +46676,2474 @@ var ts; } } } - ts.transformES7 = transformES7; + ts.transformES2016 = transformES2016; +})(ts || (ts = {})); +/// +/// +/*@internal*/ +var ts; +(function (ts) { + var ES2015SubstitutionFlags; + (function (ES2015SubstitutionFlags) { + /** Enables substitutions for captured `this` */ + ES2015SubstitutionFlags[ES2015SubstitutionFlags["CapturedThis"] = 1] = "CapturedThis"; + /** Enables substitutions for block-scoped bindings. */ + ES2015SubstitutionFlags[ES2015SubstitutionFlags["BlockScopedBindings"] = 2] = "BlockScopedBindings"; + })(ES2015SubstitutionFlags || (ES2015SubstitutionFlags = {})); + var CopyDirection; + (function (CopyDirection) { + CopyDirection[CopyDirection["ToOriginal"] = 0] = "ToOriginal"; + CopyDirection[CopyDirection["ToOutParameter"] = 1] = "ToOutParameter"; + })(CopyDirection || (CopyDirection = {})); + var Jump; + (function (Jump) { + Jump[Jump["Break"] = 2] = "Break"; + Jump[Jump["Continue"] = 4] = "Continue"; + Jump[Jump["Return"] = 8] = "Return"; + })(Jump || (Jump = {})); + var SuperCaptureResult; + (function (SuperCaptureResult) { + /** + * A capture may have been added for calls to 'super', but + * the caller should emit subsequent statements normally. + */ + SuperCaptureResult[SuperCaptureResult["NoReplacement"] = 0] = "NoReplacement"; + /** + * A call to 'super()' got replaced with a capturing statement like: + * + * var _this = _super.call(...) || this; + * + * Callers should skip the current statement. + */ + SuperCaptureResult[SuperCaptureResult["ReplaceSuperCapture"] = 1] = "ReplaceSuperCapture"; + /** + * A call to 'super()' got replaced with a capturing statement like: + * + * return _super.call(...) || this; + * + * Callers should skip the current statement and avoid any returns of '_this'. + */ + SuperCaptureResult[SuperCaptureResult["ReplaceWithReturn"] = 2] = "ReplaceWithReturn"; + })(SuperCaptureResult || (SuperCaptureResult = {})); + function transformES2015(context) { + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; + var resolver = context.getEmitResolver(); + var previousOnSubstituteNode = context.onSubstituteNode; + var previousOnEmitNode = context.onEmitNode; + context.onEmitNode = onEmitNode; + context.onSubstituteNode = onSubstituteNode; + var currentSourceFile; + var currentText; + var currentParent; + var currentNode; + var enclosingVariableStatement; + var enclosingBlockScopeContainer; + var enclosingBlockScopeContainerParent; + var enclosingFunction; + var enclosingNonArrowFunction; + var enclosingNonAsyncFunctionBody; + /** + * Used to track if we are emitting body of the converted loop + */ + var convertedLoopState; + /** + * Keeps track of whether substitutions have been enabled for specific cases. + * They are persisted between each SourceFile transformation and should not + * be reset. + */ + var enabledSubstitutions; + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } + currentSourceFile = node; + currentText = node.text; + return ts.visitNode(node, visitor, ts.isSourceFile); + } + function visitor(node) { + return saveStateAndInvoke(node, dispatcher); + } + function dispatcher(node) { + return convertedLoopState + ? visitorForConvertedLoopWorker(node) + : visitorWorker(node); + } + function saveStateAndInvoke(node, f) { + var savedEnclosingFunction = enclosingFunction; + var savedEnclosingNonArrowFunction = enclosingNonArrowFunction; + var savedEnclosingNonAsyncFunctionBody = enclosingNonAsyncFunctionBody; + var savedEnclosingBlockScopeContainer = enclosingBlockScopeContainer; + var savedEnclosingBlockScopeContainerParent = enclosingBlockScopeContainerParent; + var savedEnclosingVariableStatement = enclosingVariableStatement; + var savedCurrentParent = currentParent; + var savedCurrentNode = currentNode; + var savedConvertedLoopState = convertedLoopState; + if (ts.nodeStartsNewLexicalEnvironment(node)) { + // don't treat content of nodes that start new lexical environment as part of converted loop copy + convertedLoopState = undefined; + } + onBeforeVisitNode(node); + var visited = f(node); + convertedLoopState = savedConvertedLoopState; + enclosingFunction = savedEnclosingFunction; + enclosingNonArrowFunction = savedEnclosingNonArrowFunction; + enclosingNonAsyncFunctionBody = savedEnclosingNonAsyncFunctionBody; + enclosingBlockScopeContainer = savedEnclosingBlockScopeContainer; + enclosingBlockScopeContainerParent = savedEnclosingBlockScopeContainerParent; + enclosingVariableStatement = savedEnclosingVariableStatement; + currentParent = savedCurrentParent; + currentNode = savedCurrentNode; + return visited; + } + function shouldCheckNode(node) { + return (node.transformFlags & 256 /* ES2015 */) !== 0 || + node.kind === 215 /* LabeledStatement */ || + (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)); + } + function visitorWorker(node) { + if (shouldCheckNode(node)) { + return visitJavaScript(node); + } + else if (node.transformFlags & 512 /* ContainsES2015 */) { + return ts.visitEachChild(node, visitor, context); + } + else { + return node; + } + } + function visitorForConvertedLoopWorker(node) { + var result; + if (shouldCheckNode(node)) { + result = visitJavaScript(node); + } + else { + result = visitNodesInConvertedLoop(node); + } + return result; + } + function visitNodesInConvertedLoop(node) { + switch (node.kind) { + case 212 /* ReturnStatement */: + return visitReturnStatement(node); + case 201 /* VariableStatement */: + return visitVariableStatement(node); + case 214 /* SwitchStatement */: + return visitSwitchStatement(node); + case 211 /* BreakStatement */: + case 210 /* ContinueStatement */: + return visitBreakOrContinueStatement(node); + case 98 /* ThisKeyword */: + return visitThisKeyword(node); + case 70 /* Identifier */: + return visitIdentifier(node); + default: + return ts.visitEachChild(node, visitor, context); + } + } + function visitJavaScript(node) { + switch (node.kind) { + case 83 /* ExportKeyword */: + return node; + case 222 /* ClassDeclaration */: + return visitClassDeclaration(node); + case 193 /* ClassExpression */: + return visitClassExpression(node); + case 143 /* Parameter */: + return visitParameter(node); + case 221 /* FunctionDeclaration */: + return visitFunctionDeclaration(node); + case 181 /* ArrowFunction */: + return visitArrowFunction(node); + case 180 /* FunctionExpression */: + return visitFunctionExpression(node); + case 219 /* VariableDeclaration */: + return visitVariableDeclaration(node); + case 70 /* Identifier */: + return visitIdentifier(node); + case 220 /* VariableDeclarationList */: + return visitVariableDeclarationList(node); + case 215 /* LabeledStatement */: + return visitLabeledStatement(node); + case 205 /* DoStatement */: + return visitDoStatement(node); + case 206 /* WhileStatement */: + return visitWhileStatement(node); + case 207 /* ForStatement */: + return visitForStatement(node); + case 208 /* ForInStatement */: + return visitForInStatement(node); + case 209 /* ForOfStatement */: + return visitForOfStatement(node); + case 203 /* ExpressionStatement */: + return visitExpressionStatement(node); + case 172 /* ObjectLiteralExpression */: + return visitObjectLiteralExpression(node); + case 254 /* ShorthandPropertyAssignment */: + return visitShorthandPropertyAssignment(node); + case 171 /* ArrayLiteralExpression */: + return visitArrayLiteralExpression(node); + case 175 /* CallExpression */: + return visitCallExpression(node); + case 176 /* NewExpression */: + return visitNewExpression(node); + case 179 /* ParenthesizedExpression */: + return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); + case 188 /* BinaryExpression */: + return visitBinaryExpression(node, /*needsDestructuringValue*/ true); + case 12 /* NoSubstitutionTemplateLiteral */: + case 13 /* TemplateHead */: + case 14 /* TemplateMiddle */: + case 15 /* TemplateTail */: + return visitTemplateLiteral(node); + case 177 /* TaggedTemplateExpression */: + return visitTaggedTemplateExpression(node); + case 190 /* TemplateExpression */: + return visitTemplateExpression(node); + case 191 /* YieldExpression */: + return visitYieldExpression(node); + case 96 /* SuperKeyword */: + return visitSuperKeyword(); + case 191 /* YieldExpression */: + // `yield` will be handled by a generators transform. + return ts.visitEachChild(node, visitor, context); + case 148 /* MethodDeclaration */: + return visitMethodDeclaration(node); + case 256 /* SourceFile */: + return visitSourceFileNode(node); + case 201 /* VariableStatement */: + return visitVariableStatement(node); + default: + ts.Debug.failBadSyntaxKind(node); + return ts.visitEachChild(node, visitor, context); + } + } + function onBeforeVisitNode(node) { + if (currentNode) { + if (ts.isBlockScope(currentNode, currentParent)) { + enclosingBlockScopeContainer = currentNode; + enclosingBlockScopeContainerParent = currentParent; + } + if (ts.isFunctionLike(currentNode)) { + enclosingFunction = currentNode; + if (currentNode.kind !== 181 /* ArrowFunction */) { + enclosingNonArrowFunction = currentNode; + if (!(ts.getEmitFlags(currentNode) & 2097152 /* AsyncFunctionBody */)) { + enclosingNonAsyncFunctionBody = currentNode; + } + } + } + // keep track of the enclosing variable statement when in the context of + // variable statements, variable declarations, binding elements, and binding + // patterns. + switch (currentNode.kind) { + case 201 /* VariableStatement */: + enclosingVariableStatement = currentNode; + break; + case 220 /* VariableDeclarationList */: + case 219 /* VariableDeclaration */: + case 170 /* BindingElement */: + case 168 /* ObjectBindingPattern */: + case 169 /* ArrayBindingPattern */: + break; + default: + enclosingVariableStatement = undefined; + } + } + currentParent = currentNode; + currentNode = node; + } + function visitSwitchStatement(node) { + ts.Debug.assert(convertedLoopState !== undefined); + var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; + // for switch statement allow only non-labeled break + convertedLoopState.allowedNonLabeledJumps |= 2 /* Break */; + var result = ts.visitEachChild(node, visitor, context); + convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; + return result; + } + function visitReturnStatement(node) { + ts.Debug.assert(convertedLoopState !== undefined); + convertedLoopState.nonLocalJumps |= 8 /* Return */; + return ts.createReturn(ts.createObjectLiteral([ + ts.createPropertyAssignment(ts.createIdentifier("value"), node.expression + ? ts.visitNode(node.expression, visitor, ts.isExpression) + : ts.createVoidZero()) + ])); + } + function visitThisKeyword(node) { + ts.Debug.assert(convertedLoopState !== undefined); + if (enclosingFunction && enclosingFunction.kind === 181 /* ArrowFunction */) { + // if the enclosing function is an ArrowFunction is then we use the captured 'this' keyword. + convertedLoopState.containsLexicalThis = true; + return node; + } + return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this")); + } + function visitIdentifier(node) { + if (!convertedLoopState) { + return node; + } + if (ts.isGeneratedIdentifier(node)) { + return node; + } + if (node.text !== "arguments" && !resolver.isArgumentsLocalBinding(node)) { + return node; + } + return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = ts.createUniqueName("arguments")); + } + function visitBreakOrContinueStatement(node) { + if (convertedLoopState) { + // check if we can emit break/continue as is + // it is possible if either + // - break/continue is labeled and label is located inside the converted loop + // - break/continue is non-labeled and located in non-converted loop/switch statement + var jump = node.kind === 211 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || + (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); + if (!canUseBreakOrContinue) { + var labelMarker = void 0; + if (!node.label) { + if (node.kind === 211 /* BreakStatement */) { + convertedLoopState.nonLocalJumps |= 2 /* Break */; + labelMarker = "break"; + } + else { + convertedLoopState.nonLocalJumps |= 4 /* Continue */; + // note: return value is emitted only to simplify debugging, call to converted loop body does not do any dispatching on it. + labelMarker = "continue"; + } + } + else { + if (node.kind === 211 /* BreakStatement */) { + labelMarker = "break-" + node.label.text; + setLabeledJump(convertedLoopState, /*isBreak*/ true, node.label.text, labelMarker); + } + else { + labelMarker = "continue-" + node.label.text; + setLabeledJump(convertedLoopState, /*isBreak*/ false, node.label.text, labelMarker); + } + } + var returnExpression = ts.createLiteral(labelMarker); + if (convertedLoopState.loopOutParameters.length) { + var outParams = convertedLoopState.loopOutParameters; + var expr = void 0; + for (var i = 0; i < outParams.length; i++) { + var copyExpr = copyOutParameter(outParams[i], 1 /* ToOutParameter */); + if (i === 0) { + expr = copyExpr; + } + else { + expr = ts.createBinary(expr, 25 /* CommaToken */, copyExpr); + } + } + returnExpression = ts.createBinary(expr, 25 /* CommaToken */, returnExpression); + } + return ts.createReturn(returnExpression); + } + } + return ts.visitEachChild(node, visitor, context); + } + /** + * Visits a ClassDeclaration and transforms it into a variable statement. + * + * @param node A ClassDeclaration node. + */ + function visitClassDeclaration(node) { + // [source] + // class C { } + // + // [output] + // var C = (function () { + // function C() { + // } + // return C; + // }()); + var modifierFlags = ts.getModifierFlags(node); + var isExported = modifierFlags & 1 /* Export */; + var isDefault = modifierFlags & 512 /* Default */; + // Add an `export` modifier to the statement if needed (for `--target es5 --module es6`) + var modifiers = isExported && !isDefault + ? ts.filter(node.modifiers, isExportModifier) + : undefined; + var statement = ts.createVariableStatement(modifiers, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(getDeclarationName(node, /*allowComments*/ true), + /*type*/ undefined, transformClassLikeDeclarationToExpression(node)) + ]), + /*location*/ node); + ts.setOriginalNode(statement, node); + ts.startOnNewLine(statement); + // Add an `export default` statement for default exports (for `--target es5 --module es6`) + if (isExported && isDefault) { + var statements = [statement]; + statements.push(ts.createExportAssignment( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*isExportEquals*/ false, getDeclarationName(node, /*allowComments*/ false))); + return statements; + } + return statement; + } + function isExportModifier(node) { + return node.kind === 83 /* ExportKeyword */; + } + /** + * Visits a ClassExpression and transforms it into an expression. + * + * @param node A ClassExpression node. + */ + function visitClassExpression(node) { + // [source] + // C = class { } + // + // [output] + // C = (function () { + // function class_1() { + // } + // return class_1; + // }()) + return transformClassLikeDeclarationToExpression(node); + } + /** + * Transforms a ClassExpression or ClassDeclaration into an expression. + * + * @param node A ClassExpression or ClassDeclaration node. + */ + function transformClassLikeDeclarationToExpression(node) { + // [source] + // class C extends D { + // constructor() {} + // method() {} + // get prop() {} + // set prop(v) {} + // } + // + // [output] + // (function (_super) { + // __extends(C, _super); + // function C() { + // } + // C.prototype.method = function () {} + // Object.defineProperty(C.prototype, "prop", { + // get: function() {}, + // set: function() {}, + // enumerable: true, + // configurable: true + // }); + // return C; + // }(D)) + if (node.name) { + enableSubstitutionsForBlockScopedBindings(); + } + var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); + var classFunction = ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, extendsClauseElement ? [ts.createParameter("_super")] : [], + /*type*/ undefined, transformClassBody(node, extendsClauseElement)); + // To preserve the behavior of the old emitter, we explicitly indent + // the body of the function here if it was requested in an earlier + // transformation. + if (ts.getEmitFlags(node) & 524288 /* Indented */) { + ts.setEmitFlags(classFunction, 524288 /* Indented */); + } + // "inner" and "outer" below are added purely to preserve source map locations from + // the old emitter + var inner = ts.createPartiallyEmittedExpression(classFunction); + inner.end = node.end; + ts.setEmitFlags(inner, 49152 /* NoComments */); + var outer = ts.createPartiallyEmittedExpression(inner); + outer.end = ts.skipTrivia(currentText, node.pos); + ts.setEmitFlags(outer, 49152 /* NoComments */); + return ts.createParen(ts.createCall(outer, + /*typeArguments*/ undefined, extendsClauseElement + ? [ts.visitNode(extendsClauseElement.expression, visitor, ts.isExpression)] + : [])); + } + /** + * Transforms a ClassExpression or ClassDeclaration into a function body. + * + * @param node A ClassExpression or ClassDeclaration node. + * @param extendsClauseElement The expression for the class `extends` clause. + */ + function transformClassBody(node, extendsClauseElement) { + var statements = []; + startLexicalEnvironment(); + addExtendsHelperIfNeeded(statements, node, extendsClauseElement); + addConstructor(statements, node, extendsClauseElement); + addClassMembers(statements, node); + // Create a synthetic text range for the return statement. + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 17 /* CloseBraceToken */); + var localName = getLocalName(node); + // The following partially-emitted expression exists purely to align our sourcemap + // emit with the original emitter. + var outer = ts.createPartiallyEmittedExpression(localName); + outer.end = closingBraceLocation.end; + ts.setEmitFlags(outer, 49152 /* NoComments */); + var statement = ts.createReturn(outer); + statement.pos = closingBraceLocation.pos; + ts.setEmitFlags(statement, 49152 /* NoComments */ | 12288 /* NoTokenSourceMaps */); + statements.push(statement); + ts.addRange(statements, endLexicalEnvironment()); + var block = ts.createBlock(ts.createNodeArray(statements, /*location*/ node.members), /*location*/ undefined, /*multiLine*/ true); + ts.setEmitFlags(block, 49152 /* NoComments */); + return block; + } + /** + * Adds a call to the `__extends` helper if needed for a class. + * + * @param statements The statements of the class body function. + * @param node The ClassExpression or ClassDeclaration node. + * @param extendsClauseElement The expression for the class `extends` clause. + */ + function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) { + if (extendsClauseElement) { + statements.push(ts.createStatement(ts.createExtendsHelper(currentSourceFile.externalHelpersModuleName, getDeclarationName(node)), + /*location*/ extendsClauseElement)); + } + } + /** + * Adds the constructor of the class to a class body function. + * + * @param statements The statements of the class body function. + * @param node The ClassExpression or ClassDeclaration node. + * @param extendsClauseElement The expression for the class `extends` clause. + */ + function addConstructor(statements, node, extendsClauseElement) { + var constructor = ts.getFirstConstructorWithBody(node); + var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); + var constructorFunction = ts.createFunctionDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, getDeclarationName(node), + /*typeParameters*/ undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), + /*type*/ undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), + /*location*/ constructor || node); + if (extendsClauseElement) { + ts.setEmitFlags(constructorFunction, 256 /* CapturesThis */); + } + statements.push(constructorFunction); + } + /** + * Transforms the parameters of the constructor declaration of a class. + * + * @param constructor The constructor for the class. + * @param hasSynthesizedSuper A value indicating whether the constructor starts with a + * synthesized `super` call. + */ + function transformConstructorParameters(constructor, hasSynthesizedSuper) { + // If the TypeScript transformer needed to synthesize a constructor for property + // initializers, it would have also added a synthetic `...args` parameter and + // `super` call. + // If this is the case, we do not include the synthetic `...args` parameter and + // will instead use the `arguments` object in ES5/3. + if (constructor && !hasSynthesizedSuper) { + return ts.visitNodes(constructor.parameters, visitor, ts.isParameter); + } + return []; + } + /** + * Transforms the body of a constructor declaration of a class. + * + * @param constructor The constructor for the class. + * @param node The node which contains the constructor. + * @param extendsClauseElement The expression for the class `extends` clause. + * @param hasSynthesizedSuper A value indicating whether the constructor starts with a + * synthesized `super` call. + */ + function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { + var statements = []; + startLexicalEnvironment(); + var statementOffset = -1; + if (hasSynthesizedSuper) { + // If a super call has already been synthesized, + // we're going to assume that we should just transform everything after that. + // The assumption is that no prior step in the pipeline has added any prologue directives. + statementOffset = 1; + } + else if (constructor) { + // Otherwise, try to emit all potential prologue directives first. + statementOffset = ts.addPrologueDirectives(statements, constructor.body.statements, /*ensureUseStrict*/ false, visitor); + } + if (constructor) { + addDefaultValueAssignmentsIfNeeded(statements, constructor); + addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); + ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); + } + var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, !!extendsClauseElement, hasSynthesizedSuper, statementOffset); + // The last statement expression was replaced. Skip it. + if (superCaptureStatus === 1 /* ReplaceSuperCapture */ || superCaptureStatus === 2 /* ReplaceWithReturn */) { + statementOffset++; + } + if (constructor) { + var body = saveStateAndInvoke(constructor, function (constructor) { return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, /*start*/ statementOffset); }); + ts.addRange(statements, body); + } + // Return `_this` unless we're sure enough that it would be pointless to add a return statement. + // If there's a constructor that we can tell returns in enough places, then we *do not* want to add a return. + if (extendsClauseElement + && superCaptureStatus !== 2 /* ReplaceWithReturn */ + && !(constructor && isSufficientlyCoveredByReturnStatements(constructor.body))) { + statements.push(ts.createReturn(ts.createIdentifier("_this"))); + } + ts.addRange(statements, endLexicalEnvironment()); + var block = ts.createBlock(ts.createNodeArray(statements, + /*location*/ constructor ? constructor.body.statements : node.members), + /*location*/ constructor ? constructor.body : node, + /*multiLine*/ true); + if (!constructor) { + ts.setEmitFlags(block, 49152 /* NoComments */); + } + return block; + } + /** + * We want to try to avoid emitting a return statement in certain cases if a user already returned something. + * It would generate obviously dead code, so we'll try to make things a little bit prettier + * by doing a minimal check on whether some common patterns always explicitly return. + */ + function isSufficientlyCoveredByReturnStatements(statement) { + // A return statement is considered covered. + if (statement.kind === 212 /* ReturnStatement */) { + return true; + } + else if (statement.kind === 204 /* IfStatement */) { + var ifStatement = statement; + if (ifStatement.elseStatement) { + return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && + isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); + } + } + else if (statement.kind === 200 /* Block */) { + var lastStatement = ts.lastOrUndefined(statement.statements); + if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { + return true; + } + } + return false; + } + /** + * Declares a `_this` variable for derived classes and for when arrow functions capture `this`. + * + * @returns The new statement offset into the `statements` array. + */ + function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, hasExtendsClause, hasSynthesizedSuper, statementOffset) { + // If this isn't a derived class, just capture 'this' for arrow functions if necessary. + if (!hasExtendsClause) { + if (ctor) { + addCaptureThisForNodeIfNeeded(statements, ctor); + } + return 0 /* NoReplacement */; + } + // We must be here because the user didn't write a constructor + // but we needed to call 'super(...args)' anyway as per 14.5.14 of the ES2016 spec. + // If that's the case we can just immediately return the result of a 'super()' call. + if (!ctor) { + statements.push(ts.createReturn(createDefaultSuperCallOrThis())); + return 2 /* ReplaceWithReturn */; + } + // The constructor exists, but it and the 'super()' call it contains were generated + // for something like property initializers. + // Create a captured '_this' variable and assume it will subsequently be used. + if (hasSynthesizedSuper) { + captureThisForNode(statements, ctor, createDefaultSuperCallOrThis()); + enableSubstitutionsForCapturedThis(); + return 1 /* ReplaceSuperCapture */; + } + // Most of the time, a 'super' call will be the first real statement in a constructor body. + // In these cases, we'd like to transform these into a *single* statement instead of a declaration + // followed by an assignment statement for '_this'. For instance, if we emitted without an initializer, + // we'd get: + // + // var _this; + // _this = _super.call(...) || this; + // + // instead of + // + // var _this = _super.call(...) || this; + // + // Additionally, if the 'super()' call is the last statement, we should just avoid capturing + // entirely and immediately return the result like so: + // + // return _super.call(...) || this; + // + var firstStatement; + var superCallExpression; + var ctorStatements = ctor.body.statements; + if (statementOffset < ctorStatements.length) { + firstStatement = ctorStatements[statementOffset]; + if (firstStatement.kind === 203 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { + var superCall = firstStatement.expression; + superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); + } + } + // Return the result if we have an immediate super() call on the last statement. + if (superCallExpression && statementOffset === ctorStatements.length - 1) { + statements.push(ts.createReturn(superCallExpression)); + return 2 /* ReplaceWithReturn */; + } + // Perform the capture. + captureThisForNode(statements, ctor, superCallExpression, firstStatement); + // If we're actually replacing the original statement, we need to signal this to the caller. + if (superCallExpression) { + return 1 /* ReplaceSuperCapture */; + } + return 0 /* NoReplacement */; + } + function createDefaultSuperCallOrThis() { + var actualThis = ts.createThis(); + ts.setEmitFlags(actualThis, 128 /* NoSubstitution */); + var superCall = ts.createFunctionApply(ts.createIdentifier("_super"), actualThis, ts.createIdentifier("arguments")); + return ts.createLogicalOr(superCall, actualThis); + } + /** + * Visits a parameter declaration. + * + * @param node A ParameterDeclaration node. + */ + function visitParameter(node) { + if (node.dotDotDotToken) { + // rest parameters are elided + return undefined; + } + else if (ts.isBindingPattern(node.name)) { + // Binding patterns are converted into a generated name and are + // evaluated inside the function body. + return ts.setOriginalNode(ts.createParameter(ts.getGeneratedNameForNode(node), + /*initializer*/ undefined, + /*location*/ node), + /*original*/ node); + } + else if (node.initializer) { + // Initializers are elided + return ts.setOriginalNode(ts.createParameter(node.name, + /*initializer*/ undefined, + /*location*/ node), + /*original*/ node); + } + else { + return node; + } + } + /** + * Gets a value indicating whether we need to add default value assignments for a + * function-like node. + * + * @param node A function-like node. + */ + function shouldAddDefaultValueAssignments(node) { + return (node.transformFlags & 262144 /* ContainsDefaultValueAssignments */) !== 0; + } + /** + * Adds statements to the body of a function-like node if it contains parameters with + * binding patterns or initializers. + * + * @param statements The statements for the new function body. + * @param node A function-like node. + */ + function addDefaultValueAssignmentsIfNeeded(statements, node) { + if (!shouldAddDefaultValueAssignments(node)) { + return; + } + for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { + var parameter = _a[_i]; + var name_32 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; + // A rest parameter cannot have a binding pattern or an initializer, + // so let's just ignore it. + if (dotDotDotToken) { + continue; + } + if (ts.isBindingPattern(name_32)) { + addDefaultValueAssignmentForBindingPattern(statements, parameter, name_32, initializer); + } + else if (initializer) { + addDefaultValueAssignmentForInitializer(statements, parameter, name_32, initializer); + } + } + } + /** + * Adds statements to the body of a function-like node for parameters with binding patterns + * + * @param statements The statements for the new function body. + * @param parameter The parameter for the function. + * @param name The name of the parameter. + * @param initializer The initializer for the parameter. + */ + function addDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer) { + var temp = ts.getGeneratedNameForNode(parameter); + // In cases where a binding pattern is simply '[]' or '{}', + // we usually don't want to emit a var declaration; however, in the presence + // of an initializer, we must emit that expression to preserve side effects. + if (name.elements.length > 0) { + statements.push(ts.setEmitFlags(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList(ts.flattenParameterDestructuring(parameter, temp, visitor))), 8388608 /* CustomPrologue */)); + } + else if (initializer) { + statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 8388608 /* CustomPrologue */)); + } + } + /** + * Adds statements to the body of a function-like node for parameters with initializers. + * + * @param statements The statements for the new function body. + * @param parameter The parameter for the function. + * @param name The name of the parameter. + * @param initializer The initializer for the parameter. + */ + function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) { + initializer = ts.visitNode(initializer, visitor, ts.isExpression); + var statement = ts.createIf(ts.createStrictEquality(ts.getSynthesizedClone(name), ts.createVoidZero()), ts.setEmitFlags(ts.createBlock([ + ts.createStatement(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 1536 /* NoSourceMap */), ts.setEmitFlags(initializer, 1536 /* NoSourceMap */ | ts.getEmitFlags(initializer)), + /*location*/ parameter)) + ], /*location*/ parameter), 32 /* SingleLine */ | 1024 /* NoTrailingSourceMap */ | 12288 /* NoTokenSourceMaps */), + /*elseStatement*/ undefined, + /*location*/ parameter); + statement.startsOnNewLine = true; + ts.setEmitFlags(statement, 12288 /* NoTokenSourceMaps */ | 1024 /* NoTrailingSourceMap */ | 8388608 /* CustomPrologue */); + statements.push(statement); + } + /** + * Gets a value indicating whether we need to add statements to handle a rest parameter. + * + * @param node A ParameterDeclaration node. + * @param inConstructorWithSynthesizedSuper A value indicating whether the parameter is + * part of a constructor declaration with a + * synthesized call to `super` + */ + function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) { + return node && node.dotDotDotToken && node.name.kind === 70 /* Identifier */ && !inConstructorWithSynthesizedSuper; + } + /** + * Adds statements to the body of a function-like node if it contains a rest parameter. + * + * @param statements The statements for the new function body. + * @param node A function-like node. + * @param inConstructorWithSynthesizedSuper A value indicating whether the parameter is + * part of a constructor declaration with a + * synthesized call to `super` + */ + function addRestParameterIfNeeded(statements, node, inConstructorWithSynthesizedSuper) { + var parameter = ts.lastOrUndefined(node.parameters); + if (!shouldAddRestParameter(parameter, inConstructorWithSynthesizedSuper)) { + return; + } + // `declarationName` is the name of the local declaration for the parameter. + var declarationName = ts.getMutableClone(parameter.name); + ts.setEmitFlags(declarationName, 1536 /* NoSourceMap */); + // `expressionName` is the name of the parameter used in expressions. + var expressionName = ts.getSynthesizedClone(parameter.name); + var restIndex = node.parameters.length - 1; + var temp = ts.createLoopVariable(); + // var param = []; + statements.push(ts.setEmitFlags(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(declarationName, + /*type*/ undefined, ts.createArrayLiteral([])) + ]), + /*location*/ parameter), 8388608 /* CustomPrologue */)); + // for (var _i = restIndex; _i < arguments.length; _i++) { + // param[_i - restIndex] = arguments[_i]; + // } + var forStatement = ts.createFor(ts.createVariableDeclarationList([ + ts.createVariableDeclaration(temp, /*type*/ undefined, ts.createLiteral(restIndex)) + ], /*location*/ parameter), ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length"), + /*location*/ parameter), ts.createPostfixIncrement(temp, /*location*/ parameter), ts.createBlock([ + ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp)), + /*location*/ parameter)) + ])); + ts.setEmitFlags(forStatement, 8388608 /* CustomPrologue */); + ts.startOnNewLine(forStatement); + statements.push(forStatement); + } + /** + * Adds a statement to capture the `this` of a function declaration if it is needed. + * + * @param statements The statements for the new function body. + * @param node A node. + */ + function addCaptureThisForNodeIfNeeded(statements, node) { + if (node.transformFlags & 65536 /* ContainsCapturedLexicalThis */ && node.kind !== 181 /* ArrowFunction */) { + captureThisForNode(statements, node, ts.createThis()); + } + } + function captureThisForNode(statements, node, initializer, originalStatement) { + enableSubstitutionsForCapturedThis(); + var captureThisStatement = ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration("_this", + /*type*/ undefined, initializer) + ]), originalStatement); + ts.setEmitFlags(captureThisStatement, 49152 /* NoComments */ | 8388608 /* CustomPrologue */); + ts.setSourceMapRange(captureThisStatement, node); + statements.push(captureThisStatement); + } + /** + * Adds statements to the class body function for a class to define the members of the + * class. + * + * @param statements The statements for the class body function. + * @param node The ClassExpression or ClassDeclaration node. + */ + function addClassMembers(statements, node) { + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + switch (member.kind) { + case 199 /* SemicolonClassElement */: + statements.push(transformSemicolonClassElementToStatement(member)); + break; + case 148 /* MethodDeclaration */: + statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member)); + break; + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + var accessors = ts.getAllAccessorDeclarations(node.members, member); + if (member === accessors.firstAccessor) { + statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors)); + } + break; + case 149 /* Constructor */: + // Constructors are handled in visitClassExpression/visitClassDeclaration + break; + default: + ts.Debug.failBadSyntaxKind(node); + break; + } + } + } + /** + * Transforms a SemicolonClassElement into a statement for a class body function. + * + * @param member The SemicolonClassElement node. + */ + function transformSemicolonClassElementToStatement(member) { + return ts.createEmptyStatement(/*location*/ member); + } + /** + * Transforms a MethodDeclaration into a statement for a class body function. + * + * @param receiver The receiver for the member. + * @param member The MethodDeclaration node. + */ + function transformClassMethodDeclarationToStatement(receiver, member) { + var commentRange = ts.getCommentRange(member); + var sourceMapRange = ts.getSourceMapRange(member); + var func = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined); + ts.setEmitFlags(func, 49152 /* NoComments */); + ts.setSourceMapRange(func, sourceMapRange); + var statement = ts.createStatement(ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), + /*location*/ member.name), func), + /*location*/ member); + ts.setOriginalNode(statement, member); + ts.setCommentRange(statement, commentRange); + // The location for the statement is used to emit comments only. + // No source map should be emitted for this statement to align with the + // old emitter. + ts.setEmitFlags(statement, 1536 /* NoSourceMap */); + return statement; + } + /** + * Transforms a set of related of get/set accessors into a statement for a class body function. + * + * @param receiver The receiver for the member. + * @param accessors The set of related get/set accessors. + */ + function transformAccessorsToStatement(receiver, accessors) { + var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, /*startsOnNewLine*/ false), + /*location*/ ts.getSourceMapRange(accessors.firstAccessor)); + // The location for the statement is used to emit source maps only. + // No comments should be emitted for this statement to align with the + // old emitter. + ts.setEmitFlags(statement, 49152 /* NoComments */); + return statement; + } + /** + * Transforms a set of related get/set accessors into an expression for either a class + * body function or an ObjectLiteralExpression with computed properties. + * + * @param receiver The receiver for the member. + */ + function transformAccessorsToExpression(receiver, _a, startsOnNewLine) { + var firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; + // To align with source maps in the old emitter, the receiver and property name + // arguments are both mapped contiguously to the accessor name. + var target = ts.getMutableClone(receiver); + ts.setEmitFlags(target, 49152 /* NoComments */ | 1024 /* NoTrailingSourceMap */); + ts.setSourceMapRange(target, firstAccessor.name); + var propertyName = ts.createExpressionForPropertyName(ts.visitNode(firstAccessor.name, visitor, ts.isPropertyName)); + ts.setEmitFlags(propertyName, 49152 /* NoComments */ | 512 /* NoLeadingSourceMap */); + ts.setSourceMapRange(propertyName, firstAccessor.name); + var properties = []; + if (getAccessor) { + var getterFunction = transformFunctionLikeToExpression(getAccessor, /*location*/ undefined, /*name*/ undefined); + ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); + ts.setEmitFlags(getterFunction, 16384 /* NoLeadingComments */); + var getter = ts.createPropertyAssignment("get", getterFunction); + ts.setCommentRange(getter, ts.getCommentRange(getAccessor)); + properties.push(getter); + } + if (setAccessor) { + var setterFunction = transformFunctionLikeToExpression(setAccessor, /*location*/ undefined, /*name*/ undefined); + ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); + ts.setEmitFlags(setterFunction, 16384 /* NoLeadingComments */); + var setter = ts.createPropertyAssignment("set", setterFunction); + ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); + properties.push(setter); + } + properties.push(ts.createPropertyAssignment("enumerable", ts.createLiteral(true)), ts.createPropertyAssignment("configurable", ts.createLiteral(true))); + var call = ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), + /*typeArguments*/ undefined, [ + target, + propertyName, + ts.createObjectLiteral(properties, /*location*/ undefined, /*multiLine*/ true) + ]); + if (startsOnNewLine) { + call.startsOnNewLine = true; + } + return call; + } + /** + * Visits an ArrowFunction and transforms it into a FunctionExpression. + * + * @param node An ArrowFunction node. + */ + function visitArrowFunction(node) { + if (node.transformFlags & 32768 /* ContainsLexicalThis */) { + enableSubstitutionsForCapturedThis(); + } + var func = transformFunctionLikeToExpression(node, /*location*/ node, /*name*/ undefined); + ts.setEmitFlags(func, 256 /* CapturesThis */); + return func; + } + /** + * Visits a FunctionExpression node. + * + * @param node a FunctionExpression node. + */ + function visitFunctionExpression(node) { + return transformFunctionLikeToExpression(node, /*location*/ node, node.name); + } + /** + * Visits a FunctionDeclaration node. + * + * @param node a FunctionDeclaration node. + */ + function visitFunctionDeclaration(node) { + return ts.setOriginalNode(ts.createFunctionDeclaration( + /*decorators*/ undefined, node.modifiers, node.asteriskToken, node.name, + /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), + /*type*/ undefined, transformFunctionBody(node), + /*location*/ node), + /*original*/ node); + } + /** + * Transforms a function-like node into a FunctionExpression. + * + * @param node The function-like node to transform. + * @param location The source-map location for the new FunctionExpression. + * @param name The name of the new FunctionExpression. + */ + function transformFunctionLikeToExpression(node, location, name) { + var savedContainingNonArrowFunction = enclosingNonArrowFunction; + if (node.kind !== 181 /* ArrowFunction */) { + enclosingNonArrowFunction = node; + } + var expression = ts.setOriginalNode(ts.createFunctionExpression( + /*modifiers*/ undefined, node.asteriskToken, name, + /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), + /*type*/ undefined, saveStateAndInvoke(node, transformFunctionBody), location), + /*original*/ node); + enclosingNonArrowFunction = savedContainingNonArrowFunction; + return expression; + } + /** + * Transforms the body of a function-like node. + * + * @param node A function-like node. + */ + function transformFunctionBody(node) { + var multiLine = false; // indicates whether the block *must* be emitted as multiple lines + var singleLine = false; // indicates whether the block *may* be emitted as a single line + var statementsLocation; + var closeBraceLocation; + var statements = []; + var body = node.body; + var statementOffset; + startLexicalEnvironment(); + if (ts.isBlock(body)) { + // ensureUseStrict is false because no new prologue-directive should be added. + // addPrologueDirectives will simply put already-existing directives at the beginning of the target statement-array + statementOffset = ts.addPrologueDirectives(statements, body.statements, /*ensureUseStrict*/ false, visitor); + } + addCaptureThisForNodeIfNeeded(statements, node); + addDefaultValueAssignmentsIfNeeded(statements, node); + addRestParameterIfNeeded(statements, node, /*inConstructorWithSynthesizedSuper*/ false); + // If we added any generated statements, this must be a multi-line block. + if (!multiLine && statements.length > 0) { + multiLine = true; + } + if (ts.isBlock(body)) { + statementsLocation = body.statements; + ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, statementOffset)); + // If the original body was a multi-line block, this must be a multi-line block. + if (!multiLine && body.multiLine) { + multiLine = true; + } + } + else { + ts.Debug.assert(node.kind === 181 /* ArrowFunction */); + // To align with the old emitter, we use a synthetic end position on the location + // for the statement list we synthesize when we down-level an arrow function with + // an expression function body. This prevents both comments and source maps from + // being emitted for the end position only. + statementsLocation = ts.moveRangeEnd(body, -1); + var equalsGreaterThanToken = node.equalsGreaterThanToken; + if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { + if (ts.rangeEndIsOnSameLineAsRangeStart(equalsGreaterThanToken, body, currentSourceFile)) { + singleLine = true; + } + else { + multiLine = true; + } + } + var expression = ts.visitNode(body, visitor, ts.isExpression); + var returnStatement = ts.createReturn(expression, /*location*/ body); + ts.setEmitFlags(returnStatement, 12288 /* NoTokenSourceMaps */ | 1024 /* NoTrailingSourceMap */ | 32768 /* NoTrailingComments */); + statements.push(returnStatement); + // To align with the source map emit for the old emitter, we set a custom + // source map location for the close brace. + closeBraceLocation = body; + } + var lexicalEnvironment = endLexicalEnvironment(); + ts.addRange(statements, lexicalEnvironment); + // If we added any final generated statements, this must be a multi-line block + if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { + multiLine = true; + } + var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), node.body, multiLine); + if (!multiLine && singleLine) { + ts.setEmitFlags(block, 32 /* SingleLine */); + } + if (closeBraceLocation) { + ts.setTokenSourceMapRange(block, 17 /* CloseBraceToken */, closeBraceLocation); + } + ts.setOriginalNode(block, node.body); + return block; + } + /** + * Visits an ExpressionStatement that contains a destructuring assignment. + * + * @param node An ExpressionStatement node. + */ + function visitExpressionStatement(node) { + // If we are here it is most likely because our expression is a destructuring assignment. + switch (node.expression.kind) { + case 179 /* ParenthesizedExpression */: + return ts.updateStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); + case 188 /* BinaryExpression */: + return ts.updateStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); + } + return ts.visitEachChild(node, visitor, context); + } + /** + * Visits a ParenthesizedExpression that may contain a destructuring assignment. + * + * @param node A ParenthesizedExpression node. + * @param needsDestructuringValue A value indicating whether we need to hold onto the rhs + * of a destructuring assignment. + */ + function visitParenthesizedExpression(node, needsDestructuringValue) { + // If we are here it is most likely because our expression is a destructuring assignment. + if (needsDestructuringValue) { + switch (node.expression.kind) { + case 179 /* ParenthesizedExpression */: + return ts.createParen(visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ true), + /*location*/ node); + case 188 /* BinaryExpression */: + return ts.createParen(visitBinaryExpression(node.expression, /*needsDestructuringValue*/ true), + /*location*/ node); + } + } + return ts.visitEachChild(node, visitor, context); + } + /** + * Visits a BinaryExpression that contains a destructuring assignment. + * + * @param node A BinaryExpression node. + * @param needsDestructuringValue A value indicating whether we need to hold onto the rhs + * of a destructuring assignment. + */ + function visitBinaryExpression(node, needsDestructuringValue) { + // If we are here it is because this is a destructuring assignment. + ts.Debug.assert(ts.isDestructuringAssignment(node)); + return ts.flattenDestructuringAssignment(context, node, needsDestructuringValue, hoistVariableDeclaration, visitor); + } + function visitVariableStatement(node) { + if (convertedLoopState && (ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */) == 0) { + // we are inside a converted loop - hoist variable declarations + var assignments = void 0; + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + hoistVariableDeclarationDeclaredInConvertedLoop(convertedLoopState, decl); + if (decl.initializer) { + var assignment = void 0; + if (ts.isBindingPattern(decl.name)) { + assignment = ts.flattenVariableDestructuringToExpression(decl, hoistVariableDeclaration, /*nameSubstitution*/ undefined, visitor); + } + else { + assignment = ts.createBinary(decl.name, 57 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + } + (assignments || (assignments = [])).push(assignment); + } + } + if (assignments) { + return ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25 /* CommaToken */, acc); }), node); + } + else { + // none of declarations has initializer - the entire variable statement can be deleted + return undefined; + } + } + return ts.visitEachChild(node, visitor, context); + } + /** + * Visits a VariableDeclarationList that is block scoped (e.g. `let` or `const`). + * + * @param node A VariableDeclarationList node. + */ + function visitVariableDeclarationList(node) { + if (node.flags & 3 /* BlockScoped */) { + enableSubstitutionsForBlockScopedBindings(); + } + var declarations = ts.flatten(ts.map(node.declarations, node.flags & 1 /* Let */ + ? visitVariableDeclarationInLetDeclarationList + : visitVariableDeclaration)); + var declarationList = ts.createVariableDeclarationList(declarations, /*location*/ node); + ts.setOriginalNode(declarationList, node); + ts.setCommentRange(declarationList, node); + if (node.transformFlags & 8388608 /* ContainsBindingPattern */ + && (ts.isBindingPattern(node.declarations[0].name) + || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { + // If the first or last declaration is a binding pattern, we need to modify + // the source map range for the declaration list. + var firstDeclaration = ts.firstOrUndefined(declarations); + var lastDeclaration = ts.lastOrUndefined(declarations); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + } + return declarationList; + } + /** + * Gets a value indicating whether we should emit an explicit initializer for a variable + * declaration in a `let` declaration list. + * + * @param node A VariableDeclaration node. + */ + function shouldEmitExplicitInitializerForLetDeclaration(node) { + // Nested let bindings might need to be initialized explicitly to preserve + // ES6 semantic: + // + // { let x = 1; } + // { let x; } // x here should be undefined. not 1 + // + // Top level bindings never collide with anything and thus don't require + // explicit initialization. As for nested let bindings there are two cases: + // + // - Nested let bindings that were not renamed definitely should be + // initialized explicitly: + // + // { let x = 1; } + // { let x; if (some-condition) { x = 1}; if (x) { /*1*/ } } + // + // Without explicit initialization code in /*1*/ can be executed even if + // some-condition is evaluated to false. + // + // - Renaming introduces fresh name that should not collide with any + // existing names, however renamed bindings sometimes also should be + // explicitly initialized. One particular case: non-captured binding + // declared inside loop body (but not in loop initializer): + // + // let x; + // for (;;) { + // let x; + // } + // + // In downlevel codegen inner 'x' will be renamed so it won't collide + // with outer 'x' however it will should be reset on every iteration as + // if it was declared anew. + // + // * Why non-captured binding? + // - Because if loop contains block scoped binding captured in some + // function then loop body will be rewritten to have a fresh scope + // on every iteration so everything will just work. + // + // * Why loop initializer is excluded? + // - Since we've introduced a fresh name it already will be undefined. + var flags = resolver.getNodeCheckFlags(node); + var isCapturedInFunction = flags & 131072 /* CapturedBlockScopedBinding */; + var isDeclaredInLoop = flags & 262144 /* BlockScopedBindingInLoop */; + var emittedAsTopLevel = ts.isBlockScopedContainerTopLevel(enclosingBlockScopeContainer) + || (isCapturedInFunction + && isDeclaredInLoop + && ts.isBlock(enclosingBlockScopeContainer) + && ts.isIterationStatement(enclosingBlockScopeContainerParent, /*lookInLabeledStatements*/ false)); + var emitExplicitInitializer = !emittedAsTopLevel + && enclosingBlockScopeContainer.kind !== 208 /* ForInStatement */ + && enclosingBlockScopeContainer.kind !== 209 /* ForOfStatement */ + && (!resolver.isDeclarationWithCollidingName(node) + || (isDeclaredInLoop + && !isCapturedInFunction + && !ts.isIterationStatement(enclosingBlockScopeContainer, /*lookInLabeledStatements*/ false))); + return emitExplicitInitializer; + } + /** + * Visits a VariableDeclaration in a `let` declaration list. + * + * @param node A VariableDeclaration node. + */ + function visitVariableDeclarationInLetDeclarationList(node) { + // For binding pattern names that lack initializers there is no point to emit + // explicit initializer since downlevel codegen for destructuring will fail + // in the absence of initializer so all binding elements will say uninitialized + var name = node.name; + if (ts.isBindingPattern(name)) { + return visitVariableDeclaration(node); + } + if (!node.initializer && shouldEmitExplicitInitializerForLetDeclaration(node)) { + var clone_5 = ts.getMutableClone(node); + clone_5.initializer = ts.createVoidZero(); + return clone_5; + } + return ts.visitEachChild(node, visitor, context); + } + /** + * Visits a VariableDeclaration node with a binding pattern. + * + * @param node A VariableDeclaration node. + */ + function visitVariableDeclaration(node) { + // If we are here it is because the name contains a binding pattern. + if (ts.isBindingPattern(node.name)) { + var recordTempVariablesInLine = !enclosingVariableStatement + || !ts.hasModifier(enclosingVariableStatement, 1 /* Export */); + return ts.flattenVariableDestructuring(node, /*value*/ undefined, visitor, recordTempVariablesInLine ? undefined : hoistVariableDeclaration); + } + return ts.visitEachChild(node, visitor, context); + } + function visitLabeledStatement(node) { + if (convertedLoopState) { + if (!convertedLoopState.labels) { + convertedLoopState.labels = ts.createMap(); + } + convertedLoopState.labels[node.label.text] = node.label.text; + } + var result; + if (ts.isIterationStatement(node.statement, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node.statement)) { + result = ts.visitNodes(ts.createNodeArray([node.statement]), visitor, ts.isStatement); + } + else { + result = ts.visitEachChild(node, visitor, context); + } + if (convertedLoopState) { + convertedLoopState.labels[node.label.text] = undefined; + } + return result; + } + function visitDoStatement(node) { + return convertIterationStatementBodyIfNecessary(node); + } + function visitWhileStatement(node) { + return convertIterationStatementBodyIfNecessary(node); + } + function visitForStatement(node) { + return convertIterationStatementBodyIfNecessary(node); + } + function visitForInStatement(node) { + return convertIterationStatementBodyIfNecessary(node); + } + /** + * Visits a ForOfStatement and converts it into a compatible ForStatement. + * + * @param node A ForOfStatement. + */ + function visitForOfStatement(node) { + return convertIterationStatementBodyIfNecessary(node, convertForOfToFor); + } + function convertForOfToFor(node, convertedLoopBodyStatements) { + // The following ES6 code: + // + // for (let v of expr) { } + // + // should be emitted as + // + // for (var _i = 0, _a = expr; _i < _a.length; _i++) { + // var v = _a[_i]; + // } + // + // where _a and _i are temps emitted to capture the RHS and the counter, + // respectively. + // When the left hand side is an expression instead of a let declaration, + // the "let v" is not emitted. + // When the left hand side is a let/const, the v is renamed if there is + // another v in scope. + // Note that all assignments to the LHS are emitted in the body, including + // all destructuring. + // Note also that because an extra statement is needed to assign to the LHS, + // for-of bodies are always emitted as blocks. + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + var initializer = node.initializer; + var statements = []; + // In the case where the user wrote an identifier as the RHS, like this: + // + // for (let v of arr) { } + // + // we don't want to emit a temporary variable for the RHS, just use it directly. + var counter = ts.createLoopVariable(); + var rhsReference = expression.kind === 70 /* Identifier */ + ? ts.createUniqueName(expression.text) + : ts.createTempVariable(/*recordTempVariable*/ undefined); + // Initialize LHS + // var v = _a[_i]; + if (ts.isVariableDeclarationList(initializer)) { + if (initializer.flags & 3 /* BlockScoped */) { + enableSubstitutionsForBlockScopedBindings(); + } + var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); + if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { + // This works whether the declaration is a var, let, or const. + // It will use rhsIterationValue _a[_i] as the initializer. + var declarations = ts.flattenVariableDestructuring(firstOriginalDeclaration, ts.createElementAccess(rhsReference, counter), visitor); + var declarationList = ts.createVariableDeclarationList(declarations, /*location*/ initializer); + ts.setOriginalNode(declarationList, initializer); + // Adjust the source map range for the first declaration to align with the old + // emitter. + var firstDeclaration = declarations[0]; + var lastDeclaration = ts.lastOrUndefined(declarations); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + statements.push(ts.createVariableStatement( + /*modifiers*/ undefined, declarationList)); + } + else { + // The following call does not include the initializer, so we have + // to emit it separately. + statements.push(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(/*recordTempVariable*/ undefined), + /*type*/ undefined, ts.createElementAccess(rhsReference, counter)) + ], /*location*/ ts.moveRangePos(initializer, -1)), + /*location*/ ts.moveRangeEnd(initializer, -1))); + } + } + else { + // Initializer is an expression. Emit the expression in the body, so that it's + // evaluated on every iteration. + var assignment = ts.createAssignment(initializer, ts.createElementAccess(rhsReference, counter)); + if (ts.isDestructuringAssignment(assignment)) { + // This is a destructuring pattern, so we flatten the destructuring instead. + statements.push(ts.createStatement(ts.flattenDestructuringAssignment(context, assignment, + /*needsValue*/ false, hoistVariableDeclaration, visitor))); + } + else { + // Currently there is not way to check that assignment is binary expression of destructing assignment + // so we have to cast never type to binaryExpression + assignment.end = initializer.end; + statements.push(ts.createStatement(assignment, /*location*/ ts.moveRangeEnd(initializer, -1))); + } + } + var bodyLocation; + var statementsLocation; + if (convertedLoopBodyStatements) { + ts.addRange(statements, convertedLoopBodyStatements); + } + else { + var statement = ts.visitNode(node.statement, visitor, ts.isStatement); + if (ts.isBlock(statement)) { + ts.addRange(statements, statement.statements); + bodyLocation = statement; + statementsLocation = statement.statements; + } + else { + statements.push(statement); + } + } + // The old emitter does not emit source maps for the expression + ts.setEmitFlags(expression, 1536 /* NoSourceMap */ | ts.getEmitFlags(expression)); + // The old emitter does not emit source maps for the block. + // We add the location to preserve comments. + var body = ts.createBlock(ts.createNodeArray(statements, /*location*/ statementsLocation), + /*location*/ bodyLocation); + ts.setEmitFlags(body, 1536 /* NoSourceMap */ | 12288 /* NoTokenSourceMaps */); + var forStatement = ts.createFor(ts.createVariableDeclarationList([ + ts.createVariableDeclaration(counter, /*type*/ undefined, ts.createLiteral(0), /*location*/ ts.moveRangePos(node.expression, -1)), + ts.createVariableDeclaration(rhsReference, /*type*/ undefined, expression, /*location*/ node.expression) + ], /*location*/ node.expression), ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length"), + /*location*/ node.expression), ts.createPostfixIncrement(counter, /*location*/ node.expression), body, + /*location*/ node); + // Disable trailing source maps for the OpenParenToken to align source map emit with the old emitter. + ts.setEmitFlags(forStatement, 8192 /* NoTokenTrailingSourceMaps */); + return forStatement; + } + /** + * Visits an ObjectLiteralExpression with computed propety names. + * + * @param node An ObjectLiteralExpression node. + */ + function visitObjectLiteralExpression(node) { + // We are here because a ComputedPropertyName was used somewhere in the expression. + var properties = node.properties; + var numProperties = properties.length; + // Find the first computed property. + // Everything until that point can be emitted as part of the initial object literal. + var numInitialProperties = numProperties; + for (var i = 0; i < numProperties; i++) { + var property = properties[i]; + if (property.transformFlags & 16777216 /* ContainsYield */ + || property.name.kind === 141 /* ComputedPropertyName */) { + numInitialProperties = i; + break; + } + } + ts.Debug.assert(numInitialProperties !== numProperties); + // For computed properties, we need to create a unique handle to the object + // literal so we can modify it without risking internal assignments tainting the object. + var temp = ts.createTempVariable(hoistVariableDeclaration); + // Write out the first non-computed properties, then emit the rest through indexing on the temp variable. + var expressions = []; + var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), + /*location*/ undefined, node.multiLine), 524288 /* Indented */)); + if (node.multiLine) { + assignment.startsOnNewLine = true; + } + expressions.push(assignment); + addObjectLiteralMembers(expressions, node, temp, numInitialProperties); + // We need to clone the temporary identifier so that we can write it on a + // new line + expressions.push(node.multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); + return ts.inlineExpressions(expressions); + } + function shouldConvertIterationStatementBody(node) { + return (resolver.getNodeCheckFlags(node) & 65536 /* LoopWithCapturedBlockScopedBinding */) !== 0; + } + /** + * Records constituents of name for the given variable to be hoisted in the outer scope. + */ + function hoistVariableDeclarationDeclaredInConvertedLoop(state, node) { + if (!state.hoistedLocalVariables) { + state.hoistedLocalVariables = []; + } + visit(node.name); + function visit(node) { + if (node.kind === 70 /* Identifier */) { + state.hoistedLocalVariables.push(node); + } + else { + for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!ts.isOmittedExpression(element)) { + visit(element.name); + } + } + } + } + } + function convertIterationStatementBodyIfNecessary(node, convert) { + if (!shouldConvertIterationStatementBody(node)) { + var saveAllowedNonLabeledJumps = void 0; + if (convertedLoopState) { + // we get here if we are trying to emit normal loop loop inside converted loop + // set allowedNonLabeledJumps to Break | Continue to mark that break\continue inside the loop should be emitted as is + saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; + convertedLoopState.allowedNonLabeledJumps = 2 /* Break */ | 4 /* Continue */; + } + var result = convert ? convert(node, /*convertedLoopBodyStatements*/ undefined) : ts.visitEachChild(node, visitor, context); + if (convertedLoopState) { + convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps; + } + return result; + } + var functionName = ts.createUniqueName("_loop"); + var loopInitializer; + switch (node.kind) { + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: + var initializer = node.initializer; + if (initializer && initializer.kind === 220 /* VariableDeclarationList */) { + loopInitializer = initializer; + } + break; + } + // variables that will be passed to the loop as parameters + var loopParameters = []; + // variables declared in the loop initializer that will be changed inside the loop + var loopOutParameters = []; + if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3 /* BlockScoped */)) { + for (var _i = 0, _a = loopInitializer.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + processLoopVariableDeclaration(decl, loopParameters, loopOutParameters); + } + } + var outerConvertedLoopState = convertedLoopState; + convertedLoopState = { loopOutParameters: loopOutParameters }; + if (outerConvertedLoopState) { + // convertedOuterLoopState !== undefined means that this converted loop is nested in another converted loop. + // if outer converted loop has already accumulated some state - pass it through + if (outerConvertedLoopState.argumentsName) { + // outer loop has already used 'arguments' so we've already have some name to alias it + // use the same name in all nested loops + convertedLoopState.argumentsName = outerConvertedLoopState.argumentsName; + } + if (outerConvertedLoopState.thisName) { + // outer loop has already used 'this' so we've already have some name to alias it + // use the same name in all nested loops + convertedLoopState.thisName = outerConvertedLoopState.thisName; + } + if (outerConvertedLoopState.hoistedLocalVariables) { + // we've already collected some non-block scoped variable declarations in enclosing loop + // use the same storage in nested loop + convertedLoopState.hoistedLocalVariables = outerConvertedLoopState.hoistedLocalVariables; + } + } + var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement); + var currentState = convertedLoopState; + convertedLoopState = outerConvertedLoopState; + if (loopOutParameters.length) { + var statements_3 = ts.isBlock(loopBody) ? loopBody.statements.slice() : [loopBody]; + copyOutParameters(loopOutParameters, 1 /* ToOutParameter */, statements_3); + loopBody = ts.createBlock(statements_3, /*location*/ undefined, /*multiline*/ true); + } + if (!ts.isBlock(loopBody)) { + loopBody = ts.createBlock([loopBody], /*location*/ undefined, /*multiline*/ true); + } + var isAsyncBlockContainingAwait = enclosingNonArrowFunction + && (ts.getEmitFlags(enclosingNonArrowFunction) & 2097152 /* AsyncFunctionBody */) !== 0 + && (node.statement.transformFlags & 16777216 /* ContainsYield */) !== 0; + var loopBodyFlags = 0; + if (currentState.containsLexicalThis) { + loopBodyFlags |= 256 /* CapturesThis */; + } + if (isAsyncBlockContainingAwait) { + loopBodyFlags |= 2097152 /* AsyncFunctionBody */; + } + var convertedLoopVariable = ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(functionName, + /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression( + /*modifiers*/ undefined, isAsyncBlockContainingAwait ? ts.createToken(38 /* AsteriskToken */) : undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, loopParameters, + /*type*/ undefined, loopBody), loopBodyFlags)) + ])); + var statements = [convertedLoopVariable]; + var extraVariableDeclarations; + // propagate state from the inner loop to the outer loop if necessary + if (currentState.argumentsName) { + // if alias for arguments is set + if (outerConvertedLoopState) { + // pass it to outer converted loop + outerConvertedLoopState.argumentsName = currentState.argumentsName; + } + else { + // this is top level converted loop and we need to create an alias for 'arguments' object + (extraVariableDeclarations || (extraVariableDeclarations = [])).push(ts.createVariableDeclaration(currentState.argumentsName, + /*type*/ undefined, ts.createIdentifier("arguments"))); + } + } + if (currentState.thisName) { + // if alias for this is set + if (outerConvertedLoopState) { + // pass it to outer converted loop + outerConvertedLoopState.thisName = currentState.thisName; + } + else { + // this is top level converted loop so we need to create an alias for 'this' here + // NOTE: + // if converted loops were all nested in arrow function then we'll always emit '_this' so convertedLoopState.thisName will not be set. + // If it is set this means that all nested loops are not nested in arrow function and it is safe to capture 'this'. + (extraVariableDeclarations || (extraVariableDeclarations = [])).push(ts.createVariableDeclaration(currentState.thisName, + /*type*/ undefined, ts.createIdentifier("this"))); + } + } + if (currentState.hoistedLocalVariables) { + // if hoistedLocalVariables !== undefined this means that we've possibly collected some variable declarations to be hoisted later + if (outerConvertedLoopState) { + // pass them to outer converted loop + outerConvertedLoopState.hoistedLocalVariables = currentState.hoistedLocalVariables; + } + else { + if (!extraVariableDeclarations) { + extraVariableDeclarations = []; + } + // hoist collected variable declarations + for (var _b = 0, _c = currentState.hoistedLocalVariables; _b < _c.length; _b++) { + var identifier = _c[_b]; + extraVariableDeclarations.push(ts.createVariableDeclaration(identifier)); + } + } + } + // add extra variables to hold out parameters if necessary + if (loopOutParameters.length) { + if (!extraVariableDeclarations) { + extraVariableDeclarations = []; + } + for (var _d = 0, loopOutParameters_1 = loopOutParameters; _d < loopOutParameters_1.length; _d++) { + var outParam = loopOutParameters_1[_d]; + extraVariableDeclarations.push(ts.createVariableDeclaration(outParam.outParamName)); + } + } + // create variable statement to hold all introduced variable declarations + if (extraVariableDeclarations) { + statements.push(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList(extraVariableDeclarations))); + } + var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, isAsyncBlockContainingAwait); + var loop; + if (convert) { + loop = convert(node, convertedLoopBodyStatements); + } + else { + loop = ts.getMutableClone(node); + // clean statement part + loop.statement = undefined; + // visit childnodes to transform initializer/condition/incrementor parts + loop = ts.visitEachChild(loop, visitor, context); + // set loop statement + loop.statement = ts.createBlock(convertedLoopBodyStatements, + /*location*/ undefined, + /*multiline*/ true); + // reset and re-aggregate the transform flags + loop.transformFlags = 0; + ts.aggregateTransformFlags(loop); + } + statements.push(currentParent.kind === 215 /* LabeledStatement */ + ? ts.createLabel(currentParent.label, loop) + : loop); + return statements; + } + function copyOutParameter(outParam, copyDirection) { + var source = copyDirection === 0 /* ToOriginal */ ? outParam.outParamName : outParam.originalName; + var target = copyDirection === 0 /* ToOriginal */ ? outParam.originalName : outParam.outParamName; + return ts.createBinary(target, 57 /* EqualsToken */, source); + } + function copyOutParameters(outParams, copyDirection, statements) { + for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { + var outParam = outParams_1[_i]; + statements.push(ts.createStatement(copyOutParameter(outParam, copyDirection))); + } + } + function generateCallToConvertedLoop(loopFunctionExpressionName, parameters, state, isAsyncBlockContainingAwait) { + var outerConvertedLoopState = convertedLoopState; + var statements = []; + // loop is considered simple if it does not have any return statements or break\continue that transfer control outside of the loop + // simple loops are emitted as just 'loop()'; + // NOTE: if loop uses only 'continue' it still will be emitted as simple loop + var isSimpleLoop = !(state.nonLocalJumps & ~4 /* Continue */) && + !state.labeledNonLocalBreaks && + !state.labeledNonLocalContinues; + var call = ts.createCall(loopFunctionExpressionName, /*typeArguments*/ undefined, ts.map(parameters, function (p) { return p.name; })); + var callResult = isAsyncBlockContainingAwait ? ts.createYield(ts.createToken(38 /* AsteriskToken */), call) : call; + if (isSimpleLoop) { + statements.push(ts.createStatement(callResult)); + copyOutParameters(state.loopOutParameters, 0 /* ToOriginal */, statements); + } + else { + var loopResultName = ts.createUniqueName("state"); + var stateVariable = ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ts.createVariableDeclaration(loopResultName, /*type*/ undefined, callResult)])); + statements.push(stateVariable); + copyOutParameters(state.loopOutParameters, 0 /* ToOriginal */, statements); + if (state.nonLocalJumps & 8 /* Return */) { + var returnStatement = void 0; + if (outerConvertedLoopState) { + outerConvertedLoopState.nonLocalJumps |= 8 /* Return */; + returnStatement = ts.createReturn(loopResultName); + } + else { + returnStatement = ts.createReturn(ts.createPropertyAccess(loopResultName, "value")); + } + statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 33 /* EqualsEqualsEqualsToken */, ts.createLiteral("object")), returnStatement)); + } + if (state.nonLocalJumps & 2 /* Break */) { + statements.push(ts.createIf(ts.createBinary(loopResultName, 33 /* EqualsEqualsEqualsToken */, ts.createLiteral("break")), ts.createBreak())); + } + if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { + var caseClauses = []; + processLabeledJumps(state.labeledNonLocalBreaks, /*isBreak*/ true, loopResultName, outerConvertedLoopState, caseClauses); + processLabeledJumps(state.labeledNonLocalContinues, /*isBreak*/ false, loopResultName, outerConvertedLoopState, caseClauses); + statements.push(ts.createSwitch(loopResultName, ts.createCaseBlock(caseClauses))); + } + } + return statements; + } + function setLabeledJump(state, isBreak, labelText, labelMarker) { + if (isBreak) { + if (!state.labeledNonLocalBreaks) { + state.labeledNonLocalBreaks = ts.createMap(); + } + state.labeledNonLocalBreaks[labelText] = labelMarker; + } + else { + if (!state.labeledNonLocalContinues) { + state.labeledNonLocalContinues = ts.createMap(); + } + state.labeledNonLocalContinues[labelText] = labelMarker; + } + } + function processLabeledJumps(table, isBreak, loopResultName, outerLoop, caseClauses) { + if (!table) { + return; + } + for (var labelText in table) { + var labelMarker = table[labelText]; + var statements = []; + // if there are no outer converted loop or outer label in question is located inside outer converted loop + // then emit labeled break\continue + // otherwise propagate pair 'label -> marker' to outer converted loop and emit 'return labelMarker' so outer loop can later decide what to do + if (!outerLoop || (outerLoop.labels && outerLoop.labels[labelText])) { + var label = ts.createIdentifier(labelText); + statements.push(isBreak ? ts.createBreak(label) : ts.createContinue(label)); + } + else { + setLabeledJump(outerLoop, isBreak, labelText, labelMarker); + statements.push(ts.createReturn(loopResultName)); + } + caseClauses.push(ts.createCaseClause(ts.createLiteral(labelMarker), statements)); + } + } + function processLoopVariableDeclaration(decl, loopParameters, loopOutParameters) { + var name = decl.name; + if (ts.isBindingPattern(name)) { + for (var _i = 0, _a = name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!ts.isOmittedExpression(element)) { + processLoopVariableDeclaration(element, loopParameters, loopOutParameters); + } + } + } + else { + loopParameters.push(ts.createParameter(name)); + if (resolver.getNodeCheckFlags(decl) & 2097152 /* NeedsLoopOutParameter */) { + var outParamName = ts.createUniqueName("out_" + name.text); + loopOutParameters.push({ originalName: name, outParamName: outParamName }); + } + } + } + /** + * Adds the members of an object literal to an array of expressions. + * + * @param expressions An array of expressions. + * @param node An ObjectLiteralExpression node. + * @param receiver The receiver for members of the ObjectLiteralExpression. + * @param numInitialNonComputedProperties The number of initial properties without + * computed property names. + */ + function addObjectLiteralMembers(expressions, node, receiver, start) { + var properties = node.properties; + var numProperties = properties.length; + for (var i = start; i < numProperties; i++) { + var property = properties[i]; + switch (property.kind) { + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + var accessors = ts.getAllAccessorDeclarations(node.properties, property); + if (property === accessors.firstAccessor) { + expressions.push(transformAccessorsToExpression(receiver, accessors, node.multiLine)); + } + break; + case 253 /* PropertyAssignment */: + expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); + break; + case 254 /* ShorthandPropertyAssignment */: + expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); + break; + case 148 /* MethodDeclaration */: + expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node.multiLine)); + break; + default: + ts.Debug.failBadSyntaxKind(node); + break; + } + } + } + /** + * Transforms a PropertyAssignment node into an expression. + * + * @param node The ObjectLiteralExpression that contains the PropertyAssignment. + * @param property The PropertyAssignment node. + * @param receiver The receiver for the assignment. + */ + function transformPropertyAssignmentToExpression(property, receiver, startsOnNewLine) { + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.visitNode(property.initializer, visitor, ts.isExpression), + /*location*/ property); + if (startsOnNewLine) { + expression.startsOnNewLine = true; + } + return expression; + } + /** + * Transforms a ShorthandPropertyAssignment node into an expression. + * + * @param node The ObjectLiteralExpression that contains the ShorthandPropertyAssignment. + * @param property The ShorthandPropertyAssignment node. + * @param receiver The receiver for the assignment. + */ + function transformShorthandPropertyAssignmentToExpression(property, receiver, startsOnNewLine) { + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.getSynthesizedClone(property.name), + /*location*/ property); + if (startsOnNewLine) { + expression.startsOnNewLine = true; + } + return expression; + } + /** + * Transforms a MethodDeclaration of an ObjectLiteralExpression into an expression. + * + * @param node The ObjectLiteralExpression that contains the MethodDeclaration. + * @param method The MethodDeclaration node. + * @param receiver The receiver for the assignment. + */ + function transformObjectLiteralMethodDeclarationToExpression(method, receiver, startsOnNewLine) { + var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, /*location*/ method, /*name*/ undefined), + /*location*/ method); + if (startsOnNewLine) { + expression.startsOnNewLine = true; + } + return expression; + } + /** + * Visits a MethodDeclaration of an ObjectLiteralExpression and transforms it into a + * PropertyAssignment. + * + * @param node A MethodDeclaration node. + */ + function visitMethodDeclaration(node) { + // We should only get here for methods on an object literal with regular identifier names. + // Methods on classes are handled in visitClassDeclaration/visitClassExpression. + // Methods with computed property names are handled in visitObjectLiteralExpression. + ts.Debug.assert(!ts.isComputedPropertyName(node.name)); + var functionExpression = transformFunctionLikeToExpression(node, /*location*/ ts.moveRangePos(node, -1), /*name*/ undefined); + ts.setEmitFlags(functionExpression, 16384 /* NoLeadingComments */ | ts.getEmitFlags(functionExpression)); + return ts.createPropertyAssignment(node.name, functionExpression, + /*location*/ node); + } + /** + * Visits a ShorthandPropertyAssignment and transforms it into a PropertyAssignment. + * + * @param node A ShorthandPropertyAssignment node. + */ + function visitShorthandPropertyAssignment(node) { + return ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name), + /*location*/ node); + } + /** + * Visits a YieldExpression node. + * + * @param node A YieldExpression node. + */ + function visitYieldExpression(node) { + // `yield` expressions are transformed using the generators transformer. + return ts.visitEachChild(node, visitor, context); + } + /** + * Visits an ArrayLiteralExpression that contains a spread element. + * + * @param node An ArrayLiteralExpression node. + */ + function visitArrayLiteralExpression(node) { + // We are here because we contain a SpreadElementExpression. + return transformAndSpreadElements(node.elements, /*needsUniqueCopy*/ true, node.multiLine, /*hasTrailingComma*/ node.elements.hasTrailingComma); + } + /** + * Visits a CallExpression that contains either a spread element or `super`. + * + * @param node a CallExpression. + */ + function visitCallExpression(node) { + return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); + } + function visitImmediateSuperCallInBody(node) { + return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ false); + } + function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) { + // We are here either because SuperKeyword was used somewhere in the expression, or + // because we contain a SpreadElementExpression. + var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; + if (node.expression.kind === 96 /* SuperKeyword */) { + ts.setEmitFlags(thisArg, 128 /* NoSubstitution */); + } + var resultingCall; + if (node.transformFlags & 1048576 /* ContainsSpreadElementExpression */) { + // [source] + // f(...a, b) + // x.m(...a, b) + // super(...a, b) + // super.m(...a, b) // in static + // super.m(...a, b) // in instance + // + // [output] + // f.apply(void 0, a.concat([b])) + // (_a = x).m.apply(_a, a.concat([b])) + // _super.apply(this, a.concat([b])) + // _super.m.apply(this, a.concat([b])) + // _super.prototype.m.apply(this, a.concat([b])) + resultingCall = ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); + } + else { + // [source] + // super(a) + // super.m(a) // in static + // super.m(a) // in instance + // + // [output] + // _super.call(this, a) + // _super.m.call(this, a) + // _super.prototype.m.call(this, a) + resultingCall = ts.createFunctionCall(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), + /*location*/ node); + } + if (node.expression.kind === 96 /* SuperKeyword */) { + var actualThis = ts.createThis(); + ts.setEmitFlags(actualThis, 128 /* NoSubstitution */); + var initializer = ts.createLogicalOr(resultingCall, actualThis); + return assignToCapturedThis + ? ts.createAssignment(ts.createIdentifier("_this"), initializer) + : initializer; + } + return resultingCall; + } + /** + * Visits a NewExpression that contains a spread element. + * + * @param node A NewExpression node. + */ + function visitNewExpression(node) { + // We are here because we contain a SpreadElementExpression. + ts.Debug.assert((node.transformFlags & 1048576 /* ContainsSpreadElementExpression */) !== 0); + // [source] + // new C(...a) + // + // [output] + // new ((_a = C).bind.apply(_a, [void 0].concat(a)))() + var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; + return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)), + /*typeArguments*/ undefined, []); + } + /** + * Transforms an array of Expression nodes that contains a SpreadElementExpression. + * + * @param elements The array of Expression nodes. + * @param needsUniqueCopy A value indicating whether to ensure that the result is a fresh array. + * @param multiLine A value indicating whether the result should be emitted on multiple lines. + */ + function transformAndSpreadElements(elements, needsUniqueCopy, multiLine, hasTrailingComma) { + // [source] + // [a, ...b, c] + // + // [output] + // [a].concat(b, [c]) + // Map spans of spread expressions into their expressions and spans of other + // expressions into an array literal. + var numElements = elements.length; + var segments = ts.flatten(ts.spanMap(elements, partitionSpreadElement, function (partition, visitPartition, _start, end) { + return visitPartition(partition, multiLine, hasTrailingComma && end === numElements); + })); + if (segments.length === 1) { + var firstElement = elements[0]; + return needsUniqueCopy && ts.isSpreadElementExpression(firstElement) && firstElement.expression.kind !== 171 /* ArrayLiteralExpression */ + ? ts.createArraySlice(segments[0]) + : segments[0]; + } + // Rewrite using the pattern .concat(, , ...) + return ts.createArrayConcat(segments.shift(), segments); + } + function partitionSpreadElement(node) { + return ts.isSpreadElementExpression(node) + ? visitSpanOfSpreadElements + : visitSpanOfNonSpreadElements; + } + function visitSpanOfSpreadElements(chunk) { + return ts.map(chunk, visitExpressionOfSpreadElement); + } + function visitSpanOfNonSpreadElements(chunk, multiLine, hasTrailingComma) { + return ts.createArrayLiteral(ts.visitNodes(ts.createNodeArray(chunk, /*location*/ undefined, hasTrailingComma), visitor, ts.isExpression), + /*location*/ undefined, multiLine); + } + /** + * Transforms the expression of a SpreadElementExpression node. + * + * @param node A SpreadElementExpression node. + */ + function visitExpressionOfSpreadElement(node) { + return ts.visitNode(node.expression, visitor, ts.isExpression); + } + /** + * Visits a template literal. + * + * @param node A template literal. + */ + function visitTemplateLiteral(node) { + return ts.createLiteral(node.text, /*location*/ node); + } + /** + * Visits a TaggedTemplateExpression node. + * + * @param node A TaggedTemplateExpression node. + */ + function visitTaggedTemplateExpression(node) { + // Visit the tag expression + var tag = ts.visitNode(node.tag, visitor, ts.isExpression); + // Allocate storage for the template site object + var temp = ts.createTempVariable(hoistVariableDeclaration); + // Build up the template arguments and the raw and cooked strings for the template. + var templateArguments = [temp]; + var cookedStrings = []; + var rawStrings = []; + var template = node.template; + if (ts.isNoSubstitutionTemplateLiteral(template)) { + cookedStrings.push(ts.createLiteral(template.text)); + rawStrings.push(getRawLiteral(template)); + } + else { + cookedStrings.push(ts.createLiteral(template.head.text)); + rawStrings.push(getRawLiteral(template.head)); + for (var _i = 0, _a = template.templateSpans; _i < _a.length; _i++) { + var templateSpan = _a[_i]; + cookedStrings.push(ts.createLiteral(templateSpan.literal.text)); + rawStrings.push(getRawLiteral(templateSpan.literal)); + templateArguments.push(ts.visitNode(templateSpan.expression, visitor, ts.isExpression)); + } + } + // NOTE: The parentheses here is entirely optional as we are now able to auto- + // parenthesize when rebuilding the tree. This should be removed in a + // future version. It is here for now to match our existing emit. + return ts.createParen(ts.inlineExpressions([ + ts.createAssignment(temp, ts.createArrayLiteral(cookedStrings)), + ts.createAssignment(ts.createPropertyAccess(temp, "raw"), ts.createArrayLiteral(rawStrings)), + ts.createCall(tag, /*typeArguments*/ undefined, templateArguments) + ])); + } + /** + * Creates an ES5 compatible literal from an ES6 template literal. + * + * @param node The ES6 template literal. + */ + function getRawLiteral(node) { + // Find original source text, since we need to emit the raw strings of the tagged template. + // The raw strings contain the (escaped) strings of what the user wrote. + // Examples: `\n` is converted to "\\n", a template string with a newline to "\n". + var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); + // text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"), + // thus we need to remove those characters. + // First template piece starts with "`", others with "}" + // Last template piece ends with "`", others with "${" + var isLast = node.kind === 12 /* NoSubstitutionTemplateLiteral */ || node.kind === 15 /* TemplateTail */; + text = text.substring(1, text.length - (isLast ? 1 : 2)); + // Newline normalization: + // ES6 Spec 11.8.6.1 - Static Semantics of TV's and TRV's + // and LineTerminatorSequences are normalized to for both TV and TRV. + text = text.replace(/\r\n?/g, "\n"); + return ts.createLiteral(text, /*location*/ node); + } + /** + * Visits a TemplateExpression node. + * + * @param node A TemplateExpression node. + */ + function visitTemplateExpression(node) { + var expressions = []; + addTemplateHead(expressions, node); + addTemplateSpans(expressions, node); + // createAdd will check if each expression binds less closely than binary '+'. + // If it does, it wraps the expression in parentheses. Otherwise, something like + // `abc${ 1 << 2 }` + // becomes + // "abc" + 1 << 2 + "" + // which is really + // ("abc" + 1) << (2 + "") + // rather than + // "abc" + (1 << 2) + "" + var expression = ts.reduceLeft(expressions, ts.createAdd); + if (ts.nodeIsSynthesized(expression)) { + ts.setTextRange(expression, node); + } + return expression; + } + /** + * Gets a value indicating whether we need to include the head of a TemplateExpression. + * + * @param node A TemplateExpression node. + */ + function shouldAddTemplateHead(node) { + // If this expression has an empty head literal and the first template span has a non-empty + // literal, then emitting the empty head literal is not necessary. + // `${ foo } and ${ bar }` + // can be emitted as + // foo + " and " + bar + // This is because it is only required that one of the first two operands in the emit + // output must be a string literal, so that the other operand and all following operands + // are forced into strings. + // + // If the first template span has an empty literal, then the head must still be emitted. + // `${ foo }${ bar }` + // must still be emitted as + // "" + foo + bar + // There is always atleast one templateSpan in this code path, since + // NoSubstitutionTemplateLiterals are directly emitted via emitLiteral() + ts.Debug.assert(node.templateSpans.length !== 0); + return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0; + } + /** + * Adds the head of a TemplateExpression to an array of expressions. + * + * @param expressions An array of expressions. + * @param node A TemplateExpression node. + */ + function addTemplateHead(expressions, node) { + if (!shouldAddTemplateHead(node)) { + return; + } + expressions.push(ts.createLiteral(node.head.text)); + } + /** + * Visits and adds the template spans of a TemplateExpression to an array of expressions. + * + * @param expressions An array of expressions. + * @param node A TemplateExpression node. + */ + function addTemplateSpans(expressions, node) { + for (var _i = 0, _a = node.templateSpans; _i < _a.length; _i++) { + var span_6 = _a[_i]; + expressions.push(ts.visitNode(span_6.expression, visitor, ts.isExpression)); + // Only emit if the literal is non-empty. + // The binary '+' operator is left-associative, so the first string concatenation + // with the head will force the result up to this point to be a string. + // Emitting a '+ ""' has no semantic effect for middles and tails. + if (span_6.literal.text.length !== 0) { + expressions.push(ts.createLiteral(span_6.literal.text)); + } + } + } + /** + * Visits the `super` keyword + */ + function visitSuperKeyword() { + return enclosingNonAsyncFunctionBody + && ts.isClassElement(enclosingNonAsyncFunctionBody) + && !ts.hasModifier(enclosingNonAsyncFunctionBody, 32 /* Static */) + && currentParent.kind !== 175 /* CallExpression */ + ? ts.createPropertyAccess(ts.createIdentifier("_super"), "prototype") + : ts.createIdentifier("_super"); + } + function visitSourceFileNode(node) { + var _a = ts.span(node.statements, ts.isPrologueDirective), prologue = _a[0], remaining = _a[1]; + var statements = []; + startLexicalEnvironment(); + ts.addRange(statements, prologue); + addCaptureThisForNodeIfNeeded(statements, node); + ts.addRange(statements, ts.visitNodes(ts.createNodeArray(remaining), visitor, ts.isStatement)); + ts.addRange(statements, endLexicalEnvironment()); + var clone = ts.getMutableClone(node); + clone.statements = ts.createNodeArray(statements, /*location*/ node.statements); + return clone; + } + /** + * Called by the printer just before a node is printed. + * + * @param node The node to be printed. + */ + function onEmitNode(emitContext, node, emitCallback) { + var savedEnclosingFunction = enclosingFunction; + if (enabledSubstitutions & 1 /* CapturedThis */ && ts.isFunctionLike(node)) { + // If we are tracking a captured `this`, keep track of the enclosing function. + enclosingFunction = node; + } + previousOnEmitNode(emitContext, node, emitCallback); + enclosingFunction = savedEnclosingFunction; + } + /** + * Enables a more costly code path for substitutions when we determine a source file + * contains block-scoped bindings (e.g. `let` or `const`). + */ + function enableSubstitutionsForBlockScopedBindings() { + if ((enabledSubstitutions & 2 /* BlockScopedBindings */) === 0) { + enabledSubstitutions |= 2 /* BlockScopedBindings */; + context.enableSubstitution(70 /* Identifier */); + } + } + /** + * Enables a more costly code path for substitutions when we determine a source file + * contains a captured `this`. + */ + function enableSubstitutionsForCapturedThis() { + if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { + enabledSubstitutions |= 1 /* CapturedThis */; + context.enableSubstitution(98 /* ThisKeyword */); + context.enableEmitNotification(149 /* Constructor */); + context.enableEmitNotification(148 /* MethodDeclaration */); + context.enableEmitNotification(150 /* GetAccessor */); + context.enableEmitNotification(151 /* SetAccessor */); + context.enableEmitNotification(181 /* ArrowFunction */); + context.enableEmitNotification(180 /* FunctionExpression */); + context.enableEmitNotification(221 /* FunctionDeclaration */); + } + } + /** + * Hooks node substitutions. + * + * @param node The node to substitute. + * @param isExpression A value indicating whether the node is to be used in an expression + * position. + */ + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1 /* Expression */) { + return substituteExpression(node); + } + if (ts.isIdentifier(node)) { + return substituteIdentifier(node); + } + return node; + } + /** + * Hooks substitutions for non-expression identifiers. + */ + function substituteIdentifier(node) { + // Only substitute the identifier if we have enabled substitutions for block-scoped + // bindings. + if (enabledSubstitutions & 2 /* BlockScopedBindings */) { + var original = ts.getParseTreeNode(node, ts.isIdentifier); + if (original && isNameOfDeclarationWithCollidingName(original)) { + return ts.getGeneratedNameForNode(original); + } + } + return node; + } + /** + * Determines whether a name is the name of a declaration with a colliding name. + * NOTE: This function expects to be called with an original source tree node. + * + * @param node An original source tree node. + */ + function isNameOfDeclarationWithCollidingName(node) { + var parent = node.parent; + switch (parent.kind) { + case 170 /* BindingElement */: + case 222 /* ClassDeclaration */: + case 225 /* EnumDeclaration */: + case 219 /* VariableDeclaration */: + return parent.name === node + && resolver.isDeclarationWithCollidingName(parent); + } + return false; + } + /** + * Substitutes an expression. + * + * @param node An Expression node. + */ + function substituteExpression(node) { + switch (node.kind) { + case 70 /* Identifier */: + return substituteExpressionIdentifier(node); + case 98 /* ThisKeyword */: + return substituteThisKeyword(node); + } + return node; + } + /** + * Substitutes an expression identifier. + * + * @param node An Identifier node. + */ + function substituteExpressionIdentifier(node) { + if (enabledSubstitutions & 2 /* BlockScopedBindings */) { + var declaration = resolver.getReferencedDeclarationWithCollidingName(node); + if (declaration) { + return ts.getGeneratedNameForNode(declaration.name); + } + } + return node; + } + /** + * Substitutes `this` when contained within an arrow function. + * + * @param node The ThisKeyword node. + */ + function substituteThisKeyword(node) { + if (enabledSubstitutions & 1 /* CapturedThis */ + && enclosingFunction + && ts.getEmitFlags(enclosingFunction) & 256 /* CapturesThis */) { + return ts.createIdentifier("_this", /*location*/ node); + } + return node; + } + /** + * Gets the local name for a declaration for use in expressions. + * + * A local name will *never* be prefixed with an module or namespace export modifier like + * "exports.". + * + * @param node The declaration. + * @param allowComments A value indicating whether comments may be emitted for the name. + * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. + */ + function getLocalName(node, allowComments, allowSourceMaps) { + return getDeclarationName(node, allowComments, allowSourceMaps, 262144 /* LocalName */); + } + /** + * Gets the name of a declaration, without source map or comments. + * + * @param node The declaration. + * @param allowComments Allow comments for the name. + */ + function getDeclarationName(node, allowComments, allowSourceMaps, emitFlags) { + if (node.name && !ts.isGeneratedIdentifier(node.name)) { + var name_33 = ts.getMutableClone(node.name); + emitFlags |= ts.getEmitFlags(node.name); + if (!allowSourceMaps) { + emitFlags |= 1536 /* NoSourceMap */; + } + if (!allowComments) { + emitFlags |= 49152 /* NoComments */; + } + if (emitFlags) { + ts.setEmitFlags(name_33, emitFlags); + } + return name_33; + } + return ts.getGeneratedNameForNode(node); + } + function getClassMemberPrefix(node, member) { + var expression = getLocalName(node); + return ts.hasModifier(member, 32 /* Static */) ? expression : ts.createPropertyAccess(expression, "prototype"); + } + function hasSynthesizedDefaultSuperCall(constructor, hasExtendsClause) { + if (!constructor || !hasExtendsClause) { + return false; + } + var parameter = ts.singleOrUndefined(constructor.parameters); + if (!parameter || !ts.nodeIsSynthesized(parameter) || !parameter.dotDotDotToken) { + return false; + } + var statement = ts.firstOrUndefined(constructor.body.statements); + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 203 /* ExpressionStatement */) { + return false; + } + var statementExpression = statement.expression; + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 175 /* CallExpression */) { + return false; + } + var callTarget = statementExpression.expression; + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 96 /* SuperKeyword */) { + return false; + } + var callArgument = ts.singleOrUndefined(statementExpression.arguments); + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 192 /* SpreadElementExpression */) { + return false; + } + var expression = callArgument.expression; + return ts.isIdentifier(expression) && expression === parameter.name; + } + } + ts.transformES2015 = transformES2015; })(ts || (ts = {})); /// /// @@ -48214,7 +49378,7 @@ var ts; if (ts.isDeclarationFile(node)) { return node; } - if (node.transformFlags & 1024 /* ContainsGenerator */) { + if (node.transformFlags & 4096 /* ContainsGenerator */) { currentSourceFile = node; node = ts.visitEachChild(node, visitor, context); currentSourceFile = undefined; @@ -48234,10 +49398,10 @@ var ts; else if (inGeneratorFunctionBody) { return visitJavaScriptInGeneratorFunctionBody(node); } - else if (transformFlags & 512 /* Generator */) { + else if (transformFlags & 2048 /* Generator */) { return visitGenerator(node); } - else if (transformFlags & 1024 /* ContainsGenerator */) { + else if (transformFlags & 4096 /* ContainsGenerator */) { return ts.visitEachChild(node, visitor, context); } else { @@ -48251,13 +49415,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 204 /* DoStatement */: + case 205 /* DoStatement */: return visitDoStatement(node); - case 205 /* WhileStatement */: + case 206 /* WhileStatement */: return visitWhileStatement(node); - case 213 /* SwitchStatement */: + case 214 /* SwitchStatement */: return visitSwitchStatement(node); - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -48270,30 +49434,30 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 220 /* FunctionDeclaration */: + case 221 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 179 /* FunctionExpression */: + case 180 /* FunctionExpression */: return visitFunctionExpression(node); - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: return visitAccessorDeclaration(node); - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: return visitVariableStatement(node); - case 206 /* ForStatement */: + case 207 /* ForStatement */: return visitForStatement(node); - case 207 /* ForInStatement */: + case 208 /* ForInStatement */: return visitForInStatement(node); - case 210 /* BreakStatement */: + case 211 /* BreakStatement */: return visitBreakStatement(node); - case 209 /* ContinueStatement */: + case 210 /* ContinueStatement */: return visitContinueStatement(node); - case 211 /* ReturnStatement */: + case 212 /* ReturnStatement */: return visitReturnStatement(node); default: - if (node.transformFlags & 4194304 /* ContainsYield */) { + if (node.transformFlags & 16777216 /* ContainsYield */) { return visitJavaScriptContainingYield(node); } - else if (node.transformFlags & (1024 /* ContainsGenerator */ | 8388608 /* ContainsHoistedDeclarationOrCompletion */)) { + else if (node.transformFlags & (4096 /* ContainsGenerator */ | 33554432 /* ContainsHoistedDeclarationOrCompletion */)) { return ts.visitEachChild(node, visitor, context); } else { @@ -48308,21 +49472,21 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return visitBinaryExpression(node); - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: return visitConditionalExpression(node); - case 190 /* YieldExpression */: + case 191 /* YieldExpression */: return visitYieldExpression(node); - case 170 /* ArrayLiteralExpression */: + case 171 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 171 /* ObjectLiteralExpression */: + case 172 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 173 /* ElementAccessExpression */: + case 174 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 174 /* CallExpression */: + case 175 /* CallExpression */: return visitCallExpression(node); - case 175 /* NewExpression */: + case 176 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -48335,9 +49499,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 220 /* FunctionDeclaration */: + case 221 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 179 /* FunctionExpression */: + case 180 /* FunctionExpression */: return visitFunctionExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -48396,6 +49560,7 @@ var ts; // Currently, we only support generators that were originally async functions. if (node.asteriskToken && ts.getEmitFlags(node) & 2097152 /* AsyncFunctionBody */) { node = ts.setOriginalNode(ts.createFunctionExpression( + /*modifiers*/ undefined, /*asteriskToken*/ undefined, node.name, /*typeParameters*/ undefined, node.parameters, /*type*/ undefined, transformGeneratorFunctionBody(node.body), @@ -48497,7 +49662,7 @@ var ts; * @param node The node to visit. */ function visitVariableStatement(node) { - if (node.transformFlags & 4194304 /* ContainsYield */) { + if (node.transformFlags & 16777216 /* ContainsYield */) { transformAndEmitVariableDeclarationList(node.declarationList); return undefined; } @@ -48536,23 +49701,23 @@ var ts; } } function isCompoundAssignment(kind) { - return kind >= 57 /* FirstCompoundAssignment */ - && kind <= 68 /* LastCompoundAssignment */; + return kind >= 58 /* FirstCompoundAssignment */ + && kind <= 69 /* LastCompoundAssignment */; } function getOperatorForCompoundAssignment(kind) { switch (kind) { - case 57 /* PlusEqualsToken */: return 35 /* PlusToken */; - case 58 /* MinusEqualsToken */: return 36 /* MinusToken */; - case 59 /* AsteriskEqualsToken */: return 37 /* AsteriskToken */; - case 60 /* AsteriskAsteriskEqualsToken */: return 38 /* AsteriskAsteriskToken */; - case 61 /* SlashEqualsToken */: return 39 /* SlashToken */; - case 62 /* PercentEqualsToken */: return 40 /* PercentToken */; - case 63 /* LessThanLessThanEqualsToken */: return 43 /* LessThanLessThanToken */; - case 64 /* GreaterThanGreaterThanEqualsToken */: return 44 /* GreaterThanGreaterThanToken */; - case 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 45 /* GreaterThanGreaterThanGreaterThanToken */; - case 66 /* AmpersandEqualsToken */: return 46 /* AmpersandToken */; - case 67 /* BarEqualsToken */: return 47 /* BarToken */; - case 68 /* CaretEqualsToken */: return 48 /* CaretToken */; + case 58 /* PlusEqualsToken */: return 36 /* PlusToken */; + case 59 /* MinusEqualsToken */: return 37 /* MinusToken */; + case 60 /* AsteriskEqualsToken */: return 38 /* AsteriskToken */; + case 61 /* AsteriskAsteriskEqualsToken */: return 39 /* AsteriskAsteriskToken */; + case 62 /* SlashEqualsToken */: return 40 /* SlashToken */; + case 63 /* PercentEqualsToken */: return 41 /* PercentToken */; + case 64 /* LessThanLessThanEqualsToken */: return 44 /* LessThanLessThanToken */; + case 65 /* GreaterThanGreaterThanEqualsToken */: return 45 /* GreaterThanGreaterThanToken */; + case 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 46 /* GreaterThanGreaterThanGreaterThanToken */; + case 67 /* AmpersandEqualsToken */: return 47 /* AmpersandToken */; + case 68 /* BarEqualsToken */: return 48 /* BarToken */; + case 69 /* CaretEqualsToken */: return 49 /* CaretToken */; } } /** @@ -48565,7 +49730,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -48577,7 +49742,7 @@ var ts; // _a.b = %sent%; target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 173 /* ElementAccessExpression */: + case 174 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -48596,7 +49761,7 @@ var ts; } var operator = node.operatorToken.kind; if (isCompoundAssignment(operator)) { - return ts.createBinary(target, 56 /* EqualsToken */, ts.createBinary(cacheExpression(target), getOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression), node), node); + return ts.createBinary(target, 57 /* EqualsToken */, ts.createBinary(cacheExpression(target), getOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression), node), node); } else { return ts.updateBinary(node, target, ts.visitNode(right, visitor, ts.isExpression)); @@ -48609,7 +49774,7 @@ var ts; if (ts.isLogicalOperator(node.operatorToken.kind)) { return visitLogicalBinaryExpression(node); } - else if (node.operatorToken.kind === 24 /* CommaToken */) { + else if (node.operatorToken.kind === 25 /* CommaToken */) { return visitCommaExpression(node); } // [source] @@ -48620,10 +49785,10 @@ var ts; // _a = a(); // .yield resumeLabel // _a + %sent% + c() - var clone_5 = ts.getMutableClone(node); - clone_5.left = cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression)); - clone_5.right = ts.visitNode(node.right, visitor, ts.isExpression); - return clone_5; + var clone_6 = ts.getMutableClone(node); + clone_6.left = cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression)); + clone_6.right = ts.visitNode(node.right, visitor, ts.isExpression); + return clone_6; } return ts.visitEachChild(node, visitor, context); } @@ -48664,7 +49829,7 @@ var ts; var resultLabel = defineLabel(); var resultLocal = declareLocal(); emitAssignment(resultLocal, ts.visitNode(node.left, visitor, ts.isExpression), /*location*/ node.left); - if (node.operatorToken.kind === 51 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 52 /* AmpersandAmpersandToken */) { // Logical `&&` shortcuts when the left-hand operand is falsey. emitBreakWhenFalse(resultLabel, resultLocal, /*location*/ node.left); } @@ -48695,7 +49860,7 @@ var ts; visit(node.right); return ts.inlineExpressions(pendingExpressions); function visit(node) { - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 24 /* CommaToken */) { + if (ts.isBinaryExpression(node) && node.operatorToken.kind === 25 /* CommaToken */) { visit(node.left); visit(node.right); } @@ -48785,7 +49950,7 @@ var ts; * @param elements The elements to visit. * @param multiLine Whether array literals created should be emitted on multiple lines. */ - function visitElements(elements, multiLine) { + function visitElements(elements, _multiLine) { // [source] // ar = [1, yield, 2]; // @@ -48877,10 +50042,10 @@ var ts; // .yield resumeLabel // .mark resumeLabel // a = _a[%sent%] - var clone_6 = ts.getMutableClone(node); - clone_6.expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); - clone_6.argumentExpression = ts.visitNode(node.argumentExpression, visitor, ts.isExpression); - return clone_6; + var clone_7 = ts.getMutableClone(node); + clone_7.expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); + clone_7.argumentExpression = ts.visitNode(node.argumentExpression, visitor, ts.isExpression); + return clone_7; } return ts.visitEachChild(node, visitor, context); } @@ -48897,7 +50062,7 @@ var ts; // .mark resumeLabel // _b.apply(_a, _c.concat([%sent%, 2])); var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration, languageVersion, /*cacheIdentifiers*/ true), target = _a.target, thisArg = _a.thisArg; - return ts.setOriginalNode(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isLeftHandSideExpression)), thisArg, visitElements(node.arguments, /*multiLine*/ false), + return ts.setOriginalNode(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isLeftHandSideExpression)), thisArg, visitElements(node.arguments), /*location*/ node), node); } return ts.visitEachChild(node, visitor, context); @@ -48915,7 +50080,7 @@ var ts; // .mark resumeLabel // new (_b.apply(_a, _c.concat([%sent%, 2]))); var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.setOriginalNode(ts.createNew(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isExpression)), thisArg, visitElements(node.arguments, /*multiLine*/ false)), + return ts.setOriginalNode(ts.createNew(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isExpression)), thisArg, visitElements(node.arguments)), /*typeArguments*/ undefined, [], /*location*/ node), node); } @@ -48946,35 +50111,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 199 /* Block */: + case 200 /* Block */: return transformAndEmitBlock(node); - case 202 /* ExpressionStatement */: + case 203 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 203 /* IfStatement */: + case 204 /* IfStatement */: return transformAndEmitIfStatement(node); - case 204 /* DoStatement */: + case 205 /* DoStatement */: return transformAndEmitDoStatement(node); - case 205 /* WhileStatement */: + case 206 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 206 /* ForStatement */: + case 207 /* ForStatement */: return transformAndEmitForStatement(node); - case 207 /* ForInStatement */: + case 208 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 209 /* ContinueStatement */: + case 210 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 210 /* BreakStatement */: + case 211 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 211 /* ReturnStatement */: + case 212 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 212 /* WithStatement */: + case 213 /* WithStatement */: return transformAndEmitWithStatement(node); - case 213 /* SwitchStatement */: + case 214 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 215 /* ThrowStatement */: + case 216 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 216 /* TryStatement */: + case 217 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement, /*optional*/ true)); @@ -49538,7 +50703,7 @@ var ts; } } function containsYield(node) { - return node && (node.transformFlags & 4194304 /* ContainsYield */) !== 0; + return node && (node.transformFlags & 16777216 /* ContainsYield */) !== 0; } function countInitialNodesWithoutYield(nodes) { var numNodes = nodes.length; @@ -49568,12 +50733,12 @@ var ts; if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - var name_37 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); - if (name_37) { - var clone_7 = ts.getMutableClone(name_37); - ts.setSourceMapRange(clone_7, node); - ts.setCommentRange(clone_7, node); - return clone_7; + var name_34 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); + if (name_34) { + var clone_8 = ts.getMutableClone(name_34); + ts.setSourceMapRange(clone_8, node); + ts.setCommentRange(clone_8, node); + return clone_8; } } } @@ -49715,7 +50880,7 @@ var ts; if (!renamedCatchVariables) { renamedCatchVariables = ts.createMap(); renamedCatchVariableDeclarations = ts.createMap(); - context.enableSubstitution(69 /* Identifier */); + context.enableSubstitution(70 /* Identifier */); } renamedCatchVariables[text] = true; renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; @@ -49981,7 +51146,7 @@ var ts; } return expression; } - return ts.createNode(193 /* OmittedExpression */); + return ts.createNode(194 /* OmittedExpression */); } /** * Creates a numeric literal for the provided instruction. @@ -50163,6 +51328,7 @@ var ts; /*typeArguments*/ undefined, [ ts.createThis(), ts.setEmitFlags(ts.createFunctionExpression( + /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, [ts.createParameter(state)], @@ -50542,2306 +51708,589 @@ var ts; ts.transformGenerators = transformGenerators; var _a; })(ts || (ts = {})); -/// -/// +/// +/// /*@internal*/ var ts; (function (ts) { - var ES6SubstitutionFlags; - (function (ES6SubstitutionFlags) { - /** Enables substitutions for captured `this` */ - ES6SubstitutionFlags[ES6SubstitutionFlags["CapturedThis"] = 1] = "CapturedThis"; - /** Enables substitutions for block-scoped bindings. */ - ES6SubstitutionFlags[ES6SubstitutionFlags["BlockScopedBindings"] = 2] = "BlockScopedBindings"; - })(ES6SubstitutionFlags || (ES6SubstitutionFlags = {})); - var CopyDirection; - (function (CopyDirection) { - CopyDirection[CopyDirection["ToOriginal"] = 0] = "ToOriginal"; - CopyDirection[CopyDirection["ToOutParameter"] = 1] = "ToOutParameter"; - })(CopyDirection || (CopyDirection = {})); - var Jump; - (function (Jump) { - Jump[Jump["Break"] = 2] = "Break"; - Jump[Jump["Continue"] = 4] = "Continue"; - Jump[Jump["Return"] = 8] = "Return"; - })(Jump || (Jump = {})); - var SuperCaptureResult; - (function (SuperCaptureResult) { - /** - * A capture may have been added for calls to 'super', but - * the caller should emit subsequent statements normally. - */ - SuperCaptureResult[SuperCaptureResult["NoReplacement"] = 0] = "NoReplacement"; - /** - * A call to 'super()' got replaced with a capturing statement like: - * - * var _this = _super.call(...) || this; - * - * Callers should skip the current statement. - */ - SuperCaptureResult[SuperCaptureResult["ReplaceSuperCapture"] = 1] = "ReplaceSuperCapture"; - /** - * A call to 'super()' got replaced with a capturing statement like: - * - * return _super.call(...) || this; - * - * Callers should skip the current statement and avoid any returns of '_this'. - */ - SuperCaptureResult[SuperCaptureResult["ReplaceWithReturn"] = 2] = "ReplaceWithReturn"; - })(SuperCaptureResult || (SuperCaptureResult = {})); - function transformES6(context) { + function transformModule(context) { + var transformModuleDelegates = ts.createMap((_a = {}, + _a[ts.ModuleKind.None] = transformCommonJSModule, + _a[ts.ModuleKind.CommonJS] = transformCommonJSModule, + _a[ts.ModuleKind.AMD] = transformAMDModule, + _a[ts.ModuleKind.UMD] = transformUMDModule, + _a)); var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; + var compilerOptions = context.getCompilerOptions(); var resolver = context.getEmitResolver(); + var host = context.getEmitHost(); + var languageVersion = ts.getEmitScriptTarget(compilerOptions); + var moduleKind = ts.getEmitModuleKind(compilerOptions); var previousOnSubstituteNode = context.onSubstituteNode; var previousOnEmitNode = context.onEmitNode; - context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; + context.onEmitNode = onEmitNode; + context.enableSubstitution(70 /* Identifier */); + context.enableSubstitution(188 /* BinaryExpression */); + context.enableSubstitution(186 /* PrefixUnaryExpression */); + context.enableSubstitution(187 /* PostfixUnaryExpression */); + context.enableSubstitution(254 /* ShorthandPropertyAssignment */); + context.enableEmitNotification(256 /* SourceFile */); var currentSourceFile; - var currentText; - var currentParent; - var currentNode; - var enclosingVariableStatement; - var enclosingBlockScopeContainer; - var enclosingBlockScopeContainerParent; - var enclosingFunction; - var enclosingNonArrowFunction; - var enclosingNonAsyncFunctionBody; - /** - * Used to track if we are emitting body of the converted loop - */ - var convertedLoopState; - /** - * Keeps track of whether substitutions have been enabled for specific cases. - * They are persisted between each SourceFile transformation and should not - * be reset. - */ - var enabledSubstitutions; + var externalImports; + var exportSpecifiers; + var exportEquals; + var bindingNameExportSpecifiersMap; + // Subset of exportSpecifiers that is a binding-name. + // This is to reduce amount of memory we have to keep around even after we done with module-transformer + var bindingNameExportSpecifiersForFileMap = ts.createMap(); + var hasExportStarsToExportValues; return transformSourceFile; + /** + * Transforms the module aspects of a SourceFile. + * + * @param node The SourceFile node. + */ function transformSourceFile(node) { if (ts.isDeclarationFile(node)) { return node; } - currentSourceFile = node; - currentText = node.text; - return ts.visitNode(node, visitor, ts.isSourceFile); - } - function visitor(node) { - return saveStateAndInvoke(node, dispatcher); - } - function dispatcher(node) { - return convertedLoopState - ? visitorForConvertedLoopWorker(node) - : visitorWorker(node); - } - function saveStateAndInvoke(node, f) { - var savedEnclosingFunction = enclosingFunction; - var savedEnclosingNonArrowFunction = enclosingNonArrowFunction; - var savedEnclosingNonAsyncFunctionBody = enclosingNonAsyncFunctionBody; - var savedEnclosingBlockScopeContainer = enclosingBlockScopeContainer; - var savedEnclosingBlockScopeContainerParent = enclosingBlockScopeContainerParent; - var savedEnclosingVariableStatement = enclosingVariableStatement; - var savedCurrentParent = currentParent; - var savedCurrentNode = currentNode; - var savedConvertedLoopState = convertedLoopState; - if (ts.nodeStartsNewLexicalEnvironment(node)) { - // don't treat content of nodes that start new lexical environment as part of converted loop copy - convertedLoopState = undefined; + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + currentSourceFile = node; + // Collect information about the external module. + (_a = ts.collectExternalModuleInfo(node), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); + // Perform the transformation. + var transformModule_1 = transformModuleDelegates[moduleKind] || transformModuleDelegates[ts.ModuleKind.None]; + var updated = transformModule_1(node); + ts.aggregateTransformFlags(updated); + currentSourceFile = undefined; + externalImports = undefined; + exportSpecifiers = undefined; + exportEquals = undefined; + hasExportStarsToExportValues = false; + return updated; } - onBeforeVisitNode(node); - var visited = f(node); - convertedLoopState = savedConvertedLoopState; - enclosingFunction = savedEnclosingFunction; - enclosingNonArrowFunction = savedEnclosingNonArrowFunction; - enclosingNonAsyncFunctionBody = savedEnclosingNonAsyncFunctionBody; - enclosingBlockScopeContainer = savedEnclosingBlockScopeContainer; - enclosingBlockScopeContainerParent = savedEnclosingBlockScopeContainerParent; - enclosingVariableStatement = savedEnclosingVariableStatement; - currentParent = savedCurrentParent; - currentNode = savedCurrentNode; - return visited; - } - function shouldCheckNode(node) { - return (node.transformFlags & 64 /* ES6 */) !== 0 || - node.kind === 214 /* LabeledStatement */ || - (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)); - } - function visitorWorker(node) { - if (shouldCheckNode(node)) { - return visitJavaScript(node); - } - else if (node.transformFlags & 128 /* ContainsES6 */) { - return ts.visitEachChild(node, visitor, context); - } - else { - return node; - } - } - function visitorForConvertedLoopWorker(node) { - var result; - if (shouldCheckNode(node)) { - result = visitJavaScript(node); - } - else { - result = visitNodesInConvertedLoop(node); - } - return result; - } - function visitNodesInConvertedLoop(node) { - switch (node.kind) { - case 211 /* ReturnStatement */: - return visitReturnStatement(node); - case 200 /* VariableStatement */: - return visitVariableStatement(node); - case 213 /* SwitchStatement */: - return visitSwitchStatement(node); - case 210 /* BreakStatement */: - case 209 /* ContinueStatement */: - return visitBreakOrContinueStatement(node); - case 97 /* ThisKeyword */: - return visitThisKeyword(node); - case 69 /* Identifier */: - return visitIdentifier(node); - default: - return ts.visitEachChild(node, visitor, context); - } - } - function visitJavaScript(node) { - switch (node.kind) { - case 82 /* ExportKeyword */: - return node; - case 221 /* ClassDeclaration */: - return visitClassDeclaration(node); - case 192 /* ClassExpression */: - return visitClassExpression(node); - case 142 /* Parameter */: - return visitParameter(node); - case 220 /* FunctionDeclaration */: - return visitFunctionDeclaration(node); - case 180 /* ArrowFunction */: - return visitArrowFunction(node); - case 179 /* FunctionExpression */: - return visitFunctionExpression(node); - case 218 /* VariableDeclaration */: - return visitVariableDeclaration(node); - case 69 /* Identifier */: - return visitIdentifier(node); - case 219 /* VariableDeclarationList */: - return visitVariableDeclarationList(node); - case 214 /* LabeledStatement */: - return visitLabeledStatement(node); - case 204 /* DoStatement */: - return visitDoStatement(node); - case 205 /* WhileStatement */: - return visitWhileStatement(node); - case 206 /* ForStatement */: - return visitForStatement(node); - case 207 /* ForInStatement */: - return visitForInStatement(node); - case 208 /* ForOfStatement */: - return visitForOfStatement(node); - case 202 /* ExpressionStatement */: - return visitExpressionStatement(node); - case 171 /* ObjectLiteralExpression */: - return visitObjectLiteralExpression(node); - case 254 /* ShorthandPropertyAssignment */: - return visitShorthandPropertyAssignment(node); - case 170 /* ArrayLiteralExpression */: - return visitArrayLiteralExpression(node); - case 174 /* CallExpression */: - return visitCallExpression(node); - case 175 /* NewExpression */: - return visitNewExpression(node); - case 178 /* ParenthesizedExpression */: - return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 187 /* BinaryExpression */: - return visitBinaryExpression(node, /*needsDestructuringValue*/ true); - case 11 /* NoSubstitutionTemplateLiteral */: - case 12 /* TemplateHead */: - case 13 /* TemplateMiddle */: - case 14 /* TemplateTail */: - return visitTemplateLiteral(node); - case 176 /* TaggedTemplateExpression */: - return visitTaggedTemplateExpression(node); - case 189 /* TemplateExpression */: - return visitTemplateExpression(node); - case 190 /* YieldExpression */: - return visitYieldExpression(node); - case 95 /* SuperKeyword */: - return visitSuperKeyword(node); - case 190 /* YieldExpression */: - // `yield` will be handled by a generators transform. - return ts.visitEachChild(node, visitor, context); - case 147 /* MethodDeclaration */: - return visitMethodDeclaration(node); - case 256 /* SourceFile */: - return visitSourceFileNode(node); - case 200 /* VariableStatement */: - return visitVariableStatement(node); - default: - ts.Debug.failBadSyntaxKind(node); - return ts.visitEachChild(node, visitor, context); - } - } - function onBeforeVisitNode(node) { - if (currentNode) { - if (ts.isBlockScope(currentNode, currentParent)) { - enclosingBlockScopeContainer = currentNode; - enclosingBlockScopeContainerParent = currentParent; - } - if (ts.isFunctionLike(currentNode)) { - enclosingFunction = currentNode; - if (currentNode.kind !== 180 /* ArrowFunction */) { - enclosingNonArrowFunction = currentNode; - if (!(ts.getEmitFlags(currentNode) & 2097152 /* AsyncFunctionBody */)) { - enclosingNonAsyncFunctionBody = currentNode; - } - } - } - // keep track of the enclosing variable statement when in the context of - // variable statements, variable declarations, binding elements, and binding - // patterns. - switch (currentNode.kind) { - case 200 /* VariableStatement */: - enclosingVariableStatement = currentNode; - break; - case 219 /* VariableDeclarationList */: - case 218 /* VariableDeclaration */: - case 169 /* BindingElement */: - case 167 /* ObjectBindingPattern */: - case 168 /* ArrayBindingPattern */: - break; - default: - enclosingVariableStatement = undefined; - } - } - currentParent = currentNode; - currentNode = node; - } - function visitSwitchStatement(node) { - ts.Debug.assert(convertedLoopState !== undefined); - var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; - // for switch statement allow only non-labeled break - convertedLoopState.allowedNonLabeledJumps |= 2 /* Break */; - var result = ts.visitEachChild(node, visitor, context); - convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; - return result; - } - function visitReturnStatement(node) { - ts.Debug.assert(convertedLoopState !== undefined); - convertedLoopState.nonLocalJumps |= 8 /* Return */; - return ts.createReturn(ts.createObjectLiteral([ - ts.createPropertyAssignment(ts.createIdentifier("value"), node.expression - ? ts.visitNode(node.expression, visitor, ts.isExpression) - : ts.createVoidZero()) - ])); - } - function visitThisKeyword(node) { - ts.Debug.assert(convertedLoopState !== undefined); - if (enclosingFunction && enclosingFunction.kind === 180 /* ArrowFunction */) { - // if the enclosing function is an ArrowFunction is then we use the captured 'this' keyword. - convertedLoopState.containsLexicalThis = true; - return node; - } - return convertedLoopState.thisName || (convertedLoopState.thisName = ts.createUniqueName("this")); - } - function visitIdentifier(node) { - if (!convertedLoopState) { - return node; - } - if (ts.isGeneratedIdentifier(node)) { - return node; - } - if (node.text !== "arguments" && !resolver.isArgumentsLocalBinding(node)) { - return node; - } - return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = ts.createUniqueName("arguments")); - } - function visitBreakOrContinueStatement(node) { - if (convertedLoopState) { - // check if we can emit break/continue as is - // it is possible if either - // - break/continue is labeled and label is located inside the converted loop - // - break/continue is non-labeled and located in non-converted loop/switch statement - var jump = node.kind === 210 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; - var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || - (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); - if (!canUseBreakOrContinue) { - var labelMarker = void 0; - if (!node.label) { - if (node.kind === 210 /* BreakStatement */) { - convertedLoopState.nonLocalJumps |= 2 /* Break */; - labelMarker = "break"; - } - else { - convertedLoopState.nonLocalJumps |= 4 /* Continue */; - // note: return value is emitted only to simplify debugging, call to converted loop body does not do any dispatching on it. - labelMarker = "continue"; - } - } - else { - if (node.kind === 210 /* BreakStatement */) { - labelMarker = "break-" + node.label.text; - setLabeledJump(convertedLoopState, /*isBreak*/ true, node.label.text, labelMarker); - } - else { - labelMarker = "continue-" + node.label.text; - setLabeledJump(convertedLoopState, /*isBreak*/ false, node.label.text, labelMarker); - } - } - var returnExpression = ts.createLiteral(labelMarker); - if (convertedLoopState.loopOutParameters.length) { - var outParams = convertedLoopState.loopOutParameters; - var expr = void 0; - for (var i = 0; i < outParams.length; i++) { - var copyExpr = copyOutParameter(outParams[i], 1 /* ToOutParameter */); - if (i === 0) { - expr = copyExpr; - } - else { - expr = ts.createBinary(expr, 24 /* CommaToken */, copyExpr); - } - } - returnExpression = ts.createBinary(expr, 24 /* CommaToken */, returnExpression); - } - return ts.createReturn(returnExpression); - } - } - return ts.visitEachChild(node, visitor, context); + return node; + var _a; } /** - * Visits a ClassDeclaration and transforms it into a variable statement. + * Transforms a SourceFile into a CommonJS module. * - * @param node A ClassDeclaration node. + * @param node The SourceFile node. */ - function visitClassDeclaration(node) { - // [source] - // class C { } - // - // [output] - // var C = (function () { - // function C() { - // } - // return C; - // }()); - var modifierFlags = ts.getModifierFlags(node); - var isExported = modifierFlags & 1 /* Export */; - var isDefault = modifierFlags & 512 /* Default */; - // Add an `export` modifier to the statement if needed (for `--target es5 --module es6`) - var modifiers = isExported && !isDefault - ? ts.filter(node.modifiers, isExportModifier) - : undefined; - var statement = ts.createVariableStatement(modifiers, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(getDeclarationName(node, /*allowComments*/ true), - /*type*/ undefined, transformClassLikeDeclarationToExpression(node)) - ]), - /*location*/ node); - ts.setOriginalNode(statement, node); - ts.startOnNewLine(statement); - // Add an `export default` statement for default exports (for `--target es5 --module es6`) - if (isExported && isDefault) { - var statements = [statement]; - statements.push(ts.createExportAssignment( - /*decorators*/ undefined, - /*modifiers*/ undefined, - /*isExportEquals*/ false, getDeclarationName(node, /*allowComments*/ false))); - return statements; - } - return statement; - } - function isExportModifier(node) { - return node.kind === 82 /* ExportKeyword */; - } - /** - * Visits a ClassExpression and transforms it into an expression. - * - * @param node A ClassExpression node. - */ - function visitClassExpression(node) { - // [source] - // C = class { } - // - // [output] - // C = (function () { - // function class_1() { - // } - // return class_1; - // }()) - return transformClassLikeDeclarationToExpression(node); - } - /** - * Transforms a ClassExpression or ClassDeclaration into an expression. - * - * @param node A ClassExpression or ClassDeclaration node. - */ - function transformClassLikeDeclarationToExpression(node) { - // [source] - // class C extends D { - // constructor() {} - // method() {} - // get prop() {} - // set prop(v) {} - // } - // - // [output] - // (function (_super) { - // __extends(C, _super); - // function C() { - // } - // C.prototype.method = function () {} - // Object.defineProperty(C.prototype, "prop", { - // get: function() {}, - // set: function() {}, - // enumerable: true, - // configurable: true - // }); - // return C; - // }(D)) - if (node.name) { - enableSubstitutionsForBlockScopedBindings(); - } - var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); - var classFunction = ts.createFunctionExpression( - /*asteriskToken*/ undefined, - /*name*/ undefined, - /*typeParameters*/ undefined, extendsClauseElement ? [ts.createParameter("_super")] : [], - /*type*/ undefined, transformClassBody(node, extendsClauseElement)); - // To preserve the behavior of the old emitter, we explicitly indent - // the body of the function here if it was requested in an earlier - // transformation. - if (ts.getEmitFlags(node) & 524288 /* Indented */) { - ts.setEmitFlags(classFunction, 524288 /* Indented */); - } - // "inner" and "outer" below are added purely to preserve source map locations from - // the old emitter - var inner = ts.createPartiallyEmittedExpression(classFunction); - inner.end = node.end; - ts.setEmitFlags(inner, 49152 /* NoComments */); - var outer = ts.createPartiallyEmittedExpression(inner); - outer.end = ts.skipTrivia(currentText, node.pos); - ts.setEmitFlags(outer, 49152 /* NoComments */); - return ts.createParen(ts.createCall(outer, - /*typeArguments*/ undefined, extendsClauseElement - ? [ts.visitNode(extendsClauseElement.expression, visitor, ts.isExpression)] - : [])); - } - /** - * Transforms a ClassExpression or ClassDeclaration into a function body. - * - * @param node A ClassExpression or ClassDeclaration node. - * @param extendsClauseElement The expression for the class `extends` clause. - */ - function transformClassBody(node, extendsClauseElement) { - var statements = []; + function transformCommonJSModule(node) { startLexicalEnvironment(); - addExtendsHelperIfNeeded(statements, node, extendsClauseElement); - addConstructor(statements, node, extendsClauseElement); - addClassMembers(statements, node); - // Create a synthetic text range for the return statement. - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 16 /* CloseBraceToken */); - var localName = getLocalName(node); - // The following partially-emitted expression exists purely to align our sourcemap - // emit with the original emitter. - var outer = ts.createPartiallyEmittedExpression(localName); - outer.end = closingBraceLocation.end; - ts.setEmitFlags(outer, 49152 /* NoComments */); - var statement = ts.createReturn(outer); - statement.pos = closingBraceLocation.pos; - ts.setEmitFlags(statement, 49152 /* NoComments */ | 12288 /* NoTokenSourceMaps */); - statements.push(statement); - ts.addRange(statements, endLexicalEnvironment()); - var block = ts.createBlock(ts.createNodeArray(statements, /*location*/ node.members), /*location*/ undefined, /*multiLine*/ true); - ts.setEmitFlags(block, 49152 /* NoComments */); - return block; - } - /** - * Adds a call to the `__extends` helper if needed for a class. - * - * @param statements The statements of the class body function. - * @param node The ClassExpression or ClassDeclaration node. - * @param extendsClauseElement The expression for the class `extends` clause. - */ - function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) { - if (extendsClauseElement) { - statements.push(ts.createStatement(ts.createExtendsHelper(currentSourceFile.externalHelpersModuleName, getDeclarationName(node)), - /*location*/ extendsClauseElement)); - } - } - /** - * Adds the constructor of the class to a class body function. - * - * @param statements The statements of the class body function. - * @param node The ClassExpression or ClassDeclaration node. - * @param extendsClauseElement The expression for the class `extends` clause. - */ - function addConstructor(statements, node, extendsClauseElement) { - var constructor = ts.getFirstConstructorWithBody(node); - var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); - var constructorFunction = ts.createFunctionDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, - /*asteriskToken*/ undefined, getDeclarationName(node), - /*typeParameters*/ undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), - /*type*/ undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), - /*location*/ constructor || node); - if (extendsClauseElement) { - ts.setEmitFlags(constructorFunction, 256 /* CapturesThis */); - } - statements.push(constructorFunction); - } - /** - * Transforms the parameters of the constructor declaration of a class. - * - * @param constructor The constructor for the class. - * @param hasSynthesizedSuper A value indicating whether the constructor starts with a - * synthesized `super` call. - */ - function transformConstructorParameters(constructor, hasSynthesizedSuper) { - // If the TypeScript transformer needed to synthesize a constructor for property - // initializers, it would have also added a synthetic `...args` parameter and - // `super` call. - // If this is the case, we do not include the synthetic `...args` parameter and - // will instead use the `arguments` object in ES5/3. - if (constructor && !hasSynthesizedSuper) { - return ts.visitNodes(constructor.parameters, visitor, ts.isParameter); - } - return []; - } - /** - * Transforms the body of a constructor declaration of a class. - * - * @param constructor The constructor for the class. - * @param node The node which contains the constructor. - * @param extendsClauseElement The expression for the class `extends` clause. - * @param hasSynthesizedSuper A value indicating whether the constructor starts with a - * synthesized `super` call. - */ - function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { var statements = []; - startLexicalEnvironment(); - var statementOffset = -1; - if (hasSynthesizedSuper) { - // If a super call has already been synthesized, - // we're going to assume that we should just transform everything after that. - // The assumption is that no prior step in the pipeline has added any prologue directives. - statementOffset = 1; - } - else if (constructor) { - // Otherwise, try to emit all potential prologue directives first. - statementOffset = ts.addPrologueDirectives(statements, constructor.body.statements, /*ensureUseStrict*/ false, visitor); - } - if (constructor) { - addDefaultValueAssignmentsIfNeeded(statements, constructor); - addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); - ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); - } - var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, !!extendsClauseElement, hasSynthesizedSuper, statementOffset); - // The last statement expression was replaced. Skip it. - if (superCaptureStatus === 1 /* ReplaceSuperCapture */ || superCaptureStatus === 2 /* ReplaceWithReturn */) { - statementOffset++; - } - if (constructor) { - var body = saveStateAndInvoke(constructor, function (constructor) { return ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, /*start*/ statementOffset); }); - ts.addRange(statements, body); - } - // Return `_this` unless we're sure enough that it would be pointless to add a return statement. - // If there's a constructor that we can tell returns in enough places, then we *do not* want to add a return. - if (extendsClauseElement - && superCaptureStatus !== 2 /* ReplaceWithReturn */ - && !(constructor && isSufficientlyCoveredByReturnStatements(constructor.body))) { - statements.push(ts.createReturn(ts.createIdentifier("_this"))); - } + var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, visitor); + ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); - var block = ts.createBlock(ts.createNodeArray(statements, - /*location*/ constructor ? constructor.body.statements : node.members), - /*location*/ constructor ? constructor.body : node, - /*multiLine*/ true); - if (!constructor) { - ts.setEmitFlags(block, 49152 /* NoComments */); + addExportEqualsIfNeeded(statements, /*emitAsReturn*/ false); + var updated = updateSourceFile(node, statements); + if (hasExportStarsToExportValues) { + ts.setEmitFlags(updated, 2 /* EmitExportStar */ | ts.getEmitFlags(node)); } - return block; + return updated; } /** - * We want to try to avoid emitting a return statement in certain cases if a user already returned something. - * It would generate obviously dead code, so we'll try to make things a little bit prettier - * by doing a minimal check on whether some common patterns always explicitly return. - */ - function isSufficientlyCoveredByReturnStatements(statement) { - // A return statement is considered covered. - if (statement.kind === 211 /* ReturnStatement */) { - return true; - } - else if (statement.kind === 203 /* IfStatement */) { - var ifStatement = statement; - if (ifStatement.elseStatement) { - return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && - isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); - } - } - else if (statement.kind === 199 /* Block */) { - var lastStatement = ts.lastOrUndefined(statement.statements); - if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { - return true; - } - } - return false; - } - /** - * Declares a `_this` variable for derived classes and for when arrow functions capture `this`. + * Transforms a SourceFile into an AMD module. * - * @returns The new statement offset into the `statements` array. + * @param node The SourceFile node. */ - function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, hasExtendsClause, hasSynthesizedSuper, statementOffset) { - // If this isn't a derived class, just capture 'this' for arrow functions if necessary. - if (!hasExtendsClause) { - if (ctor) { - addCaptureThisForNodeIfNeeded(statements, ctor); - } - return 0 /* NoReplacement */; - } - // We must be here because the user didn't write a constructor - // but we needed to call 'super(...args)' anyway as per 14.5.14 of the ES2016 spec. - // If that's the case we can just immediately return the result of a 'super()' call. - if (!ctor) { - statements.push(ts.createReturn(createDefaultSuperCallOrThis())); - return 2 /* ReplaceWithReturn */; - } - // The constructor exists, but it and the 'super()' call it contains were generated - // for something like property initializers. - // Create a captured '_this' variable and assume it will subsequently be used. - if (hasSynthesizedSuper) { - captureThisForNode(statements, ctor, createDefaultSuperCallOrThis()); - enableSubstitutionsForCapturedThis(); - return 1 /* ReplaceSuperCapture */; - } - // Most of the time, a 'super' call will be the first real statement in a constructor body. - // In these cases, we'd like to transform these into a *single* statement instead of a declaration - // followed by an assignment statement for '_this'. For instance, if we emitted without an initializer, - // we'd get: + function transformAMDModule(node) { + var define = ts.createIdentifier("define"); + var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); + return transformAsynchronousModule(node, define, moduleName, /*includeNonAmdDependencies*/ true); + } + /** + * Transforms a SourceFile into a UMD module. + * + * @param node The SourceFile node. + */ + function transformUMDModule(node) { + var define = ts.createIdentifier("define"); + ts.setEmitFlags(define, 16 /* UMDDefine */); + return transformAsynchronousModule(node, define, /*moduleName*/ undefined, /*includeNonAmdDependencies*/ false); + } + /** + * Transforms a SourceFile into an AMD or UMD module. + * + * @param node The SourceFile node. + * @param define The expression used to define the module. + * @param moduleName An expression for the module name, if available. + * @param includeNonAmdDependencies A value indicating whether to incldue any non-AMD dependencies. + */ + function transformAsynchronousModule(node, define, moduleName, includeNonAmdDependencies) { + // An AMD define function has the following shape: // - // var _this; - // _this = _super.call(...) || this; + // define(id?, dependencies?, factory); // - // instead of + // This has the shape of the following: // - // var _this = _super.call(...) || this; + // define(name, ["module1", "module2"], function (module1Alias) { ... } // - // Additionally, if the 'super()' call is the last statement, we should just avoid capturing - // entirely and immediately return the result like so: + // 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. // - // return _super.call(...) || this; + // To ensure this is true in cases of modules with no aliases, e.g.: // - var firstStatement; - var superCallExpression; - var ctorStatements = ctor.body.statements; - if (statementOffset < ctorStatements.length) { - firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 202 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { - var superCall = firstStatement.expression; - superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); - } - } - // Return the result if we have an immediate super() call on the last statement. - if (superCallExpression && statementOffset === ctorStatements.length - 1) { - statements.push(ts.createReturn(superCallExpression)); - return 2 /* ReplaceWithReturn */; - } - // Perform the capture. - captureThisForNode(statements, ctor, superCallExpression, firstStatement); - // If we're actually replacing the original statement, we need to signal this to the caller. - if (superCallExpression) { - return 1 /* ReplaceSuperCapture */; - } - return 0 /* NoReplacement */; - } - function createDefaultSuperCallOrThis() { - var actualThis = ts.createThis(); - ts.setEmitFlags(actualThis, 128 /* NoSubstitution */); - var superCall = ts.createFunctionApply(ts.createIdentifier("_super"), actualThis, ts.createIdentifier("arguments")); - return ts.createLogicalOr(superCall, actualThis); - } - /** - * Visits a parameter declaration. - * - * @param node A ParameterDeclaration node. - */ - function visitParameter(node) { - if (node.dotDotDotToken) { - // rest parameters are elided - return undefined; - } - else if (ts.isBindingPattern(node.name)) { - // Binding patterns are converted into a generated name and are - // evaluated inside the function body. - return ts.setOriginalNode(ts.createParameter(ts.getGeneratedNameForNode(node), - /*initializer*/ undefined, - /*location*/ node), - /*original*/ node); - } - else if (node.initializer) { - // Initializers are elided - return ts.setOriginalNode(ts.createParameter(node.name, - /*initializer*/ undefined, - /*location*/ node), - /*original*/ node); - } - else { - return node; - } - } - /** - * Gets a value indicating whether we need to add default value assignments for a - * function-like node. - * - * @param node A function-like node. - */ - function shouldAddDefaultValueAssignments(node) { - return (node.transformFlags & 65536 /* ContainsDefaultValueAssignments */) !== 0; - } - /** - * Adds statements to the body of a function-like node if it contains parameters with - * binding patterns or initializers. - * - * @param statements The statements for the new function body. - * @param node A function-like node. - */ - function addDefaultValueAssignmentsIfNeeded(statements, node) { - if (!shouldAddDefaultValueAssignments(node)) { - return; - } - for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { - var parameter = _a[_i]; - var name_38 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; - // A rest parameter cannot have a binding pattern or an initializer, - // so let's just ignore it. - if (dotDotDotToken) { - continue; - } - if (ts.isBindingPattern(name_38)) { - addDefaultValueAssignmentForBindingPattern(statements, parameter, name_38, initializer); - } - else if (initializer) { - addDefaultValueAssignmentForInitializer(statements, parameter, name_38, initializer); - } - } - } - /** - * Adds statements to the body of a function-like node for parameters with binding patterns - * - * @param statements The statements for the new function body. - * @param parameter The parameter for the function. - * @param name The name of the parameter. - * @param initializer The initializer for the parameter. - */ - function addDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer) { - var temp = ts.getGeneratedNameForNode(parameter); - // In cases where a binding pattern is simply '[]' or '{}', - // we usually don't want to emit a var declaration; however, in the presence - // of an initializer, we must emit that expression to preserve side effects. - if (name.elements.length > 0) { - statements.push(ts.setEmitFlags(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList(ts.flattenParameterDestructuring(context, parameter, temp, visitor))), 8388608 /* CustomPrologue */)); - } - else if (initializer) { - statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 8388608 /* CustomPrologue */)); - } - } - /** - * Adds statements to the body of a function-like node for parameters with initializers. - * - * @param statements The statements for the new function body. - * @param parameter The parameter for the function. - * @param name The name of the parameter. - * @param initializer The initializer for the parameter. - */ - function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) { - initializer = ts.visitNode(initializer, visitor, ts.isExpression); - var statement = ts.createIf(ts.createStrictEquality(ts.getSynthesizedClone(name), ts.createVoidZero()), ts.setEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 1536 /* NoSourceMap */), ts.setEmitFlags(initializer, 1536 /* NoSourceMap */ | ts.getEmitFlags(initializer)), - /*location*/ parameter)) - ], /*location*/ parameter), 32 /* SingleLine */ | 1024 /* NoTrailingSourceMap */ | 12288 /* NoTokenSourceMaps */), - /*elseStatement*/ undefined, - /*location*/ parameter); - statement.startsOnNewLine = true; - ts.setEmitFlags(statement, 12288 /* NoTokenSourceMaps */ | 1024 /* NoTrailingSourceMap */ | 8388608 /* CustomPrologue */); - statements.push(statement); - } - /** - * Gets a value indicating whether we need to add statements to handle a rest parameter. - * - * @param node A ParameterDeclaration node. - * @param inConstructorWithSynthesizedSuper A value indicating whether the parameter is - * part of a constructor declaration with a - * synthesized call to `super` - */ - function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) { - return node && node.dotDotDotToken && node.name.kind === 69 /* Identifier */ && !inConstructorWithSynthesizedSuper; - } - /** - * Adds statements to the body of a function-like node if it contains a rest parameter. - * - * @param statements The statements for the new function body. - * @param node A function-like node. - * @param inConstructorWithSynthesizedSuper A value indicating whether the parameter is - * part of a constructor declaration with a - * synthesized call to `super` - */ - function addRestParameterIfNeeded(statements, node, inConstructorWithSynthesizedSuper) { - var parameter = ts.lastOrUndefined(node.parameters); - if (!shouldAddRestParameter(parameter, inConstructorWithSynthesizedSuper)) { - return; - } - // `declarationName` is the name of the local declaration for the parameter. - var declarationName = ts.getMutableClone(parameter.name); - ts.setEmitFlags(declarationName, 1536 /* NoSourceMap */); - // `expressionName` is the name of the parameter used in expressions. - var expressionName = ts.getSynthesizedClone(parameter.name); - var restIndex = node.parameters.length - 1; - var temp = ts.createLoopVariable(); - // var param = []; - statements.push(ts.setEmitFlags(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(declarationName, - /*type*/ undefined, ts.createArrayLiteral([])) - ]), - /*location*/ parameter), 8388608 /* CustomPrologue */)); - // for (var _i = restIndex; _i < arguments.length; _i++) { - // param[_i - restIndex] = arguments[_i]; - // } - var forStatement = ts.createFor(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(temp, /*type*/ undefined, ts.createLiteral(restIndex)) - ], /*location*/ parameter), ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length"), - /*location*/ parameter), ts.createPostfixIncrement(temp, /*location*/ parameter), ts.createBlock([ - ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp)), - /*location*/ parameter)) - ])); - ts.setEmitFlags(forStatement, 8388608 /* CustomPrologue */); - ts.startOnNewLine(forStatement); - statements.push(forStatement); - } - /** - * Adds a statement to capture the `this` of a function declaration if it is needed. - * - * @param statements The statements for the new function body. - * @param node A node. - */ - function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 16384 /* ContainsCapturedLexicalThis */ && node.kind !== 180 /* ArrowFunction */) { - captureThisForNode(statements, node, ts.createThis()); - } - } - function captureThisForNode(statements, node, initializer, originalStatement) { - enableSubstitutionsForCapturedThis(); - var captureThisStatement = ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration("_this", - /*type*/ undefined, initializer) - ]), originalStatement); - ts.setEmitFlags(captureThisStatement, 49152 /* NoComments */ | 8388608 /* CustomPrologue */); - ts.setSourceMapRange(captureThisStatement, node); - statements.push(captureThisStatement); - } - /** - * Adds statements to the class body function for a class to define the members of the - * class. - * - * @param statements The statements for the class body function. - * @param node The ClassExpression or ClassDeclaration node. - */ - function addClassMembers(statements, node) { - for (var _i = 0, _a = node.members; _i < _a.length; _i++) { - var member = _a[_i]; - switch (member.kind) { - case 198 /* SemicolonClassElement */: - statements.push(transformSemicolonClassElementToStatement(member)); - break; - case 147 /* MethodDeclaration */: - statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member)); - break; - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - var accessors = ts.getAllAccessorDeclarations(node.members, member); - if (member === accessors.firstAccessor) { - statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors)); - } - break; - case 148 /* Constructor */: - // Constructors are handled in visitClassExpression/visitClassDeclaration - break; - default: - ts.Debug.failBadSyntaxKind(node); - break; - } - } - } - /** - * Transforms a SemicolonClassElement into a statement for a class body function. - * - * @param member The SemicolonClassElement node. - */ - function transformSemicolonClassElementToStatement(member) { - return ts.createEmptyStatement(/*location*/ member); - } - /** - * Transforms a MethodDeclaration into a statement for a class body function. - * - * @param receiver The receiver for the member. - * @param member The MethodDeclaration node. - */ - function transformClassMethodDeclarationToStatement(receiver, member) { - var commentRange = ts.getCommentRange(member); - var sourceMapRange = ts.getSourceMapRange(member); - var func = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined); - ts.setEmitFlags(func, 49152 /* NoComments */); - ts.setSourceMapRange(func, sourceMapRange); - var statement = ts.createStatement(ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), - /*location*/ member.name), func), - /*location*/ member); - ts.setOriginalNode(statement, member); - ts.setCommentRange(statement, commentRange); - // The location for the statement is used to emit comments only. - // No source map should be emitted for this statement to align with the - // old emitter. - ts.setEmitFlags(statement, 1536 /* NoSourceMap */); - return statement; - } - /** - * Transforms a set of related of get/set accessors into a statement for a class body function. - * - * @param receiver The receiver for the member. - * @param accessors The set of related get/set accessors. - */ - function transformAccessorsToStatement(receiver, accessors) { - var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, /*startsOnNewLine*/ false), - /*location*/ ts.getSourceMapRange(accessors.firstAccessor)); - // The location for the statement is used to emit source maps only. - // No comments should be emitted for this statement to align with the - // old emitter. - ts.setEmitFlags(statement, 49152 /* NoComments */); - return statement; - } - /** - * Transforms a set of related get/set accessors into an expression for either a class - * body function or an ObjectLiteralExpression with computed properties. - * - * @param receiver The receiver for the member. - */ - function transformAccessorsToExpression(receiver, _a, startsOnNewLine) { - var firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; - // To align with source maps in the old emitter, the receiver and property name - // arguments are both mapped contiguously to the accessor name. - var target = ts.getMutableClone(receiver); - ts.setEmitFlags(target, 49152 /* NoComments */ | 1024 /* NoTrailingSourceMap */); - ts.setSourceMapRange(target, firstAccessor.name); - var propertyName = ts.createExpressionForPropertyName(ts.visitNode(firstAccessor.name, visitor, ts.isPropertyName)); - ts.setEmitFlags(propertyName, 49152 /* NoComments */ | 512 /* NoLeadingSourceMap */); - ts.setSourceMapRange(propertyName, firstAccessor.name); - var properties = []; - if (getAccessor) { - var getterFunction = transformFunctionLikeToExpression(getAccessor, /*location*/ undefined, /*name*/ undefined); - ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); - var getter = ts.createPropertyAssignment("get", getterFunction); - ts.setCommentRange(getter, ts.getCommentRange(getAccessor)); - properties.push(getter); - } - if (setAccessor) { - var setterFunction = transformFunctionLikeToExpression(setAccessor, /*location*/ undefined, /*name*/ undefined); - ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); - var setter = ts.createPropertyAssignment("set", setterFunction); - ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); - properties.push(setter); - } - properties.push(ts.createPropertyAssignment("enumerable", ts.createLiteral(true)), ts.createPropertyAssignment("configurable", ts.createLiteral(true))); - var call = ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), - /*typeArguments*/ undefined, [ - target, - propertyName, - ts.createObjectLiteral(properties, /*location*/ undefined, /*multiLine*/ true) + // import "module" + // + // or + // + // /// + // + // we need to add modules without alias names to the end of the dependencies list + var _a = collectAsynchronousDependencies(node, includeNonAmdDependencies), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + // Create an updated SourceFile: + // + // define(moduleName?, ["module1", "module2"], function ... + return updateSourceFile(node, [ + ts.createStatement(ts.createCall(define, + /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ + // Add the dependency array argument: + // + // ["require", "exports", module1", "module2", ...] + ts.createArrayLiteral([ + ts.createLiteral("require"), + ts.createLiteral("exports") + ].concat(aliasedModuleNames, unaliasedModuleNames)), + // Add the module body function argument: + // + // function (require, exports, module1, module2) ... + ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, [ + ts.createParameter("require"), + ts.createParameter("exports") + ].concat(importAliasNames), + /*type*/ undefined, transformAsynchronousModuleBody(node)) + ]))) ]); - if (startsOnNewLine) { - call.startsOnNewLine = true; - } - return call; } /** - * Visits an ArrowFunction and transforms it into a FunctionExpression. + * Transforms a SourceFile into an AMD or UMD module body. * - * @param node An ArrowFunction node. + * @param node The SourceFile node. */ - function visitArrowFunction(node) { - if (node.transformFlags & 8192 /* ContainsLexicalThis */) { - enableSubstitutionsForCapturedThis(); - } - var func = transformFunctionLikeToExpression(node, /*location*/ node, /*name*/ undefined); - ts.setEmitFlags(func, 256 /* CapturesThis */); - return func; - } - /** - * Visits a FunctionExpression node. - * - * @param node a FunctionExpression node. - */ - function visitFunctionExpression(node) { - return transformFunctionLikeToExpression(node, /*location*/ node, node.name); - } - /** - * Visits a FunctionDeclaration node. - * - * @param node a FunctionDeclaration node. - */ - function visitFunctionDeclaration(node) { - return ts.setOriginalNode(ts.createFunctionDeclaration( - /*decorators*/ undefined, node.modifiers, node.asteriskToken, node.name, - /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), - /*type*/ undefined, transformFunctionBody(node), - /*location*/ node), - /*original*/ node); - } - /** - * Transforms a function-like node into a FunctionExpression. - * - * @param node The function-like node to transform. - * @param location The source-map location for the new FunctionExpression. - * @param name The name of the new FunctionExpression. - */ - function transformFunctionLikeToExpression(node, location, name) { - var savedContainingNonArrowFunction = enclosingNonArrowFunction; - if (node.kind !== 180 /* ArrowFunction */) { - enclosingNonArrowFunction = node; - } - var expression = ts.setOriginalNode(ts.createFunctionExpression(node.asteriskToken, name, - /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), - /*type*/ undefined, saveStateAndInvoke(node, transformFunctionBody), location), - /*original*/ node); - enclosingNonArrowFunction = savedContainingNonArrowFunction; - return expression; - } - /** - * Transforms the body of a function-like node. - * - * @param node A function-like node. - */ - function transformFunctionBody(node) { - var multiLine = false; // indicates whether the block *must* be emitted as multiple lines - var singleLine = false; // indicates whether the block *may* be emitted as a single line - var statementsLocation; - var closeBraceLocation; - var statements = []; - var body = node.body; - var statementOffset; + function transformAsynchronousModuleBody(node) { startLexicalEnvironment(); - if (ts.isBlock(body)) { - // ensureUseStrict is false because no new prologue-directive should be added. - // addPrologueDirectives will simply put already-existing directives at the beginning of the target statement-array - statementOffset = ts.addPrologueDirectives(statements, body.statements, /*ensureUseStrict*/ false, visitor); - } - addCaptureThisForNodeIfNeeded(statements, node); - addDefaultValueAssignmentsIfNeeded(statements, node); - addRestParameterIfNeeded(statements, node, /*inConstructorWithSynthesizedSuper*/ false); - // If we added any generated statements, this must be a multi-line block. - if (!multiLine && statements.length > 0) { - multiLine = true; - } - if (ts.isBlock(body)) { - statementsLocation = body.statements; - ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, statementOffset)); - // If the original body was a multi-line block, this must be a multi-line block. - if (!multiLine && body.multiLine) { - multiLine = true; - } - } - else { - ts.Debug.assert(node.kind === 180 /* ArrowFunction */); - // To align with the old emitter, we use a synthetic end position on the location - // for the statement list we synthesize when we down-level an arrow function with - // an expression function body. This prevents both comments and source maps from - // being emitted for the end position only. - statementsLocation = ts.moveRangeEnd(body, -1); - var equalsGreaterThanToken = node.equalsGreaterThanToken; - if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { - if (ts.rangeEndIsOnSameLineAsRangeStart(equalsGreaterThanToken, body, currentSourceFile)) { - singleLine = true; - } - else { - multiLine = true; - } - } - var expression = ts.visitNode(body, visitor, ts.isExpression); - var returnStatement = ts.createReturn(expression, /*location*/ body); - ts.setEmitFlags(returnStatement, 12288 /* NoTokenSourceMaps */ | 1024 /* NoTrailingSourceMap */ | 32768 /* NoTrailingComments */); - statements.push(returnStatement); - // To align with the source map emit for the old emitter, we set a custom - // source map location for the close brace. - closeBraceLocation = body; - } - var lexicalEnvironment = endLexicalEnvironment(); - ts.addRange(statements, lexicalEnvironment); - // If we added any final generated statements, this must be a multi-line block - if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { - multiLine = true; - } - var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), node.body, multiLine); - if (!multiLine && singleLine) { - ts.setEmitFlags(block, 32 /* SingleLine */); - } - if (closeBraceLocation) { - ts.setTokenSourceMapRange(block, 16 /* CloseBraceToken */, closeBraceLocation); - } - ts.setOriginalNode(block, node.body); - return block; - } - /** - * Visits an ExpressionStatement that contains a destructuring assignment. - * - * @param node An ExpressionStatement node. - */ - function visitExpressionStatement(node) { - // If we are here it is most likely because our expression is a destructuring assignment. - switch (node.expression.kind) { - case 178 /* ParenthesizedExpression */: - return ts.updateStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 187 /* BinaryExpression */: - return ts.updateStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); - } - return ts.visitEachChild(node, visitor, context); - } - /** - * Visits a ParenthesizedExpression that may contain a destructuring assignment. - * - * @param node A ParenthesizedExpression node. - * @param needsDestructuringValue A value indicating whether we need to hold onto the rhs - * of a destructuring assignment. - */ - function visitParenthesizedExpression(node, needsDestructuringValue) { - // If we are here it is most likely because our expression is a destructuring assignment. - if (needsDestructuringValue) { - switch (node.expression.kind) { - case 178 /* ParenthesizedExpression */: - return ts.createParen(visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ true), - /*location*/ node); - case 187 /* BinaryExpression */: - return ts.createParen(visitBinaryExpression(node.expression, /*needsDestructuringValue*/ true), - /*location*/ node); - } - } - return ts.visitEachChild(node, visitor, context); - } - /** - * Visits a BinaryExpression that contains a destructuring assignment. - * - * @param node A BinaryExpression node. - * @param needsDestructuringValue A value indicating whether we need to hold onto the rhs - * of a destructuring assignment. - */ - function visitBinaryExpression(node, needsDestructuringValue) { - // If we are here it is because this is a destructuring assignment. - ts.Debug.assert(ts.isDestructuringAssignment(node)); - return ts.flattenDestructuringAssignment(context, node, needsDestructuringValue, hoistVariableDeclaration, visitor); - } - function visitVariableStatement(node) { - if (convertedLoopState && (ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */) == 0) { - // we are inside a converted loop - hoist variable declarations - var assignments = void 0; - for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - hoistVariableDeclarationDeclaredInConvertedLoop(convertedLoopState, decl); - if (decl.initializer) { - var assignment = void 0; - if (ts.isBindingPattern(decl.name)) { - assignment = ts.flattenVariableDestructuringToExpression(context, decl, hoistVariableDeclaration, /*nameSubstitution*/ undefined, visitor); - } - else { - assignment = ts.createBinary(decl.name, 56 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); - } - (assignments || (assignments = [])).push(assignment); - } - } - if (assignments) { - return ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 24 /* CommaToken */, acc); }), node); - } - else { - // none of declarations has initializer - the entire variable statement can be deleted - return undefined; - } - } - return ts.visitEachChild(node, visitor, context); - } - /** - * Visits a VariableDeclarationList that is block scoped (e.g. `let` or `const`). - * - * @param node A VariableDeclarationList node. - */ - function visitVariableDeclarationList(node) { - if (node.flags & 3 /* BlockScoped */) { - enableSubstitutionsForBlockScopedBindings(); - } - var declarations = ts.flatten(ts.map(node.declarations, node.flags & 1 /* Let */ - ? visitVariableDeclarationInLetDeclarationList - : visitVariableDeclaration)); - var declarationList = ts.createVariableDeclarationList(declarations, /*location*/ node); - ts.setOriginalNode(declarationList, node); - ts.setCommentRange(declarationList, node); - if (node.transformFlags & 2097152 /* ContainsBindingPattern */ - && (ts.isBindingPattern(node.declarations[0].name) - || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { - // If the first or last declaration is a binding pattern, we need to modify - // the source map range for the declaration list. - var firstDeclaration = ts.firstOrUndefined(declarations); - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); - } - return declarationList; - } - /** - * Gets a value indicating whether we should emit an explicit initializer for a variable - * declaration in a `let` declaration list. - * - * @param node A VariableDeclaration node. - */ - function shouldEmitExplicitInitializerForLetDeclaration(node) { - // Nested let bindings might need to be initialized explicitly to preserve - // ES6 semantic: - // - // { let x = 1; } - // { let x; } // x here should be undefined. not 1 - // - // Top level bindings never collide with anything and thus don't require - // explicit initialization. As for nested let bindings there are two cases: - // - // - Nested let bindings that were not renamed definitely should be - // initialized explicitly: - // - // { let x = 1; } - // { let x; if (some-condition) { x = 1}; if (x) { /*1*/ } } - // - // Without explicit initialization code in /*1*/ can be executed even if - // some-condition is evaluated to false. - // - // - Renaming introduces fresh name that should not collide with any - // existing names, however renamed bindings sometimes also should be - // explicitly initialized. One particular case: non-captured binding - // declared inside loop body (but not in loop initializer): - // - // let x; - // for (;;) { - // let x; - // } - // - // In downlevel codegen inner 'x' will be renamed so it won't collide - // with outer 'x' however it will should be reset on every iteration as - // if it was declared anew. - // - // * Why non-captured binding? - // - Because if loop contains block scoped binding captured in some - // function then loop body will be rewritten to have a fresh scope - // on every iteration so everything will just work. - // - // * Why loop initializer is excluded? - // - Since we've introduced a fresh name it already will be undefined. - var flags = resolver.getNodeCheckFlags(node); - var isCapturedInFunction = flags & 131072 /* CapturedBlockScopedBinding */; - var isDeclaredInLoop = flags & 262144 /* BlockScopedBindingInLoop */; - var emittedAsTopLevel = ts.isBlockScopedContainerTopLevel(enclosingBlockScopeContainer) - || (isCapturedInFunction - && isDeclaredInLoop - && ts.isBlock(enclosingBlockScopeContainer) - && ts.isIterationStatement(enclosingBlockScopeContainerParent, /*lookInLabeledStatements*/ false)); - var emitExplicitInitializer = !emittedAsTopLevel - && enclosingBlockScopeContainer.kind !== 207 /* ForInStatement */ - && enclosingBlockScopeContainer.kind !== 208 /* ForOfStatement */ - && (!resolver.isDeclarationWithCollidingName(node) - || (isDeclaredInLoop - && !isCapturedInFunction - && !ts.isIterationStatement(enclosingBlockScopeContainer, /*lookInLabeledStatements*/ false))); - return emitExplicitInitializer; - } - /** - * Visits a VariableDeclaration in a `let` declaration list. - * - * @param node A VariableDeclaration node. - */ - function visitVariableDeclarationInLetDeclarationList(node) { - // For binding pattern names that lack initializers there is no point to emit - // explicit initializer since downlevel codegen for destructuring will fail - // in the absence of initializer so all binding elements will say uninitialized - var name = node.name; - if (ts.isBindingPattern(name)) { - return visitVariableDeclaration(node); - } - if (!node.initializer && shouldEmitExplicitInitializerForLetDeclaration(node)) { - var clone_8 = ts.getMutableClone(node); - clone_8.initializer = ts.createVoidZero(); - return clone_8; - } - return ts.visitEachChild(node, visitor, context); - } - /** - * Visits a VariableDeclaration node with a binding pattern. - * - * @param node A VariableDeclaration node. - */ - function visitVariableDeclaration(node) { - // If we are here it is because the name contains a binding pattern. - if (ts.isBindingPattern(node.name)) { - var recordTempVariablesInLine = !enclosingVariableStatement - || !ts.hasModifier(enclosingVariableStatement, 1 /* Export */); - return ts.flattenVariableDestructuring(context, node, /*value*/ undefined, visitor, recordTempVariablesInLine ? undefined : hoistVariableDeclaration); - } - return ts.visitEachChild(node, visitor, context); - } - function visitLabeledStatement(node) { - if (convertedLoopState) { - if (!convertedLoopState.labels) { - convertedLoopState.labels = ts.createMap(); - } - convertedLoopState.labels[node.label.text] = node.label.text; - } - var result; - if (ts.isIterationStatement(node.statement, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node.statement)) { - result = ts.visitNodes(ts.createNodeArray([node.statement]), visitor, ts.isStatement); - } - else { - result = ts.visitEachChild(node, visitor, context); - } - if (convertedLoopState) { - convertedLoopState.labels[node.label.text] = undefined; - } - return result; - } - function visitDoStatement(node) { - return convertIterationStatementBodyIfNecessary(node); - } - function visitWhileStatement(node) { - return convertIterationStatementBodyIfNecessary(node); - } - function visitForStatement(node) { - return convertIterationStatementBodyIfNecessary(node); - } - function visitForInStatement(node) { - return convertIterationStatementBodyIfNecessary(node); - } - /** - * Visits a ForOfStatement and converts it into a compatible ForStatement. - * - * @param node A ForOfStatement. - */ - function visitForOfStatement(node) { - return convertIterationStatementBodyIfNecessary(node, convertForOfToFor); - } - function convertForOfToFor(node, convertedLoopBodyStatements) { - // The following ES6 code: - // - // for (let v of expr) { } - // - // should be emitted as - // - // for (var _i = 0, _a = expr; _i < _a.length; _i++) { - // var v = _a[_i]; - // } - // - // where _a and _i are temps emitted to capture the RHS and the counter, - // respectively. - // When the left hand side is an expression instead of a let declaration, - // the "let v" is not emitted. - // When the left hand side is a let/const, the v is renamed if there is - // another v in scope. - // Note that all assignments to the LHS are emitted in the body, including - // all destructuring. - // Note also that because an extra statement is needed to assign to the LHS, - // for-of bodies are always emitted as blocks. - var expression = ts.visitNode(node.expression, visitor, ts.isExpression); - var initializer = node.initializer; var statements = []; - // In the case where the user wrote an identifier as the RHS, like this: - // - // for (let v of arr) { } - // - // we don't want to emit a temporary variable for the RHS, just use it directly. - var counter = ts.createLoopVariable(); - var rhsReference = expression.kind === 69 /* Identifier */ - ? ts.createUniqueName(expression.text) - : ts.createTempVariable(/*recordTempVariable*/ undefined); - // Initialize LHS - // var v = _a[_i]; - if (ts.isVariableDeclarationList(initializer)) { - if (initializer.flags & 3 /* BlockScoped */) { - enableSubstitutionsForBlockScopedBindings(); - } - var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); - if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { - // This works whether the declaration is a var, let, or const. - // It will use rhsIterationValue _a[_i] as the initializer. - var declarations = ts.flattenVariableDestructuring(context, firstOriginalDeclaration, ts.createElementAccess(rhsReference, counter), visitor); - var declarationList = ts.createVariableDeclarationList(declarations, /*location*/ initializer); - ts.setOriginalNode(declarationList, initializer); - // Adjust the source map range for the first declaration to align with the old - // emitter. - var firstDeclaration = declarations[0]; - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, declarationList)); - } - else { - // The following call does not include the initializer, so we have - // to emit it separately. - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(/*recordTempVariable*/ undefined), - /*type*/ undefined, ts.createElementAccess(rhsReference, counter)) - ], /*location*/ ts.moveRangePos(initializer, -1)), - /*location*/ ts.moveRangeEnd(initializer, -1))); - } + var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, visitor); + // Visit each statement of the module body. + ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); + // End the lexical environment for the module body + // and merge any new lexical declarations. + ts.addRange(statements, endLexicalEnvironment()); + // Append the 'export =' statement if provided. + addExportEqualsIfNeeded(statements, /*emitAsReturn*/ true); + var body = ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true); + if (hasExportStarsToExportValues) { + // If we have any `export * from ...` declarations + // we need to inform the emitter to add the __export helper. + ts.setEmitFlags(body, 2 /* EmitExportStar */); } - else { - // Initializer is an expression. Emit the expression in the body, so that it's - // evaluated on every iteration. - var assignment = ts.createAssignment(initializer, ts.createElementAccess(rhsReference, counter)); - if (ts.isDestructuringAssignment(assignment)) { - // This is a destructuring pattern, so we flatten the destructuring instead. - statements.push(ts.createStatement(ts.flattenDestructuringAssignment(context, assignment, - /*needsValue*/ false, hoistVariableDeclaration, visitor))); - } - else { - // Currently there is not way to check that assignment is binary expression of destructing assignment - // so we have to cast never type to binaryExpression - assignment.end = initializer.end; - statements.push(ts.createStatement(assignment, /*location*/ ts.moveRangeEnd(initializer, -1))); - } - } - var bodyLocation; - var statementsLocation; - if (convertedLoopBodyStatements) { - ts.addRange(statements, convertedLoopBodyStatements); - } - else { - var statement = ts.visitNode(node.statement, visitor, ts.isStatement); - if (ts.isBlock(statement)) { - ts.addRange(statements, statement.statements); - bodyLocation = statement; - statementsLocation = statement.statements; + return body; + } + function addExportEqualsIfNeeded(statements, emitAsReturn) { + if (exportEquals) { + if (emitAsReturn) { + var statement = ts.createReturn(exportEquals.expression, + /*location*/ exportEquals); + ts.setEmitFlags(statement, 12288 /* NoTokenSourceMaps */ | 49152 /* NoComments */); + statements.push(statement); } else { + var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), exportEquals.expression), + /*location*/ exportEquals); + ts.setEmitFlags(statement, 49152 /* NoComments */); statements.push(statement); } } - // The old emitter does not emit source maps for the expression - ts.setEmitFlags(expression, 1536 /* NoSourceMap */ | ts.getEmitFlags(expression)); - // The old emitter does not emit source maps for the block. - // We add the location to preserve comments. - var body = ts.createBlock(ts.createNodeArray(statements, /*location*/ statementsLocation), - /*location*/ bodyLocation); - ts.setEmitFlags(body, 1536 /* NoSourceMap */ | 12288 /* NoTokenSourceMaps */); - var forStatement = ts.createFor(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(counter, /*type*/ undefined, ts.createLiteral(0), /*location*/ ts.moveRangePos(node.expression, -1)), - ts.createVariableDeclaration(rhsReference, /*type*/ undefined, expression, /*location*/ node.expression) - ], /*location*/ node.expression), ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length"), - /*location*/ node.expression), ts.createPostfixIncrement(counter, /*location*/ node.expression), body, - /*location*/ node); - // Disable trailing source maps for the OpenParenToken to align source map emit with the old emitter. - ts.setEmitFlags(forStatement, 8192 /* NoTokenTrailingSourceMaps */); - return forStatement; } /** - * Visits an ObjectLiteralExpression with computed propety names. + * Visits a node at the top level of the source file. * - * @param node An ObjectLiteralExpression node. + * @param node The node. */ - function visitObjectLiteralExpression(node) { - // We are here because a ComputedPropertyName was used somewhere in the expression. - var properties = node.properties; - var numProperties = properties.length; - // Find the first computed property. - // Everything until that point can be emitted as part of the initial object literal. - var numInitialProperties = numProperties; - for (var i = 0; i < numProperties; i++) { - var property = properties[i]; - if (property.transformFlags & 4194304 /* ContainsYield */ - || property.name.kind === 140 /* ComputedPropertyName */) { - numInitialProperties = i; - break; - } + function visitor(node) { + switch (node.kind) { + case 231 /* ImportDeclaration */: + return visitImportDeclaration(node); + case 230 /* ImportEqualsDeclaration */: + return visitImportEqualsDeclaration(node); + case 237 /* ExportDeclaration */: + return visitExportDeclaration(node); + case 236 /* ExportAssignment */: + return visitExportAssignment(node); + case 201 /* VariableStatement */: + return visitVariableStatement(node); + case 221 /* FunctionDeclaration */: + return visitFunctionDeclaration(node); + case 222 /* ClassDeclaration */: + return visitClassDeclaration(node); + case 203 /* ExpressionStatement */: + return visitExpressionStatement(node); + default: + // This visitor does not descend into the tree, as export/import statements + // are only transformed at the top level of a file. + return node; } - ts.Debug.assert(numInitialProperties !== numProperties); - // For computed properties, we need to create a unique handle to the object - // literal so we can modify it without risking internal assignments tainting the object. - var temp = ts.createTempVariable(hoistVariableDeclaration); - // Write out the first non-computed properties, then emit the rest through indexing on the temp variable. - var expressions = []; - var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), - /*location*/ undefined, node.multiLine), 524288 /* Indented */)); - if (node.multiLine) { - assignment.startsOnNewLine = true; - } - expressions.push(assignment); - addObjectLiteralMembers(expressions, node, temp, numInitialProperties); - // We need to clone the temporary identifier so that we can write it on a - // new line - expressions.push(node.multiLine ? ts.startOnNewLine(ts.getMutableClone(temp)) : temp); - return ts.inlineExpressions(expressions); - } - function shouldConvertIterationStatementBody(node) { - return (resolver.getNodeCheckFlags(node) & 65536 /* LoopWithCapturedBlockScopedBinding */) !== 0; } /** - * Records constituents of name for the given variable to be hoisted in the outer scope. + * Visits an ImportDeclaration node. + * + * @param node The ImportDeclaration node. */ - function hoistVariableDeclarationDeclaredInConvertedLoop(state, node) { - if (!state.hoistedLocalVariables) { - state.hoistedLocalVariables = []; + function visitImportDeclaration(node) { + if (!ts.contains(externalImports, node)) { + return undefined; } - visit(node.name); - function visit(node) { - if (node.kind === 69 /* Identifier */) { - state.hoistedLocalVariables.push(node); - } - else { - for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (!ts.isOmittedExpression(element)) { - visit(element.name); - } - } - } - } - } - function convertIterationStatementBodyIfNecessary(node, convert) { - if (!shouldConvertIterationStatementBody(node)) { - var saveAllowedNonLabeledJumps = void 0; - if (convertedLoopState) { - // we get here if we are trying to emit normal loop loop inside converted loop - // set allowedNonLabeledJumps to Break | Continue to mark that break\continue inside the loop should be emitted as is - saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; - convertedLoopState.allowedNonLabeledJumps = 2 /* Break */ | 4 /* Continue */; - } - var result = convert ? convert(node, /*convertedLoopBodyStatements*/ undefined) : ts.visitEachChild(node, visitor, context); - if (convertedLoopState) { - convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps; - } - return result; - } - var functionName = ts.createUniqueName("_loop"); - var loopInitializer; - switch (node.kind) { - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: - var initializer = node.initializer; - if (initializer && initializer.kind === 219 /* VariableDeclarationList */) { - loopInitializer = initializer; - } - break; - } - // variables that will be passed to the loop as parameters - var loopParameters = []; - // variables declared in the loop initializer that will be changed inside the loop - var loopOutParameters = []; - if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3 /* BlockScoped */)) { - for (var _i = 0, _a = loopInitializer.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - processLoopVariableDeclaration(decl, loopParameters, loopOutParameters); - } - } - var outerConvertedLoopState = convertedLoopState; - convertedLoopState = { loopOutParameters: loopOutParameters }; - if (outerConvertedLoopState) { - // convertedOuterLoopState !== undefined means that this converted loop is nested in another converted loop. - // if outer converted loop has already accumulated some state - pass it through - if (outerConvertedLoopState.argumentsName) { - // outer loop has already used 'arguments' so we've already have some name to alias it - // use the same name in all nested loops - convertedLoopState.argumentsName = outerConvertedLoopState.argumentsName; - } - if (outerConvertedLoopState.thisName) { - // outer loop has already used 'this' so we've already have some name to alias it - // use the same name in all nested loops - convertedLoopState.thisName = outerConvertedLoopState.thisName; - } - if (outerConvertedLoopState.hoistedLocalVariables) { - // we've already collected some non-block scoped variable declarations in enclosing loop - // use the same storage in nested loop - convertedLoopState.hoistedLocalVariables = outerConvertedLoopState.hoistedLocalVariables; - } - } - var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement); - var currentState = convertedLoopState; - convertedLoopState = outerConvertedLoopState; - if (loopOutParameters.length) { - var statements_3 = ts.isBlock(loopBody) ? loopBody.statements.slice() : [loopBody]; - copyOutParameters(loopOutParameters, 1 /* ToOutParameter */, statements_3); - loopBody = ts.createBlock(statements_3, /*location*/ undefined, /*multiline*/ true); - } - if (!ts.isBlock(loopBody)) { - loopBody = ts.createBlock([loopBody], /*location*/ undefined, /*multiline*/ true); - } - var isAsyncBlockContainingAwait = enclosingNonArrowFunction - && (ts.getEmitFlags(enclosingNonArrowFunction) & 2097152 /* AsyncFunctionBody */) !== 0 - && (node.statement.transformFlags & 4194304 /* ContainsYield */) !== 0; - var loopBodyFlags = 0; - if (currentState.containsLexicalThis) { - loopBodyFlags |= 256 /* CapturesThis */; - } - if (isAsyncBlockContainingAwait) { - loopBodyFlags |= 2097152 /* AsyncFunctionBody */; - } - var convertedLoopVariable = ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(functionName, - /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression(isAsyncBlockContainingAwait ? ts.createToken(37 /* AsteriskToken */) : undefined, - /*name*/ undefined, - /*typeParameters*/ undefined, loopParameters, - /*type*/ undefined, loopBody), loopBodyFlags)) - ])); - var statements = [convertedLoopVariable]; - var extraVariableDeclarations; - // propagate state from the inner loop to the outer loop if necessary - if (currentState.argumentsName) { - // if alias for arguments is set - if (outerConvertedLoopState) { - // pass it to outer converted loop - outerConvertedLoopState.argumentsName = currentState.argumentsName; - } - else { - // this is top level converted loop and we need to create an alias for 'arguments' object - (extraVariableDeclarations || (extraVariableDeclarations = [])).push(ts.createVariableDeclaration(currentState.argumentsName, - /*type*/ undefined, ts.createIdentifier("arguments"))); - } - } - if (currentState.thisName) { - // if alias for this is set - if (outerConvertedLoopState) { - // pass it to outer converted loop - outerConvertedLoopState.thisName = currentState.thisName; - } - else { - // this is top level converted loop so we need to create an alias for 'this' here - // NOTE: - // if converted loops were all nested in arrow function then we'll always emit '_this' so convertedLoopState.thisName will not be set. - // If it is set this means that all nested loops are not nested in arrow function and it is safe to capture 'this'. - (extraVariableDeclarations || (extraVariableDeclarations = [])).push(ts.createVariableDeclaration(currentState.thisName, - /*type*/ undefined, ts.createIdentifier("this"))); - } - } - if (currentState.hoistedLocalVariables) { - // if hoistedLocalVariables !== undefined this means that we've possibly collected some variable declarations to be hoisted later - if (outerConvertedLoopState) { - // pass them to outer converted loop - outerConvertedLoopState.hoistedLocalVariables = currentState.hoistedLocalVariables; - } - else { - if (!extraVariableDeclarations) { - extraVariableDeclarations = []; - } - // hoist collected variable declarations - for (var _b = 0, _c = currentState.hoistedLocalVariables; _b < _c.length; _b++) { - var identifier = _c[_b]; - extraVariableDeclarations.push(ts.createVariableDeclaration(identifier)); - } - } - } - // add extra variables to hold out parameters if necessary - if (loopOutParameters.length) { - if (!extraVariableDeclarations) { - extraVariableDeclarations = []; - } - for (var _d = 0, loopOutParameters_1 = loopOutParameters; _d < loopOutParameters_1.length; _d++) { - var outParam = loopOutParameters_1[_d]; - extraVariableDeclarations.push(ts.createVariableDeclaration(outParam.outParamName)); - } - } - // create variable statement to hold all introduced variable declarations - if (extraVariableDeclarations) { - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList(extraVariableDeclarations))); - } - var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, isAsyncBlockContainingAwait); - var loop; - if (convert) { - loop = convert(node, convertedLoopBodyStatements); - } - else { - loop = ts.getMutableClone(node); - // clean statement part - loop.statement = undefined; - // visit childnodes to transform initializer/condition/incrementor parts - loop = ts.visitEachChild(loop, visitor, context); - // set loop statement - loop.statement = ts.createBlock(convertedLoopBodyStatements, - /*location*/ undefined, - /*multiline*/ true); - // reset and re-aggregate the transform flags - loop.transformFlags = 0; - ts.aggregateTransformFlags(loop); - } - statements.push(currentParent.kind === 214 /* LabeledStatement */ - ? ts.createLabel(currentParent.label, loop) - : loop); - return statements; - } - function copyOutParameter(outParam, copyDirection) { - var source = copyDirection === 0 /* ToOriginal */ ? outParam.outParamName : outParam.originalName; - var target = copyDirection === 0 /* ToOriginal */ ? outParam.originalName : outParam.outParamName; - return ts.createBinary(target, 56 /* EqualsToken */, source); - } - function copyOutParameters(outParams, copyDirection, statements) { - for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { - var outParam = outParams_1[_i]; - statements.push(ts.createStatement(copyOutParameter(outParam, copyDirection))); - } - } - function generateCallToConvertedLoop(loopFunctionExpressionName, parameters, state, isAsyncBlockContainingAwait) { - var outerConvertedLoopState = convertedLoopState; var statements = []; - // loop is considered simple if it does not have any return statements or break\continue that transfer control outside of the loop - // simple loops are emitted as just 'loop()'; - // NOTE: if loop uses only 'continue' it still will be emitted as simple loop - var isSimpleLoop = !(state.nonLocalJumps & ~4 /* Continue */) && - !state.labeledNonLocalBreaks && - !state.labeledNonLocalContinues; - var call = ts.createCall(loopFunctionExpressionName, /*typeArguments*/ undefined, ts.map(parameters, function (p) { return p.name; })); - var callResult = isAsyncBlockContainingAwait ? ts.createYield(ts.createToken(37 /* AsteriskToken */), call) : call; - if (isSimpleLoop) { - statements.push(ts.createStatement(callResult)); - copyOutParameters(state.loopOutParameters, 0 /* ToOriginal */, statements); - } - else { - var loopResultName = ts.createUniqueName("state"); - var stateVariable = ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ts.createVariableDeclaration(loopResultName, /*type*/ undefined, callResult)])); - statements.push(stateVariable); - copyOutParameters(state.loopOutParameters, 0 /* ToOriginal */, statements); - if (state.nonLocalJumps & 8 /* Return */) { - var returnStatement = void 0; - if (outerConvertedLoopState) { - outerConvertedLoopState.nonLocalJumps |= 8 /* Return */; - returnStatement = ts.createReturn(loopResultName); + var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); + if (moduleKind !== ts.ModuleKind.AMD) { + if (!node.importClause) { + // import "mod"; + statements.push(ts.createStatement(createRequireCall(node), + /*location*/ node)); + } + else { + var variables = []; + if (namespaceDeclaration && !ts.isDefaultImport(node)) { + // import * as n from "mod"; + variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), + /*type*/ undefined, createRequireCall(node))); } else { - returnStatement = ts.createReturn(ts.createPropertyAccess(loopResultName, "value")); + // import d from "mod"; + // import { x, y } from "mod"; + // import d, { x, y } from "mod"; + // import d, * as n from "mod"; + variables.push(ts.createVariableDeclaration(ts.getGeneratedNameForNode(node), + /*type*/ undefined, createRequireCall(node))); + if (namespaceDeclaration && ts.isDefaultImport(node)) { + variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), + /*type*/ undefined, ts.getGeneratedNameForNode(node))); + } } - statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 32 /* EqualsEqualsEqualsToken */, ts.createLiteral("object")), returnStatement)); - } - if (state.nonLocalJumps & 2 /* Break */) { - statements.push(ts.createIf(ts.createBinary(loopResultName, 32 /* EqualsEqualsEqualsToken */, ts.createLiteral("break")), ts.createBreak())); - } - if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { - var caseClauses = []; - processLabeledJumps(state.labeledNonLocalBreaks, /*isBreak*/ true, loopResultName, outerConvertedLoopState, caseClauses); - processLabeledJumps(state.labeledNonLocalContinues, /*isBreak*/ false, loopResultName, outerConvertedLoopState, caseClauses); - statements.push(ts.createSwitch(loopResultName, ts.createCaseBlock(caseClauses))); + statements.push(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createConstDeclarationList(variables), + /*location*/ node)); } } - return statements; + else if (namespaceDeclaration && ts.isDefaultImport(node)) { + // import d, * as n from "mod"; + statements.push(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), + /*type*/ undefined, ts.getGeneratedNameForNode(node), + /*location*/ node) + ]))); + } + addExportImportAssignments(statements, node); + return ts.singleOrMany(statements); } - function setLabeledJump(state, isBreak, labelText, labelMarker) { - if (isBreak) { - if (!state.labeledNonLocalBreaks) { - state.labeledNonLocalBreaks = ts.createMap(); - } - state.labeledNonLocalBreaks[labelText] = labelMarker; + function visitImportEqualsDeclaration(node) { + if (!ts.contains(externalImports, node)) { + return undefined; } - else { - if (!state.labeledNonLocalContinues) { - state.labeledNonLocalContinues = ts.createMap(); - } - state.labeledNonLocalContinues[labelText] = labelMarker; - } - } - function processLabeledJumps(table, isBreak, loopResultName, outerLoop, caseClauses) { - if (!table) { - return; - } - for (var labelText in table) { - var labelMarker = table[labelText]; - var statements = []; - // if there are no outer converted loop or outer label in question is located inside outer converted loop - // then emit labeled break\continue - // otherwise propagate pair 'label -> marker' to outer converted loop and emit 'return labelMarker' so outer loop can later decide what to do - if (!outerLoop || (outerLoop.labels && outerLoop.labels[labelText])) { - var label = ts.createIdentifier(labelText); - statements.push(isBreak ? ts.createBreak(label) : ts.createContinue(label)); + // Set emitFlags on the name of the importEqualsDeclaration + // This is so the printer will not substitute the identifier + ts.setEmitFlags(node.name, 128 /* NoSubstitution */); + var statements = []; + if (moduleKind !== ts.ModuleKind.AMD) { + if (ts.hasModifier(node, 1 /* Export */)) { + statements.push(ts.createStatement(createExportAssignment(node.name, createRequireCall(node)), + /*location*/ node)); } else { - setLabeledJump(outerLoop, isBreak, labelText, labelMarker); - statements.push(ts.createReturn(loopResultName)); + statements.push(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(ts.getSynthesizedClone(node.name), + /*type*/ undefined, createRequireCall(node)) + ], + /*location*/ undefined, + /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */), + /*location*/ node)); } - caseClauses.push(ts.createCaseClause(ts.createLiteral(labelMarker), statements)); + } + else { + if (ts.hasModifier(node, 1 /* Export */)) { + statements.push(ts.createStatement(createExportAssignment(node.name, node.name), + /*location*/ node)); + } + } + addExportImportAssignments(statements, node); + return statements; + } + function visitExportDeclaration(node) { + if (!ts.contains(externalImports, node)) { + return undefined; + } + var generatedName = ts.getGeneratedNameForNode(node); + if (node.exportClause) { + var statements = []; + // export { x, y } from "mod"; + if (moduleKind !== ts.ModuleKind.AMD) { + statements.push(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(generatedName, + /*type*/ undefined, createRequireCall(node)) + ]), + /*location*/ node)); + } + for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { + var specifier = _a[_i]; + var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); + statements.push(ts.createStatement(createExportAssignment(specifier.name, exportedValue), + /*location*/ specifier)); + } + return ts.singleOrMany(statements); + } + else { + // export * from "mod"; + return ts.createStatement(ts.createCall(ts.createIdentifier("__export"), + /*typeArguments*/ undefined, [ + moduleKind !== ts.ModuleKind.AMD + ? createRequireCall(node) + : generatedName + ]), + /*location*/ node); } } - function processLoopVariableDeclaration(decl, loopParameters, loopOutParameters) { - var name = decl.name; + function visitExportAssignment(node) { + if (node.isExportEquals) { + // Elide as `export=` is handled in addExportEqualsIfNeeded + return undefined; + } + var statements = []; + addExportDefault(statements, node.expression, /*location*/ node); + return statements; + } + function addExportDefault(statements, expression, location) { + tryAddExportDefaultCompat(statements); + statements.push(ts.createStatement(createExportAssignment(ts.createIdentifier("default"), expression), location)); + } + function tryAddExportDefaultCompat(statements) { + var original = ts.getOriginalNode(currentSourceFile); + ts.Debug.assert(original.kind === 256 /* SourceFile */); + if (!original.symbol.exports["___esModule"]) { + if (languageVersion === 0 /* ES3 */) { + statements.push(ts.createStatement(createExportAssignment(ts.createIdentifier("__esModule"), ts.createLiteral(true)))); + } + else { + statements.push(ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), + /*typeArguments*/ undefined, [ + ts.createIdentifier("exports"), + ts.createLiteral("__esModule"), + ts.createObjectLiteral([ + ts.createPropertyAssignment("value", ts.createLiteral(true)) + ]) + ]))); + } + } + } + function addExportImportAssignments(statements, node) { + if (ts.isImportEqualsDeclaration(node)) { + addExportMemberAssignments(statements, node.name); + } + else { + var names = ts.reduceEachChild(node, collectExportMembers, []); + for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { + var name_35 = names_1[_i]; + addExportMemberAssignments(statements, name_35); + } + } + } + function collectExportMembers(names, node) { + if (ts.isAliasSymbolDeclaration(node) && ts.isDeclaration(node)) { + var name_36 = node.name; + if (ts.isIdentifier(name_36)) { + names.push(name_36); + } + } + return ts.reduceEachChild(node, collectExportMembers, names); + } + function addExportMemberAssignments(statements, name) { + if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { + for (var _i = 0, _a = exportSpecifiers[name.text]; _i < _a.length; _i++) { + var specifier = _a[_i]; + statements.push(ts.startOnNewLine(ts.createStatement(createExportAssignment(specifier.name, name), + /*location*/ specifier.name))); + } + } + } + function addExportMemberAssignment(statements, node) { + if (ts.hasModifier(node, 512 /* Default */)) { + addExportDefault(statements, getDeclarationName(node), /*location*/ node); + } + else { + statements.push(createExportStatement(node.name, ts.setEmitFlags(ts.getSynthesizedClone(node.name), 262144 /* LocalName */), /*location*/ node)); + } + } + function visitVariableStatement(node) { + // If the variable is for a generated declaration, + // we should maintain it and just strip off the 'export' modifier if necessary. + var originalKind = ts.getOriginalNode(node).kind; + if (originalKind === 226 /* ModuleDeclaration */ || + originalKind === 225 /* EnumDeclaration */ || + originalKind === 222 /* ClassDeclaration */) { + if (!ts.hasModifier(node, 1 /* Export */)) { + return node; + } + return ts.setOriginalNode(ts.createVariableStatement( + /*modifiers*/ undefined, node.declarationList), node); + } + var resultStatements = []; + // If we're exporting these variables, then these just become assignments to 'exports.blah'. + // We only want to emit assignments for variables with initializers. + if (ts.hasModifier(node, 1 /* Export */)) { + var variables = ts.getInitializedVariables(node.declarationList); + if (variables.length > 0) { + var inlineAssignments = ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable)), node); + resultStatements.push(inlineAssignments); + } + } + else { + resultStatements.push(node); + } + // While we might not have been exported here, each variable might have been exported + // later on in an export specifier (e.g. `export {foo as blah, bar}`). + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + addExportMemberAssignmentsForBindingName(resultStatements, decl.name); + } + return resultStatements; + } + /** + * Creates appropriate assignments for each binding identifier that is exported in an export specifier, + * and inserts it into 'resultStatements'. + */ + function addExportMemberAssignmentsForBindingName(resultStatements, name) { if (ts.isBindingPattern(name)) { for (var _i = 0, _a = name.elements; _i < _a.length; _i++) { var element = _a[_i]; if (!ts.isOmittedExpression(element)) { - processLoopVariableDeclaration(element, loopParameters, loopOutParameters); + addExportMemberAssignmentsForBindingName(resultStatements, element.name); } } } else { - loopParameters.push(ts.createParameter(name)); - if (resolver.getNodeCheckFlags(decl) & 2097152 /* NeedsLoopOutParameter */) { - var outParamName = ts.createUniqueName("out_" + name.text); - loopOutParameters.push({ originalName: name, outParamName: outParamName }); + if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { + var sourceFileId = ts.getOriginalNodeId(currentSourceFile); + if (!bindingNameExportSpecifiersForFileMap[sourceFileId]) { + bindingNameExportSpecifiersForFileMap[sourceFileId] = ts.createMap(); + } + bindingNameExportSpecifiersForFileMap[sourceFileId][name.text] = exportSpecifiers[name.text]; + addExportMemberAssignments(resultStatements, name); } } } - /** - * Adds the members of an object literal to an array of expressions. - * - * @param expressions An array of expressions. - * @param node An ObjectLiteralExpression node. - * @param receiver The receiver for members of the ObjectLiteralExpression. - * @param numInitialNonComputedProperties The number of initial properties without - * computed property names. - */ - function addObjectLiteralMembers(expressions, node, receiver, start) { - var properties = node.properties; - var numProperties = properties.length; - for (var i = start; i < numProperties; i++) { - var property = properties[i]; - switch (property.kind) { - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - var accessors = ts.getAllAccessorDeclarations(node.properties, property); - if (property === accessors.firstAccessor) { - expressions.push(transformAccessorsToExpression(receiver, accessors, node.multiLine)); - } - break; - case 253 /* PropertyAssignment */: - expressions.push(transformPropertyAssignmentToExpression(node, property, receiver, node.multiLine)); - break; - case 254 /* ShorthandPropertyAssignment */: - expressions.push(transformShorthandPropertyAssignmentToExpression(node, property, receiver, node.multiLine)); - break; - case 147 /* MethodDeclaration */: - expressions.push(transformObjectLiteralMethodDeclarationToExpression(node, property, receiver, node.multiLine)); - break; - default: - ts.Debug.failBadSyntaxKind(node); - break; - } - } - } - /** - * Transforms a PropertyAssignment node into an expression. - * - * @param node The ObjectLiteralExpression that contains the PropertyAssignment. - * @param property The PropertyAssignment node. - * @param receiver The receiver for the assignment. - */ - function transformPropertyAssignmentToExpression(node, property, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.visitNode(property.initializer, visitor, ts.isExpression), - /*location*/ property); - if (startsOnNewLine) { - expression.startsOnNewLine = true; - } - return expression; - } - /** - * Transforms a ShorthandPropertyAssignment node into an expression. - * - * @param node The ObjectLiteralExpression that contains the ShorthandPropertyAssignment. - * @param property The ShorthandPropertyAssignment node. - * @param receiver The receiver for the assignment. - */ - function transformShorthandPropertyAssignmentToExpression(node, property, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.getSynthesizedClone(property.name), - /*location*/ property); - if (startsOnNewLine) { - expression.startsOnNewLine = true; - } - return expression; - } - /** - * Transforms a MethodDeclaration of an ObjectLiteralExpression into an expression. - * - * @param node The ObjectLiteralExpression that contains the MethodDeclaration. - * @param method The MethodDeclaration node. - * @param receiver The receiver for the assignment. - */ - function transformObjectLiteralMethodDeclarationToExpression(node, method, receiver, startsOnNewLine) { - var expression = ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, /*location*/ method, /*name*/ undefined), - /*location*/ method); - if (startsOnNewLine) { - expression.startsOnNewLine = true; - } - return expression; - } - /** - * Visits a MethodDeclaration of an ObjectLiteralExpression and transforms it into a - * PropertyAssignment. - * - * @param node A MethodDeclaration node. - */ - function visitMethodDeclaration(node) { - // We should only get here for methods on an object literal with regular identifier names. - // Methods on classes are handled in visitClassDeclaration/visitClassExpression. - // Methods with computed property names are handled in visitObjectLiteralExpression. - ts.Debug.assert(!ts.isComputedPropertyName(node.name)); - var functionExpression = transformFunctionLikeToExpression(node, /*location*/ ts.moveRangePos(node, -1), /*name*/ undefined); - ts.setEmitFlags(functionExpression, 16384 /* NoLeadingComments */ | ts.getEmitFlags(functionExpression)); - return ts.createPropertyAssignment(node.name, functionExpression, - /*location*/ node); - } - /** - * Visits a ShorthandPropertyAssignment and transforms it into a PropertyAssignment. - * - * @param node A ShorthandPropertyAssignment node. - */ - function visitShorthandPropertyAssignment(node) { - return ts.createPropertyAssignment(node.name, ts.getSynthesizedClone(node.name), - /*location*/ node); - } - /** - * Visits a YieldExpression node. - * - * @param node A YieldExpression node. - */ - function visitYieldExpression(node) { - // `yield` expressions are transformed using the generators transformer. - return ts.visitEachChild(node, visitor, context); - } - /** - * Visits an ArrayLiteralExpression that contains a spread element. - * - * @param node An ArrayLiteralExpression node. - */ - function visitArrayLiteralExpression(node) { - // We are here because we contain a SpreadElementExpression. - return transformAndSpreadElements(node.elements, /*needsUniqueCopy*/ true, node.multiLine, /*hasTrailingComma*/ node.elements.hasTrailingComma); - } - /** - * Visits a CallExpression that contains either a spread element or `super`. - * - * @param node a CallExpression. - */ - function visitCallExpression(node) { - return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); - } - function visitImmediateSuperCallInBody(node) { - return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ false); - } - function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) { - // We are here either because SuperKeyword was used somewhere in the expression, or - // because we contain a SpreadElementExpression. - var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 95 /* SuperKeyword */) { - ts.setEmitFlags(thisArg, 128 /* NoSubstitution */); - } - var resultingCall; - if (node.transformFlags & 262144 /* ContainsSpreadElementExpression */) { - // [source] - // f(...a, b) - // x.m(...a, b) - // super(...a, b) - // super.m(...a, b) // in static - // super.m(...a, b) // in instance - // - // [output] - // f.apply(void 0, a.concat([b])) - // (_a = x).m.apply(_a, a.concat([b])) - // _super.apply(this, a.concat([b])) - // _super.m.apply(this, a.concat([b])) - // _super.prototype.m.apply(this, a.concat([b])) - resultingCall = ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); + function transformInitializedVariable(node) { + var name = node.name; + if (ts.isBindingPattern(name)) { + return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, getModuleMemberName, visitor); } else { - // [source] - // super(a) - // super.m(a) // in static - // super.m(a) // in instance - // - // [output] - // _super.call(this, a) - // _super.m.call(this, a) - // _super.prototype.m.call(this, a) - resultingCall = ts.createFunctionCall(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), - /*location*/ node); - } - if (node.expression.kind === 95 /* SuperKeyword */) { - var actualThis = ts.createThis(); - ts.setEmitFlags(actualThis, 128 /* NoSubstitution */); - var initializer = ts.createLogicalOr(resultingCall, actualThis); - return assignToCapturedThis - ? ts.createAssignment(ts.createIdentifier("_this"), initializer) - : initializer; - } - return resultingCall; - } - /** - * Visits a NewExpression that contains a spread element. - * - * @param node A NewExpression node. - */ - function visitNewExpression(node) { - // We are here because we contain a SpreadElementExpression. - ts.Debug.assert((node.transformFlags & 262144 /* ContainsSpreadElementExpression */) !== 0); - // [source] - // new C(...a) - // - // [output] - // new ((_a = C).bind.apply(_a, [void 0].concat(a)))() - var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)), - /*typeArguments*/ undefined, []); - } - /** - * Transforms an array of Expression nodes that contains a SpreadElementExpression. - * - * @param elements The array of Expression nodes. - * @param needsUniqueCopy A value indicating whether to ensure that the result is a fresh array. - * @param multiLine A value indicating whether the result should be emitted on multiple lines. - */ - function transformAndSpreadElements(elements, needsUniqueCopy, multiLine, hasTrailingComma) { - // [source] - // [a, ...b, c] - // - // [output] - // [a].concat(b, [c]) - // Map spans of spread expressions into their expressions and spans of other - // expressions into an array literal. - var numElements = elements.length; - var segments = ts.flatten(ts.spanMap(elements, partitionSpreadElement, function (partition, visitPartition, start, end) { - return visitPartition(partition, multiLine, hasTrailingComma && end === numElements); - })); - if (segments.length === 1) { - var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadElementExpression(firstElement) && firstElement.expression.kind !== 170 /* ArrayLiteralExpression */ - ? ts.createArraySlice(segments[0]) - : segments[0]; - } - // Rewrite using the pattern .concat(, , ...) - return ts.createArrayConcat(segments.shift(), segments); - } - function partitionSpreadElement(node) { - return ts.isSpreadElementExpression(node) - ? visitSpanOfSpreadElements - : visitSpanOfNonSpreadElements; - } - function visitSpanOfSpreadElements(chunk, multiLine, hasTrailingComma) { - return ts.map(chunk, visitExpressionOfSpreadElement); - } - function visitSpanOfNonSpreadElements(chunk, multiLine, hasTrailingComma) { - return ts.createArrayLiteral(ts.visitNodes(ts.createNodeArray(chunk, /*location*/ undefined, hasTrailingComma), visitor, ts.isExpression), - /*location*/ undefined, multiLine); - } - /** - * Transforms the expression of a SpreadElementExpression node. - * - * @param node A SpreadElementExpression node. - */ - function visitExpressionOfSpreadElement(node) { - return ts.visitNode(node.expression, visitor, ts.isExpression); - } - /** - * Visits a template literal. - * - * @param node A template literal. - */ - function visitTemplateLiteral(node) { - return ts.createLiteral(node.text, /*location*/ node); - } - /** - * Visits a TaggedTemplateExpression node. - * - * @param node A TaggedTemplateExpression node. - */ - function visitTaggedTemplateExpression(node) { - // Visit the tag expression - var tag = ts.visitNode(node.tag, visitor, ts.isExpression); - // Allocate storage for the template site object - var temp = ts.createTempVariable(hoistVariableDeclaration); - // Build up the template arguments and the raw and cooked strings for the template. - var templateArguments = [temp]; - var cookedStrings = []; - var rawStrings = []; - var template = node.template; - if (ts.isNoSubstitutionTemplateLiteral(template)) { - cookedStrings.push(ts.createLiteral(template.text)); - rawStrings.push(getRawLiteral(template)); - } - else { - cookedStrings.push(ts.createLiteral(template.head.text)); - rawStrings.push(getRawLiteral(template.head)); - for (var _i = 0, _a = template.templateSpans; _i < _a.length; _i++) { - var templateSpan = _a[_i]; - cookedStrings.push(ts.createLiteral(templateSpan.literal.text)); - rawStrings.push(getRawLiteral(templateSpan.literal)); - templateArguments.push(ts.visitNode(templateSpan.expression, visitor, ts.isExpression)); - } - } - // NOTE: The parentheses here is entirely optional as we are now able to auto- - // parenthesize when rebuilding the tree. This should be removed in a - // future version. It is here for now to match our existing emit. - return ts.createParen(ts.inlineExpressions([ - ts.createAssignment(temp, ts.createArrayLiteral(cookedStrings)), - ts.createAssignment(ts.createPropertyAccess(temp, "raw"), ts.createArrayLiteral(rawStrings)), - ts.createCall(tag, /*typeArguments*/ undefined, templateArguments) - ])); - } - /** - * Creates an ES5 compatible literal from an ES6 template literal. - * - * @param node The ES6 template literal. - */ - function getRawLiteral(node) { - // Find original source text, since we need to emit the raw strings of the tagged template. - // The raw strings contain the (escaped) strings of what the user wrote. - // Examples: `\n` is converted to "\\n", a template string with a newline to "\n". - var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - // text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"), - // thus we need to remove those characters. - // First template piece starts with "`", others with "}" - // Last template piece ends with "`", others with "${" - var isLast = node.kind === 11 /* NoSubstitutionTemplateLiteral */ || node.kind === 14 /* TemplateTail */; - text = text.substring(1, text.length - (isLast ? 1 : 2)); - // Newline normalization: - // ES6 Spec 11.8.6.1 - Static Semantics of TV's and TRV's - // and LineTerminatorSequences are normalized to for both TV and TRV. - text = text.replace(/\r\n?/g, "\n"); - return ts.createLiteral(text, /*location*/ node); - } - /** - * Visits a TemplateExpression node. - * - * @param node A TemplateExpression node. - */ - function visitTemplateExpression(node) { - var expressions = []; - addTemplateHead(expressions, node); - addTemplateSpans(expressions, node); - // createAdd will check if each expression binds less closely than binary '+'. - // If it does, it wraps the expression in parentheses. Otherwise, something like - // `abc${ 1 << 2 }` - // becomes - // "abc" + 1 << 2 + "" - // which is really - // ("abc" + 1) << (2 + "") - // rather than - // "abc" + (1 << 2) + "" - var expression = ts.reduceLeft(expressions, ts.createAdd); - if (ts.nodeIsSynthesized(expression)) { - ts.setTextRange(expression, node); - } - return expression; - } - /** - * Gets a value indicating whether we need to include the head of a TemplateExpression. - * - * @param node A TemplateExpression node. - */ - function shouldAddTemplateHead(node) { - // If this expression has an empty head literal and the first template span has a non-empty - // literal, then emitting the empty head literal is not necessary. - // `${ foo } and ${ bar }` - // can be emitted as - // foo + " and " + bar - // This is because it is only required that one of the first two operands in the emit - // output must be a string literal, so that the other operand and all following operands - // are forced into strings. - // - // If the first template span has an empty literal, then the head must still be emitted. - // `${ foo }${ bar }` - // must still be emitted as - // "" + foo + bar - // There is always atleast one templateSpan in this code path, since - // NoSubstitutionTemplateLiterals are directly emitted via emitLiteral() - ts.Debug.assert(node.templateSpans.length !== 0); - return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0; - } - /** - * Adds the head of a TemplateExpression to an array of expressions. - * - * @param expressions An array of expressions. - * @param node A TemplateExpression node. - */ - function addTemplateHead(expressions, node) { - if (!shouldAddTemplateHead(node)) { - return; - } - expressions.push(ts.createLiteral(node.head.text)); - } - /** - * Visits and adds the template spans of a TemplateExpression to an array of expressions. - * - * @param expressions An array of expressions. - * @param node A TemplateExpression node. - */ - function addTemplateSpans(expressions, node) { - for (var _i = 0, _a = node.templateSpans; _i < _a.length; _i++) { - var span_6 = _a[_i]; - expressions.push(ts.visitNode(span_6.expression, visitor, ts.isExpression)); - // Only emit if the literal is non-empty. - // The binary '+' operator is left-associative, so the first string concatenation - // with the head will force the result up to this point to be a string. - // Emitting a '+ ""' has no semantic effect for middles and tails. - if (span_6.literal.text.length !== 0) { - expressions.push(ts.createLiteral(span_6.literal.text)); - } + return ts.createAssignment(getModuleMemberName(name), ts.visitNode(node.initializer, visitor, ts.isExpression)); } } - /** - * Visits the `super` keyword - */ - function visitSuperKeyword(node) { - return enclosingNonAsyncFunctionBody - && ts.isClassElement(enclosingNonAsyncFunctionBody) - && !ts.hasModifier(enclosingNonAsyncFunctionBody, 32 /* Static */) - && currentParent.kind !== 174 /* CallExpression */ - ? ts.createPropertyAccess(ts.createIdentifier("_super"), "prototype") - : ts.createIdentifier("_super"); - } - function visitSourceFileNode(node) { - var _a = ts.span(node.statements, ts.isPrologueDirective), prologue = _a[0], remaining = _a[1]; + function visitFunctionDeclaration(node) { var statements = []; - startLexicalEnvironment(); - ts.addRange(statements, prologue); - addCaptureThisForNodeIfNeeded(statements, node); - ts.addRange(statements, ts.visitNodes(ts.createNodeArray(remaining), visitor, ts.isStatement)); - ts.addRange(statements, endLexicalEnvironment()); - var clone = ts.getMutableClone(node); - clone.statements = ts.createNodeArray(statements, /*location*/ node.statements); - return clone; + var name = node.name || ts.getGeneratedNameForNode(node); + if (ts.hasModifier(node, 1 /* Export */)) { + // Keep async modifier for ES2017 transformer + var isAsync = ts.hasModifier(node, 256 /* Async */); + statements.push(ts.setOriginalNode(ts.createFunctionDeclaration( + /*decorators*/ undefined, isAsync ? [ts.createNode(119 /* AsyncKeyword */)] : undefined, node.asteriskToken, name, + /*typeParameters*/ undefined, node.parameters, + /*type*/ undefined, node.body, + /*location*/ node), + /*original*/ node)); + addExportMemberAssignment(statements, node); + } + else { + statements.push(node); + } + if (node.name) { + addExportMemberAssignments(statements, node.name); + } + return ts.singleOrMany(statements); + } + function visitClassDeclaration(node) { + var statements = []; + var name = node.name || ts.getGeneratedNameForNode(node); + if (ts.hasModifier(node, 1 /* Export */)) { + statements.push(ts.setOriginalNode(ts.createClassDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, name, + /*typeParameters*/ undefined, node.heritageClauses, node.members, + /*location*/ node), + /*original*/ node)); + addExportMemberAssignment(statements, node); + } + else { + statements.push(node); + } + // Decorators end up creating a series of assignment expressions which overwrite + // the local binding that we export, so we need to defer from exporting decorated classes + // until the decoration assignments take place. We do this when visiting expression-statements. + if (node.name && !(node.decorators && node.decorators.length)) { + addExportMemberAssignments(statements, node.name); + } + return ts.singleOrMany(statements); + } + function visitExpressionStatement(node) { + var original = ts.getOriginalNode(node); + var origKind = original.kind; + if (origKind === 225 /* EnumDeclaration */ || origKind === 226 /* ModuleDeclaration */) { + return visitExpressionStatementForEnumOrNamespaceDeclaration(node, original); + } + else if (origKind === 222 /* ClassDeclaration */) { + // The decorated assignment for a class name may need to be transformed. + var classDecl = original; + if (classDecl.name) { + var statements = [node]; + addExportMemberAssignments(statements, classDecl.name); + return statements; + } + } + return node; + } + function visitExpressionStatementForEnumOrNamespaceDeclaration(node, original) { + var statements = [node]; + // Preserve old behavior for enums in which a variable statement is emitted after the body itself. + if (ts.hasModifier(original, 1 /* Export */) && + original.kind === 225 /* EnumDeclaration */ && + ts.isFirstDeclarationOfKind(original, 225 /* EnumDeclaration */)) { + addVarForExportedEnumOrNamespaceDeclaration(statements, original); + } + addExportMemberAssignments(statements, original.name); + return statements; } /** - * Called by the printer just before a node is printed. - * - * @param node The node to be printed. + * Adds a trailing VariableStatement for an enum or module declaration. */ + function addVarForExportedEnumOrNamespaceDeclaration(statements, node) { + var transformedStatement = ts.createVariableStatement( + /*modifiers*/ undefined, [ts.createVariableDeclaration(getDeclarationName(node), + /*type*/ undefined, ts.createPropertyAccess(ts.createIdentifier("exports"), getDeclarationName(node)))], + /*location*/ node); + ts.setEmitFlags(transformedStatement, 49152 /* NoComments */); + statements.push(transformedStatement); + } + function getDeclarationName(node) { + return node.name ? ts.getSynthesizedClone(node.name) : ts.getGeneratedNameForNode(node); + } function onEmitNode(emitContext, node, emitCallback) { - var savedEnclosingFunction = enclosingFunction; - if (enabledSubstitutions & 1 /* CapturedThis */ && ts.isFunctionLike(node)) { - // If we are tracking a captured `this`, keep track of the enclosing function. - enclosingFunction = node; + if (node.kind === 256 /* SourceFile */) { + bindingNameExportSpecifiersMap = bindingNameExportSpecifiersForFileMap[ts.getOriginalNodeId(node)]; + previousOnEmitNode(emitContext, node, emitCallback); + bindingNameExportSpecifiersMap = undefined; } - previousOnEmitNode(emitContext, node, emitCallback); - enclosingFunction = savedEnclosingFunction; - } - /** - * Enables a more costly code path for substitutions when we determine a source file - * contains block-scoped bindings (e.g. `let` or `const`). - */ - function enableSubstitutionsForBlockScopedBindings() { - if ((enabledSubstitutions & 2 /* BlockScopedBindings */) === 0) { - enabledSubstitutions |= 2 /* BlockScopedBindings */; - context.enableSubstitution(69 /* Identifier */); - } - } - /** - * Enables a more costly code path for substitutions when we determine a source file - * contains a captured `this`. - */ - function enableSubstitutionsForCapturedThis() { - if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { - enabledSubstitutions |= 1 /* CapturedThis */; - context.enableSubstitution(97 /* ThisKeyword */); - context.enableEmitNotification(148 /* Constructor */); - context.enableEmitNotification(147 /* MethodDeclaration */); - context.enableEmitNotification(149 /* GetAccessor */); - context.enableEmitNotification(150 /* SetAccessor */); - context.enableEmitNotification(180 /* ArrowFunction */); - context.enableEmitNotification(179 /* FunctionExpression */); - context.enableEmitNotification(220 /* FunctionDeclaration */); + else { + previousOnEmitNode(emitContext, node, emitCallback); } } /** @@ -52856,168 +52305,1407 @@ var ts; if (emitContext === 1 /* Expression */) { return substituteExpression(node); } - if (ts.isIdentifier(node)) { - return substituteIdentifier(node); + else if (ts.isShorthandPropertyAssignment(node)) { + return substituteShorthandPropertyAssignment(node); } return node; } - /** - * Hooks substitutions for non-expression identifiers. - */ - function substituteIdentifier(node) { - // Only substitute the identifier if we have enabled substitutions for block-scoped - // bindings. - if (enabledSubstitutions & 2 /* BlockScopedBindings */) { - var original = ts.getParseTreeNode(node, ts.isIdentifier); - if (original && isNameOfDeclarationWithCollidingName(original)) { - return ts.getGeneratedNameForNode(original); + function substituteShorthandPropertyAssignment(node) { + var name = node.name; + var exportedOrImportedName = substituteExpressionIdentifier(name); + if (exportedOrImportedName !== name) { + // A shorthand property with an assignment initializer is probably part of a + // destructuring assignment + if (node.objectAssignmentInitializer) { + var initializer = ts.createAssignment(exportedOrImportedName, node.objectAssignmentInitializer); + return ts.createPropertyAssignment(name, initializer, /*location*/ node); + } + return ts.createPropertyAssignment(name, exportedOrImportedName, /*location*/ node); + } + return node; + } + function substituteExpression(node) { + switch (node.kind) { + case 70 /* Identifier */: + return substituteExpressionIdentifier(node); + case 188 /* BinaryExpression */: + return substituteBinaryExpression(node); + case 187 /* PostfixUnaryExpression */: + case 186 /* PrefixUnaryExpression */: + return substituteUnaryExpression(node); + } + return node; + } + function substituteExpressionIdentifier(node) { + return trySubstituteExportedName(node) + || trySubstituteImportedName(node) + || node; + } + function substituteBinaryExpression(node) { + var left = node.left; + // If the left-hand-side of the binaryExpression is an identifier and its is export through export Specifier + if (ts.isIdentifier(left) && ts.isAssignmentOperator(node.operatorToken.kind)) { + if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, left.text)) { + ts.setEmitFlags(node, 128 /* NoSubstitution */); + var nestedExportAssignment = void 0; + for (var _i = 0, _a = bindingNameExportSpecifiersMap[left.text]; _i < _a.length; _i++) { + var specifier = _a[_i]; + nestedExportAssignment = nestedExportAssignment ? + createExportAssignment(specifier.name, nestedExportAssignment) : + createExportAssignment(specifier.name, node); + } + return nestedExportAssignment; } } return node; } - /** - * Determines whether a name is the name of a declaration with a colliding name. - * NOTE: This function expects to be called with an original source tree node. - * - * @param node An original source tree node. - */ - function isNameOfDeclarationWithCollidingName(node) { - var parent = node.parent; - switch (parent.kind) { - case 169 /* BindingElement */: - case 221 /* ClassDeclaration */: - case 224 /* EnumDeclaration */: - case 218 /* VariableDeclaration */: - return parent.name === node - && resolver.isDeclarationWithCollidingName(parent); + function substituteUnaryExpression(node) { + // Because how the compiler only parse plusplus and minusminus to be either prefixUnaryExpression or postFixUnaryExpression depended on where they are + // We don't need to check that the operator has SyntaxKind.plusplus or SyntaxKind.minusminus + var operator = node.operator; + var operand = node.operand; + if (ts.isIdentifier(operand) && bindingNameExportSpecifiersForFileMap) { + if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, operand.text)) { + ts.setEmitFlags(node, 128 /* NoSubstitution */); + var transformedUnaryExpression = void 0; + if (node.kind === 187 /* PostfixUnaryExpression */) { + transformedUnaryExpression = ts.createBinary(operand, ts.createToken(operator === 42 /* PlusPlusToken */ ? 58 /* PlusEqualsToken */ : 59 /* MinusEqualsToken */), ts.createLiteral(1), + /*location*/ node); + // We have to set no substitution flag here to prevent visit the binary expression and substitute it again as we will preform all necessary substitution in here + ts.setEmitFlags(transformedUnaryExpression, 128 /* NoSubstitution */); + } + var nestedExportAssignment = void 0; + for (var _i = 0, _a = bindingNameExportSpecifiersMap[operand.text]; _i < _a.length; _i++) { + var specifier = _a[_i]; + nestedExportAssignment = nestedExportAssignment ? + createExportAssignment(specifier.name, nestedExportAssignment) : + createExportAssignment(specifier.name, transformedUnaryExpression || node); + } + return nestedExportAssignment; + } } - return false; + return node; + } + function trySubstituteExportedName(node) { + var emitFlags = ts.getEmitFlags(node); + if ((emitFlags & 262144 /* LocalName */) === 0) { + var container = resolver.getReferencedExportContainer(node, (emitFlags & 131072 /* ExportName */) !== 0); + if (container) { + if (container.kind === 256 /* SourceFile */) { + return ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node), + /*location*/ node); + } + } + } + return undefined; + } + function trySubstituteImportedName(node) { + if ((ts.getEmitFlags(node) & 262144 /* LocalName */) === 0) { + var declaration = resolver.getReferencedImportDeclaration(node); + if (declaration) { + if (ts.isImportClause(declaration)) { + return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent), ts.createIdentifier("default"), + /*location*/ node); + } + else if (ts.isImportSpecifier(declaration)) { + var name_37 = declaration.propertyName || declaration.name; + return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.getSynthesizedClone(name_37), + /*location*/ node); + } + } + } + return undefined; + } + function getModuleMemberName(name) { + return ts.createPropertyAccess(ts.createIdentifier("exports"), name, + /*location*/ name); + } + function createRequireCall(importNode) { + var moduleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); + var args = []; + if (ts.isDefined(moduleName)) { + args.push(moduleName); + } + return ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, args); + } + function createExportStatement(name, value, location) { + var statement = ts.createStatement(createExportAssignment(name, value)); + statement.startsOnNewLine = true; + if (location) { + ts.setSourceMapRange(statement, location); + } + return statement; + } + function createExportAssignment(name, value) { + return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value); + } + function collectAsynchronousDependencies(node, includeNonAmdDependencies) { + // names of modules with corresponding parameter in the factory function + var aliasedModuleNames = []; + // names of modules with no corresponding parameters in factory function + var unaliasedModuleNames = []; + // names of the parameters in the factory function; these + // parameters need to match the indexes of the corresponding + // module names in aliasedModuleNames. + var importAliasNames = []; + // Fill in amd-dependency tags + for (var _i = 0, _a = node.amdDependencies; _i < _a.length; _i++) { + var amdDependency = _a[_i]; + if (amdDependency.name) { + aliasedModuleNames.push(ts.createLiteral(amdDependency.path)); + importAliasNames.push(ts.createParameter(amdDependency.name)); + } + else { + unaliasedModuleNames.push(ts.createLiteral(amdDependency.path)); + } + } + for (var _b = 0, externalImports_1 = externalImports; _b < externalImports_1.length; _b++) { + var importNode = externalImports_1[_b]; + // Find the name of the external module + var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); + // Find the name of the module alias, if there is one + var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile); + if (includeNonAmdDependencies && importAliasName) { + // Set emitFlags on the name of the classDeclaration + // This is so that when printer will not substitute the identifier + ts.setEmitFlags(importAliasName, 128 /* NoSubstitution */); + aliasedModuleNames.push(externalModuleName); + importAliasNames.push(ts.createParameter(importAliasName)); + } + else { + unaliasedModuleNames.push(externalModuleName); + } + } + return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; + } + function updateSourceFile(node, statements) { + var updated = ts.getMutableClone(node); + updated.statements = ts.createNodeArray(statements, node.statements); + return updated; + } + var _a; + } + ts.transformModule = transformModule; +})(ts || (ts = {})); +/// +/// +/*@internal*/ +var ts; +(function (ts) { + function transformSystemModule(context) { + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration, hoistFunctionDeclaration = context.hoistFunctionDeclaration; + var compilerOptions = context.getCompilerOptions(); + var resolver = context.getEmitResolver(); + var host = context.getEmitHost(); + var previousOnSubstituteNode = context.onSubstituteNode; + var previousOnEmitNode = context.onEmitNode; + context.onSubstituteNode = onSubstituteNode; + context.onEmitNode = onEmitNode; + context.enableSubstitution(70 /* Identifier */); + context.enableSubstitution(188 /* BinaryExpression */); + context.enableSubstitution(186 /* PrefixUnaryExpression */); + context.enableSubstitution(187 /* PostfixUnaryExpression */); + context.enableEmitNotification(256 /* SourceFile */); + var exportFunctionForFileMap = []; + var currentSourceFile; + var externalImports; + var exportSpecifiers; + var exportEquals; + var hasExportStarsToExportValues; + var exportFunctionForFile; + var contextObjectForFile; + var exportedLocalNames; + var exportedFunctionDeclarations; + var enclosingBlockScopedContainer; + var currentParent; + var currentNode; + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + currentSourceFile = node; + currentNode = node; + // Perform the transformation. + var updated = transformSystemModuleWorker(node); + ts.aggregateTransformFlags(updated); + currentSourceFile = undefined; + externalImports = undefined; + exportSpecifiers = undefined; + exportEquals = undefined; + hasExportStarsToExportValues = false; + exportFunctionForFile = undefined; + contextObjectForFile = undefined; + exportedLocalNames = undefined; + exportedFunctionDeclarations = undefined; + return updated; + } + return node; + } + function transformSystemModuleWorker(node) { + // System modules have the following shape: + // + // System.register(['dep-1', ... 'dep-n'], function(exports) {/* module body function */}) + // + // The parameter 'exports' here is a callback '(name: string, value: T) => T' that + // is used to publish exported values. 'exports' returns its 'value' argument so in + // most cases expressions that mutate exported values can be rewritten as: + // + // expr -> exports('name', expr) + // + // The only exception in this rule is postfix unary operators, + // see comment to 'substitutePostfixUnaryExpression' for more details + ts.Debug.assert(!exportFunctionForFile); + // Collect information about the external module and dependency groups. + (_a = ts.collectExternalModuleInfo(node), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); + // Make sure that the name of the 'exports' function does not conflict with + // existing identifiers. + exportFunctionForFile = ts.createUniqueName("exports"); + contextObjectForFile = ts.createUniqueName("context"); + exportFunctionForFileMap[ts.getOriginalNodeId(node)] = exportFunctionForFile; + var dependencyGroups = collectDependencyGroups(externalImports); + var statements = []; + // Add the body of the module. + addSystemModuleBody(statements, node, dependencyGroups); + var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); + var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, getNameOfDependencyGroup)); + var body = ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, [ + ts.createParameter(exportFunctionForFile), + ts.createParameter(contextObjectForFile) + ], + /*type*/ undefined, ts.setEmitFlags(ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true), 1 /* EmitEmitHelpers */)); + // Write the call to `System.register` + // Clear the emit-helpers flag for later passes since we'll have already used it in the module body + // So the helper will be emit at the correct position instead of at the top of the source-file + return updateSourceFile(node, [ + ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), + /*typeArguments*/ undefined, moduleName + ? [moduleName, dependencies, body] + : [dependencies, body])) + ], /*nodeEmitFlags*/ ~1 /* EmitEmitHelpers */ & ts.getEmitFlags(node)); + var _a; } /** - * Substitutes an expression. + * Adds the statements for the module body function for the source file. * - * @param node An Expression node. + * @param statements The output statements for the module body. + * @param node The source file for the module. + * @param statementOffset The offset at which to begin visiting the statements of the SourceFile. + */ + function addSystemModuleBody(statements, node, dependencyGroups) { + // Shape of the body in system modules: + // + // function (exports) { + // + // + // + // return { + // setters: [ + // + // ], + // execute: function() { + // + // } + // } + // + // } + // + // i.e: + // + // import {x} from 'file1' + // var y = 1; + // export function foo() { return y + x(); } + // console.log(y); + // + // Will be transformed to: + // + // function(exports) { + // var file_1; // local alias + // var y; + // function foo() { return y + file_1.x(); } + // exports("foo", foo); + // return { + // setters: [ + // function(v) { file_1 = v } + // ], + // execute(): function() { + // y = 1; + // console.log(y); + // } + // }; + // } + // We start a new lexical environment in this function body, but *not* in the + // body of the execute function. This allows us to emit temporary declarations + // only in the outer module body and not in the inner one. + startLexicalEnvironment(); + // Add any prologue directives. + var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, visitSourceElement); + // var __moduleName = context_1 && context_1.id; + statements.push(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration("__moduleName", + /*type*/ undefined, ts.createLogicalAnd(contextObjectForFile, ts.createPropertyAccess(contextObjectForFile, "id"))) + ]))); + // Visit the statements of the source file, emitting any transformations into + // the `executeStatements` array. We do this *before* we fill the `setters` array + // as we both emit transformations as well as aggregate some data used when creating + // setters. This allows us to reduce the number of times we need to loop through the + // statements of the source file. + var executeStatements = ts.visitNodes(node.statements, visitSourceElement, ts.isStatement, statementOffset); + // We emit the lexical environment (hoisted variables and function declarations) + // early to align roughly with our previous emit output. + // Two key differences in this approach are: + // - Temporary variables will appear at the top rather than at the bottom of the file + // - Calls to the exporter for exported function declarations are grouped after + // the declarations. + ts.addRange(statements, endLexicalEnvironment()); + // Emit early exports for function declarations. + ts.addRange(statements, exportedFunctionDeclarations); + var exportStarFunction = addExportStarIfNeeded(statements); + statements.push(ts.createReturn(ts.setMultiLine(ts.createObjectLiteral([ + ts.createPropertyAssignment("setters", generateSetters(exportStarFunction, dependencyGroups)), + ts.createPropertyAssignment("execute", ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, + /*parameters*/ [], + /*type*/ undefined, ts.createBlock(executeStatements, + /*location*/ undefined, + /*multiLine*/ true))) + ]), + /*multiLine*/ true))); + } + function addExportStarIfNeeded(statements) { + if (!hasExportStarsToExportValues) { + return; + } + // when resolving exports local exported entries/indirect exported entries in the module + // should always win over entries with similar names that were added via star exports + // to support this we store names of local/indirect exported entries in a set. + // this set is used to filter names brought by star expors. + // local names set should only be added if we have anything exported + if (!exportedLocalNames && ts.isEmpty(exportSpecifiers)) { + // no exported declarations (export var ...) or export specifiers (export {x}) + // check if we have any non star export declarations. + var hasExportDeclarationWithExportClause = false; + for (var _i = 0, externalImports_2 = externalImports; _i < externalImports_2.length; _i++) { + var externalImport = externalImports_2[_i]; + if (externalImport.kind === 237 /* ExportDeclaration */ && externalImport.exportClause) { + hasExportDeclarationWithExportClause = true; + break; + } + } + if (!hasExportDeclarationWithExportClause) { + // we still need to emit exportStar helper + return addExportStarFunction(statements, /*localNames*/ undefined); + } + } + var exportedNames = []; + if (exportedLocalNames) { + for (var _a = 0, exportedLocalNames_1 = exportedLocalNames; _a < exportedLocalNames_1.length; _a++) { + var exportedLocalName = exportedLocalNames_1[_a]; + // write name of exported declaration, i.e 'export var x...' + exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName.text), ts.createLiteral(true))); + } + } + for (var _b = 0, externalImports_3 = externalImports; _b < externalImports_3.length; _b++) { + var externalImport = externalImports_3[_b]; + if (externalImport.kind !== 237 /* ExportDeclaration */) { + continue; + } + var exportDecl = externalImport; + if (!exportDecl.exportClause) { + // export * from ... + continue; + } + for (var _c = 0, _d = exportDecl.exportClause.elements; _c < _d.length; _c++) { + var element = _d[_c]; + // write name of indirectly exported entry, i.e. 'export {x} from ...' + exportedNames.push(ts.createPropertyAssignment(ts.createLiteral((element.name || element.propertyName).text), ts.createLiteral(true))); + } + } + var exportedNamesStorageRef = ts.createUniqueName("exportedNames"); + statements.push(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(exportedNamesStorageRef, + /*type*/ undefined, ts.createObjectLiteral(exportedNames, /*location*/ undefined, /*multiline*/ true)) + ]))); + return addExportStarFunction(statements, exportedNamesStorageRef); + } + /** + * Emits a setter callback for each dependency group. + * @param write The callback used to write each callback. + */ + function generateSetters(exportStarFunction, dependencyGroups) { + var setters = []; + for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { + var group = dependencyGroups_1[_i]; + // derive a unique name for parameter from the first named entry in the group + var localName = ts.forEach(group.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); + var parameterName = localName ? ts.getGeneratedNameForNode(localName) : ts.createUniqueName(""); + var statements = []; + for (var _a = 0, _b = group.externalImports; _a < _b.length; _a++) { + var entry = _b[_a]; + var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); + switch (entry.kind) { + case 231 /* ImportDeclaration */: + if (!entry.importClause) { + // 'import "..."' case + // module is imported only for side-effects, no emit required + break; + } + // fall-through + case 230 /* ImportEqualsDeclaration */: + ts.Debug.assert(importVariableName !== undefined); + // save import into the local + statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); + break; + case 237 /* ExportDeclaration */: + ts.Debug.assert(importVariableName !== undefined); + if (entry.exportClause) { + // export {a, b as c} from 'foo' + // + // emit as: + // + // exports_({ + // "a": _["a"], + // "c": _["b"] + // }); + var properties = []; + for (var _c = 0, _d = entry.exportClause.elements; _c < _d.length; _c++) { + var e = _d[_c]; + properties.push(ts.createPropertyAssignment(ts.createLiteral(e.name.text), ts.createElementAccess(parameterName, ts.createLiteral((e.propertyName || e.name).text)))); + } + statements.push(ts.createStatement(ts.createCall(exportFunctionForFile, + /*typeArguments*/ undefined, [ts.createObjectLiteral(properties, /*location*/ undefined, /*multiline*/ true)]))); + } + else { + // export * from 'foo' + // + // emit as: + // + // exportStar(foo_1_1); + statements.push(ts.createStatement(ts.createCall(exportStarFunction, + /*typeArguments*/ undefined, [parameterName]))); + } + break; + } + } + setters.push(ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, [ts.createParameter(parameterName)], + /*type*/ undefined, ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true))); + } + return ts.createArrayLiteral(setters, /*location*/ undefined, /*multiLine*/ true); + } + function visitSourceElement(node) { + switch (node.kind) { + case 231 /* ImportDeclaration */: + return visitImportDeclaration(node); + case 230 /* ImportEqualsDeclaration */: + return visitImportEqualsDeclaration(node); + case 237 /* ExportDeclaration */: + return visitExportDeclaration(node); + case 236 /* ExportAssignment */: + return visitExportAssignment(node); + default: + return visitNestedNode(node); + } + } + function visitNestedNode(node) { + var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; + var savedCurrentParent = currentParent; + var savedCurrentNode = currentNode; + var currentGrandparent = currentParent; + currentParent = currentNode; + currentNode = node; + if (currentParent && ts.isBlockScope(currentParent, currentGrandparent)) { + enclosingBlockScopedContainer = currentParent; + } + var result = visitNestedNodeWorker(node); + enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; + currentParent = savedCurrentParent; + currentNode = savedCurrentNode; + return result; + } + function visitNestedNodeWorker(node) { + switch (node.kind) { + case 201 /* VariableStatement */: + return visitVariableStatement(node); + case 221 /* FunctionDeclaration */: + return visitFunctionDeclaration(node); + case 222 /* ClassDeclaration */: + return visitClassDeclaration(node); + case 207 /* ForStatement */: + return visitForStatement(node); + case 208 /* ForInStatement */: + return visitForInStatement(node); + case 209 /* ForOfStatement */: + return visitForOfStatement(node); + case 205 /* DoStatement */: + return visitDoStatement(node); + case 206 /* WhileStatement */: + return visitWhileStatement(node); + case 215 /* LabeledStatement */: + return visitLabeledStatement(node); + case 213 /* WithStatement */: + return visitWithStatement(node); + case 214 /* SwitchStatement */: + return visitSwitchStatement(node); + case 228 /* CaseBlock */: + return visitCaseBlock(node); + case 249 /* CaseClause */: + return visitCaseClause(node); + case 250 /* DefaultClause */: + return visitDefaultClause(node); + case 217 /* TryStatement */: + return visitTryStatement(node); + case 252 /* CatchClause */: + return visitCatchClause(node); + case 200 /* Block */: + return visitBlock(node); + case 203 /* ExpressionStatement */: + return visitExpressionStatement(node); + default: + return node; + } + } + function visitImportDeclaration(node) { + if (node.importClause && ts.contains(externalImports, node)) { + hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); + } + return undefined; + } + function visitImportEqualsDeclaration(node) { + if (ts.contains(externalImports, node)) { + hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); + } + // NOTE(rbuckton): Do we support export import = require('') in System? + return undefined; + } + function visitExportDeclaration(node) { + if (!node.moduleSpecifier) { + var statements = []; + ts.addRange(statements, ts.map(node.exportClause.elements, visitExportSpecifier)); + return statements; + } + return undefined; + } + function visitExportSpecifier(specifier) { + recordExportName(specifier.name); + return createExportStatement(specifier.name, specifier.propertyName || specifier.name); + } + function visitExportAssignment(node) { + if (node.isExportEquals) { + // Elide `export=` as it is illegal in a SystemJS module. + return undefined; + } + return createExportStatement(ts.createLiteral("default"), node.expression); + } + /** + * Visits a variable statement, hoisting declared names to the top-level module body. + * Each declaration is rewritten into an assignment expression. + * + * @param node The variable statement to visit. + */ + function visitVariableStatement(node) { + // hoist only non-block scoped declarations or block scoped declarations parented by source file + var shouldHoist = ((ts.getCombinedNodeFlags(ts.getOriginalNode(node.declarationList)) & 3 /* BlockScoped */) == 0) || + enclosingBlockScopedContainer.kind === 256 /* SourceFile */; + if (!shouldHoist) { + return node; + } + var isExported = ts.hasModifier(node, 1 /* Export */); + var expressions = []; + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var variable = _a[_i]; + var visited = transformVariable(variable, isExported); + if (visited) { + expressions.push(visited); + } + } + if (expressions.length) { + return ts.createStatement(ts.inlineExpressions(expressions), node); + } + return undefined; + } + /** + * Transforms a VariableDeclaration into one or more assignment expressions. + * + * @param node The VariableDeclaration to transform. + * @param isExported A value used to indicate whether the containing statement was exported. + */ + function transformVariable(node, isExported) { + // Hoist any bound names within the declaration. + hoistBindingElement(node, isExported); + if (!node.initializer) { + // If the variable has no initializer, ignore it. + return; + } + var name = node.name; + if (ts.isIdentifier(name)) { + // If the variable has an IdentifierName, write out an assignment expression in its place. + return ts.createAssignment(name, node.initializer); + } + else { + // If the variable has a BindingPattern, flatten the variable into multiple assignment expressions. + return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration); + } + } + /** + * Visits a FunctionDeclaration, hoisting it to the outer module body function. + * + * @param node The function declaration to visit. + */ + function visitFunctionDeclaration(node) { + if (ts.hasModifier(node, 1 /* Export */)) { + // If the function is exported, ensure it has a name and rewrite the function without any export flags. + var name_38 = node.name || ts.getGeneratedNameForNode(node); + // Keep async modifier for ES2017 transformer + var isAsync = ts.hasModifier(node, 256 /* Async */); + var newNode = ts.createFunctionDeclaration( + /*decorators*/ undefined, isAsync ? [ts.createNode(119 /* AsyncKeyword */)] : undefined, node.asteriskToken, name_38, + /*typeParameters*/ undefined, node.parameters, + /*type*/ undefined, node.body, + /*location*/ node); + // Record a declaration export in the outer module body function. + recordExportedFunctionDeclaration(node); + if (!ts.hasModifier(node, 512 /* Default */)) { + recordExportName(name_38); + } + ts.setOriginalNode(newNode, node); + node = newNode; + } + // Hoist the function declaration to the outer module body function. + hoistFunctionDeclaration(node); + return undefined; + } + function visitExpressionStatement(node) { + var originalNode = ts.getOriginalNode(node); + if ((originalNode.kind === 226 /* ModuleDeclaration */ || originalNode.kind === 225 /* EnumDeclaration */) && ts.hasModifier(originalNode, 1 /* Export */)) { + var name_39 = getDeclarationName(originalNode); + // We only need to hoistVariableDeclaration for EnumDeclaration + // as ModuleDeclaration is already hoisted when the transformer call visitVariableStatement + // which then call transformsVariable for each declaration in declarationList + if (originalNode.kind === 225 /* EnumDeclaration */) { + hoistVariableDeclaration(name_39); + } + return [ + node, + createExportStatement(name_39, name_39) + ]; + } + return node; + } + /** + * Visits a ClassDeclaration, hoisting its name to the outer module body function. + * + * @param node The class declaration to visit. + */ + function visitClassDeclaration(node) { + // Hoist the name of the class declaration to the outer module body function. + var name = getDeclarationName(node); + hoistVariableDeclaration(name); + var statements = []; + // Rewrite the class declaration into an assignment of a class expression. + statements.push(ts.createStatement(ts.createAssignment(name, ts.createClassExpression( + /*modifiers*/ undefined, node.name, + /*typeParameters*/ undefined, node.heritageClauses, node.members, + /*location*/ node)), + /*location*/ node)); + // If the class was exported, write a declaration export to the inner module body function. + if (ts.hasModifier(node, 1 /* Export */)) { + if (!ts.hasModifier(node, 512 /* Default */)) { + recordExportName(name); + } + statements.push(createDeclarationExport(node)); + } + return statements; + } + function shouldHoistLoopInitializer(node) { + return ts.isVariableDeclarationList(node) && (ts.getCombinedNodeFlags(node) & 3 /* BlockScoped */) === 0; + } + /** + * Visits the body of a ForStatement to hoist declarations. + * + * @param node The statement to visit. + */ + function visitForStatement(node) { + var initializer = node.initializer; + if (shouldHoistLoopInitializer(initializer)) { + var expressions = []; + for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) { + var variable = _a[_i]; + var visited = transformVariable(variable, /*isExported*/ false); + if (visited) { + expressions.push(visited); + } + } + ; + return ts.createFor(expressions.length + ? ts.inlineExpressions(expressions) + : ts.createSynthesizedNode(194 /* OmittedExpression */), node.condition, node.incrementor, ts.visitNode(node.statement, visitNestedNode, ts.isStatement), + /*location*/ node); + } + else { + return ts.visitEachChild(node, visitNestedNode, context); + } + } + /** + * Transforms and hoists the declaration list of a ForInStatement or ForOfStatement into an expression. + * + * @param node The decalaration list to transform. + */ + function transformForBinding(node) { + var firstDeclaration = ts.firstOrUndefined(node.declarations); + hoistBindingElement(firstDeclaration, /*isExported*/ false); + var name = firstDeclaration.name; + return ts.isIdentifier(name) + ? name + : ts.flattenVariableDestructuringToExpression(firstDeclaration, hoistVariableDeclaration); + } + /** + * Visits the body of a ForInStatement to hoist declarations. + * + * @param node The statement to visit. + */ + function visitForInStatement(node) { + var initializer = node.initializer; + if (shouldHoistLoopInitializer(initializer)) { + var updated = ts.getMutableClone(node); + updated.initializer = transformForBinding(initializer); + updated.statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); + return updated; + } + else { + return ts.visitEachChild(node, visitNestedNode, context); + } + } + /** + * Visits the body of a ForOfStatement to hoist declarations. + * + * @param node The statement to visit. + */ + function visitForOfStatement(node) { + var initializer = node.initializer; + if (shouldHoistLoopInitializer(initializer)) { + var updated = ts.getMutableClone(node); + updated.initializer = transformForBinding(initializer); + updated.statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); + return updated; + } + else { + return ts.visitEachChild(node, visitNestedNode, context); + } + } + /** + * Visits the body of a DoStatement to hoist declarations. + * + * @param node The statement to visit. + */ + function visitDoStatement(node) { + var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); + if (statement !== node.statement) { + var updated = ts.getMutableClone(node); + updated.statement = statement; + return updated; + } + return node; + } + /** + * Visits the body of a WhileStatement to hoist declarations. + * + * @param node The statement to visit. + */ + function visitWhileStatement(node) { + var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); + if (statement !== node.statement) { + var updated = ts.getMutableClone(node); + updated.statement = statement; + return updated; + } + return node; + } + /** + * Visits the body of a LabeledStatement to hoist declarations. + * + * @param node The statement to visit. + */ + function visitLabeledStatement(node) { + var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); + if (statement !== node.statement) { + var updated = ts.getMutableClone(node); + updated.statement = statement; + return updated; + } + return node; + } + /** + * Visits the body of a WithStatement to hoist declarations. + * + * @param node The statement to visit. + */ + function visitWithStatement(node) { + var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); + if (statement !== node.statement) { + var updated = ts.getMutableClone(node); + updated.statement = statement; + return updated; + } + return node; + } + /** + * Visits the body of a SwitchStatement to hoist declarations. + * + * @param node The statement to visit. + */ + function visitSwitchStatement(node) { + var caseBlock = ts.visitNode(node.caseBlock, visitNestedNode, ts.isCaseBlock); + if (caseBlock !== node.caseBlock) { + var updated = ts.getMutableClone(node); + updated.caseBlock = caseBlock; + return updated; + } + return node; + } + /** + * Visits the body of a CaseBlock to hoist declarations. + * + * @param node The node to visit. + */ + function visitCaseBlock(node) { + var clauses = ts.visitNodes(node.clauses, visitNestedNode, ts.isCaseOrDefaultClause); + if (clauses !== node.clauses) { + var updated = ts.getMutableClone(node); + updated.clauses = clauses; + return updated; + } + return node; + } + /** + * Visits the body of a CaseClause to hoist declarations. + * + * @param node The clause to visit. + */ + function visitCaseClause(node) { + var statements = ts.visitNodes(node.statements, visitNestedNode, ts.isStatement); + if (statements !== node.statements) { + var updated = ts.getMutableClone(node); + updated.statements = statements; + return updated; + } + return node; + } + /** + * Visits the body of a DefaultClause to hoist declarations. + * + * @param node The clause to visit. + */ + function visitDefaultClause(node) { + return ts.visitEachChild(node, visitNestedNode, context); + } + /** + * Visits the body of a TryStatement to hoist declarations. + * + * @param node The statement to visit. + */ + function visitTryStatement(node) { + return ts.visitEachChild(node, visitNestedNode, context); + } + /** + * Visits the body of a CatchClause to hoist declarations. + * + * @param node The clause to visit. + */ + function visitCatchClause(node) { + var block = ts.visitNode(node.block, visitNestedNode, ts.isBlock); + if (block !== node.block) { + var updated = ts.getMutableClone(node); + updated.block = block; + return updated; + } + return node; + } + /** + * Visits the body of a Block to hoist declarations. + * + * @param node The block to visit. + */ + function visitBlock(node) { + return ts.visitEachChild(node, visitNestedNode, context); + } + // + // Substitutions + // + function onEmitNode(emitContext, node, emitCallback) { + if (node.kind === 256 /* SourceFile */) { + exportFunctionForFile = exportFunctionForFileMap[ts.getOriginalNodeId(node)]; + previousOnEmitNode(emitContext, node, emitCallback); + exportFunctionForFile = undefined; + } + else { + previousOnEmitNode(emitContext, node, emitCallback); + } + } + /** + * Hooks node substitutions. + * + * @param node The node to substitute. + * @param isExpression A value indicating whether the node is to be used in an expression + * position. + */ + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (emitContext === 1 /* Expression */) { + return substituteExpression(node); + } + return node; + } + /** + * Substitute the expression, if necessary. + * + * @param node The node to substitute. */ function substituteExpression(node) { switch (node.kind) { - case 69 /* Identifier */: + case 70 /* Identifier */: return substituteExpressionIdentifier(node); - case 97 /* ThisKeyword */: - return substituteThisKeyword(node); + case 188 /* BinaryExpression */: + return substituteBinaryExpression(node); + case 186 /* PrefixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: + return substituteUnaryExpression(node); } return node; } /** - * Substitutes an expression identifier. - * - * @param node An Identifier node. + * Substitution for identifiers exported at the top level of a module. */ function substituteExpressionIdentifier(node) { - if (enabledSubstitutions & 2 /* BlockScopedBindings */) { - var declaration = resolver.getReferencedDeclarationWithCollidingName(node); - if (declaration) { - return ts.getGeneratedNameForNode(declaration.name); + var importDeclaration = resolver.getReferencedImportDeclaration(node); + if (importDeclaration) { + var importBinding = createImportBinding(importDeclaration); + if (importBinding) { + return importBinding; + } + } + return node; + } + function substituteBinaryExpression(node) { + if (ts.isAssignmentOperator(node.operatorToken.kind)) { + return substituteAssignmentExpression(node); + } + return node; + } + function substituteAssignmentExpression(node) { + ts.setEmitFlags(node, 128 /* NoSubstitution */); + var left = node.left; + switch (left.kind) { + case 70 /* Identifier */: + var exportDeclaration = resolver.getReferencedExportContainer(left); + if (exportDeclaration) { + return createExportExpression(left, node); + } + break; + case 172 /* ObjectLiteralExpression */: + case 171 /* ArrayLiteralExpression */: + if (hasExportedReferenceInDestructuringPattern(left)) { + return substituteDestructuring(node); + } + break; + } + return node; + } + function isExportedBinding(name) { + var container = resolver.getReferencedExportContainer(name); + return container && container.kind === 256 /* SourceFile */; + } + function hasExportedReferenceInDestructuringPattern(node) { + switch (node.kind) { + case 70 /* Identifier */: + return isExportedBinding(node); + case 172 /* ObjectLiteralExpression */: + for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { + var property = _a[_i]; + if (hasExportedReferenceInObjectDestructuringElement(property)) { + return true; + } + } + break; + case 171 /* ArrayLiteralExpression */: + for (var _b = 0, _c = node.elements; _b < _c.length; _b++) { + var element = _c[_b]; + if (hasExportedReferenceInArrayDestructuringElement(element)) { + return true; + } + } + break; + } + return false; + } + function hasExportedReferenceInObjectDestructuringElement(node) { + if (ts.isShorthandPropertyAssignment(node)) { + return isExportedBinding(node.name); + } + else if (ts.isPropertyAssignment(node)) { + return hasExportedReferenceInDestructuringElement(node.initializer); + } + else { + return false; + } + } + function hasExportedReferenceInArrayDestructuringElement(node) { + if (ts.isSpreadElementExpression(node)) { + var expression = node.expression; + return ts.isIdentifier(expression) && isExportedBinding(expression); + } + else { + return hasExportedReferenceInDestructuringElement(node); + } + } + function hasExportedReferenceInDestructuringElement(node) { + if (ts.isBinaryExpression(node)) { + var left = node.left; + return node.operatorToken.kind === 57 /* EqualsToken */ + && isDestructuringPattern(left) + && hasExportedReferenceInDestructuringPattern(left); + } + else if (ts.isIdentifier(node)) { + return isExportedBinding(node); + } + else if (ts.isSpreadElementExpression(node)) { + var expression = node.expression; + return ts.isIdentifier(expression) && isExportedBinding(expression); + } + else if (isDestructuringPattern(node)) { + return hasExportedReferenceInDestructuringPattern(node); + } + else { + return false; + } + } + function isDestructuringPattern(node) { + var kind = node.kind; + return kind === 70 /* Identifier */ + || kind === 172 /* ObjectLiteralExpression */ + || kind === 171 /* ArrayLiteralExpression */; + } + function substituteDestructuring(node) { + return ts.flattenDestructuringAssignment(context, node, /*needsValue*/ true, hoistVariableDeclaration); + } + function substituteUnaryExpression(node) { + var operand = node.operand; + var operator = node.operator; + var substitute = ts.isIdentifier(operand) && + (node.kind === 187 /* PostfixUnaryExpression */ || + (node.kind === 186 /* PrefixUnaryExpression */ && (operator === 42 /* PlusPlusToken */ || operator === 43 /* MinusMinusToken */))); + if (substitute) { + var exportDeclaration = resolver.getReferencedExportContainer(operand); + if (exportDeclaration) { + var expr = ts.createPrefix(node.operator, operand, node); + ts.setEmitFlags(expr, 128 /* NoSubstitution */); + var call = createExportExpression(operand, expr); + if (node.kind === 186 /* PrefixUnaryExpression */) { + return call; + } + else { + // export function returns the value that was passes as the second argument + // however for postfix unary expressions result value should be the value before modification. + // emit 'x++' as '(export('x', ++x) - 1)' and 'x--' as '(export('x', --x) + 1)' + return operator === 42 /* PlusPlusToken */ + ? ts.createSubtract(call, ts.createLiteral(1)) + : ts.createAdd(call, ts.createLiteral(1)); + } } } return node; } /** - * Substitutes `this` when contained within an arrow function. - * - * @param node The ThisKeyword node. + * Gets a name to use for a DeclarationStatement. + * @param node The declaration statement. */ - function substituteThisKeyword(node) { - if (enabledSubstitutions & 1 /* CapturedThis */ - && enclosingFunction - && ts.getEmitFlags(enclosingFunction) & 256 /* CapturesThis */) { - return ts.createIdentifier("_this", /*location*/ node); + function getDeclarationName(node) { + return node.name ? ts.getSynthesizedClone(node.name) : ts.getGeneratedNameForNode(node); + } + function addExportStarFunction(statements, localNames) { + var exportStarFunction = ts.createUniqueName("exportStar"); + var m = ts.createIdentifier("m"); + var n = ts.createIdentifier("n"); + var exports = ts.createIdentifier("exports"); + var condition = ts.createStrictInequality(n, ts.createLiteral("default")); + if (localNames) { + condition = ts.createLogicalAnd(condition, ts.createLogicalNot(ts.createHasOwnProperty(localNames, n))); } - return node; + statements.push(ts.createFunctionDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, exportStarFunction, + /*typeParameters*/ undefined, [ts.createParameter(m)], + /*type*/ undefined, ts.createBlock([ + ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(exports, + /*type*/ undefined, ts.createObjectLiteral([])) + ])), + ts.createForIn(ts.createVariableDeclarationList([ + ts.createVariableDeclaration(n, /*type*/ undefined) + ]), m, ts.createBlock([ + ts.setEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 32 /* SingleLine */) + ])), + ts.createStatement(ts.createCall(exportFunctionForFile, + /*typeArguments*/ undefined, [exports])) + ], + /*location*/ undefined, + /*multiline*/ true))); + return exportStarFunction; } /** - * Gets the local name for a declaration for use in expressions. - * - * A local name will *never* be prefixed with an module or namespace export modifier like - * "exports.". - * - * @param node The declaration. - * @param allowComments A value indicating whether comments may be emitted for the name. - * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. + * Creates a call to the current file's export function to export a value. + * @param name The bound name of the export. + * @param value The exported value. */ - function getLocalName(node, allowComments, allowSourceMaps) { - return getDeclarationName(node, allowComments, allowSourceMaps, 262144 /* LocalName */); + function createExportExpression(name, value) { + var exportName = ts.isIdentifier(name) ? ts.createLiteral(name.text) : name; + return ts.createCall(exportFunctionForFile, /*typeArguments*/ undefined, [exportName, value]); } /** - * Gets the name of a declaration, without source map or comments. - * - * @param node The declaration. - * @param allowComments Allow comments for the name. + * Creates a call to the current file's export function to export a value. + * @param name The bound name of the export. + * @param value The exported value. */ - function getDeclarationName(node, allowComments, allowSourceMaps, emitFlags) { - if (node.name && !ts.isGeneratedIdentifier(node.name)) { - var name_39 = ts.getMutableClone(node.name); - emitFlags |= ts.getEmitFlags(node.name); - if (!allowSourceMaps) { - emitFlags |= 1536 /* NoSourceMap */; - } - if (!allowComments) { - emitFlags |= 49152 /* NoComments */; - } - if (emitFlags) { - ts.setEmitFlags(name_39, emitFlags); - } - return name_39; - } - return ts.getGeneratedNameForNode(node); + function createExportStatement(name, value) { + return ts.createStatement(createExportExpression(name, value)); } - function getClassMemberPrefix(node, member) { - var expression = getLocalName(node); - return ts.hasModifier(member, 32 /* Static */) ? expression : ts.createPropertyAccess(expression, "prototype"); + /** + * Creates a call to the current file's export function to export a declaration. + * @param node The declaration to export. + */ + function createDeclarationExport(node) { + var declarationName = getDeclarationName(node); + var exportName = ts.hasModifier(node, 512 /* Default */) ? ts.createLiteral("default") : declarationName; + return createExportStatement(exportName, declarationName); } - function hasSynthesizedDefaultSuperCall(constructor, hasExtendsClause) { - if (!constructor || !hasExtendsClause) { - return false; + function createImportBinding(importDeclaration) { + var importAlias; + var name; + if (ts.isImportClause(importDeclaration)) { + importAlias = ts.getGeneratedNameForNode(importDeclaration.parent); + name = ts.createIdentifier("default"); } - var parameter = ts.singleOrUndefined(constructor.parameters); - if (!parameter || !ts.nodeIsSynthesized(parameter) || !parameter.dotDotDotToken) { - return false; + else if (ts.isImportSpecifier(importDeclaration)) { + importAlias = ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent); + name = importDeclaration.propertyName || importDeclaration.name; } - var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 202 /* ExpressionStatement */) { - return false; + else { + return undefined; } - var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 174 /* CallExpression */) { - return false; + return ts.createPropertyAccess(importAlias, ts.getSynthesizedClone(name)); + } + function collectDependencyGroups(externalImports) { + var groupIndices = ts.createMap(); + var dependencyGroups = []; + for (var i = 0; i < externalImports.length; i++) { + var externalImport = externalImports[i]; + var externalModuleName = ts.getExternalModuleNameLiteral(externalImport, currentSourceFile, host, resolver, compilerOptions); + var text = externalModuleName.text; + if (ts.hasProperty(groupIndices, text)) { + // deduplicate/group entries in dependency list by the dependency name + var groupIndex = groupIndices[text]; + dependencyGroups[groupIndex].externalImports.push(externalImport); + continue; + } + else { + groupIndices[text] = dependencyGroups.length; + dependencyGroups.push({ + name: externalModuleName, + externalImports: [externalImport] + }); + } } - var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 95 /* SuperKeyword */) { - return false; + return dependencyGroups; + } + function getNameOfDependencyGroup(dependencyGroup) { + return dependencyGroup.name; + } + function recordExportName(name) { + if (!exportedLocalNames) { + exportedLocalNames = []; } - var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 191 /* SpreadElementExpression */) { - return false; + exportedLocalNames.push(name); + } + function recordExportedFunctionDeclaration(node) { + if (!exportedFunctionDeclarations) { + exportedFunctionDeclarations = []; } - var expression = callArgument.expression; - return ts.isIdentifier(expression) && expression === parameter.name; + exportedFunctionDeclarations.push(createDeclarationExport(node)); + } + function hoistBindingElement(node, isExported) { + if (ts.isOmittedExpression(node)) { + return; + } + var name = node.name; + if (ts.isIdentifier(name)) { + hoistVariableDeclaration(ts.getSynthesizedClone(name)); + if (isExported) { + recordExportName(name); + } + } + else if (ts.isBindingPattern(name)) { + ts.forEach(name.elements, isExported ? hoistExportedBindingElement : hoistNonExportedBindingElement); + } + } + function hoistExportedBindingElement(node) { + hoistBindingElement(node, /*isExported*/ true); + } + function hoistNonExportedBindingElement(node) { + hoistBindingElement(node, /*isExported*/ false); + } + function updateSourceFile(node, statements, nodeEmitFlags) { + var updated = ts.getMutableClone(node); + updated.statements = ts.createNodeArray(statements, node.statements); + ts.setEmitFlags(updated, nodeEmitFlags); + return updated; } } - ts.transformES6 = transformES6; + ts.transformSystemModule = transformSystemModule; +})(ts || (ts = {})); +/// +/// +/*@internal*/ +var ts; +(function (ts) { + function transformES2015Module(context) { + var compilerOptions = context.getCompilerOptions(); + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + return ts.visitEachChild(node, visitor, context); + } + return node; + } + function visitor(node) { + switch (node.kind) { + case 230 /* ImportEqualsDeclaration */: + // Elide `import=` as it is not legal with --module ES6 + return undefined; + case 236 /* ExportAssignment */: + return visitExportAssignment(node); + } + return node; + } + function visitExportAssignment(node) { + // Elide `export=` as it is not legal with --module ES6 + return node.isExportEquals ? undefined : node; + } + } + ts.transformES2015Module = transformES2015Module; +})(ts || (ts = {})); +/// +/// +/*@internal*/ +var ts; +(function (ts) { + /** + * Transforms ES5 syntax into ES3 syntax. + * + * @param context Context and state information for the transformation. + */ + function transformES5(context) { + var previousOnSubstituteNode = context.onSubstituteNode; + context.onSubstituteNode = onSubstituteNode; + context.enableSubstitution(173 /* PropertyAccessExpression */); + context.enableSubstitution(253 /* PropertyAssignment */); + return transformSourceFile; + /** + * Transforms an ES5 source file to ES3. + * + * @param node A SourceFile + */ + function transformSourceFile(node) { + return node; + } + /** + * Hooks node substitutions. + * + * @param emitContext The context for the emitter. + * @param node The node to substitute. + */ + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (ts.isPropertyAccessExpression(node)) { + return substitutePropertyAccessExpression(node); + } + else if (ts.isPropertyAssignment(node)) { + return substitutePropertyAssignment(node); + } + return node; + } + /** + * Substitutes a PropertyAccessExpression whose name is a reserved word. + * + * @param node A PropertyAccessExpression + */ + function substitutePropertyAccessExpression(node) { + var literalName = trySubstituteReservedName(node.name); + if (literalName) { + return ts.createElementAccess(node.expression, literalName, /*location*/ node); + } + return node; + } + /** + * Substitutes a PropertyAssignment whose name is a reserved word. + * + * @param node A PropertyAssignment + */ + function substitutePropertyAssignment(node) { + var literalName = ts.isIdentifier(node.name) && trySubstituteReservedName(node.name); + if (literalName) { + return ts.updatePropertyAssignment(node, literalName, node.initializer); + } + return node; + } + /** + * If an identifier name is a reserved word, returns a string literal for the name. + * + * @param name An Identifier + */ + function trySubstituteReservedName(name) { + var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(name.text) : undefined); + if (token >= 71 /* FirstReservedWord */ && token <= 106 /* LastReservedWord */) { + return ts.createLiteral(name, /*location*/ name); + } + return undefined; + } + } + ts.transformES5 = transformES5; })(ts || (ts = {})); /// /// /// -/// -/// +/// +/// +/// /// +/// /// /// -/// +/// /* @internal */ var ts; (function (ts) { var moduleTransformerMap = ts.createMap((_a = {}, - _a[ts.ModuleKind.ES6] = ts.transformES6Module, + _a[ts.ModuleKind.ES2015] = ts.transformES2015Module, _a[ts.ModuleKind.System] = ts.transformSystemModule, _a[ts.ModuleKind.AMD] = ts.transformModule, _a[ts.ModuleKind.CommonJS] = ts.transformModule, @@ -53039,11 +53727,19 @@ var ts; if (jsx === 2 /* React */) { transformers.push(ts.transformJsx); } - transformers.push(ts.transformES7); - if (languageVersion < 2 /* ES6 */) { - transformers.push(ts.transformES6); + if (languageVersion < 4 /* ES2017 */) { + transformers.push(ts.transformES2017); + } + if (languageVersion < 3 /* ES2016 */) { + transformers.push(ts.transformES2016); + } + if (languageVersion < 2 /* ES2015 */) { + transformers.push(ts.transformES2015); transformers.push(ts.transformGenerators); } + if (languageVersion < 1 /* ES5 */) { + transformers.push(ts.transformES5); + } return transformers; } ts.getTransformers = getTransformers; @@ -53073,7 +53769,7 @@ var ts; hoistFunctionDeclaration: hoistFunctionDeclaration, startLexicalEnvironment: startLexicalEnvironment, endLexicalEnvironment: endLexicalEnvironment, - onSubstituteNode: function (emitContext, node) { return node; }, + onSubstituteNode: function (_emitContext, node) { return node; }, enableSubstitution: enableSubstitution, isSubstitutionEnabled: isSubstitutionEnabled, onEmitNode: function (node, emitContext, emitCallback) { return emitCallback(node, emitContext); }, @@ -53274,7 +53970,7 @@ var ts; emitNodeWithSourceMap: emitNodeWithSourceMap, emitTokenWithSourceMap: emitTokenWithSourceMap, getText: getText, - getSourceMappingURL: getSourceMappingURL + getSourceMappingURL: getSourceMappingURL, }; /** * Initialize the SourceMapWriter for a new output file. @@ -53548,7 +54244,7 @@ var ts; sources: sourceMapData.sourceMapSources, names: sourceMapData.sourceMapNames, mappings: sourceMapData.sourceMapMappings, - sourcesContent: sourceMapData.sourceMapSourcesContent + sourcesContent: sourceMapData.sourceMapSourcesContent, }); } /** @@ -53625,7 +54321,7 @@ var ts; setSourceFile: setSourceFile, emitNodeWithComments: emitNodeWithComments, emitBodyWithDetachedComments: emitBodyWithDetachedComments, - emitTrailingCommentsOfPosition: emitTrailingCommentsOfPosition + emitTrailingCommentsOfPosition: emitTrailingCommentsOfPosition, }; function emitNodeWithComments(emitContext, node, emitCallback) { if (disabled) { @@ -53669,7 +54365,7 @@ var ts; containerEnd = end; // To avoid invalid comment emit in a down-level binding pattern, we // keep track of the last declaration list container's end - if (node.kind === 219 /* VariableDeclarationList */) { + if (node.kind === 220 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -53756,7 +54452,7 @@ var ts; emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos); } } - function emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) { + function emitLeadingComment(commentPos, commentEnd, _kind, hasTrailingNewLine, rangePos) { if (!hasWrittenComment) { ts.emitNewLineBeforeLeadingCommentOfPosition(currentLineMap, writer, rangePos, commentPos); hasWrittenComment = true; @@ -53775,7 +54471,7 @@ var ts; function emitTrailingComments(pos) { forEachTrailingCommentToEmit(pos, emitTrailingComment); } - function emitTrailingComment(commentPos, commentEnd, kind, hasTrailingNewLine) { + function emitTrailingComment(commentPos, commentEnd, _kind, hasTrailingNewLine) { // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment2*/ if (!writer.isAtStartOfLine()) { writer.write(" "); @@ -53799,7 +54495,7 @@ var ts; ts.performance.measure("commentTime", "beforeEmitTrailingCommentsOfPosition"); } } - function emitTrailingCommentOfPosition(commentPos, commentEnd, kind, hasTrailingNewLine) { + function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) { // trailing comments of a position are emitted at /*trailing comment1 */space/*trailing comment*/space emitPos(commentPos); ts.writeCommentRange(currentText, currentLineMap, writer, commentPos, commentEnd, newLine); @@ -53923,7 +54619,7 @@ var ts; var isCurrentFileExternalModule; var reportedDeclarationError = false; var errorNameNode; - var emitJsDocComments = compilerOptions.removeComments ? function (declaration) { } : writeJsDocComments; + var emitJsDocComments = compilerOptions.removeComments ? function () { } : writeJsDocComments; var emit = compilerOptions.stripInternal ? stripInternal : emitNode; var noDeclare; var moduleElementDeclarationEmitInfo = []; @@ -53979,7 +54675,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 230 /* ImportDeclaration */); + ts.Debug.assert(aliasEmitInfo.node.kind === 231 /* ImportDeclaration */); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -54013,7 +54709,7 @@ var ts; reportedDeclarationError: reportedDeclarationError, moduleElementDeclarationEmitInfo: allSourcesModuleElementDeclarationEmitInfo, synchronousDeclarationOutput: writer.getText(), - referencesOutput: referencesOutput + referencesOutput: referencesOutput, }; function hasInternalAnnotation(range) { var comment = currentText.substring(range.pos, range.end); @@ -54053,10 +54749,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 218 /* VariableDeclaration */) { + if (declaration.kind === 219 /* VariableDeclaration */) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 233 /* NamedImports */ || declaration.kind === 234 /* ImportSpecifier */ || declaration.kind === 231 /* ImportClause */) { + else if (declaration.kind === 234 /* NamedImports */ || declaration.kind === 235 /* ImportSpecifier */ || declaration.kind === 232 /* ImportClause */) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -54074,7 +54770,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 === 230 /* ImportDeclaration */) { + if (moduleElementEmitInfo.node.kind === 231 /* 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; @@ -54084,12 +54780,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 225 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 226 /* ModuleDeclaration */) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 225 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 226 /* ModuleDeclaration */) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -54206,53 +54902,53 @@ var ts; } function emitType(type) { switch (type.kind) { - case 117 /* AnyKeyword */: - case 132 /* StringKeyword */: - case 130 /* NumberKeyword */: - case 120 /* BooleanKeyword */: - case 133 /* SymbolKeyword */: - case 103 /* VoidKeyword */: - case 135 /* UndefinedKeyword */: - case 93 /* NullKeyword */: - case 127 /* NeverKeyword */: - case 165 /* ThisType */: - case 166 /* LiteralType */: + case 118 /* AnyKeyword */: + case 133 /* StringKeyword */: + case 131 /* NumberKeyword */: + case 121 /* BooleanKeyword */: + case 134 /* SymbolKeyword */: + case 104 /* VoidKeyword */: + case 136 /* UndefinedKeyword */: + case 94 /* NullKeyword */: + case 128 /* NeverKeyword */: + case 166 /* ThisType */: + case 167 /* LiteralType */: return writeTextOfNode(currentText, type); - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(type); - case 155 /* TypeReference */: + case 156 /* TypeReference */: return emitTypeReference(type); - case 158 /* TypeQuery */: + case 159 /* TypeQuery */: return emitTypeQuery(type); - case 160 /* ArrayType */: + case 161 /* ArrayType */: return emitArrayType(type); - case 161 /* TupleType */: + case 162 /* TupleType */: return emitTupleType(type); - case 162 /* UnionType */: + case 163 /* UnionType */: return emitUnionType(type); - case 163 /* IntersectionType */: + case 164 /* IntersectionType */: return emitIntersectionType(type); - case 164 /* ParenthesizedType */: + case 165 /* ParenthesizedType */: return emitParenType(type); - case 156 /* FunctionType */: - case 157 /* ConstructorType */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: return emitSignatureDeclarationWithJsDocComments(type); - case 159 /* TypeLiteral */: + case 160 /* TypeLiteral */: return emitTypeLiteral(type); - case 69 /* Identifier */: + case 70 /* Identifier */: return emitEntityName(type); - case 139 /* QualifiedName */: + case 140 /* QualifiedName */: return emitEntityName(type); - case 154 /* TypePredicate */: + case 155 /* TypePredicate */: return emitTypePredicate(type); } function writeEntityName(entityName) { - if (entityName.kind === 69 /* Identifier */) { + if (entityName.kind === 70 /* Identifier */) { writeTextOfNode(currentText, entityName); } else { - var left = entityName.kind === 139 /* QualifiedName */ ? entityName.left : entityName.expression; - var right = entityName.kind === 139 /* QualifiedName */ ? entityName.right : entityName.name; + var left = entityName.kind === 140 /* QualifiedName */ ? entityName.left : entityName.expression; + var right = entityName.kind === 140 /* QualifiedName */ ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentText, right); @@ -54261,14 +54957,14 @@ var ts; function emitEntityName(entityName) { var visibilityResult = resolver.isEntityNameVisible(entityName, // Aliases can be written asynchronously so use correct enclosing declaration - entityName.parent.kind === 229 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); + entityName.parent.kind === 230 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isEntityNameExpression(node.expression)) { - ts.Debug.assert(node.expression.kind === 69 /* Identifier */ || node.expression.kind === 172 /* PropertyAccessExpression */); + ts.Debug.assert(node.expression.kind === 70 /* Identifier */ || node.expression.kind === 173 /* PropertyAccessExpression */); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -54354,7 +55050,7 @@ var ts; } } function emitExportAssignment(node) { - if (node.expression.kind === 69 /* Identifier */) { + if (node.expression.kind === 70 /* Identifier */) { write(node.isExportEquals ? "export = " : "export default "); writeTextOfNode(currentText, node.expression); } @@ -54377,12 +55073,12 @@ var ts; write(";"); writeLine(); // Make all the declarations visible for the export name - if (node.expression.kind === 69 /* Identifier */) { + if (node.expression.kind === 70 /* Identifier */) { var nodes = resolver.collectLinkedAliases(node.expression); // write each of these declarations asynchronously writeAsynchronousModuleElements(nodes); } - function getDefaultExportAccessibilityDiagnostic(diagnostic) { + function getDefaultExportAccessibilityDiagnostic() { return { diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, errorNode: node @@ -54396,7 +55092,7 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 229 /* ImportEqualsDeclaration */ || + else if (node.kind === 230 /* ImportEqualsDeclaration */ || (node.parent.kind === 256 /* SourceFile */ && isCurrentFileExternalModule)) { var isVisible = void 0; if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 256 /* SourceFile */) { @@ -54409,7 +55105,7 @@ var ts; }); } else { - if (node.kind === 230 /* ImportDeclaration */) { + if (node.kind === 231 /* ImportDeclaration */) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -54427,23 +55123,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 220 /* FunctionDeclaration */: + case 221 /* FunctionDeclaration */: return writeFunctionDeclaration(node); - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: return writeVariableStatement(node); - case 222 /* InterfaceDeclaration */: + case 223 /* InterfaceDeclaration */: return writeInterfaceDeclaration(node); - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: return writeClassDeclaration(node); - case 223 /* TypeAliasDeclaration */: + case 224 /* TypeAliasDeclaration */: return writeTypeAliasDeclaration(node); - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: return writeEnumDeclaration(node); - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: return writeModuleDeclaration(node); - case 229 /* ImportEqualsDeclaration */: + case 230 /* ImportEqualsDeclaration */: return writeImportEqualsDeclaration(node); - case 230 /* ImportDeclaration */: + case 231 /* ImportDeclaration */: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -54460,7 +55156,7 @@ var ts; if (modifiers & 512 /* Default */) { write("default "); } - else if (node.kind !== 222 /* InterfaceDeclaration */ && !noDeclare) { + else if (node.kind !== 223 /* InterfaceDeclaration */ && !noDeclare) { write("declare "); } } @@ -54502,7 +55198,7 @@ var ts; write(");"); } writer.writeLine(); - function getImportEntityNameVisibilityError(symbolAccessibilityResult) { + function getImportEntityNameVisibilityError() { return { diagnosticMessage: ts.Diagnostics.Import_declaration_0_is_using_private_name_1, errorNode: node, @@ -54512,7 +55208,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 232 /* NamespaceImport */) { + if (namedBindings.kind === 233 /* NamespaceImport */) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -54536,7 +55232,7 @@ var ts; // If the default binding was emitted, write the separated write(", "); } - if (node.importClause.namedBindings.kind === 232 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 233 /* NamespaceImport */) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -54557,13 +55253,13 @@ var ts; // the only case when it is not true is when we call it to emit correct name for module augmentation - d.ts files with just module augmentations are not considered // external modules since they are indistinguishable from script files with ambient modules. To fix this in such d.ts files we'll emit top level 'export {}' // so compiler will treat them as external modules. - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 225 /* ModuleDeclaration */; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 226 /* ModuleDeclaration */; var moduleSpecifier; - if (parent.kind === 229 /* ImportEqualsDeclaration */) { + if (parent.kind === 230 /* ImportEqualsDeclaration */) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 225 /* ModuleDeclaration */) { + else if (parent.kind === 226 /* ModuleDeclaration */) { moduleSpecifier = parent.name; } else { @@ -54633,7 +55329,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body && node.body.kind !== 226 /* ModuleBlock */) { + while (node.body && node.body.kind !== 227 /* ModuleBlock */) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -54667,7 +55363,7 @@ var ts; write(";"); writeLine(); enclosingDeclaration = prevEnclosingDeclaration; - function getTypeAliasDeclarationVisibilityError(symbolAccessibilityResult) { + function getTypeAliasDeclarationVisibilityError() { return { diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, errorNode: node.type, @@ -54703,7 +55399,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 147 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); + return node.parent.kind === 148 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -54714,50 +55410,50 @@ 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 === 156 /* FunctionType */ || - node.parent.kind === 157 /* ConstructorType */ || - (node.parent.parent && node.parent.parent.kind === 159 /* TypeLiteral */)) { - ts.Debug.assert(node.parent.kind === 147 /* MethodDeclaration */ || - node.parent.kind === 146 /* MethodSignature */ || - node.parent.kind === 156 /* FunctionType */ || - node.parent.kind === 157 /* ConstructorType */ || - node.parent.kind === 151 /* CallSignature */ || - node.parent.kind === 152 /* ConstructSignature */); + if (node.parent.kind === 157 /* FunctionType */ || + node.parent.kind === 158 /* ConstructorType */ || + (node.parent.parent && node.parent.parent.kind === 160 /* TypeLiteral */)) { + ts.Debug.assert(node.parent.kind === 148 /* MethodDeclaration */ || + node.parent.kind === 147 /* MethodSignature */ || + node.parent.kind === 157 /* FunctionType */ || + node.parent.kind === 158 /* ConstructorType */ || + node.parent.kind === 152 /* CallSignature */ || + node.parent.kind === 153 /* ConstructSignature */); emitType(node.constraint); } else { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.constraint, getTypeParameterConstraintVisibilityError); } } - function getTypeParameterConstraintVisibilityError(symbolAccessibilityResult) { + function getTypeParameterConstraintVisibilityError() { // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 222 /* InterfaceDeclaration */: + case 223 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 152 /* ConstructSignature */: + case 153 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 151 /* CallSignature */: + case 152 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* 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 === 221 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 222 /* 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 220 /* FunctionDeclaration */: + case 221 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -54785,17 +55481,17 @@ var ts; if (ts.isEntityNameExpression(node.expression)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } - else if (!isImplementsList && node.expression.kind === 93 /* NullKeyword */) { + else if (!isImplementsList && node.expression.kind === 94 /* NullKeyword */) { write("null"); } else { writer.getSymbolAccessibilityDiagnostic = getHeritageClauseVisibilityError; resolver.writeBaseConstructorTypeOfClass(enclosingDeclaration, enclosingDeclaration, 2 /* UseTypeOfFunction */ | 1024 /* UseTypeAliasValue */, writer); } - function getHeritageClauseVisibilityError(symbolAccessibilityResult) { + function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 221 /* ClassDeclaration */) { + if (node.parent.parent.kind === 222 /* 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 : @@ -54879,7 +55575,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 !== 218 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (node.kind !== 219 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -54890,11 +55586,11 @@ var ts; writeTextOfNode(currentText, node.name); // If optional property emit ? but in the case of parameterProperty declaration with "?" indicating optional parameter for the constructor // we don't want to emit property declaration with "?" - if ((node.kind === 145 /* PropertyDeclaration */ || node.kind === 144 /* PropertySignature */ || - (node.kind === 142 /* Parameter */ && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { + if ((node.kind === 146 /* PropertyDeclaration */ || node.kind === 145 /* PropertySignature */ || + (node.kind === 143 /* Parameter */ && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 145 /* PropertyDeclaration */ || node.kind === 144 /* PropertySignature */) && node.parent.kind === 159 /* TypeLiteral */) { + if ((node.kind === 146 /* PropertyDeclaration */ || node.kind === 145 /* PropertySignature */) && node.parent.kind === 160 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (resolver.isLiteralConstDeclaration(node)) { @@ -54907,14 +55603,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 218 /* VariableDeclaration */) { + if (node.kind === 219 /* VariableDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 === 145 /* PropertyDeclaration */ || node.kind === 144 /* PropertySignature */) { + else if (node.kind === 146 /* PropertyDeclaration */ || node.kind === 145 /* PropertySignature */) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.hasModifier(node, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? @@ -54923,7 +55619,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 === 221 /* ClassDeclaration */) { + else if (node.parent.kind === 222 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 : @@ -54955,7 +55651,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 193 /* OmittedExpression */) { + if (element.kind !== 194 /* OmittedExpression */) { elements.push(element); } } @@ -55025,7 +55721,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 === 149 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 150 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -55038,7 +55734,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 149 /* GetAccessor */ + return accessor.kind === 150 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -55047,7 +55743,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 150 /* SetAccessor */) { + if (accessorWithTypeAnnotation.kind === 151 /* SetAccessor */) { // Setters have to have type named and cannot infer it so, the type should always be named if (ts.hasModifier(accessorWithTypeAnnotation.parent, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? @@ -55097,17 +55793,17 @@ var ts; // so no need to verify if the declaration is visible if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 220 /* FunctionDeclaration */) { + if (node.kind === 221 /* FunctionDeclaration */) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 147 /* MethodDeclaration */ || node.kind === 148 /* Constructor */) { + else if (node.kind === 148 /* MethodDeclaration */ || node.kind === 149 /* Constructor */) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); } - if (node.kind === 220 /* FunctionDeclaration */) { + if (node.kind === 221 /* FunctionDeclaration */) { write("function "); writeTextOfNode(currentText, node.name); } - else if (node.kind === 148 /* Constructor */) { + else if (node.kind === 149 /* Constructor */) { write("constructor"); } else { @@ -55127,17 +55823,17 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; var closeParenthesizedFunctionType = false; - if (node.kind === 153 /* IndexSignature */) { + if (node.kind === 154 /* IndexSignature */) { // Index signature can have readonly modifier emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); write("["); } else { // Construct signature or constructor type write new Signature - if (node.kind === 152 /* ConstructSignature */ || node.kind === 157 /* ConstructorType */) { + if (node.kind === 153 /* ConstructSignature */ || node.kind === 158 /* ConstructorType */) { write("new "); } - else if (node.kind === 156 /* FunctionType */) { + else if (node.kind === 157 /* FunctionType */) { var currentOutput = writer.getText(); // Do not generate incorrect type when function type with type parameters is type argument // This could happen if user used space between two '<' making it error free @@ -55152,22 +55848,22 @@ var ts; } // Parameters emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 153 /* IndexSignature */) { + if (node.kind === 154 /* IndexSignature */) { write("]"); } else { write(")"); } // If this is not a constructor and is not private, emit the return type - var isFunctionTypeOrConstructorType = node.kind === 156 /* FunctionType */ || node.kind === 157 /* ConstructorType */; - if (isFunctionTypeOrConstructorType || node.parent.kind === 159 /* TypeLiteral */) { + var isFunctionTypeOrConstructorType = node.kind === 157 /* FunctionType */ || node.kind === 158 /* ConstructorType */; + if (isFunctionTypeOrConstructorType || node.parent.kind === 160 /* TypeLiteral */) { // Emit type literal signature return type only if specified if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 148 /* Constructor */ && !ts.hasModifier(node, 8 /* Private */)) { + else if (node.kind !== 149 /* Constructor */ && !ts.hasModifier(node, 8 /* Private */)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -55181,26 +55877,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 152 /* ConstructSignature */: + case 153 /* ConstructSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.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 151 /* CallSignature */: + case 152 /* CallSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.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 153 /* IndexSignature */: + case 154 /* IndexSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.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 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: if (ts.hasModifier(node, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -55208,7 +55904,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 === 221 /* ClassDeclaration */) { + else if (node.parent.kind === 222 /* ClassDeclaration */) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 : @@ -55222,7 +55918,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 220 /* FunctionDeclaration */: + case 221 /* FunctionDeclaration */: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -55257,9 +55953,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 156 /* FunctionType */ || - node.parent.kind === 157 /* ConstructorType */ || - node.parent.parent.kind === 159 /* TypeLiteral */) { + if (node.parent.kind === 157 /* FunctionType */ || + node.parent.kind === 158 /* ConstructorType */ || + node.parent.parent.kind === 160 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!ts.hasModifier(node.parent, 8 /* Private */)) { @@ -55275,24 +55971,24 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 148 /* Constructor */: + case 149 /* Constructor */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 152 /* ConstructSignature */: + case 153 /* ConstructSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.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 151 /* CallSignature */: + case 152 /* CallSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.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 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -55300,7 +55996,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 === 221 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 222 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.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 : @@ -55313,7 +56009,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 220 /* FunctionDeclaration */: + case 221 /* FunctionDeclaration */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -55325,12 +56021,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 === 167 /* ObjectBindingPattern */) { + if (bindingPattern.kind === 168 /* ObjectBindingPattern */) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 168 /* ArrayBindingPattern */) { + else if (bindingPattern.kind === 169 /* ArrayBindingPattern */) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -55341,7 +56037,7 @@ var ts; } } function emitBindingElement(bindingElement) { - if (bindingElement.kind === 193 /* OmittedExpression */) { + if (bindingElement.kind === 194 /* 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) @@ -55350,7 +56046,7 @@ var ts; // emit : function foo([ , x, , ]) {} write(" "); } - else if (bindingElement.kind === 169 /* BindingElement */) { + else if (bindingElement.kind === 170 /* 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" @@ -55373,7 +56069,7 @@ var ts; emitBindingPattern(bindingElement.name); } else { - ts.Debug.assert(bindingElement.name.kind === 69 /* Identifier */); + ts.Debug.assert(bindingElement.name.kind === 70 /* 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}) {} @@ -55389,38 +56085,38 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 220 /* FunctionDeclaration */: - case 225 /* ModuleDeclaration */: - case 229 /* ImportEqualsDeclaration */: - case 222 /* InterfaceDeclaration */: - case 221 /* ClassDeclaration */: - case 223 /* TypeAliasDeclaration */: - case 224 /* EnumDeclaration */: + case 221 /* FunctionDeclaration */: + case 226 /* ModuleDeclaration */: + case 230 /* ImportEqualsDeclaration */: + case 223 /* InterfaceDeclaration */: + case 222 /* ClassDeclaration */: + case 224 /* TypeAliasDeclaration */: + case 225 /* EnumDeclaration */: return emitModuleElement(node, isModuleElementVisible(node)); - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: return emitModuleElement(node, isVariableStatementVisible(node)); - case 230 /* ImportDeclaration */: + case 231 /* ImportDeclaration */: // Import declaration without import clause is visible, otherwise it is not visible return emitModuleElement(node, /*isModuleElementVisible*/ !node.importClause); - case 236 /* ExportDeclaration */: + case 237 /* ExportDeclaration */: return emitExportDeclaration(node); - case 148 /* Constructor */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 149 /* Constructor */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: return writeFunctionDeclaration(node); - case 152 /* ConstructSignature */: - case 151 /* CallSignature */: - case 153 /* IndexSignature */: + case 153 /* ConstructSignature */: + case 152 /* CallSignature */: + case 154 /* IndexSignature */: return emitSignatureDeclarationWithJsDocComments(node); - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: return emitAccessorDeclaration(node); - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: return emitPropertyDeclaration(node); case 255 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: return emitExportAssignment(node); case 256 /* SourceFile */: return emitSourceFile(node); @@ -55448,7 +56144,7 @@ var ts; referencesOutput += "/// " + newLine; } return addedBundledEmitReference; - function getDeclFileName(emitFileNames, sourceFiles, isBundledEmit) { + function getDeclFileName(emitFileNames, _sourceFiles, isBundledEmit) { // Dont add reference path to this file if it is a bundled emit and caller asked not emit bundled file path if (isBundledEmit && !addBundledFileReference) { return; @@ -55502,7 +56198,7 @@ var ts; TempFlags[TempFlags["_i"] = 268435456] = "_i"; })(TempFlags || (TempFlags = {})); var id = function (s) { return s; }; - var nullTransformers = [function (ctx) { return id; }]; + var nullTransformers = [function (_) { return id; }]; // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles) { var delimiters = createDelimiterMap(); @@ -55817,7 +56513,7 @@ var ts; var kind = node.kind; switch (kind) { // Identifiers - case 69 /* Identifier */: + case 70 /* Identifier */: return emitIdentifier(node); } } @@ -55831,199 +56527,213 @@ var ts; var kind = node.kind; switch (kind) { // Pseudo-literals - case 12 /* TemplateHead */: - case 13 /* TemplateMiddle */: - case 14 /* TemplateTail */: + case 13 /* TemplateHead */: + case 14 /* TemplateMiddle */: + case 15 /* TemplateTail */: return emitLiteral(node); // Identifiers - case 69 /* Identifier */: + case 70 /* Identifier */: return emitIdentifier(node); // Reserved words - case 74 /* ConstKeyword */: - case 77 /* DefaultKeyword */: - case 82 /* ExportKeyword */: - case 103 /* VoidKeyword */: + case 75 /* ConstKeyword */: + case 78 /* DefaultKeyword */: + case 83 /* ExportKeyword */: + case 104 /* VoidKeyword */: // Strict mode reserved words - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - case 112 /* PublicKeyword */: - case 113 /* StaticKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + case 113 /* PublicKeyword */: + case 114 /* StaticKeyword */: // Contextual keywords - case 115 /* AbstractKeyword */: - case 117 /* AnyKeyword */: - case 118 /* AsyncKeyword */: - case 120 /* BooleanKeyword */: - case 122 /* DeclareKeyword */: - case 130 /* NumberKeyword */: - case 128 /* ReadonlyKeyword */: - case 132 /* StringKeyword */: - case 133 /* SymbolKeyword */: - case 137 /* GlobalKeyword */: + case 116 /* AbstractKeyword */: + case 117 /* AsKeyword */: + case 118 /* AnyKeyword */: + case 119 /* AsyncKeyword */: + case 120 /* AwaitKeyword */: + case 121 /* BooleanKeyword */: + case 122 /* ConstructorKeyword */: + case 123 /* DeclareKeyword */: + case 124 /* GetKeyword */: + case 125 /* IsKeyword */: + case 126 /* ModuleKeyword */: + case 127 /* NamespaceKeyword */: + case 128 /* NeverKeyword */: + case 129 /* ReadonlyKeyword */: + case 130 /* RequireKeyword */: + case 131 /* NumberKeyword */: + case 132 /* SetKeyword */: + case 133 /* StringKeyword */: + case 134 /* SymbolKeyword */: + case 135 /* TypeKeyword */: + case 136 /* UndefinedKeyword */: + case 137 /* FromKeyword */: + case 138 /* GlobalKeyword */: + case 139 /* OfKeyword */: writeTokenText(kind); return; // Parse tree nodes // Names - case 139 /* QualifiedName */: + case 140 /* QualifiedName */: return emitQualifiedName(node); - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 141 /* TypeParameter */: + case 142 /* TypeParameter */: return emitTypeParameter(node); - case 142 /* Parameter */: + case 143 /* Parameter */: return emitParameter(node); - case 143 /* Decorator */: + case 144 /* Decorator */: return emitDecorator(node); // Type members - case 144 /* PropertySignature */: + case 145 /* PropertySignature */: return emitPropertySignature(node); - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: return emitPropertyDeclaration(node); - case 146 /* MethodSignature */: + case 147 /* MethodSignature */: return emitMethodSignature(node); - case 147 /* MethodDeclaration */: + case 148 /* MethodDeclaration */: return emitMethodDeclaration(node); - case 148 /* Constructor */: + case 149 /* Constructor */: return emitConstructor(node); - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: return emitAccessorDeclaration(node); - case 151 /* CallSignature */: + case 152 /* CallSignature */: return emitCallSignature(node); - case 152 /* ConstructSignature */: + case 153 /* ConstructSignature */: return emitConstructSignature(node); - case 153 /* IndexSignature */: + case 154 /* IndexSignature */: return emitIndexSignature(node); // Types - case 154 /* TypePredicate */: + case 155 /* TypePredicate */: return emitTypePredicate(node); - case 155 /* TypeReference */: + case 156 /* TypeReference */: return emitTypeReference(node); - case 156 /* FunctionType */: + case 157 /* FunctionType */: return emitFunctionType(node); - case 157 /* ConstructorType */: + case 158 /* ConstructorType */: return emitConstructorType(node); - case 158 /* TypeQuery */: + case 159 /* TypeQuery */: return emitTypeQuery(node); - case 159 /* TypeLiteral */: + case 160 /* TypeLiteral */: return emitTypeLiteral(node); - case 160 /* ArrayType */: + case 161 /* ArrayType */: return emitArrayType(node); - case 161 /* TupleType */: + case 162 /* TupleType */: return emitTupleType(node); - case 162 /* UnionType */: + case 163 /* UnionType */: return emitUnionType(node); - case 163 /* IntersectionType */: + case 164 /* IntersectionType */: return emitIntersectionType(node); - case 164 /* ParenthesizedType */: + case 165 /* ParenthesizedType */: return emitParenthesizedType(node); - case 194 /* ExpressionWithTypeArguments */: + case 195 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 165 /* ThisType */: - return emitThisType(node); - case 166 /* LiteralType */: + case 166 /* ThisType */: + return emitThisType(); + case 167 /* LiteralType */: return emitLiteralType(node); // Binding patterns - case 167 /* ObjectBindingPattern */: + case 168 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 168 /* ArrayBindingPattern */: + case 169 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 169 /* BindingElement */: + case 170 /* BindingElement */: return emitBindingElement(node); // Misc - case 197 /* TemplateSpan */: + case 198 /* TemplateSpan */: return emitTemplateSpan(node); - case 198 /* SemicolonClassElement */: - return emitSemicolonClassElement(node); + case 199 /* SemicolonClassElement */: + return emitSemicolonClassElement(); // Statements - case 199 /* Block */: + case 200 /* Block */: return emitBlock(node); - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: return emitVariableStatement(node); - case 201 /* EmptyStatement */: - return emitEmptyStatement(node); - case 202 /* ExpressionStatement */: + case 202 /* EmptyStatement */: + return emitEmptyStatement(); + case 203 /* ExpressionStatement */: return emitExpressionStatement(node); - case 203 /* IfStatement */: + case 204 /* IfStatement */: return emitIfStatement(node); - case 204 /* DoStatement */: + case 205 /* DoStatement */: return emitDoStatement(node); - case 205 /* WhileStatement */: + case 206 /* WhileStatement */: return emitWhileStatement(node); - case 206 /* ForStatement */: + case 207 /* ForStatement */: return emitForStatement(node); - case 207 /* ForInStatement */: + case 208 /* ForInStatement */: return emitForInStatement(node); - case 208 /* ForOfStatement */: + case 209 /* ForOfStatement */: return emitForOfStatement(node); - case 209 /* ContinueStatement */: + case 210 /* ContinueStatement */: return emitContinueStatement(node); - case 210 /* BreakStatement */: + case 211 /* BreakStatement */: return emitBreakStatement(node); - case 211 /* ReturnStatement */: + case 212 /* ReturnStatement */: return emitReturnStatement(node); - case 212 /* WithStatement */: + case 213 /* WithStatement */: return emitWithStatement(node); - case 213 /* SwitchStatement */: + case 214 /* SwitchStatement */: return emitSwitchStatement(node); - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: return emitLabeledStatement(node); - case 215 /* ThrowStatement */: + case 216 /* ThrowStatement */: return emitThrowStatement(node); - case 216 /* TryStatement */: + case 217 /* TryStatement */: return emitTryStatement(node); - case 217 /* DebuggerStatement */: + case 218 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 218 /* VariableDeclaration */: + case 219 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 219 /* VariableDeclarationList */: + case 220 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 220 /* FunctionDeclaration */: + case 221 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: return emitClassDeclaration(node); - case 222 /* InterfaceDeclaration */: + case 223 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 223 /* TypeAliasDeclaration */: + case 224 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 226 /* ModuleBlock */: + case 227 /* ModuleBlock */: return emitModuleBlock(node); - case 227 /* CaseBlock */: + case 228 /* CaseBlock */: return emitCaseBlock(node); - case 229 /* ImportEqualsDeclaration */: + case 230 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 230 /* ImportDeclaration */: + case 231 /* ImportDeclaration */: return emitImportDeclaration(node); - case 231 /* ImportClause */: + case 232 /* ImportClause */: return emitImportClause(node); - case 232 /* NamespaceImport */: + case 233 /* NamespaceImport */: return emitNamespaceImport(node); - case 233 /* NamedImports */: + case 234 /* NamedImports */: return emitNamedImports(node); - case 234 /* ImportSpecifier */: + case 235 /* ImportSpecifier */: return emitImportSpecifier(node); - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: return emitExportAssignment(node); - case 236 /* ExportDeclaration */: + case 237 /* ExportDeclaration */: return emitExportDeclaration(node); - case 237 /* NamedExports */: + case 238 /* NamedExports */: return emitNamedExports(node); - case 238 /* ExportSpecifier */: + case 239 /* ExportSpecifier */: return emitExportSpecifier(node); - case 239 /* MissingDeclaration */: + case 240 /* MissingDeclaration */: return; // Module references - case 240 /* ExternalModuleReference */: + case 241 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) - case 244 /* JsxText */: + case 10 /* JsxText */: return emitJsxText(node); - case 243 /* JsxOpeningElement */: + case 244 /* JsxOpeningElement */: return emitJsxOpeningElement(node); case 245 /* JsxClosingElement */: return emitJsxClosingElement(node); @@ -56070,77 +56780,77 @@ var ts; case 8 /* NumericLiteral */: return emitNumericLiteral(node); case 9 /* StringLiteral */: - case 10 /* RegularExpressionLiteral */: - case 11 /* NoSubstitutionTemplateLiteral */: + case 11 /* RegularExpressionLiteral */: + case 12 /* NoSubstitutionTemplateLiteral */: return emitLiteral(node); // Identifiers - case 69 /* Identifier */: + case 70 /* Identifier */: return emitIdentifier(node); // Reserved words - case 84 /* FalseKeyword */: - case 93 /* NullKeyword */: - case 95 /* SuperKeyword */: - case 99 /* TrueKeyword */: - case 97 /* ThisKeyword */: + case 85 /* FalseKeyword */: + case 94 /* NullKeyword */: + case 96 /* SuperKeyword */: + case 100 /* TrueKeyword */: + case 98 /* ThisKeyword */: writeTokenText(kind); return; // Expressions - case 170 /* ArrayLiteralExpression */: + case 171 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 171 /* ObjectLiteralExpression */: + case 172 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 172 /* PropertyAccessExpression */: + case 173 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 173 /* ElementAccessExpression */: + case 174 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 174 /* CallExpression */: + case 175 /* CallExpression */: return emitCallExpression(node); - case 175 /* NewExpression */: + case 176 /* NewExpression */: return emitNewExpression(node); - case 176 /* TaggedTemplateExpression */: + case 177 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 177 /* TypeAssertionExpression */: + case 178 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 178 /* ParenthesizedExpression */: + case 179 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 179 /* FunctionExpression */: + case 180 /* FunctionExpression */: return emitFunctionExpression(node); - case 180 /* ArrowFunction */: + case 181 /* ArrowFunction */: return emitArrowFunction(node); - case 181 /* DeleteExpression */: + case 182 /* DeleteExpression */: return emitDeleteExpression(node); - case 182 /* TypeOfExpression */: + case 183 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 183 /* VoidExpression */: + case 184 /* VoidExpression */: return emitVoidExpression(node); - case 184 /* AwaitExpression */: + case 185 /* AwaitExpression */: return emitAwaitExpression(node); - case 185 /* PrefixUnaryExpression */: + case 186 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 186 /* PostfixUnaryExpression */: + case 187 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return emitBinaryExpression(node); - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: return emitConditionalExpression(node); - case 189 /* TemplateExpression */: + case 190 /* TemplateExpression */: return emitTemplateExpression(node); - case 190 /* YieldExpression */: + case 191 /* YieldExpression */: return emitYieldExpression(node); - case 191 /* SpreadElementExpression */: + case 192 /* SpreadElementExpression */: return emitSpreadElementExpression(node); - case 192 /* ClassExpression */: + case 193 /* ClassExpression */: return emitClassExpression(node); - case 193 /* OmittedExpression */: + case 194 /* OmittedExpression */: return; - case 195 /* AsExpression */: + case 196 /* AsExpression */: return emitAsExpression(node); - case 196 /* NonNullExpression */: + case 197 /* NonNullExpression */: return emitNonNullExpression(node); // JSX - case 241 /* JsxElement */: + case 242 /* JsxElement */: return emitJsxElement(node); - case 242 /* JsxSelfClosingElement */: + case 243 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); // Transformation nodes case 288 /* PartiallyEmittedExpression */: @@ -56193,7 +56903,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 69 /* Identifier */) { + if (node.kind === 70 /* Identifier */) { emitExpression(node); } else { @@ -56269,7 +56979,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - write(node.kind === 149 /* GetAccessor */ ? "get " : "set "); + write(node.kind === 150 /* GetAccessor */ ? "get " : "set "); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); } @@ -56297,7 +57007,7 @@ var ts; emitWithPrefix(": ", node.type); write(";"); } - function emitSemicolonClassElement(node) { + function emitSemicolonClassElement() { write(";"); } // @@ -56354,7 +57064,7 @@ var ts; emit(node.type); write(")"); } - function emitThisType(node) { + function emitThisType() { write("this"); } function emitLiteralType(node) { @@ -56428,7 +57138,7 @@ var ts; if (!(ts.getEmitFlags(node) & 1048576 /* NoIndentation */)) { var dotRangeStart = node.expression.end; var dotRangeEnd = ts.skipTrivia(currentText, node.expression.end) + 1; - var dotToken = { kind: 21 /* DotToken */, pos: dotRangeStart, end: dotRangeEnd }; + var dotToken = { kind: 22 /* DotToken */, pos: dotRangeStart, end: dotRangeEnd }; indentBeforeDot = needsIndentation(node, node.expression, dotToken); indentAfterDot = needsIndentation(node, dotToken, node.name); } @@ -56446,7 +57156,7 @@ var ts; if (expression.kind === 8 /* NumericLiteral */) { // check if numeric literal was originally written with a dot var text = getLiteralTextOfNode(expression); - return text.indexOf(ts.tokenToString(21 /* DotToken */)) < 0; + return text.indexOf(ts.tokenToString(22 /* DotToken */)) < 0; } else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { // check if constant enum value is integer @@ -56465,11 +57175,13 @@ var ts; } function emitCallExpression(node) { emitExpression(node.expression); + emitTypeArguments(node, node.typeArguments); emitExpressionList(node, node.arguments, 1296 /* CallExpressionArguments */); } function emitNewExpression(node) { write("new "); emitExpression(node.expression); + emitTypeArguments(node, node.typeArguments); emitExpressionList(node, node.arguments, 9488 /* NewExpressionArguments */); } function emitTaggedTemplateExpression(node) { @@ -56541,16 +57253,16 @@ var ts; // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. var operand = node.operand; - return operand.kind === 185 /* PrefixUnaryExpression */ - && ((node.operator === 35 /* PlusToken */ && (operand.operator === 35 /* PlusToken */ || operand.operator === 41 /* PlusPlusToken */)) - || (node.operator === 36 /* MinusToken */ && (operand.operator === 36 /* MinusToken */ || operand.operator === 42 /* MinusMinusToken */))); + return operand.kind === 186 /* PrefixUnaryExpression */ + && ((node.operator === 36 /* PlusToken */ && (operand.operator === 36 /* PlusToken */ || operand.operator === 42 /* PlusPlusToken */)) + || (node.operator === 37 /* MinusToken */ && (operand.operator === 37 /* MinusToken */ || operand.operator === 43 /* MinusMinusToken */))); } function emitPostfixUnaryExpression(node) { emitExpression(node.operand); writeTokenText(node.operator); } function emitBinaryExpression(node) { - var isCommaOperator = node.operatorToken.kind !== 24 /* CommaToken */; + var isCommaOperator = node.operatorToken.kind !== 25 /* CommaToken */; var indentBeforeOperator = needsIndentation(node, node.left, node.operatorToken); var indentAfterOperator = needsIndentation(node, node.operatorToken, node.right); emitExpression(node.left); @@ -56617,16 +57329,16 @@ var ts; // // Statements // - function emitBlock(node, format) { + function emitBlock(node) { if (isSingleLineEmptyBlock(node)) { - writeToken(15 /* OpenBraceToken */, node.pos, /*contextNode*/ node); + writeToken(16 /* OpenBraceToken */, node.pos, /*contextNode*/ node); write(" "); - writeToken(16 /* CloseBraceToken */, node.statements.end, /*contextNode*/ node); + writeToken(17 /* CloseBraceToken */, node.statements.end, /*contextNode*/ node); } else { - writeToken(15 /* OpenBraceToken */, node.pos, /*contextNode*/ node); + writeToken(16 /* OpenBraceToken */, node.pos, /*contextNode*/ node); emitBlockStatements(node); - writeToken(16 /* CloseBraceToken */, node.statements.end, /*contextNode*/ node); + writeToken(17 /* CloseBraceToken */, node.statements.end, /*contextNode*/ node); } } function emitBlockStatements(node) { @@ -56642,7 +57354,7 @@ var ts; emit(node.declarationList); write(";"); } - function emitEmptyStatement(node) { + function emitEmptyStatement() { write(";"); } function emitExpressionStatement(node) { @@ -56650,16 +57362,16 @@ var ts; write(";"); } function emitIfStatement(node) { - var openParenPos = writeToken(88 /* IfKeyword */, node.pos, node); + var openParenPos = writeToken(89 /* IfKeyword */, node.pos, node); write(" "); - writeToken(17 /* OpenParenToken */, openParenPos, node); + writeToken(18 /* OpenParenToken */, openParenPos, node); emitExpression(node.expression); - writeToken(18 /* CloseParenToken */, node.expression.end, node); + writeToken(19 /* CloseParenToken */, node.expression.end, node); emitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { writeLine(); - writeToken(80 /* ElseKeyword */, node.thenStatement.end, node); - if (node.elseStatement.kind === 203 /* IfStatement */) { + writeToken(81 /* ElseKeyword */, node.thenStatement.end, node); + if (node.elseStatement.kind === 204 /* IfStatement */) { write(" "); emit(node.elseStatement); } @@ -56688,9 +57400,9 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForStatement(node) { - var openParenPos = writeToken(86 /* ForKeyword */, node.pos); + var openParenPos = writeToken(87 /* ForKeyword */, node.pos); write(" "); - writeToken(17 /* OpenParenToken */, openParenPos, /*contextNode*/ node); + writeToken(18 /* OpenParenToken */, openParenPos, /*contextNode*/ node); emitForBinding(node.initializer); write(";"); emitExpressionWithPrefix(" ", node.condition); @@ -56700,28 +57412,28 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInStatement(node) { - var openParenPos = writeToken(86 /* ForKeyword */, node.pos); + var openParenPos = writeToken(87 /* ForKeyword */, node.pos); write(" "); - writeToken(17 /* OpenParenToken */, openParenPos); + writeToken(18 /* OpenParenToken */, openParenPos); emitForBinding(node.initializer); write(" in "); emitExpression(node.expression); - writeToken(18 /* CloseParenToken */, node.expression.end); + writeToken(19 /* CloseParenToken */, node.expression.end); emitEmbeddedStatement(node.statement); } function emitForOfStatement(node) { - var openParenPos = writeToken(86 /* ForKeyword */, node.pos); + var openParenPos = writeToken(87 /* ForKeyword */, node.pos); write(" "); - writeToken(17 /* OpenParenToken */, openParenPos); + writeToken(18 /* OpenParenToken */, openParenPos); emitForBinding(node.initializer); write(" of "); emitExpression(node.expression); - writeToken(18 /* CloseParenToken */, node.expression.end); + writeToken(19 /* CloseParenToken */, node.expression.end); emitEmbeddedStatement(node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 219 /* VariableDeclarationList */) { + if (node.kind === 220 /* VariableDeclarationList */) { emit(node); } else { @@ -56730,17 +57442,17 @@ var ts; } } function emitContinueStatement(node) { - writeToken(75 /* ContinueKeyword */, node.pos); + writeToken(76 /* ContinueKeyword */, node.pos); emitWithPrefix(" ", node.label); write(";"); } function emitBreakStatement(node) { - writeToken(70 /* BreakKeyword */, node.pos); + writeToken(71 /* BreakKeyword */, node.pos); emitWithPrefix(" ", node.label); write(";"); } function emitReturnStatement(node) { - writeToken(94 /* ReturnKeyword */, node.pos, /*contextNode*/ node); + writeToken(95 /* ReturnKeyword */, node.pos, /*contextNode*/ node); emitExpressionWithPrefix(" ", node.expression); write(";"); } @@ -56751,11 +57463,11 @@ var ts; emitEmbeddedStatement(node.statement); } function emitSwitchStatement(node) { - var openParenPos = writeToken(96 /* SwitchKeyword */, node.pos); + var openParenPos = writeToken(97 /* SwitchKeyword */, node.pos); write(" "); - writeToken(17 /* OpenParenToken */, openParenPos); + writeToken(18 /* OpenParenToken */, openParenPos); emitExpression(node.expression); - writeToken(18 /* CloseParenToken */, node.expression.end); + writeToken(19 /* CloseParenToken */, node.expression.end); write(" "); emit(node.caseBlock); } @@ -56780,7 +57492,7 @@ var ts; } } function emitDebuggerStatement(node) { - writeToken(76 /* DebuggerKeyword */, node.pos); + writeToken(77 /* DebuggerKeyword */, node.pos); write(";"); } // @@ -56788,6 +57500,7 @@ var ts; // function emitVariableDeclaration(node) { emit(node.name); + emitWithPrefix(": ", node.type); emitExpressionWithPrefix(" = ", node.initializer); } function emitVariableDeclarationList(node) { @@ -56814,13 +57527,13 @@ var ts; } if (ts.getEmitFlags(node) & 4194304 /* ReuseTempVariableScope */) { emitSignatureHead(node); - emitBlockFunctionBody(node, body); + emitBlockFunctionBody(body); } else { var savedTempFlags = tempFlags; tempFlags = 0; emitSignatureHead(node); - emitBlockFunctionBody(node, body); + emitBlockFunctionBody(body); tempFlags = savedTempFlags; } if (indentedFlag) { @@ -56843,7 +57556,7 @@ var ts; emitParameters(node, node.parameters); emitWithPrefix(": ", node.type); } - function shouldEmitBlockFunctionBodyOnSingleLine(parentNode, body) { + function shouldEmitBlockFunctionBodyOnSingleLine(body) { // We must emit a function body as a single-line body in the following case: // * The body has NodeEmitFlags.SingleLine specified. // We must emit a function body as a multi-line body in the following cases: @@ -56873,14 +57586,14 @@ var ts; } return true; } - function emitBlockFunctionBody(parentNode, body) { + function emitBlockFunctionBody(body) { write(" {"); increaseIndent(); - emitBodyWithDetachedComments(body, body.statements, shouldEmitBlockFunctionBodyOnSingleLine(parentNode, body) + emitBodyWithDetachedComments(body, body.statements, shouldEmitBlockFunctionBodyOnSingleLine(body) ? emitBlockFunctionBodyOnSingleLine : emitBlockFunctionBodyWorker); decreaseIndent(); - writeToken(16 /* CloseBraceToken */, body.statements.end, body); + writeToken(17 /* CloseBraceToken */, body.statements.end, body); } function emitBlockFunctionBodyOnSingleLine(body) { emitBlockFunctionBodyWorker(body, /*emitBlockFunctionBodyOnSingleLine*/ true); @@ -56959,7 +57672,7 @@ var ts; write(node.flags & 16 /* Namespace */ ? "namespace " : "module "); emit(node.name); var body = node.body; - while (body.kind === 225 /* ModuleDeclaration */) { + while (body.kind === 226 /* ModuleDeclaration */) { write("."); emit(body.name); body = body.body; @@ -56982,9 +57695,9 @@ var ts; } } function emitCaseBlock(node) { - writeToken(15 /* OpenBraceToken */, node.pos); + writeToken(16 /* OpenBraceToken */, node.pos); emitList(node, node.clauses, 65 /* CaseBlockClauses */); - writeToken(16 /* CloseBraceToken */, node.clauses.end); + writeToken(17 /* CloseBraceToken */, node.clauses.end); } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); @@ -56995,7 +57708,7 @@ var ts; write(";"); } function emitModuleReference(node) { - if (node.kind === 69 /* Identifier */) { + if (node.kind === 70 /* Identifier */) { emitExpression(node); } else { @@ -57121,7 +57834,7 @@ var ts; } } function emitJsxTagName(node) { - if (node.kind === 69 /* Identifier */) { + if (node.kind === 70 /* Identifier */) { emitExpression(node); } else { @@ -57164,11 +57877,11 @@ var ts; } function emitCatchClause(node) { writeLine(); - var openParenPos = writeToken(72 /* CatchKeyword */, node.pos); + var openParenPos = writeToken(73 /* CatchKeyword */, node.pos); write(" "); - writeToken(17 /* OpenParenToken */, openParenPos); + writeToken(18 /* OpenParenToken */, openParenPos); emit(node.variableDeclaration); - writeToken(18 /* CloseParenToken */, node.variableDeclaration ? node.variableDeclaration.end : openParenPos); + writeToken(19 /* CloseParenToken */, node.variableDeclaration ? node.variableDeclaration.end : openParenPos); write(" "); emit(node.block); } @@ -57279,7 +57992,7 @@ var ts; var helpersEmitted = false; // Only Emit __extends function when target ES5. // For target ES6 and above, we can emit classDeclaration as is. - if ((languageVersion < 2 /* ES6 */) && (!extendsEmitted && node.flags & 1024 /* HasClassExtends */)) { + if ((languageVersion < 2 /* ES2015 */) && (!extendsEmitted && node.flags & 1024 /* HasClassExtends */)) { writeLines(extendsHelper); extendsEmitted = true; helpersEmitted = true; @@ -57301,9 +58014,12 @@ var ts; paramEmitted = true; helpersEmitted = true; } - if (!awaiterEmitted && node.flags & 8192 /* HasAsyncFunctions */) { + // Only emit __awaiter function when target ES5/ES6. + // Only emit __generator function when target ES5. + // For target ES2017 and above, we can emit async/await as is. + if ((languageVersion < 4 /* ES2017 */) && (!awaiterEmitted && node.flags & 8192 /* HasAsyncFunctions */)) { writeLines(awaiterHelper); - if (languageVersion < 2 /* ES6 */) { + if (languageVersion < 2 /* ES2015 */) { writeLines(generatorHelper); } awaiterEmitted = true; @@ -57630,7 +58346,7 @@ var ts; && !ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 178 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 179 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -57755,19 +58471,19 @@ var ts; */ function generateNameForNode(node) { switch (node.kind) { - case 69 /* Identifier */: + case 70 /* Identifier */: return makeUniqueName(getTextOfNode(node)); - case 225 /* ModuleDeclaration */: - case 224 /* EnumDeclaration */: + case 226 /* ModuleDeclaration */: + case 225 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 230 /* ImportDeclaration */: - case 236 /* ExportDeclaration */: + case 231 /* ImportDeclaration */: + case 237 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 220 /* FunctionDeclaration */: - case 221 /* ClassDeclaration */: - case 235 /* ExportAssignment */: + case 221 /* FunctionDeclaration */: + case 222 /* ClassDeclaration */: + case 236 /* ExportAssignment */: return generateNameForExportDefault(); - case 192 /* ClassExpression */: + case 193 /* ClassExpression */: return generateNameForClassExpression(); default: return makeTempVariableName(0 /* Auto */); @@ -58440,7 +59156,7 @@ var ts; getSourceFiles: program.getSourceFiles, isSourceFileFromExternalLibrary: function (file) { return !!sourceFilesFoundSearchingNodeModules[file.path]; }, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), - isEmitBlocked: isEmitBlocked + isEmitBlocked: isEmitBlocked, }; } function getDiagnosticsProducingTypeChecker() { @@ -58530,7 +59246,7 @@ var ts; return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile, cancellationToken); } } - function getSyntacticDiagnosticsForFile(sourceFile, cancellationToken) { + function getSyntacticDiagnosticsForFile(sourceFile) { return sourceFile.parseDiagnostics; } function runWithCancellationToken(func) { @@ -58563,14 +59279,14 @@ var ts; // Instead, we just report errors for using TypeScript-only constructs from within a // JavaScript file. var checkDiagnostics = ts.isSourceFileJavaScript(sourceFile) ? - getJavaScriptSemanticDiagnosticsForFile(sourceFile, cancellationToken) : + getJavaScriptSemanticDiagnosticsForFile(sourceFile) : typeChecker.getDiagnostics(sourceFile, cancellationToken); var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); - return bindDiagnostics.concat(checkDiagnostics).concat(fileProcessingDiagnosticsInFile).concat(programDiagnosticsInFile); + return bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); }); } - function getJavaScriptSemanticDiagnosticsForFile(sourceFile, cancellationToken) { + function getJavaScriptSemanticDiagnosticsForFile(sourceFile) { return runWithCancellationToken(function () { var diagnostics = []; walk(sourceFile); @@ -58580,16 +59296,16 @@ var ts; return false; } switch (node.kind) { - case 229 /* ImportEqualsDeclaration */: + case 230 /* ImportEqualsDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return true; - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return true; } break; - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: var classDeclaration = node; if (checkModifiers(classDeclaration.modifiers) || checkTypeParameters(classDeclaration.typeParameters)) { @@ -58598,29 +59314,29 @@ var ts; break; case 251 /* HeritageClause */: var heritageClause = node; - if (heritageClause.token === 106 /* ImplementsKeyword */) { + if (heritageClause.token === 107 /* ImplementsKeyword */) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return true; } break; - case 222 /* InterfaceDeclaration */: + case 223 /* InterfaceDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return true; - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return true; - case 223 /* TypeAliasDeclaration */: + case 224 /* TypeAliasDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return true; - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 179 /* FunctionExpression */: - case 220 /* FunctionDeclaration */: - case 180 /* ArrowFunction */: - case 220 /* FunctionDeclaration */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 180 /* FunctionExpression */: + case 221 /* FunctionDeclaration */: + case 181 /* ArrowFunction */: + case 221 /* FunctionDeclaration */: var functionDeclaration = node; if (checkModifiers(functionDeclaration.modifiers) || checkTypeParameters(functionDeclaration.typeParameters) || @@ -58628,20 +59344,20 @@ var ts; return true; } break; - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: var variableStatement = node; if (checkModifiers(variableStatement.modifiers)) { return true; } break; - case 218 /* VariableDeclaration */: + case 219 /* VariableDeclaration */: var variableDeclaration = node; if (checkTypeAnnotation(variableDeclaration.type)) { return true; } break; - case 174 /* CallExpression */: - case 175 /* NewExpression */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: var expression = node; if (expression.typeArguments && expression.typeArguments.length > 0) { var start = expression.typeArguments.pos; @@ -58649,7 +59365,7 @@ var ts; return true; } break; - case 142 /* Parameter */: + case 143 /* Parameter */: var parameter = node; if (parameter.modifiers) { var start = parameter.modifiers.pos; @@ -58665,12 +59381,12 @@ var ts; return true; } break; - case 145 /* PropertyDeclaration */: + case 146 /* PropertyDeclaration */: var propertyDeclaration = node; if (propertyDeclaration.modifiers) { for (var _i = 0, _a = propertyDeclaration.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 113 /* StaticKeyword */) { + if (modifier.kind !== 114 /* StaticKeyword */) { diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); return true; } @@ -58680,14 +59396,14 @@ var ts; return true; } break; - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return true; - case 177 /* TypeAssertionExpression */: + case 178 /* 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 143 /* Decorator */: + case 144 /* Decorator */: if (!options.experimentalDecorators) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning)); } @@ -58715,19 +59431,19 @@ var ts; for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { var modifier = modifiers_1[_i]; switch (modifier.kind) { - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - case 128 /* ReadonlyKeyword */: - case 122 /* DeclareKeyword */: + case 113 /* PublicKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + case 129 /* ReadonlyKeyword */: + case 123 /* 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 113 /* StaticKeyword */: - case 82 /* ExportKeyword */: - case 74 /* ConstKeyword */: - case 77 /* DefaultKeyword */: - case 115 /* AbstractKeyword */: + case 114 /* StaticKeyword */: + case 83 /* ExportKeyword */: + case 75 /* ConstKeyword */: + case 78 /* DefaultKeyword */: + case 116 /* AbstractKeyword */: } } } @@ -58761,7 +59477,7 @@ var ts; return ts.getBaseFileName(fileName).indexOf(".") >= 0; } function processRootFile(fileName, isDefaultLib) { - processSourceFile(ts.normalizePath(fileName), isDefaultLib, /*isReference*/ true); + processSourceFile(ts.normalizePath(fileName), isDefaultLib); } function fileReferenceIsEqualTo(a, b) { return a.fileName === b.fileName; @@ -58802,9 +59518,9 @@ var ts; return; function collectModuleReferences(node, inAmbientModule) { switch (node.kind) { - case 230 /* ImportDeclaration */: - case 229 /* ImportEqualsDeclaration */: - case 236 /* ExportDeclaration */: + case 231 /* ImportDeclaration */: + case 230 /* ImportEqualsDeclaration */: + case 237 /* ExportDeclaration */: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9 /* StringLiteral */) { break; @@ -58819,7 +59535,7 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasModifier(node, 2 /* Ambient */) || ts.isDeclarationFile(file))) { var moduleName = node.name; // Ambient module declarations can be interpreted as augmentations for some existing external modules. @@ -58859,7 +59575,7 @@ var ts; /** * 'isReference' indicates whether the file was brought in via a reference directive (rather than an import declaration) */ - function processSourceFile(fileName, isDefaultLib, isReference, refFile, refPos, refEnd) { + function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { var diagnosticArgument; var diagnostic; if (hasExtension(fileName)) { @@ -58867,7 +59583,7 @@ var ts; diagnostic = ts.Diagnostics.File_0_has_unsupported_extension_The_only_supported_extensions_are_1; diagnosticArgument = [fileName, "'" + supportedExtensions.join("', '") + "'"]; } - else if (!findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, isReference, refFile, refPos, refEnd)) { + else if (!findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd)) { diagnostic = ts.Diagnostics.File_0_not_found; diagnosticArgument = [fileName]; } @@ -58877,13 +59593,13 @@ var ts; } } else { - var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, isReference, refFile, refPos, refEnd); + var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd); if (!nonTsFile) { if (options.allowNonTsExtensions) { diagnostic = ts.Diagnostics.File_0_not_found; diagnosticArgument = [fileName]; } - else if (!ts.forEach(supportedExtensions, function (extension) { return findSourceFile(fileName + extension, ts.toPath(fileName + extension, currentDirectory, getCanonicalFileName), isDefaultLib, isReference, refFile, refPos, refEnd); })) { + else if (!ts.forEach(supportedExtensions, function (extension) { return findSourceFile(fileName + extension, ts.toPath(fileName + extension, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd); })) { diagnostic = ts.Diagnostics.File_0_not_found; fileName += ".ts"; diagnosticArgument = [fileName]; @@ -58908,7 +59624,7 @@ var ts; } } // Get source file from normalized fileName - function findSourceFile(fileName, path, isDefaultLib, isReference, refFile, refPos, refEnd) { + function findSourceFile(fileName, path, isDefaultLib, refFile, refPos, refEnd) { if (filesByName.contains(path)) { var file_1 = filesByName.get(path); // try to check if we've already seen this file but with a different casing in path @@ -58921,16 +59637,16 @@ var ts; if (file_1 && sourceFilesFoundSearchingNodeModules[file_1.path] && currentNodeModulesDepth == 0) { sourceFilesFoundSearchingNodeModules[file_1.path] = false; if (!options.noResolve) { - processReferencedFiles(file_1, ts.getDirectoryPath(fileName), isDefaultLib); + processReferencedFiles(file_1, isDefaultLib); processTypeReferenceDirectives(file_1); } modulesWithElidedImports[file_1.path] = false; - processImportedModules(file_1, ts.getDirectoryPath(fileName)); + processImportedModules(file_1); } else if (file_1 && modulesWithElidedImports[file_1.path]) { if (currentNodeModulesDepth < maxNodeModulesJsDepth) { modulesWithElidedImports[file_1.path] = false; - processImportedModules(file_1, ts.getDirectoryPath(fileName)); + processImportedModules(file_1); } } return file_1; @@ -58959,13 +59675,12 @@ var ts; } } skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib; - var basePath = ts.getDirectoryPath(fileName); if (!options.noResolve) { - processReferencedFiles(file, basePath, isDefaultLib); + processReferencedFiles(file, isDefaultLib); processTypeReferenceDirectives(file); } // always process imported modules to record module name resolutions - processImportedModules(file, basePath); + processImportedModules(file); if (isDefaultLib) { files.unshift(file); } @@ -58975,10 +59690,10 @@ var ts; } return file; } - function processReferencedFiles(file, basePath, isDefaultLib) { + function processReferencedFiles(file, isDefaultLib) { ts.forEach(file.referencedFiles, function (ref) { var referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName); - processSourceFile(referencedFileName, isDefaultLib, /*isReference*/ true, file, ref.pos, ref.end); + processSourceFile(referencedFileName, isDefaultLib, file, ref.pos, ref.end); }); } function processTypeReferenceDirectives(file) { @@ -59004,7 +59719,7 @@ var ts; if (resolvedTypeReferenceDirective) { if (resolvedTypeReferenceDirective.primary) { // resolved from the primary path - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*isReference*/ true, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, refFile, refPos, refEnd); } else { // If we already resolved to this file, it must have been a secondary reference. Check file contents @@ -59019,7 +59734,7 @@ var ts; } else { // First resolution of this library - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*isReference*/ true, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, refFile, refPos, refEnd); } } } @@ -59045,7 +59760,7 @@ var ts; function getCanonicalFileName(fileName) { return host.getCanonicalFileName(fileName); } - function processImportedModules(file, basePath) { + function processImportedModules(file) { collectExternalModuleReferences(file); if (file.imports.length || file.moduleAugmentations.length) { file.resolvedModules = ts.createMap(); @@ -59071,7 +59786,7 @@ var ts; } else if (shouldAddFile) { findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), - /*isDefaultLib*/ false, /*isReference*/ false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); + /*isDefaultLib*/ false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); } if (isFromNodeModulesSearch) { currentNodeModulesDepth--; @@ -59200,7 +59915,7 @@ var ts; var outFile = options.outFile || options.out; var firstNonAmbientExternalModuleSourceFile = ts.forEach(files, function (f) { return ts.isExternalModule(f) && !ts.isDeclarationFile(f) ? f : undefined; }); if (options.isolatedModules) { - if (options.module === ts.ModuleKind.None && languageVersion < 2 /* ES6 */) { + if (options.module === ts.ModuleKind.None && languageVersion < 2 /* ES2015 */) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher)); } var firstNonExternalModuleSourceFile = ts.forEach(files, function (f) { return !ts.isExternalModule(f) && !ts.isDeclarationFile(f) ? f : undefined; }); @@ -59209,7 +59924,7 @@ var ts; programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span_7.start, span_7.length, ts.Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided)); } } - else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 /* ES6 */ && options.module === ts.ModuleKind.None) { + else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 /* ES2015 */ && options.module === ts.ModuleKind.None) { // We cannot use createDiagnosticFromNode because nodes do not have parents yet var span_8 = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, firstNonAmbientExternalModuleSourceFile.externalModuleIndicator); programDiagnostics.add(ts.createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span_8.start, span_8.length, ts.Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none)); @@ -59250,7 +59965,7 @@ var ts; if (!options.noEmit && !options.suppressOutputPathCheck) { var emitHost = getEmitHost(); var emitFilesSeen_1 = ts.createFileMap(!host.useCaseSensitiveFileNames() ? function (key) { return key.toLocaleLowerCase(); } : undefined); - ts.forEachExpectedEmitFile(emitHost, function (emitFileNames, sourceFiles, isBundledEmit) { + ts.forEachExpectedEmitFile(emitHost, function (emitFileNames) { verifyEmitFilePath(emitFileNames.jsFilePath, emitFilesSeen_1); verifyEmitFilePath(emitFileNames.declarationFilePath, emitFilesSeen_1); }); @@ -59261,12 +59976,12 @@ var ts; var emitFilePath = ts.toPath(emitFileName, currentDirectory, getCanonicalFileName); // Report error if the output overwrites input file if (filesByName.contains(emitFilePath)) { - createEmitBlockingDiagnostics(emitFileName, emitFilePath, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file); + createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file); } // Report error if multiple files write into same file if (emitFilesSeen.contains(emitFilePath)) { // Already seen the same emit file - report error - createEmitBlockingDiagnostics(emitFileName, emitFilePath, ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files); + createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files); } else { emitFilesSeen.set(emitFilePath, true); @@ -59274,7 +59989,7 @@ var ts; } } } - function createEmitBlockingDiagnostics(emitFileName, emitFilePath, message) { + function createEmitBlockingDiagnostics(emitFileName, message) { hasEmitBlockingDiagnostics.set(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName), true); programDiagnostics.add(ts.createCompilerDiagnostic(message, emitFileName)); } @@ -59294,24 +60009,24 @@ var ts; ts.optionDeclarations = [ { name: "charset", - type: "string" + type: "string", }, ts.compileOnSaveCommandLineOption, { name: "declaration", shortName: "d", type: "boolean", - description: ts.Diagnostics.Generates_corresponding_d_ts_file + description: ts.Diagnostics.Generates_corresponding_d_ts_file, }, { name: "declarationDir", type: "string", isFilePath: true, - paramType: ts.Diagnostics.DIRECTORY + paramType: ts.Diagnostics.DIRECTORY, }, { name: "diagnostics", - type: "boolean" + type: "boolean", }, { name: "extendedDiagnostics", @@ -59326,7 +60041,7 @@ var ts; name: "help", shortName: "h", type: "boolean", - description: ts.Diagnostics.Print_this_message + description: ts.Diagnostics.Print_this_message, }, { name: "help", @@ -59336,15 +60051,15 @@ var ts; { name: "init", type: "boolean", - description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file + description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file, }, { name: "inlineSourceMap", - type: "boolean" + type: "boolean", }, { name: "inlineSources", - type: "boolean" + type: "boolean", }, { name: "jsx", @@ -59353,7 +60068,7 @@ var ts; "react": 2 /* React */ }), paramType: ts.Diagnostics.KIND, - description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react + description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, }, { name: "reactNamespace", @@ -59362,18 +60077,18 @@ var ts; }, { name: "listFiles", - type: "boolean" + type: "boolean", }, { name: "locale", - type: "string" + type: "string", }, { name: "mapRoot", type: "string", isFilePath: true, description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, - paramType: ts.Diagnostics.LOCATION + paramType: ts.Diagnostics.LOCATION, }, { name: "module", @@ -59384,11 +60099,11 @@ var ts; "amd": ts.ModuleKind.AMD, "system": ts.ModuleKind.System, "umd": ts.ModuleKind.UMD, - "es6": ts.ModuleKind.ES6, - "es2015": ts.ModuleKind.ES2015 + "es6": ts.ModuleKind.ES2015, + "es2015": ts.ModuleKind.ES2015, }), description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, - paramType: ts.Diagnostics.KIND + paramType: ts.Diagnostics.KIND, }, { name: "newLine", @@ -59397,12 +60112,12 @@ var ts; "lf": 1 /* LineFeed */ }), description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, - paramType: ts.Diagnostics.NEWLINE + paramType: ts.Diagnostics.NEWLINE, }, { name: "noEmit", type: "boolean", - description: ts.Diagnostics.Do_not_emit_outputs + description: ts.Diagnostics.Do_not_emit_outputs, }, { name: "noEmitHelpers", @@ -59411,7 +60126,7 @@ var ts; { name: "noEmitOnError", type: "boolean", - description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported + description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, }, { name: "noErrorTruncation", @@ -59420,60 +60135,60 @@ var ts; { name: "noImplicitAny", type: "boolean", - description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type + description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type, }, { name: "noImplicitThis", type: "boolean", - description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type + description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, }, { name: "noUnusedLocals", type: "boolean", - description: ts.Diagnostics.Report_errors_on_unused_locals + description: ts.Diagnostics.Report_errors_on_unused_locals, }, { name: "noUnusedParameters", type: "boolean", - description: ts.Diagnostics.Report_errors_on_unused_parameters + description: ts.Diagnostics.Report_errors_on_unused_parameters, }, { name: "noLib", - type: "boolean" + type: "boolean", }, { name: "noResolve", - type: "boolean" + type: "boolean", }, { name: "skipDefaultLibCheck", - type: "boolean" + type: "boolean", }, { name: "skipLibCheck", type: "boolean", - description: ts.Diagnostics.Skip_type_checking_of_declaration_files + description: ts.Diagnostics.Skip_type_checking_of_declaration_files, }, { name: "out", type: "string", isFilePath: false, // for correct behaviour, please use outFile - paramType: ts.Diagnostics.FILE + paramType: ts.Diagnostics.FILE, }, { name: "outFile", type: "string", isFilePath: true, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, - paramType: ts.Diagnostics.FILE + paramType: ts.Diagnostics.FILE, }, { name: "outDir", type: "string", isFilePath: true, description: ts.Diagnostics.Redirect_output_structure_to_the_directory, - paramType: ts.Diagnostics.DIRECTORY + paramType: ts.Diagnostics.DIRECTORY, }, { name: "preserveConstEnums", @@ -59496,30 +60211,30 @@ var ts; { name: "removeComments", type: "boolean", - description: ts.Diagnostics.Do_not_emit_comments_to_output + description: ts.Diagnostics.Do_not_emit_comments_to_output, }, { name: "rootDir", type: "string", isFilePath: true, paramType: ts.Diagnostics.LOCATION, - description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir + description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, }, { name: "isolatedModules", - type: "boolean" + type: "boolean", }, { name: "sourceMap", type: "boolean", - description: ts.Diagnostics.Generates_corresponding_map_file + description: ts.Diagnostics.Generates_corresponding_map_file, }, { name: "sourceRoot", type: "string", isFilePath: true, description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, - paramType: ts.Diagnostics.LOCATION + paramType: ts.Diagnostics.LOCATION, }, { name: "suppressExcessPropertyErrors", @@ -59530,7 +60245,7 @@ var ts; { name: "suppressImplicitAnyIndexErrors", type: "boolean", - description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures + description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, }, { name: "stripInternal", @@ -59544,23 +60259,25 @@ var ts; type: ts.createMap({ "es3": 0 /* ES3 */, "es5": 1 /* ES5 */, - "es6": 2 /* ES6 */, - "es2015": 2 /* ES2015 */ + "es6": 2 /* ES2015 */, + "es2015": 2 /* ES2015 */, + "es2016": 3 /* ES2016 */, + "es2017": 4 /* ES2017 */, }), description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015, - paramType: ts.Diagnostics.VERSION + paramType: ts.Diagnostics.VERSION, }, { name: "version", shortName: "v", type: "boolean", - description: ts.Diagnostics.Print_the_compiler_s_version + description: ts.Diagnostics.Print_the_compiler_s_version, }, { name: "watch", shortName: "w", type: "boolean", - description: ts.Diagnostics.Watch_input_files + description: ts.Diagnostics.Watch_input_files, }, { name: "experimentalDecorators", @@ -59577,10 +60294,10 @@ var ts; name: "moduleResolution", type: ts.createMap({ "node": ts.ModuleResolutionKind.NodeJs, - "classic": ts.ModuleResolutionKind.Classic + "classic": ts.ModuleResolutionKind.Classic, }), description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, - paramType: ts.Diagnostics.STRATEGY + paramType: ts.Diagnostics.STRATEGY, }, { name: "allowUnusedLabels", @@ -59710,7 +60427,7 @@ var ts; "es2016.array.include": "lib.es2016.array.include.d.ts", "es2017.object": "lib.es2017.object.d.ts", "es2017.sharedmemory": "lib.es2017.sharedmemory.d.ts" - }) + }), }, description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon }, @@ -59738,7 +60455,7 @@ var ts; ts.typingOptionDeclarations = [ { name: "enableAutoDiscovery", - type: "boolean" + type: "boolean", }, { name: "include", @@ -59762,7 +60479,7 @@ var ts; module: ts.ModuleKind.CommonJS, target: 1 /* ES5 */, noImplicitAny: false, - sourceMap: false + sourceMap: false, }; var optionNameMapCache; /* @internal */ @@ -59784,10 +60501,7 @@ var ts; ts.getOptionNameMap = getOptionNameMap; /* @internal */ function createCompilerDiagnosticForInvalidCustomType(opt) { - var namesOfType = []; - for (var key in opt.type) { - namesOfType.push(" '" + key + "'"); - } + var namesOfType = Object.keys(opt.type).map(function (key) { return "'" + key + "'"; }).join(", "); return ts.createCompilerDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); } ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; @@ -60592,7 +61306,7 @@ var ts; StringScriptSnapshot.prototype.getLength = function () { return this.text.length; }; - StringScriptSnapshot.prototype.getChangeRange = function (oldSnapshot) { + StringScriptSnapshot.prototype.getChangeRange = function () { // Text-based snapshots do not support incremental parsing. Return undefined // to signal that to the caller. return undefined; @@ -60814,7 +61528,7 @@ var ts; /* @internal */ var ts; (function (ts) { - ts.scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ true); + ts.scanner = ts.createScanner(4 /* Latest */, /*skipTrivia*/ true); ts.emptyArray = []; (function (SemanticMeaning) { SemanticMeaning[SemanticMeaning["None"] = 0] = "None"; @@ -60826,33 +61540,33 @@ var ts; var SemanticMeaning = ts.SemanticMeaning; function getMeaningFromDeclaration(node) { switch (node.kind) { - case 142 /* Parameter */: - case 218 /* VariableDeclaration */: - case 169 /* BindingElement */: - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 143 /* Parameter */: + case 219 /* VariableDeclaration */: + case 170 /* BindingElement */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: case 253 /* PropertyAssignment */: case 254 /* ShorthandPropertyAssignment */: case 255 /* EnumMember */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: case 252 /* CatchClause */: return 1 /* Value */; - case 141 /* TypeParameter */: - case 222 /* InterfaceDeclaration */: - case 223 /* TypeAliasDeclaration */: - case 159 /* TypeLiteral */: + case 142 /* TypeParameter */: + case 223 /* InterfaceDeclaration */: + case 224 /* TypeAliasDeclaration */: + case 160 /* TypeLiteral */: return 2 /* Type */; - case 221 /* ClassDeclaration */: - case 224 /* EnumDeclaration */: + case 222 /* ClassDeclaration */: + case 225 /* EnumDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -60862,12 +61576,12 @@ var ts; else { return 4 /* Namespace */; } - case 233 /* NamedImports */: - case 234 /* ImportSpecifier */: - case 229 /* ImportEqualsDeclaration */: - case 230 /* ImportDeclaration */: - case 235 /* ExportAssignment */: - case 236 /* ExportDeclaration */: + case 234 /* NamedImports */: + case 235 /* ImportSpecifier */: + case 230 /* ImportEqualsDeclaration */: + case 231 /* ImportDeclaration */: + case 236 /* ExportAssignment */: + case 237 /* ExportDeclaration */: return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; // An external module can be a Value case 256 /* SourceFile */: @@ -60877,7 +61591,7 @@ var ts; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.parent.kind === 235 /* ExportAssignment */) { + if (node.parent.kind === 236 /* ExportAssignment */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } else if (isInRightSideOfImport(node)) { @@ -60898,19 +61612,19 @@ var ts; } ts.getMeaningFromLocation = getMeaningFromLocation; function getMeaningFromRightHandSideOfImportEquals(node) { - ts.Debug.assert(node.kind === 69 /* Identifier */); + ts.Debug.assert(node.kind === 70 /* Identifier */); // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (node.parent.kind === 139 /* QualifiedName */ && + if (node.parent.kind === 140 /* QualifiedName */ && node.parent.right === node && - node.parent.parent.kind === 229 /* ImportEqualsDeclaration */) { + node.parent.parent.kind === 230 /* ImportEqualsDeclaration */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } return 4 /* Namespace */; } function isInRightSideOfImport(node) { - while (node.parent.kind === 139 /* QualifiedName */) { + while (node.parent.kind === 140 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -60921,27 +61635,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 139 /* QualifiedName */) { - while (root.parent && root.parent.kind === 139 /* QualifiedName */) { + if (root.parent.kind === 140 /* QualifiedName */) { + while (root.parent && root.parent.kind === 140 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 155 /* TypeReference */ && !isLastClause; + return root.parent.kind === 156 /* TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 172 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 172 /* PropertyAccessExpression */) { + if (root.parent.kind === 173 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 173 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 194 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 251 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 195 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 251 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 221 /* ClassDeclaration */ && root.parent.parent.token === 106 /* ImplementsKeyword */) || - (decl.kind === 222 /* InterfaceDeclaration */ && root.parent.parent.token === 83 /* ExtendsKeyword */); + return (decl.kind === 222 /* ClassDeclaration */ && root.parent.parent.token === 107 /* ImplementsKeyword */) || + (decl.kind === 223 /* InterfaceDeclaration */ && root.parent.parent.token === 84 /* ExtendsKeyword */); } return false; } @@ -60949,17 +61663,17 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 155 /* TypeReference */ || - (node.parent.kind === 194 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || - (node.kind === 97 /* ThisKeyword */ && !ts.isPartOfExpression(node)) || - node.kind === 165 /* ThisType */; + return node.parent.kind === 156 /* TypeReference */ || + (node.parent.kind === 195 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || + (node.kind === 98 /* ThisKeyword */ && !ts.isPartOfExpression(node)) || + node.kind === 166 /* ThisType */; } function isCallExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 174 /* CallExpression */); + return isCallOrNewExpressionTarget(node, 175 /* CallExpression */); } ts.isCallExpressionTarget = isCallExpressionTarget; function isNewExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 175 /* NewExpression */); + return isCallOrNewExpressionTarget(node, 176 /* NewExpression */); } ts.isNewExpressionTarget = isNewExpressionTarget; function isCallOrNewExpressionTarget(node, kind) { @@ -60972,7 +61686,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 214 /* LabeledStatement */ && referenceNode.label.text === labelName) { + if (referenceNode.kind === 215 /* LabeledStatement */ && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -60981,14 +61695,14 @@ var ts; } ts.getTargetLabel = getTargetLabel; function isJumpStatementTarget(node) { - return node.kind === 69 /* Identifier */ && - (node.parent.kind === 210 /* BreakStatement */ || node.parent.kind === 209 /* ContinueStatement */) && + return node.kind === 70 /* Identifier */ && + (node.parent.kind === 211 /* BreakStatement */ || node.parent.kind === 210 /* ContinueStatement */) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { - return node.kind === 69 /* Identifier */ && - node.parent.kind === 214 /* LabeledStatement */ && + return node.kind === 70 /* Identifier */ && + node.parent.kind === 215 /* LabeledStatement */ && node.parent.label === node; } function isLabelName(node) { @@ -60996,38 +61710,38 @@ var ts; } ts.isLabelName = isLabelName; function isRightSideOfQualifiedName(node) { - return node.parent.kind === 139 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 140 /* QualifiedName */ && node.parent.right === node; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 172 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 173 /* PropertyAccessExpression */ && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 225 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 226 /* ModuleDeclaration */ && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { - return node.kind === 69 /* Identifier */ && + return node.kind === 70 /* Identifier */ && ts.isFunctionLike(node.parent) && node.parent.name === node; } ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { switch (node.parent.kind) { - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: case 253 /* PropertyAssignment */: case 255 /* EnumMember */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 225 /* ModuleDeclaration */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 226 /* ModuleDeclaration */: return node.parent.name === node; - case 173 /* ElementAccessExpression */: + case 174 /* ElementAccessExpression */: return node.parent.argumentExpression === node; - case 140 /* ComputedPropertyName */: + case 141 /* ComputedPropertyName */: return true; } } @@ -61077,16 +61791,16 @@ var ts; } switch (node.kind) { case 256 /* SourceFile */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 221 /* ClassDeclaration */: - case 222 /* InterfaceDeclaration */: - case 224 /* EnumDeclaration */: - case 225 /* ModuleDeclaration */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 222 /* ClassDeclaration */: + case 223 /* InterfaceDeclaration */: + case 225 /* EnumDeclaration */: + case 226 /* ModuleDeclaration */: return node; } } @@ -61096,42 +61810,42 @@ var ts; switch (node.kind) { case 256 /* SourceFile */: return ts.isExternalModule(node) ? ts.ScriptElementKind.moduleElement : ts.ScriptElementKind.scriptElement; - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: return ts.ScriptElementKind.moduleElement; - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: return ts.ScriptElementKind.classElement; - case 222 /* InterfaceDeclaration */: return ts.ScriptElementKind.interfaceElement; - case 223 /* TypeAliasDeclaration */: return ts.ScriptElementKind.typeElement; - case 224 /* EnumDeclaration */: return ts.ScriptElementKind.enumElement; - case 218 /* VariableDeclaration */: + case 223 /* InterfaceDeclaration */: return ts.ScriptElementKind.interfaceElement; + case 224 /* TypeAliasDeclaration */: return ts.ScriptElementKind.typeElement; + case 225 /* EnumDeclaration */: return ts.ScriptElementKind.enumElement; + case 219 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 169 /* BindingElement */: + case 170 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 180 /* ArrowFunction */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: return ts.ScriptElementKind.functionElement; - case 149 /* GetAccessor */: return ts.ScriptElementKind.memberGetAccessorElement; - case 150 /* SetAccessor */: return ts.ScriptElementKind.memberSetAccessorElement; - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 150 /* GetAccessor */: return ts.ScriptElementKind.memberGetAccessorElement; + case 151 /* SetAccessor */: return ts.ScriptElementKind.memberSetAccessorElement; + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: return ts.ScriptElementKind.memberFunctionElement; - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: return ts.ScriptElementKind.memberVariableElement; - case 153 /* IndexSignature */: return ts.ScriptElementKind.indexSignatureElement; - case 152 /* ConstructSignature */: return ts.ScriptElementKind.constructSignatureElement; - case 151 /* CallSignature */: return ts.ScriptElementKind.callSignatureElement; - case 148 /* Constructor */: return ts.ScriptElementKind.constructorImplementationElement; - case 141 /* TypeParameter */: return ts.ScriptElementKind.typeParameterElement; + case 154 /* IndexSignature */: return ts.ScriptElementKind.indexSignatureElement; + case 153 /* ConstructSignature */: return ts.ScriptElementKind.constructSignatureElement; + case 152 /* CallSignature */: return ts.ScriptElementKind.callSignatureElement; + case 149 /* Constructor */: return ts.ScriptElementKind.constructorImplementationElement; + case 142 /* TypeParameter */: return ts.ScriptElementKind.typeParameterElement; case 255 /* EnumMember */: return ts.ScriptElementKind.enumMemberElement; - case 142 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; - case 229 /* ImportEqualsDeclaration */: - case 234 /* ImportSpecifier */: - case 231 /* ImportClause */: - case 238 /* ExportSpecifier */: - case 232 /* NamespaceImport */: + case 143 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; + case 230 /* ImportEqualsDeclaration */: + case 235 /* ImportSpecifier */: + case 232 /* ImportClause */: + case 239 /* ExportSpecifier */: + case 233 /* NamespaceImport */: return ts.ScriptElementKind.alias; case 279 /* JSDocTypedefTag */: return ts.ScriptElementKind.typeElement; @@ -61148,7 +61862,7 @@ var ts; } ts.getNodeKind = getNodeKind; function getStringLiteralTypeForNode(node, typeChecker) { - var searchNode = node.parent.kind === 166 /* LiteralType */ ? node.parent : node; + var searchNode = node.parent.kind === 167 /* LiteralType */ ? node.parent : node; var type = typeChecker.getTypeAtLocation(searchNode); if (type && type.flags & 32 /* StringLiteral */) { return type; @@ -61158,12 +61872,12 @@ var ts; ts.getStringLiteralTypeForNode = getStringLiteralTypeForNode; function isThis(node) { switch (node.kind) { - case 97 /* ThisKeyword */: + case 98 /* ThisKeyword */: // case SyntaxKind.ThisType: TODO: GH#9267 return true; - case 69 /* Identifier */: + case 70 /* Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 142 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 143 /* Parameter */; default: return false; } @@ -61208,42 +61922,42 @@ var ts; return false; } switch (n.kind) { - case 221 /* ClassDeclaration */: - case 222 /* InterfaceDeclaration */: - case 224 /* EnumDeclaration */: - case 171 /* ObjectLiteralExpression */: - case 167 /* ObjectBindingPattern */: - case 159 /* TypeLiteral */: - case 199 /* Block */: - case 226 /* ModuleBlock */: - case 227 /* CaseBlock */: - case 233 /* NamedImports */: - case 237 /* NamedExports */: - return nodeEndsWith(n, 16 /* CloseBraceToken */, sourceFile); + case 222 /* ClassDeclaration */: + case 223 /* InterfaceDeclaration */: + case 225 /* EnumDeclaration */: + case 172 /* ObjectLiteralExpression */: + case 168 /* ObjectBindingPattern */: + case 160 /* TypeLiteral */: + case 200 /* Block */: + case 227 /* ModuleBlock */: + case 228 /* CaseBlock */: + case 234 /* NamedImports */: + case 238 /* NamedExports */: + return nodeEndsWith(n, 17 /* CloseBraceToken */, sourceFile); case 252 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 175 /* NewExpression */: + case 176 /* NewExpression */: if (!n.arguments) { return true; } // fall through - case 174 /* CallExpression */: - case 178 /* ParenthesizedExpression */: - case 164 /* ParenthesizedType */: - return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile); - case 156 /* FunctionType */: - case 157 /* ConstructorType */: + case 175 /* CallExpression */: + case 179 /* ParenthesizedExpression */: + case 165 /* ParenthesizedType */: + return nodeEndsWith(n, 19 /* CloseParenToken */, sourceFile); + case 157 /* FunctionType */: + case 158 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 152 /* ConstructSignature */: - case 151 /* CallSignature */: - case 180 /* ArrowFunction */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 153 /* ConstructSignature */: + case 152 /* CallSignature */: + case 181 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -61252,68 +61966,68 @@ 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 225 /* ModuleDeclaration */: + return hasChildOfKind(n, 19 /* CloseParenToken */, sourceFile); + case 226 /* ModuleDeclaration */: return n.body && isCompletedNode(n.body, sourceFile); - case 203 /* IfStatement */: + case 204 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 202 /* ExpressionStatement */: + case 203 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || - hasChildOfKind(n, 23 /* SemicolonToken */); - case 170 /* ArrayLiteralExpression */: - case 168 /* ArrayBindingPattern */: - case 173 /* ElementAccessExpression */: - case 140 /* ComputedPropertyName */: - case 161 /* TupleType */: - return nodeEndsWith(n, 20 /* CloseBracketToken */, sourceFile); - case 153 /* IndexSignature */: + hasChildOfKind(n, 24 /* SemicolonToken */); + case 171 /* ArrayLiteralExpression */: + case 169 /* ArrayBindingPattern */: + case 174 /* ElementAccessExpression */: + case 141 /* ComputedPropertyName */: + case 162 /* TupleType */: + return nodeEndsWith(n, 21 /* CloseBracketToken */, sourceFile); + case 154 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } - return hasChildOfKind(n, 20 /* CloseBracketToken */, sourceFile); + return hasChildOfKind(n, 21 /* CloseBracketToken */, sourceFile); case 249 /* CaseClause */: case 250 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: - case 205 /* WhileStatement */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: + case 206 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 204 /* DoStatement */: + case 205 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; - var hasWhileKeyword = findChildOfKind(n, 104 /* WhileKeyword */, sourceFile); + var hasWhileKeyword = findChildOfKind(n, 105 /* WhileKeyword */, sourceFile); if (hasWhileKeyword) { - return nodeEndsWith(n, 18 /* CloseParenToken */, sourceFile); + return nodeEndsWith(n, 19 /* CloseParenToken */, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 158 /* TypeQuery */: + case 159 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 182 /* TypeOfExpression */: - case 181 /* DeleteExpression */: - case 183 /* VoidExpression */: - case 190 /* YieldExpression */: - case 191 /* SpreadElementExpression */: + case 183 /* TypeOfExpression */: + case 182 /* DeleteExpression */: + case 184 /* VoidExpression */: + case 191 /* YieldExpression */: + case 192 /* SpreadElementExpression */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 176 /* TaggedTemplateExpression */: + case 177 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 189 /* TemplateExpression */: + case 190 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 197 /* TemplateSpan */: + case 198 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 236 /* ExportDeclaration */: - case 230 /* ImportDeclaration */: + case 237 /* ExportDeclaration */: + case 231 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 185 /* PrefixUnaryExpression */: + case 186 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 187 /* BinaryExpression */: + case 188 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 188 /* ConditionalExpression */: + case 189 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -61331,7 +62045,7 @@ var ts; if (last.kind === expectedLastToken) { return true; } - else if (last.kind === 23 /* SemicolonToken */ && children.length !== 1) { + else if (last.kind === 24 /* SemicolonToken */ && children.length !== 1) { return children[children.length - 2].kind === expectedLastToken; } } @@ -61504,7 +62218,7 @@ var ts; function findPrecedingToken(position, sourceFile, startNode) { return find(startNode || sourceFile); function findRightmostToken(n) { - if (isToken(n) || n.kind === 244 /* JsxText */) { + if (isToken(n)) { return n; } var children = n.getChildren(); @@ -61512,7 +62226,7 @@ var ts; return candidate && findRightmostToken(candidate); } function find(n) { - if (isToken(n) || n.kind === 244 /* JsxText */) { + if (isToken(n)) { return n; } var children = n.getChildren(); @@ -61526,10 +62240,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 === 244 /* JsxText */)) { + if (position < child.end && (nodeHasTokens(child) || child.kind === 10 /* JsxText */)) { var start = child.getStart(sourceFile); var lookInPreviousChild = (start >= position) || - (child.kind === 244 /* JsxText */ && start === child.end); // whitespace only JsxText + (child.kind === 10 /* 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); @@ -61592,25 +62306,25 @@ var ts; if (!token) { return false; } - if (token.kind === 244 /* JsxText */) { + if (token.kind === 10 /* JsxText */) { return true; } //
Hello |
- if (token.kind === 25 /* LessThanToken */ && token.parent.kind === 244 /* JsxText */) { + if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 10 /* JsxText */) { return true; } //
{ |
or
- if (token.kind === 25 /* LessThanToken */ && token.parent.kind === 248 /* JsxExpression */) { + if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 248 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 16 /* CloseBraceToken */ && token.parent.kind === 248 /* JsxExpression */) { + if (token && token.kind === 17 /* CloseBraceToken */ && token.parent.kind === 248 /* JsxExpression */) { return true; } //
|
- if (token.kind === 25 /* LessThanToken */ && token.parent.kind === 245 /* JsxClosingElement */) { + if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 245 /* JsxClosingElement */) { return true; } return false; @@ -61667,9 +62381,9 @@ var ts; var node = ts.getTokenAtPosition(sourceFile, position); if (isToken(node)) { switch (node.kind) { - case 102 /* VarKeyword */: - case 108 /* LetKeyword */: - case 74 /* ConstKeyword */: + case 103 /* VarKeyword */: + case 109 /* LetKeyword */: + case 75 /* ConstKeyword */: // if the current token is var, let or const, skip the VariableDeclarationList node = node.parent === undefined ? undefined : node.parent.parent; break; @@ -61722,21 +62436,21 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 155 /* TypeReference */ || node.kind === 174 /* CallExpression */) { + if (node.kind === 156 /* TypeReference */ || node.kind === 175 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 221 /* ClassDeclaration */ || node.kind === 222 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 222 /* ClassDeclaration */ || node.kind === 223 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 138 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 139 /* LastToken */; } ts.isToken = isToken; function isWord(kind) { - return kind === 69 /* Identifier */ || ts.isKeyword(kind); + return kind === 70 /* Identifier */ || ts.isKeyword(kind); } ts.isWord = isWord; function isPropertyName(kind) { @@ -61748,7 +62462,7 @@ var ts; ts.isComment = isComment; function isStringOrRegularExpressionOrTemplateLiteral(kind) { if (kind === 9 /* StringLiteral */ - || kind === 10 /* RegularExpressionLiteral */ + || kind === 11 /* RegularExpressionLiteral */ || ts.isTemplateLiteralKind(kind)) { return true; } @@ -61756,7 +62470,7 @@ var ts; } ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; function isPunctuation(kind) { - return 15 /* FirstPunctuation */ <= kind && kind <= 68 /* LastPunctuation */; + return 16 /* FirstPunctuation */ <= kind && kind <= 69 /* LastPunctuation */; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position) { @@ -61766,9 +62480,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: + case 113 /* PublicKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: return true; } return false; @@ -61791,18 +62505,18 @@ var ts; } ts.compareDataObjects = compareDataObjects; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 170 /* ArrayLiteralExpression */ || - node.kind === 171 /* ObjectLiteralExpression */) { + if (node.kind === 171 /* ArrayLiteralExpression */ || + node.kind === 172 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 187 /* BinaryExpression */ && + if (node.parent.kind === 188 /* BinaryExpression */ && node.parent.left === node && - node.parent.operatorToken.kind === 56 /* EqualsToken */) { + node.parent.operatorToken.kind === 57 /* EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 208 /* ForOfStatement */ && + if (node.parent.kind === 209 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -61843,7 +62557,7 @@ var ts; /* @internal */ (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 142 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 143 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -61896,7 +62610,7 @@ var ts; } } function symbolPart(text, symbol) { - return displayPart(text, displayPartKind(symbol), symbol); + return displayPart(text, displayPartKind(symbol)); function displayPartKind(symbol) { var flags = symbol.flags; if (flags & 3 /* Variable */) { @@ -61945,7 +62659,7 @@ var ts; } } ts.symbolPart = symbolPart; - function displayPart(text, kind, symbol) { + function displayPart(text, kind) { return { text: text, kind: ts.SymbolDisplayPartKind[kind] @@ -62023,7 +62737,7 @@ var ts; return location.getText(); } else if (ts.isStringOrNumericLiteral(location.kind) && - location.parent.kind === 140 /* ComputedPropertyName */) { + location.parent.kind === 141 /* ComputedPropertyName */) { return location.text; } // Try to get the local symbol if we're dealing with an 'export default' @@ -62035,7 +62749,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 234 /* ImportSpecifier */ || location.parent.kind === 238 /* ExportSpecifier */) && + (location.parent.kind === 235 /* ImportSpecifier */ || location.parent.kind === 239 /* ExportSpecifier */) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -62081,7 +62795,7 @@ var ts; var options = { fileName: "config.js", compilerOptions: { - target: 2 /* ES6 */, + target: 2 /* ES2015 */, removeComments: true }, reportDiagnostics: true @@ -62107,24 +62821,24 @@ var ts; (function (ts) { /// Classifier function createClassifier() { - var scanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false); + var scanner = ts.createScanner(4 /* Latest */, /*skipTrivia*/ false); /// We do not have a full parser support to know when we should parse a regex or not /// If we consider every slash token to be a regex, we could be missing cases like "1/2/3", where /// 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[69 /* Identifier */] = true; + noRegexTable[70 /* Identifier */] = true; noRegexTable[9 /* StringLiteral */] = true; noRegexTable[8 /* NumericLiteral */] = true; - noRegexTable[10 /* RegularExpressionLiteral */] = 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[99 /* TrueKeyword */] = true; - noRegexTable[84 /* FalseKeyword */] = true; + noRegexTable[11 /* RegularExpressionLiteral */] = true; + noRegexTable[98 /* ThisKeyword */] = true; + noRegexTable[42 /* PlusPlusToken */] = true; + noRegexTable[43 /* MinusMinusToken */] = true; + noRegexTable[19 /* CloseParenToken */] = true; + noRegexTable[21 /* CloseBracketToken */] = true; + noRegexTable[17 /* CloseBraceToken */] = true; + noRegexTable[100 /* TrueKeyword */] = true; + noRegexTable[85 /* 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 @@ -62149,10 +62863,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 === 123 /* GetKeyword */ || - keyword2 === 131 /* SetKeyword */ || - keyword2 === 121 /* ConstructorKeyword */ || - keyword2 === 113 /* StaticKeyword */) { + if (keyword2 === 124 /* GetKeyword */ || + keyword2 === 132 /* SetKeyword */ || + keyword2 === 122 /* ConstructorKeyword */ || + keyword2 === 114 /* StaticKeyword */) { // Allow things like "public get", "public constructor" and "public static". // These are all legal. return true; @@ -62251,7 +62965,7 @@ var ts; offset = 2; // fallthrough case 6 /* InTemplateSubstitutionPosition */: - templateStack.push(12 /* TemplateHead */); + templateStack.push(13 /* TemplateHead */); break; } scanner.setText(text); @@ -62282,71 +62996,71 @@ var ts; do { token = scanner.scan(); if (!ts.isTrivia(token)) { - if ((token === 39 /* SlashToken */ || token === 61 /* SlashEqualsToken */) && !noRegexTable[lastNonTriviaToken]) { - if (scanner.reScanSlashToken() === 10 /* RegularExpressionLiteral */) { - token = 10 /* RegularExpressionLiteral */; + if ((token === 40 /* SlashToken */ || token === 62 /* SlashEqualsToken */) && !noRegexTable[lastNonTriviaToken]) { + if (scanner.reScanSlashToken() === 11 /* RegularExpressionLiteral */) { + token = 11 /* RegularExpressionLiteral */; } } - else if (lastNonTriviaToken === 21 /* DotToken */ && isKeyword(token)) { - token = 69 /* Identifier */; + else if (lastNonTriviaToken === 22 /* DotToken */ && isKeyword(token)) { + token = 70 /* 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 = 69 /* Identifier */; + token = 70 /* Identifier */; } - else if (lastNonTriviaToken === 69 /* Identifier */ && - token === 25 /* LessThanToken */) { + else if (lastNonTriviaToken === 70 /* Identifier */ && + token === 26 /* 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. angleBracketStack++; } - else if (token === 27 /* GreaterThanToken */ && angleBracketStack > 0) { + else if (token === 28 /* GreaterThanToken */ && angleBracketStack > 0) { // If we think we're currently in something generic, then mark that that // generic entity is complete. angleBracketStack--; } - else if (token === 117 /* AnyKeyword */ || - token === 132 /* StringKeyword */ || - token === 130 /* NumberKeyword */ || - token === 120 /* BooleanKeyword */ || - token === 133 /* SymbolKeyword */) { + else if (token === 118 /* AnyKeyword */ || + token === 133 /* StringKeyword */ || + token === 131 /* NumberKeyword */ || + token === 121 /* BooleanKeyword */ || + token === 134 /* 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 = 69 /* Identifier */; + token = 70 /* Identifier */; } } - else if (token === 12 /* TemplateHead */) { + else if (token === 13 /* TemplateHead */) { templateStack.push(token); } - else if (token === 15 /* OpenBraceToken */) { + else if (token === 16 /* OpenBraceToken */) { // If we don't have anything on the template stack, // then we aren't trying to keep track of a previously scanned template head. if (templateStack.length > 0) { templateStack.push(token); } } - else if (token === 16 /* CloseBraceToken */) { + else if (token === 17 /* CloseBraceToken */) { // If we don't have anything on the template stack, // then we aren't trying to keep track of a previously scanned template head. if (templateStack.length > 0) { var lastTemplateStackToken = ts.lastOrUndefined(templateStack); - if (lastTemplateStackToken === 12 /* TemplateHead */) { + if (lastTemplateStackToken === 13 /* TemplateHead */) { token = scanner.reScanTemplateToken(); // Only pop on a TemplateTail; a TemplateMiddle indicates there is more for us. - if (token === 14 /* TemplateTail */) { + if (token === 15 /* TemplateTail */) { templateStack.pop(); } else { - ts.Debug.assert(token === 13 /* TemplateMiddle */, "Should have been a template middle. Was " + token); + ts.Debug.assert(token === 14 /* TemplateMiddle */, "Should have been a template middle. Was " + token); } } else { - ts.Debug.assert(lastTemplateStackToken === 15 /* OpenBraceToken */, "Should have been an open brace. Was: " + token); + ts.Debug.assert(lastTemplateStackToken === 16 /* OpenBraceToken */, "Should have been an open brace. Was: " + token); templateStack.pop(); } } @@ -62387,10 +63101,10 @@ var ts; } else if (ts.isTemplateLiteralKind(token)) { if (scanner.isUnterminated()) { - if (token === 14 /* TemplateTail */) { + if (token === 15 /* TemplateTail */) { result.endOfLineState = 5 /* InTemplateMiddleOrTail */; } - else if (token === 11 /* NoSubstitutionTemplateLiteral */) { + else if (token === 12 /* NoSubstitutionTemplateLiteral */) { result.endOfLineState = 4 /* InTemplateHeadOrNoSubstitutionTemplate */; } else { @@ -62398,7 +63112,7 @@ var ts; } } } - else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 12 /* TemplateHead */) { + else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 13 /* TemplateHead */) { result.endOfLineState = 6 /* InTemplateSubstitutionPosition */; } } @@ -62428,43 +63142,43 @@ var ts; } function isBinaryExpressionOperatorToken(token) { switch (token) { - case 37 /* AsteriskToken */: - case 39 /* SlashToken */: - case 40 /* PercentToken */: - case 35 /* PlusToken */: - case 36 /* MinusToken */: - case 43 /* LessThanLessThanToken */: - case 44 /* GreaterThanGreaterThanToken */: - case 45 /* GreaterThanGreaterThanGreaterThanToken */: - case 25 /* LessThanToken */: - case 27 /* GreaterThanToken */: - case 28 /* LessThanEqualsToken */: - case 29 /* GreaterThanEqualsToken */: - case 91 /* InstanceOfKeyword */: - case 90 /* InKeyword */: - case 116 /* AsKeyword */: - case 30 /* EqualsEqualsToken */: - case 31 /* ExclamationEqualsToken */: - case 32 /* EqualsEqualsEqualsToken */: - case 33 /* ExclamationEqualsEqualsToken */: - 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 */: + case 38 /* AsteriskToken */: + case 40 /* SlashToken */: + case 41 /* PercentToken */: + case 36 /* PlusToken */: + case 37 /* MinusToken */: + case 44 /* LessThanLessThanToken */: + case 45 /* GreaterThanGreaterThanToken */: + case 46 /* GreaterThanGreaterThanGreaterThanToken */: + case 26 /* LessThanToken */: + case 28 /* GreaterThanToken */: + case 29 /* LessThanEqualsToken */: + case 30 /* GreaterThanEqualsToken */: + case 92 /* InstanceOfKeyword */: + case 91 /* InKeyword */: + case 117 /* AsKeyword */: + case 31 /* EqualsEqualsToken */: + case 32 /* ExclamationEqualsToken */: + case 33 /* EqualsEqualsEqualsToken */: + case 34 /* ExclamationEqualsEqualsToken */: + case 47 /* AmpersandToken */: + case 49 /* CaretToken */: + case 48 /* BarToken */: + case 52 /* AmpersandAmpersandToken */: + case 53 /* BarBarToken */: + case 68 /* BarEqualsToken */: + case 67 /* AmpersandEqualsToken */: + case 69 /* CaretEqualsToken */: + case 64 /* LessThanLessThanEqualsToken */: + case 65 /* GreaterThanGreaterThanEqualsToken */: + case 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 58 /* PlusEqualsToken */: + case 59 /* MinusEqualsToken */: + case 60 /* AsteriskEqualsToken */: + case 62 /* SlashEqualsToken */: + case 63 /* PercentEqualsToken */: + case 57 /* EqualsToken */: + case 25 /* CommaToken */: return true; default: return false; @@ -62472,19 +63186,19 @@ var ts; } function isPrefixUnaryExpressionOperatorToken(token) { switch (token) { - case 35 /* PlusToken */: - case 36 /* MinusToken */: - case 50 /* TildeToken */: - case 49 /* ExclamationToken */: - case 41 /* PlusPlusToken */: - case 42 /* MinusMinusToken */: + case 36 /* PlusToken */: + case 37 /* MinusToken */: + case 51 /* TildeToken */: + case 50 /* ExclamationToken */: + case 42 /* PlusPlusToken */: + case 43 /* MinusMinusToken */: return true; default: return false; } } function isKeyword(token) { - return token >= 70 /* FirstKeyword */ && token <= 138 /* LastKeyword */; + return token >= 71 /* FirstKeyword */ && token <= 139 /* LastKeyword */; } function classFromKind(token) { if (isKeyword(token)) { @@ -62493,7 +63207,7 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5 /* operator */; } - else if (token >= 15 /* FirstPunctuation */ && token <= 68 /* LastPunctuation */) { + else if (token >= 16 /* FirstPunctuation */ && token <= 69 /* LastPunctuation */) { return 10 /* punctuation */; } switch (token) { @@ -62501,7 +63215,7 @@ var ts; return 4 /* numericLiteral */; case 9 /* StringLiteral */: return 6 /* stringLiteral */; - case 10 /* RegularExpressionLiteral */: + case 11 /* RegularExpressionLiteral */: return 7 /* regularExpressionLiteral */; case 7 /* ConflictMarkerTrivia */: case 3 /* MultiLineCommentTrivia */: @@ -62510,7 +63224,7 @@ var ts; case 5 /* WhitespaceTrivia */: case 4 /* NewLineTrivia */: return 8 /* whiteSpace */; - case 69 /* Identifier */: + case 70 /* Identifier */: default: if (ts.isTemplateLiteralKind(token)) { return 6 /* stringLiteral */; @@ -62541,10 +63255,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 225 /* ModuleDeclaration */: - case 221 /* ClassDeclaration */: - case 222 /* InterfaceDeclaration */: - case 220 /* FunctionDeclaration */: + case 226 /* ModuleDeclaration */: + case 222 /* ClassDeclaration */: + case 223 /* InterfaceDeclaration */: + case 221 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -62595,7 +63309,7 @@ var ts; */ function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 225 /* ModuleDeclaration */ && + return declaration.kind === 226 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; }); } @@ -62605,7 +63319,7 @@ var ts; if (node && ts.textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { var kind = node.kind; checkForClassificationCancellation(cancellationToken, kind); - if (kind === 69 /* Identifier */ && !ts.nodeIsMissing(node)) { + if (kind === 70 /* 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 @@ -62674,8 +63388,8 @@ var ts; var spanStart = span.start; var spanLength = span.length; // Make a scanner we can get trivia from. - var triviaScanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); - var mergeConflictScanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); + var triviaScanner = ts.createScanner(4 /* Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); + var mergeConflictScanner = ts.createScanner(4 /* Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); var result = []; processElement(sourceFile); return { spans: result, endOfLineState: 0 /* None */ }; @@ -62839,10 +63553,10 @@ var ts; return true; } var classifiedElementName = tryClassifyJsxElementName(node); - if (!ts.isToken(node) && node.kind !== 244 /* JsxText */ && classifiedElementName === undefined) { + if (!ts.isToken(node) && node.kind !== 10 /* JsxText */ && classifiedElementName === undefined) { return false; } - var tokenStart = node.kind === 244 /* JsxText */ ? node.pos : classifyLeadingTriviaAndGetTokenStart(node); + var tokenStart = node.kind === 10 /* JsxText */ ? node.pos : classifyLeadingTriviaAndGetTokenStart(node); var tokenWidth = node.end - tokenStart; ts.Debug.assert(tokenWidth >= 0); if (tokenWidth > 0) { @@ -62855,7 +63569,7 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 243 /* JsxOpeningElement */: + case 244 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } @@ -62865,7 +63579,7 @@ var ts; return 20 /* jsxCloseTagName */; } break; - case 242 /* JsxSelfClosingElement */: + case 243 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } @@ -62887,7 +63601,7 @@ var ts; } // Special case < and > If they appear in a generic context they are punctuation, // not operators. - if (tokenKind === 25 /* LessThanToken */ || tokenKind === 27 /* GreaterThanToken */) { + if (tokenKind === 26 /* LessThanToken */ || tokenKind === 28 /* GreaterThanToken */) { // If the node owning the token has a type argument list or type parameter list, then // we can effectively assume that a '<' and '>' belong to those lists. if (token && ts.getTypeArgumentOrTypeParameterList(token.parent)) { @@ -62896,19 +63610,19 @@ var ts; } if (ts.isPunctuation(tokenKind)) { if (token) { - if (tokenKind === 56 /* EqualsToken */) { + if (tokenKind === 57 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (token.parent.kind === 218 /* VariableDeclaration */ || - token.parent.kind === 145 /* PropertyDeclaration */ || - token.parent.kind === 142 /* Parameter */ || + if (token.parent.kind === 219 /* VariableDeclaration */ || + token.parent.kind === 146 /* PropertyDeclaration */ || + token.parent.kind === 143 /* Parameter */ || token.parent.kind === 246 /* JsxAttribute */) { return 5 /* operator */; } } - if (token.parent.kind === 187 /* BinaryExpression */ || - token.parent.kind === 185 /* PrefixUnaryExpression */ || - token.parent.kind === 186 /* PostfixUnaryExpression */ || - token.parent.kind === 188 /* ConditionalExpression */) { + if (token.parent.kind === 188 /* BinaryExpression */ || + token.parent.kind === 186 /* PrefixUnaryExpression */ || + token.parent.kind === 187 /* PostfixUnaryExpression */ || + token.parent.kind === 189 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -62920,7 +63634,7 @@ var ts; else if (tokenKind === 9 /* StringLiteral */) { return token.parent.kind === 246 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } - else if (tokenKind === 10 /* RegularExpressionLiteral */) { + else if (tokenKind === 11 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. return 6 /* stringLiteral */; } @@ -62928,38 +63642,38 @@ var ts; // TODO (drosen): we should *also* get another classification type for these literals. return 6 /* stringLiteral */; } - else if (tokenKind === 244 /* JsxText */) { + else if (tokenKind === 10 /* JsxText */) { return 23 /* jsxText */; } - else if (tokenKind === 69 /* Identifier */) { + else if (tokenKind === 70 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 141 /* TypeParameter */: + case 142 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 222 /* InterfaceDeclaration */: + case 223 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 142 /* Parameter */: + case 143 /* Parameter */: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; } @@ -62989,6 +63703,7 @@ var ts; } ts.getEncodedSyntacticClassifications = getEncodedSyntacticClassifications; })(ts || (ts = {})); +/// /* @internal */ var ts; (function (ts) { @@ -63028,7 +63743,7 @@ var ts; name: tagName.text, kind: undefined, kindModifiers: undefined, - sortText: "0" + sortText: "0", }); } else { @@ -63085,7 +63800,7 @@ var ts; name: displayName, kind: ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location), kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), - sortText: "0" + sortText: "0", }; } function getCompletionEntriesFromSymbols(symbols, entries, location, performCharacterChecks) { @@ -63113,7 +63828,7 @@ var ts; return undefined; } if (node.parent.kind === 253 /* PropertyAssignment */ && - node.parent.parent.kind === 171 /* ObjectLiteralExpression */ && + node.parent.parent.kind === 172 /* ObjectLiteralExpression */ && node.parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { @@ -63138,7 +63853,7 @@ var ts; // a['/*completion position*/'] return getStringLiteralCompletionEntriesFromElementAccess(node.parent); } - else if (node.parent.kind === 230 /* ImportDeclaration */ || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { + else if (node.parent.kind === 231 /* ImportDeclaration */ || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { // Get all known external module names or complete a path to a module // i.e. import * as ns from "/*completion position*/"; // import x = require("/*completion position*/"); @@ -63151,7 +63866,7 @@ var ts; // Get string literal completions from specialized signatures of the target // i.e. declare function f(a: 'A'); // f("/*completion position*/") - return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo, node); + return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo); } // Get completion for string literal from string literal type // i.e. var x: "hi" | "hello" = "/*completion position*/" @@ -63168,7 +63883,7 @@ var ts; } } } - function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo, location) { + function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo) { var candidates = []; var entries = []; typeChecker.getResolvedSignature(argumentInfo.invocation, candidates); @@ -63531,7 +64246,7 @@ var ts; if (typeRoots) { for (var _b = 0, typeRoots_2 = typeRoots; _b < typeRoots_2.length; _b++) { var root = typeRoots_2[_b]; - getCompletionEntriesFromDirectories(host, options, root, span, result); + getCompletionEntriesFromDirectories(host, root, span, result); } } } @@ -63540,12 +64255,12 @@ var ts; for (var _c = 0, _d = findPackageJsons(scriptPath); _c < _d.length; _c++) { var packageJson = _d[_c]; var typesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules/@types"); - getCompletionEntriesFromDirectories(host, options, typesDir, span, result); + getCompletionEntriesFromDirectories(host, typesDir, span, result); } } return result; } - function getCompletionEntriesFromDirectories(host, options, directory, span, result) { + function getCompletionEntriesFromDirectories(host, directory, span, result) { if (host.getDirectories && tryDirectoryExists(host, directory)) { var directories = tryGetDirectories(host, directory); if (directories) { @@ -63769,12 +64484,12 @@ var ts; return undefined; } var parent_17 = contextToken.parent, kind = contextToken.kind; - if (kind === 21 /* DotToken */) { - if (parent_17.kind === 172 /* PropertyAccessExpression */) { + if (kind === 22 /* DotToken */) { + if (parent_17.kind === 173 /* PropertyAccessExpression */) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_17.kind === 139 /* QualifiedName */) { + else if (parent_17.kind === 140 /* QualifiedName */) { node = contextToken.parent.left; isRightOfDot = true; } @@ -63785,11 +64500,11 @@ var ts; } } else if (sourceFile.languageVariant === 1 /* JSX */) { - if (kind === 25 /* LessThanToken */) { + if (kind === 26 /* LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } - else if (kind === 39 /* SlashToken */ && contextToken.parent.kind === 245 /* JsxClosingElement */) { + else if (kind === 40 /* SlashToken */ && contextToken.parent.kind === 245 /* JsxClosingElement */) { isStartingCloseTag = true; location = contextToken; } @@ -63830,7 +64545,6 @@ var ts; if (!tryGetGlobalSymbols()) { return undefined; } - isGlobalCompletion = true; } log("getCompletionData: Semantic work: " + (ts.timestamp() - semanticStart)); return { symbols: symbols, isGlobalCompletion: isGlobalCompletion, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName: isJsDocTagName }; @@ -63839,7 +64553,7 @@ var ts; isGlobalCompletion = false; isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 69 /* Identifier */ || node.kind === 139 /* QualifiedName */ || node.kind === 172 /* PropertyAccessExpression */) { + if (node.kind === 70 /* Identifier */ || node.kind === 140 /* QualifiedName */ || node.kind === 173 /* PropertyAccessExpression */) { var symbol = typeChecker.getSymbolAtLocation(node); // This is an alias, follow what it aliases if (symbol && symbol.flags & 8388608 /* Alias */) { @@ -63895,10 +64609,9 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType = void 0; - if ((jsxContainer.kind === 242 /* JsxSelfClosingElement */) || (jsxContainer.kind === 243 /* JsxOpeningElement */)) { + if ((jsxContainer.kind === 243 /* JsxSelfClosingElement */) || (jsxContainer.kind === 244 /* JsxOpeningElement */)) { // Cursor is inside a JSX self-closing element or opening element attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); - isGlobalCompletion = false; if (attrsType) { symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); isMemberCompletion = true; @@ -63942,6 +64655,13 @@ var ts; previousToken.getStart() : position; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; + if (scopeNode) { + isGlobalCompletion = + scopeNode.kind === 256 /* SourceFile */ || + scopeNode.kind === 190 /* TemplateExpression */ || + scopeNode.kind === 248 /* JsxExpression */ || + ts.isStatement(scopeNode); + } /// TODO filter meaning based on the current context var symbolMeanings = 793064 /* Type */ | 107455 /* Value */ | 1920 /* Namespace */ | 8388608 /* Alias */; symbols = typeChecker.getSymbolsInScope(scopeNode, symbolMeanings); @@ -63968,15 +64688,15 @@ var ts; return result; } function isInJsxText(contextToken) { - if (contextToken.kind === 244 /* JsxText */) { + if (contextToken.kind === 10 /* JsxText */) { return true; } - if (contextToken.kind === 27 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 243 /* JsxOpeningElement */) { + if (contextToken.kind === 28 /* GreaterThanToken */ && contextToken.parent) { + if (contextToken.parent.kind === 244 /* JsxOpeningElement */) { return true; } - if (contextToken.parent.kind === 245 /* JsxClosingElement */ || contextToken.parent.kind === 242 /* JsxSelfClosingElement */) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 241 /* JsxElement */; + if (contextToken.parent.kind === 245 /* JsxClosingElement */ || contextToken.parent.kind === 243 /* JsxSelfClosingElement */) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 242 /* JsxElement */; } } return false; @@ -63985,41 +64705,41 @@ var ts; if (previousToken) { var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { - case 24 /* CommaToken */: - return containingNodeKind === 174 /* CallExpression */ // func( a, | - || containingNodeKind === 148 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 175 /* NewExpression */ // new C(a, | - || containingNodeKind === 170 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 187 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 156 /* FunctionType */; // var x: (s: string, list| - case 17 /* OpenParenToken */: - return containingNodeKind === 174 /* CallExpression */ // func( | - || containingNodeKind === 148 /* Constructor */ // constructor( | - || containingNodeKind === 175 /* NewExpression */ // new C(a| - || containingNodeKind === 178 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 164 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ - case 19 /* OpenBracketToken */: - return containingNodeKind === 170 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 153 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 140 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 125 /* ModuleKeyword */: // module | - case 126 /* NamespaceKeyword */: + case 25 /* CommaToken */: + return containingNodeKind === 175 /* CallExpression */ // func( a, | + || containingNodeKind === 149 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 176 /* NewExpression */ // new C(a, | + || containingNodeKind === 171 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 188 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 157 /* FunctionType */; // var x: (s: string, list| + case 18 /* OpenParenToken */: + return containingNodeKind === 175 /* CallExpression */ // func( | + || containingNodeKind === 149 /* Constructor */ // constructor( | + || containingNodeKind === 176 /* NewExpression */ // new C(a| + || containingNodeKind === 179 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 165 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + case 20 /* OpenBracketToken */: + return containingNodeKind === 171 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 154 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 141 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + case 126 /* ModuleKeyword */: // module | + case 127 /* NamespaceKeyword */: return true; - case 21 /* DotToken */: - return containingNodeKind === 225 /* ModuleDeclaration */; // module A.| - case 15 /* OpenBraceToken */: - return containingNodeKind === 221 /* ClassDeclaration */; // class A{ | - case 56 /* EqualsToken */: - return containingNodeKind === 218 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 187 /* BinaryExpression */; // x = a| - case 12 /* TemplateHead */: - return containingNodeKind === 189 /* TemplateExpression */; // `aa ${| - case 13 /* TemplateMiddle */: - return containingNodeKind === 197 /* TemplateSpan */; // `aa ${10} dd ${| - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - return containingNodeKind === 145 /* PropertyDeclaration */; // class A{ public | + case 22 /* DotToken */: + return containingNodeKind === 226 /* ModuleDeclaration */; // module A.| + case 16 /* OpenBraceToken */: + return containingNodeKind === 222 /* ClassDeclaration */; // class A{ | + case 57 /* EqualsToken */: + return containingNodeKind === 219 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 188 /* BinaryExpression */; // x = a| + case 13 /* TemplateHead */: + return containingNodeKind === 190 /* TemplateExpression */; // `aa ${| + case 14 /* TemplateMiddle */: + return containingNodeKind === 198 /* TemplateSpan */; // `aa ${10} dd ${| + case 113 /* PublicKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + return containingNodeKind === 146 /* PropertyDeclaration */; // class A{ public | } // Previous token may have been a keyword that was converted to an identifier. switch (previousToken.getText()) { @@ -64033,7 +64753,7 @@ var ts; } function isInStringOrRegularExpressionOrTemplateLiteral(contextToken) { if (contextToken.kind === 9 /* StringLiteral */ - || contextToken.kind === 10 /* RegularExpressionLiteral */ + || contextToken.kind === 11 /* RegularExpressionLiteral */ || ts.isTemplateLiteralKind(contextToken.kind)) { var start_3 = contextToken.getStart(); var end = contextToken.getEnd(); @@ -64046,7 +64766,7 @@ var ts; } if (position === end) { return !!contextToken.isUnterminated - || contextToken.kind === 10 /* RegularExpressionLiteral */; + || contextToken.kind === 11 /* RegularExpressionLiteral */; } } return false; @@ -64062,7 +64782,7 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 171 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 172 /* ObjectLiteralExpression */) { // We are completing on contextual types, but may also include properties // other than those within the declared type. isNewIdentifierLocation = true; @@ -64072,7 +64792,7 @@ var ts; typeForObject = typeForObject && typeForObject.getNonNullableType(); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 167 /* ObjectBindingPattern */) { + else if (objectLikeContainer.kind === 168 /* ObjectBindingPattern */) { // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -64083,11 +64803,11 @@ var ts; // Also proceed if rootDeclaration is a parameter and if its containing function expression/arrow function is contextually typed - // type of parameter will flow in from the contextual type of the function var canGetType = !!(rootDeclaration.initializer || rootDeclaration.type); - if (!canGetType && rootDeclaration.kind === 142 /* Parameter */) { + if (!canGetType && rootDeclaration.kind === 143 /* Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 147 /* MethodDeclaration */ || rootDeclaration.parent.kind === 150 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 148 /* MethodDeclaration */ || rootDeclaration.parent.kind === 151 /* SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -64129,9 +64849,9 @@ var ts; * @returns true if 'symbols' was successfully populated; false otherwise. */ function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 233 /* NamedImports */ ? - 230 /* ImportDeclaration */ : - 236 /* ExportDeclaration */; + var declarationKind = namedImportsOrExports.kind === 234 /* NamedImports */ ? + 231 /* ImportDeclaration */ : + 237 /* ExportDeclaration */; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -64154,10 +64874,10 @@ var ts; function tryGetObjectLikeCompletionContainer(contextToken) { if (contextToken) { switch (contextToken.kind) { - case 15 /* OpenBraceToken */: // const x = { | - case 24 /* CommaToken */: + case 16 /* OpenBraceToken */: // const x = { | + case 25 /* CommaToken */: var parent_18 = contextToken.parent; - if (parent_18 && (parent_18.kind === 171 /* ObjectLiteralExpression */ || parent_18.kind === 167 /* ObjectBindingPattern */)) { + if (parent_18 && (parent_18.kind === 172 /* ObjectLiteralExpression */ || parent_18.kind === 168 /* ObjectBindingPattern */)) { return parent_18; } break; @@ -64172,11 +64892,11 @@ var ts; function tryGetNamedImportsOrExportsForCompletion(contextToken) { if (contextToken) { switch (contextToken.kind) { - case 15 /* OpenBraceToken */: // import { | - case 24 /* CommaToken */: + case 16 /* OpenBraceToken */: // import { | + case 25 /* CommaToken */: switch (contextToken.parent.kind) { - case 233 /* NamedImports */: - case 237 /* NamedExports */: + case 234 /* NamedImports */: + case 238 /* NamedExports */: return contextToken.parent; } } @@ -64187,12 +64907,12 @@ var ts; if (contextToken) { var parent_19 = contextToken.parent; switch (contextToken.kind) { - case 26 /* LessThanSlashToken */: - case 39 /* SlashToken */: - case 69 /* Identifier */: + case 27 /* LessThanSlashToken */: + case 40 /* SlashToken */: + case 70 /* Identifier */: case 246 /* JsxAttribute */: case 247 /* JsxSpreadAttribute */: - if (parent_19 && (parent_19.kind === 242 /* JsxSelfClosingElement */ || parent_19.kind === 243 /* JsxOpeningElement */)) { + if (parent_19 && (parent_19.kind === 243 /* JsxSelfClosingElement */ || parent_19.kind === 244 /* JsxOpeningElement */)) { return parent_19; } else if (parent_19.kind === 246 /* JsxAttribute */) { @@ -64207,7 +64927,7 @@ var ts; return parent_19.parent; } break; - case 16 /* CloseBraceToken */: + case 17 /* CloseBraceToken */: if (parent_19 && parent_19.kind === 248 /* JsxExpression */ && parent_19.parent && @@ -64224,16 +64944,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: - case 220 /* FunctionDeclaration */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 153 /* IndexSignature */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 221 /* FunctionDeclaration */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 154 /* IndexSignature */: return true; } return false; @@ -64244,67 +64964,67 @@ var ts; function isSolelyIdentifierDefinitionLocation(contextToken) { var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { - case 24 /* CommaToken */: - return containingNodeKind === 218 /* VariableDeclaration */ || - containingNodeKind === 219 /* VariableDeclarationList */ || - containingNodeKind === 200 /* VariableStatement */ || - containingNodeKind === 224 /* EnumDeclaration */ || + case 25 /* CommaToken */: + return containingNodeKind === 219 /* VariableDeclaration */ || + containingNodeKind === 220 /* VariableDeclarationList */ || + containingNodeKind === 201 /* VariableStatement */ || + containingNodeKind === 225 /* EnumDeclaration */ || isFunction(containingNodeKind) || - containingNodeKind === 221 /* ClassDeclaration */ || - containingNodeKind === 192 /* ClassExpression */ || - containingNodeKind === 222 /* InterfaceDeclaration */ || - containingNodeKind === 168 /* ArrayBindingPattern */ || - containingNodeKind === 223 /* TypeAliasDeclaration */; // type Map, K, | - case 21 /* DotToken */: - return containingNodeKind === 168 /* ArrayBindingPattern */; // var [.| - case 54 /* ColonToken */: - return containingNodeKind === 169 /* BindingElement */; // var {x :html| - case 19 /* OpenBracketToken */: - return containingNodeKind === 168 /* ArrayBindingPattern */; // var [x| - case 17 /* OpenParenToken */: + containingNodeKind === 222 /* ClassDeclaration */ || + containingNodeKind === 193 /* ClassExpression */ || + containingNodeKind === 223 /* InterfaceDeclaration */ || + containingNodeKind === 169 /* ArrayBindingPattern */ || + containingNodeKind === 224 /* TypeAliasDeclaration */; // type Map, K, | + case 22 /* DotToken */: + return containingNodeKind === 169 /* ArrayBindingPattern */; // var [.| + case 55 /* ColonToken */: + return containingNodeKind === 170 /* BindingElement */; // var {x :html| + case 20 /* OpenBracketToken */: + return containingNodeKind === 169 /* ArrayBindingPattern */; // var [x| + case 18 /* OpenParenToken */: return containingNodeKind === 252 /* CatchClause */ || isFunction(containingNodeKind); - case 15 /* OpenBraceToken */: - return containingNodeKind === 224 /* EnumDeclaration */ || - containingNodeKind === 222 /* InterfaceDeclaration */ || - containingNodeKind === 159 /* TypeLiteral */; // const x : { | - case 23 /* SemicolonToken */: - return containingNodeKind === 144 /* PropertySignature */ && + case 16 /* OpenBraceToken */: + return containingNodeKind === 225 /* EnumDeclaration */ || + containingNodeKind === 223 /* InterfaceDeclaration */ || + containingNodeKind === 160 /* TypeLiteral */; // const x : { | + case 24 /* SemicolonToken */: + return containingNodeKind === 145 /* PropertySignature */ && contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 222 /* InterfaceDeclaration */ || - contextToken.parent.parent.kind === 159 /* TypeLiteral */); // const x : { a; | - case 25 /* LessThanToken */: - return containingNodeKind === 221 /* ClassDeclaration */ || - containingNodeKind === 192 /* ClassExpression */ || - containingNodeKind === 222 /* InterfaceDeclaration */ || - containingNodeKind === 223 /* TypeAliasDeclaration */ || + (contextToken.parent.parent.kind === 223 /* InterfaceDeclaration */ || + contextToken.parent.parent.kind === 160 /* TypeLiteral */); // const x : { a; | + case 26 /* LessThanToken */: + return containingNodeKind === 222 /* ClassDeclaration */ || + containingNodeKind === 193 /* ClassExpression */ || + containingNodeKind === 223 /* InterfaceDeclaration */ || + containingNodeKind === 224 /* TypeAliasDeclaration */ || isFunction(containingNodeKind); - case 113 /* StaticKeyword */: - return containingNodeKind === 145 /* PropertyDeclaration */; - case 22 /* DotDotDotToken */: - return containingNodeKind === 142 /* Parameter */ || + case 114 /* StaticKeyword */: + return containingNodeKind === 146 /* PropertyDeclaration */; + case 23 /* DotDotDotToken */: + return containingNodeKind === 143 /* Parameter */ || (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 168 /* ArrayBindingPattern */); // var [...z| - case 112 /* PublicKeyword */: - case 110 /* PrivateKeyword */: - case 111 /* ProtectedKeyword */: - return containingNodeKind === 142 /* Parameter */; - case 116 /* AsKeyword */: - return containingNodeKind === 234 /* ImportSpecifier */ || - containingNodeKind === 238 /* ExportSpecifier */ || - containingNodeKind === 232 /* NamespaceImport */; - case 73 /* ClassKeyword */: - case 81 /* EnumKeyword */: - case 107 /* InterfaceKeyword */: - case 87 /* FunctionKeyword */: - case 102 /* VarKeyword */: - case 123 /* GetKeyword */: - case 131 /* SetKeyword */: - case 89 /* ImportKeyword */: - case 108 /* LetKeyword */: - case 74 /* ConstKeyword */: - case 114 /* YieldKeyword */: - case 134 /* TypeKeyword */: + contextToken.parent.parent.kind === 169 /* ArrayBindingPattern */); // var [...z| + case 113 /* PublicKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + return containingNodeKind === 143 /* Parameter */; + case 117 /* AsKeyword */: + return containingNodeKind === 235 /* ImportSpecifier */ || + containingNodeKind === 239 /* ExportSpecifier */ || + containingNodeKind === 233 /* NamespaceImport */; + case 74 /* ClassKeyword */: + case 82 /* EnumKeyword */: + case 108 /* InterfaceKeyword */: + case 88 /* FunctionKeyword */: + case 103 /* VarKeyword */: + case 124 /* GetKeyword */: + case 132 /* SetKeyword */: + case 90 /* ImportKeyword */: + case 109 /* LetKeyword */: + case 75 /* ConstKeyword */: + case 115 /* YieldKeyword */: + case 135 /* TypeKeyword */: return true; } // Previous token may have been a keyword that was converted to an identifier. @@ -64376,8 +65096,8 @@ var ts; // Ignore omitted expressions for missing members if (m.kind !== 253 /* PropertyAssignment */ && m.kind !== 254 /* ShorthandPropertyAssignment */ && - m.kind !== 169 /* BindingElement */ && - m.kind !== 147 /* MethodDeclaration */) { + m.kind !== 170 /* BindingElement */ && + m.kind !== 148 /* MethodDeclaration */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -64385,9 +65105,9 @@ var ts; continue; } var existingName = void 0; - if (m.kind === 169 /* BindingElement */ && m.propertyName) { + if (m.kind === 170 /* BindingElement */ && m.propertyName) { // include only identifiers in completion list - if (m.propertyName.kind === 69 /* Identifier */) { + if (m.propertyName.kind === 70 /* Identifier */) { existingName = m.propertyName.text; } } @@ -64465,7 +65185,7 @@ var ts; } // A cache of completion entries for keywords, these do not change between sessions var keywordCompletions = []; - for (var i = 70 /* FirstKeyword */; i <= 138 /* LastKeyword */; i++) { + for (var i = 71 /* FirstKeyword */; i <= 139 /* LastKeyword */; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ts.ScriptElementKind.keyword, @@ -64540,10 +65260,10 @@ var ts; }; } function getSemanticDocumentHighlights(node) { - if (node.kind === 69 /* Identifier */ || - node.kind === 97 /* ThisKeyword */ || - node.kind === 165 /* ThisType */ || - node.kind === 95 /* SuperKeyword */ || + if (node.kind === 70 /* Identifier */ || + node.kind === 98 /* ThisKeyword */ || + node.kind === 166 /* ThisType */ || + node.kind === 96 /* SuperKeyword */ || node.kind === 9 /* StringLiteral */ || ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { var referencedSymbols = ts.FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFilesToSearch, /*findInStrings*/ false, /*findInComments*/ false, /*implementations*/ false); @@ -64594,77 +65314,77 @@ var ts; function getHighlightSpans(node) { if (node) { switch (node.kind) { - case 88 /* IfKeyword */: - case 80 /* ElseKeyword */: - if (hasKind(node.parent, 203 /* IfStatement */)) { + case 89 /* IfKeyword */: + case 81 /* ElseKeyword */: + if (hasKind(node.parent, 204 /* IfStatement */)) { return getIfElseOccurrences(node.parent); } break; - case 94 /* ReturnKeyword */: - if (hasKind(node.parent, 211 /* ReturnStatement */)) { + case 95 /* ReturnKeyword */: + if (hasKind(node.parent, 212 /* ReturnStatement */)) { return getReturnOccurrences(node.parent); } break; - case 98 /* ThrowKeyword */: - if (hasKind(node.parent, 215 /* ThrowStatement */)) { + case 99 /* ThrowKeyword */: + if (hasKind(node.parent, 216 /* ThrowStatement */)) { return getThrowOccurrences(node.parent); } break; - case 72 /* CatchKeyword */: - if (hasKind(parent(parent(node)), 216 /* TryStatement */)) { + case 73 /* CatchKeyword */: + if (hasKind(parent(parent(node)), 217 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; - case 100 /* TryKeyword */: - case 85 /* FinallyKeyword */: - if (hasKind(parent(node), 216 /* TryStatement */)) { + case 101 /* TryKeyword */: + case 86 /* FinallyKeyword */: + if (hasKind(parent(node), 217 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent); } break; - case 96 /* SwitchKeyword */: - if (hasKind(node.parent, 213 /* SwitchStatement */)) { + case 97 /* SwitchKeyword */: + if (hasKind(node.parent, 214 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; - case 71 /* CaseKeyword */: - case 77 /* DefaultKeyword */: - if (hasKind(parent(parent(parent(node))), 213 /* SwitchStatement */)) { + case 72 /* CaseKeyword */: + case 78 /* DefaultKeyword */: + if (hasKind(parent(parent(parent(node))), 214 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; - case 70 /* BreakKeyword */: - case 75 /* ContinueKeyword */: - if (hasKind(node.parent, 210 /* BreakStatement */) || hasKind(node.parent, 209 /* ContinueStatement */)) { + case 71 /* BreakKeyword */: + case 76 /* ContinueKeyword */: + if (hasKind(node.parent, 211 /* BreakStatement */) || hasKind(node.parent, 210 /* ContinueStatement */)) { return getBreakOrContinueStatementOccurrences(node.parent); } break; - case 86 /* ForKeyword */: - if (hasKind(node.parent, 206 /* ForStatement */) || - hasKind(node.parent, 207 /* ForInStatement */) || - hasKind(node.parent, 208 /* ForOfStatement */)) { + case 87 /* ForKeyword */: + if (hasKind(node.parent, 207 /* ForStatement */) || + hasKind(node.parent, 208 /* ForInStatement */) || + hasKind(node.parent, 209 /* ForOfStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 104 /* WhileKeyword */: - case 79 /* DoKeyword */: - if (hasKind(node.parent, 205 /* WhileStatement */) || hasKind(node.parent, 204 /* DoStatement */)) { + case 105 /* WhileKeyword */: + case 80 /* DoKeyword */: + if (hasKind(node.parent, 206 /* WhileStatement */) || hasKind(node.parent, 205 /* DoStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 121 /* ConstructorKeyword */: - if (hasKind(node.parent, 148 /* Constructor */)) { + case 122 /* ConstructorKeyword */: + if (hasKind(node.parent, 149 /* Constructor */)) { return getConstructorOccurrences(node.parent); } break; - case 123 /* GetKeyword */: - case 131 /* SetKeyword */: - if (hasKind(node.parent, 149 /* GetAccessor */) || hasKind(node.parent, 150 /* SetAccessor */)) { + case 124 /* GetKeyword */: + case 132 /* SetKeyword */: + if (hasKind(node.parent, 150 /* GetAccessor */) || hasKind(node.parent, 151 /* SetAccessor */)) { return getGetAndSetOccurrences(node.parent); } break; default: if (ts.isModifierKind(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 200 /* VariableStatement */)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 201 /* VariableStatement */)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -64680,10 +65400,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 215 /* ThrowStatement */) { + if (node.kind === 216 /* ThrowStatement */) { statementAccumulator.push(node); } - else if (node.kind === 216 /* TryStatement */) { + else if (node.kind === 217 /* TryStatement */) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -64716,7 +65436,7 @@ var ts; } // 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_20.kind === 216 /* TryStatement */) { + if (parent_20.kind === 217 /* TryStatement */) { var tryStatement = parent_20; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; @@ -64731,7 +65451,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 210 /* BreakStatement */ || node.kind === 209 /* ContinueStatement */) { + if (node.kind === 211 /* BreakStatement */ || node.kind === 210 /* ContinueStatement */) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -64746,16 +65466,16 @@ var ts; function getBreakOrContinueOwner(statement) { for (var node_1 = statement.parent; node_1; node_1 = node_1.parent) { switch (node_1.kind) { - case 213 /* SwitchStatement */: - if (statement.kind === 209 /* ContinueStatement */) { + case 214 /* SwitchStatement */: + if (statement.kind === 210 /* ContinueStatement */) { continue; } // Fall through. - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: - case 205 /* WhileStatement */: - case 204 /* DoStatement */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: + case 206 /* WhileStatement */: + case 205 /* DoStatement */: if (!statement.label || isLabeledBy(node_1, statement.label.text)) { return node_1; } @@ -64774,24 +65494,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 === 221 /* ClassDeclaration */ || - container.kind === 192 /* ClassExpression */ || - (declaration.kind === 142 /* Parameter */ && hasKind(container, 148 /* Constructor */)))) { + if (!(container.kind === 222 /* ClassDeclaration */ || + container.kind === 193 /* ClassExpression */ || + (declaration.kind === 143 /* Parameter */ && hasKind(container, 149 /* Constructor */)))) { return undefined; } } - else if (modifier === 113 /* StaticKeyword */) { - if (!(container.kind === 221 /* ClassDeclaration */ || container.kind === 192 /* ClassExpression */)) { + else if (modifier === 114 /* StaticKeyword */) { + if (!(container.kind === 222 /* ClassDeclaration */ || container.kind === 193 /* ClassExpression */)) { return undefined; } } - else if (modifier === 82 /* ExportKeyword */ || modifier === 122 /* DeclareKeyword */) { - if (!(container.kind === 226 /* ModuleBlock */ || container.kind === 256 /* SourceFile */)) { + else if (modifier === 83 /* ExportKeyword */ || modifier === 123 /* DeclareKeyword */) { + if (!(container.kind === 227 /* ModuleBlock */ || container.kind === 256 /* SourceFile */)) { return undefined; } } - else if (modifier === 115 /* AbstractKeyword */) { - if (!(container.kind === 221 /* ClassDeclaration */ || declaration.kind === 221 /* ClassDeclaration */)) { + else if (modifier === 116 /* AbstractKeyword */) { + if (!(container.kind === 222 /* ClassDeclaration */ || declaration.kind === 222 /* ClassDeclaration */)) { return undefined; } } @@ -64803,7 +65523,7 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 226 /* ModuleBlock */: + case 227 /* ModuleBlock */: case 256 /* SourceFile */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 128 /* Abstract */) { @@ -64813,17 +65533,17 @@ var ts; nodes = container.statements; } break; - case 148 /* Constructor */: + case 149 /* Constructor */: nodes = container.parameters.concat(container.parent.members); break; - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: + case 222 /* ClassDeclaration */: + case 193 /* 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 & 28 /* AccessibilityModifier */) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 148 /* Constructor */ && member; + return member.kind === 149 /* Constructor */ && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -64844,19 +65564,19 @@ var ts; return ts.map(keywords, getHighlightSpanForNode); function getFlagFromModifier(modifier) { switch (modifier) { - case 112 /* PublicKeyword */: + case 113 /* PublicKeyword */: return 4 /* Public */; - case 110 /* PrivateKeyword */: + case 111 /* PrivateKeyword */: return 8 /* Private */; - case 111 /* ProtectedKeyword */: + case 112 /* ProtectedKeyword */: return 16 /* Protected */; - case 113 /* StaticKeyword */: + case 114 /* StaticKeyword */: return 32 /* Static */; - case 82 /* ExportKeyword */: + case 83 /* ExportKeyword */: return 1 /* Export */; - case 122 /* DeclareKeyword */: + case 123 /* DeclareKeyword */: return 2 /* Ambient */; - case 115 /* AbstractKeyword */: + case 116 /* AbstractKeyword */: return 128 /* Abstract */; default: ts.Debug.fail(); @@ -64876,13 +65596,13 @@ var ts; } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 149 /* GetAccessor */); - tryPushAccessorKeyword(accessorDeclaration.symbol, 150 /* SetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 150 /* GetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 151 /* 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, 123 /* GetKeyword */, 131 /* SetKeyword */); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 124 /* GetKeyword */, 132 /* SetKeyword */); }); } } } @@ -64891,19 +65611,19 @@ var ts; var keywords = []; ts.forEach(declarations, function (declaration) { ts.forEach(declaration.getChildren(), function (token) { - return pushKeywordIf(keywords, token, 121 /* ConstructorKeyword */); + return pushKeywordIf(keywords, token, 122 /* ConstructorKeyword */); }); }); return ts.map(keywords, getHighlightSpanForNode); } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 86 /* ForKeyword */, 104 /* WhileKeyword */, 79 /* DoKeyword */)) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 87 /* ForKeyword */, 105 /* WhileKeyword */, 80 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 204 /* DoStatement */) { + if (loopNode.kind === 205 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 104 /* WhileKeyword */)) { + if (pushKeywordIf(keywords, loopTokens[i], 105 /* WhileKeyword */)) { break; } } @@ -64912,7 +65632,7 @@ var ts; var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 70 /* BreakKeyword */, 75 /* ContinueKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 71 /* BreakKeyword */, 76 /* ContinueKeyword */); } }); return ts.map(keywords, getHighlightSpanForNode); @@ -64921,13 +65641,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: - case 204 /* DoStatement */: - case 205 /* WhileStatement */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: + case 205 /* DoStatement */: + case 206 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 213 /* SwitchStatement */: + case 214 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -64935,14 +65655,14 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 96 /* SwitchKeyword */); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 97 /* 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(), 71 /* CaseKeyword */, 77 /* DefaultKeyword */); + pushKeywordIf(keywords, clause.getFirstToken(), 72 /* CaseKeyword */, 78 /* DefaultKeyword */); var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 70 /* BreakKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 71 /* BreakKeyword */); } }); }); @@ -64950,13 +65670,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 100 /* TryKeyword */); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 101 /* TryKeyword */); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 72 /* CatchKeyword */); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 73 /* CatchKeyword */); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 85 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 85 /* FinallyKeyword */); + var finallyKeyword = ts.findChildOfKind(tryStatement, 86 /* FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 86 /* FinallyKeyword */); } return ts.map(keywords, getHighlightSpanForNode); } @@ -64967,13 +65687,13 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 98 /* ThrowKeyword */); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 99 /* 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(), 94 /* ReturnKeyword */); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 95 /* ReturnKeyword */); }); } return ts.map(keywords, getHighlightSpanForNode); @@ -64981,36 +65701,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, 199 /* Block */))) { + if (!(func && hasKind(func.body, 200 /* Block */))) { return undefined; } var keywords = []; ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 94 /* ReturnKeyword */); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 95 /* ReturnKeyword */); }); // Include 'throw' statements that do not occur within a try block. ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 98 /* ThrowKeyword */); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 99 /* 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, 203 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 204 /* 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], 88 /* IfKeyword */); + pushKeywordIf(keywords, children[0], 89 /* 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], 80 /* ElseKeyword */)) { + if (pushKeywordIf(keywords, children[i], 81 /* ElseKeyword */)) { break; } } - if (!hasKind(ifStatement.elseStatement, 203 /* IfStatement */)) { + if (!hasKind(ifStatement.elseStatement, 204 /* IfStatement */)) { break; } ifStatement = ifStatement.elseStatement; @@ -65019,7 +65739,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 === 80 /* ElseKeyword */ && i < keywords.length - 1) { + if (keywords[i].kind === 81 /* ElseKeyword */ && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. var shouldCombindElseAndIf = true; @@ -65053,7 +65773,7 @@ var ts; * Note: 'node' cannot be a SourceFile. */ function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 214 /* LabeledStatement */; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 215 /* LabeledStatement */; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -65191,10 +65911,10 @@ var ts; break; } // Fallthrough - case 69 /* Identifier */: - case 97 /* ThisKeyword */: + case 70 /* Identifier */: + case 98 /* ThisKeyword */: // case SyntaxKind.SuperKeyword: TODO:GH#9268 - case 121 /* ConstructorKeyword */: + case 122 /* ConstructorKeyword */: case 9 /* StringLiteral */: return getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, /*implementations*/ false); } @@ -65219,7 +65939,7 @@ var ts; if (ts.isThis(node)) { return getReferencesForThisKeyword(node, sourceFiles); } - if (node.kind === 95 /* SuperKeyword */) { + if (node.kind === 96 /* SuperKeyword */) { return getReferencesForSuperKeyword(node); } } @@ -65255,7 +65975,7 @@ var ts; getReferencesInNode(scope, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); } else { - var internedName = getInternedName(symbol, node, declarations); + var internedName = getInternedName(symbol, node); for (var _i = 0, sourceFiles_8 = sourceFiles; _i < sourceFiles_8.length; _i++) { var sourceFile = sourceFiles_8[_i]; cancellationToken.throwIfCancellationRequested(); @@ -65287,12 +66007,12 @@ var ts; function getAliasSymbolForPropertyNameSymbol(symbol, location) { if (symbol.flags & 8388608 /* Alias */) { // Default import get alias - var defaultImport = ts.getDeclarationOfKind(symbol, 231 /* ImportClause */); + var defaultImport = ts.getDeclarationOfKind(symbol, 232 /* ImportClause */); if (defaultImport) { return typeChecker.getAliasedSymbol(symbol); } - var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 234 /* ImportSpecifier */ || - declaration.kind === 238 /* ExportSpecifier */) ? declaration : undefined; }); + var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 235 /* ImportSpecifier */ || + declaration.kind === 239 /* ExportSpecifier */) ? declaration : undefined; }); if (importOrExportSpecifier && // export { a } (!importOrExportSpecifier.propertyName || @@ -65300,7 +66020,7 @@ var ts; importOrExportSpecifier.propertyName === location)) { // If Import specifier -> get alias // else Export specifier -> get local target - return importOrExportSpecifier.kind === 234 /* ImportSpecifier */ ? + return importOrExportSpecifier.kind === 235 /* ImportSpecifier */ ? typeChecker.getAliasedSymbol(symbol) : typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); } @@ -65315,20 +66035,20 @@ var ts; typeChecker.getPropertySymbolOfDestructuringAssignment(location); } function isObjectBindingPatternElementWithoutPropertyName(symbol) { - var bindingElement = ts.getDeclarationOfKind(symbol, 169 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 170 /* BindingElement */); return bindingElement && - bindingElement.parent.kind === 167 /* ObjectBindingPattern */ && + bindingElement.parent.kind === 168 /* ObjectBindingPattern */ && !bindingElement.propertyName; } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol) { if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { - var bindingElement = ts.getDeclarationOfKind(symbol, 169 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 170 /* BindingElement */); var typeOfPattern = typeChecker.getTypeAtLocation(bindingElement.parent); return typeOfPattern && typeChecker.getPropertyOfType(typeOfPattern, bindingElement.name.text); } return undefined; } - function getInternedName(symbol, location, declarations) { + function getInternedName(symbol, location) { // If this is an export or import specifier it could have been renamed using the 'as' syntax. // If so we want to search for whatever under the cursor. if (ts.isImportOrExportSpecifierName(location)) { @@ -65352,14 +66072,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 === 179 /* FunctionExpression */ || valueDeclaration.kind === 192 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 180 /* FunctionExpression */ || valueDeclaration.kind === 193 /* 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 (ts.getModifierFlags(d) & 8 /* Private */) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 221 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 222 /* ClassDeclaration */); } } // If the symbol is an import we would like to find it if we are looking for what it imports. @@ -65421,8 +66141,8 @@ var ts; // We found a match. Make sure it's not part of a larger word (i.e. the char // before and after it have to be a non-identifier char). var endPosition = position + symbolNameLength; - if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 2 /* Latest */)) && - (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 2 /* Latest */))) { + if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 4 /* Latest */)) && + (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 4 /* Latest */))) { // Found a real match. Keep searching. positions.push(position); } @@ -65462,7 +66182,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 69 /* Identifier */: + case 70 /* Identifier */: return node.getWidth() === searchSymbolName.length; case 9 /* StringLiteral */: if (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || @@ -65526,14 +66246,14 @@ var ts; var referenceSymbolDeclaration = referenceSymbol.valueDeclaration; var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); var relatedSymbol = getRelatedSymbol(searchSymbols_1, referenceSymbol, referenceLocation, - /*searchLocationIsConstructor*/ searchLocation.kind === 121 /* ConstructorKeyword */, parents, inheritsFromCache); + /*searchLocationIsConstructor*/ searchLocation.kind === 122 /* ConstructorKeyword */, parents, inheritsFromCache); if (relatedSymbol) { addReferenceToRelatedSymbol(referenceLocation, relatedSymbol); } else if (!(referenceSymbol.flags & 67108864 /* Transient */) && searchSymbols_1.indexOf(shorthandValueSymbol) >= 0) { addReferenceToRelatedSymbol(referenceSymbolDeclaration.name, shorthandValueSymbol); } - else if (searchLocation.kind === 121 /* ConstructorKeyword */) { + else if (searchLocation.kind === 122 /* ConstructorKeyword */) { findAdditionalConstructorReferences(referenceSymbol, referenceLocation); } } @@ -65594,17 +66314,17 @@ var ts; var result = []; for (var _i = 0, _a = classSymbol.members["__constructor"].declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 148 /* Constructor */); + ts.Debug.assert(decl.kind === 149 /* Constructor */); var ctrKeyword = decl.getChildAt(0); - ts.Debug.assert(ctrKeyword.kind === 121 /* ConstructorKeyword */); + ts.Debug.assert(ctrKeyword.kind === 122 /* ConstructorKeyword */); result.push(ctrKeyword); } ts.forEachProperty(classSymbol.exports, function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 147 /* MethodDeclaration */) { + if (decl && decl.kind === 148 /* MethodDeclaration */) { var body = decl.body; if (body) { - forEachDescendantOfKind(body, 97 /* ThisKeyword */, function (thisKeyword) { + forEachDescendantOfKind(body, 98 /* ThisKeyword */, function (thisKeyword) { if (ts.isNewExpressionTarget(thisKeyword)) { result.push(thisKeyword); } @@ -65624,10 +66344,10 @@ var ts; var result = []; for (var _i = 0, _a = ctr.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 148 /* Constructor */); + ts.Debug.assert(decl.kind === 149 /* Constructor */); var body = decl.body; if (body) { - forEachDescendantOfKind(body, 95 /* SuperKeyword */, function (node) { + forEachDescendantOfKind(body, 96 /* SuperKeyword */, function (node) { if (ts.isCallExpressionTarget(node)) { result.push(node); } @@ -65665,7 +66385,7 @@ var ts; if (ts.isDeclarationName(refNode) && isImplementation(refNode.parent)) { result.push(getReferenceEntryFromNode(refNode.parent)); } - else if (refNode.kind === 69 /* Identifier */) { + else if (refNode.kind === 70 /* Identifier */) { if (refNode.parent.kind === 254 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); @@ -65684,7 +66404,7 @@ var ts; maybeAdd(getReferenceEntryFromNode(parent_21.initializer)); } else if (ts.isFunctionLike(parent_21) && parent_21.type === containingTypeReference && parent_21.body) { - if (parent_21.body.kind === 199 /* Block */) { + if (parent_21.body.kind === 200 /* Block */) { ts.forEachReturnStatement(parent_21.body, function (returnStatement) { if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); @@ -65736,12 +66456,12 @@ var ts; } function getContainingClassIfInHeritageClause(node) { if (node && node.parent) { - if (node.kind === 194 /* ExpressionWithTypeArguments */ + if (node.kind === 195 /* ExpressionWithTypeArguments */ && node.parent.kind === 251 /* HeritageClause */ && ts.isClassLike(node.parent.parent)) { return node.parent.parent; } - else if (node.kind === 69 /* Identifier */ || node.kind === 172 /* PropertyAccessExpression */) { + else if (node.kind === 70 /* Identifier */ || node.kind === 173 /* PropertyAccessExpression */) { return getContainingClassIfInHeritageClause(node.parent); } } @@ -65752,14 +66472,14 @@ var ts; */ function isImplementationExpression(node) { // Unwrap parentheses - if (node.kind === 178 /* ParenthesizedExpression */) { + if (node.kind === 179 /* ParenthesizedExpression */) { return isImplementationExpression(node.expression); } - return node.kind === 180 /* ArrowFunction */ || - node.kind === 179 /* FunctionExpression */ || - node.kind === 171 /* ObjectLiteralExpression */ || - node.kind === 192 /* ClassExpression */ || - node.kind === 170 /* ArrayLiteralExpression */; + return node.kind === 181 /* ArrowFunction */ || + node.kind === 180 /* FunctionExpression */ || + node.kind === 172 /* ObjectLiteralExpression */ || + node.kind === 193 /* ClassExpression */ || + node.kind === 171 /* ArrayLiteralExpression */; } /** * Determines if the parent symbol occurs somewhere in the child's ancestry. If the parent symbol @@ -65808,7 +66528,7 @@ var ts; } return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); } - else if (declaration.kind === 222 /* InterfaceDeclaration */) { + else if (declaration.kind === 223 /* InterfaceDeclaration */) { if (parentIsInterface) { return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); } @@ -65836,13 +66556,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -65855,7 +66575,7 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 95 /* SuperKeyword */) { + if (!node || node.kind !== 96 /* SuperKeyword */) { return; } var container = ts.getSuperContainer(node, /*stopOnFunctions*/ false); @@ -65874,17 +66594,17 @@ var ts; // Whether 'this' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // fall through - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -65893,8 +66613,8 @@ var ts; return undefined; } // Fall through - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: + case 221 /* FunctionDeclaration */: + case 180 /* 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. @@ -65937,20 +66657,20 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 179 /* FunctionExpression */: - case 220 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 221 /* FunctionDeclaration */: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 192 /* ClassExpression */: - case 221 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 222 /* 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 && (ts.getModifierFlags(container) & 32 /* Static */) === staticFlag) { @@ -66060,7 +66780,7 @@ var ts; // we should include both parameter declaration symbol and property declaration symbol // Parameter Declaration symbol is only visible within function scope, so the symbol is stored in constructor.locals. // Property Declaration symbol is a member of the class, so the symbol is stored in its class Declaration.symbol.members - if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 142 /* Parameter */ && + if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 143 /* Parameter */ && ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { result = result.concat(typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); } @@ -66115,7 +66835,7 @@ var ts; getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 222 /* InterfaceDeclaration */) { + else if (declaration.kind === 223 /* InterfaceDeclaration */) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -66199,7 +66919,7 @@ var ts; }); } function getNameFromObjectLiteralElement(node) { - if (node.name.kind === 140 /* ComputedPropertyName */) { + if (node.name.kind === 141 /* ComputedPropertyName */) { var nameExpression = node.name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteral(nameExpression.kind)) { @@ -66281,7 +67001,7 @@ var ts; if (node.initializer) { return true; } - else if (node.kind === 218 /* VariableDeclaration */) { + else if (node.kind === 219 /* VariableDeclaration */) { var parentStatement = getParentStatementOfVariableDeclaration(node); return parentStatement && ts.hasModifier(parentStatement, 2 /* Ambient */); } @@ -66291,18 +67011,18 @@ var ts; } else { switch (node.kind) { - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - case 224 /* EnumDeclaration */: - case 225 /* ModuleDeclaration */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 225 /* EnumDeclaration */: + case 226 /* ModuleDeclaration */: return true; } } return false; } function getParentStatementOfVariableDeclaration(node) { - if (node.parent && node.parent.parent && node.parent.parent.kind === 200 /* VariableStatement */) { - ts.Debug.assert(node.parent.kind === 219 /* VariableDeclarationList */); + if (node.parent && node.parent.parent && node.parent.parent.kind === 201 /* VariableStatement */) { + ts.Debug.assert(node.parent.kind === 220 /* VariableDeclarationList */); return node.parent.parent; } } @@ -66336,17 +67056,17 @@ var ts; FindAllReferences.getReferenceEntryFromNode = getReferenceEntryFromNode; /** 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 === 69 /* Identifier */ && ts.isDeclarationName(node)) { + if (node.kind === 70 /* Identifier */ && ts.isDeclarationName(node)) { return true; } var parent = node.parent; if (parent) { - if (parent.kind === 186 /* PostfixUnaryExpression */ || parent.kind === 185 /* PrefixUnaryExpression */) { + if (parent.kind === 187 /* PostfixUnaryExpression */ || parent.kind === 186 /* PrefixUnaryExpression */) { return true; } - else if (parent.kind === 187 /* BinaryExpression */ && parent.left === node) { + else if (parent.kind === 188 /* BinaryExpression */ && parent.left === node) { var operator = parent.operatorToken.kind; - return 56 /* FirstAssignment */ <= operator && operator <= 68 /* LastAssignment */; + return 57 /* FirstAssignment */ <= operator && operator <= 69 /* LastAssignment */; } } return false; @@ -66366,11 +67086,11 @@ var ts; switch (node.kind) { case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - if (node.parent.kind === 140 /* ComputedPropertyName */) { + if (node.parent.kind === 141 /* ComputedPropertyName */) { return isObjectLiteralPropertyDeclaration(node.parent.parent) ? node.parent.parent : undefined; } // intential fall through - case 69 /* Identifier */: + case 70 /* Identifier */: return isObjectLiteralPropertyDeclaration(node.parent) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -66379,9 +67099,9 @@ var ts; switch (node.kind) { case 253 /* PropertyAssignment */: case 254 /* ShorthandPropertyAssignment */: - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: return true; } return false; @@ -66454,9 +67174,9 @@ var ts; // (1) when the aliased symbol was declared in the location(parent). // (2) when the aliased symbol is originating from a named import. // - if (node.kind === 69 /* Identifier */ && + if (node.kind === 70 /* Identifier */ && (node.parent === declaration || - (declaration.kind === 234 /* ImportSpecifier */ && declaration.parent && declaration.parent.kind === 233 /* NamedImports */))) { + (declaration.kind === 235 /* ImportSpecifier */ && declaration.parent && declaration.parent.kind === 234 /* NamedImports */))) { symbol = typeChecker.getAliasedSymbol(symbol); } } @@ -66523,7 +67243,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 (ts.isNewExpressionTarget(location) || location.kind === 121 /* ConstructorKeyword */) { + if (ts.isNewExpressionTarget(location) || location.kind === 122 /* 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++) { @@ -66548,8 +67268,8 @@ var ts; var declarations = []; var definition; ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 148 /* Constructor */) || - (!selectConstructors && (d.kind === 220 /* FunctionDeclaration */ || d.kind === 147 /* MethodDeclaration */ || d.kind === 146 /* MethodSignature */))) { + if ((selectConstructors && d.kind === 149 /* Constructor */) || + (!selectConstructors && (d.kind === 221 /* FunctionDeclaration */ || d.kind === 148 /* MethodDeclaration */ || d.kind === 147 /* MethodSignature */))) { declarations.push(d); if (d.body) definition = d; @@ -66634,7 +67354,7 @@ var ts; ts.FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result); return result.length > 0 ? result : undefined; } - else if (node.kind === 95 /* SuperKeyword */ || ts.isSuperProperty(node.parent)) { + else if (node.kind === 96 /* SuperKeyword */ || ts.isSuperProperty(node.parent)) { // References to and accesses on the super keyword only have one possible implementation, so no // need to "Find all References" var symbol = typeChecker.getSymbolAtLocation(node); @@ -66702,7 +67422,7 @@ var ts; "version" ]; var jsDocCompletionEntries; - function getJsDocCommentsFromDeclarations(declarations, name, canUseParsedParamTagComments) { + function getJsDocCommentsFromDeclarations(declarations) { // Only collect doc comments from duplicate declarations once: // In case of a union property there might be same declaration multiple times // which only varies in type parameter @@ -66752,7 +67472,7 @@ var ts; name: tagName, kind: ts.ScriptElementKind.keyword, kindModifiers: "", - sortText: "0" + sortText: "0", }; })); } @@ -66795,19 +67515,19 @@ var ts; var commentOwner; findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 220 /* FunctionDeclaration */: - case 147 /* MethodDeclaration */: - case 148 /* Constructor */: - case 221 /* ClassDeclaration */: - case 200 /* VariableStatement */: + case 221 /* FunctionDeclaration */: + case 148 /* MethodDeclaration */: + case 149 /* Constructor */: + case 222 /* ClassDeclaration */: + case 201 /* VariableStatement */: break findOwner; case 256 /* SourceFile */: return undefined; - case 225 /* ModuleDeclaration */: + case 226 /* 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 === 225 /* ModuleDeclaration */) { + if (commentOwner.parent.kind === 226 /* ModuleDeclaration */) { return undefined; } break findOwner; @@ -66823,7 +67543,7 @@ var ts; var docParams = ""; for (var i = 0, numParams = parameters.length; i < numParams; i++) { var currentName = parameters[i].name; - var paramName = currentName.kind === 69 /* Identifier */ ? + var paramName = currentName.kind === 70 /* Identifier */ ? currentName.text : "param" + i; docParams += indentationStr + " * @param " + paramName + newLine; @@ -66848,7 +67568,7 @@ var ts; if (ts.isFunctionLike(commentOwner)) { return commentOwner.parameters; } - if (commentOwner.kind === 200 /* VariableStatement */) { + if (commentOwner.kind === 201 /* VariableStatement */) { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; if (varDeclarations.length === 1 && varDeclarations[0].initializer) { @@ -66866,17 +67586,17 @@ var ts; * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. */ function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 178 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 179 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: return rightHandSide.parameters; - case 192 /* ClassExpression */: + case 193 /* ClassExpression */: for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 148 /* Constructor */) { + if (member.kind === 149 /* Constructor */) { return member.parameters; } } @@ -66911,7 +67631,7 @@ var ts; * @param typingOptions are used to customize the typing inference process * @param compilerOptions are used as a source for typing inference */ - function discoverTypings(host, fileNames, projectRootPath, safeListPath, packageNameToTypingLocation, typingOptions, compilerOptions) { + function discoverTypings(host, fileNames, projectRootPath, safeListPath, packageNameToTypingLocation, typingOptions) { // A typing name to typing file path mapping var inferredTypings = ts.createMap(); if (!typingOptions || !typingOptions.enableAutoDiscovery) { @@ -67079,8 +67799,6 @@ var ts; function getNavigateToItems(sourceFiles, checker, cancellationToken, searchValue, maxResultCount, excludeDtsFiles) { var patternMatcher = ts.createPatternMatcher(searchValue); var rawItems = []; - // This means "compare in a case insensitive manner." - var baseSensitivity = { sensitivity: "base" }; // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] ts.forEach(sourceFiles, function (sourceFile) { cancellationToken.throwIfCancellationRequested(); @@ -67121,7 +67839,7 @@ var ts; // Remove imports when the imported declaration is already in the list and has the same name. rawItems = ts.filter(rawItems, function (item) { var decl = item.declaration; - if (decl.kind === 231 /* ImportClause */ || decl.kind === 234 /* ImportSpecifier */ || decl.kind === 229 /* ImportEqualsDeclaration */) { + if (decl.kind === 232 /* ImportClause */ || decl.kind === 235 /* ImportSpecifier */ || decl.kind === 230 /* ImportEqualsDeclaration */) { var importer = checker.getSymbolAtLocation(decl.name); var imported = checker.getAliasedSymbol(importer); return importer.name !== imported.name; @@ -67149,7 +67867,7 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 69 /* Identifier */ || + if (node.kind === 70 /* Identifier */ || node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { return node.text; @@ -67163,7 +67881,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 140 /* ComputedPropertyName */) { + else if (declaration.name.kind === 141 /* ComputedPropertyName */) { return tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion*/ true); } else { @@ -67184,7 +67902,7 @@ var ts; } return true; } - if (expression.kind === 172 /* PropertyAccessExpression */) { + if (expression.kind === 173 /* PropertyAccessExpression */) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -67197,7 +67915,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 === 140 /* ComputedPropertyName */) { + if (declaration.name.kind === 141 /* ComputedPropertyName */) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion*/ false)) { return undefined; } @@ -67230,8 +67948,8 @@ var ts; // We first sort case insensitively. So "Aaa" will come before "bar". // Then we sort case sensitively, so "aaa" will come before "Aaa". return i1.matchKind - i2.matchKind || - i1.name.localeCompare(i2.name, undefined, baseSensitivity) || - i1.name.localeCompare(i2.name); + ts.compareStringsCaseInsensitive(i1.name, i2.name) || + ts.compareStrings(i1.name, i2.name); } function createNavigateToItem(rawItem) { var declaration = rawItem.declaration; @@ -67350,7 +68068,7 @@ var ts; return; } switch (node.kind) { - case 148 /* Constructor */: + case 149 /* Constructor */: // Get parameter properties, and treat them as being on the *same* level as the constructor, not under it. var ctr = node; addNodeWithRecursiveChild(ctr, ctr.body); @@ -67362,21 +68080,21 @@ var ts; } } break; - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 146 /* MethodSignature */: + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 147 /* MethodSignature */: if (!ts.hasDynamicName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: if (!ts.hasDynamicName(node)) { addLeafNode(node); } break; - case 231 /* ImportClause */: + case 232 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -67388,7 +68106,7 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 232 /* NamespaceImport */) { + if (namedBindings.kind === 233 /* NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -67399,8 +68117,8 @@ var ts; } } break; - case 169 /* BindingElement */: - case 218 /* VariableDeclaration */: + case 170 /* BindingElement */: + case 219 /* VariableDeclaration */: var decl = node; var name_50 = decl.name; if (ts.isBindingPattern(name_50)) { @@ -67414,12 +68132,12 @@ var ts; addNodeWithRecursiveChild(decl, decl.initializer); } break; - case 180 /* ArrowFunction */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: startNode(node); for (var _d = 0, _e = node.members; _d < _e.length; _d++) { var member = _e[_d]; @@ -67429,9 +68147,9 @@ var ts; } endNode(); break; - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - case 222 /* InterfaceDeclaration */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 223 /* InterfaceDeclaration */: startNode(node); for (var _f = 0, _g = node.members; _f < _g.length; _f++) { var member = _g[_f]; @@ -67439,15 +68157,15 @@ var ts; } endNode(); break; - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 238 /* ExportSpecifier */: - case 229 /* ImportEqualsDeclaration */: - case 153 /* IndexSignature */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 223 /* TypeAliasDeclaration */: + case 239 /* ExportSpecifier */: + case 230 /* ImportEqualsDeclaration */: + case 154 /* IndexSignature */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 224 /* TypeAliasDeclaration */: addLeafNode(node); break; default: @@ -67504,14 +68222,14 @@ var ts; }); /** a and b have the same name, but they may not be mergeable. */ function shouldReallyMerge(a, b) { - return a.kind === b.kind && (a.kind !== 225 /* ModuleDeclaration */ || areSameModule(a, b)); + return a.kind === b.kind && (a.kind !== 226 /* ModuleDeclaration */ || areSameModule(a, b)); // We use 1 NavNode to represent 'A.B.C', but there are multiple source nodes. // Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'! function areSameModule(a, b) { if (a.body.kind !== b.body.kind) { return false; } - if (a.body.kind !== 225 /* ModuleDeclaration */) { + if (a.body.kind !== 226 /* ModuleDeclaration */) { return true; } return areSameModule(a.body, b.body); @@ -67546,11 +68264,9 @@ var ts; return name1 ? 1 : name2 ? -1 : navigationBarNodeKind(child1) - navigationBarNodeKind(child2); } } - // More efficient to create a collator once and use its `compare` than to call `a.localeCompare(b)` many times. - var collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; // Intl is missing in Safari, and node 0.10 treats "a" as greater than "B". - var localeCompareIsCorrect = collator && collator.compare("a", "B") < 0; - var localeCompareFix = localeCompareIsCorrect ? collator.compare : function (a, b) { + var localeCompareIsCorrect = ts.collator && ts.collator.compare("a", "B") < 0; + var localeCompareFix = localeCompareIsCorrect ? ts.collator.compare : function (a, b) { // This isn't perfect, but it passes all of our tests. for (var i = 0; i < Math.min(a.length, b.length); i++) { var chA = a.charAt(i), chB = b.charAt(i); @@ -67560,7 +68276,7 @@ var ts; if (chA === "'" && chB === "\"") { return -1; } - var cmp = chA.toLocaleLowerCase().localeCompare(chB.toLocaleLowerCase()); + var cmp = ts.compareStrings(chA.toLocaleLowerCase(), chB.toLocaleLowerCase()); if (cmp !== 0) { return cmp; } @@ -67573,7 +68289,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 225 /* ModuleDeclaration */) { + if (node.kind === 226 /* ModuleDeclaration */) { return getModuleName(node); } var decl = node; @@ -67581,9 +68297,9 @@ var ts; return ts.getPropertyNameForPropertyNameNode(decl.name); } switch (node.kind) { - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: - case 192 /* ClassExpression */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 193 /* ClassExpression */: return getFunctionOrClassName(node); case 279 /* JSDocTypedefTag */: return getJSDocTypedefTagName(node); @@ -67592,7 +68308,7 @@ var ts; } } function getItemName(node) { - if (node.kind === 225 /* ModuleDeclaration */) { + if (node.kind === 226 /* ModuleDeclaration */) { return getModuleName(node); } var name = node.name; @@ -67608,22 +68324,22 @@ var ts; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 180 /* ArrowFunction */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: + case 181 /* ArrowFunction */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: if (ts.getModifierFlags(node) & 512 /* Default */) { return "default"; } return getFunctionOrClassName(node); - case 148 /* Constructor */: + case 149 /* Constructor */: return "constructor"; - case 152 /* ConstructSignature */: + case 153 /* ConstructSignature */: return "new()"; - case 151 /* CallSignature */: + case 152 /* CallSignature */: return "()"; - case 153 /* IndexSignature */: + case 154 /* IndexSignature */: return "[]"; case 279 /* JSDocTypedefTag */: return getJSDocTypedefTagName(node); @@ -67637,10 +68353,10 @@ var ts; } else { var parentNode = node.parent && node.parent.parent; - if (parentNode && parentNode.kind === 200 /* VariableStatement */) { + if (parentNode && parentNode.kind === 201 /* VariableStatement */) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; - if (nameIdentifier.kind === 69 /* Identifier */) { + if (nameIdentifier.kind === 70 /* Identifier */) { return nameIdentifier.text; } } @@ -67666,24 +68382,24 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - case 224 /* EnumDeclaration */: - case 222 /* InterfaceDeclaration */: - case 225 /* ModuleDeclaration */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 225 /* EnumDeclaration */: + case 223 /* InterfaceDeclaration */: + case 226 /* ModuleDeclaration */: case 256 /* SourceFile */: - case 223 /* TypeAliasDeclaration */: + case 224 /* TypeAliasDeclaration */: case 279 /* JSDocTypedefTag */: return true; - case 148 /* Constructor */: - case 147 /* MethodDeclaration */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 218 /* VariableDeclaration */: + case 149 /* Constructor */: + case 148 /* MethodDeclaration */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 219 /* VariableDeclaration */: return hasSomeImportantChild(item); - case 180 /* ArrowFunction */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -67693,10 +68409,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 226 /* ModuleBlock */: + case 227 /* ModuleBlock */: case 256 /* SourceFile */: - case 147 /* MethodDeclaration */: - case 148 /* Constructor */: + case 148 /* MethodDeclaration */: + case 149 /* Constructor */: return true; default: return hasSomeImportantChild(item); @@ -67705,7 +68421,7 @@ var ts; function hasSomeImportantChild(item) { return ts.forEach(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 218 /* VariableDeclaration */ && childKind !== 169 /* BindingElement */; + return childKind !== 219 /* VariableDeclaration */ && childKind !== 170 /* BindingElement */; }); } } @@ -67763,7 +68479,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 === 225 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 226 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -67774,10 +68490,10 @@ var ts; * We store 'A' as associated with a NavNode, and use getModuleName to traverse down again. */ function getInteriorModule(decl) { - return decl.body.kind === 225 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; + return decl.body.kind === 226 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 140 /* ComputedPropertyName */; + return !member.name || member.name.kind === 141 /* ComputedPropertyName */; } function getNodeSpan(node) { return node.kind === 256 /* SourceFile */ @@ -67788,11 +68504,11 @@ var ts; if (node.name && ts.getFullWidth(node.name) > 0) { return ts.declarationNameToString(node.name); } - else if (node.parent.kind === 218 /* VariableDeclaration */) { + else if (node.parent.kind === 219 /* VariableDeclaration */) { return ts.declarationNameToString(node.parent.name); } - else if (node.parent.kind === 187 /* BinaryExpression */ && - node.parent.operatorToken.kind === 56 /* EqualsToken */) { + else if (node.parent.kind === 188 /* BinaryExpression */ && + node.parent.operatorToken.kind === 57 /* EqualsToken */) { return nodeText(node.parent.left); } else if (node.parent.kind === 253 /* PropertyAssignment */ && node.parent.name) { @@ -67806,7 +68522,7 @@ var ts; } } function isFunctionOrClassExpression(node) { - return node.kind === 179 /* FunctionExpression */ || node.kind === 180 /* ArrowFunction */ || node.kind === 192 /* ClassExpression */; + return node.kind === 180 /* FunctionExpression */ || node.kind === 181 /* ArrowFunction */ || node.kind === 193 /* ClassExpression */; } })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); })(ts || (ts = {})); @@ -67882,7 +68598,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 180 /* ArrowFunction */; + return ts.isFunctionBlock(node) && node.parent.kind !== 181 /* ArrowFunction */; } var depth = 0; var maxDepth = 20; @@ -67894,26 +68610,26 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 199 /* Block */: + case 200 /* Block */: if (!ts.isFunctionBlock(n)) { var parent_22 = n.parent; - var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); + var openBrace = ts.findChildOfKind(n, 16 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 17 /* CloseBraceToken */, sourceFile); // Check if the block is standalone, or 'attached' to some parent statement. // If the latter, we want to collapse the block, but consider its hint span // to be the entire span of the parent. - if (parent_22.kind === 204 /* DoStatement */ || - parent_22.kind === 207 /* ForInStatement */ || - parent_22.kind === 208 /* ForOfStatement */ || - parent_22.kind === 206 /* ForStatement */ || - parent_22.kind === 203 /* IfStatement */ || - parent_22.kind === 205 /* WhileStatement */ || - parent_22.kind === 212 /* WithStatement */ || + if (parent_22.kind === 205 /* DoStatement */ || + parent_22.kind === 208 /* ForInStatement */ || + parent_22.kind === 209 /* ForOfStatement */ || + parent_22.kind === 207 /* ForStatement */ || + parent_22.kind === 204 /* IfStatement */ || + parent_22.kind === 206 /* WhileStatement */ || + parent_22.kind === 213 /* WithStatement */ || parent_22.kind === 252 /* CatchClause */) { addOutliningSpan(parent_22, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_22.kind === 216 /* TryStatement */) { + if (parent_22.kind === 217 /* TryStatement */) { // Could be the try-block, or the finally-block. var tryStatement = parent_22; if (tryStatement.tryBlock === n) { @@ -67921,7 +68637,7 @@ var ts; break; } else if (tryStatement.finallyBlock === n) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 85 /* FinallyKeyword */, sourceFile); + var finallyKeyword = ts.findChildOfKind(tryStatement, 86 /* FinallyKeyword */, sourceFile); if (finallyKeyword) { addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); break; @@ -67940,25 +68656,25 @@ var ts; break; } // Fallthrough. - case 226 /* ModuleBlock */: { - var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); + case 227 /* ModuleBlock */: { + var openBrace = ts.findChildOfKind(n, 16 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 17 /* CloseBraceToken */, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 221 /* ClassDeclaration */: - case 222 /* InterfaceDeclaration */: - case 224 /* EnumDeclaration */: - case 171 /* ObjectLiteralExpression */: - case 227 /* CaseBlock */: { - var openBrace = ts.findChildOfKind(n, 15 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 16 /* CloseBraceToken */, sourceFile); + case 222 /* ClassDeclaration */: + case 223 /* InterfaceDeclaration */: + case 225 /* EnumDeclaration */: + case 172 /* ObjectLiteralExpression */: + case 228 /* CaseBlock */: { + var openBrace = ts.findChildOfKind(n, 16 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 17 /* CloseBraceToken */, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 170 /* ArrayLiteralExpression */: - var openBracket = ts.findChildOfKind(n, 19 /* OpenBracketToken */, sourceFile); - var closeBracket = ts.findChildOfKind(n, 20 /* CloseBracketToken */, sourceFile); + case 171 /* ArrayLiteralExpression */: + var openBracket = ts.findChildOfKind(n, 20 /* OpenBracketToken */, sourceFile); + var closeBracket = ts.findChildOfKind(n, 21 /* CloseBracketToken */, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); break; } @@ -68313,7 +69029,7 @@ var ts; if (ch >= 65 /* A */ && ch <= 90 /* Z */) { return true; } - if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 2 /* Latest */)) { + if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 4 /* Latest */)) { return false; } // TODO: find a way to determine this for any unicode characters in a @@ -68326,7 +69042,7 @@ var ts; if (ch >= 97 /* a */ && ch <= 122 /* z */) { return true; } - if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 2 /* Latest */)) { + if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 4 /* Latest */)) { return false; } // TODO: find a way to determine this for any unicode characters in a @@ -68547,10 +69263,10 @@ var ts; var externalModule = false; function nextToken() { var token = ts.scanner.scan(); - if (token === 15 /* OpenBraceToken */) { + if (token === 16 /* OpenBraceToken */) { braceNesting++; } - else if (token === 16 /* CloseBraceToken */) { + else if (token === 17 /* CloseBraceToken */) { braceNesting--; } return token; @@ -68601,10 +69317,10 @@ var ts; */ function tryConsumeDeclare() { var token = ts.scanner.getToken(); - if (token === 122 /* DeclareKeyword */) { + if (token === 123 /* DeclareKeyword */) { // declare module "mod" token = nextToken(); - if (token === 125 /* ModuleKeyword */) { + if (token === 126 /* ModuleKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { recordAmbientExternalModule(); @@ -68619,7 +69335,7 @@ var ts; */ function tryConsumeImport() { var token = ts.scanner.getToken(); - if (token === 89 /* ImportKeyword */) { + if (token === 90 /* ImportKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import "mod"; @@ -68627,9 +69343,9 @@ var ts; return true; } else { - if (token === 69 /* Identifier */ || ts.isKeyword(token)) { + if (token === 70 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 136 /* FromKeyword */) { + if (token === 137 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import d from "mod"; @@ -68637,12 +69353,12 @@ var ts; return true; } } - else if (token === 56 /* EqualsToken */) { + else if (token === 57 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } } - else if (token === 24 /* CommaToken */) { + else if (token === 25 /* CommaToken */) { // consume comma and keep going token = nextToken(); } @@ -68651,16 +69367,16 @@ var ts; return true; } } - if (token === 15 /* OpenBraceToken */) { + if (token === 16 /* OpenBraceToken */) { token = nextToken(); // consume "{ a as B, c, d as D}" clauses // make sure that it stops on EOF - while (token !== 16 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 17 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { token = nextToken(); } - if (token === 16 /* CloseBraceToken */) { + if (token === 17 /* CloseBraceToken */) { token = nextToken(); - if (token === 136 /* FromKeyword */) { + if (token === 137 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import {a as A} from "mod"; @@ -68670,13 +69386,13 @@ var ts; } } } - else if (token === 37 /* AsteriskToken */) { + else if (token === 38 /* AsteriskToken */) { token = nextToken(); - if (token === 116 /* AsKeyword */) { + if (token === 117 /* AsKeyword */) { token = nextToken(); - if (token === 69 /* Identifier */ || ts.isKeyword(token)) { + if (token === 70 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 136 /* FromKeyword */) { + if (token === 137 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import * as NS from "mod" @@ -68694,19 +69410,19 @@ var ts; } function tryConsumeExport() { var token = ts.scanner.getToken(); - if (token === 82 /* ExportKeyword */) { + if (token === 83 /* ExportKeyword */) { markAsExternalModuleIfTopLevel(); token = nextToken(); - if (token === 15 /* OpenBraceToken */) { + if (token === 16 /* OpenBraceToken */) { token = nextToken(); // consume "{ a as B, c, d as D}" clauses // make sure it stops on EOF - while (token !== 16 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 17 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { token = nextToken(); } - if (token === 16 /* CloseBraceToken */) { + if (token === 17 /* CloseBraceToken */) { token = nextToken(); - if (token === 136 /* FromKeyword */) { + if (token === 137 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // export {a as A} from "mod"; @@ -68716,9 +69432,9 @@ var ts; } } } - else if (token === 37 /* AsteriskToken */) { + else if (token === 38 /* AsteriskToken */) { token = nextToken(); - if (token === 136 /* FromKeyword */) { + if (token === 137 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // export * from "mod" @@ -68726,11 +69442,11 @@ var ts; } } } - else if (token === 89 /* ImportKeyword */) { + else if (token === 90 /* ImportKeyword */) { token = nextToken(); - if (token === 69 /* Identifier */ || ts.isKeyword(token)) { + if (token === 70 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 56 /* EqualsToken */) { + if (token === 57 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } @@ -68743,9 +69459,9 @@ var ts; } function tryConsumeRequireCall(skipCurrentToken) { var token = skipCurrentToken ? nextToken() : ts.scanner.getToken(); - if (token === 129 /* RequireKeyword */) { + if (token === 130 /* RequireKeyword */) { token = nextToken(); - if (token === 17 /* OpenParenToken */) { + if (token === 18 /* OpenParenToken */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // require("mod"); @@ -68758,16 +69474,16 @@ var ts; } function tryConsumeDefine() { var token = ts.scanner.getToken(); - if (token === 69 /* Identifier */ && ts.scanner.getTokenValue() === "define") { + if (token === 70 /* Identifier */ && ts.scanner.getTokenValue() === "define") { token = nextToken(); - if (token !== 17 /* OpenParenToken */) { + if (token !== 18 /* OpenParenToken */) { return true; } token = nextToken(); if (token === 9 /* StringLiteral */) { // looks like define ("modname", ... - skip string literal and comma token = nextToken(); - if (token === 24 /* CommaToken */) { + if (token === 25 /* CommaToken */) { token = nextToken(); } else { @@ -68776,14 +69492,14 @@ var ts; } } // should be start of dependency list - if (token !== 19 /* OpenBracketToken */) { + if (token !== 20 /* OpenBracketToken */) { return true; } // skip open bracket token = nextToken(); var i = 0; // scan until ']' or EOF - while (token !== 20 /* CloseBracketToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 21 /* CloseBracketToken */ && token !== 1 /* EndOfFileToken */) { // record string literals as module names if (token === 9 /* StringLiteral */) { recordModuleName(); @@ -68873,7 +69589,7 @@ var ts; var canonicalDefaultLibName = getCanonicalFileName(ts.normalizePath(defaultLibFileName)); var node = ts.getTouchingWord(sourceFile, position, /*includeJsDocComment*/ true); if (node) { - if (node.kind === 69 /* Identifier */ || + if (node.kind === 70 /* Identifier */ || node.kind === 9 /* StringLiteral */ || ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || ts.isThis(node)) { @@ -69134,15 +69850,15 @@ var ts; } SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; function createJavaScriptSignatureHelpItems(argumentInfo, program) { - if (argumentInfo.invocation.kind !== 174 /* CallExpression */) { + if (argumentInfo.invocation.kind !== 175 /* 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 === 69 /* Identifier */ + var name = expression.kind === 70 /* Identifier */ ? expression - : expression.kind === 172 /* PropertyAccessExpression */ + : expression.kind === 173 /* PropertyAccessExpression */ ? expression.name : undefined; if (!name || !name.text) { @@ -69175,7 +69891,7 @@ var ts; * in the argument of an invocation; returns undefined otherwise. */ function getImmediatelyContainingArgumentInfo(node, position, sourceFile) { - if (node.parent.kind === 174 /* CallExpression */ || node.parent.kind === 175 /* NewExpression */) { + if (node.parent.kind === 175 /* CallExpression */ || node.parent.kind === 176 /* NewExpression */) { var callExpression = node.parent; // There are 3 cases to handle: // 1. The token introduces a list, and should begin a sig help session @@ -69191,8 +69907,8 @@ var ts; // Case 3: // foo(a#, #b#) -> The token is buried inside a list, and should give sig help // Find out if 'node' is an argument, a type argument, or neither - if (node.kind === 25 /* LessThanToken */ || - node.kind === 17 /* OpenParenToken */) { + if (node.kind === 26 /* LessThanToken */ || + node.kind === 18 /* OpenParenToken */) { // Find the list that starts right *after* the < or ( token. // If the user has just opened a list, consider this item 0. var list = getChildListThatStartsWithOpenerToken(callExpression, node, sourceFile); @@ -69229,27 +69945,27 @@ var ts; } return undefined; } - else if (node.kind === 11 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 176 /* TaggedTemplateExpression */) { + else if (node.kind === 12 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 177 /* 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, sourceFile); } } - else if (node.kind === 12 /* TemplateHead */ && node.parent.parent.kind === 176 /* TaggedTemplateExpression */) { + else if (node.kind === 13 /* TemplateHead */ && node.parent.parent.kind === 177 /* TaggedTemplateExpression */) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 189 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 190 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } - else if (node.parent.kind === 197 /* TemplateSpan */ && node.parent.parent.parent.kind === 176 /* TaggedTemplateExpression */) { + else if (node.parent.kind === 198 /* TemplateSpan */ && node.parent.parent.parent.kind === 177 /* TaggedTemplateExpression */) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 189 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 190 /* TemplateExpression */); // If we're just after a template tail, don't show signature help. - if (node.kind === 14 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { + if (node.kind === 15 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { return undefined; } var spanIndex = templateExpression.templateSpans.indexOf(templateSpan); @@ -69277,7 +69993,7 @@ var ts; if (child === node) { break; } - if (child.kind !== 24 /* CommaToken */) { + if (child.kind !== 25 /* CommaToken */) { argumentIndex++; } } @@ -69296,8 +70012,8 @@ var ts; // That will give us 2 non-commas. We then add one for the last comma, givin us an // arg count of 3. var listChildren = argumentsList.getChildren(); - var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 24 /* CommaToken */; }); - if (listChildren.length > 0 && ts.lastOrUndefined(listChildren).kind === 24 /* CommaToken */) { + var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 25 /* CommaToken */; }); + if (listChildren.length > 0 && ts.lastOrUndefined(listChildren).kind === 25 /* CommaToken */) { argumentCount++; } return argumentCount; @@ -69327,7 +70043,7 @@ var ts; } function getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile) { // argumentCount is either 1 or (numSpans + 1) to account for the template strings array argument. - var argumentCount = tagExpression.template.kind === 11 /* NoSubstitutionTemplateLiteral */ + var argumentCount = tagExpression.template.kind === 12 /* NoSubstitutionTemplateLiteral */ ? 1 : tagExpression.template.templateSpans.length + 1; ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); @@ -69365,7 +70081,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 === 189 /* TemplateExpression */) { + if (template.kind === 190 /* TemplateExpression */) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -69435,10 +70151,10 @@ var ts; ts.addRange(prefixDisplayParts, callTargetDisplayParts); } if (isTypeParameterList) { - prefixDisplayParts.push(ts.punctuationPart(25 /* LessThanToken */)); + prefixDisplayParts.push(ts.punctuationPart(26 /* LessThanToken */)); var typeParameters = candidateSignature.typeParameters; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(27 /* GreaterThanToken */)); + suffixDisplayParts.push(ts.punctuationPart(28 /* GreaterThanToken */)); var parameterParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.thisParameter, candidateSignature.parameters, writer, invocation); }); @@ -69449,10 +70165,10 @@ var ts; return typeChecker.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation); }); ts.addRange(prefixDisplayParts, typeParameterParts); - prefixDisplayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); + prefixDisplayParts.push(ts.punctuationPart(18 /* OpenParenToken */)); var parameters = candidateSignature.parameters; signatureHelpParameters = parameters.length > 0 ? ts.map(parameters, createSignatureHelpParameterForParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); + suffixDisplayParts.push(ts.punctuationPart(19 /* CloseParenToken */)); } var returnTypeParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation); @@ -69462,7 +70178,7 @@ var ts; isVariadic: candidateSignature.hasRestParameter, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: suffixDisplayParts, - separatorDisplayParts: [ts.punctuationPart(24 /* CommaToken */), ts.spacePart()], + separatorDisplayParts: [ts.punctuationPart(25 /* CommaToken */), ts.spacePart()], parameters: signatureHelpParameters, documentation: candidateSignature.getDocumentationComment() }; @@ -69516,7 +70232,7 @@ var ts; function getSymbolKind(typeChecker, symbol, location) { var flags = symbol.getFlags(); if (flags & 32 /* Class */) - return ts.getDeclarationOfKind(symbol, 192 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 193 /* ClassExpression */) ? ts.ScriptElementKind.localClassElement : ts.ScriptElementKind.classElement; if (flags & 384 /* Enum */) return ts.ScriptElementKind.enumElement; @@ -69547,7 +70263,7 @@ var ts; if (typeChecker.isArgumentsSymbol(symbol)) { return ts.ScriptElementKind.localVariableElement; } - if (location.kind === 97 /* ThisKeyword */ && ts.isExpression(location)) { + if (location.kind === 98 /* ThisKeyword */ && ts.isExpression(location)) { return ts.ScriptElementKind.parameterElement; } if (flags & 3 /* Variable */) { @@ -69611,7 +70327,7 @@ var ts; var symbolFlags = symbol.flags; var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, symbolFlags, location); var hasAddedSymbolInfo; - var isThisExpression = location.kind === 97 /* ThisKeyword */ && ts.isExpression(location); + var isThisExpression = location.kind === 98 /* ThisKeyword */ && ts.isExpression(location); var type; // Class at constructor site need to be shown as constructor apart from property,method, vars if (symbolKind !== ts.ScriptElementKind.unknown || symbolFlags & 32 /* Class */ || symbolFlags & 8388608 /* Alias */) { @@ -69622,7 +70338,7 @@ var ts; var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 172 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 173 /* 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)) { @@ -69631,7 +70347,7 @@ var ts; } // try get the call/construct signature from the type if it matches var callExpression = void 0; - if (location.kind === 174 /* CallExpression */ || location.kind === 175 /* NewExpression */) { + if (location.kind === 175 /* CallExpression */ || location.kind === 176 /* NewExpression */) { callExpression = location; } else if (ts.isCallExpressionTarget(location) || ts.isNewExpressionTarget(location)) { @@ -69644,7 +70360,7 @@ var ts; // Use the first candidate: signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 175 /* NewExpression */ || callExpression.expression.kind === 95 /* SuperKeyword */; + var useConstructSignatures = callExpression.kind === 176 /* NewExpression */ || callExpression.expression.kind === 96 /* SuperKeyword */; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { // Get the first signature if there is one -- allSignatures may contain @@ -69662,7 +70378,7 @@ var ts; pushTypePart(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(92 /* NewKeyword */)); + displayParts.push(ts.keywordPart(93 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -69678,10 +70394,10 @@ var ts; case ts.ScriptElementKind.parameterElement: case ts.ScriptElementKind.localVariableElement: // If it is call or construct signature of lambda's write type name - displayParts.push(ts.punctuationPart(54 /* ColonToken */)); + displayParts.push(ts.punctuationPart(55 /* ColonToken */)); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(92 /* NewKeyword */)); + displayParts.push(ts.keywordPart(93 /* NewKeyword */)); displayParts.push(ts.spacePart()); } if (!(type.flags & 2097152 /* Anonymous */) && type.symbol) { @@ -69697,24 +70413,24 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304 /* Accessor */)) || - (location.kind === 121 /* ConstructorKeyword */ && location.parent.kind === 148 /* Constructor */)) { + (location.kind === 122 /* ConstructorKeyword */ && location.parent.kind === 149 /* Constructor */)) { // get the signature from the declaration and write it var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 148 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration.kind === 149 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 148 /* Constructor */) { + if (functionDeclaration.kind === 149 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = ts.ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 151 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 152 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -69723,7 +70439,7 @@ var ts; } } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { - if (ts.getDeclarationOfKind(symbol, 192 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 193 /* 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 @@ -69731,7 +70447,7 @@ var ts; } else { // Class declaration has name which is not local. - displayParts.push(ts.keywordPart(73 /* ClassKeyword */)); + displayParts.push(ts.keywordPart(74 /* ClassKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); @@ -69739,49 +70455,49 @@ var ts; } if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(107 /* InterfaceKeyword */)); + displayParts.push(ts.keywordPart(108 /* InterfaceKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if (symbolFlags & 524288 /* TypeAlias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(134 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(135 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(56 /* EqualsToken */)); + displayParts.push(ts.operatorPart(57 /* EqualsToken */)); displayParts.push(ts.spacePart()); ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 512 /* InTypeAlias */)); } if (symbolFlags & 384 /* Enum */) { addNewLineIfDisplayPartsExist(); if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { - displayParts.push(ts.keywordPart(74 /* ConstKeyword */)); + displayParts.push(ts.keywordPart(75 /* ConstKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(81 /* EnumKeyword */)); + displayParts.push(ts.keywordPart(82 /* EnumKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536 /* Module */) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 225 /* ModuleDeclaration */); - var isNamespace = declaration && declaration.name && declaration.name.kind === 69 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 126 /* NamespaceKeyword */ : 125 /* ModuleKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 226 /* ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 70 /* Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 127 /* NamespaceKeyword */ : 126 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if ((symbolFlags & 262144 /* TypeParameter */) && (semanticMeaning & 2 /* Type */)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(18 /* OpenParenToken */)); displayParts.push(ts.textPart("type parameter")); - displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(19 /* CloseParenToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(90 /* InKeyword */)); + displayParts.push(ts.keywordPart(91 /* InKeyword */)); displayParts.push(ts.spacePart()); if (symbol.parent) { // Class/Interface type parameter @@ -69790,17 +70506,17 @@ var ts; } else { // Method/function type parameter - var declaration = ts.getDeclarationOfKind(symbol, 141 /* TypeParameter */); + var declaration = ts.getDeclarationOfKind(symbol, 142 /* TypeParameter */); ts.Debug.assert(declaration !== undefined); declaration = declaration.parent; if (declaration) { if (ts.isFunctionLikeKind(declaration.kind)) { var signature = typeChecker.getSignatureFromDeclaration(declaration); - if (declaration.kind === 152 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(92 /* NewKeyword */)); + if (declaration.kind === 153 /* ConstructSignature */) { + displayParts.push(ts.keywordPart(93 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 151 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 152 /* CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); @@ -69809,7 +70525,7 @@ var ts; // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path - displayParts.push(ts.keywordPart(134 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(135 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -69824,7 +70540,7 @@ var ts; var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(56 /* EqualsToken */)); + displayParts.push(ts.operatorPart(57 /* EqualsToken */)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(constantValue.toString(), ts.SymbolDisplayPartKind.numericLiteral)); } @@ -69832,33 +70548,33 @@ var ts; } if (symbolFlags & 8388608 /* Alias */) { addNewLineIfDisplayPartsExist(); - if (symbol.declarations[0].kind === 228 /* NamespaceExportDeclaration */) { - displayParts.push(ts.keywordPart(82 /* ExportKeyword */)); + if (symbol.declarations[0].kind === 229 /* NamespaceExportDeclaration */) { + displayParts.push(ts.keywordPart(83 /* ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(126 /* NamespaceKeyword */)); + displayParts.push(ts.keywordPart(127 /* NamespaceKeyword */)); } else { - displayParts.push(ts.keywordPart(89 /* ImportKeyword */)); + displayParts.push(ts.keywordPart(90 /* ImportKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 229 /* ImportEqualsDeclaration */) { + if (declaration.kind === 230 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(56 /* EqualsToken */)); + displayParts.push(ts.operatorPart(57 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(129 /* RequireKeyword */)); - displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); + displayParts.push(ts.keywordPart(130 /* RequireKeyword */)); + displayParts.push(ts.punctuationPart(18 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); - displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(19 /* CloseParenToken */)); } else { var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(56 /* EqualsToken */)); + displayParts.push(ts.operatorPart(57 /* EqualsToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -69872,7 +70588,7 @@ var ts; if (type) { if (isThisExpression) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(97 /* ThisKeyword */)); + displayParts.push(ts.keywordPart(98 /* ThisKeyword */)); } else { addPrefixForAnyFunctionOrVar(symbol, symbolKind); @@ -69882,7 +70598,7 @@ var ts; symbolFlags & 3 /* Variable */ || symbolKind === ts.ScriptElementKind.localVariableElement || isThisExpression) { - displayParts.push(ts.punctuationPart(54 /* ColonToken */)); + displayParts.push(ts.punctuationPart(55 /* ColonToken */)); displayParts.push(ts.spacePart()); // If the type is type parameter, format it specially if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) { @@ -69919,7 +70635,7 @@ var ts; if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 256 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 187 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 188 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -69962,9 +70678,9 @@ var ts; displayParts.push(ts.textOrKeywordPart(symbolKind)); return; default: - displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(18 /* OpenParenToken */)); displayParts.push(ts.textOrKeywordPart(symbolKind)); - displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(19 /* CloseParenToken */)); return; } } @@ -69972,12 +70688,12 @@ var ts; ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32 /* WriteTypeArgumentsOfSignature */)); if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); - displayParts.push(ts.punctuationPart(17 /* OpenParenToken */)); - displayParts.push(ts.operatorPart(35 /* PlusToken */)); + displayParts.push(ts.punctuationPart(18 /* OpenParenToken */)); + displayParts.push(ts.operatorPart(36 /* PlusToken */)); displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), ts.SymbolDisplayPartKind.numericLiteral)); displayParts.push(ts.spacePart()); displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); - displayParts.push(ts.punctuationPart(18 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(19 /* CloseParenToken */)); } documentation = signature.getDocumentationComment(); } @@ -69995,16 +70711,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 179 /* FunctionExpression */) { + if (declaration.kind === 180 /* FunctionExpression */) { return true; } - if (declaration.kind !== 218 /* VariableDeclaration */ && declaration.kind !== 220 /* FunctionDeclaration */) { + if (declaration.kind !== 219 /* VariableDeclaration */ && declaration.kind !== 221 /* FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable for (var parent_23 = declaration.parent; !ts.isFunctionBlock(parent_23); parent_23 = parent_23.parent) { // Reached source file or module block - if (parent_23.kind === 256 /* SourceFile */ || parent_23.kind === 226 /* ModuleBlock */) { + if (parent_23.kind === 256 /* SourceFile */ || parent_23.kind === 227 /* ModuleBlock */) { return false; } } @@ -70065,8 +70781,8 @@ var ts; var sourceMapText; // Create a compilerHost object to allow the compiler to read and write files var compilerHost = { - getSourceFile: function (fileName, target) { return fileName === ts.normalizePath(inputFileName) ? sourceFile : undefined; }, - writeFile: function (name, text, writeByteOrderMark) { + getSourceFile: function (fileName) { return fileName === ts.normalizePath(inputFileName) ? sourceFile : undefined; }, + writeFile: function (name, text) { if (ts.fileExtensionIs(name, ".map")) { ts.Debug.assert(sourceMapText === undefined, "Unexpected multiple source map outputs for the file '" + name + "'"); sourceMapText = text; @@ -70082,9 +70798,9 @@ var ts; getCurrentDirectory: function () { return ""; }, getNewLine: function () { return newLine; }, fileExists: function (fileName) { return fileName === inputFileName; }, - readFile: function (fileName) { return ""; }, - directoryExists: function (directoryExists) { return true; }, - getDirectories: function (path) { return []; } + readFile: function () { return ""; }, + directoryExists: function () { return true; }, + getDirectories: function () { return []; } }; var program = ts.createProgram([inputFileName], options, compilerHost); if (transpileOptions.reportDiagnostics) { @@ -70146,8 +70862,8 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var standardScanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); - var jsxScanner = ts.createScanner(2 /* Latest */, /*skipTrivia*/ false, 1 /* JSX */); + var standardScanner = ts.createScanner(4 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); + var jsxScanner = ts.createScanner(4 /* Latest */, /*skipTrivia*/ false, 1 /* JSX */); /** * Scanner that is currently used for formatting */ @@ -70162,7 +70878,7 @@ var ts; ScanAction[ScanAction["RescanJsxText"] = 5] = "RescanJsxText"; })(ScanAction || (ScanAction = {})); function getFormattingScanner(sourceFile, startPos, endPos) { - ts.Debug.assert(scanner === undefined); + ts.Debug.assert(scanner === undefined, "Scanner should be undefined"); scanner = sourceFile.languageVariant === 1 /* JSX */ ? jsxScanner : standardScanner; scanner.setText(sourceFile.text); scanner.setTextPos(startPos); @@ -70187,7 +70903,7 @@ var ts; } }; function advance() { - ts.Debug.assert(scanner !== undefined); + ts.Debug.assert(scanner !== undefined, "Scanner should be present"); lastTokenInfo = undefined; var isStarted = scanner.getStartPos() !== startPos; if (isStarted) { @@ -70229,11 +70945,11 @@ var ts; function shouldRescanGreaterThanToken(node) { if (node) { switch (node.kind) { - case 29 /* GreaterThanEqualsToken */: - case 64 /* GreaterThanGreaterThanEqualsToken */: - case 65 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 45 /* GreaterThanGreaterThanGreaterThanToken */: - case 44 /* GreaterThanGreaterThanToken */: + case 30 /* GreaterThanEqualsToken */: + case 65 /* GreaterThanGreaterThanEqualsToken */: + case 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 46 /* GreaterThanGreaterThanGreaterThanToken */: + case 45 /* GreaterThanGreaterThanToken */: return true; } } @@ -70243,26 +70959,26 @@ var ts; if (node.parent) { switch (node.parent.kind) { case 246 /* JsxAttribute */: - case 243 /* JsxOpeningElement */: + case 244 /* JsxOpeningElement */: case 245 /* JsxClosingElement */: - case 242 /* JsxSelfClosingElement */: - return node.kind === 69 /* Identifier */; + case 243 /* JsxSelfClosingElement */: + return node.kind === 70 /* Identifier */; } } return false; } function shouldRescanJsxText(node) { - return node && node.kind === 244 /* JsxText */; + return node && node.kind === 10 /* JsxText */; } function shouldRescanSlashToken(container) { - return container.kind === 10 /* RegularExpressionLiteral */; + return container.kind === 11 /* RegularExpressionLiteral */; } function shouldRescanTemplateToken(container) { - return container.kind === 13 /* TemplateMiddle */ || - container.kind === 14 /* TemplateTail */; + return container.kind === 14 /* TemplateMiddle */ || + container.kind === 15 /* TemplateTail */; } function startsWithSlashToken(t) { - return t === 39 /* SlashToken */ || t === 61 /* SlashEqualsToken */; + return t === 40 /* SlashToken */ || t === 62 /* SlashEqualsToken */; } function readTokenInfo(n) { ts.Debug.assert(scanner !== undefined); @@ -70303,7 +71019,7 @@ var ts; scanner.scan(); } var currentToken = scanner.getToken(); - if (expectedScanAction === 1 /* RescanGreaterThanToken */ && currentToken === 27 /* GreaterThanToken */) { + if (expectedScanAction === 1 /* RescanGreaterThanToken */ && currentToken === 28 /* GreaterThanToken */) { currentToken = scanner.reScanGreaterToken(); ts.Debug.assert(n.kind === currentToken); lastScanAction = 1 /* RescanGreaterThanToken */; @@ -70313,11 +71029,11 @@ var ts; ts.Debug.assert(n.kind === currentToken); lastScanAction = 2 /* RescanSlashToken */; } - else if (expectedScanAction === 3 /* RescanTemplateToken */ && currentToken === 16 /* CloseBraceToken */) { + else if (expectedScanAction === 3 /* RescanTemplateToken */ && currentToken === 17 /* CloseBraceToken */) { currentToken = scanner.reScanTemplateToken(); lastScanAction = 3 /* RescanTemplateToken */; } - else if (expectedScanAction === 4 /* RescanJsxIdentifier */ && currentToken === 69 /* Identifier */) { + else if (expectedScanAction === 4 /* RescanJsxIdentifier */ && currentToken === 70 /* Identifier */) { currentToken = scanner.scanJsxIdentifier(); lastScanAction = 4 /* RescanJsxIdentifier */; } @@ -70460,8 +71176,8 @@ var ts; return startLine === endLine; }; FormattingContext.prototype.BlockIsOnOneLine = function (node) { - var openBrace = ts.findChildOfKind(node, 15 /* OpenBraceToken */, this.sourceFile); - var closeBrace = ts.findChildOfKind(node, 16 /* CloseBraceToken */, this.sourceFile); + var openBrace = ts.findChildOfKind(node, 16 /* OpenBraceToken */, this.sourceFile); + var closeBrace = ts.findChildOfKind(node, 17 /* CloseBraceToken */, this.sourceFile); if (openBrace && closeBrace) { var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line; var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line; @@ -70649,125 +71365,125 @@ var ts; this.IgnoreBeforeComment = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.Comments), formatting.RuleOperation.create1(1 /* Ignore */)); 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.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54 /* ColonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 24 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 55 /* ColonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(55 /* ColonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 2 /* Space */)); + this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsConditionalOperatorContext), 2 /* Space */)); + this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 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.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2 /* Space */)); + this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* CloseBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, 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 */, 80 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* CloseBraceToken */, 104 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 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.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* CloseBraceToken */, 81 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* CloseBraceToken */, 105 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* CloseBraceToken */, formatting.Shared.TokenRange.FromTokens([19 /* CloseParenToken */, 21 /* CloseBracketToken */, 25 /* CommaToken */, 24 /* SemicolonToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 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.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(21 /* DotToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 22 /* DotToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(22 /* DotToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // No space before and after indexer - this.NoSpaceBeforeOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19 /* OpenBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20 /* CloseBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), 8 /* Delete */)); + this.NoSpaceBeforeOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* OpenBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(21 /* CloseBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), 8 /* Delete */)); // Place a space before open brace in a function declaration 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 */); + this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 16 /* 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([69 /* Identifier */, 3 /* MultiLineCommentTrivia */, 73 /* ClassKeyword */, 82 /* ExportKeyword */, 89 /* ImportKeyword */]); - 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 */); + this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([70 /* Identifier */, 3 /* MultiLineCommentTrivia */, 74 /* ClassKeyword */, 83 /* ExportKeyword */, 90 /* ImportKeyword */]); + this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 16 /* 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 */, 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 */); + this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([19 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 80 /* DoKeyword */, 101 /* TryKeyword */, 86 /* FinallyKeyword */, 81 /* ElseKeyword */]); + this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 16 /* 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 */)); - this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); - this.NoSpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 8 /* Delete */)); - this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* OpenBraceToken */, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectContext), 8 /* Delete */)); + this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); + this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); + this.NoSpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 8 /* Delete */)); + this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* OpenBraceToken */, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectContext), 8 /* Delete */)); // Insert new line after { and before } in multi-line contexts. - this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); + this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); // For functions and control block place } on a new line [multi-line rule] - this.NewLineBeforeCloseBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.AnyIncludingMultilineComments, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); + this.NewLineBeforeCloseBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.AnyIncludingMultilineComments, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); // Special handling of unary operators. // 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.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(41 /* PlusPlusToken */, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(42 /* MinusMinusToken */, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 41 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 42 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(42 /* PlusPlusToken */, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(43 /* MinusMinusToken */, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 42 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 43 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 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(41 /* PlusPlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 35 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* PlusToken */, 41 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(42 /* MinusMinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 42 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - 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.IsNonJsxSameLineTokenContext), 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.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */)); - 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.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 8 /* Delete */)); - this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(103 /* VoidKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsVoidOpContext), 2 /* Space */)); - this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(94 /* ReturnKeyword */, 23 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(42 /* PlusPlusToken */, 36 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* PlusToken */, 36 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* PlusToken */, 42 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(43 /* MinusMinusToken */, 37 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(37 /* MinusToken */, 37 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(37 /* MinusToken */, 43 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 25 /* CommaToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([103 /* VarKeyword */, 99 /* ThrowKeyword */, 93 /* NewKeyword */, 79 /* DeleteKeyword */, 95 /* ReturnKeyword */, 102 /* TypeOfKeyword */, 120 /* AwaitKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([109 /* LetKeyword */, 75 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */)); + this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */)); + this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(88 /* 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, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 8 /* Delete */)); + this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(104 /* VoidKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsVoidOpContext), 2 /* Space */)); + this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(95 /* ReturnKeyword */, 24 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 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 */, 79 /* DoKeyword */, 80 /* ElseKeyword */, 71 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNotForContext), 2 /* Space */)); + this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([19 /* CloseParenToken */, 80 /* DoKeyword */, 81 /* ElseKeyword */, 72 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, 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([100 /* TryKeyword */, 85 /* FinallyKeyword */]), 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([101 /* TryKeyword */, 86 /* FinallyKeyword */]), 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // get x() {} // set x(val) {} - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123 /* GetKeyword */, 131 /* SetKeyword */]), 69 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([124 /* GetKeyword */, 132 /* SetKeyword */]), 70 /* 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.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, 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(121 /* ConstructorKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(122 /* ConstructorKeyword */, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 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([125 /* ModuleKeyword */, 129 /* RequireKeyword */]), 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([126 /* ModuleKeyword */, 130 /* RequireKeyword */]), 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // Add a space around certain TypeScript keywords - 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 */, 131 /* SetKeyword */, 113 /* StaticKeyword */, 134 /* TypeKeyword */, 136 /* FromKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([83 /* ExtendsKeyword */, 106 /* ImplementsKeyword */, 136 /* FromKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116 /* AbstractKeyword */, 74 /* ClassKeyword */, 123 /* DeclareKeyword */, 78 /* DefaultKeyword */, 82 /* EnumKeyword */, 83 /* ExportKeyword */, 84 /* ExtendsKeyword */, 124 /* GetKeyword */, 107 /* ImplementsKeyword */, 90 /* ImportKeyword */, 108 /* InterfaceKeyword */, 126 /* ModuleKeyword */, 127 /* NamespaceKeyword */, 111 /* PrivateKeyword */, 113 /* PublicKeyword */, 112 /* ProtectedKeyword */, 132 /* SetKeyword */, 114 /* StaticKeyword */, 135 /* TypeKeyword */, 137 /* FromKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([84 /* ExtendsKeyword */, 107 /* ImplementsKeyword */, 137 /* FromKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 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 */)); + this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9 /* StringLiteral */, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); // Lambda expressions - this.SpaceBeforeArrow = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 34 /* EqualsGreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(34 /* EqualsGreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeArrow = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 35 /* EqualsGreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(35 /* EqualsGreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // Optional parameters and let args - this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(22 /* DotDotDotToken */, 69 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 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.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(23 /* DotDotDotToken */, 70 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([19 /* CloseParenToken */, 25 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); - this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(18 /* CloseParenToken */, 25 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); - this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(25 /* LessThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 27 /* GreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); - this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(27 /* GreaterThanToken */, formatting.Shared.TokenRange.FromTokens([17 /* OpenParenToken */, 19 /* OpenBracketToken */, 27 /* GreaterThanToken */, 24 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 26 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(19 /* CloseParenToken */, 26 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(26 /* LessThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 28 /* GreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(28 /* GreaterThanToken */, formatting.Shared.TokenRange.FromTokens([18 /* OpenParenToken */, 20 /* OpenBracketToken */, 28 /* GreaterThanToken */, 25 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); // 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.IsNonJsxSameLineTokenContext, Rules.IsObjectTypeContext), 8 /* Delete */)); + this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* OpenBraceToken */, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectTypeContext), 8 /* Delete */)); // decorators - this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 55 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(55 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 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 */, 131 /* 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.IsNonJsxSameLineTokenContext, 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.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */)); + this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 56 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(56 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([116 /* AbstractKeyword */, 70 /* Identifier */, 83 /* ExportKeyword */, 78 /* DefaultKeyword */, 74 /* ClassKeyword */, 114 /* StaticKeyword */, 113 /* PublicKeyword */, 111 /* PrivateKeyword */, 112 /* ProtectedKeyword */, 124 /* GetKeyword */, 132 /* SetKeyword */, 20 /* OpenBracketToken */, 38 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); + this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(88 /* FunctionKeyword */, 38 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); + this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(38 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([70 /* Identifier */, 18 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); + this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(115 /* YieldKeyword */, 38 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); + this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([115 /* YieldKeyword */, 38 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */)); // Async-await - this.SpaceBetweenAsyncAndOpenParen = new formatting.Rule(formatting.RuleDescriptor.create1(118 /* AsyncKeyword */, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(118 /* AsyncKeyword */, 87 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenAsyncAndOpenParen = new formatting.Rule(formatting.RuleDescriptor.create1(119 /* AsyncKeyword */, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(119 /* AsyncKeyword */, 88 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // template string - this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(69 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(70 /* Identifier */, formatting.Shared.TokenRange.FromTokens([12 /* NoSubstitutionTemplateLiteral */, 13 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // jsx opening element - this.SpaceBeforeJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 69 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNextTokenParentJsxAttribute, Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeSlashInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 39 /* SlashToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create1(39 /* SlashToken */, 27 /* GreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 56 /* EqualsToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create3(56 /* EqualsToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceBeforeJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 70 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNextTokenParentJsxAttribute, Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeSlashInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 40 /* SlashToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create1(40 /* SlashToken */, 28 /* GreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 57 /* EqualsToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create3(57 /* EqualsToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // These rules are higher in priority than user-configurable rules. this.HighPriorityCommonRules = [ this.IgnoreBeforeComment, this.IgnoreAfterLineComment, @@ -70829,54 +71545,54 @@ var ts; /// Rules controlled by user options /// // Insert space after comma delimiter - this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNextTokenNotCloseBracket), 2 /* Space */)); - this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext), 8 /* Delete */)); + this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(25 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNextTokenNotCloseBracket), 2 /* Space */)); + this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(25 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext), 8 /* Delete */)); // Insert space before and after binary operators this.SpaceBeforeBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.SpaceAfterBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.NoSpaceBeforeBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 8 /* Delete */)); this.NoSpaceAfterBinaryOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 8 /* Delete */)); // Insert space after keywords in control flow statements - this.SpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 2 /* Space */)); - this.NoSpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 8 /* Delete */)); + this.SpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 2 /* Space */)); + this.NoSpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 8 /* Delete */)); // Open Brace braces after function // TypeScript: Function can have return types, which can be made of tons of different token kinds - this.NewLineBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); + this.NewLineBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); // Open Brace braces after TypeScript module/class/interface - this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); + this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); // Open Brace braces after control block - this.NewLineBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); + this.NewLineBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); // Insert space after semicolon in for statement - this.SpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 2 /* Space */)); - this.NoSpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 8 /* Delete */)); + this.SpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 2 /* Space */)); + this.NoSpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 8 /* Delete */)); // Insert space after opening and before closing nonempty parenthesis - this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* OpenParenToken */, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(18 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(18 /* OpenParenToken */, 19 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(18 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // Insert space after opening and before closing nonempty brackets - this.SpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.NoSpaceBetweenBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(19 /* OpenBracketToken */, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBetweenBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(20 /* OpenBracketToken */, 21 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20 /* OpenBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // Insert space after opening and before closing template string braces - 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.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterTemplateHeadAndMiddle = 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.IsNonJsxSameLineTokenContext), 2 /* Space */)); - 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.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.SpaceBeforeTemplateMiddleAndTail = 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.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([13 /* TemplateHead */, 14 /* TemplateMiddle */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([13 /* TemplateHead */, 14 /* TemplateMiddle */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([14 /* TemplateMiddle */, 15 /* TemplateTail */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceBeforeTemplateMiddleAndTail = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([14 /* TemplateMiddle */, 15 /* TemplateTail */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // No space after { and before } in JSX expression - this.NoSpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8 /* Delete */)); - this.SpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2 /* Space */)); - this.NoSpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8 /* Delete */)); - this.SpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2 /* Space */)); + this.NoSpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8 /* Delete */)); + this.SpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2 /* Space */)); + this.NoSpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8 /* Delete */)); + this.SpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2 /* Space */)); // Insert space after function keyword for anonymous functions - 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 */)); + this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(88 /* FunctionKeyword */, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(88 /* FunctionKeyword */, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8 /* Delete */)); // No space after type assertion - this.NoSpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(27 /* GreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 8 /* Delete */)); - this.SpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(27 /* GreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 2 /* Space */)); + this.NoSpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(28 /* GreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 8 /* Delete */)); + this.SpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(28 /* GreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 2 /* Space */)); } Rules.prototype.getRuleName = function (rule) { var o = this; @@ -70891,42 +71607,42 @@ var ts; /// Contexts /// Rules.IsForContext = function (context) { - return context.contextNode.kind === 206 /* ForStatement */; + return context.contextNode.kind === 207 /* ForStatement */; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 187 /* BinaryExpression */: - case 188 /* ConditionalExpression */: - case 195 /* AsExpression */: - case 238 /* ExportSpecifier */: - case 234 /* ImportSpecifier */: - case 154 /* TypePredicate */: - case 162 /* UnionType */: - case 163 /* IntersectionType */: + case 188 /* BinaryExpression */: + case 189 /* ConditionalExpression */: + case 196 /* AsExpression */: + case 239 /* ExportSpecifier */: + case 235 /* ImportSpecifier */: + case 155 /* TypePredicate */: + case 163 /* UnionType */: + case 164 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 169 /* BindingElement */: + case 170 /* BindingElement */: // equals in type X = ... - case 223 /* TypeAliasDeclaration */: + case 224 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 229 /* ImportEqualsDeclaration */: + case 230 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 218 /* VariableDeclaration */: + case 219 /* VariableDeclaration */: // equal in p = 0; - case 142 /* Parameter */: + case 143 /* Parameter */: case 255 /* EnumMember */: - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: - return context.currentTokenSpan.kind === 56 /* EqualsToken */ || context.nextTokenSpan.kind === 56 /* EqualsToken */; + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: + return context.currentTokenSpan.kind === 57 /* EqualsToken */ || context.nextTokenSpan.kind === 57 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 207 /* ForInStatement */: - return context.currentTokenSpan.kind === 90 /* InKeyword */ || context.nextTokenSpan.kind === 90 /* InKeyword */; + case 208 /* ForInStatement */: + return context.currentTokenSpan.kind === 91 /* InKeyword */ || context.nextTokenSpan.kind === 91 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 208 /* ForOfStatement */: - return context.currentTokenSpan.kind === 138 /* OfKeyword */ || context.nextTokenSpan.kind === 138 /* OfKeyword */; + case 209 /* ForOfStatement */: + return context.currentTokenSpan.kind === 139 /* OfKeyword */ || context.nextTokenSpan.kind === 139 /* OfKeyword */; } return false; }; @@ -70934,7 +71650,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 188 /* ConditionalExpression */; + return context.contextNode.kind === 189 /* ConditionalExpression */; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. @@ -70978,81 +71694,81 @@ var ts; return true; } switch (node.kind) { - case 199 /* Block */: - case 227 /* CaseBlock */: - case 171 /* ObjectLiteralExpression */: - case 226 /* ModuleBlock */: + case 200 /* Block */: + case 228 /* CaseBlock */: + case 172 /* ObjectLiteralExpression */: + case 227 /* ModuleBlock */: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 220 /* FunctionDeclaration */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 221 /* FunctionDeclaration */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: // case SyntaxKind.MethodSignature: - case 151 /* CallSignature */: - case 179 /* FunctionExpression */: - case 148 /* Constructor */: - case 180 /* ArrowFunction */: + case 152 /* CallSignature */: + case 180 /* FunctionExpression */: + case 149 /* Constructor */: + case 181 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 222 /* InterfaceDeclaration */: + case 223 /* InterfaceDeclaration */: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 220 /* FunctionDeclaration */ || context.contextNode.kind === 179 /* FunctionExpression */; + return context.contextNode.kind === 221 /* FunctionDeclaration */ || context.contextNode.kind === 180 /* FunctionExpression */; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - case 222 /* InterfaceDeclaration */: - case 224 /* EnumDeclaration */: - case 159 /* TypeLiteral */: - case 225 /* ModuleDeclaration */: - case 236 /* ExportDeclaration */: - case 237 /* NamedExports */: - case 230 /* ImportDeclaration */: - case 233 /* NamedImports */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 223 /* InterfaceDeclaration */: + case 225 /* EnumDeclaration */: + case 160 /* TypeLiteral */: + case 226 /* ModuleDeclaration */: + case 237 /* ExportDeclaration */: + case 238 /* NamedExports */: + case 231 /* ImportDeclaration */: + case 234 /* NamedImports */: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 221 /* ClassDeclaration */: - case 225 /* ModuleDeclaration */: - case 224 /* EnumDeclaration */: - case 199 /* Block */: + case 222 /* ClassDeclaration */: + case 226 /* ModuleDeclaration */: + case 225 /* EnumDeclaration */: + case 200 /* Block */: case 252 /* CatchClause */: - case 226 /* ModuleBlock */: - case 213 /* SwitchStatement */: + case 227 /* ModuleBlock */: + case 214 /* SwitchStatement */: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 203 /* IfStatement */: - case 213 /* SwitchStatement */: - case 206 /* ForStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: - case 205 /* WhileStatement */: - case 216 /* TryStatement */: - case 204 /* DoStatement */: - case 212 /* WithStatement */: + case 204 /* IfStatement */: + case 214 /* SwitchStatement */: + case 207 /* ForStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: + case 206 /* WhileStatement */: + case 217 /* TryStatement */: + case 205 /* DoStatement */: + case 213 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: case 252 /* CatchClause */: @@ -71062,31 +71778,31 @@ var ts; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 171 /* ObjectLiteralExpression */; + return context.contextNode.kind === 172 /* ObjectLiteralExpression */; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 174 /* CallExpression */; + return context.contextNode.kind === 175 /* CallExpression */; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 175 /* NewExpression */; + return context.contextNode.kind === 176 /* NewExpression */; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); }; Rules.IsPreviousTokenNotComma = function (context) { - return context.currentTokenSpan.kind !== 24 /* CommaToken */; + return context.currentTokenSpan.kind !== 25 /* CommaToken */; }; Rules.IsNextTokenNotCloseBracket = function (context) { - return context.nextTokenSpan.kind !== 20 /* CloseBracketToken */; + return context.nextTokenSpan.kind !== 21 /* CloseBracketToken */; }; Rules.IsArrowFunctionContext = function (context) { - return context.contextNode.kind === 180 /* ArrowFunction */; + return context.contextNode.kind === 181 /* ArrowFunction */; }; Rules.IsNonJsxSameLineTokenContext = function (context) { - return context.TokensAreOnSameLine() && context.contextNode.kind !== 244 /* JsxText */; + return context.TokensAreOnSameLine() && context.contextNode.kind !== 10 /* JsxText */; }; Rules.IsNonJsxElementContext = function (context) { - return context.contextNode.kind !== 241 /* JsxElement */; + return context.contextNode.kind !== 242 /* JsxElement */; }; Rules.IsJsxExpressionContext = function (context) { return context.contextNode.kind === 248 /* JsxExpression */; @@ -71098,7 +71814,7 @@ var ts; return context.contextNode.kind === 246 /* JsxAttribute */; }; Rules.IsJsxSelfClosingElementContext = function (context) { - return context.contextNode.kind === 242 /* JsxSelfClosingElement */; + return context.contextNode.kind === 243 /* JsxSelfClosingElement */; }; Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); @@ -71113,41 +71829,41 @@ var ts; while (ts.isPartOfExpression(node)) { node = node.parent; } - return node.kind === 143 /* Decorator */; + return node.kind === 144 /* Decorator */; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 219 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 220 /* 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 === 225 /* ModuleDeclaration */; + return context.contextNode.kind === 226 /* ModuleDeclaration */; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 159 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 160 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; }; Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { - if (token.kind !== 25 /* LessThanToken */ && token.kind !== 27 /* GreaterThanToken */) { + if (token.kind !== 26 /* LessThanToken */ && token.kind !== 28 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 155 /* TypeReference */: - case 177 /* TypeAssertionExpression */: - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - case 222 /* InterfaceDeclaration */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 174 /* CallExpression */: - case 175 /* NewExpression */: - case 194 /* ExpressionWithTypeArguments */: + case 156 /* TypeReference */: + case 178 /* TypeAssertionExpression */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 223 /* InterfaceDeclaration */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: + case 195 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -71158,13 +71874,13 @@ var ts; Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsTypeAssertionContext = function (context) { - return context.contextNode.kind === 177 /* TypeAssertionExpression */; + return context.contextNode.kind === 178 /* TypeAssertionExpression */; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 103 /* VoidKeyword */ && context.currentTokenParent.kind === 183 /* VoidExpression */; + return context.currentTokenSpan.kind === 104 /* VoidKeyword */ && context.currentTokenParent.kind === 184 /* VoidExpression */; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 190 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 191 /* YieldExpression */ && context.contextNode.expression !== undefined; }; return Rules; }()); @@ -71188,7 +71904,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 138 /* LastToken */ + 1; + this.mapRowLength = 139 /* 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); @@ -71202,8 +71918,8 @@ var ts; }); }; RulesMap.prototype.GetRuleBucketIndex = function (row, column) { + ts.Debug.assert(row <= 139 /* LastKeyword */ && column <= 139 /* LastKeyword */, "Must compute formatting context from tokens"); var rulesBucketIndex = (row * this.mapRowLength) + column; - // Debug.Assert(rulesBucketIndex < this.map.Length, "Trying to access an index outside the array."); return rulesBucketIndex; }; RulesMap.prototype.FillRule = function (rule, rulesBucketConstructionStateList) { @@ -71383,12 +72099,12 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0 /* FirstToken */; token <= 138 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 139 /* LastToken */; token++) { result.push(token); } return result; }; - TokenAllAccess.prototype.Contains = function (tokenValue) { + TokenAllAccess.prototype.Contains = function () { return true; }; TokenAllAccess.prototype.toString = function () { @@ -71427,17 +72143,17 @@ var ts; }()); TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3 /* MultiLineCommentTrivia */])); - TokenRange.Keywords = TokenRange.FromRange(70 /* FirstKeyword */, 138 /* LastKeyword */); - TokenRange.BinaryOperators = TokenRange.FromRange(25 /* FirstBinaryOperator */, 68 /* LastBinaryOperator */); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([90 /* InKeyword */, 91 /* InstanceOfKeyword */, 138 /* 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.Keywords = TokenRange.FromRange(71 /* FirstKeyword */, 139 /* LastKeyword */); + TokenRange.BinaryOperators = TokenRange.FromRange(26 /* FirstBinaryOperator */, 69 /* LastBinaryOperator */); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([91 /* InKeyword */, 92 /* InstanceOfKeyword */, 139 /* OfKeyword */, 117 /* AsKeyword */, 125 /* IsKeyword */]); + TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([42 /* PlusPlusToken */, 43 /* MinusMinusToken */, 51 /* TildeToken */, 50 /* ExclamationToken */]); + TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8 /* NumericLiteral */, 70 /* Identifier */, 18 /* OpenParenToken */, 20 /* OpenBracketToken */, 16 /* OpenBraceToken */, 98 /* ThisKeyword */, 93 /* NewKeyword */]); + TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([70 /* Identifier */, 18 /* OpenParenToken */, 98 /* ThisKeyword */, 93 /* NewKeyword */]); + TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([70 /* Identifier */, 19 /* CloseParenToken */, 21 /* CloseBracketToken */, 93 /* NewKeyword */]); + TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([70 /* Identifier */, 18 /* OpenParenToken */, 98 /* ThisKeyword */, 93 /* NewKeyword */]); + TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([70 /* Identifier */, 19 /* CloseParenToken */, 21 /* CloseBracketToken */, 93 /* NewKeyword */]); TokenRange.Comments = TokenRange.FromTokens([2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]); - TokenRange.TypeNames = TokenRange.FromTokens([69 /* Identifier */, 130 /* NumberKeyword */, 132 /* StringKeyword */, 120 /* BooleanKeyword */, 133 /* SymbolKeyword */, 103 /* VoidKeyword */, 117 /* AnyKeyword */]); + TokenRange.TypeNames = TokenRange.FromTokens([70 /* Identifier */, 131 /* NumberKeyword */, 133 /* StringKeyword */, 121 /* BooleanKeyword */, 134 /* SymbolKeyword */, 104 /* VoidKeyword */, 118 /* AnyKeyword */]); Shared.TokenRange = TokenRange; })(Shared = formatting.Shared || (formatting.Shared = {})); })(formatting = ts.formatting || (ts.formatting = {})); @@ -71628,11 +72344,11 @@ var ts; } formatting.formatOnEnter = formatOnEnter; function formatOnSemicolon(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 23 /* SemicolonToken */, sourceFile, options, rulesProvider, 3 /* FormatOnSemicolon */); + return formatOutermostParent(position, 24 /* SemicolonToken */, sourceFile, options, rulesProvider, 3 /* FormatOnSemicolon */); } formatting.formatOnSemicolon = formatOnSemicolon; function formatOnClosingCurly(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 16 /* CloseBraceToken */, sourceFile, options, rulesProvider, 4 /* FormatOnClosingCurlyBrace */); + return formatOutermostParent(position, 17 /* CloseBraceToken */, sourceFile, options, rulesProvider, 4 /* FormatOnClosingCurlyBrace */); } formatting.formatOnClosingCurly = formatOnClosingCurly; function formatDocument(sourceFile, rulesProvider, options) { @@ -71696,15 +72412,15 @@ 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 221 /* ClassDeclaration */: - case 222 /* InterfaceDeclaration */: + case 222 /* ClassDeclaration */: + case 223 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: var body = parent.body; - return body && body.kind === 226 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + return body && body.kind === 227 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); case 256 /* SourceFile */: - case 199 /* Block */: - case 226 /* ModuleBlock */: + case 200 /* Block */: + case 227 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); case 252 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); @@ -71761,7 +72477,7 @@ var ts; index++; } }; - function rangeHasNoErrors(r) { + function rangeHasNoErrors() { return false; } } @@ -71911,20 +72627,20 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 221 /* ClassDeclaration */: return 73 /* ClassKeyword */; - case 222 /* InterfaceDeclaration */: return 107 /* InterfaceKeyword */; - case 220 /* FunctionDeclaration */: return 87 /* FunctionKeyword */; - case 224 /* EnumDeclaration */: return 224 /* EnumDeclaration */; - case 149 /* GetAccessor */: return 123 /* GetKeyword */; - case 150 /* SetAccessor */: return 131 /* SetKeyword */; - case 147 /* MethodDeclaration */: + case 222 /* ClassDeclaration */: return 74 /* ClassKeyword */; + case 223 /* InterfaceDeclaration */: return 108 /* InterfaceKeyword */; + case 221 /* FunctionDeclaration */: return 88 /* FunctionKeyword */; + case 225 /* EnumDeclaration */: return 225 /* EnumDeclaration */; + case 150 /* GetAccessor */: return 124 /* GetKeyword */; + case 151 /* SetAccessor */: return 132 /* SetKeyword */; + case 148 /* MethodDeclaration */: if (node.asteriskToken) { - return 37 /* AsteriskToken */; + return 38 /* AsteriskToken */; } /* fall-through */ - case 145 /* PropertyDeclaration */: - case 142 /* Parameter */: + case 146 /* PropertyDeclaration */: + case 143 /* Parameter */: return node.name.kind; } } @@ -71936,9 +72652,9 @@ var ts; // .. { // // comment // } - case 16 /* CloseBraceToken */: - case 20 /* CloseBracketToken */: - case 18 /* CloseParenToken */: + case 17 /* CloseBraceToken */: + case 21 /* CloseBracketToken */: + case 19 /* CloseParenToken */: return indentation + getEffectiveDelta(delta, container); } return tokenIndentation !== -1 /* Unknown */ ? tokenIndentation : indentation; @@ -71952,15 +72668,15 @@ var ts; } switch (kind) { // open and close brace, 'else' and 'while' (in do statement) tokens has indentation of the parent - case 15 /* OpenBraceToken */: - case 16 /* CloseBraceToken */: - case 19 /* OpenBracketToken */: - case 20 /* CloseBracketToken */: - case 17 /* OpenParenToken */: - case 18 /* CloseParenToken */: - case 80 /* ElseKeyword */: - case 104 /* WhileKeyword */: - case 55 /* AtToken */: + case 16 /* OpenBraceToken */: + case 17 /* CloseBraceToken */: + case 20 /* OpenBracketToken */: + case 21 /* CloseBracketToken */: + case 18 /* OpenParenToken */: + case 19 /* CloseParenToken */: + case 81 /* ElseKeyword */: + case 105 /* WhileKeyword */: + case 56 /* 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 @@ -72060,18 +72776,19 @@ var ts; if (!formattingScanner.isOnToken()) { return inheritedIndentation; } - if (ts.isToken(child)) { + // JSX text shouldn't affect indenting + if (ts.isToken(child) && child.kind !== 10 /* JsxText */) { // if child node is a token, it does not impact indentation, proceed it using parent indentation scope rules var tokenInfo = formattingScanner.readTokenInfo(child); - ts.Debug.assert(tokenInfo.token.end === child.end); + ts.Debug.assert(tokenInfo.token.end === child.end, "Token end is child end"); consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 143 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 144 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; - if (isFirstListItem && parent.kind === 170 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 171 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -72416,41 +73133,41 @@ var ts; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 148 /* Constructor */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 180 /* ArrowFunction */: + case 149 /* Constructor */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 181 /* ArrowFunction */: if (node.typeParameters === list) { - return 25 /* LessThanToken */; + return 26 /* LessThanToken */; } else if (node.parameters === list) { - return 17 /* OpenParenToken */; + return 18 /* OpenParenToken */; } break; - case 174 /* CallExpression */: - case 175 /* NewExpression */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: if (node.typeArguments === list) { - return 25 /* LessThanToken */; + return 26 /* LessThanToken */; } else if (node.arguments === list) { - return 17 /* OpenParenToken */; + return 18 /* OpenParenToken */; } break; - case 155 /* TypeReference */: + case 156 /* TypeReference */: if (node.typeArguments === list) { - return 25 /* LessThanToken */; + return 26 /* LessThanToken */; } } return 0 /* Unknown */; } function getCloseTokenForOpenToken(kind) { switch (kind) { - case 17 /* OpenParenToken */: - return 18 /* CloseParenToken */; - case 25 /* LessThanToken */: - return 27 /* GreaterThanToken */; + case 18 /* OpenParenToken */: + return 19 /* CloseParenToken */; + case 26 /* LessThanToken */: + return 28 /* GreaterThanToken */; } return 0 /* Unknown */; } @@ -72554,7 +73271,7 @@ var ts; var lineStart = ts.getLineStartPositionForPosition(current_1, sourceFile); return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current_1, sourceFile, options); } - if (precedingToken.kind === 24 /* CommaToken */ && precedingToken.parent.kind !== 187 /* BinaryExpression */) { + if (precedingToken.kind === 25 /* CommaToken */ && precedingToken.parent.kind !== 188 /* 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 */) { @@ -72688,11 +73405,11 @@ var ts; if (!nextToken) { return false; } - if (nextToken.kind === 15 /* OpenBraceToken */) { + if (nextToken.kind === 16 /* OpenBraceToken */) { // open braces are always indented at the parent level return true; } - else if (nextToken.kind === 16 /* CloseBraceToken */) { + else if (nextToken.kind === 17 /* CloseBraceToken */) { // close braces are indented at the parent level if they are located on the same line with cursor // this means that if new line will be added at $ position, this case will be indented // class A { @@ -72710,8 +73427,8 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 203 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 80 /* ElseKeyword */, sourceFile); + if (parent.kind === 204 /* IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 81 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -72722,23 +73439,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 155 /* TypeReference */: + case 156 /* TypeReference */: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 171 /* ObjectLiteralExpression */: + case 172 /* ObjectLiteralExpression */: return node.parent.properties; - case 170 /* ArrayLiteralExpression */: + case 171 /* ArrayLiteralExpression */: return node.parent.elements; - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: { + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -72749,8 +73466,8 @@ var ts; } break; } - case 175 /* NewExpression */: - case 174 /* CallExpression */: { + case 176 /* NewExpression */: + case 175 /* CallExpression */: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -72777,11 +73494,11 @@ var ts; function getLineIndentationWhenExpressionIsInMultiLine(node, sourceFile, options) { // actual indentation should not be used when: // - node is close parenthesis - this is the end of the expression - if (node.kind === 18 /* CloseParenToken */) { + if (node.kind === 19 /* CloseParenToken */) { return -1 /* Unknown */; } - if (node.parent && (node.parent.kind === 174 /* CallExpression */ || - node.parent.kind === 175 /* NewExpression */) && + if (node.parent && (node.parent.kind === 175 /* CallExpression */ || + node.parent.kind === 176 /* NewExpression */) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -72799,10 +73516,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 174 /* CallExpression */: - case 175 /* NewExpression */: - case 172 /* PropertyAccessExpression */: - case 173 /* ElementAccessExpression */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: + case 173 /* PropertyAccessExpression */: + case 174 /* ElementAccessExpression */: node = node.expression; break; default: @@ -72818,7 +73535,7 @@ var ts; // if end line for item [i - 1] differs from the start line for item [i] - find column of the first non-whitespace character on the line of item [i] var lineAndCharacter = getStartLineAndCharacterForNode(node, sourceFile); for (var i = index - 1; i >= 0; i--) { - if (list[i].kind === 24 /* CommaToken */) { + if (list[i].kind === 25 /* CommaToken */) { continue; } // skip list items that ends on the same line with the current list element @@ -72866,48 +73583,48 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 202 /* ExpressionStatement */: - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - case 222 /* InterfaceDeclaration */: - case 224 /* EnumDeclaration */: - case 223 /* TypeAliasDeclaration */: - case 170 /* ArrayLiteralExpression */: - case 199 /* Block */: - case 226 /* ModuleBlock */: - case 171 /* ObjectLiteralExpression */: - case 159 /* TypeLiteral */: - case 161 /* TupleType */: - case 227 /* CaseBlock */: + case 203 /* ExpressionStatement */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 223 /* InterfaceDeclaration */: + case 225 /* EnumDeclaration */: + case 224 /* TypeAliasDeclaration */: + case 171 /* ArrayLiteralExpression */: + case 200 /* Block */: + case 227 /* ModuleBlock */: + case 172 /* ObjectLiteralExpression */: + case 160 /* TypeLiteral */: + case 162 /* TupleType */: + case 228 /* CaseBlock */: case 250 /* DefaultClause */: case 249 /* CaseClause */: - case 178 /* ParenthesizedExpression */: - case 172 /* PropertyAccessExpression */: - case 174 /* CallExpression */: - case 175 /* NewExpression */: - case 200 /* VariableStatement */: - case 218 /* VariableDeclaration */: - case 235 /* ExportAssignment */: - case 211 /* ReturnStatement */: - case 188 /* ConditionalExpression */: - case 168 /* ArrayBindingPattern */: - case 167 /* ObjectBindingPattern */: - case 243 /* JsxOpeningElement */: - case 242 /* JsxSelfClosingElement */: + case 179 /* ParenthesizedExpression */: + case 173 /* PropertyAccessExpression */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: + case 201 /* VariableStatement */: + case 219 /* VariableDeclaration */: + case 236 /* ExportAssignment */: + case 212 /* ReturnStatement */: + case 189 /* ConditionalExpression */: + case 169 /* ArrayBindingPattern */: + case 168 /* ObjectBindingPattern */: + case 244 /* JsxOpeningElement */: + case 243 /* JsxSelfClosingElement */: case 248 /* JsxExpression */: - case 146 /* MethodSignature */: - case 151 /* CallSignature */: - case 152 /* ConstructSignature */: - case 142 /* Parameter */: - case 156 /* FunctionType */: - case 157 /* ConstructorType */: - case 164 /* ParenthesizedType */: - case 176 /* TaggedTemplateExpression */: - case 184 /* AwaitExpression */: - case 237 /* NamedExports */: - case 233 /* NamedImports */: - case 238 /* ExportSpecifier */: - case 234 /* ImportSpecifier */: + case 147 /* MethodSignature */: + case 152 /* CallSignature */: + case 153 /* ConstructSignature */: + case 143 /* Parameter */: + case 157 /* FunctionType */: + case 158 /* ConstructorType */: + case 165 /* ParenthesizedType */: + case 177 /* TaggedTemplateExpression */: + case 185 /* AwaitExpression */: + case 238 /* NamedExports */: + case 234 /* NamedImports */: + case 239 /* ExportSpecifier */: + case 235 /* ImportSpecifier */: return true; } return false; @@ -72916,26 +73633,26 @@ var ts; function nodeWillIndentChild(parent, child, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 204 /* DoStatement */: - case 205 /* WhileStatement */: - case 207 /* ForInStatement */: - case 208 /* ForOfStatement */: - case 206 /* ForStatement */: - case 203 /* IfStatement */: - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 147 /* MethodDeclaration */: - case 180 /* ArrowFunction */: - case 148 /* Constructor */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - return childKind !== 199 /* Block */; - case 236 /* ExportDeclaration */: - return childKind !== 237 /* NamedExports */; - case 230 /* ImportDeclaration */: - return childKind !== 231 /* ImportClause */ || - (child.namedBindings && child.namedBindings.kind !== 233 /* NamedImports */); - case 241 /* JsxElement */: + case 205 /* DoStatement */: + case 206 /* WhileStatement */: + case 208 /* ForInStatement */: + case 209 /* ForOfStatement */: + case 207 /* ForStatement */: + case 204 /* IfStatement */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 148 /* MethodDeclaration */: + case 181 /* ArrowFunction */: + case 149 /* Constructor */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + return childKind !== 200 /* Block */; + case 237 /* ExportDeclaration */: + return childKind !== 238 /* NamedExports */; + case 231 /* ImportDeclaration */: + return childKind !== 232 /* ImportClause */ || + (child.namedBindings && child.namedBindings.kind !== 234 /* NamedImports */); + case 242 /* JsxElement */: return childKind !== 245 /* JsxClosingElement */; } // No explicit rule for given nodes so the result will follow the default value argument @@ -73001,7 +73718,7 @@ var ts; getCodeActions: function (context) { var sourceFile = context.sourceFile; var token = ts.getTokenAtPosition(sourceFile, context.span.start); - if (token.kind !== 121 /* ConstructorKeyword */) { + if (token.kind !== 122 /* ConstructorKeyword */) { return undefined; } var newPosition = getOpenBraceEnd(token.parent, sourceFile); @@ -73016,7 +73733,7 @@ var ts; getCodeActions: function (context) { var sourceFile = context.sourceFile; var token = ts.getTokenAtPosition(sourceFile, context.span.start); - if (token.kind !== 97 /* ThisKeyword */) { + if (token.kind !== 98 /* ThisKeyword */) { return undefined; } var constructor = ts.getContainingFunction(token); @@ -73026,7 +73743,7 @@ var ts; } // figure out if the this access is actuall inside the supercall // i.e. super(this.a), since in that case we won't suggest a fix - if (superCall.expression && superCall.expression.kind == 174 /* CallExpression */) { + if (superCall.expression && superCall.expression.kind == 175 /* CallExpression */) { var arguments_1 = superCall.expression.arguments; for (var i = 0; i < arguments_1.length; i++) { if (arguments_1[i].expression === token) { @@ -73050,7 +73767,7 @@ var ts; changes: changes }]; function findSuperCall(n) { - if (n.kind === 202 /* ExpressionStatement */ && ts.isSuperCall(n.expression)) { + if (n.kind === 203 /* ExpressionStatement */ && ts.isSuperCall(n.expression)) { return n; } if (ts.isFunctionLike(n)) { @@ -73095,8 +73812,8 @@ var ts; /** The version of the language service API */ ts.servicesVersion = "0.5"; function createNode(kind, pos, end, parent) { - var node = kind >= 139 /* FirstNode */ ? new NodeObject(kind, pos, end) : - kind === 69 /* Identifier */ ? new IdentifierObject(69 /* Identifier */, pos, end) : + var node = kind >= 140 /* FirstNode */ ? new NodeObject(kind, pos, end) : + kind === 70 /* Identifier */ ? new IdentifierObject(70 /* Identifier */, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; return node; @@ -73173,7 +73890,7 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 139 /* FirstNode */) { + if (this.kind >= 140 /* FirstNode */) { ts.scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos_3 = this.pos; @@ -73235,7 +73952,7 @@ var ts; return undefined; } var child = children[0]; - return child.kind < 139 /* FirstNode */ ? child : child.getFirstToken(sourceFile); + return child.kind < 140 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; NodeObject.prototype.getLastToken = function (sourceFile) { var children = this.getChildren(sourceFile); @@ -73243,7 +73960,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 139 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 140 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; return NodeObject; }()); @@ -73282,19 +73999,19 @@ var ts; TokenOrIdentifierObject.prototype.getText = function (sourceFile) { return (sourceFile || this.getSourceFile()).text.substring(this.getStart(), this.getEnd()); }; - TokenOrIdentifierObject.prototype.getChildCount = function (sourceFile) { + TokenOrIdentifierObject.prototype.getChildCount = function () { return 0; }; - TokenOrIdentifierObject.prototype.getChildAt = function (index, sourceFile) { + TokenOrIdentifierObject.prototype.getChildAt = function () { return undefined; }; - TokenOrIdentifierObject.prototype.getChildren = function (sourceFile) { + TokenOrIdentifierObject.prototype.getChildren = function () { return ts.emptyArray; }; - TokenOrIdentifierObject.prototype.getFirstToken = function (sourceFile) { + TokenOrIdentifierObject.prototype.getFirstToken = function () { return undefined; }; - TokenOrIdentifierObject.prototype.getLastToken = function (sourceFile) { + TokenOrIdentifierObject.prototype.getLastToken = function () { return undefined; }; return TokenOrIdentifierObject; @@ -73315,7 +74032,7 @@ var ts; }; SymbolObject.prototype.getDocumentationComment = function () { if (this.documentationComment === undefined) { - this.documentationComment = ts.JsDoc.getJsDocCommentsFromDeclarations(this.declarations, this.name, !(this.flags & 4 /* Property */)); + this.documentationComment = ts.JsDoc.getJsDocCommentsFromDeclarations(this.declarations); } return this.documentationComment; }; @@ -73332,12 +74049,12 @@ var ts; }(TokenOrIdentifierObject)); var IdentifierObject = (function (_super) { __extends(IdentifierObject, _super); - function IdentifierObject(kind, pos, end) { + function IdentifierObject(_kind, pos, end) { return _super.call(this, pos, end) || this; } return IdentifierObject; }(TokenOrIdentifierObject)); - IdentifierObject.prototype.kind = 69 /* Identifier */; + IdentifierObject.prototype.kind = 70 /* Identifier */; var TypeObject = (function () { function TypeObject(checker, flags) { this.checker = checker; @@ -73398,9 +74115,7 @@ var ts; }; SignatureObject.prototype.getDocumentationComment = function () { if (this.documentationComment === undefined) { - this.documentationComment = this.declaration ? ts.JsDoc.getJsDocCommentsFromDeclarations([this.declaration], - /*name*/ undefined, - /*canUseParsedParamTagComments*/ false) : []; + this.documentationComment = this.declaration ? ts.JsDoc.getJsDocCommentsFromDeclarations([this.declaration]) : []; } return this.documentationComment; }; @@ -73448,9 +74163,9 @@ var ts; if (result_6 !== undefined) { return result_6; } - if (declaration.name.kind === 140 /* ComputedPropertyName */) { + if (declaration.name.kind === 141 /* ComputedPropertyName */) { var expr = declaration.name.expression; - if (expr.kind === 172 /* PropertyAccessExpression */) { + if (expr.kind === 173 /* PropertyAccessExpression */) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -73460,7 +74175,7 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 69 /* Identifier */ || + if (node.kind === 70 /* Identifier */ || node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { return node.text; @@ -73470,10 +74185,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 220 /* FunctionDeclaration */: - case 179 /* FunctionExpression */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: + case 221 /* FunctionDeclaration */: + case 180 /* FunctionExpression */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -73493,32 +74208,32 @@ var ts; ts.forEachChild(node, visit); } break; - case 221 /* ClassDeclaration */: - case 192 /* ClassExpression */: - case 222 /* InterfaceDeclaration */: - case 223 /* TypeAliasDeclaration */: - case 224 /* EnumDeclaration */: - case 225 /* ModuleDeclaration */: - case 229 /* ImportEqualsDeclaration */: - case 238 /* ExportSpecifier */: - case 234 /* ImportSpecifier */: - case 229 /* ImportEqualsDeclaration */: - case 231 /* ImportClause */: - case 232 /* NamespaceImport */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 159 /* TypeLiteral */: + case 222 /* ClassDeclaration */: + case 193 /* ClassExpression */: + case 223 /* InterfaceDeclaration */: + case 224 /* TypeAliasDeclaration */: + case 225 /* EnumDeclaration */: + case 226 /* ModuleDeclaration */: + case 230 /* ImportEqualsDeclaration */: + case 239 /* ExportSpecifier */: + case 235 /* ImportSpecifier */: + case 230 /* ImportEqualsDeclaration */: + case 232 /* ImportClause */: + case 233 /* NamespaceImport */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 160 /* TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 142 /* Parameter */: + case 143 /* Parameter */: // Only consider parameter properties if (!ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { break; } // fall through - case 218 /* VariableDeclaration */: - case 169 /* BindingElement */: { + case 219 /* VariableDeclaration */: + case 170 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -73528,18 +74243,18 @@ var ts; visit(decl.initializer); } case 255 /* EnumMember */: - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: addDeclaration(node); break; - case 236 /* ExportDeclaration */: + case 237 /* 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 230 /* ImportDeclaration */: + case 231 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -73551,7 +74266,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 232 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 233 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -73575,7 +74290,7 @@ var ts; getSourceFileConstructor: function () { return SourceFileObject; }, getSymbolConstructor: function () { return SymbolObject; }, getTypeConstructor: function () { return TypeObject; }, - getSignatureConstructor: function () { return SignatureObject; } + getSignatureConstructor: function () { return SignatureObject; }, }; } function toEditorSettings(optionsAsMap) { @@ -73674,7 +74389,7 @@ var ts; }; HostCache.prototype.getRootFileNames = function () { var fileNames = []; - this.fileNameToEntry.forEachValue(function (path, value) { + this.fileNameToEntry.forEachValue(function (_path, value) { if (value) { fileNames.push(value.hostFileName); } @@ -73706,7 +74421,7 @@ var ts; var sourceFile; if (this.currentFileName !== fileName) { // This is a new file, just parse it - sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 2 /* Latest */, version, /*setNodeParents*/ true, scriptKind); + sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 4 /* Latest */, version, /*setNodeParents*/ true, scriptKind); } else if (this.currentFileVersion !== version) { // This is the same file, just a newer version. Incrementally parse the file. @@ -73884,7 +74599,7 @@ var ts; useCaseSensitiveFileNames: function () { return useCaseSensitivefileNames; }, getNewLine: function () { return ts.getNewLineOrDefaultFromHost(host); }, getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); }, - writeFile: function (fileName, data, writeByteOrderMark) { }, + writeFile: function () { }, getCurrentDirectory: function () { return currentDirectory; }, fileExists: function (fileName) { // stub missing host functionality @@ -74080,12 +74795,12 @@ var ts; if (!symbol || typeChecker.isUnknownSymbol(symbol)) { // Try getting just type at this position and show switch (node.kind) { - case 69 /* Identifier */: - case 172 /* PropertyAccessExpression */: - case 139 /* QualifiedName */: - case 97 /* ThisKeyword */: - case 165 /* ThisType */: - case 95 /* SuperKeyword */: + case 70 /* Identifier */: + case 173 /* PropertyAccessExpression */: + case 140 /* QualifiedName */: + case 98 /* ThisKeyword */: + case 166 /* ThisType */: + case 96 /* SuperKeyword */: // For the identifiers/this/super etc get the type at position var type = typeChecker.getTypeAtLocation(node); if (type) { @@ -74219,7 +74934,7 @@ var ts; function getSourceFile(fileName) { return getNonBoundSourceFile(fileName); } - function getNameOrDottedNameSpan(fileName, startPos, endPos) { + function getNameOrDottedNameSpan(fileName, startPos, _endPos) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); // Get node at the location var node = ts.getTouchingPropertyName(sourceFile, startPos); @@ -74227,16 +74942,16 @@ var ts; return; } switch (node.kind) { - case 172 /* PropertyAccessExpression */: - case 139 /* QualifiedName */: + case 173 /* PropertyAccessExpression */: + case 140 /* QualifiedName */: case 9 /* StringLiteral */: - case 84 /* FalseKeyword */: - case 99 /* TrueKeyword */: - case 93 /* NullKeyword */: - case 95 /* SuperKeyword */: - case 97 /* ThisKeyword */: - case 165 /* ThisType */: - case 69 /* Identifier */: + case 85 /* FalseKeyword */: + case 100 /* TrueKeyword */: + case 94 /* NullKeyword */: + case 96 /* SuperKeyword */: + case 98 /* ThisKeyword */: + case 166 /* ThisType */: + case 70 /* Identifier */: break; // Cant create the text span default: @@ -74252,7 +74967,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 === 225 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 226 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -74343,14 +75058,14 @@ var ts; return result; function getMatchingTokenKind(token) { switch (token.kind) { - case 15 /* OpenBraceToken */: return 16 /* CloseBraceToken */; - case 17 /* OpenParenToken */: return 18 /* CloseParenToken */; - case 19 /* OpenBracketToken */: return 20 /* CloseBracketToken */; - case 25 /* LessThanToken */: return 27 /* GreaterThanToken */; - case 16 /* CloseBraceToken */: return 15 /* OpenBraceToken */; - case 18 /* CloseParenToken */: return 17 /* OpenParenToken */; - case 20 /* CloseBracketToken */: return 19 /* OpenBracketToken */; - case 27 /* GreaterThanToken */: return 25 /* LessThanToken */; + case 16 /* OpenBraceToken */: return 17 /* CloseBraceToken */; + case 18 /* OpenParenToken */: return 19 /* CloseParenToken */; + case 20 /* OpenBracketToken */: return 21 /* CloseBracketToken */; + case 26 /* LessThanToken */: return 28 /* GreaterThanToken */; + case 17 /* CloseBraceToken */: return 16 /* OpenBraceToken */; + case 19 /* CloseParenToken */: return 18 /* OpenParenToken */; + case 21 /* CloseBracketToken */: return 20 /* OpenBracketToken */; + case 28 /* GreaterThanToken */: return 26 /* LessThanToken */; } return undefined; } @@ -74626,7 +75341,7 @@ var ts; sourceFile.nameTable = nameTable; function walk(node) { switch (node.kind) { - case 69 /* Identifier */: + case 70 /* Identifier */: nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; break; case 9 /* StringLiteral */: @@ -74636,7 +75351,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 === 240 /* ExternalModuleReference */ || + node.parent.kind === 241 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node)) { nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; @@ -74656,7 +75371,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 173 /* ElementAccessExpression */ && + node.parent.kind === 174 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -74740,143 +75455,143 @@ var ts; function spanInNode(node) { if (node) { switch (node.kind) { - case 200 /* VariableStatement */: + case 201 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 218 /* VariableDeclaration */: - case 145 /* PropertyDeclaration */: - case 144 /* PropertySignature */: + case 219 /* VariableDeclaration */: + case 146 /* PropertyDeclaration */: + case 145 /* PropertySignature */: return spanInVariableDeclaration(node); - case 142 /* Parameter */: + case 143 /* Parameter */: return spanInParameterDeclaration(node); - case 220 /* FunctionDeclaration */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 148 /* Constructor */: - case 179 /* FunctionExpression */: - case 180 /* ArrowFunction */: + case 221 /* FunctionDeclaration */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 149 /* Constructor */: + case 180 /* FunctionExpression */: + case 181 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 199 /* Block */: + case 200 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // Fall through - case 226 /* ModuleBlock */: + case 227 /* ModuleBlock */: return spanInBlock(node); case 252 /* CatchClause */: return spanInBlock(node.block); - case 202 /* ExpressionStatement */: + case 203 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 211 /* ReturnStatement */: + case 212 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 205 /* WhileStatement */: + case 206 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 204 /* DoStatement */: + case 205 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 217 /* DebuggerStatement */: + case 218 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 203 /* IfStatement */: + case 204 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 214 /* LabeledStatement */: + case 215 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 210 /* BreakStatement */: - case 209 /* ContinueStatement */: + case 211 /* BreakStatement */: + case 210 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 206 /* ForStatement */: + case 207 /* ForStatement */: return spanInForStatement(node); - case 207 /* ForInStatement */: + case 208 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 208 /* ForOfStatement */: + case 209 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 213 /* SwitchStatement */: + case 214 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); case 249 /* CaseClause */: case 250 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 216 /* TryStatement */: + case 217 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 215 /* ThrowStatement */: + case 216 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 235 /* ExportAssignment */: + case 236 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 229 /* ImportEqualsDeclaration */: + case 230 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 230 /* ImportDeclaration */: + case 231 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 236 /* ExportDeclaration */: + case 237 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } - case 221 /* ClassDeclaration */: - case 224 /* EnumDeclaration */: + case 222 /* ClassDeclaration */: + case 225 /* EnumDeclaration */: case 255 /* EnumMember */: - case 169 /* BindingElement */: + case 170 /* BindingElement */: // span on complete node return textSpan(node); - case 212 /* WithStatement */: + case 213 /* WithStatement */: // span in statement return spanInNode(node.statement); - case 143 /* Decorator */: + case 144 /* Decorator */: return spanInNodeArray(node.parent.decorators); - case 167 /* ObjectBindingPattern */: - case 168 /* ArrayBindingPattern */: + case 168 /* ObjectBindingPattern */: + case 169 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 222 /* InterfaceDeclaration */: - case 223 /* TypeAliasDeclaration */: + case 223 /* InterfaceDeclaration */: + case 224 /* TypeAliasDeclaration */: return undefined; // Tokens: - case 23 /* SemicolonToken */: + case 24 /* SemicolonToken */: case 1 /* EndOfFileToken */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile)); - case 24 /* CommaToken */: + case 25 /* CommaToken */: return spanInPreviousNode(node); - case 15 /* OpenBraceToken */: + case 16 /* OpenBraceToken */: return spanInOpenBraceToken(node); - case 16 /* CloseBraceToken */: + case 17 /* CloseBraceToken */: return spanInCloseBraceToken(node); - case 20 /* CloseBracketToken */: + case 21 /* CloseBracketToken */: return spanInCloseBracketToken(node); - case 17 /* OpenParenToken */: + case 18 /* OpenParenToken */: return spanInOpenParenToken(node); - case 18 /* CloseParenToken */: + case 19 /* CloseParenToken */: return spanInCloseParenToken(node); - case 54 /* ColonToken */: + case 55 /* ColonToken */: return spanInColonToken(node); - case 27 /* GreaterThanToken */: - case 25 /* LessThanToken */: + case 28 /* GreaterThanToken */: + case 26 /* LessThanToken */: return spanInGreaterThanOrLessThanToken(node); // Keywords: - case 104 /* WhileKeyword */: + case 105 /* WhileKeyword */: return spanInWhileKeyword(node); - case 80 /* ElseKeyword */: - case 72 /* CatchKeyword */: - case 85 /* FinallyKeyword */: + case 81 /* ElseKeyword */: + case 73 /* CatchKeyword */: + case 86 /* FinallyKeyword */: return spanInNextNode(node); - case 138 /* OfKeyword */: + case 139 /* OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -74888,14 +75603,14 @@ var ts; // Set breakpoint on identifier element of destructuring pattern // a or ...c or d: x from // [a, b, ...c] or { a, b } or { d: x } from destructuring pattern - if ((node.kind === 69 /* Identifier */ || - node.kind == 191 /* SpreadElementExpression */ || + if ((node.kind === 70 /* Identifier */ || + node.kind == 192 /* SpreadElementExpression */ || node.kind === 253 /* PropertyAssignment */ || node.kind === 254 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { return textSpan(node); } - if (node.kind === 187 /* BinaryExpression */) { + if (node.kind === 188 /* BinaryExpression */) { var binaryExpression = node; // Set breakpoint in destructuring pattern if its destructuring assignment // [a, b, c] or {a, b, c} of @@ -74904,7 +75619,7 @@ var ts; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left); } - if (binaryExpression.operatorToken.kind === 56 /* EqualsToken */ && + if (binaryExpression.operatorToken.kind === 57 /* EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.parent)) { // Set breakpoint on assignment expression element of destructuring pattern // a = expression of @@ -74912,28 +75627,28 @@ var ts; // { a = expression, b, c } = someExpression return textSpan(node); } - if (binaryExpression.operatorToken.kind === 24 /* CommaToken */) { + if (binaryExpression.operatorToken.kind === 25 /* CommaToken */) { return spanInNode(binaryExpression.left); } } if (ts.isPartOfExpression(node)) { switch (node.parent.kind) { - case 204 /* DoStatement */: + case 205 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 143 /* Decorator */: + case 144 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 206 /* ForStatement */: - case 208 /* ForOfStatement */: + case 207 /* ForStatement */: + case 209 /* ForOfStatement */: return textSpan(node); - case 187 /* BinaryExpression */: - if (node.parent.operatorToken.kind === 24 /* CommaToken */) { + case 188 /* BinaryExpression */: + if (node.parent.operatorToken.kind === 25 /* CommaToken */) { // If this is a comma expression, the breakpoint is possible in this expression return textSpan(node); } break; - case 180 /* ArrowFunction */: + case 181 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -74948,7 +75663,7 @@ var ts; return spanInNode(node.parent.initializer); } // Breakpoint in type assertion goes to its operand - if (node.parent.kind === 177 /* TypeAssertionExpression */ && node.parent.type === node) { + if (node.parent.kind === 178 /* TypeAssertionExpression */ && node.parent.type === node) { return spanInNextNode(node.parent.type); } // return type of function go to previous token @@ -74956,8 +75671,8 @@ var ts; return spanInPreviousNode(node); } // initializer of variable/parameter declaration go to previous node - if ((node.parent.kind === 218 /* VariableDeclaration */ || - node.parent.kind === 142 /* Parameter */)) { + if ((node.parent.kind === 219 /* VariableDeclaration */ || + node.parent.kind === 143 /* Parameter */)) { var paramOrVarDecl = node.parent; if (paramOrVarDecl.initializer === node || paramOrVarDecl.type === node || @@ -74965,7 +75680,7 @@ var ts; return spanInPreviousNode(node); } } - if (node.parent.kind === 187 /* BinaryExpression */) { + if (node.parent.kind === 188 /* BinaryExpression */) { var binaryExpression = node.parent; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left) && (binaryExpression.right === node || @@ -74991,7 +75706,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 207 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 208 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } // If this is a destructuring pattern, set breakpoint in binding pattern @@ -75002,7 +75717,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1 /* Export */) || - variableDeclaration.parent.parent.kind === 208 /* ForOfStatement */) { + variableDeclaration.parent.parent.kind === 209 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } var declarations = variableDeclaration.parent.declarations; @@ -75042,7 +75757,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 221 /* ClassDeclaration */ && functionDeclaration.kind !== 148 /* Constructor */); + (functionDeclaration.parent.kind === 222 /* ClassDeclaration */ && functionDeclaration.kind !== 149 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -75065,25 +75780,25 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 225 /* ModuleDeclaration */: + case 226 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement - case 205 /* WhileStatement */: - case 203 /* IfStatement */: - case 207 /* ForInStatement */: + case 206 /* WhileStatement */: + case 204 /* IfStatement */: + case 208 /* ForInStatement */: 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 206 /* ForStatement */: - case 208 /* ForOfStatement */: + case 207 /* ForStatement */: + case 209 /* ForOfStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } // Default action is to set on first statement return spanInNode(block.statements[0]); } function spanInInitializerOfForLike(forLikeStatement) { - if (forLikeStatement.initializer.kind === 219 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 220 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -75108,23 +75823,23 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 193 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 194 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 169 /* BindingElement */) { + if (bindingPattern.parent.kind === 170 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 168 /* ArrayBindingPattern */ && node.kind !== 167 /* ObjectBindingPattern */); - var elements = node.kind === 170 /* ArrayLiteralExpression */ ? + ts.Debug.assert(node.kind !== 169 /* ArrayBindingPattern */ && node.kind !== 168 /* ObjectBindingPattern */); + var elements = node.kind === 171 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 193 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 194 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -75132,18 +75847,18 @@ var ts; // just nested element in another destructuring assignment // set breakpoint on assignment when parent is destructuring assignment // Otherwise set breakpoint for this element - return textSpan(node.parent.kind === 187 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 188 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 224 /* EnumDeclaration */: + case 225 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 221 /* ClassDeclaration */: + case 222 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 227 /* CaseBlock */: + case 228 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -75151,16 +75866,16 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 226 /* ModuleBlock */: + case 227 /* ModuleBlock */: // If this is not an instantiated module block, no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } - case 224 /* EnumDeclaration */: - case 221 /* ClassDeclaration */: + case 225 /* EnumDeclaration */: + case 222 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 199 /* Block */: + case 200 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); @@ -75168,7 +75883,7 @@ var ts; // fall through case 252 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 227 /* CaseBlock */: + case 228 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -75176,7 +75891,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 167 /* ObjectBindingPattern */: + case 168 /* ObjectBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return spanInNode(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -75192,7 +75907,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 168 /* ArrayBindingPattern */: + case 169 /* ArrayBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return textSpan(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -75207,12 +75922,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 204 /* DoStatement */ || - node.parent.kind === 174 /* CallExpression */ || - node.parent.kind === 175 /* NewExpression */) { + if (node.parent.kind === 205 /* DoStatement */ || + node.parent.kind === 175 /* CallExpression */ || + node.parent.kind === 176 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 178 /* ParenthesizedExpression */) { + if (node.parent.kind === 179 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -75221,21 +75936,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 179 /* FunctionExpression */: - case 220 /* FunctionDeclaration */: - case 180 /* ArrowFunction */: - case 147 /* MethodDeclaration */: - case 146 /* MethodSignature */: - case 149 /* GetAccessor */: - case 150 /* SetAccessor */: - case 148 /* Constructor */: - case 205 /* WhileStatement */: - case 204 /* DoStatement */: - case 206 /* ForStatement */: - case 208 /* ForOfStatement */: - case 174 /* CallExpression */: - case 175 /* NewExpression */: - case 178 /* ParenthesizedExpression */: + case 180 /* FunctionExpression */: + case 221 /* FunctionDeclaration */: + case 181 /* ArrowFunction */: + case 148 /* MethodDeclaration */: + case 147 /* MethodSignature */: + case 150 /* GetAccessor */: + case 151 /* SetAccessor */: + case 149 /* Constructor */: + case 206 /* WhileStatement */: + case 205 /* DoStatement */: + case 207 /* ForStatement */: + case 209 /* ForOfStatement */: + case 175 /* CallExpression */: + case 176 /* NewExpression */: + case 179 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -75246,19 +75961,19 @@ var ts; // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || node.parent.kind === 253 /* PropertyAssignment */ || - node.parent.kind === 142 /* Parameter */) { + node.parent.kind === 143 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 177 /* TypeAssertionExpression */) { + if (node.parent.kind === 178 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 204 /* DoStatement */) { + if (node.parent.kind === 205 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -75266,7 +75981,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 208 /* ForOfStatement */) { + if (node.parent.kind === 209 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -75445,7 +76160,7 @@ var ts; return this.shimHost.getDefaultLibFileName(JSON.stringify(options)); }; LanguageServiceShimHostAdapter.prototype.readDirectory = function (path, extensions, exclude, include, depth) { - var pattern = ts.getFileMatcherPatterns(path, extensions, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); + var pattern = ts.getFileMatcherPatterns(path, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); return JSON.parse(this.shimHost.readDirectory(path, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); }; LanguageServiceShimHostAdapter.prototype.readFile = function (path, encoding) { @@ -75494,7 +76209,7 @@ var ts; // Wrap the API changes for 2.0 release. This try/catch // should be removed once TypeScript 2.0 has shipped. try { - var pattern = ts.getFileMatcherPatterns(rootDir, extensions, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); + var pattern = ts.getFileMatcherPatterns(rootDir, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); return JSON.parse(this.shimHost.readDirectory(rootDir, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); } catch (e) { @@ -75568,7 +76283,7 @@ var ts; this.factory = factory; factory.registerShim(this); } - ShimBase.prototype.dispose = function (dummy) { + ShimBase.prototype.dispose = function (_dummy) { this.factory.unregisterShim(this); }; return ShimBase; @@ -75991,7 +76706,7 @@ var ts; var getCanonicalFileName = ts.createGetCanonicalFileName(/*useCaseSensitivefileNames:*/ false); return this.forwardJSONCall("discoverTypings()", function () { var info = JSON.parse(discoverTypingsJson); - return ts.JsTyping.discoverTypings(_this.host, info.fileNames, ts.toPath(info.projectRootPath, info.projectRootPath, getCanonicalFileName), ts.toPath(info.safeListPath, info.safeListPath, getCanonicalFileName), info.packageNameToTypingLocation, info.typingOptions, info.compilerOptions); + return ts.JsTyping.discoverTypings(_this.host, info.fileNames, ts.toPath(info.projectRootPath, info.projectRootPath, getCanonicalFileName), ts.toPath(info.safeListPath, info.safeListPath, getCanonicalFileName), info.packageNameToTypingLocation, info.typingOptions); }); }; return CoreServicesShimObject; @@ -76080,3 +76795,5 @@ var TypeScript; /* @internal */ var toolsVersion = "2.1"; /* tslint:enable:no-unused-variable */ + +//# sourceMappingURL=typescriptServices.js.map diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index 577a8ee4fc9..147b38fde19 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -20,6 +20,418 @@ var __extends = (this && this.__extends) || function (d, b) { }; var ts; (function (ts) { + (function (SyntaxKind) { + SyntaxKind[SyntaxKind["Unknown"] = 0] = "Unknown"; + SyntaxKind[SyntaxKind["EndOfFileToken"] = 1] = "EndOfFileToken"; + SyntaxKind[SyntaxKind["SingleLineCommentTrivia"] = 2] = "SingleLineCommentTrivia"; + SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 3] = "MultiLineCommentTrivia"; + SyntaxKind[SyntaxKind["NewLineTrivia"] = 4] = "NewLineTrivia"; + SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 5] = "WhitespaceTrivia"; + SyntaxKind[SyntaxKind["ShebangTrivia"] = 6] = "ShebangTrivia"; + SyntaxKind[SyntaxKind["ConflictMarkerTrivia"] = 7] = "ConflictMarkerTrivia"; + SyntaxKind[SyntaxKind["NumericLiteral"] = 8] = "NumericLiteral"; + SyntaxKind[SyntaxKind["StringLiteral"] = 9] = "StringLiteral"; + SyntaxKind[SyntaxKind["JsxText"] = 10] = "JsxText"; + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 11] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 12] = "NoSubstitutionTemplateLiteral"; + SyntaxKind[SyntaxKind["TemplateHead"] = 13] = "TemplateHead"; + SyntaxKind[SyntaxKind["TemplateMiddle"] = 14] = "TemplateMiddle"; + SyntaxKind[SyntaxKind["TemplateTail"] = 15] = "TemplateTail"; + SyntaxKind[SyntaxKind["OpenBraceToken"] = 16] = "OpenBraceToken"; + SyntaxKind[SyntaxKind["CloseBraceToken"] = 17] = "CloseBraceToken"; + SyntaxKind[SyntaxKind["OpenParenToken"] = 18] = "OpenParenToken"; + SyntaxKind[SyntaxKind["CloseParenToken"] = 19] = "CloseParenToken"; + SyntaxKind[SyntaxKind["OpenBracketToken"] = 20] = "OpenBracketToken"; + SyntaxKind[SyntaxKind["CloseBracketToken"] = 21] = "CloseBracketToken"; + SyntaxKind[SyntaxKind["DotToken"] = 22] = "DotToken"; + SyntaxKind[SyntaxKind["DotDotDotToken"] = 23] = "DotDotDotToken"; + SyntaxKind[SyntaxKind["SemicolonToken"] = 24] = "SemicolonToken"; + SyntaxKind[SyntaxKind["CommaToken"] = 25] = "CommaToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 26] = "LessThanToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 27] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 28] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 29] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 30] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 31] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 32] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 33] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 34] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 35] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 36] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 37] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 38] = "AsteriskToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 39] = "AsteriskAsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 40] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 41] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 42] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 43] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 44] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 45] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 46] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 47] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 48] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 49] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 50] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 51] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 52] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 53] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 54] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 55] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 56] = "AtToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 57] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 58] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 59] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 60] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 61] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 62] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 63] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 64] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 65] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 66] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 67] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 68] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 69] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["Identifier"] = 70] = "Identifier"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 71] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 72] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 73] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 74] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 75] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 76] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 77] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 78] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 79] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 80] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 81] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 82] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 83] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 84] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 85] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 86] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 87] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 88] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 89] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 90] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 91] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 92] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 93] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 94] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 95] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 96] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 97] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 98] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 99] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 100] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 101] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 102] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 103] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 104] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 105] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 106] = "WithKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 107] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 108] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 109] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 110] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 111] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 112] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 113] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 114] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 115] = "YieldKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 116] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 117] = "AsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 118] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 119] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 120] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 121] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 122] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 123] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 124] = "GetKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 125] = "IsKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 126] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 127] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 128] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 129] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 130] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 131] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 132] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 133] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 134] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 135] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 136] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 137] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 138] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 139] = "OfKeyword"; + SyntaxKind[SyntaxKind["QualifiedName"] = 140] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 141] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["TypeParameter"] = 142] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 143] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 144] = "Decorator"; + SyntaxKind[SyntaxKind["PropertySignature"] = 145] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 146] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 147] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 148] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 149] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 150] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 151] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 152] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 153] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 154] = "IndexSignature"; + SyntaxKind[SyntaxKind["TypePredicate"] = 155] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 156] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 157] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 158] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 159] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 160] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 161] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 162] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 163] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 164] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 165] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 166] = "ThisType"; + SyntaxKind[SyntaxKind["LiteralType"] = 167] = "LiteralType"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 168] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 169] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 170] = "BindingElement"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 171] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 172] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 173] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 174] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 175] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 176] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 177] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 178] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 179] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 180] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 181] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 182] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 183] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 184] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 185] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 186] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 187] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 188] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 189] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 190] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 191] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElementExpression"] = 192] = "SpreadElementExpression"; + SyntaxKind[SyntaxKind["ClassExpression"] = 193] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 194] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 195] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 196] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 197] = "NonNullExpression"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 198] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 199] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["Block"] = 200] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 201] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 202] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 203] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 204] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 205] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 206] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 207] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 208] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 209] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 210] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 211] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 212] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 213] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 214] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 215] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 216] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 217] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 218] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 219] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 220] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 221] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 222] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 223] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 224] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 225] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 226] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 227] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 228] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 229] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 230] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 231] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 232] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 233] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 234] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 235] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 236] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 237] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 238] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 239] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 240] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 241] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["JsxElement"] = 242] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 243] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 244] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 245] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 246] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 247] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 248] = "JsxExpression"; + SyntaxKind[SyntaxKind["CaseClause"] = 249] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 250] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 251] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 252] = "CatchClause"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 253] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 254] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["EnumMember"] = 255] = "EnumMember"; + SyntaxKind[SyntaxKind["SourceFile"] = 256] = "SourceFile"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 257] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 258] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 259] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 260] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 261] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 262] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 263] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 264] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 265] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 266] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 267] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 268] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 269] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 270] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 271] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 272] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 273] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 274] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 275] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 276] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 277] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 278] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 279] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 280] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 281] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocLiteralType"] = 282] = "JSDocLiteralType"; + SyntaxKind[SyntaxKind["JSDocNullKeyword"] = 283] = "JSDocNullKeyword"; + SyntaxKind[SyntaxKind["JSDocUndefinedKeyword"] = 284] = "JSDocUndefinedKeyword"; + SyntaxKind[SyntaxKind["JSDocNeverKeyword"] = 285] = "JSDocNeverKeyword"; + SyntaxKind[SyntaxKind["SyntaxList"] = 286] = "SyntaxList"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 287] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 288] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["Count"] = 289] = "Count"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 57] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 69] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 58] = "FirstCompoundAssignment"; + SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 69] = "LastCompoundAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 71] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 106] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 71] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 139] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 107] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 115] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 155] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 167] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstPunctuation"] = 16] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 69] = "LastPunctuation"; + SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; + SyntaxKind[SyntaxKind["LastToken"] = 139] = "LastToken"; + SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; + SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; + SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; + SyntaxKind[SyntaxKind["LastLiteralToken"] = 12] = "LastLiteralToken"; + SyntaxKind[SyntaxKind["FirstTemplateToken"] = 12] = "FirstTemplateToken"; + SyntaxKind[SyntaxKind["LastTemplateToken"] = 15] = "LastTemplateToken"; + SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 26] = "FirstBinaryOperator"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 69] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstNode"] = 140] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 257] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 282] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 273] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 285] = "LastJSDocTagNode"; + })(ts.SyntaxKind || (ts.SyntaxKind = {})); + var SyntaxKind = ts.SyntaxKind; + (function (NodeFlags) { + NodeFlags[NodeFlags["None"] = 0] = "None"; + NodeFlags[NodeFlags["Let"] = 1] = "Let"; + NodeFlags[NodeFlags["Const"] = 2] = "Const"; + NodeFlags[NodeFlags["NestedNamespace"] = 4] = "NestedNamespace"; + NodeFlags[NodeFlags["Synthesized"] = 8] = "Synthesized"; + NodeFlags[NodeFlags["Namespace"] = 16] = "Namespace"; + NodeFlags[NodeFlags["ExportContext"] = 32] = "ExportContext"; + NodeFlags[NodeFlags["ContainsThis"] = 64] = "ContainsThis"; + NodeFlags[NodeFlags["HasImplicitReturn"] = 128] = "HasImplicitReturn"; + NodeFlags[NodeFlags["HasExplicitReturn"] = 256] = "HasExplicitReturn"; + NodeFlags[NodeFlags["GlobalAugmentation"] = 512] = "GlobalAugmentation"; + NodeFlags[NodeFlags["HasClassExtends"] = 1024] = "HasClassExtends"; + NodeFlags[NodeFlags["HasDecorators"] = 2048] = "HasDecorators"; + NodeFlags[NodeFlags["HasParamDecorators"] = 4096] = "HasParamDecorators"; + NodeFlags[NodeFlags["HasAsyncFunctions"] = 8192] = "HasAsyncFunctions"; + NodeFlags[NodeFlags["HasJsxSpreadAttributes"] = 16384] = "HasJsxSpreadAttributes"; + NodeFlags[NodeFlags["DisallowInContext"] = 32768] = "DisallowInContext"; + NodeFlags[NodeFlags["YieldContext"] = 65536] = "YieldContext"; + NodeFlags[NodeFlags["DecoratorContext"] = 131072] = "DecoratorContext"; + NodeFlags[NodeFlags["AwaitContext"] = 262144] = "AwaitContext"; + NodeFlags[NodeFlags["ThisNodeHasError"] = 524288] = "ThisNodeHasError"; + NodeFlags[NodeFlags["JavaScriptFile"] = 1048576] = "JavaScriptFile"; + NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 2097152] = "ThisNodeOrAnySubNodesHasError"; + NodeFlags[NodeFlags["HasAggregatedChildData"] = 4194304] = "HasAggregatedChildData"; + NodeFlags[NodeFlags["BlockScoped"] = 3] = "BlockScoped"; + NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 384] = "ReachabilityCheckFlags"; + NodeFlags[NodeFlags["EmitHelperFlags"] = 31744] = "EmitHelperFlags"; + NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 32128] = "ReachabilityAndEmitFlags"; + NodeFlags[NodeFlags["ContextFlags"] = 1540096] = "ContextFlags"; + NodeFlags[NodeFlags["TypeExcludesFlags"] = 327680] = "TypeExcludesFlags"; + })(ts.NodeFlags || (ts.NodeFlags = {})); + var NodeFlags = ts.NodeFlags; + (function (ModifierFlags) { + ModifierFlags[ModifierFlags["None"] = 0] = "None"; + ModifierFlags[ModifierFlags["Export"] = 1] = "Export"; + ModifierFlags[ModifierFlags["Ambient"] = 2] = "Ambient"; + ModifierFlags[ModifierFlags["Public"] = 4] = "Public"; + ModifierFlags[ModifierFlags["Private"] = 8] = "Private"; + ModifierFlags[ModifierFlags["Protected"] = 16] = "Protected"; + ModifierFlags[ModifierFlags["Static"] = 32] = "Static"; + ModifierFlags[ModifierFlags["Readonly"] = 64] = "Readonly"; + ModifierFlags[ModifierFlags["Abstract"] = 128] = "Abstract"; + ModifierFlags[ModifierFlags["Async"] = 256] = "Async"; + ModifierFlags[ModifierFlags["Default"] = 512] = "Default"; + ModifierFlags[ModifierFlags["Const"] = 2048] = "Const"; + ModifierFlags[ModifierFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; + ModifierFlags[ModifierFlags["AccessibilityModifier"] = 28] = "AccessibilityModifier"; + ModifierFlags[ModifierFlags["ParameterPropertyModifier"] = 92] = "ParameterPropertyModifier"; + ModifierFlags[ModifierFlags["NonPublicAccessibilityModifier"] = 24] = "NonPublicAccessibilityModifier"; + ModifierFlags[ModifierFlags["TypeScriptModifier"] = 2270] = "TypeScriptModifier"; + })(ts.ModifierFlags || (ts.ModifierFlags = {})); + var ModifierFlags = ts.ModifierFlags; + (function (JsxFlags) { + JsxFlags[JsxFlags["None"] = 0] = "None"; + JsxFlags[JsxFlags["IntrinsicNamedElement"] = 1] = "IntrinsicNamedElement"; + JsxFlags[JsxFlags["IntrinsicIndexedElement"] = 2] = "IntrinsicIndexedElement"; + JsxFlags[JsxFlags["IntrinsicElement"] = 3] = "IntrinsicElement"; + })(ts.JsxFlags || (ts.JsxFlags = {})); + var JsxFlags = ts.JsxFlags; + (function (RelationComparisonResult) { + RelationComparisonResult[RelationComparisonResult["Succeeded"] = 1] = "Succeeded"; + RelationComparisonResult[RelationComparisonResult["Failed"] = 2] = "Failed"; + RelationComparisonResult[RelationComparisonResult["FailedAndReported"] = 3] = "FailedAndReported"; + })(ts.RelationComparisonResult || (ts.RelationComparisonResult = {})); + var RelationComparisonResult = ts.RelationComparisonResult; + (function (GeneratedIdentifierKind) { + GeneratedIdentifierKind[GeneratedIdentifierKind["None"] = 0] = "None"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Auto"] = 1] = "Auto"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Loop"] = 2] = "Loop"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Unique"] = 3] = "Unique"; + GeneratedIdentifierKind[GeneratedIdentifierKind["Node"] = 4] = "Node"; + })(ts.GeneratedIdentifierKind || (ts.GeneratedIdentifierKind = {})); + var GeneratedIdentifierKind = ts.GeneratedIdentifierKind; + (function (FlowFlags) { + FlowFlags[FlowFlags["Unreachable"] = 1] = "Unreachable"; + FlowFlags[FlowFlags["Start"] = 2] = "Start"; + FlowFlags[FlowFlags["BranchLabel"] = 4] = "BranchLabel"; + FlowFlags[FlowFlags["LoopLabel"] = 8] = "LoopLabel"; + FlowFlags[FlowFlags["Assignment"] = 16] = "Assignment"; + FlowFlags[FlowFlags["TrueCondition"] = 32] = "TrueCondition"; + FlowFlags[FlowFlags["FalseCondition"] = 64] = "FalseCondition"; + FlowFlags[FlowFlags["SwitchClause"] = 128] = "SwitchClause"; + FlowFlags[FlowFlags["ArrayMutation"] = 256] = "ArrayMutation"; + FlowFlags[FlowFlags["Referenced"] = 512] = "Referenced"; + FlowFlags[FlowFlags["Shared"] = 1024] = "Shared"; + FlowFlags[FlowFlags["Label"] = 12] = "Label"; + FlowFlags[FlowFlags["Condition"] = 96] = "Condition"; + })(ts.FlowFlags || (ts.FlowFlags = {})); + var FlowFlags = ts.FlowFlags; var OperationCanceledException = (function () { function OperationCanceledException() { } @@ -32,6 +444,38 @@ var ts; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; })(ts.ExitStatus || (ts.ExitStatus = {})); var ExitStatus = ts.ExitStatus; + (function (TypeFormatFlags) { + TypeFormatFlags[TypeFormatFlags["None"] = 0] = "None"; + TypeFormatFlags[TypeFormatFlags["WriteArrayAsGenericType"] = 1] = "WriteArrayAsGenericType"; + TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 2] = "UseTypeOfFunction"; + TypeFormatFlags[TypeFormatFlags["NoTruncation"] = 4] = "NoTruncation"; + TypeFormatFlags[TypeFormatFlags["WriteArrowStyleSignature"] = 8] = "WriteArrowStyleSignature"; + TypeFormatFlags[TypeFormatFlags["WriteOwnNameForAnyLike"] = 16] = "WriteOwnNameForAnyLike"; + TypeFormatFlags[TypeFormatFlags["WriteTypeArgumentsOfSignature"] = 32] = "WriteTypeArgumentsOfSignature"; + TypeFormatFlags[TypeFormatFlags["InElementType"] = 64] = "InElementType"; + TypeFormatFlags[TypeFormatFlags["UseFullyQualifiedType"] = 128] = "UseFullyQualifiedType"; + TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 256] = "InFirstTypeArgument"; + TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 512] = "InTypeAlias"; + TypeFormatFlags[TypeFormatFlags["UseTypeAliasValue"] = 1024] = "UseTypeAliasValue"; + })(ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); + var TypeFormatFlags = ts.TypeFormatFlags; + (function (SymbolFormatFlags) { + SymbolFormatFlags[SymbolFormatFlags["None"] = 0] = "None"; + SymbolFormatFlags[SymbolFormatFlags["WriteTypeParametersOrArguments"] = 1] = "WriteTypeParametersOrArguments"; + SymbolFormatFlags[SymbolFormatFlags["UseOnlyExternalAliasing"] = 2] = "UseOnlyExternalAliasing"; + })(ts.SymbolFormatFlags || (ts.SymbolFormatFlags = {})); + var SymbolFormatFlags = ts.SymbolFormatFlags; + (function (SymbolAccessibility) { + SymbolAccessibility[SymbolAccessibility["Accessible"] = 0] = "Accessible"; + SymbolAccessibility[SymbolAccessibility["NotAccessible"] = 1] = "NotAccessible"; + SymbolAccessibility[SymbolAccessibility["CannotBeNamed"] = 2] = "CannotBeNamed"; + })(ts.SymbolAccessibility || (ts.SymbolAccessibility = {})); + var SymbolAccessibility = ts.SymbolAccessibility; + (function (TypePredicateKind) { + TypePredicateKind[TypePredicateKind["This"] = 0] = "This"; + TypePredicateKind[TypePredicateKind["Identifier"] = 1] = "Identifier"; + })(ts.TypePredicateKind || (ts.TypePredicateKind = {})); + var TypePredicateKind = ts.TypePredicateKind; (function (TypeReferenceSerializationKind) { TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; @@ -46,6 +490,166 @@ var ts; TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 10] = "ObjectType"; })(ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); var TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind; + (function (SymbolFlags) { + SymbolFlags[SymbolFlags["None"] = 0] = "None"; + SymbolFlags[SymbolFlags["FunctionScopedVariable"] = 1] = "FunctionScopedVariable"; + SymbolFlags[SymbolFlags["BlockScopedVariable"] = 2] = "BlockScopedVariable"; + SymbolFlags[SymbolFlags["Property"] = 4] = "Property"; + SymbolFlags[SymbolFlags["EnumMember"] = 8] = "EnumMember"; + SymbolFlags[SymbolFlags["Function"] = 16] = "Function"; + SymbolFlags[SymbolFlags["Class"] = 32] = "Class"; + SymbolFlags[SymbolFlags["Interface"] = 64] = "Interface"; + SymbolFlags[SymbolFlags["ConstEnum"] = 128] = "ConstEnum"; + SymbolFlags[SymbolFlags["RegularEnum"] = 256] = "RegularEnum"; + SymbolFlags[SymbolFlags["ValueModule"] = 512] = "ValueModule"; + SymbolFlags[SymbolFlags["NamespaceModule"] = 1024] = "NamespaceModule"; + SymbolFlags[SymbolFlags["TypeLiteral"] = 2048] = "TypeLiteral"; + SymbolFlags[SymbolFlags["ObjectLiteral"] = 4096] = "ObjectLiteral"; + SymbolFlags[SymbolFlags["Method"] = 8192] = "Method"; + SymbolFlags[SymbolFlags["Constructor"] = 16384] = "Constructor"; + SymbolFlags[SymbolFlags["GetAccessor"] = 32768] = "GetAccessor"; + SymbolFlags[SymbolFlags["SetAccessor"] = 65536] = "SetAccessor"; + SymbolFlags[SymbolFlags["Signature"] = 131072] = "Signature"; + SymbolFlags[SymbolFlags["TypeParameter"] = 262144] = "TypeParameter"; + SymbolFlags[SymbolFlags["TypeAlias"] = 524288] = "TypeAlias"; + SymbolFlags[SymbolFlags["ExportValue"] = 1048576] = "ExportValue"; + SymbolFlags[SymbolFlags["ExportType"] = 2097152] = "ExportType"; + SymbolFlags[SymbolFlags["ExportNamespace"] = 4194304] = "ExportNamespace"; + SymbolFlags[SymbolFlags["Alias"] = 8388608] = "Alias"; + SymbolFlags[SymbolFlags["Instantiated"] = 16777216] = "Instantiated"; + SymbolFlags[SymbolFlags["Merged"] = 33554432] = "Merged"; + SymbolFlags[SymbolFlags["Transient"] = 67108864] = "Transient"; + SymbolFlags[SymbolFlags["Prototype"] = 134217728] = "Prototype"; + SymbolFlags[SymbolFlags["SyntheticProperty"] = 268435456] = "SyntheticProperty"; + SymbolFlags[SymbolFlags["Optional"] = 536870912] = "Optional"; + SymbolFlags[SymbolFlags["ExportStar"] = 1073741824] = "ExportStar"; + SymbolFlags[SymbolFlags["Enum"] = 384] = "Enum"; + SymbolFlags[SymbolFlags["Variable"] = 3] = "Variable"; + SymbolFlags[SymbolFlags["Value"] = 107455] = "Value"; + SymbolFlags[SymbolFlags["Type"] = 793064] = "Type"; + SymbolFlags[SymbolFlags["Namespace"] = 1920] = "Namespace"; + SymbolFlags[SymbolFlags["Module"] = 1536] = "Module"; + SymbolFlags[SymbolFlags["Accessor"] = 98304] = "Accessor"; + SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = 107454] = "FunctionScopedVariableExcludes"; + SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = 107455] = "BlockScopedVariableExcludes"; + SymbolFlags[SymbolFlags["ParameterExcludes"] = 107455] = "ParameterExcludes"; + SymbolFlags[SymbolFlags["PropertyExcludes"] = 0] = "PropertyExcludes"; + SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 900095] = "EnumMemberExcludes"; + SymbolFlags[SymbolFlags["FunctionExcludes"] = 106927] = "FunctionExcludes"; + SymbolFlags[SymbolFlags["ClassExcludes"] = 899519] = "ClassExcludes"; + SymbolFlags[SymbolFlags["InterfaceExcludes"] = 792968] = "InterfaceExcludes"; + SymbolFlags[SymbolFlags["RegularEnumExcludes"] = 899327] = "RegularEnumExcludes"; + SymbolFlags[SymbolFlags["ConstEnumExcludes"] = 899967] = "ConstEnumExcludes"; + SymbolFlags[SymbolFlags["ValueModuleExcludes"] = 106639] = "ValueModuleExcludes"; + SymbolFlags[SymbolFlags["NamespaceModuleExcludes"] = 0] = "NamespaceModuleExcludes"; + SymbolFlags[SymbolFlags["MethodExcludes"] = 99263] = "MethodExcludes"; + SymbolFlags[SymbolFlags["GetAccessorExcludes"] = 41919] = "GetAccessorExcludes"; + SymbolFlags[SymbolFlags["SetAccessorExcludes"] = 74687] = "SetAccessorExcludes"; + SymbolFlags[SymbolFlags["TypeParameterExcludes"] = 530920] = "TypeParameterExcludes"; + SymbolFlags[SymbolFlags["TypeAliasExcludes"] = 793064] = "TypeAliasExcludes"; + SymbolFlags[SymbolFlags["AliasExcludes"] = 8388608] = "AliasExcludes"; + SymbolFlags[SymbolFlags["ModuleMember"] = 8914931] = "ModuleMember"; + SymbolFlags[SymbolFlags["ExportHasLocal"] = 944] = "ExportHasLocal"; + SymbolFlags[SymbolFlags["HasExports"] = 1952] = "HasExports"; + SymbolFlags[SymbolFlags["HasMembers"] = 6240] = "HasMembers"; + SymbolFlags[SymbolFlags["BlockScoped"] = 418] = "BlockScoped"; + SymbolFlags[SymbolFlags["PropertyOrAccessor"] = 98308] = "PropertyOrAccessor"; + SymbolFlags[SymbolFlags["Export"] = 7340032] = "Export"; + SymbolFlags[SymbolFlags["ClassMember"] = 106500] = "ClassMember"; + SymbolFlags[SymbolFlags["Classifiable"] = 788448] = "Classifiable"; + })(ts.SymbolFlags || (ts.SymbolFlags = {})); + var SymbolFlags = ts.SymbolFlags; + (function (NodeCheckFlags) { + NodeCheckFlags[NodeCheckFlags["TypeChecked"] = 1] = "TypeChecked"; + NodeCheckFlags[NodeCheckFlags["LexicalThis"] = 2] = "LexicalThis"; + NodeCheckFlags[NodeCheckFlags["CaptureThis"] = 4] = "CaptureThis"; + NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 256] = "SuperInstance"; + NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 512] = "SuperStatic"; + NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 1024] = "ContextChecked"; + NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuper"] = 2048] = "AsyncMethodWithSuper"; + NodeCheckFlags[NodeCheckFlags["AsyncMethodWithSuperBinding"] = 4096] = "AsyncMethodWithSuperBinding"; + NodeCheckFlags[NodeCheckFlags["CaptureArguments"] = 8192] = "CaptureArguments"; + NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 16384] = "EnumValuesComputed"; + NodeCheckFlags[NodeCheckFlags["LexicalModuleMergesWithClass"] = 32768] = "LexicalModuleMergesWithClass"; + NodeCheckFlags[NodeCheckFlags["LoopWithCapturedBlockScopedBinding"] = 65536] = "LoopWithCapturedBlockScopedBinding"; + NodeCheckFlags[NodeCheckFlags["CapturedBlockScopedBinding"] = 131072] = "CapturedBlockScopedBinding"; + NodeCheckFlags[NodeCheckFlags["BlockScopedBindingInLoop"] = 262144] = "BlockScopedBindingInLoop"; + NodeCheckFlags[NodeCheckFlags["ClassWithBodyScopedClassBinding"] = 524288] = "ClassWithBodyScopedClassBinding"; + NodeCheckFlags[NodeCheckFlags["BodyScopedClassBinding"] = 1048576] = "BodyScopedClassBinding"; + NodeCheckFlags[NodeCheckFlags["NeedsLoopOutParameter"] = 2097152] = "NeedsLoopOutParameter"; + NodeCheckFlags[NodeCheckFlags["AssignmentsMarked"] = 4194304] = "AssignmentsMarked"; + NodeCheckFlags[NodeCheckFlags["ClassWithConstructorReference"] = 8388608] = "ClassWithConstructorReference"; + NodeCheckFlags[NodeCheckFlags["ConstructorReferenceInClass"] = 16777216] = "ConstructorReferenceInClass"; + })(ts.NodeCheckFlags || (ts.NodeCheckFlags = {})); + var NodeCheckFlags = ts.NodeCheckFlags; + (function (TypeFlags) { + TypeFlags[TypeFlags["Any"] = 1] = "Any"; + TypeFlags[TypeFlags["String"] = 2] = "String"; + TypeFlags[TypeFlags["Number"] = 4] = "Number"; + TypeFlags[TypeFlags["Boolean"] = 8] = "Boolean"; + TypeFlags[TypeFlags["Enum"] = 16] = "Enum"; + TypeFlags[TypeFlags["StringLiteral"] = 32] = "StringLiteral"; + TypeFlags[TypeFlags["NumberLiteral"] = 64] = "NumberLiteral"; + TypeFlags[TypeFlags["BooleanLiteral"] = 128] = "BooleanLiteral"; + TypeFlags[TypeFlags["EnumLiteral"] = 256] = "EnumLiteral"; + TypeFlags[TypeFlags["ESSymbol"] = 512] = "ESSymbol"; + TypeFlags[TypeFlags["Void"] = 1024] = "Void"; + TypeFlags[TypeFlags["Undefined"] = 2048] = "Undefined"; + TypeFlags[TypeFlags["Null"] = 4096] = "Null"; + TypeFlags[TypeFlags["Never"] = 8192] = "Never"; + TypeFlags[TypeFlags["TypeParameter"] = 16384] = "TypeParameter"; + TypeFlags[TypeFlags["Class"] = 32768] = "Class"; + TypeFlags[TypeFlags["Interface"] = 65536] = "Interface"; + TypeFlags[TypeFlags["Reference"] = 131072] = "Reference"; + TypeFlags[TypeFlags["Tuple"] = 262144] = "Tuple"; + TypeFlags[TypeFlags["Union"] = 524288] = "Union"; + TypeFlags[TypeFlags["Intersection"] = 1048576] = "Intersection"; + TypeFlags[TypeFlags["Anonymous"] = 2097152] = "Anonymous"; + TypeFlags[TypeFlags["Instantiated"] = 4194304] = "Instantiated"; + TypeFlags[TypeFlags["ObjectLiteral"] = 8388608] = "ObjectLiteral"; + TypeFlags[TypeFlags["FreshLiteral"] = 16777216] = "FreshLiteral"; + TypeFlags[TypeFlags["ContainsWideningType"] = 33554432] = "ContainsWideningType"; + TypeFlags[TypeFlags["ContainsObjectLiteral"] = 67108864] = "ContainsObjectLiteral"; + TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 134217728] = "ContainsAnyFunctionType"; + TypeFlags[TypeFlags["Nullable"] = 6144] = "Nullable"; + TypeFlags[TypeFlags["Literal"] = 480] = "Literal"; + TypeFlags[TypeFlags["StringOrNumberLiteral"] = 96] = "StringOrNumberLiteral"; + TypeFlags[TypeFlags["DefinitelyFalsy"] = 7392] = "DefinitelyFalsy"; + TypeFlags[TypeFlags["PossiblyFalsy"] = 7406] = "PossiblyFalsy"; + TypeFlags[TypeFlags["Intrinsic"] = 16015] = "Intrinsic"; + TypeFlags[TypeFlags["Primitive"] = 8190] = "Primitive"; + TypeFlags[TypeFlags["StringLike"] = 34] = "StringLike"; + TypeFlags[TypeFlags["NumberLike"] = 340] = "NumberLike"; + TypeFlags[TypeFlags["BooleanLike"] = 136] = "BooleanLike"; + TypeFlags[TypeFlags["EnumLike"] = 272] = "EnumLike"; + TypeFlags[TypeFlags["ObjectType"] = 2588672] = "ObjectType"; + TypeFlags[TypeFlags["UnionOrIntersection"] = 1572864] = "UnionOrIntersection"; + TypeFlags[TypeFlags["StructuredType"] = 4161536] = "StructuredType"; + TypeFlags[TypeFlags["StructuredOrTypeParameter"] = 4177920] = "StructuredOrTypeParameter"; + TypeFlags[TypeFlags["Narrowable"] = 4178943] = "Narrowable"; + TypeFlags[TypeFlags["NotUnionOrUnit"] = 2589185] = "NotUnionOrUnit"; + TypeFlags[TypeFlags["RequiresWidening"] = 100663296] = "RequiresWidening"; + TypeFlags[TypeFlags["PropagatingFlags"] = 234881024] = "PropagatingFlags"; + })(ts.TypeFlags || (ts.TypeFlags = {})); + var TypeFlags = ts.TypeFlags; + (function (SignatureKind) { + SignatureKind[SignatureKind["Call"] = 0] = "Call"; + SignatureKind[SignatureKind["Construct"] = 1] = "Construct"; + })(ts.SignatureKind || (ts.SignatureKind = {})); + var SignatureKind = ts.SignatureKind; + (function (IndexKind) { + IndexKind[IndexKind["String"] = 0] = "String"; + IndexKind[IndexKind["Number"] = 1] = "Number"; + })(ts.IndexKind || (ts.IndexKind = {})); + var IndexKind = ts.IndexKind; + (function (SpecialPropertyAssignmentKind) { + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["None"] = 0] = "None"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ExportsProperty"] = 1] = "ExportsProperty"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ModuleExports"] = 2] = "ModuleExports"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["PrototypeProperty"] = 3] = "PrototypeProperty"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ThisProperty"] = 4] = "ThisProperty"; + })(ts.SpecialPropertyAssignmentKind || (ts.SpecialPropertyAssignmentKind = {})); + var SpecialPropertyAssignmentKind = ts.SpecialPropertyAssignmentKind; (function (DiagnosticCategory) { DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; @@ -63,10 +667,267 @@ var ts; ModuleKind[ModuleKind["AMD"] = 2] = "AMD"; ModuleKind[ModuleKind["UMD"] = 3] = "UMD"; ModuleKind[ModuleKind["System"] = 4] = "System"; - ModuleKind[ModuleKind["ES6"] = 5] = "ES6"; ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015"; })(ts.ModuleKind || (ts.ModuleKind = {})); var ModuleKind = ts.ModuleKind; + (function (JsxEmit) { + JsxEmit[JsxEmit["None"] = 0] = "None"; + JsxEmit[JsxEmit["Preserve"] = 1] = "Preserve"; + JsxEmit[JsxEmit["React"] = 2] = "React"; + })(ts.JsxEmit || (ts.JsxEmit = {})); + var JsxEmit = ts.JsxEmit; + (function (NewLineKind) { + NewLineKind[NewLineKind["CarriageReturnLineFeed"] = 0] = "CarriageReturnLineFeed"; + NewLineKind[NewLineKind["LineFeed"] = 1] = "LineFeed"; + })(ts.NewLineKind || (ts.NewLineKind = {})); + var NewLineKind = ts.NewLineKind; + (function (ScriptKind) { + ScriptKind[ScriptKind["Unknown"] = 0] = "Unknown"; + ScriptKind[ScriptKind["JS"] = 1] = "JS"; + ScriptKind[ScriptKind["JSX"] = 2] = "JSX"; + ScriptKind[ScriptKind["TS"] = 3] = "TS"; + ScriptKind[ScriptKind["TSX"] = 4] = "TSX"; + })(ts.ScriptKind || (ts.ScriptKind = {})); + var ScriptKind = ts.ScriptKind; + (function (ScriptTarget) { + ScriptTarget[ScriptTarget["ES3"] = 0] = "ES3"; + ScriptTarget[ScriptTarget["ES5"] = 1] = "ES5"; + ScriptTarget[ScriptTarget["ES2015"] = 2] = "ES2015"; + ScriptTarget[ScriptTarget["ES2016"] = 3] = "ES2016"; + ScriptTarget[ScriptTarget["ES2017"] = 4] = "ES2017"; + ScriptTarget[ScriptTarget["Latest"] = 4] = "Latest"; + })(ts.ScriptTarget || (ts.ScriptTarget = {})); + var ScriptTarget = ts.ScriptTarget; + (function (LanguageVariant) { + LanguageVariant[LanguageVariant["Standard"] = 0] = "Standard"; + LanguageVariant[LanguageVariant["JSX"] = 1] = "JSX"; + })(ts.LanguageVariant || (ts.LanguageVariant = {})); + var LanguageVariant = ts.LanguageVariant; + (function (DiagnosticStyle) { + DiagnosticStyle[DiagnosticStyle["Simple"] = 0] = "Simple"; + DiagnosticStyle[DiagnosticStyle["Pretty"] = 1] = "Pretty"; + })(ts.DiagnosticStyle || (ts.DiagnosticStyle = {})); + var DiagnosticStyle = ts.DiagnosticStyle; + (function (WatchDirectoryFlags) { + WatchDirectoryFlags[WatchDirectoryFlags["None"] = 0] = "None"; + WatchDirectoryFlags[WatchDirectoryFlags["Recursive"] = 1] = "Recursive"; + })(ts.WatchDirectoryFlags || (ts.WatchDirectoryFlags = {})); + var WatchDirectoryFlags = ts.WatchDirectoryFlags; + (function (CharacterCodes) { + CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; + CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 127] = "maxAsciiCharacter"; + CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed"; + CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn"; + CharacterCodes[CharacterCodes["lineSeparator"] = 8232] = "lineSeparator"; + CharacterCodes[CharacterCodes["paragraphSeparator"] = 8233] = "paragraphSeparator"; + CharacterCodes[CharacterCodes["nextLine"] = 133] = "nextLine"; + CharacterCodes[CharacterCodes["space"] = 32] = "space"; + CharacterCodes[CharacterCodes["nonBreakingSpace"] = 160] = "nonBreakingSpace"; + CharacterCodes[CharacterCodes["enQuad"] = 8192] = "enQuad"; + CharacterCodes[CharacterCodes["emQuad"] = 8193] = "emQuad"; + CharacterCodes[CharacterCodes["enSpace"] = 8194] = "enSpace"; + CharacterCodes[CharacterCodes["emSpace"] = 8195] = "emSpace"; + CharacterCodes[CharacterCodes["threePerEmSpace"] = 8196] = "threePerEmSpace"; + CharacterCodes[CharacterCodes["fourPerEmSpace"] = 8197] = "fourPerEmSpace"; + CharacterCodes[CharacterCodes["sixPerEmSpace"] = 8198] = "sixPerEmSpace"; + CharacterCodes[CharacterCodes["figureSpace"] = 8199] = "figureSpace"; + CharacterCodes[CharacterCodes["punctuationSpace"] = 8200] = "punctuationSpace"; + CharacterCodes[CharacterCodes["thinSpace"] = 8201] = "thinSpace"; + CharacterCodes[CharacterCodes["hairSpace"] = 8202] = "hairSpace"; + CharacterCodes[CharacterCodes["zeroWidthSpace"] = 8203] = "zeroWidthSpace"; + CharacterCodes[CharacterCodes["narrowNoBreakSpace"] = 8239] = "narrowNoBreakSpace"; + CharacterCodes[CharacterCodes["ideographicSpace"] = 12288] = "ideographicSpace"; + CharacterCodes[CharacterCodes["mathematicalSpace"] = 8287] = "mathematicalSpace"; + CharacterCodes[CharacterCodes["ogham"] = 5760] = "ogham"; + CharacterCodes[CharacterCodes["_"] = 95] = "_"; + CharacterCodes[CharacterCodes["$"] = 36] = "$"; + CharacterCodes[CharacterCodes["_0"] = 48] = "_0"; + CharacterCodes[CharacterCodes["_1"] = 49] = "_1"; + CharacterCodes[CharacterCodes["_2"] = 50] = "_2"; + CharacterCodes[CharacterCodes["_3"] = 51] = "_3"; + CharacterCodes[CharacterCodes["_4"] = 52] = "_4"; + CharacterCodes[CharacterCodes["_5"] = 53] = "_5"; + CharacterCodes[CharacterCodes["_6"] = 54] = "_6"; + CharacterCodes[CharacterCodes["_7"] = 55] = "_7"; + CharacterCodes[CharacterCodes["_8"] = 56] = "_8"; + CharacterCodes[CharacterCodes["_9"] = 57] = "_9"; + CharacterCodes[CharacterCodes["a"] = 97] = "a"; + CharacterCodes[CharacterCodes["b"] = 98] = "b"; + CharacterCodes[CharacterCodes["c"] = 99] = "c"; + CharacterCodes[CharacterCodes["d"] = 100] = "d"; + CharacterCodes[CharacterCodes["e"] = 101] = "e"; + CharacterCodes[CharacterCodes["f"] = 102] = "f"; + CharacterCodes[CharacterCodes["g"] = 103] = "g"; + CharacterCodes[CharacterCodes["h"] = 104] = "h"; + CharacterCodes[CharacterCodes["i"] = 105] = "i"; + CharacterCodes[CharacterCodes["j"] = 106] = "j"; + CharacterCodes[CharacterCodes["k"] = 107] = "k"; + CharacterCodes[CharacterCodes["l"] = 108] = "l"; + CharacterCodes[CharacterCodes["m"] = 109] = "m"; + CharacterCodes[CharacterCodes["n"] = 110] = "n"; + CharacterCodes[CharacterCodes["o"] = 111] = "o"; + CharacterCodes[CharacterCodes["p"] = 112] = "p"; + CharacterCodes[CharacterCodes["q"] = 113] = "q"; + CharacterCodes[CharacterCodes["r"] = 114] = "r"; + CharacterCodes[CharacterCodes["s"] = 115] = "s"; + CharacterCodes[CharacterCodes["t"] = 116] = "t"; + CharacterCodes[CharacterCodes["u"] = 117] = "u"; + CharacterCodes[CharacterCodes["v"] = 118] = "v"; + CharacterCodes[CharacterCodes["w"] = 119] = "w"; + CharacterCodes[CharacterCodes["x"] = 120] = "x"; + CharacterCodes[CharacterCodes["y"] = 121] = "y"; + CharacterCodes[CharacterCodes["z"] = 122] = "z"; + CharacterCodes[CharacterCodes["A"] = 65] = "A"; + CharacterCodes[CharacterCodes["B"] = 66] = "B"; + CharacterCodes[CharacterCodes["C"] = 67] = "C"; + CharacterCodes[CharacterCodes["D"] = 68] = "D"; + CharacterCodes[CharacterCodes["E"] = 69] = "E"; + CharacterCodes[CharacterCodes["F"] = 70] = "F"; + CharacterCodes[CharacterCodes["G"] = 71] = "G"; + CharacterCodes[CharacterCodes["H"] = 72] = "H"; + CharacterCodes[CharacterCodes["I"] = 73] = "I"; + CharacterCodes[CharacterCodes["J"] = 74] = "J"; + CharacterCodes[CharacterCodes["K"] = 75] = "K"; + CharacterCodes[CharacterCodes["L"] = 76] = "L"; + CharacterCodes[CharacterCodes["M"] = 77] = "M"; + CharacterCodes[CharacterCodes["N"] = 78] = "N"; + CharacterCodes[CharacterCodes["O"] = 79] = "O"; + CharacterCodes[CharacterCodes["P"] = 80] = "P"; + CharacterCodes[CharacterCodes["Q"] = 81] = "Q"; + CharacterCodes[CharacterCodes["R"] = 82] = "R"; + CharacterCodes[CharacterCodes["S"] = 83] = "S"; + CharacterCodes[CharacterCodes["T"] = 84] = "T"; + CharacterCodes[CharacterCodes["U"] = 85] = "U"; + CharacterCodes[CharacterCodes["V"] = 86] = "V"; + CharacterCodes[CharacterCodes["W"] = 87] = "W"; + CharacterCodes[CharacterCodes["X"] = 88] = "X"; + CharacterCodes[CharacterCodes["Y"] = 89] = "Y"; + CharacterCodes[CharacterCodes["Z"] = 90] = "Z"; + CharacterCodes[CharacterCodes["ampersand"] = 38] = "ampersand"; + CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk"; + CharacterCodes[CharacterCodes["at"] = 64] = "at"; + CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash"; + CharacterCodes[CharacterCodes["backtick"] = 96] = "backtick"; + CharacterCodes[CharacterCodes["bar"] = 124] = "bar"; + CharacterCodes[CharacterCodes["caret"] = 94] = "caret"; + CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace"; + CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket"; + CharacterCodes[CharacterCodes["closeParen"] = 41] = "closeParen"; + CharacterCodes[CharacterCodes["colon"] = 58] = "colon"; + CharacterCodes[CharacterCodes["comma"] = 44] = "comma"; + CharacterCodes[CharacterCodes["dot"] = 46] = "dot"; + CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote"; + CharacterCodes[CharacterCodes["equals"] = 61] = "equals"; + CharacterCodes[CharacterCodes["exclamation"] = 33] = "exclamation"; + CharacterCodes[CharacterCodes["greaterThan"] = 62] = "greaterThan"; + CharacterCodes[CharacterCodes["hash"] = 35] = "hash"; + CharacterCodes[CharacterCodes["lessThan"] = 60] = "lessThan"; + CharacterCodes[CharacterCodes["minus"] = 45] = "minus"; + CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace"; + CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket"; + CharacterCodes[CharacterCodes["openParen"] = 40] = "openParen"; + CharacterCodes[CharacterCodes["percent"] = 37] = "percent"; + CharacterCodes[CharacterCodes["plus"] = 43] = "plus"; + CharacterCodes[CharacterCodes["question"] = 63] = "question"; + CharacterCodes[CharacterCodes["semicolon"] = 59] = "semicolon"; + CharacterCodes[CharacterCodes["singleQuote"] = 39] = "singleQuote"; + CharacterCodes[CharacterCodes["slash"] = 47] = "slash"; + CharacterCodes[CharacterCodes["tilde"] = 126] = "tilde"; + CharacterCodes[CharacterCodes["backspace"] = 8] = "backspace"; + CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed"; + CharacterCodes[CharacterCodes["byteOrderMark"] = 65279] = "byteOrderMark"; + CharacterCodes[CharacterCodes["tab"] = 9] = "tab"; + CharacterCodes[CharacterCodes["verticalTab"] = 11] = "verticalTab"; + })(ts.CharacterCodes || (ts.CharacterCodes = {})); + var CharacterCodes = ts.CharacterCodes; + (function (TransformFlags) { + TransformFlags[TransformFlags["None"] = 0] = "None"; + TransformFlags[TransformFlags["TypeScript"] = 1] = "TypeScript"; + TransformFlags[TransformFlags["ContainsTypeScript"] = 2] = "ContainsTypeScript"; + TransformFlags[TransformFlags["Jsx"] = 4] = "Jsx"; + TransformFlags[TransformFlags["ContainsJsx"] = 8] = "ContainsJsx"; + TransformFlags[TransformFlags["ES2017"] = 16] = "ES2017"; + TransformFlags[TransformFlags["ContainsES2017"] = 32] = "ContainsES2017"; + TransformFlags[TransformFlags["ES2016"] = 64] = "ES2016"; + TransformFlags[TransformFlags["ContainsES2016"] = 128] = "ContainsES2016"; + TransformFlags[TransformFlags["ES2015"] = 256] = "ES2015"; + TransformFlags[TransformFlags["ContainsES2015"] = 512] = "ContainsES2015"; + TransformFlags[TransformFlags["DestructuringAssignment"] = 1024] = "DestructuringAssignment"; + TransformFlags[TransformFlags["Generator"] = 2048] = "Generator"; + TransformFlags[TransformFlags["ContainsGenerator"] = 4096] = "ContainsGenerator"; + TransformFlags[TransformFlags["ContainsDecorators"] = 8192] = "ContainsDecorators"; + TransformFlags[TransformFlags["ContainsPropertyInitializer"] = 16384] = "ContainsPropertyInitializer"; + TransformFlags[TransformFlags["ContainsLexicalThis"] = 32768] = "ContainsLexicalThis"; + TransformFlags[TransformFlags["ContainsCapturedLexicalThis"] = 65536] = "ContainsCapturedLexicalThis"; + TransformFlags[TransformFlags["ContainsLexicalThisInComputedPropertyName"] = 131072] = "ContainsLexicalThisInComputedPropertyName"; + TransformFlags[TransformFlags["ContainsDefaultValueAssignments"] = 262144] = "ContainsDefaultValueAssignments"; + TransformFlags[TransformFlags["ContainsParameterPropertyAssignments"] = 524288] = "ContainsParameterPropertyAssignments"; + TransformFlags[TransformFlags["ContainsSpreadElementExpression"] = 1048576] = "ContainsSpreadElementExpression"; + TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 2097152] = "ContainsComputedPropertyName"; + TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 4194304] = "ContainsBlockScopedBinding"; + TransformFlags[TransformFlags["ContainsBindingPattern"] = 8388608] = "ContainsBindingPattern"; + TransformFlags[TransformFlags["ContainsYield"] = 16777216] = "ContainsYield"; + TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 33554432] = "ContainsHoistedDeclarationOrCompletion"; + TransformFlags[TransformFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; + TransformFlags[TransformFlags["AssertTypeScript"] = 3] = "AssertTypeScript"; + TransformFlags[TransformFlags["AssertJsx"] = 12] = "AssertJsx"; + TransformFlags[TransformFlags["AssertES2017"] = 48] = "AssertES2017"; + TransformFlags[TransformFlags["AssertES2016"] = 192] = "AssertES2016"; + TransformFlags[TransformFlags["AssertES2015"] = 768] = "AssertES2015"; + TransformFlags[TransformFlags["AssertGenerator"] = 6144] = "AssertGenerator"; + TransformFlags[TransformFlags["NodeExcludes"] = 536874325] = "NodeExcludes"; + TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 592227669] = "ArrowFunctionExcludes"; + TransformFlags[TransformFlags["FunctionExcludes"] = 592293205] = "FunctionExcludes"; + TransformFlags[TransformFlags["ConstructorExcludes"] = 591760725] = "ConstructorExcludes"; + TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 591760725] = "MethodOrAccessorExcludes"; + TransformFlags[TransformFlags["ClassExcludes"] = 539749717] = "ClassExcludes"; + TransformFlags[TransformFlags["ModuleExcludes"] = 574729557] = "ModuleExcludes"; + TransformFlags[TransformFlags["TypeExcludes"] = -3] = "TypeExcludes"; + TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 539110741] = "ObjectLiteralExcludes"; + TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 537922901] = "ArrayLiteralOrCallOrNewExcludes"; + TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 545262933] = "VariableDeclarationListExcludes"; + TransformFlags[TransformFlags["ParameterExcludes"] = 545262933] = "ParameterExcludes"; + TransformFlags[TransformFlags["TypeScriptClassSyntaxMask"] = 548864] = "TypeScriptClassSyntaxMask"; + TransformFlags[TransformFlags["ES2015FunctionSyntaxMask"] = 327680] = "ES2015FunctionSyntaxMask"; + })(ts.TransformFlags || (ts.TransformFlags = {})); + var TransformFlags = ts.TransformFlags; + (function (EmitFlags) { + EmitFlags[EmitFlags["EmitEmitHelpers"] = 1] = "EmitEmitHelpers"; + EmitFlags[EmitFlags["EmitExportStar"] = 2] = "EmitExportStar"; + EmitFlags[EmitFlags["EmitSuperHelper"] = 4] = "EmitSuperHelper"; + EmitFlags[EmitFlags["EmitAdvancedSuperHelper"] = 8] = "EmitAdvancedSuperHelper"; + EmitFlags[EmitFlags["UMDDefine"] = 16] = "UMDDefine"; + EmitFlags[EmitFlags["SingleLine"] = 32] = "SingleLine"; + EmitFlags[EmitFlags["AdviseOnEmitNode"] = 64] = "AdviseOnEmitNode"; + EmitFlags[EmitFlags["NoSubstitution"] = 128] = "NoSubstitution"; + EmitFlags[EmitFlags["CapturesThis"] = 256] = "CapturesThis"; + EmitFlags[EmitFlags["NoLeadingSourceMap"] = 512] = "NoLeadingSourceMap"; + EmitFlags[EmitFlags["NoTrailingSourceMap"] = 1024] = "NoTrailingSourceMap"; + EmitFlags[EmitFlags["NoSourceMap"] = 1536] = "NoSourceMap"; + EmitFlags[EmitFlags["NoNestedSourceMaps"] = 2048] = "NoNestedSourceMaps"; + EmitFlags[EmitFlags["NoTokenLeadingSourceMaps"] = 4096] = "NoTokenLeadingSourceMaps"; + EmitFlags[EmitFlags["NoTokenTrailingSourceMaps"] = 8192] = "NoTokenTrailingSourceMaps"; + EmitFlags[EmitFlags["NoTokenSourceMaps"] = 12288] = "NoTokenSourceMaps"; + EmitFlags[EmitFlags["NoLeadingComments"] = 16384] = "NoLeadingComments"; + EmitFlags[EmitFlags["NoTrailingComments"] = 32768] = "NoTrailingComments"; + EmitFlags[EmitFlags["NoComments"] = 49152] = "NoComments"; + EmitFlags[EmitFlags["NoNestedComments"] = 65536] = "NoNestedComments"; + EmitFlags[EmitFlags["ExportName"] = 131072] = "ExportName"; + EmitFlags[EmitFlags["LocalName"] = 262144] = "LocalName"; + EmitFlags[EmitFlags["Indented"] = 524288] = "Indented"; + EmitFlags[EmitFlags["NoIndentation"] = 1048576] = "NoIndentation"; + EmitFlags[EmitFlags["AsyncFunctionBody"] = 2097152] = "AsyncFunctionBody"; + EmitFlags[EmitFlags["ReuseTempVariableScope"] = 4194304] = "ReuseTempVariableScope"; + EmitFlags[EmitFlags["CustomPrologue"] = 8388608] = "CustomPrologue"; + })(ts.EmitFlags || (ts.EmitFlags = {})); + var EmitFlags = ts.EmitFlags; + (function (EmitContext) { + EmitContext[EmitContext["SourceFile"] = 0] = "SourceFile"; + EmitContext[EmitContext["Expression"] = 1] = "Expression"; + EmitContext[EmitContext["IdentifierName"] = 2] = "IdentifierName"; + EmitContext[EmitContext["Unspecified"] = 3] = "Unspecified"; + })(ts.EmitContext || (ts.EmitContext = {})); + var EmitContext = ts.EmitContext; })(ts || (ts = {})); var ts; (function (ts) { @@ -77,7 +938,7 @@ var ts; (function (performance) { var profilerEvent = typeof onProfilerEvent === "function" && onProfilerEvent.profiler === true ? onProfilerEvent - : function (markName) { }; + : function (_markName) { }; var enabled = false; var profilerStart = 0; var counts; @@ -129,7 +990,14 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + (function (Ternary) { + Ternary[Ternary["False"] = 0] = "False"; + Ternary[Ternary["Maybe"] = 1] = "Maybe"; + Ternary[Ternary["True"] = -1] = "True"; + })(ts.Ternary || (ts.Ternary = {})); + var Ternary = ts.Ternary; var createObject = Object.create; + ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; function createMap(template) { var map = createObject(null); map["__"] = undefined; @@ -150,7 +1018,7 @@ var ts; remove: remove, forEachValue: forEachValueInMap, getKeys: getKeys, - clear: clear + clear: clear, }; function forEachValueInMap(f) { for (var key in files) { @@ -192,6 +1060,12 @@ var ts; return getCanonicalFileName(nonCanonicalizedPath); } ts.toPath = toPath; + (function (Comparison) { + Comparison[Comparison["LessThan"] = -1] = "LessThan"; + Comparison[Comparison["EqualTo"] = 0] = "EqualTo"; + Comparison[Comparison["GreaterThan"] = 1] = "GreaterThan"; + })(ts.Comparison || (ts.Comparison = {})); + var Comparison = ts.Comparison; function forEach(array, callback) { if (array) { for (var i = 0, len = array.length; i < len; i++) { @@ -335,13 +1209,32 @@ var ts; if (array) { result = []; for (var i = 0; i < array.length; i++) { - var v = array[i]; - result.push(f(v, i)); + result.push(f(array[i], i)); } } return result; } ts.map = map; + function sameMap(array, f) { + var result; + if (array) { + for (var i = 0; i < array.length; i++) { + if (result) { + result.push(f(array[i], i)); + } + else { + var item = array[i]; + var mapped = f(item, i); + if (item !== mapped) { + result = array.slice(0, i); + result.push(mapped); + } + } + } + } + return result || array; + } + ts.sameMap = sameMap; function flatten(array) { var result; if (array) { @@ -442,6 +1335,18 @@ var ts; return result; } ts.mapObject = mapObject; + function some(array, predicate) { + if (array) { + for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { + var v = array_5[_i]; + if (!predicate || predicate(v)) { + return true; + } + } + } + return false; + } + ts.some = some; function concatenate(array1, array2) { if (!array2 || !array2.length) return array1; @@ -454,8 +1359,8 @@ var ts; var result; if (array) { result = []; - loop: for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { - var item = array_5[_i]; + loop: for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { + var item = array_6[_i]; for (var _a = 0, result_1 = result; _a < result_1.length; _a++) { var res = result_1[_a]; if (areEqual ? areEqual(res, item) : res === item) { @@ -488,8 +1393,8 @@ var ts; ts.compact = compact; function sum(array, prop) { var result = 0; - for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { - var v = array_6[_i]; + for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { + var v = array_7[_i]; result += v[prop]; } return result; @@ -708,8 +1613,8 @@ var ts; ts.equalOwnProperties = equalOwnProperties; function arrayToMap(array, makeKey, makeValue) { var result = createMap(); - for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { - var value = array_7[_i]; + for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { + var value = array_8[_i]; result[makeKey(value)] = makeValue ? makeValue(value) : value; } return result; @@ -810,7 +1715,7 @@ var ts; return function (t) { return compose(a(t)); }; } else { - return function (t) { return function (u) { return u; }; }; + return function (_) { return function (u) { return u; }; }; } } ts.chain = chain; @@ -841,7 +1746,7 @@ var ts; ts.compose = compose; function formatStringFromArgs(text, args, baseIndex) { baseIndex = baseIndex || 0; - return text.replace(/{(\d+)}/g, function (match, index) { return args[+index + baseIndex]; }); + return text.replace(/{(\d+)}/g, function (_match, index) { return args[+index + baseIndex]; }); } ts.localizedDiagnosticMessages = undefined; function getLocaleSpecificMessage(message) { @@ -866,11 +1771,11 @@ var ts; length: length, messageText: text, category: message.category, - code: message.code + code: message.code, }; } ts.createFileDiagnostic = createFileDiagnostic; - function formatMessage(dummy, message) { + function formatMessage(_dummy, message) { var text = getLocaleSpecificMessage(message); if (arguments.length > 2) { text = formatStringFromArgs(text, arguments, 2); @@ -933,7 +1838,7 @@ var ts; if (b === undefined) return 1; if (ignoreCase) { - if (String.prototype.localeCompare) { + if (ts.collator && String.prototype.localeCompare) { var result = a.localeCompare(b, undefined, { usage: "sort", sensitivity: "accent" }); return result < 0 ? -1 : result > 0 ? 1 : 0; } @@ -1086,7 +1991,7 @@ var ts; function getEmitModuleKind(compilerOptions) { return typeof compilerOptions.module === "number" ? compilerOptions.module : - getEmitScriptTarget(compilerOptions) === 2 ? ts.ModuleKind.ES6 : ts.ModuleKind.CommonJS; + getEmitScriptTarget(compilerOptions) >= 2 ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS; } ts.getEmitModuleKind = getEmitModuleKind; function hasZeroOrOneAsteriskCharacter(str) { @@ -1383,7 +2288,7 @@ var ts; function replaceWildcardCharacter(match, singleAsteriskRegexFragment) { return match === "*" ? singleAsteriskRegexFragment : match === "?" ? "[^/]" : "\\" + match; } - function getFileMatcherPatterns(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory) { + function getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory) { path = normalizePath(path); currentDirectory = normalizePath(currentDirectory); var absolutePath = combinePaths(currentDirectory, path); @@ -1398,7 +2303,7 @@ var ts; function matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, getFileSystemEntries) { path = normalizePath(path); currentDirectory = normalizePath(currentDirectory); - var patterns = getFileMatcherPatterns(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory); + var patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory); var regexFlag = useCaseSensitiveFileNames ? "" : "i"; var includeFileRegex = patterns.includeFilePattern && new RegExp(patterns.includeFilePattern, regexFlag); var includeDirectoryRegex = patterns.includeDirectoryPattern && new RegExp(patterns.includeDirectoryPattern, regexFlag); @@ -1508,6 +2413,14 @@ var ts; return false; } ts.isSupportedSourceFileName = isSupportedSourceFileName; + (function (ExtensionPriority) { + ExtensionPriority[ExtensionPriority["TypeScriptFiles"] = 0] = "TypeScriptFiles"; + ExtensionPriority[ExtensionPriority["DeclarationAndJavaScriptFiles"] = 2] = "DeclarationAndJavaScriptFiles"; + ExtensionPriority[ExtensionPriority["Limit"] = 5] = "Limit"; + ExtensionPriority[ExtensionPriority["Highest"] = 0] = "Highest"; + ExtensionPriority[ExtensionPriority["Lowest"] = 2] = "Lowest"; + })(ts.ExtensionPriority || (ts.ExtensionPriority = {})); + var ExtensionPriority = ts.ExtensionPriority; function getExtensionPriority(path, supportedExtensions) { for (var i = supportedExtensions.length - 1; i >= 0; i--) { if (fileExtensionIs(path, supportedExtensions[i])) { @@ -1571,10 +2484,10 @@ var ts; this.name = name; this.declarations = undefined; } - function Type(checker, flags) { + function Type(_checker, flags) { this.flags = flags; } - function Signature(checker) { + function Signature() { } function Node(kind, pos, end) { this.id = 0; @@ -1596,6 +2509,13 @@ var ts; getTypeConstructor: function () { return Type; }, getSignatureConstructor: function () { return Signature; } }; + (function (AssertionLevel) { + AssertionLevel[AssertionLevel["None"] = 0] = "None"; + AssertionLevel[AssertionLevel["Normal"] = 1] = "Normal"; + AssertionLevel[AssertionLevel["Aggressive"] = 2] = "Aggressive"; + AssertionLevel[AssertionLevel["VeryAggressive"] = 3] = "VeryAggressive"; + })(ts.AssertionLevel || (ts.AssertionLevel = {})); + var AssertionLevel = ts.AssertionLevel; var Debug; (function (Debug) { Debug.currentAssertionLevel = 0; @@ -1908,7 +2828,7 @@ var ts; } var platform = _os.platform(); var useCaseSensitiveFileNames = isFileSystemCaseSensitive(); - function readFile(fileName, encoding) { + function readFile(fileName, _encoding) { if (!fileExists(fileName)) { return undefined; } @@ -1980,6 +2900,11 @@ var ts; function readDirectory(path, extensions, excludes, includes) { return ts.matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, process.cwd(), getAccessibleFileSystemEntries); } + var FileSystemEntryKind; + (function (FileSystemEntryKind) { + FileSystemEntryKind[FileSystemEntryKind["File"] = 0] = "File"; + FileSystemEntryKind[FileSystemEntryKind["Directory"] = 1] = "Directory"; + })(FileSystemEntryKind || (FileSystemEntryKind = {})); function fileSystemEntryExists(path, entryKind) { try { var stat = _fs.statSync(path); @@ -2121,7 +3046,7 @@ var ts; args: ChakraHost.args, useCaseSensitiveFileNames: !!ChakraHost.useCaseSensitiveFileNames, write: ChakraHost.echo, - readFile: function (path, encoding) { + readFile: function (path, _encoding) { return ChakraHost.readFile(path); }, writeFile: function (path, data, writeByteOrderMark) { @@ -2137,9 +3062,9 @@ var ts; getExecutingFilePath: function () { return ChakraHost.executingFile; }, getCurrentDirectory: function () { return ChakraHost.currentDirectory; }, getDirectories: ChakraHost.getDirectories, - getEnvironmentVariable: ChakraHost.getEnvironmentVariable || (function (name) { return ""; }), + getEnvironmentVariable: ChakraHost.getEnvironmentVariable || (function () { return ""; }), readDirectory: function (path, extensions, excludes, includes) { - var pattern = ts.getFileMatcherPatterns(path, extensions, excludes, includes, !!ChakraHost.useCaseSensitiveFileNames, ChakraHost.currentDirectory); + var pattern = ts.getFileMatcherPatterns(path, excludes, includes, !!ChakraHost.useCaseSensitiveFileNames, ChakraHost.currentDirectory); return ChakraHost.readDirectory(path, extensions, pattern.basePaths, pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern); }, exit: ChakraHost.quit, @@ -2927,7 +3852,7 @@ var ts; Binding_element_0_implicitly_has_an_1_type: { code: 7031, category: ts.DiagnosticCategory.Error, key: "Binding_element_0_implicitly_has_an_1_type_7031", message: "Binding element '{0}' implicitly has an '{1}' type." }, Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation: { code: 7032, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation_7032", message: "Property '{0}' implicitly has type 'any', because its set accessor lacks a parameter type annotation." }, Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation: { code: 7033, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation_7033", message: "Property '{0}' implicitly has type 'any', because its get accessor lacks a return type annotation." }, - Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined: { code: 7034, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_type_any_in_some_locations_where_its_type_cannot_be_determined_7034", message: "Variable '{0}' implicitly has type 'any' in some locations where its type cannot be determined." }, + Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined: { code: 7034, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined_7034", message: "Variable '{0}' implicitly has type '{1}' in some locations where its type cannot be determined." }, You_cannot_rename_this_element: { code: 8000, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_this_element_8000", message: "You cannot rename this element." }, You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", message: "You cannot rename elements that are defined in the standard TypeScript library." }, import_can_only_be_used_in_a_ts_file: { code: 8002, category: ts.DiagnosticCategory.Error, key: "import_can_only_be_used_in_a_ts_file_8002", message: "'import ... =' can only be used in a .ts file." }, @@ -2964,139 +3889,139 @@ var ts; Remove_unused_identifiers: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_unused_identifiers_90004", message: "Remove unused identifiers" }, Implement_interface_on_reference: { code: 90005, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_reference_90005", message: "Implement interface on reference" }, Implement_interface_on_class: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_class_90006", message: "Implement interface on class" }, - Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" } + Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" }, }; })(ts || (ts = {})); var ts; (function (ts) { function tokenIsIdentifierOrKeyword(token) { - return token >= 69; + return token >= 70; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; var textToToken = ts.createMap({ - "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": 136, - "function": 87, - "get": 123, - "if": 88, - "implements": 106, - "import": 89, - "in": 90, - "instanceof": 91, - "interface": 107, - "is": 124, - "let": 108, - "module": 125, - "namespace": 126, - "never": 127, - "new": 92, - "null": 93, - "number": 130, - "package": 109, - "private": 110, - "protected": 111, - "public": 112, - "readonly": 128, - "require": 129, - "global": 137, - "return": 94, - "set": 131, - "static": 113, - "string": 132, - "super": 95, - "switch": 96, - "symbol": 133, - "this": 97, - "throw": 98, - "true": 99, - "try": 100, - "type": 134, - "typeof": 101, - "undefined": 135, - "var": 102, - "void": 103, - "while": 104, - "with": 105, - "yield": 114, - "async": 118, - "await": 119, - "of": 138, - "{": 15, - "}": 16, - "(": 17, - ")": 18, - "[": 19, - "]": 20, - ".": 21, - "...": 22, - ";": 23, - ",": 24, - "<": 25, - ">": 27, - "<=": 28, - ">=": 29, - "==": 30, - "!=": 31, - "===": 32, - "!==": 33, - "=>": 34, - "+": 35, - "-": 36, - "**": 38, - "*": 37, - "/": 39, - "%": 40, - "++": 41, - "--": 42, - "<<": 43, - ">": 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 + "abstract": 116, + "any": 118, + "as": 117, + "boolean": 121, + "break": 71, + "case": 72, + "catch": 73, + "class": 74, + "continue": 76, + "const": 75, + "constructor": 122, + "debugger": 77, + "declare": 123, + "default": 78, + "delete": 79, + "do": 80, + "else": 81, + "enum": 82, + "export": 83, + "extends": 84, + "false": 85, + "finally": 86, + "for": 87, + "from": 137, + "function": 88, + "get": 124, + "if": 89, + "implements": 107, + "import": 90, + "in": 91, + "instanceof": 92, + "interface": 108, + "is": 125, + "let": 109, + "module": 126, + "namespace": 127, + "never": 128, + "new": 93, + "null": 94, + "number": 131, + "package": 110, + "private": 111, + "protected": 112, + "public": 113, + "readonly": 129, + "require": 130, + "global": 138, + "return": 95, + "set": 132, + "static": 114, + "string": 133, + "super": 96, + "switch": 97, + "symbol": 134, + "this": 98, + "throw": 99, + "true": 100, + "try": 101, + "type": 135, + "typeof": 102, + "undefined": 136, + "var": 103, + "void": 104, + "while": 105, + "with": 106, + "yield": 115, + "async": 119, + "await": 120, + "of": 139, + "{": 16, + "}": 17, + "(": 18, + ")": 19, + "[": 20, + "]": 21, + ".": 22, + "...": 23, + ";": 24, + ",": 25, + "<": 26, + ">": 28, + "<=": 29, + ">=": 30, + "==": 31, + "!=": 32, + "===": 33, + "!==": 34, + "=>": 35, + "+": 36, + "-": 37, + "**": 39, + "*": 38, + "/": 40, + "%": 41, + "++": 42, + "--": 43, + "<<": 44, + ">": 45, + ">>>": 46, + "&": 47, + "|": 48, + "^": 49, + "!": 50, + "~": 51, + "&&": 52, + "||": 53, + "?": 54, + ":": 55, + "=": 57, + "+=": 58, + "-=": 59, + "*=": 60, + "**=": 61, + "/=": 62, + "%=": 63, + "<<=": 64, + ">>=": 65, + ">>>=": 66, + "&=": 67, + "|=": 68, + "^=": 69, + "@": 56, }); 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,]; @@ -3493,7 +4418,7 @@ var ts; return iterateCommentRanges(true, text, pos, true, cb, state, initial); } ts.reduceEachTrailingCommentRange = reduceEachTrailingCommentRange; - function appendCommentRange(pos, end, kind, hasTrailingNewLine, state, comments) { + function appendCommentRange(pos, end, kind, hasTrailingNewLine, _state, comments) { if (!comments) { comments = []; } @@ -3559,8 +4484,8 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 69 || token > 105; }, - isReservedWord: function () { return token >= 70 && token <= 105; }, + isIdentifier: function () { return token === 70 || token > 106; }, + isReservedWord: function () { return token >= 71 && token <= 106; }, isUnterminated: function () { return tokenIsUnterminated; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, @@ -3579,7 +4504,7 @@ var ts; setTextPos: setTextPos, tryScan: tryScan, lookAhead: lookAhead, - scanRange: scanRange + scanRange: scanRange, }; function error(message, length) { if (onError) { @@ -3696,20 +4621,20 @@ var ts; contents += text.substring(start, pos); tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 11 : 14; + resultingToken = startedWithBacktick ? 12 : 15; break; } var currChar = text.charCodeAt(pos); if (currChar === 96) { contents += text.substring(start, pos); pos++; - resultingToken = startedWithBacktick ? 11 : 14; + resultingToken = startedWithBacktick ? 12 : 15; break; } if (currChar === 36 && pos + 1 < end && text.charCodeAt(pos + 1) === 123) { contents += text.substring(start, pos); pos += 2; - resultingToken = startedWithBacktick ? 12 : 13; + resultingToken = startedWithBacktick ? 13 : 14; break; } if (currChar === 92) { @@ -3871,7 +4796,7 @@ var ts; return token = textToToken[tokenValue]; } } - return token = 69; + return token = 70; } function scanBinaryOrOctalDigits(base) { ts.Debug.assert(base === 2 || base === 8, "Expected either base 2 or base 8"); @@ -3946,12 +4871,12 @@ var ts; case 33: if (text.charCodeAt(pos + 1) === 61) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 33; + return pos += 3, token = 34; } - return pos += 2, token = 31; + return pos += 2, token = 32; } pos++; - return token = 49; + return token = 50; case 34: case 39: tokenValue = scanString(); @@ -3960,51 +4885,39 @@ var ts; return token = scanTemplateAndSetTokenValue(); case 37: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 62; + return pos += 2, token = 63; } pos++; - return token = 40; + return token = 41; case 38: if (text.charCodeAt(pos + 1) === 38) { - return pos += 2, token = 51; + return pos += 2, token = 52; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 66; + return pos += 2, token = 67; } pos++; - return token = 46; + return token = 47; case 40: pos++; - return token = 17; + return token = 18; case 41: pos++; - return token = 18; + return token = 19; case 42: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 59; + return pos += 2, token = 60; } if (text.charCodeAt(pos + 1) === 42) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 60; + return pos += 3, token = 61; } - return pos += 2, token = 38; + return pos += 2, token = 39; } pos++; - return token = 37; + return token = 38; case 43: if (text.charCodeAt(pos + 1) === 43) { - return pos += 2, token = 41; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 57; - } - pos++; - return token = 35; - case 44: - pos++; - return token = 24; - case 45: - if (text.charCodeAt(pos + 1) === 45) { return pos += 2, token = 42; } if (text.charCodeAt(pos + 1) === 61) { @@ -4012,16 +4925,28 @@ var ts; } pos++; return token = 36; + case 44: + pos++; + return token = 25; + case 45: + if (text.charCodeAt(pos + 1) === 45) { + return pos += 2, token = 43; + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 59; + } + pos++; + return token = 37; case 46: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = scanNumber(); return token = 8; } if (text.charCodeAt(pos + 1) === 46 && text.charCodeAt(pos + 2) === 46) { - return pos += 3, token = 22; + return pos += 3, token = 23; } pos++; - return token = 21; + return token = 22; case 47: if (text.charCodeAt(pos + 1) === 47) { pos += 2; @@ -4065,10 +4990,10 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 61; + return pos += 2, token = 62; } pos++; - return token = 39; + return token = 40; case 48: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 || text.charCodeAt(pos + 1) === 120)) { pos += 2; @@ -4117,10 +5042,10 @@ var ts; return token = 8; case 58: pos++; - return token = 54; + return token = 55; case 59: pos++; - return token = 23; + return token = 24; case 60: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -4133,20 +5058,20 @@ var ts; } if (text.charCodeAt(pos + 1) === 60) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 63; + return pos += 3, token = 64; } - return pos += 2, token = 43; + return pos += 2, token = 44; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 28; + return pos += 2, token = 29; } if (languageVariant === 1 && text.charCodeAt(pos + 1) === 47 && text.charCodeAt(pos + 2) !== 42) { - return pos += 2, token = 26; + return pos += 2, token = 27; } pos++; - return token = 25; + return token = 26; case 61: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -4159,15 +5084,15 @@ var ts; } if (text.charCodeAt(pos + 1) === 61) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 32; + return pos += 3, token = 33; } - return pos += 2, token = 30; + return pos += 2, token = 31; } if (text.charCodeAt(pos + 1) === 62) { - return pos += 2, token = 34; + return pos += 2, token = 35; } pos++; - return token = 56; + return token = 57; case 62: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -4179,43 +5104,43 @@ var ts; } } pos++; - return token = 27; + return token = 28; case 63: pos++; - return token = 53; + return token = 54; case 91: pos++; - return token = 19; + return token = 20; case 93: pos++; - return token = 20; + return token = 21; case 94: + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 69; + } + pos++; + return token = 49; + case 123: + pos++; + return token = 16; + case 124: + if (text.charCodeAt(pos + 1) === 124) { + return pos += 2, token = 53; + } if (text.charCodeAt(pos + 1) === 61) { return pos += 2, token = 68; } pos++; return token = 48; - case 123: - pos++; - return token = 15; - case 124: - if (text.charCodeAt(pos + 1) === 124) { - return pos += 2, token = 52; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 67; - } - pos++; - return token = 47; case 125: pos++; - return token = 16; + return token = 17; case 126: pos++; - return token = 50; + return token = 51; case 64: pos++; - return token = 55; + return token = 56; case 92: var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { @@ -4253,29 +5178,29 @@ var ts; } } function reScanGreaterToken() { - if (token === 27) { + if (token === 28) { if (text.charCodeAt(pos) === 62) { if (text.charCodeAt(pos + 1) === 62) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 65; + return pos += 3, token = 66; } - return pos += 2, token = 45; + return pos += 2, token = 46; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 64; + return pos += 2, token = 65; } pos++; - return token = 44; + return token = 45; } if (text.charCodeAt(pos) === 61) { pos++; - return token = 29; + return token = 30; } } return token; } function reScanSlashToken() { - if (token === 39 || token === 61) { + if (token === 40 || token === 62) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -4314,12 +5239,12 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 10; + token = 11; } return token; } function reScanTemplateToken() { - ts.Debug.assert(token === 16, "'reScanTemplateToken' should only be called on a '}'"); + ts.Debug.assert(token === 17, "'reScanTemplateToken' should only be called on a '}'"); pos = tokenPos; return token = scanTemplateAndSetTokenValue(); } @@ -4336,14 +5261,14 @@ var ts; if (char === 60) { if (text.charCodeAt(pos + 1) === 47) { pos += 2; - return token = 26; + return token = 27; } pos++; - return token = 25; + return token = 26; } if (char === 123) { pos++; - return token = 15; + return token = 16; } while (pos < end) { pos++; @@ -4352,7 +5277,7 @@ var ts; break; } } - return token = 244; + return token = 10; } function scanJsxIdentifier() { if (tokenIsIdentifierOrKeyword(token)) { @@ -4399,39 +5324,39 @@ var ts; return token = 5; case 64: pos++; - return token = 55; + return token = 56; case 10: case 13: pos++; return token = 4; case 42: pos++; - return token = 37; + return token = 38; case 123: pos++; - return token = 15; + return token = 16; case 125: pos++; - return token = 16; + return token = 17; case 91: pos++; - return token = 19; + return token = 20; case 93: pos++; - return token = 20; + return token = 21; case 61: pos++; - return token = 56; + return token = 57; case 44: pos++; - return token = 24; + return token = 25; } - if (isIdentifierStart(ch, 2)) { + if (isIdentifierStart(ch, 4)) { pos++; - while (isIdentifierPart(text.charCodeAt(pos), 2) && pos < end) { + while (isIdentifierPart(text.charCodeAt(pos), 4) && pos < end) { pos++; } - return token = 69; + return token = 70; } else { return pos += 1, token = 0; @@ -4521,24 +5446,24 @@ var ts; ts.optionDeclarations = [ { name: "charset", - type: "string" + type: "string", }, ts.compileOnSaveCommandLineOption, { name: "declaration", shortName: "d", type: "boolean", - description: ts.Diagnostics.Generates_corresponding_d_ts_file + description: ts.Diagnostics.Generates_corresponding_d_ts_file, }, { name: "declarationDir", type: "string", isFilePath: true, - paramType: ts.Diagnostics.DIRECTORY + paramType: ts.Diagnostics.DIRECTORY, }, { name: "diagnostics", - type: "boolean" + type: "boolean", }, { name: "extendedDiagnostics", @@ -4553,7 +5478,7 @@ var ts; name: "help", shortName: "h", type: "boolean", - description: ts.Diagnostics.Print_this_message + description: ts.Diagnostics.Print_this_message, }, { name: "help", @@ -4563,15 +5488,15 @@ var ts; { name: "init", type: "boolean", - description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file + description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file, }, { name: "inlineSourceMap", - type: "boolean" + type: "boolean", }, { name: "inlineSources", - type: "boolean" + type: "boolean", }, { name: "jsx", @@ -4580,7 +5505,7 @@ var ts; "react": 2 }), paramType: ts.Diagnostics.KIND, - description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react + description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, }, { name: "reactNamespace", @@ -4589,18 +5514,18 @@ var ts; }, { name: "listFiles", - type: "boolean" + type: "boolean", }, { name: "locale", - type: "string" + type: "string", }, { name: "mapRoot", type: "string", isFilePath: true, description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, - paramType: ts.Diagnostics.LOCATION + paramType: ts.Diagnostics.LOCATION, }, { name: "module", @@ -4611,11 +5536,11 @@ var ts; "amd": ts.ModuleKind.AMD, "system": ts.ModuleKind.System, "umd": ts.ModuleKind.UMD, - "es6": ts.ModuleKind.ES6, - "es2015": ts.ModuleKind.ES2015 + "es6": ts.ModuleKind.ES2015, + "es2015": ts.ModuleKind.ES2015, }), description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, - paramType: ts.Diagnostics.KIND + paramType: ts.Diagnostics.KIND, }, { name: "newLine", @@ -4624,12 +5549,12 @@ var ts; "lf": 1 }), description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, - paramType: ts.Diagnostics.NEWLINE + paramType: ts.Diagnostics.NEWLINE, }, { name: "noEmit", type: "boolean", - description: ts.Diagnostics.Do_not_emit_outputs + description: ts.Diagnostics.Do_not_emit_outputs, }, { name: "noEmitHelpers", @@ -4638,7 +5563,7 @@ var ts; { name: "noEmitOnError", type: "boolean", - description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported + description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, }, { name: "noErrorTruncation", @@ -4647,59 +5572,59 @@ var ts; { name: "noImplicitAny", type: "boolean", - description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type + description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type, }, { name: "noImplicitThis", type: "boolean", - description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type + description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, }, { name: "noUnusedLocals", type: "boolean", - description: ts.Diagnostics.Report_errors_on_unused_locals + description: ts.Diagnostics.Report_errors_on_unused_locals, }, { name: "noUnusedParameters", type: "boolean", - description: ts.Diagnostics.Report_errors_on_unused_parameters + description: ts.Diagnostics.Report_errors_on_unused_parameters, }, { name: "noLib", - type: "boolean" + type: "boolean", }, { name: "noResolve", - type: "boolean" + type: "boolean", }, { name: "skipDefaultLibCheck", - type: "boolean" + type: "boolean", }, { name: "skipLibCheck", type: "boolean", - description: ts.Diagnostics.Skip_type_checking_of_declaration_files + description: ts.Diagnostics.Skip_type_checking_of_declaration_files, }, { name: "out", type: "string", isFilePath: false, - paramType: ts.Diagnostics.FILE + paramType: ts.Diagnostics.FILE, }, { name: "outFile", type: "string", isFilePath: true, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, - paramType: ts.Diagnostics.FILE + paramType: ts.Diagnostics.FILE, }, { name: "outDir", type: "string", isFilePath: true, description: ts.Diagnostics.Redirect_output_structure_to_the_directory, - paramType: ts.Diagnostics.DIRECTORY + paramType: ts.Diagnostics.DIRECTORY, }, { name: "preserveConstEnums", @@ -4722,30 +5647,30 @@ var ts; { name: "removeComments", type: "boolean", - description: ts.Diagnostics.Do_not_emit_comments_to_output + description: ts.Diagnostics.Do_not_emit_comments_to_output, }, { name: "rootDir", type: "string", isFilePath: true, paramType: ts.Diagnostics.LOCATION, - description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir + description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, }, { name: "isolatedModules", - type: "boolean" + type: "boolean", }, { name: "sourceMap", type: "boolean", - description: ts.Diagnostics.Generates_corresponding_map_file + description: ts.Diagnostics.Generates_corresponding_map_file, }, { name: "sourceRoot", type: "string", isFilePath: true, description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, - paramType: ts.Diagnostics.LOCATION + paramType: ts.Diagnostics.LOCATION, }, { name: "suppressExcessPropertyErrors", @@ -4756,7 +5681,7 @@ var ts; { name: "suppressImplicitAnyIndexErrors", type: "boolean", - description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures + description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, }, { name: "stripInternal", @@ -4771,22 +5696,24 @@ var ts; "es3": 0, "es5": 1, "es6": 2, - "es2015": 2 + "es2015": 2, + "es2016": 3, + "es2017": 4, }), description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015, - paramType: ts.Diagnostics.VERSION + paramType: ts.Diagnostics.VERSION, }, { name: "version", shortName: "v", type: "boolean", - description: ts.Diagnostics.Print_the_compiler_s_version + description: ts.Diagnostics.Print_the_compiler_s_version, }, { name: "watch", shortName: "w", type: "boolean", - description: ts.Diagnostics.Watch_input_files + description: ts.Diagnostics.Watch_input_files, }, { name: "experimentalDecorators", @@ -4803,10 +5730,10 @@ var ts; name: "moduleResolution", type: ts.createMap({ "node": ts.ModuleResolutionKind.NodeJs, - "classic": ts.ModuleResolutionKind.Classic + "classic": ts.ModuleResolutionKind.Classic, }), description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, - paramType: ts.Diagnostics.STRATEGY + paramType: ts.Diagnostics.STRATEGY, }, { name: "allowUnusedLabels", @@ -4929,7 +5856,7 @@ var ts; "es2016.array.include": "lib.es2016.array.include.d.ts", "es2017.object": "lib.es2017.object.d.ts", "es2017.sharedmemory": "lib.es2017.sharedmemory.d.ts" - }) + }), }, description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon }, @@ -4956,7 +5883,7 @@ var ts; ts.typingOptionDeclarations = [ { name: "enableAutoDiscovery", - type: "boolean" + type: "boolean", }, { name: "include", @@ -4979,7 +5906,7 @@ var ts; module: ts.ModuleKind.CommonJS, target: 1, noImplicitAny: false, - sourceMap: false + sourceMap: false, }; var optionNameMapCache; function getOptionNameMap() { @@ -4999,10 +5926,7 @@ var ts; } ts.getOptionNameMap = getOptionNameMap; function createCompilerDiagnosticForInvalidCustomType(opt) { - var namesOfType = []; - for (var key in opt.type) { - namesOfType.push(" '" + key + "'"); - } + var namesOfType = Object.keys(opt.type).map(function (key) { return "'" + key + "'"; }).join(", "); return ts.createCompilerDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); } ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; @@ -5608,7 +6532,7 @@ var ts; ; var safeList; var EmptySafeList = ts.createMap(); - function discoverTypings(host, fileNames, projectRootPath, safeListPath, packageNameToTypingLocation, typingOptions, compilerOptions) { + function discoverTypings(host, fileNames, projectRootPath, safeListPath, packageNameToTypingLocation, typingOptions) { var inferredTypings = ts.createMap(); if (!typingOptions || !typingOptions.enableAutoDiscovery) { return { cachedTypingPaths: [], newTypingNames: [], filesToWatch: [] }; @@ -5743,7 +6667,7 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function trace(host, message) { + function trace(host) { host.trace(ts.formatMessage.apply(undefined, arguments)); } ts.trace = trace; @@ -6342,10 +7266,9 @@ var ts; typingsInstaller.NpmViewRequest = "npm view"; typingsInstaller.NpmInstallRequest = "npm install"; var TypingsInstaller = (function () { - function TypingsInstaller(globalCachePath, npmPath, safeListPath, throttleLimit, log) { + function TypingsInstaller(globalCachePath, safeListPath, throttleLimit, log) { if (log === void 0) { log = nullLog; } this.globalCachePath = globalCachePath; - this.npmPath = npmPath; this.safeListPath = safeListPath; this.throttleLimit = throttleLimit; this.log = log; @@ -6396,7 +7319,7 @@ var ts; } this.processCacheLocation(req.cachePath); } - var discoverTypingsResult = ts.JsTyping.discoverTypings(this.installTypingHost, req.fileNames, req.projectRootPath, this.safeListPath, this.packageNameToTypingLocation, req.typingOptions, req.compilerOptions); + var discoverTypingsResult = ts.JsTyping.discoverTypings(this.installTypingHost, req.fileNames, req.projectRootPath, this.safeListPath, this.packageNameToTypingLocation, req.typingOptions); if (this.log.isEnabled()) { this.log.writeLine("Finished typings discovery: " + JSON.stringify(discoverTypingsResult)); } @@ -6567,12 +7490,11 @@ var ts; var filteredTypings = []; for (var _i = 0, typingsToInstall_3 = typingsToInstall; _i < typingsToInstall_3.length; _i++) { var typing = typingsToInstall_3[_i]; - execNpmViewTyping(this, typing); + filterExistingTypings(this, typing); } - function execNpmViewTyping(self, typing) { - var command = self.npmPath + " view @types/" + typing + " --silent name"; - self.execAsync(typingsInstaller.NpmViewRequest, requestId, command, cachePath, function (err, stdout, stderr) { - if (stdout) { + function filterExistingTypings(self, typing) { + self.execAsync(typingsInstaller.NpmViewRequest, requestId, [typing], cachePath, function (ok) { + if (ok) { filteredTypings.push(typing); } execInstallCmdCount++; @@ -6587,9 +7509,8 @@ var ts; return; } var scopedTypings = filteredTypings.map(function (t) { return "@types/" + t; }); - var command = self.npmPath + " install " + scopedTypings.join(" ") + " --save-dev"; - self.execAsync(typingsInstaller.NpmInstallRequest, requestId, command, cachePath, function (err, stdout, stderr) { - postInstallAction(stdout ? scopedTypings : []); + self.execAsync(typingsInstaller.NpmInstallRequest, requestId, scopedTypings, cachePath, function (ok) { + postInstallAction(ok ? scopedTypings : []); }); } }; @@ -6632,8 +7553,8 @@ var ts; kind: "set" }; }; - TypingsInstaller.prototype.execAsync = function (requestKind, requestId, command, cwd, onRequestCompleted) { - this.pendingRunRequests.unshift({ requestKind: requestKind, requestId: requestId, command: command, cwd: cwd, onRequestCompleted: onRequestCompleted }); + TypingsInstaller.prototype.execAsync = function (requestKind, requestId, args, cwd, onRequestCompleted) { + this.pendingRunRequests.unshift({ requestKind: requestKind, requestId: requestId, args: args, cwd: cwd, onRequestCompleted: onRequestCompleted }); this.executeWithThrottling(); }; TypingsInstaller.prototype.executeWithThrottling = function () { @@ -6641,9 +7562,9 @@ var ts; var _loop_1 = function () { this_1.inFlightRequestCount++; var request = this_1.pendingRunRequests.pop(); - this_1.runCommand(request.requestKind, request.requestId, request.command, request.cwd, function (err, stdout, stderr) { + this_1.executeRequest(request.requestKind, request.requestId, request.args, request.cwd, function (ok) { _this.inFlightRequestCount--; - request.onRequestCompleted(err, stdout, stderr); + request.onRequestCompleted(ok); _this.executeWithThrottling(); }); }; @@ -6689,13 +7610,14 @@ var ts; var NodeTypingsInstaller = (function (_super) { __extends(NodeTypingsInstaller, _super); function NodeTypingsInstaller(globalTypingsCacheLocation, throttleLimit, log) { - var _this = _super.call(this, globalTypingsCacheLocation, getNPMLocation(process.argv[0]), ts.toPath("typingSafeList.json", __dirname, ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)), throttleLimit, log) || this; + var _this = _super.call(this, globalTypingsCacheLocation, ts.toPath("typingSafeList.json", __dirname, ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)), throttleLimit, log) || this; _this.installTypingHost = ts.sys; if (_this.log.isEnabled()) { _this.log.writeLine("Process id: " + process.pid); } - var exec = require("child_process").exec; - _this.exec = exec; + _this.npmPath = getNPMLocation(process.argv[0]); + _this.exec = require("child_process").exec; + _this.httpGet = require("http").get; return _this; } NodeTypingsInstaller.prototype.init = function () { @@ -6720,18 +7642,54 @@ var ts; this.log.writeLine("Response has been sent."); } }; - NodeTypingsInstaller.prototype.runCommand = function (requestKind, requestId, command, cwd, onRequestCompleted) { + NodeTypingsInstaller.prototype.executeRequest = function (requestKind, requestId, args, cwd, onRequestCompleted) { var _this = this; if (this.log.isEnabled()) { - this.log.writeLine("#" + requestId + " running command '" + command + "'."); + this.log.writeLine("#" + requestId + " executing " + requestKind + ", arguments'" + JSON.stringify(args) + "'."); + } + switch (requestKind) { + case typingsInstaller.NpmViewRequest: + { + ts.Debug.assert(args.length === 1); + var url_1 = "http://registry.npmjs.org/@types%2f" + args[0]; + var start_2 = Date.now(); + this.httpGet(url_1, function (response) { + var ok = false; + if (_this.log.isEnabled()) { + _this.log.writeLine(requestKind + " #" + requestId + " request to " + url_1 + ":: status code " + response.statusCode + ", status message '" + response.statusMessage + "', took " + (Date.now() - start_2) + " ms"); + } + switch (response.statusCode) { + case 200: + case 301: + case 302: + ok = true; + break; + } + response.destroy(); + onRequestCompleted(ok); + }).on("error", function (err) { + if (_this.log.isEnabled()) { + _this.log.writeLine(requestKind + " #" + requestId + " query to npm registry failed with error " + err.message + ", stack " + err.stack); + } + onRequestCompleted(false); + }); + } + break; + case typingsInstaller.NpmInstallRequest: + { + var command = this.npmPath + " install " + args.join(" ") + " --save-dev"; + var start_3 = Date.now(); + this.exec(command, { cwd: cwd }, function (_err, stdout, stderr) { + if (_this.log.isEnabled()) { + _this.log.writeLine(requestKind + " #" + requestId + " took: " + (Date.now() - start_3) + " ms" + ts.sys.newLine + "stdout: " + stdout + ts.sys.newLine + "stderr: " + stderr); + } + onRequestCompleted(!!stdout); + }); + } + break; + default: + ts.Debug.assert(false, "Unknown request kind " + requestKind); } - this.exec(command, { cwd: cwd }, function (err, stdout, stderr) { - if (_this.log.isEnabled()) { - _this.log.writeLine(requestKind + " #" + requestId + " stdout: " + stdout); - _this.log.writeLine(requestKind + " #" + requestId + " stderr: " + stderr); - } - onRequestCompleted(err, stdout, stderr); - }); }; return NodeTypingsInstaller; }(typingsInstaller.TypingsInstaller)); @@ -6761,3 +7719,5 @@ var ts; })(typingsInstaller = server.typingsInstaller || (server.typingsInstaller = {})); })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); + +//# sourceMappingURL=typingsInstaller.js.map diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index af10f355e1f..e9fa5d6be2e 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -47,19 +47,6 @@ namespace FourSlash { ranges: Range[]; } - interface MemberListData { - result: { - maybeInaccurate: boolean; - isMemberCompletion: boolean; - entries: { - name: string; - type: string; - kind: string; - kindModifiers: string; - }[]; - }; - } - export interface Marker { fileName: string; position: number; @@ -178,15 +165,9 @@ namespace FourSlash { // Return object may lack some functionalities for other purposes. function createScriptSnapShot(sourceText: string): ts.IScriptSnapshot { return { - getText: (start: number, end: number) => { - return sourceText.substr(start, end - start); - }, - getLength: () => { - return sourceText.length; - }, - getChangeRange: (oldSnapshot: ts.IScriptSnapshot) => { - return undefined; - } + getText: (start: number, end: number) => sourceText.substr(start, end - start), + getLength: () => sourceText.length, + getChangeRange: () => undefined }; } @@ -419,9 +400,8 @@ namespace FourSlash { public verifyErrorExistsBetweenMarkers(startMarkerName: string, endMarkerName: string, negative: boolean) { const startMarker = this.getMarkerByName(startMarkerName); const endMarker = this.getMarkerByName(endMarkerName); - const predicate = function(errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) { - return ((errorMinChar === startPos) && (errorLimChar === endPos)) ? true : false; - }; + const predicate = (errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) => + ((errorMinChar === startPos) && (errorLimChar === endPos)) ? true : false; const exists = this.anyErrorInRange(predicate, startMarker, endMarker); @@ -471,14 +451,12 @@ namespace FourSlash { let predicate: (errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) => boolean; if (after) { - predicate = function(errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) { - return ((errorMinChar >= startPos) && (errorLimChar >= startPos)) ? true : false; - }; + predicate = (errorMinChar: number, errorLimChar: number, startPos: number) => + ((errorMinChar >= startPos) && (errorLimChar >= startPos)) ? true : false; } else { - predicate = function(errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) { - return ((errorMinChar <= startPos) && (errorLimChar <= startPos)) ? true : false; - }; + predicate = (errorMinChar: number, errorLimChar: number, startPos: number) => + ((errorMinChar <= startPos) && (errorLimChar <= startPos)) ? true : false; } const exists = this.anyErrorInRange(predicate, marker); @@ -1179,7 +1157,7 @@ namespace FourSlash { private alignmentForExtraInfo = 50; - private spanInfoToString(pos: number, spanInfo: ts.TextSpan, prefixString: string) { + private spanInfoToString(spanInfo: ts.TextSpan, prefixString: string) { let resultString = "SpanInfo: " + JSON.stringify(spanInfo); if (spanInfo) { const spanString = this.activeFile.content.substr(spanInfo.start, spanInfo.length); @@ -1230,7 +1208,7 @@ namespace FourSlash { startColumn = 0; length = 0; } - const spanInfo = this.spanInfoToString(pos, getSpanAtPos(pos), prefixString); + const spanInfo = this.spanInfoToString(getSpanAtPos(pos), prefixString); if (previousSpanInfo && previousSpanInfo !== spanInfo) { addSpanInfoString(); previousSpanInfo = spanInfo; @@ -1300,10 +1278,10 @@ namespace FourSlash { } } - emitOutput.outputFiles.forEach((outputFile, idx, array) => { + for (const outputFile of emitOutput.outputFiles) { const fileName = "FileName : " + outputFile.name + Harness.IO.newLine(); resultString = resultString + fileName + outputFile.text; - }); + } resultString += Harness.IO.newLine(); }); @@ -1328,7 +1306,7 @@ namespace FourSlash { } public printBreakpointLocation(pos: number) { - Harness.IO.log("\n**Pos: " + pos + " " + this.spanInfoToString(pos, this.getBreakpointStatementLocation(pos), " ")); + Harness.IO.log("\n**Pos: " + pos + " " + this.spanInfoToString(this.getBreakpointStatementLocation(pos), " ")); } public printBreakpointAtCurrentLocation() { @@ -1830,7 +1808,7 @@ namespace FourSlash { return result; } - private rangeText({fileName, start, end}: Range, more = false): string { + private rangeText({fileName, start, end}: Range): string { return this.getFileContent(fileName).slice(start, end); } @@ -1925,7 +1903,7 @@ namespace FourSlash { } public printNameOrDottedNameSpans(pos: number) { - Harness.IO.log(this.spanInfoToString(pos, this.getNameOrDottedNameSpan(pos), "**")); + Harness.IO.log(this.spanInfoToString(this.getNameOrDottedNameSpan(pos), "**")); } private verifyClassifications(expected: { classificationType: string; text: string; textSpan?: TextSpan }[], actual: ts.ClassifiedSpan[]) { diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 38cb56d8202..7bfd94637b5 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -220,9 +220,7 @@ namespace Utils { } export function sourceFileToJSON(file: ts.Node): string { - return JSON.stringify(file, (k, v) => { - return isNodeOrArray(v) ? serializeNode(v) : v; - }, " "); + return JSON.stringify(file, (_, v) => isNodeOrArray(v) ? serializeNode(v) : v, " "); function getKindName(k: number | string): string { if (typeof k === "string") { @@ -692,7 +690,7 @@ namespace Harness { export const getCurrentDirectory = () => ""; export const args = () => []; export const getExecutingFilePath = () => ""; - export const exit = (exitCode: number) => { }; + export const exit = () => { }; export const getDirectories = () => []; export let log = (s: string) => console.log(s); @@ -742,7 +740,7 @@ namespace Harness { } } - export function createDirectory(path: string) { + export function createDirectory() { // Do nothing (?) } @@ -750,7 +748,7 @@ namespace Harness { Http.writeToServerSync(serverRoot + path, "DELETE"); } - export function directoryExists(path: string): boolean { + export function directoryExists(): boolean { return false; } @@ -792,7 +790,7 @@ namespace Harness { return response.status === 200; } - export function _listFilesImpl(path: string, spec?: RegExp, options?: any) { + export let listFiles = Utils.memoize((path: string, spec?: RegExp): string[] => { const response = Http.getFileFromServerSync(serverRoot + path); if (response.status === 200) { const results = response.responseText.split(","); @@ -806,8 +804,7 @@ namespace Harness { else { return [""]; } - }; - export let listFiles = Utils.memoize(_listFilesImpl); + }); export function readFile(file: string) { const response = Http.getFileFromServerSync(serverRoot + file); @@ -991,7 +988,7 @@ namespace Harness { } } - function getSourceFile(fileName: string, languageVersion: ts.ScriptTarget) { + function getSourceFile(fileName: string) { fileName = ts.normalizePath(fileName); const path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); if (fileMap.contains(path)) { @@ -1051,7 +1048,7 @@ namespace Harness { getDirectories: d => { const path = ts.toPath(d, currentDirectory, getCanonicalFileName); const result: string[] = []; - fileMap.forEachValue((key, value) => { + fileMap.forEachValue(key => { if (key.indexOf(path) === 0 && key.lastIndexOf("/") > path.length) { let dirName = key.substr(path.length, key.indexOf("/", path.length + 1) - path.length); if (dirName[0] === "/") { @@ -1669,7 +1666,7 @@ namespace Harness { } // This does not need to exist strictly speaking, but many tests will need to be updated if it's removed - export function compileString(code: string, unitName: string, callback: (result: CompilerResult) => void) { + export function compileString(_code: string, _unitName: string, _callback: (result: CompilerResult) => void) { // NEWTODO: Re-implement 'compileString' throw new Error("compileString NYI"); } @@ -1853,8 +1850,8 @@ namespace Harness { // unit tests always list files explicitly const parseConfigHost: ts.ParseConfigHost = { useCaseSensitiveFileNames: false, - readDirectory: (name) => [], - fileExists: (name) => true, + readDirectory: () => [], + fileExists: () => true, readFile: (name) => ts.forEach(testUnitData, data => data.name.toLowerCase() === name.toLowerCase() ? data.content : undefined) }; diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 7cc4c2044ef..28b57728e1f 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -165,7 +165,7 @@ namespace Harness.LanguageService { throw new Error("No script with name '" + fileName + "'"); } - public openFile(fileName: string, content?: string, scriptKindName?: string): void { + public openFile(_fileName: string, _content?: string, _scriptKindName?: string): void { } /** @@ -198,7 +198,7 @@ namespace Harness.LanguageService { const script = this.getScriptInfo(fileName); return script ? new ScriptSnapshot(script) : undefined; } - getScriptKind(fileName: string): ts.ScriptKind { return ts.ScriptKind.Unknown; } + getScriptKind(): ts.ScriptKind { return ts.ScriptKind.Unknown; } getScriptVersion(fileName: string): string { const script = this.getScriptInfo(fileName); return script ? script.version.toString() : undefined; @@ -214,7 +214,7 @@ namespace Harness.LanguageService { this.getCurrentDirectory(), (p) => this.virtualFileSystem.getAccessibleFileSystemEntries(p)); } - readFile(path: string, encoding?: string): string { + readFile(path: string): string { const snapshot = this.getScriptSnapshot(path); return snapshot.getText(0, snapshot.getLength()); } @@ -223,9 +223,9 @@ namespace Harness.LanguageService { } - log(s: string): void { } - trace(s: string): void { } - error(s: string): void { } + log(_: string): void { } + trace(_: string): void { } + error(_: string): void { } } export class NativeLanguageServiceAdapter implements LanguageServiceAdapter { @@ -308,17 +308,17 @@ namespace Harness.LanguageService { const nativeScriptSnapshot = this.nativeHost.getScriptSnapshot(fileName); return nativeScriptSnapshot && new ScriptSnapshotProxy(nativeScriptSnapshot); } - getScriptKind(fileName: string): ts.ScriptKind { return this.nativeHost.getScriptKind(fileName); } + getScriptKind(): ts.ScriptKind { return this.nativeHost.getScriptKind(); } getScriptVersion(fileName: string): string { return this.nativeHost.getScriptVersion(fileName); } getLocalizedDiagnosticMessages(): string { return JSON.stringify({}); } - readDirectory(rootDir: string, extension: string): string { + readDirectory(_rootDir: string, _extension: string): string { throw new Error("NYI"); } - readDirectoryNames(path: string): string { + readDirectoryNames(_path: string): string { throw new Error("Not implemented."); } - readFileNames(path: string): string { + readFileNames(_path: string): string { throw new Error("Not implemented."); } fileExists(fileName: string) { return this.getScriptInfo(fileName) !== undefined; } @@ -329,7 +329,7 @@ namespace Harness.LanguageService { log(s: string): void { this.nativeHost.log(s); } trace(s: string): void { this.nativeHost.trace(s); } error(s: string): void { this.nativeHost.error(s); } - directoryExists(directoryName: string): boolean { + directoryExists(): boolean { // for tests pessimistically assume that directory always exists return true; } @@ -338,7 +338,7 @@ namespace Harness.LanguageService { class ClassifierShimProxy implements ts.Classifier { constructor(private shim: ts.ClassifierShim) { } - getEncodedLexicalClassifications(text: string, lexState: ts.EndOfLineState, classifyKeywordsInGenerics?: boolean): ts.Classifications { + getEncodedLexicalClassifications(_text: string, _lexState: ts.EndOfLineState, _classifyKeywordsInGenerics?: boolean): ts.Classifications { throw new Error("NYI"); } getClassificationsForLine(text: string, lexState: ts.EndOfLineState, classifyKeywordsInGenerics?: boolean): ts.ClassificationResult { @@ -411,7 +411,7 @@ namespace Harness.LanguageService { getCompletionEntryDetails(fileName: string, position: number, entryName: string): ts.CompletionEntryDetails { return unwrapJSONCallResult(this.shim.getCompletionEntryDetails(fileName, position, entryName)); } - getCompletionEntrySymbol(fileName: string, position: number, entryName: string): ts.Symbol { + getCompletionEntrySymbol(): ts.Symbol { throw new Error("getCompletionEntrySymbol not implemented across the shim layer."); } getQuickInfoAtPosition(fileName: string, position: number): ts.QuickInfo { @@ -490,7 +490,7 @@ namespace Harness.LanguageService { isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean { return unwrapJSONCallResult(this.shim.isValidBraceCompletionAtPosition(fileName, position, openingBrace)); } - getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[]): ts.CodeAction[] { + getCodeFixesAtPosition(): ts.CodeAction[] { throw new Error("Not supported on the shim."); } getEmitOutput(fileName: string): ts.EmitOutput { @@ -499,10 +499,10 @@ namespace Harness.LanguageService { getProgram(): ts.Program { throw new Error("Program can not be marshaled across the shim layer."); } - getNonBoundSourceFile(fileName: string): ts.SourceFile { + getNonBoundSourceFile(): ts.SourceFile { throw new Error("SourceFile can not be marshaled across the shim layer."); } - getSourceFile(fileName: string): ts.SourceFile { + getSourceFile(): ts.SourceFile { throw new Error("SourceFile can not be marshaled across the shim layer."); } dispose(): void { this.shim.dispose({}); } @@ -572,11 +572,11 @@ namespace Harness.LanguageService { super(cancellationToken, settings); } - onMessage(message: string): void { + onMessage(): void { } - writeMessage(message: string): void { + writeMessage(): void { } @@ -604,11 +604,11 @@ namespace Harness.LanguageService { this.newLine = this.host.getNewLine(); } - onMessage(message: string): void { + onMessage(): void { } - writeMessage(message: string): void { + writeMessage(_message: string): void { } write(message: string): void { @@ -624,7 +624,7 @@ namespace Harness.LanguageService { return snapshot && snapshot.getText(0, snapshot.getLength()); } - writeFile(name: string, text: string, writeByteOrderMark: boolean): void { + writeFile(): void { } resolvePath(path: string): string { @@ -635,7 +635,7 @@ namespace Harness.LanguageService { return !!this.host.getScriptSnapshot(path); } - directoryExists(path: string): boolean { + directoryExists(): boolean { // for tests assume that directory exists return true; } @@ -644,10 +644,10 @@ namespace Harness.LanguageService { return ""; } - exit(exitCode: number): void { + exit(): void { } - createDirectory(directoryName: string): void { + createDirectory(_directoryName: string): void { throw new Error("Not Implemented Yet."); } @@ -655,7 +655,7 @@ namespace Harness.LanguageService { return this.host.getCurrentDirectory(); } - getDirectories(path: string): string[] { + getDirectories(): string[] { return []; } @@ -663,15 +663,15 @@ namespace Harness.LanguageService { return ts.sys.getEnvironmentVariable(name); } - readDirectory(path: string, extension?: string[], exclude?: string[], include?: string[]): string[] { + readDirectory(_path: string, _extension?: string[], _exclude?: string[], _include?: string[]): string[] { throw new Error("Not implemented Yet."); } - watchFile(fileName: string, callback: (fileName: string) => void): ts.FileWatcher { + watchFile(): ts.FileWatcher { return { close() { } }; } - watchDirectory(path: string, callback: (path: string) => void, recursive?: boolean): ts.FileWatcher { + watchDirectory(): ts.FileWatcher { return { close() { } }; } @@ -717,7 +717,7 @@ namespace Harness.LanguageService { clearTimeout(timeoutId); } - setImmediate(callback: (...args: any[]) => void, ms: number, ...args: any[]): any { + setImmediate(callback: (...args: any[]) => void, _ms: number, ...args: any[]): any { return setImmediate(callback, args); } @@ -760,6 +760,6 @@ namespace Harness.LanguageService { getHost() { return this.host; } getLanguageService(): ts.LanguageService { return this.client; } getClassifier(): ts.Classifier { throw new Error("getClassifier is not available using the server interface."); } - getPreProcessedFileInfo(fileName: string, fileContents: string): ts.PreProcessedFileInfo { throw new Error("getPreProcessedFileInfo is not available using the server interface."); } + getPreProcessedFileInfo(): ts.PreProcessedFileInfo { throw new Error("getPreProcessedFileInfo is not available using the server interface."); } } } diff --git a/src/harness/loggedIO.ts b/src/harness/loggedIO.ts index 07dbf4a4e1c..eeb47f0cfa0 100644 --- a/src/harness/loggedIO.ts +++ b/src/harness/loggedIO.ts @@ -173,7 +173,7 @@ namespace Playback { path => callAndRecord(underlying.fileExists(path), recordLog.fileExists, { path }), memoize(path => { // If we read from the file, it must exist - if (findFileByPath(wrapper, replayLog.filesRead, path, /*throwFileNotFoundError*/ false)) { + if (findFileByPath(replayLog.filesRead, path, /*throwFileNotFoundError*/ false)) { return true; } else { @@ -217,7 +217,7 @@ namespace Playback { recordLog.filesRead.push(logEntry); return result; }, - memoize(path => findFileByPath(wrapper, replayLog.filesRead, path, /*throwFileNotFoundError*/ true).contents)); + memoize(path => findFileByPath(replayLog.filesRead, path, /*throwFileNotFoundError*/ true).contents)); wrapper.readDirectory = recordReplay(wrapper.readDirectory, underlying)( (path, extensions, exclude, include) => { @@ -226,7 +226,7 @@ namespace Playback { recordLog.directoriesRead.push(logEntry); return result; }, - (path, extensions, exclude) => { + path => { // Because extensions is an array of all allowed extension, we will want to merge each of the replayLog.directoriesRead into one // if each of the directoriesRead has matched path with the given path (directory with same path but different extension will considered // different entry). @@ -244,7 +244,7 @@ namespace Playback { wrapper.writeFile = recordReplay(wrapper.writeFile, underlying)( (path: string, contents: string) => callAndRecord(underlying.writeFile(path, contents), recordLog.filesWritten, { path, contents, bom: false }), - (path: string, contents: string) => noOpReplay("writeFile")); + () => noOpReplay("writeFile")); wrapper.exit = (exitCode) => { if (recordLog !== undefined) { @@ -295,7 +295,7 @@ namespace Playback { return results[0].result; } - function findFileByPath(wrapper: { resolvePath(s: string): string }, logArray: IOLogFile[], + function findFileByPath(logArray: IOLogFile[], expectedPath: string, throwFileNotFoundError: boolean): FileInformation { const normalizedName = ts.normalizePath(expectedPath).toLowerCase(); // Try to find the result through normal fileName @@ -314,7 +314,7 @@ namespace Playback { } } - function noOpReplay(name: string) { + function noOpReplay(_name: string) { // console.log("Swallowed write operation during replay: " + name); } @@ -322,13 +322,17 @@ namespace Playback { const wrapper: PlaybackIO = {}; initWrapper(wrapper, underlying); - wrapper.directoryName = (path): string => { throw new Error("NotSupported"); }; - wrapper.createDirectory = (path): void => { throw new Error("NotSupported"); }; - wrapper.directoryExists = (path): boolean => { throw new Error("NotSupported"); }; - wrapper.deleteFile = (path): void => { throw new Error("NotSupported"); }; - wrapper.listFiles = (path, filter, options): string[] => { throw new Error("NotSupported"); }; + wrapper.directoryName = notSupported; + wrapper.createDirectory = notSupported; + wrapper.directoryExists = notSupported; + wrapper.deleteFile = notSupported; + wrapper.listFiles = notSupported; return wrapper; + + function notSupported(): never { + throw new Error("NotSupported"); + } } export function wrapSystem(underlying: ts.System): PlaybackSystem { diff --git a/src/harness/projectsRunner.ts b/src/harness/projectsRunner.ts index 415c09caff6..f7541dc9bfe 100644 --- a/src/harness/projectsRunner.ts +++ b/src/harness/projectsRunner.ts @@ -178,7 +178,7 @@ class ProjectRunner extends RunnerBase { function createCompilerHost(): ts.CompilerHost { return { getSourceFile, - getDefaultLibFileName: options => Harness.Compiler.defaultLibFileName, + getDefaultLibFileName: () => Harness.Compiler.defaultLibFileName, writeFile, getCurrentDirectory, getCanonicalFileName: Harness.Compiler.getCanonicalFileName, @@ -421,7 +421,7 @@ class ProjectRunner extends RunnerBase { return undefined; } - function writeFile(fileName: string, data: string, writeByteOrderMark: boolean) { + function writeFile() { } } diff --git a/src/harness/tsconfig.json b/src/harness/tsconfig.json index d0f500e27aa..e4099d3014c 100644 --- a/src/harness/tsconfig.json +++ b/src/harness/tsconfig.json @@ -11,7 +11,9 @@ "types": [ "node", "mocha", "chai" ], - "target": "es5" + "target": "es5", + "noUnusedLocals": true, + "noUnusedParameters": true }, "files": [ "../compiler/core.ts", diff --git a/src/harness/unittests/cachingInServerLSHost.ts b/src/harness/unittests/cachingInServerLSHost.ts index 9489feb43e9..0a522ddb22e 100644 --- a/src/harness/unittests/cachingInServerLSHost.ts +++ b/src/harness/unittests/cachingInServerLSHost.ts @@ -21,15 +21,14 @@ namespace ts { args: [], newLine: "\r\n", useCaseSensitiveFileNames: false, - write: (s: string) => { - }, - readFile: (path: string, encoding?: string): string => { + write: () => { }, + readFile: (path: string): string => { return path in fileMap ? fileMap[path].content : undefined; }, - writeFile: (path: string, data: string, writeByteOrderMark?: boolean) => { + writeFile: (_path: string, _data: string, _writeByteOrderMark?: boolean) => { throw new Error("NYI"); }, - resolvePath: (path: string): string => { + resolvePath: (_path: string): string => { throw new Error("NYI"); }, fileExists: (path: string): boolean => { @@ -38,31 +37,25 @@ namespace ts { directoryExists: (path: string): boolean => { return existingDirectories[path] || false; }, - createDirectory: (path: string) => { - }, + createDirectory: () => { }, getExecutingFilePath: (): string => { return ""; }, getCurrentDirectory: (): string => { return ""; }, - getDirectories: (path: string) => [], - getEnvironmentVariable: (name: string) => "", - readDirectory: (path: string, extension?: string[], exclude?: string[], include?: string[]): string[] => { + getDirectories: () => [], + getEnvironmentVariable: () => "", + readDirectory: (_path: string, _extension?: string[], _exclude?: string[], _include?: string[]): string[] => { throw new Error("NYI"); }, - exit: (exitCode?: number) => { - }, - watchFile: (path, callback) => { - return { - close: () => { } - }; - }, - watchDirectory: (path, callback, recursive?) => { - return { - close: () => { } - }; - }, + exit: () => { }, + watchFile: () => ({ + close: () => { } + }), + watchDirectory: () => ({ + close: () => { } + }), setTimeout, clearTimeout, setImmediate, @@ -75,11 +68,11 @@ namespace ts { close() { }, hasLevel: () => false, loggingEnabled: () => false, - perftrc: (s: string) => { }, - info: (s: string) => { }, + perftrc: () => { }, + info: () => { }, startGroup: () => { }, endGroup: () => { }, - msg: (s: string, type?: string) => { }, + msg: () => { }, getLogFileName: (): string => undefined }; @@ -116,7 +109,7 @@ namespace ts { const originalFileExists = serverHost.fileExists; { // patch fileExists to make sure that disk is not touched - serverHost.fileExists = (fileName): boolean => { + serverHost.fileExists = (): boolean => { assert.isTrue(false, "fileExists should not be called"); return false; }; diff --git a/src/harness/unittests/jsDocParsing.ts b/src/harness/unittests/jsDocParsing.ts index 2c935439a9b..addd01b0e0a 100644 --- a/src/harness/unittests/jsDocParsing.ts +++ b/src/harness/unittests/jsDocParsing.ts @@ -101,7 +101,7 @@ namespace ts { Harness.Baseline.runBaseline("JSDocParsing/DocComments.parsesCorrectly." + name + ".json", () => JSON.stringify(comment.jsDoc, - (k, v) => v && v.pos !== undefined ? JSON.parse(Utils.sourceFileToJSON(v)) : v, 4)); + (_, v) => v && v.pos !== undefined ? JSON.parse(Utils.sourceFileToJSON(v)) : v, 4)); }); } diff --git a/src/harness/unittests/moduleResolution.ts b/src/harness/unittests/moduleResolution.ts index b2f7d0c224d..c21d2df4019 100644 --- a/src/harness/unittests/moduleResolution.ts +++ b/src/harness/unittests/moduleResolution.ts @@ -290,7 +290,7 @@ namespace ts { return path in files ? createSourceFile(fileName, files[path], languageVersion) : undefined; }, getDefaultLibFileName: () => "lib.d.ts", - writeFile: (fileName, content): void => { throw new Error("NotImplemented"); }, + writeFile: (): void => { throw new Error("NotImplemented"); }, getCurrentDirectory: () => currentDirectory, getDirectories: () => [], getCanonicalFileName: fileName => fileName.toLowerCase(), @@ -300,7 +300,7 @@ namespace ts { const path = normalizePath(combinePaths(currentDirectory, fileName)); return path in files; }, - readFile: (fileName): string => { throw new Error("NotImplemented"); } + readFile: (): string => { throw new Error("NotImplemented"); } }; const program = createProgram(rootFiles, options, host); @@ -370,7 +370,7 @@ export = C; return path in files ? createSourceFile(fileName, files[path], languageVersion) : undefined; }, getDefaultLibFileName: () => "lib.d.ts", - writeFile: (fileName, content): void => { throw new Error("NotImplemented"); }, + writeFile: (): void => { throw new Error("NotImplemented"); }, getCurrentDirectory: () => currentDirectory, getDirectories: () => [], getCanonicalFileName, @@ -380,7 +380,7 @@ export = C; const path = getCanonicalFileName(normalizePath(combinePaths(currentDirectory, fileName))); return path in files; }, - readFile: (fileName): string => { throw new Error("NotImplemented"); } + readFile: (): string => { throw new Error("NotImplemented"); } }; const program = createProgram(rootFiles, options, host); const diagnostics = sortAndDeduplicateDiagnostics(program.getSemanticDiagnostics().concat(program.getOptionsDiagnostics())); @@ -1022,7 +1022,7 @@ import b = require("./moduleB"); fileExists : fileName => fileName in sourceFiles, getSourceFile: fileName => sourceFiles[fileName], getDefaultLibFileName: () => "lib.d.ts", - writeFile(file, text) { + writeFile(_file, _text) { throw new Error("NYI"); }, getCurrentDirectory: () => "/", diff --git a/src/harness/unittests/reuseProgramStructure.ts b/src/harness/unittests/reuseProgramStructure.ts index 60687d34c55..fcdfc6d08c6 100644 --- a/src/harness/unittests/reuseProgramStructure.ts +++ b/src/harness/unittests/reuseProgramStructure.ts @@ -111,13 +111,13 @@ namespace ts { getDefaultLibFileName(): string { return "lib.d.ts"; }, - writeFile(file, text) { + writeFile() { throw new Error("NYI"); }, getCurrentDirectory(): string { return ""; }, - getDirectories(path: string): string[] { + getDirectories(): string[] { return []; }, getCanonicalFileName(fileName): string { @@ -244,17 +244,13 @@ namespace ts { it("fails if change affects type references", () => { const program_1 = newProgram(files, ["a.ts"], { types: ["a"] }); - updateProgram(program_1, ["a.ts"], { types: ["b"] }, files => { - - }); + updateProgram(program_1, ["a.ts"], { types: ["b"] }, () => { }); assert.isTrue(!program_1.structureIsReused); }); it("succeeds if change doesn't affect type references", () => { const program_1 = newProgram(files, ["a.ts"], { types: ["a"] }); - updateProgram(program_1, ["a.ts"], { types: ["a"] }, files => { - - }); + updateProgram(program_1, ["a.ts"], { types: ["a"] }, () => { }); assert.isTrue(program_1.structureIsReused); }); @@ -280,19 +276,19 @@ namespace ts { it("fails if module kind changes", () => { const program_1 = newProgram(files, ["a.ts"], { target, module: ModuleKind.CommonJS }); - updateProgram(program_1, ["a.ts"], { target, module: ModuleKind.AMD }, files => void 0); + updateProgram(program_1, ["a.ts"], { target, module: ModuleKind.AMD }, () => { }); assert.isTrue(!program_1.structureIsReused); }); it("fails if rootdir changes", () => { const program_1 = newProgram(files, ["a.ts"], { target, module: ModuleKind.CommonJS, rootDir: "/a/b" }); - updateProgram(program_1, ["a.ts"], { target, module: ModuleKind.CommonJS, rootDir: "/a/c" }, files => void 0); + updateProgram(program_1, ["a.ts"], { target, module: ModuleKind.CommonJS, rootDir: "/a/c" }, () => { }); assert.isTrue(!program_1.structureIsReused); }); it("fails if config path changes", () => { const program_1 = newProgram(files, ["a.ts"], { target, module: ModuleKind.CommonJS, configFilePath: "/a/b/tsconfig.json" }); - updateProgram(program_1, ["a.ts"], { target, module: ModuleKind.CommonJS, configFilePath: "/a/c/tsconfig.json" }, files => void 0); + updateProgram(program_1, ["a.ts"], { target, module: ModuleKind.CommonJS, configFilePath: "/a/c/tsconfig.json" }, () => { }); assert.isTrue(!program_1.structureIsReused); }); diff --git a/src/harness/unittests/services/documentRegistry.ts b/src/harness/unittests/services/documentRegistry.ts index 09e95db6c76..ab624a17dbf 100644 --- a/src/harness/unittests/services/documentRegistry.ts +++ b/src/harness/unittests/services/documentRegistry.ts @@ -62,7 +62,7 @@ describe("DocumentRegistry", () => { const snapshot = ts.ScriptSnapshot.fromString(contents); // Always treat any change as a full change. - snapshot.getChangeRange = old => ts.createTextChangeRange(ts.createTextSpan(0, contents.length), contents.length); + snapshot.getChangeRange = () => ts.createTextChangeRange(ts.createTextSpan(0, contents.length), contents.length); // Simulate one LS getting the document. documentRegistry.acquireDocument("file1.ts", defaultCompilerOptions, snapshot, /* version */ "1"); diff --git a/src/harness/unittests/session.ts b/src/harness/unittests/session.ts index 9099f0a4285..0d8fb31e5d8 100644 --- a/src/harness/unittests/session.ts +++ b/src/harness/unittests/session.ts @@ -18,11 +18,11 @@ namespace ts.server { createDirectory(): void {}, getExecutingFilePath(): string { return void 0; }, getCurrentDirectory(): string { return void 0; }, - getEnvironmentVariable(name: string): string { return ""; }, + getEnvironmentVariable(): string { return ""; }, readDirectory(): string[] { return []; }, exit(): void { }, - setTimeout(callback, ms, ...args) { return 0; }, - clearTimeout(timeoutId) { }, + setTimeout() { return 0; }, + clearTimeout() { }, setImmediate: () => 0, clearImmediate() {} }; @@ -31,11 +31,11 @@ namespace ts.server { close(): void {}, hasLevel(): boolean { return false; }, loggingEnabled(): boolean { return false; }, - perftrc(s: string): void {}, - info(s: string): void {}, + perftrc(): void {}, + info(): void {}, startGroup(): void {}, endGroup(): void {}, - msg(s: string, type?: string): void {}, + msg(): void {}, getLogFileName: (): string => undefined }; @@ -245,7 +245,7 @@ namespace ts.server { responseRequired: true }; - session.addProtocolHandler(command, (req) => result); + session.addProtocolHandler(command, () => result); expect(session.executeCommand({ command, @@ -263,9 +263,9 @@ namespace ts.server { }; const command = "newhandle"; - session.addProtocolHandler(command, (req) => resp); + session.addProtocolHandler(command, () => resp); - expect(() => session.addProtocolHandler(command, (req) => resp)) + expect(() => session.addProtocolHandler(command, () => resp)) .to.throw(`Protocol handler already exists for command "${command}"`); }); }); diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index c3962c77494..de2fdd10e8e 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -72,7 +72,7 @@ namespace ts.projectSystem { this.postExecActions.forEach((act, i) => assert.equal(act.requestKind, expected[i], "Unexpected post install action")); } - onProjectClosed(p: server.Project) { + onProjectClosed() { } attach(projectService: server.ProjectService) { @@ -83,7 +83,7 @@ namespace ts.projectSystem { return this.installTypingHost; } - executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: TI.RequestCompletedAction): void { + executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction): void { switch (requestKind) { case TI.NpmViewRequest: case TI.NpmInstallRequest: @@ -122,7 +122,7 @@ namespace ts.projectSystem { return JSON.stringify({ dependencies: dependencies }); } - export function getExecutingFilePathFromLibFile(libFilePath: string): string { + export function getExecutingFilePathFromLibFile(_libFilePath: string): string { return combinePaths(getDirectoryPath(libFile.path), "tsc.js"); } @@ -322,9 +322,9 @@ namespace ts.projectSystem { count() { let n = 0; -/* tslint:disable:no-unused-variable */ for (const _ in this.map) { -/* tslint:enable:no-unused-variable */ + // TODO: GH#11734 + _; n++; } return n; @@ -473,7 +473,7 @@ namespace ts.projectSystem { } // TOOD: record and invoke callbacks to simulate timer events - setTimeout(callback: TimeOutCallback, time: number, ...args: any[]) { + setTimeout(callback: TimeOutCallback, _time: number, ...args: any[]) { return this.timeoutCallbacks.register(callback, args); }; @@ -490,7 +490,7 @@ namespace ts.projectSystem { this.timeoutCallbacks.invoke(); } - setImmediate(callback: TimeOutCallback, time: number, ...args: any[]) { + setImmediate(callback: TimeOutCallback, _time: number, ...args: any[]) { return this.immediateCallbacks.register(callback, args); } @@ -522,15 +522,14 @@ namespace ts.projectSystem { this.reloadFS(filesOrFolders); } - write(s: string) { - } + write() { } readonly readFile = (s: string) => (this.fs.get(this.toPath(s))).content; readonly resolvePath = (s: string) => s; readonly getExecutingFilePath = () => this.executingFilePath; readonly getCurrentDirectory = () => this.currentDirectory; - readonly exit = () => notImplemented(); - readonly getEnvironmentVariable = (v: string) => notImplemented(); + readonly exit = notImplemented; + readonly getEnvironmentVariable = notImplemented; } export function makeSessionRequest(command: string, args: T) { diff --git a/src/harness/unittests/typingsInstaller.ts b/src/harness/unittests/typingsInstaller.ts index ebd0f0ef792..323d8c0ed9e 100644 --- a/src/harness/unittests/typingsInstaller.ts +++ b/src/harness/unittests/typingsInstaller.ts @@ -81,7 +81,7 @@ namespace ts.projectSystem { constructor() { super(host); } - executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: server.typingsInstaller.RequestCompletedAction) { + executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: server.typingsInstaller.RequestCompletedAction) { const installedTypings = ["@types/jquery"]; const typingFiles = [jquery]; executeCommand(this, host, installedTypings, typingFiles, requestKind, cb); @@ -125,7 +125,7 @@ namespace ts.projectSystem { constructor() { super(host); } - executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: server.typingsInstaller.RequestCompletedAction) { + executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: server.typingsInstaller.RequestCompletedAction) { const installedTypings = ["@types/jquery"]; const typingFiles = [jquery]; executeCommand(this, host, installedTypings, typingFiles, requestKind, cb); @@ -221,7 +221,7 @@ namespace ts.projectSystem { enqueueIsCalled = true; super.enqueueInstallTypingsRequest(project, typingOptions); } - executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: TI.RequestCompletedAction): void { + executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction): void { const installedTypings = ["@types/jquery"]; const typingFiles = [jquery]; executeCommand(this, host, installedTypings, typingFiles, requestKind, cb); @@ -275,7 +275,7 @@ namespace ts.projectSystem { constructor() { super(host); } - executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: TI.RequestCompletedAction): void { + executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction): void { const installedTypings = ["@types/lodash", "@types/react"]; const typingFiles = [lodash, react]; executeCommand(this, host, installedTypings, typingFiles, requestKind, cb); @@ -323,7 +323,7 @@ namespace ts.projectSystem { enqueueIsCalled = true; super.enqueueInstallTypingsRequest(project, typingOptions); } - executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: TI.RequestCompletedAction): void { + executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction): void { const installedTypings: string[] = []; const typingFiles: FileOrFolder[] = []; executeCommand(this, host, installedTypings, typingFiles, requestKind, cb); @@ -398,7 +398,7 @@ namespace ts.projectSystem { constructor() { super(host); } - executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: TI.RequestCompletedAction): void { + executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction): void { const installedTypings = ["@types/commander", "@types/express", "@types/jquery", "@types/moment"]; const typingFiles = [commander, express, jquery, moment]; executeCommand(this, host, installedTypings, typingFiles, requestKind, cb); @@ -477,7 +477,7 @@ namespace ts.projectSystem { constructor() { super(host, { throttleLimit: 3 }); } - executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: TI.RequestCompletedAction): void { + executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction): void { const installedTypings = ["@types/commander", "@types/express", "@types/jquery", "@types/moment", "@types/lodash"]; executeCommand(this, host, installedTypings, typingFiles, requestKind, cb); } @@ -567,7 +567,7 @@ namespace ts.projectSystem { constructor() { super(host, { throttleLimit: 3 }); } - executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: TI.RequestCompletedAction): void { + executeRequest(requestKind: TI.RequestKind, _requestId: number, args: string[], _cwd: string, cb: TI.RequestCompletedAction): void { if (requestKind === TI.NpmInstallRequest) { let typingFiles: (FileOrFolder & { typings: string}) [] = []; if (args.indexOf("@types/commander") >= 0) { @@ -655,7 +655,7 @@ namespace ts.projectSystem { constructor() { super(host, { globalTypingsCacheLocation: "/tmp" }); } - executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: server.typingsInstaller.RequestCompletedAction) { + executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: server.typingsInstaller.RequestCompletedAction) { const installedTypings = ["@types/jquery"]; const typingFiles = [jqueryDTS]; executeCommand(this, host, installedTypings, typingFiles, requestKind, cb); @@ -701,7 +701,7 @@ namespace ts.projectSystem { constructor() { super(host, { globalTypingsCacheLocation: "/tmp" }); } - executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: server.typingsInstaller.RequestCompletedAction) { + executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: server.typingsInstaller.RequestCompletedAction) { const installedTypings = ["@types/jquery"]; const typingFiles = [jqueryDTS]; executeCommand(this, host, installedTypings, typingFiles, requestKind, cb); @@ -766,7 +766,7 @@ namespace ts.projectSystem { constructor() { super(host, { globalTypingsCacheLocation: "/tmp" }, { isEnabled: () => true, writeLine: msg => messages.push(msg) }); } - executeRequest(requestKind: TI.RequestKind, requestId: number, args: string[], cwd: string, cb: server.typingsInstaller.RequestCompletedAction) { + executeRequest() { assert(false, "runCommand should not be invoked"); } })(); diff --git a/src/server/builder.ts b/src/server/builder.ts index 475202a0aab..548a3ac854c 100644 --- a/src/server/builder.ts +++ b/src/server/builder.ts @@ -122,7 +122,7 @@ namespace ts.server { } protected forEachFileInfo(action: (fileInfo: T) => any) { - this.fileInfos.forEachValue((path: Path, value: T) => action(value)); + this.fileInfos.forEachValue((_path, value) => action(value)); } abstract getFilesAffectedBy(scriptInfo: ScriptInfo): string[]; diff --git a/src/server/cancellationToken/tsconfig.json b/src/server/cancellationToken/tsconfig.json index bcfe5ddb465..1c4c0d60826 100644 --- a/src/server/cancellationToken/tsconfig.json +++ b/src/server/cancellationToken/tsconfig.json @@ -11,7 +11,9 @@ "types": [ "node" ], - "target": "es5" + "target": "es5", + "noUnusedLocals": true, + "noUnusedParameters": true }, "files": [ "cancellationToken.ts" diff --git a/src/server/client.ts b/src/server/client.ts index 6d8ef419a7a..adc55f96471 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -5,11 +5,6 @@ namespace ts.server { writeMessage(message: string): void; } - interface CompletionEntry extends CompletionInfo { - fileName: string; - position: number; - } - interface RenameEntry extends RenameInfo { fileName: string; position: number; @@ -246,7 +241,7 @@ namespace ts.server { return response.body[0]; } - getCompletionEntrySymbol(fileName: string, position: number, entryName: string): Symbol { + getCompletionEntrySymbol(_fileName: string, _position: number, _entryName: string): Symbol { throw new Error("Not Implemented Yet."); } @@ -278,7 +273,7 @@ namespace ts.server { }); } - getFormattingEditsForRange(fileName: string, start: number, end: number, options: ts.FormatCodeOptions): ts.TextChange[] { + getFormattingEditsForRange(fileName: string, start: number, end: number, _options: ts.FormatCodeOptions): ts.TextChange[] { const startLineOffset = this.positionToOneBasedLineOffset(fileName, start); const endLineOffset = this.positionToOneBasedLineOffset(fileName, end); const args: protocol.FormatRequestArgs = { @@ -300,7 +295,7 @@ namespace ts.server { return this.getFormattingEditsForRange(fileName, 0, this.host.getScriptSnapshot(fileName).getLength(), options); } - getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): ts.TextChange[] { + getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, _options: FormatCodeOptions): ts.TextChange[] { const lineOffset = this.positionToOneBasedLineOffset(fileName, position); const args: protocol.FormatOnKeyRequestArgs = { file: fileName, @@ -390,7 +385,7 @@ namespace ts.server { }); } - findReferences(fileName: string, position: number): ReferencedSymbol[] { + findReferences(_fileName: string, _position: number): ReferencedSymbol[] { // Not yet implemented. return []; } @@ -419,7 +414,7 @@ namespace ts.server { }); } - getEmitOutput(fileName: string): EmitOutput { + getEmitOutput(_fileName: string): EmitOutput { throw new Error("Not Implemented Yet."); } @@ -441,7 +436,7 @@ namespace ts.server { return (response.body).map(entry => this.convertDiagnostic(entry, fileName)); } - convertDiagnostic(entry: protocol.DiagnosticWithLinePosition, fileName: string): Diagnostic { + convertDiagnostic(entry: protocol.DiagnosticWithLinePosition, _fileName: string): Diagnostic { let category: DiagnosticCategory; for (const id in DiagnosticCategory) { if (typeof id === "string" && entry.category === id.toLowerCase()) { @@ -566,11 +561,11 @@ namespace ts.server { this.lineOffsetToPosition(fileName, span.end, lineMap)); } - getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan { + getNameOrDottedNameSpan(_fileName: string, _startPos: number, _endPos: number): TextSpan { throw new Error("Not Implemented Yet."); } - getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan { + getBreakpointStatementAtPosition(_fileName: string, _position: number): TextSpan { throw new Error("Not Implemented Yet."); } @@ -660,19 +655,19 @@ namespace ts.server { } } - getOutliningSpans(fileName: string): OutliningSpan[] { + getOutliningSpans(_fileName: string): OutliningSpan[] { throw new Error("Not Implemented Yet."); } - getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[] { + getTodoComments(_fileName: string, _descriptors: TodoCommentDescriptor[]): TodoComment[] { throw new Error("Not Implemented Yet."); } - getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion { + getDocCommentTemplateAtPosition(_fileName: string, _position: number): TextInsertion { throw new Error("Not Implemented Yet."); } - isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean { + isValidBraceCompletionAtPosition(_fileName: string, _position: number, _openingBrace: number): boolean { throw new Error("Not Implemented Yet."); } @@ -739,23 +734,23 @@ namespace ts.server { }); } - getIndentationAtPosition(fileName: string, position: number, options: EditorOptions): number { + getIndentationAtPosition(_fileName: string, _position: number, _options: EditorOptions): number { throw new Error("Not Implemented Yet."); } - getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[] { + getSyntacticClassifications(_fileName: string, _span: TextSpan): ClassifiedSpan[] { throw new Error("Not Implemented Yet."); } - getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[] { + getSemanticClassifications(_fileName: string, _span: TextSpan): ClassifiedSpan[] { throw new Error("Not Implemented Yet."); } - getEncodedSyntacticClassifications(fileName: string, span: TextSpan): Classifications { + getEncodedSyntacticClassifications(_fileName: string, _span: TextSpan): Classifications { throw new Error("Not Implemented Yet."); } - getEncodedSemanticClassifications(fileName: string, span: TextSpan): Classifications { + getEncodedSemanticClassifications(_fileName: string, _span: TextSpan): Classifications { throw new Error("Not Implemented Yet."); } @@ -763,11 +758,11 @@ namespace ts.server { throw new Error("SourceFile objects are not serializable through the server protocol."); } - getNonBoundSourceFile(fileName: string): SourceFile { + getNonBoundSourceFile(_fileName: string): SourceFile { throw new Error("SourceFile objects are not serializable through the server protocol."); } - getSourceFile(fileName: string): SourceFile { + getSourceFile(_fileName: string): SourceFile { throw new Error("SourceFile objects are not serializable through the server protocol."); } diff --git a/src/server/scriptVersionCache.ts b/src/server/scriptVersionCache.ts index 8d0efa081ad..f094a183610 100644 --- a/src/server/scriptVersionCache.ts +++ b/src/server/scriptVersionCache.ts @@ -41,7 +41,7 @@ namespace ts.server { class BaseLineIndexWalker implements ILineIndexWalker { goSubtree = true; done = false; - leaf(rangeStart: number, rangeLength: number, ll: LineLeaf) { + leaf(_rangeStart: number, _rangeLength: number, _ll: LineLeaf) { } } @@ -150,7 +150,7 @@ namespace ts.server { return this.lineIndex; } - post(relativeStart: number, relativeLength: number, lineCollection: LineCollection, parent: LineCollection, nodeType: CharRangeSection): LineCollection { + post(_relativeStart: number, _relativeLength: number, lineCollection: LineCollection): LineCollection { // have visited the path for start of range, now looking for end // if range is on single line, we will never make this state transition if (lineCollection === this.lineCollectionAtBranch) { @@ -161,7 +161,7 @@ namespace ts.server { return undefined; } - pre(relativeStart: number, relativeLength: number, lineCollection: LineCollection, parent: LineCollection, nodeType: CharRangeSection) { + pre(_relativeStart: number, _relativeLength: number, lineCollection: LineCollection, _parent: LineCollection, nodeType: CharRangeSection) { // currentNode corresponds to parent, but in the new tree const currentNode = this.stack[this.stack.length - 1]; @@ -414,7 +414,7 @@ namespace ts.server { const starts: number[] = [-1]; let count = 1; let pos = 0; - this.index.every((ll, s, len) => { + this.index.every(ll => { starts[count] = pos; count++; pos += ll.text.length; diff --git a/src/server/server.ts b/src/server/server.ts index e728d7e9d72..6ddd267f56e 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -53,14 +53,6 @@ namespace ts.server { historySize?: number; } - interface Key { - sequence?: string; - name?: string; - ctrl?: boolean; - meta?: boolean; - shift?: boolean; - } - interface Stats { isFile(): boolean; isDirectory(): boolean; @@ -192,7 +184,7 @@ namespace ts.server { constructor( private readonly logger: server.Logger, - private readonly eventPort: number, + eventPort: number, readonly globalTypingsCacheLocation: string, private newLine: string) { if (eventPort) { @@ -218,7 +210,7 @@ namespace ts.server { const match = /^--(debug|inspect)(=(\d+))?$/.exec(arg); if (match) { // if port is specified - use port + 1 - // otherwise pick a default port depending on if 'debug' or 'inspect' and use its value + 1 + // otherwise pick a default port depending on if 'debug' or 'inspect' and use its value + 1 const currentPort = match[3] !== undefined ? +match[3] : match[1] === "debug" ? 5858 : 9229; diff --git a/src/server/session.ts b/src/server/session.ts index 3bf4acd2486..545701f1449 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -1300,7 +1300,7 @@ namespace ts.server { } // No need to analyze lib.d.ts - let fileNamesInProject = fileNames.filter((value, index, array) => value.indexOf("lib.d.ts") < 0); + let fileNamesInProject = fileNames.filter(value => value.indexOf("lib.d.ts") < 0); // Sort the file name list to make the recently touched files come first const highPriorityFiles: NormalizedPath[] = []; @@ -1500,7 +1500,7 @@ namespace ts.server { [CommandNames.EncodedSemanticClassificationsFull]: (request: protocol.EncodedSemanticClassificationsRequest) => { return this.requiredResponse(this.getEncodedSemanticClassifications(request.arguments)); }, - [CommandNames.Cleanup]: (request: protocol.Request) => { + [CommandNames.Cleanup]: () => { this.cleanup(); return this.requiredResponse(true); }, @@ -1581,7 +1581,7 @@ namespace ts.server { [CommandNames.ProjectInfo]: (request: protocol.ProjectInfoRequest) => { return this.requiredResponse(this.getProjectInfo(request.arguments)); }, - [CommandNames.ReloadProjects]: (request: protocol.ReloadProjectsRequest) => { + [CommandNames.ReloadProjects]: () => { this.projectService.reloadProjects(); return this.notRequired(); }, @@ -1591,7 +1591,7 @@ namespace ts.server { [CommandNames.GetCodeFixesFull]: (request: protocol.CodeFixRequest) => { return this.requiredResponse(this.getCodeFixes(request.arguments, /*simplifiedResult*/ false)); }, - [CommandNames.GetSupportedCodeFixes]: (request: protocol.Request) => { + [CommandNames.GetSupportedCodeFixes]: () => { return this.requiredResponse(this.getSupportedCodeFixes()); } }); diff --git a/src/server/tsconfig.json b/src/server/tsconfig.json index 5308abb0c84..a99994d97c5 100644 --- a/src/server/tsconfig.json +++ b/src/server/tsconfig.json @@ -11,7 +11,9 @@ "types": [ "node" ], - "target": "es5" + "target": "es5", + "noUnusedLocals": true, + "noUnusedParameters": true }, "files": [ "../services/shims.ts", diff --git a/src/server/tsconfig.library.json b/src/server/tsconfig.library.json index a287a77fed5..e269629b558 100644 --- a/src/server/tsconfig.library.json +++ b/src/server/tsconfig.library.json @@ -8,7 +8,9 @@ "stripInternal": true, "declaration": true, "types": [], - "target": "es5" + "target": "es5", + "noUnusedLocals": true, + "noUnusedParameters": true }, "files": [ "../services/shims.ts", diff --git a/src/server/typingsCache.ts b/src/server/typingsCache.ts index 889cfe1fb8f..d522974cc5b 100644 --- a/src/server/typingsCache.ts +++ b/src/server/typingsCache.ts @@ -10,8 +10,8 @@ namespace ts.server { export const nullTypingsInstaller: ITypingsInstaller = { enqueueInstallTypingsRequest: () => {}, - attach: (projectService: ProjectService) => {}, - onProjectClosed: (p: Project) => {}, + attach: () => {}, + onProjectClosed: () => {}, globalTypingsCacheLocation: undefined }; diff --git a/src/server/typingsInstaller/nodeTypingsInstaller.ts b/src/server/typingsInstaller/nodeTypingsInstaller.ts index ff643e885e4..89419264930 100644 --- a/src/server/typingsInstaller/nodeTypingsInstaller.ts +++ b/src/server/typingsInstaller/nodeTypingsInstaller.ts @@ -126,7 +126,7 @@ namespace ts.server.typingsInstaller { case NpmInstallRequest: { const command = `${this.npmPath} install ${args.join(" ")} --save-dev`; const start = Date.now(); - this.exec(command, { cwd }, (err, stdout, stderr) => { + this.exec(command, { cwd }, (_err, stdout, stderr) => { if (this.log.isEnabled()) { this.log.writeLine(`${requestKind} #${requestId} took: ${Date.now() - start} ms${sys.newLine}stdout: ${stdout}${sys.newLine}stderr: ${stderr}`); } diff --git a/src/server/typingsInstaller/tsconfig.json b/src/server/typingsInstaller/tsconfig.json index 58805081de6..c9b4d8f0ad1 100644 --- a/src/server/typingsInstaller/tsconfig.json +++ b/src/server/typingsInstaller/tsconfig.json @@ -11,7 +11,9 @@ "types": [ "node" ], - "target": "es5" + "target": "es5", + "noUnusedLocals": true, + "noUnusedParameters": true }, "files": [ "../types.d.ts", diff --git a/src/server/typingsInstaller/typingsInstaller.ts b/src/server/typingsInstaller/typingsInstaller.ts index f62f5fc4abe..58d56195068 100644 --- a/src/server/typingsInstaller/typingsInstaller.ts +++ b/src/server/typingsInstaller/typingsInstaller.ts @@ -35,7 +35,7 @@ namespace ts.server.typingsInstaller { export const MaxPackageNameLength = 214; /** - * Validates package name using rules defined at https://docs.npmjs.com/files/package.json + * Validates package name using rules defined at https://docs.npmjs.com/files/package.json */ export function validatePackageName(packageName: string): PackageNameValidationResult { Debug.assert(!!packageName, "Package name is not specified"); @@ -131,7 +131,7 @@ namespace ts.server.typingsInstaller { this.log.writeLine(`Got install request ${JSON.stringify(req)}`); } - // load existing typing information from the cache + // load existing typing information from the cache if (req.cachePath) { if (this.log.isEnabled()) { this.log.writeLine(`Request specifies cache path '${req.cachePath}', loading cached information...`); @@ -145,8 +145,7 @@ namespace ts.server.typingsInstaller { req.projectRootPath, this.safeListPath, this.packageNameToTypingLocation, - req.typingOptions, - req.compilerOptions); + req.typingOptions); if (this.log.isEnabled()) { this.log.writeLine(`Finished typings discovery: ${JSON.stringify(discoverTypingsResult)}`); diff --git a/src/services/completions.ts b/src/services/completions.ts index 3b76fdc8c3b..ba5d1503075 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -179,7 +179,7 @@ namespace ts.Completions { // Get string literal completions from specialized signatures of the target // i.e. declare function f(a: 'A'); // f("/*completion position*/") - return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo, node); + return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo); } // Get completion for string literal from string literal type @@ -199,7 +199,7 @@ namespace ts.Completions { } } - function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo: SignatureHelp.ArgumentListInfo, location: Node) { + function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo: SignatureHelp.ArgumentListInfo) { const candidates: Signature[] = []; const entries: CompletionEntry[] = []; @@ -361,7 +361,7 @@ namespace ts.Completions { /** * Multiple file entries might map to the same truncated name once we remove extensions * (happens iff includeExtensions === false)so we use a set-like data structure. Eg: - * + * * both foo.ts and foo.tsx become foo */ const foundFiles = createMap(); @@ -617,7 +617,7 @@ namespace ts.Completions { if (typeRoots) { for (const root of typeRoots) { - getCompletionEntriesFromDirectories(host, options, root, span, result); + getCompletionEntriesFromDirectories(host, root, span, result); } } } @@ -626,14 +626,14 @@ namespace ts.Completions { // Also get all @types typings installed in visible node_modules directories for (const packageJson of findPackageJsons(scriptPath)) { const typesDir = combinePaths(getDirectoryPath(packageJson), "node_modules/@types"); - getCompletionEntriesFromDirectories(host, options, typesDir, span, result); + getCompletionEntriesFromDirectories(host, typesDir, span, result); } } return result; } - function getCompletionEntriesFromDirectories(host: LanguageServiceHost, options: CompilerOptions, directory: string, span: TextSpan, result: CompletionEntry[]) { + function getCompletionEntriesFromDirectories(host: LanguageServiceHost, directory: string, span: TextSpan, result: CompletionEntry[]) { if (host.getDirectories && tryDirectoryExists(host, directory)) { const directories = tryGetDirectories(host, directory); if (directories) { @@ -1708,11 +1708,11 @@ namespace ts.Completions { * to determine if the caret is currently within the string literal and capture the literal fragment * for completions. * For example, this matches - * + * * /// , - typingOptions: TypingOptions, - compilerOptions: CompilerOptions): + typingOptions: TypingOptions): { cachedTypingPaths: string[], newTypingNames: string[], filesToWatch: string[] } { // A typing name to typing file path mapping diff --git a/src/services/services.ts b/src/services/services.ts index 666644aca1b..9ed73318d8e 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -264,23 +264,23 @@ namespace ts { return (sourceFile || this.getSourceFile()).text.substring(this.getStart(), this.getEnd()); } - public getChildCount(sourceFile?: SourceFile): number { + public getChildCount(): number { return 0; } - public getChildAt(index: number, sourceFile?: SourceFile): Node { + public getChildAt(): Node { return undefined; } - public getChildren(sourceFile?: SourceFile): Node[] { + public getChildren(): Node[] { return emptyArray; } - public getFirstToken(sourceFile?: SourceFile): Node { + public getFirstToken(): Node { return undefined; } - public getLastToken(sourceFile?: SourceFile): Node { + public getLastToken(): Node { return undefined; } } @@ -313,7 +313,7 @@ namespace ts { getDocumentationComment(): SymbolDisplayPart[] { if (this.documentationComment === undefined) { - this.documentationComment = JsDoc.getJsDocCommentsFromDeclarations(this.declarations, this.name, !(this.flags & SymbolFlags.Property)); + this.documentationComment = JsDoc.getJsDocCommentsFromDeclarations(this.declarations); } return this.documentationComment; @@ -338,7 +338,7 @@ namespace ts { _incrementExpressionBrand: any; _unaryExpressionBrand: any; _expressionBrand: any; - constructor(kind: SyntaxKind.Identifier, pos: number, end: number) { + constructor(_kind: SyntaxKind.Identifier, pos: number, end: number) { super(pos, end); } } @@ -423,10 +423,7 @@ namespace ts { getDocumentationComment(): SymbolDisplayPart[] { if (this.documentationComment === undefined) { - this.documentationComment = this.declaration ? JsDoc.getJsDocCommentsFromDeclarations( - [this.declaration], - /*name*/ undefined, - /*canUseParsedParamTagComments*/ false) : []; + this.documentationComment = this.declaration ? JsDoc.getJsDocCommentsFromDeclarations([this.declaration]) : []; } return this.documentationComment; @@ -802,7 +799,7 @@ namespace ts { public getRootFileNames(): string[] { const fileNames: string[] = []; - this.fileNameToEntry.forEachValue((path, value) => { + this.fileNameToEntry.forEachValue((_path, value) => { if (value) { fileNames.push(value.hostFileName); } @@ -1054,7 +1051,7 @@ namespace ts { useCaseSensitiveFileNames: () => useCaseSensitivefileNames, getNewLine: () => getNewLineOrDefaultFromHost(host), getDefaultLibFileName: (options) => host.getDefaultLibFileName(options), - writeFile: (fileName, data, writeByteOrderMark) => { }, + writeFile: () => { }, getCurrentDirectory: () => currentDirectory, fileExists: (fileName): boolean => { // stub missing host functionality @@ -1458,7 +1455,7 @@ namespace ts { return getNonBoundSourceFile(fileName); } - function getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan { + function getNameOrDottedNameSpan(fileName: string, startPos: number, _endPos: number): TextSpan { const sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); // Get node at the location diff --git a/src/services/shims.ts b/src/services/shims.ts index 571f009d866..bd4c48838da 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -119,13 +119,13 @@ namespace ts { } export interface Shim { - dispose(dummy: any): void; + dispose(_dummy: any): void; } export interface LanguageServiceShim extends Shim { languageService: LanguageService; - dispose(dummy: any): void; + dispose(_dummy: any): void; refresh(throwOnError: boolean): void; @@ -600,7 +600,7 @@ namespace ts { constructor(private factory: ShimFactory) { factory.registerShim(this); } - public dispose(dummy: any): void { + public dispose(_dummy: any): void { this.factory.unregisterShim(this); } } @@ -1168,8 +1168,7 @@ namespace ts { toPath(info.projectRootPath, info.projectRootPath, getCanonicalFileName), toPath(info.safeListPath, info.safeListPath, getCanonicalFileName), info.packageNameToTypingLocation, - info.typingOptions, - info.compilerOptions); + info.typingOptions); }); } } diff --git a/src/services/transpile.ts b/src/services/transpile.ts index 303ca0d4173..da54faed1a2 100644 --- a/src/services/transpile.ts +++ b/src/services/transpile.ts @@ -74,8 +74,8 @@ namespace ts { // Create a compilerHost object to allow the compiler to read and write files const compilerHost: CompilerHost = { - getSourceFile: (fileName, target) => fileName === normalizePath(inputFileName) ? sourceFile : undefined, - writeFile: (name, text, writeByteOrderMark) => { + getSourceFile: (fileName) => fileName === normalizePath(inputFileName) ? sourceFile : undefined, + writeFile: (name, text) => { if (fileExtensionIs(name, ".map")) { Debug.assert(sourceMapText === undefined, `Unexpected multiple source map outputs for the file '${name}'`); sourceMapText = text; @@ -91,9 +91,9 @@ namespace ts { getCurrentDirectory: () => "", getNewLine: () => newLine, fileExists: (fileName): boolean => fileName === inputFileName, - readFile: (fileName): string => "", - directoryExists: directoryExists => true, - getDirectories: (path: string) => [] + readFile: () => "", + directoryExists: () => true, + getDirectories: () => [] }; const program = createProgram([inputFileName], options, compilerHost); diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index 4e130c7dfb2..e81db68325c 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -10,7 +10,9 @@ "stripInternal": true, "noResolve": false, "declaration": true, - "target": "es5" + "target": "es5", + "noUnusedLocals": true, + "noUnusedParameters": true }, "files": [ "../compiler/core.ts", diff --git a/src/services/types.ts b/src/services/types.ts index 3d2bcf4c360..4e04df3fc7c 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -97,7 +97,7 @@ namespace ts { return this.text.length; } - public getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange { + public getChangeRange(): TextChangeRange { // Text-based snapshots do not support incremental parsing. Return undefined // to signal that to the caller. return undefined; diff --git a/src/services/utilities.ts b/src/services/utilities.ts index b83262a9d8c..45dff60dd89 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -1179,7 +1179,7 @@ namespace ts { } export function symbolPart(text: string, symbol: Symbol) { - return displayPart(text, displayPartKind(symbol), symbol); + return displayPart(text, displayPartKind(symbol)); function displayPartKind(symbol: Symbol): SymbolDisplayPartKind { const flags = symbol.flags; @@ -1205,7 +1205,7 @@ namespace ts { } } - export function displayPart(text: string, kind: SymbolDisplayPartKind, symbol?: Symbol): SymbolDisplayPart { + export function displayPart(text: string, kind: SymbolDisplayPartKind): SymbolDisplayPart { return { text: text, kind: SymbolDisplayPartKind[kind] From c877635b470e43fcbc8bbf38039d0712c75969ef Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Wed, 19 Oct 2016 09:13:52 -0700 Subject: [PATCH 142/173] Don't need `libFilePath` parameter --- src/harness/unittests/tsserverProjectSystem.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index de2fdd10e8e..a1ef87c2483 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -122,7 +122,7 @@ namespace ts.projectSystem { return JSON.stringify({ dependencies: dependencies }); } - export function getExecutingFilePathFromLibFile(_libFilePath: string): string { + export function getExecutingFilePathFromLibFile(): string { return combinePaths(getDirectoryPath(libFile.path), "tsc.js"); } @@ -154,16 +154,13 @@ namespace ts.projectSystem { currentDirectory?: string; } - export function createServerHost(fileOrFolderList: FileOrFolder[], - params?: TestServerHostCreationParameters, - libFilePath: string = libFile.path): TestServerHost { - + export function createServerHost(fileOrFolderList: FileOrFolder[], params?: TestServerHostCreationParameters): TestServerHost { if (!params) { params = {}; } const host = new TestServerHost( params.useCaseSensitiveFileNames !== undefined ? params.useCaseSensitiveFileNames : false, - params.executingFilePath || getExecutingFilePathFromLibFile(libFilePath), + params.executingFilePath || getExecutingFilePathFromLibFile(), params.currentDirectory || "/", fileOrFolderList); host.createFileOrFolder(safeList, /*createParentDirectory*/ true); From 23e9e0ba63095a38f6bfa6ebb412610aad1300b2 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Tue, 18 Oct 2016 12:24:41 -0700 Subject: [PATCH 143/173] Adding testcases for reactnamespace --- tests/baselines/reference/unusedImports15.js | 27 ++++++++++++++ .../reference/unusedImports15.symbols | 36 ++++++++++++++++++ .../baselines/reference/unusedImports15.types | 37 +++++++++++++++++++ tests/baselines/reference/unusedImports16.js | 27 ++++++++++++++ .../reference/unusedImports16.symbols | 36 ++++++++++++++++++ .../baselines/reference/unusedImports16.types | 37 +++++++++++++++++++ tests/cases/compiler/unusedImports13.ts | 1 - tests/cases/compiler/unusedImports14.ts | 1 - tests/cases/compiler/unusedImports15.ts | 23 ++++++++++++ tests/cases/compiler/unusedImports16.ts | 23 ++++++++++++ 10 files changed, 246 insertions(+), 2 deletions(-) create mode 100644 tests/baselines/reference/unusedImports15.js create mode 100644 tests/baselines/reference/unusedImports15.symbols create mode 100644 tests/baselines/reference/unusedImports15.types create mode 100644 tests/baselines/reference/unusedImports16.js create mode 100644 tests/baselines/reference/unusedImports16.symbols create mode 100644 tests/baselines/reference/unusedImports16.types create mode 100644 tests/cases/compiler/unusedImports15.ts create mode 100644 tests/cases/compiler/unusedImports16.ts diff --git a/tests/baselines/reference/unusedImports15.js b/tests/baselines/reference/unusedImports15.js new file mode 100644 index 00000000000..01be756e0e5 --- /dev/null +++ b/tests/baselines/reference/unusedImports15.js @@ -0,0 +1,27 @@ +//// [tests/cases/compiler/unusedImports15.ts] //// + +//// [foo.tsx] + +import Element = require("react"); + +export const FooComponent =
+ +//// [index.d.ts] +export = React; +export as namespace React; + +declare namespace React { + function createClass(spec); +} +declare global { + namespace JSX { + } +} + + + + +//// [foo.jsx] +"use strict"; +var Element = require("react"); +exports.FooComponent =
; diff --git a/tests/baselines/reference/unusedImports15.symbols b/tests/baselines/reference/unusedImports15.symbols new file mode 100644 index 00000000000..a325dc7ed76 --- /dev/null +++ b/tests/baselines/reference/unusedImports15.symbols @@ -0,0 +1,36 @@ +=== tests/cases/compiler/foo.tsx === + +import Element = require("react"); +>Element : Symbol(Element, Decl(foo.tsx, 0, 0)) + +export const FooComponent =
+>FooComponent : Symbol(FooComponent, Decl(foo.tsx, 3, 12)) +>div : Symbol(unknown) +>div : Symbol(unknown) + +=== tests/cases/compiler/node_modules/@types/react/index.d.ts === +export = React; +>React : Symbol(React, Decl(index.d.ts, 1, 26)) + +export as namespace React; +>React : Symbol(React, Decl(index.d.ts, 0, 15)) + +declare namespace React { +>React : Symbol(React, Decl(index.d.ts, 1, 26)) + + function createClass(spec); +>createClass : Symbol(createClass, Decl(index.d.ts, 3, 25)) +>P : Symbol(P, Decl(index.d.ts, 4, 25)) +>S : Symbol(S, Decl(index.d.ts, 4, 27)) +>spec : Symbol(spec, Decl(index.d.ts, 4, 31)) +} +declare global { +>global : Symbol(global, Decl(index.d.ts, 5, 1)) + + namespace JSX { +>JSX : Symbol(JSX, Decl(index.d.ts, 6, 16)) + } +} + + + diff --git a/tests/baselines/reference/unusedImports15.types b/tests/baselines/reference/unusedImports15.types new file mode 100644 index 00000000000..c222eaa03a3 --- /dev/null +++ b/tests/baselines/reference/unusedImports15.types @@ -0,0 +1,37 @@ +=== tests/cases/compiler/foo.tsx === + +import Element = require("react"); +>Element : typeof Element + +export const FooComponent =
+>FooComponent : any +>
: any +>div : any +>div : any + +=== tests/cases/compiler/node_modules/@types/react/index.d.ts === +export = React; +>React : typeof React + +export as namespace React; +>React : typeof React + +declare namespace React { +>React : typeof React + + function createClass(spec); +>createClass : (spec: any) => any +>P : P +>S : S +>spec : any +} +declare global { +>global : any + + namespace JSX { +>JSX : any + } +} + + + diff --git a/tests/baselines/reference/unusedImports16.js b/tests/baselines/reference/unusedImports16.js new file mode 100644 index 00000000000..1ce802d869a --- /dev/null +++ b/tests/baselines/reference/unusedImports16.js @@ -0,0 +1,27 @@ +//// [tests/cases/compiler/unusedImports16.ts] //// + +//// [foo.tsx] + +import Element = require("react"); + +export const FooComponent =
+ +//// [index.d.ts] +export = React; +export as namespace React; + +declare namespace React { + function createClass(spec); +} +declare global { + namespace JSX { + } +} + + + + +//// [foo.js] +"use strict"; +var Element = require("react"); +exports.FooComponent = Element.createElement("div", null); diff --git a/tests/baselines/reference/unusedImports16.symbols b/tests/baselines/reference/unusedImports16.symbols new file mode 100644 index 00000000000..a325dc7ed76 --- /dev/null +++ b/tests/baselines/reference/unusedImports16.symbols @@ -0,0 +1,36 @@ +=== tests/cases/compiler/foo.tsx === + +import Element = require("react"); +>Element : Symbol(Element, Decl(foo.tsx, 0, 0)) + +export const FooComponent =
+>FooComponent : Symbol(FooComponent, Decl(foo.tsx, 3, 12)) +>div : Symbol(unknown) +>div : Symbol(unknown) + +=== tests/cases/compiler/node_modules/@types/react/index.d.ts === +export = React; +>React : Symbol(React, Decl(index.d.ts, 1, 26)) + +export as namespace React; +>React : Symbol(React, Decl(index.d.ts, 0, 15)) + +declare namespace React { +>React : Symbol(React, Decl(index.d.ts, 1, 26)) + + function createClass(spec); +>createClass : Symbol(createClass, Decl(index.d.ts, 3, 25)) +>P : Symbol(P, Decl(index.d.ts, 4, 25)) +>S : Symbol(S, Decl(index.d.ts, 4, 27)) +>spec : Symbol(spec, Decl(index.d.ts, 4, 31)) +} +declare global { +>global : Symbol(global, Decl(index.d.ts, 5, 1)) + + namespace JSX { +>JSX : Symbol(JSX, Decl(index.d.ts, 6, 16)) + } +} + + + diff --git a/tests/baselines/reference/unusedImports16.types b/tests/baselines/reference/unusedImports16.types new file mode 100644 index 00000000000..c222eaa03a3 --- /dev/null +++ b/tests/baselines/reference/unusedImports16.types @@ -0,0 +1,37 @@ +=== tests/cases/compiler/foo.tsx === + +import Element = require("react"); +>Element : typeof Element + +export const FooComponent =
+>FooComponent : any +>
: any +>div : any +>div : any + +=== tests/cases/compiler/node_modules/@types/react/index.d.ts === +export = React; +>React : typeof React + +export as namespace React; +>React : typeof React + +declare namespace React { +>React : typeof React + + function createClass(spec); +>createClass : (spec: any) => any +>P : P +>S : S +>spec : any +} +declare global { +>global : any + + namespace JSX { +>JSX : any + } +} + + + diff --git a/tests/cases/compiler/unusedImports13.ts b/tests/cases/compiler/unusedImports13.ts index 875e36abab2..af188e70eae 100644 --- a/tests/cases/compiler/unusedImports13.ts +++ b/tests/cases/compiler/unusedImports13.ts @@ -1,5 +1,4 @@ //@noUnusedLocals:true -//@noUnusedParameters:true //@module: commonjs //@jsx: preserve diff --git a/tests/cases/compiler/unusedImports14.ts b/tests/cases/compiler/unusedImports14.ts index 89e4b31cb13..1823d4bb49b 100644 --- a/tests/cases/compiler/unusedImports14.ts +++ b/tests/cases/compiler/unusedImports14.ts @@ -1,5 +1,4 @@ //@noUnusedLocals:true -//@noUnusedParameters:true //@module: commonjs //@jsx: react diff --git a/tests/cases/compiler/unusedImports15.ts b/tests/cases/compiler/unusedImports15.ts new file mode 100644 index 00000000000..ef6b277d21d --- /dev/null +++ b/tests/cases/compiler/unusedImports15.ts @@ -0,0 +1,23 @@ +//@noUnusedLocals:true +//@module: commonjs +//@reactNamespace: Element +//@jsx: preserve + +// @filename: foo.tsx +import Element = require("react"); + +export const FooComponent =
+ +// @filename: node_modules/@types/react/index.d.ts +export = React; +export as namespace React; + +declare namespace React { + function createClass(spec); +} +declare global { + namespace JSX { + } +} + + diff --git a/tests/cases/compiler/unusedImports16.ts b/tests/cases/compiler/unusedImports16.ts new file mode 100644 index 00000000000..ff0c38bb75e --- /dev/null +++ b/tests/cases/compiler/unusedImports16.ts @@ -0,0 +1,23 @@ +//@noUnusedLocals:true +//@module: commonjs +//@reactNamespace: Element +//@jsx: react + +// @filename: foo.tsx +import Element = require("react"); + +export const FooComponent =
+ +// @filename: node_modules/@types/react/index.d.ts +export = React; +export as namespace React; + +declare namespace React { + function createClass(spec); +} +declare global { + namespace JSX { + } +} + + From 58ed72fd9a4750defbcd65fa45e55e8fdd20b3ed Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Tue, 4 Oct 2016 06:06:28 -0700 Subject: [PATCH 144/173] Fixes #10624 --- src/compiler/checker.ts | 4 ++- .../classDeclaredBeforeClassFactory.js | 30 +++++++++++++++++ .../classDeclaredBeforeClassFactory.symbols | 13 ++++++++ .../classDeclaredBeforeClassFactory.types | 15 +++++++++ .../reference/classExpression3.errors.txt | 15 --------- .../reference/classExpression3.symbols | 26 +++++++++++++++ .../reference/classExpression3.types | 33 +++++++++++++++++++ .../reference/classExpressionES63.errors.txt | 15 --------- .../reference/classExpressionES63.symbols | 26 +++++++++++++++ .../reference/classExpressionES63.types | 33 +++++++++++++++++++ ...singPropertiesOfClassExpression.errors.txt | 5 +-- .../classDeclaredBeforeClassFactory.ts | 6 ++++ 12 files changed, 186 insertions(+), 35 deletions(-) create mode 100644 tests/baselines/reference/classDeclaredBeforeClassFactory.js create mode 100644 tests/baselines/reference/classDeclaredBeforeClassFactory.symbols create mode 100644 tests/baselines/reference/classDeclaredBeforeClassFactory.types delete mode 100644 tests/baselines/reference/classExpression3.errors.txt create mode 100644 tests/baselines/reference/classExpression3.symbols create mode 100644 tests/baselines/reference/classExpression3.types delete mode 100644 tests/baselines/reference/classExpressionES63.errors.txt create mode 100644 tests/baselines/reference/classExpressionES63.symbols create mode 100644 tests/baselines/reference/classExpressionES63.types create mode 100644 tests/cases/compiler/classDeclaredBeforeClassFactory.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f24f72491b0..3c7ff7112e0 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -17114,7 +17114,9 @@ namespace ts { checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); - if (baseType.symbol.valueDeclaration && !isInAmbientContext(baseType.symbol.valueDeclaration)) { + if (baseType.symbol.valueDeclaration && + !isInAmbientContext(baseType.symbol.valueDeclaration) && + baseType.symbol.valueDeclaration.kind === SyntaxKind.ClassDeclaration) { if (!isBlockScopedNameDeclaredBeforeUse(baseType.symbol.valueDeclaration, node)) { error(baseTypeNode, Diagnostics.A_class_must_be_declared_after_its_base_class); } diff --git a/tests/baselines/reference/classDeclaredBeforeClassFactory.js b/tests/baselines/reference/classDeclaredBeforeClassFactory.js new file mode 100644 index 00000000000..3dd1e7a4aaf --- /dev/null +++ b/tests/baselines/reference/classDeclaredBeforeClassFactory.js @@ -0,0 +1,30 @@ +//// [classDeclaredBeforeClassFactory.ts] +// Should be OK due to hoisting +class Derived extends makeBaseClass() {} + +function makeBaseClass() { + return class Base {}; +} + + +//// [classDeclaredBeforeClassFactory.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +// Should be OK due to hoisting +var Derived = (function (_super) { + __extends(Derived, _super); + function Derived() { + return _super.apply(this, arguments) || this; + } + return Derived; +}(makeBaseClass())); +function makeBaseClass() { + return (function () { + function Base() { + } + return Base; + }()); +} diff --git a/tests/baselines/reference/classDeclaredBeforeClassFactory.symbols b/tests/baselines/reference/classDeclaredBeforeClassFactory.symbols new file mode 100644 index 00000000000..cf23402c3b4 --- /dev/null +++ b/tests/baselines/reference/classDeclaredBeforeClassFactory.symbols @@ -0,0 +1,13 @@ +=== tests/cases/compiler/classDeclaredBeforeClassFactory.ts === +// Should be OK due to hoisting +class Derived extends makeBaseClass() {} +>Derived : Symbol(Derived, Decl(classDeclaredBeforeClassFactory.ts, 0, 0)) +>makeBaseClass : Symbol(makeBaseClass, Decl(classDeclaredBeforeClassFactory.ts, 1, 40)) + +function makeBaseClass() { +>makeBaseClass : Symbol(makeBaseClass, Decl(classDeclaredBeforeClassFactory.ts, 1, 40)) + + return class Base {}; +>Base : Symbol(Base, Decl(classDeclaredBeforeClassFactory.ts, 4, 10)) +} + diff --git a/tests/baselines/reference/classDeclaredBeforeClassFactory.types b/tests/baselines/reference/classDeclaredBeforeClassFactory.types new file mode 100644 index 00000000000..0fc2437381f --- /dev/null +++ b/tests/baselines/reference/classDeclaredBeforeClassFactory.types @@ -0,0 +1,15 @@ +=== tests/cases/compiler/classDeclaredBeforeClassFactory.ts === +// Should be OK due to hoisting +class Derived extends makeBaseClass() {} +>Derived : Derived +>makeBaseClass() : Base +>makeBaseClass : () => typeof Base + +function makeBaseClass() { +>makeBaseClass : () => typeof Base + + return class Base {}; +>class Base {} : typeof Base +>Base : typeof Base +} + diff --git a/tests/baselines/reference/classExpression3.errors.txt b/tests/baselines/reference/classExpression3.errors.txt deleted file mode 100644 index 2a7a2e160f1..00000000000 --- a/tests/baselines/reference/classExpression3.errors.txt +++ /dev/null @@ -1,15 +0,0 @@ -tests/cases/conformance/classes/classExpressions/classExpression3.ts(1,23): error TS2690: A class must be declared after its base class. -tests/cases/conformance/classes/classExpressions/classExpression3.ts(1,37): error TS2690: A class must be declared after its base class. - - -==== tests/cases/conformance/classes/classExpressions/classExpression3.ts (2 errors) ==== - let C = class extends class extends class { a = 1 } { b = 2 } { c = 3 }; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. - ~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. - let c = new C(); - c.a; - c.b; - c.c; - \ No newline at end of file diff --git a/tests/baselines/reference/classExpression3.symbols b/tests/baselines/reference/classExpression3.symbols new file mode 100644 index 00000000000..bc1b263a000 --- /dev/null +++ b/tests/baselines/reference/classExpression3.symbols @@ -0,0 +1,26 @@ +=== tests/cases/conformance/classes/classExpressions/classExpression3.ts === +let C = class extends class extends class { a = 1 } { b = 2 } { c = 3 }; +>C : Symbol(C, Decl(classExpression3.ts, 0, 3)) +>a : Symbol((Anonymous class).a, Decl(classExpression3.ts, 0, 43)) +>b : Symbol((Anonymous class).b, Decl(classExpression3.ts, 0, 53)) +>c : Symbol((Anonymous class).c, Decl(classExpression3.ts, 0, 63)) + +let c = new C(); +>c : Symbol(c, Decl(classExpression3.ts, 1, 3)) +>C : Symbol(C, Decl(classExpression3.ts, 0, 3)) + +c.a; +>c.a : Symbol((Anonymous class).a, Decl(classExpression3.ts, 0, 43)) +>c : Symbol(c, Decl(classExpression3.ts, 1, 3)) +>a : Symbol((Anonymous class).a, Decl(classExpression3.ts, 0, 43)) + +c.b; +>c.b : Symbol((Anonymous class).b, Decl(classExpression3.ts, 0, 53)) +>c : Symbol(c, Decl(classExpression3.ts, 1, 3)) +>b : Symbol((Anonymous class).b, Decl(classExpression3.ts, 0, 53)) + +c.c; +>c.c : Symbol((Anonymous class).c, Decl(classExpression3.ts, 0, 63)) +>c : Symbol(c, Decl(classExpression3.ts, 1, 3)) +>c : Symbol((Anonymous class).c, Decl(classExpression3.ts, 0, 63)) + diff --git a/tests/baselines/reference/classExpression3.types b/tests/baselines/reference/classExpression3.types new file mode 100644 index 00000000000..51798f300d4 --- /dev/null +++ b/tests/baselines/reference/classExpression3.types @@ -0,0 +1,33 @@ +=== tests/cases/conformance/classes/classExpressions/classExpression3.ts === +let C = class extends class extends class { a = 1 } { b = 2 } { c = 3 }; +>C : typeof (Anonymous class) +>class extends class extends class { a = 1 } { b = 2 } { c = 3 } : typeof (Anonymous class) +>class extends class { a = 1 } { b = 2 } : (Anonymous class) +>class { a = 1 } : (Anonymous class) +>a : number +>1 : 1 +>b : number +>2 : 2 +>c : number +>3 : 3 + +let c = new C(); +>c : (Anonymous class) +>new C() : (Anonymous class) +>C : typeof (Anonymous class) + +c.a; +>c.a : number +>c : (Anonymous class) +>a : number + +c.b; +>c.b : number +>c : (Anonymous class) +>b : number + +c.c; +>c.c : number +>c : (Anonymous class) +>c : number + diff --git a/tests/baselines/reference/classExpressionES63.errors.txt b/tests/baselines/reference/classExpressionES63.errors.txt deleted file mode 100644 index 9463162e4a6..00000000000 --- a/tests/baselines/reference/classExpressionES63.errors.txt +++ /dev/null @@ -1,15 +0,0 @@ -tests/cases/conformance/es6/classExpressions/classExpressionES63.ts(1,23): error TS2690: A class must be declared after its base class. -tests/cases/conformance/es6/classExpressions/classExpressionES63.ts(1,37): error TS2690: A class must be declared after its base class. - - -==== tests/cases/conformance/es6/classExpressions/classExpressionES63.ts (2 errors) ==== - let C = class extends class extends class { a = 1 } { b = 2 } { c = 3 }; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. - ~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. - let c = new C(); - c.a; - c.b; - c.c; - \ No newline at end of file diff --git a/tests/baselines/reference/classExpressionES63.symbols b/tests/baselines/reference/classExpressionES63.symbols new file mode 100644 index 00000000000..4e52d5ee9dd --- /dev/null +++ b/tests/baselines/reference/classExpressionES63.symbols @@ -0,0 +1,26 @@ +=== tests/cases/conformance/es6/classExpressions/classExpressionES63.ts === +let C = class extends class extends class { a = 1 } { b = 2 } { c = 3 }; +>C : Symbol(C, Decl(classExpressionES63.ts, 0, 3)) +>a : Symbol((Anonymous class).a, Decl(classExpressionES63.ts, 0, 43)) +>b : Symbol((Anonymous class).b, Decl(classExpressionES63.ts, 0, 53)) +>c : Symbol((Anonymous class).c, Decl(classExpressionES63.ts, 0, 63)) + +let c = new C(); +>c : Symbol(c, Decl(classExpressionES63.ts, 1, 3)) +>C : Symbol(C, Decl(classExpressionES63.ts, 0, 3)) + +c.a; +>c.a : Symbol((Anonymous class).a, Decl(classExpressionES63.ts, 0, 43)) +>c : Symbol(c, Decl(classExpressionES63.ts, 1, 3)) +>a : Symbol((Anonymous class).a, Decl(classExpressionES63.ts, 0, 43)) + +c.b; +>c.b : Symbol((Anonymous class).b, Decl(classExpressionES63.ts, 0, 53)) +>c : Symbol(c, Decl(classExpressionES63.ts, 1, 3)) +>b : Symbol((Anonymous class).b, Decl(classExpressionES63.ts, 0, 53)) + +c.c; +>c.c : Symbol((Anonymous class).c, Decl(classExpressionES63.ts, 0, 63)) +>c : Symbol(c, Decl(classExpressionES63.ts, 1, 3)) +>c : Symbol((Anonymous class).c, Decl(classExpressionES63.ts, 0, 63)) + diff --git a/tests/baselines/reference/classExpressionES63.types b/tests/baselines/reference/classExpressionES63.types new file mode 100644 index 00000000000..c5c8de91c17 --- /dev/null +++ b/tests/baselines/reference/classExpressionES63.types @@ -0,0 +1,33 @@ +=== tests/cases/conformance/es6/classExpressions/classExpressionES63.ts === +let C = class extends class extends class { a = 1 } { b = 2 } { c = 3 }; +>C : typeof (Anonymous class) +>class extends class extends class { a = 1 } { b = 2 } { c = 3 } : typeof (Anonymous class) +>class extends class { a = 1 } { b = 2 } : (Anonymous class) +>class { a = 1 } : (Anonymous class) +>a : number +>1 : 1 +>b : number +>2 : 2 +>c : number +>3 : 3 + +let c = new C(); +>c : (Anonymous class) +>new C() : (Anonymous class) +>C : typeof (Anonymous class) + +c.a; +>c.a : number +>c : (Anonymous class) +>a : number + +c.b; +>c.b : number +>c : (Anonymous class) +>b : number + +c.c; +>c.c : number +>c : (Anonymous class) +>c : number + diff --git a/tests/baselines/reference/missingPropertiesOfClassExpression.errors.txt b/tests/baselines/reference/missingPropertiesOfClassExpression.errors.txt index 23e67d7cf0b..b7331a68271 100644 --- a/tests/baselines/reference/missingPropertiesOfClassExpression.errors.txt +++ b/tests/baselines/reference/missingPropertiesOfClassExpression.errors.txt @@ -1,11 +1,8 @@ -tests/cases/compiler/missingPropertiesOfClassExpression.ts(1,22): error TS2690: A class must be declared after its base class. tests/cases/compiler/missingPropertiesOfClassExpression.ts(1,52): error TS2339: Property 'y' does not exist on type '(Anonymous class)'. -==== tests/cases/compiler/missingPropertiesOfClassExpression.ts (2 errors) ==== +==== tests/cases/compiler/missingPropertiesOfClassExpression.ts (1 errors) ==== class George extends class { reset() { return this.y; } } { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. ~ !!! error TS2339: Property 'y' does not exist on type '(Anonymous class)'. constructor() { diff --git a/tests/cases/compiler/classDeclaredBeforeClassFactory.ts b/tests/cases/compiler/classDeclaredBeforeClassFactory.ts new file mode 100644 index 00000000000..27191ce7fd2 --- /dev/null +++ b/tests/cases/compiler/classDeclaredBeforeClassFactory.ts @@ -0,0 +1,6 @@ +// Should be OK due to hoisting +class Derived extends makeBaseClass() {} + +function makeBaseClass() { + return class Base {}; +} From 0365c96e37bbdf8cb3cdce2b3ff5cef98c79dd05 Mon Sep 17 00:00:00 2001 From: Dom Chen Date: Thu, 20 Oct 2016 04:07:49 +0800 Subject: [PATCH 145/173] =?UTF-8?q?Fix=20#11660:=20wrong=20reports=20that?= =?UTF-8?q?=20block-scoped=20variable=20used=20before=20its=20=E2=80=A6=20?= =?UTF-8?q?(#11692)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix #11660: wrong reports that block-scoped variable used before its declaration * Fix code style in checker.ts * Add unit test for #11660 * Fix the unit test for #11660 --- src/compiler/checker.ts | 12 ++++-- .../reference/useBeforeDeclaration.js | 38 ++++++++++++++++++ .../reference/useBeforeDeclaration.symbols | 34 ++++++++++++++++ .../reference/useBeforeDeclaration.types | 39 +++++++++++++++++++ tests/cases/compiler/useBeforeDeclaration.ts | 20 ++++++++++ 5 files changed, 139 insertions(+), 4 deletions(-) create mode 100644 tests/baselines/reference/useBeforeDeclaration.js create mode 100644 tests/baselines/reference/useBeforeDeclaration.symbols create mode 100644 tests/baselines/reference/useBeforeDeclaration.types create mode 100644 tests/cases/compiler/useBeforeDeclaration.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3c7ff7112e0..a0a2fa19f19 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -591,7 +591,11 @@ namespace ts { // nodes are in different files and order cannot be determines return true; } - + // declaration is after usage + // can be legal if usage is deferred (i.e. inside function or in initializer of instance property) + if (isUsedInFunctionOrNonStaticProperty(usage)) { + return true; + } const sourceFiles = host.getSourceFiles(); return indexOf(sourceFiles, declarationFile) <= indexOf(sourceFiles, useFile); } @@ -605,7 +609,8 @@ namespace ts { // 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); + const container = getEnclosingBlockScopeContainer(declaration); + return isUsedInFunctionOrNonStaticProperty(usage, container); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration: VariableDeclaration, usage: Node): boolean { const container = getEnclosingBlockScopeContainer(declaration); @@ -634,8 +639,7 @@ namespace ts { return false; } - function isUsedInFunctionOrNonStaticProperty(declaration: Declaration, usage: Node): boolean { - const container = getEnclosingBlockScopeContainer(declaration); + function isUsedInFunctionOrNonStaticProperty(usage: Node, container?: Node): boolean { let current = usage; while (current) { if (current === container) { diff --git a/tests/baselines/reference/useBeforeDeclaration.js b/tests/baselines/reference/useBeforeDeclaration.js new file mode 100644 index 00000000000..6eab8683aec --- /dev/null +++ b/tests/baselines/reference/useBeforeDeclaration.js @@ -0,0 +1,38 @@ +//// [tests/cases/compiler/useBeforeDeclaration.ts] //// + +//// [A.ts] + +namespace ts { + export function printVersion():void { + log("Version: " + sys.version); // the call of sys.version is deferred, should not report an error. + } + + export function log(info:string):void { + + } +} + +//// [B.ts] +namespace ts { + + export let sys:{version:string} = {version: "2.0.5"}; + +} + + + +//// [test.js] +var ts; +(function (ts) { + function printVersion() { + log("Version: " + ts.sys.version); // the call of sys.version is deferred, should not report an error. + } + ts.printVersion = printVersion; + function log(info) { + } + ts.log = log; +})(ts || (ts = {})); +var ts; +(function (ts) { + ts.sys = { version: "2.0.5" }; +})(ts || (ts = {})); diff --git a/tests/baselines/reference/useBeforeDeclaration.symbols b/tests/baselines/reference/useBeforeDeclaration.symbols new file mode 100644 index 00000000000..484255c0c7d --- /dev/null +++ b/tests/baselines/reference/useBeforeDeclaration.symbols @@ -0,0 +1,34 @@ +=== tests/cases/compiler/A.ts === + +namespace ts { +>ts : Symbol(ts, Decl(A.ts, 0, 0), Decl(B.ts, 0, 0)) + + export function printVersion():void { +>printVersion : Symbol(printVersion, Decl(A.ts, 1, 14)) + + log("Version: " + sys.version); // the call of sys.version is deferred, should not report an error. +>log : Symbol(log, Decl(A.ts, 4, 5)) +>sys.version : Symbol(version, Decl(B.ts, 2, 20)) +>sys : Symbol(sys, Decl(B.ts, 2, 14)) +>version : Symbol(version, Decl(B.ts, 2, 20)) + } + + export function log(info:string):void { +>log : Symbol(log, Decl(A.ts, 4, 5)) +>info : Symbol(info, Decl(A.ts, 6, 24)) + + } +} + +=== tests/cases/compiler/B.ts === +namespace ts { +>ts : Symbol(ts, Decl(A.ts, 0, 0), Decl(B.ts, 0, 0)) + + export let sys:{version:string} = {version: "2.0.5"}; +>sys : Symbol(sys, Decl(B.ts, 2, 14)) +>version : Symbol(version, Decl(B.ts, 2, 20)) +>version : Symbol(version, Decl(B.ts, 2, 39)) + +} + + diff --git a/tests/baselines/reference/useBeforeDeclaration.types b/tests/baselines/reference/useBeforeDeclaration.types new file mode 100644 index 00000000000..141826723cf --- /dev/null +++ b/tests/baselines/reference/useBeforeDeclaration.types @@ -0,0 +1,39 @@ +=== tests/cases/compiler/A.ts === + +namespace ts { +>ts : typeof ts + + export function printVersion():void { +>printVersion : () => void + + log("Version: " + sys.version); // the call of sys.version is deferred, should not report an error. +>log("Version: " + sys.version) : void +>log : (info: string) => void +>"Version: " + sys.version : string +>"Version: " : "Version: " +>sys.version : string +>sys : { version: string; } +>version : string + } + + export function log(info:string):void { +>log : (info: string) => void +>info : string + + } +} + +=== tests/cases/compiler/B.ts === +namespace ts { +>ts : typeof ts + + export let sys:{version:string} = {version: "2.0.5"}; +>sys : { version: string; } +>version : string +>{version: "2.0.5"} : { version: string; } +>version : string +>"2.0.5" : "2.0.5" + +} + + diff --git a/tests/cases/compiler/useBeforeDeclaration.ts b/tests/cases/compiler/useBeforeDeclaration.ts new file mode 100644 index 00000000000..6dc3b026d13 --- /dev/null +++ b/tests/cases/compiler/useBeforeDeclaration.ts @@ -0,0 +1,20 @@ +// @outFile: test.js + +// @fileName: A.ts +namespace ts { + export function printVersion():void { + log("Version: " + sys.version); // the call of sys.version is deferred, should not report an error. + } + + export function log(info:string):void { + + } +} + +// @fileName: B.ts +namespace ts { + + export let sys:{version:string} = {version: "2.0.5"}; + +} + From 4fbbbed321baa58418b9379b418278d31400fe3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=28=C2=B4=E3=83=BB=CF=89=E3=83=BB=EF=BD=80=29?= Date: Thu, 20 Oct 2016 05:10:44 +0800 Subject: [PATCH 146/173] fix #11670, support type guards in NumberConstructor (#11722) --- src/lib/es2015.core.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/es2015.core.d.ts b/src/lib/es2015.core.d.ts index 356512ecf58..28f2e12248b 100644 --- a/src/lib/es2015.core.d.ts +++ b/src/lib/es2015.core.d.ts @@ -205,13 +205,13 @@ interface NumberConstructor { * number. Only finite values of the type number, result in true. * @param number A numeric value. */ - isFinite(number: number): boolean; + isFinite(value: any): value is number; /** * Returns true if the value passed is an integer, false otherwise. * @param number A numeric value. */ - isInteger(number: number): boolean; + isInteger(value: any): value is number; /** * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a @@ -219,13 +219,13 @@ interface NumberConstructor { * to a number. Only values of the type number, that are also NaN, result in true. * @param number A numeric value. */ - isNaN(number: number): boolean; + isNaN(value: any): value is number; /** * Returns true if the value passed is a safe integer. * @param number A numeric value. */ - isSafeInteger(number: number): boolean; + isSafeInteger(value: any): value is number; /** * The value of the largest integer n such that n and n + 1 are both exactly representable as From 5e7e5421fa1049deaef4995bcc8dd28ece334268 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Wed, 19 Oct 2016 14:15:14 -0700 Subject: [PATCH 147/173] Add noop, notImplemented, and notYetImplemented helpers --- src/compiler/core.ts | 13 ++++++++ src/compiler/declarationEmitter.ts | 2 +- src/compiler/program.ts | 3 +- src/compiler/utilities.ts | 8 ++--- src/compiler/visitor.ts | 6 ++-- src/harness/harness.ts | 4 +-- src/harness/harnessLanguageService.ts | 20 +++++------ src/harness/runner.ts | 2 +- .../unittests/cachingInServerLSHost.ts | 33 +++++++++---------- src/harness/unittests/moduleResolution.ts | 20 ++++------- .../unittests/reuseProgramStructure.ts | 14 ++++---- src/harness/unittests/session.ts | 22 ++++++------- .../unittests/tsserverProjectSystem.ts | 8 ++--- src/server/client.ts | 28 ++++++++-------- src/server/typingsCache.ts | 6 ++-- .../typingsInstaller/typingsInstaller.ts | 2 +- src/services/services.ts | 2 +- src/services/utilities.ts | 4 +-- 18 files changed, 95 insertions(+), 102 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 884f4c94267..cb469255d0a 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -869,6 +869,19 @@ namespace ts { return Array.isArray ? Array.isArray(value) : value instanceof Array; } + /** Does nothing. */ + export function noop(): void {} + + /** A function not intended to be implemented. */ + export function notImplemented(): never { + throw new Error("Not implemented"); + } + + /** A function which isn't implemented, but should be eventually. */ + export function notYetImplemented(): never { + throw new Error("TODO: Not yet implemented"); + } + export function memoize(callback: () => T): () => T { let value: T; return () => { diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index 27751a1dfc2..6458183b23c 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -63,7 +63,7 @@ namespace ts { let isCurrentFileExternalModule: boolean; let reportedDeclarationError = false; let errorNameNode: DeclarationName; - const emitJsDocComments = compilerOptions.removeComments ? () => {} : writeJsDocComments; + const emitJsDocComments = compilerOptions.removeComments ? noop : writeJsDocComments; const emit = compilerOptions.stripInternal ? stripInternal : emitNode; let noDeclare: boolean; diff --git a/src/compiler/program.ts b/src/compiler/program.ts index b34791b7198..b619f005ded 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -950,8 +950,7 @@ namespace ts { return runWithCancellationToken(() => { const resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken); // Don't actually write any files since we're just getting diagnostics. - const writeFile: WriteFileCallback = () => { }; - return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile); + return ts.getDeclarationDiagnostics(getEmitHost(noop), resolver, sourceFile); }); } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 55374a1cd74..87f6cd5e4aa 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -63,11 +63,11 @@ namespace ts { // Completely ignore indentation for string writers. And map newlines to // a single space. writeLine: () => str += " ", - increaseIndent: () => { }, - decreaseIndent: () => { }, + increaseIndent: noop, + decreaseIndent: noop, clear: () => str = "", - trackSymbol: () => { }, - reportInaccessibleThisError: () => { } + trackSymbol: noop, + reportInaccessibleThisError: noop }; } diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index 5c152c88e47..7d5558d5fb2 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -1331,18 +1331,18 @@ namespace ts { export namespace Debug { export const failNotOptional = shouldAssert(AssertionLevel.Normal) ? (message?: string) => assert(false, message || "Node not optional.") - : () => {}; + : noop; export const failBadSyntaxKind = shouldAssert(AssertionLevel.Normal) ? (node: Node, message?: string) => assert(false, message || "Unexpected node.", () => `Node ${formatSyntaxKind(node.kind)} was unexpected.`) - : () => {}; + : noop; export const assertNode = shouldAssert(AssertionLevel.Normal) ? (node: Node, test: (node: Node) => boolean, message?: string) => assert( test === undefined || test(node), message || "Unexpected node.", () => `Node ${formatSyntaxKind(node.kind)} did not pass test '${getFunctionName(test)}'.`) - : () => {}; + : noop; function getFunctionName(func: Function) { if (typeof func !== "function") { diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 7bfd94637b5..32681421d24 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -690,7 +690,7 @@ namespace Harness { export const getCurrentDirectory = () => ""; export const args = () => []; export const getExecutingFilePath = () => ""; - export const exit = () => { }; + export const exit = ts.noop; export const getDirectories = () => []; export let log = (s: string) => console.log(s); @@ -1668,7 +1668,7 @@ namespace Harness { // This does not need to exist strictly speaking, but many tests will need to be updated if it's removed export function compileString(_code: string, _unitName: string, _callback: (result: CompilerResult) => void) { // NEWTODO: Re-implement 'compileString' - throw new Error("compileString NYI"); + return ts.notYetImplemented(); } export interface GeneratedFile { diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 28b57728e1f..a2e1f52f7ea 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -313,14 +313,10 @@ namespace Harness.LanguageService { getLocalizedDiagnosticMessages(): string { return JSON.stringify({}); } readDirectory(_rootDir: string, _extension: string): string { - throw new Error("NYI"); - } - readDirectoryNames(_path: string): string { - throw new Error("Not implemented."); - } - readFileNames(_path: string): string { - throw new Error("Not implemented."); + return ts.notYetImplemented(); } + readDirectoryNames = ts.notImplemented; + readFileNames = ts.notImplemented; fileExists(fileName: string) { return this.getScriptInfo(fileName) !== undefined; } readFile(fileName: string) { const snapshot = this.nativeHost.getScriptSnapshot(fileName); @@ -339,7 +335,7 @@ namespace Harness.LanguageService { constructor(private shim: ts.ClassifierShim) { } getEncodedLexicalClassifications(_text: string, _lexState: ts.EndOfLineState, _classifyKeywordsInGenerics?: boolean): ts.Classifications { - throw new Error("NYI"); + return ts.notYetImplemented(); } getClassificationsForLine(text: string, lexState: ts.EndOfLineState, classifyKeywordsInGenerics?: boolean): ts.ClassificationResult { const result = this.shim.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics).split("\n"); @@ -648,7 +644,7 @@ namespace Harness.LanguageService { } createDirectory(_directoryName: string): void { - throw new Error("Not Implemented Yet."); + return ts.notYetImplemented(); } getCurrentDirectory(): string { @@ -664,15 +660,15 @@ namespace Harness.LanguageService { } readDirectory(_path: string, _extension?: string[], _exclude?: string[], _include?: string[]): string[] { - throw new Error("Not implemented Yet."); + return ts.notYetImplemented(); } watchFile(): ts.FileWatcher { - return { close() { } }; + return { close: ts.noop }; } watchDirectory(): ts.FileWatcher { - return { close() { } }; + return { close: ts.noop }; } close(): void { diff --git a/src/harness/runner.ts b/src/harness/runner.ts index f8df1c51683..3db1da627bc 100644 --- a/src/harness/runner.ts +++ b/src/harness/runner.ts @@ -222,5 +222,5 @@ else { } if (!runUnitTests) { // patch `describe` to skip unit tests - describe = (function () { }); + describe = ts.noop as any; } diff --git a/src/harness/unittests/cachingInServerLSHost.ts b/src/harness/unittests/cachingInServerLSHost.ts index 0a522ddb22e..f930ab393d3 100644 --- a/src/harness/unittests/cachingInServerLSHost.ts +++ b/src/harness/unittests/cachingInServerLSHost.ts @@ -21,15 +21,15 @@ namespace ts { args: [], newLine: "\r\n", useCaseSensitiveFileNames: false, - write: () => { }, + write: noop, readFile: (path: string): string => { return path in fileMap ? fileMap[path].content : undefined; }, writeFile: (_path: string, _data: string, _writeByteOrderMark?: boolean) => { - throw new Error("NYI"); + return ts.notYetImplemented(); }, resolvePath: (_path: string): string => { - throw new Error("NYI"); + return ts.notYetImplemented(); }, fileExists: (path: string): boolean => { return path in fileMap; @@ -37,7 +37,7 @@ namespace ts { directoryExists: (path: string): boolean => { return existingDirectories[path] || false; }, - createDirectory: () => { }, + createDirectory: noop, getExecutingFilePath: (): string => { return ""; }, @@ -47,14 +47,14 @@ namespace ts { getDirectories: () => [], getEnvironmentVariable: () => "", readDirectory: (_path: string, _extension?: string[], _exclude?: string[], _include?: string[]): string[] => { - throw new Error("NYI"); + return ts.notYetImplemented(); }, - exit: () => { }, + exit: noop, watchFile: () => ({ - close: () => { } + close: noop }), watchDirectory: () => ({ - close: () => { } + close: noop }), setTimeout, clearTimeout, @@ -65,14 +65,14 @@ namespace ts { function createProject(rootFile: string, serverHost: server.ServerHost): { project: server.Project, rootScriptInfo: server.ScriptInfo } { const logger: server.Logger = { - close() { }, + close: noop, hasLevel: () => false, loggingEnabled: () => false, - perftrc: () => { }, - info: () => { }, - startGroup: () => { }, - endGroup: () => { }, - msg: () => { }, + perftrc: noop, + info: noop, + startGroup: noop, + endGroup: noop, + msg: noop, getLogFileName: (): string => undefined }; @@ -109,10 +109,7 @@ namespace ts { const originalFileExists = serverHost.fileExists; { // patch fileExists to make sure that disk is not touched - serverHost.fileExists = (): boolean => { - assert.isTrue(false, "fileExists should not be called"); - return false; - }; + serverHost.fileExists = notImplemented; const newContent = `import {x} from "f1" var x: string = 1;`; diff --git a/src/harness/unittests/moduleResolution.ts b/src/harness/unittests/moduleResolution.ts index c21d2df4019..b71d42265e3 100644 --- a/src/harness/unittests/moduleResolution.ts +++ b/src/harness/unittests/moduleResolution.ts @@ -290,7 +290,7 @@ namespace ts { return path in files ? createSourceFile(fileName, files[path], languageVersion) : undefined; }, getDefaultLibFileName: () => "lib.d.ts", - writeFile: (): void => { throw new Error("NotImplemented"); }, + writeFile: notImplemented, getCurrentDirectory: () => currentDirectory, getDirectories: () => [], getCanonicalFileName: fileName => fileName.toLowerCase(), @@ -300,7 +300,7 @@ namespace ts { const path = normalizePath(combinePaths(currentDirectory, fileName)); return path in files; }, - readFile: (): string => { throw new Error("NotImplemented"); } + readFile: notImplemented }; const program = createProgram(rootFiles, options, host); @@ -370,7 +370,7 @@ export = C; return path in files ? createSourceFile(fileName, files[path], languageVersion) : undefined; }, getDefaultLibFileName: () => "lib.d.ts", - writeFile: (): void => { throw new Error("NotImplemented"); }, + writeFile: notImplemented, getCurrentDirectory: () => currentDirectory, getDirectories: () => [], getCanonicalFileName, @@ -380,7 +380,7 @@ export = C; const path = getCanonicalFileName(normalizePath(combinePaths(currentDirectory, fileName))); return path in files; }, - readFile: (): string => { throw new Error("NotImplemented"); } + readFile: notImplemented }; const program = createProgram(rootFiles, options, host); const diagnostics = sortAndDeduplicateDiagnostics(program.getSemanticDiagnostics().concat(program.getOptionsDiagnostics())); @@ -911,15 +911,11 @@ import b = require("./moduleB"); }); }); - function notImplemented(name: string): () => any { - return () => assert(`${name} is not implemented and should not be called`); - } - describe("ModuleResolutionHost.directoryExists", () => { it("No 'fileExists' calls if containing directory is missing", () => { const host: ModuleResolutionHost = { - readFile: notImplemented("readFile"), - fileExists: notImplemented("fileExists"), + readFile: notImplemented, + fileExists: notImplemented, directoryExists: _ => false }; @@ -1022,9 +1018,7 @@ import b = require("./moduleB"); fileExists : fileName => fileName in sourceFiles, getSourceFile: fileName => sourceFiles[fileName], getDefaultLibFileName: () => "lib.d.ts", - writeFile(_file, _text) { - throw new Error("NYI"); - }, + writeFile: notImplemented, getCurrentDirectory: () => "/", getDirectories: () => [], getCanonicalFileName: f => f.toLowerCase(), diff --git a/src/harness/unittests/reuseProgramStructure.ts b/src/harness/unittests/reuseProgramStructure.ts index fcdfc6d08c6..29bb9a05b7c 100644 --- a/src/harness/unittests/reuseProgramStructure.ts +++ b/src/harness/unittests/reuseProgramStructure.ts @@ -111,9 +111,7 @@ namespace ts { getDefaultLibFileName(): string { return "lib.d.ts"; }, - writeFile() { - throw new Error("NYI"); - }, + writeFile: notYetImplemented, getCurrentDirectory(): string { return ""; }, @@ -244,13 +242,13 @@ namespace ts { it("fails if change affects type references", () => { const program_1 = newProgram(files, ["a.ts"], { types: ["a"] }); - updateProgram(program_1, ["a.ts"], { types: ["b"] }, () => { }); + updateProgram(program_1, ["a.ts"], { types: ["b"] }, noop); assert.isTrue(!program_1.structureIsReused); }); it("succeeds if change doesn't affect type references", () => { const program_1 = newProgram(files, ["a.ts"], { types: ["a"] }); - updateProgram(program_1, ["a.ts"], { types: ["a"] }, () => { }); + updateProgram(program_1, ["a.ts"], { types: ["a"] }, noop); assert.isTrue(program_1.structureIsReused); }); @@ -276,19 +274,19 @@ namespace ts { it("fails if module kind changes", () => { const program_1 = newProgram(files, ["a.ts"], { target, module: ModuleKind.CommonJS }); - updateProgram(program_1, ["a.ts"], { target, module: ModuleKind.AMD }, () => { }); + updateProgram(program_1, ["a.ts"], { target, module: ModuleKind.AMD }, noop); assert.isTrue(!program_1.structureIsReused); }); it("fails if rootdir changes", () => { const program_1 = newProgram(files, ["a.ts"], { target, module: ModuleKind.CommonJS, rootDir: "/a/b" }); - updateProgram(program_1, ["a.ts"], { target, module: ModuleKind.CommonJS, rootDir: "/a/c" }, () => { }); + updateProgram(program_1, ["a.ts"], { target, module: ModuleKind.CommonJS, rootDir: "/a/c" }, noop); assert.isTrue(!program_1.structureIsReused); }); it("fails if config path changes", () => { const program_1 = newProgram(files, ["a.ts"], { target, module: ModuleKind.CommonJS, configFilePath: "/a/b/tsconfig.json" }); - updateProgram(program_1, ["a.ts"], { target, module: ModuleKind.CommonJS, configFilePath: "/a/c/tsconfig.json" }, () => { }); + updateProgram(program_1, ["a.ts"], { target, module: ModuleKind.CommonJS, configFilePath: "/a/c/tsconfig.json" }, noop); assert.isTrue(!program_1.structureIsReused); }); diff --git a/src/harness/unittests/session.ts b/src/harness/unittests/session.ts index 0d8fb31e5d8..dd9efe51a4a 100644 --- a/src/harness/unittests/session.ts +++ b/src/harness/unittests/session.ts @@ -10,32 +10,32 @@ namespace ts.server { useCaseSensitiveFileNames: true, write(s): void { lastWrittenToHost = s; }, readFile(): string { return void 0; }, - writeFile(): void {}, + writeFile: noop, resolvePath(): string { return void 0; }, fileExists: () => false, directoryExists: () => false, getDirectories: () => [], - createDirectory(): void {}, + createDirectory: noop, getExecutingFilePath(): string { return void 0; }, getCurrentDirectory(): string { return void 0; }, getEnvironmentVariable(): string { return ""; }, readDirectory(): string[] { return []; }, - exit(): void { }, + exit: noop, setTimeout() { return 0; }, - clearTimeout() { }, + clearTimeout: noop, setImmediate: () => 0, - clearImmediate() {} + clearImmediate: noop }; const nullCancellationToken: HostCancellationToken = { isCancellationRequested: () => false }; const mockLogger: Logger = { - close(): void {}, + close: noop, hasLevel(): boolean { return false; }, loggingEnabled(): boolean { return false; }, - perftrc(): void {}, - info(): void {}, - startGroup(): void {}, - endGroup(): void {}, - msg(): void {}, + perftrc: noop, + info: noop, + startGroup: noop, + endGroup: noop, + msg: noop, getLogFileName: (): string => undefined }; diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index a1ef87c2483..ff92f556eab 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -23,10 +23,6 @@ namespace ts.projectSystem { readonly callback: TI.RequestCompletedAction; } - export function notImplemented(): any { - throw new Error("Not yet implemented"); - } - export const nullLogger: server.Logger = { close: () => void 0, hasLevel: () => void 0, @@ -525,8 +521,8 @@ namespace ts.projectSystem { readonly resolvePath = (s: string) => s; readonly getExecutingFilePath = () => this.executingFilePath; readonly getCurrentDirectory = () => this.currentDirectory; - readonly exit = notImplemented; - readonly getEnvironmentVariable = notImplemented; + readonly exit = notYetImplemented; + readonly getEnvironmentVariable = notYetImplemented; } export function makeSessionRequest(command: string, args: T) { diff --git a/src/server/client.ts b/src/server/client.ts index adc55f96471..baa47ac6381 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -242,7 +242,7 @@ namespace ts.server { } getCompletionEntrySymbol(_fileName: string, _position: number, _entryName: string): Symbol { - throw new Error("Not Implemented Yet."); + return notYetImplemented(); } getNavigateToItems(searchValue: string): NavigateToItem[] { @@ -415,7 +415,7 @@ namespace ts.server { } getEmitOutput(_fileName: string): EmitOutput { - throw new Error("Not Implemented Yet."); + return notYetImplemented(); } getSyntacticDiagnostics(fileName: string): Diagnostic[] { @@ -457,7 +457,7 @@ namespace ts.server { } getCompilerOptionsDiagnostics(): Diagnostic[] { - throw new Error("Not Implemented Yet."); + return notYetImplemented(); } getRenameInfo(fileName: string, position: number, findInStrings?: boolean, findInComments?: boolean): RenameInfo { @@ -562,11 +562,11 @@ namespace ts.server { } getNameOrDottedNameSpan(_fileName: string, _startPos: number, _endPos: number): TextSpan { - throw new Error("Not Implemented Yet."); + return notYetImplemented(); } getBreakpointStatementAtPosition(_fileName: string, _position: number): TextSpan { - throw new Error("Not Implemented Yet."); + return notYetImplemented(); } getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems { @@ -656,19 +656,19 @@ namespace ts.server { } getOutliningSpans(_fileName: string): OutliningSpan[] { - throw new Error("Not Implemented Yet."); + return notYetImplemented(); } getTodoComments(_fileName: string, _descriptors: TodoCommentDescriptor[]): TodoComment[] { - throw new Error("Not Implemented Yet."); + return notYetImplemented(); } getDocCommentTemplateAtPosition(_fileName: string, _position: number): TextInsertion { - throw new Error("Not Implemented Yet."); + return notYetImplemented(); } isValidBraceCompletionAtPosition(_fileName: string, _position: number, _openingBrace: number): boolean { - throw new Error("Not Implemented Yet."); + return notYetImplemented(); } getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[]): CodeAction[] { @@ -735,23 +735,23 @@ namespace ts.server { } getIndentationAtPosition(_fileName: string, _position: number, _options: EditorOptions): number { - throw new Error("Not Implemented Yet."); + return notYetImplemented(); } getSyntacticClassifications(_fileName: string, _span: TextSpan): ClassifiedSpan[] { - throw new Error("Not Implemented Yet."); + return notYetImplemented(); } getSemanticClassifications(_fileName: string, _span: TextSpan): ClassifiedSpan[] { - throw new Error("Not Implemented Yet."); + return notYetImplemented(); } getEncodedSyntacticClassifications(_fileName: string, _span: TextSpan): Classifications { - throw new Error("Not Implemented Yet."); + return notYetImplemented(); } getEncodedSemanticClassifications(_fileName: string, _span: TextSpan): Classifications { - throw new Error("Not Implemented Yet."); + return notYetImplemented(); } getProgram(): Program { diff --git a/src/server/typingsCache.ts b/src/server/typingsCache.ts index d522974cc5b..04c321b46f9 100644 --- a/src/server/typingsCache.ts +++ b/src/server/typingsCache.ts @@ -9,9 +9,9 @@ namespace ts.server { } export const nullTypingsInstaller: ITypingsInstaller = { - enqueueInstallTypingsRequest: () => {}, - attach: () => {}, - onProjectClosed: () => {}, + enqueueInstallTypingsRequest: noop, + attach: noop, + onProjectClosed: noop, globalTypingsCacheLocation: undefined }; diff --git a/src/server/typingsInstaller/typingsInstaller.ts b/src/server/typingsInstaller/typingsInstaller.ts index 58d56195068..2851da3a64d 100644 --- a/src/server/typingsInstaller/typingsInstaller.ts +++ b/src/server/typingsInstaller/typingsInstaller.ts @@ -15,7 +15,7 @@ namespace ts.server.typingsInstaller { const nullLog: Log = { isEnabled: () => false, - writeLine: () => {} + writeLine: noop }; function typingToFileName(cachePath: string, packageName: string, installTypingHost: InstallTypingHost): string { diff --git a/src/services/services.ts b/src/services/services.ts index 9ed73318d8e..06e8a4615f9 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1051,7 +1051,7 @@ namespace ts { useCaseSensitiveFileNames: () => useCaseSensitivefileNames, getNewLine: () => getNewLineOrDefaultFromHost(host), getDefaultLibFileName: (options) => host.getDefaultLibFileName(options), - writeFile: () => { }, + writeFile: noop, getCurrentDirectory: () => currentDirectory, fileExists: (fileName): boolean => { // stub missing host functionality diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 45dff60dd89..8fd5f510be0 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -1142,8 +1142,8 @@ namespace ts { increaseIndent: () => { indent++; }, decreaseIndent: () => { indent--; }, clear: resetWriter, - trackSymbol: () => { }, - reportInaccessibleThisError: () => { } + trackSymbol: noop, + reportInaccessibleThisError: noop }; function writeIndent() { From ca970063a396bd9aacf1670e3032a0cc7c64c5fd Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 20 Oct 2016 07:15:25 -0700 Subject: [PATCH 148/173] Just use notImplemented --- src/compiler/core.ts | 7 +---- src/harness/harness.ts | 2 +- src/harness/harnessLanguageService.ts | 8 +++--- .../unittests/cachingInServerLSHost.ts | 6 ++-- .../unittests/reuseProgramStructure.ts | 2 +- .../unittests/tsserverProjectSystem.ts | 4 +-- src/server/client.ts | 28 +++++++++---------- 7 files changed, 26 insertions(+), 31 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index cb469255d0a..395ddb40574 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -872,16 +872,11 @@ namespace ts { /** Does nothing. */ export function noop(): void {} - /** A function not intended to be implemented. */ + /** Throws an error because a function is not implemented. */ export function notImplemented(): never { throw new Error("Not implemented"); } - /** A function which isn't implemented, but should be eventually. */ - export function notYetImplemented(): never { - throw new Error("TODO: Not yet implemented"); - } - export function memoize(callback: () => T): () => T { let value: T; return () => { diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 32681421d24..409ab9e2fcc 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1668,7 +1668,7 @@ namespace Harness { // This does not need to exist strictly speaking, but many tests will need to be updated if it's removed export function compileString(_code: string, _unitName: string, _callback: (result: CompilerResult) => void) { // NEWTODO: Re-implement 'compileString' - return ts.notYetImplemented(); + return ts.notImplemented(); } export interface GeneratedFile { diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index a2e1f52f7ea..889d4f28ce9 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -313,7 +313,7 @@ namespace Harness.LanguageService { getLocalizedDiagnosticMessages(): string { return JSON.stringify({}); } readDirectory(_rootDir: string, _extension: string): string { - return ts.notYetImplemented(); + return ts.notImplemented(); } readDirectoryNames = ts.notImplemented; readFileNames = ts.notImplemented; @@ -335,7 +335,7 @@ namespace Harness.LanguageService { constructor(private shim: ts.ClassifierShim) { } getEncodedLexicalClassifications(_text: string, _lexState: ts.EndOfLineState, _classifyKeywordsInGenerics?: boolean): ts.Classifications { - return ts.notYetImplemented(); + return ts.notImplemented(); } getClassificationsForLine(text: string, lexState: ts.EndOfLineState, classifyKeywordsInGenerics?: boolean): ts.ClassificationResult { const result = this.shim.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics).split("\n"); @@ -644,7 +644,7 @@ namespace Harness.LanguageService { } createDirectory(_directoryName: string): void { - return ts.notYetImplemented(); + return ts.notImplemented(); } getCurrentDirectory(): string { @@ -660,7 +660,7 @@ namespace Harness.LanguageService { } readDirectory(_path: string, _extension?: string[], _exclude?: string[], _include?: string[]): string[] { - return ts.notYetImplemented(); + return ts.notImplemented(); } watchFile(): ts.FileWatcher { diff --git a/src/harness/unittests/cachingInServerLSHost.ts b/src/harness/unittests/cachingInServerLSHost.ts index f930ab393d3..953edd98b6a 100644 --- a/src/harness/unittests/cachingInServerLSHost.ts +++ b/src/harness/unittests/cachingInServerLSHost.ts @@ -26,10 +26,10 @@ namespace ts { return path in fileMap ? fileMap[path].content : undefined; }, writeFile: (_path: string, _data: string, _writeByteOrderMark?: boolean) => { - return ts.notYetImplemented(); + return ts.notImplemented(); }, resolvePath: (_path: string): string => { - return ts.notYetImplemented(); + return ts.notImplemented(); }, fileExists: (path: string): boolean => { return path in fileMap; @@ -47,7 +47,7 @@ namespace ts { getDirectories: () => [], getEnvironmentVariable: () => "", readDirectory: (_path: string, _extension?: string[], _exclude?: string[], _include?: string[]): string[] => { - return ts.notYetImplemented(); + return ts.notImplemented(); }, exit: noop, watchFile: () => ({ diff --git a/src/harness/unittests/reuseProgramStructure.ts b/src/harness/unittests/reuseProgramStructure.ts index 29bb9a05b7c..0d3a8b3977a 100644 --- a/src/harness/unittests/reuseProgramStructure.ts +++ b/src/harness/unittests/reuseProgramStructure.ts @@ -111,7 +111,7 @@ namespace ts { getDefaultLibFileName(): string { return "lib.d.ts"; }, - writeFile: notYetImplemented, + writeFile: notImplemented, getCurrentDirectory(): string { return ""; }, diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index ff92f556eab..2abfd66b983 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -521,8 +521,8 @@ namespace ts.projectSystem { readonly resolvePath = (s: string) => s; readonly getExecutingFilePath = () => this.executingFilePath; readonly getCurrentDirectory = () => this.currentDirectory; - readonly exit = notYetImplemented; - readonly getEnvironmentVariable = notYetImplemented; + readonly exit = notImplemented; + readonly getEnvironmentVariable = notImplemented; } export function makeSessionRequest(command: string, args: T) { diff --git a/src/server/client.ts b/src/server/client.ts index baa47ac6381..3b09a926754 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -242,7 +242,7 @@ namespace ts.server { } getCompletionEntrySymbol(_fileName: string, _position: number, _entryName: string): Symbol { - return notYetImplemented(); + return notImplemented(); } getNavigateToItems(searchValue: string): NavigateToItem[] { @@ -415,7 +415,7 @@ namespace ts.server { } getEmitOutput(_fileName: string): EmitOutput { - return notYetImplemented(); + return notImplemented(); } getSyntacticDiagnostics(fileName: string): Diagnostic[] { @@ -457,7 +457,7 @@ namespace ts.server { } getCompilerOptionsDiagnostics(): Diagnostic[] { - return notYetImplemented(); + return notImplemented(); } getRenameInfo(fileName: string, position: number, findInStrings?: boolean, findInComments?: boolean): RenameInfo { @@ -562,11 +562,11 @@ namespace ts.server { } getNameOrDottedNameSpan(_fileName: string, _startPos: number, _endPos: number): TextSpan { - return notYetImplemented(); + return notImplemented(); } getBreakpointStatementAtPosition(_fileName: string, _position: number): TextSpan { - return notYetImplemented(); + return notImplemented(); } getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems { @@ -656,19 +656,19 @@ namespace ts.server { } getOutliningSpans(_fileName: string): OutliningSpan[] { - return notYetImplemented(); + return notImplemented(); } getTodoComments(_fileName: string, _descriptors: TodoCommentDescriptor[]): TodoComment[] { - return notYetImplemented(); + return notImplemented(); } getDocCommentTemplateAtPosition(_fileName: string, _position: number): TextInsertion { - return notYetImplemented(); + return notImplemented(); } isValidBraceCompletionAtPosition(_fileName: string, _position: number, _openingBrace: number): boolean { - return notYetImplemented(); + return notImplemented(); } getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[]): CodeAction[] { @@ -735,23 +735,23 @@ namespace ts.server { } getIndentationAtPosition(_fileName: string, _position: number, _options: EditorOptions): number { - return notYetImplemented(); + return notImplemented(); } getSyntacticClassifications(_fileName: string, _span: TextSpan): ClassifiedSpan[] { - return notYetImplemented(); + return notImplemented(); } getSemanticClassifications(_fileName: string, _span: TextSpan): ClassifiedSpan[] { - return notYetImplemented(); + return notImplemented(); } getEncodedSyntacticClassifications(_fileName: string, _span: TextSpan): Classifications { - return notYetImplemented(); + return notImplemented(); } getEncodedSemanticClassifications(_fileName: string, _span: TextSpan): Classifications { - return notYetImplemented(); + return notImplemented(); } getProgram(): Program { From df2f32bf0509ad60a9274e1612604f272c584b7f Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 20 Oct 2016 11:15:44 -0700 Subject: [PATCH 149/173] Properly distinguish between Type, ObjectType, and StructuredType --- src/compiler/checker.ts | 66 ++++++++++++++++++++--------------------- src/compiler/types.ts | 3 ++ 2 files changed, 36 insertions(+), 33 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 369d61ce484..c260b86e114 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -323,9 +323,9 @@ namespace ts { "undefined": undefinedType }); - let jsxElementType: ObjectType; + let jsxElementType: Type; /** Things we lazy load from the JSX namespace */ - const jsxTypes = createMap(); + const jsxTypes = createMap(); const JsxNames = { JSX: "JSX", IntrinsicElements: "IntrinsicElements", @@ -1620,7 +1620,7 @@ namespace ts { return result || emptyArray; } - function setObjectTypeMembers(type: ObjectType, members: SymbolTable, callSignatures: Signature[], constructSignatures: Signature[], stringIndexInfo: IndexInfo, numberIndexInfo: IndexInfo): ResolvedType { + function setStructuredTypeMembers(type: StructuredType, members: SymbolTable, callSignatures: Signature[], constructSignatures: Signature[], stringIndexInfo: IndexInfo, numberIndexInfo: IndexInfo): ResolvedType { (type).members = members; (type).properties = getNamedMembers(members); (type).callSignatures = callSignatures; @@ -1631,7 +1631,7 @@ namespace ts { } function createAnonymousType(symbol: Symbol, members: SymbolTable, callSignatures: Signature[], constructSignatures: Signature[], stringIndexInfo: IndexInfo, numberIndexInfo: IndexInfo): ResolvedType { - return setObjectTypeMembers(createObjectType(TypeFlags.Anonymous, symbol), + return setStructuredTypeMembers(createObjectType(TypeFlags.Anonymous, symbol), members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } @@ -3519,7 +3519,7 @@ namespace ts { return unknownType; } - function getTargetType(type: ObjectType): Type { + function getTargetType(type: Type): Type { return type.flags & TypeFlags.Reference ? (type).target : type; } @@ -3603,13 +3603,13 @@ namespace ts { return getClassExtendsHeritageClauseElement(type.symbol.valueDeclaration); } - function getConstructorsForTypeArguments(type: ObjectType, typeArgumentNodes: TypeNode[]): Signature[] { + function getConstructorsForTypeArguments(type: Type, typeArgumentNodes: TypeNode[]): Signature[] { const typeArgCount = typeArgumentNodes ? typeArgumentNodes.length : 0; return filter(getSignaturesOfType(type, SignatureKind.Construct), sig => (sig.typeParameters ? sig.typeParameters.length : 0) === typeArgCount); } - function getInstantiatedConstructorsForTypeArguments(type: ObjectType, typeArgumentNodes: TypeNode[]): Signature[] { + function getInstantiatedConstructorsForTypeArguments(type: Type, typeArgumentNodes: TypeNode[]): Signature[] { let signatures = getConstructorsForTypeArguments(type, typeArgumentNodes); if (typeArgumentNodes) { const typeArguments = map(typeArgumentNodes, getTypeFromTypeNodeNoAlias); @@ -3623,7 +3623,7 @@ namespace ts { // unknownType if an error occurred during resolution of the extends expression, // nullType if the extends expression is the null value, or // an object type with at least one construct signature. - function getBaseConstructorTypeOfClass(type: InterfaceType): ObjectType { + function getBaseConstructorTypeOfClass(type: InterfaceType): Type { if (!type.resolvedBaseConstructorType) { const baseTypeNode = getBaseTypeNodeOfClass(type); if (!baseTypeNode) { @@ -3636,7 +3636,7 @@ namespace ts { if (baseConstructorType.flags & TypeFlags.ObjectType) { // Resolving the members of a class requires us to resolve the base class of that class. // We force resolution here such that we catch circularities now. - resolveStructuredTypeMembers(baseConstructorType); + resolveStructuredTypeMembers(baseConstructorType); } if (!popTypeResolution()) { error(type.symbol.valueDeclaration, Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); @@ -3673,7 +3673,7 @@ namespace ts { function resolveBaseTypesOfClass(type: InterfaceType): void { type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; - const baseConstructorType = getBaseConstructorTypeOfClass(type); + const baseConstructorType = getBaseConstructorTypeOfClass(type); if (!(baseConstructorType.flags & TypeFlags.ObjectType)) { return; } @@ -3711,10 +3711,10 @@ namespace ts { return; } if (type.resolvedBaseTypes === emptyArray) { - type.resolvedBaseTypes = [baseType]; + type.resolvedBaseTypes = [baseType]; } else { - type.resolvedBaseTypes.push(baseType); + type.resolvedBaseTypes.push(baseType); } } @@ -3740,10 +3740,10 @@ namespace ts { if (getTargetType(baseType).flags & (TypeFlags.Class | TypeFlags.Interface)) { if (type !== baseType && !hasBaseType(baseType, type)) { if (type.resolvedBaseTypes === emptyArray) { - type.resolvedBaseTypes = [baseType]; + type.resolvedBaseTypes = [baseType]; } else { - type.resolvedBaseTypes.push(baseType); + type.resolvedBaseTypes.push(baseType); } } else { @@ -4093,7 +4093,7 @@ namespace ts { return type; } - function getTypeWithThisArgument(type: ObjectType, thisArgument?: Type) { + function getTypeWithThisArgument(type: Type, thisArgument?: Type) { if (type.flags & TypeFlags.Reference) { return createTypeReference((type).target, concatenate((type).typeArguments, [thisArgument || (type).target.thisType])); @@ -4131,7 +4131,7 @@ namespace ts { } const thisArgument = lastOrUndefined(typeArguments); for (const baseType of baseTypes) { - const instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; + const instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); callSignatures = concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, SignatureKind.Call)); constructSignatures = concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, SignatureKind.Construct)); @@ -4139,7 +4139,7 @@ namespace ts { numberIndexInfo = numberIndexInfo || getIndexInfoOfType(instantiatedBaseType, IndexKind.Number); } } - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); + setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } function resolveClassOrInterfaceMembers(type: InterfaceType): void { @@ -4286,7 +4286,7 @@ namespace ts { const constructSignatures = getUnionSignatures(type.types, SignatureKind.Construct); const stringIndexInfo = getUnionIndexInfo(type.types, IndexKind.String); const numberIndexInfo = getUnionIndexInfo(type.types, IndexKind.Number); - setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); + setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } function intersectTypes(type1: Type, type2: Type): Type { @@ -4311,7 +4311,7 @@ namespace ts { stringIndexInfo = intersectIndexInfos(stringIndexInfo, getIndexInfoOfType(t, IndexKind.String)); numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, IndexKind.Number)); } - setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); + setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } function resolveAnonymousTypeMembers(type: AnonymousType) { @@ -4322,7 +4322,7 @@ namespace ts { const constructSignatures = instantiateList(getSignaturesOfType(type.target, SignatureKind.Construct), type.mapper, instantiateSignature); const stringIndexInfo = instantiateIndexInfo(getIndexInfoOfType(type.target, IndexKind.String), type.mapper); const numberIndexInfo = instantiateIndexInfo(getIndexInfoOfType(type.target, IndexKind.Number), type.mapper); - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); + setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } else if (symbol.flags & SymbolFlags.TypeLiteral) { const members = symbol.members; @@ -4330,7 +4330,7 @@ namespace ts { const constructSignatures = getSignaturesOfSymbol(members["__new"]); const stringIndexInfo = getIndexInfoOfSymbol(symbol, IndexKind.String); const numberIndexInfo = getIndexInfoOfSymbol(symbol, IndexKind.Number); - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); + setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } else { // Combinations of function, class, enum and module @@ -4352,7 +4352,7 @@ namespace ts { } } const numberIndexInfo = symbol.flags & SymbolFlags.Enum ? enumNumberIndexInfo : undefined; - setObjectTypeMembers(type, members, emptyArray, constructSignatures, undefined, numberIndexInfo); + setStructuredTypeMembers(type, members, emptyArray, constructSignatures, undefined, numberIndexInfo); // We resolve the members before computing the signatures because a signature may use // typeof with a qualified name expression that circularly references the type we are // in the process of resolving (see issue #6072). The temporarily empty signature list @@ -4363,7 +4363,7 @@ namespace ts { } } - function resolveStructuredTypeMembers(type: ObjectType): ResolvedType { + function resolveStructuredTypeMembers(type: StructuredType): ResolvedType { if (!(type).members) { if (type.flags & TypeFlags.Reference) { resolveTypeReferenceMembers(type); @@ -4569,7 +4569,7 @@ namespace ts { function getPropertyOfType(type: Type, name: string): Symbol { type = getApparentType(type); if (type.flags & TypeFlags.ObjectType) { - const resolved = resolveStructuredTypeMembers(type); + const resolved = resolveStructuredTypeMembers(type); const symbol = resolved.members[name]; if (symbol && symbolIsValue(symbol)) { return symbol; @@ -5316,7 +5316,7 @@ namespace ts { /** * Instantiates a global type that is generic with some element type, and returns that instantiation. */ - function createTypeFromGenericGlobalType(genericGlobalType: GenericType, typeArguments: Type[]): Type { + function createTypeFromGenericGlobalType(genericGlobalType: GenericType, typeArguments: Type[]): ObjectType { return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, typeArguments) : emptyObjectType; } @@ -5328,7 +5328,7 @@ namespace ts { return createTypeFromGenericGlobalType(getGlobalIterableIteratorType(), [elementType]); } - function createArrayType(elementType: Type): Type { + function createArrayType(elementType: Type): ObjectType { return createTypeFromGenericGlobalType(globalArrayType, [elementType]); } @@ -5568,7 +5568,7 @@ namespace ts { let type = unionTypes[id]; if (!type) { const propagatedFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ TypeFlags.Nullable); - type = unionTypes[id] = createObjectType(TypeFlags.Union | propagatedFlags); + type = unionTypes[id] = createType(TypeFlags.Union | propagatedFlags); type.types = types; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; @@ -5639,7 +5639,7 @@ namespace ts { let type = intersectionTypes[id]; if (!type) { const propagatedFlags = getPropagatingFlagsOfTypes(typeSet, /*excludeKinds*/ TypeFlags.Nullable); - type = intersectionTypes[id] = createObjectType(TypeFlags.Intersection | propagatedFlags); + type = intersectionTypes[id] = createType(TypeFlags.Intersection | propagatedFlags); type.types = typeSet; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; @@ -5980,7 +5980,7 @@ namespace ts { function instantiateAnonymousType(type: AnonymousType, mapper: TypeMapper): ObjectType { if (mapper.instantiations) { - const cachedType = mapper.instantiations[type.id]; + const cachedType = mapper.instantiations[type.id]; if (cachedType) { return cachedType; } @@ -6479,8 +6479,8 @@ namespace ts { containingMessageChain?: DiagnosticMessageChain): boolean { let errorInfo: DiagnosticMessageChain; - let sourceStack: ObjectType[]; - let targetStack: ObjectType[]; + let sourceStack: Type[]; + let targetStack: Type[]; let maybeStack: Map[]; let expandingFlags: number; let depth = 0; @@ -6697,7 +6697,7 @@ namespace ts { // type, a property is considered known if it is known in any constituent type. function isKnownProperty(type: Type, name: string): boolean { if (type.flags & TypeFlags.ObjectType) { - const resolved = resolveStructuredTypeMembers(type); + const resolved = resolveStructuredTypeMembers(type); if ((relation === assignableRelation || relation === comparableRelation) && (type === globalObjectType || isEmptyObjectType(resolved)) || resolved.stringIndexInfo || (resolved.numberIndexInfo && isNumericLiteralName(name)) || @@ -17182,7 +17182,7 @@ namespace ts { } } - function checkBaseTypeAccessibility(type: ObjectType, node: ExpressionWithTypeArguments) { + function checkBaseTypeAccessibility(type: Type, node: ExpressionWithTypeArguments) { const signatures = getSignaturesOfType(type, SignatureKind.Construct); if (signatures.length) { const declaration = signatures[0].declaration; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index dd1878f36a7..540d6e8c406 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2699,6 +2699,7 @@ namespace ts { // Object types (TypeFlags.ObjectType) export interface ObjectType extends Type { + _objectTypeBrand: any; isObjectLiteralPatternWithComputedProperties?: boolean; } @@ -2753,6 +2754,8 @@ namespace ts { export interface IntersectionType extends UnionOrIntersectionType { } + export type StructuredType = ObjectType | UnionType | IntersectionType; + /* @internal */ // An instantiated anonymous type has a target and a mapper export interface AnonymousType extends ObjectType { From 3f234f2e7f170b80e9b6eef515b2efa05342ffa3 Mon Sep 17 00:00:00 2001 From: Zhengbo Li Date: Thu, 20 Oct 2016 11:30:05 -0700 Subject: [PATCH 150/173] Move setTimeout to sys (#11746) --- src/compiler/sys.ts | 6 +++++- src/compiler/tsc.ts | 24 ++++++++++++++++-------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 585fb60df32..13bbfc2ab15 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -34,6 +34,8 @@ namespace ts { realpath?(path: string): string; /*@internal*/ getEnvironmentVariable(name: string): string; /*@internal*/ tryEnableSourceMapsForHost?(): void; + setTimeout?(callback: (...args: any[]) => void, ms: number, ...args: any[]): any; + clearTimeout?(timeoutId: any): void; } export interface FileWatcher { @@ -560,7 +562,9 @@ namespace ts { catch (e) { // Could not enable source maps. } - } + }, + setTimeout, + clearTimeout }; return nodeSystem; } diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index aa277c9b507..10d4a0c1d36 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -250,8 +250,8 @@ namespace ts { let compilerOptions: CompilerOptions; // Compiler options for compilation let compilerHost: CompilerHost; // Compiler host let hostGetSourceFile: typeof compilerHost.getSourceFile; // getSourceFile method from default host - let timerHandleForRecompilation: number; // Handle for 0.25s wait timer to trigger recompilation - let timerHandleForDirectoryChanges: number; // Handle for 0.25s wait timer to trigger directory change handler + let timerHandleForRecompilation: any; // Handle for 0.25s wait timer to trigger recompilation + let timerHandleForDirectoryChanges: any; // Handle for 0.25s wait timer to trigger directory change handler // This map stores and reuses results of fileExists check that happen inside 'createProgram' // This allows to save time in module resolution heavy scenarios when existence of the same file might be checked multiple times. @@ -503,10 +503,14 @@ namespace ts { } function startTimerForHandlingDirectoryChanges() { - if (timerHandleForDirectoryChanges) { - clearTimeout(timerHandleForDirectoryChanges); + if (!sys.setTimeout || !sys.clearTimeout) { + return; } - timerHandleForDirectoryChanges = setTimeout(directoryChangeHandler, 250); + + if (timerHandleForDirectoryChanges) { + sys.clearTimeout(timerHandleForDirectoryChanges); + } + timerHandleForDirectoryChanges = sys.setTimeout(directoryChangeHandler, 250); } function directoryChangeHandler() { @@ -525,10 +529,14 @@ namespace ts { // operations (such as saving all modified files in an editor) a chance to complete before we kick // off a new compilation. function startTimerForRecompilation() { - if (timerHandleForRecompilation) { - clearTimeout(timerHandleForRecompilation); + if (!sys.setTimeout || !sys.clearTimeout) { + return; } - timerHandleForRecompilation = setTimeout(recompile, 250); + + if (timerHandleForRecompilation) { + sys.clearTimeout(timerHandleForRecompilation); + } + timerHandleForRecompilation = sys.setTimeout(recompile, 250); } function recompile() { From fab085986983f18d8823278474a706cadeb8030d Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 15 Sep 2016 09:51:32 -0700 Subject: [PATCH 151/173] Allow destructuring in catch clauses --- src/compiler/binder.ts | 16 ++++- src/compiler/checker.ts | 20 +++--- src/compiler/diagnosticMessages.json | 4 -- src/compiler/transformers/es2015.ts | 21 ++++++ src/compiler/utilities.ts | 14 ++-- .../catchClauseWithBindingPattern1.errors.txt | 10 --- .../catchClauseWithBindingPattern1.js | 11 ---- .../baselines/reference/destructuringCatch.js | 59 +++++++++++++++++ .../reference/destructuringCatch.symbols | 51 +++++++++++++++ .../reference/destructuringCatch.types | 65 +++++++++++++++++++ .../redeclareParameterInCatchBlock.errors.txt | 24 ++++++- .../redeclareParameterInCatchBlock.js | 22 ++++++- .../catchClauseWithBindingPattern1.ts | 4 -- .../redeclareParameterInCatchBlock.ts | 13 +++- .../es6/destructuring/destructuringCatch.ts | 29 +++++++++ 15 files changed, 310 insertions(+), 53 deletions(-) delete mode 100644 tests/baselines/reference/catchClauseWithBindingPattern1.errors.txt delete mode 100644 tests/baselines/reference/catchClauseWithBindingPattern1.js create mode 100644 tests/baselines/reference/destructuringCatch.js create mode 100644 tests/baselines/reference/destructuringCatch.symbols create mode 100644 tests/baselines/reference/destructuringCatch.types delete mode 100644 tests/cases/compiler/catchClauseWithBindingPattern1.ts create mode 100644 tests/cases/conformance/es6/destructuring/destructuringCatch.ts diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index a256b632fac..447a7625d38 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -1007,7 +1007,7 @@ namespace ts { currentFlow = finishFlowLabel(preFinallyLabel); bind(node.finallyBlock); // if flow after finally is unreachable - keep it - // otherwise check if flows after try and after catch are unreachable + // otherwise check if flows after try and after catch are unreachable // if yes - convert current flow to unreachable // i.e. // try { return "1" } finally { console.log(1); } @@ -2421,6 +2421,9 @@ namespace ts { case SyntaxKind.HeritageClause: return computeHeritageClause(node, subtreeFlags); + case SyntaxKind.CatchClause: + return computeCatchClause(node, subtreeFlags); + case SyntaxKind.ExpressionWithTypeArguments: return computeExpressionWithTypeArguments(node, subtreeFlags); @@ -2650,6 +2653,17 @@ namespace ts { return transformFlags & ~TransformFlags.NodeExcludes; } + function computeCatchClause(node: CatchClause, subtreeFlags: TransformFlags) { + let transformFlags = subtreeFlags; + + if (node.variableDeclaration && isBindingPattern(node.variableDeclaration.name)) { + transformFlags |= TransformFlags.AssertES2015; + } + + node.transformFlags = transformFlags | TransformFlags.HasComputedFlags; + return transformFlags & ~TransformFlags.NodeExcludes; + } + function computeExpressionWithTypeArguments(node: ExpressionWithTypeArguments, subtreeFlags: TransformFlags) { // An ExpressionWithTypeArguments is ES6 syntax, as it is used in the // extends clause of a class. diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 369d61ce484..67a306b4fce 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3304,7 +3304,7 @@ namespace ts { } // Handle catch clause variables const declaration = symbol.valueDeclaration; - if (declaration.parent.kind === SyntaxKind.CatchClause) { + if (isCatchClauseVariableDeclarationOrBindingElement(declaration)) { return links.type = anyType; } // Handle export default expressions @@ -16906,22 +16906,20 @@ namespace ts { if (catchClause) { // Grammar checking if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== SyntaxKind.Identifier) { - grammarErrorOnFirstToken(catchClause.variableDeclaration.name, Diagnostics.Catch_clause_variable_name_must_be_an_identifier); - } - else if (catchClause.variableDeclaration.type) { + if (catchClause.variableDeclaration.type) { grammarErrorOnFirstToken(catchClause.variableDeclaration.type, Diagnostics.Catch_clause_variable_cannot_have_a_type_annotation); } else if (catchClause.variableDeclaration.initializer) { grammarErrorOnFirstToken(catchClause.variableDeclaration.initializer, Diagnostics.Catch_clause_variable_cannot_have_an_initializer); } else { - const identifierName = (catchClause.variableDeclaration.name).text; - const locals = catchClause.block.locals; - if (locals) { - const localSymbol = locals[identifierName]; - if (localSymbol && (localSymbol.flags & SymbolFlags.BlockScopedVariable) !== 0) { - grammarErrorOnNode(localSymbol.valueDeclaration, Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, identifierName); + const blockLocals = catchClause.block.locals; + if (blockLocals) { + for (const caughtName in catchClause.locals) { + const blockLocal = blockLocals[caughtName]; + if (blockLocal && (blockLocal.flags & SymbolFlags.BlockScopedVariable) !== 0) { + grammarErrorOnNode(blockLocal.valueDeclaration, Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName); + } } } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 21f04da488d..bb6c62d83e2 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -603,10 +603,6 @@ "category": "Error", "code": 1194 }, - "Catch clause variable name must be an identifier.": { - "category": "Error", - "code": 1195 - }, "Catch clause variable cannot have a type annotation.": { "category": "Error", "code": 1196 diff --git a/src/compiler/transformers/es2015.ts b/src/compiler/transformers/es2015.ts index 9972f339c16..b48539e8722 100644 --- a/src/compiler/transformers/es2015.ts +++ b/src/compiler/transformers/es2015.ts @@ -362,6 +362,9 @@ namespace ts { case SyntaxKind.ObjectLiteralExpression: return visitObjectLiteralExpression(node); + case SyntaxKind.CatchClause: + return visitCatchClause(node); + case SyntaxKind.ShorthandPropertyAssignment: return visitShorthandPropertyAssignment(node); @@ -2622,6 +2625,24 @@ namespace ts { return expression; } + function visitCatchClause(node: CatchClause): CatchClause { + Debug.assert(isBindingPattern(node.variableDeclaration.name)); + + const temp = createTempVariable(undefined); + const newVariableDeclaration = createVariableDeclaration(temp, undefined, undefined, node.variableDeclaration); + + const vars = flattenVariableDestructuring(node.variableDeclaration, temp, visitor); + const list = createVariableDeclarationList(vars, /*location*/node.variableDeclaration, /*flags*/node.variableDeclaration.flags); + const destructure = createVariableStatement(undefined, list); + + return updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure)); + } + + function addStatementToStartOfBlock(block: Block, statement: Statement): Block { + const transformedStatements = visitNodes(block.statements, visitor, isStatement); + return updateBlock(block, [statement].concat(transformedStatements)); + } + /** * Visits a MethodDeclaration of an ObjectLiteralExpression and transforms it into a * PropertyAssignment. diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 87f6cd5e4aa..3a8d09f113d 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -406,7 +406,12 @@ namespace ts { export function isBlockOrCatchScoped(declaration: Declaration) { return (getCombinedNodeFlags(declaration) & NodeFlags.BlockScoped) !== 0 || - isCatchClauseVariableDeclaration(declaration); + isCatchClauseVariableDeclarationOrBindingElement(declaration); + } + + export function isCatchClauseVariableDeclarationOrBindingElement(declaration: Declaration) { + const node = getRootDeclaration(declaration); + return node.kind === SyntaxKind.VariableDeclaration && node.parent.kind === SyntaxKind.CatchClause; } export function isAmbientModule(node: Node): boolean { @@ -489,13 +494,6 @@ namespace ts { } } - export function isCatchClauseVariableDeclaration(declaration: Declaration) { - return declaration && - declaration.kind === SyntaxKind.VariableDeclaration && - declaration.parent && - declaration.parent.kind === SyntaxKind.CatchClause; - } - // Return display name of an identifier // Computed property names will just be emitted as "[]", where is the source // text of the expression in the computed property. diff --git a/tests/baselines/reference/catchClauseWithBindingPattern1.errors.txt b/tests/baselines/reference/catchClauseWithBindingPattern1.errors.txt deleted file mode 100644 index 0b7482850e5..00000000000 --- a/tests/baselines/reference/catchClauseWithBindingPattern1.errors.txt +++ /dev/null @@ -1,10 +0,0 @@ -tests/cases/compiler/catchClauseWithBindingPattern1.ts(3,8): error TS1195: Catch clause variable name must be an identifier. - - -==== tests/cases/compiler/catchClauseWithBindingPattern1.ts (1 errors) ==== - try { - } - catch ({a}) { - ~ -!!! error TS1195: Catch clause variable name must be an identifier. - } \ No newline at end of file diff --git a/tests/baselines/reference/catchClauseWithBindingPattern1.js b/tests/baselines/reference/catchClauseWithBindingPattern1.js deleted file mode 100644 index bbdc259946c..00000000000 --- a/tests/baselines/reference/catchClauseWithBindingPattern1.js +++ /dev/null @@ -1,11 +0,0 @@ -//// [catchClauseWithBindingPattern1.ts] -try { -} -catch ({a}) { -} - -//// [catchClauseWithBindingPattern1.js] -try { -} -catch (a = (void 0).a) { -} diff --git a/tests/baselines/reference/destructuringCatch.js b/tests/baselines/reference/destructuringCatch.js new file mode 100644 index 00000000000..4593b22f127 --- /dev/null +++ b/tests/baselines/reference/destructuringCatch.js @@ -0,0 +1,59 @@ +//// [destructuringCatch.ts] + +try { + throw [0, 1]; +} +catch ([a, b]) { + a + b; +} + +try { + throw { a: 0, b: 1 }; +} +catch ({a, b}) { + a + b; +} + +try { + throw [{ x: [0], z: 1 }]; +} +catch ([{x: [y], z}]) { + y + z; +} + +// Test of comment ranges. A fix to GH#11755 should update this. +try { +} +catch (/*Test comment ranges*/[/*a*/a]) { + +} + + +//// [destructuringCatch.js] +try { + throw [0, 1]; +} +catch (_a) { + var a = _a[0], b = _a[1]; + a + b; +} +try { + throw { a: 0, b: 1 }; +} +catch (_b) { + var a = _b.a, b = _b.b; + a + b; +} +try { + throw [{ x: [0], z: 1 }]; +} +catch (_c) { + var _d = _c[0], y = _d.x[0], z = _d.z; + y + z; +} +// Test of comment ranges. A fix to GH#11755 should update this. +try { +} +catch (_e) { + var /*a*/ a = _e[0]; +} diff --git a/tests/baselines/reference/destructuringCatch.symbols b/tests/baselines/reference/destructuringCatch.symbols new file mode 100644 index 00000000000..1d0a954b377 --- /dev/null +++ b/tests/baselines/reference/destructuringCatch.symbols @@ -0,0 +1,51 @@ +=== tests/cases/conformance/es6/destructuring/destructuringCatch.ts === + +try { + throw [0, 1]; +} +catch ([a, b]) { +>a : Symbol(a, Decl(destructuringCatch.ts, 4, 8)) +>b : Symbol(b, Decl(destructuringCatch.ts, 4, 10)) + + a + b; +>a : Symbol(a, Decl(destructuringCatch.ts, 4, 8)) +>b : Symbol(b, Decl(destructuringCatch.ts, 4, 10)) +} + +try { + throw { a: 0, b: 1 }; +>a : Symbol(a, Decl(destructuringCatch.ts, 9, 11)) +>b : Symbol(b, Decl(destructuringCatch.ts, 9, 17)) +} +catch ({a, b}) { +>a : Symbol(a, Decl(destructuringCatch.ts, 11, 8)) +>b : Symbol(b, Decl(destructuringCatch.ts, 11, 10)) + + a + b; +>a : Symbol(a, Decl(destructuringCatch.ts, 11, 8)) +>b : Symbol(b, Decl(destructuringCatch.ts, 11, 10)) +} + +try { + throw [{ x: [0], z: 1 }]; +>x : Symbol(x, Decl(destructuringCatch.ts, 16, 12)) +>z : Symbol(z, Decl(destructuringCatch.ts, 16, 20)) +} +catch ([{x: [y], z}]) { +>x : Symbol(x) +>y : Symbol(y, Decl(destructuringCatch.ts, 18, 13)) +>z : Symbol(z, Decl(destructuringCatch.ts, 18, 16)) + + y + z; +>y : Symbol(y, Decl(destructuringCatch.ts, 18, 13)) +>z : Symbol(z, Decl(destructuringCatch.ts, 18, 16)) +} + +// Test of comment ranges. A fix to GH#11755 should update this. +try { +} +catch (/*Test comment ranges*/[/*a*/a]) { +>a : Symbol(a, Decl(destructuringCatch.ts, 25, 31)) + +} + diff --git a/tests/baselines/reference/destructuringCatch.types b/tests/baselines/reference/destructuringCatch.types new file mode 100644 index 00000000000..3f057e64e4e --- /dev/null +++ b/tests/baselines/reference/destructuringCatch.types @@ -0,0 +1,65 @@ +=== tests/cases/conformance/es6/destructuring/destructuringCatch.ts === + +try { + throw [0, 1]; +>[0, 1] : number[] +>0 : 0 +>1 : 1 +} +catch ([a, b]) { +>a : any +>b : any + + a + b; +>a + b : any +>a : any +>b : any +} + +try { + throw { a: 0, b: 1 }; +>{ a: 0, b: 1 } : { a: number; b: number; } +>a : number +>0 : 0 +>b : number +>1 : 1 +} +catch ({a, b}) { +>a : any +>b : any + + a + b; +>a + b : any +>a : any +>b : any +} + +try { + throw [{ x: [0], z: 1 }]; +>[{ x: [0], z: 1 }] : { x: number[]; z: number; }[] +>{ x: [0], z: 1 } : { x: number[]; z: number; } +>x : number[] +>[0] : number[] +>0 : 0 +>z : number +>1 : 1 +} +catch ([{x: [y], z}]) { +>x : any +>y : any +>z : any + + y + z; +>y + z : any +>y : any +>z : any +} + +// Test of comment ranges. A fix to GH#11755 should update this. +try { +} +catch (/*Test comment ranges*/[/*a*/a]) { +>a : any + +} + diff --git a/tests/baselines/reference/redeclareParameterInCatchBlock.errors.txt b/tests/baselines/reference/redeclareParameterInCatchBlock.errors.txt index bd307bb89ae..9fd4c63f02f 100644 --- a/tests/baselines/reference/redeclareParameterInCatchBlock.errors.txt +++ b/tests/baselines/reference/redeclareParameterInCatchBlock.errors.txt @@ -1,8 +1,11 @@ tests/cases/compiler/redeclareParameterInCatchBlock.ts(5,11): error TS2492: Cannot redeclare identifier 'e' in catch clause tests/cases/compiler/redeclareParameterInCatchBlock.ts(11,9): error TS2492: Cannot redeclare identifier 'e' in catch clause +tests/cases/compiler/redeclareParameterInCatchBlock.ts(17,15): error TS2492: Cannot redeclare identifier 'b' in catch clause +tests/cases/compiler/redeclareParameterInCatchBlock.ts(22,15): error TS2451: Cannot redeclare block-scoped variable 'x'. +tests/cases/compiler/redeclareParameterInCatchBlock.ts(22,21): error TS2451: Cannot redeclare block-scoped variable 'x'. -==== tests/cases/compiler/redeclareParameterInCatchBlock.ts (2 errors) ==== +==== tests/cases/compiler/redeclareParameterInCatchBlock.ts (5 errors) ==== try { @@ -22,10 +25,27 @@ tests/cases/compiler/redeclareParameterInCatchBlock.ts(11,9): error TS2492: Cann try { + } catch ([a, b]) { + const [c, b] = [0, 1]; + ~ +!!! error TS2492: Cannot redeclare identifier 'b' in catch clause + } + + try { + + } catch ({ a: x, b: x }) { + ~ +!!! error TS2451: Cannot redeclare block-scoped variable 'x'. + ~ +!!! error TS2451: Cannot redeclare block-scoped variable 'x'. + + } + + try { + } catch(e) { function test() { let e; } } - \ No newline at end of file diff --git a/tests/baselines/reference/redeclareParameterInCatchBlock.js b/tests/baselines/reference/redeclareParameterInCatchBlock.js index 704d56676bf..9fafe0b17be 100644 --- a/tests/baselines/reference/redeclareParameterInCatchBlock.js +++ b/tests/baselines/reference/redeclareParameterInCatchBlock.js @@ -14,12 +14,23 @@ try { try { +} catch ([a, b]) { + const [c, b] = [0, 1]; +} + +try { + +} catch ({ a: x, b: x }) { + +} + +try { + } catch(e) { function test() { let e; } } - //// [redeclareParameterInCatchBlock.js] @@ -35,6 +46,15 @@ catch (e) { } try { } +catch ([a, b]) { + const [c, b] = [0, 1]; +} +try { +} +catch ({ a: x, b: x }) { +} +try { +} catch (e) { function test() { let e; diff --git a/tests/cases/compiler/catchClauseWithBindingPattern1.ts b/tests/cases/compiler/catchClauseWithBindingPattern1.ts deleted file mode 100644 index dbd0f81c576..00000000000 --- a/tests/cases/compiler/catchClauseWithBindingPattern1.ts +++ /dev/null @@ -1,4 +0,0 @@ -try { -} -catch ({a}) { -} \ No newline at end of file diff --git a/tests/cases/compiler/redeclareParameterInCatchBlock.ts b/tests/cases/compiler/redeclareParameterInCatchBlock.ts index 37ca5fc3a9e..7f98d68b29d 100644 --- a/tests/cases/compiler/redeclareParameterInCatchBlock.ts +++ b/tests/cases/compiler/redeclareParameterInCatchBlock.ts @@ -14,9 +14,20 @@ try { try { +} catch ([a, b]) { + const [c, b] = [0, 1]; +} + +try { + +} catch ({ a: x, b: x }) { + +} + +try { + } catch(e) { function test() { let e; } } - diff --git a/tests/cases/conformance/es6/destructuring/destructuringCatch.ts b/tests/cases/conformance/es6/destructuring/destructuringCatch.ts new file mode 100644 index 00000000000..31afd672084 --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/destructuringCatch.ts @@ -0,0 +1,29 @@ +// @noImplicitAny: true + +try { + throw [0, 1]; +} +catch ([a, b]) { + a + b; +} + +try { + throw { a: 0, b: 1 }; +} +catch ({a, b}) { + a + b; +} + +try { + throw [{ x: [0], z: 1 }]; +} +catch ([{x: [y], z}]) { + y + z; +} + +// Test of comment ranges. A fix to GH#11755 should update this. +try { +} +catch (/*Test comment ranges*/[/*a*/a]) { + +} From 8e6467cdb8a4d81ab7c330f6396555831a3b4829 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Tue, 18 Oct 2016 12:24:41 -0700 Subject: [PATCH 152/173] Add testcase for incorrect emit of jsx --- .../reference/jsxEmitWithAttributes.js | 81 +++++++++++ .../reference/jsxEmitWithAttributes.symbols | 119 ++++++++++++++++ .../reference/jsxEmitWithAttributes.types | 134 ++++++++++++++++++ tests/cases/compiler/jsxEmitWithAttributes.ts | 53 +++++++ 4 files changed, 387 insertions(+) create mode 100644 tests/baselines/reference/jsxEmitWithAttributes.js create mode 100644 tests/baselines/reference/jsxEmitWithAttributes.symbols create mode 100644 tests/baselines/reference/jsxEmitWithAttributes.types create mode 100644 tests/cases/compiler/jsxEmitWithAttributes.ts diff --git a/tests/baselines/reference/jsxEmitWithAttributes.js b/tests/baselines/reference/jsxEmitWithAttributes.js new file mode 100644 index 00000000000..cd50a4f3411 --- /dev/null +++ b/tests/baselines/reference/jsxEmitWithAttributes.js @@ -0,0 +1,81 @@ +//// [tests/cases/compiler/jsxEmitWithAttributes.ts] //// + +//// [Element.ts] + +declare namespace JSX { + interface Element { + name: string; + isIntrinsic: boolean; + isCustomElement: boolean; + toString(renderId?: number): string; + bindDOM(renderId?: number): number; + resetComponent(): void; + instantiateComponents(renderId?: number): number; + props: any; + } +} +export namespace Element { + export function isElement(el: any): el is JSX.Element { + return el.markAsChildOfRootElement !== undefined; + } + + export function createElement(args: any[]) { + + return { + } + } +} + +export let createElement = Element.createElement; + +function toCamelCase(text: string): string { + return text[0].toLowerCase() + text.substring(1); +} + +//// [test.tsx] +import { Element} from './Element'; + +let c: { + a?: { + b: string + } +}; + +class A { + view() { + return [ + , + + ]; + } +} + +//// [Element.js] +"use strict"; +var Element; +(function (Element) { + function isElement(el) { + return el.markAsChildOfRootElement !== undefined; + } + Element.isElement = isElement; + function createElement(args) { + return {}; + } + Element.createElement = createElement; +})(Element = exports.Element || (exports.Element = {})); +exports.createElement = Element.createElement; +function toCamelCase(text) { + return text[0].toLowerCase() + text.substring(1); +} +//// [test.js] +"use strict"; +const Element_1 = require("./Element"); +let c; +class A { + view() { + return [ + Element_1.Element.createElement("meta", { content: "helloworld" }), + Element.createElement("meta", { content: c.a.b }) + ]; + } +} diff --git a/tests/baselines/reference/jsxEmitWithAttributes.symbols b/tests/baselines/reference/jsxEmitWithAttributes.symbols new file mode 100644 index 00000000000..16cd35d1ca3 --- /dev/null +++ b/tests/baselines/reference/jsxEmitWithAttributes.symbols @@ -0,0 +1,119 @@ +=== tests/cases/compiler/Element.ts === + +declare namespace JSX { +>JSX : Symbol(JSX, Decl(Element.ts, 0, 0)) + + interface Element { +>Element : Symbol(Element, Decl(Element.ts, 1, 23)) + + name: string; +>name : Symbol(Element.name, Decl(Element.ts, 2, 23)) + + isIntrinsic: boolean; +>isIntrinsic : Symbol(Element.isIntrinsic, Decl(Element.ts, 3, 21)) + + isCustomElement: boolean; +>isCustomElement : Symbol(Element.isCustomElement, Decl(Element.ts, 4, 29)) + + toString(renderId?: number): string; +>toString : Symbol(Element.toString, Decl(Element.ts, 5, 33)) +>renderId : Symbol(renderId, Decl(Element.ts, 6, 17)) + + bindDOM(renderId?: number): number; +>bindDOM : Symbol(Element.bindDOM, Decl(Element.ts, 6, 44)) +>renderId : Symbol(renderId, Decl(Element.ts, 7, 16)) + + resetComponent(): void; +>resetComponent : Symbol(Element.resetComponent, Decl(Element.ts, 7, 43)) + + instantiateComponents(renderId?: number): number; +>instantiateComponents : Symbol(Element.instantiateComponents, Decl(Element.ts, 8, 31)) +>renderId : Symbol(renderId, Decl(Element.ts, 9, 30)) + + props: any; +>props : Symbol(Element.props, Decl(Element.ts, 9, 57)) + } +} +export namespace Element { +>Element : Symbol(Element, Decl(Element.ts, 12, 1)) + + export function isElement(el: any): el is JSX.Element { +>isElement : Symbol(isElement, Decl(Element.ts, 13, 26)) +>el : Symbol(el, Decl(Element.ts, 14, 30)) +>el : Symbol(el, Decl(Element.ts, 14, 30)) +>JSX : Symbol(JSX, Decl(Element.ts, 0, 0)) +>Element : Symbol(JSX.Element, Decl(Element.ts, 1, 23)) + + return el.markAsChildOfRootElement !== undefined; +>el : Symbol(el, Decl(Element.ts, 14, 30)) +>undefined : Symbol(undefined) + } + + export function createElement(args: any[]) { +>createElement : Symbol(createElement, Decl(Element.ts, 16, 5)) +>args : Symbol(args, Decl(Element.ts, 18, 34)) + + return { + } + } +} + +export let createElement = Element.createElement; +>createElement : Symbol(createElement, Decl(Element.ts, 25, 10)) +>Element.createElement : Symbol(Element.createElement, Decl(Element.ts, 16, 5)) +>Element : Symbol(Element, Decl(Element.ts, 12, 1)) +>createElement : Symbol(Element.createElement, Decl(Element.ts, 16, 5)) + +function toCamelCase(text: string): string { +>toCamelCase : Symbol(toCamelCase, Decl(Element.ts, 25, 49)) +>text : Symbol(text, Decl(Element.ts, 27, 21)) + + return text[0].toLowerCase() + text.substring(1); +>text[0].toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) +>text : Symbol(text, Decl(Element.ts, 27, 21)) +>toLowerCase : Symbol(String.toLowerCase, Decl(lib.es5.d.ts, --, --)) +>text.substring : Symbol(String.substring, Decl(lib.es5.d.ts, --, --)) +>text : Symbol(text, Decl(Element.ts, 27, 21)) +>substring : Symbol(String.substring, Decl(lib.es5.d.ts, --, --)) +} + +=== tests/cases/compiler/test.tsx === +import { Element} from './Element'; +>Element : Symbol(Element, Decl(test.tsx, 0, 8)) + +let c: { +>c : Symbol(c, Decl(test.tsx, 2, 3)) + + a?: { +>a : Symbol(a, Decl(test.tsx, 2, 8)) + + b: string +>b : Symbol(b, Decl(test.tsx, 3, 6)) + } +}; + +class A { +>A : Symbol(A, Decl(test.tsx, 6, 2)) + + view() { +>view : Symbol(A.view, Decl(test.tsx, 8, 9)) + + return [ + , +>meta : Symbol(unknown) +>content : Symbol(unknown) +>meta : Symbol(unknown) + + +>meta : Symbol(unknown) +>content : Symbol(unknown) +>c.a!.b : Symbol(b, Decl(test.tsx, 3, 6)) +>c.a : Symbol(a, Decl(test.tsx, 2, 8)) +>c : Symbol(c, Decl(test.tsx, 2, 3)) +>a : Symbol(a, Decl(test.tsx, 2, 8)) +>b : Symbol(b, Decl(test.tsx, 3, 6)) +>meta : Symbol(unknown) + + ]; + } +} diff --git a/tests/baselines/reference/jsxEmitWithAttributes.types b/tests/baselines/reference/jsxEmitWithAttributes.types new file mode 100644 index 00000000000..663ba4b5bfc --- /dev/null +++ b/tests/baselines/reference/jsxEmitWithAttributes.types @@ -0,0 +1,134 @@ +=== tests/cases/compiler/Element.ts === + +declare namespace JSX { +>JSX : any + + interface Element { +>Element : Element + + name: string; +>name : string + + isIntrinsic: boolean; +>isIntrinsic : boolean + + isCustomElement: boolean; +>isCustomElement : boolean + + toString(renderId?: number): string; +>toString : (renderId?: number) => string +>renderId : number + + bindDOM(renderId?: number): number; +>bindDOM : (renderId?: number) => number +>renderId : number + + resetComponent(): void; +>resetComponent : () => void + + instantiateComponents(renderId?: number): number; +>instantiateComponents : (renderId?: number) => number +>renderId : number + + props: any; +>props : any + } +} +export namespace Element { +>Element : typeof Element + + export function isElement(el: any): el is JSX.Element { +>isElement : (el: any) => el is JSX.Element +>el : any +>el : any +>JSX : any +>Element : JSX.Element + + return el.markAsChildOfRootElement !== undefined; +>el.markAsChildOfRootElement !== undefined : boolean +>el.markAsChildOfRootElement : any +>el : any +>markAsChildOfRootElement : any +>undefined : undefined + } + + export function createElement(args: any[]) { +>createElement : (args: any[]) => {} +>args : any[] + + return { +>{ } : {} + } + } +} + +export let createElement = Element.createElement; +>createElement : (args: any[]) => {} +>Element.createElement : (args: any[]) => {} +>Element : typeof Element +>createElement : (args: any[]) => {} + +function toCamelCase(text: string): string { +>toCamelCase : (text: string) => string +>text : string + + return text[0].toLowerCase() + text.substring(1); +>text[0].toLowerCase() + text.substring(1) : string +>text[0].toLowerCase() : string +>text[0].toLowerCase : () => string +>text[0] : string +>text : string +>0 : 0 +>toLowerCase : () => string +>text.substring(1) : string +>text.substring : (start: number, end?: number) => string +>text : string +>substring : (start: number, end?: number) => string +>1 : 1 +} + +=== tests/cases/compiler/test.tsx === +import { Element} from './Element'; +>Element : typeof Element + +let c: { +>c : { a?: { b: string; }; } + + a?: { +>a : { b: string; } + + b: string +>b : string + } +}; + +class A { +>A : A + + view() { +>view : () => any[] + + return [ +>[ , ] : any[] + + , +> : any +>meta : any +>content : any +>meta : any + + +> : any +>meta : any +>content : any +>c.a!.b : string +>c.a! : { b: string; } +>c.a : { b: string; } +>c : { a?: { b: string; }; } +>a : { b: string; } +>b : string +>meta : any + + ]; + } +} diff --git a/tests/cases/compiler/jsxEmitWithAttributes.ts b/tests/cases/compiler/jsxEmitWithAttributes.ts new file mode 100644 index 00000000000..1fb7a9ccf8d --- /dev/null +++ b/tests/cases/compiler/jsxEmitWithAttributes.ts @@ -0,0 +1,53 @@ +//@jsx: react +//@target: es6 +//@module: commonjs +//@reactNamespace: Element + +// @filename: Element.ts +declare namespace JSX { + interface Element { + name: string; + isIntrinsic: boolean; + isCustomElement: boolean; + toString(renderId?: number): string; + bindDOM(renderId?: number): number; + resetComponent(): void; + instantiateComponents(renderId?: number): number; + props: any; + } +} +export namespace Element { + export function isElement(el: any): el is JSX.Element { + return el.markAsChildOfRootElement !== undefined; + } + + export function createElement(args: any[]) { + + return { + } + } +} + +export let createElement = Element.createElement; + +function toCamelCase(text: string): string { + return text[0].toLowerCase() + text.substring(1); +} + +// @filename: test.tsx +import { Element} from './Element'; + +let c: { + a?: { + b: string + } +}; + +class A { + view() { + return [ + , + + ]; + } +} \ No newline at end of file From 202093a73059cf7d7ca07bc99675419e6a27d5ca Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 20 Oct 2016 15:25:26 -0700 Subject: [PATCH 153/173] When creating react namespace identifier, set its parent to jsx opening element in the parse tree This helps in resolving the react identifier correctly and Fixes #11654 --- src/compiler/factory.ts | 4 +++- tests/baselines/reference/jsxEmitWithAttributes.js | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 4194b7aaf5f..cd55b3099c1 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -1625,7 +1625,9 @@ namespace ts { // flag and setting a parent node. const react = createIdentifier(reactNamespace || "React"); react.flags &= ~NodeFlags.Synthesized; - react.parent = parent; + // Set the parent that is in parse tree + // this makes sure that parent chain is intact for checker to traverse complete scope tree + react.parent = getParseTreeNode(parent); return react; } diff --git a/tests/baselines/reference/jsxEmitWithAttributes.js b/tests/baselines/reference/jsxEmitWithAttributes.js index cd50a4f3411..1acead2801d 100644 --- a/tests/baselines/reference/jsxEmitWithAttributes.js +++ b/tests/baselines/reference/jsxEmitWithAttributes.js @@ -75,7 +75,7 @@ class A { view() { return [ Element_1.Element.createElement("meta", { content: "helloworld" }), - Element.createElement("meta", { content: c.a.b }) + Element_1.Element.createElement("meta", { content: c.a.b }) ]; } } From 10c6ab6703eb8b7a028a0a5f896df4edab9352d7 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 20 Oct 2016 15:28:32 -0700 Subject: [PATCH 154/173] Introduce ObjectFlags in object types --- src/compiler/checker.ts | 180 ++++++++++++++++++---------------- src/compiler/types.ts | 34 ++++--- src/services/services.ts | 3 +- src/services/symbolDisplay.ts | 2 +- 4 files changed, 117 insertions(+), 102 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c260b86e114..32705df1725 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -538,6 +538,10 @@ namespace ts { return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } + function getObjectFlags(type: Type): ObjectFlags { + return type.flags & TypeFlags.ObjectType ? (type).objectFlags : 0; + } + function isGlobalSourceFile(node: Node) { return node.kind === SyntaxKind.SourceFile && !isExternalOrCommonJsModule(node); } @@ -1589,8 +1593,9 @@ namespace ts { return type; } - function createObjectType(kind: TypeFlags, symbol?: Symbol): ObjectType { - const type = createType(kind); + function createObjectType(objectFlags: ObjectFlags, symbol?: Symbol): ObjectType { + const type = createType(TypeFlags.ObjectType); + type.objectFlags = objectFlags; type.symbol = symbol; return type; } @@ -1631,7 +1636,7 @@ namespace ts { } function createAnonymousType(symbol: Symbol, members: SymbolTable, callSignatures: Signature[], constructSignatures: Signature[], stringIndexInfo: IndexInfo, numberIndexInfo: IndexInfo): ResolvedType { - return setStructuredTypeMembers(createObjectType(TypeFlags.Anonymous, symbol), + return setStructuredTypeMembers(createObjectType(ObjectFlags.Anonymous, symbol), members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } @@ -2182,7 +2187,7 @@ namespace ts { } writer.writeKeyword("this"); } - else if (type.flags & TypeFlags.Reference) { + else if (getObjectFlags(type) & ObjectFlags.Reference) { writeTypeReference(type, nextFlags); } else if (type.flags & TypeFlags.EnumLiteral) { @@ -2190,11 +2195,11 @@ namespace ts { writePunctuation(writer, SyntaxKind.DotToken); appendSymbolNameOnly(type.symbol, writer); } - else if (type.flags & (TypeFlags.Class | TypeFlags.Interface | TypeFlags.Enum | TypeFlags.TypeParameter)) { + else if (getObjectFlags(type) & (ObjectFlags.Class | ObjectFlags.Interface) || type.flags & (TypeFlags.Enum | TypeFlags.TypeParameter)) { // The specified symbol flags need to be reinterpreted as type flags buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, SymbolFlags.Type, SymbolFormatFlags.None, nextFlags); } - else if (!(flags & TypeFormatFlags.InTypeAlias) && ((type.flags & TypeFlags.Anonymous && !(type).target) || type.flags & TypeFlags.UnionOrIntersection) && type.aliasSymbol && + else if (!(flags & TypeFormatFlags.InTypeAlias) && ((getObjectFlags(type) & ObjectFlags.Anonymous && !(type).target) || type.flags & TypeFlags.UnionOrIntersection) && type.aliasSymbol && isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, SymbolFlags.Type, /*shouldComputeAliasesToMakeVisible*/ false).accessibility === SymbolAccessibility.Accessible) { // We emit inferred type as type-alias at the current localtion if all the following is true // the input type is has alias symbol that is accessible @@ -2208,7 +2213,7 @@ namespace ts { else if (type.flags & TypeFlags.UnionOrIntersection) { writeUnionOrIntersectionType(type, nextFlags); } - else if (type.flags & TypeFlags.Anonymous) { + else if (getObjectFlags(type) & ObjectFlags.Anonymous) { writeAnonymousType(type, nextFlags); } else if (type.flags & TypeFlags.StringOrNumberLiteral) { @@ -2264,7 +2269,7 @@ namespace ts { writePunctuation(writer, SyntaxKind.OpenBracketToken); writePunctuation(writer, SyntaxKind.CloseBracketToken); } - else if (type.target.flags & TypeFlags.Tuple) { + else if (type.target.objectFlags & ObjectFlags.Tuple) { writePunctuation(writer, SyntaxKind.OpenBracketToken); writeTypeList(type.typeArguments.slice(0, getTypeReferenceArity(type)), SyntaxKind.CommaToken); writePunctuation(writer, SyntaxKind.CloseBracketToken); @@ -2866,7 +2871,6 @@ namespace ts { return getSymbolLinks(target).declaredType; } if (propertyName === TypeSystemPropertyName.ResolvedBaseConstructorType) { - Debug.assert(!!((target).flags & TypeFlags.Class)); return (target).resolvedBaseConstructorType; } if (propertyName === TypeSystemPropertyName.ResolvedReturnType) { @@ -3456,7 +3460,7 @@ namespace ts { links.type = anyType; } else { - const type = createObjectType(TypeFlags.Anonymous, symbol); + const type = createObjectType(ObjectFlags.Anonymous, symbol); links.type = strictNullChecks && symbol.flags & SymbolFlags.Optional ? includeFalsyTypes(type, TypeFlags.Undefined) : type; } @@ -3520,7 +3524,7 @@ namespace ts { } function getTargetType(type: Type): Type { - return type.flags & TypeFlags.Reference ? (type).target : type; + return getObjectFlags(type) & ObjectFlags.Reference ? (type).target : type; } function hasBaseType(type: InterfaceType, checkBase: InterfaceType) { @@ -3653,7 +3657,7 @@ namespace ts { function getBaseTypes(type: InterfaceType): ObjectType[] { if (!type.resolvedBaseTypes) { - if (type.flags & TypeFlags.Tuple) { + if (type.objectFlags & ObjectFlags.Tuple) { type.resolvedBaseTypes = [createArrayType(getUnionType(type.typeParameters))]; } else if (type.symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { @@ -3701,7 +3705,7 @@ namespace ts { if (baseType === unknownType) { return; } - if (!(getTargetType(baseType).flags & (TypeFlags.Class | TypeFlags.Interface))) { + if (!(getObjectFlags(getTargetType(baseType)) & (ObjectFlags.Class | ObjectFlags.Interface))) { error(baseTypeNode.expression, Diagnostics.Base_constructor_return_type_0_is_not_a_class_or_interface_type, typeToString(baseType)); return; } @@ -3737,7 +3741,7 @@ namespace ts { for (const node of getInterfaceBaseTypeNodes(declaration)) { const baseType = getTypeFromTypeNode(node); if (baseType !== unknownType) { - if (getTargetType(baseType).flags & (TypeFlags.Class | TypeFlags.Interface)) { + if (getObjectFlags(getTargetType(baseType)) & (ObjectFlags.Class | ObjectFlags.Interface)) { if (type !== baseType && !hasBaseType(baseType, type)) { if (type.resolvedBaseTypes === emptyArray) { type.resolvedBaseTypes = [baseType]; @@ -3787,7 +3791,7 @@ namespace ts { function getDeclaredTypeOfClassOrInterface(symbol: Symbol): InterfaceType { const links = getSymbolLinks(symbol); if (!links.declaredType) { - const kind = symbol.flags & SymbolFlags.Class ? TypeFlags.Class : TypeFlags.Interface; + const kind = symbol.flags & SymbolFlags.Class ? ObjectFlags.Class : ObjectFlags.Interface; const type = links.declaredType = createObjectType(kind, symbol); const outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); const localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -3796,8 +3800,8 @@ namespace ts { // 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 === TypeFlags.Class || !isIndependentInterface(symbol)) { - type.flags |= TypeFlags.Reference; + if (outerTypeParameters || localTypeParameters || kind === ObjectFlags.Class || !isIndependentInterface(symbol)) { + type.objectFlags |= ObjectFlags.Reference; type.typeParameters = concatenate(outerTypeParameters, localTypeParameters); type.outerTypeParameters = outerTypeParameters; type.localTypeParameters = localTypeParameters; @@ -4094,7 +4098,7 @@ namespace ts { } function getTypeWithThisArgument(type: Type, thisArgument?: Type) { - if (type.flags & TypeFlags.Reference) { + if (getObjectFlags(type) & ObjectFlags.Reference) { return createTypeReference((type).target, concatenate((type).typeArguments, [thisArgument || (type).target.thisType])); } @@ -4365,14 +4369,16 @@ namespace ts { function resolveStructuredTypeMembers(type: StructuredType): ResolvedType { if (!(type).members) { - if (type.flags & TypeFlags.Reference) { - resolveTypeReferenceMembers(type); - } - else if (type.flags & (TypeFlags.Class | TypeFlags.Interface)) { - resolveClassOrInterfaceMembers(type); - } - else if (type.flags & TypeFlags.Anonymous) { - resolveAnonymousTypeMembers(type); + if (type.flags & TypeFlags.ObjectType) { + if ((type).objectFlags & ObjectFlags.Reference) { + resolveTypeReferenceMembers(type); + } + else if ((type).objectFlags & (ObjectFlags.Class | ObjectFlags.Interface)) { + resolveClassOrInterfaceMembers(type); + } + else if ((type).objectFlags & ObjectFlags.Anonymous) { + resolveAnonymousTypeMembers(type); + } } else if (type.flags & TypeFlags.Union) { resolveUnionTypeMembers(type); @@ -4927,7 +4933,7 @@ namespace ts { function getRestTypeOfSignature(signature: Signature): Type { if (signature.hasRestParameter) { const type = getTypeOfSymbol(lastOrUndefined(signature.parameters)); - if (type.flags & TypeFlags.Reference && (type).target === globalArrayType) { + if (getObjectFlags(type) & ObjectFlags.Reference && (type).target === globalArrayType) { return (type).typeArguments[0]; } } @@ -4953,7 +4959,7 @@ namespace ts { // will result in a different declaration kind. if (!signature.isolatedSignatureType) { const isConstructor = signature.declaration.kind === SyntaxKind.Constructor || signature.declaration.kind === SyntaxKind.ConstructSignature; - const type = createObjectType(TypeFlags.Anonymous); + const type = createObjectType(ObjectFlags.Anonymous); type.members = emptySymbols; type.properties = emptyArray; type.callSignatures = !isConstructor ? [signature] : emptyArray; @@ -5081,9 +5087,8 @@ namespace ts { const id = getTypeListId(typeArguments); let type = target.instantiations[id]; if (!type) { - const propagatedFlags = typeArguments ? getPropagatingFlagsOfTypes(typeArguments, /*excludeKinds*/ 0) : 0; - const flags = TypeFlags.Reference | propagatedFlags; - type = target.instantiations[id] = createObjectType(flags, target.symbol); + type = target.instantiations[id] = createObjectType(ObjectFlags.Reference, target.symbol); + type.flags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, /*excludeKinds*/ 0) : 0; type.target = target; type.typeArguments = typeArguments; } @@ -5091,7 +5096,9 @@ namespace ts { } function cloneTypeReference(source: TypeReference): TypeReference { - const type = createObjectType(source.flags, source.symbol); + const type = createType(source.flags); + type.symbol = source.symbol; + type.objectFlags = source.objectFlags; type.target = source.target; type.typeArguments = source.typeArguments; return type; @@ -5357,7 +5364,7 @@ namespace ts { property.type = typeParameter; properties.push(property); } - const type = createObjectType(TypeFlags.Tuple | TypeFlags.Reference); + const type = createObjectType(ObjectFlags.Tuple | ObjectFlags.Reference); type.typeParameters = typeParameters; type.outerTypeParameters = undefined; type.localTypeParameters = typeParameters; @@ -5446,7 +5453,8 @@ namespace ts { const len = typeSet.length; const index = len && type.id > typeSet[len - 1].id ? ~len : binarySearchTypes(typeSet, type); if (index < 0) { - if (!(flags & TypeFlags.Anonymous && type.symbol && type.symbol.flags & (SymbolFlags.Function | SymbolFlags.Method) && containsIdenticalType(typeSet, type))) { + if (!(flags & TypeFlags.ObjectType && (type).objectFlags & ObjectFlags.Anonymous && + type.symbol && type.symbol.flags & (SymbolFlags.Function | SymbolFlags.Method) && containsIdenticalType(typeSet, type))) { typeSet.splice(~index, 0, type); } } @@ -5659,7 +5667,7 @@ namespace ts { const links = getNodeLinks(node); if (!links.resolvedType) { // Deferred resolution of members is handled by resolveObjectTypeMembers - const type = createObjectType(TypeFlags.Anonymous, node.symbol); + const type = createObjectType(ObjectFlags.Anonymous, node.symbol); type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; links.resolvedType = type; @@ -5989,7 +5997,7 @@ namespace ts { mapper.instantiations = []; } // Mark the anonymous type as instantiated such that our infinite instantiation detection logic can recognize it - const result = createObjectType(TypeFlags.Anonymous | TypeFlags.Instantiated, type.symbol); + const result = createObjectType(ObjectFlags.Anonymous | ObjectFlags.Instantiated, type.symbol); result.target = type; result.mapper = mapper; result.aliasSymbol = type.aliasSymbol; @@ -6052,20 +6060,22 @@ namespace ts { if (type.flags & TypeFlags.TypeParameter) { return mapper(type); } - if (type.flags & TypeFlags.Anonymous) { - // If the anonymous type originates in a declaration of a function, method, class, or - // interface, in an object type literal, or in an object literal expression, we may need - // to instantiate the type because it might reference a type parameter. We skip instantiation - // if none of the type parameters that are in scope in the type's declaration are mapped by - // the given mapper, however we can only do that analysis if the type isn't itself an - // instantiation. - return type.symbol && - type.symbol.flags & (SymbolFlags.Function | SymbolFlags.Method | SymbolFlags.Class | SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral) && - (type.flags & TypeFlags.Instantiated || isSymbolInScopeOfMappedTypeParameter(type.symbol, mapper)) ? - instantiateAnonymousType(type, mapper) : type; - } - if (type.flags & TypeFlags.Reference) { - return createTypeReference((type).target, instantiateList((type).typeArguments, mapper, instantiateType)); + if (type.flags & TypeFlags.ObjectType) { + if ((type).objectFlags & ObjectFlags.Anonymous) { + // If the anonymous type originates in a declaration of a function, method, class, or + // interface, in an object type literal, or in an object literal expression, we may need + // to instantiate the type because it might reference a type parameter. We skip instantiation + // if none of the type parameters that are in scope in the type's declaration are mapped by + // the given mapper, however we can only do that analysis if the type isn't itself an + // instantiation. + return type.symbol && + type.symbol.flags & (SymbolFlags.Function | SymbolFlags.Method | SymbolFlags.Class | SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral) && + ((type).objectFlags & ObjectFlags.Instantiated || isSymbolInScopeOfMappedTypeParameter(type.symbol, mapper)) ? + instantiateAnonymousType(type, mapper) : type; + } + if ((type).objectFlags & ObjectFlags.Reference) { + return createTypeReference((type).target, instantiateList((type).typeArguments, mapper, instantiateType)); + } } if (type.flags & TypeFlags.Union && !(type.flags & TypeFlags.Primitive)) { return getUnionType(instantiateList((type).types, mapper, instantiateType), /*subtypeReduction*/ false, type.aliasSymbol, mapper.targetTypes); @@ -6140,7 +6150,7 @@ namespace ts { if (type.flags & TypeFlags.ObjectType) { const resolved = resolveStructuredTypeMembers(type); if (resolved.constructSignatures.length) { - const result = createObjectType(TypeFlags.Anonymous, type.symbol); + const result = createObjectType(ObjectFlags.Anonymous, type.symbol); result.members = resolved.members; result.properties = resolved.properties; result.callSignatures = emptyArray; @@ -6556,7 +6566,7 @@ namespace ts { if (isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return Ternary.True; - if (source.flags & TypeFlags.ObjectLiteral && source.flags & TypeFlags.FreshLiteral) { + if (getObjectFlags(source) & ObjectFlags.ObjectLiteral && source.flags & TypeFlags.FreshLiteral) { if (hasExcessProperties(source, target, reportErrors)) { if (reportErrors) { reportRelationError(headMessage, source, target); @@ -6635,7 +6645,7 @@ namespace ts { } } else { - if (source.flags & TypeFlags.Reference && target.flags & TypeFlags.Reference && (source).target === (target).target) { + if (getObjectFlags(source) & ObjectFlags.Reference && getObjectFlags(target) & ObjectFlags.Reference && (source).target === (target).target) { // We have type references to same target type, see if relationship holds for all type arguments if (result = typeArgumentsRelatedTo(source, target, reportErrors)) { return result; @@ -6672,7 +6682,7 @@ namespace ts { function isIdenticalTo(source: Type, target: Type): Ternary { let result: Ternary; if (source.flags & TypeFlags.ObjectType && target.flags & TypeFlags.ObjectType) { - if (source.flags & TypeFlags.Reference && target.flags & TypeFlags.Reference && (source).target === (target).target) { + if (getObjectFlags(source) & ObjectFlags.Reference && getObjectFlags(target) & ObjectFlags.Reference && (source).target === (target).target) { // We have type references to same target type, see if all type arguments are identical if (result = typeArgumentsRelatedTo(source, target, /*reportErrors*/ false)) { return result; @@ -6919,7 +6929,7 @@ namespace ts { } let result = Ternary.True; const properties = getPropertiesOfObjectType(target); - const requireOptionalProperties = relation === subtypeRelation && !(source.flags & TypeFlags.ObjectLiteral); + const requireOptionalProperties = relation === subtypeRelation && !(getObjectFlags(source) & ObjectFlags.ObjectLiteral); for (const targetProp of properties) { const sourceProp = getPropertyOfType(source, targetProp.name); @@ -7200,7 +7210,7 @@ namespace ts { // Return true if the given type is the constructor type for an abstract class function isAbstractConstructorType(type: Type) { - if (type.flags & TypeFlags.Anonymous) { + if (getObjectFlags(type) & ObjectFlags.Anonymous) { const symbol = type.symbol; if (symbol && symbol.flags & SymbolFlags.Class) { const declaration = getClassLikeDeclarationOfSymbol(symbol); @@ -7219,12 +7229,12 @@ namespace ts { // some level beyond that. function isDeeplyNestedGeneric(type: Type, stack: Type[], depth: number): boolean { // We track type references (created by createTypeReference) and instantiated types (created by instantiateType) - if (type.flags & (TypeFlags.Reference | TypeFlags.Instantiated) && depth >= 5) { + if (getObjectFlags(type) & (ObjectFlags.Reference | ObjectFlags.Instantiated) && depth >= 5) { const symbol = type.symbol; let count = 0; for (let i = 0; i < depth; i++) { const t = stack[i]; - if (t.flags & (TypeFlags.Reference | TypeFlags.Instantiated) && t.symbol === symbol) { + if (getObjectFlags(t) & (ObjectFlags.Reference | ObjectFlags.Instantiated) && t.symbol === symbol) { count++; if (count >= 5) return true; } @@ -7427,13 +7437,13 @@ namespace ts { } function isArrayType(type: Type): boolean { - return type.flags & TypeFlags.Reference && (type).target === globalArrayType; + return getObjectFlags(type) & ObjectFlags.Reference && (type).target === globalArrayType; } function isArrayLikeType(type: Type): boolean { // A type is array-like if it is a reference to the global Array or global ReadonlyArray type, // or if it is not the undefined or null type and if it is assignable to ReadonlyArray - return type.flags & TypeFlags.Reference && ((type).target === globalArrayType || (type).target === globalReadonlyArrayType) || + return getObjectFlags(type) & ObjectFlags.Reference && ((type).target === globalArrayType || (type).target === globalReadonlyArrayType) || !(type.flags & TypeFlags.Nullable) && isTypeAssignableTo(type, anyReadonlyArrayType); } @@ -7474,7 +7484,7 @@ namespace ts { * Prefer using isTupleLikeType() unless the use of `elementTypes` is required. */ function isTupleType(type: Type): boolean { - return !!(type.flags & TypeFlags.Reference && (type).target.flags & TypeFlags.Tuple); + return !!(getObjectFlags(type) & ObjectFlags.Reference && (type).target.objectFlags & ObjectFlags.Tuple); } function getFalsyFlagsOfTypes(types: Type[]): TypeFlags { @@ -7558,7 +7568,7 @@ namespace ts { * Leave signatures alone since they are not subject to the check. */ function getRegularTypeOfObjectLiteral(type: Type): Type { - if (!(type.flags & TypeFlags.ObjectLiteral && type.flags & TypeFlags.FreshLiteral)) { + if (!(getObjectFlags(type) & ObjectFlags.ObjectLiteral && type.flags & TypeFlags.FreshLiteral)) { return type; } const regularType = (type).regularType; @@ -7575,6 +7585,7 @@ namespace ts { resolved.stringIndexInfo, resolved.numberIndexInfo); regularNew.flags = resolved.flags & ~TypeFlags.FreshLiteral; + regularNew.objectFlags |= ObjectFlags.ObjectLiteral; (type).regularType = regularNew; return regularNew; } @@ -7600,7 +7611,7 @@ namespace ts { if (type.flags & TypeFlags.Nullable) { return anyType; } - if (type.flags & TypeFlags.ObjectLiteral) { + if (getObjectFlags(type) & ObjectFlags.ObjectLiteral) { return getWidenedTypeOfObjectLiteral(type); } if (type.flags & TypeFlags.Union) { @@ -7640,7 +7651,7 @@ namespace ts { } } } - if (type.flags & TypeFlags.ObjectLiteral) { + if (getObjectFlags(type) & ObjectFlags.ObjectLiteral) { for (const p of getPropertiesOfObjectType(type)) { const t = getTypeOfSymbol(p); if (t.flags & TypeFlags.ContainsWideningType) { @@ -7743,8 +7754,8 @@ namespace ts { // results for union and intersection types for performance reasons. function couldContainTypeParameters(type: Type): boolean { return !!(type.flags & TypeFlags.TypeParameter || - type.flags & TypeFlags.Reference && forEach((type).typeArguments, couldContainTypeParameters) || - type.flags & TypeFlags.Anonymous && type.symbol && type.symbol.flags & (SymbolFlags.Method | SymbolFlags.TypeLiteral | SymbolFlags.Class) || + getObjectFlags(type) & ObjectFlags.Reference && forEach((type).typeArguments, couldContainTypeParameters) || + getObjectFlags(type) & ObjectFlags.Anonymous && type.symbol && type.symbol.flags & (SymbolFlags.Method | SymbolFlags.TypeLiteral | SymbolFlags.Class) || type.flags & TypeFlags.UnionOrIntersection && couldUnionOrIntersectionContainTypeParameters(type)); } @@ -7852,7 +7863,7 @@ namespace ts { } } } - else if (source.flags & TypeFlags.Reference && target.flags & TypeFlags.Reference && (source).target === (target).target) { + else if (getObjectFlags(source) & ObjectFlags.Reference && getObjectFlags(target) & ObjectFlags.Reference && (source).target === (target).target) { // If source and target are references to the same generic type, infer from type arguments const sourceTypes = (source).typeArguments || emptyArray; const targetTypes = (target).typeArguments || emptyArray; @@ -8548,7 +8559,7 @@ namespace ts { // array types are ultimately converted into manifest array types (using getFinalArrayType) // and never escape the getFlowTypeOfReference function. function createEvolvingArrayType(elementType: Type): AnonymousType { - const result = createObjectType(TypeFlags.Anonymous); + const result = createObjectType(ObjectFlags.Anonymous); result.elementType = elementType; return result; } @@ -8566,7 +8577,7 @@ namespace ts { } function isEvolvingArrayType(type: Type) { - return !!(type.flags & TypeFlags.Anonymous && (type).elementType); + return !!(getObjectFlags(type) & ObjectFlags.Anonymous && (type).elementType); } function createFinalArrayType(elementType: Type) { @@ -9101,10 +9112,10 @@ namespace ts { if (!targetType) { // Target type is type of construct signature let constructSignatures: Signature[]; - if (rightType.flags & TypeFlags.Interface) { + if (getObjectFlags(rightType) & ObjectFlags.Interface) { constructSignatures = resolveDeclaredMembers(rightType).declaredConstructSignatures; } - else if (rightType.flags & TypeFlags.Anonymous) { + else if (getObjectFlags(rightType) & ObjectFlags.Anonymous) { constructSignatures = getSignaturesOfType(rightType, SignatureKind.Construct); } if (constructSignatures && constructSignatures.length) { @@ -10654,7 +10665,8 @@ namespace ts { const numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, propertiesArray, IndexKind.Number) : undefined; const result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); const freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : TypeFlags.FreshLiteral; - result.flags |= TypeFlags.ObjectLiteral | TypeFlags.ContainsObjectLiteral | freshObjectLiteralFlag | (typeFlags & TypeFlags.PropagatingFlags); + result.flags |= TypeFlags.ContainsObjectLiteral | freshObjectLiteralFlag | (typeFlags & TypeFlags.PropagatingFlags); + result.objectFlags |= ObjectFlags.ObjectLiteral; if (patternWithComputedProperties) { result.isObjectLiteralPatternWithComputedProperties = true; } @@ -11239,7 +11251,7 @@ namespace ts { } // TODO: why is the first part of this check here? - if (!(getTargetType(type).flags & (TypeFlags.Class | TypeFlags.Interface) && hasBaseType(type, enclosingClass))) { + if (!(getObjectFlags(getTargetType(type)) & (ObjectFlags.Class | ObjectFlags.Interface) && hasBaseType(type, enclosingClass))) { error(errorNode, Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); return false; } @@ -13528,7 +13540,7 @@ namespace ts { } function isConstEnumObjectType(type: Type): boolean { - return type.flags & (TypeFlags.ObjectType | TypeFlags.Anonymous) && type.symbol && isConstEnumSymbol(type.symbol); + return getObjectFlags(type) & ObjectFlags.Anonymous && type.symbol && isConstEnumSymbol(type.symbol); } function isConstEnumSymbol(symbol: Symbol): boolean { @@ -15293,7 +15305,7 @@ namespace ts { return undefined; } - if (promise.flags & TypeFlags.Reference) { + if (getObjectFlags(promise) & ObjectFlags.Reference) { if ((promise).target === tryGetGlobalPromiseType() || (promise).target === getGlobalPromiseLikeType()) { return (promise).typeArguments[0]; @@ -16562,7 +16574,7 @@ namespace ts { if (!typeAsIterable.iterableElementType) { // As an optimization, if the type is instantiated directly using the globalIterableType (Iterable), // then just grab its type argument. - if ((type.flags & TypeFlags.Reference) && (type).target === getGlobalIterableType()) { + if ((getObjectFlags(type) & ObjectFlags.Reference) && (type).target === getGlobalIterableType()) { typeAsIterable.iterableElementType = (type).typeArguments[0]; } else { @@ -16608,7 +16620,7 @@ namespace ts { if (!typeAsIterator.iteratorElementType) { // As an optimization, if the type is instantiated directly using the globalIteratorType (Iterator), // then just grab its type argument. - if ((type.flags & TypeFlags.Reference) && (type).target === getGlobalIteratorType()) { + if ((getObjectFlags(type) & ObjectFlags.Reference) && (type).target === getGlobalIteratorType()) { typeAsIterator.iteratorElementType = (type).typeArguments[0]; } else { @@ -16652,7 +16664,7 @@ namespace ts { // As an optimization, if the type is instantiated directly using the globalIterableIteratorType (IterableIterator), // then just grab its type argument. - if ((type.flags & TypeFlags.Reference) && (type).target === getGlobalIterableIteratorType()) { + if ((getObjectFlags(type) & ObjectFlags.Reference) && (type).target === getGlobalIterableIteratorType()) { return (type).typeArguments[0]; } @@ -16949,7 +16961,7 @@ namespace ts { checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, IndexKind.Number); }); - if (type.flags & TypeFlags.Class && isClassLike(type.symbol.valueDeclaration)) { + if (getObjectFlags(type) & ObjectFlags.Class && isClassLike(type.symbol.valueDeclaration)) { const classDeclaration = type.symbol.valueDeclaration; for (const member of classDeclaration.members) { // Only process instance properties with computed names here. @@ -16968,7 +16980,7 @@ namespace ts { if (stringIndexType && numberIndexType) { errorNode = declaredNumberIndexer || declaredStringIndexer; // condition 'errorNode === undefined' may appear if types does not declare nor string neither number indexer - if (!errorNode && (type.flags & TypeFlags.Interface)) { + if (!errorNode && (getObjectFlags(type) & ObjectFlags.Interface)) { const someBaseTypeHasBothIndexers = forEach(getBaseTypes(type), base => getIndexTypeOfType(base, IndexKind.String) && getIndexTypeOfType(base, IndexKind.Number)); errorNode = someBaseTypeHasBothIndexers ? undefined : type.symbol.declarations[0]; } @@ -17005,7 +17017,7 @@ namespace ts { else if (indexDeclaration) { errorNode = indexDeclaration; } - else if (containingType.flags & TypeFlags.Interface) { + else if (getObjectFlags(containingType) & ObjectFlags.Interface) { // for interfaces property and indexer might be inherited from different bases // check if any base class already has both property and indexer. // check should be performed only if 'type' is the first type that brings property\indexer together @@ -17164,8 +17176,8 @@ namespace ts { if (produceDiagnostics) { const t = getTypeFromTypeNode(typeRefNode); if (t !== unknownType) { - const declaredType = (t.flags & TypeFlags.Reference) ? (t).target : t; - if (declaredType.flags & (TypeFlags.Class | TypeFlags.Interface)) { + const declaredType = (getObjectFlags(t) & ObjectFlags.Reference) ? (t).target : t; + if (getObjectFlags(declaredType) & (ObjectFlags.Class | ObjectFlags.Interface)) { checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(t, type.thisType), node.name || node, Diagnostics.Class_0_incorrectly_implements_interface_1); } else { @@ -19671,7 +19683,7 @@ namespace ts { const thenPropertySymbol = createSymbol(SymbolFlags.Transient | SymbolFlags.Property, "then"); getSymbolLinks(thenPropertySymbol).type = globalFunctionType; - const thenableType = createObjectType(TypeFlags.Anonymous); + const thenableType = createObjectType(ObjectFlags.Anonymous); thenableType.properties = [thenPropertySymbol]; thenableType.members = createSymbolTable(thenableType.properties); thenableType.callSignatures = []; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 540d6e8c406..0a298a78d02 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2612,24 +2612,17 @@ namespace ts { Null = 1 << 12, Never = 1 << 13, // Never type TypeParameter = 1 << 14, // Type parameter - Class = 1 << 15, // Class - Interface = 1 << 16, // Interface - Reference = 1 << 17, // Generic type reference - Tuple = 1 << 18, // Synthesized generic tuple type - Union = 1 << 19, // Union (T | U) - Intersection = 1 << 20, // Intersection (T & U) - Anonymous = 1 << 21, // Anonymous - Instantiated = 1 << 22, // Instantiated anonymous type + ObjectType = 1 << 15, // Object type + Union = 1 << 16, // Union (T | U) + Intersection = 1 << 17, // Intersection (T & U) /* @internal */ - ObjectLiteral = 1 << 23, // Originates in an object literal + FreshLiteral = 1 << 18, // Fresh literal type /* @internal */ - FreshLiteral = 1 << 24, // Fresh literal type + ContainsWideningType = 1 << 19, // Type is or contains undefined or null widening type /* @internal */ - ContainsWideningType = 1 << 25, // Type is or contains undefined or null widening type + ContainsObjectLiteral = 1 << 20, // Type is or contains object literal type /* @internal */ - ContainsObjectLiteral = 1 << 26, // Type is or contains object literal type - /* @internal */ - ContainsAnyFunctionType = 1 << 27, // Type is or contains object literal type + ContainsAnyFunctionType = 1 << 21, // Type is or contains object literal type /* @internal */ Nullable = Undefined | Null, @@ -2646,7 +2639,6 @@ namespace ts { NumberLike = Number | NumberLiteral | Enum | EnumLiteral, BooleanLike = Boolean | BooleanLiteral, EnumLike = Enum | EnumLiteral, - ObjectType = Class | Interface | Reference | Tuple | Anonymous, UnionOrIntersection = Union | Intersection, StructuredType = ObjectType | Union | Intersection, StructuredOrTypeParameter = StructuredType | TypeParameter, @@ -2663,6 +2655,16 @@ namespace ts { export type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; + export const enum ObjectFlags { + Class = 1 << 0, // Class + Interface = 1 << 1, // Interface + Reference = 1 << 2, // Generic type reference + Tuple = 1 << 3, // Synthesized generic tuple type + Anonymous = 1 << 4, // Anonymous + Instantiated = 1 << 5, // Instantiated anonymous type + ObjectLiteral = 1 << 6, // Originates in an object literal + } + // Properties common to all types export interface Type { flags: TypeFlags; // Flags @@ -2699,7 +2701,7 @@ namespace ts { // Object types (TypeFlags.ObjectType) export interface ObjectType extends Type { - _objectTypeBrand: any; + objectFlags: ObjectFlags; isObjectLiteralPatternWithComputedProperties?: boolean; } diff --git a/src/services/services.ts b/src/services/services.ts index 9ed73318d8e..a562aa44bfd 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -347,6 +347,7 @@ namespace ts { class TypeObject implements Type { checker: TypeChecker; flags: TypeFlags; + objectFlags?: ObjectFlags; id: number; symbol: Symbol; constructor(checker: TypeChecker, flags: TypeFlags) { @@ -381,7 +382,7 @@ namespace ts { return this.checker.getIndexTypeOfType(this, IndexKind.Number); } getBaseTypes(): ObjectType[] { - return this.flags & (TypeFlags.Class | TypeFlags.Interface) + return this.flags & TypeFlags.ObjectType && this.objectFlags & (ObjectFlags.Class | ObjectFlags.Interface) ? this.checker.getBaseTypes(this) : undefined; } diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts index c9141278b10..37753547768 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -173,7 +173,7 @@ namespace ts.SymbolDisplay { displayParts.push(keywordPart(SyntaxKind.NewKeyword)); displayParts.push(spacePart()); } - if (!(type.flags & TypeFlags.Anonymous) && type.symbol) { + if (!(type.flags & TypeFlags.ObjectType && (type).objectFlags & ObjectFlags.Anonymous) && type.symbol) { addRange(displayParts, symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, SymbolFormatFlags.WriteTypeParametersOrArguments)); } addSignatureDisplayParts(signature, allSignatures, TypeFormatFlags.WriteArrowStyleSignature); From cfe37ce054f735786e6a01de678014bbfc880ebf Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Thu, 20 Oct 2016 15:36:44 -0700 Subject: [PATCH 155/173] Jenkins / .net CI support --- jenkins.sh | 13 +++++++++++++ netci.groovy | 22 ++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100755 jenkins.sh create mode 100644 netci.groovy diff --git a/jenkins.sh b/jenkins.sh new file mode 100755 index 00000000000..377a44b7bf7 --- /dev/null +++ b/jenkins.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +# Set up NVM +export NVM_DIR="/home/dotnet-bot/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" + +nvm install $1 + +npm uninstall typescript +npm uninstall tslint +npm install +npm update +npm test diff --git a/netci.groovy b/netci.groovy new file mode 100644 index 00000000000..9f2a96cdeef --- /dev/null +++ b/netci.groovy @@ -0,0 +1,22 @@ +// Import the utility functionality. +import jobs.generation.Utilities; + +// Defines a the new of the repo, used elsewhere in the file +def project = GithubProject +def branch = GithubBranchName + +def nodeVersions = ['stable', '4'] + +nodeVersions.each { nodeVer -> + + def newJobName = "typescript_node.${nodeVer}" + def newJob = job(Utilities.getFullJobName(project, newJobName, true)) { + steps { + shell("./jenkins.sh ${nodeVer}") + } + } + + Utilities.standardJobSetup(newJob, project, true, "*/${branch}") + Utilities.setMachineAffinity(newJob, 'Ubuntu', '20161020') + Utilities.addGithubPRTriggerForBranch(newJob, branch, "TypeScript Test Run ${newJobName}") +} From b37313c90d6d2039e4df5d93aa8007e1fd7e16b9 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 20 Oct 2016 15:42:24 -0700 Subject: [PATCH 156/173] Introduce EvolvingArrayType and associated ObjectFlag.EvolvingArray --- src/compiler/checker.ts | 20 ++++++++++---------- src/compiler/types.ts | 8 ++++++-- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 32705df1725..843a21cbae3 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -115,7 +115,7 @@ namespace ts { const intersectionTypes = createMap(); const stringLiteralTypes = createMap(); const numericLiteralTypes = createMap(); - const evolvingArrayTypes: AnonymousType[] = []; + const evolvingArrayTypes: EvolvingArrayType[] = []; const unknownSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "unknown"); const resolvingSymbol = createSymbol(SymbolFlags.Transient, "__resolving__"); @@ -8558,26 +8558,26 @@ namespace ts { // 'x.push(value)' or 'x[n] = value' operation along the control flow graph. Evolving // array types are ultimately converted into manifest array types (using getFinalArrayType) // and never escape the getFlowTypeOfReference function. - function createEvolvingArrayType(elementType: Type): AnonymousType { - const result = createObjectType(ObjectFlags.Anonymous); + function createEvolvingArrayType(elementType: Type): EvolvingArrayType { + const result = createObjectType(ObjectFlags.EvolvingArray); result.elementType = elementType; return result; } - function getEvolvingArrayType(elementType: Type): AnonymousType { + function getEvolvingArrayType(elementType: Type): EvolvingArrayType { return evolvingArrayTypes[elementType.id] || (evolvingArrayTypes[elementType.id] = createEvolvingArrayType(elementType)); } // When adding evolving array element types we do not perform subtype reduction. Instead, // we defer subtype reduction until the evolving array type is finalized into a manifest // array type. - function addEvolvingArrayElementType(evolvingArrayType: AnonymousType, node: Expression): AnonymousType { + function addEvolvingArrayElementType(evolvingArrayType: EvolvingArrayType, node: Expression): EvolvingArrayType { const elementType = getBaseTypeOfLiteralType(checkExpression(node)); return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType])); } function isEvolvingArrayType(type: Type) { - return !!(getObjectFlags(type) & ObjectFlags.Anonymous && (type).elementType); + return !!(getObjectFlags(type) & ObjectFlags.EvolvingArray); } function createFinalArrayType(elementType: Type) { @@ -8589,16 +8589,16 @@ namespace ts { } // We perform subtype reduction upon obtaining the final array type from an evolving array type. - function getFinalArrayType(evolvingArrayType: AnonymousType): Type { + function getFinalArrayType(evolvingArrayType: EvolvingArrayType): Type { return evolvingArrayType.finalArrayType || (evolvingArrayType.finalArrayType = createFinalArrayType(evolvingArrayType.elementType)); } function finalizeEvolvingArrayType(type: Type): Type { - return isEvolvingArrayType(type) ? getFinalArrayType(type) : type; + return isEvolvingArrayType(type) ? getFinalArrayType(type) : type; } function getElementTypeOfEvolvingArrayType(type: Type) { - return isEvolvingArrayType(type) ? (type).elementType : neverType; + return isEvolvingArrayType(type) ? (type).elementType : neverType; } function isEvolvingArrayTypeList(types: Type[]) { @@ -8770,7 +8770,7 @@ namespace ts { const flowType = getTypeAtFlowNode(flow.antecedent); const type = getTypeFromFlowType(flowType); if (isEvolvingArrayType(type)) { - let evolvedType = type; + let evolvedType = type; if (node.kind === SyntaxKind.CallExpression) { for (const arg of (node).arguments) { evolvedType = addEvolvingArrayElementType(evolvedType, arg); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 0a298a78d02..551f8b8697e 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2663,6 +2663,7 @@ namespace ts { Anonymous = 1 << 4, // Anonymous Instantiated = 1 << 5, // Instantiated anonymous type ObjectLiteral = 1 << 6, // Originates in an object literal + EvolvingArray = 1 << 7, // Evolving array type } // Properties common to all types @@ -2763,8 +2764,11 @@ namespace ts { export interface AnonymousType extends ObjectType { target?: AnonymousType; // Instantiation target mapper?: TypeMapper; // Instantiation mapper - elementType?: Type; // Element expressions of evolving array type - finalArrayType?: Type; // Final array type of evolving array type + } + + export interface EvolvingArrayType extends ObjectType { + elementType: Type; // Element expressions of evolving array type + finalArrayType?: Type; // Final array type of evolving array type } /* @internal */ From 81383e172f715ec005d0110d4bbf672685f92644 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 20 Oct 2016 15:56:21 -0700 Subject: [PATCH 157/173] add test --- .../comparisonOperatorWithNumericLiteral.ts | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNumericLiteral.ts diff --git a/tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNumericLiteral.ts b/tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNumericLiteral.ts new file mode 100644 index 00000000000..457a324e971 --- /dev/null +++ b/tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNumericLiteral.ts @@ -0,0 +1,42 @@ +type BrandedNum = number & { __numberBrand: any }; +var x : BrandedNum; + +// operator > +x > 0; +x > 0; +x > 0; + +// operator < +x < 0; +x < 0; +x < 0; + +// operator >= +x >= 0; +x >= 0; +x >= 0; + +// operator <= +x <= 0; +x <= 0; +x <= 0; + +// operator == +x == 0; +x == 0; +x == 0; + +// operator != +x != 0; +x != 0; +x != 0; + +// operator === +x === 0; +x === 0; +x === 0; + +// operator !== +x !== 0; +x !== 0; +x !== 0; From 1a41ebf542525847b5f041b0db5b544dc0d93697 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 20 Oct 2016 16:27:02 -0700 Subject: [PATCH 158/173] update baselines --- ...risonOperatorWithNumericLiteral.errors.txt | 58 ++++++++++++++ .../comparisonOperatorWithNumericLiteral.js | 79 +++++++++++++++++++ .../comparisonOperatorWithNumericLiteral.ts | 42 ++++++++++ 3 files changed, 179 insertions(+) create mode 100644 tests/baselines/reference/comparisonOperatorWithNumericLiteral.errors.txt create mode 100644 tests/baselines/reference/comparisonOperatorWithNumericLiteral.js create mode 100644 tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNumericLiteral.ts diff --git a/tests/baselines/reference/comparisonOperatorWithNumericLiteral.errors.txt b/tests/baselines/reference/comparisonOperatorWithNumericLiteral.errors.txt new file mode 100644 index 00000000000..d863ca29090 --- /dev/null +++ b/tests/baselines/reference/comparisonOperatorWithNumericLiteral.errors.txt @@ -0,0 +1,58 @@ +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNumericLiteral.ts(5,1): error TS2365: Operator '>' cannot be applied to types 'BrandedNum' and '0'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNumericLiteral.ts(10,1): error TS2365: Operator '<' cannot be applied to types 'BrandedNum' and '0'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNumericLiteral.ts(15,1): error TS2365: Operator '>=' cannot be applied to types 'BrandedNum' and '0'. +tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNumericLiteral.ts(20,1): error TS2365: Operator '<=' cannot be applied to types 'BrandedNum' and '0'. + + +==== tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNumericLiteral.ts (4 errors) ==== + type BrandedNum = number & { __numberBrand: any }; + var x : BrandedNum; + + // operator > + x > 0; + ~~~~~ +!!! error TS2365: Operator '>' cannot be applied to types 'BrandedNum' and '0'. + x > 0; + x > 0; + + // operator < + x < 0; + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types 'BrandedNum' and '0'. + x < 0; + x < 0; + + // operator >= + x >= 0; + ~~~~~~ +!!! error TS2365: Operator '>=' cannot be applied to types 'BrandedNum' and '0'. + x >= 0; + x >= 0; + + // operator <= + x <= 0; + ~~~~~~ +!!! error TS2365: Operator '<=' cannot be applied to types 'BrandedNum' and '0'. + x <= 0; + x <= 0; + + // operator == + x == 0; + x == 0; + x == 0; + + // operator != + x != 0; + x != 0; + x != 0; + + // operator === + x === 0; + x === 0; + x === 0; + + // operator !== + x !== 0; + x !== 0; + x !== 0; + \ No newline at end of file diff --git a/tests/baselines/reference/comparisonOperatorWithNumericLiteral.js b/tests/baselines/reference/comparisonOperatorWithNumericLiteral.js new file mode 100644 index 00000000000..6f28423d166 --- /dev/null +++ b/tests/baselines/reference/comparisonOperatorWithNumericLiteral.js @@ -0,0 +1,79 @@ +//// [comparisonOperatorWithNumericLiteral.ts] +type BrandedNum = number & { __numberBrand: any }; +var x : BrandedNum; + +// operator > +x > 0; +x > 0; +x > 0; + +// operator < +x < 0; +x < 0; +x < 0; + +// operator >= +x >= 0; +x >= 0; +x >= 0; + +// operator <= +x <= 0; +x <= 0; +x <= 0; + +// operator == +x == 0; +x == 0; +x == 0; + +// operator != +x != 0; +x != 0; +x != 0; + +// operator === +x === 0; +x === 0; +x === 0; + +// operator !== +x !== 0; +x !== 0; +x !== 0; + + +//// [comparisonOperatorWithNumericLiteral.js] +var x; +// operator > +x > 0; +x > 0; +x > 0; +// operator < +x < 0; +x < 0; +x < 0; +// operator >= +x >= 0; +x >= 0; +x >= 0; +// operator <= +x <= 0; +x <= 0; +x <= 0; +// operator == +x == 0; +x == 0; +x == 0; +// operator != +x != 0; +x != 0; +x != 0; +// operator === +x === 0; +x === 0; +x === 0; +// operator !== +x !== 0; +x !== 0; +x !== 0; diff --git a/tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNumericLiteral.ts b/tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNumericLiteral.ts new file mode 100644 index 00000000000..457a324e971 --- /dev/null +++ b/tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithNumericLiteral.ts @@ -0,0 +1,42 @@ +type BrandedNum = number & { __numberBrand: any }; +var x : BrandedNum; + +// operator > +x > 0; +x > 0; +x > 0; + +// operator < +x < 0; +x < 0; +x < 0; + +// operator >= +x >= 0; +x >= 0; +x >= 0; + +// operator <= +x <= 0; +x <= 0; +x <= 0; + +// operator == +x == 0; +x == 0; +x == 0; + +// operator != +x != 0; +x != 0; +x != 0; + +// operator === +x === 0; +x === 0; +x === 0; + +// operator !== +x !== 0; +x !== 0; +x !== 0; From 58d6156c69e08e8479e3102d90cccc34a0e9d832 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 20 Oct 2016 17:00:07 -0700 Subject: [PATCH 159/173] Move ObjectLiteralPatternWithComputedProperties to ObjectFlags --- src/compiler/checker.ts | 10 ++++------ src/compiler/types.ts | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 843a21cbae3..ae99919fabe 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3222,7 +3222,7 @@ namespace ts { result.pattern = pattern; } if (hasComputedProperties) { - result.isObjectLiteralPatternWithComputedProperties = true; + result.objectFlags |= ObjectFlags.ObjectLiteralPatternWithComputedProperties; } return result; } @@ -6734,8 +6734,7 @@ namespace ts { } function hasExcessProperties(source: FreshObjectLiteralType, target: Type, reportErrors: boolean): boolean { - if (maybeTypeOfKind(target, TypeFlags.ObjectType) && - (!(target.flags & TypeFlags.ObjectType) || !(target as ObjectType).isObjectLiteralPatternWithComputedProperties)) { + if (maybeTypeOfKind(target, TypeFlags.ObjectType) && !(getObjectFlags(target) & ObjectFlags.ObjectLiteralPatternWithComputedProperties)) { for (const prop of getPropertiesOfObjectType(source)) { if (!isKnownProperty(target, prop.name)) { if (reportErrors) { @@ -10599,8 +10598,7 @@ namespace ts { patternWithComputedProperties = true; } } - else if (contextualTypeHasPattern && - !(contextualType.flags & TypeFlags.ObjectType && (contextualType as ObjectType).isObjectLiteralPatternWithComputedProperties)) { + else if (contextualTypeHasPattern && !(getObjectFlags(contextualType) & ObjectFlags.ObjectLiteralPatternWithComputedProperties)) { // If object literal is contextually typed by the implied type of a binding pattern, and if the // binding pattern specifies a default value for the property, make the property optional. const impliedProp = getPropertyOfType(contextualType, member.name); @@ -10668,7 +10666,7 @@ namespace ts { result.flags |= TypeFlags.ContainsObjectLiteral | freshObjectLiteralFlag | (typeFlags & TypeFlags.PropagatingFlags); result.objectFlags |= ObjectFlags.ObjectLiteral; if (patternWithComputedProperties) { - result.isObjectLiteralPatternWithComputedProperties = true; + result.objectFlags |= ObjectFlags.ObjectLiteralPatternWithComputedProperties; } if (inDestructuringPattern) { result.pattern = node; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 551f8b8697e..9d6108f27fb 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2664,6 +2664,7 @@ namespace ts { Instantiated = 1 << 5, // Instantiated anonymous type ObjectLiteral = 1 << 6, // Originates in an object literal EvolvingArray = 1 << 7, // Evolving array type + ObjectLiteralPatternWithComputedProperties = 1 << 8, // Object literal pattern with computed properties } // Properties common to all types @@ -2703,7 +2704,6 @@ namespace ts { // Object types (TypeFlags.ObjectType) export interface ObjectType extends Type { objectFlags: ObjectFlags; - isObjectLiteralPatternWithComputedProperties?: boolean; } // Class and interface types (TypeFlags.Class and TypeFlags.Interface) From f05ecec313d8ea00f0023223c01cf92c38d5657c Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 20 Oct 2016 17:28:53 -0700 Subject: [PATCH 160/173] Refactoring a bit more --- src/compiler/checker.ts | 28 ++++++++++++---------------- src/compiler/types.ts | 25 +++++++++++++------------ 2 files changed, 25 insertions(+), 28 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ae99919fabe..49d453c7761 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2195,7 +2195,7 @@ namespace ts { writePunctuation(writer, SyntaxKind.DotToken); appendSymbolNameOnly(type.symbol, writer); } - else if (getObjectFlags(type) & (ObjectFlags.Class | ObjectFlags.Interface) || type.flags & (TypeFlags.Enum | TypeFlags.TypeParameter)) { + else if (getObjectFlags(type) & ObjectFlags.ClassOrInterface || type.flags & (TypeFlags.Enum | TypeFlags.TypeParameter)) { // The specified symbol flags need to be reinterpreted as type flags buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, SymbolFlags.Type, SymbolFormatFlags.None, nextFlags); } @@ -3705,7 +3705,7 @@ namespace ts { if (baseType === unknownType) { return; } - if (!(getObjectFlags(getTargetType(baseType)) & (ObjectFlags.Class | ObjectFlags.Interface))) { + if (!(getObjectFlags(getTargetType(baseType)) & ObjectFlags.ClassOrInterface)) { error(baseTypeNode.expression, Diagnostics.Base_constructor_return_type_0_is_not_a_class_or_interface_type, typeToString(baseType)); return; } @@ -3741,7 +3741,7 @@ namespace ts { for (const node of getInterfaceBaseTypeNodes(declaration)) { const baseType = getTypeFromTypeNode(node); if (baseType !== unknownType) { - if (getObjectFlags(getTargetType(baseType)) & (ObjectFlags.Class | ObjectFlags.Interface)) { + if (getObjectFlags(getTargetType(baseType)) & ObjectFlags.ClassOrInterface) { if (type !== baseType && !hasBaseType(baseType, type)) { if (type.resolvedBaseTypes === emptyArray) { type.resolvedBaseTypes = [baseType]; @@ -4373,7 +4373,7 @@ namespace ts { if ((type).objectFlags & ObjectFlags.Reference) { resolveTypeReferenceMembers(type); } - else if ((type).objectFlags & (ObjectFlags.Class | ObjectFlags.Interface)) { + else if ((type).objectFlags & ObjectFlags.ClassOrInterface) { resolveClassOrInterfaceMembers(type); } else if ((type).objectFlags & ObjectFlags.Anonymous) { @@ -8575,10 +8575,6 @@ namespace ts { return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType])); } - function isEvolvingArrayType(type: Type) { - return !!(getObjectFlags(type) & ObjectFlags.EvolvingArray); - } - function createFinalArrayType(elementType: Type) { return elementType.flags & TypeFlags.Never ? autoArrayType : @@ -8593,18 +8589,18 @@ namespace ts { } function finalizeEvolvingArrayType(type: Type): Type { - return isEvolvingArrayType(type) ? getFinalArrayType(type) : type; + return getObjectFlags(type) & ObjectFlags.EvolvingArray ? getFinalArrayType(type) : type; } function getElementTypeOfEvolvingArrayType(type: Type) { - return isEvolvingArrayType(type) ? (type).elementType : neverType; + return getObjectFlags(type) & ObjectFlags.EvolvingArray ? (type).elementType : neverType; } function isEvolvingArrayTypeList(types: Type[]) { let hasEvolvingArrayType = false; for (const t of types) { if (!(t.flags & TypeFlags.Never)) { - if (!isEvolvingArrayType(t)) { + if (!(getObjectFlags(t) & ObjectFlags.EvolvingArray)) { return false; } hasEvolvingArrayType = true; @@ -8655,7 +8651,7 @@ namespace ts { // we give type 'any[]' to 'x' instead of using the type determined by control flow analysis such that operations // on empty arrays are possible without implicit any errors and new element types can be inferred without // type mismatch errors. - const resultType = isEvolvingArrayType(evolvedType) && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); + const resultType = getObjectFlags(evolvedType) & ObjectFlags.EvolvingArray && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); if (reference.parent.kind === SyntaxKind.NonNullExpression && getTypeWithFacts(resultType, TypeFacts.NEUndefinedOrNull).flags & TypeFlags.Never) { return declaredType; } @@ -8768,7 +8764,7 @@ namespace ts { if (isMatchingReference(reference, getReferenceCandidate(expr))) { const flowType = getTypeAtFlowNode(flow.antecedent); const type = getTypeFromFlowType(flowType); - if (isEvolvingArrayType(type)) { + if (getObjectFlags(type) & ObjectFlags.EvolvingArray) { let evolvedType = type; if (node.kind === SyntaxKind.CallExpression) { for (const arg of (node).arguments) { @@ -11249,7 +11245,7 @@ namespace ts { } // TODO: why is the first part of this check here? - if (!(getObjectFlags(getTargetType(type)) & (ObjectFlags.Class | ObjectFlags.Interface) && hasBaseType(type, enclosingClass))) { + if (!(getObjectFlags(getTargetType(type)) & ObjectFlags.ClassOrInterface && hasBaseType(type, enclosingClass))) { error(errorNode, Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); return false; } @@ -17174,8 +17170,8 @@ namespace ts { if (produceDiagnostics) { const t = getTypeFromTypeNode(typeRefNode); if (t !== unknownType) { - const declaredType = (getObjectFlags(t) & ObjectFlags.Reference) ? (t).target : t; - if (getObjectFlags(declaredType) & (ObjectFlags.Class | ObjectFlags.Interface)) { + const declaredType = getObjectFlags(t) & ObjectFlags.Reference ? (t).target : t; + if (getObjectFlags(declaredType) & ObjectFlags.ClassOrInterface) { checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(t, type.thisType), node.name || node, Diagnostics.Class_0_incorrectly_implements_interface_1); } else { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 9d6108f27fb..ed4d55c584b 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2655,18 +2655,6 @@ namespace ts { export type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; - export const enum ObjectFlags { - Class = 1 << 0, // Class - Interface = 1 << 1, // Interface - Reference = 1 << 2, // Generic type reference - Tuple = 1 << 3, // Synthesized generic tuple type - Anonymous = 1 << 4, // Anonymous - Instantiated = 1 << 5, // Instantiated anonymous type - ObjectLiteral = 1 << 6, // Originates in an object literal - EvolvingArray = 1 << 7, // Evolving array type - ObjectLiteralPatternWithComputedProperties = 1 << 8, // Object literal pattern with computed properties - } - // Properties common to all types export interface Type { flags: TypeFlags; // Flags @@ -2701,6 +2689,19 @@ namespace ts { baseType: EnumType & UnionType; // Base enum type } + export const enum ObjectFlags { + Class = 1 << 0, // Class + Interface = 1 << 1, // Interface + Reference = 1 << 2, // Generic type reference + Tuple = 1 << 3, // Synthesized generic tuple type + Anonymous = 1 << 4, // Anonymous + Instantiated = 1 << 5, // Instantiated anonymous type + ObjectLiteral = 1 << 6, // Originates in an object literal + EvolvingArray = 1 << 7, // Evolving array type + ObjectLiteralPatternWithComputedProperties = 1 << 8, // Object literal pattern with computed properties + ClassOrInterface = Class | Interface + } + // Object types (TypeFlags.ObjectType) export interface ObjectType extends Type { objectFlags: ObjectFlags; From a477d1f7bbdea99ebf022e0b99f558d4c6add24f Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Thu, 20 Oct 2016 21:15:47 -0700 Subject: [PATCH 161/173] Merge pull request #11764 from Microsoft/vladima/11744 watch configuration files if they exist even if they cannot be parsed --- src/harness/unittests/typingsInstaller.ts | 69 +++++++++++++++---- .../typingsInstaller/typingsInstaller.ts | 6 +- src/services/jsTyping.ts | 4 +- 3 files changed, 63 insertions(+), 16 deletions(-) diff --git a/src/harness/unittests/typingsInstaller.ts b/src/harness/unittests/typingsInstaller.ts index 323d8c0ed9e..4a0021e6ad4 100644 --- a/src/harness/unittests/typingsInstaller.ts +++ b/src/harness/unittests/typingsInstaller.ts @@ -569,7 +569,7 @@ namespace ts.projectSystem { } executeRequest(requestKind: TI.RequestKind, _requestId: number, args: string[], _cwd: string, cb: TI.RequestCompletedAction): void { if (requestKind === TI.NpmInstallRequest) { - let typingFiles: (FileOrFolder & { typings: string}) [] = []; + let typingFiles: (FileOrFolder & { typings: string })[] = []; if (args.indexOf("@types/commander") >= 0) { typingFiles = [commander, jquery, lodash, cordova]; } @@ -591,7 +591,7 @@ namespace ts.projectSystem { projectFileName: projectFileName1, options: { allowJS: true, moduleResolution: ModuleResolutionKind.NodeJs }, rootFiles: [toExternalFile(lodashJs.path), toExternalFile(commanderJs.path), toExternalFile(file3.path)], - typingOptions: { include: ["jquery", "cordova" ] } + typingOptions: { include: ["jquery", "cordova"] } }); installer.checkPendingCommands([TI.NpmViewRequest, TI.NpmViewRequest, TI.NpmViewRequest]); @@ -626,7 +626,7 @@ namespace ts.projectSystem { installer.executePendingCommands(); checkProjectActualFiles(p1, [lodashJs.path, commanderJs.path, file3.path, commander.path, jquery.path, lodash.path, cordova.path]); - checkProjectActualFiles(p2, [file3.path, grunt.path, gulp.path ]); + checkProjectActualFiles(p2, [file3.path, grunt.path, gulp.path]); }); it("configured projects discover from node_modules", () => { @@ -687,10 +687,10 @@ namespace ts.projectSystem { const bowerJson = { path: "/bower.json", content: JSON.stringify({ - "dependencies": { - "jquery": "^3.1.0" - } - }) + "dependencies": { + "jquery": "^3.1.0" + } + }) }; const jqueryDTS = { path: "/tmp/node_modules/@types/jquery/index.d.ts", @@ -720,26 +720,69 @@ namespace ts.projectSystem { checkNumberOfProjects(projectService, { configuredProjects: 1 }); checkProjectActualFiles(p, [app.path, jqueryDTS.path]); }); + + it("Malformed package.json should be watched", () => { + const f = { + path: "/a/b/app.js", + content: "var x = require('commander')" + }; + const brokenPackageJson = { + path: "/a/b/package.json", + content: `{ "dependencies": { "co } }` + }; + const fixedPackageJson = { + path: brokenPackageJson.path, + content: `{ "dependencies": { "commander": "0.0.2" } }` + }; + const cachePath = "/a/cache/"; + const commander = { + path: cachePath + "node_modules/@types/commander/index.d.ts", + content: "export let x: number" + }; + const host = createServerHost([f, brokenPackageJson]); + const installer = new (class extends Installer { + constructor() { + super(host, { globalTypingsCacheLocation: cachePath }); + } + executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: server.typingsInstaller.RequestCompletedAction) { + const installedTypings = ["@types/commander"]; + const typingFiles = [commander]; + executeCommand(this, host, installedTypings, typingFiles, requestKind, cb); + } + })(); + const service = createProjectService(host, { typingsInstaller: installer }); + service.openClientFile(f.path); + + installer.checkPendingCommands([]); + + host.reloadFS([f, fixedPackageJson]); + host.triggerFileWatcherCallback(fixedPackageJson.path, /*removed*/ false); + // expected one view and one install request + installer.installAll([TI.NpmViewRequest], [TI.NpmInstallRequest]); + + service.checkNumberOfProjects({ inferredProjects: 1 }); + checkProjectActualFiles(service.inferredProjects[0], [f.path, commander.path]); + }); }); describe("Validate package name:", () => { - it ("name cannot be too long", () => { + it("name cannot be too long", () => { let packageName = "a"; for (let i = 0; i < 8; i++) { packageName += packageName; } assert.equal(TI.validatePackageName(packageName), TI.PackageNameValidationResult.NameTooLong); }); - it ("name cannot start with dot", () => { + it("name cannot start with dot", () => { assert.equal(TI.validatePackageName(".foo"), TI.PackageNameValidationResult.NameStartsWithDot); }); - it ("name cannot start with underscore", () => { + it("name cannot start with underscore", () => { assert.equal(TI.validatePackageName("_foo"), TI.PackageNameValidationResult.NameStartsWithUnderscore); }); - it ("scoped packages not supported", () => { + it("scoped packages not supported", () => { assert.equal(TI.validatePackageName("@scope/bar"), TI.PackageNameValidationResult.ScopedPackagesNotSupported); }); - it ("non URI safe characters are not supported", () => { + it("non URI safe characters are not supported", () => { assert.equal(TI.validatePackageName(" scope "), TI.PackageNameValidationResult.NameContainsNonURISafeCharacters); assert.equal(TI.validatePackageName("; say ‘Hello from TypeScript!’ #"), TI.PackageNameValidationResult.NameContainsNonURISafeCharacters); assert.equal(TI.validatePackageName("a/b/c"), TI.PackageNameValidationResult.NameContainsNonURISafeCharacters); @@ -747,7 +790,7 @@ namespace ts.projectSystem { }); describe("Invalid package names", () => { - it ("should not be installed", () => { + it("should not be installed", () => { const f1 = { path: "/a/b/app.js", content: "let x = 1" diff --git a/src/server/typingsInstaller/typingsInstaller.ts b/src/server/typingsInstaller/typingsInstaller.ts index 2851da3a64d..21f85c241a6 100644 --- a/src/server/typingsInstaller/typingsInstaller.ts +++ b/src/server/typingsInstaller/typingsInstaller.ts @@ -381,8 +381,10 @@ namespace ts.server.typingsInstaller { if (this.log.isEnabled()) { this.log.writeLine(`Got FS notification for ${f}, handler is already invoked '${isInvoked}'`); } - this.sendResponse({ projectName: projectName, kind: "invalidate" }); - isInvoked = true; + if (!isInvoked) { + this.sendResponse({ projectName: projectName, kind: "invalidate" }); + isInvoked = true; + } }); watchers.push(w); } diff --git a/src/services/jsTyping.ts b/src/services/jsTyping.ts index 96654ec6702..561e0110cda 100644 --- a/src/services/jsTyping.ts +++ b/src/services/jsTyping.ts @@ -135,10 +135,12 @@ namespace ts.JsTyping { * Get the typing info from common package manager json files like package.json or bower.json */ function getTypingNamesFromJson(jsonPath: string, filesToWatch: string[]) { + if (host.fileExists(jsonPath)) { + filesToWatch.push(jsonPath); + } const result = readConfigFile(jsonPath, (path: string) => host.readFile(path)); if (result.config) { const jsonConfig: PackageJson = result.config; - filesToWatch.push(jsonPath); if (jsonConfig.dependencies) { mergeTypings(getOwnKeys(jsonConfig.dependencies)); } From a645b6e4ddd12db0e2298a6b8c8c0d57000be45e Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Fri, 21 Oct 2016 14:37:23 -0700 Subject: [PATCH 162/173] Allow unused locals in for in or for of that start with _ Fixes #11734 --- src/compiler/checker.ts | 20 ++++++++++++-- ...sedLocalsStartingWithUnderscore.errors.txt | 18 +++++++++++++ .../unusedLocalsStartingWithUnderscore.js | 27 +++++++++++++++++++ .../unusedLocalsStartingWithUnderscore.ts | 13 +++++++++ 4 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 tests/baselines/reference/unusedLocalsStartingWithUnderscore.errors.txt create mode 100644 tests/baselines/reference/unusedLocalsStartingWithUnderscore.js create mode 100644 tests/cases/compiler/unusedLocalsStartingWithUnderscore.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 369d61ce484..4fde6a321a4 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -15836,15 +15836,31 @@ namespace ts { } } else if (compilerOptions.noUnusedLocals) { - forEach(local.declarations, d => error(d.name || d, Diagnostics._0_is_declared_but_never_used, local.name)); + forEach(local.declarations, d => errorUnusedLocal(d.name || d, local.name)); } } } } } + function errorUnusedLocal(node: Node, name: string) { + if (isIdentifierThatStartsWithUnderScore(node)) { + const declaration = getRootDeclaration(node.parent); + if (declaration.kind === SyntaxKind.VariableDeclaration && + (declaration.parent.parent.kind === SyntaxKind.ForInStatement || + declaration.parent.parent.kind === SyntaxKind.ForOfStatement)) { + return; + } + } + error(node, Diagnostics._0_is_declared_but_never_used, name); + } + function parameterNameStartsWithUnderscore(parameter: ParameterDeclaration) { - return parameter.name && parameter.name.kind === SyntaxKind.Identifier && (parameter.name).text.charCodeAt(0) === CharacterCodes._; + return parameter.name && isIdentifierThatStartsWithUnderScore(parameter.name); + } + + function isIdentifierThatStartsWithUnderScore(node: Node) { + return node.kind === SyntaxKind.Identifier && (node).text.charCodeAt(0) === CharacterCodes._; } function checkUnusedClassMembers(node: ClassDeclaration | ClassExpression): void { diff --git a/tests/baselines/reference/unusedLocalsStartingWithUnderscore.errors.txt b/tests/baselines/reference/unusedLocalsStartingWithUnderscore.errors.txt new file mode 100644 index 00000000000..ae72b6fcdd3 --- /dev/null +++ b/tests/baselines/reference/unusedLocalsStartingWithUnderscore.errors.txt @@ -0,0 +1,18 @@ +tests/cases/compiler/unusedLocalsStartingWithUnderscore.ts(7,9): error TS6133: '_' is declared but never used. + + +==== tests/cases/compiler/unusedLocalsStartingWithUnderscore.ts (1 errors) ==== + + for (const _ of []) { } + + for (const _ in []) { } + + namespace M { + let _; + ~ +!!! error TS6133: '_' is declared but never used. + for (const _ of []) { } + + for (const _ in []) { } + } + \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsStartingWithUnderscore.js b/tests/baselines/reference/unusedLocalsStartingWithUnderscore.js new file mode 100644 index 00000000000..cca16a97824 --- /dev/null +++ b/tests/baselines/reference/unusedLocalsStartingWithUnderscore.js @@ -0,0 +1,27 @@ +//// [unusedLocalsStartingWithUnderscore.ts] + +for (const _ of []) { } + +for (const _ in []) { } + +namespace M { + let _; + for (const _ of []) { } + + for (const _ in []) { } +} + + +//// [unusedLocalsStartingWithUnderscore.js] +for (var _i = 0, _a = []; _i < _a.length; _i++) { + var _ = _a[_i]; +} +for (var _ in []) { } +var M; +(function (M) { + var _; + for (var _i = 0, _a = []; _i < _a.length; _i++) { + var _1 = _a[_i]; + } + for (var _2 in []) { } +})(M || (M = {})); diff --git a/tests/cases/compiler/unusedLocalsStartingWithUnderscore.ts b/tests/cases/compiler/unusedLocalsStartingWithUnderscore.ts new file mode 100644 index 00000000000..4e6930a6282 --- /dev/null +++ b/tests/cases/compiler/unusedLocalsStartingWithUnderscore.ts @@ -0,0 +1,13 @@ +//@noUnusedLocals:true + +for (const _ of []) { } + +for (const _ in []) { } + +namespace M { + let _; + for (const _ of []) { } + + for (const _ in []) { } +} + \ No newline at end of file From acd574066bef47df1ad8f14d6e29d194b1041eb7 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Fri, 21 Oct 2016 16:15:19 -0700 Subject: [PATCH 163/173] Add test for #11166 --- .../nounusedTypeParameterConstraint.errors.txt | 12 ++++++++++++ .../reference/nounusedTypeParameterConstraint.js | 14 ++++++++++++++ .../compiler/nounusedTypeParameterConstraint.ts | 8 ++++++++ 3 files changed, 34 insertions(+) create mode 100644 tests/baselines/reference/nounusedTypeParameterConstraint.errors.txt create mode 100644 tests/baselines/reference/nounusedTypeParameterConstraint.js create mode 100644 tests/cases/compiler/nounusedTypeParameterConstraint.ts diff --git a/tests/baselines/reference/nounusedTypeParameterConstraint.errors.txt b/tests/baselines/reference/nounusedTypeParameterConstraint.errors.txt new file mode 100644 index 00000000000..a5797b44d92 --- /dev/null +++ b/tests/baselines/reference/nounusedTypeParameterConstraint.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/test.ts(1,10): error TS6133: 'IEventSourcedEntity' is declared but never used. + + +==== tests/cases/compiler/bar.ts (0 errors) ==== + + export interface IEventSourcedEntity { } + +==== tests/cases/compiler/test.ts (1 errors) ==== + import { IEventSourcedEntity } from "./bar"; + ~~~~~~~~~~~~~~~~~~~ +!!! error TS6133: 'IEventSourcedEntity' is declared but never used. + export type DomainEntityConstructor = { new(): TEntity; }; \ No newline at end of file diff --git a/tests/baselines/reference/nounusedTypeParameterConstraint.js b/tests/baselines/reference/nounusedTypeParameterConstraint.js new file mode 100644 index 00000000000..aa403187f7a --- /dev/null +++ b/tests/baselines/reference/nounusedTypeParameterConstraint.js @@ -0,0 +1,14 @@ +//// [tests/cases/compiler/nounusedTypeParameterConstraint.ts] //// + +//// [bar.ts] + +export interface IEventSourcedEntity { } + +//// [test.ts] +import { IEventSourcedEntity } from "./bar"; +export type DomainEntityConstructor = { new(): TEntity; }; + +//// [bar.js] +"use strict"; +//// [test.js] +"use strict"; diff --git a/tests/cases/compiler/nounusedTypeParameterConstraint.ts b/tests/cases/compiler/nounusedTypeParameterConstraint.ts new file mode 100644 index 00000000000..d2c3a1677ee --- /dev/null +++ b/tests/cases/compiler/nounusedTypeParameterConstraint.ts @@ -0,0 +1,8 @@ +//@noUnusedLocals:true + +//@filename: bar.ts +export interface IEventSourcedEntity { } + +//@filename: test.ts +import { IEventSourcedEntity } from "./bar"; +export type DomainEntityConstructor = { new(): TEntity; }; \ No newline at end of file From 45ba67d36f8ea2f59e746d60db1cd9c868eb9331 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Fri, 21 Oct 2016 16:15:19 -0700 Subject: [PATCH 164/173] Remove unused locals/parameters from webTestServer.ts --- tests/webTestServer.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/webTestServer.ts b/tests/webTestServer.ts index 97027dfdd49..3d23ef3e961 100644 --- a/tests/webTestServer.ts +++ b/tests/webTestServer.ts @@ -128,7 +128,7 @@ function dir(dirPath: string, spec?: string, options?: any) { // fs.rmdirSync won't delete directories with files in it function deleteFolderRecursive(dirPath: string) { if (fs.existsSync(dirPath)) { - fs.readdirSync(dirPath).forEach((file, index) => { + fs.readdirSync(dirPath).forEach((file) => { const curPath = path.join(path, file); if (fs.statSync(curPath).isDirectory()) { // recurse deleteFolderRecursive(curPath); @@ -141,7 +141,7 @@ function deleteFolderRecursive(dirPath: string) { } }; -function writeFile(path: string, data: any, opts: { recursive: boolean }) { +function writeFile(path: string, data: any) { ensureDirectoriesExist(getDirectoryPath(path)); fs.writeFileSync(path, data); } @@ -208,7 +208,7 @@ enum RequestType { Unknown } -function getRequestOperation(req: http.ServerRequest, filename: string) { +function getRequestOperation(req: http.ServerRequest) { if (req.method === "GET" && req.url.indexOf("?") === -1) { if (req.url.indexOf(".") !== -1) return RequestType.GetFile; else return RequestType.GetDir; @@ -258,7 +258,7 @@ function handleRequestOperation(req: http.ServerRequest, res: http.ServerRespons break; case RequestType.WriteFile: processPost(req, res, (data) => { - writeFile(reqPath, data, { recursive: true }); + writeFile(reqPath, data); }); send(ResponseCode.Success, res, undefined); break; @@ -306,7 +306,7 @@ http.createServer((req: http.ServerRequest, res: http.ServerResponse) => { log(`${req.method} ${req.url}`); const uri = url.parse(req.url).pathname; const reqPath = path.join(process.cwd(), uri); - const operation = getRequestOperation(req, reqPath); + const operation = getRequestOperation(req); handleRequestOperation(req, res, operation, reqPath); }).listen(port); From 7facab08cbd529605ccb406a1b062fd0aeaf7672 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 21 Oct 2016 16:32:28 -0700 Subject: [PATCH 165/173] Rename TypeFlags.ObjectType to TypeFlags.Object --- src/compiler/checker.ts | 56 +++++++++++++++++------------------ src/compiler/types.ts | 6 ++-- src/services/services.ts | 2 +- src/services/symbolDisplay.ts | 2 +- 4 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 49d453c7761..2f2bc4baef7 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -539,7 +539,7 @@ namespace ts { } function getObjectFlags(type: Type): ObjectFlags { - return type.flags & TypeFlags.ObjectType ? (type).objectFlags : 0; + return type.flags & TypeFlags.Object ? (type).objectFlags : 0; } function isGlobalSourceFile(node: Node) { @@ -1594,7 +1594,7 @@ namespace ts { } function createObjectType(objectFlags: ObjectFlags, symbol?: Symbol): ObjectType { - const type = createType(TypeFlags.ObjectType); + const type = createType(TypeFlags.Object); type.objectFlags = objectFlags; type.symbol = symbol; return type; @@ -3600,7 +3600,7 @@ namespace ts { } function isConstructorType(type: Type): boolean { - return type.flags & TypeFlags.ObjectType && getSignaturesOfType(type, SignatureKind.Construct).length > 0; + return type.flags & TypeFlags.Object && getSignaturesOfType(type, SignatureKind.Construct).length > 0; } function getBaseTypeNodeOfClass(type: InterfaceType): ExpressionWithTypeArguments { @@ -3637,7 +3637,7 @@ namespace ts { return unknownType; } const baseConstructorType = checkExpression(baseTypeNode.expression); - if (baseConstructorType.flags & TypeFlags.ObjectType) { + if (baseConstructorType.flags & TypeFlags.Object) { // Resolving the members of a class requires us to resolve the base class of that class. // We force resolution here such that we catch circularities now. resolveStructuredTypeMembers(baseConstructorType); @@ -3678,7 +3678,7 @@ namespace ts { function resolveBaseTypesOfClass(type: InterfaceType): void { type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; const baseConstructorType = getBaseConstructorTypeOfClass(type); - if (!(baseConstructorType.flags & TypeFlags.ObjectType)) { + if (!(baseConstructorType.flags & TypeFlags.Object)) { return; } const baseTypeNode = getBaseTypeNodeOfClass(type); @@ -4350,7 +4350,7 @@ namespace ts { constructSignatures = getDefaultConstructSignatures(classType); } const baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & TypeFlags.ObjectType) { + if (baseConstructorType.flags & TypeFlags.Object) { members = createSymbolTable(getNamedMembers(members)); addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType)); } @@ -4369,7 +4369,7 @@ namespace ts { function resolveStructuredTypeMembers(type: StructuredType): ResolvedType { if (!(type).members) { - if (type.flags & TypeFlags.ObjectType) { + if (type.flags & TypeFlags.Object) { if ((type).objectFlags & ObjectFlags.Reference) { resolveTypeReferenceMembers(type); } @@ -4392,7 +4392,7 @@ namespace ts { /** Return properties of an object type or an empty array for other types */ function getPropertiesOfObjectType(type: Type): Symbol[] { - if (type.flags & TypeFlags.ObjectType) { + if (type.flags & TypeFlags.Object) { return resolveStructuredTypeMembers(type).properties; } return emptyArray; @@ -4401,7 +4401,7 @@ namespace ts { /** If the given type is an object type and that type has a property by the given name, * return the symbol for that property. Otherwise return undefined. */ function getPropertyOfObjectType(type: Type, name: string): Symbol { - if (type.flags & TypeFlags.ObjectType) { + if (type.flags & TypeFlags.Object) { const resolved = resolveStructuredTypeMembers(type); const symbol = resolved.members[name]; if (symbol && symbolIsValue(symbol)) { @@ -4574,7 +4574,7 @@ namespace ts { */ function getPropertyOfType(type: Type, name: string): Symbol { type = getApparentType(type); - if (type.flags & TypeFlags.ObjectType) { + if (type.flags & TypeFlags.Object) { const resolved = resolveStructuredTypeMembers(type); const symbol = resolved.members[name]; if (symbol && symbolIsValue(symbol)) { @@ -5273,7 +5273,7 @@ namespace ts { return arity ? emptyGenericType : emptyObjectType; } const type = getDeclaredTypeOfSymbol(symbol); - if (!(type.flags & TypeFlags.ObjectType)) { + if (!(type.flags & TypeFlags.Object)) { error(getTypeDeclaration(symbol), Diagnostics.Global_type_0_must_be_a_class_or_interface_type, symbol.name); return arity ? emptyGenericType : emptyObjectType; } @@ -5453,7 +5453,7 @@ namespace ts { const len = typeSet.length; const index = len && type.id > typeSet[len - 1].id ? ~len : binarySearchTypes(typeSet, type); if (index < 0) { - if (!(flags & TypeFlags.ObjectType && (type).objectFlags & ObjectFlags.Anonymous && + if (!(flags & TypeFlags.Object && (type).objectFlags & ObjectFlags.Anonymous && type.symbol && type.symbol.flags & (SymbolFlags.Function | SymbolFlags.Method) && containsIdenticalType(typeSet, type))) { typeSet.splice(~index, 0, type); } @@ -6060,7 +6060,7 @@ namespace ts { if (type.flags & TypeFlags.TypeParameter) { return mapper(type); } - if (type.flags & TypeFlags.ObjectType) { + if (type.flags & TypeFlags.Object) { if ((type).objectFlags & ObjectFlags.Anonymous) { // If the anonymous type originates in a declaration of a function, method, class, or // interface, in an object type literal, or in an object literal expression, we may need @@ -6147,7 +6147,7 @@ namespace ts { } function getTypeWithoutSignatures(type: Type): Type { - if (type.flags & TypeFlags.ObjectType) { + if (type.flags & TypeFlags.Object) { const resolved = resolveStructuredTypeMembers(type); if (resolved.constructSignatures.length) { const result = createObjectType(ObjectFlags.Anonymous, type.symbol); @@ -6457,7 +6457,7 @@ namespace ts { if (source === target || relation !== identityRelation && isSimpleTypeRelatedTo(source, target, relation)) { return true; } - if (source.flags & TypeFlags.ObjectType && target.flags & TypeFlags.ObjectType) { + if (source.flags & TypeFlags.Object && target.flags & TypeFlags.Object) { const id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; const related = relation[id]; if (related !== undefined) { @@ -6657,7 +6657,7 @@ namespace ts { // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates // to X. Failing both of those we want to check if the aggregation of A and B's members structurally // relates to X. Thus, we include intersection types on the source side here. - if (apparentSource.flags & (TypeFlags.ObjectType | TypeFlags.Intersection) && target.flags & TypeFlags.ObjectType) { + if (apparentSource.flags & (TypeFlags.Object | TypeFlags.Intersection) && target.flags & TypeFlags.Object) { // Report structural errors only if we haven't reported any errors yet const reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !(source.flags & TypeFlags.Primitive); if (result = objectTypeRelatedTo(apparentSource, source, target, reportStructuralErrors)) { @@ -6668,10 +6668,10 @@ namespace ts { } if (reportErrors) { - if (source.flags & TypeFlags.ObjectType && target.flags & TypeFlags.Primitive) { + if (source.flags & TypeFlags.Object && target.flags & TypeFlags.Primitive) { tryElaborateErrorsForPrimitivesAndObjects(source, target); } - else if (source.symbol && source.flags & TypeFlags.ObjectType && globalObjectType === source) { + else if (source.symbol && source.flags & TypeFlags.Object && globalObjectType === source) { reportError(Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead); } reportRelationError(headMessage, source, target); @@ -6681,7 +6681,7 @@ namespace ts { function isIdenticalTo(source: Type, target: Type): Ternary { let result: Ternary; - if (source.flags & TypeFlags.ObjectType && target.flags & TypeFlags.ObjectType) { + if (source.flags & TypeFlags.Object && target.flags & TypeFlags.Object) { if (getObjectFlags(source) & ObjectFlags.Reference && getObjectFlags(target) & ObjectFlags.Reference && (source).target === (target).target) { // We have type references to same target type, see if all type arguments are identical if (result = typeArgumentsRelatedTo(source, target, /*reportErrors*/ false)) { @@ -6706,7 +6706,7 @@ namespace ts { // index signatures, or if the property is actually declared in the object type. In a union or intersection // type, a property is considered known if it is known in any constituent type. function isKnownProperty(type: Type, name: string): boolean { - if (type.flags & TypeFlags.ObjectType) { + if (type.flags & TypeFlags.Object) { const resolved = resolveStructuredTypeMembers(type); if ((relation === assignableRelation || relation === comparableRelation) && (type === globalObjectType || isEmptyObjectType(resolved)) || resolved.stringIndexInfo || @@ -6734,7 +6734,7 @@ namespace ts { } function hasExcessProperties(source: FreshObjectLiteralType, target: Type, reportErrors: boolean): boolean { - if (maybeTypeOfKind(target, TypeFlags.ObjectType) && !(getObjectFlags(target) & ObjectFlags.ObjectLiteralPatternWithComputedProperties)) { + if (maybeTypeOfKind(target, TypeFlags.Object) && !(getObjectFlags(target) & ObjectFlags.ObjectLiteralPatternWithComputedProperties)) { for (const prop of getPropertiesOfObjectType(source)) { if (!isKnownProperty(target, prop.name)) { if (reportErrors) { @@ -7007,7 +7007,7 @@ namespace ts { } function propertiesIdenticalTo(source: Type, target: Type): Ternary { - if (!(source.flags & TypeFlags.ObjectType && target.flags & TypeFlags.ObjectType)) { + if (!(source.flags & TypeFlags.Object && target.flags & TypeFlags.Object)) { return Ternary.False; } const sourceProperties = getPropertiesOfObjectType(source); @@ -7903,7 +7903,7 @@ namespace ts { } else { source = getApparentType(source); - if (source.flags & TypeFlags.ObjectType) { + if (source.flags & TypeFlags.Object) { if (isInProcess(source, target)) { return; } @@ -8295,7 +8295,7 @@ namespace ts { type === falseType ? TypeFacts.FalseStrictFacts : TypeFacts.TrueStrictFacts : type === falseType ? TypeFacts.FalseFacts : TypeFacts.TrueFacts; } - if (flags & TypeFlags.ObjectType) { + if (flags & TypeFlags.Object) { return isFunctionObjectType(type) ? strictNullChecks ? TypeFacts.FunctionStrictFacts : TypeFacts.FunctionFacts : strictNullChecks ? TypeFacts.ObjectStrictFacts : TypeFacts.ObjectFacts; @@ -11732,7 +11732,7 @@ namespace ts { // If type has a single call signature and no other members, return that signature. Otherwise, return undefined. function getSingleCallSignature(type: Type): Signature { - if (type.flags & TypeFlags.ObjectType) { + if (type.flags & TypeFlags.Object) { const resolved = resolveStructuredTypeMembers(type); if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && resolved.properties.length === 0 && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { @@ -13571,7 +13571,7 @@ namespace ts { if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, TypeFlags.StringLike | TypeFlags.NumberLike | TypeFlags.ESSymbol)) { error(left, Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, TypeFlags.ObjectType | TypeFlags.TypeParameter)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, TypeFlags.Object | TypeFlags.TypeParameter)) { error(right, Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } return booleanType; @@ -16478,7 +16478,7 @@ namespace ts { const rightType = checkNonNullExpression(node.expression); // unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved // in this case error about missing name is already reported - do not report extra one - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, TypeFlags.ObjectType | TypeFlags.TypeParameter)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, TypeFlags.Object | TypeFlags.TypeParameter)) { error(node.expression, Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter); } @@ -19245,7 +19245,7 @@ namespace ts { } function isFunctionType(type: Type): boolean { - return type.flags & TypeFlags.ObjectType && getSignaturesOfType(type, SignatureKind.Call).length > 0; + return type.flags & TypeFlags.Object && getSignaturesOfType(type, SignatureKind.Call).length > 0; } function getTypeReferenceSerializationKind(typeName: EntityName, location?: Node): TypeReferenceSerializationKind { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index ed4d55c584b..f9ec3e9f268 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2612,7 +2612,7 @@ namespace ts { Null = 1 << 12, Never = 1 << 13, // Never type TypeParameter = 1 << 14, // Type parameter - ObjectType = 1 << 15, // Object type + Object = 1 << 15, // Object type Union = 1 << 16, // Union (T | U) Intersection = 1 << 17, // Intersection (T & U) /* @internal */ @@ -2640,13 +2640,13 @@ namespace ts { BooleanLike = Boolean | BooleanLiteral, EnumLike = Enum | EnumLiteral, UnionOrIntersection = Union | Intersection, - StructuredType = ObjectType | Union | Intersection, + StructuredType = Object | Union | Intersection, StructuredOrTypeParameter = StructuredType | TypeParameter, // 'Narrowable' types are types where narrowing actually narrows. // This *should* be every type other than null, undefined, void, and never Narrowable = Any | StructuredType | TypeParameter | StringLike | NumberLike | BooleanLike | ESSymbol, - NotUnionOrUnit = Any | ESSymbol | ObjectType, + NotUnionOrUnit = Any | ESSymbol | Object, /* @internal */ RequiresWidening = ContainsWideningType | ContainsObjectLiteral, /* @internal */ diff --git a/src/services/services.ts b/src/services/services.ts index a562aa44bfd..64c9f04370f 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -382,7 +382,7 @@ namespace ts { return this.checker.getIndexTypeOfType(this, IndexKind.Number); } getBaseTypes(): ObjectType[] { - return this.flags & TypeFlags.ObjectType && this.objectFlags & (ObjectFlags.Class | ObjectFlags.Interface) + return this.flags & TypeFlags.Object && this.objectFlags & (ObjectFlags.Class | ObjectFlags.Interface) ? this.checker.getBaseTypes(this) : undefined; } diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts index 37753547768..516b5d7fbc5 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -173,7 +173,7 @@ namespace ts.SymbolDisplay { displayParts.push(keywordPart(SyntaxKind.NewKeyword)); displayParts.push(spacePart()); } - if (!(type.flags & TypeFlags.ObjectType && (type).objectFlags & ObjectFlags.Anonymous) && type.symbol) { + if (!(type.flags & TypeFlags.Object && (type).objectFlags & ObjectFlags.Anonymous) && type.symbol) { addRange(displayParts, symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, SymbolFormatFlags.WriteTypeParametersOrArguments)); } addSignatureDisplayParts(signature, allSignatures, TypeFormatFlags.WriteArrowStyleSignature); From f8c3a550caaba17f40a80bba7809cefbfe883f5f Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Fri, 21 Oct 2016 16:40:11 -0700 Subject: [PATCH 166/173] Check type parameters of the type alias declaration Fixes #11166 --- src/compiler/checker.ts | 1 + .../nounusedTypeParameterConstraint.errors.txt | 12 ------------ .../nounusedTypeParameterConstraint.symbols | 15 +++++++++++++++ .../nounusedTypeParameterConstraint.types | 15 +++++++++++++++ .../reference/typeAliasDeclarationEmit.errors.txt | 10 ++++++++++ 5 files changed, 41 insertions(+), 12 deletions(-) delete mode 100644 tests/baselines/reference/nounusedTypeParameterConstraint.errors.txt create mode 100644 tests/baselines/reference/nounusedTypeParameterConstraint.symbols create mode 100644 tests/baselines/reference/nounusedTypeParameterConstraint.types create mode 100644 tests/baselines/reference/typeAliasDeclarationEmit.errors.txt diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 369d61ce484..5d66221df2b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -17418,6 +17418,7 @@ namespace ts { checkGrammarDecorators(node) || checkGrammarModifiers(node); checkTypeNameIsReserved(node.name, Diagnostics.Type_alias_name_cannot_be_0); + checkTypeParameters(node.typeParameters); checkSourceElement(node.type); } diff --git a/tests/baselines/reference/nounusedTypeParameterConstraint.errors.txt b/tests/baselines/reference/nounusedTypeParameterConstraint.errors.txt deleted file mode 100644 index a5797b44d92..00000000000 --- a/tests/baselines/reference/nounusedTypeParameterConstraint.errors.txt +++ /dev/null @@ -1,12 +0,0 @@ -tests/cases/compiler/test.ts(1,10): error TS6133: 'IEventSourcedEntity' is declared but never used. - - -==== tests/cases/compiler/bar.ts (0 errors) ==== - - export interface IEventSourcedEntity { } - -==== tests/cases/compiler/test.ts (1 errors) ==== - import { IEventSourcedEntity } from "./bar"; - ~~~~~~~~~~~~~~~~~~~ -!!! error TS6133: 'IEventSourcedEntity' is declared but never used. - export type DomainEntityConstructor = { new(): TEntity; }; \ No newline at end of file diff --git a/tests/baselines/reference/nounusedTypeParameterConstraint.symbols b/tests/baselines/reference/nounusedTypeParameterConstraint.symbols new file mode 100644 index 00000000000..40364460f50 --- /dev/null +++ b/tests/baselines/reference/nounusedTypeParameterConstraint.symbols @@ -0,0 +1,15 @@ +=== tests/cases/compiler/bar.ts === + +export interface IEventSourcedEntity { } +>IEventSourcedEntity : Symbol(IEventSourcedEntity, Decl(bar.ts, 0, 0)) + +=== tests/cases/compiler/test.ts === +import { IEventSourcedEntity } from "./bar"; +>IEventSourcedEntity : Symbol(IEventSourcedEntity, Decl(test.ts, 0, 8)) + +export type DomainEntityConstructor = { new(): TEntity; }; +>DomainEntityConstructor : Symbol(DomainEntityConstructor, Decl(test.ts, 0, 44)) +>TEntity : Symbol(TEntity, Decl(test.ts, 1, 36)) +>IEventSourcedEntity : Symbol(IEventSourcedEntity, Decl(test.ts, 0, 8)) +>TEntity : Symbol(TEntity, Decl(test.ts, 1, 36)) + diff --git a/tests/baselines/reference/nounusedTypeParameterConstraint.types b/tests/baselines/reference/nounusedTypeParameterConstraint.types new file mode 100644 index 00000000000..8f2de483d26 --- /dev/null +++ b/tests/baselines/reference/nounusedTypeParameterConstraint.types @@ -0,0 +1,15 @@ +=== tests/cases/compiler/bar.ts === + +export interface IEventSourcedEntity { } +>IEventSourcedEntity : IEventSourcedEntity + +=== tests/cases/compiler/test.ts === +import { IEventSourcedEntity } from "./bar"; +>IEventSourcedEntity : any + +export type DomainEntityConstructor = { new(): TEntity; }; +>DomainEntityConstructor : new () => TEntity +>TEntity : TEntity +>IEventSourcedEntity : IEventSourcedEntity +>TEntity : TEntity + diff --git a/tests/baselines/reference/typeAliasDeclarationEmit.errors.txt b/tests/baselines/reference/typeAliasDeclarationEmit.errors.txt new file mode 100644 index 00000000000..2fd71844dc4 --- /dev/null +++ b/tests/baselines/reference/typeAliasDeclarationEmit.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/typeAliasDeclarationEmit.ts(4,37): error TS2314: Generic type 'callback' requires 1 type argument(s). + + +==== tests/cases/compiler/typeAliasDeclarationEmit.ts (1 errors) ==== + + export type callback = () => T; + + export type CallbackArray = () => T; + ~~~~~~~~ +!!! error TS2314: Generic type 'callback' requires 1 type argument(s). \ No newline at end of file From 95670c62519d1b0e105cbcb1e93924aa696386fb Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 24 Oct 2016 10:14:41 -0700 Subject: [PATCH 167/173] Perform a useful comparison. Fixes #11805 --- src/compiler/program.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index b619f005ded..a9c64f3ecbe 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -474,7 +474,7 @@ namespace ts { (oldOptions.baseUrl !== options.baseUrl) || (oldOptions.maxNodeModuleJsDepth !== options.maxNodeModuleJsDepth) || !arrayIsEqualTo(oldOptions.lib, options.lib) || - !arrayIsEqualTo(oldOptions.typeRoots, oldOptions.typeRoots) || + !arrayIsEqualTo(oldOptions.typeRoots, options.typeRoots) || !arrayIsEqualTo(oldOptions.rootDirs, options.rootDirs) || !equalOwnProperties(oldOptions.paths, options.paths)) { return false; From 287b54518d62c25dc12c4cdc17a599d1c7c4772b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=28=C2=B4=E3=83=BB=CF=89=E3=83=BB=EF=BD=80=29?= Date: Tue, 25 Oct 2016 01:45:07 +0800 Subject: [PATCH 168/173] Fix #10967, allow boolean flags to have explicit value (#11798) * Fix #10967, allow boolean flag to have explicit value * add commandLineParsing test for boolean flags --- src/compiler/commandLineParser.ts | 8 ++++- src/harness/unittests/commandLineParsing.ts | 35 ++++++++++++++++++++- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index d6c7dad0e8e..c4e079c6a13 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -599,7 +599,13 @@ namespace ts { i++; break; case "boolean": - options[opt.name] = true; + // boolean flag has optional value true, false, others + let optValue = args[i]; + options[opt.name] = optValue !== "false"; + // consume next argument as boolean flag value + if (optValue === "false" || optValue === "true") { + i++; + } break; case "string": options[opt.name] = args[i] || ""; diff --git a/src/harness/unittests/commandLineParsing.ts b/src/harness/unittests/commandLineParsing.ts index 67bc1e9b795..c15490738fa 100644 --- a/src/harness/unittests/commandLineParsing.ts +++ b/src/harness/unittests/commandLineParsing.ts @@ -1,4 +1,4 @@ -/// +/// /// namespace ts { @@ -338,5 +338,38 @@ namespace ts { } }); }); + + it("Parse explicit boolean flag value", () => { + assertParseResult(["--strictNullChecks", "false", "0.ts"], + { + errors: [], + fileNames: ["0.ts"], + options: { + strictNullChecks: false, + } + }); + }); + + it("Parse non boolean argument after boolean flag", () => { + assertParseResult(["--noImplicitAny", "t", "0.ts"], + { + errors: [], + fileNames: ["t", "0.ts"], + options: { + noImplicitAny: true, + } + }); + }); + + it("Parse implicit boolean flag value", () => { + assertParseResult(["--strictNullChecks"], + { + errors: [], + fileNames: [], + options: { + strictNullChecks: true, + } + }); + }); }); } From 1e32b6742ecb2dd172de6fc0950991a05649509d Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 24 Oct 2016 10:58:51 -0700 Subject: [PATCH 169/173] Add test case for destructured unused parameter --- .../unusedDestructuringParameters.js | 15 ++++++++++++ .../unusedDestructuringParameters.symbols | 16 +++++++++++++ .../unusedDestructuringParameters.types | 24 +++++++++++++++++++ .../compiler/unusedDestructuringParameters.ts | 5 ++++ 4 files changed, 60 insertions(+) create mode 100644 tests/baselines/reference/unusedDestructuringParameters.js create mode 100644 tests/baselines/reference/unusedDestructuringParameters.symbols create mode 100644 tests/baselines/reference/unusedDestructuringParameters.types create mode 100644 tests/cases/compiler/unusedDestructuringParameters.ts diff --git a/tests/baselines/reference/unusedDestructuringParameters.js b/tests/baselines/reference/unusedDestructuringParameters.js new file mode 100644 index 00000000000..9d47f6f9f1b --- /dev/null +++ b/tests/baselines/reference/unusedDestructuringParameters.js @@ -0,0 +1,15 @@ +//// [unusedDestructuringParameters.ts] +const f = ([a]) => { }; +f([1]); +const f2 = ({a}) => { }; +f2({ a: 10 }); + +//// [unusedDestructuringParameters.js] +var f = function (_a) { + var a = _a[0]; +}; +f([1]); +var f2 = function (_a) { + var a = _a.a; +}; +f2({ a: 10 }); diff --git a/tests/baselines/reference/unusedDestructuringParameters.symbols b/tests/baselines/reference/unusedDestructuringParameters.symbols new file mode 100644 index 00000000000..d40d54f3fce --- /dev/null +++ b/tests/baselines/reference/unusedDestructuringParameters.symbols @@ -0,0 +1,16 @@ +=== tests/cases/compiler/unusedDestructuringParameters.ts === +const f = ([a]) => { }; +>f : Symbol(f, Decl(unusedDestructuringParameters.ts, 0, 5)) +>a : Symbol(a, Decl(unusedDestructuringParameters.ts, 0, 12)) + +f([1]); +>f : Symbol(f, Decl(unusedDestructuringParameters.ts, 0, 5)) + +const f2 = ({a}) => { }; +>f2 : Symbol(f2, Decl(unusedDestructuringParameters.ts, 2, 5)) +>a : Symbol(a, Decl(unusedDestructuringParameters.ts, 2, 13)) + +f2({ a: 10 }); +>f2 : Symbol(f2, Decl(unusedDestructuringParameters.ts, 2, 5)) +>a : Symbol(a, Decl(unusedDestructuringParameters.ts, 3, 4)) + diff --git a/tests/baselines/reference/unusedDestructuringParameters.types b/tests/baselines/reference/unusedDestructuringParameters.types new file mode 100644 index 00000000000..ebbe1efbc30 --- /dev/null +++ b/tests/baselines/reference/unusedDestructuringParameters.types @@ -0,0 +1,24 @@ +=== tests/cases/compiler/unusedDestructuringParameters.ts === +const f = ([a]) => { }; +>f : ([a]: [any]) => void +>([a]) => { } : ([a]: [any]) => void +>a : any + +f([1]); +>f([1]) : void +>f : ([a]: [any]) => void +>[1] : [number] +>1 : 1 + +const f2 = ({a}) => { }; +>f2 : ({a}: { a: any; }) => void +>({a}) => { } : ({a}: { a: any; }) => void +>a : any + +f2({ a: 10 }); +>f2({ a: 10 }) : void +>f2 : ({a}: { a: any; }) => void +>{ a: 10 } : { a: number; } +>a : number +>10 : 10 + diff --git a/tests/cases/compiler/unusedDestructuringParameters.ts b/tests/cases/compiler/unusedDestructuringParameters.ts new file mode 100644 index 00000000000..748c9ea83fe --- /dev/null +++ b/tests/cases/compiler/unusedDestructuringParameters.ts @@ -0,0 +1,5 @@ +//@noUnusedParameters: true +const f = ([a]) => { }; +f([1]); +const f2 = ({a}) => { }; +f2({ a: 10 }); \ No newline at end of file From 4dc60282639aa22b87f6446b625fe360e525c3ed Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Mon, 24 Oct 2016 11:00:32 -0700 Subject: [PATCH 170/173] Fix #11650 add an error message for no source files parsing a tsconfig.json (#11743) * Fix #11650 add an error message for no source files parsing a tsconfig.json * Use the file name in error message * Use constants * Review comments: change message text --- src/compiler/commandLineParser.ts | 16 ++++- src/compiler/diagnosticMessages.json | 10 +++ src/harness/unittests/matchFiles.ts | 80 +++++++++++++++++------- src/harness/unittests/tsconfigParsing.ts | 67 ++++++++++++++++++++ 4 files changed, 148 insertions(+), 25 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index c4e079c6a13..686af79a6cc 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -912,6 +912,9 @@ namespace ts { if (hasProperty(json, "files")) { if (isArray(json["files"])) { fileNames = json["files"]; + if (fileNames.length === 0) { + errors.push(createCompilerDiagnostic(Diagnostics.The_files_list_in_config_file_0_is_empty, configFileName || "tsconfig.json")); + } } else { errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array")); @@ -954,7 +957,18 @@ namespace ts { includeSpecs = ["**/*"]; } - return matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors); + const result = matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors); + + if (result.fileNames.length === 0 && !hasProperty(json, "files") && resolutionStack.length === 0) { + errors.push( + createCompilerDiagnostic( + Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2, + configFileName || "tsconfig.json", + JSON.stringify(includeSpecs || []), + JSON.stringify(excludeSpecs || []))); + } + + return result; } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 21f04da488d..0c92f0acd7f 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3077,6 +3077,7 @@ "category": "Error", "code": 17010 }, + "Circularity detected while resolving configuration: {0}": { "category": "Error", "code": 18000 @@ -3085,6 +3086,15 @@ "category": "Error", "code": 18001 }, + "The 'files' list in config file '{0}' is empty.": { + "category": "Error", + "code": 18002 + }, + "No inputs were found in config file '{0}'. Specified 'include' paths were '{1}' and 'exclude' paths were '{2}'.": { + "category": "Error", + "code": 18003 + }, + "Add missing 'super()' call.": { "category": "Message", "code": 90001 diff --git a/src/harness/unittests/matchFiles.ts b/src/harness/unittests/matchFiles.ts index 6b499e56989..79e9668d073 100644 --- a/src/harness/unittests/matchFiles.ts +++ b/src/harness/unittests/matchFiles.ts @@ -3,6 +3,7 @@ namespace ts { const caseInsensitiveBasePath = "c:/dev/"; + const caseInsensitiveTsconfigPath = "c:/dev/tsconfig.json"; const caseInsensitiveHost = new Utils.MockParseConfigHost(caseInsensitiveBasePath, /*useCaseSensitiveFileNames*/ false, [ "c:/dev/a.ts", "c:/dev/a.d.ts", @@ -88,6 +89,8 @@ namespace ts { "c:/dev/g.min.js/.g/g.ts" ]); + const defaultExcludes = ["node_modules", "bower_components", "jspm_packages"]; + describe("matchFiles", () => { describe("with literal file list", () => { it("without exclusions", () => { @@ -189,11 +192,14 @@ namespace ts { }; const expected: ts.ParsedCommandLine = { options: {}, - errors: [], + errors: [ + ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2, + caseInsensitiveTsconfigPath, JSON.stringify(json.include), JSON.stringify(defaultExcludes)) + ], fileNames: [], wildcardDirectories: {}, }; - const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath); + const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath); assert.deepEqual(actual.fileNames, expected.fileNames); assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories); assert.deepEqual(actual.errors, expected.errors); @@ -207,11 +213,14 @@ namespace ts { }; const expected: ts.ParsedCommandLine = { options: {}, - errors: [], + errors: [ + ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2, + caseInsensitiveTsconfigPath, JSON.stringify(json.include), JSON.stringify(defaultExcludes)) + ], fileNames: [], wildcardDirectories: {}, }; - const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath); + const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath); assert.deepEqual(actual.fileNames, expected.fileNames); assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories); assert.deepEqual(actual.errors, expected.errors); @@ -551,13 +560,16 @@ namespace ts { }; const expected: ts.ParsedCommandLine = { options: {}, - errors: [], + errors: [ + ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2, + caseInsensitiveTsconfigPath, JSON.stringify(json.include), JSON.stringify(defaultExcludes)) + ], fileNames: [], wildcardDirectories: { "c:/dev": ts.WatchDirectoryFlags.Recursive }, }; - const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath); + const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath); assert.deepEqual(actual.fileNames, expected.fileNames); assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories); assert.deepEqual(actual.errors, expected.errors); @@ -619,7 +631,7 @@ namespace ts { it("with common package folders and no exclusions", () => { const json = { include: [ - "**/a.ts" + "**/a.ts" ] }; const expected: ts.ParsedCommandLine = { @@ -701,13 +713,16 @@ namespace ts { options: { allowJs: false }, - errors: [], + errors: [ + ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2, + caseInsensitiveTsconfigPath, JSON.stringify(json.include), JSON.stringify(defaultExcludes)) + ], fileNames: [], wildcardDirectories: { "c:/dev/js": ts.WatchDirectoryFlags.None } }; - const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath); + const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath); assert.deepEqual(actual.fileNames, expected.fileNames); assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories); assert.deepEqual(actual.errors, expected.errors); @@ -828,11 +843,14 @@ namespace ts { }; const expected: ts.ParsedCommandLine = { options: {}, - errors: [], + errors: [ + ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2, + caseInsensitiveTsconfigPath, JSON.stringify(json.include), JSON.stringify(json.exclude))] + , fileNames: [], wildcardDirectories: {} }; - const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath); + const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath); assert.deepEqual(actual.fileNames, expected.fileNames); assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories); assert.deepEqual(actual.errors, expected.errors); @@ -1030,12 +1048,14 @@ namespace ts { const expected: ts.ParsedCommandLine = { options: {}, errors: [ - ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, "**") + ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, "**"), + ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2, + caseInsensitiveTsconfigPath, JSON.stringify(json.include), JSON.stringify(defaultExcludes)) ], fileNames: [], wildcardDirectories: {} }; - const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath); + const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath); assert.deepEqual(actual.fileNames, expected.fileNames); assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories); assert.deepEqual(actual.errors, expected.errors); @@ -1051,11 +1071,14 @@ namespace ts { }; const expected: ts.ParsedCommandLine = { options: {}, - errors: [], + errors: [ + ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2, + caseInsensitiveTsconfigPath, JSON.stringify(json.include), JSON.stringify(json.exclude)) + ], fileNames: [], wildcardDirectories: {} }; - const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath); + const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath); assert.deepEqual(actual.fileNames, expected.fileNames); assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories); assert.deepEqual(actual.errors, expected.errors); @@ -1071,12 +1094,14 @@ namespace ts { const expected: ts.ParsedCommandLine = { options: {}, errors: [ - ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0, "**/x/**/*") + ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0, "**/x/**/*"), + ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2, + caseInsensitiveTsconfigPath, JSON.stringify(json.include), JSON.stringify(defaultExcludes)) ], fileNames: [], wildcardDirectories: {} }; - const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath); + const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath); assert.deepEqual(actual.fileNames, expected.fileNames); assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories); assert.deepEqual(actual.errors, expected.errors); @@ -1122,12 +1147,14 @@ namespace ts { const expected: ts.ParsedCommandLine = { options: {}, errors: [ - ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, "**/../*") + ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, "**/../*"), + ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2, + caseInsensitiveTsconfigPath, JSON.stringify(json.include), JSON.stringify(defaultExcludes)) ], fileNames: [], wildcardDirectories: {} }; - const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath); + const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath); assert.deepEqual(actual.fileNames, expected.fileNames); assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories); assert.deepEqual(actual.errors, expected.errors); @@ -1142,12 +1169,14 @@ namespace ts { const expected: ts.ParsedCommandLine = { options: {}, errors: [ - ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, "**/y/../*") + ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, "**/y/../*"), + ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2, + caseInsensitiveTsconfigPath, JSON.stringify(json.include), JSON.stringify(defaultExcludes)) ], fileNames: [], wildcardDirectories: {} }; - const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath); + const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath); assert.deepEqual(actual.fileNames, expected.fileNames); assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories); assert.deepEqual(actual.errors, expected.errors); @@ -1195,7 +1224,7 @@ namespace ts { const expected: ts.ParsedCommandLine = { options: {}, errors: [ - ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, "**/y/..") + ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, "**/y/..") ], fileNames: [ "c:/dev/a.ts", @@ -1320,11 +1349,14 @@ namespace ts { }; const expected: ts.ParsedCommandLine = { options: {}, - errors: [], + errors: [ + ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2, + caseInsensitiveTsconfigPath, JSON.stringify(json.include), JSON.stringify(json.exclude)) + ], fileNames: [], wildcardDirectories: {} }; - const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveDottedFoldersHost, caseInsensitiveBasePath); + const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveDottedFoldersHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath); assert.deepEqual(actual.fileNames, expected.fileNames); assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories); assert.deepEqual(actual.errors, expected.errors); diff --git a/src/harness/unittests/tsconfigParsing.ts b/src/harness/unittests/tsconfigParsing.ts index f38a05b9cfa..7b980cdd2d8 100644 --- a/src/harness/unittests/tsconfigParsing.ts +++ b/src/harness/unittests/tsconfigParsing.ts @@ -28,6 +28,14 @@ namespace ts { assert.isTrue(arrayIsEqualTo(parsed.fileNames.sort(), expectedFileList.sort())); } + function assertParseFileDiagnostics(jsonText: string, configFileName: string, basePath: string, allFileList: string[], expectedDiagnosticCode: number) { + const json = JSON.parse(jsonText); + const host: ParseConfigHost = new Utils.MockParseConfigHost(basePath, true, allFileList); + const parsed = ts.parseJsonConfigFileContent(json, host, basePath, /*existingOptions*/ undefined, configFileName); + assert.isTrue(parsed.errors.length >= 0); + assert.isTrue(parsed.errors.filter(e => e.code === expectedDiagnosticCode).length > 0, `Expected error code ${expectedDiagnosticCode} to be in ${JSON.stringify(parsed.errors)}`); + } + it("returns empty config for file with only whitespaces", () => { assertParseResult("", { config : {} }); assertParseResult(" ", { config : {} }); @@ -202,5 +210,64 @@ namespace ts { assert.isTrue(diagnostics.length === 2); assert.equal(JSON.stringify(configJsonObject), JSON.stringify(expectedResult)); }); + + it("generates errors for empty files list", () => { + const content = `{ + "files": [] + }`; + assertParseFileDiagnostics(content, + "/apath/tsconfig.json", + "tests/cases/unittests", + ["/apath/a.ts"], + Diagnostics.The_files_list_in_config_file_0_is_empty.code); + }); + + it("generates errors for directory with no .ts files", () => { + const content = `{ + }`; + assertParseFileDiagnostics(content, + "/apath/tsconfig.json", + "tests/cases/unittests", + ["/apath/a.js"], + Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2.code); + }); + + it("generates errors for empty directory", () => { + const content = `{ + "compilerOptions": { + "allowJs": true + } + }`; + assertParseFileDiagnostics(content, + "/apath/tsconfig.json", + "tests/cases/unittests", + [], + Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2.code); + }); + + it("generates errors for empty include", () => { + const content = `{ + "include": [] + }`; + assertParseFileDiagnostics(content, + "/apath/tsconfig.json", + "tests/cases/unittests", + ["/apath/a.ts"], + Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2.code); + }); + + it("generates errors for includes with outDir", () => { + const content = `{ + "compilerOptions": { + "outDir": "./" + }, + "include": ["**/*"] + }`; + assertParseFileDiagnostics(content, + "/apath/tsconfig.json", + "tests/cases/unittests", + ["/apath/a.ts"], + Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2.code); + }); }); } From c1c670f8f6d78f5ed6b02efeeef07e27ba619c5d Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 24 Oct 2016 11:12:15 -0700 Subject: [PATCH 171/173] Report error on unused destructured parameters Fixes #11795 --- src/compiler/checker.ts | 10 ++++---- .../unusedDestructuringParameters.errors.txt | 15 ++++++++++++ .../unusedDestructuringParameters.js | 8 ++++++- .../unusedDestructuringParameters.symbols | 16 ------------- .../unusedDestructuringParameters.types | 24 ------------------- .../unusedParametersWithUnderscore.errors.txt | 14 +---------- .../compiler/unusedDestructuringParameters.ts | 4 +++- 7 files changed, 31 insertions(+), 60 deletions(-) create mode 100644 tests/baselines/reference/unusedDestructuringParameters.errors.txt delete mode 100644 tests/baselines/reference/unusedDestructuringParameters.symbols delete mode 100644 tests/baselines/reference/unusedDestructuringParameters.types diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5b85a932c05..de807600066 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -15832,12 +15832,12 @@ namespace ts { for (const key in node.locals) { const local = node.locals[key]; if (!local.isReferenced) { - if (local.valueDeclaration && local.valueDeclaration.kind === SyntaxKind.Parameter) { - const parameter = local.valueDeclaration; + if (local.valueDeclaration && getRootDeclaration(local.valueDeclaration).kind === SyntaxKind.Parameter) { + const parameter = getRootDeclaration(local.valueDeclaration); if (compilerOptions.noUnusedParameters && !isParameterPropertyDeclaration(parameter) && !parameterIsThisKeyword(parameter) && - !parameterNameStartsWithUnderscore(parameter)) { + !parameterNameStartsWithUnderscore(local.valueDeclaration.name)) { error(local.valueDeclaration.name, Diagnostics._0_is_declared_but_never_used, local.name); } } @@ -15861,8 +15861,8 @@ namespace ts { error(node, Diagnostics._0_is_declared_but_never_used, name); } - function parameterNameStartsWithUnderscore(parameter: ParameterDeclaration) { - return parameter.name && isIdentifierThatStartsWithUnderScore(parameter.name); + function parameterNameStartsWithUnderscore(parameterName: DeclarationName) { + return parameterName && isIdentifierThatStartsWithUnderScore(parameterName); } function isIdentifierThatStartsWithUnderScore(node: Node) { diff --git a/tests/baselines/reference/unusedDestructuringParameters.errors.txt b/tests/baselines/reference/unusedDestructuringParameters.errors.txt new file mode 100644 index 00000000000..b6814df6b7a --- /dev/null +++ b/tests/baselines/reference/unusedDestructuringParameters.errors.txt @@ -0,0 +1,15 @@ +tests/cases/compiler/unusedDestructuringParameters.ts(1,13): error TS6133: 'a' is declared but never used. +tests/cases/compiler/unusedDestructuringParameters.ts(3,14): error TS6133: 'a' is declared but never used. + + +==== tests/cases/compiler/unusedDestructuringParameters.ts (2 errors) ==== + const f = ([a]) => { }; + ~ +!!! error TS6133: 'a' is declared but never used. + f([1]); + const f2 = ({a}) => { }; + ~ +!!! error TS6133: 'a' is declared but never used. + f2({ a: 10 }); + const f3 = ([_]) => { }; + f3([10]); \ No newline at end of file diff --git a/tests/baselines/reference/unusedDestructuringParameters.js b/tests/baselines/reference/unusedDestructuringParameters.js index 9d47f6f9f1b..ca0ab80b86e 100644 --- a/tests/baselines/reference/unusedDestructuringParameters.js +++ b/tests/baselines/reference/unusedDestructuringParameters.js @@ -2,7 +2,9 @@ const f = ([a]) => { }; f([1]); const f2 = ({a}) => { }; -f2({ a: 10 }); +f2({ a: 10 }); +const f3 = ([_]) => { }; +f3([10]); //// [unusedDestructuringParameters.js] var f = function (_a) { @@ -13,3 +15,7 @@ var f2 = function (_a) { var a = _a.a; }; f2({ a: 10 }); +var f3 = function (_a) { + var _ = _a[0]; +}; +f3([10]); diff --git a/tests/baselines/reference/unusedDestructuringParameters.symbols b/tests/baselines/reference/unusedDestructuringParameters.symbols deleted file mode 100644 index d40d54f3fce..00000000000 --- a/tests/baselines/reference/unusedDestructuringParameters.symbols +++ /dev/null @@ -1,16 +0,0 @@ -=== tests/cases/compiler/unusedDestructuringParameters.ts === -const f = ([a]) => { }; ->f : Symbol(f, Decl(unusedDestructuringParameters.ts, 0, 5)) ->a : Symbol(a, Decl(unusedDestructuringParameters.ts, 0, 12)) - -f([1]); ->f : Symbol(f, Decl(unusedDestructuringParameters.ts, 0, 5)) - -const f2 = ({a}) => { }; ->f2 : Symbol(f2, Decl(unusedDestructuringParameters.ts, 2, 5)) ->a : Symbol(a, Decl(unusedDestructuringParameters.ts, 2, 13)) - -f2({ a: 10 }); ->f2 : Symbol(f2, Decl(unusedDestructuringParameters.ts, 2, 5)) ->a : Symbol(a, Decl(unusedDestructuringParameters.ts, 3, 4)) - diff --git a/tests/baselines/reference/unusedDestructuringParameters.types b/tests/baselines/reference/unusedDestructuringParameters.types deleted file mode 100644 index ebbe1efbc30..00000000000 --- a/tests/baselines/reference/unusedDestructuringParameters.types +++ /dev/null @@ -1,24 +0,0 @@ -=== tests/cases/compiler/unusedDestructuringParameters.ts === -const f = ([a]) => { }; ->f : ([a]: [any]) => void ->([a]) => { } : ([a]: [any]) => void ->a : any - -f([1]); ->f([1]) : void ->f : ([a]: [any]) => void ->[1] : [number] ->1 : 1 - -const f2 = ({a}) => { }; ->f2 : ({a}: { a: any; }) => void ->({a}) => { } : ({a}: { a: any; }) => void ->a : any - -f2({ a: 10 }); ->f2({ a: 10 }) : void ->f2 : ({a}: { a: any; }) => void ->{ a: 10 } : { a: number; } ->a : number ->10 : 10 - diff --git a/tests/baselines/reference/unusedParametersWithUnderscore.errors.txt b/tests/baselines/reference/unusedParametersWithUnderscore.errors.txt index adfe7bb9bc1..5e9ffa993b0 100644 --- a/tests/baselines/reference/unusedParametersWithUnderscore.errors.txt +++ b/tests/baselines/reference/unusedParametersWithUnderscore.errors.txt @@ -2,15 +2,11 @@ tests/cases/compiler/unusedParametersWithUnderscore.ts(2,12): error TS6133: 'a' tests/cases/compiler/unusedParametersWithUnderscore.ts(2,19): error TS6133: 'c' is declared but never used. tests/cases/compiler/unusedParametersWithUnderscore.ts(2,27): error TS6133: 'd' is declared but never used. tests/cases/compiler/unusedParametersWithUnderscore.ts(2,29): error TS6133: 'e___' is declared but never used. -tests/cases/compiler/unusedParametersWithUnderscore.ts(6,14): error TS6133: '_a' is declared but never used. -tests/cases/compiler/unusedParametersWithUnderscore.ts(6,18): error TS6133: '___b' is declared but never used. -tests/cases/compiler/unusedParametersWithUnderscore.ts(9,14): error TS6133: '_a' is declared but never used. -tests/cases/compiler/unusedParametersWithUnderscore.ts(9,19): error TS6133: '___b' is declared but never used. tests/cases/compiler/unusedParametersWithUnderscore.ts(12,16): error TS6133: 'arg' is declared but never used. tests/cases/compiler/unusedParametersWithUnderscore.ts(18,13): error TS6133: 'arg' is declared but never used. -==== tests/cases/compiler/unusedParametersWithUnderscore.ts (10 errors) ==== +==== tests/cases/compiler/unusedParametersWithUnderscore.ts (6 errors) ==== function f(a, _b, c, ___, d,e___, _f) { ~ @@ -25,17 +21,9 @@ tests/cases/compiler/unusedParametersWithUnderscore.ts(18,13): error TS6133: 'ar function f2({_a, __b}) { - ~~ -!!! error TS6133: '_a' is declared but never used. - ~~~ -!!! error TS6133: '___b' is declared but never used. } function f3([_a, ,__b]) { - ~~ -!!! error TS6133: '_a' is declared but never used. - ~~~ -!!! error TS6133: '___b' is declared but never used. } function f4(...arg) { diff --git a/tests/cases/compiler/unusedDestructuringParameters.ts b/tests/cases/compiler/unusedDestructuringParameters.ts index 748c9ea83fe..7c042351049 100644 --- a/tests/cases/compiler/unusedDestructuringParameters.ts +++ b/tests/cases/compiler/unusedDestructuringParameters.ts @@ -2,4 +2,6 @@ const f = ([a]) => { }; f([1]); const f2 = ({a}) => { }; -f2({ a: 10 }); \ No newline at end of file +f2({ a: 10 }); +const f3 = ([_]) => { }; +f3([10]); \ No newline at end of file From b7ea3e5bddd73d2827d6355c1d688267f64bba17 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Mon, 24 Oct 2016 11:19:41 -0700 Subject: [PATCH 172/173] treat ambient non-aliased 'require' as commonjs 'require' --- src/compiler/checker.ts | 33 ++++++++++++++++--- .../reference/ambientRequireFunction.js | 21 ++++++++++++ .../reference/ambientRequireFunction.symbols | 27 +++++++++++++++ .../reference/ambientRequireFunction.types | 30 +++++++++++++++++ .../reference/localRequireFunction.js | 15 +++++++++ .../reference/localRequireFunction.symbols | 18 ++++++++++ .../reference/localRequireFunction.types | 24 ++++++++++++++ .../cases/compiler/ambientRequireFunction.ts | 17 ++++++++++ tests/cases/compiler/localRequireFunction.ts | 11 +++++++ tests/webTestServer.ts | 10 +++--- 10 files changed, 197 insertions(+), 9 deletions(-) create mode 100644 tests/baselines/reference/ambientRequireFunction.js create mode 100644 tests/baselines/reference/ambientRequireFunction.symbols create mode 100644 tests/baselines/reference/ambientRequireFunction.types create mode 100644 tests/baselines/reference/localRequireFunction.js create mode 100644 tests/baselines/reference/localRequireFunction.symbols create mode 100644 tests/baselines/reference/localRequireFunction.types create mode 100644 tests/cases/compiler/ambientRequireFunction.ts create mode 100644 tests/cases/compiler/localRequireFunction.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 369d61ce484..5aba1b46006 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -12819,16 +12819,41 @@ namespace ts { } // In JavaScript files, calls to any identifier 'require' are treated as external module imports - if (isInJavaScriptFile(node) && - isRequireCall(node, /*checkArgumentIsStringLiteral*/true) && - // Make sure require is not a local function - !resolveName(node.expression, (node.expression).text, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined)) { + if (isInJavaScriptFile(node) && isCommonJsRequire(node)) { return resolveExternalModuleTypeByLiteral(node.arguments[0]); } return getReturnTypeOfSignature(signature); } + function isCommonJsRequire(node: Node) { + if (!isRequireCall(node, /*checkArgumentIsStringLiteral*/true)) { + return false; + } + // Make sure require is not a local function + const resolvedRequire = resolveName(node.expression, (node.expression).text, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + if (!resolvedRequire) { + // project does not contain symbol named 'require' - assume commonjs require + return true; + } + // project includes symbol named 'require' - make sure that it it ambient and local non-alias + if (resolvedRequire.flags & SymbolFlags.Alias) { + return false; + } + + const targetDeclarationKind = resolvedRequire.flags & SymbolFlags.Function + ? SyntaxKind.FunctionDeclaration + : resolvedRequire.flags & SymbolFlags.Variable + ? SyntaxKind.VariableDeclaration + : SyntaxKind.Unknown; + if (targetDeclarationKind !== SyntaxKind.Unknown) { + const decl = getDeclarationOfKind(resolvedRequire, targetDeclarationKind); + // function/variable declaration should be ambient + return isInAmbientContext(decl); + } + return false; + } + function checkTaggedTemplateExpression(node: TaggedTemplateExpression): Type { return getReturnTypeOfSignature(getResolvedSignature(node)); } diff --git a/tests/baselines/reference/ambientRequireFunction.js b/tests/baselines/reference/ambientRequireFunction.js new file mode 100644 index 00000000000..cd00b287c82 --- /dev/null +++ b/tests/baselines/reference/ambientRequireFunction.js @@ -0,0 +1,21 @@ +//// [tests/cases/compiler/ambientRequireFunction.ts] //// + +//// [node.d.ts] + + +declare function require(moduleName: string): any; + +declare module "fs" { + export function readFileSync(s: string): string; +} + +//// [app.js] +/// + +const fs = require("fs"); +const text = fs.readFileSync("/a/b/c"); + +//// [app.js] +/// +var fs = require("fs"); +var text = fs.readFileSync("/a/b/c"); diff --git a/tests/baselines/reference/ambientRequireFunction.symbols b/tests/baselines/reference/ambientRequireFunction.symbols new file mode 100644 index 00000000000..6afb47e37fb --- /dev/null +++ b/tests/baselines/reference/ambientRequireFunction.symbols @@ -0,0 +1,27 @@ +=== tests/cases/compiler/app.js === +/// + +const fs = require("fs"); +>fs : Symbol(fs, Decl(app.js, 2, 5)) +>require : Symbol(require, Decl(node.d.ts, 0, 0)) +>"fs" : Symbol("fs", Decl(node.d.ts, 2, 50)) + +const text = fs.readFileSync("/a/b/c"); +>text : Symbol(text, Decl(app.js, 3, 5)) +>fs.readFileSync : Symbol(readFileSync, Decl(node.d.ts, 4, 21)) +>fs : Symbol(fs, Decl(app.js, 2, 5)) +>readFileSync : Symbol(readFileSync, Decl(node.d.ts, 4, 21)) + +=== tests/cases/compiler/node.d.ts === + + +declare function require(moduleName: string): any; +>require : Symbol(require, Decl(node.d.ts, 0, 0)) +>moduleName : Symbol(moduleName, Decl(node.d.ts, 2, 25)) + +declare module "fs" { + export function readFileSync(s: string): string; +>readFileSync : Symbol(readFileSync, Decl(node.d.ts, 4, 21)) +>s : Symbol(s, Decl(node.d.ts, 5, 33)) +} + diff --git a/tests/baselines/reference/ambientRequireFunction.types b/tests/baselines/reference/ambientRequireFunction.types new file mode 100644 index 00000000000..7b01a59268f --- /dev/null +++ b/tests/baselines/reference/ambientRequireFunction.types @@ -0,0 +1,30 @@ +=== tests/cases/compiler/app.js === +/// + +const fs = require("fs"); +>fs : typeof "fs" +>require("fs") : typeof "fs" +>require : (moduleName: string) => any +>"fs" : "fs" + +const text = fs.readFileSync("/a/b/c"); +>text : string +>fs.readFileSync("/a/b/c") : string +>fs.readFileSync : (s: string) => string +>fs : typeof "fs" +>readFileSync : (s: string) => string +>"/a/b/c" : "/a/b/c" + +=== tests/cases/compiler/node.d.ts === + + +declare function require(moduleName: string): any; +>require : (moduleName: string) => any +>moduleName : string + +declare module "fs" { + export function readFileSync(s: string): string; +>readFileSync : (s: string) => string +>s : string +} + diff --git a/tests/baselines/reference/localRequireFunction.js b/tests/baselines/reference/localRequireFunction.js new file mode 100644 index 00000000000..1ae20821a07 --- /dev/null +++ b/tests/baselines/reference/localRequireFunction.js @@ -0,0 +1,15 @@ +//// [app.js] + +function require(a) { + return a; +} + +const fs = require("fs"); +const text = fs.readFileSync("/a/b/c"); + +//// [app.js] +function require(a) { + return a; +} +var fs = require("fs"); +var text = fs.readFileSync("/a/b/c"); diff --git a/tests/baselines/reference/localRequireFunction.symbols b/tests/baselines/reference/localRequireFunction.symbols new file mode 100644 index 00000000000..b977328f0ef --- /dev/null +++ b/tests/baselines/reference/localRequireFunction.symbols @@ -0,0 +1,18 @@ +=== tests/cases/compiler/app.js === + +function require(a) { +>require : Symbol(require, Decl(app.js, 0, 0)) +>a : Symbol(a, Decl(app.js, 1, 17)) + + return a; +>a : Symbol(a, Decl(app.js, 1, 17)) +} + +const fs = require("fs"); +>fs : Symbol(fs, Decl(app.js, 5, 5)) +>require : Symbol(require, Decl(app.js, 0, 0)) + +const text = fs.readFileSync("/a/b/c"); +>text : Symbol(text, Decl(app.js, 6, 5)) +>fs : Symbol(fs, Decl(app.js, 5, 5)) + diff --git a/tests/baselines/reference/localRequireFunction.types b/tests/baselines/reference/localRequireFunction.types new file mode 100644 index 00000000000..4b5c7578cd9 --- /dev/null +++ b/tests/baselines/reference/localRequireFunction.types @@ -0,0 +1,24 @@ +=== tests/cases/compiler/app.js === + +function require(a) { +>require : (a: any) => any +>a : any + + return a; +>a : any +} + +const fs = require("fs"); +>fs : any +>require("fs") : any +>require : (a: any) => any +>"fs" : "fs" + +const text = fs.readFileSync("/a/b/c"); +>text : any +>fs.readFileSync("/a/b/c") : any +>fs.readFileSync : any +>fs : any +>readFileSync : any +>"/a/b/c" : "/a/b/c" + diff --git a/tests/cases/compiler/ambientRequireFunction.ts b/tests/cases/compiler/ambientRequireFunction.ts new file mode 100644 index 00000000000..ce9019e00bc --- /dev/null +++ b/tests/cases/compiler/ambientRequireFunction.ts @@ -0,0 +1,17 @@ +// @module: commonjs +// @allowJs: true +// @outDir: ./out/ + +// @filename: node.d.ts + +declare function require(moduleName: string): any; + +declare module "fs" { + export function readFileSync(s: string): string; +} + +// @filename: app.js +/// + +const fs = require("fs"); +const text = fs.readFileSync("/a/b/c"); \ No newline at end of file diff --git a/tests/cases/compiler/localRequireFunction.ts b/tests/cases/compiler/localRequireFunction.ts new file mode 100644 index 00000000000..c8f3c2452ff --- /dev/null +++ b/tests/cases/compiler/localRequireFunction.ts @@ -0,0 +1,11 @@ +// @module: commonjs +// @allowJs: true +// @outDir: ./out/ + +// @filename: app.js +function require(a) { + return a; +} + +const fs = require("fs"); +const text = fs.readFileSync("/a/b/c"); \ No newline at end of file diff --git a/tests/webTestServer.ts b/tests/webTestServer.ts index 97027dfdd49..3d23ef3e961 100644 --- a/tests/webTestServer.ts +++ b/tests/webTestServer.ts @@ -128,7 +128,7 @@ function dir(dirPath: string, spec?: string, options?: any) { // fs.rmdirSync won't delete directories with files in it function deleteFolderRecursive(dirPath: string) { if (fs.existsSync(dirPath)) { - fs.readdirSync(dirPath).forEach((file, index) => { + fs.readdirSync(dirPath).forEach((file) => { const curPath = path.join(path, file); if (fs.statSync(curPath).isDirectory()) { // recurse deleteFolderRecursive(curPath); @@ -141,7 +141,7 @@ function deleteFolderRecursive(dirPath: string) { } }; -function writeFile(path: string, data: any, opts: { recursive: boolean }) { +function writeFile(path: string, data: any) { ensureDirectoriesExist(getDirectoryPath(path)); fs.writeFileSync(path, data); } @@ -208,7 +208,7 @@ enum RequestType { Unknown } -function getRequestOperation(req: http.ServerRequest, filename: string) { +function getRequestOperation(req: http.ServerRequest) { if (req.method === "GET" && req.url.indexOf("?") === -1) { if (req.url.indexOf(".") !== -1) return RequestType.GetFile; else return RequestType.GetDir; @@ -258,7 +258,7 @@ function handleRequestOperation(req: http.ServerRequest, res: http.ServerRespons break; case RequestType.WriteFile: processPost(req, res, (data) => { - writeFile(reqPath, data, { recursive: true }); + writeFile(reqPath, data); }); send(ResponseCode.Success, res, undefined); break; @@ -306,7 +306,7 @@ http.createServer((req: http.ServerRequest, res: http.ServerResponse) => { log(`${req.method} ${req.url}`); const uri = url.parse(req.url).pathname; const reqPath = path.join(process.cwd(), uri); - const operation = getRequestOperation(req, reqPath); + const operation = getRequestOperation(req); handleRequestOperation(req, res, operation, reqPath); }).listen(port); From 7b684214fa5a88b4c885614fa5a8dd0de1d5a94a Mon Sep 17 00:00:00 2001 From: Alexander Rusakov Date: Mon, 24 Oct 2016 23:18:46 +0300 Subject: [PATCH 173/173] Fix #11545 ('export as namespace foo' occurs EOF without semicolon) (#11797) --- src/compiler/parser.ts | 2 +- tests/baselines/reference/exportAsNamespace.d.symbols | 9 +++++++++ tests/baselines/reference/exportAsNamespace.d.types | 9 +++++++++ tests/cases/compiler/exportAsNamespace.d.ts | 4 ++++ 4 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/exportAsNamespace.d.symbols create mode 100644 tests/baselines/reference/exportAsNamespace.d.types create mode 100644 tests/cases/compiler/exportAsNamespace.d.ts diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 8cdbf956d42..7048677e8a4 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -5472,7 +5472,7 @@ namespace ts { exportDeclaration.name = parseIdentifier(); - parseExpected(SyntaxKind.SemicolonToken); + parseSemicolon(); return finishNode(exportDeclaration); } diff --git a/tests/baselines/reference/exportAsNamespace.d.symbols b/tests/baselines/reference/exportAsNamespace.d.symbols new file mode 100644 index 00000000000..ca65cb2574e --- /dev/null +++ b/tests/baselines/reference/exportAsNamespace.d.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/exportAsNamespace.d.ts === +// issue: https://github.com/Microsoft/TypeScript/issues/11545 + +export var X; +>X : Symbol(X, Decl(exportAsNamespace.d.ts, 2, 10)) + +export as namespace N +>N : Symbol(N, Decl(exportAsNamespace.d.ts, 2, 13)) + diff --git a/tests/baselines/reference/exportAsNamespace.d.types b/tests/baselines/reference/exportAsNamespace.d.types new file mode 100644 index 00000000000..706857bf8ed --- /dev/null +++ b/tests/baselines/reference/exportAsNamespace.d.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/exportAsNamespace.d.ts === +// issue: https://github.com/Microsoft/TypeScript/issues/11545 + +export var X; +>X : any + +export as namespace N +>N : typeof N + diff --git a/tests/cases/compiler/exportAsNamespace.d.ts b/tests/cases/compiler/exportAsNamespace.d.ts new file mode 100644 index 00000000000..755d4fdb2a9 --- /dev/null +++ b/tests/cases/compiler/exportAsNamespace.d.ts @@ -0,0 +1,4 @@ +// issue: https://github.com/Microsoft/TypeScript/issues/11545 + +export var X; +export as namespace N \ No newline at end of file